1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* Copyright (c) 2020, Intel Corporation 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * 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. 14 * 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. 18 * 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. 30 */ 31 /*$FreeBSD$*/ 32 33 #ifndef _ICE_DCB_H_ 34 #define _ICE_DCB_H_ 35 36 #include "ice_type.h" 37 #include "ice_common.h" 38 39 #define ICE_DCBX_OFFLOAD_DIS 0 40 #define ICE_DCBX_OFFLOAD_ENABLED 1 41 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 47 48 #define ICE_TLV_TYPE_END 0 49 #define ICE_TLV_TYPE_ORG 127 50 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 56 57 #define ICE_CEE_DCBX_OUI 0x001B21 58 #define ICE_CEE_DCBX_TYPE 2 59 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 64 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 70 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) 80 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 97 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 103 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) 111 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) 117 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 128 129 #define ICE_IEEE_ETS_TLV_LEN 25 130 #define ICE_IEEE_PFC_TLV_LEN 6 131 #define ICE_IEEE_APP_TLV_LEN 11 132 133 #pragma pack(1) 134 /* IEEE 802.1AB LLDP TLV structure */ 135 struct ice_lldp_generic_tlv { 136 __be16 typelen; 137 u8 tlvinfo[1]; 138 }; 139 140 /* IEEE 802.1AB LLDP Organization specific TLV */ 141 struct ice_lldp_org_tlv { 142 __be16 typelen; 143 __be32 ouisubtype; 144 u8 tlvinfo[1]; 145 }; 146 #pragma pack() 147 148 struct ice_cee_tlv_hdr { 149 __be16 typelen; 150 u8 operver; 151 u8 maxver; 152 }; 153 154 struct ice_cee_ctrl_tlv { 155 struct ice_cee_tlv_hdr hdr; 156 __be32 seqno; 157 __be32 ackno; 158 }; 159 160 struct ice_cee_feat_tlv { 161 struct ice_cee_tlv_hdr hdr; 162 u8 en_will_err; /* Bits: |En|Will|Err|Reserved(5)| */ 163 #define ICE_CEE_FEAT_TLV_ENA_M 0x80 164 #define ICE_CEE_FEAT_TLV_WILLING_M 0x40 165 #define ICE_CEE_FEAT_TLV_ERR_M 0x20 166 u8 subtype; 167 u8 tlvinfo[1]; 168 }; 169 170 #pragma pack(1) 171 struct ice_cee_app_prio { 172 __be16 protocol; 173 u8 upper_oui_sel; /* Bits: |Upper OUI(6)|Selector(2)| */ 174 #define ICE_CEE_APP_SELECTOR_M 0x03 175 __be16 lower_oui; 176 u8 prio_map; 177 }; 178 #pragma pack() 179 180 /* TODO: The below structures related LLDP/DCBX variables 181 * and statistics are defined but need to find how to get 182 * the required information from the Firmware to use them 183 */ 184 185 /* IEEE 802.1AB LLDP Agent Statistics */ 186 struct ice_lldp_stats { 187 u64 remtablelastchangetime; 188 u64 remtableinserts; 189 u64 remtabledeletes; 190 u64 remtabledrops; 191 u64 remtableageouts; 192 u64 txframestotal; 193 u64 rxframesdiscarded; 194 u64 rxportframeerrors; 195 u64 rxportframestotal; 196 u64 rxporttlvsdiscardedtotal; 197 u64 rxporttlvsunrecognizedtotal; 198 u64 remtoomanyneighbors; 199 }; 200 201 /* IEEE 802.1Qaz DCBX variables */ 202 struct ice_dcbx_variables { 203 u32 defmaxtrafficclasses; 204 u32 defprioritytcmapping; 205 u32 deftcbandwidth; 206 u32 deftsaassignment; 207 }; 208 209 enum ice_status 210 ice_aq_get_lldp_mib(struct ice_hw *hw, u8 bridge_type, u8 mib_type, void *buf, 211 u16 buf_size, u16 *local_len, u16 *remote_len, 212 struct ice_sq_cd *cd); 213 enum ice_status 214 ice_aq_add_delete_lldp_tlv(struct ice_hw *hw, u8 bridge_type, bool add_lldp_tlv, 215 void *buf, u16 buf_size, u16 tlv_len, u16 *mib_len, 216 struct ice_sq_cd *cd); 217 enum ice_status 218 ice_aq_update_lldp_tlv(struct ice_hw *hw, u8 bridge_type, void *buf, 219 u16 buf_size, u16 old_len, u16 new_len, u16 offset, 220 u16 *mib_len, struct ice_sq_cd *cd); 221 enum ice_status 222 ice_aq_set_lldp_mib(struct ice_hw *hw, u8 mib_type, void *buf, u16 buf_size, 223 struct ice_sq_cd *cd); 224 enum ice_status 225 ice_aq_dcb_ignore_pfc(struct ice_hw *hw, u8 tcmap, bool request, u8 *tcmap_ret, 226 struct ice_sq_cd *cd); 227 enum ice_status 228 ice_aq_get_cee_dcb_cfg(struct ice_hw *hw, 229 struct ice_aqc_get_cee_dcb_cfg_resp *buff, 230 struct ice_sq_cd *cd); 231 enum ice_status 232 ice_aq_query_pfc_mode(struct ice_hw *hw, u8 *pfcmode_ret, struct ice_sq_cd *cd); 233 enum ice_status 234 ice_aq_set_pfc_mode(struct ice_hw *hw, u8 pfcmode_set, u8 *pfcmode_ret, 235 struct ice_sq_cd *cd); 236 enum ice_status 237 ice_aq_set_dcb_parameters(struct ice_hw *hw, bool dcb_enable, 238 struct ice_sq_cd *cd); 239 enum ice_status ice_lldp_to_dcb_cfg(u8 *lldpmib, struct ice_dcbx_cfg *dcbcfg); 240 u8 ice_get_dcbx_status(struct ice_hw *hw); 241 enum ice_status 242 ice_aq_get_dcb_cfg(struct ice_hw *hw, u8 mib_type, u8 bridgetype, 243 struct ice_dcbx_cfg *dcbcfg); 244 enum ice_status ice_get_dcb_cfg(struct ice_port_info *pi); 245 enum ice_status ice_set_dcb_cfg(struct ice_port_info *pi); 246 enum ice_status ice_init_dcb(struct ice_hw *hw, bool enable_mib_change); 247 void ice_dcb_cfg_to_lldp(u8 *lldpmib, u16 *miblen, struct ice_dcbx_cfg *dcbcfg); 248 enum ice_status 249 ice_query_port_ets(struct ice_port_info *pi, 250 struct ice_aqc_port_ets_elem *buf, u16 buf_size, 251 struct ice_sq_cd *cmd_details); 252 enum ice_status 253 ice_aq_query_port_ets(struct ice_port_info *pi, 254 struct ice_aqc_port_ets_elem *buf, u16 buf_size, 255 struct ice_sq_cd *cd); 256 enum ice_status 257 ice_update_port_tc_tree_cfg(struct ice_port_info *pi, 258 struct ice_aqc_port_ets_elem *buf); 259 enum ice_status 260 ice_aq_stop_lldp(struct ice_hw *hw, bool shutdown_lldp_agent, bool persist, 261 struct ice_sq_cd *cd); 262 enum ice_status 263 ice_aq_start_lldp(struct ice_hw *hw, bool persist, struct ice_sq_cd *cd); 264 enum ice_status 265 ice_aq_start_stop_dcbx(struct ice_hw *hw, bool start_dcbx_agent, 266 bool *dcbx_agent_status, struct ice_sq_cd *cd); 267 enum ice_status ice_cfg_lldp_mib_change(struct ice_hw *hw, bool ena_mib); 268 enum ice_status 269 ice_aq_cfg_lldp_mib_change(struct ice_hw *hw, bool ena_update, 270 struct ice_sq_cd *cd); 271 #endif /* _ICE_DCB_H_ */ 272