aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pcnet32.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/pcnet32.c')
-rw-r--r--drivers/net/pcnet32.c159
1 files changed, 75 insertions, 84 deletions
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index 0791360a6a6..9c171a7390e 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -253,12 +253,12 @@ struct pcnet32_access {
253 * so the structure should be allocated using pci_alloc_consistent(). 253 * so the structure should be allocated using pci_alloc_consistent().
254 */ 254 */
255struct pcnet32_private { 255struct pcnet32_private {
256 struct pcnet32_init_block init_block; 256 struct pcnet32_init_block *init_block;
257 /* The Tx and Rx ring entries must be aligned on 16-byte boundaries in 32bit mode. */ 257 /* The Tx and Rx ring entries must be aligned on 16-byte boundaries in 32bit mode. */
258 struct pcnet32_rx_head *rx_ring; 258 struct pcnet32_rx_head *rx_ring;
259 struct pcnet32_tx_head *tx_ring; 259 struct pcnet32_tx_head *tx_ring;
260 dma_addr_t dma_addr;/* DMA address of beginning of this 260 dma_addr_t init_dma_addr;/* DMA address of beginning of the init block,
261 object, returned by pci_alloc_consistent */ 261 returned by pci_alloc_consistent */
262 struct pci_dev *pci_dev; 262 struct pci_dev *pci_dev;
263 const char *name; 263 const char *name;
264 /* The saved address of a sent-in-place packet/buffer, for skfree(). */ 264 /* The saved address of a sent-in-place packet/buffer, for skfree(). */
@@ -653,7 +653,7 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev,
653 653
654static void pcnet32_purge_rx_ring(struct net_device *dev) 654static void pcnet32_purge_rx_ring(struct net_device *dev)
655{ 655{
656 struct pcnet32_private *lp = dev->priv; 656 struct pcnet32_private *lp = netdev_priv(dev);
657 int i; 657 int i;
658 658
659 /* free all allocated skbuffs */ 659 /* free all allocated skbuffs */
@@ -681,7 +681,7 @@ static void pcnet32_poll_controller(struct net_device *dev)
681 681
682static int pcnet32_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 682static int pcnet32_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
683{ 683{
684 struct pcnet32_private *lp = dev->priv; 684 struct pcnet32_private *lp = netdev_priv(dev);
685 unsigned long flags; 685 unsigned long flags;
686 int r = -EOPNOTSUPP; 686 int r = -EOPNOTSUPP;
687 687
@@ -696,7 +696,7 @@ static int pcnet32_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
696 696
697static int pcnet32_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 697static int pcnet32_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
698{ 698{
699 struct pcnet32_private *lp = dev->priv; 699 struct pcnet32_private *lp = netdev_priv(dev);
700 unsigned long flags; 700 unsigned long flags;
701 int r = -EOPNOTSUPP; 701 int r = -EOPNOTSUPP;
702 702
@@ -711,7 +711,7 @@ static int pcnet32_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
711static void pcnet32_get_drvinfo(struct net_device *dev, 711static void pcnet32_get_drvinfo(struct net_device *dev,
712 struct ethtool_drvinfo *info) 712 struct ethtool_drvinfo *info)
713{ 713{
714 struct pcnet32_private *lp = dev->priv; 714 struct pcnet32_private *lp = netdev_priv(dev);
715 715
716 strcpy(info->driver, DRV_NAME); 716 strcpy(info->driver, DRV_NAME);
717 strcpy(info->version, DRV_VERSION); 717 strcpy(info->version, DRV_VERSION);
@@ -723,7 +723,7 @@ static void pcnet32_get_drvinfo(struct net_device *dev,
723 723
724static u32 pcnet32_get_link(struct net_device *dev) 724static u32 pcnet32_get_link(struct net_device *dev)
725{ 725{
726 struct pcnet32_private *lp = dev->priv; 726 struct pcnet32_private *lp = netdev_priv(dev);
727 unsigned long flags; 727 unsigned long flags;
728 int r; 728 int r;
729 729
@@ -743,19 +743,19 @@ static u32 pcnet32_get_link(struct net_device *dev)
743 743
744static u32 pcnet32_get_msglevel(struct net_device *dev) 744static u32 pcnet32_get_msglevel(struct net_device *dev)
745{ 745{
746 struct pcnet32_private *lp = dev->priv; 746 struct pcnet32_private *lp = netdev_priv(dev);
747 return lp->msg_enable; 747 return lp->msg_enable;
748} 748}
749 749
750static void pcnet32_set_msglevel(struct net_device *dev, u32 value) 750static void pcnet32_set_msglevel(struct net_device *dev, u32 value)
751{ 751{
752 struct pcnet32_private *lp = dev->priv; 752 struct pcnet32_private *lp = netdev_priv(dev);
753 lp->msg_enable = value; 753 lp->msg_enable = value;
754} 754}
755 755
756static int pcnet32_nway_reset(struct net_device *dev) 756static int pcnet32_nway_reset(struct net_device *dev)
757{ 757{
758 struct pcnet32_private *lp = dev->priv; 758 struct pcnet32_private *lp = netdev_priv(dev);
759 unsigned long flags; 759 unsigned long flags;
760 int r = -EOPNOTSUPP; 760 int r = -EOPNOTSUPP;
761 761
@@ -770,7 +770,7 @@ static int pcnet32_nway_reset(struct net_device *dev)
770static void pcnet32_get_ringparam(struct net_device *dev, 770static void pcnet32_get_ringparam(struct net_device *dev,
771 struct ethtool_ringparam *ering) 771 struct ethtool_ringparam *ering)
772{ 772{
773 struct pcnet32_private *lp = dev->priv; 773 struct pcnet32_private *lp = netdev_priv(dev);
774 774
775 ering->tx_max_pending = TX_MAX_RING_SIZE; 775 ering->tx_max_pending = TX_MAX_RING_SIZE;
776 ering->tx_pending = lp->tx_ring_size; 776 ering->tx_pending = lp->tx_ring_size;
@@ -781,7 +781,7 @@ static void pcnet32_get_ringparam(struct net_device *dev,
781static int pcnet32_set_ringparam(struct net_device *dev, 781static int pcnet32_set_ringparam(struct net_device *dev,
782 struct ethtool_ringparam *ering) 782 struct ethtool_ringparam *ering)
783{ 783{
784 struct pcnet32_private *lp = dev->priv; 784 struct pcnet32_private *lp = netdev_priv(dev);
785 unsigned long flags; 785 unsigned long flags;
786 unsigned int size; 786 unsigned int size;
787 ulong ioaddr = dev->base_addr; 787 ulong ioaddr = dev->base_addr;
@@ -847,7 +847,7 @@ static int pcnet32_self_test_count(struct net_device *dev)
847static void pcnet32_ethtool_test(struct net_device *dev, 847static void pcnet32_ethtool_test(struct net_device *dev,
848 struct ethtool_test *test, u64 * data) 848 struct ethtool_test *test, u64 * data)
849{ 849{
850 struct pcnet32_private *lp = dev->priv; 850 struct pcnet32_private *lp = netdev_priv(dev);
851 int rc; 851 int rc;
852 852
853 if (test->flags == ETH_TEST_FL_OFFLINE) { 853 if (test->flags == ETH_TEST_FL_OFFLINE) {
@@ -868,7 +868,7 @@ static void pcnet32_ethtool_test(struct net_device *dev,
868 868
869static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1) 869static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1)
870{ 870{
871 struct pcnet32_private *lp = dev->priv; 871 struct pcnet32_private *lp = netdev_priv(dev);
872 struct pcnet32_access *a = &lp->a; /* access to registers */ 872 struct pcnet32_access *a = &lp->a; /* access to registers */
873 ulong ioaddr = dev->base_addr; /* card base I/O address */ 873 ulong ioaddr = dev->base_addr; /* card base I/O address */
874 struct sk_buff *skb; /* sk buff */ 874 struct sk_buff *skb; /* sk buff */
@@ -1047,7 +1047,7 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1)
1047 1047
1048static void pcnet32_led_blink_callback(struct net_device *dev) 1048static void pcnet32_led_blink_callback(struct net_device *dev)
1049{ 1049{
1050 struct pcnet32_private *lp = dev->priv; 1050 struct pcnet32_private *lp = netdev_priv(dev);
1051 struct pcnet32_access *a = &lp->a; 1051 struct pcnet32_access *a = &lp->a;
1052 ulong ioaddr = dev->base_addr; 1052 ulong ioaddr = dev->base_addr;
1053 unsigned long flags; 1053 unsigned long flags;
@@ -1064,7 +1064,7 @@ static void pcnet32_led_blink_callback(struct net_device *dev)
1064 1064
1065static int pcnet32_phys_id(struct net_device *dev, u32 data) 1065static int pcnet32_phys_id(struct net_device *dev, u32 data)
1066{ 1066{
1067 struct pcnet32_private *lp = dev->priv; 1067 struct pcnet32_private *lp = netdev_priv(dev);
1068 struct pcnet32_access *a = &lp->a; 1068 struct pcnet32_access *a = &lp->a;
1069 ulong ioaddr = dev->base_addr; 1069 ulong ioaddr = dev->base_addr;
1070 unsigned long flags; 1070 unsigned long flags;
@@ -1109,7 +1109,7 @@ static int pcnet32_suspend(struct net_device *dev, unsigned long *flags,
1109 int can_sleep) 1109 int can_sleep)
1110{ 1110{
1111 int csr5; 1111 int csr5;
1112 struct pcnet32_private *lp = dev->priv; 1112 struct pcnet32_private *lp = netdev_priv(dev);
1113 struct pcnet32_access *a = &lp->a; 1113 struct pcnet32_access *a = &lp->a;
1114 ulong ioaddr = dev->base_addr; 1114 ulong ioaddr = dev->base_addr;
1115 int ticks; 1115 int ticks;
@@ -1257,7 +1257,7 @@ static void pcnet32_rx_entry(struct net_device *dev,
1257 1257
1258static int pcnet32_rx(struct net_device *dev, int quota) 1258static int pcnet32_rx(struct net_device *dev, int quota)
1259{ 1259{
1260 struct pcnet32_private *lp = dev->priv; 1260 struct pcnet32_private *lp = netdev_priv(dev);
1261 int entry = lp->cur_rx & lp->rx_mod_mask; 1261 int entry = lp->cur_rx & lp->rx_mod_mask;
1262 struct pcnet32_rx_head *rxp = &lp->rx_ring[entry]; 1262 struct pcnet32_rx_head *rxp = &lp->rx_ring[entry];
1263 int npackets = 0; 1263 int npackets = 0;
@@ -1282,7 +1282,7 @@ static int pcnet32_rx(struct net_device *dev, int quota)
1282 1282
1283static int pcnet32_tx(struct net_device *dev) 1283static int pcnet32_tx(struct net_device *dev)
1284{ 1284{
1285 struct pcnet32_private *lp = dev->priv; 1285 struct pcnet32_private *lp = netdev_priv(dev);
1286 unsigned int dirty_tx = lp->dirty_tx; 1286 unsigned int dirty_tx = lp->dirty_tx;
1287 int delta; 1287 int delta;
1288 int must_restart = 0; 1288 int must_restart = 0;
@@ -1381,7 +1381,7 @@ static int pcnet32_tx(struct net_device *dev)
1381#ifdef CONFIG_PCNET32_NAPI 1381#ifdef CONFIG_PCNET32_NAPI
1382static int pcnet32_poll(struct net_device *dev, int *budget) 1382static int pcnet32_poll(struct net_device *dev, int *budget)
1383{ 1383{
1384 struct pcnet32_private *lp = dev->priv; 1384 struct pcnet32_private *lp = netdev_priv(dev);
1385 int quota = min(dev->quota, *budget); 1385 int quota = min(dev->quota, *budget);
1386 unsigned long ioaddr = dev->base_addr; 1386 unsigned long ioaddr = dev->base_addr;
1387 unsigned long flags; 1387 unsigned long flags;
@@ -1428,7 +1428,7 @@ static int pcnet32_poll(struct net_device *dev, int *budget)
1428#define PCNET32_MAX_PHYS 32 1428#define PCNET32_MAX_PHYS 32
1429static int pcnet32_get_regs_len(struct net_device *dev) 1429static int pcnet32_get_regs_len(struct net_device *dev)
1430{ 1430{
1431 struct pcnet32_private *lp = dev->priv; 1431 struct pcnet32_private *lp = netdev_priv(dev);
1432 int j = lp->phycount * PCNET32_REGS_PER_PHY; 1432 int j = lp->phycount * PCNET32_REGS_PER_PHY;
1433 1433
1434 return ((PCNET32_NUM_REGS + j) * sizeof(u16)); 1434 return ((PCNET32_NUM_REGS + j) * sizeof(u16));
@@ -1439,7 +1439,7 @@ static void pcnet32_get_regs(struct net_device *dev, struct ethtool_regs *regs,
1439{ 1439{
1440 int i, csr0; 1440 int i, csr0;
1441 u16 *buff = ptr; 1441 u16 *buff = ptr;
1442 struct pcnet32_private *lp = dev->priv; 1442 struct pcnet32_private *lp = netdev_priv(dev);
1443 struct pcnet32_access *a = &lp->a; 1443 struct pcnet32_access *a = &lp->a;
1444 ulong ioaddr = dev->base_addr; 1444 ulong ioaddr = dev->base_addr;
1445 unsigned long flags; 1445 unsigned long flags;
@@ -1592,7 +1592,6 @@ static int __devinit
1592pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) 1592pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1593{ 1593{
1594 struct pcnet32_private *lp; 1594 struct pcnet32_private *lp;
1595 dma_addr_t lp_dma_addr;
1596 int i, media; 1595 int i, media;
1597 int fdx, mii, fset, dxsuflo; 1596 int fdx, mii, fset, dxsuflo;
1598 int chip_version; 1597 int chip_version;
@@ -1714,7 +1713,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1714 dxsuflo = 1; 1713 dxsuflo = 1;
1715 } 1714 }
1716 1715
1717 dev = alloc_etherdev(0); 1716 dev = alloc_etherdev(sizeof(*lp));
1718 if (!dev) { 1717 if (!dev) {
1719 if (pcnet32_debug & NETIF_MSG_PROBE) 1718 if (pcnet32_debug & NETIF_MSG_PROBE)
1720 printk(KERN_ERR PFX "Memory allocation failed.\n"); 1719 printk(KERN_ERR PFX "Memory allocation failed.\n");
@@ -1805,25 +1804,22 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1805 } 1804 }
1806 1805
1807 dev->base_addr = ioaddr; 1806 dev->base_addr = ioaddr;
1807 lp = netdev_priv(dev);
1808 /* pci_alloc_consistent returns page-aligned memory, so we do not have to check the alignment */ 1808 /* pci_alloc_consistent returns page-aligned memory, so we do not have to check the alignment */
1809 if ((lp = 1809 if ((lp->init_block =
1810 pci_alloc_consistent(pdev, sizeof(*lp), &lp_dma_addr)) == NULL) { 1810 pci_alloc_consistent(pdev, sizeof(*lp->init_block), &lp->init_dma_addr)) == NULL) {
1811 if (pcnet32_debug & NETIF_MSG_PROBE) 1811 if (pcnet32_debug & NETIF_MSG_PROBE)
1812 printk(KERN_ERR PFX 1812 printk(KERN_ERR PFX
1813 "Consistent memory allocation failed.\n"); 1813 "Consistent memory allocation failed.\n");
1814 ret = -ENOMEM; 1814 ret = -ENOMEM;
1815 goto err_free_netdev; 1815 goto err_free_netdev;
1816 } 1816 }
1817
1818 memset(lp, 0, sizeof(*lp));
1819 lp->dma_addr = lp_dma_addr;
1820 lp->pci_dev = pdev; 1817 lp->pci_dev = pdev;
1821 1818
1822 spin_lock_init(&lp->lock); 1819 spin_lock_init(&lp->lock);
1823 1820
1824 SET_MODULE_OWNER(dev); 1821 SET_MODULE_OWNER(dev);
1825 SET_NETDEV_DEV(dev, &pdev->dev); 1822 SET_NETDEV_DEV(dev, &pdev->dev);
1826 dev->priv = lp;
1827 lp->name = chipname; 1823 lp->name = chipname;
1828 lp->shared_irq = shared; 1824 lp->shared_irq = shared;
1829 lp->tx_ring_size = TX_RING_SIZE; /* default tx ring size */ 1825 lp->tx_ring_size = TX_RING_SIZE; /* default tx ring size */
@@ -1870,23 +1866,21 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1870 && dev->dev_addr[2] == 0x75) 1866 && dev->dev_addr[2] == 0x75)
1871 lp->options = PCNET32_PORT_FD | PCNET32_PORT_GPSI; 1867 lp->options = PCNET32_PORT_FD | PCNET32_PORT_GPSI;
1872 1868
1873 lp->init_block.mode = le16_to_cpu(0x0003); /* Disable Rx and Tx. */ 1869 lp->init_block->mode = le16_to_cpu(0x0003); /* Disable Rx and Tx. */
1874 lp->init_block.tlen_rlen = 1870 lp->init_block->tlen_rlen =
1875 le16_to_cpu(lp->tx_len_bits | lp->rx_len_bits); 1871 le16_to_cpu(lp->tx_len_bits | lp->rx_len_bits);
1876 for (i = 0; i < 6; i++) 1872 for (i = 0; i < 6; i++)
1877 lp->init_block.phys_addr[i] = dev->dev_addr[i]; 1873 lp->init_block->phys_addr[i] = dev->dev_addr[i];
1878 lp->init_block.filter[0] = 0x00000000; 1874 lp->init_block->filter[0] = 0x00000000;
1879 lp->init_block.filter[1] = 0x00000000; 1875 lp->init_block->filter[1] = 0x00000000;
1880 lp->init_block.rx_ring = (u32) le32_to_cpu(lp->rx_ring_dma_addr); 1876 lp->init_block->rx_ring = (u32) le32_to_cpu(lp->rx_ring_dma_addr);
1881 lp->init_block.tx_ring = (u32) le32_to_cpu(lp->tx_ring_dma_addr); 1877 lp->init_block->tx_ring = (u32) le32_to_cpu(lp->tx_ring_dma_addr);
1882 1878
1883 /* switch pcnet32 to 32bit mode */ 1879 /* switch pcnet32 to 32bit mode */
1884 a->write_bcr(ioaddr, 20, 2); 1880 a->write_bcr(ioaddr, 20, 2);
1885 1881
1886 a->write_csr(ioaddr, 1, (lp->dma_addr + offsetof(struct pcnet32_private, 1882 a->write_csr(ioaddr, 1, (lp->init_dma_addr & 0xffff));
1887 init_block)) & 0xffff); 1883 a->write_csr(ioaddr, 2, (lp->init_dma_addr >> 16));
1888 a->write_csr(ioaddr, 2, (lp->dma_addr + offsetof(struct pcnet32_private,
1889 init_block)) >> 16);
1890 1884
1891 if (pdev) { /* use the IRQ provided by PCI */ 1885 if (pdev) { /* use the IRQ provided by PCI */
1892 dev->irq = pdev->irq; 1886 dev->irq = pdev->irq;
@@ -1992,7 +1986,8 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1992 err_free_ring: 1986 err_free_ring:
1993 pcnet32_free_ring(dev); 1987 pcnet32_free_ring(dev);
1994 err_free_consistent: 1988 err_free_consistent:
1995 pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr); 1989 pci_free_consistent(lp->pci_dev, sizeof(*lp->init_block),
1990 lp->init_block, lp->init_dma_addr);
1996 err_free_netdev: 1991 err_free_netdev:
1997 free_netdev(dev); 1992 free_netdev(dev);
1998 err_release_region: 1993 err_release_region:
@@ -2003,7 +1998,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
2003/* if any allocation fails, caller must also call pcnet32_free_ring */ 1998/* if any allocation fails, caller must also call pcnet32_free_ring */
2004static int pcnet32_alloc_ring(struct net_device *dev, char *name) 1999static int pcnet32_alloc_ring(struct net_device *dev, char *name)
2005{ 2000{
2006 struct pcnet32_private *lp = dev->priv; 2001 struct pcnet32_private *lp = netdev_priv(dev);
2007 2002
2008 lp->tx_ring = pci_alloc_consistent(lp->pci_dev, 2003 lp->tx_ring = pci_alloc_consistent(lp->pci_dev,
2009 sizeof(struct pcnet32_tx_head) * 2004 sizeof(struct pcnet32_tx_head) *
@@ -2070,7 +2065,7 @@ static int pcnet32_alloc_ring(struct net_device *dev, char *name)
2070 2065
2071static void pcnet32_free_ring(struct net_device *dev) 2066static void pcnet32_free_ring(struct net_device *dev)
2072{ 2067{
2073 struct pcnet32_private *lp = dev->priv; 2068 struct pcnet32_private *lp = netdev_priv(dev);
2074 2069
2075 kfree(lp->tx_skbuff); 2070 kfree(lp->tx_skbuff);
2076 lp->tx_skbuff = NULL; 2071 lp->tx_skbuff = NULL;
@@ -2103,7 +2098,7 @@ static void pcnet32_free_ring(struct net_device *dev)
2103 2098
2104static int pcnet32_open(struct net_device *dev) 2099static int pcnet32_open(struct net_device *dev)
2105{ 2100{
2106 struct pcnet32_private *lp = dev->priv; 2101 struct pcnet32_private *lp = netdev_priv(dev);
2107 unsigned long ioaddr = dev->base_addr; 2102 unsigned long ioaddr = dev->base_addr;
2108 u16 val; 2103 u16 val;
2109 int i; 2104 int i;
@@ -2134,8 +2129,7 @@ static int pcnet32_open(struct net_device *dev)
2134 "%s: pcnet32_open() irq %d tx/rx rings %#x/%#x init %#x.\n", 2129 "%s: pcnet32_open() irq %d tx/rx rings %#x/%#x init %#x.\n",
2135 dev->name, dev->irq, (u32) (lp->tx_ring_dma_addr), 2130 dev->name, dev->irq, (u32) (lp->tx_ring_dma_addr),
2136 (u32) (lp->rx_ring_dma_addr), 2131 (u32) (lp->rx_ring_dma_addr),
2137 (u32) (lp->dma_addr + 2132 (u32) (lp->init_dma_addr));
2138 offsetof(struct pcnet32_private, init_block)));
2139 2133
2140 /* set/reset autoselect bit */ 2134 /* set/reset autoselect bit */
2141 val = lp->a.read_bcr(ioaddr, 2) & ~2; 2135 val = lp->a.read_bcr(ioaddr, 2) & ~2;
@@ -2274,7 +2268,7 @@ static int pcnet32_open(struct net_device *dev)
2274 } 2268 }
2275#endif 2269#endif
2276 2270
2277 lp->init_block.mode = 2271 lp->init_block->mode =
2278 le16_to_cpu((lp->options & PCNET32_PORT_PORTSEL) << 7); 2272 le16_to_cpu((lp->options & PCNET32_PORT_PORTSEL) << 7);
2279 pcnet32_load_multicast(dev); 2273 pcnet32_load_multicast(dev);
2280 2274
@@ -2284,12 +2278,8 @@ static int pcnet32_open(struct net_device *dev)
2284 } 2278 }
2285 2279
2286 /* Re-initialize the PCNET32, and start it when done. */ 2280 /* Re-initialize the PCNET32, and start it when done. */
2287 lp->a.write_csr(ioaddr, 1, (lp->dma_addr + 2281 lp->a.write_csr(ioaddr, 1, (lp->init_dma_addr & 0xffff));
2288 offsetof(struct pcnet32_private, 2282 lp->a.write_csr(ioaddr, 2, (lp->init_dma_addr >> 16));
2289 init_block)) & 0xffff);
2290 lp->a.write_csr(ioaddr, 2,
2291 (lp->dma_addr +
2292 offsetof(struct pcnet32_private, init_block)) >> 16);
2293 2283
2294 lp->a.write_csr(ioaddr, CSR4, 0x0915); /* auto tx pad */ 2284 lp->a.write_csr(ioaddr, CSR4, 0x0915); /* auto tx pad */
2295 lp->a.write_csr(ioaddr, CSR0, CSR0_INIT); 2285 lp->a.write_csr(ioaddr, CSR0, CSR0_INIT);
@@ -2316,8 +2306,7 @@ static int pcnet32_open(struct net_device *dev)
2316 printk(KERN_DEBUG 2306 printk(KERN_DEBUG
2317 "%s: pcnet32 open after %d ticks, init block %#x csr0 %4.4x.\n", 2307 "%s: pcnet32 open after %d ticks, init block %#x csr0 %4.4x.\n",
2318 dev->name, i, 2308 dev->name, i,
2319 (u32) (lp->dma_addr + 2309 (u32) (lp->init_dma_addr),
2320 offsetof(struct pcnet32_private, init_block)),
2321 lp->a.read_csr(ioaddr, CSR0)); 2310 lp->a.read_csr(ioaddr, CSR0));
2322 2311
2323 spin_unlock_irqrestore(&lp->lock, flags); 2312 spin_unlock_irqrestore(&lp->lock, flags);
@@ -2355,7 +2344,7 @@ static int pcnet32_open(struct net_device *dev)
2355 2344
2356static void pcnet32_purge_tx_ring(struct net_device *dev) 2345static void pcnet32_purge_tx_ring(struct net_device *dev)
2357{ 2346{
2358 struct pcnet32_private *lp = dev->priv; 2347 struct pcnet32_private *lp = netdev_priv(dev);
2359 int i; 2348 int i;
2360 2349
2361 for (i = 0; i < lp->tx_ring_size; i++) { 2350 for (i = 0; i < lp->tx_ring_size; i++) {
@@ -2375,7 +2364,7 @@ static void pcnet32_purge_tx_ring(struct net_device *dev)
2375/* Initialize the PCNET32 Rx and Tx rings. */ 2364/* Initialize the PCNET32 Rx and Tx rings. */
2376static int pcnet32_init_ring(struct net_device *dev) 2365static int pcnet32_init_ring(struct net_device *dev)
2377{ 2366{
2378 struct pcnet32_private *lp = dev->priv; 2367 struct pcnet32_private *lp = netdev_priv(dev);
2379 int i; 2368 int i;
2380 2369
2381 lp->tx_full = 0; 2370 lp->tx_full = 0;
@@ -2417,12 +2406,12 @@ static int pcnet32_init_ring(struct net_device *dev)
2417 lp->tx_dma_addr[i] = 0; 2406 lp->tx_dma_addr[i] = 0;
2418 } 2407 }
2419 2408
2420 lp->init_block.tlen_rlen = 2409 lp->init_block->tlen_rlen =
2421 le16_to_cpu(lp->tx_len_bits | lp->rx_len_bits); 2410 le16_to_cpu(lp->tx_len_bits | lp->rx_len_bits);
2422 for (i = 0; i < 6; i++) 2411 for (i = 0; i < 6; i++)
2423 lp->init_block.phys_addr[i] = dev->dev_addr[i]; 2412 lp->init_block->phys_addr[i] = dev->dev_addr[i];
2424 lp->init_block.rx_ring = (u32) le32_to_cpu(lp->rx_ring_dma_addr); 2413 lp->init_block->rx_ring = (u32) le32_to_cpu(lp->rx_ring_dma_addr);
2425 lp->init_block.tx_ring = (u32) le32_to_cpu(lp->tx_ring_dma_addr); 2414 lp->init_block->tx_ring = (u32) le32_to_cpu(lp->tx_ring_dma_addr);
2426 wmb(); /* Make sure all changes are visible */ 2415 wmb(); /* Make sure all changes are visible */
2427 return 0; 2416 return 0;
2428} 2417}
@@ -2433,7 +2422,7 @@ static int pcnet32_init_ring(struct net_device *dev)
2433 */ 2422 */
2434static void pcnet32_restart(struct net_device *dev, unsigned int csr0_bits) 2423static void pcnet32_restart(struct net_device *dev, unsigned int csr0_bits)
2435{ 2424{
2436 struct pcnet32_private *lp = dev->priv; 2425 struct pcnet32_private *lp = netdev_priv(dev);
2437 unsigned long ioaddr = dev->base_addr; 2426 unsigned long ioaddr = dev->base_addr;
2438 int i; 2427 int i;
2439 2428
@@ -2463,7 +2452,7 @@ static void pcnet32_restart(struct net_device *dev, unsigned int csr0_bits)
2463 2452
2464static void pcnet32_tx_timeout(struct net_device *dev) 2453static void pcnet32_tx_timeout(struct net_device *dev)
2465{ 2454{
2466 struct pcnet32_private *lp = dev->priv; 2455 struct pcnet32_private *lp = netdev_priv(dev);
2467 unsigned long ioaddr = dev->base_addr, flags; 2456 unsigned long ioaddr = dev->base_addr, flags;
2468 2457
2469 spin_lock_irqsave(&lp->lock, flags); 2458 spin_lock_irqsave(&lp->lock, flags);
@@ -2504,7 +2493,7 @@ static void pcnet32_tx_timeout(struct net_device *dev)
2504 2493
2505static int pcnet32_start_xmit(struct sk_buff *skb, struct net_device *dev) 2494static int pcnet32_start_xmit(struct sk_buff *skb, struct net_device *dev)
2506{ 2495{
2507 struct pcnet32_private *lp = dev->priv; 2496 struct pcnet32_private *lp = netdev_priv(dev);
2508 unsigned long ioaddr = dev->base_addr; 2497 unsigned long ioaddr = dev->base_addr;
2509 u16 status; 2498 u16 status;
2510 int entry; 2499 int entry;
@@ -2569,7 +2558,7 @@ pcnet32_interrupt(int irq, void *dev_id)
2569 int boguscnt = max_interrupt_work; 2558 int boguscnt = max_interrupt_work;
2570 2559
2571 ioaddr = dev->base_addr; 2560 ioaddr = dev->base_addr;
2572 lp = dev->priv; 2561 lp = netdev_priv(dev);
2573 2562
2574 spin_lock(&lp->lock); 2563 spin_lock(&lp->lock);
2575 2564
@@ -2651,7 +2640,7 @@ pcnet32_interrupt(int irq, void *dev_id)
2651static int pcnet32_close(struct net_device *dev) 2640static int pcnet32_close(struct net_device *dev)
2652{ 2641{
2653 unsigned long ioaddr = dev->base_addr; 2642 unsigned long ioaddr = dev->base_addr;
2654 struct pcnet32_private *lp = dev->priv; 2643 struct pcnet32_private *lp = netdev_priv(dev);
2655 unsigned long flags; 2644 unsigned long flags;
2656 2645
2657 del_timer_sync(&lp->watchdog_timer); 2646 del_timer_sync(&lp->watchdog_timer);
@@ -2692,7 +2681,7 @@ static int pcnet32_close(struct net_device *dev)
2692 2681
2693static struct net_device_stats *pcnet32_get_stats(struct net_device *dev) 2682static struct net_device_stats *pcnet32_get_stats(struct net_device *dev)
2694{ 2683{
2695 struct pcnet32_private *lp = dev->priv; 2684 struct pcnet32_private *lp = netdev_priv(dev);
2696 unsigned long ioaddr = dev->base_addr; 2685 unsigned long ioaddr = dev->base_addr;
2697 unsigned long flags; 2686 unsigned long flags;
2698 2687
@@ -2706,8 +2695,8 @@ static struct net_device_stats *pcnet32_get_stats(struct net_device *dev)
2706/* taken from the sunlance driver, which it took from the depca driver */ 2695/* taken from the sunlance driver, which it took from the depca driver */
2707static void pcnet32_load_multicast(struct net_device *dev) 2696static void pcnet32_load_multicast(struct net_device *dev)
2708{ 2697{
2709 struct pcnet32_private *lp = dev->priv; 2698 struct pcnet32_private *lp = netdev_priv(dev);
2710 volatile struct pcnet32_init_block *ib = &lp->init_block; 2699 volatile struct pcnet32_init_block *ib = lp->init_block;
2711 volatile u16 *mcast_table = (u16 *) & ib->filter; 2700 volatile u16 *mcast_table = (u16 *) & ib->filter;
2712 struct dev_mc_list *dmi = dev->mc_list; 2701 struct dev_mc_list *dmi = dev->mc_list;
2713 unsigned long ioaddr = dev->base_addr; 2702 unsigned long ioaddr = dev->base_addr;
@@ -2756,7 +2745,7 @@ static void pcnet32_load_multicast(struct net_device *dev)
2756static void pcnet32_set_multicast_list(struct net_device *dev) 2745static void pcnet32_set_multicast_list(struct net_device *dev)
2757{ 2746{
2758 unsigned long ioaddr = dev->base_addr, flags; 2747 unsigned long ioaddr = dev->base_addr, flags;
2759 struct pcnet32_private *lp = dev->priv; 2748 struct pcnet32_private *lp = netdev_priv(dev);
2760 int csr15, suspended; 2749 int csr15, suspended;
2761 2750
2762 spin_lock_irqsave(&lp->lock, flags); 2751 spin_lock_irqsave(&lp->lock, flags);
@@ -2767,12 +2756,12 @@ static void pcnet32_set_multicast_list(struct net_device *dev)
2767 if (netif_msg_hw(lp)) 2756 if (netif_msg_hw(lp))
2768 printk(KERN_INFO "%s: Promiscuous mode enabled.\n", 2757 printk(KERN_INFO "%s: Promiscuous mode enabled.\n",
2769 dev->name); 2758 dev->name);
2770 lp->init_block.mode = 2759 lp->init_block->mode =
2771 le16_to_cpu(0x8000 | (lp->options & PCNET32_PORT_PORTSEL) << 2760 le16_to_cpu(0x8000 | (lp->options & PCNET32_PORT_PORTSEL) <<
2772 7); 2761 7);
2773 lp->a.write_csr(ioaddr, CSR15, csr15 | 0x8000); 2762 lp->a.write_csr(ioaddr, CSR15, csr15 | 0x8000);
2774 } else { 2763 } else {
2775 lp->init_block.mode = 2764 lp->init_block->mode =
2776 le16_to_cpu((lp->options & PCNET32_PORT_PORTSEL) << 7); 2765 le16_to_cpu((lp->options & PCNET32_PORT_PORTSEL) << 7);
2777 lp->a.write_csr(ioaddr, CSR15, csr15 & 0x7fff); 2766 lp->a.write_csr(ioaddr, CSR15, csr15 & 0x7fff);
2778 pcnet32_load_multicast(dev); 2767 pcnet32_load_multicast(dev);
@@ -2795,7 +2784,7 @@ static void pcnet32_set_multicast_list(struct net_device *dev)
2795/* This routine assumes that the lp->lock is held */ 2784/* This routine assumes that the lp->lock is held */
2796static int mdio_read(struct net_device *dev, int phy_id, int reg_num) 2785static int mdio_read(struct net_device *dev, int phy_id, int reg_num)
2797{ 2786{
2798 struct pcnet32_private *lp = dev->priv; 2787 struct pcnet32_private *lp = netdev_priv(dev);
2799 unsigned long ioaddr = dev->base_addr; 2788 unsigned long ioaddr = dev->base_addr;
2800 u16 val_out; 2789 u16 val_out;
2801 2790
@@ -2811,7 +2800,7 @@ static int mdio_read(struct net_device *dev, int phy_id, int reg_num)
2811/* This routine assumes that the lp->lock is held */ 2800/* This routine assumes that the lp->lock is held */
2812static void mdio_write(struct net_device *dev, int phy_id, int reg_num, int val) 2801static void mdio_write(struct net_device *dev, int phy_id, int reg_num, int val)
2813{ 2802{
2814 struct pcnet32_private *lp = dev->priv; 2803 struct pcnet32_private *lp = netdev_priv(dev);
2815 unsigned long ioaddr = dev->base_addr; 2804 unsigned long ioaddr = dev->base_addr;
2816 2805
2817 if (!lp->mii) 2806 if (!lp->mii)
@@ -2823,7 +2812,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int reg_num, int val)
2823 2812
2824static int pcnet32_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 2813static int pcnet32_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2825{ 2814{
2826 struct pcnet32_private *lp = dev->priv; 2815 struct pcnet32_private *lp = netdev_priv(dev);
2827 int rc; 2816 int rc;
2828 unsigned long flags; 2817 unsigned long flags;
2829 2818
@@ -2841,7 +2830,7 @@ static int pcnet32_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2841 2830
2842static int pcnet32_check_otherphy(struct net_device *dev) 2831static int pcnet32_check_otherphy(struct net_device *dev)
2843{ 2832{
2844 struct pcnet32_private *lp = dev->priv; 2833 struct pcnet32_private *lp = netdev_priv(dev);
2845 struct mii_if_info mii = lp->mii_if; 2834 struct mii_if_info mii = lp->mii_if;
2846 u16 bmcr; 2835 u16 bmcr;
2847 int i; 2836 int i;
@@ -2888,7 +2877,7 @@ static int pcnet32_check_otherphy(struct net_device *dev)
2888 2877
2889static void pcnet32_check_media(struct net_device *dev, int verbose) 2878static void pcnet32_check_media(struct net_device *dev, int verbose)
2890{ 2879{
2891 struct pcnet32_private *lp = dev->priv; 2880 struct pcnet32_private *lp = netdev_priv(dev);
2892 int curr_link; 2881 int curr_link;
2893 int prev_link = netif_carrier_ok(dev) ? 1 : 0; 2882 int prev_link = netif_carrier_ok(dev) ? 1 : 0;
2894 u32 bcr9; 2883 u32 bcr9;
@@ -2944,7 +2933,7 @@ static void pcnet32_check_media(struct net_device *dev, int verbose)
2944 2933
2945static void pcnet32_watchdog(struct net_device *dev) 2934static void pcnet32_watchdog(struct net_device *dev)
2946{ 2935{
2947 struct pcnet32_private *lp = dev->priv; 2936 struct pcnet32_private *lp = netdev_priv(dev);
2948 unsigned long flags; 2937 unsigned long flags;
2949 2938
2950 /* Print the link status if it has changed */ 2939 /* Print the link status if it has changed */
@@ -2960,12 +2949,13 @@ static void __devexit pcnet32_remove_one(struct pci_dev *pdev)
2960 struct net_device *dev = pci_get_drvdata(pdev); 2949 struct net_device *dev = pci_get_drvdata(pdev);
2961 2950
2962 if (dev) { 2951 if (dev) {
2963 struct pcnet32_private *lp = dev->priv; 2952 struct pcnet32_private *lp = netdev_priv(dev);
2964 2953
2965 unregister_netdev(dev); 2954 unregister_netdev(dev);
2966 pcnet32_free_ring(dev); 2955 pcnet32_free_ring(dev);
2967 release_region(dev->base_addr, PCNET32_TOTAL_SIZE); 2956 release_region(dev->base_addr, PCNET32_TOTAL_SIZE);
2968 pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr); 2957 pci_free_consistent(lp->pci_dev, sizeof(*lp->init_block),
2958 lp->init_block, lp->init_dma_addr);
2969 free_netdev(dev); 2959 free_netdev(dev);
2970 pci_disable_device(pdev); 2960 pci_disable_device(pdev);
2971 pci_set_drvdata(pdev, NULL); 2961 pci_set_drvdata(pdev, NULL);
@@ -3040,12 +3030,13 @@ static void __exit pcnet32_cleanup_module(void)
3040 struct net_device *next_dev; 3030 struct net_device *next_dev;
3041 3031
3042 while (pcnet32_dev) { 3032 while (pcnet32_dev) {
3043 struct pcnet32_private *lp = pcnet32_dev->priv; 3033 struct pcnet32_private *lp = netdev_priv(pcnet32_dev);
3044 next_dev = lp->next; 3034 next_dev = lp->next;
3045 unregister_netdev(pcnet32_dev); 3035 unregister_netdev(pcnet32_dev);
3046 pcnet32_free_ring(pcnet32_dev); 3036 pcnet32_free_ring(pcnet32_dev);
3047 release_region(pcnet32_dev->base_addr, PCNET32_TOTAL_SIZE); 3037 release_region(pcnet32_dev->base_addr, PCNET32_TOTAL_SIZE);
3048 pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr); 3038 pci_free_consistent(lp->pci_dev, sizeof(*lp->init_block),
3039 lp->init_block, lp->init_dma_addr);
3049 free_netdev(pcnet32_dev); 3040 free_netdev(pcnet32_dev);
3050 pcnet32_dev = next_dev; 3041 pcnet32_dev = next_dev;
3051 } 3042 }