The branch stable/12 has been updated by kp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=91282dac0d2559712bdc0f3181085673e8d9eba9

commit 91282dac0d2559712bdc0f3181085673e8d9eba9
Author:     Luiz Otavio O Souza <[email protected]>
AuthorDate: 2021-08-21 09:41:03 +0000
Commit:     Kristof Provost <[email protected]>
CommitDate: 2021-09-01 07:38:02 +0000

    if_vlan: add the ALTQ support to if_vlan.
    
    Inspired by the iflib implementation, allow ALTQ to be used with if_vlan
    interfaces.
    
    Reviewed by:    donner
    Obtained from:  pfsense
    MFC after:      1 week
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D31647
    
    (cherry picked from commit 2e5ff01d0a1fabc757252f9c28ad5cddc98a652d)
---
 sys/net/if_vlan.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index a055c978c32f..ae1e05e8bc93 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -291,6 +291,10 @@ static     int vlan_setflag(struct ifnet *ifp, int flag, 
int status,
 static int vlan_setflags(struct ifnet *ifp, int status);
 static int vlan_setmulti(struct ifnet *ifp);
 static int vlan_transmit(struct ifnet *ifp, struct mbuf *m);
+#ifdef ALTQ
+static void vlan_altq_start(struct ifnet *ifp);
+static int vlan_altq_transmit(struct ifnet *ifp, struct mbuf *m);
+#endif
 static int vlan_output(struct ifnet *ifp, struct mbuf *m,
     const struct sockaddr *dst, struct route *ro);
 static void vlan_unconfig(struct ifnet *ifp);
@@ -1058,7 +1062,15 @@ vlan_clone_create(struct if_clone *ifc, char *name, 
size_t len, caddr_t params)
        ifp->if_dunit = unit;
 
        ifp->if_init = vlan_init;
+#ifdef ALTQ
+       ifp->if_start = vlan_altq_start;
+       ifp->if_transmit = vlan_altq_transmit;
+       IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
+       ifp->if_snd.ifq_drv_maxlen = 0;
+       IFQ_SET_READY(&ifp->if_snd);
+#else
        ifp->if_transmit = vlan_transmit;
+#endif
        ifp->if_qflush = vlan_qflush;
        ifp->if_ioctl = vlan_ioctl;
 #ifdef RATELIMIT
@@ -1102,6 +1114,10 @@ vlan_clone_destroy(struct if_clone *ifc, struct ifnet 
*ifp)
        struct ifvlan *ifv = ifp->if_softc;
        int unit = ifp->if_dunit;
 
+
+#ifdef ALTQ
+       IFQ_PURGE(&ifp->if_snd);
+#endif
        ether_ifdetach(ifp);    /* first, remove it from system-wide lists */
        vlan_unconfig(ifp);     /* now it can be unconfigured and freed */
        /*
@@ -1200,6 +1216,37 @@ vlan_output(struct ifnet *ifp, struct mbuf *m, const 
struct sockaddr *dst,
        return p->if_output(ifp, m, dst, ro);
 }
 
+#ifdef ALTQ
+static void
+vlan_altq_start(if_t ifp)
+{
+       struct ifaltq *ifq = &ifp->if_snd;
+       struct mbuf *m;
+
+       IFQ_LOCK(ifq);
+       IFQ_DEQUEUE_NOLOCK(ifq, m);
+       while (m != NULL) {
+               vlan_transmit(ifp, m);
+               IFQ_DEQUEUE_NOLOCK(ifq, m);
+       }
+       IFQ_UNLOCK(ifq);
+}
+
+static int
+vlan_altq_transmit(if_t ifp, struct mbuf *m)
+{
+       int err;
+
+       if (ALTQ_IS_ENABLED(&ifp->if_snd)) {
+               IFQ_ENQUEUE(&ifp->if_snd, m, err);
+               if (err == 0)
+                       vlan_altq_start(ifp);
+       } else
+               err = vlan_transmit(ifp, m);
+
+       return (err);
+}
+#endif /* ALTQ */
 
 /*
  * The ifp->if_qflush entry point for vlan(4) is a no-op.
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to