Skip to content

Commit 7f90a5a

Browse files
gsleshnejgunthorpe
authored andcommitted
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/[email protected] Reviewed-by: Dennis Dalessandro <[email protected]> Reviewed-by: Mike Marciniszyn <[email protected]> Signed-off-by: Gary Leshner <[email protected]> Signed-off-by: Kaike Wan <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 84e3b19 commit 7f90a5a

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

drivers/infiniband/hw/hfi1/verbs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ static void hfi1_fill_device_attr(struct hfi1_devdata *dd)
13421342
IB_DEVICE_SYS_IMAGE_GUID | IB_DEVICE_RC_RNR_NAK_GEN |
13431343
IB_DEVICE_PORT_ACTIVE_EVENT | IB_DEVICE_SRQ_RESIZE |
13441344
IB_DEVICE_MEM_MGT_EXTENSIONS |
1345-
IB_DEVICE_RDMA_NETDEV_OPA_VNIC;
1345+
IB_DEVICE_RDMA_NETDEV_OPA;
13461346
rdi->dparms.props.page_size_cap = PAGE_SIZE;
13471347
rdi->dparms.props.vendor_id = dd->oui1 << 16 | dd->oui2 << 8 | dd->oui3;
13481348
rdi->dparms.props.vendor_part_id = dd->pcidev->device;

drivers/infiniband/sw/rdmavt/qp.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright(c) 2016 - 2019 Intel Corporation.
2+
* Copyright(c) 2016 - 2020 Intel Corporation.
33
*
44
* This file is provided under a dual BSD/GPLv2 license. When using or
55
* redistributing this file, you may do so under either license.
@@ -525,15 +525,18 @@ static inline unsigned mk_qpn(struct rvt_qpn_table *qpt,
525525
* @rdi: rvt device info structure
526526
* @qpt: queue pair number table pointer
527527
* @port_num: IB port number, 1 based, comes from core
528+
* @exclude_prefix: prefix of special queue pair number being allocated
528529
*
529530
* Return: The queue pair number
530531
*/
531532
static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
532-
enum ib_qp_type type, u8 port_num)
533+
enum ib_qp_type type, u8 port_num, u8 exclude_prefix)
533534
{
534535
u32 i, offset, max_scan, qpn;
535536
struct rvt_qpn_map *map;
536537
u32 ret;
538+
u32 max_qpn = exclude_prefix == RVT_AIP_QP_PREFIX ?
539+
RVT_AIP_QPN_MAX : RVT_QPN_MAX;
537540

538541
if (rdi->driver_f.alloc_qpn)
539542
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,
553556
}
554557

555558
qpn = qpt->last + qpt->incr;
556-
if (qpn >= RVT_QPN_MAX)
559+
if (qpn >= max_qpn)
557560
qpn = qpt->incr | ((qpt->last & 1) ^ 1);
558561
/* offset carries bit 0 */
559562
offset = qpn & RVT_BITS_PER_PAGE_MASK;
@@ -987,6 +990,9 @@ static void rvt_free_qpn(struct rvt_qpn_table *qpt, u32 qpn)
987990
{
988991
struct rvt_qpn_map *map;
989992

993+
if ((qpn & RVT_AIP_QP_PREFIX_MASK) == RVT_AIP_QP_BASE)
994+
qpn &= RVT_AIP_QP_SUFFIX;
995+
990996
map = qpt->map + (qpn & RVT_QPN_MASK) / RVT_BITS_PER_PAGE;
991997
if (map->page)
992998
clear_bit(qpn & RVT_BITS_PER_PAGE_MASK, map->page);
@@ -1074,13 +1080,15 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
10741080
struct rvt_dev_info *rdi = ib_to_rvt(ibpd->device);
10751081
void *priv = NULL;
10761082
size_t sqsize;
1083+
u8 exclude_prefix = 0;
10771084

10781085
if (!rdi)
10791086
return ERR_PTR(-EINVAL);
10801087

10811088
if (init_attr->cap.max_send_sge > rdi->dparms.props.max_send_sge ||
10821089
init_attr->cap.max_send_wr > rdi->dparms.props.max_qp_wr ||
1083-
init_attr->create_flags)
1090+
(init_attr->create_flags &&
1091+
init_attr->create_flags != IB_QP_CREATE_NETDEV_USE))
10841092
return ERR_PTR(-EINVAL);
10851093

10861094
/* Check receive queue parameters if no SRQ is specified. */
@@ -1199,14 +1207,20 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
11991207
goto bail_driver_priv;
12001208
}
12011209

1210+
if (init_attr->create_flags & IB_QP_CREATE_NETDEV_USE)
1211+
exclude_prefix = RVT_AIP_QP_PREFIX;
1212+
12021213
err = alloc_qpn(rdi, &rdi->qp_dev->qpn_table,
12031214
init_attr->qp_type,
1204-
init_attr->port_num);
1215+
init_attr->port_num,
1216+
exclude_prefix);
12051217
if (err < 0) {
12061218
ret = ERR_PTR(err);
12071219
goto bail_rq_wq;
12081220
}
12091221
qp->ibqp.qp_num = err;
1222+
if (init_attr->create_flags & IB_QP_CREATE_NETDEV_USE)
1223+
qp->ibqp.qp_num |= RVT_AIP_QP_BASE;
12101224
qp->port_num = init_attr->port_num;
12111225
rvt_init_qp(rdi, qp, init_attr->qp_type);
12121226
if (rdi->driver_f.qp_priv_init) {

drivers/infiniband/ulp/ipoib/ipoib_verbs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca)
206206
if (priv->hca_caps & IB_DEVICE_MANAGED_FLOW_STEERING)
207207
init_attr.create_flags |= IB_QP_CREATE_NETIF_QP;
208208

209+
if (priv->hca_caps & IB_DEVICE_RDMA_NETDEV_OPA)
210+
init_attr.create_flags |= IB_QP_CREATE_NETDEV_USE;
211+
209212
priv->qp = ib_create_qp(priv->pd, &init_attr);
210213
if (IS_ERR(priv->qp)) {
211214
pr_warn("%s: failed to create QP\n", ca->name);

include/rdma/ib_verbs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ enum ib_device_cap_flags {
305305
IB_DEVICE_VIRTUAL_FUNCTION = (1ULL << 33),
306306
/* Deprecated. Please use IB_RAW_PACKET_CAP_SCATTER_FCS. */
307307
IB_DEVICE_RAW_SCATTER_FCS = (1ULL << 34),
308-
IB_DEVICE_RDMA_NETDEV_OPA_VNIC = (1ULL << 35),
308+
IB_DEVICE_RDMA_NETDEV_OPA = (1ULL << 35),
309309
/* The device supports padding incoming writes to cacheline. */
310310
IB_DEVICE_PCI_WRITE_END_PADDING = (1ULL << 36),
311311
IB_DEVICE_ALLOW_USER_UNREG = (1ULL << 37),
@@ -1117,7 +1117,7 @@ enum ib_qp_create_flags {
11171117
IB_QP_CREATE_MANAGED_RECV = 1 << 4,
11181118
IB_QP_CREATE_NETIF_QP = 1 << 5,
11191119
IB_QP_CREATE_INTEGRITY_EN = 1 << 6,
1120-
/* FREE = 1 << 7, */
1120+
IB_QP_CREATE_NETDEV_USE = 1 << 7,
11211121
IB_QP_CREATE_SCATTER_FCS = 1 << 8,
11221122
IB_QP_CREATE_CVLAN_STRIPPING = 1 << 9,
11231123
IB_QP_CREATE_SOURCE_QPN = 1 << 10,

include/rdma/opa_vnic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef _OPA_VNIC_H
22
#define _OPA_VNIC_H
33
/*
4-
* Copyright(c) 2017 Intel Corporation.
4+
* Copyright(c) 2017 - 2020 Intel Corporation.
55
*
66
* This file is provided under a dual BSD/GPLv2 license. When using or
77
* redistributing this file, you may do so under either license.
@@ -132,7 +132,7 @@ struct opa_vnic_stats {
132132
static inline bool rdma_cap_opa_vnic(struct ib_device *device)
133133
{
134134
return !!(device->attrs.device_cap_flags &
135-
IB_DEVICE_RDMA_NETDEV_OPA_VNIC);
135+
IB_DEVICE_RDMA_NETDEV_OPA);
136136
}
137137

138138
#endif /* _OPA_VNIC_H */

0 commit comments

Comments
 (0)