Lines Matching refs:conn

49 	if (atomic_read(&smc->conn.sndbuf_space) && sock) {  in smc_tx_write_space()
51 SMC_STAT_RMB_TX_FULL(smc, !smc->conn.lnk); in smc_tx_write_space()
81 struct smc_connection *conn = &smc->conn; in smc_tx_wait() local
93 conn->killed || in smc_tx_wait()
94 conn->local_tx_ctrl.conn_state_flags.peer_done_writing) { in smc_tx_wait()
98 if (smc_cdc_rxed_any_close(conn)) { in smc_tx_wait()
113 if (atomic_read(&conn->sndbuf_space) && !conn->urg_tx_pend) in smc_tx_wait()
119 smc_cdc_rxed_any_close(conn) || in smc_tx_wait()
120 (atomic_read(&conn->sndbuf_space) && in smc_tx_wait()
121 !conn->urg_tx_pend), in smc_tx_wait()
142 struct smc_connection *conn = &smc->conn; in smc_tx_sendmsg() local
161 if (len > conn->sndbuf_desc->len) in smc_tx_sendmsg()
162 SMC_STAT_RMB_TX_SIZE_SMALL(smc, !conn->lnk); in smc_tx_sendmsg()
164 if (len > conn->peer_rmbe_size) in smc_tx_sendmsg()
165 SMC_STAT_RMB_TX_PEER_SIZE_SMALL(smc, !conn->lnk); in smc_tx_sendmsg()
173 conn->killed) in smc_tx_sendmsg()
175 if (smc_cdc_rxed_any_close(conn)) in smc_tx_sendmsg()
179 conn->local_tx_ctrl.prod_flags.urg_data_pending = 1; in smc_tx_sendmsg()
181 if (!atomic_read(&conn->sndbuf_space) || conn->urg_tx_pend) { in smc_tx_sendmsg()
192 writespace = atomic_read(&conn->sndbuf_space); in smc_tx_sendmsg()
196 sndbuf_base = conn->sndbuf_desc->cpu_addr; in smc_tx_sendmsg()
197 smc_curs_copy(&prep, &conn->tx_curs_prep, conn); in smc_tx_sendmsg()
201 chunk_len = min_t(size_t, copylen, conn->sndbuf_desc->len - in smc_tx_sendmsg()
205 smc_sndbuf_sync_sg_for_cpu(conn); in smc_tx_sendmsg()
210 smc_sndbuf_sync_sg_for_device(conn); in smc_tx_sendmsg()
225 smc_sndbuf_sync_sg_for_device(conn); in smc_tx_sendmsg()
227 smc_curs_add(conn->sndbuf_desc->len, &prep, copylen); in smc_tx_sendmsg()
228 smc_curs_copy(&conn->tx_curs_prep, &prep, conn); in smc_tx_sendmsg()
231 atomic_sub(copylen, &conn->sndbuf_space); in smc_tx_sendmsg()
238 conn->urg_tx_pend = true; in smc_tx_sendmsg()
240 (atomic_read(&conn->sndbuf_space) > in smc_tx_sendmsg()
241 (conn->sndbuf_desc->len >> 1))) in smc_tx_sendmsg()
245 queue_delayed_work(conn->lgr->tx_wq, &conn->tx_work, in smc_tx_sendmsg()
248 smc_tx_sndbuf_nonempty(conn); in smc_tx_sendmsg()
266 int smcd_tx_ism_write(struct smc_connection *conn, void *data, size_t len, in smcd_tx_ism_write() argument
273 pos.token = conn->peer_token; in smcd_tx_ism_write()
274 pos.index = conn->peer_rmbe_idx; in smcd_tx_ism_write()
275 pos.offset = conn->tx_off + offset; in smcd_tx_ism_write()
277 rc = smc_ism_write(conn->lgr->smcd, &pos, data, len); in smcd_tx_ism_write()
279 conn->local_tx_ctrl.conn_state_flags.peer_conn_abort = 1; in smcd_tx_ism_write()
284 static int smc_tx_rdma_write(struct smc_connection *conn, int peer_rmbe_offset, in smc_tx_rdma_write() argument
287 struct smc_link_group *lgr = conn->lgr; in smc_tx_rdma_write()
288 struct smc_link *link = conn->lnk; in smc_tx_rdma_write()
294 lgr->rtokens[conn->rtoken_idx][link->link_idx].dma_addr + in smc_tx_rdma_write()
296 conn->tx_off + in smc_tx_rdma_write()
299 rdma_wr->rkey = lgr->rtokens[conn->rtoken_idx][link->link_idx].rkey; in smc_tx_rdma_write()
307 static inline void smc_tx_advance_cursors(struct smc_connection *conn, in smc_tx_advance_cursors() argument
312 smc_curs_add(conn->peer_rmbe_size, prod, len); in smc_tx_advance_cursors()
316 atomic_sub(len, &conn->peer_rmbe_space); in smc_tx_advance_cursors()
319 smc_curs_add(conn->sndbuf_desc->len, sent, len); in smc_tx_advance_cursors()
323 static int smcr_tx_rdma_writes(struct smc_connection *conn, size_t len, in smcr_tx_rdma_writes() argument
328 struct smc_link *link = conn->lnk; in smcr_tx_rdma_writes()
331 sg_dma_address(conn->sndbuf_desc->sgt[link->link_idx].sgl); in smcr_tx_rdma_writes()
349 if (src_off >= conn->sndbuf_desc->len) in smcr_tx_rdma_writes()
350 src_off -= conn->sndbuf_desc->len; in smcr_tx_rdma_writes()
358 rc = smc_tx_rdma_write(conn, dst_off, num_sges, in smcr_tx_rdma_writes()
368 src_len = min_t(int, dst_len, conn->sndbuf_desc->len - in smcr_tx_rdma_writes()
376 static int smcd_tx_rdma_writes(struct smc_connection *conn, size_t len, in smcd_tx_rdma_writes() argument
386 void *data = conn->sndbuf_desc->cpu_addr + src_off; in smcd_tx_rdma_writes()
388 rc = smcd_tx_ism_write(conn, data, src_len, dst_off + in smcd_tx_rdma_writes()
394 if (src_off >= conn->sndbuf_desc->len) in smcd_tx_rdma_writes()
395 src_off -= conn->sndbuf_desc->len; in smcd_tx_rdma_writes()
409 src_len = min_t(int, dst_len, conn->sndbuf_desc->len - src_off); in smcd_tx_rdma_writes()
418 static int smc_tx_rdma_writes(struct smc_connection *conn, in smc_tx_rdma_writes() argument
428 smc_curs_copy(&sent, &conn->tx_curs_sent, conn); in smc_tx_rdma_writes()
429 smc_curs_copy(&prep, &conn->tx_curs_prep, conn); in smc_tx_rdma_writes()
431 to_send = smc_curs_diff(conn->sndbuf_desc->len, &sent, &prep); in smc_tx_rdma_writes()
437 rmbespace = atomic_read(&conn->peer_rmbe_space); in smc_tx_rdma_writes()
439 struct smc_sock *smc = container_of(conn, struct smc_sock, in smc_tx_rdma_writes()
440 conn); in smc_tx_rdma_writes()
441 SMC_STAT_RMB_TX_PEER_FULL(smc, !conn->lnk); in smc_tx_rdma_writes()
444 smc_curs_copy(&prod, &conn->local_tx_ctrl.prod, conn); in smc_tx_rdma_writes()
445 smc_curs_copy(&cons, &conn->local_rx_ctrl.cons, conn); in smc_tx_rdma_writes()
448 pflags = &conn->local_tx_ctrl.prod_flags; in smc_tx_rdma_writes()
462 conn->peer_rmbe_size - prod.count, len); in smc_tx_rdma_writes()
471 if (sent.count + dst_len <= conn->sndbuf_desc->len) { in smc_tx_rdma_writes()
476 src_len = conn->sndbuf_desc->len - sent.count; in smc_tx_rdma_writes()
479 if (conn->lgr->is_smcd) in smc_tx_rdma_writes()
480 rc = smcd_tx_rdma_writes(conn, len, sent.count, src_len, in smc_tx_rdma_writes()
483 rc = smcr_tx_rdma_writes(conn, len, sent.count, src_len, in smc_tx_rdma_writes()
488 if (conn->urg_tx_pend && len == to_send) in smc_tx_rdma_writes()
490 smc_tx_advance_cursors(conn, &prod, &sent, len); in smc_tx_rdma_writes()
492 smc_curs_copy(&conn->local_tx_ctrl.prod, &prod, conn); in smc_tx_rdma_writes()
494 smc_curs_copy(&conn->tx_curs_sent, &sent, conn);/* src: local sndbuf */ in smc_tx_rdma_writes()
502 static int smcr_tx_sndbuf_nonempty(struct smc_connection *conn) in smcr_tx_sndbuf_nonempty() argument
504 struct smc_cdc_producer_flags *pflags = &conn->local_tx_ctrl.prod_flags; in smcr_tx_sndbuf_nonempty()
505 struct smc_link *link = conn->lnk; in smcr_tx_sndbuf_nonempty()
513 rc = smc_cdc_get_free_slot(conn, link, &wr_buf, &wr_rdma_buf, &pend); in smcr_tx_sndbuf_nonempty()
518 container_of(conn, struct smc_sock, conn); in smcr_tx_sndbuf_nonempty()
522 if (conn->killed) in smcr_tx_sndbuf_nonempty()
525 mod_delayed_work(conn->lgr->tx_wq, &conn->tx_work, in smcr_tx_sndbuf_nonempty()
531 spin_lock_bh(&conn->send_lock); in smcr_tx_sndbuf_nonempty()
532 if (link != conn->lnk) { in smcr_tx_sndbuf_nonempty()
540 rc = smc_tx_rdma_writes(conn, wr_rdma_buf); in smcr_tx_sndbuf_nonempty()
548 rc = smc_cdc_msg_send(conn, wr_buf, pend); in smcr_tx_sndbuf_nonempty()
555 spin_unlock_bh(&conn->send_lock); in smcr_tx_sndbuf_nonempty()
560 static int smcd_tx_sndbuf_nonempty(struct smc_connection *conn) in smcd_tx_sndbuf_nonempty() argument
562 struct smc_cdc_producer_flags *pflags = &conn->local_tx_ctrl.prod_flags; in smcd_tx_sndbuf_nonempty()
565 spin_lock_bh(&conn->send_lock); in smcd_tx_sndbuf_nonempty()
567 rc = smc_tx_rdma_writes(conn, NULL); in smcd_tx_sndbuf_nonempty()
569 rc = smcd_cdc_msg_send(conn); in smcd_tx_sndbuf_nonempty()
575 spin_unlock_bh(&conn->send_lock); in smcd_tx_sndbuf_nonempty()
579 int smc_tx_sndbuf_nonempty(struct smc_connection *conn) in smc_tx_sndbuf_nonempty() argument
583 if (conn->killed || in smc_tx_sndbuf_nonempty()
584 conn->local_rx_ctrl.conn_state_flags.peer_conn_abort) in smc_tx_sndbuf_nonempty()
586 if (conn->lgr->is_smcd) in smc_tx_sndbuf_nonempty()
587 rc = smcd_tx_sndbuf_nonempty(conn); in smc_tx_sndbuf_nonempty()
589 rc = smcr_tx_sndbuf_nonempty(conn); in smc_tx_sndbuf_nonempty()
593 struct smc_sock *smc = container_of(conn, struct smc_sock, in smc_tx_sndbuf_nonempty()
594 conn); in smc_tx_sndbuf_nonempty()
605 struct smc_connection *conn = container_of(to_delayed_work(work), in smc_tx_work() local
608 struct smc_sock *smc = container_of(conn, struct smc_sock, conn); in smc_tx_work()
615 rc = smc_tx_sndbuf_nonempty(conn); in smc_tx_work()
616 if (!rc && conn->local_rx_ctrl.prod_flags.write_blocked && in smc_tx_work()
617 !atomic_read(&conn->bytes_to_rcv)) in smc_tx_work()
618 conn->local_rx_ctrl.prod_flags.write_blocked = 0; in smc_tx_work()
624 void smc_tx_consumer_update(struct smc_connection *conn, bool force) in smc_tx_consumer_update() argument
627 int sender_free = conn->rmb_desc->len; in smc_tx_consumer_update()
630 smc_curs_copy(&cons, &conn->local_tx_ctrl.cons, conn); in smc_tx_consumer_update()
631 smc_curs_copy(&cfed, &conn->rx_curs_confirmed, conn); in smc_tx_consumer_update()
632 to_confirm = smc_curs_diff(conn->rmb_desc->len, &cfed, &cons); in smc_tx_consumer_update()
633 if (to_confirm > conn->rmbe_update_limit) { in smc_tx_consumer_update()
634 smc_curs_copy(&prod, &conn->local_rx_ctrl.prod, conn); in smc_tx_consumer_update()
635 sender_free = conn->rmb_desc->len - in smc_tx_consumer_update()
636 smc_curs_diff_large(conn->rmb_desc->len, in smc_tx_consumer_update()
640 if (conn->local_rx_ctrl.prod_flags.cons_curs_upd_req || in smc_tx_consumer_update()
642 ((to_confirm > conn->rmbe_update_limit) && in smc_tx_consumer_update()
643 ((sender_free <= (conn->rmb_desc->len / 2)) || in smc_tx_consumer_update()
644 conn->local_rx_ctrl.prod_flags.write_blocked))) { in smc_tx_consumer_update()
645 if (conn->killed || in smc_tx_consumer_update()
646 conn->local_rx_ctrl.conn_state_flags.peer_conn_abort) in smc_tx_consumer_update()
648 if ((smc_cdc_get_slot_and_msg_send(conn) < 0) && in smc_tx_consumer_update()
649 !conn->killed) { in smc_tx_consumer_update()
650 queue_delayed_work(conn->lgr->tx_wq, &conn->tx_work, in smc_tx_consumer_update()
655 if (conn->local_rx_ctrl.prod_flags.write_blocked && in smc_tx_consumer_update()
656 !atomic_read(&conn->bytes_to_rcv)) in smc_tx_consumer_update()
657 conn->local_rx_ctrl.prod_flags.write_blocked = 0; in smc_tx_consumer_update()