linux/drivers/net/ethernet/intel/i40e/i40e.h

/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright(c) 2013 - 2021 Intel Corporation. */

#ifndef _I40E_H_
#define _I40E_H_

#include <linux/linkmode.h>
#include <linux/pci.h>
#include <linux/ptp_clock_kernel.h>
#include <linux/types.h>
#include <linux/avf/virtchnl.h>
#include <linux/net/intel/i40e_client.h>
#include <net/devlink.h>
#include <net/pkt_cls.h>
#include <net/udp_tunnel.h>
#include "i40e_dcb.h"
#include "i40e_debug.h"
#include "i40e_devlink.h"
#include "i40e_io.h"
#include "i40e_prototype.h"
#include "i40e_register.h"
#include "i40e_txrx.h"

/* Useful i40e defaults */
#define I40E_MAX_VEB

#define I40E_MAX_NUM_DESCRIPTORS
#define I40E_MAX_NUM_DESCRIPTORS_XL710
#define I40E_MAX_CSR_SPACE
#define I40E_DEFAULT_NUM_DESCRIPTORS
#define I40E_REQ_DESCRIPTOR_MULTIPLE
#define I40E_MIN_NUM_DESCRIPTORS
#define I40E_MIN_MSIX
#define I40E_DEFAULT_NUM_VMDQ_VSI
#define I40E_MIN_VSI_ALLOC
/* max 16 qps */
#define i40e_default_queues_per_vmdq(pf)
#define I40E_DEFAULT_QUEUES_PER_VF
#define I40E_MAX_VF_QUEUES
#define i40e_pf_get_max_q_per_tc(pf)
#define I40E_FDIR_RING_COUNT
#define I40E_MAX_AQ_BUF_SIZE
#define I40E_AQ_LEN
#define I40E_MIN_ARQ_LEN
#define I40E_MIN_ASQ_LEN
#define I40E_AQ_WORK_LIMIT
#define I40E_MAX_USER_PRIORITY
#define I40E_DEFAULT_TRAFFIC_CLASS
#define I40E_QUEUE_WAIT_RETRY_LIMIT
#define I40E_INT_NAME_STR_LEN

#define I40E_PHY_DEBUG_ALL

#define I40E_OEM_EETRACK_ID
#define I40E_NVM_VERSION_LO_MASK
#define I40E_NVM_VERSION_HI_MASK
#define I40E_OEM_VER_BUILD_MASK
#define I40E_OEM_VER_PATCH_MASK
#define I40E_OEM_VER_MASK
#define I40E_OEM_GEN_MASK
#define I40E_OEM_SNAP_MASK
#define I40E_OEM_RELEASE_MASK

#define I40E_RX_DESC(R, i)
#define I40E_TX_DESC(R, i)
#define I40E_TX_CTXTDESC(R, i)
#define I40E_TX_FDIRDESC(R, i)

/* BW rate limiting */
#define I40E_BW_CREDIT_DIVISOR
#define I40E_BW_MBPS_DIVISOR
#define I40E_MAX_BW_INACTIVE_ACCUM

/* driver state flags */
enum i40e_state {};

#define I40E_PF_RESET_FLAG
#define I40E_PF_RESET_AND_REBUILD_FLAG

/* VSI state flags */
enum i40e_vsi_state {};

enum i40e_pf_flags {};

enum i40e_interrupt_policy {};

struct i40e_lump_tracking {};

#define I40E_DEFAULT_ATR_SAMPLE_RATE
#define I40E_FDIR_MAX_RAW_PACKET_SIZE
#define I40E_FDIR_BUFFER_FULL_MARGIN
#define I40E_FDIR_BUFFER_HEAD_ROOM
#define I40E_FDIR_BUFFER_HEAD_ROOM_FOR_ATR

#define I40E_HKEY_ARRAY_SIZE
#define I40E_HLUT_ARRAY_SIZE
#define I40E_VF_HLUT_ARRAY_SIZE

enum i40e_fd_stat_idx {};
#define I40E_FD_STAT_PF_IDX(pf_id)
#define I40E_FD_ATR_STAT_IDX(pf_id)
#define I40E_FD_SB_STAT_IDX(pf_id)
#define I40E_FD_ATR_TUNNEL_STAT_IDX(pf_id)

/* The following structure contains the data parsed from the user-defined
 * field of the ethtool_rx_flow_spec structure.
 */
struct i40e_rx_flow_userdef {};

struct i40e_fdir_filter {};

#define I40E_CLOUD_FIELD_OMAC
#define I40E_CLOUD_FIELD_IMAC
#define I40E_CLOUD_FIELD_IVLAN
#define I40E_CLOUD_FIELD_TEN_ID
#define I40E_CLOUD_FIELD_IIP

#define I40E_CLOUD_FILTER_FLAGS_OMAC
#define I40E_CLOUD_FILTER_FLAGS_IMAC
#define I40E_CLOUD_FILTER_FLAGS_IMAC_IVLAN
#define I40E_CLOUD_FILTER_FLAGS_IMAC_TEN_ID
#define I40E_CLOUD_FILTER_FLAGS_OMAC_TEN_ID_IMAC
#define I40E_CLOUD_FILTER_FLAGS_IMAC_IVLAN_TEN_ID
#define I40E_CLOUD_FILTER_FLAGS_IIP

struct i40e_cloud_filter {};

#define I40E_DCB_PRIO_TYPE_STRICT
#define I40E_DCB_PRIO_TYPE_ETS
#define I40E_DCB_STRICT_PRIO_CREDITS
/* DCB per TC information data structure */
struct i40e_tc_info {};

/* TC configuration data structure */
struct i40e_tc_configuration {};

#define I40E_UDP_PORT_INDEX_UNUSED
struct i40e_udp_port_config {};

/* macros related to FLX_PIT */
#define I40E_FLEX_SET_FSIZE(fsize)
#define I40E_FLEX_SET_DST_WORD(dst)
#define I40E_FLEX_SET_SRC_WORD(src)
#define I40E_FLEX_PREP_VAL(dst, fsize, src)


#define I40E_MAX_FLEX_SRC_OFFSET

/* macros related to GLQF_ORT */
#define I40E_ORT_SET_IDX(idx)

#define I40E_ORT_SET_COUNT(count)

#define I40E_ORT_SET_PAYLOAD(payload)

#define I40E_ORT_PREP_VAL(idx, count, payload)

#define I40E_L3_GLQF_ORT_IDX
#define I40E_L4_GLQF_ORT_IDX

/* Flex PIT register index */
#define I40E_FLEX_PIT_IDX_START_L3
#define I40E_FLEX_PIT_IDX_START_L4

#define I40E_FLEX_PIT_TABLE_SIZE

#define I40E_FLEX_DEST_UNUSED

#define I40E_FLEX_INDEX_ENTRIES

/* Flex MASK to disable all flexible entries */
#define I40E_FLEX_INPUT_MASK

#define I40E_QINT_TQCTL_VAL(qp, vector, nextq_type)

#define I40E_QINT_RQCTL_VAL(qp, vector, nextq_type)

struct i40e_flex_pit {};

struct i40e_fwd_adapter {};

struct i40e_channel {};

struct i40e_ptp_pins_settings;

static inline bool i40e_is_channel_macvlan(struct i40e_channel *ch)
{}

static inline const u8 *i40e_channel_mac(struct i40e_channel *ch)
{}

/* struct that defines the Ethernet device */
struct i40e_pf {};

/**
 * __i40e_pf_next_vsi - get next valid VSI
 * @pf: pointer to the PF struct
 * @idx: pointer to start position number
 *
 * Find and return next non-NULL VSI pointer in pf->vsi array and
 * updates idx position. Returns NULL if no VSI is found.
 **/
static __always_inline struct i40e_vsi *
__i40e_pf_next_vsi(struct i40e_pf *pf, int *idx)
{}

#define i40e_pf_for_each_vsi(_pf, _i, _vsi)

/**
 * __i40e_pf_next_veb - get next valid VEB
 * @pf: pointer to the PF struct
 * @idx: pointer to start position number
 *
 * Find and return next non-NULL VEB pointer in pf->veb array and
 * updates idx position. Returns NULL if no VEB is found.
 **/
static __always_inline struct i40e_veb *
__i40e_pf_next_veb(struct i40e_pf *pf, int *idx)
{}

#define i40e_pf_for_each_veb(_pf, _i, _veb)

/**
 * i40e_addr_to_hkey - Convert a 6-byte MAC Address to a u64 hash key
 * @macaddr: the MAC Address as the base key
 *
 * Simply copies the address and returns it as a u64 for hashing
 **/
static inline u64 i40e_addr_to_hkey(const u8 *macaddr)
{}

enum i40e_filter_state {};
struct i40e_mac_filter {};

/* Wrapper structure to keep track of filters while we are preparing to send
 * firmware commands. We cannot send firmware commands while holding a
 * spinlock, since it might sleep. To avoid this, we wrap the added filters in
 * a separate structure, which will track the state change and update the real
 * filter while under lock. We can't simply hold the filters in a separate
 * list, as this opens a window for a race condition when adding new MAC
 * addresses to all VLANs, or when adding new VLANs to all MAC addresses.
 */
struct i40e_new_mac_filter {};

struct i40e_veb {};

/* struct that defines a VSI, associated with a dev */
struct i40e_vsi {} ____cacheline_internodealigned_in_smp;

struct i40e_netdev_priv {};

extern struct ida i40e_client_ida;

/* struct that defines an interrupt vector */
struct i40e_q_vector {} ____cacheline_internodealigned_in_smp;

/* lan device */
struct i40e_device {};

/**
 * i40e_info_nvm_ver - format the NVM version string
 * @hw: ptr to the hardware info
 * @buf: string buffer to store
 * @len: buffer size
 *
 * Formats NVM version string as:
 * <gen>.<snap>.<release> when eetrackid == I40E_OEM_EETRACK_ID
 * <nvm_major>.<nvm_minor> otherwise
 **/
static inline void i40e_info_nvm_ver(struct i40e_hw *hw, char *buf, size_t len)
{}

/**
 * i40e_info_eetrack - format the EETrackID string
 * @hw: ptr to the hardware info
 * @buf: string buffer to store
 * @len: buffer size
 *
 * Returns hexadecimally formated EETrackID if it is
 * different from I40E_OEM_EETRACK_ID or empty string.
 **/
static inline void i40e_info_eetrack(struct i40e_hw *hw, char *buf, size_t len)
{}

/**
 * i40e_info_civd_ver - format the NVM version strings
 * @hw: ptr to the hardware info
 * @buf: string buffer to store
 * @len: buffer size
 *
 * Returns formated combo image version if adapter's EETrackID is
 * different from I40E_OEM_EETRACK_ID or empty string.
 **/
static inline void i40e_info_civd_ver(struct i40e_hw *hw, char *buf, size_t len)
{}

/**
 * i40e_nvm_version_str - format the NVM version strings
 * @hw: ptr to the hardware info
 * @buf: string buffer to store
 * @len: buffer size
 **/
static inline char *i40e_nvm_version_str(struct i40e_hw *hw, char *buf,
					 size_t len)
{}

/**
 * i40e_netdev_to_pf: Retrieve the PF struct for given netdev
 * @netdev: the corresponding netdev
 *
 * Return the PF struct for the given netdev
 **/
static inline struct i40e_pf *i40e_netdev_to_pf(struct net_device *netdev)
{}

static inline void i40e_vsi_setup_irqhandler(struct i40e_vsi *vsi,
				irqreturn_t (*irq_handler)(int, void *))
{}

/**
 * i40e_get_fd_cnt_all - get the total FD filter space available
 * @pf: pointer to the PF struct
 **/
static inline int i40e_get_fd_cnt_all(struct i40e_pf *pf)
{}

/**
 * i40e_read_fd_input_set - reads value of flow director input set register
 * @pf: pointer to the PF struct
 * @addr: register addr
 *
 * This function reads value of flow director input set register
 * specified by 'addr' (which is specific to flow-type)
 **/
static inline u64 i40e_read_fd_input_set(struct i40e_pf *pf, u16 addr)
{}

/**
 * i40e_write_fd_input_set - writes value into flow director input set register
 * @pf: pointer to the PF struct
 * @addr: register addr
 * @val: value to be written
 *
 * This function writes specified value to the register specified by 'addr'.
 * This register is input set register based on flow-type.
 **/
static inline void i40e_write_fd_input_set(struct i40e_pf *pf,
					   u16 addr, u64 val)
{}

/**
 * i40e_get_pf_count - get PCI PF count.
 * @hw: pointer to a hw.
 *
 * Reports the function number of the highest PCI physical
 * function plus 1 as it is loaded from the NVM.
 *
 * Return: PCI PF count.
 **/
static inline u32 i40e_get_pf_count(struct i40e_hw *hw)
{}

/* needed by i40e_ethtool.c */
int i40e_up(struct i40e_vsi *vsi);
void i40e_down(struct i40e_vsi *vsi);
extern const char i40e_driver_name[];
void i40e_do_reset_safe(struct i40e_pf *pf, u32 reset_flags);
void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags, bool lock_acquired);
int i40e_config_rss(struct i40e_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size);
int i40e_get_rss(struct i40e_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size);
void i40e_fill_rss_lut(struct i40e_pf *pf, u8 *lut,
		       u16 rss_table_size, u16 rss_size);
struct i40e_vsi *i40e_find_vsi_from_id(struct i40e_pf *pf, u16 id);
/**
 * i40e_find_vsi_by_type - Find and return Flow Director VSI
 * @pf: PF to search for VSI
 * @type: Value indicating type of VSI we are looking for
 **/
static inline struct i40e_vsi *
i40e_find_vsi_by_type(struct i40e_pf *pf, u16 type)
{}
void i40e_update_stats(struct i40e_vsi *vsi);
void i40e_update_veb_stats(struct i40e_veb *veb);
void i40e_update_eth_stats(struct i40e_vsi *vsi);
struct rtnl_link_stats64 *i40e_get_vsi_stats_struct(struct i40e_vsi *vsi);
int i40e_fetch_switch_configuration(struct i40e_pf *pf,
				    bool printconfig);

int i40e_add_del_fdir(struct i40e_vsi *vsi,
		      struct i40e_fdir_filter *input, bool add);
void i40e_fdir_check_and_reenable(struct i40e_pf *pf);
u32 i40e_get_current_fd_count(struct i40e_pf *pf);
u32 i40e_get_cur_guaranteed_fd_count(struct i40e_pf *pf);
u32 i40e_get_current_atr_cnt(struct i40e_pf *pf);
u32 i40e_get_global_fd_count(struct i40e_pf *pf);
bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features);
void i40e_set_ethtool_ops(struct net_device *netdev);
struct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi,
					const u8 *macaddr, s16 vlan);
void __i40e_del_filter(struct i40e_vsi *vsi, struct i40e_mac_filter *f);
void i40e_del_filter(struct i40e_vsi *vsi, const u8 *macaddr, s16 vlan);
int i40e_sync_vsi_filters(struct i40e_vsi *vsi);
struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type,
				u16 uplink, u32 param1);
int i40e_vsi_release(struct i40e_vsi *vsi);
void i40e_service_event_schedule(struct i40e_pf *pf);
void i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 vf_id,
				  u8 *msg, u16 len);

int i40e_control_wait_tx_q(int seid, struct i40e_pf *pf, int pf_q, bool is_xdp,
			   bool enable);
int i40e_control_wait_rx_q(struct i40e_pf *pf, int pf_q, bool enable);
int i40e_vsi_start_rings(struct i40e_vsi *vsi);
void i40e_vsi_stop_rings(struct i40e_vsi *vsi);
void i40e_vsi_stop_rings_no_wait(struct  i40e_vsi *vsi);
int i40e_vsi_wait_queues_disabled(struct i40e_vsi *vsi);
int i40e_reconfig_rss_queues(struct i40e_pf *pf, int queue_count);
struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 uplink_seid,
				u16 downlink_seid, u8 enabled_tc);
void i40e_veb_release(struct i40e_veb *veb);

int i40e_veb_config_tc(struct i40e_veb *veb, u8 enabled_tc);
int i40e_vsi_add_pvid(struct i40e_vsi *vsi, u16 vid);
void i40e_vsi_remove_pvid(struct i40e_vsi *vsi);
void i40e_vsi_reset_stats(struct i40e_vsi *vsi);
void i40e_pf_reset_stats(struct i40e_pf *pf);
#ifdef CONFIG_DEBUG_FS
void i40e_dbg_pf_init(struct i40e_pf *pf);
void i40e_dbg_pf_exit(struct i40e_pf *pf);
void i40e_dbg_init(void);
void i40e_dbg_exit(void);
#else
static inline void i40e_dbg_pf_init(struct i40e_pf *pf) {}
static inline void i40e_dbg_pf_exit(struct i40e_pf *pf) {}
static inline void i40e_dbg_init(void) {}
static inline void i40e_dbg_exit(void) {}
#endif /* CONFIG_DEBUG_FS*/
/* needed by client drivers */
int i40e_lan_add_device(struct i40e_pf *pf);
int i40e_lan_del_device(struct i40e_pf *pf);
void i40e_client_subtask(struct i40e_pf *pf);
void i40e_notify_client_of_l2_param_changes(struct i40e_pf *pf);
void i40e_notify_client_of_netdev_close(struct i40e_pf *pf, bool reset);
void i40e_notify_client_of_vf_enable(struct i40e_pf *pf, u32 num_vfs);
void i40e_notify_client_of_vf_reset(struct i40e_pf *pf, u32 vf_id);
void i40e_client_update_msix_info(struct i40e_pf *pf);
int i40e_vf_client_capable(struct i40e_pf *pf, u32 vf_id);
/**
 * i40e_irq_dynamic_enable - Enable default interrupt generation settings
 * @vsi: pointer to a vsi
 * @vector: enable a particular Hw Interrupt vector, without base_vector
 **/
static inline void i40e_irq_dynamic_enable(struct i40e_vsi *vsi, int vector)
{}

void i40e_irq_dynamic_disable_icr0(struct i40e_pf *pf);
void i40e_irq_dynamic_enable_icr0(struct i40e_pf *pf);
int i40e_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
int i40e_open(struct net_device *netdev);
int i40e_close(struct net_device *netdev);
int i40e_vsi_open(struct i40e_vsi *vsi);
void i40e_vlan_stripping_disable(struct i40e_vsi *vsi);
int i40e_add_vlan_all_mac(struct i40e_vsi *vsi, s16 vid);
int i40e_vsi_add_vlan(struct i40e_vsi *vsi, u16 vid);
void i40e_rm_vlan_all_mac(struct i40e_vsi *vsi, s16 vid);
void i40e_vsi_kill_vlan(struct i40e_vsi *vsi, u16 vid);
struct i40e_mac_filter *i40e_add_mac_filter(struct i40e_vsi *vsi,
					    const u8 *macaddr);
int i40e_del_mac_filter(struct i40e_vsi *vsi, const u8 *macaddr);
bool i40e_is_vsi_in_vlan(struct i40e_vsi *vsi);
int i40e_count_filters(struct i40e_vsi *vsi);
struct i40e_mac_filter *i40e_find_mac(struct i40e_vsi *vsi, const u8 *macaddr);
void i40e_vlan_stripping_enable(struct i40e_vsi *vsi);
static inline bool i40e_is_sw_dcb(struct i40e_pf *pf)
{}

#ifdef CONFIG_I40E_DCB
void i40e_dcbnl_flush_apps(struct i40e_pf *pf,
			   struct i40e_dcbx_config *old_cfg,
			   struct i40e_dcbx_config *new_cfg);
void i40e_dcbnl_set_all(struct i40e_vsi *vsi);
void i40e_dcbnl_setup(struct i40e_vsi *vsi);
bool i40e_dcb_need_reconfig(struct i40e_pf *pf,
			    struct i40e_dcbx_config *old_cfg,
			    struct i40e_dcbx_config *new_cfg);
int i40e_hw_dcb_config(struct i40e_pf *pf, struct i40e_dcbx_config *new_cfg);
int i40e_dcb_sw_default_config(struct i40e_pf *pf);
#endif /* CONFIG_I40E_DCB */
void i40e_ptp_rx_hang(struct i40e_pf *pf);
void i40e_ptp_tx_hang(struct i40e_pf *pf);
void i40e_ptp_tx_hwtstamp(struct i40e_pf *pf);
void i40e_ptp_rx_hwtstamp(struct i40e_pf *pf, struct sk_buff *skb, u8 index);
void i40e_ptp_set_increment(struct i40e_pf *pf);
int i40e_ptp_set_ts_config(struct i40e_pf *pf, struct ifreq *ifr);
int i40e_ptp_get_ts_config(struct i40e_pf *pf, struct ifreq *ifr);
void i40e_ptp_save_hw_time(struct i40e_pf *pf);
void i40e_ptp_restore_hw_time(struct i40e_pf *pf);
void i40e_ptp_init(struct i40e_pf *pf);
void i40e_ptp_stop(struct i40e_pf *pf);
int i40e_ptp_alloc_pins(struct i40e_pf *pf);
int i40e_update_adq_vsi_queues(struct i40e_vsi *vsi, int vsi_offset);
int i40e_is_vsi_uplink_mode_veb(struct i40e_vsi *vsi);
int i40e_get_partition_bw_setting(struct i40e_pf *pf);
int i40e_set_partition_bw_setting(struct i40e_pf *pf);
int i40e_commit_partition_bw_setting(struct i40e_pf *pf);
void i40e_print_link_message(struct i40e_vsi *vsi, bool isup);

void i40e_set_fec_in_flags(u8 fec_cfg, unsigned long *flags);

static inline bool i40e_enabled_xdp_vsi(struct i40e_vsi *vsi)
{}

int i40e_create_queue_channel(struct i40e_vsi *vsi, struct i40e_channel *ch);
int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate);
int i40e_add_del_cloud_filter(struct i40e_vsi *vsi,
			      struct i40e_cloud_filter *filter,
			      bool add);
int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi,
				      struct i40e_cloud_filter *filter,
				      bool add);

/**
 * i40e_is_tc_mqprio_enabled - check if TC MQPRIO is enabled on PF
 * @pf: pointer to a pf.
 *
 * Check and return state of flag I40E_FLAG_TC_MQPRIO.
 *
 * Return: true/false if I40E_FLAG_TC_MQPRIO is set or not
 **/
static inline bool i40e_is_tc_mqprio_enabled(struct i40e_pf *pf)
{}

/**
 * i40e_hw_to_pf - get pf pointer from the hardware structure
 * @hw: pointer to the device HW structure
 **/
static inline struct i40e_pf *i40e_hw_to_pf(struct i40e_hw *hw)
{}

struct device *i40e_hw_to_dev(struct i40e_hw *hw);

/**
 * i40e_pf_get_vsi_by_seid - find VSI by SEID
 * @pf: pointer to a PF
 * @seid: SEID of the VSI
 **/
static inline struct i40e_vsi *
i40e_pf_get_vsi_by_seid(struct i40e_pf *pf, u16 seid)
{}

/**
 * i40e_pf_get_main_vsi - get pointer to main VSI
 * @pf: pointer to a PF
 *
 * Return: pointer to main VSI or NULL if it does not exist
 **/
static inline struct i40e_vsi *i40e_pf_get_main_vsi(struct i40e_pf *pf)
{}

/**
 * i40e_pf_get_veb_by_seid - find VEB by SEID
 * @pf: pointer to a PF
 * @seid: SEID of the VSI
 **/
static inline struct i40e_veb *
i40e_pf_get_veb_by_seid(struct i40e_pf *pf, u16 seid)
{}

/**
 * i40e_pf_get_main_veb - get pointer to main VEB
 * @pf: pointer to a PF
 *
 * Return: pointer to main VEB or NULL if it does not exist
 **/
static inline struct i40e_veb *i40e_pf_get_main_veb(struct i40e_pf *pf)
{}

#endif /* _I40E_H_ */