Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/xen make the csum blank/undefer counters per interface



details:   https://anonhg.NetBSD.org/src/rev/74706b371ecc
branches:  trunk
changeset: 1009731:74706b371ecc
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri May 01 19:53:17 2020 +0000

description:
make the csum blank/undefer counters per interface

diffstat:

 sys/arch/xen/include/xennet_checksum.h |   5 +++--
 sys/arch/xen/xen/if_xennet_xenbus.c    |  19 ++++++++++++++-----
 sys/arch/xen/xen/xennet_checksum.c     |  21 +++++++--------------
 sys/arch/xen/xen/xennetback_xenbus.c   |  26 +++++++++++++++++++++-----
 4 files changed, 45 insertions(+), 26 deletions(-)

diffs (214 lines):

diff -r fc9eb8fd4a2d -r 74706b371ecc sys/arch/xen/include/xennet_checksum.h
--- a/sys/arch/xen/include/xennet_checksum.h    Fri May 01 17:58:48 2020 +0000
+++ b/sys/arch/xen/include/xennet_checksum.h    Fri May 01 19:53:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xennet_checksum.h,v 1.4 2020/03/22 11:20:59 jdolecek Exp $     */
+/*     $NetBSD: xennet_checksum.h,v 1.5 2020/05/01 19:53:17 jdolecek Exp $     */
 
 /*-
  * Copyright (c)2006 YAMAMOTO Takashi,
@@ -32,6 +32,7 @@
 struct ifnet;
 struct mbuf;
 
-int xennet_checksum_fill(struct ifnet *, struct mbuf *);
+int xennet_checksum_fill(struct ifnet *, struct mbuf *,
+       struct evcnt *, struct evcnt *);
 
 #endif /* !_XEN_XENNET_CHECKSUM_H_ */
diff -r fc9eb8fd4a2d -r 74706b371ecc sys/arch/xen/xen/if_xennet_xenbus.c
--- a/sys/arch/xen/xen/if_xennet_xenbus.c       Fri May 01 17:58:48 2020 +0000
+++ b/sys/arch/xen/xen/if_xennet_xenbus.c       Fri May 01 19:53:17 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: if_xennet_xenbus.c,v 1.120 2020/04/30 11:19:39 jdolecek Exp $      */
+/*      $NetBSD: if_xennet_xenbus.c,v 1.121 2020/05/01 19:53:17 jdolecek Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -81,7 +81,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.120 2020/04/30 11:19:39 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.121 2020/05/01 19:53:17 jdolecek Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -204,6 +204,8 @@
        struct evcnt sc_cnt_tx_drop;
        struct evcnt sc_cnt_tx_frag;
        struct evcnt sc_cnt_rx_frag;
+       struct evcnt sc_cnt_rx_cksum_blank;
+       struct evcnt sc_cnt_rx_cksum_undefer;
 };
 
 static pool_cache_t if_xennetrxbuf_cache;
@@ -433,6 +435,10 @@
            NULL, device_xname(sc->sc_dev), "Tx queue full");
        evcnt_attach_dynamic(&sc->sc_cnt_rx_frag, EVCNT_TYPE_MISC,
            NULL, device_xname(sc->sc_dev), "Rx multi-segment packet");
+       evcnt_attach_dynamic(&sc->sc_cnt_rx_cksum_blank, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx csum blank");
+       evcnt_attach_dynamic(&sc->sc_cnt_rx_cksum_undefer, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx csum undeferred");
 
        if (!pmf_device_register(self, xennet_xenbus_suspend,
            xennet_xenbus_resume))
@@ -493,6 +499,8 @@
        evcnt_detach(&sc->sc_cnt_tx_drop);
        evcnt_detach(&sc->sc_cnt_tx_queue_full);
        evcnt_detach(&sc->sc_cnt_rx_frag);
+       evcnt_detach(&sc->sc_cnt_rx_cksum_blank);
+       evcnt_detach(&sc->sc_cnt_rx_cksum_undefer);
 
        /* Unhook the entropy source. */
        rnd_detach_source(&sc->sc_rnd_source);
@@ -1034,9 +1042,10 @@
                        rxflags = m0_rxflags;
                }
 
-               if (rxflags & NETRXF_csum_blank)
-                       xennet_checksum_fill(ifp, m);
-               else if (rxflags & NETRXF_data_validated)
+               if (rxflags & NETRXF_csum_blank) {
+                       xennet_checksum_fill(ifp, m, &sc->sc_cnt_rx_cksum_blank,
+                           &sc->sc_cnt_rx_cksum_undefer);
+               } else if (rxflags & NETRXF_data_validated)
                        m->m_pkthdr.csum_flags = XN_M_CSUM_SUPPORTED;
 
                /* We'are done with req */
diff -r fc9eb8fd4a2d -r 74706b371ecc sys/arch/xen/xen/xennet_checksum.c
--- a/sys/arch/xen/xen/xennet_checksum.c        Fri May 01 17:58:48 2020 +0000
+++ b/sys/arch/xen/xen/xennet_checksum.c        Fri May 01 19:53:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xennet_checksum.c,v 1.11 2020/04/26 12:38:21 jdolecek Exp $    */
+/*     $NetBSD: xennet_checksum.c,v 1.12 2020/05/01 19:53:17 jdolecek Exp $    */
 
 /*-
  * Copyright (c)2006 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xennet_checksum.c,v 1.11 2020/04/26 12:38:21 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennet_checksum.c,v 1.12 2020/05/01 19:53:17 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -52,14 +52,6 @@
 
 #include <xen/xennet_checksum.h>
 
-static struct evcnt xn_cksum_defer = EVCNT_INITIALIZER(EVCNT_TYPE_MISC,
-    NULL, "xennet", "csum blank");
-static struct evcnt xn_cksum_undefer = EVCNT_INITIALIZER(EVCNT_TYPE_MISC,
-    NULL, "xennet", "csum undeferred");
-
-EVCNT_ATTACH_STATIC(xn_cksum_defer);
-EVCNT_ATTACH_STATIC(xn_cksum_undefer);
-
 #ifdef XENNET_DEBUG
 /* ratecheck(9) for checksum validation failures */
 static const struct timeval xn_cksum_errintvl = { 600, 0 };  /* 10 min, each */
@@ -79,7 +71,8 @@
  * for hw offload to do it
  */
 int
-xennet_checksum_fill(struct ifnet *ifp, struct mbuf *m)
+xennet_checksum_fill(struct ifnet *ifp, struct mbuf *m,
+    struct evcnt *cksum_blank, struct evcnt *cksum_undefer)
 {
        const struct ether_header *eh;
        struct ip *iph = NULL;
@@ -225,13 +218,13 @@
 
        if (m->m_pkthdr.csum_flags != 0) {
                if (sw_csum)
-                       xn_cksum_undefer.ev_count++;
-               xn_cksum_defer.ev_count++;
+                       cksum_undefer->ev_count++;
+               cksum_blank->ev_count++;
 #ifdef M_CSUM_BLANK
                m->m_pkthdr.csum_flags |= M_CSUM_BLANK;
 #endif
        } else {
-               xn_cksum_undefer.ev_count++;
+               cksum_undefer->ev_count++;
        }
 
     out:
diff -r fc9eb8fd4a2d -r 74706b371ecc sys/arch/xen/xen/xennetback_xenbus.c
--- a/sys/arch/xen/xen/xennetback_xenbus.c      Fri May 01 17:58:48 2020 +0000
+++ b/sys/arch/xen/xen/xennetback_xenbus.c      Fri May 01 19:53:17 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: xennetback_xenbus.c,v 1.99 2020/04/30 11:23:44 jdolecek Exp $      */
+/*      $NetBSD: xennetback_xenbus.c,v 1.100 2020/05/01 19:53:17 jdolecek Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.99 2020/04/30 11:23:44 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.100 2020/05/01 19:53:17 jdolecek Exp $");
 
 #include "opt_xen.h"
 
@@ -60,6 +60,8 @@
 
 #include <uvm/uvm.h>
 
+/* #define notyet 1 */
+
 /*
  * Backend network device driver for Xen.
  */
@@ -124,6 +126,10 @@
        /* arrays used in xennetback_ifstart(), used for both Rx and Tx */
        gnttab_copy_t           xni_gop_copy[NB_XMIT_PAGES_BATCH];
        struct xnetback_xstate  xni_xstate[NB_XMIT_PAGES_BATCH];
+
+       /* event counters */
+       struct evcnt xni_cnt_rx_cksum_blank;
+       struct evcnt xni_cnt_rx_cksum_undefer;
 };
 #define xni_if    xni_ec.ec_if
 #define xni_bpf   xni_if.if_bpf
@@ -249,6 +255,11 @@
                }
        }
 
+       evcnt_attach_dynamic(&xneti->xni_cnt_rx_cksum_blank, EVCNT_TYPE_MISC,
+           NULL, ifp->if_xname, "Rx csum blank");
+       evcnt_attach_dynamic(&xneti->xni_cnt_rx_cksum_undefer, EVCNT_TYPE_MISC,
+           NULL, ifp->if_xname, "Rx csum undeferred");
+
        /* create pseudo-interface */
        aprint_verbose_ifnet(ifp, "Ethernet address %s\n",
            ether_sprintf(xneti->xni_enaddr));
@@ -372,6 +383,9 @@
        ether_ifdetach(&xneti->xni_if);
        if_detach(&xneti->xni_if);
 
+       evcnt_detach(&xneti->xni_cnt_rx_cksum_blank);
+       evcnt_detach(&xneti->xni_cnt_rx_cksum_undefer);
+
        if (xneti->xni_txring.sring) {
                op.host_addr = xneti->xni_tx_ring_va;
                op.handle = xneti->xni_tx_ring_handle;
@@ -782,9 +796,11 @@
                        bus_dmamap_unload(xneti->xni_xbusd->xbusd_dmat,
                            xst->xs_dmamap);
 
-                       if (xst->xs_tx.flags & NETTXF_csum_blank)
-                               xennet_checksum_fill(ifp, xst->xs_m);
-                       else if (xst->xs_tx.flags & NETTXF_data_validated) {
+                       if (xst->xs_tx.flags & NETTXF_csum_blank) {
+                               xennet_checksum_fill(ifp, xst->xs_m,
+                                   &xneti->xni_cnt_rx_cksum_blank,
+                                   &xneti->xni_cnt_rx_cksum_undefer);
+                       } else if (xst->xs_tx.flags & NETTXF_data_validated) {
                                xst->xs_m->m_pkthdr.csum_flags =
                                    XN_M_CSUM_SUPPORTED;
                        }



Home | Main Index | Thread Index | Old Index