• Home
  • Raw
  • Download

Lines Matching refs:smc

86 		       sock_net(skb->sk)->smc.limit_smc_hs))  in smc_nl_dump_hs_limitation()
100 sock_net(skb->sk)->smc.limit_smc_hs = true; in smc_nl_enable_hs_limitation()
106 sock_net(skb->sk)->smc.limit_smc_hs = false; in smc_nl_disable_hs_limitation()
112 struct smc_sock *smc = smc_sk(sk); in smc_set_keepalive() local
114 smc->clcsock->sk->sk_prot->keepalive(smc->clcsock->sk, val); in smc_set_keepalive()
124 struct smc_sock *smc; in smc_tcp_syn_recv_sock() local
127 smc = smc_clcsock_user_data(sk); in smc_tcp_syn_recv_sock()
129 if (READ_ONCE(sk->sk_ack_backlog) + atomic_read(&smc->queued_smc_hs) > in smc_tcp_syn_recv_sock()
133 if (sk_acceptq_is_full(&smc->sk)) { in smc_tcp_syn_recv_sock()
139 child = smc->ori_af_ops->syn_recv_sock(sk, skb, req, dst, req_unhash, in smc_tcp_syn_recv_sock()
147 inet_csk(child)->icsk_af_ops = smc->ori_af_ops; in smc_tcp_syn_recv_sock()
159 const struct smc_sock *smc; in smc_hs_congested() local
161 smc = smc_clcsock_user_data(sk); in smc_hs_congested()
163 if (!smc) in smc_hs_congested()
213 struct smc_sock *smc = smc_sk(sk); in smc_release_cb() local
215 if (smc->conn.tx_in_release_sock) { in smc_release_cb()
216 smc_tx_pending(&smc->conn); in smc_release_cb()
217 smc->conn.tx_in_release_sock = false; in smc_release_cb()
247 static void smc_fback_restore_callbacks(struct smc_sock *smc) in smc_fback_restore_callbacks() argument
249 struct sock *clcsk = smc->clcsock->sk; in smc_fback_restore_callbacks()
254 smc_clcsock_restore_cb(&clcsk->sk_state_change, &smc->clcsk_state_change); in smc_fback_restore_callbacks()
255 smc_clcsock_restore_cb(&clcsk->sk_data_ready, &smc->clcsk_data_ready); in smc_fback_restore_callbacks()
256 smc_clcsock_restore_cb(&clcsk->sk_write_space, &smc->clcsk_write_space); in smc_fback_restore_callbacks()
257 smc_clcsock_restore_cb(&clcsk->sk_error_report, &smc->clcsk_error_report); in smc_fback_restore_callbacks()
262 static void smc_restore_fallback_changes(struct smc_sock *smc) in smc_restore_fallback_changes() argument
264 if (smc->clcsock->file) { /* non-accepted sockets have no file yet */ in smc_restore_fallback_changes()
265 smc->clcsock->file->private_data = smc->sk.sk_socket; in smc_restore_fallback_changes()
266 smc->clcsock->file = NULL; in smc_restore_fallback_changes()
267 smc_fback_restore_callbacks(smc); in smc_restore_fallback_changes()
271 static int __smc_release(struct smc_sock *smc) in __smc_release() argument
273 struct sock *sk = &smc->sk; in __smc_release()
276 if (!smc->use_fallback) { in __smc_release()
277 rc = smc_close_active(smc); in __smc_release()
287 rc = kernel_sock_shutdown(smc->clcsock, in __smc_release()
293 smc_restore_fallback_changes(smc); in __smc_release()
299 if (smc->clcsock) { in __smc_release()
301 smc_clcsock_release(smc); in __smc_release()
304 if (!smc->use_fallback) in __smc_release()
305 smc_conn_free(&smc->conn); in __smc_release()
314 struct smc_sock *smc; in smc_release() local
321 smc = smc_sk(sk); in smc_release()
326 if (smc->connect_nonblock && old_state == SMC_INIT) in smc_release()
327 tcp_abort(smc->clcsock->sk, ECONNABORTED); in smc_release()
329 if (cancel_work_sync(&smc->connect_work)) in smc_release()
330 sock_put(&smc->sk); /* sock_hold in smc_connect for passive closing */ in smc_release()
341 !smc->use_fallback) in smc_release()
342 smc_close_active_abort(smc); in smc_release()
344 rc = __smc_release(smc); in smc_release()
368 struct smc_sock *smc; in smc_sock_alloc() local
381 WRITE_ONCE(sk->sk_sndbuf, 2 * READ_ONCE(net->smc.sysctl_wmem)); in smc_sock_alloc()
382 WRITE_ONCE(sk->sk_rcvbuf, 2 * READ_ONCE(net->smc.sysctl_rmem)); in smc_sock_alloc()
383 smc = smc_sk(sk); in smc_sock_alloc()
384 INIT_WORK(&smc->tcp_listen_work, smc_tcp_listen_work); in smc_sock_alloc()
385 INIT_WORK(&smc->connect_work, smc_connect_work); in smc_sock_alloc()
386 INIT_DELAYED_WORK(&smc->conn.tx_work, smc_tx_work); in smc_sock_alloc()
387 INIT_LIST_HEAD(&smc->accept_q); in smc_sock_alloc()
388 spin_lock_init(&smc->accept_q_lock); in smc_sock_alloc()
389 spin_lock_init(&smc->conn.send_lock); in smc_sock_alloc()
391 mutex_init(&smc->clcsock_release_lock); in smc_sock_alloc()
392 smc_init_saved_callbacks(smc); in smc_sock_alloc()
402 struct smc_sock *smc; in smc_bind() local
405 smc = smc_sk(sk); in smc_bind()
426 if (sk->sk_state != SMC_INIT || smc->connect_nonblock) in smc_bind()
429 smc->clcsock->sk->sk_reuse = sk->sk_reuse; in smc_bind()
430 smc->clcsock->sk->sk_reuseport = sk->sk_reuseport; in smc_bind()
431 rc = kernel_bind(smc->clcsock, uaddr, addr_len); in smc_bind()
489 static void smc_copy_sock_settings_to_clc(struct smc_sock *smc) in smc_copy_sock_settings_to_clc() argument
491 smc_copy_sock_settings(smc->clcsock->sk, &smc->sk, SK_FLAGS_SMC_TO_CLC); in smc_copy_sock_settings_to_clc()
499 static void smc_copy_sock_settings_to_smc(struct smc_sock *smc) in smc_copy_sock_settings_to_smc() argument
501 smc_copy_sock_settings(&smc->sk, smc->clcsock->sk, SK_FLAGS_CLC_TO_SMC); in smc_copy_sock_settings_to_smc()
577 static int smcr_clnt_conf_first_link(struct smc_sock *smc) in smcr_clnt_conf_first_link() argument
579 struct smc_link *link = smc->conn.lnk; in smcr_clnt_conf_first_link()
593 rc = smc_clc_wait_msg(smc, &dclc, sizeof(dclc), in smcr_clnt_conf_first_link()
610 if (smc->conn.sndbuf_desc->is_vm) { in smcr_clnt_conf_first_link()
611 if (smcr_link_reg_buf(link, smc->conn.sndbuf_desc)) in smcr_clnt_conf_first_link()
616 if (smcr_link_reg_buf(link, smc->conn.rmb_desc)) in smcr_clnt_conf_first_link()
620 smc->conn.rmb_desc->is_conf_rkey = true; in smcr_clnt_conf_first_link()
637 rc = smc_clc_wait_msg(smc, &dclc, sizeof(dclc), in smcr_clnt_conf_first_link()
659 static void smc_conn_save_peer_info_fce(struct smc_sock *smc, in smc_conn_save_peer_info_fce() argument
671 if (smc->conn.lgr->is_smcd) { in smc_conn_save_peer_info_fce()
672 memcpy(smc->conn.lgr->negotiated_eid, clc_v2->d1.eid, in smc_conn_save_peer_info_fce()
677 memcpy(smc->conn.lgr->negotiated_eid, clc_v2->r1.eid, in smc_conn_save_peer_info_fce()
683 smc->conn.lgr->peer_os = fce->os_type; in smc_conn_save_peer_info_fce()
684 smc->conn.lgr->peer_smc_release = fce->release; in smc_conn_save_peer_info_fce()
686 memcpy(smc->conn.lgr->peer_hostname, fce->hostname, in smc_conn_save_peer_info_fce()
690 static void smcr_conn_save_peer_info(struct smc_sock *smc, in smcr_conn_save_peer_info() argument
695 smc->conn.peer_rmbe_idx = clc->r0.rmbe_idx; in smcr_conn_save_peer_info()
696 smc->conn.local_tx_ctrl.token = ntohl(clc->r0.rmbe_alert_token); in smcr_conn_save_peer_info()
697 smc->conn.peer_rmbe_size = bufsize; in smcr_conn_save_peer_info()
698 atomic_set(&smc->conn.peer_rmbe_space, smc->conn.peer_rmbe_size); in smcr_conn_save_peer_info()
699 smc->conn.tx_off = bufsize * (smc->conn.peer_rmbe_idx - 1); in smcr_conn_save_peer_info()
702 static void smcd_conn_save_peer_info(struct smc_sock *smc, in smcd_conn_save_peer_info() argument
707 smc->conn.peer_rmbe_idx = clc->d0.dmbe_idx; in smcd_conn_save_peer_info()
708 smc->conn.peer_token = ntohll(clc->d0.token); in smcd_conn_save_peer_info()
710 smc->conn.peer_rmbe_size = bufsize - sizeof(struct smcd_cdc_msg); in smcd_conn_save_peer_info()
711 atomic_set(&smc->conn.peer_rmbe_space, smc->conn.peer_rmbe_size); in smcd_conn_save_peer_info()
712 smc->conn.tx_off = bufsize * smc->conn.peer_rmbe_idx; in smcd_conn_save_peer_info()
715 static void smc_conn_save_peer_info(struct smc_sock *smc, in smc_conn_save_peer_info() argument
718 if (smc->conn.lgr->is_smcd) in smc_conn_save_peer_info()
719 smcd_conn_save_peer_info(smc, clc); in smc_conn_save_peer_info()
721 smcr_conn_save_peer_info(smc, clc); in smc_conn_save_peer_info()
722 smc_conn_save_peer_info_fce(smc, clc); in smc_conn_save_peer_info()
736 static void smc_stat_inc_fback_rsn_cnt(struct smc_sock *smc, in smc_stat_inc_fback_rsn_cnt() argument
742 if (fback_arr[cnt].fback_code == smc->fallback_rsn) { in smc_stat_inc_fback_rsn_cnt()
747 fback_arr[cnt].fback_code = smc->fallback_rsn; in smc_stat_inc_fback_rsn_cnt()
754 static void smc_stat_fallback(struct smc_sock *smc) in smc_stat_fallback() argument
756 struct net *net = sock_net(&smc->sk); in smc_stat_fallback()
758 mutex_lock(&net->smc.mutex_fback_rsn); in smc_stat_fallback()
759 if (smc->listen_smc) { in smc_stat_fallback()
760 smc_stat_inc_fback_rsn_cnt(smc, net->smc.fback_rsn->srv); in smc_stat_fallback()
761 net->smc.fback_rsn->srv_fback_cnt++; in smc_stat_fallback()
763 smc_stat_inc_fback_rsn_cnt(smc, net->smc.fback_rsn->clnt); in smc_stat_fallback()
764 net->smc.fback_rsn->clnt_fback_cnt++; in smc_stat_fallback()
766 mutex_unlock(&net->smc.mutex_fback_rsn); in smc_stat_fallback()
770 static void smc_fback_wakeup_waitqueue(struct smc_sock *smc, void *key) in smc_fback_wakeup_waitqueue() argument
775 wq = rcu_dereference(smc->sk.sk_wq); in smc_fback_wakeup_waitqueue()
805 static void smc_fback_forward_wakeup(struct smc_sock *smc, struct sock *clcsk, in smc_fback_forward_wakeup() argument
822 smc_fback_wakeup_waitqueue(smc, mark.key); in smc_fback_forward_wakeup()
829 struct smc_sock *smc; in smc_fback_state_change() local
832 smc = smc_clcsock_user_data(clcsk); in smc_fback_state_change()
833 if (smc) in smc_fback_state_change()
834 smc_fback_forward_wakeup(smc, clcsk, in smc_fback_state_change()
835 smc->clcsk_state_change); in smc_fback_state_change()
841 struct smc_sock *smc; in smc_fback_data_ready() local
844 smc = smc_clcsock_user_data(clcsk); in smc_fback_data_ready()
845 if (smc) in smc_fback_data_ready()
846 smc_fback_forward_wakeup(smc, clcsk, in smc_fback_data_ready()
847 smc->clcsk_data_ready); in smc_fback_data_ready()
853 struct smc_sock *smc; in smc_fback_write_space() local
856 smc = smc_clcsock_user_data(clcsk); in smc_fback_write_space()
857 if (smc) in smc_fback_write_space()
858 smc_fback_forward_wakeup(smc, clcsk, in smc_fback_write_space()
859 smc->clcsk_write_space); in smc_fback_write_space()
865 struct smc_sock *smc; in smc_fback_error_report() local
868 smc = smc_clcsock_user_data(clcsk); in smc_fback_error_report()
869 if (smc) in smc_fback_error_report()
870 smc_fback_forward_wakeup(smc, clcsk, in smc_fback_error_report()
871 smc->clcsk_error_report); in smc_fback_error_report()
875 static void smc_fback_replace_callbacks(struct smc_sock *smc) in smc_fback_replace_callbacks() argument
877 struct sock *clcsk = smc->clcsock->sk; in smc_fback_replace_callbacks()
880 clcsk->sk_user_data = (void *)((uintptr_t)smc | SK_USER_DATA_NOCOPY); in smc_fback_replace_callbacks()
883 &smc->clcsk_state_change); in smc_fback_replace_callbacks()
885 &smc->clcsk_data_ready); in smc_fback_replace_callbacks()
887 &smc->clcsk_write_space); in smc_fback_replace_callbacks()
889 &smc->clcsk_error_report); in smc_fback_replace_callbacks()
894 static int smc_switch_to_fallback(struct smc_sock *smc, int reason_code) in smc_switch_to_fallback() argument
898 mutex_lock(&smc->clcsock_release_lock); in smc_switch_to_fallback()
899 if (!smc->clcsock) { in smc_switch_to_fallback()
904 smc->use_fallback = true; in smc_switch_to_fallback()
905 smc->fallback_rsn = reason_code; in smc_switch_to_fallback()
906 smc_stat_fallback(smc); in smc_switch_to_fallback()
907 trace_smc_switch_to_fallback(smc, reason_code); in smc_switch_to_fallback()
908 if (smc->sk.sk_socket && smc->sk.sk_socket->file) { in smc_switch_to_fallback()
909 smc->clcsock->file = smc->sk.sk_socket->file; in smc_switch_to_fallback()
910 smc->clcsock->file->private_data = smc->clcsock; in smc_switch_to_fallback()
911 smc->clcsock->wq.fasync_list = in smc_switch_to_fallback()
912 smc->sk.sk_socket->wq.fasync_list; in smc_switch_to_fallback()
918 smc_fback_replace_callbacks(smc); in smc_switch_to_fallback()
921 mutex_unlock(&smc->clcsock_release_lock); in smc_switch_to_fallback()
926 static int smc_connect_fallback(struct smc_sock *smc, int reason_code) in smc_connect_fallback() argument
928 struct net *net = sock_net(&smc->sk); in smc_connect_fallback()
931 rc = smc_switch_to_fallback(smc, reason_code); in smc_connect_fallback()
933 this_cpu_inc(net->smc.smc_stats->clnt_hshake_err_cnt); in smc_connect_fallback()
934 if (smc->sk.sk_state == SMC_INIT) in smc_connect_fallback()
935 sock_put(&smc->sk); /* passive closing */ in smc_connect_fallback()
938 smc_copy_sock_settings_to_clc(smc); in smc_connect_fallback()
939 smc->connect_nonblock = 0; in smc_connect_fallback()
940 if (smc->sk.sk_state == SMC_INIT) in smc_connect_fallback()
941 smc->sk.sk_state = SMC_ACTIVE; in smc_connect_fallback()
946 static int smc_connect_decline_fallback(struct smc_sock *smc, int reason_code, in smc_connect_decline_fallback() argument
949 struct net *net = sock_net(&smc->sk); in smc_connect_decline_fallback()
953 this_cpu_inc(net->smc.smc_stats->clnt_hshake_err_cnt); in smc_connect_decline_fallback()
954 if (smc->sk.sk_state == SMC_INIT) in smc_connect_decline_fallback()
955 sock_put(&smc->sk); /* passive closing */ in smc_connect_decline_fallback()
959 rc = smc_clc_send_decline(smc, reason_code, version); in smc_connect_decline_fallback()
961 this_cpu_inc(net->smc.smc_stats->clnt_hshake_err_cnt); in smc_connect_decline_fallback()
962 if (smc->sk.sk_state == SMC_INIT) in smc_connect_decline_fallback()
963 sock_put(&smc->sk); /* passive closing */ in smc_connect_decline_fallback()
967 return smc_connect_fallback(smc, reason_code); in smc_connect_decline_fallback()
970 static void smc_conn_abort(struct smc_sock *smc, int local_first) in smc_conn_abort() argument
972 struct smc_connection *conn = &smc->conn; in smc_conn_abort()
986 static int smc_find_rdma_device(struct smc_sock *smc, struct smc_init_info *ini) in smc_find_rdma_device() argument
992 smc_pnet_find_roce_resource(smc->clcsock->sk, ini); in smc_find_rdma_device()
1002 static int smc_find_ism_device(struct smc_sock *smc, struct smc_init_info *ini) in smc_find_ism_device() argument
1005 smc_pnet_find_ism_resource(smc->clcsock->sk, ini); in smc_find_ism_device()
1028 static int smc_find_ism_v2_device_clnt(struct smc_sock *smc, in smc_find_ism_v2_device_clnt() argument
1046 smc_pnet_is_ndev_pnetid(sock_net(&smc->sk), smcd->pnetid)) { in smc_find_ism_v2_device_clnt()
1065 static int smc_connect_ism_vlan_setup(struct smc_sock *smc, in smc_connect_ism_vlan_setup() argument
1073 static int smc_find_proposal_devices(struct smc_sock *smc, in smc_find_proposal_devices() argument
1080 smc_find_ism_device(smc, ini) || in smc_find_proposal_devices()
1081 smc_connect_ism_vlan_setup(smc, ini)) in smc_find_proposal_devices()
1087 smc_find_rdma_device(smc, ini)) in smc_find_proposal_devices()
1097 smc_find_ism_v2_device_clnt(smc, ini)) in smc_find_proposal_devices()
1102 ini->smcrv2.saddr = smc->clcsock->sk->sk_rcv_saddr; in smc_find_proposal_devices()
1104 smc->clcsock->sk->sk_family != AF_INET || in smc_find_proposal_devices()
1106 smc_find_rdma_device(smc, ini)) in smc_find_proposal_devices()
1123 static int smc_connect_ism_vlan_cleanup(struct smc_sock *smc, in smc_connect_ism_vlan_cleanup() argument
1139 static int smc_connect_clc(struct smc_sock *smc, in smc_connect_clc() argument
1146 rc = smc_clc_send_proposal(smc, ini); in smc_connect_clc()
1150 return smc_clc_wait_msg(smc, aclc2, SMC_CLC_MAX_ACCEPT_LEN, in smc_connect_clc()
1182 static int smc_connect_rdma_v2_prepare(struct smc_sock *smc, in smc_connect_rdma_v2_prepare() argument
1190 struct net *net = sock_net(&smc->sk); in smc_connect_rdma_v2_prepare()
1200 if (smc_ib_find_route(net, smc->clcsock->sk->sk_rcv_saddr, in smc_connect_rdma_v2_prepare()
1220 static int smc_connect_rdma(struct smc_sock *smc, in smc_connect_rdma() argument
1237 reason_code = smc_connect_rdma_v2_prepare(smc, aclc, ini); in smc_connect_rdma()
1242 reason_code = smc_conn_create(smc, ini); in smc_connect_rdma()
1248 smc_conn_save_peer_info(smc, aclc); in smc_connect_rdma()
1251 link = smc->conn.lnk; in smc_connect_rdma()
1256 struct smc_link *l = &smc->conn.lgr->lnk[i]; in smc_connect_rdma()
1272 smc_switch_link_and_count(&smc->conn, link); in smc_connect_rdma()
1276 if (smc_buf_create(smc, false)) { in smc_connect_rdma()
1284 if (smc_rmb_rtoken_handling(&smc->conn, link, aclc)) { in smc_connect_rdma()
1289 smc_close_init(smc); in smc_connect_rdma()
1290 smc_rx_init(smc); in smc_connect_rdma()
1299 if (smc->conn.sndbuf_desc->is_vm) { in smc_connect_rdma()
1300 if (smcr_lgr_reg_sndbufs(link, smc->conn.sndbuf_desc)) { in smc_connect_rdma()
1305 if (smcr_lgr_reg_rmbs(link, smc->conn.rmb_desc)) { in smc_connect_rdma()
1321 reason_code = smc_clc_send_confirm(smc, ini->first_contact_local, in smc_connect_rdma()
1326 smc_tx_init(smc); in smc_connect_rdma()
1331 reason_code = smcr_clnt_conf_first_link(smc); in smc_connect_rdma()
1338 smc_copy_sock_settings_to_clc(smc); in smc_connect_rdma()
1339 smc->connect_nonblock = 0; in smc_connect_rdma()
1340 if (smc->sk.sk_state == SMC_INIT) in smc_connect_rdma()
1341 smc->sk.sk_state = SMC_ACTIVE; in smc_connect_rdma()
1345 smc_conn_abort(smc, ini->first_contact_local); in smc_connect_rdma()
1347 smc->connect_nonblock = 0; in smc_connect_rdma()
1372 static int smc_connect_ism(struct smc_sock *smc, in smc_connect_ism() argument
1404 rc = smc_conn_create(smc, ini); in smc_connect_ism()
1411 rc = smc_buf_create(smc, true); in smc_connect_ism()
1417 smc_conn_save_peer_info(smc, aclc); in smc_connect_ism()
1418 smc_close_init(smc); in smc_connect_ism()
1419 smc_rx_init(smc); in smc_connect_ism()
1420 smc_tx_init(smc); in smc_connect_ism()
1429 rc = smc_clc_send_confirm(smc, ini->first_contact_local, in smc_connect_ism()
1435 smc_copy_sock_settings_to_clc(smc); in smc_connect_ism()
1436 smc->connect_nonblock = 0; in smc_connect_ism()
1437 if (smc->sk.sk_state == SMC_INIT) in smc_connect_ism()
1438 smc->sk.sk_state = SMC_ACTIVE; in smc_connect_ism()
1442 smc_conn_abort(smc, ini->first_contact_local); in smc_connect_ism()
1444 smc->connect_nonblock = 0; in smc_connect_ism()
1475 static int __smc_connect(struct smc_sock *smc) in __smc_connect() argument
1484 if (smc->use_fallback) in __smc_connect()
1485 return smc_connect_fallback(smc, smc->fallback_rsn); in __smc_connect()
1488 if (!tcp_sk(smc->clcsock->sk)->syn_smc) in __smc_connect()
1489 return smc_connect_fallback(smc, SMC_CLC_DECL_PEERNOSMC); in __smc_connect()
1492 if (using_ipsec(smc)) in __smc_connect()
1493 return smc_connect_decline_fallback(smc, SMC_CLC_DECL_IPSEC, in __smc_connect()
1498 return smc_connect_decline_fallback(smc, SMC_CLC_DECL_MEM, in __smc_connect()
1507 if (smc_vlan_by_tcpsk(smc->clcsock, ini)) { in __smc_connect()
1517 rc = smc_find_proposal_devices(smc, ini); in __smc_connect()
1530 rc = smc_connect_clc(smc, aclc2, ini); in __smc_connect()
1535 smc->sk.sk_err = ETIMEDOUT; in __smc_connect()
1549 rc = smc_connect_rdma(smc, aclc, ini); in __smc_connect()
1552 rc = smc_connect_ism(smc, aclc, ini); in __smc_connect()
1557 SMC_STAT_CLNT_SUCC_INC(sock_net(smc->clcsock->sk), aclc); in __smc_connect()
1558 smc_connect_ism_vlan_cleanup(smc, ini); in __smc_connect()
1564 smc_connect_ism_vlan_cleanup(smc, ini); in __smc_connect()
1568 return smc_connect_decline_fallback(smc, rc, version); in __smc_connect()
1573 struct smc_sock *smc = container_of(work, struct smc_sock, in smc_connect_work() local
1575 long timeo = smc->sk.sk_sndtimeo; in smc_connect_work()
1580 lock_sock(smc->clcsock->sk); in smc_connect_work()
1581 if (smc->clcsock->sk->sk_err) { in smc_connect_work()
1582 smc->sk.sk_err = smc->clcsock->sk->sk_err; in smc_connect_work()
1583 } else if ((1 << smc->clcsock->sk->sk_state) & in smc_connect_work()
1585 rc = sk_stream_wait_connect(smc->clcsock->sk, &timeo); in smc_connect_work()
1587 ((1 << smc->clcsock->sk->sk_state) & in smc_connect_work()
1591 release_sock(smc->clcsock->sk); in smc_connect_work()
1592 lock_sock(&smc->sk); in smc_connect_work()
1593 if (rc != 0 || smc->sk.sk_err) { in smc_connect_work()
1594 smc->sk.sk_state = SMC_CLOSED; in smc_connect_work()
1596 smc->sk.sk_err = EPIPE; in smc_connect_work()
1598 smc->sk.sk_err = ECONNREFUSED; in smc_connect_work()
1600 smc->sk.sk_err = -sock_intr_errno(timeo); in smc_connect_work()
1601 sock_put(&smc->sk); /* passive closing */ in smc_connect_work()
1605 rc = __smc_connect(smc); in smc_connect_work()
1607 smc->sk.sk_err = -rc; in smc_connect_work()
1610 if (!sock_flag(&smc->sk, SOCK_DEAD)) { in smc_connect_work()
1611 if (smc->sk.sk_err) { in smc_connect_work()
1612 smc->sk.sk_state_change(&smc->sk); in smc_connect_work()
1614 smc->clcsock->sk->sk_write_space(smc->clcsock->sk); in smc_connect_work()
1615 smc->sk.sk_write_space(&smc->sk); in smc_connect_work()
1618 release_sock(&smc->sk); in smc_connect_work()
1625 struct smc_sock *smc; in smc_connect() local
1628 smc = smc_sk(sk); in smc_connect()
1667 smc_copy_sock_settings_to_clc(smc); in smc_connect()
1668 tcp_sk(smc->clcsock->sk)->syn_smc = 1; in smc_connect()
1669 if (smc->connect_nonblock) { in smc_connect()
1673 rc = kernel_connect(smc->clcsock, addr, alen, flags); in smc_connect()
1677 if (smc->use_fallback) { in smc_connect()
1681 sock_hold(&smc->sk); /* sock put in passive closing */ in smc_connect()
1683 if (queue_work(smc_hs_wq, &smc->connect_work)) in smc_connect()
1684 smc->connect_nonblock = 1; in smc_connect()
1688 rc = __smc_connect(smc); in smc_connect()
1824 struct smc_sock *smc = smc_sk(sk); in smc_close_non_accepted() local
1831 __smc_release(smc); in smc_close_non_accepted()
1837 static int smcr_serv_conf_first_link(struct smc_sock *smc) in smcr_serv_conf_first_link() argument
1839 struct smc_link *link = smc->conn.lnk; in smcr_serv_conf_first_link()
1844 if (smc->conn.sndbuf_desc->is_vm) { in smcr_serv_conf_first_link()
1845 if (smcr_link_reg_buf(link, smc->conn.sndbuf_desc)) in smcr_serv_conf_first_link()
1850 if (smcr_link_reg_buf(link, smc->conn.rmb_desc)) in smcr_serv_conf_first_link()
1864 rc = smc_clc_wait_msg(smc, &dclc, sizeof(dclc), in smcr_serv_conf_first_link()
1875 smc->conn.rmb_desc->is_conf_rkey = true; in smcr_serv_conf_first_link()
1928 this_cpu_inc(net->smc.smc_stats->srv_hshake_err_cnt); in smc_listen_out_err()
2573 struct smc_sock *smc; in smc_listen() local
2576 smc = smc_sk(sk); in smc_listen()
2581 smc->connect_nonblock || sock->state != SS_UNCONNECTED) in smc_listen()
2592 smc_copy_sock_settings_to_clc(smc); in smc_listen()
2593 if (!smc->use_fallback) in smc_listen()
2594 tcp_sk(smc->clcsock->sk)->syn_smc = 1; in smc_listen()
2599 write_lock_bh(&smc->clcsock->sk->sk_callback_lock); in smc_listen()
2600 smc->clcsock->sk->sk_user_data = in smc_listen()
2601 (void *)((uintptr_t)smc | SK_USER_DATA_NOCOPY); in smc_listen()
2602 smc_clcsock_replace_cb(&smc->clcsock->sk->sk_data_ready, in smc_listen()
2603 smc_clcsock_data_ready, &smc->clcsk_data_ready); in smc_listen()
2604 write_unlock_bh(&smc->clcsock->sk->sk_callback_lock); in smc_listen()
2607 smc->ori_af_ops = inet_csk(smc->clcsock->sk)->icsk_af_ops; in smc_listen()
2609 smc->af_ops = *smc->ori_af_ops; in smc_listen()
2610 smc->af_ops.syn_recv_sock = smc_tcp_syn_recv_sock; in smc_listen()
2612 inet_csk(smc->clcsock->sk)->icsk_af_ops = &smc->af_ops; in smc_listen()
2614 if (smc->limit_smc_hs) in smc_listen()
2615 tcp_sk(smc->clcsock->sk)->smc_hs_congested = smc_hs_congested; in smc_listen()
2617 rc = kernel_listen(smc->clcsock, backlog); in smc_listen()
2619 write_lock_bh(&smc->clcsock->sk->sk_callback_lock); in smc_listen()
2620 smc_clcsock_restore_cb(&smc->clcsock->sk->sk_data_ready, in smc_listen()
2621 &smc->clcsk_data_ready); in smc_listen()
2622 smc->clcsock->sk->sk_user_data = NULL; in smc_listen()
2623 write_unlock_bh(&smc->clcsock->sk->sk_callback_lock); in smc_listen()
2708 struct smc_sock *smc; in smc_getname() local
2714 smc = smc_sk(sock->sk); in smc_getname()
2716 return smc->clcsock->ops->getname(smc->clcsock, addr, peer); in smc_getname()
2722 struct smc_sock *smc; in smc_sendmsg() local
2725 smc = smc_sk(sk); in smc_sendmsg()
2731 if (sk->sk_state == SMC_INIT && !smc->connect_nonblock) { in smc_sendmsg()
2732 rc = smc_switch_to_fallback(smc, SMC_CLC_DECL_OPTUNSUPP); in smc_sendmsg()
2746 if (smc->use_fallback) { in smc_sendmsg()
2747 rc = smc->clcsock->ops->sendmsg(smc->clcsock, msg, len); in smc_sendmsg()
2749 rc = smc_tx_sendmsg(smc, msg, len); in smc_sendmsg()
2750 SMC_STAT_TX_PAYLOAD(smc, len, rc); in smc_sendmsg()
2761 struct smc_sock *smc; in smc_recvmsg() local
2764 smc = smc_sk(sk); in smc_recvmsg()
2781 if (smc->use_fallback) { in smc_recvmsg()
2782 rc = smc->clcsock->ops->recvmsg(smc->clcsock, msg, len, flags); in smc_recvmsg()
2785 rc = smc_rx_recvmsg(smc, msg, NULL, len, flags); in smc_recvmsg()
2786 SMC_STAT_RX_PAYLOAD(smc, rc, rc); in smc_recvmsg()
2811 struct smc_sock *smc; in smc_poll() local
2817 smc = smc_sk(sock->sk); in smc_poll()
2818 if (smc->use_fallback) { in smc_poll()
2820 mask = smc->clcsock->ops->poll(file, smc->clcsock, wait); in smc_poll()
2821 sk->sk_err = smc->clcsock->sk->sk_err; in smc_poll()
2833 } else if (smc->use_fallback) { /* as result of connect_work()*/ in smc_poll()
2834 mask |= smc->clcsock->ops->poll(file, smc->clcsock, in smc_poll()
2836 sk->sk_err = smc->clcsock->sk->sk_err; in smc_poll()
2839 atomic_read(&smc->conn.sndbuf_space)) || in smc_poll()
2846 if (atomic_read(&smc->conn.bytes_to_rcv)) in smc_poll()
2852 if (smc->conn.urg_state == SMC_URG_VALID) in smc_poll()
2864 struct smc_sock *smc; in smc_shutdown() local
2869 smc = smc_sk(sk); in smc_shutdown()
2895 if (smc->use_fallback) { in smc_shutdown()
2896 rc = kernel_sock_shutdown(smc->clcsock, how); in smc_shutdown()
2897 sk->sk_shutdown = smc->clcsock->sk->sk_shutdown; in smc_shutdown()
2908 rc = smc_close_active(smc); in smc_shutdown()
2914 rc = smc_close_shutdown_write(smc); in smc_shutdown()
2921 if (do_shutdown && smc->clcsock) in smc_shutdown()
2922 rc1 = kernel_sock_shutdown(smc->clcsock, how); in smc_shutdown()
2938 struct smc_sock *smc; in __smc_getsockopt() local
2941 smc = smc_sk(sock->sk); in __smc_getsockopt()
2953 val = smc->limit_smc_hs; in __smc_getsockopt()
2971 struct smc_sock *smc; in __smc_setsockopt() local
2974 smc = smc_sk(sk); in __smc_setsockopt()
2988 smc->limit_smc_hs = !!val; in __smc_setsockopt()
3004 struct smc_sock *smc; in smc_setsockopt() local
3012 smc = smc_sk(sk); in smc_setsockopt()
3017 mutex_lock(&smc->clcsock_release_lock); in smc_setsockopt()
3018 if (!smc->clcsock) { in smc_setsockopt()
3019 mutex_unlock(&smc->clcsock_release_lock); in smc_setsockopt()
3022 if (unlikely(!smc->clcsock->ops->setsockopt)) in smc_setsockopt()
3025 rc = smc->clcsock->ops->setsockopt(smc->clcsock, level, optname, in smc_setsockopt()
3027 if (smc->clcsock->sk->sk_err) { in smc_setsockopt()
3028 sk->sk_err = smc->clcsock->sk->sk_err; in smc_setsockopt()
3031 mutex_unlock(&smc->clcsock_release_lock); in smc_setsockopt()
3039 if (rc || smc->use_fallback) in smc_setsockopt()
3047 if (sk->sk_state == SMC_INIT && !smc->connect_nonblock) { in smc_setsockopt()
3048 rc = smc_switch_to_fallback(smc, SMC_CLC_DECL_OPTUNSUPP); in smc_setsockopt()
3058 SMC_STAT_INC(smc, ndly_cnt); in smc_setsockopt()
3059 smc_tx_pending(&smc->conn); in smc_setsockopt()
3060 cancel_delayed_work(&smc->conn.tx_work); in smc_setsockopt()
3069 SMC_STAT_INC(smc, cork_cnt); in smc_setsockopt()
3070 smc_tx_pending(&smc->conn); in smc_setsockopt()
3071 cancel_delayed_work(&smc->conn.tx_work); in smc_setsockopt()
3076 smc->sockopt_defer_accept = val; in smc_setsockopt()
3090 struct smc_sock *smc; in smc_getsockopt() local
3096 smc = smc_sk(sock->sk); in smc_getsockopt()
3097 mutex_lock(&smc->clcsock_release_lock); in smc_getsockopt()
3098 if (!smc->clcsock) { in smc_getsockopt()
3099 mutex_unlock(&smc->clcsock_release_lock); in smc_getsockopt()
3103 if (unlikely(!smc->clcsock->ops->getsockopt)) { in smc_getsockopt()
3104 mutex_unlock(&smc->clcsock_release_lock); in smc_getsockopt()
3107 rc = smc->clcsock->ops->getsockopt(smc->clcsock, level, optname, in smc_getsockopt()
3109 mutex_unlock(&smc->clcsock_release_lock); in smc_getsockopt()
3118 struct smc_sock *smc; in smc_ioctl() local
3121 smc = smc_sk(sock->sk); in smc_ioctl()
3122 conn = &smc->conn; in smc_ioctl()
3123 lock_sock(&smc->sk); in smc_ioctl()
3124 if (smc->use_fallback) { in smc_ioctl()
3125 if (!smc->clcsock) { in smc_ioctl()
3126 release_sock(&smc->sk); in smc_ioctl()
3129 answ = smc->clcsock->ops->ioctl(smc->clcsock, cmd, arg); in smc_ioctl()
3130 release_sock(&smc->sk); in smc_ioctl()
3135 if (smc->sk.sk_state == SMC_LISTEN) { in smc_ioctl()
3136 release_sock(&smc->sk); in smc_ioctl()
3139 if (smc->sk.sk_state == SMC_INIT || in smc_ioctl()
3140 smc->sk.sk_state == SMC_CLOSED) in smc_ioctl()
3143 answ = atomic_read(&smc->conn.bytes_to_rcv); in smc_ioctl()
3147 if (smc->sk.sk_state == SMC_LISTEN) { in smc_ioctl()
3148 release_sock(&smc->sk); in smc_ioctl()
3151 if (smc->sk.sk_state == SMC_INIT || in smc_ioctl()
3152 smc->sk.sk_state == SMC_CLOSED) in smc_ioctl()
3155 answ = smc->conn.sndbuf_desc->len - in smc_ioctl()
3156 atomic_read(&smc->conn.sndbuf_space); in smc_ioctl()
3160 if (smc->sk.sk_state == SMC_LISTEN) { in smc_ioctl()
3161 release_sock(&smc->sk); in smc_ioctl()
3164 if (smc->sk.sk_state == SMC_INIT || in smc_ioctl()
3165 smc->sk.sk_state == SMC_CLOSED) in smc_ioctl()
3168 answ = smc_tx_prepared_sends(&smc->conn); in smc_ioctl()
3171 if (smc->sk.sk_state == SMC_LISTEN) { in smc_ioctl()
3172 release_sock(&smc->sk); in smc_ioctl()
3175 if (smc->sk.sk_state == SMC_INIT || in smc_ioctl()
3176 smc->sk.sk_state == SMC_CLOSED) { in smc_ioctl()
3186 release_sock(&smc->sk); in smc_ioctl()
3189 release_sock(&smc->sk); in smc_ioctl()
3205 struct smc_sock *smc; in smc_splice_read() local
3208 smc = smc_sk(sk); in smc_splice_read()
3225 if (smc->use_fallback) { in smc_splice_read()
3226 rc = smc->clcsock->ops->splice_read(smc->clcsock, ppos, in smc_splice_read()
3237 SMC_STAT_INC(smc, splice_cnt); in smc_splice_read()
3238 rc = smc_rx_recvmsg(smc, NULL, pipe, len, flags); in smc_splice_read()
3272 struct smc_sock *smc; in __smc_create() local
3292 smc = smc_sk(sk); in __smc_create()
3293 smc->use_fallback = false; /* assume rdma capability first */ in __smc_create()
3294 smc->fallback_rsn = 0; in __smc_create()
3297 smc->limit_smc_hs = net->smc.limit_smc_hs; in __smc_create()
3302 &smc->clcsock); in __smc_create()
3313 sk = smc->clcsock->sk; in __smc_create()
3319 smc->clcsock = clcsock; in __smc_create()