Deleted Added
full compact
1/**************************************************************************
2
3Copyright (c) 2007, Chelsio Inc.
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8

--- 13 unchanged lines hidden (view full) ---

22SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26POSSIBILITY OF SUCH DAMAGE.
27
28***************************************************************************/
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c 183292 2008-09-23 03:16:54Z kmacy $");
30__FBSDID("$FreeBSD: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c 193272 2009-06-01 21:17:03Z jhb $");
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/kernel.h>
35#include <sys/bus.h>
36#include <sys/module.h>
37#include <sys/pciio.h>
38#include <sys/conf.h>

--- 97 unchanged lines hidden (view full) ---

136
137static unsigned int cong_flavor = 1;
138TUNABLE_INT("hw.iw_cxgb.cong_flavor", &cong_flavor);
139SYSCTL_UINT(_hw_cxgb, OID_AUTO, cong_flavor, CTLFLAG_RDTUN, &cong_flavor, 0,
140 "TCP Congestion control flavor (default=1)");
141
142static void ep_timeout(void *arg);
143static void connect_reply_upcall(struct iwch_ep *ep, int status);
144static void iwch_so_upcall(struct socket *so, void *arg, int waitflag);
144static int iwch_so_upcall(struct socket *so, void *arg, int waitflag);
145
146/*
147 * Cruft to offload socket upcalls onto thread.
148 */
149static struct mtx req_lock;
150static TAILQ_HEAD(iwch_ep_list, iwch_ep_common) req_list;
151static struct task iw_cxgb_task;
152static struct taskqueue *iw_cxgb_taskq;

--- 177 unchanged lines hidden (view full) ---

330 return iproute.ro_rt;
331}
332
333static void
334close_socket(struct iwch_ep_common *epc)
335{
336 CTR4(KTR_IW_CXGB, "%s ep %p so %p state %s", __FUNCTION__, epc, epc->so, states[epc->state]);
337 SOCK_LOCK(epc->so);
338 epc->so->so_upcall = NULL;
339 epc->so->so_upcallarg = NULL;
340 epc->so->so_rcv.sb_flags &= ~SB_UPCALL;
338 soupcall_clear(epc->so, SO_RCV);
339 SOCK_UNLOCK(epc->so);
340 soshutdown(epc->so, SHUT_WR|SHUT_RD);
341 epc->so = NULL;
342}
343
344static void
345shutdown_socket(struct iwch_ep_common *epc)
346{

--- 754 unchanged lines hidden (view full) ---

1101 *
1102 * terminate() handles case (1)...
1103 */
1104static int
1105terminate(struct t3cdev *tdev, struct mbuf *m, void *ctx)
1106{
1107 struct toepcb *toep = (struct toepcb *)ctx;
1108 struct socket *so = toeptoso(toep);
1111 struct iwch_ep *ep = so->so_upcallarg;
1109 struct iwch_ep *ep = so->so_rcv.sb_upcallarg;
1110
1111 CTR2(KTR_IW_CXGB, "%s ep %p", __FUNCTION__, ep);
1112 m_adj(m, sizeof(struct cpl_rdma_terminate));
1113 CTR2(KTR_IW_CXGB, "%s saving %d bytes of term msg", __FUNCTION__, m->m_len);
1114 m_copydata(m, 0, m->m_len, ep->com.qp->attr.terminate_buffer);
1115 ep->com.qp->attr.terminate_msg_len = m->m_len;
1116 ep->com.qp->attr.is_terminate_local = 0;
1117 return CPL_RET_BUF_DONE;

--- 4 unchanged lines hidden (view full) ---

1122{
1123 struct toepcb *toep = (struct toepcb *)ctx;
1124 struct socket *so = toeptoso(toep);
1125 struct cpl_rdma_ec_status *rep = cplhdr(m);
1126 struct iwch_ep *ep;
1127 struct iwch_qp_attributes attrs;
1128 int release = 0;
1129
1132 ep = so->so_upcallarg;
1130 ep = so->so_rcv.sb_upcallarg;
1131 CTR5(KTR_IW_CXGB, "%s ep %p so %p state %s ec_status %d", __FUNCTION__, ep, ep->com.so, states[ep->com.state], rep->status);
1132 if (!so || !ep) {
1133 panic("bogosity ep %p state %d, so %p state %x\n", ep, ep ? ep->com.state : -1, so, so ? so->so_state : -1);
1134 }
1135 mtx_lock(&ep->com.lock);
1136 switch (ep->com.state) {
1137 case CLOSING:
1138 if (!rep->status)

--- 163 unchanged lines hidden (view full) ---

1302}
1303
1304static int init_sock(struct iwch_ep_common *epc)
1305{
1306 int err;
1307 struct sockopt sopt;
1308 int on=1;
1309
1312 epc->so->so_upcall = iwch_so_upcall;
1313 epc->so->so_upcallarg = epc;
1314 epc->so->so_rcv.sb_flags |= SB_UPCALL;
1310 SOCK_LOCK(epc->so);
1311 soupcall_set(epc->so, SO_RCV, iwch_so_upcall, epc);
1312 epc->so->so_state |= SS_NBIO;
1313 SOCK_UNLOCK(epc->so);
1314 sopt.sopt_dir = SOPT_SET;
1315 sopt.sopt_level = SOL_SOCKET;
1316 sopt.sopt_name = SO_NO_DDP;
1317 sopt.sopt_val = (caddr_t)&on;
1318 sopt.sopt_valsize = sizeof on;
1319 sopt.sopt_td = NULL;
1320 err = sosetopt(epc->so, &sopt);
1321 if (err)

--- 282 unchanged lines hidden (view full) ---

1604 return NULL;
1605 }
1606 TAILQ_REMOVE(&head->so_comp, so, so_list);
1607 head->so_qlen--;
1608 SOCK_LOCK(so);
1609 so->so_qstate &= ~SQ_COMP;
1610 so->so_head = NULL;
1611 soref(so);
1614 so->so_rcv.sb_flags |= SB_UPCALL;
1612 soupcall_set(so, SO_RCV, iwch_so_upcall, child_ep);
1613 so->so_state |= SS_NBIO;
1616 so->so_upcall = iwch_so_upcall;
1617 so->so_upcallarg = child_ep;
1614 PANIC_IF(!(so->so_state & SS_ISCONNECTED));
1615 PANIC_IF(so->so_error);
1616 SOCK_UNLOCK(so);
1617 ACCEPT_UNLOCK();
1618 soaccept(so, (struct sockaddr **)remote);
1619 return so;
1620}
1621

--- 30 unchanged lines hidden (view full) ---

1652 callout_init(&child_ep->timer, TRUE);
1653 state_set(&child_ep->com, MPA_REQ_WAIT);
1654 start_ep_timer(child_ep);
1655
1656 /* maybe the request has already been queued up on the socket... */
1657 process_mpa_request(child_ep);
1658}
1659
1664static void
1660static int
1661iwch_so_upcall(struct socket *so, void *arg, int waitflag)
1662{
1663 struct iwch_ep *ep = arg;
1664
1665 CTR6(KTR_IW_CXGB, "%s so %p so state %x ep %p ep state(%d)=%s", __FUNCTION__, so, so->so_state, ep, ep->com.state, states[ep->com.state]);
1666 mtx_lock(&req_lock);
1667 if (ep && ep->com.so && !ep->com.entry.tqe_prev) {
1668 get_ep(&ep->com);
1669 TAILQ_INSERT_TAIL(&req_list, &ep->com, entry);
1670 taskqueue_enqueue(iw_cxgb_taskq, &iw_cxgb_task);
1671 }
1672 mtx_unlock(&req_lock);
1673 return (SU_OK);
1674}
1675
1676static void
1677process_socket_event(struct iwch_ep *ep)
1678{
1679 int state = state_read(&ep->com);
1680 struct socket *so = ep->com.so;
1681

--- 81 unchanged lines hidden ---