From: Saeed Mahameed <saeedm@nvidia.com>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, Mark Bloch <mbloch@nvidia.com>,
Maor Gottlieb <maorg@nvidia.com>,
Saeed Mahameed <saeedm@nvidia.com>
Subject: [net-next 04/15] net/mlx5: devcom only supports 2 ports
Date: Mon, 9 May 2022 22:57:32 -0700 [thread overview]
Message-ID: <20220510055743.118828-5-saeedm@nvidia.com> (raw)
In-Reply-To: <20220510055743.118828-1-saeedm@nvidia.com>
From: Mark Bloch <mbloch@nvidia.com>
Devcom API is intended to be used between 2 devices only add this
implied assumption into the code and check when it's no true.
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/lib/devcom.c | 16 +++++++++-------
.../net/ethernet/mellanox/mlx5/core/lib/devcom.h | 2 ++
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
index bced2efe9bef..adefde3ea941 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
@@ -14,7 +14,7 @@ static LIST_HEAD(devcom_list);
struct mlx5_devcom_component {
struct {
void *data;
- } device[MLX5_MAX_PORTS];
+ } device[MLX5_DEVCOM_PORTS_SUPPORTED];
mlx5_devcom_event_handler_t handler;
struct rw_semaphore sem;
@@ -25,7 +25,7 @@ struct mlx5_devcom_list {
struct list_head list;
struct mlx5_devcom_component components[MLX5_DEVCOM_NUM_COMPONENTS];
- struct mlx5_core_dev *devs[MLX5_MAX_PORTS];
+ struct mlx5_core_dev *devs[MLX5_DEVCOM_PORTS_SUPPORTED];
};
struct mlx5_devcom {
@@ -74,13 +74,15 @@ struct mlx5_devcom *mlx5_devcom_register_device(struct mlx5_core_dev *dev)
if (!mlx5_core_is_pf(dev))
return NULL;
+ if (MLX5_CAP_GEN(dev, num_lag_ports) != MLX5_DEVCOM_PORTS_SUPPORTED)
+ return NULL;
sguid0 = mlx5_query_nic_system_image_guid(dev);
list_for_each_entry(iter, &devcom_list, list) {
struct mlx5_core_dev *tmp_dev = NULL;
idx = -1;
- for (i = 0; i < MLX5_MAX_PORTS; i++) {
+ for (i = 0; i < MLX5_DEVCOM_PORTS_SUPPORTED; i++) {
if (iter->devs[i])
tmp_dev = iter->devs[i];
else
@@ -134,11 +136,11 @@ void mlx5_devcom_unregister_device(struct mlx5_devcom *devcom)
kfree(devcom);
- for (i = 0; i < MLX5_MAX_PORTS; i++)
+ for (i = 0; i < MLX5_DEVCOM_PORTS_SUPPORTED; i++)
if (priv->devs[i])
break;
- if (i != MLX5_MAX_PORTS)
+ if (i != MLX5_DEVCOM_PORTS_SUPPORTED)
return;
list_del(&priv->list);
@@ -191,7 +193,7 @@ int mlx5_devcom_send_event(struct mlx5_devcom *devcom,
comp = &devcom->priv->components[id];
down_write(&comp->sem);
- for (i = 0; i < MLX5_MAX_PORTS; i++)
+ for (i = 0; i < MLX5_DEVCOM_PORTS_SUPPORTED; i++)
if (i != devcom->idx && comp->device[i].data) {
err = comp->handler(event, comp->device[i].data,
event_data);
@@ -239,7 +241,7 @@ void *mlx5_devcom_get_peer_data(struct mlx5_devcom *devcom,
return NULL;
}
- for (i = 0; i < MLX5_MAX_PORTS; i++)
+ for (i = 0; i < MLX5_DEVCOM_PORTS_SUPPORTED; i++)
if (i != devcom->idx)
break;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h
index 939d5bf1581b..94313c18bb64 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h
@@ -6,6 +6,8 @@
#include <linux/mlx5/driver.h>
+#define MLX5_DEVCOM_PORTS_SUPPORTED 2
+
enum mlx5_devcom_components {
MLX5_DEVCOM_ESW_OFFLOADS,
--
2.35.1
next prev parent reply other threads:[~2022-05-10 5:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-10 5:57 [pull request][net-next 00/15] mlx5 updates 2022-05-09 Saeed Mahameed
2022-05-10 5:57 ` [net-next 01/15] net/mlx5: Add exit route when waiting for FW Saeed Mahameed
2022-05-11 11:30 ` patchwork-bot+netdevbpf
2022-05-10 5:57 ` [net-next 02/15] net/mlx5: Increase FW pre-init timeout for health recovery Saeed Mahameed
2022-05-10 5:57 ` [net-next 03/15] net/mlx5: Lag, expose number of lag ports Saeed Mahameed
2022-05-10 5:57 ` Saeed Mahameed [this message]
2022-05-10 5:57 ` [net-next 05/15] net/mlx5: Lag, move E-Switch prerequisite check into lag code Saeed Mahameed
2022-05-10 5:57 ` [net-next 06/15] net/mlx5: Lag, use lag lock Saeed Mahameed
2022-05-10 5:57 ` [net-next 07/15] net/mlx5: Lag, filter non compatible devices Saeed Mahameed
2022-05-10 5:57 ` [net-next 08/15] net/mlx5: Lag, store number of ports inside lag object Saeed Mahameed
2022-05-10 5:57 ` [net-next 09/15] net/mlx5: Lag, support single FDB only on 2 ports Saeed Mahameed
2022-05-10 5:57 ` [net-next 10/15] net/mlx5: Lag, use hash when in roce lag on 4 ports Saeed Mahameed
2022-05-10 5:57 ` [net-next 11/15] net/mlx5: Lag, use actual number of lag ports Saeed Mahameed
2022-05-10 5:57 ` [net-next 12/15] net/mlx5: Support devices with more than 2 ports Saeed Mahameed
2022-05-10 5:57 ` [net-next 13/15] net/mlx5: Lag, refactor dmesg print Saeed Mahameed
2022-05-10 5:57 ` [net-next 14/15] net/mlx5: Lag, use buckets in hash mode Saeed Mahameed
2022-05-10 5:57 ` [net-next 15/15] net/mlx5: Lag, add debugfs to query hardware lag state 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=20220510055743.118828-5-saeedm@nvidia.com \
--to=saeedm@nvidia.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=maorg@nvidia.com \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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).