net/ngbe: support Rx queue start/stop
[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 (*start_hw)(struct ngbe_hw *hw);
98         s32 (*stop_hw)(struct ngbe_hw *hw);
99         s32 (*get_mac_addr)(struct ngbe_hw *hw, u8 *mac_addr);
100         s32 (*enable_rx_dma)(struct ngbe_hw *hw, u32 regval);
101         s32 (*disable_sec_rx_path)(struct ngbe_hw *hw);
102         s32 (*enable_sec_rx_path)(struct ngbe_hw *hw);
103         s32 (*acquire_swfw_sync)(struct ngbe_hw *hw, u32 mask);
104         void (*release_swfw_sync)(struct ngbe_hw *hw, u32 mask);
105
106         /* Link */
107         s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
108                                bool autoneg_wait_to_complete);
109         s32 (*check_link)(struct ngbe_hw *hw, u32 *speed,
110                                bool *link_up, bool link_up_wait_to_complete);
111         s32 (*get_link_capabilities)(struct ngbe_hw *hw,
112                                       u32 *speed, bool *autoneg);
113
114         /* RAR */
115         s32 (*set_rar)(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
116                           u32 enable_addr);
117         s32 (*clear_rar)(struct ngbe_hw *hw, u32 index);
118         s32 (*set_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
119         s32 (*clear_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
120         s32 (*init_rx_addrs)(struct ngbe_hw *hw);
121
122         /* Manageability interface */
123         s32 (*init_thermal_sensor_thresh)(struct ngbe_hw *hw);
124         s32 (*check_overtemp)(struct ngbe_hw *hw);
125
126         enum ngbe_mac_type type;
127         u8 addr[ETH_ADDR_LEN];
128         u8 perm_addr[ETH_ADDR_LEN];
129         s32 mc_filter_type;
130         u32 mcft_size;
131         u32 num_rar_entries;
132         u32 max_tx_queues;
133         u32 max_rx_queues;
134         bool get_link_status;
135         struct ngbe_thermal_sensor_data  thermal_sensor_data;
136         bool set_lben;
137         u32  max_link_up_time;
138
139         u32 default_speeds;
140         bool autoneg;
141 };
142
143 struct ngbe_phy_info {
144         s32 (*identify)(struct ngbe_hw *hw);
145         s32 (*init_hw)(struct ngbe_hw *hw);
146         s32 (*reset_hw)(struct ngbe_hw *hw);
147         s32 (*read_reg)(struct ngbe_hw *hw, u32 reg_addr,
148                                 u32 device_type, u16 *phy_data);
149         s32 (*write_reg)(struct ngbe_hw *hw, u32 reg_addr,
150                                 u32 device_type, u16 phy_data);
151         s32 (*read_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
152                                 u32 device_type, u16 *phy_data);
153         s32 (*write_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
154                                 u32 device_type, u16 phy_data);
155         s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
156                                 bool autoneg_wait_to_complete);
157         s32 (*check_link)(struct ngbe_hw *hw, u32 *speed, bool *link_up);
158
159         enum ngbe_media_type media_type;
160         enum ngbe_phy_type type;
161         u32 addr;
162         u32 id;
163         u32 revision;
164         u32 phy_semaphore_mask;
165         bool reset_disable;
166         u32 autoneg_advertised;
167 };
168
169 enum ngbe_isb_idx {
170         NGBE_ISB_HEADER,
171         NGBE_ISB_MISC,
172         NGBE_ISB_VEC0,
173         NGBE_ISB_VEC1,
174         NGBE_ISB_MAX
175 };
176
177 struct ngbe_hw {
178         void IOMEM *hw_addr;
179         void *back;
180         struct ngbe_mac_info mac;
181         struct ngbe_addr_filter_info addr_ctrl;
182         struct ngbe_phy_info phy;
183         struct ngbe_rom_info rom;
184         struct ngbe_bus_info bus;
185         u16 device_id;
186         u16 vendor_id;
187         u16 sub_device_id;
188         u16 sub_system_id;
189         bool adapter_stopped;
190
191         uint64_t isb_dma;
192         void IOMEM *isb_mem;
193         u16 nb_rx_queues;
194         u16 nb_tx_queues;
195
196         u32 q_rx_regs[8 * 4];
197         u32 q_tx_regs[8 * 4];
198         bool is_pf;
199 };
200
201 #include "ngbe_regs.h"
202 #include "ngbe_dummy.h"
203
204 #endif /* _NGBE_TYPE_H_ */