xref: /freebsd/sys/dev/ixl/i40e_dcb.h (revision ceebc2f348c028b21bf9bcc99f7a3c4b0cb7d926)
1*ceebc2f3SEric Joyner /******************************************************************************
2*ceebc2f3SEric Joyner 
3*ceebc2f3SEric Joyner   Copyright (c) 2013-2017, Intel Corporation
4*ceebc2f3SEric Joyner   All rights reserved.
5*ceebc2f3SEric Joyner 
6*ceebc2f3SEric Joyner   Redistribution and use in source and binary forms, with or without
7*ceebc2f3SEric Joyner   modification, are permitted provided that the following conditions are met:
8*ceebc2f3SEric Joyner 
9*ceebc2f3SEric Joyner    1. Redistributions of source code must retain the above copyright notice,
10*ceebc2f3SEric Joyner       this list of conditions and the following disclaimer.
11*ceebc2f3SEric Joyner 
12*ceebc2f3SEric Joyner    2. Redistributions in binary form must reproduce the above copyright
13*ceebc2f3SEric Joyner       notice, this list of conditions and the following disclaimer in the
14*ceebc2f3SEric Joyner       documentation and/or other materials provided with the distribution.
15*ceebc2f3SEric Joyner 
16*ceebc2f3SEric Joyner    3. Neither the name of the Intel Corporation nor the names of its
17*ceebc2f3SEric Joyner       contributors may be used to endorse or promote products derived from
18*ceebc2f3SEric Joyner       this software without specific prior written permission.
19*ceebc2f3SEric Joyner 
20*ceebc2f3SEric Joyner   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21*ceebc2f3SEric Joyner   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22*ceebc2f3SEric Joyner   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23*ceebc2f3SEric Joyner   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24*ceebc2f3SEric Joyner   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25*ceebc2f3SEric Joyner   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26*ceebc2f3SEric Joyner   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27*ceebc2f3SEric Joyner   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28*ceebc2f3SEric Joyner   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29*ceebc2f3SEric Joyner   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30*ceebc2f3SEric Joyner   POSSIBILITY OF SUCH DAMAGE.
31*ceebc2f3SEric Joyner 
32*ceebc2f3SEric Joyner ******************************************************************************/
33*ceebc2f3SEric Joyner /*$FreeBSD$*/
34*ceebc2f3SEric Joyner 
35*ceebc2f3SEric Joyner #ifndef _I40E_DCB_H_
36*ceebc2f3SEric Joyner #define _I40E_DCB_H_
37*ceebc2f3SEric Joyner 
38*ceebc2f3SEric Joyner #include "i40e_type.h"
39*ceebc2f3SEric Joyner 
40*ceebc2f3SEric Joyner #define I40E_DCBX_OFFLOAD_DISABLED	0
41*ceebc2f3SEric Joyner #define I40E_DCBX_OFFLOAD_ENABLED	1
42*ceebc2f3SEric Joyner 
43*ceebc2f3SEric Joyner #define I40E_DCBX_STATUS_NOT_STARTED	0
44*ceebc2f3SEric Joyner #define I40E_DCBX_STATUS_IN_PROGRESS	1
45*ceebc2f3SEric Joyner #define I40E_DCBX_STATUS_DONE		2
46*ceebc2f3SEric Joyner #define I40E_DCBX_STATUS_MULTIPLE_PEERS	3
47*ceebc2f3SEric Joyner #define I40E_DCBX_STATUS_DISABLED	7
48*ceebc2f3SEric Joyner 
49*ceebc2f3SEric Joyner #define I40E_TLV_TYPE_END		0
50*ceebc2f3SEric Joyner #define I40E_TLV_TYPE_ORG		127
51*ceebc2f3SEric Joyner 
52*ceebc2f3SEric Joyner #define I40E_IEEE_8021QAZ_OUI		0x0080C2
53*ceebc2f3SEric Joyner #define I40E_IEEE_SUBTYPE_ETS_CFG	9
54*ceebc2f3SEric Joyner #define I40E_IEEE_SUBTYPE_ETS_REC	10
55*ceebc2f3SEric Joyner #define I40E_IEEE_SUBTYPE_PFC_CFG	11
56*ceebc2f3SEric Joyner #define I40E_IEEE_SUBTYPE_APP_PRI	12
57*ceebc2f3SEric Joyner 
58*ceebc2f3SEric Joyner #define I40E_CEE_DCBX_OUI		0x001b21
59*ceebc2f3SEric Joyner #define I40E_CEE_DCBX_TYPE		2
60*ceebc2f3SEric Joyner 
61*ceebc2f3SEric Joyner #define I40E_CEE_SUBTYPE_CTRL		1
62*ceebc2f3SEric Joyner #define I40E_CEE_SUBTYPE_PG_CFG		2
63*ceebc2f3SEric Joyner #define I40E_CEE_SUBTYPE_PFC_CFG	3
64*ceebc2f3SEric Joyner #define I40E_CEE_SUBTYPE_APP_PRI	4
65*ceebc2f3SEric Joyner 
66*ceebc2f3SEric Joyner #define I40E_CEE_MAX_FEAT_TYPE		3
67*ceebc2f3SEric Joyner #define I40E_LLDP_ADMINSTATUS_DISABLED		0
68*ceebc2f3SEric Joyner #define I40E_LLDP_ADMINSTATUS_ENABLED_RX	1
69*ceebc2f3SEric Joyner #define I40E_LLDP_ADMINSTATUS_ENABLED_TX	2
70*ceebc2f3SEric Joyner #define I40E_LLDP_ADMINSTATUS_ENABLED_RXTX	3
71*ceebc2f3SEric Joyner 
72*ceebc2f3SEric Joyner /* Defines for LLDP TLV header */
73*ceebc2f3SEric Joyner #define I40E_LLDP_MIB_HLEN		14
74*ceebc2f3SEric Joyner #define I40E_LLDP_TLV_LEN_SHIFT		0
75*ceebc2f3SEric Joyner #define I40E_LLDP_TLV_LEN_MASK		(0x01FF << I40E_LLDP_TLV_LEN_SHIFT)
76*ceebc2f3SEric Joyner #define I40E_LLDP_TLV_TYPE_SHIFT	9
77*ceebc2f3SEric Joyner #define I40E_LLDP_TLV_TYPE_MASK		(0x7F << I40E_LLDP_TLV_TYPE_SHIFT)
78*ceebc2f3SEric Joyner #define I40E_LLDP_TLV_SUBTYPE_SHIFT	0
79*ceebc2f3SEric Joyner #define I40E_LLDP_TLV_SUBTYPE_MASK	(0xFF << I40E_LLDP_TLV_SUBTYPE_SHIFT)
80*ceebc2f3SEric Joyner #define I40E_LLDP_TLV_OUI_SHIFT		8
81*ceebc2f3SEric Joyner #define I40E_LLDP_TLV_OUI_MASK		(0xFFFFFF << I40E_LLDP_TLV_OUI_SHIFT)
82*ceebc2f3SEric Joyner 
83*ceebc2f3SEric Joyner /* Defines for IEEE ETS TLV */
84*ceebc2f3SEric Joyner #define I40E_IEEE_ETS_MAXTC_SHIFT	0
85*ceebc2f3SEric Joyner #define I40E_IEEE_ETS_MAXTC_MASK	(0x7 << I40E_IEEE_ETS_MAXTC_SHIFT)
86*ceebc2f3SEric Joyner #define I40E_IEEE_ETS_CBS_SHIFT		6
87*ceebc2f3SEric Joyner #define I40E_IEEE_ETS_CBS_MASK		BIT(I40E_IEEE_ETS_CBS_SHIFT)
88*ceebc2f3SEric Joyner #define I40E_IEEE_ETS_WILLING_SHIFT	7
89*ceebc2f3SEric Joyner #define I40E_IEEE_ETS_WILLING_MASK	BIT(I40E_IEEE_ETS_WILLING_SHIFT)
90*ceebc2f3SEric Joyner #define I40E_IEEE_ETS_PRIO_0_SHIFT	0
91*ceebc2f3SEric Joyner #define I40E_IEEE_ETS_PRIO_0_MASK	(0x7 << I40E_IEEE_ETS_PRIO_0_SHIFT)
92*ceebc2f3SEric Joyner #define I40E_IEEE_ETS_PRIO_1_SHIFT	4
93*ceebc2f3SEric Joyner #define I40E_IEEE_ETS_PRIO_1_MASK	(0x7 << I40E_IEEE_ETS_PRIO_1_SHIFT)
94*ceebc2f3SEric Joyner #define I40E_CEE_PGID_PRIO_0_SHIFT	0
95*ceebc2f3SEric Joyner #define I40E_CEE_PGID_PRIO_0_MASK	(0xF << I40E_CEE_PGID_PRIO_0_SHIFT)
96*ceebc2f3SEric Joyner #define I40E_CEE_PGID_PRIO_1_SHIFT	4
97*ceebc2f3SEric Joyner #define I40E_CEE_PGID_PRIO_1_MASK	(0xF << I40E_CEE_PGID_PRIO_1_SHIFT)
98*ceebc2f3SEric Joyner #define I40E_CEE_PGID_STRICT		15
99*ceebc2f3SEric Joyner 
100*ceebc2f3SEric Joyner /* Defines for IEEE TSA types */
101*ceebc2f3SEric Joyner #define I40E_IEEE_TSA_STRICT		0
102*ceebc2f3SEric Joyner #define I40E_IEEE_TSA_CBS		1
103*ceebc2f3SEric Joyner #define I40E_IEEE_TSA_ETS		2
104*ceebc2f3SEric Joyner #define I40E_IEEE_TSA_VENDOR		255
105*ceebc2f3SEric Joyner 
106*ceebc2f3SEric Joyner /* Defines for IEEE PFC TLV */
107*ceebc2f3SEric Joyner #define I40E_IEEE_PFC_CAP_SHIFT		0
108*ceebc2f3SEric Joyner #define I40E_IEEE_PFC_CAP_MASK		(0xF << I40E_IEEE_PFC_CAP_SHIFT)
109*ceebc2f3SEric Joyner #define I40E_IEEE_PFC_MBC_SHIFT		6
110*ceebc2f3SEric Joyner #define I40E_IEEE_PFC_MBC_MASK		BIT(I40E_IEEE_PFC_MBC_SHIFT)
111*ceebc2f3SEric Joyner #define I40E_IEEE_PFC_WILLING_SHIFT	7
112*ceebc2f3SEric Joyner #define I40E_IEEE_PFC_WILLING_MASK	BIT(I40E_IEEE_PFC_WILLING_SHIFT)
113*ceebc2f3SEric Joyner 
114*ceebc2f3SEric Joyner /* Defines for IEEE APP TLV */
115*ceebc2f3SEric Joyner #define I40E_IEEE_APP_SEL_SHIFT		0
116*ceebc2f3SEric Joyner #define I40E_IEEE_APP_SEL_MASK		(0x7 << I40E_IEEE_APP_SEL_SHIFT)
117*ceebc2f3SEric Joyner #define I40E_IEEE_APP_PRIO_SHIFT	5
118*ceebc2f3SEric Joyner #define I40E_IEEE_APP_PRIO_MASK		(0x7 << I40E_IEEE_APP_PRIO_SHIFT)
119*ceebc2f3SEric Joyner 
120*ceebc2f3SEric Joyner /* TLV definitions for preparing MIB */
121*ceebc2f3SEric Joyner #define I40E_TLV_ID_CHASSIS_ID		0
122*ceebc2f3SEric Joyner #define I40E_TLV_ID_PORT_ID		1
123*ceebc2f3SEric Joyner #define I40E_TLV_ID_TIME_TO_LIVE	2
124*ceebc2f3SEric Joyner #define I40E_IEEE_TLV_ID_ETS_CFG	3
125*ceebc2f3SEric Joyner #define I40E_IEEE_TLV_ID_ETS_REC	4
126*ceebc2f3SEric Joyner #define I40E_IEEE_TLV_ID_PFC_CFG	5
127*ceebc2f3SEric Joyner #define I40E_IEEE_TLV_ID_APP_PRI	6
128*ceebc2f3SEric Joyner #define I40E_TLV_ID_END_OF_LLDPPDU	7
129*ceebc2f3SEric Joyner #define I40E_TLV_ID_START		I40E_IEEE_TLV_ID_ETS_CFG
130*ceebc2f3SEric Joyner 
131*ceebc2f3SEric Joyner #define I40E_IEEE_ETS_TLV_LENGTH	25
132*ceebc2f3SEric Joyner #define I40E_IEEE_PFC_TLV_LENGTH	6
133*ceebc2f3SEric Joyner #define I40E_IEEE_APP_TLV_LENGTH	11
134*ceebc2f3SEric Joyner 
135*ceebc2f3SEric Joyner #pragma pack(1)
136*ceebc2f3SEric Joyner 
137*ceebc2f3SEric Joyner /* IEEE 802.1AB LLDP TLV structure */
138*ceebc2f3SEric Joyner struct i40e_lldp_generic_tlv {
139*ceebc2f3SEric Joyner 	__be16 typelength;
140*ceebc2f3SEric Joyner 	u8 tlvinfo[1];
141*ceebc2f3SEric Joyner };
142*ceebc2f3SEric Joyner 
143*ceebc2f3SEric Joyner /* IEEE 802.1AB LLDP Organization specific TLV */
144*ceebc2f3SEric Joyner struct i40e_lldp_org_tlv {
145*ceebc2f3SEric Joyner 	__be16 typelength;
146*ceebc2f3SEric Joyner 	__be32 ouisubtype;
147*ceebc2f3SEric Joyner 	u8 tlvinfo[1];
148*ceebc2f3SEric Joyner };
149*ceebc2f3SEric Joyner 
150*ceebc2f3SEric Joyner struct i40e_cee_tlv_hdr {
151*ceebc2f3SEric Joyner 	__be16 typelen;
152*ceebc2f3SEric Joyner 	u8 operver;
153*ceebc2f3SEric Joyner 	u8 maxver;
154*ceebc2f3SEric Joyner };
155*ceebc2f3SEric Joyner 
156*ceebc2f3SEric Joyner struct i40e_cee_ctrl_tlv {
157*ceebc2f3SEric Joyner 	struct i40e_cee_tlv_hdr hdr;
158*ceebc2f3SEric Joyner 	__be32 seqno;
159*ceebc2f3SEric Joyner 	__be32 ackno;
160*ceebc2f3SEric Joyner };
161*ceebc2f3SEric Joyner 
162*ceebc2f3SEric Joyner struct i40e_cee_feat_tlv {
163*ceebc2f3SEric Joyner 	struct i40e_cee_tlv_hdr hdr;
164*ceebc2f3SEric Joyner 	u8 en_will_err; /* Bits: |En|Will|Err|Reserved(5)| */
165*ceebc2f3SEric Joyner #define I40E_CEE_FEAT_TLV_ENABLE_MASK	0x80
166*ceebc2f3SEric Joyner #define I40E_CEE_FEAT_TLV_WILLING_MASK	0x40
167*ceebc2f3SEric Joyner #define I40E_CEE_FEAT_TLV_ERR_MASK	0x20
168*ceebc2f3SEric Joyner 	u8 subtype;
169*ceebc2f3SEric Joyner 	u8 tlvinfo[1];
170*ceebc2f3SEric Joyner };
171*ceebc2f3SEric Joyner 
172*ceebc2f3SEric Joyner struct i40e_cee_app_prio {
173*ceebc2f3SEric Joyner 	__be16 protocol;
174*ceebc2f3SEric Joyner 	u8 upper_oui_sel; /* Bits: |Upper OUI(6)|Selector(2)| */
175*ceebc2f3SEric Joyner #define I40E_CEE_APP_SELECTOR_MASK	0x03
176*ceebc2f3SEric Joyner 	__be16 lower_oui;
177*ceebc2f3SEric Joyner 	u8 prio_map;
178*ceebc2f3SEric Joyner };
179*ceebc2f3SEric Joyner #pragma pack()
180*ceebc2f3SEric Joyner 
181*ceebc2f3SEric Joyner /*
182*ceebc2f3SEric Joyner  * TODO: The below structures related LLDP/DCBX variables
183*ceebc2f3SEric Joyner  * and statistics are defined but need to find how to get
184*ceebc2f3SEric Joyner  * the required information from the Firmware to use them
185*ceebc2f3SEric Joyner  */
186*ceebc2f3SEric Joyner 
187*ceebc2f3SEric Joyner /* IEEE 802.1AB LLDP Agent Statistics */
188*ceebc2f3SEric Joyner struct i40e_lldp_stats {
189*ceebc2f3SEric Joyner 	u64 remtablelastchangetime;
190*ceebc2f3SEric Joyner 	u64 remtableinserts;
191*ceebc2f3SEric Joyner 	u64 remtabledeletes;
192*ceebc2f3SEric Joyner 	u64 remtabledrops;
193*ceebc2f3SEric Joyner 	u64 remtableageouts;
194*ceebc2f3SEric Joyner 	u64 txframestotal;
195*ceebc2f3SEric Joyner 	u64 rxframesdiscarded;
196*ceebc2f3SEric Joyner 	u64 rxportframeerrors;
197*ceebc2f3SEric Joyner 	u64 rxportframestotal;
198*ceebc2f3SEric Joyner 	u64 rxporttlvsdiscardedtotal;
199*ceebc2f3SEric Joyner 	u64 rxporttlvsunrecognizedtotal;
200*ceebc2f3SEric Joyner 	u64 remtoomanyneighbors;
201*ceebc2f3SEric Joyner };
202*ceebc2f3SEric Joyner 
203*ceebc2f3SEric Joyner /* IEEE 802.1Qaz DCBX variables */
204*ceebc2f3SEric Joyner struct i40e_dcbx_variables {
205*ceebc2f3SEric Joyner 	u32 defmaxtrafficclasses;
206*ceebc2f3SEric Joyner 	u32 defprioritytcmapping;
207*ceebc2f3SEric Joyner 	u32 deftcbandwidth;
208*ceebc2f3SEric Joyner 	u32 deftsaassignment;
209*ceebc2f3SEric Joyner };
210*ceebc2f3SEric Joyner 
211*ceebc2f3SEric Joyner enum i40e_status_code i40e_get_dcbx_status(struct i40e_hw *hw,
212*ceebc2f3SEric Joyner 					   u16 *status);
213*ceebc2f3SEric Joyner enum i40e_status_code i40e_lldp_to_dcb_config(u8 *lldpmib,
214*ceebc2f3SEric Joyner 					      struct i40e_dcbx_config *dcbcfg);
215*ceebc2f3SEric Joyner enum i40e_status_code i40e_aq_get_dcb_config(struct i40e_hw *hw, u8 mib_type,
216*ceebc2f3SEric Joyner 					     u8 bridgetype,
217*ceebc2f3SEric Joyner 					     struct i40e_dcbx_config *dcbcfg);
218*ceebc2f3SEric Joyner enum i40e_status_code i40e_get_dcb_config(struct i40e_hw *hw);
219*ceebc2f3SEric Joyner enum i40e_status_code i40e_init_dcb(struct i40e_hw *hw);
220*ceebc2f3SEric Joyner enum i40e_status_code i40e_set_dcb_config(struct i40e_hw *hw);
221*ceebc2f3SEric Joyner enum i40e_status_code i40e_dcb_config_to_lldp(u8 *lldpmib, u16 *miblen,
222*ceebc2f3SEric Joyner 					      struct i40e_dcbx_config *dcbcfg);
223*ceebc2f3SEric Joyner 
224*ceebc2f3SEric Joyner #endif /* _I40E_DCB_H_ */
225