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_ALIGN 128 /* as intel did */
21 #define NGBE_ISB_SIZE 16
23 #include "ngbe_status.h"
24 #include "ngbe_osdep.h"
25 #include "ngbe_devids.h"
27 struct ngbe_thermal_diode_data {
33 struct ngbe_thermal_sensor_data {
34 struct ngbe_thermal_diode_data sensor[1];
37 enum ngbe_eeprom_type {
38 ngbe_eeprom_unknown = 0,
41 ngbe_eeprom_none /* No NVM support */
63 enum ngbe_media_type {
64 ngbe_media_type_unknown = 0,
65 ngbe_media_type_fiber,
66 ngbe_media_type_fiber_qsfp,
67 ngbe_media_type_copper,
68 ngbe_media_type_backplane,
70 ngbe_media_type_virtual
73 /* Flow Control Settings */
84 struct ngbe_addr_filter_info {
90 struct ngbe_bus_info {
91 void (*set_lan_id)(struct ngbe_hw *hw);
97 /* Flow control parameters */
99 u32 high_water; /* Flow Ctrl High-water */
100 u32 low_water; /* Flow Ctrl Low-water */
101 u16 pause_time; /* Flow Control Pause timer */
102 bool send_xon; /* Flow control send XON */
103 bool strict_ieee; /* Strict IEEE mode */
104 bool disable_fc_autoneg; /* Do not autonegotiate FC */
105 bool fc_was_autonegged; /* Is current_mode the result of autonegging? */
106 enum ngbe_fc_mode current_mode; /* FC mode in effect */
107 enum ngbe_fc_mode requested_mode; /* FC mode requested by caller */
110 /* Statistics counters collected by the MAC */
112 struct ngbe_pb_stats {
113 u64 tx_pb_xon_packets;
114 u64 rx_pb_xon_packets;
115 u64 tx_pb_xoff_packets;
116 u64 rx_pb_xoff_packets;
118 u64 rx_pb_mbuf_alloc_errors;
119 u64 tx_pb_xon2off_packets;
123 struct ngbe_qp_stats {
128 u64 rx_qp_mc_packets;
131 struct ngbe_hw_stats {
133 u64 mng_bmc2host_packets;
134 u64 mng_host2bmc_packets;
139 u64 tx_secdrp_packets;
145 u64 rx_total_packets;
146 u64 tx_total_packets;
147 u64 rx_total_missed_packets;
148 u64 rx_broadcast_packets;
149 u64 tx_broadcast_packets;
150 u64 rx_multicast_packets;
151 u64 tx_multicast_packets;
152 u64 rx_management_packets;
153 u64 tx_management_packets;
154 u64 rx_management_dropped;
158 u64 rx_illegal_byte_errors;
160 u64 rx_mac_short_packet_dropped;
161 u64 rx_length_errors;
162 u64 rx_undersize_errors;
163 u64 rx_fragment_errors;
164 u64 rx_oversize_errors;
165 u64 rx_jabber_errors;
166 u64 rx_l3_l4_xsum_error;
167 u64 mac_local_errors;
168 u64 mac_remote_errors;
171 u64 tx_macsec_pkts_untagged;
172 u64 tx_macsec_pkts_encrypted;
173 u64 tx_macsec_pkts_protected;
174 u64 tx_macsec_octets_encrypted;
175 u64 tx_macsec_octets_protected;
176 u64 rx_macsec_pkts_untagged;
177 u64 rx_macsec_pkts_badtag;
178 u64 rx_macsec_pkts_nosci;
179 u64 rx_macsec_pkts_unknownsci;
180 u64 rx_macsec_octets_decrypted;
181 u64 rx_macsec_octets_validated;
182 u64 rx_macsec_sc_pkts_unchecked;
183 u64 rx_macsec_sc_pkts_delayed;
184 u64 rx_macsec_sc_pkts_late;
185 u64 rx_macsec_sa_pkts_ok;
186 u64 rx_macsec_sa_pkts_invalid;
187 u64 rx_macsec_sa_pkts_notvalid;
188 u64 rx_macsec_sa_pkts_unusedsa;
189 u64 rx_macsec_sa_pkts_notusingsa;
192 u64 rx_size_64_packets;
193 u64 rx_size_65_to_127_packets;
194 u64 rx_size_128_to_255_packets;
195 u64 rx_size_256_to_511_packets;
196 u64 rx_size_512_to_1023_packets;
197 u64 rx_size_1024_to_max_packets;
198 u64 tx_size_64_packets;
199 u64 tx_size_65_to_127_packets;
200 u64 tx_size_128_to_255_packets;
201 u64 tx_size_256_to_511_packets;
202 u64 tx_size_512_to_1023_packets;
203 u64 tx_size_1024_to_max_packets;
223 u64 rx_qp_mc_packets;
224 u64 tx_qp_mc_packets;
225 u64 rx_qp_bc_packets;
226 u64 tx_qp_bc_packets;
231 /* iterator type for walking multicast address lists */
232 typedef u8* (*ngbe_mc_addr_itr) (struct ngbe_hw *hw, u8 **mc_addr_ptr,
235 struct ngbe_rom_info {
236 s32 (*init_params)(struct ngbe_hw *hw);
237 s32 (*readw_buffer)(struct ngbe_hw *hw, u32 offset, u32 words,
239 s32 (*read32)(struct ngbe_hw *hw, u32 addr, u32 *data);
240 s32 (*writew_buffer)(struct ngbe_hw *hw, u32 offset, u32 words,
242 s32 (*validate_checksum)(struct ngbe_hw *hw, u16 *checksum_val);
244 enum ngbe_eeprom_type type;
254 struct ngbe_mac_info {
255 s32 (*init_hw)(struct ngbe_hw *hw);
256 s32 (*reset_hw)(struct ngbe_hw *hw);
257 s32 (*start_hw)(struct ngbe_hw *hw);
258 s32 (*stop_hw)(struct ngbe_hw *hw);
259 s32 (*clear_hw_cntrs)(struct ngbe_hw *hw);
260 s32 (*get_mac_addr)(struct ngbe_hw *hw, u8 *mac_addr);
261 s32 (*enable_rx_dma)(struct ngbe_hw *hw, u32 regval);
262 s32 (*disable_sec_rx_path)(struct ngbe_hw *hw);
263 s32 (*enable_sec_rx_path)(struct ngbe_hw *hw);
264 s32 (*acquire_swfw_sync)(struct ngbe_hw *hw, u32 mask);
265 void (*release_swfw_sync)(struct ngbe_hw *hw, u32 mask);
268 s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
269 bool autoneg_wait_to_complete);
270 s32 (*check_link)(struct ngbe_hw *hw, u32 *speed,
271 bool *link_up, bool link_up_wait_to_complete);
272 s32 (*get_link_capabilities)(struct ngbe_hw *hw,
273 u32 *speed, bool *autoneg);
275 /* Packet Buffer manipulation */
276 void (*setup_pba)(struct ngbe_hw *hw);
279 s32 (*led_on)(struct ngbe_hw *hw, u32 index);
280 s32 (*led_off)(struct ngbe_hw *hw, u32 index);
283 s32 (*set_rar)(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
285 s32 (*clear_rar)(struct ngbe_hw *hw, u32 index);
286 s32 (*set_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
287 s32 (*clear_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
288 s32 (*init_rx_addrs)(struct ngbe_hw *hw);
289 s32 (*update_mc_addr_list)(struct ngbe_hw *hw, u8 *mc_addr_list,
291 ngbe_mc_addr_itr func, bool clear);
292 s32 (*clear_vfta)(struct ngbe_hw *hw);
293 s32 (*set_vfta)(struct ngbe_hw *hw, u32 vlan,
294 u32 vind, bool vlan_on, bool vlvf_bypass);
295 s32 (*set_vlvf)(struct ngbe_hw *hw, u32 vlan, u32 vind,
296 bool vlan_on, u32 *vfta_delta, u32 vfta,
298 void (*set_mac_anti_spoofing)(struct ngbe_hw *hw, bool enable, int vf);
299 void (*set_vlan_anti_spoofing)(struct ngbe_hw *hw,
300 bool enable, int vf);
303 s32 (*fc_enable)(struct ngbe_hw *hw);
304 s32 (*setup_fc)(struct ngbe_hw *hw);
305 void (*fc_autoneg)(struct ngbe_hw *hw);
307 /* Manageability interface */
308 s32 (*init_thermal_sensor_thresh)(struct ngbe_hw *hw);
309 s32 (*check_overtemp)(struct ngbe_hw *hw);
311 enum ngbe_mac_type type;
312 u8 addr[ETH_ADDR_LEN];
313 u8 perm_addr[ETH_ADDR_LEN];
314 #define NGBE_MAX_MTA 128
315 u32 mta_shadow[NGBE_MAX_MTA];
323 bool get_link_status;
324 struct ngbe_thermal_sensor_data thermal_sensor_data;
326 u32 max_link_up_time;
332 struct ngbe_phy_info {
333 s32 (*identify)(struct ngbe_hw *hw);
334 s32 (*init_hw)(struct ngbe_hw *hw);
335 s32 (*reset_hw)(struct ngbe_hw *hw);
336 s32 (*read_reg)(struct ngbe_hw *hw, u32 reg_addr,
337 u32 device_type, u16 *phy_data);
338 s32 (*write_reg)(struct ngbe_hw *hw, u32 reg_addr,
339 u32 device_type, u16 phy_data);
340 s32 (*read_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
341 u32 device_type, u16 *phy_data);
342 s32 (*write_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
343 u32 device_type, u16 phy_data);
344 s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
345 bool autoneg_wait_to_complete);
346 s32 (*check_link)(struct ngbe_hw *hw, u32 *speed, bool *link_up);
347 s32 (*set_phy_power)(struct ngbe_hw *hw, bool on);
348 s32 (*get_adv_pause)(struct ngbe_hw *hw, u8 *pause_bit);
349 s32 (*get_lp_adv_pause)(struct ngbe_hw *hw, u8 *pause_bit);
350 s32 (*set_pause_adv)(struct ngbe_hw *hw, u16 pause_bit);
352 enum ngbe_media_type media_type;
353 enum ngbe_phy_type type;
357 u32 phy_semaphore_mask;
359 u32 autoneg_advertised;
362 struct ngbe_mbx_stats {
371 struct ngbe_mbx_info {
372 void (*init_params)(struct ngbe_hw *hw);
373 s32 (*read)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
374 s32 (*write)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
375 s32 (*check_for_msg)(struct ngbe_hw *hw, u16 mbx_id);
376 s32 (*check_for_ack)(struct ngbe_hw *hw, u16 mbx_id);
377 s32 (*check_for_rst)(struct ngbe_hw *hw, u16 mbx_id);
379 struct ngbe_mbx_stats stats;
396 struct ngbe_mac_info mac;
397 struct ngbe_addr_filter_info addr_ctrl;
398 struct ngbe_fc_info fc;
399 struct ngbe_phy_info phy;
400 struct ngbe_rom_info rom;
401 struct ngbe_bus_info bus;
402 struct ngbe_mbx_info mbx;
409 bool adapter_stopped;
418 u32 q_rx_regs[8 * 4];
419 u32 q_tx_regs[8 * 4];
427 u64 rx_qp_mc_packets;
428 u64 tx_qp_mc_packets;
429 u64 rx_qp_bc_packets;
430 u64 tx_qp_bc_packets;
431 } qp_last[NGBE_MAX_QP];
434 #include "ngbe_regs.h"
435 #include "ngbe_dummy.h"
437 #endif /* _NGBE_TYPE_H_ */