18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * drivers/net/ethernet/freescale/gianfar.h 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Gianfar Ethernet Driver 68c2ecf20Sopenharmony_ci * Driver for FEC on MPC8540 and TSEC on MPC8540/MPC8560 78c2ecf20Sopenharmony_ci * Based on 8260_io/fcc_enet.c 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * Author: Andy Fleming 108c2ecf20Sopenharmony_ci * Maintainer: Kumar Gala 118c2ecf20Sopenharmony_ci * Modifier: Sandeep Gopalpet <sandeep.kumar@freescale.com> 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci * Copyright 2002-2009, 2011-2013 Freescale Semiconductor, Inc. 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * Still left to do: 168c2ecf20Sopenharmony_ci * -Add support for module parameters 178c2ecf20Sopenharmony_ci * -Add patch for ethtool phys id 188c2ecf20Sopenharmony_ci */ 198c2ecf20Sopenharmony_ci#ifndef __GIANFAR_H 208c2ecf20Sopenharmony_ci#define __GIANFAR_H 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#include <linux/kernel.h> 238c2ecf20Sopenharmony_ci#include <linux/sched.h> 248c2ecf20Sopenharmony_ci#include <linux/string.h> 258c2ecf20Sopenharmony_ci#include <linux/errno.h> 268c2ecf20Sopenharmony_ci#include <linux/slab.h> 278c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 288c2ecf20Sopenharmony_ci#include <linux/delay.h> 298c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 308c2ecf20Sopenharmony_ci#include <linux/etherdevice.h> 318c2ecf20Sopenharmony_ci#include <linux/skbuff.h> 328c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 338c2ecf20Sopenharmony_ci#include <linux/mm.h> 348c2ecf20Sopenharmony_ci#include <linux/mii.h> 358c2ecf20Sopenharmony_ci#include <linux/phy.h> 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#include <asm/io.h> 388c2ecf20Sopenharmony_ci#include <asm/irq.h> 398c2ecf20Sopenharmony_ci#include <linux/uaccess.h> 408c2ecf20Sopenharmony_ci#include <linux/module.h> 418c2ecf20Sopenharmony_ci#include <linux/crc32.h> 428c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 438c2ecf20Sopenharmony_ci#include <linux/ethtool.h> 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistruct ethtool_flow_spec_container { 468c2ecf20Sopenharmony_ci struct ethtool_rx_flow_spec fs; 478c2ecf20Sopenharmony_ci struct list_head list; 488c2ecf20Sopenharmony_ci}; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cistruct ethtool_rx_list { 518c2ecf20Sopenharmony_ci struct list_head list; 528c2ecf20Sopenharmony_ci unsigned int count; 538c2ecf20Sopenharmony_ci}; 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci/* The maximum number of packets to be handled in one call of gfar_poll */ 568c2ecf20Sopenharmony_ci#define GFAR_DEV_WEIGHT 64 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/* Length for FCB */ 598c2ecf20Sopenharmony_ci#define GMAC_FCB_LEN 8 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci/* Length for TxPAL */ 628c2ecf20Sopenharmony_ci#define GMAC_TXPAL_LEN 16 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* Default padding amount */ 658c2ecf20Sopenharmony_ci#define DEFAULT_PADDING 2 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci/* Number of bytes to align the rx bufs to */ 688c2ecf20Sopenharmony_ci#define RXBUF_ALIGNMENT 64 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define DRV_NAME "gfar-enet" 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci/* MAXIMUM NUMBER OF QUEUES SUPPORTED */ 738c2ecf20Sopenharmony_ci#define MAX_TX_QS 0x8 748c2ecf20Sopenharmony_ci#define MAX_RX_QS 0x8 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci/* MAXIMUM NUMBER OF GROUPS SUPPORTED */ 778c2ecf20Sopenharmony_ci#define MAXGROUPS 0x2 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* These need to be powers of 2 for this driver */ 808c2ecf20Sopenharmony_ci#define DEFAULT_TX_RING_SIZE 256 818c2ecf20Sopenharmony_ci#define DEFAULT_RX_RING_SIZE 256 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#define GFAR_RX_BUFF_ALLOC 16 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci#define GFAR_RX_MAX_RING_SIZE 256 868c2ecf20Sopenharmony_ci#define GFAR_TX_MAX_RING_SIZE 256 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define FBTHR_SHIFT 24 898c2ecf20Sopenharmony_ci#define DEFAULT_RX_LFC_THR 16 908c2ecf20Sopenharmony_ci#define DEFAULT_LFC_PTVVAL 4 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define GFAR_RXB_TRUESIZE 2048 938c2ecf20Sopenharmony_ci#define GFAR_SKBFRAG_OVR (RXBUF_ALIGNMENT \ 948c2ecf20Sopenharmony_ci + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) 958c2ecf20Sopenharmony_ci#define GFAR_RXB_SIZE rounddown(GFAR_RXB_TRUESIZE - GFAR_SKBFRAG_OVR, 64) 968c2ecf20Sopenharmony_ci#define GFAR_SKBFRAG_SIZE (GFAR_RXB_SIZE + GFAR_SKBFRAG_OVR) 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#define TX_RING_MOD_MASK(size) (size-1) 998c2ecf20Sopenharmony_ci#define RX_RING_MOD_MASK(size) (size-1) 1008c2ecf20Sopenharmony_ci#define GFAR_JUMBO_FRAME_SIZE 9600 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define DEFAULT_FIFO_TX_THR 0x100 1038c2ecf20Sopenharmony_ci#define DEFAULT_FIFO_TX_STARVE 0x40 1048c2ecf20Sopenharmony_ci#define DEFAULT_FIFO_TX_STARVE_OFF 0x80 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci/* The number of Exact Match registers */ 1078c2ecf20Sopenharmony_ci#define GFAR_EM_NUM 15 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/* Latency of interface clock in nanoseconds */ 1108c2ecf20Sopenharmony_ci/* Interface clock latency , in this case, means the 1118c2ecf20Sopenharmony_ci * time described by a value of 1 in the interrupt 1128c2ecf20Sopenharmony_ci * coalescing registers' time fields. Since those fields 1138c2ecf20Sopenharmony_ci * refer to the time it takes for 64 clocks to pass, the 1148c2ecf20Sopenharmony_ci * latencies are as such: 1158c2ecf20Sopenharmony_ci * GBIT = 125MHz => 8ns/clock => 8*64 ns / tick 1168c2ecf20Sopenharmony_ci * 100 = 25 MHz => 40ns/clock => 40*64 ns / tick 1178c2ecf20Sopenharmony_ci * 10 = 2.5 MHz => 400ns/clock => 400*64 ns / tick 1188c2ecf20Sopenharmony_ci */ 1198c2ecf20Sopenharmony_ci#define GFAR_GBIT_TIME 512 1208c2ecf20Sopenharmony_ci#define GFAR_100_TIME 2560 1218c2ecf20Sopenharmony_ci#define GFAR_10_TIME 25600 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci#define DEFAULT_TX_COALESCE 1 1248c2ecf20Sopenharmony_ci#define DEFAULT_TXCOUNT 16 1258c2ecf20Sopenharmony_ci#define DEFAULT_TXTIME 21 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci#define DEFAULT_RXTIME 21 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci#define DEFAULT_RX_COALESCE 0 1308c2ecf20Sopenharmony_ci#define DEFAULT_RXCOUNT 0 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci/* TBI register addresses */ 1338c2ecf20Sopenharmony_ci#define MII_TBICON 0x11 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci/* TBICON register bit fields */ 1368c2ecf20Sopenharmony_ci#define TBICON_CLK_SELECT 0x0020 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci/* MAC register bits */ 1398c2ecf20Sopenharmony_ci#define MACCFG1_SOFT_RESET 0x80000000 1408c2ecf20Sopenharmony_ci#define MACCFG1_RESET_RX_MC 0x00080000 1418c2ecf20Sopenharmony_ci#define MACCFG1_RESET_TX_MC 0x00040000 1428c2ecf20Sopenharmony_ci#define MACCFG1_RESET_RX_FUN 0x00020000 1438c2ecf20Sopenharmony_ci#define MACCFG1_RESET_TX_FUN 0x00010000 1448c2ecf20Sopenharmony_ci#define MACCFG1_LOOPBACK 0x00000100 1458c2ecf20Sopenharmony_ci#define MACCFG1_RX_FLOW 0x00000020 1468c2ecf20Sopenharmony_ci#define MACCFG1_TX_FLOW 0x00000010 1478c2ecf20Sopenharmony_ci#define MACCFG1_SYNCD_RX_EN 0x00000008 1488c2ecf20Sopenharmony_ci#define MACCFG1_RX_EN 0x00000004 1498c2ecf20Sopenharmony_ci#define MACCFG1_SYNCD_TX_EN 0x00000002 1508c2ecf20Sopenharmony_ci#define MACCFG1_TX_EN 0x00000001 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci#define MACCFG2_INIT_SETTINGS 0x00007205 1538c2ecf20Sopenharmony_ci#define MACCFG2_FULL_DUPLEX 0x00000001 1548c2ecf20Sopenharmony_ci#define MACCFG2_IF 0x00000300 1558c2ecf20Sopenharmony_ci#define MACCFG2_MII 0x00000100 1568c2ecf20Sopenharmony_ci#define MACCFG2_GMII 0x00000200 1578c2ecf20Sopenharmony_ci#define MACCFG2_HUGEFRAME 0x00000020 1588c2ecf20Sopenharmony_ci#define MACCFG2_LENGTHCHECK 0x00000010 1598c2ecf20Sopenharmony_ci#define MACCFG2_MPEN 0x00000008 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci#define ECNTRL_FIFM 0x00008000 1628c2ecf20Sopenharmony_ci#define ECNTRL_INIT_SETTINGS 0x00001000 1638c2ecf20Sopenharmony_ci#define ECNTRL_TBI_MODE 0x00000020 1648c2ecf20Sopenharmony_ci#define ECNTRL_REDUCED_MODE 0x00000010 1658c2ecf20Sopenharmony_ci#define ECNTRL_R100 0x00000008 1668c2ecf20Sopenharmony_ci#define ECNTRL_REDUCED_MII_MODE 0x00000004 1678c2ecf20Sopenharmony_ci#define ECNTRL_SGMII_MODE 0x00000002 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci#define MINFLR_INIT_SETTINGS 0x00000040 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ci/* Tqueue control */ 1728c2ecf20Sopenharmony_ci#define TQUEUE_EN0 0x00008000 1738c2ecf20Sopenharmony_ci#define TQUEUE_EN1 0x00004000 1748c2ecf20Sopenharmony_ci#define TQUEUE_EN2 0x00002000 1758c2ecf20Sopenharmony_ci#define TQUEUE_EN3 0x00001000 1768c2ecf20Sopenharmony_ci#define TQUEUE_EN4 0x00000800 1778c2ecf20Sopenharmony_ci#define TQUEUE_EN5 0x00000400 1788c2ecf20Sopenharmony_ci#define TQUEUE_EN6 0x00000200 1798c2ecf20Sopenharmony_ci#define TQUEUE_EN7 0x00000100 1808c2ecf20Sopenharmony_ci#define TQUEUE_EN_ALL 0x0000FF00 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci#define TR03WT_WT0_MASK 0xFF000000 1838c2ecf20Sopenharmony_ci#define TR03WT_WT1_MASK 0x00FF0000 1848c2ecf20Sopenharmony_ci#define TR03WT_WT2_MASK 0x0000FF00 1858c2ecf20Sopenharmony_ci#define TR03WT_WT3_MASK 0x000000FF 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci#define TR47WT_WT4_MASK 0xFF000000 1888c2ecf20Sopenharmony_ci#define TR47WT_WT5_MASK 0x00FF0000 1898c2ecf20Sopenharmony_ci#define TR47WT_WT6_MASK 0x0000FF00 1908c2ecf20Sopenharmony_ci#define TR47WT_WT7_MASK 0x000000FF 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci/* Rqueue control */ 1938c2ecf20Sopenharmony_ci#define RQUEUE_EX0 0x00800000 1948c2ecf20Sopenharmony_ci#define RQUEUE_EX1 0x00400000 1958c2ecf20Sopenharmony_ci#define RQUEUE_EX2 0x00200000 1968c2ecf20Sopenharmony_ci#define RQUEUE_EX3 0x00100000 1978c2ecf20Sopenharmony_ci#define RQUEUE_EX4 0x00080000 1988c2ecf20Sopenharmony_ci#define RQUEUE_EX5 0x00040000 1998c2ecf20Sopenharmony_ci#define RQUEUE_EX6 0x00020000 2008c2ecf20Sopenharmony_ci#define RQUEUE_EX7 0x00010000 2018c2ecf20Sopenharmony_ci#define RQUEUE_EX_ALL 0x00FF0000 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci#define RQUEUE_EN0 0x00000080 2048c2ecf20Sopenharmony_ci#define RQUEUE_EN1 0x00000040 2058c2ecf20Sopenharmony_ci#define RQUEUE_EN2 0x00000020 2068c2ecf20Sopenharmony_ci#define RQUEUE_EN3 0x00000010 2078c2ecf20Sopenharmony_ci#define RQUEUE_EN4 0x00000008 2088c2ecf20Sopenharmony_ci#define RQUEUE_EN5 0x00000004 2098c2ecf20Sopenharmony_ci#define RQUEUE_EN6 0x00000002 2108c2ecf20Sopenharmony_ci#define RQUEUE_EN7 0x00000001 2118c2ecf20Sopenharmony_ci#define RQUEUE_EN_ALL 0x000000FF 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci/* Init to do tx snooping for buffers and descriptors */ 2148c2ecf20Sopenharmony_ci#define DMACTRL_INIT_SETTINGS 0x000000c3 2158c2ecf20Sopenharmony_ci#define DMACTRL_GRS 0x00000010 2168c2ecf20Sopenharmony_ci#define DMACTRL_GTS 0x00000008 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci#define TSTAT_CLEAR_THALT_ALL 0xFF000000 2198c2ecf20Sopenharmony_ci#define TSTAT_CLEAR_THALT 0x80000000 2208c2ecf20Sopenharmony_ci#define TSTAT_CLEAR_THALT0 0x80000000 2218c2ecf20Sopenharmony_ci#define TSTAT_CLEAR_THALT1 0x40000000 2228c2ecf20Sopenharmony_ci#define TSTAT_CLEAR_THALT2 0x20000000 2238c2ecf20Sopenharmony_ci#define TSTAT_CLEAR_THALT3 0x10000000 2248c2ecf20Sopenharmony_ci#define TSTAT_CLEAR_THALT4 0x08000000 2258c2ecf20Sopenharmony_ci#define TSTAT_CLEAR_THALT5 0x04000000 2268c2ecf20Sopenharmony_ci#define TSTAT_CLEAR_THALT6 0x02000000 2278c2ecf20Sopenharmony_ci#define TSTAT_CLEAR_THALT7 0x01000000 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci/* Interrupt coalescing macros */ 2308c2ecf20Sopenharmony_ci#define IC_ICEN 0x80000000 2318c2ecf20Sopenharmony_ci#define IC_ICFT_MASK 0x1fe00000 2328c2ecf20Sopenharmony_ci#define IC_ICFT_SHIFT 21 2338c2ecf20Sopenharmony_ci#define mk_ic_icft(x) \ 2348c2ecf20Sopenharmony_ci (((unsigned int)x << IC_ICFT_SHIFT)&IC_ICFT_MASK) 2358c2ecf20Sopenharmony_ci#define IC_ICTT_MASK 0x0000ffff 2368c2ecf20Sopenharmony_ci#define mk_ic_ictt(x) (x&IC_ICTT_MASK) 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci#define mk_ic_value(count, time) (IC_ICEN | \ 2398c2ecf20Sopenharmony_ci mk_ic_icft(count) | \ 2408c2ecf20Sopenharmony_ci mk_ic_ictt(time)) 2418c2ecf20Sopenharmony_ci#define get_icft_value(ic) (((unsigned long)ic & IC_ICFT_MASK) >> \ 2428c2ecf20Sopenharmony_ci IC_ICFT_SHIFT) 2438c2ecf20Sopenharmony_ci#define get_ictt_value(ic) ((unsigned long)ic & IC_ICTT_MASK) 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci#define DEFAULT_TXIC mk_ic_value(DEFAULT_TXCOUNT, DEFAULT_TXTIME) 2468c2ecf20Sopenharmony_ci#define DEFAULT_RXIC mk_ic_value(DEFAULT_RXCOUNT, DEFAULT_RXTIME) 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_ci#define RCTRL_TS_ENABLE 0x01000000 2498c2ecf20Sopenharmony_ci#define RCTRL_PAL_MASK 0x001f0000 2508c2ecf20Sopenharmony_ci#define RCTRL_LFC 0x00004000 2518c2ecf20Sopenharmony_ci#define RCTRL_VLEX 0x00002000 2528c2ecf20Sopenharmony_ci#define RCTRL_FILREN 0x00001000 2538c2ecf20Sopenharmony_ci#define RCTRL_GHTX 0x00000400 2548c2ecf20Sopenharmony_ci#define RCTRL_IPCSEN 0x00000200 2558c2ecf20Sopenharmony_ci#define RCTRL_TUCSEN 0x00000100 2568c2ecf20Sopenharmony_ci#define RCTRL_PRSDEP_MASK 0x000000c0 2578c2ecf20Sopenharmony_ci#define RCTRL_PRSDEP_INIT 0x000000c0 2588c2ecf20Sopenharmony_ci#define RCTRL_PRSFM 0x00000020 2598c2ecf20Sopenharmony_ci#define RCTRL_PROM 0x00000008 2608c2ecf20Sopenharmony_ci#define RCTRL_EMEN 0x00000002 2618c2ecf20Sopenharmony_ci#define RCTRL_REQ_PARSER (RCTRL_VLEX | RCTRL_IPCSEN | \ 2628c2ecf20Sopenharmony_ci RCTRL_TUCSEN | RCTRL_FILREN) 2638c2ecf20Sopenharmony_ci#define RCTRL_CHECKSUMMING (RCTRL_IPCSEN | RCTRL_TUCSEN | \ 2648c2ecf20Sopenharmony_ci RCTRL_PRSDEP_INIT) 2658c2ecf20Sopenharmony_ci#define RCTRL_EXTHASH (RCTRL_GHTX) 2668c2ecf20Sopenharmony_ci#define RCTRL_VLAN (RCTRL_PRSDEP_INIT) 2678c2ecf20Sopenharmony_ci#define RCTRL_PADDING(x) ((x << 16) & RCTRL_PAL_MASK) 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci#define RSTAT_CLEAR_RHALT 0x00800000 2718c2ecf20Sopenharmony_ci#define RSTAT_CLEAR_RXF0 0x00000080 2728c2ecf20Sopenharmony_ci#define RSTAT_RXF_MASK 0x000000ff 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci#define TCTRL_IPCSEN 0x00004000 2758c2ecf20Sopenharmony_ci#define TCTRL_TUCSEN 0x00002000 2768c2ecf20Sopenharmony_ci#define TCTRL_VLINS 0x00001000 2778c2ecf20Sopenharmony_ci#define TCTRL_THDF 0x00000800 2788c2ecf20Sopenharmony_ci#define TCTRL_RFCPAUSE 0x00000010 2798c2ecf20Sopenharmony_ci#define TCTRL_TFCPAUSE 0x00000008 2808c2ecf20Sopenharmony_ci#define TCTRL_TXSCHED_MASK 0x00000006 2818c2ecf20Sopenharmony_ci#define TCTRL_TXSCHED_INIT 0x00000000 2828c2ecf20Sopenharmony_ci/* priority scheduling */ 2838c2ecf20Sopenharmony_ci#define TCTRL_TXSCHED_PRIO 0x00000002 2848c2ecf20Sopenharmony_ci/* weighted round-robin scheduling (WRRS) */ 2858c2ecf20Sopenharmony_ci#define TCTRL_TXSCHED_WRRS 0x00000004 2868c2ecf20Sopenharmony_ci/* default WRRS weight and policy setting, 2878c2ecf20Sopenharmony_ci * tailored to the tr03wt and tr47wt registers: 2888c2ecf20Sopenharmony_ci * equal weight for all Tx Qs, measured in 64byte units 2898c2ecf20Sopenharmony_ci */ 2908c2ecf20Sopenharmony_ci#define DEFAULT_WRRS_WEIGHT 0x18181818 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci#define TCTRL_INIT_CSUM (TCTRL_TUCSEN | TCTRL_IPCSEN) 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci#define IEVENT_INIT_CLEAR 0xffffffff 2958c2ecf20Sopenharmony_ci#define IEVENT_BABR 0x80000000 2968c2ecf20Sopenharmony_ci#define IEVENT_RXC 0x40000000 2978c2ecf20Sopenharmony_ci#define IEVENT_BSY 0x20000000 2988c2ecf20Sopenharmony_ci#define IEVENT_EBERR 0x10000000 2998c2ecf20Sopenharmony_ci#define IEVENT_MSRO 0x04000000 3008c2ecf20Sopenharmony_ci#define IEVENT_GTSC 0x02000000 3018c2ecf20Sopenharmony_ci#define IEVENT_BABT 0x01000000 3028c2ecf20Sopenharmony_ci#define IEVENT_TXC 0x00800000 3038c2ecf20Sopenharmony_ci#define IEVENT_TXE 0x00400000 3048c2ecf20Sopenharmony_ci#define IEVENT_TXB 0x00200000 3058c2ecf20Sopenharmony_ci#define IEVENT_TXF 0x00100000 3068c2ecf20Sopenharmony_ci#define IEVENT_LC 0x00040000 3078c2ecf20Sopenharmony_ci#define IEVENT_CRL 0x00020000 3088c2ecf20Sopenharmony_ci#define IEVENT_XFUN 0x00010000 3098c2ecf20Sopenharmony_ci#define IEVENT_RXB0 0x00008000 3108c2ecf20Sopenharmony_ci#define IEVENT_MAG 0x00000800 3118c2ecf20Sopenharmony_ci#define IEVENT_GRSC 0x00000100 3128c2ecf20Sopenharmony_ci#define IEVENT_RXF0 0x00000080 3138c2ecf20Sopenharmony_ci#define IEVENT_FGPI 0x00000010 3148c2ecf20Sopenharmony_ci#define IEVENT_FIR 0x00000008 3158c2ecf20Sopenharmony_ci#define IEVENT_FIQ 0x00000004 3168c2ecf20Sopenharmony_ci#define IEVENT_DPE 0x00000002 3178c2ecf20Sopenharmony_ci#define IEVENT_PERR 0x00000001 3188c2ecf20Sopenharmony_ci#define IEVENT_RX_MASK (IEVENT_RXB0 | IEVENT_RXF0 | IEVENT_BSY) 3198c2ecf20Sopenharmony_ci#define IEVENT_TX_MASK (IEVENT_TXB | IEVENT_TXF) 3208c2ecf20Sopenharmony_ci#define IEVENT_RTX_MASK (IEVENT_RX_MASK | IEVENT_TX_MASK) 3218c2ecf20Sopenharmony_ci#define IEVENT_ERR_MASK \ 3228c2ecf20Sopenharmony_ci(IEVENT_RXC | IEVENT_BSY | IEVENT_EBERR | IEVENT_MSRO | \ 3238c2ecf20Sopenharmony_ci IEVENT_BABT | IEVENT_TXC | IEVENT_TXE | IEVENT_LC \ 3248c2ecf20Sopenharmony_ci | IEVENT_CRL | IEVENT_XFUN | IEVENT_DPE | IEVENT_PERR \ 3258c2ecf20Sopenharmony_ci | IEVENT_MAG | IEVENT_BABR) 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci#define IMASK_INIT_CLEAR 0x00000000 3288c2ecf20Sopenharmony_ci#define IMASK_BABR 0x80000000 3298c2ecf20Sopenharmony_ci#define IMASK_RXC 0x40000000 3308c2ecf20Sopenharmony_ci#define IMASK_BSY 0x20000000 3318c2ecf20Sopenharmony_ci#define IMASK_EBERR 0x10000000 3328c2ecf20Sopenharmony_ci#define IMASK_MSRO 0x04000000 3338c2ecf20Sopenharmony_ci#define IMASK_GTSC 0x02000000 3348c2ecf20Sopenharmony_ci#define IMASK_BABT 0x01000000 3358c2ecf20Sopenharmony_ci#define IMASK_TXC 0x00800000 3368c2ecf20Sopenharmony_ci#define IMASK_TXEEN 0x00400000 3378c2ecf20Sopenharmony_ci#define IMASK_TXBEN 0x00200000 3388c2ecf20Sopenharmony_ci#define IMASK_TXFEN 0x00100000 3398c2ecf20Sopenharmony_ci#define IMASK_LC 0x00040000 3408c2ecf20Sopenharmony_ci#define IMASK_CRL 0x00020000 3418c2ecf20Sopenharmony_ci#define IMASK_XFUN 0x00010000 3428c2ecf20Sopenharmony_ci#define IMASK_RXB0 0x00008000 3438c2ecf20Sopenharmony_ci#define IMASK_MAG 0x00000800 3448c2ecf20Sopenharmony_ci#define IMASK_GRSC 0x00000100 3458c2ecf20Sopenharmony_ci#define IMASK_RXFEN0 0x00000080 3468c2ecf20Sopenharmony_ci#define IMASK_FGPI 0x00000010 3478c2ecf20Sopenharmony_ci#define IMASK_FIR 0x00000008 3488c2ecf20Sopenharmony_ci#define IMASK_FIQ 0x00000004 3498c2ecf20Sopenharmony_ci#define IMASK_DPE 0x00000002 3508c2ecf20Sopenharmony_ci#define IMASK_PERR 0x00000001 3518c2ecf20Sopenharmony_ci#define IMASK_DEFAULT (IMASK_TXEEN | IMASK_TXFEN | IMASK_TXBEN | \ 3528c2ecf20Sopenharmony_ci IMASK_RXFEN0 | IMASK_BSY | IMASK_EBERR | IMASK_BABR | \ 3538c2ecf20Sopenharmony_ci IMASK_XFUN | IMASK_RXC | IMASK_BABT | IMASK_DPE \ 3548c2ecf20Sopenharmony_ci | IMASK_PERR) 3558c2ecf20Sopenharmony_ci#define IMASK_RX_DEFAULT (IMASK_RXFEN0 | IMASK_BSY) 3568c2ecf20Sopenharmony_ci#define IMASK_TX_DEFAULT (IMASK_TXFEN | IMASK_TXBEN) 3578c2ecf20Sopenharmony_ci 3588c2ecf20Sopenharmony_ci#define IMASK_RX_DISABLED ((~(IMASK_RX_DEFAULT)) & IMASK_DEFAULT) 3598c2ecf20Sopenharmony_ci#define IMASK_TX_DISABLED ((~(IMASK_TX_DEFAULT)) & IMASK_DEFAULT) 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci/* Attribute fields */ 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_ci/* This enables rx snooping for buffers and descriptors */ 3648c2ecf20Sopenharmony_ci#define ATTR_BDSTASH 0x00000800 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci#define ATTR_BUFSTASH 0x00004000 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_ci#define ATTR_SNOOPING 0x000000c0 3698c2ecf20Sopenharmony_ci#define ATTR_INIT_SETTINGS ATTR_SNOOPING 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci#define ATTRELI_INIT_SETTINGS 0x0 3728c2ecf20Sopenharmony_ci#define ATTRELI_EL_MASK 0x3fff0000 3738c2ecf20Sopenharmony_ci#define ATTRELI_EL(x) (x << 16) 3748c2ecf20Sopenharmony_ci#define ATTRELI_EI_MASK 0x00003fff 3758c2ecf20Sopenharmony_ci#define ATTRELI_EI(x) (x) 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ci#define BD_LFLAG(flags) ((flags) << 16) 3788c2ecf20Sopenharmony_ci#define BD_LENGTH_MASK 0x0000ffff 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci#define FPR_FILER_MASK 0xFFFFFFFF 3818c2ecf20Sopenharmony_ci#define MAX_FILER_IDX 0xFF 3828c2ecf20Sopenharmony_ci 3838c2ecf20Sopenharmony_ci/* This default RIR value directly corresponds 3848c2ecf20Sopenharmony_ci * to the 3-bit hash value generated */ 3858c2ecf20Sopenharmony_ci#define DEFAULT_8RXQ_RIR0 0x05397700 3868c2ecf20Sopenharmony_ci/* Map even hash values to Q0, and odd ones to Q1 */ 3878c2ecf20Sopenharmony_ci#define DEFAULT_2RXQ_RIR0 0x04104100 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_ci/* RQFCR register bits */ 3908c2ecf20Sopenharmony_ci#define RQFCR_GPI 0x80000000 3918c2ecf20Sopenharmony_ci#define RQFCR_HASHTBL_Q 0x00000000 3928c2ecf20Sopenharmony_ci#define RQFCR_HASHTBL_0 0x00020000 3938c2ecf20Sopenharmony_ci#define RQFCR_HASHTBL_1 0x00040000 3948c2ecf20Sopenharmony_ci#define RQFCR_HASHTBL_2 0x00060000 3958c2ecf20Sopenharmony_ci#define RQFCR_HASHTBL_3 0x00080000 3968c2ecf20Sopenharmony_ci#define RQFCR_HASH 0x00010000 3978c2ecf20Sopenharmony_ci#define RQFCR_QUEUE 0x0000FC00 3988c2ecf20Sopenharmony_ci#define RQFCR_CLE 0x00000200 3998c2ecf20Sopenharmony_ci#define RQFCR_RJE 0x00000100 4008c2ecf20Sopenharmony_ci#define RQFCR_AND 0x00000080 4018c2ecf20Sopenharmony_ci#define RQFCR_CMP_EXACT 0x00000000 4028c2ecf20Sopenharmony_ci#define RQFCR_CMP_MATCH 0x00000020 4038c2ecf20Sopenharmony_ci#define RQFCR_CMP_NOEXACT 0x00000040 4048c2ecf20Sopenharmony_ci#define RQFCR_CMP_NOMATCH 0x00000060 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci/* RQFCR PID values */ 4078c2ecf20Sopenharmony_ci#define RQFCR_PID_MASK 0x00000000 4088c2ecf20Sopenharmony_ci#define RQFCR_PID_PARSE 0x00000001 4098c2ecf20Sopenharmony_ci#define RQFCR_PID_ARB 0x00000002 4108c2ecf20Sopenharmony_ci#define RQFCR_PID_DAH 0x00000003 4118c2ecf20Sopenharmony_ci#define RQFCR_PID_DAL 0x00000004 4128c2ecf20Sopenharmony_ci#define RQFCR_PID_SAH 0x00000005 4138c2ecf20Sopenharmony_ci#define RQFCR_PID_SAL 0x00000006 4148c2ecf20Sopenharmony_ci#define RQFCR_PID_ETY 0x00000007 4158c2ecf20Sopenharmony_ci#define RQFCR_PID_VID 0x00000008 4168c2ecf20Sopenharmony_ci#define RQFCR_PID_PRI 0x00000009 4178c2ecf20Sopenharmony_ci#define RQFCR_PID_TOS 0x0000000A 4188c2ecf20Sopenharmony_ci#define RQFCR_PID_L4P 0x0000000B 4198c2ecf20Sopenharmony_ci#define RQFCR_PID_DIA 0x0000000C 4208c2ecf20Sopenharmony_ci#define RQFCR_PID_SIA 0x0000000D 4218c2ecf20Sopenharmony_ci#define RQFCR_PID_DPT 0x0000000E 4228c2ecf20Sopenharmony_ci#define RQFCR_PID_SPT 0x0000000F 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_ci/* RQFPR when PID is 0x0001 */ 4258c2ecf20Sopenharmony_ci#define RQFPR_HDR_GE_512 0x00200000 4268c2ecf20Sopenharmony_ci#define RQFPR_LERR 0x00100000 4278c2ecf20Sopenharmony_ci#define RQFPR_RAR 0x00080000 4288c2ecf20Sopenharmony_ci#define RQFPR_RARQ 0x00040000 4298c2ecf20Sopenharmony_ci#define RQFPR_AR 0x00020000 4308c2ecf20Sopenharmony_ci#define RQFPR_ARQ 0x00010000 4318c2ecf20Sopenharmony_ci#define RQFPR_EBC 0x00008000 4328c2ecf20Sopenharmony_ci#define RQFPR_VLN 0x00004000 4338c2ecf20Sopenharmony_ci#define RQFPR_CFI 0x00002000 4348c2ecf20Sopenharmony_ci#define RQFPR_JUM 0x00001000 4358c2ecf20Sopenharmony_ci#define RQFPR_IPF 0x00000800 4368c2ecf20Sopenharmony_ci#define RQFPR_FIF 0x00000400 4378c2ecf20Sopenharmony_ci#define RQFPR_IPV4 0x00000200 4388c2ecf20Sopenharmony_ci#define RQFPR_IPV6 0x00000100 4398c2ecf20Sopenharmony_ci#define RQFPR_ICC 0x00000080 4408c2ecf20Sopenharmony_ci#define RQFPR_ICV 0x00000040 4418c2ecf20Sopenharmony_ci#define RQFPR_TCP 0x00000020 4428c2ecf20Sopenharmony_ci#define RQFPR_UDP 0x00000010 4438c2ecf20Sopenharmony_ci#define RQFPR_TUC 0x00000008 4448c2ecf20Sopenharmony_ci#define RQFPR_TUV 0x00000004 4458c2ecf20Sopenharmony_ci#define RQFPR_PER 0x00000002 4468c2ecf20Sopenharmony_ci#define RQFPR_EER 0x00000001 4478c2ecf20Sopenharmony_ci 4488c2ecf20Sopenharmony_ci/* TxBD status field bits */ 4498c2ecf20Sopenharmony_ci#define TXBD_READY 0x8000 4508c2ecf20Sopenharmony_ci#define TXBD_PADCRC 0x4000 4518c2ecf20Sopenharmony_ci#define TXBD_WRAP 0x2000 4528c2ecf20Sopenharmony_ci#define TXBD_INTERRUPT 0x1000 4538c2ecf20Sopenharmony_ci#define TXBD_LAST 0x0800 4548c2ecf20Sopenharmony_ci#define TXBD_CRC 0x0400 4558c2ecf20Sopenharmony_ci#define TXBD_DEF 0x0200 4568c2ecf20Sopenharmony_ci#define TXBD_HUGEFRAME 0x0080 4578c2ecf20Sopenharmony_ci#define TXBD_LATECOLLISION 0x0080 4588c2ecf20Sopenharmony_ci#define TXBD_RETRYLIMIT 0x0040 4598c2ecf20Sopenharmony_ci#define TXBD_RETRYCOUNTMASK 0x003c 4608c2ecf20Sopenharmony_ci#define TXBD_UNDERRUN 0x0002 4618c2ecf20Sopenharmony_ci#define TXBD_TOE 0x0002 4628c2ecf20Sopenharmony_ci 4638c2ecf20Sopenharmony_ci/* Tx FCB param bits */ 4648c2ecf20Sopenharmony_ci#define TXFCB_VLN 0x80 4658c2ecf20Sopenharmony_ci#define TXFCB_IP 0x40 4668c2ecf20Sopenharmony_ci#define TXFCB_IP6 0x20 4678c2ecf20Sopenharmony_ci#define TXFCB_TUP 0x10 4688c2ecf20Sopenharmony_ci#define TXFCB_UDP 0x08 4698c2ecf20Sopenharmony_ci#define TXFCB_CIP 0x04 4708c2ecf20Sopenharmony_ci#define TXFCB_CTU 0x02 4718c2ecf20Sopenharmony_ci#define TXFCB_NPH 0x01 4728c2ecf20Sopenharmony_ci#define TXFCB_DEFAULT (TXFCB_IP|TXFCB_TUP|TXFCB_CTU|TXFCB_NPH) 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_ci/* RxBD status field bits */ 4758c2ecf20Sopenharmony_ci#define RXBD_EMPTY 0x8000 4768c2ecf20Sopenharmony_ci#define RXBD_RO1 0x4000 4778c2ecf20Sopenharmony_ci#define RXBD_WRAP 0x2000 4788c2ecf20Sopenharmony_ci#define RXBD_INTERRUPT 0x1000 4798c2ecf20Sopenharmony_ci#define RXBD_LAST 0x0800 4808c2ecf20Sopenharmony_ci#define RXBD_FIRST 0x0400 4818c2ecf20Sopenharmony_ci#define RXBD_MISS 0x0100 4828c2ecf20Sopenharmony_ci#define RXBD_BROADCAST 0x0080 4838c2ecf20Sopenharmony_ci#define RXBD_MULTICAST 0x0040 4848c2ecf20Sopenharmony_ci#define RXBD_LARGE 0x0020 4858c2ecf20Sopenharmony_ci#define RXBD_NONOCTET 0x0010 4868c2ecf20Sopenharmony_ci#define RXBD_SHORT 0x0008 4878c2ecf20Sopenharmony_ci#define RXBD_CRCERR 0x0004 4888c2ecf20Sopenharmony_ci#define RXBD_OVERRUN 0x0002 4898c2ecf20Sopenharmony_ci#define RXBD_TRUNCATED 0x0001 4908c2ecf20Sopenharmony_ci#define RXBD_STATS 0x01ff 4918c2ecf20Sopenharmony_ci#define RXBD_ERR (RXBD_LARGE | RXBD_SHORT | RXBD_NONOCTET \ 4928c2ecf20Sopenharmony_ci | RXBD_CRCERR | RXBD_OVERRUN \ 4938c2ecf20Sopenharmony_ci | RXBD_TRUNCATED) 4948c2ecf20Sopenharmony_ci 4958c2ecf20Sopenharmony_ci/* Rx FCB status field bits */ 4968c2ecf20Sopenharmony_ci#define RXFCB_VLN 0x8000 4978c2ecf20Sopenharmony_ci#define RXFCB_IP 0x4000 4988c2ecf20Sopenharmony_ci#define RXFCB_IP6 0x2000 4998c2ecf20Sopenharmony_ci#define RXFCB_TUP 0x1000 5008c2ecf20Sopenharmony_ci#define RXFCB_CIP 0x0800 5018c2ecf20Sopenharmony_ci#define RXFCB_CTU 0x0400 5028c2ecf20Sopenharmony_ci#define RXFCB_EIP 0x0200 5038c2ecf20Sopenharmony_ci#define RXFCB_ETU 0x0100 5048c2ecf20Sopenharmony_ci#define RXFCB_CSUM_MASK 0x0f00 5058c2ecf20Sopenharmony_ci#define RXFCB_PERR_MASK 0x000c 5068c2ecf20Sopenharmony_ci#define RXFCB_PERR_BADL3 0x0008 5078c2ecf20Sopenharmony_ci 5088c2ecf20Sopenharmony_ci#define GFAR_INT_NAME_MAX (IFNAMSIZ + 6) /* '_g#_xx' */ 5098c2ecf20Sopenharmony_ci 5108c2ecf20Sopenharmony_ci#define GFAR_WOL_MAGIC 0x00000001 5118c2ecf20Sopenharmony_ci#define GFAR_WOL_FILER_UCAST 0x00000002 5128c2ecf20Sopenharmony_ci 5138c2ecf20Sopenharmony_cistruct txbd8 5148c2ecf20Sopenharmony_ci{ 5158c2ecf20Sopenharmony_ci union { 5168c2ecf20Sopenharmony_ci struct { 5178c2ecf20Sopenharmony_ci __be16 status; /* Status Fields */ 5188c2ecf20Sopenharmony_ci __be16 length; /* Buffer length */ 5198c2ecf20Sopenharmony_ci }; 5208c2ecf20Sopenharmony_ci __be32 lstatus; 5218c2ecf20Sopenharmony_ci }; 5228c2ecf20Sopenharmony_ci __be32 bufPtr; /* Buffer Pointer */ 5238c2ecf20Sopenharmony_ci}; 5248c2ecf20Sopenharmony_ci 5258c2ecf20Sopenharmony_cistruct txfcb { 5268c2ecf20Sopenharmony_ci u8 flags; 5278c2ecf20Sopenharmony_ci u8 ptp; /* Flag to enable tx timestamping */ 5288c2ecf20Sopenharmony_ci u8 l4os; /* Level 4 Header Offset */ 5298c2ecf20Sopenharmony_ci u8 l3os; /* Level 3 Header Offset */ 5308c2ecf20Sopenharmony_ci __be16 phcs; /* Pseudo-header Checksum */ 5318c2ecf20Sopenharmony_ci __be16 vlctl; /* VLAN control word */ 5328c2ecf20Sopenharmony_ci}; 5338c2ecf20Sopenharmony_ci 5348c2ecf20Sopenharmony_cistruct rxbd8 5358c2ecf20Sopenharmony_ci{ 5368c2ecf20Sopenharmony_ci union { 5378c2ecf20Sopenharmony_ci struct { 5388c2ecf20Sopenharmony_ci __be16 status; /* Status Fields */ 5398c2ecf20Sopenharmony_ci __be16 length; /* Buffer Length */ 5408c2ecf20Sopenharmony_ci }; 5418c2ecf20Sopenharmony_ci __be32 lstatus; 5428c2ecf20Sopenharmony_ci }; 5438c2ecf20Sopenharmony_ci __be32 bufPtr; /* Buffer Pointer */ 5448c2ecf20Sopenharmony_ci}; 5458c2ecf20Sopenharmony_ci 5468c2ecf20Sopenharmony_cistruct rxfcb { 5478c2ecf20Sopenharmony_ci __be16 flags; 5488c2ecf20Sopenharmony_ci u8 rq; /* Receive Queue index */ 5498c2ecf20Sopenharmony_ci u8 pro; /* Layer 4 Protocol */ 5508c2ecf20Sopenharmony_ci u16 reserved; 5518c2ecf20Sopenharmony_ci __be16 vlctl; /* VLAN control word */ 5528c2ecf20Sopenharmony_ci}; 5538c2ecf20Sopenharmony_ci 5548c2ecf20Sopenharmony_cistruct gianfar_skb_cb { 5558c2ecf20Sopenharmony_ci unsigned int bytes_sent; /* bytes-on-wire (i.e. no FCB) */ 5568c2ecf20Sopenharmony_ci}; 5578c2ecf20Sopenharmony_ci 5588c2ecf20Sopenharmony_ci#define GFAR_CB(skb) ((struct gianfar_skb_cb *)((skb)->cb)) 5598c2ecf20Sopenharmony_ci 5608c2ecf20Sopenharmony_cistruct rmon_mib 5618c2ecf20Sopenharmony_ci{ 5628c2ecf20Sopenharmony_ci u32 tr64; /* 0x.680 - Transmit and Receive 64-byte Frame Counter */ 5638c2ecf20Sopenharmony_ci u32 tr127; /* 0x.684 - Transmit and Receive 65-127 byte Frame Counter */ 5648c2ecf20Sopenharmony_ci u32 tr255; /* 0x.688 - Transmit and Receive 128-255 byte Frame Counter */ 5658c2ecf20Sopenharmony_ci u32 tr511; /* 0x.68c - Transmit and Receive 256-511 byte Frame Counter */ 5668c2ecf20Sopenharmony_ci u32 tr1k; /* 0x.690 - Transmit and Receive 512-1023 byte Frame Counter */ 5678c2ecf20Sopenharmony_ci u32 trmax; /* 0x.694 - Transmit and Receive 1024-1518 byte Frame Counter */ 5688c2ecf20Sopenharmony_ci u32 trmgv; /* 0x.698 - Transmit and Receive 1519-1522 byte Good VLAN Frame */ 5698c2ecf20Sopenharmony_ci u32 rbyt; /* 0x.69c - Receive Byte Counter */ 5708c2ecf20Sopenharmony_ci u32 rpkt; /* 0x.6a0 - Receive Packet Counter */ 5718c2ecf20Sopenharmony_ci u32 rfcs; /* 0x.6a4 - Receive FCS Error Counter */ 5728c2ecf20Sopenharmony_ci u32 rmca; /* 0x.6a8 - Receive Multicast Packet Counter */ 5738c2ecf20Sopenharmony_ci u32 rbca; /* 0x.6ac - Receive Broadcast Packet Counter */ 5748c2ecf20Sopenharmony_ci u32 rxcf; /* 0x.6b0 - Receive Control Frame Packet Counter */ 5758c2ecf20Sopenharmony_ci u32 rxpf; /* 0x.6b4 - Receive Pause Frame Packet Counter */ 5768c2ecf20Sopenharmony_ci u32 rxuo; /* 0x.6b8 - Receive Unknown OP Code Counter */ 5778c2ecf20Sopenharmony_ci u32 raln; /* 0x.6bc - Receive Alignment Error Counter */ 5788c2ecf20Sopenharmony_ci u32 rflr; /* 0x.6c0 - Receive Frame Length Error Counter */ 5798c2ecf20Sopenharmony_ci u32 rcde; /* 0x.6c4 - Receive Code Error Counter */ 5808c2ecf20Sopenharmony_ci u32 rcse; /* 0x.6c8 - Receive Carrier Sense Error Counter */ 5818c2ecf20Sopenharmony_ci u32 rund; /* 0x.6cc - Receive Undersize Packet Counter */ 5828c2ecf20Sopenharmony_ci u32 rovr; /* 0x.6d0 - Receive Oversize Packet Counter */ 5838c2ecf20Sopenharmony_ci u32 rfrg; /* 0x.6d4 - Receive Fragments Counter */ 5848c2ecf20Sopenharmony_ci u32 rjbr; /* 0x.6d8 - Receive Jabber Counter */ 5858c2ecf20Sopenharmony_ci u32 rdrp; /* 0x.6dc - Receive Drop Counter */ 5868c2ecf20Sopenharmony_ci u32 tbyt; /* 0x.6e0 - Transmit Byte Counter Counter */ 5878c2ecf20Sopenharmony_ci u32 tpkt; /* 0x.6e4 - Transmit Packet Counter */ 5888c2ecf20Sopenharmony_ci u32 tmca; /* 0x.6e8 - Transmit Multicast Packet Counter */ 5898c2ecf20Sopenharmony_ci u32 tbca; /* 0x.6ec - Transmit Broadcast Packet Counter */ 5908c2ecf20Sopenharmony_ci u32 txpf; /* 0x.6f0 - Transmit Pause Control Frame Counter */ 5918c2ecf20Sopenharmony_ci u32 tdfr; /* 0x.6f4 - Transmit Deferral Packet Counter */ 5928c2ecf20Sopenharmony_ci u32 tedf; /* 0x.6f8 - Transmit Excessive Deferral Packet Counter */ 5938c2ecf20Sopenharmony_ci u32 tscl; /* 0x.6fc - Transmit Single Collision Packet Counter */ 5948c2ecf20Sopenharmony_ci u32 tmcl; /* 0x.700 - Transmit Multiple Collision Packet Counter */ 5958c2ecf20Sopenharmony_ci u32 tlcl; /* 0x.704 - Transmit Late Collision Packet Counter */ 5968c2ecf20Sopenharmony_ci u32 txcl; /* 0x.708 - Transmit Excessive Collision Packet Counter */ 5978c2ecf20Sopenharmony_ci u32 tncl; /* 0x.70c - Transmit Total Collision Counter */ 5988c2ecf20Sopenharmony_ci u8 res1[4]; 5998c2ecf20Sopenharmony_ci u32 tdrp; /* 0x.714 - Transmit Drop Frame Counter */ 6008c2ecf20Sopenharmony_ci u32 tjbr; /* 0x.718 - Transmit Jabber Frame Counter */ 6018c2ecf20Sopenharmony_ci u32 tfcs; /* 0x.71c - Transmit FCS Error Counter */ 6028c2ecf20Sopenharmony_ci u32 txcf; /* 0x.720 - Transmit Control Frame Counter */ 6038c2ecf20Sopenharmony_ci u32 tovr; /* 0x.724 - Transmit Oversize Frame Counter */ 6048c2ecf20Sopenharmony_ci u32 tund; /* 0x.728 - Transmit Undersize Frame Counter */ 6058c2ecf20Sopenharmony_ci u32 tfrg; /* 0x.72c - Transmit Fragments Frame Counter */ 6068c2ecf20Sopenharmony_ci u32 car1; /* 0x.730 - Carry Register One */ 6078c2ecf20Sopenharmony_ci u32 car2; /* 0x.734 - Carry Register Two */ 6088c2ecf20Sopenharmony_ci u32 cam1; /* 0x.738 - Carry Mask Register One */ 6098c2ecf20Sopenharmony_ci u32 cam2; /* 0x.73c - Carry Mask Register Two */ 6108c2ecf20Sopenharmony_ci}; 6118c2ecf20Sopenharmony_ci 6128c2ecf20Sopenharmony_cistruct gfar_extra_stats { 6138c2ecf20Sopenharmony_ci atomic64_t rx_alloc_err; 6148c2ecf20Sopenharmony_ci atomic64_t rx_large; 6158c2ecf20Sopenharmony_ci atomic64_t rx_short; 6168c2ecf20Sopenharmony_ci atomic64_t rx_nonoctet; 6178c2ecf20Sopenharmony_ci atomic64_t rx_crcerr; 6188c2ecf20Sopenharmony_ci atomic64_t rx_overrun; 6198c2ecf20Sopenharmony_ci atomic64_t rx_bsy; 6208c2ecf20Sopenharmony_ci atomic64_t rx_babr; 6218c2ecf20Sopenharmony_ci atomic64_t rx_trunc; 6228c2ecf20Sopenharmony_ci atomic64_t eberr; 6238c2ecf20Sopenharmony_ci atomic64_t tx_babt; 6248c2ecf20Sopenharmony_ci atomic64_t tx_underrun; 6258c2ecf20Sopenharmony_ci atomic64_t tx_timeout; 6268c2ecf20Sopenharmony_ci}; 6278c2ecf20Sopenharmony_ci 6288c2ecf20Sopenharmony_ci#define GFAR_RMON_LEN ((sizeof(struct rmon_mib) - 16)/sizeof(u32)) 6298c2ecf20Sopenharmony_ci#define GFAR_EXTRA_STATS_LEN \ 6308c2ecf20Sopenharmony_ci (sizeof(struct gfar_extra_stats)/sizeof(atomic64_t)) 6318c2ecf20Sopenharmony_ci 6328c2ecf20Sopenharmony_ci/* Number of stats exported via ethtool */ 6338c2ecf20Sopenharmony_ci#define GFAR_STATS_LEN (GFAR_RMON_LEN + GFAR_EXTRA_STATS_LEN) 6348c2ecf20Sopenharmony_ci 6358c2ecf20Sopenharmony_cistruct gfar { 6368c2ecf20Sopenharmony_ci u32 tsec_id; /* 0x.000 - Controller ID register */ 6378c2ecf20Sopenharmony_ci u32 tsec_id2; /* 0x.004 - Controller ID2 register */ 6388c2ecf20Sopenharmony_ci u8 res1[8]; 6398c2ecf20Sopenharmony_ci u32 ievent; /* 0x.010 - Interrupt Event Register */ 6408c2ecf20Sopenharmony_ci u32 imask; /* 0x.014 - Interrupt Mask Register */ 6418c2ecf20Sopenharmony_ci u32 edis; /* 0x.018 - Error Disabled Register */ 6428c2ecf20Sopenharmony_ci u32 emapg; /* 0x.01c - Group Error mapping register */ 6438c2ecf20Sopenharmony_ci u32 ecntrl; /* 0x.020 - Ethernet Control Register */ 6448c2ecf20Sopenharmony_ci u32 minflr; /* 0x.024 - Minimum Frame Length Register */ 6458c2ecf20Sopenharmony_ci u32 ptv; /* 0x.028 - Pause Time Value Register */ 6468c2ecf20Sopenharmony_ci u32 dmactrl; /* 0x.02c - DMA Control Register */ 6478c2ecf20Sopenharmony_ci u32 tbipa; /* 0x.030 - TBI PHY Address Register */ 6488c2ecf20Sopenharmony_ci u8 res2[28]; 6498c2ecf20Sopenharmony_ci u32 fifo_rx_pause; /* 0x.050 - FIFO receive pause start threshold 6508c2ecf20Sopenharmony_ci register */ 6518c2ecf20Sopenharmony_ci u32 fifo_rx_pause_shutoff; /* x.054 - FIFO receive starve shutoff 6528c2ecf20Sopenharmony_ci register */ 6538c2ecf20Sopenharmony_ci u32 fifo_rx_alarm; /* 0x.058 - FIFO receive alarm start threshold 6548c2ecf20Sopenharmony_ci register */ 6558c2ecf20Sopenharmony_ci u32 fifo_rx_alarm_shutoff; /*0x.05c - FIFO receive alarm starve 6568c2ecf20Sopenharmony_ci shutoff register */ 6578c2ecf20Sopenharmony_ci u8 res3[44]; 6588c2ecf20Sopenharmony_ci u32 fifo_tx_thr; /* 0x.08c - FIFO transmit threshold register */ 6598c2ecf20Sopenharmony_ci u8 res4[8]; 6608c2ecf20Sopenharmony_ci u32 fifo_tx_starve; /* 0x.098 - FIFO transmit starve register */ 6618c2ecf20Sopenharmony_ci u32 fifo_tx_starve_shutoff; /* 0x.09c - FIFO transmit starve shutoff register */ 6628c2ecf20Sopenharmony_ci u8 res5[96]; 6638c2ecf20Sopenharmony_ci u32 tctrl; /* 0x.100 - Transmit Control Register */ 6648c2ecf20Sopenharmony_ci u32 tstat; /* 0x.104 - Transmit Status Register */ 6658c2ecf20Sopenharmony_ci u32 dfvlan; /* 0x.108 - Default VLAN Control word */ 6668c2ecf20Sopenharmony_ci u32 tbdlen; /* 0x.10c - Transmit Buffer Descriptor Data Length Register */ 6678c2ecf20Sopenharmony_ci u32 txic; /* 0x.110 - Transmit Interrupt Coalescing Configuration Register */ 6688c2ecf20Sopenharmony_ci u32 tqueue; /* 0x.114 - Transmit queue control register */ 6698c2ecf20Sopenharmony_ci u8 res7[40]; 6708c2ecf20Sopenharmony_ci u32 tr03wt; /* 0x.140 - TxBD Rings 0-3 round-robin weightings */ 6718c2ecf20Sopenharmony_ci u32 tr47wt; /* 0x.144 - TxBD Rings 4-7 round-robin weightings */ 6728c2ecf20Sopenharmony_ci u8 res8[52]; 6738c2ecf20Sopenharmony_ci u32 tbdbph; /* 0x.17c - Tx data buffer pointer high */ 6748c2ecf20Sopenharmony_ci u8 res9a[4]; 6758c2ecf20Sopenharmony_ci u32 tbptr0; /* 0x.184 - TxBD Pointer for ring 0 */ 6768c2ecf20Sopenharmony_ci u8 res9b[4]; 6778c2ecf20Sopenharmony_ci u32 tbptr1; /* 0x.18c - TxBD Pointer for ring 1 */ 6788c2ecf20Sopenharmony_ci u8 res9c[4]; 6798c2ecf20Sopenharmony_ci u32 tbptr2; /* 0x.194 - TxBD Pointer for ring 2 */ 6808c2ecf20Sopenharmony_ci u8 res9d[4]; 6818c2ecf20Sopenharmony_ci u32 tbptr3; /* 0x.19c - TxBD Pointer for ring 3 */ 6828c2ecf20Sopenharmony_ci u8 res9e[4]; 6838c2ecf20Sopenharmony_ci u32 tbptr4; /* 0x.1a4 - TxBD Pointer for ring 4 */ 6848c2ecf20Sopenharmony_ci u8 res9f[4]; 6858c2ecf20Sopenharmony_ci u32 tbptr5; /* 0x.1ac - TxBD Pointer for ring 5 */ 6868c2ecf20Sopenharmony_ci u8 res9g[4]; 6878c2ecf20Sopenharmony_ci u32 tbptr6; /* 0x.1b4 - TxBD Pointer for ring 6 */ 6888c2ecf20Sopenharmony_ci u8 res9h[4]; 6898c2ecf20Sopenharmony_ci u32 tbptr7; /* 0x.1bc - TxBD Pointer for ring 7 */ 6908c2ecf20Sopenharmony_ci u8 res9[64]; 6918c2ecf20Sopenharmony_ci u32 tbaseh; /* 0x.200 - TxBD base address high */ 6928c2ecf20Sopenharmony_ci u32 tbase0; /* 0x.204 - TxBD Base Address of ring 0 */ 6938c2ecf20Sopenharmony_ci u8 res10a[4]; 6948c2ecf20Sopenharmony_ci u32 tbase1; /* 0x.20c - TxBD Base Address of ring 1 */ 6958c2ecf20Sopenharmony_ci u8 res10b[4]; 6968c2ecf20Sopenharmony_ci u32 tbase2; /* 0x.214 - TxBD Base Address of ring 2 */ 6978c2ecf20Sopenharmony_ci u8 res10c[4]; 6988c2ecf20Sopenharmony_ci u32 tbase3; /* 0x.21c - TxBD Base Address of ring 3 */ 6998c2ecf20Sopenharmony_ci u8 res10d[4]; 7008c2ecf20Sopenharmony_ci u32 tbase4; /* 0x.224 - TxBD Base Address of ring 4 */ 7018c2ecf20Sopenharmony_ci u8 res10e[4]; 7028c2ecf20Sopenharmony_ci u32 tbase5; /* 0x.22c - TxBD Base Address of ring 5 */ 7038c2ecf20Sopenharmony_ci u8 res10f[4]; 7048c2ecf20Sopenharmony_ci u32 tbase6; /* 0x.234 - TxBD Base Address of ring 6 */ 7058c2ecf20Sopenharmony_ci u8 res10g[4]; 7068c2ecf20Sopenharmony_ci u32 tbase7; /* 0x.23c - TxBD Base Address of ring 7 */ 7078c2ecf20Sopenharmony_ci u8 res10[192]; 7088c2ecf20Sopenharmony_ci u32 rctrl; /* 0x.300 - Receive Control Register */ 7098c2ecf20Sopenharmony_ci u32 rstat; /* 0x.304 - Receive Status Register */ 7108c2ecf20Sopenharmony_ci u8 res12[8]; 7118c2ecf20Sopenharmony_ci u32 rxic; /* 0x.310 - Receive Interrupt Coalescing Configuration Register */ 7128c2ecf20Sopenharmony_ci u32 rqueue; /* 0x.314 - Receive queue control register */ 7138c2ecf20Sopenharmony_ci u32 rir0; /* 0x.318 - Ring mapping register 0 */ 7148c2ecf20Sopenharmony_ci u32 rir1; /* 0x.31c - Ring mapping register 1 */ 7158c2ecf20Sopenharmony_ci u32 rir2; /* 0x.320 - Ring mapping register 2 */ 7168c2ecf20Sopenharmony_ci u32 rir3; /* 0x.324 - Ring mapping register 3 */ 7178c2ecf20Sopenharmony_ci u8 res13[8]; 7188c2ecf20Sopenharmony_ci u32 rbifx; /* 0x.330 - Receive bit field extract control register */ 7198c2ecf20Sopenharmony_ci u32 rqfar; /* 0x.334 - Receive queue filing table address register */ 7208c2ecf20Sopenharmony_ci u32 rqfcr; /* 0x.338 - Receive queue filing table control register */ 7218c2ecf20Sopenharmony_ci u32 rqfpr; /* 0x.33c - Receive queue filing table property register */ 7228c2ecf20Sopenharmony_ci u32 mrblr; /* 0x.340 - Maximum Receive Buffer Length Register */ 7238c2ecf20Sopenharmony_ci u8 res14[56]; 7248c2ecf20Sopenharmony_ci u32 rbdbph; /* 0x.37c - Rx data buffer pointer high */ 7258c2ecf20Sopenharmony_ci u8 res15a[4]; 7268c2ecf20Sopenharmony_ci u32 rbptr0; /* 0x.384 - RxBD pointer for ring 0 */ 7278c2ecf20Sopenharmony_ci u8 res15b[4]; 7288c2ecf20Sopenharmony_ci u32 rbptr1; /* 0x.38c - RxBD pointer for ring 1 */ 7298c2ecf20Sopenharmony_ci u8 res15c[4]; 7308c2ecf20Sopenharmony_ci u32 rbptr2; /* 0x.394 - RxBD pointer for ring 2 */ 7318c2ecf20Sopenharmony_ci u8 res15d[4]; 7328c2ecf20Sopenharmony_ci u32 rbptr3; /* 0x.39c - RxBD pointer for ring 3 */ 7338c2ecf20Sopenharmony_ci u8 res15e[4]; 7348c2ecf20Sopenharmony_ci u32 rbptr4; /* 0x.3a4 - RxBD pointer for ring 4 */ 7358c2ecf20Sopenharmony_ci u8 res15f[4]; 7368c2ecf20Sopenharmony_ci u32 rbptr5; /* 0x.3ac - RxBD pointer for ring 5 */ 7378c2ecf20Sopenharmony_ci u8 res15g[4]; 7388c2ecf20Sopenharmony_ci u32 rbptr6; /* 0x.3b4 - RxBD pointer for ring 6 */ 7398c2ecf20Sopenharmony_ci u8 res15h[4]; 7408c2ecf20Sopenharmony_ci u32 rbptr7; /* 0x.3bc - RxBD pointer for ring 7 */ 7418c2ecf20Sopenharmony_ci u8 res16[64]; 7428c2ecf20Sopenharmony_ci u32 rbaseh; /* 0x.400 - RxBD base address high */ 7438c2ecf20Sopenharmony_ci u32 rbase0; /* 0x.404 - RxBD base address of ring 0 */ 7448c2ecf20Sopenharmony_ci u8 res17a[4]; 7458c2ecf20Sopenharmony_ci u32 rbase1; /* 0x.40c - RxBD base address of ring 1 */ 7468c2ecf20Sopenharmony_ci u8 res17b[4]; 7478c2ecf20Sopenharmony_ci u32 rbase2; /* 0x.414 - RxBD base address of ring 2 */ 7488c2ecf20Sopenharmony_ci u8 res17c[4]; 7498c2ecf20Sopenharmony_ci u32 rbase3; /* 0x.41c - RxBD base address of ring 3 */ 7508c2ecf20Sopenharmony_ci u8 res17d[4]; 7518c2ecf20Sopenharmony_ci u32 rbase4; /* 0x.424 - RxBD base address of ring 4 */ 7528c2ecf20Sopenharmony_ci u8 res17e[4]; 7538c2ecf20Sopenharmony_ci u32 rbase5; /* 0x.42c - RxBD base address of ring 5 */ 7548c2ecf20Sopenharmony_ci u8 res17f[4]; 7558c2ecf20Sopenharmony_ci u32 rbase6; /* 0x.434 - RxBD base address of ring 6 */ 7568c2ecf20Sopenharmony_ci u8 res17g[4]; 7578c2ecf20Sopenharmony_ci u32 rbase7; /* 0x.43c - RxBD base address of ring 7 */ 7588c2ecf20Sopenharmony_ci u8 res17[192]; 7598c2ecf20Sopenharmony_ci u32 maccfg1; /* 0x.500 - MAC Configuration 1 Register */ 7608c2ecf20Sopenharmony_ci u32 maccfg2; /* 0x.504 - MAC Configuration 2 Register */ 7618c2ecf20Sopenharmony_ci u32 ipgifg; /* 0x.508 - Inter Packet Gap/Inter Frame Gap Register */ 7628c2ecf20Sopenharmony_ci u32 hafdup; /* 0x.50c - Half Duplex Register */ 7638c2ecf20Sopenharmony_ci u32 maxfrm; /* 0x.510 - Maximum Frame Length Register */ 7648c2ecf20Sopenharmony_ci u8 res18[12]; 7658c2ecf20Sopenharmony_ci u8 gfar_mii_regs[24]; /* See gianfar_phy.h */ 7668c2ecf20Sopenharmony_ci u32 ifctrl; /* 0x.538 - Interface control register */ 7678c2ecf20Sopenharmony_ci u32 ifstat; /* 0x.53c - Interface Status Register */ 7688c2ecf20Sopenharmony_ci u32 macstnaddr1; /* 0x.540 - Station Address Part 1 Register */ 7698c2ecf20Sopenharmony_ci u32 macstnaddr2; /* 0x.544 - Station Address Part 2 Register */ 7708c2ecf20Sopenharmony_ci u32 mac01addr1; /* 0x.548 - MAC exact match address 1, part 1 */ 7718c2ecf20Sopenharmony_ci u32 mac01addr2; /* 0x.54c - MAC exact match address 1, part 2 */ 7728c2ecf20Sopenharmony_ci u32 mac02addr1; /* 0x.550 - MAC exact match address 2, part 1 */ 7738c2ecf20Sopenharmony_ci u32 mac02addr2; /* 0x.554 - MAC exact match address 2, part 2 */ 7748c2ecf20Sopenharmony_ci u32 mac03addr1; /* 0x.558 - MAC exact match address 3, part 1 */ 7758c2ecf20Sopenharmony_ci u32 mac03addr2; /* 0x.55c - MAC exact match address 3, part 2 */ 7768c2ecf20Sopenharmony_ci u32 mac04addr1; /* 0x.560 - MAC exact match address 4, part 1 */ 7778c2ecf20Sopenharmony_ci u32 mac04addr2; /* 0x.564 - MAC exact match address 4, part 2 */ 7788c2ecf20Sopenharmony_ci u32 mac05addr1; /* 0x.568 - MAC exact match address 5, part 1 */ 7798c2ecf20Sopenharmony_ci u32 mac05addr2; /* 0x.56c - MAC exact match address 5, part 2 */ 7808c2ecf20Sopenharmony_ci u32 mac06addr1; /* 0x.570 - MAC exact match address 6, part 1 */ 7818c2ecf20Sopenharmony_ci u32 mac06addr2; /* 0x.574 - MAC exact match address 6, part 2 */ 7828c2ecf20Sopenharmony_ci u32 mac07addr1; /* 0x.578 - MAC exact match address 7, part 1 */ 7838c2ecf20Sopenharmony_ci u32 mac07addr2; /* 0x.57c - MAC exact match address 7, part 2 */ 7848c2ecf20Sopenharmony_ci u32 mac08addr1; /* 0x.580 - MAC exact match address 8, part 1 */ 7858c2ecf20Sopenharmony_ci u32 mac08addr2; /* 0x.584 - MAC exact match address 8, part 2 */ 7868c2ecf20Sopenharmony_ci u32 mac09addr1; /* 0x.588 - MAC exact match address 9, part 1 */ 7878c2ecf20Sopenharmony_ci u32 mac09addr2; /* 0x.58c - MAC exact match address 9, part 2 */ 7888c2ecf20Sopenharmony_ci u32 mac10addr1; /* 0x.590 - MAC exact match address 10, part 1*/ 7898c2ecf20Sopenharmony_ci u32 mac10addr2; /* 0x.594 - MAC exact match address 10, part 2*/ 7908c2ecf20Sopenharmony_ci u32 mac11addr1; /* 0x.598 - MAC exact match address 11, part 1*/ 7918c2ecf20Sopenharmony_ci u32 mac11addr2; /* 0x.59c - MAC exact match address 11, part 2*/ 7928c2ecf20Sopenharmony_ci u32 mac12addr1; /* 0x.5a0 - MAC exact match address 12, part 1*/ 7938c2ecf20Sopenharmony_ci u32 mac12addr2; /* 0x.5a4 - MAC exact match address 12, part 2*/ 7948c2ecf20Sopenharmony_ci u32 mac13addr1; /* 0x.5a8 - MAC exact match address 13, part 1*/ 7958c2ecf20Sopenharmony_ci u32 mac13addr2; /* 0x.5ac - MAC exact match address 13, part 2*/ 7968c2ecf20Sopenharmony_ci u32 mac14addr1; /* 0x.5b0 - MAC exact match address 14, part 1*/ 7978c2ecf20Sopenharmony_ci u32 mac14addr2; /* 0x.5b4 - MAC exact match address 14, part 2*/ 7988c2ecf20Sopenharmony_ci u32 mac15addr1; /* 0x.5b8 - MAC exact match address 15, part 1*/ 7998c2ecf20Sopenharmony_ci u32 mac15addr2; /* 0x.5bc - MAC exact match address 15, part 2*/ 8008c2ecf20Sopenharmony_ci u8 res20[192]; 8018c2ecf20Sopenharmony_ci struct rmon_mib rmon; /* 0x.680-0x.73c */ 8028c2ecf20Sopenharmony_ci u32 rrej; /* 0x.740 - Receive filer rejected packet counter */ 8038c2ecf20Sopenharmony_ci u8 res21[188]; 8048c2ecf20Sopenharmony_ci u32 igaddr0; /* 0x.800 - Indivdual/Group address register 0*/ 8058c2ecf20Sopenharmony_ci u32 igaddr1; /* 0x.804 - Indivdual/Group address register 1*/ 8068c2ecf20Sopenharmony_ci u32 igaddr2; /* 0x.808 - Indivdual/Group address register 2*/ 8078c2ecf20Sopenharmony_ci u32 igaddr3; /* 0x.80c - Indivdual/Group address register 3*/ 8088c2ecf20Sopenharmony_ci u32 igaddr4; /* 0x.810 - Indivdual/Group address register 4*/ 8098c2ecf20Sopenharmony_ci u32 igaddr5; /* 0x.814 - Indivdual/Group address register 5*/ 8108c2ecf20Sopenharmony_ci u32 igaddr6; /* 0x.818 - Indivdual/Group address register 6*/ 8118c2ecf20Sopenharmony_ci u32 igaddr7; /* 0x.81c - Indivdual/Group address register 7*/ 8128c2ecf20Sopenharmony_ci u8 res22[96]; 8138c2ecf20Sopenharmony_ci u32 gaddr0; /* 0x.880 - Group address register 0 */ 8148c2ecf20Sopenharmony_ci u32 gaddr1; /* 0x.884 - Group address register 1 */ 8158c2ecf20Sopenharmony_ci u32 gaddr2; /* 0x.888 - Group address register 2 */ 8168c2ecf20Sopenharmony_ci u32 gaddr3; /* 0x.88c - Group address register 3 */ 8178c2ecf20Sopenharmony_ci u32 gaddr4; /* 0x.890 - Group address register 4 */ 8188c2ecf20Sopenharmony_ci u32 gaddr5; /* 0x.894 - Group address register 5 */ 8198c2ecf20Sopenharmony_ci u32 gaddr6; /* 0x.898 - Group address register 6 */ 8208c2ecf20Sopenharmony_ci u32 gaddr7; /* 0x.89c - Group address register 7 */ 8218c2ecf20Sopenharmony_ci u8 res23a[352]; 8228c2ecf20Sopenharmony_ci u32 fifocfg; /* 0x.a00 - FIFO interface config register */ 8238c2ecf20Sopenharmony_ci u8 res23b[252]; 8248c2ecf20Sopenharmony_ci u8 res23c[248]; 8258c2ecf20Sopenharmony_ci u32 attr; /* 0x.bf8 - Attributes Register */ 8268c2ecf20Sopenharmony_ci u32 attreli; /* 0x.bfc - Attributes Extract Length and Extract Index Register */ 8278c2ecf20Sopenharmony_ci u32 rqprm0; /* 0x.c00 - Receive queue parameters register 0 */ 8288c2ecf20Sopenharmony_ci u32 rqprm1; /* 0x.c04 - Receive queue parameters register 1 */ 8298c2ecf20Sopenharmony_ci u32 rqprm2; /* 0x.c08 - Receive queue parameters register 2 */ 8308c2ecf20Sopenharmony_ci u32 rqprm3; /* 0x.c0c - Receive queue parameters register 3 */ 8318c2ecf20Sopenharmony_ci u32 rqprm4; /* 0x.c10 - Receive queue parameters register 4 */ 8328c2ecf20Sopenharmony_ci u32 rqprm5; /* 0x.c14 - Receive queue parameters register 5 */ 8338c2ecf20Sopenharmony_ci u32 rqprm6; /* 0x.c18 - Receive queue parameters register 6 */ 8348c2ecf20Sopenharmony_ci u32 rqprm7; /* 0x.c1c - Receive queue parameters register 7 */ 8358c2ecf20Sopenharmony_ci u8 res24[36]; 8368c2ecf20Sopenharmony_ci u32 rfbptr0; /* 0x.c44 - Last free RxBD pointer for ring 0 */ 8378c2ecf20Sopenharmony_ci u8 res24a[4]; 8388c2ecf20Sopenharmony_ci u32 rfbptr1; /* 0x.c4c - Last free RxBD pointer for ring 1 */ 8398c2ecf20Sopenharmony_ci u8 res24b[4]; 8408c2ecf20Sopenharmony_ci u32 rfbptr2; /* 0x.c54 - Last free RxBD pointer for ring 2 */ 8418c2ecf20Sopenharmony_ci u8 res24c[4]; 8428c2ecf20Sopenharmony_ci u32 rfbptr3; /* 0x.c5c - Last free RxBD pointer for ring 3 */ 8438c2ecf20Sopenharmony_ci u8 res24d[4]; 8448c2ecf20Sopenharmony_ci u32 rfbptr4; /* 0x.c64 - Last free RxBD pointer for ring 4 */ 8458c2ecf20Sopenharmony_ci u8 res24e[4]; 8468c2ecf20Sopenharmony_ci u32 rfbptr5; /* 0x.c6c - Last free RxBD pointer for ring 5 */ 8478c2ecf20Sopenharmony_ci u8 res24f[4]; 8488c2ecf20Sopenharmony_ci u32 rfbptr6; /* 0x.c74 - Last free RxBD pointer for ring 6 */ 8498c2ecf20Sopenharmony_ci u8 res24g[4]; 8508c2ecf20Sopenharmony_ci u32 rfbptr7; /* 0x.c7c - Last free RxBD pointer for ring 7 */ 8518c2ecf20Sopenharmony_ci u8 res24h[4]; 8528c2ecf20Sopenharmony_ci u8 res24x[556]; 8538c2ecf20Sopenharmony_ci u32 isrg0; /* 0x.eb0 - Interrupt steering group 0 register */ 8548c2ecf20Sopenharmony_ci u32 isrg1; /* 0x.eb4 - Interrupt steering group 1 register */ 8558c2ecf20Sopenharmony_ci u32 isrg2; /* 0x.eb8 - Interrupt steering group 2 register */ 8568c2ecf20Sopenharmony_ci u32 isrg3; /* 0x.ebc - Interrupt steering group 3 register */ 8578c2ecf20Sopenharmony_ci u8 res25[16]; 8588c2ecf20Sopenharmony_ci u32 rxic0; /* 0x.ed0 - Ring 0 Rx interrupt coalescing */ 8598c2ecf20Sopenharmony_ci u32 rxic1; /* 0x.ed4 - Ring 1 Rx interrupt coalescing */ 8608c2ecf20Sopenharmony_ci u32 rxic2; /* 0x.ed8 - Ring 2 Rx interrupt coalescing */ 8618c2ecf20Sopenharmony_ci u32 rxic3; /* 0x.edc - Ring 3 Rx interrupt coalescing */ 8628c2ecf20Sopenharmony_ci u32 rxic4; /* 0x.ee0 - Ring 4 Rx interrupt coalescing */ 8638c2ecf20Sopenharmony_ci u32 rxic5; /* 0x.ee4 - Ring 5 Rx interrupt coalescing */ 8648c2ecf20Sopenharmony_ci u32 rxic6; /* 0x.ee8 - Ring 6 Rx interrupt coalescing */ 8658c2ecf20Sopenharmony_ci u32 rxic7; /* 0x.eec - Ring 7 Rx interrupt coalescing */ 8668c2ecf20Sopenharmony_ci u8 res26[32]; 8678c2ecf20Sopenharmony_ci u32 txic0; /* 0x.f10 - Ring 0 Tx interrupt coalescing */ 8688c2ecf20Sopenharmony_ci u32 txic1; /* 0x.f14 - Ring 1 Tx interrupt coalescing */ 8698c2ecf20Sopenharmony_ci u32 txic2; /* 0x.f18 - Ring 2 Tx interrupt coalescing */ 8708c2ecf20Sopenharmony_ci u32 txic3; /* 0x.f1c - Ring 3 Tx interrupt coalescing */ 8718c2ecf20Sopenharmony_ci u32 txic4; /* 0x.f20 - Ring 4 Tx interrupt coalescing */ 8728c2ecf20Sopenharmony_ci u32 txic5; /* 0x.f24 - Ring 5 Tx interrupt coalescing */ 8738c2ecf20Sopenharmony_ci u32 txic6; /* 0x.f28 - Ring 6 Tx interrupt coalescing */ 8748c2ecf20Sopenharmony_ci u32 txic7; /* 0x.f2c - Ring 7 Tx interrupt coalescing */ 8758c2ecf20Sopenharmony_ci u8 res27[208]; 8768c2ecf20Sopenharmony_ci}; 8778c2ecf20Sopenharmony_ci 8788c2ecf20Sopenharmony_ci/* Flags related to gianfar device features */ 8798c2ecf20Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_GIGABIT 0x00000001 8808c2ecf20Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_COALESCE 0x00000002 8818c2ecf20Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_RMON 0x00000004 8828c2ecf20Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_MULTI_INTR 0x00000008 8838c2ecf20Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_CSUM 0x00000010 8848c2ecf20Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_VLAN 0x00000020 8858c2ecf20Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_EXTENDED_HASH 0x00000040 8868c2ecf20Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_MAGIC_PACKET 0x00000100 8878c2ecf20Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_BD_STASHING 0x00000200 8888c2ecf20Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_BUF_STASHING 0x00000400 8898c2ecf20Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_TIMER 0x00000800 8908c2ecf20Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_WAKE_ON_FILER 0x00001000 8918c2ecf20Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_RX_FILER 0x00002000 8928c2ecf20Sopenharmony_ci 8938c2ecf20Sopenharmony_ci#if (MAXGROUPS == 2) 8948c2ecf20Sopenharmony_ci#define DEFAULT_MAPPING 0xAA 8958c2ecf20Sopenharmony_ci#else 8968c2ecf20Sopenharmony_ci#define DEFAULT_MAPPING 0xFF 8978c2ecf20Sopenharmony_ci#endif 8988c2ecf20Sopenharmony_ci 8998c2ecf20Sopenharmony_ci#define ISRG_RR0 0x80000000 9008c2ecf20Sopenharmony_ci#define ISRG_TR0 0x00800000 9018c2ecf20Sopenharmony_ci 9028c2ecf20Sopenharmony_ci/* The same driver can operate in two modes */ 9038c2ecf20Sopenharmony_ci/* SQ_SG_MODE: Single Queue Single Group Mode 9048c2ecf20Sopenharmony_ci * (Backward compatible mode) 9058c2ecf20Sopenharmony_ci * MQ_MG_MODE: Multi Queue Multi Group mode 9068c2ecf20Sopenharmony_ci */ 9078c2ecf20Sopenharmony_cienum { 9088c2ecf20Sopenharmony_ci SQ_SG_MODE = 0, 9098c2ecf20Sopenharmony_ci MQ_MG_MODE 9108c2ecf20Sopenharmony_ci}; 9118c2ecf20Sopenharmony_ci 9128c2ecf20Sopenharmony_ci/* GFAR_SQ_POLLING: Single Queue NAPI polling mode 9138c2ecf20Sopenharmony_ci * The driver supports a single pair of RX/Tx queues 9148c2ecf20Sopenharmony_ci * per interrupt group (Rx/Tx int line). MQ_MG mode 9158c2ecf20Sopenharmony_ci * devices have 2 interrupt groups, so the device will 9168c2ecf20Sopenharmony_ci * have a total of 2 Tx and 2 Rx queues in this case. 9178c2ecf20Sopenharmony_ci * GFAR_MQ_POLLING: Multi Queue NAPI polling mode 9188c2ecf20Sopenharmony_ci * The driver supports all the 8 Rx and Tx HW queues 9198c2ecf20Sopenharmony_ci * each queue mapped by the Device Tree to one of 9208c2ecf20Sopenharmony_ci * the 2 interrupt groups. This mode implies significant 9218c2ecf20Sopenharmony_ci * processing overhead (CPU and controller level). 9228c2ecf20Sopenharmony_ci */ 9238c2ecf20Sopenharmony_cienum gfar_poll_mode { 9248c2ecf20Sopenharmony_ci GFAR_SQ_POLLING = 0, 9258c2ecf20Sopenharmony_ci GFAR_MQ_POLLING 9268c2ecf20Sopenharmony_ci}; 9278c2ecf20Sopenharmony_ci 9288c2ecf20Sopenharmony_ci/* 9298c2ecf20Sopenharmony_ci * Per TX queue stats 9308c2ecf20Sopenharmony_ci */ 9318c2ecf20Sopenharmony_cistruct tx_q_stats { 9328c2ecf20Sopenharmony_ci unsigned long tx_packets; 9338c2ecf20Sopenharmony_ci unsigned long tx_bytes; 9348c2ecf20Sopenharmony_ci}; 9358c2ecf20Sopenharmony_ci 9368c2ecf20Sopenharmony_ci/** 9378c2ecf20Sopenharmony_ci * struct gfar_priv_tx_q - per tx queue structure 9388c2ecf20Sopenharmony_ci * @txlock: per queue tx spin lock 9398c2ecf20Sopenharmony_ci * @tx_skbuff:skb pointers 9408c2ecf20Sopenharmony_ci * @skb_curtx: to be used skb pointer 9418c2ecf20Sopenharmony_ci * @skb_dirtytx:the last used skb pointer 9428c2ecf20Sopenharmony_ci * @stats: bytes/packets stats 9438c2ecf20Sopenharmony_ci * @qindex: index of this queue 9448c2ecf20Sopenharmony_ci * @dev: back pointer to the dev structure 9458c2ecf20Sopenharmony_ci * @grp: back pointer to the group to which this queue belongs 9468c2ecf20Sopenharmony_ci * @tx_bd_base: First tx buffer descriptor 9478c2ecf20Sopenharmony_ci * @cur_tx: Next free ring entry 9488c2ecf20Sopenharmony_ci * @dirty_tx: First buffer in line to be transmitted 9498c2ecf20Sopenharmony_ci * @tx_ring_size: Tx ring size 9508c2ecf20Sopenharmony_ci * @num_txbdfree: number of free TxBds 9518c2ecf20Sopenharmony_ci * @txcoalescing: enable/disable tx coalescing 9528c2ecf20Sopenharmony_ci * @txic: transmit interrupt coalescing value 9538c2ecf20Sopenharmony_ci * @txcount: coalescing value if based on tx frame count 9548c2ecf20Sopenharmony_ci * @txtime: coalescing value if based on time 9558c2ecf20Sopenharmony_ci */ 9568c2ecf20Sopenharmony_cistruct gfar_priv_tx_q { 9578c2ecf20Sopenharmony_ci /* cacheline 1 */ 9588c2ecf20Sopenharmony_ci spinlock_t txlock __attribute__ ((aligned (SMP_CACHE_BYTES))); 9598c2ecf20Sopenharmony_ci struct txbd8 *tx_bd_base; 9608c2ecf20Sopenharmony_ci struct txbd8 *cur_tx; 9618c2ecf20Sopenharmony_ci unsigned int num_txbdfree; 9628c2ecf20Sopenharmony_ci unsigned short skb_curtx; 9638c2ecf20Sopenharmony_ci unsigned short tx_ring_size; 9648c2ecf20Sopenharmony_ci struct tx_q_stats stats; 9658c2ecf20Sopenharmony_ci struct gfar_priv_grp *grp; 9668c2ecf20Sopenharmony_ci /* cacheline 2 */ 9678c2ecf20Sopenharmony_ci struct net_device *dev; 9688c2ecf20Sopenharmony_ci struct sk_buff **tx_skbuff; 9698c2ecf20Sopenharmony_ci struct txbd8 *dirty_tx; 9708c2ecf20Sopenharmony_ci unsigned short skb_dirtytx; 9718c2ecf20Sopenharmony_ci unsigned short qindex; 9728c2ecf20Sopenharmony_ci /* Configuration info for the coalescing features */ 9738c2ecf20Sopenharmony_ci unsigned int txcoalescing; 9748c2ecf20Sopenharmony_ci unsigned long txic; 9758c2ecf20Sopenharmony_ci dma_addr_t tx_bd_dma_base; 9768c2ecf20Sopenharmony_ci}; 9778c2ecf20Sopenharmony_ci 9788c2ecf20Sopenharmony_ci/* 9798c2ecf20Sopenharmony_ci * Per RX queue stats 9808c2ecf20Sopenharmony_ci */ 9818c2ecf20Sopenharmony_cistruct rx_q_stats { 9828c2ecf20Sopenharmony_ci unsigned long rx_packets; 9838c2ecf20Sopenharmony_ci unsigned long rx_bytes; 9848c2ecf20Sopenharmony_ci unsigned long rx_dropped; 9858c2ecf20Sopenharmony_ci}; 9868c2ecf20Sopenharmony_ci 9878c2ecf20Sopenharmony_cistruct gfar_rx_buff { 9888c2ecf20Sopenharmony_ci dma_addr_t dma; 9898c2ecf20Sopenharmony_ci struct page *page; 9908c2ecf20Sopenharmony_ci unsigned int page_offset; 9918c2ecf20Sopenharmony_ci}; 9928c2ecf20Sopenharmony_ci 9938c2ecf20Sopenharmony_ci/** 9948c2ecf20Sopenharmony_ci * struct gfar_priv_rx_q - per rx queue structure 9958c2ecf20Sopenharmony_ci * @rx_buff: Array of buffer info metadata structs 9968c2ecf20Sopenharmony_ci * @rx_bd_base: First rx buffer descriptor 9978c2ecf20Sopenharmony_ci * @next_to_use: index of the next buffer to be alloc'd 9988c2ecf20Sopenharmony_ci * @next_to_clean: index of the next buffer to be cleaned 9998c2ecf20Sopenharmony_ci * @qindex: index of this queue 10008c2ecf20Sopenharmony_ci * @ndev: back pointer to net_device 10018c2ecf20Sopenharmony_ci * @rx_ring_size: Rx ring size 10028c2ecf20Sopenharmony_ci * @rxcoalescing: enable/disable rx-coalescing 10038c2ecf20Sopenharmony_ci * @rxic: receive interrupt coalescing vlaue 10048c2ecf20Sopenharmony_ci */ 10058c2ecf20Sopenharmony_ci 10068c2ecf20Sopenharmony_cistruct gfar_priv_rx_q { 10078c2ecf20Sopenharmony_ci struct gfar_rx_buff *rx_buff __aligned(SMP_CACHE_BYTES); 10088c2ecf20Sopenharmony_ci struct rxbd8 *rx_bd_base; 10098c2ecf20Sopenharmony_ci struct net_device *ndev; 10108c2ecf20Sopenharmony_ci struct device *dev; 10118c2ecf20Sopenharmony_ci u16 rx_ring_size; 10128c2ecf20Sopenharmony_ci u16 qindex; 10138c2ecf20Sopenharmony_ci struct gfar_priv_grp *grp; 10148c2ecf20Sopenharmony_ci u16 next_to_clean; 10158c2ecf20Sopenharmony_ci u16 next_to_use; 10168c2ecf20Sopenharmony_ci u16 next_to_alloc; 10178c2ecf20Sopenharmony_ci struct sk_buff *skb; 10188c2ecf20Sopenharmony_ci struct rx_q_stats stats; 10198c2ecf20Sopenharmony_ci u32 __iomem *rfbptr; 10208c2ecf20Sopenharmony_ci unsigned char rxcoalescing; 10218c2ecf20Sopenharmony_ci unsigned long rxic; 10228c2ecf20Sopenharmony_ci dma_addr_t rx_bd_dma_base; 10238c2ecf20Sopenharmony_ci}; 10248c2ecf20Sopenharmony_ci 10258c2ecf20Sopenharmony_cienum gfar_irqinfo_id { 10268c2ecf20Sopenharmony_ci GFAR_TX = 0, 10278c2ecf20Sopenharmony_ci GFAR_RX = 1, 10288c2ecf20Sopenharmony_ci GFAR_ER = 2, 10298c2ecf20Sopenharmony_ci GFAR_NUM_IRQS = 3 10308c2ecf20Sopenharmony_ci}; 10318c2ecf20Sopenharmony_ci 10328c2ecf20Sopenharmony_cistruct gfar_irqinfo { 10338c2ecf20Sopenharmony_ci unsigned int irq; 10348c2ecf20Sopenharmony_ci char name[GFAR_INT_NAME_MAX]; 10358c2ecf20Sopenharmony_ci}; 10368c2ecf20Sopenharmony_ci 10378c2ecf20Sopenharmony_ci/** 10388c2ecf20Sopenharmony_ci * struct gfar_priv_grp - per group structure 10398c2ecf20Sopenharmony_ci * @napi: the napi poll function 10408c2ecf20Sopenharmony_ci * @priv: back pointer to the priv structure 10418c2ecf20Sopenharmony_ci * @regs: the ioremapped register space for this group 10428c2ecf20Sopenharmony_ci * @irqinfo: TX/RX/ER irq data for this group 10438c2ecf20Sopenharmony_ci */ 10448c2ecf20Sopenharmony_ci 10458c2ecf20Sopenharmony_cistruct gfar_priv_grp { 10468c2ecf20Sopenharmony_ci spinlock_t grplock __aligned(SMP_CACHE_BYTES); 10478c2ecf20Sopenharmony_ci struct napi_struct napi_rx; 10488c2ecf20Sopenharmony_ci struct napi_struct napi_tx; 10498c2ecf20Sopenharmony_ci struct gfar __iomem *regs; 10508c2ecf20Sopenharmony_ci struct gfar_priv_tx_q *tx_queue; 10518c2ecf20Sopenharmony_ci struct gfar_priv_rx_q *rx_queue; 10528c2ecf20Sopenharmony_ci unsigned int tstat; 10538c2ecf20Sopenharmony_ci unsigned int rstat; 10548c2ecf20Sopenharmony_ci 10558c2ecf20Sopenharmony_ci struct gfar_private *priv; 10568c2ecf20Sopenharmony_ci unsigned long num_tx_queues; 10578c2ecf20Sopenharmony_ci unsigned long tx_bit_map; 10588c2ecf20Sopenharmony_ci unsigned long num_rx_queues; 10598c2ecf20Sopenharmony_ci unsigned long rx_bit_map; 10608c2ecf20Sopenharmony_ci 10618c2ecf20Sopenharmony_ci struct gfar_irqinfo *irqinfo[GFAR_NUM_IRQS]; 10628c2ecf20Sopenharmony_ci}; 10638c2ecf20Sopenharmony_ci 10648c2ecf20Sopenharmony_ci#define gfar_irq(grp, ID) \ 10658c2ecf20Sopenharmony_ci ((grp)->irqinfo[GFAR_##ID]) 10668c2ecf20Sopenharmony_ci 10678c2ecf20Sopenharmony_cienum gfar_errata { 10688c2ecf20Sopenharmony_ci GFAR_ERRATA_74 = 0x01, 10698c2ecf20Sopenharmony_ci GFAR_ERRATA_76 = 0x02, 10708c2ecf20Sopenharmony_ci GFAR_ERRATA_A002 = 0x04, 10718c2ecf20Sopenharmony_ci GFAR_ERRATA_12 = 0x08, /* a.k.a errata eTSEC49 */ 10728c2ecf20Sopenharmony_ci}; 10738c2ecf20Sopenharmony_ci 10748c2ecf20Sopenharmony_cienum gfar_dev_state { 10758c2ecf20Sopenharmony_ci GFAR_DOWN = 1, 10768c2ecf20Sopenharmony_ci GFAR_RESETTING 10778c2ecf20Sopenharmony_ci}; 10788c2ecf20Sopenharmony_ci 10798c2ecf20Sopenharmony_ci/* Struct stolen almost completely (and shamelessly) from the FCC enet source 10808c2ecf20Sopenharmony_ci * (Ok, that's not so true anymore, but there is a family resemblance) 10818c2ecf20Sopenharmony_ci * The GFAR buffer descriptors track the ring buffers. The rx_bd_base 10828c2ecf20Sopenharmony_ci * and tx_bd_base always point to the currently available buffer. 10838c2ecf20Sopenharmony_ci * The dirty_tx tracks the current buffer that is being sent by the 10848c2ecf20Sopenharmony_ci * controller. The cur_tx and dirty_tx are equal under both completely 10858c2ecf20Sopenharmony_ci * empty and completely full conditions. The empty/ready indicator in 10868c2ecf20Sopenharmony_ci * the buffer descriptor determines the actual condition. 10878c2ecf20Sopenharmony_ci */ 10888c2ecf20Sopenharmony_cistruct gfar_private { 10898c2ecf20Sopenharmony_ci struct device *dev; 10908c2ecf20Sopenharmony_ci struct net_device *ndev; 10918c2ecf20Sopenharmony_ci enum gfar_errata errata; 10928c2ecf20Sopenharmony_ci 10938c2ecf20Sopenharmony_ci u16 uses_rxfcb; 10948c2ecf20Sopenharmony_ci u16 padding; 10958c2ecf20Sopenharmony_ci u32 device_flags; 10968c2ecf20Sopenharmony_ci 10978c2ecf20Sopenharmony_ci /* HW time stamping enabled flag */ 10988c2ecf20Sopenharmony_ci int hwts_rx_en; 10998c2ecf20Sopenharmony_ci int hwts_tx_en; 11008c2ecf20Sopenharmony_ci 11018c2ecf20Sopenharmony_ci struct gfar_priv_tx_q *tx_queue[MAX_TX_QS]; 11028c2ecf20Sopenharmony_ci struct gfar_priv_rx_q *rx_queue[MAX_RX_QS]; 11038c2ecf20Sopenharmony_ci struct gfar_priv_grp gfargrp[MAXGROUPS]; 11048c2ecf20Sopenharmony_ci 11058c2ecf20Sopenharmony_ci unsigned long state; 11068c2ecf20Sopenharmony_ci 11078c2ecf20Sopenharmony_ci unsigned short mode; 11088c2ecf20Sopenharmony_ci unsigned short poll_mode; 11098c2ecf20Sopenharmony_ci unsigned int num_tx_queues; 11108c2ecf20Sopenharmony_ci unsigned int num_rx_queues; 11118c2ecf20Sopenharmony_ci unsigned int num_grps; 11128c2ecf20Sopenharmony_ci int tx_actual_en; 11138c2ecf20Sopenharmony_ci 11148c2ecf20Sopenharmony_ci /* Network Statistics */ 11158c2ecf20Sopenharmony_ci struct gfar_extra_stats extra_stats; 11168c2ecf20Sopenharmony_ci 11178c2ecf20Sopenharmony_ci /* PHY stuff */ 11188c2ecf20Sopenharmony_ci phy_interface_t interface; 11198c2ecf20Sopenharmony_ci struct device_node *phy_node; 11208c2ecf20Sopenharmony_ci struct device_node *tbi_node; 11218c2ecf20Sopenharmony_ci struct mii_bus *mii_bus; 11228c2ecf20Sopenharmony_ci int oldspeed; 11238c2ecf20Sopenharmony_ci int oldduplex; 11248c2ecf20Sopenharmony_ci int oldlink; 11258c2ecf20Sopenharmony_ci 11268c2ecf20Sopenharmony_ci uint32_t msg_enable; 11278c2ecf20Sopenharmony_ci 11288c2ecf20Sopenharmony_ci struct work_struct reset_task; 11298c2ecf20Sopenharmony_ci 11308c2ecf20Sopenharmony_ci struct platform_device *ofdev; 11318c2ecf20Sopenharmony_ci unsigned char 11328c2ecf20Sopenharmony_ci extended_hash:1, 11338c2ecf20Sopenharmony_ci bd_stash_en:1, 11348c2ecf20Sopenharmony_ci rx_filer_enable:1, 11358c2ecf20Sopenharmony_ci /* Enable priorty based Tx scheduling in Hw */ 11368c2ecf20Sopenharmony_ci prio_sched_en:1, 11378c2ecf20Sopenharmony_ci /* Flow control flags */ 11388c2ecf20Sopenharmony_ci pause_aneg_en:1, 11398c2ecf20Sopenharmony_ci tx_pause_en:1, 11408c2ecf20Sopenharmony_ci rx_pause_en:1; 11418c2ecf20Sopenharmony_ci 11428c2ecf20Sopenharmony_ci /* The total tx and rx ring size for the enabled queues */ 11438c2ecf20Sopenharmony_ci unsigned int total_tx_ring_size; 11448c2ecf20Sopenharmony_ci unsigned int total_rx_ring_size; 11458c2ecf20Sopenharmony_ci 11468c2ecf20Sopenharmony_ci u32 rqueue; 11478c2ecf20Sopenharmony_ci u32 tqueue; 11488c2ecf20Sopenharmony_ci 11498c2ecf20Sopenharmony_ci /* RX per device parameters */ 11508c2ecf20Sopenharmony_ci unsigned int rx_stash_size; 11518c2ecf20Sopenharmony_ci unsigned int rx_stash_index; 11528c2ecf20Sopenharmony_ci 11538c2ecf20Sopenharmony_ci u32 cur_filer_idx; 11548c2ecf20Sopenharmony_ci 11558c2ecf20Sopenharmony_ci /* RX queue filer rule set*/ 11568c2ecf20Sopenharmony_ci struct ethtool_rx_list rx_list; 11578c2ecf20Sopenharmony_ci struct mutex rx_queue_access; 11588c2ecf20Sopenharmony_ci 11598c2ecf20Sopenharmony_ci /* Hash registers and their width */ 11608c2ecf20Sopenharmony_ci u32 __iomem *hash_regs[16]; 11618c2ecf20Sopenharmony_ci int hash_width; 11628c2ecf20Sopenharmony_ci 11638c2ecf20Sopenharmony_ci /* wake-on-lan settings */ 11648c2ecf20Sopenharmony_ci u16 wol_opts; 11658c2ecf20Sopenharmony_ci u16 wol_supported; 11668c2ecf20Sopenharmony_ci 11678c2ecf20Sopenharmony_ci /*Filer table*/ 11688c2ecf20Sopenharmony_ci unsigned int ftp_rqfpr[MAX_FILER_IDX + 1]; 11698c2ecf20Sopenharmony_ci unsigned int ftp_rqfcr[MAX_FILER_IDX + 1]; 11708c2ecf20Sopenharmony_ci}; 11718c2ecf20Sopenharmony_ci 11728c2ecf20Sopenharmony_ci 11738c2ecf20Sopenharmony_cistatic inline int gfar_has_errata(struct gfar_private *priv, 11748c2ecf20Sopenharmony_ci enum gfar_errata err) 11758c2ecf20Sopenharmony_ci{ 11768c2ecf20Sopenharmony_ci return priv->errata & err; 11778c2ecf20Sopenharmony_ci} 11788c2ecf20Sopenharmony_ci 11798c2ecf20Sopenharmony_cistatic inline u32 gfar_read(unsigned __iomem *addr) 11808c2ecf20Sopenharmony_ci{ 11818c2ecf20Sopenharmony_ci u32 val; 11828c2ecf20Sopenharmony_ci val = ioread32be(addr); 11838c2ecf20Sopenharmony_ci return val; 11848c2ecf20Sopenharmony_ci} 11858c2ecf20Sopenharmony_ci 11868c2ecf20Sopenharmony_cistatic inline void gfar_write(unsigned __iomem *addr, u32 val) 11878c2ecf20Sopenharmony_ci{ 11888c2ecf20Sopenharmony_ci iowrite32be(val, addr); 11898c2ecf20Sopenharmony_ci} 11908c2ecf20Sopenharmony_ci 11918c2ecf20Sopenharmony_cistatic inline void gfar_write_filer(struct gfar_private *priv, 11928c2ecf20Sopenharmony_ci unsigned int far, unsigned int fcr, unsigned int fpr) 11938c2ecf20Sopenharmony_ci{ 11948c2ecf20Sopenharmony_ci struct gfar __iomem *regs = priv->gfargrp[0].regs; 11958c2ecf20Sopenharmony_ci 11968c2ecf20Sopenharmony_ci gfar_write(®s->rqfar, far); 11978c2ecf20Sopenharmony_ci gfar_write(®s->rqfcr, fcr); 11988c2ecf20Sopenharmony_ci gfar_write(®s->rqfpr, fpr); 11998c2ecf20Sopenharmony_ci} 12008c2ecf20Sopenharmony_ci 12018c2ecf20Sopenharmony_cistatic inline void gfar_read_filer(struct gfar_private *priv, 12028c2ecf20Sopenharmony_ci unsigned int far, unsigned int *fcr, unsigned int *fpr) 12038c2ecf20Sopenharmony_ci{ 12048c2ecf20Sopenharmony_ci struct gfar __iomem *regs = priv->gfargrp[0].regs; 12058c2ecf20Sopenharmony_ci 12068c2ecf20Sopenharmony_ci gfar_write(®s->rqfar, far); 12078c2ecf20Sopenharmony_ci *fcr = gfar_read(®s->rqfcr); 12088c2ecf20Sopenharmony_ci *fpr = gfar_read(®s->rqfpr); 12098c2ecf20Sopenharmony_ci} 12108c2ecf20Sopenharmony_ci 12118c2ecf20Sopenharmony_cistatic inline void gfar_write_isrg(struct gfar_private *priv) 12128c2ecf20Sopenharmony_ci{ 12138c2ecf20Sopenharmony_ci struct gfar __iomem *regs = priv->gfargrp[0].regs; 12148c2ecf20Sopenharmony_ci u32 __iomem *baddr = ®s->isrg0; 12158c2ecf20Sopenharmony_ci u32 isrg = 0; 12168c2ecf20Sopenharmony_ci int grp_idx, i; 12178c2ecf20Sopenharmony_ci 12188c2ecf20Sopenharmony_ci for (grp_idx = 0; grp_idx < priv->num_grps; grp_idx++) { 12198c2ecf20Sopenharmony_ci struct gfar_priv_grp *grp = &priv->gfargrp[grp_idx]; 12208c2ecf20Sopenharmony_ci 12218c2ecf20Sopenharmony_ci for_each_set_bit(i, &grp->rx_bit_map, priv->num_rx_queues) { 12228c2ecf20Sopenharmony_ci isrg |= (ISRG_RR0 >> i); 12238c2ecf20Sopenharmony_ci } 12248c2ecf20Sopenharmony_ci 12258c2ecf20Sopenharmony_ci for_each_set_bit(i, &grp->tx_bit_map, priv->num_tx_queues) { 12268c2ecf20Sopenharmony_ci isrg |= (ISRG_TR0 >> i); 12278c2ecf20Sopenharmony_ci } 12288c2ecf20Sopenharmony_ci 12298c2ecf20Sopenharmony_ci gfar_write(baddr, isrg); 12308c2ecf20Sopenharmony_ci 12318c2ecf20Sopenharmony_ci baddr++; 12328c2ecf20Sopenharmony_ci isrg = 0; 12338c2ecf20Sopenharmony_ci } 12348c2ecf20Sopenharmony_ci} 12358c2ecf20Sopenharmony_ci 12368c2ecf20Sopenharmony_cistatic inline int gfar_is_dma_stopped(struct gfar_private *priv) 12378c2ecf20Sopenharmony_ci{ 12388c2ecf20Sopenharmony_ci struct gfar __iomem *regs = priv->gfargrp[0].regs; 12398c2ecf20Sopenharmony_ci 12408c2ecf20Sopenharmony_ci return ((gfar_read(®s->ievent) & (IEVENT_GRSC | IEVENT_GTSC)) == 12418c2ecf20Sopenharmony_ci (IEVENT_GRSC | IEVENT_GTSC)); 12428c2ecf20Sopenharmony_ci} 12438c2ecf20Sopenharmony_ci 12448c2ecf20Sopenharmony_cistatic inline int gfar_is_rx_dma_stopped(struct gfar_private *priv) 12458c2ecf20Sopenharmony_ci{ 12468c2ecf20Sopenharmony_ci struct gfar __iomem *regs = priv->gfargrp[0].regs; 12478c2ecf20Sopenharmony_ci 12488c2ecf20Sopenharmony_ci return gfar_read(®s->ievent) & IEVENT_GRSC; 12498c2ecf20Sopenharmony_ci} 12508c2ecf20Sopenharmony_ci 12518c2ecf20Sopenharmony_cistatic inline void gfar_wmb(void) 12528c2ecf20Sopenharmony_ci{ 12538c2ecf20Sopenharmony_ci#if defined(CONFIG_PPC) 12548c2ecf20Sopenharmony_ci /* The powerpc-specific eieio() is used, as wmb() has too strong 12558c2ecf20Sopenharmony_ci * semantics (it requires synchronization between cacheable and 12568c2ecf20Sopenharmony_ci * uncacheable mappings, which eieio() doesn't provide and which we 12578c2ecf20Sopenharmony_ci * don't need), thus requiring a more expensive sync instruction. At 12588c2ecf20Sopenharmony_ci * some point, the set of architecture-independent barrier functions 12598c2ecf20Sopenharmony_ci * should be expanded to include weaker barriers. 12608c2ecf20Sopenharmony_ci */ 12618c2ecf20Sopenharmony_ci eieio(); 12628c2ecf20Sopenharmony_ci#else 12638c2ecf20Sopenharmony_ci wmb(); /* order write acesses for BD (or FCB) fields */ 12648c2ecf20Sopenharmony_ci#endif 12658c2ecf20Sopenharmony_ci} 12668c2ecf20Sopenharmony_ci 12678c2ecf20Sopenharmony_cistatic inline void gfar_clear_txbd_status(struct txbd8 *bdp) 12688c2ecf20Sopenharmony_ci{ 12698c2ecf20Sopenharmony_ci u32 lstatus = be32_to_cpu(bdp->lstatus); 12708c2ecf20Sopenharmony_ci 12718c2ecf20Sopenharmony_ci lstatus &= BD_LFLAG(TXBD_WRAP); 12728c2ecf20Sopenharmony_ci bdp->lstatus = cpu_to_be32(lstatus); 12738c2ecf20Sopenharmony_ci} 12748c2ecf20Sopenharmony_ci 12758c2ecf20Sopenharmony_cistatic inline int gfar_rxbd_unused(struct gfar_priv_rx_q *rxq) 12768c2ecf20Sopenharmony_ci{ 12778c2ecf20Sopenharmony_ci if (rxq->next_to_clean > rxq->next_to_use) 12788c2ecf20Sopenharmony_ci return rxq->next_to_clean - rxq->next_to_use - 1; 12798c2ecf20Sopenharmony_ci 12808c2ecf20Sopenharmony_ci return rxq->rx_ring_size + rxq->next_to_clean - rxq->next_to_use - 1; 12818c2ecf20Sopenharmony_ci} 12828c2ecf20Sopenharmony_ci 12838c2ecf20Sopenharmony_cistatic inline u32 gfar_rxbd_dma_lastfree(struct gfar_priv_rx_q *rxq) 12848c2ecf20Sopenharmony_ci{ 12858c2ecf20Sopenharmony_ci struct rxbd8 *bdp; 12868c2ecf20Sopenharmony_ci u32 bdp_dma; 12878c2ecf20Sopenharmony_ci int i; 12888c2ecf20Sopenharmony_ci 12898c2ecf20Sopenharmony_ci i = rxq->next_to_use ? rxq->next_to_use - 1 : rxq->rx_ring_size - 1; 12908c2ecf20Sopenharmony_ci bdp = &rxq->rx_bd_base[i]; 12918c2ecf20Sopenharmony_ci bdp_dma = lower_32_bits(rxq->rx_bd_dma_base); 12928c2ecf20Sopenharmony_ci bdp_dma += (uintptr_t)bdp - (uintptr_t)rxq->rx_bd_base; 12938c2ecf20Sopenharmony_ci 12948c2ecf20Sopenharmony_ci return bdp_dma; 12958c2ecf20Sopenharmony_ci} 12968c2ecf20Sopenharmony_ci 12978c2ecf20Sopenharmony_ciint startup_gfar(struct net_device *dev); 12988c2ecf20Sopenharmony_civoid stop_gfar(struct net_device *dev); 12998c2ecf20Sopenharmony_civoid gfar_mac_reset(struct gfar_private *priv); 13008c2ecf20Sopenharmony_ciint gfar_set_features(struct net_device *dev, netdev_features_t features); 13018c2ecf20Sopenharmony_ci 13028c2ecf20Sopenharmony_ciextern const struct ethtool_ops gfar_ethtool_ops; 13038c2ecf20Sopenharmony_ci 13048c2ecf20Sopenharmony_ci#define MAX_FILER_CACHE_IDX (2*(MAX_FILER_IDX)) 13058c2ecf20Sopenharmony_ci 13068c2ecf20Sopenharmony_ci#define RQFCR_PID_PRI_MASK 0xFFFFFFF8 13078c2ecf20Sopenharmony_ci#define RQFCR_PID_L4P_MASK 0xFFFFFF00 13088c2ecf20Sopenharmony_ci#define RQFCR_PID_VID_MASK 0xFFFFF000 13098c2ecf20Sopenharmony_ci#define RQFCR_PID_PORT_MASK 0xFFFF0000 13108c2ecf20Sopenharmony_ci#define RQFCR_PID_MAC_MASK 0xFF000000 13118c2ecf20Sopenharmony_ci 13128c2ecf20Sopenharmony_ci/* Represents a receive filer table entry */ 13138c2ecf20Sopenharmony_cistruct gfar_filer_entry { 13148c2ecf20Sopenharmony_ci u32 ctrl; 13158c2ecf20Sopenharmony_ci u32 prop; 13168c2ecf20Sopenharmony_ci}; 13178c2ecf20Sopenharmony_ci 13188c2ecf20Sopenharmony_ci 13198c2ecf20Sopenharmony_ci/* The 20 additional entries are a shadow for one extra element */ 13208c2ecf20Sopenharmony_cistruct filer_table { 13218c2ecf20Sopenharmony_ci u32 index; 13228c2ecf20Sopenharmony_ci struct gfar_filer_entry fe[MAX_FILER_CACHE_IDX + 20]; 13238c2ecf20Sopenharmony_ci}; 13248c2ecf20Sopenharmony_ci 13258c2ecf20Sopenharmony_ci#endif /* __GIANFAR_H */ 1326