472c0c1bea1fb5372af2ad4f72f1dd6e5dd3d8fa
[dpdk.git] / drivers / net / ngbe / base / ngbe_type.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd.
3  * Copyright(c) 2010-2017 Intel Corporation
4  */
5
6 #ifndef _NGBE_TYPE_H_
7 #define _NGBE_TYPE_H_
8
9 #define NGBE_LINK_UP_TIME       90 /* 9.0 Seconds */
10
11 #define NGBE_FRAME_SIZE_DFT       (1522) /* Default frame size, +FCS */
12
13 #define NGBE_ALIGN              128 /* as intel did */
14 #define NGBE_ISB_SIZE           16
15
16 #include "ngbe_status.h"
17 #include "ngbe_osdep.h"
18 #include "ngbe_devids.h"
19
20 struct ngbe_thermal_diode_data {
21         s16 temp;
22         s16 alarm_thresh;
23         s16 dalarm_thresh;
24 };
25
26 struct ngbe_thermal_sensor_data {
27         struct ngbe_thermal_diode_data sensor[1];
28 };
29
30 enum ngbe_eeprom_type {
31         ngbe_eeprom_unknown = 0,
32         ngbe_eeprom_spi,
33         ngbe_eeprom_flash,
34         ngbe_eeprom_none /* No NVM support */
35 };
36
37 enum ngbe_mac_type {
38         ngbe_mac_unknown = 0,
39         ngbe_mac_em,
40         ngbe_mac_em_vf,
41         ngbe_num_macs
42 };
43
44 enum ngbe_phy_type {
45         ngbe_phy_unknown = 0,
46         ngbe_phy_none,
47         ngbe_phy_rtl,
48         ngbe_phy_mvl,
49         ngbe_phy_mvl_sfi,
50         ngbe_phy_yt8521s,
51         ngbe_phy_yt8521s_sfi,
52         ngbe_phy_zte,
53         ngbe_phy_cu_mtd,
54 };
55
56 enum ngbe_media_type {
57         ngbe_media_type_unknown = 0,
58         ngbe_media_type_fiber,
59         ngbe_media_type_fiber_qsfp,
60         ngbe_media_type_copper,
61         ngbe_media_type_backplane,
62         ngbe_media_type_cx4,
63         ngbe_media_type_virtual
64 };
65
66 struct ngbe_hw;
67
68 struct ngbe_addr_filter_info {
69         u32 mta_in_use;
70 };
71
72 /* Bus parameters */
73 struct ngbe_bus_info {
74         void (*set_lan_id)(struct ngbe_hw *hw);
75
76         u16 func;
77         u8 lan_id;
78 };
79
80 struct ngbe_rom_info {
81         s32 (*init_params)(struct ngbe_hw *hw);
82         s32 (*validate_checksum)(struct ngbe_hw *hw, u16 *checksum_val);
83
84         enum ngbe_eeprom_type type;
85         u32 semaphore_delay;
86         u16 word_size;
87         u16 address_bits;
88         u16 word_page_size;
89         u32 sw_addr;
90         u32 saved_version;
91         u16 cksum_devcap;
92 };
93
94 struct ngbe_mac_info {
95         s32 (*init_hw)(struct ngbe_hw *hw);
96         s32 (*reset_hw)(struct ngbe_hw *hw);
97         s32 (*stop_hw)(struct ngbe_hw *hw);
98         s32 (*get_mac_addr)(struct ngbe_hw *hw, u8 *mac_addr);
99         s32 (*acquire_swfw_sync)(struct ngbe_hw *hw, u32 mask);
100         void (*release_swfw_sync)(struct ngbe_hw *hw, u32 mask);
101
102         s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
103                                bool autoneg_wait_to_complete);
104         s32 (*check_link)(struct ngbe_hw *hw, u32 *speed,
105                                bool *link_up, bool link_up_wait_to_complete);
106         /* RAR */
107         s32 (*set_rar)(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
108                           u32 enable_addr);
109         s32 (*clear_rar)(struct ngbe_hw *hw, u32 index);
110         s32 (*set_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
111         s32 (*clear_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
112         s32 (*init_rx_addrs)(struct ngbe_hw *hw);
113
114         /* Manageability interface */
115         s32 (*init_thermal_sensor_thresh)(struct ngbe_hw *hw);
116         s32 (*check_overtemp)(struct ngbe_hw *hw);
117
118         enum ngbe_mac_type type;
119         u8 addr[ETH_ADDR_LEN];
120         u8 perm_addr[ETH_ADDR_LEN];
121         s32 mc_filter_type;
122         u32 mcft_size;
123         u32 num_rar_entries;
124         u32 max_tx_queues;
125         u32 max_rx_queues;
126         bool get_link_status;
127         struct ngbe_thermal_sensor_data  thermal_sensor_data;
128         bool set_lben;
129         u32  max_link_up_time;
130
131         bool autoneg;
132 };
133
134 struct ngbe_phy_info {
135         s32 (*identify)(struct ngbe_hw *hw);
136         s32 (*reset_hw)(struct ngbe_hw *hw);
137         s32 (*read_reg)(struct ngbe_hw *hw, u32 reg_addr,
138                                 u32 device_type, u16 *phy_data);
139         s32 (*write_reg)(struct ngbe_hw *hw, u32 reg_addr,
140                                 u32 device_type, u16 phy_data);
141         s32 (*read_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
142                                 u32 device_type, u16 *phy_data);
143         s32 (*write_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
144                                 u32 device_type, u16 phy_data);
145         s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
146                                 bool autoneg_wait_to_complete);
147         s32 (*check_link)(struct ngbe_hw *hw, u32 *speed, bool *link_up);
148
149         enum ngbe_media_type media_type;
150         enum ngbe_phy_type type;
151         u32 addr;
152         u32 id;
153         u32 revision;
154         u32 phy_semaphore_mask;
155         bool reset_disable;
156         u32 autoneg_advertised;
157 };
158
159 enum ngbe_isb_idx {
160         NGBE_ISB_HEADER,
161         NGBE_ISB_MISC,
162         NGBE_ISB_VEC0,
163         NGBE_ISB_VEC1,
164         NGBE_ISB_MAX
165 };
166
167 struct ngbe_hw {
168         void IOMEM *hw_addr;
169         void *back;
170         struct ngbe_mac_info mac;
171         struct ngbe_addr_filter_info addr_ctrl;
172         struct ngbe_phy_info phy;
173         struct ngbe_rom_info rom;
174         struct ngbe_bus_info bus;
175         u16 device_id;
176         u16 vendor_id;
177         u16 sub_device_id;
178         u16 sub_system_id;
179         bool adapter_stopped;
180
181         uint64_t isb_dma;
182         void IOMEM *isb_mem;
183
184         bool is_pf;
185 };
186
187 #include "ngbe_regs.h"
188 #include "ngbe_dummy.h"
189
190 #endif /* _NGBE_TYPE_H_ */