2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2012 Chelsio Communications, Inc.
6 * Written by: Navdeep Parhar <np@FreeBSD.org>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
34 #include "opt_inet6.h"
37 #include <sys/param.h>
38 #include <sys/types.h>
39 #include <sys/kernel.h>
41 #include <sys/module.h>
42 #include <sys/protosw.h>
43 #include <sys/refcount.h>
44 #include <sys/domain.h>
45 #include <sys/fnv_hash.h>
46 #include <sys/socket.h>
47 #include <sys/socketvar.h>
48 #include <sys/sysctl.h>
49 #include <net/ethernet.h>
51 #include <net/if_types.h>
52 #include <net/if_vlan_var.h>
53 #include <net/route.h>
54 #include <netinet/in.h>
55 #include <netinet/in_fib.h>
56 #include <netinet/in_pcb.h>
57 #include <netinet/ip.h>
58 #include <netinet/ip6.h>
59 #include <netinet6/in6_fib.h>
60 #include <netinet6/scope6_var.h>
61 #include <netinet/tcp_timer.h>
63 #include <netinet/tcp_fsm.h>
64 #include <netinet/tcp_var.h>
65 #include <netinet/toecore.h>
66 #include <netinet/cc/cc.h>
68 #include "common/common.h"
69 #include "common/t4_msg.h"
70 #include "common/t4_regs.h"
72 #include "tom/t4_tom_l2t.h"
73 #include "tom/t4_tom.h"
76 static int alloc_stid(struct adapter *, struct listen_ctx *, int);
77 static struct listen_ctx *lookup_stid(struct adapter *, int);
78 static void free_stid(struct adapter *, struct listen_ctx *);
81 static struct listen_ctx *alloc_lctx(struct adapter *, struct inpcb *,
83 static int free_lctx(struct adapter *, struct listen_ctx *);
84 static void hold_lctx(struct listen_ctx *);
85 static void listen_hash_add(struct adapter *, struct listen_ctx *);
86 static struct listen_ctx *listen_hash_find(struct adapter *, struct inpcb *);
87 static struct listen_ctx *listen_hash_del(struct adapter *, struct inpcb *);
88 static struct inpcb *release_lctx(struct adapter *, struct listen_ctx *);
90 static void send_reset_synqe(struct toedev *, struct synq_entry *);
93 alloc_stid(struct adapter *sc, struct listen_ctx *lctx, int isipv6)
95 struct tid_info *t = &sc->tids;
96 u_int stid, n, f, mask;
97 struct stid_region *sr = &lctx->stid_region;
100 * An IPv6 server needs 2 naturally aligned stids (1 stid = 4 cells) in
101 * the TCAM. The start of the stid region is properly aligned (the chip
102 * requires each region to be 128-cell aligned).
106 KASSERT((t->stid_base & mask) == 0 && (t->nstids & mask) == 0,
107 ("%s: stid region (%u, %u) not properly aligned. n = %u",
108 __func__, t->stid_base, t->nstids, n));
110 mtx_lock(&t->stid_lock);
111 if (n > t->nstids - t->stids_in_use) {
112 mtx_unlock(&t->stid_lock);
116 if (t->nstids_free_head >= n) {
118 * This allocation will definitely succeed because the region
119 * starts at a good alignment and we just checked we have enough
122 f = t->nstids_free_head & mask;
123 t->nstids_free_head -= n + f;
124 stid = t->nstids_free_head;
125 TAILQ_INSERT_HEAD(&t->stids, sr, link);
127 struct stid_region *s;
129 stid = t->nstids_free_head;
130 TAILQ_FOREACH(s, &t->stids, link) {
131 stid += s->used + s->free;
133 if (s->free >= n + f) {
136 TAILQ_INSERT_AFTER(&t->stids, s, sr, link);
141 if (__predict_false(stid != t->nstids)) {
142 panic("%s: stids TAILQ (%p) corrupt."
143 " At %d instead of %d at the end of the queue.",
144 __func__, &t->stids, stid, t->nstids);
147 mtx_unlock(&t->stid_lock);
154 t->stids_in_use += n;
155 t->stid_tab[stid] = lctx;
156 mtx_unlock(&t->stid_lock);
158 KASSERT(((stid + t->stid_base) & mask) == 0,
159 ("%s: EDOOFUS.", __func__));
160 return (stid + t->stid_base);
163 static struct listen_ctx *
164 lookup_stid(struct adapter *sc, int stid)
166 struct tid_info *t = &sc->tids;
168 return (t->stid_tab[stid - t->stid_base]);
172 free_stid(struct adapter *sc, struct listen_ctx *lctx)
174 struct tid_info *t = &sc->tids;
175 struct stid_region *sr = &lctx->stid_region;
176 struct stid_region *s;
178 KASSERT(sr->used > 0, ("%s: nonsense free (%d)", __func__, sr->used));
180 mtx_lock(&t->stid_lock);
181 s = TAILQ_PREV(sr, stid_head, link);
183 s->free += sr->used + sr->free;
185 t->nstids_free_head += sr->used + sr->free;
186 KASSERT(t->stids_in_use >= sr->used,
187 ("%s: stids_in_use (%u) < stids being freed (%u)", __func__,
188 t->stids_in_use, sr->used));
189 t->stids_in_use -= sr->used;
190 TAILQ_REMOVE(&t->stids, sr, link);
191 mtx_unlock(&t->stid_lock);
194 static struct listen_ctx *
195 alloc_lctx(struct adapter *sc, struct inpcb *inp, struct vi_info *vi)
197 struct listen_ctx *lctx;
199 INP_WLOCK_ASSERT(inp);
201 lctx = malloc(sizeof(struct listen_ctx), M_CXGBE, M_NOWAIT | M_ZERO);
205 lctx->stid = alloc_stid(sc, lctx, inp->inp_vflag & INP_IPV6);
206 if (lctx->stid < 0) {
211 if (inp->inp_vflag & INP_IPV6 &&
212 !IN6_ARE_ADDR_EQUAL(&in6addr_any, &inp->in6p_laddr)) {
213 lctx->ce = t4_hold_lip(sc, &inp->in6p_laddr, NULL);
214 if (lctx->ce == NULL) {
220 lctx->ctrlq = &sc->sge.ctrlq[vi->pi->port_id];
221 lctx->ofld_rxq = &sc->sge.ofld_rxq[vi->first_ofld_rxq];
222 refcount_init(&lctx->refcount, 1);
225 lctx->vnet = inp->inp_socket->so_vnet;
231 /* Don't call this directly, use release_lctx instead */
233 free_lctx(struct adapter *sc, struct listen_ctx *lctx)
235 struct inpcb *inp = lctx->inp;
237 INP_WLOCK_ASSERT(inp);
238 KASSERT(lctx->refcount == 0,
239 ("%s: refcount %d", __func__, lctx->refcount));
240 KASSERT(lctx->stid >= 0, ("%s: bad stid %d.", __func__, lctx->stid));
242 CTR4(KTR_CXGBE, "%s: stid %u, lctx %p, inp %p",
243 __func__, lctx->stid, lctx, lctx->inp);
246 t4_release_lip(sc, lctx->ce);
250 return (in_pcbrele_wlocked(inp));
254 hold_lctx(struct listen_ctx *lctx)
257 refcount_acquire(&lctx->refcount);
260 static inline uint32_t
261 listen_hashfn(void *key, u_long mask)
264 return (fnv_32_buf(&key, sizeof(key), FNV1_32_INIT) & mask);
268 * Add a listen_ctx entry to the listen hash table.
271 listen_hash_add(struct adapter *sc, struct listen_ctx *lctx)
273 struct tom_data *td = sc->tom_softc;
274 int bucket = listen_hashfn(lctx->inp, td->listen_mask);
276 mtx_lock(&td->lctx_hash_lock);
277 LIST_INSERT_HEAD(&td->listen_hash[bucket], lctx, link);
279 mtx_unlock(&td->lctx_hash_lock);
283 * Look for the listening socket's context entry in the hash and return it.
285 static struct listen_ctx *
286 listen_hash_find(struct adapter *sc, struct inpcb *inp)
288 struct tom_data *td = sc->tom_softc;
289 int bucket = listen_hashfn(inp, td->listen_mask);
290 struct listen_ctx *lctx;
292 mtx_lock(&td->lctx_hash_lock);
293 LIST_FOREACH(lctx, &td->listen_hash[bucket], link) {
294 if (lctx->inp == inp)
297 mtx_unlock(&td->lctx_hash_lock);
303 * Removes the listen_ctx structure for inp from the hash and returns it.
305 static struct listen_ctx *
306 listen_hash_del(struct adapter *sc, struct inpcb *inp)
308 struct tom_data *td = sc->tom_softc;
309 int bucket = listen_hashfn(inp, td->listen_mask);
310 struct listen_ctx *lctx, *l;
312 mtx_lock(&td->lctx_hash_lock);
313 LIST_FOREACH_SAFE(lctx, &td->listen_hash[bucket], link, l) {
314 if (lctx->inp == inp) {
315 LIST_REMOVE(lctx, link);
320 mtx_unlock(&td->lctx_hash_lock);
326 * Releases a hold on the lctx. Must be called with the listening socket's inp
327 * locked. The inp may be freed by this function and it returns NULL to
330 static struct inpcb *
331 release_lctx(struct adapter *sc, struct listen_ctx *lctx)
333 struct inpcb *inp = lctx->inp;
336 INP_WLOCK_ASSERT(inp);
337 if (refcount_release(&lctx->refcount))
338 inp_freed = free_lctx(sc, lctx);
340 return (inp_freed ? NULL : inp);
344 send_reset_synqe(struct toedev *tod, struct synq_entry *synqe)
346 struct adapter *sc = tod->tod_softc;
347 struct mbuf *m = synqe->syn;
348 struct ifnet *ifp = m->m_pkthdr.rcvif;
349 struct vi_info *vi = ifp->if_softc;
350 struct port_info *pi = vi->pi;
351 struct l2t_entry *e = &sc->l2t->l2tab[synqe->params.l2t_idx];
353 struct fw_flowc_wr *flowc;
354 struct cpl_abort_req *req;
356 struct sge_wrq *ofld_txq;
357 struct sge_ofld_rxq *ofld_rxq;
358 const int nparams = 6;
359 const u_int pfvf = sc->pf << S_FW_VIID_PFN;
361 INP_WLOCK_ASSERT(synqe->lctx->inp);
363 CTR5(KTR_CXGBE, "%s: synqe %p (0x%x), tid %d%s",
364 __func__, synqe, synqe->flags, synqe->tid,
365 synqe->flags & TPF_ABORT_SHUTDOWN ?
366 " (abort already in progress)" : "");
367 if (synqe->flags & TPF_ABORT_SHUTDOWN)
368 return; /* abort already in progress */
369 synqe->flags |= TPF_ABORT_SHUTDOWN;
371 ofld_txq = &sc->sge.ofld_txq[synqe->params.txq_idx];
372 ofld_rxq = &sc->sge.ofld_rxq[synqe->params.rxq_idx];
374 /* The wrqe will have two WRs - a flowc followed by an abort_req */
375 flowclen = sizeof(*flowc) + nparams * sizeof(struct fw_flowc_mnemval);
377 wr = alloc_wrqe(roundup2(flowclen, EQ_ESIZE) + sizeof(*req), ofld_txq);
380 panic("%s: allocation failure.", __func__);
383 req = (void *)((caddr_t)flowc + roundup2(flowclen, EQ_ESIZE));
385 /* First the flowc ... */
386 memset(flowc, 0, wr->wr_len);
387 flowc->op_to_nparams = htobe32(V_FW_WR_OP(FW_FLOWC_WR) |
388 V_FW_FLOWC_WR_NPARAMS(nparams));
389 flowc->flowid_len16 = htonl(V_FW_WR_LEN16(howmany(flowclen, 16)) |
390 V_FW_WR_FLOWID(synqe->tid));
391 flowc->mnemval[0].mnemonic = FW_FLOWC_MNEM_PFNVFN;
392 flowc->mnemval[0].val = htobe32(pfvf);
393 flowc->mnemval[1].mnemonic = FW_FLOWC_MNEM_CH;
394 flowc->mnemval[1].val = htobe32(pi->tx_chan);
395 flowc->mnemval[2].mnemonic = FW_FLOWC_MNEM_PORT;
396 flowc->mnemval[2].val = htobe32(pi->tx_chan);
397 flowc->mnemval[3].mnemonic = FW_FLOWC_MNEM_IQID;
398 flowc->mnemval[3].val = htobe32(ofld_rxq->iq.abs_id);
399 flowc->mnemval[4].mnemonic = FW_FLOWC_MNEM_SNDBUF;
400 flowc->mnemval[4].val = htobe32(512);
401 flowc->mnemval[5].mnemonic = FW_FLOWC_MNEM_MSS;
402 flowc->mnemval[5].val = htobe32(512);
403 synqe->flags |= TPF_FLOWC_WR_SENT;
405 /* ... then ABORT request */
406 INIT_TP_WR_MIT_CPL(req, CPL_ABORT_REQ, synqe->tid);
407 req->rsvd0 = 0; /* don't have a snd_nxt */
408 req->rsvd1 = 1; /* no data sent yet */
409 req->cmd = CPL_ABORT_SEND_RST;
411 t4_l2t_send(sc, wr, e);
415 create_server(struct adapter *sc, struct listen_ctx *lctx)
418 struct cpl_pass_open_req *req;
419 struct inpcb *inp = lctx->inp;
421 wr = alloc_wrqe(sizeof(*req), lctx->ctrlq);
423 log(LOG_ERR, "%s: allocation failure", __func__);
429 OPCODE_TID(req) = htobe32(MK_OPCODE_TID(CPL_PASS_OPEN_REQ, lctx->stid));
430 req->local_port = inp->inp_lport;
432 req->local_ip = inp->inp_laddr.s_addr;
434 req->opt0 = htobe64(V_TX_CHAN(lctx->ctrlq->eq.tx_chan));
435 req->opt1 = htobe64(V_CONN_POLICY(CPL_CONN_POLICY_ASK) |
436 F_SYN_RSS_ENABLE | V_SYN_RSS_QUEUE(lctx->ofld_rxq->iq.abs_id));
443 create_server6(struct adapter *sc, struct listen_ctx *lctx)
446 struct cpl_pass_open_req6 *req;
447 struct inpcb *inp = lctx->inp;
449 wr = alloc_wrqe(sizeof(*req), lctx->ctrlq);
451 log(LOG_ERR, "%s: allocation failure", __func__);
457 OPCODE_TID(req) = htobe32(MK_OPCODE_TID(CPL_PASS_OPEN_REQ6, lctx->stid));
458 req->local_port = inp->inp_lport;
460 req->local_ip_hi = *(uint64_t *)&inp->in6p_laddr.s6_addr[0];
461 req->local_ip_lo = *(uint64_t *)&inp->in6p_laddr.s6_addr[8];
464 req->opt0 = htobe64(V_TX_CHAN(lctx->ctrlq->eq.tx_chan));
465 req->opt1 = htobe64(V_CONN_POLICY(CPL_CONN_POLICY_ASK) |
466 F_SYN_RSS_ENABLE | V_SYN_RSS_QUEUE(lctx->ofld_rxq->iq.abs_id));
473 destroy_server(struct adapter *sc, struct listen_ctx *lctx)
476 struct cpl_close_listsvr_req *req;
478 wr = alloc_wrqe(sizeof(*req), lctx->ctrlq);
481 panic("%s: allocation failure.", __func__);
486 OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_CLOSE_LISTSRV_REQ,
488 req->reply_ctrl = htobe16(lctx->ofld_rxq->iq.abs_id);
489 req->rsvd = htobe16(0);
496 * Start a listening server by sending a passive open request to HW.
498 * Can't take adapter lock here and access to sc->flags,
499 * sc->offload_map, if_capenable are all race prone.
502 t4_listen_start(struct toedev *tod, struct tcpcb *tp)
504 struct adapter *sc = tod->tod_softc;
506 struct port_info *pi;
507 struct inpcb *inp = tp->t_inpcb;
508 struct listen_ctx *lctx;
510 struct offload_settings settings;
512 INP_WLOCK_ASSERT(inp);
514 rw_rlock(&sc->policy_lock);
515 settings = *lookup_offload_policy(sc, OPEN_TYPE_LISTEN, NULL,
516 EVL_MAKETAG(0xfff, 0, 0), inp);
517 rw_runlock(&sc->policy_lock);
518 if (!settings.offload)
521 /* Don't start a hardware listener for any loopback address. */
522 if (inp->inp_vflag & INP_IPV6 && IN6_IS_ADDR_LOOPBACK(&inp->in6p_laddr))
524 if (!(inp->inp_vflag & INP_IPV6) &&
525 IN_LOOPBACK(ntohl(inp->inp_laddr.s_addr)))
527 if (sc->flags & KERN_TLS_OK)
532 log(LOG_ERR, "%s: listen request ignored, %s is busy",
533 __func__, device_get_nameunit(sc->dev));
537 KASSERT(uld_active(sc, ULD_TOM),
538 ("%s: TOM not initialized", __func__));
542 * Find an initialized VI with IFCAP_TOE (4 or 6). We'll use the first
543 * such VI's queues to send the passive open and receive the reply to
546 * XXX: need a way to mark a port in use by offload. if_cxgbe should
547 * then reject any attempt to bring down such a port (and maybe reject
548 * attempts to disable IFCAP_TOE on that port too?).
550 for_each_port(sc, i) {
552 for_each_vi(pi, v, vi) {
553 if (vi->flags & VI_INIT_DONE &&
554 vi->ifp->if_capenable & IFCAP_TOE)
558 goto done; /* no port that's UP with IFCAP_TOE enabled */
561 if (listen_hash_find(sc, inp) != NULL)
562 goto done; /* already setup */
564 lctx = alloc_lctx(sc, inp, vi);
567 "%s: listen request ignored, %s couldn't allocate lctx\n",
568 __func__, device_get_nameunit(sc->dev));
571 listen_hash_add(sc, lctx);
573 CTR6(KTR_CXGBE, "%s: stid %u (%s), lctx %p, inp %p vflag 0x%x",
574 __func__, lctx->stid, tcpstates[tp->t_state], lctx, inp,
577 if (inp->inp_vflag & INP_IPV6)
578 rc = create_server6(sc, lctx);
580 rc = create_server(sc, lctx);
582 log(LOG_ERR, "%s: %s failed to create hw listener: %d.\n",
583 __func__, device_get_nameunit(sc->dev), rc);
584 (void) listen_hash_del(sc, inp);
585 inp = release_lctx(sc, lctx);
586 /* can't be freed, host stack has a reference */
587 KASSERT(inp != NULL, ("%s: inp freed", __func__));
590 lctx->flags |= LCTX_RPL_PENDING;
599 t4_listen_stop(struct toedev *tod, struct tcpcb *tp)
601 struct listen_ctx *lctx;
602 struct adapter *sc = tod->tod_softc;
603 struct inpcb *inp = tp->t_inpcb;
605 INP_WLOCK_ASSERT(inp);
607 lctx = listen_hash_del(sc, inp);
609 return (ENOENT); /* no hardware listener for this inp */
611 CTR4(KTR_CXGBE, "%s: stid %u, lctx %p, flags %x", __func__, lctx->stid,
615 * If the reply to the PASS_OPEN is still pending we'll wait for it to
616 * arrive and clean up when it does.
618 if (lctx->flags & LCTX_RPL_PENDING) {
619 return (EINPROGRESS);
622 destroy_server(sc, lctx);
626 static inline struct synq_entry *
627 alloc_synqe(struct adapter *sc __unused, struct listen_ctx *lctx, int flags)
629 struct synq_entry *synqe;
631 INP_WLOCK_ASSERT(lctx->inp);
632 MPASS(flags == M_WAITOK || flags == M_NOWAIT);
634 synqe = malloc(sizeof(*synqe), M_CXGBE, flags);
635 if (__predict_true(synqe != NULL)) {
636 synqe->flags = TPF_SYNQE;
637 refcount_init(&synqe->refcnt, 1);
639 hold_lctx(lctx); /* Every synqe has a ref on its lctx. */
647 hold_synqe(struct synq_entry *synqe)
650 refcount_acquire(&synqe->refcnt);
653 static inline struct inpcb *
654 release_synqe(struct adapter *sc, struct synq_entry *synqe)
658 MPASS(synqe->flags & TPF_SYNQE);
659 MPASS(synqe->lctx != NULL);
661 inp = synqe->lctx->inp;
663 INP_WLOCK_ASSERT(inp);
665 if (refcount_release(&synqe->refcnt)) {
666 inp = release_lctx(sc, synqe->lctx);
668 free(synqe, M_CXGBE);
675 t4_syncache_added(struct toedev *tod __unused, void *arg)
677 struct synq_entry *synqe = arg;
683 t4_syncache_removed(struct toedev *tod, void *arg)
685 struct adapter *sc = tod->tod_softc;
686 struct synq_entry *synqe = arg;
687 struct inpcb *inp = synqe->lctx->inp;
690 * XXX: this is a LOR but harmless when running from the softclock.
693 inp = release_synqe(sc, synqe);
699 t4_syncache_respond(struct toedev *tod, void *arg, struct mbuf *m)
701 struct synq_entry *synqe = arg;
703 if (atomic_fetchadd_int(&synqe->ok_to_respond, 1) == 0) {
705 struct ip *ip = mtod(m, struct ip *);
708 if (ip->ip_v == IPVERSION)
709 th = (void *)(ip + 1);
711 th = (void *)((struct ip6_hdr *)ip + 1);
712 bzero(&to, sizeof(to));
713 tcp_dooptions(&to, (void *)(th + 1),
714 (th->th_off << 2) - sizeof(*th), TO_SYN);
716 /* save these for later */
717 synqe->iss = be32toh(th->th_seq);
718 synqe->irs = be32toh(th->th_ack) - 1;
719 synqe->ts = to.to_tsval;
722 m_freem(m); /* don't need this any more */
727 do_pass_open_rpl(struct sge_iq *iq, const struct rss_header *rss,
730 struct adapter *sc = iq->adapter;
731 const struct cpl_pass_open_rpl *cpl = (const void *)(rss + 1);
732 int stid = GET_TID(cpl);
733 unsigned int status = cpl->status;
734 struct listen_ctx *lctx = lookup_stid(sc, stid);
735 struct inpcb *inp = lctx->inp;
737 unsigned int opcode = G_CPL_OPCODE(be32toh(OPCODE_TID(cpl)));
740 KASSERT(opcode == CPL_PASS_OPEN_RPL,
741 ("%s: unexpected opcode 0x%x", __func__, opcode));
742 KASSERT(m == NULL, ("%s: wasn't expecting payload", __func__));
743 KASSERT(lctx->stid == stid, ("%s: lctx stid mismatch", __func__));
747 CTR4(KTR_CXGBE, "%s: stid %d, status %u, flags 0x%x",
748 __func__, stid, status, lctx->flags);
750 lctx->flags &= ~LCTX_RPL_PENDING;
752 if (status != CPL_ERR_NONE)
753 log(LOG_ERR, "listener (stid %u) failed: %d\n", stid, status);
757 * If the inp has been dropped (listening socket closed) then
758 * listen_stop must have run and taken the inp out of the hash.
760 if (inp->inp_flags & INP_DROPPED) {
761 KASSERT(listen_hash_del(sc, inp) == NULL,
762 ("%s: inp %p still in listen hash", __func__, inp));
766 if (inp->inp_flags & INP_DROPPED && status != CPL_ERR_NONE) {
767 if (release_lctx(sc, lctx) != NULL)
773 * Listening socket stopped listening earlier and now the chip tells us
774 * it has started the hardware listener. Stop it; the lctx will be
775 * released in do_close_server_rpl.
777 if (inp->inp_flags & INP_DROPPED) {
778 destroy_server(sc, lctx);
784 * Failed to start hardware listener. Take inp out of the hash and
785 * release our reference on it. An error message has been logged
788 if (status != CPL_ERR_NONE) {
789 listen_hash_del(sc, inp);
790 if (release_lctx(sc, lctx) != NULL)
795 /* hardware listener open for business */
802 do_close_server_rpl(struct sge_iq *iq, const struct rss_header *rss,
805 struct adapter *sc = iq->adapter;
806 const struct cpl_close_listsvr_rpl *cpl = (const void *)(rss + 1);
807 int stid = GET_TID(cpl);
808 unsigned int status = cpl->status;
809 struct listen_ctx *lctx = lookup_stid(sc, stid);
810 struct inpcb *inp = lctx->inp;
812 unsigned int opcode = G_CPL_OPCODE(be32toh(OPCODE_TID(cpl)));
815 KASSERT(opcode == CPL_CLOSE_LISTSRV_RPL,
816 ("%s: unexpected opcode 0x%x", __func__, opcode));
817 KASSERT(m == NULL, ("%s: wasn't expecting payload", __func__));
818 KASSERT(lctx->stid == stid, ("%s: lctx stid mismatch", __func__));
820 CTR3(KTR_CXGBE, "%s: stid %u, status %u", __func__, stid, status);
822 if (status != CPL_ERR_NONE) {
823 log(LOG_ERR, "%s: failed (%u) to close listener for stid %u\n",
824 __func__, status, stid);
829 inp = release_lctx(sc, lctx);
837 done_with_synqe(struct adapter *sc, struct synq_entry *synqe)
839 struct listen_ctx *lctx = synqe->lctx;
840 struct inpcb *inp = lctx->inp;
841 struct l2t_entry *e = &sc->l2t->l2tab[synqe->params.l2t_idx];
844 INP_WLOCK_ASSERT(inp);
845 ntids = inp->inp_vflag & INP_IPV6 ? 2 : 1;
847 remove_tid(sc, synqe->tid, ntids);
848 release_tid(sc, synqe->tid, lctx->ctrlq);
850 inp = release_synqe(sc, synqe);
856 synack_failure_cleanup(struct adapter *sc, int tid)
858 struct synq_entry *synqe = lookup_tid(sc, tid);
860 INP_WLOCK(synqe->lctx->inp);
861 done_with_synqe(sc, synqe);
865 do_abort_req_synqe(struct sge_iq *iq, const struct rss_header *rss,
868 struct adapter *sc = iq->adapter;
869 const struct cpl_abort_req_rss *cpl = (const void *)(rss + 1);
870 unsigned int tid = GET_TID(cpl);
871 struct synq_entry *synqe = lookup_tid(sc, tid);
872 struct listen_ctx *lctx = synqe->lctx;
873 struct inpcb *inp = lctx->inp;
874 struct sge_wrq *ofld_txq;
876 unsigned int opcode = G_CPL_OPCODE(be32toh(OPCODE_TID(cpl)));
879 KASSERT(opcode == CPL_ABORT_REQ_RSS,
880 ("%s: unexpected opcode 0x%x", __func__, opcode));
881 KASSERT(m == NULL, ("%s: wasn't expecting payload", __func__));
882 KASSERT(synqe->tid == tid, ("%s: toep tid mismatch", __func__));
884 CTR6(KTR_CXGBE, "%s: tid %u, synqe %p (0x%x), lctx %p, status %d",
885 __func__, tid, synqe, synqe->flags, synqe->lctx, cpl->status);
887 if (negative_advice(cpl->status))
888 return (0); /* Ignore negative advice */
892 ofld_txq = &sc->sge.ofld_txq[synqe->params.txq_idx];
895 * If we'd initiated an abort earlier the reply to it is responsible for
896 * cleaning up resources. Otherwise we tear everything down right here
897 * right now. We owe the T4 a CPL_ABORT_RPL no matter what.
899 if (synqe->flags & TPF_ABORT_SHUTDOWN) {
904 done_with_synqe(sc, synqe);
905 /* inp lock released by done_with_synqe */
907 send_abort_rpl(sc, ofld_txq, tid, CPL_ABORT_NO_RST);
912 do_abort_rpl_synqe(struct sge_iq *iq, const struct rss_header *rss,
915 struct adapter *sc = iq->adapter;
916 const struct cpl_abort_rpl_rss *cpl = (const void *)(rss + 1);
917 unsigned int tid = GET_TID(cpl);
918 struct synq_entry *synqe = lookup_tid(sc, tid);
919 struct listen_ctx *lctx = synqe->lctx;
920 struct inpcb *inp = lctx->inp;
922 unsigned int opcode = G_CPL_OPCODE(be32toh(OPCODE_TID(cpl)));
925 KASSERT(opcode == CPL_ABORT_RPL_RSS,
926 ("%s: unexpected opcode 0x%x", __func__, opcode));
927 KASSERT(m == NULL, ("%s: wasn't expecting payload", __func__));
928 KASSERT(synqe->tid == tid, ("%s: toep tid mismatch", __func__));
930 CTR6(KTR_CXGBE, "%s: tid %u, synqe %p (0x%x), lctx %p, status %d",
931 __func__, tid, synqe, synqe->flags, synqe->lctx, cpl->status);
934 KASSERT(synqe->flags & TPF_ABORT_SHUTDOWN,
935 ("%s: wasn't expecting abort reply for synqe %p (0x%x)",
936 __func__, synqe, synqe->flags));
938 done_with_synqe(sc, synqe);
939 /* inp lock released by done_with_synqe */
945 t4_offload_socket(struct toedev *tod, void *arg, struct socket *so)
947 struct adapter *sc = tod->tod_softc;
948 struct synq_entry *synqe = arg;
950 struct inpcb *inp = sotoinpcb(so);
952 struct toepcb *toep = synqe->toep;
954 NET_EPOCH_ASSERT(); /* prevents bad race with accept() */
955 INP_WLOCK_ASSERT(inp);
956 KASSERT(synqe->flags & TPF_SYNQE,
957 ("%s: %p not a synq_entry?", __func__, arg));
958 MPASS(toep->tid == synqe->tid);
960 offload_socket(so, toep);
961 make_established(toep, synqe->iss, synqe->irs, synqe->tcp_opt);
962 toep->flags |= TPF_CPL_PENDING;
963 update_tid(sc, synqe->tid, toep);
964 synqe->flags |= TPF_SYNQE_EXPANDED;
968 t4opt_to_tcpopt(const struct tcp_options *t4opt, struct tcpopt *to)
970 bzero(to, sizeof(*to));
973 to->to_flags |= TOF_MSS;
974 to->to_mss = be16toh(t4opt->mss);
977 if (t4opt->wsf > 0 && t4opt->wsf < 15) {
978 to->to_flags |= TOF_SCALE;
979 to->to_wscale = t4opt->wsf;
983 to->to_flags |= TOF_TS;
986 to->to_flags |= TOF_SACKPERM;
990 pass_accept_req_to_protohdrs(struct adapter *sc, const struct mbuf *m,
991 struct in_conninfo *inc, struct tcphdr *th, uint8_t *iptos)
993 const struct cpl_pass_accept_req *cpl = mtod(m, const void *);
994 const struct ether_header *eh;
995 unsigned int hlen = be32toh(cpl->hdr_len);
997 const struct tcphdr *tcp;
999 eh = (const void *)(cpl + 1);
1000 if (chip_id(sc) >= CHELSIO_T6) {
1001 l3hdr = ((uintptr_t)eh + G_T6_ETH_HDR_LEN(hlen));
1002 tcp = (const void *)(l3hdr + G_T6_IP_HDR_LEN(hlen));
1004 l3hdr = ((uintptr_t)eh + G_ETH_HDR_LEN(hlen));
1005 tcp = (const void *)(l3hdr + G_IP_HDR_LEN(hlen));
1008 /* extract TOS (DiffServ + ECN) byte for AccECN */
1010 if (((struct ip *)l3hdr)->ip_v == IPVERSION) {
1011 const struct ip *ip = (const void *)l3hdr;
1012 *iptos = ip->ip_tos;
1016 if (((struct ip *)l3hdr)->ip_v == (IPV6_VERSION >> 4)) {
1017 const struct ip6_hdr *ip6 = (const void *)l3hdr;
1018 *iptos = (ntohl(ip6->ip6_flow) >> 20) & 0xff;
1024 bzero(inc, sizeof(*inc));
1025 inc->inc_fport = tcp->th_sport;
1026 inc->inc_lport = tcp->th_dport;
1027 if (((struct ip *)l3hdr)->ip_v == IPVERSION) {
1028 const struct ip *ip = (const void *)l3hdr;
1030 inc->inc_faddr = ip->ip_src;
1031 inc->inc_laddr = ip->ip_dst;
1033 const struct ip6_hdr *ip6 = (const void *)l3hdr;
1035 inc->inc_flags |= INC_ISIPV6;
1036 inc->inc6_faddr = ip6->ip6_src;
1037 inc->inc6_laddr = ip6->ip6_dst;
1042 bcopy(tcp, th, sizeof(*th));
1043 tcp_fields_to_host(th); /* just like tcp_input */
1047 static struct l2t_entry *
1048 get_l2te_for_nexthop(struct port_info *pi, struct ifnet *ifp,
1049 struct in_conninfo *inc)
1051 struct l2t_entry *e;
1052 struct sockaddr_in6 sin6;
1053 struct sockaddr *dst = (void *)&sin6;
1055 if (inc->inc_flags & INC_ISIPV6) {
1056 struct nhop6_basic nh6;
1058 bzero(dst, sizeof(struct sockaddr_in6));
1059 dst->sa_len = sizeof(struct sockaddr_in6);
1060 dst->sa_family = AF_INET6;
1062 if (IN6_IS_ADDR_LINKLOCAL(&inc->inc6_laddr)) {
1063 /* no need for route lookup */
1064 e = t4_l2t_get(pi, ifp, dst);
1068 if (fib6_lookup_nh_basic(RT_DEFAULT_FIB, &inc->inc6_faddr,
1069 0, 0, 0, &nh6) != 0)
1071 if (nh6.nh_ifp != ifp)
1073 ((struct sockaddr_in6 *)dst)->sin6_addr = nh6.nh_addr;
1075 struct nhop4_basic nh4;
1077 dst->sa_len = sizeof(struct sockaddr_in);
1078 dst->sa_family = AF_INET;
1080 if (fib4_lookup_nh_basic(RT_DEFAULT_FIB, inc->inc_faddr, 0, 0,
1083 if (nh4.nh_ifp != ifp)
1085 ((struct sockaddr_in *)dst)->sin_addr = nh4.nh_addr;
1088 e = t4_l2t_get(pi, ifp, dst);
1093 send_synack(struct adapter *sc, struct synq_entry *synqe, uint64_t opt0,
1094 uint32_t opt2, int tid)
1097 struct cpl_pass_accept_rpl *rpl;
1098 struct l2t_entry *e = &sc->l2t->l2tab[synqe->params.l2t_idx];
1100 wr = alloc_wrqe(is_t4(sc) ? sizeof(struct cpl_pass_accept_rpl) :
1101 sizeof(struct cpl_t5_pass_accept_rpl), &sc->sge.ctrlq[0]);
1107 INIT_TP_WR_MIT_CPL(rpl, CPL_PASS_ACCEPT_RPL, tid);
1109 struct cpl_t5_pass_accept_rpl *rpl5 = (void *)rpl;
1111 INIT_TP_WR_MIT_CPL(rpl5, CPL_PASS_ACCEPT_RPL, tid);
1112 rpl5->iss = htobe32(synqe->iss);
1117 return (t4_l2t_send(sc, wr, e));
1120 #define REJECT_PASS_ACCEPT_REQ(tunnel) do { \
1125 reject_reason = __LINE__; \
1130 * The context associated with a tid entry via insert_tid could be a synq_entry
1131 * or a toepcb. The only way CPL handlers can tell is via a bit in these flags.
1133 CTASSERT(offsetof(struct toepcb, flags) == offsetof(struct synq_entry, flags));
1136 * Incoming SYN on a listening socket.
1138 * XXX: Every use of ifp in this routine has a bad race with up/down, toe/-toe,
1142 do_pass_accept_req(struct sge_iq *iq, const struct rss_header *rss,
1145 struct adapter *sc = iq->adapter;
1147 const struct cpl_pass_accept_req *cpl = mtod(m, const void *);
1148 unsigned int stid = G_PASS_OPEN_TID(be32toh(cpl->tos_stid));
1149 unsigned int tid = GET_TID(cpl);
1150 struct listen_ctx *lctx = lookup_stid(sc, stid);
1153 struct in_conninfo inc;
1156 struct port_info *pi;
1158 struct ifnet *hw_ifp, *ifp;
1159 struct l2t_entry *e = NULL;
1160 struct synq_entry *synqe = NULL;
1161 int reject_reason, v, ntids;
1162 uint16_t vid, l2info;
1163 struct epoch_tracker et;
1165 unsigned int opcode = G_CPL_OPCODE(be32toh(OPCODE_TID(cpl)));
1167 struct offload_settings settings;
1170 KASSERT(opcode == CPL_PASS_ACCEPT_REQ,
1171 ("%s: unexpected opcode 0x%x", __func__, opcode));
1172 KASSERT(lctx->stid == stid, ("%s: lctx stid mismatch", __func__));
1174 CTR4(KTR_CXGBE, "%s: stid %u, tid %u, lctx %p", __func__, stid, tid,
1177 CURVNET_SET(lctx->vnet); /* before any potential REJECT */
1180 * Use the MAC index to lookup the associated VI. If this SYN didn't
1181 * match a perfect MAC filter, punt.
1183 l2info = be16toh(cpl->l2info);
1184 pi = sc->port[G_SYN_INTF(l2info)];
1185 if (!(l2info & F_SYN_XACT_MATCH)) {
1186 REJECT_PASS_ACCEPT_REQ(false);
1188 for_each_vi(pi, v, vi) {
1189 if (vi->xact_addr_filt == G_SYN_MAC_IDX(l2info))
1192 REJECT_PASS_ACCEPT_REQ(false);
1194 hw_ifp = vi->ifp; /* the cxgbe ifnet */
1195 m->m_pkthdr.rcvif = hw_ifp;
1196 tod = TOEDEV(hw_ifp);
1199 * Don't offload if the peer requested a TCP option that's not known to
1200 * the silicon. Send the SYN to the kernel instead.
1202 if (__predict_false(cpl->tcpopt.unknown))
1203 REJECT_PASS_ACCEPT_REQ(true);
1206 * Figure out if there is a pseudo interface (vlan, lagg, etc.)
1207 * involved. Don't offload if the SYN had a VLAN tag and the vid
1208 * doesn't match anything on this interface.
1210 * XXX: lagg support, lagg + vlan support.
1212 vid = EVL_VLANOFTAG(be16toh(cpl->vlan));
1213 if (vid != 0xfff && vid != 0) {
1214 ifp = VLAN_DEVAT(hw_ifp, vid);
1216 REJECT_PASS_ACCEPT_REQ(true);
1221 * Don't offload if the ifnet that the SYN came in on is not in the same
1222 * vnet as the listening socket.
1224 if (lctx->vnet != ifp->if_vnet)
1225 REJECT_PASS_ACCEPT_REQ(true);
1227 pass_accept_req_to_protohdrs(sc, m, &inc, &th, &iptos);
1228 if (inc.inc_flags & INC_ISIPV6) {
1230 /* Don't offload if the ifcap isn't enabled */
1231 if ((ifp->if_capenable & IFCAP_TOE6) == 0)
1232 REJECT_PASS_ACCEPT_REQ(true);
1235 * SYN must be directed to an IP6 address on this ifnet. This
1236 * is more restrictive than in6_localip.
1238 NET_EPOCH_ENTER(et);
1239 if (!in6_ifhasaddr(ifp, &inc.inc6_laddr)) {
1241 REJECT_PASS_ACCEPT_REQ(true);
1247 /* Don't offload if the ifcap isn't enabled */
1248 if ((ifp->if_capenable & IFCAP_TOE4) == 0)
1249 REJECT_PASS_ACCEPT_REQ(true);
1252 * SYN must be directed to an IP address on this ifnet. This
1253 * is more restrictive than in_localip.
1255 NET_EPOCH_ENTER(et);
1256 if (!in_ifhasaddr(ifp, inc.inc_laddr)) {
1258 REJECT_PASS_ACCEPT_REQ(true);
1264 e = get_l2te_for_nexthop(pi, ifp, &inc);
1267 REJECT_PASS_ACCEPT_REQ(true);
1270 /* Don't offload if the 4-tuple is already in use */
1271 if (toe_4tuple_check(&inc, &th, ifp) != 0) {
1273 REJECT_PASS_ACCEPT_REQ(false);
1276 inp = lctx->inp; /* listening socket, not owned by TOE */
1279 /* Don't offload if the listening socket has closed */
1280 if (__predict_false(inp->inp_flags & INP_DROPPED)) {
1283 REJECT_PASS_ACCEPT_REQ(false);
1285 so = inp->inp_socket;
1286 rw_rlock(&sc->policy_lock);
1287 settings = *lookup_offload_policy(sc, OPEN_TYPE_PASSIVE, m,
1288 EVL_MAKETAG(0xfff, 0, 0), inp);
1289 rw_runlock(&sc->policy_lock);
1290 if (!settings.offload) {
1293 REJECT_PASS_ACCEPT_REQ(true); /* Rejected by COP. */
1296 synqe = alloc_synqe(sc, lctx, M_NOWAIT);
1297 if (synqe == NULL) {
1300 REJECT_PASS_ACCEPT_REQ(true);
1302 atomic_store_int(&synqe->ok_to_respond, 0);
1304 init_conn_params(vi, &settings, &inc, so, &cpl->tcpopt, e->idx,
1308 * If all goes well t4_syncache_respond will get called during
1309 * syncache_add. Note that syncache_add releases the pcb lock.
1311 t4opt_to_tcpopt(&cpl->tcpopt, &to);
1312 toe_syncache_add(&inc, &to, &th, inp, tod, synqe, iptos);
1314 if (atomic_load_int(&synqe->ok_to_respond) > 0) {
1318 opt0 = calc_options0(vi, &synqe->params);
1319 opt2 = calc_options2(vi, &synqe->params);
1321 insert_tid(sc, tid, synqe, ntids);
1326 if (send_synack(sc, synqe, opt0, opt2, tid) != 0) {
1327 remove_tid(sc, tid, ntids);
1331 REJECT_PASS_ACCEPT_REQ(true);
1335 "%s: stid %u, tid %u, synqe %p, opt0 %#016lx, opt2 %#08x",
1336 __func__, stid, tid, synqe, be64toh(opt0), be32toh(opt2));
1339 REJECT_PASS_ACCEPT_REQ(false);
1347 CTR4(KTR_CXGBE, "%s: stid %u, tid %u, REJECT (%d)", __func__, stid, tid,
1352 release_tid(sc, tid, lctx->ctrlq);
1354 inp = synqe->lctx->inp;
1356 inp = release_synqe(sc, synqe);
1363 * The connection request hit a TOE listener but is being passed
1364 * on to the kernel sw stack instead of getting offloaded.
1366 m_adj(m, sizeof(*cpl));
1367 m->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID |
1368 CSUM_DATA_VALID | CSUM_PSEUDO_HDR);
1369 m->m_pkthdr.csum_data = 0xffff;
1370 hw_ifp->if_input(hw_ifp, m);
1373 return (reject_reason);
1377 synqe_to_protohdrs(struct adapter *sc, struct synq_entry *synqe,
1378 const struct cpl_pass_establish *cpl, struct in_conninfo *inc,
1379 struct tcphdr *th, struct tcpopt *to)
1381 uint16_t tcp_opt = be16toh(cpl->tcp_opt);
1384 /* start off with the original SYN */
1385 pass_accept_req_to_protohdrs(sc, synqe->syn, inc, th, &iptos);
1387 /* modify parts to make it look like the ACK to our SYN|ACK */
1388 th->th_flags = TH_ACK;
1389 th->th_ack = synqe->iss + 1;
1390 th->th_seq = be32toh(cpl->rcv_isn);
1391 bzero(to, sizeof(*to));
1392 if (G_TCPOPT_TSTAMP(tcp_opt)) {
1393 to->to_flags |= TOF_TS;
1394 to->to_tsecr = synqe->ts;
1399 do_pass_establish(struct sge_iq *iq, const struct rss_header *rss,
1402 struct adapter *sc = iq->adapter;
1405 const struct cpl_pass_establish *cpl = (const void *)(rss + 1);
1406 #if defined(KTR) || defined(INVARIANTS)
1407 unsigned int stid = G_PASS_OPEN_TID(be32toh(cpl->tos_stid));
1409 unsigned int tid = GET_TID(cpl);
1410 struct synq_entry *synqe = lookup_tid(sc, tid);
1411 struct listen_ctx *lctx = synqe->lctx;
1412 struct inpcb *inp = lctx->inp, *new_inp;
1416 struct in_conninfo inc;
1417 struct toepcb *toep;
1418 struct epoch_tracker et;
1420 unsigned int opcode = G_CPL_OPCODE(be32toh(OPCODE_TID(cpl)));
1423 KASSERT(opcode == CPL_PASS_ESTABLISH,
1424 ("%s: unexpected opcode 0x%x", __func__, opcode));
1425 KASSERT(m == NULL, ("%s: wasn't expecting payload", __func__));
1426 KASSERT(lctx->stid == stid, ("%s: lctx stid mismatch", __func__));
1427 KASSERT(synqe->flags & TPF_SYNQE,
1428 ("%s: tid %u (ctx %p) not a synqe", __func__, tid, synqe));
1430 CURVNET_SET(lctx->vnet);
1431 NET_EPOCH_ENTER(et); /* for syncache_expand */
1435 "%s: stid %u, tid %u, synqe %p (0x%x), inp_flags 0x%x",
1436 __func__, stid, tid, synqe, synqe->flags, inp->inp_flags);
1438 ifp = synqe->syn->m_pkthdr.rcvif;
1440 KASSERT(vi->pi->adapter == sc,
1441 ("%s: vi %p, sc %p mismatch", __func__, vi, sc));
1443 if (__predict_false(inp->inp_flags & INP_DROPPED)) {
1445 send_reset_synqe(TOEDEV(ifp), synqe);
1452 KASSERT(synqe->params.rxq_idx == iq_to_ofld_rxq(iq) - &sc->sge.ofld_rxq[0],
1453 ("%s: CPL arrived on unexpected rxq. %d %d", __func__,
1454 synqe->params.rxq_idx,
1455 (int)(iq_to_ofld_rxq(iq) - &sc->sge.ofld_rxq[0])));
1457 toep = alloc_toepcb(vi, M_NOWAIT);
1461 toep->l2te = &sc->l2t->l2tab[synqe->params.l2t_idx];
1462 toep->vnet = lctx->vnet;
1463 bcopy(&synqe->params, &toep->params, sizeof(toep->params));
1464 init_toepcb(vi, toep);
1466 MPASS(be32toh(cpl->snd_isn) - 1 == synqe->iss);
1467 MPASS(be32toh(cpl->rcv_isn) - 1 == synqe->irs);
1468 synqe->tcp_opt = cpl->tcp_opt;
1471 /* Come up with something that syncache_expand should be ok with. */
1472 synqe_to_protohdrs(sc, synqe, cpl, &inc, &th, &to);
1473 if (inc.inc_flags & INC_ISIPV6)
1474 toep->ce = t4_hold_lip(sc, &inc.inc6_laddr, lctx->ce);
1475 so = inp->inp_socket;
1476 KASSERT(so != NULL, ("%s: socket is NULL", __func__));
1478 if (!toe_syncache_expand(&inc, &to, &th, &so) || so == NULL) {
1483 /* New connection inpcb is already locked by syncache_expand(). */
1484 new_inp = sotoinpcb(so);
1485 INP_WLOCK_ASSERT(new_inp);
1486 MPASS(so->so_vnet == lctx->vnet);
1489 * This is for expansion from syncookies.
1491 * XXX: we've held the tcbinfo lock throughout so there's no risk of
1492 * anyone accept'ing a connection before we've installed our hooks, but
1493 * this somewhat defeats the purpose of having a tod_offload_socket :-(
1495 if (__predict_false(!(synqe->flags & TPF_SYNQE_EXPANDED))) {
1496 tcp_timer_activate(intotcpcb(new_inp), TT_KEEP, 0);
1497 t4_offload_socket(TOEDEV(ifp), synqe, so);
1500 INP_WUNLOCK(new_inp);
1502 /* Done with the synqe */
1503 inp = release_synqe(sc, synqe);
1513 t4_init_listen_cpl_handlers(void)
1516 t4_register_cpl_handler(CPL_PASS_OPEN_RPL, do_pass_open_rpl);
1517 t4_register_cpl_handler(CPL_CLOSE_LISTSRV_RPL, do_close_server_rpl);
1518 t4_register_cpl_handler(CPL_PASS_ACCEPT_REQ, do_pass_accept_req);
1519 t4_register_cpl_handler(CPL_PASS_ESTABLISH, do_pass_establish);
1523 t4_uninit_listen_cpl_handlers(void)
1526 t4_register_cpl_handler(CPL_PASS_OPEN_RPL, NULL);
1527 t4_register_cpl_handler(CPL_CLOSE_LISTSRV_RPL, NULL);
1528 t4_register_cpl_handler(CPL_PASS_ACCEPT_REQ, NULL);
1529 t4_register_cpl_handler(CPL_PASS_ESTABLISH, NULL);