Lines Matching refs:conn
47 if (atomic_read(&smc->conn.sndbuf_space) && sock) { in smc_tx_write_space()
77 struct smc_connection *conn = &smc->conn; in smc_tx_wait() local
89 conn->local_tx_ctrl.conn_state_flags.peer_done_writing) { in smc_tx_wait()
93 if (smc_cdc_rxed_any_close(conn)) { in smc_tx_wait()
108 if (atomic_read(&conn->sndbuf_space) && !conn->urg_tx_pend) in smc_tx_wait()
114 smc_cdc_rxed_any_close(conn) || in smc_tx_wait()
115 (atomic_read(&conn->sndbuf_space) && in smc_tx_wait()
116 !conn->urg_tx_pend), in smc_tx_wait()
137 struct smc_connection *conn = &smc->conn; in smc_tx_sendmsg() local
158 conn->local_tx_ctrl.conn_state_flags.peer_conn_abort) in smc_tx_sendmsg()
160 if (smc_cdc_rxed_any_close(conn)) in smc_tx_sendmsg()
164 conn->local_tx_ctrl.prod_flags.urg_data_pending = 1; in smc_tx_sendmsg()
166 if (!atomic_read(&conn->sndbuf_space) || conn->urg_tx_pend) { in smc_tx_sendmsg()
177 writespace = atomic_read(&conn->sndbuf_space); in smc_tx_sendmsg()
181 sndbuf_base = conn->sndbuf_desc->cpu_addr; in smc_tx_sendmsg()
182 smc_curs_copy(&prep, &conn->tx_curs_prep, conn); in smc_tx_sendmsg()
186 chunk_len = min_t(size_t, copylen, conn->sndbuf_desc->len - in smc_tx_sendmsg()
190 smc_sndbuf_sync_sg_for_cpu(conn); in smc_tx_sendmsg()
195 smc_sndbuf_sync_sg_for_device(conn); in smc_tx_sendmsg()
210 smc_sndbuf_sync_sg_for_device(conn); in smc_tx_sendmsg()
212 smc_curs_add(conn->sndbuf_desc->len, &prep, copylen); in smc_tx_sendmsg()
213 smc_curs_copy(&conn->tx_curs_prep, &prep, conn); in smc_tx_sendmsg()
216 atomic_sub(copylen, &conn->sndbuf_space); in smc_tx_sendmsg()
223 conn->urg_tx_pend = true; in smc_tx_sendmsg()
225 (atomic_read(&conn->sndbuf_space) > in smc_tx_sendmsg()
226 (conn->sndbuf_desc->len >> 1))) in smc_tx_sendmsg()
230 schedule_delayed_work(&conn->tx_work, in smc_tx_sendmsg()
233 smc_tx_sndbuf_nonempty(conn); in smc_tx_sendmsg()
249 int smcd_tx_ism_write(struct smc_connection *conn, void *data, size_t len, in smcd_tx_ism_write() argument
256 pos.token = conn->peer_token; in smcd_tx_ism_write()
257 pos.index = conn->peer_rmbe_idx; in smcd_tx_ism_write()
258 pos.offset = conn->tx_off + offset; in smcd_tx_ism_write()
260 rc = smc_ism_write(conn->lgr->smcd, &pos, data, len); in smcd_tx_ism_write()
262 conn->local_tx_ctrl.conn_state_flags.peer_conn_abort = 1; in smcd_tx_ism_write()
267 static int smc_tx_rdma_write(struct smc_connection *conn, int peer_rmbe_offset, in smc_tx_rdma_write() argument
270 struct smc_link_group *lgr = conn->lgr; in smc_tx_rdma_write()
278 lgr->rtokens[conn->rtoken_idx][SMC_SINGLE_LINK].dma_addr + in smc_tx_rdma_write()
280 conn->tx_off + in smc_tx_rdma_write()
283 rdma_wr->rkey = lgr->rtokens[conn->rtoken_idx][SMC_SINGLE_LINK].rkey; in smc_tx_rdma_write()
286 conn->local_tx_ctrl.conn_state_flags.peer_conn_abort = 1; in smc_tx_rdma_write()
293 static inline void smc_tx_advance_cursors(struct smc_connection *conn, in smc_tx_advance_cursors() argument
298 smc_curs_add(conn->peer_rmbe_size, prod, len); in smc_tx_advance_cursors()
302 atomic_sub(len, &conn->peer_rmbe_space); in smc_tx_advance_cursors()
305 smc_curs_add(conn->sndbuf_desc->len, sent, len); in smc_tx_advance_cursors()
309 static int smcr_tx_rdma_writes(struct smc_connection *conn, size_t len, in smcr_tx_rdma_writes() argument
315 sg_dma_address(conn->sndbuf_desc->sgt[SMC_SINGLE_LINK].sgl); in smcr_tx_rdma_writes()
333 if (src_off >= conn->sndbuf_desc->len) in smcr_tx_rdma_writes()
334 src_off -= conn->sndbuf_desc->len; in smcr_tx_rdma_writes()
342 rc = smc_tx_rdma_write(conn, dst_off, num_sges, in smcr_tx_rdma_writes()
352 src_len = min_t(int, dst_len, conn->sndbuf_desc->len - in smcr_tx_rdma_writes()
360 static int smcd_tx_rdma_writes(struct smc_connection *conn, size_t len, in smcd_tx_rdma_writes() argument
370 void *data = conn->sndbuf_desc->cpu_addr + src_off; in smcd_tx_rdma_writes()
372 rc = smcd_tx_ism_write(conn, data, src_len, dst_off + in smcd_tx_rdma_writes()
378 if (src_off >= conn->sndbuf_desc->len) in smcd_tx_rdma_writes()
379 src_off -= conn->sndbuf_desc->len; in smcd_tx_rdma_writes()
393 src_len = min_t(int, dst_len, conn->sndbuf_desc->len - src_off); in smcd_tx_rdma_writes()
402 static int smc_tx_rdma_writes(struct smc_connection *conn, in smc_tx_rdma_writes() argument
412 smc_curs_copy(&sent, &conn->tx_curs_sent, conn); in smc_tx_rdma_writes()
413 smc_curs_copy(&prep, &conn->tx_curs_prep, conn); in smc_tx_rdma_writes()
415 to_send = smc_curs_diff(conn->sndbuf_desc->len, &sent, &prep); in smc_tx_rdma_writes()
421 rmbespace = atomic_read(&conn->peer_rmbe_space); in smc_tx_rdma_writes()
424 smc_curs_copy(&prod, &conn->local_tx_ctrl.prod, conn); in smc_tx_rdma_writes()
425 smc_curs_copy(&cons, &conn->local_rx_ctrl.cons, conn); in smc_tx_rdma_writes()
428 pflags = &conn->local_tx_ctrl.prod_flags; in smc_tx_rdma_writes()
442 conn->peer_rmbe_size - prod.count, len); in smc_tx_rdma_writes()
451 if (sent.count + dst_len <= conn->sndbuf_desc->len) { in smc_tx_rdma_writes()
456 src_len = conn->sndbuf_desc->len - sent.count; in smc_tx_rdma_writes()
459 if (conn->lgr->is_smcd) in smc_tx_rdma_writes()
460 rc = smcd_tx_rdma_writes(conn, len, sent.count, src_len, in smc_tx_rdma_writes()
463 rc = smcr_tx_rdma_writes(conn, len, sent.count, src_len, in smc_tx_rdma_writes()
468 if (conn->urg_tx_pend && len == to_send) in smc_tx_rdma_writes()
470 smc_tx_advance_cursors(conn, &prod, &sent, len); in smc_tx_rdma_writes()
472 smc_curs_copy(&conn->local_tx_ctrl.prod, &prod, conn); in smc_tx_rdma_writes()
474 smc_curs_copy(&conn->tx_curs_sent, &sent, conn);/* src: local sndbuf */ in smc_tx_rdma_writes()
482 static int smcr_tx_sndbuf_nonempty(struct smc_connection *conn) in smcr_tx_sndbuf_nonempty() argument
484 struct smc_cdc_producer_flags *pflags = &conn->local_tx_ctrl.prod_flags; in smcr_tx_sndbuf_nonempty()
490 rc = smc_cdc_get_free_slot(conn, &wr_buf, &wr_rdma_buf, &pend); in smcr_tx_sndbuf_nonempty()
494 container_of(conn, struct smc_sock, conn); in smcr_tx_sndbuf_nonempty()
499 if (conn->alert_token_local) /* connection healthy */ in smcr_tx_sndbuf_nonempty()
500 mod_delayed_work(system_wq, &conn->tx_work, in smcr_tx_sndbuf_nonempty()
506 spin_lock_bh(&conn->send_lock); in smcr_tx_sndbuf_nonempty()
508 rc = smc_tx_rdma_writes(conn, wr_rdma_buf); in smcr_tx_sndbuf_nonempty()
510 smc_wr_tx_put_slot(&conn->lgr->lnk[SMC_SINGLE_LINK], in smcr_tx_sndbuf_nonempty()
516 rc = smc_cdc_msg_send(conn, wr_buf, pend); in smcr_tx_sndbuf_nonempty()
523 spin_unlock_bh(&conn->send_lock); in smcr_tx_sndbuf_nonempty()
527 static int smcd_tx_sndbuf_nonempty(struct smc_connection *conn) in smcd_tx_sndbuf_nonempty() argument
529 struct smc_cdc_producer_flags *pflags = &conn->local_tx_ctrl.prod_flags; in smcd_tx_sndbuf_nonempty()
532 spin_lock_bh(&conn->send_lock); in smcd_tx_sndbuf_nonempty()
534 rc = smc_tx_rdma_writes(conn, NULL); in smcd_tx_sndbuf_nonempty()
536 rc = smcd_cdc_msg_send(conn); in smcd_tx_sndbuf_nonempty()
542 spin_unlock_bh(&conn->send_lock); in smcd_tx_sndbuf_nonempty()
546 int smc_tx_sndbuf_nonempty(struct smc_connection *conn) in smc_tx_sndbuf_nonempty() argument
550 if (conn->lgr->is_smcd) in smc_tx_sndbuf_nonempty()
551 rc = smcd_tx_sndbuf_nonempty(conn); in smc_tx_sndbuf_nonempty()
553 rc = smcr_tx_sndbuf_nonempty(conn); in smc_tx_sndbuf_nonempty()
557 struct smc_sock *smc = container_of(conn, struct smc_sock, in smc_tx_sndbuf_nonempty()
558 conn); in smc_tx_sndbuf_nonempty()
569 struct smc_connection *conn = container_of(to_delayed_work(work), in smc_tx_work() local
572 struct smc_sock *smc = container_of(conn, struct smc_sock, conn); in smc_tx_work()
577 !conn->alert_token_local || in smc_tx_work()
578 conn->local_rx_ctrl.conn_state_flags.peer_conn_abort) in smc_tx_work()
581 rc = smc_tx_sndbuf_nonempty(conn); in smc_tx_work()
582 if (!rc && conn->local_rx_ctrl.prod_flags.write_blocked && in smc_tx_work()
583 !atomic_read(&conn->bytes_to_rcv)) in smc_tx_work()
584 conn->local_rx_ctrl.prod_flags.write_blocked = 0; in smc_tx_work()
590 void smc_tx_consumer_update(struct smc_connection *conn, bool force) in smc_tx_consumer_update() argument
593 int sender_free = conn->rmb_desc->len; in smc_tx_consumer_update()
596 smc_curs_copy(&cons, &conn->local_tx_ctrl.cons, conn); in smc_tx_consumer_update()
597 smc_curs_copy(&cfed, &conn->rx_curs_confirmed, conn); in smc_tx_consumer_update()
598 to_confirm = smc_curs_diff(conn->rmb_desc->len, &cfed, &cons); in smc_tx_consumer_update()
599 if (to_confirm > conn->rmbe_update_limit) { in smc_tx_consumer_update()
600 smc_curs_copy(&prod, &conn->local_rx_ctrl.prod, conn); in smc_tx_consumer_update()
601 sender_free = conn->rmb_desc->len - in smc_tx_consumer_update()
602 smc_curs_diff_large(conn->rmb_desc->len, in smc_tx_consumer_update()
606 if (conn->local_rx_ctrl.prod_flags.cons_curs_upd_req || in smc_tx_consumer_update()
608 ((to_confirm > conn->rmbe_update_limit) && in smc_tx_consumer_update()
609 ((sender_free <= (conn->rmb_desc->len / 2)) || in smc_tx_consumer_update()
610 conn->local_rx_ctrl.prod_flags.write_blocked))) { in smc_tx_consumer_update()
611 if ((smc_cdc_get_slot_and_msg_send(conn) < 0) && in smc_tx_consumer_update()
612 conn->alert_token_local) { /* connection healthy */ in smc_tx_consumer_update()
613 schedule_delayed_work(&conn->tx_work, in smc_tx_consumer_update()
618 if (conn->local_rx_ctrl.prod_flags.write_blocked && in smc_tx_consumer_update()
619 !atomic_read(&conn->bytes_to_rcv)) in smc_tx_consumer_update()
620 conn->local_rx_ctrl.prod_flags.write_blocked = 0; in smc_tx_consumer_update()