linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE:  Re: [v1,net-next 3/4] net: qos: police action add index for tc flower offloading
@ 2020-06-23 23:52 Po Liu
  2020-06-24 12:44 ` Jamal Hadi Salim
  0 siblings, 1 reply; 7+ messages in thread
From: Po Liu @ 2020-06-23 23:52 UTC (permalink / raw)
  To: Jamal Hadi Salim, davem, linux-kernel, netdev, idosch
  Cc: jiri, vinicius.gomes, vlad, Claudiu Manoil, Vladimir Oltean,
	Alexandru Marginean, michael.chan, vishal, saeedm, leon, jiri,
	idosch, alexandre.belloni, UNGLinuxDriver, kuba, xiyou.wangcong,
	simon.horman, pablo, moshe, m-karicheri2, andre.guedes, stephen,
	Edward Cree

Hi Jamal,


> -----Original Message-----
> From: Jamal Hadi Salim <jhs@mojatatu.com>
> Sent: 2020年6月23日 20:18
> To: Po Liu <po.liu@nxp.com>; davem@davemloft.net; linux-
> kernel@vger.kernel.org; netdev@vger.kernel.org; idosch@idosch.org
> Cc: jiri@resnulli.us; vinicius.gomes@intel.com; vlad@buslov.dev; Claudiu
> Manoil <claudiu.manoil@nxp.com>; Vladimir Oltean
> <vladimir.oltean@nxp.com>; Alexandru Marginean
> <alexandru.marginean@nxp.com>; michael.chan@broadcom.com;
> vishal@chelsio.com; saeedm@mellanox.com; leon@kernel.org;
> jiri@mellanox.com; idosch@mellanox.com;
> alexandre.belloni@bootlin.com; UNGLinuxDriver@microchip.com;
> kuba@kernel.org; xiyou.wangcong@gmail.com;
> simon.horman@netronome.com; pablo@netfilter.org;
> moshe@mellanox.com; m-karicheri2@ti.com;
> andre.guedes@linux.intel.com; stephen@networkplumber.org; Edward
> Cree <ecree@solarflare.com>
> Subject: Re: [v1,net-next 3/4] net: qos: police action add index for tc
> flower offloading
> 
> On 2020-06-23 7:55 a.m., Po Liu wrote:
> 
> 
> [..]
> >> My question: Is this any different from how stats are structured?
> >
> > I don't know I fully catch the question. Are you trying to get how many
> frames for each filter chain passing one index policing action?
> > If one index police action bind to multiple tc filter(they should have
> differnt chain index ). All those filter should get same index police action
> stats value since they are sharing the same hardware entry. But I don't
> think this is the problem.
> >
> 
> This is a good thing. What is nice is i can use the same index for s/w and
> h/w (and no need for a translation/remapping).
> 
> > With index provide to device driver(map the s/w action index to a h/w
> table index ), user could list the police actions list by command:
> > # tc actions show action police
> > Shows the police action table by index.
> 
> This is also nice.
> 
> My question: Why cant you apply the same semantics for the counters?
> Does your hardware have an indexed counter/stats table? If yes then you

Yes,  but I think tc flower can only care about the  counters of that chain. And action police care about how many frames for each police entry.

> should be able to do similar thing for counters as you do for policer (i.e
> use an index and share counters across actions). So when i say:
> tc action drop index 5

Do you mean something like "tc xxx flower action police index 5 drop"  since '' tc action drop index 5" is not a proper command? (there is 'action drop'  follow the tc filter command but not with index assigned). 

> and
> tc action ok index 5
> infact they use the same counter.

Maybe you are saying if action police follow with 'CONTROL' (reclassify | pipe | drop | continue | ok)  when offloading to hardware. With different 'CONTROL', the hardware counter won't changed since hardware never known what the 'CONTROL' is. This is still software part and will do at software part(although software seems not deal with this, I also suggest to after offloading should back to tcf_police_act() continue the action). 

When set to be offloading mode, the counters only showing the hardware counters(even different vendor could set different counter register.). But I don't think the index offloading could break anything.

> 
> 
> cheers,
> jamal


Br,
Po Liu

^ permalink raw reply	[flat|nested] 7+ messages in thread
* RE:Re: [v1,net-next 3/4] net: qos: police action add index for tc flower offloading
@ 2020-06-25  0:34 Po Liu
  2020-06-26 13:28 ` Jamal Hadi Salim
  0 siblings, 1 reply; 7+ messages in thread
From: Po Liu @ 2020-06-25  0:34 UTC (permalink / raw)
  To: Jamal Hadi Salim, davem, linux-kernel, netdev, idosch
  Cc: jiri, vinicius.gomes, vlad, Claudiu Manoil, Vladimir Oltean,
	Alexandru Marginean, michael.chan, vishal, saeedm, leon, jiri,
	idosch, alexandre.belloni, UNGLinuxDriver, kuba, xiyou.wangcong,
	simon.horman, pablo, moshe, m-karicheri2, andre.guedes, stephen,
	Edward Cree



> -----Original Message-----
> From: Jamal Hadi Salim <jhs@mojatatu.com>
> Sent: 2020年6月24日 20:45
> To: Po Liu <po.liu@nxp.com>; davem@davemloft.net; linux-
> kernel@vger.kernel.org; netdev@vger.kernel.org; idosch@idosch.org
> Cc: jiri@resnulli.us; vinicius.gomes@intel.com; vlad@buslov.dev; Claudiu
> Manoil <claudiu.manoil@nxp.com>; Vladimir Oltean
> <vladimir.oltean@nxp.com>; Alexandru Marginean
> <alexandru.marginean@nxp.com>; michael.chan@broadcom.com;
> vishal@chelsio.com; saeedm@mellanox.com; leon@kernel.org;
> jiri@mellanox.com; idosch@mellanox.com;
> alexandre.belloni@bootlin.com; UNGLinuxDriver@microchip.com;
> kuba@kernel.org; xiyou.wangcong@gmail.com;
> simon.horman@netronome.com; pablo@netfilter.org;
> moshe@mellanox.com; m-karicheri2@ti.com;
> andre.guedes@linux.intel.com; stephen@networkplumber.org; Edward
> Cree <ecree@solarflare.com>
> Subject: Re: [v1,net-next 3/4] net: qos: police action add index for tc
> flower offloading
> > 
> On 2020-06-23 7:52 p.m., Po Liu wrote:
> > Hi Jamal,
> >
> >
> 
> >>>> My question: Is this any different from how stats are structured?
> >>>
> 
> [..]
> >> My question: Why cant you apply the same semantics for the counters?
> >> Does your hardware have an indexed counter/stats table? If yes then
> >> you
> >
> > Yes,
> 
> That is the point i was trying to get to. Basically:
> You have a counter table which is referenced by "index"
> You also have a meter/policer table which is referenced by "index".

They should be one same group and same meaning.

> 
> For policers, they maintain their own stats. So when i say:
> tc ... flower ... action police ... index 5 The index referred to is in the
> policer table
> 

Sure. Means police with No. 5 entry. 

> But for other actions, example when i say:
> tc ... flower ... action drop index 10

Still the question, does gact action drop could bind with index? It doesn't meanful.

> The index is in the counter/stats table.
> It is not exactly "10" in hardware, the driver magically hides it from the
> user - so it could be hw counter index 1234

Not exactly. Current flower offloading stats means get the chain index for that flow filter. The other actions should bind to that chain index. Like IEEE802.1Qci, what I am doing is bind gate action to filter chain(mandatory). And also police action as optional. There is stream counter table which summary the counters pass gate action entry and police action entry for that chain index(there is a bit different if two chain sharing same action list).
One chain counter which tc show stats get counter source:
struct psfp_streamfilter_counters {
        u64 matching_frames_count;
        u64 passing_frames_count;
        u64 not_passing_frames_count;
        u64 passing_sdu_count;
        u64 not_passing_sdu_count;
        u64 red_frames_count;
};

When pass to the user space, summarize as:
        stats.pkts = counters.matching_frames_count +  counters.not_passing_sdu_count - filter->stats.pkts;
        stats.drops = counters.not_passing_frames_count + counters.not_passing_sdu_count +   counters.red_frames_count - filter->stats.drops;

But in software side, it is showing in the action list. And action gate and police exactly showing the counters that chain index. Not the true counters of index action gate or index police. This is the limitation of get the offloading stats.


> 
> The old approach is to assume the classifier (flower in this
> case) has a counter. The reason for this assumption is older hardware was
> designed to deal with a single action per match.
> So a counter to the filter is also the counter to the
> (single) action. I get the feeling your hardware fits in that space.

No, hardware could have gate+police actions but bind to one stream filter counter table in IEEE 802.1Qci.

> 
> Modern use cases have evolved from the ACL single match and action
> approach. Maintaining the old thought/architecture breaks in two use
> cases:
> 1) when you have multiple actions per policy filter. You need counter-per-
> action for various reasons

Action index only for set an action entry in hardware, and not get stats by that index.
So I don't think it is problem of  exposing action index to the driver break the rule. This is the limitation of get the offloading stats, there is no counters get by action index. 

> 2) Sharing of counters across filters and action. This can be achieve
> 
> tc supports the above and is sufficient to cover the old use cases.
> I am just worried, architecturally, we are restricting ourselves to the old
> scheme.
> 
> Another reason this is important is for the sake of analytics.
> A user space app can poll just for the stats table in hardware (or the
> cached version in the kernel) and reduce the amount of data crossing to
> user space..
> 
> cheers,
> jamal
> 
> 
> 
> 


Br,
Po Liu


^ permalink raw reply	[flat|nested] 7+ messages in thread
* RE:  Re: [v1,net-next 3/4] net: qos: police action add index for tc flower offloading
@ 2020-06-23 11:55 Po Liu
  2020-06-23 12:17 ` Jamal Hadi Salim
  0 siblings, 1 reply; 7+ messages in thread
From: Po Liu @ 2020-06-23 11:55 UTC (permalink / raw)
  To: Jamal Hadi Salim, davem, linux-kernel, netdev, idosch
  Cc: jiri, vinicius.gomes, vlad, Claudiu Manoil, Vladimir Oltean,
	Alexandru Marginean, michael.chan, vishal, saeedm, leon, jiri,
	idosch, alexandre.belloni, UNGLinuxDriver, kuba, xiyou.wangcong,
	simon.horman, pablo, moshe, m-karicheri2, andre.guedes, stephen,
	Edward Cree

Hi Jamal,


> -----Original Message-----
> From: Jamal Hadi Salim <jhs@mojatatu.com>
> Sent: 2020年6月23日 18:09
> To: Po Liu <po.liu@nxp.com>; davem@davemloft.net; linux-
> kernel@vger.kernel.org; netdev@vger.kernel.org; idosch@idosch.org
> Cc: jiri@resnulli.us; vinicius.gomes@intel.com; vlad@buslov.dev; Claudiu
> Manoil <claudiu.manoil@nxp.com>; Vladimir Oltean
> <vladimir.oltean@nxp.com>; Alexandru Marginean
> <alexandru.marginean@nxp.com>; michael.chan@broadcom.com;
> vishal@chelsio.com; saeedm@mellanox.com; leon@kernel.org;
> jiri@mellanox.com; idosch@mellanox.com;
> alexandre.belloni@bootlin.com; UNGLinuxDriver@microchip.com;
> kuba@kernel.org; xiyou.wangcong@gmail.com;
> simon.horman@netronome.com; pablo@netfilter.org;
> moshe@mellanox.com; m-karicheri2@ti.com;
> andre.guedes@linux.intel.com; stephen@networkplumber.org; Edward
> Cree <ecree@solarflare.com>
> Subject: Re: [v1,net-next 3/4] net: qos: police action add index for tc
> flower offloading
> 
> 
> This certainly brings an interesting point which i brought up earlier when
> Jiri was doing offloading of stats.
> In this case the action index is being used as the offloaded policer index
> (note: there'd need to be a check whether the index is infact acceptable to
> the h/w etc unless there
> 2^32 meters available in the hardware).

Yes, device should report invalid if index is out of range which means hardware not support.

> 
> My question: Is this any different from how stats are structured?

I don't know I fully catch the question. Are you trying to get how many frames for each filter chain passing one index policing action? 
If one index police action bind to multiple tc filter(they should have differnt chain index ). All those filter should get same index police action stats value since they are sharing the same hardware entry. But I don't think this is the problem.

With index provide to device driver(map the s/w action index to a h/w table index ), user could list the police actions list by command:
# tc actions show action police
Shows the police action table by index.
Thanks!

> In this case you can map the s/w action index to a h/w table index (of
> meters).
> My comment then was: hardware i have encountered (and i pointed to P4
> model as well) assumes an indexed table of stats.
> 
> cheers,
> jamal
> 
> On 2020-06-23 2:34 a.m., Po Liu wrote:
> > From: Po Liu <Po.Liu@nxp.com>
> >
> > Hardware may own many entries for police flow. So that make one(or
> >   multi) flow to be policed by one hardware entry. This patch add the
> > police action index provide to the driver side make it mapping the
> > driver hardware entry index.
> >
> > Signed-off-by: Po Liu <Po.Liu@nxp.com>
> > ---
> >   include/net/flow_offload.h | 1 +
> >   net/sched/cls_api.c        | 1 +
> >   2 files changed, 2 insertions(+)
> >
> > diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
> > index c2ef19c6b27d..eed98075b1ae 100644
> > --- a/include/net/flow_offload.h
> > +++ b/include/net/flow_offload.h
> > @@ -232,6 +232,7 @@ struct flow_action_entry {
> >                       bool                    truncate;
> >               } sample;
> >               struct {                                /* FLOW_ACTION_POLICE */
> > +                     u32                     index;
> >                       s64                     burst;
> >                       u64                     rate_bytes_ps;
> >                       u32                     mtu;
> > diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index
> > 6aba7d5ba1ec..fdc4c89ca1fa 100644
> > --- a/net/sched/cls_api.c
> > +++ b/net/sched/cls_api.c
> > @@ -3659,6 +3659,7 @@ int tc_setup_flow_action(struct flow_action
> *flow_action,
> >                       entry->police.rate_bytes_ps =
> >                               tcf_police_rate_bytes_ps(act);
> >                       entry->police.mtu = tcf_police_tcfp_mtu(act);
> > +                     entry->police.index = act->tcfa_index;
> >               } else if (is_tcf_ct(act)) {
> >                       entry->id = FLOW_ACTION_CT;
> >                       entry->ct.action = tcf_ct_action(act);
> >

Br,
Po Liu

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [RFC,net-next  6/9] net: qos: add tc police offloading action with max frame size limit
@ 2020-03-06 12:56 Po Liu
  2020-06-23  6:34 ` [v1,net-next 1/4] " Po Liu
  0 siblings, 1 reply; 7+ messages in thread
From: Po Liu @ 2020-03-06 12:56 UTC (permalink / raw)
  To: davem, linux-kernel, netdev
  Cc: vinicius.gomes, po.liu, claudiu.manoil, vladimir.oltean,
	alexandru.marginean, xiaoliang.yang_1, roy.zang, mingkai.hu,
	jerry.huang, leoyang.li, michael.chan, vishal, saeedm, leon,
	jiri, idosch, alexandre.belloni, UNGLinuxDriver, kuba, jhs,
	xiyou.wangcong, john.hurley, simon.horman,
	pieter.jansenvanvuuren, pablo, moshe, ivan.khoronzhuk,
	m-karicheri2, andre.guedes, jakub.kicinski, Po Liu

Current police offloading support the 'burst'' and 'rate_bytes_ps'. Some
hardware own the capability to limit the frame size. If the frame size
larger than the setting, the frame would be dropped. For the police
action itself already accept the 'mtu' parameter in tc command. But not
extend to tc flower offloading. So extend 'mtu' to tc flower offloading.

Signed-off-by: Po Liu <Po.Liu@nxp.com>
---
 include/net/flow_offload.h     |  1 +
 include/net/tc_act/tc_police.h | 10 ++++++++++
 net/sched/cls_api.c            |  1 +
 3 files changed, 12 insertions(+)

diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index 7f5a097f5072..54df87328edc 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -203,6 +203,7 @@ struct flow_action_entry {
 		struct {				/* FLOW_ACTION_POLICE */
 			s64			burst;
 			u64			rate_bytes_ps;
+			u32			mtu;
 		} police;
 		struct {				/* FLOW_ACTION_CT */
 			int action;
diff --git a/include/net/tc_act/tc_police.h b/include/net/tc_act/tc_police.h
index f098ad4424be..39fbf28f8f3e 100644
--- a/include/net/tc_act/tc_police.h
+++ b/include/net/tc_act/tc_police.h
@@ -69,4 +69,14 @@ static inline s64 tcf_police_tcfp_burst(const struct tc_action *act)
 	return params->tcfp_burst;
 }
 
+static inline u32 tcf_police_mtu(const struct tc_action *act)
+{
+	struct tcf_police *police = to_police(act);
+	struct tcf_police_params *params;
+
+	params = rcu_dereference_protected(police->params,
+					   lockdep_is_held(&police->tcf_lock));
+
+	return params->tcfp_mtu;
+}
 #endif /* __NET_TC_POLICE_H */
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 0ada7b2a5c2c..363d3991793d 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -3583,6 +3583,7 @@ int tc_setup_flow_action(struct flow_action *flow_action,
 			entry->police.burst = tcf_police_tcfp_burst(act);
 			entry->police.rate_bytes_ps =
 				tcf_police_rate_bytes_ps(act);
+			entry->police.mtu = tcf_police_mtu(act);
 		} else if (is_tcf_ct(act)) {
 			entry->id = FLOW_ACTION_CT;
 			entry->ct.action = tcf_ct_action(act);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-06-26 13:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23 23:52 Re: [v1,net-next 3/4] net: qos: police action add index for tc flower offloading Po Liu
2020-06-24 12:44 ` Jamal Hadi Salim
  -- strict thread matches above, loose matches on Subject: below --
2020-06-25  0:34 Po Liu
2020-06-26 13:28 ` Jamal Hadi Salim
2020-06-23 11:55 Po Liu
2020-06-23 12:17 ` Jamal Hadi Salim
2020-03-06 12:56 [RFC,net-next 6/9] net: qos: add tc police offloading action with max frame size limit Po Liu
2020-06-23  6:34 ` [v1,net-next 1/4] " Po Liu
2020-06-23  6:34   ` [v1,net-next 3/4] net: qos: police action add index for tc flower offloading Po Liu
2020-06-23  7:09     ` Ido Schimmel
2020-06-23 10:08     ` Jamal Hadi Salim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).