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