Skip to contentSkip to conversation

net: flow_offload: skip hw stats check for FLOW_ACTION_HW_STATS_DISABLED

PATCH In review Pablo Neira Ayuso 5 participants 20 messages Apr 19, 2020 – Apr 27, 2020

Subsystems (3)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 net: flow_offload: skip hw stats check for FLOW_ACTION_HW_STATS_DISABLED

If the frontend requests no stats through FLOW_ACTION_HW_STATS_DISABLED, drivers that are checking for the hw stats configuration bail out with EOPNOTSUPP.

Fixes 319a1d19471e ("flow_offload: check for basic action hw stats type")
---
 include/net/flow_offload.h | 3 +++
 1 file changed, 3 insertions(+)
include/net/flow_offload.h +3 -0
index 3619c6acf60f..c2519a25d0bd 100644
@@ -326,6 +326,9 @@ __flow_action_hw_stats_check(const struct flow_action *action,
 	if (!flow_action_mixed_hw_stats_check(action, extack))
 		return false;
 	action_entry = flow_action_first_entry_get(action);
+	if (action_entry->hw_stats == FLOW_ACTION_HW_STATS_DISABLED)
+		return true;
+
 	if (!check_allow_bit &&
 	    action_entry->hw_stats != FLOW_ACTION_HW_STATS_ANY) {
 		NL_SET_ERR_MSG_MOD(extack, "Driver supports only default HW stats type \"any\"");
Signature · 1 line
2.11.0
#1 lore raw
Quoted 3 lines · Sun, Apr 19, 2020 at 01:53:38PM CEST, [email protected] wrote:

If the frontend requests no stats through FLOW_ACTION_HW_STATS_DISABLED, drivers that are checking for the hw stats configuration bail out with EOPNOTSUPP.

Wait, that was a point. Driver has to support stats disabling.

Quoted 24 lines
Fixes 319a1d19471e ("flow_offload: check for basic action hw stats type")

---
include/net/flow_offload.h | 3 +++

1 file changed, 3 insertions(+)
include/net/flow_offload.h +3 -0
index 3619c6acf60f..c2519a25d0bd 100644
@@ -326,6 +326,9 @@ __flow_action_hw_stats_check(const struct flow_action *action,
 	if (!flow_action_mixed_hw_stats_check(action, extack))
 		return false;
 	action_entry = flow_action_first_entry_get(action);
+	if (action_entry->hw_stats == FLOW_ACTION_HW_STATS_DISABLED)
+		return true;
+
 	if (!check_allow_bit &&
 	    action_entry->hw_stats != FLOW_ACTION_HW_STATS_ANY) {
 		NL_SET_ERR_MSG_MOD(extack, "Driver supports only default HW stats type \"any\"");
Signature · 1 line
2.11.0
author maintainer
#2 lore raw
Quoted 6 lines · Jiri Pirko
Quoted 3 lines · Sun, Apr 19, 2020 at 01:53:38PM CEST, [email protected] wrote:

If the frontend requests no stats through FLOW_ACTION_HW_STATS_DISABLED, drivers that are checking for the hw stats configuration bail out with EOPNOTSUPP.

Wait, that was a point. Driver has to support stats disabling.

Hm, some drivers used to accept FLOW_ACTION_HW_STATS_DISABLED, now rulesets that used to work don't work anymore.

#3 lore raw
Quoted 10 lines · Mon, Apr 20, 2020 at 11:05:05AM CEST, [email protected] wrote:
Quoted 6 lines · Jiri Pirko
Quoted 3 lines · Sun, Apr 19, 2020 at 01:53:38PM CEST, [email protected] wrote:

If the frontend requests no stats through FLOW_ACTION_HW_STATS_DISABLED, drivers that are checking for the hw stats configuration bail out with EOPNOTSUPP.

Wait, that was a point. Driver has to support stats disabling.

Hm, some drivers used to accept FLOW_ACTION_HW_STATS_DISABLED, now rulesets that used to work don't work anymore.

How? This check is here since the introduction of hw stats types.

author maintainer
#4 lore raw
Quoted 7 lines · Jiri Pirko
Quoted 6 lines · Mon, Apr 20, 2020 at 11:05:05AM CEST, [email protected] wrote:
Quoted 5 lines · Jiri Pirko
Quoted 3 lines · Sun, Apr 19, 2020 at 01:53:38PM CEST, [email protected] wrote:

If the frontend requests no stats through FLOW_ACTION_HW_STATS_DISABLED, drivers that are checking for the hw stats configuration bail out with EOPNOTSUPP.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Wait, that was a point. Driver has to support stats disabling.

Hm, some drivers used to accept FLOW_ACTION_HW_STATS_DISABLED, now rulesets that used to work don't work anymore.

How? This check is here since the introduction of hw stats types.

Netfilter is setting the counter support to FLOW_ACTION_HW_STATS_DISABLED in this example below:

  table netdev filter {
        chain ingress {
                type filter hook ingress device eth0 priority 0; flags offload;

tcp dport 22 drop
}
}

The user did not specify a counter in this case.

I think __flow_action_hw_stats_check() cannot work with FLOW_ACTION_HW_STATS_DISABLED.

If check_allow_bit is false and FLOW_ACTION_HW_STATS_DISABLED is specified, then this always evaluates true:

        if (!check_allow_bit &&
            action_entry->hw_stats != FLOW_ACTION_HW_STATS_ANY) {

Similarly:

        } else if (check_allow_bit &&
                   !(action_entry->hw_stats & BIT(allow_bit))) {

evaluates true for FLOW_ACTION_HW_STATS_DISABLED, assuming allow_bit is set, which I think it is the intention.

Another suggestion: This is control plane code and this __flow_action_hw_stats_check() function is relatively large, I'd suggest to move it to net/core/flow_offload.c at some point.

Thank you!

#5 lore raw
Quoted 18 lines · Mon, Apr 20, 2020 at 12:03:41PM CEST, [email protected] wrote:
Quoted 7 lines · Jiri Pirko
Quoted 6 lines · Mon, Apr 20, 2020 at 11:05:05AM CEST, [email protected] wrote:
Quoted 5 lines · Jiri Pirko
Quoted 3 lines · Sun, Apr 19, 2020 at 01:53:38PM CEST, [email protected] wrote:

If the frontend requests no stats through FLOW_ACTION_HW_STATS_DISABLED, drivers that are checking for the hw stats configuration bail out with EOPNOTSUPP.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Wait, that was a point. Driver has to support stats disabling.

Hm, some drivers used to accept FLOW_ACTION_HW_STATS_DISABLED, now rulesets that used to work don't work anymore.

How? This check is here since the introduction of hw stats types.

Netfilter is setting the counter support to FLOW_ACTION_HW_STATS_DISABLED in this example below:

Quoted 7 lines
 table netdev filter {
       chain ingress {
               type filter hook ingress device eth0 priority 0; flags offload;

               tcp dport 22 drop
       }

}

Hmm. In TC the HW_STATS_DISABLED has to be explicitly asked by the user, as the sw stats are always on. Your case is different. However so far (before HW_STATS patchset), the offload just did the stats and you ignored them in netfilter code, correct?

Perhaps we need another value of this, like "HW_STATS_MAY_DISABLED" for such case. Because you don't care if the HW actually does the stats or not. It is an optimization for you.

However for TC, when user specifies "HW_STATS_DISABLED", the driver should not do stats.

Quoted 12 lines

The user did not specify a counter in this case.

I think __flow_action_hw_stats_check() cannot work with FLOW_ACTION_HW_STATS_DISABLED.

If check_allow_bit is false and FLOW_ACTION_HW_STATS_DISABLED is specified, then this always evaluates true:

       if (!check_allow_bit &&
           action_entry->hw_stats != FLOW_ACTION_HW_STATS_ANY) {
Quoted 7 lines

Similarly:

       } else if (check_allow_bit &&
                  !(action_entry->hw_stats & BIT(allow_bit))) {

evaluates true for FLOW_ACTION_HW_STATS_DISABLED, assuming allow_bit is set, which I think it is the intention.

That is correct. __flow_action_hw_stats_check() helper is here for simple drivers that support just one type of hw stats (immediate/delayed).

Quoted 4 lines

Another suggestion: This is control plane code and this __flow_action_hw_stats_check() function is relatively large, I'd suggest to move it to net/core/flow_offload.c at some point.

Sure, why not.

Quoted 2 lines

Thank you!

author maintainer
#6 lore raw
Quoted 23 lines · Jiri Pirko
Quoted 22 lines · Mon, Apr 20, 2020 at 12:03:41PM CEST, [email protected] wrote:
Quoted 7 lines · Jiri Pirko
Quoted 6 lines · Mon, Apr 20, 2020 at 11:05:05AM CEST, [email protected] wrote:
Quoted 5 lines · Jiri Pirko
Quoted 3 lines · Sun, Apr 19, 2020 at 01:53:38PM CEST, [email protected] wrote:

If the frontend requests no stats through FLOW_ACTION_HW_STATS_DISABLED, drivers that are checking for the hw stats configuration bail out with EOPNOTSUPP.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Wait, that was a point. Driver has to support stats disabling.

Hm, some drivers used to accept FLOW_ACTION_HW_STATS_DISABLED, now rulesets that used to work don't work anymore.

How? This check is here since the introduction of hw stats types.

Netfilter is setting the counter support to FLOW_ACTION_HW_STATS_DISABLED in this example below:

 table netdev filter {
       chain ingress {
               type filter hook ingress device eth0 priority 0; flags offload;
Quoted 6 lines
Quoted 3 lines

tcp dport 22 drop
}
}

Hmm. In TC the HW_STATS_DISABLED has to be explicitly asked by the user, as the sw stats are always on. Your case is different.

I see, I think requesting HW_STATS_DISABLED in tc fails with the existing code though.

Quoted 2 lines

However so far (before HW_STATS patchset), the offload just did the stats and you ignored them in netfilter code, correct?

Yes, netfilter is not collecting stats yet.

Quoted 2 lines

Perhaps we need another value of this, like "HW_STATS_MAY_DISABLED" for such case.

Or just redefine FLOW_ACTION_HW_STATS_DISABLED to define a bit in enum flow_action_hw_stats_bit.

enum flow_action_hw_stats_bit {
FLOW_ACTION_HW_STATES_DISABLED_BIT,
FLOW_ACTION_HW_STATS_IMMEDIATE_BIT,
FLOW_ACTION_HW_STATS_DELAYED_BIT,
};

Then update:

FLOW_ACTION_HW_STATS_ANY = FLOW_ACTION_HW_STATS_DISABLED |
FLOW_ACTION_HW_STATS_IMMEDIATE | FLOW_ACTION_HW_STATS_DELAYED,

?

Quoted 5 lines

Because you don't care if the HW actually does the stats or not. It is an optimization for you.

However for TC, when user specifies "HW_STATS_DISABLED", the driver should not do stats.

My interpretation is that _DISABLED means that front-end does not request counters to the driver.

Quoted 16 lines
Quoted 16 lines

The user did not specify a counter in this case.

I think __flow_action_hw_stats_check() cannot work with FLOW_ACTION_HW_STATS_DISABLED.

If check_allow_bit is false and FLOW_ACTION_HW_STATS_DISABLED is specified, then this always evaluates true:

       if (!check_allow_bit &&
           action_entry->hw_stats != FLOW_ACTION_HW_STATS_ANY) {

Similarly:

       } else if (check_allow_bit &&
                  !(action_entry->hw_stats & BIT(allow_bit))) {
Quoted 6 lines
Quoted 2 lines

evaluates true for FLOW_ACTION_HW_STATS_DISABLED, assuming allow_bit is set, which I think it is the intention.

That is correct. __flow_action_hw_stats_check() helper is here for simple drivers that support just one type of hw stats (immediate/delayed).

If this is solved as I'm proposing above, then __flow_action_hw_stats_check() need to take a bitmask instead of enum flow_action_hw_stats_bit as parameter, because a driver need to specify what they support, eg.

if (!__flow_action_hw_stats_check(action, &extack,
FLOW_ACTION_HW_STATS_DISABLED | FLOW_ACTION_HW_STATS_DELAYED))
return -EOPNOSUPP;

or alternatively, if the driver supports any case:

if (!__flow_action_hw_stats_check(action, &extack,
FLOW_ACTION_HW_STATS_ANY))
return -EOPNOSUPP;

#8 lore raw
In reply to Jiri Pirko
Quoted 2 lines · Jiri Pirko

However for TC, when user specifies "HW_STATS_DISABLED", the driver should not do stats.

What should a driver do if the user specifies DISABLED, but the stats are still needed for internal bookkeeping (e.g. to prod an ARP entry that's in use for encapsulation offload, so that it doesn't get expired out of the cache)?  Enable the stats on the HW anyway but not report them to FLOW_CLS_STATS?  Or return an error?

-ed

#9 lore raw
Quoted 8 lines · Mon, Apr 20, 2020 at 02:28:22PM CEST, [email protected] wrote:
Quoted 2 lines · Jiri Pirko

However for TC, when user specifies "HW_STATS_DISABLED", the driver should not do stats.

What should a driver do if the user specifies DISABLED, but the stats are still needed for internal bookkeeping (e.g. to prod an ARP entry that's in use for encapsulation offload, so that it doesn't get expired out of the cache)?  Enable the stats on the HW anyway but not report them to FLOW_CLS_STATS?  Or return an error?

If internally needed, it means they cannot be disabled. So returning error would make sense, as what the user requested is not supported.

Quoted 2 lines

-ed

author maintainer
#12 lore raw
In reply to Edward Cree
Quoted 9 lines · Edward Cree
Quoted 2 lines · Jiri Pirko

However for TC, when user specifies "HW_STATS_DISABLED", the driver should not do stats.

What should a driver do if the user specifies DISABLED, but the stats are still needed for internal bookkeeping (e.g. to prod an ARP entry that's in use for encapsulation offload, so that it doesn't get expired out of the cache)?  Enable the stats on the HW anyway but not report them to FLOW_CLS_STATS?  Or return an error?

My interpretation is that HW_STATS_DISABLED means that the front-end does not care / does not need counters. The driver can still allocate them if needed. So the enum flow_action_hw_stats flags represent what the front-end requires.

author maintainer
#10 lore raw
In reply to Jiri Pirko
Quoted 4 lines · Jiri Pirko
Quoted 3 lines · Mon, Apr 20, 2020 at 02:28:22PM CEST, [email protected] wrote:
Quoted 2 lines · Jiri Pirko

However for TC, when user specifies "HW_STATS_DISABLED", the driver should not do stats.

Quoted 8 lines
Quoted 5 lines

What should a driver do if the user specifies DISABLED, but the stats are still needed for internal bookkeeping (e.g. to prod an ARP entry that's in use for encapsulation offload, so that it doesn't get expired out of the cache)?  Enable the stats on the HW anyway but not report them to FLOW_CLS_STATS?  Or return an error?

If internally needed, it means they cannot be disabled. So returning error would make sense, as what the user requested is not supported.

Hm.

Then, if the user disables counters but there is internal dependency on them, the tc rule fails to be loaded for this reason.

After this the user is forced to re-load the rule, specifying enable counters.

Why does the user need to force in this case to reload? It seems more natural to me to give the user what it is requesting (disabled counters / front-end doesn't care) and the driver internally allocates the resources that it needs (actually turn them on if there is a dependency like tunneling).

#11 lore raw
Quoted 11 lines · Mon, Apr 20, 2020 at 02:49:20PM CEST, [email protected] wrote:
Quoted 10 lines · Jiri Pirko
Quoted 8 lines · Mon, Apr 20, 2020 at 02:28:22PM CEST, [email protected] wrote:
Quoted 2 lines · Jiri Pirko

However for TC, when user specifies "HW_STATS_DISABLED", the driver should not do stats.

What should a driver do if the user specifies DISABLED, but the stats are still needed for internal bookkeeping (e.g. to prod an ARP entry that's in use for encapsulation offload, so that it doesn't get expired out of the cache)?  Enable the stats on the HW anyway but not report them to FLOW_CLS_STATS?  Or return an error?

Quoted 7 lines
Quoted 2 lines

If internally needed, it means they cannot be disabled. So returning error would make sense, as what the user requested is not supported.

Hm.

Then, if the user disables counters but there is internal dependency on them, the tc rule fails to be loaded for this reason.

User asked for disable. They should be disabled. If driver does not support it, should not pretend they are disabled. Does not make sense.

Quoted 9 lines

After this the user is forced to re-load the rule, specifying enable counters.

Why does the user need to force in this case to reload? It seems more natural to me to give the user what it is requesting (disabled counters / front-end doesn't care) and the driver internally allocates the resources that it needs (actually turn them on if there is a dependency like tunneling).

#13 lore raw
In reply to Pablo Neira Ayuso
Quoted 5 lines · Mon, Apr 20, 2020 at 02:39:15PM CEST, [email protected] wrote:
Quoted 4 lines · Edward Cree
Quoted 2 lines · Jiri Pirko

However for TC, when user specifies "HW_STATS_DISABLED", the driver should not do stats.

Quoted 8 lines
Quoted 5 lines

What should a driver do if the user specifies DISABLED, but the stats are still needed for internal bookkeeping (e.g. to prod an ARP entry that's in use for encapsulation offload, so that it doesn't get expired out of the cache)?  Enable the stats on the HW anyway but not report them to FLOW_CLS_STATS?  Or return an error?

My interpretation is that HW_STATS_DISABLED means that the front-end does not care / does not need counters. The driver can still allocate

That is wrong interpretation. If user does not care, he specifies "ANY". That is the default.

When he says "DISABLED" he means disabled. Not "I don't care".

Quoted 2 lines

them if needed. So the enum flow_action_hw_stats flags represent what the front-end requires.

#7 lore raw
In reply to Pablo Neira Ayuso
Quoted 51 lines · Mon, Apr 20, 2020 at 02:13:51PM CEST, [email protected] wrote:
Quoted 23 lines · Jiri Pirko
Quoted 22 lines · Mon, Apr 20, 2020 at 12:03:41PM CEST, [email protected] wrote:
Quoted 7 lines · Jiri Pirko
Quoted 6 lines · Mon, Apr 20, 2020 at 11:05:05AM CEST, [email protected] wrote:
Quoted 5 lines · Jiri Pirko
Quoted 3 lines · Sun, Apr 19, 2020 at 01:53:38PM CEST, [email protected] wrote:

If the frontend requests no stats through FLOW_ACTION_HW_STATS_DISABLED, drivers that are checking for the hw stats configuration bail out with EOPNOTSUPP.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Wait, that was a point. Driver has to support stats disabling.

Hm, some drivers used to accept FLOW_ACTION_HW_STATS_DISABLED, now rulesets that used to work don't work anymore.

How? This check is here since the introduction of hw stats types.

Netfilter is setting the counter support to FLOW_ACTION_HW_STATS_DISABLED in this example below:

 table netdev filter {
       chain ingress {
               type filter hook ingress device eth0 priority 0; flags offload;
Quoted 6 lines
Quoted 3 lines

tcp dport 22 drop
}
}

Hmm. In TC the HW_STATS_DISABLED has to be explicitly asked by the user, as the sw stats are always on. Your case is different.

I see, I think requesting HW_STATS_DISABLED in tc fails with the existing code though.

Quoted 2 lines

However so far (before HW_STATS patchset), the offload just did the stats and you ignored them in netfilter code, correct?

Yes, netfilter is not collecting stats yet.

Quoted 2 lines

Perhaps we need another value of this, like "HW_STATS_MAY_DISABLED" for such case.

Or just redefine FLOW_ACTION_HW_STATS_DISABLED to define a bit in enum flow_action_hw_stats_bit.

enum flow_action_hw_stats_bit {
FLOW_ACTION_HW_STATES_DISABLED_BIT,
FLOW_ACTION_HW_STATS_IMMEDIATE_BIT,
FLOW_ACTION_HW_STATS_DELAYED_BIT,
};

Quoted 5 lines

Then update:

FLOW_ACTION_HW_STATS_ANY = FLOW_ACTION_HW_STATS_DISABLED |
FLOW_ACTION_HW_STATS_IMMEDIATE | FLOW_ACTION_HW_STATS_DELAYED,

No! That would break the default. "ANY" can never mean "disabled".

Quoted 50 lines

?

Quoted 5 lines

Because you don't care if the HW actually does the stats or not. It is an optimization for you.

However for TC, when user specifies "HW_STATS_DISABLED", the driver should not do stats.

My interpretation is that _DISABLED means that front-end does not request counters to the driver.

Quoted 16 lines
Quoted 16 lines

The user did not specify a counter in this case.

I think __flow_action_hw_stats_check() cannot work with FLOW_ACTION_HW_STATS_DISABLED.

If check_allow_bit is false and FLOW_ACTION_HW_STATS_DISABLED is specified, then this always evaluates true:

       if (!check_allow_bit &&
           action_entry->hw_stats != FLOW_ACTION_HW_STATS_ANY) {

Similarly:

       } else if (check_allow_bit &&
                  !(action_entry->hw_stats & BIT(allow_bit))) {
Quoted 6 lines
Quoted 2 lines

evaluates true for FLOW_ACTION_HW_STATS_DISABLED, assuming allow_bit is set, which I think it is the intention.

That is correct. __flow_action_hw_stats_check() helper is here for simple drivers that support just one type of hw stats (immediate/delayed).

If this is solved as I'm proposing above, then __flow_action_hw_stats_check() need to take a bitmask instead of enum flow_action_hw_stats_bit as parameter, because a driver need to specify what they support, eg.

if (!__flow_action_hw_stats_check(action, &extack,
FLOW_ACTION_HW_STATS_DISABLED | FLOW_ACTION_HW_STATS_DELAYED))
return -EOPNOSUPP;

or alternatively, if the driver supports any case:

if (!__flow_action_hw_stats_check(action, &extack,
FLOW_ACTION_HW_STATS_ANY))
return -EOPNOSUPP;

maintainer
#14 lore raw
In reply to Jiri Pirko
Quoted 12 lines · Jiri Pirko
Quoted 11 lines · Mon, Apr 20, 2020 at 02:39:15PM CEST, [email protected] wrote:
Quoted 9 lines · Edward Cree
Quoted 2 lines · Jiri Pirko

However for TC, when user specifies "HW_STATS_DISABLED", the driver should not do stats.

What should a driver do if the user specifies DISABLED, but the stats are still needed for internal bookkeeping (e.g. to prod an ARP entry that's in use for encapsulation offload, so that it doesn't get expired out of the cache)?  Enable the stats on the HW anyway but not report them to FLOW_CLS_STATS?  Or return an error?

Quoted 7 lines
Quoted 2 lines

My interpretation is that HW_STATS_DISABLED means that the front-end does not care / does not need counters. The driver can still allocate

That is wrong interpretation. If user does not care, he specifies "ANY". That is the default.

When he says "DISABLED" he means disabled. Not "I don't care".

Under what circumstances would the user care about this? Rejecting such config seems to be just to annoy user?

I mean, the user is forced to use SW datapath just because HW can't turn off stats?! Same for a config change, why do i need to change my rules to say 'enable stats' even though I don't need them in first place?

Unlike the inverse (want feature X but HW can't support it), it makes no sense to me to reject with an error here:
stats-off is just a hint that can be safely ignored.

#15 lore raw
Quoted 16 lines · Mon, Apr 20, 2020 at 03:57:54PM CEST, [email protected] wrote:
Quoted 15 lines · Jiri Pirko
Quoted 13 lines · Mon, Apr 20, 2020 at 02:39:15PM CEST, [email protected] wrote:
Quoted 9 lines · Edward Cree
Quoted 2 lines · Jiri Pirko

However for TC, when user specifies "HW_STATS_DISABLED", the driver should not do stats.

What should a driver do if the user specifies DISABLED, but the stats are still needed for internal bookkeeping (e.g. to prod an ARP entry that's in use for encapsulation offload, so that it doesn't get expired out of the cache)?  Enable the stats on the HW anyway but not report them to FLOW_CLS_STATS?  Or return an error?

My interpretation is that HW_STATS_DISABLED means that the front-end does not care / does not need counters. The driver can still allocate

Quoted 6 lines
Quoted 4 lines

That is wrong interpretation. If user does not care, he specifies "ANY". That is the default.

When he says "DISABLED" he means disabled. Not "I don't care".

Under what circumstances would the user care about this?

On some HW, the stats are separate resource. The user instructs the stats to be disabled so safe resources. It is explicit. He like to safe the resources for other usage (he can list them in devlink resource).

Quoted 1 line

Rejecting such config seems to be just to annoy user?

Well, the user passed the arg, he should know what is he doing. There's no annoyment.

Quoted 3 lines

I mean, the user is forced to use SW datapath just because HW can't turn off stats?! Same for a config change, why do i need to change my rules

By default, they are on. That is what user should do in most of the cases.

Quoted 1 line

to say 'enable stats' even though I don't need them in first place?

It may require to program HW differently (as in case of mlxsw).

Quoted 4 lines

Unlike the inverse (want feature X but HW can't support it), it makes no sense to me to reject with an error here:
stats-off is just a hint that can be safely ignored.

author maintainer
#16 lore raw
Quoted 1 line · Jiri Pirko

Mon, Apr 20, 2020 at 03:57:54PM CEST, [email protected] wrote:

[...]

Quoted 5 lines
Quoted 2 lines

I mean, the user is forced to use SW datapath just because HW can't turn off stats?! Same for a config change, why do i need to change my rules

By default, they are on. That is what user should do in most of the cases.

Fair enough, I can workaround this problem by using FLOW_ACTION_HW_STATS_ANY. However, I still don't need counters and there is no way to say "I don't care" to the drivers.

Note that the flow_offload infrastructure is used by ethtool, netfilter, flowtable and tc these days.

* ethtool's default behaviour is no counters.
* netfilter's default behaviour is no counters.
* flowtable's default behaviour is no counters.

I understand FLOW_ACTION_HW_STATS_DISABLED means disabled, strictly. But would you allow me to introduce FLOW_ACTION_HW_STATS_DONT_CARE to fix ethtool, netfilter and flowtable? :-)

FLOW_ACTION_HW_STATS_DONT_CARE means "this front-end doesn't need counters, let driver decide what it is best".

Thank you.

include/net/flow_offload.h +5 -1
index 3619c6acf60f..ae09d1911912 100644
@@ -164,17 +164,21 @@ enum flow_action_mangle_base {
 };
 
 enum flow_action_hw_stats_bit {
+	FLOW_ACTION_HW_STATS_DONT_CARE_BIT,
 	FLOW_ACTION_HW_STATS_IMMEDIATE_BIT,
 	FLOW_ACTION_HW_STATS_DELAYED_BIT,
 };
 
 enum flow_action_hw_stats {
 	FLOW_ACTION_HW_STATS_DISABLED = 0,
+	FLOW_ACTION_HW_STATS_DONT_CARE =
+		BIT(FLOW_ACTION_HW_STATS_DONT_CARE_BIT),
 	FLOW_ACTION_HW_STATS_IMMEDIATE =
 		BIT(FLOW_ACTION_HW_STATS_IMMEDIATE_BIT),
 	FLOW_ACTION_HW_STATS_DELAYED = BIT(FLOW_ACTION_HW_STATS_DELAYED_BIT),
 	FLOW_ACTION_HW_STATS_ANY = FLOW_ACTION_HW_STATS_IMMEDIATE |
-				   FLOW_ACTION_HW_STATS_DELAYED,
+				   FLOW_ACTION_HW_STATS_DELAYED |
+				   FLOW_ACTION_HW_STATS_DONT_CARE,
 };
 
 typedef void (*action_destr)(void *priv);
#17 lore raw
Quoted 44 lines · Mon, Apr 20, 2020 at 09:18:32PM CEST, [email protected] wrote:
Quoted 1 line · Jiri Pirko

Mon, Apr 20, 2020 at 03:57:54PM CEST, [email protected] wrote:

[...]

Quoted 5 lines
Quoted 2 lines

I mean, the user is forced to use SW datapath just because HW can't turn off stats?! Same for a config change, why do i need to change my rules

By default, they are on. That is what user should do in most of the cases.

Fair enough, I can workaround this problem by using FLOW_ACTION_HW_STATS_ANY. However, I still don't need counters and there is no way to say "I don't care" to the drivers.

Note that the flow_offload infrastructure is used by ethtool, netfilter, flowtable and tc these days.

* ethtool's default behaviour is no counters.
* netfilter's default behaviour is no counters.
* flowtable's default behaviour is no counters.

I understand FLOW_ACTION_HW_STATS_DISABLED means disabled, strictly. But would you allow me to introduce FLOW_ACTION_HW_STATS_DONT_CARE to fix ethtool, netfilter and flowtable? :-)

FLOW_ACTION_HW_STATS_DONT_CARE means "this front-end doesn't need counters, let driver decide what it is best".

Thank you.

include/net/flow_offload.h +1 -0
index 3619c6acf60f..ae09d1911912 100644
@@ -164,17 +164,21 @@ enum flow_action_mangle_base {
 };
 
 enum flow_action_hw_stats_bit {
+	FLOW_ACTION_HW_STATS_DONT_CARE_BIT,
 	FLOW_ACTION_HW_STATS_IMMEDIATE_BIT,
 	FLOW_ACTION_HW_STATS_DELAYED_BIT,
 };
 
 enum flow_action_hw_stats {

include/net/flow_offload.h enum flow_action_mangle_base { · line 181

Quoted 10 lines
include/net/flow_offload.h +4 -1
 	FLOW_ACTION_HW_STATS_DISABLED = 0,
+	FLOW_ACTION_HW_STATS_DONT_CARE =
+		BIT(FLOW_ACTION_HW_STATS_DONT_CARE_BIT),
 	FLOW_ACTION_HW_STATS_IMMEDIATE =
 		BIT(FLOW_ACTION_HW_STATS_IMMEDIATE_BIT),
 	FLOW_ACTION_HW_STATS_DELAYED = BIT(FLOW_ACTION_HW_STATS_DELAYED_BIT),
 	FLOW_ACTION_HW_STATS_ANY = FLOW_ACTION_HW_STATS_IMMEDIATE |
-				   FLOW_ACTION_HW_STATS_DELAYED,
+				   FLOW_ACTION_HW_STATS_DELAYED |
+				   FLOW_ACTION_HW_STATS_DONT_CARE,

"Any" can't be "don't care". TC User expects stats. That's default.

Let's have "don't care" bit only and set it for ethtool/netfilter/flowtable. Don't change any. Teach the drivers to deal with "don't care", most probably using the default checker.

Quoted 3 lines
include/net/flow_offload.h +0 -0
 };
 
 typedef void (*action_destr)(void *priv);
#18 lore raw
Quoted 5 lines · Jiri Pirko

"Any" can't be "don't care". TC User expects stats. That's default.

Let's have "don't care" bit only and set it for ethtool/netfilter/flowtable. Don't change any. Teach the drivers to deal with "don't care", most probably using the default checker.

I think the right solution is either this, or the semantically-similar approach of "0 means don't care, we have a bit for disabled, and ANY (the TC default) is "all the bits except disabled", i.e. DELAYED | IMMEDIATE.  That seems slightly cleaner to me, as then non- zero settings are always "here is a bitmask of options, driver may choose any of them".  (And 0 differs from DELAYED | IMMEDIATE | DISABLED only in that if new bits are added to kernel, 0 includes them.) And of course either way the TC uAPI needs to be able to specify the new "don't care" option.

-ed

maintainer
#19 lore raw
Quoted 6 lines · On Mon, 27 Apr 2020 15:31:48 +0100 Edward Cree wrote:
Quoted 5 lines · Jiri Pirko

"Any" can't be "don't care". TC User expects stats. That's default.

Let's have "don't care" bit only and set it for ethtool/netfilter/flowtable. Don't change any. Teach the drivers to deal with "don't care", most probably using the default checker.

Quoted 7 lines

I think the right solution is either this, or the semantically-similar approach of "0 means don't care, we have a bit for disabled, and ANY (the TC default) is "all the bits except disabled", i.e. DELAYED | IMMEDIATE.  That seems slightly cleaner to me, as then non- zero settings are always "here is a bitmask of options, driver may choose any of them".  (And 0 differs from DELAYED | IMMEDIATE | DISABLED only in that if new bits are added to kernel, 0 includes them.)

+1

Quoted 2 lines

And of course either way the TC uAPI needs to be able to specify the new "don't care" option.