diff options
author | jhb <jhb@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f> | 2020-10-29 23:28:39 +0000 |
---|---|---|
committer | jhb <jhb@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f> | 2020-10-29 23:28:39 +0000 |
commit | c837fbcb487ffa4903338a2099ebd6f000fcb3e7 (patch) | |
tree | 245737d152751426c6a0d37fd9400f63d49f4331 | |
parent | e5e7e48f68c383cb1d60c2af2fcd1ace7a161c81 (diff) | |
download | freebsd-c837fbcb487ffa4903338a2099ebd6f000fcb3e7.tar.gz freebsd-c837fbcb487ffa4903338a2099ebd6f000fcb3e7.tar.bz2 |
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
git-svn-id: http://svn.freebsd.org/base/head@367151 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
-rw-r--r-- | sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_mbuf.c | 10 | ||||
-rw-r--r-- | sys/kern/uipc_ktls.c | 6 | ||||
-rw-r--r-- | sys/net/if_lagg.c | 4 | ||||
-rw-r--r-- | sys/net/if_vlan.c | 4 | ||||
-rw-r--r-- | sys/netinet/in_pcb.c | 17 | ||||
-rw-r--r-- | sys/netinet/tcp_ratelimit.c | 24 | ||||
-rw-r--r-- | sys/sys/mbuf.h | 3 |
8 files changed, 32 insertions, 38 deletions
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c index 8f1242826c9..b768aac55ef 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c @@ -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; diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c index 2c9b4430948..84e06842442 100644 --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -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) { diff --git a/sys/kern/uipc_ktls.c b/sys/kern/uipc_ktls.c index c048f708ecf..2776d6fcd19 100644 --- a/sys/kern/uipc_ktls.c +++ b/sys/kern/uipc_ktls.c @@ -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, ¶ms, mstp); + error = m_snd_tag_alloc(ifp, ¶ms, mstp); out: if_rele(ifp); return (error); diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index dee4a5be6cc..87019dd4c32 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -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); diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 920c65323ae..9358724844c 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -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); diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index a8255a04ae6..03cd09fb448 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -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, ¶ms, st); - + error = m_snd_tag_alloc(ifp, ¶ms, 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); } diff --git a/sys/netinet/tcp_ratelimit.c b/sys/netinet/tcp_ratelimit.c index e7c4aaa5bd1..97f066be69e 100644 --- a/sys/netinet/tcp_ratelimit.c +++ b/sys/netinet/tcp_ratelimit.c @@ -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, ¶ms, tag); + error = m_snd_tag_alloc(ifp, ¶ms, 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, ¶ms, &tag); + err = m_snd_tag_alloc(ifp, ¶ms, &tag); if (err) { /* Failed to setup a tag? */ if (error) diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 6b5a6141dd2..e7d958da203 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -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 *); |