summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2013-10-09 19:04:40 +0000
committerglebius <glebius@FreeBSD.org>2013-10-09 19:04:40 +0000
commit75528d8e36fb23734af42c83fe710155dc3e2d5c (patch)
treea73da61112c51368ee56913bcb5771167291b7ca /sys/net
parent57b95400601bfa18b78d342b43a877efa06e81d1 (diff)
downloadFreeBSD-src-75528d8e36fb23734af42c83fe710155dc3e2d5c.zip
FreeBSD-src-75528d8e36fb23734af42c83fe710155dc3e2d5c.tar.gz
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)
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.h1
-rw-r--r--sys/net/if_ethersubr.c3
-rw-r--r--sys/net/if_lagg.c1
3 files changed, 4 insertions, 1 deletions
diff --git a/sys/net/if.h b/sys/net/if.h
index ab98ec0..80a7112 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -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)
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 638b364..d5c5521 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -528,7 +528,8 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m)
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) {
diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c
index 27bab87..258c2f9 100644
--- a/sys/net/if_lagg.c
+++ b/sys/net/if_lagg.c
@@ -347,6 +347,7 @@ lagg_clone_create(struct if_clone *ifc, int unit, caddr_t params)
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
OpenPOWER on IntegriCloud