Author: np
Date: Sat Jan 14 04:34:30 2017
New Revision: 312117
URL: https://svnweb.freebsd.org/changeset/base/312117

Log:
  MFC r311569, r311657, and r311949.
  
  r311569:
  Fix comment in t4_tom.  No functional change.
  
  r311657:
  cxgbe/t4_tom: Fix tid accounting.  An offloaded IPv6 connection uses 2
  tids, not 1, in the hardware.
  
  r311949:
  cxgbe/tom: Add VIMAGE support to the TOE driver.
  
  Active Open:
  - Save the socket's vnet at the time of the active open (t4_connect) and
    switch to it when processing the reply (do_act_open_rpl or
    do_act_establish).
  
  Passive Open:
  - Save the listening socket's vnet in the driver's listen_ctx and switch
    to it when processing incoming SYNs for the socket.
  - Reject SYNs that arrive on an ifnet that's not in the same vnet as the
    listening socket.
  
  CLIP (Compressed Local IPv6) table:
  - Add only those IPv6 addresses to the CLIP that are in a vnet
    associated with one of the card's ifnets.
  
  Misc:
  - Set vnet from the toepcb when processing TCP state transitions.
  - The kernel sets the vnet when calling the driver's output routine
    so t4_push_frames runs in proper vnet context already.  One exception
    is when incoming credits trigger tx within the driver's ithread.  Set
    the vnet explicitly in do_fw4_ack for that case.
  
  Sponsored by: Chelsio Communications

Modified:
  stable/10/sys/dev/cxgbe/tom/t4_connect.c
  stable/10/sys/dev/cxgbe/tom/t4_cpl_io.c
  stable/10/sys/dev/cxgbe/tom/t4_ddp.c
  stable/10/sys/dev/cxgbe/tom/t4_listen.c
  stable/10/sys/dev/cxgbe/tom/t4_tom.c
  stable/10/sys/dev/cxgbe/tom/t4_tom.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/cxgbe/tom/t4_connect.c
==============================================================================
--- stable/10/sys/dev/cxgbe/tom/t4_connect.c    Sat Jan 14 04:24:49 2017        
(r312116)
+++ stable/10/sys/dev/cxgbe/tom/t4_connect.c    Sat Jan 14 04:34:30 2017        
(r312117)
@@ -107,7 +107,7 @@ free_atid(struct adapter *sc, int atid)
 }
 
 /*
- * Active open failed.
+ * Active open succeeded.
  */
 static int
 do_act_establish(struct sge_iq *iq, const struct rss_header *rss,
@@ -126,9 +126,10 @@ do_act_establish(struct sge_iq *iq, cons
        CTR3(KTR_CXGBE, "%s: atid %u, tid %u", __func__, atid, tid);
        free_atid(sc, atid);
 
+       CURVNET_SET(toep->vnet);
        INP_WLOCK(inp);
        toep->tid = tid;
-       insert_tid(sc, tid, toep);
+       insert_tid(sc, tid, toep, inp->inp_vflag & INP_IPV6 ? 2 : 1);
        if (inp->inp_flags & INP_DROPPED) {
 
                /* socket closed by the kernel before hw told us it connected */
@@ -141,6 +142,7 @@ do_act_establish(struct sge_iq *iq, cons
        make_established(toep, cpl->snd_isn, cpl->rcv_isn, cpl->tcp_opt);
 done:
        INP_WUNLOCK(inp);
+       CURVNET_RESTORE();
        return (0);
 }
 
@@ -178,6 +180,7 @@ act_open_failure_cleanup(struct adapter 
        free_atid(sc, atid);
        toep->tid = -1;
 
+       CURVNET_SET(toep->vnet);
        if (status != EAGAIN)
                INP_INFO_RLOCK(&V_tcbinfo);
        INP_WLOCK(inp);
@@ -185,8 +188,12 @@ act_open_failure_cleanup(struct adapter 
        final_cpl_received(toep);       /* unlocks inp */
        if (status != EAGAIN)
                INP_INFO_RUNLOCK(&V_tcbinfo);
+       CURVNET_RESTORE();
 }
 
+/*
+ * Active open failed.
+ */
 static int
 do_act_open_rpl(struct sge_iq *iq, const struct rss_header *rss,
     struct mbuf *m)
@@ -357,6 +364,7 @@ t4_connect(struct toedev *tod, struct so
        if (wr == NULL)
                DONT_OFFLOAD_ACTIVE_OPEN(ENOMEM);
 
+       toep->vnet = so->so_vnet;
        if (sc->tt.ddp && (so->so_options & SO_NO_DDP) == 0)
                set_tcpddp_ulp_mode(toep);
        else

Modified: stable/10/sys/dev/cxgbe/tom/t4_cpl_io.c
==============================================================================
--- stable/10/sys/dev/cxgbe/tom/t4_cpl_io.c     Sat Jan 14 04:24:49 2017        
(r312116)
+++ stable/10/sys/dev/cxgbe/tom/t4_cpl_io.c     Sat Jan 14 04:34:30 2017        
(r312117)
@@ -302,7 +302,6 @@ make_established(struct toepcb *toep, ui
        uint16_t tcpopt = be16toh(opt);
        struct flowc_tx_params ftxp;
 
-       CURVNET_SET(so->so_vnet);
        INP_WLOCK_ASSERT(inp);
        KASSERT(tp->t_state == TCPS_SYN_SENT ||
            tp->t_state == TCPS_SYN_RECEIVED,
@@ -353,7 +352,6 @@ make_established(struct toepcb *toep, ui
        send_flowc_wr(toep, &ftxp);
 
        soisconnected(so);
-       CURVNET_RESTORE();
 }
 
 static int
@@ -1107,6 +1105,7 @@ do_peer_close(struct sge_iq *iq, const s
 
        KASSERT(toep->tid == tid, ("%s: toep tid mismatch", __func__));
 
+       CURVNET_SET(toep->vnet);
        INP_INFO_RLOCK(&V_tcbinfo);
        INP_WLOCK(inp);
        tp = intotcpcb(inp);
@@ -1150,6 +1149,7 @@ do_peer_close(struct sge_iq *iq, const s
                tcp_twstart(tp);
                INP_UNLOCK_ASSERT(inp);  /* safe, we have a ref on the inp */
                INP_INFO_RUNLOCK(&V_tcbinfo);
+               CURVNET_RESTORE();
 
                INP_WLOCK(inp);
                final_cpl_received(toep);
@@ -1162,6 +1162,7 @@ do_peer_close(struct sge_iq *iq, const s
 done:
        INP_WUNLOCK(inp);
        INP_INFO_RUNLOCK(&V_tcbinfo);
+       CURVNET_RESTORE();
        return (0);
 }
 
@@ -1188,6 +1189,7 @@ do_close_con_rpl(struct sge_iq *iq, cons
        KASSERT(m == NULL, ("%s: wasn't expecting payload", __func__));
        KASSERT(toep->tid == tid, ("%s: toep tid mismatch", __func__));
 
+       CURVNET_SET(toep->vnet);
        INP_INFO_RLOCK(&V_tcbinfo);
        INP_WLOCK(inp);
        tp = intotcpcb(inp);
@@ -1207,6 +1209,7 @@ do_close_con_rpl(struct sge_iq *iq, cons
 release:
                INP_UNLOCK_ASSERT(inp); /* safe, we have a ref on the  inp */
                INP_INFO_RUNLOCK(&V_tcbinfo);
+               CURVNET_RESTORE();
 
                INP_WLOCK(inp);
                final_cpl_received(toep);       /* no more CPLs expected */
@@ -1231,6 +1234,7 @@ release:
 done:
        INP_WUNLOCK(inp);
        INP_INFO_RUNLOCK(&V_tcbinfo);
+       CURVNET_RESTORE();
        return (0);
 }
 
@@ -1304,6 +1308,7 @@ do_abort_req(struct sge_iq *iq, const st
        }
 
        inp = toep->inp;
+       CURVNET_SET(toep->vnet);
        INP_INFO_RLOCK(&V_tcbinfo);     /* for tcp_close */
        INP_WLOCK(inp);
 
@@ -1339,6 +1344,7 @@ do_abort_req(struct sge_iq *iq, const st
        final_cpl_received(toep);
 done:
        INP_INFO_RUNLOCK(&V_tcbinfo);
+       CURVNET_RESTORE();
        send_abort_rpl(sc, ofld_txq, tid, CPL_ABORT_NO_RST);
        return (0);
 }
@@ -1456,18 +1462,21 @@ do_rx_data(struct sge_iq *iq, const stru
                SOCKBUF_UNLOCK(sb);
                INP_WUNLOCK(inp);
 
+               CURVNET_SET(toep->vnet);
                INP_INFO_RLOCK(&V_tcbinfo);
                INP_WLOCK(inp);
                tp = tcp_drop(tp, ECONNRESET);
                if (tp)
                        INP_WUNLOCK(inp);
                INP_INFO_RUNLOCK(&V_tcbinfo);
+               CURVNET_RESTORE();
 
                return (0);
        }
 
        /* receive buffer autosize */
-       CURVNET_SET(so->so_vnet);
+       MPASS(toep->vnet == so->so_vnet);
+       CURVNET_SET(toep->vnet);
        if (sb->sb_flags & SB_AUTOSIZE &&
            V_tcp_do_autorcvbuf &&
            sb->sb_hiwat < V_tcp_autorcvbuf_max &&
@@ -1674,10 +1683,12 @@ do_fw4_ack(struct sge_iq *iq, const stru
        if (toep->flags & TPF_TX_SUSPENDED &&
            toep->tx_credits >= toep->tx_total / 4) {
                toep->flags &= ~TPF_TX_SUSPENDED;
+               CURVNET_SET(toep->vnet);
                if (toep->ulp_mode == ULP_MODE_ISCSI)
                        t4_push_pdus(sc, toep, plen);
                else
                        t4_push_frames(sc, toep, plen);
+               CURVNET_RESTORE();
        } else if (plen > 0) {
                struct sockbuf *sb = &so->so_snd;
                int sbu;

Modified: stable/10/sys/dev/cxgbe/tom/t4_ddp.c
==============================================================================
--- stable/10/sys/dev/cxgbe/tom/t4_ddp.c        Sat Jan 14 04:24:49 2017        
(r312116)
+++ stable/10/sys/dev/cxgbe/tom/t4_ddp.c        Sat Jan 14 04:34:30 2017        
(r312117)
@@ -392,6 +392,9 @@ handle_ddp_data(struct toepcb *toep, __b
                discourage_ddp(toep);
 
        /* receive buffer autosize */
+       MPASS(toep->vnet == so->so_vnet);
+       CURVNET_SET(toep->vnet);
+       SOCKBUF_LOCK(sb);
        if (sb->sb_flags & SB_AUTOSIZE &&
            V_tcp_do_autorcvbuf &&
            sb->sb_hiwat < V_tcp_autorcvbuf_max &&
@@ -405,6 +408,7 @@ handle_ddp_data(struct toepcb *toep, __b
                else
                        toep->rx_credits += newsize - hiwat;
        }
+       CURVNET_RESTORE();
 
        KASSERT(toep->sb_cc >= sb->sb_cc,
            ("%s: sb %p has more data (%d) than last time (%d).",

Modified: stable/10/sys/dev/cxgbe/tom/t4_listen.c
==============================================================================
--- stable/10/sys/dev/cxgbe/tom/t4_listen.c     Sat Jan 14 04:24:49 2017        
(r312116)
+++ stable/10/sys/dev/cxgbe/tom/t4_listen.c     Sat Jan 14 04:34:30 2017        
(r312117)
@@ -220,6 +220,7 @@ alloc_lctx(struct adapter *sc, struct in
        TAILQ_INIT(&lctx->synq);
 
        lctx->inp = inp;
+       lctx->vnet = inp->inp_socket->so_vnet;
        in_pcbref(inp);
 
        return (lctx);
@@ -825,14 +826,16 @@ done_with_synqe(struct adapter *sc, stru
        struct inpcb *inp = lctx->inp;
        struct vi_info *vi = synqe->syn->m_pkthdr.rcvif->if_softc;
        struct l2t_entry *e = &sc->l2t->l2tab[synqe->l2e_idx];
+       int ntids;
 
        INP_WLOCK_ASSERT(inp);
+       ntids = inp->inp_vflag & INP_IPV6 ? 2 : 1;
 
        TAILQ_REMOVE(&lctx->synq, synqe, link);
        inp = release_lctx(sc, lctx);
        if (inp)
                INP_WUNLOCK(inp);
-       remove_tid(sc, synqe->tid);
+       remove_tid(sc, synqe->tid, ntids);
        release_tid(sc, synqe->tid, &sc->sge.ctrlq[vi->pi->port_id]);
        t4_l2t_release(e);
        release_synqe(synqe);   /* removed from synq list */
@@ -1235,7 +1238,7 @@ do_pass_accept_req(struct sge_iq *iq, co
        struct l2t_entry *e = NULL;
        int rscale, mtu_idx, rx_credits, rxqid, ulp_mode;
        struct synq_entry *synqe = NULL;
-       int reject_reason, v;
+       int reject_reason, v, ntids;
        uint16_t vid;
 #ifdef INVARIANTS
        unsigned int opcode = G_CPL_OPCODE(be32toh(OPCODE_TID(cpl)));
@@ -1253,6 +1256,8 @@ do_pass_accept_req(struct sge_iq *iq, co
 
        pi = sc->port[G_SYN_INTF(be16toh(cpl->l2info))];
 
+       CURVNET_SET(lctx->vnet);
+
        /*
         * Use the MAC index to lookup the associated VI.  If this SYN
         * didn't match a perfect MAC filter, punt.
@@ -1309,6 +1314,8 @@ found:
                 */
                if (!ifnet_has_ip6(ifp, &inc.inc6_laddr))
                        REJECT_PASS_ACCEPT();
+
+               ntids = 2;
        } else {
 
                /* Don't offload if the ifcap isn't enabled */
@@ -1321,8 +1328,17 @@ found:
                 */
                if (!ifnet_has_ip(ifp, inc.inc_laddr))
                        REJECT_PASS_ACCEPT();
+
+               ntids = 1;
        }
 
+       /*
+        * Don't offload if the ifnet that the SYN came in on is not in the same
+        * vnet as the listening socket.
+        */
+       if (lctx->vnet != ifp->if_vnet)
+               REJECT_PASS_ACCEPT();
+
        e = get_l2te_for_nexthop(pi, ifp, &inc);
        if (e == NULL)
                REJECT_PASS_ACCEPT();
@@ -1362,7 +1378,6 @@ found:
                REJECT_PASS_ACCEPT();
        }
        so = inp->inp_socket;
-       CURVNET_SET(so->so_vnet);
 
        mtu_idx = find_best_mtu_idx(sc, &inc, be16toh(cpl->tcpopt.mss));
        rscale = cpl->tcpopt.wsf && V_tcp_do_rfc1323 ? select_rcv_wscale() : 0;
@@ -1398,7 +1413,7 @@ found:
        synqe->rcv_bufsize = rx_credits;
        atomic_store_rel_ptr(&synqe->wr, (uintptr_t)wr);
 
-       insert_tid(sc, tid, synqe);
+       insert_tid(sc, tid, synqe, ntids);
        TAILQ_INSERT_TAIL(&lctx->synq, synqe, link);
        hold_synqe(synqe);      /* hold for the duration it's in the synq */
        hold_lctx(lctx);        /* A synqe on the list has a ref on its lctx */
@@ -1409,7 +1424,6 @@ found:
         */
        toe_syncache_add(&inc, &to, &th, inp, tod, synqe);
        INP_UNLOCK_ASSERT(inp); /* ok to assert, we have a ref on the inp */
-       CURVNET_RESTORE();
 
        /*
         * If we replied during syncache_add (synqe->wr has been consumed),
@@ -1427,7 +1441,7 @@ found:
                if (m)
                        m->m_pkthdr.rcvif = hw_ifp;
 
-               remove_tid(sc, synqe->tid);
+               remove_tid(sc, synqe->tid, ntids);
                free(wr, M_CXGBE);
 
                /* Yank the synqe out of the lctx synq. */
@@ -1464,10 +1478,12 @@ found:
                return (__LINE__);
        }
        INP_WUNLOCK(inp);
+       CURVNET_RESTORE();
 
        release_synqe(synqe);   /* extra hold */
        return (0);
 reject:
+       CURVNET_RESTORE();
        CTR4(KTR_CXGBE, "%s: stid %u, tid %u, REJECT (%d)", __func__, stid, tid,
            reject_reason);
 
@@ -1539,6 +1555,7 @@ do_pass_establish(struct sge_iq *iq, con
        KASSERT(synqe->flags & TPF_SYNQE,
            ("%s: tid %u (ctx %p) not a synqe", __func__, tid, synqe));
 
+       CURVNET_SET(lctx->vnet);
        INP_INFO_RLOCK(&V_tcbinfo);     /* for syncache_expand */
        INP_WLOCK(inp);
 
@@ -1556,6 +1573,7 @@ do_pass_establish(struct sge_iq *iq, con
 
                INP_WUNLOCK(inp);
                INP_INFO_RUNLOCK(&V_tcbinfo);
+               CURVNET_RESTORE();
                return (0);
        }
 
@@ -1581,6 +1599,7 @@ reset:
                send_reset_synqe(TOEDEV(ifp), synqe);
                INP_WUNLOCK(inp);
                INP_INFO_RUNLOCK(&V_tcbinfo);
+               CURVNET_RESTORE();
                return (0);
        }
        toep->tid = tid;
@@ -1617,6 +1636,8 @@ reset:
        /* New connection inpcb is already locked by syncache_expand(). */
        new_inp = sotoinpcb(so);
        INP_WLOCK_ASSERT(new_inp);
+       MPASS(so->so_vnet == lctx->vnet);
+       toep->vnet = lctx->vnet;
 
        /*
         * This is for the unlikely case where the syncache entry that we added
@@ -1640,6 +1661,7 @@ reset:
        if (inp != NULL)
                INP_WUNLOCK(inp);
        INP_INFO_RUNLOCK(&V_tcbinfo);
+       CURVNET_RESTORE();
        release_synqe(synqe);
 
        return (0);

Modified: stable/10/sys/dev/cxgbe/tom/t4_tom.c
==============================================================================
--- stable/10/sys/dev/cxgbe/tom/t4_tom.c        Sat Jan 14 04:24:49 2017        
(r312116)
+++ stable/10/sys/dev/cxgbe/tom/t4_tom.c        Sat Jan 14 04:34:30 2017        
(r312117)
@@ -321,7 +321,7 @@ release_offload_resources(struct toepcb 
                t4_l2t_release(toep->l2te);
 
        if (tid >= 0) {
-               remove_tid(sc, tid);
+               remove_tid(sc, tid, toep->ce ? 2 : 1);
                release_tid(sc, tid, toep->ctrlq);
        }
 
@@ -432,12 +432,12 @@ final_cpl_received(struct toepcb *toep)
 }
 
 void
-insert_tid(struct adapter *sc, int tid, void *ctx)
+insert_tid(struct adapter *sc, int tid, void *ctx, int ntids)
 {
        struct tid_info *t = &sc->tids;
 
        t->tid_tab[tid] = ctx;
-       atomic_add_int(&t->tids_in_use, 1);
+       atomic_add_int(&t->tids_in_use, ntids);
 }
 
 void *
@@ -457,12 +457,12 @@ update_tid(struct adapter *sc, int tid, 
 }
 
 void
-remove_tid(struct adapter *sc, int tid)
+remove_tid(struct adapter *sc, int tid, int ntids)
 {
        struct tid_info *t = &sc->tids;
 
        t->tid_tab[tid] = NULL;
-       atomic_subtract_int(&t->tids_in_use, 1);
+       atomic_subtract_int(&t->tids_in_use, ntids);
 }
 
 void
@@ -811,74 +811,96 @@ update_clip_table(struct adapter *sc, st
        struct in6_addr *lip, tlip;
        struct clip_head stale;
        struct clip_entry *ce, *ce_temp;
-       int rc, gen = atomic_load_acq_int(&in6_ifaddr_gen);
+       struct vi_info *vi;
+       int rc, gen, i, j;
+       uintptr_t last_vnet;
 
        ASSERT_SYNCHRONIZED_OP(sc);
 
        IN6_IFADDR_RLOCK();
        mtx_lock(&td->clip_table_lock);
 
+       gen = atomic_load_acq_int(&in6_ifaddr_gen);
        if (gen == td->clip_gen)
                goto done;
 
        TAILQ_INIT(&stale);
        TAILQ_CONCAT(&stale, &td->clip_table, link);
 
-       TAILQ_FOREACH(ia, &V_in6_ifaddrhead, ia_link) {
-               lip = &ia->ia_addr.sin6_addr;
+       /*
+        * last_vnet optimizes the common cases where all if_vnet = NULL (no
+        * VIMAGE) or all if_vnet = vnet0.
+        */
+       last_vnet = (uintptr_t)(-1);
+       for_each_port(sc, i)
+       for_each_vi(sc->port[i], j, vi) {
+               if (last_vnet == (uintptr_t)vi->ifp->if_vnet)
+                       continue;
 
-               KASSERT(!IN6_IS_ADDR_MULTICAST(lip),
-                   ("%s: mcast address in in6_ifaddr list", __func__));
+               /* XXX: races with if_vmove */
+               CURVNET_SET(vi->ifp->if_vnet);
+               TAILQ_FOREACH(ia, &V_in6_ifaddrhead, ia_link) {
+                       lip = &ia->ia_addr.sin6_addr;
+
+                       KASSERT(!IN6_IS_ADDR_MULTICAST(lip),
+                           ("%s: mcast address in in6_ifaddr list", __func__));
+
+                       if (IN6_IS_ADDR_LOOPBACK(lip))
+                               continue;
+                       if (IN6_IS_SCOPE_EMBED(lip)) {
+                               /* Remove the embedded scope */
+                               tlip = *lip;
+                               lip = &tlip;
+                               in6_clearscope(lip);
+                       }
+                       /*
+                        * XXX: how to weed out the link local address for the
+                        * loopback interface?  It's fe80::1 usually (always?).
+                        */
+
+                       /*
+                        * If it's in the main list then we already know it's
+                        * not stale.
+                        */
+                       TAILQ_FOREACH(ce, &td->clip_table, link) {
+                               if (IN6_ARE_ADDR_EQUAL(&ce->lip, lip))
+                                       goto next;
+                       }
 
-               if (IN6_IS_ADDR_LOOPBACK(lip))
-                       continue;
-               if (IN6_IS_SCOPE_EMBED(lip)) {
-                       /* Remove the embedded scope */
-                       tlip = *lip;
-                       lip = &tlip;
-                       in6_clearscope(lip);
-               }
-               /*
-                * XXX: how to weed out the link local address for the loopback
-                * interface?  It's fe80::1 usually (always?).
-                */
-
-               /*
-                * If it's in the main list then we already know it's not stale.
-                */
-               TAILQ_FOREACH(ce, &td->clip_table, link) {
-                       if (IN6_ARE_ADDR_EQUAL(&ce->lip, lip))
-                               goto next;
-               }
+                       /*
+                        * If it's in the stale list we should move it to the
+                        * main list.
+                        */
+                       TAILQ_FOREACH(ce, &stale, link) {
+                               if (IN6_ARE_ADDR_EQUAL(&ce->lip, lip)) {
+                                       TAILQ_REMOVE(&stale, ce, link);
+                                       TAILQ_INSERT_TAIL(&td->clip_table, ce,
+                                           link);
+                                       goto next;
+                               }
+                       }
 
-               /*
-                * If it's in the stale list we should move it to the main list.
-                */
-               TAILQ_FOREACH(ce, &stale, link) {
-                       if (IN6_ARE_ADDR_EQUAL(&ce->lip, lip)) {
-                               TAILQ_REMOVE(&stale, ce, link);
+                       /* A new IP6 address; add it to the CLIP table */
+                       ce = malloc(sizeof(*ce), M_CXGBE, M_NOWAIT);
+                       memcpy(&ce->lip, lip, sizeof(ce->lip));
+                       ce->refcount = 0;
+                       rc = add_lip(sc, lip);
+                       if (rc == 0)
                                TAILQ_INSERT_TAIL(&td->clip_table, ce, link);
-                               goto next;
-                       }
-               }
+                       else {
+                               char ip[INET6_ADDRSTRLEN];
 
-               /* A new IP6 address; add it to the CLIP table */
-               ce = malloc(sizeof(*ce), M_CXGBE, M_NOWAIT);
-               memcpy(&ce->lip, lip, sizeof(ce->lip));
-               ce->refcount = 0;
-               rc = add_lip(sc, lip);
-               if (rc == 0)
-                       TAILQ_INSERT_TAIL(&td->clip_table, ce, link);
-               else {
-                       char ip[INET6_ADDRSTRLEN];
-
-                       inet_ntop(AF_INET6, &ce->lip, &ip[0], sizeof(ip));
-                       log(LOG_ERR, "%s: could not add %s (%d)\n",
-                           __func__, ip, rc);
-                       free(ce, M_CXGBE);
-               }
+                               inet_ntop(AF_INET6, &ce->lip, &ip[0],
+                                   sizeof(ip));
+                               log(LOG_ERR, "%s: could not add %s (%d)\n",
+                                   __func__, ip, rc);
+                               free(ce, M_CXGBE);
+                       }
 next:
-               continue;
+                       continue;
+               }
+               CURVNET_RESTORE();
+               last_vnet = (uintptr_t)vi->ifp->if_vnet;
        }
 
        /*

Modified: stable/10/sys/dev/cxgbe/tom/t4_tom.h
==============================================================================
--- stable/10/sys/dev/cxgbe/tom/t4_tom.h        Sat Jan 14 04:24:49 2017        
(r312116)
+++ stable/10/sys/dev/cxgbe/tom/t4_tom.h        Sat Jan 14 04:34:30 2017        
(r312117)
@@ -123,6 +123,7 @@ struct toepcb {
        u_int flags;            /* miscellaneous flags */
        struct tom_data *td;
        struct inpcb *inp;      /* backpointer to host stack's PCB */
+       struct vnet *vnet;
        struct vi_info *vi;     /* virtual interface */
        struct sge_wrq *ofld_txq;
        struct sge_ofld_rxq *ofld_rxq;
@@ -199,6 +200,7 @@ struct listen_ctx {
        struct stid_region stid_region;
        int flags;
        struct inpcb *inp;              /* listening socket's inp */
+       struct vnet *vnet;
        struct sge_wrq *ctrlq;
        struct sge_ofld_rxq *ofld_rxq;
        struct clip_entry *ce;
@@ -278,10 +280,10 @@ void free_toepcb(struct toepcb *);
 void offload_socket(struct socket *, struct toepcb *);
 void undo_offload_socket(struct socket *);
 void final_cpl_received(struct toepcb *);
-void insert_tid(struct adapter *, int, void *);
+void insert_tid(struct adapter *, int, void *, int);
 void *lookup_tid(struct adapter *, int);
 void update_tid(struct adapter *, int, void *);
-void remove_tid(struct adapter *, int);
+void remove_tid(struct adapter *, int, int);
 void release_tid(struct adapter *, int, struct sge_wrq *);
 int find_best_mtu_idx(struct adapter *, struct in_conninfo *, int);
 u_long select_rcv_wnd(struct socket *);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to