blob: c5e33296e55c3789698fc421d5d0e2d8cac55f57 [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);
Karsten Graulf0ec4f12020-05-04 14:18:37 +020050 smc_curs_copy(&conn->local_tx_ctrl_fin, &cdcpend->p_cursor,
51 conn);
52 conn->tx_cdc_seq_fin = cdcpend->ctrl_seq;
Ursula Braun5f083182017-01-09 16:55:22 +010053 }
Ursula Braune6727f32017-01-09 16:55:23 +010054 smc_tx_sndbuf_nonfull(smc);
Ursula Braun5f083182017-01-09 16:55:22 +010055 bh_unlock_sock(&smc->sk);
56}
57
Ursula Braun51957bc2017-09-21 09:17:34 +020058int smc_cdc_get_free_slot(struct smc_connection *conn,
Ursula Braun5f083182017-01-09 16:55:22 +010059 struct smc_wr_buf **wr_buf,
Ursula Braunad6f3172019-02-04 13:44:44 +010060 struct smc_rdma_wr **wr_rdma_buf,
Ursula Braun5f083182017-01-09 16:55:22 +010061 struct smc_cdc_tx_pend **pend)
62{
Karsten Graul387707f2020-04-29 17:10:40 +020063 struct smc_link *link = conn->lnk;
Ursula Braun1a0a04c2018-01-25 11:15:36 +010064 int rc;
Ursula Braun51957bc2017-09-21 09:17:34 +020065
Ursula Braun1a0a04c2018-01-25 11:15:36 +010066 rc = smc_wr_tx_get_free_slot(link, smc_cdc_tx_handler, wr_buf,
Ursula Braunad6f3172019-02-04 13:44:44 +010067 wr_rdma_buf,
Ursula Braun1a0a04c2018-01-25 11:15:36 +010068 (struct smc_wr_tx_pend_priv **)pend);
Ursula Braunb2900982019-10-21 16:13:08 +020069 if (conn->killed)
Ursula Braun1a0a04c2018-01-25 11:15:36 +010070 /* abnormal termination */
71 rc = -EPIPE;
72 return rc;
Ursula Braun5f083182017-01-09 16:55:22 +010073}
74
75static inline void smc_cdc_add_pending_send(struct smc_connection *conn,
76 struct smc_cdc_tx_pend *pend)
77{
78 BUILD_BUG_ON_MSG(
79 sizeof(struct smc_cdc_msg) > SMC_WR_BUF_SIZE,
80 "must increase SMC_WR_BUF_SIZE to at least sizeof(struct smc_cdc_msg)");
81 BUILD_BUG_ON_MSG(
Ursula Braunb9a22dd2018-11-20 16:46:42 +010082 offsetofend(struct smc_cdc_msg, reserved) > SMC_WR_TX_SIZE,
Ursula Braun5f083182017-01-09 16:55:22 +010083 "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()");
84 BUILD_BUG_ON_MSG(
85 sizeof(struct smc_cdc_tx_pend) > SMC_WR_TX_PEND_PRIV_SIZE,
86 "must increase SMC_WR_TX_PEND_PRIV_SIZE to at least sizeof(struct smc_cdc_tx_pend)");
87 pend->conn = conn;
88 pend->cursor = conn->tx_curs_sent;
89 pend->p_cursor = conn->local_tx_ctrl.prod;
90 pend->ctrl_seq = conn->tx_cdc_seq;
91}
92
93int smc_cdc_msg_send(struct smc_connection *conn,
94 struct smc_wr_buf *wr_buf,
95 struct smc_cdc_tx_pend *pend)
96{
Karsten Graul387707f2020-04-29 17:10:40 +020097 struct smc_link *link = conn->lnk;
Ursula Braunb8649ef2019-02-04 13:44:45 +010098 union smc_host_cursor cfed;
Ursula Braun5f083182017-01-09 16:55:22 +010099 int rc;
100
Ursula Braun5f083182017-01-09 16:55:22 +0100101 smc_cdc_add_pending_send(conn, pend);
102
103 conn->tx_cdc_seq++;
104 conn->local_tx_ctrl.seqno = conn->tx_cdc_seq;
Ursula Braunccc8ca92019-02-07 14:52:54 +0100105 smc_host_msg_to_cdc((struct smc_cdc_msg *)wr_buf, conn, &cfed);
Ursula Braun5f083182017-01-09 16:55:22 +0100106 rc = smc_wr_tx_send(link, (struct smc_wr_tx_pend_priv *)pend);
Karsten Graul4dff63c2019-02-12 16:29:50 +0100107 if (!rc) {
Ursula Braunb8649ef2019-02-04 13:44:45 +0100108 smc_curs_copy(&conn->rx_curs_confirmed, &cfed, conn);
Karsten Graul4dff63c2019-02-12 16:29:50 +0100109 conn->local_rx_ctrl.prod_flags.cons_curs_upd_req = 0;
Karsten Graulf0ec4f12020-05-04 14:18:37 +0200110 } else {
111 conn->tx_cdc_seq--;
112 conn->local_tx_ctrl.seqno = conn->tx_cdc_seq;
Karsten Graul4dff63c2019-02-12 16:29:50 +0100113 }
Ursula Braun5f083182017-01-09 16:55:22 +0100114
115 return rc;
116}
117
Hans Wippelbe244f22018-06-28 19:05:10 +0200118static int smcr_cdc_get_slot_and_msg_send(struct smc_connection *conn)
Ursula Braun5f083182017-01-09 16:55:22 +0100119{
120 struct smc_cdc_tx_pend *pend;
121 struct smc_wr_buf *wr_buf;
122 int rc;
123
Ursula Braunad6f3172019-02-04 13:44:44 +0100124 rc = smc_cdc_get_free_slot(conn, &wr_buf, NULL, &pend);
Ursula Braun5f083182017-01-09 16:55:22 +0100125 if (rc)
126 return rc;
127
Karsten Graul2dee25a2019-01-30 18:51:06 +0100128 spin_lock_bh(&conn->send_lock);
129 rc = smc_cdc_msg_send(conn, wr_buf, pend);
130 spin_unlock_bh(&conn->send_lock);
131 return rc;
Ursula Braun5f083182017-01-09 16:55:22 +0100132}
133
Hans Wippelbe244f22018-06-28 19:05:10 +0200134int smc_cdc_get_slot_and_msg_send(struct smc_connection *conn)
135{
136 int rc;
137
Ursula Braun50c6b202019-11-14 13:02:40 +0100138 if (!conn->lgr || (conn->lgr->is_smcd && conn->lgr->peer_shutdown))
139 return -EPIPE;
140
Hans Wippelbe244f22018-06-28 19:05:10 +0200141 if (conn->lgr->is_smcd) {
142 spin_lock_bh(&conn->send_lock);
143 rc = smcd_cdc_msg_send(conn);
144 spin_unlock_bh(&conn->send_lock);
145 } else {
146 rc = smcr_cdc_get_slot_and_msg_send(conn);
147 }
148
149 return rc;
150}
151
Ursula Braun5f083182017-01-09 16:55:22 +0100152static bool smc_cdc_tx_filter(struct smc_wr_tx_pend_priv *tx_pend,
153 unsigned long data)
154{
155 struct smc_connection *conn = (struct smc_connection *)data;
156 struct smc_cdc_tx_pend *cdc_pend =
157 (struct smc_cdc_tx_pend *)tx_pend;
158
159 return cdc_pend->conn == conn;
160}
161
162static void smc_cdc_tx_dismisser(struct smc_wr_tx_pend_priv *tx_pend)
163{
164 struct smc_cdc_tx_pend *cdc_pend =
165 (struct smc_cdc_tx_pend *)tx_pend;
166
167 cdc_pend->conn = NULL;
168}
169
170void smc_cdc_tx_dismiss_slots(struct smc_connection *conn)
171{
Karsten Graul387707f2020-04-29 17:10:40 +0200172 struct smc_link *link = conn->lnk;
Ursula Braun5f083182017-01-09 16:55:22 +0100173
174 smc_wr_tx_dismiss_slots(link, SMC_CDC_MSG_TYPE,
175 smc_cdc_tx_filter, smc_cdc_tx_dismisser,
176 (unsigned long)conn);
177}
178
Hans Wippelbe244f22018-06-28 19:05:10 +0200179/* Send a SMC-D CDC header.
180 * This increments the free space available in our send buffer.
181 * Also update the confirmed receive buffer with what was sent to the peer.
182 */
183int smcd_cdc_msg_send(struct smc_connection *conn)
184{
185 struct smc_sock *smc = container_of(conn, struct smc_sock, conn);
Ursula Braunb9a22dd2018-11-20 16:46:42 +0100186 union smc_host_cursor curs;
Hans Wippelbe244f22018-06-28 19:05:10 +0200187 struct smcd_cdc_msg cdc;
188 int rc, diff;
189
190 memset(&cdc, 0, sizeof(cdc));
191 cdc.common.type = SMC_CDC_MSG_TYPE;
Ursula Braunb9a22dd2018-11-20 16:46:42 +0100192 curs.acurs.counter = atomic64_read(&conn->local_tx_ctrl.prod.acurs);
193 cdc.prod.wrap = curs.wrap;
194 cdc.prod.count = curs.count;
195 curs.acurs.counter = atomic64_read(&conn->local_tx_ctrl.cons.acurs);
196 cdc.cons.wrap = curs.wrap;
197 cdc.cons.count = curs.count;
198 cdc.cons.prod_flags = conn->local_tx_ctrl.prod_flags;
199 cdc.cons.conn_state_flags = conn->local_tx_ctrl.conn_state_flags;
Hans Wippelbe244f22018-06-28 19:05:10 +0200200 rc = smcd_tx_ism_write(conn, &cdc, sizeof(cdc), 0, 1);
201 if (rc)
202 return rc;
Ursula Braunb9a22dd2018-11-20 16:46:42 +0100203 smc_curs_copy(&conn->rx_curs_confirmed, &curs, conn);
Karsten Graul4dff63c2019-02-12 16:29:50 +0100204 conn->local_rx_ctrl.prod_flags.cons_curs_upd_req = 0;
Hans Wippelbe244f22018-06-28 19:05:10 +0200205 /* Calculate transmitted data and increment free send buffer space */
206 diff = smc_curs_diff(conn->sndbuf_desc->len, &conn->tx_curs_fin,
207 &conn->tx_curs_sent);
208 /* increased by confirmed number of bytes */
209 smp_mb__before_atomic();
210 atomic_add(diff, &conn->sndbuf_space);
211 /* guarantee 0 <= sndbuf_space <= sndbuf_desc->len */
212 smp_mb__after_atomic();
Stefan Rasplbac6de72018-07-23 13:53:09 +0200213 smc_curs_copy(&conn->tx_curs_fin, &conn->tx_curs_sent, conn);
Hans Wippelbe244f22018-06-28 19:05:10 +0200214
215 smc_tx_sndbuf_nonfull(smc);
216 return rc;
217}
218
Ursula Braun5f083182017-01-09 16:55:22 +0100219/********************************* receive ***********************************/
220
221static inline bool smc_cdc_before(u16 seq1, u16 seq2)
222{
223 return (s16)(seq1 - seq2) < 0;
224}
225
Stefan Rasplde8474e2018-05-23 16:38:11 +0200226static void smc_cdc_handle_urg_data_arrival(struct smc_sock *smc,
227 int *diff_prod)
228{
229 struct smc_connection *conn = &smc->conn;
230 char *base;
231
232 /* new data included urgent business */
Stefan Rasplbac6de72018-07-23 13:53:09 +0200233 smc_curs_copy(&conn->urg_curs, &conn->local_rx_ctrl.prod, conn);
Stefan Rasplde8474e2018-05-23 16:38:11 +0200234 conn->urg_state = SMC_URG_VALID;
235 if (!sock_flag(&smc->sk, SOCK_URGINLINE))
236 /* we'll skip the urgent byte, so don't account for it */
237 (*diff_prod)--;
Hans Wippelbe244f22018-06-28 19:05:10 +0200238 base = (char *)conn->rmb_desc->cpu_addr + conn->rx_off;
Stefan Rasplde8474e2018-05-23 16:38:11 +0200239 if (conn->urg_curs.count)
240 conn->urg_rx_byte = *(base + conn->urg_curs.count - 1);
241 else
242 conn->urg_rx_byte = *(base + conn->rmb_desc->len - 1);
243 sk_send_sigurg(&smc->sk);
244}
245
Ursula Braun5f083182017-01-09 16:55:22 +0100246static void smc_cdc_msg_recv_action(struct smc_sock *smc,
Ursula Braun5f083182017-01-09 16:55:22 +0100247 struct smc_cdc_msg *cdc)
248{
249 union smc_host_cursor cons_old, prod_old;
250 struct smc_connection *conn = &smc->conn;
251 int diff_cons, diff_prod;
252
Stefan Rasplbac6de72018-07-23 13:53:09 +0200253 smc_curs_copy(&prod_old, &conn->local_rx_ctrl.prod, conn);
254 smc_curs_copy(&cons_old, &conn->local_rx_ctrl.cons, conn);
Ursula Braun5f083182017-01-09 16:55:22 +0100255 smc_cdc_msg_to_host(&conn->local_rx_ctrl, cdc, conn);
256
257 diff_cons = smc_curs_diff(conn->peer_rmbe_size, &cons_old,
258 &conn->local_rx_ctrl.cons);
259 if (diff_cons) {
260 /* peer_rmbe_space is decreased during data transfer with RDMA
261 * write
262 */
263 smp_mb__before_atomic();
264 atomic_add(diff_cons, &conn->peer_rmbe_space);
265 /* guarantee 0 <= peer_rmbe_space <= peer_rmbe_size */
266 smp_mb__after_atomic();
267 }
268
Hans Wippel69cb7dc2018-05-18 09:34:10 +0200269 diff_prod = smc_curs_diff(conn->rmb_desc->len, &prod_old,
Ursula Braun5f083182017-01-09 16:55:22 +0100270 &conn->local_rx_ctrl.prod);
271 if (diff_prod) {
Stefan Rasplde8474e2018-05-23 16:38:11 +0200272 if (conn->local_rx_ctrl.prod_flags.urg_data_present)
273 smc_cdc_handle_urg_data_arrival(smc, &diff_prod);
Ursula Braun5f083182017-01-09 16:55:22 +0100274 /* bytes_to_rcv is decreased in smc_recvmsg */
275 smp_mb__before_atomic();
276 atomic_add(diff_prod, &conn->bytes_to_rcv);
Hans Wippel69cb7dc2018-05-18 09:34:10 +0200277 /* guarantee 0 <= bytes_to_rcv <= rmb_desc->len */
Ursula Braun5f083182017-01-09 16:55:22 +0100278 smp_mb__after_atomic();
Ursula Braun952310c2017-01-09 16:55:24 +0100279 smc->sk.sk_data_ready(&smc->sk);
Stefan Rasplde8474e2018-05-23 16:38:11 +0200280 } else {
Karsten Graulcf0cfe52019-02-12 16:29:53 +0100281 if (conn->local_rx_ctrl.prod_flags.write_blocked)
282 smc->sk.sk_data_ready(&smc->sk);
283 if (conn->local_rx_ctrl.prod_flags.urg_data_pending)
284 conn->urg_state = SMC_URG_NOTYET;
Ursula Braun5f083182017-01-09 16:55:22 +0100285 }
286
Ursula Braun51f1de72018-01-26 09:28:48 +0100287 /* trigger sndbuf consumer: RDMA write into peer RMBE and CDC */
Karsten Graulcf0cfe52019-02-12 16:29:53 +0100288 if ((diff_cons && smc_tx_prepared_sends(conn)) ||
289 conn->local_rx_ctrl.prod_flags.cons_curs_upd_req ||
290 conn->local_rx_ctrl.prod_flags.urg_data_pending)
Ursula Braun51f1de72018-01-26 09:28:48 +0100291 smc_tx_sndbuf_nonempty(conn);
Karsten Graulcf0cfe52019-02-12 16:29:53 +0100292
Stefan Rasplde8474e2018-05-23 16:38:11 +0200293 if (diff_cons && conn->urg_tx_pend &&
294 atomic_read(&conn->peer_rmbe_space) == conn->peer_rmbe_size) {
295 /* urg data confirmed by peer, indicate we're ready for more */
296 conn->urg_tx_pend = false;
297 smc->sk.sk_write_space(&smc->sk);
298 }
Ursula Braun51f1de72018-01-26 09:28:48 +0100299
Ursula Braunb38d7322017-01-09 16:55:25 +0100300 if (conn->local_rx_ctrl.conn_state_flags.peer_conn_abort) {
Ursula Braun5f083182017-01-09 16:55:22 +0100301 smc->sk.sk_err = ECONNRESET;
Ursula Braunb38d7322017-01-09 16:55:25 +0100302 conn->local_tx_ctrl.conn_state_flags.peer_conn_abort = 1;
303 }
Ursula Braun46c28db2017-04-10 14:58:01 +0200304 if (smc_cdc_rxed_any_close_or_senddone(conn)) {
305 smc->sk.sk_shutdown |= RCV_SHUTDOWN;
306 if (smc->clcsock && smc->clcsock->sk)
307 smc->clcsock->sk->sk_shutdown |= RCV_SHUTDOWN;
308 sock_set_flag(&smc->sk, SOCK_DONE);
Ursula Braun51f1de72018-01-26 09:28:48 +0100309 sock_hold(&smc->sk); /* sock_put in close_work */
310 if (!schedule_work(&conn->close_work))
311 sock_put(&smc->sk);
Ursula Braunb38d7322017-01-09 16:55:25 +0100312 }
Ursula Braun5f083182017-01-09 16:55:22 +0100313}
314
315/* called under tasklet context */
Hans Wippeld7b0e372018-05-18 09:34:15 +0200316static void smc_cdc_msg_recv(struct smc_sock *smc, struct smc_cdc_msg *cdc)
Ursula Braun5f083182017-01-09 16:55:22 +0100317{
Ursula Braun5f083182017-01-09 16:55:22 +0100318 sock_hold(&smc->sk);
Ursula Braun5f083182017-01-09 16:55:22 +0100319 bh_lock_sock(&smc->sk);
Hans Wippeld7b0e372018-05-18 09:34:15 +0200320 smc_cdc_msg_recv_action(smc, cdc);
Ursula Braun5f083182017-01-09 16:55:22 +0100321 bh_unlock_sock(&smc->sk);
322 sock_put(&smc->sk); /* no free sk in softirq-context */
323}
324
Hans Wippelbe244f22018-06-28 19:05:10 +0200325/* Schedule a tasklet for this connection. Triggered from the ISM device IRQ
326 * handler to indicate update in the DMBE.
327 *
328 * Context:
329 * - tasklet context
330 */
331static void smcd_cdc_rx_tsklet(unsigned long data)
332{
333 struct smc_connection *conn = (struct smc_connection *)data;
Ursula Braunb9a22dd2018-11-20 16:46:42 +0100334 struct smcd_cdc_msg *data_cdc;
Hans Wippelbe244f22018-06-28 19:05:10 +0200335 struct smcd_cdc_msg cdc;
336 struct smc_sock *smc;
337
Ursula Braunb2900982019-10-21 16:13:08 +0200338 if (!conn || conn->killed)
Hans Wippelbe244f22018-06-28 19:05:10 +0200339 return;
340
Ursula Braunb9a22dd2018-11-20 16:46:42 +0100341 data_cdc = (struct smcd_cdc_msg *)conn->rmb_desc->cpu_addr;
342 smcd_curs_copy(&cdc.prod, &data_cdc->prod, conn);
343 smcd_curs_copy(&cdc.cons, &data_cdc->cons, conn);
Hans Wippelbe244f22018-06-28 19:05:10 +0200344 smc = container_of(conn, struct smc_sock, conn);
345 smc_cdc_msg_recv(smc, (struct smc_cdc_msg *)&cdc);
346}
347
348/* Initialize receive tasklet. Called from ISM device IRQ handler to start
349 * receiver side.
350 */
351void smcd_cdc_rx_init(struct smc_connection *conn)
352{
353 tasklet_init(&conn->rx_tsklet, smcd_cdc_rx_tsklet, (unsigned long)conn);
354}
355
Ursula Braun5f083182017-01-09 16:55:22 +0100356/***************************** init, exit, misc ******************************/
357
358static void smc_cdc_rx_handler(struct ib_wc *wc, void *buf)
359{
360 struct smc_link *link = (struct smc_link *)wc->qp->qp_context;
361 struct smc_cdc_msg *cdc = buf;
Hans Wippeld7b0e372018-05-18 09:34:15 +0200362 struct smc_connection *conn;
363 struct smc_link_group *lgr;
364 struct smc_sock *smc;
Ursula Braun5f083182017-01-09 16:55:22 +0100365
366 if (wc->byte_len < offsetof(struct smc_cdc_msg, reserved))
367 return; /* short message */
Karsten Graulcbba07a2018-02-28 12:44:07 +0100368 if (cdc->len != SMC_WR_TX_SIZE)
Ursula Braun5f083182017-01-09 16:55:22 +0100369 return; /* invalid message */
Hans Wippeld7b0e372018-05-18 09:34:15 +0200370
371 /* lookup connection */
Stefan Raspl00e5fb22018-07-23 13:53:10 +0200372 lgr = smc_get_lgr(link);
Hans Wippeld7b0e372018-05-18 09:34:15 +0200373 read_lock_bh(&lgr->conns_lock);
374 conn = smc_lgr_find_conn(ntohl(cdc->token), lgr);
375 read_unlock_bh(&lgr->conns_lock);
376 if (!conn)
377 return;
378 smc = container_of(conn, struct smc_sock, conn);
379
380 if (!cdc->prod_flags.failover_validation) {
381 if (smc_cdc_before(ntohs(cdc->seqno),
382 conn->local_rx_ctrl.seqno))
383 /* received seqno is old */
384 return;
385 }
386 smc_cdc_msg_recv(smc, cdc);
Ursula Braun5f083182017-01-09 16:55:22 +0100387}
388
389static struct smc_wr_rx_handler smc_cdc_rx_handlers[] = {
390 {
391 .handler = smc_cdc_rx_handler,
392 .type = SMC_CDC_MSG_TYPE
393 },
394 {
395 .handler = NULL,
396 }
397};
398
399int __init smc_cdc_init(void)
400{
401 struct smc_wr_rx_handler *handler;
402 int rc = 0;
403
404 for (handler = smc_cdc_rx_handlers; handler->handler; handler++) {
405 INIT_HLIST_NODE(&handler->list);
406 rc = smc_wr_rx_register_handler(handler);
407 if (rc)
408 break;
409 }
410 return rc;
411}