Lines Matching refs:conn
46 if (atomic_read(&smc->conn.sndbuf_space) && sock) { in smc_tx_write_space()
76 struct smc_connection *conn = &smc->conn; in smc_tx_wait() local
90 conn->local_tx_ctrl.conn_state_flags.peer_done_writing) { in smc_tx_wait()
94 if (smc_cdc_rxed_any_close(conn)) { in smc_tx_wait()
109 if (atomic_read(&conn->sndbuf_space) && !conn->urg_tx_pend) in smc_tx_wait()
115 smc_cdc_rxed_any_close(conn) || in smc_tx_wait()
116 (atomic_read(&conn->sndbuf_space) && in smc_tx_wait()
117 !conn->urg_tx_pend), in smc_tx_wait()
138 struct smc_connection *conn = &smc->conn; in smc_tx_sendmsg() local
159 conn->local_tx_ctrl.conn_state_flags.peer_conn_abort) in smc_tx_sendmsg()
161 if (smc_cdc_rxed_any_close(conn)) in smc_tx_sendmsg()
165 conn->local_tx_ctrl.prod_flags.urg_data_pending = 1; in smc_tx_sendmsg()
167 if (!atomic_read(&conn->sndbuf_space) || conn->urg_tx_pend) { in smc_tx_sendmsg()
179 writespace = atomic_read(&conn->sndbuf_space); in smc_tx_sendmsg()
183 sndbuf_base = conn->sndbuf_desc->cpu_addr; in smc_tx_sendmsg()
184 smc_curs_copy(&prep, &conn->tx_curs_prep, conn); in smc_tx_sendmsg()
188 chunk_len = min_t(size_t, copylen, conn->sndbuf_desc->len - in smc_tx_sendmsg()
192 smc_sndbuf_sync_sg_for_cpu(conn); in smc_tx_sendmsg()
197 smc_sndbuf_sync_sg_for_device(conn); in smc_tx_sendmsg()
212 smc_sndbuf_sync_sg_for_device(conn); in smc_tx_sendmsg()
214 smc_curs_add(conn->sndbuf_desc->len, &prep, copylen); in smc_tx_sendmsg()
215 smc_curs_copy(&conn->tx_curs_prep, &prep, conn); in smc_tx_sendmsg()
218 atomic_sub(copylen, &conn->sndbuf_space); in smc_tx_sendmsg()
225 conn->urg_tx_pend = true; in smc_tx_sendmsg()
227 (atomic_read(&conn->sndbuf_space) > in smc_tx_sendmsg()
228 (conn->sndbuf_desc->len >> 1))) in smc_tx_sendmsg()
232 schedule_delayed_work(&conn->tx_work, in smc_tx_sendmsg()
235 smc_tx_sndbuf_nonempty(conn); in smc_tx_sendmsg()
251 int smcd_tx_ism_write(struct smc_connection *conn, void *data, size_t len, in smcd_tx_ism_write() argument
258 pos.token = conn->peer_token; in smcd_tx_ism_write()
259 pos.index = conn->peer_rmbe_idx; in smcd_tx_ism_write()
260 pos.offset = conn->tx_off + offset; in smcd_tx_ism_write()
262 rc = smc_ism_write(conn->lgr->smcd, &pos, data, len); in smcd_tx_ism_write()
264 conn->local_tx_ctrl.conn_state_flags.peer_conn_abort = 1; in smcd_tx_ism_write()
269 static int smc_tx_rdma_write(struct smc_connection *conn, int peer_rmbe_offset, in smc_tx_rdma_write() argument
272 struct smc_link_group *lgr = conn->lgr; in smc_tx_rdma_write()
284 lgr->rtokens[conn->rtoken_idx][SMC_SINGLE_LINK].dma_addr + in smc_tx_rdma_write()
286 conn->tx_off + in smc_tx_rdma_write()
289 rdma_wr.rkey = lgr->rtokens[conn->rtoken_idx][SMC_SINGLE_LINK].rkey; in smc_tx_rdma_write()
292 conn->local_tx_ctrl.conn_state_flags.peer_conn_abort = 1; in smc_tx_rdma_write()
299 static inline void smc_tx_advance_cursors(struct smc_connection *conn, in smc_tx_advance_cursors() argument
304 smc_curs_add(conn->peer_rmbe_size, prod, len); in smc_tx_advance_cursors()
308 atomic_sub(len, &conn->peer_rmbe_space); in smc_tx_advance_cursors()
311 smc_curs_add(conn->sndbuf_desc->len, sent, len); in smc_tx_advance_cursors()
315 static int smcr_tx_rdma_writes(struct smc_connection *conn, size_t len, in smcr_tx_rdma_writes() argument
320 sg_dma_address(conn->sndbuf_desc->sgt[SMC_SINGLE_LINK].sgl); in smcr_tx_rdma_writes()
321 struct smc_link *link = &conn->lgr->lnk[SMC_SINGLE_LINK]; in smcr_tx_rdma_writes()
338 if (src_off >= conn->sndbuf_desc->len) in smcr_tx_rdma_writes()
339 src_off -= conn->sndbuf_desc->len; in smcr_tx_rdma_writes()
347 rc = smc_tx_rdma_write(conn, dst_off, num_sges, sges); in smcr_tx_rdma_writes()
356 src_len = min_t(int, dst_len, conn->sndbuf_desc->len - in smcr_tx_rdma_writes()
364 static int smcd_tx_rdma_writes(struct smc_connection *conn, size_t len, in smcd_tx_rdma_writes() argument
374 void *data = conn->sndbuf_desc->cpu_addr + src_off; in smcd_tx_rdma_writes()
376 rc = smcd_tx_ism_write(conn, data, src_len, dst_off + in smcd_tx_rdma_writes()
382 if (src_off >= conn->sndbuf_desc->len) in smcd_tx_rdma_writes()
383 src_off -= conn->sndbuf_desc->len; in smcd_tx_rdma_writes()
397 src_len = min_t(int, dst_len, conn->sndbuf_desc->len - src_off); in smcd_tx_rdma_writes()
406 static int smc_tx_rdma_writes(struct smc_connection *conn) in smc_tx_rdma_writes() argument
415 smc_curs_copy(&sent, &conn->tx_curs_sent, conn); in smc_tx_rdma_writes()
416 smc_curs_copy(&prep, &conn->tx_curs_prep, conn); in smc_tx_rdma_writes()
418 to_send = smc_curs_diff(conn->sndbuf_desc->len, &sent, &prep); in smc_tx_rdma_writes()
424 rmbespace = atomic_read(&conn->peer_rmbe_space); in smc_tx_rdma_writes()
427 smc_curs_copy(&prod, &conn->local_tx_ctrl.prod, conn); in smc_tx_rdma_writes()
428 smc_curs_copy(&cons, &conn->local_rx_ctrl.cons, conn); in smc_tx_rdma_writes()
431 pflags = &conn->local_tx_ctrl.prod_flags; in smc_tx_rdma_writes()
445 conn->peer_rmbe_size - prod.count, len); in smc_tx_rdma_writes()
454 if (sent.count + dst_len <= conn->sndbuf_desc->len) { in smc_tx_rdma_writes()
459 src_len = conn->sndbuf_desc->len - sent.count; in smc_tx_rdma_writes()
462 if (conn->lgr->is_smcd) in smc_tx_rdma_writes()
463 rc = smcd_tx_rdma_writes(conn, len, sent.count, src_len, in smc_tx_rdma_writes()
466 rc = smcr_tx_rdma_writes(conn, len, sent.count, src_len, in smc_tx_rdma_writes()
471 if (conn->urg_tx_pend && len == to_send) in smc_tx_rdma_writes()
473 smc_tx_advance_cursors(conn, &prod, &sent, len); in smc_tx_rdma_writes()
475 smc_curs_copy(&conn->local_tx_ctrl.prod, &prod, conn); in smc_tx_rdma_writes()
477 smc_curs_copy(&conn->tx_curs_sent, &sent, conn);/* src: local sndbuf */ in smc_tx_rdma_writes()
485 static int smcr_tx_sndbuf_nonempty(struct smc_connection *conn) in smcr_tx_sndbuf_nonempty() argument
492 spin_lock_bh(&conn->send_lock); in smcr_tx_sndbuf_nonempty()
493 rc = smc_cdc_get_free_slot(conn, &wr_buf, &pend); in smcr_tx_sndbuf_nonempty()
497 container_of(conn, struct smc_sock, conn); in smcr_tx_sndbuf_nonempty()
504 if (conn->alert_token_local) /* connection healthy */ in smcr_tx_sndbuf_nonempty()
505 mod_delayed_work(system_wq, &conn->tx_work, in smcr_tx_sndbuf_nonempty()
511 if (!conn->local_tx_ctrl.prod_flags.urg_data_present) { in smcr_tx_sndbuf_nonempty()
512 rc = smc_tx_rdma_writes(conn); in smcr_tx_sndbuf_nonempty()
514 smc_wr_tx_put_slot(&conn->lgr->lnk[SMC_SINGLE_LINK], in smcr_tx_sndbuf_nonempty()
520 rc = smc_cdc_msg_send(conn, wr_buf, pend); in smcr_tx_sndbuf_nonempty()
521 pflags = &conn->local_tx_ctrl.prod_flags; in smcr_tx_sndbuf_nonempty()
528 spin_unlock_bh(&conn->send_lock); in smcr_tx_sndbuf_nonempty()
532 static int smcd_tx_sndbuf_nonempty(struct smc_connection *conn) in smcd_tx_sndbuf_nonempty() argument
534 struct smc_cdc_producer_flags *pflags = &conn->local_tx_ctrl.prod_flags; in smcd_tx_sndbuf_nonempty()
537 spin_lock_bh(&conn->send_lock); in smcd_tx_sndbuf_nonempty()
539 rc = smc_tx_rdma_writes(conn); in smcd_tx_sndbuf_nonempty()
541 rc = smcd_cdc_msg_send(conn); in smcd_tx_sndbuf_nonempty()
547 spin_unlock_bh(&conn->send_lock); in smcd_tx_sndbuf_nonempty()
551 int smc_tx_sndbuf_nonempty(struct smc_connection *conn) in smc_tx_sndbuf_nonempty() argument
555 if (conn->lgr->is_smcd) in smc_tx_sndbuf_nonempty()
556 rc = smcd_tx_sndbuf_nonempty(conn); in smc_tx_sndbuf_nonempty()
558 rc = smcr_tx_sndbuf_nonempty(conn); in smc_tx_sndbuf_nonempty()
568 struct smc_connection *conn = container_of(to_delayed_work(work), in smc_tx_work() local
571 struct smc_sock *smc = container_of(conn, struct smc_sock, conn); in smc_tx_work()
576 !conn->alert_token_local || in smc_tx_work()
577 conn->local_rx_ctrl.conn_state_flags.peer_conn_abort) in smc_tx_work()
580 rc = smc_tx_sndbuf_nonempty(conn); in smc_tx_work()
581 if (!rc && conn->local_rx_ctrl.prod_flags.write_blocked && in smc_tx_work()
582 !atomic_read(&conn->bytes_to_rcv)) in smc_tx_work()
583 conn->local_rx_ctrl.prod_flags.write_blocked = 0; in smc_tx_work()
589 void smc_tx_consumer_update(struct smc_connection *conn, bool force) in smc_tx_consumer_update() argument
592 int sender_free = conn->rmb_desc->len; in smc_tx_consumer_update()
595 smc_curs_copy(&cons, &conn->local_tx_ctrl.cons, conn); in smc_tx_consumer_update()
596 smc_curs_copy(&cfed, &conn->rx_curs_confirmed, conn); in smc_tx_consumer_update()
597 to_confirm = smc_curs_diff(conn->rmb_desc->len, &cfed, &cons); in smc_tx_consumer_update()
598 if (to_confirm > conn->rmbe_update_limit) { in smc_tx_consumer_update()
599 smc_curs_copy(&prod, &conn->local_rx_ctrl.prod, conn); in smc_tx_consumer_update()
600 sender_free = conn->rmb_desc->len - in smc_tx_consumer_update()
601 smc_curs_diff(conn->rmb_desc->len, &prod, &cfed); in smc_tx_consumer_update()
604 if (conn->local_rx_ctrl.prod_flags.cons_curs_upd_req || in smc_tx_consumer_update()
606 ((to_confirm > conn->rmbe_update_limit) && in smc_tx_consumer_update()
607 ((sender_free <= (conn->rmb_desc->len / 2)) || in smc_tx_consumer_update()
608 conn->local_rx_ctrl.prod_flags.write_blocked))) { in smc_tx_consumer_update()
609 if ((smc_cdc_get_slot_and_msg_send(conn) < 0) && in smc_tx_consumer_update()
610 conn->alert_token_local) { /* connection healthy */ in smc_tx_consumer_update()
611 schedule_delayed_work(&conn->tx_work, in smc_tx_consumer_update()
615 smc_curs_copy(&conn->rx_curs_confirmed, in smc_tx_consumer_update()
616 &conn->local_tx_ctrl.cons, conn); in smc_tx_consumer_update()
617 conn->local_rx_ctrl.prod_flags.cons_curs_upd_req = 0; in smc_tx_consumer_update()
619 if (conn->local_rx_ctrl.prod_flags.write_blocked && in smc_tx_consumer_update()
620 !atomic_read(&conn->bytes_to_rcv)) in smc_tx_consumer_update()
621 conn->local_rx_ctrl.prod_flags.write_blocked = 0; in smc_tx_consumer_update()