1 From 5bac5f471fb1124c51a5811757c54174f6224e7e Mon Sep 17 00:00:00 2001
2 From: Kurt Mahan <kmahan@freescale.com>
3 Date: Wed, 12 Mar 2008 17:13:29 -0600
4 Subject: [PATCH] Clean up FEC DMA driver.
6 LTIBName: m547x-8x-fec-cleanup
7 Signed-off-by: Kurt Mahan <kmahan@freescale.com>
9 drivers/net/fec/fec.c | 611 +++++++++++++++++++++---------------------------
10 1 files changed, 267 insertions(+), 344 deletions(-)
12 --- a/drivers/net/fec/fec.c
13 +++ b/drivers/net/fec/fec.c
16 * Code crunched to get it to work on 2.6.24 -- FEC cleanup coming
20 #include <linux/module.h>
21 #include <linux/kernel.h>
26 -#define VERSION "0.13"
27 +#define VERSION "0.20"
28 MODULE_DESCRIPTION( "DMA Fast Ethernet Controller driver ver " VERSION);
33 struct net_device *netdev; /* owning net device */
34 - void* fecpriv_txbuf[FEC_TX_BUF_NUMBER]; //Array of transmission buffers
35 - MCD_bufDescFec *fecpriv_txdesc; // Array of transmission descriptors
36 - volatile unsigned int fecpriv_current_tx; // Inex of the transmission descriptor that is used by DMA
37 - volatile unsigned int fecpriv_next_tx; // Inex of the transmission descriptor that can be used for new data
38 - unsigned int fecpriv_current_rx; // Index of the reception descriptor that is used by DMA
39 - MCD_bufDescFec *fecpriv_rxdesc; // Array of reception descriptors
40 -// unsigned char *fecpriv_rxbuf; // Address of reception buffers
41 - struct sk_buff *askb_rx[FEC_RX_BUF_NUMBER]; // Array of reception skb structure pointers
42 - unsigned int fecpriv_initiator_rx; // Reception DMA initiator
43 - unsigned int fecpriv_initiator_tx; // Transmission DMA initiator
44 - int fecpriv_fec_rx_channel; // DMA reception channel
45 - int fecpriv_fec_tx_channel; // DMA transmission channel
46 - int fecpriv_rx_requestor; // DMA reception requestor
47 - int fecpriv_tx_requestor; // DMA transmission requestor
48 - void *fecpriv_interrupt_fec_rx_handler; // DMA reception handler
49 - void *fecpriv_interrupt_fec_tx_handler; // DMA transmission handler
50 - unsigned char *fecpriv_mac_addr; // Private copy of FEC address
51 - struct net_device_stats fecpriv_stat; // Pointer to the statistical information
52 + void* fecpriv_txbuf[FEC_TX_BUF_NUMBER]; /* tx buffer ptrs */
53 + MCD_bufDescFec *fecpriv_txdesc; /* tx descriptor ptrs */
54 + volatile unsigned int fecpriv_current_tx; /* current tx desc index */
55 + volatile unsigned int fecpriv_next_tx; /* next tx desc index */
56 + unsigned int fecpriv_current_rx; /* current rx desc index */
57 + MCD_bufDescFec *fecpriv_rxdesc; /* rx descriptor ptrs */
58 + struct sk_buff *askb_rx[FEC_RX_BUF_NUMBER]; /* rx SKB ptrs */
59 + unsigned int fecpriv_initiator_rx; /* rx dma initiator */
60 + unsigned int fecpriv_initiator_tx; /* tx dma initiator */
61 + int fecpriv_fec_rx_channel; /* rx dma channel */
62 + int fecpriv_fec_tx_channel; /* tx dma channel */
63 + int fecpriv_rx_requestor; /* rx dma requestor */
64 + int fecpriv_tx_requestor; /* tx dma requestor */
65 + void *fecpriv_interrupt_fec_rx_handler; /* dma rx handler */
66 + void *fecpriv_interrupt_fec_tx_handler; /* dma tx handler */
67 + unsigned char *fecpriv_mac_addr; /* private fec mac addr */
68 + struct net_device_stats fecpriv_stat; /* stats ptr */
69 spinlock_t fecpriv_lock;
71 struct tasklet_struct fecpriv_tasklet_reinit;
73 + int index; /* fec hw number */
76 struct net_device *fec_dev[FEC_MAX_PORTS];
80 int __init fec_init(void);
81 struct net_device_stats *fec_get_stat(struct net_device *dev);
83 int fec_open(struct net_device *dev);
84 int fec_close(struct net_device *nd);
85 int fec_tx(struct sk_buff *skb, struct net_device *dev);
86 @@ -93,10 +90,12 @@ void fec_interrupt_fec_tx_handler_fec0(v
87 void fec_interrupt_fec_rx_handler_fec0(void);
88 void fec_interrupt_fec_reinit(unsigned long data);
90 -unsigned char fec_mac_addr_fec0[6] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x50 }; // Default address of FEC0
91 +/* default fec0 address */
92 +unsigned char fec_mac_addr_fec0[6] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x50 };
95 -unsigned char fec_mac_addr_fec1[6] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x51 }; // Default address of FEC1
96 +/* default fec1 address */
97 +unsigned char fec_mac_addr_fec1[6] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x51 };
100 extern unsigned char uboot_enet0[];
101 @@ -111,17 +110,18 @@ int __init fec_mac_setup0 (char *s);
103 void fec_interrupt_fec_tx_handler_fec1(void);
104 void fec_interrupt_fec_rx_handler_fec1(void);
108 int __init fec_mac_setup1 (char *s);
112 int fec_read_mii(unsigned int base_addr, unsigned int pa, unsigned int ra, unsigned int *data);
113 int fec_write_mii(unsigned int base_addr, unsigned int pa, unsigned int ra, unsigned int data);
115 module_init(fec_init);
116 /* module_exit(fec_cleanup); */
118 __setup("mac0=", fec_mac_setup0);
121 @@ -140,7 +140,6 @@ int fec_enet_init(struct net_device *dev
124 fec_dev[ index ] = dev;
125 -printk(KERN_INFO "FEI: index=%d\n", index);
129 @@ -175,8 +174,6 @@ printk(KERN_INFO "FEI: index=%d\n", inde
131 fp->fecpriv_rxdesc = (void*)FEC_RX_DESC_FEC0;
133 -printk(KERN_INFO "FEI: txdesc=0x%p rxdesc=0x%p\n", fp->fecpriv_txdesc, fp->fecpriv_rxdesc);
136 if (uboot_enet0[0] || uboot_enet0[1] || uboot_enet0[2] ||
137 uboot_enet0[3] || uboot_enet0[4] || uboot_enet0[5]) {
138 @@ -229,8 +226,6 @@ printk(KERN_INFO "FEI: txdesc=0x%p rxde
142 -printk(KERN_INFO "FEI: index=%d base_addr=0x%lx\n", index, dev->base_addr);
145 memset((void *) (dev->base_addr + 0x200), 0, FEC_MIB_LEN);
147 @@ -288,8 +283,7 @@ int __init fec_init(void)
149 DECLARE_MAC_BUF(mac);
151 - printk(KERN_INFO "FEC ENET (DMA) Version .00\n");
153 + printk(KERN_INFO "FEC ENET (DMA) Version %s\n", VERSION);
155 for (i = 0; i < FEC_MAX_PORTS; i++) {
156 dev = alloc_etherdev(sizeof(struct fec_priv));
157 @@ -333,7 +327,6 @@ void fec_stop(struct net_device *dev)
159 * RETURNS: If no error occurs, this function returns zero.
160 *************************************************************************/
162 int fec_open(struct net_device *dev)
164 struct fec_priv *fp = netdev_priv(dev);
165 @@ -343,13 +336,10 @@ int fec_open(struct net_device *dev)
167 int error_code = -EBUSY;
169 -printk(KERN_INFO "FECOPEN: index=%d\n", fp->index);
171 - //Receive the DMA channels
172 + /* Receive the DMA channels */
173 channel = dma_set_channel_fec(fp->fecpriv_rx_requestor);
177 + if (channel == -1) {
178 printk("Dma channel cannot be reserved\n");
181 @@ -360,60 +350,54 @@ printk(KERN_INFO "FECOPEN: index=%d\n",
183 channel = dma_set_channel_fec(fp->fecpriv_tx_requestor);
187 + if (channel == -1) {
188 printk("Dma channel cannot be reserved\n");
191 -printk(KERN_INFO "FECOPEN2\n");
193 fp->fecpriv_fec_tx_channel = channel;
195 dma_connect(channel, (int) fp->fecpriv_interrupt_fec_tx_handler);
197 - // init tasklet for controller reinitialization
198 + /* init tasklet for controller reinitialization */
199 tasklet_init(&fp->fecpriv_tasklet_reinit, fec_interrupt_fec_reinit, (unsigned long) dev);
200 -printk(KERN_INFO "FECOPEN3\n");
204 FEC_FECFRST(base_addr) |= FEC_SW_RST | FEC_RST_CTL;
205 FEC_FECFRST(base_addr) &= ~FEC_SW_RST;
207 - // Reset and disable FEC
208 + /* Reset and disable FEC */
209 FEC_ECR(base_addr) = FEC_ECR_RESET;
214 - // Clear all events
215 + /* Clear all events */
216 FEC_EIR(base_addr) = FEC_EIR_CLEAR;
218 - // Reset FIFO status
219 + /* Reset FIFO status */
220 FEC_FECTFSR(base_addr) = FEC_FECTFSR_MSK;
221 FEC_FECRFSR(base_addr) = FEC_FECRFSR_MSK;
224 -/* JKM -- move into HW init */
225 - // Copy the default address to the device structure
226 - memcpy(dev->dev_addr, fp->fecpriv_mac_addr, ETH_ALEN);
228 + /* Set the default address */
229 + FEC_PALR(base_addr) = (fp->fecpriv_mac_addr[0] << 24) |
230 + (fp->fecpriv_mac_addr[1] << 16) |
231 + (fp->fecpriv_mac_addr[2] << 8) |
232 + fp->fecpriv_mac_addr[3];
233 + FEC_PAUR(base_addr) = (fp->fecpriv_mac_addr[4] << 24) |
234 + (fp->fecpriv_mac_addr[5] << 16) | 0x8808;
236 - // Set the default address
237 - FEC_PALR(base_addr) = (fp->fecpriv_mac_addr[0] << 24) | (fp->fecpriv_mac_addr[1] << 16) | (fp->fecpriv_mac_addr[2] << 8) | fp->fecpriv_mac_addr[3];
238 - FEC_PAUR(base_addr) = (fp->fecpriv_mac_addr[4] << 24) | (fp->fecpriv_mac_addr[5] << 16) | 0x8808;
240 - // Reset the group address descriptor
241 + /* Reset the group address descriptor */
242 FEC_GALR(base_addr) = 0x00000000;
243 FEC_GAUR(base_addr) = 0x00000000;
245 - // Reset the individual address descriptor
246 + /* Reset the individual address descriptor */
247 FEC_IALR(base_addr) = 0x00000000;
248 FEC_IAUR(base_addr) = 0x00000000;
250 - // Set the receive control register
251 + /* Set the receive control register */
252 FEC_RCR(base_addr) = FEC_RCR_MAX_FRM_SIZE | FEC_RCR_MII;
254 - // Set the receive FIFO control register
255 + /* Set the receive FIFO control register */
256 // FEC_FECRFCR(base_addr) = FEC_FECRFCR_FRM | FEC_FECRFCR_GR | FEC_FECRFCR_MSK;
257 FEC_FECRFCR(base_addr) = FEC_FECRFCR_FRM | FEC_FECRFCR_GR
258 | (FEC_FECRFCR_MSK // disable all but ...
259 @@ -422,10 +406,10 @@ printk(KERN_INFO "FECOPEN3\n");
260 // & ~FEC_FECRFCR_UF // enable FIFO underflow
263 - //Set the receive FIFO alarm register
264 + /* Set the receive FIFO alarm register */
265 FEC_FECRFAR(base_addr) = FEC_FECRFAR_ALARM;
267 - // Set the transmit FIFO control register
268 + /* Set the transmit FIFO control register */
269 // FEC_FECTFCR(base_addr) = FEC_FECTFCR_FRM | FEC_FECTFCR_GR | FEC_FECTFCR_MSK;
270 FEC_FECTFCR(base_addr) = FEC_FECTFCR_FRM | FEC_FECTFCR_GR
271 | (FEC_FECTFCR_MSK // disable all but ...
272 @@ -434,16 +418,16 @@ printk(KERN_INFO "FECOPEN3\n");
273 // & ~FEC_FECTFCR_UF // enable FIFO underflow
274 & ~FEC_FECTFCR_OF); // enable FIFO overflow
276 - //Set the transmit FIFO alarm register
277 + /* Set the transmit FIFO alarm register */
278 FEC_FECTFAR(base_addr) = FEC_FECTFAR_ALARM;
280 - // Set the Tx FIFO watermark
281 + /* Set the Tx FIFO watermark */
282 FEC_FECTFWR(base_addr) = FEC_FECTFWR_XWMRK;
284 - // Enable the transmitter to append the CRC
285 + /* Enable the transmitter to append the CRC */
286 FEC_CTCWR(base_addr) = FEC_CTCWR_TFCW_CRC;
288 - // Enable the ethernet interrupts
289 + /* Enable the ethernet interrupts */
290 // FEC_EIMR(base_addr) = FEC_EIMR_MASK;
291 FEC_EIMR(base_addr) = FEC_EIMR_DISABLE
293 @@ -453,9 +437,16 @@ printk(KERN_INFO "FECOPEN3\n");
297 -printk(KERN_INFO "FECOPEN4\n");
299 -#ifdef CONFIG_FEC_548x_AUTO_NEGOTIATION
303 + * There's a problem with the PHY initialization code --
304 + * for now assume uboot left it in an initialized state.
306 +// printk(KERN_INFO "FECOPEN: starting auto-negotiation\n");
307 +// #ifdef CONFIG_FEC_548x_AUTO_NEGOTIATION
309 if ((error_code = init_transceiver(base_addr, &fduplex)) != 0)
311 printk("Initialization of the transceiver is failed\n");
312 @@ -464,25 +455,24 @@ printk(KERN_INFO "FECOPEN4\n");
316 -printk(KERN_INFO "FECOPEN5\n");
317 +// printk(KERN_INFO "FECOPEN: done with auto-negotiation\n");
320 - // Enable the full duplex mode
321 + /* Enable the full duplex mode */
322 FEC_TCR(base_addr) = FEC_TCR_FDEN | FEC_TCR_HBC;
324 - // Disable reception of frames while transmitting
325 + /* Disable reception of frames while transmitting */
326 FEC_RCR(base_addr) |= FEC_RCR_DRT;
330 FEC_MIBC(base_addr) = FEC_MIBC_ENABLE;
334 FEC_ECR(base_addr) |= FEC_ECR_ETHEREN;
336 - // Initialize transmission descriptors and start DMA for the transmission
337 + /* Initialize tx descriptors and start DMA for the transmission */
338 for (i = 0; i < FEC_TX_BUF_NUMBER; i++)
339 fp->fecpriv_txdesc[i].statCtrl = MCD_FEC_INTERRUPT;
340 -printk(KERN_INFO "FECOPEN6\n");
342 fp->fecpriv_txdesc[i - 1].statCtrl |= MCD_FEC_WRAP;
344 @@ -494,31 +484,27 @@ printk(KERN_INFO "FECOPEN6\n");
345 FEC_TX_DMA_PRI, MCD_FECTX_DMA | MCD_INTERRUPT,
346 MCD_NO_CSUM | MCD_NO_BYTE_SWAP);
348 - // Initialize reception descriptors and start DMA for the reception
349 - for (i = 0; i < FEC_RX_BUF_NUMBER; i++)
351 + /* Initialize rx descriptors and start DMA for the reception */
352 + for (i = 0; i < FEC_RX_BUF_NUMBER; i++) {
353 fp->askb_rx[i] = alloc_skb(FEC_MAXBUF_SIZE + 16, GFP_DMA);
354 - if (!fp->askb_rx[i])
356 - fp->fecpriv_rxdesc[i].dataPointer = 0;
357 - fp->fecpriv_rxdesc[i].statCtrl = 0;
358 - fp->fecpriv_rxdesc[i].length = 0;
359 + if (!fp->askb_rx[i]) {
360 + fp->fecpriv_rxdesc[i].dataPointer = 0;
361 + fp->fecpriv_rxdesc[i].statCtrl = 0;
362 + fp->fecpriv_rxdesc[i].length = 0;
366 - skb_reserve(fp->askb_rx[i], 16);
368 + skb_reserve(fp->askb_rx[i], 16);
369 fp->askb_rx[i]->dev = dev;
370 - fp->fecpriv_rxdesc[i].dataPointer = (unsigned int) virt_to_phys(fp->askb_rx[i]->tail);
371 - fp->fecpriv_rxdesc[i].statCtrl = MCD_FEC_BUF_READY | MCD_FEC_INTERRUPT;
372 - fp->fecpriv_rxdesc[i].length = FEC_MAXBUF_SIZE;
374 + fp->fecpriv_rxdesc[i].dataPointer = (unsigned int) virt_to_phys(fp->askb_rx[i]->tail);
375 + fp->fecpriv_rxdesc[i].statCtrl = MCD_FEC_BUF_READY | MCD_FEC_INTERRUPT;
376 + fp->fecpriv_rxdesc[i].length = FEC_MAXBUF_SIZE;
379 -printk(KERN_INFO "FECOPEN7\n");
381 fp->fecpriv_rxdesc[i - 1].statCtrl |= MCD_FEC_WRAP;
382 fp->fecpriv_current_rx = 0;
384 - // flush entire data cache before restarting the DMA
385 + /* flush entire data cache before restarting the DMA */
387 /* JKM -- currently running with cache turned off */
388 DcacheFlushInvalidate();
389 @@ -531,31 +517,24 @@ printk(KERN_INFO "FECOPEN7\n");
390 MCD_NO_CSUM | MCD_NO_BYTE_SWAP);
392 netif_start_queue(dev);
394 -// MOD_INC_USE_COUNT;
395 -printk(KERN_INFO "FECOPEN: finished\n");
401 - // Remove the channels and return with the error code
402 - if (fp->fecpriv_fec_rx_channel != -1)
404 + /* Remove the channels and return with the error code */
405 + if (fp->fecpriv_fec_rx_channel != -1) {
406 dma_disconnect(fp->fecpriv_fec_rx_channel);
407 dma_remove_channel_by_number(fp->fecpriv_fec_rx_channel);
408 fp->fecpriv_fec_rx_channel = -1;
411 - if (fp->fecpriv_fec_tx_channel != -1)
413 + if (fp->fecpriv_fec_tx_channel != -1) {
414 dma_disconnect(fp->fecpriv_fec_tx_channel);
415 dma_remove_channel_by_number(fp->fecpriv_fec_tx_channel);
416 fp->fecpriv_fec_tx_channel = -1;
423 /************************************************************************
424 @@ -568,31 +547,26 @@ ERRORS:
425 *************************************************************************/
426 int fec_close(struct net_device *dev)
428 - //Receive the pointer to the private structure
429 struct fec_priv *fp = netdev_priv(dev);
431 - // Receive the base address
432 unsigned long base_addr = (unsigned long) dev->base_addr;
438 netif_stop_queue(dev);
440 - // Perform the graceful stop
441 + /* Perform the graceful stop */
442 FEC_TCR(base_addr) |= FEC_TCR_GTS;
446 - // Wait for the graceful stop
447 + /* Wait for the graceful stop */
448 while (!(FEC_EIR(base_addr) & FEC_EIR_GRA) && jiffies - time < FEC_GR_TIMEOUT * HZ)
453 FEC_ECR(base_addr) = FEC_ECR_DISABLE;
455 - // Reset the DMA channels
456 + /* Reset the DMA channels */
457 spin_lock_irq(&fp->fecpriv_lock);
458 MCD_killDma(fp->fecpriv_fec_tx_channel);
459 spin_unlock_irq(&fp->fecpriv_lock);
460 @@ -600,12 +574,12 @@ int fec_close(struct net_device *dev)
461 dma_disconnect(fp->fecpriv_fec_tx_channel);
462 fp->fecpriv_fec_tx_channel = -1;
464 - for (i = 0; i < FEC_TX_BUF_NUMBER; i++)
465 - if (fp->fecpriv_txbuf[i])
467 + for (i = 0; i < FEC_TX_BUF_NUMBER; i++) {
468 + if (fp->fecpriv_txbuf[i]) {
469 kfree(fp->fecpriv_txbuf[i]);
470 fp->fecpriv_txbuf[i] = NULL;
474 spin_lock_irq(&fp->fecpriv_lock);
475 MCD_killDma(fp->fecpriv_fec_rx_channel);
476 @@ -615,15 +589,12 @@ int fec_close(struct net_device *dev)
477 dma_disconnect(fp->fecpriv_fec_rx_channel);
478 fp->fecpriv_fec_rx_channel = -1;
480 - for (i = 0; i < FEC_RX_BUF_NUMBER; i++)
482 - if (fp->askb_rx[i])
484 - kfree_skb(fp->askb_rx[i]);
485 - fp->askb_rx[i] = NULL;
487 + for (i = 0; i < FEC_RX_BUF_NUMBER; i++) {
488 + if (fp->askb_rx[i]) {
489 + kfree_skb(fp->askb_rx[i]);
490 + fp->askb_rx[i] = NULL;
493 -// MOD_DEC_USE_COUNT;
497 @@ -635,14 +606,10 @@ int fec_close(struct net_device *dev)
498 *************************************************************************/
499 struct net_device_stats * fec_get_stat(struct net_device *dev)
502 - //Receive the pointer to the private structure
503 struct fec_priv *fp = netdev_priv(dev);
505 - // Receive the base address
506 unsigned long base_addr = dev->base_addr;
508 - // Receive the statistical information
509 + /* Receive the statistical information */
510 fp->fecpriv_stat.rx_packets = FECSTAT_RMON_R_PACKETS(base_addr);
511 fp->fecpriv_stat.tx_packets = FECSTAT_RMON_T_PACKETS(base_addr);
512 fp->fecpriv_stat.rx_bytes = FECSTAT_RMON_R_OCTETS(base_addr);
513 @@ -651,7 +618,10 @@ struct net_device_stats * fec_get_stat(s
514 fp->fecpriv_stat.multicast = FECSTAT_RMON_R_MC_PKT(base_addr);
515 fp->fecpriv_stat.collisions = FECSTAT_RMON_T_COL(base_addr);
517 - fp->fecpriv_stat.rx_length_errors = FECSTAT_RMON_R_UNDERSIZE(base_addr) + FECSTAT_RMON_R_OVERSIZE(base_addr) + FECSTAT_RMON_R_FRAG(base_addr) + FECSTAT_RMON_R_JAB(base_addr);
518 + fp->fecpriv_stat.rx_length_errors = FECSTAT_RMON_R_UNDERSIZE(base_addr) +
519 + FECSTAT_RMON_R_OVERSIZE(base_addr) +
520 + FECSTAT_RMON_R_FRAG(base_addr) +
521 + FECSTAT_RMON_R_JAB(base_addr);
522 fp->fecpriv_stat.rx_crc_errors = FECSTAT_IEEE_R_CRC(base_addr);
523 fp->fecpriv_stat.rx_frame_errors = FECSTAT_IEEE_R_ALIGN(base_addr);
524 fp->fecpriv_stat.rx_over_errors = FECSTAT_IEEE_R_MACERR(base_addr);
525 @@ -660,9 +630,18 @@ struct net_device_stats * fec_get_stat(s
526 fp->fecpriv_stat.tx_fifo_errors = FECSTAT_IEEE_T_MACERR(base_addr);
527 fp->fecpriv_stat.tx_window_errors = FECSTAT_IEEE_T_LCOL(base_addr);
529 - // I hope that one frame doesn't have more than one error
530 - fp->fecpriv_stat.rx_errors = fp->fecpriv_stat.rx_length_errors + fp->fecpriv_stat.rx_crc_errors + fp->fecpriv_stat.rx_frame_errors + fp->fecpriv_stat.rx_over_errors + fp->fecpriv_stat.rx_dropped;
531 - fp->fecpriv_stat.tx_errors = fp->fecpriv_stat.tx_carrier_errors + fp->fecpriv_stat.tx_fifo_errors + fp->fecpriv_stat.tx_window_errors + fp->fecpriv_stat.tx_aborted_errors + fp->fecpriv_stat.tx_heartbeat_errors + fp->fecpriv_stat.tx_dropped;
532 + /* I hope that one frame doesn't have more than one error */
533 + fp->fecpriv_stat.rx_errors = fp->fecpriv_stat.rx_length_errors +
534 + fp->fecpriv_stat.rx_crc_errors +
535 + fp->fecpriv_stat.rx_frame_errors +
536 + fp->fecpriv_stat.rx_over_errors +
537 + fp->fecpriv_stat.rx_dropped;
538 + fp->fecpriv_stat.tx_errors = fp->fecpriv_stat.tx_carrier_errors +
539 + fp->fecpriv_stat.tx_fifo_errors +
540 + fp->fecpriv_stat.tx_window_errors +
541 + fp->fecpriv_stat.tx_aborted_errors +
542 + fp->fecpriv_stat.tx_heartbeat_errors +
543 + fp->fecpriv_stat.tx_dropped;
545 return &fp->fecpriv_stat;
547 @@ -674,59 +653,47 @@ struct net_device_stats * fec_get_stat(s
548 *************************************************************************/
549 void fec_set_multicast_list(struct net_device *dev)
551 - // Pointer to the address list
552 struct dev_mc_list *dmi;
554 unsigned int crc, data;
557 - // Receive the base address
558 unsigned long base_addr = (unsigned long) dev->base_addr;
560 - if (dev->flags & IFF_PROMISC || dev->flags & IFF_ALLMULTI)
562 - // Allow all incoming frames
563 + if (dev->flags & IFF_PROMISC || dev->flags & IFF_ALLMULTI) {
564 + /* Allow all incoming frames */
565 FEC_GALR(base_addr) = 0xFFFFFFFF;
566 FEC_GAUR(base_addr) = 0xFFFFFFFF;
569 - // Reset the group address register
571 + /* Reset the group address register */
572 FEC_GALR(base_addr) = 0x00000000;
573 FEC_GAUR(base_addr) = 0x00000000;
575 - // Process all addresses
576 - for (i = 0, dmi = dev->mc_list; i < dev->mc_count; i++, dmi = dmi->next)
578 - // Processing must be only for the group addresses
579 + /* Process all addresses */
580 + for (i = 0, dmi = dev->mc_list; i < dev->mc_count; i++, dmi = dmi->next) {
581 + /* Processing must be only for the group addresses */
582 if (!(dmi->dmi_addr[0] & 1))
585 - // Calculate crc value for the current address
586 + /* Calculate crc value for the current address */
588 - for (j = 0; j < dmi->dmi_addrlen; j++)
591 - for (k = 0, data = dmi->dmi_addr[j]; k < 8; k++, data >>= 1)
593 + for (j = 0; j < dmi->dmi_addrlen; j++) {
594 + for (k = 0, data = dmi->dmi_addr[j]; k < 8; k++, data >>= 1) {
595 if ((crc ^ data) & 1)
596 crc = (crc >> 1) ^ FEC_CRCPOL;
605 + /* Add this value */
609 FEC_GAUR(base_addr) |= 0x1 << (crc - 32);
611 FEC_GALR(base_addr) |= 0x1 << crc;
617 /************************************************************************
618 @@ -736,26 +703,27 @@ void fec_set_multicast_list(struct net_d
619 *************************************************************************/
620 int fec_set_mac_address(struct net_device *dev, void *p)
622 - //Receive the pointer to the private structure
623 struct fec_priv *fp = netdev_priv(dev);
625 - // Receive the base address
626 unsigned long base_addr = (unsigned long) dev->base_addr;
628 struct sockaddr *addr = p;
630 if (netif_running(dev))
633 - // Copy a new address to the device structure
634 + /* Copy a new address to the device structure */
635 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
637 - // Copy a new address to the private structure
638 + /* Copy a new address to the private structure */
639 memcpy(fp->fecpriv_mac_addr, addr->sa_data, 6);
641 - // Set the address to the registers
642 - FEC_PALR(base_addr) = (fp->fecpriv_mac_addr[0] << 24) | (fp->fecpriv_mac_addr[1] << 16) | (fp->fecpriv_mac_addr[2] << 8) | fp->fecpriv_mac_addr[3];
643 - FEC_PAUR(base_addr) = (fp->fecpriv_mac_addr[4] << 24) | (fp->fecpriv_mac_addr[5] << 16) | 0x8808;
644 + /* Set the address to the registers */
645 + FEC_PALR(base_addr) = (fp->fecpriv_mac_addr[0] << 24) |
646 + (fp->fecpriv_mac_addr[1] << 16) |
647 + (fp->fecpriv_mac_addr[2] << 8) |
648 + fp->fecpriv_mac_addr[3];
649 + FEC_PAUR(base_addr) = (fp->fecpriv_mac_addr[4] << 24) |
650 + (fp->fecpriv_mac_addr[5] << 16) |
655 @@ -769,27 +737,24 @@ int fec_set_mac_address(struct net_devic
656 *************************************************************************/
657 int fec_tx(struct sk_buff *skb, struct net_device *dev)
660 - //Receive the pointer to the private structure
661 struct fec_priv *fp = netdev_priv(dev);
663 void *data, *data_aligned;
666 data = kmalloc(skb->len + 15, GFP_DMA | GFP_ATOMIC);
671 fp->fecpriv_stat.tx_dropped++;
676 - offset = (((unsigned long)virt_to_phys(data) + 15) & 0xFFFFFFF0) - (unsigned long)virt_to_phys(data);
677 + offset = (((unsigned long)virt_to_phys(data) + 15) & 0xFFFFFFF0) -
678 + (unsigned long)virt_to_phys(data);
679 data_aligned = (void*)((unsigned long)data + offset);
680 memcpy(data_aligned, skb->data, skb->len);
682 - // flush data cache before initializing the descriptor and starting DMA
683 + /* flush data cache before initializing the descriptor and starting DMA */
685 /* JKM -- currently running with cache turned off */
686 DcacheFlushInvalidateCacheBlock((void*)virt_to_phys(data_aligned), skb->len);
687 @@ -797,7 +762,7 @@ int fec_tx(struct sk_buff *skb, struct n
689 spin_lock_irq(&fp->fecpriv_lock);
691 - // Initialize the descriptor
692 + /* Initialize the descriptor */
693 fp->fecpriv_txbuf[fp->fecpriv_next_tx] = data;
694 fp->fecpriv_txdesc[fp->fecpriv_next_tx].dataPointer = (unsigned int) virt_to_phys(data_aligned);
695 fp->fecpriv_txdesc[fp->fecpriv_next_tx].length = skb->len;
696 @@ -809,7 +774,7 @@ int fec_tx(struct sk_buff *skb, struct n
698 spin_unlock_irq(&fp->fecpriv_lock);
700 - // Tell the DMA to continue the transmission
701 + /* Tell the DMA to continue the transmission */
702 MCD_continDma(fp->fecpriv_fec_tx_channel);
705 @@ -835,14 +800,10 @@ void fec_tx_timeout(struct net_device *d
707 spin_lock_irq(&fp->fecpriv_lock);
708 MCD_killDma(fp->fecpriv_fec_tx_channel);
709 - for (i = 0; i < FEC_TX_BUF_NUMBER; i++)
711 - if (fp->fecpriv_txbuf[i])
714 + for (i = 0; i < FEC_TX_BUF_NUMBER; i++) {
715 + if (fp->fecpriv_txbuf[i]) {
716 kfree(fp->fecpriv_txbuf[i]);
717 fp->fecpriv_txbuf[i] = NULL;
720 fp->fecpriv_txdesc[i].statCtrl = MCD_FEC_INTERRUPT;
722 @@ -850,14 +811,14 @@ void fec_tx_timeout(struct net_device *d
724 fp->fecpriv_current_tx = fp->fecpriv_next_tx = 0;
728 FEC_FECFRST(base_addr) |= FEC_SW_RST;
729 FEC_FECFRST(base_addr) &= ~FEC_SW_RST;
731 - // Reset and disable FEC
732 + /* Reset and disable FEC */
733 // FEC_ECR(base_addr) = FEC_ECR_RESET;
737 FEC_ECR(base_addr) |= FEC_ECR_ETHEREN;
739 MCD_startDma(fp->fecpriv_fec_tx_channel, (char *) fp->fecpriv_txdesc, 0,
740 @@ -883,23 +844,22 @@ int fec_read_mii(unsigned int base_addr,
744 - // Clear the MII interrupt bit
745 + /* Clear the MII interrupt bit */
746 FEC_EIR(base_addr) = FEC_EIR_MII;
748 - // Write to the MII management frame register
749 + /* Write to the MII management frame register */
750 FEC_MMFR(base_addr) = FEC_MMFR_READ | (pa << 23) | (ra << 18);
754 - // Wait for the reading
755 - while (!(FEC_EIR(base_addr) & FEC_EIR_MII))
757 + /* Wait for the reading */
758 + while (!(FEC_EIR(base_addr) & FEC_EIR_MII)) {
759 if (jiffies - time > FEC_MII_TIMEOUT * HZ)
764 - // Clear the MII interrupt bit
765 + /* Clear the MII interrupt bit */
766 FEC_EIR(base_addr) = FEC_EIR_MII;
768 *data = FEC_MMFR(base_addr) & 0x0000FFFF;
769 @@ -918,25 +878,22 @@ int fec_write_mii(unsigned int base_addr
773 - // Clear the MII interrupt bit
774 + /* Clear the MII interrupt bit */
775 FEC_EIR(base_addr) = FEC_EIR_MII;
777 - // Write to the MII management frame register
778 + /* Write to the MII management frame register */
779 FEC_MMFR(base_addr) = FEC_MMFR_WRITE | (pa << 23) | (ra << 18) | data;
783 - // Wait for the writing
785 - while (!(FEC_EIR(base_addr) & FEC_EIR_MII))
787 + /* Wait for the writing */
788 + while (!(FEC_EIR(base_addr) & FEC_EIR_MII)) {
789 if (jiffies - time > FEC_MII_TIMEOUT * HZ)
795 - // Clear the MII interrupt bit
796 + /* Clear the MII interrupt bit */
797 FEC_EIR(base_addr) = FEC_EIR_MII;
800 @@ -953,27 +910,24 @@ void fec_interrupt_fec_tx_handler(struct
802 struct fec_priv *fp = netdev_priv(dev);
804 - //Release the socket buffer
805 - if(fp->fecpriv_txbuf[fp->fecpriv_current_tx])
807 + /* Release the socket buffer */
808 + if(fp->fecpriv_txbuf[fp->fecpriv_current_tx]) {
809 kfree(fp->fecpriv_txbuf[fp->fecpriv_current_tx]);
810 fp->fecpriv_txbuf[fp->fecpriv_current_tx] = NULL;
812 fp->fecpriv_current_tx = (fp->fecpriv_current_tx + 1) & FEC_TX_INDEX_MASK;
814 - if (MCD_dmaStatus(fp->fecpriv_fec_tx_channel) == MCD_DONE)
815 - for (; fp->fecpriv_current_tx != fp->fecpriv_next_tx; fp->fecpriv_current_tx = (fp->fecpriv_current_tx + 1) & FEC_TX_INDEX_MASK)
817 - if(fp->fecpriv_txbuf[fp->fecpriv_current_tx])
819 + if (MCD_dmaStatus(fp->fecpriv_fec_tx_channel) == MCD_DONE) {
820 + for (; fp->fecpriv_current_tx != fp->fecpriv_next_tx; fp->fecpriv_current_tx = (fp->fecpriv_current_tx + 1) & FEC_TX_INDEX_MASK) {
821 + if(fp->fecpriv_txbuf[fp->fecpriv_current_tx]) {
822 kfree(fp->fecpriv_txbuf[fp->fecpriv_current_tx]);
823 fp->fecpriv_txbuf[fp->fecpriv_current_tx] = NULL;
828 if (netif_queue_stopped(dev))
829 netif_wake_queue(dev);
833 /************************************************************************
834 @@ -1008,49 +962,41 @@ void fec_interrupt_fec_rx_handler(struct
838 - for (; fp->fecpriv_rxdesc[fp->fecpriv_current_rx].statCtrl & MCD_FEC_END_FRAME; fp->fecpriv_current_rx = (fp->fecpriv_current_rx + 1) & FEC_RX_INDEX_MASK)
840 + for (; fp->fecpriv_rxdesc[fp->fecpriv_current_rx].statCtrl & MCD_FEC_END_FRAME; fp->fecpriv_current_rx = (fp->fecpriv_current_rx + 1) & FEC_RX_INDEX_MASK) {
841 if( (fp->fecpriv_rxdesc[fp->fecpriv_current_rx].length <= FEC_MAXBUF_SIZE) &&
842 - (fp->fecpriv_rxdesc[fp->fecpriv_current_rx].length > 4)) // --tym--
844 + (fp->fecpriv_rxdesc[fp->fecpriv_current_rx].length > 4)) { /* --tym-- */
845 skb = fp->askb_rx[fp->fecpriv_current_rx];
848 - fp->fecpriv_stat.rx_dropped++;
852 - // flush data cache before initializing the descriptor and starting DMA
853 + fp->fecpriv_stat.rx_dropped++;
855 + /* flush data cache before initializing the descriptor and starting DMA */
856 // DcacheFlushInvalidateCacheBlock((void*)virt_to_phys(fp->askb_rx[fp->fecpriv_current_rx]->tail), fp->askb_rx[fp->fecpriv_current_rx]->len);
858 skb_put(skb, fp->fecpriv_rxdesc[fp->fecpriv_current_rx].length - 4);
860 skb->protocol = eth_type_trans(skb, dev);
863 - fp->fecpriv_rxdesc[fp->fecpriv_current_rx].statCtrl &= ~MCD_FEC_END_FRAME;
864 - // allocate new skbuff
866 + fp->fecpriv_rxdesc[fp->fecpriv_current_rx].statCtrl &= ~MCD_FEC_END_FRAME;
867 + /* allocate new skbuff */
868 fp->askb_rx[fp->fecpriv_current_rx] = alloc_skb(FEC_MAXBUF_SIZE + 16, /*GFP_ATOMIC |*/ GFP_DMA);
869 - if (!fp->askb_rx[fp->fecpriv_current_rx])
871 - fp->fecpriv_rxdesc[fp->fecpriv_current_rx].dataPointer = 0;
872 - fp->fecpriv_rxdesc[fp->fecpriv_current_rx].length = 0;
873 - fp->fecpriv_stat.rx_dropped++;
877 - skb_reserve(fp->askb_rx[fp->fecpriv_current_rx], 16);
878 - fp->askb_rx[fp->fecpriv_current_rx]->dev = dev;
879 + if (!fp->askb_rx[fp->fecpriv_current_rx]) {
880 + fp->fecpriv_rxdesc[fp->fecpriv_current_rx].dataPointer = 0;
881 + fp->fecpriv_rxdesc[fp->fecpriv_current_rx].length = 0;
882 + fp->fecpriv_stat.rx_dropped++;
885 + skb_reserve(fp->askb_rx[fp->fecpriv_current_rx], 16);
886 + fp->askb_rx[fp->fecpriv_current_rx]->dev = dev;
888 - // flush data cache before initializing the descriptor and starting DMA
889 + /* flush data cache before initializing the descriptor and starting DMA */
891 /* JKM -- currently running with cache turned off */
892 - DcacheFlushInvalidateCacheBlock((void*)virt_to_phys(fp->askb_rx[fp->fecpriv_current_rx]->tail), FEC_MAXBUF_SIZE);
893 + DcacheFlushInvalidateCacheBlock((void*)virt_to_phys(fp->askb_rx[fp->fecpriv_current_rx]->tail), FEC_MAXBUF_SIZE);
896 fp->fecpriv_rxdesc[fp->fecpriv_current_rx].dataPointer = (unsigned int) virt_to_phys(fp->askb_rx[fp->fecpriv_current_rx]->tail);
897 fp->fecpriv_rxdesc[fp->fecpriv_current_rx].length = FEC_MAXBUF_SIZE;
898 - fp->fecpriv_rxdesc[fp->fecpriv_current_rx].statCtrl |= MCD_FEC_BUF_READY;
899 + fp->fecpriv_rxdesc[fp->fecpriv_current_rx].statCtrl |= MCD_FEC_BUF_READY;
901 // flush data cache before initializing the descriptor and starting DMA
902 // DcacheFlushInvalidateCacheBlock((void*)virt_to_phys(fp->askb_rx[fp->fecpriv_current_rx]->tail), FEC_MAXBUF_SIZE);
903 @@ -1059,11 +1005,10 @@ void fec_interrupt_fec_rx_handler(struct
907 - // Tell the DMA to continue the reception
908 + /* Tell the DMA to continue the reception */
909 MCD_continDma(fp->fecpriv_fec_rx_channel);
911 fp->fecpriv_rxflag = 0;
915 /************************************************************************
916 @@ -1080,76 +1025,70 @@ irqreturn_t fec_interrupt_handler(int ir
917 unsigned long base_addr = (unsigned long) dev->base_addr;
918 unsigned long events;
920 - // Read and clear the events
921 + /* Read and clear the events */
922 events = FEC_EIR(base_addr) & FEC_EIMR(base_addr);
924 - if (events & FEC_EIR_HBERR)
926 + if (events & FEC_EIR_HBERR) {
927 fp->fecpriv_stat.tx_heartbeat_errors++;
928 - FEC_EIR(base_addr) = FEC_EIR_HBERR;
929 + FEC_EIR(base_addr) = FEC_EIR_HBERR;
932 - // receive/transmit FIFO error
933 - if (((events & FEC_EIR_RFERR) != 0) || ((events & FEC_EIR_XFERR) != 0))
935 - // kill DMA receive channel
936 - MCD_killDma (fp->fecpriv_fec_rx_channel);
937 - // kill running transmission by DMA
938 - MCD_killDma (fp->fecpriv_fec_tx_channel);
941 - FEC_FECFRST(base_addr) |= FEC_SW_RST;
942 - FEC_FECFRST(base_addr) &= ~FEC_SW_RST;
944 - // reset receive FIFO status register
945 - FEC_FECRFSR(base_addr) = FEC_FECRFSR_FAE
949 - // reset transmit FIFO status register
950 - FEC_FECTFSR(base_addr) = FEC_FECTFSR_FAE
954 + /* receive/transmit FIFO error */
955 + if (((events & FEC_EIR_RFERR) != 0) || ((events & FEC_EIR_XFERR) != 0)) {
956 + /* kill DMA receive channel */
957 + MCD_killDma (fp->fecpriv_fec_rx_channel);
959 - // reset RFERR and XFERR event
960 - FEC_EIR(base_addr) = FEC_EIR_RFERR | FEC_EIR_XFERR;
961 + /* kill running transmission by DMA */
962 + MCD_killDma (fp->fecpriv_fec_tx_channel);
965 - netif_stop_queue(dev);
967 - // execute reinitialization as tasklet
968 - tasklet_schedule(&fp->fecpriv_tasklet_reinit);
970 + FEC_FECFRST(base_addr) |= FEC_SW_RST;
971 + FEC_FECFRST(base_addr) &= ~FEC_SW_RST;
973 - fp->fecpriv_stat.rx_dropped++;
974 + /* reset receive FIFO status register */
975 + FEC_FECRFSR(base_addr) = FEC_FECRFSR_FAE |
980 + /* reset transmit FIFO status register */
981 + FEC_FECTFSR(base_addr) = FEC_FECTFSR_FAE |
986 - // transmit FIFO underrun
987 - if ((events & FEC_EIR_XFUN) != 0)
989 - // reset XFUN event
990 - FEC_EIR(base_addr) = FEC_EIR_XFUN;
991 - fp->fecpriv_stat.tx_aborted_errors++;
993 + /* reset RFERR and XFERR event */
994 + FEC_EIR(base_addr) = FEC_EIR_RFERR | FEC_EIR_XFERR;
997 + netif_stop_queue(dev);
999 + /* execute reinitialization as tasklet */
1000 + tasklet_schedule(&fp->fecpriv_tasklet_reinit);
1002 + fp->fecpriv_stat.rx_dropped++;
1006 - if ((events & FEC_EIR_LC) != 0)
1009 - FEC_EIR(base_addr) = FEC_EIR_LC;
1010 + /* transmit FIFO underrun */
1011 + if ((events & FEC_EIR_XFUN) != 0) {
1012 + /* reset XFUN event */
1013 + FEC_EIR(base_addr) = FEC_EIR_XFUN;
1014 fp->fecpriv_stat.tx_aborted_errors++;
1018 - // collision retry limit
1019 - if ((events & FEC_EIR_RL) != 0)
1022 - FEC_EIR(base_addr) = FEC_EIR_RL;
1023 + /* late collision */
1024 + if ((events & FEC_EIR_LC) != 0) {
1025 + /* reset LC event */
1026 + FEC_EIR(base_addr) = FEC_EIR_LC;
1027 fp->fecpriv_stat.tx_aborted_errors++;
1032 + /* collision retry limit */
1033 + if ((events & FEC_EIR_RL) != 0) {
1034 + /* reset RL event */
1035 + FEC_EIR(base_addr) = FEC_EIR_RL;
1036 + fp->fecpriv_stat.tx_aborted_errors++;
1041 /************************************************************************
1042 @@ -1166,52 +1105,46 @@ void fec_interrupt_fec_reinit(unsigned l
1043 struct fec_priv *fp = netdev_priv(dev);
1044 unsigned long base_addr = (unsigned long) dev->base_addr;
1046 - // Initialize reception descriptors and start DMA for the reception
1047 - for (i = 0; i < FEC_RX_BUF_NUMBER; i++)
1049 - if (!fp->askb_rx[i])
1051 - fp->askb_rx[i] = alloc_skb(FEC_MAXBUF_SIZE + 16, GFP_ATOMIC | GFP_DMA);
1052 - if (!fp->askb_rx[i])
1054 - fp->fecpriv_rxdesc[i].dataPointer = 0;
1055 - fp->fecpriv_rxdesc[i].statCtrl = 0;
1056 - fp->fecpriv_rxdesc[i].length = 0;
1059 + /* Initialize reception descriptors and start DMA for the reception */
1060 + for (i = 0; i < FEC_RX_BUF_NUMBER; i++) {
1061 + if (!fp->askb_rx[i]) {
1062 + fp->askb_rx[i] = alloc_skb(FEC_MAXBUF_SIZE + 16, GFP_ATOMIC | GFP_DMA);
1063 + if (!fp->askb_rx[i]) {
1064 + fp->fecpriv_rxdesc[i].dataPointer = 0;
1065 + fp->fecpriv_rxdesc[i].statCtrl = 0;
1066 + fp->fecpriv_rxdesc[i].length = 0;
1069 fp->askb_rx[i]->dev = dev;
1070 - skb_reserve(fp->askb_rx[i], 16);
1072 - fp->fecpriv_rxdesc[i].dataPointer = (unsigned int) virt_to_phys(fp->askb_rx[i]->tail);
1073 + skb_reserve(fp->askb_rx[i], 16);
1075 + fp->fecpriv_rxdesc[i].dataPointer = (unsigned int) virt_to_phys(fp->askb_rx[i]->tail);
1076 fp->fecpriv_rxdesc[i].statCtrl = MCD_FEC_BUF_READY | MCD_FEC_INTERRUPT;
1077 - fp->fecpriv_rxdesc[i].length = FEC_MAXBUF_SIZE;
1078 + fp->fecpriv_rxdesc[i].length = FEC_MAXBUF_SIZE;
1081 fp->fecpriv_rxdesc[i - 1].statCtrl |= MCD_FEC_WRAP;
1082 fp->fecpriv_current_rx = 0;
1084 - // restart frame transmission
1085 - for (i = 0; i < FEC_TX_BUF_NUMBER; i++)
1087 - if (fp->fecpriv_txbuf[i])
1090 + /* restart frame transmission */
1091 + for (i = 0; i < FEC_TX_BUF_NUMBER; i++) {
1092 + if (fp->fecpriv_txbuf[i]) {
1093 kfree(fp->fecpriv_txbuf[i]);
1094 fp->fecpriv_txbuf[i] = NULL;
1095 - fp->fecpriv_stat.tx_dropped++;
1096 + fp->fecpriv_stat.tx_dropped++;
1098 fp->fecpriv_txdesc[i].statCtrl = MCD_FEC_INTERRUPT;
1100 fp->fecpriv_txdesc[i - 1].statCtrl |= MCD_FEC_WRAP;
1101 fp->fecpriv_current_tx = fp->fecpriv_next_tx = 0;
1103 - // flush entire data cache before restarting the DMA
1104 + /* flush entire data cache before restarting the DMA */
1106 /* JKM -- currently running with cache turned off */
1107 DcacheFlushInvalidate();
1110 - // restart DMA from beginning
1111 + /* restart DMA from beginning */
1112 MCD_startDma(fp->fecpriv_fec_rx_channel,
1113 (char *) fp->fecpriv_rxdesc, 0,
1114 (unsigned char *) &(FEC_FECRFDR(base_addr)), 0,
1115 @@ -1225,11 +1158,10 @@ void fec_interrupt_fec_reinit(unsigned l
1116 FEC_TX_DMA_PRI, MCD_FECTX_DMA | MCD_INTERRUPT,
1117 MCD_NO_CSUM | MCD_NO_BYTE_SWAP);
1120 - FEC_ECR(base_addr) |= FEC_ECR_ETHEREN;
1122 + FEC_ECR(base_addr) |= FEC_ECR_ETHEREN;
1124 netif_wake_queue(dev);
1128 /************************************************************************
1129 @@ -1284,8 +1216,8 @@ void fec_interrupt_fec_rx_handler_fec1(v
1136 /************************************************************************
1137 * NAME: fec_mac_setup0
1139 @@ -1300,7 +1232,6 @@ int __init fec_mac_setup0(char *s)
1140 if(fec_str_to_mac(s, fec_mac_addr_fec0))
1141 printk("The MAC address of FEC0 cannot be set from command line");
1147 @@ -1316,11 +1247,9 @@ int __init fec_mac_setup1(char *s)
1152 if(fec_str_to_mac(s, fec_mac_addr_fec1))
1153 printk("The MAC address of FEC1 cannot be set from command line");
1159 @@ -1332,52 +1261,46 @@ int __init fec_mac_setup1(char *s)
1160 *************************************************************************/
1161 int fec_str_to_mac( char *str_mac, unsigned char* addr)
1163 - unsigned long val;
1164 + unsigned long val;
1166 unsigned long octet[6], *octetptr = octet;
1172 - while ((c = *str_mac) != '\0')
1174 - if ((c>='0')&&(c<='9'))
1176 + while ((c = *str_mac) != '\0') {
1177 + if ((c>='0')&&(c<='9')) {
1178 val = (val * 16) + (c - '0');
1183 - if (((c>='a')&&(c<='f'))||((c>='A')&&(c<='F')))
1185 + else if (((c>='a')&&(c<='f'))||((c>='A')&&(c<='F'))) {
1186 val = (val << 4) + (c + 10 - (((c>='a')&&(c<='f')) ? 'a' : 'A'));
1192 - if (*str_mac == ':')
1194 + if (*str_mac == ':') {
1195 *octetptr++ = val, str_mac++;
1196 if (octetptr >= octet + 6)
1201 - //Check for trailing characters.
1202 + /* Check for trailing characters */
1203 if (*str_mac && !(*str_mac==' '))
1208 - if ((octetptr - octet)==6)
1212 + if ((octetptr - octet)==6) {