Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ixl/ixl.h
/****************************************************************************** | /****************************************************************************** | ||||
Copyright (c) 2013-2017, Intel Corporation | Copyright (c) 2013-2019, Intel Corporation | ||||
All rights reserved. | All rights reserved. | ||||
Redistribution and use in source and binary forms, with or without | Redistribution and use in source and binary forms, with or without | ||||
modification, are permitted provided that the following conditions are met: | modification, are permitted provided that the following conditions are met: | ||||
1. Redistributions of source code must retain the above copyright notice, | 1. Redistributions of source code must retain the above copyright notice, | ||||
this list of conditions and the following disclaimer. | this list of conditions and the following disclaimer. | ||||
2. Redistributions in binary form must reproduce the above copyright | 2. Redistributions in binary form must reproduce the above copyright | ||||
notice, this list of conditions and the following disclaimer in the | notice, this list of conditions and the following disclaimer in the | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | |||||
#ifdef RSS | #ifdef RSS | ||||
#include <net/rss_config.h> | #include <net/rss_config.h> | ||||
#include <netinet/in_rss.h> | #include <netinet/in_rss.h> | ||||
#endif | #endif | ||||
#include "i40e_type.h" | #include "i40e_type.h" | ||||
#include "i40e_prototype.h" | #include "i40e_prototype.h" | ||||
#include "i40e_dcb.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") | ||||
#ifdef IXL_DEBUG | #ifdef IXL_DEBUG | ||||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | |||||
#define CSUM_OFFLOAD (CSUM_OFFLOAD_IPV4|CSUM_OFFLOAD_IPV6|CSUM_TSO) | #define CSUM_OFFLOAD (CSUM_OFFLOAD_IPV4|CSUM_OFFLOAD_IPV6|CSUM_TSO) | ||||
/* Misc flags for ixl_vsi.flags */ | /* Misc flags for ixl_vsi.flags */ | ||||
#define IXL_FLAGS_KEEP_TSO4 (1 << 0) | #define IXL_FLAGS_KEEP_TSO4 (1 << 0) | ||||
#define IXL_FLAGS_KEEP_TSO6 (1 << 1) | #define IXL_FLAGS_KEEP_TSO6 (1 << 1) | ||||
#define IXL_FLAGS_USES_MSIX (1 << 2) | #define IXL_FLAGS_USES_MSIX (1 << 2) | ||||
#define IXL_FLAGS_IS_VF (1 << 3) | #define IXL_FLAGS_IS_VF (1 << 3) | ||||
#define IXL_VSI_IS_PF(v) ((v->flags & IXL_FLAGS_IS_VF) == 0) | |||||
#define IXL_VSI_IS_VF(v) ((v->flags & IXL_FLAGS_IS_VF) != 0) | |||||
#define IXL_VF_RESET_TIMEOUT 100 | #define IXL_VF_RESET_TIMEOUT 100 | ||||
#define IXL_VSI_DATA_PORT 0x01 | #define IXL_VSI_DATA_PORT 0x01 | ||||
#define IXLV_MAX_QUEUES 16 | #define IXLV_MAX_QUEUES 16 | ||||
#define IXL_MAX_VSI_QUEUES (2 * (I40E_VSILAN_QTABLE_MAX_INDEX + 1)) | #define IXL_MAX_VSI_QUEUES (2 * (I40E_VSILAN_QTABLE_MAX_INDEX + 1)) | ||||
#define IXL_RX_CTX_BASE_UNITS 128 | #define IXL_RX_CTX_BASE_UNITS 128 | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
#define IXL_SET_OBYTES(vsi, count) (vsi)->ifp->if_obytes = (count) | #define IXL_SET_OBYTES(vsi, count) (vsi)->ifp->if_obytes = (count) | ||||
#define IXL_SET_IMCASTS(vsi, count) (vsi)->ifp->if_imcasts = (count) | #define IXL_SET_IMCASTS(vsi, count) (vsi)->ifp->if_imcasts = (count) | ||||
#define IXL_SET_OMCASTS(vsi, count) (vsi)->ifp->if_omcasts = (count) | #define IXL_SET_OMCASTS(vsi, count) (vsi)->ifp->if_omcasts = (count) | ||||
#define IXL_SET_IQDROPS(vsi, count) (vsi)->ifp->if_iqdrops = (count) | #define IXL_SET_IQDROPS(vsi, count) (vsi)->ifp->if_iqdrops = (count) | ||||
#define IXL_SET_OQDROPS(vsi, odrops) (vsi)->ifp->if_snd.ifq_drops = (odrops) | #define IXL_SET_OQDROPS(vsi, odrops) (vsi)->ifp->if_snd.ifq_drops = (odrops) | ||||
#define IXL_SET_NOPROTO(vsi, count) (vsi)->noproto = (count) | #define IXL_SET_NOPROTO(vsi, count) (vsi)->noproto = (count) | ||||
#endif | #endif | ||||
/* For stats sysctl naming */ | |||||
#define IXL_QUEUE_NAME_LEN 32 | |||||
/* | /* | ||||
***************************************************************************** | ***************************************************************************** | ||||
* vendor_info_array | * vendor_info_array | ||||
* | * | ||||
* This array contains the list of Subvendor/Subdevice IDs on which the driver | * This array contains the list of Subvendor/Subdevice IDs on which the driver | ||||
* should load. | * should load. | ||||
* | * | ||||
***************************************************************************** | ***************************************************************************** | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | struct tx_ring { | ||||
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]; | char mtx_name[16]; | ||||
struct buf_ring *br; | struct buf_ring *br; | ||||
s32 watchdog_timer; | s32 watchdog_timer; | ||||
/* 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; | struct mtx mtx; | ||||
union i40e_rx_desc *base; | union i40e_rx_desc *base; | ||||
struct i40e_dma_mem dma; | struct i40e_dma_mem dma; | ||||
struct lro_ctrl lro; | struct lro_ctrl lro; | ||||
bool lro_enabled; | bool lro_enabled; | ||||
bool hdr_split; | bool hdr_split; | ||||
bool discard; | bool discard; | ||||
u32 next_refresh; | u32 next_refresh; | ||||
u32 next_check; | u32 next_check; | ||||
u32 itr; | u32 itr; | ||||
u32 latency; | u32 latency; | ||||
char mtx_name[16]; | char mtx_name[16]; | ||||
struct ixl_rx_buf *buffers; | 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; | ||||
/* Soft stats */ | /* Soft stats */ | ||||
u64 split; | u64 split; | ||||
u64 rx_packets; | u64 rx_packets; | ||||
u64 rx_bytes; | u64 rx_bytes; | ||||
u64 desc_errs; | u64 desc_errs; | ||||
u64 not_done; | u64 not_done; | ||||
}; | }; | ||||
/* | /* | ||||
** Driver queue struct: this is the interrupt container | ** Driver queue struct: this is the interrupt container | ||||
** for the associated tx and rx ring pair. | ** for the associated tx and rx ring pair. | ||||
*/ | */ | ||||
struct ixl_queue { | struct ixl_queue { | ||||
struct ixl_vsi *vsi; | struct ixl_vsi *vsi; | ||||
Show All 21 Lines | struct ixl_queue { | ||||
u64 mss_too_small; | u64 mss_too_small; | ||||
}; | }; | ||||
/* | /* | ||||
** Virtual Station Interface | ** Virtual Station Interface | ||||
*/ | */ | ||||
SLIST_HEAD(ixl_ftl_head, ixl_mac_filter); | SLIST_HEAD(ixl_ftl_head, ixl_mac_filter); | ||||
struct ixl_vsi { | struct ixl_vsi { | ||||
void *back; | void *back; | ||||
struct ifnet *ifp; | struct ifnet *ifp; | ||||
struct device *dev; | struct device *dev; | ||||
struct i40e_hw *hw; | struct i40e_hw *hw; | ||||
struct ifmedia media; | struct ifmedia media; | ||||
enum i40e_vsi_type type; | enum i40e_vsi_type type; | ||||
int id; | int id; | ||||
u16 num_queues; | u16 num_queues; | ||||
int num_tx_desc; | int num_tx_desc; | ||||
Show All 9 Lines | struct ixl_vsi { | ||||
bool link_active; | bool link_active; | ||||
u16 seid; | u16 seid; | ||||
u16 uplink_seid; | u16 uplink_seid; | ||||
u16 downlink_seid; | u16 downlink_seid; | ||||
/* MAC/VLAN Filter list */ | /* MAC/VLAN Filter list */ | ||||
struct ixl_ftl_head ftl; | struct ixl_ftl_head ftl; | ||||
u16 num_macs; | u16 num_macs; | ||||
u64 num_hw_filters; | |||||
/* Contains readylist & stat counter id */ | /* Contains readylist & stat counter id */ | ||||
struct i40e_aqc_vsi_properties_data info; | struct i40e_aqc_vsi_properties_data info; | ||||
eventhandler_tag vlan_attach; | eventhandler_tag vlan_attach; | ||||
eventhandler_tag vlan_detach; | 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; | ||||
u64 ierrors; | u64 ierrors; | ||||
u64 opackets; | u64 opackets; | ||||
u64 oerrors; | u64 oerrors; | ||||
u64 ibytes; | u64 ibytes; | ||||
u64 obytes; | u64 obytes; | ||||
u64 imcasts; | u64 imcasts; | ||||
u64 omcasts; | u64 omcasts; | ||||
u64 iqdrops; | u64 iqdrops; | ||||
u64 oqdrops; | u64 oqdrops; | ||||
u64 noproto; | u64 noproto; | ||||
/* Driver statistics */ | |||||
u64 hw_filters_del; | |||||
u64 hw_filters_add; | |||||
/* Misc. */ | /* Misc. */ | ||||
u64 flags; | u64 flags; | ||||
struct sysctl_oid *vsi_node; | struct sysctl_oid *vsi_node; | ||||
struct sysctl_ctx_list sysctl_ctx; | |||||
}; | }; | ||||
/* | /* | ||||
** Find the number of unrefreshed RX descriptors | ** Find the number of unrefreshed RX descriptors | ||||
*/ | */ | ||||
static inline u16 | static inline u16 | ||||
ixl_rx_unrefreshed(struct ixl_queue *que) | ixl_rx_unrefreshed(struct ixl_queue *que) | ||||
{ | { | ||||
struct rx_ring *rxr = &que->rxr; | struct rx_ring *rxr = &que->rxr; | ||||
if (rxr->next_check > rxr->next_refresh) | if (rxr->next_check > rxr->next_refresh) | ||||
return (rxr->next_check - rxr->next_refresh - 1); | return (rxr->next_check - rxr->next_refresh - 1); | ||||
else | else | ||||
return ((que->num_rx_desc + rxr->next_check) - | return ((que->num_rx_desc + rxr->next_check) - | ||||
rxr->next_refresh - 1); | rxr->next_refresh - 1); | ||||
} | } | ||||
/* | /* | ||||
Show All 13 Lines | ixl_get_filter(struct ixl_vsi *vsi) | ||||
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; | bool cmp = FALSE; | ||||
if ((ea1[0] == ea2[0]) && (ea1[1] == ea2[1]) && | if ((ea1[0] == ea2[0]) && (ea1[1] == ea2[1]) && | ||||
(ea1[2] == ea2[2]) && (ea1[3] == ea2[3]) && | (ea1[2] == ea2[2]) && (ea1[3] == ea2[3]) && | ||||
(ea1[4] == ea2[4]) && (ea1[5] == ea2[5])) | (ea1[4] == ea2[4]) && (ea1[5] == ea2[5])) | ||||
cmp = TRUE; | cmp = TRUE; | ||||
return (cmp); | return (cmp); | ||||
} | } | ||||
/* | /* | ||||
* Return next largest power of 2, unsigned | * Return next largest power of 2, unsigned | ||||
* | * | ||||
* Public domain, from Bit Twiddling Hacks | * Public domain, from Bit Twiddling Hacks | ||||
*/ | */ | ||||
static inline u32 | static inline u32 | ||||
next_power_of_two(u32 n) | next_power_of_two(u32 n) | ||||
Show All 34 Lines | |||||
bool ixl_txeof(struct ixl_queue *); | bool ixl_txeof(struct ixl_queue *); | ||||
void ixl_free_que_tx(struct ixl_queue *); | void ixl_free_que_tx(struct ixl_queue *); | ||||
void ixl_free_que_rx(struct ixl_queue *); | void ixl_free_que_rx(struct ixl_queue *); | ||||
int ixl_mq_start(struct ifnet *, struct mbuf *); | int ixl_mq_start(struct ifnet *, struct mbuf *); | ||||
int ixl_mq_start_locked(struct ifnet *, struct tx_ring *); | int ixl_mq_start_locked(struct ifnet *, struct tx_ring *); | ||||
void ixl_deferred_mq_start(void *, int); | void ixl_deferred_mq_start(void *, int); | ||||
void ixl_add_sysctls_eth_stats(struct sysctl_ctx_list *, struct sysctl_oid_list *, | |||||
struct i40e_eth_stats *); | |||||
void ixl_vsi_add_queues_stats(struct ixl_vsi *); | |||||
void ixl_vsi_setup_rings_size(struct ixl_vsi *, int, int); | void ixl_vsi_setup_rings_size(struct ixl_vsi *, int, int); | ||||
int ixl_queue_hang_check(struct ixl_vsi *); | int ixl_queue_hang_check(struct ixl_vsi *); | ||||
void ixl_free_vsi(struct ixl_vsi *); | void ixl_free_vsi(struct ixl_vsi *); | ||||
void ixl_qflush(struct ifnet *); | void ixl_qflush(struct ifnet *); | ||||
/* Common function prototypes between PF/VF driver */ | /* Common function prototypes between PF/VF driver */ | ||||
#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 | ||||
void ixl_get_default_rss_key(u32 *); | void ixl_get_default_rss_key(u32 *); | ||||
const char * i40e_vc_stat_str(struct i40e_hw *hw, | const char * i40e_vc_stat_str(struct i40e_hw *hw, | ||||
enum virtchnl_status_code stat_err); | enum virtchnl_status_code stat_err); | ||||
void ixl_set_busmaster(device_t); | void ixl_set_busmaster(device_t); | ||||
void ixl_set_msix_enable(device_t); | void ixl_set_msix_enable(device_t); | ||||
#endif /* _IXL_H_ */ | #endif /* _IXL_H_ */ |