bnx: Implement multiple RX/TX rings and MSI-X support for 5718/57785
[dragonfly.git] / sys / dev / netif / bnx / if_bnxvar.h
index 3ea3f1c..3255946 100644 (file)
@@ -119,6 +119,7 @@ do {                                                                \
 #define BNX_JMEM ((BNX_JLEN * BNX_JSLOTS) + BNX_RESID)
 
 struct bnx_softc;
+struct bnx_tx_ring;
 
 struct bnx_jslot {
        struct bnx_softc        *bnx_sc;
@@ -136,22 +137,67 @@ struct bnx_jslot {
  * we access via the shared memory window.
  */
 struct bnx_ring_data {
-       struct bge_rx_bd        *bnx_rx_std_ring;
-       bus_addr_t              bnx_rx_std_ring_paddr;
        struct bge_rx_bd        *bnx_rx_jumbo_ring;
        bus_addr_t              bnx_rx_jumbo_ring_paddr;
-       struct bge_rx_bd        *bnx_rx_return_ring;
-       bus_addr_t              bnx_rx_return_ring_paddr;
-       struct bge_status_block *bnx_status_block;
-       bus_addr_t              bnx_status_block_paddr;
        void                    *bnx_jumbo_buf;
        struct bnx_gib          bnx_info;
 };
 
-struct bnx_rxchain {
-       struct mbuf     *bnx_mbuf;
-       bus_addr_t      bnx_paddr;
-};
+struct bnx_rx_buf {
+       bus_dmamap_t            bnx_rx_dmamap;
+       struct mbuf             *bnx_rx_mbuf;
+       bus_addr_t              bnx_rx_paddr;
+       int                     bnx_rx_len;
+       int                     bnx_rx_refilled;
+} __cachealign;
+
+struct bnx_rx_std_ring {
+       struct lwkt_serialize   bnx_rx_std_serialize;
+       struct bnx_softc        *bnx_sc;
+
+       uint16_t                bnx_rx_std_stop;
+       uint16_t                bnx_rx_std;     /* current prod ring head */
+       struct bge_rx_bd        *bnx_rx_std_ring;
+
+       int                     bnx_rx_std_refill __cachealign;
+       u_int                   bnx_rx_std_running;
+       struct thread           bnx_rx_std_ithread;
+
+       struct bnx_rx_buf       bnx_rx_std_buf[BGE_STD_RX_RING_CNT];
+
+       bus_dma_tag_t           bnx_rx_mtag;    /* RX mbuf DMA tag */
+
+       bus_dma_tag_t           bnx_rx_std_ring_tag;
+       bus_dmamap_t            bnx_rx_std_ring_map;
+       bus_addr_t              bnx_rx_std_ring_paddr;
+} __cachealign;
+
+struct bnx_rx_ret_ring {
+       struct lwkt_serialize   bnx_rx_ret_serialize;
+       int                     bnx_rx_mbx;
+       uint32_t                bnx_saved_status_tag;
+       volatile uint32_t       *bnx_hw_status_tag;
+       int                     bnx_msix_mbx;
+       struct bnx_softc        *bnx_sc;
+       struct bnx_rx_std_ring  *bnx_std;
+       struct bnx_tx_ring      *bnx_txr;
+
+       /* Shadow of bnx_rx_std_ring's bnx_rx_mtag */
+       bus_dma_tag_t           bnx_rx_mtag;
+
+       volatile uint16_t       *bnx_rx_considx;
+       uint16_t                bnx_rx_saved_considx;
+       uint16_t                bnx_rx_cnt;
+       uint16_t                bnx_rx_cntmax;
+       uint16_t                bnx_rx_mask;
+       struct bge_rx_bd        *bnx_rx_ret_ring;
+       bus_dmamap_t            bnx_rx_tmpmap;
+
+       u_long                  bnx_rx_pkt;
+       bus_dma_tag_t           bnx_rx_ret_ring_tag;
+       bus_dmamap_t            bnx_rx_ret_ring_map;
+       bus_addr_t              bnx_rx_ret_ring_paddr;
+} __cachealign;
 
 /*
  * Mbuf pointers. We need these to keep track of the virtual addresses
@@ -160,65 +206,96 @@ struct bnx_rxchain {
  */
 struct bnx_chain_data {
        bus_dma_tag_t           bnx_parent_tag;
-       bus_dma_tag_t           bnx_rx_std_ring_tag;
        bus_dma_tag_t           bnx_rx_jumbo_ring_tag;
-       bus_dma_tag_t           bnx_rx_return_ring_tag;
-       bus_dma_tag_t           bnx_status_tag;
        bus_dma_tag_t           bnx_jumbo_tag;
-       bus_dma_tag_t           bnx_rx_mtag;    /* RX mbuf DMA tag */
-       bus_dmamap_t            bnx_rx_tmpmap;
-       bus_dmamap_t            bnx_rx_std_dmamap[BGE_STD_RX_RING_CNT];
-       bus_dmamap_t            bnx_rx_std_ring_map;
        bus_dmamap_t            bnx_rx_jumbo_ring_map;
-       bus_dmamap_t            bnx_rx_return_ring_map;
-       bus_dmamap_t            bnx_status_map;
        bus_dmamap_t            bnx_jumbo_map;
-       struct bnx_rxchain      bnx_rx_std_chain[BGE_STD_RX_RING_CNT];
-       struct bnx_rxchain      bnx_rx_jumbo_chain[BGE_JUMBO_RX_RING_CNT];
+       struct bnx_rx_buf       bnx_rx_jumbo_chain[BGE_JUMBO_RX_RING_CNT];
        /* Stick the jumbo mem management stuff here too. */
        struct bnx_jslot        bnx_jslots[BNX_JSLOTS];
 };
 
+struct bnx_tx_buf {
+       bus_dmamap_t            bnx_tx_dmamap;
+       struct mbuf             *bnx_tx_mbuf;
+};
+
 struct bnx_tx_ring {
+       struct lwkt_serialize   bnx_tx_serialize;
+       volatile uint32_t       *bnx_hw_status_tag;
+       uint32_t                bnx_saved_status_tag;
        struct bnx_softc        *bnx_sc;
+       struct ifaltq_subque    *bnx_ifsq;
+       volatile uint16_t       *bnx_tx_considx;
        uint16_t                bnx_tx_flags;
 #define BNX_TX_FLAG_SHORTDMA           0x0001
 #define BNX_TX_FLAG_FORCE_DEFRAG       0x0002
        uint16_t                bnx_tx_saved_considx;
-       int                     bnx_txcnt;
+       int                     bnx_tx_cnt;
        uint32_t                bnx_tx_prodidx;
        int                     bnx_tx_wreg;
        int                     bnx_tx_mbx;
+       struct ifsubq_watchdog  bnx_tx_watchdog;
 
        struct bge_tx_bd        *bnx_tx_ring;
 
        bus_dma_tag_t           bnx_tx_mtag;    /* TX mbuf DMA tag */
-       bus_dmamap_t            bnx_tx_dmamap[BGE_TX_RING_CNT];
-       struct mbuf             *bnx_tx_chain[BGE_TX_RING_CNT];
+       struct bnx_tx_buf       bnx_tx_buf[BGE_TX_RING_CNT];
 
        bus_dma_tag_t           bnx_tx_ring_tag;
        bus_dmamap_t            bnx_tx_ring_map;
        bus_addr_t              bnx_tx_ring_paddr;
+       int                     bnx_tx_cpuid;
+
+       u_long                  bnx_tx_pkt;
+} __cachealign;
+
+struct bnx_intr_data {
+       struct bnx_softc        *bnx_sc;
+       struct bnx_rx_ret_ring  *bnx_ret;
+       struct bnx_tx_ring      *bnx_txr;
+
+       int                     bnx_intr_cpuid;
+       struct lwkt_serialize   *bnx_intr_serialize;
+       struct callout          bnx_intr_timer;
+       void                    (*bnx_intr_check)(void *);
+       uint16_t                bnx_rx_check_considx;
+       uint16_t                bnx_tx_check_considx;
+       boolean_t               bnx_intr_maylose;
+
+       void                    *bnx_intr_arg;
+       driver_intr_t           *bnx_intr_func;
+       void                    *bnx_intr_hand;
+       struct resource         *bnx_intr_res;
+       int                     bnx_intr_rid;
+       int                     bnx_intr_mbx;
+       const uint32_t          *bnx_saved_status_tag;
+
+       const char              *bnx_intr_desc;
+       char                    bnx_intr_desc0[64];
+
+       bus_dma_tag_t           bnx_status_tag;
+       bus_dmamap_t            bnx_status_map;
+       struct bge_status_block *bnx_status_block;
+       bus_addr_t              bnx_status_block_paddr;
 } __cachealign;
 
+#define BNX_RX_RING_MAX                4
+#define BNX_TX_RING_MAX                4
+#define BNX_INTR_MAX           5
+
 struct bnx_softc {
        struct arpcom           arpcom;         /* interface info */
        device_t                bnx_dev;
        device_t                bnx_miibus;
        bus_space_handle_t      bnx_bhandle;
        bus_space_tag_t         bnx_btag;
-       void                    *bnx_intrhand;
-       struct resource         *bnx_irq;
-       int                     bnx_irq_type;
-       int                     bnx_irq_rid;
        struct resource         *bnx_res;
        struct ifmedia          bnx_ifmedia;    /* TBI media info */
        int                     bnx_pciecap;
-       uint32_t                bnx_status_tag;
        uint32_t                bnx_flags;      /* BNX_FLAG_ */
 #define BNX_FLAG_TBI           0x00000001
 #define BNX_FLAG_JUMBO         0x00000002
-#define BNX_FLAG_ONESHOT_MSI   0x00000004
 #define BNX_FLAG_5717_PLUS     0x00000008
 #define BNX_FLAG_MII_SERDES    0x00000010
 #define BNX_FLAG_CPMU          0x00000020
@@ -227,16 +304,33 @@ struct bnx_softc {
 #define BNX_FLAG_STATUSTAG_BUG 0x00000100
 #define BNX_FLAG_TSO           0x00000200
 #define BNX_FLAG_NO_EEPROM     0x10000000
+#define BNX_FLAG_RXTX_BUNDLE   0x20000000
+#define BNX_FLAG_STD_THREAD    0x40000000
+#define BNX_FLAG_STATUS_HASTAG 0x80000000
 
        uint32_t                bnx_chipid;
        uint32_t                bnx_asicrev;
        uint32_t                bnx_chiprev;
        struct bnx_ring_data    bnx_ldata;      /* rings */
        struct bnx_chain_data   bnx_cdata;      /* mbufs */
+
+       struct lwkt_serialize   bnx_main_serialize;
+       volatile uint32_t       *bnx_hw_status;
+       volatile uint32_t       *bnx_hw_status_tag;
+       uint32_t                bnx_saved_status_tag;
+       int                     bnx_link_evt;
+       u_long                  bnx_errors;
+       u_long                  bnx_norxbds;
+
+       int                     bnx_serialize_cnt;
+       struct lwkt_serialize   **bnx_serialize;
+
        int                     bnx_tx_ringcnt;
        struct bnx_tx_ring      *bnx_tx_ring;
-       uint16_t                bnx_rx_saved_considx;
-       uint16_t                bnx_std;        /* current std ring head */
+       int                     bnx_rx_retcnt;
+       struct bnx_rx_ret_ring  *bnx_rx_ret_ring;
+       struct bnx_rx_std_ring  bnx_rx_std_ring;
+
        uint16_t                bnx_jumbo;      /* current jumo ring head */
        SLIST_HEAD(__bnx_jfreehead, bnx_jslot)  bnx_jfree_listhead;
        struct lwkt_serialize   bnx_jslot_serializer;
@@ -249,16 +343,17 @@ struct bnx_softc {
        uint32_t                bnx_mi_mode;
        int                     bnx_if_flags;
        int                     bnx_link;
-       int                     bnx_link_evt;
-       int                     bnx_stat_cpuid;
-       struct callout          bnx_stat_timer;
-       struct ifpoll_compat    bnx_npoll;
+       int                     bnx_tick_cpuid;
+       struct callout          bnx_tick_timer;
 
-       uint16_t                bnx_rx_check_considx;
-       uint16_t                bnx_tx_check_considx;
-       boolean_t               bnx_intr_maylose;
-       int                     bnx_intr_cpuid;
-       struct callout          bnx_intr_timer;
+       int                     bnx_npoll_rxoff;
+       int                     bnx_npoll_txoff;
+
+       int                     bnx_msix_mem_rid;
+       struct resource         *bnx_msix_mem_res;
+       int                     bnx_intr_type;
+       int                     bnx_intr_cnt;
+       struct bnx_intr_data    bnx_intr_data[BNX_INTR_MAX];
 
        struct sysctl_ctx_list  bnx_sysctl_ctx;
        struct sysctl_oid       *bnx_sysctl_tree;
@@ -275,6 +370,7 @@ struct bnx_softc {
        void                    (*bnx_link_upd)(struct bnx_softc *, uint32_t);
        uint32_t                bnx_link_chg;
 
+       int                     bnx_rss_debug;
 #define BNX_TSO_NSTATS         45
        u_long                  bnx_tsosegs[BNX_TSO_NSTATS];
 };
@@ -311,4 +407,8 @@ struct bnx_softc {
 /* Return ring descriptor count */
 #define BNX_RETURN_RING_CNT    512
 
+#define BNX_TX_RING_MAX                4
+
+#define BNX_RSS_ENABLED(sc)    ((sc)->bnx_rx_retcnt > 1)
+
 #endif /* !_IF_BNXVAR_H_ */