sfxge.h revision 49ef7e0638c8b771d8a136eae78b1c0f99acc8e0
/*
* Copyright (c) 2008-2016 Solarflare Communications Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the FreeBSD Project.
*/
#ifndef _SYS_SFXGE_H
#define _SYS_SFXGE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/ethernet.h>
#include <sys/mac_ether.h>
#include <sys/mac_provider.h>
#include "sfxge_ioc.h"
#include "sfxge_debug.h"
#include "efx.h"
#include "efx_regs.h"
#ifdef _KERNEL
#define SFXGE_DRIVER_NAME "sfxge"
#define SFXGE_CPU_CACHE_SIZE 64
typedef enum sfxge_intr_state_e {
typedef struct sfxge_intr_s {
int si_table_size;
int si_nalloc;
int si_type;
int si_cap;
int si_intr_pri;
} sfxge_intr_t;
typedef enum sfxge_promisc_type_e {
SFXGE_PROMISC_OFF = 0,
typedef enum sfxge_link_duplex_e {
typedef enum sfxge_unicst_type_e {
SFXGE_UNICST_BIA = 0,
typedef struct sfxge_phy_s {
} sfxge_phy_t;
typedef enum sfxge_mac_state_e {
typedef struct sfxge_mac_s {
unsigned int sm_fcntl;
ETHERADDRL]; /* List of multicast addresses to filter on */
int sm_mcast_count;
unsigned int sm_link_speed;
} sfxge_mac_t;
typedef enum sfxge_mon_state_e {
typedef struct sfxge_mon_s {
unsigned int sm_devid;
int sm_polling;
} sfxge_mon_t;
typedef enum sfxge_sram_state_e {
typedef struct sfxge_sram_s {
struct map *ss_buf_tbl_map;
unsigned int ss_count;
} sfxge_sram_t;
typedef enum sfxge_mcdi_state_e {
typedef struct sfxge_mcdi_s {
} sfxge_mcdi_t;
#define SFXGE_NEVS 4096
#define SFXGE_RX_NDESCS 1024
#define SFXGE_TX_NDESCS 1024
#define SFXGE_TX_NLABELS EFX_EV_TX_NLABELS
#define SFXGE_DEFAULT_RXQ_SIZE 1024
#define SFXGE_DEFAULT_MODERATION 30
typedef enum sfxge_evq_state_e {
typedef struct sfxge_txq_s sfxge_txq_t;
typedef struct sfxge_evq_s {
union {
struct {
unsigned int __se_index;
unsigned int __se_id;
} __se_s1;
} __se_u1;
union {
struct {
unsigned int __se_count;
unsigned int __se_rx;
unsigned int __se_tx;
} __se_s2;
} __se_u2;
union {
struct {
} __se_s3;
} __se_u3;
} sfxge_evq_t;
#define SFXGE_MAGIC_RESERVED 0x8000
#define SFXGE_MAGIC_DMAQ_LABEL_WIDTH 5
#define SFXGE_MAGIC_RX_QFLUSH_DONE \
#define SFXGE_MAGIC_RX_QFLUSH_FAILED \
#define SFXGE_MAGIC_RX_QFPP_TRIM \
#define SFXGE_MAGIC_TX_QFLUSH_DONE \
typedef struct sfxge_rxq_s sfxge_rxq_t;
typedef struct sfxge_rx_packet_s sfxge_rx_packet_t;
struct sfxge_rx_packet_s {
union {
struct {
struct ether_header *__srp_etherhp;
struct ip *__srp_iphp;
} __srp_s1;
} __srp_u1;
union {
struct {
unsigned char *__srp_base;
} __srp_s2;
} __srp_u2;
};
#define SFXGE_RX_FPP_NSLOTS 8
/* Free packet pool putlist (dynamically allocated) */
typedef struct sfxge_rx_fpp_putlist_s {
unsigned int srfpl_count;
/* Free packet pool */
typedef struct sfxge_rx_fpp_s {
unsigned int srfpp_loaned;
unsigned int srfpp_count;
unsigned int srfpp_min;
/* Low water mark: Don't trim to below this */
unsigned int srfpp_lowat;
typedef struct sfxge_rx_flow_s sfxge_rx_flow_t;
struct sfxge_rx_flow_s {
/* in-order segment count */
unsigned int srf_count;
/* sequence number */
struct ether_header *srf_etherhp;
struct tcphdr *srf_first_thp;
struct tcphdr *srf_last_thp;
};
#define SFXGE_MAX_FLOW 1024
#define SFXGE_SLOW_START 20
typedef enum sfxge_flush_state_e {
SFXGE_FLUSH_INACTIVE = 0,
typedef enum sfxge_rxq_state_e {
#define SFXGE_RX_BATCH 128
struct sfxge_rxq_s {
union {
struct {
unsigned int __sr_index;
unsigned int __sr_id;
unsigned int __sr_lowat;
unsigned int __sr_hiwat;
volatile timeout_id_t __sr_tid;
} __sr_s1;
} __sr_u1;
union {
struct {
unsigned int __sr_added;
unsigned int __sr_pushed;
unsigned int __sr_pending;
unsigned int __sr_completed;
unsigned int __sr_loopback;
} __sr_s2;
} __sr_u2;
union {
struct {
volatile sfxge_flush_state_t __sr_flush;
} __sr_s3;
} __sr_u3;
struct {
/* NB must match SFXGE_RX_NSTATS */
} sr_kstat;
};
typedef struct sfxge_tx_packet_s sfxge_tx_packet_t;
/* Packet type from parsing transmit packet */
typedef enum sfxge_packet_type_e {
struct sfxge_tx_packet_s {
struct ether_header *stp_etherhp;
};
#define SFXGE_TX_FPP_MAX 64
typedef struct sfxge_tx_fpp_s {
unsigned int stf_count;
typedef struct sfxge_tx_mapping_s sfxge_tx_mapping_t;
struct sfxge_tx_mapping_s {
};
typedef struct sfxge_tx_fmp_s {
unsigned int stf_count;
typedef struct sfxge_tx_buffer_s sfxge_tx_buffer_t;
struct sfxge_tx_buffer_s {
};
#define SFXGE_TX_BUFFER_SIZE 0x400
#define SFXGE_TX_HEADER_SIZE 0x100
#define SFXGE_TX_COPY_THRESHOLD 0x200
typedef struct sfxge_tx_fbp_s {
unsigned int stf_count;
typedef struct sfxge_tx_dpl_s {
unsigned int std_count; /* only get list count */
unsigned int get_pkt_limit;
unsigned int put_pkt_limit;
unsigned int get_full_count;
unsigned int put_full_count;
typedef enum sfxge_txq_state_e {
typedef enum sfxge_txq_type_e {
SFXGE_TXQ_NON_CKSUM = 0,
#define SFXGE_TXQ_UNBLOCK_LEVEL2 0
#define SFXGE_TXQ_NOT_BLOCKED -1
#define SFXGE_TX_BATCH 64
struct sfxge_txq_s {
union {
struct {
unsigned int __st_index;
unsigned int __st_label;
unsigned int __st_evq;
unsigned int __st_id;
} __st_s1;
} __st_u1;
union {
struct {
} __st_s2;
} __st_u2;
union {
struct {
/* mapping pool - sfxge_tx_mapping_t */
/* buffer pool - sfxge_tx_buffer_t */
/* packet pool - sfxge_tx_packet_t */
unsigned int __st_n;
unsigned int __st_added;
unsigned int __st_reaped;
int __st_unblock;
} __st_s3;
} __st_u3;
union {
struct {
unsigned int __st_pending;
unsigned int __st_completed;
} __st_s4;
} __st_u4;
};
typedef enum sfxge_rx_scale_state_e {
#define SFXGE_RX_SCALE_MAX EFX_RSS_TBL_SIZE
typedef struct sfxge_rx_scale_s {
unsigned int *srs_cpu;
unsigned int srs_tbl[SFXGE_RX_SCALE_MAX];
unsigned int srs_count;
typedef enum sfxge_rx_coalesce_mode_e {
typedef enum sfxge_vpd_type_e {
SFXGE_VPD_ID = 0,
SFXGE_VPD_PN = 1,
SFXGE_VPD_SN = 2,
SFXGE_VPD_EC = 3,
SFXGE_VPD_MN = 4,
SFXGE_VPD_VD = 5,
SFXGE_VPD_VE = 6,
SFXGE_VPD_MAX = 7,
typedef struct sfxge_vpd_kstat_s {
typedef struct sfxge_cfg_kstat_s {
struct {
} kstat;
struct {
} buf;
typedef enum sfxge_state_e {
SFXGE_UNINITIALIZED = 0,
typedef enum sfxge_hw_err_e {
SFXGE_HW_OK = 0,
typedef enum sfxge_action_on_hw_err_e {
SFXGE_RECOVER = 0,
SFXGE_INVISIBLE = 1,
SFXGE_LEAVE_DEAD = 2,
typedef char *sfxge_mac_priv_prop_t;
#define SFXGE_TOEPLITZ_KEY_LEN 40
struct sfxge_s {
unsigned int s_bus_addr;
#endif
unsigned int s_pcie_nlanes;
unsigned int s_pcie_linkspeed;
unsigned int s_ev_moderation;
volatile uint64_t s_rx_pkt_mem_alloc;
unsigned int s_tx_scale_base[SFXGE_TXQ_NTYPES];
unsigned int s_tx_scale_max[SFXGE_TXQ_NTYPES];
int s_tx_qcount;
SFXGE_TXQ_NTYPES]; /* Sparse array */
int s_tx_flush_pending;
int s_rxq_poll_usec;
volatile uint32_t s_nested_restarts;
int s_mcdi_logging;
#endif
const uint32_t *s_toeplitz_cache;
};
typedef struct sfxge_dma_buffer_attr_s {
int (*sdba_callback) (caddr_t);
int sdba_maxcookies;
extern const char sfxge_ident[];
extern uint8_t sfxge_brdcst[];
extern kmutex_t sfxge_global_lock;
extern unsigned int *sfxge_cpu;
extern void sfxge_stop(sfxge_t *);
sfxge_hw_err_t, const char *, uint32_t);
extern void sfxge_gld_link_update(sfxge_t *);
extern void sfxge_gld_mtu_update(sfxge_t *);
extern void sfxge_gld_rx_post(sfxge_t *, unsigned int,
mblk_t *);
extern void sfxge_gld_rx_push(sfxge_t *);
extern int sfxge_gld_register(sfxge_t *);
extern int sfxge_gld_unregister(sfxge_t *);
extern int sfxge_dma_buffer_create(efsys_mem_t *,
const sfxge_dma_buffer_attr_t *);
extern void sfxge_dma_buffer_destroy(efsys_mem_t *);
extern int sfxge_intr_init(sfxge_t *);
extern int sfxge_intr_start(sfxge_t *);
extern void sfxge_intr_stop(sfxge_t *);
extern void sfxge_intr_fini(sfxge_t *);
extern void sfxge_intr_fatal(sfxge_t *);
extern int sfxge_ev_init(sfxge_t *);
extern int sfxge_ev_start(sfxge_t *);
extern void sfxge_ev_moderation_get(sfxge_t *,
unsigned int *);
extern int sfxge_ev_moderation_set(sfxge_t *,
unsigned int);
extern int sfxge_ev_qmoderate(sfxge_t *, unsigned int,
unsigned int);
extern int sfxge_ev_qpoll(sfxge_t *, unsigned int);
extern int sfxge_ev_qprime(sfxge_t *, unsigned int);
extern void sfxge_ev_stop(sfxge_t *);
extern void sfxge_ev_fini(sfxge_t *);
extern int sfxge_mon_init(sfxge_t *);
extern int sfxge_mon_start(sfxge_t *);
extern void sfxge_mon_stop(sfxge_t *);
extern void sfxge_mon_fini(sfxge_t *);
extern int sfxge_mac_init(sfxge_t *);
extern void sfxge_mac_stat_get(sfxge_t *, unsigned int,
uint64_t *);
extern void sfxge_mac_link_speed_get(sfxge_t *,
unsigned int *);
extern void sfxge_mac_link_duplex_get(sfxge_t *,
extern void sfxge_mac_fcntl_get(sfxge_t *, unsigned int *);
extern int sfxge_mac_fcntl_set(sfxge_t *, unsigned int);
extern int sfxge_mac_unicst_get(sfxge_t *,
extern int sfxge_mac_unicst_set(sfxge_t *,
uint8_t *);
extern int sfxge_mac_promisc_set(sfxge_t *,
extern int sfxge_mac_multicst_add(sfxge_t *,
extern int sfxge_mac_multicst_remove(sfxge_t *,
extern void sfxge_mac_stop(sfxge_t *);
extern void sfxge_mac_fini(sfxge_t *);
extern int sfxge_phy_init(sfxge_t *);
extern void sfxge_phy_link_mode_get(sfxge_t *,
efx_link_mode_t *);
extern void sfxge_phy_fini(sfxge_t *);
int set);
extern int sfxge_rx_init(sfxge_t *);
extern int sfxge_rx_start(sfxge_t *);
extern void sfxge_rx_coalesce_mode_get(sfxge_t *,
extern int sfxge_rx_coalesce_mode_set(sfxge_t *,
extern unsigned int sfxge_rx_scale_prop_get(sfxge_t *);
extern void sfxge_rx_scale_update(void *);
extern int sfxge_rx_scale_count_get(sfxge_t *,
unsigned int *);
extern int sfxge_rx_scale_count_set(sfxge_t *,
unsigned int);
extern void sfxge_rx_qflush_done(sfxge_rxq_t *);
extern void sfxge_rx_qflush_failed(sfxge_rxq_t *);
extern void sfxge_rx_qfpp_trim(sfxge_rxq_t *);
extern void sfxge_rx_stop(sfxge_t *);
extern unsigned int sfxge_rx_loaned(sfxge_t *);
extern void sfxge_rx_fini(sfxge_t *);
extern int sfxge_tx_init(sfxge_t *);
extern int sfxge_tx_start(sfxge_t *);
extern void sfxge_tx_qcomplete(sfxge_txq_t *);
extern void sfxge_tx_qflush_done(sfxge_txq_t *);
extern void sfxge_tx_stop(sfxge_t *);
extern void sfxge_tx_fini(sfxge_t *);
extern void sfxge_sram_init(sfxge_t *);
uint32_t *);
extern int sfxge_sram_start(sfxge_t *);
efsys_mem_t *, size_t);
size_t);
extern void sfxge_sram_stop(sfxge_t *);
size_t);
extern void sfxge_sram_fini(sfxge_t *);
extern int sfxge_toeplitz_hash_init(sfxge_t *);
extern void sfxge_toeplitz_hash_fini(sfxge_t *);
/*
* To compute the same hash value as Siena/Huntington hardware, the inputs
* must be in big endian (network) byte order.
*/
do { \
sizeof (struct in_addr), \
(_rport), \
(_lport)); \
} while (B_FALSE)
/*
* 4-tuple hash for non-TCP IPv4 packets, used for TX queue selection.
* For UDP or SCTP packets, calculate a 4-tuple hash using port numbers.
* For other IPv4 non-TCP packets, use zero for the port numbers.
*/
extern int sfxge_pci_init(sfxge_t *);
extern void sfxge_pcie_check_link(sfxge_t *, unsigned int,
unsigned int);
extern void sfxge_pci_fini(sfxge_t *);
extern int sfxge_bar_init(sfxge_t *);
extern void sfxge_bar_fini(sfxge_t *);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SFXGE_H */