cxgbe/tom: Add support for fully offloaded TCP/IPv6 connections (active open).
MFC after: 1 week
This commit is contained in:
parent
425dd534ac
commit
8be0815671
@ -29,6 +29,7 @@
|
|||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include "opt_inet.h"
|
#include "opt_inet.h"
|
||||||
|
#include "opt_inet6.h"
|
||||||
|
|
||||||
#ifdef TCP_OFFLOAD
|
#ifdef TCP_OFFLOAD
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -220,10 +221,9 @@ do_act_open_rpl(struct sge_iq *iq, const struct rss_header *rss,
|
|||||||
* Options2 for active open.
|
* Options2 for active open.
|
||||||
*/
|
*/
|
||||||
static uint32_t
|
static uint32_t
|
||||||
calc_opt2a(struct socket *so)
|
calc_opt2a(struct socket *so, struct toepcb *toep)
|
||||||
{
|
{
|
||||||
struct tcpcb *tp = so_sototcpcb(so);
|
struct tcpcb *tp = so_sototcpcb(so);
|
||||||
struct toepcb *toep = tp->t_toe;
|
|
||||||
struct port_info *pi = toep->port;
|
struct port_info *pi = toep->port;
|
||||||
struct adapter *sc = pi->adapter;
|
struct adapter *sc = pi->adapter;
|
||||||
uint32_t opt2 = 0;
|
uint32_t opt2 = 0;
|
||||||
@ -260,6 +260,12 @@ t4_init_connect_cpl_handlers(struct adapter *sc)
|
|||||||
t4_register_cpl_handler(sc, CPL_ACT_OPEN_RPL, do_act_open_rpl);
|
t4_register_cpl_handler(sc, CPL_ACT_OPEN_RPL, do_act_open_rpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DONT_OFFLOAD_ACTIVE_OPEN(x) do { \
|
||||||
|
reason = __LINE__; \
|
||||||
|
rc = (x); \
|
||||||
|
goto failed; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* active open (soconnect).
|
* active open (soconnect).
|
||||||
*
|
*
|
||||||
@ -275,20 +281,19 @@ t4_connect(struct toedev *tod, struct socket *so, struct rtentry *rt,
|
|||||||
struct sockaddr *nam)
|
struct sockaddr *nam)
|
||||||
{
|
{
|
||||||
struct adapter *sc = tod->tod_softc;
|
struct adapter *sc = tod->tod_softc;
|
||||||
|
struct tom_data *td = tod_td(tod);
|
||||||
struct toepcb *toep = NULL;
|
struct toepcb *toep = NULL;
|
||||||
struct wrqe *wr = NULL;
|
struct wrqe *wr = NULL;
|
||||||
struct cpl_act_open_req *cpl;
|
|
||||||
struct l2t_entry *e = NULL;
|
|
||||||
struct ifnet *rt_ifp = rt->rt_ifp;
|
struct ifnet *rt_ifp = rt->rt_ifp;
|
||||||
struct port_info *pi;
|
struct port_info *pi;
|
||||||
int atid = -1, mtu_idx, rscale, qid_atid, rc = ENOMEM;
|
int mtu_idx, rscale, qid_atid, rc, isipv6;
|
||||||
struct inpcb *inp = sotoinpcb(so);
|
struct inpcb *inp = sotoinpcb(so);
|
||||||
struct tcpcb *tp = intotcpcb(inp);
|
struct tcpcb *tp = intotcpcb(inp);
|
||||||
|
int reason;
|
||||||
|
|
||||||
INP_WLOCK_ASSERT(inp);
|
INP_WLOCK_ASSERT(inp);
|
||||||
|
KASSERT(nam->sa_family == AF_INET || nam->sa_family == AF_INET6,
|
||||||
if (nam->sa_family != AF_INET)
|
("%s: dest addr %p has family %u", __func__, nam, nam->sa_family));
|
||||||
CXGBE_UNIMPLEMENTED("IPv6 connect");
|
|
||||||
|
|
||||||
if (rt_ifp->if_type == IFT_ETHER)
|
if (rt_ifp->if_type == IFT_ETHER)
|
||||||
pi = rt_ifp->if_softc;
|
pi = rt_ifp->if_softc;
|
||||||
@ -297,30 +302,29 @@ t4_connect(struct toedev *tod, struct socket *so, struct rtentry *rt,
|
|||||||
|
|
||||||
pi = ifp->if_softc;
|
pi = ifp->if_softc;
|
||||||
} else if (rt_ifp->if_type == IFT_IEEE8023ADLAG)
|
} else if (rt_ifp->if_type == IFT_IEEE8023ADLAG)
|
||||||
return (ENOSYS); /* XXX: implement lagg support */
|
DONT_OFFLOAD_ACTIVE_OPEN(ENOSYS); /* XXX: implement lagg+TOE */
|
||||||
else
|
else
|
||||||
return (ENOTSUP);
|
DONT_OFFLOAD_ACTIVE_OPEN(ENOTSUP);
|
||||||
|
|
||||||
toep = alloc_toepcb(pi, -1, -1, M_NOWAIT);
|
toep = alloc_toepcb(pi, -1, -1, M_NOWAIT);
|
||||||
if (toep == NULL)
|
if (toep == NULL)
|
||||||
goto failed;
|
DONT_OFFLOAD_ACTIVE_OPEN(ENOMEM);
|
||||||
|
|
||||||
atid = alloc_atid(sc, toep);
|
toep->tid = alloc_atid(sc, toep);
|
||||||
if (atid < 0)
|
if (toep->tid < 0)
|
||||||
goto failed;
|
DONT_OFFLOAD_ACTIVE_OPEN(ENOMEM);
|
||||||
|
|
||||||
e = t4_l2t_get(pi, rt_ifp,
|
toep->l2te = t4_l2t_get(pi, rt_ifp,
|
||||||
rt->rt_flags & RTF_GATEWAY ? rt->rt_gateway : nam);
|
rt->rt_flags & RTF_GATEWAY ? rt->rt_gateway : nam);
|
||||||
if (e == NULL)
|
if (toep->l2te == NULL)
|
||||||
goto failed;
|
DONT_OFFLOAD_ACTIVE_OPEN(ENOMEM);
|
||||||
|
|
||||||
wr = alloc_wrqe(sizeof(*cpl), toep->ctrlq);
|
isipv6 = nam->sa_family == AF_INET6;
|
||||||
|
wr = alloc_wrqe(isipv6 ? sizeof(struct cpl_act_open_req6) :
|
||||||
|
sizeof(struct cpl_act_open_req), toep->ctrlq);
|
||||||
if (wr == NULL)
|
if (wr == NULL)
|
||||||
goto failed;
|
DONT_OFFLOAD_ACTIVE_OPEN(ENOMEM);
|
||||||
cpl = wrtod(wr);
|
|
||||||
|
|
||||||
toep->tid = atid;
|
|
||||||
toep->l2te = e;
|
|
||||||
if (sc->tt.ddp && (so->so_options & SO_NO_DDP) == 0)
|
if (sc->tt.ddp && (so->so_options & SO_NO_DDP) == 0)
|
||||||
set_tcpddp_ulp_mode(toep);
|
set_tcpddp_ulp_mode(toep);
|
||||||
else
|
else
|
||||||
@ -330,8 +334,6 @@ t4_connect(struct toedev *tod, struct socket *so, struct rtentry *rt,
|
|||||||
toep->rx_credits = min(select_rcv_wnd(so) >> 10, M_RCV_BUFSIZ);
|
toep->rx_credits = min(select_rcv_wnd(so) >> 10, M_RCV_BUFSIZ);
|
||||||
SOCKBUF_UNLOCK(&so->so_rcv);
|
SOCKBUF_UNLOCK(&so->so_rcv);
|
||||||
|
|
||||||
offload_socket(so, toep);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The kernel sets request_r_scale based on sb_max whereas we need to
|
* The kernel sets request_r_scale based on sb_max whereas we need to
|
||||||
* take hardware's MAX_RCV_WND into account too. This is normally a
|
* take hardware's MAX_RCV_WND into account too. This is normally a
|
||||||
@ -342,39 +344,78 @@ t4_connect(struct toedev *tod, struct socket *so, struct rtentry *rt,
|
|||||||
else
|
else
|
||||||
rscale = 0;
|
rscale = 0;
|
||||||
mtu_idx = find_best_mtu_idx(sc, &inp->inp_inc, 0);
|
mtu_idx = find_best_mtu_idx(sc, &inp->inp_inc, 0);
|
||||||
qid_atid = (toep->ofld_rxq->iq.abs_id << 14) | atid;
|
qid_atid = (toep->ofld_rxq->iq.abs_id << 14) | toep->tid;
|
||||||
|
|
||||||
INIT_TP_WR(cpl, 0);
|
if (isipv6) {
|
||||||
OPCODE_TID(cpl) = htobe32(MK_OPCODE_TID(CPL_ACT_OPEN_REQ, qid_atid));
|
struct cpl_act_open_req6 *cpl = wrtod(wr);
|
||||||
inp_4tuple_get(inp, &cpl->local_ip, &cpl->local_port, &cpl->peer_ip,
|
|
||||||
&cpl->peer_port);
|
if ((inp->inp_vflag & INP_IPV6) == 0) {
|
||||||
cpl->opt0 = calc_opt0(so, pi, e, mtu_idx, rscale, toep->rx_credits,
|
/* XXX think about this a bit more */
|
||||||
toep->ulp_mode);
|
log(LOG_ERR,
|
||||||
cpl->params = select_ntuple(pi, e, sc->filter_mode);
|
"%s: time to think about AF_INET6 + vflag 0x%x.\n",
|
||||||
cpl->opt2 = calc_opt2a(so);
|
__func__, inp->inp_vflag);
|
||||||
|
DONT_OFFLOAD_ACTIVE_OPEN(ENOTSUP);
|
||||||
|
}
|
||||||
|
|
||||||
|
toep->ce = hold_lip(td, &inp->in6p_laddr);
|
||||||
|
if (toep->ce == NULL)
|
||||||
|
DONT_OFFLOAD_ACTIVE_OPEN(ENOENT);
|
||||||
|
|
||||||
|
INIT_TP_WR(cpl, 0);
|
||||||
|
OPCODE_TID(cpl) = htobe32(MK_OPCODE_TID(CPL_ACT_OPEN_REQ6,
|
||||||
|
qid_atid));
|
||||||
|
|
||||||
|
cpl->local_port = inp->inp_lport;
|
||||||
|
cpl->local_ip_hi = *(uint64_t *)&inp->in6p_laddr.s6_addr[0];
|
||||||
|
cpl->local_ip_lo = *(uint64_t *)&inp->in6p_laddr.s6_addr[8];
|
||||||
|
cpl->peer_port = inp->inp_fport;
|
||||||
|
cpl->peer_ip_hi = *(uint64_t *)&inp->in6p_faddr.s6_addr[0];
|
||||||
|
cpl->peer_ip_lo = *(uint64_t *)&inp->in6p_faddr.s6_addr[8];
|
||||||
|
cpl->opt0 = calc_opt0(so, pi, toep->l2te, mtu_idx, rscale,
|
||||||
|
toep->rx_credits, toep->ulp_mode);
|
||||||
|
cpl->params = select_ntuple(pi, toep->l2te, sc->filter_mode);
|
||||||
|
cpl->opt2 = calc_opt2a(so, toep);
|
||||||
|
} else {
|
||||||
|
struct cpl_act_open_req *cpl = wrtod(wr);
|
||||||
|
|
||||||
|
INIT_TP_WR(cpl, 0);
|
||||||
|
OPCODE_TID(cpl) = htobe32(MK_OPCODE_TID(CPL_ACT_OPEN_REQ,
|
||||||
|
qid_atid));
|
||||||
|
inp_4tuple_get(inp, &cpl->local_ip, &cpl->local_port,
|
||||||
|
&cpl->peer_ip, &cpl->peer_port);
|
||||||
|
cpl->opt0 = calc_opt0(so, pi, toep->l2te, mtu_idx, rscale,
|
||||||
|
toep->rx_credits, toep->ulp_mode);
|
||||||
|
cpl->params = select_ntuple(pi, toep->l2te, sc->filter_mode);
|
||||||
|
cpl->opt2 = calc_opt2a(so, toep);
|
||||||
|
}
|
||||||
|
|
||||||
CTR5(KTR_CXGBE, "%s: atid %u (%s), toep %p, inp %p", __func__,
|
CTR5(KTR_CXGBE, "%s: atid %u (%s), toep %p, inp %p", __func__,
|
||||||
toep->tid, tcpstates[tp->t_state], toep, inp);
|
toep->tid, tcpstates[tp->t_state], toep, inp);
|
||||||
|
|
||||||
rc = t4_l2t_send(sc, wr, e);
|
offload_socket(so, toep);
|
||||||
|
rc = t4_l2t_send(sc, wr, toep->l2te);
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
toep->flags |= TPF_CPL_PENDING;
|
toep->flags |= TPF_CPL_PENDING;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
undo_offload_socket(so);
|
undo_offload_socket(so);
|
||||||
|
reason = __LINE__;
|
||||||
failed:
|
failed:
|
||||||
CTR5(KTR_CXGBE, "%s: FAILED, atid %d, toep %p, l2te %p, wr %p",
|
CTR3(KTR_CXGBE, "%s: not offloading (%d), rc %d", __func__, reason, rc);
|
||||||
__func__, atid, toep, e, wr);
|
|
||||||
|
|
||||||
if (e)
|
|
||||||
t4_l2t_release(e);
|
|
||||||
if (wr)
|
if (wr)
|
||||||
free_wrqe(wr);
|
free_wrqe(wr);
|
||||||
if (atid >= 0)
|
|
||||||
free_atid(sc, atid);
|
if (toep) {
|
||||||
if (toep)
|
if (toep->tid >= 0)
|
||||||
|
free_atid(sc, toep->tid);
|
||||||
|
if (toep->l2te)
|
||||||
|
t4_l2t_release(toep->l2te);
|
||||||
|
if (toep->ce)
|
||||||
|
release_lip(td, toep->ce);
|
||||||
free_toepcb(toep);
|
free_toepcb(toep);
|
||||||
|
}
|
||||||
|
|
||||||
return (rc);
|
return (rc);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user