Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/cxgbe/t4_main.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 2,180 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
cxgbe_transmit(struct ifnet *ifp, struct mbuf *m) | cxgbe_transmit(struct ifnet *ifp, struct mbuf *m) | ||||
{ | { | ||||
struct vi_info *vi = ifp->if_softc; | struct vi_info *vi = ifp->if_softc; | ||||
struct port_info *pi = vi->pi; | struct port_info *pi = vi->pi; | ||||
struct adapter *sc; | struct adapter *sc; | ||||
struct sge_txq *txq; | struct sge_txq *txq; | ||||
#ifdef RATELIMIT | |||||
struct cxgbe_snd_tag *cst; | |||||
#endif | |||||
void *items[1]; | void *items[1]; | ||||
int rc; | int rc; | ||||
M_ASSERTPKTHDR(m); | M_ASSERTPKTHDR(m); | ||||
MPASS(m->m_nextpkt == NULL); /* not quite ready for this yet */ | MPASS(m->m_nextpkt == NULL); /* not quite ready for this yet */ | ||||
#if defined(KERN_TLS) || defined(RATELIMIT) | #if defined(KERN_TLS) || defined(RATELIMIT) | ||||
if (m->m_pkthdr.csum_flags & CSUM_SND_TAG) | if (m->m_pkthdr.csum_flags & CSUM_SND_TAG) | ||||
MPASS(m->m_pkthdr.snd_tag->ifp == ifp); | MPASS(m->m_pkthdr.snd_tag->ifp == ifp); | ||||
#endif | #endif | ||||
if (__predict_false(pi->link_cfg.link_ok == false)) { | if (__predict_false(pi->link_cfg.link_ok == false)) { | ||||
m_freem(m); | m_freem(m); | ||||
return (ENETDOWN); | return (ENETDOWN); | ||||
} | } | ||||
rc = parse_pkt(&m, vi->flags & TX_USES_VM_WR); | rc = parse_pkt(&m, vi->flags & TX_USES_VM_WR); | ||||
if (__predict_false(rc != 0)) { | if (__predict_false(rc != 0)) { | ||||
MPASS(m == NULL); /* was freed already */ | MPASS(m == NULL); /* was freed already */ | ||||
atomic_add_int(&pi->tx_parse_error, 1); /* rare, atomic is ok */ | atomic_add_int(&pi->tx_parse_error, 1); /* rare, atomic is ok */ | ||||
return (rc); | return (rc); | ||||
} | } | ||||
#ifdef RATELIMIT | #ifdef RATELIMIT | ||||
if (m->m_pkthdr.csum_flags & CSUM_SND_TAG) { | if (m->m_pkthdr.csum_flags & CSUM_SND_TAG) { | ||||
cst = mst_to_cst(m->m_pkthdr.snd_tag); | if (m->m_pkthdr.snd_tag->type == IF_SND_TAG_TYPE_RATE_LIMIT) | ||||
if (cst->type == IF_SND_TAG_TYPE_RATE_LIMIT) | |||||
return (ethofld_transmit(ifp, m)); | return (ethofld_transmit(ifp, m)); | ||||
} | } | ||||
#endif | #endif | ||||
/* Select a txq. */ | /* Select a txq. */ | ||||
sc = vi->adapter; | sc = vi->adapter; | ||||
txq = &sc->sge.txq[vi->first_txq]; | txq = &sc->sge.txq[vi->first_txq]; | ||||
if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) | if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) | ||||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | cxgbe_get_counter(struct ifnet *ifp, ift_counter c) | ||||
} | } | ||||
default: | default: | ||||
return (if_get_counter_default(ifp, c)); | return (if_get_counter_default(ifp, c)); | ||||
} | } | ||||
} | } | ||||
#if defined(KERN_TLS) || defined(RATELIMIT) | #if defined(KERN_TLS) || defined(RATELIMIT) | ||||
void | |||||
cxgbe_snd_tag_init(struct cxgbe_snd_tag *cst, struct ifnet *ifp, int type) | |||||
{ | |||||
m_snd_tag_init(&cst->com, ifp); | |||||
cst->type = type; | |||||
} | |||||
static int | static int | ||||
cxgbe_snd_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params, | cxgbe_snd_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params, | ||||
struct m_snd_tag **pt) | struct m_snd_tag **pt) | ||||
{ | { | ||||
int error; | int error; | ||||
switch (params->hdr.type) { | switch (params->hdr.type) { | ||||
#ifdef RATELIMIT | #ifdef RATELIMIT | ||||
case IF_SND_TAG_TYPE_RATE_LIMIT: | case IF_SND_TAG_TYPE_RATE_LIMIT: | ||||
error = cxgbe_rate_tag_alloc(ifp, params, pt); | error = cxgbe_rate_tag_alloc(ifp, params, pt); | ||||
break; | break; | ||||
#endif | #endif | ||||
#ifdef KERN_TLS | #ifdef KERN_TLS | ||||
case IF_SND_TAG_TYPE_TLS: | case IF_SND_TAG_TYPE_TLS: | ||||
error = cxgbe_tls_tag_alloc(ifp, params, pt); | error = cxgbe_tls_tag_alloc(ifp, params, pt); | ||||
break; | break; | ||||
#endif | #endif | ||||
default: | default: | ||||
error = EOPNOTSUPP; | error = EOPNOTSUPP; | ||||
} | } | ||||
if (error == 0) | |||||
MPASS(mst_to_cst(*pt)->type == params->hdr.type); | |||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
cxgbe_snd_tag_modify(struct m_snd_tag *mst, | cxgbe_snd_tag_modify(struct m_snd_tag *mst, | ||||
union if_snd_tag_modify_params *params) | union if_snd_tag_modify_params *params) | ||||
{ | { | ||||
struct cxgbe_snd_tag *cst; | |||||
cst = mst_to_cst(mst); | switch (mst->type) { | ||||
switch (cst->type) { | |||||
#ifdef RATELIMIT | #ifdef RATELIMIT | ||||
case IF_SND_TAG_TYPE_RATE_LIMIT: | case IF_SND_TAG_TYPE_RATE_LIMIT: | ||||
return (cxgbe_rate_tag_modify(mst, params)); | return (cxgbe_rate_tag_modify(mst, params)); | ||||
#endif | #endif | ||||
default: | default: | ||||
return (EOPNOTSUPP); | return (EOPNOTSUPP); | ||||
} | } | ||||
} | } | ||||
static int | static int | ||||
cxgbe_snd_tag_query(struct m_snd_tag *mst, | cxgbe_snd_tag_query(struct m_snd_tag *mst, | ||||
union if_snd_tag_query_params *params) | union if_snd_tag_query_params *params) | ||||
{ | { | ||||
struct cxgbe_snd_tag *cst; | |||||
cst = mst_to_cst(mst); | switch (mst->type) { | ||||
switch (cst->type) { | |||||
#ifdef RATELIMIT | #ifdef RATELIMIT | ||||
case IF_SND_TAG_TYPE_RATE_LIMIT: | case IF_SND_TAG_TYPE_RATE_LIMIT: | ||||
return (cxgbe_rate_tag_query(mst, params)); | return (cxgbe_rate_tag_query(mst, params)); | ||||
#endif | #endif | ||||
default: | default: | ||||
return (EOPNOTSUPP); | return (EOPNOTSUPP); | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
cxgbe_snd_tag_free(struct m_snd_tag *mst) | cxgbe_snd_tag_free(struct m_snd_tag *mst) | ||||
{ | { | ||||
struct cxgbe_snd_tag *cst; | |||||
cst = mst_to_cst(mst); | switch (mst->type) { | ||||
switch (cst->type) { | |||||
#ifdef RATELIMIT | #ifdef RATELIMIT | ||||
case IF_SND_TAG_TYPE_RATE_LIMIT: | case IF_SND_TAG_TYPE_RATE_LIMIT: | ||||
cxgbe_rate_tag_free(mst); | cxgbe_rate_tag_free(mst); | ||||
return; | return; | ||||
#endif | #endif | ||||
#ifdef KERN_TLS | #ifdef KERN_TLS | ||||
case IF_SND_TAG_TYPE_TLS: | case IF_SND_TAG_TYPE_TLS: | ||||
cxgbe_tls_tag_free(mst); | cxgbe_tls_tag_free(mst); | ||||
▲ Show 20 Lines • Show All 9,188 Lines • Show Last 20 Lines |