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 */
66 enum ngbe_media_type {
67 ngbe_media_type_unknown = 0,
68 ngbe_media_type_fiber,
69 ngbe_media_type_fiber_qsfp,
70 ngbe_media_type_copper,
71 ngbe_media_type_backplane,
73 ngbe_media_type_virtual
76 /* Flow Control Settings */
87 struct ngbe_addr_filter_info {
93 struct ngbe_bus_info {
94 void (*set_lan_id)(struct ngbe_hw *hw);
100 /* Flow control parameters */
101 struct ngbe_fc_info {
102 u32 high_water; /* Flow Ctrl High-water */
103 u32 low_water; /* Flow Ctrl Low-water */
104 u16 pause_time; /* Flow Control Pause timer */
105 bool send_xon; /* Flow control send XON */
106 bool strict_ieee; /* Strict IEEE mode */
107 bool disable_fc_autoneg; /* Do not autonegotiate FC */
108 bool fc_was_autonegged; /* Is current_mode the result of autonegging? */
109 enum ngbe_fc_mode current_mode; /* FC mode in effect */
110 enum ngbe_fc_mode requested_mode; /* FC mode requested by caller */
113 /* Statistics counters collected by the MAC */
115 struct ngbe_pb_stats {
116 u64 tx_pb_xon_packets;
117 u64 rx_pb_xon_packets;
118 u64 tx_pb_xoff_packets;
119 u64 rx_pb_xoff_packets;
121 u64 rx_pb_mbuf_alloc_errors;
122 u64 tx_pb_xon2off_packets;
126 struct ngbe_qp_stats {
131 u64 rx_qp_mc_packets;
134 struct ngbe_hw_stats {
136 u64 mng_bmc2host_packets;
137 u64 mng_host2bmc_packets;
142 u64 tx_secdrp_packets;
148 u64 rx_total_packets;
149 u64 tx_total_packets;
150 u64 rx_total_missed_packets;
151 u64 rx_broadcast_packets;
152 u64 tx_broadcast_packets;
153 u64 rx_multicast_packets;
154 u64 tx_multicast_packets;
155 u64 rx_management_packets;
156 u64 tx_management_packets;
157 u64 rx_management_dropped;
161 u64 rx_illegal_byte_errors;
163 u64 rx_mac_short_packet_dropped;
164 u64 rx_length_errors;
165 u64 rx_undersize_errors;
166 u64 rx_fragment_errors;
167 u64 rx_oversize_errors;
168 u64 rx_jabber_errors;
169 u64 rx_l3_l4_xsum_error;
170 u64 mac_local_errors;
171 u64 mac_remote_errors;
174 u64 tx_macsec_pkts_untagged;
175 u64 tx_macsec_pkts_encrypted;
176 u64 tx_macsec_pkts_protected;
177 u64 tx_macsec_octets_encrypted;
178 u64 tx_macsec_octets_protected;
179 u64 rx_macsec_pkts_untagged;
180 u64 rx_macsec_pkts_badtag;
181 u64 rx_macsec_pkts_nosci;
182 u64 rx_macsec_pkts_unknownsci;
183 u64 rx_macsec_octets_decrypted;
184 u64 rx_macsec_octets_validated;
185 u64 rx_macsec_sc_pkts_unchecked;
186 u64 rx_macsec_sc_pkts_delayed;
187 u64 rx_macsec_sc_pkts_late;
188 u64 rx_macsec_sa_pkts_ok;
189 u64 rx_macsec_sa_pkts_invalid;
190 u64 rx_macsec_sa_pkts_notvalid;
191 u64 rx_macsec_sa_pkts_unusedsa;
192 u64 rx_macsec_sa_pkts_notusingsa;
195 u64 rx_size_64_packets;
196 u64 rx_size_65_to_127_packets;
197 u64 rx_size_128_to_255_packets;
198 u64 rx_size_256_to_511_packets;
199 u64 rx_size_512_to_1023_packets;
200 u64 rx_size_1024_to_max_packets;
201 u64 tx_size_64_packets;
202 u64 tx_size_65_to_127_packets;
203 u64 tx_size_128_to_255_packets;
204 u64 tx_size_256_to_511_packets;
205 u64 tx_size_512_to_1023_packets;
206 u64 tx_size_1024_to_max_packets;
226 u64 rx_qp_mc_packets;
227 u64 tx_qp_mc_packets;
228 u64 rx_qp_bc_packets;
229 u64 tx_qp_bc_packets;
234 /* iterator type for walking multicast address lists */
235 typedef u8* (*ngbe_mc_addr_itr) (struct ngbe_hw *hw, u8 **mc_addr_ptr,
238 struct ngbe_rom_info {
239 s32 (*init_params)(struct ngbe_hw *hw);
240 s32 (*readw_buffer)(struct ngbe_hw *hw, u32 offset, u32 words,
242 s32 (*read32)(struct ngbe_hw *hw, u32 addr, u32 *data);
243 s32 (*writew_buffer)(struct ngbe_hw *hw, u32 offset, u32 words,
245 s32 (*validate_checksum)(struct ngbe_hw *hw, u16 *checksum_val);
247 enum ngbe_eeprom_type type;
257 struct ngbe_mac_info {
258 s32 (*init_hw)(struct ngbe_hw *hw);
259 s32 (*reset_hw)(struct ngbe_hw *hw);
260 s32 (*start_hw)(struct ngbe_hw *hw);
261 s32 (*stop_hw)(struct ngbe_hw *hw);
262 s32 (*clear_hw_cntrs)(struct ngbe_hw *hw);
263 s32 (*get_mac_addr)(struct ngbe_hw *hw, u8 *mac_addr);
264 s32 (*enable_rx_dma)(struct ngbe_hw *hw, u32 regval);
265 s32 (*disable_sec_rx_path)(struct ngbe_hw *hw);
266 s32 (*enable_sec_rx_path)(struct ngbe_hw *hw);
267 s32 (*acquire_swfw_sync)(struct ngbe_hw *hw, u32 mask);
268 void (*release_swfw_sync)(struct ngbe_hw *hw, u32 mask);
271 s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
272 bool autoneg_wait_to_complete);
273 s32 (*check_link)(struct ngbe_hw *hw, u32 *speed,
274 bool *link_up, bool link_up_wait_to_complete);
275 s32 (*get_link_capabilities)(struct ngbe_hw *hw,
276 u32 *speed, bool *autoneg);
278 /* Packet Buffer manipulation */
279 void (*setup_pba)(struct ngbe_hw *hw);
282 s32 (*led_on)(struct ngbe_hw *hw, u32 index);
283 s32 (*led_off)(struct ngbe_hw *hw, u32 index);
286 s32 (*set_rar)(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
288 s32 (*clear_rar)(struct ngbe_hw *hw, u32 index);
289 s32 (*set_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
290 s32 (*clear_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
291 s32 (*init_rx_addrs)(struct ngbe_hw *hw);
292 s32 (*update_mc_addr_list)(struct ngbe_hw *hw, u8 *mc_addr_list,
294 ngbe_mc_addr_itr func, bool clear);
295 s32 (*clear_vfta)(struct ngbe_hw *hw);
296 s32 (*set_vfta)(struct ngbe_hw *hw, u32 vlan,
297 u32 vind, bool vlan_on, bool vlvf_bypass);
298 s32 (*set_vlvf)(struct ngbe_hw *hw, u32 vlan, u32 vind,
299 bool vlan_on, u32 *vfta_delta, u32 vfta,
301 void (*set_mac_anti_spoofing)(struct ngbe_hw *hw, bool enable, int vf);
302 void (*set_vlan_anti_spoofing)(struct ngbe_hw *hw,
303 bool enable, int vf);
306 s32 (*fc_enable)(struct ngbe_hw *hw);
307 s32 (*setup_fc)(struct ngbe_hw *hw);
308 void (*fc_autoneg)(struct ngbe_hw *hw);
310 /* Manageability interface */
311 s32 (*init_thermal_sensor_thresh)(struct ngbe_hw *hw);
312 s32 (*check_overtemp)(struct ngbe_hw *hw);
314 enum ngbe_mac_type type;
315 u8 addr[ETH_ADDR_LEN];
316 u8 perm_addr[ETH_ADDR_LEN];
317 #define NGBE_MAX_MTA 128
318 u32 mta_shadow[NGBE_MAX_MTA];
326 bool get_link_status;
327 struct ngbe_thermal_sensor_data thermal_sensor_data;
329 u32 max_link_up_time;
335 struct ngbe_phy_info {
336 s32 (*identify)(struct ngbe_hw *hw);
337 s32 (*init_hw)(struct ngbe_hw *hw);
338 s32 (*reset_hw)(struct ngbe_hw *hw);
339 s32 (*read_reg)(struct ngbe_hw *hw, u32 reg_addr,
340 u32 device_type, u16 *phy_data);
341 s32 (*write_reg)(struct ngbe_hw *hw, u32 reg_addr,
342 u32 device_type, u16 phy_data);
343 s32 (*read_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
344 u32 device_type, u16 *phy_data);
345 s32 (*write_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
346 u32 device_type, u16 phy_data);
347 s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
348 bool autoneg_wait_to_complete);
349 s32 (*check_link)(struct ngbe_hw *hw, u32 *speed, bool *link_up);
350 s32 (*set_phy_power)(struct ngbe_hw *hw, bool on);
351 s32 (*get_adv_pause)(struct ngbe_hw *hw, u8 *pause_bit);
352 s32 (*get_lp_adv_pause)(struct ngbe_hw *hw, u8 *pause_bit);
353 s32 (*set_pause_adv)(struct ngbe_hw *hw, u16 pause_bit);
355 enum ngbe_media_type media_type;
356 enum ngbe_phy_type type;
360 u32 phy_semaphore_mask;
362 u32 autoneg_advertised;
365 struct ngbe_mbx_stats {
374 struct ngbe_mbx_info {
375 void (*init_params)(struct ngbe_hw *hw);
376 s32 (*read)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
377 s32 (*write)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
378 s32 (*check_for_msg)(struct ngbe_hw *hw, u16 mbx_id);
379 s32 (*check_for_ack)(struct ngbe_hw *hw, u16 mbx_id);
380 s32 (*check_for_rst)(struct ngbe_hw *hw, u16 mbx_id);
382 struct ngbe_mbx_stats stats;
399 struct ngbe_mac_info mac;
400 struct ngbe_addr_filter_info addr_ctrl;
401 struct ngbe_fc_info fc;
402 struct ngbe_phy_info phy;
403 struct ngbe_rom_info rom;
404 struct ngbe_bus_info bus;
405 struct ngbe_mbx_info mbx;
412 bool adapter_stopped;
421 u32 q_rx_regs[8 * 4];
422 u32 q_tx_regs[8 * 4];
430 u64 rx_qp_mc_packets;
431 u64 tx_qp_mc_packets;
432 u64 rx_qp_bc_packets;
433 u64 tx_qp_bc_packets;
434 } qp_last[NGBE_MAX_QP];
437 #include "ngbe_regs.h"
438 #include "ngbe_dummy.h"
440 #endif /* _NGBE_TYPE_H_ */