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_PBRXSIZE_MAX 0x00080000 /* 512KB Packet Buffer */
15 #define NGBE_PBTXSIZE_MAX 0x00005000 /* 20KB Packet Buffer */
16 #define NGBE_TXPKT_SIZE_MAX 0xA /* Max Tx Packet size */
17 #define NGBE_MAX_QP (8)
18 #define NGBE_MAX_UTA 128
20 #define NGBE_PCI_MASTER_DISABLE_TIMEOUT 800
23 #define NGBE_ALIGN 128 /* as intel did */
24 #define NGBE_ISB_SIZE 16
26 #include "ngbe_status.h"
27 #include "ngbe_osdep.h"
28 #include "ngbe_devids.h"
30 struct ngbe_thermal_diode_data {
36 struct ngbe_thermal_sensor_data {
37 struct ngbe_thermal_diode_data sensor[1];
40 enum ngbe_eeprom_type {
41 ngbe_eeprom_unknown = 0,
44 ngbe_eeprom_none /* No NVM support */
48 ngbe_link_type_unknown = 0,
72 enum ngbe_media_type {
73 ngbe_media_type_unknown = 0,
74 ngbe_media_type_fiber,
75 ngbe_media_type_fiber_qsfp,
76 ngbe_media_type_copper,
77 ngbe_media_type_backplane,
79 ngbe_media_type_virtual
82 /* Flow Control Settings */
93 struct ngbe_addr_filter_info {
99 struct ngbe_bus_info {
100 void (*set_lan_id)(struct ngbe_hw *hw);
106 /* Flow control parameters */
107 struct ngbe_fc_info {
108 u32 high_water; /* Flow Ctrl High-water */
109 u32 low_water; /* Flow Ctrl Low-water */
110 u16 pause_time; /* Flow Control Pause timer */
111 bool send_xon; /* Flow control send XON */
112 bool strict_ieee; /* Strict IEEE mode */
113 bool disable_fc_autoneg; /* Do not autonegotiate FC */
114 bool fc_was_autonegged; /* Is current_mode the result of autonegging? */
115 enum ngbe_fc_mode current_mode; /* FC mode in effect */
116 enum ngbe_fc_mode requested_mode; /* FC mode requested by caller */
119 /* Statistics counters collected by the MAC */
121 struct ngbe_pb_stats {
122 u64 tx_pb_xon_packets;
123 u64 rx_pb_xon_packets;
124 u64 tx_pb_xoff_packets;
125 u64 rx_pb_xoff_packets;
127 u64 rx_pb_mbuf_alloc_errors;
128 u64 tx_pb_xon2off_packets;
132 struct ngbe_qp_stats {
137 u64 rx_qp_mc_packets;
140 struct ngbe_hw_stats {
142 u64 mng_bmc2host_packets;
143 u64 mng_host2bmc_packets;
148 u64 tx_secdrp_packets;
154 u64 rx_total_packets;
155 u64 tx_total_packets;
156 u64 rx_total_missed_packets;
157 u64 rx_broadcast_packets;
158 u64 tx_broadcast_packets;
159 u64 rx_multicast_packets;
160 u64 tx_multicast_packets;
161 u64 rx_management_packets;
162 u64 tx_management_packets;
163 u64 rx_management_dropped;
167 u64 rx_illegal_byte_errors;
169 u64 rx_mac_short_packet_dropped;
170 u64 rx_length_errors;
171 u64 rx_undersize_errors;
172 u64 rx_fragment_errors;
173 u64 rx_oversize_errors;
174 u64 rx_jabber_errors;
175 u64 rx_l3_l4_xsum_error;
176 u64 mac_local_errors;
177 u64 mac_remote_errors;
180 u64 tx_macsec_pkts_untagged;
181 u64 tx_macsec_pkts_encrypted;
182 u64 tx_macsec_pkts_protected;
183 u64 tx_macsec_octets_encrypted;
184 u64 tx_macsec_octets_protected;
185 u64 rx_macsec_pkts_untagged;
186 u64 rx_macsec_pkts_badtag;
187 u64 rx_macsec_pkts_nosci;
188 u64 rx_macsec_pkts_unknownsci;
189 u64 rx_macsec_octets_decrypted;
190 u64 rx_macsec_octets_validated;
191 u64 rx_macsec_sc_pkts_unchecked;
192 u64 rx_macsec_sc_pkts_delayed;
193 u64 rx_macsec_sc_pkts_late;
194 u64 rx_macsec_sa_pkts_ok;
195 u64 rx_macsec_sa_pkts_invalid;
196 u64 rx_macsec_sa_pkts_notvalid;
197 u64 rx_macsec_sa_pkts_unusedsa;
198 u64 rx_macsec_sa_pkts_notusingsa;
201 u64 rx_size_64_packets;
202 u64 rx_size_65_to_127_packets;
203 u64 rx_size_128_to_255_packets;
204 u64 rx_size_256_to_511_packets;
205 u64 rx_size_512_to_1023_packets;
206 u64 rx_size_1024_to_max_packets;
207 u64 tx_size_64_packets;
208 u64 tx_size_65_to_127_packets;
209 u64 tx_size_128_to_255_packets;
210 u64 tx_size_256_to_511_packets;
211 u64 tx_size_512_to_1023_packets;
212 u64 tx_size_1024_to_max_packets;
232 u64 rx_qp_mc_packets;
233 u64 tx_qp_mc_packets;
234 u64 rx_qp_bc_packets;
235 u64 tx_qp_bc_packets;
240 /* iterator type for walking multicast address lists */
241 typedef u8* (*ngbe_mc_addr_itr) (struct ngbe_hw *hw, u8 **mc_addr_ptr,
244 struct ngbe_rom_info {
245 s32 (*init_params)(struct ngbe_hw *hw);
246 s32 (*readw_buffer)(struct ngbe_hw *hw, u32 offset, u32 words,
248 s32 (*read32)(struct ngbe_hw *hw, u32 addr, u32 *data);
249 s32 (*writew_buffer)(struct ngbe_hw *hw, u32 offset, u32 words,
251 s32 (*validate_checksum)(struct ngbe_hw *hw, u16 *checksum_val);
253 enum ngbe_eeprom_type type;
263 struct ngbe_mac_info {
264 s32 (*init_hw)(struct ngbe_hw *hw);
265 s32 (*reset_hw)(struct ngbe_hw *hw);
266 s32 (*start_hw)(struct ngbe_hw *hw);
267 s32 (*stop_hw)(struct ngbe_hw *hw);
268 s32 (*clear_hw_cntrs)(struct ngbe_hw *hw);
269 s32 (*get_mac_addr)(struct ngbe_hw *hw, u8 *mac_addr);
270 s32 (*enable_rx_dma)(struct ngbe_hw *hw, u32 regval);
271 s32 (*disable_sec_rx_path)(struct ngbe_hw *hw);
272 s32 (*enable_sec_rx_path)(struct ngbe_hw *hw);
273 s32 (*acquire_swfw_sync)(struct ngbe_hw *hw, u32 mask);
274 void (*release_swfw_sync)(struct ngbe_hw *hw, u32 mask);
277 s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
278 bool autoneg_wait_to_complete);
279 s32 (*check_link)(struct ngbe_hw *hw, u32 *speed,
280 bool *link_up, bool link_up_wait_to_complete);
281 s32 (*get_link_capabilities)(struct ngbe_hw *hw,
282 u32 *speed, bool *autoneg);
284 /* Packet Buffer manipulation */
285 void (*setup_pba)(struct ngbe_hw *hw);
288 s32 (*led_on)(struct ngbe_hw *hw, u32 index);
289 s32 (*led_off)(struct ngbe_hw *hw, u32 index);
292 s32 (*set_rar)(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
294 s32 (*clear_rar)(struct ngbe_hw *hw, u32 index);
295 s32 (*set_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
296 s32 (*clear_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
297 s32 (*init_rx_addrs)(struct ngbe_hw *hw);
298 s32 (*update_mc_addr_list)(struct ngbe_hw *hw, u8 *mc_addr_list,
300 ngbe_mc_addr_itr func, bool clear);
301 s32 (*clear_vfta)(struct ngbe_hw *hw);
302 s32 (*set_vfta)(struct ngbe_hw *hw, u32 vlan,
303 u32 vind, bool vlan_on, bool vlvf_bypass);
304 s32 (*set_vlvf)(struct ngbe_hw *hw, u32 vlan, u32 vind,
305 bool vlan_on, u32 *vfta_delta, u32 vfta,
307 void (*set_mac_anti_spoofing)(struct ngbe_hw *hw, bool enable, int vf);
308 void (*set_vlan_anti_spoofing)(struct ngbe_hw *hw,
309 bool enable, int vf);
312 s32 (*fc_enable)(struct ngbe_hw *hw);
313 s32 (*setup_fc)(struct ngbe_hw *hw);
314 void (*fc_autoneg)(struct ngbe_hw *hw);
316 /* Manageability interface */
317 s32 (*init_thermal_sensor_thresh)(struct ngbe_hw *hw);
318 s32 (*check_overtemp)(struct ngbe_hw *hw);
320 enum ngbe_mac_type type;
321 enum ngbe_link_type link_type;
322 u8 addr[ETH_ADDR_LEN];
323 u8 perm_addr[ETH_ADDR_LEN];
324 #define NGBE_MAX_MTA 128
325 u32 mta_shadow[NGBE_MAX_MTA];
333 bool get_link_status;
334 struct ngbe_thermal_sensor_data thermal_sensor_data;
336 u32 max_link_up_time;
342 struct ngbe_phy_info {
343 s32 (*identify)(struct ngbe_hw *hw);
344 s32 (*init_hw)(struct ngbe_hw *hw);
345 s32 (*reset_hw)(struct ngbe_hw *hw);
346 s32 (*read_reg)(struct ngbe_hw *hw, u32 reg_addr,
347 u32 device_type, u16 *phy_data);
348 s32 (*write_reg)(struct ngbe_hw *hw, u32 reg_addr,
349 u32 device_type, u16 phy_data);
350 s32 (*read_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
351 u32 device_type, u16 *phy_data);
352 s32 (*write_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
353 u32 device_type, u16 phy_data);
354 s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
355 bool autoneg_wait_to_complete);
356 s32 (*check_link)(struct ngbe_hw *hw, u32 *speed, bool *link_up);
357 s32 (*set_phy_power)(struct ngbe_hw *hw, bool on);
358 s32 (*get_adv_pause)(struct ngbe_hw *hw, u8 *pause_bit);
359 s32 (*get_lp_adv_pause)(struct ngbe_hw *hw, u8 *pause_bit);
360 s32 (*set_pause_adv)(struct ngbe_hw *hw, u16 pause_bit);
362 enum ngbe_media_type media_type;
363 enum ngbe_phy_type type;
367 u32 phy_semaphore_mask;
369 u32 autoneg_advertised;
372 struct ngbe_mbx_stats {
381 struct ngbe_mbx_info {
382 void (*init_params)(struct ngbe_hw *hw);
383 s32 (*read)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
384 s32 (*write)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
385 s32 (*check_for_msg)(struct ngbe_hw *hw, u16 mbx_id);
386 s32 (*check_for_ack)(struct ngbe_hw *hw, u16 mbx_id);
387 s32 (*check_for_rst)(struct ngbe_hw *hw, u16 mbx_id);
389 struct ngbe_mbx_stats stats;
406 struct ngbe_mac_info mac;
407 struct ngbe_addr_filter_info addr_ctrl;
408 struct ngbe_fc_info fc;
409 struct ngbe_phy_info phy;
410 struct ngbe_rom_info rom;
411 struct ngbe_bus_info bus;
412 struct ngbe_mbx_info mbx;
419 bool adapter_stopped;
428 u32 q_rx_regs[8 * 4];
429 u32 q_tx_regs[8 * 4];
438 u64 rx_qp_mc_packets;
439 u64 tx_qp_mc_packets;
440 u64 rx_qp_bc_packets;
441 u64 tx_qp_bc_packets;
442 } qp_last[NGBE_MAX_QP];
445 #include "ngbe_regs.h"
446 #include "ngbe_dummy.h"
448 #endif /* _NGBE_TYPE_H_ */