162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * drivers/net/ethernet/freescale/gianfar.h 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Gianfar Ethernet Driver 662306a36Sopenharmony_ci * Driver for FEC on MPC8540 and TSEC on MPC8540/MPC8560 762306a36Sopenharmony_ci * Based on 8260_io/fcc_enet.c 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * Author: Andy Fleming 1062306a36Sopenharmony_ci * Maintainer: Kumar Gala 1162306a36Sopenharmony_ci * Modifier: Sandeep Gopalpet <sandeep.kumar@freescale.com> 1262306a36Sopenharmony_ci * 1362306a36Sopenharmony_ci * Copyright 2002-2009, 2011-2013 Freescale Semiconductor, Inc. 1462306a36Sopenharmony_ci * 1562306a36Sopenharmony_ci * Still left to do: 1662306a36Sopenharmony_ci * -Add support for module parameters 1762306a36Sopenharmony_ci * -Add patch for ethtool phys id 1862306a36Sopenharmony_ci */ 1962306a36Sopenharmony_ci#ifndef __GIANFAR_H 2062306a36Sopenharmony_ci#define __GIANFAR_H 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci#include <linux/kernel.h> 2362306a36Sopenharmony_ci#include <linux/sched.h> 2462306a36Sopenharmony_ci#include <linux/string.h> 2562306a36Sopenharmony_ci#include <linux/errno.h> 2662306a36Sopenharmony_ci#include <linux/slab.h> 2762306a36Sopenharmony_ci#include <linux/interrupt.h> 2862306a36Sopenharmony_ci#include <linux/delay.h> 2962306a36Sopenharmony_ci#include <linux/netdevice.h> 3062306a36Sopenharmony_ci#include <linux/etherdevice.h> 3162306a36Sopenharmony_ci#include <linux/skbuff.h> 3262306a36Sopenharmony_ci#include <linux/spinlock.h> 3362306a36Sopenharmony_ci#include <linux/mm.h> 3462306a36Sopenharmony_ci#include <linux/mii.h> 3562306a36Sopenharmony_ci#include <linux/phy.h> 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci#include <asm/io.h> 3862306a36Sopenharmony_ci#include <asm/irq.h> 3962306a36Sopenharmony_ci#include <linux/uaccess.h> 4062306a36Sopenharmony_ci#include <linux/module.h> 4162306a36Sopenharmony_ci#include <linux/crc32.h> 4262306a36Sopenharmony_ci#include <linux/workqueue.h> 4362306a36Sopenharmony_ci#include <linux/ethtool.h> 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_cistruct ethtool_flow_spec_container { 4662306a36Sopenharmony_ci struct ethtool_rx_flow_spec fs; 4762306a36Sopenharmony_ci struct list_head list; 4862306a36Sopenharmony_ci}; 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_cistruct ethtool_rx_list { 5162306a36Sopenharmony_ci struct list_head list; 5262306a36Sopenharmony_ci unsigned int count; 5362306a36Sopenharmony_ci}; 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci/* Length for FCB */ 5662306a36Sopenharmony_ci#define GMAC_FCB_LEN 8 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci/* Length for TxPAL */ 5962306a36Sopenharmony_ci#define GMAC_TXPAL_LEN 16 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci/* Default padding amount */ 6262306a36Sopenharmony_ci#define DEFAULT_PADDING 2 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci/* Number of bytes to align the rx bufs to */ 6562306a36Sopenharmony_ci#define RXBUF_ALIGNMENT 64 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci#define DRV_NAME "gfar-enet" 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci/* MAXIMUM NUMBER OF QUEUES SUPPORTED */ 7062306a36Sopenharmony_ci#define MAX_TX_QS 0x8 7162306a36Sopenharmony_ci#define MAX_RX_QS 0x8 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci/* MAXIMUM NUMBER OF GROUPS SUPPORTED */ 7462306a36Sopenharmony_ci#define MAXGROUPS 0x2 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci/* These need to be powers of 2 for this driver */ 7762306a36Sopenharmony_ci#define DEFAULT_TX_RING_SIZE 256 7862306a36Sopenharmony_ci#define DEFAULT_RX_RING_SIZE 256 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci#define GFAR_RX_BUFF_ALLOC 16 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci#define GFAR_RX_MAX_RING_SIZE 256 8362306a36Sopenharmony_ci#define GFAR_TX_MAX_RING_SIZE 256 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci#define FBTHR_SHIFT 24 8662306a36Sopenharmony_ci#define DEFAULT_RX_LFC_THR 16 8762306a36Sopenharmony_ci#define DEFAULT_LFC_PTVVAL 4 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci#define GFAR_RXB_TRUESIZE 2048 9062306a36Sopenharmony_ci#define GFAR_SKBFRAG_OVR (RXBUF_ALIGNMENT \ 9162306a36Sopenharmony_ci + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) 9262306a36Sopenharmony_ci#define GFAR_RXB_SIZE rounddown(GFAR_RXB_TRUESIZE - GFAR_SKBFRAG_OVR, 64) 9362306a36Sopenharmony_ci#define GFAR_SKBFRAG_SIZE (GFAR_RXB_SIZE + GFAR_SKBFRAG_OVR) 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci#define TX_RING_MOD_MASK(size) (size-1) 9662306a36Sopenharmony_ci#define RX_RING_MOD_MASK(size) (size-1) 9762306a36Sopenharmony_ci#define GFAR_JUMBO_FRAME_SIZE 9600 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci#define DEFAULT_FIFO_TX_THR 0x100 10062306a36Sopenharmony_ci#define DEFAULT_FIFO_TX_STARVE 0x40 10162306a36Sopenharmony_ci#define DEFAULT_FIFO_TX_STARVE_OFF 0x80 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci/* The number of Exact Match registers */ 10462306a36Sopenharmony_ci#define GFAR_EM_NUM 15 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci/* Latency of interface clock in nanoseconds */ 10762306a36Sopenharmony_ci/* Interface clock latency , in this case, means the 10862306a36Sopenharmony_ci * time described by a value of 1 in the interrupt 10962306a36Sopenharmony_ci * coalescing registers' time fields. Since those fields 11062306a36Sopenharmony_ci * refer to the time it takes for 64 clocks to pass, the 11162306a36Sopenharmony_ci * latencies are as such: 11262306a36Sopenharmony_ci * GBIT = 125MHz => 8ns/clock => 8*64 ns / tick 11362306a36Sopenharmony_ci * 100 = 25 MHz => 40ns/clock => 40*64 ns / tick 11462306a36Sopenharmony_ci * 10 = 2.5 MHz => 400ns/clock => 400*64 ns / tick 11562306a36Sopenharmony_ci */ 11662306a36Sopenharmony_ci#define GFAR_GBIT_TIME 512 11762306a36Sopenharmony_ci#define GFAR_100_TIME 2560 11862306a36Sopenharmony_ci#define GFAR_10_TIME 25600 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci#define DEFAULT_TX_COALESCE 1 12162306a36Sopenharmony_ci#define DEFAULT_TXCOUNT 16 12262306a36Sopenharmony_ci#define DEFAULT_TXTIME 21 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci#define DEFAULT_RXTIME 21 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci#define DEFAULT_RX_COALESCE 0 12762306a36Sopenharmony_ci#define DEFAULT_RXCOUNT 0 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci/* TBI register addresses */ 13062306a36Sopenharmony_ci#define MII_TBICON 0x11 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci/* TBICON register bit fields */ 13362306a36Sopenharmony_ci#define TBICON_CLK_SELECT 0x0020 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ci/* MAC register bits */ 13662306a36Sopenharmony_ci#define MACCFG1_SOFT_RESET 0x80000000 13762306a36Sopenharmony_ci#define MACCFG1_RESET_RX_MC 0x00080000 13862306a36Sopenharmony_ci#define MACCFG1_RESET_TX_MC 0x00040000 13962306a36Sopenharmony_ci#define MACCFG1_RESET_RX_FUN 0x00020000 14062306a36Sopenharmony_ci#define MACCFG1_RESET_TX_FUN 0x00010000 14162306a36Sopenharmony_ci#define MACCFG1_LOOPBACK 0x00000100 14262306a36Sopenharmony_ci#define MACCFG1_RX_FLOW 0x00000020 14362306a36Sopenharmony_ci#define MACCFG1_TX_FLOW 0x00000010 14462306a36Sopenharmony_ci#define MACCFG1_SYNCD_RX_EN 0x00000008 14562306a36Sopenharmony_ci#define MACCFG1_RX_EN 0x00000004 14662306a36Sopenharmony_ci#define MACCFG1_SYNCD_TX_EN 0x00000002 14762306a36Sopenharmony_ci#define MACCFG1_TX_EN 0x00000001 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_ci#define MACCFG2_INIT_SETTINGS 0x00007205 15062306a36Sopenharmony_ci#define MACCFG2_FULL_DUPLEX 0x00000001 15162306a36Sopenharmony_ci#define MACCFG2_IF 0x00000300 15262306a36Sopenharmony_ci#define MACCFG2_MII 0x00000100 15362306a36Sopenharmony_ci#define MACCFG2_GMII 0x00000200 15462306a36Sopenharmony_ci#define MACCFG2_HUGEFRAME 0x00000020 15562306a36Sopenharmony_ci#define MACCFG2_LENGTHCHECK 0x00000010 15662306a36Sopenharmony_ci#define MACCFG2_MPEN 0x00000008 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_ci#define ECNTRL_FIFM 0x00008000 15962306a36Sopenharmony_ci#define ECNTRL_INIT_SETTINGS 0x00001000 16062306a36Sopenharmony_ci#define ECNTRL_TBI_MODE 0x00000020 16162306a36Sopenharmony_ci#define ECNTRL_REDUCED_MODE 0x00000010 16262306a36Sopenharmony_ci#define ECNTRL_R100 0x00000008 16362306a36Sopenharmony_ci#define ECNTRL_REDUCED_MII_MODE 0x00000004 16462306a36Sopenharmony_ci#define ECNTRL_SGMII_MODE 0x00000002 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_ci#define MINFLR_INIT_SETTINGS 0x00000040 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci/* Tqueue control */ 16962306a36Sopenharmony_ci#define TQUEUE_EN0 0x00008000 17062306a36Sopenharmony_ci#define TQUEUE_EN1 0x00004000 17162306a36Sopenharmony_ci#define TQUEUE_EN2 0x00002000 17262306a36Sopenharmony_ci#define TQUEUE_EN3 0x00001000 17362306a36Sopenharmony_ci#define TQUEUE_EN4 0x00000800 17462306a36Sopenharmony_ci#define TQUEUE_EN5 0x00000400 17562306a36Sopenharmony_ci#define TQUEUE_EN6 0x00000200 17662306a36Sopenharmony_ci#define TQUEUE_EN7 0x00000100 17762306a36Sopenharmony_ci#define TQUEUE_EN_ALL 0x0000FF00 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci#define TR03WT_WT0_MASK 0xFF000000 18062306a36Sopenharmony_ci#define TR03WT_WT1_MASK 0x00FF0000 18162306a36Sopenharmony_ci#define TR03WT_WT2_MASK 0x0000FF00 18262306a36Sopenharmony_ci#define TR03WT_WT3_MASK 0x000000FF 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci#define TR47WT_WT4_MASK 0xFF000000 18562306a36Sopenharmony_ci#define TR47WT_WT5_MASK 0x00FF0000 18662306a36Sopenharmony_ci#define TR47WT_WT6_MASK 0x0000FF00 18762306a36Sopenharmony_ci#define TR47WT_WT7_MASK 0x000000FF 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_ci/* Rqueue control */ 19062306a36Sopenharmony_ci#define RQUEUE_EX0 0x00800000 19162306a36Sopenharmony_ci#define RQUEUE_EX1 0x00400000 19262306a36Sopenharmony_ci#define RQUEUE_EX2 0x00200000 19362306a36Sopenharmony_ci#define RQUEUE_EX3 0x00100000 19462306a36Sopenharmony_ci#define RQUEUE_EX4 0x00080000 19562306a36Sopenharmony_ci#define RQUEUE_EX5 0x00040000 19662306a36Sopenharmony_ci#define RQUEUE_EX6 0x00020000 19762306a36Sopenharmony_ci#define RQUEUE_EX7 0x00010000 19862306a36Sopenharmony_ci#define RQUEUE_EX_ALL 0x00FF0000 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_ci#define RQUEUE_EN0 0x00000080 20162306a36Sopenharmony_ci#define RQUEUE_EN1 0x00000040 20262306a36Sopenharmony_ci#define RQUEUE_EN2 0x00000020 20362306a36Sopenharmony_ci#define RQUEUE_EN3 0x00000010 20462306a36Sopenharmony_ci#define RQUEUE_EN4 0x00000008 20562306a36Sopenharmony_ci#define RQUEUE_EN5 0x00000004 20662306a36Sopenharmony_ci#define RQUEUE_EN6 0x00000002 20762306a36Sopenharmony_ci#define RQUEUE_EN7 0x00000001 20862306a36Sopenharmony_ci#define RQUEUE_EN_ALL 0x000000FF 20962306a36Sopenharmony_ci 21062306a36Sopenharmony_ci/* Init to do tx snooping for buffers and descriptors */ 21162306a36Sopenharmony_ci#define DMACTRL_INIT_SETTINGS 0x000000c3 21262306a36Sopenharmony_ci#define DMACTRL_GRS 0x00000010 21362306a36Sopenharmony_ci#define DMACTRL_GTS 0x00000008 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_ci#define TSTAT_CLEAR_THALT_ALL 0xFF000000 21662306a36Sopenharmony_ci#define TSTAT_CLEAR_THALT 0x80000000 21762306a36Sopenharmony_ci#define TSTAT_CLEAR_THALT0 0x80000000 21862306a36Sopenharmony_ci#define TSTAT_CLEAR_THALT1 0x40000000 21962306a36Sopenharmony_ci#define TSTAT_CLEAR_THALT2 0x20000000 22062306a36Sopenharmony_ci#define TSTAT_CLEAR_THALT3 0x10000000 22162306a36Sopenharmony_ci#define TSTAT_CLEAR_THALT4 0x08000000 22262306a36Sopenharmony_ci#define TSTAT_CLEAR_THALT5 0x04000000 22362306a36Sopenharmony_ci#define TSTAT_CLEAR_THALT6 0x02000000 22462306a36Sopenharmony_ci#define TSTAT_CLEAR_THALT7 0x01000000 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_ci/* Interrupt coalescing macros */ 22762306a36Sopenharmony_ci#define IC_ICEN 0x80000000 22862306a36Sopenharmony_ci#define IC_ICFT_MASK 0x1fe00000 22962306a36Sopenharmony_ci#define IC_ICFT_SHIFT 21 23062306a36Sopenharmony_ci#define mk_ic_icft(x) \ 23162306a36Sopenharmony_ci (((unsigned int)x << IC_ICFT_SHIFT)&IC_ICFT_MASK) 23262306a36Sopenharmony_ci#define IC_ICTT_MASK 0x0000ffff 23362306a36Sopenharmony_ci#define mk_ic_ictt(x) (x&IC_ICTT_MASK) 23462306a36Sopenharmony_ci 23562306a36Sopenharmony_ci#define mk_ic_value(count, time) (IC_ICEN | \ 23662306a36Sopenharmony_ci mk_ic_icft(count) | \ 23762306a36Sopenharmony_ci mk_ic_ictt(time)) 23862306a36Sopenharmony_ci#define get_icft_value(ic) (((unsigned long)ic & IC_ICFT_MASK) >> \ 23962306a36Sopenharmony_ci IC_ICFT_SHIFT) 24062306a36Sopenharmony_ci#define get_ictt_value(ic) ((unsigned long)ic & IC_ICTT_MASK) 24162306a36Sopenharmony_ci 24262306a36Sopenharmony_ci#define DEFAULT_TXIC mk_ic_value(DEFAULT_TXCOUNT, DEFAULT_TXTIME) 24362306a36Sopenharmony_ci#define DEFAULT_RXIC mk_ic_value(DEFAULT_RXCOUNT, DEFAULT_RXTIME) 24462306a36Sopenharmony_ci 24562306a36Sopenharmony_ci#define RCTRL_TS_ENABLE 0x01000000 24662306a36Sopenharmony_ci#define RCTRL_PAL_MASK 0x001f0000 24762306a36Sopenharmony_ci#define RCTRL_LFC 0x00004000 24862306a36Sopenharmony_ci#define RCTRL_VLEX 0x00002000 24962306a36Sopenharmony_ci#define RCTRL_FILREN 0x00001000 25062306a36Sopenharmony_ci#define RCTRL_GHTX 0x00000400 25162306a36Sopenharmony_ci#define RCTRL_IPCSEN 0x00000200 25262306a36Sopenharmony_ci#define RCTRL_TUCSEN 0x00000100 25362306a36Sopenharmony_ci#define RCTRL_PRSDEP_MASK 0x000000c0 25462306a36Sopenharmony_ci#define RCTRL_PRSDEP_INIT 0x000000c0 25562306a36Sopenharmony_ci#define RCTRL_PRSFM 0x00000020 25662306a36Sopenharmony_ci#define RCTRL_PROM 0x00000008 25762306a36Sopenharmony_ci#define RCTRL_EMEN 0x00000002 25862306a36Sopenharmony_ci#define RCTRL_REQ_PARSER (RCTRL_VLEX | RCTRL_IPCSEN | \ 25962306a36Sopenharmony_ci RCTRL_TUCSEN | RCTRL_FILREN) 26062306a36Sopenharmony_ci#define RCTRL_CHECKSUMMING (RCTRL_IPCSEN | RCTRL_TUCSEN | \ 26162306a36Sopenharmony_ci RCTRL_PRSDEP_INIT) 26262306a36Sopenharmony_ci#define RCTRL_EXTHASH (RCTRL_GHTX) 26362306a36Sopenharmony_ci#define RCTRL_VLAN (RCTRL_PRSDEP_INIT) 26462306a36Sopenharmony_ci#define RCTRL_PADDING(x) ((x << 16) & RCTRL_PAL_MASK) 26562306a36Sopenharmony_ci 26662306a36Sopenharmony_ci 26762306a36Sopenharmony_ci#define RSTAT_CLEAR_RHALT 0x00800000 26862306a36Sopenharmony_ci#define RSTAT_CLEAR_RXF0 0x00000080 26962306a36Sopenharmony_ci#define RSTAT_RXF_MASK 0x000000ff 27062306a36Sopenharmony_ci 27162306a36Sopenharmony_ci#define TCTRL_IPCSEN 0x00004000 27262306a36Sopenharmony_ci#define TCTRL_TUCSEN 0x00002000 27362306a36Sopenharmony_ci#define TCTRL_VLINS 0x00001000 27462306a36Sopenharmony_ci#define TCTRL_THDF 0x00000800 27562306a36Sopenharmony_ci#define TCTRL_RFCPAUSE 0x00000010 27662306a36Sopenharmony_ci#define TCTRL_TFCPAUSE 0x00000008 27762306a36Sopenharmony_ci#define TCTRL_TXSCHED_MASK 0x00000006 27862306a36Sopenharmony_ci#define TCTRL_TXSCHED_INIT 0x00000000 27962306a36Sopenharmony_ci/* priority scheduling */ 28062306a36Sopenharmony_ci#define TCTRL_TXSCHED_PRIO 0x00000002 28162306a36Sopenharmony_ci/* weighted round-robin scheduling (WRRS) */ 28262306a36Sopenharmony_ci#define TCTRL_TXSCHED_WRRS 0x00000004 28362306a36Sopenharmony_ci/* default WRRS weight and policy setting, 28462306a36Sopenharmony_ci * tailored to the tr03wt and tr47wt registers: 28562306a36Sopenharmony_ci * equal weight for all Tx Qs, measured in 64byte units 28662306a36Sopenharmony_ci */ 28762306a36Sopenharmony_ci#define DEFAULT_WRRS_WEIGHT 0x18181818 28862306a36Sopenharmony_ci 28962306a36Sopenharmony_ci#define TCTRL_INIT_CSUM (TCTRL_TUCSEN | TCTRL_IPCSEN) 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_ci#define IEVENT_INIT_CLEAR 0xffffffff 29262306a36Sopenharmony_ci#define IEVENT_BABR 0x80000000 29362306a36Sopenharmony_ci#define IEVENT_RXC 0x40000000 29462306a36Sopenharmony_ci#define IEVENT_BSY 0x20000000 29562306a36Sopenharmony_ci#define IEVENT_EBERR 0x10000000 29662306a36Sopenharmony_ci#define IEVENT_MSRO 0x04000000 29762306a36Sopenharmony_ci#define IEVENT_GTSC 0x02000000 29862306a36Sopenharmony_ci#define IEVENT_BABT 0x01000000 29962306a36Sopenharmony_ci#define IEVENT_TXC 0x00800000 30062306a36Sopenharmony_ci#define IEVENT_TXE 0x00400000 30162306a36Sopenharmony_ci#define IEVENT_TXB 0x00200000 30262306a36Sopenharmony_ci#define IEVENT_TXF 0x00100000 30362306a36Sopenharmony_ci#define IEVENT_LC 0x00040000 30462306a36Sopenharmony_ci#define IEVENT_CRL 0x00020000 30562306a36Sopenharmony_ci#define IEVENT_XFUN 0x00010000 30662306a36Sopenharmony_ci#define IEVENT_RXB0 0x00008000 30762306a36Sopenharmony_ci#define IEVENT_MAG 0x00000800 30862306a36Sopenharmony_ci#define IEVENT_GRSC 0x00000100 30962306a36Sopenharmony_ci#define IEVENT_RXF0 0x00000080 31062306a36Sopenharmony_ci#define IEVENT_FGPI 0x00000010 31162306a36Sopenharmony_ci#define IEVENT_FIR 0x00000008 31262306a36Sopenharmony_ci#define IEVENT_FIQ 0x00000004 31362306a36Sopenharmony_ci#define IEVENT_DPE 0x00000002 31462306a36Sopenharmony_ci#define IEVENT_PERR 0x00000001 31562306a36Sopenharmony_ci#define IEVENT_RX_MASK (IEVENT_RXB0 | IEVENT_RXF0 | IEVENT_BSY) 31662306a36Sopenharmony_ci#define IEVENT_TX_MASK (IEVENT_TXB | IEVENT_TXF) 31762306a36Sopenharmony_ci#define IEVENT_RTX_MASK (IEVENT_RX_MASK | IEVENT_TX_MASK) 31862306a36Sopenharmony_ci#define IEVENT_ERR_MASK \ 31962306a36Sopenharmony_ci(IEVENT_RXC | IEVENT_BSY | IEVENT_EBERR | IEVENT_MSRO | \ 32062306a36Sopenharmony_ci IEVENT_BABT | IEVENT_TXC | IEVENT_TXE | IEVENT_LC \ 32162306a36Sopenharmony_ci | IEVENT_CRL | IEVENT_XFUN | IEVENT_DPE | IEVENT_PERR \ 32262306a36Sopenharmony_ci | IEVENT_MAG | IEVENT_BABR) 32362306a36Sopenharmony_ci 32462306a36Sopenharmony_ci#define IMASK_INIT_CLEAR 0x00000000 32562306a36Sopenharmony_ci#define IMASK_BABR 0x80000000 32662306a36Sopenharmony_ci#define IMASK_RXC 0x40000000 32762306a36Sopenharmony_ci#define IMASK_BSY 0x20000000 32862306a36Sopenharmony_ci#define IMASK_EBERR 0x10000000 32962306a36Sopenharmony_ci#define IMASK_MSRO 0x04000000 33062306a36Sopenharmony_ci#define IMASK_GTSC 0x02000000 33162306a36Sopenharmony_ci#define IMASK_BABT 0x01000000 33262306a36Sopenharmony_ci#define IMASK_TXC 0x00800000 33362306a36Sopenharmony_ci#define IMASK_TXEEN 0x00400000 33462306a36Sopenharmony_ci#define IMASK_TXBEN 0x00200000 33562306a36Sopenharmony_ci#define IMASK_TXFEN 0x00100000 33662306a36Sopenharmony_ci#define IMASK_LC 0x00040000 33762306a36Sopenharmony_ci#define IMASK_CRL 0x00020000 33862306a36Sopenharmony_ci#define IMASK_XFUN 0x00010000 33962306a36Sopenharmony_ci#define IMASK_RXB0 0x00008000 34062306a36Sopenharmony_ci#define IMASK_MAG 0x00000800 34162306a36Sopenharmony_ci#define IMASK_GRSC 0x00000100 34262306a36Sopenharmony_ci#define IMASK_RXFEN0 0x00000080 34362306a36Sopenharmony_ci#define IMASK_FGPI 0x00000010 34462306a36Sopenharmony_ci#define IMASK_FIR 0x00000008 34562306a36Sopenharmony_ci#define IMASK_FIQ 0x00000004 34662306a36Sopenharmony_ci#define IMASK_DPE 0x00000002 34762306a36Sopenharmony_ci#define IMASK_PERR 0x00000001 34862306a36Sopenharmony_ci#define IMASK_DEFAULT (IMASK_TXEEN | IMASK_TXFEN | IMASK_TXBEN | \ 34962306a36Sopenharmony_ci IMASK_RXFEN0 | IMASK_BSY | IMASK_EBERR | IMASK_BABR | \ 35062306a36Sopenharmony_ci IMASK_XFUN | IMASK_RXC | IMASK_BABT | IMASK_DPE \ 35162306a36Sopenharmony_ci | IMASK_PERR) 35262306a36Sopenharmony_ci#define IMASK_RX_DEFAULT (IMASK_RXFEN0 | IMASK_BSY) 35362306a36Sopenharmony_ci#define IMASK_TX_DEFAULT (IMASK_TXFEN | IMASK_TXBEN) 35462306a36Sopenharmony_ci 35562306a36Sopenharmony_ci#define IMASK_RX_DISABLED ((~(IMASK_RX_DEFAULT)) & IMASK_DEFAULT) 35662306a36Sopenharmony_ci#define IMASK_TX_DISABLED ((~(IMASK_TX_DEFAULT)) & IMASK_DEFAULT) 35762306a36Sopenharmony_ci 35862306a36Sopenharmony_ci/* Attribute fields */ 35962306a36Sopenharmony_ci 36062306a36Sopenharmony_ci/* This enables rx snooping for buffers and descriptors */ 36162306a36Sopenharmony_ci#define ATTR_BDSTASH 0x00000800 36262306a36Sopenharmony_ci 36362306a36Sopenharmony_ci#define ATTR_BUFSTASH 0x00004000 36462306a36Sopenharmony_ci 36562306a36Sopenharmony_ci#define ATTR_SNOOPING 0x000000c0 36662306a36Sopenharmony_ci#define ATTR_INIT_SETTINGS ATTR_SNOOPING 36762306a36Sopenharmony_ci 36862306a36Sopenharmony_ci#define ATTRELI_INIT_SETTINGS 0x0 36962306a36Sopenharmony_ci#define ATTRELI_EL_MASK 0x3fff0000 37062306a36Sopenharmony_ci#define ATTRELI_EL(x) (x << 16) 37162306a36Sopenharmony_ci#define ATTRELI_EI_MASK 0x00003fff 37262306a36Sopenharmony_ci#define ATTRELI_EI(x) (x) 37362306a36Sopenharmony_ci 37462306a36Sopenharmony_ci#define BD_LFLAG(flags) ((flags) << 16) 37562306a36Sopenharmony_ci#define BD_LENGTH_MASK 0x0000ffff 37662306a36Sopenharmony_ci 37762306a36Sopenharmony_ci#define FPR_FILER_MASK 0xFFFFFFFF 37862306a36Sopenharmony_ci#define MAX_FILER_IDX 0xFF 37962306a36Sopenharmony_ci 38062306a36Sopenharmony_ci/* This default RIR value directly corresponds 38162306a36Sopenharmony_ci * to the 3-bit hash value generated */ 38262306a36Sopenharmony_ci#define DEFAULT_8RXQ_RIR0 0x05397700 38362306a36Sopenharmony_ci/* Map even hash values to Q0, and odd ones to Q1 */ 38462306a36Sopenharmony_ci#define DEFAULT_2RXQ_RIR0 0x04104100 38562306a36Sopenharmony_ci 38662306a36Sopenharmony_ci/* RQFCR register bits */ 38762306a36Sopenharmony_ci#define RQFCR_GPI 0x80000000 38862306a36Sopenharmony_ci#define RQFCR_HASHTBL_Q 0x00000000 38962306a36Sopenharmony_ci#define RQFCR_HASHTBL_0 0x00020000 39062306a36Sopenharmony_ci#define RQFCR_HASHTBL_1 0x00040000 39162306a36Sopenharmony_ci#define RQFCR_HASHTBL_2 0x00060000 39262306a36Sopenharmony_ci#define RQFCR_HASHTBL_3 0x00080000 39362306a36Sopenharmony_ci#define RQFCR_HASH 0x00010000 39462306a36Sopenharmony_ci#define RQFCR_QUEUE 0x0000FC00 39562306a36Sopenharmony_ci#define RQFCR_CLE 0x00000200 39662306a36Sopenharmony_ci#define RQFCR_RJE 0x00000100 39762306a36Sopenharmony_ci#define RQFCR_AND 0x00000080 39862306a36Sopenharmony_ci#define RQFCR_CMP_EXACT 0x00000000 39962306a36Sopenharmony_ci#define RQFCR_CMP_MATCH 0x00000020 40062306a36Sopenharmony_ci#define RQFCR_CMP_NOEXACT 0x00000040 40162306a36Sopenharmony_ci#define RQFCR_CMP_NOMATCH 0x00000060 40262306a36Sopenharmony_ci 40362306a36Sopenharmony_ci/* RQFCR PID values */ 40462306a36Sopenharmony_ci#define RQFCR_PID_MASK 0x00000000 40562306a36Sopenharmony_ci#define RQFCR_PID_PARSE 0x00000001 40662306a36Sopenharmony_ci#define RQFCR_PID_ARB 0x00000002 40762306a36Sopenharmony_ci#define RQFCR_PID_DAH 0x00000003 40862306a36Sopenharmony_ci#define RQFCR_PID_DAL 0x00000004 40962306a36Sopenharmony_ci#define RQFCR_PID_SAH 0x00000005 41062306a36Sopenharmony_ci#define RQFCR_PID_SAL 0x00000006 41162306a36Sopenharmony_ci#define RQFCR_PID_ETY 0x00000007 41262306a36Sopenharmony_ci#define RQFCR_PID_VID 0x00000008 41362306a36Sopenharmony_ci#define RQFCR_PID_PRI 0x00000009 41462306a36Sopenharmony_ci#define RQFCR_PID_TOS 0x0000000A 41562306a36Sopenharmony_ci#define RQFCR_PID_L4P 0x0000000B 41662306a36Sopenharmony_ci#define RQFCR_PID_DIA 0x0000000C 41762306a36Sopenharmony_ci#define RQFCR_PID_SIA 0x0000000D 41862306a36Sopenharmony_ci#define RQFCR_PID_DPT 0x0000000E 41962306a36Sopenharmony_ci#define RQFCR_PID_SPT 0x0000000F 42062306a36Sopenharmony_ci 42162306a36Sopenharmony_ci/* RQFPR when PID is 0x0001 */ 42262306a36Sopenharmony_ci#define RQFPR_HDR_GE_512 0x00200000 42362306a36Sopenharmony_ci#define RQFPR_LERR 0x00100000 42462306a36Sopenharmony_ci#define RQFPR_RAR 0x00080000 42562306a36Sopenharmony_ci#define RQFPR_RARQ 0x00040000 42662306a36Sopenharmony_ci#define RQFPR_AR 0x00020000 42762306a36Sopenharmony_ci#define RQFPR_ARQ 0x00010000 42862306a36Sopenharmony_ci#define RQFPR_EBC 0x00008000 42962306a36Sopenharmony_ci#define RQFPR_VLN 0x00004000 43062306a36Sopenharmony_ci#define RQFPR_CFI 0x00002000 43162306a36Sopenharmony_ci#define RQFPR_JUM 0x00001000 43262306a36Sopenharmony_ci#define RQFPR_IPF 0x00000800 43362306a36Sopenharmony_ci#define RQFPR_FIF 0x00000400 43462306a36Sopenharmony_ci#define RQFPR_IPV4 0x00000200 43562306a36Sopenharmony_ci#define RQFPR_IPV6 0x00000100 43662306a36Sopenharmony_ci#define RQFPR_ICC 0x00000080 43762306a36Sopenharmony_ci#define RQFPR_ICV 0x00000040 43862306a36Sopenharmony_ci#define RQFPR_TCP 0x00000020 43962306a36Sopenharmony_ci#define RQFPR_UDP 0x00000010 44062306a36Sopenharmony_ci#define RQFPR_TUC 0x00000008 44162306a36Sopenharmony_ci#define RQFPR_TUV 0x00000004 44262306a36Sopenharmony_ci#define RQFPR_PER 0x00000002 44362306a36Sopenharmony_ci#define RQFPR_EER 0x00000001 44462306a36Sopenharmony_ci 44562306a36Sopenharmony_ci/* CAR1 bits */ 44662306a36Sopenharmony_ci#define CAR1_C164 0x80000000 44762306a36Sopenharmony_ci#define CAR1_C1127 0x40000000 44862306a36Sopenharmony_ci#define CAR1_C1255 0x20000000 44962306a36Sopenharmony_ci#define CAR1_C1511 0x10000000 45062306a36Sopenharmony_ci#define CAR1_C11K 0x08000000 45162306a36Sopenharmony_ci#define CAR1_C1MAX 0x04000000 45262306a36Sopenharmony_ci#define CAR1_C1MGV 0x02000000 45362306a36Sopenharmony_ci#define CAR1_C1REJ 0x00020000 45462306a36Sopenharmony_ci#define CAR1_C1RBY 0x00010000 45562306a36Sopenharmony_ci#define CAR1_C1RPK 0x00008000 45662306a36Sopenharmony_ci#define CAR1_C1RFC 0x00004000 45762306a36Sopenharmony_ci#define CAR1_C1RMC 0x00002000 45862306a36Sopenharmony_ci#define CAR1_C1RBC 0x00001000 45962306a36Sopenharmony_ci#define CAR1_C1RXC 0x00000800 46062306a36Sopenharmony_ci#define CAR1_C1RXP 0x00000400 46162306a36Sopenharmony_ci#define CAR1_C1RXU 0x00000200 46262306a36Sopenharmony_ci#define CAR1_C1RAL 0x00000100 46362306a36Sopenharmony_ci#define CAR1_C1RFL 0x00000080 46462306a36Sopenharmony_ci#define CAR1_C1RCD 0x00000040 46562306a36Sopenharmony_ci#define CAR1_C1RCS 0x00000020 46662306a36Sopenharmony_ci#define CAR1_C1RUN 0x00000010 46762306a36Sopenharmony_ci#define CAR1_C1ROV 0x00000008 46862306a36Sopenharmony_ci#define CAR1_C1RFR 0x00000004 46962306a36Sopenharmony_ci#define CAR1_C1RJB 0x00000002 47062306a36Sopenharmony_ci#define CAR1_C1RDR 0x00000001 47162306a36Sopenharmony_ci 47262306a36Sopenharmony_ci/* CAM1 bits */ 47362306a36Sopenharmony_ci#define CAM1_M164 0x80000000 47462306a36Sopenharmony_ci#define CAM1_M1127 0x40000000 47562306a36Sopenharmony_ci#define CAM1_M1255 0x20000000 47662306a36Sopenharmony_ci#define CAM1_M1511 0x10000000 47762306a36Sopenharmony_ci#define CAM1_M11K 0x08000000 47862306a36Sopenharmony_ci#define CAM1_M1MAX 0x04000000 47962306a36Sopenharmony_ci#define CAM1_M1MGV 0x02000000 48062306a36Sopenharmony_ci#define CAM1_M1REJ 0x00020000 48162306a36Sopenharmony_ci#define CAM1_M1RBY 0x00010000 48262306a36Sopenharmony_ci#define CAM1_M1RPK 0x00008000 48362306a36Sopenharmony_ci#define CAM1_M1RFC 0x00004000 48462306a36Sopenharmony_ci#define CAM1_M1RMC 0x00002000 48562306a36Sopenharmony_ci#define CAM1_M1RBC 0x00001000 48662306a36Sopenharmony_ci#define CAM1_M1RXC 0x00000800 48762306a36Sopenharmony_ci#define CAM1_M1RXP 0x00000400 48862306a36Sopenharmony_ci#define CAM1_M1RXU 0x00000200 48962306a36Sopenharmony_ci#define CAM1_M1RAL 0x00000100 49062306a36Sopenharmony_ci#define CAM1_M1RFL 0x00000080 49162306a36Sopenharmony_ci#define CAM1_M1RCD 0x00000040 49262306a36Sopenharmony_ci#define CAM1_M1RCS 0x00000020 49362306a36Sopenharmony_ci#define CAM1_M1RUN 0x00000010 49462306a36Sopenharmony_ci#define CAM1_M1ROV 0x00000008 49562306a36Sopenharmony_ci#define CAM1_M1RFR 0x00000004 49662306a36Sopenharmony_ci#define CAM1_M1RJB 0x00000002 49762306a36Sopenharmony_ci#define CAM1_M1RDR 0x00000001 49862306a36Sopenharmony_ci 49962306a36Sopenharmony_ci/* TxBD status field bits */ 50062306a36Sopenharmony_ci#define TXBD_READY 0x8000 50162306a36Sopenharmony_ci#define TXBD_PADCRC 0x4000 50262306a36Sopenharmony_ci#define TXBD_WRAP 0x2000 50362306a36Sopenharmony_ci#define TXBD_INTERRUPT 0x1000 50462306a36Sopenharmony_ci#define TXBD_LAST 0x0800 50562306a36Sopenharmony_ci#define TXBD_CRC 0x0400 50662306a36Sopenharmony_ci#define TXBD_DEF 0x0200 50762306a36Sopenharmony_ci#define TXBD_HUGEFRAME 0x0080 50862306a36Sopenharmony_ci#define TXBD_LATECOLLISION 0x0080 50962306a36Sopenharmony_ci#define TXBD_RETRYLIMIT 0x0040 51062306a36Sopenharmony_ci#define TXBD_RETRYCOUNTMASK 0x003c 51162306a36Sopenharmony_ci#define TXBD_UNDERRUN 0x0002 51262306a36Sopenharmony_ci#define TXBD_TOE 0x0002 51362306a36Sopenharmony_ci 51462306a36Sopenharmony_ci/* Tx FCB param bits */ 51562306a36Sopenharmony_ci#define TXFCB_VLN 0x80 51662306a36Sopenharmony_ci#define TXFCB_IP 0x40 51762306a36Sopenharmony_ci#define TXFCB_IP6 0x20 51862306a36Sopenharmony_ci#define TXFCB_TUP 0x10 51962306a36Sopenharmony_ci#define TXFCB_UDP 0x08 52062306a36Sopenharmony_ci#define TXFCB_CIP 0x04 52162306a36Sopenharmony_ci#define TXFCB_CTU 0x02 52262306a36Sopenharmony_ci#define TXFCB_NPH 0x01 52362306a36Sopenharmony_ci#define TXFCB_DEFAULT (TXFCB_IP|TXFCB_TUP|TXFCB_CTU|TXFCB_NPH) 52462306a36Sopenharmony_ci 52562306a36Sopenharmony_ci/* RxBD status field bits */ 52662306a36Sopenharmony_ci#define RXBD_EMPTY 0x8000 52762306a36Sopenharmony_ci#define RXBD_RO1 0x4000 52862306a36Sopenharmony_ci#define RXBD_WRAP 0x2000 52962306a36Sopenharmony_ci#define RXBD_INTERRUPT 0x1000 53062306a36Sopenharmony_ci#define RXBD_LAST 0x0800 53162306a36Sopenharmony_ci#define RXBD_FIRST 0x0400 53262306a36Sopenharmony_ci#define RXBD_MISS 0x0100 53362306a36Sopenharmony_ci#define RXBD_BROADCAST 0x0080 53462306a36Sopenharmony_ci#define RXBD_MULTICAST 0x0040 53562306a36Sopenharmony_ci#define RXBD_LARGE 0x0020 53662306a36Sopenharmony_ci#define RXBD_NONOCTET 0x0010 53762306a36Sopenharmony_ci#define RXBD_SHORT 0x0008 53862306a36Sopenharmony_ci#define RXBD_CRCERR 0x0004 53962306a36Sopenharmony_ci#define RXBD_OVERRUN 0x0002 54062306a36Sopenharmony_ci#define RXBD_TRUNCATED 0x0001 54162306a36Sopenharmony_ci#define RXBD_STATS 0x01ff 54262306a36Sopenharmony_ci#define RXBD_ERR (RXBD_LARGE | RXBD_SHORT | RXBD_NONOCTET \ 54362306a36Sopenharmony_ci | RXBD_CRCERR | RXBD_OVERRUN \ 54462306a36Sopenharmony_ci | RXBD_TRUNCATED) 54562306a36Sopenharmony_ci 54662306a36Sopenharmony_ci/* Rx FCB status field bits */ 54762306a36Sopenharmony_ci#define RXFCB_VLN 0x8000 54862306a36Sopenharmony_ci#define RXFCB_IP 0x4000 54962306a36Sopenharmony_ci#define RXFCB_IP6 0x2000 55062306a36Sopenharmony_ci#define RXFCB_TUP 0x1000 55162306a36Sopenharmony_ci#define RXFCB_CIP 0x0800 55262306a36Sopenharmony_ci#define RXFCB_CTU 0x0400 55362306a36Sopenharmony_ci#define RXFCB_EIP 0x0200 55462306a36Sopenharmony_ci#define RXFCB_ETU 0x0100 55562306a36Sopenharmony_ci#define RXFCB_CSUM_MASK 0x0f00 55662306a36Sopenharmony_ci#define RXFCB_PERR_MASK 0x000c 55762306a36Sopenharmony_ci#define RXFCB_PERR_BADL3 0x0008 55862306a36Sopenharmony_ci 55962306a36Sopenharmony_ci#define GFAR_INT_NAME_MAX (IFNAMSIZ + 6) /* '_g#_xx' */ 56062306a36Sopenharmony_ci 56162306a36Sopenharmony_ci#define GFAR_WOL_MAGIC 0x00000001 56262306a36Sopenharmony_ci#define GFAR_WOL_FILER_UCAST 0x00000002 56362306a36Sopenharmony_ci 56462306a36Sopenharmony_cistruct txbd8 56562306a36Sopenharmony_ci{ 56662306a36Sopenharmony_ci union { 56762306a36Sopenharmony_ci struct { 56862306a36Sopenharmony_ci __be16 status; /* Status Fields */ 56962306a36Sopenharmony_ci __be16 length; /* Buffer length */ 57062306a36Sopenharmony_ci }; 57162306a36Sopenharmony_ci __be32 lstatus; 57262306a36Sopenharmony_ci }; 57362306a36Sopenharmony_ci __be32 bufPtr; /* Buffer Pointer */ 57462306a36Sopenharmony_ci}; 57562306a36Sopenharmony_ci 57662306a36Sopenharmony_cistruct txfcb { 57762306a36Sopenharmony_ci u8 flags; 57862306a36Sopenharmony_ci u8 ptp; /* Flag to enable tx timestamping */ 57962306a36Sopenharmony_ci u8 l4os; /* Level 4 Header Offset */ 58062306a36Sopenharmony_ci u8 l3os; /* Level 3 Header Offset */ 58162306a36Sopenharmony_ci __be16 phcs; /* Pseudo-header Checksum */ 58262306a36Sopenharmony_ci __be16 vlctl; /* VLAN control word */ 58362306a36Sopenharmony_ci}; 58462306a36Sopenharmony_ci 58562306a36Sopenharmony_cistruct rxbd8 58662306a36Sopenharmony_ci{ 58762306a36Sopenharmony_ci union { 58862306a36Sopenharmony_ci struct { 58962306a36Sopenharmony_ci __be16 status; /* Status Fields */ 59062306a36Sopenharmony_ci __be16 length; /* Buffer Length */ 59162306a36Sopenharmony_ci }; 59262306a36Sopenharmony_ci __be32 lstatus; 59362306a36Sopenharmony_ci }; 59462306a36Sopenharmony_ci __be32 bufPtr; /* Buffer Pointer */ 59562306a36Sopenharmony_ci}; 59662306a36Sopenharmony_ci 59762306a36Sopenharmony_cistruct rxfcb { 59862306a36Sopenharmony_ci __be16 flags; 59962306a36Sopenharmony_ci u8 rq; /* Receive Queue index */ 60062306a36Sopenharmony_ci u8 pro; /* Layer 4 Protocol */ 60162306a36Sopenharmony_ci u16 reserved; 60262306a36Sopenharmony_ci __be16 vlctl; /* VLAN control word */ 60362306a36Sopenharmony_ci}; 60462306a36Sopenharmony_ci 60562306a36Sopenharmony_cistruct gianfar_skb_cb { 60662306a36Sopenharmony_ci unsigned int bytes_sent; /* bytes-on-wire (i.e. no FCB) */ 60762306a36Sopenharmony_ci}; 60862306a36Sopenharmony_ci 60962306a36Sopenharmony_ci#define GFAR_CB(skb) ((struct gianfar_skb_cb *)((skb)->cb)) 61062306a36Sopenharmony_ci 61162306a36Sopenharmony_cistruct rmon_mib 61262306a36Sopenharmony_ci{ 61362306a36Sopenharmony_ci u32 tr64; /* 0x.680 - Transmit and Receive 64-byte Frame Counter */ 61462306a36Sopenharmony_ci u32 tr127; /* 0x.684 - Transmit and Receive 65-127 byte Frame Counter */ 61562306a36Sopenharmony_ci u32 tr255; /* 0x.688 - Transmit and Receive 128-255 byte Frame Counter */ 61662306a36Sopenharmony_ci u32 tr511; /* 0x.68c - Transmit and Receive 256-511 byte Frame Counter */ 61762306a36Sopenharmony_ci u32 tr1k; /* 0x.690 - Transmit and Receive 512-1023 byte Frame Counter */ 61862306a36Sopenharmony_ci u32 trmax; /* 0x.694 - Transmit and Receive 1024-1518 byte Frame Counter */ 61962306a36Sopenharmony_ci u32 trmgv; /* 0x.698 - Transmit and Receive 1519-1522 byte Good VLAN Frame */ 62062306a36Sopenharmony_ci u32 rbyt; /* 0x.69c - Receive Byte Counter */ 62162306a36Sopenharmony_ci u32 rpkt; /* 0x.6a0 - Receive Packet Counter */ 62262306a36Sopenharmony_ci u32 rfcs; /* 0x.6a4 - Receive FCS Error Counter */ 62362306a36Sopenharmony_ci u32 rmca; /* 0x.6a8 - Receive Multicast Packet Counter */ 62462306a36Sopenharmony_ci u32 rbca; /* 0x.6ac - Receive Broadcast Packet Counter */ 62562306a36Sopenharmony_ci u32 rxcf; /* 0x.6b0 - Receive Control Frame Packet Counter */ 62662306a36Sopenharmony_ci u32 rxpf; /* 0x.6b4 - Receive Pause Frame Packet Counter */ 62762306a36Sopenharmony_ci u32 rxuo; /* 0x.6b8 - Receive Unknown OP Code Counter */ 62862306a36Sopenharmony_ci u32 raln; /* 0x.6bc - Receive Alignment Error Counter */ 62962306a36Sopenharmony_ci u32 rflr; /* 0x.6c0 - Receive Frame Length Error Counter */ 63062306a36Sopenharmony_ci u32 rcde; /* 0x.6c4 - Receive Code Error Counter */ 63162306a36Sopenharmony_ci u32 rcse; /* 0x.6c8 - Receive Carrier Sense Error Counter */ 63262306a36Sopenharmony_ci u32 rund; /* 0x.6cc - Receive Undersize Packet Counter */ 63362306a36Sopenharmony_ci u32 rovr; /* 0x.6d0 - Receive Oversize Packet Counter */ 63462306a36Sopenharmony_ci u32 rfrg; /* 0x.6d4 - Receive Fragments Counter */ 63562306a36Sopenharmony_ci u32 rjbr; /* 0x.6d8 - Receive Jabber Counter */ 63662306a36Sopenharmony_ci u32 rdrp; /* 0x.6dc - Receive Drop Counter */ 63762306a36Sopenharmony_ci u32 tbyt; /* 0x.6e0 - Transmit Byte Counter Counter */ 63862306a36Sopenharmony_ci u32 tpkt; /* 0x.6e4 - Transmit Packet Counter */ 63962306a36Sopenharmony_ci u32 tmca; /* 0x.6e8 - Transmit Multicast Packet Counter */ 64062306a36Sopenharmony_ci u32 tbca; /* 0x.6ec - Transmit Broadcast Packet Counter */ 64162306a36Sopenharmony_ci u32 txpf; /* 0x.6f0 - Transmit Pause Control Frame Counter */ 64262306a36Sopenharmony_ci u32 tdfr; /* 0x.6f4 - Transmit Deferral Packet Counter */ 64362306a36Sopenharmony_ci u32 tedf; /* 0x.6f8 - Transmit Excessive Deferral Packet Counter */ 64462306a36Sopenharmony_ci u32 tscl; /* 0x.6fc - Transmit Single Collision Packet Counter */ 64562306a36Sopenharmony_ci u32 tmcl; /* 0x.700 - Transmit Multiple Collision Packet Counter */ 64662306a36Sopenharmony_ci u32 tlcl; /* 0x.704 - Transmit Late Collision Packet Counter */ 64762306a36Sopenharmony_ci u32 txcl; /* 0x.708 - Transmit Excessive Collision Packet Counter */ 64862306a36Sopenharmony_ci u32 tncl; /* 0x.70c - Transmit Total Collision Counter */ 64962306a36Sopenharmony_ci u8 res1[4]; 65062306a36Sopenharmony_ci u32 tdrp; /* 0x.714 - Transmit Drop Frame Counter */ 65162306a36Sopenharmony_ci u32 tjbr; /* 0x.718 - Transmit Jabber Frame Counter */ 65262306a36Sopenharmony_ci u32 tfcs; /* 0x.71c - Transmit FCS Error Counter */ 65362306a36Sopenharmony_ci u32 txcf; /* 0x.720 - Transmit Control Frame Counter */ 65462306a36Sopenharmony_ci u32 tovr; /* 0x.724 - Transmit Oversize Frame Counter */ 65562306a36Sopenharmony_ci u32 tund; /* 0x.728 - Transmit Undersize Frame Counter */ 65662306a36Sopenharmony_ci u32 tfrg; /* 0x.72c - Transmit Fragments Frame Counter */ 65762306a36Sopenharmony_ci u32 car1; /* 0x.730 - Carry Register One */ 65862306a36Sopenharmony_ci u32 car2; /* 0x.734 - Carry Register Two */ 65962306a36Sopenharmony_ci u32 cam1; /* 0x.738 - Carry Mask Register One */ 66062306a36Sopenharmony_ci u32 cam2; /* 0x.73c - Carry Mask Register Two */ 66162306a36Sopenharmony_ci}; 66262306a36Sopenharmony_ci 66362306a36Sopenharmony_cistruct rmon_overflow { 66462306a36Sopenharmony_ci /* lock for synchronization of the rdrp field of this struct, and 66562306a36Sopenharmony_ci * CAR1/CAR2 registers 66662306a36Sopenharmony_ci */ 66762306a36Sopenharmony_ci spinlock_t lock; 66862306a36Sopenharmony_ci u32 imask; 66962306a36Sopenharmony_ci u64 rdrp; 67062306a36Sopenharmony_ci}; 67162306a36Sopenharmony_ci 67262306a36Sopenharmony_cistruct gfar_extra_stats { 67362306a36Sopenharmony_ci atomic64_t rx_alloc_err; 67462306a36Sopenharmony_ci atomic64_t rx_large; 67562306a36Sopenharmony_ci atomic64_t rx_short; 67662306a36Sopenharmony_ci atomic64_t rx_nonoctet; 67762306a36Sopenharmony_ci atomic64_t rx_crcerr; 67862306a36Sopenharmony_ci atomic64_t rx_overrun; 67962306a36Sopenharmony_ci atomic64_t rx_bsy; 68062306a36Sopenharmony_ci atomic64_t rx_babr; 68162306a36Sopenharmony_ci atomic64_t rx_trunc; 68262306a36Sopenharmony_ci atomic64_t eberr; 68362306a36Sopenharmony_ci atomic64_t tx_babt; 68462306a36Sopenharmony_ci atomic64_t tx_underrun; 68562306a36Sopenharmony_ci atomic64_t tx_timeout; 68662306a36Sopenharmony_ci}; 68762306a36Sopenharmony_ci 68862306a36Sopenharmony_ci#define GFAR_RMON_LEN ((sizeof(struct rmon_mib) - 16)/sizeof(u32)) 68962306a36Sopenharmony_ci#define GFAR_EXTRA_STATS_LEN \ 69062306a36Sopenharmony_ci (sizeof(struct gfar_extra_stats)/sizeof(atomic64_t)) 69162306a36Sopenharmony_ci 69262306a36Sopenharmony_ci/* Number of stats exported via ethtool */ 69362306a36Sopenharmony_ci#define GFAR_STATS_LEN (GFAR_RMON_LEN + GFAR_EXTRA_STATS_LEN) 69462306a36Sopenharmony_ci 69562306a36Sopenharmony_cistruct gfar { 69662306a36Sopenharmony_ci u32 tsec_id; /* 0x.000 - Controller ID register */ 69762306a36Sopenharmony_ci u32 tsec_id2; /* 0x.004 - Controller ID2 register */ 69862306a36Sopenharmony_ci u8 res1[8]; 69962306a36Sopenharmony_ci u32 ievent; /* 0x.010 - Interrupt Event Register */ 70062306a36Sopenharmony_ci u32 imask; /* 0x.014 - Interrupt Mask Register */ 70162306a36Sopenharmony_ci u32 edis; /* 0x.018 - Error Disabled Register */ 70262306a36Sopenharmony_ci u32 emapg; /* 0x.01c - Group Error mapping register */ 70362306a36Sopenharmony_ci u32 ecntrl; /* 0x.020 - Ethernet Control Register */ 70462306a36Sopenharmony_ci u32 minflr; /* 0x.024 - Minimum Frame Length Register */ 70562306a36Sopenharmony_ci u32 ptv; /* 0x.028 - Pause Time Value Register */ 70662306a36Sopenharmony_ci u32 dmactrl; /* 0x.02c - DMA Control Register */ 70762306a36Sopenharmony_ci u32 tbipa; /* 0x.030 - TBI PHY Address Register */ 70862306a36Sopenharmony_ci u8 res2[28]; 70962306a36Sopenharmony_ci u32 fifo_rx_pause; /* 0x.050 - FIFO receive pause start threshold 71062306a36Sopenharmony_ci register */ 71162306a36Sopenharmony_ci u32 fifo_rx_pause_shutoff; /* x.054 - FIFO receive starve shutoff 71262306a36Sopenharmony_ci register */ 71362306a36Sopenharmony_ci u32 fifo_rx_alarm; /* 0x.058 - FIFO receive alarm start threshold 71462306a36Sopenharmony_ci register */ 71562306a36Sopenharmony_ci u32 fifo_rx_alarm_shutoff; /*0x.05c - FIFO receive alarm starve 71662306a36Sopenharmony_ci shutoff register */ 71762306a36Sopenharmony_ci u8 res3[44]; 71862306a36Sopenharmony_ci u32 fifo_tx_thr; /* 0x.08c - FIFO transmit threshold register */ 71962306a36Sopenharmony_ci u8 res4[8]; 72062306a36Sopenharmony_ci u32 fifo_tx_starve; /* 0x.098 - FIFO transmit starve register */ 72162306a36Sopenharmony_ci u32 fifo_tx_starve_shutoff; /* 0x.09c - FIFO transmit starve shutoff register */ 72262306a36Sopenharmony_ci u8 res5[96]; 72362306a36Sopenharmony_ci u32 tctrl; /* 0x.100 - Transmit Control Register */ 72462306a36Sopenharmony_ci u32 tstat; /* 0x.104 - Transmit Status Register */ 72562306a36Sopenharmony_ci u32 dfvlan; /* 0x.108 - Default VLAN Control word */ 72662306a36Sopenharmony_ci u32 tbdlen; /* 0x.10c - Transmit Buffer Descriptor Data Length Register */ 72762306a36Sopenharmony_ci u32 txic; /* 0x.110 - Transmit Interrupt Coalescing Configuration Register */ 72862306a36Sopenharmony_ci u32 tqueue; /* 0x.114 - Transmit queue control register */ 72962306a36Sopenharmony_ci u8 res7[40]; 73062306a36Sopenharmony_ci u32 tr03wt; /* 0x.140 - TxBD Rings 0-3 round-robin weightings */ 73162306a36Sopenharmony_ci u32 tr47wt; /* 0x.144 - TxBD Rings 4-7 round-robin weightings */ 73262306a36Sopenharmony_ci u8 res8[52]; 73362306a36Sopenharmony_ci u32 tbdbph; /* 0x.17c - Tx data buffer pointer high */ 73462306a36Sopenharmony_ci u8 res9a[4]; 73562306a36Sopenharmony_ci u32 tbptr0; /* 0x.184 - TxBD Pointer for ring 0 */ 73662306a36Sopenharmony_ci u8 res9b[4]; 73762306a36Sopenharmony_ci u32 tbptr1; /* 0x.18c - TxBD Pointer for ring 1 */ 73862306a36Sopenharmony_ci u8 res9c[4]; 73962306a36Sopenharmony_ci u32 tbptr2; /* 0x.194 - TxBD Pointer for ring 2 */ 74062306a36Sopenharmony_ci u8 res9d[4]; 74162306a36Sopenharmony_ci u32 tbptr3; /* 0x.19c - TxBD Pointer for ring 3 */ 74262306a36Sopenharmony_ci u8 res9e[4]; 74362306a36Sopenharmony_ci u32 tbptr4; /* 0x.1a4 - TxBD Pointer for ring 4 */ 74462306a36Sopenharmony_ci u8 res9f[4]; 74562306a36Sopenharmony_ci u32 tbptr5; /* 0x.1ac - TxBD Pointer for ring 5 */ 74662306a36Sopenharmony_ci u8 res9g[4]; 74762306a36Sopenharmony_ci u32 tbptr6; /* 0x.1b4 - TxBD Pointer for ring 6 */ 74862306a36Sopenharmony_ci u8 res9h[4]; 74962306a36Sopenharmony_ci u32 tbptr7; /* 0x.1bc - TxBD Pointer for ring 7 */ 75062306a36Sopenharmony_ci u8 res9[64]; 75162306a36Sopenharmony_ci u32 tbaseh; /* 0x.200 - TxBD base address high */ 75262306a36Sopenharmony_ci u32 tbase0; /* 0x.204 - TxBD Base Address of ring 0 */ 75362306a36Sopenharmony_ci u8 res10a[4]; 75462306a36Sopenharmony_ci u32 tbase1; /* 0x.20c - TxBD Base Address of ring 1 */ 75562306a36Sopenharmony_ci u8 res10b[4]; 75662306a36Sopenharmony_ci u32 tbase2; /* 0x.214 - TxBD Base Address of ring 2 */ 75762306a36Sopenharmony_ci u8 res10c[4]; 75862306a36Sopenharmony_ci u32 tbase3; /* 0x.21c - TxBD Base Address of ring 3 */ 75962306a36Sopenharmony_ci u8 res10d[4]; 76062306a36Sopenharmony_ci u32 tbase4; /* 0x.224 - TxBD Base Address of ring 4 */ 76162306a36Sopenharmony_ci u8 res10e[4]; 76262306a36Sopenharmony_ci u32 tbase5; /* 0x.22c - TxBD Base Address of ring 5 */ 76362306a36Sopenharmony_ci u8 res10f[4]; 76462306a36Sopenharmony_ci u32 tbase6; /* 0x.234 - TxBD Base Address of ring 6 */ 76562306a36Sopenharmony_ci u8 res10g[4]; 76662306a36Sopenharmony_ci u32 tbase7; /* 0x.23c - TxBD Base Address of ring 7 */ 76762306a36Sopenharmony_ci u8 res10[192]; 76862306a36Sopenharmony_ci u32 rctrl; /* 0x.300 - Receive Control Register */ 76962306a36Sopenharmony_ci u32 rstat; /* 0x.304 - Receive Status Register */ 77062306a36Sopenharmony_ci u8 res12[8]; 77162306a36Sopenharmony_ci u32 rxic; /* 0x.310 - Receive Interrupt Coalescing Configuration Register */ 77262306a36Sopenharmony_ci u32 rqueue; /* 0x.314 - Receive queue control register */ 77362306a36Sopenharmony_ci u32 rir0; /* 0x.318 - Ring mapping register 0 */ 77462306a36Sopenharmony_ci u32 rir1; /* 0x.31c - Ring mapping register 1 */ 77562306a36Sopenharmony_ci u32 rir2; /* 0x.320 - Ring mapping register 2 */ 77662306a36Sopenharmony_ci u32 rir3; /* 0x.324 - Ring mapping register 3 */ 77762306a36Sopenharmony_ci u8 res13[8]; 77862306a36Sopenharmony_ci u32 rbifx; /* 0x.330 - Receive bit field extract control register */ 77962306a36Sopenharmony_ci u32 rqfar; /* 0x.334 - Receive queue filing table address register */ 78062306a36Sopenharmony_ci u32 rqfcr; /* 0x.338 - Receive queue filing table control register */ 78162306a36Sopenharmony_ci u32 rqfpr; /* 0x.33c - Receive queue filing table property register */ 78262306a36Sopenharmony_ci u32 mrblr; /* 0x.340 - Maximum Receive Buffer Length Register */ 78362306a36Sopenharmony_ci u8 res14[56]; 78462306a36Sopenharmony_ci u32 rbdbph; /* 0x.37c - Rx data buffer pointer high */ 78562306a36Sopenharmony_ci u8 res15a[4]; 78662306a36Sopenharmony_ci u32 rbptr0; /* 0x.384 - RxBD pointer for ring 0 */ 78762306a36Sopenharmony_ci u8 res15b[4]; 78862306a36Sopenharmony_ci u32 rbptr1; /* 0x.38c - RxBD pointer for ring 1 */ 78962306a36Sopenharmony_ci u8 res15c[4]; 79062306a36Sopenharmony_ci u32 rbptr2; /* 0x.394 - RxBD pointer for ring 2 */ 79162306a36Sopenharmony_ci u8 res15d[4]; 79262306a36Sopenharmony_ci u32 rbptr3; /* 0x.39c - RxBD pointer for ring 3 */ 79362306a36Sopenharmony_ci u8 res15e[4]; 79462306a36Sopenharmony_ci u32 rbptr4; /* 0x.3a4 - RxBD pointer for ring 4 */ 79562306a36Sopenharmony_ci u8 res15f[4]; 79662306a36Sopenharmony_ci u32 rbptr5; /* 0x.3ac - RxBD pointer for ring 5 */ 79762306a36Sopenharmony_ci u8 res15g[4]; 79862306a36Sopenharmony_ci u32 rbptr6; /* 0x.3b4 - RxBD pointer for ring 6 */ 79962306a36Sopenharmony_ci u8 res15h[4]; 80062306a36Sopenharmony_ci u32 rbptr7; /* 0x.3bc - RxBD pointer for ring 7 */ 80162306a36Sopenharmony_ci u8 res16[64]; 80262306a36Sopenharmony_ci u32 rbaseh; /* 0x.400 - RxBD base address high */ 80362306a36Sopenharmony_ci u32 rbase0; /* 0x.404 - RxBD base address of ring 0 */ 80462306a36Sopenharmony_ci u8 res17a[4]; 80562306a36Sopenharmony_ci u32 rbase1; /* 0x.40c - RxBD base address of ring 1 */ 80662306a36Sopenharmony_ci u8 res17b[4]; 80762306a36Sopenharmony_ci u32 rbase2; /* 0x.414 - RxBD base address of ring 2 */ 80862306a36Sopenharmony_ci u8 res17c[4]; 80962306a36Sopenharmony_ci u32 rbase3; /* 0x.41c - RxBD base address of ring 3 */ 81062306a36Sopenharmony_ci u8 res17d[4]; 81162306a36Sopenharmony_ci u32 rbase4; /* 0x.424 - RxBD base address of ring 4 */ 81262306a36Sopenharmony_ci u8 res17e[4]; 81362306a36Sopenharmony_ci u32 rbase5; /* 0x.42c - RxBD base address of ring 5 */ 81462306a36Sopenharmony_ci u8 res17f[4]; 81562306a36Sopenharmony_ci u32 rbase6; /* 0x.434 - RxBD base address of ring 6 */ 81662306a36Sopenharmony_ci u8 res17g[4]; 81762306a36Sopenharmony_ci u32 rbase7; /* 0x.43c - RxBD base address of ring 7 */ 81862306a36Sopenharmony_ci u8 res17[192]; 81962306a36Sopenharmony_ci u32 maccfg1; /* 0x.500 - MAC Configuration 1 Register */ 82062306a36Sopenharmony_ci u32 maccfg2; /* 0x.504 - MAC Configuration 2 Register */ 82162306a36Sopenharmony_ci u32 ipgifg; /* 0x.508 - Inter Packet Gap/Inter Frame Gap Register */ 82262306a36Sopenharmony_ci u32 hafdup; /* 0x.50c - Half Duplex Register */ 82362306a36Sopenharmony_ci u32 maxfrm; /* 0x.510 - Maximum Frame Length Register */ 82462306a36Sopenharmony_ci u8 res18[12]; 82562306a36Sopenharmony_ci u8 gfar_mii_regs[24]; /* See gianfar_phy.h */ 82662306a36Sopenharmony_ci u32 ifctrl; /* 0x.538 - Interface control register */ 82762306a36Sopenharmony_ci u32 ifstat; /* 0x.53c - Interface Status Register */ 82862306a36Sopenharmony_ci u32 macstnaddr1; /* 0x.540 - Station Address Part 1 Register */ 82962306a36Sopenharmony_ci u32 macstnaddr2; /* 0x.544 - Station Address Part 2 Register */ 83062306a36Sopenharmony_ci u32 mac01addr1; /* 0x.548 - MAC exact match address 1, part 1 */ 83162306a36Sopenharmony_ci u32 mac01addr2; /* 0x.54c - MAC exact match address 1, part 2 */ 83262306a36Sopenharmony_ci u32 mac02addr1; /* 0x.550 - MAC exact match address 2, part 1 */ 83362306a36Sopenharmony_ci u32 mac02addr2; /* 0x.554 - MAC exact match address 2, part 2 */ 83462306a36Sopenharmony_ci u32 mac03addr1; /* 0x.558 - MAC exact match address 3, part 1 */ 83562306a36Sopenharmony_ci u32 mac03addr2; /* 0x.55c - MAC exact match address 3, part 2 */ 83662306a36Sopenharmony_ci u32 mac04addr1; /* 0x.560 - MAC exact match address 4, part 1 */ 83762306a36Sopenharmony_ci u32 mac04addr2; /* 0x.564 - MAC exact match address 4, part 2 */ 83862306a36Sopenharmony_ci u32 mac05addr1; /* 0x.568 - MAC exact match address 5, part 1 */ 83962306a36Sopenharmony_ci u32 mac05addr2; /* 0x.56c - MAC exact match address 5, part 2 */ 84062306a36Sopenharmony_ci u32 mac06addr1; /* 0x.570 - MAC exact match address 6, part 1 */ 84162306a36Sopenharmony_ci u32 mac06addr2; /* 0x.574 - MAC exact match address 6, part 2 */ 84262306a36Sopenharmony_ci u32 mac07addr1; /* 0x.578 - MAC exact match address 7, part 1 */ 84362306a36Sopenharmony_ci u32 mac07addr2; /* 0x.57c - MAC exact match address 7, part 2 */ 84462306a36Sopenharmony_ci u32 mac08addr1; /* 0x.580 - MAC exact match address 8, part 1 */ 84562306a36Sopenharmony_ci u32 mac08addr2; /* 0x.584 - MAC exact match address 8, part 2 */ 84662306a36Sopenharmony_ci u32 mac09addr1; /* 0x.588 - MAC exact match address 9, part 1 */ 84762306a36Sopenharmony_ci u32 mac09addr2; /* 0x.58c - MAC exact match address 9, part 2 */ 84862306a36Sopenharmony_ci u32 mac10addr1; /* 0x.590 - MAC exact match address 10, part 1*/ 84962306a36Sopenharmony_ci u32 mac10addr2; /* 0x.594 - MAC exact match address 10, part 2*/ 85062306a36Sopenharmony_ci u32 mac11addr1; /* 0x.598 - MAC exact match address 11, part 1*/ 85162306a36Sopenharmony_ci u32 mac11addr2; /* 0x.59c - MAC exact match address 11, part 2*/ 85262306a36Sopenharmony_ci u32 mac12addr1; /* 0x.5a0 - MAC exact match address 12, part 1*/ 85362306a36Sopenharmony_ci u32 mac12addr2; /* 0x.5a4 - MAC exact match address 12, part 2*/ 85462306a36Sopenharmony_ci u32 mac13addr1; /* 0x.5a8 - MAC exact match address 13, part 1*/ 85562306a36Sopenharmony_ci u32 mac13addr2; /* 0x.5ac - MAC exact match address 13, part 2*/ 85662306a36Sopenharmony_ci u32 mac14addr1; /* 0x.5b0 - MAC exact match address 14, part 1*/ 85762306a36Sopenharmony_ci u32 mac14addr2; /* 0x.5b4 - MAC exact match address 14, part 2*/ 85862306a36Sopenharmony_ci u32 mac15addr1; /* 0x.5b8 - MAC exact match address 15, part 1*/ 85962306a36Sopenharmony_ci u32 mac15addr2; /* 0x.5bc - MAC exact match address 15, part 2*/ 86062306a36Sopenharmony_ci u8 res20[192]; 86162306a36Sopenharmony_ci struct rmon_mib rmon; /* 0x.680-0x.73c */ 86262306a36Sopenharmony_ci u32 rrej; /* 0x.740 - Receive filer rejected packet counter */ 86362306a36Sopenharmony_ci u8 res21[188]; 86462306a36Sopenharmony_ci u32 igaddr0; /* 0x.800 - Indivdual/Group address register 0*/ 86562306a36Sopenharmony_ci u32 igaddr1; /* 0x.804 - Indivdual/Group address register 1*/ 86662306a36Sopenharmony_ci u32 igaddr2; /* 0x.808 - Indivdual/Group address register 2*/ 86762306a36Sopenharmony_ci u32 igaddr3; /* 0x.80c - Indivdual/Group address register 3*/ 86862306a36Sopenharmony_ci u32 igaddr4; /* 0x.810 - Indivdual/Group address register 4*/ 86962306a36Sopenharmony_ci u32 igaddr5; /* 0x.814 - Indivdual/Group address register 5*/ 87062306a36Sopenharmony_ci u32 igaddr6; /* 0x.818 - Indivdual/Group address register 6*/ 87162306a36Sopenharmony_ci u32 igaddr7; /* 0x.81c - Indivdual/Group address register 7*/ 87262306a36Sopenharmony_ci u8 res22[96]; 87362306a36Sopenharmony_ci u32 gaddr0; /* 0x.880 - Group address register 0 */ 87462306a36Sopenharmony_ci u32 gaddr1; /* 0x.884 - Group address register 1 */ 87562306a36Sopenharmony_ci u32 gaddr2; /* 0x.888 - Group address register 2 */ 87662306a36Sopenharmony_ci u32 gaddr3; /* 0x.88c - Group address register 3 */ 87762306a36Sopenharmony_ci u32 gaddr4; /* 0x.890 - Group address register 4 */ 87862306a36Sopenharmony_ci u32 gaddr5; /* 0x.894 - Group address register 5 */ 87962306a36Sopenharmony_ci u32 gaddr6; /* 0x.898 - Group address register 6 */ 88062306a36Sopenharmony_ci u32 gaddr7; /* 0x.89c - Group address register 7 */ 88162306a36Sopenharmony_ci u8 res23a[352]; 88262306a36Sopenharmony_ci u32 fifocfg; /* 0x.a00 - FIFO interface config register */ 88362306a36Sopenharmony_ci u8 res23b[252]; 88462306a36Sopenharmony_ci u8 res23c[248]; 88562306a36Sopenharmony_ci u32 attr; /* 0x.bf8 - Attributes Register */ 88662306a36Sopenharmony_ci u32 attreli; /* 0x.bfc - Attributes Extract Length and Extract Index Register */ 88762306a36Sopenharmony_ci u32 rqprm0; /* 0x.c00 - Receive queue parameters register 0 */ 88862306a36Sopenharmony_ci u32 rqprm1; /* 0x.c04 - Receive queue parameters register 1 */ 88962306a36Sopenharmony_ci u32 rqprm2; /* 0x.c08 - Receive queue parameters register 2 */ 89062306a36Sopenharmony_ci u32 rqprm3; /* 0x.c0c - Receive queue parameters register 3 */ 89162306a36Sopenharmony_ci u32 rqprm4; /* 0x.c10 - Receive queue parameters register 4 */ 89262306a36Sopenharmony_ci u32 rqprm5; /* 0x.c14 - Receive queue parameters register 5 */ 89362306a36Sopenharmony_ci u32 rqprm6; /* 0x.c18 - Receive queue parameters register 6 */ 89462306a36Sopenharmony_ci u32 rqprm7; /* 0x.c1c - Receive queue parameters register 7 */ 89562306a36Sopenharmony_ci u8 res24[36]; 89662306a36Sopenharmony_ci u32 rfbptr0; /* 0x.c44 - Last free RxBD pointer for ring 0 */ 89762306a36Sopenharmony_ci u8 res24a[4]; 89862306a36Sopenharmony_ci u32 rfbptr1; /* 0x.c4c - Last free RxBD pointer for ring 1 */ 89962306a36Sopenharmony_ci u8 res24b[4]; 90062306a36Sopenharmony_ci u32 rfbptr2; /* 0x.c54 - Last free RxBD pointer for ring 2 */ 90162306a36Sopenharmony_ci u8 res24c[4]; 90262306a36Sopenharmony_ci u32 rfbptr3; /* 0x.c5c - Last free RxBD pointer for ring 3 */ 90362306a36Sopenharmony_ci u8 res24d[4]; 90462306a36Sopenharmony_ci u32 rfbptr4; /* 0x.c64 - Last free RxBD pointer for ring 4 */ 90562306a36Sopenharmony_ci u8 res24e[4]; 90662306a36Sopenharmony_ci u32 rfbptr5; /* 0x.c6c - Last free RxBD pointer for ring 5 */ 90762306a36Sopenharmony_ci u8 res24f[4]; 90862306a36Sopenharmony_ci u32 rfbptr6; /* 0x.c74 - Last free RxBD pointer for ring 6 */ 90962306a36Sopenharmony_ci u8 res24g[4]; 91062306a36Sopenharmony_ci u32 rfbptr7; /* 0x.c7c - Last free RxBD pointer for ring 7 */ 91162306a36Sopenharmony_ci u8 res24h[4]; 91262306a36Sopenharmony_ci u8 res24x[556]; 91362306a36Sopenharmony_ci u32 isrg0; /* 0x.eb0 - Interrupt steering group 0 register */ 91462306a36Sopenharmony_ci u32 isrg1; /* 0x.eb4 - Interrupt steering group 1 register */ 91562306a36Sopenharmony_ci u32 isrg2; /* 0x.eb8 - Interrupt steering group 2 register */ 91662306a36Sopenharmony_ci u32 isrg3; /* 0x.ebc - Interrupt steering group 3 register */ 91762306a36Sopenharmony_ci u8 res25[16]; 91862306a36Sopenharmony_ci u32 rxic0; /* 0x.ed0 - Ring 0 Rx interrupt coalescing */ 91962306a36Sopenharmony_ci u32 rxic1; /* 0x.ed4 - Ring 1 Rx interrupt coalescing */ 92062306a36Sopenharmony_ci u32 rxic2; /* 0x.ed8 - Ring 2 Rx interrupt coalescing */ 92162306a36Sopenharmony_ci u32 rxic3; /* 0x.edc - Ring 3 Rx interrupt coalescing */ 92262306a36Sopenharmony_ci u32 rxic4; /* 0x.ee0 - Ring 4 Rx interrupt coalescing */ 92362306a36Sopenharmony_ci u32 rxic5; /* 0x.ee4 - Ring 5 Rx interrupt coalescing */ 92462306a36Sopenharmony_ci u32 rxic6; /* 0x.ee8 - Ring 6 Rx interrupt coalescing */ 92562306a36Sopenharmony_ci u32 rxic7; /* 0x.eec - Ring 7 Rx interrupt coalescing */ 92662306a36Sopenharmony_ci u8 res26[32]; 92762306a36Sopenharmony_ci u32 txic0; /* 0x.f10 - Ring 0 Tx interrupt coalescing */ 92862306a36Sopenharmony_ci u32 txic1; /* 0x.f14 - Ring 1 Tx interrupt coalescing */ 92962306a36Sopenharmony_ci u32 txic2; /* 0x.f18 - Ring 2 Tx interrupt coalescing */ 93062306a36Sopenharmony_ci u32 txic3; /* 0x.f1c - Ring 3 Tx interrupt coalescing */ 93162306a36Sopenharmony_ci u32 txic4; /* 0x.f20 - Ring 4 Tx interrupt coalescing */ 93262306a36Sopenharmony_ci u32 txic5; /* 0x.f24 - Ring 5 Tx interrupt coalescing */ 93362306a36Sopenharmony_ci u32 txic6; /* 0x.f28 - Ring 6 Tx interrupt coalescing */ 93462306a36Sopenharmony_ci u32 txic7; /* 0x.f2c - Ring 7 Tx interrupt coalescing */ 93562306a36Sopenharmony_ci u8 res27[208]; 93662306a36Sopenharmony_ci}; 93762306a36Sopenharmony_ci 93862306a36Sopenharmony_ci/* Flags related to gianfar device features */ 93962306a36Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_GIGABIT 0x00000001 94062306a36Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_COALESCE 0x00000002 94162306a36Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_RMON 0x00000004 94262306a36Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_MULTI_INTR 0x00000008 94362306a36Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_CSUM 0x00000010 94462306a36Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_VLAN 0x00000020 94562306a36Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_EXTENDED_HASH 0x00000040 94662306a36Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_MAGIC_PACKET 0x00000100 94762306a36Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_BD_STASHING 0x00000200 94862306a36Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_BUF_STASHING 0x00000400 94962306a36Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_TIMER 0x00000800 95062306a36Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_WAKE_ON_FILER 0x00001000 95162306a36Sopenharmony_ci#define FSL_GIANFAR_DEV_HAS_RX_FILER 0x00002000 95262306a36Sopenharmony_ci 95362306a36Sopenharmony_ci#if (MAXGROUPS == 2) 95462306a36Sopenharmony_ci#define DEFAULT_MAPPING 0xAA 95562306a36Sopenharmony_ci#else 95662306a36Sopenharmony_ci#define DEFAULT_MAPPING 0xFF 95762306a36Sopenharmony_ci#endif 95862306a36Sopenharmony_ci 95962306a36Sopenharmony_ci#define ISRG_RR0 0x80000000 96062306a36Sopenharmony_ci#define ISRG_TR0 0x00800000 96162306a36Sopenharmony_ci 96262306a36Sopenharmony_ci/* The same driver can operate in two modes */ 96362306a36Sopenharmony_ci/* SQ_SG_MODE: Single Queue Single Group Mode 96462306a36Sopenharmony_ci * (Backward compatible mode) 96562306a36Sopenharmony_ci * MQ_MG_MODE: Multi Queue Multi Group mode 96662306a36Sopenharmony_ci */ 96762306a36Sopenharmony_cienum { 96862306a36Sopenharmony_ci SQ_SG_MODE = 0, 96962306a36Sopenharmony_ci MQ_MG_MODE 97062306a36Sopenharmony_ci}; 97162306a36Sopenharmony_ci 97262306a36Sopenharmony_ci/* 97362306a36Sopenharmony_ci * Per TX queue stats 97462306a36Sopenharmony_ci */ 97562306a36Sopenharmony_cistruct tx_q_stats { 97662306a36Sopenharmony_ci u64 tx_packets; 97762306a36Sopenharmony_ci u64 tx_bytes; 97862306a36Sopenharmony_ci}; 97962306a36Sopenharmony_ci 98062306a36Sopenharmony_ci/** 98162306a36Sopenharmony_ci * struct gfar_priv_tx_q - per tx queue structure 98262306a36Sopenharmony_ci * @txlock: per queue tx spin lock 98362306a36Sopenharmony_ci * @tx_skbuff:skb pointers 98462306a36Sopenharmony_ci * @skb_curtx: to be used skb pointer 98562306a36Sopenharmony_ci * @skb_dirtytx:the last used skb pointer 98662306a36Sopenharmony_ci * @stats: bytes/packets stats 98762306a36Sopenharmony_ci * @qindex: index of this queue 98862306a36Sopenharmony_ci * @dev: back pointer to the dev structure 98962306a36Sopenharmony_ci * @grp: back pointer to the group to which this queue belongs 99062306a36Sopenharmony_ci * @tx_bd_base: First tx buffer descriptor 99162306a36Sopenharmony_ci * @cur_tx: Next free ring entry 99262306a36Sopenharmony_ci * @dirty_tx: First buffer in line to be transmitted 99362306a36Sopenharmony_ci * @tx_ring_size: Tx ring size 99462306a36Sopenharmony_ci * @num_txbdfree: number of free TxBds 99562306a36Sopenharmony_ci * @txcoalescing: enable/disable tx coalescing 99662306a36Sopenharmony_ci * @txic: transmit interrupt coalescing value 99762306a36Sopenharmony_ci * @txcount: coalescing value if based on tx frame count 99862306a36Sopenharmony_ci * @txtime: coalescing value if based on time 99962306a36Sopenharmony_ci */ 100062306a36Sopenharmony_cistruct gfar_priv_tx_q { 100162306a36Sopenharmony_ci /* cacheline 1 */ 100262306a36Sopenharmony_ci spinlock_t txlock __attribute__ ((aligned (SMP_CACHE_BYTES))); 100362306a36Sopenharmony_ci struct txbd8 *tx_bd_base; 100462306a36Sopenharmony_ci struct txbd8 *cur_tx; 100562306a36Sopenharmony_ci unsigned int num_txbdfree; 100662306a36Sopenharmony_ci unsigned short skb_curtx; 100762306a36Sopenharmony_ci unsigned short tx_ring_size; 100862306a36Sopenharmony_ci struct tx_q_stats stats; 100962306a36Sopenharmony_ci struct gfar_priv_grp *grp; 101062306a36Sopenharmony_ci /* cacheline 2 */ 101162306a36Sopenharmony_ci struct net_device *dev; 101262306a36Sopenharmony_ci struct sk_buff **tx_skbuff; 101362306a36Sopenharmony_ci struct txbd8 *dirty_tx; 101462306a36Sopenharmony_ci unsigned short skb_dirtytx; 101562306a36Sopenharmony_ci unsigned short qindex; 101662306a36Sopenharmony_ci /* Configuration info for the coalescing features */ 101762306a36Sopenharmony_ci unsigned int txcoalescing; 101862306a36Sopenharmony_ci unsigned long txic; 101962306a36Sopenharmony_ci dma_addr_t tx_bd_dma_base; 102062306a36Sopenharmony_ci}; 102162306a36Sopenharmony_ci 102262306a36Sopenharmony_ci/* 102362306a36Sopenharmony_ci * Per RX queue stats 102462306a36Sopenharmony_ci */ 102562306a36Sopenharmony_cistruct rx_q_stats { 102662306a36Sopenharmony_ci u64 rx_packets; 102762306a36Sopenharmony_ci u64 rx_bytes; 102862306a36Sopenharmony_ci u64 rx_dropped; 102962306a36Sopenharmony_ci}; 103062306a36Sopenharmony_ci 103162306a36Sopenharmony_cistruct gfar_rx_buff { 103262306a36Sopenharmony_ci dma_addr_t dma; 103362306a36Sopenharmony_ci struct page *page; 103462306a36Sopenharmony_ci unsigned int page_offset; 103562306a36Sopenharmony_ci}; 103662306a36Sopenharmony_ci 103762306a36Sopenharmony_ci/** 103862306a36Sopenharmony_ci * struct gfar_priv_rx_q - per rx queue structure 103962306a36Sopenharmony_ci * @rx_buff: Array of buffer info metadata structs 104062306a36Sopenharmony_ci * @rx_bd_base: First rx buffer descriptor 104162306a36Sopenharmony_ci * @next_to_use: index of the next buffer to be alloc'd 104262306a36Sopenharmony_ci * @next_to_clean: index of the next buffer to be cleaned 104362306a36Sopenharmony_ci * @qindex: index of this queue 104462306a36Sopenharmony_ci * @ndev: back pointer to net_device 104562306a36Sopenharmony_ci * @rx_ring_size: Rx ring size 104662306a36Sopenharmony_ci * @rxcoalescing: enable/disable rx-coalescing 104762306a36Sopenharmony_ci * @rxic: receive interrupt coalescing vlaue 104862306a36Sopenharmony_ci */ 104962306a36Sopenharmony_ci 105062306a36Sopenharmony_cistruct gfar_priv_rx_q { 105162306a36Sopenharmony_ci struct gfar_rx_buff *rx_buff __aligned(SMP_CACHE_BYTES); 105262306a36Sopenharmony_ci struct rxbd8 *rx_bd_base; 105362306a36Sopenharmony_ci struct net_device *ndev; 105462306a36Sopenharmony_ci struct device *dev; 105562306a36Sopenharmony_ci u16 rx_ring_size; 105662306a36Sopenharmony_ci u16 qindex; 105762306a36Sopenharmony_ci struct gfar_priv_grp *grp; 105862306a36Sopenharmony_ci u16 next_to_clean; 105962306a36Sopenharmony_ci u16 next_to_use; 106062306a36Sopenharmony_ci u16 next_to_alloc; 106162306a36Sopenharmony_ci struct sk_buff *skb; 106262306a36Sopenharmony_ci struct rx_q_stats stats; 106362306a36Sopenharmony_ci u32 __iomem *rfbptr; 106462306a36Sopenharmony_ci unsigned char rxcoalescing; 106562306a36Sopenharmony_ci unsigned long rxic; 106662306a36Sopenharmony_ci dma_addr_t rx_bd_dma_base; 106762306a36Sopenharmony_ci}; 106862306a36Sopenharmony_ci 106962306a36Sopenharmony_cienum gfar_irqinfo_id { 107062306a36Sopenharmony_ci GFAR_TX = 0, 107162306a36Sopenharmony_ci GFAR_RX = 1, 107262306a36Sopenharmony_ci GFAR_ER = 2, 107362306a36Sopenharmony_ci GFAR_NUM_IRQS = 3 107462306a36Sopenharmony_ci}; 107562306a36Sopenharmony_ci 107662306a36Sopenharmony_cistruct gfar_irqinfo { 107762306a36Sopenharmony_ci unsigned int irq; 107862306a36Sopenharmony_ci char name[GFAR_INT_NAME_MAX]; 107962306a36Sopenharmony_ci}; 108062306a36Sopenharmony_ci 108162306a36Sopenharmony_ci/** 108262306a36Sopenharmony_ci * struct gfar_priv_grp - per group structure 108362306a36Sopenharmony_ci * @napi: the napi poll function 108462306a36Sopenharmony_ci * @priv: back pointer to the priv structure 108562306a36Sopenharmony_ci * @regs: the ioremapped register space for this group 108662306a36Sopenharmony_ci * @irqinfo: TX/RX/ER irq data for this group 108762306a36Sopenharmony_ci */ 108862306a36Sopenharmony_ci 108962306a36Sopenharmony_cistruct gfar_priv_grp { 109062306a36Sopenharmony_ci spinlock_t grplock __aligned(SMP_CACHE_BYTES); 109162306a36Sopenharmony_ci struct napi_struct napi_rx; 109262306a36Sopenharmony_ci struct napi_struct napi_tx; 109362306a36Sopenharmony_ci struct gfar __iomem *regs; 109462306a36Sopenharmony_ci struct gfar_priv_tx_q *tx_queue; 109562306a36Sopenharmony_ci struct gfar_priv_rx_q *rx_queue; 109662306a36Sopenharmony_ci unsigned int tstat; 109762306a36Sopenharmony_ci unsigned int rstat; 109862306a36Sopenharmony_ci 109962306a36Sopenharmony_ci struct gfar_private *priv; 110062306a36Sopenharmony_ci unsigned long num_tx_queues; 110162306a36Sopenharmony_ci unsigned long tx_bit_map; 110262306a36Sopenharmony_ci unsigned long num_rx_queues; 110362306a36Sopenharmony_ci unsigned long rx_bit_map; 110462306a36Sopenharmony_ci 110562306a36Sopenharmony_ci struct gfar_irqinfo *irqinfo[GFAR_NUM_IRQS]; 110662306a36Sopenharmony_ci}; 110762306a36Sopenharmony_ci 110862306a36Sopenharmony_ci#define gfar_irq(grp, ID) \ 110962306a36Sopenharmony_ci ((grp)->irqinfo[GFAR_##ID]) 111062306a36Sopenharmony_ci 111162306a36Sopenharmony_cienum gfar_errata { 111262306a36Sopenharmony_ci GFAR_ERRATA_74 = 0x01, 111362306a36Sopenharmony_ci GFAR_ERRATA_76 = 0x02, 111462306a36Sopenharmony_ci GFAR_ERRATA_A002 = 0x04, 111562306a36Sopenharmony_ci GFAR_ERRATA_12 = 0x08, /* a.k.a errata eTSEC49 */ 111662306a36Sopenharmony_ci}; 111762306a36Sopenharmony_ci 111862306a36Sopenharmony_cienum gfar_dev_state { 111962306a36Sopenharmony_ci GFAR_DOWN = 1, 112062306a36Sopenharmony_ci GFAR_RESETTING 112162306a36Sopenharmony_ci}; 112262306a36Sopenharmony_ci 112362306a36Sopenharmony_ci/* Struct stolen almost completely (and shamelessly) from the FCC enet source 112462306a36Sopenharmony_ci * (Ok, that's not so true anymore, but there is a family resemblance) 112562306a36Sopenharmony_ci * The GFAR buffer descriptors track the ring buffers. The rx_bd_base 112662306a36Sopenharmony_ci * and tx_bd_base always point to the currently available buffer. 112762306a36Sopenharmony_ci * The dirty_tx tracks the current buffer that is being sent by the 112862306a36Sopenharmony_ci * controller. The cur_tx and dirty_tx are equal under both completely 112962306a36Sopenharmony_ci * empty and completely full conditions. The empty/ready indicator in 113062306a36Sopenharmony_ci * the buffer descriptor determines the actual condition. 113162306a36Sopenharmony_ci */ 113262306a36Sopenharmony_cistruct gfar_private { 113362306a36Sopenharmony_ci struct device *dev; 113462306a36Sopenharmony_ci struct net_device *ndev; 113562306a36Sopenharmony_ci enum gfar_errata errata; 113662306a36Sopenharmony_ci 113762306a36Sopenharmony_ci u16 uses_rxfcb; 113862306a36Sopenharmony_ci u16 padding; 113962306a36Sopenharmony_ci u32 device_flags; 114062306a36Sopenharmony_ci 114162306a36Sopenharmony_ci /* HW time stamping enabled flag */ 114262306a36Sopenharmony_ci int hwts_rx_en; 114362306a36Sopenharmony_ci int hwts_tx_en; 114462306a36Sopenharmony_ci 114562306a36Sopenharmony_ci struct gfar_priv_tx_q *tx_queue[MAX_TX_QS]; 114662306a36Sopenharmony_ci struct gfar_priv_rx_q *rx_queue[MAX_RX_QS]; 114762306a36Sopenharmony_ci struct gfar_priv_grp gfargrp[MAXGROUPS]; 114862306a36Sopenharmony_ci 114962306a36Sopenharmony_ci unsigned long state; 115062306a36Sopenharmony_ci 115162306a36Sopenharmony_ci unsigned short mode; 115262306a36Sopenharmony_ci unsigned int num_tx_queues; 115362306a36Sopenharmony_ci unsigned int num_rx_queues; 115462306a36Sopenharmony_ci unsigned int num_grps; 115562306a36Sopenharmony_ci int tx_actual_en; 115662306a36Sopenharmony_ci 115762306a36Sopenharmony_ci /* Network Statistics */ 115862306a36Sopenharmony_ci struct gfar_extra_stats extra_stats; 115962306a36Sopenharmony_ci struct rmon_overflow rmon_overflow; 116062306a36Sopenharmony_ci 116162306a36Sopenharmony_ci /* PHY stuff */ 116262306a36Sopenharmony_ci phy_interface_t interface; 116362306a36Sopenharmony_ci struct device_node *phy_node; 116462306a36Sopenharmony_ci struct device_node *tbi_node; 116562306a36Sopenharmony_ci struct mii_bus *mii_bus; 116662306a36Sopenharmony_ci int oldspeed; 116762306a36Sopenharmony_ci int oldduplex; 116862306a36Sopenharmony_ci int oldlink; 116962306a36Sopenharmony_ci 117062306a36Sopenharmony_ci uint32_t msg_enable; 117162306a36Sopenharmony_ci 117262306a36Sopenharmony_ci struct work_struct reset_task; 117362306a36Sopenharmony_ci 117462306a36Sopenharmony_ci struct platform_device *ofdev; 117562306a36Sopenharmony_ci unsigned char 117662306a36Sopenharmony_ci extended_hash:1, 117762306a36Sopenharmony_ci bd_stash_en:1, 117862306a36Sopenharmony_ci rx_filer_enable:1, 117962306a36Sopenharmony_ci /* Enable priorty based Tx scheduling in Hw */ 118062306a36Sopenharmony_ci prio_sched_en:1, 118162306a36Sopenharmony_ci /* Flow control flags */ 118262306a36Sopenharmony_ci pause_aneg_en:1, 118362306a36Sopenharmony_ci tx_pause_en:1, 118462306a36Sopenharmony_ci rx_pause_en:1; 118562306a36Sopenharmony_ci 118662306a36Sopenharmony_ci /* The total tx and rx ring size for the enabled queues */ 118762306a36Sopenharmony_ci unsigned int total_tx_ring_size; 118862306a36Sopenharmony_ci unsigned int total_rx_ring_size; 118962306a36Sopenharmony_ci 119062306a36Sopenharmony_ci u32 rqueue; 119162306a36Sopenharmony_ci u32 tqueue; 119262306a36Sopenharmony_ci 119362306a36Sopenharmony_ci /* RX per device parameters */ 119462306a36Sopenharmony_ci unsigned int rx_stash_size; 119562306a36Sopenharmony_ci unsigned int rx_stash_index; 119662306a36Sopenharmony_ci 119762306a36Sopenharmony_ci u32 cur_filer_idx; 119862306a36Sopenharmony_ci 119962306a36Sopenharmony_ci /* RX queue filer rule set*/ 120062306a36Sopenharmony_ci struct ethtool_rx_list rx_list; 120162306a36Sopenharmony_ci struct mutex rx_queue_access; 120262306a36Sopenharmony_ci 120362306a36Sopenharmony_ci /* Hash registers and their width */ 120462306a36Sopenharmony_ci u32 __iomem *hash_regs[16]; 120562306a36Sopenharmony_ci int hash_width; 120662306a36Sopenharmony_ci 120762306a36Sopenharmony_ci /* wake-on-lan settings */ 120862306a36Sopenharmony_ci u16 wol_opts; 120962306a36Sopenharmony_ci u16 wol_supported; 121062306a36Sopenharmony_ci 121162306a36Sopenharmony_ci /*Filer table*/ 121262306a36Sopenharmony_ci unsigned int ftp_rqfpr[MAX_FILER_IDX + 1]; 121362306a36Sopenharmony_ci unsigned int ftp_rqfcr[MAX_FILER_IDX + 1]; 121462306a36Sopenharmony_ci}; 121562306a36Sopenharmony_ci 121662306a36Sopenharmony_ci 121762306a36Sopenharmony_cistatic inline int gfar_has_errata(struct gfar_private *priv, 121862306a36Sopenharmony_ci enum gfar_errata err) 121962306a36Sopenharmony_ci{ 122062306a36Sopenharmony_ci return priv->errata & err; 122162306a36Sopenharmony_ci} 122262306a36Sopenharmony_ci 122362306a36Sopenharmony_cistatic inline u32 gfar_read(unsigned __iomem *addr) 122462306a36Sopenharmony_ci{ 122562306a36Sopenharmony_ci u32 val; 122662306a36Sopenharmony_ci val = ioread32be(addr); 122762306a36Sopenharmony_ci return val; 122862306a36Sopenharmony_ci} 122962306a36Sopenharmony_ci 123062306a36Sopenharmony_cistatic inline void gfar_write(unsigned __iomem *addr, u32 val) 123162306a36Sopenharmony_ci{ 123262306a36Sopenharmony_ci iowrite32be(val, addr); 123362306a36Sopenharmony_ci} 123462306a36Sopenharmony_ci 123562306a36Sopenharmony_cistatic inline void gfar_write_filer(struct gfar_private *priv, 123662306a36Sopenharmony_ci unsigned int far, unsigned int fcr, unsigned int fpr) 123762306a36Sopenharmony_ci{ 123862306a36Sopenharmony_ci struct gfar __iomem *regs = priv->gfargrp[0].regs; 123962306a36Sopenharmony_ci 124062306a36Sopenharmony_ci gfar_write(®s->rqfar, far); 124162306a36Sopenharmony_ci gfar_write(®s->rqfcr, fcr); 124262306a36Sopenharmony_ci gfar_write(®s->rqfpr, fpr); 124362306a36Sopenharmony_ci} 124462306a36Sopenharmony_ci 124562306a36Sopenharmony_cistatic inline void gfar_read_filer(struct gfar_private *priv, 124662306a36Sopenharmony_ci unsigned int far, unsigned int *fcr, unsigned int *fpr) 124762306a36Sopenharmony_ci{ 124862306a36Sopenharmony_ci struct gfar __iomem *regs = priv->gfargrp[0].regs; 124962306a36Sopenharmony_ci 125062306a36Sopenharmony_ci gfar_write(®s->rqfar, far); 125162306a36Sopenharmony_ci *fcr = gfar_read(®s->rqfcr); 125262306a36Sopenharmony_ci *fpr = gfar_read(®s->rqfpr); 125362306a36Sopenharmony_ci} 125462306a36Sopenharmony_ci 125562306a36Sopenharmony_cistatic inline void gfar_write_isrg(struct gfar_private *priv) 125662306a36Sopenharmony_ci{ 125762306a36Sopenharmony_ci struct gfar __iomem *regs = priv->gfargrp[0].regs; 125862306a36Sopenharmony_ci u32 __iomem *baddr = ®s->isrg0; 125962306a36Sopenharmony_ci u32 isrg = 0; 126062306a36Sopenharmony_ci int grp_idx, i; 126162306a36Sopenharmony_ci 126262306a36Sopenharmony_ci for (grp_idx = 0; grp_idx < priv->num_grps; grp_idx++) { 126362306a36Sopenharmony_ci struct gfar_priv_grp *grp = &priv->gfargrp[grp_idx]; 126462306a36Sopenharmony_ci 126562306a36Sopenharmony_ci for_each_set_bit(i, &grp->rx_bit_map, priv->num_rx_queues) { 126662306a36Sopenharmony_ci isrg |= (ISRG_RR0 >> i); 126762306a36Sopenharmony_ci } 126862306a36Sopenharmony_ci 126962306a36Sopenharmony_ci for_each_set_bit(i, &grp->tx_bit_map, priv->num_tx_queues) { 127062306a36Sopenharmony_ci isrg |= (ISRG_TR0 >> i); 127162306a36Sopenharmony_ci } 127262306a36Sopenharmony_ci 127362306a36Sopenharmony_ci gfar_write(baddr, isrg); 127462306a36Sopenharmony_ci 127562306a36Sopenharmony_ci baddr++; 127662306a36Sopenharmony_ci isrg = 0; 127762306a36Sopenharmony_ci } 127862306a36Sopenharmony_ci} 127962306a36Sopenharmony_ci 128062306a36Sopenharmony_cistatic inline int gfar_is_dma_stopped(struct gfar_private *priv) 128162306a36Sopenharmony_ci{ 128262306a36Sopenharmony_ci struct gfar __iomem *regs = priv->gfargrp[0].regs; 128362306a36Sopenharmony_ci 128462306a36Sopenharmony_ci return ((gfar_read(®s->ievent) & (IEVENT_GRSC | IEVENT_GTSC)) == 128562306a36Sopenharmony_ci (IEVENT_GRSC | IEVENT_GTSC)); 128662306a36Sopenharmony_ci} 128762306a36Sopenharmony_ci 128862306a36Sopenharmony_cistatic inline int gfar_is_rx_dma_stopped(struct gfar_private *priv) 128962306a36Sopenharmony_ci{ 129062306a36Sopenharmony_ci struct gfar __iomem *regs = priv->gfargrp[0].regs; 129162306a36Sopenharmony_ci 129262306a36Sopenharmony_ci return gfar_read(®s->ievent) & IEVENT_GRSC; 129362306a36Sopenharmony_ci} 129462306a36Sopenharmony_ci 129562306a36Sopenharmony_cistatic inline void gfar_wmb(void) 129662306a36Sopenharmony_ci{ 129762306a36Sopenharmony_ci#if defined(CONFIG_PPC) 129862306a36Sopenharmony_ci /* The powerpc-specific eieio() is used, as wmb() has too strong 129962306a36Sopenharmony_ci * semantics (it requires synchronization between cacheable and 130062306a36Sopenharmony_ci * uncacheable mappings, which eieio() doesn't provide and which we 130162306a36Sopenharmony_ci * don't need), thus requiring a more expensive sync instruction. At 130262306a36Sopenharmony_ci * some point, the set of architecture-independent barrier functions 130362306a36Sopenharmony_ci * should be expanded to include weaker barriers. 130462306a36Sopenharmony_ci */ 130562306a36Sopenharmony_ci eieio(); 130662306a36Sopenharmony_ci#else 130762306a36Sopenharmony_ci wmb(); /* order write acesses for BD (or FCB) fields */ 130862306a36Sopenharmony_ci#endif 130962306a36Sopenharmony_ci} 131062306a36Sopenharmony_ci 131162306a36Sopenharmony_cistatic inline void gfar_clear_txbd_status(struct txbd8 *bdp) 131262306a36Sopenharmony_ci{ 131362306a36Sopenharmony_ci u32 lstatus = be32_to_cpu(bdp->lstatus); 131462306a36Sopenharmony_ci 131562306a36Sopenharmony_ci lstatus &= BD_LFLAG(TXBD_WRAP); 131662306a36Sopenharmony_ci bdp->lstatus = cpu_to_be32(lstatus); 131762306a36Sopenharmony_ci} 131862306a36Sopenharmony_ci 131962306a36Sopenharmony_cistatic inline int gfar_rxbd_unused(struct gfar_priv_rx_q *rxq) 132062306a36Sopenharmony_ci{ 132162306a36Sopenharmony_ci if (rxq->next_to_clean > rxq->next_to_use) 132262306a36Sopenharmony_ci return rxq->next_to_clean - rxq->next_to_use - 1; 132362306a36Sopenharmony_ci 132462306a36Sopenharmony_ci return rxq->rx_ring_size + rxq->next_to_clean - rxq->next_to_use - 1; 132562306a36Sopenharmony_ci} 132662306a36Sopenharmony_ci 132762306a36Sopenharmony_cistatic inline u32 gfar_rxbd_dma_lastfree(struct gfar_priv_rx_q *rxq) 132862306a36Sopenharmony_ci{ 132962306a36Sopenharmony_ci struct rxbd8 *bdp; 133062306a36Sopenharmony_ci u32 bdp_dma; 133162306a36Sopenharmony_ci int i; 133262306a36Sopenharmony_ci 133362306a36Sopenharmony_ci i = rxq->next_to_use ? rxq->next_to_use - 1 : rxq->rx_ring_size - 1; 133462306a36Sopenharmony_ci bdp = &rxq->rx_bd_base[i]; 133562306a36Sopenharmony_ci bdp_dma = lower_32_bits(rxq->rx_bd_dma_base); 133662306a36Sopenharmony_ci bdp_dma += (uintptr_t)bdp - (uintptr_t)rxq->rx_bd_base; 133762306a36Sopenharmony_ci 133862306a36Sopenharmony_ci return bdp_dma; 133962306a36Sopenharmony_ci} 134062306a36Sopenharmony_ci 134162306a36Sopenharmony_ciint startup_gfar(struct net_device *dev); 134262306a36Sopenharmony_civoid stop_gfar(struct net_device *dev); 134362306a36Sopenharmony_civoid gfar_mac_reset(struct gfar_private *priv); 134462306a36Sopenharmony_ciint gfar_set_features(struct net_device *dev, netdev_features_t features); 134562306a36Sopenharmony_ci 134662306a36Sopenharmony_ciextern const struct ethtool_ops gfar_ethtool_ops; 134762306a36Sopenharmony_ci 134862306a36Sopenharmony_ci#define MAX_FILER_CACHE_IDX (2*(MAX_FILER_IDX)) 134962306a36Sopenharmony_ci 135062306a36Sopenharmony_ci#define RQFCR_PID_PRI_MASK 0xFFFFFFF8 135162306a36Sopenharmony_ci#define RQFCR_PID_L4P_MASK 0xFFFFFF00 135262306a36Sopenharmony_ci#define RQFCR_PID_VID_MASK 0xFFFFF000 135362306a36Sopenharmony_ci#define RQFCR_PID_PORT_MASK 0xFFFF0000 135462306a36Sopenharmony_ci#define RQFCR_PID_MAC_MASK 0xFF000000 135562306a36Sopenharmony_ci 135662306a36Sopenharmony_ci/* Represents a receive filer table entry */ 135762306a36Sopenharmony_cistruct gfar_filer_entry { 135862306a36Sopenharmony_ci u32 ctrl; 135962306a36Sopenharmony_ci u32 prop; 136062306a36Sopenharmony_ci}; 136162306a36Sopenharmony_ci 136262306a36Sopenharmony_ci 136362306a36Sopenharmony_ci/* The 20 additional entries are a shadow for one extra element */ 136462306a36Sopenharmony_cistruct filer_table { 136562306a36Sopenharmony_ci u32 index; 136662306a36Sopenharmony_ci struct gfar_filer_entry fe[MAX_FILER_CACHE_IDX + 20]; 136762306a36Sopenharmony_ci}; 136862306a36Sopenharmony_ci 136962306a36Sopenharmony_ci#endif /* __GIANFAR_H */ 1370