Merge branch 'linus' into cont_syslog
[safe/jmp/linux-2.6] / drivers / net / spider_net.h
index 5922b52..05f74cb 100644 (file)
@@ -1,7 +1,8 @@
 /*
- * Network device driver for Cell Processor-Based Blade
+ * Network device driver for Cell Processor-Based Blade and Celleb platform
  *
  * (C) Copyright IBM Corp. 2005
+ * (C) Copyright 2006 TOSHIBA CORPORATION
  *
  * Authors : Utz Bacher <utz.bacher@de.ibm.com>
  *           Jens Osterkamp <Jens.Osterkamp@de.ibm.com>
 #ifndef _SPIDER_NET_H
 #define _SPIDER_NET_H
 
+#define VERSION "2.0 B"
+
 #include "sungem_phy.h"
 
 extern int spider_net_stop(struct net_device *netdev);
 extern int spider_net_open(struct net_device *netdev);
 
-extern struct ethtool_ops spider_net_ethtool_ops;
+extern const struct ethtool_ops spider_net_ethtool_ops;
 
 extern char spider_net_driver_name[];
 
@@ -47,7 +50,9 @@ extern char spider_net_driver_name[];
 #define SPIDER_NET_TX_DESCRIPTORS_MIN          16
 #define SPIDER_NET_TX_DESCRIPTORS_MAX          512
 
-#define SPIDER_NET_TX_TIMER                    20
+#define SPIDER_NET_TX_TIMER                    (HZ/5)
+#define SPIDER_NET_ANEG_TIMER                  (HZ)
+#define SPIDER_NET_ANEG_TIMEOUT                        5
 
 #define SPIDER_NET_RX_CSUM_DEFAULT             1
 
@@ -102,6 +107,7 @@ extern char spider_net_driver_name[];
 
 #define SPIDER_NET_GMACOPEMD           0x00000100
 #define SPIDER_NET_GMACLENLMT          0x00000108
+#define SPIDER_NET_GMACST              0x00000110
 #define SPIDER_NET_GMACINTEN           0x00000118
 #define SPIDER_NET_GMACPHYCTRL         0x00000120
 
@@ -120,6 +126,8 @@ extern char spider_net_driver_name[];
 #define SPIDER_NET_GMRUAFILnR          0x00000500
 #define SPIDER_NET_GMRUA0FIL15R                0x00000578
 
+#define SPIDER_NET_GTTQMSK             0x00000934
+
 /* RX DMA controller registers, all 0x00000a.. are for DMA controller A,
  * 0x00000b.. for DMA controller B, etc. */
 #define SPIDER_NET_GDADCHA             0x00000a00
@@ -151,9 +159,8 @@ extern char spider_net_driver_name[];
 
 /** interrupt mask registers */
 #define SPIDER_NET_INT0_MASK_VALUE     0x3f7fe2c7
-#define SPIDER_NET_INT1_MASK_VALUE     0xffff7ff7
-/* no MAC aborts -> auto retransmission */
-#define SPIDER_NET_INT2_MASK_VALUE     0xffef7ff1
+#define SPIDER_NET_INT1_MASK_VALUE     0x0000fff2
+#define SPIDER_NET_INT2_MASK_VALUE     0x000003f1
 
 /* we rely on flagged descriptor interrupts */
 #define SPIDER_NET_FRAMENUM_VALUE      0x00000000
@@ -177,7 +184,8 @@ extern char spider_net_driver_name[];
 
 /* pause frames: automatic, no upper retransmission count */
 /* outside loopback mode: ETOMOD signal dont matter, not connected */
-#define SPIDER_NET_OPMODE_VALUE                0x00000063
+/* ETOMOD signal is brought to PHY reset. bit 2 must be 1 in Celleb */
+#define SPIDER_NET_OPMODE_VALUE                0x00000067
 /*#define SPIDER_NET_OPMODE_VALUE              0x001b0062*/
 #define SPIDER_NET_LENLMT_VALUE                0x00000908
 
@@ -187,7 +195,9 @@ extern char spider_net_driver_name[];
 #define SPIDER_NET_MACMODE_VALUE       0x00000001
 #define SPIDER_NET_BURSTLMT_VALUE      0x00000200 /* about 16 us */
 
-/* 1(0)                                        enable r/tx dma
+/* DMAC control register GDMACCNTR
+ *
+ * 1(0)                                enable r/tx dma
  *  0000000                            fixed to 0
  *
  *         000000                      fixed to 0
@@ -196,6 +206,7 @@ extern char spider_net_driver_name[];
  *
  *                 000000              fixed to 0
  *                       00            burst alignment: 128 bytes
+ *                       11            burst alignment: 1024 bytes
  *
  *                         00000       fixed to 0
  *                              0      descr writeback size 32 bytes
@@ -206,7 +217,13 @@ extern char spider_net_driver_name[];
 #define SPIDER_NET_DMA_RX_VALUE                0x80000000
 #define SPIDER_NET_DMA_RX_FEND_VALUE   0x00030003
 /* to set TX_DMA_EN */
-#define SPIDER_NET_DMA_TX_VALUE                0x80000000
+#define SPIDER_NET_TX_DMA_EN           0x80000000
+#define SPIDER_NET_GDTBSTA             0x00000300
+#define SPIDER_NET_GDTDCEIDIS          0x00000002
+#define SPIDER_NET_DMA_TX_VALUE        SPIDER_NET_TX_DMA_EN | \
+                                       SPIDER_NET_GDTDCEIDIS | \
+                                       SPIDER_NET_GDTBSTA
+
 #define SPIDER_NET_DMA_TX_FEND_VALUE   0x00030003
 
 /* SPIDER_NET_UA_DESCR_VALUE is OR'ed with the unicast address */
@@ -315,70 +332,58 @@ enum spider_net_int2_status {
        SPIDER_NET_GRISPDNGINT
 };
 
-#define SPIDER_NET_TXINT       ( (1 << SPIDER_NET_GTTEDINT) | \
-                                 (1 << SPIDER_NET_GDTDCEINT) | \
-                                 (1 << SPIDER_NET_GDTFDCINT) )
+#define SPIDER_NET_TXINT       (1 << SPIDER_NET_GDTFDCINT)
 
-/* we rely on flagged descriptor interrupts*/
-#define SPIDER_NET_RXINT       ( (1 << SPIDER_NET_GDAFDCINT) | \
-                                 (1 << SPIDER_NET_GRMFLLINT) )
+/* We rely on flagged descriptor interrupts */
+#define SPIDER_NET_RXINT       ( (1 << SPIDER_NET_GDAFDCINT) )
+
+#define SPIDER_NET_LINKINT     ( 1 << SPIDER_NET_GMAC2INT )
 
 #define SPIDER_NET_ERRINT      ( 0xffffffff & \
                                  (~SPIDER_NET_TXINT) & \
-                                 (~SPIDER_NET_RXINT) )
-
-#define SPIDER_NET_GPREXEC             0x80000000
-#define SPIDER_NET_GPRDAT_MASK         0x0000ffff
-
-/* descriptor bits
- *
- * 1010                                        descriptor ready
- *     0                               descr in middle of chain
- *      000                            fixed to 0
- *
- *         0                           no interrupt on completion
- *          000                                fixed to 0
- *             1                       no ipsec processing
- *              1                      last descriptor for this frame
- *               00                    no checksum
- *               10                    tcp checksum
- *               11                    udp checksum
- *
- *                 00                  fixed to 0
- *                   0                 fixed to 0
- *                    0                        no interrupt on response errors
- *                     0               no interrupt on invalid descr
- *                      0              no interrupt on dma process termination
- *                       0             no interrupt on descr chain end
- *                        0            no interrupt on descr complete
- *
- *                         000         fixed to 0
- *                            0                response error interrupt status
- *                             0       invalid descr status
- *                              0      dma termination status
- *                               0     descr chain end status
- *                                0    descr complete status */
-#define SPIDER_NET_DMAC_CMDSTAT_NOCS   0xa00c0000
-#define SPIDER_NET_DMAC_CMDSTAT_TCPCS  0xa00e0000
-#define SPIDER_NET_DMAC_CMDSTAT_UDPCS  0xa00f0000
-#define SPIDER_NET_DESCR_IND_PROC_SHIFT        28
-#define SPIDER_NET_DESCR_IND_PROC_MASKO        0x0fffffff
-
-/* descr ready, descr is in middle of chain, get interrupt on completion */
-#define SPIDER_NET_DMAC_RX_CARDOWNED   0xa0800000
-
-enum spider_net_descr_status {
-       SPIDER_NET_DESCR_COMPLETE               = 0x00, /* used in rx and tx */
-       SPIDER_NET_DESCR_RESPONSE_ERROR         = 0x01, /* used in rx and tx */
-       SPIDER_NET_DESCR_PROTECTION_ERROR       = 0x02, /* used in rx and tx */
-       SPIDER_NET_DESCR_FRAME_END              = 0x04, /* used in rx */
-       SPIDER_NET_DESCR_FORCE_END              = 0x05, /* used in rx and tx */
-       SPIDER_NET_DESCR_CARDOWNED              = 0x0a, /* used in rx and tx */
-       SPIDER_NET_DESCR_NOT_IN_USE /* any other value */
-};
-
-struct spider_net_descr {
-       /* as defined by the hardware */
+                                 (~SPIDER_NET_RXINT) & \
+                                 (~SPIDER_NET_LINKINT) )
+
+#define SPIDER_NET_GPREXEC                     0x80000000
+#define SPIDER_NET_GPRDAT_MASK                 0x0000ffff
+
+#define SPIDER_NET_DMAC_NOINTR_COMPLETE                0x00800000
+#define SPIDER_NET_DMAC_TXFRMTL                0x00040000
+#define SPIDER_NET_DMAC_TCP                    0x00020000
+#define SPIDER_NET_DMAC_UDP                    0x00030000
+#define SPIDER_NET_TXDCEST                     0x08000000
+
+#define SPIDER_NET_DESCR_RXFDIS        0x00000001
+#define SPIDER_NET_DESCR_RXDCEIS       0x00000002
+#define SPIDER_NET_DESCR_RXDEN0IS      0x00000004
+#define SPIDER_NET_DESCR_RXINVDIS      0x00000008
+#define SPIDER_NET_DESCR_RXRERRIS      0x00000010
+#define SPIDER_NET_DESCR_RXFDCIMS      0x00000100
+#define SPIDER_NET_DESCR_RXDCEIMS      0x00000200
+#define SPIDER_NET_DESCR_RXDEN0IMS     0x00000400
+#define SPIDER_NET_DESCR_RXINVDIMS     0x00000800
+#define SPIDER_NET_DESCR_RXRERRMIS     0x00001000
+#define SPIDER_NET_DESCR_UNUSED        0x077fe0e0
+
+#define SPIDER_NET_DESCR_IND_PROC_MASK         0xF0000000
+#define SPIDER_NET_DESCR_COMPLETE              0x00000000 /* used in rx and tx */
+#define SPIDER_NET_DESCR_RESPONSE_ERROR                0x10000000 /* used in rx and tx */
+#define SPIDER_NET_DESCR_PROTECTION_ERROR      0x20000000 /* used in rx and tx */
+#define SPIDER_NET_DESCR_FRAME_END             0x40000000 /* used in rx */
+#define SPIDER_NET_DESCR_FORCE_END             0x50000000 /* used in rx and tx */
+#define SPIDER_NET_DESCR_CARDOWNED             0xA0000000 /* used in rx and tx */
+#define SPIDER_NET_DESCR_NOT_IN_USE            0xF0000000
+#define SPIDER_NET_DESCR_TXDESFLG              0x00800000
+
+#define SPIDER_NET_DESCR_BAD_STATUS   (SPIDER_NET_DESCR_RXDEN0IS | \
+                                       SPIDER_NET_DESCR_RXRERRIS | \
+                                       SPIDER_NET_DESCR_RXDEN0IMS | \
+                                       SPIDER_NET_DESCR_RXINVDIMS | \
+                                       SPIDER_NET_DESCR_RXRERRMIS | \
+                                       SPIDER_NET_DESCR_UNUSED)
+
+/* Descriptor, as defined by the hardware */
+struct spider_net_hw_descr {
        u32 buf_addr;
        u32 buf_size;
        u32 next_descr_addr;
@@ -387,18 +392,24 @@ struct spider_net_descr {
        u32 valid_size; /* all zeroes for tx */
        u32 data_status;
        u32 data_error; /* all zeroes for tx */
+} __attribute__((aligned(32)));
 
-       /* used in the driver */
+struct spider_net_descr {
+       struct spider_net_hw_descr *hwdescr;
        struct sk_buff *skb;
        u32 bus_addr;
        struct spider_net_descr *next;
        struct spider_net_descr *prev;
-} __attribute__((aligned(32)));
+};
 
 struct spider_net_descr_chain {
-       /* we walk from tail to head */
+       spinlock_t lock;
        struct spider_net_descr *head;
        struct spider_net_descr *tail;
+       struct spider_net_descr *ring;
+       int num_desc;
+       struct spider_net_hw_descr *hwring;
+       dma_addr_t dma_addr;
 };
 
 /* descriptor data_status bits */
@@ -418,8 +429,6 @@ struct spider_net_descr_chain {
  * 701b8000 would be correct, but every packets gets that flag */
 #define SPIDER_NET_DESTROY_RX_FLAGS    0x700b8000
 
-#define SPIDER_NET_DESCR_SIZE          32
-
 /* this will be bigger some time */
 struct spider_net_options {
        int rx_csum; /* for rx: if 0 ip_summed=NONE,
@@ -442,37 +451,46 @@ struct spider_net_options {
                                          NETIF_MSG_HW | \
                                          NETIF_MSG_WOL )
 
+struct spider_net_extra_stats {
+       unsigned long rx_desc_error;
+       unsigned long tx_timeouts;
+       unsigned long alloc_rx_skb_error;
+       unsigned long rx_iommu_map_error;
+       unsigned long tx_iommu_map_error;
+       unsigned long rx_desc_unk_state;
+};
+
 struct spider_net_card {
        struct net_device *netdev;
        struct pci_dev *pdev;
        struct mii_phy phy;
 
+       struct napi_struct napi;
+
+       int medium;
+
        void __iomem *regs;
 
        struct spider_net_descr_chain tx_chain;
        struct spider_net_descr_chain rx_chain;
-       atomic_t rx_chain_refill;
-       atomic_t tx_chain_release;
-
-       struct net_device_stats netdev_stats;
-
-       struct spider_net_options options;
+       struct spider_net_descr *low_watermark;
 
-       spinlock_t intmask_lock;
-       struct tasklet_struct rxram_full_tl;
+       int aneg_count;
+       struct timer_list aneg_timer;
        struct timer_list tx_timer;
-
        struct work_struct tx_timeout_task;
        atomic_t tx_timeout_task_counter;
        wait_queue_head_t waitq;
+       int num_rx_ints;
+       int ignore_rx_ramfull;
 
        /* for ethtool */
        int msg_enable;
+       struct spider_net_extra_stats spider_stats;
+       struct spider_net_options options;
 
-       struct spider_net_descr descr[0];
+       /* Must be last item in struct */
+       struct spider_net_descr darray[0];
 };
 
-#define pr_err(fmt,arg...) \
-       printk(KERN_ERR fmt ,##arg)
-
 #endif