Source-Changes-HG archive

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

[src/trunk]: src/sys Convert ARP from a legacy netisr to pktqueue.



details:   https://anonhg.NetBSD.org/src/rev/f0cdf9ed8791
branches:  trunk
changeset: 369830:f0cdf9ed8791
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Sep 03 01:35:03 2022 +0000

description:
Convert ARP from a legacy netisr to pktqueue.

diffstat:

 sys/net/if_arcsubr.c                            |  22 +++++------------
 sys/net/if_ethersubr.c                          |   7 ++---
 sys/net/if_ieee1394subr.c                       |  19 +++++----------
 sys/net/netisr_dispatch.h                       |   7 +-----
 sys/netinet/if_arp.c                            |  30 ++++++++----------------
 sys/netinet/if_inarp.h                          |   8 ++++--
 sys/rump/net/lib/libnetinet/netinet_component.c |   6 +---
 7 files changed, 34 insertions(+), 65 deletions(-)

diffs (truncated from 313 to 300 lines):

diff -r 47a1536914e8 -r f0cdf9ed8791 sys/net/if_arcsubr.c
--- a/sys/net/if_arcsubr.c      Sat Sep 03 00:50:07 2022 +0000
+++ b/sys/net/if_arcsubr.c      Sat Sep 03 01:35:03 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arcsubr.c,v 1.83 2021/06/16 00:21:19 riastradh Exp $        */
+/*     $NetBSD: if_arcsubr.c,v 1.84 2022/09/03 01:35:03 thorpej Exp $  */
 
 /*
  * Copyright (c) 1994, 1995 Ignatios Souvatzis
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.83 2021/06/16 00:21:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.84 2022/09/03 01:35:03 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -508,9 +508,7 @@
 {
        pktqueue_t *pktq = NULL;
        struct arc_header *ah;
-       struct ifqueue *inq;
        uint8_t atype;
-       int isr = 0;
 
        if ((ifp->if_flags & IFF_UP) == 0) {
                m_freem(m);
@@ -546,8 +544,7 @@
 
        case ARCTYPE_ARP:
                m_adj(m, ARC_HDRNEWLEN);
-               isr = NETISR_ARP;
-               inq = &arpintrq;
+               pktq = arp_pktq;
 #ifdef ARCNET_ALLOW_BROKEN_ARP
                mtod(m, struct arphdr *)->ar_pro = htons(ETHERTYPE_IP);
 #endif
@@ -555,8 +552,7 @@
 
        case ARCTYPE_ARP_OLD:
                m_adj(m, ARC_HDRLEN);
-               isr = NETISR_ARP;
-               inq = &arpintrq;
+               pktq = arp_pktq;
 #ifdef ARCNET_ALLOW_BROKEN_ARP
                mtod(m, struct arphdr *)->ar_pro = htons(ETHERTYPE_IP);
 #endif
@@ -573,14 +569,10 @@
                return;
        }
 
-       if (__predict_true(pktq)) {
-               if (__predict_false(!pktq_enqueue(pktq, m, 0))) {
-                       m_freem(m);
-               }
-               return;
+       KASSERT(pktq != NULL);
+       if (__predict_false(!pktq_enqueue(pktq, m, 0))) {
+               m_freem(m);
        }
-
-       IFQ_ENQUEUE_ISR(inq, m, isr);
 }
 
 /*
diff -r 47a1536914e8 -r f0cdf9ed8791 sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Sat Sep 03 00:50:07 2022 +0000
+++ b/sys/net/if_ethersubr.c    Sat Sep 03 01:35:03 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ethersubr.c,v 1.316 2022/09/03 00:31:02 thorpej Exp $       */
+/*     $NetBSD: if_ethersubr.c,v 1.317 2022/09/03 01:35:03 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.316 2022/09/03 00:31:02 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.317 2022/09/03 01:35:03 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -904,8 +904,7 @@
                break;
 
        case ETHERTYPE_ARP:
-               isr = NETISR_ARP;
-               inq = &arpintrq;
+               pktq = arp_pktq;
                break;
 
        case ETHERTYPE_REVARP:
diff -r 47a1536914e8 -r f0cdf9ed8791 sys/net/if_ieee1394subr.c
--- a/sys/net/if_ieee1394subr.c Sat Sep 03 00:50:07 2022 +0000
+++ b/sys/net/if_ieee1394subr.c Sat Sep 03 01:35:03 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ieee1394subr.c,v 1.67 2021/12/31 14:25:24 riastradh Exp $   */
+/*     $NetBSD: if_ieee1394subr.c,v 1.68 2022/09/03 01:35:03 thorpej Exp $     */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.67 2021/12/31 14:25:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.68 2022/09/03 01:35:03 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -326,10 +326,8 @@
 ieee1394_input(struct ifnet *ifp, struct mbuf *m, uint16_t src)
 {
        pktqueue_t *pktq = NULL;
-       struct ifqueue *inq;
        uint16_t etype;
        struct ieee1394_unfraghdr *iuh;
-       int isr = 0;
 
        if ((ifp->if_flags & IFF_UP) == 0) {
                m_freem(m);
@@ -381,8 +379,7 @@
                break;
 
        case ETHERTYPE_ARP:
-               isr = NETISR_ARP;
-               inq = &arpintrq;
+               pktq = arp_pktq;
                break;
 #endif /* INET */
 
@@ -397,14 +394,10 @@
                return;
        }
 
-       if (__predict_true(pktq)) {
-               if (__predict_false(!pktq_enqueue(pktq, m, 0))) {
-                       m_freem(m);
-               }
-               return;
+       KASSERT(pktq != NULL);
+       if (__predict_false(!pktq_enqueue(pktq, m, 0))) {
+               m_freem(m);
        }
-
-       IFQ_ENQUEUE_ISR(inq, m, isr);
 }
 
 static struct mbuf *
diff -r 47a1536914e8 -r f0cdf9ed8791 sys/net/netisr_dispatch.h
--- a/sys/net/netisr_dispatch.h Sat Sep 03 00:50:07 2022 +0000
+++ b/sys/net/netisr_dispatch.h Sat Sep 03 01:35:03 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netisr_dispatch.h,v 1.20 2018/09/06 06:42:00 maxv Exp $ */
+/* $NetBSD: netisr_dispatch.h,v 1.21 2022/09/03 01:35:03 thorpej Exp $ */
 
 #ifndef _NET_NETISR_DISPATCH_H_
 #define _NET_NETISR_DISPATCH_H_
@@ -27,11 +27,6 @@
  * their prototypes in <net/netisr.h> (if necessary).
  */
 
-#ifdef INET
-#if NARP > 0
-       DONETISR(NETISR_ARP,arpintr);
-#endif
-#endif
 #ifdef NETATALK
        DONETISR(NETISR_ATALK,atintr);
 #endif
diff -r 47a1536914e8 -r f0cdf9ed8791 sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c      Sat Sep 03 00:50:07 2022 +0000
+++ b/sys/netinet/if_arp.c      Sat Sep 03 01:35:03 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arp.c,v 1.307 2021/02/19 14:51:59 christos Exp $    */
+/*     $NetBSD: if_arp.c,v 1.308 2022/09/03 01:35:03 thorpej Exp $     */
 
 /*
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.307 2021/02/19 14:51:59 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.308 2022/09/03 01:35:03 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -196,13 +196,9 @@
 static void arp_dad_stop(struct ifaddr *);
 static void arp_dad_duplicated(struct ifaddr *, const struct sockaddr_dl *);
 
-struct ifqueue arpintrq = {
-       .ifq_head = NULL,
-       .ifq_tail = NULL,
-       .ifq_len = 0,
-       .ifq_maxlen = 50,
-       .ifq_drops = 0,
-};
+#define        ARP_MAXQLEN     50
+pktqueue_t *           arp_pktq                __read_mostly;
+
 static int useloopback = 1;    /* use loopback interface for local traffic */
 
 static percpu_t *arpstat_percpu;
@@ -269,9 +265,11 @@
 arp_init(void)
 {
 
+       arp_pktq = pktq_create(ARP_MAXQLEN, arpintr, NULL);
+       KASSERT(arp_pktq != NULL);
+
        sysctl_net_inet_arp_setup(NULL);
        arpstat_percpu = percpu_alloc(sizeof(uint64_t) * ARP_NSTATS);
-       IFQ_LOCK_INIT(&arpintrq);
 
 #ifdef MBUFTRACE
        MOWNER_ATTACH(&arpdomain.dom_mowner);
@@ -678,7 +676,7 @@
  * then the protocol-specific routine is called.
  */
 void
-arpintr(void)
+arpintr(void *arg __unused)
 {
        struct mbuf *m;
        struct arphdr *ar;
@@ -688,13 +686,7 @@
        bool badhrd;
 
        SOFTNET_KERNEL_LOCK_UNLESS_NET_MPSAFE();
-       for (;;) {
-
-               IFQ_LOCK(&arpintrq);
-               IF_DEQUEUE(&arpintrq, m);
-               IFQ_UNLOCK(&arpintrq);
-               if (m == NULL)
-                       goto out;
+       while ((m = pktq_dequeue(arp_pktq)) != NULL) {
                if ((m->m_flags & M_PKTHDR) == 0)
                        panic("arpintr");
 
@@ -753,8 +745,6 @@
 free:
                m_freem(m);
        }
-
-out:
        SOFTNET_KERNEL_UNLOCK_UNLESS_NET_MPSAFE();
        return; /* XXX gcc */
 }
diff -r 47a1536914e8 -r f0cdf9ed8791 sys/netinet/if_inarp.h
--- a/sys/netinet/if_inarp.h    Sat Sep 03 00:50:07 2022 +0000
+++ b/sys/netinet/if_inarp.h    Sat Sep 03 01:35:03 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_inarp.h,v 1.52 2020/09/11 15:16:00 roy Exp $        */
+/*     $NetBSD: if_inarp.h,v 1.53 2022/09/03 01:35:03 thorpej Exp $    */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -57,6 +57,8 @@
 
 #ifdef _KERNEL
 
+#include <net/pktqueue.h>
+
 /* ARP timings from RFC5227 */
 #define PROBE_WAIT               1
 #define PROBE_NUM                3
@@ -69,12 +71,12 @@
 #define RATE_LIMIT_INTERVAL     60
 #define DEFEND_INTERVAL         10
 
-extern struct ifqueue arpintrq;
+extern pktqueue_t *arp_pktq;
 void arp_ifinit(struct ifnet *, struct ifaddr *);
 void arp_rtrequest(int, struct rtentry *, const struct rt_addrinfo *);
 int arpresolve(struct ifnet *, const struct rtentry *, struct mbuf *,
     const struct sockaddr *, void *, size_t);
-void arpintr(void);
+void arpintr(void *);
 void arpannounce(struct ifnet *, struct ifaddr *, const uint8_t *);
 struct llentry *arplookup(struct ifnet *,
     const struct in_addr *, const struct sockaddr *, int);
diff -r 47a1536914e8 -r f0cdf9ed8791 sys/rump/net/lib/libnetinet/netinet_component.c
--- a/sys/rump/net/lib/libnetinet/netinet_component.c   Sat Sep 03 00:50:07 2022 +0000
+++ b/sys/rump/net/lib/libnetinet/netinet_component.c   Sat Sep 03 01:35:03 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netinet_component.c,v 1.11 2018/02/24 07:37:08 ozaki-r Exp $   */
+/*     $NetBSD: netinet_component.c,v 1.12 2022/09/03 01:35:03 thorpej Exp $   */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netinet_component.c,v 1.11 2018/02/24 07:37:08 ozaki-r Exp $");



Home | Main Index | Thread Index | Old Index