Lines Matching refs:ibdev

87 	dev = mpi->ibdev;  in mlx5_ib_get_ibdev_from_mpi()
114 static int get_port_state(struct ib_device *ibdev, in get_port_state() argument
122 ret = ibdev->ops.query_port(ibdev, port_num, &attr); in get_port_state()
171 struct mlx5_ib_dev *ibdev; in mlx5_netdev_event() local
173 ibdev = roce->dev; in mlx5_netdev_event()
174 mdev = mlx5_ib_get_native_port_mdev(ibdev, port_num, NULL); in mlx5_netdev_event()
181 if (ibdev->is_rep) in mlx5_netdev_event()
208 if (ibdev->is_rep) in mlx5_netdev_event()
209 roce = mlx5_get_rep_roce(ibdev, ndev, upper, &port_num); in mlx5_netdev_event()
213 ((!upper || ibdev->is_rep) && ndev == roce->netdev)) && in mlx5_netdev_event()
214 ibdev->ib_active) { in mlx5_netdev_event()
218 if (get_port_state(&ibdev->ib_dev, port_num, in mlx5_netdev_event()
226 ibev.device = &ibdev->ib_dev; in mlx5_netdev_event()
244 mlx5_ib_put_native_port_mdev(ibdev, port_num); in mlx5_netdev_event()
251 struct mlx5_ib_dev *ibdev = to_mdev(device); in mlx5_ib_get_netdev() local
255 mdev = mlx5_ib_get_native_port_mdev(ibdev, port_num, NULL); in mlx5_ib_get_netdev()
265 read_lock(&ibdev->port[port_num - 1].roce.netdev_lock); in mlx5_ib_get_netdev()
266 ndev = ibdev->port[port_num - 1].roce.netdev; in mlx5_ib_get_netdev()
269 read_unlock(&ibdev->port[port_num - 1].roce.netdev_lock); in mlx5_ib_get_netdev()
272 mlx5_ib_put_native_port_mdev(ibdev, port_num); in mlx5_ib_get_netdev()
276 struct mlx5_core_dev *mlx5_ib_get_native_port_mdev(struct mlx5_ib_dev *ibdev, in mlx5_ib_get_native_port_mdev() argument
280 enum rdma_link_layer ll = mlx5_ib_port_link_layer(&ibdev->ib_dev, in mlx5_ib_get_native_port_mdev()
286 if (!mlx5_core_mp_enabled(ibdev->mdev) || in mlx5_ib_get_native_port_mdev()
290 return ibdev->mdev; in mlx5_ib_get_native_port_mdev()
296 port = &ibdev->port[ib_port_num - 1]; in mlx5_ib_get_native_port_mdev()
298 mpi = ibdev->port[ib_port_num - 1].mp.mpi; in mlx5_ib_get_native_port_mdev()
312 void mlx5_ib_put_native_port_mdev(struct mlx5_ib_dev *ibdev, u32 port_num) in mlx5_ib_put_native_port_mdev() argument
314 enum rdma_link_layer ll = mlx5_ib_port_link_layer(&ibdev->ib_dev, in mlx5_ib_put_native_port_mdev()
319 if (!mlx5_core_mp_enabled(ibdev->mdev) || ll != IB_LINK_LAYER_ETHERNET) in mlx5_ib_put_native_port_mdev()
322 port = &ibdev->port[port_num - 1]; in mlx5_ib_put_native_port_mdev()
325 mpi = ibdev->port[port_num - 1].mp.mpi; in mlx5_ib_put_native_port_mdev()
658 static int mlx5_get_vport_access_method(struct ib_device *ibdev) in mlx5_get_vport_access_method() argument
660 if (mlx5_use_mad_ifc(to_mdev(ibdev))) in mlx5_get_vport_access_method()
663 if (mlx5_ib_port_link_layer(ibdev, 1) == in mlx5_get_vport_access_method()
700 static int mlx5_query_system_image_guid(struct ib_device *ibdev, in mlx5_query_system_image_guid() argument
703 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_query_system_image_guid()
708 switch (mlx5_get_vport_access_method(ibdev)) { in mlx5_query_system_image_guid()
710 return mlx5_query_mad_ifc_system_image_guid(ibdev, in mlx5_query_system_image_guid()
732 static int mlx5_query_max_pkeys(struct ib_device *ibdev, in mlx5_query_max_pkeys() argument
735 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_query_max_pkeys()
738 switch (mlx5_get_vport_access_method(ibdev)) { in mlx5_query_max_pkeys()
740 return mlx5_query_mad_ifc_max_pkeys(ibdev, max_pkeys); in mlx5_query_max_pkeys()
753 static int mlx5_query_vendor_id(struct ib_device *ibdev, in mlx5_query_vendor_id() argument
756 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_query_vendor_id()
758 switch (mlx5_get_vport_access_method(ibdev)) { in mlx5_query_vendor_id()
760 return mlx5_query_mad_ifc_vendor_id(ibdev, vendor_id); in mlx5_query_vendor_id()
817 static int mlx5_ib_query_device(struct ib_device *ibdev, in mlx5_ib_query_device() argument
822 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_ib_query_device()
844 err = mlx5_query_system_image_guid(ibdev, in mlx5_ib_query_device()
851 err = mlx5_query_vendor_id(ibdev, &props->vendor_id); in mlx5_ib_query_device()
1038 if (mlx5_ib_port_link_layer(ibdev, 1) == in mlx5_ib_query_device()
1218 static void translate_active_width(struct ib_device *ibdev, u16 active_width, in translate_active_width() argument
1221 struct mlx5_ib_dev *dev = to_mdev(ibdev); in translate_active_width()
1276 static int translate_max_vl_num(struct ib_device *ibdev, u8 vl_hw_cap, in translate_max_vl_num() argument
1303 static int mlx5_query_hca_port(struct ib_device *ibdev, u32 port, in mlx5_query_hca_port() argument
1306 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_query_hca_port()
1350 translate_active_width(ibdev, ib_link_width_oper, &props->active_width); in mlx5_query_hca_port()
1364 err = translate_max_vl_num(ibdev, vl_hw_cap, in mlx5_query_hca_port()
1371 int mlx5_ib_query_port(struct ib_device *ibdev, u32 port, in mlx5_ib_query_port() argument
1377 switch (mlx5_get_vport_access_method(ibdev)) { in mlx5_ib_query_port()
1379 ret = mlx5_query_mad_ifc_port(ibdev, port, props); in mlx5_ib_query_port()
1383 ret = mlx5_query_hca_port(ibdev, port, props); in mlx5_ib_query_port()
1387 ret = mlx5_query_port_roce(ibdev, port, props); in mlx5_ib_query_port()
1395 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_ib_query_port()
1416 static int mlx5_ib_rep_query_port(struct ib_device *ibdev, u32 port, in mlx5_ib_rep_query_port() argument
1419 return mlx5_query_port_roce(ibdev, port, props); in mlx5_ib_rep_query_port()
1422 static int mlx5_ib_rep_query_pkey(struct ib_device *ibdev, u32 port, u16 index, in mlx5_ib_rep_query_pkey() argument
1432 static int mlx5_ib_query_gid(struct ib_device *ibdev, u32 port, int index, in mlx5_ib_query_gid() argument
1435 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_ib_query_gid()
1438 switch (mlx5_get_vport_access_method(ibdev)) { in mlx5_ib_query_gid()
1440 return mlx5_query_mad_ifc_gids(ibdev, port, index, gid); in mlx5_ib_query_gid()
1451 static int mlx5_query_hca_nic_pkey(struct ib_device *ibdev, u32 port, in mlx5_query_hca_nic_pkey() argument
1454 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_query_hca_nic_pkey()
1478 static int mlx5_ib_query_pkey(struct ib_device *ibdev, u32 port, u16 index, in mlx5_ib_query_pkey() argument
1481 switch (mlx5_get_vport_access_method(ibdev)) { in mlx5_ib_query_pkey()
1483 return mlx5_query_mad_ifc_pkey(ibdev, port, index, pkey); in mlx5_ib_query_pkey()
1487 return mlx5_query_hca_nic_pkey(ibdev, port, index, pkey); in mlx5_ib_query_pkey()
1493 static int mlx5_ib_modify_device(struct ib_device *ibdev, int mask, in mlx5_ib_modify_device() argument
1496 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_ib_modify_device()
1517 memcpy(ibdev->node_desc, props->node_desc, IB_DEVICE_NODE_DESC_MAX); in mlx5_ib_modify_device()
1556 static int mlx5_ib_modify_port(struct ib_device *ibdev, u32 port, int mask, in mlx5_ib_modify_port() argument
1559 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_ib_modify_port()
1565 bool is_ib = (mlx5_ib_port_link_layer(ibdev, port) == in mlx5_ib_modify_port()
1582 err = ib_query_port(ibdev, port, &attr); in mlx5_ib_modify_port()
1774 struct ib_device *ibdev = uctx->device; in set_ucontext_resp() local
1775 struct mlx5_ib_dev *dev = to_mdev(ibdev); in set_ucontext_resp()
1807 if (mlx5_ib_port_link_layer(ibdev, 1) == IB_LINK_LAYER_ETHERNET) { in set_ucontext_resp()
1852 struct ib_device *ibdev = uctx->device; in mlx5_ib_alloc_ucontext() local
1853 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_ib_alloc_ucontext()
2355 struct ib_device *ibdev = ibpd->device; in mlx5_ib_alloc_pd() local
2367 err = mlx5_cmd_exec_inout(to_mdev(ibdev)->mdev, alloc_pd, in, out); in mlx5_ib_alloc_pd()
2376 mlx5_cmd_dealloc_pd(to_mdev(ibdev)->mdev, pd->pdn, uid); in mlx5_ib_alloc_pd()
2524 static void mlx5_ib_handle_internal_error(struct mlx5_ib_dev *ibdev) in mlx5_ib_handle_internal_error() argument
2537 spin_lock_irqsave(&ibdev->reset_flow_resource_lock, flags); in mlx5_ib_handle_internal_error()
2538 list_for_each_entry(mqp, &ibdev->qp_list, qps_list) { in mlx5_ib_handle_internal_error()
2580 spin_unlock_irqrestore(&ibdev->reset_flow_resource_lock, flags); in mlx5_ib_handle_internal_error()
2602 static void handle_general_event(struct mlx5_ib_dev *ibdev, struct mlx5_eqe *eqe, in handle_general_event() argument
2609 if (mlx5_ib_port_link_layer(&ibdev->ib_dev, port) == in handle_general_event()
2611 schedule_work(&ibdev->delay_drop.delay_drop_work); in handle_general_event()
2618 static int handle_port_change(struct mlx5_ib_dev *ibdev, struct mlx5_eqe *eqe, in handle_port_change() argument
2632 if (mlx5_ib_port_link_layer(&ibdev->ib_dev, port) == in handle_port_change()
2646 schedule_work(&ibdev->devr.ports[port - 1].pkey_change_work); in handle_port_change()
2667 struct mlx5_ib_dev *ibdev; in mlx5_ib_handle_event() local
2672 ibdev = mlx5_ib_get_ibdev_from_mpi(work->mpi); in mlx5_ib_handle_event()
2673 if (!ibdev) in mlx5_ib_handle_event()
2676 ibdev = work->dev; in mlx5_ib_handle_event()
2682 mlx5_ib_handle_internal_error(ibdev); in mlx5_ib_handle_event()
2687 if (handle_port_change(ibdev, work->param, &ibev)) in mlx5_ib_handle_event()
2691 handle_general_event(ibdev, work->param, &ibev); in mlx5_ib_handle_event()
2697 ibev.device = &ibdev->ib_dev; in mlx5_ib_handle_event()
2699 if (!rdma_is_port_valid(&ibdev->ib_dev, ibev.element.port_num)) { in mlx5_ib_handle_event()
2700 mlx5_ib_warn(ibdev, "warning: event on port %d\n", ibev.element.port_num); in mlx5_ib_handle_event()
2704 if (ibdev->ib_active) in mlx5_ib_handle_event()
2708 ibdev->ib_active = false; in mlx5_ib_handle_event()
2803 struct ib_device *ibdev; in mlx5_ib_dev_res_init() local
2808 ibdev = &dev->ib_dev; in mlx5_ib_dev_res_init()
2813 devr->p0 = ib_alloc_pd(ibdev, 0); in mlx5_ib_dev_res_init()
2817 devr->c0 = ib_create_cq(ibdev, NULL, NULL, NULL, &cq_attr); in mlx5_ib_dev_res_init()
2895 static u32 get_core_cap_flags(struct ib_device *ibdev, in get_core_cap_flags() argument
2898 struct mlx5_ib_dev *dev = to_mdev(ibdev); in get_core_cap_flags()
2899 enum rdma_link_layer ll = mlx5_ib_port_link_layer(ibdev, 1); in get_core_cap_flags()
2929 static int mlx5_port_immutable(struct ib_device *ibdev, u32 port_num, in mlx5_port_immutable() argument
2933 struct mlx5_ib_dev *dev = to_mdev(ibdev); in mlx5_port_immutable()
2934 enum rdma_link_layer ll = mlx5_ib_port_link_layer(ibdev, port_num); in mlx5_port_immutable()
2938 err = ib_query_port(ibdev, port_num, &attr); in mlx5_port_immutable()
2951 immutable->core_cap_flags = get_core_cap_flags(ibdev, &rep); in mlx5_port_immutable()
2957 static int mlx5_port_rep_immutable(struct ib_device *ibdev, u32 port_num, in mlx5_port_rep_immutable() argument
2965 err = ib_query_port(ibdev, port_num, &attr); in mlx5_port_rep_immutable()
2976 static void get_dev_fw_str(struct ib_device *ibdev, char *str) in get_dev_fw_str() argument
2979 container_of(ibdev, struct mlx5_ib_dev, ib_dev); in get_dev_fw_str()
3168 static void mlx5_ib_unbind_slave_port(struct mlx5_ib_dev *ibdev, in mlx5_ib_unbind_slave_port() argument
3172 struct mlx5_ib_port *port = &ibdev->port[port_num]; in mlx5_ib_unbind_slave_port()
3179 mlx5_core_mp_event_replay(ibdev->mdev, in mlx5_ib_unbind_slave_port()
3186 mlx5_ib_cleanup_cong_debugfs(ibdev, port_num); in mlx5_ib_unbind_slave_port()
3189 if (!mpi->ibdev) { in mlx5_ib_unbind_slave_port()
3194 mpi->ibdev = NULL; in mlx5_ib_unbind_slave_port()
3200 mlx5_mdev_netdev_untrack(ibdev, port_num); in mlx5_ib_unbind_slave_port()
3222 mlx5_ib_dbg(ibdev, "unaffiliated port %u\n", port_num + 1); in mlx5_ib_unbind_slave_port()
3227 mlx5_ib_err(ibdev, "Failed to unaffiliate port %u\n", in mlx5_ib_unbind_slave_port()
3230 ibdev->port[port_num].roce.last_port_state = IB_PORT_DOWN; in mlx5_ib_unbind_slave_port()
3233 static bool mlx5_ib_bind_slave_port(struct mlx5_ib_dev *ibdev, in mlx5_ib_bind_slave_port() argument
3242 spin_lock(&ibdev->port[port_num].mp.mpi_lock); in mlx5_ib_bind_slave_port()
3243 if (ibdev->port[port_num].mp.mpi) { in mlx5_ib_bind_slave_port()
3244 mlx5_ib_dbg(ibdev, "port %u already affiliated.\n", in mlx5_ib_bind_slave_port()
3246 spin_unlock(&ibdev->port[port_num].mp.mpi_lock); in mlx5_ib_bind_slave_port()
3250 ibdev->port[port_num].mp.mpi = mpi; in mlx5_ib_bind_slave_port()
3251 mpi->ibdev = ibdev; in mlx5_ib_bind_slave_port()
3253 spin_unlock(&ibdev->port[port_num].mp.mpi_lock); in mlx5_ib_bind_slave_port()
3255 err = mlx5_nic_vport_affiliate_multiport(ibdev->mdev, mpi->mdev); in mlx5_ib_bind_slave_port()
3259 mlx5_mdev_netdev_track(ibdev, port_num); in mlx5_ib_bind_slave_port()
3264 mlx5_ib_init_cong_debugfs(ibdev, port_num); in mlx5_ib_bind_slave_port()
3270 mlx5_core_mp_event_replay(ibdev->mdev, in mlx5_ib_bind_slave_port()
3277 mlx5_ib_unbind_slave_port(ibdev, mpi); in mlx5_ib_bind_slave_port()
3319 mpi->ibdev = dev; in mlx5_ib_init_multiport_master()
4353 mpi->ibdev->ib_active = true; in mlx5r_mp_probe()
4375 if (mpi->ibdev) in mlx5r_mp_remove()
4376 mlx5_ib_unbind_slave_port(mpi->ibdev, mpi); in mlx5r_mp_remove()