Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[pandora-kernel.git] / drivers / net / netxen / netxen_nic.h
index 9362190..8e73661 100644 (file)
@@ -54,6 +54,7 @@
 
 #include <linux/mm.h>
 #include <linux/mman.h>
+#include <linux/vmalloc.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
 
 #include "netxen_nic_hw.h"
 
-#define _NETXEN_NIC_LINUX_MAJOR 3
-#define _NETXEN_NIC_LINUX_MINOR 4
-#define _NETXEN_NIC_LINUX_SUBVERSION 18
-#define NETXEN_NIC_LINUX_VERSIONID  "3.4.18"
+#define _NETXEN_NIC_LINUX_MAJOR 4
+#define _NETXEN_NIC_LINUX_MINOR 0
+#define _NETXEN_NIC_LINUX_SUBVERSION 0
+#define NETXEN_NIC_LINUX_VERSIONID  "4.0.0"
+
+#define NETXEN_VERSION_CODE(a, b, c)   (((a) << 16) + ((b) << 8) + (c))
 
 #define NETXEN_NUM_FLASH_SECTORS (64)
 #define NETXEN_FLASH_SECTOR_SIZE (64 * 1024)
 #define NX_RX_NORMAL_BUF_MAX_LEN       (NX_MAX_ETHERHDR + NX_ETHERMTU)
 #define NX_P2_RX_JUMBO_BUF_MAX_LEN     (NX_MAX_ETHERHDR + P2_MAX_MTU)
 #define NX_P3_RX_JUMBO_BUF_MAX_LEN     (NX_MAX_ETHERHDR + P3_MAX_MTU)
+#define NX_CT_DEFAULT_RX_BUF_LEN       2048
 
 #define MAX_RX_BUFFER_LENGTH           1760
 #define MAX_RX_JUMBO_BUFFER_LENGTH     8062
@@ -391,8 +395,8 @@ struct rcv_desc {
 };
 
 /* opcode field in status_desc */
-#define RCV_NIC_PKT    (0xA)
-#define STATUS_NIC_PKT ((RCV_NIC_PKT) << 12)
+#define NETXEN_NIC_RXPKT_DESC  0x04
+#define NETXEN_OLD_RXPKT_DESC  0x3f
 
 /* for status field in status_desc */
 #define STATUS_NEED_CKSUM      (1)
@@ -424,6 +428,8 @@ struct rcv_desc {
        (((sts_data) >> 28) & 0xFFFF)
 #define netxen_get_sts_prot(sts_data)  \
        (((sts_data) >> 44) & 0x0F)
+#define netxen_get_sts_pkt_offset(sts_data)    \
+       (((sts_data) >> 48) & 0x1F)
 #define netxen_get_sts_opcode(sts_data)        \
        (((sts_data) >> 58) & 0x03F)
 
@@ -438,17 +444,30 @@ struct rcv_desc {
 
 struct status_desc {
        /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length
-          28-43 reference_handle, 44-47 protocol, 48-52 unused
+          28-43 reference_handle, 44-47 protocol, 48-52 pkt_offset
           53-55 desc_cnt, 56-57 owner, 58-63 opcode
         */
        __le64 status_desc_data;
-       __le32 hash_value;
-       u8 hash_type;
-       u8 msg_type;
-       u8 unused;
-       /* Bit pattern: 0-6 lro_count indicates frag sequence,
-          7 last_frag indicates last frag */
-       u8 lro;
+       union {
+               struct {
+                       __le32 hash_value;
+                       u8 hash_type;
+                       u8 msg_type;
+                       u8 unused;
+                       union {
+                               /* Bit pattern: 0-6 lro_count indicates frag
+                                * sequence, 7 last_frag indicates last frag
+                                */
+                               u8 lro;
+
+                               /* chained buffers */
+                               u8 nr_frags;
+                       };
+               };
+               struct {
+                       __le16 frag_handles[4];
+               };
+       };
 } __attribute__ ((aligned(16)));
 
 enum {
@@ -774,6 +793,7 @@ struct netxen_cmd_buffer {
 
 /* In rx_buffer, we do not need multiple fragments as is a single buffer */
 struct netxen_rx_buffer {
+       struct list_head list;
        struct sk_buff *skb;
        u64 dma;
        u16 ref_handle;
@@ -854,6 +874,7 @@ struct nx_host_rds_ring {
        u32 dma_size;
        u32 skb_size;
        struct netxen_rx_buffer *rx_buf_arr;    /* rx buffers for receive   */
+       struct list_head free_list;
        int begin_alloc;
 };
 
@@ -1115,11 +1136,45 @@ typedef struct nx_mac_list_s {
        uint8_t mac_addr[MAX_ADDR_LEN];
 } nx_mac_list_t;
 
+/*
+ * Interrupt coalescing defaults. The defaults are for 1500 MTU. It is
+ * adjusted based on configured MTU.
+ */
+#define NETXEN_DEFAULT_INTR_COALESCE_RX_TIME_US        3
+#define NETXEN_DEFAULT_INTR_COALESCE_RX_PACKETS        256
+#define NETXEN_DEFAULT_INTR_COALESCE_TX_PACKETS        64
+#define NETXEN_DEFAULT_INTR_COALESCE_TX_TIME_US        4
+
+#define NETXEN_NIC_INTR_DEFAULT                        0x04
+
+typedef union {
+       struct {
+               uint16_t        rx_packets;
+               uint16_t        rx_time_us;
+               uint16_t        tx_packets;
+               uint16_t        tx_time_us;
+       } data;
+       uint64_t                word;
+} nx_nic_intr_coalesce_data_t;
+
+typedef struct {
+       uint16_t                        stats_time_us;
+       uint16_t                        rate_sample_time;
+       uint16_t                        flags;
+       uint16_t                        rsvd_1;
+       uint32_t                        low_threshold;
+       uint32_t                        high_threshold;
+       nx_nic_intr_coalesce_data_t     normal;
+       nx_nic_intr_coalesce_data_t     low;
+       nx_nic_intr_coalesce_data_t     high;
+       nx_nic_intr_coalesce_data_t     irq;
+} nx_nic_intr_coalesce_t;
+
 typedef struct {
        u64 qhdr;
        u64 req_hdr;
        u64 words[6];
-} nic_request_t;
+} nx_nic_req_t;
 
 typedef struct {
        u8 op;
@@ -1127,6 +1182,7 @@ typedef struct {
        u8 mac_addr[6];
 } nx_mac_req_t;
 
+#define MAX_PENDING_DESC_BLOCK_SIZE    64
 
 #define NETXEN_NIC_MSI_ENABLED         0x02
 #define NETXEN_NIC_MSIX_ENABLED                0x04
@@ -1139,6 +1195,10 @@ typedef struct {
 
 #define NETXEN_DB_MAPSIZE_BYTES        0x1000
 
+#define NETXEN_NETDEV_WEIGHT 120
+#define NETXEN_ADAPTER_UP_MAGIC 777
+#define NETXEN_NIC_PEG_TUNE 0
+
 struct netxen_dummy_dma {
        void *addr;
        dma_addr_t phys_addr;
@@ -1152,7 +1212,6 @@ struct netxen_adapter {
        int pci_using_dac;
        struct napi_struct napi;
        struct net_device_stats net_stats;
-       unsigned char mac_addr[ETH_ALEN];
        int mtu;
        int portnum;
        u8 physical_port;
@@ -1160,6 +1219,7 @@ struct netxen_adapter {
 
        uint8_t         mc_enabled;
        uint8_t         max_mc_count;
+       nx_mac_list_t   *mac_list;
 
        struct netxen_legacy_intr_set legacy_intr;
        u32     crb_intr_mask;
@@ -1217,6 +1277,7 @@ struct netxen_adapter {
 
        int is_up;
        struct netxen_dummy_dma dummy_dma;
+       nx_nic_intr_coalesce_t coal;
 
        /* Context interface shared between card and host */
        struct netxen_ring_ctx *ctx_desc;
@@ -1231,7 +1292,6 @@ struct netxen_adapter {
        int (*phy_read) (struct netxen_adapter *, long reg, u32 *);
        int (*phy_write) (struct netxen_adapter *, long reg, u32 val);
        int (*init_port) (struct netxen_adapter *, int);
-       void (*init_niu) (struct netxen_adapter *);
        int (*stop_port) (struct netxen_adapter *);
 
        int (*hw_read_wx)(struct netxen_adapter *, ulong, void *, int);
@@ -1316,7 +1376,6 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter,
 /* Functions available from netxen_nic_hw.c */
 int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu);
 int netxen_nic_set_mtu_gb(struct netxen_adapter *adapter, int new_mtu);
-void netxen_nic_init_niu_gb(struct netxen_adapter *adapter);
 void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val);
 int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off);
 void netxen_nic_write_w0(struct netxen_adapter *adapter, u32 index, u32 value);
@@ -1404,7 +1463,9 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx,
                            u32 ringid);
 int netxen_process_cmd_ring(struct netxen_adapter *adapter);
 u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max);
-void netxen_nic_set_multi(struct net_device *netdev);
+void netxen_p2_nic_set_multi(struct net_device *netdev);
+void netxen_p3_nic_set_multi(struct net_device *netdev);
+int netxen_config_intr_coalesce(struct netxen_adapter *adapter);
 
 u32 nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, u32 mtu);
 int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu);
@@ -1412,6 +1473,8 @@ int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu);
 int netxen_nic_set_mac(struct net_device *netdev, void *p);
 struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev);
 
+void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter,
+               uint32_t crb_producer);
 
 /*
  * NetXen Board information