Skip to content

Commit 2bb185c

Browse files
Luoyoumingjgunthorpe
authored andcommitted
RDMA/hns: Add compatibility handling for only support userspace rq inline
The rq inline makes some changes as follows, Firstly, it is only used in user space. Secondly, it should notify hardware in QP RTR status. Thirdly, Add compatibility processing between different user space and kernel space. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Luoyouming <[email protected]> Signed-off-by: Haoyue Xu <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 968606e commit 2bb185c

File tree

5 files changed

+31
-11
lines changed

5 files changed

+31
-11
lines changed

drivers/infiniband/hw/hns/hns_roce_device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ struct hns_roce_hw {
871871
u32 step_idx);
872872
int (*modify_qp)(struct ib_qp *ibqp, const struct ib_qp_attr *attr,
873873
int attr_mask, enum ib_qp_state cur_state,
874-
enum ib_qp_state new_state);
874+
enum ib_qp_state new_state, struct ib_udata *udata);
875875
int (*qp_flow_control_init)(struct hns_roce_dev *hr_dev,
876876
struct hns_roce_qp *hr_qp);
877877
void (*dereg_mr)(struct hns_roce_dev *hr_dev);

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2837,7 +2837,7 @@ static int free_mr_modify_rsv_qp(struct hns_roce_dev *hr_dev,
28372837
attr->port_num = 1;
28382838
attr->qp_access_flags = IB_ACCESS_REMOTE_WRITE;
28392839
ret = hr_dev->hw->modify_qp(&hr_qp->ibqp, attr, mask, IB_QPS_INIT,
2840-
IB_QPS_INIT);
2840+
IB_QPS_INIT, NULL);
28412841
if (ret) {
28422842
ibdev_err(ibdev, "failed to modify qp to init, ret = %d.\n",
28432843
ret);
@@ -2859,7 +2859,7 @@ static int free_mr_modify_rsv_qp(struct hns_roce_dev *hr_dev,
28592859
rdma_ah_set_sl(&attr->ah_attr, (u8)sl_num);
28602860

28612861
ret = hr_dev->hw->modify_qp(&hr_qp->ibqp, attr, mask, IB_QPS_INIT,
2862-
IB_QPS_RTR);
2862+
IB_QPS_RTR, NULL);
28632863
hr_dev->loop_idc = loopback;
28642864
if (ret) {
28652865
ibdev_err(ibdev, "failed to modify qp to rtr, ret = %d.\n",
@@ -2874,7 +2874,7 @@ static int free_mr_modify_rsv_qp(struct hns_roce_dev *hr_dev,
28742874
attr->retry_cnt = HNS_ROCE_FREE_MR_USED_QP_RETRY_CNT;
28752875
attr->timeout = HNS_ROCE_FREE_MR_USED_QP_TIMEOUT;
28762876
ret = hr_dev->hw->modify_qp(&hr_qp->ibqp, attr, mask, IB_QPS_RTR,
2877-
IB_QPS_RTS);
2877+
IB_QPS_RTS, NULL);
28782878
if (ret)
28792879
ibdev_err(ibdev, "failed to modify qp to rts, ret = %d.\n",
28802880
ret);
@@ -4572,8 +4572,11 @@ static inline enum ib_mtu get_mtu(struct ib_qp *ibqp,
45724572
static int modify_qp_init_to_rtr(struct ib_qp *ibqp,
45734573
const struct ib_qp_attr *attr, int attr_mask,
45744574
struct hns_roce_v2_qp_context *context,
4575-
struct hns_roce_v2_qp_context *qpc_mask)
4575+
struct hns_roce_v2_qp_context *qpc_mask,
4576+
struct ib_udata *udata)
45764577
{
4578+
struct hns_roce_ucontext *uctx = rdma_udata_to_drv_context(udata,
4579+
struct hns_roce_ucontext, ibucontext);
45774580
struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
45784581
struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
45794582
struct ib_device *ibdev = &hr_dev->ib_dev;
@@ -4693,6 +4696,14 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,
46934696
hr_reg_write(context, QPC_LP_SGEN_INI, 3);
46944697
hr_reg_clear(qpc_mask, QPC_LP_SGEN_INI);
46954698

4699+
if (udata && ibqp->qp_type == IB_QPT_RC &&
4700+
(uctx->config & HNS_ROCE_RQ_INLINE_FLAGS)) {
4701+
hr_reg_write_bool(context, QPC_RQIE,
4702+
hr_dev->caps.flags &
4703+
HNS_ROCE_CAP_FLAG_RQ_INLINE);
4704+
hr_reg_clear(qpc_mask, QPC_RQIE);
4705+
}
4706+
46964707
return 0;
46974708
}
46984709

@@ -5040,7 +5051,8 @@ static int hns_roce_v2_set_abs_fields(struct ib_qp *ibqp,
50405051
enum ib_qp_state cur_state,
50415052
enum ib_qp_state new_state,
50425053
struct hns_roce_v2_qp_context *context,
5043-
struct hns_roce_v2_qp_context *qpc_mask)
5054+
struct hns_roce_v2_qp_context *qpc_mask,
5055+
struct ib_udata *udata)
50445056
{
50455057
struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
50465058
int ret = 0;
@@ -5057,7 +5069,7 @@ static int hns_roce_v2_set_abs_fields(struct ib_qp *ibqp,
50575069
modify_qp_init_to_init(ibqp, attr, context, qpc_mask);
50585070
} else if (cur_state == IB_QPS_INIT && new_state == IB_QPS_RTR) {
50595071
ret = modify_qp_init_to_rtr(ibqp, attr, attr_mask, context,
5060-
qpc_mask);
5072+
qpc_mask, udata);
50615073
} else if (cur_state == IB_QPS_RTR && new_state == IB_QPS_RTS) {
50625074
ret = modify_qp_rtr_to_rts(ibqp, attr, attr_mask, context,
50635075
qpc_mask);
@@ -5262,7 +5274,7 @@ static void v2_set_flushed_fields(struct ib_qp *ibqp,
52625274
static int hns_roce_v2_modify_qp(struct ib_qp *ibqp,
52635275
const struct ib_qp_attr *attr,
52645276
int attr_mask, enum ib_qp_state cur_state,
5265-
enum ib_qp_state new_state)
5277+
enum ib_qp_state new_state, struct ib_udata *udata)
52665278
{
52675279
struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
52685280
struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
@@ -5285,7 +5297,7 @@ static int hns_roce_v2_modify_qp(struct ib_qp *ibqp,
52855297
memset(qpc_mask, 0xff, hr_dev->caps.qpc_sz);
52865298

52875299
ret = hns_roce_v2_set_abs_fields(ibqp, attr, attr_mask, cur_state,
5288-
new_state, context, qpc_mask);
5300+
new_state, context, qpc_mask, udata);
52895301
if (ret)
52905302
goto out;
52915303

@@ -5488,7 +5500,7 @@ static int hns_roce_v2_destroy_qp_common(struct hns_roce_dev *hr_dev,
54885500
if (modify_qp_is_ok(hr_qp)) {
54895501
/* Modify qp to reset before destroying qp */
54905502
ret = hns_roce_v2_modify_qp(&hr_qp->ibqp, NULL, 0,
5491-
hr_qp->state, IB_QPS_RESET);
5503+
hr_qp->state, IB_QPS_RESET, udata);
54925504
if (ret)
54935505
ibdev_err(ibdev,
54945506
"failed to modify QP to RST, ret = %d.\n",

drivers/infiniband/hw/hns/hns_roce_main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,12 @@ static int hns_roce_alloc_ucontext(struct ib_ucontext *uctx,
379379
resp.max_inline_data = hr_dev->caps.max_sq_inline;
380380
}
381381

382+
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RQ_INLINE) {
383+
context->config |= ucmd.config & HNS_ROCE_RQ_INLINE_FLAGS;
384+
if (context->config & HNS_ROCE_RQ_INLINE_FLAGS)
385+
resp.config |= HNS_ROCE_RSP_RQ_INLINE_FLAGS;
386+
}
387+
382388
ret = hns_roce_uar_alloc(hr_dev, &context->uar);
383389
if (ret)
384390
goto error_fail_uar_alloc;

drivers/infiniband/hw/hns/hns_roce_qp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
13461346
goto out;
13471347

13481348
ret = hr_dev->hw->modify_qp(ibqp, attr, attr_mask, cur_state,
1349-
new_state);
1349+
new_state, udata);
13501350

13511351
out:
13521352
mutex_unlock(&hr_qp->mutex);

include/uapi/rdma/hns-abi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ struct hns_roce_ib_create_qp_resp {
8787

8888
enum {
8989
HNS_ROCE_EXSGE_FLAGS = 1 << 0,
90+
HNS_ROCE_RQ_INLINE_FLAGS = 1 << 1,
9091
};
9192

9293
enum {
9394
HNS_ROCE_RSP_EXSGE_FLAGS = 1 << 0,
95+
HNS_ROCE_RSP_RQ_INLINE_FLAGS = 1 << 1,
9496
};
9597

9698
struct hns_roce_ib_alloc_ucontext_resp {

0 commit comments

Comments
 (0)