From d61225ead742670db06b1b22dbedb26c664d8c26 Mon Sep 17 00:00:00 2001 From: hselasky Date: Sun, 18 Jun 2017 11:50:09 +0000 Subject: [PATCH] MFC r319972: Use static device numbering instead of dynamic one when creating mlx4en network interfaces. This prevents infinite unit number growth typically when the mlx4en driver is used inside virtual machines which support runtime PCI attach and detach. Sponsored by: Mellanox Technologies git-svn-id: svn://svn.freebsd.org/base/stable/9@320068 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/ofed/drivers/net/mlx4/en_netdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/ofed/drivers/net/mlx4/en_netdev.c b/sys/ofed/drivers/net/mlx4/en_netdev.c index 4e6b7de7e..f8a231dbf 100644 --- a/sys/ofed/drivers/net/mlx4/en_netdev.c +++ b/sys/ofed/drivers/net/mlx4/en_netdev.c @@ -54,7 +54,6 @@ static void mlx4_en_sysctl_stat(struct mlx4_en_priv *priv); static void mlx4_en_sysctl_conf(struct mlx4_en_priv *priv); -static int mlx4_en_unit; #ifdef CONFIG_NET_RX_BUSY_POLL /* must be called with local_bh_disable()d */ @@ -2055,7 +2054,8 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, return -ENOMEM; } dev->if_softc = priv; - if_initname(dev, "mlxen", atomic_fetchadd_int(&mlx4_en_unit, 1)); + if_initname(dev, "mlxen", (device_get_unit( + mdev->pdev->dev.bsddev) * MLX4_MAX_PORTS) + port - 1); dev->if_mtu = ETHERMTU; dev->if_init = mlx4_en_open; dev->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; -- 2.42.0