cm.c (294610) | cm.c (297124) |
---|---|
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: head/sys/dev/cxgbe/iw_cxgbe/cm.c 294610 2016-01-22 23:33:34Z np $"); | 33__FBSDID("$FreeBSD: head/sys/dev/cxgbe/iw_cxgbe/cm.c 297124 2016-03-21 00:29:45Z 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> --- 33 unchanged lines hidden (view full) --- 75static TAILQ_HEAD(c4iw_ep_list, c4iw_ep_common) req_list; 76static struct work_struct c4iw_task; 77static struct workqueue_struct *c4iw_taskq; 78static LIST_HEAD(timeout_list); 79static spinlock_t timeout_lock; 80 81static void process_req(struct work_struct *ctx); 82static void start_ep_timer(struct c4iw_ep *ep); | 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> --- 33 unchanged lines hidden (view full) --- 75static TAILQ_HEAD(c4iw_ep_list, c4iw_ep_common) req_list; 76static struct work_struct c4iw_task; 77static struct workqueue_struct *c4iw_taskq; 78static LIST_HEAD(timeout_list); 79static spinlock_t timeout_lock; 80 81static void process_req(struct work_struct *ctx); 82static void start_ep_timer(struct c4iw_ep *ep); |
83static void stop_ep_timer(struct c4iw_ep *ep); | 83static int stop_ep_timer(struct c4iw_ep *ep); |
84static int set_tcpinfo(struct c4iw_ep *ep); 85static enum c4iw_ep_state state_read(struct c4iw_ep_common *epc); 86static void __state_set(struct c4iw_ep_common *epc, enum c4iw_ep_state tostate); 87static void state_set(struct c4iw_ep_common *epc, enum c4iw_ep_state tostate); 88static void *alloc_ep(int size, gfp_t flags); 89void __free_ep(struct c4iw_ep_common *epc); 90static int find_route(__be32 local_ip, __be32 peer_ip, __be16 local_port, 91 __be16 peer_port, u8 tos, struct nhop4_extended *pnh4); 92static int close_socket(struct c4iw_ep_common *epc, int close); 93static int shutdown_socket(struct c4iw_ep_common *epc); 94static void abort_socket(struct c4iw_ep *ep); 95static void send_mpa_req(struct c4iw_ep *ep); 96static int send_mpa_reject(struct c4iw_ep *ep, const void *pdata, u8 plen); 97static int send_mpa_reply(struct c4iw_ep *ep, const void *pdata, u8 plen); 98static void close_complete_upcall(struct c4iw_ep *ep, int status); | 84static int set_tcpinfo(struct c4iw_ep *ep); 85static enum c4iw_ep_state state_read(struct c4iw_ep_common *epc); 86static void __state_set(struct c4iw_ep_common *epc, enum c4iw_ep_state tostate); 87static void state_set(struct c4iw_ep_common *epc, enum c4iw_ep_state tostate); 88static void *alloc_ep(int size, gfp_t flags); 89void __free_ep(struct c4iw_ep_common *epc); 90static int find_route(__be32 local_ip, __be32 peer_ip, __be16 local_port, 91 __be16 peer_port, u8 tos, struct nhop4_extended *pnh4); 92static int close_socket(struct c4iw_ep_common *epc, int close); 93static int shutdown_socket(struct c4iw_ep_common *epc); 94static void abort_socket(struct c4iw_ep *ep); 95static void send_mpa_req(struct c4iw_ep *ep); 96static int send_mpa_reject(struct c4iw_ep *ep, const void *pdata, u8 plen); 97static int send_mpa_reply(struct c4iw_ep *ep, const void *pdata, u8 plen); 98static void close_complete_upcall(struct c4iw_ep *ep, int status); |
99static int abort_connection(struct c4iw_ep *ep); | 99static int send_abort(struct c4iw_ep *ep); |
100static void peer_close_upcall(struct c4iw_ep *ep); 101static void peer_abort_upcall(struct c4iw_ep *ep); 102static void connect_reply_upcall(struct c4iw_ep *ep, int status); 103static int connect_request_upcall(struct c4iw_ep *ep); 104static void established_upcall(struct c4iw_ep *ep); | 100static void peer_close_upcall(struct c4iw_ep *ep); 101static void peer_abort_upcall(struct c4iw_ep *ep); 102static void connect_reply_upcall(struct c4iw_ep *ep, int status); 103static int connect_request_upcall(struct c4iw_ep *ep); 104static void established_upcall(struct c4iw_ep *ep); |
105static void process_mpa_reply(struct c4iw_ep *ep); 106static void process_mpa_request(struct c4iw_ep *ep); | 105static int process_mpa_reply(struct c4iw_ep *ep); 106static int process_mpa_request(struct c4iw_ep *ep); |
107static void process_peer_close(struct c4iw_ep *ep); 108static void process_conn_error(struct c4iw_ep *ep); 109static void process_close_complete(struct c4iw_ep *ep); 110static void ep_timeout(unsigned long arg); 111static void init_sock(struct c4iw_ep_common *epc); 112static void process_data(struct c4iw_ep *ep); 113static void process_connected(struct c4iw_ep *ep); 114static int c4iw_so_upcall(struct socket *so, void *arg, int waitflag); 115static void process_socket_event(struct c4iw_ep *ep); 116static void release_ep_resources(struct c4iw_ep *ep); 117 118#define START_EP_TIMER(ep) \ 119 do { \ 120 CTR3(KTR_IW_CXGBE, "start_ep_timer (%s:%d) ep %p", \ 121 __func__, __LINE__, (ep)); \ 122 start_ep_timer(ep); \ 123 } while (0) 124 125#define STOP_EP_TIMER(ep) \ | 107static void process_peer_close(struct c4iw_ep *ep); 108static void process_conn_error(struct c4iw_ep *ep); 109static void process_close_complete(struct c4iw_ep *ep); 110static void ep_timeout(unsigned long arg); 111static void init_sock(struct c4iw_ep_common *epc); 112static void process_data(struct c4iw_ep *ep); 113static void process_connected(struct c4iw_ep *ep); 114static int c4iw_so_upcall(struct socket *so, void *arg, int waitflag); 115static void process_socket_event(struct c4iw_ep *ep); 116static void release_ep_resources(struct c4iw_ep *ep); 117 118#define START_EP_TIMER(ep) \ 119 do { \ 120 CTR3(KTR_IW_CXGBE, "start_ep_timer (%s:%d) ep %p", \ 121 __func__, __LINE__, (ep)); \ 122 start_ep_timer(ep); \ 123 } while (0) 124 125#define STOP_EP_TIMER(ep) \ |
126 do { \ | 126 ({ \ |
127 CTR3(KTR_IW_CXGBE, "stop_ep_timer (%s:%d) ep %p", \ 128 __func__, __LINE__, (ep)); \ 129 stop_ep_timer(ep); \ | 127 CTR3(KTR_IW_CXGBE, "stop_ep_timer (%s:%d) ep %p", \ 128 __func__, __LINE__, (ep)); \ 129 stop_ep_timer(ep); \ |
130 } while (0) | 130 }) |
131 132#ifdef KTR 133static char *states[] = { 134 "idle", 135 "listen", 136 "connecting", 137 "mpa_wait_req", 138 "mpa_req_sent", 139 "mpa_req_rcvd", 140 "mpa_rep_sent", 141 "fpdu_mode", 142 "aborting", 143 "closing", 144 "moribund", 145 "dead", 146 NULL, 147}; 148#endif 149 | 131 132#ifdef KTR 133static char *states[] = { 134 "idle", 135 "listen", 136 "connecting", 137 "mpa_wait_req", 138 "mpa_req_sent", 139 "mpa_req_rcvd", 140 "mpa_rep_sent", 141 "fpdu_mode", 142 "aborting", 143 "closing", 144 "moribund", 145 "dead", 146 NULL, 147}; 148#endif 149 |
150 151static void deref_cm_id(struct c4iw_ep_common *epc) 152{ 153 epc->cm_id->rem_ref(epc->cm_id); 154 epc->cm_id = NULL; 155 set_bit(CM_ID_DEREFED, &epc->history); 156} 157 158static void ref_cm_id(struct c4iw_ep_common *epc) 159{ 160 set_bit(CM_ID_REFED, &epc->history); 161 epc->cm_id->add_ref(epc->cm_id); 162} 163 164static void deref_qp(struct c4iw_ep *ep) 165{ 166 c4iw_qp_rem_ref(&ep->com.qp->ibqp); 167 clear_bit(QP_REFERENCED, &ep->com.flags); 168 set_bit(QP_DEREFED, &ep->com.history); 169} 170 171static void ref_qp(struct c4iw_ep *ep) 172{ 173 set_bit(QP_REFERENCED, &ep->com.flags); 174 set_bit(QP_REFED, &ep->com.history); 175 c4iw_qp_add_ref(&ep->com.qp->ibqp); 176} 177 |
|
150static void 151process_req(struct work_struct *ctx) 152{ 153 struct c4iw_ep_common *epc; 154 155 spin_lock(&req_lock); 156 while (!TAILQ_EMPTY(&req_list)) { 157 epc = TAILQ_FIRST(&req_list); --- 141 unchanged lines hidden (view full) --- 299 CTR2(KTR_IW_CXGBE, "%s:ppc2 %p MPA_REQ_SENT CLOSING", 300 __func__, ep); 301 __state_set(&ep->com, DEAD); 302 connect_reply_upcall(ep, -ECONNABORTED); 303 304 disconnect = 0; 305 STOP_EP_TIMER(ep); 306 close_socket(&ep->com, 0); | 178static void 179process_req(struct work_struct *ctx) 180{ 181 struct c4iw_ep_common *epc; 182 183 spin_lock(&req_lock); 184 while (!TAILQ_EMPTY(&req_list)) { 185 epc = TAILQ_FIRST(&req_list); --- 141 unchanged lines hidden (view full) --- 327 CTR2(KTR_IW_CXGBE, "%s:ppc2 %p MPA_REQ_SENT CLOSING", 328 __func__, ep); 329 __state_set(&ep->com, DEAD); 330 connect_reply_upcall(ep, -ECONNABORTED); 331 332 disconnect = 0; 333 STOP_EP_TIMER(ep); 334 close_socket(&ep->com, 0); |
307 ep->com.cm_id->rem_ref(ep->com.cm_id); 308 ep->com.cm_id = NULL; 309 ep->com.qp = NULL; | 335 deref_cm_id(&ep->com); |
310 release = 1; 311 break; 312 313 case MPA_REQ_RCVD: 314 315 /* 316 * We're gonna mark this puppy DEAD, but keep 317 * the reference on it until the ULP accepts or --- 167 unchanged lines hidden (view full) --- 485 struct c4iw_qp_attributes attrs; 486 int release = 0; 487 488 CTR4(KTR_IW_CXGBE, "%s:pccB ep %p so %p state %s", __func__, ep, 489 ep->com.so, states[ep->com.state]); 490 491 /* The cm_id may be null if we failed to connect */ 492 mutex_lock(&ep->com.mutex); | 336 release = 1; 337 break; 338 339 case MPA_REQ_RCVD: 340 341 /* 342 * We're gonna mark this puppy DEAD, but keep 343 * the reference on it until the ULP accepts or --- 167 unchanged lines hidden (view full) --- 511 struct c4iw_qp_attributes attrs; 512 int release = 0; 513 514 CTR4(KTR_IW_CXGBE, "%s:pccB ep %p so %p state %s", __func__, ep, 515 ep->com.so, states[ep->com.state]); 516 517 /* The cm_id may be null if we failed to connect */ 518 mutex_lock(&ep->com.mutex); |
519 set_bit(CLOSE_CON_RPL, &ep->com.history); |
|
493 494 switch (ep->com.state) { 495 496 case CLOSING: 497 CTR2(KTR_IW_CXGBE, "%s:pcc1 %p CLOSING MORIBUND", 498 __func__, ep); 499 __state_set(&ep->com, MORIBUND); 500 break; --- 74 unchanged lines hidden (view full) --- 575 __func__, so, rc); 576 } 577} 578 579static void 580process_data(struct c4iw_ep *ep) 581{ 582 struct sockaddr_in *local, *remote; | 520 521 switch (ep->com.state) { 522 523 case CLOSING: 524 CTR2(KTR_IW_CXGBE, "%s:pcc1 %p CLOSING MORIBUND", 525 __func__, ep); 526 __state_set(&ep->com, MORIBUND); 527 break; --- 74 unchanged lines hidden (view full) --- 602 __func__, so, rc); 603 } 604} 605 606static void 607process_data(struct c4iw_ep *ep) 608{ 609 struct sockaddr_in *local, *remote; |
610 int disconnect = 0; |
|
583 584 CTR5(KTR_IW_CXGBE, "%s: so %p, ep %p, state %s, sbused %d", __func__, 585 ep->com.so, ep, states[ep->com.state], sbused(&ep->com.so->so_rcv)); 586 587 switch (state_read(&ep->com)) { 588 case MPA_REQ_SENT: | 611 612 CTR5(KTR_IW_CXGBE, "%s: so %p, ep %p, state %s, sbused %d", __func__, 613 ep->com.so, ep, states[ep->com.state], sbused(&ep->com.so->so_rcv)); 614 615 switch (state_read(&ep->com)) { 616 case MPA_REQ_SENT: |
589 process_mpa_reply(ep); | 617 disconnect = process_mpa_reply(ep); |
590 break; 591 case MPA_REQ_WAIT: 592 in_getsockaddr(ep->com.so, (struct sockaddr **)&local); 593 in_getpeeraddr(ep->com.so, (struct sockaddr **)&remote); 594 ep->com.local_addr = *local; 595 ep->com.remote_addr = *remote; 596 free(local, M_SONAME); 597 free(remote, M_SONAME); | 618 break; 619 case MPA_REQ_WAIT: 620 in_getsockaddr(ep->com.so, (struct sockaddr **)&local); 621 in_getpeeraddr(ep->com.so, (struct sockaddr **)&remote); 622 ep->com.local_addr = *local; 623 ep->com.remote_addr = *remote; 624 free(local, M_SONAME); 625 free(remote, M_SONAME); |
598 process_mpa_request(ep); | 626 disconnect = process_mpa_request(ep); |
599 break; 600 default: 601 if (sbused(&ep->com.so->so_rcv)) 602 log(LOG_ERR, "%s: Unexpected streaming data. ep %p, " 603 "state %d, so %p, so_state 0x%x, sbused %u\n", 604 __func__, ep, state_read(&ep->com), ep->com.so, 605 ep->com.so->so_state, sbused(&ep->com.so->so_rcv)); 606 break; 607 } | 627 break; 628 default: 629 if (sbused(&ep->com.so->so_rcv)) 630 log(LOG_ERR, "%s: Unexpected streaming data. ep %p, " 631 "state %d, so %p, so_state 0x%x, sbused %u\n", 632 __func__, ep, state_read(&ep->com), ep->com.so, 633 ep->com.so->so_state, sbused(&ep->com.so->so_rcv)); 634 break; 635 } |
636 if (disconnect) 637 c4iw_ep_disconnect(ep, disconnect == 2, GFP_KERNEL); 638 |
|
608} 609 610static void 611process_connected(struct c4iw_ep *ep) 612{ 613 614 if ((ep->com.so->so_state & SS_ISCONNECTED) && !ep->com.so->so_error) 615 send_mpa_req(ep); --- 128 unchanged lines hidden (view full) --- 744} 745 746SYSCTL_NODE(_hw, OID_AUTO, iw_cxgbe, CTLFLAG_RD, 0, "iw_cxgbe driver parameters"); 747 748int db_delay_usecs = 1; 749SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, db_delay_usecs, CTLFLAG_RWTUN, &db_delay_usecs, 0, 750 "Usecs to delay awaiting db fifo to drain"); 751 | 639} 640 641static void 642process_connected(struct c4iw_ep *ep) 643{ 644 645 if ((ep->com.so->so_state & SS_ISCONNECTED) && !ep->com.so->so_error) 646 send_mpa_req(ep); --- 128 unchanged lines hidden (view full) --- 775} 776 777SYSCTL_NODE(_hw, OID_AUTO, iw_cxgbe, CTLFLAG_RD, 0, "iw_cxgbe driver parameters"); 778 779int db_delay_usecs = 1; 780SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, db_delay_usecs, CTLFLAG_RWTUN, &db_delay_usecs, 0, 781 "Usecs to delay awaiting db fifo to drain"); 782 |
752static int dack_mode = 1; | 783static int dack_mode = 0; |
753SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, dack_mode, CTLFLAG_RWTUN, &dack_mode, 0, | 784SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, dack_mode, CTLFLAG_RWTUN, &dack_mode, 0, |
754 "Delayed ack mode (default = 1)"); | 785 "Delayed ack mode (default = 0)"); |
755 756int c4iw_max_read_depth = 8; 757SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_max_read_depth, CTLFLAG_RWTUN, &c4iw_max_read_depth, 0, 758 "Per-connection max ORD/IRD (default = 8)"); 759 760static int enable_tcp_timestamps; 761SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_timestamps, CTLFLAG_RWTUN, &enable_tcp_timestamps, 0, 762 "Enable tcp timestamps (default = 0)"); --- 5 unchanged lines hidden (view full) --- 768static int enable_tcp_window_scaling = 1; 769SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_window_scaling, CTLFLAG_RWTUN, &enable_tcp_window_scaling, 0, 770 "Enable tcp window scaling (default = 1)"); 771 772int c4iw_debug = 1; 773SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_debug, CTLFLAG_RWTUN, &c4iw_debug, 0, 774 "Enable debug logging (default = 0)"); 775 | 786 787int c4iw_max_read_depth = 8; 788SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_max_read_depth, CTLFLAG_RWTUN, &c4iw_max_read_depth, 0, 789 "Per-connection max ORD/IRD (default = 8)"); 790 791static int enable_tcp_timestamps; 792SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_timestamps, CTLFLAG_RWTUN, &enable_tcp_timestamps, 0, 793 "Enable tcp timestamps (default = 0)"); --- 5 unchanged lines hidden (view full) --- 799static int enable_tcp_window_scaling = 1; 800SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_window_scaling, CTLFLAG_RWTUN, &enable_tcp_window_scaling, 0, 801 "Enable tcp window scaling (default = 1)"); 802 803int c4iw_debug = 1; 804SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_debug, CTLFLAG_RWTUN, &c4iw_debug, 0, 805 "Enable debug logging (default = 0)"); 806 |
776static int peer2peer; | 807static int peer2peer = 1; |
777SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, peer2peer, CTLFLAG_RWTUN, &peer2peer, 0, | 808SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, peer2peer, CTLFLAG_RWTUN, &peer2peer, 0, |
778 "Support peer2peer ULPs (default = 0)"); | 809 "Support peer2peer ULPs (default = 1)"); |
779 780static int p2p_type = FW_RI_INIT_P2PTYPE_READ_REQ; 781SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, p2p_type, CTLFLAG_RWTUN, &p2p_type, 0, 782 "RDMAP opcode to use for the RTR message: 1 = RDMA_READ 0 = RDMA_WRITE (default 1)"); 783 784static int ep_timeout_secs = 60; 785SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, ep_timeout_secs, CTLFLAG_RWTUN, &ep_timeout_secs, 0, 786 "CM Endpoint operation timeout in seconds (default = 60)"); --- 35 unchanged lines hidden (view full) --- 822 clear_bit(TIMEOUT, &ep->com.flags); 823 c4iw_get_ep(&ep->com); 824 ep->timer.expires = jiffies + ep_timeout_secs * HZ; 825 ep->timer.data = (unsigned long)ep; 826 ep->timer.function = ep_timeout; 827 add_timer(&ep->timer); 828} 829 | 810 811static int p2p_type = FW_RI_INIT_P2PTYPE_READ_REQ; 812SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, p2p_type, CTLFLAG_RWTUN, &p2p_type, 0, 813 "RDMAP opcode to use for the RTR message: 1 = RDMA_READ 0 = RDMA_WRITE (default 1)"); 814 815static int ep_timeout_secs = 60; 816SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, ep_timeout_secs, CTLFLAG_RWTUN, &ep_timeout_secs, 0, 817 "CM Endpoint operation timeout in seconds (default = 60)"); --- 35 unchanged lines hidden (view full) --- 853 clear_bit(TIMEOUT, &ep->com.flags); 854 c4iw_get_ep(&ep->com); 855 ep->timer.expires = jiffies + ep_timeout_secs * HZ; 856 ep->timer.data = (unsigned long)ep; 857 ep->timer.function = ep_timeout; 858 add_timer(&ep->timer); 859} 860 |
830static void | 861static int |
831stop_ep_timer(struct c4iw_ep *ep) 832{ 833 834 del_timer_sync(&ep->timer); 835 if (!test_and_set_bit(TIMEOUT, &ep->com.flags)) { 836 c4iw_put_ep(&ep->com); | 862stop_ep_timer(struct c4iw_ep *ep) 863{ 864 865 del_timer_sync(&ep->timer); 866 if (!test_and_set_bit(TIMEOUT, &ep->com.flags)) { 867 c4iw_put_ep(&ep->com); |
868 return 0; |
|
837 } | 869 } |
870 return 1; |
|
838} 839 840static enum 841c4iw_ep_state state_read(struct c4iw_ep_common *epc) 842{ 843 enum c4iw_ep_state state; 844 845 mutex_lock(&epc->mutex); --- 49 unchanged lines hidden (view full) --- 895{ 896 struct c4iw_ep *ep; 897 struct c4iw_ep_common *epc; 898 899 ep = container_of(kref, struct c4iw_ep, com.kref); 900 epc = &ep->com; 901 KASSERT(!epc->entry.tqe_prev, ("%s epc %p still on req list", 902 __func__, epc)); | 871} 872 873static enum 874c4iw_ep_state state_read(struct c4iw_ep_common *epc) 875{ 876 enum c4iw_ep_state state; 877 878 mutex_lock(&epc->mutex); --- 49 unchanged lines hidden (view full) --- 928{ 929 struct c4iw_ep *ep; 930 struct c4iw_ep_common *epc; 931 932 ep = container_of(kref, struct c4iw_ep, com.kref); 933 epc = &ep->com; 934 KASSERT(!epc->entry.tqe_prev, ("%s epc %p still on req list", 935 __func__, epc)); |
936 if (test_bit(QP_REFERENCED, &ep->com.flags)) 937 deref_qp(ep); |
|
903 kfree(ep); 904} 905 906static void release_ep_resources(struct c4iw_ep *ep) 907{ 908 CTR2(KTR_IW_CXGBE, "%s:rerB %p", __func__, ep); 909 set_bit(RELEASE_RESOURCES, &ep->com.flags); 910 c4iw_put_ep(&ep->com); --- 259 unchanged lines hidden (view full) --- 1170 memset(&event, 0, sizeof(event)); 1171 event.event = IW_CM_EVENT_CLOSE; 1172 event.status = status; 1173 1174 if (ep->com.cm_id) { 1175 1176 CTR2(KTR_IW_CXGBE, "%s:ccu1 %1", __func__, ep); 1177 ep->com.cm_id->event_handler(ep->com.cm_id, &event); | 938 kfree(ep); 939} 940 941static void release_ep_resources(struct c4iw_ep *ep) 942{ 943 CTR2(KTR_IW_CXGBE, "%s:rerB %p", __func__, ep); 944 set_bit(RELEASE_RESOURCES, &ep->com.flags); 945 c4iw_put_ep(&ep->com); --- 259 unchanged lines hidden (view full) --- 1205 memset(&event, 0, sizeof(event)); 1206 event.event = IW_CM_EVENT_CLOSE; 1207 event.status = status; 1208 1209 if (ep->com.cm_id) { 1210 1211 CTR2(KTR_IW_CXGBE, "%s:ccu1 %1", __func__, ep); 1212 ep->com.cm_id->event_handler(ep->com.cm_id, &event); |
1178 ep->com.cm_id->rem_ref(ep->com.cm_id); 1179 ep->com.cm_id = NULL; 1180 ep->com.qp = NULL; | 1213 deref_cm_id(&ep->com); |
1181 set_bit(CLOSE_UPCALL, &ep->com.history); 1182 } 1183 CTR2(KTR_IW_CXGBE, "%s:ccuE %p", __func__, ep); 1184} 1185 | 1214 set_bit(CLOSE_UPCALL, &ep->com.history); 1215 } 1216 CTR2(KTR_IW_CXGBE, "%s:ccuE %p", __func__, ep); 1217} 1218 |
1186static int abort_connection(struct c4iw_ep *ep) | 1219static int send_abort(struct c4iw_ep *ep) |
1187{ 1188 int err; 1189 1190 CTR2(KTR_IW_CXGBE, "%s:abB %p", __func__, ep); | 1220{ 1221 int err; 1222 1223 CTR2(KTR_IW_CXGBE, "%s:abB %p", __func__, ep); |
1191 state_set(&ep->com, ABORTING); | |
1192 abort_socket(ep); 1193 err = close_socket(&ep->com, 0); 1194 set_bit(ABORT_CONN, &ep->com.history); 1195 CTR2(KTR_IW_CXGBE, "%s:abE %p", __func__, ep); 1196 return err; 1197} 1198 1199static void peer_close_upcall(struct c4iw_ep *ep) --- 21 unchanged lines hidden (view full) --- 1221 memset(&event, 0, sizeof(event)); 1222 event.event = IW_CM_EVENT_CLOSE; 1223 event.status = -ECONNRESET; 1224 1225 if (ep->com.cm_id) { 1226 1227 CTR2(KTR_IW_CXGBE, "%s:pau1 %p", __func__, ep); 1228 ep->com.cm_id->event_handler(ep->com.cm_id, &event); | 1224 abort_socket(ep); 1225 err = close_socket(&ep->com, 0); 1226 set_bit(ABORT_CONN, &ep->com.history); 1227 CTR2(KTR_IW_CXGBE, "%s:abE %p", __func__, ep); 1228 return err; 1229} 1230 1231static void peer_close_upcall(struct c4iw_ep *ep) --- 21 unchanged lines hidden (view full) --- 1253 memset(&event, 0, sizeof(event)); 1254 event.event = IW_CM_EVENT_CLOSE; 1255 event.status = -ECONNRESET; 1256 1257 if (ep->com.cm_id) { 1258 1259 CTR2(KTR_IW_CXGBE, "%s:pau1 %p", __func__, ep); 1260 ep->com.cm_id->event_handler(ep->com.cm_id, &event); |
1229 ep->com.cm_id->rem_ref(ep->com.cm_id); 1230 ep->com.cm_id = NULL; 1231 ep->com.qp = NULL; | 1261 deref_cm_id(&ep->com); |
1232 set_bit(ABORT_UPCALL, &ep->com.history); 1233 } 1234 CTR2(KTR_IW_CXGBE, "%s:pauE %p", __func__, ep); 1235} 1236 1237static void connect_reply_upcall(struct c4iw_ep *ep, int status) 1238{ 1239 struct iw_cm_event event; --- 37 unchanged lines hidden (view full) --- 1277 1278 CTR3(KTR_IW_CXGBE, "%s:cruE %p %d", __func__, ep, status); 1279 return; 1280 } 1281 1282 if (status < 0) { 1283 1284 CTR3(KTR_IW_CXGBE, "%s:cru4 %p %d", __func__, ep, status); | 1262 set_bit(ABORT_UPCALL, &ep->com.history); 1263 } 1264 CTR2(KTR_IW_CXGBE, "%s:pauE %p", __func__, ep); 1265} 1266 1267static void connect_reply_upcall(struct c4iw_ep *ep, int status) 1268{ 1269 struct iw_cm_event event; --- 37 unchanged lines hidden (view full) --- 1307 1308 CTR3(KTR_IW_CXGBE, "%s:cruE %p %d", __func__, ep, status); 1309 return; 1310 } 1311 1312 if (status < 0) { 1313 1314 CTR3(KTR_IW_CXGBE, "%s:cru4 %p %d", __func__, ep, status); |
1285 ep->com.cm_id->rem_ref(ep->com.cm_id); 1286 ep->com.cm_id = NULL; 1287 ep->com.qp = NULL; | 1315 deref_cm_id(&ep->com); |
1288 } 1289 1290 CTR2(KTR_IW_CXGBE, "%s:cruE %p", __func__, ep); 1291} 1292 1293static int connect_request_upcall(struct c4iw_ep *ep) 1294{ 1295 struct iw_cm_event event; --- 52 unchanged lines hidden (view full) --- 1348 CTR2(KTR_IW_CXGBE, "%s:eu1 %p", __func__, ep); 1349 ep->com.cm_id->event_handler(ep->com.cm_id, &event); 1350 set_bit(ESTAB_UPCALL, &ep->com.history); 1351 } 1352 CTR2(KTR_IW_CXGBE, "%s:euE %p", __func__, ep); 1353} 1354 1355 | 1316 } 1317 1318 CTR2(KTR_IW_CXGBE, "%s:cruE %p", __func__, ep); 1319} 1320 1321static int connect_request_upcall(struct c4iw_ep *ep) 1322{ 1323 struct iw_cm_event event; --- 52 unchanged lines hidden (view full) --- 1376 CTR2(KTR_IW_CXGBE, "%s:eu1 %p", __func__, ep); 1377 ep->com.cm_id->event_handler(ep->com.cm_id, &event); 1378 set_bit(ESTAB_UPCALL, &ep->com.history); 1379 } 1380 CTR2(KTR_IW_CXGBE, "%s:euE %p", __func__, ep); 1381} 1382 1383 |
1356 1357static void process_mpa_reply(struct c4iw_ep *ep) | 1384/* 1385 * process_mpa_reply - process streaming mode MPA reply 1386 * 1387 * Returns: 1388 * 1389 * 0 upon success indicating a connect request was delivered to the ULP 1390 * or the mpa request is incomplete but valid so far. 1391 * 1392 * 1 if a failure requires the caller to close the connection. 1393 * 1394 * 2 if a failure requires the caller to abort the connection. 1395 */ 1396static int process_mpa_reply(struct c4iw_ep *ep) |
1358{ 1359 struct mpa_message *mpa; 1360 struct mpa_v2_conn_params *mpa_v2_params; 1361 u16 plen; 1362 u16 resp_ird, resp_ord; 1363 u8 rtr_mismatch = 0, insuff_ird = 0; 1364 struct c4iw_qp_attributes attrs; 1365 enum c4iw_qp_attr_mask mask; 1366 int err; 1367 struct mbuf *top, *m; 1368 int flags = MSG_DONTWAIT; 1369 struct uio uio; | 1397{ 1398 struct mpa_message *mpa; 1399 struct mpa_v2_conn_params *mpa_v2_params; 1400 u16 plen; 1401 u16 resp_ird, resp_ord; 1402 u8 rtr_mismatch = 0, insuff_ird = 0; 1403 struct c4iw_qp_attributes attrs; 1404 enum c4iw_qp_attr_mask mask; 1405 int err; 1406 struct mbuf *top, *m; 1407 int flags = MSG_DONTWAIT; 1408 struct uio uio; |
1409 int disconnect = 0; |
|
1370 1371 CTR2(KTR_IW_CXGBE, "%s:pmrB %p", __func__, ep); 1372 1373 /* | 1410 1411 CTR2(KTR_IW_CXGBE, "%s:pmrB %p", __func__, ep); 1412 1413 /* |
1374 * Stop mpa timer. If it expired, then the state has 1375 * changed and we bail since ep_timeout already aborted 1376 * the connection. | 1414 * Stop mpa timer. If it expired, then 1415 * we ignore the MPA reply. process_timeout() 1416 * will abort the connection. |
1377 */ | 1417 */ |
1378 STOP_EP_TIMER(ep); 1379 if (state_read(&ep->com) != MPA_REQ_SENT) 1380 return; | 1418 if (STOP_EP_TIMER(ep)) 1419 return 0; |
1381 1382 uio.uio_resid = 1000000; 1383 uio.uio_td = ep->com.thread; 1384 err = soreceive(ep->com.so, NULL, &uio, &top, NULL, &flags); 1385 1386 if (err) { 1387 1388 if (err == EWOULDBLOCK) { 1389 1390 CTR2(KTR_IW_CXGBE, "%s:pmr1 %p", __func__, ep); 1391 START_EP_TIMER(ep); | 1420 1421 uio.uio_resid = 1000000; 1422 uio.uio_td = ep->com.thread; 1423 err = soreceive(ep->com.so, NULL, &uio, &top, NULL, &flags); 1424 1425 if (err) { 1426 1427 if (err == EWOULDBLOCK) { 1428 1429 CTR2(KTR_IW_CXGBE, "%s:pmr1 %p", __func__, ep); 1430 START_EP_TIMER(ep); |
1392 return; | 1431 return 0; |
1393 } 1394 err = -err; 1395 CTR2(KTR_IW_CXGBE, "%s:pmr2 %p", __func__, ep); 1396 goto err; 1397 } 1398 1399 if (ep->com.so->so_rcv.sb_mb) { 1400 --- 11 unchanged lines hidden (view full) --- 1412 * If we get more than the supported amount of private data 1413 * then we must fail this connection. 1414 */ 1415 if (ep->mpa_pkt_len + m->m_len > sizeof(ep->mpa_pkt)) { 1416 1417 CTR3(KTR_IW_CXGBE, "%s:pmr5 %p %d", __func__, ep, 1418 ep->mpa_pkt_len + m->m_len); 1419 err = (-EINVAL); | 1432 } 1433 err = -err; 1434 CTR2(KTR_IW_CXGBE, "%s:pmr2 %p", __func__, ep); 1435 goto err; 1436 } 1437 1438 if (ep->com.so->so_rcv.sb_mb) { 1439 --- 11 unchanged lines hidden (view full) --- 1451 * If we get more than the supported amount of private data 1452 * then we must fail this connection. 1453 */ 1454 if (ep->mpa_pkt_len + m->m_len > sizeof(ep->mpa_pkt)) { 1455 1456 CTR3(KTR_IW_CXGBE, "%s:pmr5 %p %d", __func__, ep, 1457 ep->mpa_pkt_len + m->m_len); 1458 err = (-EINVAL); |
1420 goto err; | 1459 goto err_stop_timer; |
1421 } 1422 1423 /* 1424 * copy the new data into our accumulation buffer. 1425 */ 1426 m_copydata(m, 0, m->m_len, &(ep->mpa_pkt[ep->mpa_pkt_len])); 1427 ep->mpa_pkt_len += m->m_len; 1428 if (!m->m_next) 1429 m = m->m_nextpkt; 1430 else 1431 m = m->m_next; 1432 } while (m); 1433 1434 m_freem(top); 1435 /* 1436 * if we don't even have the mpa message, then bail. 1437 */ | 1460 } 1461 1462 /* 1463 * copy the new data into our accumulation buffer. 1464 */ 1465 m_copydata(m, 0, m->m_len, &(ep->mpa_pkt[ep->mpa_pkt_len])); 1466 ep->mpa_pkt_len += m->m_len; 1467 if (!m->m_next) 1468 m = m->m_nextpkt; 1469 else 1470 m = m->m_next; 1471 } while (m); 1472 1473 m_freem(top); 1474 /* 1475 * if we don't even have the mpa message, then bail. 1476 */ |
1438 if (ep->mpa_pkt_len < sizeof(*mpa)) 1439 return; | 1477 if (ep->mpa_pkt_len < sizeof(*mpa)) { 1478 return 0; 1479 } |
1440 mpa = (struct mpa_message *) ep->mpa_pkt; 1441 1442 /* Validate MPA header. */ 1443 if (mpa->revision > mpa_rev) { 1444 1445 CTR4(KTR_IW_CXGBE, "%s:pmr6 %p %d %d", __func__, ep, 1446 mpa->revision, mpa_rev); 1447 printk(KERN_ERR MOD "%s MPA version mismatch. Local = %d, " 1448 " Received = %d\n", __func__, mpa_rev, mpa->revision); 1449 err = -EPROTO; | 1480 mpa = (struct mpa_message *) ep->mpa_pkt; 1481 1482 /* Validate MPA header. */ 1483 if (mpa->revision > mpa_rev) { 1484 1485 CTR4(KTR_IW_CXGBE, "%s:pmr6 %p %d %d", __func__, ep, 1486 mpa->revision, mpa_rev); 1487 printk(KERN_ERR MOD "%s MPA version mismatch. Local = %d, " 1488 " Received = %d\n", __func__, mpa_rev, mpa->revision); 1489 err = -EPROTO; |
1450 goto err; | 1490 goto err_stop_timer; |
1451 } 1452 1453 if (memcmp(mpa->key, MPA_KEY_REP, sizeof(mpa->key))) { 1454 1455 CTR2(KTR_IW_CXGBE, "%s:pmr7 %p", __func__, ep); 1456 err = -EPROTO; | 1491 } 1492 1493 if (memcmp(mpa->key, MPA_KEY_REP, sizeof(mpa->key))) { 1494 1495 CTR2(KTR_IW_CXGBE, "%s:pmr7 %p", __func__, ep); 1496 err = -EPROTO; |
1457 goto err; | 1497 goto err_stop_timer; |
1458 } 1459 1460 plen = ntohs(mpa->private_data_size); 1461 1462 /* 1463 * Fail if there's too much private data. 1464 */ 1465 if (plen > MPA_MAX_PRIVATE_DATA) { 1466 1467 CTR2(KTR_IW_CXGBE, "%s:pmr8 %p", __func__, ep); 1468 err = -EPROTO; | 1498 } 1499 1500 plen = ntohs(mpa->private_data_size); 1501 1502 /* 1503 * Fail if there's too much private data. 1504 */ 1505 if (plen > MPA_MAX_PRIVATE_DATA) { 1506 1507 CTR2(KTR_IW_CXGBE, "%s:pmr8 %p", __func__, ep); 1508 err = -EPROTO; |
1469 goto err; | 1509 goto err_stop_timer; |
1470 } 1471 1472 /* 1473 * If plen does not account for pkt size 1474 */ 1475 if (ep->mpa_pkt_len > (sizeof(*mpa) + plen)) { 1476 1477 CTR2(KTR_IW_CXGBE, "%s:pmr9 %p", __func__, ep); | 1510 } 1511 1512 /* 1513 * If plen does not account for pkt size 1514 */ 1515 if (ep->mpa_pkt_len > (sizeof(*mpa) + plen)) { 1516 1517 CTR2(KTR_IW_CXGBE, "%s:pmr9 %p", __func__, ep); |
1518 STOP_EP_TIMER(ep); |
|
1478 err = -EPROTO; | 1519 err = -EPROTO; |
1479 goto err; | 1520 goto err_stop_timer; |
1480 } 1481 1482 ep->plen = (u8) plen; 1483 1484 /* 1485 * If we don't have all the pdata yet, then bail. 1486 * We'll continue process when more data arrives. 1487 */ 1488 if (ep->mpa_pkt_len < (sizeof(*mpa) + plen)) { 1489 1490 CTR2(KTR_IW_CXGBE, "%s:pmra %p", __func__, ep); | 1521 } 1522 1523 ep->plen = (u8) plen; 1524 1525 /* 1526 * If we don't have all the pdata yet, then bail. 1527 * We'll continue process when more data arrives. 1528 */ 1529 if (ep->mpa_pkt_len < (sizeof(*mpa) + plen)) { 1530 1531 CTR2(KTR_IW_CXGBE, "%s:pmra %p", __func__, ep); |
1491 return; | 1532 return 0; |
1492 } 1493 1494 if (mpa->flags & MPA_REJECT) { 1495 1496 CTR2(KTR_IW_CXGBE, "%s:pmrb %p", __func__, ep); 1497 err = -ECONNREFUSED; | 1533 } 1534 1535 if (mpa->flags & MPA_REJECT) { 1536 1537 CTR2(KTR_IW_CXGBE, "%s:pmrb %p", __func__, ep); 1538 err = -ECONNREFUSED; |
1498 goto err; | 1539 goto err_stop_timer; |
1499 } 1500 1501 /* 1502 * If we get here we have accumulated the entire mpa 1503 * start reply message including private data. And 1504 * the MPA header is valid. 1505 */ 1506 state_set(&ep->com, FPDU_MODE); --- 126 unchanged lines hidden (view full) --- 1633 CTR2(KTR_IW_CXGBE, "%s:pmro %p", __func__, ep); 1634 printk(KERN_ERR "%s: RTR mismatch, sending TERM\n", __func__); 1635 attrs.layer_etype = LAYER_MPA | DDP_LLP; 1636 attrs.ecode = MPA_NOMATCH_RTR; 1637 attrs.next_state = C4IW_QP_STATE_TERMINATE; 1638 err = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp, 1639 C4IW_QP_ATTR_NEXT_STATE, &attrs, 0); 1640 err = -ENOMEM; | 1540 } 1541 1542 /* 1543 * If we get here we have accumulated the entire mpa 1544 * start reply message including private data. And 1545 * the MPA header is valid. 1546 */ 1547 state_set(&ep->com, FPDU_MODE); --- 126 unchanged lines hidden (view full) --- 1674 CTR2(KTR_IW_CXGBE, "%s:pmro %p", __func__, ep); 1675 printk(KERN_ERR "%s: RTR mismatch, sending TERM\n", __func__); 1676 attrs.layer_etype = LAYER_MPA | DDP_LLP; 1677 attrs.ecode = MPA_NOMATCH_RTR; 1678 attrs.next_state = C4IW_QP_STATE_TERMINATE; 1679 err = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp, 1680 C4IW_QP_ATTR_NEXT_STATE, &attrs, 0); 1681 err = -ENOMEM; |
1682 disconnect = 1; |
|
1641 goto out; 1642 } 1643 1644 /* 1645 * Generate TERM if initiator IRD is not sufficient for responder 1646 * provided ORD. Currently, we do the same behaviour even when 1647 * responder provided IRD is also not sufficient as regards to 1648 * initiator ORD. --- 4 unchanged lines hidden (view full) --- 1653 printk(KERN_ERR "%s: Insufficient IRD, sending TERM\n", 1654 __func__); 1655 attrs.layer_etype = LAYER_MPA | DDP_LLP; 1656 attrs.ecode = MPA_INSUFF_IRD; 1657 attrs.next_state = C4IW_QP_STATE_TERMINATE; 1658 err = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp, 1659 C4IW_QP_ATTR_NEXT_STATE, &attrs, 0); 1660 err = -ENOMEM; | 1683 goto out; 1684 } 1685 1686 /* 1687 * Generate TERM if initiator IRD is not sufficient for responder 1688 * provided ORD. Currently, we do the same behaviour even when 1689 * responder provided IRD is also not sufficient as regards to 1690 * initiator ORD. --- 4 unchanged lines hidden (view full) --- 1695 printk(KERN_ERR "%s: Insufficient IRD, sending TERM\n", 1696 __func__); 1697 attrs.layer_etype = LAYER_MPA | DDP_LLP; 1698 attrs.ecode = MPA_INSUFF_IRD; 1699 attrs.next_state = C4IW_QP_STATE_TERMINATE; 1700 err = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp, 1701 C4IW_QP_ATTR_NEXT_STATE, &attrs, 0); 1702 err = -ENOMEM; |
1703 disconnect = 1; |
|
1661 goto out; 1662 } 1663 goto out; | 1704 goto out; 1705 } 1706 goto out; |
1707err_stop_timer: 1708 STOP_EP_TIMER(ep); |
|
1664err: | 1709err: |
1665 state_set(&ep->com, ABORTING); 1666 abort_connection(ep); | 1710 disconnect = 2; |
1667out: 1668 connect_reply_upcall(ep, err); 1669 CTR2(KTR_IW_CXGBE, "%s:pmrE %p", __func__, ep); | 1711out: 1712 connect_reply_upcall(ep, err); 1713 CTR2(KTR_IW_CXGBE, "%s:pmrE %p", __func__, ep); |
1670 return; | 1714 return disconnect; |
1671} 1672 | 1715} 1716 |
1673static void | 1717/* 1718 * process_mpa_request - process streaming mode MPA request 1719 * 1720 * Returns: 1721 * 1722 * 0 upon success indicating a connect request was delivered to the ULP 1723 * or the mpa request is incomplete but valid so far. 1724 * 1725 * 1 if a failure requires the caller to close the connection. 1726 * 1727 * 2 if a failure requires the caller to abort the connection. 1728 */ 1729static int |
1674process_mpa_request(struct c4iw_ep *ep) 1675{ 1676 struct mpa_message *mpa; 1677 u16 plen; 1678 int flags = MSG_DONTWAIT; 1679 int rc; 1680 struct iovec iov; 1681 struct uio uio; 1682 enum c4iw_ep_state state = state_read(&ep->com); 1683 1684 CTR3(KTR_IW_CXGBE, "%s: ep %p, state %s", __func__, ep, states[state]); 1685 1686 if (state != MPA_REQ_WAIT) | 1730process_mpa_request(struct c4iw_ep *ep) 1731{ 1732 struct mpa_message *mpa; 1733 u16 plen; 1734 int flags = MSG_DONTWAIT; 1735 int rc; 1736 struct iovec iov; 1737 struct uio uio; 1738 enum c4iw_ep_state state = state_read(&ep->com); 1739 1740 CTR3(KTR_IW_CXGBE, "%s: ep %p, state %s", __func__, ep, states[state]); 1741 1742 if (state != MPA_REQ_WAIT) |
1687 return; | 1743 return 0; |
1688 1689 iov.iov_base = &ep->mpa_pkt[ep->mpa_pkt_len]; 1690 iov.iov_len = sizeof(ep->mpa_pkt) - ep->mpa_pkt_len; 1691 uio.uio_iov = &iov; 1692 uio.uio_iovcnt = 1; 1693 uio.uio_offset = 0; 1694 uio.uio_resid = sizeof(ep->mpa_pkt) - ep->mpa_pkt_len; 1695 uio.uio_segflg = UIO_SYSSPACE; 1696 uio.uio_rw = UIO_READ; 1697 uio.uio_td = NULL; /* uio.uio_td = ep->com.thread; */ 1698 1699 rc = soreceive(ep->com.so, NULL, &uio, NULL, NULL, &flags); 1700 if (rc == EAGAIN) | 1744 1745 iov.iov_base = &ep->mpa_pkt[ep->mpa_pkt_len]; 1746 iov.iov_len = sizeof(ep->mpa_pkt) - ep->mpa_pkt_len; 1747 uio.uio_iov = &iov; 1748 uio.uio_iovcnt = 1; 1749 uio.uio_offset = 0; 1750 uio.uio_resid = sizeof(ep->mpa_pkt) - ep->mpa_pkt_len; 1751 uio.uio_segflg = UIO_SYSSPACE; 1752 uio.uio_rw = UIO_READ; 1753 uio.uio_td = NULL; /* uio.uio_td = ep->com.thread; */ 1754 1755 rc = soreceive(ep->com.so, NULL, &uio, NULL, NULL, &flags); 1756 if (rc == EAGAIN) |
1701 return; 1702 else if (rc) { 1703abort: 1704 STOP_EP_TIMER(ep); 1705 abort_connection(ep); 1706 return; 1707 } | 1757 return 0; 1758 else if (rc) 1759 goto err_stop_timer; 1760 |
1708 KASSERT(uio.uio_offset > 0, ("%s: sorecieve on so %p read no data", 1709 __func__, ep->com.so)); 1710 ep->mpa_pkt_len += uio.uio_offset; 1711 1712 /* 1713 * If we get more than the supported amount of private data then we must 1714 * fail this connection. XXX: check so_rcv->sb_cc, or peek with another 1715 * soreceive, or increase the size of mpa_pkt by 1 and abort if the last 1716 * byte is filled by the soreceive above. 1717 */ 1718 1719 /* Don't even have the MPA message. Wait for more data to arrive. */ 1720 if (ep->mpa_pkt_len < sizeof(*mpa)) | 1761 KASSERT(uio.uio_offset > 0, ("%s: sorecieve on so %p read no data", 1762 __func__, ep->com.so)); 1763 ep->mpa_pkt_len += uio.uio_offset; 1764 1765 /* 1766 * If we get more than the supported amount of private data then we must 1767 * fail this connection. XXX: check so_rcv->sb_cc, or peek with another 1768 * soreceive, or increase the size of mpa_pkt by 1 and abort if the last 1769 * byte is filled by the soreceive above. 1770 */ 1771 1772 /* Don't even have the MPA message. Wait for more data to arrive. */ 1773 if (ep->mpa_pkt_len < sizeof(*mpa)) |
1721 return; | 1774 return 0; |
1722 mpa = (struct mpa_message *) ep->mpa_pkt; 1723 1724 /* 1725 * Validate MPA Header. 1726 */ 1727 if (mpa->revision > mpa_rev) { 1728 log(LOG_ERR, "%s: MPA version mismatch. Local = %d," 1729 " Received = %d\n", __func__, mpa_rev, mpa->revision); | 1775 mpa = (struct mpa_message *) ep->mpa_pkt; 1776 1777 /* 1778 * Validate MPA Header. 1779 */ 1780 if (mpa->revision > mpa_rev) { 1781 log(LOG_ERR, "%s: MPA version mismatch. Local = %d," 1782 " Received = %d\n", __func__, mpa_rev, mpa->revision); |
1730 goto abort; | 1783 goto err_stop_timer; |
1731 } 1732 1733 if (memcmp(mpa->key, MPA_KEY_REQ, sizeof(mpa->key))) | 1784 } 1785 1786 if (memcmp(mpa->key, MPA_KEY_REQ, sizeof(mpa->key))) |
1734 goto abort; | 1787 goto err_stop_timer; |
1735 1736 /* 1737 * Fail if there's too much private data. 1738 */ 1739 plen = ntohs(mpa->private_data_size); 1740 if (plen > MPA_MAX_PRIVATE_DATA) | 1788 1789 /* 1790 * Fail if there's too much private data. 1791 */ 1792 plen = ntohs(mpa->private_data_size); 1793 if (plen > MPA_MAX_PRIVATE_DATA) |
1741 goto abort; | 1794 goto err_stop_timer; |
1742 1743 /* 1744 * If plen does not account for pkt size 1745 */ 1746 if (ep->mpa_pkt_len > (sizeof(*mpa) + plen)) | 1795 1796 /* 1797 * If plen does not account for pkt size 1798 */ 1799 if (ep->mpa_pkt_len > (sizeof(*mpa) + plen)) |
1747 goto abort; | 1800 goto err_stop_timer; |
1748 1749 ep->plen = (u8) plen; 1750 1751 /* 1752 * If we don't have all the pdata yet, then bail. 1753 */ 1754 if (ep->mpa_pkt_len < (sizeof(*mpa) + plen)) | 1801 1802 ep->plen = (u8) plen; 1803 1804 /* 1805 * If we don't have all the pdata yet, then bail. 1806 */ 1807 if (ep->mpa_pkt_len < (sizeof(*mpa) + plen)) |
1755 return; | 1808 return 0; |
1756 1757 /* 1758 * If we get here we have accumulated the entire mpa 1759 * start reply message including private data. 1760 */ 1761 ep->mpa_attr.initiator = 0; 1762 ep->mpa_attr.crc_enabled = (mpa->flags & MPA_CRC) | crc_enabled ? 1 : 0; 1763 ep->mpa_attr.recv_marker_enabled = markers_enabled; --- 25 unchanged lines hidden (view full) --- 1789 FW_RI_INIT_P2PTYPE_READ_REQ; 1790 } 1791 } 1792 } 1793 } else if (mpa->revision == 1 && peer2peer) 1794 ep->mpa_attr.p2p_type = p2p_type; 1795 1796 if (set_tcpinfo(ep)) | 1809 1810 /* 1811 * If we get here we have accumulated the entire mpa 1812 * start reply message including private data. 1813 */ 1814 ep->mpa_attr.initiator = 0; 1815 ep->mpa_attr.crc_enabled = (mpa->flags & MPA_CRC) | crc_enabled ? 1 : 0; 1816 ep->mpa_attr.recv_marker_enabled = markers_enabled; --- 25 unchanged lines hidden (view full) --- 1842 FW_RI_INIT_P2PTYPE_READ_REQ; 1843 } 1844 } 1845 } 1846 } else if (mpa->revision == 1 && peer2peer) 1847 ep->mpa_attr.p2p_type = p2p_type; 1848 1849 if (set_tcpinfo(ep)) |
1797 goto abort; | 1850 goto err_stop_timer; |
1798 1799 CTR5(KTR_IW_CXGBE, "%s: crc_enabled = %d, recv_marker_enabled = %d, " 1800 "xmit_marker_enabled = %d, version = %d", __func__, 1801 ep->mpa_attr.crc_enabled, ep->mpa_attr.recv_marker_enabled, 1802 ep->mpa_attr.xmit_marker_enabled, ep->mpa_attr.version); 1803 1804 state_set(&ep->com, MPA_REQ_RCVD); | 1851 1852 CTR5(KTR_IW_CXGBE, "%s: crc_enabled = %d, recv_marker_enabled = %d, " 1853 "xmit_marker_enabled = %d, version = %d", __func__, 1854 ep->mpa_attr.crc_enabled, ep->mpa_attr.recv_marker_enabled, 1855 ep->mpa_attr.xmit_marker_enabled, ep->mpa_attr.version); 1856 1857 state_set(&ep->com, MPA_REQ_RCVD); |
1805 STOP_EP_TIMER(ep); | |
1806 1807 /* drive upcall */ 1808 mutex_lock(&ep->parent_ep->com.mutex); 1809 if (ep->parent_ep->com.state != DEAD) { | 1858 1859 /* drive upcall */ 1860 mutex_lock(&ep->parent_ep->com.mutex); 1861 if (ep->parent_ep->com.state != DEAD) { |
1810 if(connect_request_upcall(ep)) { 1811 abort_connection(ep); 1812 } 1813 }else 1814 abort_connection(ep); | 1862 if(connect_request_upcall(ep)) 1863 goto err_out; 1864 }else { 1865 goto err_out; 1866 } |
1815 mutex_unlock(&ep->parent_ep->com.mutex); | 1867 mutex_unlock(&ep->parent_ep->com.mutex); |
1868 return 0; 1869 1870err_stop_timer: 1871 STOP_EP_TIMER(ep); 1872err_out: 1873 return 2; |
|
1816} 1817 1818/* 1819 * Upcall from the adapter indicating data has been transmitted. 1820 * For us its just the single MPA request or reply. We can now free 1821 * the skb holding the mpa message. 1822 */ 1823int c4iw_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len) 1824{ 1825 int err; 1826 struct c4iw_ep *ep = to_ep(cm_id); 1827 CTR2(KTR_IW_CXGBE, "%s:crcB %p", __func__, ep); | 1874} 1875 1876/* 1877 * Upcall from the adapter indicating data has been transmitted. 1878 * For us its just the single MPA request or reply. We can now free 1879 * the skb holding the mpa message. 1880 */ 1881int c4iw_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len) 1882{ 1883 int err; 1884 struct c4iw_ep *ep = to_ep(cm_id); 1885 CTR2(KTR_IW_CXGBE, "%s:crcB %p", __func__, ep); |
1886 int disconnect = 0; |
|
1828 1829 if (state_read(&ep->com) == DEAD) { 1830 1831 CTR2(KTR_IW_CXGBE, "%s:crc1 %p", __func__, ep); 1832 c4iw_put_ep(&ep->com); 1833 return -ECONNRESET; 1834 } 1835 set_bit(ULP_REJECT, &ep->com.history); 1836 BUG_ON(state_read(&ep->com) != MPA_REQ_RCVD); 1837 1838 if (mpa_rev == 0) { 1839 1840 CTR2(KTR_IW_CXGBE, "%s:crc2 %p", __func__, ep); | 1887 1888 if (state_read(&ep->com) == DEAD) { 1889 1890 CTR2(KTR_IW_CXGBE, "%s:crc1 %p", __func__, ep); 1891 c4iw_put_ep(&ep->com); 1892 return -ECONNRESET; 1893 } 1894 set_bit(ULP_REJECT, &ep->com.history); 1895 BUG_ON(state_read(&ep->com) != MPA_REQ_RCVD); 1896 1897 if (mpa_rev == 0) { 1898 1899 CTR2(KTR_IW_CXGBE, "%s:crc2 %p", __func__, ep); |
1841 abort_connection(ep); | 1900 disconnect = 2; |
1842 } 1843 else { 1844 1845 CTR2(KTR_IW_CXGBE, "%s:crc3 %p", __func__, ep); 1846 err = send_mpa_reject(ep, pdata, pdata_len); 1847 err = soshutdown(ep->com.so, 3); 1848 } 1849 c4iw_put_ep(&ep->com); | 1901 } 1902 else { 1903 1904 CTR2(KTR_IW_CXGBE, "%s:crc3 %p", __func__, ep); 1905 err = send_mpa_reject(ep, pdata, pdata_len); 1906 err = soshutdown(ep->com.so, 3); 1907 } 1908 c4iw_put_ep(&ep->com); |
1909 if (disconnect) 1910 err = c4iw_ep_disconnect(ep, disconnect == 2, GFP_KERNEL); |
|
1850 CTR2(KTR_IW_CXGBE, "%s:crc4 %p", __func__, ep); 1851 return 0; 1852} 1853 1854int c4iw_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) 1855{ 1856 int err; 1857 struct c4iw_qp_attributes attrs; 1858 enum c4iw_qp_attr_mask mask; 1859 struct c4iw_ep *ep = to_ep(cm_id); 1860 struct c4iw_dev *h = to_c4iw_dev(cm_id->device); 1861 struct c4iw_qp *qp = get_qhp(h, conn_param->qpn); | 1911 CTR2(KTR_IW_CXGBE, "%s:crc4 %p", __func__, ep); 1912 return 0; 1913} 1914 1915int c4iw_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) 1916{ 1917 int err; 1918 struct c4iw_qp_attributes attrs; 1919 enum c4iw_qp_attr_mask mask; 1920 struct c4iw_ep *ep = to_ep(cm_id); 1921 struct c4iw_dev *h = to_c4iw_dev(cm_id->device); 1922 struct c4iw_qp *qp = get_qhp(h, conn_param->qpn); |
1923 int abort = 0; |
|
1862 1863 CTR2(KTR_IW_CXGBE, "%s:cacB %p", __func__, ep); 1864 1865 if (state_read(&ep->com) == DEAD) { 1866 1867 CTR2(KTR_IW_CXGBE, "%s:cac1 %p", __func__, ep); 1868 err = -ECONNRESET; | 1924 1925 CTR2(KTR_IW_CXGBE, "%s:cacB %p", __func__, ep); 1926 1927 if (state_read(&ep->com) == DEAD) { 1928 1929 CTR2(KTR_IW_CXGBE, "%s:cac1 %p", __func__, ep); 1930 err = -ECONNRESET; |
1869 goto err; | 1931 goto err_out; |
1870 } 1871 1872 BUG_ON(state_read(&ep->com) != MPA_REQ_RCVD); 1873 BUG_ON(!qp); 1874 1875 set_bit(ULP_ACCEPT, &ep->com.history); 1876 1877 if ((conn_param->ord > c4iw_max_read_depth) || 1878 (conn_param->ird > c4iw_max_read_depth)) { 1879 1880 CTR2(KTR_IW_CXGBE, "%s:cac2 %p", __func__, ep); | 1932 } 1933 1934 BUG_ON(state_read(&ep->com) != MPA_REQ_RCVD); 1935 BUG_ON(!qp); 1936 1937 set_bit(ULP_ACCEPT, &ep->com.history); 1938 1939 if ((conn_param->ord > c4iw_max_read_depth) || 1940 (conn_param->ird > c4iw_max_read_depth)) { 1941 1942 CTR2(KTR_IW_CXGBE, "%s:cac2 %p", __func__, ep); |
1881 abort_connection(ep); | |
1882 err = -EINVAL; | 1943 err = -EINVAL; |
1883 goto err; | 1944 goto err_abort; |
1884 } 1885 1886 if (ep->mpa_attr.version == 2 && ep->mpa_attr.enhanced_rdma_conn) { 1887 1888 CTR2(KTR_IW_CXGBE, "%s:cac3 %p", __func__, ep); 1889 1890 if (conn_param->ord > ep->ird) { 1891 1892 CTR2(KTR_IW_CXGBE, "%s:cac4 %p", __func__, ep); 1893 ep->ird = conn_param->ird; 1894 ep->ord = conn_param->ord; 1895 send_mpa_reject(ep, conn_param->private_data, 1896 conn_param->private_data_len); | 1945 } 1946 1947 if (ep->mpa_attr.version == 2 && ep->mpa_attr.enhanced_rdma_conn) { 1948 1949 CTR2(KTR_IW_CXGBE, "%s:cac3 %p", __func__, ep); 1950 1951 if (conn_param->ord > ep->ird) { 1952 1953 CTR2(KTR_IW_CXGBE, "%s:cac4 %p", __func__, ep); 1954 ep->ird = conn_param->ird; 1955 ep->ord = conn_param->ord; 1956 send_mpa_reject(ep, conn_param->private_data, 1957 conn_param->private_data_len); |
1897 abort_connection(ep); | |
1898 err = -ENOMEM; | 1958 err = -ENOMEM; |
1899 goto err; | 1959 goto err_abort; |
1900 } 1901 1902 if (conn_param->ird > ep->ord) { 1903 1904 CTR2(KTR_IW_CXGBE, "%s:cac5 %p", __func__, ep); 1905 1906 if (!ep->ord) { 1907 1908 CTR2(KTR_IW_CXGBE, "%s:cac6 %p", __func__, ep); 1909 conn_param->ird = 1; 1910 } 1911 else { 1912 CTR2(KTR_IW_CXGBE, "%s:cac7 %p", __func__, ep); | 1960 } 1961 1962 if (conn_param->ird > ep->ord) { 1963 1964 CTR2(KTR_IW_CXGBE, "%s:cac5 %p", __func__, ep); 1965 1966 if (!ep->ord) { 1967 1968 CTR2(KTR_IW_CXGBE, "%s:cac6 %p", __func__, ep); 1969 conn_param->ird = 1; 1970 } 1971 else { 1972 CTR2(KTR_IW_CXGBE, "%s:cac7 %p", __func__, ep); |
1913 abort_connection(ep); | |
1914 err = -ENOMEM; | 1973 err = -ENOMEM; |
1915 goto err; | 1974 goto err_abort; |
1916 } 1917 } 1918 1919 } 1920 ep->ird = conn_param->ird; 1921 ep->ord = conn_param->ord; 1922 1923 if (ep->mpa_attr.version != 2) { 1924 1925 CTR2(KTR_IW_CXGBE, "%s:cac8 %p", __func__, ep); 1926 1927 if (peer2peer && ep->ird == 0) { 1928 1929 CTR2(KTR_IW_CXGBE, "%s:cac9 %p", __func__, ep); 1930 ep->ird = 1; 1931 } 1932 } 1933 1934 | 1975 } 1976 } 1977 1978 } 1979 ep->ird = conn_param->ird; 1980 ep->ord = conn_param->ord; 1981 1982 if (ep->mpa_attr.version != 2) { 1983 1984 CTR2(KTR_IW_CXGBE, "%s:cac8 %p", __func__, ep); 1985 1986 if (peer2peer && ep->ird == 0) { 1987 1988 CTR2(KTR_IW_CXGBE, "%s:cac9 %p", __func__, ep); 1989 ep->ird = 1; 1990 } 1991 } 1992 1993 |
1935 cm_id->add_ref(cm_id); | |
1936 ep->com.cm_id = cm_id; | 1994 ep->com.cm_id = cm_id; |
1995 ref_cm_id(&ep->com); |
|
1937 ep->com.qp = qp; | 1996 ep->com.qp = qp; |
1997 ref_qp(ep); |
|
1938 //ep->ofld_txq = TOEPCB(ep->com.so)->ofld_txq; 1939 1940 /* bind QP to EP and move to RTS */ 1941 attrs.mpa_attr = ep->mpa_attr; 1942 attrs.max_ird = ep->ird; 1943 attrs.max_ord = ep->ord; 1944 attrs.llp_stream_handle = ep; 1945 attrs.next_state = C4IW_QP_STATE_RTS; --- 5 unchanged lines hidden (view full) --- 1951 C4IW_QP_ATTR_MAX_IRD | 1952 C4IW_QP_ATTR_MAX_ORD; 1953 1954 err = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp, mask, &attrs, 1); 1955 1956 if (err) { 1957 1958 CTR2(KTR_IW_CXGBE, "%s:caca %p", __func__, ep); | 1998 //ep->ofld_txq = TOEPCB(ep->com.so)->ofld_txq; 1999 2000 /* bind QP to EP and move to RTS */ 2001 attrs.mpa_attr = ep->mpa_attr; 2002 attrs.max_ird = ep->ird; 2003 attrs.max_ord = ep->ord; 2004 attrs.llp_stream_handle = ep; 2005 attrs.next_state = C4IW_QP_STATE_RTS; --- 5 unchanged lines hidden (view full) --- 2011 C4IW_QP_ATTR_MAX_IRD | 2012 C4IW_QP_ATTR_MAX_ORD; 2013 2014 err = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp, mask, &attrs, 1); 2015 2016 if (err) { 2017 2018 CTR2(KTR_IW_CXGBE, "%s:caca %p", __func__, ep); |
1959 goto err1; | 2019 goto err_defef_cm_id; |
1960 } 1961 err = send_mpa_reply(ep, conn_param->private_data, 1962 conn_param->private_data_len); 1963 1964 if (err) { 1965 1966 CTR2(KTR_IW_CXGBE, "%s:caca %p", __func__, ep); | 2020 } 2021 err = send_mpa_reply(ep, conn_param->private_data, 2022 conn_param->private_data_len); 2023 2024 if (err) { 2025 2026 CTR2(KTR_IW_CXGBE, "%s:caca %p", __func__, ep); |
1967 goto err1; | 2027 goto err_defef_cm_id; |
1968 } 1969 1970 state_set(&ep->com, FPDU_MODE); 1971 established_upcall(ep); 1972 c4iw_put_ep(&ep->com); 1973 CTR2(KTR_IW_CXGBE, "%s:cacE %p", __func__, ep); 1974 return 0; | 2028 } 2029 2030 state_set(&ep->com, FPDU_MODE); 2031 established_upcall(ep); 2032 c4iw_put_ep(&ep->com); 2033 CTR2(KTR_IW_CXGBE, "%s:cacE %p", __func__, ep); 2034 return 0; |
1975err1: 1976 ep->com.cm_id = NULL; 1977 ep->com.qp = NULL; 1978 cm_id->rem_ref(cm_id); 1979err: | 2035err_defef_cm_id: 2036 deref_cm_id(&ep->com); 2037err_abort: 2038 abort = 1; 2039err_out: 2040 if (abort) 2041 c4iw_ep_disconnect(ep, 1, GFP_KERNEL); |
1980 c4iw_put_ep(&ep->com); 1981 CTR2(KTR_IW_CXGBE, "%s:cacE err %p", __func__, ep); 1982 return err; 1983} 1984 1985 1986 1987int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) --- 35 unchanged lines hidden (view full) --- 2023 ep->ord = conn_param->ord; 2024 2025 if (peer2peer && ep->ord == 0) { 2026 2027 CTR2(KTR_IW_CXGBE, "%s:cc4 %p", __func__, ep); 2028 ep->ord = 1; 2029 } 2030 | 2042 c4iw_put_ep(&ep->com); 2043 CTR2(KTR_IW_CXGBE, "%s:cacE err %p", __func__, ep); 2044 return err; 2045} 2046 2047 2048 2049int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) --- 35 unchanged lines hidden (view full) --- 2085 ep->ord = conn_param->ord; 2086 2087 if (peer2peer && ep->ord == 0) { 2088 2089 CTR2(KTR_IW_CXGBE, "%s:cc4 %p", __func__, ep); 2090 ep->ord = 1; 2091 } 2092 |
2031 cm_id->add_ref(cm_id); | |
2032 ep->com.dev = dev; 2033 ep->com.cm_id = cm_id; | 2093 ep->com.dev = dev; 2094 ep->com.cm_id = cm_id; |
2095 ref_cm_id(&ep->com); |
|
2034 ep->com.qp = get_qhp(dev, conn_param->qpn); 2035 2036 if (!ep->com.qp) { 2037 2038 CTR2(KTR_IW_CXGBE, "%s:cc5 %p", __func__, ep); 2039 err = -EINVAL; 2040 goto fail2; 2041 } | 2096 ep->com.qp = get_qhp(dev, conn_param->qpn); 2097 2098 if (!ep->com.qp) { 2099 2100 CTR2(KTR_IW_CXGBE, "%s:cc5 %p", __func__, ep); 2101 err = -EINVAL; 2102 goto fail2; 2103 } |
2104 ref_qp(ep); |
|
2042 ep->com.thread = curthread; 2043 ep->com.so = cm_id->so; 2044 2045 init_sock(&ep->com); 2046 2047 /* find a route */ 2048 err = find_route( 2049 cm_id->local_addr.sin_addr.s_addr, --- 41 unchanged lines hidden (view full) --- 2091 close_socket(&ep->com, 0); 2092 goto fail2; 2093 } 2094 2095fail3: 2096 CTR2(KTR_IW_CXGBE, "%s:ccb %p", __func__, ep); 2097 fib4_free_nh_ext(RT_DEFAULT_FIB, &nh4); 2098fail2: | 2105 ep->com.thread = curthread; 2106 ep->com.so = cm_id->so; 2107 2108 init_sock(&ep->com); 2109 2110 /* find a route */ 2111 err = find_route( 2112 cm_id->local_addr.sin_addr.s_addr, --- 41 unchanged lines hidden (view full) --- 2154 close_socket(&ep->com, 0); 2155 goto fail2; 2156 } 2157 2158fail3: 2159 CTR2(KTR_IW_CXGBE, "%s:ccb %p", __func__, ep); 2160 fib4_free_nh_ext(RT_DEFAULT_FIB, &nh4); 2161fail2: |
2099 cm_id->rem_ref(cm_id); | 2162 deref_cm_id(&ep->com); |
2100 c4iw_put_ep(&ep->com); 2101out: 2102 CTR2(KTR_IW_CXGBE, "%s:ccE %p", __func__, ep); 2103 return err; 2104} 2105 2106/* 2107 * iwcm->create_listen_ep. Returns -errno on failure. --- 11 unchanged lines hidden (view full) --- 2119 cm_id, so, ep, so->so_pcb); 2120 if (ep == NULL) { 2121 log(LOG_ERR, "%s: failed to alloc memory for endpoint\n", 2122 __func__); 2123 rc = ENOMEM; 2124 goto failed; 2125 } 2126 | 2163 c4iw_put_ep(&ep->com); 2164out: 2165 CTR2(KTR_IW_CXGBE, "%s:ccE %p", __func__, ep); 2166 return err; 2167} 2168 2169/* 2170 * iwcm->create_listen_ep. Returns -errno on failure. --- 11 unchanged lines hidden (view full) --- 2182 cm_id, so, ep, so->so_pcb); 2183 if (ep == NULL) { 2184 log(LOG_ERR, "%s: failed to alloc memory for endpoint\n", 2185 __func__); 2186 rc = ENOMEM; 2187 goto failed; 2188 } 2189 |
2127 cm_id->add_ref(cm_id); | |
2128 ep->com.cm_id = cm_id; | 2190 ep->com.cm_id = cm_id; |
2191 ref_cm_id(&ep->com); |
|
2129 ep->com.dev = dev; 2130 ep->backlog = backlog; 2131 ep->com.local_addr = cm_id->local_addr; 2132 ep->com.thread = curthread; 2133 state_set(&ep->com, LISTEN); 2134 ep->com.so = so; 2135 2136 cm_id->provider_data = ep; --- 8 unchanged lines hidden (view full) --- 2145c4iw_destroy_listen_ep(struct iw_cm_id *cm_id) 2146{ 2147 struct c4iw_listen_ep *ep = to_listen_ep(cm_id); 2148 2149 CTR4(KTR_IW_CXGBE, "%s: cm_id %p, so %p, state %s", __func__, cm_id, 2150 cm_id->so, states[ep->com.state]); 2151 2152 state_set(&ep->com, DEAD); | 2192 ep->com.dev = dev; 2193 ep->backlog = backlog; 2194 ep->com.local_addr = cm_id->local_addr; 2195 ep->com.thread = curthread; 2196 state_set(&ep->com, LISTEN); 2197 ep->com.so = so; 2198 2199 cm_id->provider_data = ep; --- 8 unchanged lines hidden (view full) --- 2208c4iw_destroy_listen_ep(struct iw_cm_id *cm_id) 2209{ 2210 struct c4iw_listen_ep *ep = to_listen_ep(cm_id); 2211 2212 CTR4(KTR_IW_CXGBE, "%s: cm_id %p, so %p, state %s", __func__, cm_id, 2213 cm_id->so, states[ep->com.state]); 2214 2215 state_set(&ep->com, DEAD); |
2153 cm_id->rem_ref(cm_id); | 2216 deref_cm_id(&ep->com); |
2154 c4iw_put_ep(&ep->com); 2155 2156 return; 2157} 2158 2159int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp) 2160{ 2161 int ret = 0; --- 65 unchanged lines hidden (view full) --- 2227 if (close) { 2228 2229 CTR2(KTR_IW_CXGBE, "%s:ced3 %p", __func__, ep); 2230 2231 if (abrupt) { 2232 2233 CTR2(KTR_IW_CXGBE, "%s:ced4 %p", __func__, ep); 2234 set_bit(EP_DISC_ABORT, &ep->com.history); | 2217 c4iw_put_ep(&ep->com); 2218 2219 return; 2220} 2221 2222int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp) 2223{ 2224 int ret = 0; --- 65 unchanged lines hidden (view full) --- 2290 if (close) { 2291 2292 CTR2(KTR_IW_CXGBE, "%s:ced3 %p", __func__, ep); 2293 2294 if (abrupt) { 2295 2296 CTR2(KTR_IW_CXGBE, "%s:ced4 %p", __func__, ep); 2297 set_bit(EP_DISC_ABORT, &ep->com.history); |
2235 ret = abort_connection(ep); | 2298 close_complete_upcall(ep, -ECONNRESET); 2299 ret = send_abort(ep); |
2236 } else { 2237 2238 CTR2(KTR_IW_CXGBE, "%s:ced5 %p", __func__, ep); 2239 set_bit(EP_DISC_CLOSE, &ep->com.history); 2240 2241 if (!ep->parent_ep) 2242 __state_set(&ep->com, MORIBUND); 2243 ret = shutdown_socket(&ep->com); 2244 } 2245 2246 if (ret) { 2247 2248 fatal = 1; 2249 } 2250 } 2251 2252 if (fatal) { | 2300 } else { 2301 2302 CTR2(KTR_IW_CXGBE, "%s:ced5 %p", __func__, ep); 2303 set_bit(EP_DISC_CLOSE, &ep->com.history); 2304 2305 if (!ep->parent_ep) 2306 __state_set(&ep->com, MORIBUND); 2307 ret = shutdown_socket(&ep->com); 2308 } 2309 2310 if (ret) { 2311 2312 fatal = 1; 2313 } 2314 } 2315 2316 if (fatal) { |
2317 set_bit(EP_DISC_FAIL, &ep->com.history); 2318 if (!abrupt) { 2319 STOP_EP_TIMER(ep); 2320 close_complete_upcall(ep, -EIO); 2321 } 2322 if (ep->com.qp) { 2323 struct c4iw_qp_attributes attrs; |
|
2253 | 2324 |
2325 attrs.next_state = C4IW_QP_STATE_ERROR; 2326 ret = c4iw_modify_qp(ep->com.dev, ep->com.qp, 2327 C4IW_QP_ATTR_NEXT_STATE, 2328 &attrs, 1); 2329 if (ret) { 2330 CTR2(KTR_IW_CXGBE, "%s:ced7 %p", __func__, ep); 2331 printf("%s - qp <- error failed!\n", __func__); 2332 } 2333 } |
|
2254 release_ep_resources(ep); | 2334 release_ep_resources(ep); |
2335 ep->com.state = DEAD; |
|
2255 CTR2(KTR_IW_CXGBE, "%s:ced6 %p", __func__, ep); 2256 } 2257 CTR2(KTR_IW_CXGBE, "%s:cedE %p", __func__, ep); 2258 return ret; 2259} 2260 2261#ifdef C4IW_EP_REDIRECT 2262int c4iw_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new, --- 22 unchanged lines hidden (view full) --- 2285 struct c4iw_ep *ep = (struct c4iw_ep *)arg; 2286 int kickit = 0; 2287 2288 CTR2(KTR_IW_CXGBE, "%s:etB %p", __func__, ep); 2289 spin_lock(&timeout_lock); 2290 2291 if (!test_and_set_bit(TIMEOUT, &ep->com.flags)) { 2292 | 2336 CTR2(KTR_IW_CXGBE, "%s:ced6 %p", __func__, ep); 2337 } 2338 CTR2(KTR_IW_CXGBE, "%s:cedE %p", __func__, ep); 2339 return ret; 2340} 2341 2342#ifdef C4IW_EP_REDIRECT 2343int c4iw_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new, --- 22 unchanged lines hidden (view full) --- 2366 struct c4iw_ep *ep = (struct c4iw_ep *)arg; 2367 int kickit = 0; 2368 2369 CTR2(KTR_IW_CXGBE, "%s:etB %p", __func__, ep); 2370 spin_lock(&timeout_lock); 2371 2372 if (!test_and_set_bit(TIMEOUT, &ep->com.flags)) { 2373 |
2293 list_add_tail(&ep->entry, &timeout_list); 2294 kickit = 1; | 2374 /* 2375 * Only insert if it is not already on the list. 2376 */ 2377 if (!ep->entry.next) { 2378 list_add_tail(&ep->entry, &timeout_list); 2379 kickit = 1; 2380 } |
2295 } 2296 spin_unlock(&timeout_lock); 2297 2298 if (kickit) { 2299 2300 CTR2(KTR_IW_CXGBE, "%s:et1 %p", __func__, ep); 2301 queue_work(c4iw_taskq, &c4iw_task); 2302 } --- 104 unchanged lines hidden --- | 2381 } 2382 spin_unlock(&timeout_lock); 2383 2384 if (kickit) { 2385 2386 CTR2(KTR_IW_CXGBE, "%s:et1 %p", __func__, ep); 2387 queue_work(c4iw_taskq, &c4iw_task); 2388 } --- 104 unchanged lines hidden --- |