cleanup
[linux-2.4.21-pre4.git] / include / net1 / qtype.h
1 /* 
2  * FILE : /usr/src/linux/include/net/qtype.h
3  *
4  * This file defines data structures for programs to send commands and 
5  * parameters from user-level to kernel. Some of them are used directly in
6  * kernel. NOTE that parts of the definitions here are designed only for
7  * WF2Q scheduler.
8  */
9
10
11 /* NIC identification */
12 typedef struct t_qtype
13 {
14         char if_id[8];          //Identifier of the NIC. ex. eth0
15         u_int8_t if_dir;        //1: Inbound
16                                 //2: Outbound
17         u_int32_t bandwidth;    //Bandwidth of this NIC
18                                 //NOTE that "bandwidth" may be less than
19                                 //NIC's maximum capacity. If it is set
20                                 //this way, mechanism of "Maximum output
21                                 //rate control" will enforce the NIC to run
22                                 //at speed no more faster than "bandwidth".
23 }If_Name;
24
25
26 /* Information of a service class or a bandwidth pipe(Bpipe)
27  * 
28  * NOTE that in addition to Class_Name we need another T_Spec(defined below)
29  * to define a Bpipe .
30  */
31 typedef struct t_clsname
32 {
33         char if_id[8];          // the if name, ex: fxp0
34         
35         u_int8_t  if_dir;       // the direction of the interface
36                                 // 1: Inbound
37                                 // 2: Outbound                                          
38         char agency[30];        // the name of the agency
39                                 // ex: "ntu"
40         char class[30];         // the name of the class
41                                 // ex: "im"
42                                                                                                                                                         
43         u_int8_t  service_type; // the service type
44                                 // 0: Non_CAC class
45                                 // 1: CAC class
46                                 // 2: VoIP class
47                                 // 3: Video class
48                                 // 101: Bpipe
49
50         u_int16_t po;           /* 20020716 by ARGAY
51                                  * Precedence Order 
52                                  * The most significant 8-bit is the precedence order at Agency
53                                  * level. The last significatn 8 bits represents the precedence
54                                  * order at Bpipe level
55                                  */
56
57 }Class_Name;
58
59
60 /* Specification of a service class (5 fields)
61  * 1. Source address
62  * 2. Source ports
63  * 3. Destination address
64  * 4. Destination ports
65  * 5. Protocol
66  *
67  * NOTE that except for "protocol_id", other data(including addresses and
68  * ports) may spread within a range. Therefore we use start(ex. s_saddr)
69  * and end(ex. e_saddr) to define the range. To describe a wildcard 
70  * address or port, we have define their range as 0~2^32-1 and 0~2^16-1
71  * respectively.
72  */
73 typedef struct t_cspec
74 {
75         u_int32_t  s_saddr;     //the start of the source address
76                                 //ex: 01020300h (1.2.3.0)
77                                                                                                         
78         u_int32_t  e_saddr;     //the end of the source address
79                                 //ex: 010203FFh (1.2.3.255)
80                                                                                                         
81         u_int16_t  s_sport;     //the start of source port
82                                 //ex: 21
83                                                                                                         
84         u_int16_t  e_sport;     //the end of source port
85                                 //ex: 22
86                                                                                                         
87         u_int32_t  s_daddr;     //the start of the destination address
88                                 //ex: 02040600h (2.4.6.0)
89                                                                                                         
90         u_int32_t  e_daddr;     //the end of the destination address
91                                 //ex: 020406FFh (2.4.6.255)
92                                                                                                         
93         u_int16_t  s_dport;     //the start of destination port
94                                 //ex: 23
95                                                                                                         
96         u_int16_t  e_dport;     //the end of destination port
97                                 //ex: 24
98                                                                                                         
99         u_int8_t  protocol_id;  //the start of protocol ID
100                                 //0=wild card, or specific
101         
102 }C_Spec;
103
104
105 /* Traffic specification
106  *
107  * This is only required for special classes which need policing, that is 
108  * "Bandwidth pipe"(Bpipe). We now use 5 parameters defined by IETF in RFC
109  * 2210 as a Bpipe's traffic specification. "VOIP_T_Spec" is designed for
110  * future extension.
111  */
112 typedef union t_tspec
113 {
114         struct IT_Spec
115         {
116                 u_int32_t  TokenRate;           // the r value (bps)
117                 u_int32_t  TokenBucketSize;     // the b value (byte)
118                 u_int32_t  PeakBandwidth;       // the p value (bps)
119                 u_int16_t  MaxPacketSize;       // the M value (byte)
120                 u_int8_t   MinPacketSize;       // the m value (byte)
121         }IETF_T_Spec;
122                                         
123         struct VT_Spec
124         {
125                 u_int8_t  Coding_scheme;        // the coding scheme
126                                                 // ex: ask bigzoo :)
127                                                                                                                 
128                 u_int8_t  Suppression;          // to indicate whether 
129                                                 // the silence supression
130                                                 // is supported.
131                                                 // 0: no, 1: yes
132                                                                                                                 
133                 u_int8_t  padding[12];          // the padding bits
134                                                 
135         }VOIP_T_Spec;
136 }T_Spec;
137                                 
138                                         
139 /* QoS specification
140  *
141  * This structure defines the QoS requirements of a service class or a Bpipe.
142  * Actually, this strcture is not used for the current version. Instead, we
143  * pay most attention to the achieved throughput of each service class or a
144  * Bpipe.
145  */                                     
146 typedef struct t_qos
147 {
148         u_int32_t  delay;       // the delay value(ms)
149         u_int32_t  maxrate;     // the maximum rate
150         u_int32_t  minrate;     // the minimum rate(must be supported by scheduler)
151         u_int32_t  nominalrate; // the guaranteed value(byte per second)
152         u_int32_t  loss;        // the loss rate(UNIT= 10^-6)
153 }QoS_Spec;
154
155
156 /* Parameters of resources to reserve
157  * 1. Buffer (byte)
158  * 2. Minimum guaranteed rate (bps)
159  */
160
161 //20020716 by ARGAY
162 enum {
163         DISABLE_BPIPE = 0,
164         ENABLE_BPIPE
165 };
166
167 typedef struct reff
168 {       
169         u_int32_t b;            //buffer size (byte)
170         u_int32_t r;            //guaranteed rate(bps)
171         u_int8_t modFlag;       //the flag to indicate what kind
172                                 //of modification
173                                 // 0 : class modification (MOD_CLASS)
174                                 // 1 : bpipe modification (MOD_BPIPE)
175                                 // 2 : Rsc modification (MOD_RSC)
176                                 //This flag is only used when we have to
177                                 //change resource allocation of an EXISTING
178                                 //service class or Bpipe
179
180         u_int8_t  enableBpipeFlag;      /* 20020716 by ARGAY
181                                          * the flag to indicate whether an AR Bpipe is enabled
182                                          * 0: DISABLE_BPIPE
183                                          * 1: ENABLE_BPIPE
184                                          * Currently, only an AR Bpipe will be disabled when it
185                                          * should not be activated. IR Bpipes will NEVER be
186                                          * disabled.
187                                          */
188 }Eff_Rsc;
189
190 enum {
191         MOD_CLASS = 0,
192         MOD_BPIPE,
193         MOD_RSC,
194         MOD_QMGT,
195         MOD_PRIO 
196 };
197
198
199 //Parameters of RED queue management    added by Binbon
200 typedef struct t_redspec{
201
202         /* RED parameters: unit= 1/1000000 */
203         u_int32_t wq;                   /* weighted average */
204         u_int32_t minthp;               /* the proportion of minimum threshold to buf_len */
205         u_int32_t maxthp;               /* the proportion of maximum threshold to buf_len */
206         u_int32_t maxp;                 /* maximum value of dropping probability */
207         
208 }RED_Spec;
209
210
211 /* Struct tc_wfq_qopt is the data structure containging commands and parameters
212  * sent from user-space to kernel. Each time when tc_wfq_qopt is used, not
213  * every member of this data strcuture contains data. It depends on which
214  * command the administrator wants to execute. For example, if we want to
215  * add a service class, only members in, cn, cs and er are required to fill in
216  * data. ts is not required.
217  */
218 struct tc_wfq_qopt {
219         If_Name in;
220         Class_Name cn;
221         C_Spec cs;
222         T_Spec ts;
223         Eff_Rsc er;
224         u_int8_t qm;    //added by Binbon
225         RED_Spec rs;    //added by Binbon
226 };
227 struct tc_ken_prio_qopt {
228         If_Name in;
229         Class_Name cn;
230         C_Spec cs;
231         T_Spec ts;
232         Eff_Rsc er;
233         u_int8_t qm;    //added by Binbon
234         RED_Spec rs;    //added by Binbon
235         u_int8_t prio;
236 };
237 /* The following codes are for PORTER.
238  */
239 //  2001/03/25 add by Jay
240
241 struct db_ir
242 {
243 //      u_int8_t cac_flag;
244 //      unsigned long classID;
245         
246         Class_Name cname;
247         C_Spec cspec;
248         T_Spec tspec;
249         QoS_Spec qos;
250         Eff_Rsc rsc;
251         struct db_ir *next;
252 };
253
254 struct db_ar
255 {
256 //      u_int8_t cac_flag;
257 //      unsigned long classID;
258
259         time_t  s_time;
260         time_t e_time;
261
262         Class_Name cname;
263         C_Spec cspec;
264         T_Spec tspec;
265         QoS_Spec qos;
266         Eff_Rsc rsc;
267         struct db_ar *next;
268 };
269
270 struct db_if
271 {
272         char if_id[8];          // the if name, ex: fxp0
273         
274         u_int8_t  if_dir;       // the direction of the interface
275                                 // 0: Outbound                                          
276                                 // 1: Inbound
277         u_int32_t ir_bw;
278         u_int32_t ar_bw;
279         struct db_ir *ir_head;
280         struct db_ar *ar_head;
281         
282         struct db_if *next;
283 };
284
285 //end of 2001/3/25 add by Jay
286