Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net add drop count which means the sum of struct if_perc...
details: https://anonhg.NetBSD.org/src/rev/0540ab398e84
branches: trunk
changeset: 814479:0540ab398e84
user: knakahara <knakahara%NetBSD.org@localhost>
date: Wed Mar 23 07:05:28 2016 +0000
description:
add drop count which means the sum of struct if_percpuq's per-CPU queues.
ok by ozaki-r@n.o
diffstat:
sys/net/if.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 103 insertions(+), 2 deletions(-)
diffs (140 lines):
diff -r b905bbe257de -r 0540ab398e84 sys/net/if.c
--- a/sys/net/if.c Wed Mar 23 06:59:59 2016 +0000
+++ b/sys/net/if.c Wed Mar 23 07:05:28 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.326 2016/03/07 01:41:55 ozaki-r Exp $ */
+/* $NetBSD: if.c,v 1.327 2016/03/23 07:05:28 knakahara Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.326 2016/03/07 01:41:55 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.327 2016/03/23 07:05:28 knakahara Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -210,6 +210,11 @@
static struct mbuf *if_percpuq_dequeue(struct if_percpuq *);
+static void if_percpuq_drops(void *, void *, struct cpu_info *);
+static int sysctl_percpuq_drops_handler(SYSCTLFN_PROTO);
+static void sysctl_percpuq_setup(struct sysctllog **, const char *,
+ struct if_percpuq *);
+
#if defined(INET) || defined(INET6)
static void sysctl_net_pktq_setup(struct sysctllog **, int);
#endif
@@ -718,6 +723,8 @@
ipq->ipq_ifqs = percpu_alloc(sizeof(struct ifqueue));
percpu_foreach(ipq->ipq_ifqs, &if_percpuq_init_ifq, NULL);
+ sysctl_percpuq_setup(&ifp->if_sysctl_log, ifp->if_xname, ipq);
+
return ipq;
}
@@ -782,6 +789,100 @@
splx(s);
}
+static void
+if_percpuq_drops(void *p, void *arg, struct cpu_info *ci __unused)
+{
+ struct ifqueue *const ifq = p;
+ int *sum = arg;
+
+ *sum += ifq->ifq_drops;
+}
+
+static int
+sysctl_percpuq_drops_handler(SYSCTLFN_ARGS)
+{
+ struct sysctlnode node;
+ struct if_percpuq *ipq;
+ int sum = 0;
+ int error;
+
+ node = *rnode;
+ ipq = node.sysctl_data;
+
+ percpu_foreach(ipq->ipq_ifqs, if_percpuq_drops, &sum);
+
+ node.sysctl_data = ∑
+ error = sysctl_lookup(SYSCTLFN_CALL(&node));
+ if (error != 0 || newp == NULL)
+ return error;
+
+ return 0;
+}
+
+static void
+sysctl_percpuq_setup(struct sysctllog **clog, const char* ifname,
+ struct if_percpuq *ipq)
+{
+ const struct sysctlnode *cnode, *rnode;
+
+ if (sysctl_createv(clog, 0, NULL, &rnode,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_NODE, "interfaces",
+ SYSCTL_DESCR("Per-interface controls"),
+ NULL, 0, NULL, 0,
+ CTL_NET, CTL_CREATE, CTL_EOL) != 0)
+ goto bad;
+
+ if (sysctl_createv(clog, 0, &rnode, &rnode,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_NODE, ifname,
+ SYSCTL_DESCR("Interface controls"),
+ NULL, 0, NULL, 0,
+ CTL_CREATE, CTL_EOL) != 0)
+ goto bad;
+
+ if (sysctl_createv(clog, 0, &rnode, &rnode,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_NODE, "rcvq",
+ SYSCTL_DESCR("Interface input queue controls"),
+ NULL, 0, NULL, 0,
+ CTL_CREATE, CTL_EOL) != 0)
+ goto bad;
+
+#ifdef NOTYET
+ /* XXX Should show each per-CPU queue length? */
+ if (sysctl_createv(clog, 0, &rnode, &rnode,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_INT, "len",
+ SYSCTL_DESCR("Current input queue length"),
+ sysctl_percpuq_len, 0, NULL, 0,
+ CTL_CREATE, CTL_EOL) != 0)
+ goto bad;
+
+ if (sysctl_createv(clog, 0, &rnode, &cnode,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_INT, "maxlen",
+ SYSCTL_DESCR("Maximum allowed input queue length"),
+ sysctl_percpuq_maxlen_handler, 0, (void *)ipq, 0,
+ CTL_CREATE, CTL_EOL) != 0)
+ goto bad;
+#endif
+
+ if (sysctl_createv(clog, 0, &rnode, &cnode,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_INT, "drops",
+ SYSCTL_DESCR("Total packets dropped due to full input queue"),
+ sysctl_percpuq_drops_handler, 0, (void *)ipq, 0,
+ CTL_CREATE, CTL_EOL) != 0)
+ goto bad;
+
+ return;
+bad:
+ printf("%s: could not attach sysctl nodes\n", ifname);
+ return;
+}
+
+
/*
* The common interface input routine that is called by device drivers,
* which should be used only when the driver's rx handler already runs
Home |
Main Index |
Thread Index |
Old Index