[kernel] generic-2.6/2.6.30: gets rid of the length limitation on the name in the...
[openwrt.git] / target / linux / brcm63xx / files / drivers / net / bcm63xx_enet.h
1 #ifndef BCM63XX_ENET_H_
2 #define BCM63XX_ENET_H_
3
4 #include <linux/types.h>
5 #include <linux/mii.h>
6 #include <linux/mutex.h>
7 #include <linux/phy.h>
8 #include <linux/platform_device.h>
9
10 #include <bcm63xx_regs.h>
11 #include <bcm63xx_irq.h>
12 #include <bcm63xx_io.h>
13
14 /* default number of descriptor */
15 #define BCMENET_DEF_RX_DESC 64
16 #define BCMENET_DEF_TX_DESC 32
17
18 /* maximum burst len for dma (4 bytes unit) */
19 #define BCMENET_DMA_MAXBURST 16
20
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
25
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)
29
30 /*
31 * rx/tx dma descriptor
32 */
33 struct bcm_enet_desc {
34 u32 len_stat;
35 u32 address;
36 };
37
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)
45
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 | \
54 DMADESC_RXER_MASK | \
55 DMADESC_CRC_MASK | \
56 DMADESC_OV_MASK)
57
58
59 /*
60 * MIB Counters register definitions
61 */
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
86
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
110
111
112 struct bcm_enet_mib_counters {
113 u64 tx_gd_octets;
114 u32 tx_gd_pkts;
115 u32 tx_all_octets;
116 u32 tx_all_pkts;
117 u32 tx_brdcast;
118 u32 tx_mult;
119 u32 tx_64;
120 u32 tx_65_127;
121 u32 tx_128_255;
122 u32 tx_256_511;
123 u32 tx_512_1023;
124 u32 tx_1024_max;
125 u32 tx_jab;
126 u32 tx_ovr;
127 u32 tx_frag;
128 u32 tx_underrun;
129 u32 tx_col;
130 u32 tx_1_col;
131 u32 tx_m_col;
132 u32 tx_ex_col;
133 u32 tx_late;
134 u32 tx_def;
135 u32 tx_crs;
136 u32 tx_pause;
137 u64 rx_gd_octets;
138 u32 rx_gd_pkts;
139 u32 rx_all_octets;
140 u32 rx_all_pkts;
141 u32 rx_brdcast;
142 u32 rx_mult;
143 u32 rx_64;
144 u32 rx_65_127;
145 u32 rx_128_255;
146 u32 rx_256_511;
147 u32 rx_512_1023;
148 u32 rx_1024_max;
149 u32 rx_jab;
150 u32 rx_ovr;
151 u32 rx_frag;
152 u32 rx_drop;
153 u32 rx_crc_align;
154 u32 rx_und;
155 u32 rx_crc;
156 u32 rx_align;
157 u32 rx_sym;
158 u32 rx_pause;
159 u32 rx_cntrl;
160 };
161
162
163 struct bcm_enet_priv {
164
165 /* mac id (from platform device id) */
166 int mac_id;
167
168 /* base remapped address of device */
169 void __iomem *base;
170
171 /* mac irq, rx_dma irq, tx_dma irq */
172 int irq;
173 int irq_rx;
174 int irq_tx;
175
176 /* hw view of rx & tx dma ring */
177 dma_addr_t rx_desc_dma;
178 dma_addr_t tx_desc_dma;
179
180 /* allocated size (in bytes) for rx & tx dma ring */
181 unsigned int rx_desc_alloc_size;
182 unsigned int tx_desc_alloc_size;
183
184
185 struct napi_struct napi;
186
187 /* dma channel id for rx */
188 int rx_chan;
189
190 /* number of dma desc in rx ring */
191 int rx_ring_size;
192
193 /* cpu view of rx dma ring */
194 struct bcm_enet_desc *rx_desc_cpu;
195
196 /* current number of armed descriptor given to hardware for rx */
197 int rx_desc_count;
198
199 /* next rx descriptor to fetch from hardware */
200 int rx_curr_desc;
201
202 /* next dirty rx descriptor to refill */
203 int rx_dirty_desc;
204
205 /* list of skb given to hw for rx */
206 struct sk_buff **rx_skb;
207
208 /* used when rx skb allocation failed, so we defer rx queue
209 * refill */
210 struct timer_list rx_timeout;
211
212 /* lock rx_timeout against rx normal operation */
213 spinlock_t rx_lock;
214
215
216 /* dma channel id for tx */
217 int tx_chan;
218
219 /* number of dma desc in tx ring */
220 int tx_ring_size;
221
222 /* cpu view of rx dma ring */
223 struct bcm_enet_desc *tx_desc_cpu;
224
225 /* number of available descriptor for tx */
226 int tx_desc_count;
227
228 /* next tx descriptor avaiable */
229 int tx_curr_desc;
230
231 /* next dirty tx descriptor to reclaim */
232 int tx_dirty_desc;
233
234 /* list of skb given to hw for tx */
235 struct sk_buff **tx_skb;
236
237 /* lock used by tx reclaim and xmit */
238 spinlock_t tx_lock;
239
240
241 /* set if internal phy is ignored and external mii interface
242 * is selected */
243 int use_external_mii;
244
245 /* set if a phy is connected, phy address must be known,
246 * probing is not possible */
247 int has_phy;
248 int phy_id;
249
250 /* set if connected phy has an associated irq */
251 int has_phy_interrupt;
252 int phy_interrupt;
253
254 /* used when a phy is connected (phylib used) */
255 struct mii_bus mii_bus;
256 struct phy_device *phydev;
257 int old_link;
258 int old_duplex;
259 int old_pause;
260
261 /* used when no phy is connected */
262 int force_speed_100;
263 int force_duplex_full;
264
265 /* pause parameters */
266 int pause_auto;
267 int pause_rx;
268 int pause_tx;
269
270 /* stats */
271 struct net_device_stats stats;
272 struct bcm_enet_mib_counters mib;
273
274 /* after mib interrupt, mib registers update is done in this
275 * work queue */
276 struct work_struct mib_update_task;
277
278 /* lock mib update between userspace request and workqueue */
279 struct mutex mib_update_lock;
280
281 /* mac clock */
282 struct clk *mac_clk;
283
284 /* phy clock if internal phy is used */
285 struct clk *phy_clk;
286
287 /* network device reference */
288 struct net_device *net_dev;
289
290 /* platform device reference */
291 struct platform_device *pdev;
292 };
293
294 #endif /* ! BCM63XX_ENET_H_ */
This page took 0.083031 seconds and 5 git commands to generate.