netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Roi Dayan <roid@nvidia.com>,
	Oz Shlomo <ozsh@nvidia.com>, Maor Dickman <maord@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>
Subject: [net-next v0 12/14] net/mlx5e: TC, Move common flow_action checks into function
Date: Thu,  2 Dec 2021 16:56:20 -0800	[thread overview]
Message-ID: <20211203005622.183325-13-saeed@kernel.org> (raw)
In-Reply-To: <20211203005622.183325-1-saeed@kernel.org>

From: Roi Dayan <roid@nvidia.com>

Remove duplicate checks on flow_action by using common function.

Signed-off-by: Roi Dayan <roid@nvidia.com>
Reviewed-by: Oz Shlomo <ozsh@nvidia.com>
Reviewed-by: Maor Dickman <maord@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../net/ethernet/mellanox/mlx5/core/en_tc.c   | 44 ++++++++++---------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 3c5e9efb9873..c7f1c93709cd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -3444,6 +3444,24 @@ actions_prepare_mod_hdr_actions(struct mlx5e_priv *priv,
 	return 0;
 }
 
+static int
+flow_action_supported(struct flow_action *flow_action,
+		      struct netlink_ext_ack *extack)
+{
+	if (!flow_action_has_entries(flow_action)) {
+		NL_SET_ERR_MSG_MOD(extack, "Flow action doesn't have any entries");
+		return -EINVAL;
+	}
+
+	if (!flow_action_hw_stats_check(flow_action, extack,
+					FLOW_ACTION_HW_STATS_DELAYED_BIT)) {
+		NL_SET_ERR_MSG_MOD(extack, "Flow action HW stats type is not supported");
+		return -EOPNOTSUPP;
+	}
+
+	return 0;
+}
+
 static int
 parse_tc_nic_actions(struct mlx5e_priv *priv,
 		     struct flow_action *flow_action,
@@ -3457,16 +3475,9 @@ parse_tc_nic_actions(struct mlx5e_priv *priv,
 	struct mlx5_nic_flow_attr *nic_attr;
 	int err, i;
 
-	if (!flow_action_has_entries(flow_action)) {
-		NL_SET_ERR_MSG_MOD(extack, "Flow action doesn't have any entries");
-		return -EINVAL;
-	}
-
-	if (!flow_action_hw_stats_check(flow_action, extack,
-					FLOW_ACTION_HW_STATS_DELAYED_BIT)) {
-		NL_SET_ERR_MSG_MOD(extack, "Flow action HW stats type is not supported");
-		return -EOPNOTSUPP;
-	}
+	err = flow_action_supported(flow_action, extack);
+	if (err)
+		return err;
 
 	nic_attr = attr->nic_attr;
 	nic_attr->flow_tag = MLX5_FS_DEFAULT_FLOW_TAG;
@@ -3883,16 +3894,9 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
 	bool ptype_host = false;
 	bool mpls_push = false;
 
-	if (!flow_action_has_entries(flow_action)) {
-		NL_SET_ERR_MSG_MOD(extack, "Flow action doesn't have any entries");
-		return -EINVAL;
-	}
-
-	if (!flow_action_hw_stats_check(flow_action, extack,
-					FLOW_ACTION_HW_STATS_DELAYED_BIT)) {
-		NL_SET_ERR_MSG_MOD(extack, "Flow action HW stats type is not supported");
-		return -EOPNOTSUPP;
-	}
+	err = flow_action_supported(flow_action, extack);
+	if (err)
+		return err;
 
 	esw_attr = attr->esw_attr;
 	parse_attr = attr->parse_attr;
-- 
2.31.1


  parent reply	other threads:[~2021-12-03  0:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-03  0:56 [pull request][net-next v0 00/14] mlx5 updates 2021-12-02 Saeed Mahameed
2021-12-03  0:56 ` [net-next v0 01/14] mlx5: fix psample_sample_packet link error Saeed Mahameed
2021-12-03  3:20   ` patchwork-bot+netdevbpf
2021-12-03  0:56 ` [net-next v0 02/14] mlx5: fix mlx5i_grp_sw_update_stats() stack usage Saeed Mahameed
2021-12-03  0:56 ` [net-next v0 03/14] net/mlx5: Fix error return code in esw_qos_create() Saeed Mahameed
2021-12-03  0:56 ` [net-next v0 04/14] net/mlx5: Fix some error handling paths in 'mlx5e_tc_add_fdb_flow()' Saeed Mahameed
2021-12-03  0:56 ` [net-next v0 05/14] net/mlx5: SF, silence an uninitialized variable warning Saeed Mahameed
2021-12-03  0:56 ` [net-next v0 06/14] net/mlx5: Print more info on pci error handlers Saeed Mahameed
2021-12-03  0:56 ` [net-next v0 07/14] net/mlx5e: SHAMPO, clean MLX5E_MAX_KLM_PER_WQE macro Saeed Mahameed
2021-12-03  0:56 ` [net-next v0 08/14] net/mlx5e: Hide function mlx5e_num_channels_changed Saeed Mahameed
2021-12-03  0:56 ` [net-next v0 09/14] net/mlx5e: TC, Remove redundant action stack var Saeed Mahameed
2021-12-03  0:56 ` [net-next v0 10/14] net/mlx5e: Remove redundant actions arg from validate_goto_chain() Saeed Mahameed
2021-12-03  0:56 ` [net-next v0 11/14] net/mlx5e: Remove redundant actions arg from vlan push/pop funcs Saeed Mahameed
2021-12-03  0:56 ` Saeed Mahameed [this message]
2021-12-03  0:56 ` [net-next v0 13/14] net/mlx5e: TC, Set flow attr ip_version earlier Saeed Mahameed
2021-12-03  0:56 ` [net-next v0 14/14] net/mlx5: Dynamically resize flow counters query buffer Saeed Mahameed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211203005622.183325-13-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=maord@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=ozsh@nvidia.com \
    --cc=roid@nvidia.com \
    --cc=saeedm@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).