cm.c (346922) | cm.c (346923) |
---|---|
1/* 2 * Copyright (c) 2009-2013, 2016 Chelsio, Inc. All rights reserved. 3 * 4 * This software is available to you under a choice of one of two 5 * licenses. You may choose to be licensed under the terms of the GNU 6 * General Public License (GPL) Version 2, available from the file 7 * COPYING in the main directory of this source tree, or the 8 * OpenIB.org BSD license below: --- 16 unchanged lines hidden (view full) --- 25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * SOFTWARE. 31 */ 32#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2009-2013, 2016 Chelsio, Inc. All rights reserved. 3 * 4 * This software is available to you under a choice of one of two 5 * licenses. You may choose to be licensed under the terms of the GNU 6 * General Public License (GPL) Version 2, available from the file 7 * COPYING in the main directory of this source tree, or the 8 * OpenIB.org BSD license below: --- 16 unchanged lines hidden (view full) --- 25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * SOFTWARE. 31 */ 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: stable/11/sys/dev/cxgbe/iw_cxgbe/cm.c 346922 2019-04-29 19:47:21Z np $"); | 33__FBSDID("$FreeBSD: stable/11/sys/dev/cxgbe/iw_cxgbe/cm.c 346923 2019-04-29 20:10:28Z np $"); |
34 35#include "opt_inet.h" 36 37#ifdef TCP_OFFLOAD 38#include <sys/types.h> 39#include <sys/malloc.h> 40#include <sys/socket.h> 41#include <sys/socketvar.h> --- 125 unchanged lines hidden (view full) --- 167 if (__inp->inp_vflag & INP_IPV4) \ 168 in_getpeeraddr(so, (struct sockaddr **)&__a); \ 169 else \ 170 in6_getpeeraddr(so, (struct sockaddr **)&__a); \ 171 *(praddr) = *__a; \ 172 free(__a, M_SONAME); \ 173 } while (0) 174 | 34 35#include "opt_inet.h" 36 37#ifdef TCP_OFFLOAD 38#include <sys/types.h> 39#include <sys/malloc.h> 40#include <sys/socket.h> 41#include <sys/socketvar.h> --- 125 unchanged lines hidden (view full) --- 167 if (__inp->inp_vflag & INP_IPV4) \ 168 in_getpeeraddr(so, (struct sockaddr **)&__a); \ 169 else \ 170 in6_getpeeraddr(so, (struct sockaddr **)&__a); \ 171 *(praddr) = *__a; \ 172 free(__a, M_SONAME); \ 173 } while (0) 174 |
175#ifdef KTR | |
176static char *states[] = { 177 "idle", 178 "listen", 179 "connecting", 180 "mpa_wait_req", 181 "mpa_req_sent", 182 "mpa_req_rcvd", 183 "mpa_rep_sent", 184 "fpdu_mode", 185 "aborting", 186 "closing", 187 "moribund", 188 "dead", 189 NULL, 190}; | 175static char *states[] = { 176 "idle", 177 "listen", 178 "connecting", 179 "mpa_wait_req", 180 "mpa_req_sent", 181 "mpa_req_rcvd", 182 "mpa_rep_sent", 183 "fpdu_mode", 184 "aborting", 185 "closing", 186 "moribund", 187 "dead", 188 NULL, 189}; |
191#endif | |
192 193static void deref_cm_id(struct c4iw_ep_common *epc) 194{ 195 epc->cm_id->rem_ref(epc->cm_id); 196 epc->cm_id = NULL; 197 set_bit(CM_ID_DEREFED, &epc->history); 198} 199 --- 224 unchanged lines hidden (view full) --- 424 /* 425 * These states are expected if the ep timed out at the same 426 * time as another thread was calling stop_ep_timer(). 427 * So we silently do nothing for these states. 428 */ 429 abort = 0; 430 break; 431 default: | 190 191static void deref_cm_id(struct c4iw_ep_common *epc) 192{ 193 epc->cm_id->rem_ref(epc->cm_id); 194 epc->cm_id = NULL; 195 set_bit(CM_ID_DEREFED, &epc->history); 196} 197 --- 224 unchanged lines hidden (view full) --- 422 /* 423 * These states are expected if the ep timed out at the same 424 * time as another thread was calling stop_ep_timer(). 425 * So we silently do nothing for these states. 426 */ 427 abort = 0; 428 break; 429 default: |
432 CTR4(KTR_IW_CXGBE, "%s unexpected state ep %p tid %u state %u\n" | 430 CTR4(KTR_IW_CXGBE, "%s unexpected state ep %p tid %u state %u" |
433 , __func__, ep, ep->hwtid, ep->com.state); 434 abort = 0; 435 } 436 if (abort) 437 c4iw_ep_disconnect(ep, 1, GFP_KERNEL); 438 c4iw_put_ep(&ep->com); 439 return; 440} --- 395 unchanged lines hidden (view full) --- 836 int on = 1; 837 838 sopt.sopt_dir = SOPT_SET; 839 sopt.sopt_level = IPPROTO_TCP; 840 sopt.sopt_name = TCP_NODELAY; 841 sopt.sopt_val = (caddr_t)&on; 842 sopt.sopt_valsize = sizeof on; 843 sopt.sopt_td = NULL; | 431 , __func__, ep, ep->hwtid, ep->com.state); 432 abort = 0; 433 } 434 if (abort) 435 c4iw_ep_disconnect(ep, 1, GFP_KERNEL); 436 c4iw_put_ep(&ep->com); 437 return; 438} --- 395 unchanged lines hidden (view full) --- 834 int on = 1; 835 836 sopt.sopt_dir = SOPT_SET; 837 sopt.sopt_level = IPPROTO_TCP; 838 sopt.sopt_name = TCP_NODELAY; 839 sopt.sopt_val = (caddr_t)&on; 840 sopt.sopt_valsize = sizeof on; 841 sopt.sopt_td = NULL; |
844 rc = sosetopt(so, &sopt); | 842 rc = -sosetopt(so, &sopt); |
845 if (rc) { 846 log(LOG_ERR, "%s: can't set TCP_NODELAY on so %p (%d)\n", 847 __func__, so, rc); 848 } 849} 850 851static void 852init_iwarp_socket(struct socket *so, void *arg) --- 12 unchanged lines hidden (view full) --- 865 SOCKBUF_LOCK(&so->so_rcv); 866 soupcall_clear(so, SO_RCV); 867 SOCKBUF_UNLOCK(&so->so_rcv); 868} 869 870static void 871process_data(struct c4iw_ep *ep) 872{ | 843 if (rc) { 844 log(LOG_ERR, "%s: can't set TCP_NODELAY on so %p (%d)\n", 845 __func__, so, rc); 846 } 847} 848 849static void 850init_iwarp_socket(struct socket *so, void *arg) --- 12 unchanged lines hidden (view full) --- 863 SOCKBUF_LOCK(&so->so_rcv); 864 soupcall_clear(so, SO_RCV); 865 SOCKBUF_UNLOCK(&so->so_rcv); 866} 867 868static void 869process_data(struct c4iw_ep *ep) 870{ |
871 int ret = 0; |
|
873 int disconnect = 0; | 872 int disconnect = 0; |
873 struct c4iw_qp_attributes attrs = {0}; |
|
874 875 CTR5(KTR_IW_CXGBE, "%s: so %p, ep %p, state %s, sbused %d", __func__, 876 ep->com.so, ep, states[ep->com.state], sbused(&ep->com.so->so_rcv)); 877 878 switch (ep->com.state) { 879 case MPA_REQ_SENT: 880 disconnect = process_mpa_reply(ep); 881 break; 882 case MPA_REQ_WAIT: 883 disconnect = process_mpa_request(ep); 884 if (disconnect) 885 /* Refered in process_newconn() */ 886 c4iw_put_ep(&ep->parent_ep->com); 887 break; | 874 875 CTR5(KTR_IW_CXGBE, "%s: so %p, ep %p, state %s, sbused %d", __func__, 876 ep->com.so, ep, states[ep->com.state], sbused(&ep->com.so->so_rcv)); 877 878 switch (ep->com.state) { 879 case MPA_REQ_SENT: 880 disconnect = process_mpa_reply(ep); 881 break; 882 case MPA_REQ_WAIT: 883 disconnect = process_mpa_request(ep); 884 if (disconnect) 885 /* Refered in process_newconn() */ 886 c4iw_put_ep(&ep->parent_ep->com); 887 break; |
888 case FPDU_MODE: 889 MPASS(ep->com.qp != NULL); 890 attrs.next_state = C4IW_QP_STATE_TERMINATE; 891 ret = c4iw_modify_qp(ep->com.dev, ep->com.qp, 892 C4IW_QP_ATTR_NEXT_STATE, &attrs, 1); 893 if (ret != -EINPROGRESS) 894 disconnect = 1; 895 break; |
|
888 default: | 896 default: |
889 if (sbused(&ep->com.so->so_rcv)) 890 log(LOG_ERR, "%s: Unexpected streaming data. ep %p, " | 897 log(LOG_ERR, "%s: Unexpected streaming data. ep %p, " |
891 "state %d, so %p, so_state 0x%x, sbused %u\n", 892 __func__, ep, ep->com.state, ep->com.so, 893 ep->com.so->so_state, sbused(&ep->com.so->so_rcv)); 894 break; 895 } 896 if (disconnect) 897 c4iw_ep_disconnect(ep, disconnect == 2, GFP_KERNEL); 898 --- 48 unchanged lines hidden (view full) --- 947 return c4iw_zero_addr(addr) || c4iw_loopback_addr(addr); 948} 949 950static void 951process_newconn(struct c4iw_listen_ep *master_lep, struct socket *new_so) 952{ 953 struct c4iw_listen_ep *real_lep = NULL; 954 struct c4iw_ep *new_ep = NULL; | 898 "state %d, so %p, so_state 0x%x, sbused %u\n", 899 __func__, ep, ep->com.state, ep->com.so, 900 ep->com.so->so_state, sbused(&ep->com.so->so_rcv)); 901 break; 902 } 903 if (disconnect) 904 c4iw_ep_disconnect(ep, disconnect == 2, GFP_KERNEL); 905 --- 48 unchanged lines hidden (view full) --- 954 return c4iw_zero_addr(addr) || c4iw_loopback_addr(addr); 955} 956 957static void 958process_newconn(struct c4iw_listen_ep *master_lep, struct socket *new_so) 959{ 960 struct c4iw_listen_ep *real_lep = NULL; 961 struct c4iw_ep *new_ep = NULL; |
962 struct sockaddr_in *remote = NULL; |
|
955 int ret = 0; 956 957 MPASS(new_so != NULL); 958 959 if (c4iw_any_addr((struct sockaddr *)&master_lep->com.local_addr)) { 960 /* Here we need to find the 'real_lep' that belongs to the 961 * incomming socket's network interface, such that the newly 962 * created 'ep' can be attached to the real 'lep'. --- 28 unchanged lines hidden (view full) --- 991 GET_LOCAL_ADDR(&new_ep->com.local_addr, new_so); 992 GET_REMOTE_ADDR(&new_ep->com.remote_addr, new_so); 993 c4iw_get_ep(&real_lep->com); 994 init_timer(&new_ep->timer); 995 new_ep->com.state = MPA_REQ_WAIT; 996 START_EP_TIMER(new_ep); 997 998 setiwsockopt(new_so); | 963 int ret = 0; 964 965 MPASS(new_so != NULL); 966 967 if (c4iw_any_addr((struct sockaddr *)&master_lep->com.local_addr)) { 968 /* Here we need to find the 'real_lep' that belongs to the 969 * incomming socket's network interface, such that the newly 970 * created 'ep' can be attached to the real 'lep'. --- 28 unchanged lines hidden (view full) --- 999 GET_LOCAL_ADDR(&new_ep->com.local_addr, new_so); 1000 GET_REMOTE_ADDR(&new_ep->com.remote_addr, new_so); 1001 c4iw_get_ep(&real_lep->com); 1002 init_timer(&new_ep->timer); 1003 new_ep->com.state = MPA_REQ_WAIT; 1004 START_EP_TIMER(new_ep); 1005 1006 setiwsockopt(new_so); |
1007 ret = soaccept(new_so, (struct sockaddr **)&remote); 1008 if (ret != 0) { 1009 CTR4(KTR_IW_CXGBE, 1010 "%s:listen sock:%p, new sock:%p, ret:%d", 1011 __func__, master_lep->com.so, new_so, ret); 1012 if (remote != NULL) 1013 free(remote, M_SONAME); 1014 uninit_iwarp_socket(new_so); 1015 soclose(new_so); 1016 c4iw_put_ep(&new_ep->com); 1017 c4iw_put_ep(&real_lep->com); 1018 return; 1019 } 1020 free(remote, M_SONAME); |
|
999 1000 /* MPA request might have been queued up on the socket already, so we 1001 * initialize the socket/upcall_handler under lock to prevent processing 1002 * MPA request on another thread(via process_req()) simultaniously. 1003 */ 1004 c4iw_get_ep(&new_ep->com); /* Dereferenced at the end below, this is to 1005 avoid freeing of ep before ep unlock. */ 1006 mutex_lock(&new_ep->com.mutex); --- 159 unchanged lines hidden (view full) --- 1166 1167 /* close complete */ 1168 if (so->so_state & SS_ISDISCONNECTED) { 1169 process_close_complete(ep); 1170 return; 1171 } 1172 1173 /* rx data */ | 1021 1022 /* MPA request might have been queued up on the socket already, so we 1023 * initialize the socket/upcall_handler under lock to prevent processing 1024 * MPA request on another thread(via process_req()) simultaniously. 1025 */ 1026 c4iw_get_ep(&new_ep->com); /* Dereferenced at the end below, this is to 1027 avoid freeing of ep before ep unlock. */ 1028 mutex_lock(&new_ep->com.mutex); --- 159 unchanged lines hidden (view full) --- 1188 1189 /* close complete */ 1190 if (so->so_state & SS_ISDISCONNECTED) { 1191 process_close_complete(ep); 1192 return; 1193 } 1194 1195 /* rx data */ |
1174 process_data(ep); | 1196 if (sbused(&ep->com.so->so_rcv)) { 1197 process_data(ep); 1198 return; 1199 } 1200 1201 /* Socket events for 'MPA Request Received' and 'Close Complete' 1202 * were already processed earlier in their previous events handlers. 1203 * Hence, these socket events are skipped. 1204 * And any other socket events must have handled above. 1205 */ 1206 MPASS((ep->com.state == MPA_REQ_RCVD) || (ep->com.state == MORIBUND)); 1207 1208 if ((ep->com.state != MPA_REQ_RCVD) && (ep->com.state != MORIBUND)) 1209 log(LOG_ERR, "%s: Unprocessed socket event so %p, " 1210 "so_state 0x%x, so_err %d, sb_state 0x%x, ep %p, ep_state %s\n", 1211 __func__, so, so->so_state, so->so_error, so->so_rcv.sb_state, 1212 ep, states[state]); 1213 |
1175} 1176 1177SYSCTL_NODE(_hw, OID_AUTO, iw_cxgbe, CTLFLAG_RD, 0, "iw_cxgbe driver parameters"); 1178 1179static int dack_mode = 0; 1180SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, dack_mode, CTLFLAG_RWTUN, &dack_mode, 0, 1181 "Delayed ack mode (default = 0)"); 1182 --- 44 unchanged lines hidden (view full) --- 1227static int rcv_win = 256 * 1024; 1228SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, rcv_win, CTLFLAG_RWTUN, &rcv_win, 0, 1229 "TCP receive window in bytes (default = 256KB)"); 1230 1231static int snd_win = 128 * 1024; 1232SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, snd_win, CTLFLAG_RWTUN, &snd_win, 0, 1233 "TCP send window in bytes (default = 128KB)"); 1234 | 1214} 1215 1216SYSCTL_NODE(_hw, OID_AUTO, iw_cxgbe, CTLFLAG_RD, 0, "iw_cxgbe driver parameters"); 1217 1218static int dack_mode = 0; 1219SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, dack_mode, CTLFLAG_RWTUN, &dack_mode, 0, 1220 "Delayed ack mode (default = 0)"); 1221 --- 44 unchanged lines hidden (view full) --- 1266static int rcv_win = 256 * 1024; 1267SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, rcv_win, CTLFLAG_RWTUN, &rcv_win, 0, 1268 "TCP receive window in bytes (default = 256KB)"); 1269 1270static int snd_win = 128 * 1024; 1271SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, snd_win, CTLFLAG_RWTUN, &snd_win, 0, 1272 "TCP send window in bytes (default = 128KB)"); 1273 |
1274int use_dsgl = 1; 1275SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, use_dsgl, CTLFLAG_RWTUN, &use_dsgl, 0, 1276 "Use DSGL for PBL/FastReg (default=1)"); 1277 1278int inline_threshold = 128; 1279SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, inline_threshold, CTLFLAG_RWTUN, &inline_threshold, 0, 1280 "inline vs dsgl threshold (default=128)"); 1281 1282static int reuseaddr = 0; 1283SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, reuseaddr, CTLFLAG_RWTUN, &reuseaddr, 0, 1284 "Enable SO_REUSEADDR & SO_REUSEPORT socket options on all iWARP client connections(default = 0)"); 1285 |
|
1235static void 1236start_ep_timer(struct c4iw_ep *ep) 1237{ 1238 1239 if (timer_pending(&ep->timer)) { 1240 CTR2(KTR_IW_CXGBE, "%s: ep %p, already started", __func__, ep); 1241 printk(KERN_ERR "%s timer already started! ep %p\n", __func__, 1242 ep); --- 358 unchanged lines hidden (view full) --- 1601 1602 /* linger_time of 0 forces RST to be sent */ 1603 sopt.sopt_dir = SOPT_SET; 1604 sopt.sopt_level = SOL_SOCKET; 1605 sopt.sopt_name = SO_LINGER; 1606 sopt.sopt_val = (caddr_t)&l; 1607 sopt.sopt_valsize = sizeof l; 1608 sopt.sopt_td = NULL; | 1286static void 1287start_ep_timer(struct c4iw_ep *ep) 1288{ 1289 1290 if (timer_pending(&ep->timer)) { 1291 CTR2(KTR_IW_CXGBE, "%s: ep %p, already started", __func__, ep); 1292 printk(KERN_ERR "%s timer already started! ep %p\n", __func__, 1293 ep); --- 358 unchanged lines hidden (view full) --- 1652 1653 /* linger_time of 0 forces RST to be sent */ 1654 sopt.sopt_dir = SOPT_SET; 1655 sopt.sopt_level = SOL_SOCKET; 1656 sopt.sopt_name = SO_LINGER; 1657 sopt.sopt_val = (caddr_t)&l; 1658 sopt.sopt_valsize = sizeof l; 1659 sopt.sopt_td = NULL; |
1609 rc = sosetopt(so, &sopt); | 1660 rc = -sosetopt(so, &sopt); |
1610 if (rc != 0) { 1611 log(LOG_ERR, "%s: sosetopt(%p, linger = 0) failed with %d.\n", 1612 __func__, so, rc); 1613 } 1614 1615 uninit_iwarp_socket(so); 1616 soclose(so); 1617 set_bit(ABORT_CONN, &ep->com.history); 1618 1619 /* 1620 * TBD: iw_cxgbe driver should receive ABORT reply for every ABORT 1621 * request it has sent. But the current TOE driver is not propagating 1622 * this ABORT reply event (via do_abort_rpl) to iw_cxgbe. So as a work- 1623 * around de-refererece 'ep' here instead of doing it in abort_rpl() 1624 * handler(not yet implemented) of iw_cxgbe driver. 1625 */ 1626 release_ep_resources(ep); | 1661 if (rc != 0) { 1662 log(LOG_ERR, "%s: sosetopt(%p, linger = 0) failed with %d.\n", 1663 __func__, so, rc); 1664 } 1665 1666 uninit_iwarp_socket(so); 1667 soclose(so); 1668 set_bit(ABORT_CONN, &ep->com.history); 1669 1670 /* 1671 * TBD: iw_cxgbe driver should receive ABORT reply for every ABORT 1672 * request it has sent. But the current TOE driver is not propagating 1673 * this ABORT reply event (via do_abort_rpl) to iw_cxgbe. So as a work- 1674 * around de-refererece 'ep' here instead of doing it in abort_rpl() 1675 * handler(not yet implemented) of iw_cxgbe driver. 1676 */ 1677 release_ep_resources(ep); |
1678 ep->com.state = DEAD; |
|
1627 1628 return (0); 1629} 1630 1631static void peer_close_upcall(struct c4iw_ep *ep) 1632{ 1633 struct iw_cm_event event; 1634 --- 623 unchanged lines hidden (view full) --- 2258 ep->ird = ntohs(mpa_v2_params->ird) & 2259 MPA_V2_IRD_ORD_MASK; 2260 ep->ird = min_t(u32, ep->ird, 2261 cur_max_read_depth(ep->com.dev)); 2262 ep->ord = ntohs(mpa_v2_params->ord) & 2263 MPA_V2_IRD_ORD_MASK; 2264 ep->ord = min_t(u32, ep->ord, 2265 cur_max_read_depth(ep->com.dev)); | 1679 1680 return (0); 1681} 1682 1683static void peer_close_upcall(struct c4iw_ep *ep) 1684{ 1685 struct iw_cm_event event; 1686 --- 623 unchanged lines hidden (view full) --- 2310 ep->ird = ntohs(mpa_v2_params->ird) & 2311 MPA_V2_IRD_ORD_MASK; 2312 ep->ird = min_t(u32, ep->ird, 2313 cur_max_read_depth(ep->com.dev)); 2314 ep->ord = ntohs(mpa_v2_params->ord) & 2315 MPA_V2_IRD_ORD_MASK; 2316 ep->ord = min_t(u32, ep->ord, 2317 cur_max_read_depth(ep->com.dev)); |
2266 CTR3(KTR_IW_CXGBE, "%s initiator ird %u ord %u\n", | 2318 CTR3(KTR_IW_CXGBE, "%s initiator ird %u ord %u", |
2267 __func__, ep->ird, ep->ord); 2268 if (ntohs(mpa_v2_params->ird) & MPA_V2_PEER2PEER_MODEL) 2269 if (peer2peer) { 2270 if (ntohs(mpa_v2_params->ord) & 2271 MPA_V2_RDMA_WRITE_RTR) 2272 ep->mpa_attr.p2p_type = 2273 FW_RI_INIT_P2PTYPE_RDMA_WRITE; 2274 else if (ntohs(mpa_v2_params->ord) & --- 137 unchanged lines hidden (view full) --- 2412 ep->ird = 1; 2413 } else { 2414 if (peer2peer && 2415 (ep->mpa_attr.p2p_type != FW_RI_INIT_P2PTYPE_DISABLED) && 2416 (p2p_type == FW_RI_INIT_P2PTYPE_READ_REQ) && ep->ird == 0) 2417 ep->ird = 1; 2418 } 2419 | 2319 __func__, ep->ird, ep->ord); 2320 if (ntohs(mpa_v2_params->ird) & MPA_V2_PEER2PEER_MODEL) 2321 if (peer2peer) { 2322 if (ntohs(mpa_v2_params->ord) & 2323 MPA_V2_RDMA_WRITE_RTR) 2324 ep->mpa_attr.p2p_type = 2325 FW_RI_INIT_P2PTYPE_RDMA_WRITE; 2326 else if (ntohs(mpa_v2_params->ord) & --- 137 unchanged lines hidden (view full) --- 2464 ep->ird = 1; 2465 } else { 2466 if (peer2peer && 2467 (ep->mpa_attr.p2p_type != FW_RI_INIT_P2PTYPE_DISABLED) && 2468 (p2p_type == FW_RI_INIT_P2PTYPE_READ_REQ) && ep->ird == 0) 2469 ep->ird = 1; 2470 } 2471 |
2420 CTR4(KTR_IW_CXGBE, "%s %d ird %d ord %d\n", __func__, __LINE__, | 2472 CTR4(KTR_IW_CXGBE, "%s %d ird %d ord %d", __func__, __LINE__, |
2421 ep->ird, ep->ord); 2422 2423 ep->com.cm_id = cm_id; 2424 ref_cm_id(&ep->com); 2425 ep->com.qp = qp; 2426 ref_qp(ep); 2427 //ep->ofld_txq = TOEPCB(ep->com.so)->ofld_txq; 2428 --- 42 unchanged lines hidden (view full) --- 2471 CTR2(KTR_IW_CXGBE, "%s:cacE err %p", __func__, ep); 2472 return err; 2473} 2474 2475static int 2476c4iw_sock_create(struct sockaddr_storage *laddr, struct socket **so) 2477{ 2478 int ret; | 2473 ep->ird, ep->ord); 2474 2475 ep->com.cm_id = cm_id; 2476 ref_cm_id(&ep->com); 2477 ep->com.qp = qp; 2478 ref_qp(ep); 2479 //ep->ofld_txq = TOEPCB(ep->com.so)->ofld_txq; 2480 --- 42 unchanged lines hidden (view full) --- 2523 CTR2(KTR_IW_CXGBE, "%s:cacE err %p", __func__, ep); 2524 return err; 2525} 2526 2527static int 2528c4iw_sock_create(struct sockaddr_storage *laddr, struct socket **so) 2529{ 2530 int ret; |
2479 int size; | 2531 int size, on; |
2480 struct socket *sock = NULL; | 2532 struct socket *sock = NULL; |
2533 struct sockopt sopt; |
|
2481 2482 ret = sock_create_kern(laddr->ss_family, 2483 SOCK_STREAM, IPPROTO_TCP, &sock); 2484 if (ret) { 2485 CTR2(KTR_IW_CXGBE, "%s:Failed to create TCP socket. err %d", 2486 __func__, ret); 2487 return ret; 2488 } 2489 | 2534 2535 ret = sock_create_kern(laddr->ss_family, 2536 SOCK_STREAM, IPPROTO_TCP, &sock); 2537 if (ret) { 2538 CTR2(KTR_IW_CXGBE, "%s:Failed to create TCP socket. err %d", 2539 __func__, ret); 2540 return ret; 2541 } 2542 |
2490 ret = sobind(sock, (struct sockaddr *)laddr, curthread); | 2543 if (reuseaddr) { 2544 bzero(&sopt, sizeof(struct sockopt)); 2545 sopt.sopt_dir = SOPT_SET; 2546 sopt.sopt_level = SOL_SOCKET; 2547 sopt.sopt_name = SO_REUSEADDR; 2548 on = 1; 2549 sopt.sopt_val = &on; 2550 sopt.sopt_valsize = sizeof(on); 2551 ret = -sosetopt(sock, &sopt); 2552 if (ret != 0) { 2553 log(LOG_ERR, "%s: sosetopt(%p, SO_REUSEADDR) " 2554 "failed with %d.\n", __func__, sock, ret); 2555 } 2556 bzero(&sopt, sizeof(struct sockopt)); 2557 sopt.sopt_dir = SOPT_SET; 2558 sopt.sopt_level = SOL_SOCKET; 2559 sopt.sopt_name = SO_REUSEPORT; 2560 on = 1; 2561 sopt.sopt_val = &on; 2562 sopt.sopt_valsize = sizeof(on); 2563 ret = -sosetopt(sock, &sopt); 2564 if (ret != 0) { 2565 log(LOG_ERR, "%s: sosetopt(%p, SO_REUSEPORT) " 2566 "failed with %d.\n", __func__, sock, ret); 2567 } 2568 } 2569 2570 ret = -sobind(sock, (struct sockaddr *)laddr, curthread); |
2491 if (ret) { 2492 CTR2(KTR_IW_CXGBE, "%s:Failed to bind socket. err %p", 2493 __func__, ret); 2494 sock_release(sock); 2495 return ret; 2496 } 2497 2498 size = laddr->ss_family == AF_INET6 ? --- 88 unchanged lines hidden (view full) --- 2587 ep->com.local_addr = cm_id->local_addr; 2588 ep->com.remote_addr = cm_id->remote_addr; 2589 2590 err = c4iw_sock_create(&cm_id->local_addr, &ep->com.so); 2591 if (err) 2592 goto fail; 2593 2594 setiwsockopt(ep->com.so); | 2571 if (ret) { 2572 CTR2(KTR_IW_CXGBE, "%s:Failed to bind socket. err %p", 2573 __func__, ret); 2574 sock_release(sock); 2575 return ret; 2576 } 2577 2578 size = laddr->ss_family == AF_INET6 ? --- 88 unchanged lines hidden (view full) --- 2667 ep->com.local_addr = cm_id->local_addr; 2668 ep->com.remote_addr = cm_id->remote_addr; 2669 2670 err = c4iw_sock_create(&cm_id->local_addr, &ep->com.so); 2671 if (err) 2672 goto fail; 2673 2674 setiwsockopt(ep->com.so); |
2675 init_iwarp_socket(ep->com.so, &ep->com); |
|
2595 err = -soconnect(ep->com.so, (struct sockaddr *)&ep->com.remote_addr, 2596 ep->com.thread); | 2676 err = -soconnect(ep->com.so, (struct sockaddr *)&ep->com.remote_addr, 2677 ep->com.thread); |
2597 if (!err) { 2598 init_iwarp_socket(ep->com.so, &ep->com); 2599 goto out; 2600 } else | 2678 if (err) |
2601 goto fail_free_so; | 2679 goto fail_free_so; |
2680 CTR2(KTR_IW_CXGBE, "%s:ccE, ep %p", __func__, ep); 2681 return 0; |
|
2602 2603fail_free_so: | 2682 2683fail_free_so: |
2684 uninit_iwarp_socket(ep->com.so); 2685 ep->com.state = DEAD; |
|
2604 sock_release(ep->com.so); 2605fail: 2606 deref_cm_id(&ep->com); 2607 c4iw_put_ep(&ep->com); 2608 ep = NULL; 2609out: | 2686 sock_release(ep->com.so); 2687fail: 2688 deref_cm_id(&ep->com); 2689 c4iw_put_ep(&ep->com); 2690 ep = NULL; 2691out: |
2610 CTR2(KTR_IW_CXGBE, "%s:ccE ret:%d", __func__, err); | 2692 CTR2(KTR_IW_CXGBE, "%s:ccE Error %d", __func__, err); |
2611 return err; 2612} 2613 2614/* 2615 * iwcm->create_listen. Returns -errno on failure. 2616 */ 2617int 2618c4iw_create_listen(struct iw_cm_id *cm_id, int backlog) --- 45 unchanged lines hidden (view full) --- 2664 } 2665 rc = c4iw_sock_create(&cm_id->local_addr, &lep->com.so); 2666 if (rc) { 2667 CTR2(KTR_IW_CXGBE, "%s:Failed to create socket. err %d", 2668 __func__, rc); 2669 goto fail; 2670 } 2671 | 2693 return err; 2694} 2695 2696/* 2697 * iwcm->create_listen. Returns -errno on failure. 2698 */ 2699int 2700c4iw_create_listen(struct iw_cm_id *cm_id, int backlog) --- 45 unchanged lines hidden (view full) --- 2746 } 2747 rc = c4iw_sock_create(&cm_id->local_addr, &lep->com.so); 2748 if (rc) { 2749 CTR2(KTR_IW_CXGBE, "%s:Failed to create socket. err %d", 2750 __func__, rc); 2751 goto fail; 2752 } 2753 |
2672 rc = solisten(lep->com.so, backlog, curthread); | 2754 rc = -solisten(lep->com.so, backlog, curthread); |
2673 if (rc) { 2674 CTR3(KTR_IW_CXGBE, "%s:Failed to listen on sock:%p. err %d", 2675 __func__, lep->com.so, rc); 2676 goto fail_free_so; 2677 } 2678 init_iwarp_socket(lep->com.so, &lep->com); 2679out: 2680 return 0; --- 295 unchanged lines hidden --- | 2755 if (rc) { 2756 CTR3(KTR_IW_CXGBE, "%s:Failed to listen on sock:%p. err %d", 2757 __func__, lep->com.so, rc); 2758 goto fail_free_so; 2759 } 2760 init_iwarp_socket(lep->com.so, &lep->com); 2761out: 2762 return 0; --- 295 unchanged lines hidden --- |