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