Lines Matching full:smc
3 * Shared Memory Communications over RDMA (SMC-R) and RoCE
18 #include "smc.h"
24 void smc_clcsock_release(struct smc_sock *smc) in smc_clcsock_release() argument
28 if (smc->listen_smc && current_work() != &smc->smc_listen_work) in smc_clcsock_release()
29 cancel_work_sync(&smc->smc_listen_work); in smc_clcsock_release()
30 mutex_lock(&smc->clcsock_release_lock); in smc_clcsock_release()
31 if (smc->clcsock) { in smc_clcsock_release()
32 tcp = smc->clcsock; in smc_clcsock_release()
33 smc->clcsock = NULL; in smc_clcsock_release()
36 mutex_unlock(&smc->clcsock_release_lock); in smc_clcsock_release()
49 static void smc_close_stream_wait(struct smc_sock *smc, long timeout) in smc_close_stream_wait() argument
52 struct sock *sk = &smc->sk; in smc_close_stream_wait()
57 if (!smc_tx_prepared_sends(&smc->conn)) in smc_close_stream_wait()
61 smc_tx_pending(&smc->conn); in smc_close_stream_wait()
63 smc->wait_close_tx_prepared = 1; in smc_close_stream_wait()
69 !smc_tx_prepared_sends(&smc->conn) || in smc_close_stream_wait()
72 smc->conn.killed, in smc_close_stream_wait()
78 smc->wait_close_tx_prepared = 0; in smc_close_stream_wait()
81 void smc_close_wake_tx_prepared(struct smc_sock *smc) in smc_close_wake_tx_prepared() argument
83 if (smc->wait_close_tx_prepared) in smc_close_wake_tx_prepared()
85 smc->sk.sk_state_change(&smc->sk); in smc_close_wake_tx_prepared()
114 static void smc_close_cancel_work(struct smc_sock *smc) in smc_close_cancel_work() argument
116 struct sock *sk = &smc->sk; in smc_close_cancel_work()
119 cancel_work_sync(&smc->conn.close_work); in smc_close_cancel_work()
120 cancel_delayed_work_sync(&smc->conn.tx_work); in smc_close_cancel_work()
124 /* terminate smc socket abnormally - active abort
127 void smc_close_active_abort(struct smc_sock *smc) in smc_close_active_abort() argument
129 struct sock *sk = &smc->sk; in smc_close_active_abort()
132 if (sk->sk_state != SMC_INIT && smc->clcsock && smc->clcsock->sk) { in smc_close_active_abort()
134 if (smc->clcsock && smc->clcsock->sk) in smc_close_active_abort()
135 tcp_abort(smc->clcsock->sk, ECONNABORTED); in smc_close_active_abort()
142 smc_close_cancel_work(smc); in smc_close_active_abort()
152 smc_close_cancel_work(smc); in smc_close_active_abort()
156 smc_conn_free(&smc->conn); in smc_close_active_abort()
163 smc_close_cancel_work(smc); in smc_close_active_abort()
167 smc_conn_free(&smc->conn); in smc_close_active_abort()
181 smc_clcsock_release(smc); in smc_close_active_abort()
192 int smc_close_active(struct smc_sock *smc) in smc_close_active() argument
195 &smc->conn.local_tx_ctrl.conn_state_flags; in smc_close_active()
196 struct smc_connection *conn = &smc->conn; in smc_close_active()
197 struct sock *sk = &smc->sk; in smc_close_active()
216 if (smc->clcsock && smc->clcsock->sk) { in smc_close_active()
217 write_lock_bh(&smc->clcsock->sk->sk_callback_lock); in smc_close_active()
218 smc_clcsock_restore_cb(&smc->clcsock->sk->sk_data_ready, in smc_close_active()
219 &smc->clcsk_data_ready); in smc_close_active()
220 smc->clcsock->sk->sk_user_data = NULL; in smc_close_active()
221 write_unlock_bh(&smc->clcsock->sk->sk_callback_lock); in smc_close_active()
222 rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR); in smc_close_active()
226 flush_work(&smc->tcp_listen_work); in smc_close_active()
230 smc_close_stream_wait(smc, timeout); in smc_close_active()
242 if (smc->clcsock && smc->clcsock->sk) { in smc_close_active()
243 rc1 = kernel_sock_shutdown(smc->clcsock, in smc_close_active()
264 smc_close_stream_wait(smc, timeout); in smc_close_active()
311 static void smc_close_passive_abort_received(struct smc_sock *smc) in smc_close_passive_abort_received() argument
314 &smc->conn.local_tx_ctrl.conn_state_flags; in smc_close_passive_abort_received()
315 struct sock *sk = &smc->sk; in smc_close_passive_abort_received()
330 !smc_close_sent_any_close(&smc->conn)) in smc_close_passive_abort_received()
360 struct smc_sock *smc = container_of(conn, struct smc_sock, conn); in smc_close_passive_work() local
363 struct sock *sk = &smc->sk; in smc_close_passive_work()
372 smc_close_passive_abort_received(smc); in smc_close_passive_work()
436 if (smc->clcsock) in smc_close_passive_work()
442 smc_clcsock_release(smc); in smc_close_passive_work()
446 int smc_close_shutdown_write(struct smc_sock *smc) in smc_close_shutdown_write() argument
448 struct smc_connection *conn = &smc->conn; in smc_close_shutdown_write()
449 struct sock *sk = &smc->sk; in smc_close_shutdown_write()
462 smc_close_stream_wait(smc, timeout); in smc_close_shutdown_write()
475 smc_close_stream_wait(smc, timeout); in smc_close_shutdown_write()
502 void smc_close_init(struct smc_sock *smc) in smc_close_init() argument
504 INIT_WORK(&smc->conn.close_work, smc_close_passive_work); in smc_close_init()