Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH net-next] mlx4: make sure to always set the port type
@ 2020-09-04 20:06 Jakub Kicinski
  2020-09-06  7:27 ` Leon Romanovsky
  0 siblings, 1 reply; 11+ messages in thread
From: Jakub Kicinski @ 2020-09-04 20:06 UTC (permalink / raw)
  To: davem
  Cc: netdev, kernel-team, tariqt, yishaih, linux-rdma, jiri, Jakub Kicinski

Even tho mlx4_core registers the devlink ports, it's mlx4_en
and mlx4_ib which set their type. In situations where one of
the two is not built yet the machine has ports of given type
we see the devlink warning from devlink_port_type_warn() trigger.

Having ports of a type not supported by the kernel may seem
surprising, but it does occur in practice - when the unsupported
port is not plugged in to a switch anyway users are more than happy
not to see it (and potentially allocate any resources to it).

Set the type in mlx4_core if type-specific driver is not built.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/mellanox/mlx4/main.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 258c7a96f269..70cf24ba71e4 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -3031,6 +3031,17 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
 	if (err)
 		return err;
 
+	/* Ethernet and IB drivers will normally set the port type,
+	 * but if they are not built set the type now to prevent
+	 * devlink_port_type_warn() from firing.
+	 */
+	if (!IS_ENABLED(CONFIG_MLX4_EN) &&
+	    dev->caps.port_type[port] == MLX4_PORT_TYPE_ETH)
+		devlink_port_type_eth_set(&info->devlink_port, NULL);
+	else if (!IS_ENABLED(CONFIG_MLX4_INFINIBAND) &&
+		 dev->caps.port_type[port] == MLX4_PORT_TYPE_IB)
+		devlink_port_type_ib_set(&info->devlink_port, NULL);
+
 	info->dev = dev;
 	info->port = port;
 	if (!mlx4_is_slave(dev)) {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-09-07 17:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-04 20:06 [PATCH net-next] mlx4: make sure to always set the port type Jakub Kicinski
2020-09-06  7:27 ` Leon Romanovsky
2020-09-06 16:33   ` Jakub Kicinski
2020-09-07  6:21     ` Jiri Pirko
2020-09-07  6:48       ` Leon Romanovsky
2020-09-07  7:19         ` Jiri Pirko
2020-09-07  9:10           ` Leon Romanovsky
2020-09-07 16:34           ` Jakub Kicinski
2020-09-07 16:55             ` Jiri Pirko
2020-09-07 16:36         ` Jakub Kicinski
2020-09-07 17:51           ` Leon Romanovsky

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).