1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020
8 #define TXGBE_LINK_UP_TIME 90 /* 9.0 Seconds */
9 #define TXGBE_AUTO_NEG_TIME 45 /* 4.5 Seconds */
11 #define TXGBE_FRAME_SIZE_MAX (9728) /* Maximum frame size, +FCS */
12 #define TXGBE_FRAME_SIZE_DFT (1518) /* Default frame size, +FCS */
13 #define TXGBE_MAX_UP 8
14 #define TXGBE_MAX_QP (128)
15 #define TXGBE_MAX_UTA 128
17 #define TXGBE_ALIGN 128 /* as intel did */
19 #include "txgbe_status.h"
20 #include "txgbe_osdep.h"
21 #include "txgbe_devids.h"
23 struct txgbe_thermal_diode_data {
29 struct txgbe_thermal_sensor_data {
30 struct txgbe_thermal_diode_data sensor[1];
33 /* Physical layer type */
34 #define TXGBE_PHYSICAL_LAYER_UNKNOWN 0
35 #define TXGBE_PHYSICAL_LAYER_10GBASE_T 0x00001
36 #define TXGBE_PHYSICAL_LAYER_1000BASE_T 0x00002
37 #define TXGBE_PHYSICAL_LAYER_100BASE_TX 0x00004
38 #define TXGBE_PHYSICAL_LAYER_SFP_PLUS_CU 0x00008
39 #define TXGBE_PHYSICAL_LAYER_10GBASE_LR 0x00010
40 #define TXGBE_PHYSICAL_LAYER_10GBASE_LRM 0x00020
41 #define TXGBE_PHYSICAL_LAYER_10GBASE_SR 0x00040
42 #define TXGBE_PHYSICAL_LAYER_10GBASE_KX4 0x00080
43 #define TXGBE_PHYSICAL_LAYER_10GBASE_CX4 0x00100
44 #define TXGBE_PHYSICAL_LAYER_1000BASE_KX 0x00200
45 #define TXGBE_PHYSICAL_LAYER_1000BASE_BX 0x00400
46 #define TXGBE_PHYSICAL_LAYER_10GBASE_KR 0x00800
47 #define TXGBE_PHYSICAL_LAYER_10GBASE_XAUI 0x01000
48 #define TXGBE_PHYSICAL_LAYER_SFP_ACTIVE_DA 0x02000
49 #define TXGBE_PHYSICAL_LAYER_1000BASE_SX 0x04000
50 #define TXGBE_PHYSICAL_LAYER_10BASE_T 0x08000
51 #define TXGBE_PHYSICAL_LAYER_2500BASE_KX 0x10000
53 #define TXGBE_ATR_HASH_MASK 0x7fff
55 enum txgbe_eeprom_type {
56 txgbe_eeprom_unknown = 0,
59 txgbe_eeprom_none /* No NVM support */
63 txgbe_mac_unknown = 0,
70 txgbe_phy_unknown = 0,
80 txgbe_phy_sfp_tyco_passive,
81 txgbe_phy_sfp_unknown_passive,
82 txgbe_phy_sfp_unknown_active,
85 txgbe_phy_sfp_ftl_active,
86 txgbe_phy_sfp_unknown,
88 txgbe_phy_qsfp_unknown_passive,
89 txgbe_phy_qsfp_unknown_active,
91 txgbe_phy_qsfp_unknown,
92 txgbe_phy_sfp_unsupported, /* Enforce bit set with unsupported module */
99 * SFP+ module type IDs:
106 * 3 SFP_DA_CU_CORE0 - chip-specific
107 * 4 SFP_DA_CU_CORE1 - chip-specific
108 * 5 SFP_SR/LR_CORE0 - chip-specific
109 * 6 SFP_SR/LR_CORE1 - chip-specific
111 enum txgbe_sfp_type {
112 txgbe_sfp_type_unknown = 0,
113 txgbe_sfp_type_da_cu,
116 txgbe_sfp_type_da_cu_core0,
117 txgbe_sfp_type_da_cu_core1,
118 txgbe_sfp_type_srlr_core0,
119 txgbe_sfp_type_srlr_core1,
120 txgbe_sfp_type_da_act_lmt_core0,
121 txgbe_sfp_type_da_act_lmt_core1,
122 txgbe_sfp_type_1g_cu_core0,
123 txgbe_sfp_type_1g_cu_core1,
124 txgbe_sfp_type_1g_sx_core0,
125 txgbe_sfp_type_1g_sx_core1,
126 txgbe_sfp_type_1g_lx_core0,
127 txgbe_sfp_type_1g_lx_core1,
128 txgbe_sfp_type_not_present = 0xFFFE,
129 txgbe_sfp_type_not_known = 0xFFFF
132 enum txgbe_media_type {
133 txgbe_media_type_unknown = 0,
134 txgbe_media_type_fiber,
135 txgbe_media_type_fiber_qsfp,
136 txgbe_media_type_copper,
137 txgbe_media_type_backplane,
138 txgbe_media_type_cx4,
139 txgbe_media_type_virtual
143 /* Smart Speed Settings */
144 #define TXGBE_SMARTSPEED_MAX_RETRIES 3
145 enum txgbe_smart_speed {
146 txgbe_smart_speed_auto = 0,
147 txgbe_smart_speed_on,
148 txgbe_smart_speed_off
152 enum txgbe_bus_type {
153 txgbe_bus_type_unknown = 0,
156 txgbe_bus_type_pci_express,
157 txgbe_bus_type_internal,
158 txgbe_bus_type_reserved
162 enum txgbe_bus_speed {
163 txgbe_bus_speed_unknown = 0,
164 txgbe_bus_speed_33 = 33,
165 txgbe_bus_speed_66 = 66,
166 txgbe_bus_speed_100 = 100,
167 txgbe_bus_speed_120 = 120,
168 txgbe_bus_speed_133 = 133,
169 txgbe_bus_speed_2500 = 2500,
170 txgbe_bus_speed_5000 = 5000,
171 txgbe_bus_speed_8000 = 8000,
172 txgbe_bus_speed_reserved
176 enum txgbe_bus_width {
177 txgbe_bus_width_unknown = 0,
178 txgbe_bus_width_pcie_x1 = 1,
179 txgbe_bus_width_pcie_x2 = 2,
180 txgbe_bus_width_pcie_x4 = 4,
181 txgbe_bus_width_pcie_x8 = 8,
182 txgbe_bus_width_32 = 32,
183 txgbe_bus_width_64 = 64,
184 txgbe_bus_width_reserved
189 struct txgbe_addr_filter_info {
193 u32 overflow_promisc;
194 bool user_set_promisc;
198 struct txgbe_bus_info {
199 s32 (*get_bus_info)(struct txgbe_hw *hw);
200 void (*set_lan_id)(struct txgbe_hw *hw);
202 enum txgbe_bus_speed speed;
203 enum txgbe_bus_width width;
204 enum txgbe_bus_type type;
211 /* Statistics counters collected by the MAC */
213 struct txgbe_pb_stats {
214 u64 tx_pb_xon_packets;
215 u64 rx_pb_xon_packets;
216 u64 tx_pb_xoff_packets;
217 u64 rx_pb_xoff_packets;
219 u64 rx_pb_mbuf_alloc_errors;
220 u64 tx_pb_xon2off_packets;
224 struct txgbe_qp_stats {
229 u64 rx_qp_mc_packets;
232 struct txgbe_hw_stats {
234 u64 mng_bmc2host_packets;
235 u64 mng_host2bmc_packets;
242 u64 rx_total_packets;
243 u64 tx_total_packets;
244 u64 rx_total_missed_packets;
245 u64 rx_broadcast_packets;
246 u64 tx_broadcast_packets;
247 u64 rx_multicast_packets;
248 u64 tx_multicast_packets;
249 u64 rx_management_packets;
250 u64 tx_management_packets;
251 u64 rx_management_dropped;
256 u64 rx_illegal_byte_errors;
258 u64 rx_mac_short_packet_dropped;
259 u64 rx_length_errors;
260 u64 rx_undersize_errors;
261 u64 rx_fragment_errors;
262 u64 rx_oversize_errors;
263 u64 rx_jabber_errors;
264 u64 rx_l3_l4_xsum_error;
265 u64 mac_local_errors;
266 u64 mac_remote_errors;
269 u64 flow_director_added_filters;
270 u64 flow_director_removed_filters;
271 u64 flow_director_filter_add_errors;
272 u64 flow_director_filter_remove_errors;
273 u64 flow_director_matched_filters;
274 u64 flow_director_missed_filters;
277 u64 rx_fcoe_crc_errors;
278 u64 rx_fcoe_mbuf_allocation_errors;
285 u64 rx_fcoe_no_ddp_ext_buff;
288 u64 tx_macsec_pkts_untagged;
289 u64 tx_macsec_pkts_encrypted;
290 u64 tx_macsec_pkts_protected;
291 u64 tx_macsec_octets_encrypted;
292 u64 tx_macsec_octets_protected;
293 u64 rx_macsec_pkts_untagged;
294 u64 rx_macsec_pkts_badtag;
295 u64 rx_macsec_pkts_nosci;
296 u64 rx_macsec_pkts_unknownsci;
297 u64 rx_macsec_octets_decrypted;
298 u64 rx_macsec_octets_validated;
299 u64 rx_macsec_sc_pkts_unchecked;
300 u64 rx_macsec_sc_pkts_delayed;
301 u64 rx_macsec_sc_pkts_late;
302 u64 rx_macsec_sa_pkts_ok;
303 u64 rx_macsec_sa_pkts_invalid;
304 u64 rx_macsec_sa_pkts_notvalid;
305 u64 rx_macsec_sa_pkts_unusedsa;
306 u64 rx_macsec_sa_pkts_notusingsa;
309 u64 rx_size_64_packets;
310 u64 rx_size_65_to_127_packets;
311 u64 rx_size_128_to_255_packets;
312 u64 rx_size_256_to_511_packets;
313 u64 rx_size_512_to_1023_packets;
314 u64 rx_size_1024_to_max_packets;
315 u64 tx_size_64_packets;
316 u64 tx_size_65_to_127_packets;
317 u64 tx_size_128_to_255_packets;
318 u64 tx_size_256_to_511_packets;
319 u64 tx_size_512_to_1023_packets;
320 u64 tx_size_1024_to_max_packets;
334 u64 rx_up_drop_packets;
336 u64 tx_up_xon_packets;
337 u64 rx_up_xon_packets;
338 u64 tx_up_xoff_packets;
339 u64 rx_up_xoff_packets;
341 u64 rx_up_mbuf_alloc_errors;
342 u64 tx_up_xon2off_packets;
351 u64 rx_qp_mc_packets;
356 /* iterator type for walking multicast address lists */
357 typedef u8* (*txgbe_mc_addr_itr) (struct txgbe_hw *hw, u8 **mc_addr_ptr,
360 struct txgbe_link_info {
361 s32 (*read_link)(struct txgbe_hw *hw, u8 addr, u16 reg, u16 *val);
362 s32 (*read_link_unlocked)(struct txgbe_hw *hw, u8 addr, u16 reg,
364 s32 (*write_link)(struct txgbe_hw *hw, u8 addr, u16 reg, u16 val);
365 s32 (*write_link_unlocked)(struct txgbe_hw *hw, u8 addr, u16 reg,
371 struct txgbe_rom_info {
372 s32 (*init_params)(struct txgbe_hw *hw);
373 s32 (*read16)(struct txgbe_hw *hw, u32 offset, u16 *data);
374 s32 (*readw_sw)(struct txgbe_hw *hw, u32 offset, u16 *data);
375 s32 (*readw_buffer)(struct txgbe_hw *hw, u32 offset, u32 words,
377 s32 (*read32)(struct txgbe_hw *hw, u32 addr, u32 *data);
378 s32 (*read_buffer)(struct txgbe_hw *hw, u32 addr, u32 len, void *data);
379 s32 (*write16)(struct txgbe_hw *hw, u32 offset, u16 data);
380 s32 (*writew_sw)(struct txgbe_hw *hw, u32 offset, u16 data);
381 s32 (*writew_buffer)(struct txgbe_hw *hw, u32 offset, u32 words,
383 s32 (*write32)(struct txgbe_hw *hw, u32 addr, u32 data);
384 s32 (*write_buffer)(struct txgbe_hw *hw, u32 addr, u32 len, void *data);
385 s32 (*validate_checksum)(struct txgbe_hw *hw, u16 *checksum_val);
386 s32 (*update_checksum)(struct txgbe_hw *hw);
387 s32 (*calc_checksum)(struct txgbe_hw *hw);
389 enum txgbe_eeprom_type type;
399 struct txgbe_flash_info {
405 #define TXGBE_FLAGS_DOUBLE_RESET_REQUIRED 0x01
406 struct txgbe_mac_info {
407 s32 (*init_hw)(struct txgbe_hw *hw);
408 s32 (*reset_hw)(struct txgbe_hw *hw);
409 s32 (*start_hw)(struct txgbe_hw *hw);
410 s32 (*stop_hw)(struct txgbe_hw *hw);
411 s32 (*clear_hw_cntrs)(struct txgbe_hw *hw);
412 s32 (*get_mac_addr)(struct txgbe_hw *hw, u8 *mac_addr);
413 s32 (*get_san_mac_addr)(struct txgbe_hw *hw, u8 *san_mac_addr);
414 s32 (*set_san_mac_addr)(struct txgbe_hw *hw, u8 *san_mac_addr);
415 s32 (*get_device_caps)(struct txgbe_hw *hw, u16 *device_caps);
416 s32 (*get_wwn_prefix)(struct txgbe_hw *hw, u16 *wwnn_prefix,
418 s32 (*setup_sfp)(struct txgbe_hw *hw);
419 s32 (*enable_rx_dma)(struct txgbe_hw *hw, u32 regval);
420 s32 (*disable_sec_rx_path)(struct txgbe_hw *hw);
421 s32 (*enable_sec_rx_path)(struct txgbe_hw *hw);
422 s32 (*disable_sec_tx_path)(struct txgbe_hw *hw);
423 s32 (*enable_sec_tx_path)(struct txgbe_hw *hw);
424 s32 (*acquire_swfw_sync)(struct txgbe_hw *hw, u32 mask);
425 void (*release_swfw_sync)(struct txgbe_hw *hw, u32 mask);
426 u64 (*autoc_read)(struct txgbe_hw *hw);
427 void (*autoc_write)(struct txgbe_hw *hw, u64 value);
428 s32 (*prot_autoc_read)(struct txgbe_hw *hw, bool *locked, u64 *value);
429 s32 (*prot_autoc_write)(struct txgbe_hw *hw, bool locked, u64 value);
430 s32 (*negotiate_api_version)(struct txgbe_hw *hw, int api);
433 void (*disable_tx_laser)(struct txgbe_hw *hw);
434 void (*enable_tx_laser)(struct txgbe_hw *hw);
435 void (*flap_tx_laser)(struct txgbe_hw *hw);
436 s32 (*setup_link)(struct txgbe_hw *hw, u32 speed,
437 bool autoneg_wait_to_complete);
438 s32 (*setup_mac_link)(struct txgbe_hw *hw, u32 speed,
439 bool autoneg_wait_to_complete);
440 s32 (*check_link)(struct txgbe_hw *hw, u32 *speed,
441 bool *link_up, bool link_up_wait_to_complete);
442 s32 (*get_link_capabilities)(struct txgbe_hw *hw,
443 u32 *speed, bool *autoneg);
444 void (*set_rate_select_speed)(struct txgbe_hw *hw, u32 speed);
446 /* Packet Buffer manipulation */
447 void (*setup_pba)(struct txgbe_hw *hw, int num_pb, u32 headroom,
451 s32 (*led_on)(struct txgbe_hw *hw, u32 index);
452 s32 (*led_off)(struct txgbe_hw *hw, u32 index);
454 /* RAR, Multicast, VLAN */
455 s32 (*set_rar)(struct txgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
457 s32 (*set_uc_addr)(struct txgbe_hw *hw, u32 index, u8 *addr);
458 s32 (*clear_rar)(struct txgbe_hw *hw, u32 index);
459 s32 (*set_vmdq)(struct txgbe_hw *hw, u32 rar, u32 vmdq);
460 s32 (*clear_vmdq)(struct txgbe_hw *hw, u32 rar, u32 vmdq);
461 s32 (*init_rx_addrs)(struct txgbe_hw *hw);
462 s32 (*update_mc_addr_list)(struct txgbe_hw *hw, u8 *mc_addr_list,
464 txgbe_mc_addr_itr func, bool clear);
465 s32 (*clear_vfta)(struct txgbe_hw *hw);
466 s32 (*set_vfta)(struct txgbe_hw *hw, u32 vlan,
467 u32 vind, bool vlan_on, bool vlvf_bypass);
468 s32 (*set_vlvf)(struct txgbe_hw *hw, u32 vlan, u32 vind,
469 bool vlan_on, u32 *vfta_delta, u32 vfta,
471 s32 (*init_uta_tables)(struct txgbe_hw *hw);
472 void (*set_mac_anti_spoofing)(struct txgbe_hw *hw, bool enable, int vf);
473 void (*set_vlan_anti_spoofing)(struct txgbe_hw *hw,
474 bool enable, int vf);
475 s32 (*update_xcast_mode)(struct txgbe_hw *hw, int xcast_mode);
476 s32 (*set_rlpml)(struct txgbe_hw *hw, u16 max_size);
479 s32 (*fc_enable)(struct txgbe_hw *hw);
480 s32 (*setup_fc)(struct txgbe_hw *hw);
481 void (*fc_autoneg)(struct txgbe_hw *hw);
483 /* Manageability interface */
484 s32 (*set_fw_drv_ver)(struct txgbe_hw *hw, u8 maj, u8 min, u8 build,
485 u8 ver, u16 len, char *driver_ver);
486 s32 (*get_thermal_sensor_data)(struct txgbe_hw *hw);
487 s32 (*init_thermal_sensor_thresh)(struct txgbe_hw *hw);
488 void (*get_rtrup2tc)(struct txgbe_hw *hw, u8 *map);
489 void (*disable_rx)(struct txgbe_hw *hw);
490 void (*enable_rx)(struct txgbe_hw *hw);
491 void (*set_ethertype_anti_spoofing)(struct txgbe_hw *hw,
492 bool enable, int vf);
493 s32 (*dmac_update_tcs)(struct txgbe_hw *hw);
494 s32 (*dmac_config_tcs)(struct txgbe_hw *hw);
495 s32 (*dmac_config)(struct txgbe_hw *hw);
496 s32 (*setup_eee)(struct txgbe_hw *hw, bool enable_eee);
498 enum txgbe_mac_type type;
499 u8 addr[ETH_ADDR_LEN];
500 u8 perm_addr[ETH_ADDR_LEN];
501 u8 san_addr[ETH_ADDR_LEN];
502 /* prefix for World Wide Node Name (WWNN) */
504 /* prefix for World Wide Port Name (WWPN) */
506 #define TXGBE_MAX_MTA 128
507 u32 mta_shadow[TXGBE_MAX_MTA];
514 u8 san_mac_rar_index;
515 bool get_link_status;
516 u64 orig_autoc; /* cached value of AUTOC */
517 bool orig_link_settings_stored;
518 bool autotry_restart;
520 struct txgbe_thermal_sensor_data thermal_sensor_data;
522 u32 max_link_up_time;
525 struct txgbe_phy_info {
526 u32 (*get_media_type)(struct txgbe_hw *hw);
527 s32 (*identify)(struct txgbe_hw *hw);
528 s32 (*identify_sfp)(struct txgbe_hw *hw);
529 s32 (*init)(struct txgbe_hw *hw);
530 s32 (*reset)(struct txgbe_hw *hw);
531 s32 (*read_reg)(struct txgbe_hw *hw, u32 reg_addr,
532 u32 device_type, u16 *phy_data);
533 s32 (*write_reg)(struct txgbe_hw *hw, u32 reg_addr,
534 u32 device_type, u16 phy_data);
535 s32 (*read_reg_mdi)(struct txgbe_hw *hw, u32 reg_addr,
536 u32 device_type, u16 *phy_data);
537 s32 (*write_reg_mdi)(struct txgbe_hw *hw, u32 reg_addr,
538 u32 device_type, u16 phy_data);
539 s32 (*setup_link)(struct txgbe_hw *hw);
540 s32 (*setup_internal_link)(struct txgbe_hw *hw);
541 s32 (*setup_link_speed)(struct txgbe_hw *hw, u32 speed,
542 bool autoneg_wait_to_complete);
543 s32 (*check_link)(struct txgbe_hw *hw, u32 *speed, bool *link_up);
544 s32 (*read_i2c_byte)(struct txgbe_hw *hw, u8 byte_offset,
545 u8 dev_addr, u8 *data);
546 s32 (*write_i2c_byte)(struct txgbe_hw *hw, u8 byte_offset,
547 u8 dev_addr, u8 data);
548 s32 (*read_i2c_sff8472)(struct txgbe_hw *hw, u8 byte_offset,
550 s32 (*read_i2c_eeprom)(struct txgbe_hw *hw, u8 byte_offset,
552 s32 (*write_i2c_eeprom)(struct txgbe_hw *hw, u8 byte_offset,
554 s32 (*check_overtemp)(struct txgbe_hw *hw);
555 s32 (*set_phy_power)(struct txgbe_hw *hw, bool on);
556 s32 (*handle_lasi)(struct txgbe_hw *hw);
557 s32 (*read_i2c_byte_unlocked)(struct txgbe_hw *hw, u8 offset, u8 addr,
559 s32 (*write_i2c_byte_unlocked)(struct txgbe_hw *hw, u8 offset, u8 addr,
562 enum txgbe_phy_type type;
565 enum txgbe_sfp_type sfp_type;
566 bool sfp_setup_needed;
569 u32 phy_semaphore_mask;
571 u32 autoneg_advertised;
572 u32 speeds_supported;
573 enum txgbe_smart_speed smart_speed;
574 bool smart_speed_active;
575 bool multispeed_fiber;
576 bool qsfp_shared_i2c_bus;
581 struct txgbe_mbx_info {
582 void (*init_params)(struct txgbe_hw *hw);
583 s32 (*read)(struct txgbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
584 s32 (*write)(struct txgbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
585 s32 (*read_posted)(struct txgbe_hw *hw, u32 *msg, u16 size,
587 s32 (*write_posted)(struct txgbe_hw *hw, u32 *msg, u16 size,
589 s32 (*check_for_msg)(struct txgbe_hw *hw, u16 mbx_id);
590 s32 (*check_for_ack)(struct txgbe_hw *hw, u16 mbx_id);
591 s32 (*check_for_rst)(struct txgbe_hw *hw, u16 mbx_id);
605 struct txgbe_mac_info mac;
606 struct txgbe_addr_filter_info addr_ctrl;
607 struct txgbe_phy_info phy;
608 struct txgbe_link_info link;
609 struct txgbe_rom_info rom;
610 struct txgbe_flash_info flash;
611 struct txgbe_bus_info bus;
612 struct txgbe_mbx_info mbx;
615 u16 subsystem_device_id;
616 u16 subsystem_vendor_id;
617 bool adapter_stopped;
618 bool allow_unsupported_sfp;
619 bool need_crosstalk_fix;
625 enum txgbe_link_status {
626 TXGBE_LINK_STATUS_NONE = 0,
627 TXGBE_LINK_STATUS_KX,
628 TXGBE_LINK_STATUS_KX4
630 enum txgbe_reset_type {
636 u32 q_rx_regs[128 * 4];
637 u32 q_tx_regs[128 * 4];
644 u64 rx_qp_mc_packets;
645 } qp_last[TXGBE_MAX_QP];
648 #include "txgbe_regs.h"
649 #include "txgbe_dummy.h"
651 #endif /* _TXGBE_TYPE_H_ */