mirror of https://gitee.com/openkylin/linux.git
IB/mlx5: Extend query_device/port to support RoCE
Using the vport access functions to retrieve the Ethernet specific information and return this information in ib_query_device and ib_query_port. Signed-off-by: Achiad Shochat <achiad@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
parent
9efa752545
commit
3f89a643eb
|
@ -40,6 +40,7 @@
|
|||
#include <linux/io-mapping.h>
|
||||
#include <linux/sched.h>
|
||||
#include <rdma/ib_user_verbs.h>
|
||||
#include <rdma/ib_addr.h>
|
||||
#include <linux/mlx5/vport.h>
|
||||
#include <rdma/ib_smi.h>
|
||||
#include <rdma/ib_umem.h>
|
||||
|
@ -120,6 +121,50 @@ static struct net_device *mlx5_ib_get_netdev(struct ib_device *device,
|
|||
return ndev;
|
||||
}
|
||||
|
||||
static int mlx5_query_port_roce(struct ib_device *device, u8 port_num,
|
||||
struct ib_port_attr *props)
|
||||
{
|
||||
struct mlx5_ib_dev *dev = to_mdev(device);
|
||||
struct net_device *ndev;
|
||||
enum ib_mtu ndev_ib_mtu;
|
||||
|
||||
memset(props, 0, sizeof(*props));
|
||||
|
||||
props->port_cap_flags |= IB_PORT_CM_SUP;
|
||||
props->port_cap_flags |= IB_PORT_IP_BASED_GIDS;
|
||||
|
||||
props->gid_tbl_len = MLX5_CAP_ROCE(dev->mdev,
|
||||
roce_address_table_size);
|
||||
props->max_mtu = IB_MTU_4096;
|
||||
props->max_msg_sz = 1 << MLX5_CAP_GEN(dev->mdev, log_max_msg);
|
||||
props->pkey_tbl_len = 1;
|
||||
props->state = IB_PORT_DOWN;
|
||||
props->phys_state = 3;
|
||||
|
||||
mlx5_query_nic_vport_qkey_viol_cntr(dev->mdev,
|
||||
(u16 *)&props->qkey_viol_cntr);
|
||||
|
||||
ndev = mlx5_ib_get_netdev(device, port_num);
|
||||
if (!ndev)
|
||||
return 0;
|
||||
|
||||
if (netif_running(ndev) && netif_carrier_ok(ndev)) {
|
||||
props->state = IB_PORT_ACTIVE;
|
||||
props->phys_state = 5;
|
||||
}
|
||||
|
||||
ndev_ib_mtu = iboe_get_mtu(ndev->mtu);
|
||||
|
||||
dev_put(ndev);
|
||||
|
||||
props->active_mtu = min(props->max_mtu, ndev_ib_mtu);
|
||||
|
||||
props->active_width = IB_WIDTH_4X; /* TODO */
|
||||
props->active_speed = IB_SPEED_QDR; /* TODO */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mlx5_use_mad_ifc(struct mlx5_ib_dev *dev)
|
||||
{
|
||||
return !dev->mdev->issi;
|
||||
|
@ -158,13 +203,21 @@ static int mlx5_query_system_image_guid(struct ib_device *ibdev,
|
|||
|
||||
case MLX5_VPORT_ACCESS_METHOD_HCA:
|
||||
err = mlx5_query_hca_vport_system_image_guid(mdev, &tmp);
|
||||
if (!err)
|
||||
*sys_image_guid = cpu_to_be64(tmp);
|
||||
return err;
|
||||
break;
|
||||
|
||||
case MLX5_VPORT_ACCESS_METHOD_NIC:
|
||||
err = mlx5_query_nic_vport_system_image_guid(mdev, &tmp);
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!err)
|
||||
*sys_image_guid = cpu_to_be64(tmp);
|
||||
|
||||
return err;
|
||||
|
||||
}
|
||||
|
||||
static int mlx5_query_max_pkeys(struct ib_device *ibdev,
|
||||
|
@ -218,13 +271,20 @@ static int mlx5_query_node_guid(struct mlx5_ib_dev *dev,
|
|||
|
||||
case MLX5_VPORT_ACCESS_METHOD_HCA:
|
||||
err = mlx5_query_hca_vport_node_guid(dev->mdev, &tmp);
|
||||
if (!err)
|
||||
*node_guid = cpu_to_be64(tmp);
|
||||
return err;
|
||||
break;
|
||||
|
||||
case MLX5_VPORT_ACCESS_METHOD_NIC:
|
||||
err = mlx5_query_nic_vport_node_guid(dev->mdev, &tmp);
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!err)
|
||||
*node_guid = cpu_to_be64(tmp);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
struct mlx5_reg_node_desc {
|
||||
|
@ -522,6 +582,9 @@ int mlx5_ib_query_port(struct ib_device *ibdev, u8 port,
|
|||
case MLX5_VPORT_ACCESS_METHOD_HCA:
|
||||
return mlx5_query_hca_port(ibdev, port, props);
|
||||
|
||||
case MLX5_VPORT_ACCESS_METHOD_NIC:
|
||||
return mlx5_query_port_roce(ibdev, port, props);
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -632,13 +632,6 @@ extern struct workqueue_struct *mlx5_core_wq;
|
|||
.struct_offset_bytes = offsetof(struct ib_unpacked_ ## header, field), \
|
||||
.struct_size_bytes = sizeof((struct ib_unpacked_ ## header *)0)->field
|
||||
|
||||
struct ib_field {
|
||||
size_t struct_offset_bytes;
|
||||
size_t struct_size_bytes;
|
||||
int offset_bits;
|
||||
int size_bits;
|
||||
};
|
||||
|
||||
static inline struct mlx5_core_dev *pci2mlx5_core_dev(struct pci_dev *pdev)
|
||||
{
|
||||
return pci_get_drvdata(pdev);
|
||||
|
|
Loading…
Reference in New Issue