diff mbox series

[net-next,06/10] mlxsw: restrict supported HW stats type to "any"

Message ID 20200221095643.6642-7-jiri@resnulli.us
State Changes Requested
Delegated to: David Miller
Headers show
Series net: allow user specify TC filter HW stats type | expand

Commit Message

Jiri Pirko Feb. 21, 2020, 9:56 a.m. UTC
From: Jiri Pirko <jiri@mellanox.com>

Currently don't allow rules with any other type to be inserted.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 .../ethernet/mellanox/mlxsw/spectrum_flower.c | 28 +++++++++++++------
 1 file changed, 19 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
index b607919c8ad0..ef0799a539d2 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
@@ -14,11 +14,13 @@ 
 #include "spectrum.h"
 #include "core_acl_flex_keys.h"
 
-static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
-					 struct mlxsw_sp_acl_block *block,
-					 struct mlxsw_sp_acl_rule_info *rulei,
-					 struct flow_action *flow_action,
-					 struct netlink_ext_ack *extack)
+static int
+mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
+			      struct mlxsw_sp_acl_block *block,
+			      struct mlxsw_sp_acl_rule_info *rulei,
+			      struct flow_action *flow_action,
+			      enum flow_cls_hw_stats_type hw_stats_type,
+			      struct netlink_ext_ack *extack)
 {
 	const struct flow_action_entry *act;
 	int mirror_act_count = 0;
@@ -27,10 +29,17 @@  static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
 	if (!flow_action_has_entries(flow_action))
 		return 0;
 
-	/* Count action is inserted first */
-	err = mlxsw_sp_acl_rulei_act_count(mlxsw_sp, rulei, extack);
-	if (err)
-		return err;
+	switch (hw_stats_type) {
+	case FLOW_CLS_HW_STATS_TYPE_ANY:
+		/* Count action is inserted first */
+		err = mlxsw_sp_acl_rulei_act_count(mlxsw_sp, rulei, extack);
+		if (err)
+			return err;
+		break;
+	default:
+		NL_SET_ERR_MSG_MOD(extack, "Unsupported HW stats type");
+		return -EOPNOTSUPP;
+	}
 
 	flow_action_for_each(i, act, flow_action) {
 		switch (act->id) {
@@ -449,6 +458,7 @@  static int mlxsw_sp_flower_parse(struct mlxsw_sp *mlxsw_sp,
 
 	return mlxsw_sp_flower_parse_actions(mlxsw_sp, block, rulei,
 					     &f->rule->action,
+					     f->common.hw_stats_type,
 					     f->common.extack);
 }