public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: Saeed Mahameed <saeedm@mellanox.com>,
	Leon Romanovsky <leonro@mellanox.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	Parav Pandit <parav@mellanox.com>
Subject: [PATCH mlx5-next 2/5] net/mlx5: E-Switch prepare functions change handler to be modular
Date: Wed, 3 Jul 2019 07:39:28 +0000	[thread overview]
Message-ID: <20190703073909.14965-3-saeedm@mellanox.com> (raw)
In-Reply-To: <20190703073909.14965-1-saeedm@mellanox.com>

From: Parav Pandit <parav@mellanox.com>

Eswitch function change handler will service multiple type of events for
VFs and non VF functions update.
Hence, introduce and use the helper function
esw_vfs_changed_event_handler() for handling change in num VFs to improve
the code readability.

Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 .../mellanox/mlx5/core/eswitch_offloads.c     | 44 ++++++++++++-------
 1 file changed, 27 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 5c8fb2597bfa..42c0db585561 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -2046,38 +2046,48 @@ static void esw_offloads_steering_cleanup(struct mlx5_eswitch *esw)
 	esw_destroy_offloads_acl_tables(esw);
 }
 
-static void esw_functions_changed_event_handler(struct work_struct *work)
+static void
+esw_vfs_changed_event_handler(struct mlx5_eswitch *esw, const u32 *out)
 {
-	u32 out[MLX5_ST_SZ_DW(query_esw_functions_out)] = {};
-	struct mlx5_host_work *host_work;
-	struct mlx5_eswitch *esw;
 	bool host_pf_disabled;
-	u16 num_vfs = 0;
-	int err;
-
-	host_work = container_of(work, struct mlx5_host_work, work);
-	esw = host_work->esw;
+	u16 new_num_vfs;
 
-	err = mlx5_esw_query_functions(esw->dev, out, sizeof(out));
-	num_vfs = MLX5_GET(query_esw_functions_out, out,
-			   host_params_context.host_num_of_vfs);
+	new_num_vfs = MLX5_GET(query_esw_functions_out, out,
+			       host_params_context.host_num_of_vfs);
 	host_pf_disabled = MLX5_GET(query_esw_functions_out, out,
 				    host_params_context.host_pf_disabled);
-	if (err || host_pf_disabled || num_vfs == esw->esw_funcs.num_vfs)
-		goto out;
+
+	if (new_num_vfs == esw->esw_funcs.num_vfs || host_pf_disabled)
+		return;
 
 	/* Number of VFs can only change from "0 to x" or "x to 0". */
 	if (esw->esw_funcs.num_vfs > 0) {
 		esw_offloads_unload_vf_reps(esw, esw->esw_funcs.num_vfs);
 	} else {
-		err = esw_offloads_load_vf_reps(esw, num_vfs);
+		int err;
 
+		err = esw_offloads_load_vf_reps(esw, new_num_vfs);
 		if (err)
-			goto out;
+			return;
 	}
+	esw->esw_funcs.num_vfs = new_num_vfs;
+}
+
+static void esw_functions_changed_event_handler(struct work_struct *work)
+{
+	u32 out[MLX5_ST_SZ_DW(query_esw_functions_out)] = {};
+	struct mlx5_host_work *host_work;
+	struct mlx5_eswitch *esw;
+	int err;
+
+	host_work = container_of(work, struct mlx5_host_work, work);
+	esw = host_work->esw;
 
-	esw->esw_funcs.num_vfs = num_vfs;
+	err = mlx5_esw_query_functions(esw->dev, out, sizeof(out));
+	if (err)
+		goto out;
 
+	esw_vfs_changed_event_handler(esw, out);
 out:
 	kfree(host_work);
 }
-- 
2.21.0


  parent reply	other threads:[~2019-07-03  7:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03  7:39 [PATCH mlx5-next 0/5] Mellanox, mlx5 low level updates 2019-07-02 Saeed Mahameed
2019-07-03  7:39 ` [PATCH mlx5-next 1/5] net/mlx5: Introduce and use mlx5_eswitch_get_total_vports() Saeed Mahameed
2019-07-03  7:39 ` Saeed Mahameed [this message]
2019-07-03  7:39 ` [PATCH mlx5-next 3/5] net/mlx5: Refactor mlx5_esw_query_functions for modularity Saeed Mahameed
2019-07-03  7:39 ` [PATCH mlx5-next 4/5] net/mlx5: Introduce TLS TX offload hardware bits and structures Saeed Mahameed
2019-07-03  9:27   ` leon
2019-07-04 17:06     ` Saeed Mahameed
2019-07-04 17:15       ` Leon Romanovsky
2019-07-04 17:21         ` Saeed Mahameed
2019-07-04 18:21           ` Leon Romanovsky
2019-07-09 20:54             ` Saeed Mahameed
2019-07-10  5:27               ` Leon Romanovsky
2019-07-03  7:39 ` [PATCH mlx5-next 5/5] net/mlx5: Properly name the generic WQE control field Saeed Mahameed
2019-07-04 17:10 ` [PATCH mlx5-next 0/5] Mellanox, mlx5 low level updates 2019-07-02 Saeed Mahameed
2019-07-04 17:16   ` Leon Romanovsky

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=20190703073909.14965-3-saeedm@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=parav@mellanox.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