+m_tag_next(struct mbuf *m, struct m_tag *t)
+{
+#pragma unused(m)
+ VERIFY(t != NULL);
+ VERIFY(t->m_tag_cookie == M_TAG_VALID_PATTERN);
+
+ return (SLIST_NEXT(t, m_tag_link));
+}
+
+int
+m_set_traffic_class(struct mbuf *m, mbuf_traffic_class_t tc)
+{
+ u_int32_t val = MBUF_TC2SCVAL(tc); /* just the val portion */
+
+ return (m_set_service_class(m, m_service_class_from_val(val)));
+}
+
+mbuf_traffic_class_t
+m_get_traffic_class(struct mbuf *m)
+{
+ return (MBUF_SC2TC(m_get_service_class(m)));
+}
+
+int
+m_set_service_class(struct mbuf *m, mbuf_svc_class_t sc)
+{
+ int error = 0;
+
+ VERIFY(m->m_flags & M_PKTHDR);
+
+ if (MBUF_VALID_SC(sc))
+ m->m_pkthdr.pkt_svc = sc;
+ else
+ error = EINVAL;
+
+ return (error);
+}
+
+mbuf_svc_class_t
+m_get_service_class(struct mbuf *m)
+{
+ mbuf_svc_class_t sc;
+
+ VERIFY(m->m_flags & M_PKTHDR);
+
+ if (MBUF_VALID_SC(m->m_pkthdr.pkt_svc))
+ sc = m->m_pkthdr.pkt_svc;
+ else
+ sc = MBUF_SC_BE;
+
+ return (sc);
+}
+
+mbuf_svc_class_t
+m_service_class_from_idx(u_int32_t i)
+{
+ mbuf_svc_class_t sc = MBUF_SC_BE;
+
+ switch (i) {
+ case SCIDX_BK_SYS:
+ return (MBUF_SC_BK_SYS);
+
+ case SCIDX_BK:
+ return (MBUF_SC_BK);
+
+ case SCIDX_BE:
+ return (MBUF_SC_BE);
+
+ case SCIDX_RD:
+ return (MBUF_SC_RD);
+
+ case SCIDX_OAM:
+ return (MBUF_SC_OAM);
+
+ case SCIDX_AV:
+ return (MBUF_SC_AV);
+
+ case SCIDX_RV:
+ return (MBUF_SC_RV);
+
+ case SCIDX_VI:
+ return (MBUF_SC_VI);
+
+ case SCIDX_VO:
+ return (MBUF_SC_VO);
+
+ case SCIDX_CTL:
+ return (MBUF_SC_CTL);
+
+ default:
+ break;
+ }
+
+ VERIFY(0);
+ /* NOTREACHED */
+ return (sc);
+}
+
+mbuf_svc_class_t
+m_service_class_from_val(u_int32_t v)
+{
+ mbuf_svc_class_t sc = MBUF_SC_BE;
+
+ switch (v) {
+ case SCVAL_BK_SYS:
+ return (MBUF_SC_BK_SYS);
+
+ case SCVAL_BK:
+ return (MBUF_SC_BK);
+
+ case SCVAL_BE:
+ return (MBUF_SC_BE);
+
+ case SCVAL_RD:
+ return (MBUF_SC_RD);
+
+ case SCVAL_OAM:
+ return (MBUF_SC_OAM);
+
+ case SCVAL_AV:
+ return (MBUF_SC_AV);
+
+ case SCVAL_RV:
+ return (MBUF_SC_RV);
+
+ case SCVAL_VI:
+ return (MBUF_SC_VI);
+
+ case SCVAL_VO:
+ return (MBUF_SC_VO);
+
+ case SCVAL_CTL:
+ return (MBUF_SC_CTL);
+
+ default:
+ break;
+ }
+
+ VERIFY(0);
+ /* NOTREACHED */
+ return (sc);
+}
+
+uint16_t
+m_adj_sum16(struct mbuf *m, uint32_t start, uint32_t ulpoff, uint32_t sum)