18c2ecf20Sopenharmony_ci/* Synopsys DesignWare Core Enterprise Ethernet (XLGMAC) Driver 28c2ecf20Sopenharmony_ci * 38c2ecf20Sopenharmony_ci * Copyright (c) 2017 Synopsys, Inc. (www.synopsys.com) 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * This program is dual-licensed; you may select either version 2 of 68c2ecf20Sopenharmony_ci * the GNU General Public License ("GPL") or BSD license ("BSD"). 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * This Synopsys DWC XLGMAC software driver and associated documentation 98c2ecf20Sopenharmony_ci * (hereinafter the "Software") is an unsupported proprietary work of 108c2ecf20Sopenharmony_ci * Synopsys, Inc. unless otherwise expressly agreed to in writing between 118c2ecf20Sopenharmony_ci * Synopsys and you. The Software IS NOT an item of Licensed Software or a 128c2ecf20Sopenharmony_ci * Licensed Product under any End User Software License Agreement or 138c2ecf20Sopenharmony_ci * Agreement for Licensed Products with Synopsys or any supplement thereto. 148c2ecf20Sopenharmony_ci * Synopsys is a registered trademark of Synopsys, Inc. Other names included 158c2ecf20Sopenharmony_ci * in the SOFTWARE may be the trademarks of their respective owners. 168c2ecf20Sopenharmony_ci */ 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#ifndef __DWC_XLGMAC_H__ 198c2ecf20Sopenharmony_ci#define __DWC_XLGMAC_H__ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#include <linux/dma-mapping.h> 228c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 238c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 248c2ecf20Sopenharmony_ci#include <linux/phy.h> 258c2ecf20Sopenharmony_ci#include <linux/if_vlan.h> 268c2ecf20Sopenharmony_ci#include <linux/bitops.h> 278c2ecf20Sopenharmony_ci#include <linux/timecounter.h> 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define XLGMAC_DRV_NAME "dwc-xlgmac" 308c2ecf20Sopenharmony_ci#define XLGMAC_DRV_VERSION "1.0.0" 318c2ecf20Sopenharmony_ci#define XLGMAC_DRV_DESC "Synopsys DWC XLGMAC Driver" 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci/* Descriptor related parameters */ 348c2ecf20Sopenharmony_ci#define XLGMAC_TX_DESC_CNT 1024 358c2ecf20Sopenharmony_ci#define XLGMAC_TX_DESC_MIN_FREE (XLGMAC_TX_DESC_CNT >> 3) 368c2ecf20Sopenharmony_ci#define XLGMAC_TX_DESC_MAX_PROC (XLGMAC_TX_DESC_CNT >> 1) 378c2ecf20Sopenharmony_ci#define XLGMAC_RX_DESC_CNT 1024 388c2ecf20Sopenharmony_ci#define XLGMAC_RX_DESC_MAX_DIRTY (XLGMAC_RX_DESC_CNT >> 3) 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci/* Descriptors required for maximum contiguous TSO/GSO packet */ 418c2ecf20Sopenharmony_ci#define XLGMAC_TX_MAX_SPLIT ((GSO_MAX_SIZE / XLGMAC_TX_MAX_BUF_SIZE) + 1) 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* Maximum possible descriptors needed for a SKB */ 448c2ecf20Sopenharmony_ci#define XLGMAC_TX_MAX_DESC_NR (MAX_SKB_FRAGS + XLGMAC_TX_MAX_SPLIT + 2) 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define XLGMAC_TX_MAX_BUF_SIZE (0x3fff & ~(64 - 1)) 478c2ecf20Sopenharmony_ci#define XLGMAC_RX_MIN_BUF_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN) 488c2ecf20Sopenharmony_ci#define XLGMAC_RX_BUF_ALIGN 64 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci/* Maximum Size for Splitting the Header Data 518c2ecf20Sopenharmony_ci * Keep in sync with SKB_ALLOC_SIZE 528c2ecf20Sopenharmony_ci * 3'b000: 64 bytes, 3'b001: 128 bytes 538c2ecf20Sopenharmony_ci * 3'b010: 256 bytes, 3'b011: 512 bytes 548c2ecf20Sopenharmony_ci * 3'b100: 1023 bytes , 3'b101'3'b111: Reserved 558c2ecf20Sopenharmony_ci */ 568c2ecf20Sopenharmony_ci#define XLGMAC_SPH_HDSMS_SIZE 3 578c2ecf20Sopenharmony_ci#define XLGMAC_SKB_ALLOC_SIZE 512 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#define XLGMAC_MAX_FIFO 81920 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci#define XLGMAC_MAX_DMA_CHANNELS 16 628c2ecf20Sopenharmony_ci#define XLGMAC_DMA_STOP_TIMEOUT 5 638c2ecf20Sopenharmony_ci#define XLGMAC_DMA_INTERRUPT_MASK 0x31c7 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* Default coalescing parameters */ 668c2ecf20Sopenharmony_ci#define XLGMAC_INIT_DMA_TX_USECS 1000 678c2ecf20Sopenharmony_ci#define XLGMAC_INIT_DMA_TX_FRAMES 25 688c2ecf20Sopenharmony_ci#define XLGMAC_INIT_DMA_RX_USECS 30 698c2ecf20Sopenharmony_ci#define XLGMAC_INIT_DMA_RX_FRAMES 25 708c2ecf20Sopenharmony_ci#define XLGMAC_MAX_DMA_RIWT 0xff 718c2ecf20Sopenharmony_ci#define XLGMAC_MIN_DMA_RIWT 0x01 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci/* Flow control queue count */ 748c2ecf20Sopenharmony_ci#define XLGMAC_MAX_FLOW_CONTROL_QUEUES 8 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci/* System clock is 125 MHz */ 778c2ecf20Sopenharmony_ci#define XLGMAC_SYSCLOCK 125000000 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* Maximum MAC address hash table size (256 bits = 8 bytes) */ 808c2ecf20Sopenharmony_ci#define XLGMAC_MAC_HASH_TABLE_SIZE 8 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci/* Receive Side Scaling */ 838c2ecf20Sopenharmony_ci#define XLGMAC_RSS_HASH_KEY_SIZE 40 848c2ecf20Sopenharmony_ci#define XLGMAC_RSS_MAX_TABLE_SIZE 256 858c2ecf20Sopenharmony_ci#define XLGMAC_RSS_LOOKUP_TABLE_TYPE 0 868c2ecf20Sopenharmony_ci#define XLGMAC_RSS_HASH_KEY_TYPE 1 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define XLGMAC_STD_PACKET_MTU 1500 898c2ecf20Sopenharmony_ci#define XLGMAC_JUMBO_PACKET_MTU 9000 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* Helper macro for descriptor handling 928c2ecf20Sopenharmony_ci * Always use XLGMAC_GET_DESC_DATA to access the descriptor data 938c2ecf20Sopenharmony_ci */ 948c2ecf20Sopenharmony_ci#define XLGMAC_GET_DESC_DATA(ring, idx) ({ \ 958c2ecf20Sopenharmony_ci typeof(ring) _ring = (ring); \ 968c2ecf20Sopenharmony_ci ((_ring)->desc_data_head + \ 978c2ecf20Sopenharmony_ci ((idx) & ((_ring)->dma_desc_count - 1))); \ 988c2ecf20Sopenharmony_ci}) 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci#define XLGMAC_GET_REG_BITS(var, pos, len) ({ \ 1018c2ecf20Sopenharmony_ci typeof(pos) _pos = (pos); \ 1028c2ecf20Sopenharmony_ci typeof(len) _len = (len); \ 1038c2ecf20Sopenharmony_ci ((var) & GENMASK(_pos + _len - 1, _pos)) >> (_pos); \ 1048c2ecf20Sopenharmony_ci}) 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci#define XLGMAC_GET_REG_BITS_LE(var, pos, len) ({ \ 1078c2ecf20Sopenharmony_ci typeof(pos) _pos = (pos); \ 1088c2ecf20Sopenharmony_ci typeof(len) _len = (len); \ 1098c2ecf20Sopenharmony_ci typeof(var) _var = le32_to_cpu((var)); \ 1108c2ecf20Sopenharmony_ci ((_var) & GENMASK(_pos + _len - 1, _pos)) >> (_pos); \ 1118c2ecf20Sopenharmony_ci}) 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#define XLGMAC_SET_REG_BITS(var, pos, len, val) ({ \ 1148c2ecf20Sopenharmony_ci typeof(var) _var = (var); \ 1158c2ecf20Sopenharmony_ci typeof(pos) _pos = (pos); \ 1168c2ecf20Sopenharmony_ci typeof(len) _len = (len); \ 1178c2ecf20Sopenharmony_ci typeof(val) _val = (val); \ 1188c2ecf20Sopenharmony_ci _val = (_val << _pos) & GENMASK(_pos + _len - 1, _pos); \ 1198c2ecf20Sopenharmony_ci _var = (_var & ~GENMASK(_pos + _len - 1, _pos)) | _val; \ 1208c2ecf20Sopenharmony_ci}) 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci#define XLGMAC_SET_REG_BITS_LE(var, pos, len, val) ({ \ 1238c2ecf20Sopenharmony_ci typeof(var) _var = (var); \ 1248c2ecf20Sopenharmony_ci typeof(pos) _pos = (pos); \ 1258c2ecf20Sopenharmony_ci typeof(len) _len = (len); \ 1268c2ecf20Sopenharmony_ci typeof(val) _val = (val); \ 1278c2ecf20Sopenharmony_ci _val = (_val << _pos) & GENMASK(_pos + _len - 1, _pos); \ 1288c2ecf20Sopenharmony_ci _var = (_var & ~GENMASK(_pos + _len - 1, _pos)) | _val; \ 1298c2ecf20Sopenharmony_ci cpu_to_le32(_var); \ 1308c2ecf20Sopenharmony_ci}) 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_cistruct xlgmac_pdata; 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_cienum xlgmac_int { 1358c2ecf20Sopenharmony_ci XLGMAC_INT_DMA_CH_SR_TI, 1368c2ecf20Sopenharmony_ci XLGMAC_INT_DMA_CH_SR_TPS, 1378c2ecf20Sopenharmony_ci XLGMAC_INT_DMA_CH_SR_TBU, 1388c2ecf20Sopenharmony_ci XLGMAC_INT_DMA_CH_SR_RI, 1398c2ecf20Sopenharmony_ci XLGMAC_INT_DMA_CH_SR_RBU, 1408c2ecf20Sopenharmony_ci XLGMAC_INT_DMA_CH_SR_RPS, 1418c2ecf20Sopenharmony_ci XLGMAC_INT_DMA_CH_SR_TI_RI, 1428c2ecf20Sopenharmony_ci XLGMAC_INT_DMA_CH_SR_FBE, 1438c2ecf20Sopenharmony_ci XLGMAC_INT_DMA_ALL, 1448c2ecf20Sopenharmony_ci}; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_cistruct xlgmac_stats { 1478c2ecf20Sopenharmony_ci /* MMC TX counters */ 1488c2ecf20Sopenharmony_ci u64 txoctetcount_gb; 1498c2ecf20Sopenharmony_ci u64 txframecount_gb; 1508c2ecf20Sopenharmony_ci u64 txbroadcastframes_g; 1518c2ecf20Sopenharmony_ci u64 txmulticastframes_g; 1528c2ecf20Sopenharmony_ci u64 tx64octets_gb; 1538c2ecf20Sopenharmony_ci u64 tx65to127octets_gb; 1548c2ecf20Sopenharmony_ci u64 tx128to255octets_gb; 1558c2ecf20Sopenharmony_ci u64 tx256to511octets_gb; 1568c2ecf20Sopenharmony_ci u64 tx512to1023octets_gb; 1578c2ecf20Sopenharmony_ci u64 tx1024tomaxoctets_gb; 1588c2ecf20Sopenharmony_ci u64 txunicastframes_gb; 1598c2ecf20Sopenharmony_ci u64 txmulticastframes_gb; 1608c2ecf20Sopenharmony_ci u64 txbroadcastframes_gb; 1618c2ecf20Sopenharmony_ci u64 txunderflowerror; 1628c2ecf20Sopenharmony_ci u64 txoctetcount_g; 1638c2ecf20Sopenharmony_ci u64 txframecount_g; 1648c2ecf20Sopenharmony_ci u64 txpauseframes; 1658c2ecf20Sopenharmony_ci u64 txvlanframes_g; 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci /* MMC RX counters */ 1688c2ecf20Sopenharmony_ci u64 rxframecount_gb; 1698c2ecf20Sopenharmony_ci u64 rxoctetcount_gb; 1708c2ecf20Sopenharmony_ci u64 rxoctetcount_g; 1718c2ecf20Sopenharmony_ci u64 rxbroadcastframes_g; 1728c2ecf20Sopenharmony_ci u64 rxmulticastframes_g; 1738c2ecf20Sopenharmony_ci u64 rxcrcerror; 1748c2ecf20Sopenharmony_ci u64 rxrunterror; 1758c2ecf20Sopenharmony_ci u64 rxjabbererror; 1768c2ecf20Sopenharmony_ci u64 rxundersize_g; 1778c2ecf20Sopenharmony_ci u64 rxoversize_g; 1788c2ecf20Sopenharmony_ci u64 rx64octets_gb; 1798c2ecf20Sopenharmony_ci u64 rx65to127octets_gb; 1808c2ecf20Sopenharmony_ci u64 rx128to255octets_gb; 1818c2ecf20Sopenharmony_ci u64 rx256to511octets_gb; 1828c2ecf20Sopenharmony_ci u64 rx512to1023octets_gb; 1838c2ecf20Sopenharmony_ci u64 rx1024tomaxoctets_gb; 1848c2ecf20Sopenharmony_ci u64 rxunicastframes_g; 1858c2ecf20Sopenharmony_ci u64 rxlengtherror; 1868c2ecf20Sopenharmony_ci u64 rxoutofrangetype; 1878c2ecf20Sopenharmony_ci u64 rxpauseframes; 1888c2ecf20Sopenharmony_ci u64 rxfifooverflow; 1898c2ecf20Sopenharmony_ci u64 rxvlanframes_gb; 1908c2ecf20Sopenharmony_ci u64 rxwatchdogerror; 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci /* Extra counters */ 1938c2ecf20Sopenharmony_ci u64 tx_tso_packets; 1948c2ecf20Sopenharmony_ci u64 rx_split_header_packets; 1958c2ecf20Sopenharmony_ci u64 tx_process_stopped; 1968c2ecf20Sopenharmony_ci u64 rx_process_stopped; 1978c2ecf20Sopenharmony_ci u64 tx_buffer_unavailable; 1988c2ecf20Sopenharmony_ci u64 rx_buffer_unavailable; 1998c2ecf20Sopenharmony_ci u64 fatal_bus_error; 2008c2ecf20Sopenharmony_ci u64 tx_vlan_packets; 2018c2ecf20Sopenharmony_ci u64 rx_vlan_packets; 2028c2ecf20Sopenharmony_ci u64 napi_poll_isr; 2038c2ecf20Sopenharmony_ci u64 napi_poll_txtimer; 2048c2ecf20Sopenharmony_ci}; 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_cistruct xlgmac_ring_buf { 2078c2ecf20Sopenharmony_ci struct sk_buff *skb; 2088c2ecf20Sopenharmony_ci dma_addr_t skb_dma; 2098c2ecf20Sopenharmony_ci unsigned int skb_len; 2108c2ecf20Sopenharmony_ci}; 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci/* Common Tx and Rx DMA hardware descriptor */ 2138c2ecf20Sopenharmony_cistruct xlgmac_dma_desc { 2148c2ecf20Sopenharmony_ci __le32 desc0; 2158c2ecf20Sopenharmony_ci __le32 desc1; 2168c2ecf20Sopenharmony_ci __le32 desc2; 2178c2ecf20Sopenharmony_ci __le32 desc3; 2188c2ecf20Sopenharmony_ci}; 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci/* Page allocation related values */ 2218c2ecf20Sopenharmony_cistruct xlgmac_page_alloc { 2228c2ecf20Sopenharmony_ci struct page *pages; 2238c2ecf20Sopenharmony_ci unsigned int pages_len; 2248c2ecf20Sopenharmony_ci unsigned int pages_offset; 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci dma_addr_t pages_dma; 2278c2ecf20Sopenharmony_ci}; 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci/* Ring entry buffer data */ 2308c2ecf20Sopenharmony_cistruct xlgmac_buffer_data { 2318c2ecf20Sopenharmony_ci struct xlgmac_page_alloc pa; 2328c2ecf20Sopenharmony_ci struct xlgmac_page_alloc pa_unmap; 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci dma_addr_t dma_base; 2358c2ecf20Sopenharmony_ci unsigned long dma_off; 2368c2ecf20Sopenharmony_ci unsigned int dma_len; 2378c2ecf20Sopenharmony_ci}; 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci/* Tx-related desc data */ 2408c2ecf20Sopenharmony_cistruct xlgmac_tx_desc_data { 2418c2ecf20Sopenharmony_ci unsigned int packets; /* BQL packet count */ 2428c2ecf20Sopenharmony_ci unsigned int bytes; /* BQL byte count */ 2438c2ecf20Sopenharmony_ci}; 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci/* Rx-related desc data */ 2468c2ecf20Sopenharmony_cistruct xlgmac_rx_desc_data { 2478c2ecf20Sopenharmony_ci struct xlgmac_buffer_data hdr; /* Header locations */ 2488c2ecf20Sopenharmony_ci struct xlgmac_buffer_data buf; /* Payload locations */ 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci unsigned short hdr_len; /* Length of received header */ 2518c2ecf20Sopenharmony_ci unsigned short len; /* Length of received packet */ 2528c2ecf20Sopenharmony_ci}; 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_cistruct xlgmac_pkt_info { 2558c2ecf20Sopenharmony_ci struct sk_buff *skb; 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci unsigned int attributes; 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci unsigned int errors; 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci /* descriptors needed for this packet */ 2628c2ecf20Sopenharmony_ci unsigned int desc_count; 2638c2ecf20Sopenharmony_ci unsigned int length; 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci unsigned int tx_packets; 2668c2ecf20Sopenharmony_ci unsigned int tx_bytes; 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci unsigned int header_len; 2698c2ecf20Sopenharmony_ci unsigned int tcp_header_len; 2708c2ecf20Sopenharmony_ci unsigned int tcp_payload_len; 2718c2ecf20Sopenharmony_ci unsigned short mss; 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci unsigned short vlan_ctag; 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci u64 rx_tstamp; 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci u32 rss_hash; 2788c2ecf20Sopenharmony_ci enum pkt_hash_types rss_hash_type; 2798c2ecf20Sopenharmony_ci}; 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_cistruct xlgmac_desc_data { 2828c2ecf20Sopenharmony_ci /* dma_desc: Virtual address of descriptor 2838c2ecf20Sopenharmony_ci * dma_desc_addr: DMA address of descriptor 2848c2ecf20Sopenharmony_ci */ 2858c2ecf20Sopenharmony_ci struct xlgmac_dma_desc *dma_desc; 2868c2ecf20Sopenharmony_ci dma_addr_t dma_desc_addr; 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci /* skb: Virtual address of SKB 2898c2ecf20Sopenharmony_ci * skb_dma: DMA address of SKB data 2908c2ecf20Sopenharmony_ci * skb_dma_len: Length of SKB DMA area 2918c2ecf20Sopenharmony_ci */ 2928c2ecf20Sopenharmony_ci struct sk_buff *skb; 2938c2ecf20Sopenharmony_ci dma_addr_t skb_dma; 2948c2ecf20Sopenharmony_ci unsigned int skb_dma_len; 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_ci /* Tx/Rx -related data */ 2978c2ecf20Sopenharmony_ci struct xlgmac_tx_desc_data tx; 2988c2ecf20Sopenharmony_ci struct xlgmac_rx_desc_data rx; 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci unsigned int mapped_as_page; 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_ci /* Incomplete receive save location. If the budget is exhausted 3038c2ecf20Sopenharmony_ci * or the last descriptor (last normal descriptor or a following 3048c2ecf20Sopenharmony_ci * context descriptor) has not been DMA'd yet the current state 3058c2ecf20Sopenharmony_ci * of the receive processing needs to be saved. 3068c2ecf20Sopenharmony_ci */ 3078c2ecf20Sopenharmony_ci unsigned int state_saved; 3088c2ecf20Sopenharmony_ci struct { 3098c2ecf20Sopenharmony_ci struct sk_buff *skb; 3108c2ecf20Sopenharmony_ci unsigned int len; 3118c2ecf20Sopenharmony_ci unsigned int error; 3128c2ecf20Sopenharmony_ci } state; 3138c2ecf20Sopenharmony_ci}; 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_cistruct xlgmac_ring { 3168c2ecf20Sopenharmony_ci /* Per packet related information */ 3178c2ecf20Sopenharmony_ci struct xlgmac_pkt_info pkt_info; 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ci /* Virtual/DMA addresses of DMA descriptor list and the total count */ 3208c2ecf20Sopenharmony_ci struct xlgmac_dma_desc *dma_desc_head; 3218c2ecf20Sopenharmony_ci dma_addr_t dma_desc_head_addr; 3228c2ecf20Sopenharmony_ci unsigned int dma_desc_count; 3238c2ecf20Sopenharmony_ci 3248c2ecf20Sopenharmony_ci /* Array of descriptor data corresponding the DMA descriptor 3258c2ecf20Sopenharmony_ci * (always use the XLGMAC_GET_DESC_DATA macro to access this data) 3268c2ecf20Sopenharmony_ci */ 3278c2ecf20Sopenharmony_ci struct xlgmac_desc_data *desc_data_head; 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ci /* Page allocation for RX buffers */ 3308c2ecf20Sopenharmony_ci struct xlgmac_page_alloc rx_hdr_pa; 3318c2ecf20Sopenharmony_ci struct xlgmac_page_alloc rx_buf_pa; 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci /* Ring index values 3348c2ecf20Sopenharmony_ci * cur - Tx: index of descriptor to be used for current transfer 3358c2ecf20Sopenharmony_ci * Rx: index of descriptor to check for packet availability 3368c2ecf20Sopenharmony_ci * dirty - Tx: index of descriptor to check for transfer complete 3378c2ecf20Sopenharmony_ci * Rx: index of descriptor to check for buffer reallocation 3388c2ecf20Sopenharmony_ci */ 3398c2ecf20Sopenharmony_ci unsigned int cur; 3408c2ecf20Sopenharmony_ci unsigned int dirty; 3418c2ecf20Sopenharmony_ci 3428c2ecf20Sopenharmony_ci /* Coalesce frame count used for interrupt bit setting */ 3438c2ecf20Sopenharmony_ci unsigned int coalesce_count; 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_ci union { 3468c2ecf20Sopenharmony_ci struct { 3478c2ecf20Sopenharmony_ci unsigned int xmit_more; 3488c2ecf20Sopenharmony_ci unsigned int queue_stopped; 3498c2ecf20Sopenharmony_ci unsigned short cur_mss; 3508c2ecf20Sopenharmony_ci unsigned short cur_vlan_ctag; 3518c2ecf20Sopenharmony_ci } tx; 3528c2ecf20Sopenharmony_ci }; 3538c2ecf20Sopenharmony_ci} ____cacheline_aligned; 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_cistruct xlgmac_channel { 3568c2ecf20Sopenharmony_ci char name[16]; 3578c2ecf20Sopenharmony_ci 3588c2ecf20Sopenharmony_ci /* Address of private data area for device */ 3598c2ecf20Sopenharmony_ci struct xlgmac_pdata *pdata; 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci /* Queue index and base address of queue's DMA registers */ 3628c2ecf20Sopenharmony_ci unsigned int queue_index; 3638c2ecf20Sopenharmony_ci void __iomem *dma_regs; 3648c2ecf20Sopenharmony_ci 3658c2ecf20Sopenharmony_ci /* Per channel interrupt irq number */ 3668c2ecf20Sopenharmony_ci int dma_irq; 3678c2ecf20Sopenharmony_ci char dma_irq_name[IFNAMSIZ + 32]; 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ci /* Netdev related settings */ 3708c2ecf20Sopenharmony_ci struct napi_struct napi; 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_ci unsigned int saved_ier; 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_ci unsigned int tx_timer_active; 3758c2ecf20Sopenharmony_ci struct timer_list tx_timer; 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ci struct xlgmac_ring *tx_ring; 3788c2ecf20Sopenharmony_ci struct xlgmac_ring *rx_ring; 3798c2ecf20Sopenharmony_ci} ____cacheline_aligned; 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_cistruct xlgmac_desc_ops { 3828c2ecf20Sopenharmony_ci int (*alloc_channles_and_rings)(struct xlgmac_pdata *pdata); 3838c2ecf20Sopenharmony_ci void (*free_channels_and_rings)(struct xlgmac_pdata *pdata); 3848c2ecf20Sopenharmony_ci int (*map_tx_skb)(struct xlgmac_channel *channel, 3858c2ecf20Sopenharmony_ci struct sk_buff *skb); 3868c2ecf20Sopenharmony_ci int (*map_rx_buffer)(struct xlgmac_pdata *pdata, 3878c2ecf20Sopenharmony_ci struct xlgmac_ring *ring, 3888c2ecf20Sopenharmony_ci struct xlgmac_desc_data *desc_data); 3898c2ecf20Sopenharmony_ci void (*unmap_desc_data)(struct xlgmac_pdata *pdata, 3908c2ecf20Sopenharmony_ci struct xlgmac_desc_data *desc_data); 3918c2ecf20Sopenharmony_ci void (*tx_desc_init)(struct xlgmac_pdata *pdata); 3928c2ecf20Sopenharmony_ci void (*rx_desc_init)(struct xlgmac_pdata *pdata); 3938c2ecf20Sopenharmony_ci}; 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_cistruct xlgmac_hw_ops { 3968c2ecf20Sopenharmony_ci int (*init)(struct xlgmac_pdata *pdata); 3978c2ecf20Sopenharmony_ci int (*exit)(struct xlgmac_pdata *pdata); 3988c2ecf20Sopenharmony_ci 3998c2ecf20Sopenharmony_ci int (*tx_complete)(struct xlgmac_dma_desc *dma_desc); 4008c2ecf20Sopenharmony_ci 4018c2ecf20Sopenharmony_ci void (*enable_tx)(struct xlgmac_pdata *pdata); 4028c2ecf20Sopenharmony_ci void (*disable_tx)(struct xlgmac_pdata *pdata); 4038c2ecf20Sopenharmony_ci void (*enable_rx)(struct xlgmac_pdata *pdata); 4048c2ecf20Sopenharmony_ci void (*disable_rx)(struct xlgmac_pdata *pdata); 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci int (*enable_int)(struct xlgmac_channel *channel, 4078c2ecf20Sopenharmony_ci enum xlgmac_int int_id); 4088c2ecf20Sopenharmony_ci int (*disable_int)(struct xlgmac_channel *channel, 4098c2ecf20Sopenharmony_ci enum xlgmac_int int_id); 4108c2ecf20Sopenharmony_ci void (*dev_xmit)(struct xlgmac_channel *channel); 4118c2ecf20Sopenharmony_ci int (*dev_read)(struct xlgmac_channel *channel); 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_ci int (*set_mac_address)(struct xlgmac_pdata *pdata, u8 *addr); 4148c2ecf20Sopenharmony_ci int (*config_rx_mode)(struct xlgmac_pdata *pdata); 4158c2ecf20Sopenharmony_ci int (*enable_rx_csum)(struct xlgmac_pdata *pdata); 4168c2ecf20Sopenharmony_ci int (*disable_rx_csum)(struct xlgmac_pdata *pdata); 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci /* For MII speed configuration */ 4198c2ecf20Sopenharmony_ci int (*set_xlgmii_25000_speed)(struct xlgmac_pdata *pdata); 4208c2ecf20Sopenharmony_ci int (*set_xlgmii_40000_speed)(struct xlgmac_pdata *pdata); 4218c2ecf20Sopenharmony_ci int (*set_xlgmii_50000_speed)(struct xlgmac_pdata *pdata); 4228c2ecf20Sopenharmony_ci int (*set_xlgmii_100000_speed)(struct xlgmac_pdata *pdata); 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_ci /* For descriptor related operation */ 4258c2ecf20Sopenharmony_ci void (*tx_desc_init)(struct xlgmac_channel *channel); 4268c2ecf20Sopenharmony_ci void (*rx_desc_init)(struct xlgmac_channel *channel); 4278c2ecf20Sopenharmony_ci void (*tx_desc_reset)(struct xlgmac_desc_data *desc_data); 4288c2ecf20Sopenharmony_ci void (*rx_desc_reset)(struct xlgmac_pdata *pdata, 4298c2ecf20Sopenharmony_ci struct xlgmac_desc_data *desc_data, 4308c2ecf20Sopenharmony_ci unsigned int index); 4318c2ecf20Sopenharmony_ci int (*is_last_desc)(struct xlgmac_dma_desc *dma_desc); 4328c2ecf20Sopenharmony_ci int (*is_context_desc)(struct xlgmac_dma_desc *dma_desc); 4338c2ecf20Sopenharmony_ci void (*tx_start_xmit)(struct xlgmac_channel *channel, 4348c2ecf20Sopenharmony_ci struct xlgmac_ring *ring); 4358c2ecf20Sopenharmony_ci 4368c2ecf20Sopenharmony_ci /* For Flow Control */ 4378c2ecf20Sopenharmony_ci int (*config_tx_flow_control)(struct xlgmac_pdata *pdata); 4388c2ecf20Sopenharmony_ci int (*config_rx_flow_control)(struct xlgmac_pdata *pdata); 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_ci /* For Vlan related config */ 4418c2ecf20Sopenharmony_ci int (*enable_rx_vlan_stripping)(struct xlgmac_pdata *pdata); 4428c2ecf20Sopenharmony_ci int (*disable_rx_vlan_stripping)(struct xlgmac_pdata *pdata); 4438c2ecf20Sopenharmony_ci int (*enable_rx_vlan_filtering)(struct xlgmac_pdata *pdata); 4448c2ecf20Sopenharmony_ci int (*disable_rx_vlan_filtering)(struct xlgmac_pdata *pdata); 4458c2ecf20Sopenharmony_ci int (*update_vlan_hash_table)(struct xlgmac_pdata *pdata); 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_ci /* For RX coalescing */ 4488c2ecf20Sopenharmony_ci int (*config_rx_coalesce)(struct xlgmac_pdata *pdata); 4498c2ecf20Sopenharmony_ci int (*config_tx_coalesce)(struct xlgmac_pdata *pdata); 4508c2ecf20Sopenharmony_ci unsigned int (*usec_to_riwt)(struct xlgmac_pdata *pdata, 4518c2ecf20Sopenharmony_ci unsigned int usec); 4528c2ecf20Sopenharmony_ci unsigned int (*riwt_to_usec)(struct xlgmac_pdata *pdata, 4538c2ecf20Sopenharmony_ci unsigned int riwt); 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci /* For RX and TX threshold config */ 4568c2ecf20Sopenharmony_ci int (*config_rx_threshold)(struct xlgmac_pdata *pdata, 4578c2ecf20Sopenharmony_ci unsigned int val); 4588c2ecf20Sopenharmony_ci int (*config_tx_threshold)(struct xlgmac_pdata *pdata, 4598c2ecf20Sopenharmony_ci unsigned int val); 4608c2ecf20Sopenharmony_ci 4618c2ecf20Sopenharmony_ci /* For RX and TX Store and Forward Mode config */ 4628c2ecf20Sopenharmony_ci int (*config_rsf_mode)(struct xlgmac_pdata *pdata, 4638c2ecf20Sopenharmony_ci unsigned int val); 4648c2ecf20Sopenharmony_ci int (*config_tsf_mode)(struct xlgmac_pdata *pdata, 4658c2ecf20Sopenharmony_ci unsigned int val); 4668c2ecf20Sopenharmony_ci 4678c2ecf20Sopenharmony_ci /* For TX DMA Operate on Second Frame config */ 4688c2ecf20Sopenharmony_ci int (*config_osp_mode)(struct xlgmac_pdata *pdata); 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_ci /* For RX and TX PBL config */ 4718c2ecf20Sopenharmony_ci int (*config_rx_pbl_val)(struct xlgmac_pdata *pdata); 4728c2ecf20Sopenharmony_ci int (*get_rx_pbl_val)(struct xlgmac_pdata *pdata); 4738c2ecf20Sopenharmony_ci int (*config_tx_pbl_val)(struct xlgmac_pdata *pdata); 4748c2ecf20Sopenharmony_ci int (*get_tx_pbl_val)(struct xlgmac_pdata *pdata); 4758c2ecf20Sopenharmony_ci int (*config_pblx8)(struct xlgmac_pdata *pdata); 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ci /* For MMC statistics */ 4788c2ecf20Sopenharmony_ci void (*rx_mmc_int)(struct xlgmac_pdata *pdata); 4798c2ecf20Sopenharmony_ci void (*tx_mmc_int)(struct xlgmac_pdata *pdata); 4808c2ecf20Sopenharmony_ci void (*read_mmc_stats)(struct xlgmac_pdata *pdata); 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_ci /* For Receive Side Scaling */ 4838c2ecf20Sopenharmony_ci int (*enable_rss)(struct xlgmac_pdata *pdata); 4848c2ecf20Sopenharmony_ci int (*disable_rss)(struct xlgmac_pdata *pdata); 4858c2ecf20Sopenharmony_ci int (*set_rss_hash_key)(struct xlgmac_pdata *pdata, 4868c2ecf20Sopenharmony_ci const u8 *key); 4878c2ecf20Sopenharmony_ci int (*set_rss_lookup_table)(struct xlgmac_pdata *pdata, 4888c2ecf20Sopenharmony_ci const u32 *table); 4898c2ecf20Sopenharmony_ci}; 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci/* This structure contains flags that indicate what hardware features 4928c2ecf20Sopenharmony_ci * or configurations are present in the device. 4938c2ecf20Sopenharmony_ci */ 4948c2ecf20Sopenharmony_cistruct xlgmac_hw_features { 4958c2ecf20Sopenharmony_ci /* HW Version */ 4968c2ecf20Sopenharmony_ci unsigned int version; 4978c2ecf20Sopenharmony_ci 4988c2ecf20Sopenharmony_ci /* HW Feature Register0 */ 4998c2ecf20Sopenharmony_ci unsigned int phyifsel; /* PHY interface support */ 5008c2ecf20Sopenharmony_ci unsigned int vlhash; /* VLAN Hash Filter */ 5018c2ecf20Sopenharmony_ci unsigned int sma; /* SMA(MDIO) Interface */ 5028c2ecf20Sopenharmony_ci unsigned int rwk; /* PMT remote wake-up packet */ 5038c2ecf20Sopenharmony_ci unsigned int mgk; /* PMT magic packet */ 5048c2ecf20Sopenharmony_ci unsigned int mmc; /* RMON module */ 5058c2ecf20Sopenharmony_ci unsigned int aoe; /* ARP Offload */ 5068c2ecf20Sopenharmony_ci unsigned int ts; /* IEEE 1588-2008 Advanced Timestamp */ 5078c2ecf20Sopenharmony_ci unsigned int eee; /* Energy Efficient Ethernet */ 5088c2ecf20Sopenharmony_ci unsigned int tx_coe; /* Tx Checksum Offload */ 5098c2ecf20Sopenharmony_ci unsigned int rx_coe; /* Rx Checksum Offload */ 5108c2ecf20Sopenharmony_ci unsigned int addn_mac; /* Additional MAC Addresses */ 5118c2ecf20Sopenharmony_ci unsigned int ts_src; /* Timestamp Source */ 5128c2ecf20Sopenharmony_ci unsigned int sa_vlan_ins; /* Source Address or VLAN Insertion */ 5138c2ecf20Sopenharmony_ci 5148c2ecf20Sopenharmony_ci /* HW Feature Register1 */ 5158c2ecf20Sopenharmony_ci unsigned int rx_fifo_size; /* MTL Receive FIFO Size */ 5168c2ecf20Sopenharmony_ci unsigned int tx_fifo_size; /* MTL Transmit FIFO Size */ 5178c2ecf20Sopenharmony_ci unsigned int adv_ts_hi; /* Advance Timestamping High Word */ 5188c2ecf20Sopenharmony_ci unsigned int dma_width; /* DMA width */ 5198c2ecf20Sopenharmony_ci unsigned int dcb; /* DCB Feature */ 5208c2ecf20Sopenharmony_ci unsigned int sph; /* Split Header Feature */ 5218c2ecf20Sopenharmony_ci unsigned int tso; /* TCP Segmentation Offload */ 5228c2ecf20Sopenharmony_ci unsigned int dma_debug; /* DMA Debug Registers */ 5238c2ecf20Sopenharmony_ci unsigned int rss; /* Receive Side Scaling */ 5248c2ecf20Sopenharmony_ci unsigned int tc_cnt; /* Number of Traffic Classes */ 5258c2ecf20Sopenharmony_ci unsigned int hash_table_size; /* Hash Table Size */ 5268c2ecf20Sopenharmony_ci unsigned int l3l4_filter_num; /* Number of L3-L4 Filters */ 5278c2ecf20Sopenharmony_ci 5288c2ecf20Sopenharmony_ci /* HW Feature Register2 */ 5298c2ecf20Sopenharmony_ci unsigned int rx_q_cnt; /* Number of MTL Receive Queues */ 5308c2ecf20Sopenharmony_ci unsigned int tx_q_cnt; /* Number of MTL Transmit Queues */ 5318c2ecf20Sopenharmony_ci unsigned int rx_ch_cnt; /* Number of DMA Receive Channels */ 5328c2ecf20Sopenharmony_ci unsigned int tx_ch_cnt; /* Number of DMA Transmit Channels */ 5338c2ecf20Sopenharmony_ci unsigned int pps_out_num; /* Number of PPS outputs */ 5348c2ecf20Sopenharmony_ci unsigned int aux_snap_num; /* Number of Aux snapshot inputs */ 5358c2ecf20Sopenharmony_ci}; 5368c2ecf20Sopenharmony_ci 5378c2ecf20Sopenharmony_cistruct xlgmac_resources { 5388c2ecf20Sopenharmony_ci void __iomem *addr; 5398c2ecf20Sopenharmony_ci int irq; 5408c2ecf20Sopenharmony_ci}; 5418c2ecf20Sopenharmony_ci 5428c2ecf20Sopenharmony_cistruct xlgmac_pdata { 5438c2ecf20Sopenharmony_ci struct net_device *netdev; 5448c2ecf20Sopenharmony_ci struct device *dev; 5458c2ecf20Sopenharmony_ci 5468c2ecf20Sopenharmony_ci struct xlgmac_hw_ops hw_ops; 5478c2ecf20Sopenharmony_ci struct xlgmac_desc_ops desc_ops; 5488c2ecf20Sopenharmony_ci 5498c2ecf20Sopenharmony_ci /* Device statistics */ 5508c2ecf20Sopenharmony_ci struct xlgmac_stats stats; 5518c2ecf20Sopenharmony_ci 5528c2ecf20Sopenharmony_ci u32 msg_enable; 5538c2ecf20Sopenharmony_ci 5548c2ecf20Sopenharmony_ci /* MAC registers base */ 5558c2ecf20Sopenharmony_ci void __iomem *mac_regs; 5568c2ecf20Sopenharmony_ci 5578c2ecf20Sopenharmony_ci /* Hardware features of the device */ 5588c2ecf20Sopenharmony_ci struct xlgmac_hw_features hw_feat; 5598c2ecf20Sopenharmony_ci 5608c2ecf20Sopenharmony_ci struct work_struct restart_work; 5618c2ecf20Sopenharmony_ci 5628c2ecf20Sopenharmony_ci /* Rings for Tx/Rx on a DMA channel */ 5638c2ecf20Sopenharmony_ci struct xlgmac_channel *channel_head; 5648c2ecf20Sopenharmony_ci unsigned int channel_count; 5658c2ecf20Sopenharmony_ci unsigned int tx_ring_count; 5668c2ecf20Sopenharmony_ci unsigned int rx_ring_count; 5678c2ecf20Sopenharmony_ci unsigned int tx_desc_count; 5688c2ecf20Sopenharmony_ci unsigned int rx_desc_count; 5698c2ecf20Sopenharmony_ci unsigned int tx_q_count; 5708c2ecf20Sopenharmony_ci unsigned int rx_q_count; 5718c2ecf20Sopenharmony_ci 5728c2ecf20Sopenharmony_ci /* Tx/Rx common settings */ 5738c2ecf20Sopenharmony_ci unsigned int pblx8; 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_ci /* Tx settings */ 5768c2ecf20Sopenharmony_ci unsigned int tx_sf_mode; 5778c2ecf20Sopenharmony_ci unsigned int tx_threshold; 5788c2ecf20Sopenharmony_ci unsigned int tx_pbl; 5798c2ecf20Sopenharmony_ci unsigned int tx_osp_mode; 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_ci /* Rx settings */ 5828c2ecf20Sopenharmony_ci unsigned int rx_sf_mode; 5838c2ecf20Sopenharmony_ci unsigned int rx_threshold; 5848c2ecf20Sopenharmony_ci unsigned int rx_pbl; 5858c2ecf20Sopenharmony_ci 5868c2ecf20Sopenharmony_ci /* Tx coalescing settings */ 5878c2ecf20Sopenharmony_ci unsigned int tx_usecs; 5888c2ecf20Sopenharmony_ci unsigned int tx_frames; 5898c2ecf20Sopenharmony_ci 5908c2ecf20Sopenharmony_ci /* Rx coalescing settings */ 5918c2ecf20Sopenharmony_ci unsigned int rx_riwt; 5928c2ecf20Sopenharmony_ci unsigned int rx_usecs; 5938c2ecf20Sopenharmony_ci unsigned int rx_frames; 5948c2ecf20Sopenharmony_ci 5958c2ecf20Sopenharmony_ci /* Current Rx buffer size */ 5968c2ecf20Sopenharmony_ci unsigned int rx_buf_size; 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_ci /* Flow control settings */ 5998c2ecf20Sopenharmony_ci unsigned int tx_pause; 6008c2ecf20Sopenharmony_ci unsigned int rx_pause; 6018c2ecf20Sopenharmony_ci 6028c2ecf20Sopenharmony_ci /* Device interrupt number */ 6038c2ecf20Sopenharmony_ci int dev_irq; 6048c2ecf20Sopenharmony_ci unsigned int per_channel_irq; 6058c2ecf20Sopenharmony_ci int channel_irq[XLGMAC_MAX_DMA_CHANNELS]; 6068c2ecf20Sopenharmony_ci 6078c2ecf20Sopenharmony_ci /* Netdev related settings */ 6088c2ecf20Sopenharmony_ci unsigned char mac_addr[ETH_ALEN]; 6098c2ecf20Sopenharmony_ci netdev_features_t netdev_features; 6108c2ecf20Sopenharmony_ci struct napi_struct napi; 6118c2ecf20Sopenharmony_ci 6128c2ecf20Sopenharmony_ci /* Filtering support */ 6138c2ecf20Sopenharmony_ci unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 6148c2ecf20Sopenharmony_ci 6158c2ecf20Sopenharmony_ci /* Device clocks */ 6168c2ecf20Sopenharmony_ci unsigned long sysclk_rate; 6178c2ecf20Sopenharmony_ci 6188c2ecf20Sopenharmony_ci /* RSS addressing mutex */ 6198c2ecf20Sopenharmony_ci struct mutex rss_mutex; 6208c2ecf20Sopenharmony_ci 6218c2ecf20Sopenharmony_ci /* Receive Side Scaling settings */ 6228c2ecf20Sopenharmony_ci u8 rss_key[XLGMAC_RSS_HASH_KEY_SIZE]; 6238c2ecf20Sopenharmony_ci u32 rss_table[XLGMAC_RSS_MAX_TABLE_SIZE]; 6248c2ecf20Sopenharmony_ci u32 rss_options; 6258c2ecf20Sopenharmony_ci 6268c2ecf20Sopenharmony_ci int phy_speed; 6278c2ecf20Sopenharmony_ci 6288c2ecf20Sopenharmony_ci char drv_name[32]; 6298c2ecf20Sopenharmony_ci char drv_ver[32]; 6308c2ecf20Sopenharmony_ci}; 6318c2ecf20Sopenharmony_ci 6328c2ecf20Sopenharmony_civoid xlgmac_init_desc_ops(struct xlgmac_desc_ops *desc_ops); 6338c2ecf20Sopenharmony_civoid xlgmac_init_hw_ops(struct xlgmac_hw_ops *hw_ops); 6348c2ecf20Sopenharmony_ciconst struct net_device_ops *xlgmac_get_netdev_ops(void); 6358c2ecf20Sopenharmony_ciconst struct ethtool_ops *xlgmac_get_ethtool_ops(void); 6368c2ecf20Sopenharmony_civoid xlgmac_dump_tx_desc(struct xlgmac_pdata *pdata, 6378c2ecf20Sopenharmony_ci struct xlgmac_ring *ring, 6388c2ecf20Sopenharmony_ci unsigned int idx, 6398c2ecf20Sopenharmony_ci unsigned int count, 6408c2ecf20Sopenharmony_ci unsigned int flag); 6418c2ecf20Sopenharmony_civoid xlgmac_dump_rx_desc(struct xlgmac_pdata *pdata, 6428c2ecf20Sopenharmony_ci struct xlgmac_ring *ring, 6438c2ecf20Sopenharmony_ci unsigned int idx); 6448c2ecf20Sopenharmony_civoid xlgmac_print_pkt(struct net_device *netdev, 6458c2ecf20Sopenharmony_ci struct sk_buff *skb, bool tx_rx); 6468c2ecf20Sopenharmony_civoid xlgmac_get_all_hw_features(struct xlgmac_pdata *pdata); 6478c2ecf20Sopenharmony_civoid xlgmac_print_all_hw_features(struct xlgmac_pdata *pdata); 6488c2ecf20Sopenharmony_ciint xlgmac_drv_probe(struct device *dev, 6498c2ecf20Sopenharmony_ci struct xlgmac_resources *res); 6508c2ecf20Sopenharmony_ciint xlgmac_drv_remove(struct device *dev); 6518c2ecf20Sopenharmony_ci 6528c2ecf20Sopenharmony_ci/* For debug prints */ 6538c2ecf20Sopenharmony_ci#ifdef XLGMAC_DEBUG 6548c2ecf20Sopenharmony_ci#define XLGMAC_PR(fmt, args...) \ 6558c2ecf20Sopenharmony_ci pr_alert("[%s,%d]:" fmt, __func__, __LINE__, ## args) 6568c2ecf20Sopenharmony_ci#else 6578c2ecf20Sopenharmony_ci#define XLGMAC_PR(x...) do { } while (0) 6588c2ecf20Sopenharmony_ci#endif 6598c2ecf20Sopenharmony_ci 6608c2ecf20Sopenharmony_ci#endif /* __DWC_XLGMAC_H__ */ 661