All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
To: "David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
	Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Mark Bloch <markb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Saeed Mahameed <saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: [for-next 02/11] net/mlx5: E-Switch, Refactor load/unload of representors
Date: Tue, 19 Dec 2017 12:33:31 -0800	[thread overview]
Message-ID: <20171219203340.2600-3-saeedm@mellanox.com> (raw)
In-Reply-To: <20171219203340.2600-1-saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

From: Mark Bloch <markb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

Refactor the load/unload stages for better code reuse.

Signed-off-by: Mark Bloch <markb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Reviewed-by: Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Saeed Mahameed <saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
 .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 66 +++++++++++++---------
 1 file changed, 40 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 230b05842cb0..139da9f3cc70 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -768,12 +768,47 @@ int esw_offloads_init_reps(struct mlx5_eswitch *esw)
 	return 0;
 }
 
-int esw_offloads_init(struct mlx5_eswitch *esw, int nvports)
+static void esw_offloads_unload_reps(struct mlx5_eswitch *esw, int nvports)
+{
+	struct mlx5_eswitch_rep *rep;
+	int vport;
+
+	for (vport = nvports - 1; vport >= 0; vport--) {
+		rep = &esw->offloads.vport_reps[vport];
+		if (!rep->valid)
+			continue;
+
+		rep->unload(esw, rep);
+	}
+}
+
+static int esw_offloads_load_reps(struct mlx5_eswitch *esw, int nvports)
 {
 	struct mlx5_eswitch_rep *rep;
 	int vport;
 	int err;
 
+	for (vport = 0; vport < nvports; vport++) {
+		rep = &esw->offloads.vport_reps[vport];
+		if (!rep->valid)
+			continue;
+
+		err = rep->load(esw, rep);
+		if (err)
+			goto err_reps;
+	}
+
+	return 0;
+
+err_reps:
+	esw_offloads_unload_reps(esw, vport);
+	return err;
+}
+
+int esw_offloads_init(struct mlx5_eswitch *esw, int nvports)
+{
+	int err;
+
 	/* disable PF RoCE so missed packets don't go through RoCE steering */
 	mlx5_dev_list_lock();
 	mlx5_remove_dev_by_protocol(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
@@ -791,25 +826,13 @@ int esw_offloads_init(struct mlx5_eswitch *esw, int nvports)
 	if (err)
 		goto create_fg_err;
 
-	for (vport = 0; vport < nvports; vport++) {
-		rep = &esw->offloads.vport_reps[vport];
-		if (!rep->valid)
-			continue;
-
-		err = rep->load(esw, rep);
-		if (err)
-			goto err_reps;
-	}
+	err = esw_offloads_load_reps(esw, nvports);
+	if (err)
+		goto err_reps;
 
 	return 0;
 
 err_reps:
-	for (vport--; vport >= 0; vport--) {
-		rep = &esw->offloads.vport_reps[vport];
-		if (!rep->valid)
-			continue;
-		rep->unload(esw, rep);
-	}
 	esw_destroy_vport_rx_group(esw);
 
 create_fg_err:
@@ -850,16 +873,7 @@ static int esw_offloads_stop(struct mlx5_eswitch *esw)
 
 void esw_offloads_cleanup(struct mlx5_eswitch *esw, int nvports)
 {
-	struct mlx5_eswitch_rep *rep;
-	int vport;
-
-	for (vport = nvports - 1; vport >= 0; vport--) {
-		rep = &esw->offloads.vport_reps[vport];
-		if (!rep->valid)
-			continue;
-		rep->unload(esw, rep);
-	}
-
+	esw_offloads_unload_reps(esw, nvports);
 	esw_destroy_vport_rx_group(esw);
 	esw_destroy_offloads_table(esw);
 	esw_destroy_offloads_fdb_tables(esw);
-- 
2.14.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-12-19 20:33 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-19 20:33 [pull request][for-next 00/11] Mellanox, mlx5 E-Switch updates 2017-12-19 Saeed Mahameed
2017-12-19 20:33 ` [for-next 03/11] net/mlx5: E-Switch, Simplify representor load/unload callback API Saeed Mahameed
2017-12-19 20:33 ` [for-next 04/11] net/mlx5: E-Switch, Move mlx5e only logic outside E-Switch Saeed Mahameed
2017-12-19 20:33 ` [for-next 05/11] net/mlx5: E-Switch, Create a dedicated send to vport rule deletion function Saeed Mahameed
2017-12-19 20:33 ` [for-next 06/11] net/mlx5e: Move ethernet representors data into separate struct Saeed Mahameed
2017-12-19 20:33 ` [for-next 07/11] net/mlx5: E-Switch, Create generic header struct to be used by representors Saeed Mahameed
2017-12-20 17:58   ` David Miller
     [not found]     ` <20171220.125858.1378708055295289661.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2017-12-20 19:22       ` Mark Bloch
2017-12-19 20:33 ` [for-next 08/11] net/mlx5e: E-Switch, Move send-to-vport rule struct to en_rep Saeed Mahameed
2017-12-19 20:33 ` [for-next 09/11] net/mlx5e: E-Switch, Use the name of static array instead of its address Saeed Mahameed
2017-12-19 20:33 ` [for-next 10/11] net/mlx5: Fix ingress/egress naming mistake Saeed Mahameed
2017-12-19 20:33 ` [for-next 11/11] net/mlx5: Separate ingress/egress namespaces for each vport Saeed Mahameed
     [not found] ` <20171219203340.2600-1-saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-12-19 20:33   ` [for-next 01/11] net/mlx5: E-Switch, Refactor vport representors initialization Saeed Mahameed
     [not found]     ` <20171219203340.2600-2-saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-12-20 17:57       ` David Miller
2017-12-20 19:21         ` Mark Bloch
     [not found]           ` <066d5ac8-e95a-f4ec-fda7-31716242cc05-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-12-20 19:45             ` David Miller
2017-12-19 20:33   ` Saeed Mahameed [this message]
2017-12-19 21:54   ` [pull request][for-next 00/11] Mellanox, mlx5 E-Switch updates 2017-12-19 Marcelo Ricardo Leitner
     [not found]     ` <20171219215414.GH6122-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2017-12-19 22:39       ` Saeed Mahameed
     [not found]         ` <CALzJLG9i4g7c8vKbw7k+o=Pv5GcqWi6AATpOQXj09_KwqvWkmQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-12-19 22:46           ` Marcelo Ricardo Leitner
     [not found]             ` <20171219224600.GJ6122-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2017-12-19 23:36               ` Saeed Mahameed
2017-12-20 17:56   ` David Miller
     [not found]     ` <20171220.125631.1837619997849298593.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2017-12-21  6:19       ` Saeed Mahameed
     [not found]         ` <1513837142.18312.27.camel-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-12-21 15:03           ` David Miller
2017-12-24 11:08             ` 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=20171219203340.2600-3-saeedm@mellanox.com \
    --to=saeedm-vpraknaxozvwk0htik3j/w@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=markb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.