Module Name:    src
Committed By:   knakahara
Date:           Mon Oct 11 05:13:11 UTC 2021

Modified Files:
        src/sys/dev/pci: xmm7360.c
        src/sys/net: if_ethersubr.c if_gif.c if_ipsec.c if_pppoe.c
            if_spppsubr.c pktqueue.c pktqueue.h
        src/sys/rump/librump/rumpnet: Makefile.rumpnet

Log Message:
Make pktq_rps_hash() pluggable for each interface type.  Reviewed by gdt@n.o, 
thorpej@n.o, and riastradh@n.o, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/xmm7360.c
cvs rdiff -u -r1.300 -r1.301 src/sys/net/if_ethersubr.c
cvs rdiff -u -r1.155 -r1.156 src/sys/net/if_gif.c
cvs rdiff -u -r1.30 -r1.31 src/sys/net/if_ipsec.c
cvs rdiff -u -r1.177 -r1.178 src/sys/net/if_pppoe.c
cvs rdiff -u -r1.258 -r1.259 src/sys/net/if_spppsubr.c
cvs rdiff -u -r1.13 -r1.14 src/sys/net/pktqueue.c
cvs rdiff -u -r1.4 -r1.5 src/sys/net/pktqueue.h
cvs rdiff -u -r1.23 -r1.24 src/sys/rump/librump/rumpnet/Makefile.rumpnet

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/xmm7360.c
diff -u src/sys/dev/pci/xmm7360.c:1.11 src/sys/dev/pci/xmm7360.c:1.12
--- src/sys/dev/pci/xmm7360.c:1.11	Mon Oct 11 01:07:36 2021
+++ src/sys/dev/pci/xmm7360.c	Mon Oct 11 05:13:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: xmm7360.c,v 1.11 2021/10/11 01:07:36 thorpej Exp $	*/
+/*	$NetBSD: xmm7360.c,v 1.12 2021/10/11 05:13:10 knakahara Exp $	*/
 
 /*
  * Device driver for Intel XMM7360 LTE modems, eg. Fibocom L850-GL.
@@ -75,7 +75,7 @@ MODULE_DEVICE_TABLE(pci, xmm7360_ids);
 #include "opt_gateway.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xmm7360.c,v 1.11 2021/10/11 01:07:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xmm7360.c,v 1.12 2021/10/11 05:13:10 knakahara Exp $");
 #endif
 
 #include <sys/param.h>
@@ -3110,11 +3110,7 @@ wwan_if_input(struct ifnet *ifp, struct 
 	/* No errors.  Receive the packet. */
 	m_set_rcvif(m, ifp);
 
-#ifdef NET_MPSAFE
-	const u_int h = curcpu()->ci_index;
-#else
-	const uint32_t h = pktq_rps_hash(m);
-#endif
+	const uint32_t h = pktq_rps_hash(&pktq_rps_hash_default, m);
 	if (__predict_false(!pktq_enqueue(pktq, m, h))) {
 		m_freem(m);
 	}

Index: src/sys/net/if_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.300 src/sys/net/if_ethersubr.c:1.301
--- src/sys/net/if_ethersubr.c:1.300	Thu Sep 30 04:29:16 2021
+++ src/sys/net/if_ethersubr.c	Mon Oct 11 05:13:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.300 2021/09/30 04:29:16 yamaguchi Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.301 2021/10/11 05:13:11 knakahara Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.300 2021/09/30 04:29:16 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.301 2021/10/11 05:13:11 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -183,6 +183,8 @@ const uint8_t ethermulticastaddr_slowpro
     { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x02 };
 #define senderr(e) { error = (e); goto bad;}
 
+static pktq_rps_hash_func_t ether_pktq_rps_hash_p;
+
 /* if_lagg(4) support */
 struct mbuf *(*lagg_input_ethernet_p)(struct ifnet *, struct mbuf *);
 
@@ -955,11 +957,7 @@ ether_input(struct ifnet *ifp, struct mb
 	}
 
 	if (__predict_true(pktq)) {
-#ifdef NET_MPSAFE
-		const u_int h = curcpu()->ci_index;
-#else
-		const uint32_t h = pktq_rps_hash(m);
-#endif
+		const uint32_t h = pktq_rps_hash(&ether_pktq_rps_hash_p, m);
 		if (__predict_false(!pktq_enqueue(pktq, m, h))) {
 			m_freem(m);
 		}
@@ -1766,6 +1764,14 @@ ether_sysctl_setup(struct sysctllog **cl
 		       SYSCTL_DESCR("multicast addresses"),
 		       ether_multicast_sysctl, 0, NULL, 0,
 		       CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(clog, 0, &rnode, NULL,
+		       CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+		       CTLTYPE_STRING, "rps_hash",
+		       SYSCTL_DESCR("Interface rps hash function control"),
+		       sysctl_pktq_rps_hash_handler, 0, (void *)&ether_pktq_rps_hash_p,
+		       PKTQ_RPS_HASH_NAME_LEN,
+		       CTL_CREATE, CTL_EOL);
 }
 
 void
@@ -1775,5 +1781,6 @@ etherinit(void)
 #ifdef DIAGNOSTIC
 	mutex_init(&bigpktpps_lock, MUTEX_DEFAULT, IPL_NET);
 #endif
+	ether_pktq_rps_hash_p = pktq_rps_hash_default;
 	ether_sysctl_setup(NULL);
 }

Index: src/sys/net/if_gif.c
diff -u src/sys/net/if_gif.c:1.155 src/sys/net/if_gif.c:1.156
--- src/sys/net/if_gif.c:1.155	Wed Jun 16 00:21:19 2021
+++ src/sys/net/if_gif.c	Mon Oct 11 05:13:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_gif.c,v 1.155 2021/06/16 00:21:19 riastradh Exp $	*/
+/*	$NetBSD: if_gif.c,v 1.156 2021/10/11 05:13:11 knakahara Exp $	*/
 /*	$KAME: if_gif.c,v 1.76 2001/08/20 02:01:02 kjc Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.155 2021/06/16 00:21:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.156 2021/10/11 05:13:11 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -105,6 +105,8 @@ static struct {
 
 struct psref_class *gv_psref_class __read_mostly;
 
+static pktq_rps_hash_func_t gif_pktq_rps_hash_p;
+
 static int	gifattach0(struct gif_softc *);
 static int	gif_output(struct ifnet *, struct mbuf *,
 			   const struct sockaddr *, const struct rtentry *);
@@ -198,6 +200,8 @@ sysctl_gif_pmtu_perif(SYSCTLFN_ARGS)
 static void
 gif_sysctl_setup(void)
 {
+	const struct sysctlnode *node = NULL;
+
 	gif_sysctl = NULL;
 
 #ifdef INET
@@ -258,6 +262,21 @@ gif_sysctl_setup(void)
 		       CTL_NET, PF_INET6, IPPROTO_IPV6,
 		       IPV6CTL_GIF_PMTU, CTL_EOL);
 #endif
+
+	sysctl_createv(&gif_sysctl, 0, NULL, &node,
+		       CTLFLAG_PERMANENT,
+		       CTLTYPE_NODE, "gif",
+		       SYSCTL_DESCR("gif global control"),
+		       NULL, 0, NULL, 0,
+		       CTL_NET, CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(&gif_sysctl, 0, &node, NULL,
+		       CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+		       CTLTYPE_STRING, "rps_hash",
+		       SYSCTL_DESCR("Interface rps hash function control"),
+		       sysctl_pktq_rps_hash_handler, 0, (void *)&gif_pktq_rps_hash_p,
+		       PKTQ_RPS_HASH_NAME_LEN,
+		       CTL_CREATE, CTL_EOL);
 }
 
 static void
@@ -318,6 +337,7 @@ gifinit(void)
 
 	gv_psref_class = psref_class_create("gifvar", IPL_SOFTNET);
 
+	gif_pktq_rps_hash_p = pktq_rps_hash_default;
 	gif_sysctl_setup();
 }
 
@@ -703,11 +723,7 @@ gif_input(struct mbuf *m, int af, struct
 		return;
 	}
 
-#ifdef GIF_MPSAFE
-	const u_int h = curcpu()->ci_index;
-#else
-	const uint32_t h = pktq_rps_hash(m);
-#endif
+	const uint32_t h = pktq_rps_hash(&gif_pktq_rps_hash_p, m);
 	if (__predict_true(pktq_enqueue(pktq, m, h))) {
 		if_statadd2(ifp, if_ibytes, pktlen, if_ipackets, 1);
 	} else {

Index: src/sys/net/if_ipsec.c
diff -u src/sys/net/if_ipsec.c:1.30 src/sys/net/if_ipsec.c:1.31
--- src/sys/net/if_ipsec.c:1.30	Wed Oct 14 18:48:05 2020
+++ src/sys/net/if_ipsec.c	Mon Oct 11 05:13:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ipsec.c,v 1.30 2020/10/14 18:48:05 roy Exp $  */
+/*	$NetBSD: if_ipsec.c,v 1.31 2021/10/11 05:13:11 knakahara Exp $  */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ipsec.c,v 1.30 2020/10/14 18:48:05 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ipsec.c,v 1.31 2021/10/11 05:13:11 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -151,6 +151,8 @@ static int max_ipsec_nesting = MAX_IPSEC
 
 static struct sysctllog *if_ipsec_sysctl;
 
+static pktq_rps_hash_func_t if_ipsec_pktq_rps_hash_p;
+
 #ifdef INET6
 static int
 sysctl_if_ipsec_pmtu_global(SYSCTLFN_ARGS)
@@ -206,6 +208,8 @@ sysctl_if_ipsec_pmtu_perif(SYSCTLFN_ARGS
 static void
 if_ipsec_sysctl_setup(void)
 {
+	const struct sysctlnode *node = NULL;
+
 	if_ipsec_sysctl = NULL;
 
 #ifdef INET6
@@ -241,6 +245,21 @@ if_ipsec_sysctl_setup(void)
 		       CTL_NET, PF_INET6, IPPROTO_IPV6,
 		       IPV6CTL_IPSEC_PMTU, CTL_EOL);
 #endif
+
+	sysctl_createv(&if_ipsec_sysctl, 0, NULL, &node,
+	    CTLFLAG_PERMANENT,
+	    CTLTYPE_NODE, "ipsecif",
+	    SYSCTL_DESCR("ipsecif global control"),
+	    NULL, 0, NULL, 0,
+	    CTL_NET, CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(&if_ipsec_sysctl, 0, &node, NULL,
+	    CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+	    CTLTYPE_STRING, "rps_hash",
+	    SYSCTL_DESCR("Interface rps hash function control"),
+	    sysctl_pktq_rps_hash_handler, 0, (void *)&if_ipsec_pktq_rps_hash_p,
+	    PKTQ_RPS_HASH_NAME_LEN,
+	    CTL_CREATE, CTL_EOL);
 }
 
 static void
@@ -291,6 +310,7 @@ ipsecifattach(int count)
 
 	iv_psref_class = psref_class_create("ipsecvar", IPL_SOFTNET);
 
+	if_ipsec_pktq_rps_hash_p = pktq_rps_hash_default;
 	if_ipsec_sysctl_setup();
 
 	if_clone_attach(&ipsec_cloner);
@@ -615,11 +635,7 @@ if_ipsec_in_enqueue(struct mbuf *m, int 
 		return;
 	}
 
-#if 1
-	const u_int h = curcpu()->ci_index;
-#else
-	const uint32_t h = pktq_rps_hash(m);
-#endif
+	const uint32_t h = pktq_rps_hash(&if_ipsec_pktq_rps_hash_p, m);
 	pktlen = m->m_pkthdr.len;
 	if (__predict_true(pktq_enqueue(pktq, m, h))) {
 		if_statadd2(ifp, if_ibytes, pktlen, if_ipackets, 1);

Index: src/sys/net/if_pppoe.c
diff -u src/sys/net/if_pppoe.c:1.177 src/sys/net/if_pppoe.c:1.178
--- src/sys/net/if_pppoe.c:1.177	Wed Jun 16 00:21:19 2021
+++ src/sys/net/if_pppoe.c	Mon Oct 11 05:13:11 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.177 2021/06/16 00:21:19 riastradh Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.178 2021/10/11 05:13:11 knakahara Exp $ */
 
 /*
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.177 2021/06/16 00:21:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.178 2021/10/11 05:13:11 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "pppoe.h"
@@ -2146,6 +2146,9 @@ static void
 sysctl_net_pppoe_setup(struct sysctllog **clog)
 {
 	const struct sysctlnode *node = NULL;
+	extern pktq_rps_hash_func_t sppp_pktq_rps_hash_p;
+
+	sppp_pktq_rps_hash_p = pktq_rps_hash_default;
 
 	sysctl_createv(clog, 0, NULL, &node,
 	    CTLFLAG_PERMANENT,
@@ -2163,6 +2166,14 @@ sysctl_net_pppoe_setup(struct sysctllog 
 	    SYSCTL_DESCR("Terminate unknown sessions"),
 	    NULL, 0, &pppoe_term_unknown, sizeof(pppoe_term_unknown),
 	    CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(clog, 0, &node, NULL,
+	    CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+	    CTLTYPE_STRING, "rps_hash",
+	    SYSCTL_DESCR("Interface rps hash function control"),
+	    sysctl_pktq_rps_hash_handler, 0, (void *)&sppp_pktq_rps_hash_p,
+	    PKTQ_RPS_HASH_NAME_LEN,
+	    CTL_CREATE, CTL_EOL);
 }
 
 /*

Index: src/sys/net/if_spppsubr.c
diff -u src/sys/net/if_spppsubr.c:1.258 src/sys/net/if_spppsubr.c:1.259
--- src/sys/net/if_spppsubr.c:1.258	Wed Jun  2 00:47:59 2021
+++ src/sys/net/if_spppsubr.c	Mon Oct 11 05:13:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_spppsubr.c,v 1.258 2021/06/02 00:47:59 yamaguchi Exp $	 */
+/*	$NetBSD: if_spppsubr.c,v 1.259 2021/10/11 05:13:11 knakahara Exp $	 */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.258 2021/06/02 00:47:59 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.259 2021/10/11 05:13:11 knakahara Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -304,6 +304,8 @@ static kmutex_t *spppq_lock = NULL;
 static callout_t keepalive_ch;
 static unsigned int sppp_keepalive_cnt = 0;
 
+pktq_rps_hash_func_t sppp_pktq_rps_hash_p;
+
 #define SPPPQ_LOCK()	if (spppq_lock) \
 				mutex_enter(spppq_lock);
 #define SPPPQ_UNLOCK()	if (spppq_lock) \
@@ -779,7 +781,9 @@ sppp_input(struct ifnet *ifp, struct mbu
 
 	/* Check queue. */
 	if (__predict_true(pktq)) {
-		if (__predict_false(!pktq_enqueue(pktq, m, 0))) {
+		uint32_t hash = pktq_rps_hash(&sppp_pktq_rps_hash_p, m);
+
+		if (__predict_false(!pktq_enqueue(pktq, m, hash))) {
 			goto drop;
 		}
 		SPPP_UNLOCK(sp);

Index: src/sys/net/pktqueue.c
diff -u src/sys/net/pktqueue.c:1.13 src/sys/net/pktqueue.c:1.14
--- src/sys/net/pktqueue.c:1.13	Thu Mar 25 08:18:03 2021
+++ src/sys/net/pktqueue.c	Mon Oct 11 05:13:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pktqueue.c,v 1.13 2021/03/25 08:18:03 skrll Exp $	*/
+/*	$NetBSD: pktqueue.c,v 1.14 2021/10/11 05:13:11 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -36,7 +36,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pktqueue.c,v 1.13 2021/03/25 08:18:03 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pktqueue.c,v 1.14 2021/10/11 05:13:11 knakahara Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_net_mpsafe.h"
+#endif
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -51,6 +55,11 @@ __KERNEL_RCSID(0, "$NetBSD: pktqueue.c,v
 #include <sys/xcall.h>
 
 #include <net/pktqueue.h>
+#include <net/rss_config.h>
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <netinet/ip6.h>
 
 struct pktqueue {
 	/*
@@ -214,16 +223,146 @@ pktq_get_count(pktqueue_t *pq, pktq_coun
 }
 
 uint32_t
-pktq_rps_hash(const struct mbuf *m __unused)
+pktq_rps_hash(pktq_rps_hash_func_t *funcp, const struct mbuf *m)
+{
+	pktq_rps_hash_func_t func = atomic_load_relaxed(funcp);
+
+	KASSERT(func != NULL);
+
+	return (*func)(m);
+}
+
+static uint32_t
+pktq_rps_hash_zero(const struct mbuf *m __unused)
 {
+
+	return 0;
+}
+
+static uint32_t
+pktq_rps_hash_curcpu(const struct mbuf *m __unused)
+{
+
+	return cpu_index(curcpu());
+}
+
+static uint32_t
+pktq_rps_hash_toeplitz(const struct mbuf *m)
+{
+	struct ip *ip;
 	/*
-	 * XXX: No distribution yet; the softnet_lock contention
-	 * XXX: must be eliminated first.
+	 * Disable UDP port - IP fragments aren't currently being handled
+	 * and so we end up with a mix of 2-tuple and 4-tuple
+	 * traffic.
 	 */
+	const u_int flag = RSS_TOEPLITZ_USE_TCP_PORT;
+
+	/* glance IP version */
+	if ((m->m_flags & M_PKTHDR) == 0)
+		return 0;
+
+	ip = mtod(m, struct ip *);
+	if (ip->ip_v == IPVERSION) {
+		if (__predict_false(m->m_len < sizeof(struct ip)))
+			return 0;
+		return rss_toeplitz_hash_from_mbuf_ipv4(m, flag);
+	} else if (ip->ip_v == 6) {
+		if (__predict_false(m->m_len < sizeof(struct ip6_hdr)))
+			return 0;
+		return rss_toeplitz_hash_from_mbuf_ipv6(m, flag);
+	}
+
 	return 0;
 }
 
 /*
+ * topelitz without curcpu.
+ * Generally, this has better performance than topelitz.
+ */
+static uint32_t
+pktq_rps_hash_toeplitz_othercpus(const struct mbuf *m)
+{
+	uint32_t hash;
+
+	hash = pktq_rps_hash_toeplitz(m);
+	hash %= ncpu - 1;
+	if (hash >= cpu_index(curcpu()))
+		return hash + 1;
+	else
+		return hash;
+}
+
+static struct pktq_rps_hash_table {
+	const char* prh_type;
+	pktq_rps_hash_func_t prh_func;
+} const pktq_rps_hash_tab[] = {
+	{ "zero", pktq_rps_hash_zero },
+	{ "curcpu", pktq_rps_hash_curcpu },
+	{ "toeplitz", pktq_rps_hash_toeplitz },
+	{ "toeplitz-othercpus", pktq_rps_hash_toeplitz_othercpus },
+};
+const pktq_rps_hash_func_t pktq_rps_hash_default =
+#ifdef NET_MPSAFE
+	pktq_rps_hash_curcpu;
+#else
+	pktq_rps_hash_zero;
+#endif
+
+static const char *
+pktq_get_rps_hash_type(pktq_rps_hash_func_t func)
+{
+
+	for (int i = 0; i < __arraycount(pktq_rps_hash_tab); i++) {
+		if (func == pktq_rps_hash_tab[i].prh_func) {
+			return pktq_rps_hash_tab[i].prh_type;
+		}
+	}
+
+	return NULL;
+}
+
+static int
+pktq_set_rps_hash_type(pktq_rps_hash_func_t *func, const char *type)
+{
+
+	if (strcmp(type, pktq_get_rps_hash_type(*func)) == 0)
+		return 0;
+
+	for (int i = 0; i < __arraycount(pktq_rps_hash_tab); i++) {
+		if (strcmp(type, pktq_rps_hash_tab[i].prh_type) == 0) {
+			atomic_store_relaxed(func, pktq_rps_hash_tab[i].prh_func);
+			return 0;
+		}
+	}
+
+	return ENOENT;
+}
+
+int
+sysctl_pktq_rps_hash_handler(SYSCTLFN_ARGS)
+{
+	struct sysctlnode node;
+	pktq_rps_hash_func_t *func;
+	int error;
+	char type[PKTQ_RPS_HASH_NAME_LEN];
+
+	node = *rnode;
+	func = node.sysctl_data;
+
+	strlcpy(type, pktq_get_rps_hash_type(*func), PKTQ_RPS_HASH_NAME_LEN);
+
+	node.sysctl_data = &type;
+	node.sysctl_size = sizeof(type);
+	error = sysctl_lookup(SYSCTLFN_CALL(&node));
+	if (error || newp == NULL)
+		return error;
+
+	error = pktq_set_rps_hash_type(func, type);
+
+	return error;
+ }
+
+/*
  * pktq_enqueue: inject the packet into the end of the queue.
  *
  * => Must be called from the interrupt or with the preemption disabled.

Index: src/sys/net/pktqueue.h
diff -u src/sys/net/pktqueue.h:1.4 src/sys/net/pktqueue.h:1.5
--- src/sys/net/pktqueue.h:1.4	Mon Jun 16 00:40:10 2014
+++ src/sys/net/pktqueue.h	Mon Oct 11 05:13:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pktqueue.h,v 1.4 2014/06/16 00:40:10 ozaki-r Exp $	*/
+/*	$NetBSD: pktqueue.h,v 1.5 2021/10/11 05:13:11 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -44,6 +44,9 @@ typedef struct pktqueue pktqueue_t;
 
 typedef enum { PKTQ_MAXLEN, PKTQ_NITEMS, PKTQ_DROPS } pktq_count_t;
 
+typedef uint32_t (*pktq_rps_hash_func_t)(const struct mbuf *);
+#define PKTQ_RPS_HASH_NAME_LEN 32
+
 pktqueue_t *	pktq_create(size_t, void (*)(void *), void *);
 void		pktq_destroy(pktqueue_t *);
 
@@ -53,9 +56,13 @@ void		pktq_barrier(pktqueue_t *);
 void		pktq_flush(pktqueue_t *);
 int		pktq_set_maxlen(pktqueue_t *, size_t);
 
-uint32_t	pktq_rps_hash(const struct mbuf *);
+uint32_t	pktq_rps_hash(pktq_rps_hash_func_t *, const struct mbuf *);
+extern const pktq_rps_hash_func_t	pktq_rps_hash_default;
+
 uint64_t	pktq_get_count(pktqueue_t *, pktq_count_t);
 
+int		sysctl_pktq_rps_hash_handler(SYSCTLFN_PROTO);
+
 int		sysctl_pktq_maxlen(SYSCTLFN_PROTO, pktqueue_t *);
 int		sysctl_pktq_count(SYSCTLFN_PROTO, pktqueue_t *, u_int);
 

Index: src/sys/rump/librump/rumpnet/Makefile.rumpnet
diff -u src/sys/rump/librump/rumpnet/Makefile.rumpnet:1.23 src/sys/rump/librump/rumpnet/Makefile.rumpnet:1.24
--- src/sys/rump/librump/rumpnet/Makefile.rumpnet:1.23	Thu Nov 15 09:38:57 2018
+++ src/sys/rump/librump/rumpnet/Makefile.rumpnet	Mon Oct 11 05:13:11 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.rumpnet,v 1.23 2018/11/15 09:38:57 maxv Exp $
+#	$NetBSD: Makefile.rumpnet,v 1.24 2021/10/11 05:13:11 knakahara Exp $
 #
 
 LIB=		rumpnet
@@ -24,7 +24,7 @@ SRCS+=	sys_socket.c uipc_accf.c uipc_dom
 	uipc_socket.c uipc_socket2.c uipc_syscalls.c
 
 # sys/net
-SRCS+=	pktqueue.c pfil.c
+SRCS+=	pktqueue.c pfil.c rss_config.c toeplitz.c
 
 # formatters
 SRCS+= at_print.c dl_print.c in_print.c in6_print.c

Reply via email to