flow_offload: follow-ups to HW stats type patchset
cover flow_offload: follow-ups to HW stats type patchset
This patchset includes couple of patches in reaction to the discussions to the original HW stats patchset. The first patch is a fix, the other two patches are basically cosmetics.
Jiri Pirko (3):
flow_offload: fix allowed types check
flow_offload: turn hw_stats_type into dedicated enum
flow_offload: restrict driver to pass one allowed bit to
flow_action_hw_stats_types_check()
.../net/ethernet/mellanox/mlx5/core/en_tc.c | 4 +- include/net/flow_offload.h | 46 +++++++++++++------ 2 files changed, 35 insertions(+), 15 deletions(-)
Signature · 1 line
2.21.1
PATCH 1/3 flow_offload: fix allowed types check
Change the check to see if the passed allowed type bit is enabled.
--- include/net/flow_offload.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/flow_offload.h +1 -1
@@ -306,7 +306,7 @@ flow_action_hw_stats_types_check(const struct flow_action *action,NL_SET_ERR_MSG_MOD (extack,"Driver supports only default HW stats type \"any\"" );return false; }else if (allowed_hw_stats_type !=0 && - action_entry->hw_stats_type != allowed_hw_stats_type) { + !(action_entry->hw_stats_type & allowed_hw_stats_type)) {NL_SET_ERR_MSG_MOD (extack,"Driver does not support selected HW stats type" );return false; }
Signature · 1 line
2.21.1
PATCH 2/3 flow_offload: turn hw_stats_type into dedicated enum
In reply to Jiri PirkoPut the values into enum and add an enum to define the bits.
--- include/net/flow_offload.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
include/net/flow_offload.h +16 -6
@@ -155,11 +155,21 @@ enum flow_action_mangle_base { FLOW_ACT_MANGLE_HDR_TYPE_UDP, }; -#define FLOW_ACTION_HW_STATS_TYPE_IMMEDIATE BIT(0) -#define FLOW_ACTION_HW_STATS_TYPE_DELAYED BIT(1) -#define FLOW_ACTION_HW_STATS_TYPE_ANY (FLOW_ACTION_HW_STATS_TYPE_IMMEDIATE | \ - FLOW_ACTION_HW_STATS_TYPE_DELAYED) -#define FLOW_ACTION_HW_STATS_TYPE_DISABLED 0 +enum flow_action_hw_stats_type_bit { +FLOW_ACTION_HW_STATS_TYPE_IMMEDIATE_BIT , +FLOW_ACTION_HW_STATS_TYPE_DELAYED_BIT , +}; + +enum flow_action_hw_stats_type { +FLOW_ACTION_HW_STATS_TYPE_DISABLED =0 , +FLOW_ACTION_HW_STATS_TYPE_IMMEDIATE = +BIT (FLOW_ACTION_HW_STATS_TYPE_IMMEDIATE_BIT ), +FLOW_ACTION_HW_STATS_TYPE_DELAYED = +BIT (FLOW_ACTION_HW_STATS_TYPE_DELAYED_BIT ), +FLOW_ACTION_HW_STATS_TYPE_ANY = +FLOW_ACTION_HW_STATS_TYPE_IMMEDIATE | +FLOW_ACTION_HW_STATS_TYPE_DELAYED , +};typedef void (*action_destr )(void *priv);
@@ -175,7 +185,7 @@ void flow_action_cookie_destroy(struct flow_action_cookie *cookie);struct flow_action_entry {enum flow_action_id id; -u8 hw_stats_type; +enum flow_action_hw_stats_type hw_stats_type;action_destr destructor;void *destructor_priv;union {
Signature · 1 line
2.21.1
PATCH 3/3 flow_offload: restrict driver to pass one allowed bit to flow_action_hw_stats_types_check()
In reply to Jiri PirkoThe intention of this helper was to allow driver to specify one type that it supports, so not only "any" value would pass. So make the API more strict and allow driver to pass only 1 bit that is going to be checked.
--- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 4 ++-- include/net/flow_offload.h | 24 +++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +2 -2
@@ -2879,7 +2879,7 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv,return -EINVAL ;if (!flow_action_hw_stats_types_check (flow_action, extack, -FLOW_ACTION_HW_STATS_TYPE_DELAYED )) +FLOW_ACTION_HW_STATS_TYPE_DELAYED_BIT ))return -EOPNOTSUPP ; attr->flow_tag =MLX5_FS_DEFAULT_FLOW_TAG ;
@@ -3374,7 +3374,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,return -EINVAL ;if (!flow_action_hw_stats_types_check (flow_action, extack, -FLOW_ACTION_HW_STATS_TYPE_DELAYED )) +FLOW_ACTION_HW_STATS_TYPE_DELAYED_BIT ))return -EOPNOTSUPP ;flow_action_for_each (i, act, flow_action) {
include/net/flow_offload.h +17 -7
@@ -300,9 +300,10 @@ flow_action_first_entry_get(const struct flow_action *action) }static inline bool -flow_action_hw_stats_types_check (const struct flow_action *action, -struct netlink_ext_ack *extack, -u8 allowed_hw_stats_type) +__flow_action_hw_stats_types_check (const struct flow_action *action, +struct netlink_ext_ack *extack, +bool check_allow_bit, +enum flow_action_hw_stats_type_bit allow_bit) {const struct flow_action_entry *action_entry;
@@ -311,23 +312,32 @@ flow_action_hw_stats_types_check(const struct flow_action *action,if (!flow_action_mixed_hw_stats_types_check (action, extack))return false; action_entry =flow_action_first_entry_get (action); -if (allowed_hw_stats_type ==0 && +if (!check_allow_bit && action_entry->hw_stats_type !=FLOW_ACTION_HW_STATS_TYPE_ANY ) {NL_SET_ERR_MSG_MOD (extack,"Driver supports only default HW stats type \"any\"" );return false; - }else if (allowed_hw_stats_type !=0 && - !(action_entry->hw_stats_type & allowed_hw_stats_type)) { + }else if (check_allow_bit && + !(action_entry->hw_stats_type &BIT (allow_bit))) {NL_SET_ERR_MSG_MOD (extack,"Driver does not support selected HW stats type" );return false; }return true; } +static inline bool +flow_action_hw_stats_types_check (const struct flow_action *action, +struct netlink_ext_ack *extack, +enum flow_action_hw_stats_type_bit allow_bit) +{ +return __flow_action_hw_stats_types_check (action, extack, + true, allow_bit); +} +static inline bool flow_action_basic_hw_stats_types_check (const struct flow_action *action,struct netlink_ext_ack *extack) { -return flow_action_hw_stats_types_check (action, extack,0 ); +return __flow_action_hw_stats_types_check (action, extack, false,0 ); }struct flow_rule {
Signature · 1 line
2.21.1
Quoted 10 lines · Jiri Pirko
This patchset includes couple of patches in reaction to the discussions to the original HW stats patchset. The first patch is a fix, the other two patches are basically cosmetics.
Jiri Pirko (3):
flow_offload: fix allowed types check
flow_offload: turnhw_stats_typeinto dedicated enum
flow_offload: restrict driver to pass one allowed bit to
flow_action_hw_stats_types_check()
Quoted 4 lines
.../net/ethernet/mellanox/mlx5/core/en_tc.c | 4 +- include/net/flow_offload.h | 46 +++++++++++++------ 2 files changed, 35 insertions(+), 15 deletions(-)
Quoted 3 lines · On Tue, 10 Mar 2020 16:49:06 +0100 Jiri Pirko wrote:
This patchset includes couple of patches in reaction to the discussions to the original HW stats patchset. The first patch is a fix, the other two patches are basically cosmetics.
This problem already exists, but writing a patch for nfp I noticed that there is no way for this:
if (!flow_action_hw_stats_types_check(flow_action, extack, FLOW_ACTION_HW_STATS_TYPE_DELAYED_BIT)) return -EOPNOTSUPP;
to fit on a line for either bit, which kind of sucks.
I may send a rename...
Quoted 7 lines · Tue, Mar 10, 2020 at 08:05:19PM CET, [email protected] wrote:
Quoted 3 lines · On Tue, 10 Mar 2020 16:49:06 +0100 Jiri Pirko wrote:
This patchset includes couple of patches in reaction to the discussions to the original HW stats patchset. The first patch is a fix, the other two patches are basically cosmetics.
Reviewed-by Jakub Kicinski <[email protected]>
Quoted 8 lines
This problem already exists, but writing a patch for nfp I noticed that there is no way for this:
if (!flow_action_hw_stats_types_check(flow_action, extack, FLOW_ACTION_HW_STATS_TYPE_DELAYED_BIT)) return -EOPNOTSUPP;to fit on a line for either bit, which kind of sucks.
Yeah, I was thinking about having flow_action_hw_stats_types_check as a macro and then just simply have:
if (!flow_action_hw_stats_types_check(flow_action, extack, DELAYED)) return -EOPNOTSUPP;
WDYT?
Quoted 2 lines
I may send a rename...
Jakub Kicinski
maintainerQuoted 17 lines · On Wed, 11 Mar 2020 08:19:55 +0100 Jiri Pirko wrote:
Quoted 7 lines · Tue, Mar 10, 2020 at 08:05:19PM CET, [email protected] wrote:
Quoted 3 lines · On Tue, 10 Mar 2020 16:49:06 +0100 Jiri Pirko wrote:
This patchset includes couple of patches in reaction to the discussions to the original HW stats patchset. The first patch is a fix, the other two patches are basically cosmetics.
Reviewed-by Jakub Kicinski <[email protected]>Quoted 8 lines
This problem already exists, but writing a patch for nfp I noticed that there is no way for this:
if (!flow_action_hw_stats_types_check(flow_action, extack, FLOW_ACTION_HW_STATS_TYPE_DELAYED_BIT)) return -EOPNOTSUPP;to fit on a line for either bit, which kind of sucks.
Quoted 7 lines
Yeah, I was thinking about having
flow_action_hw_stats_types_checkas a macro and then just simply have:if (!flow_action_hw_stats_types_check(flow_action, extack, DELAYED)) return -EOPNOTSUPP;WDYT?
I'd rather have the 80+ lines than not be able to grep for it :(
What's wrong with flow_action_stats_ok()? Also perhaps, flow_act as a prefix?
Quoted 24 lines · Wed, Mar 11, 2020 at 09:30:28PM CET, [email protected] wrote:
Quoted 23 lines · On Wed, 11 Mar 2020 08:19:55 +0100 Jiri Pirko wrote:
Quoted 7 lines · Tue, Mar 10, 2020 at 08:05:19PM CET, [email protected] wrote:
Quoted 3 lines · On Tue, 10 Mar 2020 16:49:06 +0100 Jiri Pirko wrote:
This patchset includes couple of patches in reaction to the discussions to the original HW stats patchset. The first patch is a fix, the other two patches are basically cosmetics.
Reviewed-by Jakub Kicinski <[email protected]>Quoted 8 lines
This problem already exists, but writing a patch for nfp I noticed that there is no way for this:
if (!flow_action_hw_stats_types_check(flow_action, extack, FLOW_ACTION_HW_STATS_TYPE_DELAYED_BIT)) return -EOPNOTSUPP;to fit on a line for either bit, which kind of sucks.
Yeah, I was thinking about having
flow_action_hw_stats_types_checkas a macro and then just simply have:if (!flow_action_hw_stats_types_check(flow_action, extack, DELAYED)) return -EOPNOTSUPP;
Quoted 6 lines
Quoted 1 line
WDYT?
I'd rather have the 80+ lines than not be able to grep for it :(
What's wrong with
flow_action_stats_ok()? Also perhaps,flow_actas a prefix?
Well nothing, just that we'd loose consistency. Everything is "flow_action_*" and also, the name you suggest might indicate that you are checking sw stats. :/
Jakub Kicinski
maintainerQuoted 27 lines · On Thu, 12 Mar 2020 08:03:59 +0100 Jiri Pirko wrote:
Quoted 26 lines · Wed, Mar 11, 2020 at 09:30:28PM CET, [email protected] wrote:
Quoted 24 lines · On Wed, 11 Mar 2020 08:19:55 +0100 Jiri Pirko wrote:
Quoted 7 lines · Tue, Mar 10, 2020 at 08:05:19PM CET, [email protected] wrote:
Quoted 3 lines · On Tue, 10 Mar 2020 16:49:06 +0100 Jiri Pirko wrote:
This patchset includes couple of patches in reaction to the discussions to the original HW stats patchset. The first patch is a fix, the other two patches are basically cosmetics.
Reviewed-by Jakub Kicinski <[email protected]>Quoted 8 lines
This problem already exists, but writing a patch for nfp I noticed that there is no way for this:
if (!flow_action_hw_stats_types_check(flow_action, extack, FLOW_ACTION_HW_STATS_TYPE_DELAYED_BIT)) return -EOPNOTSUPP;to fit on a line for either bit, which kind of sucks.
Yeah, I was thinking about having
flow_action_hw_stats_types_checkas a macro and then just simply have:if (!flow_action_hw_stats_types_check(flow_action, extack, DELAYED)) return -EOPNOTSUPP;WDYT?
Quoted 8 lines
Quoted 4 lines
I'd rather have the 80+ lines than not be able to grep for it :(
What's wrong with
flow_action_stats_ok()? Also perhaps,flow_actas a prefix?Well nothing, just that we'd loose consistency. Everything is "flow_action_*" and also, the name you suggest might indicate that you are checking sw stats. :/
SW stats in flow action? flow stuff is an abstraction for HW/drivers.
David Miller
maintainerFrom: Jiri Pirko <[email protected]>
Date: Tue, 10 Mar 2020 16:49:06 +0100
Quoted 3 lines
This patchset includes couple of patches in reaction to the discussions to the original HW stats patchset. The first patch is a fix, the other two patches are basically cosmetics.
Series applied, thanks Jiri.