Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1415814ybb; Sun, 29 Mar 2020 04:12:13 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtZu5lUlO5uyQwrUG3i26SgWm6bHFQbh0Fo9BDPKo0CNBqw19T/zLA9778wLWWkefjtspCg X-Received: by 2002:aca:52d0:: with SMTP id g199mr4580508oib.59.1585480332865; Sun, 29 Mar 2020 04:12:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585480332; cv=none; d=google.com; s=arc-20160816; b=BoHwxRgMlX0P76kXjavINjNgkNUCRiBonPQFE1gzfEJNGxt7azSt/aTvQSPSpGDYqU jt6kO4qaqTfYdzoY7MvwksAICvw/ovLdmjcFx2vr+3UDYeQw+R9BWcnBP9BNwnN3RRZd ia78/pc5jAZ2f0wpbQyvdAvz/zGHFroZED5frXVh/Y6r/dCS8bTzXbm5dNiaGLYTIfBw HteZhpUVH834kfsSuOE5FZ6lKkmj+yf5Oo1wyN8FyyBUmbJWZ9oiMHmgE6sOZBD/t980 8uK40+REF8LuPa6I4wcmqcDingBb0+63MGBC/A4+VvwavYrOfqqCM23ynzcgLK9yK7IE MGYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=q/yD6c2PKgnHnFk14kJeOz5sQTjlHMyFhj12xzI5L0o=; b=mSpRB70o7FgP6dNllTfjfHRmFIgzMtOJ27gjkCS2NlSaD/b1qDcRUJh//VkNDHXQgC iLmAeHdtnllLBJtCzDmzsueX6MHRdsQWFnWwK2avYl/Yyz4TVFZNO+BX/ckZY/sGHGNR Dd4yUm5yeyMJJ+3/O8VSXIZVdhVw8rifBjyg5vH1F96pOUsdJM093aHw5+LMbfzfdYjS D1h84WUCJOmJsmOF0ZRemEYMU1CGC7TlNDcyDgYTuc4HfNo9dT/n7ZNOIdSxwbgDf5Mu TJfZGTKRBgjA1XbluCVxNFKedBFy1F5qLvePDpGwtBcVem430Yj99dEg1FCv4Dtgzc0C aoKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="nCv/zjYj"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 184si4485175oif.56.2020.03.29.04.12.00; Sun, 29 Mar 2020 04:12:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="nCv/zjYj"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728071AbgC2LKv (ORCPT + 99 others); Sun, 29 Mar 2020 07:10:51 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:38109 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727875AbgC2LKu (ORCPT ); Sun, 29 Mar 2020 07:10:50 -0400 Received: by mail-ed1-f65.google.com with SMTP id e5so17343091edq.5; Sun, 29 Mar 2020 04:10:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=q/yD6c2PKgnHnFk14kJeOz5sQTjlHMyFhj12xzI5L0o=; b=nCv/zjYj0AUp65ssXNemevbr+jeDmSSwzv4oAtnNOcoHqkNMcQzwvIuXHE6fYpivQb GSrWblRItvs7fcqn4bukBOyHksiwt9kRibYK263UxHKRrX6TTCpeF6UC6jFnrqEjmW33 Sw+YFWhYjz6I2Rpi2HOjejms1jXVnCyLWHZalL31bvPmH94hQBVkbKfZFdyH6/sK21Wh swl0rYIuWAnvQJ8/+Gfmo77cnhZqDKGYDR6HBL4J0+tm0P0xORA91IwDrPfifNar55HZ yXFUoCXxglhXpVmbhccVFJ6QJKrWdBsVzRvYMyeBw/QD2Gt1NCttjnzBJDlDF7ZKsq8f YVqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=q/yD6c2PKgnHnFk14kJeOz5sQTjlHMyFhj12xzI5L0o=; b=LOn3I3r5IH99U1ilmptpbHybRNHOrcSWSJE+1Hbn3VtEZ23qoLG3omznw95lMhQY1I 7hyQZ3754OhYC14HaTN16FXp8wwe8ztjT/Dqeny6GG3KfWBzYTjF/1k5PAv5DFCgU1iN 0re68VkB+uO0X/eFp3f5ve2zhP6VpTUaXfG1XODxA5DPpaBzBNbU6XbMf9i6x7iYdhJY Nrt8sIHAyKhHNFbeEWMPAx2Lhr9uq9HURQOa+fVYLymSvw+c6I/sLF1pfWYNDjEsPF7b XViEPw+fzsEVQ8TxiROYeZGp5YR7rwHQZqVSkBojt9YJxodNekNBoFBJvjIne4SX5tsa VMng== X-Gm-Message-State: ANhLgQ07hjKO3rut040H/rxZsGz7jgTRDPYJg20GixAAK9g+DgKceGVe Un+iO+VqL2jpcFkMLgiaUg5ShI+JpQUhwH8v03s= X-Received: by 2002:a17:906:449:: with SMTP id e9mr6493292eja.239.1585480248014; Sun, 29 Mar 2020 04:10:48 -0700 (PDT) MIME-Version: 1.0 References: <20200329005202.17926-1-olteanv@gmail.com> <20200329005202.17926-5-olteanv@gmail.com> In-Reply-To: <20200329005202.17926-5-olteanv@gmail.com> From: Vladimir Oltean Date: Sun, 29 Mar 2020 14:10:36 +0300 Message-ID: Subject: Re: [PATCH net-next 4/6] net: dsa: felix: add port policers To: Andrew Lunn , Florian Fainelli , Vivien Didelot , "David S. Miller" Cc: Jiri Pirko , Ido Schimmel , Jakub Kicinski , netdev , Xiaoliang Yang , lkml , Horatiu Vultur , Alexandre Belloni , "Allan W. Nielsen" , Joergen Andreasen , Microchip Linux Driver Support , "Y.b. Lu" , Alexandru Marginean , Po Liu , Claudiu Manoil , Li Yang Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 29 Mar 2020 at 02:53, Vladimir Oltean wrote: > > From: Vladimir Oltean > > This patch is a trivial passthrough towards the ocelot library, which > support port policers since commit 2c1d029a017f ("net: mscc: ocelot: > Implement port policers via tc command"). > > Some data structure conversion between the DSA core and the Ocelot > library is necessary, for policer parameters. > > Signed-off-by: Vladimir Oltean > --- > drivers/net/dsa/ocelot/felix.c | 24 +++++++++++++++++++++++ > drivers/net/ethernet/mscc/ocelot_police.c | 3 +++ > drivers/net/ethernet/mscc/ocelot_police.h | 10 ---------- > drivers/net/ethernet/mscc/ocelot_tc.c | 2 +- > include/soc/mscc/ocelot.h | 8 ++++++++ > 5 files changed, 36 insertions(+), 11 deletions(-) > > diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c > index eef9fa812a3c..7f7dd6736051 100644 > --- a/drivers/net/dsa/ocelot/felix.c > +++ b/drivers/net/dsa/ocelot/felix.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include > #include > #include "felix.h" > > @@ -651,6 +652,27 @@ static int felix_cls_flower_stats(struct dsa_switch *ds, int port, > return ocelot_cls_flower_stats(ocelot, port, cls, ingress); > } > > +static int felix_port_policer_add(struct dsa_switch *ds, int port, > + struct dsa_mall_policer_tc_entry *policer) > +{ > + struct ocelot *ocelot = ds->priv; > + struct ocelot_policer pol = { > + .rate = div_u64(policer->rate_bytes_per_sec, 1000) * 8, > + .burst = div_u64(policer->rate_bytes_per_sec * > + PSCHED_NS2TICKS(policer->burst), > + PSCHED_TICKS_PER_SEC), > + }; > + > + return ocelot_port_policer_add(ocelot, port, &pol); > +} > + > +static void felix_port_policer_del(struct dsa_switch *ds, int port) > +{ > + struct ocelot *ocelot = ds->priv; > + > + ocelot_port_policer_del(ocelot, port); > +} > + > static const struct dsa_switch_ops felix_switch_ops = { > .get_tag_protocol = felix_get_tag_protocol, > .setup = felix_setup, > @@ -684,6 +706,8 @@ static const struct dsa_switch_ops felix_switch_ops = { > .port_txtstamp = felix_txtstamp, > .port_change_mtu = felix_change_mtu, > .port_max_mtu = felix_get_max_mtu, > + .port_policer_add = felix_port_policer_add, > + .port_policer_del = felix_port_policer_del, > .cls_flower_add = felix_cls_flower_add, > .cls_flower_del = felix_cls_flower_del, > .cls_flower_stats = felix_cls_flower_stats, > diff --git a/drivers/net/ethernet/mscc/ocelot_police.c b/drivers/net/ethernet/mscc/ocelot_police.c > index 8d25b2706ff0..2e1d8e187332 100644 > --- a/drivers/net/ethernet/mscc/ocelot_police.c > +++ b/drivers/net/ethernet/mscc/ocelot_police.c > @@ -4,6 +4,7 @@ > * Copyright (c) 2019 Microsemi Corporation > */ > > +#include > #include "ocelot_police.h" > > enum mscc_qos_rate_mode { > @@ -203,6 +204,7 @@ int ocelot_port_policer_add(struct ocelot *ocelot, int port, > > return 0; > } > +EXPORT_SYMBOL(ocelot_port_policer_add); > > int ocelot_port_policer_del(struct ocelot *ocelot, int port) > { > @@ -225,6 +227,7 @@ int ocelot_port_policer_del(struct ocelot *ocelot, int port) > > return 0; > } > +EXPORT_SYMBOL(ocelot_port_policer_del); > > int ocelot_ace_policer_add(struct ocelot *ocelot, u32 pol_ix, > struct ocelot_policer *pol) > diff --git a/drivers/net/ethernet/mscc/ocelot_police.h b/drivers/net/ethernet/mscc/ocelot_police.h > index 22025cce0a6a..792abd28010a 100644 > --- a/drivers/net/ethernet/mscc/ocelot_police.h > +++ b/drivers/net/ethernet/mscc/ocelot_police.h > @@ -9,16 +9,6 @@ > > #include "ocelot.h" > > -struct ocelot_policer { > - u32 rate; /* kilobit per second */ > - u32 burst; /* bytes */ > -}; > - > -int ocelot_port_policer_add(struct ocelot *ocelot, int port, > - struct ocelot_policer *pol); > - > -int ocelot_port_policer_del(struct ocelot *ocelot, int port); > - > int ocelot_ace_policer_add(struct ocelot *ocelot, u32 pol_ix, > struct ocelot_policer *pol); > > diff --git a/drivers/net/ethernet/mscc/ocelot_tc.c b/drivers/net/ethernet/mscc/ocelot_tc.c > index 3ff5ef41eccf..d326e231f0ad 100644 > --- a/drivers/net/ethernet/mscc/ocelot_tc.c > +++ b/drivers/net/ethernet/mscc/ocelot_tc.c > @@ -4,8 +4,8 @@ > * Copyright (c) 2019 Microsemi Corporation > */ > > +#include > #include "ocelot_tc.h" > -#include "ocelot_police.h" > #include "ocelot_ace.h" > #include > > diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h > index 3db66638a3b2..ca49f7a114de 100644 > --- a/include/soc/mscc/ocelot.h > +++ b/include/soc/mscc/ocelot.h > @@ -555,6 +555,11 @@ struct ocelot { > struct ptp_pin_desc ptp_pins[OCELOT_PTP_PINS_NUM]; > }; > Oops, it looks like I had Yangbo's patch in my tree, and the ptp_pins are messing with this patch's context, causing it to fail to apply cleanly: https://patchwork.ozlabs.org/patch/1258827/ I think I need to send a v2 for this. Sorry. > +struct ocelot_policer { > + u32 rate; /* kilobit per second */ > + u32 burst; /* bytes */ > +}; > + > #define ocelot_read_ix(ocelot, reg, gi, ri) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri)) > #define ocelot_read_gix(ocelot, reg, gi) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi)) > #define ocelot_read_rix(ocelot, reg, ri) __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri)) > @@ -624,6 +629,9 @@ int ocelot_port_add_txtstamp_skb(struct ocelot_port *ocelot_port, > void ocelot_get_txtstamp(struct ocelot *ocelot); > void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu); > int ocelot_get_max_mtu(struct ocelot *ocelot, int port); > +int ocelot_port_policer_add(struct ocelot *ocelot, int port, > + struct ocelot_policer *pol); > +int ocelot_port_policer_del(struct ocelot *ocelot, int port); > int ocelot_cls_flower_replace(struct ocelot *ocelot, int port, > struct flow_cls_offload *f, bool ingress); > int ocelot_cls_flower_destroy(struct ocelot *ocelot, int port, > -- > 2.17.1 > Thanks, -Vladimir