Author: sephe
Date: Mon Aug 14 05:30:02 2017
New Revision: 322483
URL: https://svnweb.freebsd.org/changeset/base/322483

Log:
  hyperv/hn: Update VF's ibytes properly under transparent VF mode.
  
  While, I'm here add comment about why updating VF's imcast stat is
  not necessary.
  
  MFC after:    3 days
  Sponsored by: Microsoft
  Differential Revision:        https://reviews.freebsd.org/D11948

Modified:
  head/sys/dev/hyperv/netvsc/if_hn.c

Modified: head/sys/dev/hyperv/netvsc/if_hn.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/if_hn.c  Mon Aug 14 04:48:35 2017        
(r322482)
+++ head/sys/dev/hyperv/netvsc/if_hn.c  Mon Aug 14 05:30:02 2017        
(r322483)
@@ -1266,16 +1266,37 @@ hn_xpnt_vf_input(struct ifnet *vf_ifp, struct mbuf *m)
        rm_runlock(&hn_vfmap_lock, &pt);
 
        if (hn_ifp != NULL) {
-               /*
-                * Fix up rcvif and go through hn(4)'s if_input and 
-                * increase ipackets.
-                */
                for (mn = m; mn != NULL; mn = mn->m_nextpkt) {
-                       /* Allow tapping on the VF. */
+                       /*
+                        * Allow tapping on the VF.
+                        */
                        ETHER_BPF_MTAP(vf_ifp, mn);
+
+                       /*
+                        * Update VF stats.
+                        */
+                       if ((vf_ifp->if_capenable & IFCAP_HWSTATS) == 0) {
+                               if_inc_counter(vf_ifp, IFCOUNTER_IBYTES,
+                                   mn->m_pkthdr.len);
+                       }
+                       /*
+                        * XXX IFCOUNTER_IMCAST
+                        * This stat updating is kinda invasive, since it
+                        * requires two checks on the mbuf: the length check
+                        * and the ethernet header check.  As of this write,
+                        * all multicast packets go directly to hn(4), which
+                        * makes imcast stat updating in the VF a try in vian.
+                        */
+
+                       /*
+                        * Fix up rcvif and increase hn(4)'s ipackets.
+                        */
                        mn->m_pkthdr.rcvif = hn_ifp;
                        if_inc_counter(hn_ifp, IFCOUNTER_IPACKETS, 1);
                }
+               /*
+                * Go through hn(4)'s if_input.
+                */
                hn_ifp->if_input(hn_ifp, m);
        } else {
                /*
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to