net/ice/base: add helper to check for 100M speed support
[dpdk.git] / drivers / net / ice / base / ice_dcb.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2001-2021 Intel Corporation
3  */
4
5 #ifndef _ICE_DCB_H_
6 #define _ICE_DCB_H_
7
8 #include "ice_type.h"
9 #include "ice_common.h"
10
11 #define ICE_DCBX_OFFLOAD_DIS            0
12 #define ICE_DCBX_OFFLOAD_ENABLED        1
13
14 #define ICE_DCBX_STATUS_NOT_STARTED     0
15 #define ICE_DCBX_STATUS_IN_PROGRESS     1
16 #define ICE_DCBX_STATUS_DONE            2
17 #define ICE_DCBX_STATUS_MULTIPLE_PEERS  3
18 #define ICE_DCBX_STATUS_DIS             7
19
20 #define ICE_TLV_TYPE_END                0
21 #define ICE_TLV_TYPE_ORG                127
22
23 #define ICE_IEEE_8021QAZ_OUI            0x0080C2
24 #define ICE_IEEE_SUBTYPE_ETS_CFG        9
25 #define ICE_IEEE_SUBTYPE_ETS_REC        10
26 #define ICE_IEEE_SUBTYPE_PFC_CFG        11
27 #define ICE_IEEE_SUBTYPE_APP_PRI        12
28
29 #define ICE_CEE_DCBX_OUI                0x001B21
30 #define ICE_CEE_DCBX_TYPE               2
31
32 #define ICE_DSCP_OUI                    0xFFFFFF
33 #define ICE_DSCP_SUBTYPE_DSCP2UP        0x41
34 #define ICE_DSCP_SUBTYPE_ENFORCE        0x42
35 #define ICE_DSCP_SUBTYPE_TCBW           0x43
36 #define ICE_DSCP_SUBTYPE_PFC            0x44
37 #define ICE_DSCP_IPV6_OFFSET            80
38
39 #define ICE_CEE_SUBTYPE_CTRL            1
40 #define ICE_CEE_SUBTYPE_PG_CFG          2
41 #define ICE_CEE_SUBTYPE_PFC_CFG         3
42 #define ICE_CEE_SUBTYPE_APP_PRI         4
43
44 #define ICE_CEE_MAX_FEAT_TYPE           3
45 #define ICE_LLDP_ADMINSTATUS_DIS        0
46 #define ICE_LLDP_ADMINSTATUS_ENA_RX     1
47 #define ICE_LLDP_ADMINSTATUS_ENA_TX     2
48 #define ICE_LLDP_ADMINSTATUS_ENA_RXTX   3
49
50 /* Defines for LLDP TLV header */
51 #define ICE_LLDP_TLV_LEN_S              0
52 #define ICE_LLDP_TLV_LEN_M              (0x01FF << ICE_LLDP_TLV_LEN_S)
53 #define ICE_LLDP_TLV_TYPE_S             9
54 #define ICE_LLDP_TLV_TYPE_M             (0x7F << ICE_LLDP_TLV_TYPE_S)
55 #define ICE_LLDP_TLV_SUBTYPE_S          0
56 #define ICE_LLDP_TLV_SUBTYPE_M          (0xFF << ICE_LLDP_TLV_SUBTYPE_S)
57 #define ICE_LLDP_TLV_OUI_S              8
58 #define ICE_LLDP_TLV_OUI_M              (0xFFFFFFUL << ICE_LLDP_TLV_OUI_S)
59
60 /* Defines for IEEE ETS TLV */
61 #define ICE_IEEE_ETS_MAXTC_S    0
62 #define ICE_IEEE_ETS_MAXTC_M            (0x7 << ICE_IEEE_ETS_MAXTC_S)
63 #define ICE_IEEE_ETS_CBS_S              6
64 #define ICE_IEEE_ETS_CBS_M              BIT(ICE_IEEE_ETS_CBS_S)
65 #define ICE_IEEE_ETS_WILLING_S          7
66 #define ICE_IEEE_ETS_WILLING_M          BIT(ICE_IEEE_ETS_WILLING_S)
67 #define ICE_IEEE_ETS_PRIO_0_S           0
68 #define ICE_IEEE_ETS_PRIO_0_M           (0x7 << ICE_IEEE_ETS_PRIO_0_S)
69 #define ICE_IEEE_ETS_PRIO_1_S           4
70 #define ICE_IEEE_ETS_PRIO_1_M           (0x7 << ICE_IEEE_ETS_PRIO_1_S)
71 #define ICE_CEE_PGID_PRIO_0_S           0
72 #define ICE_CEE_PGID_PRIO_0_M           (0xF << ICE_CEE_PGID_PRIO_0_S)
73 #define ICE_CEE_PGID_PRIO_1_S           4
74 #define ICE_CEE_PGID_PRIO_1_M           (0xF << ICE_CEE_PGID_PRIO_1_S)
75 #define ICE_CEE_PGID_STRICT             15
76
77 /* Defines for IEEE TSA types */
78 #define ICE_IEEE_TSA_STRICT             0
79 #define ICE_IEEE_TSA_CBS                1
80 #define ICE_IEEE_TSA_ETS                2
81 #define ICE_IEEE_TSA_VENDOR             255
82
83 /* Defines for IEEE PFC TLV */
84 #define ICE_IEEE_PFC_CAP_S              0
85 #define ICE_IEEE_PFC_CAP_M              (0xF << ICE_IEEE_PFC_CAP_S)
86 #define ICE_IEEE_PFC_MBC_S              6
87 #define ICE_IEEE_PFC_MBC_M              BIT(ICE_IEEE_PFC_MBC_S)
88 #define ICE_IEEE_PFC_WILLING_S          7
89 #define ICE_IEEE_PFC_WILLING_M          BIT(ICE_IEEE_PFC_WILLING_S)
90
91 /* Defines for IEEE APP TLV */
92 #define ICE_IEEE_APP_SEL_S              0
93 #define ICE_IEEE_APP_SEL_M              (0x7 << ICE_IEEE_APP_SEL_S)
94 #define ICE_IEEE_APP_PRIO_S             5
95 #define ICE_IEEE_APP_PRIO_M             (0x7 << ICE_IEEE_APP_PRIO_S)
96
97 /* TLV definitions for preparing MIB */
98 #define ICE_TLV_ID_CHASSIS_ID           0
99 #define ICE_TLV_ID_PORT_ID              1
100 #define ICE_TLV_ID_TIME_TO_LIVE         2
101 #define ICE_IEEE_TLV_ID_ETS_CFG         3
102 #define ICE_IEEE_TLV_ID_ETS_REC         4
103 #define ICE_IEEE_TLV_ID_PFC_CFG         5
104 #define ICE_IEEE_TLV_ID_APP_PRI         6
105 #define ICE_TLV_ID_END_OF_LLDPPDU       7
106 #define ICE_TLV_ID_START                ICE_IEEE_TLV_ID_ETS_CFG
107 #define ICE_TLV_ID_DSCP_UP              3
108 #define ICE_TLV_ID_DSCP_ENF             4
109 #define ICE_TLV_ID_DSCP_TC_BW           5
110 #define ICE_TLV_ID_DSCP_TO_PFC          6
111
112 #define ICE_IEEE_ETS_TLV_LEN            25
113 #define ICE_IEEE_PFC_TLV_LEN            6
114 #define ICE_IEEE_APP_TLV_LEN            11
115
116 #define ICE_DSCP_UP_TLV_LEN             148
117 #define ICE_DSCP_ENF_TLV_LEN            132
118 #define ICE_DSCP_TC_BW_TLV_LEN          25
119 #define ICE_DSCP_PFC_TLV_LEN            6
120
121 #pragma pack(1)
122 /* IEEE 802.1AB LLDP Organization specific TLV */
123 struct ice_lldp_org_tlv {
124         __be16 typelen;
125         __be32 ouisubtype;
126         u8 tlvinfo[STRUCT_HACK_VAR_LEN];
127 };
128 #pragma pack()
129
130 struct ice_cee_tlv_hdr {
131         __be16 typelen;
132         u8 operver;
133         u8 maxver;
134 };
135
136 struct ice_cee_ctrl_tlv {
137         struct ice_cee_tlv_hdr hdr;
138         __be32 seqno;
139         __be32 ackno;
140 };
141
142 struct ice_cee_feat_tlv {
143         struct ice_cee_tlv_hdr hdr;
144         u8 en_will_err; /* Bits: |En|Will|Err|Reserved(5)| */
145 #define ICE_CEE_FEAT_TLV_ENA_M          0x80
146 #define ICE_CEE_FEAT_TLV_WILLING_M      0x40
147 #define ICE_CEE_FEAT_TLV_ERR_M          0x20
148         u8 subtype;
149         u8 tlvinfo[STRUCT_HACK_VAR_LEN];
150 };
151
152 #pragma pack(1)
153 struct ice_cee_app_prio {
154         __be16 protocol;
155         u8 upper_oui_sel; /* Bits: |Upper OUI(6)|Selector(2)| */
156 #define ICE_CEE_APP_SELECTOR_M  0x03
157         __be16 lower_oui;
158         u8 prio_map;
159 };
160 #pragma pack()
161
162 /* TODO: The below structures related LLDP/DCBX variables
163  * and statistics are defined but need to find how to get
164  * the required information from the Firmware to use them
165  */
166
167 /* IEEE 802.1AB LLDP Agent Statistics */
168 struct ice_lldp_stats {
169         u64 remtablelastchangetime;
170         u64 remtableinserts;
171         u64 remtabledeletes;
172         u64 remtabledrops;
173         u64 remtableageouts;
174         u64 txframestotal;
175         u64 rxframesdiscarded;
176         u64 rxportframeerrors;
177         u64 rxportframestotal;
178         u64 rxporttlvsdiscardedtotal;
179         u64 rxporttlvsunrecognizedtotal;
180         u64 remtoomanyneighbors;
181 };
182
183 /* IEEE 802.1Qaz DCBX variables */
184 struct ice_dcbx_variables {
185         u32 defmaxtrafficclasses;
186         u32 defprioritytcmapping;
187         u32 deftcbandwidth;
188         u32 deftsaassignment;
189 };
190
191 enum ice_status
192 ice_aq_get_lldp_mib(struct ice_hw *hw, u8 bridge_type, u8 mib_type, void *buf,
193                     u16 buf_size, u16 *local_len, u16 *remote_len,
194                     struct ice_sq_cd *cd);
195 enum ice_status
196 ice_aq_get_cee_dcb_cfg(struct ice_hw *hw,
197                        struct ice_aqc_get_cee_dcb_cfg_resp *buff,
198                        struct ice_sq_cd *cd);
199 enum ice_status
200 ice_aq_set_pfc_mode(struct ice_hw *hw, u8 pfc_mode, struct ice_sq_cd *cd);
201 enum ice_status ice_lldp_to_dcb_cfg(u8 *lldpmib, struct ice_dcbx_cfg *dcbcfg);
202 u8 ice_get_dcbx_status(struct ice_hw *hw);
203 enum ice_status
204 ice_aq_get_dcb_cfg(struct ice_hw *hw, u8 mib_type, u8 bridgetype,
205                    struct ice_dcbx_cfg *dcbcfg);
206 enum ice_status ice_get_dcb_cfg(struct ice_port_info *pi);
207 enum ice_status ice_set_dcb_cfg(struct ice_port_info *pi);
208 enum ice_status ice_init_dcb(struct ice_hw *hw, bool enable_mib_change);
209 void ice_dcb_cfg_to_lldp(u8 *lldpmib, u16 *miblen, struct ice_dcbx_cfg *dcbcfg);
210 enum ice_status
211 ice_query_port_ets(struct ice_port_info *pi,
212                    struct ice_aqc_port_ets_elem *buf, u16 buf_size,
213                    struct ice_sq_cd *cmd_details);
214 enum ice_status
215 ice_aq_query_port_ets(struct ice_port_info *pi,
216                       struct ice_aqc_port_ets_elem *buf, u16 buf_size,
217                       struct ice_sq_cd *cd);
218 enum ice_status
219 ice_update_port_tc_tree_cfg(struct ice_port_info *pi,
220                             struct ice_aqc_port_ets_elem *buf);
221 enum ice_status
222 ice_aq_stop_lldp(struct ice_hw *hw, bool shutdown_lldp_agent, bool persist,
223                  struct ice_sq_cd *cd);
224 enum ice_status
225 ice_aq_start_lldp(struct ice_hw *hw, bool persist, struct ice_sq_cd *cd);
226 enum ice_status
227 ice_aq_start_stop_dcbx(struct ice_hw *hw, bool start_dcbx_agent,
228                        bool *dcbx_agent_status, struct ice_sq_cd *cd);
229 enum ice_status ice_cfg_lldp_mib_change(struct ice_hw *hw, bool ena_mib);
230 enum ice_status
231 ice_aq_cfg_lldp_mib_change(struct ice_hw *hw, bool ena_update,
232                            struct ice_sq_cd *cd);
233 #endif /* _ICE_DCB_H_ */