/*
- * Copyright (c) 2007-2012 Apple Inc. All rights reserved.
+ * Copyright (c) 2007-2013 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
static int priq_throttle(struct priq_if *, cqrq_throttle_t *);
static int priq_resumeq(struct priq_if *, struct priq_class *);
static int priq_suspendq(struct priq_if *, struct priq_class *);
+static int priq_stat_sc(struct priq_if *, cqrq_stat_sc_t *);
static inline struct priq_class *priq_clh_to_clp(struct priq_if *, u_int32_t);
static const char *priq_style(struct priq_if *);
VERIFY(cl == NULL || cl->cl_pif == pif);
if (cl == NULL) {
+#if PF_ALTQ
cl = priq_clh_to_clp(pif, t->pftag_qid);
+#else /* !PF_ALTQ */
+ cl = priq_clh_to_clp(pif, 0);
+#endif /* !PF_ALTQ */
if (cl == NULL) {
cl = pif->pif_default;
if (cl == NULL) {
}
}
IFCQ_INC_LEN(ifq);
+ IFCQ_INC_BYTES(ifq, len);
/* class is now active; indicate it as such */
if (!pktsched_bit_tst(pri, &pif->pif_bitmap))
len = m_pktlen(m);
IFCQ_DEC_LEN(ifq);
+ IFCQ_DEC_BYTES(ifq, len);
if (qempty(&cl->cl_q)) {
cl->cl_period++;
/* class is now inactive; indicate it as such */
return (CLASSQEQ_DROPPED);
}
+#if PF_ECN
if (cl->cl_flags & PRCF_CLEARDSCP)
write_dsfield(m, t, 0);
+#endif /* PF_ECN */
_addq(&cl->cl_q, m);
return (0);
}
+static int
+priq_stat_sc(struct priq_if *pif, cqrq_stat_sc_t *sr)
+{
+ struct ifclassq *ifq = pif->pif_ifq;
+ struct priq_class *cl;
+ u_int32_t i;
+
+ IFCQ_LOCK_ASSERT_HELD(ifq);
+
+ VERIFY(sr->sc == MBUF_SC_UNSPEC || MBUF_VALID_SC(sr->sc));
+
+ i = MBUF_SCIDX(sr->sc);
+ VERIFY(i < IFCQ_SC_MAX);
+
+ cl = ifq->ifcq_disc_slots[i].cl;
+ sr->packets = qlen(&cl->cl_q);
+ sr->bytes = qsize(&cl->cl_q);
+
+ return (0);
+}
+
/* convert a class handle to the corresponding class pointer */
static inline struct priq_class *
priq_clh_to_clp(struct priq_if *pif, u_int32_t chandle)
case CLASSQRQ_THROTTLE:
err = priq_throttle(pif, (cqrq_throttle_t *)arg);
break;
+
+ case CLASSQRQ_STAT_SC:
+ err = priq_stat_sc(pif, (cqrq_stat_sc_t *)arg);
+ break;
}
return (err);
}
err = ifclassq_attach(ifq, PKTSCHEDT_PRIQ, pif,
priq_enqueue_ifclassq, priq_dequeue_ifclassq, NULL,
- priq_request_ifclassq);
+ NULL, priq_request_ifclassq);
/* cache these for faster lookup */
if (err == 0) {
{
struct ifclassq *ifq = pif->pif_ifq;
struct priq_class *cl;
- int err;
+ int err = 0;
IFCQ_LOCK_ASSERT_HELD(ifq);
VERIFY(!(pif->pif_flags & PRIQIFF_ALTQ));