Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Jun 2015 11:56:13 GMT
From:      btw@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r286522 - in soc2015/btw/head/sys: kern net netinet netinet6 sys
Message-ID:  <201506011156.t51BuDML029811@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: btw
Date: Mon Jun  1 11:56:12 2015
New Revision: 286522
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286522

Log:
  Implement the ifring structure, and the corresponding instrumentation
  points in network stack.

Modified:
  soc2015/btw/head/sys/kern/uipc_mbuf.c
  soc2015/btw/head/sys/net/if_ethersubr.c
  soc2015/btw/head/sys/net/if_var.h
  soc2015/btw/head/sys/net/netisr.c
  soc2015/btw/head/sys/netinet/ip_input.c
  soc2015/btw/head/sys/netinet/tcp_input.c
  soc2015/btw/head/sys/netinet/udp_usrreq.c
  soc2015/btw/head/sys/netinet6/ip6_input.c
  soc2015/btw/head/sys/sys/mbuf.h

Modified: soc2015/btw/head/sys/kern/uipc_mbuf.c
==============================================================================
--- soc2015/btw/head/sys/kern/uipc_mbuf.c	Mon Jun  1 10:29:50 2015	(r286521)
+++ soc2015/btw/head/sys/kern/uipc_mbuf.c	Mon Jun  1 11:56:12 2015	(r286522)
@@ -111,11 +111,11 @@
  */
 #if defined(__LP64__)
 CTASSERT(offsetof(struct mbuf, m_dat) == 32);
-CTASSERT(sizeof(struct pkthdr) == 56);
+CTASSERT(sizeof(struct pkthdr) == 64);
 CTASSERT(sizeof(struct m_ext) == 48);
 #else
 CTASSERT(offsetof(struct mbuf, m_dat) == 24);
-CTASSERT(sizeof(struct pkthdr) == 48);
+CTASSERT(sizeof(struct pkthdr) == 52);
 CTASSERT(sizeof(struct m_ext) == 28);
 #endif
 

Modified: soc2015/btw/head/sys/net/if_ethersubr.c
==============================================================================
--- soc2015/btw/head/sys/net/if_ethersubr.c	Mon Jun  1 10:29:50 2015	(r286521)
+++ soc2015/btw/head/sys/net/if_ethersubr.c	Mon Jun  1 11:56:12 2015	(r286522)
@@ -386,6 +386,8 @@
 	struct ether_header *eh;
 	u_short etype;
 
+	IFRSTAT_INC(m, ifrs_ether);
+
 	if ((ifp->if_flags & IFF_UP) == 0) {
 		m_freem(m);
 		return;
@@ -662,6 +664,7 @@
 		 * so assert it is correct here.
 		 */
 		KASSERT(m->m_pkthdr.rcvif == ifp, ("%s: ifnet mismatch", __func__));
+		IFRSTAT_INC(m, ifrs_ifinput);
 		netisr_dispatch(NETISR_ETHER, m);
 		m = mn;
 	}

Modified: soc2015/btw/head/sys/net/if_var.h
==============================================================================
--- soc2015/btw/head/sys/net/if_var.h	Mon Jun  1 10:29:50 2015	(r286521)
+++ soc2015/btw/head/sys/net/if_var.h	Mon Jun  1 11:56:12 2015	(r286522)
@@ -79,6 +79,29 @@
 	struct ifops		ift_ops;
 };
 
+struct ifrstat {
+	uint64_t ifrs_ifinput;
+	uint64_t ifrs_netisr;
+	uint64_t ifrs_ether;
+	uint64_t ifrs_ip;
+	uint64_t ifrs_ip6;
+	uint64_t ifrs_udp;
+	uint64_t ifrs_tcp;
+} __aligned(CACHE_LINE_SIZE);
+
+#define IFRSTAT_ADD(m, name, val)					\
+do {									\
+	if ((m)->m_pkthdr.ifring != NULL)				\
+		(m)->m_pkthdr.ifring->ifr_stats[curcpu].name += (val);	\
+} while (0)
+#define IFRSTAT_SUB(m, name, val)	IFRSTAT_ADD((m), name, -(val))
+#define IFRSTAT_INC(m, name)		IFRSTAT_ADD((m), name, 1)
+#define IFRSTAT_DEC(m, name)		IFRSTAT_SUB((m), name, 1)
+
+struct ifring {
+	struct ifrstat ifr_stats[MAXCPU]; /* Percpu counters */
+};
+
 /*
  * Many network stack modules want to store their software context associated
  * with an interface.  We used to give a pointer for everyone, but that yield
@@ -129,6 +152,8 @@
 	size_t		if_linkmiblen;	/* length of above data */
 	u_int		if_refcount;	/* reference count */
 	u_int		if_fib;		/* interface FIB */
+	struct ifring	*if_rings;	/* pairs of tx and rx rings */
+	int		if_nrings;	/* elements in if_rings */
 
 	uint8_t		if_link_state;	/* current link state */
 	uint32_t	if_mtu;		/* maximum transmission unit */

Modified: soc2015/btw/head/sys/net/netisr.c
==============================================================================
--- soc2015/btw/head/sys/net/netisr.c	Mon Jun  1 10:29:50 2015	(r286521)
+++ soc2015/btw/head/sys/net/netisr.c	Mon Jun  1 11:56:12 2015	(r286522)
@@ -761,6 +761,7 @@
 		local_npw.nw_len--;
 		VNET_ASSERT(m->m_pkthdr.rcvif != NULL,
 		    ("%s:%d rcvif == NULL: m=%p", __func__, __LINE__, m));
+		IFRSTAT_INC(m, ifrs_netisr);
 		CURVNET_SET(m->m_pkthdr.rcvif->if_vnet);
 		netisr_proto[proto].np_handler(m);
 		CURVNET_RESTORE();

Modified: soc2015/btw/head/sys/netinet/ip_input.c
==============================================================================
--- soc2015/btw/head/sys/netinet/ip_input.c	Mon Jun  1 10:29:50 2015	(r286521)
+++ soc2015/btw/head/sys/netinet/ip_input.c	Mon Jun  1 11:56:12 2015	(r286522)
@@ -402,6 +402,7 @@
 	struct in_addr odst;			/* original dst address */
 
 	M_ASSERTPKTHDR(m);
+	IFRSTAT_INC(m, ifrs_ip);
 
 	if (m->m_flags & M_FASTFWD_OURS) {
 		m->m_flags &= ~M_FASTFWD_OURS;

Modified: soc2015/btw/head/sys/netinet/tcp_input.c
==============================================================================
--- soc2015/btw/head/sys/netinet/tcp_input.c	Mon Jun  1 10:29:50 2015	(r286521)
+++ soc2015/btw/head/sys/netinet/tcp_input.c	Mon Jun  1 11:56:12 2015	(r286522)
@@ -629,6 +629,7 @@
 	*mp = NULL;
 	to.to_flags = 0;
 	TCPSTAT_INC(tcps_rcvtotal);
+	IFRSTAT_INC(m, ifrs_tcp);
 
 #ifdef INET6
 	if (isipv6) {

Modified: soc2015/btw/head/sys/netinet/udp_usrreq.c
==============================================================================
--- soc2015/btw/head/sys/netinet/udp_usrreq.c	Mon Jun  1 10:29:50 2015	(r286521)
+++ soc2015/btw/head/sys/netinet/udp_usrreq.c	Mon Jun  1 11:56:12 2015	(r286522)
@@ -395,6 +395,7 @@
 	ifp = m->m_pkthdr.rcvif;
 	*mp = NULL;
 	UDPSTAT_INC(udps_ipackets);
+	IFRSTAT_INC(m, ifrs_udp);
 
 	/*
 	 * Strip IP options, if any; should skip this, make available to

Modified: soc2015/btw/head/sys/netinet6/ip6_input.c
==============================================================================
--- soc2015/btw/head/sys/netinet6/ip6_input.c	Mon Jun  1 10:29:50 2015	(r286521)
+++ soc2015/btw/head/sys/netinet6/ip6_input.c	Mon Jun  1 11:56:12 2015	(r286522)
@@ -416,6 +416,8 @@
 
 #endif /* IPSEC */
 
+	IFRSTAT_INC(m, ifrs_ip6);
+
 	if (m->m_flags & M_FASTFWD_OURS) {
 		/*
 		 * Firewall changed destination to local.

Modified: soc2015/btw/head/sys/sys/mbuf.h
==============================================================================
--- soc2015/btw/head/sys/sys/mbuf.h	Mon Jun  1 10:29:50 2015	(r286521)
+++ soc2015/btw/head/sys/sys/mbuf.h	Mon Jun  1 11:56:12 2015	(r286522)
@@ -105,13 +105,14 @@
 
 /*
  * Record/packet header in first mbuf of chain; valid only if M_PKTHDR is set.
- * Size ILP32: 48
- *	 LP64: 56
+ * Size ILP32: 52
+ *	 LP64: 64
  * Compile-time assertions in uipc_mbuf.c test these values to ensure that
  * they are correct.
  */
 struct pkthdr {
 	struct ifnet	*rcvif;		/* rcv interface */
+	struct ifring	*ifring;	/* rcv ring */
 	SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */
 	int32_t		 len;		/* total packet length */
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201506011156.t51BuDML029811>