Lines Matching refs:ibdev
85 dev = mpi->ibdev; in mlx5_ib_get_ibdev_from_mpi()
112 static int get_port_state(struct ib_device *ibdev, in get_port_state() argument
120 ret = ibdev->ops.query_port(ibdev, port_num, &attr); in get_port_state()
169 struct mlx5_ib_dev *ibdev; in mlx5_netdev_event() local
171 ibdev = roce->dev; in mlx5_netdev_event()
172 mdev = mlx5_ib_get_native_port_mdev(ibdev, port_num, NULL); in mlx5_netdev_event()
179 if (ibdev->is_rep) in mlx5_netdev_event()
206 if (ibdev->is_rep) in mlx5_netdev_event()
207 roce = mlx5_get_rep_roce(ibdev, ndev, upper, &port_num); in mlx5_netdev_event()
211 ((!upper || ibdev->is_rep) && ndev == roce->netdev)) && in mlx5_netdev_event()
212 ibdev->ib_active) { in mlx5_netdev_event()
216 if (get_port_state(&ibdev->ib_dev, port_num, in mlx5_netdev_event()
224 ibev.device = &ibdev->ib_dev; in mlx5_netdev_event()
242 mlx5_ib_put_native_port_mdev(ibdev, port_num); in mlx5_netdev_event()
249 struct mlx5_ib_dev *ibdev = to_mdev(device); in mlx5_ib_get_netdev() local
253 mdev = mlx5_ib_get_native_port_mdev(ibdev, port_num, NULL); in mlx5_ib_get_netdev()
263 read_lock(&ibdev->port[port_num - 1].roce.netdev_lock); in mlx5_ib_get_netdev()
264 ndev = ibdev->port[port_num - 1].roce.netdev; in mlx5_ib_get_netdev()
267 read_unlock(&ibdev->port[port_num - 1].roce.netdev_lock); in mlx5_ib_get_netdev()
270 mlx5_ib_put_native_port_mdev(ibdev, port_num); in mlx5_ib_get_netdev()
274 struct mlx5_core_dev *mlx5_ib_get_native_port_mdev(struct mlx5_ib_dev *ibdev, in mlx5_ib_get_native_port_mdev() argument
278 enum rdma_link_layer ll = mlx5_ib_port_link_layer(&ibdev->ib_dev, in mlx5_ib_get_native_port_mdev()
284 if (!mlx5_core_mp_enabled(ibdev->mdev) || in mlx5_ib_get_native_port_mdev()
288 return ibdev->mdev; in mlx5_ib_get_native_port_mdev()
294 port = &ibdev->port[ib_port_num - 1]; in mlx5_ib_get_native_port_mdev()
296 mpi = ibdev->port[ib_port_num - 1].mp.mpi; in mlx5_ib_get_native_port_mdev()
310 void mlx5_ib_put_native_port_mdev(struct mlx5_ib_dev *ibdev, u32 port_num) in mlx5_ib_put_native_port_mdev() argument
312 enum rdma_link_layer ll = mlx5_ib_port_link_layer(&ibdev->ib_dev, in mlx5_ib_put_native_port_mdev()
317 if (!mlx5_core_mp_enabled(ibdev->mdev) || ll != IB_LINK_LAYER_ETHERNET) in mlx5_ib_put_native_port_mdev()
320 port = &ibdev->port[port_num - 1]; in mlx5_ib_put_native_port_mdev()
323 mpi = ibdev->port[port_num - 1].mp.mpi; in mlx5_ib_put_native_port_mdev()
639 static int mlx5_get_vport_access_method(struct ib_device *ibdev) in mlx5_get_vport_access_method() argument
641 if (mlx5_use_mad_ifc(to_mdev(ibdev))) in mlx5_get_vport_access_method()
644 if (mlx5_ib_port_link_layer(ibdev, 1) == in mlx5_get_vport_access_method()
681 static int mlx5_query_system_image_guid(struct ib_device *ibdev, in mlx5_query_system_image_guid() argument
684 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_query_system_image_guid()
689 switch (mlx5_get_vport_access_method(ibdev)) { in mlx5_query_system_image_guid()
691 return mlx5_query_mad_ifc_system_image_guid(ibdev, in mlx5_query_system_image_guid()
713 static int mlx5_query_max_pkeys(struct ib_device *ibdev, in mlx5_query_max_pkeys() argument
716 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_query_max_pkeys()
719 switch (mlx5_get_vport_access_method(ibdev)) { in mlx5_query_max_pkeys()
721 return mlx5_query_mad_ifc_max_pkeys(ibdev, max_pkeys); in mlx5_query_max_pkeys()
734 static int mlx5_query_vendor_id(struct ib_device *ibdev, in mlx5_query_vendor_id() argument
737 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_query_vendor_id()
739 switch (mlx5_get_vport_access_method(ibdev)) { in mlx5_query_vendor_id()
741 return mlx5_query_mad_ifc_vendor_id(ibdev, vendor_id); in mlx5_query_vendor_id()
798 static int mlx5_ib_query_device(struct ib_device *ibdev, in mlx5_ib_query_device() argument
803 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_ib_query_device()
825 err = mlx5_query_system_image_guid(ibdev, in mlx5_ib_query_device()
832 err = mlx5_query_vendor_id(ibdev, &props->vendor_id); in mlx5_ib_query_device()
1019 if (mlx5_ib_port_link_layer(ibdev, 1) == in mlx5_ib_query_device()
1199 static void translate_active_width(struct ib_device *ibdev, u16 active_width, in translate_active_width() argument
1202 struct mlx5_ib_dev *dev = to_mdev(ibdev); in translate_active_width()
1257 static int translate_max_vl_num(struct ib_device *ibdev, u8 vl_hw_cap, in translate_max_vl_num() argument
1284 static int mlx5_query_hca_port(struct ib_device *ibdev, u32 port, in mlx5_query_hca_port() argument
1287 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_query_hca_port()
1331 translate_active_width(ibdev, ib_link_width_oper, &props->active_width); in mlx5_query_hca_port()
1345 err = translate_max_vl_num(ibdev, vl_hw_cap, in mlx5_query_hca_port()
1352 int mlx5_ib_query_port(struct ib_device *ibdev, u32 port, in mlx5_ib_query_port() argument
1358 switch (mlx5_get_vport_access_method(ibdev)) { in mlx5_ib_query_port()
1360 ret = mlx5_query_mad_ifc_port(ibdev, port, props); in mlx5_ib_query_port()
1364 ret = mlx5_query_hca_port(ibdev, port, props); in mlx5_ib_query_port()
1368 ret = mlx5_query_port_roce(ibdev, port, props); in mlx5_ib_query_port()
1376 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_ib_query_port()
1397 static int mlx5_ib_rep_query_port(struct ib_device *ibdev, u32 port, in mlx5_ib_rep_query_port() argument
1400 return mlx5_query_port_roce(ibdev, port, props); in mlx5_ib_rep_query_port()
1403 static int mlx5_ib_rep_query_pkey(struct ib_device *ibdev, u32 port, u16 index, in mlx5_ib_rep_query_pkey() argument
1413 static int mlx5_ib_query_gid(struct ib_device *ibdev, u32 port, int index, in mlx5_ib_query_gid() argument
1416 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_ib_query_gid()
1419 switch (mlx5_get_vport_access_method(ibdev)) { in mlx5_ib_query_gid()
1421 return mlx5_query_mad_ifc_gids(ibdev, port, index, gid); in mlx5_ib_query_gid()
1432 static int mlx5_query_hca_nic_pkey(struct ib_device *ibdev, u32 port, in mlx5_query_hca_nic_pkey() argument
1435 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_query_hca_nic_pkey()
1459 static int mlx5_ib_query_pkey(struct ib_device *ibdev, u32 port, u16 index, in mlx5_ib_query_pkey() argument
1462 switch (mlx5_get_vport_access_method(ibdev)) { in mlx5_ib_query_pkey()
1464 return mlx5_query_mad_ifc_pkey(ibdev, port, index, pkey); in mlx5_ib_query_pkey()
1468 return mlx5_query_hca_nic_pkey(ibdev, port, index, pkey); in mlx5_ib_query_pkey()
1474 static int mlx5_ib_modify_device(struct ib_device *ibdev, int mask, in mlx5_ib_modify_device() argument
1477 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_ib_modify_device()
1498 memcpy(ibdev->node_desc, props->node_desc, IB_DEVICE_NODE_DESC_MAX); in mlx5_ib_modify_device()
1537 static int mlx5_ib_modify_port(struct ib_device *ibdev, u32 port, int mask, in mlx5_ib_modify_port() argument
1540 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_ib_modify_port()
1546 bool is_ib = (mlx5_ib_port_link_layer(ibdev, port) == in mlx5_ib_modify_port()
1563 err = ib_query_port(ibdev, port, &attr); in mlx5_ib_modify_port()
1755 struct ib_device *ibdev = uctx->device; in set_ucontext_resp() local
1756 struct mlx5_ib_dev *dev = to_mdev(ibdev); in set_ucontext_resp()
1792 if (mlx5_ib_port_link_layer(ibdev, 1) == IB_LINK_LAYER_ETHERNET) { in set_ucontext_resp()
1837 struct ib_device *ibdev = uctx->device; in mlx5_ib_alloc_ucontext() local
1838 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_ib_alloc_ucontext()
2340 struct ib_device *ibdev = ibpd->device; in mlx5_ib_alloc_pd() local
2352 err = mlx5_cmd_exec_inout(to_mdev(ibdev)->mdev, alloc_pd, in, out); in mlx5_ib_alloc_pd()
2361 mlx5_cmd_dealloc_pd(to_mdev(ibdev)->mdev, pd->pdn, uid); in mlx5_ib_alloc_pd()
2509 static void mlx5_ib_handle_internal_error(struct mlx5_ib_dev *ibdev) in mlx5_ib_handle_internal_error() argument
2522 spin_lock_irqsave(&ibdev->reset_flow_resource_lock, flags); in mlx5_ib_handle_internal_error()
2523 list_for_each_entry(mqp, &ibdev->qp_list, qps_list) { in mlx5_ib_handle_internal_error()
2565 spin_unlock_irqrestore(&ibdev->reset_flow_resource_lock, flags); in mlx5_ib_handle_internal_error()
2587 static void handle_general_event(struct mlx5_ib_dev *ibdev, struct mlx5_eqe *eqe, in handle_general_event() argument
2594 if (mlx5_ib_port_link_layer(&ibdev->ib_dev, port) == in handle_general_event()
2596 schedule_work(&ibdev->delay_drop.delay_drop_work); in handle_general_event()
2603 static int handle_port_change(struct mlx5_ib_dev *ibdev, struct mlx5_eqe *eqe, in handle_port_change() argument
2617 if (mlx5_ib_port_link_layer(&ibdev->ib_dev, port) == in handle_port_change()
2631 schedule_work(&ibdev->devr.ports[port - 1].pkey_change_work); in handle_port_change()
2652 struct mlx5_ib_dev *ibdev; in mlx5_ib_handle_event() local
2657 ibdev = mlx5_ib_get_ibdev_from_mpi(work->mpi); in mlx5_ib_handle_event()
2658 if (!ibdev) in mlx5_ib_handle_event()
2661 ibdev = work->dev; in mlx5_ib_handle_event()
2667 mlx5_ib_handle_internal_error(ibdev); in mlx5_ib_handle_event()
2672 if (handle_port_change(ibdev, work->param, &ibev)) in mlx5_ib_handle_event()
2676 handle_general_event(ibdev, work->param, &ibev); in mlx5_ib_handle_event()
2682 ibev.device = &ibdev->ib_dev; in mlx5_ib_handle_event()
2684 if (!rdma_is_port_valid(&ibdev->ib_dev, ibev.element.port_num)) { in mlx5_ib_handle_event()
2685 mlx5_ib_warn(ibdev, "warning: event on port %d\n", ibev.element.port_num); in mlx5_ib_handle_event()
2689 if (ibdev->ib_active) in mlx5_ib_handle_event()
2693 ibdev->ib_active = false; in mlx5_ib_handle_event()
2788 struct ib_device *ibdev; in mlx5_ib_dev_res_init() local
2793 ibdev = &dev->ib_dev; in mlx5_ib_dev_res_init()
2798 devr->p0 = ib_alloc_pd(ibdev, 0); in mlx5_ib_dev_res_init()
2802 devr->c0 = ib_create_cq(ibdev, NULL, NULL, NULL, &cq_attr); in mlx5_ib_dev_res_init()
2880 static u32 get_core_cap_flags(struct ib_device *ibdev, in get_core_cap_flags() argument
2883 struct mlx5_ib_dev *dev = to_mdev(ibdev); in get_core_cap_flags()
2884 enum rdma_link_layer ll = mlx5_ib_port_link_layer(ibdev, 1); in get_core_cap_flags()
2914 static int mlx5_port_immutable(struct ib_device *ibdev, u32 port_num, in mlx5_port_immutable() argument
2918 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_port_immutable()
2919 enum rdma_link_layer ll = mlx5_ib_port_link_layer(ibdev, port_num); in mlx5_port_immutable()
2923 err = ib_query_port(ibdev, port_num, &attr); in mlx5_port_immutable()
2936 immutable->core_cap_flags = get_core_cap_flags(ibdev, &rep); in mlx5_port_immutable()
2942 static int mlx5_port_rep_immutable(struct ib_device *ibdev, u32 port_num, in mlx5_port_rep_immutable() argument
2950 err = ib_query_port(ibdev, port_num, &attr); in mlx5_port_rep_immutable()
2961 static void get_dev_fw_str(struct ib_device *ibdev, char *str) in get_dev_fw_str() argument
2964 container_of(ibdev, struct mlx5_ib_dev, ib_dev); in get_dev_fw_str()
3116 static void mlx5_ib_unbind_slave_port(struct mlx5_ib_dev *ibdev, in mlx5_ib_unbind_slave_port() argument
3120 struct mlx5_ib_port *port = &ibdev->port[port_num]; in mlx5_ib_unbind_slave_port()
3127 mlx5_ib_cleanup_cong_debugfs(ibdev, port_num); in mlx5_ib_unbind_slave_port()
3130 if (!mpi->ibdev) { in mlx5_ib_unbind_slave_port()
3135 mpi->ibdev = NULL; in mlx5_ib_unbind_slave_port()
3141 mlx5_remove_netdev_notifier(ibdev, port_num); in mlx5_ib_unbind_slave_port()
3163 mlx5_ib_dbg(ibdev, "unaffiliated port %u\n", port_num + 1); in mlx5_ib_unbind_slave_port()
3168 mlx5_ib_err(ibdev, "Failed to unaffiliate port %u\n", in mlx5_ib_unbind_slave_port()
3171 ibdev->port[port_num].roce.last_port_state = IB_PORT_DOWN; in mlx5_ib_unbind_slave_port()
3174 static bool mlx5_ib_bind_slave_port(struct mlx5_ib_dev *ibdev, in mlx5_ib_bind_slave_port() argument
3182 spin_lock(&ibdev->port[port_num].mp.mpi_lock); in mlx5_ib_bind_slave_port()
3183 if (ibdev->port[port_num].mp.mpi) { in mlx5_ib_bind_slave_port()
3184 mlx5_ib_dbg(ibdev, "port %u already affiliated.\n", in mlx5_ib_bind_slave_port()
3186 spin_unlock(&ibdev->port[port_num].mp.mpi_lock); in mlx5_ib_bind_slave_port()
3190 ibdev->port[port_num].mp.mpi = mpi; in mlx5_ib_bind_slave_port()
3191 mpi->ibdev = ibdev; in mlx5_ib_bind_slave_port()
3193 spin_unlock(&ibdev->port[port_num].mp.mpi_lock); in mlx5_ib_bind_slave_port()
3195 err = mlx5_nic_vport_affiliate_multiport(ibdev->mdev, mpi->mdev); in mlx5_ib_bind_slave_port()
3199 err = mlx5_add_netdev_notifier(ibdev, port_num); in mlx5_ib_bind_slave_port()
3201 mlx5_ib_err(ibdev, "failed adding netdev notifier for port %u\n", in mlx5_ib_bind_slave_port()
3209 mlx5_ib_init_cong_debugfs(ibdev, port_num); in mlx5_ib_bind_slave_port()
3214 mlx5_ib_unbind_slave_port(ibdev, mpi); in mlx5_ib_bind_slave_port()
3256 mpi->ibdev = dev; in mlx5_ib_init_multiport_master()
4283 mpi->ibdev->ib_active = true; in mlx5r_mp_probe()
4305 if (mpi->ibdev) in mlx5r_mp_remove()
4306 mlx5_ib_unbind_slave_port(mpi->ibdev, mpi); in mlx5r_mp_remove()