e1000: integrate ich8 support into driver
[pandora-kernel.git] / drivers / net / s2io.h
index 852a6a8..3203732 100644 (file)
@@ -31,6 +31,8 @@
 #define SUCCESS 0
 #define FAILURE -1
 
+#define CHECKBIT(value, nbit) (value & (1 << nbit))
+
 /* Maximum time to flicker LED when asked to identify NIC using ethtool */
 #define MAX_FLICKER_TIME       60000 /* 60 Secs */
 
@@ -64,7 +66,7 @@ typedef enum xena_max_outstanding_splits {
 #define        INTR_DBG        4
 
 /* Global variable that defines the present debug level of the driver. */
-int debug_level = ERR_DBG;     /* Default level. */
+static int debug_level = ERR_DBG;
 
 /* DEBUG message print. */
 #define DBG_PRINT(dbg_level, args...)  if(!(debug_level<dbg_level)) printk(args)
@@ -78,8 +80,39 @@ int debug_level = ERR_DBG;   /* Default level. */
 typedef struct {
        unsigned long long single_ecc_errs;
        unsigned long long double_ecc_errs;
+       unsigned long long parity_err_cnt;
+       unsigned long long serious_err_cnt;
+       unsigned long long soft_reset_cnt;
+       unsigned long long fifo_full_cnt;
+       unsigned long long ring_full_cnt;
+       /* LRO statistics */
+       unsigned long long clubbed_frms_cnt;
+       unsigned long long sending_both;
+       unsigned long long outof_sequence_pkts;
+       unsigned long long flush_max_pkts;
+       unsigned long long sum_avg_pkts_aggregated;
+       unsigned long long num_aggregations;
 } swStat_t;
 
+/* Xpak releated alarm and warnings */
+typedef struct {
+       u64 alarm_transceiver_temp_high;
+       u64 alarm_transceiver_temp_low;
+       u64 alarm_laser_bias_current_high;
+       u64 alarm_laser_bias_current_low;
+       u64 alarm_laser_output_power_high;
+       u64 alarm_laser_output_power_low;
+       u64 warn_transceiver_temp_high;
+       u64 warn_transceiver_temp_low;
+       u64 warn_laser_bias_current_high;
+       u64 warn_laser_bias_current_low;
+       u64 warn_laser_output_power_high;
+       u64 warn_laser_output_power_low;
+       u64 xpak_regs_stat;
+       u32 xpak_timer_count;
+} xpakStat_t;
+
+
 /* The statistics block of Xena */
 typedef struct stat_block {
 /* Tx MAC statistics counters. */
@@ -256,7 +289,9 @@ typedef struct stat_block {
        u32 rmac_accepted_ip_oflow;
        u32 reserved_14;
        u32 link_fault_cnt;
+       u8  buffer[20];
        swStat_t sw_stat;
+       xpakStat_t xpak_stat;
 } StatInfo_t;
 
 /*
@@ -268,7 +303,7 @@ typedef struct stat_block {
 #define MAX_RX_RINGS 8
 
 /* FIFO mappings for all possible number of fifos configured */
-int fifo_map[][MAX_TX_FIFOS] = {
+static int fifo_map[][MAX_TX_FIFOS] = {
        {0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 1, 1, 1, 1},
        {0, 0, 0, 1, 1, 1, 2, 2},
@@ -652,7 +687,8 @@ typedef struct {
 } usr_addr_t;
 
 /* Default Tunable parameters of the NIC. */
-#define DEFAULT_FIFO_LEN 4096
+#define DEFAULT_FIFO_0_LEN 4096
+#define DEFAULT_FIFO_1_7_LEN 512
 #define SMALL_BLK_CNT  30
 #define LARGE_BLK_CNT  100
 
@@ -680,6 +716,24 @@ struct msix_info_st {
        u64 data;
 };
 
+/* Data structure to represent a LRO session */
+typedef struct lro {
+       struct sk_buff  *parent;
+       u8              *l2h;
+       struct iphdr    *iph;
+       struct tcphdr   *tcph;
+       u32             tcp_next_seq;
+       u32             tcp_ack;
+       int             total_len;
+       int             frags_len;
+       int             sg_num;
+       int             in_use;
+       u16             window;
+       u32             cur_tsval;
+       u32             cur_tsecr;
+       u8              saw_ts;
+}lro_t;
+
 /* Structure representing one instance of the NIC */
 struct s2io_nic {
        int rxd_mode;
@@ -707,7 +761,7 @@ struct s2io_nic {
        int device_close_flag;
        int device_enabled_once;
 
-       char name[50];
+       char name[60];
        struct tasklet_struct task;
        volatile unsigned long tasklet_status;
 
@@ -778,12 +832,21 @@ struct s2io_nic {
        char desc1[35];
        char desc2[35];
 
+       int avail_msix_vectors; /* No. of MSI-X vectors granted by system */
+
        struct msix_info_st msix_info[0x3f];
 
 #define XFRAME_I_DEVICE                1
 #define XFRAME_II_DEVICE       2
        u8 device_type;
 
+#define MAX_LRO_SESSIONS       32
+       lro_t lro0_n[MAX_LRO_SESSIONS];
+       unsigned long   clubbed_frms_cnt;
+       unsigned long   sending_both;
+       u8              lro;
+       u16             lro_max_aggr_per_sess;
+
 #define INTA   0
 #define MSI    1
 #define MSI_X  2
@@ -792,6 +855,8 @@ struct s2io_nic {
        spinlock_t      rx_lock;
        atomic_t        isr_cnt;
        u64 *ufo_in_band_v;
+#define VPD_PRODUCT_NAME_LEN 50
+       u8  product_name[VPD_PRODUCT_NAME_LEN];
 };
 
 #define RESET_ERROR 1;
@@ -816,28 +881,32 @@ static inline void writeq(u64 val, void __iomem *addr)
        writel((u32) (val), addr);
        writel((u32) (val >> 32), (addr + 4));
 }
+#endif
 
-/* In 32 bit modes, some registers have to be written in a
- * particular order to expect correct hardware operation. The
- * macro SPECIAL_REG_WRITE is used to perform such ordered
- * writes. Defines UF (Upper First) and LF (Lower First) will
- * be used to specify the required write order.
+/* 
+ * Some registers have to be written in a particular order to 
+ * expect correct hardware operation. The macro SPECIAL_REG_WRITE 
+ * is used to perform such ordered writes. Defines UF (Upper First) 
+ * and LF (Lower First) will be used to specify the required write order.
  */
 #define UF     1
 #define LF     2
 static inline void SPECIAL_REG_WRITE(u64 val, void __iomem *addr, int order)
 {
+       u32 ret;
+
        if (order == LF) {
                writel((u32) (val), addr);
+               ret = readl(addr);
                writel((u32) (val >> 32), (addr + 4));
+               ret = readl(addr + 4);
        } else {
                writel((u32) (val >> 32), (addr + 4));
+               ret = readl(addr + 4);
                writel((u32) (val), addr);
+               ret = readl(addr);
        }
 }
-#else
-#define SPECIAL_REG_WRITE(val, addr, dummy) writeq(val, addr)
-#endif
 
 /*  Interrupt related values of Xena */
 
@@ -911,18 +980,16 @@ static void tx_intr_handler(fifo_info_t *fifo_data);
 static void alarm_intr_handler(struct s2io_nic *sp);
 
 static int s2io_starter(void);
-void s2io_closer(void);
 static void s2io_tx_watchdog(struct net_device *dev);
 static void s2io_tasklet(unsigned long dev_addr);
 static void s2io_set_multicast(struct net_device *dev);
 static int rx_osm_handler(ring_info_t *ring_data, RxD_t * rxdp);
-void s2io_link(nic_t * sp, int link);
-void s2io_reset(nic_t * sp);
+static void s2io_link(nic_t * sp, int link);
 #if defined(CONFIG_S2IO_NAPI)
 static int s2io_poll(struct net_device *dev, int *budget);
 #endif
 static void s2io_init_pci(nic_t * sp);
-int s2io_set_mac_addr(struct net_device *dev, u8 * addr);
+static int s2io_set_mac_addr(struct net_device *dev, u8 * addr);
 static void s2io_alarm_handle(unsigned long data);
 static int s2io_enable_msi(nic_t *nic);
 static irqreturn_t s2io_msi_handle(int irq, void *dev_id, struct pt_regs *regs);
@@ -930,14 +997,19 @@ static irqreturn_t
 s2io_msix_ring_handle(int irq, void *dev_id, struct pt_regs *regs);
 static irqreturn_t
 s2io_msix_fifo_handle(int irq, void *dev_id, struct pt_regs *regs);
-int s2io_enable_msi_x(nic_t *nic);
 static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs);
 static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag);
 static struct ethtool_ops netdev_ethtool_ops;
 static void s2io_set_link(unsigned long data);
-int s2io_set_swapper(nic_t * sp);
-static void s2io_card_down(nic_t *nic);
+static int s2io_set_swapper(nic_t * sp);
+static void s2io_card_down(nic_t *nic, int flag);
 static int s2io_card_up(nic_t *nic);
-int get_xena_rev_id(struct pci_dev *pdev);
-void restore_xmsi_data(nic_t *nic);
+static int get_xena_rev_id(struct pci_dev *pdev);
+static void restore_xmsi_data(nic_t *nic);
+
+static int s2io_club_tcp_session(u8 *buffer, u8 **tcp, u32 *tcp_len, lro_t **lro, RxD_t *rxdp, nic_t *sp);
+static void clear_lro_session(lro_t *lro);
+static void queue_rx_frame(struct sk_buff *skb);
+static void update_L3L4_header(nic_t *sp, lro_t *lro);
+static void lro_append_pkt(nic_t *sp, lro_t *lro, struct sk_buff *skb, u32 tcp_len);
 #endif                         /* _S2IO_H */