Skip to content

Commit 0b1fbfb

Browse files
rpearsonhpe-designjgunthorpe
authored andcommitted
RDMA/rxe: Remove IB_SRQ_INIT_MASK
Currently the #define IB_SRQ_INIT_MASK is used to distinguish the rxe_create_srq verb from the rxe_modify_srq verb so that some code can be shared between these two subroutines. This commit splits rxe_srq_chk_attr into two subroutines: rxe_srq_chk_init and rxe_srq_chk_attr which handle the create_srq and modify_srq verbs separately. Link: https://lore.kernel.org/r/20220421014042.26985-2-rpearsonhpe@gmail.com Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 1a7085b commit 0b1fbfb

3 files changed

Lines changed: 74 additions & 57 deletions

File tree

drivers/infiniband/sw/rxe/rxe_loc.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,12 @@ void retransmit_timer(struct timer_list *t);
159159
void rnr_nak_timer(struct timer_list *t);
160160

161161
/* rxe_srq.c */
162-
#define IB_SRQ_INIT_MASK (~IB_SRQ_LIMIT)
163-
164-
int rxe_srq_chk_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
165-
struct ib_srq_attr *attr, enum ib_srq_attr_mask mask);
166-
162+
int rxe_srq_chk_init(struct rxe_dev *rxe, struct ib_srq_init_attr *init);
167163
int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq,
168164
struct ib_srq_init_attr *init, struct ib_udata *udata,
169165
struct rxe_create_srq_resp __user *uresp);
170-
166+
int rxe_srq_chk_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
167+
struct ib_srq_attr *attr, enum ib_srq_attr_mask mask);
171168
int rxe_srq_from_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
172169
struct ib_srq_attr *attr, enum ib_srq_attr_mask mask,
173170
struct rxe_modify_srq_cmd *ucmd, struct ib_udata *udata);

drivers/infiniband/sw/rxe/rxe_srq.c

Lines changed: 69 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,64 +6,34 @@
66

77
#include <linux/vmalloc.h>
88
#include "rxe.h"
9-
#include "rxe_loc.h"
109
#include "rxe_queue.h"
1110

12-
int rxe_srq_chk_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
13-
struct ib_srq_attr *attr, enum ib_srq_attr_mask mask)
11+
int rxe_srq_chk_init(struct rxe_dev *rxe, struct ib_srq_init_attr *init)
1412
{
15-
if (srq && srq->error) {
16-
pr_warn("srq in error state\n");
13+
struct ib_srq_attr *attr = &init->attr;
14+
15+
if (attr->max_wr > rxe->attr.max_srq_wr) {
16+
pr_warn("max_wr(%d) > max_srq_wr(%d)\n",
17+
attr->max_wr, rxe->attr.max_srq_wr);
1718
goto err1;
1819
}
1920

20-
if (mask & IB_SRQ_MAX_WR) {
21-
if (attr->max_wr > rxe->attr.max_srq_wr) {
22-
pr_warn("max_wr(%d) > max_srq_wr(%d)\n",
23-
attr->max_wr, rxe->attr.max_srq_wr);
24-
goto err1;
25-
}
26-
27-
if (attr->max_wr <= 0) {
28-
pr_warn("max_wr(%d) <= 0\n", attr->max_wr);
29-
goto err1;
30-
}
31-
32-
if (srq && srq->limit && (attr->max_wr < srq->limit)) {
33-
pr_warn("max_wr (%d) < srq->limit (%d)\n",
34-
attr->max_wr, srq->limit);
35-
goto err1;
36-
}
37-
38-
if (attr->max_wr < RXE_MIN_SRQ_WR)
39-
attr->max_wr = RXE_MIN_SRQ_WR;
21+
if (attr->max_wr <= 0) {
22+
pr_warn("max_wr(%d) <= 0\n", attr->max_wr);
23+
goto err1;
4024
}
4125

42-
if (mask & IB_SRQ_LIMIT) {
43-
if (attr->srq_limit > rxe->attr.max_srq_wr) {
44-
pr_warn("srq_limit(%d) > max_srq_wr(%d)\n",
45-
attr->srq_limit, rxe->attr.max_srq_wr);
46-
goto err1;
47-
}
26+
if (attr->max_wr < RXE_MIN_SRQ_WR)
27+
attr->max_wr = RXE_MIN_SRQ_WR;
4828

49-
if (srq && (attr->srq_limit > srq->rq.queue->buf->index_mask)) {
50-
pr_warn("srq_limit (%d) > cur limit(%d)\n",
51-
attr->srq_limit,
52-
srq->rq.queue->buf->index_mask);
53-
goto err1;
54-
}
29+
if (attr->max_sge > rxe->attr.max_srq_sge) {
30+
pr_warn("max_sge(%d) > max_srq_sge(%d)\n",
31+
attr->max_sge, rxe->attr.max_srq_sge);
32+
goto err1;
5533
}
5634

57-
if (mask == IB_SRQ_INIT_MASK) {
58-
if (attr->max_sge > rxe->attr.max_srq_sge) {
59-
pr_warn("max_sge(%d) > max_srq_sge(%d)\n",
60-
attr->max_sge, rxe->attr.max_srq_sge);
61-
goto err1;
62-
}
63-
64-
if (attr->max_sge < RXE_MIN_SRQ_SGE)
65-
attr->max_sge = RXE_MIN_SRQ_SGE;
66-
}
35+
if (attr->max_sge < RXE_MIN_SRQ_SGE)
36+
attr->max_sge = RXE_MIN_SRQ_SGE;
6737

6838
return 0;
6939

@@ -93,8 +63,7 @@ int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq,
9363
spin_lock_init(&srq->rq.consumer_lock);
9464

9565
type = QUEUE_TYPE_FROM_CLIENT;
96-
q = rxe_queue_init(rxe, &srq->rq.max_wr,
97-
srq_wqe_size, type);
66+
q = rxe_queue_init(rxe, &srq->rq.max_wr, srq_wqe_size, type);
9867
if (!q) {
9968
pr_warn("unable to allocate queue for srq\n");
10069
return -ENOMEM;
@@ -121,6 +90,57 @@ int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq,
12190
return 0;
12291
}
12392

93+
int rxe_srq_chk_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
94+
struct ib_srq_attr *attr, enum ib_srq_attr_mask mask)
95+
{
96+
if (srq->error) {
97+
pr_warn("srq in error state\n");
98+
goto err1;
99+
}
100+
101+
if (mask & IB_SRQ_MAX_WR) {
102+
if (attr->max_wr > rxe->attr.max_srq_wr) {
103+
pr_warn("max_wr(%d) > max_srq_wr(%d)\n",
104+
attr->max_wr, rxe->attr.max_srq_wr);
105+
goto err1;
106+
}
107+
108+
if (attr->max_wr <= 0) {
109+
pr_warn("max_wr(%d) <= 0\n", attr->max_wr);
110+
goto err1;
111+
}
112+
113+
if (srq->limit && (attr->max_wr < srq->limit)) {
114+
pr_warn("max_wr (%d) < srq->limit (%d)\n",
115+
attr->max_wr, srq->limit);
116+
goto err1;
117+
}
118+
119+
if (attr->max_wr < RXE_MIN_SRQ_WR)
120+
attr->max_wr = RXE_MIN_SRQ_WR;
121+
}
122+
123+
if (mask & IB_SRQ_LIMIT) {
124+
if (attr->srq_limit > rxe->attr.max_srq_wr) {
125+
pr_warn("srq_limit(%d) > max_srq_wr(%d)\n",
126+
attr->srq_limit, rxe->attr.max_srq_wr);
127+
goto err1;
128+
}
129+
130+
if (attr->srq_limit > srq->rq.queue->buf->index_mask) {
131+
pr_warn("srq_limit (%d) > cur limit(%d)\n",
132+
attr->srq_limit,
133+
srq->rq.queue->buf->index_mask);
134+
goto err1;
135+
}
136+
}
137+
138+
return 0;
139+
140+
err1:
141+
return -EINVAL;
142+
}
143+
124144
int rxe_srq_from_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
125145
struct ib_srq_attr *attr, enum ib_srq_attr_mask mask,
126146
struct rxe_modify_srq_cmd *ucmd, struct ib_udata *udata)

drivers/infiniband/sw/rxe/rxe_verbs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#include <linux/dma-mapping.h>
88
#include <net/addrconf.h>
99
#include <rdma/uverbs_ioctl.h>
10+
1011
#include "rxe.h"
11-
#include "rxe_loc.h"
1212
#include "rxe_queue.h"
1313
#include "rxe_hw_counters.h"
1414

@@ -295,7 +295,7 @@ static int rxe_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *init,
295295
uresp = udata->outbuf;
296296
}
297297

298-
err = rxe_srq_chk_attr(rxe, NULL, &init->attr, IB_SRQ_INIT_MASK);
298+
err = rxe_srq_chk_init(rxe, init);
299299
if (err)
300300
goto err1;
301301

0 commit comments

Comments
 (0)