diff options
Diffstat (limited to 'sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c')
-rw-r--r-- | sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c index acd74e3ec643..629ecf3e5755 100644 --- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c +++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c @@ -87,21 +87,21 @@ mlx5_ib_port_link_layer(struct ib_device *device, u8 port_num) return mlx5_port_type_cap_to_rdma_ll(port_type_cap); } -static bool mlx5_netdev_match(struct ifnet *ndev, +static bool mlx5_netdev_match(if_t ndev, struct mlx5_core_dev *mdev, const char *dname) { - return ndev->if_type == IFT_ETHER && - ndev->if_dname != NULL && - strcmp(ndev->if_dname, dname) == 0 && - ndev->if_softc != NULL && - *(struct mlx5_core_dev **)ndev->if_softc == mdev; + return if_gettype(ndev) == IFT_ETHER && + if_getdname(ndev) != NULL && + strcmp(if_getdname(ndev), dname) == 0 && + if_getsoftc(ndev) != NULL && + *(struct mlx5_core_dev **)if_getsoftc(ndev) == mdev; } static int mlx5_netdev_event(struct notifier_block *this, unsigned long event, void *ptr) { - struct ifnet *ndev = netdev_notifier_info_to_ifp(ptr); + if_t ndev = netdev_notifier_info_to_ifp(ptr); struct mlx5_ib_dev *ibdev = container_of(this, struct mlx5_ib_dev, roce.nb); @@ -118,7 +118,7 @@ static int mlx5_netdev_event(struct notifier_block *this, case NETDEV_UP: case NETDEV_DOWN: { - struct ifnet *upper = NULL; + if_t upper = NULL; if ((upper == ndev || (!upper && ndev == ibdev->roce.netdev)) && ibdev->ib_active) { @@ -140,11 +140,11 @@ static int mlx5_netdev_event(struct notifier_block *this, return NOTIFY_DONE; } -static struct ifnet *mlx5_ib_get_netdev(struct ib_device *device, +static if_t mlx5_ib_get_netdev(struct ib_device *device, u8 port_num) { struct mlx5_ib_dev *ibdev = to_mdev(device); - struct ifnet *ndev; + if_t ndev; /* Ensure ndev does not disappear before we invoke if_ref() */ @@ -289,7 +289,7 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num, { struct mlx5_ib_dev *dev = to_mdev(device); u32 out[MLX5_ST_SZ_DW(ptys_reg)] = {}; - struct ifnet *ndev; + if_t ndev; enum ib_mtu ndev_ib_mtu; u16 qkey_viol_cntr; u32 eth_prot_oper; @@ -334,13 +334,13 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num, if (!ndev) return 0; - if (ndev->if_drv_flags & IFF_DRV_RUNNING && - ndev->if_link_state == LINK_STATE_UP) { + if (if_getdrvflags(ndev) & IFF_DRV_RUNNING && + if_getlinkstate(ndev) == LINK_STATE_UP) { props->state = IB_PORT_ACTIVE; props->phys_state = IB_PORT_PHYS_STATE_LINK_UP; } - ndev_ib_mtu = iboe_get_mtu(ndev->if_mtu); + ndev_ib_mtu = iboe_get_mtu(if_getmtu(ndev)); if_rele(ndev); @@ -361,7 +361,7 @@ static void ib_gid_to_mlx5_roce_addr(const union ib_gid *gid, if (!gid) return; - ether_addr_copy(mlx5_addr_mac, IF_LLADDR(attr->ndev)); + ether_addr_copy(mlx5_addr_mac, if_getlladdr(attr->ndev)); vlan_id = rdma_vlan_dev_vlan_id(attr->ndev); if (vlan_id != 0xffff) { @@ -3132,10 +3132,25 @@ static void mlx5_remove_roce_notifier(struct mlx5_ib_dev *dev) } } +static int +mlx5_enable_roce_if_cb(if_t ifp, void *arg) +{ + struct mlx5_ib_dev *dev = arg; + + /* check if network interface belongs to mlx5en */ + if (!mlx5_netdev_match(ifp, dev->mdev, "mce")) + return (0); + + write_lock(&dev->roce.netdev_lock); + dev->roce.netdev = ifp; + write_unlock(&dev->roce.netdev_lock); + + return (0); +} + static int mlx5_enable_roce(struct mlx5_ib_dev *dev) { VNET_ITERATOR_DECL(vnet_iter); - struct ifnet *idev; int err; /* Check if mlx5en net device already exists */ @@ -3143,14 +3158,7 @@ static int mlx5_enable_roce(struct mlx5_ib_dev *dev) VNET_FOREACH(vnet_iter) { IFNET_RLOCK(); CURVNET_SET_QUIET(vnet_iter); - CK_STAILQ_FOREACH(idev, &V_ifnet, if_link) { - /* check if network interface belongs to mlx5en */ - if (!mlx5_netdev_match(idev, dev->mdev, "mce")) - continue; - write_lock(&dev->roce.netdev_lock); - dev->roce.netdev = idev; - write_unlock(&dev->roce.netdev_lock); - } + if_foreach(mlx5_enable_roce_if_cb, dev); CURVNET_RESTORE(); IFNET_RUNLOCK(); } |