+/*
+ * On platforms which require strict alignment (currently for anything but
+ * i386 or x86_64), this macro checks whether the data pointer of an mbuf
+ * is 32-bit aligned (this is the expected minimum alignment for protocol
+ * headers), and assert otherwise.
+ */
+#if defined(__i386__) || defined(__x86_64__)
+#define MBUF_STRICT_DATA_ALIGNMENT_CHECK_32(_m)
+#else /* !__i386__ && !__x86_64__ */
+#define MBUF_STRICT_DATA_ALIGNMENT_CHECK_32(_m) do { \
+ if (!IS_P2ALIGNED((_m)->m_data, sizeof (u_int32_t))) { \
+ if (((_m)->m_flags & M_PKTHDR) && \
+ (_m)->m_pkthdr.rcvif != NULL) { \
+ panic_plain("\n%s: mbuf %p data ptr %p is not " \
+ "32-bit aligned [%s: alignerrs=%lld]\n", \
+ __func__, (_m), (_m)->m_data, \
+ if_name((_m)->m_pkthdr.rcvif), \
+ (_m)->m_pkthdr.rcvif->if_alignerrs); \
+ } else { \
+ panic_plain("\n%s: mbuf %p data ptr %p is not " \
+ "32-bit aligned\n", \
+ __func__, (_m), (_m)->m_data); \
+ } \
+ } \
+} while (0)
+#endif /* !__i386__ && !__x86_64__ */
+
+/* Maximum number of MBUF_SC values (excluding MBUF_SC_UNSPEC) */
+#define MBUF_SC_MAX_CLASSES 10
+
+/*
+ * These conversion macros rely on the corresponding MBUF_SC and
+ * MBUF_TC values in order to establish the following mapping:
+ *
+ * MBUF_SC_BK_SYS ] ==> MBUF_TC_BK
+ * MBUF_SC_BK ]
+ *
+ * MBUF_SC_BE ] ==> MBUF_TC_BE
+ * MBUF_SC_RD ]
+ * MBUF_SC_OAM ]
+ *
+ * MBUF_SC_AV ] ==> MBUF_TC_VI
+ * MBUF_SC_RV ]
+ * MBUF_SC_VI ]
+ *
+ * MBUF_SC_VO ] ==> MBUF_TC_VO
+ * MBUF_SC_CTL ]
+ *
+ * The values assigned to each service class allows for a fast mapping to
+ * the corresponding MBUF_TC traffic class values, as well as to retrieve the
+ * assigned index; therefore care must be taken when comparing against these
+ * values. Use the corresponding class and index macros to retrieve the
+ * corresponding portion, and never assume that a higher class corresponds
+ * to a higher index.
+ */
+#define MBUF_SCVAL(x) ((x) & 0xffff)
+#define MBUF_SCIDX(x) ((((x) >> 16) & 0xff) >> 3)
+#define MBUF_SC2TC(_sc) (MBUF_SCVAL(_sc) >> 7)
+#define MBUF_TC2SCVAL(_tc) ((_tc) << 7)
+#define IS_MBUF_SC_BACKGROUND(_sc) (((_sc) == MBUF_SC_BK_SYS) || \
+ ((_sc) == MBUF_SC_BK))
+#define IS_MBUF_SC_REALTIME(_sc) ((_sc) >= MBUF_SC_AV && (_sc) <= MBUF_SC_VO)
+#define IS_MBUF_SC_BESTEFFORT(_sc) ((_sc) == MBUF_SC_BE || \
+ (_sc) == MBUF_SC_RD || (_sc) == MBUF_SC_OAM)
+
+#define SCIDX_BK_SYS MBUF_SCIDX(MBUF_SC_BK_SYS)
+#define SCIDX_BK MBUF_SCIDX(MBUF_SC_BK)
+#define SCIDX_BE MBUF_SCIDX(MBUF_SC_BE)
+#define SCIDX_RD MBUF_SCIDX(MBUF_SC_RD)
+#define SCIDX_OAM MBUF_SCIDX(MBUF_SC_OAM)
+#define SCIDX_AV MBUF_SCIDX(MBUF_SC_AV)
+#define SCIDX_RV MBUF_SCIDX(MBUF_SC_RV)
+#define SCIDX_VI MBUF_SCIDX(MBUF_SC_VI)
+#define SCIDX_VO MBUF_SCIDX(MBUF_SC_VO)
+#define SCIDX_CTL MBUF_SCIDX(MBUF_SC_CTL)
+
+#define SCVAL_BK_SYS MBUF_SCVAL(MBUF_SC_BK_SYS)
+#define SCVAL_BK MBUF_SCVAL(MBUF_SC_BK)
+#define SCVAL_BE MBUF_SCVAL(MBUF_SC_BE)
+#define SCVAL_RD MBUF_SCVAL(MBUF_SC_RD)
+#define SCVAL_OAM MBUF_SCVAL(MBUF_SC_OAM)
+#define SCVAL_AV MBUF_SCVAL(MBUF_SC_AV)
+#define SCVAL_RV MBUF_SCVAL(MBUF_SC_RV)
+#define SCVAL_VI MBUF_SCVAL(MBUF_SC_VI)
+#define SCVAL_VO MBUF_SCVAL(MBUF_SC_VO)
+#define SCVAL_CTL MBUF_SCVAL(MBUF_SC_CTL)
+
+#define MBUF_VALID_SC(c) \
+ (c == MBUF_SC_BK_SYS || c == MBUF_SC_BK || c == MBUF_SC_BE || \
+ c == MBUF_SC_RD || c == MBUF_SC_OAM || c == MBUF_SC_AV || \
+ c == MBUF_SC_RV || c == MBUF_SC_VI || c == MBUF_SC_VO || \
+ c == MBUF_SC_CTL)
+
+#define MBUF_VALID_SCIDX(c) \
+ (c == SCIDX_BK_SYS || c == SCIDX_BK || c == SCIDX_BE || \
+ c == SCIDX_RD || c == SCIDX_OAM || c == SCIDX_AV || \
+ c == SCIDX_RV || c == SCIDX_VI || c == SCIDX_VO || \
+ c == SCIDX_CTL)
+
+#define MBUF_VALID_SCVAL(c) \
+ (c == SCVAL_BK_SYS || c == SCVAL_BK || c == SCVAL_BE || \
+ c == SCVAL_RD || c == SCVAL_OAM || c == SCVAL_AV || \
+ c == SCVAL_RV || c == SCVAL_VI || c == SCVAL_VO || \
+ c == SCVAL_CTL)
+
+extern unsigned char *mbutl; /* start VA of mbuf pool */
+extern unsigned char *embutl; /* end VA of mbuf pool */
+extern unsigned int nmbclusters; /* number of mapped clusters */
+extern int njcl; /* # of jumbo clusters */
+extern int njclbytes; /* size of a jumbo cluster */
+extern int max_hdr; /* largest link+protocol header */
+extern int max_datalen; /* MHLEN - max_hdr */
+
+/* Use max_linkhdr instead of _max_linkhdr */
+extern int _max_linkhdr; /* largest link-level header */
+
+/* Use max_protohdr instead of _max_protohdr */
+extern int _max_protohdr; /* largest protocol header */