Skip to content

Commit 81fce62

Browse files
oulijunjgunthorpe
authored andcommitted
RDMA/hns: Add SRQ asynchronous event support
This patch implements the process flow of SRQ asynchronous event. Signed-off-by: Lijun Ou <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent c7bcb13 commit 81fce62

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

drivers/infiniband/hw/hns/hns_roce_device.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,12 @@ struct hns_roce_aeqe {
646646
u32 rsv1;
647647
} qp_event;
648648

649+
struct {
650+
__le32 srq;
651+
u32 rsv0;
652+
u32 rsv1;
653+
} srq_event;
654+
649655
struct {
650656
__le32 cq;
651657
u32 rsv0;
@@ -1135,6 +1141,7 @@ void hns_roce_free_db(struct hns_roce_dev *hr_dev, struct hns_roce_db *db);
11351141
void hns_roce_cq_completion(struct hns_roce_dev *hr_dev, u32 cqn);
11361142
void hns_roce_cq_event(struct hns_roce_dev *hr_dev, u32 cqn, int event_type);
11371143
void hns_roce_qp_event(struct hns_roce_dev *hr_dev, u32 qpn, int event_type);
1144+
void hns_roce_srq_event(struct hns_roce_dev *hr_dev, u32 srqn, int event_type);
11381145
int hns_get_gid_index(struct hns_roce_dev *hr_dev, u8 port, int gid_index);
11391146
int hns_roce_init(struct hns_roce_dev *hr_dev);
11401147
void hns_roce_exit(struct hns_roce_dev *hr_dev);

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4459,6 +4459,7 @@ static int hns_roce_v2_aeq_int(struct hns_roce_dev *hr_dev,
44594459
int aeqe_found = 0;
44604460
int event_type;
44614461
int sub_type;
4462+
u32 srqn;
44624463
u32 qpn;
44634464
u32 cqn;
44644465

@@ -4481,20 +4482,24 @@ static int hns_roce_v2_aeq_int(struct hns_roce_dev *hr_dev,
44814482
cqn = roce_get_field(aeqe->event.cq_event.cq,
44824483
HNS_ROCE_V2_AEQE_EVENT_QUEUE_NUM_M,
44834484
HNS_ROCE_V2_AEQE_EVENT_QUEUE_NUM_S);
4485+
srqn = roce_get_field(aeqe->event.srq_event.srq,
4486+
HNS_ROCE_V2_AEQE_EVENT_QUEUE_NUM_M,
4487+
HNS_ROCE_V2_AEQE_EVENT_QUEUE_NUM_S);
44844488

44854489
switch (event_type) {
44864490
case HNS_ROCE_EVENT_TYPE_PATH_MIG:
44874491
case HNS_ROCE_EVENT_TYPE_PATH_MIG_FAILED:
44884492
case HNS_ROCE_EVENT_TYPE_COMM_EST:
44894493
case HNS_ROCE_EVENT_TYPE_SQ_DRAINED:
44904494
case HNS_ROCE_EVENT_TYPE_WQ_CATAS_ERROR:
4495+
case HNS_ROCE_EVENT_TYPE_SRQ_LAST_WQE_REACH:
44914496
case HNS_ROCE_EVENT_TYPE_INV_REQ_LOCAL_WQ_ERROR:
44924497
case HNS_ROCE_EVENT_TYPE_LOCAL_WQ_ACCESS_ERROR:
44934498
hns_roce_qp_event(hr_dev, qpn, event_type);
44944499
break;
44954500
case HNS_ROCE_EVENT_TYPE_SRQ_LIMIT_REACH:
4496-
case HNS_ROCE_EVENT_TYPE_SRQ_LAST_WQE_REACH:
44974501
case HNS_ROCE_EVENT_TYPE_SRQ_CATAS_ERROR:
4502+
hns_roce_srq_event(hr_dev, srqn, event_type);
44984503
break;
44994504
case HNS_ROCE_EVENT_TYPE_CQ_ACCESS_ERROR:
45004505
case HNS_ROCE_EVENT_TYPE_CQ_OVERFLOW:

drivers/infiniband/hw/hns/hns_roce_srq.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@
99
#include "hns_roce_cmd.h"
1010
#include "hns_roce_hem.h"
1111

12+
void hns_roce_srq_event(struct hns_roce_dev *hr_dev, u32 srqn, int event_type)
13+
{
14+
struct hns_roce_srq_table *srq_table = &hr_dev->srq_table;
15+
struct hns_roce_srq *srq;
16+
17+
xa_lock(&srq_table->xa);
18+
srq = xa_load(&srq_table->xa, srqn & (hr_dev->caps.num_srqs - 1));
19+
if (srq)
20+
atomic_inc(&srq->refcount);
21+
xa_unlock(&srq_table->xa);
22+
23+
if (!srq) {
24+
dev_warn(hr_dev->dev, "Async event for bogus SRQ %08x\n", srqn);
25+
return;
26+
}
27+
28+
srq->event(srq, event_type);
29+
30+
if (atomic_dec_and_test(&srq->refcount))
31+
complete(&srq->free);
32+
}
33+
EXPORT_SYMBOL_GPL(hns_roce_srq_event);
34+
1235
static void hns_roce_ib_srq_event(struct hns_roce_srq *srq,
1336
enum hns_roce_event event_type)
1437
{

0 commit comments

Comments
 (0)