summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2020-03-11 02:04:19 +0300
committerDavid S. Miller <davem@davemloft.net>2020-03-11 02:04:19 +0300
commit377bb76444a1c501e551522af6039ef7f33b0fa3 (patch)
tree8db1b7e7a3bbd559c06c7e996eab3dd23d7ff1dc
parent79c57bffebe83ad0a7395f62596dc2e8d29a9ede (diff)
parenta16fa289843d5d4dd7c4d8eb3b2deb15a9d2180e (diff)
downloadlinux-377bb76444a1c501e551522af6039ef7f33b0fa3.tar.xz
Merge branch 'flow_offload-follow-ups-to-HW-stats-type-patchset'
Jiri Pirko says: ==================== 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. ==================== Acked-by: Edward Cree <ecree@solarflare.com> Reviewed-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tc.c4
-rw-r--r--include/net/flow_offload.h46
2 files changed, 35 insertions, 15 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 33d3e70418fb..f285713def77 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -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) {
diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index 891e15055708..d1b1e4aa310a 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -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 {
@@ -290,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;
@@ -301,12 +312,12 @@ 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;
}
@@ -314,10 +325,19 @@ flow_action_hw_stats_types_check(const struct flow_action *action,
}
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 {