1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright (c) 2021, Intel Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the Intel Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
37 #include "ice_common.h"
39 #define ICE_DCBX_OFFLOAD_DIS 0
40 #define ICE_DCBX_OFFLOAD_ENABLED 1
42 #define ICE_DCBX_STATUS_NOT_STARTED 0
43 #define ICE_DCBX_STATUS_IN_PROGRESS 1
44 #define ICE_DCBX_STATUS_DONE 2
45 #define ICE_DCBX_STATUS_MULTIPLE_PEERS 3
46 #define ICE_DCBX_STATUS_DIS 7
48 #define ICE_TLV_TYPE_END 0
49 #define ICE_TLV_TYPE_ORG 127
51 #define ICE_IEEE_8021QAZ_OUI 0x0080C2
52 #define ICE_IEEE_SUBTYPE_ETS_CFG 9
53 #define ICE_IEEE_SUBTYPE_ETS_REC 10
54 #define ICE_IEEE_SUBTYPE_PFC_CFG 11
55 #define ICE_IEEE_SUBTYPE_APP_PRI 12
57 #define ICE_CEE_DCBX_OUI 0x001B21
58 #define ICE_CEE_DCBX_TYPE 2
60 #define ICE_CEE_SUBTYPE_CTRL 1
61 #define ICE_CEE_SUBTYPE_PG_CFG 2
62 #define ICE_CEE_SUBTYPE_PFC_CFG 3
63 #define ICE_CEE_SUBTYPE_APP_PRI 4
65 #define ICE_CEE_MAX_FEAT_TYPE 3
66 #define ICE_LLDP_ADMINSTATUS_DIS 0
67 #define ICE_LLDP_ADMINSTATUS_ENA_RX 1
68 #define ICE_LLDP_ADMINSTATUS_ENA_TX 2
69 #define ICE_LLDP_ADMINSTATUS_ENA_RXTX 3
71 /* Defines for LLDP TLV header */
72 #define ICE_LLDP_TLV_LEN_S 0
73 #define ICE_LLDP_TLV_LEN_M (0x01FF << ICE_LLDP_TLV_LEN_S)
74 #define ICE_LLDP_TLV_TYPE_S 9
75 #define ICE_LLDP_TLV_TYPE_M (0x7F << ICE_LLDP_TLV_TYPE_S)
76 #define ICE_LLDP_TLV_SUBTYPE_S 0
77 #define ICE_LLDP_TLV_SUBTYPE_M (0xFF << ICE_LLDP_TLV_SUBTYPE_S)
78 #define ICE_LLDP_TLV_OUI_S 8
79 #define ICE_LLDP_TLV_OUI_M (0xFFFFFFUL << ICE_LLDP_TLV_OUI_S)
81 /* Defines for IEEE ETS TLV */
82 #define ICE_IEEE_ETS_MAXTC_S 0
83 #define ICE_IEEE_ETS_MAXTC_M (0x7 << ICE_IEEE_ETS_MAXTC_S)
84 #define ICE_IEEE_ETS_CBS_S 6
85 #define ICE_IEEE_ETS_CBS_M BIT(ICE_IEEE_ETS_CBS_S)
86 #define ICE_IEEE_ETS_WILLING_S 7
87 #define ICE_IEEE_ETS_WILLING_M BIT(ICE_IEEE_ETS_WILLING_S)
88 #define ICE_IEEE_ETS_PRIO_0_S 0
89 #define ICE_IEEE_ETS_PRIO_0_M (0x7 << ICE_IEEE_ETS_PRIO_0_S)
90 #define ICE_IEEE_ETS_PRIO_1_S 4
91 #define ICE_IEEE_ETS_PRIO_1_M (0x7 << ICE_IEEE_ETS_PRIO_1_S)
92 #define ICE_CEE_PGID_PRIO_0_S 0
93 #define ICE_CEE_PGID_PRIO_0_M (0xF << ICE_CEE_PGID_PRIO_0_S)
94 #define ICE_CEE_PGID_PRIO_1_S 4
95 #define ICE_CEE_PGID_PRIO_1_M (0xF << ICE_CEE_PGID_PRIO_1_S)
96 #define ICE_CEE_PGID_STRICT 15
98 /* Defines for IEEE TSA types */
99 #define ICE_IEEE_TSA_STRICT 0
100 #define ICE_IEEE_TSA_CBS 1
101 #define ICE_IEEE_TSA_ETS 2
102 #define ICE_IEEE_TSA_VENDOR 255
104 /* Defines for IEEE PFC TLV */
105 #define ICE_IEEE_PFC_CAP_S 0
106 #define ICE_IEEE_PFC_CAP_M (0xF << ICE_IEEE_PFC_CAP_S)
107 #define ICE_IEEE_PFC_MBC_S 6
108 #define ICE_IEEE_PFC_MBC_M BIT(ICE_IEEE_PFC_MBC_S)
109 #define ICE_IEEE_PFC_WILLING_S 7
110 #define ICE_IEEE_PFC_WILLING_M BIT(ICE_IEEE_PFC_WILLING_S)
112 /* Defines for IEEE APP TLV */
113 #define ICE_IEEE_APP_SEL_S 0
114 #define ICE_IEEE_APP_SEL_M (0x7 << ICE_IEEE_APP_SEL_S)
115 #define ICE_IEEE_APP_PRIO_S 5
116 #define ICE_IEEE_APP_PRIO_M (0x7 << ICE_IEEE_APP_PRIO_S)
118 /* TLV definitions for preparing MIB */
119 #define ICE_TLV_ID_CHASSIS_ID 0
120 #define ICE_TLV_ID_PORT_ID 1
121 #define ICE_TLV_ID_TIME_TO_LIVE 2
122 #define ICE_IEEE_TLV_ID_ETS_CFG 3
123 #define ICE_IEEE_TLV_ID_ETS_REC 4
124 #define ICE_IEEE_TLV_ID_PFC_CFG 5
125 #define ICE_IEEE_TLV_ID_APP_PRI 6
126 #define ICE_TLV_ID_END_OF_LLDPPDU 7
127 #define ICE_TLV_ID_START ICE_IEEE_TLV_ID_ETS_CFG
129 #define ICE_IEEE_ETS_TLV_LEN 25
130 #define ICE_IEEE_PFC_TLV_LEN 6
131 #define ICE_IEEE_APP_TLV_LEN 11
134 /* IEEE 802.1AB LLDP Organization specific TLV */
135 struct ice_lldp_org_tlv {
138 u8 tlvinfo[STRUCT_HACK_VAR_LEN];
142 struct ice_cee_tlv_hdr {
148 struct ice_cee_ctrl_tlv {
149 struct ice_cee_tlv_hdr hdr;
154 struct ice_cee_feat_tlv {
155 struct ice_cee_tlv_hdr hdr;
156 u8 en_will_err; /* Bits: |En|Will|Err|Reserved(5)| */
157 #define ICE_CEE_FEAT_TLV_ENA_M 0x80
158 #define ICE_CEE_FEAT_TLV_WILLING_M 0x40
159 #define ICE_CEE_FEAT_TLV_ERR_M 0x20
161 u8 tlvinfo[STRUCT_HACK_VAR_LEN];
165 struct ice_cee_app_prio {
167 u8 upper_oui_sel; /* Bits: |Upper OUI(6)|Selector(2)| */
168 #define ICE_CEE_APP_SELECTOR_M 0x03
174 /* TODO: The below structures related LLDP/DCBX variables
175 * and statistics are defined but need to find how to get
176 * the required information from the Firmware to use them
179 /* IEEE 802.1AB LLDP Agent Statistics */
180 struct ice_lldp_stats {
181 u64 remtablelastchangetime;
187 u64 rxframesdiscarded;
188 u64 rxportframeerrors;
189 u64 rxportframestotal;
190 u64 rxporttlvsdiscardedtotal;
191 u64 rxporttlvsunrecognizedtotal;
192 u64 remtoomanyneighbors;
195 /* IEEE 802.1Qaz DCBX variables */
196 struct ice_dcbx_variables {
197 u32 defmaxtrafficclasses;
198 u32 defprioritytcmapping;
200 u32 deftsaassignment;
204 ice_aq_get_lldp_mib(struct ice_hw *hw, u8 bridge_type, u8 mib_type, void *buf,
205 u16 buf_size, u16 *local_len, u16 *remote_len,
206 struct ice_sq_cd *cd);
208 ice_aq_add_delete_lldp_tlv(struct ice_hw *hw, u8 bridge_type, bool add_lldp_tlv,
209 void *buf, u16 buf_size, u16 tlv_len, u16 *mib_len,
210 struct ice_sq_cd *cd);
212 ice_aq_update_lldp_tlv(struct ice_hw *hw, u8 bridge_type, void *buf,
213 u16 buf_size, u16 old_len, u16 new_len, u16 offset,
214 u16 *mib_len, struct ice_sq_cd *cd);
216 ice_aq_dcb_ignore_pfc(struct ice_hw *hw, u8 tcmap, bool request, u8 *tcmap_ret,
217 struct ice_sq_cd *cd);
219 ice_aq_get_cee_dcb_cfg(struct ice_hw *hw,
220 struct ice_aqc_get_cee_dcb_cfg_resp *buff,
221 struct ice_sq_cd *cd);
223 ice_aq_query_pfc_mode(struct ice_hw *hw, u8 *pfcmode_ret, struct ice_sq_cd *cd);
225 ice_aq_set_pfc_mode(struct ice_hw *hw, u8 pfcmode_set, u8 *pfcmode_ret,
226 struct ice_sq_cd *cd);
228 ice_aq_set_dcb_parameters(struct ice_hw *hw, bool dcb_enable,
229 struct ice_sq_cd *cd);
230 enum ice_status ice_lldp_to_dcb_cfg(u8 *lldpmib, struct ice_dcbx_cfg *dcbcfg);
231 u8 ice_get_dcbx_status(struct ice_hw *hw);
233 ice_aq_get_dcb_cfg(struct ice_hw *hw, u8 mib_type, u8 bridgetype,
234 struct ice_dcbx_cfg *dcbcfg);
235 enum ice_status ice_get_dcb_cfg(struct ice_port_info *pi);
236 enum ice_status ice_set_dcb_cfg(struct ice_port_info *pi);
237 enum ice_status ice_init_dcb(struct ice_hw *hw, bool enable_mib_change);
238 void ice_dcb_cfg_to_lldp(u8 *lldpmib, u16 *miblen, struct ice_dcbx_cfg *dcbcfg);
240 ice_query_port_ets(struct ice_port_info *pi,
241 struct ice_aqc_port_ets_elem *buf, u16 buf_size,
242 struct ice_sq_cd *cmd_details);
244 ice_aq_query_port_ets(struct ice_port_info *pi,
245 struct ice_aqc_port_ets_elem *buf, u16 buf_size,
246 struct ice_sq_cd *cd);
248 ice_update_port_tc_tree_cfg(struct ice_port_info *pi,
249 struct ice_aqc_port_ets_elem *buf);
251 ice_aq_stop_lldp(struct ice_hw *hw, bool shutdown_lldp_agent, bool persist,
252 struct ice_sq_cd *cd);
254 ice_aq_start_lldp(struct ice_hw *hw, bool persist, struct ice_sq_cd *cd);
256 ice_aq_start_stop_dcbx(struct ice_hw *hw, bool start_dcbx_agent,
257 bool *dcbx_agent_status, struct ice_sq_cd *cd);
258 enum ice_status ice_cfg_lldp_mib_change(struct ice_hw *hw, bool ena_mib);
260 ice_aq_cfg_lldp_mib_change(struct ice_hw *hw, bool ena_update,
261 struct ice_sq_cd *cd);
262 #endif /* _ICE_DCB_H_ */