1 #ifndef BCM63XX_ENET_H_
2 #define BCM63XX_ENET_H_
4 #include <linux/types.h>
6 #include <linux/mutex.h>
8 #include <linux/platform_device.h>
10 #include <bcm63xx_regs.h>
11 #include <bcm63xx_irq.h>
12 #include <bcm63xx_io.h>
14 /* default number of descriptor */
15 #define BCMENET_DEF_RX_DESC 64
16 #define BCMENET_DEF_TX_DESC 32
18 /* maximum burst len for dma (4 bytes unit) */
19 #define BCMENET_DMA_MAXBURST 16
21 /* tx transmit threshold (4 bytes unit), fifo is 256 bytes, the value
22 * must be low enough so that a DMA transfer of above burst length can
23 * not overflow the fifo */
24 #define BCMENET_TX_FIFO_TRESH 32
26 /* maximum rx/tx packet size */
27 #define BCMENET_MAX_RX_SIZE (ETH_FRAME_LEN + 4)
28 #define BCMENET_MAX_TX_SIZE (ETH_FRAME_LEN + 4)
31 * rx/tx dma descriptor
33 struct bcm_enet_desc
{
38 #define DMADESC_LENGTH_SHIFT 16
39 #define DMADESC_LENGTH_MASK (0xfff << DMADESC_LENGTH_SHIFT)
40 #define DMADESC_OWNER_MASK (1 << 15)
41 #define DMADESC_EOP_MASK (1 << 14)
42 #define DMADESC_SOP_MASK (1 << 13)
43 #define DMADESC_ESOP_MASK (DMADESC_EOP_MASK | DMADESC_SOP_MASK)
44 #define DMADESC_WRAP_MASK (1 << 12)
46 #define DMADESC_UNDER_MASK (1 << 9)
47 #define DMADESC_APPEND_CRC (1 << 8)
48 #define DMADESC_OVSIZE_MASK (1 << 4)
49 #define DMADESC_RXER_MASK (1 << 2)
50 #define DMADESC_CRC_MASK (1 << 1)
51 #define DMADESC_OV_MASK (1 << 0)
52 #define DMADESC_ERR_MASK (DMADESC_UNDER_MASK | \
53 DMADESC_OVSIZE_MASK | \
60 * MIB Counters register definitions
62 #define ETH_MIB_TX_GD_OCTETS 0
63 #define ETH_MIB_TX_GD_PKTS 1
64 #define ETH_MIB_TX_ALL_OCTETS 2
65 #define ETH_MIB_TX_ALL_PKTS 3
66 #define ETH_MIB_TX_BRDCAST 4
67 #define ETH_MIB_TX_MULT 5
68 #define ETH_MIB_TX_64 6
69 #define ETH_MIB_TX_65_127 7
70 #define ETH_MIB_TX_128_255 8
71 #define ETH_MIB_TX_256_511 9
72 #define ETH_MIB_TX_512_1023 10
73 #define ETH_MIB_TX_1024_MAX 11
74 #define ETH_MIB_TX_JAB 12
75 #define ETH_MIB_TX_OVR 13
76 #define ETH_MIB_TX_FRAG 14
77 #define ETH_MIB_TX_UNDERRUN 15
78 #define ETH_MIB_TX_COL 16
79 #define ETH_MIB_TX_1_COL 17
80 #define ETH_MIB_TX_M_COL 18
81 #define ETH_MIB_TX_EX_COL 19
82 #define ETH_MIB_TX_LATE 20
83 #define ETH_MIB_TX_DEF 21
84 #define ETH_MIB_TX_CRS 22
85 #define ETH_MIB_TX_PAUSE 23
87 #define ETH_MIB_RX_GD_OCTETS 32
88 #define ETH_MIB_RX_GD_PKTS 33
89 #define ETH_MIB_RX_ALL_OCTETS 34
90 #define ETH_MIB_RX_ALL_PKTS 35
91 #define ETH_MIB_RX_BRDCAST 36
92 #define ETH_MIB_RX_MULT 37
93 #define ETH_MIB_RX_64 38
94 #define ETH_MIB_RX_65_127 39
95 #define ETH_MIB_RX_128_255 40
96 #define ETH_MIB_RX_256_511 41
97 #define ETH_MIB_RX_512_1023 42
98 #define ETH_MIB_RX_1024_MAX 43
99 #define ETH_MIB_RX_JAB 44
100 #define ETH_MIB_RX_OVR 45
101 #define ETH_MIB_RX_FRAG 46
102 #define ETH_MIB_RX_DROP 47
103 #define ETH_MIB_RX_CRC_ALIGN 48
104 #define ETH_MIB_RX_UND 49
105 #define ETH_MIB_RX_CRC 50
106 #define ETH_MIB_RX_ALIGN 51
107 #define ETH_MIB_RX_SYM 52
108 #define ETH_MIB_RX_PAUSE 53
109 #define ETH_MIB_RX_CNTRL 54
112 struct bcm_enet_mib_counters
{
163 struct bcm_enet_priv
{
165 /* mac id (from platform device id) */
168 /* base remapped address of device */
171 /* mac irq, rx_dma irq, tx_dma irq */
176 /* hw view of rx & tx dma ring */
177 dma_addr_t rx_desc_dma
;
178 dma_addr_t tx_desc_dma
;
180 /* allocated size (in bytes) for rx & tx dma ring */
181 unsigned int rx_desc_alloc_size
;
182 unsigned int tx_desc_alloc_size
;
185 struct napi_struct napi
;
187 /* dma channel id for rx */
190 /* number of dma desc in rx ring */
193 /* cpu view of rx dma ring */
194 struct bcm_enet_desc
*rx_desc_cpu
;
196 /* current number of armed descriptor given to hardware for rx */
199 /* next rx descriptor to fetch from hardware */
202 /* next dirty rx descriptor to refill */
205 /* list of skb given to hw for rx */
206 struct sk_buff
**rx_skb
;
208 /* used when rx skb allocation failed, so we defer rx queue
210 struct timer_list rx_timeout
;
212 /* lock rx_timeout against rx normal operation */
216 /* dma channel id for tx */
219 /* number of dma desc in tx ring */
222 /* cpu view of rx dma ring */
223 struct bcm_enet_desc
*tx_desc_cpu
;
225 /* number of available descriptor for tx */
228 /* next tx descriptor avaiable */
231 /* next dirty tx descriptor to reclaim */
234 /* list of skb given to hw for tx */
235 struct sk_buff
**tx_skb
;
237 /* lock used by tx reclaim and xmit */
241 /* set if internal phy is ignored and external mii interface
243 int use_external_mii
;
245 /* set if a phy is connected, phy address must be known,
246 * probing is not possible */
250 /* set if connected phy has an associated irq */
251 int has_phy_interrupt
;
254 /* used when a phy is connected (phylib used) */
255 struct mii_bus mii_bus
;
256 struct phy_device
*phydev
;
261 /* used when no phy is connected */
263 int force_duplex_full
;
265 /* pause parameters */
271 struct net_device_stats stats
;
272 struct bcm_enet_mib_counters mib
;
274 /* after mib interrupt, mib registers update is done in this
276 struct work_struct mib_update_task
;
278 /* lock mib update between userspace request and workqueue */
279 struct mutex mib_update_lock
;
284 /* phy clock if internal phy is used */
287 /* network device reference */
288 struct net_device
*net_dev
;
290 /* platform device reference */
291 struct platform_device
*pdev
;
294 #endif /* ! BCM63XX_ENET_H_ */