1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd.
3 * Copyright(c) 2010-2017 Intel Corporation
9 #define NGBE_LINK_UP_TIME 90 /* 9.0 Seconds */
11 #define NGBE_FRAME_SIZE_MAX (9728) /* Maximum frame size, +FCS */
12 #define NGBE_FRAME_SIZE_DFT (1522) /* Default frame size, +FCS */
13 #define NGBE_NUM_POOL (32)
14 #define NGBE_MAX_QP (8)
15 #define NGBE_MAX_UTA 128
17 #define NGBE_ALIGN 128 /* as intel did */
18 #define NGBE_ISB_SIZE 16
20 #include "ngbe_status.h"
21 #include "ngbe_osdep.h"
22 #include "ngbe_devids.h"
24 struct ngbe_thermal_diode_data {
30 struct ngbe_thermal_sensor_data {
31 struct ngbe_thermal_diode_data sensor[1];
34 enum ngbe_eeprom_type {
35 ngbe_eeprom_unknown = 0,
38 ngbe_eeprom_none /* No NVM support */
60 enum ngbe_media_type {
61 ngbe_media_type_unknown = 0,
62 ngbe_media_type_fiber,
63 ngbe_media_type_fiber_qsfp,
64 ngbe_media_type_copper,
65 ngbe_media_type_backplane,
67 ngbe_media_type_virtual
70 /* Flow Control Settings */
81 struct ngbe_addr_filter_info {
87 struct ngbe_bus_info {
88 void (*set_lan_id)(struct ngbe_hw *hw);
94 /* Flow control parameters */
96 u32 high_water; /* Flow Ctrl High-water */
97 u32 low_water; /* Flow Ctrl Low-water */
98 u16 pause_time; /* Flow Control Pause timer */
99 bool send_xon; /* Flow control send XON */
100 bool strict_ieee; /* Strict IEEE mode */
101 bool disable_fc_autoneg; /* Do not autonegotiate FC */
102 bool fc_was_autonegged; /* Is current_mode the result of autonegging? */
103 enum ngbe_fc_mode current_mode; /* FC mode in effect */
104 enum ngbe_fc_mode requested_mode; /* FC mode requested by caller */
107 /* Statistics counters collected by the MAC */
109 struct ngbe_pb_stats {
110 u64 tx_pb_xon_packets;
111 u64 rx_pb_xon_packets;
112 u64 tx_pb_xoff_packets;
113 u64 rx_pb_xoff_packets;
115 u64 rx_pb_mbuf_alloc_errors;
116 u64 tx_pb_xon2off_packets;
120 struct ngbe_qp_stats {
125 u64 rx_qp_mc_packets;
128 struct ngbe_hw_stats {
130 u64 mng_bmc2host_packets;
131 u64 mng_host2bmc_packets;
136 u64 tx_secdrp_packets;
142 u64 rx_total_packets;
143 u64 tx_total_packets;
144 u64 rx_total_missed_packets;
145 u64 rx_broadcast_packets;
146 u64 tx_broadcast_packets;
147 u64 rx_multicast_packets;
148 u64 tx_multicast_packets;
149 u64 rx_management_packets;
150 u64 tx_management_packets;
151 u64 rx_management_dropped;
155 u64 rx_illegal_byte_errors;
157 u64 rx_mac_short_packet_dropped;
158 u64 rx_length_errors;
159 u64 rx_undersize_errors;
160 u64 rx_fragment_errors;
161 u64 rx_oversize_errors;
162 u64 rx_jabber_errors;
163 u64 rx_l3_l4_xsum_error;
164 u64 mac_local_errors;
165 u64 mac_remote_errors;
168 u64 tx_macsec_pkts_untagged;
169 u64 tx_macsec_pkts_encrypted;
170 u64 tx_macsec_pkts_protected;
171 u64 tx_macsec_octets_encrypted;
172 u64 tx_macsec_octets_protected;
173 u64 rx_macsec_pkts_untagged;
174 u64 rx_macsec_pkts_badtag;
175 u64 rx_macsec_pkts_nosci;
176 u64 rx_macsec_pkts_unknownsci;
177 u64 rx_macsec_octets_decrypted;
178 u64 rx_macsec_octets_validated;
179 u64 rx_macsec_sc_pkts_unchecked;
180 u64 rx_macsec_sc_pkts_delayed;
181 u64 rx_macsec_sc_pkts_late;
182 u64 rx_macsec_sa_pkts_ok;
183 u64 rx_macsec_sa_pkts_invalid;
184 u64 rx_macsec_sa_pkts_notvalid;
185 u64 rx_macsec_sa_pkts_unusedsa;
186 u64 rx_macsec_sa_pkts_notusingsa;
189 u64 rx_size_64_packets;
190 u64 rx_size_65_to_127_packets;
191 u64 rx_size_128_to_255_packets;
192 u64 rx_size_256_to_511_packets;
193 u64 rx_size_512_to_1023_packets;
194 u64 rx_size_1024_to_max_packets;
195 u64 tx_size_64_packets;
196 u64 tx_size_65_to_127_packets;
197 u64 tx_size_128_to_255_packets;
198 u64 tx_size_256_to_511_packets;
199 u64 tx_size_512_to_1023_packets;
200 u64 tx_size_1024_to_max_packets;
220 u64 rx_qp_mc_packets;
221 u64 tx_qp_mc_packets;
222 u64 rx_qp_bc_packets;
223 u64 tx_qp_bc_packets;
228 /* iterator type for walking multicast address lists */
229 typedef u8* (*ngbe_mc_addr_itr) (struct ngbe_hw *hw, u8 **mc_addr_ptr,
232 struct ngbe_rom_info {
233 s32 (*init_params)(struct ngbe_hw *hw);
234 s32 (*read32)(struct ngbe_hw *hw, u32 addr, u32 *data);
235 s32 (*validate_checksum)(struct ngbe_hw *hw, u16 *checksum_val);
237 enum ngbe_eeprom_type type;
247 struct ngbe_mac_info {
248 s32 (*init_hw)(struct ngbe_hw *hw);
249 s32 (*reset_hw)(struct ngbe_hw *hw);
250 s32 (*start_hw)(struct ngbe_hw *hw);
251 s32 (*stop_hw)(struct ngbe_hw *hw);
252 s32 (*clear_hw_cntrs)(struct ngbe_hw *hw);
253 s32 (*get_mac_addr)(struct ngbe_hw *hw, u8 *mac_addr);
254 s32 (*enable_rx_dma)(struct ngbe_hw *hw, u32 regval);
255 s32 (*disable_sec_rx_path)(struct ngbe_hw *hw);
256 s32 (*enable_sec_rx_path)(struct ngbe_hw *hw);
257 s32 (*acquire_swfw_sync)(struct ngbe_hw *hw, u32 mask);
258 void (*release_swfw_sync)(struct ngbe_hw *hw, u32 mask);
261 s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
262 bool autoneg_wait_to_complete);
263 s32 (*check_link)(struct ngbe_hw *hw, u32 *speed,
264 bool *link_up, bool link_up_wait_to_complete);
265 s32 (*get_link_capabilities)(struct ngbe_hw *hw,
266 u32 *speed, bool *autoneg);
269 s32 (*set_rar)(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
271 s32 (*clear_rar)(struct ngbe_hw *hw, u32 index);
272 s32 (*set_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
273 s32 (*clear_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
274 s32 (*init_rx_addrs)(struct ngbe_hw *hw);
275 s32 (*update_mc_addr_list)(struct ngbe_hw *hw, u8 *mc_addr_list,
277 ngbe_mc_addr_itr func, bool clear);
278 s32 (*clear_vfta)(struct ngbe_hw *hw);
279 s32 (*set_vfta)(struct ngbe_hw *hw, u32 vlan,
280 u32 vind, bool vlan_on, bool vlvf_bypass);
281 s32 (*set_vlvf)(struct ngbe_hw *hw, u32 vlan, u32 vind,
282 bool vlan_on, u32 *vfta_delta, u32 vfta,
284 void (*set_mac_anti_spoofing)(struct ngbe_hw *hw, bool enable, int vf);
285 void (*set_vlan_anti_spoofing)(struct ngbe_hw *hw,
286 bool enable, int vf);
289 s32 (*fc_enable)(struct ngbe_hw *hw);
290 s32 (*setup_fc)(struct ngbe_hw *hw);
291 void (*fc_autoneg)(struct ngbe_hw *hw);
293 /* Manageability interface */
294 s32 (*init_thermal_sensor_thresh)(struct ngbe_hw *hw);
295 s32 (*check_overtemp)(struct ngbe_hw *hw);
297 enum ngbe_mac_type type;
298 u8 addr[ETH_ADDR_LEN];
299 u8 perm_addr[ETH_ADDR_LEN];
300 #define NGBE_MAX_MTA 128
301 u32 mta_shadow[NGBE_MAX_MTA];
308 bool get_link_status;
309 struct ngbe_thermal_sensor_data thermal_sensor_data;
311 u32 max_link_up_time;
317 struct ngbe_phy_info {
318 s32 (*identify)(struct ngbe_hw *hw);
319 s32 (*init_hw)(struct ngbe_hw *hw);
320 s32 (*reset_hw)(struct ngbe_hw *hw);
321 s32 (*read_reg)(struct ngbe_hw *hw, u32 reg_addr,
322 u32 device_type, u16 *phy_data);
323 s32 (*write_reg)(struct ngbe_hw *hw, u32 reg_addr,
324 u32 device_type, u16 phy_data);
325 s32 (*read_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
326 u32 device_type, u16 *phy_data);
327 s32 (*write_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
328 u32 device_type, u16 phy_data);
329 s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
330 bool autoneg_wait_to_complete);
331 s32 (*check_link)(struct ngbe_hw *hw, u32 *speed, bool *link_up);
332 s32 (*set_phy_power)(struct ngbe_hw *hw, bool on);
333 s32 (*get_adv_pause)(struct ngbe_hw *hw, u8 *pause_bit);
334 s32 (*get_lp_adv_pause)(struct ngbe_hw *hw, u8 *pause_bit);
335 s32 (*set_pause_adv)(struct ngbe_hw *hw, u16 pause_bit);
337 enum ngbe_media_type media_type;
338 enum ngbe_phy_type type;
342 u32 phy_semaphore_mask;
344 u32 autoneg_advertised;
347 struct ngbe_mbx_stats {
356 struct ngbe_mbx_info {
357 void (*init_params)(struct ngbe_hw *hw);
358 s32 (*read)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
359 s32 (*write)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
360 s32 (*check_for_msg)(struct ngbe_hw *hw, u16 mbx_id);
361 s32 (*check_for_ack)(struct ngbe_hw *hw, u16 mbx_id);
362 s32 (*check_for_rst)(struct ngbe_hw *hw, u16 mbx_id);
364 struct ngbe_mbx_stats stats;
381 struct ngbe_mac_info mac;
382 struct ngbe_addr_filter_info addr_ctrl;
383 struct ngbe_fc_info fc;
384 struct ngbe_phy_info phy;
385 struct ngbe_rom_info rom;
386 struct ngbe_bus_info bus;
387 struct ngbe_mbx_info mbx;
393 bool adapter_stopped;
402 u32 q_rx_regs[8 * 4];
403 u32 q_tx_regs[8 * 4];
411 u64 rx_qp_mc_packets;
412 u64 tx_qp_mc_packets;
413 u64 rx_qp_bc_packets;
414 u64 tx_qp_bc_packets;
415 } qp_last[NGBE_MAX_QP];
418 #include "ngbe_regs.h"
419 #include "ngbe_dummy.h"
421 #endif /* _NGBE_TYPE_H_ */