Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Convert MPLS from a legacy netisr to pktqueue.
details: https://anonhg.NetBSD.org/src/rev/65b314f521c7
branches: trunk
changeset: 369833:65b314f521c7
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Sep 03 02:24:59 2022 +0000
description:
Convert MPLS from a legacy netisr to pktqueue.
diffstat:
sys/net/if_ethersubr.c | 26 +++----------
sys/net/if_gre.c | 29 +++-------------
sys/net/if_loop.c | 44 +++++++-----------------
sys/net/if_mpls.c | 15 ++------
sys/net/netisr_dispatch.h | 6 +--
sys/netmpls/mpls_proto.c | 25 ++++++-------
sys/netmpls/mpls_var.h | 8 ++-
sys/rump/net/lib/libnetmpls/netmpls_component.c | 6 +--
8 files changed, 50 insertions(+), 109 deletions(-)
diffs (truncated from 410 to 300 lines):
diff -r 0fd17f21a8fb -r 65b314f521c7 sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c Sat Sep 03 02:07:32 2022 +0000
+++ b/sys/net/if_ethersubr.c Sat Sep 03 02:24:59 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ethersubr.c,v 1.318 2022/09/03 01:48:22 thorpej Exp $ */
+/* $NetBSD: if_ethersubr.c,v 1.319 2022/09/03 02:24:59 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.318 2022/09/03 01:48:22 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.319 2022/09/03 02:24:59 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -648,12 +648,10 @@
struct ethercom *ec = (struct ethercom *) ifp;
#endif
pktqueue_t *pktq = NULL;
- struct ifqueue *inq = NULL;
uint16_t etype;
struct ether_header *eh;
size_t ehlen;
static int earlypkts;
- int isr = 0;
/* No RPS for not-IP. */
pktq_rps_hash_func_t rps_hash = NULL;
@@ -937,8 +935,7 @@
#ifdef MPLS
case ETHERTYPE_MPLS:
- isr = NETISR_MPLS;
- inq = &mplsintrq;
+ pktq = mpls_pktq;
break;
#endif
@@ -946,20 +943,11 @@
goto noproto;
}
- if (__predict_true(pktq)) {
- const uint32_t h = rps_hash ? pktq_rps_hash(&rps_hash, m) : 0;
- if (__predict_false(!pktq_enqueue(pktq, m, h))) {
- m_freem(m);
- }
- return;
+ KASSERT(pktq != NULL);
+ const uint32_t h = rps_hash ? pktq_rps_hash(&rps_hash, m) : 0;
+ if (__predict_false(!pktq_enqueue(pktq, m, h))) {
+ m_freem(m);
}
-
- if (__predict_false(!inq)) {
- /* Should not happen. */
- goto error;
- }
-
- IFQ_ENQUEUE_ISR(inq, m, isr);
return;
drop:
diff -r 0fd17f21a8fb -r 65b314f521c7 sys/net/if_gre.c
--- a/sys/net/if_gre.c Sat Sep 03 02:07:32 2022 +0000
+++ b/sys/net/if_gre.c Sat Sep 03 02:24:59 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_gre.c,v 1.182 2022/09/03 01:48:22 thorpej Exp $ */
+/* $NetBSD: if_gre.c,v 1.183 2022/09/03 02:24:59 thorpej Exp $ */
/*
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.182 2022/09/03 01:48:22 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.183 2022/09/03 02:24:59 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_atalk.h"
@@ -790,10 +790,8 @@
gre_input(struct gre_softc *sc, struct mbuf *m, const struct gre_h *gh)
{
pktqueue_t *pktq = NULL;
- struct ifqueue *ifq = NULL;
uint16_t flags;
uint32_t af; /* af passed to BPF tap */
- int isr = 0, s;
int hlen;
if_statadd2(&sc->sc_if, if_ipackets, 1, if_ibytes, m->m_pkthdr.len);
@@ -837,8 +835,7 @@
#endif
#ifdef MPLS
case ETHERTYPE_MPLS:
- ifq = &mplsintrq;
- isr = NETISR_MPLS;
+ pktq = mpls_pktq;
af = AF_MPLS;
break;
#endif
@@ -860,24 +857,10 @@
m_set_rcvif(m, &sc->sc_if);
- if (__predict_true(pktq)) {
- if (__predict_false(!pktq_enqueue(pktq, m, 0))) {
- m_freem(m);
- }
- return 1;
+ KASSERT(pktq != NULL);
+ if (__predict_false(!pktq_enqueue(pktq, m, 0))) {
+ m_freem(m);
}
-
- s = splnet();
- if (IF_QFULL(ifq)) {
- IF_DROP(ifq);
- m_freem(m);
- } else {
- IF_ENQUEUE(ifq, m);
- }
- /* we need schednetisr since the address family may change */
- schednetisr(isr);
- splx(s);
-
return 1; /* packet is done, no further processing needed */
}
diff -r 0fd17f21a8fb -r 65b314f521c7 sys/net/if_loop.c
--- a/sys/net/if_loop.c Sat Sep 03 02:07:32 2022 +0000
+++ b/sys/net/if_loop.c Sat Sep 03 02:24:59 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_loop.c,v 1.115 2022/09/03 01:48:22 thorpej Exp $ */
+/* $NetBSD: if_loop.c,v 1.116 2022/09/03 02:24:59 thorpej Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.115 2022/09/03 01:48:22 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.116 2022/09/03 02:24:59 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -242,8 +242,7 @@
const struct rtentry *rt)
{
pktqueue_t *pktq = NULL;
- struct ifqueue *ifq = NULL;
- int s, isr = -1;
+ int s;
int csum_flags;
int error = 0;
size_t pktlen;
@@ -304,11 +303,10 @@
union mpls_shim msh;
msh.s_addr = MPLS_GETSADDR(rt);
if (msh.shim.label != MPLS_LABEL_IMPLNULL) {
- ifq = &mplsintrq;
- isr = NETISR_MPLS;
+ pktq = mpls_pktq;
}
}
- if (isr != NETISR_MPLS)
+ if (pktq != mpls_pktq)
#endif
switch (dst->sa_family) {
@@ -359,31 +357,17 @@
goto out;
}
- s = splnet();
- if (__predict_true(pktq)) {
- error = 0;
+ KASSERT(pktq != NULL);
- if (__predict_true(pktq_enqueue(pktq, m, 0))) {
- if_statadd2(ifp, if_ipackets, 1, if_ibytes, pktlen);
- } else {
- m_freem(m);
- if_statinc(ifp, if_oerrors);
- error = ENOBUFS;
- }
- splx(s);
- goto out;
+ error = 0;
+ s = splnet();
+ if (__predict_true(pktq_enqueue(pktq, m, 0))) {
+ if_statadd2(ifp, if_ipackets, 1, if_ibytes, pktlen);
+ } else {
+ m_freem(m);
+ if_statinc(ifp, if_oerrors);
+ error = ENOBUFS;
}
- if (IF_QFULL(ifq)) {
- IF_DROP(ifq);
- m_freem(m);
- splx(s);
- error = ENOBUFS;
- if_statinc(ifp, if_oerrors);
- goto out;
- }
- if_statadd2(ifp, if_ipackets, 1, if_ibytes, m->m_pkthdr.len);
- IF_ENQUEUE(ifq, m);
- schednetisr(isr);
splx(s);
out:
KERNEL_UNLOCK_UNLESS_NET_MPSAFE();
diff -r 0fd17f21a8fb -r 65b314f521c7 sys/net/if_mpls.c
--- a/sys/net/if_mpls.c Sat Sep 03 02:07:32 2022 +0000
+++ b/sys/net/if_mpls.c Sat Sep 03 02:24:59 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_mpls.c,v 1.38 2022/07/29 15:25:51 skrll Exp $ */
+/* $NetBSD: if_mpls.c,v 1.39 2022/09/03 02:24:59 thorpej Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.38 2022/07/29 15:25:51 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.39 2022/09/03 02:24:59 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -189,18 +189,11 @@
}
void
-mplsintr(void)
+mplsintr(void *arg __unused)
{
struct mbuf *m;
- for (;;) {
- IFQ_LOCK(&mplsintrq);
- IF_DEQUEUE(&mplsintrq, m);
- IFQ_UNLOCK(&mplsintrq);
-
- if (!m)
- return;
-
+ while ((m = pktq_dequeue(mpls_pktq)) != NULL) {
if (((m->m_flags & M_PKTHDR) == 0) ||
(m->m_pkthdr.rcvif_index == 0))
panic("mplsintr(): no pkthdr or rcvif");
diff -r 0fd17f21a8fb -r 65b314f521c7 sys/net/netisr_dispatch.h
--- a/sys/net/netisr_dispatch.h Sat Sep 03 02:07:32 2022 +0000
+++ b/sys/net/netisr_dispatch.h Sat Sep 03 02:24:59 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netisr_dispatch.h,v 1.23 2022/09/03 02:07:32 thorpej Exp $ */
+/* $NetBSD: netisr_dispatch.h,v 1.24 2022/09/03 02:24:59 thorpej Exp $ */
#ifndef _NET_NETISR_DISPATCH_H_
#define _NET_NETISR_DISPATCH_H_
@@ -27,8 +27,4 @@
* their prototypes in <net/netisr.h> (if necessary).
*/
-#ifdef MPLS
- DONETISR(NETISR_MPLS,mplsintr);
-#endif
-
#endif /* !_NET_NETISR_DISPATCH_H_ */
diff -r 0fd17f21a8fb -r 65b314f521c7 sys/netmpls/mpls_proto.c
--- a/sys/netmpls/mpls_proto.c Sat Sep 03 02:07:32 2022 +0000
+++ b/sys/netmpls/mpls_proto.c Sat Sep 03 02:24:59 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mpls_proto.c,v 1.32 2019/01/28 12:53:01 martin Exp $ */
+/* $NetBSD: mpls_proto.c,v 1.33 2022/09/03 02:24:59 thorpej Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpls_proto.c,v 1.32 2019/01/28 12:53:01 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpls_proto.c,v 1.33 2022/09/03 02:24:59 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -49,7 +49,8 @@
#include <netmpls/mpls.h>
#include <netmpls/mpls_var.h>
-struct ifqueue mplsintrq;
+#define MPLS_MAXQLEN 256
+pktqueue_t * mpls_pktq __read_mostly;
static int mpls_attach(struct socket *, int);
Home |
Main Index |
Thread Index |
Old Index