Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block
[safe/jmp/linux-2.6] / drivers / net / bnx2x.h
index 97bc5e0..3c48a7a 100644 (file)
@@ -1,6 +1,6 @@
 /* bnx2x.h: Broadcom Everest network driver.
  *
- * Copyright (c) 2007-2009 Broadcom Corporation
+ * Copyright (c) 2007-2010 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #define BCM_VLAN                       1
 #endif
 
+#if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE)
+#define BCM_CNIC 1
+#include "cnic_if.h"
+#endif
 
 #define BNX2X_MULTI_QUEUE
 
@@ -40,7 +44,6 @@
 /* error/debug prints */
 
 #define DRV_MODULE_NAME                "bnx2x"
-#define PFX DRV_MODULE_NAME    ": "
 
 /* for messages that are currently off */
 #define BNX2X_MSG_OFF                  0
 #define DP_LEVEL                       KERN_NOTICE     /* was: KERN_DEBUG */
 
 /* regular debug print */
-#define DP(__mask, __fmt, __args...) do { \
-       if (bp->msglevel & (__mask)) \
-               printk(DP_LEVEL "[%s:%d(%s)]" __fmt, __func__, __LINE__, \
-                       bp->dev ? (bp->dev->name) : "?", ##__args); \
-       } while (0)
+#define DP(__mask, __fmt, __args...)                           \
+do {                                                           \
+       if (bp->msg_enable & (__mask))                          \
+               printk(DP_LEVEL "[%s:%d(%s)]" __fmt,            \
+                      __func__, __LINE__,                      \
+                      bp->dev ? (bp->dev->name) : "?",         \
+                      ##__args);                               \
+} while (0)
 
 /* errors debug print */
-#define BNX2X_DBG_ERR(__fmt, __args...) do { \
-       if (bp->msglevel & NETIF_MSG_PROBE) \
-               printk(KERN_ERR "[%s:%d(%s)]" __fmt, __func__, __LINE__, \
-                       bp->dev ? (bp->dev->name) : "?", ##__args); \
-       } while (0)
+#define BNX2X_DBG_ERR(__fmt, __args...)                                \
+do {                                                           \
+       if (netif_msg_probe(bp))                                \
+               pr_err("[%s:%d(%s)]" __fmt,                     \
+                      __func__, __LINE__,                      \
+                      bp->dev ? (bp->dev->name) : "?",         \
+                      ##__args);                               \
+} while (0)
 
 /* for errors (never masked) */
-#define BNX2X_ERR(__fmt, __args...) do { \
-       printk(KERN_ERR "[%s:%d(%s)]" __fmt, __func__, __LINE__, \
-               bp->dev ? (bp->dev->name) : "?", ##__args); \
-       } while (0)
+#define BNX2X_ERR(__fmt, __args...)                            \
+do {                                                           \
+       pr_err("[%s:%d(%s)]" __fmt,                             \
+              __func__, __LINE__,                              \
+              bp->dev ? (bp->dev->name) : "?",                 \
+              ##__args);                                       \
+} while (0)
 
 /* before we have a dev->name use dev_info() */
-#define BNX2X_DEV_INFO(__fmt, __args...) do { \
-       if (bp->msglevel & NETIF_MSG_PROBE) \
-               dev_info(&bp->pdev->dev, __fmt, ##__args); \
-       } while (0)
+#define BNX2X_DEV_INFO(__fmt, __args...)                        \
+do {                                                            \
+       if (netif_msg_probe(bp))                                 \
+               dev_info(&bp->pdev->dev, __fmt, ##__args);       \
+} while (0)
 
 
 #ifdef BNX2X_STOP_ON_ERROR
                                 offset, len32); \
        } while (0)
 
-#define VIRT_WR_DMAE_LEN(bp, data, addr, len32) \
+#define VIRT_WR_DMAE_LEN(bp, data, addr, len32, le32_swap) \
        do { \
                memcpy(GUNZIP_BUF(bp), data, (len32) * 4); \
                bnx2x_write_big_buf_wb(bp, addr, len32); \
@@ -255,9 +268,6 @@ struct bnx2x_eth_q_stats {
 struct bnx2x_fastpath {
 
        struct napi_struct      napi;
-
-       u8                      is_rx_queue;
-
        struct host_status_block *status_blk;
        dma_addr_t              status_blk_mapping;
 
@@ -314,9 +324,11 @@ struct bnx2x_fastpath {
        __le16                  *rx_cons_sb;
        __le16                  *rx_bd_cons_sb;
 
+
        unsigned long           tx_pkt,
                                rx_pkt,
                                rx_calls;
+
        /* TPA related */
        struct sw_rx_bd         tpa_pool[ETH_MAX_AGGREGATION_QUEUES_E1H];
        u8                      tpa_state[ETH_MAX_AGGREGATION_QUEUES_E1H];
@@ -760,7 +772,11 @@ struct bnx2x_eth_stats {
                        (offsetof(struct bnx2x_eth_stats, stat_name) / 4)
 
 
+#ifdef BCM_CNIC
+#define MAX_CONTEXT                    15
+#else
 #define MAX_CONTEXT                    16
+#endif
 
 union cdu_context {
        struct eth_context eth;
@@ -809,13 +825,21 @@ struct bnx2x {
        struct bnx2x_fastpath   fp[MAX_CONTEXT];
        void __iomem            *regview;
        void __iomem            *doorbells;
+#ifdef BCM_CNIC
+#define BNX2X_DB_SIZE          (18*BCM_PAGE_SIZE)
+#else
 #define BNX2X_DB_SIZE          (16*BCM_PAGE_SIZE)
+#endif
 
        struct net_device       *dev;
        struct pci_dev          *pdev;
 
        atomic_t                intr_sem;
+#ifdef BCM_CNIC
+       struct msix_entry       msix_table[MAX_CONTEXT+2];
+#else
        struct msix_entry       msix_table[MAX_CONTEXT+1];
+#endif
 #define INT_MODE_INTx                  1
 #define INT_MODE_MSI                   2
 #define INT_MODE_MSIX                  3
@@ -861,13 +885,13 @@ struct bnx2x {
 
        /* Flags for marking that there is a STAT_QUERY or
           SET_MAC ramrod pending */
-       u8                      stats_pending;
-       u8                      set_mac_pending;
+       int                     stats_pending;
+       int                     set_mac_pending;
 
        /* End of fields used in the performance code paths */
 
        int                     panic;
-       int                     msglevel;
+       int                     msg_enable;
 
        u32                     flags;
 #define PCIX_FLAG                      1
@@ -882,6 +906,7 @@ struct bnx2x {
 #define BP_NOMCP(bp)                   (bp->flags & NO_MCP_FLAG)
 #define HW_VLAN_TX_FLAG                        0x400
 #define HW_VLAN_RX_FLAG                        0x800
+#define MF_FUNC_DIS                    0x1000
 
        int                     func;
 #define BP_PORT(bp)                    (bp->func % PORT_MAX)
@@ -889,6 +914,11 @@ struct bnx2x {
 #define BP_E1HVN(bp)                   (bp->func >> 1)
 #define BP_L_ID(bp)                    (BP_E1HVN(bp) << 2)
 
+#ifdef BCM_CNIC
+#define BCM_CNIC_CID_START             16
+#define BCM_ISCSI_ETH_CL_ID            17
+#endif
+
        int                     pm_cap;
        int                     pcie_cap;
        int                     mrrs;
@@ -942,13 +972,11 @@ struct bnx2x {
 #define BNX2X_STATE_CLOSING_WAIT4_HALT 0x4000
 #define BNX2X_STATE_CLOSING_WAIT4_DELETE 0x5000
 #define BNX2X_STATE_CLOSING_WAIT4_UNLOAD 0x6000
-#define BNX2X_STATE_DISABLED           0xd000
 #define BNX2X_STATE_DIAG               0xe000
 #define BNX2X_STATE_ERROR              0xf000
 
        int                     multi_mode;
-       int                     num_rx_queues;
-       int                     num_tx_queues;
+       int                     num_queues;
 
        u32                     rx_mode;
 #define BNX2X_RX_MODE_NONE             0
@@ -958,28 +986,51 @@ struct bnx2x {
 #define BNX2X_MAX_MULTICAST            64
 #define BNX2X_MAX_EMUL_MULTI           16
 
+       u32                     rx_mode_cl_mask;
+
        dma_addr_t              def_status_blk_mapping;
 
        struct bnx2x_slowpath   *slowpath;
        dma_addr_t              slowpath_mapping;
 
-#ifdef BCM_ISCSI
-       void                    *t1;
-       dma_addr_t              t1_mapping;
-       void                    *t2;
-       dma_addr_t              t2_mapping;
-       void                    *timers;
-       dma_addr_t              timers_mapping;
-       void                    *qm;
-       dma_addr_t              qm_mapping;
-#endif
-
        int                     dropless_fc;
 
+#ifdef BCM_CNIC
+       u32                     cnic_flags;
+#define BNX2X_CNIC_FLAG_MAC_SET                1
+
+       void                    *t1;
+       dma_addr_t              t1_mapping;
+       void                    *t2;
+       dma_addr_t              t2_mapping;
+       void                    *timers;
+       dma_addr_t              timers_mapping;
+       void                    *qm;
+       dma_addr_t              qm_mapping;
+       struct cnic_ops         *cnic_ops;
+       void                    *cnic_data;
+       u32                     cnic_tag;
+       struct cnic_eth_dev     cnic_eth_dev;
+       struct host_status_block *cnic_sb;
+       dma_addr_t              cnic_sb_mapping;
+#define CNIC_SB_ID(bp)                 BP_L_ID(bp)
+       struct eth_spe          *cnic_kwq;
+       struct eth_spe          *cnic_kwq_prod;
+       struct eth_spe          *cnic_kwq_cons;
+       struct eth_spe          *cnic_kwq_last;
+       u16                     cnic_kwq_pending;
+       u16                     cnic_spq_pending;
+       struct mutex            cnic_mutex;
+       u8                      iscsi_mac[6];
+#endif
+
        int                     dmae_ready;
        /* used to synchronize dmae accesses */
        struct mutex            dmae_mutex;
 
+       /* used to protect the FW mail box */
+       struct mutex            fw_mb_mutex;
+
        /* used to synchronize stats collecting */
        int                     stats_state;
        /* used by dmae command loader */
@@ -998,20 +1049,20 @@ struct bnx2x {
 #define GUNZIP_PHYS(bp)                        (bp->gunzip_mapping)
 #define GUNZIP_OUTLEN(bp)              (bp->gunzip_outlen)
 
-       struct raw_op          *init_ops;
+       struct raw_op           *init_ops;
        /* Init blocks offsets inside init_ops */
-       u16                    *init_ops_offsets;
+       u16                     *init_ops_offsets;
        /* Data blob - has 32 bit granularity */
-       u32                    *init_data;
+       u32                     *init_data;
        /* Zipped PRAM blobs - raw data */
-       const u8               *tsem_int_table_data;
-       const u8               *tsem_pram_data;
-       const u8               *usem_int_table_data;
-       const u8               *usem_pram_data;
-       const u8               *xsem_int_table_data;
-       const u8               *xsem_pram_data;
-       const u8               *csem_int_table_data;
-       const u8               *csem_pram_data;
+       const u8                *tsem_int_table_data;
+       const u8                *tsem_pram_data;
+       const u8                *usem_int_table_data;
+       const u8                *usem_pram_data;
+       const u8                *xsem_int_table_data;
+       const u8                *xsem_pram_data;
+       const u8                *csem_int_table_data;
+       const u8                *csem_pram_data;
 #define INIT_OPS(bp)                   (bp->init_ops)
 #define INIT_OPS_OFFSETS(bp)           (bp->init_ops_offsets)
 #define INIT_DATA(bp)                  (bp->init_data)
@@ -1024,24 +1075,19 @@ struct bnx2x {
 #define INIT_CSEM_INT_TABLE_DATA(bp)   (bp->csem_int_table_data)
 #define INIT_CSEM_PRAM_DATA(bp)                (bp->csem_pram_data)
 
-        const struct firmware  *firmware;
+       const struct firmware   *firmware;
 };
 
 
-#define BNX2X_MAX_QUEUES(bp)   (IS_E1HMF(bp) ? (MAX_CONTEXT/(2 * E1HVN_MAX)) \
-                                             : (MAX_CONTEXT/2))
-#define BNX2X_NUM_QUEUES(bp)   (bp->num_rx_queues + bp->num_tx_queues)
-#define is_multi(bp)           (BNX2X_NUM_QUEUES(bp) > 2)
+#define BNX2X_MAX_QUEUES(bp)   (IS_E1HMF(bp) ? (MAX_CONTEXT/E1HVN_MAX) \
+                                             : MAX_CONTEXT)
+#define BNX2X_NUM_QUEUES(bp)   (bp->num_queues)
+#define is_multi(bp)           (BNX2X_NUM_QUEUES(bp) > 1)
 
-#define for_each_rx_queue(bp, var) \
-                       for (var = 0; var < bp->num_rx_queues; var++)
-#define for_each_tx_queue(bp, var) \
-                       for (var = bp->num_rx_queues; \
-                            var < BNX2X_NUM_QUEUES(bp); var++)
 #define for_each_queue(bp, var) \
                        for (var = 0; var < BNX2X_NUM_QUEUES(bp); var++)
 #define for_each_nondefault_queue(bp, var) \
-                       for (var = 1; var < bp->num_rx_queues; var++)
+                       for (var = 1; var < BNX2X_NUM_QUEUES(bp); var++)
 
 
 void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32);
@@ -1111,9 +1157,9 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
 #define DMAE_COMP_VAL                  0xe0d0d0ae
 
 #define MAX_DMAE_C_PER_PORT            8
-#define INIT_DMAE_C(bp)                        (BP_PORT(bp)*MAX_DMAE_C_PER_PORT + \
+#define INIT_DMAE_C(bp)                        (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
                                         BP_E1HVN(bp))
-#define PMF_DMAE_C(bp)                 (BP_PORT(bp)*MAX_DMAE_C_PER_PORT + \
+#define PMF_DMAE_C(bp)                 (BP_PORT(bp) * MAX_DMAE_C_PER_PORT + \
                                         E1HVN_MAX)
 
 
@@ -1138,13 +1184,14 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
 
 
 /* must be used on a CID before placing it on a HW ring */
-#define HW_CID(bp, x)          ((BP_PORT(bp) << 23) | (BP_E1HVN(bp) << 17) | x)
+#define HW_CID(bp, x)                  ((BP_PORT(bp) << 23) | \
+                                        (BP_E1HVN(bp) << 17) | (x))
 
 #define SP_DESC_CNT            (BCM_PAGE_SIZE / sizeof(struct eth_spe))
 #define MAX_SP_DESC_CNT                        (SP_DESC_CNT - 1)
 
 
-#define BNX2X_BTR                      3
+#define BNX2X_BTR                      1
 #define MAX_SPQ_PENDING                        8
 
 
@@ -1226,8 +1273,8 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
                                 AEU_INPUTS_ATTN_BITS_QM_PARITY_ERROR | \
                                 AEU_INPUTS_ATTN_BITS_XSDM_PARITY_ERROR | \
                                 AEU_INPUTS_ATTN_BITS_XSEMI_PARITY_ERROR | \
-                               AEU_INPUTS_ATTN_BITS_DOORBELLQ_PARITY_ERROR |\
-                           AEU_INPUTS_ATTN_BITS_VAUX_PCI_CORE_PARITY_ERROR |\
+                                AEU_INPUTS_ATTN_BITS_DOORBELLQ_PARITY_ERROR |\
+                            AEU_INPUTS_ATTN_BITS_VAUX_PCI_CORE_PARITY_ERROR |\
                                 AEU_INPUTS_ATTN_BITS_DEBUG_PARITY_ERROR | \
                                 AEU_INPUTS_ATTN_BITS_USDM_PARITY_ERROR | \
                                 AEU_INPUTS_ATTN_BITS_USEMI_PARITY_ERROR | \
@@ -1255,7 +1302,6 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
                 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY | \
                 (bp->multi_mode << \
                  TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_MODE_SHIFT))
-
 #define MULTI_MASK                     0x7f