netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Ariel Almog <ariela@mellanox.com>,
	Tonghao Zhang <xiangxia.m.yue@gmail.com>,
	Saeed Mahameed <saeedm@mellanox.com>
Subject: [net-next 05/11] net/mlx5e: Introduce mlx5e_flow_esw_attr_init() helper
Date: Tue, 19 Feb 2019 14:19:51 -0800	[thread overview]
Message-ID: <20190219221957.2899-6-saeedm@mellanox.com> (raw)
In-Reply-To: <20190219221957.2899-1-saeedm@mellanox.com>

From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

Introduce the mlx5e_flow_esw_attr_init() helper
for simplifying codes.

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 .../net/ethernet/mellanox/mlx5/core/en_tc.c   | 41 +++++++++++++------
 1 file changed, 29 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 43b7191e94b2..1df7e7d6431b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -2733,6 +2733,30 @@ mlx5e_alloc_flow(struct mlx5e_priv *priv, int attr_size,
 	return err;
 }
 
+static void
+mlx5e_flow_esw_attr_init(struct mlx5_esw_flow_attr *esw_attr,
+			 struct mlx5e_priv *priv,
+			 struct mlx5e_tc_flow_parse_attr *parse_attr,
+			 struct tc_cls_flower_offload *f,
+			 struct mlx5_eswitch_rep *in_rep,
+			 struct mlx5_core_dev *in_mdev)
+{
+	struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
+
+	esw_attr->parse_attr = parse_attr;
+	esw_attr->chain = f->common.chain_index;
+	esw_attr->prio = TC_H_MAJ(f->common.prio) >> 16;
+
+	esw_attr->in_rep = in_rep;
+	esw_attr->in_mdev = in_mdev;
+
+	if (MLX5_CAP_ESW(esw->dev, counter_eswitch_affinity) ==
+	    MLX5_COUNTER_SOURCE_ESWITCH)
+		esw_attr->counter_dev = in_mdev;
+	else
+		esw_attr->counter_dev = priv->mdev;
+}
+
 static struct mlx5e_tc_flow *
 __mlx5e_add_fdb_flow(struct mlx5e_priv *priv,
 		     struct tc_cls_flower_offload *f,
@@ -2754,28 +2778,21 @@ __mlx5e_add_fdb_flow(struct mlx5e_priv *priv,
 			       &parse_attr, &flow);
 	if (err)
 		goto out;
+
 	parse_attr->filter_dev = filter_dev;
-	flow->esw_attr->parse_attr = parse_attr;
+	mlx5e_flow_esw_attr_init(flow->esw_attr,
+				 priv, parse_attr,
+				 f, in_rep, in_mdev);
+
 	err = parse_cls_flower(flow->priv, flow, &parse_attr->spec,
 			       f, filter_dev);
 	if (err)
 		goto err_free;
 
-	flow->esw_attr->chain = f->common.chain_index;
-	flow->esw_attr->prio = TC_H_MAJ(f->common.prio) >> 16;
 	err = parse_tc_fdb_actions(priv, &rule->action, parse_attr, flow, extack);
 	if (err)
 		goto err_free;
 
-	flow->esw_attr->in_rep = in_rep;
-	flow->esw_attr->in_mdev = in_mdev;
-
-	if (MLX5_CAP_ESW(esw->dev, counter_eswitch_affinity) ==
-	    MLX5_COUNTER_SOURCE_ESWITCH)
-		flow->esw_attr->counter_dev = in_mdev;
-	else
-		flow->esw_attr->counter_dev = priv->mdev;
-
 	err = mlx5e_tc_add_fdb_flow(priv, parse_attr, flow, extack);
 	if (err)
 		goto err_free;
-- 
2.20.1


  parent reply	other threads:[~2019-02-19 22:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-19 22:19 [pull request][net-next 00/11] Mellanox, mlx5 updates 2019-02-19 Saeed Mahameed
2019-02-19 22:19 ` [net-next 01/11] ethtool: Added support for 50Gbps per lane link modes Saeed Mahameed
2019-02-19 22:19 ` [net-next 02/11] net/mlx5: ethtool, Add ethtool " Saeed Mahameed
2019-02-19 22:19 ` [net-next 03/11] net/mlx5e: Wrap the open and apply of channels in one fail-safe function Saeed Mahameed
2019-02-19 22:19 ` [net-next 04/11] net/mlx5e: Remove wrong and superfluous tc pedit header type check Saeed Mahameed
2019-02-19 22:19 ` Saeed Mahameed [this message]
2019-02-19 22:19 ` [net-next 06/11] net/mlx5e: Remove 'parse_attr' argument in mlx5e_tc_add_fdb_flow() Saeed Mahameed
2019-02-19 22:19 ` [net-next 07/11] net/mlx5e: Add missing static function annotation Saeed Mahameed
2019-02-19 22:19 ` [net-next 08/11] net/mlx5: Delete unused FPGA QPN variable Saeed Mahameed
2019-02-19 22:19 ` [net-next 09/11] net/mlx5e: Remove unused variable ‘esw’ Saeed Mahameed
2019-02-19 22:19 ` [net-next 10/11] net/mlx5: E-Switch, Fix the warning on vport index out of range Saeed Mahameed
2019-02-19 22:19 ` [net-next 11/11] net/mlx5: E-Switch, Disable esw manager vport correctly Saeed Mahameed
2019-02-21  4:15 ` [pull request][net-next 00/11] Mellanox, mlx5 updates 2019-02-19 David Miller

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=20190219221957.2899-6-saeedm@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=ariela@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=xiangxia.m.yue@gmail.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).