343279127f7063e8aad02bea1c333ebd92f98f39
[dpdk.git] / drivers / net / txgbe / base / txgbe_type.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020 Beijing WangXun Technology Co., Ltd.
3  * Copyright(c) 2010-2017 Intel Corporation
4  */
5
6 #ifndef _TXGBE_TYPE_H_
7 #define _TXGBE_TYPE_H_
8
9 #define TXGBE_DCB_TC_MAX        TXGBE_MAX_UP
10 #define TXGBE_DCB_UP_MAX        TXGBE_MAX_UP
11 #define TXGBE_DCB_BWG_MAX       TXGBE_MAX_UP
12 #define TXGBE_LINK_UP_TIME      90 /* 9.0 Seconds */
13 #define TXGBE_AUTO_NEG_TIME     45 /* 4.5 Seconds */
14
15 #define TXGBE_RX_HDR_SIZE       256
16 #define TXGBE_RX_BUF_SIZE       2048
17
18 #define TXGBE_FRAME_SIZE_MAX    (9728) /* Maximum frame size, +FCS */
19 #define TXGBE_FRAME_SIZE_DFT    (1518) /* Default frame size, +FCS */
20 #define TXGBE_NUM_POOL          (64)
21 #define TXGBE_PBTXSIZE_MAX      0x00028000 /* 160KB Packet Buffer */
22 #define TXGBE_MAX_FTQF_FILTERS  128
23 #define TXGBE_TXPKT_SIZE_MAX    0xA /* Max Tx Packet size */
24 #define TXGBE_MAX_UP            8
25 #define TXGBE_MAX_QP            (128)
26 #define TXGBE_MAX_UTA           128
27
28 #define TXGBE_FDIR_INIT_DONE_POLL               10
29 #define TXGBE_FDIRCMD_CMD_POLL                  10
30 #define TXGBE_VF_INIT_TIMEOUT   200 /* Number of retries to clear RSTI */
31 #define TXGBE_SPI_TIMEOUT       10000
32
33 #define TXGBE_ALIGN             128 /* as intel did */
34
35 #include "txgbe_status.h"
36 #include "txgbe_osdep.h"
37 #include "txgbe_devids.h"
38
39 struct txgbe_thermal_diode_data {
40         s16 temp;
41         s16 alarm_thresh;
42         s16 dalarm_thresh;
43 };
44
45 struct txgbe_thermal_sensor_data {
46         struct txgbe_thermal_diode_data sensor[1];
47 };
48
49 /* Packet buffer allocation strategies */
50 enum {
51         PBA_STRATEGY_EQUAL      = 0, /* Distribute PB space equally */
52 #define PBA_STRATEGY_EQUAL      PBA_STRATEGY_EQUAL
53         PBA_STRATEGY_WEIGHTED   = 1, /* Weight front half of TCs */
54 #define PBA_STRATEGY_WEIGHTED   PBA_STRATEGY_WEIGHTED
55 };
56
57 /* Physical layer type */
58 #define TXGBE_PHYSICAL_LAYER_UNKNOWN            0
59 #define TXGBE_PHYSICAL_LAYER_10GBASE_T          0x00001
60 #define TXGBE_PHYSICAL_LAYER_1000BASE_T         0x00002
61 #define TXGBE_PHYSICAL_LAYER_100BASE_TX         0x00004
62 #define TXGBE_PHYSICAL_LAYER_SFP_PLUS_CU        0x00008
63 #define TXGBE_PHYSICAL_LAYER_10GBASE_LR         0x00010
64 #define TXGBE_PHYSICAL_LAYER_10GBASE_LRM        0x00020
65 #define TXGBE_PHYSICAL_LAYER_10GBASE_SR         0x00040
66 #define TXGBE_PHYSICAL_LAYER_10GBASE_KX4        0x00080
67 #define TXGBE_PHYSICAL_LAYER_10GBASE_CX4        0x00100
68 #define TXGBE_PHYSICAL_LAYER_1000BASE_KX        0x00200
69 #define TXGBE_PHYSICAL_LAYER_1000BASE_BX        0x00400
70 #define TXGBE_PHYSICAL_LAYER_10GBASE_KR         0x00800
71 #define TXGBE_PHYSICAL_LAYER_10GBASE_XAUI       0x01000
72 #define TXGBE_PHYSICAL_LAYER_SFP_ACTIVE_DA      0x02000
73 #define TXGBE_PHYSICAL_LAYER_1000BASE_SX        0x04000
74 #define TXGBE_PHYSICAL_LAYER_10BASE_T           0x08000
75 #define TXGBE_PHYSICAL_LAYER_2500BASE_KX        0x10000
76
77 /* Software ATR hash keys */
78 #define TXGBE_ATR_BUCKET_HASH_KEY               0x3DAD14E2
79 #define TXGBE_ATR_SIGNATURE_HASH_KEY            0x174D3614
80
81 /* Software ATR input stream values and masks */
82 #define TXGBE_ATR_HASH_MASK                     0x7fff
83 #define TXGBE_ATR_L3TYPE_MASK                   0x4
84 #define TXGBE_ATR_L3TYPE_IPV4                   0x0
85 #define TXGBE_ATR_L3TYPE_IPV6                   0x4
86 #define TXGBE_ATR_L4TYPE_MASK                   0x3
87 #define TXGBE_ATR_L4TYPE_UDP                    0x1
88 #define TXGBE_ATR_L4TYPE_TCP                    0x2
89 #define TXGBE_ATR_L4TYPE_SCTP                   0x3
90 #define TXGBE_ATR_TUNNEL_MASK                   0x10
91 #define TXGBE_ATR_TUNNEL_ANY                    0x10
92 enum txgbe_atr_flow_type {
93         TXGBE_ATR_FLOW_TYPE_IPV4                = 0x0,
94         TXGBE_ATR_FLOW_TYPE_UDPV4               = 0x1,
95         TXGBE_ATR_FLOW_TYPE_TCPV4               = 0x2,
96         TXGBE_ATR_FLOW_TYPE_SCTPV4              = 0x3,
97         TXGBE_ATR_FLOW_TYPE_IPV6                = 0x4,
98         TXGBE_ATR_FLOW_TYPE_UDPV6               = 0x5,
99         TXGBE_ATR_FLOW_TYPE_TCPV6               = 0x6,
100         TXGBE_ATR_FLOW_TYPE_SCTPV6              = 0x7,
101         TXGBE_ATR_FLOW_TYPE_TUNNELED_IPV4       = 0x10,
102         TXGBE_ATR_FLOW_TYPE_TUNNELED_UDPV4      = 0x11,
103         TXGBE_ATR_FLOW_TYPE_TUNNELED_TCPV4      = 0x12,
104         TXGBE_ATR_FLOW_TYPE_TUNNELED_SCTPV4     = 0x13,
105         TXGBE_ATR_FLOW_TYPE_TUNNELED_IPV6       = 0x14,
106         TXGBE_ATR_FLOW_TYPE_TUNNELED_UDPV6      = 0x15,
107         TXGBE_ATR_FLOW_TYPE_TUNNELED_TCPV6      = 0x16,
108         TXGBE_ATR_FLOW_TYPE_TUNNELED_SCTPV6     = 0x17,
109 };
110
111 /* Flow Director ATR input struct. */
112 struct txgbe_atr_input {
113         /*
114          * Byte layout in order, all values with MSB first:
115          *
116          * vm_pool      - 1 byte
117          * flow_type    - 1 byte
118          * vlan_id      - 2 bytes
119          * src_ip       - 16 bytes
120          * inner_mac    - 6 bytes
121          * cloud_mode   - 2 bytes
122          * tni_vni      - 4 bytes
123          * dst_ip       - 16 bytes
124          * src_port     - 2 bytes
125          * dst_port     - 2 bytes
126          * flex_bytes   - 2 bytes
127          * bkt_hash     - 2 bytes
128          */
129         u8 vm_pool;
130         u8 flow_type;
131         __be16 pkt_type;
132         __be32 dst_ip[4];
133         __be32 src_ip[4];
134         __be16 src_port;
135         __be16 dst_port;
136         __be16 flex_bytes;
137         __be16 bkt_hash;
138 };
139
140 enum txgbe_eeprom_type {
141         txgbe_eeprom_unknown = 0,
142         txgbe_eeprom_spi,
143         txgbe_eeprom_flash,
144         txgbe_eeprom_none /* No NVM support */
145 };
146
147 enum txgbe_mac_type {
148         txgbe_mac_unknown = 0,
149         txgbe_mac_raptor,
150         txgbe_mac_raptor_vf,
151         txgbe_num_macs
152 };
153
154 enum txgbe_phy_type {
155         txgbe_phy_unknown = 0,
156         txgbe_phy_none,
157         txgbe_phy_tn,
158         txgbe_phy_aq,
159         txgbe_phy_ext_1g_t,
160         txgbe_phy_cu_mtd,
161         txgbe_phy_cu_unknown,
162         txgbe_phy_qt,
163         txgbe_phy_xaui,
164         txgbe_phy_nl,
165         txgbe_phy_sfp_tyco_passive,
166         txgbe_phy_sfp_unknown_passive,
167         txgbe_phy_sfp_unknown_active,
168         txgbe_phy_sfp_avago,
169         txgbe_phy_sfp_ftl,
170         txgbe_phy_sfp_ftl_active,
171         txgbe_phy_sfp_unknown,
172         txgbe_phy_sfp_intel,
173         txgbe_phy_qsfp_unknown_passive,
174         txgbe_phy_qsfp_unknown_active,
175         txgbe_phy_qsfp_intel,
176         txgbe_phy_qsfp_unknown,
177         txgbe_phy_sfp_unsupported, /* Enforce bit set with unsupported module */
178         txgbe_phy_sgmii,
179         txgbe_phy_fw,
180         txgbe_phy_generic
181 };
182
183 /*
184  * SFP+ module type IDs:
185  *
186  * ID   Module Type
187  * =============
188  * 0    SFP_DA_CU
189  * 1    SFP_SR
190  * 2    SFP_LR
191  * 3    SFP_DA_CU_CORE0 - chip-specific
192  * 4    SFP_DA_CU_CORE1 - chip-specific
193  * 5    SFP_SR/LR_CORE0 - chip-specific
194  * 6    SFP_SR/LR_CORE1 - chip-specific
195  */
196 enum txgbe_sfp_type {
197         txgbe_sfp_type_unknown = 0,
198         txgbe_sfp_type_da_cu,
199         txgbe_sfp_type_sr,
200         txgbe_sfp_type_lr,
201         txgbe_sfp_type_da_cu_core0,
202         txgbe_sfp_type_da_cu_core1,
203         txgbe_sfp_type_srlr_core0,
204         txgbe_sfp_type_srlr_core1,
205         txgbe_sfp_type_da_act_lmt_core0,
206         txgbe_sfp_type_da_act_lmt_core1,
207         txgbe_sfp_type_1g_cu_core0,
208         txgbe_sfp_type_1g_cu_core1,
209         txgbe_sfp_type_1g_sx_core0,
210         txgbe_sfp_type_1g_sx_core1,
211         txgbe_sfp_type_1g_lx_core0,
212         txgbe_sfp_type_1g_lx_core1,
213         txgbe_sfp_type_not_present = 0xFFFE,
214         txgbe_sfp_type_not_known = 0xFFFF
215 };
216
217 enum txgbe_media_type {
218         txgbe_media_type_unknown = 0,
219         txgbe_media_type_fiber,
220         txgbe_media_type_fiber_qsfp,
221         txgbe_media_type_copper,
222         txgbe_media_type_backplane,
223         txgbe_media_type_cx4,
224         txgbe_media_type_virtual
225 };
226
227 /* Flow Control Settings */
228 enum txgbe_fc_mode {
229         txgbe_fc_none = 0,
230         txgbe_fc_rx_pause,
231         txgbe_fc_tx_pause,
232         txgbe_fc_full,
233         txgbe_fc_default
234 };
235
236 /* Smart Speed Settings */
237 #define TXGBE_SMARTSPEED_MAX_RETRIES    3
238 enum txgbe_smart_speed {
239         txgbe_smart_speed_auto = 0,
240         txgbe_smart_speed_on,
241         txgbe_smart_speed_off
242 };
243
244 /* PCI bus types */
245 enum txgbe_bus_type {
246         txgbe_bus_type_unknown = 0,
247         txgbe_bus_type_pci,
248         txgbe_bus_type_pcix,
249         txgbe_bus_type_pci_express,
250         txgbe_bus_type_internal,
251         txgbe_bus_type_reserved
252 };
253
254 /* PCI bus speeds */
255 enum txgbe_bus_speed {
256         txgbe_bus_speed_unknown = 0,
257         txgbe_bus_speed_33      = 33,
258         txgbe_bus_speed_66      = 66,
259         txgbe_bus_speed_100     = 100,
260         txgbe_bus_speed_120     = 120,
261         txgbe_bus_speed_133     = 133,
262         txgbe_bus_speed_2500    = 2500,
263         txgbe_bus_speed_5000    = 5000,
264         txgbe_bus_speed_8000    = 8000,
265         txgbe_bus_speed_reserved
266 };
267
268 /* PCI bus widths */
269 enum txgbe_bus_width {
270         txgbe_bus_width_unknown = 0,
271         txgbe_bus_width_pcie_x1 = 1,
272         txgbe_bus_width_pcie_x2 = 2,
273         txgbe_bus_width_pcie_x4 = 4,
274         txgbe_bus_width_pcie_x8 = 8,
275         txgbe_bus_width_32      = 32,
276         txgbe_bus_width_64      = 64,
277         txgbe_bus_width_reserved
278 };
279
280 struct txgbe_hw;
281
282 struct txgbe_addr_filter_info {
283         u32 num_mc_addrs;
284         u32 rar_used_count;
285         u32 mta_in_use;
286         u32 overflow_promisc;
287         bool user_set_promisc;
288 };
289
290 /* Bus parameters */
291 struct txgbe_bus_info {
292         s32 (*get_bus_info)(struct txgbe_hw *hw);
293         void (*set_lan_id)(struct txgbe_hw *hw);
294
295         enum txgbe_bus_speed speed;
296         enum txgbe_bus_width width;
297         enum txgbe_bus_type type;
298
299         u16 func;
300         u8 lan_id;
301         u16 instance_id;
302 };
303
304 /* Flow control parameters */
305 struct txgbe_fc_info {
306         u32 high_water[TXGBE_DCB_TC_MAX]; /* Flow Ctrl High-water */
307         u32 low_water[TXGBE_DCB_TC_MAX]; /* Flow Ctrl Low-water */
308         u16 pause_time; /* Flow Control Pause timer */
309         bool send_xon; /* Flow control send XON */
310         bool strict_ieee; /* Strict IEEE mode */
311         bool disable_fc_autoneg; /* Do not autonegotiate FC */
312         bool fc_was_autonegged; /* Is current_mode the result of autonegging? */
313         enum txgbe_fc_mode current_mode; /* FC mode in effect */
314         enum txgbe_fc_mode requested_mode; /* FC mode requested by caller */
315 };
316
317 /* Statistics counters collected by the MAC */
318 /* PB[] RxTx */
319 struct txgbe_pb_stats {
320         u64 tx_pb_xon_packets;
321         u64 rx_pb_xon_packets;
322         u64 tx_pb_xoff_packets;
323         u64 rx_pb_xoff_packets;
324         u64 rx_pb_dropped;
325         u64 rx_pb_mbuf_alloc_errors;
326         u64 tx_pb_xon2off_packets;
327 };
328
329 /* QP[] RxTx */
330 struct txgbe_qp_stats {
331         u64 rx_qp_packets;
332         u64 tx_qp_packets;
333         u64 rx_qp_bytes;
334         u64 tx_qp_bytes;
335         u64 rx_qp_mc_packets;
336 };
337
338 struct txgbe_hw_stats {
339         /* MNG RxTx */
340         u64 mng_bmc2host_packets;
341         u64 mng_host2bmc_packets;
342         /* Basix RxTx */
343         u64 rx_packets;
344         u64 tx_packets;
345         u64 rx_bytes;
346         u64 tx_bytes;
347         u64 rx_total_bytes;
348         u64 rx_total_packets;
349         u64 tx_total_packets;
350         u64 rx_total_missed_packets;
351         u64 rx_broadcast_packets;
352         u64 tx_broadcast_packets;
353         u64 rx_multicast_packets;
354         u64 tx_multicast_packets;
355         u64 rx_management_packets;
356         u64 tx_management_packets;
357         u64 rx_management_dropped;
358         u64 rx_dma_drop;
359         u64 rx_drop_packets;
360
361         /* Basic Error */
362         u64 rx_crc_errors;
363         u64 rx_illegal_byte_errors;
364         u64 rx_error_bytes;
365         u64 rx_mac_short_packet_dropped;
366         u64 rx_length_errors;
367         u64 rx_undersize_errors;
368         u64 rx_fragment_errors;
369         u64 rx_oversize_errors;
370         u64 rx_jabber_errors;
371         u64 rx_l3_l4_xsum_error;
372         u64 mac_local_errors;
373         u64 mac_remote_errors;
374
375         /* Flow Director */
376         u64 flow_director_added_filters;
377         u64 flow_director_removed_filters;
378         u64 flow_director_filter_add_errors;
379         u64 flow_director_filter_remove_errors;
380         u64 flow_director_matched_filters;
381         u64 flow_director_missed_filters;
382
383         /* FCoE */
384         u64 rx_fcoe_crc_errors;
385         u64 rx_fcoe_mbuf_allocation_errors;
386         u64 rx_fcoe_dropped;
387         u64 rx_fcoe_packets;
388         u64 tx_fcoe_packets;
389         u64 rx_fcoe_bytes;
390         u64 tx_fcoe_bytes;
391         u64 rx_fcoe_no_ddp;
392         u64 rx_fcoe_no_ddp_ext_buff;
393
394         /* MACSEC */
395         u64 tx_macsec_pkts_untagged;
396         u64 tx_macsec_pkts_encrypted;
397         u64 tx_macsec_pkts_protected;
398         u64 tx_macsec_octets_encrypted;
399         u64 tx_macsec_octets_protected;
400         u64 rx_macsec_pkts_untagged;
401         u64 rx_macsec_pkts_badtag;
402         u64 rx_macsec_pkts_nosci;
403         u64 rx_macsec_pkts_unknownsci;
404         u64 rx_macsec_octets_decrypted;
405         u64 rx_macsec_octets_validated;
406         u64 rx_macsec_sc_pkts_unchecked;
407         u64 rx_macsec_sc_pkts_delayed;
408         u64 rx_macsec_sc_pkts_late;
409         u64 rx_macsec_sa_pkts_ok;
410         u64 rx_macsec_sa_pkts_invalid;
411         u64 rx_macsec_sa_pkts_notvalid;
412         u64 rx_macsec_sa_pkts_unusedsa;
413         u64 rx_macsec_sa_pkts_notusingsa;
414
415         /* MAC RxTx */
416         u64 rx_size_64_packets;
417         u64 rx_size_65_to_127_packets;
418         u64 rx_size_128_to_255_packets;
419         u64 rx_size_256_to_511_packets;
420         u64 rx_size_512_to_1023_packets;
421         u64 rx_size_1024_to_max_packets;
422         u64 tx_size_64_packets;
423         u64 tx_size_65_to_127_packets;
424         u64 tx_size_128_to_255_packets;
425         u64 tx_size_256_to_511_packets;
426         u64 tx_size_512_to_1023_packets;
427         u64 tx_size_1024_to_max_packets;
428
429         /* Flow Control */
430         u64 tx_xon_packets;
431         u64 rx_xon_packets;
432         u64 tx_xoff_packets;
433         u64 rx_xoff_packets;
434
435         /* PB[] RxTx */
436         struct {
437                 u64 rx_up_packets;
438                 u64 tx_up_packets;
439                 u64 rx_up_bytes;
440                 u64 tx_up_bytes;
441                 u64 rx_up_drop_packets;
442
443                 u64 tx_up_xon_packets;
444                 u64 rx_up_xon_packets;
445                 u64 tx_up_xoff_packets;
446                 u64 rx_up_xoff_packets;
447                 u64 rx_up_dropped;
448                 u64 rx_up_mbuf_alloc_errors;
449                 u64 tx_up_xon2off_packets;
450         } up[TXGBE_MAX_UP];
451
452         /* QP[] RxTx */
453         struct {
454                 u64 rx_qp_packets;
455                 u64 tx_qp_packets;
456                 u64 rx_qp_bytes;
457                 u64 tx_qp_bytes;
458                 u64 rx_qp_mc_packets;
459         } qp[TXGBE_MAX_QP];
460
461 };
462
463 /* iterator type for walking multicast address lists */
464 typedef u8* (*txgbe_mc_addr_itr) (struct txgbe_hw *hw, u8 **mc_addr_ptr,
465                                   u32 *vmdq);
466
467 struct txgbe_link_info {
468         s32 (*read_link)(struct txgbe_hw *hw, u8 addr, u16 reg, u16 *val);
469         s32 (*read_link_unlocked)(struct txgbe_hw *hw, u8 addr, u16 reg,
470                                   u16 *val);
471         s32 (*write_link)(struct txgbe_hw *hw, u8 addr, u16 reg, u16 val);
472         s32 (*write_link_unlocked)(struct txgbe_hw *hw, u8 addr, u16 reg,
473                                    u16 val);
474
475         u8 addr;
476 };
477
478 struct txgbe_rom_info {
479         s32 (*init_params)(struct txgbe_hw *hw);
480         s32 (*read16)(struct txgbe_hw *hw, u32 offset, u16 *data);
481         s32 (*readw_sw)(struct txgbe_hw *hw, u32 offset, u16 *data);
482         s32 (*readw_buffer)(struct txgbe_hw *hw, u32 offset, u32 words,
483                             void *data);
484         s32 (*read32)(struct txgbe_hw *hw, u32 addr, u32 *data);
485         s32 (*read_buffer)(struct txgbe_hw *hw, u32 addr, u32 len, void *data);
486         s32 (*write16)(struct txgbe_hw *hw, u32 offset, u16 data);
487         s32 (*writew_sw)(struct txgbe_hw *hw, u32 offset, u16 data);
488         s32 (*writew_buffer)(struct txgbe_hw *hw, u32 offset, u32 words,
489                              void *data);
490         s32 (*write32)(struct txgbe_hw *hw, u32 addr, u32 data);
491         s32 (*write_buffer)(struct txgbe_hw *hw, u32 addr, u32 len, void *data);
492         s32 (*validate_checksum)(struct txgbe_hw *hw, u16 *checksum_val);
493         s32 (*update_checksum)(struct txgbe_hw *hw);
494         s32 (*calc_checksum)(struct txgbe_hw *hw);
495
496         enum txgbe_eeprom_type type;
497         u32 semaphore_delay;
498         u16 word_size;
499         u16 address_bits;
500         u16 word_page_size;
501         u16 ctrl_word_3;
502
503         u32 sw_addr;
504 };
505
506 struct txgbe_flash_info {
507         u32 semaphore_delay;
508         u32 dword_size;
509         u16 address_bits;
510 };
511
512 #define TXGBE_FLAGS_DOUBLE_RESET_REQUIRED       0x01
513 struct txgbe_mac_info {
514         s32 (*init_hw)(struct txgbe_hw *hw);
515         s32 (*reset_hw)(struct txgbe_hw *hw);
516         s32 (*start_hw)(struct txgbe_hw *hw);
517         s32 (*stop_hw)(struct txgbe_hw *hw);
518         s32 (*clear_hw_cntrs)(struct txgbe_hw *hw);
519         s32 (*get_mac_addr)(struct txgbe_hw *hw, u8 *mac_addr);
520         s32 (*get_san_mac_addr)(struct txgbe_hw *hw, u8 *san_mac_addr);
521         s32 (*set_san_mac_addr)(struct txgbe_hw *hw, u8 *san_mac_addr);
522         s32 (*get_device_caps)(struct txgbe_hw *hw, u16 *device_caps);
523         s32 (*get_wwn_prefix)(struct txgbe_hw *hw, u16 *wwnn_prefix,
524                                  u16 *wwpn_prefix);
525         s32 (*setup_sfp)(struct txgbe_hw *hw);
526         s32 (*enable_rx_dma)(struct txgbe_hw *hw, u32 regval);
527         s32 (*disable_sec_rx_path)(struct txgbe_hw *hw);
528         s32 (*enable_sec_rx_path)(struct txgbe_hw *hw);
529         s32 (*disable_sec_tx_path)(struct txgbe_hw *hw);
530         s32 (*enable_sec_tx_path)(struct txgbe_hw *hw);
531         s32 (*acquire_swfw_sync)(struct txgbe_hw *hw, u32 mask);
532         void (*release_swfw_sync)(struct txgbe_hw *hw, u32 mask);
533         u64 (*autoc_read)(struct txgbe_hw *hw);
534         void (*autoc_write)(struct txgbe_hw *hw, u64 value);
535         s32 (*prot_autoc_read)(struct txgbe_hw *hw, bool *locked, u64 *value);
536         s32 (*prot_autoc_write)(struct txgbe_hw *hw, bool locked, u64 value);
537         s32 (*negotiate_api_version)(struct txgbe_hw *hw, int api);
538
539         /* Link */
540         void (*disable_tx_laser)(struct txgbe_hw *hw);
541         void (*enable_tx_laser)(struct txgbe_hw *hw);
542         void (*flap_tx_laser)(struct txgbe_hw *hw);
543         s32 (*setup_link)(struct txgbe_hw *hw, u32 speed,
544                                bool autoneg_wait_to_complete);
545         s32 (*setup_mac_link)(struct txgbe_hw *hw, u32 speed,
546                                bool autoneg_wait_to_complete);
547         s32 (*check_link)(struct txgbe_hw *hw, u32 *speed,
548                                bool *link_up, bool link_up_wait_to_complete);
549         s32 (*get_link_capabilities)(struct txgbe_hw *hw,
550                                       u32 *speed, bool *autoneg);
551         void (*set_rate_select_speed)(struct txgbe_hw *hw, u32 speed);
552
553         /* Packet Buffer manipulation */
554         void (*setup_pba)(struct txgbe_hw *hw, int num_pb, u32 headroom,
555                              int strategy);
556
557         /* LED */
558         s32 (*led_on)(struct txgbe_hw *hw, u32 index);
559         s32 (*led_off)(struct txgbe_hw *hw, u32 index);
560
561         /* RAR, Multicast, VLAN */
562         s32 (*set_rar)(struct txgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
563                           u32 enable_addr);
564         s32 (*set_uc_addr)(struct txgbe_hw *hw, u32 index, u8 *addr);
565         s32 (*clear_rar)(struct txgbe_hw *hw, u32 index);
566         s32 (*set_vmdq)(struct txgbe_hw *hw, u32 rar, u32 vmdq);
567         s32 (*clear_vmdq)(struct txgbe_hw *hw, u32 rar, u32 vmdq);
568         s32 (*init_rx_addrs)(struct txgbe_hw *hw);
569         s32 (*update_mc_addr_list)(struct txgbe_hw *hw, u8 *mc_addr_list,
570                                       u32 mc_addr_count,
571                                       txgbe_mc_addr_itr func, bool clear);
572         s32 (*clear_vfta)(struct txgbe_hw *hw);
573         s32 (*set_vfta)(struct txgbe_hw *hw, u32 vlan,
574                          u32 vind, bool vlan_on, bool vlvf_bypass);
575         s32 (*set_vlvf)(struct txgbe_hw *hw, u32 vlan, u32 vind,
576                            bool vlan_on, u32 *vfta_delta, u32 vfta,
577                            bool vlvf_bypass);
578         s32 (*init_uta_tables)(struct txgbe_hw *hw);
579         void (*set_mac_anti_spoofing)(struct txgbe_hw *hw, bool enable, int vf);
580         void (*set_vlan_anti_spoofing)(struct txgbe_hw *hw,
581                                         bool enable, int vf);
582         s32 (*update_xcast_mode)(struct txgbe_hw *hw, int xcast_mode);
583         s32 (*set_rlpml)(struct txgbe_hw *hw, u16 max_size);
584
585         /* Flow Control */
586         s32 (*fc_enable)(struct txgbe_hw *hw);
587         s32 (*setup_fc)(struct txgbe_hw *hw);
588         void (*fc_autoneg)(struct txgbe_hw *hw);
589
590         /* Manageability interface */
591         s32 (*set_fw_drv_ver)(struct txgbe_hw *hw, u8 maj, u8 min, u8 build,
592                          u8 ver, u16 len, const char *driver_ver);
593         s32 (*get_thermal_sensor_data)(struct txgbe_hw *hw);
594         s32 (*init_thermal_sensor_thresh)(struct txgbe_hw *hw);
595         void (*get_rtrup2tc)(struct txgbe_hw *hw, u8 *map);
596         void (*disable_rx)(struct txgbe_hw *hw);
597         void (*enable_rx)(struct txgbe_hw *hw);
598         void (*set_ethertype_anti_spoofing)(struct txgbe_hw *hw,
599                                                 bool enable, int vf);
600         s32 (*dmac_update_tcs)(struct txgbe_hw *hw);
601         s32 (*dmac_config_tcs)(struct txgbe_hw *hw);
602         s32 (*dmac_config)(struct txgbe_hw *hw);
603         s32 (*setup_eee)(struct txgbe_hw *hw, bool enable_eee);
604
605         s32 (*kr_handle)(struct txgbe_hw *hw);
606         void (*bp_down_event)(struct txgbe_hw *hw);
607
608         enum txgbe_mac_type type;
609         u8 addr[ETH_ADDR_LEN];
610         u8 perm_addr[ETH_ADDR_LEN];
611         u8 san_addr[ETH_ADDR_LEN];
612         /* prefix for World Wide Node Name (WWNN) */
613         u16 wwnn_prefix;
614         /* prefix for World Wide Port Name (WWPN) */
615         u16 wwpn_prefix;
616 #define TXGBE_MAX_MTA                   128
617         u32 mta_shadow[TXGBE_MAX_MTA];
618         s32 mc_filter_type;
619         u32 mcft_size;
620         u32 vft_size;
621         u32 num_rar_entries;
622         u32 rx_pb_size;
623         u32 max_tx_queues;
624         u32 max_rx_queues;
625         u64 autoc;
626         u64 orig_autoc;  /* cached value of AUTOC */
627         u8  san_mac_rar_index;
628         bool get_link_status;
629         bool orig_link_settings_stored;
630         bool autotry_restart;
631         u8 flags;
632         struct txgbe_thermal_sensor_data  thermal_sensor_data;
633         bool set_lben;
634         u32  max_link_up_time;
635 };
636
637 struct txgbe_phy_info {
638         u32 (*get_media_type)(struct txgbe_hw *hw);
639         s32 (*identify)(struct txgbe_hw *hw);
640         s32 (*identify_sfp)(struct txgbe_hw *hw);
641         s32 (*init)(struct txgbe_hw *hw);
642         s32 (*reset)(struct txgbe_hw *hw);
643         s32 (*read_reg)(struct txgbe_hw *hw, u32 reg_addr,
644                                 u32 device_type, u16 *phy_data);
645         s32 (*write_reg)(struct txgbe_hw *hw, u32 reg_addr,
646                                 u32 device_type, u16 phy_data);
647         s32 (*read_reg_mdi)(struct txgbe_hw *hw, u32 reg_addr,
648                                 u32 device_type, u16 *phy_data);
649         s32 (*write_reg_mdi)(struct txgbe_hw *hw, u32 reg_addr,
650                                 u32 device_type, u16 phy_data);
651         s32 (*setup_link)(struct txgbe_hw *hw);
652         s32 (*setup_internal_link)(struct txgbe_hw *hw);
653         s32 (*setup_link_speed)(struct txgbe_hw *hw, u32 speed,
654                                 bool autoneg_wait_to_complete);
655         s32 (*check_link)(struct txgbe_hw *hw, u32 *speed, bool *link_up);
656         s32 (*get_fw_version)(struct txgbe_hw *hw, u32 *fw_version);
657         s32 (*read_i2c_byte)(struct txgbe_hw *hw, u8 byte_offset,
658                                 u8 dev_addr, u8 *data);
659         s32 (*write_i2c_byte)(struct txgbe_hw *hw, u8 byte_offset,
660                                 u8 dev_addr, u8 data);
661         s32 (*read_i2c_sff8472)(struct txgbe_hw *hw, u8 byte_offset,
662                                 u8 *sff8472_data);
663         s32 (*read_i2c_eeprom)(struct txgbe_hw *hw, u8 byte_offset,
664                                 u8 *eeprom_data);
665         s32 (*write_i2c_eeprom)(struct txgbe_hw *hw, u8 byte_offset,
666                                 u8 eeprom_data);
667         s32 (*check_overtemp)(struct txgbe_hw *hw);
668         s32 (*set_phy_power)(struct txgbe_hw *hw, bool on);
669         s32 (*handle_lasi)(struct txgbe_hw *hw);
670         s32 (*read_i2c_byte_unlocked)(struct txgbe_hw *hw, u8 offset, u8 addr,
671                                       u8 *value);
672         s32 (*write_i2c_byte_unlocked)(struct txgbe_hw *hw, u8 offset, u8 addr,
673                                        u8 value);
674
675         enum txgbe_phy_type type;
676         u32 addr;
677         u32 id;
678         enum txgbe_sfp_type sfp_type;
679         bool sfp_setup_needed;
680         u32 revision;
681         u32 media_type;
682         u32 phy_semaphore_mask;
683         bool reset_disable;
684         u32 autoneg_advertised;
685         u32 speeds_supported;
686         enum txgbe_smart_speed smart_speed;
687         bool smart_speed_active;
688         bool multispeed_fiber;
689         bool qsfp_shared_i2c_bus;
690         u32 nw_mng_if_sel;
691         u32 link_mode;
692
693         /* Some features need tri-state capability */
694         u16 ffe_set;
695         u16 ffe_main;
696         u16 ffe_pre;
697         u16 ffe_post;
698 };
699
700 #define TXGBE_DEVARG_BP_AUTO            "auto_neg"
701 #define TXGBE_DEVARG_KR_POLL            "poll"
702 #define TXGBE_DEVARG_KR_PRESENT         "present"
703 #define TXGBE_DEVARG_KX_SGMII           "sgmii"
704 #define TXGBE_DEVARG_FFE_SET            "ffe_set"
705 #define TXGBE_DEVARG_FFE_MAIN           "ffe_main"
706 #define TXGBE_DEVARG_FFE_PRE            "ffe_pre"
707 #define TXGBE_DEVARG_FFE_POST           "ffe_post"
708
709 static const char * const txgbe_valid_arguments[] = {
710         TXGBE_DEVARG_BP_AUTO,
711         TXGBE_DEVARG_KR_POLL,
712         TXGBE_DEVARG_KR_PRESENT,
713         TXGBE_DEVARG_KX_SGMII,
714         TXGBE_DEVARG_FFE_SET,
715         TXGBE_DEVARG_FFE_MAIN,
716         TXGBE_DEVARG_FFE_PRE,
717         TXGBE_DEVARG_FFE_POST,
718         NULL
719 };
720
721 struct txgbe_mbx_stats {
722         u32 msgs_tx;
723         u32 msgs_rx;
724
725         u32 acks;
726         u32 reqs;
727         u32 rsts;
728 };
729
730 struct txgbe_mbx_info {
731         void (*init_params)(struct txgbe_hw *hw);
732         s32  (*read)(struct txgbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
733         s32  (*write)(struct txgbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
734         s32  (*read_posted)(struct txgbe_hw *hw, u32 *msg, u16 size,
735                                 u16 mbx_id);
736         s32  (*write_posted)(struct txgbe_hw *hw, u32 *msg, u16 size,
737                                 u16 mbx_id);
738         s32  (*check_for_msg)(struct txgbe_hw *hw, u16 mbx_id);
739         s32  (*check_for_ack)(struct txgbe_hw *hw, u16 mbx_id);
740         s32  (*check_for_rst)(struct txgbe_hw *hw, u16 mbx_id);
741
742         struct txgbe_mbx_stats stats;
743         u32 timeout;
744         u32 usec_delay;
745         u32 v2p_mailbox;
746         u16 size;
747 };
748
749 enum txgbe_isb_idx {
750         TXGBE_ISB_HEADER,
751         TXGBE_ISB_MISC,
752         TXGBE_ISB_VEC0,
753         TXGBE_ISB_VEC1,
754         TXGBE_ISB_MAX
755 };
756
757 struct txgbe_devargs {
758         u16 auto_neg;
759         u16 poll;
760         u16 present;
761         u16 sgmii;
762 };
763
764 struct txgbe_hw {
765         void IOMEM *hw_addr;
766         void *back;
767         struct txgbe_mac_info mac;
768         struct txgbe_addr_filter_info addr_ctrl;
769         struct txgbe_fc_info fc;
770         struct txgbe_phy_info phy;
771         struct txgbe_link_info link;
772         struct txgbe_rom_info rom;
773         struct txgbe_flash_info flash;
774         struct txgbe_bus_info bus;
775         struct txgbe_mbx_info mbx;
776         u16 device_id;
777         u16 vendor_id;
778         u16 subsystem_device_id;
779         u16 subsystem_vendor_id;
780         u8 revision_id;
781         bool adapter_stopped;
782         int api_version;
783         bool allow_unsupported_sfp;
784         bool need_crosstalk_fix;
785         bool dev_start;
786         struct txgbe_devargs devarg;
787
788         uint64_t isb_dma;
789         void IOMEM *isb_mem;
790         u16 nb_rx_queues;
791         u16 nb_tx_queues;
792
793         u32 fw_version;
794         u32 mode;
795         enum txgbe_link_status {
796                 TXGBE_LINK_STATUS_NONE = 0,
797                 TXGBE_LINK_STATUS_KX,
798                 TXGBE_LINK_STATUS_KX4
799         } link_status;
800         enum txgbe_reset_type {
801                 TXGBE_LAN_RESET = 0,
802                 TXGBE_SW_RESET,
803                 TXGBE_GLOBAL_RESET
804         } reset_type;
805
806         u32 q_rx_regs[128 * 4];
807         u32 q_tx_regs[128 * 4];
808         bool offset_loaded;
809         bool rx_loaded;
810         struct {
811                 u64 rx_qp_packets;
812                 u64 tx_qp_packets;
813                 u64 rx_qp_bytes;
814                 u64 tx_qp_bytes;
815                 u64 rx_qp_mc_packets;
816         } qp_last[TXGBE_MAX_QP];
817 };
818
819 struct txgbe_backplane_ability {
820         u32 next_page;    /* Next Page (bit0) */
821         u32 link_ability; /* Link Ability (bit[7:0]) */
822         u32 fec_ability;  /* FEC Request (bit1), FEC Enable (bit0) */
823         u32 current_link_mode; /* current link mode for local device */
824 };
825
826 #include "txgbe_regs.h"
827 #include "txgbe_dummy.h"
828
829 #endif /* _TXGBE_TYPE_H_ */