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