18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright(c) 2008 - 2009 Atheros Corporation. All rights reserved. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Derived from Intel e1000 driver 68c2ecf20Sopenharmony_ci * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef _ATL1C_H_ 108c2ecf20Sopenharmony_ci#define _ATL1C_H_ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 138c2ecf20Sopenharmony_ci#include <linux/types.h> 148c2ecf20Sopenharmony_ci#include <linux/errno.h> 158c2ecf20Sopenharmony_ci#include <linux/module.h> 168c2ecf20Sopenharmony_ci#include <linux/pci.h> 178c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 188c2ecf20Sopenharmony_ci#include <linux/etherdevice.h> 198c2ecf20Sopenharmony_ci#include <linux/skbuff.h> 208c2ecf20Sopenharmony_ci#include <linux/ioport.h> 218c2ecf20Sopenharmony_ci#include <linux/slab.h> 228c2ecf20Sopenharmony_ci#include <linux/list.h> 238c2ecf20Sopenharmony_ci#include <linux/delay.h> 248c2ecf20Sopenharmony_ci#include <linux/sched.h> 258c2ecf20Sopenharmony_ci#include <linux/in.h> 268c2ecf20Sopenharmony_ci#include <linux/ip.h> 278c2ecf20Sopenharmony_ci#include <linux/ipv6.h> 288c2ecf20Sopenharmony_ci#include <linux/udp.h> 298c2ecf20Sopenharmony_ci#include <linux/mii.h> 308c2ecf20Sopenharmony_ci#include <linux/io.h> 318c2ecf20Sopenharmony_ci#include <linux/vmalloc.h> 328c2ecf20Sopenharmony_ci#include <linux/pagemap.h> 338c2ecf20Sopenharmony_ci#include <linux/tcp.h> 348c2ecf20Sopenharmony_ci#include <linux/ethtool.h> 358c2ecf20Sopenharmony_ci#include <linux/if_vlan.h> 368c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 378c2ecf20Sopenharmony_ci#include <net/checksum.h> 388c2ecf20Sopenharmony_ci#include <net/ip6_checksum.h> 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#include "atl1c_hw.h" 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci/* Wake Up Filter Control */ 438c2ecf20Sopenharmony_ci#define AT_WUFC_LNKC 0x00000001 /* Link Status Change Wakeup Enable */ 448c2ecf20Sopenharmony_ci#define AT_WUFC_MAG 0x00000002 /* Magic Packet Wakeup Enable */ 458c2ecf20Sopenharmony_ci#define AT_WUFC_EX 0x00000004 /* Directed Exact Wakeup Enable */ 468c2ecf20Sopenharmony_ci#define AT_WUFC_MC 0x00000008 /* Multicast Wakeup Enable */ 478c2ecf20Sopenharmony_ci#define AT_WUFC_BC 0x00000010 /* Broadcast Wakeup Enable */ 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci#define AT_VLAN_TO_TAG(_vlan, _tag) \ 508c2ecf20Sopenharmony_ci _tag = ((((_vlan) >> 8) & 0xFF) |\ 518c2ecf20Sopenharmony_ci (((_vlan) & 0xFF) << 8)) 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#define AT_TAG_TO_VLAN(_tag, _vlan) \ 548c2ecf20Sopenharmony_ci _vlan = ((((_tag) >> 8) & 0xFF) |\ 558c2ecf20Sopenharmony_ci (((_tag) & 0xFF) << 8)) 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#define SPEED_0 0xffff 588c2ecf20Sopenharmony_ci#define HALF_DUPLEX 1 598c2ecf20Sopenharmony_ci#define FULL_DUPLEX 2 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci#define AT_RX_BUF_SIZE (ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN) 628c2ecf20Sopenharmony_ci#define MAX_JUMBO_FRAME_SIZE (6*1024) 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define AT_MAX_RECEIVE_QUEUE 4 658c2ecf20Sopenharmony_ci#define AT_DEF_RECEIVE_QUEUE 1 668c2ecf20Sopenharmony_ci#define AT_MAX_TRANSMIT_QUEUE 2 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#define AT_DMA_HI_ADDR_MASK 0xffffffff00000000ULL 698c2ecf20Sopenharmony_ci#define AT_DMA_LO_ADDR_MASK 0x00000000ffffffffULL 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci#define AT_TX_WATCHDOG (5 * HZ) 728c2ecf20Sopenharmony_ci#define AT_MAX_INT_WORK 5 738c2ecf20Sopenharmony_ci#define AT_TWSI_EEPROM_TIMEOUT 100 748c2ecf20Sopenharmony_ci#define AT_HW_MAX_IDLE_DELAY 10 758c2ecf20Sopenharmony_ci#define AT_SUSPEND_LINK_TIMEOUT 100 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#define AT_ASPM_L0S_TIMER 6 788c2ecf20Sopenharmony_ci#define AT_ASPM_L1_TIMER 12 798c2ecf20Sopenharmony_ci#define AT_LCKDET_TIMER 12 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#define ATL1C_PCIE_L0S_L1_DISABLE 0x01 828c2ecf20Sopenharmony_ci#define ATL1C_PCIE_PHY_RESET 0x02 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#define ATL1C_ASPM_L0s_ENABLE 0x0001 858c2ecf20Sopenharmony_ci#define ATL1C_ASPM_L1_ENABLE 0x0002 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci#define AT_REGS_LEN (74 * sizeof(u32)) 888c2ecf20Sopenharmony_ci#define AT_EEPROM_LEN 512 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci#define ATL1C_GET_DESC(R, i, type) (&(((type *)((R)->desc))[i])) 918c2ecf20Sopenharmony_ci#define ATL1C_RFD_DESC(R, i) ATL1C_GET_DESC(R, i, struct atl1c_rx_free_desc) 928c2ecf20Sopenharmony_ci#define ATL1C_TPD_DESC(R, i) ATL1C_GET_DESC(R, i, struct atl1c_tpd_desc) 938c2ecf20Sopenharmony_ci#define ATL1C_RRD_DESC(R, i) ATL1C_GET_DESC(R, i, struct atl1c_recv_ret_status) 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci/* tpd word 1 bit 0:7 General Checksum task offload */ 968c2ecf20Sopenharmony_ci#define TPD_L4HDR_OFFSET_MASK 0x00FF 978c2ecf20Sopenharmony_ci#define TPD_L4HDR_OFFSET_SHIFT 0 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci/* tpd word 1 bit 0:7 Large Send task offload (IPv4/IPV6) */ 1008c2ecf20Sopenharmony_ci#define TPD_TCPHDR_OFFSET_MASK 0x00FF 1018c2ecf20Sopenharmony_ci#define TPD_TCPHDR_OFFSET_SHIFT 0 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci/* tpd word 1 bit 0:7 Custom Checksum task offload */ 1048c2ecf20Sopenharmony_ci#define TPD_PLOADOFFSET_MASK 0x00FF 1058c2ecf20Sopenharmony_ci#define TPD_PLOADOFFSET_SHIFT 0 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci/* tpd word 1 bit 8:17 */ 1088c2ecf20Sopenharmony_ci#define TPD_CCSUM_EN_MASK 0x0001 1098c2ecf20Sopenharmony_ci#define TPD_CCSUM_EN_SHIFT 8 1108c2ecf20Sopenharmony_ci#define TPD_IP_CSUM_MASK 0x0001 1118c2ecf20Sopenharmony_ci#define TPD_IP_CSUM_SHIFT 9 1128c2ecf20Sopenharmony_ci#define TPD_TCP_CSUM_MASK 0x0001 1138c2ecf20Sopenharmony_ci#define TPD_TCP_CSUM_SHIFT 10 1148c2ecf20Sopenharmony_ci#define TPD_UDP_CSUM_MASK 0x0001 1158c2ecf20Sopenharmony_ci#define TPD_UDP_CSUM_SHIFT 11 1168c2ecf20Sopenharmony_ci#define TPD_LSO_EN_MASK 0x0001 /* TCP Large Send Offload */ 1178c2ecf20Sopenharmony_ci#define TPD_LSO_EN_SHIFT 12 1188c2ecf20Sopenharmony_ci#define TPD_LSO_VER_MASK 0x0001 1198c2ecf20Sopenharmony_ci#define TPD_LSO_VER_SHIFT 13 /* 0 : ipv4; 1 : ipv4/ipv6 */ 1208c2ecf20Sopenharmony_ci#define TPD_CON_VTAG_MASK 0x0001 1218c2ecf20Sopenharmony_ci#define TPD_CON_VTAG_SHIFT 14 1228c2ecf20Sopenharmony_ci#define TPD_INS_VTAG_MASK 0x0001 1238c2ecf20Sopenharmony_ci#define TPD_INS_VTAG_SHIFT 15 1248c2ecf20Sopenharmony_ci#define TPD_IPV4_PACKET_MASK 0x0001 /* valid when LSO VER is 1 */ 1258c2ecf20Sopenharmony_ci#define TPD_IPV4_PACKET_SHIFT 16 1268c2ecf20Sopenharmony_ci#define TPD_ETH_TYPE_MASK 0x0001 1278c2ecf20Sopenharmony_ci#define TPD_ETH_TYPE_SHIFT 17 /* 0 : 802.3 frame; 1 : Ethernet */ 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci/* tpd word 18:25 Custom Checksum task offload */ 1308c2ecf20Sopenharmony_ci#define TPD_CCSUM_OFFSET_MASK 0x00FF 1318c2ecf20Sopenharmony_ci#define TPD_CCSUM_OFFSET_SHIFT 18 1328c2ecf20Sopenharmony_ci#define TPD_CCSUM_EPAD_MASK 0x0001 1338c2ecf20Sopenharmony_ci#define TPD_CCSUM_EPAD_SHIFT 30 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci/* tpd word 18:30 Large Send task offload (IPv4/IPV6) */ 1368c2ecf20Sopenharmony_ci#define TPD_MSS_MASK 0x1FFF 1378c2ecf20Sopenharmony_ci#define TPD_MSS_SHIFT 18 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci#define TPD_EOP_MASK 0x0001 1408c2ecf20Sopenharmony_ci#define TPD_EOP_SHIFT 31 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_cistruct atl1c_tpd_desc { 1438c2ecf20Sopenharmony_ci __le16 buffer_len; /* include 4-byte CRC */ 1448c2ecf20Sopenharmony_ci __le16 vlan_tag; 1458c2ecf20Sopenharmony_ci __le32 word1; 1468c2ecf20Sopenharmony_ci __le64 buffer_addr; 1478c2ecf20Sopenharmony_ci}; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_cistruct atl1c_tpd_ext_desc { 1508c2ecf20Sopenharmony_ci u32 reservd_0; 1518c2ecf20Sopenharmony_ci __le32 word1; 1528c2ecf20Sopenharmony_ci __le32 pkt_len; 1538c2ecf20Sopenharmony_ci u32 reservd_1; 1548c2ecf20Sopenharmony_ci}; 1558c2ecf20Sopenharmony_ci/* rrs word 0 bit 0:31 */ 1568c2ecf20Sopenharmony_ci#define RRS_RX_CSUM_MASK 0xFFFF 1578c2ecf20Sopenharmony_ci#define RRS_RX_CSUM_SHIFT 0 1588c2ecf20Sopenharmony_ci#define RRS_RX_RFD_CNT_MASK 0x000F 1598c2ecf20Sopenharmony_ci#define RRS_RX_RFD_CNT_SHIFT 16 1608c2ecf20Sopenharmony_ci#define RRS_RX_RFD_INDEX_MASK 0x0FFF 1618c2ecf20Sopenharmony_ci#define RRS_RX_RFD_INDEX_SHIFT 20 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci/* rrs flag bit 0:16 */ 1648c2ecf20Sopenharmony_ci#define RRS_HEAD_LEN_MASK 0x00FF 1658c2ecf20Sopenharmony_ci#define RRS_HEAD_LEN_SHIFT 0 1668c2ecf20Sopenharmony_ci#define RRS_HDS_TYPE_MASK 0x0003 1678c2ecf20Sopenharmony_ci#define RRS_HDS_TYPE_SHIFT 8 1688c2ecf20Sopenharmony_ci#define RRS_CPU_NUM_MASK 0x0003 1698c2ecf20Sopenharmony_ci#define RRS_CPU_NUM_SHIFT 10 1708c2ecf20Sopenharmony_ci#define RRS_HASH_FLG_MASK 0x000F 1718c2ecf20Sopenharmony_ci#define RRS_HASH_FLG_SHIFT 12 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci#define RRS_HDS_TYPE_HEAD 1 1748c2ecf20Sopenharmony_ci#define RRS_HDS_TYPE_DATA 2 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci#define RRS_IS_NO_HDS_TYPE(flag) \ 1778c2ecf20Sopenharmony_ci ((((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK) == 0) 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci#define RRS_IS_HDS_HEAD(flag) \ 1808c2ecf20Sopenharmony_ci ((((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK) == \ 1818c2ecf20Sopenharmony_ci RRS_HDS_TYPE_HEAD) 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci#define RRS_IS_HDS_DATA(flag) \ 1848c2ecf20Sopenharmony_ci ((((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK) == \ 1858c2ecf20Sopenharmony_ci RRS_HDS_TYPE_DATA) 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci/* rrs word 3 bit 0:31 */ 1888c2ecf20Sopenharmony_ci#define RRS_PKT_SIZE_MASK 0x3FFF 1898c2ecf20Sopenharmony_ci#define RRS_PKT_SIZE_SHIFT 0 1908c2ecf20Sopenharmony_ci#define RRS_ERR_L4_CSUM_MASK 0x0001 1918c2ecf20Sopenharmony_ci#define RRS_ERR_L4_CSUM_SHIFT 14 1928c2ecf20Sopenharmony_ci#define RRS_ERR_IP_CSUM_MASK 0x0001 1938c2ecf20Sopenharmony_ci#define RRS_ERR_IP_CSUM_SHIFT 15 1948c2ecf20Sopenharmony_ci#define RRS_VLAN_INS_MASK 0x0001 1958c2ecf20Sopenharmony_ci#define RRS_VLAN_INS_SHIFT 16 1968c2ecf20Sopenharmony_ci#define RRS_PROT_ID_MASK 0x0007 1978c2ecf20Sopenharmony_ci#define RRS_PROT_ID_SHIFT 17 1988c2ecf20Sopenharmony_ci#define RRS_RX_ERR_SUM_MASK 0x0001 1998c2ecf20Sopenharmony_ci#define RRS_RX_ERR_SUM_SHIFT 20 2008c2ecf20Sopenharmony_ci#define RRS_RX_ERR_CRC_MASK 0x0001 2018c2ecf20Sopenharmony_ci#define RRS_RX_ERR_CRC_SHIFT 21 2028c2ecf20Sopenharmony_ci#define RRS_RX_ERR_FAE_MASK 0x0001 2038c2ecf20Sopenharmony_ci#define RRS_RX_ERR_FAE_SHIFT 22 2048c2ecf20Sopenharmony_ci#define RRS_RX_ERR_TRUNC_MASK 0x0001 2058c2ecf20Sopenharmony_ci#define RRS_RX_ERR_TRUNC_SHIFT 23 2068c2ecf20Sopenharmony_ci#define RRS_RX_ERR_RUNC_MASK 0x0001 2078c2ecf20Sopenharmony_ci#define RRS_RX_ERR_RUNC_SHIFT 24 2088c2ecf20Sopenharmony_ci#define RRS_RX_ERR_ICMP_MASK 0x0001 2098c2ecf20Sopenharmony_ci#define RRS_RX_ERR_ICMP_SHIFT 25 2108c2ecf20Sopenharmony_ci#define RRS_PACKET_BCAST_MASK 0x0001 2118c2ecf20Sopenharmony_ci#define RRS_PACKET_BCAST_SHIFT 26 2128c2ecf20Sopenharmony_ci#define RRS_PACKET_MCAST_MASK 0x0001 2138c2ecf20Sopenharmony_ci#define RRS_PACKET_MCAST_SHIFT 27 2148c2ecf20Sopenharmony_ci#define RRS_PACKET_TYPE_MASK 0x0001 2158c2ecf20Sopenharmony_ci#define RRS_PACKET_TYPE_SHIFT 28 2168c2ecf20Sopenharmony_ci#define RRS_FIFO_FULL_MASK 0x0001 2178c2ecf20Sopenharmony_ci#define RRS_FIFO_FULL_SHIFT 29 2188c2ecf20Sopenharmony_ci#define RRS_802_3_LEN_ERR_MASK 0x0001 2198c2ecf20Sopenharmony_ci#define RRS_802_3_LEN_ERR_SHIFT 30 2208c2ecf20Sopenharmony_ci#define RRS_RXD_UPDATED_MASK 0x0001 2218c2ecf20Sopenharmony_ci#define RRS_RXD_UPDATED_SHIFT 31 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci#define RRS_ERR_L4_CSUM 0x00004000 2248c2ecf20Sopenharmony_ci#define RRS_ERR_IP_CSUM 0x00008000 2258c2ecf20Sopenharmony_ci#define RRS_VLAN_INS 0x00010000 2268c2ecf20Sopenharmony_ci#define RRS_RX_ERR_SUM 0x00100000 2278c2ecf20Sopenharmony_ci#define RRS_RX_ERR_CRC 0x00200000 2288c2ecf20Sopenharmony_ci#define RRS_802_3_LEN_ERR 0x40000000 2298c2ecf20Sopenharmony_ci#define RRS_RXD_UPDATED 0x80000000 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci#define RRS_PACKET_TYPE_802_3 1 2328c2ecf20Sopenharmony_ci#define RRS_PACKET_TYPE_ETH 0 2338c2ecf20Sopenharmony_ci#define RRS_PACKET_IS_ETH(word) \ 2348c2ecf20Sopenharmony_ci ((((word) >> RRS_PACKET_TYPE_SHIFT) & RRS_PACKET_TYPE_MASK) == \ 2358c2ecf20Sopenharmony_ci RRS_PACKET_TYPE_ETH) 2368c2ecf20Sopenharmony_ci#define RRS_RXD_IS_VALID(word) \ 2378c2ecf20Sopenharmony_ci ((((word) >> RRS_RXD_UPDATED_SHIFT) & RRS_RXD_UPDATED_MASK) == 1) 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci#define RRS_PACKET_PROT_IS_IPV4_ONLY(word) \ 2408c2ecf20Sopenharmony_ci ((((word) >> RRS_PROT_ID_SHIFT) & RRS_PROT_ID_MASK) == 1) 2418c2ecf20Sopenharmony_ci#define RRS_PACKET_PROT_IS_IPV6_ONLY(word) \ 2428c2ecf20Sopenharmony_ci ((((word) >> RRS_PROT_ID_SHIFT) & RRS_PROT_ID_MASK) == 6) 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_cistruct atl1c_recv_ret_status { 2458c2ecf20Sopenharmony_ci __le32 word0; 2468c2ecf20Sopenharmony_ci __le32 rss_hash; 2478c2ecf20Sopenharmony_ci __le16 vlan_tag; 2488c2ecf20Sopenharmony_ci __le16 flag; 2498c2ecf20Sopenharmony_ci __le32 word3; 2508c2ecf20Sopenharmony_ci}; 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci/* RFD descriptor */ 2538c2ecf20Sopenharmony_cistruct atl1c_rx_free_desc { 2548c2ecf20Sopenharmony_ci __le64 buffer_addr; 2558c2ecf20Sopenharmony_ci}; 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci/* DMA Order Settings */ 2588c2ecf20Sopenharmony_cienum atl1c_dma_order { 2598c2ecf20Sopenharmony_ci atl1c_dma_ord_in = 1, 2608c2ecf20Sopenharmony_ci atl1c_dma_ord_enh = 2, 2618c2ecf20Sopenharmony_ci atl1c_dma_ord_out = 4 2628c2ecf20Sopenharmony_ci}; 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_cienum atl1c_dma_rcb { 2658c2ecf20Sopenharmony_ci atl1c_rcb_64 = 0, 2668c2ecf20Sopenharmony_ci atl1c_rcb_128 = 1 2678c2ecf20Sopenharmony_ci}; 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_cienum atl1c_mac_speed { 2708c2ecf20Sopenharmony_ci atl1c_mac_speed_0 = 0, 2718c2ecf20Sopenharmony_ci atl1c_mac_speed_10_100 = 1, 2728c2ecf20Sopenharmony_ci atl1c_mac_speed_1000 = 2 2738c2ecf20Sopenharmony_ci}; 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_cienum atl1c_dma_req_block { 2768c2ecf20Sopenharmony_ci atl1c_dma_req_128 = 0, 2778c2ecf20Sopenharmony_ci atl1c_dma_req_256 = 1, 2788c2ecf20Sopenharmony_ci atl1c_dma_req_512 = 2, 2798c2ecf20Sopenharmony_ci atl1c_dma_req_1024 = 3, 2808c2ecf20Sopenharmony_ci atl1c_dma_req_2048 = 4, 2818c2ecf20Sopenharmony_ci atl1c_dma_req_4096 = 5 2828c2ecf20Sopenharmony_ci}; 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_cienum atl1c_nic_type { 2868c2ecf20Sopenharmony_ci athr_l1c = 0, 2878c2ecf20Sopenharmony_ci athr_l2c = 1, 2888c2ecf20Sopenharmony_ci athr_l2c_b, 2898c2ecf20Sopenharmony_ci athr_l2c_b2, 2908c2ecf20Sopenharmony_ci athr_l1d, 2918c2ecf20Sopenharmony_ci athr_l1d_2, 2928c2ecf20Sopenharmony_ci}; 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_cienum atl1c_trans_queue { 2958c2ecf20Sopenharmony_ci atl1c_trans_normal = 0, 2968c2ecf20Sopenharmony_ci atl1c_trans_high = 1 2978c2ecf20Sopenharmony_ci}; 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_cistruct atl1c_hw_stats { 3008c2ecf20Sopenharmony_ci /* rx */ 3018c2ecf20Sopenharmony_ci unsigned long rx_ok; /* The number of good packet received. */ 3028c2ecf20Sopenharmony_ci unsigned long rx_bcast; /* The number of good broadcast packet received. */ 3038c2ecf20Sopenharmony_ci unsigned long rx_mcast; /* The number of good multicast packet received. */ 3048c2ecf20Sopenharmony_ci unsigned long rx_pause; /* The number of Pause packet received. */ 3058c2ecf20Sopenharmony_ci unsigned long rx_ctrl; /* The number of Control packet received other than Pause frame. */ 3068c2ecf20Sopenharmony_ci unsigned long rx_fcs_err; /* The number of packets with bad FCS. */ 3078c2ecf20Sopenharmony_ci unsigned long rx_len_err; /* The number of packets with mismatch of length field and actual size. */ 3088c2ecf20Sopenharmony_ci unsigned long rx_byte_cnt; /* The number of bytes of good packet received. FCS is NOT included. */ 3098c2ecf20Sopenharmony_ci unsigned long rx_runt; /* The number of packets received that are less than 64 byte long and with good FCS. */ 3108c2ecf20Sopenharmony_ci unsigned long rx_frag; /* The number of packets received that are less than 64 byte long and with bad FCS. */ 3118c2ecf20Sopenharmony_ci unsigned long rx_sz_64; /* The number of good and bad packets received that are 64 byte long. */ 3128c2ecf20Sopenharmony_ci unsigned long rx_sz_65_127; /* The number of good and bad packets received that are between 65 and 127-byte long. */ 3138c2ecf20Sopenharmony_ci unsigned long rx_sz_128_255; /* The number of good and bad packets received that are between 128 and 255-byte long. */ 3148c2ecf20Sopenharmony_ci unsigned long rx_sz_256_511; /* The number of good and bad packets received that are between 256 and 511-byte long. */ 3158c2ecf20Sopenharmony_ci unsigned long rx_sz_512_1023; /* The number of good and bad packets received that are between 512 and 1023-byte long. */ 3168c2ecf20Sopenharmony_ci unsigned long rx_sz_1024_1518; /* The number of good and bad packets received that are between 1024 and 1518-byte long. */ 3178c2ecf20Sopenharmony_ci unsigned long rx_sz_1519_max; /* The number of good and bad packets received that are between 1519-byte and MTU. */ 3188c2ecf20Sopenharmony_ci unsigned long rx_sz_ov; /* The number of good and bad packets received that are more than MTU size truncated by Selene. */ 3198c2ecf20Sopenharmony_ci unsigned long rx_rxf_ov; /* The number of frame dropped due to occurrence of RX FIFO overflow. */ 3208c2ecf20Sopenharmony_ci unsigned long rx_rrd_ov; /* The number of frame dropped due to occurrence of RRD overflow. */ 3218c2ecf20Sopenharmony_ci unsigned long rx_align_err; /* Alignment Error */ 3228c2ecf20Sopenharmony_ci unsigned long rx_bcast_byte_cnt; /* The byte count of broadcast packet received, excluding FCS. */ 3238c2ecf20Sopenharmony_ci unsigned long rx_mcast_byte_cnt; /* The byte count of multicast packet received, excluding FCS. */ 3248c2ecf20Sopenharmony_ci unsigned long rx_err_addr; /* The number of packets dropped due to address filtering. */ 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ci /* tx */ 3278c2ecf20Sopenharmony_ci unsigned long tx_ok; /* The number of good packet transmitted. */ 3288c2ecf20Sopenharmony_ci unsigned long tx_bcast; /* The number of good broadcast packet transmitted. */ 3298c2ecf20Sopenharmony_ci unsigned long tx_mcast; /* The number of good multicast packet transmitted. */ 3308c2ecf20Sopenharmony_ci unsigned long tx_pause; /* The number of Pause packet transmitted. */ 3318c2ecf20Sopenharmony_ci unsigned long tx_exc_defer; /* The number of packets transmitted with excessive deferral. */ 3328c2ecf20Sopenharmony_ci unsigned long tx_ctrl; /* The number of packets transmitted is a control frame, excluding Pause frame. */ 3338c2ecf20Sopenharmony_ci unsigned long tx_defer; /* The number of packets transmitted that is deferred. */ 3348c2ecf20Sopenharmony_ci unsigned long tx_byte_cnt; /* The number of bytes of data transmitted. FCS is NOT included. */ 3358c2ecf20Sopenharmony_ci unsigned long tx_sz_64; /* The number of good and bad packets transmitted that are 64 byte long. */ 3368c2ecf20Sopenharmony_ci unsigned long tx_sz_65_127; /* The number of good and bad packets transmitted that are between 65 and 127-byte long. */ 3378c2ecf20Sopenharmony_ci unsigned long tx_sz_128_255; /* The number of good and bad packets transmitted that are between 128 and 255-byte long. */ 3388c2ecf20Sopenharmony_ci unsigned long tx_sz_256_511; /* The number of good and bad packets transmitted that are between 256 and 511-byte long. */ 3398c2ecf20Sopenharmony_ci unsigned long tx_sz_512_1023; /* The number of good and bad packets transmitted that are between 512 and 1023-byte long. */ 3408c2ecf20Sopenharmony_ci unsigned long tx_sz_1024_1518; /* The number of good and bad packets transmitted that are between 1024 and 1518-byte long. */ 3418c2ecf20Sopenharmony_ci unsigned long tx_sz_1519_max; /* The number of good and bad packets transmitted that are between 1519-byte and MTU. */ 3428c2ecf20Sopenharmony_ci unsigned long tx_1_col; /* The number of packets subsequently transmitted successfully with a single prior collision. */ 3438c2ecf20Sopenharmony_ci unsigned long tx_2_col; /* The number of packets subsequently transmitted successfully with multiple prior collisions. */ 3448c2ecf20Sopenharmony_ci unsigned long tx_late_col; /* The number of packets transmitted with late collisions. */ 3458c2ecf20Sopenharmony_ci unsigned long tx_abort_col; /* The number of transmit packets aborted due to excessive collisions. */ 3468c2ecf20Sopenharmony_ci unsigned long tx_underrun; /* The number of transmit packets aborted due to transmit FIFO underrun, or TRD FIFO underrun */ 3478c2ecf20Sopenharmony_ci unsigned long tx_rd_eop; /* The number of times that read beyond the EOP into the next frame area when TRD was not written timely */ 3488c2ecf20Sopenharmony_ci unsigned long tx_len_err; /* The number of transmit packets with length field does NOT match the actual frame size. */ 3498c2ecf20Sopenharmony_ci unsigned long tx_trunc; /* The number of transmit packets truncated due to size exceeding MTU. */ 3508c2ecf20Sopenharmony_ci unsigned long tx_bcast_byte; /* The byte count of broadcast packet transmitted, excluding FCS. */ 3518c2ecf20Sopenharmony_ci unsigned long tx_mcast_byte; /* The byte count of multicast packet transmitted, excluding FCS. */ 3528c2ecf20Sopenharmony_ci}; 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_cistruct atl1c_hw { 3558c2ecf20Sopenharmony_ci u8 __iomem *hw_addr; /* inner register address */ 3568c2ecf20Sopenharmony_ci struct atl1c_adapter *adapter; 3578c2ecf20Sopenharmony_ci enum atl1c_nic_type nic_type; 3588c2ecf20Sopenharmony_ci enum atl1c_dma_order dma_order; 3598c2ecf20Sopenharmony_ci enum atl1c_dma_rcb rcb_value; 3608c2ecf20Sopenharmony_ci enum atl1c_dma_req_block dmar_block; 3618c2ecf20Sopenharmony_ci 3628c2ecf20Sopenharmony_ci u16 device_id; 3638c2ecf20Sopenharmony_ci u16 vendor_id; 3648c2ecf20Sopenharmony_ci u16 subsystem_id; 3658c2ecf20Sopenharmony_ci u16 subsystem_vendor_id; 3668c2ecf20Sopenharmony_ci u8 revision_id; 3678c2ecf20Sopenharmony_ci u16 phy_id1; 3688c2ecf20Sopenharmony_ci u16 phy_id2; 3698c2ecf20Sopenharmony_ci 3708c2ecf20Sopenharmony_ci u32 intr_mask; 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_ci u8 preamble_len; 3738c2ecf20Sopenharmony_ci u16 max_frame_size; 3748c2ecf20Sopenharmony_ci u16 min_frame_size; 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_ci enum atl1c_mac_speed mac_speed; 3778c2ecf20Sopenharmony_ci bool mac_duplex; 3788c2ecf20Sopenharmony_ci bool hibernate; 3798c2ecf20Sopenharmony_ci u16 media_type; 3808c2ecf20Sopenharmony_ci#define MEDIA_TYPE_AUTO_SENSOR 0 3818c2ecf20Sopenharmony_ci#define MEDIA_TYPE_100M_FULL 1 3828c2ecf20Sopenharmony_ci#define MEDIA_TYPE_100M_HALF 2 3838c2ecf20Sopenharmony_ci#define MEDIA_TYPE_10M_FULL 3 3848c2ecf20Sopenharmony_ci#define MEDIA_TYPE_10M_HALF 4 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_ci u16 autoneg_advertised; 3878c2ecf20Sopenharmony_ci u16 mii_autoneg_adv_reg; 3888c2ecf20Sopenharmony_ci u16 mii_1000t_ctrl_reg; 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_ci u16 tx_imt; /* TX Interrupt Moderator timer ( 2us resolution) */ 3918c2ecf20Sopenharmony_ci u16 rx_imt; /* RX Interrupt Moderator timer ( 2us resolution) */ 3928c2ecf20Sopenharmony_ci u16 ict; /* Interrupt Clear timer (2us resolution) */ 3938c2ecf20Sopenharmony_ci u16 ctrl_flags; 3948c2ecf20Sopenharmony_ci#define ATL1C_INTR_CLEAR_ON_READ 0x0001 3958c2ecf20Sopenharmony_ci#define ATL1C_INTR_MODRT_ENABLE 0x0002 3968c2ecf20Sopenharmony_ci#define ATL1C_CMB_ENABLE 0x0004 3978c2ecf20Sopenharmony_ci#define ATL1C_SMB_ENABLE 0x0010 3988c2ecf20Sopenharmony_ci#define ATL1C_TXQ_MODE_ENHANCE 0x0020 3998c2ecf20Sopenharmony_ci#define ATL1C_RX_IPV6_CHKSUM 0x0040 4008c2ecf20Sopenharmony_ci#define ATL1C_ASPM_L0S_SUPPORT 0x0080 4018c2ecf20Sopenharmony_ci#define ATL1C_ASPM_L1_SUPPORT 0x0100 4028c2ecf20Sopenharmony_ci#define ATL1C_ASPM_CTRL_MON 0x0200 4038c2ecf20Sopenharmony_ci#define ATL1C_HIB_DISABLE 0x0400 4048c2ecf20Sopenharmony_ci#define ATL1C_APS_MODE_ENABLE 0x0800 4058c2ecf20Sopenharmony_ci#define ATL1C_LINK_EXT_SYNC 0x1000 4068c2ecf20Sopenharmony_ci#define ATL1C_CLK_GATING_EN 0x2000 4078c2ecf20Sopenharmony_ci#define ATL1C_FPGA_VERSION 0x8000 4088c2ecf20Sopenharmony_ci u16 link_cap_flags; 4098c2ecf20Sopenharmony_ci#define ATL1C_LINK_CAP_1000M 0x0001 4108c2ecf20Sopenharmony_ci u32 smb_timer; 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci u16 rrd_thresh; /* Threshold of number of RRD produced to trigger 4138c2ecf20Sopenharmony_ci interrupt request */ 4148c2ecf20Sopenharmony_ci u16 tpd_thresh; 4158c2ecf20Sopenharmony_ci u8 tpd_burst; /* Number of TPD to prefetch in cache-aligned burst. */ 4168c2ecf20Sopenharmony_ci u8 rfd_burst; 4178c2ecf20Sopenharmony_ci u32 base_cpu; 4188c2ecf20Sopenharmony_ci u32 indirect_tab; 4198c2ecf20Sopenharmony_ci u8 mac_addr[ETH_ALEN]; 4208c2ecf20Sopenharmony_ci u8 perm_mac_addr[ETH_ALEN]; 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_ci bool phy_configured; 4238c2ecf20Sopenharmony_ci bool re_autoneg; 4248c2ecf20Sopenharmony_ci bool emi_ca; 4258c2ecf20Sopenharmony_ci bool msi_lnkpatch; /* link patch for specific platforms */ 4268c2ecf20Sopenharmony_ci}; 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_ci/* 4298c2ecf20Sopenharmony_ci * atl1c_ring_header represents a single, contiguous block of DMA space 4308c2ecf20Sopenharmony_ci * mapped for the three descriptor rings (tpd, rfd, rrd) described below 4318c2ecf20Sopenharmony_ci */ 4328c2ecf20Sopenharmony_cistruct atl1c_ring_header { 4338c2ecf20Sopenharmony_ci void *desc; /* virtual address */ 4348c2ecf20Sopenharmony_ci dma_addr_t dma; /* physical address*/ 4358c2ecf20Sopenharmony_ci unsigned int size; /* length in bytes */ 4368c2ecf20Sopenharmony_ci}; 4378c2ecf20Sopenharmony_ci 4388c2ecf20Sopenharmony_ci/* 4398c2ecf20Sopenharmony_ci * atl1c_buffer is wrapper around a pointer to a socket buffer 4408c2ecf20Sopenharmony_ci * so a DMA handle can be stored along with the skb 4418c2ecf20Sopenharmony_ci */ 4428c2ecf20Sopenharmony_cistruct atl1c_buffer { 4438c2ecf20Sopenharmony_ci struct sk_buff *skb; /* socket buffer */ 4448c2ecf20Sopenharmony_ci u16 length; /* rx buffer length */ 4458c2ecf20Sopenharmony_ci u16 flags; /* information of buffer */ 4468c2ecf20Sopenharmony_ci#define ATL1C_BUFFER_FREE 0x0001 4478c2ecf20Sopenharmony_ci#define ATL1C_BUFFER_BUSY 0x0002 4488c2ecf20Sopenharmony_ci#define ATL1C_BUFFER_STATE_MASK 0x0003 4498c2ecf20Sopenharmony_ci 4508c2ecf20Sopenharmony_ci#define ATL1C_PCIMAP_SINGLE 0x0004 4518c2ecf20Sopenharmony_ci#define ATL1C_PCIMAP_PAGE 0x0008 4528c2ecf20Sopenharmony_ci#define ATL1C_PCIMAP_TYPE_MASK 0x000C 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_ci#define ATL1C_PCIMAP_TODEVICE 0x0010 4558c2ecf20Sopenharmony_ci#define ATL1C_PCIMAP_FROMDEVICE 0x0020 4568c2ecf20Sopenharmony_ci#define ATL1C_PCIMAP_DIRECTION_MASK 0x0030 4578c2ecf20Sopenharmony_ci dma_addr_t dma; 4588c2ecf20Sopenharmony_ci}; 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_ci#define ATL1C_SET_BUFFER_STATE(buff, state) do { \ 4618c2ecf20Sopenharmony_ci ((buff)->flags) &= ~ATL1C_BUFFER_STATE_MASK; \ 4628c2ecf20Sopenharmony_ci ((buff)->flags) |= (state); \ 4638c2ecf20Sopenharmony_ci } while (0) 4648c2ecf20Sopenharmony_ci 4658c2ecf20Sopenharmony_ci#define ATL1C_SET_PCIMAP_TYPE(buff, type, direction) do { \ 4668c2ecf20Sopenharmony_ci ((buff)->flags) &= ~ATL1C_PCIMAP_TYPE_MASK; \ 4678c2ecf20Sopenharmony_ci ((buff)->flags) |= (type); \ 4688c2ecf20Sopenharmony_ci ((buff)->flags) &= ~ATL1C_PCIMAP_DIRECTION_MASK; \ 4698c2ecf20Sopenharmony_ci ((buff)->flags) |= (direction); \ 4708c2ecf20Sopenharmony_ci } while (0) 4718c2ecf20Sopenharmony_ci 4728c2ecf20Sopenharmony_ci/* transimit packet descriptor (tpd) ring */ 4738c2ecf20Sopenharmony_cistruct atl1c_tpd_ring { 4748c2ecf20Sopenharmony_ci void *desc; /* descriptor ring virtual address */ 4758c2ecf20Sopenharmony_ci dma_addr_t dma; /* descriptor ring physical address */ 4768c2ecf20Sopenharmony_ci u16 size; /* descriptor ring length in bytes */ 4778c2ecf20Sopenharmony_ci u16 count; /* number of descriptors in the ring */ 4788c2ecf20Sopenharmony_ci u16 next_to_use; 4798c2ecf20Sopenharmony_ci atomic_t next_to_clean; 4808c2ecf20Sopenharmony_ci struct atl1c_buffer *buffer_info; 4818c2ecf20Sopenharmony_ci}; 4828c2ecf20Sopenharmony_ci 4838c2ecf20Sopenharmony_ci/* receive free descriptor (rfd) ring */ 4848c2ecf20Sopenharmony_cistruct atl1c_rfd_ring { 4858c2ecf20Sopenharmony_ci void *desc; /* descriptor ring virtual address */ 4868c2ecf20Sopenharmony_ci dma_addr_t dma; /* descriptor ring physical address */ 4878c2ecf20Sopenharmony_ci u16 size; /* descriptor ring length in bytes */ 4888c2ecf20Sopenharmony_ci u16 count; /* number of descriptors in the ring */ 4898c2ecf20Sopenharmony_ci u16 next_to_use; 4908c2ecf20Sopenharmony_ci u16 next_to_clean; 4918c2ecf20Sopenharmony_ci struct atl1c_buffer *buffer_info; 4928c2ecf20Sopenharmony_ci}; 4938c2ecf20Sopenharmony_ci 4948c2ecf20Sopenharmony_ci/* receive return descriptor (rrd) ring */ 4958c2ecf20Sopenharmony_cistruct atl1c_rrd_ring { 4968c2ecf20Sopenharmony_ci void *desc; /* descriptor ring virtual address */ 4978c2ecf20Sopenharmony_ci dma_addr_t dma; /* descriptor ring physical address */ 4988c2ecf20Sopenharmony_ci u16 size; /* descriptor ring length in bytes */ 4998c2ecf20Sopenharmony_ci u16 count; /* number of descriptors in the ring */ 5008c2ecf20Sopenharmony_ci u16 next_to_use; 5018c2ecf20Sopenharmony_ci u16 next_to_clean; 5028c2ecf20Sopenharmony_ci}; 5038c2ecf20Sopenharmony_ci 5048c2ecf20Sopenharmony_ci/* board specific private data structure */ 5058c2ecf20Sopenharmony_cistruct atl1c_adapter { 5068c2ecf20Sopenharmony_ci struct net_device *netdev; 5078c2ecf20Sopenharmony_ci struct pci_dev *pdev; 5088c2ecf20Sopenharmony_ci struct napi_struct napi; 5098c2ecf20Sopenharmony_ci struct page *rx_page; 5108c2ecf20Sopenharmony_ci unsigned int rx_page_offset; 5118c2ecf20Sopenharmony_ci unsigned int rx_frag_size; 5128c2ecf20Sopenharmony_ci struct atl1c_hw hw; 5138c2ecf20Sopenharmony_ci struct atl1c_hw_stats hw_stats; 5148c2ecf20Sopenharmony_ci struct mii_if_info mii; /* MII interface info */ 5158c2ecf20Sopenharmony_ci u16 rx_buffer_len; 5168c2ecf20Sopenharmony_ci 5178c2ecf20Sopenharmony_ci unsigned long flags; 5188c2ecf20Sopenharmony_ci#define __AT_TESTING 0x0001 5198c2ecf20Sopenharmony_ci#define __AT_RESETTING 0x0002 5208c2ecf20Sopenharmony_ci#define __AT_DOWN 0x0003 5218c2ecf20Sopenharmony_ci unsigned long work_event; 5228c2ecf20Sopenharmony_ci#define ATL1C_WORK_EVENT_RESET 0 5238c2ecf20Sopenharmony_ci#define ATL1C_WORK_EVENT_LINK_CHANGE 1 5248c2ecf20Sopenharmony_ci u32 msg_enable; 5258c2ecf20Sopenharmony_ci 5268c2ecf20Sopenharmony_ci bool have_msi; 5278c2ecf20Sopenharmony_ci u32 wol; 5288c2ecf20Sopenharmony_ci u16 link_speed; 5298c2ecf20Sopenharmony_ci u16 link_duplex; 5308c2ecf20Sopenharmony_ci 5318c2ecf20Sopenharmony_ci spinlock_t mdio_lock; 5328c2ecf20Sopenharmony_ci atomic_t irq_sem; 5338c2ecf20Sopenharmony_ci 5348c2ecf20Sopenharmony_ci struct work_struct common_task; 5358c2ecf20Sopenharmony_ci struct timer_list watchdog_timer; 5368c2ecf20Sopenharmony_ci struct timer_list phy_config_timer; 5378c2ecf20Sopenharmony_ci 5388c2ecf20Sopenharmony_ci /* All Descriptor memory */ 5398c2ecf20Sopenharmony_ci struct atl1c_ring_header ring_header; 5408c2ecf20Sopenharmony_ci struct atl1c_tpd_ring tpd_ring[AT_MAX_TRANSMIT_QUEUE]; 5418c2ecf20Sopenharmony_ci struct atl1c_rfd_ring rfd_ring; 5428c2ecf20Sopenharmony_ci struct atl1c_rrd_ring rrd_ring; 5438c2ecf20Sopenharmony_ci u32 bd_number; /* board number;*/ 5448c2ecf20Sopenharmony_ci}; 5458c2ecf20Sopenharmony_ci 5468c2ecf20Sopenharmony_ci#define AT_WRITE_REG(a, reg, value) ( \ 5478c2ecf20Sopenharmony_ci writel((value), ((a)->hw_addr + reg))) 5488c2ecf20Sopenharmony_ci 5498c2ecf20Sopenharmony_ci#define AT_WRITE_FLUSH(a) (\ 5508c2ecf20Sopenharmony_ci readl((a)->hw_addr)) 5518c2ecf20Sopenharmony_ci 5528c2ecf20Sopenharmony_ci#define AT_READ_REG(a, reg, pdata) do { \ 5538c2ecf20Sopenharmony_ci if (unlikely((a)->hibernate)) { \ 5548c2ecf20Sopenharmony_ci readl((a)->hw_addr + reg); \ 5558c2ecf20Sopenharmony_ci *(u32 *)pdata = readl((a)->hw_addr + reg); \ 5568c2ecf20Sopenharmony_ci } else { \ 5578c2ecf20Sopenharmony_ci *(u32 *)pdata = readl((a)->hw_addr + reg); \ 5588c2ecf20Sopenharmony_ci } \ 5598c2ecf20Sopenharmony_ci } while (0) 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_ci#define AT_WRITE_REGB(a, reg, value) (\ 5628c2ecf20Sopenharmony_ci writeb((value), ((a)->hw_addr + reg))) 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_ci#define AT_READ_REGB(a, reg) (\ 5658c2ecf20Sopenharmony_ci readb((a)->hw_addr + reg)) 5668c2ecf20Sopenharmony_ci 5678c2ecf20Sopenharmony_ci#define AT_WRITE_REGW(a, reg, value) (\ 5688c2ecf20Sopenharmony_ci writew((value), ((a)->hw_addr + reg))) 5698c2ecf20Sopenharmony_ci 5708c2ecf20Sopenharmony_ci#define AT_READ_REGW(a, reg, pdata) do { \ 5718c2ecf20Sopenharmony_ci if (unlikely((a)->hibernate)) { \ 5728c2ecf20Sopenharmony_ci readw((a)->hw_addr + reg); \ 5738c2ecf20Sopenharmony_ci *(u16 *)pdata = readw((a)->hw_addr + reg); \ 5748c2ecf20Sopenharmony_ci } else { \ 5758c2ecf20Sopenharmony_ci *(u16 *)pdata = readw((a)->hw_addr + reg); \ 5768c2ecf20Sopenharmony_ci } \ 5778c2ecf20Sopenharmony_ci } while (0) 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_ci#define AT_WRITE_REG_ARRAY(a, reg, offset, value) ( \ 5808c2ecf20Sopenharmony_ci writel((value), (((a)->hw_addr + reg) + ((offset) << 2)))) 5818c2ecf20Sopenharmony_ci 5828c2ecf20Sopenharmony_ci#define AT_READ_REG_ARRAY(a, reg, offset) ( \ 5838c2ecf20Sopenharmony_ci readl(((a)->hw_addr + reg) + ((offset) << 2))) 5848c2ecf20Sopenharmony_ci 5858c2ecf20Sopenharmony_ciextern char atl1c_driver_name[]; 5868c2ecf20Sopenharmony_ci 5878c2ecf20Sopenharmony_civoid atl1c_reinit_locked(struct atl1c_adapter *adapter); 5888c2ecf20Sopenharmony_cis32 atl1c_reset_hw(struct atl1c_hw *hw); 5898c2ecf20Sopenharmony_civoid atl1c_set_ethtool_ops(struct net_device *netdev); 5908c2ecf20Sopenharmony_ci#endif /* _ATL1C_H_ */ 591