Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178171240
D62253.1796179600.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
15 KB
Referenced Files
None
Subscribers
None
D62253.1796179600.diff
View Options
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -51,6 +51,9 @@
# xargs -n1 | sort | uniq -d;
# done
+# 2026XXXX: netisr_internal.h removed
+OLD_FILES+=usr/include/net/netisr_internal.h
+
# 20261120: uefisign(8) -> efisign(8) collateral damage
OLD_FILES+=usr/share/examples/uefisign/uefikeys
OLD_DIRS+=usr/share/examples/uefisign
diff --git a/sys/net/netisr.c b/sys/net/netisr.c
--- a/sys/net/netisr.c
+++ b/sys/net/netisr.c
@@ -88,14 +88,80 @@
#include <ddb/ddb.h>
#endif
-#define _WANT_NETISR_INTERNAL /* Enable definitions from netisr_internal.h */
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_private.h>
#include <net/netisr.h>
-#include <net/netisr_internal.h>
#include <net/vnet.h>
+/*
+ * Each protocol is described by a struct netisr_proto, which holds all
+ * global per-protocol information. This data structure is set up by
+ * netisr_register(), and derived from the public struct netisr_handler.
+ */
+struct netisr_proto {
+ const char *np_name; /* Character string protocol name. */
+ netisr_handler_t *np_handler; /* Protocol handler. */
+ netisr_m2flow_t *np_m2flow; /* Query flow for untagged packet. */
+ netisr_m2cpuid_t *np_m2cpuid; /* Query CPU to process packet on. */
+ netisr_drainedcpu_t *np_drainedcpu; /* Callback when drained a queue. */
+ u_int np_qlimit; /* Maximum per-CPU queue depth. */
+ u_int np_policy; /* Work placement policy. */
+ u_int np_dispatch; /* Work dispatch policy. */
+};
+
+/*
+ * Workstreams hold a queue of ordered work across each protocol, and are
+ * described by netisr_workstream. Each workstream is associated with a
+ * worker thread, which in turn is pinned to a CPU. Work associated with a
+ * workstream can be processd in other threads during direct dispatch;
+ * concurrent processing is prevented by the NWS_RUNNING flag, which
+ * indicates that a thread is already processing the work queue. It is
+ * important to prevent a directly dispatched packet from "skipping ahead" of
+ * work already in the workstream queue.
+ */
+#define NETISR_MAXPROT 16 /* Compile-time limit. */
+struct netisr_workstream {
+ struct intr_event *nws_intr_event; /* Handler for stream. */
+ void *nws_swi_cookie; /* swi(9) cookie for stream. */
+ struct mtx nws_mtx; /* Synchronize work. */
+ u_int nws_cpu; /* CPU pinning. */
+ u_int nws_flags; /* Wakeup flags. */
+ u_int nws_pendingbits; /* Scheduled protocols. */
+
+ /*
+ * Protocol-specific work for each workstream is described by struct
+ * netisr_work. Each work descriptor consists of an mbuf queue and
+ * statistics.
+ */
+ struct netisr_work {
+ /*
+ * Packet queue, linked by m_nextpkt.
+ */
+ struct mbuf *nw_head;
+ struct mbuf *nw_tail;
+ u_int nw_len;
+ u_int nw_qlimit;
+ u_int nw_watermark;
+
+ /*
+ * Statistics -- written unlocked, but mostly from curcpu.
+ */
+ uint64_t nw_dispatched; /* Number of direct dispatches. */
+ uint64_t nw_hybrid_dispatched; /* "" hybrid dispatches. */
+ uint64_t nw_qdrops; /* "" drops. */
+ uint64_t nw_queued; /* "" enqueues. */
+ uint64_t nw_handled; /* "" handled in worker. */
+ } nws_work[NETISR_MAXPROT];
+} __aligned(CACHE_LINE_SIZE);
+
+/*
+ * Per-workstream flags.
+ */
+#define NWS_RUNNING 0x00000001 /* Currently running in a thread. */
+#define NWS_DISPATCHING 0x00000002 /* Currently being direct-dispatched. */
+#define NWS_SCHEDULED 0x00000004 /* Signal issued. */
+
/*-
* Synchronize use and modification of the registered netisr data structures;
* acquire a read lock while modifying the set of registered protocols to
@@ -209,7 +275,7 @@
/*
* The netisr_proto array describes all registered protocols, indexed by
- * protocol number. See netisr_internal.h for more details.
+ * protocol number.
*/
static struct netisr_proto netisr_proto[NETISR_MAXPROT];
@@ -231,7 +297,7 @@
#endif
/*
- * Per-CPU workstream data. See netisr_internal.h for more details.
+ * Per-CPU workstream data.
*/
DPCPU_DEFINE(struct netisr_workstream, nws);
diff --git a/sys/net/netisr_internal.h b/sys/net/netisr_internal.h
deleted file mode 100644
--- a/sys/net/netisr_internal.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2007-2009 Robert N. M. Watson
- * Copyright (c) 2010-2011 Juniper Networks, Inc.
- * All rights reserved.
- *
- * This software was developed by Robert N. M. Watson under contract
- * to Juniper Networks, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _NET_NETISR_INTERNAL_H_
-#define _NET_NETISR_INTERNAL_H_
-
-#ifndef _WANT_NETISR_INTERNAL
-#error "no user-serviceable parts inside"
-#endif
-
-/*
- * These definitions are private to the netisr implementation, but provided
- * here for use by post-mortem crashdump analysis tools. They should not be
- * used in any other context as they can and will change. Public definitions
- * may be found in netisr.h.
- */
-
-#ifndef _KERNEL
-typedef void *netisr_handler_t;
-typedef void *netisr_m2flow_t;
-typedef void *netisr_m2cpuid_t;
-typedef void *netisr_drainedcpu_t;
-#endif
-
-/*
- * Each protocol is described by a struct netisr_proto, which holds all
- * global per-protocol information. This data structure is set up by
- * netisr_register(), and derived from the public struct netisr_handler.
- */
-struct netisr_proto {
- const char *np_name; /* Character string protocol name. */
- netisr_handler_t *np_handler; /* Protocol handler. */
- netisr_m2flow_t *np_m2flow; /* Query flow for untagged packet. */
- netisr_m2cpuid_t *np_m2cpuid; /* Query CPU to process packet on. */
- netisr_drainedcpu_t *np_drainedcpu; /* Callback when drained a queue. */
- u_int np_qlimit; /* Maximum per-CPU queue depth. */
- u_int np_policy; /* Work placement policy. */
- u_int np_dispatch; /* Work dispatch policy. */
-};
-
-#define NETISR_MAXPROT 16 /* Compile-time limit. */
-
-/*
- * Protocol-specific work for each workstream is described by struct
- * netisr_work. Each work descriptor consists of an mbuf queue and
- * statistics.
- */
-struct netisr_work {
- /*
- * Packet queue, linked by m_nextpkt.
- */
- struct mbuf *nw_head;
- struct mbuf *nw_tail;
- u_int nw_len;
- u_int nw_qlimit;
- u_int nw_watermark;
-
- /*
- * Statistics -- written unlocked, but mostly from curcpu.
- */
- u_int64_t nw_dispatched; /* Number of direct dispatches. */
- u_int64_t nw_hybrid_dispatched; /* "" hybrid dispatches. */
- u_int64_t nw_qdrops; /* "" drops. */
- u_int64_t nw_queued; /* "" enqueues. */
- u_int64_t nw_handled; /* "" handled in worker. */
-};
-
-/*
- * Workstreams hold a queue of ordered work across each protocol, and are
- * described by netisr_workstream. Each workstream is associated with a
- * worker thread, which in turn is pinned to a CPU. Work associated with a
- * workstream can be processd in other threads during direct dispatch;
- * concurrent processing is prevented by the NWS_RUNNING flag, which
- * indicates that a thread is already processing the work queue. It is
- * important to prevent a directly dispatched packet from "skipping ahead" of
- * work already in the workstream queue.
- */
-struct netisr_workstream {
- struct intr_event *nws_intr_event; /* Handler for stream. */
- void *nws_swi_cookie; /* swi(9) cookie for stream. */
- struct mtx nws_mtx; /* Synchronize work. */
- u_int nws_cpu; /* CPU pinning. */
- u_int nws_flags; /* Wakeup flags. */
- u_int nws_pendingbits; /* Scheduled protocols. */
-
- /*
- * Each protocol has per-workstream data.
- */
- struct netisr_work nws_work[NETISR_MAXPROT];
-} __aligned(CACHE_LINE_SIZE);
-
-/*
- * Per-workstream flags.
- */
-#define NWS_RUNNING 0x00000001 /* Currently running in a thread. */
-#define NWS_DISPATCHING 0x00000002 /* Currently being direct-dispatched. */
-#define NWS_SCHEDULED 0x00000004 /* Signal issued. */
-
-#endif /* !_NET_NETISR_INTERNAL_H_ */
diff --git a/usr.bin/netstat/netisr.c b/usr.bin/netstat/netisr.c
--- a/usr.bin/netstat/netisr.c
+++ b/usr.bin/netstat/netisr.c
@@ -36,9 +36,7 @@
#include <sys/_lock.h>
#include <sys/_mutex.h>
-#define _WANT_NETISR_INTERNAL
#include <net/netisr.h>
-#include <net/netisr_internal.h>
#include <stdint.h>
#include <stdio.h>
@@ -71,10 +69,6 @@
static struct sysctl_netisr_work *work_array;
static u_int work_array_len;
-static u_int *nws_array;
-
-static u_int maxprot;
-
static void
netisr_dispatch_policy_to_string(u_int policy, char *buf,
size_t buflen)
@@ -101,24 +95,6 @@
snprintf(buf, buflen, "%s", str);
}
-/*
- * Load a nul-terminated string from KVM up to 'limit', guarantee that the
- * string in local memory is nul-terminated.
- */
-static void
-netisr_load_kvm_string(uintptr_t addr, char *dest, u_int limit)
-{
- u_int i;
-
- for (i = 0; i < limit; i++) {
- if (kread(addr + i, &dest[i], sizeof(dest[i])) != 0)
- xo_errx(EX_OSERR, "%s: kread()", __func__);
- if (dest[i] == '\0')
- break;
- }
- dest[limit - 1] = '\0';
-}
-
static const char *
netisr_proto2name(u_int proto)
{
@@ -143,23 +119,6 @@
return (0);
}
-static void
-netisr_load_kvm_config(void)
-{
- u_int tmp;
-
- kread(nl[N_NETISR_BINDTHREADS].n_value, &bindthreads, sizeof(u_int));
- kread(nl[N_NETISR_MAXTHREADS].n_value, &maxthreads, sizeof(u_int));
- kread(nl[N_NWS_COUNT].n_value, &numthreads, sizeof(u_int));
- kread(nl[N_NETISR_DEFAULTQLIMIT].n_value, &defaultqlimit,
- sizeof(u_int));
- kread(nl[N_NETISR_MAXQLIMIT].n_value, &maxqlimit, sizeof(u_int));
- kread(nl[N_NETISR_DISPATCH_POLICY].n_value, &tmp, sizeof(u_int));
-
- netisr_dispatch_policy_to_string(tmp, dispatch_policy,
- sizeof(dispatch_policy));
-}
-
static void
netisr_load_sysctl_uint(const char *name, u_int *p)
{
@@ -198,65 +157,6 @@
sizeof(dispatch_policy));
}
-static void
-netisr_load_kvm_proto(void)
-{
- struct netisr_proto *np_array, *npp;
- u_int i, protocount;
- struct sysctl_netisr_proto *snpp;
- size_t len;
-
- /*
- * Kernel compile-time and user compile-time definitions of
- * NETISR_MAXPROT must match, as we use that to size work arrays.
- */
- kread(nl[N_NETISR_MAXPROT].n_value, &maxprot, sizeof(u_int));
- if (maxprot != NETISR_MAXPROT)
- xo_errx(EX_DATAERR, "%s: NETISR_MAXPROT mismatch", __func__);
- len = maxprot * sizeof(*np_array);
- np_array = malloc(len);
- if (np_array == NULL)
- xo_err(EX_OSERR, "%s: malloc", __func__);
- if (kread(nl[N_NETISR_PROTO].n_value, np_array, len) != 0)
- xo_errx(EX_DATAERR, "%s: kread(_netisr_proto)", __func__);
-
- /*
- * Size and allocate memory to hold only live protocols.
- */
- protocount = 0;
- for (i = 0; i < maxprot; i++) {
- if (np_array[i].np_name == NULL)
- continue;
- protocount++;
- }
- proto_array = calloc(protocount, sizeof(*proto_array));
- if (proto_array == NULL)
- xo_err(EX_OSERR, "malloc");
- protocount = 0;
- for (i = 0; i < maxprot; i++) {
- npp = &np_array[i];
- if (npp->np_name == NULL)
- continue;
- snpp = &proto_array[protocount];
- snpp->snp_version = sizeof(*snpp);
- netisr_load_kvm_string((uintptr_t)npp->np_name,
- snpp->snp_name, sizeof(snpp->snp_name));
- snpp->snp_proto = i;
- snpp->snp_qlimit = npp->np_qlimit;
- snpp->snp_policy = npp->np_policy;
- snpp->snp_dispatch = npp->np_dispatch;
- if (npp->np_m2flow != NULL)
- snpp->snp_flags |= NETISR_SNP_FLAGS_M2FLOW;
- if (npp->np_m2cpuid != NULL)
- snpp->snp_flags |= NETISR_SNP_FLAGS_M2CPUID;
- if (npp->np_drainedcpu != NULL)
- snpp->snp_flags |= NETISR_SNP_FLAGS_DRAINEDCPU;
- protocount++;
- }
- proto_array_len = protocount;
- free(np_array);
-}
-
static void
netisr_load_sysctl_proto(void)
{
@@ -280,68 +180,6 @@
xo_errx(EX_DATAERR, "net.isr.proto: invalid version");
}
-static void
-netisr_load_kvm_workstream(void)
-{
- struct netisr_workstream nws;
- struct sysctl_netisr_workstream *snwsp;
- struct sysctl_netisr_work *snwp;
- struct netisr_work *nwp;
- u_int counter, cpuid, proto, wsid;
- size_t len;
-
- len = numthreads * sizeof(*nws_array);
- nws_array = malloc(len);
- if (nws_array == NULL)
- xo_err(EX_OSERR, "malloc");
- if (kread(nl[N_NWS_ARRAY].n_value, nws_array, len) != 0)
- xo_errx(EX_OSERR, "%s: kread(_nws_array)", __func__);
- workstream_array = calloc(numthreads, sizeof(*workstream_array));
- if (workstream_array == NULL)
- xo_err(EX_OSERR, "calloc");
- workstream_array_len = numthreads;
- work_array = calloc(numthreads * proto_array_len, sizeof(*work_array));
- if (work_array == NULL)
- xo_err(EX_OSERR, "calloc");
- counter = 0;
- for (wsid = 0; wsid < numthreads; wsid++) {
- cpuid = nws_array[wsid];
- kset_dpcpu(cpuid);
- if (kread(nl[N_NWS].n_value, &nws, sizeof(nws)) != 0)
- xo_errx(EX_OSERR, "%s: kread(nw)", __func__);
- snwsp = &workstream_array[wsid];
- snwsp->snws_version = sizeof(*snwsp);
- snwsp->snws_wsid = cpuid;
- snwsp->snws_cpu = cpuid;
- if (nws.nws_intr_event != NULL)
- snwsp->snws_flags |= NETISR_SNWS_FLAGS_INTR;
-
- /*
- * Extract the CPU's per-protocol work information.
- */
- xo_emit("counting to maxprot: {:maxprot/%u}\n", maxprot);
- for (proto = 0; proto < maxprot; proto++) {
- if (!netisr_protoispresent(proto))
- continue;
- nwp = &nws.nws_work[proto];
- snwp = &work_array[counter];
- snwp->snw_version = sizeof(*snwp);
- snwp->snw_wsid = cpuid;
- snwp->snw_proto = proto;
- snwp->snw_len = nwp->nw_len;
- snwp->snw_watermark = nwp->nw_watermark;
- snwp->snw_dispatched = nwp->nw_dispatched;
- snwp->snw_hybrid_dispatched =
- nwp->nw_hybrid_dispatched;
- snwp->snw_qdrops = nwp->nw_qdrops;
- snwp->snw_queued = nwp->nw_queued;
- snwp->snw_handled = nwp->nw_handled;
- counter++;
- }
- }
- work_array_len = counter;
-}
-
static void
netisr_load_sysctl_workstream(void)
{
@@ -447,16 +285,13 @@
struct sysctl_netisr_proto *snpp;
u_int i;
- if (live) {
- netisr_load_sysctl_config();
- netisr_load_sysctl_proto();
- netisr_load_sysctl_workstream();
- netisr_load_sysctl_work();
- } else {
- netisr_load_kvm_config();
- netisr_load_kvm_proto();
- netisr_load_kvm_workstream(); /* Also does work. */
- }
+ if (!live)
+ return;
+
+ netisr_load_sysctl_config();
+ netisr_load_sysctl_proto();
+ netisr_load_sysctl_workstream();
+ netisr_load_sysctl_work();
xo_open_container("netisr");
diff --git a/usr.bin/netstat/nlist_symbols b/usr.bin/netstat/nlist_symbols
--- a/usr.bin/netstat/nlist_symbols
+++ b/usr.bin/netstat/nlist_symbols
@@ -18,13 +18,6 @@
all mif6table
all mrt6stat
all mrtstat
-all netisr_bindthreads
-all netisr_defaultqlimit
-all netisr_dispatch_policy
-all netisr_maxprot
-all netisr_maxqlimit
-all netisr_maxthreads
-all netisr_proto
all ngsocklist
all nws
all nws_array
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 2, 2:46 AM (23 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42136168
Default Alt Text
D62253.1796179600.diff (15 KB)
Attached To
Mode
D62253: netstat: drop -Q support when running on a vmcore
Attached
Detach File
Event Timeline