Author: jhb
Date: Thu Oct 29 23:28:39 2020
New Revision: 367151
URL: https://svnweb.freebsd.org/changeset/base/367151

Log:
  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

Modified:
  head/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c
  head/sys/kern/kern_mbuf.c
  head/sys/kern/uipc_ktls.c
  head/sys/net/if_lagg.c
  head/sys/net/if_vlan.c
  head/sys/netinet/in_pcb.c
  head/sys/netinet/tcp_ratelimit.c
  head/sys/sys/mbuf.h

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c
==============================================================================
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c  Thu Oct 29 23:15:11 2020        
(r367150)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c  Thu Oct 29 23:28:39 2020        
(r367151)
@@ -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;
 

Modified: head/sys/kern/kern_mbuf.c
==============================================================================
--- head/sys/kern/kern_mbuf.c   Thu Oct 29 23:15:11 2020        (r367150)
+++ head/sys/kern/kern_mbuf.c   Thu Oct 29 23:28:39 2020        (r367151)
@@ -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)
 {

Modified: head/sys/kern/uipc_ktls.c
==============================================================================
--- head/sys/kern/uipc_ktls.c   Thu Oct 29 23:15:11 2020        (r367150)
+++ head/sys/kern/uipc_ktls.c   Thu Oct 29 23:28:39 2020        (r367151)
@@ -834,10 +834,6 @@ ktls_alloc_snd_tag(struct inpcb *inp, struct ktls_sess
        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_sess
                        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);

Modified: head/sys/net/if_lagg.c
==============================================================================
--- head/sys/net/if_lagg.c      Thu Oct 29 23:15:11 2020        (r367150)
+++ head/sys/net/if_lagg.c      Thu Oct 29 23:28:39 2020        (r367151)
@@ -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);

Modified: head/sys/net/if_vlan.c
==============================================================================
--- head/sys/net/if_vlan.c      Thu Oct 29 23:15:11 2020        (r367150)
+++ head/sys/net/if_vlan.c      Thu Oct 29 23:28:39 2020        (r367151)
@@ -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);

Modified: head/sys/netinet/in_pcb.c
==============================================================================
--- head/sys/netinet/in_pcb.c   Thu Oct 29 23:15:11 2020        (r367150)
+++ head/sys/netinet/in_pcb.c   Thu Oct 29 23:28:39 2020        (r367151)
@@ -3330,19 +3330,14 @@ in_pcbattach_txrtlmt(struct inpcb *inp, struct ifnet *
        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);
 }
 

Modified: head/sys/netinet/tcp_ratelimit.c
==============================================================================
--- head/sys/netinet/tcp_ratelimit.c    Thu Oct 29 23:15:11 2020        
(r367150)
+++ head/sys/netinet/tcp_ratelimit.c    Thu Oct 29 23:28:39 2020        
(r367151)
@@ -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
 #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)

Modified: head/sys/sys/mbuf.h
==============================================================================
--- head/sys/sys/mbuf.h Thu Oct 29 23:15:11 2020        (r367150)
+++ head/sys/sys/mbuf.h Thu Oct 29 23:28:39 2020        (r367151)
@@ -754,6 +754,7 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgof
 #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 *);
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to