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 (*readw_buffer)(struct ngbe_hw *hw, u32 offset, u32 words,
236 s32 (*read32)(struct ngbe_hw *hw, u32 addr, u32 *data);
237 s32 (*writew_buffer)(struct ngbe_hw *hw, u32 offset, u32 words,
239 s32 (*validate_checksum)(struct ngbe_hw *hw, u16 *checksum_val);
241 enum ngbe_eeprom_type type;
251 struct ngbe_mac_info {
252 s32 (*init_hw)(struct ngbe_hw *hw);
253 s32 (*reset_hw)(struct ngbe_hw *hw);
254 s32 (*start_hw)(struct ngbe_hw *hw);
255 s32 (*stop_hw)(struct ngbe_hw *hw);
256 s32 (*clear_hw_cntrs)(struct ngbe_hw *hw);
257 s32 (*get_mac_addr)(struct ngbe_hw *hw, u8 *mac_addr);
258 s32 (*enable_rx_dma)(struct ngbe_hw *hw, u32 regval);
259 s32 (*disable_sec_rx_path)(struct ngbe_hw *hw);
260 s32 (*enable_sec_rx_path)(struct ngbe_hw *hw);
261 s32 (*acquire_swfw_sync)(struct ngbe_hw *hw, u32 mask);
262 void (*release_swfw_sync)(struct ngbe_hw *hw, u32 mask);
265 s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
266 bool autoneg_wait_to_complete);
267 s32 (*check_link)(struct ngbe_hw *hw, u32 *speed,
268 bool *link_up, bool link_up_wait_to_complete);
269 s32 (*get_link_capabilities)(struct ngbe_hw *hw,
270 u32 *speed, bool *autoneg);
273 s32 (*led_on)(struct ngbe_hw *hw, u32 index);
274 s32 (*led_off)(struct ngbe_hw *hw, u32 index);
277 s32 (*set_rar)(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
279 s32 (*clear_rar)(struct ngbe_hw *hw, u32 index);
280 s32 (*set_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
281 s32 (*clear_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
282 s32 (*init_rx_addrs)(struct ngbe_hw *hw);
283 s32 (*update_mc_addr_list)(struct ngbe_hw *hw, u8 *mc_addr_list,
285 ngbe_mc_addr_itr func, bool clear);
286 s32 (*clear_vfta)(struct ngbe_hw *hw);
287 s32 (*set_vfta)(struct ngbe_hw *hw, u32 vlan,
288 u32 vind, bool vlan_on, bool vlvf_bypass);
289 s32 (*set_vlvf)(struct ngbe_hw *hw, u32 vlan, u32 vind,
290 bool vlan_on, u32 *vfta_delta, u32 vfta,
292 void (*set_mac_anti_spoofing)(struct ngbe_hw *hw, bool enable, int vf);
293 void (*set_vlan_anti_spoofing)(struct ngbe_hw *hw,
294 bool enable, int vf);
297 s32 (*fc_enable)(struct ngbe_hw *hw);
298 s32 (*setup_fc)(struct ngbe_hw *hw);
299 void (*fc_autoneg)(struct ngbe_hw *hw);
301 /* Manageability interface */
302 s32 (*init_thermal_sensor_thresh)(struct ngbe_hw *hw);
303 s32 (*check_overtemp)(struct ngbe_hw *hw);
305 enum ngbe_mac_type type;
306 u8 addr[ETH_ADDR_LEN];
307 u8 perm_addr[ETH_ADDR_LEN];
308 #define NGBE_MAX_MTA 128
309 u32 mta_shadow[NGBE_MAX_MTA];
316 bool get_link_status;
317 struct ngbe_thermal_sensor_data thermal_sensor_data;
319 u32 max_link_up_time;
325 struct ngbe_phy_info {
326 s32 (*identify)(struct ngbe_hw *hw);
327 s32 (*init_hw)(struct ngbe_hw *hw);
328 s32 (*reset_hw)(struct ngbe_hw *hw);
329 s32 (*read_reg)(struct ngbe_hw *hw, u32 reg_addr,
330 u32 device_type, u16 *phy_data);
331 s32 (*write_reg)(struct ngbe_hw *hw, u32 reg_addr,
332 u32 device_type, u16 phy_data);
333 s32 (*read_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
334 u32 device_type, u16 *phy_data);
335 s32 (*write_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
336 u32 device_type, u16 phy_data);
337 s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
338 bool autoneg_wait_to_complete);
339 s32 (*check_link)(struct ngbe_hw *hw, u32 *speed, bool *link_up);
340 s32 (*set_phy_power)(struct ngbe_hw *hw, bool on);
341 s32 (*get_adv_pause)(struct ngbe_hw *hw, u8 *pause_bit);
342 s32 (*get_lp_adv_pause)(struct ngbe_hw *hw, u8 *pause_bit);
343 s32 (*set_pause_adv)(struct ngbe_hw *hw, u16 pause_bit);
345 enum ngbe_media_type media_type;
346 enum ngbe_phy_type type;
350 u32 phy_semaphore_mask;
352 u32 autoneg_advertised;
355 struct ngbe_mbx_stats {
364 struct ngbe_mbx_info {
365 void (*init_params)(struct ngbe_hw *hw);
366 s32 (*read)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
367 s32 (*write)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
368 s32 (*check_for_msg)(struct ngbe_hw *hw, u16 mbx_id);
369 s32 (*check_for_ack)(struct ngbe_hw *hw, u16 mbx_id);
370 s32 (*check_for_rst)(struct ngbe_hw *hw, u16 mbx_id);
372 struct ngbe_mbx_stats stats;
389 struct ngbe_mac_info mac;
390 struct ngbe_addr_filter_info addr_ctrl;
391 struct ngbe_fc_info fc;
392 struct ngbe_phy_info phy;
393 struct ngbe_rom_info rom;
394 struct ngbe_bus_info bus;
395 struct ngbe_mbx_info mbx;
402 bool adapter_stopped;
411 u32 q_rx_regs[8 * 4];
412 u32 q_tx_regs[8 * 4];
420 u64 rx_qp_mc_packets;
421 u64 tx_qp_mc_packets;
422 u64 rx_qp_bc_packets;
423 u64 tx_qp_bc_packets;
424 } qp_last[NGBE_MAX_QP];
427 #include "ngbe_regs.h"
428 #include "ngbe_dummy.h"
430 #endif /* _NGBE_TYPE_H_ */