Source-Changes-HG archive

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

[src/trunk]: src/sys Make pktq_rps_hash() pluggable for each interface type. ...



details:   https://anonhg.NetBSD.org/src/rev/db15922a4557
branches:  trunk
changeset: 1024145:db15922a4557
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Mon Oct 11 05:13:10 2021 +0000

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

diffstat:

 sys/dev/pci/xmm7360.c                     |   10 +-
 sys/net/if_ethersubr.c                    |   21 ++-
 sys/net/if_gif.c                          |   30 ++++-
 sys/net/if_ipsec.c                        |   30 ++++-
 sys/net/if_pppoe.c                        |   15 ++-
 sys/net/if_spppsubr.c                     |   10 +-
 sys/net/pktqueue.c                        |  149 ++++++++++++++++++++++++++++-
 sys/net/pktqueue.h                        |   11 +-
 sys/rump/librump/rumpnet/Makefile.rumpnet |    4 +-
 9 files changed, 238 insertions(+), 42 deletions(-)

diffs (truncated from 568 to 300 lines):

diff -r 872c9753eb8c -r db15922a4557 sys/dev/pci/xmm7360.c
--- a/sys/dev/pci/xmm7360.c     Mon Oct 11 03:50:45 2021 +0000
+++ b/sys/dev/pci/xmm7360.c     Mon Oct 11 05:13:10 2021 +0000
@@ -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 @@
 #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 @@
        /* 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);
        }
diff -r 872c9753eb8c -r db15922a4557 sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Mon Oct 11 03:50:45 2021 +0000
+++ b/sys/net/if_ethersubr.c    Mon Oct 11 05:13:10 2021 +0000
@@ -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 @@
     { 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 @@
        }
 
        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 @@
                       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 @@
 #ifdef DIAGNOSTIC
        mutex_init(&bigpktpps_lock, MUTEX_DEFAULT, IPL_NET);
 #endif
+       ether_pktq_rps_hash_p = pktq_rps_hash_default;
        ether_sysctl_setup(NULL);
 }
diff -r 872c9753eb8c -r db15922a4557 sys/net/if_gif.c
--- a/sys/net/if_gif.c  Mon Oct 11 03:50:45 2021 +0000
+++ b/sys/net/if_gif.c  Mon Oct 11 05:13:10 2021 +0000
@@ -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 @@
 
 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 @@
 static void
 gif_sysctl_setup(void)
 {
+       const struct sysctlnode *node = NULL;
+
        gif_sysctl = NULL;
 
 #ifdef INET
@@ -258,6 +262,21 @@
                       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 @@
 
        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 @@
                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 {
diff -r 872c9753eb8c -r db15922a4557 sys/net/if_ipsec.c
--- a/sys/net/if_ipsec.c        Mon Oct 11 03:50:45 2021 +0000
+++ b/sys/net/if_ipsec.c        Mon Oct 11 05:13:10 2021 +0000
@@ -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 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 @@
 static void
 if_ipsec_sysctl_setup(void)
 {
+       const struct sysctlnode *node = NULL;
+
        if_ipsec_sysctl = NULL;
 
 #ifdef INET6
@@ -241,6 +245,21 @@
                       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 @@
 
        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 @@
                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);
diff -r 872c9753eb8c -r db15922a4557 sys/net/if_pppoe.c
--- a/sys/net/if_pppoe.c        Mon Oct 11 03:50:45 2021 +0000
+++ b/sys/net/if_pppoe.c        Mon Oct 11 05:13:10 2021 +0000
@@ -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 @@
 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_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);
 }
 
 /*
diff -r 872c9753eb8c -r db15922a4557 sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c     Mon Oct 11 03:50:45 2021 +0000
+++ b/sys/net/if_spppsubr.c     Mon Oct 11 05:13:10 2021 +0000
@@ -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 $       */



Home | Main Index | Thread Index | Old Index