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