Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ixl/ixl.h
Show All 33 Lines | |||||
#ifndef _IXL_H_ | #ifndef _IXL_H_ | ||||
#define _IXL_H_ | #define _IXL_H_ | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/buf_ring.h> | |||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
#include <sys/protosw.h> | #include <sys/protosw.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/sockio.h> | #include <sys/sockio.h> | ||||
#include <sys/eventhandler.h> | #include <sys/eventhandler.h> | ||||
#include <net/if.h> | #include <net/if.h> | ||||
#include <net/if_var.h> | #include <net/if_var.h> | ||||
#include <net/if_arp.h> | #include <net/if_arp.h> | ||||
#include <net/bpf.h> | #include <net/bpf.h> | ||||
#include <net/ethernet.h> | #include <net/ethernet.h> | ||||
#include <net/if_dl.h> | #include <net/if_dl.h> | ||||
#include <net/if_media.h> | #include <net/if_media.h> | ||||
#include <net/bpf.h> | #include <net/bpf.h> | ||||
#include <net/if_types.h> | #include <net/if_types.h> | ||||
#include <net/if_vlan_var.h> | #include <net/if_vlan_var.h> | ||||
#include <net/iflib.h> | |||||
#include <netinet/in_systm.h> | #include <netinet/in_systm.h> | ||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <netinet/if_ether.h> | #include <netinet/if_ether.h> | ||||
#include <netinet/ip.h> | #include <netinet/ip.h> | ||||
#include <netinet/ip6.h> | #include <netinet/ip6.h> | ||||
#include <netinet/tcp.h> | #include <netinet/tcp.h> | ||||
#include <netinet/tcp_lro.h> | #include <netinet/tcp_lro.h> | ||||
Show All 9 Lines | |||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/pmap.h> | #include <vm/pmap.h> | ||||
#include <machine/clock.h> | #include <machine/clock.h> | ||||
#include <dev/pci/pcivar.h> | #include <dev/pci/pcivar.h> | ||||
#include <dev/pci/pcireg.h> | #include <dev/pci/pcireg.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/endian.h> | #include <sys/endian.h> | ||||
#include <sys/taskqueue.h> | |||||
#include <sys/pcpu.h> | #include <sys/pcpu.h> | ||||
#include <sys/smp.h> | #include <sys/smp.h> | ||||
#include <machine/smp.h> | #include <machine/smp.h> | ||||
#ifdef PCI_IOV | #ifdef PCI_IOV | ||||
#include <sys/nv.h> | #include <sys/nv.h> | ||||
#include <sys/iov_schema.h> | #include <sys/iov_schema.h> | ||||
#include <dev/pci/pci_iov.h> | #include <dev/pci/pci_iov.h> | ||||
#endif | #endif | ||||
#include "ifdi_if.h" | |||||
#include "i40e_type.h" | #include "i40e_type.h" | ||||
#include "i40e_prototype.h" | #include "i40e_prototype.h" | ||||
MALLOC_DECLARE(M_IXL); | |||||
#if defined(IXL_DEBUG) || defined(IXL_DEBUG_SYSCTL) | #if defined(IXL_DEBUG) || defined(IXL_DEBUG_SYSCTL) | ||||
#include <sys/sbuf.h> | #include <sys/sbuf.h> | ||||
#define MAC_FORMAT "%02x:%02x:%02x:%02x:%02x:%02x" | #define MAC_FORMAT "%02x:%02x:%02x:%02x:%02x:%02x" | ||||
#define MAC_FORMAT_ARGS(mac_addr) \ | #define MAC_FORMAT_ARGS(mac_addr) \ | ||||
(mac_addr)[0], (mac_addr)[1], (mac_addr)[2], (mac_addr)[3], \ | (mac_addr)[0], (mac_addr)[1], (mac_addr)[2], (mac_addr)[3], \ | ||||
(mac_addr)[4], (mac_addr)[5] | (mac_addr)[4], (mac_addr)[5] | ||||
#define ON_OFF_STR(is_set) ((is_set) ? "On" : "Off") | #define ON_OFF_STR(is_set) ((is_set) ? "On" : "Off") | ||||
#endif /* IXL_DEBUG || IXL_DEBUG_SYSCTL */ | #endif /* IXL_DEBUG || IXL_DEBUG_SYSCTL */ | ||||
#ifdef IXL_DEBUG | #ifdef IXL_DEBUG | ||||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | |||||
#define IXL_GLGEN_VFLRSTAT_INDEX(glb_vf) ((glb_vf) / 32) | #define IXL_GLGEN_VFLRSTAT_INDEX(glb_vf) ((glb_vf) / 32) | ||||
#define IXL_GLGEN_VFLRSTAT_MASK(glb_vf) (1 << ((glb_vf) % 32)) | #define IXL_GLGEN_VFLRSTAT_MASK(glb_vf) (1 << ((glb_vf) % 32)) | ||||
#define IXL_MAX_ITR_IDX 3 | #define IXL_MAX_ITR_IDX 3 | ||||
#define IXL_END_OF_INTR_LNKLST 0x7FF | #define IXL_END_OF_INTR_LNKLST 0x7FF | ||||
#define IXL_TX_LOCK(_sc) mtx_lock(&(_sc)->mtx) | |||||
#define IXL_TX_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx) | |||||
#define IXL_TX_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->mtx) | |||||
#define IXL_TX_TRYLOCK(_sc) mtx_trylock(&(_sc)->mtx) | |||||
#define IXL_TX_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->mtx, MA_OWNED) | |||||
#define IXL_RX_LOCK(_sc) mtx_lock(&(_sc)->mtx) | |||||
#define IXL_RX_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx) | |||||
#define IXL_RX_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->mtx) | |||||
#if __FreeBSD_version >= 1100036 | #if __FreeBSD_version >= 1100036 | ||||
#define IXL_SET_IPACKETS(vsi, count) (vsi)->ipackets = (count) | #define IXL_SET_IPACKETS(vsi, count) (vsi)->ipackets = (count) | ||||
#define IXL_SET_IERRORS(vsi, count) (vsi)->ierrors = (count) | #define IXL_SET_IERRORS(vsi, count) (vsi)->ierrors = (count) | ||||
#define IXL_SET_OPACKETS(vsi, count) (vsi)->opackets = (count) | #define IXL_SET_OPACKETS(vsi, count) (vsi)->opackets = (count) | ||||
#define IXL_SET_OERRORS(vsi, count) (vsi)->oerrors = (count) | #define IXL_SET_OERRORS(vsi, count) (vsi)->oerrors = (count) | ||||
#define IXL_SET_COLLISIONS(vsi, count) /* Do nothing; collisions is always 0. */ | #define IXL_SET_COLLISIONS(vsi, count) /* Do nothing; collisions is always 0. */ | ||||
#define IXL_SET_IBYTES(vsi, count) (vsi)->ibytes = (count) | #define IXL_SET_IBYTES(vsi, count) (vsi)->ibytes = (count) | ||||
#define IXL_SET_OBYTES(vsi, count) (vsi)->obytes = (count) | #define IXL_SET_OBYTES(vsi, count) (vsi)->obytes = (count) | ||||
Show All 32 Lines | typedef struct _ixl_vendor_info_t { | ||||
unsigned int subvendor_id; | unsigned int subvendor_id; | ||||
unsigned int subdevice_id; | unsigned int subdevice_id; | ||||
unsigned int index; | unsigned int index; | ||||
} ixl_vendor_info_t; | } ixl_vendor_info_t; | ||||
struct ixl_tx_buf { | struct ixl_tx_buf { | ||||
u32 eop_index; | u32 eop_index; | ||||
struct mbuf *m_head; | |||||
bus_dmamap_t map; | |||||
bus_dma_tag_t tag; | |||||
}; | }; | ||||
struct ixl_rx_buf { | |||||
struct mbuf *m_head; | |||||
struct mbuf *m_pack; | |||||
struct mbuf *fmp; | |||||
bus_dmamap_t hmap; | |||||
bus_dmamap_t pmap; | |||||
}; | |||||
/* | /* | ||||
** This struct has multiple uses, multicast | ** This struct has multiple uses, multicast | ||||
** addresses, vlans, and mac filters all use it. | ** addresses, vlans, and mac filters all use it. | ||||
*/ | */ | ||||
struct ixl_mac_filter { | struct ixl_mac_filter { | ||||
SLIST_ENTRY(ixl_mac_filter) next; | SLIST_ENTRY(ixl_mac_filter) next; | ||||
u8 macaddr[ETHER_ADDR_LEN]; | u8 macaddr[ETHER_ADDR_LEN]; | ||||
s16 vlan; | s16 vlan; | ||||
u16 flags; | u16 flags; | ||||
}; | }; | ||||
/* | /* | ||||
* The Transmit ring control struct | * The Transmit ring control struct | ||||
*/ | */ | ||||
struct tx_ring { | struct tx_ring { | ||||
struct ixl_queue *que; | struct ixl_queue *que; | ||||
struct mtx mtx; | |||||
u32 tail; | u32 tail; | ||||
struct i40e_tx_desc *base; | struct i40e_tx_desc *tx_base; | ||||
struct i40e_dma_mem dma; | uint64_t tx_paddr; | ||||
u16 next_avail; | u16 next_avail; | ||||
u16 next_to_clean; | u16 next_to_clean; | ||||
u16 atr_rate; | u16 atr_rate; | ||||
u16 atr_count; | u16 atr_count; | ||||
u16 itr; | u16 itr; | ||||
u16 latency; | u16 latency; | ||||
struct ixl_tx_buf *buffers; | struct ixl_tx_buf *tx_buffers; | ||||
volatile u16 avail; | volatile u16 avail; | ||||
u32 cmd; | u32 cmd; | ||||
bus_dma_tag_t tx_tag; | bus_dma_tag_t tx_tag; | ||||
bus_dma_tag_t tso_tag; | bus_dma_tag_t tso_tag; | ||||
char mtx_name[16]; | |||||
struct buf_ring *br; | |||||
/* Used for Dynamic ITR calculation */ | /* Used for Dynamic ITR calculation */ | ||||
u32 packets; | u32 packets; | ||||
u32 bytes; | u32 bytes; | ||||
/* Soft Stats */ | /* Soft Stats */ | ||||
u64 tx_bytes; | u64 tx_bytes; | ||||
u64 no_desc; | u64 no_desc; | ||||
u64 total_packets; | u64 total_packets; | ||||
}; | }; | ||||
/* | /* | ||||
* The Receive ring control struct | * The Receive ring control struct | ||||
*/ | */ | ||||
struct rx_ring { | struct rx_ring { | ||||
struct ixl_queue *que; | struct ixl_queue *que; | ||||
struct mtx mtx; | union i40e_rx_desc *rx_base; | ||||
union i40e_rx_desc *base; | uint64_t rx_paddr; | ||||
struct i40e_dma_mem dma; | |||||
struct lro_ctrl lro; | |||||
bool lro_enabled; | |||||
bool hdr_split; | |||||
bool discard; | bool discard; | ||||
u16 next_refresh; | |||||
u16 next_check; | |||||
u16 itr; | u16 itr; | ||||
u16 latency; | u16 latency; | ||||
char mtx_name[16]; | |||||
struct ixl_rx_buf *buffers; | |||||
u32 mbuf_sz; | u32 mbuf_sz; | ||||
u32 tail; | u32 tail; | ||||
bus_dma_tag_t htag; | bus_dma_tag_t htag; | ||||
bus_dma_tag_t ptag; | bus_dma_tag_t ptag; | ||||
/* Used for Dynamic ITR calculation */ | /* Used for Dynamic ITR calculation */ | ||||
u32 packets; | u32 packets; | ||||
u32 bytes; | u32 bytes; | ||||
Show All 12 Lines | |||||
*/ | */ | ||||
struct ixl_queue { | struct ixl_queue { | ||||
struct ixl_vsi *vsi; | struct ixl_vsi *vsi; | ||||
u32 me; | u32 me; | ||||
u32 msix; /* This queue's MSIX vector */ | u32 msix; /* This queue's MSIX vector */ | ||||
u32 eims; /* This queue's EIMS bit */ | u32 eims; /* This queue's EIMS bit */ | ||||
struct resource *res; | struct resource *res; | ||||
void *tag; | void *tag; | ||||
int num_desc; /* both tx and rx */ | |||||
int busy; | int busy; | ||||
struct tx_ring txr; | struct tx_ring txr; | ||||
struct rx_ring rxr; | struct rx_ring rxr; | ||||
struct task task; | |||||
struct task tx_task; | |||||
struct taskqueue *tq; | |||||
struct if_irq que_irq; | |||||
/* Queue stats */ | /* Queue stats */ | ||||
u64 irqs; | u64 irqs; | ||||
u64 tso; | u64 tso; | ||||
u64 mbuf_defrag_failed; | u64 mbuf_defrag_failed; | ||||
u64 mbuf_hdr_failed; | u64 mbuf_hdr_failed; | ||||
u64 mbuf_pkt_failed; | u64 mbuf_pkt_failed; | ||||
u64 tx_map_avail; | u64 tx_map_avail; | ||||
u64 tx_dma_setup; | u64 tx_dma_setup; | ||||
u64 dropped_pkts; | u64 dropped_pkts; | ||||
}; | }; | ||||
#define DOWNCAST(sctx) ((struct ixl_vsi *)(sctx)) | |||||
/* | /* | ||||
** Virtual Station interface: | ** Virtual Station interface: | ||||
** there would be one of these per traffic class/type | ** there would be one of these per traffic class/type | ||||
** for now just one, and its embedded in the pf | ** for now just one, and its embedded in the pf | ||||
*/ | */ | ||||
SLIST_HEAD(ixl_ftl_head, ixl_mac_filter); | SLIST_HEAD(ixl_ftl_head, ixl_mac_filter); | ||||
struct ixl_vsi { | struct ixl_vsi { | ||||
void *back; | if_ctx_t ctx; | ||||
if_softc_ctx_t shared; | |||||
struct ifnet *ifp; | struct ifnet *ifp; | ||||
struct device *dev; | struct ifmedia *media; | ||||
#define num_queues shared->isc_nqsets | |||||
#define max_frame_size shared->isc_max_frame_size | |||||
void *back; | |||||
struct i40e_hw *hw; | struct i40e_hw *hw; | ||||
struct ifmedia media; | |||||
u64 que_mask; | u64 que_mask; | ||||
int id; | int id; | ||||
u16 vsi_num; | u16 vsi_num; | ||||
u16 msix_base; /* station base MSIX vector */ | u16 msix_base; /* station base MSIX vector */ | ||||
u16 first_queue; | u16 first_queue; | ||||
u16 num_queues; | |||||
u16 rx_itr_setting; | u16 rx_itr_setting; | ||||
u16 tx_itr_setting; | u16 tx_itr_setting; | ||||
struct ixl_queue *queues; /* head of queues */ | struct ixl_queue *queues; /* head of queues */ | ||||
bool link_active; | bool link_active; | ||||
u16 seid; | u16 seid; | ||||
u32 link_speed; | |||||
struct if_irq irq; | |||||
u16 uplink_seid; | u16 uplink_seid; | ||||
u16 downlink_seid; | u16 downlink_seid; | ||||
u16 max_frame_size; | |||||
/* MAC/VLAN Filter list */ | /* MAC/VLAN Filter list */ | ||||
struct ixl_ftl_head ftl; | struct ixl_ftl_head ftl; | ||||
u16 num_macs; | u16 num_macs; | ||||
struct i40e_aqc_vsi_properties_data info; | struct i40e_aqc_vsi_properties_data info; | ||||
eventhandler_tag vlan_attach; | |||||
eventhandler_tag vlan_detach; | |||||
u16 num_vlans; | u16 num_vlans; | ||||
/* Per-VSI stats from hardware */ | /* Per-VSI stats from hardware */ | ||||
struct i40e_eth_stats eth_stats; | struct i40e_eth_stats eth_stats; | ||||
struct i40e_eth_stats eth_stats_offsets; | struct i40e_eth_stats eth_stats_offsets; | ||||
bool stat_offsets_loaded; | bool stat_offsets_loaded; | ||||
/* VSI stat counters */ | /* VSI stat counters */ | ||||
u64 ipackets; | u64 ipackets; | ||||
Show All 14 Lines | #define max_frame_size shared->isc_max_frame_size | ||||
/* Misc. */ | /* Misc. */ | ||||
u64 active_queues; | u64 active_queues; | ||||
u64 flags; | u64 flags; | ||||
struct sysctl_oid *vsi_node; | struct sysctl_oid *vsi_node; | ||||
}; | }; | ||||
/* | /* | ||||
** Find the number of unrefreshed RX descriptors | |||||
*/ | |||||
static inline u16 | |||||
ixl_rx_unrefreshed(struct ixl_queue *que) | |||||
{ | |||||
struct rx_ring *rxr = &que->rxr; | |||||
if (rxr->next_check > rxr->next_refresh) | |||||
return (rxr->next_check - rxr->next_refresh - 1); | |||||
else | |||||
return ((que->num_desc + rxr->next_check) - | |||||
rxr->next_refresh - 1); | |||||
} | |||||
/* | |||||
** Find the next available unused filter | ** Find the next available unused filter | ||||
*/ | */ | ||||
static inline struct ixl_mac_filter * | static inline struct ixl_mac_filter * | ||||
ixl_get_filter(struct ixl_vsi *vsi) | ixl_get_filter(struct ixl_vsi *vsi) | ||||
{ | { | ||||
struct ixl_mac_filter *f; | struct ixl_mac_filter *f; | ||||
/* create a new empty filter */ | /* create a new empty filter */ | ||||
f = malloc(sizeof(struct ixl_mac_filter), | f = malloc(sizeof(struct ixl_mac_filter), | ||||
M_DEVBUF, M_NOWAIT | M_ZERO); | M_IXL, M_NOWAIT | M_ZERO); | ||||
if (f) | if (f) | ||||
SLIST_INSERT_HEAD(&vsi->ftl, f, next); | SLIST_INSERT_HEAD(&vsi->ftl, f, next); | ||||
return (f); | return (f); | ||||
} | } | ||||
/* | /* | ||||
** Compare two ethernet addresses | ** Compare two ethernet addresses | ||||
*/ | */ | ||||
static inline bool | static inline bool | ||||
cmp_etheraddr(const u8 *ea1, const u8 *ea2) | cmp_etheraddr(const u8 *ea1, const u8 *ea2) | ||||
{ | { | ||||
bool cmp = FALSE; | |||||
if ((ea1[0] == ea2[0]) && (ea1[1] == ea2[1]) && | return (bcmp(ea1, ea2, 6) == 0); | ||||
(ea1[2] == ea2[2]) && (ea1[3] == ea2[3]) && | |||||
(ea1[4] == ea2[4]) && (ea1[5] == ea2[5])) | |||||
cmp = TRUE; | |||||
return (cmp); | |||||
} | } | ||||
/* | /* | ||||
* Info for stats sysctls | * Info for stats sysctls | ||||
*/ | */ | ||||
struct ixl_sysctl_info { | struct ixl_sysctl_info { | ||||
u64 *stat; | u64 *stat; | ||||
char *name; | char *name; | ||||
Show All 20 Lines | snprintf(buf, sizeof(buf), | ||||
IXL_NVM_VERSION_LO_SHIFT, | IXL_NVM_VERSION_LO_SHIFT, | ||||
hw->nvm.eetrack); | hw->nvm.eetrack); | ||||
return buf; | return buf; | ||||
} | } | ||||
/********************************************************************* | /********************************************************************* | ||||
* TXRX Function prototypes | * TXRX Function prototypes | ||||
*********************************************************************/ | *********************************************************************/ | ||||
int ixl_allocate_tx_data(struct ixl_queue *); | |||||
int ixl_allocate_rx_data(struct ixl_queue *); | |||||
void ixl_init_tx_ring(struct ixl_queue *); | void ixl_init_tx_ring(struct ixl_queue *); | ||||
int ixl_init_rx_ring(struct ixl_queue *); | |||||
bool ixl_rxeof(struct ixl_queue *, int); | |||||
bool ixl_txeof(struct ixl_queue *); | |||||
int ixl_mq_start(struct ifnet *, struct mbuf *); | |||||
int ixl_mq_start_locked(struct ifnet *, struct tx_ring *); | |||||
void ixl_deferred_mq_start(void *, int); | |||||
void ixl_qflush(struct ifnet *); | |||||
void ixl_free_vsi(struct ixl_vsi *); | |||||
void ixl_free_que_tx(struct ixl_queue *); | |||||
void ixl_free_que_rx(struct ixl_queue *); | |||||
#ifdef IXL_FDIR | #ifdef IXL_FDIR | ||||
void ixl_atr(struct ixl_queue *, struct tcphdr *, int); | void ixl_atr(struct ixl_queue *, struct tcphdr *, int); | ||||
#endif | #endif | ||||
#if __FreeBSD_version >= 1100000 | #if __FreeBSD_version >= 1100000 | ||||
uint64_t ixl_get_counter(if_t ifp, ift_counter cnt); | uint64_t ixl_get_counter(if_t ifp, ift_counter cnt); | ||||
#endif | #endif | ||||
/********************************************************************* | |||||
* common Function prototypes | |||||
*********************************************************************/ | |||||
int ixl_if_media_change(if_ctx_t); | |||||
int ixl_if_queues_alloc(if_ctx_t, caddr_t *, uint64_t *, int); | |||||
void ixl_if_queues_free(if_ctx_t ctx); | |||||
#endif /* _IXL_H_ */ | #endif /* _IXL_H_ */ |