775bdb4465bfe35296bfe5d63a1f875dd58637be
[pandora-kernel.git] / include / linux / dcbnl.h
1 /*
2  * Copyright (c) 2008, Intel Corporation.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms and conditions of the GNU General Public License,
6  * version 2, as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11  * more details.
12  *
13  * You should have received a copy of the GNU General Public License along with
14  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15  * Place - Suite 330, Boston, MA 02111-1307 USA.
16  *
17  * Author: Lucy Liu <lucy.liu@intel.com>
18  */
19
20 #ifndef __LINUX_DCBNL_H__
21 #define __LINUX_DCBNL_H__
22
23 #include <linux/types.h>
24
25 /* IEEE 802.1Qaz std supported values */
26 #define IEEE_8021QAZ_MAX_TCS    8
27
28 /* This structure contains the IEEE 802.1Qaz ETS managed object
29  *
30  * @willing: willing bit in ETS configuratin TLV
31  * @ets_cap: indicates supported capacity of ets feature
32  * @cbs: credit based shaper ets algorithm supported
33  * @tc_tx_bw: tc tx bandwidth indexed by traffic class
34  * @tc_rx_bw: tc rx bandwidth indexed by traffic class
35  * @tc_tsa: TSA Assignment table, indexed by traffic class
36  * @prio_tc: priority assignment table mapping 8021Qp to traffic class
37  * @tc_reco_bw: recommended tc bandwidth indexed by traffic class for TLV
38  * @tc_reco_tsa: recommended tc bandwidth indexed by traffic class for TLV
39  * @reco_prio_tc: recommended tc tx bandwidth indexed by traffic class for TLV
40  *
41  * Recommended values are used to set fields in the ETS recommendation TLV
42  * with hardware offloaded LLDP.
43  *
44  * ----
45  *  TSA Assignment 8 bit identifiers
46  *      0       strict priority
47  *      1       credit-based shaper
48  *      2       enhanced transmission selection
49  *      3-254   reserved
50  *      255     vendor specific
51  */
52 struct ieee_ets {
53         __u8    willing;
54         __u8    ets_cap;
55         __u8    cbs;
56         __u8    tc_tx_bw[IEEE_8021QAZ_MAX_TCS];
57         __u8    tc_rx_bw[IEEE_8021QAZ_MAX_TCS];
58         __u8    tc_tsa[IEEE_8021QAZ_MAX_TCS];
59         __u8    prio_tc[IEEE_8021QAZ_MAX_TCS];
60         __u8    tc_reco_bw[IEEE_8021QAZ_MAX_TCS];
61         __u8    tc_reco_tsa[IEEE_8021QAZ_MAX_TCS];
62         __u8    reco_prio_tc[IEEE_8021QAZ_MAX_TCS];
63 };
64
65 /* This structure contains the IEEE 802.1Qaz PFC managed object
66  *
67  * @pfc_cap: Indicates the number of traffic classes on the local device
68  *           that may simultaneously have PFC enabled.
69  * @pfc_en: bitmap indicating pfc enabled traffic classes
70  * @mbc: enable macsec bypass capability
71  * @delay: the allowance made for a round-trip propagation delay of the
72  *         link in bits.
73  * @requests: count of the sent pfc frames
74  * @indications: count of the received pfc frames
75  */
76 struct ieee_pfc {
77         __u8    pfc_cap;
78         __u8    pfc_en;
79         __u8    mbc;
80         __u16   delay;
81         __u64   requests[IEEE_8021QAZ_MAX_TCS];
82         __u64   indications[IEEE_8021QAZ_MAX_TCS];
83 };
84
85 /* This structure contains the IEEE 802.1Qaz APP managed object. This
86  * object is also used for the CEE std as well. There is no difference
87  * between the objects.
88  *
89  * @selector: protocol identifier type
90  * @protocol: protocol of type indicated
91  * @priority: 3-bit unsigned integer indicating priority
92  *
93  * ----
94  *  Selector field values
95  *      0       Reserved
96  *      1       Ethertype
97  *      2       Well known port number over TCP or SCTP
98  *      3       Well known port number over UDP or DCCP
99  *      4       Well known port number over TCP, SCTP, UDP, or DCCP
100  *      5-7     Reserved
101  */
102 struct dcb_app {
103         __u8    selector;
104         __u32   protocol;
105         __u8    priority;
106 };
107
108 struct dcbmsg {
109         __u8               dcb_family;
110         __u8               cmd;
111         __u16              dcb_pad;
112 };
113
114 /**
115  * enum dcbnl_commands - supported DCB commands
116  *
117  * @DCB_CMD_UNDEFINED: unspecified command to catch errors
118  * @DCB_CMD_GSTATE: request the state of DCB in the device
119  * @DCB_CMD_SSTATE: set the state of DCB in the device
120  * @DCB_CMD_PGTX_GCFG: request the priority group configuration for Tx
121  * @DCB_CMD_PGTX_SCFG: set the priority group configuration for Tx
122  * @DCB_CMD_PGRX_GCFG: request the priority group configuration for Rx
123  * @DCB_CMD_PGRX_SCFG: set the priority group configuration for Rx
124  * @DCB_CMD_PFC_GCFG: request the priority flow control configuration
125  * @DCB_CMD_PFC_SCFG: set the priority flow control configuration
126  * @DCB_CMD_SET_ALL: apply all changes to the underlying device
127  * @DCB_CMD_GPERM_HWADDR: get the permanent MAC address of the underlying
128  *                        device.  Only useful when using bonding.
129  * @DCB_CMD_GCAP: request the DCB capabilities of the device
130  * @DCB_CMD_GNUMTCS: get the number of traffic classes currently supported
131  * @DCB_CMD_SNUMTCS: set the number of traffic classes
132  * @DCB_CMD_GBCN: set backward congestion notification configuration
133  * @DCB_CMD_SBCN: get backward congestion notification configration.
134  * @DCB_CMD_GAPP: get application protocol configuration
135  * @DCB_CMD_SAPP: set application protocol configuration
136  * @DCB_CMD_IEEE_SET: set IEEE 802.1Qaz configuration
137  * @DCB_CMD_IEEE_GET: get IEEE 802.1Qaz configuration
138  */
139 enum dcbnl_commands {
140         DCB_CMD_UNDEFINED,
141
142         DCB_CMD_GSTATE,
143         DCB_CMD_SSTATE,
144
145         DCB_CMD_PGTX_GCFG,
146         DCB_CMD_PGTX_SCFG,
147         DCB_CMD_PGRX_GCFG,
148         DCB_CMD_PGRX_SCFG,
149
150         DCB_CMD_PFC_GCFG,
151         DCB_CMD_PFC_SCFG,
152
153         DCB_CMD_SET_ALL,
154
155         DCB_CMD_GPERM_HWADDR,
156
157         DCB_CMD_GCAP,
158
159         DCB_CMD_GNUMTCS,
160         DCB_CMD_SNUMTCS,
161
162         DCB_CMD_PFC_GSTATE,
163         DCB_CMD_PFC_SSTATE,
164
165         DCB_CMD_BCN_GCFG,
166         DCB_CMD_BCN_SCFG,
167
168         DCB_CMD_GAPP,
169         DCB_CMD_SAPP,
170
171         DCB_CMD_IEEE_SET,
172         DCB_CMD_IEEE_GET,
173
174         __DCB_CMD_ENUM_MAX,
175         DCB_CMD_MAX = __DCB_CMD_ENUM_MAX - 1,
176 };
177
178 /**
179  * enum dcbnl_attrs - DCB top-level netlink attributes
180  *
181  * @DCB_ATTR_UNDEFINED: unspecified attribute to catch errors
182  * @DCB_ATTR_IFNAME: interface name of the underlying device (NLA_STRING)
183  * @DCB_ATTR_STATE: enable state of DCB in the device (NLA_U8)
184  * @DCB_ATTR_PFC_STATE: enable state of PFC in the device (NLA_U8)
185  * @DCB_ATTR_PFC_CFG: priority flow control configuration (NLA_NESTED)
186  * @DCB_ATTR_NUM_TC: number of traffic classes supported in the device (NLA_U8)
187  * @DCB_ATTR_PG_CFG: priority group configuration (NLA_NESTED)
188  * @DCB_ATTR_SET_ALL: bool to commit changes to hardware or not (NLA_U8)
189  * @DCB_ATTR_PERM_HWADDR: MAC address of the physical device (NLA_NESTED)
190  * @DCB_ATTR_CAP: DCB capabilities of the device (NLA_NESTED)
191  * @DCB_ATTR_NUMTCS: number of traffic classes supported (NLA_NESTED)
192  * @DCB_ATTR_BCN: backward congestion notification configuration (NLA_NESTED)
193  * @DCB_ATTR_IEEE: IEEE 802.1Qaz supported attributes (NLA_NESTED)
194  */
195 enum dcbnl_attrs {
196         DCB_ATTR_UNDEFINED,
197
198         DCB_ATTR_IFNAME,
199         DCB_ATTR_STATE,
200         DCB_ATTR_PFC_STATE,
201         DCB_ATTR_PFC_CFG,
202         DCB_ATTR_NUM_TC,
203         DCB_ATTR_PG_CFG,
204         DCB_ATTR_SET_ALL,
205         DCB_ATTR_PERM_HWADDR,
206         DCB_ATTR_CAP,
207         DCB_ATTR_NUMTCS,
208         DCB_ATTR_BCN,
209         DCB_ATTR_APP,
210
211         /* IEEE std attributes */
212         DCB_ATTR_IEEE,
213
214         __DCB_ATTR_ENUM_MAX,
215         DCB_ATTR_MAX = __DCB_ATTR_ENUM_MAX - 1,
216 };
217
218 enum ieee_attrs {
219         DCB_ATTR_IEEE_UNSPEC,
220         DCB_ATTR_IEEE_ETS,
221         DCB_ATTR_IEEE_PFC,
222         DCB_ATTR_IEEE_APP_TABLE,
223         __DCB_ATTR_IEEE_MAX
224 };
225 #define DCB_ATTR_IEEE_MAX (__DCB_ATTR_IEEE_MAX - 1)
226
227 enum ieee_attrs_app {
228         DCB_ATTR_IEEE_APP_UNSPEC,
229         DCB_ATTR_IEEE_APP,
230         __DCB_ATTR_IEEE_APP_MAX
231 };
232 #define DCB_ATTR_IEEE_APP_MAX (__DCB_ATTR_IEEE_APP_MAX - 1)
233
234 /**
235  * enum dcbnl_pfc_attrs - DCB Priority Flow Control user priority nested attrs
236  *
237  * @DCB_PFC_UP_ATTR_UNDEFINED: unspecified attribute to catch errors
238  * @DCB_PFC_UP_ATTR_0: Priority Flow Control value for User Priority 0 (NLA_U8)
239  * @DCB_PFC_UP_ATTR_1: Priority Flow Control value for User Priority 1 (NLA_U8)
240  * @DCB_PFC_UP_ATTR_2: Priority Flow Control value for User Priority 2 (NLA_U8)
241  * @DCB_PFC_UP_ATTR_3: Priority Flow Control value for User Priority 3 (NLA_U8)
242  * @DCB_PFC_UP_ATTR_4: Priority Flow Control value for User Priority 4 (NLA_U8)
243  * @DCB_PFC_UP_ATTR_5: Priority Flow Control value for User Priority 5 (NLA_U8)
244  * @DCB_PFC_UP_ATTR_6: Priority Flow Control value for User Priority 6 (NLA_U8)
245  * @DCB_PFC_UP_ATTR_7: Priority Flow Control value for User Priority 7 (NLA_U8)
246  * @DCB_PFC_UP_ATTR_MAX: highest attribute number currently defined
247  * @DCB_PFC_UP_ATTR_ALL: apply to all priority flow control attrs (NLA_FLAG)
248  *
249  */
250 enum dcbnl_pfc_up_attrs {
251         DCB_PFC_UP_ATTR_UNDEFINED,
252
253         DCB_PFC_UP_ATTR_0,
254         DCB_PFC_UP_ATTR_1,
255         DCB_PFC_UP_ATTR_2,
256         DCB_PFC_UP_ATTR_3,
257         DCB_PFC_UP_ATTR_4,
258         DCB_PFC_UP_ATTR_5,
259         DCB_PFC_UP_ATTR_6,
260         DCB_PFC_UP_ATTR_7,
261         DCB_PFC_UP_ATTR_ALL,
262
263         __DCB_PFC_UP_ATTR_ENUM_MAX,
264         DCB_PFC_UP_ATTR_MAX = __DCB_PFC_UP_ATTR_ENUM_MAX - 1,
265 };
266
267 /**
268  * enum dcbnl_pg_attrs - DCB Priority Group attributes
269  *
270  * @DCB_PG_ATTR_UNDEFINED: unspecified attribute to catch errors
271  * @DCB_PG_ATTR_TC_0: Priority Group Traffic Class 0 configuration (NLA_NESTED)
272  * @DCB_PG_ATTR_TC_1: Priority Group Traffic Class 1 configuration (NLA_NESTED)
273  * @DCB_PG_ATTR_TC_2: Priority Group Traffic Class 2 configuration (NLA_NESTED)
274  * @DCB_PG_ATTR_TC_3: Priority Group Traffic Class 3 configuration (NLA_NESTED)
275  * @DCB_PG_ATTR_TC_4: Priority Group Traffic Class 4 configuration (NLA_NESTED)
276  * @DCB_PG_ATTR_TC_5: Priority Group Traffic Class 5 configuration (NLA_NESTED)
277  * @DCB_PG_ATTR_TC_6: Priority Group Traffic Class 6 configuration (NLA_NESTED)
278  * @DCB_PG_ATTR_TC_7: Priority Group Traffic Class 7 configuration (NLA_NESTED)
279  * @DCB_PG_ATTR_TC_MAX: highest attribute number currently defined
280  * @DCB_PG_ATTR_TC_ALL: apply to all traffic classes (NLA_NESTED)
281  * @DCB_PG_ATTR_BW_ID_0: Percent of link bandwidth for Priority Group 0 (NLA_U8)
282  * @DCB_PG_ATTR_BW_ID_1: Percent of link bandwidth for Priority Group 1 (NLA_U8)
283  * @DCB_PG_ATTR_BW_ID_2: Percent of link bandwidth for Priority Group 2 (NLA_U8)
284  * @DCB_PG_ATTR_BW_ID_3: Percent of link bandwidth for Priority Group 3 (NLA_U8)
285  * @DCB_PG_ATTR_BW_ID_4: Percent of link bandwidth for Priority Group 4 (NLA_U8)
286  * @DCB_PG_ATTR_BW_ID_5: Percent of link bandwidth for Priority Group 5 (NLA_U8)
287  * @DCB_PG_ATTR_BW_ID_6: Percent of link bandwidth for Priority Group 6 (NLA_U8)
288  * @DCB_PG_ATTR_BW_ID_7: Percent of link bandwidth for Priority Group 7 (NLA_U8)
289  * @DCB_PG_ATTR_BW_ID_MAX: highest attribute number currently defined
290  * @DCB_PG_ATTR_BW_ID_ALL: apply to all priority groups (NLA_FLAG)
291  *
292  */
293 enum dcbnl_pg_attrs {
294         DCB_PG_ATTR_UNDEFINED,
295
296         DCB_PG_ATTR_TC_0,
297         DCB_PG_ATTR_TC_1,
298         DCB_PG_ATTR_TC_2,
299         DCB_PG_ATTR_TC_3,
300         DCB_PG_ATTR_TC_4,
301         DCB_PG_ATTR_TC_5,
302         DCB_PG_ATTR_TC_6,
303         DCB_PG_ATTR_TC_7,
304         DCB_PG_ATTR_TC_MAX,
305         DCB_PG_ATTR_TC_ALL,
306
307         DCB_PG_ATTR_BW_ID_0,
308         DCB_PG_ATTR_BW_ID_1,
309         DCB_PG_ATTR_BW_ID_2,
310         DCB_PG_ATTR_BW_ID_3,
311         DCB_PG_ATTR_BW_ID_4,
312         DCB_PG_ATTR_BW_ID_5,
313         DCB_PG_ATTR_BW_ID_6,
314         DCB_PG_ATTR_BW_ID_7,
315         DCB_PG_ATTR_BW_ID_MAX,
316         DCB_PG_ATTR_BW_ID_ALL,
317
318         __DCB_PG_ATTR_ENUM_MAX,
319         DCB_PG_ATTR_MAX = __DCB_PG_ATTR_ENUM_MAX - 1,
320 };
321
322 /**
323  * enum dcbnl_tc_attrs - DCB Traffic Class attributes
324  *
325  * @DCB_TC_ATTR_PARAM_UNDEFINED: unspecified attribute to catch errors
326  * @DCB_TC_ATTR_PARAM_PGID: (NLA_U8) Priority group the traffic class belongs to
327  *                          Valid values are:  0-7
328  * @DCB_TC_ATTR_PARAM_UP_MAPPING: (NLA_U8) Traffic class to user priority map
329  *                                Some devices may not support changing the
330  *                                user priority map of a TC.
331  * @DCB_TC_ATTR_PARAM_STRICT_PRIO: (NLA_U8) Strict priority setting
332  *                                 0 - none
333  *                                 1 - group strict
334  *                                 2 - link strict
335  * @DCB_TC_ATTR_PARAM_BW_PCT: optional - (NLA_U8) If supported by the device and
336  *                            not configured to use link strict priority,
337  *                            this is the percentage of bandwidth of the
338  *                            priority group this traffic class belongs to
339  * @DCB_TC_ATTR_PARAM_ALL: (NLA_FLAG) all traffic class parameters
340  *
341  */
342 enum dcbnl_tc_attrs {
343         DCB_TC_ATTR_PARAM_UNDEFINED,
344
345         DCB_TC_ATTR_PARAM_PGID,
346         DCB_TC_ATTR_PARAM_UP_MAPPING,
347         DCB_TC_ATTR_PARAM_STRICT_PRIO,
348         DCB_TC_ATTR_PARAM_BW_PCT,
349         DCB_TC_ATTR_PARAM_ALL,
350
351         __DCB_TC_ATTR_PARAM_ENUM_MAX,
352         DCB_TC_ATTR_PARAM_MAX = __DCB_TC_ATTR_PARAM_ENUM_MAX - 1,
353 };
354
355 /**
356  * enum dcbnl_cap_attrs - DCB Capability attributes
357  *
358  * @DCB_CAP_ATTR_UNDEFINED: unspecified attribute to catch errors
359  * @DCB_CAP_ATTR_ALL: (NLA_FLAG) all capability parameters
360  * @DCB_CAP_ATTR_PG: (NLA_U8) device supports Priority Groups
361  * @DCB_CAP_ATTR_PFC: (NLA_U8) device supports Priority Flow Control
362  * @DCB_CAP_ATTR_UP2TC: (NLA_U8) device supports user priority to
363  *                               traffic class mapping
364  * @DCB_CAP_ATTR_PG_TCS: (NLA_U8) bitmap where each bit represents a
365  *                                number of traffic classes the device
366  *                                can be configured to use for Priority Groups
367  * @DCB_CAP_ATTR_PFC_TCS: (NLA_U8) bitmap where each bit represents a
368  *                                 number of traffic classes the device can be
369  *                                 configured to use for Priority Flow Control
370  * @DCB_CAP_ATTR_GSP: (NLA_U8) device supports group strict priority
371  * @DCB_CAP_ATTR_BCN: (NLA_U8) device supports Backwards Congestion
372  *                             Notification
373  */
374 enum dcbnl_cap_attrs {
375         DCB_CAP_ATTR_UNDEFINED,
376         DCB_CAP_ATTR_ALL,
377         DCB_CAP_ATTR_PG,
378         DCB_CAP_ATTR_PFC,
379         DCB_CAP_ATTR_UP2TC,
380         DCB_CAP_ATTR_PG_TCS,
381         DCB_CAP_ATTR_PFC_TCS,
382         DCB_CAP_ATTR_GSP,
383         DCB_CAP_ATTR_BCN,
384
385         __DCB_CAP_ATTR_ENUM_MAX,
386         DCB_CAP_ATTR_MAX = __DCB_CAP_ATTR_ENUM_MAX - 1,
387 };
388
389 /**
390  * enum dcbnl_numtcs_attrs - number of traffic classes
391  *
392  * @DCB_NUMTCS_ATTR_UNDEFINED: unspecified attribute to catch errors
393  * @DCB_NUMTCS_ATTR_ALL: (NLA_FLAG) all traffic class attributes
394  * @DCB_NUMTCS_ATTR_PG: (NLA_U8) number of traffic classes used for
395  *                               priority groups
396  * @DCB_NUMTCS_ATTR_PFC: (NLA_U8) number of traffic classes which can
397  *                                support priority flow control
398  */
399 enum dcbnl_numtcs_attrs {
400         DCB_NUMTCS_ATTR_UNDEFINED,
401         DCB_NUMTCS_ATTR_ALL,
402         DCB_NUMTCS_ATTR_PG,
403         DCB_NUMTCS_ATTR_PFC,
404
405         __DCB_NUMTCS_ATTR_ENUM_MAX,
406         DCB_NUMTCS_ATTR_MAX = __DCB_NUMTCS_ATTR_ENUM_MAX - 1,
407 };
408
409 enum dcbnl_bcn_attrs{
410         DCB_BCN_ATTR_UNDEFINED = 0,
411
412         DCB_BCN_ATTR_RP_0,
413         DCB_BCN_ATTR_RP_1,
414         DCB_BCN_ATTR_RP_2,
415         DCB_BCN_ATTR_RP_3,
416         DCB_BCN_ATTR_RP_4,
417         DCB_BCN_ATTR_RP_5,
418         DCB_BCN_ATTR_RP_6,
419         DCB_BCN_ATTR_RP_7,
420         DCB_BCN_ATTR_RP_ALL,
421
422         DCB_BCN_ATTR_BCNA_0,
423         DCB_BCN_ATTR_BCNA_1,
424         DCB_BCN_ATTR_ALPHA,
425         DCB_BCN_ATTR_BETA,
426         DCB_BCN_ATTR_GD,
427         DCB_BCN_ATTR_GI,
428         DCB_BCN_ATTR_TMAX,
429         DCB_BCN_ATTR_TD,
430         DCB_BCN_ATTR_RMIN,
431         DCB_BCN_ATTR_W,
432         DCB_BCN_ATTR_RD,
433         DCB_BCN_ATTR_RU,
434         DCB_BCN_ATTR_WRTT,
435         DCB_BCN_ATTR_RI,
436         DCB_BCN_ATTR_C,
437         DCB_BCN_ATTR_ALL,
438
439         __DCB_BCN_ATTR_ENUM_MAX,
440         DCB_BCN_ATTR_MAX = __DCB_BCN_ATTR_ENUM_MAX - 1,
441 };
442
443 /**
444  * enum dcb_general_attr_values - general DCB attribute values
445  *
446  * @DCB_ATTR_UNDEFINED: value used to indicate an attribute is not supported
447  *
448  */
449 enum dcb_general_attr_values {
450         DCB_ATTR_VALUE_UNDEFINED = 0xff
451 };
452
453 #define DCB_APP_IDTYPE_ETHTYPE  0x00
454 #define DCB_APP_IDTYPE_PORTNUM  0x01
455 enum dcbnl_app_attrs {
456         DCB_APP_ATTR_UNDEFINED,
457
458         DCB_APP_ATTR_IDTYPE,
459         DCB_APP_ATTR_ID,
460         DCB_APP_ATTR_PRIORITY,
461
462         __DCB_APP_ATTR_ENUM_MAX,
463         DCB_APP_ATTR_MAX = __DCB_APP_ATTR_ENUM_MAX - 1,
464 };
465
466 #endif /* __LINUX_DCBNL_H__ */