Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Toward NET_MPSAFE-on in future, if_snd uses if_snd->...
details: https://anonhg.NetBSD.org/src/rev/2ca0e5cbe015
branches: trunk
changeset: 346619:2ca0e5cbe015
user: knakahara <knakahara%NetBSD.org@localhost>
date: Fri Jul 22 07:09:40 2016 +0000
description:
Toward NET_MPSAFE-on in future, if_snd uses if_snd->ifq_lock by default.
That can reduce confusing difference between NET_MPSAFE on and off.
diffstat:
sys/net/if.c | 11 +++--------
sys/net/if.h | 41 +++++++++++++++++++----------------------
2 files changed, 22 insertions(+), 30 deletions(-)
diffs (177 lines):
diff -r ba6ac1d27284 -r 2ca0e5cbe015 sys/net/if.c
--- a/sys/net/if.c Fri Jul 22 04:08:10 2016 +0000
+++ b/sys/net/if.c Fri Jul 22 07:09:40 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.354 2016/07/07 09:32:02 ozaki-r Exp $ */
+/* $NetBSD: if.c,v 1.355 2016/07/22 07:09:40 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.354 2016/07/07 09:32:02 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.355 2016/07/22 07:09:40 knakahara Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -637,11 +637,7 @@
ifp->if_snd.altq_ifp = ifp;
#endif
-#ifdef NET_MPSAFE
ifp->if_snd.ifq_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET);
-#else
- ifp->if_snd.ifq_lock = NULL;
-#endif
ifp->if_pfil = pfil_head_create(PFIL_TYPE_IFNET, ifp);
(void)pfil_run_hooks(if_pfil,
@@ -1160,8 +1156,7 @@
altq_detach(&ifp->if_snd);
#endif
- if (ifp->if_snd.ifq_lock)
- mutex_obj_free(ifp->if_snd.ifq_lock);
+ mutex_obj_free(ifp->if_snd.ifq_lock);
#if NCARP > 0
/* Remove the interface from any carp group it is a part of. */
diff -r ba6ac1d27284 -r 2ca0e5cbe015 sys/net/if.h
--- a/sys/net/if.h Fri Jul 22 04:08:10 2016 +0000
+++ b/sys/net/if.h Fri Jul 22 07:09:40 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.h,v 1.221 2016/07/11 02:14:27 ozaki-r Exp $ */
+/* $NetBSD: if.h,v 1.222 2016/07/22 07:09:40 knakahara Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -511,9 +511,6 @@
#define IF_AFDATA_UNLOCK_ASSERT(ifp) \
KASSERT(!rw_lock_held((ifp)->if_afdata_lock))
-#define IFQ_LOCK(_ifq) if ((_ifq)->ifq_lock) mutex_enter((_ifq)->ifq_lock)
-#define IFQ_UNLOCK(_ifq) if ((_ifq)->ifq_lock) mutex_exit((_ifq)->ifq_lock)
-
/*
* Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
* input routines have queues of messages stored on ifqueue structures
@@ -804,7 +801,7 @@
#ifdef ALTQ
#define IFQ_ENQUEUE(ifq, m, err) \
do { \
- IFQ_LOCK((ifq)); \
+ mutex_enter((ifq)->ifq_lock); \
if (ALTQ_IS_ENABLED((ifq))) \
ALTQ_ENQUEUE((ifq), (m), (err)); \
else { \
@@ -818,41 +815,41 @@
} \
if ((err)) \
(ifq)->ifq_drops++; \
- IFQ_UNLOCK((ifq)); \
+ mutex_exit((ifq)->ifq_lock); \
} while (/*CONSTCOND*/ 0)
#define IFQ_DEQUEUE(ifq, m) \
do { \
- IFQ_LOCK((ifq)); \
+ mutex_enter((ifq)->ifq_lock); \
if (TBR_IS_ENABLED((ifq))) \
(m) = tbr_dequeue((ifq), ALTDQ_REMOVE); \
else if (ALTQ_IS_ENABLED((ifq))) \
ALTQ_DEQUEUE((ifq), (m)); \
else \
IF_DEQUEUE((ifq), (m)); \
- IFQ_UNLOCK((ifq)); \
+ mutex_exit((ifq)->ifq_lock); \
} while (/*CONSTCOND*/ 0)
#define IFQ_POLL(ifq, m) \
do { \
- IFQ_LOCK((ifq)); \
+ mutex_enter((ifq)->ifq_lock); \
if (TBR_IS_ENABLED((ifq))) \
(m) = tbr_dequeue((ifq), ALTDQ_POLL); \
else if (ALTQ_IS_ENABLED((ifq))) \
ALTQ_POLL((ifq), (m)); \
else \
IF_POLL((ifq), (m)); \
- IFQ_UNLOCK((ifq)); \
+ mutex_exit((ifq)->ifq_lock); \
} while (/*CONSTCOND*/ 0)
#define IFQ_PURGE(ifq) \
do { \
- IFQ_LOCK((ifq)); \
+ mutex_enter((ifq)->ifq_lock); \
if (ALTQ_IS_ENABLED((ifq))) \
ALTQ_PURGE((ifq)); \
else \
IF_PURGE((ifq)); \
- IFQ_UNLOCK((ifq)); \
+ mutex_exit((ifq)->ifq_lock); \
} while (/*CONSTCOND*/ 0)
#define IFQ_SET_READY(ifq) \
@@ -862,7 +859,7 @@
#define IFQ_CLASSIFY(ifq, m, af) \
do { \
- IFQ_LOCK((ifq)); \
+ mutex_enter((ifq)->ifq_lock); \
if (ALTQ_IS_ENABLED((ifq))) { \
if (ALTQ_NEEDS_CLASSIFY((ifq))) \
m->m_pkthdr.pattr_class = (*(ifq)->altq_classify) \
@@ -870,12 +867,12 @@
m->m_pkthdr.pattr_af = (af); \
m->m_pkthdr.pattr_hdr = mtod((m), void *); \
} \
- IFQ_UNLOCK((ifq)); \
+ mutex_exit((ifq)->ifq_lock); \
} while (/*CONSTCOND*/ 0)
#else /* ! ALTQ */
#define IFQ_ENQUEUE(ifq, m, err) \
do { \
- IFQ_LOCK((ifq)); \
+ mutex_enter((ifq)->ifq_lock); \
if (IF_QFULL((ifq))) { \
m_freem((m)); \
(err) = ENOBUFS; \
@@ -885,28 +882,28 @@
} \
if ((err)) \
(ifq)->ifq_drops++; \
- IFQ_UNLOCK((ifq)); \
+ mutex_exit((ifq)->ifq_lock); \
} while (/*CONSTCOND*/ 0)
#define IFQ_DEQUEUE(ifq, m) \
do { \
- IFQ_LOCK((ifq)); \
+ mutex_enter((ifq)->ifq_lock); \
IF_DEQUEUE((ifq), (m)); \
- IFQ_UNLOCK((ifq)); \
+ mutex_exit((ifq)->ifq_lock); \
} while (/*CONSTCOND*/ 0)
#define IFQ_POLL(ifq, m) \
do { \
- IFQ_LOCK((ifq)); \
+ mutex_enter((ifq)->ifq_lock); \
IF_POLL((ifq), (m)); \
- IFQ_UNLOCK((ifq)); \
+ mutex_exit((ifq)->ifq_lock); \
} while (/*CONSTCOND*/ 0)
#define IFQ_PURGE(ifq) \
do { \
- IFQ_LOCK((ifq)); \
+ mutex_enter((ifq)->ifq_lock); \
IF_PURGE((ifq)); \
- IFQ_UNLOCK((ifq)); \
+ mutex_exit((ifq)->ifq_lock); \
} while (/*CONSTCOND*/ 0)
#define IFQ_SET_READY(ifq) /* nothing */
Home |
Main Index |
Thread Index |
Old Index