summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2013-08-24 20:26:41 +0000
committerandre <andre@FreeBSD.org>2013-08-24 20:26:41 +0000
commite7f914a8b6e8ce35b1cd18c6932dcfae4360d5fa (patch)
tree493e0440212e0ba3664b86e79a24ea41a0f4057d
parentf53205fcfa3664184b4a8f18b12f4911f2a948d3 (diff)
downloadFreeBSD-src-e7f914a8b6e8ce35b1cd18c6932dcfae4360d5fa.zip
FreeBSD-src-e7f914a8b6e8ce35b1cd18c6932dcfae4360d5fa.tar.gz
Compact m_hdr by packing the type and flags fields into one uint32_t.
The mbuf type is an enumerator with only a handful of types in use and thus reduced from int to 8bits allowing for 255 types to be specified. Only 5 types have been in use for a long time. The flags field gets the remaining 24 bits with 12 bits for global persistent flags and 12 bits for protocol/layer specific overlays. Some of the global flags/functionality can be moved to the csum_flags or ext_flags bits in the future. MT_VENDOR[1-4] and MT_EXP[1-4] types for vendor-internal and experimental local mapping are added. The size of m_hdr shrinks from 24/40 to 20/32bytes (32/64bit architectures). Sponsored by: The FreeBSD Foundation
-rw-r--r--sys/sys/mbuf.h34
1 files changed, 22 insertions, 12 deletions
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index 4e6e59e..ed56ea5 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -82,23 +82,18 @@ struct mb_args {
};
#endif /* _KERNEL */
-#if defined(__LP64__)
-#define M_HDR_PAD 6
-#else
-#define M_HDR_PAD 2
-#endif
-
/*
* Header present at the beginning of every mbuf.
+ * Size ILP32: 20
+ * LP64: 32
*/
struct m_hdr {
struct mbuf *mh_next; /* next buffer in chain */
struct mbuf *mh_nextpkt; /* next chain in queue/record */
caddr_t mh_data; /* location of data */
- int mh_len; /* amount of data in this mbuf */
- int mh_flags; /* flags; see below */
- short mh_type; /* type of data in this mbuf */
- uint8_t pad[M_HDR_PAD];/* word align */
+ int32_t mh_len; /* amount of data in this mbuf */
+ uint32_t mh_type:8, /* type of data in this mbuf */
+ mh_flags:24; /* flags; see below */
};
/*
@@ -206,7 +201,10 @@ struct mbuf {
#define m_dat M_dat.M_databuf
/*
- * mbuf flags.
+ * mbuf flags of global significance and layer crossing.
+ * Those of only protocol/layer specific significance are to be mapped
+ * to M_PROTO[1-12] and cleared at layer handoff boundaries.
+ * NB: Limited to the lower 24 bits.
*/
#define M_EXT 0x00000001 /* has associated external storage */
#define M_PKTHDR 0x00000002 /* start of record */
@@ -430,12 +428,24 @@ struct mbuf {
#define CSUM_FRAGMENT 0x0 /* Unused */
/*
- * mbuf types.
+ * mbuf types describing the content of the mbuf (including external storage).
*/
#define MT_NOTMBUF 0 /* USED INTERNALLY ONLY! Object is not mbuf */
#define MT_DATA 1 /* dynamic (data) allocation */
#define MT_HEADER MT_DATA /* packet header, use M_PKTHDR instead */
+
+#define MT_VENDOR1 4 /* for vendor-internal use */
+#define MT_VENDOR2 5 /* for vendor-internal use */
+#define MT_VENDOR3 6 /* for vendor-internal use */
+#define MT_VENDOR4 7 /* for vendor-internal use */
+
#define MT_SONAME 8 /* socket name */
+
+#define MT_EXP1 9 /* for experimental use */
+#define MT_EXP2 10 /* for experimental use */
+#define MT_EXP3 11 /* for experimental use */
+#define MT_EXP4 12 /* for experimental use */
+
#define MT_CONTROL 14 /* extra-data protocol message */
#define MT_OOBDATA 15 /* expedited data */
#define MT_NTYPES 16 /* number of mbuf types for mbtypes[] */
OpenPOWER on IntegriCloud