Skip to content

Commit 2b8af50

Browse files
mrgolinrleon
authored andcommitted
RDMA/efa: Support QP with unsolicited write w/ imm. receive
Add a new EFA flags attribute for QP creation, and support unsolicited write with immediate flag. QPs created with this flag set will not consume receive work requests for incoming RDMA write with immediate. Expose device capability bit for this feature support. Reviewed-by: Daniel Kranzdorf <[email protected]> Reviewed-by: Firas Jahjah <[email protected]> Signed-off-by: Michael Margolin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent f483f6a commit 2b8af50

File tree

5 files changed

+38
-3
lines changed

5 files changed

+38
-3
lines changed

drivers/infiniband/hw/efa/efa_admin_cmds_defs.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ struct efa_admin_create_qp_cmd {
110110
* virtual (IOVA returned by MR registration)
111111
* 1 : rq_virt - If set, RQ ring base address is
112112
* virtual (IOVA returned by MR registration)
113-
* 7:2 : reserved - MBZ
113+
* 2 : unsolicited_write_recv - If set, work requests
114+
* will not be consumed for incoming RDMA write with
115+
* immediate
116+
* 7:3 : reserved - MBZ
114117
*/
115118
u8 flags;
116119

@@ -663,7 +666,9 @@ struct efa_admin_feature_device_attr_desc {
663666
* polling is supported
664667
* 3 : rdma_write - If set, RDMA Write is supported
665668
* on TX queues
666-
* 31:4 : reserved - MBZ
669+
* 4 : unsolicited_write_recv - If set, unsolicited
670+
* write with imm. receive is supported
671+
* 31:5 : reserved - MBZ
667672
*/
668673
u32 device_caps;
669674

@@ -1009,6 +1014,7 @@ struct efa_admin_host_info {
10091014
/* create_qp_cmd */
10101015
#define EFA_ADMIN_CREATE_QP_CMD_SQ_VIRT_MASK BIT(0)
10111016
#define EFA_ADMIN_CREATE_QP_CMD_RQ_VIRT_MASK BIT(1)
1017+
#define EFA_ADMIN_CREATE_QP_CMD_UNSOLICITED_WRITE_RECV_MASK BIT(2)
10121018

10131019
/* modify_qp_cmd */
10141020
#define EFA_ADMIN_MODIFY_QP_CMD_QP_STATE_MASK BIT(0)
@@ -1044,6 +1050,7 @@ struct efa_admin_host_info {
10441050
#define EFA_ADMIN_FEATURE_DEVICE_ATTR_DESC_RNR_RETRY_MASK BIT(1)
10451051
#define EFA_ADMIN_FEATURE_DEVICE_ATTR_DESC_DATA_POLLING_128_MASK BIT(2)
10461052
#define EFA_ADMIN_FEATURE_DEVICE_ATTR_DESC_RDMA_WRITE_MASK BIT(3)
1053+
#define EFA_ADMIN_FEATURE_DEVICE_ATTR_DESC_UNSOLICITED_WRITE_RECV_MASK BIT(4)
10471054

10481055
/* create_eq_cmd */
10491056
#define EFA_ADMIN_CREATE_EQ_CMD_ENTRY_SIZE_WORDS_MASK GENMASK(4, 0)

drivers/infiniband/hw/efa/efa_com_cmd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ int efa_com_create_qp(struct efa_com_dev *edev,
3232
params->rq_depth;
3333
create_qp_cmd.uar = params->uarn;
3434

35+
if (params->unsolicited_write_recv)
36+
EFA_SET(&create_qp_cmd.flags, EFA_ADMIN_CREATE_QP_CMD_UNSOLICITED_WRITE_RECV, 1);
37+
3538
err = efa_com_cmd_exec(aq,
3639
(struct efa_admin_aq_entry *)&create_qp_cmd,
3740
sizeof(create_qp_cmd),

drivers/infiniband/hw/efa/efa_com_cmd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct efa_com_create_qp_params {
2727
u16 pd;
2828
u16 uarn;
2929
u8 qp_type;
30+
u8 unsolicited_write_recv : 1;
3031
};
3132

3233
struct efa_com_create_qp_result {

drivers/infiniband/hw/efa/efa_verbs.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ int efa_query_device(struct ib_device *ibdev,
263263
if (EFA_DEV_CAP(dev, RDMA_WRITE))
264264
resp.device_caps |= EFA_QUERY_DEVICE_CAPS_RDMA_WRITE;
265265

266+
if (EFA_DEV_CAP(dev, UNSOLICITED_WRITE_RECV))
267+
resp.device_caps |= EFA_QUERY_DEVICE_CAPS_UNSOLICITED_WRITE_RECV;
268+
266269
if (dev->neqs)
267270
resp.device_caps |= EFA_QUERY_DEVICE_CAPS_CQ_NOTIFICATIONS;
268271

@@ -639,6 +642,7 @@ int efa_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr,
639642
struct efa_ibv_create_qp cmd = {};
640643
struct efa_qp *qp = to_eqp(ibqp);
641644
struct efa_ucontext *ucontext;
645+
u16 supported_efa_flags = 0;
642646
int err;
643647

644648
ucontext = rdma_udata_to_drv_context(udata, struct efa_ucontext,
@@ -676,13 +680,23 @@ int efa_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr,
676680
goto err_out;
677681
}
678682

679-
if (cmd.comp_mask) {
683+
if (cmd.comp_mask || !is_reserved_cleared(cmd.reserved_90)) {
680684
ibdev_dbg(&dev->ibdev,
681685
"Incompatible ABI params, unknown fields in udata\n");
682686
err = -EINVAL;
683687
goto err_out;
684688
}
685689

690+
if (EFA_DEV_CAP(dev, UNSOLICITED_WRITE_RECV))
691+
supported_efa_flags |= EFA_CREATE_QP_WITH_UNSOLICITED_WRITE_RECV;
692+
693+
if (cmd.flags & ~supported_efa_flags) {
694+
ibdev_dbg(&dev->ibdev, "Unsupported EFA QP create flags[%#x], supported[%#x]\n",
695+
cmd.flags, supported_efa_flags);
696+
err = -EOPNOTSUPP;
697+
goto err_out;
698+
}
699+
686700
create_qp_params.uarn = ucontext->uarn;
687701
create_qp_params.pd = to_epd(ibqp->pd)->pdn;
688702

@@ -722,6 +736,9 @@ int efa_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr,
722736
create_qp_params.rq_base_addr = qp->rq_dma_addr;
723737
}
724738

739+
if (cmd.flags & EFA_CREATE_QP_WITH_UNSOLICITED_WRITE_RECV)
740+
create_qp_params.unsolicited_write_recv = true;
741+
725742
err = efa_com_create_qp(&dev->edev, &create_qp_params,
726743
&create_qp_resp);
727744
if (err)

include/uapi/rdma/efa-abi.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,17 @@ enum {
8585
EFA_QP_DRIVER_TYPE_SRD = 0,
8686
};
8787

88+
enum {
89+
EFA_CREATE_QP_WITH_UNSOLICITED_WRITE_RECV = 1 << 0,
90+
};
91+
8892
struct efa_ibv_create_qp {
8993
__u32 comp_mask;
9094
__u32 rq_ring_size; /* bytes */
9195
__u32 sq_ring_size; /* bytes */
9296
__u32 driver_qp_type;
97+
__u16 flags;
98+
__u8 reserved_90[6];
9399
};
94100

95101
struct efa_ibv_create_qp_resp {
@@ -123,6 +129,7 @@ enum {
123129
EFA_QUERY_DEVICE_CAPS_CQ_WITH_SGID = 1 << 3,
124130
EFA_QUERY_DEVICE_CAPS_DATA_POLLING_128 = 1 << 4,
125131
EFA_QUERY_DEVICE_CAPS_RDMA_WRITE = 1 << 5,
132+
EFA_QUERY_DEVICE_CAPS_UNSOLICITED_WRITE_RECV = 1 << 6,
126133
};
127134

128135
struct efa_ibv_ex_query_device_resp {

0 commit comments

Comments
 (0)