Commit 7f90a5a0 authored by Gary Leshner's avatar Gary Leshner Committed by Jason Gunthorpe

IB/{rdmavt, hfi1}: Implement creation of accelerated UD QPs

Adds capability to create a qpn to be recognized as an accelerated
UD QP for ipoib.

This is accomplished by reserving 0x81 in byte[0] of the qpn as the
prefix for these qp types and reserving qpns between 0x810000 and
0x81ffff.

The hfi1 capability mask already contained a flag for the VNIC netdev.
This has been renamed and extended to include both VNIC and ipoib.

The rvt code to allocate qps now recognizes this flag and sets 0x81
into byte[0] of the qpn.

The code to allocate qpns is modified to reset the qpn numbering when it
is detected that a value is located in byte[0] for a UD QP and it is a
qpn being requested for net dev use. If it is a regular UD QP then it is
allowable to have bits set in byte[0] of the qpn and provide the
previously normal behavior.

The code to free the qpn now checks for the AIP prefix value of 0x81 and
removes it from the qpn before being freed so that the lower 16 bit
number can be reused.

This patch requires minor changes in the IB core and ipoib to facilitate
the creation of accelerated UP QPs.

Link: https://lore.kernel.org/r/20200511160607.173205.11757.stgit@awfm-01.aw.intel.comReviewed-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarGary Leshner <Gary.S.Leshner@intel.com>
Signed-off-by: default avatarKaike Wan <kaike.wan@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 84e3b19a
...@@ -1342,7 +1342,7 @@ static void hfi1_fill_device_attr(struct hfi1_devdata *dd) ...@@ -1342,7 +1342,7 @@ static void hfi1_fill_device_attr(struct hfi1_devdata *dd)
IB_DEVICE_SYS_IMAGE_GUID | IB_DEVICE_RC_RNR_NAK_GEN | IB_DEVICE_SYS_IMAGE_GUID | IB_DEVICE_RC_RNR_NAK_GEN |
IB_DEVICE_PORT_ACTIVE_EVENT | IB_DEVICE_SRQ_RESIZE | IB_DEVICE_PORT_ACTIVE_EVENT | IB_DEVICE_SRQ_RESIZE |
IB_DEVICE_MEM_MGT_EXTENSIONS | IB_DEVICE_MEM_MGT_EXTENSIONS |
IB_DEVICE_RDMA_NETDEV_OPA_VNIC; IB_DEVICE_RDMA_NETDEV_OPA;
rdi->dparms.props.page_size_cap = PAGE_SIZE; rdi->dparms.props.page_size_cap = PAGE_SIZE;
rdi->dparms.props.vendor_id = dd->oui1 << 16 | dd->oui2 << 8 | dd->oui3; rdi->dparms.props.vendor_id = dd->oui1 << 16 | dd->oui2 << 8 | dd->oui3;
rdi->dparms.props.vendor_part_id = dd->pcidev->device; rdi->dparms.props.vendor_part_id = dd->pcidev->device;
......
/* /*
* Copyright(c) 2016 - 2019 Intel Corporation. * Copyright(c) 2016 - 2020 Intel Corporation.
* *
* This file is provided under a dual BSD/GPLv2 license. When using or * This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license. * redistributing this file, you may do so under either license.
...@@ -525,15 +525,18 @@ static inline unsigned mk_qpn(struct rvt_qpn_table *qpt, ...@@ -525,15 +525,18 @@ static inline unsigned mk_qpn(struct rvt_qpn_table *qpt,
* @rdi: rvt device info structure * @rdi: rvt device info structure
* @qpt: queue pair number table pointer * @qpt: queue pair number table pointer
* @port_num: IB port number, 1 based, comes from core * @port_num: IB port number, 1 based, comes from core
* @exclude_prefix: prefix of special queue pair number being allocated
* *
* Return: The queue pair number * Return: The queue pair number
*/ */
static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
enum ib_qp_type type, u8 port_num) enum ib_qp_type type, u8 port_num, u8 exclude_prefix)
{ {
u32 i, offset, max_scan, qpn; u32 i, offset, max_scan, qpn;
struct rvt_qpn_map *map; struct rvt_qpn_map *map;
u32 ret; u32 ret;
u32 max_qpn = exclude_prefix == RVT_AIP_QP_PREFIX ?
RVT_AIP_QPN_MAX : RVT_QPN_MAX;
if (rdi->driver_f.alloc_qpn) if (rdi->driver_f.alloc_qpn)
return rdi->driver_f.alloc_qpn(rdi, qpt, type, port_num); return rdi->driver_f.alloc_qpn(rdi, qpt, type, port_num);
...@@ -553,7 +556,7 @@ static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, ...@@ -553,7 +556,7 @@ static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
} }
qpn = qpt->last + qpt->incr; qpn = qpt->last + qpt->incr;
if (qpn >= RVT_QPN_MAX) if (qpn >= max_qpn)
qpn = qpt->incr | ((qpt->last & 1) ^ 1); qpn = qpt->incr | ((qpt->last & 1) ^ 1);
/* offset carries bit 0 */ /* offset carries bit 0 */
offset = qpn & RVT_BITS_PER_PAGE_MASK; offset = qpn & RVT_BITS_PER_PAGE_MASK;
...@@ -987,6 +990,9 @@ static void rvt_free_qpn(struct rvt_qpn_table *qpt, u32 qpn) ...@@ -987,6 +990,9 @@ static void rvt_free_qpn(struct rvt_qpn_table *qpt, u32 qpn)
{ {
struct rvt_qpn_map *map; struct rvt_qpn_map *map;
if ((qpn & RVT_AIP_QP_PREFIX_MASK) == RVT_AIP_QP_BASE)
qpn &= RVT_AIP_QP_SUFFIX;
map = qpt->map + (qpn & RVT_QPN_MASK) / RVT_BITS_PER_PAGE; map = qpt->map + (qpn & RVT_QPN_MASK) / RVT_BITS_PER_PAGE;
if (map->page) if (map->page)
clear_bit(qpn & RVT_BITS_PER_PAGE_MASK, map->page); clear_bit(qpn & RVT_BITS_PER_PAGE_MASK, map->page);
...@@ -1074,13 +1080,15 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, ...@@ -1074,13 +1080,15 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
struct rvt_dev_info *rdi = ib_to_rvt(ibpd->device); struct rvt_dev_info *rdi = ib_to_rvt(ibpd->device);
void *priv = NULL; void *priv = NULL;
size_t sqsize; size_t sqsize;
u8 exclude_prefix = 0;
if (!rdi) if (!rdi)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
if (init_attr->cap.max_send_sge > rdi->dparms.props.max_send_sge || if (init_attr->cap.max_send_sge > rdi->dparms.props.max_send_sge ||
init_attr->cap.max_send_wr > rdi->dparms.props.max_qp_wr || init_attr->cap.max_send_wr > rdi->dparms.props.max_qp_wr ||
init_attr->create_flags) (init_attr->create_flags &&
init_attr->create_flags != IB_QP_CREATE_NETDEV_USE))
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
/* Check receive queue parameters if no SRQ is specified. */ /* Check receive queue parameters if no SRQ is specified. */
...@@ -1199,14 +1207,20 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, ...@@ -1199,14 +1207,20 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
goto bail_driver_priv; goto bail_driver_priv;
} }
if (init_attr->create_flags & IB_QP_CREATE_NETDEV_USE)
exclude_prefix = RVT_AIP_QP_PREFIX;
err = alloc_qpn(rdi, &rdi->qp_dev->qpn_table, err = alloc_qpn(rdi, &rdi->qp_dev->qpn_table,
init_attr->qp_type, init_attr->qp_type,
init_attr->port_num); init_attr->port_num,
exclude_prefix);
if (err < 0) { if (err < 0) {
ret = ERR_PTR(err); ret = ERR_PTR(err);
goto bail_rq_wq; goto bail_rq_wq;
} }
qp->ibqp.qp_num = err; qp->ibqp.qp_num = err;
if (init_attr->create_flags & IB_QP_CREATE_NETDEV_USE)
qp->ibqp.qp_num |= RVT_AIP_QP_BASE;
qp->port_num = init_attr->port_num; qp->port_num = init_attr->port_num;
rvt_init_qp(rdi, qp, init_attr->qp_type); rvt_init_qp(rdi, qp, init_attr->qp_type);
if (rdi->driver_f.qp_priv_init) { if (rdi->driver_f.qp_priv_init) {
......
...@@ -206,6 +206,9 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca) ...@@ -206,6 +206,9 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca)
if (priv->hca_caps & IB_DEVICE_MANAGED_FLOW_STEERING) if (priv->hca_caps & IB_DEVICE_MANAGED_FLOW_STEERING)
init_attr.create_flags |= IB_QP_CREATE_NETIF_QP; init_attr.create_flags |= IB_QP_CREATE_NETIF_QP;
if (priv->hca_caps & IB_DEVICE_RDMA_NETDEV_OPA)
init_attr.create_flags |= IB_QP_CREATE_NETDEV_USE;
priv->qp = ib_create_qp(priv->pd, &init_attr); priv->qp = ib_create_qp(priv->pd, &init_attr);
if (IS_ERR(priv->qp)) { if (IS_ERR(priv->qp)) {
pr_warn("%s: failed to create QP\n", ca->name); pr_warn("%s: failed to create QP\n", ca->name);
......
...@@ -305,7 +305,7 @@ enum ib_device_cap_flags { ...@@ -305,7 +305,7 @@ enum ib_device_cap_flags {
IB_DEVICE_VIRTUAL_FUNCTION = (1ULL << 33), IB_DEVICE_VIRTUAL_FUNCTION = (1ULL << 33),
/* Deprecated. Please use IB_RAW_PACKET_CAP_SCATTER_FCS. */ /* Deprecated. Please use IB_RAW_PACKET_CAP_SCATTER_FCS. */
IB_DEVICE_RAW_SCATTER_FCS = (1ULL << 34), IB_DEVICE_RAW_SCATTER_FCS = (1ULL << 34),
IB_DEVICE_RDMA_NETDEV_OPA_VNIC = (1ULL << 35), IB_DEVICE_RDMA_NETDEV_OPA = (1ULL << 35),
/* The device supports padding incoming writes to cacheline. */ /* The device supports padding incoming writes to cacheline. */
IB_DEVICE_PCI_WRITE_END_PADDING = (1ULL << 36), IB_DEVICE_PCI_WRITE_END_PADDING = (1ULL << 36),
IB_DEVICE_ALLOW_USER_UNREG = (1ULL << 37), IB_DEVICE_ALLOW_USER_UNREG = (1ULL << 37),
...@@ -1117,7 +1117,7 @@ enum ib_qp_create_flags { ...@@ -1117,7 +1117,7 @@ enum ib_qp_create_flags {
IB_QP_CREATE_MANAGED_RECV = 1 << 4, IB_QP_CREATE_MANAGED_RECV = 1 << 4,
IB_QP_CREATE_NETIF_QP = 1 << 5, IB_QP_CREATE_NETIF_QP = 1 << 5,
IB_QP_CREATE_INTEGRITY_EN = 1 << 6, IB_QP_CREATE_INTEGRITY_EN = 1 << 6,
/* FREE = 1 << 7, */ IB_QP_CREATE_NETDEV_USE = 1 << 7,
IB_QP_CREATE_SCATTER_FCS = 1 << 8, IB_QP_CREATE_SCATTER_FCS = 1 << 8,
IB_QP_CREATE_CVLAN_STRIPPING = 1 << 9, IB_QP_CREATE_CVLAN_STRIPPING = 1 << 9,
IB_QP_CREATE_SOURCE_QPN = 1 << 10, IB_QP_CREATE_SOURCE_QPN = 1 << 10,
......
#ifndef _OPA_VNIC_H #ifndef _OPA_VNIC_H
#define _OPA_VNIC_H #define _OPA_VNIC_H
/* /*
* Copyright(c) 2017 Intel Corporation. * Copyright(c) 2017 - 2020 Intel Corporation.
* *
* This file is provided under a dual BSD/GPLv2 license. When using or * This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license. * redistributing this file, you may do so under either license.
...@@ -132,7 +132,7 @@ struct opa_vnic_stats { ...@@ -132,7 +132,7 @@ struct opa_vnic_stats {
static inline bool rdma_cap_opa_vnic(struct ib_device *device) static inline bool rdma_cap_opa_vnic(struct ib_device *device)
{ {
return !!(device->attrs.device_cap_flags & return !!(device->attrs.device_cap_flags &
IB_DEVICE_RDMA_NETDEV_OPA_VNIC); IB_DEVICE_RDMA_NETDEV_OPA);
} }
#endif /* _OPA_VNIC_H */ #endif /* _OPA_VNIC_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment