From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Xiaoliang Yang <xiaoliang.yang_1@nxp.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"allan.nielsen@microchip.com" <allan.nielsen@microchip.com>,
"joergen.andreasen@microchip.com"
<joergen.andreasen@microchip.com>,
"UNGLinuxDriver@microchip.com" <UNGLinuxDriver@microchip.com>,
"vinicius.gomes@intel.com" <vinicius.gomes@intel.com>,
"michael.chan@broadcom.com" <michael.chan@broadcom.com>,
"vishal@chelsio.com" <vishal@chelsio.com>,
"saeedm@mellanox.com" <saeedm@mellanox.com>,
"jiri@mellanox.com" <jiri@mellanox.com>,
"idosch@mellanox.com" <idosch@mellanox.com>,
"alexandre.belloni@bootlin.com" <alexandre.belloni@bootlin.com>,
"kuba@kernel.org" <kuba@kernel.org>, Po Liu <po.liu@nxp.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
Alexandru Marginean <alexandru.marginean@nxp.com>,
Leo Li <leoyang.li@nxp.com>, Mingkai Hu <mingkai.hu@nxp.com>
Subject: Re: [PATCH v1 net-next 5/5] net: dsa: felix: add police action for tc flower offload
Date: Tue, 20 Oct 2020 23:38:58 +0000 [thread overview]
Message-ID: <20201020233857.ifa4zjehupbvv5vs@skbuf> (raw)
In-Reply-To: <20201020072321.36921-6-xiaoliang.yang_1@nxp.com>
On Tue, Oct 20, 2020 at 03:23:21PM +0800, Xiaoliang Yang wrote:
> This patch add police action to set flow meter table which is defined
> in IEEE802.1Qci. Flow metering is two rates two buckets and three color
> marker to policing the frames, we only enable one rate one bucket in
> this patch.
>
> Flow metering shares a same policer pool with VCAP policers, it calls
> ocelot_vcap_policer_add() and ocelot_vcap_policer_del() to set flow
> meter table.
>
> Signed-off-by: Xiaoliang Yang <xiaoliang.yang_1@nxp.com>
> ---
It would be good to provide a functional example in
tools/testing/selftests/drivers/net/ocelot/ which sets a policer up and
explains what is the practical difference between a PSFP policer and a
regular VCAP policer, except for the fact that the PSFP policer can only
match on {DMAC, VLAN} and the regular one can match on a lot more (L2,
L3 and L4 headers).
Specifically, why would the user ever want to use a PSFP policer.
> drivers/net/dsa/ocelot/felix_flower.c | 32 +++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/drivers/net/dsa/ocelot/felix_flower.c b/drivers/net/dsa/ocelot/felix_flower.c
> index 71894dcc0af2..d58a2357bab1 100644
> --- a/drivers/net/dsa/ocelot/felix_flower.c
> +++ b/drivers/net/dsa/ocelot/felix_flower.c
> @@ -363,6 +363,8 @@ static void felix_list_stream_filter_del(struct ocelot *ocelot, u32 index)
> if (tmp->index == index) {
> if (tmp->sg_valid)
> felix_list_gate_del(ocelot, tmp->sgid);
> + if (tmp->fm_valid)
> + ocelot_vcap_policer_del(ocelot, tmp->fmid);
>
> z = refcount_dec_and_test(&tmp->refcount);
> if (z) {
> @@ -466,6 +468,8 @@ static int felix_psfp_set(struct ocelot *ocelot,
> if (ret) {
> if (sfi->sg_valid)
> felix_list_gate_del(ocelot, sfi->sgid);
> + if (sfi->fm_valid)
> + ocelot_vcap_policer_del(ocelot, sfi->fmid);
> return ret;
> }
>
> @@ -559,7 +563,9 @@ int felix_flower_stream_replace(struct ocelot *ocelot, int port,
> struct felix_streamid stream = {0};
> struct felix_stream_gate_conf *sgi;
> const struct flow_action_entry *a;
> + struct ocelot_policer pol;
> int ret, size, i;
> + u64 rate, burst;
> u32 index;
>
> ret = felix_flower_parse_key(f, &stream);
> @@ -595,6 +601,32 @@ int felix_flower_stream_replace(struct ocelot *ocelot, int port,
> stream.sfid_valid = 1;
> kfree(sgi);
> break;
> + case FLOW_ACTION_POLICE:
> + if (f->common.chain_index != OCELOT_PSFP_CHAIN) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Police action only be offloaded to PSFP chain");
This message is confusing and outright incorrect. The policing action
can be offloaded to VCAP IS2 too.
> + return -EOPNOTSUPP;
> + }
> +
> + index = a->police.index + FELIX_POLICER_PSFP_BASE;
> + if (index > FELIX_POLICER_PSFP_MAX)
> + return -EINVAL;
> +
> + rate = a->police.rate_bytes_ps;
> + burst = rate * PSCHED_NS2TICKS(a->police.burst);
> + pol = (struct ocelot_policer) {
> + .burst = div_u64(burst, PSCHED_TICKS_PER_SEC),
> + .rate = div_u64(rate, 1000) * 8,
> + };
> + ret = ocelot_vcap_policer_add(ocelot, index, &pol);
> + if (ret)
> + return ret;
> +
> + sfi.fm_valid = 1;
> + sfi.fmid = index;
> + sfi.maxsdu = a->police.mtu;
> + stream.sfid_valid = 1;
> + break;
> default:
> return -EOPNOTSUPP;
> }
> --
> 2.17.1
>
next prev parent reply other threads:[~2020-10-20 23:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-20 7:23 [PATCH v1 net-next 0/5] net: dsa: felix: psfp support on Xiaoliang Yang
2020-10-20 7:23 ` [PATCH v1 net-next 1/5] net: mscc: ocelot: add and export MAC table lookup operations Xiaoliang Yang
2020-10-20 23:24 ` Vladimir Oltean
2020-10-20 7:23 ` [PATCH v1 net-next 2/5] net: mscc: ocelot: set vcap IS2 chain to goto PSFP chain Xiaoliang Yang
2020-10-20 23:27 ` Vladimir Oltean
2020-10-21 16:59 ` joergen.andreasen
2020-10-20 7:23 ` [PATCH v1 net-next 3/5] net: dsa: felix: add gate action offload based on tc flower Xiaoliang Yang
2020-10-21 0:23 ` Vladimir Oltean
2020-10-20 7:23 ` [PATCH v1 net-next 4/5] net: mscc: ocelot: use index to set vcap policer Xiaoliang Yang
2020-10-20 7:23 ` [PATCH v1 net-next 5/5] net: dsa: felix: add police action for tc flower offload Xiaoliang Yang
2020-10-20 23:38 ` Vladimir Oltean [this message]
2020-10-20 20:37 ` [PATCH v1 net-next 0/5] net: dsa: felix: psfp support on Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201020233857.ifa4zjehupbvv5vs@skbuf \
--to=vladimir.oltean@nxp.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=alexandru.marginean@nxp.com \
--cc=allan.nielsen@microchip.com \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=idosch@mellanox.com \
--cc=jiri@mellanox.com \
--cc=joergen.andreasen@microchip.com \
--cc=kuba@kernel.org \
--cc=leoyang.li@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.chan@broadcom.com \
--cc=mingkai.hu@nxp.com \
--cc=netdev@vger.kernel.org \
--cc=po.liu@nxp.com \
--cc=saeedm@mellanox.com \
--cc=vinicius.gomes@intel.com \
--cc=vishal@chelsio.com \
--cc=xiaoliang.yang_1@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox