1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020
8 #define TXGBE_LINK_UP_TIME 90 /* 9.0 Seconds */
10 #define TXGBE_ALIGN 128 /* as intel did */
12 #include "txgbe_status.h"
13 #include "txgbe_osdep.h"
14 #include "txgbe_devids.h"
17 txgbe_mac_unknown = 0,
24 txgbe_phy_unknown = 0,
34 txgbe_phy_sfp_tyco_passive,
35 txgbe_phy_sfp_unknown_passive,
36 txgbe_phy_sfp_unknown_active,
39 txgbe_phy_sfp_ftl_active,
40 txgbe_phy_sfp_unknown,
42 txgbe_phy_qsfp_unknown_passive,
43 txgbe_phy_qsfp_unknown_active,
45 txgbe_phy_qsfp_unknown,
46 txgbe_phy_sfp_unsupported, /* Enforce bit set with unsupported module */
53 * SFP+ module type IDs:
60 * 3 SFP_DA_CU_CORE0 - chip-specific
61 * 4 SFP_DA_CU_CORE1 - chip-specific
62 * 5 SFP_SR/LR_CORE0 - chip-specific
63 * 6 SFP_SR/LR_CORE1 - chip-specific
66 txgbe_sfp_type_unknown = 0,
70 txgbe_sfp_type_da_cu_core0,
71 txgbe_sfp_type_da_cu_core1,
72 txgbe_sfp_type_srlr_core0,
73 txgbe_sfp_type_srlr_core1,
74 txgbe_sfp_type_da_act_lmt_core0,
75 txgbe_sfp_type_da_act_lmt_core1,
76 txgbe_sfp_type_1g_cu_core0,
77 txgbe_sfp_type_1g_cu_core1,
78 txgbe_sfp_type_1g_sx_core0,
79 txgbe_sfp_type_1g_sx_core1,
80 txgbe_sfp_type_1g_lx_core0,
81 txgbe_sfp_type_1g_lx_core1,
82 txgbe_sfp_type_not_present = 0xFFFE,
83 txgbe_sfp_type_not_known = 0xFFFF
86 enum txgbe_media_type {
87 txgbe_media_type_unknown = 0,
88 txgbe_media_type_fiber,
89 txgbe_media_type_fiber_qsfp,
90 txgbe_media_type_copper,
91 txgbe_media_type_backplane,
93 txgbe_media_type_virtual
98 txgbe_bus_type_unknown = 0,
101 txgbe_bus_type_pci_express,
102 txgbe_bus_type_internal,
103 txgbe_bus_type_reserved
107 enum txgbe_bus_speed {
108 txgbe_bus_speed_unknown = 0,
109 txgbe_bus_speed_33 = 33,
110 txgbe_bus_speed_66 = 66,
111 txgbe_bus_speed_100 = 100,
112 txgbe_bus_speed_120 = 120,
113 txgbe_bus_speed_133 = 133,
114 txgbe_bus_speed_2500 = 2500,
115 txgbe_bus_speed_5000 = 5000,
116 txgbe_bus_speed_8000 = 8000,
117 txgbe_bus_speed_reserved
121 enum txgbe_bus_width {
122 txgbe_bus_width_unknown = 0,
123 txgbe_bus_width_pcie_x1 = 1,
124 txgbe_bus_width_pcie_x2 = 2,
125 txgbe_bus_width_pcie_x4 = 4,
126 txgbe_bus_width_pcie_x8 = 8,
127 txgbe_bus_width_32 = 32,
128 txgbe_bus_width_64 = 64,
129 txgbe_bus_width_reserved
135 struct txgbe_bus_info {
136 s32 (*get_bus_info)(struct txgbe_hw *hw);
137 void (*set_lan_id)(struct txgbe_hw *hw);
139 enum txgbe_bus_speed speed;
140 enum txgbe_bus_width width;
141 enum txgbe_bus_type type;
148 /* iterator type for walking multicast address lists */
149 typedef u8* (*txgbe_mc_addr_itr) (struct txgbe_hw *hw, u8 **mc_addr_ptr,
152 struct txgbe_link_info {
153 s32 (*read_link)(struct txgbe_hw *hw, u8 addr, u16 reg, u16 *val);
154 s32 (*read_link_unlocked)(struct txgbe_hw *hw, u8 addr, u16 reg,
156 s32 (*write_link)(struct txgbe_hw *hw, u8 addr, u16 reg, u16 val);
157 s32 (*write_link_unlocked)(struct txgbe_hw *hw, u8 addr, u16 reg,
163 struct txgbe_rom_info {
164 s32 (*init_params)(struct txgbe_hw *hw);
165 s32 (*read16)(struct txgbe_hw *hw, u32 offset, u16 *data);
166 s32 (*readw_sw)(struct txgbe_hw *hw, u32 offset, u16 *data);
167 s32 (*readw_buffer)(struct txgbe_hw *hw, u32 offset, u32 words,
169 s32 (*read32)(struct txgbe_hw *hw, u32 addr, u32 *data);
170 s32 (*read_buffer)(struct txgbe_hw *hw, u32 addr, u32 len, void *data);
171 s32 (*write16)(struct txgbe_hw *hw, u32 offset, u16 data);
172 s32 (*writew_sw)(struct txgbe_hw *hw, u32 offset, u16 data);
173 s32 (*writew_buffer)(struct txgbe_hw *hw, u32 offset, u32 words,
175 s32 (*write32)(struct txgbe_hw *hw, u32 addr, u32 data);
176 s32 (*write_buffer)(struct txgbe_hw *hw, u32 addr, u32 len, void *data);
177 s32 (*validate_checksum)(struct txgbe_hw *hw, u16 *checksum_val);
178 s32 (*update_checksum)(struct txgbe_hw *hw);
179 s32 (*calc_checksum)(struct txgbe_hw *hw);
182 struct txgbe_flash_info {
188 struct txgbe_mac_info {
189 s32 (*init_hw)(struct txgbe_hw *hw);
190 s32 (*reset_hw)(struct txgbe_hw *hw);
191 s32 (*start_hw)(struct txgbe_hw *hw);
192 s32 (*stop_hw)(struct txgbe_hw *hw);
193 s32 (*clear_hw_cntrs)(struct txgbe_hw *hw);
194 s32 (*get_mac_addr)(struct txgbe_hw *hw, u8 *mac_addr);
195 s32 (*get_san_mac_addr)(struct txgbe_hw *hw, u8 *san_mac_addr);
196 s32 (*set_san_mac_addr)(struct txgbe_hw *hw, u8 *san_mac_addr);
197 s32 (*get_device_caps)(struct txgbe_hw *hw, u16 *device_caps);
198 s32 (*get_wwn_prefix)(struct txgbe_hw *hw, u16 *wwnn_prefix,
200 s32 (*setup_sfp)(struct txgbe_hw *hw);
201 s32 (*enable_rx_dma)(struct txgbe_hw *hw, u32 regval);
202 s32 (*disable_sec_rx_path)(struct txgbe_hw *hw);
203 s32 (*enable_sec_rx_path)(struct txgbe_hw *hw);
204 s32 (*disable_sec_tx_path)(struct txgbe_hw *hw);
205 s32 (*enable_sec_tx_path)(struct txgbe_hw *hw);
206 s32 (*acquire_swfw_sync)(struct txgbe_hw *hw, u32 mask);
207 void (*release_swfw_sync)(struct txgbe_hw *hw, u32 mask);
208 u64 (*autoc_read)(struct txgbe_hw *hw);
209 void (*autoc_write)(struct txgbe_hw *hw, u64 value);
210 s32 (*prot_autoc_read)(struct txgbe_hw *hw, bool *locked, u64 *value);
211 s32 (*prot_autoc_write)(struct txgbe_hw *hw, bool locked, u64 value);
212 s32 (*negotiate_api_version)(struct txgbe_hw *hw, int api);
215 void (*disable_tx_laser)(struct txgbe_hw *hw);
216 void (*enable_tx_laser)(struct txgbe_hw *hw);
217 void (*flap_tx_laser)(struct txgbe_hw *hw);
218 s32 (*setup_link)(struct txgbe_hw *hw, u32 speed,
219 bool autoneg_wait_to_complete);
220 s32 (*setup_mac_link)(struct txgbe_hw *hw, u32 speed,
221 bool autoneg_wait_to_complete);
222 s32 (*check_link)(struct txgbe_hw *hw, u32 *speed,
223 bool *link_up, bool link_up_wait_to_complete);
224 s32 (*get_link_capabilities)(struct txgbe_hw *hw,
225 u32 *speed, bool *autoneg);
226 void (*set_rate_select_speed)(struct txgbe_hw *hw, u32 speed);
228 /* Packet Buffer manipulation */
229 void (*setup_pba)(struct txgbe_hw *hw, int num_pb, u32 headroom,
233 s32 (*led_on)(struct txgbe_hw *hw, u32 index);
234 s32 (*led_off)(struct txgbe_hw *hw, u32 index);
236 /* RAR, Multicast, VLAN */
237 s32 (*set_rar)(struct txgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
239 s32 (*set_uc_addr)(struct txgbe_hw *hw, u32 index, u8 *addr);
240 s32 (*clear_rar)(struct txgbe_hw *hw, u32 index);
241 s32 (*set_vmdq)(struct txgbe_hw *hw, u32 rar, u32 vmdq);
242 s32 (*clear_vmdq)(struct txgbe_hw *hw, u32 rar, u32 vmdq);
243 s32 (*init_rx_addrs)(struct txgbe_hw *hw);
244 s32 (*update_mc_addr_list)(struct txgbe_hw *hw, u8 *mc_addr_list,
246 txgbe_mc_addr_itr func, bool clear);
247 s32 (*clear_vfta)(struct txgbe_hw *hw);
248 s32 (*set_vfta)(struct txgbe_hw *hw, u32 vlan,
249 u32 vind, bool vlan_on, bool vlvf_bypass);
250 s32 (*set_vlvf)(struct txgbe_hw *hw, u32 vlan, u32 vind,
251 bool vlan_on, u32 *vfta_delta, u32 vfta,
253 s32 (*init_uta_tables)(struct txgbe_hw *hw);
254 void (*set_mac_anti_spoofing)(struct txgbe_hw *hw, bool enable, int vf);
255 void (*set_vlan_anti_spoofing)(struct txgbe_hw *hw,
256 bool enable, int vf);
257 s32 (*update_xcast_mode)(struct txgbe_hw *hw, int xcast_mode);
258 s32 (*set_rlpml)(struct txgbe_hw *hw, u16 max_size);
261 s32 (*fc_enable)(struct txgbe_hw *hw);
262 s32 (*setup_fc)(struct txgbe_hw *hw);
263 void (*fc_autoneg)(struct txgbe_hw *hw);
265 /* Manageability interface */
266 s32 (*set_fw_drv_ver)(struct txgbe_hw *hw, u8 maj, u8 min, u8 build,
267 u8 ver, u16 len, char *driver_ver);
268 s32 (*get_thermal_sensor_data)(struct txgbe_hw *hw);
269 s32 (*init_thermal_sensor_thresh)(struct txgbe_hw *hw);
270 void (*get_rtrup2tc)(struct txgbe_hw *hw, u8 *map);
271 void (*disable_rx)(struct txgbe_hw *hw);
272 void (*enable_rx)(struct txgbe_hw *hw);
273 void (*set_ethertype_anti_spoofing)(struct txgbe_hw *hw,
274 bool enable, int vf);
275 s32 (*dmac_update_tcs)(struct txgbe_hw *hw);
276 s32 (*dmac_config_tcs)(struct txgbe_hw *hw);
277 s32 (*dmac_config)(struct txgbe_hw *hw);
278 s32 (*setup_eee)(struct txgbe_hw *hw, bool enable_eee);
280 enum txgbe_mac_type type;
281 u8 perm_addr[ETH_ADDR_LEN];
283 u32 max_link_up_time;
286 struct txgbe_phy_info {
287 u32 (*get_media_type)(struct txgbe_hw *hw);
288 s32 (*identify)(struct txgbe_hw *hw);
289 s32 (*identify_sfp)(struct txgbe_hw *hw);
290 s32 (*init)(struct txgbe_hw *hw);
291 s32 (*reset)(struct txgbe_hw *hw);
292 s32 (*read_reg)(struct txgbe_hw *hw, u32 reg_addr,
293 u32 device_type, u16 *phy_data);
294 s32 (*write_reg)(struct txgbe_hw *hw, u32 reg_addr,
295 u32 device_type, u16 phy_data);
296 s32 (*read_reg_mdi)(struct txgbe_hw *hw, u32 reg_addr,
297 u32 device_type, u16 *phy_data);
298 s32 (*write_reg_mdi)(struct txgbe_hw *hw, u32 reg_addr,
299 u32 device_type, u16 phy_data);
300 s32 (*setup_link)(struct txgbe_hw *hw);
301 s32 (*setup_internal_link)(struct txgbe_hw *hw);
302 s32 (*setup_link_speed)(struct txgbe_hw *hw, u32 speed,
303 bool autoneg_wait_to_complete);
304 s32 (*check_link)(struct txgbe_hw *hw, u32 *speed, bool *link_up);
305 s32 (*read_i2c_byte)(struct txgbe_hw *hw, u8 byte_offset,
306 u8 dev_addr, u8 *data);
307 s32 (*write_i2c_byte)(struct txgbe_hw *hw, u8 byte_offset,
308 u8 dev_addr, u8 data);
309 s32 (*read_i2c_sff8472)(struct txgbe_hw *hw, u8 byte_offset,
311 s32 (*read_i2c_eeprom)(struct txgbe_hw *hw, u8 byte_offset,
313 s32 (*write_i2c_eeprom)(struct txgbe_hw *hw, u8 byte_offset,
315 s32 (*check_overtemp)(struct txgbe_hw *hw);
316 s32 (*set_phy_power)(struct txgbe_hw *hw, bool on);
317 s32 (*handle_lasi)(struct txgbe_hw *hw);
318 s32 (*read_i2c_byte_unlocked)(struct txgbe_hw *hw, u8 offset, u8 addr,
320 s32 (*write_i2c_byte_unlocked)(struct txgbe_hw *hw, u8 offset, u8 addr,
323 enum txgbe_phy_type type;
324 enum txgbe_sfp_type sfp_type;
328 struct txgbe_mbx_info {
329 void (*init_params)(struct txgbe_hw *hw);
330 s32 (*read)(struct txgbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
331 s32 (*write)(struct txgbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
332 s32 (*read_posted)(struct txgbe_hw *hw, u32 *msg, u16 size,
334 s32 (*write_posted)(struct txgbe_hw *hw, u32 *msg, u16 size,
336 s32 (*check_for_msg)(struct txgbe_hw *hw, u16 mbx_id);
337 s32 (*check_for_ack)(struct txgbe_hw *hw, u16 mbx_id);
338 s32 (*check_for_rst)(struct txgbe_hw *hw, u16 mbx_id);
344 struct txgbe_mac_info mac;
345 struct txgbe_phy_info phy;
346 struct txgbe_link_info link;
347 struct txgbe_rom_info rom;
348 struct txgbe_flash_info flash;
349 struct txgbe_bus_info bus;
350 struct txgbe_mbx_info mbx;
353 u16 subsystem_device_id;
354 u16 subsystem_vendor_id;
356 bool allow_unsupported_sfp;
362 #include "txgbe_regs.h"
363 #include "txgbe_dummy.h"
365 #endif /* _TXGBE_TYPE_H_ */