bnx2x: Using registers name
[safe/jmp/linux-2.6] / drivers / net / bnx2x.h
index 6fcccef..9834a86 100644 (file)
@@ -1,6 +1,6 @@
 /* bnx2x.h: Broadcom Everest network driver.
  *
- * Copyright (c) 2007-2008 Broadcom Corporation
+ * Copyright (c) 2007-2009 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
 #endif
 
 
+#define BNX2X_MULTI_QUEUE
+
+#define BNX2X_NEW_NAPI
+
 /* error/debug prints */
 
 #define DRV_MODULE_NAME                "bnx2x"
@@ -154,8 +158,6 @@ struct sw_rx_page {
 #define SGE_PAGE_SHIFT                 PAGE_SHIFT
 #define SGE_PAGE_ALIGN(addr)           PAGE_ALIGN(addr)
 
-#define BCM_RX_ETH_PAYLOAD_ALIGN       64
-
 /* SGE ring related macros */
 #define NUM_RX_SGE_PAGES               2
 #define RX_SGE_CNT             (BCM_PAGE_SIZE / sizeof(struct eth_rx_sge))
@@ -187,6 +189,43 @@ struct sw_rx_page {
 #define NEXT_SGE_MASK_ELEM(el)         (((el) + 1) & RX_SGE_MASK_LEN_MASK)
 
 
+struct bnx2x_eth_q_stats {
+       u32 total_bytes_received_hi;
+       u32 total_bytes_received_lo;
+       u32 total_bytes_transmitted_hi;
+       u32 total_bytes_transmitted_lo;
+       u32 total_unicast_packets_received_hi;
+       u32 total_unicast_packets_received_lo;
+       u32 total_multicast_packets_received_hi;
+       u32 total_multicast_packets_received_lo;
+       u32 total_broadcast_packets_received_hi;
+       u32 total_broadcast_packets_received_lo;
+       u32 total_unicast_packets_transmitted_hi;
+       u32 total_unicast_packets_transmitted_lo;
+       u32 total_multicast_packets_transmitted_hi;
+       u32 total_multicast_packets_transmitted_lo;
+       u32 total_broadcast_packets_transmitted_hi;
+       u32 total_broadcast_packets_transmitted_lo;
+       u32 valid_bytes_received_hi;
+       u32 valid_bytes_received_lo;
+
+       u32 error_bytes_received_hi;
+       u32 error_bytes_received_lo;
+       u32 etherstatsoverrsizepkts_hi;
+       u32 etherstatsoverrsizepkts_lo;
+       u32 no_buff_discard_hi;
+       u32 no_buff_discard_lo;
+
+       u32 driver_xoff;
+       u32 rx_err_discard_pkt;
+       u32 rx_skb_alloc_failed;
+       u32 hw_csum_err;
+};
+
+#define BNX2X_NUM_Q_STATS              11
+#define Q_STATS_OFFSET32(stat_name) \
+                       (offsetof(struct bnx2x_eth_q_stats, stat_name) / 4)
+
 struct bnx2x_fastpath {
 
        struct napi_struct      napi;
@@ -266,19 +305,18 @@ struct bnx2x_fastpath {
        u64                     tpa_queue_used;
 #endif
 
+       struct tstorm_per_client_stats old_tclient;
+       struct ustorm_per_client_stats old_uclient;
+       struct xstorm_per_client_stats old_xclient;
+       struct bnx2x_eth_q_stats eth_q_stats;
+
+       char                    name[IFNAMSIZ];
        struct bnx2x            *bp; /* parent */
 };
 
 #define bnx2x_fp(bp, nr, var)          (bp->fp[nr].var)
 
-#define BNX2X_HAS_TX_WORK(fp) \
-                       ((fp->tx_pkt_prod != le16_to_cpu(*fp->tx_cons_sb)) || \
-                        (fp->tx_pkt_prod != fp->tx_pkt_cons))
-
-#define BNX2X_HAS_RX_WORK(fp) \
-                       (fp->rx_comp_cons != rx_cons_sb)
-
-#define BNX2X_HAS_WORK(fp)     (BNX2X_HAS_RX_WORK(fp) || BNX2X_HAS_TX_WORK(fp))
+#define BNX2X_HAS_WORK(fp)     (bnx2x_has_rx_work(fp) || bnx2x_has_tx_work(fp))
 
 
 /* MC hsi */
@@ -408,10 +446,13 @@ struct bnx2x_fastpath {
 #define BNX2X_RX_CSUM_OK(cqe) \
                        (!(BNX2X_L4_CSUM_ERR(cqe) || BNX2X_IP_CSUM_ERR(cqe)))
 
+#define BNX2X_PRS_FLAG_OVERETH_IPV4(flags) \
+                               (((le16_to_cpu(flags) & \
+                                  PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) >> \
+                                 PARSING_FLAGS_OVER_ETHERNET_PROTOCOL_SHIFT) \
+                                == PRS_FLAG_OVERETH_IPV4)
 #define BNX2X_RX_SUM_FIX(cqe) \
-                       ((le16_to_cpu(cqe->fast_path_cqe.pars_flags.flags) & \
-                         PARSING_FLAGS_OVER_ETHERNET_PROTOCOL) == \
-                        (1 << PARSING_FLAGS_OVER_ETHERNET_PROTOCOL_SHIFT))
+       BNX2X_PRS_FLAG_OVERETH_IPV4(cqe->fast_path_cqe.pars_flags.flags)
 
 
 #define FP_USB_FUNC_OFF                        (2 + 2*HC_USTORM_SB_NUM_INDICES)
@@ -485,11 +526,8 @@ struct bnx2x_common {
        u32                     shmem_base;
 
        u32                     hw_config;
-       u32                     board;
 
        u32                     bc_ver;
-
-       char                    *name;
 };
 
 
@@ -535,6 +573,7 @@ struct bnx2x_port {
 
        /* used to synchronize phy accesses */
        struct mutex            phy_mutex;
+       int                     need_hw_lock;
 
        u32                     port_stx;
 
@@ -580,6 +619,10 @@ struct bnx2x_eth_stats {
 
        u32 error_bytes_received_hi;
        u32 error_bytes_received_lo;
+       u32 etherstatsoverrsizepkts_hi;
+       u32 etherstatsoverrsizepkts_lo;
+       u32 no_buff_discard_hi;
+       u32 no_buff_discard_lo;
 
        u32 rx_stat_ifhcinbadoctets_hi;
        u32 rx_stat_ifhcinbadoctets_lo;
@@ -658,19 +701,20 @@ struct bnx2x_eth_stats {
        u32 tx_stat_bmac_ufl_hi;
        u32 tx_stat_bmac_ufl_lo;
 
-       u32 brb_drop_hi;
-       u32 brb_drop_lo;
-       u32 brb_truncate_hi;
-       u32 brb_truncate_lo;
-
-       u32 jabber_packets_received;
+       u32 pause_frames_received_hi;
+       u32 pause_frames_received_lo;
+       u32 pause_frames_sent_hi;
+       u32 pause_frames_sent_lo;
 
        u32 etherstatspkts1024octetsto1522octets_hi;
        u32 etherstatspkts1024octetsto1522octets_lo;
        u32 etherstatspktsover1522octets_hi;
        u32 etherstatspktsover1522octets_lo;
 
-       u32 no_buff_discard;
+       u32 brb_drop_hi;
+       u32 brb_drop_lo;
+       u32 brb_truncate_hi;
+       u32 brb_truncate_lo;
 
        u32 mac_filter_discard;
        u32 xxoverflow_discard;
@@ -681,17 +725,16 @@ struct bnx2x_eth_stats {
        u32 rx_err_discard_pkt;
        u32 rx_skb_alloc_failed;
        u32 hw_csum_err;
+
+       u32 nig_timer_max;
 };
 
+#define BNX2X_NUM_STATS                        41
 #define STATS_OFFSET32(stat_name) \
                        (offsetof(struct bnx2x_eth_stats, stat_name) / 4)
 
 
-#ifdef BNX2X_MULTI
 #define MAX_CONTEXT                    16
-#else
-#define MAX_CONTEXT                    1
-#endif
 
 union cdu_context {
        struct eth_context eth;
@@ -746,6 +789,9 @@ struct bnx2x {
 
        atomic_t                intr_sem;
        struct msix_entry       msix_table[MAX_CONTEXT+1];
+#define INT_MODE_INTx                  1
+#define INT_MODE_MSI                   2
+#define INT_MODE_MSIX                  3
 
        int                     tx_ring_size;
 
@@ -754,13 +800,17 @@ struct bnx2x {
 #endif
 
        u32                     rx_csum;
-       u32                     rx_offset;
        u32                     rx_buf_size;
 #define ETH_OVREHEAD                   (ETH_HLEN + 8)  /* 8 for CRC + VLAN */
 #define ETH_MIN_PACKET_SIZE            60
 #define ETH_MAX_PACKET_SIZE            1500
 #define ETH_MAX_JUMBO_PACKET_SIZE      9600
 
+       /* Max supported alignment is 256 (8 shift) */
+#define BNX2X_RX_ALIGN_SHIFT           ((L1_CACHE_SHIFT < 8) ? \
+                                        L1_CACHE_SHIFT : 8)
+#define BNX2X_RX_ALIGN                 (1 << BNX2X_RX_ALIGN_SHIFT)
+
        struct host_def_status_block *def_status_blk;
 #define DEF_SB_ID                      16
        u16                     def_c_idx;
@@ -770,7 +820,6 @@ struct bnx2x {
        u16                     def_att_idx;
        u32                     attn_state;
        struct attn_route       attn_group[MAX_DYNAMIC_ATTN_GRPS];
-       u32                     nig_mask;
 
        /* slow path ring */
        struct eth_spe          *spq;
@@ -796,11 +845,11 @@ struct bnx2x {
        u32                     flags;
 #define PCIX_FLAG                      1
 #define PCI_32BIT_FLAG                 2
-#define ONE_TDMA_FLAG                  4       /* no longer used */
+#define ONE_PORT_FLAG                  4
 #define NO_WOL_FLAG                    8
 #define USING_DAC_FLAG                 0x10
 #define USING_MSIX_FLAG                        0x20
-#define ASF_ENABLE_FLAG                        0x40
+#define USING_MSI_FLAG                 0x40
 #define TPA_ENABLE_FLAG                        0x80
 #define NO_MCP_FLAG                    0x100
 #define BP_NOMCP(bp)                   (bp->flags & NO_MCP_FLAG)
@@ -820,7 +869,6 @@ struct bnx2x {
        struct work_struct      reset_task;
 
        struct timer_list       timer;
-       int                     timer_interval;
        int                     current_interval;
 
        u16                     fw_seq;
@@ -833,6 +881,9 @@ struct bnx2x {
        struct bnx2x_common     common;
        struct bnx2x_port       port;
 
+       struct cmng_struct_per_port cmng;
+       u32                     vn_weight_sum;
+
        u32                     mf_config;
        u16                     e1hov;
        u8                      e1hmf;
@@ -866,8 +917,9 @@ struct bnx2x {
 #define BNX2X_STATE_DIAG               0xe000
 #define BNX2X_STATE_ERROR              0xf000
 
-       int                     num_queues;
-#define BP_MAX_QUEUES(bp)              (IS_E1HMF(bp) ? 4 : 16)
+       int                     multi_mode;
+       int                     num_rx_queues;
+       int                     num_tx_queues;
 
        u32                     rx_mode;
 #define BNX2X_RX_MODE_NONE             0
@@ -905,8 +957,6 @@ struct bnx2x {
        int                     executer_idx;
 
        u16                     stats_counter;
-       struct tstorm_per_client_stats old_tclient;
-       struct xstorm_per_client_stats old_xclient;
        struct bnx2x_eth_stats  eth_stats;
 
        struct z_stream_s       *strm;
@@ -918,17 +968,27 @@ struct bnx2x {
 };
 
 
-#define for_each_queue(bp, var)        for (var = 0; var < bp->num_queues; var++)
+#define BNX2X_MAX_QUEUES(bp)   (IS_E1HMF(bp) ? (MAX_CONTEXT / E1HVN_MAX) : \
+                                                MAX_CONTEXT)
+#define BNX2X_NUM_QUEUES(bp)   max(bp->num_rx_queues, bp->num_tx_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 = 0; var < bp->num_tx_queues; 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_queues; var++)
-#define is_multi(bp)           (bp->num_queues > 1)
+                       for (var = 1; var < BNX2X_NUM_QUEUES(bp); var++)
 
 
 void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32);
 void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr,
                      u32 len32);
+int bnx2x_get_gpio(struct bnx2x *bp, int gpio_num, u8 port);
 int bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode, u8 port);
+int bnx2x_set_gpio_int(struct bnx2x *bp, int gpio_num, u32 mode, u8 port);
 
 static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
                           int wait)
@@ -999,8 +1059,7 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
 #define PCICFG_LINK_SPEED_SHIFT                16
 
 
-#define BNX2X_NUM_STATS                        42
-#define BNX2X_NUM_TESTS                        8
+#define BNX2X_NUM_TESTS                        7
 
 #define BNX2X_MAC_LOOPBACK             0
 #define BNX2X_PHY_LOOPBACK             1
@@ -1127,12 +1186,13 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
                                 AEU_INPUTS_ATTN_BITS_MISC_PARITY_ERROR)
 
 
-#define MULTI_FLAGS \
+#define MULTI_FLAGS(bp) \
                (TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_CAPABILITY | \
                 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV4_TCP_CAPABILITY | \
                 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_CAPABILITY | \
                 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY | \
-                TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_ENABLE)
+                (bp->multi_mode << \
+                 TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_MODE_SHIFT))
 
 #define MULTI_MASK                     0x7f