1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-25 07:49:18 +00:00

Add m_snd_tag_alloc() as a wrapper around if_snd_tag_alloc().

This gives a more uniform API for send tag life cycle management.

Reviewed by:	gallatin, hselasky
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D27000
This commit is contained in:
John Baldwin 2020-10-29 23:28:39 +00:00
parent 0de9332429
commit 36e0a362ac
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=367151
8 changed files with 32 additions and 38 deletions

View File

@ -396,7 +396,7 @@ mlx5e_tls_snd_tag_alloc(struct ifnet *ifp,
goto failure;
}
error = ifp->if_snd_tag_alloc(ifp, &rl_params, &ptag->rl_tag);
error = m_snd_tag_alloc(ifp, &rl_params, &ptag->rl_tag);
if (error)
goto failure;

View File

@ -1525,6 +1525,16 @@ m_freem(struct mbuf *mb)
mb = m_free(mb);
}
int
m_snd_tag_alloc(struct ifnet *ifp, union if_snd_tag_alloc_params *params,
struct m_snd_tag **mstp)
{
if (ifp->if_snd_tag_alloc == NULL)
return (EOPNOTSUPP);
return (ifp->if_snd_tag_alloc(ifp, params, mstp));
}
void
m_snd_tag_init(struct m_snd_tag *mst, struct ifnet *ifp, u_int type)
{

View File

@ -834,10 +834,6 @@ ktls_alloc_snd_tag(struct inpcb *inp, struct ktls_session *tls, bool force,
params.hdr.numa_domain = inp->inp_numa_domain;
INP_RUNLOCK(inp);
if (ifp->if_snd_tag_alloc == NULL) {
error = EOPNOTSUPP;
goto out;
}
if ((ifp->if_capenable & IFCAP_NOMAP) == 0) {
error = EOPNOTSUPP;
goto out;
@ -853,7 +849,7 @@ ktls_alloc_snd_tag(struct inpcb *inp, struct ktls_session *tls, bool force,
goto out;
}
}
error = ifp->if_snd_tag_alloc(ifp, &params, mstp);
error = m_snd_tag_alloc(ifp, &params, mstp);
out:
if_rele(ifp);
return (error);

View File

@ -1808,7 +1808,7 @@ lagg_snd_tag_alloc(struct ifnet *ifp,
LAGG_RUNLOCK();
return (EOPNOTSUPP);
}
if (lp->lp_ifp == NULL || lp->lp_ifp->if_snd_tag_alloc == NULL) {
if (lp->lp_ifp == NULL) {
LAGG_RUNLOCK();
return (EOPNOTSUPP);
}
@ -1822,7 +1822,7 @@ lagg_snd_tag_alloc(struct ifnet *ifp,
return (ENOMEM);
}
error = lp_ifp->if_snd_tag_alloc(lp_ifp, params, &lst->tag);
error = m_snd_tag_alloc(lp_ifp, params, &lst->tag);
if_rele(lp_ifp);
if (error) {
free(lst, M_LAGG);

View File

@ -2047,7 +2047,7 @@ vlan_snd_tag_alloc(struct ifnet *ifp,
parent = PARENT(ifv);
else
parent = NULL;
if (parent == NULL || parent->if_snd_tag_alloc == NULL) {
if (parent == NULL) {
NET_EPOCH_EXIT(et);
return (EOPNOTSUPP);
}
@ -2060,7 +2060,7 @@ vlan_snd_tag_alloc(struct ifnet *ifp,
return (ENOMEM);
}
error = parent->if_snd_tag_alloc(parent, params, &vst->tag);
error = m_snd_tag_alloc(parent, params, &vst->tag);
if_rele(parent);
if (error) {
free(vst, M_VLAN);

View File

@ -3330,19 +3330,14 @@ in_pcbattach_txrtlmt(struct inpcb *inp, struct ifnet *ifp,
if (*st != NULL)
return (EINVAL);
if (ifp->if_snd_tag_alloc == NULL) {
error = EOPNOTSUPP;
} else {
error = ifp->if_snd_tag_alloc(ifp, &params, st);
error = m_snd_tag_alloc(ifp, &params, st);
#ifdef INET
if (error == 0) {
counter_u64_add(rate_limit_set_ok, 1);
counter_u64_add(rate_limit_active, 1);
} else
counter_u64_add(rate_limit_alloc_fail, 1);
if (error == 0) {
counter_u64_add(rate_limit_set_ok, 1);
counter_u64_add(rate_limit_active, 1);
} else if (error != EOPNOTSUPP)
counter_u64_add(rate_limit_alloc_fail, 1);
#endif
}
return (error);
}

View File

@ -464,18 +464,14 @@ rl_attach_txrtlmt(struct ifnet *ifp,
.rate_limit.flags = M_NOWAIT,
};
if (ifp->if_snd_tag_alloc == NULL) {
error = EOPNOTSUPP;
} else {
error = ifp->if_snd_tag_alloc(ifp, &params, tag);
error = m_snd_tag_alloc(ifp, &params, tag);
#ifdef INET
if (error == 0) {
counter_u64_add(rate_limit_set_ok, 1);
counter_u64_add(rate_limit_active, 1);
} else
counter_u64_add(rate_limit_alloc_fail, 1);
if (error == 0) {
counter_u64_add(rate_limit_set_ok, 1);
counter_u64_add(rate_limit_active, 1);
} else if (error != EOPNOTSUPP)
counter_u64_add(rate_limit_alloc_fail, 1);
#endif
}
return (error);
}
@ -1014,13 +1010,7 @@ rt_find_real_interface(struct ifnet *ifp, struct inpcb *inp, int *error)
#else
params.rate_limit.hdr.flowtype = M_HASHTYPE_OPAQUE_HASH;
#endif
tag = NULL;
if (ifp->if_snd_tag_alloc) {
if (error)
*error = ENODEV;
return (NULL);
}
err = ifp->if_snd_tag_alloc(ifp, &params, &tag);
err = m_snd_tag_alloc(ifp, &params, &tag);
if (err) {
/* Failed to setup a tag? */
if (error)

View File

@ -754,6 +754,7 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff)
#define MBUF_EXTPGS_MEM_NAME "mbuf_extpgs"
#ifdef _KERNEL
union if_snd_tag_alloc_params;
#ifdef WITNESS
#define MBUF_CHECKSLEEP(how) do { \
@ -834,6 +835,8 @@ int m_sanity(struct mbuf *, int);
struct mbuf *m_split(struct mbuf *, int, int);
struct mbuf *m_uiotombuf(struct uio *, int, int, int, int);
struct mbuf *m_unshare(struct mbuf *, int);
int m_snd_tag_alloc(struct ifnet *,
union if_snd_tag_alloc_params *, struct m_snd_tag **);
void m_snd_tag_init(struct m_snd_tag *, struct ifnet *, u_int);
void m_snd_tag_destroy(struct m_snd_tag *);