This is the beta release of the driver for the new
Intel 40G Ethernet Controller XL710 Family. This is the core driver, a VF driver called i40evf, will be following soon. Questions or comments to myself or my co-developer Eric Joyner. Cheers!
This commit is contained in:
parent
883831c675
commit
a7353153c1
@ -1417,6 +1417,22 @@ dev/hptiop/hptiop.c optional hptiop scbus
|
||||
dev/hwpmc/hwpmc_logging.c optional hwpmc
|
||||
dev/hwpmc/hwpmc_mod.c optional hwpmc
|
||||
dev/hwpmc/hwpmc_soft.c optional hwpmc
|
||||
dev/i40e/if_i40e.c optional i40e inet \
|
||||
compile-with "${NORMAL_C} -I$S/dev/i40e -DSMP"
|
||||
dev/i40e/i40e_txrx.c optional i40e inet \
|
||||
compile-with "${NORMAL_C} -I$S/dev/i40e -DSMP"
|
||||
dev/i40e/i40e_osdep.c optional i40e inet \
|
||||
compile-with "${NORMAL_C} -I$S/dev/i40e -DSMP"
|
||||
dev/i40e/i40e_nvm.c optional i40e inet \
|
||||
compile-with "${NORMAL_C} -I$S/dev/i40e -DSMP"
|
||||
dev/i40e/i40e_lan_hmc.c optional i40e inet \
|
||||
compile-with "${NORMAL_C} -I$S/dev/i40e -DSMP"
|
||||
dev/i40e/i40e_hmc.c optional i40e inet \
|
||||
compile-with "${NORMAL_C} -I$S/dev/i40e -DSMP"
|
||||
dev/i40e/i40e_common.c optional i40e inet \
|
||||
compile-with "${NORMAL_C} -I$S/dev/i40e -DSMP"
|
||||
dev/i40e/i40e_adminq.c optional i40e inet \
|
||||
compile-with "${NORMAL_C} -I$S/dev/i40e -DSMP"
|
||||
dev/ichsmb/ichsmb.c optional ichsmb
|
||||
dev/ichsmb/ichsmb_pci.c optional ichsmb pci
|
||||
dev/ida/ida.c optional ida
|
||||
|
491
sys/dev/i40e/i40e.h
Executable file
491
sys/dev/i40e/i40e.h
Executable file
@ -0,0 +1,491 @@
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (c) 2013-2014, Intel Corporation
|
||||
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 and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
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.
|
||||
|
||||
******************************************************************************/
|
||||
/*$FreeBSD$*/
|
||||
|
||||
|
||||
#ifndef _I40E_H_
|
||||
#define _I40E_H_
|
||||
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/buf_ring.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/sockio.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_arp.h>
|
||||
#include <net/bpf.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_media.h>
|
||||
|
||||
#include <net/bpf.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/if_vlan_var.h>
|
||||
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/if_ether.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/ip6.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/tcp_lro.h>
|
||||
#include <netinet/udp.h>
|
||||
#include <netinet/sctp.h>
|
||||
|
||||
#include <machine/in_cksum.h>
|
||||
|
||||
#include <sys/bus.h>
|
||||
#include <machine/bus.h>
|
||||
#include <sys/rman.h>
|
||||
#include <machine/resource.h>
|
||||
#include <vm/vm.h>
|
||||
#include <vm/pmap.h>
|
||||
#include <machine/clock.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/taskqueue.h>
|
||||
#include <sys/pcpu.h>
|
||||
#include <sys/smp.h>
|
||||
#include <machine/smp.h>
|
||||
|
||||
#include "i40e_type.h"
|
||||
#include "i40e_prototype.h"
|
||||
|
||||
#ifdef I40E_DEBUG
|
||||
#define MAC_FORMAT "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
#define MAC_FORMAT_ARGS(mac_addr) \
|
||||
(mac_addr)[0], (mac_addr)[1], (mac_addr)[2], (mac_addr)[3], \
|
||||
(mac_addr)[4], (mac_addr)[5]
|
||||
#define ON_OFF_STR(is_set) ((is_set) ? "On" : "Off")
|
||||
|
||||
// static void i40e_dump_desc(void *, u8, u16);
|
||||
#endif
|
||||
|
||||
/* Tunables */
|
||||
|
||||
/*
|
||||
* Ring Descriptors Valid Range: 32-4096 Default Value: 1024 This value is the
|
||||
* number of tx/rx descriptors allocated by the driver. Increasing this
|
||||
* value allows the driver to queue more operations. Each descriptor is 16
|
||||
* or 32 bytes (configurable in FVL)
|
||||
*/
|
||||
#define DEFAULT_RING 1024
|
||||
#define PERFORM_RING 2048
|
||||
#define MAX_RING 4096
|
||||
#define MIN_RING 32
|
||||
|
||||
/* Alignment for rings */
|
||||
#define DBA_ALIGN 128
|
||||
|
||||
/*
|
||||
* This parameter controls the maximum no of times the driver will loop in
|
||||
* the isr. Minimum Value = 1
|
||||
*/
|
||||
#define MAX_LOOP 10
|
||||
|
||||
/*
|
||||
* This is the max watchdog interval, ie. the time that can
|
||||
* pass between any two TX clean operations, such only happening
|
||||
* when the TX hardware is functioning.
|
||||
*/
|
||||
#define I40E_WATCHDOG (10 * hz)
|
||||
|
||||
/*
|
||||
* This parameters control when the driver calls the routine to reclaim
|
||||
* transmit descriptors.
|
||||
*/
|
||||
#define I40E_TX_CLEANUP_THRESHOLD (que->num_desc / 8)
|
||||
#define I40E_TX_OP_THRESHOLD (que->num_desc / 32)
|
||||
|
||||
/* Flow control constants */
|
||||
#define I40E_FC_PAUSE 0xFFFF
|
||||
#define I40E_FC_HI 0x20000
|
||||
#define I40E_FC_LO 0x10000
|
||||
|
||||
/* Defines for printing debug information */
|
||||
#define DEBUG_INIT 0
|
||||
#define DEBUG_IOCTL 0
|
||||
#define DEBUG_HW 0
|
||||
|
||||
#define INIT_DEBUGOUT(S) if (DEBUG_INIT) printf(S "\n")
|
||||
#define INIT_DEBUGOUT1(S, A) if (DEBUG_INIT) printf(S "\n", A)
|
||||
#define INIT_DEBUGOUT2(S, A, B) if (DEBUG_INIT) printf(S "\n", A, B)
|
||||
#define IOCTL_DEBUGOUT(S) if (DEBUG_IOCTL) printf(S "\n")
|
||||
#define IOCTL_DEBUGOUT1(S, A) if (DEBUG_IOCTL) printf(S "\n", A)
|
||||
#define IOCTL_DEBUGOUT2(S, A, B) if (DEBUG_IOCTL) printf(S "\n", A, B)
|
||||
#define HW_DEBUGOUT(S) if (DEBUG_HW) printf(S "\n")
|
||||
#define HW_DEBUGOUT1(S, A) if (DEBUG_HW) printf(S "\n", A)
|
||||
#define HW_DEBUGOUT2(S, A, B) if (DEBUG_HW) printf(S "\n", A, B)
|
||||
|
||||
#define MAX_MULTICAST_ADDR 128
|
||||
|
||||
#define I40E_BAR 3
|
||||
#define I40E_ADM_LIMIT 2
|
||||
#define I40E_TSO_SIZE 65535
|
||||
#define I40E_TX_BUF_SZ ((u32) 1514)
|
||||
#define I40E_AQ_BUF_SZ ((u32) 4096)
|
||||
#define I40E_RX_HDR 128
|
||||
#define I40E_AQ_LEN 32
|
||||
#define I40E_AQ_BUFSZ 4096
|
||||
#define I40E_RX_LIMIT 512
|
||||
#define I40E_RX_ITR 0
|
||||
#define I40E_TX_ITR 1
|
||||
#define I40E_ITR_NONE 3
|
||||
#define I40E_QUEUE_EOL 0x7FF
|
||||
#define I40E_MAX_FRAME 0x2600
|
||||
#define I40E_MAX_SEGS 32
|
||||
#define I40E_MAX_FILTERS 256 /* This is artificial */
|
||||
#define I40E_MAX_TX_BUSY 10
|
||||
|
||||
/*
|
||||
* Interrupt Moderation parameters
|
||||
*/
|
||||
#define I40E_MAX_ITR 0x07FF
|
||||
#define I40E_ITR_100K 0x0005
|
||||
#define I40E_ITR_20K 0x0019
|
||||
#define I40E_ITR_8K 0x003E
|
||||
#define I40E_ITR_4K 0x007A
|
||||
#define I40E_ITR_DYNAMIC 0x8000
|
||||
#define I40E_LOW_LATENCY 0
|
||||
#define I40E_AVE_LATENCY 1
|
||||
#define I40E_BULK_LATENCY 2
|
||||
|
||||
/* MacVlan Flags */
|
||||
#define I40E_FILTER_USED (u16)(1 << 0)
|
||||
#define I40E_FILTER_VLAN (u16)(1 << 1)
|
||||
#define I40E_FILTER_ADD (u16)(1 << 2)
|
||||
#define I40E_FILTER_DEL (u16)(1 << 3)
|
||||
#define I40E_FILTER_MC (u16)(1 << 4)
|
||||
|
||||
/* used in the vlan field of the filter when not a vlan */
|
||||
#define I40E_VLAN_ANY -1
|
||||
|
||||
#define CSUM_OFFLOAD (CSUM_IP|CSUM_TCP|CSUM_UDP|CSUM_SCTP)
|
||||
|
||||
/* Misc flags for i40e_vsi.flags */
|
||||
#define I40E_FLAGS_KEEP_TSO4 (1 << 0)
|
||||
#define I40E_FLAGS_KEEP_TSO6 (1 << 1)
|
||||
|
||||
#define I40E_TX_LOCK(_sc) mtx_lock(&(_sc)->mtx)
|
||||
#define I40E_TX_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx)
|
||||
#define I40E_TX_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->mtx)
|
||||
#define I40E_TX_TRYLOCK(_sc) mtx_trylock(&(_sc)->mtx)
|
||||
#define I40E_TX_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->mtx, MA_OWNED)
|
||||
|
||||
#define I40E_RX_LOCK(_sc) mtx_lock(&(_sc)->mtx)
|
||||
#define I40E_RX_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx)
|
||||
#define I40E_RX_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->mtx)
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
* vendor_info_array
|
||||
*
|
||||
* This array contains the list of Subvendor/Subdevice IDs on which the driver
|
||||
* should load.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
typedef struct _i40e_vendor_info_t {
|
||||
unsigned int vendor_id;
|
||||
unsigned int device_id;
|
||||
unsigned int subvendor_id;
|
||||
unsigned int subdevice_id;
|
||||
unsigned int index;
|
||||
} i40e_vendor_info_t;
|
||||
|
||||
|
||||
struct i40e_tx_buf {
|
||||
u32 eop_index;
|
||||
struct mbuf *m_head;
|
||||
bus_dmamap_t map;
|
||||
};
|
||||
|
||||
struct i40e_rx_buf {
|
||||
struct mbuf *m_head;
|
||||
struct mbuf *m_pack;
|
||||
struct mbuf *fmp;
|
||||
bus_dmamap_t hmap;
|
||||
bus_dmamap_t pmap;
|
||||
};
|
||||
|
||||
struct i40e_pkt_info {
|
||||
u16 etype;
|
||||
u32 elen;
|
||||
u32 iplen;
|
||||
struct ip *ip;
|
||||
struct ip6_hdr *ip6;
|
||||
struct tcphdr *th;
|
||||
};
|
||||
|
||||
/*
|
||||
** This struct has multiple uses, multicast
|
||||
** addresses, vlans, and mac filters all use it.
|
||||
*/
|
||||
struct i40e_mac_filter {
|
||||
SLIST_ENTRY(i40e_mac_filter) next;
|
||||
u8 macaddr[ETHER_ADDR_LEN];
|
||||
s16 vlan;
|
||||
u16 flags;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* The Transmit ring control struct
|
||||
*/
|
||||
struct tx_ring {
|
||||
struct i40e_queue *que;
|
||||
struct mtx mtx;
|
||||
int watchdog;
|
||||
struct i40e_tx_desc *base;
|
||||
struct i40e_dma_mem dma;
|
||||
u16 next_avail;
|
||||
u16 next_to_clean;
|
||||
u16 atr_rate;
|
||||
u16 atr_count;
|
||||
u16 itr;
|
||||
u16 latency;
|
||||
struct i40e_tx_buf *buffers;
|
||||
volatile u16 avail;
|
||||
u32 cmd;
|
||||
bus_dma_tag_t tag;
|
||||
char mtx_name[16];
|
||||
struct buf_ring *br;
|
||||
|
||||
/* Soft Stats */
|
||||
u32 packets;
|
||||
u32 bytes;
|
||||
u64 no_desc;
|
||||
u64 total_packets;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* The Receive ring control struct
|
||||
*/
|
||||
struct rx_ring {
|
||||
struct i40e_queue *que;
|
||||
struct mtx mtx;
|
||||
union i40e_rx_desc *base;
|
||||
struct i40e_dma_mem dma;
|
||||
struct lro_ctrl lro;
|
||||
bool lro_enabled;
|
||||
bool hdr_split;
|
||||
bool discard;
|
||||
u16 next_refresh;
|
||||
u16 next_check;
|
||||
u16 itr;
|
||||
u16 latency;
|
||||
char mtx_name[16];
|
||||
struct i40e_rx_buf *buffers;
|
||||
u32 mbuf_sz;
|
||||
bus_dma_tag_t htag;
|
||||
bus_dma_tag_t ptag;
|
||||
|
||||
/* Soft stats */
|
||||
u32 packets;
|
||||
u32 bytes;
|
||||
|
||||
u64 split;
|
||||
u64 rx_packets;
|
||||
u64 rx_bytes;
|
||||
u64 discarded;
|
||||
u64 not_done;
|
||||
};
|
||||
|
||||
/*
|
||||
** Driver queue struct: this is the interrupt container
|
||||
** for the associated tx and rx ring pair.
|
||||
*/
|
||||
struct i40e_queue {
|
||||
struct i40e_vsi *vsi;
|
||||
u32 me;
|
||||
u32 msix; /* This queue's MSIX vector */
|
||||
u32 eims; /* This queue's EIMS bit */
|
||||
struct resource *res;
|
||||
void *tag;
|
||||
int num_desc; /* both tx and rx */
|
||||
int busy;
|
||||
struct tx_ring txr;
|
||||
struct rx_ring rxr;
|
||||
struct task task;
|
||||
struct task tx_task;
|
||||
struct taskqueue *tq;
|
||||
|
||||
/* Queue stats */
|
||||
u64 irqs;
|
||||
u64 tso;
|
||||
u64 mbuf_defrag_failed;
|
||||
u64 mbuf_hdr_failed;
|
||||
u64 mbuf_pkt_failed;
|
||||
u64 tx_map_avail;
|
||||
u64 tx_dma_setup;
|
||||
u64 dropped_pkts;
|
||||
};
|
||||
|
||||
/*
|
||||
** Virtual Station interface:
|
||||
** there would be one of these per traffic class/type
|
||||
** for now just one, and its embedded in the pf
|
||||
*/
|
||||
SLIST_HEAD(i40e_ftl_head, i40e_mac_filter);
|
||||
struct i40e_vsi {
|
||||
void *back;
|
||||
struct ifnet *ifp;
|
||||
struct device *dev;
|
||||
struct i40e_hw *hw;
|
||||
struct ifmedia media;
|
||||
u64 que_mask;
|
||||
int id;
|
||||
u16 msix_base; /* station base MSIX vector */
|
||||
u16 num_queues;
|
||||
u16 rx_itr_setting;
|
||||
u16 tx_itr_setting;
|
||||
struct i40e_queue *queues; /* head of queues */
|
||||
bool link_active;
|
||||
u16 seid;
|
||||
u16 max_frame_size;
|
||||
u32 link_speed;
|
||||
bool link_up;
|
||||
u32 fc; /* local flow ctrl setting */
|
||||
|
||||
/* MAC/VLAN Filter list */
|
||||
struct i40e_ftl_head ftl;
|
||||
|
||||
struct i40e_aqc_vsi_properties_data info;
|
||||
|
||||
eventhandler_tag vlan_attach;
|
||||
eventhandler_tag vlan_detach;
|
||||
u16 num_vlans;
|
||||
|
||||
/* Per-VSI stats from hardware */
|
||||
struct i40e_eth_stats eth_stats;
|
||||
struct i40e_eth_stats eth_stats_offsets;
|
||||
bool stat_offsets_loaded;
|
||||
|
||||
/* Driver statistics */
|
||||
u64 hw_filters_del;
|
||||
u64 hw_filters_add;
|
||||
|
||||
/* Misc. */
|
||||
u64 flags;
|
||||
};
|
||||
|
||||
/*
|
||||
** Find the number of unrefreshed RX descriptors
|
||||
*/
|
||||
static inline u16
|
||||
i40e_rx_unrefreshed(struct i40e_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
|
||||
*/
|
||||
static inline struct i40e_mac_filter *
|
||||
i40e_get_filter(struct i40e_vsi *vsi)
|
||||
{
|
||||
struct i40e_mac_filter *f;
|
||||
|
||||
// create a new empty filter
|
||||
f = malloc(sizeof(struct i40e_mac_filter) , M_DEVBUF, M_NOWAIT | M_ZERO);
|
||||
SLIST_INSERT_HEAD(&vsi->ftl, f, next);
|
||||
|
||||
return (f);
|
||||
}
|
||||
|
||||
/*
|
||||
** Compare two ethernet addresses
|
||||
*/
|
||||
static inline bool
|
||||
cmp_etheraddr(u8 *ea1, u8 *ea2)
|
||||
{
|
||||
bool cmp = FALSE;
|
||||
|
||||
if ((ea1[0] == ea2[0]) && (ea1[1] == ea2[1]) &&
|
||||
(ea1[2] == ea2[2]) && (ea1[3] == ea2[3]) &&
|
||||
(ea1[4] == ea2[4]) && (ea1[5] == ea2[5]))
|
||||
cmp = TRUE;
|
||||
|
||||
return (cmp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Info for stats sysctls
|
||||
*/
|
||||
struct i40e_sysctl_info {
|
||||
u64 *stat;
|
||||
char *name;
|
||||
char *description;
|
||||
};
|
||||
|
||||
extern int i40e_atr_rate;
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* TXRX Function prototypes
|
||||
*********************************************************************/
|
||||
int i40e_allocate_tx_data(struct i40e_queue *);
|
||||
int i40e_allocate_rx_data(struct i40e_queue *);
|
||||
void i40e_init_tx_ring(struct i40e_queue *);
|
||||
int i40e_init_rx_ring(struct i40e_queue *);
|
||||
bool i40e_rxeof(struct i40e_queue *, int);
|
||||
bool i40e_txeof(struct i40e_queue *);
|
||||
int i40e_mq_start(struct ifnet *, struct mbuf *);
|
||||
int i40e_mq_start_locked(struct ifnet *, struct tx_ring *);
|
||||
void i40e_deferred_mq_start(void *, int);
|
||||
void i40e_qflush(struct ifnet *);
|
||||
void i40e_free_vsi(struct i40e_vsi *);
|
||||
void i40e_free_que_tx(struct i40e_queue *);
|
||||
void i40e_free_que_rx(struct i40e_queue *);
|
||||
#ifdef I40E_FDIR
|
||||
void i40e_atr(struct i40e_queue *, struct tcphdr *, int);
|
||||
#endif
|
||||
|
||||
#endif /* _I40E_H_ */
|
1089
sys/dev/i40e/i40e_adminq.c
Executable file
1089
sys/dev/i40e/i40e_adminq.c
Executable file
File diff suppressed because it is too large
Load Diff
119
sys/dev/i40e/i40e_adminq.h
Executable file
119
sys/dev/i40e/i40e_adminq.h
Executable file
@ -0,0 +1,119 @@
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (c) 2013-2014, Intel Corporation
|
||||
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 and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
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.
|
||||
|
||||
******************************************************************************/
|
||||
/*$FreeBSD$*/
|
||||
|
||||
#ifndef _I40E_ADMINQ_H_
|
||||
#define _I40E_ADMINQ_H_
|
||||
|
||||
#include "i40e_osdep.h"
|
||||
#include "i40e_adminq_cmd.h"
|
||||
|
||||
#define I40E_ADMINQ_DESC(R, i) \
|
||||
(&(((struct i40e_aq_desc *)((R).desc_buf.va))[i]))
|
||||
|
||||
#define I40E_ADMINQ_DESC_ALIGNMENT 4096
|
||||
|
||||
struct i40e_adminq_ring {
|
||||
struct i40e_virt_mem dma_head; /* space for dma structures */
|
||||
struct i40e_dma_mem desc_buf; /* descriptor ring memory */
|
||||
struct i40e_virt_mem cmd_buf; /* command buffer memory */
|
||||
|
||||
union {
|
||||
struct i40e_dma_mem *asq_bi;
|
||||
struct i40e_dma_mem *arq_bi;
|
||||
} r;
|
||||
|
||||
u16 count; /* Number of descriptors */
|
||||
u16 rx_buf_len; /* Admin Receive Queue buffer length */
|
||||
|
||||
/* used for interrupt processing */
|
||||
u16 next_to_use;
|
||||
u16 next_to_clean;
|
||||
|
||||
/* used for queue tracking */
|
||||
u32 head;
|
||||
u32 tail;
|
||||
u32 len;
|
||||
};
|
||||
|
||||
/* ASQ transaction details */
|
||||
struct i40e_asq_cmd_details {
|
||||
void *callback; /* cast from type I40E_ADMINQ_CALLBACK */
|
||||
u64 cookie;
|
||||
u16 flags_ena;
|
||||
u16 flags_dis;
|
||||
bool async;
|
||||
bool postpone;
|
||||
};
|
||||
|
||||
#define I40E_ADMINQ_DETAILS(R, i) \
|
||||
(&(((struct i40e_asq_cmd_details *)((R).cmd_buf.va))[i]))
|
||||
|
||||
/* ARQ event information */
|
||||
struct i40e_arq_event_info {
|
||||
struct i40e_aq_desc desc;
|
||||
u16 msg_size;
|
||||
u8 *msg_buf;
|
||||
};
|
||||
|
||||
/* Admin Queue information */
|
||||
struct i40e_adminq_info {
|
||||
struct i40e_adminq_ring arq; /* receive queue */
|
||||
struct i40e_adminq_ring asq; /* send queue */
|
||||
u16 num_arq_entries; /* receive queue depth */
|
||||
u16 num_asq_entries; /* send queue depth */
|
||||
u16 arq_buf_size; /* receive queue buffer size */
|
||||
u16 asq_buf_size; /* send queue buffer size */
|
||||
u16 fw_maj_ver; /* firmware major version */
|
||||
u16 fw_min_ver; /* firmware minor version */
|
||||
u16 api_maj_ver; /* api major version */
|
||||
u16 api_min_ver; /* api minor version */
|
||||
bool nvm_busy;
|
||||
bool nvm_release_on_done;
|
||||
|
||||
struct i40e_spinlock asq_spinlock; /* Send queue spinlock */
|
||||
struct i40e_spinlock arq_spinlock; /* Receive queue spinlock */
|
||||
|
||||
/* last status values on send and receive queues */
|
||||
enum i40e_admin_queue_err asq_last_status;
|
||||
enum i40e_admin_queue_err arq_last_status;
|
||||
};
|
||||
|
||||
/* general information */
|
||||
#define I40E_AQ_LARGE_BUF 512
|
||||
#define I40E_ASQ_CMD_TIMEOUT 100000 /* usecs */
|
||||
|
||||
void i40e_fill_default_direct_cmd_desc(struct i40e_aq_desc *desc,
|
||||
u16 opcode);
|
||||
|
||||
#endif /* _I40E_ADMINQ_H_ */
|
2238
sys/dev/i40e/i40e_adminq_cmd.h
Executable file
2238
sys/dev/i40e/i40e_adminq_cmd.h
Executable file
File diff suppressed because it is too large
Load Diff
66
sys/dev/i40e/i40e_alloc.h
Executable file
66
sys/dev/i40e/i40e_alloc.h
Executable file
@ -0,0 +1,66 @@
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (c) 2013-2014, Intel Corporation
|
||||
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 and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
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.
|
||||
|
||||
******************************************************************************/
|
||||
/*$FreeBSD$*/
|
||||
|
||||
#ifndef _I40E_ALLOC_H_
|
||||
#define _I40E_ALLOC_H_
|
||||
|
||||
struct i40e_hw;
|
||||
|
||||
/* Memory allocation types */
|
||||
enum i40e_memory_type {
|
||||
i40e_mem_arq_buf = 0, /* ARQ indirect command buffer */
|
||||
i40e_mem_asq_buf = 1,
|
||||
i40e_mem_atq_buf = 2, /* ATQ indirect command buffer */
|
||||
i40e_mem_arq_ring = 3, /* ARQ descriptor ring */
|
||||
i40e_mem_atq_ring = 4, /* ATQ descriptor ring */
|
||||
i40e_mem_pd = 5, /* Page Descriptor */
|
||||
i40e_mem_bp = 6, /* Backing Page - 4KB */
|
||||
i40e_mem_bp_jumbo = 7, /* Backing Page - > 4KB */
|
||||
i40e_mem_reserved
|
||||
};
|
||||
|
||||
/* prototype for functions used for dynamic memory allocation */
|
||||
enum i40e_status_code i40e_allocate_dma_mem(struct i40e_hw *hw,
|
||||
struct i40e_dma_mem *mem,
|
||||
enum i40e_memory_type type,
|
||||
u64 size, u32 alignment);
|
||||
enum i40e_status_code i40e_free_dma_mem(struct i40e_hw *hw,
|
||||
struct i40e_dma_mem *mem);
|
||||
enum i40e_status_code i40e_allocate_virt_mem(struct i40e_hw *hw,
|
||||
struct i40e_virt_mem *mem,
|
||||
u32 size);
|
||||
enum i40e_status_code i40e_free_virt_mem(struct i40e_hw *hw,
|
||||
struct i40e_virt_mem *mem);
|
||||
|
||||
#endif /* _I40E_ALLOC_H_ */
|
4625
sys/dev/i40e/i40e_common.c
Executable file
4625
sys/dev/i40e/i40e_common.c
Executable file
File diff suppressed because it is too large
Load Diff
376
sys/dev/i40e/i40e_hmc.c
Executable file
376
sys/dev/i40e/i40e_hmc.c
Executable file
@ -0,0 +1,376 @@
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (c) 2013-2014, Intel Corporation
|
||||
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 and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
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.
|
||||
|
||||
******************************************************************************/
|
||||
/*$FreeBSD$*/
|
||||
|
||||
#include "i40e_osdep.h"
|
||||
#include "i40e_register.h"
|
||||
#include "i40e_status.h"
|
||||
#include "i40e_alloc.h"
|
||||
#include "i40e_hmc.h"
|
||||
#ifndef I40E_NO_TYPE_HEADER
|
||||
#include "i40e_type.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* i40e_add_sd_table_entry - Adds a segment descriptor to the table
|
||||
* @hw: pointer to our hw struct
|
||||
* @hmc_info: pointer to the HMC configuration information struct
|
||||
* @sd_index: segment descriptor index to manipulate
|
||||
* @type: what type of segment descriptor we're manipulating
|
||||
* @direct_mode_sz: size to alloc in direct mode
|
||||
**/
|
||||
enum i40e_status_code i40e_add_sd_table_entry(struct i40e_hw *hw,
|
||||
struct i40e_hmc_info *hmc_info,
|
||||
u32 sd_index,
|
||||
enum i40e_sd_entry_type type,
|
||||
u64 direct_mode_sz)
|
||||
{
|
||||
enum i40e_status_code ret_code = I40E_SUCCESS;
|
||||
struct i40e_hmc_sd_entry *sd_entry;
|
||||
enum i40e_memory_type mem_type;
|
||||
bool dma_mem_alloc_done = FALSE;
|
||||
struct i40e_dma_mem mem;
|
||||
u64 alloc_len;
|
||||
|
||||
if (NULL == hmc_info->sd_table.sd_entry) {
|
||||
ret_code = I40E_ERR_BAD_PTR;
|
||||
DEBUGOUT("i40e_add_sd_table_entry: bad sd_entry\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (sd_index >= hmc_info->sd_table.sd_cnt) {
|
||||
ret_code = I40E_ERR_INVALID_SD_INDEX;
|
||||
DEBUGOUT("i40e_add_sd_table_entry: bad sd_index\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
sd_entry = &hmc_info->sd_table.sd_entry[sd_index];
|
||||
if (!sd_entry->valid) {
|
||||
if (I40E_SD_TYPE_PAGED == type) {
|
||||
mem_type = i40e_mem_pd;
|
||||
alloc_len = I40E_HMC_PAGED_BP_SIZE;
|
||||
} else {
|
||||
mem_type = i40e_mem_bp_jumbo;
|
||||
alloc_len = direct_mode_sz;
|
||||
}
|
||||
|
||||
/* allocate a 4K pd page or 2M backing page */
|
||||
ret_code = i40e_allocate_dma_mem(hw, &mem, mem_type, alloc_len,
|
||||
I40E_HMC_PD_BP_BUF_ALIGNMENT);
|
||||
if (ret_code)
|
||||
goto exit;
|
||||
dma_mem_alloc_done = TRUE;
|
||||
if (I40E_SD_TYPE_PAGED == type) {
|
||||
ret_code = i40e_allocate_virt_mem(hw,
|
||||
&sd_entry->u.pd_table.pd_entry_virt_mem,
|
||||
sizeof(struct i40e_hmc_pd_entry) * 512);
|
||||
if (ret_code)
|
||||
goto exit;
|
||||
sd_entry->u.pd_table.pd_entry =
|
||||
(struct i40e_hmc_pd_entry *)
|
||||
sd_entry->u.pd_table.pd_entry_virt_mem.va;
|
||||
i40e_memcpy(&sd_entry->u.pd_table.pd_page_addr,
|
||||
&mem, sizeof(struct i40e_dma_mem),
|
||||
I40E_NONDMA_TO_NONDMA);
|
||||
} else {
|
||||
i40e_memcpy(&sd_entry->u.bp.addr,
|
||||
&mem, sizeof(struct i40e_dma_mem),
|
||||
I40E_NONDMA_TO_NONDMA);
|
||||
sd_entry->u.bp.sd_pd_index = sd_index;
|
||||
}
|
||||
/* initialize the sd entry */
|
||||
hmc_info->sd_table.sd_entry[sd_index].entry_type = type;
|
||||
|
||||
/* increment the ref count */
|
||||
I40E_INC_SD_REFCNT(&hmc_info->sd_table);
|
||||
}
|
||||
/* Increment backing page reference count */
|
||||
if (I40E_SD_TYPE_DIRECT == sd_entry->entry_type)
|
||||
I40E_INC_BP_REFCNT(&sd_entry->u.bp);
|
||||
exit:
|
||||
if (I40E_SUCCESS != ret_code)
|
||||
if (dma_mem_alloc_done)
|
||||
i40e_free_dma_mem(hw, &mem);
|
||||
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* i40e_add_pd_table_entry - Adds page descriptor to the specified table
|
||||
* @hw: pointer to our HW structure
|
||||
* @hmc_info: pointer to the HMC configuration information structure
|
||||
* @pd_index: which page descriptor index to manipulate
|
||||
*
|
||||
* This function:
|
||||
* 1. Initializes the pd entry
|
||||
* 2. Adds pd_entry in the pd_table
|
||||
* 3. Mark the entry valid in i40e_hmc_pd_entry structure
|
||||
* 4. Initializes the pd_entry's ref count to 1
|
||||
* assumptions:
|
||||
* 1. The memory for pd should be pinned down, physically contiguous and
|
||||
* aligned on 4K boundary and zeroed memory.
|
||||
* 2. It should be 4K in size.
|
||||
**/
|
||||
enum i40e_status_code i40e_add_pd_table_entry(struct i40e_hw *hw,
|
||||
struct i40e_hmc_info *hmc_info,
|
||||
u32 pd_index)
|
||||
{
|
||||
enum i40e_status_code ret_code = I40E_SUCCESS;
|
||||
struct i40e_hmc_pd_table *pd_table;
|
||||
struct i40e_hmc_pd_entry *pd_entry;
|
||||
struct i40e_dma_mem mem;
|
||||
u32 sd_idx, rel_pd_idx;
|
||||
u64 *pd_addr;
|
||||
u64 page_desc;
|
||||
|
||||
if (pd_index / I40E_HMC_PD_CNT_IN_SD >= hmc_info->sd_table.sd_cnt) {
|
||||
ret_code = I40E_ERR_INVALID_PAGE_DESC_INDEX;
|
||||
DEBUGOUT("i40e_add_pd_table_entry: bad pd_index\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* find corresponding sd */
|
||||
sd_idx = (pd_index / I40E_HMC_PD_CNT_IN_SD);
|
||||
if (I40E_SD_TYPE_PAGED !=
|
||||
hmc_info->sd_table.sd_entry[sd_idx].entry_type)
|
||||
goto exit;
|
||||
|
||||
rel_pd_idx = (pd_index % I40E_HMC_PD_CNT_IN_SD);
|
||||
pd_table = &hmc_info->sd_table.sd_entry[sd_idx].u.pd_table;
|
||||
pd_entry = &pd_table->pd_entry[rel_pd_idx];
|
||||
if (!pd_entry->valid) {
|
||||
/* allocate a 4K backing page */
|
||||
ret_code = i40e_allocate_dma_mem(hw, &mem, i40e_mem_bp,
|
||||
I40E_HMC_PAGED_BP_SIZE,
|
||||
I40E_HMC_PD_BP_BUF_ALIGNMENT);
|
||||
if (ret_code)
|
||||
goto exit;
|
||||
|
||||
i40e_memcpy(&pd_entry->bp.addr, &mem,
|
||||
sizeof(struct i40e_dma_mem), I40E_NONDMA_TO_NONDMA);
|
||||
pd_entry->bp.sd_pd_index = pd_index;
|
||||
pd_entry->bp.entry_type = I40E_SD_TYPE_PAGED;
|
||||
/* Set page address and valid bit */
|
||||
page_desc = mem.pa | 0x1;
|
||||
|
||||
pd_addr = (u64 *)pd_table->pd_page_addr.va;
|
||||
pd_addr += rel_pd_idx;
|
||||
|
||||
/* Add the backing page physical address in the pd entry */
|
||||
i40e_memcpy(pd_addr, &page_desc, sizeof(u64),
|
||||
I40E_NONDMA_TO_DMA);
|
||||
|
||||
pd_entry->sd_index = sd_idx;
|
||||
pd_entry->valid = TRUE;
|
||||
I40E_INC_PD_REFCNT(pd_table);
|
||||
}
|
||||
I40E_INC_BP_REFCNT(&pd_entry->bp);
|
||||
exit:
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* i40e_remove_pd_bp - remove a backing page from a page descriptor
|
||||
* @hw: pointer to our HW structure
|
||||
* @hmc_info: pointer to the HMC configuration information structure
|
||||
* @idx: the page index
|
||||
* @is_pf: distinguishes a VF from a PF
|
||||
*
|
||||
* This function:
|
||||
* 1. Marks the entry in pd tabe (for paged address mode) or in sd table
|
||||
* (for direct address mode) invalid.
|
||||
* 2. Write to register PMPDINV to invalidate the backing page in FV cache
|
||||
* 3. Decrement the ref count for the pd _entry
|
||||
* assumptions:
|
||||
* 1. Caller can deallocate the memory used by backing storage after this
|
||||
* function returns.
|
||||
**/
|
||||
enum i40e_status_code i40e_remove_pd_bp(struct i40e_hw *hw,
|
||||
struct i40e_hmc_info *hmc_info,
|
||||
u32 idx)
|
||||
{
|
||||
enum i40e_status_code ret_code = I40E_SUCCESS;
|
||||
struct i40e_hmc_pd_entry *pd_entry;
|
||||
struct i40e_hmc_pd_table *pd_table;
|
||||
struct i40e_hmc_sd_entry *sd_entry;
|
||||
u32 sd_idx, rel_pd_idx;
|
||||
u64 *pd_addr;
|
||||
|
||||
/* calculate index */
|
||||
sd_idx = idx / I40E_HMC_PD_CNT_IN_SD;
|
||||
rel_pd_idx = idx % I40E_HMC_PD_CNT_IN_SD;
|
||||
if (sd_idx >= hmc_info->sd_table.sd_cnt) {
|
||||
ret_code = I40E_ERR_INVALID_PAGE_DESC_INDEX;
|
||||
DEBUGOUT("i40e_remove_pd_bp: bad idx\n");
|
||||
goto exit;
|
||||
}
|
||||
sd_entry = &hmc_info->sd_table.sd_entry[sd_idx];
|
||||
if (I40E_SD_TYPE_PAGED != sd_entry->entry_type) {
|
||||
ret_code = I40E_ERR_INVALID_SD_TYPE;
|
||||
DEBUGOUT("i40e_remove_pd_bp: wrong sd_entry type\n");
|
||||
goto exit;
|
||||
}
|
||||
/* get the entry and decrease its ref counter */
|
||||
pd_table = &hmc_info->sd_table.sd_entry[sd_idx].u.pd_table;
|
||||
pd_entry = &pd_table->pd_entry[rel_pd_idx];
|
||||
I40E_DEC_BP_REFCNT(&pd_entry->bp);
|
||||
if (pd_entry->bp.ref_cnt)
|
||||
goto exit;
|
||||
|
||||
/* mark the entry invalid */
|
||||
pd_entry->valid = FALSE;
|
||||
I40E_DEC_PD_REFCNT(pd_table);
|
||||
pd_addr = (u64 *)pd_table->pd_page_addr.va;
|
||||
pd_addr += rel_pd_idx;
|
||||
i40e_memset(pd_addr, 0, sizeof(u64), I40E_DMA_MEM);
|
||||
I40E_INVALIDATE_PF_HMC_PD(hw, sd_idx, idx);
|
||||
|
||||
/* free memory here */
|
||||
ret_code = i40e_free_dma_mem(hw, &(pd_entry->bp.addr));
|
||||
if (I40E_SUCCESS != ret_code)
|
||||
goto exit;
|
||||
if (!pd_table->ref_cnt)
|
||||
i40e_free_virt_mem(hw, &pd_table->pd_entry_virt_mem);
|
||||
exit:
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* i40e_prep_remove_sd_bp - Prepares to remove a backing page from a sd entry
|
||||
* @hmc_info: pointer to the HMC configuration information structure
|
||||
* @idx: the page index
|
||||
**/
|
||||
enum i40e_status_code i40e_prep_remove_sd_bp(struct i40e_hmc_info *hmc_info,
|
||||
u32 idx)
|
||||
{
|
||||
enum i40e_status_code ret_code = I40E_SUCCESS;
|
||||
struct i40e_hmc_sd_entry *sd_entry;
|
||||
|
||||
/* get the entry and decrease its ref counter */
|
||||
sd_entry = &hmc_info->sd_table.sd_entry[idx];
|
||||
I40E_DEC_BP_REFCNT(&sd_entry->u.bp);
|
||||
if (sd_entry->u.bp.ref_cnt) {
|
||||
ret_code = I40E_ERR_NOT_READY;
|
||||
goto exit;
|
||||
}
|
||||
I40E_DEC_SD_REFCNT(&hmc_info->sd_table);
|
||||
|
||||
/* mark the entry invalid */
|
||||
sd_entry->valid = FALSE;
|
||||
exit:
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* i40e_remove_sd_bp_new - Removes a backing page from a segment descriptor
|
||||
* @hw: pointer to our hw struct
|
||||
* @hmc_info: pointer to the HMC configuration information structure
|
||||
* @idx: the page index
|
||||
* @is_pf: used to distinguish between VF and PF
|
||||
**/
|
||||
enum i40e_status_code i40e_remove_sd_bp_new(struct i40e_hw *hw,
|
||||
struct i40e_hmc_info *hmc_info,
|
||||
u32 idx, bool is_pf)
|
||||
{
|
||||
struct i40e_hmc_sd_entry *sd_entry;
|
||||
enum i40e_status_code ret_code = I40E_SUCCESS;
|
||||
|
||||
/* get the entry and decrease its ref counter */
|
||||
sd_entry = &hmc_info->sd_table.sd_entry[idx];
|
||||
if (is_pf) {
|
||||
I40E_CLEAR_PF_SD_ENTRY(hw, idx, I40E_SD_TYPE_DIRECT);
|
||||
} else {
|
||||
ret_code = I40E_NOT_SUPPORTED;
|
||||
goto exit;
|
||||
}
|
||||
ret_code = i40e_free_dma_mem(hw, &(sd_entry->u.bp.addr));
|
||||
if (I40E_SUCCESS != ret_code)
|
||||
goto exit;
|
||||
exit:
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* i40e_prep_remove_pd_page - Prepares to remove a PD page from sd entry.
|
||||
* @hmc_info: pointer to the HMC configuration information structure
|
||||
* @idx: segment descriptor index to find the relevant page descriptor
|
||||
**/
|
||||
enum i40e_status_code i40e_prep_remove_pd_page(struct i40e_hmc_info *hmc_info,
|
||||
u32 idx)
|
||||
{
|
||||
enum i40e_status_code ret_code = I40E_SUCCESS;
|
||||
struct i40e_hmc_sd_entry *sd_entry;
|
||||
|
||||
sd_entry = &hmc_info->sd_table.sd_entry[idx];
|
||||
|
||||
if (sd_entry->u.pd_table.ref_cnt) {
|
||||
ret_code = I40E_ERR_NOT_READY;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* mark the entry invalid */
|
||||
sd_entry->valid = FALSE;
|
||||
|
||||
I40E_DEC_SD_REFCNT(&hmc_info->sd_table);
|
||||
exit:
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* i40e_remove_pd_page_new - Removes a PD page from sd entry.
|
||||
* @hw: pointer to our hw struct
|
||||
* @hmc_info: pointer to the HMC configuration information structure
|
||||
* @idx: segment descriptor index to find the relevant page descriptor
|
||||
* @is_pf: used to distinguish between VF and PF
|
||||
**/
|
||||
enum i40e_status_code i40e_remove_pd_page_new(struct i40e_hw *hw,
|
||||
struct i40e_hmc_info *hmc_info,
|
||||
u32 idx, bool is_pf)
|
||||
{
|
||||
enum i40e_status_code ret_code = I40E_SUCCESS;
|
||||
struct i40e_hmc_sd_entry *sd_entry;
|
||||
|
||||
sd_entry = &hmc_info->sd_table.sd_entry[idx];
|
||||
if (is_pf) {
|
||||
I40E_CLEAR_PF_SD_ENTRY(hw, idx, I40E_SD_TYPE_PAGED);
|
||||
} else {
|
||||
ret_code = I40E_NOT_SUPPORTED;
|
||||
goto exit;
|
||||
}
|
||||
/* free memory here */
|
||||
ret_code = i40e_free_dma_mem(hw, &(sd_entry->u.pd_table.pd_page_addr));
|
||||
if (I40E_SUCCESS != ret_code)
|
||||
goto exit;
|
||||
exit:
|
||||
return ret_code;
|
||||
}
|
245
sys/dev/i40e/i40e_hmc.h
Executable file
245
sys/dev/i40e/i40e_hmc.h
Executable file
@ -0,0 +1,245 @@
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (c) 2013-2014, Intel Corporation
|
||||
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 and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
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.
|
||||
|
||||
******************************************************************************/
|
||||
/*$FreeBSD$*/
|
||||
|
||||
#ifndef _I40E_HMC_H_
|
||||
#define _I40E_HMC_H_
|
||||
|
||||
#define I40E_HMC_MAX_BP_COUNT 512
|
||||
|
||||
/* forward-declare the HW struct for the compiler */
|
||||
struct i40e_hw;
|
||||
enum i40e_status_code;
|
||||
|
||||
#define I40E_HMC_INFO_SIGNATURE 0x484D5347 /* HMSG */
|
||||
#define I40E_HMC_PD_CNT_IN_SD 512
|
||||
#define I40E_HMC_DIRECT_BP_SIZE 0x200000 /* 2M */
|
||||
#define I40E_HMC_PAGED_BP_SIZE 4096
|
||||
#define I40E_HMC_PD_BP_BUF_ALIGNMENT 4096
|
||||
#define I40E_FIRST_VF_FPM_ID 16
|
||||
|
||||
struct i40e_hmc_obj_info {
|
||||
u64 base; /* base addr in FPM */
|
||||
u32 max_cnt; /* max count available for this hmc func */
|
||||
u32 cnt; /* count of objects driver actually wants to create */
|
||||
u64 size; /* size in bytes of one object */
|
||||
};
|
||||
|
||||
enum i40e_sd_entry_type {
|
||||
I40E_SD_TYPE_INVALID = 0,
|
||||
I40E_SD_TYPE_PAGED = 1,
|
||||
I40E_SD_TYPE_DIRECT = 2
|
||||
};
|
||||
|
||||
struct i40e_hmc_bp {
|
||||
enum i40e_sd_entry_type entry_type;
|
||||
struct i40e_dma_mem addr; /* populate to be used by hw */
|
||||
u32 sd_pd_index;
|
||||
u32 ref_cnt;
|
||||
};
|
||||
|
||||
struct i40e_hmc_pd_entry {
|
||||
struct i40e_hmc_bp bp;
|
||||
u32 sd_index;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
struct i40e_hmc_pd_table {
|
||||
struct i40e_dma_mem pd_page_addr; /* populate to be used by hw */
|
||||
struct i40e_hmc_pd_entry *pd_entry; /* [512] for sw book keeping */
|
||||
struct i40e_virt_mem pd_entry_virt_mem; /* virt mem for pd_entry */
|
||||
|
||||
u32 ref_cnt;
|
||||
u32 sd_index;
|
||||
};
|
||||
|
||||
struct i40e_hmc_sd_entry {
|
||||
enum i40e_sd_entry_type entry_type;
|
||||
bool valid;
|
||||
|
||||
union {
|
||||
struct i40e_hmc_pd_table pd_table;
|
||||
struct i40e_hmc_bp bp;
|
||||
} u;
|
||||
};
|
||||
|
||||
struct i40e_hmc_sd_table {
|
||||
struct i40e_virt_mem addr; /* used to track sd_entry allocations */
|
||||
u32 sd_cnt;
|
||||
u32 ref_cnt;
|
||||
struct i40e_hmc_sd_entry *sd_entry; /* (sd_cnt*512) entries max */
|
||||
};
|
||||
|
||||
struct i40e_hmc_info {
|
||||
u32 signature;
|
||||
/* equals to pci func num for PF and dynamically allocated for VFs */
|
||||
u8 hmc_fn_id;
|
||||
u16 first_sd_index; /* index of the first available SD */
|
||||
|
||||
/* hmc objects */
|
||||
struct i40e_hmc_obj_info *hmc_obj;
|
||||
struct i40e_virt_mem hmc_obj_virt_mem;
|
||||
struct i40e_hmc_sd_table sd_table;
|
||||
};
|
||||
|
||||
#define I40E_INC_SD_REFCNT(sd_table) ((sd_table)->ref_cnt++)
|
||||
#define I40E_INC_PD_REFCNT(pd_table) ((pd_table)->ref_cnt++)
|
||||
#define I40E_INC_BP_REFCNT(bp) ((bp)->ref_cnt++)
|
||||
|
||||
#define I40E_DEC_SD_REFCNT(sd_table) ((sd_table)->ref_cnt--)
|
||||
#define I40E_DEC_PD_REFCNT(pd_table) ((pd_table)->ref_cnt--)
|
||||
#define I40E_DEC_BP_REFCNT(bp) ((bp)->ref_cnt--)
|
||||
|
||||
/**
|
||||
* I40E_SET_PF_SD_ENTRY - marks the sd entry as valid in the hardware
|
||||
* @hw: pointer to our hw struct
|
||||
* @pa: pointer to physical address
|
||||
* @sd_index: segment descriptor index
|
||||
* @type: if sd entry is direct or paged
|
||||
**/
|
||||
#define I40E_SET_PF_SD_ENTRY(hw, pa, sd_index, type) \
|
||||
{ \
|
||||
u32 val1, val2, val3; \
|
||||
val1 = (u32)(I40E_HI_DWORD(pa)); \
|
||||
val2 = (u32)(pa) | (I40E_HMC_MAX_BP_COUNT << \
|
||||
I40E_PFHMC_SDDATALOW_PMSDBPCOUNT_SHIFT) | \
|
||||
((((type) == I40E_SD_TYPE_PAGED) ? 0 : 1) << \
|
||||
I40E_PFHMC_SDDATALOW_PMSDTYPE_SHIFT) | \
|
||||
(1 << I40E_PFHMC_SDDATALOW_PMSDVALID_SHIFT); \
|
||||
val3 = (sd_index) | (1 << I40E_PFHMC_SDCMD_PMSDWR_SHIFT); \
|
||||
wr32((hw), I40E_PFHMC_SDDATAHIGH, val1); \
|
||||
wr32((hw), I40E_PFHMC_SDDATALOW, val2); \
|
||||
wr32((hw), I40E_PFHMC_SDCMD, val3); \
|
||||
}
|
||||
|
||||
/**
|
||||
* I40E_CLEAR_PF_SD_ENTRY - marks the sd entry as invalid in the hardware
|
||||
* @hw: pointer to our hw struct
|
||||
* @sd_index: segment descriptor index
|
||||
* @type: if sd entry is direct or paged
|
||||
**/
|
||||
#define I40E_CLEAR_PF_SD_ENTRY(hw, sd_index, type) \
|
||||
{ \
|
||||
u32 val2, val3; \
|
||||
val2 = (I40E_HMC_MAX_BP_COUNT << \
|
||||
I40E_PFHMC_SDDATALOW_PMSDBPCOUNT_SHIFT) | \
|
||||
((((type) == I40E_SD_TYPE_PAGED) ? 0 : 1) << \
|
||||
I40E_PFHMC_SDDATALOW_PMSDTYPE_SHIFT); \
|
||||
val3 = (sd_index) | (1 << I40E_PFHMC_SDCMD_PMSDWR_SHIFT); \
|
||||
wr32((hw), I40E_PFHMC_SDDATAHIGH, 0); \
|
||||
wr32((hw), I40E_PFHMC_SDDATALOW, val2); \
|
||||
wr32((hw), I40E_PFHMC_SDCMD, val3); \
|
||||
}
|
||||
|
||||
/**
|
||||
* I40E_INVALIDATE_PF_HMC_PD - Invalidates the pd cache in the hardware
|
||||
* @hw: pointer to our hw struct
|
||||
* @sd_idx: segment descriptor index
|
||||
* @pd_idx: page descriptor index
|
||||
**/
|
||||
#define I40E_INVALIDATE_PF_HMC_PD(hw, sd_idx, pd_idx) \
|
||||
wr32((hw), I40E_PFHMC_PDINV, \
|
||||
(((sd_idx) << I40E_PFHMC_PDINV_PMSDIDX_SHIFT) | \
|
||||
((pd_idx) << I40E_PFHMC_PDINV_PMPDIDX_SHIFT)))
|
||||
|
||||
/**
|
||||
* I40E_FIND_SD_INDEX_LIMIT - finds segment descriptor index limit
|
||||
* @hmc_info: pointer to the HMC configuration information structure
|
||||
* @type: type of HMC resources we're searching
|
||||
* @index: starting index for the object
|
||||
* @cnt: number of objects we're trying to create
|
||||
* @sd_idx: pointer to return index of the segment descriptor in question
|
||||
* @sd_limit: pointer to return the maximum number of segment descriptors
|
||||
*
|
||||
* This function calculates the segment descriptor index and index limit
|
||||
* for the resource defined by i40e_hmc_rsrc_type.
|
||||
**/
|
||||
#define I40E_FIND_SD_INDEX_LIMIT(hmc_info, type, index, cnt, sd_idx, sd_limit)\
|
||||
{ \
|
||||
u64 fpm_addr, fpm_limit; \
|
||||
fpm_addr = (hmc_info)->hmc_obj[(type)].base + \
|
||||
(hmc_info)->hmc_obj[(type)].size * (index); \
|
||||
fpm_limit = fpm_addr + (hmc_info)->hmc_obj[(type)].size * (cnt);\
|
||||
*(sd_idx) = (u32)(fpm_addr / I40E_HMC_DIRECT_BP_SIZE); \
|
||||
*(sd_limit) = (u32)((fpm_limit - 1) / I40E_HMC_DIRECT_BP_SIZE); \
|
||||
/* add one more to the limit to correct our range */ \
|
||||
*(sd_limit) += 1; \
|
||||
}
|
||||
|
||||
/**
|
||||
* I40E_FIND_PD_INDEX_LIMIT - finds page descriptor index limit
|
||||
* @hmc_info: pointer to the HMC configuration information struct
|
||||
* @type: HMC resource type we're examining
|
||||
* @idx: starting index for the object
|
||||
* @cnt: number of objects we're trying to create
|
||||
* @pd_index: pointer to return page descriptor index
|
||||
* @pd_limit: pointer to return page descriptor index limit
|
||||
*
|
||||
* Calculates the page descriptor index and index limit for the resource
|
||||
* defined by i40e_hmc_rsrc_type.
|
||||
**/
|
||||
#define I40E_FIND_PD_INDEX_LIMIT(hmc_info, type, idx, cnt, pd_index, pd_limit)\
|
||||
{ \
|
||||
u64 fpm_adr, fpm_limit; \
|
||||
fpm_adr = (hmc_info)->hmc_obj[(type)].base + \
|
||||
(hmc_info)->hmc_obj[(type)].size * (idx); \
|
||||
fpm_limit = fpm_adr + (hmc_info)->hmc_obj[(type)].size * (cnt); \
|
||||
*(pd_index) = (u32)(fpm_adr / I40E_HMC_PAGED_BP_SIZE); \
|
||||
*(pd_limit) = (u32)((fpm_limit - 1) / I40E_HMC_PAGED_BP_SIZE); \
|
||||
/* add one more to the limit to correct our range */ \
|
||||
*(pd_limit) += 1; \
|
||||
}
|
||||
enum i40e_status_code i40e_add_sd_table_entry(struct i40e_hw *hw,
|
||||
struct i40e_hmc_info *hmc_info,
|
||||
u32 sd_index,
|
||||
enum i40e_sd_entry_type type,
|
||||
u64 direct_mode_sz);
|
||||
|
||||
enum i40e_status_code i40e_add_pd_table_entry(struct i40e_hw *hw,
|
||||
struct i40e_hmc_info *hmc_info,
|
||||
u32 pd_index);
|
||||
enum i40e_status_code i40e_remove_pd_bp(struct i40e_hw *hw,
|
||||
struct i40e_hmc_info *hmc_info,
|
||||
u32 idx);
|
||||
enum i40e_status_code i40e_prep_remove_sd_bp(struct i40e_hmc_info *hmc_info,
|
||||
u32 idx);
|
||||
enum i40e_status_code i40e_remove_sd_bp_new(struct i40e_hw *hw,
|
||||
struct i40e_hmc_info *hmc_info,
|
||||
u32 idx, bool is_pf);
|
||||
enum i40e_status_code i40e_prep_remove_pd_page(struct i40e_hmc_info *hmc_info,
|
||||
u32 idx);
|
||||
enum i40e_status_code i40e_remove_pd_page_new(struct i40e_hw *hw,
|
||||
struct i40e_hmc_info *hmc_info,
|
||||
u32 idx, bool is_pf);
|
||||
|
||||
#endif /* _I40E_HMC_H_ */
|
1122
sys/dev/i40e/i40e_lan_hmc.c
Executable file
1122
sys/dev/i40e/i40e_lan_hmc.c
Executable file
File diff suppressed because it is too large
Load Diff
194
sys/dev/i40e/i40e_lan_hmc.h
Executable file
194
sys/dev/i40e/i40e_lan_hmc.h
Executable file
@ -0,0 +1,194 @@
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (c) 2013-2014, Intel Corporation
|
||||
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 and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
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.
|
||||
|
||||
******************************************************************************/
|
||||
/*$FreeBSD$*/
|
||||
|
||||
#ifndef _I40E_LAN_HMC_H_
|
||||
#define _I40E_LAN_HMC_H_
|
||||
|
||||
/* forward-declare the HW struct for the compiler */
|
||||
struct i40e_hw;
|
||||
enum i40e_status_code;
|
||||
|
||||
/* HMC element context information */
|
||||
|
||||
/* Rx queue context data */
|
||||
struct i40e_hmc_obj_rxq {
|
||||
u16 head;
|
||||
u8 cpuid;
|
||||
u64 base;
|
||||
u16 qlen;
|
||||
#define I40E_RXQ_CTX_DBUFF_SHIFT 7
|
||||
u8 dbuff;
|
||||
#define I40E_RXQ_CTX_HBUFF_SHIFT 6
|
||||
u8 hbuff;
|
||||
u8 dtype;
|
||||
u8 dsize;
|
||||
u8 crcstrip;
|
||||
u8 fc_ena;
|
||||
u8 l2tsel;
|
||||
u8 hsplit_0;
|
||||
u8 hsplit_1;
|
||||
u8 showiv;
|
||||
u16 rxmax;
|
||||
u8 tphrdesc_ena;
|
||||
u8 tphwdesc_ena;
|
||||
u8 tphdata_ena;
|
||||
u8 tphhead_ena;
|
||||
u8 lrxqthresh;
|
||||
u8 prefena; /* NOTE: normally must be set to 1 at init */
|
||||
};
|
||||
|
||||
/* Tx queue context data */
|
||||
struct i40e_hmc_obj_txq {
|
||||
u16 head;
|
||||
u8 new_context;
|
||||
u64 base;
|
||||
u8 fc_ena;
|
||||
u8 timesync_ena;
|
||||
u8 fd_ena;
|
||||
u8 alt_vlan_ena;
|
||||
u16 thead_wb;
|
||||
u16 cpuid;
|
||||
u8 head_wb_ena;
|
||||
u16 qlen;
|
||||
u8 tphrdesc_ena;
|
||||
u8 tphrpacket_ena;
|
||||
u8 tphwdesc_ena;
|
||||
u64 head_wb_addr;
|
||||
u32 crc;
|
||||
u16 rdylist;
|
||||
u8 rdylist_act;
|
||||
};
|
||||
|
||||
/* for hsplit_0 field of Rx HMC context */
|
||||
enum i40e_hmc_obj_rx_hsplit_0 {
|
||||
I40E_HMC_OBJ_RX_HSPLIT_0_NO_SPLIT = 0,
|
||||
I40E_HMC_OBJ_RX_HSPLIT_0_SPLIT_L2 = 1,
|
||||
I40E_HMC_OBJ_RX_HSPLIT_0_SPLIT_IP = 2,
|
||||
I40E_HMC_OBJ_RX_HSPLIT_0_SPLIT_TCP_UDP = 4,
|
||||
I40E_HMC_OBJ_RX_HSPLIT_0_SPLIT_SCTP = 8,
|
||||
};
|
||||
|
||||
/* fcoe_cntx and fcoe_filt are for debugging purpose only */
|
||||
struct i40e_hmc_obj_fcoe_cntx {
|
||||
u32 rsv[32];
|
||||
};
|
||||
|
||||
struct i40e_hmc_obj_fcoe_filt {
|
||||
u32 rsv[8];
|
||||
};
|
||||
|
||||
/* Context sizes for LAN objects */
|
||||
enum i40e_hmc_lan_object_size {
|
||||
I40E_HMC_LAN_OBJ_SZ_8 = 0x3,
|
||||
I40E_HMC_LAN_OBJ_SZ_16 = 0x4,
|
||||
I40E_HMC_LAN_OBJ_SZ_32 = 0x5,
|
||||
I40E_HMC_LAN_OBJ_SZ_64 = 0x6,
|
||||
I40E_HMC_LAN_OBJ_SZ_128 = 0x7,
|
||||
I40E_HMC_LAN_OBJ_SZ_256 = 0x8,
|
||||
I40E_HMC_LAN_OBJ_SZ_512 = 0x9,
|
||||
};
|
||||
|
||||
#define I40E_HMC_L2OBJ_BASE_ALIGNMENT 512
|
||||
#define I40E_HMC_OBJ_SIZE_TXQ 128
|
||||
#define I40E_HMC_OBJ_SIZE_RXQ 32
|
||||
#ifdef FORTVILLE_A0_SUPPORT
|
||||
#define I40E_HMC_OBJ_SIZE_FCOE_CNTX 128
|
||||
#else
|
||||
#define I40E_HMC_OBJ_SIZE_FCOE_CNTX 64
|
||||
#endif
|
||||
#define I40E_HMC_OBJ_SIZE_FCOE_FILT 64
|
||||
|
||||
enum i40e_hmc_lan_rsrc_type {
|
||||
I40E_HMC_LAN_FULL = 0,
|
||||
I40E_HMC_LAN_TX = 1,
|
||||
I40E_HMC_LAN_RX = 2,
|
||||
I40E_HMC_FCOE_CTX = 3,
|
||||
I40E_HMC_FCOE_FILT = 4,
|
||||
I40E_HMC_LAN_MAX = 5
|
||||
};
|
||||
|
||||
enum i40e_hmc_model {
|
||||
I40E_HMC_MODEL_DIRECT_PREFERRED = 0,
|
||||
I40E_HMC_MODEL_DIRECT_ONLY = 1,
|
||||
I40E_HMC_MODEL_PAGED_ONLY = 2,
|
||||
I40E_HMC_MODEL_UNKNOWN,
|
||||
};
|
||||
|
||||
struct i40e_hmc_lan_create_obj_info {
|
||||
struct i40e_hmc_info *hmc_info;
|
||||
u32 rsrc_type;
|
||||
u32 start_idx;
|
||||
u32 count;
|
||||
enum i40e_sd_entry_type entry_type;
|
||||
u64 direct_mode_sz;
|
||||
};
|
||||
|
||||
struct i40e_hmc_lan_delete_obj_info {
|
||||
struct i40e_hmc_info *hmc_info;
|
||||
u32 rsrc_type;
|
||||
u32 start_idx;
|
||||
u32 count;
|
||||
};
|
||||
|
||||
enum i40e_status_code i40e_init_lan_hmc(struct i40e_hw *hw, u32 txq_num,
|
||||
u32 rxq_num, u32 fcoe_cntx_num,
|
||||
u32 fcoe_filt_num);
|
||||
enum i40e_status_code i40e_configure_lan_hmc(struct i40e_hw *hw,
|
||||
enum i40e_hmc_model model);
|
||||
enum i40e_status_code i40e_shutdown_lan_hmc(struct i40e_hw *hw);
|
||||
|
||||
u64 i40e_calculate_l2fpm_size(u32 txq_num, u32 rxq_num,
|
||||
u32 fcoe_cntx_num, u32 fcoe_filt_num);
|
||||
enum i40e_status_code i40e_get_lan_tx_queue_context(struct i40e_hw *hw,
|
||||
u16 queue,
|
||||
struct i40e_hmc_obj_txq *s);
|
||||
enum i40e_status_code i40e_clear_lan_tx_queue_context(struct i40e_hw *hw,
|
||||
u16 queue);
|
||||
enum i40e_status_code i40e_set_lan_tx_queue_context(struct i40e_hw *hw,
|
||||
u16 queue,
|
||||
struct i40e_hmc_obj_txq *s);
|
||||
enum i40e_status_code i40e_get_lan_rx_queue_context(struct i40e_hw *hw,
|
||||
u16 queue,
|
||||
struct i40e_hmc_obj_rxq *s);
|
||||
enum i40e_status_code i40e_clear_lan_rx_queue_context(struct i40e_hw *hw,
|
||||
u16 queue);
|
||||
enum i40e_status_code i40e_set_lan_rx_queue_context(struct i40e_hw *hw,
|
||||
u16 queue,
|
||||
struct i40e_hmc_obj_rxq *s);
|
||||
enum i40e_status_code i40e_create_lan_hmc_object(struct i40e_hw *hw,
|
||||
struct i40e_hmc_lan_create_obj_info *info);
|
||||
enum i40e_status_code i40e_delete_lan_hmc_object(struct i40e_hw *hw,
|
||||
struct i40e_hmc_lan_delete_obj_info *info);
|
||||
|
||||
#endif /* _I40E_LAN_HMC_H_ */
|
488
sys/dev/i40e/i40e_nvm.c
Executable file
488
sys/dev/i40e/i40e_nvm.c
Executable file
@ -0,0 +1,488 @@
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (c) 2013-2014, Intel Corporation
|
||||
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 and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
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.
|
||||
|
||||
******************************************************************************/
|
||||
/*$FreeBSD$*/
|
||||
|
||||
#include "i40e_prototype.h"
|
||||
|
||||
/**
|
||||
* i40e_init_nvm_ops - Initialize NVM function pointers
|
||||
* @hw: pointer to the HW structure
|
||||
*
|
||||
* Setup the function pointers and the NVM info structure. Should be called
|
||||
* once per NVM initialization, e.g. inside the i40e_init_shared_code().
|
||||
* Please notice that the NVM term is used here (& in all methods covered
|
||||
* in this file) as an equivalent of the FLASH part mapped into the SR.
|
||||
* We are accessing FLASH always thru the Shadow RAM.
|
||||
**/
|
||||
enum i40e_status_code i40e_init_nvm(struct i40e_hw *hw)
|
||||
{
|
||||
struct i40e_nvm_info *nvm = &hw->nvm;
|
||||
enum i40e_status_code ret_code = I40E_SUCCESS;
|
||||
u32 fla, gens;
|
||||
u8 sr_size;
|
||||
|
||||
DEBUGFUNC("i40e_init_nvm");
|
||||
|
||||
/* The SR size is stored regardless of the nvm programming mode
|
||||
* as the blank mode may be used in the factory line.
|
||||
*/
|
||||
gens = rd32(hw, I40E_GLNVM_GENS);
|
||||
sr_size = ((gens & I40E_GLNVM_GENS_SR_SIZE_MASK) >>
|
||||
I40E_GLNVM_GENS_SR_SIZE_SHIFT);
|
||||
/* Switching to words (sr_size contains power of 2KB) */
|
||||
nvm->sr_size = (1 << sr_size) * I40E_SR_WORDS_IN_1KB;
|
||||
|
||||
/* Check if we are in the normal or blank NVM programming mode */
|
||||
fla = rd32(hw, I40E_GLNVM_FLA);
|
||||
if (fla & I40E_GLNVM_FLA_LOCKED_MASK) { /* Normal programming mode */
|
||||
/* Max NVM timeout */
|
||||
nvm->timeout = I40E_MAX_NVM_TIMEOUT;
|
||||
nvm->blank_nvm_mode = FALSE;
|
||||
} else { /* Blank programming mode */
|
||||
nvm->blank_nvm_mode = TRUE;
|
||||
ret_code = I40E_ERR_NVM_BLANK_MODE;
|
||||
DEBUGOUT("NVM init error: unsupported blank mode.\n");
|
||||
}
|
||||
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* i40e_acquire_nvm - Generic request for acquiring the NVM ownership
|
||||
* @hw: pointer to the HW structure
|
||||
* @access: NVM access type (read or write)
|
||||
*
|
||||
* This function will request NVM ownership for reading
|
||||
* via the proper Admin Command.
|
||||
**/
|
||||
enum i40e_status_code i40e_acquire_nvm(struct i40e_hw *hw,
|
||||
enum i40e_aq_resource_access_type access)
|
||||
{
|
||||
enum i40e_status_code ret_code = I40E_SUCCESS;
|
||||
u64 gtime, timeout;
|
||||
u64 time = 0;
|
||||
|
||||
DEBUGFUNC("i40e_acquire_nvm");
|
||||
|
||||
if (hw->nvm.blank_nvm_mode)
|
||||
goto i40e_i40e_acquire_nvm_exit;
|
||||
|
||||
ret_code = i40e_aq_request_resource(hw, I40E_NVM_RESOURCE_ID, access,
|
||||
0, &time, NULL);
|
||||
/* Reading the Global Device Timer */
|
||||
gtime = rd32(hw, I40E_GLVFGEN_TIMER);
|
||||
|
||||
/* Store the timeout */
|
||||
hw->nvm.hw_semaphore_timeout = I40E_MS_TO_GTIME(time) + gtime;
|
||||
|
||||
if (ret_code != I40E_SUCCESS) {
|
||||
/* Set the polling timeout */
|
||||
if (time > I40E_MAX_NVM_TIMEOUT)
|
||||
timeout = I40E_MS_TO_GTIME(I40E_MAX_NVM_TIMEOUT)
|
||||
+ gtime;
|
||||
else
|
||||
timeout = hw->nvm.hw_semaphore_timeout;
|
||||
/* Poll until the current NVM owner timeouts */
|
||||
while (gtime < timeout) {
|
||||
i40e_msec_delay(10);
|
||||
ret_code = i40e_aq_request_resource(hw,
|
||||
I40E_NVM_RESOURCE_ID,
|
||||
access, 0, &time,
|
||||
NULL);
|
||||
if (ret_code == I40E_SUCCESS) {
|
||||
hw->nvm.hw_semaphore_timeout =
|
||||
I40E_MS_TO_GTIME(time) + gtime;
|
||||
break;
|
||||
}
|
||||
gtime = rd32(hw, I40E_GLVFGEN_TIMER);
|
||||
}
|
||||
if (ret_code != I40E_SUCCESS) {
|
||||
hw->nvm.hw_semaphore_timeout = 0;
|
||||
hw->nvm.hw_semaphore_wait =
|
||||
I40E_MS_TO_GTIME(time) + gtime;
|
||||
DEBUGOUT1("NVM acquire timed out, wait %llu ms before trying again.\n",
|
||||
time);
|
||||
}
|
||||
}
|
||||
|
||||
i40e_i40e_acquire_nvm_exit:
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* i40e_release_nvm - Generic request for releasing the NVM ownership
|
||||
* @hw: pointer to the HW structure
|
||||
*
|
||||
* This function will release NVM resource via the proper Admin Command.
|
||||
**/
|
||||
void i40e_release_nvm(struct i40e_hw *hw)
|
||||
{
|
||||
DEBUGFUNC("i40e_release_nvm");
|
||||
|
||||
if (!hw->nvm.blank_nvm_mode)
|
||||
i40e_aq_release_resource(hw, I40E_NVM_RESOURCE_ID, 0, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* i40e_poll_sr_srctl_done_bit - Polls the GLNVM_SRCTL done bit
|
||||
* @hw: pointer to the HW structure
|
||||
*
|
||||
* Polls the SRCTL Shadow RAM register done bit.
|
||||
**/
|
||||
static enum i40e_status_code i40e_poll_sr_srctl_done_bit(struct i40e_hw *hw)
|
||||
{
|
||||
enum i40e_status_code ret_code = I40E_ERR_TIMEOUT;
|
||||
u32 srctl, wait_cnt;
|
||||
|
||||
DEBUGFUNC("i40e_poll_sr_srctl_done_bit");
|
||||
|
||||
/* Poll the I40E_GLNVM_SRCTL until the done bit is set */
|
||||
for (wait_cnt = 0; wait_cnt < I40E_SRRD_SRCTL_ATTEMPTS; wait_cnt++) {
|
||||
srctl = rd32(hw, I40E_GLNVM_SRCTL);
|
||||
if (srctl & I40E_GLNVM_SRCTL_DONE_MASK) {
|
||||
ret_code = I40E_SUCCESS;
|
||||
break;
|
||||
}
|
||||
i40e_usec_delay(5);
|
||||
}
|
||||
if (ret_code == I40E_ERR_TIMEOUT)
|
||||
DEBUGOUT("Done bit in GLNVM_SRCTL not set");
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* i40e_read_nvm_word - Reads Shadow RAM
|
||||
* @hw: pointer to the HW structure
|
||||
* @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
|
||||
* @data: word read from the Shadow RAM
|
||||
*
|
||||
* Reads one 16 bit word from the Shadow RAM using the GLNVM_SRCTL register.
|
||||
**/
|
||||
enum i40e_status_code i40e_read_nvm_word(struct i40e_hw *hw, u16 offset,
|
||||
u16 *data)
|
||||
{
|
||||
enum i40e_status_code ret_code = I40E_ERR_TIMEOUT;
|
||||
u32 sr_reg;
|
||||
|
||||
DEBUGFUNC("i40e_read_nvm_srctl");
|
||||
|
||||
if (offset >= hw->nvm.sr_size) {
|
||||
DEBUGOUT("NVM read error: Offset beyond Shadow RAM limit.\n");
|
||||
ret_code = I40E_ERR_PARAM;
|
||||
goto read_nvm_exit;
|
||||
}
|
||||
|
||||
/* Poll the done bit first */
|
||||
ret_code = i40e_poll_sr_srctl_done_bit(hw);
|
||||
if (ret_code == I40E_SUCCESS) {
|
||||
/* Write the address and start reading */
|
||||
sr_reg = (u32)(offset << I40E_GLNVM_SRCTL_ADDR_SHIFT) |
|
||||
(1 << I40E_GLNVM_SRCTL_START_SHIFT);
|
||||
wr32(hw, I40E_GLNVM_SRCTL, sr_reg);
|
||||
|
||||
/* Poll I40E_GLNVM_SRCTL until the done bit is set */
|
||||
ret_code = i40e_poll_sr_srctl_done_bit(hw);
|
||||
if (ret_code == I40E_SUCCESS) {
|
||||
sr_reg = rd32(hw, I40E_GLNVM_SRDATA);
|
||||
*data = (u16)((sr_reg &
|
||||
I40E_GLNVM_SRDATA_RDDATA_MASK)
|
||||
>> I40E_GLNVM_SRDATA_RDDATA_SHIFT);
|
||||
}
|
||||
}
|
||||
if (ret_code != I40E_SUCCESS)
|
||||
DEBUGOUT1("NVM read error: Couldn't access Shadow RAM address: 0x%x\n",
|
||||
offset);
|
||||
|
||||
read_nvm_exit:
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* i40e_read_nvm_buffer - Reads Shadow RAM buffer
|
||||
* @hw: pointer to the HW structure
|
||||
* @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF).
|
||||
* @words: (in) number of words to read; (out) number of words actually read
|
||||
* @data: words read from the Shadow RAM
|
||||
*
|
||||
* Reads 16 bit words (data buffer) from the SR using the i40e_read_nvm_srrd()
|
||||
* method. The buffer read is preceded by the NVM ownership take
|
||||
* and followed by the release.
|
||||
**/
|
||||
enum i40e_status_code i40e_read_nvm_buffer(struct i40e_hw *hw, u16 offset,
|
||||
u16 *words, u16 *data)
|
||||
{
|
||||
enum i40e_status_code ret_code = I40E_SUCCESS;
|
||||
u16 index, word;
|
||||
|
||||
DEBUGFUNC("i40e_read_nvm_buffer");
|
||||
|
||||
/* Loop thru the selected region */
|
||||
for (word = 0; word < *words; word++) {
|
||||
index = offset + word;
|
||||
ret_code = i40e_read_nvm_word(hw, index, &data[word]);
|
||||
if (ret_code != I40E_SUCCESS)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update the number of words read from the Shadow RAM */
|
||||
*words = word;
|
||||
|
||||
return ret_code;
|
||||
}
|
||||
/**
|
||||
* i40e_write_nvm_aq - Writes Shadow RAM.
|
||||
* @hw: pointer to the HW structure.
|
||||
* @module_pointer: module pointer location in words from the NVM beginning
|
||||
* @offset: offset in words from module start
|
||||
* @words: number of words to write
|
||||
* @data: buffer with words to write to the Shadow RAM
|
||||
* @last_command: tells the AdminQ that this is the last command
|
||||
*
|
||||
* Writes a 16 bit words buffer to the Shadow RAM using the admin command.
|
||||
**/
|
||||
enum i40e_status_code i40e_write_nvm_aq(struct i40e_hw *hw, u8 module_pointer,
|
||||
u32 offset, u16 words, void *data,
|
||||
bool last_command)
|
||||
{
|
||||
enum i40e_status_code ret_code = I40E_ERR_NVM;
|
||||
|
||||
DEBUGFUNC("i40e_write_nvm_aq");
|
||||
|
||||
/* Here we are checking the SR limit only for the flat memory model.
|
||||
* We cannot do it for the module-based model, as we did not acquire
|
||||
* the NVM resource yet (we cannot get the module pointer value).
|
||||
* Firmware will check the module-based model.
|
||||
*/
|
||||
if ((offset + words) > hw->nvm.sr_size)
|
||||
DEBUGOUT("NVM write error: offset beyond Shadow RAM limit.\n");
|
||||
else if (words > I40E_SR_SECTOR_SIZE_IN_WORDS)
|
||||
/* We can write only up to 4KB (one sector), in one AQ write */
|
||||
DEBUGOUT("NVM write fail error: cannot write more than 4KB in a single write.\n");
|
||||
else if (((offset + (words - 1)) / I40E_SR_SECTOR_SIZE_IN_WORDS)
|
||||
!= (offset / I40E_SR_SECTOR_SIZE_IN_WORDS))
|
||||
/* A single write cannot spread over two sectors */
|
||||
DEBUGOUT("NVM write error: cannot spread over two sectors in a single write.\n");
|
||||
else
|
||||
ret_code = i40e_aq_update_nvm(hw, module_pointer,
|
||||
2 * offset, /*bytes*/
|
||||
2 * words, /*bytes*/
|
||||
data, last_command, NULL);
|
||||
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* i40e_write_nvm_word - Writes Shadow RAM word
|
||||
* @hw: pointer to the HW structure
|
||||
* @offset: offset of the Shadow RAM word to write
|
||||
* @data: word to write to the Shadow RAM
|
||||
*
|
||||
* Writes a 16 bit word to the SR using the i40e_write_nvm_aq() method.
|
||||
* NVM ownership have to be acquired and released (on ARQ completion event
|
||||
* reception) by caller. To commit SR to NVM update checksum function
|
||||
* should be called.
|
||||
**/
|
||||
enum i40e_status_code i40e_write_nvm_word(struct i40e_hw *hw, u32 offset,
|
||||
void *data)
|
||||
{
|
||||
DEBUGFUNC("i40e_write_nvm_word");
|
||||
|
||||
/* Value 0x00 below means that we treat SR as a flat mem */
|
||||
return i40e_write_nvm_aq(hw, 0x00, offset, 1, data, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* i40e_write_nvm_buffer - Writes Shadow RAM buffer
|
||||
* @hw: pointer to the HW structure
|
||||
* @module_pointer: module pointer location in words from the NVM beginning
|
||||
* @offset: offset of the Shadow RAM buffer to write
|
||||
* @words: number of words to write
|
||||
* @data: words to write to the Shadow RAM
|
||||
*
|
||||
* Writes a 16 bit words buffer to the Shadow RAM using the admin command.
|
||||
* NVM ownership must be acquired before calling this function and released
|
||||
* on ARQ completion event reception by caller. To commit SR to NVM update
|
||||
* checksum function should be called.
|
||||
**/
|
||||
enum i40e_status_code i40e_write_nvm_buffer(struct i40e_hw *hw,
|
||||
u8 module_pointer, u32 offset,
|
||||
u16 words, void *data)
|
||||
{
|
||||
DEBUGFUNC("i40e_write_nvm_buffer");
|
||||
|
||||
/* Here we will only write one buffer as the size of the modules
|
||||
* mirrored in the Shadow RAM is always less than 4K.
|
||||
*/
|
||||
return i40e_write_nvm_aq(hw, module_pointer, offset, words,
|
||||
data, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* i40e_calc_nvm_checksum - Calculates and returns the checksum
|
||||
* @hw: pointer to hardware structure
|
||||
* @checksum: pointer to the checksum
|
||||
*
|
||||
* This function calculates SW Checksum that covers the whole 64kB shadow RAM
|
||||
* except the VPD and PCIe ALT Auto-load modules. The structure and size of VPD
|
||||
* is customer specific and unknown. Therefore, this function skips all maximum
|
||||
* possible size of VPD (1kB).
|
||||
**/
|
||||
enum i40e_status_code i40e_calc_nvm_checksum(struct i40e_hw *hw, u16 *checksum)
|
||||
{
|
||||
enum i40e_status_code ret_code = I40E_SUCCESS;
|
||||
u16 pcie_alt_module = 0;
|
||||
u16 checksum_local = 0;
|
||||
u16 vpd_module = 0;
|
||||
u16 word = 0;
|
||||
u32 i = 0;
|
||||
|
||||
DEBUGFUNC("i40e_calc_nvm_checksum");
|
||||
|
||||
/* read pointer to VPD area */
|
||||
ret_code = i40e_read_nvm_word(hw, I40E_SR_VPD_PTR, &vpd_module);
|
||||
if (ret_code != I40E_SUCCESS) {
|
||||
ret_code = I40E_ERR_NVM_CHECKSUM;
|
||||
goto i40e_calc_nvm_checksum_exit;
|
||||
}
|
||||
|
||||
/* read pointer to PCIe Alt Auto-load module */
|
||||
ret_code = i40e_read_nvm_word(hw, I40E_SR_PCIE_ALT_AUTO_LOAD_PTR,
|
||||
&pcie_alt_module);
|
||||
if (ret_code != I40E_SUCCESS) {
|
||||
ret_code = I40E_ERR_NVM_CHECKSUM;
|
||||
goto i40e_calc_nvm_checksum_exit;
|
||||
}
|
||||
|
||||
/* Calculate SW checksum that covers the whole 64kB shadow RAM
|
||||
* except the VPD and PCIe ALT Auto-load modules
|
||||
*/
|
||||
for (i = 0; i < hw->nvm.sr_size; i++) {
|
||||
/* Skip Checksum word */
|
||||
if (i == I40E_SR_SW_CHECKSUM_WORD)
|
||||
i++;
|
||||
/* Skip VPD module (convert byte size to word count) */
|
||||
if (i == (u32)vpd_module) {
|
||||
i += (I40E_SR_VPD_MODULE_MAX_SIZE / 2);
|
||||
if (i >= hw->nvm.sr_size)
|
||||
break;
|
||||
}
|
||||
/* Skip PCIe ALT module (convert byte size to word count) */
|
||||
if (i == (u32)pcie_alt_module) {
|
||||
i += (I40E_SR_PCIE_ALT_MODULE_MAX_SIZE / 2);
|
||||
if (i >= hw->nvm.sr_size)
|
||||
break;
|
||||
}
|
||||
|
||||
ret_code = i40e_read_nvm_word(hw, (u16)i, &word);
|
||||
if (ret_code != I40E_SUCCESS) {
|
||||
ret_code = I40E_ERR_NVM_CHECKSUM;
|
||||
goto i40e_calc_nvm_checksum_exit;
|
||||
}
|
||||
checksum_local += word;
|
||||
}
|
||||
|
||||
*checksum = (u16)I40E_SR_SW_CHECKSUM_BASE - checksum_local;
|
||||
|
||||
i40e_calc_nvm_checksum_exit:
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* i40e_update_nvm_checksum - Updates the NVM checksum
|
||||
* @hw: pointer to hardware structure
|
||||
*
|
||||
* NVM ownership must be acquired before calling this function and released
|
||||
* on ARQ completion event reception by caller.
|
||||
* This function will commit SR to NVM.
|
||||
**/
|
||||
enum i40e_status_code i40e_update_nvm_checksum(struct i40e_hw *hw)
|
||||
{
|
||||
enum i40e_status_code ret_code = I40E_SUCCESS;
|
||||
u16 checksum;
|
||||
|
||||
DEBUGFUNC("i40e_update_nvm_checksum");
|
||||
|
||||
ret_code = i40e_calc_nvm_checksum(hw, &checksum);
|
||||
if (ret_code == I40E_SUCCESS)
|
||||
ret_code = i40e_write_nvm_aq(hw, 0x00, I40E_SR_SW_CHECKSUM_WORD,
|
||||
1, &checksum, TRUE);
|
||||
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* i40e_validate_nvm_checksum - Validate EEPROM checksum
|
||||
* @hw: pointer to hardware structure
|
||||
* @checksum: calculated checksum
|
||||
*
|
||||
* Performs checksum calculation and validates the NVM SW checksum. If the
|
||||
* caller does not need checksum, the value can be NULL.
|
||||
**/
|
||||
enum i40e_status_code i40e_validate_nvm_checksum(struct i40e_hw *hw,
|
||||
u16 *checksum)
|
||||
{
|
||||
enum i40e_status_code ret_code = I40E_SUCCESS;
|
||||
u16 checksum_sr = 0;
|
||||
u16 checksum_local = 0;
|
||||
|
||||
DEBUGFUNC("i40e_validate_nvm_checksum");
|
||||
|
||||
ret_code = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
|
||||
if (ret_code != I40E_SUCCESS)
|
||||
goto i40e_validate_nvm_checksum_exit;
|
||||
|
||||
ret_code = i40e_calc_nvm_checksum(hw, &checksum_local);
|
||||
if (ret_code != I40E_SUCCESS)
|
||||
goto i40e_validate_nvm_checksum_free;
|
||||
|
||||
/* Do not use i40e_read_nvm_word() because we do not want to take
|
||||
* the synchronization semaphores twice here.
|
||||
*/
|
||||
i40e_read_nvm_word(hw, I40E_SR_SW_CHECKSUM_WORD, &checksum_sr);
|
||||
|
||||
/* Verify read checksum from EEPROM is the same as
|
||||
* calculated checksum
|
||||
*/
|
||||
if (checksum_local != checksum_sr)
|
||||
ret_code = I40E_ERR_NVM_CHECKSUM;
|
||||
|
||||
/* If the user cares, return the calculated checksum */
|
||||
if (checksum)
|
||||
*checksum = checksum_local;
|
||||
|
||||
i40e_validate_nvm_checksum_free:
|
||||
i40e_release_nvm(hw);
|
||||
|
||||
i40e_validate_nvm_checksum_exit:
|
||||
return ret_code;
|
||||
}
|
198
sys/dev/i40e/i40e_osdep.c
Executable file
198
sys/dev/i40e/i40e_osdep.c
Executable file
@ -0,0 +1,198 @@
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (c) 2013-2014, Intel Corporation
|
||||
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 and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
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.
|
||||
|
||||
******************************************************************************/
|
||||
/*$FreeBSD$*/
|
||||
|
||||
#include <machine/stdarg.h>
|
||||
|
||||
#include "i40e.h"
|
||||
|
||||
/********************************************************************
|
||||
* Manage DMA'able memory.
|
||||
*******************************************************************/
|
||||
static void
|
||||
i40e_dmamap_cb(void *arg, bus_dma_segment_t * segs, int nseg, int error)
|
||||
{
|
||||
if (error)
|
||||
return;
|
||||
*(bus_addr_t *) arg = segs->ds_addr;
|
||||
return;
|
||||
}
|
||||
|
||||
i40e_status
|
||||
i40e_allocate_virt(struct i40e_hw *hw, struct i40e_virt_mem *m, u32 size)
|
||||
{
|
||||
m->va = malloc(size, M_DEVBUF, M_NOWAIT | M_ZERO);
|
||||
return(m->va == NULL);
|
||||
}
|
||||
|
||||
i40e_status
|
||||
i40e_free_virt(struct i40e_hw *hw, struct i40e_virt_mem *m)
|
||||
{
|
||||
free(m->va, M_DEVBUF);
|
||||
return(0);
|
||||
}
|
||||
|
||||
i40e_status
|
||||
i40e_allocate_dma(struct i40e_hw *hw, struct i40e_dma_mem *dma,
|
||||
bus_size_t size, u32 alignment)
|
||||
{
|
||||
device_t dev = ((struct i40e_osdep *)hw->back)->dev;
|
||||
int err;
|
||||
|
||||
|
||||
err = bus_dma_tag_create(bus_get_dma_tag(dev), /* parent */
|
||||
alignment, 0, /* alignment, bounds */
|
||||
BUS_SPACE_MAXADDR, /* lowaddr */
|
||||
BUS_SPACE_MAXADDR, /* highaddr */
|
||||
NULL, NULL, /* filter, filterarg */
|
||||
size, /* maxsize */
|
||||
1, /* nsegments */
|
||||
size, /* maxsegsize */
|
||||
BUS_DMA_ALLOCNOW, /* flags */
|
||||
NULL, /* lockfunc */
|
||||
NULL, /* lockfuncarg */
|
||||
&dma->tag);
|
||||
if (err != 0) {
|
||||
device_printf(dev,
|
||||
"i40e_allocate_dma: bus_dma_tag_create failed, "
|
||||
"error %u\n", err);
|
||||
goto fail_0;
|
||||
}
|
||||
err = bus_dmamem_alloc(dma->tag, (void **)&dma->va,
|
||||
BUS_DMA_NOWAIT | M_ZERO, &dma->map);
|
||||
if (err != 0) {
|
||||
device_printf(dev,
|
||||
"i40e_allocate_dma: bus_dmamem_alloc failed, "
|
||||
"error %u\n", err);
|
||||
goto fail_1;
|
||||
}
|
||||
err = bus_dmamap_load(dma->tag, dma->map, dma->va,
|
||||
size,
|
||||
i40e_dmamap_cb,
|
||||
&dma->pa,
|
||||
BUS_DMA_NOWAIT);
|
||||
if (err != 0) {
|
||||
device_printf(dev,
|
||||
"i40e_allocate_dma: bus_dmamap_load failed, "
|
||||
"error %u\n", err);
|
||||
goto fail_2;
|
||||
}
|
||||
dma->size = size;
|
||||
bus_dmamap_sync(dma->tag, dma->map,
|
||||
BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
|
||||
return (0);
|
||||
fail_2:
|
||||
bus_dmamem_free(dma->tag, dma->va, dma->map);
|
||||
fail_1:
|
||||
bus_dma_tag_destroy(dma->tag);
|
||||
fail_0:
|
||||
dma->map = NULL;
|
||||
dma->tag = NULL;
|
||||
return (err);
|
||||
}
|
||||
|
||||
i40e_status
|
||||
i40e_free_dma(struct i40e_hw *hw, struct i40e_dma_mem *dma)
|
||||
{
|
||||
bus_dmamap_sync(dma->tag, dma->map,
|
||||
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
|
||||
bus_dmamap_unload(dma->tag, dma->map);
|
||||
bus_dmamem_free(dma->tag, dma->va, dma->map);
|
||||
bus_dma_tag_destroy(dma->tag);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
i40e_init_spinlock(struct i40e_spinlock *lock)
|
||||
{
|
||||
mtx_init(&lock->mutex, "mutex",
|
||||
MTX_NETWORK_LOCK, MTX_DEF | MTX_DUPOK);
|
||||
}
|
||||
|
||||
void
|
||||
i40e_acquire_spinlock(struct i40e_spinlock *lock)
|
||||
{
|
||||
mtx_lock(&lock->mutex);
|
||||
}
|
||||
|
||||
void
|
||||
i40e_release_spinlock(struct i40e_spinlock *lock)
|
||||
{
|
||||
mtx_unlock(&lock->mutex);
|
||||
}
|
||||
|
||||
void
|
||||
i40e_destroy_spinlock(struct i40e_spinlock *lock)
|
||||
{
|
||||
mtx_destroy(&lock->mutex);
|
||||
}
|
||||
|
||||
/*
|
||||
** i40e_debug_d - OS dependent version of shared code debug printing
|
||||
*/
|
||||
void i40e_debug_d(void *hw, u32 mask, char *fmt, ...)
|
||||
{
|
||||
char buf[512];
|
||||
va_list args;
|
||||
|
||||
if (!(mask & ((struct i40e_hw *)hw)->debug_mask))
|
||||
return;
|
||||
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
/* the debug string is already formatted with a newline */
|
||||
printf("%s", buf);
|
||||
}
|
||||
|
||||
u16
|
||||
i40e_read_pci_cfg(struct i40e_hw *hw, u32 reg)
|
||||
{
|
||||
u16 value;
|
||||
|
||||
value = pci_read_config(((struct i40e_osdep *)hw->back)->dev,
|
||||
reg, 2);
|
||||
|
||||
return (value);
|
||||
}
|
||||
|
||||
void
|
||||
i40e_write_pci_cfg(struct i40e_hw *hw, u32 reg, u16 value)
|
||||
{
|
||||
pci_write_config(((struct i40e_osdep *)hw->back)->dev,
|
||||
reg, value, 2);
|
||||
|
||||
return;
|
||||
}
|
||||
|
211
sys/dev/i40e/i40e_osdep.h
Executable file
211
sys/dev/i40e/i40e_osdep.h
Executable file
@ -0,0 +1,211 @@
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (c) 2013-2014, Intel Corporation
|
||||
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 and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
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.
|
||||
|
||||
******************************************************************************/
|
||||
/*$FreeBSD$*/
|
||||
|
||||
#ifndef _I40E_OSDEP_H_
|
||||
#define _I40E_OSDEP_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/bus.h>
|
||||
#include <machine/bus.h>
|
||||
#include <sys/rman.h>
|
||||
#include <machine/resource.h>
|
||||
#include <vm/vm.h>
|
||||
#include <vm/pmap.h>
|
||||
#include <machine/clock.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/pci/pcireg.h>
|
||||
|
||||
#define ASSERT(x) if(!(x)) panic("I40E: x")
|
||||
|
||||
/* The happy-fun DELAY macro is defined in /usr/src/sys/i386/include/clock.h */
|
||||
#define i40e_usec_delay(x) DELAY(x)
|
||||
#define i40e_msec_delay(x) DELAY(1000*(x))
|
||||
|
||||
#define DBG 0
|
||||
#define MSGOUT(S, A, B) printf(S "\n", A, B)
|
||||
#define DEBUGFUNC(F) DEBUGOUT(F);
|
||||
#if DBG
|
||||
#define DEBUGOUT(S) printf(S "\n")
|
||||
#define DEBUGOUT1(S,A) printf(S "\n",A)
|
||||
#define DEBUGOUT2(S,A,B) printf(S "\n",A,B)
|
||||
#define DEBUGOUT3(S,A,B,C) printf(S "\n",A,B,C)
|
||||
#define DEBUGOUT7(S,A,B,C,D,E,F,G) printf(S "\n",A,B,C,D,E,F,G)
|
||||
#else
|
||||
#define DEBUGOUT(S)
|
||||
#define DEBUGOUT1(S,A)
|
||||
#define DEBUGOUT2(S,A,B)
|
||||
#define DEBUGOUT3(S,A,B,C)
|
||||
#define DEBUGOUT6(S,A,B,C,D,E,F)
|
||||
#define DEBUGOUT7(S,A,B,C,D,E,F,G)
|
||||
#endif
|
||||
|
||||
#define UNREFERENCED_XPARAMETER
|
||||
#define UNREFERENCED_PARAMETER(_p)
|
||||
#define UNREFERENCED_1PARAMETER(_p)
|
||||
#define UNREFERENCED_2PARAMETER(_p, _q)
|
||||
#define UNREFERENCED_3PARAMETER(_p, _q, _r)
|
||||
#define UNREFERENCED_4PARAMETER(_p, _q, _r, _s)
|
||||
|
||||
#define STATIC static
|
||||
#define INLINE inline
|
||||
|
||||
#define FALSE 0
|
||||
#define false 0 /* shared code requires this */
|
||||
#define TRUE 1
|
||||
#define true 1
|
||||
#define CMD_MEM_WRT_INVALIDATE 0x0010 /* BIT_4 */
|
||||
#define PCI_COMMAND_REGISTER PCIR_COMMAND
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
|
||||
#define i40e_memset(a, b, c, d) memset((a), (b), (c))
|
||||
#define i40e_memcpy(a, b, c, d) memcpy((a), (b), (c))
|
||||
|
||||
#define CPU_TO_LE16(o) htole16(o)
|
||||
#define CPU_TO_LE32(s) htole32(s)
|
||||
#define CPU_TO_LE64(h) htole64(h)
|
||||
#define LE16_TO_CPU(a) le16toh(a)
|
||||
#define LE32_TO_CPU(c) le32toh(c)
|
||||
#define LE64_TO_CPU(k) le64toh(k)
|
||||
|
||||
#define I40E_NTOHS(a) ntohs(a)
|
||||
#define I40E_NTOHL(a) ntohl(a)
|
||||
#define I40E_HTONS(a) htons(a)
|
||||
#define I40E_HTONL(a) htonl(a)
|
||||
|
||||
#define FIELD_SIZEOF(x, y) (sizeof(((x*)0)->y))
|
||||
|
||||
typedef uint8_t u8;
|
||||
typedef int8_t s8;
|
||||
typedef uint16_t u16;
|
||||
typedef int16_t s16;
|
||||
typedef uint32_t u32;
|
||||
typedef int32_t s32;
|
||||
typedef uint64_t u64;
|
||||
|
||||
/* long string relief */
|
||||
typedef enum i40e_status_code i40e_status;
|
||||
|
||||
#define __le16 u16
|
||||
#define __le32 u32
|
||||
#define __le64 u64
|
||||
#define __be16 u16
|
||||
#define __be32 u32
|
||||
#define __be64 u64
|
||||
|
||||
/* SW spinlock */
|
||||
struct i40e_spinlock {
|
||||
struct mtx mutex;
|
||||
};
|
||||
|
||||
#define le16_to_cpu
|
||||
|
||||
static __inline
|
||||
void prefetch(void *x)
|
||||
{
|
||||
__asm volatile("prefetcht0 %0" :: "m" (*(unsigned long *)x));
|
||||
}
|
||||
|
||||
struct i40e_osdep
|
||||
{
|
||||
bus_space_tag_t mem_bus_space_tag;
|
||||
bus_space_handle_t mem_bus_space_handle;
|
||||
struct device *dev;
|
||||
};
|
||||
|
||||
struct i40e_dma_mem {
|
||||
void *va;
|
||||
u64 pa;
|
||||
bus_dma_tag_t tag;
|
||||
bus_dmamap_t map;
|
||||
bus_dma_segment_t seg;
|
||||
bus_size_t size;
|
||||
int nseg;
|
||||
int flags;
|
||||
};
|
||||
|
||||
struct i40e_hw; /* forward decl */
|
||||
u16 i40e_read_pci_cfg(struct i40e_hw *, u32);
|
||||
void i40e_write_pci_cfg(struct i40e_hw *, u32, u16);
|
||||
|
||||
#define I40E_READ_PCIE_WORD i40e_read_pci_cfg
|
||||
|
||||
#define i40e_allocate_dma_mem(h, m, unused, s, a) i40e_allocate_dma(h, m, s, a)
|
||||
#define i40e_free_dma_mem(h, m) i40e_free_dma(h, m)
|
||||
|
||||
#define i40e_debug(h, m, s, ...) i40e_debug_d(h, m, s, ##__VA_ARGS__)
|
||||
extern void i40e_debug_d(void *hw, u32 mask, char *fmt_str, ...);
|
||||
|
||||
struct i40e_virt_mem {
|
||||
void *va;
|
||||
u32 size;
|
||||
};
|
||||
#define i40e_allocate_virt_mem(h, m, s) i40e_allocate_virt(h, m, s)
|
||||
#define i40e_free_virt_mem(h, m) i40e_free_virt(h, m)
|
||||
|
||||
#define i40e_rx_desc i40e_32byte_rx_desc
|
||||
|
||||
#define rd32(a, reg) (\
|
||||
bus_space_read_4( ((struct i40e_osdep *)(a)->back)->mem_bus_space_tag, \
|
||||
((struct i40e_osdep *)(a)->back)->mem_bus_space_handle, \
|
||||
reg))
|
||||
|
||||
#define wr32(a, reg, value) (\
|
||||
bus_space_write_4( ((struct i40e_osdep *)(a)->back)->mem_bus_space_tag, \
|
||||
((struct i40e_osdep *)(a)->back)->mem_bus_space_handle, \
|
||||
reg, value))
|
||||
|
||||
#define rd64(a, reg) (\
|
||||
bus_space_read_8( ((struct i40e_osdep *)(a)->back)->mem_bus_space_tag, \
|
||||
((struct i40e_osdep *)(a)->back)->mem_bus_space_handle, \
|
||||
reg))
|
||||
|
||||
#define wr64(a, reg, value) (\
|
||||
bus_space_write_8( ((struct i40e_osdep *)(a)->back)->mem_bus_space_tag, \
|
||||
((struct i40e_osdep *)(a)->back)->mem_bus_space_handle, \
|
||||
reg, value))
|
||||
|
||||
#define i40e_flush(a) (\
|
||||
bus_space_read_4( ((struct i40e_osdep *)(a)->back)->mem_bus_space_tag, \
|
||||
((struct i40e_osdep *)(a)->back)->mem_bus_space_handle, \
|
||||
I40E_GLGEN_STAT))
|
||||
|
||||
#endif /* _I40E_OSDEP_H_ */
|
94
sys/dev/i40e/i40e_pf.h
Executable file
94
sys/dev/i40e/i40e_pf.h
Executable file
@ -0,0 +1,94 @@
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (c) 2013-2014, Intel Corporation
|
||||
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 and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
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.
|
||||
|
||||
******************************************************************************/
|
||||
/*$FreeBSD$*/
|
||||
|
||||
|
||||
#ifndef _I40E_PF_H_
|
||||
#define _I40E_PF_H_
|
||||
|
||||
/* Physical controller structure */
|
||||
struct i40e_pf {
|
||||
struct i40e_hw hw;
|
||||
struct i40e_osdep osdep;
|
||||
struct device *dev;
|
||||
|
||||
struct resource *pci_mem;
|
||||
struct resource *msix_mem;
|
||||
|
||||
/*
|
||||
* Interrupt resources: this set is
|
||||
* either used for legacy, or for Link
|
||||
* when doing MSIX
|
||||
*/
|
||||
void *tag;
|
||||
struct resource *res;
|
||||
|
||||
struct callout timer;
|
||||
int msix;
|
||||
int if_flags;
|
||||
|
||||
struct mtx pf_mtx;
|
||||
|
||||
u32 qbase;
|
||||
u32 admvec;
|
||||
struct task adminq;
|
||||
struct taskqueue *tq;
|
||||
|
||||
/*
|
||||
** VSI - Stations:
|
||||
** These are the traffic class holders, and
|
||||
** will have a stack interface and queues
|
||||
** associated with them.
|
||||
** NOTE: for now using just one, so embed it.
|
||||
*/
|
||||
struct i40e_vsi vsi;
|
||||
|
||||
/* Misc stats maintained by the driver */
|
||||
u64 watchdog_events;
|
||||
u64 admin_irq;
|
||||
|
||||
/* Statistics from hw */
|
||||
struct i40e_hw_port_stats stats;
|
||||
struct i40e_hw_port_stats stats_offsets;
|
||||
bool stat_offsets_loaded;
|
||||
};
|
||||
|
||||
|
||||
#define I40E_PF_LOCK_INIT(_sc, _name) \
|
||||
mtx_init(&(_sc)->pf_mtx, _name, "I40E PF Lock", MTX_DEF)
|
||||
#define I40E_PF_LOCK(_sc) mtx_lock(&(_sc)->pf_mtx)
|
||||
#define I40E_PF_UNLOCK(_sc) mtx_unlock(&(_sc)->pf_mtx)
|
||||
#define I40E_PF_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->pf_mtx)
|
||||
#define I40E_PF_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->pf_mtx, MA_OWNED)
|
||||
|
||||
#endif /* _I40E_PF_H_ */
|
439
sys/dev/i40e/i40e_prototype.h
Executable file
439
sys/dev/i40e/i40e_prototype.h
Executable file
@ -0,0 +1,439 @@
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (c) 2013-2014, Intel Corporation
|
||||
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 and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
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.
|
||||
|
||||
******************************************************************************/
|
||||
/*$FreeBSD$*/
|
||||
|
||||
#ifndef _I40E_PROTOTYPE_H_
|
||||
#define _I40E_PROTOTYPE_H_
|
||||
|
||||
#include "i40e_type.h"
|
||||
#include "i40e_alloc.h"
|
||||
#include "i40e_virtchnl.h"
|
||||
|
||||
/* Prototypes for shared code functions that are not in
|
||||
* the standard function pointer structures. These are
|
||||
* mostly because they are needed even before the init
|
||||
* has happened and will assist in the early SW and FW
|
||||
* setup.
|
||||
*/
|
||||
|
||||
/* adminq functions */
|
||||
enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw);
|
||||
enum i40e_status_code i40e_shutdown_adminq(struct i40e_hw *hw);
|
||||
enum i40e_status_code i40e_init_asq(struct i40e_hw *hw);
|
||||
enum i40e_status_code i40e_init_arq(struct i40e_hw *hw);
|
||||
enum i40e_status_code i40e_alloc_adminq_asq_ring(struct i40e_hw *hw);
|
||||
enum i40e_status_code i40e_alloc_adminq_arq_ring(struct i40e_hw *hw);
|
||||
enum i40e_status_code i40e_shutdown_asq(struct i40e_hw *hw);
|
||||
enum i40e_status_code i40e_shutdown_arq(struct i40e_hw *hw);
|
||||
u16 i40e_clean_asq(struct i40e_hw *hw);
|
||||
void i40e_free_adminq_asq(struct i40e_hw *hw);
|
||||
void i40e_free_adminq_arq(struct i40e_hw *hw);
|
||||
void i40e_adminq_init_ring_data(struct i40e_hw *hw);
|
||||
enum i40e_status_code i40e_clean_arq_element(struct i40e_hw *hw,
|
||||
struct i40e_arq_event_info *e,
|
||||
u16 *events_pending);
|
||||
enum i40e_status_code i40e_asq_send_command(struct i40e_hw *hw,
|
||||
struct i40e_aq_desc *desc,
|
||||
void *buff, /* can be NULL */
|
||||
u16 buff_size,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
bool i40e_asq_done(struct i40e_hw *hw);
|
||||
|
||||
/* debug function for adminq */
|
||||
void i40e_debug_aq(struct i40e_hw *hw,
|
||||
enum i40e_debug_mask mask,
|
||||
void *desc,
|
||||
void *buffer);
|
||||
|
||||
void i40e_idle_aq(struct i40e_hw *hw);
|
||||
void i40e_resume_aq(struct i40e_hw *hw);
|
||||
bool i40e_check_asq_alive(struct i40e_hw *hw);
|
||||
enum i40e_status_code i40e_aq_queue_shutdown(struct i40e_hw *hw, bool unloading);
|
||||
|
||||
|
||||
u32 i40e_led_get(struct i40e_hw *hw);
|
||||
void i40e_led_set(struct i40e_hw *hw, u32 mode, bool blink);
|
||||
|
||||
/* admin send queue commands */
|
||||
|
||||
enum i40e_status_code i40e_aq_get_firmware_version(struct i40e_hw *hw,
|
||||
u16 *fw_major_version, u16 *fw_minor_version,
|
||||
u16 *api_major_version, u16 *api_minor_version,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_set_phy_debug(struct i40e_hw *hw, u8 cmd_flags,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_set_default_vsi(struct i40e_hw *hw, u16 vsi_id,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_get_phy_capabilities(struct i40e_hw *hw,
|
||||
bool qualified_modules, bool report_init,
|
||||
struct i40e_aq_get_phy_abilities_resp *abilities,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_set_phy_config(struct i40e_hw *hw,
|
||||
struct i40e_aq_set_phy_config *config,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_set_fc(struct i40e_hw *hw, u8 *aq_failures,
|
||||
bool atomic_reset);
|
||||
enum i40e_status_code i40e_aq_set_mac_config(struct i40e_hw *hw,
|
||||
u16 max_frame_size, bool crc_en, u16 pacing,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_set_phy_int_mask(struct i40e_hw *hw, u16 mask,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_get_local_advt_reg(struct i40e_hw *hw,
|
||||
u64 *advt_reg,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_get_partner_advt(struct i40e_hw *hw,
|
||||
u64 *advt_reg,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_set_lb_modes(struct i40e_hw *hw, u16 lb_modes,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
#ifndef FORTVILLE_A0_SUPPORT
|
||||
enum i40e_status_code i40e_aq_clear_pxe_mode(struct i40e_hw *hw,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
#endif
|
||||
enum i40e_status_code i40e_aq_set_link_restart_an(struct i40e_hw *hw,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_get_link_info(struct i40e_hw *hw,
|
||||
bool enable_lse, struct i40e_link_status *link,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_update_link_info(struct i40e_hw *hw,
|
||||
bool enable_lse);
|
||||
enum i40e_status_code i40e_aq_set_local_advt_reg(struct i40e_hw *hw,
|
||||
u64 advt_reg,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_send_driver_version(struct i40e_hw *hw,
|
||||
struct i40e_driver_version *dv,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_add_vsi(struct i40e_hw *hw,
|
||||
struct i40e_vsi_context *vsi_ctx,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_set_vsi_broadcast(struct i40e_hw *hw,
|
||||
u16 vsi_id, bool set_filter,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw,
|
||||
u16 vsi_id, bool set, struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_set_vsi_multicast_promiscuous(struct i40e_hw *hw,
|
||||
u16 vsi_id, bool set, struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_get_vsi_params(struct i40e_hw *hw,
|
||||
struct i40e_vsi_context *vsi_ctx,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_update_vsi_params(struct i40e_hw *hw,
|
||||
struct i40e_vsi_context *vsi_ctx,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_add_veb(struct i40e_hw *hw, u16 uplink_seid,
|
||||
u16 downlink_seid, u8 enabled_tc,
|
||||
bool default_port, bool enable_l2_filtering,
|
||||
u16 *pveb_seid,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_get_veb_parameters(struct i40e_hw *hw,
|
||||
u16 veb_seid, u16 *switch_id, bool *floating,
|
||||
u16 *statistic_index, u16 *vebs_used,
|
||||
u16 *vebs_free,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_add_macvlan(struct i40e_hw *hw, u16 vsi_id,
|
||||
struct i40e_aqc_add_macvlan_element_data *mv_list,
|
||||
u16 count, struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_remove_macvlan(struct i40e_hw *hw, u16 vsi_id,
|
||||
struct i40e_aqc_remove_macvlan_element_data *mv_list,
|
||||
u16 count, struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_add_vlan(struct i40e_hw *hw, u16 vsi_id,
|
||||
struct i40e_aqc_add_remove_vlan_element_data *v_list,
|
||||
u8 count, struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_remove_vlan(struct i40e_hw *hw, u16 vsi_id,
|
||||
struct i40e_aqc_add_remove_vlan_element_data *v_list,
|
||||
u8 count, struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_send_msg_to_vf(struct i40e_hw *hw, u16 vfid,
|
||||
u32 v_opcode, u32 v_retval, u8 *msg, u16 msglen,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_get_switch_config(struct i40e_hw *hw,
|
||||
struct i40e_aqc_get_switch_config_resp *buf,
|
||||
u16 buf_size, u16 *start_seid,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_request_resource(struct i40e_hw *hw,
|
||||
enum i40e_aq_resources_ids resource,
|
||||
enum i40e_aq_resource_access_type access,
|
||||
u8 sdp_number, u64 *timeout,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_release_resource(struct i40e_hw *hw,
|
||||
enum i40e_aq_resources_ids resource,
|
||||
u8 sdp_number,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_read_nvm(struct i40e_hw *hw, u8 module_pointer,
|
||||
u32 offset, u16 length, void *data,
|
||||
bool last_command,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_erase_nvm(struct i40e_hw *hw, u8 module_pointer,
|
||||
u32 offset, u16 length, bool last_command,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_discover_capabilities(struct i40e_hw *hw,
|
||||
void *buff, u16 buff_size, u16 *data_size,
|
||||
enum i40e_admin_queue_opc list_type_opc,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_update_nvm(struct i40e_hw *hw, u8 module_pointer,
|
||||
u32 offset, u16 length, void *data,
|
||||
bool last_command,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_get_lldp_mib(struct i40e_hw *hw, u8 bridge_type,
|
||||
u8 mib_type, void *buff, u16 buff_size,
|
||||
u16 *local_len, u16 *remote_len,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_cfg_lldp_mib_change_event(struct i40e_hw *hw,
|
||||
bool enable_update,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_add_lldp_tlv(struct i40e_hw *hw, u8 bridge_type,
|
||||
void *buff, u16 buff_size, u16 tlv_len,
|
||||
u16 *mib_len,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_update_lldp_tlv(struct i40e_hw *hw,
|
||||
u8 bridge_type, void *buff, u16 buff_size,
|
||||
u16 old_len, u16 new_len, u16 offset,
|
||||
u16 *mib_len,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_delete_lldp_tlv(struct i40e_hw *hw,
|
||||
u8 bridge_type, void *buff, u16 buff_size,
|
||||
u16 tlv_len, u16 *mib_len,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_stop_lldp(struct i40e_hw *hw, bool shutdown_agent,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_start_lldp(struct i40e_hw *hw,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
#ifdef FORTVILLE_A0_SUPPORT
|
||||
enum i40e_status_code i40e_aq_add_udp_tunnel(struct i40e_hw *hw,
|
||||
u16 udp_port, u8 header_len,
|
||||
u8 protocol_index, u8 *filter_index,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
#else
|
||||
enum i40e_status_code i40e_aq_add_udp_tunnel(struct i40e_hw *hw,
|
||||
u16 udp_port, u8 protocol_index,
|
||||
u8 *filter_index,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
#endif
|
||||
enum i40e_status_code i40e_aq_del_udp_tunnel(struct i40e_hw *hw, u8 index,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_get_switch_resource_alloc(struct i40e_hw *hw,
|
||||
u8 *num_entries,
|
||||
struct i40e_aqc_switch_resource_alloc_element_resp *buf,
|
||||
u16 count,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_add_pvirt(struct i40e_hw *hw, u16 flags,
|
||||
u16 mac_seid, u16 vsi_seid,
|
||||
u16 *ret_seid);
|
||||
enum i40e_status_code i40e_aq_add_tag(struct i40e_hw *hw, bool direct_to_queue,
|
||||
u16 vsi_seid, u16 tag, u16 queue_num,
|
||||
u16 *tags_used, u16 *tags_free,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_remove_tag(struct i40e_hw *hw, u16 vsi_seid,
|
||||
u16 tag, u16 *tags_used, u16 *tags_free,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_add_mcast_etag(struct i40e_hw *hw, u16 pe_seid,
|
||||
u16 etag, u8 num_tags_in_buf, void *buf,
|
||||
u16 *tags_used, u16 *tags_free,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_remove_mcast_etag(struct i40e_hw *hw, u16 pe_seid,
|
||||
u16 etag, u16 *tags_used, u16 *tags_free,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_update_tag(struct i40e_hw *hw, u16 vsi_seid,
|
||||
u16 old_tag, u16 new_tag, u16 *tags_used,
|
||||
u16 *tags_free,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_add_statistics(struct i40e_hw *hw, u16 seid,
|
||||
u16 vlan_id, u16 *stat_index,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_remove_statistics(struct i40e_hw *hw, u16 seid,
|
||||
u16 vlan_id, u16 stat_index,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_set_port_parameters(struct i40e_hw *hw,
|
||||
u16 bad_frame_vsi, bool save_bad_pac,
|
||||
bool pad_short_pac, bool double_vlan,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_delete_element(struct i40e_hw *hw, u16 seid,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_mac_address_write(struct i40e_hw *hw,
|
||||
u16 flags, u8 *mac_addr,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_config_vsi_bw_limit(struct i40e_hw *hw,
|
||||
u16 seid, u16 credit, u8 max_credit,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_dcb_ignore_pfc(struct i40e_hw *hw,
|
||||
u8 tcmap, bool request, u8 *tcmap_ret,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_get_hmc_resource_profile(struct i40e_hw *hw,
|
||||
enum i40e_aq_hmc_profile *profile,
|
||||
u8 *pe_vf_enabled_count,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_config_switch_comp_ets_bw_limit(
|
||||
struct i40e_hw *hw, u16 seid,
|
||||
struct i40e_aqc_configure_switching_comp_ets_bw_limit_data *bw_data,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_config_vsi_ets_sla_bw_limit(struct i40e_hw *hw,
|
||||
u16 seid,
|
||||
struct i40e_aqc_configure_vsi_ets_sla_bw_data *bw_data,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_dcb_updated(struct i40e_hw *hw,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_set_hmc_resource_profile(struct i40e_hw *hw,
|
||||
enum i40e_aq_hmc_profile profile,
|
||||
u8 pe_vf_enabled_count,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_config_switch_comp_bw_limit(struct i40e_hw *hw,
|
||||
u16 seid, u16 credit, u8 max_bw,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_config_vsi_tc_bw(struct i40e_hw *hw, u16 seid,
|
||||
struct i40e_aqc_configure_vsi_tc_bw_data *bw_data,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_query_vsi_bw_config(struct i40e_hw *hw,
|
||||
u16 seid,
|
||||
struct i40e_aqc_query_vsi_bw_config_resp *bw_data,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_query_vsi_ets_sla_config(struct i40e_hw *hw,
|
||||
u16 seid,
|
||||
struct i40e_aqc_query_vsi_ets_sla_config_resp *bw_data,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_query_switch_comp_ets_config(struct i40e_hw *hw,
|
||||
u16 seid,
|
||||
struct i40e_aqc_query_switching_comp_ets_config_resp *bw_data,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_query_port_ets_config(struct i40e_hw *hw,
|
||||
u16 seid,
|
||||
struct i40e_aqc_query_port_ets_config_resp *bw_data,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_query_switch_comp_bw_config(struct i40e_hw *hw,
|
||||
u16 seid,
|
||||
struct i40e_aqc_query_switching_comp_bw_config_resp *bw_data,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_resume_port_tx(struct i40e_hw *hw,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_aq_add_cloud_filters(struct i40e_hw *hw,
|
||||
u16 vsi,
|
||||
struct i40e_aqc_add_remove_cloud_filters_element_data *filters,
|
||||
u8 filter_count);
|
||||
|
||||
enum i40e_status_code i40e_aq_remove_cloud_filters(struct i40e_hw *hw,
|
||||
u16 vsi,
|
||||
struct i40e_aqc_add_remove_cloud_filters_element_data *filters,
|
||||
u8 filter_count);
|
||||
|
||||
enum i40e_status_code i40e_aq_alternate_read(struct i40e_hw *hw,
|
||||
u32 reg_addr0, u32 *reg_val0,
|
||||
u32 reg_addr1, u32 *reg_val1);
|
||||
enum i40e_status_code i40e_aq_alternate_read_indirect(struct i40e_hw *hw,
|
||||
u32 addr, u32 dw_count, void *buffer);
|
||||
enum i40e_status_code i40e_aq_alternate_write(struct i40e_hw *hw,
|
||||
u32 reg_addr0, u32 reg_val0,
|
||||
u32 reg_addr1, u32 reg_val1);
|
||||
enum i40e_status_code i40e_aq_alternate_write_indirect(struct i40e_hw *hw,
|
||||
u32 addr, u32 dw_count, void *buffer);
|
||||
enum i40e_status_code i40e_aq_alternate_clear(struct i40e_hw *hw);
|
||||
enum i40e_status_code i40e_aq_alternate_write_done(struct i40e_hw *hw,
|
||||
u8 bios_mode, bool *reset_needed);
|
||||
enum i40e_status_code i40e_aq_set_oem_mode(struct i40e_hw *hw,
|
||||
u8 oem_mode);
|
||||
|
||||
/* i40e_common */
|
||||
enum i40e_status_code i40e_init_shared_code(struct i40e_hw *hw);
|
||||
enum i40e_status_code i40e_pf_reset(struct i40e_hw *hw);
|
||||
void i40e_clear_pxe_mode(struct i40e_hw *hw);
|
||||
bool i40e_get_link_status(struct i40e_hw *hw);
|
||||
enum i40e_status_code i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr);
|
||||
enum i40e_status_code i40e_read_bw_from_alt_ram(struct i40e_hw *hw,
|
||||
u32 *max_bw, u32 *min_bw, bool *min_valid, bool *max_valid);
|
||||
enum i40e_status_code i40e_aq_configure_partition_bw(struct i40e_hw *hw,
|
||||
struct i40e_aqc_configure_partition_bw_data *bw_data,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_get_port_mac_addr(struct i40e_hw *hw, u8 *mac_addr);
|
||||
void i40e_pre_tx_queue_cfg(struct i40e_hw *hw, u32 queue, bool enable);
|
||||
#ifdef FORTVILLE_A0_SUPPORT
|
||||
void i40e_set_tag_alloc_method(struct i40e_hw *hw, bool debug);
|
||||
#endif
|
||||
enum i40e_status_code i40e_validate_mac_addr(u8 *mac_addr);
|
||||
enum i40e_aq_link_speed i40e_get_link_speed(struct i40e_hw *hw);
|
||||
/* prototype for functions used for NVM access */
|
||||
enum i40e_status_code i40e_init_nvm(struct i40e_hw *hw);
|
||||
enum i40e_status_code i40e_acquire_nvm(struct i40e_hw *hw,
|
||||
enum i40e_aq_resource_access_type access);
|
||||
void i40e_release_nvm(struct i40e_hw *hw);
|
||||
enum i40e_status_code i40e_read_nvm_srrd(struct i40e_hw *hw, u16 offset,
|
||||
u16 *data);
|
||||
enum i40e_status_code i40e_read_nvm_word(struct i40e_hw *hw, u16 offset,
|
||||
u16 *data);
|
||||
enum i40e_status_code i40e_read_nvm_buffer(struct i40e_hw *hw, u16 offset,
|
||||
u16 *words, u16 *data);
|
||||
enum i40e_status_code i40e_write_nvm_aq(struct i40e_hw *hw, u8 module,
|
||||
u32 offset, u16 words, void *data,
|
||||
bool last_command);
|
||||
enum i40e_status_code i40e_write_nvm_word(struct i40e_hw *hw, u32 offset,
|
||||
void *data);
|
||||
enum i40e_status_code i40e_write_nvm_buffer(struct i40e_hw *hw, u8 module,
|
||||
u32 offset, u16 words, void *data);
|
||||
enum i40e_status_code i40e_calc_nvm_checksum(struct i40e_hw *hw, u16 *checksum);
|
||||
enum i40e_status_code i40e_update_nvm_checksum(struct i40e_hw *hw);
|
||||
enum i40e_status_code i40e_validate_nvm_checksum(struct i40e_hw *hw,
|
||||
u16 *checksum);
|
||||
enum i40e_status_code i40e_nvmupd_command(struct i40e_hw *hw,
|
||||
struct i40e_nvm_access *cmd,
|
||||
u8 *bytes, int *);
|
||||
void i40e_set_pci_config_data(struct i40e_hw *hw, u16 link_status);
|
||||
|
||||
#if defined(I40E_QV) || defined(VF_DRIVER)
|
||||
enum i40e_status_code i40e_set_mac_type(struct i40e_hw *hw);
|
||||
|
||||
#endif
|
||||
extern struct i40e_rx_ptype_decoded i40e_ptype_lookup[];
|
||||
|
||||
static INLINE struct i40e_rx_ptype_decoded decode_rx_desc_ptype(u8 ptype)
|
||||
{
|
||||
return i40e_ptype_lookup[ptype];
|
||||
}
|
||||
|
||||
/* prototype for functions used for SW spinlocks */
|
||||
void i40e_init_spinlock(struct i40e_spinlock *sp);
|
||||
void i40e_acquire_spinlock(struct i40e_spinlock *sp);
|
||||
void i40e_release_spinlock(struct i40e_spinlock *sp);
|
||||
void i40e_destroy_spinlock(struct i40e_spinlock *sp);
|
||||
|
||||
/* i40e_common for VF drivers*/
|
||||
void i40e_vf_parse_hw_config(struct i40e_hw *hw,
|
||||
struct i40e_virtchnl_vf_resource *msg);
|
||||
enum i40e_status_code i40e_vf_reset(struct i40e_hw *hw);
|
||||
enum i40e_status_code i40e_aq_send_msg_to_pf(struct i40e_hw *hw,
|
||||
enum i40e_virtchnl_ops v_opcode,
|
||||
enum i40e_status_code v_retval,
|
||||
u8 *msg, u16 msglen,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
enum i40e_status_code i40e_set_filter_control(struct i40e_hw *hw,
|
||||
struct i40e_filter_control_settings *settings);
|
||||
enum i40e_status_code i40e_aq_add_rem_control_packet_filter(struct i40e_hw *hw,
|
||||
u8 *mac_addr, u16 ethtype, u16 flags,
|
||||
u16 vsi_seid, u16 queue, bool is_add,
|
||||
struct i40e_control_filter_stats *stats,
|
||||
struct i40e_asq_cmd_details *cmd_details);
|
||||
#endif /* _I40E_PROTOTYPE_H_ */
|
3622
sys/dev/i40e/i40e_register.h
Executable file
3622
sys/dev/i40e/i40e_register.h
Executable file
File diff suppressed because it is too large
Load Diff
10328
sys/dev/i40e/i40e_register_x710_int.h
Executable file
10328
sys/dev/i40e/i40e_register_x710_int.h
Executable file
File diff suppressed because it is too large
Load Diff
108
sys/dev/i40e/i40e_status.h
Executable file
108
sys/dev/i40e/i40e_status.h
Executable file
@ -0,0 +1,108 @@
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (c) 2013-2014, Intel Corporation
|
||||
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 and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
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.
|
||||
|
||||
******************************************************************************/
|
||||
/*$FreeBSD$*/
|
||||
|
||||
#ifndef _I40E_STATUS_H_
|
||||
#define _I40E_STATUS_H_
|
||||
|
||||
/* Error Codes */
|
||||
enum i40e_status_code {
|
||||
I40E_SUCCESS = 0,
|
||||
I40E_ERR_NVM = -1,
|
||||
I40E_ERR_NVM_CHECKSUM = -2,
|
||||
I40E_ERR_PHY = -3,
|
||||
I40E_ERR_CONFIG = -4,
|
||||
I40E_ERR_PARAM = -5,
|
||||
I40E_ERR_MAC_TYPE = -6,
|
||||
I40E_ERR_UNKNOWN_PHY = -7,
|
||||
I40E_ERR_LINK_SETUP = -8,
|
||||
I40E_ERR_ADAPTER_STOPPED = -9,
|
||||
I40E_ERR_INVALID_MAC_ADDR = -10,
|
||||
I40E_ERR_DEVICE_NOT_SUPPORTED = -11,
|
||||
I40E_ERR_MASTER_REQUESTS_PENDING = -12,
|
||||
I40E_ERR_INVALID_LINK_SETTINGS = -13,
|
||||
I40E_ERR_AUTONEG_NOT_COMPLETE = -14,
|
||||
I40E_ERR_RESET_FAILED = -15,
|
||||
I40E_ERR_SWFW_SYNC = -16,
|
||||
I40E_ERR_NO_AVAILABLE_VSI = -17,
|
||||
I40E_ERR_NO_MEMORY = -18,
|
||||
I40E_ERR_BAD_PTR = -19,
|
||||
I40E_ERR_RING_FULL = -20,
|
||||
I40E_ERR_INVALID_PD_ID = -21,
|
||||
I40E_ERR_INVALID_QP_ID = -22,
|
||||
I40E_ERR_INVALID_CQ_ID = -23,
|
||||
I40E_ERR_INVALID_CEQ_ID = -24,
|
||||
I40E_ERR_INVALID_AEQ_ID = -25,
|
||||
I40E_ERR_INVALID_SIZE = -26,
|
||||
I40E_ERR_INVALID_ARP_INDEX = -27,
|
||||
I40E_ERR_INVALID_FPM_FUNC_ID = -28,
|
||||
I40E_ERR_QP_INVALID_MSG_SIZE = -29,
|
||||
I40E_ERR_QP_TOOMANY_WRS_POSTED = -30,
|
||||
I40E_ERR_INVALID_FRAG_COUNT = -31,
|
||||
I40E_ERR_QUEUE_EMPTY = -32,
|
||||
I40E_ERR_INVALID_ALIGNMENT = -33,
|
||||
I40E_ERR_FLUSHED_QUEUE = -34,
|
||||
I40E_ERR_INVALID_PUSH_PAGE_INDEX = -35,
|
||||
I40E_ERR_INVALID_IMM_DATA_SIZE = -36,
|
||||
I40E_ERR_TIMEOUT = -37,
|
||||
I40E_ERR_OPCODE_MISMATCH = -38,
|
||||
I40E_ERR_CQP_COMPL_ERROR = -39,
|
||||
I40E_ERR_INVALID_VF_ID = -40,
|
||||
I40E_ERR_INVALID_HMCFN_ID = -41,
|
||||
I40E_ERR_BACKING_PAGE_ERROR = -42,
|
||||
I40E_ERR_NO_PBLCHUNKS_AVAILABLE = -43,
|
||||
I40E_ERR_INVALID_PBLE_INDEX = -44,
|
||||
I40E_ERR_INVALID_SD_INDEX = -45,
|
||||
I40E_ERR_INVALID_PAGE_DESC_INDEX = -46,
|
||||
I40E_ERR_INVALID_SD_TYPE = -47,
|
||||
I40E_ERR_MEMCPY_FAILED = -48,
|
||||
I40E_ERR_INVALID_HMC_OBJ_INDEX = -49,
|
||||
I40E_ERR_INVALID_HMC_OBJ_COUNT = -50,
|
||||
I40E_ERR_INVALID_SRQ_ARM_LIMIT = -51,
|
||||
I40E_ERR_SRQ_ENABLED = -52,
|
||||
I40E_ERR_ADMIN_QUEUE_ERROR = -53,
|
||||
I40E_ERR_ADMIN_QUEUE_TIMEOUT = -54,
|
||||
I40E_ERR_BUF_TOO_SHORT = -55,
|
||||
I40E_ERR_ADMIN_QUEUE_FULL = -56,
|
||||
I40E_ERR_ADMIN_QUEUE_NO_WORK = -57,
|
||||
I40E_ERR_BAD_IWARP_CQE = -58,
|
||||
I40E_ERR_NVM_BLANK_MODE = -59,
|
||||
I40E_ERR_NOT_IMPLEMENTED = -60,
|
||||
I40E_ERR_PE_DOORBELL_NOT_ENABLED = -61,
|
||||
I40E_ERR_DIAG_TEST_FAILED = -62,
|
||||
I40E_ERR_NOT_READY = -63,
|
||||
I40E_NOT_SUPPORTED = -64,
|
||||
I40E_ERR_FIRMWARE_API_VERSION = -65,
|
||||
};
|
||||
|
||||
#endif /* _I40E_STATUS_H_ */
|
1501
sys/dev/i40e/i40e_txrx.c
Executable file
1501
sys/dev/i40e/i40e_txrx.c
Executable file
File diff suppressed because it is too large
Load Diff
1421
sys/dev/i40e/i40e_type.h
Executable file
1421
sys/dev/i40e/i40e_type.h
Executable file
File diff suppressed because it is too large
Load Diff
374
sys/dev/i40e/i40e_virtchnl.h
Executable file
374
sys/dev/i40e/i40e_virtchnl.h
Executable file
@ -0,0 +1,374 @@
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (c) 2013-2014, Intel Corporation
|
||||
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 and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
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.
|
||||
|
||||
******************************************************************************/
|
||||
/*$FreeBSD$*/
|
||||
|
||||
#ifndef _I40E_VIRTCHNL_H_
|
||||
#define _I40E_VIRTCHNL_H_
|
||||
|
||||
#include "i40e_type.h"
|
||||
|
||||
/* Description:
|
||||
* This header file describes the VF-PF communication protocol used
|
||||
* by the various i40e drivers.
|
||||
*
|
||||
* Admin queue buffer usage:
|
||||
* desc->opcode is always i40e_aqc_opc_send_msg_to_pf
|
||||
* flags, retval, datalen, and data addr are all used normally.
|
||||
* Firmware copies the cookie fields when sending messages between the PF and
|
||||
* VF, but uses all other fields internally. Due to this limitation, we
|
||||
* must send all messages as "indirect", i.e. using an external buffer.
|
||||
*
|
||||
* All the vsi indexes are relative to the VF. Each VF can have maximum of
|
||||
* three VSIs. All the queue indexes are relative to the VSI. Each VF can
|
||||
* have a maximum of sixteen queues for all of its VSIs.
|
||||
*
|
||||
* The PF is required to return a status code in v_retval for all messages
|
||||
* except RESET_VF, which does not require any response. The return value is of
|
||||
* i40e_status_code type, defined in the i40e_type.h.
|
||||
*
|
||||
* In general, VF driver initialization should roughly follow the order of these
|
||||
* opcodes. The VF driver must first validate the API version of the PF driver,
|
||||
* then request a reset, then get resources, then configure queues and
|
||||
* interrupts. After these operations are complete, the VF driver may start
|
||||
* its queues, optionally add MAC and VLAN filters, and process traffic.
|
||||
*/
|
||||
|
||||
/* Opcodes for VF-PF communication. These are placed in the v_opcode field
|
||||
* of the virtchnl_msg structure.
|
||||
*/
|
||||
enum i40e_virtchnl_ops {
|
||||
/* VF sends req. to pf for the following
|
||||
* ops.
|
||||
*/
|
||||
I40E_VIRTCHNL_OP_UNKNOWN = 0,
|
||||
I40E_VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */
|
||||
I40E_VIRTCHNL_OP_RESET_VF,
|
||||
I40E_VIRTCHNL_OP_GET_VF_RESOURCES,
|
||||
I40E_VIRTCHNL_OP_CONFIG_TX_QUEUE,
|
||||
I40E_VIRTCHNL_OP_CONFIG_RX_QUEUE,
|
||||
I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES,
|
||||
I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP,
|
||||
I40E_VIRTCHNL_OP_ENABLE_QUEUES,
|
||||
I40E_VIRTCHNL_OP_DISABLE_QUEUES,
|
||||
I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS,
|
||||
I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS,
|
||||
I40E_VIRTCHNL_OP_ADD_VLAN,
|
||||
I40E_VIRTCHNL_OP_DEL_VLAN,
|
||||
I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE,
|
||||
I40E_VIRTCHNL_OP_GET_STATS,
|
||||
I40E_VIRTCHNL_OP_FCOE,
|
||||
/* PF sends status change events to vfs using
|
||||
* the following op.
|
||||
*/
|
||||
I40E_VIRTCHNL_OP_EVENT,
|
||||
};
|
||||
|
||||
/* Virtual channel message descriptor. This overlays the admin queue
|
||||
* descriptor. All other data is passed in external buffers.
|
||||
*/
|
||||
|
||||
struct i40e_virtchnl_msg {
|
||||
u8 pad[8]; /* AQ flags/opcode/len/retval fields */
|
||||
enum i40e_virtchnl_ops v_opcode; /* avoid confusion with desc->opcode */
|
||||
enum i40e_status_code v_retval; /* ditto for desc->retval */
|
||||
u32 vfid; /* used by PF when sending to VF */
|
||||
};
|
||||
|
||||
/* Message descriptions and data structures.*/
|
||||
|
||||
/* I40E_VIRTCHNL_OP_VERSION
|
||||
* VF posts its version number to the PF. PF responds with its version number
|
||||
* in the same format, along with a return code.
|
||||
* Reply from PF has its major/minor versions also in param0 and param1.
|
||||
* If there is a major version mismatch, then the VF cannot operate.
|
||||
* If there is a minor version mismatch, then the VF can operate but should
|
||||
* add a warning to the system log.
|
||||
*
|
||||
* This enum element MUST always be specified as == 1, regardless of other
|
||||
* changes in the API. The PF must always respond to this message without
|
||||
* error regardless of version mismatch.
|
||||
*/
|
||||
#define I40E_VIRTCHNL_VERSION_MAJOR 1
|
||||
#define I40E_VIRTCHNL_VERSION_MINOR 0
|
||||
struct i40e_virtchnl_version_info {
|
||||
u32 major;
|
||||
u32 minor;
|
||||
};
|
||||
|
||||
/* I40E_VIRTCHNL_OP_RESET_VF
|
||||
* VF sends this request to PF with no parameters
|
||||
* PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
|
||||
* until reset completion is indicated. The admin queue must be reinitialized
|
||||
* after this operation.
|
||||
*
|
||||
* When reset is complete, PF must ensure that all queues in all VSIs associated
|
||||
* with the VF are stopped, all queue configurations in the HMC are set to 0,
|
||||
* and all MAC and VLAN filters (except the default MAC address) on all VSIs
|
||||
* are cleared.
|
||||
*/
|
||||
|
||||
/* I40E_VIRTCHNL_OP_GET_VF_RESOURCES
|
||||
* VF sends this request to PF with no parameters
|
||||
* PF responds with an indirect message containing
|
||||
* i40e_virtchnl_vf_resource and one or more
|
||||
* i40e_virtchnl_vsi_resource structures.
|
||||
*/
|
||||
|
||||
struct i40e_virtchnl_vsi_resource {
|
||||
u16 vsi_id;
|
||||
u16 num_queue_pairs;
|
||||
enum i40e_vsi_type vsi_type;
|
||||
u16 qset_handle;
|
||||
u8 default_mac_addr[I40E_ETH_LENGTH_OF_ADDRESS];
|
||||
};
|
||||
/* VF offload flags */
|
||||
#define I40E_VIRTCHNL_VF_OFFLOAD_L2 0x00000001
|
||||
#define I40E_VIRTCHNL_VF_OFFLOAD_IWARP 0x00000002
|
||||
#define I40E_VIRTCHNL_VF_OFFLOAD_FCOE 0x00000004
|
||||
#define I40E_VIRTCHNL_VF_OFFLOAD_VLAN 0x00010000
|
||||
|
||||
struct i40e_virtchnl_vf_resource {
|
||||
u16 num_vsis;
|
||||
u16 num_queue_pairs;
|
||||
u16 max_vectors;
|
||||
u16 max_mtu;
|
||||
|
||||
u32 vf_offload_flags;
|
||||
u32 max_fcoe_contexts;
|
||||
u32 max_fcoe_filters;
|
||||
|
||||
struct i40e_virtchnl_vsi_resource vsi_res[1];
|
||||
};
|
||||
|
||||
/* I40E_VIRTCHNL_OP_CONFIG_TX_QUEUE
|
||||
* VF sends this message to set up parameters for one TX queue.
|
||||
* External data buffer contains one instance of i40e_virtchnl_txq_info.
|
||||
* PF configures requested queue and returns a status code.
|
||||
*/
|
||||
|
||||
/* Tx queue config info */
|
||||
struct i40e_virtchnl_txq_info {
|
||||
u16 vsi_id;
|
||||
u16 queue_id;
|
||||
u16 ring_len; /* number of descriptors, multiple of 8 */
|
||||
u16 headwb_enabled;
|
||||
u64 dma_ring_addr;
|
||||
u64 dma_headwb_addr;
|
||||
};
|
||||
|
||||
/* I40E_VIRTCHNL_OP_CONFIG_RX_QUEUE
|
||||
* VF sends this message to set up parameters for one RX queue.
|
||||
* External data buffer contains one instance of i40e_virtchnl_rxq_info.
|
||||
* PF configures requested queue and returns a status code.
|
||||
*/
|
||||
|
||||
/* Rx queue config info */
|
||||
struct i40e_virtchnl_rxq_info {
|
||||
u16 vsi_id;
|
||||
u16 queue_id;
|
||||
u32 ring_len; /* number of descriptors, multiple of 32 */
|
||||
u16 hdr_size;
|
||||
u16 splithdr_enabled;
|
||||
u32 databuffer_size;
|
||||
u32 max_pkt_size;
|
||||
u64 dma_ring_addr;
|
||||
enum i40e_hmc_obj_rx_hsplit_0 rx_split_pos;
|
||||
};
|
||||
|
||||
/* I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES
|
||||
* VF sends this message to set parameters for all active TX and RX queues
|
||||
* associated with the specified VSI.
|
||||
* PF configures queues and returns status.
|
||||
* If the number of queues specified is greater than the number of queues
|
||||
* associated with the VSI, an error is returned and no queues are configured.
|
||||
*/
|
||||
struct i40e_virtchnl_queue_pair_info {
|
||||
/* NOTE: vsi_id and queue_id should be identical for both queues. */
|
||||
struct i40e_virtchnl_txq_info txq;
|
||||
struct i40e_virtchnl_rxq_info rxq;
|
||||
};
|
||||
|
||||
struct i40e_virtchnl_vsi_queue_config_info {
|
||||
u16 vsi_id;
|
||||
u16 num_queue_pairs;
|
||||
struct i40e_virtchnl_queue_pair_info qpair[1];
|
||||
};
|
||||
|
||||
/* I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP
|
||||
* VF uses this message to map vectors to queues.
|
||||
* The rxq_map and txq_map fields are bitmaps used to indicate which queues
|
||||
* are to be associated with the specified vector.
|
||||
* The "other" causes are always mapped to vector 0.
|
||||
* PF configures interrupt mapping and returns status.
|
||||
*/
|
||||
struct i40e_virtchnl_vector_map {
|
||||
u16 vsi_id;
|
||||
u16 vector_id;
|
||||
u16 rxq_map;
|
||||
u16 txq_map;
|
||||
u16 rxitr_idx;
|
||||
u16 txitr_idx;
|
||||
};
|
||||
|
||||
struct i40e_virtchnl_irq_map_info {
|
||||
u16 num_vectors;
|
||||
struct i40e_virtchnl_vector_map vecmap[1];
|
||||
};
|
||||
|
||||
/* I40E_VIRTCHNL_OP_ENABLE_QUEUES
|
||||
* I40E_VIRTCHNL_OP_DISABLE_QUEUES
|
||||
* VF sends these message to enable or disable TX/RX queue pairs.
|
||||
* The queues fields are bitmaps indicating which queues to act upon.
|
||||
* (Currently, we only support 16 queues per VF, but we make the field
|
||||
* u32 to allow for expansion.)
|
||||
* PF performs requested action and returns status.
|
||||
*/
|
||||
struct i40e_virtchnl_queue_select {
|
||||
u16 vsi_id;
|
||||
u16 pad;
|
||||
u32 rx_queues;
|
||||
u32 tx_queues;
|
||||
};
|
||||
|
||||
/* I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS
|
||||
* VF sends this message in order to add one or more unicast or multicast
|
||||
* address filters for the specified VSI.
|
||||
* PF adds the filters and returns status.
|
||||
*/
|
||||
|
||||
/* I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS
|
||||
* VF sends this message in order to remove one or more unicast or multicast
|
||||
* filters for the specified VSI.
|
||||
* PF removes the filters and returns status.
|
||||
*/
|
||||
|
||||
struct i40e_virtchnl_ether_addr {
|
||||
u8 addr[I40E_ETH_LENGTH_OF_ADDRESS];
|
||||
u8 pad[2];
|
||||
};
|
||||
|
||||
struct i40e_virtchnl_ether_addr_list {
|
||||
u16 vsi_id;
|
||||
u16 num_elements;
|
||||
struct i40e_virtchnl_ether_addr list[1];
|
||||
};
|
||||
|
||||
/* I40E_VIRTCHNL_OP_ADD_VLAN
|
||||
* VF sends this message to add one or more VLAN tag filters for receives.
|
||||
* PF adds the filters and returns status.
|
||||
* If a port VLAN is configured by the PF, this operation will return an
|
||||
* error to the VF.
|
||||
*/
|
||||
|
||||
/* I40E_VIRTCHNL_OP_DEL_VLAN
|
||||
* VF sends this message to remove one or more VLAN tag filters for receives.
|
||||
* PF removes the filters and returns status.
|
||||
* If a port VLAN is configured by the PF, this operation will return an
|
||||
* error to the VF.
|
||||
*/
|
||||
|
||||
struct i40e_virtchnl_vlan_filter_list {
|
||||
u16 vsi_id;
|
||||
u16 num_elements;
|
||||
u16 vlan_id[1];
|
||||
};
|
||||
|
||||
/* I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
|
||||
* VF sends VSI id and flags.
|
||||
* PF returns status code in retval.
|
||||
* Note: we assume that broadcast accept mode is always enabled.
|
||||
*/
|
||||
struct i40e_virtchnl_promisc_info {
|
||||
u16 vsi_id;
|
||||
u16 flags;
|
||||
};
|
||||
|
||||
#define I40E_FLAG_VF_UNICAST_PROMISC 0x00000001
|
||||
#define I40E_FLAG_VF_MULTICAST_PROMISC 0x00000002
|
||||
|
||||
/* I40E_VIRTCHNL_OP_GET_STATS
|
||||
* VF sends this message to request stats for the selected VSI. VF uses
|
||||
* the i40e_virtchnl_queue_select struct to specify the VSI. The queue_id
|
||||
* field is ignored by the PF.
|
||||
*
|
||||
* PF replies with struct i40e_eth_stats in an external buffer.
|
||||
*/
|
||||
|
||||
/* I40E_VIRTCHNL_OP_EVENT
|
||||
* PF sends this message to inform the VF driver of events that may affect it.
|
||||
* No direct response is expected from the VF, though it may generate other
|
||||
* messages in response to this one.
|
||||
*/
|
||||
enum i40e_virtchnl_event_codes {
|
||||
I40E_VIRTCHNL_EVENT_UNKNOWN = 0,
|
||||
I40E_VIRTCHNL_EVENT_LINK_CHANGE,
|
||||
I40E_VIRTCHNL_EVENT_RESET_IMPENDING,
|
||||
I40E_VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
|
||||
};
|
||||
#define I40E_PF_EVENT_SEVERITY_INFO 0
|
||||
#define I40E_PF_EVENT_SEVERITY_ATTENTION 1
|
||||
#define I40E_PF_EVENT_SEVERITY_ACTION_REQUIRED 2
|
||||
#define I40E_PF_EVENT_SEVERITY_CERTAIN_DOOM 255
|
||||
|
||||
struct i40e_virtchnl_pf_event {
|
||||
enum i40e_virtchnl_event_codes event;
|
||||
union {
|
||||
struct {
|
||||
enum i40e_aq_link_speed link_speed;
|
||||
bool link_status;
|
||||
} link_event;
|
||||
} event_data;
|
||||
|
||||
int severity;
|
||||
};
|
||||
|
||||
/* VF reset states - these are written into the RSTAT register:
|
||||
* I40E_VFGEN_RSTAT1 on the PF
|
||||
* I40E_VFGEN_RSTAT on the VF
|
||||
* When the PF initiates a reset, it writes 0
|
||||
* When the reset is complete, it writes 1
|
||||
* When the PF detects that the VF has recovered, it writes 2
|
||||
* VF checks this register periodically to determine if a reset has occurred,
|
||||
* then polls it to know when the reset is complete.
|
||||
* If either the PF or VF reads the register while the hardware
|
||||
* is in a reset state, it will return DEADBEEF, which, when masked
|
||||
* will result in 3.
|
||||
*/
|
||||
enum i40e_vfr_states {
|
||||
I40E_VFR_INPROGRESS = 0,
|
||||
I40E_VFR_COMPLETED,
|
||||
I40E_VFR_VFACTIVE,
|
||||
I40E_VFR_UNKNOWN,
|
||||
};
|
||||
|
||||
#endif /* _I40E_VIRTCHNL_H_ */
|
4298
sys/dev/i40e/if_i40e.c
Executable file
4298
sys/dev/i40e/if_i40e.c
Executable file
File diff suppressed because it is too large
Load Diff
35
sys/modules/i40e/Makefile
Executable file
35
sys/modules/i40e/Makefile
Executable file
@ -0,0 +1,35 @@
|
||||
#$FreeBSD$
|
||||
|
||||
.include <src.opts.mk>
|
||||
|
||||
.PATH: ${.CURDIR}/../../dev/i40e
|
||||
|
||||
KMOD = if_i40e
|
||||
SRCS = device_if.h bus_if.h pci_if.h opt_bdg.h
|
||||
SRCS += if_i40e.c i40e_txrx.c i40e_osdep.c
|
||||
|
||||
# Shared source
|
||||
SRCS += i40e_common.c i40e_nvm.c i40e_adminq.c i40e_lan_hmc.c i40e_hmc.c
|
||||
|
||||
CFLAGS += -DSMP -DFORTVILLE_HW
|
||||
|
||||
# Add Flow Director support
|
||||
# CFLAGS += -DI40E_FDIR
|
||||
# A0 hardware support
|
||||
# CFLAGS += -DFORTVILLE_A0_SUPPORT
|
||||
# Debug messages / sysctls
|
||||
# CFLAGS += -DI40E_DEBUG
|
||||
|
||||
.if !defined(KERNBUILDDIR)
|
||||
.if ${MK_INET_SUPPORT} != "no"
|
||||
opt_inet.h:
|
||||
@echo "#define INET 1" > ${.TARGET}
|
||||
.endif
|
||||
|
||||
.if ${MK_INET6_SUPPORT} != "no"
|
||||
opt_inet6.h:
|
||||
@echo "#define INET6 1" > ${.TARGET}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.include <bsd.kmod.mk>
|
Loading…
x
Reference in New Issue
Block a user