Skip to content

Commit 904a52d

Browse files
Guoqing Jianggregkh
authored andcommitted
RDMA/rtrs: Introduce rtrs_post_send
[ Upstream commit e6ab8cf ] Since the three functions share the similar logic, let's introduce one common function for it. Link: https://lore.kernel.org/r/20201023074353.21946-12-jinpu.wang@cloud.ionos.com Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com> Signed-off-by: Jack Wang <jinpu.wang@cloud.ionos.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 9e97c21 commit 904a52d

1 file changed

Lines changed: 19 additions & 33 deletions

File tree

  • drivers/infiniband/ulp/rtrs

‎drivers/infiniband/ulp/rtrs/rtrs.c‎

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,22 @@ int rtrs_post_recv_empty(struct rtrs_con *con, struct ib_cqe *cqe)
104104
}
105105
EXPORT_SYMBOL_GPL(rtrs_post_recv_empty);
106106

107+
static int rtrs_post_send(struct ib_qp *qp, struct ib_send_wr *head,
108+
struct ib_send_wr *wr)
109+
{
110+
if (head) {
111+
struct ib_send_wr *tail = head;
112+
113+
while (tail->next)
114+
tail = tail->next;
115+
tail->next = wr;
116+
} else {
117+
head = wr;
118+
}
119+
120+
return ib_post_send(qp, head, NULL);
121+
}
122+
107123
int rtrs_iu_post_send(struct rtrs_con *con, struct rtrs_iu *iu, size_t size,
108124
struct ib_send_wr *head)
109125
{
@@ -126,17 +142,7 @@ int rtrs_iu_post_send(struct rtrs_con *con, struct rtrs_iu *iu, size_t size,
126142
.send_flags = IB_SEND_SIGNALED,
127143
};
128144

129-
if (head) {
130-
struct ib_send_wr *tail = head;
131-
132-
while (tail->next)
133-
tail = tail->next;
134-
tail->next = &wr;
135-
} else {
136-
head = &wr;
137-
}
138-
139-
return ib_post_send(con->qp, head, NULL);
145+
return rtrs_post_send(con->qp, head, &wr);
140146
}
141147
EXPORT_SYMBOL_GPL(rtrs_iu_post_send);
142148

@@ -168,17 +174,7 @@ int rtrs_iu_post_rdma_write_imm(struct rtrs_con *con, struct rtrs_iu *iu,
168174
if (WARN_ON(sge[i].length == 0))
169175
return -EINVAL;
170176

171-
if (head) {
172-
struct ib_send_wr *tail = head;
173-
174-
while (tail->next)
175-
tail = tail->next;
176-
tail->next = &wr.wr;
177-
} else {
178-
head = &wr.wr;
179-
}
180-
181-
return ib_post_send(con->qp, head, NULL);
177+
return rtrs_post_send(con->qp, head, &wr.wr);
182178
}
183179
EXPORT_SYMBOL_GPL(rtrs_iu_post_rdma_write_imm);
184180

@@ -195,17 +191,7 @@ int rtrs_post_rdma_write_imm_empty(struct rtrs_con *con, struct ib_cqe *cqe,
195191
.ex.imm_data = cpu_to_be32(imm_data),
196192
};
197193

198-
if (head) {
199-
struct ib_send_wr *tail = head;
200-
201-
while (tail->next)
202-
tail = tail->next;
203-
tail->next = &wr;
204-
} else {
205-
head = &wr;
206-
}
207-
208-
return ib_post_send(con->qp, head, NULL);
194+
return rtrs_post_send(con->qp, head, &wr);
209195
}
210196
EXPORT_SYMBOL_GPL(rtrs_post_rdma_write_imm_empty);
211197

0 commit comments

Comments
 (0)