diff options
author | David S. Miller <davem@davemloft.net> | 2009-09-24 18:13:11 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-09-24 18:13:11 -0400 |
commit | 8b3f6af86378d0a10ca2f1ded1da124aef13b62c (patch) | |
tree | de6ca90295730343c495be8d98be8efa322140ef /drivers/net | |
parent | 139d6065c83071d5f66cd013a274a43699f8e2c1 (diff) | |
parent | 94e0fb086fc5663c38bbc0fe86d698be8314f82f (diff) |
Merge branch 'master' of /home/davem/src/GIT/linux-2.6/
Conflicts:
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/cpc-usb/TODO
drivers/staging/cpc-usb/cpc-usb_drv.c
drivers/staging/cpc-usb/cpc.h
drivers/staging/cpc-usb/cpc_int.h
drivers/staging/cpc-usb/cpcusb.h
Diffstat (limited to 'drivers/net')
43 files changed, 2386 insertions, 158 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index f9fbd52b799b..2bea67c134f0 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -209,7 +209,7 @@ config MII | |||
209 | 209 | ||
210 | config MACB | 210 | config MACB |
211 | tristate "Atmel MACB support" | 211 | tristate "Atmel MACB support" |
212 | depends on AVR32 || ARCH_AT91SAM9260 || ARCH_AT91SAM9263 || ARCH_AT91SAM9G20 || ARCH_AT91CAP9 | 212 | depends on AVR32 || ARCH_AT91SAM9260 || ARCH_AT91SAM9263 || ARCH_AT91SAM9G20 || ARCH_AT91SAM9G45 || ARCH_AT91CAP9 |
213 | select PHYLIB | 213 | select PHYLIB |
214 | help | 214 | help |
215 | The Atmel MACB ethernet interface is found on many AT32 and AT91 | 215 | The Atmel MACB ethernet interface is found on many AT32 and AT91 |
@@ -1934,6 +1934,15 @@ config XILINX_EMACLITE | |||
1934 | help | 1934 | help |
1935 | This driver supports the 10/100 Ethernet Lite from Xilinx. | 1935 | This driver supports the 10/100 Ethernet Lite from Xilinx. |
1936 | 1936 | ||
1937 | config BCM63XX_ENET | ||
1938 | tristate "Broadcom 63xx internal mac support" | ||
1939 | depends on BCM63XX | ||
1940 | select MII | ||
1941 | select PHYLIB | ||
1942 | help | ||
1943 | This driver supports the ethernet MACs in the Broadcom 63xx | ||
1944 | MIPS chipset family (BCM63XX). | ||
1945 | |||
1937 | source "drivers/net/fs_enet/Kconfig" | 1946 | source "drivers/net/fs_enet/Kconfig" |
1938 | 1947 | ||
1939 | endif # NET_ETHERNET | 1948 | endif # NET_ETHERNET |
diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 99ae6d7fe6a9..ae8cd30f13d6 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile | |||
@@ -137,6 +137,7 @@ obj-$(CONFIG_B44) += b44.o | |||
137 | obj-$(CONFIG_FORCEDETH) += forcedeth.o | 137 | obj-$(CONFIG_FORCEDETH) += forcedeth.o |
138 | obj-$(CONFIG_NE_H8300) += ne-h8300.o 8390.o | 138 | obj-$(CONFIG_NE_H8300) += ne-h8300.o 8390.o |
139 | obj-$(CONFIG_AX88796) += ax88796.o | 139 | obj-$(CONFIG_AX88796) += ax88796.o |
140 | obj-$(CONFIG_BCM63XX_ENET) += bcm63xx_enet.o | ||
140 | 141 | ||
141 | obj-$(CONFIG_TSI108_ETH) += tsi108_eth.o | 142 | obj-$(CONFIG_TSI108_ETH) += tsi108_eth.o |
142 | obj-$(CONFIG_MV643XX_ETH) += mv643xx_eth.o | 143 | obj-$(CONFIG_MV643XX_ETH) += mv643xx_eth.o |
diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c index 646dfc5f50c9..8ea9c7545c12 100644 --- a/drivers/net/arcnet/arc-rawmode.c +++ b/drivers/net/arcnet/arc-rawmode.c | |||
@@ -123,7 +123,6 @@ static void rx(struct net_device *dev, int bufnum, | |||
123 | BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx"); | 123 | BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx"); |
124 | 124 | ||
125 | skb->protocol = cpu_to_be16(ETH_P_ARCNET); | 125 | skb->protocol = cpu_to_be16(ETH_P_ARCNET); |
126 | ; | ||
127 | netif_rx(skb); | 126 | netif_rx(skb); |
128 | } | 127 | } |
129 | 128 | ||
diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c index 083e21094b20..66bcbbb6babc 100644 --- a/drivers/net/arcnet/capmode.c +++ b/drivers/net/arcnet/capmode.c | |||
@@ -149,7 +149,6 @@ static void rx(struct net_device *dev, int bufnum, | |||
149 | BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx"); | 149 | BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx"); |
150 | 150 | ||
151 | skb->protocol = cpu_to_be16(ETH_P_ARCNET); | 151 | skb->protocol = cpu_to_be16(ETH_P_ARCNET); |
152 | ; | ||
153 | netif_rx(skb); | 152 | netif_rx(skb); |
154 | } | 153 | } |
155 | 154 | ||
diff --git a/drivers/net/bcm63xx_enet.c b/drivers/net/bcm63xx_enet.c new file mode 100644 index 000000000000..09d270913c50 --- /dev/null +++ b/drivers/net/bcm63xx_enet.c | |||
@@ -0,0 +1,1971 @@ | |||
1 | /* | ||
2 | * Driver for BCM963xx builtin Ethernet mac | ||
3 | * | ||
4 | * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
19 | */ | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/clk.h> | ||
23 | #include <linux/etherdevice.h> | ||
24 | #include <linux/delay.h> | ||
25 | #include <linux/ethtool.h> | ||
26 | #include <linux/crc32.h> | ||
27 | #include <linux/err.h> | ||
28 | #include <linux/dma-mapping.h> | ||
29 | #include <linux/platform_device.h> | ||
30 | #include <linux/if_vlan.h> | ||
31 | |||
32 | #include <bcm63xx_dev_enet.h> | ||
33 | #include "bcm63xx_enet.h" | ||
34 | |||
35 | static char bcm_enet_driver_name[] = "bcm63xx_enet"; | ||
36 | static char bcm_enet_driver_version[] = "1.0"; | ||
37 | |||
38 | static int copybreak __read_mostly = 128; | ||
39 | module_param(copybreak, int, 0); | ||
40 | MODULE_PARM_DESC(copybreak, "Receive copy threshold"); | ||
41 | |||
42 | /* io memory shared between all devices */ | ||
43 | static void __iomem *bcm_enet_shared_base; | ||
44 | |||
45 | /* | ||
46 | * io helpers to access mac registers | ||
47 | */ | ||
48 | static inline u32 enet_readl(struct bcm_enet_priv *priv, u32 off) | ||
49 | { | ||
50 | return bcm_readl(priv->base + off); | ||
51 | } | ||
52 | |||
53 | static inline void enet_writel(struct bcm_enet_priv *priv, | ||
54 | u32 val, u32 off) | ||
55 | { | ||
56 | bcm_writel(val, priv->base + off); | ||
57 | } | ||
58 | |||
59 | /* | ||
60 | * io helpers to access shared registers | ||
61 | */ | ||
62 | static inline u32 enet_dma_readl(struct bcm_enet_priv *priv, u32 off) | ||
63 | { | ||
64 | return bcm_readl(bcm_enet_shared_base + off); | ||
65 | } | ||
66 | |||
67 | static inline void enet_dma_writel(struct bcm_enet_priv *priv, | ||
68 | u32 val, u32 off) | ||
69 | { | ||
70 | bcm_writel(val, bcm_enet_shared_base + off); | ||
71 | } | ||
72 | |||
73 | /* | ||
74 | * write given data into mii register and wait for transfer to end | ||
75 | * with timeout (average measured transfer time is 25us) | ||
76 | */ | ||
77 | static int do_mdio_op(struct bcm_enet_priv *priv, unsigned int data) | ||
78 | { | ||
79 | int limit; | ||
80 | |||
81 | /* make sure mii interrupt status is cleared */ | ||
82 | enet_writel(priv, ENET_IR_MII, ENET_IR_REG); | ||
83 | |||
84 | enet_writel(priv, data, ENET_MIIDATA_REG); | ||
85 | wmb(); | ||
86 | |||
87 | /* busy wait on mii interrupt bit, with timeout */ | ||
88 | limit = 1000; | ||
89 | do { | ||
90 | if (enet_readl(priv, ENET_IR_REG) & ENET_IR_MII) | ||
91 | break; | ||
92 | udelay(1); | ||
93 | } while (limit-- >= 0); | ||
94 | |||
95 | return (limit < 0) ? 1 : 0; | ||
96 | } | ||
97 | |||
98 | /* | ||
99 | * MII internal read callback | ||
100 | */ | ||
101 | static int bcm_enet_mdio_read(struct bcm_enet_priv *priv, int mii_id, | ||
102 | int regnum) | ||
103 | { | ||
104 | u32 tmp, val; | ||
105 | |||
106 | tmp = regnum << ENET_MIIDATA_REG_SHIFT; | ||
107 | tmp |= 0x2 << ENET_MIIDATA_TA_SHIFT; | ||
108 | tmp |= mii_id << ENET_MIIDATA_PHYID_SHIFT; | ||
109 | tmp |= ENET_MIIDATA_OP_READ_MASK; | ||
110 | |||
111 | if (do_mdio_op(priv, tmp)) | ||
112 | return -1; | ||
113 | |||
114 | val = enet_readl(priv, ENET_MIIDATA_REG); | ||
115 | val &= 0xffff; | ||
116 | return val; | ||
117 | } | ||
118 | |||
119 | /* | ||
120 | * MII internal write callback | ||
121 | */ | ||
122 | static int bcm_enet_mdio_write(struct bcm_enet_priv *priv, int mii_id, | ||
123 | int regnum, u16 value) | ||
124 | { | ||
125 | u32 tmp; | ||
126 | |||
127 | tmp = (value & 0xffff) << ENET_MIIDATA_DATA_SHIFT; | ||
128 | tmp |= 0x2 << ENET_MIIDATA_TA_SHIFT; | ||
129 | tmp |= regnum << ENET_MIIDATA_REG_SHIFT; | ||
130 | tmp |= mii_id << ENET_MIIDATA_PHYID_SHIFT; | ||
131 | tmp |= ENET_MIIDATA_OP_WRITE_MASK; | ||
132 | |||
133 | (void)do_mdio_op(priv, tmp); | ||
134 | return 0; | ||
135 | } | ||
136 | |||
137 | /* | ||
138 | * MII read callback from phylib | ||
139 | */ | ||
140 | static int bcm_enet_mdio_read_phylib(struct mii_bus *bus, int mii_id, | ||
141 | int regnum) | ||
142 | { | ||
143 | return bcm_enet_mdio_read(bus->priv, mii_id, regnum); | ||
144 | } | ||
145 | |||
146 | /* | ||
147 | * MII write callback from phylib | ||
148 | */ | ||
149 | static int bcm_enet_mdio_write_phylib(struct mii_bus *bus, int mii_id, | ||
150 | int regnum, u16 value) | ||
151 | { | ||
152 | return bcm_enet_mdio_write(bus->priv, mii_id, regnum, value); | ||
153 | } | ||
154 | |||
155 | /* | ||
156 | * MII read callback from mii core | ||
157 | */ | ||
158 | static int bcm_enet_mdio_read_mii(struct net_device *dev, int mii_id, | ||
159 | int regnum) | ||
160 | { | ||
161 | return bcm_enet_mdio_read(netdev_priv(dev), mii_id, regnum); | ||
162 | } | ||
163 | |||
164 | /* | ||
165 | * MII write callback from mii core | ||
166 | */ | ||
167 | static void bcm_enet_mdio_write_mii(struct net_device *dev, int mii_id, | ||
168 | int regnum, int value) | ||
169 | { | ||
170 | bcm_enet_mdio_write(netdev_priv(dev), mii_id, regnum, value); | ||
171 | } | ||
172 | |||
173 | /* | ||
174 | * refill rx queue | ||
175 | */ | ||
176 | static int bcm_enet_refill_rx(struct net_device *dev) | ||
177 | { | ||
178 | struct bcm_enet_priv *priv; | ||
179 | |||
180 | priv = netdev_priv(dev); | ||
181 | |||
182 | while (priv->rx_desc_count < priv->rx_ring_size) { | ||
183 | struct bcm_enet_desc *desc; | ||
184 | struct sk_buff *skb; | ||
185 | dma_addr_t p; | ||
186 | int desc_idx; | ||
187 | u32 len_stat; | ||
188 | |||
189 | desc_idx = priv->rx_dirty_desc; | ||
190 | desc = &priv->rx_desc_cpu[desc_idx]; | ||
191 | |||
192 | if (!priv->rx_skb[desc_idx]) { | ||
193 | skb = netdev_alloc_skb(dev, priv->rx_skb_size); | ||
194 | if (!skb) | ||
195 | break; | ||
196 | priv->rx_skb[desc_idx] = skb; | ||
197 | |||
198 | p = dma_map_single(&priv->pdev->dev, skb->data, | ||
199 | priv->rx_skb_size, | ||
200 | DMA_FROM_DEVICE); | ||
201 | desc->address = p; | ||
202 | } | ||
203 | |||
204 | len_stat = priv->rx_skb_size << DMADESC_LENGTH_SHIFT; | ||
205 | len_stat |= DMADESC_OWNER_MASK; | ||
206 | if (priv->rx_dirty_desc == priv->rx_ring_size - 1) { | ||
207 | len_stat |= DMADESC_WRAP_MASK; | ||
208 | priv->rx_dirty_desc = 0; | ||
209 | } else { | ||
210 | priv->rx_dirty_desc++; | ||
211 | } | ||
212 | wmb(); | ||
213 | desc->len_stat = len_stat; | ||
214 | |||
215 | priv->rx_desc_count++; | ||
216 | |||
217 | /* tell dma engine we allocated one buffer */ | ||
218 | enet_dma_writel(priv, 1, ENETDMA_BUFALLOC_REG(priv->rx_chan)); | ||
219 | } | ||
220 | |||
221 | /* If rx ring is still empty, set a timer to try allocating | ||
222 | * again at a later time. */ | ||
223 | if (priv->rx_desc_count == 0 && netif_running(dev)) { | ||
224 | dev_warn(&priv->pdev->dev, "unable to refill rx ring\n"); | ||
225 | priv->rx_timeout.expires = jiffies + HZ; | ||
226 | add_timer(&priv->rx_timeout); | ||
227 | } | ||
228 | |||
229 | return 0; | ||
230 | } | ||
231 | |||
232 | /* | ||
233 | * timer callback to defer refill rx queue in case we're OOM | ||
234 | */ | ||
235 | static void bcm_enet_refill_rx_timer(unsigned long data) | ||
236 | { | ||
237 | struct net_device *dev; | ||
238 | struct bcm_enet_priv *priv; | ||
239 | |||
240 | dev = (struct net_device *)data; | ||
241 | priv = netdev_priv(dev); | ||
242 | |||
243 | spin_lock(&priv->rx_lock); | ||
244 | bcm_enet_refill_rx((struct net_device *)data); | ||
245 | spin_unlock(&priv->rx_lock); | ||
246 | } | ||
247 | |||
248 | /* | ||
249 | * extract packet from rx queue | ||
250 | */ | ||
251 | static int bcm_enet_receive_queue(struct net_device *dev, int budget) | ||
252 | { | ||
253 | struct bcm_enet_priv *priv; | ||
254 | struct device *kdev; | ||
255 | int processed; | ||
256 | |||
257 | priv = netdev_priv(dev); | ||
258 | kdev = &priv->pdev->dev; | ||
259 | processed = 0; | ||
260 | |||
261 | /* don't scan ring further than number of refilled | ||
262 | * descriptor */ | ||
263 | if (budget > priv->rx_desc_count) | ||
264 | budget = priv->rx_desc_count; | ||
265 | |||
266 | do { | ||
267 | struct bcm_enet_desc *desc; | ||
268 | struct sk_buff *skb; | ||
269 | int desc_idx; | ||
270 | u32 len_stat; | ||
271 | unsigned int len; | ||
272 | |||
273 | desc_idx = priv->rx_curr_desc; | ||
274 | desc = &priv->rx_desc_cpu[desc_idx]; | ||
275 | |||
276 | /* make sure we actually read the descriptor status at | ||
277 | * each loop */ | ||
278 | rmb(); | ||
279 | |||
280 | len_stat = desc->len_stat; | ||
281 | |||
282 | /* break if dma ownership belongs to hw */ | ||
283 | if (len_stat & DMADESC_OWNER_MASK) | ||
284 | break; | ||
285 | |||
286 | processed++; | ||
287 | priv->rx_curr_desc++; | ||
288 | if (priv->rx_curr_desc == priv->rx_ring_size) | ||
289 | priv->rx_curr_desc = 0; | ||
290 | priv->rx_desc_count--; | ||
291 | |||
292 | /* if the packet does not have start of packet _and_ | ||
293 | * end of packet flag set, then just recycle it */ | ||
294 | if ((len_stat & DMADESC_ESOP_MASK) != DMADESC_ESOP_MASK) { | ||
295 | priv->stats.rx_dropped++; | ||
296 | continue; | ||
297 | } | ||
298 | |||
299 | /* recycle packet if it's marked as bad */ | ||
300 | if (unlikely(len_stat & DMADESC_ERR_MASK)) { | ||
301 | priv->stats.rx_errors++; | ||
302 | |||
303 | if (len_stat & DMADESC_OVSIZE_MASK) | ||
304 | priv->stats.rx_length_errors++; | ||
305 | if (len_stat & DMADESC_CRC_MASK) | ||
306 | priv->stats.rx_crc_errors++; | ||
307 | if (len_stat & DMADESC_UNDER_MASK) | ||
308 | priv->stats.rx_frame_errors++; | ||
309 | if (len_stat & DMADESC_OV_MASK) | ||
310 | priv->stats.rx_fifo_errors++; | ||
311 | continue; | ||
312 | } | ||
313 | |||
314 | /* valid packet */ | ||
315 | skb = priv->rx_skb[desc_idx]; | ||
316 | len = (len_stat & DMADESC_LENGTH_MASK) >> DMADESC_LENGTH_SHIFT; | ||
317 | /* don't include FCS */ | ||
318 | len -= 4; | ||
319 | |||
320 | if (len < copybreak) { | ||
321 | struct sk_buff *nskb; | ||
322 | |||
323 | nskb = netdev_alloc_skb(dev, len + NET_IP_ALIGN); | ||
324 | if (!nskb) { | ||
325 | /* forget packet, just rearm desc */ | ||
326 | priv->stats.rx_dropped++; | ||
327 | continue; | ||
328 | } | ||
329 | |||
330 | /* since we're copying the data, we can align | ||
331 | * them properly */ | ||
332 | skb_reserve(nskb, NET_IP_ALIGN); | ||
333 | dma_sync_single_for_cpu(kdev, desc->address, | ||
334 | len, DMA_FROM_DEVICE); | ||
335 | memcpy(nskb->data, skb->data, len); | ||
336 | dma_sync_single_for_device(kdev, desc->address, | ||
337 | len, DMA_FROM_DEVICE); | ||
338 | skb = nskb; | ||
339 | } else { | ||
340 | dma_unmap_single(&priv->pdev->dev, desc->address, | ||
341 | priv->rx_skb_size, DMA_FROM_DEVICE); | ||
342 | priv->rx_skb[desc_idx] = NULL; | ||
343 | } | ||
344 | |||
345 | skb_put(skb, len); | ||
346 | skb->dev = dev; | ||
347 | skb->protocol = eth_type_trans(skb, dev); | ||
348 | priv->stats.rx_packets++; | ||
349 | priv->stats.rx_bytes += len; | ||
350 | dev->last_rx = jiffies; | ||
351 | netif_receive_skb(skb); | ||
352 | |||
353 | } while (--budget > 0); | ||
354 | |||
355 | if (processed || !priv->rx_desc_count) { | ||
356 | bcm_enet_refill_rx(dev); | ||
357 | |||
358 | /* kick rx dma */ | ||
359 | enet_dma_writel(priv, ENETDMA_CHANCFG_EN_MASK, | ||
360 | ENETDMA_CHANCFG_REG(priv->rx_chan)); | ||
361 | } | ||
362 | |||
363 | return processed; | ||
364 | } | ||
365 | |||
366 | |||
367 | /* | ||
368 | * try to or force reclaim of transmitted buffers | ||
369 | */ | ||
370 | static int bcm_enet_tx_reclaim(struct net_device *dev, int force) | ||
371 | { | ||
372 | struct bcm_enet_priv *priv; | ||
373 | int released; | ||
374 | |||
375 | priv = netdev_priv(dev); | ||
376 | released = 0; | ||
377 | |||
378 | while (priv->tx_desc_count < priv->tx_ring_size) { | ||
379 | struct bcm_enet_desc *desc; | ||
380 | struct sk_buff *skb; | ||
381 | |||
382 | /* We run in a bh and fight against start_xmit, which | ||
383 | * is called with bh disabled */ | ||
384 | spin_lock(&priv->tx_lock); | ||
385 | |||
386 | desc = &priv->tx_desc_cpu[priv->tx_dirty_desc]; | ||
387 | |||
388 | if (!force && (desc->len_stat & DMADESC_OWNER_MASK)) { | ||
389 | spin_unlock(&priv->tx_lock); | ||
390 | break; | ||
391 | } | ||
392 | |||
393 | /* ensure other field of the descriptor were not read | ||
394 | * before we checked ownership */ | ||
395 | rmb(); | ||
396 | |||
397 | skb = priv->tx_skb[priv->tx_dirty_desc]; | ||
398 | priv->tx_skb[priv->tx_dirty_desc] = NULL; | ||
399 | dma_unmap_single(&priv->pdev->dev, desc->address, skb->len, | ||
400 | DMA_TO_DEVICE); | ||
401 | |||
402 | priv->tx_dirty_desc++; | ||
403 | if (priv->tx_dirty_desc == priv->tx_ring_size) | ||
404 | priv->tx_dirty_desc = 0; | ||
405 | priv->tx_desc_count++; | ||
406 | |||
407 | spin_unlock(&priv->tx_lock); | ||
408 | |||
409 | if (desc->len_stat & DMADESC_UNDER_MASK) | ||
410 | priv->stats.tx_errors++; | ||
411 | |||
412 | dev_kfree_skb(skb); | ||
413 | released++; | ||
414 | } | ||
415 | |||
416 | if (netif_queue_stopped(dev) && released) | ||
417 | netif_wake_queue(dev); | ||
418 | |||
419 | return released; | ||
420 | } | ||
421 | |||
422 | /* | ||
423 | * poll func, called by network core | ||
424 | */ | ||
425 | static int bcm_enet_poll(struct napi_struct *napi, int budget) | ||
426 | { | ||
427 | struct bcm_enet_priv *priv; | ||
428 | struct net_device *dev; | ||
429 | int tx_work_done, rx_work_done; | ||
430 | |||
431 | priv = container_of(napi, struct bcm_enet_priv, napi); | ||
432 | dev = priv->net_dev; | ||
433 | |||
434 | /* ack interrupts */ | ||
435 | enet_dma_writel(priv, ENETDMA_IR_PKTDONE_MASK, | ||
436 | ENETDMA_IR_REG(priv->rx_chan)); | ||
437 | enet_dma_writel(priv, ENETDMA_IR_PKTDONE_MASK, | ||
438 | ENETDMA_IR_REG(priv->tx_chan)); | ||
439 | |||
440 | /* reclaim sent skb */ | ||
441 | tx_work_done = bcm_enet_tx_reclaim(dev, 0); | ||
442 | |||
443 | spin_lock(&priv->rx_lock); | ||
444 | rx_work_done = bcm_enet_receive_queue(dev, budget); | ||
445 | spin_unlock(&priv->rx_lock); | ||
446 | |||
447 | if (rx_work_done >= budget || tx_work_done > 0) { | ||
448 | /* rx/tx queue is not yet empty/clean */ | ||
449 | return rx_work_done; | ||
450 | } | ||
451 | |||
452 | /* no more packet in rx/tx queue, remove device from poll | ||
453 | * queue */ | ||
454 | napi_complete(napi); | ||
455 | |||
456 | /* restore rx/tx interrupt */ | ||
457 | enet_dma_writel(priv, ENETDMA_IR_PKTDONE_MASK, | ||
458 | ENETDMA_IRMASK_REG(priv->rx_chan)); | ||
459 | enet_dma_writel(priv, ENETDMA_IR_PKTDONE_MASK, | ||
460 | ENETDMA_IRMASK_REG(priv->tx_chan)); | ||
461 | |||
462 | return rx_work_done; | ||
463 | } | ||
464 | |||
465 | /* | ||
466 | * mac interrupt handler | ||
467 | */ | ||
468 | static irqreturn_t bcm_enet_isr_mac(int irq, void *dev_id) | ||
469 | { | ||
470 | struct net_device *dev; | ||
471 | struct bcm_enet_priv *priv; | ||
472 | u32 stat; | ||
473 | |||
474 | dev = dev_id; | ||
475 | priv = netdev_priv(dev); | ||
476 | |||
477 | stat = enet_readl(priv, ENET_IR_REG); | ||
478 | if (!(stat & ENET_IR_MIB)) | ||
479 | return IRQ_NONE; | ||
480 | |||
481 | /* clear & mask interrupt */ | ||
482 | enet_writel(priv, ENET_IR_MIB, ENET_IR_REG); | ||
483 | enet_writel(priv, 0, ENET_IRMASK_REG); | ||
484 | |||
485 | /* read mib registers in workqueue */ | ||
486 | schedule_work(&priv->mib_update_task); | ||
487 | |||
488 | return IRQ_HANDLED; | ||
489 | } | ||
490 | |||
491 | /* | ||
492 | * rx/tx dma interrupt handler | ||
493 | */ | ||
494 | static irqreturn_t bcm_enet_isr_dma(int irq, void *dev_id) | ||
495 | { | ||
496 | struct net_device *dev; | ||
497 | struct bcm_enet_priv *priv; | ||
498 | |||
499 | dev = dev_id; | ||
500 | priv = netdev_priv(dev); | ||
501 | |||
502 | /* mask rx/tx interrupts */ | ||
503 | enet_dma_writel(priv, 0, ENETDMA_IRMASK_REG(priv->rx_chan)); | ||
504 | enet_dma_writel(priv, 0, ENETDMA_IRMASK_REG(priv->tx_chan)); | ||
505 | |||
506 | napi_schedule(&priv->napi); | ||
507 | |||
508 | return IRQ_HANDLED; | ||
509 | } | ||
510 | |||
511 | /* | ||
512 | * tx request callback | ||
513 | */ | ||
514 | static int bcm_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | ||
515 | { | ||
516 | struct bcm_enet_priv *priv; | ||
517 | struct bcm_enet_desc *desc; | ||
518 | u32 len_stat; | ||
519 | int ret; | ||
520 | |||
521 | priv = netdev_priv(dev); | ||
522 | |||
523 | /* lock against tx reclaim */ | ||
524 | spin_lock(&priv->tx_lock); | ||
525 | |||
526 | /* make sure the tx hw queue is not full, should not happen | ||
527 | * since we stop queue before it's the case */ | ||
528 | if (unlikely(!priv->tx_desc_count)) { | ||
529 | netif_stop_queue(dev); | ||
530 | dev_err(&priv->pdev->dev, "xmit called with no tx desc " | ||
531 | "available?\n"); | ||
532 | ret = NETDEV_TX_BUSY; | ||
533 | goto out_unlock; | ||
534 | } | ||
535 | |||
536 | /* point to the next available desc */ | ||
537 | desc = &priv->tx_desc_cpu[priv->tx_curr_desc]; | ||
538 | priv->tx_skb[priv->tx_curr_desc] = skb; | ||
539 | |||
540 | /* fill descriptor */ | ||
541 | desc->address = dma_map_single(&priv->pdev->dev, skb->data, skb->len, | ||
542 | DMA_TO_DEVICE); | ||
543 | |||
544 | len_stat = (skb->len << DMADESC_LENGTH_SHIFT) & DMADESC_LENGTH_MASK; | ||
545 | len_stat |= DMADESC_ESOP_MASK | | ||
546 | DMADESC_APPEND_CRC | | ||
547 | DMADESC_OWNER_MASK; | ||
548 | |||
549 | priv->tx_curr_desc++; | ||
550 | if (priv->tx_curr_desc == priv->tx_ring_size) { | ||
551 | priv->tx_curr_desc = 0; | ||
552 | len_stat |= DMADESC_WRAP_MASK; | ||
553 | } | ||
554 | priv->tx_desc_count--; | ||
555 | |||
556 | /* dma might be already polling, make sure we update desc | ||
557 | * fields in correct order */ | ||
558 | wmb(); | ||
559 | desc->len_stat = len_stat; | ||
560 | wmb(); | ||
561 | |||
562 | /* kick tx dma */ | ||
563 | enet_dma_writel(priv, ENETDMA_CHANCFG_EN_MASK, | ||
564 | ENETDMA_CHANCFG_REG(priv->tx_chan)); | ||
565 | |||
566 | /* stop queue if no more desc available */ | ||
567 | if (!priv->tx_desc_count) | ||
568 | netif_stop_queue(dev); | ||
569 | |||
570 | priv->stats.tx_bytes += skb->len; | ||
571 | priv->stats.tx_packets++; | ||
572 | dev->trans_start = jiffies; | ||
573 | ret = NETDEV_TX_OK; | ||
574 | |||
575 | out_unlock: | ||
576 | spin_unlock(&priv->tx_lock); | ||
577 | return ret; | ||
578 | } | ||
579 | |||
580 | /* | ||
581 | * Change the interface's mac address. | ||
582 | */ | ||
583 | static int bcm_enet_set_mac_address(struct net_device *dev, void *p) | ||
584 | { | ||
585 | struct bcm_enet_priv *priv; | ||
586 | struct sockaddr *addr = p; | ||
587 | u32 val; | ||
588 | |||
589 | priv = netdev_priv(dev); | ||
590 | memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); | ||
591 | |||
592 | /* use perfect match register 0 to store my mac address */ | ||
593 | val = (dev->dev_addr[2] << 24) | (dev->dev_addr[3] << 16) | | ||
594 | (dev->dev_addr[4] << 8) | dev->dev_addr[5]; | ||
595 | enet_writel(priv, val, ENET_PML_REG(0)); | ||
596 | |||
597 | val = (dev->dev_addr[0] << 8 | dev->dev_addr[1]); | ||
598 | val |= ENET_PMH_DATAVALID_MASK; | ||
599 | enet_writel(priv, val, ENET_PMH_REG(0)); | ||
600 | |||
601 | return 0; | ||
602 | } | ||
603 | |||
604 | /* | ||
605 | * Change rx mode (promiscous/allmulti) and update multicast list | ||
606 | */ | ||
607 | static void bcm_enet_set_multicast_list(struct net_device *dev) | ||
608 | { | ||
609 | struct bcm_enet_priv *priv; | ||
610 | struct dev_mc_list *mc_list; | ||
611 | u32 val; | ||
612 | int i; | ||
613 | |||
614 | priv = netdev_priv(dev); | ||
615 | |||
616 | val = enet_readl(priv, ENET_RXCFG_REG); | ||
617 | |||
618 | if (dev->flags & IFF_PROMISC) | ||
619 | val |= ENET_RXCFG_PROMISC_MASK; | ||
620 | else | ||
621 | val &= ~ENET_RXCFG_PROMISC_MASK; | ||
622 | |||
623 | /* only 3 perfect match registers left, first one is used for | ||
624 | * own mac address */ | ||
625 | if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > 3) | ||
626 | val |= ENET_RXCFG_ALLMCAST_MASK; | ||
627 | else | ||
628 | val &= ~ENET_RXCFG_ALLMCAST_MASK; | ||
629 | |||
630 | /* no need to set perfect match registers if we catch all | ||
631 | * multicast */ | ||
632 | if (val & ENET_RXCFG_ALLMCAST_MASK) { | ||
633 | enet_writel(priv, val, ENET_RXCFG_REG); | ||
634 | return; | ||
635 | } | ||
636 | |||
637 | for (i = 0, mc_list = dev->mc_list; | ||
638 | (mc_list != NULL) && (i < dev->mc_count) && (i < 3); | ||
639 | i++, mc_list = mc_list->next) { | ||
640 | u8 *dmi_addr; | ||
641 | u32 tmp; | ||
642 | |||
643 | /* filter non ethernet address */ | ||
644 | if (mc_list->dmi_addrlen != 6) | ||
645 | continue; | ||
646 | |||
647 | /* update perfect match registers */ | ||
648 | dmi_addr = mc_list->dmi_addr; | ||
649 | tmp = (dmi_addr[2] << 24) | (dmi_addr[3] << 16) | | ||
650 | (dmi_addr[4] << 8) | dmi_addr[5]; | ||
651 | enet_writel(priv, tmp, ENET_PML_REG(i + 1)); | ||
652 | |||
653 | tmp = (dmi_addr[0] << 8 | dmi_addr[1]); | ||
654 | tmp |= ENET_PMH_DATAVALID_MASK; | ||
655 | enet_writel(priv, tmp, ENET_PMH_REG(i + 1)); | ||
656 | } | ||
657 | |||
658 | for (; i < 3; i++) { | ||
659 | enet_writel(priv, 0, ENET_PML_REG(i + 1)); | ||
660 | enet_writel(priv, 0, ENET_PMH_REG(i + 1)); | ||
661 | } | ||
662 | |||
663 | enet_writel(priv, val, ENET_RXCFG_REG); | ||
664 | } | ||
665 | |||
666 | /* | ||
667 | * set mac duplex parameters | ||
668 | */ | ||
669 | static void bcm_enet_set_duplex(struct bcm_enet_priv *priv, int fullduplex) | ||
670 | { | ||
671 | u32 val; | ||
672 | |||
673 | val = enet_readl(priv, ENET_TXCTL_REG); | ||
674 | if (fullduplex) | ||
675 | val |= ENET_TXCTL_FD_MASK; | ||
676 | else | ||
677 | val &= ~ENET_TXCTL_FD_MASK; | ||
678 | enet_writel(priv, val, ENET_TXCTL_REG); | ||
679 | } | ||
680 | |||
681 | /* | ||
682 | * set mac flow control parameters | ||
683 | */ | ||
684 | static void bcm_enet_set_flow(struct bcm_enet_priv *priv, int rx_en, int tx_en) | ||
685 | { | ||
686 | u32 val; | ||
687 | |||
688 | /* rx flow control (pause frame handling) */ | ||
689 | val = enet_readl(priv, ENET_RXCFG_REG); | ||
690 | if (rx_en) | ||
691 | val |= ENET_RXCFG_ENFLOW_MASK; | ||
692 | else | ||
693 | val &= ~ENET_RXCFG_ENFLOW_MASK; | ||
694 | enet_writel(priv, val, ENET_RXCFG_REG); | ||
695 | |||
696 | /* tx flow control (pause frame generation) */ | ||
697 | val = enet_dma_readl(priv, ENETDMA_CFG_REG); | ||
698 | if (tx_en) | ||
699 | val |= ENETDMA_CFG_FLOWCH_MASK(priv->rx_chan); | ||
700 | else | ||
701 | val &= ~ENETDMA_CFG_FLOWCH_MASK(priv->rx_chan); | ||
702 | enet_dma_writel(priv, val, ENETDMA_CFG_REG); | ||
703 | } | ||
704 | |||
705 | /* | ||
706 | * link changed callback (from phylib) | ||
707 | */ | ||
708 | static void bcm_enet_adjust_phy_link(struct net_device *dev) | ||
709 | { | ||
710 | struct bcm_enet_priv *priv; | ||
711 | struct phy_device *phydev; | ||
712 | int status_changed; | ||
713 | |||
714 | priv = netdev_priv(dev); | ||
715 | phydev = priv->phydev; | ||
716 | status_changed = 0; | ||
717 | |||
718 | if (priv->old_link != phydev->link) { | ||
719 | status_changed = 1; | ||
720 | priv->old_link = phydev->link; | ||
721 | } | ||
722 | |||
723 | /* reflect duplex change in mac configuration */ | ||
724 | if (phydev->link && phydev->duplex != priv->old_duplex) { | ||
725 | bcm_enet_set_duplex(priv, | ||
726 | (phydev->duplex == DUPLEX_FULL) ? 1 : 0); | ||
727 | status_changed = 1; | ||
728 | priv->old_duplex = phydev->duplex; | ||
729 | } | ||
730 | |||
731 | /* enable flow control if remote advertise it (trust phylib to | ||
732 | * check that duplex is full */ | ||
733 | if (phydev->link && phydev->pause != priv->old_pause) { | ||
734 | int rx_pause_en, tx_pause_en; | ||
735 | |||
736 | if (phydev->pause) { | ||
737 | /* pause was advertised by lpa and us */ | ||
738 | rx_pause_en = 1; | ||
739 | tx_pause_en = 1; | ||
740 | } else if (!priv->pause_auto) { | ||
741 | /* pause setting overrided by user */ | ||
742 | rx_pause_en = priv->pause_rx; | ||
743 | tx_pause_en = priv->pause_tx; | ||
744 | } else { | ||
745 | rx_pause_en = 0; | ||
746 | tx_pause_en = 0; | ||
747 | } | ||
748 | |||
749 | bcm_enet_set_flow(priv, rx_pause_en, tx_pause_en); | ||
750 | status_changed = 1; | ||
751 | priv->old_pause = phydev->pause; | ||
752 | } | ||
753 | |||
754 | if (status_changed) { | ||
755 | pr_info("%s: link %s", dev->name, phydev->link ? | ||
756 | "UP" : "DOWN"); | ||
757 | if (phydev->link) | ||
758 | pr_cont(" - %d/%s - flow control %s", phydev->speed, | ||
759 | DUPLEX_FULL == phydev->duplex ? "full" : "half", | ||
760 | phydev->pause == 1 ? "rx&tx" : "off"); | ||
761 | |||
762 | pr_cont("\n"); | ||
763 | } | ||
764 | } | ||
765 | |||
766 | /* | ||
767 | * link changed callback (if phylib is not used) | ||
768 | */ | ||
769 | static void bcm_enet_adjust_link(struct net_device *dev) | ||
770 | { | ||
771 | struct bcm_enet_priv *priv; | ||
772 | |||
773 | priv = netdev_priv(dev); | ||
774 | bcm_enet_set_duplex(priv, priv->force_duplex_full); | ||
775 | bcm_enet_set_flow(priv, priv->pause_rx, priv->pause_tx); | ||
776 | netif_carrier_on(dev); | ||
777 | |||
778 | pr_info("%s: link forced UP - %d/%s - flow control %s/%s\n", | ||
779 | dev->name, | ||
780 | priv->force_speed_100 ? 100 : 10, | ||
781 | priv->force_duplex_full ? "full" : "half", | ||
782 | priv->pause_rx ? "rx" : "off", | ||
783 | priv->pause_tx ? "tx" : "off"); | ||
784 | } | ||
785 | |||
786 | /* | ||
787 | * open callback, allocate dma rings & buffers and start rx operation | ||
788 | */ | ||
789 | static int bcm_enet_open(struct net_device *dev) | ||
790 | { | ||
791 | struct bcm_enet_priv *priv; | ||
792 | struct sockaddr addr; | ||
793 | struct device *kdev; | ||
794 | struct phy_device *phydev; | ||
795 | int i, ret; | ||
796 | unsigned int size; | ||
797 | char phy_id[MII_BUS_ID_SIZE + 3]; | ||
798 | void *p; | ||
799 | u32 val; | ||
800 | |||
801 | priv = netdev_priv(dev); | ||
802 | kdev = &priv->pdev->dev; | ||
803 | |||
804 | if (priv->has_phy) { | ||
805 | /* connect to PHY */ | ||
806 | snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, | ||
807 | priv->mac_id ? "1" : "0", priv->phy_id); | ||
808 | |||
809 | phydev = phy_connect(dev, phy_id, &bcm_enet_adjust_phy_link, 0, | ||
810 | PHY_INTERFACE_MODE_MII); | ||
811 | |||
812 | if (IS_ERR(phydev)) { | ||
813 | dev_err(kdev, "could not attach to PHY\n"); | ||
814 | return PTR_ERR(phydev); | ||
815 | } | ||
816 | |||
817 | /* mask with MAC supported features */ | ||
818 | phydev->supported &= (SUPPORTED_10baseT_Half | | ||
819 | SUPPORTED_10baseT_Full | | ||
820 | SUPPORTED_100baseT_Half | | ||
821 | SUPPORTED_100baseT_Full | | ||
822 | SUPPORTED_Autoneg | | ||
823 | SUPPORTED_Pause | | ||
824 | SUPPORTED_MII); | ||
825 | phydev->advertising = phydev->supported; | ||
826 | |||
827 | if (priv->pause_auto && priv->pause_rx && priv->pause_tx) | ||
828 | phydev->advertising |= SUPPORTED_Pause; | ||
829 | else | ||
830 | phydev->advertising &= ~SUPPORTED_Pause; | ||
831 | |||
832 | dev_info(kdev, "attached PHY at address %d [%s]\n", | ||
833 | phydev->addr, phydev->drv->name); | ||
834 | |||
835 | priv->old_link = 0; | ||
836 | priv->old_duplex = -1; | ||
837 | priv->old_pause = -1; | ||
838 | priv->phydev = phydev; | ||
839 | } | ||
840 | |||
841 | /* mask all interrupts and request them */ | ||
842 | enet_writel(priv, 0, ENET_IRMASK_REG); | ||
843 | enet_dma_writel(priv, 0, ENETDMA_IRMASK_REG(priv->rx_chan)); | ||
844 | enet_dma_writel(priv, 0, ENETDMA_IRMASK_REG(priv->tx_chan)); | ||
845 | |||
846 | ret = request_irq(dev->irq, bcm_enet_isr_mac, 0, dev->name, dev); | ||
847 | if (ret) | ||
848 | goto out_phy_disconnect; | ||
849 | |||
850 | ret = request_irq(priv->irq_rx, bcm_enet_isr_dma, | ||
851 | IRQF_SAMPLE_RANDOM | IRQF_DISABLED, dev->name, dev); | ||
852 | if (ret) | ||
853 | goto out_freeirq; | ||
854 | |||
855 | ret = request_irq(priv->irq_tx, bcm_enet_isr_dma, | ||
856 | IRQF_DISABLED, dev->name, dev); | ||
857 | if (ret) | ||
858 | goto out_freeirq_rx; | ||
859 | |||
860 | /* initialize perfect match registers */ | ||
861 | for (i = 0; i < 4; i++) { | ||
862 | enet_writel(priv, 0, ENET_PML_REG(i)); | ||
863 | enet_writel(priv, 0, ENET_PMH_REG(i)); | ||
864 | } | ||
865 | |||
866 | /* write device mac address */ | ||
867 | memcpy(addr.sa_data, dev->dev_addr, ETH_ALEN); | ||
868 | bcm_enet_set_mac_address(dev, &addr); | ||
869 | |||
870 | /* allocate rx dma ring */ | ||
871 | size = priv->rx_ring_size * sizeof(struct bcm_enet_desc); | ||
872 | p = dma_alloc_coherent(kdev, size, &priv->rx_desc_dma, GFP_KERNEL); | ||
873 | if (!p) { | ||
874 | dev_err(kdev, "cannot allocate rx ring %u\n", size); | ||
875 | ret = -ENOMEM; | ||
876 | goto out_freeirq_tx; | ||
877 | } | ||
878 | |||
879 | memset(p, 0, size); | ||
880 | priv->rx_desc_alloc_size = size; | ||
881 | priv->rx_desc_cpu = p; | ||
882 | |||
883 | /* allocate tx dma ring */ | ||
884 | size = priv->tx_ring_size * sizeof(struct bcm_enet_desc); | ||
885 | p = dma_alloc_coherent(kdev, size, &priv->tx_desc_dma, GFP_KERNEL); | ||
886 | if (!p) { | ||
887 | dev_err(kdev, "cannot allocate tx ring\n"); | ||
888 | ret = -ENOMEM; | ||
889 | goto out_free_rx_ring; | ||
890 | } | ||
891 | |||
892 | memset(p, 0, size); | ||
893 | priv->tx_desc_alloc_size = size; | ||
894 | priv->tx_desc_cpu = p; | ||
895 | |||
896 | priv->tx_skb = kzalloc(sizeof(struct sk_buff *) * priv->tx_ring_size, | ||
897 | GFP_KERNEL); | ||
898 | if (!priv->tx_skb) { | ||
899 | dev_err(kdev, "cannot allocate rx skb queue\n"); | ||
900 | ret = -ENOMEM; | ||
901 | goto out_free_tx_ring; | ||
902 | } | ||
903 | |||
904 | priv->tx_desc_count = priv->tx_ring_size; | ||
905 | priv->tx_dirty_desc = 0; | ||
906 | priv->tx_curr_desc = 0; | ||
907 | spin_lock_init(&priv->tx_lock); | ||
908 | |||
909 | /* init & fill rx ring with skbs */ | ||
910 | priv->rx_skb = kzalloc(sizeof(struct sk_buff *) * priv->rx_ring_size, | ||
911 | GFP_KERNEL); | ||
912 | if (!priv->rx_skb) { | ||
913 | dev_err(kdev, "cannot allocate rx skb queue\n"); | ||
914 | ret = -ENOMEM; | ||
915 | goto out_free_tx_skb; | ||
916 | } | ||
917 | |||
918 | priv->rx_desc_count = 0; | ||
919 | priv->rx_dirty_desc = 0; | ||
920 | priv->rx_curr_desc = 0; | ||
921 | |||
922 | /* initialize flow control buffer allocation */ | ||
923 | enet_dma_writel(priv, ENETDMA_BUFALLOC_FORCE_MASK | 0, | ||
924 | ENETDMA_BUFALLOC_REG(priv->rx_chan)); | ||
925 | |||
926 | if (bcm_enet_refill_rx(dev)) { | ||
927 | dev_err(kdev, "cannot allocate rx skb queue\n"); | ||
928 | ret = -ENOMEM; | ||
929 | goto out; | ||
930 | } | ||
931 | |||
932 | /* write rx & tx ring addresses */ | ||
933 | enet_dma_writel(priv, priv->rx_desc_dma, | ||
934 | ENETDMA_RSTART_REG(priv->rx_chan)); | ||
935 | enet_dma_writel(priv, priv->tx_desc_dma, | ||
936 | ENETDMA_RSTART_REG(priv->tx_chan)); | ||
937 | |||
938 | /* clear remaining state ram for rx & tx channel */ | ||
939 | enet_dma_writel(priv, 0, ENETDMA_SRAM2_REG(priv->rx_chan)); | ||
940 | enet_dma_writel(priv, 0, ENETDMA_SRAM2_REG(priv->tx_chan)); | ||
941 | enet_dma_writel(priv, 0, ENETDMA_SRAM3_REG(priv->rx_chan)); | ||
942 | enet_dma_writel(priv, 0, ENETDMA_SRAM3_REG(priv->tx_chan)); | ||
943 | enet_dma_writel(priv, 0, ENETDMA_SRAM4_REG(priv->rx_chan)); | ||
944 | enet_dma_writel(priv, 0, ENETDMA_SRAM4_REG(priv->tx_chan)); | ||
945 | |||
946 | /* set max rx/tx length */ | ||
947 | enet_writel(priv, priv->hw_mtu, ENET_RXMAXLEN_REG); | ||
948 | enet_writel(priv, priv->hw_mtu, ENET_TXMAXLEN_REG); | ||
949 | |||
950 | /* set dma maximum burst len */ | ||
951 | enet_dma_writel(priv, BCMENET_DMA_MAXBURST, | ||
952 | ENETDMA_MAXBURST_REG(priv->rx_chan)); | ||
953 | enet_dma_writel(priv, BCMENET_DMA_MAXBURST, | ||
954 | ENETDMA_MAXBURST_REG(priv->tx_chan)); | ||
955 | |||
956 | /* set correct transmit fifo watermark */ | ||
957 | enet_writel(priv, BCMENET_TX_FIFO_TRESH, ENET_TXWMARK_REG); | ||
958 | |||
959 | /* set flow control low/high threshold to 1/3 / 2/3 */ | ||
960 | val = priv->rx_ring_size / 3; | ||
961 | enet_dma_writel(priv, val, ENETDMA_FLOWCL_REG(priv->rx_chan)); | ||
962 | val = (priv->rx_ring_size * 2) / 3; | ||
963 | enet_dma_writel(priv, val, ENETDMA_FLOWCH_REG(priv->rx_chan)); | ||
964 | |||
965 | /* all set, enable mac and interrupts, start dma engine and | ||
966 | * kick rx dma channel */ | ||
967 | wmb(); | ||
968 | enet_writel(priv, ENET_CTL_ENABLE_MASK, ENET_CTL_REG); | ||
969 | enet_dma_writel(priv, ENETDMA_CFG_EN_MASK, ENETDMA_CFG_REG); | ||
970 | enet_dma_writel(priv, ENETDMA_CHANCFG_EN_MASK, | ||
971 | ENETDMA_CHANCFG_REG(priv->rx_chan)); | ||
972 | |||
973 | /* watch "mib counters about to overflow" interrupt */ | ||
974 | enet_writel(priv, ENET_IR_MIB, ENET_IR_REG); | ||
975 | enet_writel(priv, ENET_IR_MIB, ENET_IRMASK_REG); | ||
976 | |||
977 | /* watch "packet transferred" interrupt in rx and tx */ | ||
978 | enet_dma_writel(priv, ENETDMA_IR_PKTDONE_MASK, | ||
979 | ENETDMA_IR_REG(priv->rx_chan)); | ||
980 | enet_dma_writel(priv, ENETDMA_IR_PKTDONE_MASK, | ||
981 | ENETDMA_IR_REG(priv->tx_chan)); | ||
982 | |||
983 | /* make sure we enable napi before rx interrupt */ | ||
984 | napi_enable(&priv->napi); | ||
985 | |||
986 | enet_dma_writel(priv, ENETDMA_IR_PKTDONE_MASK, | ||
987 | ENETDMA_IRMASK_REG(priv->rx_chan)); | ||
988 | enet_dma_writel(priv, ENETDMA_IR_PKTDONE_MASK, | ||
989 | ENETDMA_IRMASK_REG(priv->tx_chan)); | ||
990 | |||
991 | if (priv->has_phy) | ||
992 | phy_start(priv->phydev); | ||
993 | else | ||
994 | bcm_enet_adjust_link(dev); | ||
995 | |||
996 | netif_start_queue(dev); | ||
997 | return 0; | ||
998 | |||
999 | out: | ||
1000 | for (i = 0; i < priv->rx_ring_size; i++) { | ||
1001 | struct bcm_enet_desc *desc; | ||
1002 | |||
1003 | if (!priv->rx_skb[i]) | ||
1004 | continue; | ||
1005 | |||
1006 | desc = &priv->rx_desc_cpu[i]; | ||
1007 | dma_unmap_single(kdev, desc->address, priv->rx_skb_size, | ||
1008 | DMA_FROM_DEVICE); | ||
1009 | kfree_skb(priv->rx_skb[i]); | ||
1010 | } | ||
1011 | kfree(priv->rx_skb); | ||
1012 | |||
1013 | out_free_tx_skb: | ||
1014 | kfree(priv->tx_skb); | ||
1015 | |||
1016 | out_free_tx_ring: | ||
1017 | dma_free_coherent(kdev, priv->tx_desc_alloc_size, | ||
1018 | priv->tx_desc_cpu, priv->tx_desc_dma); | ||
1019 | |||
1020 | out_free_rx_ring: | ||
1021 | dma_free_coherent(kdev, priv->rx_desc_alloc_size, | ||
1022 | priv->rx_desc_cpu, priv->rx_desc_dma); | ||
1023 | |||
1024 | out_freeirq_tx: | ||
1025 | free_irq(priv->irq_tx, dev); | ||
1026 | |||
1027 | out_freeirq_rx: | ||
1028 | free_irq(priv->irq_rx, dev); | ||
1029 | |||
1030 | out_freeirq: | ||
1031 | free_irq(dev->irq, dev); | ||
1032 | |||
1033 | out_phy_disconnect: | ||
1034 | phy_disconnect(priv->phydev); | ||
1035 | |||
1036 | return ret; | ||
1037 | } | ||
1038 | |||
1039 | /* | ||
1040 | * disable mac | ||
1041 | */ | ||
1042 | static void bcm_enet_disable_mac(struct bcm_enet_priv *priv) | ||
1043 | { | ||
1044 | int limit; | ||
1045 | u32 val; | ||
1046 | |||
1047 | val = enet_readl(priv, ENET_CTL_REG); | ||
1048 | val |= ENET_CTL_DISABLE_MASK; | ||
1049 | enet_writel(priv, val, ENET_CTL_REG); | ||
1050 | |||
1051 | limit = 1000; | ||
1052 | do { | ||
1053 | u32 val; | ||
1054 | |||
1055 | val = enet_readl(priv, ENET_CTL_REG); | ||
1056 | if (!(val & ENET_CTL_DISABLE_MASK)) | ||
1057 | break; | ||
1058 | udelay(1); | ||
1059 | } while (limit--); | ||
1060 | } | ||
1061 | |||
1062 | /* | ||
1063 | * disable dma in given channel | ||
1064 | */ | ||
1065 | static void bcm_enet_disable_dma(struct bcm_enet_priv *priv, int chan) | ||
1066 | { | ||
1067 | int limit; | ||
1068 | |||
1069 | enet_dma_writel(priv, 0, ENETDMA_CHANCFG_REG(chan)); | ||
1070 | |||
1071 | limit = 1000; | ||
1072 | do { | ||
1073 | u32 val; | ||
1074 | |||
1075 | val = enet_dma_readl(priv, ENETDMA_CHANCFG_REG(chan)); | ||
1076 | if (!(val & ENETDMA_CHANCFG_EN_MASK)) | ||
1077 | break; | ||
1078 | udelay(1); | ||
1079 | } while (limit--); | ||
1080 | } | ||
1081 | |||
1082 | /* | ||
1083 | * stop callback | ||
1084 | */ | ||
1085 | static int bcm_enet_stop(struct net_device *dev) | ||
1086 | { | ||
1087 | struct bcm_enet_priv *priv; | ||
1088 | struct device *kdev; | ||
1089 | int i; | ||
1090 | |||
1091 | priv = netdev_priv(dev); | ||
1092 | kdev = &priv->pdev->dev; | ||
1093 | |||
1094 | netif_stop_queue(dev); | ||
1095 | napi_disable(&priv->napi); | ||
1096 | if (priv->has_phy) | ||
1097 | phy_stop(priv->phydev); | ||
1098 | del_timer_sync(&priv->rx_timeout); | ||
1099 | |||
1100 | /* mask all interrupts */ | ||
1101 | enet_writel(priv, 0, ENET_IRMASK_REG); | ||
1102 | enet_dma_writel(priv, 0, ENETDMA_IRMASK_REG(priv->rx_chan)); | ||
1103 | enet_dma_writel(priv, 0, ENETDMA_IRMASK_REG(priv->tx_chan)); | ||
1104 | |||
1105 | /* make sure no mib update is scheduled */ | ||
1106 | flush_scheduled_work(); | ||
1107 | |||
1108 | /* disable dma & mac */ | ||
1109 | bcm_enet_disable_dma(priv, priv->tx_chan); | ||
1110 | bcm_enet_disable_dma(priv, priv->rx_chan); | ||
1111 | bcm_enet_disable_mac(priv); | ||
1112 | |||
1113 | /* force reclaim of all tx buffers */ | ||
1114 | bcm_enet_tx_reclaim(dev, 1); | ||
1115 | |||
1116 | /* free the rx skb ring */ | ||
1117 | for (i = 0; i < priv->rx_ring_size; i++) { | ||
1118 | struct bcm_enet_desc *desc; | ||
1119 | |||
1120 | if (!priv->rx_skb[i]) | ||
1121 | continue; | ||
1122 | |||
1123 | desc = &priv->rx_desc_cpu[i]; | ||
1124 | dma_unmap_single(kdev, desc->address, priv->rx_skb_size, | ||
1125 | DMA_FROM_DEVICE); | ||
1126 | kfree_skb(priv->rx_skb[i]); | ||
1127 | } | ||
1128 | |||
1129 | /* free remaining allocated memory */ | ||
1130 | kfree(priv->rx_skb); | ||
1131 | kfree(priv->tx_skb); | ||
1132 | dma_free_coherent(kdev, priv->rx_desc_alloc_size, | ||
1133 | priv->rx_desc_cpu, priv->rx_desc_dma); | ||
1134 | dma_free_coherent(kdev, priv->tx_desc_alloc_size, | ||
1135 | priv->tx_desc_cpu, priv->tx_desc_dma); | ||
1136 | free_irq(priv->irq_tx, dev); | ||
1137 | free_irq(priv->irq_rx, dev); | ||
1138 | free_irq(dev->irq, dev); | ||
1139 | |||
1140 | /* release phy */ | ||
1141 | if (priv->has_phy) { | ||
1142 | phy_disconnect(priv->phydev); | ||
1143 | priv->phydev = NULL; | ||
1144 | } | ||
1145 | |||
1146 | return 0; | ||
1147 | } | ||
1148 | |||
1149 | /* | ||
1150 | * core request to return device rx/tx stats | ||
1151 | */ | ||
1152 | static struct net_device_stats *bcm_enet_get_stats(struct net_device *dev) | ||
1153 | { | ||
1154 | struct bcm_enet_priv *priv; | ||
1155 | |||
1156 | priv = netdev_priv(dev); | ||
1157 | return &priv->stats; | ||
1158 | } | ||
1159 | |||
1160 | /* | ||
1161 | * ethtool callbacks | ||
1162 | */ | ||
1163 | struct bcm_enet_stats { | ||
1164 | char stat_string[ETH_GSTRING_LEN]; | ||
1165 | int sizeof_stat; | ||
1166 | int stat_offset; | ||
1167 | int mib_reg; | ||
1168 | }; | ||
1169 | |||
1170 | #define GEN_STAT(m) sizeof(((struct bcm_enet_priv *)0)->m), \ | ||
1171 | offsetof(struct bcm_enet_priv, m) | ||
1172 | |||
1173 | static const struct bcm_enet_stats bcm_enet_gstrings_stats[] = { | ||
1174 | { "rx_packets", GEN_STAT(stats.rx_packets), -1 }, | ||
1175 | { "tx_packets", GEN_STAT(stats.tx_packets), -1 }, | ||
1176 | { "rx_bytes", GEN_STAT(stats.rx_bytes), -1 }, | ||
1177 | { "tx_bytes", GEN_STAT(stats.tx_bytes), -1 }, | ||
1178 | { "rx_errors", GEN_STAT(stats.rx_errors), -1 }, | ||
1179 | { "tx_errors", GEN_STAT(stats.tx_errors), -1 }, | ||
1180 | { "rx_dropped", GEN_STAT(stats.rx_dropped), -1 }, | ||
1181 | { "tx_dropped", GEN_STAT(stats.tx_dropped), -1 }, | ||
1182 | |||
1183 | { "rx_good_octets", GEN_STAT(mib.rx_gd_octets), ETH_MIB_RX_GD_OCTETS}, | ||
1184 | { "rx_good_pkts", GEN_STAT(mib.rx_gd_pkts), ETH_MIB_RX_GD_PKTS }, | ||
1185 | { "rx_broadcast", GEN_STAT(mib.rx_brdcast), ETH_MIB_RX_BRDCAST }, | ||
1186 | { "rx_multicast", GEN_STAT(mib.rx_mult), ETH_MIB_RX_MULT }, | ||
1187 | { "rx_64_octets", GEN_STAT(mib.rx_64), ETH_MIB_RX_64 }, | ||
1188 | { "rx_65_127_oct", GEN_STAT(mib.rx_65_127), ETH_MIB_RX_65_127 }, | ||
1189 | { "rx_128_255_oct", GEN_STAT(mib.rx_128_255), ETH_MIB_RX_128_255 }, | ||
1190 | { "rx_256_511_oct", GEN_STAT(mib.rx_256_511), ETH_MIB_RX_256_511 }, | ||
1191 | { "rx_512_1023_oct", GEN_STAT(mib.rx_512_1023), ETH_MIB_RX_512_1023 }, | ||
1192 | { "rx_1024_max_oct", GEN_STAT(mib.rx_1024_max), ETH_MIB_RX_1024_MAX }, | ||
1193 | { "rx_jabber", GEN_STAT(mib.rx_jab), ETH_MIB_RX_JAB }, | ||
1194 | { "rx_oversize", GEN_STAT(mib.rx_ovr), ETH_MIB_RX_OVR }, | ||
1195 | { "rx_fragment", GEN_STAT(mib.rx_frag), ETH_MIB_RX_FRAG }, | ||
1196 | { "rx_dropped", GEN_STAT(mib.rx_drop), ETH_MIB_RX_DROP }, | ||
1197 | { "rx_crc_align", GEN_STAT(mib.rx_crc_align), ETH_MIB_RX_CRC_ALIGN }, | ||
1198 | { "rx_undersize", GEN_STAT(mib.rx_und), ETH_MIB_RX_UND }, | ||
1199 | { "rx_crc", GEN_STAT(mib.rx_crc), ETH_MIB_RX_CRC }, | ||
1200 | { "rx_align", GEN_STAT(mib.rx_align), ETH_MIB_RX_ALIGN }, | ||
1201 | { "rx_symbol_error", GEN_STAT(mib.rx_sym), ETH_MIB_RX_SYM }, | ||
1202 | { "rx_pause", GEN_STAT(mib.rx_pause), ETH_MIB_RX_PAUSE }, | ||
1203 | { "rx_control", GEN_STAT(mib.rx_cntrl), ETH_MIB_RX_CNTRL }, | ||
1204 | |||
1205 | { "tx_good_octets", GEN_STAT(mib.tx_gd_octets), ETH_MIB_TX_GD_OCTETS }, | ||
1206 | { "tx_good_pkts", GEN_STAT(mib.tx_gd_pkts), ETH_MIB_TX_GD_PKTS }, | ||
1207 | { "tx_broadcast", GEN_STAT(mib.tx_brdcast), ETH_MIB_TX_BRDCAST }, | ||
1208 | { "tx_multicast", GEN_STAT(mib.tx_mult), ETH_MIB_TX_MULT }, | ||
1209 | { "tx_64_oct", GEN_STAT(mib.tx_64), ETH_MIB_TX_64 }, | ||
1210 | { "tx_65_127_oct", GEN_STAT(mib.tx_65_127), ETH_MIB_TX_65_127 }, | ||
1211 | { "tx_128_255_oct", GEN_STAT(mib.tx_128_255), ETH_MIB_TX_128_255 }, | ||
1212 | { "tx_256_511_oct", GEN_STAT(mib.tx_256_511), ETH_MIB_TX_256_511 }, | ||
1213 | { "tx_512_1023_oct", GEN_STAT(mib.tx_512_1023), ETH_MIB_TX_512_1023}, | ||
1214 | { "tx_1024_max_oct", GEN_STAT(mib.tx_1024_max), ETH_MIB_TX_1024_MAX }, | ||
1215 | { "tx_jabber", GEN_STAT(mib.tx_jab), ETH_MIB_TX_JAB }, | ||
1216 | { "tx_oversize", GEN_STAT(mib.tx_ovr), ETH_MIB_TX_OVR }, | ||
1217 | { "tx_fragment", GEN_STAT(mib.tx_frag), ETH_MIB_TX_FRAG }, | ||
1218 | { "tx_underrun", GEN_STAT(mib.tx_underrun), ETH_MIB_TX_UNDERRUN }, | ||
1219 | { "tx_collisions", GEN_STAT(mib.tx_col), ETH_MIB_TX_COL }, | ||
1220 | { "tx_single_collision", GEN_STAT(mib.tx_1_col), ETH_MIB_TX_1_COL }, | ||
1221 | { "tx_multiple_collision", GEN_STAT(mib.tx_m_col), ETH_MIB_TX_M_COL }, | ||
1222 | { "tx_excess_collision", GEN_STAT(mib.tx_ex_col), ETH_MIB_TX_EX_COL }, | ||
1223 | { "tx_late_collision", GEN_STAT(mib.tx_late), ETH_MIB_TX_LATE }, | ||
1224 | { "tx_deferred", GEN_STAT(mib.tx_def), ETH_MIB_TX_DEF }, | ||
1225 | { "tx_carrier_sense", GEN_STAT(mib.tx_crs), ETH_MIB_TX_CRS }, | ||
1226 | { "tx_pause", GEN_STAT(mib.tx_pause), ETH_MIB_TX_PAUSE }, | ||
1227 | |||
1228 | }; | ||
1229 | |||
1230 | #define BCM_ENET_STATS_LEN \ | ||
1231 | (sizeof(bcm_enet_gstrings_stats) / sizeof(struct bcm_enet_stats)) | ||
1232 | |||
1233 | static const u32 unused_mib_regs[] = { | ||
1234 | ETH_MIB_TX_ALL_OCTETS, | ||
1235 | ETH_MIB_TX_ALL_PKTS, | ||
1236 | ETH_MIB_RX_ALL_OCTETS, | ||
1237 | ETH_MIB_RX_ALL_PKTS, | ||
1238 | }; | ||
1239 | |||
1240 | |||
1241 | static void bcm_enet_get_drvinfo(struct net_device *netdev, | ||
1242 | struct ethtool_drvinfo *drvinfo) | ||
1243 | { | ||
1244 | strncpy(drvinfo->driver, bcm_enet_driver_name, 32); | ||
1245 | strncpy(drvinfo->version, bcm_enet_driver_version, 32); | ||
1246 | strncpy(drvinfo->fw_version, "N/A", 32); | ||
1247 | strncpy(drvinfo->bus_info, "bcm63xx", 32); | ||
1248 | drvinfo->n_stats = BCM_ENET_STATS_LEN; | ||
1249 | } | ||
1250 | |||
1251 | static int bcm_enet_get_stats_count(struct net_device *netdev) | ||
1252 | { | ||
1253 | return BCM_ENET_STATS_LEN; | ||
1254 | } | ||
1255 | |||
1256 | static void bcm_enet_get_strings(struct net_device *netdev, | ||
1257 | u32 stringset, u8 *data) | ||
1258 | { | ||
1259 | int i; | ||
1260 | |||
1261 | switch (stringset) { | ||
1262 | case ETH_SS_STATS: | ||
1263 | for (i = 0; i < BCM_ENET_STATS_LEN; i++) { | ||
1264 | memcpy(data + i * ETH_GSTRING_LEN, | ||
1265 | bcm_enet_gstrings_stats[i].stat_string, | ||
1266 | ETH_GSTRING_LEN); | ||
1267 | } | ||
1268 | break; | ||
1269 | } | ||
1270 | } | ||
1271 | |||
1272 | static void update_mib_counters(struct bcm_enet_priv *priv) | ||
1273 | { | ||
1274 | int i; | ||
1275 | |||
1276 | for (i = 0; i < BCM_ENET_STATS_LEN; i++) { | ||
1277 | const struct bcm_enet_stats *s; | ||
1278 | u32 val; | ||
1279 | char *p; | ||
1280 | |||
1281 | s = &bcm_enet_gstrings_stats[i]; | ||
1282 | if (s->mib_reg == -1) | ||
1283 | continue; | ||
1284 | |||
1285 | val = enet_readl(priv, ENET_MIB_REG(s->mib_reg)); | ||
1286 | p = (char *)priv + s->stat_offset; | ||
1287 | |||
1288 | if (s->sizeof_stat == sizeof(u64)) | ||
1289 | *(u64 *)p += val; | ||
1290 | else | ||
1291 | *(u32 *)p += val; | ||
1292 | } | ||
1293 | |||
1294 | /* also empty unused mib counters to make sure mib counter | ||
1295 | * overflow interrupt is cleared */ | ||
1296 | for (i = 0; i < ARRAY_SIZE(unused_mib_regs); i++) | ||
1297 | (void)enet_readl(priv, ENET_MIB_REG(unused_mib_regs[i])); | ||
1298 | } | ||
1299 | |||
1300 | static void bcm_enet_update_mib_counters_defer(struct work_struct *t) | ||
1301 | { | ||
1302 | struct bcm_enet_priv *priv; | ||
1303 | |||
1304 | priv = container_of(t, struct bcm_enet_priv, mib_update_task); | ||
1305 | mutex_lock(&priv->mib_update_lock); | ||
1306 | update_mib_counters(priv); | ||
1307 | mutex_unlock(&priv->mib_update_lock); | ||
1308 | |||
1309 | /* reenable mib interrupt */ | ||
1310 | if (netif_running(priv->net_dev)) | ||
1311 | enet_writel(priv, ENET_IR_MIB, ENET_IRMASK_REG); | ||
1312 | } | ||
1313 | |||
1314 | static void bcm_enet_get_ethtool_stats(struct net_device *netdev, | ||
1315 | struct ethtool_stats *stats, | ||
1316 | u64 *data) | ||
1317 | { | ||
1318 | struct bcm_enet_priv *priv; | ||
1319 | int i; | ||
1320 | |||
1321 | priv = netdev_priv(netdev); | ||
1322 | |||
1323 | mutex_lock(&priv->mib_update_lock); | ||
1324 | update_mib_counters(priv); | ||
1325 | |||
1326 | for (i = 0; i < BCM_ENET_STATS_LEN; i++) { | ||
1327 | const struct bcm_enet_stats *s; | ||
1328 | char *p; | ||
1329 | |||
1330 | s = &bcm_enet_gstrings_stats[i]; | ||
1331 | p = (char *)priv + s->stat_offset; | ||
1332 | data[i] = (s->sizeof_stat == sizeof(u64)) ? | ||
1333 | *(u64 *)p : *(u32 *)p; | ||
1334 | } | ||
1335 | mutex_unlock(&priv->mib_update_lock); | ||
1336 | } | ||
1337 | |||
1338 | static int bcm_enet_get_settings(struct net_device *dev, | ||
1339 | struct ethtool_cmd *cmd) | ||
1340 | { | ||
1341 | struct bcm_enet_priv *priv; | ||
1342 | |||
1343 | priv = netdev_priv(dev); | ||
1344 | |||
1345 | cmd->maxrxpkt = 0; | ||
1346 | cmd->maxtxpkt = 0; | ||
1347 | |||
1348 | if (priv->has_phy) { | ||
1349 | if (!priv->phydev) | ||
1350 | return -ENODEV; | ||
1351 | return phy_ethtool_gset(priv->phydev, cmd); | ||
1352 | } else { | ||
1353 | cmd->autoneg = 0; | ||
1354 | cmd->speed = (priv->force_speed_100) ? SPEED_100 : SPEED_10; | ||
1355 | cmd->duplex = (priv->force_duplex_full) ? | ||
1356 | DUPLEX_FULL : DUPLEX_HALF; | ||
1357 | cmd->supported = ADVERTISED_10baseT_Half | | ||
1358 | ADVERTISED_10baseT_Full | | ||
1359 | ADVERTISED_100baseT_Half | | ||
1360 | ADVERTISED_100baseT_Full; | ||
1361 | cmd->advertising = 0; | ||
1362 | cmd->port = PORT_MII; | ||
1363 | cmd->transceiver = XCVR_EXTERNAL; | ||
1364 | } | ||
1365 | return 0; | ||
1366 | } | ||
1367 | |||
1368 | static int bcm_enet_set_settings(struct net_device *dev, | ||
1369 | struct ethtool_cmd *cmd) | ||
1370 | { | ||
1371 | struct bcm_enet_priv *priv; | ||
1372 | |||
1373 | priv = netdev_priv(dev); | ||
1374 | if (priv->has_phy) { | ||
1375 | if (!priv->phydev) | ||
1376 | return -ENODEV; | ||
1377 | return phy_ethtool_sset(priv->phydev, cmd); | ||
1378 | } else { | ||
1379 | |||
1380 | if (cmd->autoneg || | ||
1381 | (cmd->speed != SPEED_100 && cmd->speed != SPEED_10) || | ||
1382 | cmd->port != PORT_MII) | ||
1383 | return -EINVAL; | ||
1384 | |||
1385 | priv->force_speed_100 = (cmd->speed == SPEED_100) ? 1 : 0; | ||
1386 | priv->force_duplex_full = (cmd->duplex == DUPLEX_FULL) ? 1 : 0; | ||
1387 | |||
1388 | if (netif_running(dev)) | ||
1389 | bcm_enet_adjust_link(dev); | ||
1390 | return 0; | ||
1391 | } | ||
1392 | } | ||
1393 | |||
1394 | static void bcm_enet_get_ringparam(struct net_device *dev, | ||
1395 | struct ethtool_ringparam *ering) | ||
1396 | { | ||
1397 | struct bcm_enet_priv *priv; | ||
1398 | |||
1399 | priv = netdev_priv(dev); | ||
1400 | |||
1401 | /* rx/tx ring is actually only limited by memory */ | ||
1402 | ering->rx_max_pending = 8192; | ||
1403 | ering->tx_max_pending = 8192; | ||
1404 | ering->rx_mini_max_pending = 0; | ||
1405 | ering->rx_jumbo_max_pending = 0; | ||
1406 | ering->rx_pending = priv->rx_ring_size; | ||
1407 | ering->tx_pending = priv->tx_ring_size; | ||
1408 | } | ||
1409 | |||
1410 | static int bcm_enet_set_ringparam(struct net_device *dev, | ||
1411 | struct ethtool_ringparam *ering) | ||
1412 | { | ||
1413 | struct bcm_enet_priv *priv; | ||
1414 | int was_running; | ||
1415 | |||
1416 | priv = netdev_priv(dev); | ||
1417 | |||
1418 | was_running = 0; | ||
1419 | if (netif_running(dev)) { | ||
1420 | bcm_enet_stop(dev); | ||
1421 | was_running = 1; | ||
1422 | } | ||
1423 | |||
1424 | priv->rx_ring_size = ering->rx_pending; | ||
1425 | priv->tx_ring_size = ering->tx_pending; | ||
1426 | |||
1427 | if (was_running) { | ||
1428 | int err; | ||
1429 | |||
1430 | err = bcm_enet_open(dev); | ||
1431 | if (err) | ||
1432 | dev_close(dev); | ||
1433 | else | ||
1434 | bcm_enet_set_multicast_list(dev); | ||
1435 | } | ||
1436 | return 0; | ||
1437 | } | ||
1438 | |||
1439 | static void bcm_enet_get_pauseparam(struct net_device *dev, | ||
1440 | struct ethtool_pauseparam *ecmd) | ||
1441 | { | ||
1442 | struct bcm_enet_priv *priv; | ||
1443 | |||
1444 | priv = netdev_priv(dev); | ||
1445 | ecmd->autoneg = priv->pause_auto; | ||
1446 | ecmd->rx_pause = priv->pause_rx; | ||
1447 | ecmd->tx_pause = priv->pause_tx; | ||
1448 | } | ||
1449 | |||
1450 | static int bcm_enet_set_pauseparam(struct net_device *dev, | ||
1451 | struct ethtool_pauseparam *ecmd) | ||
1452 | { | ||
1453 | struct bcm_enet_priv *priv; | ||
1454 | |||
1455 | priv = netdev_priv(dev); | ||
1456 | |||
1457 | if (priv->has_phy) { | ||
1458 | if (ecmd->autoneg && (ecmd->rx_pause != ecmd->tx_pause)) { | ||
1459 | /* asymetric pause mode not supported, | ||
1460 | * actually possible but integrated PHY has RO | ||
1461 | * asym_pause bit */ | ||
1462 | return -EINVAL; | ||
1463 | } | ||
1464 | } else { | ||
1465 | /* no pause autoneg on direct mii connection */ | ||
1466 | if (ecmd->autoneg) | ||
1467 | return -EINVAL; | ||
1468 | } | ||
1469 | |||
1470 | priv->pause_auto = ecmd->autoneg; | ||
1471 | priv->pause_rx = ecmd->rx_pause; | ||
1472 | priv->pause_tx = ecmd->tx_pause; | ||
1473 | |||
1474 | return 0; | ||
1475 | } | ||
1476 | |||
1477 | static struct ethtool_ops bcm_enet_ethtool_ops = { | ||
1478 | .get_strings = bcm_enet_get_strings, | ||
1479 | .get_stats_count = bcm_enet_get_stats_count, | ||
1480 | .get_ethtool_stats = bcm_enet_get_ethtool_stats, | ||
1481 | .get_settings = bcm_enet_get_settings, | ||
1482 | .set_settings = bcm_enet_set_settings, | ||
1483 | .get_drvinfo = bcm_enet_get_drvinfo, | ||
1484 | .get_link = ethtool_op_get_link, | ||
1485 | .get_ringparam = bcm_enet_get_ringparam, | ||
1486 | .set_ringparam = bcm_enet_set_ringparam, | ||
1487 | .get_pauseparam = bcm_enet_get_pauseparam, | ||
1488 | .set_pauseparam = bcm_enet_set_pauseparam, | ||
1489 | }; | ||
1490 | |||
1491 | static int bcm_enet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | ||
1492 | { | ||
1493 | struct bcm_enet_priv *priv; | ||
1494 | |||
1495 | priv = netdev_priv(dev); | ||
1496 | if (priv->has_phy) { | ||
1497 | if (!priv->phydev) | ||
1498 | return -ENODEV; | ||
1499 | return phy_mii_ioctl(priv->phydev, if_mii(rq), cmd); | ||
1500 | } else { | ||
1501 | struct mii_if_info mii; | ||
1502 | |||
1503 | mii.dev = dev; | ||
1504 | mii.mdio_read = bcm_enet_mdio_read_mii; | ||
1505 | mii.mdio_write = bcm_enet_mdio_write_mii; | ||
1506 | mii.phy_id = 0; | ||
1507 | mii.phy_id_mask = 0x3f; | ||
1508 | mii.reg_num_mask = 0x1f; | ||
1509 | return generic_mii_ioctl(&mii, if_mii(rq), cmd, NULL); | ||
1510 | } | ||
1511 | } | ||
1512 | |||
1513 | /* | ||
1514 | * calculate actual hardware mtu | ||
1515 | */ | ||
1516 | static int compute_hw_mtu(struct bcm_enet_priv *priv, int mtu) | ||
1517 | { | ||
1518 | int actual_mtu; | ||
1519 | |||
1520 | actual_mtu = mtu; | ||
1521 | |||
1522 | /* add ethernet header + vlan tag size */ | ||
1523 | actual_mtu += VLAN_ETH_HLEN; | ||
1524 | |||
1525 | if (actual_mtu < 64 || actual_mtu > BCMENET_MAX_MTU) | ||
1526 | return -EINVAL; | ||
1527 | |||
1528 | /* | ||
1529 | * setup maximum size before we get overflow mark in | ||
1530 | * descriptor, note that this will not prevent reception of | ||
1531 | * big frames, they will be split into multiple buffers | ||
1532 | * anyway | ||
1533 | */ | ||
1534 | priv->hw_mtu = actual_mtu; | ||
1535 | |||
1536 | /* | ||
1537 | * align rx buffer size to dma burst len, account FCS since | ||
1538 | * it's appended | ||
1539 | */ | ||
1540 | priv->rx_skb_size = ALIGN(actual_mtu + ETH_FCS_LEN, | ||
1541 | BCMENET_DMA_MAXBURST * 4); | ||
1542 | return 0; | ||
1543 | } | ||
1544 | |||
1545 | /* | ||
1546 | * adjust mtu, can't be called while device is running | ||
1547 | */ | ||
1548 | static int bcm_enet_change_mtu(struct net_device *dev, int new_mtu) | ||
1549 | { | ||
1550 | int ret; | ||
1551 | |||
1552 | if (netif_running(dev)) | ||
1553 | return -EBUSY; | ||
1554 | |||
1555 | ret = compute_hw_mtu(netdev_priv(dev), new_mtu); | ||
1556 | if (ret) | ||
1557 | return ret; | ||
1558 | dev->mtu = new_mtu; | ||
1559 | return 0; | ||
1560 | } | ||
1561 | |||
1562 | /* | ||
1563 | * preinit hardware to allow mii operation while device is down | ||
1564 | */ | ||
1565 | static void bcm_enet_hw_preinit(struct bcm_enet_priv *priv) | ||
1566 | { | ||
1567 | u32 val; | ||
1568 | int limit; | ||
1569 | |||
1570 | /* make sure mac is disabled */ | ||
1571 | bcm_enet_disable_mac(priv); | ||
1572 | |||
1573 | /* soft reset mac */ | ||
1574 | val = ENET_CTL_SRESET_MASK; | ||
1575 | enet_writel(priv, val, ENET_CTL_REG); | ||
1576 | wmb(); | ||
1577 | |||
1578 | limit = 1000; | ||
1579 | do { | ||
1580 | val = enet_readl(priv, ENET_CTL_REG); | ||
1581 | if (!(val & ENET_CTL_SRESET_MASK)) | ||
1582 | break; | ||
1583 | udelay(1); | ||
1584 | } while (limit--); | ||
1585 | |||
1586 | /* select correct mii interface */ | ||
1587 | val = enet_readl(priv, ENET_CTL_REG); | ||
1588 | if (priv->use_external_mii) | ||
1589 | val |= ENET_CTL_EPHYSEL_MASK; | ||
1590 | else | ||
1591 | val &= ~ENET_CTL_EPHYSEL_MASK; | ||
1592 | enet_writel(priv, val, ENET_CTL_REG); | ||
1593 | |||
1594 | /* turn on mdc clock */ | ||
1595 | enet_writel(priv, (0x1f << ENET_MIISC_MDCFREQDIV_SHIFT) | | ||
1596 | ENET_MIISC_PREAMBLEEN_MASK, ENET_MIISC_REG); | ||
1597 | |||
1598 | /* set mib counters to self-clear when read */ | ||
1599 | val = enet_readl(priv, ENET_MIBCTL_REG); | ||
1600 | val |= ENET_MIBCTL_RDCLEAR_MASK; | ||
1601 | enet_writel(priv, val, ENET_MIBCTL_REG); | ||
1602 | } | ||
1603 | |||
1604 | static const struct net_device_ops bcm_enet_ops = { | ||
1605 | .ndo_open = bcm_enet_open, | ||
1606 | .ndo_stop = bcm_enet_stop, | ||
1607 | .ndo_start_xmit = bcm_enet_start_xmit, | ||
1608 | .ndo_get_stats = bcm_enet_get_stats, | ||
1609 | .ndo_set_mac_address = bcm_enet_set_mac_address, | ||
1610 | .ndo_set_multicast_list = bcm_enet_set_multicast_list, | ||
1611 | .ndo_do_ioctl = bcm_enet_ioctl, | ||
1612 | .ndo_change_mtu = bcm_enet_change_mtu, | ||
1613 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
1614 | .ndo_poll_controller = bcm_enet_netpoll, | ||
1615 | #endif | ||
1616 | }; | ||
1617 | |||
1618 | /* | ||
1619 | * allocate netdevice, request register memory and register device. | ||
1620 | */ | ||
1621 | static int __devinit bcm_enet_probe(struct platform_device *pdev) | ||
1622 | { | ||
1623 | struct bcm_enet_priv *priv; | ||
1624 | struct net_device *dev; | ||
1625 | struct bcm63xx_enet_platform_data *pd; | ||
1626 | struct resource *res_mem, *res_irq, *res_irq_rx, *res_irq_tx; | ||
1627 | struct mii_bus *bus; | ||
1628 | const char *clk_name; | ||
1629 | unsigned int iomem_size; | ||
1630 | int i, ret; | ||
1631 | |||
1632 | /* stop if shared driver failed, assume driver->probe will be | ||
1633 | * called in the same order we register devices (correct ?) */ | ||
1634 | if (!bcm_enet_shared_base) | ||
1635 | return -ENODEV; | ||
1636 | |||
1637 | res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1638 | res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
1639 | res_irq_rx = platform_get_resource(pdev, IORESOURCE_IRQ, 1); | ||
1640 | res_irq_tx = platform_get_resource(pdev, IORESOURCE_IRQ, 2); | ||
1641 | if (!res_mem || !res_irq || !res_irq_rx || !res_irq_tx) | ||
1642 | return -ENODEV; | ||
1643 | |||
1644 | ret = 0; | ||
1645 | dev = alloc_etherdev(sizeof(*priv)); | ||
1646 | if (!dev) | ||
1647 | return -ENOMEM; | ||
1648 | priv = netdev_priv(dev); | ||
1649 | memset(priv, 0, sizeof(*priv)); | ||
1650 | |||
1651 | ret = compute_hw_mtu(priv, dev->mtu); | ||
1652 | if (ret) | ||
1653 | goto out; | ||
1654 | |||
1655 | iomem_size = res_mem->end - res_mem->start + 1; | ||
1656 | if (!request_mem_region(res_mem->start, iomem_size, "bcm63xx_enet")) { | ||
1657 | ret = -EBUSY; | ||
1658 | goto out; | ||
1659 | } | ||
1660 | |||
1661 | priv->base = ioremap(res_mem->start, iomem_size); | ||
1662 | if (priv->base == NULL) { | ||
1663 | ret = -ENOMEM; | ||
1664 | goto out_release_mem; | ||
1665 | } | ||
1666 | dev->irq = priv->irq = res_irq->start; | ||
1667 | priv->irq_rx = res_irq_rx->start; | ||
1668 | priv->irq_tx = res_irq_tx->start; | ||
1669 | priv->mac_id = pdev->id; | ||
1670 | |||
1671 | /* get rx & tx dma channel id for this mac */ | ||
1672 | if (priv->mac_id == 0) { | ||
1673 | priv->rx_chan = 0; | ||
1674 | priv->tx_chan = 1; | ||
1675 | clk_name = "enet0"; | ||
1676 | } else { | ||
1677 | priv->rx_chan = 2; | ||
1678 | priv->tx_chan = 3; | ||
1679 | clk_name = "enet1"; | ||
1680 | } | ||
1681 | |||
1682 | priv->mac_clk = clk_get(&pdev->dev, clk_name); | ||
1683 | if (IS_ERR(priv->mac_clk)) { | ||
1684 | ret = PTR_ERR(priv->mac_clk); | ||
1685 | goto out_unmap; | ||
1686 | } | ||
1687 | clk_enable(priv->mac_clk); | ||
1688 | |||
1689 | /* initialize default and fetch platform data */ | ||
1690 | priv->rx_ring_size = BCMENET_DEF_RX_DESC; | ||
1691 | priv->tx_ring_size = BCMENET_DEF_TX_DESC; | ||
1692 | |||
1693 | pd = pdev->dev.platform_data; | ||
1694 | if (pd) { | ||
1695 | memcpy(dev->dev_addr, pd->mac_addr, ETH_ALEN); | ||
1696 | priv->has_phy = pd->has_phy; | ||
1697 | priv->phy_id = pd->phy_id; | ||
1698 | priv->has_phy_interrupt = pd->has_phy_interrupt; | ||
1699 | priv->phy_interrupt = pd->phy_interrupt; | ||
1700 | priv->use_external_mii = !pd->use_internal_phy; | ||
1701 | priv->pause_auto = pd->pause_auto; | ||
1702 | priv->pause_rx = pd->pause_rx; | ||
1703 | priv->pause_tx = pd->pause_tx; | ||
1704 | priv->force_duplex_full = pd->force_duplex_full; | ||
1705 | priv->force_speed_100 = pd->force_speed_100; | ||
1706 | } | ||
1707 | |||
1708 | if (priv->mac_id == 0 && priv->has_phy && !priv->use_external_mii) { | ||
1709 | /* using internal PHY, enable clock */ | ||
1710 | priv->phy_clk = clk_get(&pdev->dev, "ephy"); | ||
1711 | if (IS_ERR(priv->phy_clk)) { | ||
1712 | ret = PTR_ERR(priv->phy_clk); | ||
1713 | priv->phy_clk = NULL; | ||
1714 | goto out_put_clk_mac; | ||
1715 | } | ||
1716 | clk_enable(priv->phy_clk); | ||
1717 | } | ||
1718 | |||
1719 | /* do minimal hardware init to be able to probe mii bus */ | ||
1720 | bcm_enet_hw_preinit(priv); | ||
1721 | |||
1722 | /* MII bus registration */ | ||
1723 | if (priv->has_phy) { | ||
1724 | |||
1725 | priv->mii_bus = mdiobus_alloc(); | ||
1726 | if (!priv->mii_bus) { | ||
1727 | ret = -ENOMEM; | ||
1728 | goto out_uninit_hw; | ||
1729 | } | ||
1730 | |||
1731 | bus = priv->mii_bus; | ||
1732 | bus->name = "bcm63xx_enet MII bus"; | ||
1733 | bus->parent = &pdev->dev; | ||
1734 | bus->priv = priv; | ||
1735 | bus->read = bcm_enet_mdio_read_phylib; | ||
1736 | bus->write = bcm_enet_mdio_write_phylib; | ||
1737 | sprintf(bus->id, "%d", priv->mac_id); | ||
1738 | |||
1739 | /* only probe bus where we think the PHY is, because | ||
1740 | * the mdio read operation return 0 instead of 0xffff | ||
1741 | * if a slave is not present on hw */ | ||
1742 | bus->phy_mask = ~(1 << priv->phy_id); | ||
1743 | |||
1744 | bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); | ||
1745 | if (!bus->irq) { | ||
1746 | ret = -ENOMEM; | ||
1747 | goto out_free_mdio; | ||
1748 | } | ||
1749 | |||
1750 | if (priv->has_phy_interrupt) | ||
1751 | bus->irq[priv->phy_id] = priv->phy_interrupt; | ||
1752 | else | ||
1753 | bus->irq[priv->phy_id] = PHY_POLL; | ||
1754 | |||
1755 | ret = mdiobus_register(bus); | ||
1756 | if (ret) { | ||
1757 | dev_err(&pdev->dev, "unable to register mdio bus\n"); | ||
1758 | goto out_free_mdio; | ||
1759 | } | ||
1760 | } else { | ||
1761 | |||
1762 | /* run platform code to initialize PHY device */ | ||
1763 | if (pd->mii_config && | ||
1764 | pd->mii_config(dev, 1, bcm_enet_mdio_read_mii, | ||
1765 | bcm_enet_mdio_write_mii)) { | ||
1766 | dev_err(&pdev->dev, "unable to configure mdio bus\n"); | ||
1767 | goto out_uninit_hw; | ||
1768 | } | ||
1769 | } | ||
1770 | |||
1771 | spin_lock_init(&priv->rx_lock); | ||
1772 | |||
1773 | /* init rx timeout (used for oom) */ | ||
1774 | init_timer(&priv->rx_timeout); | ||
1775 | priv->rx_timeout.function = bcm_enet_refill_rx_timer; | ||
1776 | priv->rx_timeout.data = (unsigned long)dev; | ||
1777 | |||
1778 | /* init the mib update lock&work */ | ||
1779 | mutex_init(&priv->mib_update_lock); | ||
1780 | INIT_WORK(&priv->mib_update_task, bcm_enet_update_mib_counters_defer); | ||
1781 | |||
1782 | /* zero mib counters */ | ||
1783 | for (i = 0; i < ENET_MIB_REG_COUNT; i++) | ||
1784 | enet_writel(priv, 0, ENET_MIB_REG(i)); | ||
1785 | |||
1786 | /* register netdevice */ | ||
1787 | dev->netdev_ops = &bcm_enet_ops; | ||
1788 | netif_napi_add(dev, &priv->napi, bcm_enet_poll, 16); | ||
1789 | |||
1790 | SET_ETHTOOL_OPS(dev, &bcm_enet_ethtool_ops); | ||
1791 | SET_NETDEV_DEV(dev, &pdev->dev); | ||
1792 | |||
1793 | ret = register_netdev(dev); | ||
1794 | if (ret) | ||
1795 | goto out_unregister_mdio; | ||
1796 | |||
1797 | netif_carrier_off(dev); | ||
1798 | platform_set_drvdata(pdev, dev); | ||
1799 | priv->pdev = pdev; | ||
1800 | priv->net_dev = dev; | ||
1801 | |||
1802 | return 0; | ||
1803 | |||
1804 | out_unregister_mdio: | ||
1805 | if (priv->mii_bus) { | ||
1806 | mdiobus_unregister(priv->mii_bus); | ||
1807 | kfree(priv->mii_bus->irq); | ||
1808 | } | ||
1809 | |||
1810 | out_free_mdio: | ||
1811 | if (priv->mii_bus) | ||
1812 | mdiobus_free(priv->mii_bus); | ||
1813 | |||
1814 | out_uninit_hw: | ||
1815 | /* turn off mdc clock */ | ||
1816 | enet_writel(priv, 0, ENET_MIISC_REG); | ||
1817 | if (priv->phy_clk) { | ||
1818 | clk_disable(priv->phy_clk); | ||
1819 | clk_put(priv->phy_clk); | ||
1820 | } | ||
1821 | |||
1822 | out_put_clk_mac: | ||
1823 | clk_disable(priv->mac_clk); | ||
1824 | clk_put(priv->mac_clk); | ||
1825 | |||
1826 | out_unmap: | ||
1827 | iounmap(priv->base); | ||
1828 | |||
1829 | out_release_mem: | ||
1830 | release_mem_region(res_mem->start, iomem_size); | ||
1831 | out: | ||
1832 | free_netdev(dev); | ||
1833 | return ret; | ||
1834 | } | ||
1835 | |||
1836 | |||
1837 | /* | ||
1838 | * exit func, stops hardware and unregisters netdevice | ||
1839 | */ | ||
1840 | static int __devexit bcm_enet_remove(struct platform_device *pdev) | ||
1841 | { | ||
1842 | struct bcm_enet_priv *priv; | ||
1843 | struct net_device *dev; | ||
1844 | struct resource *res; | ||
1845 | |||
1846 | /* stop netdevice */ | ||
1847 | dev = platform_get_drvdata(pdev); | ||
1848 | priv = netdev_priv(dev); | ||
1849 | unregister_netdev(dev); | ||
1850 | |||
1851 | /* turn off mdc clock */ | ||
1852 | enet_writel(priv, 0, ENET_MIISC_REG); | ||
1853 | |||
1854 | if (priv->has_phy) { | ||
1855 | mdiobus_unregister(priv->mii_bus); | ||
1856 | kfree(priv->mii_bus->irq); | ||
1857 | mdiobus_free(priv->mii_bus); | ||
1858 | } else { | ||
1859 | struct bcm63xx_enet_platform_data *pd; | ||
1860 | |||
1861 | pd = pdev->dev.platform_data; | ||
1862 | if (pd && pd->mii_config) | ||
1863 | pd->mii_config(dev, 0, bcm_enet_mdio_read_mii, | ||
1864 | bcm_enet_mdio_write_mii); | ||
1865 | } | ||
1866 | |||
1867 | /* release device resources */ | ||
1868 | iounmap(priv->base); | ||
1869 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1870 | release_mem_region(res->start, res->end - res->start + 1); | ||
1871 | |||
1872 | /* disable hw block clocks */ | ||
1873 | if (priv->phy_clk) { | ||
1874 | clk_disable(priv->phy_clk); | ||
1875 | clk_put(priv->phy_clk); | ||
1876 | } | ||
1877 | clk_disable(priv->mac_clk); | ||
1878 | clk_put(priv->mac_clk); | ||
1879 | |||
1880 | platform_set_drvdata(pdev, NULL); | ||
1881 | free_netdev(dev); | ||
1882 | return 0; | ||
1883 | } | ||
1884 | |||
1885 | struct platform_driver bcm63xx_enet_driver = { | ||
1886 | .probe = bcm_enet_probe, | ||
1887 | .remove = __devexit_p(bcm_enet_remove), | ||
1888 | .driver = { | ||
1889 | .name = "bcm63xx_enet", | ||
1890 | .owner = THIS_MODULE, | ||
1891 | }, | ||
1892 | }; | ||
1893 | |||
1894 | /* | ||
1895 | * reserve & remap memory space shared between all macs | ||
1896 | */ | ||
1897 | static int __devinit bcm_enet_shared_probe(struct platform_device *pdev) | ||
1898 | { | ||
1899 | struct resource *res; | ||
1900 | unsigned int iomem_size; | ||
1901 | |||
1902 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1903 | if (!res) | ||
1904 | return -ENODEV; | ||
1905 | |||
1906 | iomem_size = res->end - res->start + 1; | ||
1907 | if (!request_mem_region(res->start, iomem_size, "bcm63xx_enet_dma")) | ||
1908 | return -EBUSY; | ||
1909 | |||
1910 | bcm_enet_shared_base = ioremap(res->start, iomem_size); | ||
1911 | if (!bcm_enet_shared_base) { | ||
1912 | release_mem_region(res->start, iomem_size); | ||
1913 | return -ENOMEM; | ||
1914 | } | ||
1915 | return 0; | ||
1916 | } | ||
1917 | |||
1918 | static int __devexit bcm_enet_shared_remove(struct platform_device *pdev) | ||
1919 | { | ||
1920 | struct resource *res; | ||
1921 | |||
1922 | iounmap(bcm_enet_shared_base); | ||
1923 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1924 | release_mem_region(res->start, res->end - res->start + 1); | ||
1925 | return 0; | ||
1926 | } | ||
1927 | |||
1928 | /* | ||
1929 | * this "shared" driver is needed because both macs share a single | ||
1930 | * address space | ||
1931 | */ | ||
1932 | struct platform_driver bcm63xx_enet_shared_driver = { | ||
1933 | .probe = bcm_enet_shared_probe, | ||
1934 | .remove = __devexit_p(bcm_enet_shared_remove), | ||
1935 | .driver = { | ||
1936 | .name = "bcm63xx_enet_shared", | ||
1937 | .owner = THIS_MODULE, | ||
1938 | }, | ||
1939 | }; | ||
1940 | |||
1941 | /* | ||
1942 | * entry point | ||
1943 | */ | ||
1944 | static int __init bcm_enet_init(void) | ||
1945 | { | ||
1946 | int ret; | ||
1947 | |||
1948 | ret = platform_driver_register(&bcm63xx_enet_shared_driver); | ||
1949 | if (ret) | ||
1950 | return ret; | ||
1951 | |||
1952 | ret = platform_driver_register(&bcm63xx_enet_driver); | ||
1953 | if (ret) | ||
1954 | platform_driver_unregister(&bcm63xx_enet_shared_driver); | ||
1955 | |||
1956 | return ret; | ||
1957 | } | ||
1958 | |||
1959 | static void __exit bcm_enet_exit(void) | ||
1960 | { | ||
1961 | platform_driver_unregister(&bcm63xx_enet_driver); | ||
1962 | platform_driver_unregister(&bcm63xx_enet_shared_driver); | ||
1963 | } | ||
1964 | |||
1965 | |||
1966 | module_init(bcm_enet_init); | ||
1967 | module_exit(bcm_enet_exit); | ||
1968 | |||
1969 | MODULE_DESCRIPTION("BCM63xx internal ethernet mac driver"); | ||
1970 | MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>"); | ||
1971 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/net/bcm63xx_enet.h b/drivers/net/bcm63xx_enet.h new file mode 100644 index 000000000000..bd3684d42d74 --- /dev/null +++ b/drivers/net/bcm63xx_enet.h | |||
@@ -0,0 +1,303 @@ | |||
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 | /* | ||
27 | * hardware maximum rx/tx packet size including FCS, max mtu is | ||
28 | * actually 2047, but if we set max rx size register to 2047 we won't | ||
29 | * get overflow information if packet size is 2048 or above | ||
30 | */ | ||
31 | #define BCMENET_MAX_MTU 2046 | ||
32 | |||
33 | /* | ||
34 | * rx/tx dma descriptor | ||
35 | */ | ||
36 | struct bcm_enet_desc { | ||
37 | u32 len_stat; | ||
38 | u32 address; | ||
39 | }; | ||
40 | |||
41 | #define DMADESC_LENGTH_SHIFT 16 | ||
42 | #define DMADESC_LENGTH_MASK (0xfff << DMADESC_LENGTH_SHIFT) | ||
43 | #define DMADESC_OWNER_MASK (1 << 15) | ||
44 | #define DMADESC_EOP_MASK (1 << 14) | ||
45 | #define DMADESC_SOP_MASK (1 << 13) | ||
46 | #define DMADESC_ESOP_MASK (DMADESC_EOP_MASK | DMADESC_SOP_MASK) | ||
47 | #define DMADESC_WRAP_MASK (1 << 12) | ||
48 | |||
49 | #define DMADESC_UNDER_MASK (1 << 9) | ||
50 | #define DMADESC_APPEND_CRC (1 << 8) | ||
51 | #define DMADESC_OVSIZE_MASK (1 << 4) | ||
52 | #define DMADESC_RXER_MASK (1 << 2) | ||
53 | #define DMADESC_CRC_MASK (1 << 1) | ||
54 | #define DMADESC_OV_MASK (1 << 0) | ||
55 | #define DMADESC_ERR_MASK (DMADESC_UNDER_MASK | \ | ||
56 | DMADESC_OVSIZE_MASK | \ | ||
57 | DMADESC_RXER_MASK | \ | ||
58 | DMADESC_CRC_MASK | \ | ||
59 | DMADESC_OV_MASK) | ||
60 | |||
61 | |||
62 | /* | ||
63 | * MIB Counters register definitions | ||
64 | */ | ||
65 | #define ETH_MIB_TX_GD_OCTETS 0 | ||
66 | #define ETH_MIB_TX_GD_PKTS 1 | ||
67 | #define ETH_MIB_TX_ALL_OCTETS 2 | ||
68 | #define ETH_MIB_TX_ALL_PKTS 3 | ||
69 | #define ETH_MIB_TX_BRDCAST 4 | ||
70 | #define ETH_MIB_TX_MULT 5 | ||
71 | #define ETH_MIB_TX_64 6 | ||
72 | #define ETH_MIB_TX_65_127 7 | ||
73 | #define ETH_MIB_TX_128_255 8 | ||
74 | #define ETH_MIB_TX_256_511 9 | ||
75 | #define ETH_MIB_TX_512_1023 10 | ||
76 | #define ETH_MIB_TX_1024_MAX 11 | ||
77 | #define ETH_MIB_TX_JAB 12 | ||
78 | #define ETH_MIB_TX_OVR 13 | ||
79 | #define ETH_MIB_TX_FRAG 14 | ||
80 | #define ETH_MIB_TX_UNDERRUN 15 | ||
81 | #define ETH_MIB_TX_COL 16 | ||
82 | #define ETH_MIB_TX_1_COL 17 | ||
83 | #define ETH_MIB_TX_M_COL 18 | ||
84 | #define ETH_MIB_TX_EX_COL 19 | ||
85 | #define ETH_MIB_TX_LATE 20 | ||
86 | #define ETH_MIB_TX_DEF 21 | ||
87 | #define ETH_MIB_TX_CRS 22 | ||
88 | #define ETH_MIB_TX_PAUSE 23 | ||
89 | |||
90 | #define ETH_MIB_RX_GD_OCTETS 32 | ||
91 | #define ETH_MIB_RX_GD_PKTS 33 | ||
92 | #define ETH_MIB_RX_ALL_OCTETS 34 | ||
93 | #define ETH_MIB_RX_ALL_PKTS 35 | ||
94 | #define ETH_MIB_RX_BRDCAST 36 | ||
95 | #define ETH_MIB_RX_MULT 37 | ||
96 | #define ETH_MIB_RX_64 38 | ||
97 | #define ETH_MIB_RX_65_127 39 | ||
98 | #define ETH_MIB_RX_128_255 40 | ||
99 | #define ETH_MIB_RX_256_511 41 | ||
100 | #define ETH_MIB_RX_512_1023 42 | ||
101 | #define ETH_MIB_RX_1024_MAX 43 | ||
102 | #define ETH_MIB_RX_JAB 44 | ||
103 | #define ETH_MIB_RX_OVR 45 | ||
104 | #define ETH_MIB_RX_FRAG 46 | ||
105 | #define ETH_MIB_RX_DROP 47 | ||
106 | #define ETH_MIB_RX_CRC_ALIGN 48 | ||
107 | #define ETH_MIB_RX_UND 49 | ||
108 | #define ETH_MIB_RX_CRC 50 | ||
109 | #define ETH_MIB_RX_ALIGN 51 | ||
110 | #define ETH_MIB_RX_SYM 52 | ||
111 | #define ETH_MIB_RX_PAUSE 53 | ||
112 | #define ETH_MIB_RX_CNTRL 54 | ||
113 | |||
114 | |||
115 | struct bcm_enet_mib_counters { | ||
116 | u64 tx_gd_octets; | ||
117 | u32 tx_gd_pkts; | ||
118 | u32 tx_all_octets; | ||
119 | u32 tx_all_pkts; | ||
120 | u32 tx_brdcast; | ||
121 | u32 tx_mult; | ||
122 | u32 tx_64; | ||
123 | u32 tx_65_127; | ||
124 | u32 tx_128_255; | ||
125 | u32 tx_256_511; | ||
126 | u32 tx_512_1023; | ||
127 | u32 tx_1024_max; | ||
128 | u32 tx_jab; | ||
129 | u32 tx_ovr; | ||
130 | u32 tx_frag; | ||
131 | u32 tx_underrun; | ||
132 | u32 tx_col; | ||
133 | u32 tx_1_col; | ||
134 | u32 tx_m_col; | ||
135 | u32 tx_ex_col; | ||
136 | u32 tx_late; | ||
137 | u32 tx_def; | ||
138 | u32 tx_crs; | ||
139 | u32 tx_pause; | ||
140 | u64 rx_gd_octets; | ||
141 | u32 rx_gd_pkts; | ||
142 | u32 rx_all_octets; | ||
143 | u32 rx_all_pkts; | ||
144 | u32 rx_brdcast; | ||
145 | u32 rx_mult; | ||
146 | u32 rx_64; | ||
147 | u32 rx_65_127; | ||
148 | u32 rx_128_255; | ||
149 | u32 rx_256_511; | ||
150 | u32 rx_512_1023; | ||
151 | u32 rx_1024_max; | ||
152 | u32 rx_jab; | ||
153 | u32 rx_ovr; | ||
154 | u32 rx_frag; | ||
155 | u32 rx_drop; | ||
156 | u32 rx_crc_align; | ||
157 | u32 rx_und; | ||
158 | u32 rx_crc; | ||
159 | u32 rx_align; | ||
160 | u32 rx_sym; | ||
161 | u32 rx_pause; | ||
162 | u32 rx_cntrl; | ||
163 | }; | ||
164 | |||
165 | |||
166 | struct bcm_enet_priv { | ||
167 | |||
168 | /* mac id (from platform device id) */ | ||
169 | int mac_id; | ||
170 | |||
171 | /* base remapped address of device */ | ||
172 | void __iomem *base; | ||
173 | |||
174 | /* mac irq, rx_dma irq, tx_dma irq */ | ||
175 | int irq; | ||
176 | int irq_rx; | ||
177 | int irq_tx; | ||
178 | |||
179 | /* hw view of rx & tx dma ring */ | ||
180 | dma_addr_t rx_desc_dma; | ||
181 | dma_addr_t tx_desc_dma; | ||
182 | |||
183 | /* allocated size (in bytes) for rx & tx dma ring */ | ||
184 | unsigned int rx_desc_alloc_size; | ||
185 | unsigned int tx_desc_alloc_size; | ||
186 | |||
187 | |||
188 | struct napi_struct napi; | ||
189 | |||
190 | /* dma channel id for rx */ | ||
191 | int rx_chan; | ||
192 | |||
193 | /* number of dma desc in rx ring */ | ||
194 | int rx_ring_size; | ||
195 | |||
196 | /* cpu view of rx dma ring */ | ||
197 | struct bcm_enet_desc *rx_desc_cpu; | ||
198 | |||
199 | /* current number of armed descriptor given to hardware for rx */ | ||
200 | int rx_desc_count; | ||
201 | |||
202 | /* next rx descriptor to fetch from hardware */ | ||
203 | int rx_curr_desc; | ||
204 | |||
205 | /* next dirty rx descriptor to refill */ | ||
206 | int rx_dirty_desc; | ||
207 | |||
208 | /* size of allocated rx skbs */ | ||
209 | unsigned int rx_skb_size; | ||
210 | |||
211 | /* list of skb given to hw for rx */ | ||
212 | struct sk_buff **rx_skb; | ||
213 | |||
214 | /* used when rx skb allocation failed, so we defer rx queue | ||
215 | * refill */ | ||
216 | struct timer_list rx_timeout; | ||
217 | |||
218 | /* lock rx_timeout against rx normal operation */ | ||
219 | spinlock_t rx_lock; | ||
220 | |||
221 | |||
222 | /* dma channel id for tx */ | ||
223 | int tx_chan; | ||
224 | |||
225 | /* number of dma desc in tx ring */ | ||
226 | int tx_ring_size; | ||
227 | |||
228 | /* cpu view of rx dma ring */ | ||
229 | struct bcm_enet_desc *tx_desc_cpu; | ||
230 | |||
231 | /* number of available descriptor for tx */ | ||
232 | int tx_desc_count; | ||
233 | |||
234 | /* next tx descriptor avaiable */ | ||
235 | int tx_curr_desc; | ||
236 | |||
237 | /* next dirty tx descriptor to reclaim */ | ||
238 | int tx_dirty_desc; | ||
239 | |||
240 | /* list of skb given to hw for tx */ | ||
241 | struct sk_buff **tx_skb; | ||
242 | |||
243 | /* lock used by tx reclaim and xmit */ | ||
244 | spinlock_t tx_lock; | ||
245 | |||
246 | |||
247 | /* set if internal phy is ignored and external mii interface | ||
248 | * is selected */ | ||
249 | int use_external_mii; | ||
250 | |||
251 | /* set if a phy is connected, phy address must be known, | ||
252 | * probing is not possible */ | ||
253 | int has_phy; | ||
254 | int phy_id; | ||
255 | |||
256 | /* set if connected phy has an associated irq */ | ||
257 | int has_phy_interrupt; | ||
258 | int phy_interrupt; | ||
259 | |||
260 | /* used when a phy is connected (phylib used) */ | ||
261 | struct mii_bus *mii_bus; | ||
262 | struct phy_device *phydev; | ||
263 | int old_link; | ||
264 | int old_duplex; | ||
265 | int old_pause; | ||
266 | |||
267 | /* used when no phy is connected */ | ||
268 | int force_speed_100; | ||
269 | int force_duplex_full; | ||
270 | |||
271 | /* pause parameters */ | ||
272 | int pause_auto; | ||
273 | int pause_rx; | ||
274 | int pause_tx; | ||
275 | |||
276 | /* stats */ | ||
277 | struct net_device_stats stats; | ||
278 | struct bcm_enet_mib_counters mib; | ||
279 | |||
280 | /* after mib interrupt, mib registers update is done in this | ||
281 | * work queue */ | ||
282 | struct work_struct mib_update_task; | ||
283 | |||
284 | /* lock mib update between userspace request and workqueue */ | ||
285 | struct mutex mib_update_lock; | ||
286 | |||
287 | /* mac clock */ | ||
288 | struct clk *mac_clk; | ||
289 | |||
290 | /* phy clock if internal phy is used */ | ||
291 | struct clk *phy_clk; | ||
292 | |||
293 | /* network device reference */ | ||
294 | struct net_device *net_dev; | ||
295 | |||
296 | /* platform device reference */ | ||
297 | struct platform_device *pdev; | ||
298 | |||
299 | /* maximum hardware transmit/receive size */ | ||
300 | unsigned int hw_mtu; | ||
301 | }; | ||
302 | |||
303 | #endif /* ! BCM63XX_ENET_H_ */ | ||
diff --git a/drivers/net/bnx2x_reg.h b/drivers/net/bnx2x_reg.h index 0695be14cf91..aa76cbada5e2 100644 --- a/drivers/net/bnx2x_reg.h +++ b/drivers/net/bnx2x_reg.h | |||
@@ -3122,7 +3122,7 @@ | |||
3122 | The fields are:[4:0] - tail pointer; [10:5] - Link List size; 15:11] - | 3122 | The fields are:[4:0] - tail pointer; [10:5] - Link List size; 15:11] - |
3123 | header pointer. */ | 3123 | header pointer. */ |
3124 | #define TCM_REG_XX_TABLE 0x50240 | 3124 | #define TCM_REG_XX_TABLE 0x50240 |
3125 | /* [RW 4] Load value for for cfc ac credit cnt. */ | 3125 | /* [RW 4] Load value for cfc ac credit cnt. */ |
3126 | #define TM_REG_CFC_AC_CRDCNT_VAL 0x164208 | 3126 | #define TM_REG_CFC_AC_CRDCNT_VAL 0x164208 |
3127 | /* [RW 4] Load value for cfc cld credit cnt. */ | 3127 | /* [RW 4] Load value for cfc cld credit cnt. */ |
3128 | #define TM_REG_CFC_CLD_CRDCNT_VAL 0x164210 | 3128 | #define TM_REG_CFC_CLD_CRDCNT_VAL 0x164210 |
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index cea5cfe23b71..c3fa31c9f2a7 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -1987,7 +1987,7 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
1987 | // find new aggregator for the related port(s) | 1987 | // find new aggregator for the related port(s) |
1988 | new_aggregator = __get_first_agg(port); | 1988 | new_aggregator = __get_first_agg(port); |
1989 | for (; new_aggregator; new_aggregator = __get_next_agg(new_aggregator)) { | 1989 | for (; new_aggregator; new_aggregator = __get_next_agg(new_aggregator)) { |
1990 | // if the new aggregator is empty, or it connected to to our port only | 1990 | // if the new aggregator is empty, or it is connected to our port only |
1991 | if (!new_aggregator->lag_ports || ((new_aggregator->lag_ports == port) && !new_aggregator->lag_ports->next_port_in_aggregator)) { | 1991 | if (!new_aggregator->lag_ports || ((new_aggregator->lag_ports == port) && !new_aggregator->lag_ports->next_port_in_aggregator)) { |
1992 | break; | 1992 | break; |
1993 | } | 1993 | } |
diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c index cda6b397550d..45ac225a7aaa 100644 --- a/drivers/net/e1000/e1000_hw.c +++ b/drivers/net/e1000/e1000_hw.c | |||
@@ -3035,7 +3035,7 @@ s32 e1000_check_for_link(struct e1000_hw *hw) | |||
3035 | /* If TBI compatibility is was previously off, turn it on. For | 3035 | /* If TBI compatibility is was previously off, turn it on. For |
3036 | * compatibility with a TBI link partner, we will store bad | 3036 | * compatibility with a TBI link partner, we will store bad |
3037 | * packets. Some frames have an additional byte on the end and | 3037 | * packets. Some frames have an additional byte on the end and |
3038 | * will look like CRC errors to to the hardware. | 3038 | * will look like CRC errors to the hardware. |
3039 | */ | 3039 | */ |
3040 | if (!hw->tbi_compatibility_on) { | 3040 | if (!hw->tbi_compatibility_on) { |
3041 | hw->tbi_compatibility_on = true; | 3041 | hw->tbi_compatibility_on = true; |
diff --git a/drivers/net/ehea/ehea_qmr.c b/drivers/net/ehea/ehea_qmr.c index 3747457f5e69..bc7c5b7abb88 100644 --- a/drivers/net/ehea/ehea_qmr.c +++ b/drivers/net/ehea/ehea_qmr.c | |||
@@ -751,7 +751,7 @@ int ehea_create_busmap(void) | |||
751 | 751 | ||
752 | mutex_lock(&ehea_busmap_mutex); | 752 | mutex_lock(&ehea_busmap_mutex); |
753 | ehea_mr_len = 0; | 753 | ehea_mr_len = 0; |
754 | ret = walk_memory_resource(0, 1ULL << MAX_PHYSMEM_BITS, NULL, | 754 | ret = walk_system_ram_range(0, 1ULL << MAX_PHYSMEM_BITS, NULL, |
755 | ehea_create_busmap_callback); | 755 | ehea_create_busmap_callback); |
756 | mutex_unlock(&ehea_busmap_mutex); | 756 | mutex_unlock(&ehea_busmap_mutex); |
757 | return ret; | 757 | return ret; |
diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c index 117fc6c12e34..66813c91a720 100644 --- a/drivers/net/enc28j60.c +++ b/drivers/net/enc28j60.c | |||
@@ -1666,3 +1666,4 @@ MODULE_AUTHOR("Claudio Lanconelli <lanconelli.claudio@eptar.com>"); | |||
1666 | MODULE_LICENSE("GPL"); | 1666 | MODULE_LICENSE("GPL"); |
1667 | module_param_named(debug, debug.msg_enable, int, 0); | 1667 | module_param_named(debug, debug.msg_enable, int, 0); |
1668 | MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., ffff=all)"); | 1668 | MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., ffff=all)"); |
1669 | MODULE_ALIAS("spi:" DRV_NAME); | ||
diff --git a/drivers/net/fec.c b/drivers/net/fec.c index b47201874d84..29234380e6c6 100644 --- a/drivers/net/fec.c +++ b/drivers/net/fec.c | |||
@@ -1154,19 +1154,9 @@ static void __inline__ fec_request_mii_intr(struct net_device *dev) | |||
1154 | printk("FEC: Could not allocate fec(MII) IRQ(66)!\n"); | 1154 | printk("FEC: Could not allocate fec(MII) IRQ(66)!\n"); |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | static void __inline__ fec_disable_phy_intr(void) | 1157 | static void __inline__ fec_disable_phy_intr(struct net_device *dev) |
1158 | { | 1158 | { |
1159 | volatile unsigned long *icrp; | 1159 | free_irq(66, dev); |
1160 | icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1); | ||
1161 | *icrp = 0x08000000; | ||
1162 | } | ||
1163 | |||
1164 | static void __inline__ fec_phy_ack_intr(void) | ||
1165 | { | ||
1166 | volatile unsigned long *icrp; | ||
1167 | /* Acknowledge the interrupt */ | ||
1168 | icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1); | ||
1169 | *icrp = 0x0d000000; | ||
1170 | } | 1160 | } |
1171 | #endif | 1161 | #endif |
1172 | 1162 | ||
@@ -1398,7 +1388,7 @@ mii_discover_phy(uint mii_reg, struct net_device *dev) | |||
1398 | writel(0, fep->hwp + FEC_MII_SPEED); | 1388 | writel(0, fep->hwp + FEC_MII_SPEED); |
1399 | fep->phy_speed = 0; | 1389 | fep->phy_speed = 0; |
1400 | #ifdef HAVE_mii_link_interrupt | 1390 | #ifdef HAVE_mii_link_interrupt |
1401 | fec_disable_phy_intr(); | 1391 | fec_disable_phy_intr(dev); |
1402 | #endif | 1392 | #endif |
1403 | } | 1393 | } |
1404 | } | 1394 | } |
@@ -1411,8 +1401,6 @@ mii_link_interrupt(int irq, void * dev_id) | |||
1411 | struct net_device *dev = dev_id; | 1401 | struct net_device *dev = dev_id; |
1412 | struct fec_enet_private *fep = netdev_priv(dev); | 1402 | struct fec_enet_private *fep = netdev_priv(dev); |
1413 | 1403 | ||
1414 | fec_phy_ack_intr(); | ||
1415 | |||
1416 | mii_do_cmd(dev, fep->phy->ack_int); | 1404 | mii_do_cmd(dev, fep->phy->ack_int); |
1417 | mii_do_cmd(dev, phy_cmd_relink); /* restart and display status */ | 1405 | mii_do_cmd(dev, phy_cmd_relink); /* restart and display status */ |
1418 | 1406 | ||
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c index 2234118eedbb..6c144b525b47 100644 --- a/drivers/net/gianfar_ethtool.c +++ b/drivers/net/gianfar_ethtool.c | |||
@@ -293,7 +293,7 @@ static int gfar_gcoalesce(struct net_device *dev, struct ethtool_coalesce *cvals | |||
293 | rxtime = get_ictt_value(priv->rxic); | 293 | rxtime = get_ictt_value(priv->rxic); |
294 | rxcount = get_icft_value(priv->rxic); | 294 | rxcount = get_icft_value(priv->rxic); |
295 | txtime = get_ictt_value(priv->txic); | 295 | txtime = get_ictt_value(priv->txic); |
296 | txcount = get_icft_value(priv->txic);; | 296 | txcount = get_icft_value(priv->txic); |
297 | cvals->rx_coalesce_usecs = gfar_ticks2usecs(priv, rxtime); | 297 | cvals->rx_coalesce_usecs = gfar_ticks2usecs(priv, rxtime); |
298 | cvals->rx_max_coalesced_frames = rxcount; | 298 | cvals->rx_max_coalesced_frames = rxcount; |
299 | 299 | ||
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index 1d7d7fef414f..89c82c5e63e4 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c | |||
@@ -2556,13 +2556,13 @@ static int __devinit emac_init_config(struct emac_instance *dev) | |||
2556 | if (emac_read_uint_prop(np, "mdio-device", &dev->mdio_ph, 0)) | 2556 | if (emac_read_uint_prop(np, "mdio-device", &dev->mdio_ph, 0)) |
2557 | dev->mdio_ph = 0; | 2557 | dev->mdio_ph = 0; |
2558 | if (emac_read_uint_prop(np, "zmii-device", &dev->zmii_ph, 0)) | 2558 | if (emac_read_uint_prop(np, "zmii-device", &dev->zmii_ph, 0)) |
2559 | dev->zmii_ph = 0;; | 2559 | dev->zmii_ph = 0; |
2560 | if (emac_read_uint_prop(np, "zmii-channel", &dev->zmii_port, 0)) | 2560 | if (emac_read_uint_prop(np, "zmii-channel", &dev->zmii_port, 0)) |
2561 | dev->zmii_port = 0xffffffff;; | 2561 | dev->zmii_port = 0xffffffff; |
2562 | if (emac_read_uint_prop(np, "rgmii-device", &dev->rgmii_ph, 0)) | 2562 | if (emac_read_uint_prop(np, "rgmii-device", &dev->rgmii_ph, 0)) |
2563 | dev->rgmii_ph = 0;; | 2563 | dev->rgmii_ph = 0; |
2564 | if (emac_read_uint_prop(np, "rgmii-channel", &dev->rgmii_port, 0)) | 2564 | if (emac_read_uint_prop(np, "rgmii-channel", &dev->rgmii_port, 0)) |
2565 | dev->rgmii_port = 0xffffffff;; | 2565 | dev->rgmii_port = 0xffffffff; |
2566 | if (emac_read_uint_prop(np, "fifo-entry-size", &dev->fifo_entry_size, 0)) | 2566 | if (emac_read_uint_prop(np, "fifo-entry-size", &dev->fifo_entry_size, 0)) |
2567 | dev->fifo_entry_size = 16; | 2567 | dev->fifo_entry_size = 16; |
2568 | if (emac_read_uint_prop(np, "mal-burst-size", &dev->mal_burst_size, 0)) | 2568 | if (emac_read_uint_prop(np, "mal-burst-size", &dev->mal_burst_size, 0)) |
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index d2639c4a086d..5d6c1530a8c0 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c | |||
@@ -3966,7 +3966,7 @@ static int igb_set_vf_multicasts(struct igb_adapter *adapter, | |||
3966 | /* VFs are limited to using the MTA hash table for their multicast | 3966 | /* VFs are limited to using the MTA hash table for their multicast |
3967 | * addresses */ | 3967 | * addresses */ |
3968 | for (i = 0; i < n; i++) | 3968 | for (i = 0; i < n; i++) |
3969 | vf_data->vf_mc_hashes[i] = hash_list[i];; | 3969 | vf_data->vf_mc_hashes[i] = hash_list[i]; |
3970 | 3970 | ||
3971 | /* Flush and reset the mta with the new values */ | 3971 | /* Flush and reset the mta with the new values */ |
3972 | igb_set_rx_mode(adapter->netdev); | 3972 | igb_set_rx_mode(adapter->netdev); |
diff --git a/drivers/net/ks8851.c b/drivers/net/ks8851.c index 547ac7c7479c..237835864357 100644 --- a/drivers/net/ks8851.c +++ b/drivers/net/ks8851.c | |||
@@ -1321,3 +1321,4 @@ MODULE_LICENSE("GPL"); | |||
1321 | 1321 | ||
1322 | module_param_named(message, msg_enable, int, 0); | 1322 | module_param_named(message, msg_enable, int, 0); |
1323 | MODULE_PARM_DESC(message, "Message verbosity level (0=none, 31=all)"); | 1323 | MODULE_PARM_DESC(message, "Message verbosity level (0=none, 31=all)"); |
1324 | MODULE_ALIAS("spi:ks8851"); | ||
diff --git a/drivers/net/ll_temac_main.c b/drivers/net/ll_temac_main.c index da8d0a0ca94f..f2a197fd47a5 100644 --- a/drivers/net/ll_temac_main.c +++ b/drivers/net/ll_temac_main.c | |||
@@ -865,7 +865,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match) | |||
865 | dcrs = dcr_resource_start(np, 0); | 865 | dcrs = dcr_resource_start(np, 0); |
866 | if (dcrs == 0) { | 866 | if (dcrs == 0) { |
867 | dev_err(&op->dev, "could not get DMA register address\n"); | 867 | dev_err(&op->dev, "could not get DMA register address\n"); |
868 | goto nodev;; | 868 | goto nodev; |
869 | } | 869 | } |
870 | lp->sdma_dcrs = dcr_map(np, dcrs, dcr_resource_len(np, 0)); | 870 | lp->sdma_dcrs = dcr_map(np, dcrs, dcr_resource_len(np, 0)); |
871 | dev_dbg(&op->dev, "DCR base: %x\n", dcrs); | 871 | dev_dbg(&op->dev, "DCR base: %x\n", dcrs); |
diff --git a/drivers/net/macb.c b/drivers/net/macb.c index fb65b427c692..1d0d4d9ab623 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c | |||
@@ -241,7 +241,7 @@ static int macb_mii_init(struct macb *bp) | |||
241 | struct eth_platform_data *pdata; | 241 | struct eth_platform_data *pdata; |
242 | int err = -ENXIO, i; | 242 | int err = -ENXIO, i; |
243 | 243 | ||
244 | /* Enable managment port */ | 244 | /* Enable management port */ |
245 | macb_writel(bp, NCR, MACB_BIT(MPE)); | 245 | macb_writel(bp, NCR, MACB_BIT(MPE)); |
246 | 246 | ||
247 | bp->mii_bus = mdiobus_alloc(); | 247 | bp->mii_bus = mdiobus_alloc(); |
diff --git a/drivers/net/ni52.c b/drivers/net/ni52.c index bd0ac690d12c..aad3b370c562 100644 --- a/drivers/net/ni52.c +++ b/drivers/net/ni52.c | |||
@@ -615,10 +615,10 @@ static int init586(struct net_device *dev) | |||
615 | /* addr_len |!src_insert |pre-len |loopback */ | 615 | /* addr_len |!src_insert |pre-len |loopback */ |
616 | writeb(0x2e, &cfg_cmd->adr_len); | 616 | writeb(0x2e, &cfg_cmd->adr_len); |
617 | writeb(0x00, &cfg_cmd->priority); | 617 | writeb(0x00, &cfg_cmd->priority); |
618 | writeb(0x60, &cfg_cmd->ifs);; | 618 | writeb(0x60, &cfg_cmd->ifs); |
619 | writeb(0x00, &cfg_cmd->time_low); | 619 | writeb(0x00, &cfg_cmd->time_low); |
620 | writeb(0xf2, &cfg_cmd->time_high); | 620 | writeb(0xf2, &cfg_cmd->time_high); |
621 | writeb(0x00, &cfg_cmd->promisc);; | 621 | writeb(0x00, &cfg_cmd->promisc); |
622 | if (dev->flags & IFF_ALLMULTI) { | 622 | if (dev->flags & IFF_ALLMULTI) { |
623 | int len = ((char __iomem *)p->iscp - (char __iomem *)ptr - 8) / 6; | 623 | int len = ((char __iomem *)p->iscp - (char __iomem *)ptr - 8) / 6; |
624 | if (num_addrs > len) { | 624 | if (num_addrs > len) { |
diff --git a/drivers/net/niu.c b/drivers/net/niu.c index 76cc2614f480..f9364d0678f2 100644 --- a/drivers/net/niu.c +++ b/drivers/net/niu.c | |||
@@ -5615,7 +5615,7 @@ static void niu_init_tx_mac(struct niu *np) | |||
5615 | /* The XMAC_MIN register only accepts values for TX min which | 5615 | /* The XMAC_MIN register only accepts values for TX min which |
5616 | * have the low 3 bits cleared. | 5616 | * have the low 3 bits cleared. |
5617 | */ | 5617 | */ |
5618 | BUILD_BUG_ON(min & 0x7); | 5618 | BUG_ON(min & 0x7); |
5619 | 5619 | ||
5620 | if (np->flags & NIU_FLAGS_XMAC) | 5620 | if (np->flags & NIU_FLAGS_XMAC) |
5621 | niu_init_tx_xmac(np, min, max); | 5621 | niu_init_tx_xmac(np, min, max); |
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c index 220529257828..7783c5db81dc 100644 --- a/drivers/net/qlge/qlge_main.c +++ b/drivers/net/qlge/qlge_main.c | |||
@@ -2630,7 +2630,7 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) | |||
2630 | FLAGS_LI; /* Load irq delay values */ | 2630 | FLAGS_LI; /* Load irq delay values */ |
2631 | if (rx_ring->lbq_len) { | 2631 | if (rx_ring->lbq_len) { |
2632 | cqicb->flags |= FLAGS_LL; /* Load lbq values */ | 2632 | cqicb->flags |= FLAGS_LL; /* Load lbq values */ |
2633 | tmp = (u64)rx_ring->lbq_base_dma;; | 2633 | tmp = (u64)rx_ring->lbq_base_dma; |
2634 | base_indirect_ptr = (__le64 *) rx_ring->lbq_base_indirect; | 2634 | base_indirect_ptr = (__le64 *) rx_ring->lbq_base_indirect; |
2635 | page_entries = 0; | 2635 | page_entries = 0; |
2636 | do { | 2636 | do { |
@@ -2654,7 +2654,7 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) | |||
2654 | } | 2654 | } |
2655 | if (rx_ring->sbq_len) { | 2655 | if (rx_ring->sbq_len) { |
2656 | cqicb->flags |= FLAGS_LS; /* Load sbq values */ | 2656 | cqicb->flags |= FLAGS_LS; /* Load sbq values */ |
2657 | tmp = (u64)rx_ring->sbq_base_dma;; | 2657 | tmp = (u64)rx_ring->sbq_base_dma; |
2658 | base_indirect_ptr = (__le64 *) rx_ring->sbq_base_indirect; | 2658 | base_indirect_ptr = (__le64 *) rx_ring->sbq_base_indirect; |
2659 | page_entries = 0; | 2659 | page_entries = 0; |
2660 | do { | 2660 | do { |
diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c index bc98e7f69ee9..ede937ee50c7 100644 --- a/drivers/net/rionet.c +++ b/drivers/net/rionet.c | |||
@@ -72,7 +72,7 @@ static int rionet_check = 0; | |||
72 | static int rionet_capable = 1; | 72 | static int rionet_capable = 1; |
73 | 73 | ||
74 | /* | 74 | /* |
75 | * This is a fast lookup table for for translating TX | 75 | * This is a fast lookup table for translating TX |
76 | * Ethernet packets into a destination RIO device. It | 76 | * Ethernet packets into a destination RIO device. It |
77 | * could be made into a hash table to save memory depending | 77 | * could be made into a hash table to save memory depending |
78 | * on system trade-offs. | 78 | * on system trade-offs. |
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c index 07a7e4b8f8fc..cc4b2f99989d 100644 --- a/drivers/net/sfc/efx.c +++ b/drivers/net/sfc/efx.c | |||
@@ -884,13 +884,12 @@ static int efx_wanted_rx_queues(void) | |||
884 | int count; | 884 | int count; |
885 | int cpu; | 885 | int cpu; |
886 | 886 | ||
887 | if (unlikely(!alloc_cpumask_var(&core_mask, GFP_KERNEL))) { | 887 | if (unlikely(!zalloc_cpumask_var(&core_mask, GFP_KERNEL))) { |
888 | printk(KERN_WARNING | 888 | printk(KERN_WARNING |
889 | "sfc: RSS disabled due to allocation failure\n"); | 889 | "sfc: RSS disabled due to allocation failure\n"); |
890 | return 1; | 890 | return 1; |
891 | } | 891 | } |
892 | 892 | ||
893 | cpumask_clear(core_mask); | ||
894 | count = 0; | 893 | count = 0; |
895 | for_each_online_cpu(cpu) { | 894 | for_each_online_cpu(cpu) { |
896 | if (!cpumask_test_cpu(cpu, core_mask)) { | 895 | if (!cpumask_test_cpu(cpu, core_mask)) { |
diff --git a/drivers/net/skfp/pcmplc.c b/drivers/net/skfp/pcmplc.c index f1df2ec8ad41..e6b33ee05ede 100644 --- a/drivers/net/skfp/pcmplc.c +++ b/drivers/net/skfp/pcmplc.c | |||
@@ -960,7 +960,7 @@ static void pcm_fsm(struct s_smc *smc, struct s_phy *phy, int cmd) | |||
960 | /*PC88b*/ | 960 | /*PC88b*/ |
961 | if (!phy->cf_join) { | 961 | if (!phy->cf_join) { |
962 | phy->cf_join = TRUE ; | 962 | phy->cf_join = TRUE ; |
963 | queue_event(smc,EVENT_CFM,CF_JOIN+np) ; ; | 963 | queue_event(smc,EVENT_CFM,CF_JOIN+np) ; |
964 | } | 964 | } |
965 | if (cmd == PC_JOIN) | 965 | if (cmd == PC_JOIN) |
966 | GO_STATE(PC8_ACTIVE) ; | 966 | GO_STATE(PC8_ACTIVE) ; |
diff --git a/drivers/net/skfp/pmf.c b/drivers/net/skfp/pmf.c index 79e665e0853d..a320fdb3727d 100644 --- a/drivers/net/skfp/pmf.c +++ b/drivers/net/skfp/pmf.c | |||
@@ -807,9 +807,9 @@ void smt_add_para(struct s_smc *smc, struct s_pcon *pcon, u_short para, | |||
807 | mib_p->fddiPORTLerFlag ; | 807 | mib_p->fddiPORTLerFlag ; |
808 | sp->p4050_pad = 0 ; | 808 | sp->p4050_pad = 0 ; |
809 | sp->p4050_cutoff = | 809 | sp->p4050_cutoff = |
810 | mib_p->fddiPORTLer_Cutoff ; ; | 810 | mib_p->fddiPORTLer_Cutoff ; |
811 | sp->p4050_alarm = | 811 | sp->p4050_alarm = |
812 | mib_p->fddiPORTLer_Alarm ; ; | 812 | mib_p->fddiPORTLer_Alarm ; |
813 | sp->p4050_estimate = | 813 | sp->p4050_estimate = |
814 | mib_p->fddiPORTLer_Estimate ; | 814 | mib_p->fddiPORTLer_Estimate ; |
815 | sp->p4050_reject_ct = | 815 | sp->p4050_reject_ct = |
@@ -829,7 +829,7 @@ void smt_add_para(struct s_smc *smc, struct s_pcon *pcon, u_short para, | |||
829 | sp->p4051_porttype = | 829 | sp->p4051_porttype = |
830 | mib_p->fddiPORTMy_Type ; | 830 | mib_p->fddiPORTMy_Type ; |
831 | sp->p4051_connectstate = | 831 | sp->p4051_connectstate = |
832 | mib_p->fddiPORTConnectState ; ; | 832 | mib_p->fddiPORTConnectState ; |
833 | sp->p4051_pc_neighbor = | 833 | sp->p4051_pc_neighbor = |
834 | mib_p->fddiPORTNeighborType ; | 834 | mib_p->fddiPORTNeighborType ; |
835 | sp->p4051_pc_withhold = | 835 | sp->p4051_pc_withhold = |
@@ -853,7 +853,7 @@ void smt_add_para(struct s_smc *smc, struct s_pcon *pcon, u_short para, | |||
853 | struct smt_p_4053 *sp ; | 853 | struct smt_p_4053 *sp ; |
854 | sp = (struct smt_p_4053 *) to ; | 854 | sp = (struct smt_p_4053 *) to ; |
855 | sp->p4053_multiple = | 855 | sp->p4053_multiple = |
856 | mib_p->fddiPORTMultiple_P ; ; | 856 | mib_p->fddiPORTMultiple_P ; |
857 | sp->p4053_availablepaths = | 857 | sp->p4053_availablepaths = |
858 | mib_p->fddiPORTAvailablePaths ; | 858 | mib_p->fddiPORTAvailablePaths ; |
859 | sp->p4053_currentpath = | 859 | sp->p4053_currentpath = |
diff --git a/drivers/net/skge.c b/drivers/net/skge.c index 62e852e21ab2..55bad4081966 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c | |||
@@ -215,7 +215,7 @@ static void skge_wol_init(struct skge_port *skge) | |||
215 | if (skge->wol & WAKE_MAGIC) | 215 | if (skge->wol & WAKE_MAGIC) |
216 | ctrl |= WOL_CTL_ENA_PME_ON_MAGIC_PKT|WOL_CTL_ENA_MAGIC_PKT_UNIT; | 216 | ctrl |= WOL_CTL_ENA_PME_ON_MAGIC_PKT|WOL_CTL_ENA_MAGIC_PKT_UNIT; |
217 | else | 217 | else |
218 | ctrl |= WOL_CTL_DIS_PME_ON_MAGIC_PKT|WOL_CTL_DIS_MAGIC_PKT_UNIT;; | 218 | ctrl |= WOL_CTL_DIS_PME_ON_MAGIC_PKT|WOL_CTL_DIS_MAGIC_PKT_UNIT; |
219 | 219 | ||
220 | ctrl |= WOL_CTL_DIS_PME_ON_PATTERN|WOL_CTL_DIS_PATTERN_UNIT; | 220 | ctrl |= WOL_CTL_DIS_PME_ON_PATTERN|WOL_CTL_DIS_PATTERN_UNIT; |
221 | skge_write16(hw, WOL_REGS(port, WOL_CTRL_STAT), ctrl); | 221 | skge_write16(hw, WOL_REGS(port, WOL_CTRL_STAT), ctrl); |
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 68d256b9638c..ef1165718dd7 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c | |||
@@ -765,7 +765,7 @@ static void sky2_wol_init(struct sky2_port *sky2) | |||
765 | if (sky2->wol & WAKE_MAGIC) | 765 | if (sky2->wol & WAKE_MAGIC) |
766 | ctrl |= WOL_CTL_ENA_PME_ON_MAGIC_PKT|WOL_CTL_ENA_MAGIC_PKT_UNIT; | 766 | ctrl |= WOL_CTL_ENA_PME_ON_MAGIC_PKT|WOL_CTL_ENA_MAGIC_PKT_UNIT; |
767 | else | 767 | else |
768 | ctrl |= WOL_CTL_DIS_PME_ON_MAGIC_PKT|WOL_CTL_DIS_MAGIC_PKT_UNIT;; | 768 | ctrl |= WOL_CTL_DIS_PME_ON_MAGIC_PKT|WOL_CTL_DIS_MAGIC_PKT_UNIT; |
769 | 769 | ||
770 | ctrl |= WOL_CTL_DIS_PME_ON_PATTERN|WOL_CTL_DIS_PATTERN_UNIT; | 770 | ctrl |= WOL_CTL_DIS_PME_ON_PATTERN|WOL_CTL_DIS_PATTERN_UNIT; |
771 | sky2_write16(hw, WOL_REGS(port, WOL_CTRL_STAT), ctrl); | 771 | sky2_write16(hw, WOL_REGS(port, WOL_CTRL_STAT), ctrl); |
diff --git a/drivers/net/slip.c b/drivers/net/slip.c index 26f6ee93a064..e17c535a577e 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c | |||
@@ -616,6 +616,14 @@ static void sl_uninit(struct net_device *dev) | |||
616 | sl_free_bufs(sl); | 616 | sl_free_bufs(sl); |
617 | } | 617 | } |
618 | 618 | ||
619 | /* Hook the destructor so we can free slip devices at the right point in time */ | ||
620 | static void sl_free_netdev(struct net_device *dev) | ||
621 | { | ||
622 | int i = dev->base_addr; | ||
623 | free_netdev(dev); | ||
624 | slip_devs[i] = NULL; | ||
625 | } | ||
626 | |||
619 | static const struct net_device_ops sl_netdev_ops = { | 627 | static const struct net_device_ops sl_netdev_ops = { |
620 | .ndo_init = sl_init, | 628 | .ndo_init = sl_init, |
621 | .ndo_uninit = sl_uninit, | 629 | .ndo_uninit = sl_uninit, |
@@ -634,7 +642,7 @@ static const struct net_device_ops sl_netdev_ops = { | |||
634 | static void sl_setup(struct net_device *dev) | 642 | static void sl_setup(struct net_device *dev) |
635 | { | 643 | { |
636 | dev->netdev_ops = &sl_netdev_ops; | 644 | dev->netdev_ops = &sl_netdev_ops; |
637 | dev->destructor = free_netdev; | 645 | dev->destructor = sl_free_netdev; |
638 | 646 | ||
639 | dev->hard_header_len = 0; | 647 | dev->hard_header_len = 0; |
640 | dev->addr_len = 0; | 648 | dev->addr_len = 0; |
@@ -712,8 +720,6 @@ static void sl_sync(void) | |||
712 | static struct slip *sl_alloc(dev_t line) | 720 | static struct slip *sl_alloc(dev_t line) |
713 | { | 721 | { |
714 | int i; | 722 | int i; |
715 | int sel = -1; | ||
716 | int score = -1; | ||
717 | struct net_device *dev = NULL; | 723 | struct net_device *dev = NULL; |
718 | struct slip *sl; | 724 | struct slip *sl; |
719 | 725 | ||
@@ -724,55 +730,7 @@ static struct slip *sl_alloc(dev_t line) | |||
724 | dev = slip_devs[i]; | 730 | dev = slip_devs[i]; |
725 | if (dev == NULL) | 731 | if (dev == NULL) |
726 | break; | 732 | break; |
727 | |||
728 | sl = netdev_priv(dev); | ||
729 | if (sl->leased) { | ||
730 | if (sl->line != line) | ||
731 | continue; | ||
732 | if (sl->tty) | ||
733 | return NULL; | ||
734 | |||
735 | /* Clear ESCAPE & ERROR flags */ | ||
736 | sl->flags &= (1 << SLF_INUSE); | ||
737 | return sl; | ||
738 | } | ||
739 | |||
740 | if (sl->tty) | ||
741 | continue; | ||
742 | |||
743 | if (current->pid == sl->pid) { | ||
744 | if (sl->line == line && score < 3) { | ||
745 | sel = i; | ||
746 | score = 3; | ||
747 | continue; | ||
748 | } | ||
749 | if (score < 2) { | ||
750 | sel = i; | ||
751 | score = 2; | ||
752 | } | ||
753 | continue; | ||
754 | } | ||
755 | if (sl->line == line && score < 1) { | ||
756 | sel = i; | ||
757 | score = 1; | ||
758 | continue; | ||
759 | } | ||
760 | if (score < 0) { | ||
761 | sel = i; | ||
762 | score = 0; | ||
763 | } | ||
764 | } | ||
765 | |||
766 | if (sel >= 0) { | ||
767 | i = sel; | ||
768 | dev = slip_devs[i]; | ||
769 | if (score > 1) { | ||
770 | sl = netdev_priv(dev); | ||
771 | sl->flags &= (1 << SLF_INUSE); | ||
772 | return sl; | ||
773 | } | ||
774 | } | 733 | } |
775 | |||
776 | /* Sorry, too many, all slots in use */ | 734 | /* Sorry, too many, all slots in use */ |
777 | if (i >= slip_maxdev) | 735 | if (i >= slip_maxdev) |
778 | return NULL; | 736 | return NULL; |
@@ -909,30 +867,13 @@ err_exit: | |||
909 | } | 867 | } |
910 | 868 | ||
911 | /* | 869 | /* |
912 | |||
913 | FIXME: 1,2 are fixed 3 was never true anyway. | ||
914 | |||
915 | Let me to blame a bit. | ||
916 | 1. TTY module calls this funstion on soft interrupt. | ||
917 | 2. TTY module calls this function WITH MASKED INTERRUPTS! | ||
918 | 3. TTY module does not notify us about line discipline | ||
919 | shutdown, | ||
920 | |||
921 | Seems, now it is clean. The solution is to consider netdevice and | ||
922 | line discipline sides as two independent threads. | ||
923 | |||
924 | By-product (not desired): sl? does not feel hangups and remains open. | ||
925 | It is supposed, that user level program (dip, diald, slattach...) | ||
926 | will catch SIGHUP and make the rest of work. | ||
927 | |||
928 | I see no way to make more with current tty code. --ANK | ||
929 | */ | ||
930 | |||
931 | /* | ||
932 | * Close down a SLIP channel. | 870 | * Close down a SLIP channel. |
933 | * This means flushing out any pending queues, and then returning. This | 871 | * This means flushing out any pending queues, and then returning. This |
934 | * call is serialized against other ldisc functions. | 872 | * call is serialized against other ldisc functions. |
873 | * | ||
874 | * We also use this method fo a hangup event | ||
935 | */ | 875 | */ |
876 | |||
936 | static void slip_close(struct tty_struct *tty) | 877 | static void slip_close(struct tty_struct *tty) |
937 | { | 878 | { |
938 | struct slip *sl = tty->disc_data; | 879 | struct slip *sl = tty->disc_data; |
@@ -951,10 +892,16 @@ static void slip_close(struct tty_struct *tty) | |||
951 | del_timer_sync(&sl->keepalive_timer); | 892 | del_timer_sync(&sl->keepalive_timer); |
952 | del_timer_sync(&sl->outfill_timer); | 893 | del_timer_sync(&sl->outfill_timer); |
953 | #endif | 894 | #endif |
954 | 895 | /* Flush network side */ | |
955 | /* Count references from TTY module */ | 896 | unregister_netdev(sl->dev); |
897 | /* This will complete via sl_free_netdev */ | ||
956 | } | 898 | } |
957 | 899 | ||
900 | static int slip_hangup(struct tty_struct *tty) | ||
901 | { | ||
902 | slip_close(tty); | ||
903 | return 0; | ||
904 | } | ||
958 | /************************************************************************ | 905 | /************************************************************************ |
959 | * STANDARD SLIP ENCAPSULATION * | 906 | * STANDARD SLIP ENCAPSULATION * |
960 | ************************************************************************/ | 907 | ************************************************************************/ |
@@ -1311,6 +1258,7 @@ static struct tty_ldisc_ops sl_ldisc = { | |||
1311 | .name = "slip", | 1258 | .name = "slip", |
1312 | .open = slip_open, | 1259 | .open = slip_open, |
1313 | .close = slip_close, | 1260 | .close = slip_close, |
1261 | .hangup = slip_hangup, | ||
1314 | .ioctl = slip_ioctl, | 1262 | .ioctl = slip_ioctl, |
1315 | .receive_buf = slip_receive_buf, | 1263 | .receive_buf = slip_receive_buf, |
1316 | .write_wakeup = slip_write_wakeup, | 1264 | .write_wakeup = slip_write_wakeup, |
@@ -1384,6 +1332,8 @@ static void __exit slip_exit(void) | |||
1384 | } | 1332 | } |
1385 | } while (busy && time_before(jiffies, timeout)); | 1333 | } while (busy && time_before(jiffies, timeout)); |
1386 | 1334 | ||
1335 | /* FIXME: hangup is async so we should wait when doing this second | ||
1336 | phase */ | ||
1387 | 1337 | ||
1388 | for (i = 0; i < slip_maxdev; i++) { | 1338 | for (i = 0; i < slip_maxdev; i++) { |
1389 | dev = slip_devs[i]; | 1339 | dev = slip_devs[i]; |
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c index 61be6d7680f6..05c91ee6921e 100644 --- a/drivers/net/smc91x.c +++ b/drivers/net/smc91x.c | |||
@@ -35,7 +35,7 @@ | |||
35 | * | 35 | * |
36 | * contributors: | 36 | * contributors: |
37 | * Daris A Nevil <dnevil@snmc.com> | 37 | * Daris A Nevil <dnevil@snmc.com> |
38 | * Nicolas Pitre <nico@cam.org> | 38 | * Nicolas Pitre <nico@fluxnic.net> |
39 | * Russell King <rmk@arm.linux.org.uk> | 39 | * Russell King <rmk@arm.linux.org.uk> |
40 | * | 40 | * |
41 | * History: | 41 | * History: |
@@ -58,7 +58,7 @@ | |||
58 | * 22/09/04 Nicolas Pitre big update (see commit log for details) | 58 | * 22/09/04 Nicolas Pitre big update (see commit log for details) |
59 | */ | 59 | */ |
60 | static const char version[] = | 60 | static const char version[] = |
61 | "smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@cam.org>\n"; | 61 | "smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@fluxnic.net>\n"; |
62 | 62 | ||
63 | /* Debugging level */ | 63 | /* Debugging level */ |
64 | #ifndef SMC_DEBUG | 64 | #ifndef SMC_DEBUG |
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h index 9c8c6ed4a3cd..3911be7c0cba 100644 --- a/drivers/net/smc91x.h +++ b/drivers/net/smc91x.h | |||
@@ -28,7 +28,7 @@ | |||
28 | . Authors | 28 | . Authors |
29 | . Erik Stahlman <erik@vt.edu> | 29 | . Erik Stahlman <erik@vt.edu> |
30 | . Daris A Nevil <dnevil@snmc.com> | 30 | . Daris A Nevil <dnevil@snmc.com> |
31 | . Nicolas Pitre <nico@cam.org> | 31 | . Nicolas Pitre <nico@fluxnic.net> |
32 | . | 32 | . |
33 | ---------------------------------------------------------------------------*/ | 33 | ---------------------------------------------------------------------------*/ |
34 | #ifndef _SMC91X_H_ | 34 | #ifndef _SMC91X_H_ |
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index e091756166a3..4fdfa2ae5418 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
@@ -1368,7 +1368,7 @@ static const struct file_operations tun_fops = { | |||
1368 | static struct miscdevice tun_miscdev = { | 1368 | static struct miscdevice tun_miscdev = { |
1369 | .minor = TUN_MINOR, | 1369 | .minor = TUN_MINOR, |
1370 | .name = "tun", | 1370 | .name = "tun", |
1371 | .devnode = "net/tun", | 1371 | .nodename = "net/tun", |
1372 | .fops = &tun_fops, | 1372 | .fops = &tun_fops, |
1373 | }; | 1373 | }; |
1374 | 1374 | ||
diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c index 45cebfb302cf..23300656c266 100644 --- a/drivers/net/usb/cdc_eem.c +++ b/drivers/net/usb/cdc_eem.c | |||
@@ -300,20 +300,23 @@ static int eem_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
300 | return 0; | 300 | return 0; |
301 | } | 301 | } |
302 | 302 | ||
303 | crc = get_unaligned_le32(skb2->data | ||
304 | + len - ETH_FCS_LEN); | ||
305 | skb_trim(skb2, len - ETH_FCS_LEN); | ||
306 | |||
307 | /* | 303 | /* |
308 | * The bmCRC helps to denote when the CRC field in | 304 | * The bmCRC helps to denote when the CRC field in |
309 | * the Ethernet frame contains a calculated CRC: | 305 | * the Ethernet frame contains a calculated CRC: |
310 | * bmCRC = 1 : CRC is calculated | 306 | * bmCRC = 1 : CRC is calculated |
311 | * bmCRC = 0 : CRC = 0xDEADBEEF | 307 | * bmCRC = 0 : CRC = 0xDEADBEEF |
312 | */ | 308 | */ |
313 | if (header & BIT(14)) | 309 | if (header & BIT(14)) { |
314 | crc2 = ~crc32_le(~0, skb2->data, skb2->len); | 310 | crc = get_unaligned_le32(skb2->data |
315 | else | 311 | + len - ETH_FCS_LEN); |
312 | crc2 = ~crc32_le(~0, skb2->data, skb2->len | ||
313 | - ETH_FCS_LEN); | ||
314 | } else { | ||
315 | crc = get_unaligned_be32(skb2->data | ||
316 | + len - ETH_FCS_LEN); | ||
316 | crc2 = 0xdeadbeef; | 317 | crc2 = 0xdeadbeef; |
318 | } | ||
319 | skb_trim(skb2, len - ETH_FCS_LEN); | ||
317 | 320 | ||
318 | if (is_last) | 321 | if (is_last) |
319 | return crc == crc2; | 322 | return crc == crc2; |
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 32266fb89c20..5c498d2b043f 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/ethtool.h> | 22 | #include <linux/ethtool.h> |
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/virtio.h> | 24 | #include <linux/virtio.h> |
25 | #include <linux/virtio_ids.h> | ||
25 | #include <linux/virtio_net.h> | 26 | #include <linux/virtio_net.h> |
26 | #include <linux/scatterlist.h> | 27 | #include <linux/scatterlist.h> |
27 | #include <linux/if_vlan.h> | 28 | #include <linux/if_vlan.h> |
@@ -320,7 +321,7 @@ static bool try_fill_recv_maxbufs(struct virtnet_info *vi, gfp_t gfp) | |||
320 | skb_queue_head(&vi->recv, skb); | 321 | skb_queue_head(&vi->recv, skb); |
321 | 322 | ||
322 | err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, num, skb); | 323 | err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, num, skb); |
323 | if (err) { | 324 | if (err < 0) { |
324 | skb_unlink(skb, &vi->recv); | 325 | skb_unlink(skb, &vi->recv); |
325 | trim_pages(vi, skb); | 326 | trim_pages(vi, skb); |
326 | kfree_skb(skb); | 327 | kfree_skb(skb); |
@@ -373,7 +374,7 @@ static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp) | |||
373 | skb_queue_head(&vi->recv, skb); | 374 | skb_queue_head(&vi->recv, skb); |
374 | 375 | ||
375 | err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, 1, skb); | 376 | err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, 1, skb); |
376 | if (err) { | 377 | if (err < 0) { |
377 | skb_unlink(skb, &vi->recv); | 378 | skb_unlink(skb, &vi->recv); |
378 | kfree_skb(skb); | 379 | kfree_skb(skb); |
379 | break; | 380 | break; |
@@ -527,7 +528,7 @@ static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb) | |||
527 | num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1; | 528 | num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1; |
528 | 529 | ||
529 | err = vi->svq->vq_ops->add_buf(vi->svq, sg, num, 0, skb); | 530 | err = vi->svq->vq_ops->add_buf(vi->svq, sg, num, 0, skb); |
530 | if (!err && !vi->free_in_tasklet) | 531 | if (err >= 0 && !vi->free_in_tasklet) |
531 | mod_timer(&vi->xmit_free_timer, jiffies + (HZ/10)); | 532 | mod_timer(&vi->xmit_free_timer, jiffies + (HZ/10)); |
532 | 533 | ||
533 | return err; | 534 | return err; |
@@ -538,7 +539,7 @@ static void xmit_tasklet(unsigned long data) | |||
538 | struct virtnet_info *vi = (void *)data; | 539 | struct virtnet_info *vi = (void *)data; |
539 | 540 | ||
540 | netif_tx_lock_bh(vi->dev); | 541 | netif_tx_lock_bh(vi->dev); |
541 | if (vi->last_xmit_skb && xmit_skb(vi, vi->last_xmit_skb) == 0) { | 542 | if (vi->last_xmit_skb && xmit_skb(vi, vi->last_xmit_skb) >= 0) { |
542 | vi->svq->vq_ops->kick(vi->svq); | 543 | vi->svq->vq_ops->kick(vi->svq); |
543 | vi->last_xmit_skb = NULL; | 544 | vi->last_xmit_skb = NULL; |
544 | } | 545 | } |
@@ -557,7 +558,7 @@ again: | |||
557 | 558 | ||
558 | /* If we has a buffer left over from last time, send it now. */ | 559 | /* If we has a buffer left over from last time, send it now. */ |
559 | if (unlikely(vi->last_xmit_skb) && | 560 | if (unlikely(vi->last_xmit_skb) && |
560 | xmit_skb(vi, vi->last_xmit_skb) != 0) | 561 | xmit_skb(vi, vi->last_xmit_skb) < 0) |
561 | goto stop_queue; | 562 | goto stop_queue; |
562 | 563 | ||
563 | vi->last_xmit_skb = NULL; | 564 | vi->last_xmit_skb = NULL; |
@@ -565,7 +566,7 @@ again: | |||
565 | /* Put new one in send queue and do transmit */ | 566 | /* Put new one in send queue and do transmit */ |
566 | if (likely(skb)) { | 567 | if (likely(skb)) { |
567 | __skb_queue_head(&vi->send, skb); | 568 | __skb_queue_head(&vi->send, skb); |
568 | if (xmit_skb(vi, skb) != 0) { | 569 | if (xmit_skb(vi, skb) < 0) { |
569 | vi->last_xmit_skb = skb; | 570 | vi->last_xmit_skb = skb; |
570 | skb = NULL; | 571 | skb = NULL; |
571 | goto stop_queue; | 572 | goto stop_queue; |
@@ -668,7 +669,7 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, | |||
668 | sg_set_buf(&sg[i + 1], sg_virt(s), s->length); | 669 | sg_set_buf(&sg[i + 1], sg_virt(s), s->length); |
669 | sg_set_buf(&sg[out + in - 1], &status, sizeof(status)); | 670 | sg_set_buf(&sg[out + in - 1], &status, sizeof(status)); |
670 | 671 | ||
671 | BUG_ON(vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi)); | 672 | BUG_ON(vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi) < 0); |
672 | 673 | ||
673 | vi->cvq->vq_ops->kick(vi->cvq); | 674 | vi->cvq->vq_ops->kick(vi->cvq); |
674 | 675 | ||
diff --git a/drivers/net/vxge/vxge-config.h b/drivers/net/vxge/vxge-config.h index 62779a520ca1..3e94f0ce0900 100644 --- a/drivers/net/vxge/vxge-config.h +++ b/drivers/net/vxge/vxge-config.h | |||
@@ -1541,7 +1541,7 @@ void vxge_hw_ring_rxd_1b_info_get( | |||
1541 | rxd_info->l4_cksum_valid = | 1541 | rxd_info->l4_cksum_valid = |
1542 | (u32)VXGE_HW_RING_RXD_L4_CKSUM_CORRECT_GET(rxdp->control_0); | 1542 | (u32)VXGE_HW_RING_RXD_L4_CKSUM_CORRECT_GET(rxdp->control_0); |
1543 | rxd_info->l4_cksum = | 1543 | rxd_info->l4_cksum = |
1544 | (u32)VXGE_HW_RING_RXD_L4_CKSUM_GET(rxdp->control_0);; | 1544 | (u32)VXGE_HW_RING_RXD_L4_CKSUM_GET(rxdp->control_0); |
1545 | rxd_info->frame = | 1545 | rxd_info->frame = |
1546 | (u32)VXGE_HW_RING_RXD_ETHER_ENCAP_GET(rxdp->control_0); | 1546 | (u32)VXGE_HW_RING_RXD_ETHER_ENCAP_GET(rxdp->control_0); |
1547 | rxd_info->proto = | 1547 | rxd_info->proto = |
diff --git a/drivers/net/vxge/vxge-main.c b/drivers/net/vxge/vxge-main.c index b378037a29b5..068d7a9d3e36 100644 --- a/drivers/net/vxge/vxge-main.c +++ b/drivers/net/vxge/vxge-main.c | |||
@@ -2350,7 +2350,7 @@ static int vxge_enable_msix(struct vxgedev *vdev) | |||
2350 | enum vxge_hw_status status; | 2350 | enum vxge_hw_status status; |
2351 | /* 0 - Tx, 1 - Rx */ | 2351 | /* 0 - Tx, 1 - Rx */ |
2352 | int tim_msix_id[4]; | 2352 | int tim_msix_id[4]; |
2353 | int alarm_msix_id = 0, msix_intr_vect = 0;; | 2353 | int alarm_msix_id = 0, msix_intr_vect = 0; |
2354 | vdev->intr_cnt = 0; | 2354 | vdev->intr_cnt = 0; |
2355 | 2355 | ||
2356 | /* allocate msix vectors */ | 2356 | /* allocate msix vectors */ |
diff --git a/drivers/net/wireless/arlan-proc.c b/drivers/net/wireless/arlan-proc.c index 2ab1d59870f4..a8b689635a3b 100644 --- a/drivers/net/wireless/arlan-proc.c +++ b/drivers/net/wireless/arlan-proc.c | |||
@@ -402,7 +402,7 @@ static int arlan_setup_card_by_book(struct net_device *dev) | |||
402 | 402 | ||
403 | static char arlan_drive_info[ARLAN_STR_SIZE] = "A655\n\0"; | 403 | static char arlan_drive_info[ARLAN_STR_SIZE] = "A655\n\0"; |
404 | 404 | ||
405 | static int arlan_sysctl_info(ctl_table * ctl, int write, struct file *filp, | 405 | static int arlan_sysctl_info(ctl_table * ctl, int write, |
406 | void __user *buffer, size_t * lenp, loff_t *ppos) | 406 | void __user *buffer, size_t * lenp, loff_t *ppos) |
407 | { | 407 | { |
408 | int i; | 408 | int i; |
@@ -629,7 +629,7 @@ final: | |||
629 | *lenp = pos; | 629 | *lenp = pos; |
630 | 630 | ||
631 | if (!write) | 631 | if (!write) |
632 | retv = proc_dostring(ctl, write, filp, buffer, lenp, ppos); | 632 | retv = proc_dostring(ctl, write, buffer, lenp, ppos); |
633 | else | 633 | else |
634 | { | 634 | { |
635 | *lenp = 0; | 635 | *lenp = 0; |
@@ -639,7 +639,7 @@ final: | |||
639 | } | 639 | } |
640 | 640 | ||
641 | 641 | ||
642 | static int arlan_sysctl_info161719(ctl_table * ctl, int write, struct file *filp, | 642 | static int arlan_sysctl_info161719(ctl_table * ctl, int write, |
643 | void __user *buffer, size_t * lenp, loff_t *ppos) | 643 | void __user *buffer, size_t * lenp, loff_t *ppos) |
644 | { | 644 | { |
645 | int i; | 645 | int i; |
@@ -669,11 +669,11 @@ static int arlan_sysctl_info161719(ctl_table * ctl, int write, struct file *filp | |||
669 | 669 | ||
670 | final: | 670 | final: |
671 | *lenp = pos; | 671 | *lenp = pos; |
672 | retv = proc_dostring(ctl, write, filp, buffer, lenp, ppos); | 672 | retv = proc_dostring(ctl, write, buffer, lenp, ppos); |
673 | return retv; | 673 | return retv; |
674 | } | 674 | } |
675 | 675 | ||
676 | static int arlan_sysctl_infotxRing(ctl_table * ctl, int write, struct file *filp, | 676 | static int arlan_sysctl_infotxRing(ctl_table * ctl, int write, |
677 | void __user *buffer, size_t * lenp, loff_t *ppos) | 677 | void __user *buffer, size_t * lenp, loff_t *ppos) |
678 | { | 678 | { |
679 | int i; | 679 | int i; |
@@ -698,11 +698,11 @@ static int arlan_sysctl_infotxRing(ctl_table * ctl, int write, struct file *filp | |||
698 | SARLBNpln(u_char, txBuffer, 0x800); | 698 | SARLBNpln(u_char, txBuffer, 0x800); |
699 | final: | 699 | final: |
700 | *lenp = pos; | 700 | *lenp = pos; |
701 | retv = proc_dostring(ctl, write, filp, buffer, lenp, ppos); | 701 | retv = proc_dostring(ctl, write, buffer, lenp, ppos); |
702 | return retv; | 702 | return retv; |
703 | } | 703 | } |
704 | 704 | ||
705 | static int arlan_sysctl_inforxRing(ctl_table * ctl, int write, struct file *filp, | 705 | static int arlan_sysctl_inforxRing(ctl_table * ctl, int write, |
706 | void __user *buffer, size_t * lenp, loff_t *ppos) | 706 | void __user *buffer, size_t * lenp, loff_t *ppos) |
707 | { | 707 | { |
708 | int i; | 708 | int i; |
@@ -726,11 +726,11 @@ static int arlan_sysctl_inforxRing(ctl_table * ctl, int write, struct file *filp | |||
726 | SARLBNpln(u_char, rxBuffer, 0x800); | 726 | SARLBNpln(u_char, rxBuffer, 0x800); |
727 | final: | 727 | final: |
728 | *lenp = pos; | 728 | *lenp = pos; |
729 | retv = proc_dostring(ctl, write, filp, buffer, lenp, ppos); | 729 | retv = proc_dostring(ctl, write, buffer, lenp, ppos); |
730 | return retv; | 730 | return retv; |
731 | } | 731 | } |
732 | 732 | ||
733 | static int arlan_sysctl_info18(ctl_table * ctl, int write, struct file *filp, | 733 | static int arlan_sysctl_info18(ctl_table * ctl, int write, |
734 | void __user *buffer, size_t * lenp, loff_t *ppos) | 734 | void __user *buffer, size_t * lenp, loff_t *ppos) |
735 | { | 735 | { |
736 | int i; | 736 | int i; |
@@ -756,7 +756,7 @@ static int arlan_sysctl_info18(ctl_table * ctl, int write, struct file *filp, | |||
756 | 756 | ||
757 | final: | 757 | final: |
758 | *lenp = pos; | 758 | *lenp = pos; |
759 | retv = proc_dostring(ctl, write, filp, buffer, lenp, ppos); | 759 | retv = proc_dostring(ctl, write, buffer, lenp, ppos); |
760 | return retv; | 760 | return retv; |
761 | } | 761 | } |
762 | 762 | ||
@@ -766,7 +766,7 @@ final: | |||
766 | 766 | ||
767 | static char conf_reset_result[200]; | 767 | static char conf_reset_result[200]; |
768 | 768 | ||
769 | static int arlan_configure(ctl_table * ctl, int write, struct file *filp, | 769 | static int arlan_configure(ctl_table * ctl, int write, |
770 | void __user *buffer, size_t * lenp, loff_t *ppos) | 770 | void __user *buffer, size_t * lenp, loff_t *ppos) |
771 | { | 771 | { |
772 | int pos = 0; | 772 | int pos = 0; |
@@ -788,10 +788,10 @@ static int arlan_configure(ctl_table * ctl, int write, struct file *filp, | |||
788 | return -1; | 788 | return -1; |
789 | 789 | ||
790 | *lenp = pos; | 790 | *lenp = pos; |
791 | return proc_dostring(ctl, write, filp, buffer, lenp, ppos); | 791 | return proc_dostring(ctl, write, buffer, lenp, ppos); |
792 | } | 792 | } |
793 | 793 | ||
794 | static int arlan_sysctl_reset(ctl_table * ctl, int write, struct file *filp, | 794 | static int arlan_sysctl_reset(ctl_table * ctl, int write, |
795 | void __user *buffer, size_t * lenp, loff_t *ppos) | 795 | void __user *buffer, size_t * lenp, loff_t *ppos) |
796 | { | 796 | { |
797 | int pos = 0; | 797 | int pos = 0; |
@@ -811,7 +811,7 @@ static int arlan_sysctl_reset(ctl_table * ctl, int write, struct file *filp, | |||
811 | } else | 811 | } else |
812 | return -1; | 812 | return -1; |
813 | *lenp = pos + 3; | 813 | *lenp = pos + 3; |
814 | return proc_dostring(ctl, write, filp, buffer, lenp, ppos); | 814 | return proc_dostring(ctl, write, buffer, lenp, ppos); |
815 | } | 815 | } |
816 | 816 | ||
817 | 817 | ||
diff --git a/drivers/net/wireless/ath/ath5k/reg.h b/drivers/net/wireless/ath/ath5k/reg.h index debad07d9900..c63ea6afd96f 100644 --- a/drivers/net/wireless/ath/ath5k/reg.h +++ b/drivers/net/wireless/ath/ath5k/reg.h | |||
@@ -982,7 +982,7 @@ | |||
982 | #define AR5K_5414_CBCFG_BUF_DIS 0x10 /* Disable buffer */ | 982 | #define AR5K_5414_CBCFG_BUF_DIS 0x10 /* Disable buffer */ |
983 | 983 | ||
984 | /* | 984 | /* |
985 | * PCI-E Power managment configuration | 985 | * PCI-E Power management configuration |
986 | * and status register [5424+] | 986 | * and status register [5424+] |
987 | */ | 987 | */ |
988 | #define AR5K_PCIE_PM_CTL 0x4068 /* Register address */ | 988 | #define AR5K_PCIE_PM_CTL 0x4068 /* Register address */ |
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c index a3b36b3a9d67..cce188837d10 100644 --- a/drivers/net/wireless/atmel.c +++ b/drivers/net/wireless/atmel.c | |||
@@ -3330,7 +3330,7 @@ static void atmel_smooth_qual(struct atmel_private *priv) | |||
3330 | priv->wstats.qual.updated &= ~IW_QUAL_QUAL_INVALID; | 3330 | priv->wstats.qual.updated &= ~IW_QUAL_QUAL_INVALID; |
3331 | } | 3331 | } |
3332 | 3332 | ||
3333 | /* deals with incoming managment frames. */ | 3333 | /* deals with incoming management frames. */ |
3334 | static void atmel_management_frame(struct atmel_private *priv, | 3334 | static void atmel_management_frame(struct atmel_private *priv, |
3335 | struct ieee80211_hdr *header, | 3335 | struct ieee80211_hdr *header, |
3336 | u16 frame_len, u8 rssi) | 3336 | u16 frame_len, u8 rssi) |
diff --git a/drivers/net/wireless/iwmc3200wifi/Kconfig b/drivers/net/wireless/iwmc3200wifi/Kconfig index c62da435285a..c25a04371ca8 100644 --- a/drivers/net/wireless/iwmc3200wifi/Kconfig +++ b/drivers/net/wireless/iwmc3200wifi/Kconfig | |||
@@ -24,8 +24,8 @@ config IWM_DEBUG | |||
24 | To see the list of debug modules and levels, see iwm/debug.h | 24 | To see the list of debug modules and levels, see iwm/debug.h |
25 | 25 | ||
26 | For example, if you want the full MLME debug output: | 26 | For example, if you want the full MLME debug output: |
27 | echo 0xff > /debug/iwm/phyN/debug/mlme | 27 | echo 0xff > /sys/kernel/debug/iwm/phyN/debug/mlme |
28 | 28 | ||
29 | Or, if you want the full debug, for all modules: | 29 | Or, if you want the full debug, for all modules: |
30 | echo 0xff > /debug/iwm/phyN/debug/level | 30 | echo 0xff > /sys/kernel/debug/iwm/phyN/debug/level |
31 | echo 0xff > /debug/iwm/phyN/debug/modules | 31 | echo 0xff > /sys/kernel/debug/iwm/phyN/debug/modules |
diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c index 446e327180f8..cb8be8d7abc1 100644 --- a/drivers/net/wireless/libertas/if_spi.c +++ b/drivers/net/wireless/libertas/if_spi.c | |||
@@ -1222,3 +1222,4 @@ MODULE_DESCRIPTION("Libertas SPI WLAN Driver"); | |||
1222 | MODULE_AUTHOR("Andrey Yurovsky <andrey@cozybit.com>, " | 1222 | MODULE_AUTHOR("Andrey Yurovsky <andrey@cozybit.com>, " |
1223 | "Colin McCabe <colin@cozybit.com>"); | 1223 | "Colin McCabe <colin@cozybit.com>"); |
1224 | MODULE_LICENSE("GPL"); | 1224 | MODULE_LICENSE("GPL"); |
1225 | MODULE_ALIAS("spi:libertas_spi"); | ||
diff --git a/drivers/net/wireless/p54/p54spi.c b/drivers/net/wireless/p54/p54spi.c index 05458d9249ce..afd26bf06649 100644 --- a/drivers/net/wireless/p54/p54spi.c +++ b/drivers/net/wireless/p54/p54spi.c | |||
@@ -731,3 +731,4 @@ module_exit(p54spi_exit); | |||
731 | 731 | ||
732 | MODULE_LICENSE("GPL"); | 732 | MODULE_LICENSE("GPL"); |
733 | MODULE_AUTHOR("Christian Lamparter <chunkeey@web.de>"); | 733 | MODULE_AUTHOR("Christian Lamparter <chunkeey@web.de>"); |
734 | MODULE_ALIAS("spi:cx3110x"); | ||
diff --git a/drivers/net/wireless/wl12xx/wl1251_main.c b/drivers/net/wireless/wl12xx/wl1251_main.c index 5809ef5b18f8..1103256ad989 100644 --- a/drivers/net/wireless/wl12xx/wl1251_main.c +++ b/drivers/net/wireless/wl12xx/wl1251_main.c | |||
@@ -1426,3 +1426,4 @@ EXPORT_SYMBOL_GPL(wl1251_free_hw); | |||
1426 | MODULE_DESCRIPTION("TI wl1251 Wireles LAN Driver Core"); | 1426 | MODULE_DESCRIPTION("TI wl1251 Wireles LAN Driver Core"); |
1427 | MODULE_LICENSE("GPL"); | 1427 | MODULE_LICENSE("GPL"); |
1428 | MODULE_AUTHOR("Kalle Valo <kalle.valo@nokia.com>"); | 1428 | MODULE_AUTHOR("Kalle Valo <kalle.valo@nokia.com>"); |
1429 | MODULE_ALIAS("spi:wl12xx"); | ||
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c index 5e110a2328ae..4e79a9800134 100644 --- a/drivers/net/wireless/zd1211rw/zd_chip.c +++ b/drivers/net/wireless/zd1211rw/zd_chip.c | |||
@@ -368,7 +368,7 @@ error: | |||
368 | return r; | 368 | return r; |
369 | } | 369 | } |
370 | 370 | ||
371 | /* MAC address: if custom mac addresses are to to be used CR_MAC_ADDR_P1 and | 371 | /* MAC address: if custom mac addresses are to be used CR_MAC_ADDR_P1 and |
372 | * CR_MAC_ADDR_P2 must be overwritten | 372 | * CR_MAC_ADDR_P2 must be overwritten |
373 | */ | 373 | */ |
374 | int zd_write_mac_addr(struct zd_chip *chip, const u8 *mac_addr) | 374 | int zd_write_mac_addr(struct zd_chip *chip, const u8 *mac_addr) |