Author: glebius
Date: Wed Oct  9 19:04:40 2013
New Revision: 256218
URL: http://svnweb.freebsd.org/changeset/base/256218

Log:
    There are some high performance NICs that count statistics in hardware,
  and there are ifnets, that do that via counter(9). Provide a flag that
  would skip cache line trashing '+=' operation in ether_input().
  
  Sponsored by: Netflix
  Sponsored by: Nginx, Inc.
  Reviewed by:  melifaro, adrian
  Approved by:  re (marius)

Modified:
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/ixgbe/ixgbe.c
  head/sys/net/if.h
  head/sys/net/if_ethersubr.c
  head/sys/net/if_lagg.c

Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c        Wed Oct  9 19:02:59 2013        
(r256217)
+++ head/sys/dev/cxgbe/t4_main.c        Wed Oct  9 19:04:40 2013        
(r256218)
@@ -950,7 +950,7 @@ cxgbe_probe(device_t dev)
 
 #define T4_CAP (IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | \
     IFCAP_VLAN_HWCSUM | IFCAP_TSO | IFCAP_JUMBO_MTU | IFCAP_LRO | \
-    IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE | IFCAP_HWCSUM_IPV6)
+    IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE | IFCAP_HWCSUM_IPV6 | IFCAP_HWSTATS)
 #define T4_CAP_ENABLE (T4_CAP)
 
 static int

Modified: head/sys/dev/ixgbe/ixgbe.c
==============================================================================
--- head/sys/dev/ixgbe/ixgbe.c  Wed Oct  9 19:02:59 2013        (r256217)
+++ head/sys/dev/ixgbe/ixgbe.c  Wed Oct  9 19:04:40 2013        (r256218)
@@ -2662,7 +2662,8 @@ ixgbe_setup_interface(device_t dev, stru
        ifp->if_capabilities |= IFCAP_LRO;
        ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING
                             |  IFCAP_VLAN_HWTSO
-                            |  IFCAP_VLAN_MTU;
+                            |  IFCAP_VLAN_MTU
+                            |  IFCAP_HWSTATS;
        ifp->if_capenable = ifp->if_capabilities;
 
        /*

Modified: head/sys/net/if.h
==============================================================================
--- head/sys/net/if.h   Wed Oct  9 19:02:59 2013        (r256217)
+++ head/sys/net/if.h   Wed Oct  9 19:04:40 2013        (r256218)
@@ -231,6 +231,7 @@ struct if_data {
 #define        IFCAP_NETMAP            0x100000 /* netmap mode 
supported/enabled */
 #define        IFCAP_RXCSUM_IPV6       0x200000  /* can offload checksum on 
IPv6 RX */
 #define        IFCAP_TXCSUM_IPV6       0x400000  /* can offload checksum on 
IPv6 TX */
+#define        IFCAP_HWSTATS           0x800000 /* manages counters internally 
*/
 
 #define IFCAP_HWCSUM_IPV6      (IFCAP_RXCSUM_IPV6 | IFCAP_TXCSUM_IPV6)
 

Modified: head/sys/net/if_ethersubr.c
==============================================================================
--- head/sys/net/if_ethersubr.c Wed Oct  9 19:02:59 2013        (r256217)
+++ head/sys/net/if_ethersubr.c Wed Oct  9 19:04:40 2013        (r256218)
@@ -528,7 +528,8 @@ ether_input_internal(struct ifnet *ifp, 
                m->m_flags &= ~M_HASFCS;
        }
 
-       ifp->if_ibytes += m->m_pkthdr.len;
+       if (!(ifp->if_capenable & IFCAP_HWSTATS))
+               ifp->if_ibytes += m->m_pkthdr.len;
 
        /* Allow monitor mode to claim this frame, after stats are updated. */
        if (ifp->if_flags & IFF_MONITOR) {

Modified: head/sys/net/if_lagg.c
==============================================================================
--- head/sys/net/if_lagg.c      Wed Oct  9 19:02:59 2013        (r256217)
+++ head/sys/net/if_lagg.c      Wed Oct  9 19:04:40 2013        (r256218)
@@ -347,6 +347,7 @@ lagg_clone_create(struct if_clone *ifc, 
        ifp->if_init = lagg_init;
        ifp->if_ioctl = lagg_ioctl;
        ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
+       ifp->if_capenable = ifp->if_capabilities = IFCAP_HWSTATS;
 
        /*
         * Attach as an ordinary ethernet device, children will be attached
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to