Source-Changes-HG archive

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

[src/trunk]: src/sys/net Only use configured RPS hash functions for IPv4 and ...



details:   https://anonhg.NetBSD.org/src/rev/1f4f232af7e2
branches:  trunk
changeset: 369828:1f4f232af7e2
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Sep 03 00:31:02 2022 +0000

description:
Only use configured RPS hash functions for IPv4 and IPv6 packets.

This is NFC change now because only IPv4 and IPv6 use pktqueue,
but that will change in future commits.

diffstat:

 sys/net/if_ethersubr.c |  11 ++++++++---
 sys/net/if_spppsubr.c  |  13 +++++++++----
 2 files changed, 17 insertions(+), 7 deletions(-)

diffs (108 lines):

diff -r 7417e62840b4 -r 1f4f232af7e2 sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Fri Sep 02 23:48:10 2022 +0000
+++ b/sys/net/if_ethersubr.c    Sat Sep 03 00:31:02 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ethersubr.c,v 1.315 2022/06/20 12:22:00 martin Exp $        */
+/*     $NetBSD: if_ethersubr.c,v 1.316 2022/09/03 00:31:02 thorpej 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.315 2022/06/20 12:22:00 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.316 2022/09/03 00:31:02 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -655,6 +655,9 @@
        static int earlypkts;
        int isr = 0;
 
+       /* No RPS for not-IP. */
+       pktq_rps_hash_func_t rps_hash = NULL;
+
        KASSERT(!cpu_intr_p());
        KASSERT((m->m_flags & M_PKTHDR) != 0);
 
@@ -897,6 +900,7 @@
                        return;
 #endif
                pktq = ip_pktq;
+               rps_hash = atomic_load_relaxed(&ether_pktq_rps_hash_p);
                break;
 
        case ETHERTYPE_ARP:
@@ -918,6 +922,7 @@
                        return;
 #endif
                pktq = ip6_pktq;
+               rps_hash = atomic_load_relaxed(&ether_pktq_rps_hash_p);
                break;
 #endif
 
@@ -944,7 +949,7 @@
        }
 
        if (__predict_true(pktq)) {
-               const uint32_t h = pktq_rps_hash(&ether_pktq_rps_hash_p, m);
+               const uint32_t h = rps_hash ? pktq_rps_hash(&rps_hash, m) : 0;
                if (__predict_false(!pktq_enqueue(pktq, m, h))) {
                        m_freem(m);
                }
diff -r 7417e62840b4 -r 1f4f232af7e2 sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c     Fri Sep 02 23:48:10 2022 +0000
+++ b/sys/net/if_spppsubr.c     Sat Sep 03 00:31:02 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_spppsubr.c,v 1.264 2022/08/27 19:25:35 thorpej Exp $         */
+/*     $NetBSD: if_spppsubr.c,v 1.265 2022/09/03 00:31:02 thorpej Exp $         */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.264 2022/08/27 19:25:35 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.265 2022/09/03 00:31:02 thorpej Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -644,6 +644,9 @@
        struct sppp *sp = (struct sppp *)ifp;
        int isr = 0;
 
+       /* No RPS for not-IP. */
+       pktq_rps_hash_func_t rps_hash = NULL;
+
        SPPP_LOCK(sp, RW_READER);
 
        if (ifp->if_flags & IFF_UP) {
@@ -747,6 +750,7 @@
                if (sp->scp[IDX_IPCP].state == STATE_OPENED) {
                        sp->pp_last_activity = time_uptime;
                        pktq = ip_pktq;
+                       rps_hash = atomic_load_relaxed(&sppp_pktq_rps_hash_p);
                }
                break;
 #endif
@@ -770,6 +774,7 @@
                if (sp->scp[IDX_IPV6CP].state == STATE_OPENED) {
                        sp->pp_last_activity = time_uptime;
                        pktq = ip6_pktq;
+                       rps_hash = atomic_load_relaxed(&sppp_pktq_rps_hash_p);
                }
                break;
 #endif
@@ -781,8 +786,8 @@
 
        /* Check queue. */
        if (__predict_true(pktq)) {
-               uint32_t hash = pktq_rps_hash(&sppp_pktq_rps_hash_p, m);
-
+               const uint32_t hash =
+                   rps_hash ? pktq_rps_hash(&rps_hash, m) : 0;
                if (__predict_false(!pktq_enqueue(pktq, m, hash))) {
                        goto drop;
                }



Home | Main Index | Thread Index | Old Index