Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Convert CAN from a legacy netisr to pktqueue.
details: https://anonhg.NetBSD.org/src/rev/0fd17f21a8fb
branches: trunk
changeset: 369832:0fd17f21a8fb
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Sep 03 02:07:32 2022 +0000
description:
Convert CAN from a legacy netisr to pktqueue.
diffstat:
sys/net/netisr_dispatch.h | 5 +--
sys/netcan/can.c | 43 +++++++++-----------------
sys/netcan/can_proto.c | 5 +-
sys/netcan/can_var.h | 4 +-
sys/rump/net/lib/libnetcan/netcan_component.c | 5 +-
5 files changed, 21 insertions(+), 41 deletions(-)
diffs (198 lines):
diff -r f84388fc82c6 -r 0fd17f21a8fb sys/net/netisr_dispatch.h
--- a/sys/net/netisr_dispatch.h Sat Sep 03 01:48:22 2022 +0000
+++ b/sys/net/netisr_dispatch.h Sat Sep 03 02:07:32 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netisr_dispatch.h,v 1.22 2022/09/03 01:48:22 thorpej Exp $ */
+/* $NetBSD: netisr_dispatch.h,v 1.23 2022/09/03 02:07:32 thorpej Exp $ */
#ifndef _NET_NETISR_DISPATCH_H_
#define _NET_NETISR_DISPATCH_H_
@@ -30,8 +30,5 @@
#ifdef MPLS
DONETISR(NETISR_MPLS,mplsintr);
#endif
-#ifdef CAN
- DONETISR(NETISR_CAN,canintr);
-#endif
#endif /* !_NET_NETISR_DISPATCH_H_ */
diff -r f84388fc82c6 -r 0fd17f21a8fb sys/netcan/can.c
--- a/sys/netcan/can.c Sat Sep 03 01:48:22 2022 +0000
+++ b/sys/netcan/can.c Sat Sep 03 02:07:32 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: can.c,v 1.11 2021/12/31 14:24:51 riastradh Exp $ */
+/* $NetBSD: can.c,v 1.12 2022/09/03 02:07:32 thorpej Exp $ */
/*-
* Copyright (c) 2003, 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: can.c,v 1.11 2021/12/31 14:24:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: can.c,v 1.12 2022/09/03 02:07:32 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -46,7 +46,7 @@
#include <net/if.h>
#include <net/if_types.h>
-#include <net/netisr.h>
+#include <net/pktqueue.h>
#include <net/route.h>
#include <net/bpf.h>
@@ -61,7 +61,7 @@
struct canpcbtable cbtable;
-struct ifqueue canintrq;
+pktqueue_t * can_pktq __read_mostly;
int canqmaxlen = IFQ_MAXLEN;
int can_copy_output = 0;
@@ -86,11 +86,14 @@
static int can_control(struct socket *, u_long, void *, struct ifnet *);
+static void canintr(void *);
+
void
can_init(void)
{
- canintrq.ifq_maxlen = canqmaxlen;
- IFQ_LOCK_INIT(&canintrq);
+ can_pktq = pktq_create(canqmaxlen, canintr, NULL);
+ KASSERT(can_pktq != NULL);
+
can_pcbinit(&cbtable, canhashsize, canhashsize);
}
@@ -290,30 +293,21 @@
void
can_input(struct ifnet *ifp, struct mbuf *m)
{
- struct ifqueue *inq;
-
if ((ifp->if_flags & IFF_UP) == 0) {
m_freem(m);
return;
}
- inq = &canintrq;
-
- IFQ_LOCK(inq);
- if (IF_QFULL(inq)) {
- IF_DROP(inq);
- IFQ_UNLOCK(inq);
+ const int pktlen = m->m_pkthdr.len;
+ if (__predict_false(!pktq_enqueue(can_pktq, m, 0))) {
m_freem(m);
} else {
- IF_ENQUEUE(inq, m);
- IFQ_UNLOCK(inq);
- if_statadd2(ifp, if_ipackets, 1, if_ibytes, m->m_pkthdr.len);
- schednetisr(NETISR_CAN);
+ if_statadd2(ifp, if_ipackets, 1, if_ibytes, pktlen);
}
}
-void
-canintr(void)
+static void
+canintr(void *arg __unused)
{
int rcv_ifindex;
struct mbuf *m;
@@ -324,14 +318,7 @@
struct canpcb *sender_canp;
mutex_enter(softnet_lock);
- for (;;) {
- IFQ_LOCK(&canintrq);
- IF_DEQUEUE(&canintrq, m);
- IFQ_UNLOCK(&canintrq);
-
- if (m == NULL) /* no more queued packets */
- break;
-
+ while ((m = pktq_dequeue(can_pktq)) != NULL) {
#if 0
m_claim(m, &can_rx_mowner);
#endif
diff -r f84388fc82c6 -r 0fd17f21a8fb sys/netcan/can_proto.c
--- a/sys/netcan/can_proto.c Sat Sep 03 01:48:22 2022 +0000
+++ b/sys/netcan/can_proto.c Sat Sep 03 02:07:32 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: can_proto.c,v 1.2 2017/05/27 21:02:56 bouyer Exp $ */
+/* $NetBSD: can_proto.c,v 1.3 2022/09/03 02:07:32 thorpej Exp $ */
/*-
* Copyright (c) 2003, 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: can_proto.c,v 1.2 2017/05/27 21:02:56 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: can_proto.c,v 1.3 2022/09/03 02:07:32 thorpej Exp $");
#include <sys/param.h>
#include <sys/socket.h>
@@ -68,7 +68,6 @@
.dom_externalize = NULL, .dom_dispose = NULL,
.dom_protosw = cansw,
.dom_protoswNPROTOSW = &cansw[__arraycount(cansw)],
- .dom_ifqueues = { &canintrq, NULL },
.dom_link = { NULL },
.dom_mowner = MOWNER_INIT("",""),
.dom_sa_cmpofs = offsetof(struct sockaddr_can, can_ifindex),
diff -r f84388fc82c6 -r 0fd17f21a8fb sys/netcan/can_var.h
--- a/sys/netcan/can_var.h Sat Sep 03 01:48:22 2022 +0000
+++ b/sys/netcan/can_var.h Sat Sep 03 02:07:32 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: can_var.h,v 1.2 2017/05/27 21:02:56 bouyer Exp $ */
+/* $NetBSD: can_var.h,v 1.3 2022/09/03 02:07:32 thorpej Exp $ */
/*-
* Copyright (c) 2003, 2017 The NetBSD Foundation, Inc.
@@ -54,7 +54,6 @@
uint32_t csc_linkmodes;
};
-extern struct ifqueue canintrq;
extern struct domain candomain;
extern const struct pr_usrreqs can_usrreqs;
@@ -67,7 +66,6 @@
void *can_ctlinput(int, struct sockaddr *, void *);
int can_ctloutput(int, struct socket *, struct sockopt *);
void can_init(void);
-void canintr(void);
void can_bpf_mtap(struct ifnet *, struct mbuf *, bool);
#endif
diff -r f84388fc82c6 -r 0fd17f21a8fb sys/rump/net/lib/libnetcan/netcan_component.c
--- a/sys/rump/net/lib/libnetcan/netcan_component.c Sat Sep 03 01:48:22 2022 +0000
+++ b/sys/rump/net/lib/libnetcan/netcan_component.c Sat Sep 03 02:07:32 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netcan_component.c,v 1.3 2020/07/21 18:38:18 pgoyette Exp $ */
+/* $NetBSD: netcan_component.c,v 1.4 2022/09/03 02:07:33 thorpej Exp $ */
/*
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netcan_component.c,v 1.3 2020/07/21 18:38:18 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netcan_component.c,v 1.4 2022/09/03 02:07:33 thorpej Exp $");
#include <sys/param.h>
#include <sys/domain.h>
@@ -42,5 +42,4 @@
extern struct domain candomain;
domain_attach(&candomain);
- rump_netisr_register(NETISR_CAN, canintr);
}
Home |
Main Index |
Thread Index |
Old Index