blob: f64589d823aa05bcd57d06b57e67f435992f1b3c [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Ursula Braun5f083182017-01-09 16:55:22 +01002/*
3 * Shared Memory Communications over RDMA (SMC-R) and RoCE
4 *
5 * Connection Data Control (CDC)
6 * handles flow control
7 *
8 * Copyright IBM Corp. 2016
9 *
10 * Author(s): Ursula Braun <ubraun@linux.vnet.ibm.com>
11 */
12
13#include <linux/spinlock.h>
14
15#include "smc.h"
16#include "smc_wr.h"
17#include "smc_cdc.h"
Ursula Braune6727f32017-01-09 16:55:23 +010018#include "smc_tx.h"
Ursula Braun952310c2017-01-09 16:55:24 +010019#include "smc_rx.h"
Ursula Braunb38d7322017-01-09 16:55:25 +010020#include "smc_close.h"
Ursula Braun5f083182017-01-09 16:55:22 +010021
22/********************************** send *************************************/
23
Ursula Braun5f083182017-01-09 16:55:22 +010024/* handler for send/transmission completion of a CDC msg */
25static void smc_cdc_tx_handler(struct smc_wr_tx_pend_priv *pnd_snd,
26 struct smc_link *link,
27 enum ib_wc_status wc_status)
28{
29 struct smc_cdc_tx_pend *cdcpend = (struct smc_cdc_tx_pend *)pnd_snd;
Stefan Rasplbac6de72018-07-23 13:53:09 +020030 struct smc_connection *conn = cdcpend->conn;
Ursula Braun5f083182017-01-09 16:55:22 +010031 struct smc_sock *smc;
32 int diff;
33
Stefan Rasplbac6de72018-07-23 13:53:09 +020034 if (!conn)
Ursula Braun5f083182017-01-09 16:55:22 +010035 /* already dismissed */
36 return;
37
Stefan Rasplbac6de72018-07-23 13:53:09 +020038 smc = container_of(conn, struct smc_sock, conn);
Ursula Braun5f083182017-01-09 16:55:22 +010039 bh_lock_sock(&smc->sk);
40 if (!wc_status) {
Hans Wippel69cb7dc2018-05-18 09:34:10 +020041 diff = smc_curs_diff(cdcpend->conn->sndbuf_desc->len,
Ursula Braun5f083182017-01-09 16:55:22 +010042 &cdcpend->conn->tx_curs_fin,
43 &cdcpend->cursor);
44 /* sndbuf_space is decreased in smc_sendmsg */
45 smp_mb__before_atomic();
46 atomic_add(diff, &cdcpend->conn->sndbuf_space);
Hans Wippel69cb7dc2018-05-18 09:34:10 +020047 /* guarantee 0 <= sndbuf_space <= sndbuf_desc->len */
Ursula Braun5f083182017-01-09 16:55:22 +010048 smp_mb__after_atomic();
Stefan Rasplbac6de72018-07-23 13:53:09 +020049 smc_curs_copy(&conn->tx_curs_fin, &cdcpend->cursor, conn);
Ursula Braun5f083182017-01-09 16:55:22 +010050 }
Ursula Braune6727f32017-01-09 16:55:23 +010051 smc_tx_sndbuf_nonfull(smc);
Ursula Braun5f083182017-01-09 16:55:22 +010052 bh_unlock_sock(&smc->sk);
53}
54
Ursula Braun51957bc2017-09-21 09:17:34 +020055int smc_cdc_get_free_slot(struct smc_connection *conn,
Ursula Braun5f083182017-01-09 16:55:22 +010056 struct smc_wr_buf **wr_buf,
Ursula Braunad6f3172019-02-04 13:44:44 +010057 struct smc_rdma_wr **wr_rdma_buf,
Ursula Braun5f083182017-01-09 16:55:22 +010058 struct smc_cdc_tx_pend **pend)
59{
Karsten Graul387707f2020-04-29 17:10:40 +020060 struct smc_link *link = conn->lnk;
Ursula Braun1a0a04c2018-01-25 11:15:36 +010061 int rc;
Ursula Braun51957bc2017-09-21 09:17:34 +020062
Ursula Braun1a0a04c2018-01-25 11:15:36 +010063 rc = smc_wr_tx_get_free_slot(link, smc_cdc_tx_handler, wr_buf,
Ursula Braunad6f3172019-02-04 13:44:44 +010064 wr_rdma_buf,
Ursula Braun1a0a04c2018-01-25 11:15:36 +010065 (struct smc_wr_tx_pend_priv **)pend);
Ursula Braunb2900982019-10-21 16:13:08 +020066 if (conn->killed)
Ursula Braun1a0a04c2018-01-25 11:15:36 +010067 /* abnormal termination */
68 rc = -EPIPE;
69 return rc;
Ursula Braun5f083182017-01-09 16:55:22 +010070}
71
72static inline void smc_cdc_add_pending_send(struct smc_connection *conn,
73 struct smc_cdc_tx_pend *pend)
74{
75 BUILD_BUG_ON_MSG(
76 sizeof(struct smc_cdc_msg) > SMC_WR_BUF_SIZE,
77 "must increase SMC_WR_BUF_SIZE to at least sizeof(struct smc_cdc_msg)");
78 BUILD_BUG_ON_MSG(
Ursula Braunb9a22dd2018-11-20 16:46:42 +010079 offsetofend(struct smc_cdc_msg, reserved) > SMC_WR_TX_SIZE,
Ursula Braun5f083182017-01-09 16:55:22 +010080 "must adapt SMC_WR_TX_SIZE to sizeof(struct smc_cdc_msg); if not all smc_wr upper layer protocols use the same message size any more, must start to set link->wr_tx_sges[i].length on each individual smc_wr_tx_send()");
81 BUILD_BUG_ON_MSG(
82 sizeof(struct smc_cdc_tx_pend) > SMC_WR_TX_PEND_PRIV_SIZE,
83 "must increase SMC_WR_TX_PEND_PRIV_SIZE to at least sizeof(struct smc_cdc_tx_pend)");
84 pend->conn = conn;
85 pend->cursor = conn->tx_curs_sent;
86 pend->p_cursor = conn->local_tx_ctrl.prod;
87 pend->ctrl_seq = conn->tx_cdc_seq;
88}
89
90int smc_cdc_msg_send(struct smc_connection *conn,
91 struct smc_wr_buf *wr_buf,
92 struct smc_cdc_tx_pend *pend)
93{
Karsten Graul387707f2020-04-29 17:10:40 +020094 struct smc_link *link = conn->lnk;
Ursula Braunb8649ef2019-02-04 13:44:45 +010095 union smc_host_cursor cfed;
Ursula Braun5f083182017-01-09 16:55:22 +010096 int rc;
97
Ursula Braun5f083182017-01-09 16:55:22 +010098 smc_cdc_add_pending_send(conn, pend);
99
100 conn->tx_cdc_seq++;
101 conn->local_tx_ctrl.seqno = conn->tx_cdc_seq;
Ursula Braunccc8ca92019-02-07 14:52:54 +0100102 smc_host_msg_to_cdc((struct smc_cdc_msg *)wr_buf, conn, &cfed);
Ursula Braun5f083182017-01-09 16:55:22 +0100103 rc = smc_wr_tx_send(link, (struct smc_wr_tx_pend_priv *)pend);
Karsten Graul4dff63c2019-02-12 16:29:50 +0100104 if (!rc) {
Ursula Braunb8649ef2019-02-04 13:44:45 +0100105 smc_curs_copy(&conn->rx_curs_confirmed, &cfed, conn);
Karsten Graul4dff63c2019-02-12 16:29:50 +0100106 conn->local_rx_ctrl.prod_flags.cons_curs_upd_req = 0;
107 }
Ursula Braun5f083182017-01-09 16:55:22 +0100108
109 return rc;
110}
111
Hans Wippelbe244f22018-06-28 19:05:10 +0200112static int smcr_cdc_get_slot_and_msg_send(struct smc_connection *conn)
Ursula Braun5f083182017-01-09 16:55:22 +0100113{
114 struct smc_cdc_tx_pend *pend;
115 struct smc_wr_buf *wr_buf;
116 int rc;
117
Ursula Braunad6f3172019-02-04 13:44:44 +0100118 rc = smc_cdc_get_free_slot(conn, &wr_buf, NULL, &pend);
Ursula Braun5f083182017-01-09 16:55:22 +0100119 if (rc)
120 return rc;
121
Karsten Graul2dee25a2019-01-30 18:51:06 +0100122 spin_lock_bh(&conn->send_lock);
123 rc = smc_cdc_msg_send(conn, wr_buf, pend);
124 spin_unlock_bh(&conn->send_lock);
125 return rc;
Ursula Braun5f083182017-01-09 16:55:22 +0100126}
127
Hans Wippelbe244f22018-06-28 19:05:10 +0200128int smc_cdc_get_slot_and_msg_send(struct smc_connection *conn)
129{
130 int rc;
131
Ursula Braun50c6b202019-11-14 13:02:40 +0100132 if (!conn->lgr || (conn->lgr->is_smcd && conn->lgr->peer_shutdown))
133 return -EPIPE;
134
Hans Wippelbe244f22018-06-28 19:05:10 +0200135 if (conn->lgr->is_smcd) {
136 spin_lock_bh(&conn->send_lock);
137 rc = smcd_cdc_msg_send(conn);
138 spin_unlock_bh(&conn->send_lock);
139 } else {
140 rc = smcr_cdc_get_slot_and_msg_send(conn);
141 }
142
143 return rc;
144}
145
Ursula Braun5f083182017-01-09 16:55:22 +0100146static bool smc_cdc_tx_filter(struct smc_wr_tx_pend_priv *tx_pend,
147 unsigned long data)
148{
149 struct smc_connection *conn = (struct smc_connection *)data;
150 struct smc_cdc_tx_pend *cdc_pend =
151 (struct smc_cdc_tx_pend *)tx_pend;
152
153 return cdc_pend->conn == conn;
154}
155
156static void smc_cdc_tx_dismisser(struct smc_wr_tx_pend_priv *tx_pend)
157{
158 struct smc_cdc_tx_pend *cdc_pend =
159 (struct smc_cdc_tx_pend *)tx_pend;
160
161 cdc_pend->conn = NULL;
162}
163
164void smc_cdc_tx_dismiss_slots(struct smc_connection *conn)
165{
Karsten Graul387707f2020-04-29 17:10:40 +0200166 struct smc_link *link = conn->lnk;
Ursula Braun5f083182017-01-09 16:55:22 +0100167
168 smc_wr_tx_dismiss_slots(link, SMC_CDC_MSG_TYPE,
169 smc_cdc_tx_filter, smc_cdc_tx_dismisser,
170 (unsigned long)conn);
171}
172
Hans Wippelbe244f22018-06-28 19:05:10 +0200173/* Send a SMC-D CDC header.
174 * This increments the free space available in our send buffer.
175 * Also update the confirmed receive buffer with what was sent to the peer.
176 */
177int smcd_cdc_msg_send(struct smc_connection *conn)
178{
179 struct smc_sock *smc = container_of(conn, struct smc_sock, conn);
Ursula Braunb9a22dd2018-11-20 16:46:42 +0100180 union smc_host_cursor curs;
Hans Wippelbe244f22018-06-28 19:05:10 +0200181 struct smcd_cdc_msg cdc;
182 int rc, diff;
183
184 memset(&cdc, 0, sizeof(cdc));
185 cdc.common.type = SMC_CDC_MSG_TYPE;
Ursula Braunb9a22dd2018-11-20 16:46:42 +0100186 curs.acurs.counter = atomic64_read(&conn->local_tx_ctrl.prod.acurs);
187 cdc.prod.wrap = curs.wrap;
188 cdc.prod.count = curs.count;
189 curs.acurs.counter = atomic64_read(&conn->local_tx_ctrl.cons.acurs);
190 cdc.cons.wrap = curs.wrap;
191 cdc.cons.count = curs.count;
192 cdc.cons.prod_flags = conn->local_tx_ctrl.prod_flags;
193 cdc.cons.conn_state_flags = conn->local_tx_ctrl.conn_state_flags;
Hans Wippelbe244f22018-06-28 19:05:10 +0200194 rc = smcd_tx_ism_write(conn, &cdc, sizeof(cdc), 0, 1);
195 if (rc)
196 return rc;
Ursula Braunb9a22dd2018-11-20 16:46:42 +0100197 smc_curs_copy(&conn->rx_curs_confirmed, &curs, conn);
Karsten Graul4dff63c2019-02-12 16:29:50 +0100198 conn->local_rx_ctrl.prod_flags.cons_curs_upd_req = 0;
Hans Wippelbe244f22018-06-28 19:05:10 +0200199 /* Calculate transmitted data and increment free send buffer space */
200 diff = smc_curs_diff(conn->sndbuf_desc->len, &conn->tx_curs_fin,
201 &conn->tx_curs_sent);
202 /* increased by confirmed number of bytes */
203 smp_mb__before_atomic();
204 atomic_add(diff, &conn->sndbuf_space);
205 /* guarantee 0 <= sndbuf_space <= sndbuf_desc->len */
206 smp_mb__after_atomic();
Stefan Rasplbac6de72018-07-23 13:53:09 +0200207 smc_curs_copy(&conn->tx_curs_fin, &conn->tx_curs_sent, conn);
Hans Wippelbe244f22018-06-28 19:05:10 +0200208
209 smc_tx_sndbuf_nonfull(smc);
210 return rc;
211}
212
Ursula Braun5f083182017-01-09 16:55:22 +0100213/********************************* receive ***********************************/
214
215static inline bool smc_cdc_before(u16 seq1, u16 seq2)
216{
217 return (s16)(seq1 - seq2) < 0;
218}
219
Stefan Rasplde8474e2018-05-23 16:38:11 +0200220static void smc_cdc_handle_urg_data_arrival(struct smc_sock *smc,
221 int *diff_prod)
222{
223 struct smc_connection *conn = &smc->conn;
224 char *base;
225
226 /* new data included urgent business */
Stefan Rasplbac6de72018-07-23 13:53:09 +0200227 smc_curs_copy(&conn->urg_curs, &conn->local_rx_ctrl.prod, conn);
Stefan Rasplde8474e2018-05-23 16:38:11 +0200228 conn->urg_state = SMC_URG_VALID;
229 if (!sock_flag(&smc->sk, SOCK_URGINLINE))
230 /* we'll skip the urgent byte, so don't account for it */
231 (*diff_prod)--;
Hans Wippelbe244f22018-06-28 19:05:10 +0200232 base = (char *)conn->rmb_desc->cpu_addr + conn->rx_off;
Stefan Rasplde8474e2018-05-23 16:38:11 +0200233 if (conn->urg_curs.count)
234 conn->urg_rx_byte = *(base + conn->urg_curs.count - 1);
235 else
236 conn->urg_rx_byte = *(base + conn->rmb_desc->len - 1);
237 sk_send_sigurg(&smc->sk);
238}
239
Ursula Braun5f083182017-01-09 16:55:22 +0100240static void smc_cdc_msg_recv_action(struct smc_sock *smc,
Ursula Braun5f083182017-01-09 16:55:22 +0100241 struct smc_cdc_msg *cdc)
242{
243 union smc_host_cursor cons_old, prod_old;
244 struct smc_connection *conn = &smc->conn;
245 int diff_cons, diff_prod;
246
Stefan Rasplbac6de72018-07-23 13:53:09 +0200247 smc_curs_copy(&prod_old, &conn->local_rx_ctrl.prod, conn);
248 smc_curs_copy(&cons_old, &conn->local_rx_ctrl.cons, conn);
Ursula Braun5f083182017-01-09 16:55:22 +0100249 smc_cdc_msg_to_host(&conn->local_rx_ctrl, cdc, conn);
250
251 diff_cons = smc_curs_diff(conn->peer_rmbe_size, &cons_old,
252 &conn->local_rx_ctrl.cons);
253 if (diff_cons) {
254 /* peer_rmbe_space is decreased during data transfer with RDMA
255 * write
256 */
257 smp_mb__before_atomic();
258 atomic_add(diff_cons, &conn->peer_rmbe_space);
259 /* guarantee 0 <= peer_rmbe_space <= peer_rmbe_size */
260 smp_mb__after_atomic();
261 }
262
Hans Wippel69cb7dc2018-05-18 09:34:10 +0200263 diff_prod = smc_curs_diff(conn->rmb_desc->len, &prod_old,
Ursula Braun5f083182017-01-09 16:55:22 +0100264 &conn->local_rx_ctrl.prod);
265 if (diff_prod) {
Stefan Rasplde8474e2018-05-23 16:38:11 +0200266 if (conn->local_rx_ctrl.prod_flags.urg_data_present)
267 smc_cdc_handle_urg_data_arrival(smc, &diff_prod);
Ursula Braun5f083182017-01-09 16:55:22 +0100268 /* bytes_to_rcv is decreased in smc_recvmsg */
269 smp_mb__before_atomic();
270 atomic_add(diff_prod, &conn->bytes_to_rcv);
Hans Wippel69cb7dc2018-05-18 09:34:10 +0200271 /* guarantee 0 <= bytes_to_rcv <= rmb_desc->len */
Ursula Braun5f083182017-01-09 16:55:22 +0100272 smp_mb__after_atomic();
Ursula Braun952310c2017-01-09 16:55:24 +0100273 smc->sk.sk_data_ready(&smc->sk);
Stefan Rasplde8474e2018-05-23 16:38:11 +0200274 } else {
Karsten Graulcf0cfe52019-02-12 16:29:53 +0100275 if (conn->local_rx_ctrl.prod_flags.write_blocked)
276 smc->sk.sk_data_ready(&smc->sk);
277 if (conn->local_rx_ctrl.prod_flags.urg_data_pending)
278 conn->urg_state = SMC_URG_NOTYET;
Ursula Braun5f083182017-01-09 16:55:22 +0100279 }
280
Ursula Braun51f1de72018-01-26 09:28:48 +0100281 /* trigger sndbuf consumer: RDMA write into peer RMBE and CDC */
Karsten Graulcf0cfe52019-02-12 16:29:53 +0100282 if ((diff_cons && smc_tx_prepared_sends(conn)) ||
283 conn->local_rx_ctrl.prod_flags.cons_curs_upd_req ||
284 conn->local_rx_ctrl.prod_flags.urg_data_pending)
Ursula Braun51f1de72018-01-26 09:28:48 +0100285 smc_tx_sndbuf_nonempty(conn);
Karsten Graulcf0cfe52019-02-12 16:29:53 +0100286
Stefan Rasplde8474e2018-05-23 16:38:11 +0200287 if (diff_cons && conn->urg_tx_pend &&
288 atomic_read(&conn->peer_rmbe_space) == conn->peer_rmbe_size) {
289 /* urg data confirmed by peer, indicate we're ready for more */
290 conn->urg_tx_pend = false;
291 smc->sk.sk_write_space(&smc->sk);
292 }
Ursula Braun51f1de72018-01-26 09:28:48 +0100293
Ursula Braunb38d7322017-01-09 16:55:25 +0100294 if (conn->local_rx_ctrl.conn_state_flags.peer_conn_abort) {
Ursula Braun5f083182017-01-09 16:55:22 +0100295 smc->sk.sk_err = ECONNRESET;
Ursula Braunb38d7322017-01-09 16:55:25 +0100296 conn->local_tx_ctrl.conn_state_flags.peer_conn_abort = 1;
297 }
Ursula Braun46c28db2017-04-10 14:58:01 +0200298 if (smc_cdc_rxed_any_close_or_senddone(conn)) {
299 smc->sk.sk_shutdown |= RCV_SHUTDOWN;
300 if (smc->clcsock && smc->clcsock->sk)
301 smc->clcsock->sk->sk_shutdown |= RCV_SHUTDOWN;
302 sock_set_flag(&smc->sk, SOCK_DONE);
Ursula Braun51f1de72018-01-26 09:28:48 +0100303 sock_hold(&smc->sk); /* sock_put in close_work */
304 if (!schedule_work(&conn->close_work))
305 sock_put(&smc->sk);
Ursula Braunb38d7322017-01-09 16:55:25 +0100306 }
Ursula Braun5f083182017-01-09 16:55:22 +0100307}
308
309/* called under tasklet context */
Hans Wippeld7b0e372018-05-18 09:34:15 +0200310static void smc_cdc_msg_recv(struct smc_sock *smc, struct smc_cdc_msg *cdc)
Ursula Braun5f083182017-01-09 16:55:22 +0100311{
Ursula Braun5f083182017-01-09 16:55:22 +0100312 sock_hold(&smc->sk);
Ursula Braun5f083182017-01-09 16:55:22 +0100313 bh_lock_sock(&smc->sk);
Hans Wippeld7b0e372018-05-18 09:34:15 +0200314 smc_cdc_msg_recv_action(smc, cdc);
Ursula Braun5f083182017-01-09 16:55:22 +0100315 bh_unlock_sock(&smc->sk);
316 sock_put(&smc->sk); /* no free sk in softirq-context */
317}
318
Hans Wippelbe244f22018-06-28 19:05:10 +0200319/* Schedule a tasklet for this connection. Triggered from the ISM device IRQ
320 * handler to indicate update in the DMBE.
321 *
322 * Context:
323 * - tasklet context
324 */
325static void smcd_cdc_rx_tsklet(unsigned long data)
326{
327 struct smc_connection *conn = (struct smc_connection *)data;
Ursula Braunb9a22dd2018-11-20 16:46:42 +0100328 struct smcd_cdc_msg *data_cdc;
Hans Wippelbe244f22018-06-28 19:05:10 +0200329 struct smcd_cdc_msg cdc;
330 struct smc_sock *smc;
331
Ursula Braunb2900982019-10-21 16:13:08 +0200332 if (!conn || conn->killed)
Hans Wippelbe244f22018-06-28 19:05:10 +0200333 return;
334
Ursula Braunb9a22dd2018-11-20 16:46:42 +0100335 data_cdc = (struct smcd_cdc_msg *)conn->rmb_desc->cpu_addr;
336 smcd_curs_copy(&cdc.prod, &data_cdc->prod, conn);
337 smcd_curs_copy(&cdc.cons, &data_cdc->cons, conn);
Hans Wippelbe244f22018-06-28 19:05:10 +0200338 smc = container_of(conn, struct smc_sock, conn);
339 smc_cdc_msg_recv(smc, (struct smc_cdc_msg *)&cdc);
340}
341
342/* Initialize receive tasklet. Called from ISM device IRQ handler to start
343 * receiver side.
344 */
345void smcd_cdc_rx_init(struct smc_connection *conn)
346{
347 tasklet_init(&conn->rx_tsklet, smcd_cdc_rx_tsklet, (unsigned long)conn);
348}
349
Ursula Braun5f083182017-01-09 16:55:22 +0100350/***************************** init, exit, misc ******************************/
351
352static void smc_cdc_rx_handler(struct ib_wc *wc, void *buf)
353{
354 struct smc_link *link = (struct smc_link *)wc->qp->qp_context;
355 struct smc_cdc_msg *cdc = buf;
Hans Wippeld7b0e372018-05-18 09:34:15 +0200356 struct smc_connection *conn;
357 struct smc_link_group *lgr;
358 struct smc_sock *smc;
Ursula Braun5f083182017-01-09 16:55:22 +0100359
360 if (wc->byte_len < offsetof(struct smc_cdc_msg, reserved))
361 return; /* short message */
Karsten Graulcbba07a2018-02-28 12:44:07 +0100362 if (cdc->len != SMC_WR_TX_SIZE)
Ursula Braun5f083182017-01-09 16:55:22 +0100363 return; /* invalid message */
Hans Wippeld7b0e372018-05-18 09:34:15 +0200364
365 /* lookup connection */
Stefan Raspl00e5fb22018-07-23 13:53:10 +0200366 lgr = smc_get_lgr(link);
Hans Wippeld7b0e372018-05-18 09:34:15 +0200367 read_lock_bh(&lgr->conns_lock);
368 conn = smc_lgr_find_conn(ntohl(cdc->token), lgr);
369 read_unlock_bh(&lgr->conns_lock);
370 if (!conn)
371 return;
372 smc = container_of(conn, struct smc_sock, conn);
373
374 if (!cdc->prod_flags.failover_validation) {
375 if (smc_cdc_before(ntohs(cdc->seqno),
376 conn->local_rx_ctrl.seqno))
377 /* received seqno is old */
378 return;
379 }
380 smc_cdc_msg_recv(smc, cdc);
Ursula Braun5f083182017-01-09 16:55:22 +0100381}
382
383static struct smc_wr_rx_handler smc_cdc_rx_handlers[] = {
384 {
385 .handler = smc_cdc_rx_handler,
386 .type = SMC_CDC_MSG_TYPE
387 },
388 {
389 .handler = NULL,
390 }
391};
392
393int __init smc_cdc_init(void)
394{
395 struct smc_wr_rx_handler *handler;
396 int rc = 0;
397
398 for (handler = smc_cdc_rx_handlers; handler->handler; handler++) {
399 INIT_HLIST_NODE(&handler->list);
400 rc = smc_wr_rx_register_handler(handler);
401 if (rc)
402 break;
403 }
404 return rc;
405}