#ifndef _IF_IGB_H_
#define _IF_IGB_H_
#define IGB_MAX_RING_I210 4
#define IGB_MAX_RING_I211 2
#define IGB_MAX_RING_I350 8
#define IGB_MAX_RING_I354 8
#define IGB_MAX_RING_82580 8
#define IGB_MAX_RING_82576 16
#define IGB_MAX_RING_82575 4
#define IGB_MIN_RING 1
#define IGB_MIN_RING_RSS 2
#define IGB_MAX_TXRXINT_I210 4
#define IGB_MAX_TXRXINT_I211 4
#define IGB_MAX_TXRXINT_I350 8
#define IGB_MAX_TXRXINT_I354 8
#define IGB_MAX_TXRXINT_82580 8
#define IGB_MAX_TXRXINT_82576 16
#define IGB_MAX_TXRXINT_82575 4
#define IGB_MIN_TXRXINT 2
#define IGB_MAX_IVAR_I210 4
#define IGB_MAX_IVAR_I211 4
#define IGB_MAX_IVAR_I350 4
#define IGB_MAX_IVAR_I354 4
#define IGB_MAX_IVAR_82580 4
#define IGB_MAX_IVAR_82576 8
#define IGB_MAX_IVAR_VF 1
#define IGB_DEF_RXWREG_NSEGS 32
#define IGB_DEF_TXWREG_NSEGS 8
#define IGB_MIN_TXD 256
#define IGB_DEFAULT_TXD 1024
#define IGB_MAX_TXD 4096
#define IGB_MIN_RXD 256
#define IGB_DEFAULT_RXD 512
#define IGB_MAX_RXD 4096
#define IGB_TX_CLEANUP_THRESHOLD(sc) ((sc)->num_tx_desc / 2)
#define DO_AUTO_NEG 1
#define WAIT_FOR_AUTO_NEG_DEFAULT 0
#define AUTONEG_ADV_DEFAULT (ADVERTISE_10_HALF | ADVERTISE_10_FULL | \
ADVERTISE_100_HALF | ADVERTISE_100_FULL | \
ADVERTISE_1000_FULL)
#define AUTO_ALL_MODES 0
#define IGB_MASTER_SLAVE e1000_ms_hw_default
#define IGB_VENDOR_ID 0x8086
#define IGB_JUMBO_PBA 0x00000028
#define IGB_DEFAULT_PBA 0x00000030
#define IGB_SMARTSPEED_DOWNSHIFT 3
#define IGB_SMARTSPEED_MAX 15
#define IGB_MAX_LOOP 10
#define IGB_RX_PTHRESH ((hw->mac.type == e1000_i354) ? 12 : \
((hw->mac.type <= e1000_82576) ? 16 : 8))
#define IGB_RX_HTHRESH 8
#define IGB_RX_WTHRESH ((hw->mac.type == e1000_82576 && \
sc->msix_mem_res) ? 1 : 4)
#define IGB_TX_PTHRESH ((hw->mac.type == e1000_i354) ? 20 : 8)
#define IGB_TX_HTHRESH 1
#define IGB_TX_WTHRESH 16
#define MAX_NUM_MULTICAST_ADDRESSES 128
#define IGB_FC_PAUSE_TIME 0x0680
#define IGB_INTR_RATE 6000
#define IGB_MSIX_RX_RATE 6000
#define IGB_MSIX_TX_RATE 4000
#define IGB_DBA_ALIGN 128
#define IGB_MSIX_BAR 3
#define IGB_MSIX_BAR_ALT 4
#define IGB_VFTA_SIZE 128
#define IGB_TSO_SIZE (IP_MAXPACKET + \
sizeof(struct ether_vlan_header))
#define IGB_HDR_BUF 128
#define IGB_TXPBSIZE 20408
#define IGB_PKTTYPE_MASK 0x0000FFF0
#define IGB_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP)
#define IGB_TX_RESERVED 3
#define IGB_MAX_SCATTER 33
#define IGB_NRSSRK 10
#define IGB_RSSRK_SIZE 4
#define IGB_RSSRK_VAL(key, i) (key[(i) * IGB_RSSRK_SIZE] | \
key[(i) * IGB_RSSRK_SIZE + 1] << 8 | \
key[(i) * IGB_RSSRK_SIZE + 2] << 16 | \
key[(i) * IGB_RSSRK_SIZE + 3] << 24)
#define IGB_NRETA 32
#define IGB_RETA_SIZE 4
#define IGB_RETA_SHIFT 0
#define IGB_RETA_SHIFT_82575 6
#define IGB_RDRTABLE_SIZE (IGB_NRETA * IGB_RETA_SIZE)
#define IGB_EITR_INTVL_MASK 0x7ffc
#define IGB_EITR_INTVL_SHIFT 2
#define IGB_DMCTLX_DCFLUSH_DIS 0x80000000
struct igb_softc;
struct igb_dma {
bus_addr_t dma_paddr;
void *dma_vaddr;
bus_dma_tag_t dma_tag;
bus_dmamap_t dma_map;
};
struct igb_tx_ring {
struct lwkt_serialize tx_serialize;
struct igb_softc *sc;
struct ifaltq_subque *ifsq;
uint32_t me;
int16_t tx_running;
#define IGB_TX_RUNNING 100
#define IGB_TX_RUNNING_DEC 25
uint16_t tx_flags;
#define IGB_TXFLAG_TSO_IPLEN0 0x1
#define IGB_TXFLAG_ENABLED 0x2
struct e1000_tx_desc *tx_base;
int num_tx_desc;
uint32_t next_avail_desc;
uint32_t next_to_clean;
int tx_avail;
int tx_nmbuf;
uint32_t *tx_hdr;
struct igb_tx_buf *tx_buf;
bus_dma_tag_t tx_tag;
int tx_nsegs;
int intr_nsegs;
int wreg_nsegs;
int tx_intr_vec;
uint32_t tx_intr_mask;
struct ifsubq_watchdog tx_watchdog;
struct callout tx_gc_timer;
u_long tx_packets;
u_long tx_gc;
struct igb_dma txdma;
bus_dma_tag_t tx_hdr_dtag;
bus_dmamap_t tx_hdr_dmap;
bus_addr_t tx_hdr_paddr;
int tx_intr_cpuid;
} __cachealign;
struct igb_rx_ring {
struct lwkt_serialize rx_serialize;
struct igb_softc *sc;
uint32_t me;
union e1000_adv_rx_desc *rx_base;
boolean_t discard;
int num_rx_desc;
uint32_t next_to_check;
struct igb_rx_buf *rx_buf;
bus_dma_tag_t rx_tag;
bus_dmamap_t rx_sparemap;
int rx_intr_vec;
uint32_t rx_intr_mask;
struct mbuf *fmp;
struct mbuf *lmp;
int wreg_nsegs;
struct igb_tx_ring *rx_txr;
u_long rx_packets;
struct igb_dma rxdma;
} __cachealign;
struct igb_intr_data {
struct lwkt_serialize *intr_serialize;
driver_intr_t *intr_func;
void *intr_hand;
struct resource *intr_res;
void *intr_funcarg;
int intr_rid;
int intr_cpuid;
int intr_rate;
int intr_use;
#define IGB_INTR_USE_RXTX 0
#define IGB_INTR_USE_STATUS 1
#define IGB_INTR_USE_RX 2
#define IGB_INTR_USE_TX 3
const char *intr_desc;
char intr_desc0[64];
};
struct igb_softc {
struct arpcom arpcom;
struct e1000_hw hw;
struct e1000_osdep osdep;
device_t dev;
uint32_t flags;
#define IGB_FLAG_SHARED_INTR 0x1
#define IGB_FLAG_HAS_MGMT 0x2
bus_dma_tag_t parent_tag;
int mem_rid;
struct resource *mem_res;
struct ifmedia media;
struct callout timer;
int timer_cpuid;
int if_flags;
int max_frame_size;
int pause_frames;
uint16_t vf_ifp;
int wol;
uint8_t link_active;
uint16_t link_speed;
uint16_t link_duplex;
uint32_t smartspeed;
uint32_t dma_coalesce;
uint8_t *mta;
int serialize_cnt;
struct lwkt_serialize **serializes;
struct lwkt_serialize main_serialize;
int intr_type;
uint32_t intr_mask;
int sts_msix_vec;
uint32_t sts_intr_mask;
int tx_ring_cnt;
int tx_ring_msix;
int tx_ring_inuse;
struct igb_tx_ring *tx_rings;
int rss_debug;
int rx_ring_cnt;
int rx_ring_msix;
int rx_ring_inuse;
struct igb_rx_ring *rx_rings;
int ifm_flowctrl;
u_long dropped_pkts;
u_long mbuf_defrag_failed;
u_long no_tx_dma_setup;
u_long watchdog_events;
u_long rx_overruns;
u_long device_control;
u_long rx_control;
u_long int_mask;
u_long eint_mask;
u_long packet_buf_alloc_rx;
u_long packet_buf_alloc_tx;
void *stats;
int msix_mem_rid;
struct resource *msix_mem_res;
int intr_cnt;
struct igb_intr_data *intr_data;
struct if_ringmap *rx_rmap;
struct if_ringmap *rx_rmap_intr;
struct if_ringmap *tx_rmap;
struct if_ringmap *tx_rmap_intr;
int rdr_table[IGB_RDRTABLE_SIZE];
};
#define IGB_ENABLE_HWRSS(sc) ((sc)->rx_ring_cnt > 1)
#define IGB_ENABLE_HWTSS(sc) ((sc)->tx_ring_cnt > 1)
struct igb_tx_buf {
struct mbuf *m_head;
bus_dmamap_t map;
};
struct igb_rx_buf {
struct mbuf *m_head;
bus_dmamap_t map;
bus_addr_t paddr;
};
#define UPDATE_VF_REG(reg, last, cur) \
{ \
uint32_t new = E1000_READ_REG(hw, reg); \
if (new < last) \
cur += 0x100000000LL; \
last = new; \
cur &= 0xFFFFFFFF00000000LL; \
cur |= new; \
}
#define IGB_I210_LINK_DELAY 1000
#endif