altq_classq.h (416ba5c74546f32a993436a99516d35008e9f384) | altq_classq.h (0a70aaf8f5d93454d0940a09b94deecd7aa5fa0d) |
---|---|
1/*- 2 * Copyright (c) 1991-1997 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 36 unchanged lines hidden (view full) --- 45 46/* 47 * Packet Queue types: RED or DROPHEAD. 48 */ 49#define Q_DROPHEAD 0x00 50#define Q_RED 0x01 51#define Q_RIO 0x02 52#define Q_DROPTAIL 0x03 | 1/*- 2 * Copyright (c) 1991-1997 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 36 unchanged lines hidden (view full) --- 45 46/* 47 * Packet Queue types: RED or DROPHEAD. 48 */ 49#define Q_DROPHEAD 0x00 50#define Q_RED 0x01 51#define Q_RIO 0x02 52#define Q_DROPTAIL 0x03 |
53#define Q_CODEL 0x04 |
|
53 54#ifdef _KERNEL 55 56/* 57 * Packet Queue structures and macros to manipulate them. 58 */ 59struct _class_queue_ { 60 struct mbuf *tail_; /* Tail of packet queue */ 61 int qlen_; /* Queue length (in number of packets) */ 62 int qlim_; /* Queue limit (in number of packets*) */ | 54 55#ifdef _KERNEL 56 57/* 58 * Packet Queue structures and macros to manipulate them. 59 */ 60struct _class_queue_ { 61 struct mbuf *tail_; /* Tail of packet queue */ 62 int qlen_; /* Queue length (in number of packets) */ 63 int qlim_; /* Queue limit (in number of packets*) */ |
64 int qsize_; /* Queue size (in number of bytes*) */ |
|
63 int qtype_; /* Queue type */ 64}; 65 66typedef struct _class_queue_ class_queue_t; 67 68#define qtype(q) (q)->qtype_ /* Get queue type */ 69#define qlimit(q) (q)->qlim_ /* Max packets to be queued */ 70#define qlen(q) (q)->qlen_ /* Current queue length. */ | 65 int qtype_; /* Queue type */ 66}; 67 68typedef struct _class_queue_ class_queue_t; 69 70#define qtype(q) (q)->qtype_ /* Get queue type */ 71#define qlimit(q) (q)->qlim_ /* Max packets to be queued */ 72#define qlen(q) (q)->qlen_ /* Current queue length. */ |
73#define qsize(q) (q)->qsize_ /* Current queue size. */ |
|
71#define qtail(q) (q)->tail_ /* Tail of the queue */ 72#define qhead(q) ((q)->tail_ ? (q)->tail_->m_nextpkt : NULL) 73 74#define qempty(q) ((q)->qlen_ == 0) /* Is the queue empty?? */ | 74#define qtail(q) (q)->tail_ /* Tail of the queue */ 75#define qhead(q) ((q)->tail_ ? (q)->tail_->m_nextpkt : NULL) 76 77#define qempty(q) ((q)->qlen_ == 0) /* Is the queue empty?? */ |
78#define q_is_codel(q) ((q)->qtype_ == Q_CODEL) /* Is the queue a codel queue */ |
|
75#define q_is_red(q) ((q)->qtype_ == Q_RED) /* Is the queue a red queue */ 76#define q_is_rio(q) ((q)->qtype_ == Q_RIO) /* Is the queue a rio queue */ 77#define q_is_red_or_rio(q) ((q)->qtype_ == Q_RED || (q)->qtype_ == Q_RIO) 78 79#if !defined(__GNUC__) || defined(ALTQ_DEBUG) 80 81extern void _addq(class_queue_t *, struct mbuf *); 82extern struct mbuf *_getq(class_queue_t *); --- 13 unchanged lines hidden (view full) --- 96 97 if ((m0 = qtail(q)) != NULL) 98 m->m_nextpkt = m0->m_nextpkt; 99 else 100 m0 = m; 101 m0->m_nextpkt = m; 102 qtail(q) = m; 103 qlen(q)++; | 79#define q_is_red(q) ((q)->qtype_ == Q_RED) /* Is the queue a red queue */ 80#define q_is_rio(q) ((q)->qtype_ == Q_RIO) /* Is the queue a rio queue */ 81#define q_is_red_or_rio(q) ((q)->qtype_ == Q_RED || (q)->qtype_ == Q_RIO) 82 83#if !defined(__GNUC__) || defined(ALTQ_DEBUG) 84 85extern void _addq(class_queue_t *, struct mbuf *); 86extern struct mbuf *_getq(class_queue_t *); --- 13 unchanged lines hidden (view full) --- 100 101 if ((m0 = qtail(q)) != NULL) 102 m->m_nextpkt = m0->m_nextpkt; 103 else 104 m0 = m; 105 m0->m_nextpkt = m; 106 qtail(q) = m; 107 qlen(q)++; |
108 qsize(q) += m_pktlen(m); |
|
104} 105 106static __inline struct mbuf * 107_getq(class_queue_t *q) 108{ 109 struct mbuf *m, *m0; 110 111 if ((m = qtail(q)) == NULL) 112 return (NULL); 113 if ((m0 = m->m_nextpkt) != m) 114 m->m_nextpkt = m0->m_nextpkt; 115 else 116 qtail(q) = NULL; 117 qlen(q)--; | 109} 110 111static __inline struct mbuf * 112_getq(class_queue_t *q) 113{ 114 struct mbuf *m, *m0; 115 116 if ((m = qtail(q)) == NULL) 117 return (NULL); 118 if ((m0 = m->m_nextpkt) != m) 119 m->m_nextpkt = m0->m_nextpkt; 120 else 121 qtail(q) = NULL; 122 qlen(q)--; |
123 qsize(q) -= m_pktlen(m0); |
|
118 m0->m_nextpkt = NULL; 119 return (m0); 120} 121 122/* drop a packet at the tail of the queue */ 123static __inline struct mbuf * 124_getq_tail(class_queue_t *q) 125{ --- 82 unchanged lines hidden --- | 124 m0->m_nextpkt = NULL; 125 return (m0); 126} 127 128/* drop a packet at the tail of the queue */ 129static __inline struct mbuf * 130_getq_tail(class_queue_t *q) 131{ --- 82 unchanged lines hidden --- |