Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f42feb29 authored by Mark Bloch's avatar Mark Bloch Committed by Greg Kroah-Hartman
Browse files

net/mlx5: devcom only supports 2 ports



[ Upstream commit 8a6e75e5f57e9ac82268d9bfca3403598d9d0292 ]

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: default avatarMark Bloch <mbloch@nvidia.com>
Reviewed-by: default avatarMaor Gottlieb <maorg@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
Stable-dep-of: 1f893f57a3bf ("net/mlx5: Devcom, serialize devcom registration")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 67637a7e
Loading
Loading
Loading
Loading
+9 −7
Original line number Original line Diff line number Diff line
@@ -14,7 +14,7 @@ static LIST_HEAD(devcom_list);
struct mlx5_devcom_component {
struct mlx5_devcom_component {
	struct {
	struct {
		void *data;
		void *data;
	} device[MLX5_MAX_PORTS];
	} device[MLX5_DEVCOM_PORTS_SUPPORTED];


	mlx5_devcom_event_handler_t handler;
	mlx5_devcom_event_handler_t handler;
	struct rw_semaphore sem;
	struct rw_semaphore sem;
@@ -25,7 +25,7 @@ struct mlx5_devcom_list {
	struct list_head list;
	struct list_head list;


	struct mlx5_devcom_component components[MLX5_DEVCOM_NUM_COMPONENTS];
	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 {
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))
	if (!mlx5_core_is_pf(dev))
		return NULL;
		return NULL;
	if (MLX5_CAP_GEN(dev, num_lag_ports) != MLX5_DEVCOM_PORTS_SUPPORTED)
		return NULL;


	sguid0 = mlx5_query_nic_system_image_guid(dev);
	sguid0 = mlx5_query_nic_system_image_guid(dev);
	list_for_each_entry(iter, &devcom_list, list) {
	list_for_each_entry(iter, &devcom_list, list) {
		struct mlx5_core_dev *tmp_dev = NULL;
		struct mlx5_core_dev *tmp_dev = NULL;


		idx = -1;
		idx = -1;
		for (i = 0; i < MLX5_MAX_PORTS; i++) {
		for (i = 0; i < MLX5_DEVCOM_PORTS_SUPPORTED; i++) {
			if (iter->devs[i])
			if (iter->devs[i])
				tmp_dev = iter->devs[i];
				tmp_dev = iter->devs[i];
			else
			else
@@ -135,11 +137,11 @@ void mlx5_devcom_unregister_device(struct mlx5_devcom *devcom)


	kfree(devcom);
	kfree(devcom);


	for (i = 0; i < MLX5_MAX_PORTS; i++)
	for (i = 0; i < MLX5_DEVCOM_PORTS_SUPPORTED; i++)
		if (priv->devs[i])
		if (priv->devs[i])
			break;
			break;


	if (i != MLX5_MAX_PORTS)
	if (i != MLX5_DEVCOM_PORTS_SUPPORTED)
		return;
		return;


	list_del(&priv->list);
	list_del(&priv->list);
@@ -192,7 +194,7 @@ int mlx5_devcom_send_event(struct mlx5_devcom *devcom,


	comp = &devcom->priv->components[id];
	comp = &devcom->priv->components[id];
	down_write(&comp->sem);
	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) {
		if (i != devcom->idx && comp->device[i].data) {
			err = comp->handler(event, comp->device[i].data,
			err = comp->handler(event, comp->device[i].data,
					    event_data);
					    event_data);
@@ -240,7 +242,7 @@ void *mlx5_devcom_get_peer_data(struct mlx5_devcom *devcom,
		return NULL;
		return NULL;
	}
	}


	for (i = 0; i < MLX5_MAX_PORTS; i++)
	for (i = 0; i < MLX5_DEVCOM_PORTS_SUPPORTED; i++)
		if (i != devcom->idx)
		if (i != devcom->idx)
			break;
			break;


+2 −0
Original line number Original line Diff line number Diff line
@@ -6,6 +6,8 @@


#include <linux/mlx5/driver.h>
#include <linux/mlx5/driver.h>


#define MLX5_DEVCOM_PORTS_SUPPORTED 2

enum mlx5_devcom_components {
enum mlx5_devcom_components {
	MLX5_DEVCOM_ESW_OFFLOADS,
	MLX5_DEVCOM_ESW_OFFLOADS,