Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys IFQ_ENQUEUE refactor (1/3) : add altq_pktattr fields to ...
details: https://anonhg.NetBSD.org/src/rev/96f719e95d22
branches: trunk
changeset: 344789:96f719e95d22
user: knakahara <knakahara%NetBSD.org@localhost>
date: Wed Apr 20 08:56:32 2016 +0000
description:
IFQ_ENQUEUE refactor (1/3) : add altq_pktattr fields to m_pkthdr
Reviewed by joerg@n.o and tls@n.o, thanks.
diffstat:
sys/net/if.h | 24 +++++++++++++++---------
sys/net/if_ethersubr.c | 18 +++++++++---------
sys/sys/mbuf.h | 18 +++++++++++++++++-
3 files changed, 41 insertions(+), 19 deletions(-)
diffs (159 lines):
diff -r 4820453e868f -r 96f719e95d22 sys/net/if.h
--- a/sys/net/if.h Wed Apr 20 08:54:38 2016 +0000
+++ b/sys/net/if.h Wed Apr 20 08:56:32 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.h,v 1.198 2016/02/19 20:05:43 roy Exp $ */
+/* $NetBSD: if.h,v 1.199 2016/04/20 08:56:32 knakahara Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -757,12 +757,17 @@
#define ALTQ_DECL(x) x
#define ALTQ_COMMA ,
-#define IFQ_ENQUEUE(ifq, m, pattr, err) \
+#define IFQ_ENQUEUE(ifq, m, unused, err) \
do { \
+ struct altq_pktattr *_unused __unused = unused; \
IFQ_LOCK((ifq)); \
- if (ALTQ_IS_ENABLED((ifq))) \
- ALTQ_ENQUEUE((ifq), (m), (pattr), (err)); \
- else { \
+ if (ALTQ_IS_ENABLED((ifq))) { \
+ struct altq_pktattr pattr; \
+ pattr.pattr_class = (m)->m_pkthdr.pattr_class; \
+ pattr.pattr_af = (m)->m_pkthdr.pattr_af; \
+ pattr.pattr_hdr = (m)->m_pkthdr.pattr_hdr; \
+ ALTQ_ENQUEUE((ifq), (m), &pattr, (err)); \
+ } else { \
if (IF_QFULL((ifq))) { \
m_freem((m)); \
(err) = ENOBUFS; \
@@ -815,15 +820,16 @@
(ifq)->altq_flags |= ALTQF_READY; \
} while (/*CONSTCOND*/ 0)
-#define IFQ_CLASSIFY(ifq, m, af, pattr) \
+#define IFQ_CLASSIFY(ifq, m, af, unused) \
do { \
+ struct altq_pktattr *_unused __unused = unused; \
IFQ_LOCK((ifq)); \
if (ALTQ_IS_ENABLED((ifq))) { \
if (ALTQ_NEEDS_CLASSIFY((ifq))) \
- (pattr)->pattr_class = (*(ifq)->altq_classify) \
+ m->m_pkthdr.pattr_class = (*(ifq)->altq_classify) \
((ifq)->altq_clfier, (m), (af)); \
- (pattr)->pattr_af = (af); \
- (pattr)->pattr_hdr = mtod((m), void *); \
+ m->m_pkthdr.pattr_af = (af); \
+ m->m_pkthdr.pattr_hdr = mtod((m), void *); \
} \
IFQ_UNLOCK((ifq)); \
} while (/*CONSTCOND*/ 0)
diff -r 4820453e868f -r 96f719e95d22 sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c Wed Apr 20 08:54:38 2016 +0000
+++ b/sys/net/if_ethersubr.c Wed Apr 20 08:56:32 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ethersubr.c,v 1.218 2016/04/15 01:31:29 ozaki-r Exp $ */
+/* $NetBSD: if_ethersubr.c,v 1.219 2016/04/20 08:56:32 knakahara 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.218 2016/04/15 01:31:29 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.219 2016/04/20 08:56:32 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -418,7 +418,7 @@
* address family/header pointer in the pktattr.
*/
if (ALTQ_IS_ENABLED(&ifp->if_snd))
- altq_etherclassify(&ifp->if_snd, m, &pktattr);
+ altq_etherclassify(&ifp->if_snd, m, NULL);
#endif
return ifq_enqueue(ifp, m ALTQ_COMMA ALTQ_DECL(&pktattr));
@@ -504,10 +504,10 @@
hdr = mtod(m, void *);
if (ALTQ_NEEDS_CLASSIFY(ifq))
- pktattr->pattr_class =
+ m->m_pkthdr.pattr_class =
(*ifq->altq_classify)(ifq->altq_clfier, m, af);
- pktattr->pattr_af = af;
- pktattr->pattr_hdr = hdr;
+ m->m_pkthdr.pattr_af = af;
+ m->m_pkthdr.pattr_hdr = hdr;
m->m_data -= hlen;
m->m_len += hlen;
@@ -515,9 +515,9 @@
return;
bad:
- pktattr->pattr_class = NULL;
- pktattr->pattr_hdr = NULL;
- pktattr->pattr_af = AF_UNSPEC;
+ m->m_pkthdr.pattr_class = NULL;
+ m->m_pkthdr.pattr_hdr = NULL;
+ m->m_pkthdr.pattr_af = AF_UNSPEC;
}
#endif /* ALTQ */
diff -r 4820453e868f -r 96f719e95d22 sys/sys/mbuf.h
--- a/sys/sys/mbuf.h Wed Apr 20 08:54:38 2016 +0000
+++ b/sys/sys/mbuf.h Wed Apr 20 08:56:32 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mbuf.h,v 1.160 2016/04/20 08:50:43 knakahara Exp $ */
+/* $NetBSD: mbuf.h,v 1.161 2016/04/20 08:56:32 knakahara Exp $ */
/*-
* Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
@@ -75,6 +75,7 @@
#include <sys/queue.h>
#if defined(_KERNEL)
#include <sys/percpu_types.h>
+#include <sys/socket.h> /* for AF_UNSPEC */
#endif /* defined(_KERNEL) */
/* For offsetof() */
@@ -169,6 +170,9 @@
* be bit-wise inverted (the final step in the calculation of an IP
* checksum) -- this is so we can accumulate the checksum for fragmented
* packets during reassembly.
+ *
+ * Size ILP32: 36
+ * LP64: 56
*/
struct pkthdr {
struct ifnet *rcvif; /* rcv interface */
@@ -177,6 +181,14 @@
int csum_flags; /* checksum flags */
uint32_t csum_data; /* checksum data */
u_int segsz; /* segment size */
+
+ /*
+ * Following three fields are open-coded struct altq_pktattr
+ * to rearrange struct pkthdr fields flexibly.
+ */
+ void *pattr_class; /* ALTQ: sched class set by classifier */
+ void *pattr_hdr; /* ALTQ: saved header position in mbuf */
+ int pattr_af; /* ALTQ: address family */
};
/*
@@ -964,6 +976,10 @@
m->m_pkthdr.csum_flags = 0;
m->m_pkthdr.csum_data = 0;
SLIST_INIT(&m->m_pkthdr.tags);
+
+ m->m_pkthdr.pattr_class = NULL;
+ m->m_pkthdr.pattr_af = AF_UNSPEC;
+ m->m_pkthdr.pattr_hdr = NULL;
}
void m_print(const struct mbuf *, const char *, void (*)(const char *, ...)
Home |
Main Index |
Thread Index |
Old Index