]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - drivers/net/au1000_eth.c
update AU1000 get_ethernet_addr()
[linux-2.6.git] / drivers / net / au1000_eth.c
index ac33b1b9cf4a5ed4b189c62a68197a90c030ad44..297e2d08d267130405899ce4ca60871aab85779f 100644 (file)
  *
  *
  */
-
+#include <linux/dma-mapping.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
 #include <linux/string.h>
 #include <linux/timer.h>
 #include <linux/errno.h>
@@ -46,7 +45,6 @@
 #include <linux/bitops.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
-#include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -89,10 +87,9 @@ static int au1000_open(struct net_device *);
 static int au1000_close(struct net_device *);
 static int au1000_tx(struct sk_buff *, struct net_device *);
 static int au1000_rx(struct net_device *);
-static irqreturn_t au1000_interrupt(int, void *, struct pt_regs *);
+static irqreturn_t au1000_interrupt(int, void *);
 static void au1000_tx_timeout(struct net_device *);
 static void set_rx_mode(struct net_device *);
-static struct net_device_stats *au1000_get_stats(struct net_device *);
 static int au1000_ioctl(struct net_device *, struct ifreq *, int);
 static int mdio_read(struct net_device *, int, int);
 static void mdio_write(struct net_device *, int, int, u16);
@@ -100,9 +97,7 @@ static void au1000_adjust_link(struct net_device *);
 static void enable_mac(struct net_device *, int);
 
 // externs
-extern int get_ethernet_addr(char *ethernet_addr);
-extern void str2eaddr(unsigned char *ea, unsigned char *str);
-extern char * __init prom_getcmdline(void);
+extern int prom_get_ethernet_addr(char *ethernet_addr);
 
 /*
  * Theory of operation
@@ -360,7 +355,8 @@ static int mii_probe (struct net_device *dev)
        BUG_ON(!phydev);
        BUG_ON(phydev->attached_dev);
 
-       phydev = phy_connect(dev, phydev->dev.bus_id, &au1000_adjust_link, 0);
+       phydev = phy_connect(dev, phydev->dev.bus_id, &au1000_adjust_link, 0,
+                       PHY_INTERFACE_MODE_MII);
 
        if (IS_ERR(phydev)) {
                printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
@@ -621,7 +617,6 @@ static struct net_device * au1000_probe(int port_num)
        struct au1000_private *aup = NULL;
        struct net_device *dev = NULL;
        db_dest_t *pDB, *pDBfree;
-       char *pmac, *argptr;
        char ethaddr[6];
        int irq, i, err;
        u32 base, macen;
@@ -679,21 +674,12 @@ static struct net_device * au1000_probe(int port_num)
        au_macs[port_num] = aup;
 
        if (port_num == 0) {
-               /* Check the environment variables first */
-               if (get_ethernet_addr(ethaddr) == 0)
+               if (prom_get_ethernet_addr(ethaddr) == 0)
                        memcpy(au1000_mac_addr, ethaddr, sizeof(au1000_mac_addr));
                else {
-                       /* Check command line */
-                       argptr = prom_getcmdline();
-                       if ((pmac = strstr(argptr, "ethaddr=")) == NULL)
-                               printk(KERN_INFO "%s: No MAC address found\n",
-                                                dev->name);
+                       printk(KERN_INFO "%s: No MAC address found\n",
+                                        dev->name);
                                /* Use the hard coded MAC addresses */
-                       else {
-                               str2eaddr(ethaddr, pmac + strlen("ethaddr="));
-                               memcpy(au1000_mac_addr, ethaddr,
-                                      sizeof(au1000_mac_addr));
-                       }
                }
 
                setup_hw_rings(aup, MAC0_RX_DMA_ADDR, MAC0_TX_DMA_ADDR);
@@ -773,7 +759,6 @@ static struct net_device * au1000_probe(int port_num)
        dev->open = au1000_open;
        dev->hard_start_xmit = au1000_tx;
        dev->stop = au1000_close;
-       dev->get_stats = au1000_get_stats;
        dev->set_multicast_list = &set_rx_mode;
        dev->do_ioctl = &au1000_ioctl;
        SET_ETHTOOL_OPS(dev, &au1000_ethtool_ops);
@@ -1039,7 +1024,7 @@ static void __exit au1000_cleanup_module(void)
 static void update_tx_stats(struct net_device *dev, u32 status)
 {
        struct au1000_private *aup = (struct au1000_private *) dev->priv;
-       struct net_device_stats *ps = &aup->stats;
+       struct net_device_stats *ps = &dev->stats;
 
        if (status & TX_FRAME_ABORTED) {
                if (!aup->phy_dev || (DUPLEX_FULL == aup->phy_dev->duplex)) {
@@ -1095,7 +1080,7 @@ static void au1000_tx_ack(struct net_device *dev)
 static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
 {
        struct au1000_private *aup = (struct au1000_private *) dev->priv;
-       struct net_device_stats *ps = &aup->stats;
+       struct net_device_stats *ps = &dev->stats;
        volatile tx_dma_t *ptxd;
        u32 buff_stat;
        db_dest_t *pDB;
@@ -1125,7 +1110,7 @@ static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
        }
 
        pDB = aup->tx_db_inuse[aup->tx_head];
-       memcpy((void *)pDB->vaddr, skb->data, skb->len);
+       skb_copy_from_linear_data(skb, pDB->vaddr, skb->len);
        if (skb->len < ETH_ZLEN) {
                for (i=skb->len; i<ETH_ZLEN; i++) {
                        ((char *)pDB->vaddr)[i] = 0;
@@ -1149,7 +1134,7 @@ static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
 static inline void update_rx_stats(struct net_device *dev, u32 status)
 {
        struct au1000_private *aup = (struct au1000_private *) dev->priv;
-       struct net_device_stats *ps = &aup->stats;
+       struct net_device_stats *ps = &dev->stats;
 
        ps->rx_packets++;
        if (status & RX_MCAST_FRAME)
@@ -1202,13 +1187,12 @@ static int au1000_rx(struct net_device *dev)
                                printk(KERN_ERR
                                       "%s: Memory squeeze, dropping packet.\n",
                                       dev->name);
-                               aup->stats.rx_dropped++;
+                               dev->stats.rx_dropped++;
                                continue;
                        }
-                       skb->dev = dev;
                        skb_reserve(skb, 2);    /* 16 byte IP header align */
-                       eth_copy_and_sum(skb,
-                               (unsigned char *)pDB->vaddr, frmlen, 0);
+                       skb_copy_to_linear_data(skb,
+                               (unsigned char *)pDB->vaddr, frmlen);
                        skb_put(skb, frmlen);
                        skb->protocol = eth_type_trans(skb, dev);
                        netif_rx(skb);  /* pass the packet to upper layers */
@@ -1253,7 +1237,7 @@ static int au1000_rx(struct net_device *dev)
 /*
  * Au1000 interrupt service routine.
  */
-static irqreturn_t au1000_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t au1000_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev = (struct net_device *) dev_id;
 
@@ -1326,18 +1310,5 @@ static int au1000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
        return phy_mii_ioctl(aup->phy_dev, if_mii(rq), cmd);
 }
 
-static struct net_device_stats *au1000_get_stats(struct net_device *dev)
-{
-       struct au1000_private *aup = (struct au1000_private *) dev->priv;
-
-       if (au1000_debug > 4)
-               printk("%s: au1000_get_stats: dev=%p\n", dev->name, dev);
-
-       if (netif_device_present(dev)) {
-               return &aup->stats;
-       }
-       return 0;
-}
-
 module_init(au1000_init_module);
 module_exit(au1000_cleanup_module);