1 // SPDX-License-Identifier: GPL-2.0
3 * Shared Memory Communications over RDMA (SMC-R) and RoCE
7 * Copy user space data into send buffer, if send buffer space available.
9 * Trigger RDMA write into RMBE of peer and send CDC, if RMBE space available.
11 * Copyright IBM Corp. 2016
13 * Author(s): Ursula Braun <ubraun@linux.vnet.ibm.com>
16 #include <linux/net.h>
17 #include <linux/rcupdate.h>
18 #include <linux/workqueue.h>
19 #include <linux/sched/signal.h>
27 #include "smc_close.h"
30 #include "smc_stats.h"
31 #include "smc_tracepoint.h"
33 #define SMC_TX_WORK_DELAY 0
35 /***************************** sndbuf producer *******************************/
37 /* callback implementation for sk.sk_write_space()
38 * to wakeup sndbuf producers that blocked with smc_tx_wait().
39 * called under sk_socket lock.
41 static void smc_tx_write_space(struct sock *sk)
43 struct socket *sock = sk->sk_socket;
44 struct smc_sock *smc = smc_sk(sk);
47 /* similar to sk_stream_write_space */
48 if (atomic_read(&smc->conn.sndbuf_space) && sock) {
49 if (test_bit(SOCK_NOSPACE, &sock->flags))
50 SMC_STAT_RMB_TX_FULL(smc, !smc->conn.lnk);
51 clear_bit(SOCK_NOSPACE, &sock->flags);
53 wq = rcu_dereference(sk->sk_wq);
54 if (skwq_has_sleeper(wq))
55 wake_up_interruptible_poll(&wq->wait,
56 EPOLLOUT | EPOLLWRNORM |
58 if (wq && wq->fasync_list && !(sk->sk_shutdown & SEND_SHUTDOWN))
59 sock_wake_async(wq, SOCK_WAKE_SPACE, POLL_OUT);
64 /* Wakeup sndbuf producers that blocked with smc_tx_wait().
65 * Cf. tcp_data_snd_check()=>tcp_check_space()=>tcp_new_space().
67 void smc_tx_sndbuf_nonfull(struct smc_sock *smc)
69 if (smc->sk.sk_socket &&
70 test_bit(SOCK_NOSPACE, &smc->sk.sk_socket->flags))
71 smc->sk.sk_write_space(&smc->sk);
74 /* blocks sndbuf producer until at least one byte of free space available
75 * or urgent Byte was consumed
77 static int smc_tx_wait(struct smc_sock *smc, int flags)
79 DEFINE_WAIT_FUNC(wait, woken_wake_function);
80 struct smc_connection *conn = &smc->conn;
81 struct sock *sk = &smc->sk;
85 /* similar to sk_stream_wait_memory */
86 timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);
87 add_wait_queue(sk_sleep(sk), &wait);
89 sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
91 (sk->sk_shutdown & SEND_SHUTDOWN) ||
93 conn->local_tx_ctrl.conn_state_flags.peer_done_writing) {
97 if (smc_cdc_rxed_any_close(conn)) {
102 /* ensure EPOLLOUT is subsequently generated */
103 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
107 if (signal_pending(current)) {
108 rc = sock_intr_errno(timeo);
111 sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
112 if (atomic_read(&conn->sndbuf_space) && !conn->urg_tx_pend)
113 break; /* at least 1 byte of free & no urgent data */
114 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
115 sk_wait_event(sk, &timeo,
116 READ_ONCE(sk->sk_err) ||
117 (READ_ONCE(sk->sk_shutdown) & SEND_SHUTDOWN) ||
118 smc_cdc_rxed_any_close(conn) ||
119 (atomic_read(&conn->sndbuf_space) &&
123 remove_wait_queue(sk_sleep(sk), &wait);
127 static bool smc_tx_is_corked(struct smc_sock *smc)
129 struct tcp_sock *tp = tcp_sk(smc->clcsock->sk);
131 return (tp->nonagle & TCP_NAGLE_CORK) ? true : false;
134 /* If we have pending CDC messages, do not send:
135 * Because CQE of this CDC message will happen shortly, it gives
136 * a chance to coalesce future sendmsg() payload in to one RDMA Write,
137 * without need for a timer, and with no latency trade off.
139 * 1. First message should never cork
140 * 2. If we have pending Tx CDC messages, wait for the first CDC
141 * message's completion
142 * 3. Don't cork to much data in a single RDMA Write to prevent burst
143 * traffic, total corked message should not exceed sendbuf/2
145 static bool smc_should_autocork(struct smc_sock *smc)
147 struct smc_connection *conn = &smc->conn;
150 corking_size = min_t(unsigned int, conn->sndbuf_desc->len >> 1,
151 sock_net(&smc->sk)->smc.sysctl_autocorking_size);
153 if (atomic_read(&conn->cdc_pend_tx_wr) == 0 ||
154 smc_tx_prepared_sends(conn) > corking_size)
159 static bool smc_tx_should_cork(struct smc_sock *smc, struct msghdr *msg)
161 struct smc_connection *conn = &smc->conn;
163 if (smc_should_autocork(smc))
166 /* for a corked socket defer the RDMA writes if
167 * sndbuf_space is still available. The applications
168 * should known how/when to uncork it.
170 if ((msg->msg_flags & MSG_MORE ||
171 smc_tx_is_corked(smc)) &&
172 atomic_read(&conn->sndbuf_space))
178 /* sndbuf producer: main API called by socket layer.
179 * called under sock lock.
181 int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len)
183 size_t copylen, send_done = 0, send_remaining = len;
184 size_t chunk_len, chunk_off, chunk_len_sum;
185 struct smc_connection *conn = &smc->conn;
186 union smc_host_cursor prep;
187 struct sock *sk = &smc->sk;
193 /* This should be in poll */
194 sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
196 if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN)) {
201 if (sk->sk_state == SMC_INIT)
204 if (len > conn->sndbuf_desc->len)
205 SMC_STAT_RMB_TX_SIZE_SMALL(smc, !conn->lnk);
207 if (len > conn->peer_rmbe_size)
208 SMC_STAT_RMB_TX_PEER_SIZE_SMALL(smc, !conn->lnk);
210 if (msg->msg_flags & MSG_OOB)
211 SMC_STAT_INC(smc, urg_data_cnt);
213 while (msg_data_left(msg)) {
214 if (smc->sk.sk_shutdown & SEND_SHUTDOWN ||
215 (smc->sk.sk_err == ECONNABORTED) ||
218 if (smc_cdc_rxed_any_close(conn))
219 return send_done ?: -ECONNRESET;
221 if (msg->msg_flags & MSG_OOB)
222 conn->local_tx_ctrl.prod_flags.urg_data_pending = 1;
224 if (!atomic_read(&conn->sndbuf_space) || conn->urg_tx_pend) {
227 rc = smc_tx_wait(smc, msg->msg_flags);
233 /* initialize variables for 1st iteration of subsequent loop */
234 /* could be just 1 byte, even after smc_tx_wait above */
235 writespace = atomic_read(&conn->sndbuf_space);
236 /* not more than what user space asked for */
237 copylen = min_t(size_t, send_remaining, writespace);
238 /* determine start of sndbuf */
239 sndbuf_base = conn->sndbuf_desc->cpu_addr;
240 smc_curs_copy(&prep, &conn->tx_curs_prep, conn);
241 tx_cnt_prep = prep.count;
242 /* determine chunks where to write into sndbuf */
243 /* either unwrapped case, or 1st chunk of wrapped case */
244 chunk_len = min_t(size_t, copylen, conn->sndbuf_desc->len -
246 chunk_len_sum = chunk_len;
247 chunk_off = tx_cnt_prep;
248 for (chunk = 0; chunk < 2; chunk++) {
249 rc = memcpy_from_msg(sndbuf_base + chunk_off,
252 smc_sndbuf_sync_sg_for_device(conn);
257 send_done += chunk_len;
258 send_remaining -= chunk_len;
260 if (chunk_len_sum == copylen)
261 break; /* either on 1st or 2nd iteration */
262 /* prepare next (== 2nd) iteration */
263 chunk_len = copylen - chunk_len; /* remainder */
264 chunk_len_sum += chunk_len;
265 chunk_off = 0; /* modulo offset in send ring buffer */
267 smc_sndbuf_sync_sg_for_device(conn);
269 smc_curs_add(conn->sndbuf_desc->len, &prep, copylen);
270 smc_curs_copy(&conn->tx_curs_prep, &prep, conn);
271 /* increased in send tasklet smc_cdc_tx_handler() */
272 smp_mb__before_atomic();
273 atomic_sub(copylen, &conn->sndbuf_space);
274 /* guarantee 0 <= sndbuf_space <= sndbuf_desc->len */
275 smp_mb__after_atomic();
276 /* since we just produced more new data into sndbuf,
277 * trigger sndbuf consumer: RDMA write into peer RMBE and CDC
279 if ((msg->msg_flags & MSG_OOB) && !send_remaining)
280 conn->urg_tx_pend = true;
281 /* If we need to cork, do nothing and wait for the next
282 * sendmsg() call or push on tx completion
284 if (!smc_tx_should_cork(smc, msg))
285 smc_tx_sndbuf_nonempty(conn);
287 trace_smc_tx_sendmsg(smc, copylen);
288 } /* while (msg_data_left(msg)) */
293 rc = sk_stream_error(sk, msg->msg_flags, rc);
294 /* make sure we wake any epoll edge trigger waiter */
295 if (unlikely(rc == -EAGAIN))
296 sk->sk_write_space(sk);
300 int smc_tx_sendpage(struct smc_sock *smc, struct page *page, int offset,
301 size_t size, int flags)
303 struct msghdr msg = {.msg_flags = flags};
304 char *kaddr = kmap(page);
308 if (flags & MSG_SENDPAGE_NOTLAST)
309 msg.msg_flags |= MSG_MORE;
311 iov.iov_base = kaddr + offset;
313 iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, &iov, 1, size);
314 rc = smc_tx_sendmsg(smc, &msg, size);
319 /***************************** sndbuf consumer *******************************/
321 /* sndbuf consumer: actual data transfer of one target chunk with ISM write */
322 int smcd_tx_ism_write(struct smc_connection *conn, void *data, size_t len,
323 u32 offset, int signal)
327 rc = smc_ism_write(conn->lgr->smcd, conn->peer_token,
328 conn->peer_rmbe_idx, signal, conn->tx_off + offset,
331 conn->local_tx_ctrl.conn_state_flags.peer_conn_abort = 1;
335 /* sndbuf consumer: actual data transfer of one target chunk with RDMA write */
336 static int smc_tx_rdma_write(struct smc_connection *conn, int peer_rmbe_offset,
337 int num_sges, struct ib_rdma_wr *rdma_wr)
339 struct smc_link_group *lgr = conn->lgr;
340 struct smc_link *link = conn->lnk;
343 rdma_wr->wr.wr_id = smc_wr_tx_get_next_wr_id(link);
344 rdma_wr->wr.num_sge = num_sges;
345 rdma_wr->remote_addr =
346 lgr->rtokens[conn->rtoken_idx][link->link_idx].dma_addr +
347 /* RMBE within RMB */
349 /* offset within RMBE */
351 rdma_wr->rkey = lgr->rtokens[conn->rtoken_idx][link->link_idx].rkey;
352 rc = ib_post_send(link->roce_qp, &rdma_wr->wr, NULL);
354 smcr_link_down_cond_sched(link);
358 /* sndbuf consumer */
359 static inline void smc_tx_advance_cursors(struct smc_connection *conn,
360 union smc_host_cursor *prod,
361 union smc_host_cursor *sent,
364 smc_curs_add(conn->peer_rmbe_size, prod, len);
365 /* increased in recv tasklet smc_cdc_msg_rcv() */
366 smp_mb__before_atomic();
367 /* data in flight reduces usable snd_wnd */
368 atomic_sub(len, &conn->peer_rmbe_space);
369 /* guarantee 0 <= peer_rmbe_space <= peer_rmbe_size */
370 smp_mb__after_atomic();
371 smc_curs_add(conn->sndbuf_desc->len, sent, len);
374 /* SMC-R helper for smc_tx_rdma_writes() */
375 static int smcr_tx_rdma_writes(struct smc_connection *conn, size_t len,
376 size_t src_off, size_t src_len,
377 size_t dst_off, size_t dst_len,
378 struct smc_rdma_wr *wr_rdma_buf)
380 struct smc_link *link = conn->lnk;
382 dma_addr_t dma_addr =
383 sg_dma_address(conn->sndbuf_desc->sgt[link->link_idx].sgl);
384 u64 virt_addr = (uintptr_t)conn->sndbuf_desc->cpu_addr;
385 int src_len_sum = src_len, dst_len_sum = dst_len;
386 int sent_count = src_off;
387 int srcchunk, dstchunk;
391 for (dstchunk = 0; dstchunk < 2; dstchunk++) {
392 struct ib_rdma_wr *wr = &wr_rdma_buf->wr_tx_rdma[dstchunk];
393 struct ib_sge *sge = wr->wr.sg_list;
394 u64 base_addr = dma_addr;
396 if (dst_len < link->qp_attr.cap.max_inline_data) {
397 base_addr = virt_addr;
398 wr->wr.send_flags |= IB_SEND_INLINE;
400 wr->wr.send_flags &= ~IB_SEND_INLINE;
404 for (srcchunk = 0; srcchunk < 2; srcchunk++) {
405 sge[srcchunk].addr = conn->sndbuf_desc->is_vm ?
406 (virt_addr + src_off) : (base_addr + src_off);
407 sge[srcchunk].length = src_len;
408 if (conn->sndbuf_desc->is_vm)
410 conn->sndbuf_desc->mr[link->link_idx]->lkey;
414 if (src_off >= conn->sndbuf_desc->len)
415 src_off -= conn->sndbuf_desc->len;
416 /* modulo in send ring */
417 if (src_len_sum == dst_len)
418 break; /* either on 1st or 2nd iteration */
419 /* prepare next (== 2nd) iteration */
420 src_len = dst_len - src_len; /* remainder */
421 src_len_sum += src_len;
423 rc = smc_tx_rdma_write(conn, dst_off, num_sges, wr);
426 if (dst_len_sum == len)
427 break; /* either on 1st or 2nd iteration */
428 /* prepare next (== 2nd) iteration */
429 dst_off = 0; /* modulo offset in RMBE ring buffer */
430 dst_len = len - dst_len; /* remainder */
431 dst_len_sum += dst_len;
432 src_len = min_t(int, dst_len, conn->sndbuf_desc->len -
434 src_len_sum = src_len;
439 /* SMC-D helper for smc_tx_rdma_writes() */
440 static int smcd_tx_rdma_writes(struct smc_connection *conn, size_t len,
441 size_t src_off, size_t src_len,
442 size_t dst_off, size_t dst_len)
444 int src_len_sum = src_len, dst_len_sum = dst_len;
445 int srcchunk, dstchunk;
448 for (dstchunk = 0; dstchunk < 2; dstchunk++) {
449 for (srcchunk = 0; srcchunk < 2; srcchunk++) {
450 void *data = conn->sndbuf_desc->cpu_addr + src_off;
452 rc = smcd_tx_ism_write(conn, data, src_len, dst_off +
453 sizeof(struct smcd_cdc_msg), 0);
458 if (src_off >= conn->sndbuf_desc->len)
459 src_off -= conn->sndbuf_desc->len;
460 /* modulo in send ring */
461 if (src_len_sum == dst_len)
462 break; /* either on 1st or 2nd iteration */
463 /* prepare next (== 2nd) iteration */
464 src_len = dst_len - src_len; /* remainder */
465 src_len_sum += src_len;
467 if (dst_len_sum == len)
468 break; /* either on 1st or 2nd iteration */
469 /* prepare next (== 2nd) iteration */
470 dst_off = 0; /* modulo offset in RMBE ring buffer */
471 dst_len = len - dst_len; /* remainder */
472 dst_len_sum += dst_len;
473 src_len = min_t(int, dst_len, conn->sndbuf_desc->len - src_off);
474 src_len_sum = src_len;
479 /* sndbuf consumer: prepare all necessary (src&dst) chunks of data transmit;
480 * usable snd_wnd as max transmit
482 static int smc_tx_rdma_writes(struct smc_connection *conn,
483 struct smc_rdma_wr *wr_rdma_buf)
485 size_t len, src_len, dst_off, dst_len; /* current chunk values */
486 union smc_host_cursor sent, prep, prod, cons;
487 struct smc_cdc_producer_flags *pflags;
488 int to_send, rmbespace;
492 smc_curs_copy(&sent, &conn->tx_curs_sent, conn);
493 smc_curs_copy(&prep, &conn->tx_curs_prep, conn);
494 /* cf. wmem_alloc - (snd_max - snd_una) */
495 to_send = smc_curs_diff(conn->sndbuf_desc->len, &sent, &prep);
499 /* destination: RMBE */
501 rmbespace = atomic_read(&conn->peer_rmbe_space);
502 if (rmbespace <= 0) {
503 struct smc_sock *smc = container_of(conn, struct smc_sock,
505 SMC_STAT_RMB_TX_PEER_FULL(smc, !conn->lnk);
508 smc_curs_copy(&prod, &conn->local_tx_ctrl.prod, conn);
509 smc_curs_copy(&cons, &conn->local_rx_ctrl.cons, conn);
511 /* if usable snd_wnd closes ask peer to advertise once it opens again */
512 pflags = &conn->local_tx_ctrl.prod_flags;
513 pflags->write_blocked = (to_send >= rmbespace);
514 /* cf. usable snd_wnd */
515 len = min(to_send, rmbespace);
517 /* initialize variables for first iteration of subsequent nested loop */
518 dst_off = prod.count;
519 if (prod.wrap == cons.wrap) {
520 /* the filled destination area is unwrapped,
521 * hence the available free destination space is wrapped
522 * and we need 2 destination chunks of sum len; start with 1st
523 * which is limited by what's available in sndbuf
525 dst_len = min_t(size_t,
526 conn->peer_rmbe_size - prod.count, len);
528 /* the filled destination area is wrapped,
529 * hence the available free destination space is unwrapped
530 * and we need a single destination chunk of entire len
534 /* dst_len determines the maximum src_len */
535 if (sent.count + dst_len <= conn->sndbuf_desc->len) {
536 /* unwrapped src case: single chunk of entire dst_len */
539 /* wrapped src case: 2 chunks of sum dst_len; start with 1st: */
540 src_len = conn->sndbuf_desc->len - sent.count;
543 if (conn->lgr->is_smcd)
544 rc = smcd_tx_rdma_writes(conn, len, sent.count, src_len,
547 rc = smcr_tx_rdma_writes(conn, len, sent.count, src_len,
548 dst_off, dst_len, wr_rdma_buf);
552 if (conn->urg_tx_pend && len == to_send)
553 pflags->urg_data_present = 1;
554 smc_tx_advance_cursors(conn, &prod, &sent, len);
555 /* update connection's cursors with advanced local cursors */
556 smc_curs_copy(&conn->local_tx_ctrl.prod, &prod, conn);
558 smc_curs_copy(&conn->tx_curs_sent, &sent, conn);/* src: local sndbuf */
563 /* Wakeup sndbuf consumers from any context (IRQ or process)
564 * since there is more data to transmit; usable snd_wnd as max transmit
566 static int smcr_tx_sndbuf_nonempty(struct smc_connection *conn)
568 struct smc_cdc_producer_flags *pflags = &conn->local_tx_ctrl.prod_flags;
569 struct smc_link *link = conn->lnk;
570 struct smc_rdma_wr *wr_rdma_buf;
571 struct smc_cdc_tx_pend *pend;
572 struct smc_wr_buf *wr_buf;
575 if (!link || !smc_wr_tx_link_hold(link))
577 rc = smc_cdc_get_free_slot(conn, link, &wr_buf, &wr_rdma_buf, &pend);
579 smc_wr_tx_link_put(link);
581 struct smc_sock *smc =
582 container_of(conn, struct smc_sock, conn);
584 if (smc->sk.sk_err == ECONNABORTED)
585 return sock_error(&smc->sk);
589 mod_delayed_work(conn->lgr->tx_wq, &conn->tx_work,
595 spin_lock_bh(&conn->send_lock);
596 if (link != conn->lnk) {
597 /* link of connection changed, tx_work will restart */
598 smc_wr_tx_put_slot(link,
599 (struct smc_wr_tx_pend_priv *)pend);
603 if (!pflags->urg_data_present) {
604 rc = smc_tx_rdma_writes(conn, wr_rdma_buf);
606 smc_wr_tx_put_slot(link,
607 (struct smc_wr_tx_pend_priv *)pend);
612 rc = smc_cdc_msg_send(conn, wr_buf, pend);
613 if (!rc && pflags->urg_data_present) {
614 pflags->urg_data_pending = 0;
615 pflags->urg_data_present = 0;
619 spin_unlock_bh(&conn->send_lock);
620 smc_wr_tx_link_put(link);
624 static int smcd_tx_sndbuf_nonempty(struct smc_connection *conn)
626 struct smc_cdc_producer_flags *pflags = &conn->local_tx_ctrl.prod_flags;
629 spin_lock_bh(&conn->send_lock);
630 if (!pflags->urg_data_present)
631 rc = smc_tx_rdma_writes(conn, NULL);
633 rc = smcd_cdc_msg_send(conn);
635 if (!rc && pflags->urg_data_present) {
636 pflags->urg_data_pending = 0;
637 pflags->urg_data_present = 0;
639 spin_unlock_bh(&conn->send_lock);
643 static int __smc_tx_sndbuf_nonempty(struct smc_connection *conn)
645 struct smc_sock *smc = container_of(conn, struct smc_sock, conn);
648 /* No data in the send queue */
649 if (unlikely(smc_tx_prepared_sends(conn) <= 0))
652 /* Peer don't have RMBE space */
653 if (unlikely(atomic_read(&conn->peer_rmbe_space) <= 0)) {
654 SMC_STAT_RMB_TX_PEER_FULL(smc, !conn->lnk);
659 conn->local_rx_ctrl.conn_state_flags.peer_conn_abort) {
660 rc = -EPIPE; /* connection being aborted */
663 if (conn->lgr->is_smcd)
664 rc = smcd_tx_sndbuf_nonempty(conn);
666 rc = smcr_tx_sndbuf_nonempty(conn);
669 /* trigger socket release if connection is closing */
670 smc_close_wake_tx_prepared(smc);
677 int smc_tx_sndbuf_nonempty(struct smc_connection *conn)
681 /* This make sure only one can send simultaneously to prevent wasting
682 * of CPU and CDC slot.
683 * Record whether someone has tried to push while we are pushing.
685 if (atomic_inc_return(&conn->tx_pushing) > 1)
689 atomic_set(&conn->tx_pushing, 1);
690 smp_wmb(); /* Make sure tx_pushing is 1 before real send */
691 rc = __smc_tx_sndbuf_nonempty(conn);
693 /* We need to check whether someone else have added some data into
694 * the send queue and tried to push but failed after the atomic_set()
695 * when we are pushing.
696 * If so, we need to push again to prevent those data hang in the send
699 if (unlikely(!atomic_dec_and_test(&conn->tx_pushing)))
705 /* Wakeup sndbuf consumers from process context
706 * since there is more data to transmit. The caller
707 * must hold sock lock.
709 void smc_tx_pending(struct smc_connection *conn)
711 struct smc_sock *smc = container_of(conn, struct smc_sock, conn);
717 rc = smc_tx_sndbuf_nonempty(conn);
718 if (!rc && conn->local_rx_ctrl.prod_flags.write_blocked &&
719 !atomic_read(&conn->bytes_to_rcv))
720 conn->local_rx_ctrl.prod_flags.write_blocked = 0;
723 /* Wakeup sndbuf consumers from process context
724 * since there is more data to transmit in locked
727 void smc_tx_work(struct work_struct *work)
729 struct smc_connection *conn = container_of(to_delayed_work(work),
730 struct smc_connection,
732 struct smc_sock *smc = container_of(conn, struct smc_sock, conn);
735 smc_tx_pending(conn);
736 release_sock(&smc->sk);
739 void smc_tx_consumer_update(struct smc_connection *conn, bool force)
741 union smc_host_cursor cfed, cons, prod;
742 int sender_free = conn->rmb_desc->len;
745 smc_curs_copy(&cons, &conn->local_tx_ctrl.cons, conn);
746 smc_curs_copy(&cfed, &conn->rx_curs_confirmed, conn);
747 to_confirm = smc_curs_diff(conn->rmb_desc->len, &cfed, &cons);
748 if (to_confirm > conn->rmbe_update_limit) {
749 smc_curs_copy(&prod, &conn->local_rx_ctrl.prod, conn);
750 sender_free = conn->rmb_desc->len -
751 smc_curs_diff_large(conn->rmb_desc->len,
755 if (conn->local_rx_ctrl.prod_flags.cons_curs_upd_req ||
757 ((to_confirm > conn->rmbe_update_limit) &&
758 ((sender_free <= (conn->rmb_desc->len / 2)) ||
759 conn->local_rx_ctrl.prod_flags.write_blocked))) {
761 conn->local_rx_ctrl.conn_state_flags.peer_conn_abort)
763 if ((smc_cdc_get_slot_and_msg_send(conn) < 0) &&
765 queue_delayed_work(conn->lgr->tx_wq, &conn->tx_work,
770 if (conn->local_rx_ctrl.prod_flags.write_blocked &&
771 !atomic_read(&conn->bytes_to_rcv))
772 conn->local_rx_ctrl.prod_flags.write_blocked = 0;
775 /***************************** send initialize *******************************/
777 /* Initialize send properties on connection establishment. NB: not __init! */
778 void smc_tx_init(struct smc_sock *smc)
780 smc->sk.sk_write_space = smc_tx_write_space;