Source-Changes-HG archive

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

[src/trunk]: src/sys/net Remove the conditional __IF_STATS_PERCPU.



details:   https://anonhg.NetBSD.org/src/rev/3c9390696405
branches:  trunk
changeset: 1007339:3c9390696405
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Feb 14 22:04:12 2020 +0000

description:
Remove the conditional __IF_STATS_PERCPU.

diffstat:

 sys/net/if.h       |  33 +--------------------------------
 sys/net/if_stats.c |  44 ++------------------------------------------
 sys/net/if_stats.h |  49 ++++---------------------------------------------
 3 files changed, 7 insertions(+), 119 deletions(-)

diffs (225 lines):

diff -r 98521466752f -r 3c9390696405 sys/net/if.h
--- a/sys/net/if.h      Fri Feb 14 18:17:23 2020 +0000
+++ b/sys/net/if.h      Fri Feb 14 22:04:12 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.h,v 1.281 2020/02/06 23:30:19 thorpej Exp $ */
+/*     $NetBSD: if.h,v 1.282 2020/02/14 22:04:12 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -63,12 +63,6 @@
 #ifndef _NET_IF_H_
 #define _NET_IF_H_
 
-/*
- * Temporary, to allow for a quick disable if problems are discovered
- * during a transition period.
- */
-#define        __IF_STATS_PERCPU
-
 #if !defined(_KERNEL) && !defined(_STANDALONE)
 #include <stdbool.h>
 #endif
@@ -282,7 +276,6 @@
        short           if_timer;       /* ?: time 'til if_slowtimo called */
        unsigned short  if_flags;       /* i: up/down, broadcast, etc. */
        short           if_extflags;    /* :: if_output MP-safe, etc. */
-#ifdef __IF_STATS_PERCPU
        u_char          if_type;        /* :: ethernet, tokenring, etc. */
        u_char          if_addrlen;     /* :: media address length */
        u_char          if_hdrlen;      /* :: media header length */
@@ -297,9 +290,6 @@
 #else
        void            *if_stats;      /* opaque to user-space */
 #endif /* _KERNEL */
-#else /* ! __IF_STATS_PERCPU */
-       struct if_data  if_data;        /* ?: statistics and other data */
-#endif /* __IF_STATS_PERCPU */
        /*
         * Procedure handles.  If you add more of these, don't forget the
         * corresponding NULL stub in if.c.
@@ -426,27 +416,6 @@
 
 #include <net/if_stats.h>
  
-#ifndef __IF_STATS_PERCPU
-#define        if_mtu          if_data.ifi_mtu
-#define        if_type         if_data.ifi_type
-#define        if_addrlen      if_data.ifi_addrlen
-#define        if_hdrlen       if_data.ifi_hdrlen
-#define        if_metric       if_data.ifi_metric
-#define        if_link_state   if_data.ifi_link_state
-#define        if_baudrate     if_data.ifi_baudrate
-#define        if_ipackets     if_data.ifi_ipackets
-#define        if_ierrors      if_data.ifi_ierrors
-#define        if_opackets     if_data.ifi_opackets
-#define        if_oerrors      if_data.ifi_oerrors
-#define        if_collisions   if_data.ifi_collisions
-#define        if_ibytes       if_data.ifi_ibytes
-#define        if_obytes       if_data.ifi_obytes
-#define        if_imcasts      if_data.ifi_imcasts
-#define        if_omcasts      if_data.ifi_omcasts
-#define        if_iqdrops      if_data.ifi_iqdrops
-#define        if_noproto      if_data.ifi_noproto
-#define        if_lastchange   if_data.ifi_lastchange
-#endif /* __IF_STATS_PERCPU */
 #define        if_name(ifp)    ((ifp)->if_xname)
 
 #define        IFF_UP          0x0001          /* interface is up */
diff -r 98521466752f -r 3c9390696405 sys/net/if_stats.c
--- a/sys/net/if_stats.c        Fri Feb 14 18:17:23 2020 +0000
+++ b/sys/net/if_stats.c        Fri Feb 14 22:04:12 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_stats.c,v 1.2 2020/02/07 12:35:33 thorpej Exp $     */
+/*     $NetBSD: if_stats.c,v 1.3 2020/02/14 22:04:12 thorpej Exp $     */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_stats.c,v 1.2 2020/02/07 12:35:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_stats.c,v 1.3 2020/02/14 22:04:12 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/mbuf.h>
@@ -48,11 +48,9 @@
 int
 if_stats_init(ifnet_t * const ifp)
 {
-#ifdef __IF_STATS_PERCPU
        ifp->if_stats = percpu_alloc(IF_STATS_SIZE);
        if (ifp->if_stats == NULL)
                return ENOMEM;
-#endif /* __IF_STATS_PERCPU */
        return 0;
 }
 
@@ -63,17 +61,13 @@
 void
 if_stats_fini(ifnet_t * const ifp)
 {
-#ifdef __IF_STATS_PERCPU
        percpu_t *pc = ifp->if_stats;
        ifp->if_stats = NULL;
        if (pc) {
                percpu_free(pc, IF_STATS_SIZE);
        }
-#endif /* __IF_STATS_PERCPU */
 }
 
-#ifdef __IF_STATS_PERCPU
-
 struct if_stats_to_if_data_ctx {
        struct if_data * const ifi;
        const bool zero_stats;
@@ -127,37 +121,3 @@
        percpu_foreach_xcall(ifp->if_stats, XC_HIGHPRI_IPL(IPL_SOFTNET),
            if_stats_to_if_data_cb, &ctx);
 }
-
-#else /* ! __IF_STATS_PERCPU */
-
-/*
- * if_stats_to_if_data --
- *     Collect the interface statistics and place them into the
- *     legacy if_data structure for reportig to user space.
- *     Optionally zeros the stats after collection.
- */
-void
-if_stats_to_if_data(ifnet_t * const ifp, struct if_data * const ifi,
-                   const bool zero_stats)
-{
-
-       memset(ifi, 0, sizeof(*ifi));
-
-       int s = splnet();
-
-       if (ifi) {
-               memcpy(&ifi->ifi_ipackets, &ifp->if_data.ifi_ipackets,
-                   offsetof(struct if_data, ifi_lastchange) -
-                   offsetof(struct if_data, ifi_ipackets));
-       }
-
-       if (zero_stats) {
-               memset(&ifp->if_data.ifi_ipackets, 0,
-                   offsetof(struct if_data, ifi_lastchange) -
-                   offsetof(struct if_data, ifi_ipackets));
-       }
-
-       splx(s);
-}
-
-#endif /* __IF_STATS_PERCPU */
diff -r 98521466752f -r 3c9390696405 sys/net/if_stats.h
--- a/sys/net/if_stats.h        Fri Feb 14 18:17:23 2020 +0000
+++ b/sys/net/if_stats.h        Fri Feb 14 22:04:12 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_stats.h,v 1.1 2020/01/29 03:16:28 thorpej Exp $     */
+/*     $NetBSD: if_stats.h,v 1.2 2020/02/14 22:04:12 thorpej Exp $     */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,6 @@
 
 #include <net/net_stats.h>
 
-#ifdef __IF_STATS_PERCPU
 /*
  * Interface statistics.  All values are unsigned 64-bit.
  */
@@ -116,50 +115,10 @@
        _NET_STATSUB_REF(nsr, x, v);
 }
 
-#endif /* _KERNEL */
-
-#else /* ! __IF_STATS_PERCPU */
-
-#ifdef _KERNEL
-
-/*
- * Transitional aid to allow drivers to migrate to the new API.  Once
- * all drivers are transitioned, the implementation will be replaced
- * with per-cpu counters.
- */
-
-static inline net_stat_ref_t
-IF_STAT_GETREF(ifnet_t *ifp)
-{
-       return (net_stat_ref_t)ifp;
-}
-
-#define        IF_STAT_PUTREF(ifp)     __nothing
-
-#define        if_statinc(ifp, x)      do { ++(ifp)->x; } while (/*CONSTCOND*/0)
-#define        if_statdec(ifp, x)      do { --(ifp)->x; } while (/*CONSTCOND*/0)
-#define        if_statadd(ifp, x, v)   do { (ifp)->x += (v); } while (/*CONSTCOND*/0)
-#define        if_statsub(ifp, x, v)   do { (ifp)->x -= (v); } while (/*CONSTCOND*/0)
-
-#define        if_statadd2(ifp, x1, v1, x2, v2)                                \
-do {                                                                   \
-       (ifp)->x1 += (v1);                                              \
-       (ifp)->x2 += (v2);                                              \
-} while (/*CONSTCOND*/0)
-
-#define        if_statinc_ref(r, x)    if_statinc((ifnet_t *)(r), x)
-#define        if_statdec_ref(r, x)    if_statdec((ifnet_t *)(r), x)
-#define        if_statadd_ref(r, x, v) if_statadd((ifnet_t *)(r), x, v)
-#define        if_statsub_ref(r, x, v) if_statsub((ifnet_t *)(r), x, v)
+int    if_stats_init(ifnet_t *);
+void   if_stats_fini(ifnet_t *);
+void   if_stats_to_if_data(ifnet_t *, struct if_data *, bool);
 
 #endif /* _KERNEL */
 
-#endif /* __IF_STATS_PERCPU */
-
-#ifdef _KERNEL
-int    if_stats_init(ifnet_t *);
-void   if_stats_fini(ifnet_t *);
-void   if_stats_to_if_data(ifnet_t *, struct if_data *, bool);
-#endif /* _KERNEL */
-
 #endif /* !_NET_IF_STATS_H_ */



Home | Main Index | Thread Index | Old Index