net/txgbe: add HW infrastructure and dummy function
[dpdk.git] / drivers / net / txgbe / base / txgbe_type.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020
3  */
4
5 #ifndef _TXGBE_TYPE_H_
6 #define _TXGBE_TYPE_H_
7
8 #define TXGBE_LINK_UP_TIME      90 /* 9.0 Seconds */
9
10 #define TXGBE_ALIGN                             128 /* as intel did */
11
12 #include "txgbe_status.h"
13 #include "txgbe_osdep.h"
14 #include "txgbe_devids.h"
15
16 enum txgbe_mac_type {
17         txgbe_mac_unknown = 0,
18         txgbe_mac_raptor,
19         txgbe_mac_raptor_vf,
20         txgbe_num_macs
21 };
22
23 enum txgbe_phy_type {
24         txgbe_phy_unknown = 0,
25         txgbe_phy_none,
26         txgbe_phy_tn,
27         txgbe_phy_aq,
28         txgbe_phy_ext_1g_t,
29         txgbe_phy_cu_mtd,
30         txgbe_phy_cu_unknown,
31         txgbe_phy_qt,
32         txgbe_phy_xaui,
33         txgbe_phy_nl,
34         txgbe_phy_sfp_tyco_passive,
35         txgbe_phy_sfp_unknown_passive,
36         txgbe_phy_sfp_unknown_active,
37         txgbe_phy_sfp_avago,
38         txgbe_phy_sfp_ftl,
39         txgbe_phy_sfp_ftl_active,
40         txgbe_phy_sfp_unknown,
41         txgbe_phy_sfp_intel,
42         txgbe_phy_qsfp_unknown_passive,
43         txgbe_phy_qsfp_unknown_active,
44         txgbe_phy_qsfp_intel,
45         txgbe_phy_qsfp_unknown,
46         txgbe_phy_sfp_unsupported, /* Enforce bit set with unsupported module */
47         txgbe_phy_sgmii,
48         txgbe_phy_fw,
49         txgbe_phy_generic
50 };
51
52 /*
53  * SFP+ module type IDs:
54  *
55  * ID   Module Type
56  * =============
57  * 0    SFP_DA_CU
58  * 1    SFP_SR
59  * 2    SFP_LR
60  * 3    SFP_DA_CU_CORE0 - chip-specific
61  * 4    SFP_DA_CU_CORE1 - chip-specific
62  * 5    SFP_SR/LR_CORE0 - chip-specific
63  * 6    SFP_SR/LR_CORE1 - chip-specific
64  */
65 enum txgbe_sfp_type {
66         txgbe_sfp_type_unknown = 0,
67         txgbe_sfp_type_da_cu,
68         txgbe_sfp_type_sr,
69         txgbe_sfp_type_lr,
70         txgbe_sfp_type_da_cu_core0,
71         txgbe_sfp_type_da_cu_core1,
72         txgbe_sfp_type_srlr_core0,
73         txgbe_sfp_type_srlr_core1,
74         txgbe_sfp_type_da_act_lmt_core0,
75         txgbe_sfp_type_da_act_lmt_core1,
76         txgbe_sfp_type_1g_cu_core0,
77         txgbe_sfp_type_1g_cu_core1,
78         txgbe_sfp_type_1g_sx_core0,
79         txgbe_sfp_type_1g_sx_core1,
80         txgbe_sfp_type_1g_lx_core0,
81         txgbe_sfp_type_1g_lx_core1,
82         txgbe_sfp_type_not_present = 0xFFFE,
83         txgbe_sfp_type_not_known = 0xFFFF
84 };
85
86 enum txgbe_media_type {
87         txgbe_media_type_unknown = 0,
88         txgbe_media_type_fiber,
89         txgbe_media_type_fiber_qsfp,
90         txgbe_media_type_copper,
91         txgbe_media_type_backplane,
92         txgbe_media_type_cx4,
93         txgbe_media_type_virtual
94 };
95
96 /* PCI bus types */
97 enum txgbe_bus_type {
98         txgbe_bus_type_unknown = 0,
99         txgbe_bus_type_pci,
100         txgbe_bus_type_pcix,
101         txgbe_bus_type_pci_express,
102         txgbe_bus_type_internal,
103         txgbe_bus_type_reserved
104 };
105
106 /* PCI bus speeds */
107 enum txgbe_bus_speed {
108         txgbe_bus_speed_unknown = 0,
109         txgbe_bus_speed_33      = 33,
110         txgbe_bus_speed_66      = 66,
111         txgbe_bus_speed_100     = 100,
112         txgbe_bus_speed_120     = 120,
113         txgbe_bus_speed_133     = 133,
114         txgbe_bus_speed_2500    = 2500,
115         txgbe_bus_speed_5000    = 5000,
116         txgbe_bus_speed_8000    = 8000,
117         txgbe_bus_speed_reserved
118 };
119
120 /* PCI bus widths */
121 enum txgbe_bus_width {
122         txgbe_bus_width_unknown = 0,
123         txgbe_bus_width_pcie_x1 = 1,
124         txgbe_bus_width_pcie_x2 = 2,
125         txgbe_bus_width_pcie_x4 = 4,
126         txgbe_bus_width_pcie_x8 = 8,
127         txgbe_bus_width_32      = 32,
128         txgbe_bus_width_64      = 64,
129         txgbe_bus_width_reserved
130 };
131
132 struct txgbe_hw;
133
134 /* Bus parameters */
135 struct txgbe_bus_info {
136         s32 (*get_bus_info)(struct txgbe_hw *hw);
137         void (*set_lan_id)(struct txgbe_hw *hw);
138
139         enum txgbe_bus_speed speed;
140         enum txgbe_bus_width width;
141         enum txgbe_bus_type type;
142
143         u16 func;
144         u8 lan_id;
145         u16 instance_id;
146 };
147
148 /* iterator type for walking multicast address lists */
149 typedef u8* (*txgbe_mc_addr_itr) (struct txgbe_hw *hw, u8 **mc_addr_ptr,
150                                   u32 *vmdq);
151
152 struct txgbe_link_info {
153         s32 (*read_link)(struct txgbe_hw *hw, u8 addr, u16 reg, u16 *val);
154         s32 (*read_link_unlocked)(struct txgbe_hw *hw, u8 addr, u16 reg,
155                                   u16 *val);
156         s32 (*write_link)(struct txgbe_hw *hw, u8 addr, u16 reg, u16 val);
157         s32 (*write_link_unlocked)(struct txgbe_hw *hw, u8 addr, u16 reg,
158                                    u16 val);
159
160         u8 addr;
161 };
162
163 struct txgbe_rom_info {
164         s32 (*init_params)(struct txgbe_hw *hw);
165         s32 (*read16)(struct txgbe_hw *hw, u32 offset, u16 *data);
166         s32 (*readw_sw)(struct txgbe_hw *hw, u32 offset, u16 *data);
167         s32 (*readw_buffer)(struct txgbe_hw *hw, u32 offset, u32 words,
168                             void *data);
169         s32 (*read32)(struct txgbe_hw *hw, u32 addr, u32 *data);
170         s32 (*read_buffer)(struct txgbe_hw *hw, u32 addr, u32 len, void *data);
171         s32 (*write16)(struct txgbe_hw *hw, u32 offset, u16 data);
172         s32 (*writew_sw)(struct txgbe_hw *hw, u32 offset, u16 data);
173         s32 (*writew_buffer)(struct txgbe_hw *hw, u32 offset, u32 words,
174                              void *data);
175         s32 (*write32)(struct txgbe_hw *hw, u32 addr, u32 data);
176         s32 (*write_buffer)(struct txgbe_hw *hw, u32 addr, u32 len, void *data);
177         s32 (*validate_checksum)(struct txgbe_hw *hw, u16 *checksum_val);
178         s32 (*update_checksum)(struct txgbe_hw *hw);
179         s32 (*calc_checksum)(struct txgbe_hw *hw);
180 };
181
182 struct txgbe_flash_info {
183         u32 semaphore_delay;
184         u32 dword_size;
185         u16 address_bits;
186 };
187
188 struct txgbe_mac_info {
189         s32 (*init_hw)(struct txgbe_hw *hw);
190         s32 (*reset_hw)(struct txgbe_hw *hw);
191         s32 (*start_hw)(struct txgbe_hw *hw);
192         s32 (*stop_hw)(struct txgbe_hw *hw);
193         s32 (*clear_hw_cntrs)(struct txgbe_hw *hw);
194         s32 (*get_mac_addr)(struct txgbe_hw *hw, u8 *mac_addr);
195         s32 (*get_san_mac_addr)(struct txgbe_hw *hw, u8 *san_mac_addr);
196         s32 (*set_san_mac_addr)(struct txgbe_hw *hw, u8 *san_mac_addr);
197         s32 (*get_device_caps)(struct txgbe_hw *hw, u16 *device_caps);
198         s32 (*get_wwn_prefix)(struct txgbe_hw *hw, u16 *wwnn_prefix,
199                                  u16 *wwpn_prefix);
200         s32 (*setup_sfp)(struct txgbe_hw *hw);
201         s32 (*enable_rx_dma)(struct txgbe_hw *hw, u32 regval);
202         s32 (*disable_sec_rx_path)(struct txgbe_hw *hw);
203         s32 (*enable_sec_rx_path)(struct txgbe_hw *hw);
204         s32 (*disable_sec_tx_path)(struct txgbe_hw *hw);
205         s32 (*enable_sec_tx_path)(struct txgbe_hw *hw);
206         s32 (*acquire_swfw_sync)(struct txgbe_hw *hw, u32 mask);
207         void (*release_swfw_sync)(struct txgbe_hw *hw, u32 mask);
208         u64 (*autoc_read)(struct txgbe_hw *hw);
209         void (*autoc_write)(struct txgbe_hw *hw, u64 value);
210         s32 (*prot_autoc_read)(struct txgbe_hw *hw, bool *locked, u64 *value);
211         s32 (*prot_autoc_write)(struct txgbe_hw *hw, bool locked, u64 value);
212         s32 (*negotiate_api_version)(struct txgbe_hw *hw, int api);
213
214         /* Link */
215         void (*disable_tx_laser)(struct txgbe_hw *hw);
216         void (*enable_tx_laser)(struct txgbe_hw *hw);
217         void (*flap_tx_laser)(struct txgbe_hw *hw);
218         s32 (*setup_link)(struct txgbe_hw *hw, u32 speed,
219                                bool autoneg_wait_to_complete);
220         s32 (*setup_mac_link)(struct txgbe_hw *hw, u32 speed,
221                                bool autoneg_wait_to_complete);
222         s32 (*check_link)(struct txgbe_hw *hw, u32 *speed,
223                                bool *link_up, bool link_up_wait_to_complete);
224         s32 (*get_link_capabilities)(struct txgbe_hw *hw,
225                                       u32 *speed, bool *autoneg);
226         void (*set_rate_select_speed)(struct txgbe_hw *hw, u32 speed);
227
228         /* Packet Buffer manipulation */
229         void (*setup_pba)(struct txgbe_hw *hw, int num_pb, u32 headroom,
230                              int strategy);
231
232         /* LED */
233         s32 (*led_on)(struct txgbe_hw *hw, u32 index);
234         s32 (*led_off)(struct txgbe_hw *hw, u32 index);
235
236         /* RAR, Multicast, VLAN */
237         s32 (*set_rar)(struct txgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
238                           u32 enable_addr);
239         s32 (*set_uc_addr)(struct txgbe_hw *hw, u32 index, u8 *addr);
240         s32 (*clear_rar)(struct txgbe_hw *hw, u32 index);
241         s32 (*set_vmdq)(struct txgbe_hw *hw, u32 rar, u32 vmdq);
242         s32 (*clear_vmdq)(struct txgbe_hw *hw, u32 rar, u32 vmdq);
243         s32 (*init_rx_addrs)(struct txgbe_hw *hw);
244         s32 (*update_mc_addr_list)(struct txgbe_hw *hw, u8 *mc_addr_list,
245                                       u32 mc_addr_count,
246                                       txgbe_mc_addr_itr func, bool clear);
247         s32 (*clear_vfta)(struct txgbe_hw *hw);
248         s32 (*set_vfta)(struct txgbe_hw *hw, u32 vlan,
249                          u32 vind, bool vlan_on, bool vlvf_bypass);
250         s32 (*set_vlvf)(struct txgbe_hw *hw, u32 vlan, u32 vind,
251                            bool vlan_on, u32 *vfta_delta, u32 vfta,
252                            bool vlvf_bypass);
253         s32 (*init_uta_tables)(struct txgbe_hw *hw);
254         void (*set_mac_anti_spoofing)(struct txgbe_hw *hw, bool enable, int vf);
255         void (*set_vlan_anti_spoofing)(struct txgbe_hw *hw,
256                                         bool enable, int vf);
257         s32 (*update_xcast_mode)(struct txgbe_hw *hw, int xcast_mode);
258         s32 (*set_rlpml)(struct txgbe_hw *hw, u16 max_size);
259
260         /* Flow Control */
261         s32 (*fc_enable)(struct txgbe_hw *hw);
262         s32 (*setup_fc)(struct txgbe_hw *hw);
263         void (*fc_autoneg)(struct txgbe_hw *hw);
264
265         /* Manageability interface */
266         s32 (*set_fw_drv_ver)(struct txgbe_hw *hw, u8 maj, u8 min, u8 build,
267                          u8 ver, u16 len, char *driver_ver);
268         s32 (*get_thermal_sensor_data)(struct txgbe_hw *hw);
269         s32 (*init_thermal_sensor_thresh)(struct txgbe_hw *hw);
270         void (*get_rtrup2tc)(struct txgbe_hw *hw, u8 *map);
271         void (*disable_rx)(struct txgbe_hw *hw);
272         void (*enable_rx)(struct txgbe_hw *hw);
273         void (*set_ethertype_anti_spoofing)(struct txgbe_hw *hw,
274                                                 bool enable, int vf);
275         s32 (*dmac_update_tcs)(struct txgbe_hw *hw);
276         s32 (*dmac_config_tcs)(struct txgbe_hw *hw);
277         s32 (*dmac_config)(struct txgbe_hw *hw);
278         s32 (*setup_eee)(struct txgbe_hw *hw, bool enable_eee);
279
280         enum txgbe_mac_type type;
281         u8 perm_addr[ETH_ADDR_LEN];
282         u32 num_rar_entries;
283         u32  max_link_up_time;
284 };
285
286 struct txgbe_phy_info {
287         u32 (*get_media_type)(struct txgbe_hw *hw);
288         s32 (*identify)(struct txgbe_hw *hw);
289         s32 (*identify_sfp)(struct txgbe_hw *hw);
290         s32 (*init)(struct txgbe_hw *hw);
291         s32 (*reset)(struct txgbe_hw *hw);
292         s32 (*read_reg)(struct txgbe_hw *hw, u32 reg_addr,
293                                 u32 device_type, u16 *phy_data);
294         s32 (*write_reg)(struct txgbe_hw *hw, u32 reg_addr,
295                                 u32 device_type, u16 phy_data);
296         s32 (*read_reg_mdi)(struct txgbe_hw *hw, u32 reg_addr,
297                                 u32 device_type, u16 *phy_data);
298         s32 (*write_reg_mdi)(struct txgbe_hw *hw, u32 reg_addr,
299                                 u32 device_type, u16 phy_data);
300         s32 (*setup_link)(struct txgbe_hw *hw);
301         s32 (*setup_internal_link)(struct txgbe_hw *hw);
302         s32 (*setup_link_speed)(struct txgbe_hw *hw, u32 speed,
303                                 bool autoneg_wait_to_complete);
304         s32 (*check_link)(struct txgbe_hw *hw, u32 *speed, bool *link_up);
305         s32 (*read_i2c_byte)(struct txgbe_hw *hw, u8 byte_offset,
306                                 u8 dev_addr, u8 *data);
307         s32 (*write_i2c_byte)(struct txgbe_hw *hw, u8 byte_offset,
308                                 u8 dev_addr, u8 data);
309         s32 (*read_i2c_sff8472)(struct txgbe_hw *hw, u8 byte_offset,
310                                 u8 *sff8472_data);
311         s32 (*read_i2c_eeprom)(struct txgbe_hw *hw, u8 byte_offset,
312                                 u8 *eeprom_data);
313         s32 (*write_i2c_eeprom)(struct txgbe_hw *hw, u8 byte_offset,
314                                 u8 eeprom_data);
315         s32 (*check_overtemp)(struct txgbe_hw *hw);
316         s32 (*set_phy_power)(struct txgbe_hw *hw, bool on);
317         s32 (*handle_lasi)(struct txgbe_hw *hw);
318         s32 (*read_i2c_byte_unlocked)(struct txgbe_hw *hw, u8 offset, u8 addr,
319                                       u8 *value);
320         s32 (*write_i2c_byte_unlocked)(struct txgbe_hw *hw, u8 offset, u8 addr,
321                                        u8 value);
322
323         enum txgbe_phy_type type;
324         enum txgbe_sfp_type sfp_type;
325         u32 media_type;
326 };
327
328 struct txgbe_mbx_info {
329         void (*init_params)(struct txgbe_hw *hw);
330         s32  (*read)(struct txgbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
331         s32  (*write)(struct txgbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
332         s32  (*read_posted)(struct txgbe_hw *hw, u32 *msg, u16 size,
333                                 u16 mbx_id);
334         s32  (*write_posted)(struct txgbe_hw *hw, u32 *msg, u16 size,
335                                 u16 mbx_id);
336         s32  (*check_for_msg)(struct txgbe_hw *hw, u16 mbx_id);
337         s32  (*check_for_ack)(struct txgbe_hw *hw, u16 mbx_id);
338         s32  (*check_for_rst)(struct txgbe_hw *hw, u16 mbx_id);
339 };
340
341 struct txgbe_hw {
342         void IOMEM *hw_addr;
343         void *back;
344         struct txgbe_mac_info mac;
345         struct txgbe_phy_info phy;
346         struct txgbe_link_info link;
347         struct txgbe_rom_info rom;
348         struct txgbe_flash_info flash;
349         struct txgbe_bus_info bus;
350         struct txgbe_mbx_info mbx;
351         u16 device_id;
352         u16 vendor_id;
353         u16 subsystem_device_id;
354         u16 subsystem_vendor_id;
355
356         bool allow_unsupported_sfp;
357
358         uint64_t isb_dma;
359         void IOMEM *isb_mem;
360 };
361
362 #include "txgbe_regs.h"
363 #include "txgbe_dummy.h"
364
365 #endif /* _TXGBE_TYPE_H_ */