Set inp_flowid's for TOE connections.

KTLS uses the flowid to distribute software encryption tasks among its
pool of worker threads.  Without this change, all software KTLS
requests for TOE sockets ended up on the first worker thread.

Note that the flowid for TOE sockets created via connect() is not a
hash of the 4-tuple, but is instead the id of the TOE pcb (tid).  The
flowid of TOE sockets created from TOE listen sockets do use the
4-tuple RSS hash as the flowid since the firmware provides the hash in
the message containing the original SYN.

Reviewed by:	np (earlier version)
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D24348
This commit is contained in:
John Baldwin 2020-04-15 19:28:51 +00:00
parent f3b6d8ad2e
commit 708652acc4
3 changed files with 8 additions and 2 deletions

View File

@ -101,6 +101,8 @@ do_act_establish(struct sge_iq *iq, const struct rss_header *rss,
make_established(toep, be32toh(cpl->snd_isn) - 1,
be32toh(cpl->rcv_isn) - 1, cpl->tcp_opt);
inp->inp_flowtype = M_HASHTYPE_OPAQUE;
inp->inp_flowid = tid;
if (ulp_mode(toep) == ULP_MODE_TLS)
tls_establish(toep);

View File

@ -946,9 +946,7 @@ t4_offload_socket(struct toedev *tod, void *arg, struct socket *so)
{
struct adapter *sc = tod->tod_softc;
struct synq_entry *synqe = arg;
#ifdef INVARIANTS
struct inpcb *inp = sotoinpcb(so);
#endif
struct toepcb *toep = synqe->toep;
NET_EPOCH_ASSERT(); /* prevents bad race with accept() */
@ -962,6 +960,9 @@ t4_offload_socket(struct toedev *tod, void *arg, struct socket *so)
toep->flags |= TPF_CPL_PENDING;
update_tid(sc, synqe->tid, toep);
synqe->flags |= TPF_SYNQE_EXPANDED;
inp->inp_flowtype = (inp->inp_vflag & INP_IPV6) ?
M_HASHTYPE_RSS_TCP_IPV6 : M_HASHTYPE_RSS_TCP_IPV4;
inp->inp_flowid = synqe->rss_hash;
}
static void
@ -1299,6 +1300,8 @@ do_pass_accept_req(struct sge_iq *iq, const struct rss_header *rss,
NET_EPOCH_EXIT(et);
REJECT_PASS_ACCEPT_REQ(true);
}
MPASS(rss->hash_type == RSS_HASH_TCP);
synqe->rss_hash = be32toh(rss->hash_val);
atomic_store_int(&synqe->ok_to_respond, 0);
init_conn_params(vi, &settings, &inc, so, &cpl->tcpopt, e->idx,

View File

@ -242,6 +242,7 @@ struct synq_entry {
uint32_t iss;
uint32_t irs;
uint32_t ts;
uint32_t rss_hash;
__be16 tcp_opt; /* from cpl_pass_establish */
struct toepcb *toep;