Author: glebius
Date: Mon Feb 24 21:07:30 2020
New Revision: 358301
URL: https://svnweb.freebsd.org/changeset/base/358301

Log:
  Although most of the NIC drivers are epoch ready, due to peer pressure
  switch over to opt-in instead of opt-out for epoch.
  
  Instead of IFF_NEEDSEPOCH, provide IFF_KNOWSEPOCH. If driver marks
  itself with IFF_KNOWSEPOCH, then ether_input() would not enter epoch
  when processing its packets.
  
  Now this will create recursive entrance in epoch in >90% network
  drivers, but will guarantee safeness of the transition.
  
  Mark several tested drivers as IFF_KNOWSEPOCH.
  
  Reviewed by:          hselasky, jeff, bz, gallatin
  Differential Revision:        https://reviews.freebsd.org/D23674

Modified:
  head/sys/dev/beri/virtio/network/if_vtbe.c
  head/sys/dev/dpaa/if_dtsec.c
  head/sys/dev/hyperv/netvsc/if_hn.c
  head/sys/dev/if_ndis/if_ndis.c
  head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
  head/sys/dev/ntb/if_ntb/if_ntb.c
  head/sys/dev/sbni/if_sbni.c
  head/sys/dev/virtio/network/if_vtnet.c
  head/sys/mips/nlm/dev/net/xlpge.c
  head/sys/net/if.c
  head/sys/net/if.h
  head/sys/net/if_ethersubr.c
  head/sys/net/iflib.c

Modified: head/sys/dev/beri/virtio/network/if_vtbe.c
==============================================================================
--- head/sys/dev/beri/virtio/network/if_vtbe.c  Mon Feb 24 19:50:28 2020        
(r358300)
+++ head/sys/dev/beri/virtio/network/if_vtbe.c  Mon Feb 24 21:07:30 2020        
(r358301)
@@ -613,7 +613,7 @@ vtbe_attach(device_t dev)
        ifp->if_softc = sc;
        if_initname(ifp, device_get_name(dev), device_get_unit(dev));
        ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX |
-                        IFF_MULTICAST | IFF_PROMISC | IFF_NEEDSEPOCH);
+                        IFF_MULTICAST | IFF_PROMISC);
        ifp->if_capabilities = IFCAP_VLAN_MTU;
        ifp->if_capenable = ifp->if_capabilities;
        ifp->if_start = vtbe_txstart;

Modified: head/sys/dev/dpaa/if_dtsec.c
==============================================================================
--- head/sys/dev/dpaa/if_dtsec.c        Mon Feb 24 19:50:28 2020        
(r358300)
+++ head/sys/dev/dpaa/if_dtsec.c        Mon Feb 24 21:07:30 2020        
(r358301)
@@ -688,7 +688,7 @@ dtsec_attach(device_t dev)
 
        ifp->if_softc = sc;
        ifp->if_mtu = ETHERMTU; /* TODO: Configure */
-       ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_NEEDSEPOCH;
+       ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST;
        ifp->if_init = dtsec_if_init;
        ifp->if_start = dtsec_if_start;
        ifp->if_ioctl = dtsec_if_ioctl;

Modified: head/sys/dev/hyperv/netvsc/if_hn.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/if_hn.c  Mon Feb 24 19:50:28 2020        
(r358300)
+++ head/sys/dev/hyperv/netvsc/if_hn.c  Mon Feb 24 21:07:30 2020        
(r358301)
@@ -2362,8 +2362,7 @@ hn_attach(device_t dev)
         */
 
        ifp->if_baudrate = IF_Gbps(10);
-       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
-           IFF_NEEDSEPOCH;
+       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
        ifp->if_ioctl = hn_ioctl;
        ifp->if_init = hn_init;
 #ifdef HN_IFSTART_SUPPORT

Modified: head/sys/dev/if_ndis/if_ndis.c
==============================================================================
--- head/sys/dev/if_ndis/if_ndis.c      Mon Feb 24 19:50:28 2020        
(r358300)
+++ head/sys/dev/if_ndis/if_ndis.c      Mon Feb 24 21:07:30 2020        
(r358301)
@@ -967,8 +967,7 @@ ndis_ifattach(struct ndis_softc *sc)
 
        if_initname(ifp, device_get_name(sc->ndis_dev),
            device_get_unit(sc->ndis_dev));
-       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
-           IFF_NEEDSEPOCH;
+       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
        ifp->if_ioctl = ndis_ifioctl;
        ifp->if_start = ndis_ifstart;
        ifp->if_init = ndis_init;

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==============================================================================
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c    Mon Feb 24 19:50:28 2020        
(r358300)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c    Mon Feb 24 21:07:30 2020        
(r358301)
@@ -4275,7 +4275,8 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
        if_initname(ifp, "mce", device_get_unit(mdev->pdev->dev.bsddev));
        ifp->if_mtu = ETHERMTU;
        ifp->if_init = mlx5e_open;
-       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
+           IFF_KNOWSEPOCH;
        ifp->if_ioctl = mlx5e_ioctl;
        ifp->if_transmit = mlx5e_xmit;
        ifp->if_qflush = if_qflush;

Modified: head/sys/dev/ntb/if_ntb/if_ntb.c
==============================================================================
--- head/sys/dev/ntb/if_ntb/if_ntb.c    Mon Feb 24 19:50:28 2020        
(r358300)
+++ head/sys/dev/ntb/if_ntb/if_ntb.c    Mon Feb 24 21:07:30 2020        
(r358301)
@@ -172,8 +172,7 @@ ntb_net_attach(device_t dev)
 
        if_setinitfn(ifp, ntb_net_init);
        if_setsoftc(ifp, sc);
-       if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
-           IFF_NEEDSEPOCH);
+       if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
        if_setioctlfn(ifp, ntb_ioctl);
        if_settransmitfn(ifp, ntb_transmit);
        if_setqflushfn(ifp, ntb_qflush);

Modified: head/sys/dev/sbni/if_sbni.c
==============================================================================
--- head/sys/dev/sbni/if_sbni.c Mon Feb 24 19:50:28 2020        (r358300)
+++ head/sys/dev/sbni/if_sbni.c Mon Feb 24 21:07:30 2020        (r358301)
@@ -243,8 +243,7 @@ sbni_attach(struct sbni_softc *sc, int unit, struct sb
        ifp->if_baudrate =
                (csr0 & 0x01 ? 500000 : 2000000) / (1 << flags.rate);
 
-       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
-           IFF_NEEDSEPOCH;
+       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 
        mtx_init(&sc->lock, ifp->if_xname, MTX_NETWORK_LOCK, MTX_DEF);
        callout_init_mtx(&sc->wch, &sc->lock, 0);

Modified: head/sys/dev/virtio/network/if_vtnet.c
==============================================================================
--- head/sys/dev/virtio/network/if_vtnet.c      Mon Feb 24 19:50:28 2020        
(r358300)
+++ head/sys/dev/virtio/network/if_vtnet.c      Mon Feb 24 21:07:30 2020        
(r358301)
@@ -950,7 +950,8 @@ vtnet_setup_interface(struct vtnet_softc *sc)
        if_initname(ifp, device_get_name(dev), device_get_unit(dev));
        ifp->if_baudrate = IF_Gbps(10); /* Approx. */
        ifp->if_softc = sc;
-       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
+           IFF_KNOWSEPOCH;
        ifp->if_init = vtnet_init;
        ifp->if_ioctl = vtnet_ioctl;
        ifp->if_get_counter = vtnet_get_counter;

Modified: head/sys/mips/nlm/dev/net/xlpge.c
==============================================================================
--- head/sys/mips/nlm/dev/net/xlpge.c   Mon Feb 24 19:50:28 2020        
(r358300)
+++ head/sys/mips/nlm/dev/net/xlpge.c   Mon Feb 24 21:07:30 2020        
(r358301)
@@ -1052,8 +1052,7 @@ nlm_xlpge_ifinit(struct nlm_xlpge_softc *sc)
        }
        ifp->if_softc = sc;
        if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
-           IFF_NEEDSEPOCH;
+       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
        sc->if_flags = ifp->if_flags;
        /*ifp->if_capabilities = IFCAP_TXCSUM | IFCAP_VLAN_HWTAGGING;*/
        ifp->if_capabilities = 0;

Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c   Mon Feb 24 19:50:28 2020        (r358300)
+++ head/sys/net/if.c   Mon Feb 24 21:07:30 2020        (r358301)
@@ -551,8 +551,6 @@ if_alloc_domain(u_char type, int numa_domain)
 #ifdef VIMAGE
        ifp->if_vnet = curvnet;
 #endif
-       /* XXX */
-       ifp->if_flags |= IFF_NEEDSEPOCH;
        if (if_com_alloc[type] != NULL) {
                ifp->if_l2com = if_com_alloc[type](type, ifp);
                if (ifp->if_l2com == NULL) {
@@ -4167,8 +4165,8 @@ if_setdrvflags(if_t ifp, int flags)
 int
 if_setflags(if_t ifp, int flags)
 {
-       /* XXX Temporary */
-       ((struct ifnet *)ifp)->if_flags = flags | IFF_NEEDSEPOCH;
+
+       ifp->if_flags = flags;
        return (0);
 }
 

Modified: head/sys/net/if.h
==============================================================================
--- head/sys/net/if.h   Mon Feb 24 19:50:28 2020        (r358300)
+++ head/sys/net/if.h   Mon Feb 24 21:07:30 2020        (r358301)
@@ -144,7 +144,7 @@ struct if_data {
 #define        IFF_DEBUG       0x4             /* (n) turn on debugging */
 #define        IFF_LOOPBACK    0x8             /* (i) is a loopback net */
 #define        IFF_POINTOPOINT 0x10            /* (i) is a point-to-point link 
*/
-#define        IFF_NEEDSEPOCH  0x20            /* (i) calls if_input w/o epoch 
*/
+#define        IFF_KNOWSEPOCH  0x20            /* (i) calls if_input in net 
epoch */
 #define        IFF_DRV_RUNNING 0x40            /* (d) resources allocated */
 #define        IFF_NOARP       0x80            /* (n) no address resolution 
protocol */
 #define        IFF_PROMISC     0x100           /* (n) receive all packets */
@@ -178,7 +178,7 @@ struct if_data {
 #define        IFF_CANTCHANGE \
        (IFF_BROADCAST|IFF_POINTOPOINT|IFF_DRV_RUNNING|IFF_DRV_OACTIVE|\
            IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_PROMISC|\
-           IFF_DYING|IFF_CANTCONFIG)
+           IFF_DYING|IFF_CANTCONFIG|IFF_KNOWSEPOCH)
 
 /*
  * Values for if_link_state.

Modified: head/sys/net/if_ethersubr.c
==============================================================================
--- head/sys/net/if_ethersubr.c Mon Feb 24 19:50:28 2020        (r358300)
+++ head/sys/net/if_ethersubr.c Mon Feb 24 21:07:30 2020        (r358301)
@@ -802,14 +802,17 @@ ether_input(struct ifnet *ifp, struct mbuf *m)
 {
        struct epoch_tracker et;
        struct mbuf *mn;
+       bool needs_epoch;
 
+       needs_epoch = !(ifp->if_flags & IFF_KNOWSEPOCH);
+
        /*
         * The drivers are allowed to pass in a chain of packets linked with
         * m_nextpkt. We split them up into separate packets here and pass
         * them up. This allows the drivers to amortize the receive lock.
         */
        CURVNET_SET_QUIET(ifp->if_vnet);
-       if (__predict_false(ifp->if_flags & IFF_NEEDSEPOCH))
+       if (__predict_false(needs_epoch))
                NET_EPOCH_ENTER(et);
        while (m) {
                mn = m->m_nextpkt;
@@ -825,7 +828,7 @@ ether_input(struct ifnet *ifp, struct mbuf *m)
                netisr_dispatch(NETISR_ETHER, m);
                m = mn;
        }
-       if (__predict_false(ifp->if_flags & IFF_NEEDSEPOCH))
+       if (__predict_false(needs_epoch))
                NET_EPOCH_EXIT(et);
        CURVNET_RESTORE();
 }

Modified: head/sys/net/iflib.c
==============================================================================
--- head/sys/net/iflib.c        Mon Feb 24 19:50:28 2020        (r358300)
+++ head/sys/net/iflib.c        Mon Feb 24 21:07:30 2020        (r358301)
@@ -5400,7 +5400,8 @@ iflib_register(if_ctx_t ctx)
        if_settransmitfn(ifp, iflib_if_transmit);
 #endif
        if_setqflushfn(ifp, iflib_if_qflush);
-       if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
+       if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
+           IFF_KNOWSEPOCH);
 
        ctx->ifc_vlan_attach_event =
                EVENTHANDLER_REGISTER(vlan_config, iflib_vlan_register, ctx,
_______________________________________________
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