]> Pileus Git - ~andy/linux/blobdiff - drivers/staging/et131x/et131x_netdev.c
Staging: et131x: spinlocks
[~andy/linux] / drivers / staging / et131x / et131x_netdev.c
index 59e99cc7786b11daefe0e84c30bac3b09dce6bc3..74ba1774206b2300b259344a6defcf79149ade45 100644 (file)
@@ -2,7 +2,7 @@
  * Agere Systems Inc.
  * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
  *
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright Â© 2005 Agere Systems Inc.
  * All rights reserved.
  *   http://www.agere.com
  *
@@ -19,7 +19,7 @@
  * software indicates your acceptance of these terms and conditions.  If you do
  * not agree with these terms and conditions, do not use the software.
  *
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright Â© 2005 Agere Systems Inc.
  * All rights reserved.
  *
  * Redistribution and use in source or binary forms, with or without
@@ -40,7 +40,7 @@
  *
  * Disclaimer
  *
- * THIS SOFTWARE IS PROVIDED \93AS IS\94 AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  ANY
  * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -73,9 +73,9 @@
 #include <linux/interrupt.h>
 #include <linux/in.h>
 #include <linux/delay.h>
-#include <asm/io.h>
+#include <linux/io.h>
+#include <linux/bitops.h>
 #include <asm/system.h>
-#include <asm/bitops.h>
 
 #include <linux/mii.h>
 #include <linux/netdevice.h>
@@ -153,16 +153,16 @@ struct net_device *et131x_device_alloc(void)
        /* Setup the function registration table (and other data) for a
         * net_device
         */
-       //netdev->init               = &et131x_init;
-       //netdev->set_config = &et131x_config;
+       /* netdev->init               = &et131x_init; */
+       /* netdev->set_config = &et131x_config; */
        netdev->watchdog_timeo = ET131X_TX_TIMEOUT;
        netdev->netdev_ops = &et131x_netdev_ops;
 
-       //netdev->ethtool_ops        = &et131x_ethtool_ops;
+       /* netdev->ethtool_ops        = &et131x_ethtool_ops; */
 
-       // Poll?
-       //netdev->poll               = &et131x_poll;
-       //netdev->poll_controller    = &et131x_poll_controller;
+       /* Poll? */
+       /* netdev->poll               = &et131x_poll; */
+       /* netdev->poll_controller    = &et131x_poll_controller; */
 
        DBG_LEAVE(et131x_dbginfo);
        return netdev;
@@ -194,23 +194,25 @@ struct net_device_stats *et131x_stats(struct net_device *netdev)
        stats->rx_over_errors = devstat->rx_ov_flow;
        stats->rx_crc_errors = devstat->crc_err;
 
-       // NOTE: These stats don't have corresponding values in CE_STATS, so we're
-       //       going to have to update these directly from within the TX/RX code
-       //stats->rx_bytes            = 20; //devstat->;
-       //stats->tx_bytes            = 20; //devstat->;
-       //stats->rx_dropped          = devstat->;
-       //stats->tx_dropped          = devstat->;
-
-       // NOTE: Not used, can't find analogous statistics
-       //stats->rx_frame_errors     = devstat->;
-       //stats->rx_fifo_errors      = devstat->;
-       //stats->rx_missed_errors    = devstat->;
-
-       //stats->tx_aborted_errors   = devstat->;
-       //stats->tx_carrier_errors   = devstat->;
-       //stats->tx_fifo_errors      = devstat->;
-       //stats->tx_heartbeat_errors = devstat->;
-       //stats->tx_window_errors    = devstat->;
+       /* NOTE: These stats don't have corresponding values in CE_STATS,
+        * so we're going to have to update these directly from within the
+        * TX/RX code
+        */
+       /* stats->rx_bytes            = 20; devstat->; */
+       /* stats->tx_bytes            = 20;  devstat->; */
+       /* stats->rx_dropped          = devstat->; */
+       /* stats->tx_dropped          = devstat->; */
+
+       /*  NOTE: Not used, can't find analogous statistics */
+       /* stats->rx_frame_errors     = devstat->; */
+       /* stats->rx_fifo_errors      = devstat->; */
+       /* stats->rx_missed_errors    = devstat->; */
+
+       /* stats->tx_aborted_errors   = devstat->; */
+       /* stats->tx_carrier_errors   = devstat->; */
+       /* stats->tx_fifo_errors      = devstat->; */
+       /* stats->tx_heartbeat_errors = devstat->; */
+       /* stats->tx_window_errors    = devstat->; */
 
        DBG_LEAVE(et131x_dbginfo);
        return stats;
@@ -306,7 +308,7 @@ int et131x_close(struct net_device *netdev)
 int et131x_ioctl_mii(struct net_device *netdev, struct ifreq *reqbuf, int cmd)
 {
        int status = 0;
-       struct et131x_adapter *pAdapter = netdev_priv(netdev);
+       struct et131x_adapter *etdev = netdev_priv(netdev);
        struct mii_ioctl_data *data = if_mii(reqbuf);
 
        DBG_ENTER(et131x_dbginfo);
@@ -314,7 +316,7 @@ int et131x_ioctl_mii(struct net_device *netdev, struct ifreq *reqbuf, int cmd)
        switch (cmd) {
        case SIOCGMIIPHY:
                DBG_VERBOSE(et131x_dbginfo, "SIOCGMIIPHY\n");
-               data->phy_id = pAdapter->Stats.xcvr_addr;
+               data->phy_id = etdev->Stats.xcvr_addr;
                break;
 
        case SIOCGMIIREG:
@@ -322,7 +324,7 @@ int et131x_ioctl_mii(struct net_device *netdev, struct ifreq *reqbuf, int cmd)
                if (!capable(CAP_NET_ADMIN)) {
                        status = -EPERM;
                } else {
-                       status = MiRead(pAdapter,
+                       status = MiRead(etdev,
                                        data->reg_num, &data->val_out);
                }
                break;
@@ -332,7 +334,7 @@ int et131x_ioctl_mii(struct net_device *netdev, struct ifreq *reqbuf, int cmd)
                if (!capable(CAP_NET_ADMIN)) {
                        status = -EPERM;
                } else {
-                       status = MiWrite(pAdapter, data->reg_num,
+                       status = MiWrite(etdev, data->reg_num,
                                         data->val_in);
                }
                break;
@@ -414,10 +416,11 @@ int et131x_set_packet_filter(struct et131x_adapter *adapter)
                 */
                if (filter & ET131X_PACKET_TYPE_ALL_MULTICAST) {
                        DBG_VERBOSE(et131x_dbginfo,
-                                   "Multicast filtering OFF (Rx ALL MULTICAST)\n");
+                             "Multicast filtering OFF (Rx ALL MULTICAST)\n");
                        pf_ctrl.bits.filter_multi_en = 0;
                } else {
-                       DBG_VERBOSE(et131x_dbginfo, "Multicast filtering ON\n");
+                       DBG_VERBOSE(et131x_dbginfo,
+                               "Multicast filtering ON\n");
                        SetupDeviceForMulticast(adapter);
                        pf_ctrl.bits.filter_multi_en = 1;
                        ctrl.bits.pkt_filter_disable = 0;
@@ -464,12 +467,12 @@ void et131x_multicast(struct net_device *netdev)
        struct et131x_adapter *adapter = netdev_priv(netdev);
        uint32_t PacketFilter = 0;
        uint32_t count;
-       unsigned long lockflags;
+       unsigned long flags;
        struct dev_mc_list *mclist = netdev->mc_list;
 
        DBG_ENTER(et131x_dbginfo);
 
-       spin_lock_irqsave(&adapter->Lock, lockflags);
+       spin_lock_irqsave(&adapter->Lock, flags);
 
        /* Before we modify the platform-independent filter flags, store them
         * locally. This allows us to determine if anything's changed and if
@@ -505,9 +508,7 @@ void et131x_multicast(struct net_device *netdev)
 
        if (netdev->mc_count > NIC_MAX_MCAST_LIST) {
                DBG_WARNING(et131x_dbginfo,
-                           "ACCEPT ALL MULTICAST for now, as there's more Multicast "
-                           "addresses than the HW supports\n");
-
+                           "ACCEPT ALL MULTICAST for now, as there's more Multicast addresses than the HW supports\n");
                adapter->PacketFilter |= ET131X_PACKET_TYPE_ALL_MULTICAST;
        }
 
@@ -525,10 +526,10 @@ void et131x_multicast(struct net_device *netdev)
        adapter->MCAddressCount = netdev->mc_count;
 
        if (netdev->mc_count) {
-               if (mclist->dmi_addrlen != ETH_ALEN) {
+               if (mclist->dmi_addrlen != ETH_ALEN)
                        DBG_WARNING(et131x_dbginfo,
-                                   "Multicast addrs are not ETH_ALEN in size\n");
-               else {
+                               "Multicast addrs are not ETH_ALEN in size\n");
+               else {
                        count = netdev->mc_count - 1;
                        memcpy(adapter->MCList[count], mclist->dmi_addr,
                               ETH_ALEN);
@@ -551,7 +552,7 @@ void et131x_multicast(struct net_device *netdev)
                            "NO UPDATE REQUIRED, FLAGS didn't change\n");
        }
 
-       spin_unlock_irqrestore(&adapter->Lock, lockflags);
+       spin_unlock_irqrestore(&adapter->Lock, flags);
 
        DBG_LEAVE(et131x_dbginfo);
 }
@@ -607,14 +608,14 @@ int et131x_tx(struct sk_buff *skb, struct net_device *netdev)
  */
 void et131x_tx_timeout(struct net_device *netdev)
 {
-       struct et131x_adapter *pAdapter = netdev_priv(netdev);
+       struct et131x_adapter *etdev = netdev_priv(netdev);
        PMP_TCB pMpTcb;
-       unsigned long lockflags;
+       unsigned long flags;
 
        DBG_WARNING(et131x_dbginfo, "TX TIMEOUT\n");
 
        /* Just skip this part if the adapter is doing link detection */
-       if (MP_TEST_FLAG(pAdapter, fMP_ADAPTER_LINK_DETECTION)) {
+       if (MP_TEST_FLAG(etdev, fMP_ADAPTER_LINK_DETECTION)) {
                DBG_ERROR(et131x_dbginfo, "Still doing link detection\n");
                return;
        }
@@ -622,21 +623,21 @@ void et131x_tx_timeout(struct net_device *netdev)
        /* Any nonrecoverable hardware error?
         * Checks adapter->flags for any failure in phy reading
         */
-       if (MP_TEST_FLAG(pAdapter, fMP_ADAPTER_NON_RECOVER_ERROR)) {
+       if (MP_TEST_FLAG(etdev, fMP_ADAPTER_NON_RECOVER_ERROR)) {
                DBG_WARNING(et131x_dbginfo, "Non recoverable error - remove\n");
                return;
        }
 
        /* Hardware failure? */
-       if (MP_TEST_FLAG(pAdapter, fMP_ADAPTER_HARDWARE_ERROR)) {
+       if (MP_TEST_FLAG(etdev, fMP_ADAPTER_HARDWARE_ERROR)) {
                DBG_WARNING(et131x_dbginfo, "hardware error - reset\n");
                return;
        }
 
        /* Is send stuck? */
-       spin_lock_irqsave(&pAdapter->TCBSendQLock, lockflags);
+       spin_lock_irqsave(&etdev->TCBSendQLock, flags);
 
-       pMpTcb = pAdapter->TxRing.CurrSendHead;
+       pMpTcb = etdev->TxRing.CurrSendHead;
 
        if (pMpTcb != NULL) {
                pMpTcb->Count++;
@@ -644,42 +645,42 @@ void et131x_tx_timeout(struct net_device *netdev)
                if (pMpTcb->Count > NIC_SEND_HANG_THRESHOLD) {
 #ifdef CONFIG_ET131X_DEBUG
                        TX_STATUS_BLOCK_t txDmaComplete =
-                           *(pAdapter->TxRing.pTxStatusVa);
+                           *(etdev->TxRing.pTxStatusVa);
                        PTX_DESC_ENTRY_t pDesc =
-                           pAdapter->TxRing.pTxDescRingVa +
+                           etdev->TxRing.pTxDescRingVa +
                            pMpTcb->WrIndex.bits.val;
 #endif
                        TX_DESC_ENTRY_t StuckDescriptors[10];
 
                        if (pMpTcb->WrIndex.bits.val > 7) {
                                memcpy(StuckDescriptors,
-                                      pAdapter->TxRing.pTxDescRingVa +
+                                      etdev->TxRing.pTxDescRingVa +
                                       pMpTcb->WrIndex.bits.val - 6,
                                       sizeof(TX_DESC_ENTRY_t) * 10);
                        }
 
-                       spin_unlock_irqrestore(&pAdapter->TCBSendQLock,
-                                              lockflags);
+                       spin_unlock_irqrestore(&etdev->TCBSendQLock,
+                                              flags);
 
                        DBG_WARNING(et131x_dbginfo,
-                                   "Send stuck - reset.  pMpTcb->WrIndex %x, Flags 0x%08x\n",
-                                   pMpTcb->WrIndex.bits.val,
-                                   pMpTcb->Flags);
+                               "Send stuck - reset.  pMpTcb->WrIndex %x, Flags 0x%08x\n",
+                               pMpTcb->WrIndex.bits.val,
+                               pMpTcb->Flags);
 
                        DBG_WARNING(et131x_dbginfo,
-                                   "pDesc 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
-                                   pDesc->DataBufferPtrHigh,
-                                   pDesc->DataBufferPtrLow, pDesc->word2.value,
-                                   pDesc->word3.value);
+                               "pDesc 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
+                               pDesc->DataBufferPtrHigh,
+                               pDesc->DataBufferPtrLow, pDesc->word2.value,
+                               pDesc->word3.value);
 
                        DBG_WARNING(et131x_dbginfo,
                                    "WbStatus 0x%08x\n", txDmaComplete.value);
 
 #ifdef CONFIG_ET131X_DEBUG
-                       DumpDeviceBlock(DBG_WARNING_ON, pAdapter, 0);
-                       DumpDeviceBlock(DBG_WARNING_ON, pAdapter, 1);
-                       DumpDeviceBlock(DBG_WARNING_ON, pAdapter, 3);
-                       DumpDeviceBlock(DBG_WARNING_ON, pAdapter, 5);
+                       DumpDeviceBlock(DBG_WARNING_ON, etdev, 0);
+                       DumpDeviceBlock(DBG_WARNING_ON, etdev, 1);
+                       DumpDeviceBlock(DBG_WARNING_ON, etdev, 3);
+                       DumpDeviceBlock(DBG_WARNING_ON, etdev, 5);
 #endif
                        et131x_close(netdev);
                        et131x_open(netdev);
@@ -688,7 +689,7 @@ void et131x_tx_timeout(struct net_device *netdev)
                }
        }
 
-       spin_unlock_irqrestore(&pAdapter->TCBSendQLock, lockflags);
+       spin_unlock_irqrestore(&etdev->TCBSendQLock, flags);
 }
 
 /**
@@ -737,7 +738,7 @@ int et131x_change_mtu(struct net_device *netdev, int new_mtu)
        result = et131x_adapter_memory_alloc(adapter);
        if (result != 0) {
                DBG_WARNING(et131x_dbginfo,
-                           "Change MTU failed; couldn't re-alloc DMA memory\n");
+                       "Change MTU failed; couldn't re-alloc DMA memory\n");
                return result;
        }
 
@@ -750,9 +751,8 @@ int et131x_change_mtu(struct net_device *netdev, int new_mtu)
        et131x_adapter_setup(adapter);
 
        /* Enable interrupts */
-       if (MP_TEST_FLAG(adapter, fMP_ADAPTER_INTERRUPT_IN_USE)) {
+       if (MP_TEST_FLAG(adapter, fMP_ADAPTER_INTERRUPT_IN_USE))
                et131x_enable_interrupts(adapter);
-       }
 
        /* Restart the Tx and Rx DMA engines */
        et131x_rx_dma_enable(adapter);
@@ -781,8 +781,8 @@ int et131x_set_mac_addr(struct net_device *netdev, void *new_mac)
        struct sockaddr *address = new_mac;
 
        DBG_ENTER(et131x_dbginfo);
-       // begin blux
-       // DBG_VERBOSE( et131x_dbginfo, "Function not implemented!!\n" );
+       /* begin blux */
+       /* DBG_VERBOSE( et131x_dbginfo, "Function not implemented!!\n" ); */
 
        if (adapter == NULL) {
                DBG_LEAVE(et131x_dbginfo);
@@ -808,22 +808,24 @@ int et131x_set_mac_addr(struct net_device *netdev, void *new_mac)
        et131x_handle_recv_interrupt(adapter);
 
        /* Set the new MAC */
-       // netdev->set_mac_address  = &new_mac;
-       // netdev->mtu = new_mtu;
+       /* netdev->set_mac_address  = &new_mac; */
+       /* netdev->mtu = new_mtu; */
 
        memcpy(netdev->dev_addr, address->sa_data, netdev->addr_len);
 
-       printk("%s: Setting MAC address to %02x:%02x:%02x:%02x:%02x:%02x\n",
-              netdev->name, netdev->dev_addr[0], netdev->dev_addr[1],
-              netdev->dev_addr[2], netdev->dev_addr[3], netdev->dev_addr[4],
-              netdev->dev_addr[5]);
+       printk(KERN_INFO
+               "%s: Setting MAC address to %02x:%02x:%02x:%02x:%02x:%02x\n",
+                       netdev->name,
+                       netdev->dev_addr[0], netdev->dev_addr[1],
+                       netdev->dev_addr[2], netdev->dev_addr[3],
+                       netdev->dev_addr[4], netdev->dev_addr[5]);
 
        /* Free Rx DMA memory */
        et131x_adapter_memory_free(adapter);
 
        /* Set the config parameter for Jumbo Packet support */
-       // adapter->RegistryJumboPacket = new_mtu + 14;
-       // blux: not needet here, w'll change the MAC
+       /* adapter->RegistryJumboPacket = new_mtu + 14; */
+       /* blux: not needet here, we'll change the MAC */
 
        et131x_soft_reset(adapter);
 
@@ -831,23 +833,22 @@ int et131x_set_mac_addr(struct net_device *netdev, void *new_mac)
        result = et131x_adapter_memory_alloc(adapter);
        if (result != 0) {
                DBG_WARNING(et131x_dbginfo,
-                           "Change MAC failed; couldn't re-alloc DMA memory\n");
+                       "Change MAC failed; couldn't re-alloc DMA memory\n");
                return result;
        }
 
        et131x_init_send(adapter);
 
        et131x_setup_hardware_properties(adapter);
-       // memcpy( netdev->dev_addr, adapter->CurrentAddress, ETH_ALEN );
-       // blux: no, do not override our nice address
+       /* memcpy( netdev->dev_addr, adapter->CurrentAddress, ETH_ALEN ); */
+       /* blux: no, do not override our nice address */
 
        /* Init the device with the new settings */
        et131x_adapter_setup(adapter);
 
        /* Enable interrupts */
-       if (MP_TEST_FLAG(adapter, fMP_ADAPTER_INTERRUPT_IN_USE)) {
+       if (MP_TEST_FLAG(adapter, fMP_ADAPTER_INTERRUPT_IN_USE))
                et131x_enable_interrupts(adapter);
-       }
 
        /* Restart the Tx and Rx DMA engines */
        et131x_rx_dma_enable(adapter);