Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[safe/jmp/linux-2.6] / drivers / net / gianfar.h
index bead71c..2cd9433 100644 (file)
@@ -45,8 +45,6 @@
 #include <linux/crc32.h>
 #include <linux/workqueue.h>
 #include <linux/ethtool.h>
-#include <linux/fsl_devices.h>
-#include "gianfar_mii.h"
 
 /* The maximum number of packets to be handled in one call of gfar_poll */
 #define GFAR_DEV_WEIGHT 64
@@ -126,9 +124,12 @@ extern const char gfar_driver_version[];
 #define DEFAULT_RX_COALESCE 0
 #define DEFAULT_RXCOUNT        0
 
-#define MIIMCFG_INIT_VALUE     0x00000007
-#define MIIMCFG_RESET           0x80000000
-#define MIIMIND_BUSY            0x00000001
+#define GFAR_SUPPORTED (SUPPORTED_10baseT_Half \
+               | SUPPORTED_10baseT_Full \
+               | SUPPORTED_100baseT_Half \
+               | SUPPORTED_100baseT_Full \
+               | SUPPORTED_Autoneg \
+               | SUPPORTED_MII)
 
 /* TBI register addresses */
 #define MII_TBICON             0x11
@@ -157,6 +158,7 @@ extern const char gfar_driver_version[];
 #define MACCFG2_GMII            0x00000200
 #define MACCFG2_HUGEFRAME      0x00000020
 #define MACCFG2_LENGTHCHECK    0x00000010
+#define MACCFG2_MPEN           0x00000008
 
 #define ECNTRL_INIT_SETTINGS   0x00001000
 #define ECNTRL_TBI_MODE         0x00000020
@@ -188,6 +190,18 @@ extern const char gfar_driver_version[];
 #define mk_ic_value(count, time) (IC_ICEN | \
                                mk_ic_icft(count) | \
                                mk_ic_ictt(time))
+#define get_icft_value(ic)     (((unsigned long)ic & IC_ICFT_MASK) >> \
+                                IC_ICFT_SHIFT)
+#define get_ictt_value(ic)     ((unsigned long)ic & IC_ICTT_MASK)
+
+#define DEFAULT_TXIC mk_ic_value(DEFAULT_TXCOUNT, DEFAULT_TXTIME)
+#define DEFAULT_RXIC mk_ic_value(DEFAULT_RXCOUNT, DEFAULT_RXTIME)
+
+#define skip_bd(bdp, stride, base, ring_size) ({ \
+       typeof(bdp) new_bd = (bdp) + (stride); \
+       (new_bd >= (base) + (ring_size)) ? (new_bd - (ring_size)) : new_bd; })
+
+#define next_bd(bdp, base, ring_size) skip_bd(bdp, 1, base, ring_size)
 
 #define RCTRL_PAL_MASK         0x001f0000
 #define RCTRL_VLEX             0x00002000
@@ -199,8 +213,10 @@ extern const char gfar_driver_version[];
 #define RCTRL_PRSDEP_INIT      0x000000c0
 #define RCTRL_PROM             0x00000008
 #define RCTRL_EMEN             0x00000002
-#define RCTRL_CHECKSUMMING     (RCTRL_IPCSEN \
-               | RCTRL_TUCSEN | RCTRL_PRSDEP_INIT)
+#define RCTRL_REQ_PARSER       (RCTRL_VLEX | RCTRL_IPCSEN | \
+                                RCTRL_TUCSEN)
+#define RCTRL_CHECKSUMMING     (RCTRL_IPCSEN | RCTRL_TUCSEN | \
+                               RCTRL_PRSDEP_INIT)
 #define RCTRL_EXTHASH          (RCTRL_GHTX)
 #define RCTRL_VLAN             (RCTRL_PRSDEP_INIT)
 #define RCTRL_PADDING(x)       ((x << 16) & RCTRL_PAL_MASK)
@@ -229,19 +245,21 @@ extern const char gfar_driver_version[];
 #define IEVENT_CRL             0x00020000
 #define IEVENT_XFUN            0x00010000
 #define IEVENT_RXB0            0x00008000
+#define IEVENT_MAG             0x00000800
 #define IEVENT_GRSC            0x00000100
 #define IEVENT_RXF0            0x00000080
 #define IEVENT_FIR             0x00000008
 #define IEVENT_FIQ             0x00000004
 #define IEVENT_DPE             0x00000002
 #define IEVENT_PERR            0x00000001
-#define IEVENT_RX_MASK          (IEVENT_RXB0 | IEVENT_RXF0)
+#define IEVENT_RX_MASK          (IEVENT_RXB0 | IEVENT_RXF0 | IEVENT_BSY)
 #define IEVENT_TX_MASK          (IEVENT_TXB | IEVENT_TXF)
 #define IEVENT_RTX_MASK         (IEVENT_RX_MASK | IEVENT_TX_MASK)
 #define IEVENT_ERR_MASK         \
 (IEVENT_RXC | IEVENT_BSY | IEVENT_EBERR | IEVENT_MSRO | \
  IEVENT_BABT | IEVENT_TXC | IEVENT_TXE | IEVENT_LC \
- | IEVENT_CRL | IEVENT_XFUN | IEVENT_DPE | IEVENT_PERR)
+ | IEVENT_CRL | IEVENT_XFUN | IEVENT_DPE | IEVENT_PERR \
+ | IEVENT_MAG | IEVENT_BABR)
 
 #define IMASK_INIT_CLEAR       0x00000000
 #define IMASK_BABR              0x80000000
@@ -259,6 +277,7 @@ extern const char gfar_driver_version[];
 #define IMASK_CRL              0x00020000
 #define IMASK_XFUN             0x00010000
 #define IMASK_RXB0              0x00008000
+#define IMASK_MAG              0x00000800
 #define IMASK_GTSC              0x00000100
 #define IMASK_RXFEN0           0x00000080
 #define IMASK_FIR              0x00000008
@@ -293,6 +312,8 @@ extern const char gfar_driver_version[];
 #define ATTRELI_EI_MASK                0x00003fff
 #define ATTRELI_EI(x) (x)
 
+#define BD_LFLAG(flags) ((flags) << 16)
+#define BD_LENGTH_MASK         0x0000ffff
 
 /* TxBD status field bits */
 #define TXBD_READY             0x8000
@@ -354,10 +375,17 @@ extern const char gfar_driver_version[];
 #define RXFCB_PERR_MASK                0x000c
 #define RXFCB_PERR_BADL3       0x0008
 
+#define GFAR_INT_NAME_MAX      IFNAMSIZ + 4
+
 struct txbd8
 {
-       u16     status; /* Status Fields */
-       u16     length; /* Buffer length */
+       union {
+               struct {
+                       u16     status; /* Status Fields */
+                       u16     length; /* Buffer length */
+               };
+               u32 lstatus;
+       };
        u32     bufPtr; /* Buffer Pointer */
 };
 
@@ -372,8 +400,13 @@ struct txfcb {
 
 struct rxbd8
 {
-       u16     status; /* Status Fields */
-       u16     length; /* Buffer Length */
+       union {
+               struct {
+                       u16     status; /* Status Fields */
+                       u16     length; /* Buffer Length */
+               };
+               u32 lstatus;
+       };
        u32     bufPtr; /* Buffer Pointer */
 };
 
@@ -653,6 +686,19 @@ struct gfar {
 
 };
 
+/* Flags related to gianfar device features */
+#define FSL_GIANFAR_DEV_HAS_GIGABIT            0x00000001
+#define FSL_GIANFAR_DEV_HAS_COALESCE           0x00000002
+#define FSL_GIANFAR_DEV_HAS_RMON               0x00000004
+#define FSL_GIANFAR_DEV_HAS_MULTI_INTR         0x00000008
+#define FSL_GIANFAR_DEV_HAS_CSUM               0x00000010
+#define FSL_GIANFAR_DEV_HAS_VLAN               0x00000020
+#define FSL_GIANFAR_DEV_HAS_EXTENDED_HASH      0x00000040
+#define FSL_GIANFAR_DEV_HAS_PADDING            0x00000080
+#define FSL_GIANFAR_DEV_HAS_MAGIC_PACKET       0x00000100
+#define FSL_GIANFAR_DEV_HAS_BD_STASHING                0x00000200
+#define FSL_GIANFAR_DEV_HAS_BUF_STASHING       0x00000400
+
 /* Struct stolen almost completely (and shamelessly) from the FCC enet source
  * (Ok, that's not so true anymore, but there is a family resemblence)
  * The GFAR buffer descriptors track the ring buffers.  The rx_bd_base
@@ -677,8 +723,7 @@ struct gfar_private {
 
        /* Configuration info for the coalescing features */
        unsigned char txcoalescing;
-       unsigned short txcount;
-       unsigned short txtime;
+       unsigned long txic;
 
        /* Buffer descriptor pointers */
        struct txbd8 *tx_bd_base;       /* First tx buffer descriptor */
@@ -686,11 +731,14 @@ struct gfar_private {
        struct txbd8 *dirty_tx;         /* First buffer in line
                                           to be transmitted */
        unsigned int tx_ring_size;
+       unsigned int num_txbdfree;      /* number of TxBDs free */
 
        /* RX Locked fields */
        spinlock_t rxlock;
 
-       struct net_device *dev;
+       struct device_node *node;
+       struct net_device *ndev;
+       struct of_device *ofdev;
        struct napi_struct napi;
 
        /* skb array and index */
@@ -699,8 +747,7 @@ struct gfar_private {
 
        /* RX Coalescing values */
        unsigned char rxcoalescing;
-       unsigned short rxcount;
-       unsigned short rxtime;
+       unsigned long rxic;
 
        struct rxbd8 *rx_bd_base;       /* First Rx buffers */
        struct rxbd8 *cur_rx;           /* Next free rx ring entry */
@@ -711,6 +758,8 @@ struct gfar_private {
        unsigned int rx_stash_size;
        unsigned int rx_stash_index;
 
+       struct sk_buff_head rx_recycle;
+
        struct vlan_group *vlgrp;
 
        /* Unprotected fields */
@@ -726,19 +775,23 @@ struct gfar_private {
        unsigned int fifo_starve;
        unsigned int fifo_starve_off;
 
-       unsigned char vlan_enable:1,
-               rx_csum_enable:1,
+       /* Bitfield update lock */
+       spinlock_t bflock;
+
+       phy_interface_t interface;
+       struct device_node *phy_node;
+       struct device_node *tbi_node;
+       u32 device_flags;
+       unsigned char rx_csum_enable:1,
                extended_hash:1,
-               bd_stash_en:1;
+               bd_stash_en:1,
+               wol_en:1; /* Wake-on-LAN enabled */
        unsigned short padding;
 
        unsigned int interruptTransmit;
        unsigned int interruptReceive;
        unsigned int interruptError;
 
-       /* info structure initialized by platform code */
-       struct gianfar_platform_data *einfo;
-
        /* PHY stuff */
        struct phy_device *phydev;
        struct mii_bus *mii_bus;
@@ -748,6 +801,12 @@ struct gfar_private {
 
        uint32_t msg_enable;
 
+       struct work_struct reset_task;
+
+       char int_name_tx[GFAR_INT_NAME_MAX];
+       char int_name_rx[GFAR_INT_NAME_MAX];
+       char int_name_er[GFAR_INT_NAME_MAX];
+
        /* Network Statistics */
        struct gfar_extra_stats extra_stats;
 };
@@ -771,8 +830,7 @@ extern void gfar_halt(struct net_device *dev);
 extern void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev,
                int enable, u32 regnum, u32 read);
 void gfar_init_sysfs(struct net_device *dev);
-int gfar_local_mdio_write(struct gfar_mii __iomem *regs, int mii_id,
-                         int regnum, u16 value);
-int gfar_local_mdio_read(struct gfar_mii __iomem *regs, int mii_id, int regnum);
+
+extern const struct ethtool_ops gfar_ethtool_ops;
 
 #endif /* __GIANFAR_H */