]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/8139cp.c
bnx2x: FW Internal Memory structure
[linux-2.6-omap-h63xx.git] / drivers / net / 8139cp.c
index 58fad1b2f72e1e00b61802d53c05a1349ca841b7..6011d6fabef0a125695302b2e1d3ad7d6e9e09f1 100644 (file)
@@ -78,7 +78,7 @@
 #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
 #define CP_VLAN_TAG_USED 1
 #define CP_VLAN_TX_TAG(tx_desc,vlan_tag_value) \
-       do { (tx_desc)->opts2 = (vlan_tag_value); } while (0)
+       do { (tx_desc)->opts2 = cpu_to_le32(vlan_tag_value); } while (0)
 #else
 #define CP_VLAN_TAG_USED 0
 #define CP_VLAN_TX_TAG(tx_desc,vlan_tag_value) \
@@ -303,25 +303,25 @@ static const unsigned int cp_rx_config =
          (RX_DMA_BURST << RxCfgDMAShift);
 
 struct cp_desc {
-       u32             opts1;
-       u32             opts2;
-       u64             addr;
+       __le32          opts1;
+       __le32          opts2;
+       __le64          addr;
 };
 
 struct cp_dma_stats {
-       u64                     tx_ok;
-       u64                     rx_ok;
-       u64                     tx_err;
-       u32                     rx_err;
-       u16                     rx_fifo;
-       u16                     frame_align;
-       u32                     tx_ok_1col;
-       u32                     tx_ok_mcol;
-       u64                     rx_ok_phys;
-       u64                     rx_ok_bcast;
-       u32                     rx_ok_mcast;
-       u16                     tx_abort;
-       u16                     tx_underrun;
+       __le64                  tx_ok;
+       __le64                  rx_ok;
+       __le64                  tx_err;
+       __le32                  rx_err;
+       __le16                  rx_fifo;
+       __le16                  frame_align;
+       __le32                  tx_ok_1col;
+       __le32                  tx_ok_mcol;
+       __le64                  rx_ok_phys;
+       __le64                  rx_ok_bcast;
+       __le32                  rx_ok_mcast;
+       __le16                  tx_abort;
+       __le16                  tx_underrun;
 } __attribute__((packed));
 
 struct cp_extra_stats {
@@ -340,7 +340,6 @@ struct cp_private {
        u32                     rx_config;
        u16                     cpcmd;
 
-       struct net_device_stats net_stats;
        struct cp_extra_stats   cp_stats;
 
        unsigned                rx_head         ____cacheline_aligned;
@@ -457,14 +456,14 @@ static inline void cp_rx_skb (struct cp_private *cp, struct sk_buff *skb,
 {
        skb->protocol = eth_type_trans (skb, cp->dev);
 
-       cp->net_stats.rx_packets++;
-       cp->net_stats.rx_bytes += skb->len;
+       cp->dev->stats.rx_packets++;
+       cp->dev->stats.rx_bytes += skb->len;
        cp->dev->last_rx = jiffies;
 
 #if CP_VLAN_TAG_USED
-       if (cp->vlgrp && (desc->opts2 & RxVlanTagged)) {
+       if (cp->vlgrp && (desc->opts2 & cpu_to_le32(RxVlanTagged))) {
                vlan_hwaccel_receive_skb(skb, cp->vlgrp,
-                                        be16_to_cpu(desc->opts2 & 0xffff));
+                                        swab16(le32_to_cpu(desc->opts2) & 0xffff));
        } else
 #endif
                netif_receive_skb(skb);
@@ -477,17 +476,17 @@ static void cp_rx_err_acct (struct cp_private *cp, unsigned rx_tail,
                printk (KERN_DEBUG
                        "%s: rx err, slot %d status 0x%x len %d\n",
                        cp->dev->name, rx_tail, status, len);
-       cp->net_stats.rx_errors++;
+       cp->dev->stats.rx_errors++;
        if (status & RxErrFrame)
-               cp->net_stats.rx_frame_errors++;
+               cp->dev->stats.rx_frame_errors++;
        if (status & RxErrCRC)
-               cp->net_stats.rx_crc_errors++;
+               cp->dev->stats.rx_crc_errors++;
        if ((status & RxErrRunt) || (status & RxErrLong))
-               cp->net_stats.rx_length_errors++;
+               cp->dev->stats.rx_length_errors++;
        if ((status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag))
-               cp->net_stats.rx_length_errors++;
+               cp->dev->stats.rx_length_errors++;
        if (status & RxErrFIFO)
-               cp->net_stats.rx_fifo_errors++;
+               cp->dev->stats.rx_fifo_errors++;
 }
 
 static inline unsigned int cp_rx_csum_ok (u32 status)
@@ -539,7 +538,7 @@ rx_status_loop:
                         * that RX fragments are never encountered
                         */
                        cp_rx_err_acct(cp, rx_tail, status, len);
-                       cp->net_stats.rx_dropped++;
+                       dev->stats.rx_dropped++;
                        cp->cp_stats.rx_frags++;
                        goto rx_next;
                }
@@ -556,7 +555,7 @@ rx_status_loop:
                buflen = cp->rx_buf_sz + RX_OFFSET;
                new_skb = dev_alloc_skb (buflen);
                if (!new_skb) {
-                       cp->net_stats.rx_dropped++;
+                       dev->stats.rx_dropped++;
                        goto rx_next;
                }
 
@@ -710,20 +709,20 @@ static void cp_tx (struct cp_private *cp)
                                if (netif_msg_tx_err(cp))
                                        printk(KERN_DEBUG "%s: tx err, status 0x%x\n",
                                               cp->dev->name, status);
-                               cp->net_stats.tx_errors++;
+                               cp->dev->stats.tx_errors++;
                                if (status & TxOWC)
-                                       cp->net_stats.tx_window_errors++;
+                                       cp->dev->stats.tx_window_errors++;
                                if (status & TxMaxCol)
-                                       cp->net_stats.tx_aborted_errors++;
+                                       cp->dev->stats.tx_aborted_errors++;
                                if (status & TxLinkFail)
-                                       cp->net_stats.tx_carrier_errors++;
+                                       cp->dev->stats.tx_carrier_errors++;
                                if (status & TxFIFOUnder)
-                                       cp->net_stats.tx_fifo_errors++;
+                                       cp->dev->stats.tx_fifo_errors++;
                        } else {
-                               cp->net_stats.collisions +=
+                               cp->dev->stats.collisions +=
                                        ((status >> TxColCntShift) & TxColCntMask);
-                               cp->net_stats.tx_packets++;
-                               cp->net_stats.tx_bytes += skb->len;
+                               cp->dev->stats.tx_packets++;
+                               cp->dev->stats.tx_bytes += skb->len;
                                if (netif_msg_tx_done(cp))
                                        printk(KERN_DEBUG "%s: tx done, slot %d\n", cp->dev->name, tx_tail);
                        }
@@ -765,7 +764,7 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev)
 
 #if CP_VLAN_TAG_USED
        if (cp->vlgrp && vlan_tx_tag_present(skb))
-               vlan_tag = TxVlanTag | cpu_to_be16(vlan_tx_tag_get(skb));
+               vlan_tag = TxVlanTag | swab16(vlan_tx_tag_get(skb));
 #endif
 
        entry = cp->tx_head;
@@ -956,7 +955,7 @@ static void cp_set_rx_mode (struct net_device *dev)
 static void __cp_get_stats(struct cp_private *cp)
 {
        /* only lower 24 bits valid; write any value to clear */
-       cp->net_stats.rx_missed_errors += (cpr32 (RxMissed) & 0xffffff);
+       cp->dev->stats.rx_missed_errors += (cpr32 (RxMissed) & 0xffffff);
        cpw32 (RxMissed, 0);
 }
 
@@ -971,7 +970,7 @@ static struct net_device_stats *cp_get_stats(struct net_device *dev)
                __cp_get_stats(cp);
        spin_unlock_irqrestore(&cp->lock, flags);
 
-       return &cp->net_stats;
+       return &dev->stats;
 }
 
 static void cp_stop_hw (struct cp_private *cp)
@@ -1018,8 +1017,8 @@ static void cp_init_hw (struct cp_private *cp)
        cpw8_f (Cfg9346, Cfg9346_Unlock);
 
        /* Restore our idea of the MAC address. */
-       cpw32_f (MAC0 + 0, cpu_to_le32 (*(u32 *) (dev->dev_addr + 0)));
-       cpw32_f (MAC0 + 4, cpu_to_le32 (*(u32 *) (dev->dev_addr + 4)));
+       cpw32_f (MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0)));
+       cpw32_f (MAC0 + 4, le32_to_cpu (*(__le32 *) (dev->dev_addr + 4)));
 
        cp_start_hw(cp);
        cpw8(TxThresh, 0x06); /* XXX convert magic num to a constant */
@@ -1142,7 +1141,7 @@ static void cp_clean_rings (struct cp_private *cp)
                                         PCI_DMA_TODEVICE);
                        if (le32_to_cpu(desc->opts1) & LastFrag)
                                dev_kfree_skb(skb);
-                       cp->net_stats.tx_dropped++;
+                       cp->dev->stats.tx_dropped++;
                }
        }
 
@@ -1214,7 +1213,6 @@ static int cp_close (struct net_device *dev)
 
        spin_unlock_irqrestore(&cp->lock, flags);
 
-       synchronize_irq(dev->irq);
        free_irq(dev->irq, dev);
 
        cp_free_rings(cp);
@@ -1383,9 +1381,14 @@ static int cp_get_regs_len(struct net_device *dev)
        return CP_REGS_SIZE;
 }
 
-static int cp_get_stats_count (struct net_device *dev)
+static int cp_get_sset_count (struct net_device *dev, int sset)
 {
-       return CP_NUM_STATS;
+       switch (sset) {
+       case ETH_SS_STATS:
+               return CP_NUM_STATS;
+       default:
+               return -EOPNOTSUPP;
+       }
 }
 
 static int cp_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
@@ -1563,7 +1566,7 @@ static void cp_get_ethtool_stats (struct net_device *dev,
 static const struct ethtool_ops cp_ethtool_ops = {
        .get_drvinfo            = cp_get_drvinfo,
        .get_regs_len           = cp_get_regs_len,
-       .get_stats_count        = cp_get_stats_count,
+       .get_sset_count         = cp_get_sset_count,
        .get_settings           = cp_get_settings,
        .set_settings           = cp_set_settings,
        .nway_reset             = cp_nway_reset,
@@ -1823,6 +1826,7 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        void __iomem *regs;
        resource_size_t pciaddr;
        unsigned int addr_len, i, pci_using_dac;
+       DECLARE_MAC_BUF(mac);
 
 #ifndef MODULE
        static int version_printed;
@@ -1924,8 +1928,8 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        /* read MAC address from EEPROM */
        addr_len = read_eeprom (regs, 0, 8) == 0x8129 ? 8 : 6;
        for (i = 0; i < 3; i++)
-               ((u16 *) (dev->dev_addr))[i] =
-                   le16_to_cpu (read_eeprom (regs, i + 7, addr_len));
+               ((__le16 *) (dev->dev_addr))[i] =
+                   cpu_to_le16(read_eeprom (regs, i + 7, addr_len));
        memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
 
        dev->open = cp_open;
@@ -1964,13 +1968,10 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
                goto err_out_iomap;
 
        printk (KERN_INFO "%s: RTL-8139C+ at 0x%lx, "
-               "%02x:%02x:%02x:%02x:%02x:%02x, "
-               "IRQ %d\n",
+               "%s, IRQ %d\n",
                dev->name,
                dev->base_addr,
-               dev->dev_addr[0], dev->dev_addr[1],
-               dev->dev_addr[2], dev->dev_addr[3],
-               dev->dev_addr[4], dev->dev_addr[5],
+               print_mac(mac, dev->dev_addr),
                dev->irq);
 
        pci_set_drvdata(pdev, dev);