1*043036a2SApple OSS Distributions /* 2*043036a2SApple OSS Distributions * Copyright (c) 2016-2021 Apple Inc. All rights reserved. 3*043036a2SApple OSS Distributions * 4*043036a2SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5*043036a2SApple OSS Distributions * 6*043036a2SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 7*043036a2SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 8*043036a2SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 9*043036a2SApple OSS Distributions * compliance with the License. The rights granted to you under the License 10*043036a2SApple OSS Distributions * may not be used to create, or enable the creation or redistribution of, 11*043036a2SApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to 12*043036a2SApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any 13*043036a2SApple OSS Distributions * terms of an Apple operating system software license agreement. 14*043036a2SApple OSS Distributions * 15*043036a2SApple OSS Distributions * Please obtain a copy of the License at 16*043036a2SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file. 17*043036a2SApple OSS Distributions * 18*043036a2SApple OSS Distributions * The Original Code and all software distributed under the License are 19*043036a2SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20*043036a2SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21*043036a2SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22*043036a2SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23*043036a2SApple OSS Distributions * Please see the License for the specific language governing rights and 24*043036a2SApple OSS Distributions * limitations under the License. 25*043036a2SApple OSS Distributions * 26*043036a2SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27*043036a2SApple OSS Distributions */ 28*043036a2SApple OSS Distributions 29*043036a2SApple OSS Distributions #ifndef _NET_CLASSQ_CLASSQ_FQ_CODEL_H 30*043036a2SApple OSS Distributions #define _NET_CLASSQ_CLASSQ_FQ_CODEL_H 31*043036a2SApple OSS Distributions #ifdef PRIVATE 32*043036a2SApple OSS Distributions #ifdef BSD_KERNEL_PRIVATE 33*043036a2SApple OSS Distributions #include <stdbool.h> 34*043036a2SApple OSS Distributions #include <sys/time.h> 35*043036a2SApple OSS Distributions #include <net/flowadv.h> 36*043036a2SApple OSS Distributions #include <net/classq/if_classq.h> 37*043036a2SApple OSS Distributions #if SKYWALK 38*043036a2SApple OSS Distributions #include <skywalk/os_skywalk_private.h> 39*043036a2SApple OSS Distributions #endif /* SKYWALK */ 40*043036a2SApple OSS Distributions 41*043036a2SApple OSS Distributions #ifdef __cplusplus 42*043036a2SApple OSS Distributions extern "C" { 43*043036a2SApple OSS Distributions #endif 44*043036a2SApple OSS Distributions 45*043036a2SApple OSS Distributions #define AQM_KTRACE_AON_FLOW_HIGH_DELAY AQMDBG_CODE(DBG_AQM_ALWAYSON, 0x001) 46*043036a2SApple OSS Distributions #define AQM_KTRACE_AON_THROTTLE AQMDBG_CODE(DBG_AQM_ALWAYSON, 0x002) 47*043036a2SApple OSS Distributions #define AQM_KTRACE_AON_FLOW_OVERWHELMING AQMDBG_CODE(DBG_AQM_ALWAYSON, 0x003) 48*043036a2SApple OSS Distributions #define AQM_KTRACE_AON_FLOW_DQ_STALL AQMDBG_CODE(DBG_AQM_ALWAYSON, 0x004) 49*043036a2SApple OSS Distributions 50*043036a2SApple OSS Distributions #define AQM_KTRACE_STATS_FLOW_ENQUEUE AQMDBG_CODE(DBG_AQM_STATS, 0x001) 51*043036a2SApple OSS Distributions #define AQM_KTRACE_STATS_FLOW_DEQUEUE AQMDBG_CODE(DBG_AQM_STATS, 0x002) 52*043036a2SApple OSS Distributions #define AQM_KTRACE_STATS_FLOW_CTL AQMDBG_CODE(DBG_AQM_STATS, 0x003) 53*043036a2SApple OSS Distributions #define AQM_KTRACE_STATS_FLOW_ALLOC AQMDBG_CODE(DBG_AQM_STATS, 0x004) 54*043036a2SApple OSS Distributions #define AQM_KTRACE_STATS_FLOW_DESTROY AQMDBG_CODE(DBG_AQM_STATS, 0x005) 55*043036a2SApple OSS Distributions #define AQM_KTRACE_STATS_FLOW_REPORT_CE AQMDBG_CODE(DBG_AQM_STATS, 0x006) 56*043036a2SApple OSS Distributions #define AQM_KTRACE_STATS_GET_QLEN AQMDBG_CODE(DBG_AQM_STATS, 0x007) 57*043036a2SApple OSS Distributions #define AQM_KTRACE_TX_NOT_READY AQMDBG_CODE(DBG_AQM_STATS, 0x008) 58*043036a2SApple OSS Distributions #define AQM_KTRACE_TX_PACEMAKER AQMDBG_CODE(DBG_AQM_STATS, 0x009) 59*043036a2SApple OSS Distributions #define AQM_KTRACE_PKT_DROP AQMDBG_CODE(DBG_AQM_STATS, 0x00a) 60*043036a2SApple OSS Distributions #define AQM_KTRACE_OK_TO_DROP AQMDBG_CODE(DBG_AQM_STATS, 0x00b) 61*043036a2SApple OSS Distributions #define AQM_KTRACE_CONGESTION_INC AQMDBG_CODE(DBG_AQM_STATS, 0x00c) 62*043036a2SApple OSS Distributions #define AQM_KTRACE_CONGESTION_NOTIFIED AQMDBG_CODE(DBG_AQM_STATS, 0x00d) 63*043036a2SApple OSS Distributions 64*043036a2SApple OSS Distributions #define AQM_KTRACE_FQ_GRP_SC_IDX(_fq_) \ 65*043036a2SApple OSS Distributions ((_fq_)->fq_group->fqg_index << 4 | (_fq_)->fq_sc_index) 66*043036a2SApple OSS Distributions 67*043036a2SApple OSS Distributions #define FQ_MIN_FC_THRESHOLD_BYTES 7500 68*043036a2SApple OSS Distributions #define FQ_IS_DELAY_HIGH(_fq_) ((_fq_)->fq_flags & FQF_DELAY_HIGH) 69*043036a2SApple OSS Distributions #define FQ_SET_DELAY_HIGH(_fq_) do { \ 70*043036a2SApple OSS Distributions if (!FQ_IS_DELAY_HIGH(_fq_)) { \ 71*043036a2SApple OSS Distributions KDBG(AQM_KTRACE_AON_FLOW_HIGH_DELAY | DBG_FUNC_START, \ 72*043036a2SApple OSS Distributions (_fq_)->fq_flowhash, AQM_KTRACE_FQ_GRP_SC_IDX((_fq_)), \ 73*043036a2SApple OSS Distributions (_fq_)->fq_bytes, (_fq_)->fq_min_qdelay); \ 74*043036a2SApple OSS Distributions } \ 75*043036a2SApple OSS Distributions (_fq_)->fq_flags |= FQF_DELAY_HIGH; \ 76*043036a2SApple OSS Distributions } while (0) 77*043036a2SApple OSS Distributions #define FQ_CLEAR_DELAY_HIGH(_fq_) do { \ 78*043036a2SApple OSS Distributions if (FQ_IS_DELAY_HIGH(_fq_)) { \ 79*043036a2SApple OSS Distributions KDBG(AQM_KTRACE_AON_FLOW_HIGH_DELAY | DBG_FUNC_END, \ 80*043036a2SApple OSS Distributions (_fq_)->fq_flowhash, AQM_KTRACE_FQ_GRP_SC_IDX((_fq_)), \ 81*043036a2SApple OSS Distributions (_fq_)->fq_bytes, (_fq_)->fq_min_qdelay); \ 82*043036a2SApple OSS Distributions } \ 83*043036a2SApple OSS Distributions (_fq_)->fq_flags &= ~FQF_DELAY_HIGH; \ 84*043036a2SApple OSS Distributions } while (0) 85*043036a2SApple OSS Distributions 86*043036a2SApple OSS Distributions #define FQ_IS_ECN_CAPABLE(_fq_) ((_fq_)->fq_flags & FQF_ECN_CAPABLE) 87*043036a2SApple OSS Distributions #define FQ_SET_ECN_CAPABLE(_fq_) do { \ 88*043036a2SApple OSS Distributions (_fq_)->fq_flags |= FQF_ECN_CAPABLE; \ 89*043036a2SApple OSS Distributions } while (0) 90*043036a2SApple OSS Distributions #define FQ_CLEAR_ECN_CAPABLE(_fq_) do { \ 91*043036a2SApple OSS Distributions (_fq_)->fq_flags &= ~FQF_ECN_CAPABLE; \ 92*043036a2SApple OSS Distributions } while (0) 93*043036a2SApple OSS Distributions 94*043036a2SApple OSS Distributions #define FQ_CONGESTION_FEEDBACK_CAPABLE(_fq_) ((_fq_)->fq_flags & FQF_CONGESTION_FEEDBACK) 95*043036a2SApple OSS Distributions #define FQ_ENABLE_CONGESTION_FEEDBACK(_fq_) do { \ 96*043036a2SApple OSS Distributions (_fq_)->fq_flags |= FQF_CONGESTION_FEEDBACK; \ 97*043036a2SApple OSS Distributions } while (0) 98*043036a2SApple OSS Distributions 99*043036a2SApple OSS Distributions #define FQ_IS_OVERWHELMING(_fq_) ((_fq_)->fq_flags & FQF_OVERWHELMING) 100*043036a2SApple OSS Distributions #define FQ_SET_OVERWHELMING(_fq_) do { \ 101*043036a2SApple OSS Distributions if (!FQ_IS_OVERWHELMING(_fq_)) { \ 102*043036a2SApple OSS Distributions KDBG(AQM_KTRACE_AON_FLOW_OVERWHELMING | DBG_FUNC_START, \ 103*043036a2SApple OSS Distributions (_fq_)->fq_flowhash, AQM_KTRACE_FQ_GRP_SC_IDX((_fq_)), \ 104*043036a2SApple OSS Distributions (_fq_)->fq_bytes, (_fq_)->fq_min_qdelay); \ 105*043036a2SApple OSS Distributions } \ 106*043036a2SApple OSS Distributions (_fq_)->fq_flags |= FQF_OVERWHELMING; \ 107*043036a2SApple OSS Distributions } while (0) 108*043036a2SApple OSS Distributions #define FQ_CLEAR_OVERWHELMING(_fq_) do { \ 109*043036a2SApple OSS Distributions if (FQ_IS_OVERWHELMING(_fq_)) { \ 110*043036a2SApple OSS Distributions KDBG(AQM_KTRACE_AON_FLOW_OVERWHELMING | DBG_FUNC_END, \ 111*043036a2SApple OSS Distributions (_fq_)->fq_flowhash, AQM_KTRACE_FQ_GRP_SC_IDX((_fq_)), \ 112*043036a2SApple OSS Distributions (_fq_)->fq_bytes, (_fq_)->fq_min_qdelay); \ 113*043036a2SApple OSS Distributions } \ 114*043036a2SApple OSS Distributions (_fq_)->fq_flags &= ~FQF_OVERWHELMING; \ 115*043036a2SApple OSS Distributions } while (0) 116*043036a2SApple OSS Distributions 117*043036a2SApple OSS Distributions /* 118*043036a2SApple OSS Distributions * time (in ns) the flow queue can stay in empty state. 119*043036a2SApple OSS Distributions */ 120*043036a2SApple OSS Distributions #define FQ_EMPTY_PURGE_DELAY (3ULL * 1000 * 1000 * 1000) 121*043036a2SApple OSS Distributions 122*043036a2SApple OSS Distributions /* 123*043036a2SApple OSS Distributions * maximum number of flow queues which can be purged during a dequeue. 124*043036a2SApple OSS Distributions */ 125*043036a2SApple OSS Distributions #define FQ_EMPTY_PURGE_MAX 4 126*043036a2SApple OSS Distributions 127*043036a2SApple OSS Distributions #define FQ_INVALID_TX_TS UINT64_MAX 128*043036a2SApple OSS Distributions 129*043036a2SApple OSS Distributions typedef struct codel_status { 130*043036a2SApple OSS Distributions boolean_t dropping; 131*043036a2SApple OSS Distributions uint32_t lastcnt; 132*043036a2SApple OSS Distributions uint32_t count; 133*043036a2SApple OSS Distributions uint64_t first_above_time; 134*043036a2SApple OSS Distributions uint64_t drop_next; 135*043036a2SApple OSS Distributions } codel_status_t; 136*043036a2SApple OSS Distributions 137*043036a2SApple OSS Distributions struct flowq { 138*043036a2SApple OSS Distributions #pragma pack(push,1) 139*043036a2SApple OSS Distributions union { 140*043036a2SApple OSS Distributions MBUFQ_HEAD(mbufq_head) __mbufq; /* mbuf packet queue */ 141*043036a2SApple OSS Distributions #if SKYWALK 142*043036a2SApple OSS Distributions KPKTQ_HEAD(kpktq_head) __kpktq; /* skywalk packet queue */ 143*043036a2SApple OSS Distributions #endif /* SKYWALK */ 144*043036a2SApple OSS Distributions } __fq_pktq_u; 145*043036a2SApple OSS Distributions #pragma pack(pop) 146*043036a2SApple OSS Distributions uint32_t fq_flowhash; /* Flow hash */ 147*043036a2SApple OSS Distributions uint32_t fq_bytes; /* Number of bytes in the queue */ 148*043036a2SApple OSS Distributions int32_t fq_deficit; /* Deficit for scheduling */ 149*043036a2SApple OSS Distributions fq_if_group_t *fq_group; /* Back pointer to the group */ 150*043036a2SApple OSS Distributions #define FQF_FLOWCTL_CAPABLE 0x01 /* Use flow control instead of drop */ 151*043036a2SApple OSS Distributions #define FQF_DELAY_HIGH 0x02 /* Min delay is greater than target */ 152*043036a2SApple OSS Distributions #define FQF_NEW_FLOW 0x04 /* Currently on new flows queue */ 153*043036a2SApple OSS Distributions #define FQF_OLD_FLOW 0x08 /* Currently on old flows queue */ 154*043036a2SApple OSS Distributions #define FQF_FLOWCTL_ON 0x10 /* Currently flow controlled */ 155*043036a2SApple OSS Distributions #define FQF_EMPTY_FLOW 0x20 /* Currently on empty flows queue */ 156*043036a2SApple OSS Distributions #define FQF_OVERWHELMING 0x40 /* The largest flow when AQM hits queue limit */ 157*043036a2SApple OSS Distributions #define FQF_FRESH_FLOW 0x80 /* The flow queue has just been allocated */ 158*043036a2SApple OSS Distributions #define FQF_ECN_CAPABLE 0x100 /* The flow is capable for doing ECN for classic traffic */ 159*043036a2SApple OSS Distributions #define FQF_CONGESTION_FEEDBACK 0x200 /* The flow is capable for doing congestion feedbacks */ 160*043036a2SApple OSS Distributions uint16_t fq_flags; /* flags */ 161*043036a2SApple OSS Distributions uint8_t fq_flowsrc; 162*043036a2SApple OSS Distributions uint8_t fq_sc_index; /* service_class index */ 163*043036a2SApple OSS Distributions bool fq_in_dqlist; 164*043036a2SApple OSS Distributions fq_tfc_type_t fq_tfc_type; 165*043036a2SApple OSS Distributions uint8_t __fq_pad_uint8[4]; 166*043036a2SApple OSS Distributions uint64_t fq_min_qdelay; /* min queue delay for Codel */ 167*043036a2SApple OSS Distributions uint64_t fq_getqtime; /* last dequeue time */ 168*043036a2SApple OSS Distributions /* total pkt count since last congestion event report */ 169*043036a2SApple OSS Distributions uint32_t fq_pkts_since_last_report; 170*043036a2SApple OSS Distributions /* the next time that a paced packet is ready to go*/ 171*043036a2SApple OSS Distributions uint64_t fq_next_tx_time; 172*043036a2SApple OSS Distributions /* number of packets that have experienced congestion event */ 173*043036a2SApple OSS Distributions uint32_t fq_congestion_cnt; 174*043036a2SApple OSS Distributions uint32_t fq_last_congestion_cnt; 175*043036a2SApple OSS Distributions codel_status_t codel_status; 176*043036a2SApple OSS Distributions union { 177*043036a2SApple OSS Distributions uint64_t fq_updatetime; /* next update interval */ 178*043036a2SApple OSS Distributions /* empty list purge time (in nanoseconds) */ 179*043036a2SApple OSS Distributions uint64_t fq_empty_purge_time; 180*043036a2SApple OSS Distributions }; 181*043036a2SApple OSS Distributions LIST_ENTRY(flowq) fq_hashlink; /* for flow queue hash table */ 182*043036a2SApple OSS Distributions /* 183*043036a2SApple OSS Distributions * flow queue will only be on either one of the lists. 184*043036a2SApple OSS Distributions */ 185*043036a2SApple OSS Distributions union { 186*043036a2SApple OSS Distributions STAILQ_ENTRY(flowq) fq_actlink; /* for new/old flow queues */ 187*043036a2SApple OSS Distributions /* entry on empty flow queue list */ 188*043036a2SApple OSS Distributions TAILQ_ENTRY(flowq) fq_empty_link; 189*043036a2SApple OSS Distributions }; 190*043036a2SApple OSS Distributions /* entry on dequeue flow list */ 191*043036a2SApple OSS Distributions STAILQ_ENTRY(flowq) fq_dqlink; 192*043036a2SApple OSS Distributions /* temporary packet queue for dequeued packets */ 193*043036a2SApple OSS Distributions classq_pkt_t fq_dq_head; 194*043036a2SApple OSS Distributions classq_pkt_t fq_dq_tail; 195*043036a2SApple OSS Distributions }; 196*043036a2SApple OSS Distributions 197*043036a2SApple OSS Distributions typedef struct flowq fq_t; 198*043036a2SApple OSS Distributions 199*043036a2SApple OSS Distributions #define FQF_FLOW_STATE_MASK (FQF_DELAY_HIGH | FQF_NEW_FLOW | \ 200*043036a2SApple OSS Distributions FQF_OLD_FLOW | FQF_FLOWCTL_ON | FQF_EMPTY_FLOW) 201*043036a2SApple OSS Distributions 202*043036a2SApple OSS Distributions #define fq_mbufq __fq_pktq_u.__mbufq 203*043036a2SApple OSS Distributions #if SKYWALK 204*043036a2SApple OSS Distributions #define fq_kpktq __fq_pktq_u.__kpktq 205*043036a2SApple OSS Distributions #endif /* SKYWALK */ 206*043036a2SApple OSS Distributions 207*043036a2SApple OSS Distributions #if SKYWALK 208*043036a2SApple OSS Distributions #define fq_empty(_q, _ptype) (((_ptype) == QP_MBUF) ? \ 209*043036a2SApple OSS Distributions MBUFQ_EMPTY(&(_q)->fq_mbufq) : KPKTQ_EMPTY(&(_q)->fq_kpktq)) 210*043036a2SApple OSS Distributions #else /* !SKYWALK */ 211*043036a2SApple OSS Distributions #define fq_empty(_q, _ptype) MBUFQ_EMPTY(&(_q)->fq_mbufq) 212*043036a2SApple OSS Distributions #endif /* !SKYWALK */ 213*043036a2SApple OSS Distributions 214*043036a2SApple OSS Distributions #if SKYWALK 215*043036a2SApple OSS Distributions #define fq_enqueue(_q, _h, _t, _c, _ptype) do { \ 216*043036a2SApple OSS Distributions switch (_ptype) { \ 217*043036a2SApple OSS Distributions case QP_MBUF: \ 218*043036a2SApple OSS Distributions ASSERT((_h).cp_ptype == QP_MBUF); \ 219*043036a2SApple OSS Distributions ASSERT((_t).cp_ptype == QP_MBUF); \ 220*043036a2SApple OSS Distributions MBUFQ_ENQUEUE_MULTI(&(_q)->fq_mbufq, (_h).cp_mbuf, \ 221*043036a2SApple OSS Distributions (_t).cp_mbuf); \ 222*043036a2SApple OSS Distributions MBUFQ_ADD_CRUMB_MULTI(&(_q)->fq_mbufq, (_h).cp_mbuf, \ 223*043036a2SApple OSS Distributions (_t).cp_mbuf, PKT_CRUMB_FQ_ENQUEUE); \ 224*043036a2SApple OSS Distributions break; \ 225*043036a2SApple OSS Distributions case QP_PACKET: \ 226*043036a2SApple OSS Distributions ASSERT((_h).cp_ptype == QP_PACKET); \ 227*043036a2SApple OSS Distributions ASSERT((_t).cp_ptype == QP_PACKET); \ 228*043036a2SApple OSS Distributions KPKTQ_ENQUEUE_MULTI(&(_q)->fq_kpktq, (_h).cp_kpkt, \ 229*043036a2SApple OSS Distributions (_t).cp_kpkt, (_c)); \ 230*043036a2SApple OSS Distributions break; \ 231*043036a2SApple OSS Distributions default: \ 232*043036a2SApple OSS Distributions VERIFY(0); \ 233*043036a2SApple OSS Distributions __builtin_unreachable(); \ 234*043036a2SApple OSS Distributions break; \ 235*043036a2SApple OSS Distributions } \ 236*043036a2SApple OSS Distributions } while (0) 237*043036a2SApple OSS Distributions #else /* !SKYWALK */ 238*043036a2SApple OSS Distributions #define fq_enqueue(_q, _h, _t, _c, _ptype) { \ 239*043036a2SApple OSS Distributions MBUFQ_ENQUEUE_MULTI(&(_q)->fq_mbufq, (_h).cp_mbuf, (_t).cp_mbuf); \ 240*043036a2SApple OSS Distributions MBUFQ_ADD_CRUMB_MULTI(&(_q)->fq_mbufq, (_h).cp_mbuf, \ 241*043036a2SApple OSS Distributions (_t).cp_mbuf, PKT_CRUMB_FQ_ENQUEUE); \ 242*043036a2SApple OSS Distributions } while (0) 243*043036a2SApple OSS Distributions #endif /* !SKYWALK */ 244*043036a2SApple OSS Distributions 245*043036a2SApple OSS Distributions #if SKYWALK 246*043036a2SApple OSS Distributions #define fq_dequeue(_q, _p, _ptype) do { \ 247*043036a2SApple OSS Distributions switch (_ptype) { \ 248*043036a2SApple OSS Distributions case QP_MBUF: { \ 249*043036a2SApple OSS Distributions MBUFQ_DEQUEUE(&(_q)->fq_mbufq, (_p)->cp_mbuf); \ 250*043036a2SApple OSS Distributions if (__probable((_p)->cp_mbuf != NULL)) { \ 251*043036a2SApple OSS Distributions CLASSQ_PKT_INIT_MBUF((_p), (_p)->cp_mbuf); \ 252*043036a2SApple OSS Distributions m_add_crumb((_p)->cp_mbuf, \ 253*043036a2SApple OSS Distributions PKT_CRUMB_FQ_DEQUEUE); \ 254*043036a2SApple OSS Distributions } \ 255*043036a2SApple OSS Distributions break; \ 256*043036a2SApple OSS Distributions } \ 257*043036a2SApple OSS Distributions case QP_PACKET: { \ 258*043036a2SApple OSS Distributions KPKTQ_DEQUEUE(&(_q)->fq_kpktq, (_p)->cp_kpkt); \ 259*043036a2SApple OSS Distributions if (__probable((_p)->cp_kpkt != NULL)) { \ 260*043036a2SApple OSS Distributions CLASSQ_PKT_INIT_PACKET((_p), (_p)->cp_kpkt); \ 261*043036a2SApple OSS Distributions } \ 262*043036a2SApple OSS Distributions break; \ 263*043036a2SApple OSS Distributions } \ 264*043036a2SApple OSS Distributions default: \ 265*043036a2SApple OSS Distributions VERIFY(0); \ 266*043036a2SApple OSS Distributions __builtin_unreachable(); \ 267*043036a2SApple OSS Distributions break; \ 268*043036a2SApple OSS Distributions } \ 269*043036a2SApple OSS Distributions } while (0) 270*043036a2SApple OSS Distributions #else /* !SKYWALK */ 271*043036a2SApple OSS Distributions #define fq_dequeue(_q, _p, _ptype) do { \ 272*043036a2SApple OSS Distributions MBUFQ_DEQUEUE(&(_q)->fq_mbufq, (_p)->cp_mbuf); \ 273*043036a2SApple OSS Distributions if (__probable((_p)->cp_mbuf != NULL)) { \ 274*043036a2SApple OSS Distributions CLASSQ_PKT_INIT_MBUF((_p), (_p)->cp_mbuf); \ 275*043036a2SApple OSS Distributions m_add_crumb((_p)->cp_mbuf, PKT_CRUMB_FQ_DEQUEUE); \ 276*043036a2SApple OSS Distributions } \ 277*043036a2SApple OSS Distributions } while (0) 278*043036a2SApple OSS Distributions #endif /* !SKYWALK */ 279*043036a2SApple OSS Distributions 280*043036a2SApple OSS Distributions struct fq_codel_sched_data; 281*043036a2SApple OSS Distributions struct fq_if_classq; 282*043036a2SApple OSS Distributions 283*043036a2SApple OSS Distributions /* Function definitions */ 284*043036a2SApple OSS Distributions extern void fq_codel_init(void); 285*043036a2SApple OSS Distributions extern fq_t *fq_alloc(classq_pkt_type_t); 286*043036a2SApple OSS Distributions extern void fq_destroy(fq_t *, classq_pkt_type_t); 287*043036a2SApple OSS Distributions extern int fq_codel_enq_legacy(void * fqs, fq_if_group_t *, pktsched_pkt_t *, struct fq_if_classq *); 288*043036a2SApple OSS Distributions extern void fq_codel_dq_legacy(void *fqs, void *fq, pktsched_pkt_t *pkt, uint64_t now); 289*043036a2SApple OSS Distributions extern void fq_getq_flow_internal(struct fq_codel_sched_data *, 290*043036a2SApple OSS Distributions fq_t *, pktsched_pkt_t *); 291*043036a2SApple OSS Distributions extern void fq_head_drop(struct fq_codel_sched_data *, fq_t *); 292*043036a2SApple OSS Distributions extern boolean_t fq_tx_time_ready(fq_if_t *fqs, fq_t *fq, uint64_t now, 293*043036a2SApple OSS Distributions uint64_t *ready_time); 294*043036a2SApple OSS Distributions 295*043036a2SApple OSS Distributions extern void fq_codel_dq(void *fqs_p, void *fq_p, pktsched_pkt_t *pkt, uint64_t now); 296*043036a2SApple OSS Distributions extern int fq_codel_enq(void *fqs_p, fq_if_group_t *fq_grp, pktsched_pkt_t *pkt, 297*043036a2SApple OSS Distributions fq_if_classq_t *fq_cl); 298*043036a2SApple OSS Distributions 299*043036a2SApple OSS Distributions #ifdef __cplusplus 300*043036a2SApple OSS Distributions } 301*043036a2SApple OSS Distributions #endif 302*043036a2SApple OSS Distributions #endif /* BSD_KERNEL_PRIVATE */ 303*043036a2SApple OSS Distributions #endif /* PRIVATE */ 304*043036a2SApple OSS Distributions #endif /* _NET_CLASSQ_CLASSQ_FQ_CODEL_H */ 305