Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys introduce new ifnet MP-scalable sending interface "if_tr...
details: https://anonhg.NetBSD.org/src/rev/f30afaf7eabc
branches: trunk
changeset: 815072:f30afaf7eabc
user: knakahara <knakahara%NetBSD.org@localhost>
date: Thu Apr 28 01:37:17 2016 +0000
description:
introduce new ifnet MP-scalable sending interface "if_transmit".
diffstat:
sys/dev/usb/if_upl.c | 21 +++------------
sys/net/if.c | 61 ++++++++++++++++++++++++++++++++-------------
sys/net/if.h | 7 ++++-
sys/net/if_bridge.c | 17 +++---------
sys/net/if_ieee1394subr.c | 21 +++------------
sys/net/if_loop.c | 9 ++----
sys/net/if_vlan.c | 22 ++++++---------
sys/netipsec/ipsec_osdep.h | 15 +++--------
8 files changed, 79 insertions(+), 94 deletions(-)
diffs (truncated from 412 to 300 lines):
diff -r 541dcfa061ae -r f30afaf7eabc sys/dev/usb/if_upl.c
--- a/sys/dev/usb/if_upl.c Thu Apr 28 01:20:31 2016 +0000
+++ b/sys/dev/usb/if_upl.c Thu Apr 28 01:37:17 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_upl.c,v 1.52 2016/04/28 00:16:56 ozaki-r Exp $ */
+/* $NetBSD: if_upl.c,v 1.53 2016/04/28 01:37:17 knakahara Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.52 2016/04/28 00:16:56 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.53 2016/04/28 01:37:17 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -987,7 +987,7 @@
upl_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
const struct rtentry *rt0)
{
- int s, len, error;
+ int error;
DPRINTFN(10,("%s: %s: enter\n",
device_xname(((struct upl_softc *)ifp->if_softc)->sc_dev),
@@ -999,24 +999,13 @@
*/
IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family);
- len = m->m_pkthdr.len;
- s = splnet();
/*
* Queue message on interface, and start output if interface
* not yet active.
*/
- IFQ_ENQUEUE(&ifp->if_snd, m, error);
- if (error) {
- /* mbuf is already freed */
- splx(s);
- return error;
- }
- ifp->if_obytes += len;
- if ((ifp->if_flags & IFF_OACTIVE) == 0)
- (*ifp->if_start)(ifp);
- splx(s);
+ error = (*ifp->if_transmit)(ifp, m);
- return 0;
+ return error;
}
Static void
diff -r 541dcfa061ae -r f30afaf7eabc sys/net/if.c
--- a/sys/net/if.c Thu Apr 28 01:20:31 2016 +0000
+++ b/sys/net/if.c Thu Apr 28 01:37:17 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.331 2016/04/28 00:16:56 ozaki-r Exp $ */
+/* $NetBSD: if.c,v 1.332 2016/04/28 01:37:17 knakahara Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.331 2016/04/28 00:16:56 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.332 2016/04/28 01:37:17 knakahara Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -329,6 +329,13 @@
}
int
+if_nulltransmit(struct ifnet *ifp, struct mbuf *m)
+{
+
+ return ENXIO;
+}
+
+int
if_nullioctl(struct ifnet *ifp, u_long cmd, void *data)
{
@@ -665,6 +672,9 @@
if_slowtimo(ifp);
}
+ if (ifp->if_transmit == NULL || ifp->if_transmit == if_nulltransmit)
+ ifp->if_transmit = if_transmit;
+
TAILQ_INSERT_TAIL(&ifnet_list, ifp, if_list);
}
@@ -959,6 +969,7 @@
ifp->if_output = if_nulloutput;
ifp->_if_input = if_nullinput;
ifp->if_start = if_nullstart;
+ ifp->if_transmit = if_nulltransmit;
ifp->if_ioctl = if_nullioctl;
ifp->if_init = if_nullinit;
ifp->if_stop = if_nullstop;
@@ -2667,28 +2678,42 @@
}
/*
+ * wrapper function for the drivers which doesn't have if_transmit().
+ */
+int
+if_transmit(struct ifnet *ifp, struct mbuf *m)
+{
+ int s, error;
+
+ s = splnet();
+
+ IFQ_ENQUEUE(&ifp->if_snd, m, error);
+ if (error != 0) {
+ /* mbuf is already freed */
+ goto out;
+ }
+
+ ifp->if_obytes += m->m_pkthdr.len;;
+ if (m->m_flags & M_MCAST)
+ ifp->if_omcasts++;
+
+ if ((ifp->if_flags & IFF_OACTIVE) == 0)
+ (*ifp->if_start)(ifp);
+out:
+ splx(s);
+
+ return error;
+}
+
+/*
* Queue message on interface, and start output if interface
* not yet active.
*/
int
ifq_enqueue(struct ifnet *ifp, struct mbuf *m)
{
- int len = m->m_pkthdr.len;
- int mflags = m->m_flags;
- int s = splnet();
- int error;
-
- IFQ_ENQUEUE(&ifp->if_snd, m, error);
- if (error != 0)
- goto out;
- ifp->if_obytes += len;
- if (mflags & M_MCAST)
- ifp->if_omcasts++;
- if ((ifp->if_flags & IFF_OACTIVE) == 0)
- (*ifp->if_start)(ifp);
-out:
- splx(s);
- return error;
+
+ return (*ifp->if_transmit)(ifp, m);
}
/*
diff -r 541dcfa061ae -r f30afaf7eabc sys/net/if.h
--- a/sys/net/if.h Thu Apr 28 01:20:31 2016 +0000
+++ b/sys/net/if.h Thu Apr 28 01:37:17 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.h,v 1.202 2016/04/28 00:16:56 ozaki-r Exp $ */
+/* $NetBSD: if.h,v 1.203 2016/04/28 01:37:17 knakahara Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -272,6 +272,8 @@
(struct ifnet *, struct mbuf *);
void (*if_start) /* initiate output routine */
(struct ifnet *);
+ int (*if_transmit) /* output routine (direct) */
+ (struct ifnet *, struct mbuf *);
int (*if_ioctl) /* ioctl routine */
(struct ifnet *, u_long, void *);
int (*if_init) /* init routine */
@@ -939,6 +941,8 @@
void if_clone_attach(struct if_clone *);
void if_clone_detach(struct if_clone *);
+int if_transmit(struct ifnet *, struct mbuf *);
+
int ifq_enqueue(struct ifnet *, struct mbuf *);
int ifq_enqueue2(struct ifnet *, struct ifqueue *, struct mbuf *);
@@ -956,6 +960,7 @@
const struct sockaddr *, const struct rtentry *);
void if_nullinput(struct ifnet *, struct mbuf *);
void if_nullstart(struct ifnet *);
+int if_nulltransmit(struct ifnet *, struct mbuf *);
int if_nullioctl(struct ifnet *, u_long, void *);
int if_nullinit(struct ifnet *);
void if_nullstop(struct ifnet *, int);
diff -r 541dcfa061ae -r f30afaf7eabc sys/net/if_bridge.c
--- a/sys/net/if_bridge.c Thu Apr 28 01:20:31 2016 +0000
+++ b/sys/net/if_bridge.c Thu Apr 28 01:37:17 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bridge.c,v 1.120 2016/04/28 00:16:56 ozaki-r Exp $ */
+/* $NetBSD: if_bridge.c,v 1.121 2016/04/28 01:37:17 knakahara Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.120 2016/04/28 00:16:56 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.121 2016/04/28 01:37:17 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_bridge_ipf.h"
@@ -1381,8 +1381,7 @@
len = m->m_pkthdr.len;
mflags = m->m_flags;
- IFQ_ENQUEUE(&dst_ifp->if_snd, m, error);
-
+ error = (*dst_ifp->if_transmit)(dst_ifp, m);
if (error) {
/* mbuf is already freed */
sc->sc_if.if_oerrors++;
@@ -1391,16 +1390,8 @@
sc->sc_if.if_opackets++;
sc->sc_if.if_obytes += len;
-
- dst_ifp->if_obytes += len;
-
- if (mflags & M_MCAST) {
+ if (mflags & M_MCAST)
sc->sc_if.if_omcasts++;
- dst_ifp->if_omcasts++;
- }
-
- if ((dst_ifp->if_flags & IFF_OACTIVE) == 0)
- (*dst_ifp->if_start)(dst_ifp);
}
/*
diff -r 541dcfa061ae -r f30afaf7eabc sys/net/if_ieee1394subr.c
--- a/sys/net/if_ieee1394subr.c Thu Apr 28 01:20:31 2016 +0000
+++ b/sys/net/if_ieee1394subr.c Thu Apr 28 01:37:17 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ieee1394subr.c,v 1.54 2016/04/28 00:16:56 ozaki-r Exp $ */
+/* $NetBSD: if_ieee1394subr.c,v 1.55 2016/04/28 01:37:17 knakahara 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.54 2016/04/28 00:16:56 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.55 2016/04/28 01:37:17 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -88,7 +88,7 @@
{
uint16_t etype = 0;
struct mbuf *m;
- int s, hdrlen, error = 0;
+ int hdrlen, error = 0;
struct mbuf *mcopy = NULL;
struct ieee1394_hwaddr *hwdst, baddr;
const struct ieee1394_hwaddr *myaddr;
@@ -218,26 +218,15 @@
if (m0 == NULL)
senderr(ENOBUFS);
- s = splnet();
- ifp->if_obytes += m0->m_pkthdr.len;
- if (m0->m_flags & M_MCAST)
- ifp->if_omcasts++;
while ((m = m0) != NULL) {
m0 = m->m_nextpkt;
- if (m == NULL) {
- splx(s);
- senderr(ENOBUFS);
- }
- IFQ_ENQUEUE(&ifp->if_snd, m, error);
+
+ error = (*ifp->if_transmit)(ifp, m);
if (error) {
/* mbuf is already freed */
- splx(s);
goto bad;
}
}
- if ((ifp->if_flags & IFF_OACTIVE) == 0)
- (*ifp->if_start)(ifp);
- splx(s);
return 0;
bad:
Home |
Main Index |
Thread Index |
Old Index