1 /* FILE : /usr/src/linux/include/net/kernel_qtype.h *
2 * This file define data structures used in kernel to run WF2Q scheduler.
6 #include <net/qmgt_red.h>
7 #include <linux/time.h> //for "struct timeval"
8 #include <asm/semaphore.h> //for "struct semaphore"
10 /*Please reference the include/linux/types.h for more info of u_intxx_t type*/
12 #define MAX_UINT64 0xfffffffffffff800 //used to detect when to wrap around
13 //an 64-bit integer which is going to
15 /* Statistical information of a queue. */
18 //"Static" property of the queue
20 //the drop mechanism(RED or TD)
22 //the direction of the queue
26 //the weight of the queue (unit: 1/10000)
28 //the max weight of the queue(for max rate control)
30 //the required buffer length (bytes)
32 //the required delay(in ms)
35 u_int32_t sample_counter;
36 //to determine the sample rate
37 struct timeval last_VFT;//the latest Virtual Finish Time
39 //"Statistical" property of the queue
40 u_int64_t send_pkt; //the # of sent packets.
41 u_int64_t send_byte; //the # of sent bytes.
42 u_int64_t recv_pkt; //the # of received packets.
43 u_int64_t recv_byte; //the # of received bytes.
44 u_int64_t drop_pkt; //the # of dropped packets.
45 u_int64_t drop_byte; //the # of dropped bytes.
46 u_int32_t current_q_len; //the current length of queue (bytes)
47 u_int32_t current_q_pkt; //the current length of queue (pkts)
48 u_int32_t avg_q_len; //the average length of queue
49 u_int32_t avg_delay; //the average delay
50 u_int64_t second_moment_delay; //the second moment of delay
51 u_int64_t var_delay; //the delay variance
52 u_int32_t max_delay_until_now; //the max delay so far
53 u_int8_t policing_enable; //the flag the determine whether to
58 typedef struct t_qstat Q_Stat;
60 /* Imformation of the policer of a bandwidth pipe (Bpipe) * */
63 u_int8_t policer_type;
64 //to Best Effort or Drop it
65 u_int32_t TB_left_token; //the left credit of the class/flow,
68 //"Statistical information"
69 u_int64_t recv_pkt; //the # of received packets
70 u_int64_t recv_byte; //the # of received bytes
71 u_int64_t conform_pkt; //the # of comfom packets
72 u_int64_t conform_byte; //the # of comfom bytes
73 //NOTE that "conform_pkt" and "conform_byte"
74 //will be the same as "recv_pkt" and
75 //"recv_byte" respectively.
76 T_Spec t_spec; //the traffic spec
77 struct timeval last_policing_time; //to count the remaining tokens
81 typedef struct t_policer Policer_Spec;
82 /* Information identifying which queue a packet belongs to. *
83 * Information here is usually reffered to when doing packet classification. */
86 C_Spec c_spec; //the filter rule
87 Class_Name class_name; //the name of the class/flow
88 struct t_qspec *theQueue; //the queue to which the traffic belongs
91 typedef struct t_filter Filter_Spec;
93 /* Information of a queue *
94 * A queue could represent a service class or bandwidth pipe(Bpipe). */
97 Q_Stat q_stat; //the information of the queue
98 Policer_Spec p_spec; //the policer info of the queue
99 Filter_Spec *f_spec;//the filter bound to the queue
101 //We use doubly linked list to manage the ACTIVE queues.
102 struct t_qspec *prev_active;//the previous active queue
103 struct t_qspec *next_active;//the next active queue
105 //We also use doubly linked list to manage ALL queues
106 struct t_qspec *prev;//the previous queue
107 struct t_qspec *next;//the next queue
108 struct sk_buff_head pkt_list; //the packet list of the queue
110 u_int16_t po; //Precedence Order
113 u_int8_t enabled; //Is this Bpipe enabled? (DISABLE_BPIPE v.s. ENABLE_BPIPE)
116 void *ext; // for future extension
119 typedef struct t_qspec Q_Spec;
121 /* Information of a WF2Q scheduler *
125 Q_Spec *head; //head of queue list which contains ALL queues
126 //created in a NIC (Let say "ALL-queue list")
127 Q_Spec *active_head; //head of active queue list which contains ONLY
128 //active queues in a NIC (Let say "ACTIVE-queue
130 Q_Spec *default_q; //for Best Effort traffic
131 u_int32_t usedWeight; //sum of weights of active queues
132 u_int32_t totalWeight; //sum of weights of all queues
133 u_int32_t BW; //bandwidth of link
134 //NOTE that "bandwidth" may be less than
135 //NIC's maximum capacity. If it is set
136 //this way, mechanism of "Maximum output
137 //rate control" will enforce the NIC to run
138 //at speed no more faster than "bandwidth".
139 u_int32_t BW_token; //for bandwidth control (maximum output rate
140 //control), measured in BYTES
141 struct timeval last_ctl_time; //to count residual tokens of a NIC
142 struct semaphore *active_queue_lock; //to avoid infinite loop caused by
143 //erroneously reffering to ACTIVE
145 struct semaphore *all_queue_lock; //to avoid infinite loop caused by
146 //erroneously reffering to ALL
148 struct timer_list deq_timer; //to regularly wake up scheduler to send