Changeset View
Changeset View
Standalone View
Standalone View
sys/net/altq/altq_classq.h
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Packet Queue types: RED or DROPHEAD. | * Packet Queue types: RED or DROPHEAD. | ||||
*/ | */ | ||||
#define Q_DROPHEAD 0x00 | #define Q_DROPHEAD 0x00 | ||||
#define Q_RED 0x01 | #define Q_RED 0x01 | ||||
#define Q_RIO 0x02 | #define Q_RIO 0x02 | ||||
#define Q_DROPTAIL 0x03 | #define Q_DROPTAIL 0x03 | ||||
#define Q_CODEL 0x04 | |||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
/* | /* | ||||
* Packet Queue structures and macros to manipulate them. | * Packet Queue structures and macros to manipulate them. | ||||
*/ | */ | ||||
struct _class_queue_ { | struct _class_queue_ { | ||||
struct mbuf *tail_; /* Tail of packet queue */ | struct mbuf *tail_; /* Tail of packet queue */ | ||||
int qlen_; /* Queue length (in number of packets) */ | int qlen_; /* Queue length (in number of packets) */ | ||||
int qlim_; /* Queue limit (in number of packets*) */ | int qlim_; /* Queue limit (in number of packets*) */ | ||||
int qsize_; /* Queue size (in number of bytes*) */ | |||||
int qtype_; /* Queue type */ | int qtype_; /* Queue type */ | ||||
}; | }; | ||||
typedef struct _class_queue_ class_queue_t; | typedef struct _class_queue_ class_queue_t; | ||||
#define qtype(q) (q)->qtype_ /* Get queue type */ | #define qtype(q) (q)->qtype_ /* Get queue type */ | ||||
#define qlimit(q) (q)->qlim_ /* Max packets to be queued */ | #define qlimit(q) (q)->qlim_ /* Max packets to be queued */ | ||||
#define qlen(q) (q)->qlen_ /* Current queue length. */ | #define qlen(q) (q)->qlen_ /* Current queue length. */ | ||||
#define qsize(q) (q)->qsize_ /* Current queue size. */ | |||||
#define qtail(q) (q)->tail_ /* Tail of the queue */ | #define qtail(q) (q)->tail_ /* Tail of the queue */ | ||||
#define qhead(q) ((q)->tail_ ? (q)->tail_->m_nextpkt : NULL) | #define qhead(q) ((q)->tail_ ? (q)->tail_->m_nextpkt : NULL) | ||||
#define qempty(q) ((q)->qlen_ == 0) /* Is the queue empty?? */ | #define qempty(q) ((q)->qlen_ == 0) /* Is the queue empty?? */ | ||||
#define q_is_codel(q) ((q)->qtype_ == Q_CODEL) /* Is the queue a codel queue */ | |||||
#define q_is_red(q) ((q)->qtype_ == Q_RED) /* Is the queue a red queue */ | #define q_is_red(q) ((q)->qtype_ == Q_RED) /* Is the queue a red queue */ | ||||
#define q_is_rio(q) ((q)->qtype_ == Q_RIO) /* Is the queue a rio queue */ | #define q_is_rio(q) ((q)->qtype_ == Q_RIO) /* Is the queue a rio queue */ | ||||
#define q_is_red_or_rio(q) ((q)->qtype_ == Q_RED || (q)->qtype_ == Q_RIO) | #define q_is_red_or_rio(q) ((q)->qtype_ == Q_RED || (q)->qtype_ == Q_RIO) | ||||
#if !defined(__GNUC__) || defined(ALTQ_DEBUG) | #if !defined(__GNUC__) || defined(ALTQ_DEBUG) | ||||
extern void _addq(class_queue_t *, struct mbuf *); | extern void _addq(class_queue_t *, struct mbuf *); | ||||
extern struct mbuf *_getq(class_queue_t *); | extern struct mbuf *_getq(class_queue_t *); | ||||
Show All 13 Lines | _addq(class_queue_t *q, struct mbuf *m) | ||||
if ((m0 = qtail(q)) != NULL) | if ((m0 = qtail(q)) != NULL) | ||||
m->m_nextpkt = m0->m_nextpkt; | m->m_nextpkt = m0->m_nextpkt; | ||||
else | else | ||||
m0 = m; | m0 = m; | ||||
m0->m_nextpkt = m; | m0->m_nextpkt = m; | ||||
qtail(q) = m; | qtail(q) = m; | ||||
qlen(q)++; | qlen(q)++; | ||||
qsize(q) += m_pktlen(m); | |||||
} | } | ||||
static __inline struct mbuf * | static __inline struct mbuf * | ||||
_getq(class_queue_t *q) | _getq(class_queue_t *q) | ||||
{ | { | ||||
struct mbuf *m, *m0; | struct mbuf *m, *m0; | ||||
if ((m = qtail(q)) == NULL) | if ((m = qtail(q)) == NULL) | ||||
return (NULL); | return (NULL); | ||||
if ((m0 = m->m_nextpkt) != m) | if ((m0 = m->m_nextpkt) != m) | ||||
m->m_nextpkt = m0->m_nextpkt; | m->m_nextpkt = m0->m_nextpkt; | ||||
else | else | ||||
qtail(q) = NULL; | qtail(q) = NULL; | ||||
qlen(q)--; | qlen(q)--; | ||||
qsize(q) -= m_pktlen(m0); | |||||
m0->m_nextpkt = NULL; | m0->m_nextpkt = NULL; | ||||
return (m0); | return (m0); | ||||
} | } | ||||
/* drop a packet at the tail of the queue */ | /* drop a packet at the tail of the queue */ | ||||
static __inline struct mbuf * | static __inline struct mbuf * | ||||
_getq_tail(class_queue_t *q) | _getq_tail(class_queue_t *q) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |