Skip to content

Commit c7bcb13

Browse files
oulijunjgunthorpe
authored andcommitted
RDMA/hns: Add SRQ support for hip08 kernel mode
This patch implements the SRQ(Share Receive Queue) verbs and update the poll cq verbs to deal with SRQ complentions. Signed-off-by: Lijun Ou <oulijun@huawei.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent 5c1f167 commit c7bcb13

File tree

10 files changed

+1098
-52
lines changed

10 files changed

+1098
-52
lines changed

drivers/infiniband/hw/hns/hns_roce_cmd.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ enum {
120120
HNS_ROCE_CMD_SQD2RTS_QP = 0x20,
121121
HNS_ROCE_CMD_2RST_QP = 0x21,
122122
HNS_ROCE_CMD_QUERY_QP = 0x22,
123+
HNS_ROCE_CMD_SW2HW_SRQ = 0x70,
124+
HNS_ROCE_CMD_MODIFY_SRQC = 0x72,
125+
HNS_ROCE_CMD_QUERY_SRQC = 0x73,
126+
HNS_ROCE_CMD_HW2SW_SRQ = 0x74,
123127
};
124128

125129
int hns_roce_cmd_mbox(struct hns_roce_dev *hr_dev, u64 in_param, u64 out_param,

drivers/infiniband/hw/hns/hns_roce_device.h

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@
111111
#define PAGES_SHIFT_24 24
112112
#define PAGES_SHIFT_32 32
113113

114+
#define HNS_ROCE_IDX_QUE_ENTRY_SZ 4
115+
#define SRQ_DB_REG 0x230
116+
114117
enum {
115118
HNS_ROCE_SUPPORT_RQ_RECORD_DB = 1 << 0,
116119
HNS_ROCE_SUPPORT_SQ_RECORD_DB = 1 << 1,
@@ -436,9 +439,37 @@ struct hns_roce_cq {
436439
struct completion free;
437440
};
438441

442+
struct hns_roce_idx_que {
443+
struct hns_roce_buf idx_buf;
444+
int entry_sz;
445+
u32 buf_size;
446+
struct ib_umem *umem;
447+
struct hns_roce_mtt mtt;
448+
u64 *bitmap;
449+
};
450+
439451
struct hns_roce_srq {
440452
struct ib_srq ibsrq;
441-
int srqn;
453+
void (*event)(struct hns_roce_srq *srq, enum hns_roce_event event);
454+
unsigned long srqn;
455+
int max;
456+
int max_gs;
457+
int wqe_shift;
458+
void __iomem *db_reg_l;
459+
460+
atomic_t refcount;
461+
struct completion free;
462+
463+
struct hns_roce_buf buf;
464+
u64 *wrid;
465+
struct ib_umem *umem;
466+
struct hns_roce_mtt mtt;
467+
struct hns_roce_idx_que idx_que;
468+
spinlock_t lock;
469+
int head;
470+
int tail;
471+
u16 wqe_ctr;
472+
struct mutex mutex;
442473
};
443474

444475
struct hns_roce_uar_table {
@@ -761,6 +792,12 @@ struct hns_roce_caps {
761792
u32 cqe_ba_pg_sz;
762793
u32 cqe_buf_pg_sz;
763794
u32 cqe_hop_num;
795+
u32 srqwqe_ba_pg_sz;
796+
u32 srqwqe_buf_pg_sz;
797+
u32 srqwqe_hop_num;
798+
u32 idx_ba_pg_sz;
799+
u32 idx_buf_pg_sz;
800+
u32 idx_hop_num;
764801
u32 eqe_ba_pg_sz;
765802
u32 eqe_buf_pg_sz;
766803
u32 eqe_hop_num;
@@ -829,6 +866,17 @@ struct hns_roce_hw {
829866
int (*modify_cq)(struct ib_cq *cq, u16 cq_count, u16 cq_period);
830867
int (*init_eq)(struct hns_roce_dev *hr_dev);
831868
void (*cleanup_eq)(struct hns_roce_dev *hr_dev);
869+
void (*write_srqc)(struct hns_roce_dev *hr_dev,
870+
struct hns_roce_srq *srq, u32 pdn, u16 xrcd, u32 cqn,
871+
void *mb_buf, u64 *mtts_wqe, u64 *mtts_idx,
872+
dma_addr_t dma_handle_wqe,
873+
dma_addr_t dma_handle_idx);
874+
int (*modify_srq)(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr,
875+
enum ib_srq_attr_mask srq_attr_mask,
876+
struct ib_udata *udata);
877+
int (*query_srq)(struct ib_srq *ibsrq, struct ib_srq_attr *attr);
878+
int (*post_srq_recv)(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
879+
const struct ib_recv_wr **bad_wr);
832880
};
833881

834882
struct hns_roce_dev {
@@ -1038,6 +1086,14 @@ int hns_roce_buf_alloc(struct hns_roce_dev *hr_dev, u32 size, u32 max_direct,
10381086
int hns_roce_ib_umem_write_mtt(struct hns_roce_dev *hr_dev,
10391087
struct hns_roce_mtt *mtt, struct ib_umem *umem);
10401088

1089+
struct ib_srq *hns_roce_create_srq(struct ib_pd *pd,
1090+
struct ib_srq_init_attr *srq_init_attr,
1091+
struct ib_udata *udata);
1092+
int hns_roce_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr,
1093+
enum ib_srq_attr_mask srq_attr_mask,
1094+
struct ib_udata *udata);
1095+
int hns_roce_destroy_srq(struct ib_srq *ibsrq);
1096+
10411097
struct ib_qp *hns_roce_create_qp(struct ib_pd *ib_pd,
10421098
struct ib_qp_init_attr *init_attr,
10431099
struct ib_udata *udata);

drivers/infiniband/hw/hns/hns_roce_hem.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ bool hns_roce_check_whether_mhop(struct hns_roce_dev *hr_dev, u32 type)
4646
(hr_dev->caps.cqc_hop_num && type == HEM_TYPE_CQC) ||
4747
(hr_dev->caps.srqc_hop_num && type == HEM_TYPE_SRQC) ||
4848
(hr_dev->caps.cqe_hop_num && type == HEM_TYPE_CQE) ||
49-
(hr_dev->caps.mtt_hop_num && type == HEM_TYPE_MTT))
49+
(hr_dev->caps.mtt_hop_num && type == HEM_TYPE_MTT) ||
50+
(hr_dev->caps.srqwqe_hop_num && type == HEM_TYPE_SRQWQE) ||
51+
(hr_dev->caps.idx_hop_num && type == HEM_TYPE_IDX))
5052
return true;
5153

5254
return false;
@@ -147,6 +149,22 @@ int hns_roce_calc_hem_mhop(struct hns_roce_dev *hr_dev,
147149
mhop->ba_l0_num = mhop->bt_chunk_size / 8;
148150
mhop->hop_num = hr_dev->caps.cqe_hop_num;
149151
break;
152+
case HEM_TYPE_SRQWQE:
153+
mhop->buf_chunk_size = 1 << (hr_dev->caps.srqwqe_buf_pg_sz
154+
+ PAGE_SHIFT);
155+
mhop->bt_chunk_size = 1 << (hr_dev->caps.srqwqe_ba_pg_sz
156+
+ PAGE_SHIFT);
157+
mhop->ba_l0_num = mhop->bt_chunk_size / 8;
158+
mhop->hop_num = hr_dev->caps.srqwqe_hop_num;
159+
break;
160+
case HEM_TYPE_IDX:
161+
mhop->buf_chunk_size = 1 << (hr_dev->caps.idx_buf_pg_sz
162+
+ PAGE_SHIFT);
163+
mhop->bt_chunk_size = 1 << (hr_dev->caps.idx_ba_pg_sz
164+
+ PAGE_SHIFT);
165+
mhop->ba_l0_num = mhop->bt_chunk_size / 8;
166+
mhop->hop_num = hr_dev->caps.idx_hop_num;
167+
break;
150168
default:
151169
dev_err(dev, "Table %d not support multi-hop addressing!\n",
152170
table->type);
@@ -906,6 +924,18 @@ int hns_roce_init_hem_table(struct hns_roce_dev *hr_dev,
906924
bt_chunk_size = buf_chunk_size;
907925
hop_num = hr_dev->caps.cqe_hop_num;
908926
break;
927+
case HEM_TYPE_SRQWQE:
928+
buf_chunk_size = 1 << (hr_dev->caps.srqwqe_ba_pg_sz
929+
+ PAGE_SHIFT);
930+
bt_chunk_size = buf_chunk_size;
931+
hop_num = hr_dev->caps.srqwqe_hop_num;
932+
break;
933+
case HEM_TYPE_IDX:
934+
buf_chunk_size = 1 << (hr_dev->caps.idx_ba_pg_sz
935+
+ PAGE_SHIFT);
936+
bt_chunk_size = buf_chunk_size;
937+
hop_num = hr_dev->caps.idx_hop_num;
938+
break;
909939
default:
910940
dev_err(dev,
911941
"Table %d not support to init hem table here!\n",

0 commit comments

Comments
 (0)