net/txgbe: add PF module init and uninit for SRIOV
[dpdk.git] / drivers / net / txgbe / base / txgbe_type.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020
3  */
4
5 #ifndef _TXGBE_TYPE_H_
6 #define _TXGBE_TYPE_H_
7
8 #define TXGBE_LINK_UP_TIME      90 /* 9.0 Seconds */
9 #define TXGBE_AUTO_NEG_TIME     45 /* 4.5 Seconds */
10
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_NUM_POOL          (64)
14 #define TXGBE_MAX_UP            8
15 #define TXGBE_MAX_QP            (128)
16 #define TXGBE_MAX_UTA           128
17
18 #define TXGBE_ALIGN             128 /* as intel did */
19
20 #include "txgbe_status.h"
21 #include "txgbe_osdep.h"
22 #include "txgbe_devids.h"
23
24 struct txgbe_thermal_diode_data {
25         s16 temp;
26         s16 alarm_thresh;
27         s16 dalarm_thresh;
28 };
29
30 struct txgbe_thermal_sensor_data {
31         struct txgbe_thermal_diode_data sensor[1];
32 };
33
34 /* Physical layer type */
35 #define TXGBE_PHYSICAL_LAYER_UNKNOWN            0
36 #define TXGBE_PHYSICAL_LAYER_10GBASE_T          0x00001
37 #define TXGBE_PHYSICAL_LAYER_1000BASE_T         0x00002
38 #define TXGBE_PHYSICAL_LAYER_100BASE_TX         0x00004
39 #define TXGBE_PHYSICAL_LAYER_SFP_PLUS_CU        0x00008
40 #define TXGBE_PHYSICAL_LAYER_10GBASE_LR         0x00010
41 #define TXGBE_PHYSICAL_LAYER_10GBASE_LRM        0x00020
42 #define TXGBE_PHYSICAL_LAYER_10GBASE_SR         0x00040
43 #define TXGBE_PHYSICAL_LAYER_10GBASE_KX4        0x00080
44 #define TXGBE_PHYSICAL_LAYER_10GBASE_CX4        0x00100
45 #define TXGBE_PHYSICAL_LAYER_1000BASE_KX        0x00200
46 #define TXGBE_PHYSICAL_LAYER_1000BASE_BX        0x00400
47 #define TXGBE_PHYSICAL_LAYER_10GBASE_KR         0x00800
48 #define TXGBE_PHYSICAL_LAYER_10GBASE_XAUI       0x01000
49 #define TXGBE_PHYSICAL_LAYER_SFP_ACTIVE_DA      0x02000
50 #define TXGBE_PHYSICAL_LAYER_1000BASE_SX        0x04000
51 #define TXGBE_PHYSICAL_LAYER_10BASE_T           0x08000
52 #define TXGBE_PHYSICAL_LAYER_2500BASE_KX        0x10000
53
54 #define TXGBE_ATR_HASH_MASK                     0x7fff
55
56 enum txgbe_eeprom_type {
57         txgbe_eeprom_unknown = 0,
58         txgbe_eeprom_spi,
59         txgbe_eeprom_flash,
60         txgbe_eeprom_none /* No NVM support */
61 };
62
63 enum txgbe_mac_type {
64         txgbe_mac_unknown = 0,
65         txgbe_mac_raptor,
66         txgbe_mac_raptor_vf,
67         txgbe_num_macs
68 };
69
70 enum txgbe_phy_type {
71         txgbe_phy_unknown = 0,
72         txgbe_phy_none,
73         txgbe_phy_tn,
74         txgbe_phy_aq,
75         txgbe_phy_ext_1g_t,
76         txgbe_phy_cu_mtd,
77         txgbe_phy_cu_unknown,
78         txgbe_phy_qt,
79         txgbe_phy_xaui,
80         txgbe_phy_nl,
81         txgbe_phy_sfp_tyco_passive,
82         txgbe_phy_sfp_unknown_passive,
83         txgbe_phy_sfp_unknown_active,
84         txgbe_phy_sfp_avago,
85         txgbe_phy_sfp_ftl,
86         txgbe_phy_sfp_ftl_active,
87         txgbe_phy_sfp_unknown,
88         txgbe_phy_sfp_intel,
89         txgbe_phy_qsfp_unknown_passive,
90         txgbe_phy_qsfp_unknown_active,
91         txgbe_phy_qsfp_intel,
92         txgbe_phy_qsfp_unknown,
93         txgbe_phy_sfp_unsupported, /* Enforce bit set with unsupported module */
94         txgbe_phy_sgmii,
95         txgbe_phy_fw,
96         txgbe_phy_generic
97 };
98
99 /*
100  * SFP+ module type IDs:
101  *
102  * ID   Module Type
103  * =============
104  * 0    SFP_DA_CU
105  * 1    SFP_SR
106  * 2    SFP_LR
107  * 3    SFP_DA_CU_CORE0 - chip-specific
108  * 4    SFP_DA_CU_CORE1 - chip-specific
109  * 5    SFP_SR/LR_CORE0 - chip-specific
110  * 6    SFP_SR/LR_CORE1 - chip-specific
111  */
112 enum txgbe_sfp_type {
113         txgbe_sfp_type_unknown = 0,
114         txgbe_sfp_type_da_cu,
115         txgbe_sfp_type_sr,
116         txgbe_sfp_type_lr,
117         txgbe_sfp_type_da_cu_core0,
118         txgbe_sfp_type_da_cu_core1,
119         txgbe_sfp_type_srlr_core0,
120         txgbe_sfp_type_srlr_core1,
121         txgbe_sfp_type_da_act_lmt_core0,
122         txgbe_sfp_type_da_act_lmt_core1,
123         txgbe_sfp_type_1g_cu_core0,
124         txgbe_sfp_type_1g_cu_core1,
125         txgbe_sfp_type_1g_sx_core0,
126         txgbe_sfp_type_1g_sx_core1,
127         txgbe_sfp_type_1g_lx_core0,
128         txgbe_sfp_type_1g_lx_core1,
129         txgbe_sfp_type_not_present = 0xFFFE,
130         txgbe_sfp_type_not_known = 0xFFFF
131 };
132
133 enum txgbe_media_type {
134         txgbe_media_type_unknown = 0,
135         txgbe_media_type_fiber,
136         txgbe_media_type_fiber_qsfp,
137         txgbe_media_type_copper,
138         txgbe_media_type_backplane,
139         txgbe_media_type_cx4,
140         txgbe_media_type_virtual
141 };
142
143
144 /* Smart Speed Settings */
145 #define TXGBE_SMARTSPEED_MAX_RETRIES    3
146 enum txgbe_smart_speed {
147         txgbe_smart_speed_auto = 0,
148         txgbe_smart_speed_on,
149         txgbe_smart_speed_off
150 };
151
152 /* PCI bus types */
153 enum txgbe_bus_type {
154         txgbe_bus_type_unknown = 0,
155         txgbe_bus_type_pci,
156         txgbe_bus_type_pcix,
157         txgbe_bus_type_pci_express,
158         txgbe_bus_type_internal,
159         txgbe_bus_type_reserved
160 };
161
162 /* PCI bus speeds */
163 enum txgbe_bus_speed {
164         txgbe_bus_speed_unknown = 0,
165         txgbe_bus_speed_33      = 33,
166         txgbe_bus_speed_66      = 66,
167         txgbe_bus_speed_100     = 100,
168         txgbe_bus_speed_120     = 120,
169         txgbe_bus_speed_133     = 133,
170         txgbe_bus_speed_2500    = 2500,
171         txgbe_bus_speed_5000    = 5000,
172         txgbe_bus_speed_8000    = 8000,
173         txgbe_bus_speed_reserved
174 };
175
176 /* PCI bus widths */
177 enum txgbe_bus_width {
178         txgbe_bus_width_unknown = 0,
179         txgbe_bus_width_pcie_x1 = 1,
180         txgbe_bus_width_pcie_x2 = 2,
181         txgbe_bus_width_pcie_x4 = 4,
182         txgbe_bus_width_pcie_x8 = 8,
183         txgbe_bus_width_32      = 32,
184         txgbe_bus_width_64      = 64,
185         txgbe_bus_width_reserved
186 };
187
188 struct txgbe_hw;
189
190 struct txgbe_addr_filter_info {
191         u32 num_mc_addrs;
192         u32 rar_used_count;
193         u32 mta_in_use;
194         u32 overflow_promisc;
195         bool user_set_promisc;
196 };
197
198 /* Bus parameters */
199 struct txgbe_bus_info {
200         s32 (*get_bus_info)(struct txgbe_hw *hw);
201         void (*set_lan_id)(struct txgbe_hw *hw);
202
203         enum txgbe_bus_speed speed;
204         enum txgbe_bus_width width;
205         enum txgbe_bus_type type;
206
207         u16 func;
208         u8 lan_id;
209         u16 instance_id;
210 };
211
212 /* Statistics counters collected by the MAC */
213 /* PB[] RxTx */
214 struct txgbe_pb_stats {
215         u64 tx_pb_xon_packets;
216         u64 rx_pb_xon_packets;
217         u64 tx_pb_xoff_packets;
218         u64 rx_pb_xoff_packets;
219         u64 rx_pb_dropped;
220         u64 rx_pb_mbuf_alloc_errors;
221         u64 tx_pb_xon2off_packets;
222 };
223
224 /* QP[] RxTx */
225 struct txgbe_qp_stats {
226         u64 rx_qp_packets;
227         u64 tx_qp_packets;
228         u64 rx_qp_bytes;
229         u64 tx_qp_bytes;
230         u64 rx_qp_mc_packets;
231 };
232
233 struct txgbe_hw_stats {
234         /* MNG RxTx */
235         u64 mng_bmc2host_packets;
236         u64 mng_host2bmc_packets;
237         /* Basix RxTx */
238         u64 rx_packets;
239         u64 tx_packets;
240         u64 rx_bytes;
241         u64 tx_bytes;
242         u64 rx_total_bytes;
243         u64 rx_total_packets;
244         u64 tx_total_packets;
245         u64 rx_total_missed_packets;
246         u64 rx_broadcast_packets;
247         u64 tx_broadcast_packets;
248         u64 rx_multicast_packets;
249         u64 tx_multicast_packets;
250         u64 rx_management_packets;
251         u64 tx_management_packets;
252         u64 rx_management_dropped;
253         u64 rx_drop_packets;
254
255         /* Basic Error */
256         u64 rx_crc_errors;
257         u64 rx_illegal_byte_errors;
258         u64 rx_error_bytes;
259         u64 rx_mac_short_packet_dropped;
260         u64 rx_length_errors;
261         u64 rx_undersize_errors;
262         u64 rx_fragment_errors;
263         u64 rx_oversize_errors;
264         u64 rx_jabber_errors;
265         u64 rx_l3_l4_xsum_error;
266         u64 mac_local_errors;
267         u64 mac_remote_errors;
268
269         /* Flow Director */
270         u64 flow_director_added_filters;
271         u64 flow_director_removed_filters;
272         u64 flow_director_filter_add_errors;
273         u64 flow_director_filter_remove_errors;
274         u64 flow_director_matched_filters;
275         u64 flow_director_missed_filters;
276
277         /* FCoE */
278         u64 rx_fcoe_crc_errors;
279         u64 rx_fcoe_mbuf_allocation_errors;
280         u64 rx_fcoe_dropped;
281         u64 rx_fcoe_packets;
282         u64 tx_fcoe_packets;
283         u64 rx_fcoe_bytes;
284         u64 tx_fcoe_bytes;
285         u64 rx_fcoe_no_ddp;
286         u64 rx_fcoe_no_ddp_ext_buff;
287
288         /* MACSEC */
289         u64 tx_macsec_pkts_untagged;
290         u64 tx_macsec_pkts_encrypted;
291         u64 tx_macsec_pkts_protected;
292         u64 tx_macsec_octets_encrypted;
293         u64 tx_macsec_octets_protected;
294         u64 rx_macsec_pkts_untagged;
295         u64 rx_macsec_pkts_badtag;
296         u64 rx_macsec_pkts_nosci;
297         u64 rx_macsec_pkts_unknownsci;
298         u64 rx_macsec_octets_decrypted;
299         u64 rx_macsec_octets_validated;
300         u64 rx_macsec_sc_pkts_unchecked;
301         u64 rx_macsec_sc_pkts_delayed;
302         u64 rx_macsec_sc_pkts_late;
303         u64 rx_macsec_sa_pkts_ok;
304         u64 rx_macsec_sa_pkts_invalid;
305         u64 rx_macsec_sa_pkts_notvalid;
306         u64 rx_macsec_sa_pkts_unusedsa;
307         u64 rx_macsec_sa_pkts_notusingsa;
308
309         /* MAC RxTx */
310         u64 rx_size_64_packets;
311         u64 rx_size_65_to_127_packets;
312         u64 rx_size_128_to_255_packets;
313         u64 rx_size_256_to_511_packets;
314         u64 rx_size_512_to_1023_packets;
315         u64 rx_size_1024_to_max_packets;
316         u64 tx_size_64_packets;
317         u64 tx_size_65_to_127_packets;
318         u64 tx_size_128_to_255_packets;
319         u64 tx_size_256_to_511_packets;
320         u64 tx_size_512_to_1023_packets;
321         u64 tx_size_1024_to_max_packets;
322
323         /* Flow Control */
324         u64 tx_xon_packets;
325         u64 rx_xon_packets;
326         u64 tx_xoff_packets;
327         u64 rx_xoff_packets;
328
329         /* PB[] RxTx */
330         struct {
331                 u64 rx_up_packets;
332                 u64 tx_up_packets;
333                 u64 rx_up_bytes;
334                 u64 tx_up_bytes;
335                 u64 rx_up_drop_packets;
336
337                 u64 tx_up_xon_packets;
338                 u64 rx_up_xon_packets;
339                 u64 tx_up_xoff_packets;
340                 u64 rx_up_xoff_packets;
341                 u64 rx_up_dropped;
342                 u64 rx_up_mbuf_alloc_errors;
343                 u64 tx_up_xon2off_packets;
344         } up[TXGBE_MAX_UP];
345
346         /* QP[] RxTx */
347         struct {
348                 u64 rx_qp_packets;
349                 u64 tx_qp_packets;
350                 u64 rx_qp_bytes;
351                 u64 tx_qp_bytes;
352                 u64 rx_qp_mc_packets;
353         } qp[TXGBE_MAX_QP];
354
355 };
356
357 /* iterator type for walking multicast address lists */
358 typedef u8* (*txgbe_mc_addr_itr) (struct txgbe_hw *hw, u8 **mc_addr_ptr,
359                                   u32 *vmdq);
360
361 struct txgbe_link_info {
362         s32 (*read_link)(struct txgbe_hw *hw, u8 addr, u16 reg, u16 *val);
363         s32 (*read_link_unlocked)(struct txgbe_hw *hw, u8 addr, u16 reg,
364                                   u16 *val);
365         s32 (*write_link)(struct txgbe_hw *hw, u8 addr, u16 reg, u16 val);
366         s32 (*write_link_unlocked)(struct txgbe_hw *hw, u8 addr, u16 reg,
367                                    u16 val);
368
369         u8 addr;
370 };
371
372 struct txgbe_rom_info {
373         s32 (*init_params)(struct txgbe_hw *hw);
374         s32 (*read16)(struct txgbe_hw *hw, u32 offset, u16 *data);
375         s32 (*readw_sw)(struct txgbe_hw *hw, u32 offset, u16 *data);
376         s32 (*readw_buffer)(struct txgbe_hw *hw, u32 offset, u32 words,
377                             void *data);
378         s32 (*read32)(struct txgbe_hw *hw, u32 addr, u32 *data);
379         s32 (*read_buffer)(struct txgbe_hw *hw, u32 addr, u32 len, void *data);
380         s32 (*write16)(struct txgbe_hw *hw, u32 offset, u16 data);
381         s32 (*writew_sw)(struct txgbe_hw *hw, u32 offset, u16 data);
382         s32 (*writew_buffer)(struct txgbe_hw *hw, u32 offset, u32 words,
383                              void *data);
384         s32 (*write32)(struct txgbe_hw *hw, u32 addr, u32 data);
385         s32 (*write_buffer)(struct txgbe_hw *hw, u32 addr, u32 len, void *data);
386         s32 (*validate_checksum)(struct txgbe_hw *hw, u16 *checksum_val);
387         s32 (*update_checksum)(struct txgbe_hw *hw);
388         s32 (*calc_checksum)(struct txgbe_hw *hw);
389
390         enum txgbe_eeprom_type type;
391         u32 semaphore_delay;
392         u16 word_size;
393         u16 address_bits;
394         u16 word_page_size;
395         u16 ctrl_word_3;
396
397         u32 sw_addr;
398 };
399
400 struct txgbe_flash_info {
401         u32 semaphore_delay;
402         u32 dword_size;
403         u16 address_bits;
404 };
405
406 #define TXGBE_FLAGS_DOUBLE_RESET_REQUIRED       0x01
407 struct txgbe_mac_info {
408         s32 (*init_hw)(struct txgbe_hw *hw);
409         s32 (*reset_hw)(struct txgbe_hw *hw);
410         s32 (*start_hw)(struct txgbe_hw *hw);
411         s32 (*stop_hw)(struct txgbe_hw *hw);
412         s32 (*clear_hw_cntrs)(struct txgbe_hw *hw);
413         s32 (*get_mac_addr)(struct txgbe_hw *hw, u8 *mac_addr);
414         s32 (*get_san_mac_addr)(struct txgbe_hw *hw, u8 *san_mac_addr);
415         s32 (*set_san_mac_addr)(struct txgbe_hw *hw, u8 *san_mac_addr);
416         s32 (*get_device_caps)(struct txgbe_hw *hw, u16 *device_caps);
417         s32 (*get_wwn_prefix)(struct txgbe_hw *hw, u16 *wwnn_prefix,
418                                  u16 *wwpn_prefix);
419         s32 (*setup_sfp)(struct txgbe_hw *hw);
420         s32 (*enable_rx_dma)(struct txgbe_hw *hw, u32 regval);
421         s32 (*disable_sec_rx_path)(struct txgbe_hw *hw);
422         s32 (*enable_sec_rx_path)(struct txgbe_hw *hw);
423         s32 (*disable_sec_tx_path)(struct txgbe_hw *hw);
424         s32 (*enable_sec_tx_path)(struct txgbe_hw *hw);
425         s32 (*acquire_swfw_sync)(struct txgbe_hw *hw, u32 mask);
426         void (*release_swfw_sync)(struct txgbe_hw *hw, u32 mask);
427         u64 (*autoc_read)(struct txgbe_hw *hw);
428         void (*autoc_write)(struct txgbe_hw *hw, u64 value);
429         s32 (*prot_autoc_read)(struct txgbe_hw *hw, bool *locked, u64 *value);
430         s32 (*prot_autoc_write)(struct txgbe_hw *hw, bool locked, u64 value);
431         s32 (*negotiate_api_version)(struct txgbe_hw *hw, int api);
432
433         /* Link */
434         void (*disable_tx_laser)(struct txgbe_hw *hw);
435         void (*enable_tx_laser)(struct txgbe_hw *hw);
436         void (*flap_tx_laser)(struct txgbe_hw *hw);
437         s32 (*setup_link)(struct txgbe_hw *hw, u32 speed,
438                                bool autoneg_wait_to_complete);
439         s32 (*setup_mac_link)(struct txgbe_hw *hw, u32 speed,
440                                bool autoneg_wait_to_complete);
441         s32 (*check_link)(struct txgbe_hw *hw, u32 *speed,
442                                bool *link_up, bool link_up_wait_to_complete);
443         s32 (*get_link_capabilities)(struct txgbe_hw *hw,
444                                       u32 *speed, bool *autoneg);
445         void (*set_rate_select_speed)(struct txgbe_hw *hw, u32 speed);
446
447         /* Packet Buffer manipulation */
448         void (*setup_pba)(struct txgbe_hw *hw, int num_pb, u32 headroom,
449                              int strategy);
450
451         /* LED */
452         s32 (*led_on)(struct txgbe_hw *hw, u32 index);
453         s32 (*led_off)(struct txgbe_hw *hw, u32 index);
454
455         /* RAR, Multicast, VLAN */
456         s32 (*set_rar)(struct txgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
457                           u32 enable_addr);
458         s32 (*set_uc_addr)(struct txgbe_hw *hw, u32 index, u8 *addr);
459         s32 (*clear_rar)(struct txgbe_hw *hw, u32 index);
460         s32 (*set_vmdq)(struct txgbe_hw *hw, u32 rar, u32 vmdq);
461         s32 (*clear_vmdq)(struct txgbe_hw *hw, u32 rar, u32 vmdq);
462         s32 (*init_rx_addrs)(struct txgbe_hw *hw);
463         s32 (*update_mc_addr_list)(struct txgbe_hw *hw, u8 *mc_addr_list,
464                                       u32 mc_addr_count,
465                                       txgbe_mc_addr_itr func, bool clear);
466         s32 (*clear_vfta)(struct txgbe_hw *hw);
467         s32 (*set_vfta)(struct txgbe_hw *hw, u32 vlan,
468                          u32 vind, bool vlan_on, bool vlvf_bypass);
469         s32 (*set_vlvf)(struct txgbe_hw *hw, u32 vlan, u32 vind,
470                            bool vlan_on, u32 *vfta_delta, u32 vfta,
471                            bool vlvf_bypass);
472         s32 (*init_uta_tables)(struct txgbe_hw *hw);
473         void (*set_mac_anti_spoofing)(struct txgbe_hw *hw, bool enable, int vf);
474         void (*set_vlan_anti_spoofing)(struct txgbe_hw *hw,
475                                         bool enable, int vf);
476         s32 (*update_xcast_mode)(struct txgbe_hw *hw, int xcast_mode);
477         s32 (*set_rlpml)(struct txgbe_hw *hw, u16 max_size);
478
479         /* Flow Control */
480         s32 (*fc_enable)(struct txgbe_hw *hw);
481         s32 (*setup_fc)(struct txgbe_hw *hw);
482         void (*fc_autoneg)(struct txgbe_hw *hw);
483
484         /* Manageability interface */
485         s32 (*set_fw_drv_ver)(struct txgbe_hw *hw, u8 maj, u8 min, u8 build,
486                          u8 ver, u16 len, const char *driver_ver);
487         s32 (*get_thermal_sensor_data)(struct txgbe_hw *hw);
488         s32 (*init_thermal_sensor_thresh)(struct txgbe_hw *hw);
489         void (*get_rtrup2tc)(struct txgbe_hw *hw, u8 *map);
490         void (*disable_rx)(struct txgbe_hw *hw);
491         void (*enable_rx)(struct txgbe_hw *hw);
492         void (*set_ethertype_anti_spoofing)(struct txgbe_hw *hw,
493                                                 bool enable, int vf);
494         s32 (*dmac_update_tcs)(struct txgbe_hw *hw);
495         s32 (*dmac_config_tcs)(struct txgbe_hw *hw);
496         s32 (*dmac_config)(struct txgbe_hw *hw);
497         s32 (*setup_eee)(struct txgbe_hw *hw, bool enable_eee);
498
499         enum txgbe_mac_type type;
500         u8 addr[ETH_ADDR_LEN];
501         u8 perm_addr[ETH_ADDR_LEN];
502         u8 san_addr[ETH_ADDR_LEN];
503         /* prefix for World Wide Node Name (WWNN) */
504         u16 wwnn_prefix;
505         /* prefix for World Wide Port Name (WWPN) */
506         u16 wwpn_prefix;
507 #define TXGBE_MAX_MTA                   128
508         u32 mta_shadow[TXGBE_MAX_MTA];
509         s32 mc_filter_type;
510         u32 mcft_size;
511         u32 vft_size;
512         u32 num_rar_entries;
513         u32 max_tx_queues;
514         u32 max_rx_queues;
515
516         u8  san_mac_rar_index;
517         bool get_link_status;
518         u64 orig_autoc;  /* cached value of AUTOC */
519         bool orig_link_settings_stored;
520         bool autotry_restart;
521         u8 flags;
522         struct txgbe_thermal_sensor_data  thermal_sensor_data;
523         bool set_lben;
524         u32  max_link_up_time;
525 };
526
527 struct txgbe_phy_info {
528         u32 (*get_media_type)(struct txgbe_hw *hw);
529         s32 (*identify)(struct txgbe_hw *hw);
530         s32 (*identify_sfp)(struct txgbe_hw *hw);
531         s32 (*init)(struct txgbe_hw *hw);
532         s32 (*reset)(struct txgbe_hw *hw);
533         s32 (*read_reg)(struct txgbe_hw *hw, u32 reg_addr,
534                                 u32 device_type, u16 *phy_data);
535         s32 (*write_reg)(struct txgbe_hw *hw, u32 reg_addr,
536                                 u32 device_type, u16 phy_data);
537         s32 (*read_reg_mdi)(struct txgbe_hw *hw, u32 reg_addr,
538                                 u32 device_type, u16 *phy_data);
539         s32 (*write_reg_mdi)(struct txgbe_hw *hw, u32 reg_addr,
540                                 u32 device_type, u16 phy_data);
541         s32 (*setup_link)(struct txgbe_hw *hw);
542         s32 (*setup_internal_link)(struct txgbe_hw *hw);
543         s32 (*setup_link_speed)(struct txgbe_hw *hw, u32 speed,
544                                 bool autoneg_wait_to_complete);
545         s32 (*check_link)(struct txgbe_hw *hw, u32 *speed, bool *link_up);
546         s32 (*read_i2c_byte)(struct txgbe_hw *hw, u8 byte_offset,
547                                 u8 dev_addr, u8 *data);
548         s32 (*write_i2c_byte)(struct txgbe_hw *hw, u8 byte_offset,
549                                 u8 dev_addr, u8 data);
550         s32 (*read_i2c_sff8472)(struct txgbe_hw *hw, u8 byte_offset,
551                                 u8 *sff8472_data);
552         s32 (*read_i2c_eeprom)(struct txgbe_hw *hw, u8 byte_offset,
553                                 u8 *eeprom_data);
554         s32 (*write_i2c_eeprom)(struct txgbe_hw *hw, u8 byte_offset,
555                                 u8 eeprom_data);
556         s32 (*check_overtemp)(struct txgbe_hw *hw);
557         s32 (*set_phy_power)(struct txgbe_hw *hw, bool on);
558         s32 (*handle_lasi)(struct txgbe_hw *hw);
559         s32 (*read_i2c_byte_unlocked)(struct txgbe_hw *hw, u8 offset, u8 addr,
560                                       u8 *value);
561         s32 (*write_i2c_byte_unlocked)(struct txgbe_hw *hw, u8 offset, u8 addr,
562                                        u8 value);
563
564         enum txgbe_phy_type type;
565         u32 addr;
566         u32 id;
567         enum txgbe_sfp_type sfp_type;
568         bool sfp_setup_needed;
569         u32 revision;
570         u32 media_type;
571         u32 phy_semaphore_mask;
572         bool reset_disable;
573         u32 autoneg_advertised;
574         u32 speeds_supported;
575         enum txgbe_smart_speed smart_speed;
576         bool smart_speed_active;
577         bool multispeed_fiber;
578         bool qsfp_shared_i2c_bus;
579         u32 nw_mng_if_sel;
580         u32 link_mode;
581 };
582
583 struct txgbe_mbx_stats {
584         u32 msgs_tx;
585         u32 msgs_rx;
586
587         u32 acks;
588         u32 reqs;
589         u32 rsts;
590 };
591
592 struct txgbe_mbx_info {
593         void (*init_params)(struct txgbe_hw *hw);
594         s32  (*read)(struct txgbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
595         s32  (*write)(struct txgbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
596         s32  (*read_posted)(struct txgbe_hw *hw, u32 *msg, u16 size,
597                                 u16 mbx_id);
598         s32  (*write_posted)(struct txgbe_hw *hw, u32 *msg, u16 size,
599                                 u16 mbx_id);
600         s32  (*check_for_msg)(struct txgbe_hw *hw, u16 mbx_id);
601         s32  (*check_for_ack)(struct txgbe_hw *hw, u16 mbx_id);
602         s32  (*check_for_rst)(struct txgbe_hw *hw, u16 mbx_id);
603
604         struct txgbe_mbx_stats stats;
605         u32 timeout;
606         u32 usec_delay;
607         u16 size;
608 };
609
610 enum txgbe_isb_idx {
611         TXGBE_ISB_HEADER,
612         TXGBE_ISB_MISC,
613         TXGBE_ISB_VEC0,
614         TXGBE_ISB_VEC1,
615         TXGBE_ISB_MAX
616 };
617
618 struct txgbe_hw {
619         void IOMEM *hw_addr;
620         void *back;
621         struct txgbe_mac_info mac;
622         struct txgbe_addr_filter_info addr_ctrl;
623         struct txgbe_phy_info phy;
624         struct txgbe_link_info link;
625         struct txgbe_rom_info rom;
626         struct txgbe_flash_info flash;
627         struct txgbe_bus_info bus;
628         struct txgbe_mbx_info mbx;
629         u16 device_id;
630         u16 vendor_id;
631         u16 subsystem_device_id;
632         u16 subsystem_vendor_id;
633         bool adapter_stopped;
634         bool allow_unsupported_sfp;
635         bool need_crosstalk_fix;
636
637         uint64_t isb_dma;
638         void IOMEM *isb_mem;
639         u16 nb_rx_queues;
640         u16 nb_tx_queues;
641         enum txgbe_link_status {
642                 TXGBE_LINK_STATUS_NONE = 0,
643                 TXGBE_LINK_STATUS_KX,
644                 TXGBE_LINK_STATUS_KX4
645         } link_status;
646         enum txgbe_reset_type {
647                 TXGBE_LAN_RESET = 0,
648                 TXGBE_SW_RESET,
649                 TXGBE_GLOBAL_RESET
650         } reset_type;
651
652         u32 q_rx_regs[128 * 4];
653         u32 q_tx_regs[128 * 4];
654         bool offset_loaded;
655         struct {
656                 u64 rx_qp_packets;
657                 u64 tx_qp_packets;
658                 u64 rx_qp_bytes;
659                 u64 tx_qp_bytes;
660                 u64 rx_qp_mc_packets;
661         } qp_last[TXGBE_MAX_QP];
662 };
663
664 #include "txgbe_regs.h"
665 #include "txgbe_dummy.h"
666
667 #endif /* _TXGBE_TYPE_H_ */