18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* Copyright(c) 2007 - 2018 Intel Corporation. */ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci/* Linux PRO/1000 Ethernet Driver main header file */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef _IGB_H_ 78c2ecf20Sopenharmony_ci#define _IGB_H_ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include "e1000_mac.h" 108c2ecf20Sopenharmony_ci#include "e1000_82575.h" 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/timecounter.h> 138c2ecf20Sopenharmony_ci#include <linux/net_tstamp.h> 148c2ecf20Sopenharmony_ci#include <linux/ptp_clock_kernel.h> 158c2ecf20Sopenharmony_ci#include <linux/bitops.h> 168c2ecf20Sopenharmony_ci#include <linux/if_vlan.h> 178c2ecf20Sopenharmony_ci#include <linux/i2c.h> 188c2ecf20Sopenharmony_ci#include <linux/i2c-algo-bit.h> 198c2ecf20Sopenharmony_ci#include <linux/pci.h> 208c2ecf20Sopenharmony_ci#include <linux/mdio.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#include <net/xdp.h> 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cistruct igb_adapter; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define E1000_PCS_CFG_IGN_SD 1 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* Interrupt defines */ 298c2ecf20Sopenharmony_ci#define IGB_START_ITR 648 /* ~6000 ints/sec */ 308c2ecf20Sopenharmony_ci#define IGB_4K_ITR 980 318c2ecf20Sopenharmony_ci#define IGB_20K_ITR 196 328c2ecf20Sopenharmony_ci#define IGB_70K_ITR 56 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* TX/RX descriptor defines */ 358c2ecf20Sopenharmony_ci#define IGB_DEFAULT_TXD 256 368c2ecf20Sopenharmony_ci#define IGB_DEFAULT_TX_WORK 128 378c2ecf20Sopenharmony_ci#define IGB_MIN_TXD 64 388c2ecf20Sopenharmony_ci#define IGB_MAX_TXD 4096 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define IGB_DEFAULT_RXD 256 418c2ecf20Sopenharmony_ci#define IGB_MIN_RXD 64 428c2ecf20Sopenharmony_ci#define IGB_MAX_RXD 4096 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#define IGB_DEFAULT_ITR 3 /* dynamic */ 458c2ecf20Sopenharmony_ci#define IGB_MAX_ITR_USECS 10000 468c2ecf20Sopenharmony_ci#define IGB_MIN_ITR_USECS 10 478c2ecf20Sopenharmony_ci#define NON_Q_VECTORS 1 488c2ecf20Sopenharmony_ci#define MAX_Q_VECTORS 8 498c2ecf20Sopenharmony_ci#define MAX_MSIX_ENTRIES 10 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci/* Transmit and receive queues */ 528c2ecf20Sopenharmony_ci#define IGB_MAX_RX_QUEUES 8 538c2ecf20Sopenharmony_ci#define IGB_MAX_RX_QUEUES_82575 4 548c2ecf20Sopenharmony_ci#define IGB_MAX_RX_QUEUES_I211 2 558c2ecf20Sopenharmony_ci#define IGB_MAX_TX_QUEUES 8 568c2ecf20Sopenharmony_ci#define IGB_MAX_VF_MC_ENTRIES 30 578c2ecf20Sopenharmony_ci#define IGB_MAX_VF_FUNCTIONS 8 588c2ecf20Sopenharmony_ci#define IGB_MAX_VFTA_ENTRIES 128 598c2ecf20Sopenharmony_ci#define IGB_82576_VF_DEV_ID 0x10CA 608c2ecf20Sopenharmony_ci#define IGB_I350_VF_DEV_ID 0x1520 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci/* NVM version defines */ 638c2ecf20Sopenharmony_ci#define IGB_MAJOR_MASK 0xF000 648c2ecf20Sopenharmony_ci#define IGB_MINOR_MASK 0x0FF0 658c2ecf20Sopenharmony_ci#define IGB_BUILD_MASK 0x000F 668c2ecf20Sopenharmony_ci#define IGB_COMB_VER_MASK 0x00FF 678c2ecf20Sopenharmony_ci#define IGB_MAJOR_SHIFT 12 688c2ecf20Sopenharmony_ci#define IGB_MINOR_SHIFT 4 698c2ecf20Sopenharmony_ci#define IGB_COMB_VER_SHFT 8 708c2ecf20Sopenharmony_ci#define IGB_NVM_VER_INVALID 0xFFFF 718c2ecf20Sopenharmony_ci#define IGB_ETRACK_SHIFT 16 728c2ecf20Sopenharmony_ci#define NVM_ETRACK_WORD 0x0042 738c2ecf20Sopenharmony_ci#define NVM_COMB_VER_OFF 0x0083 748c2ecf20Sopenharmony_ci#define NVM_COMB_VER_PTR 0x003d 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci/* Transmit and receive latency (for PTP timestamps) */ 778c2ecf20Sopenharmony_ci#define IGB_I210_TX_LATENCY_10 9542 788c2ecf20Sopenharmony_ci#define IGB_I210_TX_LATENCY_100 1024 798c2ecf20Sopenharmony_ci#define IGB_I210_TX_LATENCY_1000 178 808c2ecf20Sopenharmony_ci#define IGB_I210_RX_LATENCY_10 20662 818c2ecf20Sopenharmony_ci#define IGB_I210_RX_LATENCY_100 2213 828c2ecf20Sopenharmony_ci#define IGB_I210_RX_LATENCY_1000 448 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci/* XDP */ 858c2ecf20Sopenharmony_ci#define IGB_XDP_PASS 0 868c2ecf20Sopenharmony_ci#define IGB_XDP_CONSUMED BIT(0) 878c2ecf20Sopenharmony_ci#define IGB_XDP_TX BIT(1) 888c2ecf20Sopenharmony_ci#define IGB_XDP_REDIR BIT(2) 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_cistruct vf_data_storage { 918c2ecf20Sopenharmony_ci unsigned char vf_mac_addresses[ETH_ALEN]; 928c2ecf20Sopenharmony_ci u16 vf_mc_hashes[IGB_MAX_VF_MC_ENTRIES]; 938c2ecf20Sopenharmony_ci u16 num_vf_mc_hashes; 948c2ecf20Sopenharmony_ci u32 flags; 958c2ecf20Sopenharmony_ci unsigned long last_nack; 968c2ecf20Sopenharmony_ci u16 pf_vlan; /* When set, guest VLAN config not allowed. */ 978c2ecf20Sopenharmony_ci u16 pf_qos; 988c2ecf20Sopenharmony_ci u16 tx_rate; 998c2ecf20Sopenharmony_ci bool spoofchk_enabled; 1008c2ecf20Sopenharmony_ci bool trusted; 1018c2ecf20Sopenharmony_ci}; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci/* Number of unicast MAC filters reserved for the PF in the RAR registers */ 1048c2ecf20Sopenharmony_ci#define IGB_PF_MAC_FILTERS_RESERVED 3 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_cistruct vf_mac_filter { 1078c2ecf20Sopenharmony_ci struct list_head l; 1088c2ecf20Sopenharmony_ci int vf; 1098c2ecf20Sopenharmony_ci bool free; 1108c2ecf20Sopenharmony_ci u8 vf_mac[ETH_ALEN]; 1118c2ecf20Sopenharmony_ci}; 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#define IGB_VF_FLAG_CTS 0x00000001 /* VF is clear to send data */ 1148c2ecf20Sopenharmony_ci#define IGB_VF_FLAG_UNI_PROMISC 0x00000002 /* VF has unicast promisc */ 1158c2ecf20Sopenharmony_ci#define IGB_VF_FLAG_MULTI_PROMISC 0x00000004 /* VF has multicast promisc */ 1168c2ecf20Sopenharmony_ci#define IGB_VF_FLAG_PF_SET_MAC 0x00000008 /* PF has set MAC address */ 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci/* RX descriptor control thresholds. 1198c2ecf20Sopenharmony_ci * PTHRESH - MAC will consider prefetch if it has fewer than this number of 1208c2ecf20Sopenharmony_ci * descriptors available in its onboard memory. 1218c2ecf20Sopenharmony_ci * Setting this to 0 disables RX descriptor prefetch. 1228c2ecf20Sopenharmony_ci * HTHRESH - MAC will only prefetch if there are at least this many descriptors 1238c2ecf20Sopenharmony_ci * available in host memory. 1248c2ecf20Sopenharmony_ci * If PTHRESH is 0, this should also be 0. 1258c2ecf20Sopenharmony_ci * WTHRESH - RX descriptor writeback threshold - MAC will delay writing back 1268c2ecf20Sopenharmony_ci * descriptors until either it has this many to write back, or the 1278c2ecf20Sopenharmony_ci * ITR timer expires. 1288c2ecf20Sopenharmony_ci */ 1298c2ecf20Sopenharmony_ci#define IGB_RX_PTHRESH ((hw->mac.type == e1000_i354) ? 12 : 8) 1308c2ecf20Sopenharmony_ci#define IGB_RX_HTHRESH 8 1318c2ecf20Sopenharmony_ci#define IGB_TX_PTHRESH ((hw->mac.type == e1000_i354) ? 20 : 8) 1328c2ecf20Sopenharmony_ci#define IGB_TX_HTHRESH 1 1338c2ecf20Sopenharmony_ci#define IGB_RX_WTHRESH ((hw->mac.type == e1000_82576 && \ 1348c2ecf20Sopenharmony_ci (adapter->flags & IGB_FLAG_HAS_MSIX)) ? 1 : 4) 1358c2ecf20Sopenharmony_ci#define IGB_TX_WTHRESH ((hw->mac.type == e1000_82576 && \ 1368c2ecf20Sopenharmony_ci (adapter->flags & IGB_FLAG_HAS_MSIX)) ? 1 : 16) 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci/* this is the size past which hardware will drop packets when setting LPE=0 */ 1398c2ecf20Sopenharmony_ci#define MAXIMUM_ETHERNET_VLAN_SIZE 1522 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci#define IGB_ETH_PKT_HDR_PAD (ETH_HLEN + ETH_FCS_LEN + (VLAN_HLEN * 2)) 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci/* Supported Rx Buffer Sizes */ 1448c2ecf20Sopenharmony_ci#define IGB_RXBUFFER_256 256 1458c2ecf20Sopenharmony_ci#define IGB_RXBUFFER_1536 1536 1468c2ecf20Sopenharmony_ci#define IGB_RXBUFFER_2048 2048 1478c2ecf20Sopenharmony_ci#define IGB_RXBUFFER_3072 3072 1488c2ecf20Sopenharmony_ci#define IGB_RX_HDR_LEN IGB_RXBUFFER_256 1498c2ecf20Sopenharmony_ci#define IGB_TS_HDR_LEN 16 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci/* Attempt to maximize the headroom available for incoming frames. We 1528c2ecf20Sopenharmony_ci * use a 2K buffer for receives and need 1536/1534 to store the data for 1538c2ecf20Sopenharmony_ci * the frame. This leaves us with 512 bytes of room. From that we need 1548c2ecf20Sopenharmony_ci * to deduct the space needed for the shared info and the padding needed 1558c2ecf20Sopenharmony_ci * to IP align the frame. 1568c2ecf20Sopenharmony_ci * 1578c2ecf20Sopenharmony_ci * Note: For cache line sizes 256 or larger this value is going to end 1588c2ecf20Sopenharmony_ci * up negative. In these cases we should fall back to the 3K 1598c2ecf20Sopenharmony_ci * buffers. 1608c2ecf20Sopenharmony_ci */ 1618c2ecf20Sopenharmony_ci#if (PAGE_SIZE < 8192) 1628c2ecf20Sopenharmony_ci#define IGB_MAX_FRAME_BUILD_SKB (IGB_RXBUFFER_1536 - NET_IP_ALIGN) 1638c2ecf20Sopenharmony_ci#define IGB_2K_TOO_SMALL_WITH_PADDING \ 1648c2ecf20Sopenharmony_ci((NET_SKB_PAD + IGB_TS_HDR_LEN + IGB_RXBUFFER_1536) > SKB_WITH_OVERHEAD(IGB_RXBUFFER_2048)) 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_cistatic inline int igb_compute_pad(int rx_buf_len) 1678c2ecf20Sopenharmony_ci{ 1688c2ecf20Sopenharmony_ci int page_size, pad_size; 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci page_size = ALIGN(rx_buf_len, PAGE_SIZE / 2); 1718c2ecf20Sopenharmony_ci pad_size = SKB_WITH_OVERHEAD(page_size) - rx_buf_len; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci return pad_size; 1748c2ecf20Sopenharmony_ci} 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_cistatic inline int igb_skb_pad(void) 1778c2ecf20Sopenharmony_ci{ 1788c2ecf20Sopenharmony_ci int rx_buf_len; 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci /* If a 2K buffer cannot handle a standard Ethernet frame then 1818c2ecf20Sopenharmony_ci * optimize padding for a 3K buffer instead of a 1.5K buffer. 1828c2ecf20Sopenharmony_ci * 1838c2ecf20Sopenharmony_ci * For a 3K buffer we need to add enough padding to allow for 1848c2ecf20Sopenharmony_ci * tailroom due to NET_IP_ALIGN possibly shifting us out of 1858c2ecf20Sopenharmony_ci * cache-line alignment. 1868c2ecf20Sopenharmony_ci */ 1878c2ecf20Sopenharmony_ci if (IGB_2K_TOO_SMALL_WITH_PADDING) 1888c2ecf20Sopenharmony_ci rx_buf_len = IGB_RXBUFFER_3072 + SKB_DATA_ALIGN(NET_IP_ALIGN); 1898c2ecf20Sopenharmony_ci else 1908c2ecf20Sopenharmony_ci rx_buf_len = IGB_RXBUFFER_1536; 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci /* if needed make room for NET_IP_ALIGN */ 1938c2ecf20Sopenharmony_ci rx_buf_len -= NET_IP_ALIGN; 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci return igb_compute_pad(rx_buf_len); 1968c2ecf20Sopenharmony_ci} 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci#define IGB_SKB_PAD igb_skb_pad() 1998c2ecf20Sopenharmony_ci#else 2008c2ecf20Sopenharmony_ci#define IGB_SKB_PAD (NET_SKB_PAD + NET_IP_ALIGN) 2018c2ecf20Sopenharmony_ci#endif 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci/* How many Rx Buffers do we bundle into one write to the hardware ? */ 2048c2ecf20Sopenharmony_ci#define IGB_RX_BUFFER_WRITE 16 /* Must be power of 2 */ 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci#define IGB_RX_DMA_ATTR \ 2078c2ecf20Sopenharmony_ci (DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING) 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci#define AUTO_ALL_MODES 0 2108c2ecf20Sopenharmony_ci#define IGB_EEPROM_APME 0x0400 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci#ifndef IGB_MASTER_SLAVE 2138c2ecf20Sopenharmony_ci/* Switch to override PHY master/slave setting */ 2148c2ecf20Sopenharmony_ci#define IGB_MASTER_SLAVE e1000_ms_hw_default 2158c2ecf20Sopenharmony_ci#endif 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci#define IGB_MNG_VLAN_NONE -1 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_cienum igb_tx_flags { 2208c2ecf20Sopenharmony_ci /* cmd_type flags */ 2218c2ecf20Sopenharmony_ci IGB_TX_FLAGS_VLAN = 0x01, 2228c2ecf20Sopenharmony_ci IGB_TX_FLAGS_TSO = 0x02, 2238c2ecf20Sopenharmony_ci IGB_TX_FLAGS_TSTAMP = 0x04, 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_ci /* olinfo flags */ 2268c2ecf20Sopenharmony_ci IGB_TX_FLAGS_IPV4 = 0x10, 2278c2ecf20Sopenharmony_ci IGB_TX_FLAGS_CSUM = 0x20, 2288c2ecf20Sopenharmony_ci}; 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci/* VLAN info */ 2318c2ecf20Sopenharmony_ci#define IGB_TX_FLAGS_VLAN_MASK 0xffff0000 2328c2ecf20Sopenharmony_ci#define IGB_TX_FLAGS_VLAN_SHIFT 16 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci/* The largest size we can write to the descriptor is 65535. In order to 2358c2ecf20Sopenharmony_ci * maintain a power of two alignment we have to limit ourselves to 32K. 2368c2ecf20Sopenharmony_ci */ 2378c2ecf20Sopenharmony_ci#define IGB_MAX_TXD_PWR 15 2388c2ecf20Sopenharmony_ci#define IGB_MAX_DATA_PER_TXD (1u << IGB_MAX_TXD_PWR) 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci/* Tx Descriptors needed, worst case */ 2418c2ecf20Sopenharmony_ci#define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IGB_MAX_DATA_PER_TXD) 2428c2ecf20Sopenharmony_ci#define DESC_NEEDED (MAX_SKB_FRAGS + 4) 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci/* EEPROM byte offsets */ 2458c2ecf20Sopenharmony_ci#define IGB_SFF_8472_SWAP 0x5C 2468c2ecf20Sopenharmony_ci#define IGB_SFF_8472_COMP 0x5E 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_ci/* Bitmasks */ 2498c2ecf20Sopenharmony_ci#define IGB_SFF_ADDRESSING_MODE 0x4 2508c2ecf20Sopenharmony_ci#define IGB_SFF_8472_UNSUP 0x00 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci/* TX resources are shared between XDP and netstack 2538c2ecf20Sopenharmony_ci * and we need to tag the buffer type to distinguish them 2548c2ecf20Sopenharmony_ci */ 2558c2ecf20Sopenharmony_cienum igb_tx_buf_type { 2568c2ecf20Sopenharmony_ci IGB_TYPE_SKB = 0, 2578c2ecf20Sopenharmony_ci IGB_TYPE_XDP, 2588c2ecf20Sopenharmony_ci}; 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci/* wrapper around a pointer to a socket buffer, 2618c2ecf20Sopenharmony_ci * so a DMA handle can be stored along with the buffer 2628c2ecf20Sopenharmony_ci */ 2638c2ecf20Sopenharmony_cistruct igb_tx_buffer { 2648c2ecf20Sopenharmony_ci union e1000_adv_tx_desc *next_to_watch; 2658c2ecf20Sopenharmony_ci unsigned long time_stamp; 2668c2ecf20Sopenharmony_ci enum igb_tx_buf_type type; 2678c2ecf20Sopenharmony_ci union { 2688c2ecf20Sopenharmony_ci struct sk_buff *skb; 2698c2ecf20Sopenharmony_ci struct xdp_frame *xdpf; 2708c2ecf20Sopenharmony_ci }; 2718c2ecf20Sopenharmony_ci unsigned int bytecount; 2728c2ecf20Sopenharmony_ci u16 gso_segs; 2738c2ecf20Sopenharmony_ci __be16 protocol; 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci DEFINE_DMA_UNMAP_ADDR(dma); 2768c2ecf20Sopenharmony_ci DEFINE_DMA_UNMAP_LEN(len); 2778c2ecf20Sopenharmony_ci u32 tx_flags; 2788c2ecf20Sopenharmony_ci}; 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_cistruct igb_rx_buffer { 2818c2ecf20Sopenharmony_ci dma_addr_t dma; 2828c2ecf20Sopenharmony_ci struct page *page; 2838c2ecf20Sopenharmony_ci#if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536) 2848c2ecf20Sopenharmony_ci __u32 page_offset; 2858c2ecf20Sopenharmony_ci#else 2868c2ecf20Sopenharmony_ci __u16 page_offset; 2878c2ecf20Sopenharmony_ci#endif 2888c2ecf20Sopenharmony_ci __u16 pagecnt_bias; 2898c2ecf20Sopenharmony_ci}; 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_cistruct igb_tx_queue_stats { 2928c2ecf20Sopenharmony_ci u64 packets; 2938c2ecf20Sopenharmony_ci u64 bytes; 2948c2ecf20Sopenharmony_ci u64 restart_queue; 2958c2ecf20Sopenharmony_ci u64 restart_queue2; 2968c2ecf20Sopenharmony_ci}; 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_cistruct igb_rx_queue_stats { 2998c2ecf20Sopenharmony_ci u64 packets; 3008c2ecf20Sopenharmony_ci u64 bytes; 3018c2ecf20Sopenharmony_ci u64 drops; 3028c2ecf20Sopenharmony_ci u64 csum_err; 3038c2ecf20Sopenharmony_ci u64 alloc_failed; 3048c2ecf20Sopenharmony_ci}; 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_cistruct igb_ring_container { 3078c2ecf20Sopenharmony_ci struct igb_ring *ring; /* pointer to linked list of rings */ 3088c2ecf20Sopenharmony_ci unsigned int total_bytes; /* total bytes processed this int */ 3098c2ecf20Sopenharmony_ci unsigned int total_packets; /* total packets processed this int */ 3108c2ecf20Sopenharmony_ci u16 work_limit; /* total work allowed per interrupt */ 3118c2ecf20Sopenharmony_ci u8 count; /* total number of rings in vector */ 3128c2ecf20Sopenharmony_ci u8 itr; /* current ITR setting for ring */ 3138c2ecf20Sopenharmony_ci}; 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_cistruct igb_ring { 3168c2ecf20Sopenharmony_ci struct igb_q_vector *q_vector; /* backlink to q_vector */ 3178c2ecf20Sopenharmony_ci struct net_device *netdev; /* back pointer to net_device */ 3188c2ecf20Sopenharmony_ci struct bpf_prog *xdp_prog; 3198c2ecf20Sopenharmony_ci struct device *dev; /* device pointer for dma mapping */ 3208c2ecf20Sopenharmony_ci union { /* array of buffer info structs */ 3218c2ecf20Sopenharmony_ci struct igb_tx_buffer *tx_buffer_info; 3228c2ecf20Sopenharmony_ci struct igb_rx_buffer *rx_buffer_info; 3238c2ecf20Sopenharmony_ci }; 3248c2ecf20Sopenharmony_ci void *desc; /* descriptor ring memory */ 3258c2ecf20Sopenharmony_ci unsigned long flags; /* ring specific flags */ 3268c2ecf20Sopenharmony_ci void __iomem *tail; /* pointer to ring tail register */ 3278c2ecf20Sopenharmony_ci dma_addr_t dma; /* phys address of the ring */ 3288c2ecf20Sopenharmony_ci unsigned int size; /* length of desc. ring in bytes */ 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ci u16 count; /* number of desc. in the ring */ 3318c2ecf20Sopenharmony_ci u8 queue_index; /* logical index of the ring*/ 3328c2ecf20Sopenharmony_ci u8 reg_idx; /* physical index of the ring */ 3338c2ecf20Sopenharmony_ci bool launchtime_enable; /* true if LaunchTime is enabled */ 3348c2ecf20Sopenharmony_ci bool cbs_enable; /* indicates if CBS is enabled */ 3358c2ecf20Sopenharmony_ci s32 idleslope; /* idleSlope in kbps */ 3368c2ecf20Sopenharmony_ci s32 sendslope; /* sendSlope in kbps */ 3378c2ecf20Sopenharmony_ci s32 hicredit; /* hiCredit in bytes */ 3388c2ecf20Sopenharmony_ci s32 locredit; /* loCredit in bytes */ 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci /* everything past this point are written often */ 3418c2ecf20Sopenharmony_ci u16 next_to_clean; 3428c2ecf20Sopenharmony_ci u16 next_to_use; 3438c2ecf20Sopenharmony_ci u16 next_to_alloc; 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_ci union { 3468c2ecf20Sopenharmony_ci /* TX */ 3478c2ecf20Sopenharmony_ci struct { 3488c2ecf20Sopenharmony_ci struct igb_tx_queue_stats tx_stats; 3498c2ecf20Sopenharmony_ci struct u64_stats_sync tx_syncp; 3508c2ecf20Sopenharmony_ci struct u64_stats_sync tx_syncp2; 3518c2ecf20Sopenharmony_ci }; 3528c2ecf20Sopenharmony_ci /* RX */ 3538c2ecf20Sopenharmony_ci struct { 3548c2ecf20Sopenharmony_ci struct sk_buff *skb; 3558c2ecf20Sopenharmony_ci struct igb_rx_queue_stats rx_stats; 3568c2ecf20Sopenharmony_ci struct u64_stats_sync rx_syncp; 3578c2ecf20Sopenharmony_ci }; 3588c2ecf20Sopenharmony_ci }; 3598c2ecf20Sopenharmony_ci struct xdp_rxq_info xdp_rxq; 3608c2ecf20Sopenharmony_ci} ____cacheline_internodealigned_in_smp; 3618c2ecf20Sopenharmony_ci 3628c2ecf20Sopenharmony_cistruct igb_q_vector { 3638c2ecf20Sopenharmony_ci struct igb_adapter *adapter; /* backlink */ 3648c2ecf20Sopenharmony_ci int cpu; /* CPU for DCA */ 3658c2ecf20Sopenharmony_ci u32 eims_value; /* EIMS mask value */ 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_ci u16 itr_val; 3688c2ecf20Sopenharmony_ci u8 set_itr; 3698c2ecf20Sopenharmony_ci void __iomem *itr_register; 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci struct igb_ring_container rx, tx; 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_ci struct napi_struct napi; 3748c2ecf20Sopenharmony_ci struct rcu_head rcu; /* to avoid race with update stats on free */ 3758c2ecf20Sopenharmony_ci char name[IFNAMSIZ + 9]; 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ci /* for dynamic allocation of rings associated with this q_vector */ 3788c2ecf20Sopenharmony_ci struct igb_ring ring[] ____cacheline_internodealigned_in_smp; 3798c2ecf20Sopenharmony_ci}; 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_cienum e1000_ring_flags_t { 3828c2ecf20Sopenharmony_ci IGB_RING_FLAG_RX_3K_BUFFER, 3838c2ecf20Sopenharmony_ci IGB_RING_FLAG_RX_BUILD_SKB_ENABLED, 3848c2ecf20Sopenharmony_ci IGB_RING_FLAG_RX_SCTP_CSUM, 3858c2ecf20Sopenharmony_ci IGB_RING_FLAG_RX_LB_VLAN_BSWAP, 3868c2ecf20Sopenharmony_ci IGB_RING_FLAG_TX_CTX_IDX, 3878c2ecf20Sopenharmony_ci IGB_RING_FLAG_TX_DETECT_HANG 3888c2ecf20Sopenharmony_ci}; 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_ci#define ring_uses_large_buffer(ring) \ 3918c2ecf20Sopenharmony_ci test_bit(IGB_RING_FLAG_RX_3K_BUFFER, &(ring)->flags) 3928c2ecf20Sopenharmony_ci#define set_ring_uses_large_buffer(ring) \ 3938c2ecf20Sopenharmony_ci set_bit(IGB_RING_FLAG_RX_3K_BUFFER, &(ring)->flags) 3948c2ecf20Sopenharmony_ci#define clear_ring_uses_large_buffer(ring) \ 3958c2ecf20Sopenharmony_ci clear_bit(IGB_RING_FLAG_RX_3K_BUFFER, &(ring)->flags) 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci#define ring_uses_build_skb(ring) \ 3988c2ecf20Sopenharmony_ci test_bit(IGB_RING_FLAG_RX_BUILD_SKB_ENABLED, &(ring)->flags) 3998c2ecf20Sopenharmony_ci#define set_ring_build_skb_enabled(ring) \ 4008c2ecf20Sopenharmony_ci set_bit(IGB_RING_FLAG_RX_BUILD_SKB_ENABLED, &(ring)->flags) 4018c2ecf20Sopenharmony_ci#define clear_ring_build_skb_enabled(ring) \ 4028c2ecf20Sopenharmony_ci clear_bit(IGB_RING_FLAG_RX_BUILD_SKB_ENABLED, &(ring)->flags) 4038c2ecf20Sopenharmony_ci 4048c2ecf20Sopenharmony_cistatic inline unsigned int igb_rx_bufsz(struct igb_ring *ring) 4058c2ecf20Sopenharmony_ci{ 4068c2ecf20Sopenharmony_ci#if (PAGE_SIZE < 8192) 4078c2ecf20Sopenharmony_ci if (ring_uses_large_buffer(ring)) 4088c2ecf20Sopenharmony_ci return IGB_RXBUFFER_3072; 4098c2ecf20Sopenharmony_ci 4108c2ecf20Sopenharmony_ci if (ring_uses_build_skb(ring)) 4118c2ecf20Sopenharmony_ci return IGB_MAX_FRAME_BUILD_SKB; 4128c2ecf20Sopenharmony_ci#endif 4138c2ecf20Sopenharmony_ci return IGB_RXBUFFER_2048; 4148c2ecf20Sopenharmony_ci} 4158c2ecf20Sopenharmony_ci 4168c2ecf20Sopenharmony_cistatic inline unsigned int igb_rx_pg_order(struct igb_ring *ring) 4178c2ecf20Sopenharmony_ci{ 4188c2ecf20Sopenharmony_ci#if (PAGE_SIZE < 8192) 4198c2ecf20Sopenharmony_ci if (ring_uses_large_buffer(ring)) 4208c2ecf20Sopenharmony_ci return 1; 4218c2ecf20Sopenharmony_ci#endif 4228c2ecf20Sopenharmony_ci return 0; 4238c2ecf20Sopenharmony_ci} 4248c2ecf20Sopenharmony_ci 4258c2ecf20Sopenharmony_ci#define igb_rx_pg_size(_ring) (PAGE_SIZE << igb_rx_pg_order(_ring)) 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_ci#define IGB_TXD_DCMD (E1000_ADVTXD_DCMD_EOP | E1000_ADVTXD_DCMD_RS) 4288c2ecf20Sopenharmony_ci 4298c2ecf20Sopenharmony_ci#define IGB_RX_DESC(R, i) \ 4308c2ecf20Sopenharmony_ci (&(((union e1000_adv_rx_desc *)((R)->desc))[i])) 4318c2ecf20Sopenharmony_ci#define IGB_TX_DESC(R, i) \ 4328c2ecf20Sopenharmony_ci (&(((union e1000_adv_tx_desc *)((R)->desc))[i])) 4338c2ecf20Sopenharmony_ci#define IGB_TX_CTXTDESC(R, i) \ 4348c2ecf20Sopenharmony_ci (&(((struct e1000_adv_tx_context_desc *)((R)->desc))[i])) 4358c2ecf20Sopenharmony_ci 4368c2ecf20Sopenharmony_ci/* igb_test_staterr - tests bits within Rx descriptor status and error fields */ 4378c2ecf20Sopenharmony_cistatic inline __le32 igb_test_staterr(union e1000_adv_rx_desc *rx_desc, 4388c2ecf20Sopenharmony_ci const u32 stat_err_bits) 4398c2ecf20Sopenharmony_ci{ 4408c2ecf20Sopenharmony_ci return rx_desc->wb.upper.status_error & cpu_to_le32(stat_err_bits); 4418c2ecf20Sopenharmony_ci} 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_ci/* igb_desc_unused - calculate if we have unused descriptors */ 4448c2ecf20Sopenharmony_cistatic inline int igb_desc_unused(struct igb_ring *ring) 4458c2ecf20Sopenharmony_ci{ 4468c2ecf20Sopenharmony_ci if (ring->next_to_clean > ring->next_to_use) 4478c2ecf20Sopenharmony_ci return ring->next_to_clean - ring->next_to_use - 1; 4488c2ecf20Sopenharmony_ci 4498c2ecf20Sopenharmony_ci return ring->count + ring->next_to_clean - ring->next_to_use - 1; 4508c2ecf20Sopenharmony_ci} 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_ci#ifdef CONFIG_IGB_HWMON 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_ci#define IGB_HWMON_TYPE_LOC 0 4558c2ecf20Sopenharmony_ci#define IGB_HWMON_TYPE_TEMP 1 4568c2ecf20Sopenharmony_ci#define IGB_HWMON_TYPE_CAUTION 2 4578c2ecf20Sopenharmony_ci#define IGB_HWMON_TYPE_MAX 3 4588c2ecf20Sopenharmony_ci 4598c2ecf20Sopenharmony_cistruct hwmon_attr { 4608c2ecf20Sopenharmony_ci struct device_attribute dev_attr; 4618c2ecf20Sopenharmony_ci struct e1000_hw *hw; 4628c2ecf20Sopenharmony_ci struct e1000_thermal_diode_data *sensor; 4638c2ecf20Sopenharmony_ci char name[12]; 4648c2ecf20Sopenharmony_ci }; 4658c2ecf20Sopenharmony_ci 4668c2ecf20Sopenharmony_cistruct hwmon_buff { 4678c2ecf20Sopenharmony_ci struct attribute_group group; 4688c2ecf20Sopenharmony_ci const struct attribute_group *groups[2]; 4698c2ecf20Sopenharmony_ci struct attribute *attrs[E1000_MAX_SENSORS * 4 + 1]; 4708c2ecf20Sopenharmony_ci struct hwmon_attr hwmon_list[E1000_MAX_SENSORS * 4]; 4718c2ecf20Sopenharmony_ci unsigned int n_hwmon; 4728c2ecf20Sopenharmony_ci }; 4738c2ecf20Sopenharmony_ci#endif 4748c2ecf20Sopenharmony_ci 4758c2ecf20Sopenharmony_ci/* The number of L2 ether-type filter registers, Index 3 is reserved 4768c2ecf20Sopenharmony_ci * for PTP 1588 timestamp 4778c2ecf20Sopenharmony_ci */ 4788c2ecf20Sopenharmony_ci#define MAX_ETYPE_FILTER (4 - 1) 4798c2ecf20Sopenharmony_ci/* ETQF filter list: one static filter per filter consumer. This is 4808c2ecf20Sopenharmony_ci * to avoid filter collisions later. Add new filters here!! 4818c2ecf20Sopenharmony_ci * 4828c2ecf20Sopenharmony_ci * Current filters: Filter 3 4838c2ecf20Sopenharmony_ci */ 4848c2ecf20Sopenharmony_ci#define IGB_ETQF_FILTER_1588 3 4858c2ecf20Sopenharmony_ci 4868c2ecf20Sopenharmony_ci#define IGB_N_EXTTS 2 4878c2ecf20Sopenharmony_ci#define IGB_N_PEROUT 2 4888c2ecf20Sopenharmony_ci#define IGB_N_SDP 4 4898c2ecf20Sopenharmony_ci#define IGB_RETA_SIZE 128 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_cienum igb_filter_match_flags { 4928c2ecf20Sopenharmony_ci IGB_FILTER_FLAG_ETHER_TYPE = 0x1, 4938c2ecf20Sopenharmony_ci IGB_FILTER_FLAG_VLAN_TCI = 0x2, 4948c2ecf20Sopenharmony_ci IGB_FILTER_FLAG_SRC_MAC_ADDR = 0x4, 4958c2ecf20Sopenharmony_ci IGB_FILTER_FLAG_DST_MAC_ADDR = 0x8, 4968c2ecf20Sopenharmony_ci}; 4978c2ecf20Sopenharmony_ci 4988c2ecf20Sopenharmony_ci#define IGB_MAX_RXNFC_FILTERS 16 4998c2ecf20Sopenharmony_ci 5008c2ecf20Sopenharmony_ci/* RX network flow classification data structure */ 5018c2ecf20Sopenharmony_cistruct igb_nfc_input { 5028c2ecf20Sopenharmony_ci /* Byte layout in order, all values with MSB first: 5038c2ecf20Sopenharmony_ci * match_flags - 1 byte 5048c2ecf20Sopenharmony_ci * etype - 2 bytes 5058c2ecf20Sopenharmony_ci * vlan_tci - 2 bytes 5068c2ecf20Sopenharmony_ci */ 5078c2ecf20Sopenharmony_ci u8 match_flags; 5088c2ecf20Sopenharmony_ci __be16 etype; 5098c2ecf20Sopenharmony_ci __be16 vlan_tci; 5108c2ecf20Sopenharmony_ci u8 src_addr[ETH_ALEN]; 5118c2ecf20Sopenharmony_ci u8 dst_addr[ETH_ALEN]; 5128c2ecf20Sopenharmony_ci}; 5138c2ecf20Sopenharmony_ci 5148c2ecf20Sopenharmony_cistruct igb_nfc_filter { 5158c2ecf20Sopenharmony_ci struct hlist_node nfc_node; 5168c2ecf20Sopenharmony_ci struct igb_nfc_input filter; 5178c2ecf20Sopenharmony_ci unsigned long cookie; 5188c2ecf20Sopenharmony_ci u16 etype_reg_index; 5198c2ecf20Sopenharmony_ci u16 sw_idx; 5208c2ecf20Sopenharmony_ci u16 action; 5218c2ecf20Sopenharmony_ci}; 5228c2ecf20Sopenharmony_ci 5238c2ecf20Sopenharmony_cistruct igb_mac_addr { 5248c2ecf20Sopenharmony_ci u8 addr[ETH_ALEN]; 5258c2ecf20Sopenharmony_ci u8 queue; 5268c2ecf20Sopenharmony_ci u8 state; /* bitmask */ 5278c2ecf20Sopenharmony_ci}; 5288c2ecf20Sopenharmony_ci 5298c2ecf20Sopenharmony_ci#define IGB_MAC_STATE_DEFAULT 0x1 5308c2ecf20Sopenharmony_ci#define IGB_MAC_STATE_IN_USE 0x2 5318c2ecf20Sopenharmony_ci#define IGB_MAC_STATE_SRC_ADDR 0x4 5328c2ecf20Sopenharmony_ci#define IGB_MAC_STATE_QUEUE_STEERING 0x8 5338c2ecf20Sopenharmony_ci 5348c2ecf20Sopenharmony_ci/* board specific private data structure */ 5358c2ecf20Sopenharmony_cistruct igb_adapter { 5368c2ecf20Sopenharmony_ci unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 5378c2ecf20Sopenharmony_ci 5388c2ecf20Sopenharmony_ci struct net_device *netdev; 5398c2ecf20Sopenharmony_ci struct bpf_prog *xdp_prog; 5408c2ecf20Sopenharmony_ci 5418c2ecf20Sopenharmony_ci unsigned long state; 5428c2ecf20Sopenharmony_ci unsigned int flags; 5438c2ecf20Sopenharmony_ci 5448c2ecf20Sopenharmony_ci unsigned int num_q_vectors; 5458c2ecf20Sopenharmony_ci struct msix_entry msix_entries[MAX_MSIX_ENTRIES]; 5468c2ecf20Sopenharmony_ci 5478c2ecf20Sopenharmony_ci /* Interrupt Throttle Rate */ 5488c2ecf20Sopenharmony_ci u32 rx_itr_setting; 5498c2ecf20Sopenharmony_ci u32 tx_itr_setting; 5508c2ecf20Sopenharmony_ci u16 tx_itr; 5518c2ecf20Sopenharmony_ci u16 rx_itr; 5528c2ecf20Sopenharmony_ci 5538c2ecf20Sopenharmony_ci /* TX */ 5548c2ecf20Sopenharmony_ci u16 tx_work_limit; 5558c2ecf20Sopenharmony_ci u32 tx_timeout_count; 5568c2ecf20Sopenharmony_ci int num_tx_queues; 5578c2ecf20Sopenharmony_ci struct igb_ring *tx_ring[16]; 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_ci /* RX */ 5608c2ecf20Sopenharmony_ci int num_rx_queues; 5618c2ecf20Sopenharmony_ci struct igb_ring *rx_ring[16]; 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_ci u32 max_frame_size; 5648c2ecf20Sopenharmony_ci u32 min_frame_size; 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_ci struct timer_list watchdog_timer; 5678c2ecf20Sopenharmony_ci struct timer_list phy_info_timer; 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_ci u16 mng_vlan_id; 5708c2ecf20Sopenharmony_ci u32 bd_number; 5718c2ecf20Sopenharmony_ci u32 wol; 5728c2ecf20Sopenharmony_ci u32 en_mng_pt; 5738c2ecf20Sopenharmony_ci u16 link_speed; 5748c2ecf20Sopenharmony_ci u16 link_duplex; 5758c2ecf20Sopenharmony_ci 5768c2ecf20Sopenharmony_ci u8 __iomem *io_addr; /* Mainly for iounmap use */ 5778c2ecf20Sopenharmony_ci 5788c2ecf20Sopenharmony_ci struct work_struct reset_task; 5798c2ecf20Sopenharmony_ci struct work_struct watchdog_task; 5808c2ecf20Sopenharmony_ci bool fc_autoneg; 5818c2ecf20Sopenharmony_ci u8 tx_timeout_factor; 5828c2ecf20Sopenharmony_ci struct timer_list blink_timer; 5838c2ecf20Sopenharmony_ci unsigned long led_status; 5848c2ecf20Sopenharmony_ci 5858c2ecf20Sopenharmony_ci /* OS defined structs */ 5868c2ecf20Sopenharmony_ci struct pci_dev *pdev; 5878c2ecf20Sopenharmony_ci 5888c2ecf20Sopenharmony_ci spinlock_t stats64_lock; 5898c2ecf20Sopenharmony_ci struct rtnl_link_stats64 stats64; 5908c2ecf20Sopenharmony_ci 5918c2ecf20Sopenharmony_ci /* structs defined in e1000_hw.h */ 5928c2ecf20Sopenharmony_ci struct e1000_hw hw; 5938c2ecf20Sopenharmony_ci struct e1000_hw_stats stats; 5948c2ecf20Sopenharmony_ci struct e1000_phy_info phy_info; 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_ci u32 test_icr; 5978c2ecf20Sopenharmony_ci struct igb_ring test_tx_ring; 5988c2ecf20Sopenharmony_ci struct igb_ring test_rx_ring; 5998c2ecf20Sopenharmony_ci 6008c2ecf20Sopenharmony_ci int msg_enable; 6018c2ecf20Sopenharmony_ci 6028c2ecf20Sopenharmony_ci struct igb_q_vector *q_vector[MAX_Q_VECTORS]; 6038c2ecf20Sopenharmony_ci u32 eims_enable_mask; 6048c2ecf20Sopenharmony_ci u32 eims_other; 6058c2ecf20Sopenharmony_ci 6068c2ecf20Sopenharmony_ci /* to not mess up cache alignment, always add to the bottom */ 6078c2ecf20Sopenharmony_ci u16 tx_ring_count; 6088c2ecf20Sopenharmony_ci u16 rx_ring_count; 6098c2ecf20Sopenharmony_ci unsigned int vfs_allocated_count; 6108c2ecf20Sopenharmony_ci struct vf_data_storage *vf_data; 6118c2ecf20Sopenharmony_ci int vf_rate_link_speed; 6128c2ecf20Sopenharmony_ci u32 rss_queues; 6138c2ecf20Sopenharmony_ci u32 wvbr; 6148c2ecf20Sopenharmony_ci u32 *shadow_vfta; 6158c2ecf20Sopenharmony_ci 6168c2ecf20Sopenharmony_ci struct ptp_clock *ptp_clock; 6178c2ecf20Sopenharmony_ci struct ptp_clock_info ptp_caps; 6188c2ecf20Sopenharmony_ci struct delayed_work ptp_overflow_work; 6198c2ecf20Sopenharmony_ci struct work_struct ptp_tx_work; 6208c2ecf20Sopenharmony_ci struct sk_buff *ptp_tx_skb; 6218c2ecf20Sopenharmony_ci struct hwtstamp_config tstamp_config; 6228c2ecf20Sopenharmony_ci unsigned long ptp_tx_start; 6238c2ecf20Sopenharmony_ci unsigned long last_rx_ptp_check; 6248c2ecf20Sopenharmony_ci unsigned long last_rx_timestamp; 6258c2ecf20Sopenharmony_ci unsigned int ptp_flags; 6268c2ecf20Sopenharmony_ci spinlock_t tmreg_lock; 6278c2ecf20Sopenharmony_ci struct cyclecounter cc; 6288c2ecf20Sopenharmony_ci struct timecounter tc; 6298c2ecf20Sopenharmony_ci u32 tx_hwtstamp_timeouts; 6308c2ecf20Sopenharmony_ci u32 tx_hwtstamp_skipped; 6318c2ecf20Sopenharmony_ci u32 rx_hwtstamp_cleared; 6328c2ecf20Sopenharmony_ci bool pps_sys_wrap_on; 6338c2ecf20Sopenharmony_ci 6348c2ecf20Sopenharmony_ci struct ptp_pin_desc sdp_config[IGB_N_SDP]; 6358c2ecf20Sopenharmony_ci struct { 6368c2ecf20Sopenharmony_ci struct timespec64 start; 6378c2ecf20Sopenharmony_ci struct timespec64 period; 6388c2ecf20Sopenharmony_ci } perout[IGB_N_PEROUT]; 6398c2ecf20Sopenharmony_ci 6408c2ecf20Sopenharmony_ci char fw_version[32]; 6418c2ecf20Sopenharmony_ci#ifdef CONFIG_IGB_HWMON 6428c2ecf20Sopenharmony_ci struct hwmon_buff *igb_hwmon_buff; 6438c2ecf20Sopenharmony_ci bool ets; 6448c2ecf20Sopenharmony_ci#endif 6458c2ecf20Sopenharmony_ci struct i2c_algo_bit_data i2c_algo; 6468c2ecf20Sopenharmony_ci struct i2c_adapter i2c_adap; 6478c2ecf20Sopenharmony_ci struct i2c_client *i2c_client; 6488c2ecf20Sopenharmony_ci u32 rss_indir_tbl_init; 6498c2ecf20Sopenharmony_ci u8 rss_indir_tbl[IGB_RETA_SIZE]; 6508c2ecf20Sopenharmony_ci 6518c2ecf20Sopenharmony_ci unsigned long link_check_timeout; 6528c2ecf20Sopenharmony_ci int copper_tries; 6538c2ecf20Sopenharmony_ci struct e1000_info ei; 6548c2ecf20Sopenharmony_ci u16 eee_advert; 6558c2ecf20Sopenharmony_ci 6568c2ecf20Sopenharmony_ci /* RX network flow classification support */ 6578c2ecf20Sopenharmony_ci struct hlist_head nfc_filter_list; 6588c2ecf20Sopenharmony_ci struct hlist_head cls_flower_list; 6598c2ecf20Sopenharmony_ci unsigned int nfc_filter_count; 6608c2ecf20Sopenharmony_ci /* lock for RX network flow classification filter */ 6618c2ecf20Sopenharmony_ci spinlock_t nfc_lock; 6628c2ecf20Sopenharmony_ci bool etype_bitmap[MAX_ETYPE_FILTER]; 6638c2ecf20Sopenharmony_ci 6648c2ecf20Sopenharmony_ci struct igb_mac_addr *mac_table; 6658c2ecf20Sopenharmony_ci struct vf_mac_filter vf_macs; 6668c2ecf20Sopenharmony_ci struct vf_mac_filter *vf_mac_list; 6678c2ecf20Sopenharmony_ci /* lock for VF resources */ 6688c2ecf20Sopenharmony_ci spinlock_t vfs_lock; 6698c2ecf20Sopenharmony_ci}; 6708c2ecf20Sopenharmony_ci 6718c2ecf20Sopenharmony_ci/* flags controlling PTP/1588 function */ 6728c2ecf20Sopenharmony_ci#define IGB_PTP_ENABLED BIT(0) 6738c2ecf20Sopenharmony_ci#define IGB_PTP_OVERFLOW_CHECK BIT(1) 6748c2ecf20Sopenharmony_ci 6758c2ecf20Sopenharmony_ci#define IGB_FLAG_HAS_MSI BIT(0) 6768c2ecf20Sopenharmony_ci#define IGB_FLAG_DCA_ENABLED BIT(1) 6778c2ecf20Sopenharmony_ci#define IGB_FLAG_QUAD_PORT_A BIT(2) 6788c2ecf20Sopenharmony_ci#define IGB_FLAG_QUEUE_PAIRS BIT(3) 6798c2ecf20Sopenharmony_ci#define IGB_FLAG_DMAC BIT(4) 6808c2ecf20Sopenharmony_ci#define IGB_FLAG_RSS_FIELD_IPV4_UDP BIT(6) 6818c2ecf20Sopenharmony_ci#define IGB_FLAG_RSS_FIELD_IPV6_UDP BIT(7) 6828c2ecf20Sopenharmony_ci#define IGB_FLAG_WOL_SUPPORTED BIT(8) 6838c2ecf20Sopenharmony_ci#define IGB_FLAG_NEED_LINK_UPDATE BIT(9) 6848c2ecf20Sopenharmony_ci#define IGB_FLAG_MEDIA_RESET BIT(10) 6858c2ecf20Sopenharmony_ci#define IGB_FLAG_MAS_CAPABLE BIT(11) 6868c2ecf20Sopenharmony_ci#define IGB_FLAG_MAS_ENABLE BIT(12) 6878c2ecf20Sopenharmony_ci#define IGB_FLAG_HAS_MSIX BIT(13) 6888c2ecf20Sopenharmony_ci#define IGB_FLAG_EEE BIT(14) 6898c2ecf20Sopenharmony_ci#define IGB_FLAG_VLAN_PROMISC BIT(15) 6908c2ecf20Sopenharmony_ci#define IGB_FLAG_RX_LEGACY BIT(16) 6918c2ecf20Sopenharmony_ci#define IGB_FLAG_FQTSS BIT(17) 6928c2ecf20Sopenharmony_ci 6938c2ecf20Sopenharmony_ci/* Media Auto Sense */ 6948c2ecf20Sopenharmony_ci#define IGB_MAS_ENABLE_0 0X0001 6958c2ecf20Sopenharmony_ci#define IGB_MAS_ENABLE_1 0X0002 6968c2ecf20Sopenharmony_ci#define IGB_MAS_ENABLE_2 0X0004 6978c2ecf20Sopenharmony_ci#define IGB_MAS_ENABLE_3 0X0008 6988c2ecf20Sopenharmony_ci 6998c2ecf20Sopenharmony_ci/* DMA Coalescing defines */ 7008c2ecf20Sopenharmony_ci#define IGB_MIN_TXPBSIZE 20408 7018c2ecf20Sopenharmony_ci#define IGB_TX_BUF_4096 4096 7028c2ecf20Sopenharmony_ci#define IGB_DMCTLX_DCFLUSH_DIS 0x80000000 /* Disable DMA Coal Flush */ 7038c2ecf20Sopenharmony_ci 7048c2ecf20Sopenharmony_ci#define IGB_82576_TSYNC_SHIFT 19 7058c2ecf20Sopenharmony_cienum e1000_state_t { 7068c2ecf20Sopenharmony_ci __IGB_TESTING, 7078c2ecf20Sopenharmony_ci __IGB_RESETTING, 7088c2ecf20Sopenharmony_ci __IGB_DOWN, 7098c2ecf20Sopenharmony_ci __IGB_PTP_TX_IN_PROGRESS, 7108c2ecf20Sopenharmony_ci}; 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_cienum igb_boards { 7138c2ecf20Sopenharmony_ci board_82575, 7148c2ecf20Sopenharmony_ci}; 7158c2ecf20Sopenharmony_ci 7168c2ecf20Sopenharmony_ciextern char igb_driver_name[]; 7178c2ecf20Sopenharmony_ci 7188c2ecf20Sopenharmony_ciint igb_xmit_xdp_ring(struct igb_adapter *adapter, 7198c2ecf20Sopenharmony_ci struct igb_ring *ring, 7208c2ecf20Sopenharmony_ci struct xdp_frame *xdpf); 7218c2ecf20Sopenharmony_ciint igb_open(struct net_device *netdev); 7228c2ecf20Sopenharmony_ciint igb_close(struct net_device *netdev); 7238c2ecf20Sopenharmony_ciint igb_up(struct igb_adapter *); 7248c2ecf20Sopenharmony_civoid igb_down(struct igb_adapter *); 7258c2ecf20Sopenharmony_civoid igb_reinit_locked(struct igb_adapter *); 7268c2ecf20Sopenharmony_civoid igb_reset(struct igb_adapter *); 7278c2ecf20Sopenharmony_ciint igb_reinit_queues(struct igb_adapter *); 7288c2ecf20Sopenharmony_civoid igb_write_rss_indir_tbl(struct igb_adapter *); 7298c2ecf20Sopenharmony_ciint igb_set_spd_dplx(struct igb_adapter *, u32, u8); 7308c2ecf20Sopenharmony_ciint igb_setup_tx_resources(struct igb_ring *); 7318c2ecf20Sopenharmony_ciint igb_setup_rx_resources(struct igb_ring *); 7328c2ecf20Sopenharmony_civoid igb_free_tx_resources(struct igb_ring *); 7338c2ecf20Sopenharmony_civoid igb_free_rx_resources(struct igb_ring *); 7348c2ecf20Sopenharmony_civoid igb_configure_tx_ring(struct igb_adapter *, struct igb_ring *); 7358c2ecf20Sopenharmony_civoid igb_configure_rx_ring(struct igb_adapter *, struct igb_ring *); 7368c2ecf20Sopenharmony_civoid igb_setup_tctl(struct igb_adapter *); 7378c2ecf20Sopenharmony_civoid igb_setup_rctl(struct igb_adapter *); 7388c2ecf20Sopenharmony_civoid igb_setup_srrctl(struct igb_adapter *, struct igb_ring *); 7398c2ecf20Sopenharmony_cinetdev_tx_t igb_xmit_frame_ring(struct sk_buff *, struct igb_ring *); 7408c2ecf20Sopenharmony_civoid igb_alloc_rx_buffers(struct igb_ring *, u16); 7418c2ecf20Sopenharmony_civoid igb_update_stats(struct igb_adapter *); 7428c2ecf20Sopenharmony_cibool igb_has_link(struct igb_adapter *adapter); 7438c2ecf20Sopenharmony_civoid igb_set_ethtool_ops(struct net_device *); 7448c2ecf20Sopenharmony_civoid igb_power_up_link(struct igb_adapter *); 7458c2ecf20Sopenharmony_civoid igb_set_fw_version(struct igb_adapter *); 7468c2ecf20Sopenharmony_civoid igb_ptp_init(struct igb_adapter *adapter); 7478c2ecf20Sopenharmony_civoid igb_ptp_stop(struct igb_adapter *adapter); 7488c2ecf20Sopenharmony_civoid igb_ptp_reset(struct igb_adapter *adapter); 7498c2ecf20Sopenharmony_civoid igb_ptp_suspend(struct igb_adapter *adapter); 7508c2ecf20Sopenharmony_civoid igb_ptp_rx_hang(struct igb_adapter *adapter); 7518c2ecf20Sopenharmony_civoid igb_ptp_tx_hang(struct igb_adapter *adapter); 7528c2ecf20Sopenharmony_civoid igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector, struct sk_buff *skb); 7538c2ecf20Sopenharmony_ciint igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, void *va, 7548c2ecf20Sopenharmony_ci struct sk_buff *skb); 7558c2ecf20Sopenharmony_ciint igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr); 7568c2ecf20Sopenharmony_ciint igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr); 7578c2ecf20Sopenharmony_civoid igb_set_flag_queue_pairs(struct igb_adapter *, const u32); 7588c2ecf20Sopenharmony_ciunsigned int igb_get_max_rss_queues(struct igb_adapter *); 7598c2ecf20Sopenharmony_ci#ifdef CONFIG_IGB_HWMON 7608c2ecf20Sopenharmony_civoid igb_sysfs_exit(struct igb_adapter *adapter); 7618c2ecf20Sopenharmony_ciint igb_sysfs_init(struct igb_adapter *adapter); 7628c2ecf20Sopenharmony_ci#endif 7638c2ecf20Sopenharmony_cistatic inline s32 igb_reset_phy(struct e1000_hw *hw) 7648c2ecf20Sopenharmony_ci{ 7658c2ecf20Sopenharmony_ci if (hw->phy.ops.reset) 7668c2ecf20Sopenharmony_ci return hw->phy.ops.reset(hw); 7678c2ecf20Sopenharmony_ci 7688c2ecf20Sopenharmony_ci return 0; 7698c2ecf20Sopenharmony_ci} 7708c2ecf20Sopenharmony_ci 7718c2ecf20Sopenharmony_cistatic inline s32 igb_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data) 7728c2ecf20Sopenharmony_ci{ 7738c2ecf20Sopenharmony_ci if (hw->phy.ops.read_reg) 7748c2ecf20Sopenharmony_ci return hw->phy.ops.read_reg(hw, offset, data); 7758c2ecf20Sopenharmony_ci 7768c2ecf20Sopenharmony_ci return 0; 7778c2ecf20Sopenharmony_ci} 7788c2ecf20Sopenharmony_ci 7798c2ecf20Sopenharmony_cistatic inline s32 igb_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data) 7808c2ecf20Sopenharmony_ci{ 7818c2ecf20Sopenharmony_ci if (hw->phy.ops.write_reg) 7828c2ecf20Sopenharmony_ci return hw->phy.ops.write_reg(hw, offset, data); 7838c2ecf20Sopenharmony_ci 7848c2ecf20Sopenharmony_ci return 0; 7858c2ecf20Sopenharmony_ci} 7868c2ecf20Sopenharmony_ci 7878c2ecf20Sopenharmony_cistatic inline s32 igb_get_phy_info(struct e1000_hw *hw) 7888c2ecf20Sopenharmony_ci{ 7898c2ecf20Sopenharmony_ci if (hw->phy.ops.get_phy_info) 7908c2ecf20Sopenharmony_ci return hw->phy.ops.get_phy_info(hw); 7918c2ecf20Sopenharmony_ci 7928c2ecf20Sopenharmony_ci return 0; 7938c2ecf20Sopenharmony_ci} 7948c2ecf20Sopenharmony_ci 7958c2ecf20Sopenharmony_cistatic inline struct netdev_queue *txring_txq(const struct igb_ring *tx_ring) 7968c2ecf20Sopenharmony_ci{ 7978c2ecf20Sopenharmony_ci return netdev_get_tx_queue(tx_ring->netdev, tx_ring->queue_index); 7988c2ecf20Sopenharmony_ci} 7998c2ecf20Sopenharmony_ci 8008c2ecf20Sopenharmony_ciint igb_add_filter(struct igb_adapter *adapter, 8018c2ecf20Sopenharmony_ci struct igb_nfc_filter *input); 8028c2ecf20Sopenharmony_ciint igb_erase_filter(struct igb_adapter *adapter, 8038c2ecf20Sopenharmony_ci struct igb_nfc_filter *input); 8048c2ecf20Sopenharmony_ci 8058c2ecf20Sopenharmony_ciint igb_add_mac_steering_filter(struct igb_adapter *adapter, 8068c2ecf20Sopenharmony_ci const u8 *addr, u8 queue, u8 flags); 8078c2ecf20Sopenharmony_ciint igb_del_mac_steering_filter(struct igb_adapter *adapter, 8088c2ecf20Sopenharmony_ci const u8 *addr, u8 queue, u8 flags); 8098c2ecf20Sopenharmony_ci 8108c2ecf20Sopenharmony_ci#endif /* _IGB_H_ */ 811