* [PATCH net-next v2 0/2] mlx4: avoid devlink port type not set warnings
@ 2020-09-08 22:21 Jakub Kicinski
2020-09-08 22:21 ` [PATCH net-next v2 1/2] devlink: don't crash if netdev is NULL Jakub Kicinski
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jakub Kicinski @ 2020-09-08 22:21 UTC (permalink / raw)
To: davem
Cc: netdev, kernel-team, tariqt, ogerlitz, yishaih, saeedm, leonro,
Jakub Kicinski
Hi!
This small set addresses the issue of mlx4 potentially not setting
devlink port type when Ethernet or IB driver is not built, but
port has that type.
v2:
- add patch 1
Jakub Kicinski (2):
devlink: don't crash if netdev is NULL
mlx4: make sure to always set the port type
drivers/net/ethernet/mellanox/mlx4/main.c | 11 +++++++++
net/core/devlink.c | 28 ++++++++++++++++-------
2 files changed, 31 insertions(+), 8 deletions(-)
--
2.26.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net-next v2 1/2] devlink: don't crash if netdev is NULL
2020-09-08 22:21 [PATCH net-next v2 0/2] mlx4: avoid devlink port type not set warnings Jakub Kicinski
@ 2020-09-08 22:21 ` Jakub Kicinski
2020-09-08 22:21 ` [PATCH net-next v2 2/2] mlx4: make sure to always set the port type Jakub Kicinski
2020-09-10 19:49 ` [PATCH net-next v2 0/2] mlx4: avoid devlink port type not set warnings David Miller
2 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2020-09-08 22:21 UTC (permalink / raw)
To: davem
Cc: netdev, kernel-team, tariqt, ogerlitz, yishaih, saeedm, leonro,
Jakub Kicinski
Following change will add support for a corner case where
we may not have a netdev to pass to devlink_port_type_eth_set()
but we still want to set port type.
This is definitely a corner case, and drivers should not normally
pass NULL netdev - print a warning message when this happens.
Sadly for other port types (ib) switches don't have a device
reference, the way we always do for Ethernet, so we can't put
the warning in __devlink_port_type_set().
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
net/core/devlink.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 49e911c19881..31cac8365b22 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -7603,14 +7603,8 @@ static void __devlink_port_type_set(struct devlink_port *devlink_port,
devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_NEW);
}
-/**
- * devlink_port_type_eth_set - Set port type to Ethernet
- *
- * @devlink_port: devlink port
- * @netdev: related netdevice
- */
-void devlink_port_type_eth_set(struct devlink_port *devlink_port,
- struct net_device *netdev)
+static void devlink_port_type_netdev_checks(struct devlink_port *devlink_port,
+ struct net_device *netdev)
{
const struct net_device_ops *ops = netdev->netdev_ops;
@@ -7644,6 +7638,24 @@ void devlink_port_type_eth_set(struct devlink_port *devlink_port,
err = ops->ndo_get_port_parent_id(netdev, &ppid);
WARN_ON(err != -EOPNOTSUPP);
}
+}
+
+/**
+ * devlink_port_type_eth_set - Set port type to Ethernet
+ *
+ * @devlink_port: devlink port
+ * @netdev: related netdevice
+ */
+void devlink_port_type_eth_set(struct devlink_port *devlink_port,
+ struct net_device *netdev)
+{
+ if (netdev)
+ devlink_port_type_netdev_checks(devlink_port, netdev);
+ else
+ dev_warn(devlink_port->devlink->dev,
+ "devlink port type for port %d set to Ethernet without a software interface reference, device type not supported by the kernel?\n",
+ devlink_port->index);
+
__devlink_port_type_set(devlink_port, DEVLINK_PORT_TYPE_ETH, netdev);
}
EXPORT_SYMBOL_GPL(devlink_port_type_eth_set);
--
2.26.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next v2 2/2] mlx4: make sure to always set the port type
2020-09-08 22:21 [PATCH net-next v2 0/2] mlx4: avoid devlink port type not set warnings Jakub Kicinski
2020-09-08 22:21 ` [PATCH net-next v2 1/2] devlink: don't crash if netdev is NULL Jakub Kicinski
@ 2020-09-08 22:21 ` Jakub Kicinski
2020-09-09 7:21 ` Tariq Toukan
2020-09-10 19:49 ` [PATCH net-next v2 0/2] mlx4: avoid devlink port type not set warnings David Miller
2 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2020-09-08 22:21 UTC (permalink / raw)
To: davem
Cc: netdev, kernel-team, tariqt, ogerlitz, yishaih, saeedm, leonro,
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] 5+ messages in thread
* Re: [PATCH net-next v2 2/2] mlx4: make sure to always set the port type
2020-09-08 22:21 ` [PATCH net-next v2 2/2] mlx4: make sure to always set the port type Jakub Kicinski
@ 2020-09-09 7:21 ` Tariq Toukan
0 siblings, 0 replies; 5+ messages in thread
From: Tariq Toukan @ 2020-09-09 7:21 UTC (permalink / raw)
To: Jakub Kicinski, davem
Cc: netdev, kernel-team, tariqt, ogerlitz, yishaih, saeedm, leonro
On 9/9/2020 1:21 AM, Jakub Kicinski wrote:
> 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)) {
>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2 0/2] mlx4: avoid devlink port type not set warnings
2020-09-08 22:21 [PATCH net-next v2 0/2] mlx4: avoid devlink port type not set warnings Jakub Kicinski
2020-09-08 22:21 ` [PATCH net-next v2 1/2] devlink: don't crash if netdev is NULL Jakub Kicinski
2020-09-08 22:21 ` [PATCH net-next v2 2/2] mlx4: make sure to always set the port type Jakub Kicinski
@ 2020-09-10 19:49 ` David Miller
2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2020-09-10 19:49 UTC (permalink / raw)
To: kuba; +Cc: netdev, kernel-team, tariqt, ogerlitz, yishaih, saeedm, leonro
From: Jakub Kicinski <kuba@kernel.org>
Date: Tue, 8 Sep 2020 15:21:12 -0700
> This small set addresses the issue of mlx4 potentially not setting
> devlink port type when Ethernet or IB driver is not built, but
> port has that type.
>
> v2:
> - add patch 1
Series applied, thank you.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-09-10 19:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-08 22:21 [PATCH net-next v2 0/2] mlx4: avoid devlink port type not set warnings Jakub Kicinski
2020-09-08 22:21 ` [PATCH net-next v2 1/2] devlink: don't crash if netdev is NULL Jakub Kicinski
2020-09-08 22:21 ` [PATCH net-next v2 2/2] mlx4: make sure to always set the port type Jakub Kicinski
2020-09-09 7:21 ` Tariq Toukan
2020-09-10 19:49 ` [PATCH net-next v2 0/2] mlx4: avoid devlink port type not set warnings David Miller
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).