igb: remove rx_ps_hdr_len
[safe/jmp/linux-2.6] / drivers / net / igb / igb.h
index d4a0423..303df02 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) Gigabit Ethernet Linux driver
-  Copyright(c) 2007 Intel Corporation.
+  Copyright(c) 2007-2009 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
 #include "e1000_mac.h"
 #include "e1000_82575.h"
 
-struct igb_adapter;
-
-/* Interrupt defines */
-#define IGB_MAX_TX_CLEAN 72
+#include <linux/clocksource.h>
+#include <linux/timecompare.h>
+#include <linux/net_tstamp.h>
 
-#define IGB_MIN_DYN_ITR 3000
-#define IGB_MAX_DYN_ITR 96000
-#define IGB_START_ITR 6000
+struct igb_adapter;
 
-#define IGB_DYN_ITR_PACKET_THRESHOLD 2
-#define IGB_DYN_ITR_LENGTH_LOW 200
-#define IGB_DYN_ITR_LENGTH_HIGH 1000
+/* ((1000000000ns / (6000ints/s * 1024ns)) << 2 = 648 */
+#define IGB_START_ITR 648
 
 /* TX/RX descriptor defines */
 #define IGB_DEFAULT_TXD                  256
@@ -59,10 +55,26 @@ struct igb_adapter;
 #define IGB_DEFAULT_ITR                    3 /* dynamic */
 #define IGB_MAX_ITR_USECS              10000
 #define IGB_MIN_ITR_USECS                 10
+#define NON_Q_VECTORS                      1
+#define MAX_Q_VECTORS                      8
 
 /* Transmit and receive queues */
-#define IGB_MAX_RX_QUEUES                  4
-#define IGB_MAX_TX_QUEUES                  4
+#define IGB_MAX_RX_QUEUES     (adapter->vfs_allocated_count ? \
+                               (adapter->vfs_allocated_count > 6 ? 1 : 2) : 4)
+#define IGB_MAX_TX_QUEUES     IGB_MAX_RX_QUEUES
+#define IGB_ABS_MAX_TX_QUEUES     4
+
+#define IGB_MAX_VF_MC_ENTRIES              30
+#define IGB_MAX_VF_FUNCTIONS               8
+#define IGB_MAX_VFTA_ENTRIES               128
+
+struct vf_data_storage {
+       unsigned char vf_mac_addresses[ETH_ALEN];
+       u16 vf_mc_hashes[IGB_MAX_VF_MC_ENTRIES];
+       u16 num_vf_mc_hashes;
+       u16 vlans_enabled;
+       bool clear_to_send;
+};
 
 /* RX descriptor control thresholds.
  * PTHRESH - MAC will consider prefetch if it has fewer than this number of
@@ -75,25 +87,24 @@ struct igb_adapter;
  *           descriptors until either it has this many to write back, or the
  *           ITR timer expires.
  */
-#define IGB_RX_PTHRESH                    16
+#define IGB_RX_PTHRESH                    (hw->mac.type <= e1000_82576 ? 16 : 8)
 #define IGB_RX_HTHRESH                     8
 #define IGB_RX_WTHRESH                     1
+#define IGB_TX_PTHRESH                     8
+#define IGB_TX_HTHRESH                     1
+#define IGB_TX_WTHRESH                     ((hw->mac.type == e1000_82576 && \
+                                             adapter->msix_entries) ? 0 : 16)
 
 /* this is the size past which hardware will drop packets when setting LPE=0 */
 #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
 
 /* Supported Rx Buffer Sizes */
 #define IGB_RXBUFFER_128   128    /* Used for packet split */
-#define IGB_RXBUFFER_256   256    /* Used for packet split */
-#define IGB_RXBUFFER_512   512
 #define IGB_RXBUFFER_1024  1024
 #define IGB_RXBUFFER_2048  2048
-#define IGB_RXBUFFER_4096  4096
-#define IGB_RXBUFFER_8192  8192
 #define IGB_RXBUFFER_16384 16384
 
-/* Packet Buffer allocations */
-
+#define MAX_STD_JUMBO_FRAME_SIZE 9234
 
 /* How many Tx Descriptors do we need to call netif_wake_queue ? */
 #define IGB_TX_QUEUE_WAKE      16
@@ -119,75 +130,84 @@ struct igb_buffer {
                /* TX */
                struct {
                        unsigned long time_stamp;
-                       u32 length;
+                       u16 length;
+                       u16 next_to_watch;
                };
                /* RX */
                struct {
                        struct page *page;
                        u64 page_dma;
+                       unsigned int page_offset;
                };
        };
 };
 
-struct igb_queue_stats {
+struct igb_tx_queue_stats {
        u64 packets;
        u64 bytes;
 };
 
-struct igb_ring {
+struct igb_rx_queue_stats {
+       u64 packets;
+       u64 bytes;
+       u64 drops;
+};
+
+struct igb_q_vector {
        struct igb_adapter *adapter; /* backlink */
-       void *desc;                  /* descriptor ring memory */
-       dma_addr_t dma;              /* phys address of the ring */
-       unsigned int size;           /* length of desc. ring in bytes */
-       unsigned int count;          /* number of desc. in the ring */
+       struct igb_ring *rx_ring;
+       struct igb_ring *tx_ring;
+       struct napi_struct napi;
+
+       u32 eims_value;
+       u16 cpu;
+
+       u16 itr_val;
+       u8 set_itr;
+       u8 itr_shift;
+       void __iomem *itr_register;
+
+       char name[IFNAMSIZ + 9];
+};
+
+struct igb_ring {
+       struct igb_q_vector *q_vector; /* backlink to q_vector */
+       void *desc;                    /* descriptor ring memory */
+       dma_addr_t dma;                /* phys address of the ring */
+       unsigned int size;             /* length of desc. ring in bytes */
+       unsigned int count;            /* number of desc. in the ring */
        u16 next_to_use;
        u16 next_to_clean;
        u16 head;
        u16 tail;
        struct igb_buffer *buffer_info; /* array of buffer info structs */
 
-       u32 eims_value;
-       u32 itr_val;
-       u16 itr_register;
-       u16 cpu;
+       u8 queue_index;
+       u8 reg_idx;
 
-       int queue_index;
        unsigned int total_bytes;
        unsigned int total_packets;
 
        union {
                /* TX */
                struct {
-                       struct igb_queue_stats tx_stats;
+                       struct igb_tx_queue_stats tx_stats;
                        bool detect_tx_hung;
                };
                /* RX */
                struct {
-                       /* arrays of page information for packet split */
-                       struct sk_buff *pending_skb;
-                       int pending_skb_page;
-                       int no_itr_adjust;
-                       struct igb_queue_stats rx_stats;
-                       struct napi_struct napi;
+                       struct igb_rx_queue_stats rx_stats;
+                       u64 rx_queue_drops;
                };
        };
-
-       char name[IFNAMSIZ + 5];
 };
 
-#define IGB_DESC_UNUSED(R) \
-       ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
-       (R)->next_to_clean - (R)->next_to_use - 1)
-
 #define E1000_RX_DESC_ADV(R, i)            \
        (&(((union e1000_adv_rx_desc *)((R).desc))[i]))
 #define E1000_TX_DESC_ADV(R, i)            \
        (&(((union e1000_adv_tx_desc *)((R).desc))[i]))
 #define E1000_TX_CTXTDESC_ADV(R, i)        \
        (&(((struct e1000_adv_tx_context_desc *)((R).desc))[i]))
-#define E1000_GET_DESC(R, i, type)     (&(((struct type *)((R).desc))[i]))
-#define E1000_TX_DESC(R, i)            E1000_GET_DESC(R, i, e1000_tx_desc)
-#define E1000_RX_DESC(R, i)            E1000_GET_DESC(R, i, e1000_rx_desc)
 
 /* board specific private data structure */
 
@@ -211,7 +231,6 @@ struct igb_adapter {
        u32 itr_setting;
        u16 tx_itr;
        u16 rx_itr;
-       int set_itr;
 
        struct work_struct reset_task;
        struct work_struct watchdog_task;
@@ -237,21 +256,19 @@ struct igb_adapter {
        int num_rx_queues;
 
        u64 hw_csum_err;
-       u64 hw_csum_good;
-       u64 rx_hdr_split;
        u32 alloc_rx_buff_failed;
-       bool rx_csum;
        u32 gorc;
        u64 gorc_old;
-       u16 rx_ps_hdr_size;
        u32 max_frame_size;
        u32 min_frame_size;
 
        /* OS defined structs */
        struct net_device *netdev;
-       struct napi_struct napi;
        struct pci_dev *pdev;
-       struct net_device_stats net_stats;
+       struct cyclecounter cycles;
+       struct timecounter clock;
+       struct timecompare compare;
+       struct hwtstamp_config hwtstamp_config;
 
        /* structs defined in e1000_hw.h */
        struct e1000_hw hw;
@@ -264,27 +281,31 @@ struct igb_adapter {
        struct igb_ring test_rx_ring;
 
        int msg_enable;
+
+       unsigned int num_q_vectors;
+       struct igb_q_vector *q_vector[MAX_Q_VECTORS];
        struct msix_entry *msix_entries;
        u32 eims_enable_mask;
        u32 eims_other;
 
        /* to not mess up cache alignment, always add to the bottom */
        unsigned long state;
-       unsigned int msi_enabled;
-#ifdef CONFIG_DCA
-       unsigned int dca_enabled;
-#endif
+       unsigned int flags;
        u32 eeprom_wol;
 
-       /* for ioport free */
-       int bars;
-       int need_ioport;
-
-#ifdef CONFIG_NETDEVICES_MULTIQUEUE
-       struct igb_ring *multi_tx_table[IGB_MAX_TX_QUEUES];
-#endif /* CONFIG_NETDEVICES_MULTIQUEUE */
+       struct igb_ring *multi_tx_table[IGB_ABS_MAX_TX_QUEUES];
+       unsigned int tx_ring_count;
+       unsigned int rx_ring_count;
+       unsigned int vfs_allocated_count;
+       struct vf_data_storage *vf_data;
 };
 
+#define IGB_FLAG_HAS_MSI           (1 << 0)
+#define IGB_FLAG_DCA_ENABLED       (1 << 1)
+#define IGB_FLAG_QUAD_PORT_A       (1 << 2)
+#define IGB_FLAG_NEED_CTX_IDX      (1 << 3)
+#define IGB_FLAG_RX_CSUM_DISABLED  (1 << 4)
+
 enum e1000_state_t {
        __IGB_TESTING,
        __IGB_RESETTING,
@@ -306,7 +327,41 @@ extern void igb_reset(struct igb_adapter *);
 extern int igb_set_spd_dplx(struct igb_adapter *, u16);
 extern int igb_setup_tx_resources(struct igb_adapter *, struct igb_ring *);
 extern int igb_setup_rx_resources(struct igb_adapter *, struct igb_ring *);
+extern void igb_free_tx_resources(struct igb_ring *);
+extern void igb_free_rx_resources(struct igb_ring *);
 extern void igb_update_stats(struct igb_adapter *);
 extern void igb_set_ethtool_ops(struct net_device *);
 
+static inline s32 igb_reset_phy(struct e1000_hw *hw)
+{
+       if (hw->phy.ops.reset)
+               return hw->phy.ops.reset(hw);
+
+       return 0;
+}
+
+static inline s32 igb_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
+{
+       if (hw->phy.ops.read_reg)
+               return hw->phy.ops.read_reg(hw, offset, data);
+
+       return 0;
+}
+
+static inline s32 igb_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
+{
+       if (hw->phy.ops.write_reg)
+               return hw->phy.ops.write_reg(hw, offset, data);
+
+       return 0;
+}
+
+static inline s32 igb_get_phy_info(struct e1000_hw *hw)
+{
+       if (hw->phy.ops.get_phy_info)
+               return hw->phy.ops.get_phy_info(hw);
+
+       return 0;
+}
+
 #endif /* _IGB_H_ */