162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* Copyright(c) 2013 - 2021 Intel Corporation. */ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci#ifndef _I40E_H_ 562306a36Sopenharmony_ci#define _I40E_H_ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#include <net/tcp.h> 862306a36Sopenharmony_ci#include <net/udp.h> 962306a36Sopenharmony_ci#include <linux/types.h> 1062306a36Sopenharmony_ci#include <linux/errno.h> 1162306a36Sopenharmony_ci#include <linux/module.h> 1262306a36Sopenharmony_ci#include <linux/pci.h> 1362306a36Sopenharmony_ci#include <linux/netdevice.h> 1462306a36Sopenharmony_ci#include <linux/ioport.h> 1562306a36Sopenharmony_ci#include <linux/iommu.h> 1662306a36Sopenharmony_ci#include <linux/slab.h> 1762306a36Sopenharmony_ci#include <linux/list.h> 1862306a36Sopenharmony_ci#include <linux/hashtable.h> 1962306a36Sopenharmony_ci#include <linux/string.h> 2062306a36Sopenharmony_ci#include <linux/in.h> 2162306a36Sopenharmony_ci#include <linux/ip.h> 2262306a36Sopenharmony_ci#include <linux/sctp.h> 2362306a36Sopenharmony_ci#include <linux/pkt_sched.h> 2462306a36Sopenharmony_ci#include <linux/ipv6.h> 2562306a36Sopenharmony_ci#include <net/checksum.h> 2662306a36Sopenharmony_ci#include <net/ip6_checksum.h> 2762306a36Sopenharmony_ci#include <linux/ethtool.h> 2862306a36Sopenharmony_ci#include <linux/if_vlan.h> 2962306a36Sopenharmony_ci#include <linux/if_macvlan.h> 3062306a36Sopenharmony_ci#include <linux/if_bridge.h> 3162306a36Sopenharmony_ci#include <linux/clocksource.h> 3262306a36Sopenharmony_ci#include <linux/net_tstamp.h> 3362306a36Sopenharmony_ci#include <linux/ptp_clock_kernel.h> 3462306a36Sopenharmony_ci#include <net/pkt_cls.h> 3562306a36Sopenharmony_ci#include <net/pkt_sched.h> 3662306a36Sopenharmony_ci#include <net/tc_act/tc_gact.h> 3762306a36Sopenharmony_ci#include <net/tc_act/tc_mirred.h> 3862306a36Sopenharmony_ci#include <net/udp_tunnel.h> 3962306a36Sopenharmony_ci#include <net/xdp_sock.h> 4062306a36Sopenharmony_ci#include <linux/bitfield.h> 4162306a36Sopenharmony_ci#include "i40e_type.h" 4262306a36Sopenharmony_ci#include "i40e_prototype.h" 4362306a36Sopenharmony_ci#include <linux/net/intel/i40e_client.h> 4462306a36Sopenharmony_ci#include <linux/avf/virtchnl.h> 4562306a36Sopenharmony_ci#include "i40e_virtchnl_pf.h" 4662306a36Sopenharmony_ci#include "i40e_txrx.h" 4762306a36Sopenharmony_ci#include "i40e_dcb.h" 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci/* Useful i40e defaults */ 5062306a36Sopenharmony_ci#define I40E_MAX_VEB 16 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci#define I40E_MAX_NUM_DESCRIPTORS 4096 5362306a36Sopenharmony_ci#define I40E_MAX_CSR_SPACE (4 * 1024 * 1024 - 64 * 1024) 5462306a36Sopenharmony_ci#define I40E_DEFAULT_NUM_DESCRIPTORS 512 5562306a36Sopenharmony_ci#define I40E_REQ_DESCRIPTOR_MULTIPLE 32 5662306a36Sopenharmony_ci#define I40E_MIN_NUM_DESCRIPTORS 64 5762306a36Sopenharmony_ci#define I40E_MIN_MSIX 2 5862306a36Sopenharmony_ci#define I40E_DEFAULT_NUM_VMDQ_VSI 8 /* max 256 VSIs */ 5962306a36Sopenharmony_ci#define I40E_MIN_VSI_ALLOC 83 /* LAN, ATR, FCOE, 64 VF */ 6062306a36Sopenharmony_ci/* max 16 qps */ 6162306a36Sopenharmony_ci#define i40e_default_queues_per_vmdq(pf) \ 6262306a36Sopenharmony_ci (((pf)->hw_features & I40E_HW_RSS_AQ_CAPABLE) ? 4 : 1) 6362306a36Sopenharmony_ci#define I40E_DEFAULT_QUEUES_PER_VF 4 6462306a36Sopenharmony_ci#define I40E_MAX_VF_QUEUES 16 6562306a36Sopenharmony_ci#define i40e_pf_get_max_q_per_tc(pf) \ 6662306a36Sopenharmony_ci (((pf)->hw_features & I40E_HW_128_QP_RSS_CAPABLE) ? 128 : 64) 6762306a36Sopenharmony_ci#define I40E_FDIR_RING_COUNT 32 6862306a36Sopenharmony_ci#define I40E_MAX_AQ_BUF_SIZE 4096 6962306a36Sopenharmony_ci#define I40E_AQ_LEN 256 7062306a36Sopenharmony_ci#define I40E_MIN_ARQ_LEN 1 7162306a36Sopenharmony_ci#define I40E_MIN_ASQ_LEN 2 7262306a36Sopenharmony_ci#define I40E_AQ_WORK_LIMIT 66 /* max number of VFs + a little */ 7362306a36Sopenharmony_ci#define I40E_MAX_USER_PRIORITY 8 7462306a36Sopenharmony_ci#define I40E_DEFAULT_TRAFFIC_CLASS BIT(0) 7562306a36Sopenharmony_ci#define I40E_QUEUE_WAIT_RETRY_LIMIT 10 7662306a36Sopenharmony_ci#define I40E_INT_NAME_STR_LEN (IFNAMSIZ + 16) 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci#define I40E_NVM_VERSION_LO_SHIFT 0 7962306a36Sopenharmony_ci#define I40E_NVM_VERSION_LO_MASK (0xff << I40E_NVM_VERSION_LO_SHIFT) 8062306a36Sopenharmony_ci#define I40E_NVM_VERSION_HI_SHIFT 12 8162306a36Sopenharmony_ci#define I40E_NVM_VERSION_HI_MASK (0xf << I40E_NVM_VERSION_HI_SHIFT) 8262306a36Sopenharmony_ci#define I40E_OEM_VER_BUILD_MASK 0xffff 8362306a36Sopenharmony_ci#define I40E_OEM_VER_PATCH_MASK 0xff 8462306a36Sopenharmony_ci#define I40E_OEM_VER_BUILD_SHIFT 8 8562306a36Sopenharmony_ci#define I40E_OEM_VER_SHIFT 24 8662306a36Sopenharmony_ci#define I40E_PHY_DEBUG_ALL \ 8762306a36Sopenharmony_ci (I40E_AQ_PHY_DEBUG_DISABLE_LINK_FW | \ 8862306a36Sopenharmony_ci I40E_AQ_PHY_DEBUG_DISABLE_ALL_LINK_FW) 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci#define I40E_OEM_EETRACK_ID 0xffffffff 9162306a36Sopenharmony_ci#define I40E_OEM_GEN_SHIFT 24 9262306a36Sopenharmony_ci#define I40E_OEM_SNAP_MASK 0x00ff0000 9362306a36Sopenharmony_ci#define I40E_OEM_SNAP_SHIFT 16 9462306a36Sopenharmony_ci#define I40E_OEM_RELEASE_MASK 0x0000ffff 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci#define I40E_RX_DESC(R, i) \ 9762306a36Sopenharmony_ci (&(((union i40e_rx_desc *)((R)->desc))[i])) 9862306a36Sopenharmony_ci#define I40E_TX_DESC(R, i) \ 9962306a36Sopenharmony_ci (&(((struct i40e_tx_desc *)((R)->desc))[i])) 10062306a36Sopenharmony_ci#define I40E_TX_CTXTDESC(R, i) \ 10162306a36Sopenharmony_ci (&(((struct i40e_tx_context_desc *)((R)->desc))[i])) 10262306a36Sopenharmony_ci#define I40E_TX_FDIRDESC(R, i) \ 10362306a36Sopenharmony_ci (&(((struct i40e_filter_program_desc *)((R)->desc))[i])) 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci/* BW rate limiting */ 10662306a36Sopenharmony_ci#define I40E_BW_CREDIT_DIVISOR 50 /* 50Mbps per BW credit */ 10762306a36Sopenharmony_ci#define I40E_BW_MBPS_DIVISOR 125000 /* rate / (1000000 / 8) Mbps */ 10862306a36Sopenharmony_ci#define I40E_MAX_BW_INACTIVE_ACCUM 4 /* accumulate 4 credits max */ 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci/* driver state flags */ 11162306a36Sopenharmony_cienum i40e_state_t { 11262306a36Sopenharmony_ci __I40E_TESTING, 11362306a36Sopenharmony_ci __I40E_CONFIG_BUSY, 11462306a36Sopenharmony_ci __I40E_CONFIG_DONE, 11562306a36Sopenharmony_ci __I40E_DOWN, 11662306a36Sopenharmony_ci __I40E_SERVICE_SCHED, 11762306a36Sopenharmony_ci __I40E_ADMINQ_EVENT_PENDING, 11862306a36Sopenharmony_ci __I40E_MDD_EVENT_PENDING, 11962306a36Sopenharmony_ci __I40E_VFLR_EVENT_PENDING, 12062306a36Sopenharmony_ci __I40E_RESET_RECOVERY_PENDING, 12162306a36Sopenharmony_ci __I40E_TIMEOUT_RECOVERY_PENDING, 12262306a36Sopenharmony_ci __I40E_MISC_IRQ_REQUESTED, 12362306a36Sopenharmony_ci __I40E_RESET_INTR_RECEIVED, 12462306a36Sopenharmony_ci __I40E_REINIT_REQUESTED, 12562306a36Sopenharmony_ci __I40E_PF_RESET_REQUESTED, 12662306a36Sopenharmony_ci __I40E_PF_RESET_AND_REBUILD_REQUESTED, 12762306a36Sopenharmony_ci __I40E_CORE_RESET_REQUESTED, 12862306a36Sopenharmony_ci __I40E_GLOBAL_RESET_REQUESTED, 12962306a36Sopenharmony_ci __I40E_EMP_RESET_INTR_RECEIVED, 13062306a36Sopenharmony_ci __I40E_SUSPENDED, 13162306a36Sopenharmony_ci __I40E_PTP_TX_IN_PROGRESS, 13262306a36Sopenharmony_ci __I40E_BAD_EEPROM, 13362306a36Sopenharmony_ci __I40E_DOWN_REQUESTED, 13462306a36Sopenharmony_ci __I40E_FD_FLUSH_REQUESTED, 13562306a36Sopenharmony_ci __I40E_FD_ATR_AUTO_DISABLED, 13662306a36Sopenharmony_ci __I40E_FD_SB_AUTO_DISABLED, 13762306a36Sopenharmony_ci __I40E_RESET_FAILED, 13862306a36Sopenharmony_ci __I40E_PORT_SUSPENDED, 13962306a36Sopenharmony_ci __I40E_VF_DISABLE, 14062306a36Sopenharmony_ci __I40E_MACVLAN_SYNC_PENDING, 14162306a36Sopenharmony_ci __I40E_TEMP_LINK_POLLING, 14262306a36Sopenharmony_ci __I40E_CLIENT_SERVICE_REQUESTED, 14362306a36Sopenharmony_ci __I40E_CLIENT_L2_CHANGE, 14462306a36Sopenharmony_ci __I40E_CLIENT_RESET, 14562306a36Sopenharmony_ci __I40E_VIRTCHNL_OP_PENDING, 14662306a36Sopenharmony_ci __I40E_RECOVERY_MODE, 14762306a36Sopenharmony_ci __I40E_VF_RESETS_DISABLED, /* disable resets during i40e_remove */ 14862306a36Sopenharmony_ci __I40E_IN_REMOVE, 14962306a36Sopenharmony_ci __I40E_VFS_RELEASING, 15062306a36Sopenharmony_ci /* This must be last as it determines the size of the BITMAP */ 15162306a36Sopenharmony_ci __I40E_STATE_SIZE__, 15262306a36Sopenharmony_ci}; 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_ci#define I40E_PF_RESET_FLAG BIT_ULL(__I40E_PF_RESET_REQUESTED) 15562306a36Sopenharmony_ci#define I40E_PF_RESET_AND_REBUILD_FLAG \ 15662306a36Sopenharmony_ci BIT_ULL(__I40E_PF_RESET_AND_REBUILD_REQUESTED) 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_ci/* VSI state flags */ 15962306a36Sopenharmony_cienum i40e_vsi_state_t { 16062306a36Sopenharmony_ci __I40E_VSI_DOWN, 16162306a36Sopenharmony_ci __I40E_VSI_NEEDS_RESTART, 16262306a36Sopenharmony_ci __I40E_VSI_SYNCING_FILTERS, 16362306a36Sopenharmony_ci __I40E_VSI_OVERFLOW_PROMISC, 16462306a36Sopenharmony_ci __I40E_VSI_REINIT_REQUESTED, 16562306a36Sopenharmony_ci __I40E_VSI_DOWN_REQUESTED, 16662306a36Sopenharmony_ci __I40E_VSI_RELEASING, 16762306a36Sopenharmony_ci /* This must be last as it determines the size of the BITMAP */ 16862306a36Sopenharmony_ci __I40E_VSI_STATE_SIZE__, 16962306a36Sopenharmony_ci}; 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_cienum i40e_interrupt_policy { 17262306a36Sopenharmony_ci I40E_INTERRUPT_BEST_CASE, 17362306a36Sopenharmony_ci I40E_INTERRUPT_MEDIUM, 17462306a36Sopenharmony_ci I40E_INTERRUPT_LOWEST 17562306a36Sopenharmony_ci}; 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_cistruct i40e_lump_tracking { 17862306a36Sopenharmony_ci u16 num_entries; 17962306a36Sopenharmony_ci u16 list[]; 18062306a36Sopenharmony_ci#define I40E_PILE_VALID_BIT 0x8000 18162306a36Sopenharmony_ci#define I40E_IWARP_IRQ_PILE_ID (I40E_PILE_VALID_BIT - 2) 18262306a36Sopenharmony_ci}; 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci#define I40E_DEFAULT_ATR_SAMPLE_RATE 20 18562306a36Sopenharmony_ci#define I40E_FDIR_MAX_RAW_PACKET_SIZE 512 18662306a36Sopenharmony_ci#define I40E_FDIR_BUFFER_FULL_MARGIN 10 18762306a36Sopenharmony_ci#define I40E_FDIR_BUFFER_HEAD_ROOM 32 18862306a36Sopenharmony_ci#define I40E_FDIR_BUFFER_HEAD_ROOM_FOR_ATR (I40E_FDIR_BUFFER_HEAD_ROOM * 4) 18962306a36Sopenharmony_ci 19062306a36Sopenharmony_ci#define I40E_HKEY_ARRAY_SIZE ((I40E_PFQF_HKEY_MAX_INDEX + 1) * 4) 19162306a36Sopenharmony_ci#define I40E_HLUT_ARRAY_SIZE ((I40E_PFQF_HLUT_MAX_INDEX + 1) * 4) 19262306a36Sopenharmony_ci#define I40E_VF_HLUT_ARRAY_SIZE ((I40E_VFQF_HLUT1_MAX_INDEX + 1) * 4) 19362306a36Sopenharmony_ci 19462306a36Sopenharmony_cienum i40e_fd_stat_idx { 19562306a36Sopenharmony_ci I40E_FD_STAT_ATR, 19662306a36Sopenharmony_ci I40E_FD_STAT_SB, 19762306a36Sopenharmony_ci I40E_FD_STAT_ATR_TUNNEL, 19862306a36Sopenharmony_ci I40E_FD_STAT_PF_COUNT 19962306a36Sopenharmony_ci}; 20062306a36Sopenharmony_ci#define I40E_FD_STAT_PF_IDX(pf_id) ((pf_id) * I40E_FD_STAT_PF_COUNT) 20162306a36Sopenharmony_ci#define I40E_FD_ATR_STAT_IDX(pf_id) \ 20262306a36Sopenharmony_ci (I40E_FD_STAT_PF_IDX(pf_id) + I40E_FD_STAT_ATR) 20362306a36Sopenharmony_ci#define I40E_FD_SB_STAT_IDX(pf_id) \ 20462306a36Sopenharmony_ci (I40E_FD_STAT_PF_IDX(pf_id) + I40E_FD_STAT_SB) 20562306a36Sopenharmony_ci#define I40E_FD_ATR_TUNNEL_STAT_IDX(pf_id) \ 20662306a36Sopenharmony_ci (I40E_FD_STAT_PF_IDX(pf_id) + I40E_FD_STAT_ATR_TUNNEL) 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci/* The following structure contains the data parsed from the user-defined 20962306a36Sopenharmony_ci * field of the ethtool_rx_flow_spec structure. 21062306a36Sopenharmony_ci */ 21162306a36Sopenharmony_cistruct i40e_rx_flow_userdef { 21262306a36Sopenharmony_ci bool flex_filter; 21362306a36Sopenharmony_ci u16 flex_word; 21462306a36Sopenharmony_ci u16 flex_offset; 21562306a36Sopenharmony_ci}; 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_cistruct i40e_fdir_filter { 21862306a36Sopenharmony_ci struct hlist_node fdir_node; 21962306a36Sopenharmony_ci /* filter ipnut set */ 22062306a36Sopenharmony_ci u8 flow_type; 22162306a36Sopenharmony_ci u8 ipl4_proto; 22262306a36Sopenharmony_ci /* TX packet view of src and dst */ 22362306a36Sopenharmony_ci __be32 dst_ip; 22462306a36Sopenharmony_ci __be32 src_ip; 22562306a36Sopenharmony_ci __be32 dst_ip6[4]; 22662306a36Sopenharmony_ci __be32 src_ip6[4]; 22762306a36Sopenharmony_ci __be16 src_port; 22862306a36Sopenharmony_ci __be16 dst_port; 22962306a36Sopenharmony_ci __be32 sctp_v_tag; 23062306a36Sopenharmony_ci 23162306a36Sopenharmony_ci __be16 vlan_etype; 23262306a36Sopenharmony_ci __be16 vlan_tag; 23362306a36Sopenharmony_ci /* Flexible data to match within the packet payload */ 23462306a36Sopenharmony_ci __be16 flex_word; 23562306a36Sopenharmony_ci u16 flex_offset; 23662306a36Sopenharmony_ci bool flex_filter; 23762306a36Sopenharmony_ci 23862306a36Sopenharmony_ci /* filter control */ 23962306a36Sopenharmony_ci u16 q_index; 24062306a36Sopenharmony_ci u8 flex_off; 24162306a36Sopenharmony_ci u8 pctype; 24262306a36Sopenharmony_ci u16 dest_vsi; 24362306a36Sopenharmony_ci u8 dest_ctl; 24462306a36Sopenharmony_ci u8 fd_status; 24562306a36Sopenharmony_ci u16 cnt_index; 24662306a36Sopenharmony_ci u32 fd_id; 24762306a36Sopenharmony_ci}; 24862306a36Sopenharmony_ci 24962306a36Sopenharmony_ci#define I40E_CLOUD_FIELD_OMAC BIT(0) 25062306a36Sopenharmony_ci#define I40E_CLOUD_FIELD_IMAC BIT(1) 25162306a36Sopenharmony_ci#define I40E_CLOUD_FIELD_IVLAN BIT(2) 25262306a36Sopenharmony_ci#define I40E_CLOUD_FIELD_TEN_ID BIT(3) 25362306a36Sopenharmony_ci#define I40E_CLOUD_FIELD_IIP BIT(4) 25462306a36Sopenharmony_ci 25562306a36Sopenharmony_ci#define I40E_CLOUD_FILTER_FLAGS_OMAC I40E_CLOUD_FIELD_OMAC 25662306a36Sopenharmony_ci#define I40E_CLOUD_FILTER_FLAGS_IMAC I40E_CLOUD_FIELD_IMAC 25762306a36Sopenharmony_ci#define I40E_CLOUD_FILTER_FLAGS_IMAC_IVLAN (I40E_CLOUD_FIELD_IMAC | \ 25862306a36Sopenharmony_ci I40E_CLOUD_FIELD_IVLAN) 25962306a36Sopenharmony_ci#define I40E_CLOUD_FILTER_FLAGS_IMAC_TEN_ID (I40E_CLOUD_FIELD_IMAC | \ 26062306a36Sopenharmony_ci I40E_CLOUD_FIELD_TEN_ID) 26162306a36Sopenharmony_ci#define I40E_CLOUD_FILTER_FLAGS_OMAC_TEN_ID_IMAC (I40E_CLOUD_FIELD_OMAC | \ 26262306a36Sopenharmony_ci I40E_CLOUD_FIELD_IMAC | \ 26362306a36Sopenharmony_ci I40E_CLOUD_FIELD_TEN_ID) 26462306a36Sopenharmony_ci#define I40E_CLOUD_FILTER_FLAGS_IMAC_IVLAN_TEN_ID (I40E_CLOUD_FIELD_IMAC | \ 26562306a36Sopenharmony_ci I40E_CLOUD_FIELD_IVLAN | \ 26662306a36Sopenharmony_ci I40E_CLOUD_FIELD_TEN_ID) 26762306a36Sopenharmony_ci#define I40E_CLOUD_FILTER_FLAGS_IIP I40E_CLOUD_FIELD_IIP 26862306a36Sopenharmony_ci 26962306a36Sopenharmony_cistruct i40e_cloud_filter { 27062306a36Sopenharmony_ci struct hlist_node cloud_node; 27162306a36Sopenharmony_ci unsigned long cookie; 27262306a36Sopenharmony_ci /* cloud filter input set follows */ 27362306a36Sopenharmony_ci u8 dst_mac[ETH_ALEN]; 27462306a36Sopenharmony_ci u8 src_mac[ETH_ALEN]; 27562306a36Sopenharmony_ci __be16 vlan_id; 27662306a36Sopenharmony_ci u16 seid; /* filter control */ 27762306a36Sopenharmony_ci __be16 dst_port; 27862306a36Sopenharmony_ci __be16 src_port; 27962306a36Sopenharmony_ci u32 tenant_id; 28062306a36Sopenharmony_ci union { 28162306a36Sopenharmony_ci struct { 28262306a36Sopenharmony_ci struct in_addr dst_ip; 28362306a36Sopenharmony_ci struct in_addr src_ip; 28462306a36Sopenharmony_ci } v4; 28562306a36Sopenharmony_ci struct { 28662306a36Sopenharmony_ci struct in6_addr dst_ip6; 28762306a36Sopenharmony_ci struct in6_addr src_ip6; 28862306a36Sopenharmony_ci } v6; 28962306a36Sopenharmony_ci } ip; 29062306a36Sopenharmony_ci#define dst_ipv6 ip.v6.dst_ip6.s6_addr32 29162306a36Sopenharmony_ci#define src_ipv6 ip.v6.src_ip6.s6_addr32 29262306a36Sopenharmony_ci#define dst_ipv4 ip.v4.dst_ip.s_addr 29362306a36Sopenharmony_ci#define src_ipv4 ip.v4.src_ip.s_addr 29462306a36Sopenharmony_ci u16 n_proto; /* Ethernet Protocol */ 29562306a36Sopenharmony_ci u8 ip_proto; /* IPPROTO value */ 29662306a36Sopenharmony_ci u8 flags; 29762306a36Sopenharmony_ci#define I40E_CLOUD_TNL_TYPE_NONE 0xff 29862306a36Sopenharmony_ci u8 tunnel_type; 29962306a36Sopenharmony_ci}; 30062306a36Sopenharmony_ci 30162306a36Sopenharmony_ci#define I40E_DCB_PRIO_TYPE_STRICT 0 30262306a36Sopenharmony_ci#define I40E_DCB_PRIO_TYPE_ETS 1 30362306a36Sopenharmony_ci#define I40E_DCB_STRICT_PRIO_CREDITS 127 30462306a36Sopenharmony_ci/* DCB per TC information data structure */ 30562306a36Sopenharmony_cistruct i40e_tc_info { 30662306a36Sopenharmony_ci u16 qoffset; /* Queue offset from base queue */ 30762306a36Sopenharmony_ci u16 qcount; /* Total Queues */ 30862306a36Sopenharmony_ci u8 netdev_tc; /* Netdev TC index if netdev associated */ 30962306a36Sopenharmony_ci}; 31062306a36Sopenharmony_ci 31162306a36Sopenharmony_ci/* TC configuration data structure */ 31262306a36Sopenharmony_cistruct i40e_tc_configuration { 31362306a36Sopenharmony_ci u8 numtc; /* Total number of enabled TCs */ 31462306a36Sopenharmony_ci u8 enabled_tc; /* TC map */ 31562306a36Sopenharmony_ci struct i40e_tc_info tc_info[I40E_MAX_TRAFFIC_CLASS]; 31662306a36Sopenharmony_ci}; 31762306a36Sopenharmony_ci 31862306a36Sopenharmony_ci#define I40E_UDP_PORT_INDEX_UNUSED 255 31962306a36Sopenharmony_cistruct i40e_udp_port_config { 32062306a36Sopenharmony_ci /* AdminQ command interface expects port number in Host byte order */ 32162306a36Sopenharmony_ci u16 port; 32262306a36Sopenharmony_ci u8 type; 32362306a36Sopenharmony_ci u8 filter_index; 32462306a36Sopenharmony_ci}; 32562306a36Sopenharmony_ci 32662306a36Sopenharmony_ci#define I40_DDP_FLASH_REGION 100 32762306a36Sopenharmony_ci#define I40E_PROFILE_INFO_SIZE 48 32862306a36Sopenharmony_ci#define I40E_MAX_PROFILE_NUM 16 32962306a36Sopenharmony_ci#define I40E_PROFILE_LIST_SIZE \ 33062306a36Sopenharmony_ci (I40E_PROFILE_INFO_SIZE * I40E_MAX_PROFILE_NUM + 4) 33162306a36Sopenharmony_ci#define I40E_DDP_PROFILE_PATH "intel/i40e/ddp/" 33262306a36Sopenharmony_ci#define I40E_DDP_PROFILE_NAME_MAX 64 33362306a36Sopenharmony_ci 33462306a36Sopenharmony_ciint i40e_ddp_load(struct net_device *netdev, const u8 *data, size_t size, 33562306a36Sopenharmony_ci bool is_add); 33662306a36Sopenharmony_ciint i40e_ddp_flash(struct net_device *netdev, struct ethtool_flash *flash); 33762306a36Sopenharmony_ci 33862306a36Sopenharmony_cistruct i40e_ddp_profile_list { 33962306a36Sopenharmony_ci u32 p_count; 34062306a36Sopenharmony_ci struct i40e_profile_info p_info[]; 34162306a36Sopenharmony_ci}; 34262306a36Sopenharmony_ci 34362306a36Sopenharmony_cistruct i40e_ddp_old_profile_list { 34462306a36Sopenharmony_ci struct list_head list; 34562306a36Sopenharmony_ci size_t old_ddp_size; 34662306a36Sopenharmony_ci u8 old_ddp_buf[]; 34762306a36Sopenharmony_ci}; 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_ci/* macros related to FLX_PIT */ 35062306a36Sopenharmony_ci#define I40E_FLEX_SET_FSIZE(fsize) (((fsize) << \ 35162306a36Sopenharmony_ci I40E_PRTQF_FLX_PIT_FSIZE_SHIFT) & \ 35262306a36Sopenharmony_ci I40E_PRTQF_FLX_PIT_FSIZE_MASK) 35362306a36Sopenharmony_ci#define I40E_FLEX_SET_DST_WORD(dst) (((dst) << \ 35462306a36Sopenharmony_ci I40E_PRTQF_FLX_PIT_DEST_OFF_SHIFT) & \ 35562306a36Sopenharmony_ci I40E_PRTQF_FLX_PIT_DEST_OFF_MASK) 35662306a36Sopenharmony_ci#define I40E_FLEX_SET_SRC_WORD(src) (((src) << \ 35762306a36Sopenharmony_ci I40E_PRTQF_FLX_PIT_SOURCE_OFF_SHIFT) & \ 35862306a36Sopenharmony_ci I40E_PRTQF_FLX_PIT_SOURCE_OFF_MASK) 35962306a36Sopenharmony_ci#define I40E_FLEX_PREP_VAL(dst, fsize, src) (I40E_FLEX_SET_DST_WORD(dst) | \ 36062306a36Sopenharmony_ci I40E_FLEX_SET_FSIZE(fsize) | \ 36162306a36Sopenharmony_ci I40E_FLEX_SET_SRC_WORD(src)) 36262306a36Sopenharmony_ci 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_ci#define I40E_MAX_FLEX_SRC_OFFSET 0x1F 36562306a36Sopenharmony_ci 36662306a36Sopenharmony_ci/* macros related to GLQF_ORT */ 36762306a36Sopenharmony_ci#define I40E_ORT_SET_IDX(idx) (((idx) << \ 36862306a36Sopenharmony_ci I40E_GLQF_ORT_PIT_INDX_SHIFT) & \ 36962306a36Sopenharmony_ci I40E_GLQF_ORT_PIT_INDX_MASK) 37062306a36Sopenharmony_ci 37162306a36Sopenharmony_ci#define I40E_ORT_SET_COUNT(count) (((count) << \ 37262306a36Sopenharmony_ci I40E_GLQF_ORT_FIELD_CNT_SHIFT) & \ 37362306a36Sopenharmony_ci I40E_GLQF_ORT_FIELD_CNT_MASK) 37462306a36Sopenharmony_ci 37562306a36Sopenharmony_ci#define I40E_ORT_SET_PAYLOAD(payload) (((payload) << \ 37662306a36Sopenharmony_ci I40E_GLQF_ORT_FLX_PAYLOAD_SHIFT) & \ 37762306a36Sopenharmony_ci I40E_GLQF_ORT_FLX_PAYLOAD_MASK) 37862306a36Sopenharmony_ci 37962306a36Sopenharmony_ci#define I40E_ORT_PREP_VAL(idx, count, payload) (I40E_ORT_SET_IDX(idx) | \ 38062306a36Sopenharmony_ci I40E_ORT_SET_COUNT(count) | \ 38162306a36Sopenharmony_ci I40E_ORT_SET_PAYLOAD(payload)) 38262306a36Sopenharmony_ci 38362306a36Sopenharmony_ci#define I40E_L3_GLQF_ORT_IDX 34 38462306a36Sopenharmony_ci#define I40E_L4_GLQF_ORT_IDX 35 38562306a36Sopenharmony_ci 38662306a36Sopenharmony_ci/* Flex PIT register index */ 38762306a36Sopenharmony_ci#define I40E_FLEX_PIT_IDX_START_L3 3 38862306a36Sopenharmony_ci#define I40E_FLEX_PIT_IDX_START_L4 6 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_ci#define I40E_FLEX_PIT_TABLE_SIZE 3 39162306a36Sopenharmony_ci 39262306a36Sopenharmony_ci#define I40E_FLEX_DEST_UNUSED 63 39362306a36Sopenharmony_ci 39462306a36Sopenharmony_ci#define I40E_FLEX_INDEX_ENTRIES 8 39562306a36Sopenharmony_ci 39662306a36Sopenharmony_ci/* Flex MASK to disable all flexible entries */ 39762306a36Sopenharmony_ci#define I40E_FLEX_INPUT_MASK (I40E_FLEX_50_MASK | I40E_FLEX_51_MASK | \ 39862306a36Sopenharmony_ci I40E_FLEX_52_MASK | I40E_FLEX_53_MASK | \ 39962306a36Sopenharmony_ci I40E_FLEX_54_MASK | I40E_FLEX_55_MASK | \ 40062306a36Sopenharmony_ci I40E_FLEX_56_MASK | I40E_FLEX_57_MASK) 40162306a36Sopenharmony_ci 40262306a36Sopenharmony_ci#define I40E_QINT_TQCTL_VAL(qp, vector, nextq_type) \ 40362306a36Sopenharmony_ci (I40E_QINT_TQCTL_CAUSE_ENA_MASK | \ 40462306a36Sopenharmony_ci (I40E_TX_ITR << I40E_QINT_TQCTL_ITR_INDX_SHIFT) | \ 40562306a36Sopenharmony_ci ((vector) << I40E_QINT_TQCTL_MSIX_INDX_SHIFT) | \ 40662306a36Sopenharmony_ci ((qp) << I40E_QINT_TQCTL_NEXTQ_INDX_SHIFT) | \ 40762306a36Sopenharmony_ci (I40E_QUEUE_TYPE_##nextq_type << I40E_QINT_TQCTL_NEXTQ_TYPE_SHIFT)) 40862306a36Sopenharmony_ci 40962306a36Sopenharmony_ci#define I40E_QINT_RQCTL_VAL(qp, vector, nextq_type) \ 41062306a36Sopenharmony_ci (I40E_QINT_RQCTL_CAUSE_ENA_MASK | \ 41162306a36Sopenharmony_ci (I40E_RX_ITR << I40E_QINT_RQCTL_ITR_INDX_SHIFT) | \ 41262306a36Sopenharmony_ci ((vector) << I40E_QINT_RQCTL_MSIX_INDX_SHIFT) | \ 41362306a36Sopenharmony_ci ((qp) << I40E_QINT_RQCTL_NEXTQ_INDX_SHIFT) | \ 41462306a36Sopenharmony_ci (I40E_QUEUE_TYPE_##nextq_type << I40E_QINT_RQCTL_NEXTQ_TYPE_SHIFT)) 41562306a36Sopenharmony_ci 41662306a36Sopenharmony_cistruct i40e_flex_pit { 41762306a36Sopenharmony_ci struct list_head list; 41862306a36Sopenharmony_ci u16 src_offset; 41962306a36Sopenharmony_ci u8 pit_index; 42062306a36Sopenharmony_ci}; 42162306a36Sopenharmony_ci 42262306a36Sopenharmony_cistruct i40e_fwd_adapter { 42362306a36Sopenharmony_ci struct net_device *netdev; 42462306a36Sopenharmony_ci int bit_no; 42562306a36Sopenharmony_ci}; 42662306a36Sopenharmony_ci 42762306a36Sopenharmony_cistruct i40e_channel { 42862306a36Sopenharmony_ci struct list_head list; 42962306a36Sopenharmony_ci bool initialized; 43062306a36Sopenharmony_ci u8 type; 43162306a36Sopenharmony_ci u16 vsi_number; /* Assigned VSI number from AQ 'Add VSI' response */ 43262306a36Sopenharmony_ci u16 stat_counter_idx; 43362306a36Sopenharmony_ci u16 base_queue; 43462306a36Sopenharmony_ci u16 num_queue_pairs; /* Requested by user */ 43562306a36Sopenharmony_ci u16 seid; 43662306a36Sopenharmony_ci 43762306a36Sopenharmony_ci u8 enabled_tc; 43862306a36Sopenharmony_ci struct i40e_aqc_vsi_properties_data info; 43962306a36Sopenharmony_ci 44062306a36Sopenharmony_ci u64 max_tx_rate; 44162306a36Sopenharmony_ci struct i40e_fwd_adapter *fwd; 44262306a36Sopenharmony_ci 44362306a36Sopenharmony_ci /* track this channel belongs to which VSI */ 44462306a36Sopenharmony_ci struct i40e_vsi *parent_vsi; 44562306a36Sopenharmony_ci}; 44662306a36Sopenharmony_ci 44762306a36Sopenharmony_cistruct i40e_ptp_pins_settings; 44862306a36Sopenharmony_ci 44962306a36Sopenharmony_cistatic inline bool i40e_is_channel_macvlan(struct i40e_channel *ch) 45062306a36Sopenharmony_ci{ 45162306a36Sopenharmony_ci return !!ch->fwd; 45262306a36Sopenharmony_ci} 45362306a36Sopenharmony_ci 45462306a36Sopenharmony_cistatic inline const u8 *i40e_channel_mac(struct i40e_channel *ch) 45562306a36Sopenharmony_ci{ 45662306a36Sopenharmony_ci if (i40e_is_channel_macvlan(ch)) 45762306a36Sopenharmony_ci return ch->fwd->netdev->dev_addr; 45862306a36Sopenharmony_ci else 45962306a36Sopenharmony_ci return NULL; 46062306a36Sopenharmony_ci} 46162306a36Sopenharmony_ci 46262306a36Sopenharmony_ci/* struct that defines the Ethernet device */ 46362306a36Sopenharmony_cistruct i40e_pf { 46462306a36Sopenharmony_ci struct pci_dev *pdev; 46562306a36Sopenharmony_ci struct i40e_hw hw; 46662306a36Sopenharmony_ci DECLARE_BITMAP(state, __I40E_STATE_SIZE__); 46762306a36Sopenharmony_ci struct msix_entry *msix_entries; 46862306a36Sopenharmony_ci bool fc_autoneg_status; 46962306a36Sopenharmony_ci 47062306a36Sopenharmony_ci u16 eeprom_version; 47162306a36Sopenharmony_ci u16 num_vmdq_vsis; /* num vmdq vsis this PF has set up */ 47262306a36Sopenharmony_ci u16 num_vmdq_qps; /* num queue pairs per vmdq pool */ 47362306a36Sopenharmony_ci u16 num_vmdq_msix; /* num queue vectors per vmdq pool */ 47462306a36Sopenharmony_ci u16 num_req_vfs; /* num VFs requested for this PF */ 47562306a36Sopenharmony_ci u16 num_vf_qps; /* num queue pairs per VF */ 47662306a36Sopenharmony_ci u16 num_lan_qps; /* num lan queues this PF has set up */ 47762306a36Sopenharmony_ci u16 num_lan_msix; /* num queue vectors for the base PF vsi */ 47862306a36Sopenharmony_ci u16 num_fdsb_msix; /* num queue vectors for sideband Fdir */ 47962306a36Sopenharmony_ci u16 num_iwarp_msix; /* num of iwarp vectors for this PF */ 48062306a36Sopenharmony_ci int iwarp_base_vector; 48162306a36Sopenharmony_ci int queues_left; /* queues left unclaimed */ 48262306a36Sopenharmony_ci u16 alloc_rss_size; /* allocated RSS queues */ 48362306a36Sopenharmony_ci u16 rss_size_max; /* HW defined max RSS queues */ 48462306a36Sopenharmony_ci u16 fdir_pf_filter_count; /* num of guaranteed filters for this PF */ 48562306a36Sopenharmony_ci u16 num_alloc_vsi; /* num VSIs this driver supports */ 48662306a36Sopenharmony_ci u8 atr_sample_rate; 48762306a36Sopenharmony_ci bool wol_en; 48862306a36Sopenharmony_ci 48962306a36Sopenharmony_ci struct hlist_head fdir_filter_list; 49062306a36Sopenharmony_ci u16 fdir_pf_active_filters; 49162306a36Sopenharmony_ci unsigned long fd_flush_timestamp; 49262306a36Sopenharmony_ci u32 fd_flush_cnt; 49362306a36Sopenharmony_ci u32 fd_add_err; 49462306a36Sopenharmony_ci u32 fd_atr_cnt; 49562306a36Sopenharmony_ci 49662306a36Sopenharmony_ci /* Book-keeping of side-band filter count per flow-type. 49762306a36Sopenharmony_ci * This is used to detect and handle input set changes for 49862306a36Sopenharmony_ci * respective flow-type. 49962306a36Sopenharmony_ci */ 50062306a36Sopenharmony_ci u16 fd_tcp4_filter_cnt; 50162306a36Sopenharmony_ci u16 fd_udp4_filter_cnt; 50262306a36Sopenharmony_ci u16 fd_sctp4_filter_cnt; 50362306a36Sopenharmony_ci u16 fd_ip4_filter_cnt; 50462306a36Sopenharmony_ci 50562306a36Sopenharmony_ci u16 fd_tcp6_filter_cnt; 50662306a36Sopenharmony_ci u16 fd_udp6_filter_cnt; 50762306a36Sopenharmony_ci u16 fd_sctp6_filter_cnt; 50862306a36Sopenharmony_ci u16 fd_ip6_filter_cnt; 50962306a36Sopenharmony_ci 51062306a36Sopenharmony_ci /* Flexible filter table values that need to be programmed into 51162306a36Sopenharmony_ci * hardware, which expects L3 and L4 to be programmed separately. We 51262306a36Sopenharmony_ci * need to ensure that the values are in ascended order and don't have 51362306a36Sopenharmony_ci * duplicates, so we track each L3 and L4 values in separate lists. 51462306a36Sopenharmony_ci */ 51562306a36Sopenharmony_ci struct list_head l3_flex_pit_list; 51662306a36Sopenharmony_ci struct list_head l4_flex_pit_list; 51762306a36Sopenharmony_ci 51862306a36Sopenharmony_ci struct udp_tunnel_nic_shared udp_tunnel_shared; 51962306a36Sopenharmony_ci struct udp_tunnel_nic_info udp_tunnel_nic; 52062306a36Sopenharmony_ci 52162306a36Sopenharmony_ci struct hlist_head cloud_filter_list; 52262306a36Sopenharmony_ci u16 num_cloud_filters; 52362306a36Sopenharmony_ci 52462306a36Sopenharmony_ci enum i40e_interrupt_policy int_policy; 52562306a36Sopenharmony_ci u16 rx_itr_default; 52662306a36Sopenharmony_ci u16 tx_itr_default; 52762306a36Sopenharmony_ci u32 msg_enable; 52862306a36Sopenharmony_ci char int_name[I40E_INT_NAME_STR_LEN]; 52962306a36Sopenharmony_ci u16 adminq_work_limit; /* num of admin receive queue desc to process */ 53062306a36Sopenharmony_ci unsigned long service_timer_period; 53162306a36Sopenharmony_ci unsigned long service_timer_previous; 53262306a36Sopenharmony_ci struct timer_list service_timer; 53362306a36Sopenharmony_ci struct work_struct service_task; 53462306a36Sopenharmony_ci 53562306a36Sopenharmony_ci u32 hw_features; 53662306a36Sopenharmony_ci#define I40E_HW_RSS_AQ_CAPABLE BIT(0) 53762306a36Sopenharmony_ci#define I40E_HW_128_QP_RSS_CAPABLE BIT(1) 53862306a36Sopenharmony_ci#define I40E_HW_ATR_EVICT_CAPABLE BIT(2) 53962306a36Sopenharmony_ci#define I40E_HW_WB_ON_ITR_CAPABLE BIT(3) 54062306a36Sopenharmony_ci#define I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE BIT(4) 54162306a36Sopenharmony_ci#define I40E_HW_NO_PCI_LINK_CHECK BIT(5) 54262306a36Sopenharmony_ci#define I40E_HW_100M_SGMII_CAPABLE BIT(6) 54362306a36Sopenharmony_ci#define I40E_HW_NO_DCB_SUPPORT BIT(7) 54462306a36Sopenharmony_ci#define I40E_HW_USE_SET_LLDP_MIB BIT(8) 54562306a36Sopenharmony_ci#define I40E_HW_GENEVE_OFFLOAD_CAPABLE BIT(9) 54662306a36Sopenharmony_ci#define I40E_HW_PTP_L4_CAPABLE BIT(10) 54762306a36Sopenharmony_ci#define I40E_HW_WOL_MC_MAGIC_PKT_WAKE BIT(11) 54862306a36Sopenharmony_ci#define I40E_HW_HAVE_CRT_RETIMER BIT(13) 54962306a36Sopenharmony_ci#define I40E_HW_OUTER_UDP_CSUM_CAPABLE BIT(14) 55062306a36Sopenharmony_ci#define I40E_HW_PHY_CONTROLS_LEDS BIT(15) 55162306a36Sopenharmony_ci#define I40E_HW_STOP_FW_LLDP BIT(16) 55262306a36Sopenharmony_ci#define I40E_HW_PORT_ID_VALID BIT(17) 55362306a36Sopenharmony_ci#define I40E_HW_RESTART_AUTONEG BIT(18) 55462306a36Sopenharmony_ci 55562306a36Sopenharmony_ci u32 flags; 55662306a36Sopenharmony_ci#define I40E_FLAG_RX_CSUM_ENABLED BIT(0) 55762306a36Sopenharmony_ci#define I40E_FLAG_MSI_ENABLED BIT(1) 55862306a36Sopenharmony_ci#define I40E_FLAG_MSIX_ENABLED BIT(2) 55962306a36Sopenharmony_ci#define I40E_FLAG_RSS_ENABLED BIT(3) 56062306a36Sopenharmony_ci#define I40E_FLAG_VMDQ_ENABLED BIT(4) 56162306a36Sopenharmony_ci#define I40E_FLAG_SRIOV_ENABLED BIT(5) 56262306a36Sopenharmony_ci#define I40E_FLAG_DCB_CAPABLE BIT(6) 56362306a36Sopenharmony_ci#define I40E_FLAG_DCB_ENABLED BIT(7) 56462306a36Sopenharmony_ci#define I40E_FLAG_FD_SB_ENABLED BIT(8) 56562306a36Sopenharmony_ci#define I40E_FLAG_FD_ATR_ENABLED BIT(9) 56662306a36Sopenharmony_ci#define I40E_FLAG_MFP_ENABLED BIT(10) 56762306a36Sopenharmony_ci#define I40E_FLAG_HW_ATR_EVICT_ENABLED BIT(11) 56862306a36Sopenharmony_ci#define I40E_FLAG_VEB_MODE_ENABLED BIT(12) 56962306a36Sopenharmony_ci#define I40E_FLAG_VEB_STATS_ENABLED BIT(13) 57062306a36Sopenharmony_ci#define I40E_FLAG_LINK_POLLING_ENABLED BIT(14) 57162306a36Sopenharmony_ci#define I40E_FLAG_TRUE_PROMISC_SUPPORT BIT(15) 57262306a36Sopenharmony_ci#define I40E_FLAG_LEGACY_RX BIT(16) 57362306a36Sopenharmony_ci#define I40E_FLAG_PTP BIT(17) 57462306a36Sopenharmony_ci#define I40E_FLAG_IWARP_ENABLED BIT(18) 57562306a36Sopenharmony_ci#define I40E_FLAG_LINK_DOWN_ON_CLOSE_ENABLED BIT(19) 57662306a36Sopenharmony_ci#define I40E_FLAG_SOURCE_PRUNING_DISABLED BIT(20) 57762306a36Sopenharmony_ci#define I40E_FLAG_TC_MQPRIO BIT(21) 57862306a36Sopenharmony_ci#define I40E_FLAG_FD_SB_INACTIVE BIT(22) 57962306a36Sopenharmony_ci#define I40E_FLAG_FD_SB_TO_CLOUD_FILTER BIT(23) 58062306a36Sopenharmony_ci#define I40E_FLAG_DISABLE_FW_LLDP BIT(24) 58162306a36Sopenharmony_ci#define I40E_FLAG_RS_FEC BIT(25) 58262306a36Sopenharmony_ci#define I40E_FLAG_BASE_R_FEC BIT(26) 58362306a36Sopenharmony_ci/* TOTAL_PORT_SHUTDOWN 58462306a36Sopenharmony_ci * Allows to physically disable the link on the NIC's port. 58562306a36Sopenharmony_ci * If enabled, (after link down request from the OS) 58662306a36Sopenharmony_ci * no link, traffic or led activity is possible on that port. 58762306a36Sopenharmony_ci * 58862306a36Sopenharmony_ci * If I40E_FLAG_TOTAL_PORT_SHUTDOWN_ENABLED is set, the 58962306a36Sopenharmony_ci * I40E_FLAG_LINK_DOWN_ON_CLOSE_ENABLED must be explicitly forced to true 59062306a36Sopenharmony_ci * and cannot be disabled by system admin at that time. 59162306a36Sopenharmony_ci * The functionalities are exclusive in terms of configuration, but they also 59262306a36Sopenharmony_ci * have similar behavior (allowing to disable physical link of the port), 59362306a36Sopenharmony_ci * with following differences: 59462306a36Sopenharmony_ci * - LINK_DOWN_ON_CLOSE_ENABLED is configurable at host OS run-time and is 59562306a36Sopenharmony_ci * supported by whole family of 7xx Intel Ethernet Controllers 59662306a36Sopenharmony_ci * - TOTAL_PORT_SHUTDOWN may be enabled only before OS loads (in BIOS) 59762306a36Sopenharmony_ci * only if motherboard's BIOS and NIC's FW has support of it 59862306a36Sopenharmony_ci * - when LINK_DOWN_ON_CLOSE_ENABLED is used, the link is being brought down 59962306a36Sopenharmony_ci * by sending phy_type=0 to NIC's FW 60062306a36Sopenharmony_ci * - when TOTAL_PORT_SHUTDOWN is used, phy_type is not altered, instead 60162306a36Sopenharmony_ci * the link is being brought down by clearing bit (I40E_AQ_PHY_ENABLE_LINK) 60262306a36Sopenharmony_ci * in abilities field of i40e_aq_set_phy_config structure 60362306a36Sopenharmony_ci */ 60462306a36Sopenharmony_ci#define I40E_FLAG_TOTAL_PORT_SHUTDOWN_ENABLED BIT(27) 60562306a36Sopenharmony_ci#define I40E_FLAG_VF_VLAN_PRUNING BIT(28) 60662306a36Sopenharmony_ci 60762306a36Sopenharmony_ci struct i40e_client_instance *cinst; 60862306a36Sopenharmony_ci bool stat_offsets_loaded; 60962306a36Sopenharmony_ci struct i40e_hw_port_stats stats; 61062306a36Sopenharmony_ci struct i40e_hw_port_stats stats_offsets; 61162306a36Sopenharmony_ci u32 tx_timeout_count; 61262306a36Sopenharmony_ci u32 tx_timeout_recovery_level; 61362306a36Sopenharmony_ci unsigned long tx_timeout_last_recovery; 61462306a36Sopenharmony_ci u32 tx_sluggish_count; 61562306a36Sopenharmony_ci u32 hw_csum_rx_error; 61662306a36Sopenharmony_ci u32 led_status; 61762306a36Sopenharmony_ci u16 corer_count; /* Core reset count */ 61862306a36Sopenharmony_ci u16 globr_count; /* Global reset count */ 61962306a36Sopenharmony_ci u16 empr_count; /* EMP reset count */ 62062306a36Sopenharmony_ci u16 pfr_count; /* PF reset count */ 62162306a36Sopenharmony_ci u16 sw_int_count; /* SW interrupt count */ 62262306a36Sopenharmony_ci 62362306a36Sopenharmony_ci struct mutex switch_mutex; 62462306a36Sopenharmony_ci u16 lan_vsi; /* our default LAN VSI */ 62562306a36Sopenharmony_ci u16 lan_veb; /* initial relay, if exists */ 62662306a36Sopenharmony_ci#define I40E_NO_VEB 0xffff 62762306a36Sopenharmony_ci#define I40E_NO_VSI 0xffff 62862306a36Sopenharmony_ci u16 next_vsi; /* Next unallocated VSI - 0-based! */ 62962306a36Sopenharmony_ci struct i40e_vsi **vsi; 63062306a36Sopenharmony_ci struct i40e_veb *veb[I40E_MAX_VEB]; 63162306a36Sopenharmony_ci 63262306a36Sopenharmony_ci struct i40e_lump_tracking *qp_pile; 63362306a36Sopenharmony_ci struct i40e_lump_tracking *irq_pile; 63462306a36Sopenharmony_ci 63562306a36Sopenharmony_ci /* switch config info */ 63662306a36Sopenharmony_ci u16 pf_seid; 63762306a36Sopenharmony_ci u16 main_vsi_seid; 63862306a36Sopenharmony_ci u16 mac_seid; 63962306a36Sopenharmony_ci struct kobject *switch_kobj; 64062306a36Sopenharmony_ci#ifdef CONFIG_DEBUG_FS 64162306a36Sopenharmony_ci struct dentry *i40e_dbg_pf; 64262306a36Sopenharmony_ci#endif /* CONFIG_DEBUG_FS */ 64362306a36Sopenharmony_ci bool cur_promisc; 64462306a36Sopenharmony_ci 64562306a36Sopenharmony_ci u16 instance; /* A unique number per i40e_pf instance in the system */ 64662306a36Sopenharmony_ci 64762306a36Sopenharmony_ci /* sr-iov config info */ 64862306a36Sopenharmony_ci struct i40e_vf *vf; 64962306a36Sopenharmony_ci int num_alloc_vfs; /* actual number of VFs allocated */ 65062306a36Sopenharmony_ci u32 vf_aq_requests; 65162306a36Sopenharmony_ci u32 arq_overflows; /* Not fatal, possibly indicative of problems */ 65262306a36Sopenharmony_ci 65362306a36Sopenharmony_ci /* DCBx/DCBNL capability for PF that indicates 65462306a36Sopenharmony_ci * whether DCBx is managed by firmware or host 65562306a36Sopenharmony_ci * based agent (LLDPAD). Also, indicates what 65662306a36Sopenharmony_ci * flavor of DCBx protocol (IEEE/CEE) is supported 65762306a36Sopenharmony_ci * by the device. For now we're supporting IEEE 65862306a36Sopenharmony_ci * mode only. 65962306a36Sopenharmony_ci */ 66062306a36Sopenharmony_ci u16 dcbx_cap; 66162306a36Sopenharmony_ci 66262306a36Sopenharmony_ci struct i40e_filter_control_settings filter_settings; 66362306a36Sopenharmony_ci struct i40e_rx_pb_config pb_cfg; /* Current Rx packet buffer config */ 66462306a36Sopenharmony_ci struct i40e_dcbx_config tmp_cfg; 66562306a36Sopenharmony_ci 66662306a36Sopenharmony_ci/* GPIO defines used by PTP */ 66762306a36Sopenharmony_ci#define I40E_SDP3_2 18 66862306a36Sopenharmony_ci#define I40E_SDP3_3 19 66962306a36Sopenharmony_ci#define I40E_GPIO_4 20 67062306a36Sopenharmony_ci#define I40E_LED2_0 26 67162306a36Sopenharmony_ci#define I40E_LED2_1 27 67262306a36Sopenharmony_ci#define I40E_LED3_0 28 67362306a36Sopenharmony_ci#define I40E_LED3_1 29 67462306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_SET_SDP_DATA_HI \ 67562306a36Sopenharmony_ci (1 << I40E_GLGEN_GPIO_SET_SDP_DATA_SHIFT) 67662306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_SET_DRV_SDP_DATA \ 67762306a36Sopenharmony_ci (1 << I40E_GLGEN_GPIO_SET_DRIVE_SDP_SHIFT) 67862306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_CTL_PRT_NUM_0 \ 67962306a36Sopenharmony_ci (0 << I40E_GLGEN_GPIO_CTL_PRT_NUM_SHIFT) 68062306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_CTL_PRT_NUM_1 \ 68162306a36Sopenharmony_ci (1 << I40E_GLGEN_GPIO_CTL_PRT_NUM_SHIFT) 68262306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_CTL_RESERVED BIT(2) 68362306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_CTL_PRT_NUM_NA_Z \ 68462306a36Sopenharmony_ci (1 << I40E_GLGEN_GPIO_CTL_PRT_NUM_NA_SHIFT) 68562306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_CTL_DIR_OUT \ 68662306a36Sopenharmony_ci (1 << I40E_GLGEN_GPIO_CTL_PIN_DIR_SHIFT) 68762306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_CTL_TRI_DRV_HI \ 68862306a36Sopenharmony_ci (1 << I40E_GLGEN_GPIO_CTL_TRI_CTL_SHIFT) 68962306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_CTL_OUT_HI_RST \ 69062306a36Sopenharmony_ci (1 << I40E_GLGEN_GPIO_CTL_OUT_CTL_SHIFT) 69162306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_CTL_TIMESYNC_0 \ 69262306a36Sopenharmony_ci (3 << I40E_GLGEN_GPIO_CTL_PIN_FUNC_SHIFT) 69362306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_CTL_TIMESYNC_1 \ 69462306a36Sopenharmony_ci (4 << I40E_GLGEN_GPIO_CTL_PIN_FUNC_SHIFT) 69562306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_CTL_NOT_FOR_PHY_CONN \ 69662306a36Sopenharmony_ci (0x3F << I40E_GLGEN_GPIO_CTL_PHY_PIN_NAME_SHIFT) 69762306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_CTL_OUT_DEFAULT \ 69862306a36Sopenharmony_ci (1 << I40E_GLGEN_GPIO_CTL_OUT_DEFAULT_SHIFT) 69962306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_CTL_PORT_0_IN_TIMESYNC_0 \ 70062306a36Sopenharmony_ci (I40E_GLGEN_GPIO_CTL_NOT_FOR_PHY_CONN | \ 70162306a36Sopenharmony_ci I40E_GLGEN_GPIO_CTL_TIMESYNC_0 | \ 70262306a36Sopenharmony_ci I40E_GLGEN_GPIO_CTL_RESERVED | I40E_GLGEN_GPIO_CTL_PRT_NUM_0) 70362306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_CTL_PORT_1_IN_TIMESYNC_0 \ 70462306a36Sopenharmony_ci (I40E_GLGEN_GPIO_CTL_NOT_FOR_PHY_CONN | \ 70562306a36Sopenharmony_ci I40E_GLGEN_GPIO_CTL_TIMESYNC_0 | \ 70662306a36Sopenharmony_ci I40E_GLGEN_GPIO_CTL_RESERVED | I40E_GLGEN_GPIO_CTL_PRT_NUM_1) 70762306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_CTL_PORT_0_OUT_TIMESYNC_1 \ 70862306a36Sopenharmony_ci (I40E_GLGEN_GPIO_CTL_NOT_FOR_PHY_CONN | \ 70962306a36Sopenharmony_ci I40E_GLGEN_GPIO_CTL_TIMESYNC_1 | I40E_GLGEN_GPIO_CTL_OUT_HI_RST | \ 71062306a36Sopenharmony_ci I40E_GLGEN_GPIO_CTL_TRI_DRV_HI | I40E_GLGEN_GPIO_CTL_DIR_OUT | \ 71162306a36Sopenharmony_ci I40E_GLGEN_GPIO_CTL_RESERVED | I40E_GLGEN_GPIO_CTL_PRT_NUM_0) 71262306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_CTL_PORT_1_OUT_TIMESYNC_1 \ 71362306a36Sopenharmony_ci (I40E_GLGEN_GPIO_CTL_NOT_FOR_PHY_CONN | \ 71462306a36Sopenharmony_ci I40E_GLGEN_GPIO_CTL_TIMESYNC_1 | I40E_GLGEN_GPIO_CTL_OUT_HI_RST | \ 71562306a36Sopenharmony_ci I40E_GLGEN_GPIO_CTL_TRI_DRV_HI | I40E_GLGEN_GPIO_CTL_DIR_OUT | \ 71662306a36Sopenharmony_ci I40E_GLGEN_GPIO_CTL_RESERVED | I40E_GLGEN_GPIO_CTL_PRT_NUM_1) 71762306a36Sopenharmony_ci#define I40E_GLGEN_GPIO_CTL_LED_INIT \ 71862306a36Sopenharmony_ci (I40E_GLGEN_GPIO_CTL_PRT_NUM_NA_Z | \ 71962306a36Sopenharmony_ci I40E_GLGEN_GPIO_CTL_DIR_OUT | \ 72062306a36Sopenharmony_ci I40E_GLGEN_GPIO_CTL_TRI_DRV_HI | \ 72162306a36Sopenharmony_ci I40E_GLGEN_GPIO_CTL_OUT_HI_RST | \ 72262306a36Sopenharmony_ci I40E_GLGEN_GPIO_CTL_OUT_DEFAULT | \ 72362306a36Sopenharmony_ci I40E_GLGEN_GPIO_CTL_NOT_FOR_PHY_CONN) 72462306a36Sopenharmony_ci#define I40E_PRTTSYN_AUX_1_INSTNT \ 72562306a36Sopenharmony_ci (1 << I40E_PRTTSYN_AUX_1_INSTNT_SHIFT) 72662306a36Sopenharmony_ci#define I40E_PRTTSYN_AUX_0_OUT_ENABLE \ 72762306a36Sopenharmony_ci (1 << I40E_PRTTSYN_AUX_0_OUT_ENA_SHIFT) 72862306a36Sopenharmony_ci#define I40E_PRTTSYN_AUX_0_OUT_CLK_MOD (3 << I40E_PRTTSYN_AUX_0_OUTMOD_SHIFT) 72962306a36Sopenharmony_ci#define I40E_PRTTSYN_AUX_0_OUT_ENABLE_CLK_MOD \ 73062306a36Sopenharmony_ci (I40E_PRTTSYN_AUX_0_OUT_ENABLE | I40E_PRTTSYN_AUX_0_OUT_CLK_MOD) 73162306a36Sopenharmony_ci#define I40E_PTP_HALF_SECOND 500000000LL /* nano seconds */ 73262306a36Sopenharmony_ci#define I40E_PTP_2_SEC_DELAY 2 73362306a36Sopenharmony_ci 73462306a36Sopenharmony_ci struct ptp_clock *ptp_clock; 73562306a36Sopenharmony_ci struct ptp_clock_info ptp_caps; 73662306a36Sopenharmony_ci struct sk_buff *ptp_tx_skb; 73762306a36Sopenharmony_ci unsigned long ptp_tx_start; 73862306a36Sopenharmony_ci struct hwtstamp_config tstamp_config; 73962306a36Sopenharmony_ci struct timespec64 ptp_prev_hw_time; 74062306a36Sopenharmony_ci struct work_struct ptp_pps_work; 74162306a36Sopenharmony_ci struct work_struct ptp_extts0_work; 74262306a36Sopenharmony_ci struct work_struct ptp_extts1_work; 74362306a36Sopenharmony_ci ktime_t ptp_reset_start; 74462306a36Sopenharmony_ci struct mutex tmreg_lock; /* Used to protect the SYSTIME registers. */ 74562306a36Sopenharmony_ci u32 ptp_adj_mult; 74662306a36Sopenharmony_ci u32 tx_hwtstamp_timeouts; 74762306a36Sopenharmony_ci u32 tx_hwtstamp_skipped; 74862306a36Sopenharmony_ci u32 rx_hwtstamp_cleared; 74962306a36Sopenharmony_ci u32 latch_event_flags; 75062306a36Sopenharmony_ci u64 ptp_pps_start; 75162306a36Sopenharmony_ci u32 pps_delay; 75262306a36Sopenharmony_ci spinlock_t ptp_rx_lock; /* Used to protect Rx timestamp registers. */ 75362306a36Sopenharmony_ci struct ptp_pin_desc ptp_pin[3]; 75462306a36Sopenharmony_ci unsigned long latch_events[4]; 75562306a36Sopenharmony_ci bool ptp_tx; 75662306a36Sopenharmony_ci bool ptp_rx; 75762306a36Sopenharmony_ci struct i40e_ptp_pins_settings *ptp_pins; 75862306a36Sopenharmony_ci u16 rss_table_size; /* HW RSS table size */ 75962306a36Sopenharmony_ci u32 max_bw; 76062306a36Sopenharmony_ci u32 min_bw; 76162306a36Sopenharmony_ci 76262306a36Sopenharmony_ci u32 ioremap_len; 76362306a36Sopenharmony_ci u32 fd_inv; 76462306a36Sopenharmony_ci u16 phy_led_val; 76562306a36Sopenharmony_ci 76662306a36Sopenharmony_ci u16 override_q_count; 76762306a36Sopenharmony_ci u16 last_sw_conf_flags; 76862306a36Sopenharmony_ci u16 last_sw_conf_valid_flags; 76962306a36Sopenharmony_ci /* List to keep previous DDP profiles to be rolled back in the future */ 77062306a36Sopenharmony_ci struct list_head ddp_old_prof; 77162306a36Sopenharmony_ci}; 77262306a36Sopenharmony_ci 77362306a36Sopenharmony_ci/** 77462306a36Sopenharmony_ci * i40e_mac_to_hkey - Convert a 6-byte MAC Address to a u64 hash key 77562306a36Sopenharmony_ci * @macaddr: the MAC Address as the base key 77662306a36Sopenharmony_ci * 77762306a36Sopenharmony_ci * Simply copies the address and returns it as a u64 for hashing 77862306a36Sopenharmony_ci **/ 77962306a36Sopenharmony_cistatic inline u64 i40e_addr_to_hkey(const u8 *macaddr) 78062306a36Sopenharmony_ci{ 78162306a36Sopenharmony_ci u64 key = 0; 78262306a36Sopenharmony_ci 78362306a36Sopenharmony_ci ether_addr_copy((u8 *)&key, macaddr); 78462306a36Sopenharmony_ci return key; 78562306a36Sopenharmony_ci} 78662306a36Sopenharmony_ci 78762306a36Sopenharmony_cienum i40e_filter_state { 78862306a36Sopenharmony_ci I40E_FILTER_INVALID = 0, /* Invalid state */ 78962306a36Sopenharmony_ci I40E_FILTER_NEW, /* New, not sent to FW yet */ 79062306a36Sopenharmony_ci I40E_FILTER_ACTIVE, /* Added to switch by FW */ 79162306a36Sopenharmony_ci I40E_FILTER_FAILED, /* Rejected by FW */ 79262306a36Sopenharmony_ci I40E_FILTER_REMOVE, /* To be removed */ 79362306a36Sopenharmony_ci/* There is no 'removed' state; the filter struct is freed */ 79462306a36Sopenharmony_ci}; 79562306a36Sopenharmony_cistruct i40e_mac_filter { 79662306a36Sopenharmony_ci struct hlist_node hlist; 79762306a36Sopenharmony_ci u8 macaddr[ETH_ALEN]; 79862306a36Sopenharmony_ci#define I40E_VLAN_ANY -1 79962306a36Sopenharmony_ci s16 vlan; 80062306a36Sopenharmony_ci enum i40e_filter_state state; 80162306a36Sopenharmony_ci}; 80262306a36Sopenharmony_ci 80362306a36Sopenharmony_ci/* Wrapper structure to keep track of filters while we are preparing to send 80462306a36Sopenharmony_ci * firmware commands. We cannot send firmware commands while holding a 80562306a36Sopenharmony_ci * spinlock, since it might sleep. To avoid this, we wrap the added filters in 80662306a36Sopenharmony_ci * a separate structure, which will track the state change and update the real 80762306a36Sopenharmony_ci * filter while under lock. We can't simply hold the filters in a separate 80862306a36Sopenharmony_ci * list, as this opens a window for a race condition when adding new MAC 80962306a36Sopenharmony_ci * addresses to all VLANs, or when adding new VLANs to all MAC addresses. 81062306a36Sopenharmony_ci */ 81162306a36Sopenharmony_cistruct i40e_new_mac_filter { 81262306a36Sopenharmony_ci struct hlist_node hlist; 81362306a36Sopenharmony_ci struct i40e_mac_filter *f; 81462306a36Sopenharmony_ci 81562306a36Sopenharmony_ci /* Track future changes to state separately */ 81662306a36Sopenharmony_ci enum i40e_filter_state state; 81762306a36Sopenharmony_ci}; 81862306a36Sopenharmony_ci 81962306a36Sopenharmony_cistruct i40e_veb { 82062306a36Sopenharmony_ci struct i40e_pf *pf; 82162306a36Sopenharmony_ci u16 idx; 82262306a36Sopenharmony_ci u16 veb_idx; /* index of VEB parent */ 82362306a36Sopenharmony_ci u16 seid; 82462306a36Sopenharmony_ci u16 uplink_seid; 82562306a36Sopenharmony_ci u16 stats_idx; /* index of VEB parent */ 82662306a36Sopenharmony_ci u8 enabled_tc; 82762306a36Sopenharmony_ci u16 bridge_mode; /* Bridge Mode (VEB/VEPA) */ 82862306a36Sopenharmony_ci u16 flags; 82962306a36Sopenharmony_ci u16 bw_limit; 83062306a36Sopenharmony_ci u8 bw_max_quanta; 83162306a36Sopenharmony_ci bool is_abs_credits; 83262306a36Sopenharmony_ci u8 bw_tc_share_credits[I40E_MAX_TRAFFIC_CLASS]; 83362306a36Sopenharmony_ci u16 bw_tc_limit_credits[I40E_MAX_TRAFFIC_CLASS]; 83462306a36Sopenharmony_ci u8 bw_tc_max_quanta[I40E_MAX_TRAFFIC_CLASS]; 83562306a36Sopenharmony_ci struct kobject *kobj; 83662306a36Sopenharmony_ci bool stat_offsets_loaded; 83762306a36Sopenharmony_ci struct i40e_eth_stats stats; 83862306a36Sopenharmony_ci struct i40e_eth_stats stats_offsets; 83962306a36Sopenharmony_ci struct i40e_veb_tc_stats tc_stats; 84062306a36Sopenharmony_ci struct i40e_veb_tc_stats tc_stats_offsets; 84162306a36Sopenharmony_ci}; 84262306a36Sopenharmony_ci 84362306a36Sopenharmony_ci/* struct that defines a VSI, associated with a dev */ 84462306a36Sopenharmony_cistruct i40e_vsi { 84562306a36Sopenharmony_ci struct net_device *netdev; 84662306a36Sopenharmony_ci unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 84762306a36Sopenharmony_ci bool netdev_registered; 84862306a36Sopenharmony_ci bool stat_offsets_loaded; 84962306a36Sopenharmony_ci 85062306a36Sopenharmony_ci u32 current_netdev_flags; 85162306a36Sopenharmony_ci DECLARE_BITMAP(state, __I40E_VSI_STATE_SIZE__); 85262306a36Sopenharmony_ci#define I40E_VSI_FLAG_FILTER_CHANGED BIT(0) 85362306a36Sopenharmony_ci#define I40E_VSI_FLAG_VEB_OWNER BIT(1) 85462306a36Sopenharmony_ci unsigned long flags; 85562306a36Sopenharmony_ci 85662306a36Sopenharmony_ci /* Per VSI lock to protect elements/hash (MAC filter) */ 85762306a36Sopenharmony_ci spinlock_t mac_filter_hash_lock; 85862306a36Sopenharmony_ci /* Fixed size hash table with 2^8 buckets for MAC filters */ 85962306a36Sopenharmony_ci DECLARE_HASHTABLE(mac_filter_hash, 8); 86062306a36Sopenharmony_ci bool has_vlan_filter; 86162306a36Sopenharmony_ci 86262306a36Sopenharmony_ci /* VSI stats */ 86362306a36Sopenharmony_ci struct rtnl_link_stats64 net_stats; 86462306a36Sopenharmony_ci struct rtnl_link_stats64 net_stats_offsets; 86562306a36Sopenharmony_ci struct i40e_eth_stats eth_stats; 86662306a36Sopenharmony_ci struct i40e_eth_stats eth_stats_offsets; 86762306a36Sopenharmony_ci u64 tx_restart; 86862306a36Sopenharmony_ci u64 tx_busy; 86962306a36Sopenharmony_ci u64 tx_linearize; 87062306a36Sopenharmony_ci u64 tx_force_wb; 87162306a36Sopenharmony_ci u64 tx_stopped; 87262306a36Sopenharmony_ci u64 rx_buf_failed; 87362306a36Sopenharmony_ci u64 rx_page_failed; 87462306a36Sopenharmony_ci u64 rx_page_reuse; 87562306a36Sopenharmony_ci u64 rx_page_alloc; 87662306a36Sopenharmony_ci u64 rx_page_waive; 87762306a36Sopenharmony_ci u64 rx_page_busy; 87862306a36Sopenharmony_ci 87962306a36Sopenharmony_ci /* These are containers of ring pointers, allocated at run-time */ 88062306a36Sopenharmony_ci struct i40e_ring **rx_rings; 88162306a36Sopenharmony_ci struct i40e_ring **tx_rings; 88262306a36Sopenharmony_ci struct i40e_ring **xdp_rings; /* XDP Tx rings */ 88362306a36Sopenharmony_ci 88462306a36Sopenharmony_ci u32 active_filters; 88562306a36Sopenharmony_ci u32 promisc_threshold; 88662306a36Sopenharmony_ci 88762306a36Sopenharmony_ci u16 work_limit; 88862306a36Sopenharmony_ci u16 int_rate_limit; /* value in usecs */ 88962306a36Sopenharmony_ci 89062306a36Sopenharmony_ci u16 rss_table_size; /* HW RSS table size */ 89162306a36Sopenharmony_ci u16 rss_size; /* Allocated RSS queues */ 89262306a36Sopenharmony_ci u8 *rss_hkey_user; /* User configured hash keys */ 89362306a36Sopenharmony_ci u8 *rss_lut_user; /* User configured lookup table entries */ 89462306a36Sopenharmony_ci 89562306a36Sopenharmony_ci 89662306a36Sopenharmony_ci u16 max_frame; 89762306a36Sopenharmony_ci u16 rx_buf_len; 89862306a36Sopenharmony_ci 89962306a36Sopenharmony_ci struct bpf_prog *xdp_prog; 90062306a36Sopenharmony_ci 90162306a36Sopenharmony_ci /* List of q_vectors allocated to this VSI */ 90262306a36Sopenharmony_ci struct i40e_q_vector **q_vectors; 90362306a36Sopenharmony_ci int num_q_vectors; 90462306a36Sopenharmony_ci int base_vector; 90562306a36Sopenharmony_ci bool irqs_ready; 90662306a36Sopenharmony_ci 90762306a36Sopenharmony_ci u16 seid; /* HW index of this VSI (absolute index) */ 90862306a36Sopenharmony_ci u16 id; /* VSI number */ 90962306a36Sopenharmony_ci u16 uplink_seid; 91062306a36Sopenharmony_ci 91162306a36Sopenharmony_ci u16 base_queue; /* vsi's first queue in hw array */ 91262306a36Sopenharmony_ci u16 alloc_queue_pairs; /* Allocated Tx/Rx queues */ 91362306a36Sopenharmony_ci u16 req_queue_pairs; /* User requested queue pairs */ 91462306a36Sopenharmony_ci u16 num_queue_pairs; /* Used tx and rx pairs */ 91562306a36Sopenharmony_ci u16 num_tx_desc; 91662306a36Sopenharmony_ci u16 num_rx_desc; 91762306a36Sopenharmony_ci enum i40e_vsi_type type; /* VSI type, e.g., LAN, FCoE, etc */ 91862306a36Sopenharmony_ci s16 vf_id; /* Virtual function ID for SRIOV VSIs */ 91962306a36Sopenharmony_ci 92062306a36Sopenharmony_ci struct tc_mqprio_qopt_offload mqprio_qopt; /* queue parameters */ 92162306a36Sopenharmony_ci struct i40e_tc_configuration tc_config; 92262306a36Sopenharmony_ci struct i40e_aqc_vsi_properties_data info; 92362306a36Sopenharmony_ci 92462306a36Sopenharmony_ci /* VSI BW limit (absolute across all TCs) */ 92562306a36Sopenharmony_ci u16 bw_limit; /* VSI BW Limit (0 = disabled) */ 92662306a36Sopenharmony_ci u8 bw_max_quanta; /* Max Quanta when BW limit is enabled */ 92762306a36Sopenharmony_ci 92862306a36Sopenharmony_ci /* Relative TC credits across VSIs */ 92962306a36Sopenharmony_ci u8 bw_ets_share_credits[I40E_MAX_TRAFFIC_CLASS]; 93062306a36Sopenharmony_ci /* TC BW limit credits within VSI */ 93162306a36Sopenharmony_ci u16 bw_ets_limit_credits[I40E_MAX_TRAFFIC_CLASS]; 93262306a36Sopenharmony_ci /* TC BW limit max quanta within VSI */ 93362306a36Sopenharmony_ci u8 bw_ets_max_quanta[I40E_MAX_TRAFFIC_CLASS]; 93462306a36Sopenharmony_ci 93562306a36Sopenharmony_ci struct i40e_pf *back; /* Backreference to associated PF */ 93662306a36Sopenharmony_ci u16 idx; /* index in pf->vsi[] */ 93762306a36Sopenharmony_ci u16 veb_idx; /* index of VEB parent */ 93862306a36Sopenharmony_ci struct kobject *kobj; /* sysfs object */ 93962306a36Sopenharmony_ci bool current_isup; /* Sync 'link up' logging */ 94062306a36Sopenharmony_ci enum i40e_aq_link_speed current_speed; /* Sync link speed logging */ 94162306a36Sopenharmony_ci 94262306a36Sopenharmony_ci /* channel specific fields */ 94362306a36Sopenharmony_ci u16 cnt_q_avail; /* num of queues available for channel usage */ 94462306a36Sopenharmony_ci u16 orig_rss_size; 94562306a36Sopenharmony_ci u16 current_rss_size; 94662306a36Sopenharmony_ci bool reconfig_rss; 94762306a36Sopenharmony_ci 94862306a36Sopenharmony_ci u16 next_base_queue; /* next queue to be used for channel setup */ 94962306a36Sopenharmony_ci 95062306a36Sopenharmony_ci struct list_head ch_list; 95162306a36Sopenharmony_ci u16 tc_seid_map[I40E_MAX_TRAFFIC_CLASS]; 95262306a36Sopenharmony_ci 95362306a36Sopenharmony_ci /* macvlan fields */ 95462306a36Sopenharmony_ci#define I40E_MAX_MACVLANS 128 /* Max HW vectors - 1 on FVL */ 95562306a36Sopenharmony_ci#define I40E_MIN_MACVLAN_VECTORS 2 /* Min vectors to enable macvlans */ 95662306a36Sopenharmony_ci DECLARE_BITMAP(fwd_bitmask, I40E_MAX_MACVLANS); 95762306a36Sopenharmony_ci struct list_head macvlan_list; 95862306a36Sopenharmony_ci int macvlan_cnt; 95962306a36Sopenharmony_ci 96062306a36Sopenharmony_ci void *priv; /* client driver data reference. */ 96162306a36Sopenharmony_ci 96262306a36Sopenharmony_ci /* VSI specific handlers */ 96362306a36Sopenharmony_ci irqreturn_t (*irq_handler)(int irq, void *data); 96462306a36Sopenharmony_ci 96562306a36Sopenharmony_ci unsigned long *af_xdp_zc_qps; /* tracks AF_XDP ZC enabled qps */ 96662306a36Sopenharmony_ci} ____cacheline_internodealigned_in_smp; 96762306a36Sopenharmony_ci 96862306a36Sopenharmony_cistruct i40e_netdev_priv { 96962306a36Sopenharmony_ci struct i40e_vsi *vsi; 97062306a36Sopenharmony_ci}; 97162306a36Sopenharmony_ci 97262306a36Sopenharmony_ciextern struct ida i40e_client_ida; 97362306a36Sopenharmony_ci 97462306a36Sopenharmony_ci/* struct that defines an interrupt vector */ 97562306a36Sopenharmony_cistruct i40e_q_vector { 97662306a36Sopenharmony_ci struct i40e_vsi *vsi; 97762306a36Sopenharmony_ci 97862306a36Sopenharmony_ci u16 v_idx; /* index in the vsi->q_vector array. */ 97962306a36Sopenharmony_ci u16 reg_idx; /* register index of the interrupt */ 98062306a36Sopenharmony_ci 98162306a36Sopenharmony_ci struct napi_struct napi; 98262306a36Sopenharmony_ci 98362306a36Sopenharmony_ci struct i40e_ring_container rx; 98462306a36Sopenharmony_ci struct i40e_ring_container tx; 98562306a36Sopenharmony_ci 98662306a36Sopenharmony_ci u8 itr_countdown; /* when 0 should adjust adaptive ITR */ 98762306a36Sopenharmony_ci u8 num_ringpairs; /* total number of ring pairs in vector */ 98862306a36Sopenharmony_ci 98962306a36Sopenharmony_ci cpumask_t affinity_mask; 99062306a36Sopenharmony_ci struct irq_affinity_notify affinity_notify; 99162306a36Sopenharmony_ci 99262306a36Sopenharmony_ci struct rcu_head rcu; /* to avoid race with update stats on free */ 99362306a36Sopenharmony_ci char name[I40E_INT_NAME_STR_LEN]; 99462306a36Sopenharmony_ci bool arm_wb_state; 99562306a36Sopenharmony_ci int irq_num; /* IRQ assigned to this q_vector */ 99662306a36Sopenharmony_ci} ____cacheline_internodealigned_in_smp; 99762306a36Sopenharmony_ci 99862306a36Sopenharmony_ci/* lan device */ 99962306a36Sopenharmony_cistruct i40e_device { 100062306a36Sopenharmony_ci struct list_head list; 100162306a36Sopenharmony_ci struct i40e_pf *pf; 100262306a36Sopenharmony_ci}; 100362306a36Sopenharmony_ci 100462306a36Sopenharmony_ci/** 100562306a36Sopenharmony_ci * i40e_nvm_version_str - format the NVM version strings 100662306a36Sopenharmony_ci * @hw: ptr to the hardware info 100762306a36Sopenharmony_ci **/ 100862306a36Sopenharmony_cistatic inline char *i40e_nvm_version_str(struct i40e_hw *hw) 100962306a36Sopenharmony_ci{ 101062306a36Sopenharmony_ci static char buf[32]; 101162306a36Sopenharmony_ci u32 full_ver; 101262306a36Sopenharmony_ci 101362306a36Sopenharmony_ci full_ver = hw->nvm.oem_ver; 101462306a36Sopenharmony_ci 101562306a36Sopenharmony_ci if (hw->nvm.eetrack == I40E_OEM_EETRACK_ID) { 101662306a36Sopenharmony_ci u8 gen, snap; 101762306a36Sopenharmony_ci u16 release; 101862306a36Sopenharmony_ci 101962306a36Sopenharmony_ci gen = (u8)(full_ver >> I40E_OEM_GEN_SHIFT); 102062306a36Sopenharmony_ci snap = (u8)((full_ver & I40E_OEM_SNAP_MASK) >> 102162306a36Sopenharmony_ci I40E_OEM_SNAP_SHIFT); 102262306a36Sopenharmony_ci release = (u16)(full_ver & I40E_OEM_RELEASE_MASK); 102362306a36Sopenharmony_ci 102462306a36Sopenharmony_ci snprintf(buf, sizeof(buf), "%x.%x.%x", gen, snap, release); 102562306a36Sopenharmony_ci } else { 102662306a36Sopenharmony_ci u8 ver, patch; 102762306a36Sopenharmony_ci u16 build; 102862306a36Sopenharmony_ci 102962306a36Sopenharmony_ci ver = (u8)(full_ver >> I40E_OEM_VER_SHIFT); 103062306a36Sopenharmony_ci build = (u16)((full_ver >> I40E_OEM_VER_BUILD_SHIFT) & 103162306a36Sopenharmony_ci I40E_OEM_VER_BUILD_MASK); 103262306a36Sopenharmony_ci patch = (u8)(full_ver & I40E_OEM_VER_PATCH_MASK); 103362306a36Sopenharmony_ci 103462306a36Sopenharmony_ci snprintf(buf, sizeof(buf), 103562306a36Sopenharmony_ci "%x.%02x 0x%x %d.%d.%d", 103662306a36Sopenharmony_ci (hw->nvm.version & I40E_NVM_VERSION_HI_MASK) >> 103762306a36Sopenharmony_ci I40E_NVM_VERSION_HI_SHIFT, 103862306a36Sopenharmony_ci (hw->nvm.version & I40E_NVM_VERSION_LO_MASK) >> 103962306a36Sopenharmony_ci I40E_NVM_VERSION_LO_SHIFT, 104062306a36Sopenharmony_ci hw->nvm.eetrack, ver, build, patch); 104162306a36Sopenharmony_ci } 104262306a36Sopenharmony_ci 104362306a36Sopenharmony_ci return buf; 104462306a36Sopenharmony_ci} 104562306a36Sopenharmony_ci 104662306a36Sopenharmony_ci/** 104762306a36Sopenharmony_ci * i40e_netdev_to_pf: Retrieve the PF struct for given netdev 104862306a36Sopenharmony_ci * @netdev: the corresponding netdev 104962306a36Sopenharmony_ci * 105062306a36Sopenharmony_ci * Return the PF struct for the given netdev 105162306a36Sopenharmony_ci **/ 105262306a36Sopenharmony_cistatic inline struct i40e_pf *i40e_netdev_to_pf(struct net_device *netdev) 105362306a36Sopenharmony_ci{ 105462306a36Sopenharmony_ci struct i40e_netdev_priv *np = netdev_priv(netdev); 105562306a36Sopenharmony_ci struct i40e_vsi *vsi = np->vsi; 105662306a36Sopenharmony_ci 105762306a36Sopenharmony_ci return vsi->back; 105862306a36Sopenharmony_ci} 105962306a36Sopenharmony_ci 106062306a36Sopenharmony_cistatic inline void i40e_vsi_setup_irqhandler(struct i40e_vsi *vsi, 106162306a36Sopenharmony_ci irqreturn_t (*irq_handler)(int, void *)) 106262306a36Sopenharmony_ci{ 106362306a36Sopenharmony_ci vsi->irq_handler = irq_handler; 106462306a36Sopenharmony_ci} 106562306a36Sopenharmony_ci 106662306a36Sopenharmony_ci/** 106762306a36Sopenharmony_ci * i40e_get_fd_cnt_all - get the total FD filter space available 106862306a36Sopenharmony_ci * @pf: pointer to the PF struct 106962306a36Sopenharmony_ci **/ 107062306a36Sopenharmony_cistatic inline int i40e_get_fd_cnt_all(struct i40e_pf *pf) 107162306a36Sopenharmony_ci{ 107262306a36Sopenharmony_ci return pf->hw.fdir_shared_filter_count + pf->fdir_pf_filter_count; 107362306a36Sopenharmony_ci} 107462306a36Sopenharmony_ci 107562306a36Sopenharmony_ci/** 107662306a36Sopenharmony_ci * i40e_read_fd_input_set - reads value of flow director input set register 107762306a36Sopenharmony_ci * @pf: pointer to the PF struct 107862306a36Sopenharmony_ci * @addr: register addr 107962306a36Sopenharmony_ci * 108062306a36Sopenharmony_ci * This function reads value of flow director input set register 108162306a36Sopenharmony_ci * specified by 'addr' (which is specific to flow-type) 108262306a36Sopenharmony_ci **/ 108362306a36Sopenharmony_cistatic inline u64 i40e_read_fd_input_set(struct i40e_pf *pf, u16 addr) 108462306a36Sopenharmony_ci{ 108562306a36Sopenharmony_ci u64 val; 108662306a36Sopenharmony_ci 108762306a36Sopenharmony_ci val = i40e_read_rx_ctl(&pf->hw, I40E_PRTQF_FD_INSET(addr, 1)); 108862306a36Sopenharmony_ci val <<= 32; 108962306a36Sopenharmony_ci val += i40e_read_rx_ctl(&pf->hw, I40E_PRTQF_FD_INSET(addr, 0)); 109062306a36Sopenharmony_ci 109162306a36Sopenharmony_ci return val; 109262306a36Sopenharmony_ci} 109362306a36Sopenharmony_ci 109462306a36Sopenharmony_ci/** 109562306a36Sopenharmony_ci * i40e_write_fd_input_set - writes value into flow director input set register 109662306a36Sopenharmony_ci * @pf: pointer to the PF struct 109762306a36Sopenharmony_ci * @addr: register addr 109862306a36Sopenharmony_ci * @val: value to be written 109962306a36Sopenharmony_ci * 110062306a36Sopenharmony_ci * This function writes specified value to the register specified by 'addr'. 110162306a36Sopenharmony_ci * This register is input set register based on flow-type. 110262306a36Sopenharmony_ci **/ 110362306a36Sopenharmony_cistatic inline void i40e_write_fd_input_set(struct i40e_pf *pf, 110462306a36Sopenharmony_ci u16 addr, u64 val) 110562306a36Sopenharmony_ci{ 110662306a36Sopenharmony_ci i40e_write_rx_ctl(&pf->hw, I40E_PRTQF_FD_INSET(addr, 1), 110762306a36Sopenharmony_ci (u32)(val >> 32)); 110862306a36Sopenharmony_ci i40e_write_rx_ctl(&pf->hw, I40E_PRTQF_FD_INSET(addr, 0), 110962306a36Sopenharmony_ci (u32)(val & 0xFFFFFFFFULL)); 111062306a36Sopenharmony_ci} 111162306a36Sopenharmony_ci 111262306a36Sopenharmony_ci/** 111362306a36Sopenharmony_ci * i40e_get_pf_count - get PCI PF count. 111462306a36Sopenharmony_ci * @hw: pointer to a hw. 111562306a36Sopenharmony_ci * 111662306a36Sopenharmony_ci * Reports the function number of the highest PCI physical 111762306a36Sopenharmony_ci * function plus 1 as it is loaded from the NVM. 111862306a36Sopenharmony_ci * 111962306a36Sopenharmony_ci * Return: PCI PF count. 112062306a36Sopenharmony_ci **/ 112162306a36Sopenharmony_cistatic inline u32 i40e_get_pf_count(struct i40e_hw *hw) 112262306a36Sopenharmony_ci{ 112362306a36Sopenharmony_ci return FIELD_GET(I40E_GLGEN_PCIFCNCNT_PCIPFCNT_MASK, 112462306a36Sopenharmony_ci rd32(hw, I40E_GLGEN_PCIFCNCNT)); 112562306a36Sopenharmony_ci} 112662306a36Sopenharmony_ci 112762306a36Sopenharmony_ci/* needed by i40e_ethtool.c */ 112862306a36Sopenharmony_ciint i40e_up(struct i40e_vsi *vsi); 112962306a36Sopenharmony_civoid i40e_down(struct i40e_vsi *vsi); 113062306a36Sopenharmony_ciextern const char i40e_driver_name[]; 113162306a36Sopenharmony_civoid i40e_do_reset_safe(struct i40e_pf *pf, u32 reset_flags); 113262306a36Sopenharmony_civoid i40e_do_reset(struct i40e_pf *pf, u32 reset_flags, bool lock_acquired); 113362306a36Sopenharmony_ciint i40e_config_rss(struct i40e_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size); 113462306a36Sopenharmony_ciint i40e_get_rss(struct i40e_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size); 113562306a36Sopenharmony_civoid i40e_fill_rss_lut(struct i40e_pf *pf, u8 *lut, 113662306a36Sopenharmony_ci u16 rss_table_size, u16 rss_size); 113762306a36Sopenharmony_cistruct i40e_vsi *i40e_find_vsi_from_id(struct i40e_pf *pf, u16 id); 113862306a36Sopenharmony_ci/** 113962306a36Sopenharmony_ci * i40e_find_vsi_by_type - Find and return Flow Director VSI 114062306a36Sopenharmony_ci * @pf: PF to search for VSI 114162306a36Sopenharmony_ci * @type: Value indicating type of VSI we are looking for 114262306a36Sopenharmony_ci **/ 114362306a36Sopenharmony_cistatic inline struct i40e_vsi * 114462306a36Sopenharmony_cii40e_find_vsi_by_type(struct i40e_pf *pf, u16 type) 114562306a36Sopenharmony_ci{ 114662306a36Sopenharmony_ci int i; 114762306a36Sopenharmony_ci 114862306a36Sopenharmony_ci for (i = 0; i < pf->num_alloc_vsi; i++) { 114962306a36Sopenharmony_ci struct i40e_vsi *vsi = pf->vsi[i]; 115062306a36Sopenharmony_ci 115162306a36Sopenharmony_ci if (vsi && vsi->type == type) 115262306a36Sopenharmony_ci return vsi; 115362306a36Sopenharmony_ci } 115462306a36Sopenharmony_ci 115562306a36Sopenharmony_ci return NULL; 115662306a36Sopenharmony_ci} 115762306a36Sopenharmony_civoid i40e_update_stats(struct i40e_vsi *vsi); 115862306a36Sopenharmony_civoid i40e_update_veb_stats(struct i40e_veb *veb); 115962306a36Sopenharmony_civoid i40e_update_eth_stats(struct i40e_vsi *vsi); 116062306a36Sopenharmony_cistruct rtnl_link_stats64 *i40e_get_vsi_stats_struct(struct i40e_vsi *vsi); 116162306a36Sopenharmony_ciint i40e_fetch_switch_configuration(struct i40e_pf *pf, 116262306a36Sopenharmony_ci bool printconfig); 116362306a36Sopenharmony_ci 116462306a36Sopenharmony_ciint i40e_add_del_fdir(struct i40e_vsi *vsi, 116562306a36Sopenharmony_ci struct i40e_fdir_filter *input, bool add); 116662306a36Sopenharmony_civoid i40e_fdir_check_and_reenable(struct i40e_pf *pf); 116762306a36Sopenharmony_ciu32 i40e_get_current_fd_count(struct i40e_pf *pf); 116862306a36Sopenharmony_ciu32 i40e_get_cur_guaranteed_fd_count(struct i40e_pf *pf); 116962306a36Sopenharmony_ciu32 i40e_get_current_atr_cnt(struct i40e_pf *pf); 117062306a36Sopenharmony_ciu32 i40e_get_global_fd_count(struct i40e_pf *pf); 117162306a36Sopenharmony_cibool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features); 117262306a36Sopenharmony_civoid i40e_set_ethtool_ops(struct net_device *netdev); 117362306a36Sopenharmony_cistruct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi, 117462306a36Sopenharmony_ci const u8 *macaddr, s16 vlan); 117562306a36Sopenharmony_civoid __i40e_del_filter(struct i40e_vsi *vsi, struct i40e_mac_filter *f); 117662306a36Sopenharmony_civoid i40e_del_filter(struct i40e_vsi *vsi, const u8 *macaddr, s16 vlan); 117762306a36Sopenharmony_ciint i40e_sync_vsi_filters(struct i40e_vsi *vsi); 117862306a36Sopenharmony_cistruct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type, 117962306a36Sopenharmony_ci u16 uplink, u32 param1); 118062306a36Sopenharmony_ciint i40e_vsi_release(struct i40e_vsi *vsi); 118162306a36Sopenharmony_civoid i40e_service_event_schedule(struct i40e_pf *pf); 118262306a36Sopenharmony_civoid i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 vf_id, 118362306a36Sopenharmony_ci u8 *msg, u16 len); 118462306a36Sopenharmony_ci 118562306a36Sopenharmony_ciint i40e_control_wait_tx_q(int seid, struct i40e_pf *pf, int pf_q, bool is_xdp, 118662306a36Sopenharmony_ci bool enable); 118762306a36Sopenharmony_ciint i40e_control_wait_rx_q(struct i40e_pf *pf, int pf_q, bool enable); 118862306a36Sopenharmony_ciint i40e_vsi_start_rings(struct i40e_vsi *vsi); 118962306a36Sopenharmony_civoid i40e_vsi_stop_rings(struct i40e_vsi *vsi); 119062306a36Sopenharmony_civoid i40e_vsi_stop_rings_no_wait(struct i40e_vsi *vsi); 119162306a36Sopenharmony_ciint i40e_vsi_wait_queues_disabled(struct i40e_vsi *vsi); 119262306a36Sopenharmony_ciint i40e_reconfig_rss_queues(struct i40e_pf *pf, int queue_count); 119362306a36Sopenharmony_cistruct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 flags, u16 uplink_seid, 119462306a36Sopenharmony_ci u16 downlink_seid, u8 enabled_tc); 119562306a36Sopenharmony_civoid i40e_veb_release(struct i40e_veb *veb); 119662306a36Sopenharmony_ci 119762306a36Sopenharmony_ciint i40e_veb_config_tc(struct i40e_veb *veb, u8 enabled_tc); 119862306a36Sopenharmony_ciint i40e_vsi_add_pvid(struct i40e_vsi *vsi, u16 vid); 119962306a36Sopenharmony_civoid i40e_vsi_remove_pvid(struct i40e_vsi *vsi); 120062306a36Sopenharmony_civoid i40e_vsi_reset_stats(struct i40e_vsi *vsi); 120162306a36Sopenharmony_civoid i40e_pf_reset_stats(struct i40e_pf *pf); 120262306a36Sopenharmony_ci#ifdef CONFIG_DEBUG_FS 120362306a36Sopenharmony_civoid i40e_dbg_pf_init(struct i40e_pf *pf); 120462306a36Sopenharmony_civoid i40e_dbg_pf_exit(struct i40e_pf *pf); 120562306a36Sopenharmony_civoid i40e_dbg_init(void); 120662306a36Sopenharmony_civoid i40e_dbg_exit(void); 120762306a36Sopenharmony_ci#else 120862306a36Sopenharmony_cistatic inline void i40e_dbg_pf_init(struct i40e_pf *pf) {} 120962306a36Sopenharmony_cistatic inline void i40e_dbg_pf_exit(struct i40e_pf *pf) {} 121062306a36Sopenharmony_cistatic inline void i40e_dbg_init(void) {} 121162306a36Sopenharmony_cistatic inline void i40e_dbg_exit(void) {} 121262306a36Sopenharmony_ci#endif /* CONFIG_DEBUG_FS*/ 121362306a36Sopenharmony_ci/* needed by client drivers */ 121462306a36Sopenharmony_ciint i40e_lan_add_device(struct i40e_pf *pf); 121562306a36Sopenharmony_ciint i40e_lan_del_device(struct i40e_pf *pf); 121662306a36Sopenharmony_civoid i40e_client_subtask(struct i40e_pf *pf); 121762306a36Sopenharmony_civoid i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi); 121862306a36Sopenharmony_civoid i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset); 121962306a36Sopenharmony_civoid i40e_notify_client_of_vf_enable(struct i40e_pf *pf, u32 num_vfs); 122062306a36Sopenharmony_civoid i40e_notify_client_of_vf_reset(struct i40e_pf *pf, u32 vf_id); 122162306a36Sopenharmony_civoid i40e_client_update_msix_info(struct i40e_pf *pf); 122262306a36Sopenharmony_ciint i40e_vf_client_capable(struct i40e_pf *pf, u32 vf_id); 122362306a36Sopenharmony_ci/** 122462306a36Sopenharmony_ci * i40e_irq_dynamic_enable - Enable default interrupt generation settings 122562306a36Sopenharmony_ci * @vsi: pointer to a vsi 122662306a36Sopenharmony_ci * @vector: enable a particular Hw Interrupt vector, without base_vector 122762306a36Sopenharmony_ci **/ 122862306a36Sopenharmony_cistatic inline void i40e_irq_dynamic_enable(struct i40e_vsi *vsi, int vector) 122962306a36Sopenharmony_ci{ 123062306a36Sopenharmony_ci struct i40e_pf *pf = vsi->back; 123162306a36Sopenharmony_ci struct i40e_hw *hw = &pf->hw; 123262306a36Sopenharmony_ci u32 val; 123362306a36Sopenharmony_ci 123462306a36Sopenharmony_ci val = I40E_PFINT_DYN_CTLN_INTENA_MASK | 123562306a36Sopenharmony_ci I40E_PFINT_DYN_CTLN_CLEARPBA_MASK | 123662306a36Sopenharmony_ci (I40E_ITR_NONE << I40E_PFINT_DYN_CTLN_ITR_INDX_SHIFT); 123762306a36Sopenharmony_ci wr32(hw, I40E_PFINT_DYN_CTLN(vector + vsi->base_vector - 1), val); 123862306a36Sopenharmony_ci /* skip the flush */ 123962306a36Sopenharmony_ci} 124062306a36Sopenharmony_ci 124162306a36Sopenharmony_civoid i40e_irq_dynamic_disable_icr0(struct i40e_pf *pf); 124262306a36Sopenharmony_civoid i40e_irq_dynamic_enable_icr0(struct i40e_pf *pf); 124362306a36Sopenharmony_ciint i40e_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); 124462306a36Sopenharmony_ciint i40e_open(struct net_device *netdev); 124562306a36Sopenharmony_ciint i40e_close(struct net_device *netdev); 124662306a36Sopenharmony_ciint i40e_vsi_open(struct i40e_vsi *vsi); 124762306a36Sopenharmony_civoid i40e_vlan_stripping_disable(struct i40e_vsi *vsi); 124862306a36Sopenharmony_ciint i40e_add_vlan_all_mac(struct i40e_vsi *vsi, s16 vid); 124962306a36Sopenharmony_ciint i40e_vsi_add_vlan(struct i40e_vsi *vsi, u16 vid); 125062306a36Sopenharmony_civoid i40e_rm_vlan_all_mac(struct i40e_vsi *vsi, s16 vid); 125162306a36Sopenharmony_civoid i40e_vsi_kill_vlan(struct i40e_vsi *vsi, u16 vid); 125262306a36Sopenharmony_cistruct i40e_mac_filter *i40e_add_mac_filter(struct i40e_vsi *vsi, 125362306a36Sopenharmony_ci const u8 *macaddr); 125462306a36Sopenharmony_ciint i40e_del_mac_filter(struct i40e_vsi *vsi, const u8 *macaddr); 125562306a36Sopenharmony_cibool i40e_is_vsi_in_vlan(struct i40e_vsi *vsi); 125662306a36Sopenharmony_ciint i40e_count_filters(struct i40e_vsi *vsi); 125762306a36Sopenharmony_cistruct i40e_mac_filter *i40e_find_mac(struct i40e_vsi *vsi, const u8 *macaddr); 125862306a36Sopenharmony_civoid i40e_vlan_stripping_enable(struct i40e_vsi *vsi); 125962306a36Sopenharmony_cistatic inline bool i40e_is_sw_dcb(struct i40e_pf *pf) 126062306a36Sopenharmony_ci{ 126162306a36Sopenharmony_ci return !!(pf->flags & I40E_FLAG_DISABLE_FW_LLDP); 126262306a36Sopenharmony_ci} 126362306a36Sopenharmony_ci 126462306a36Sopenharmony_ci#ifdef CONFIG_I40E_DCB 126562306a36Sopenharmony_civoid i40e_dcbnl_flush_apps(struct i40e_pf *pf, 126662306a36Sopenharmony_ci struct i40e_dcbx_config *old_cfg, 126762306a36Sopenharmony_ci struct i40e_dcbx_config *new_cfg); 126862306a36Sopenharmony_civoid i40e_dcbnl_set_all(struct i40e_vsi *vsi); 126962306a36Sopenharmony_civoid i40e_dcbnl_setup(struct i40e_vsi *vsi); 127062306a36Sopenharmony_cibool i40e_dcb_need_reconfig(struct i40e_pf *pf, 127162306a36Sopenharmony_ci struct i40e_dcbx_config *old_cfg, 127262306a36Sopenharmony_ci struct i40e_dcbx_config *new_cfg); 127362306a36Sopenharmony_ciint i40e_hw_dcb_config(struct i40e_pf *pf, struct i40e_dcbx_config *new_cfg); 127462306a36Sopenharmony_ciint i40e_dcb_sw_default_config(struct i40e_pf *pf); 127562306a36Sopenharmony_ci#endif /* CONFIG_I40E_DCB */ 127662306a36Sopenharmony_civoid i40e_ptp_rx_hang(struct i40e_pf *pf); 127762306a36Sopenharmony_civoid i40e_ptp_tx_hang(struct i40e_pf *pf); 127862306a36Sopenharmony_civoid i40e_ptp_tx_hwtstamp(struct i40e_pf *pf); 127962306a36Sopenharmony_civoid i40e_ptp_rx_hwtstamp(struct i40e_pf *pf, struct sk_buff *skb, u8 index); 128062306a36Sopenharmony_civoid i40e_ptp_set_increment(struct i40e_pf *pf); 128162306a36Sopenharmony_ciint i40e_ptp_set_ts_config(struct i40e_pf *pf, struct ifreq *ifr); 128262306a36Sopenharmony_ciint i40e_ptp_get_ts_config(struct i40e_pf *pf, struct ifreq *ifr); 128362306a36Sopenharmony_civoid i40e_ptp_save_hw_time(struct i40e_pf *pf); 128462306a36Sopenharmony_civoid i40e_ptp_restore_hw_time(struct i40e_pf *pf); 128562306a36Sopenharmony_civoid i40e_ptp_init(struct i40e_pf *pf); 128662306a36Sopenharmony_civoid i40e_ptp_stop(struct i40e_pf *pf); 128762306a36Sopenharmony_ciint i40e_ptp_alloc_pins(struct i40e_pf *pf); 128862306a36Sopenharmony_ciint i40e_update_adq_vsi_queues(struct i40e_vsi *vsi, int vsi_offset); 128962306a36Sopenharmony_ciint i40e_is_vsi_uplink_mode_veb(struct i40e_vsi *vsi); 129062306a36Sopenharmony_ciint i40e_get_partition_bw_setting(struct i40e_pf *pf); 129162306a36Sopenharmony_ciint i40e_set_partition_bw_setting(struct i40e_pf *pf); 129262306a36Sopenharmony_ciint i40e_commit_partition_bw_setting(struct i40e_pf *pf); 129362306a36Sopenharmony_civoid i40e_print_link_message(struct i40e_vsi *vsi, bool isup); 129462306a36Sopenharmony_ci 129562306a36Sopenharmony_civoid i40e_set_fec_in_flags(u8 fec_cfg, u32 *flags); 129662306a36Sopenharmony_ci 129762306a36Sopenharmony_cistatic inline bool i40e_enabled_xdp_vsi(struct i40e_vsi *vsi) 129862306a36Sopenharmony_ci{ 129962306a36Sopenharmony_ci return !!READ_ONCE(vsi->xdp_prog); 130062306a36Sopenharmony_ci} 130162306a36Sopenharmony_ci 130262306a36Sopenharmony_ciint i40e_create_queue_channel(struct i40e_vsi *vsi, struct i40e_channel *ch); 130362306a36Sopenharmony_ciint i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate); 130462306a36Sopenharmony_ciint i40e_add_del_cloud_filter(struct i40e_vsi *vsi, 130562306a36Sopenharmony_ci struct i40e_cloud_filter *filter, 130662306a36Sopenharmony_ci bool add); 130762306a36Sopenharmony_ciint i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi, 130862306a36Sopenharmony_ci struct i40e_cloud_filter *filter, 130962306a36Sopenharmony_ci bool add); 131062306a36Sopenharmony_ci 131162306a36Sopenharmony_ci/** 131262306a36Sopenharmony_ci * i40e_is_tc_mqprio_enabled - check if TC MQPRIO is enabled on PF 131362306a36Sopenharmony_ci * @pf: pointer to a pf. 131462306a36Sopenharmony_ci * 131562306a36Sopenharmony_ci * Check and return value of flag I40E_FLAG_TC_MQPRIO. 131662306a36Sopenharmony_ci * 131762306a36Sopenharmony_ci * Return: I40E_FLAG_TC_MQPRIO set state. 131862306a36Sopenharmony_ci **/ 131962306a36Sopenharmony_cistatic inline u32 i40e_is_tc_mqprio_enabled(struct i40e_pf *pf) 132062306a36Sopenharmony_ci{ 132162306a36Sopenharmony_ci return pf->flags & I40E_FLAG_TC_MQPRIO; 132262306a36Sopenharmony_ci} 132362306a36Sopenharmony_ci 132462306a36Sopenharmony_ci#endif /* _I40E_H_ */ 1325