Skip to content

Commit 3254887

Browse files
Wenpeng Liangjgunthorpe
authored andcommitted
RDMA/hns: Add support for XRC on HIP09
The HIP09 supports XRC transport service, it greatly saves the number of QPs required to connect all processes in a large cluster. Link: https://lore.kernel.org/r/1614826558-35423-1-git-send-email-liweihang@huawei.com Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com> Signed-off-by: Weihang Li <liweihang@huawei.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent c33d516 commit 3254887

9 files changed

Lines changed: 258 additions & 70 deletions

File tree

‎drivers/infiniband/hw/hns/hns_roce_alloc.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ int hns_roce_get_umem_bufs(struct hns_roce_dev *hr_dev, dma_addr_t *bufs,
304304

305305
void hns_roce_cleanup_bitmap(struct hns_roce_dev *hr_dev)
306306
{
307+
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_XRC)
308+
hns_roce_cleanup_xrcd_table(hr_dev);
309+
307310
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SRQ)
308311
hns_roce_cleanup_srq_table(hr_dev);
309312
hns_roce_cleanup_qp_table(hr_dev);

‎drivers/infiniband/hw/hns/hns_roce_device.h‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ enum {
137137
SERV_TYPE_UC,
138138
SERV_TYPE_RD,
139139
SERV_TYPE_UD,
140+
SERV_TYPE_XRC = 5,
140141
};
141142

142143
enum hns_roce_qp_state {
@@ -168,6 +169,8 @@ enum hns_roce_event {
168169
HNS_ROCE_EVENT_TYPE_DB_OVERFLOW = 0x12,
169170
HNS_ROCE_EVENT_TYPE_MB = 0x13,
170171
HNS_ROCE_EVENT_TYPE_FLR = 0x15,
172+
HNS_ROCE_EVENT_TYPE_XRCD_VIOLATION = 0x16,
173+
HNS_ROCE_EVENT_TYPE_INVALID_XRCETH = 0x17,
171174
};
172175

173176
#define HNS_ROCE_CAP_FLAGS_EX_SHIFT 12
@@ -179,6 +182,7 @@ enum {
179182
HNS_ROCE_CAP_FLAG_RECORD_DB = BIT(3),
180183
HNS_ROCE_CAP_FLAG_SQ_RECORD_DB = BIT(4),
181184
HNS_ROCE_CAP_FLAG_SRQ = BIT(5),
185+
HNS_ROCE_CAP_FLAG_XRC = BIT(6),
182186
HNS_ROCE_CAP_FLAG_MW = BIT(7),
183187
HNS_ROCE_CAP_FLAG_FRMR = BIT(8),
184188
HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL = BIT(9),
@@ -244,6 +248,11 @@ struct hns_roce_pd {
244248
unsigned long pdn;
245249
};
246250

251+
struct hns_roce_xrcd {
252+
struct ib_xrcd ibxrcd;
253+
u32 xrcdn;
254+
};
255+
247256
struct hns_roce_bitmap {
248257
/* Bitmap Traversal last a bit which is 1 */
249258
unsigned long last;
@@ -467,6 +476,7 @@ struct hns_roce_srq {
467476
u32 rsv_sge;
468477
int wqe_shift;
469478
u32 cqn;
479+
u32 xrcdn;
470480
void __iomem *db_reg_l;
471481

472482
atomic_t refcount;
@@ -640,6 +650,8 @@ struct hns_roce_qp {
640650
enum hns_roce_event event_type);
641651
unsigned long qpn;
642652

653+
u32 xrcdn;
654+
643655
atomic_t refcount;
644656
struct completion free;
645657

@@ -766,6 +778,8 @@ struct hns_roce_caps {
766778
int reserved_uars;
767779
int num_pds;
768780
int reserved_pds;
781+
u32 num_xrcds;
782+
u32 reserved_xrcds;
769783
u32 mtt_entry_sz;
770784
u32 cqe_sz;
771785
u32 page_size_cap;
@@ -963,6 +977,7 @@ struct hns_roce_dev {
963977

964978
struct hns_roce_cmdq cmd;
965979
struct hns_roce_bitmap pd_bitmap;
980+
struct hns_roce_bitmap xrcd_bitmap;
966981
struct hns_roce_uar_table uar_table;
967982
struct hns_roce_mr_table mr_table;
968983
struct hns_roce_cq_table cq_table;
@@ -1004,6 +1019,11 @@ static inline struct hns_roce_pd *to_hr_pd(struct ib_pd *ibpd)
10041019
return container_of(ibpd, struct hns_roce_pd, ibpd);
10051020
}
10061021

1022+
static inline struct hns_roce_xrcd *to_hr_xrcd(struct ib_xrcd *ibxrcd)
1023+
{
1024+
return container_of(ibxrcd, struct hns_roce_xrcd, ibxrcd);
1025+
}
1026+
10071027
static inline struct hns_roce_ah *to_hr_ah(struct ib_ah *ibah)
10081028
{
10091029
return container_of(ibah, struct hns_roce_ah, ibah);
@@ -1136,13 +1156,15 @@ int hns_roce_init_mr_table(struct hns_roce_dev *hr_dev);
11361156
void hns_roce_init_cq_table(struct hns_roce_dev *hr_dev);
11371157
int hns_roce_init_qp_table(struct hns_roce_dev *hr_dev);
11381158
int hns_roce_init_srq_table(struct hns_roce_dev *hr_dev);
1159+
int hns_roce_init_xrcd_table(struct hns_roce_dev *hr_dev);
11391160

11401161
void hns_roce_cleanup_pd_table(struct hns_roce_dev *hr_dev);
11411162
void hns_roce_cleanup_mr_table(struct hns_roce_dev *hr_dev);
11421163
void hns_roce_cleanup_eq_table(struct hns_roce_dev *hr_dev);
11431164
void hns_roce_cleanup_cq_table(struct hns_roce_dev *hr_dev);
11441165
void hns_roce_cleanup_qp_table(struct hns_roce_dev *hr_dev);
11451166
void hns_roce_cleanup_srq_table(struct hns_roce_dev *hr_dev);
1167+
void hns_roce_cleanup_xrcd_table(struct hns_roce_dev *hr_dev);
11461168

11471169
int hns_roce_bitmap_alloc(struct hns_roce_bitmap *bitmap, unsigned long *obj);
11481170
void hns_roce_bitmap_free(struct hns_roce_bitmap *bitmap, unsigned long obj,
@@ -1207,6 +1229,9 @@ int hns_roce_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr,
12071229
struct ib_udata *udata);
12081230
int hns_roce_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata);
12091231

1232+
int hns_roce_alloc_xrcd(struct ib_xrcd *ib_xrcd, struct ib_udata *udata);
1233+
int hns_roce_dealloc_xrcd(struct ib_xrcd *ib_xrcd, struct ib_udata *udata);
1234+
12101235
struct ib_qp *hns_roce_create_qp(struct ib_pd *ib_pd,
12111236
struct ib_qp_init_attr *init_attr,
12121237
struct ib_udata *udata);

0 commit comments

Comments
 (0)