2018-03-23 00:08:48 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2018-04-26 22:08:09 +07:00
|
|
|
/* Copyright(c) 2009 - 2018 Intel Corporation. */
|
2009-04-07 21:37:34 +07:00
|
|
|
|
|
|
|
/* Linux PRO/1000 Ethernet Driver main header file */
|
|
|
|
|
|
|
|
#ifndef _IGBVF_H_
|
|
|
|
#define _IGBVF_H_
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/netdevice.h>
|
2011-07-21 13:30:00 +07:00
|
|
|
#include <linux/if_vlan.h>
|
2009-04-07 21:37:34 +07:00
|
|
|
|
|
|
|
#include "vf.h"
|
|
|
|
|
|
|
|
/* Forward declarations */
|
|
|
|
struct igbvf_info;
|
|
|
|
struct igbvf_adapter;
|
|
|
|
|
|
|
|
/* Interrupt defines */
|
2015-01-21 16:57:50 +07:00
|
|
|
#define IGBVF_START_ITR 488 /* ~8000 ints/sec */
|
|
|
|
#define IGBVF_4K_ITR 980
|
|
|
|
#define IGBVF_20K_ITR 196
|
|
|
|
#define IGBVF_70K_ITR 56
|
2012-01-14 15:10:50 +07:00
|
|
|
|
|
|
|
enum latency_range {
|
|
|
|
lowest_latency = 0,
|
|
|
|
low_latency = 1,
|
|
|
|
bulk_latency = 2,
|
|
|
|
latency_invalid = 255
|
|
|
|
};
|
|
|
|
|
2009-04-22 23:21:29 +07:00
|
|
|
/* Interrupt modes, as used by the IntMode parameter */
|
2015-01-21 16:57:50 +07:00
|
|
|
#define IGBVF_INT_MODE_LEGACY 0
|
|
|
|
#define IGBVF_INT_MODE_MSI 1
|
|
|
|
#define IGBVF_INT_MODE_MSIX 2
|
2009-04-07 21:37:34 +07:00
|
|
|
|
|
|
|
/* Tx/Rx descriptor defines */
|
2015-01-21 16:57:50 +07:00
|
|
|
#define IGBVF_DEFAULT_TXD 256
|
|
|
|
#define IGBVF_MAX_TXD 4096
|
|
|
|
#define IGBVF_MIN_TXD 80
|
2009-04-07 21:37:34 +07:00
|
|
|
|
2015-01-21 16:57:50 +07:00
|
|
|
#define IGBVF_DEFAULT_RXD 256
|
|
|
|
#define IGBVF_MAX_RXD 4096
|
|
|
|
#define IGBVF_MIN_RXD 80
|
2009-04-07 21:37:34 +07:00
|
|
|
|
2015-01-21 16:57:50 +07:00
|
|
|
#define IGBVF_MIN_ITR_USECS 10 /* 100000 irq/sec */
|
|
|
|
#define IGBVF_MAX_ITR_USECS 10000 /* 100 irq/sec */
|
2009-04-07 21:37:34 +07:00
|
|
|
|
|
|
|
/* RX descriptor control thresholds.
|
|
|
|
* PTHRESH - MAC will consider prefetch if it has fewer than this number of
|
2015-01-21 16:57:50 +07:00
|
|
|
* descriptors available in its onboard memory.
|
|
|
|
* Setting this to 0 disables RX descriptor prefetch.
|
2009-04-07 21:37:34 +07:00
|
|
|
* HTHRESH - MAC will only prefetch if there are at least this many descriptors
|
2015-01-21 16:57:50 +07:00
|
|
|
* available in host memory.
|
|
|
|
* If PTHRESH is 0, this should also be 0.
|
2009-04-07 21:37:34 +07:00
|
|
|
* WTHRESH - RX descriptor writeback threshold - MAC will delay writing back
|
2015-01-21 16:57:50 +07:00
|
|
|
* descriptors until either it has this many to write back, or the
|
|
|
|
* ITR timer expires.
|
2009-04-07 21:37:34 +07:00
|
|
|
*/
|
2015-01-21 16:57:50 +07:00
|
|
|
#define IGBVF_RX_PTHRESH 16
|
|
|
|
#define IGBVF_RX_HTHRESH 8
|
|
|
|
#define IGBVF_RX_WTHRESH 1
|
2009-04-07 21:37:34 +07:00
|
|
|
|
|
|
|
/* this is the size past which hardware will drop packets when setting LPE=0 */
|
2015-01-21 16:57:50 +07:00
|
|
|
#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
|
2009-04-07 21:37:34 +07:00
|
|
|
|
2015-01-21 16:57:50 +07:00
|
|
|
#define IGBVF_FC_PAUSE_TIME 0x0680 /* 858 usec */
|
2009-04-07 21:37:34 +07:00
|
|
|
|
|
|
|
/* How many Tx Descriptors do we need to call netif_wake_queue ? */
|
2015-01-21 16:57:50 +07:00
|
|
|
#define IGBVF_TX_QUEUE_WAKE 32
|
2009-04-07 21:37:34 +07:00
|
|
|
/* How many Rx Buffers do we bundle into one write to the hardware ? */
|
2015-01-21 16:57:50 +07:00
|
|
|
#define IGBVF_RX_BUFFER_WRITE 16 /* Must be power of 2 */
|
2009-04-07 21:37:34 +07:00
|
|
|
|
2015-01-21 16:57:50 +07:00
|
|
|
#define AUTO_ALL_MODES 0
|
|
|
|
#define IGBVF_EEPROM_APME 0x0400
|
2009-04-07 21:37:34 +07:00
|
|
|
|
2015-01-21 16:57:50 +07:00
|
|
|
#define IGBVF_MNG_VLAN_NONE (-1)
|
2009-04-07 21:37:34 +07:00
|
|
|
|
2017-03-07 15:20:26 +07:00
|
|
|
#define IGBVF_MAX_MAC_FILTERS 3
|
|
|
|
|
2009-04-07 21:37:34 +07:00
|
|
|
/* Number of packet split data buffers (not including the header buffer) */
|
2015-01-21 16:57:50 +07:00
|
|
|
#define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1)
|
2009-04-07 21:37:34 +07:00
|
|
|
|
|
|
|
enum igbvf_boards {
|
|
|
|
board_vf,
|
2010-12-09 10:23:56 +07:00
|
|
|
board_i350_vf,
|
2009-04-07 21:37:34 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct igbvf_queue_stats {
|
|
|
|
u64 packets;
|
|
|
|
u64 bytes;
|
|
|
|
};
|
|
|
|
|
2015-01-21 16:57:50 +07:00
|
|
|
/* wrappers around a pointer to a socket buffer,
|
2009-04-07 21:37:34 +07:00
|
|
|
* so a DMA handle can be stored along with the buffer
|
|
|
|
*/
|
|
|
|
struct igbvf_buffer {
|
|
|
|
dma_addr_t dma;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
union {
|
|
|
|
/* Tx */
|
|
|
|
struct {
|
|
|
|
unsigned long time_stamp;
|
2013-01-31 14:15:51 +07:00
|
|
|
union e1000_adv_tx_desc *next_to_watch;
|
2009-04-07 21:37:34 +07:00
|
|
|
u16 length;
|
2009-12-02 23:47:37 +07:00
|
|
|
u16 mapped_as_page;
|
2009-04-07 21:37:34 +07:00
|
|
|
};
|
|
|
|
/* Rx */
|
|
|
|
struct {
|
|
|
|
struct page *page;
|
|
|
|
u64 page_dma;
|
|
|
|
unsigned int page_offset;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
union igbvf_desc {
|
|
|
|
union e1000_adv_rx_desc rx_desc;
|
|
|
|
union e1000_adv_tx_desc tx_desc;
|
|
|
|
struct e1000_adv_tx_context_desc tx_context_desc;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct igbvf_ring {
|
|
|
|
struct igbvf_adapter *adapter; /* backlink */
|
2015-01-21 16:57:50 +07:00
|
|
|
union igbvf_desc *desc; /* pointer to ring memory */
|
|
|
|
dma_addr_t dma; /* phys address of ring */
|
|
|
|
unsigned int size; /* length of ring in bytes */
|
|
|
|
unsigned int count; /* number of desc. in ring */
|
2009-04-07 21:37:34 +07:00
|
|
|
|
|
|
|
u16 next_to_use;
|
|
|
|
u16 next_to_clean;
|
|
|
|
|
|
|
|
u16 head;
|
|
|
|
u16 tail;
|
|
|
|
|
|
|
|
/* array of buffer information structs */
|
|
|
|
struct igbvf_buffer *buffer_info;
|
|
|
|
struct napi_struct napi;
|
|
|
|
|
|
|
|
char name[IFNAMSIZ + 5];
|
|
|
|
u32 eims_value;
|
|
|
|
u32 itr_val;
|
2012-01-14 15:10:50 +07:00
|
|
|
enum latency_range itr_range;
|
2009-04-07 21:37:34 +07:00
|
|
|
u16 itr_register;
|
|
|
|
int set_itr;
|
|
|
|
|
|
|
|
struct sk_buff *rx_skb_top;
|
|
|
|
|
|
|
|
struct igbvf_queue_stats stats;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* board specific private data structure */
|
|
|
|
struct igbvf_adapter {
|
|
|
|
struct timer_list watchdog_timer;
|
|
|
|
struct timer_list blink_timer;
|
|
|
|
|
|
|
|
struct work_struct reset_task;
|
|
|
|
struct work_struct watchdog_task;
|
|
|
|
|
|
|
|
const struct igbvf_info *ei;
|
|
|
|
|
2011-07-21 13:30:00 +07:00
|
|
|
unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
|
2009-04-07 21:37:34 +07:00
|
|
|
u32 bd_number;
|
|
|
|
u32 rx_buffer_len;
|
|
|
|
u32 polling_interval;
|
|
|
|
u16 mng_vlan_id;
|
|
|
|
u16 link_speed;
|
|
|
|
u16 link_duplex;
|
|
|
|
|
|
|
|
spinlock_t tx_queue_lock; /* prevent concurrent tail updates */
|
|
|
|
|
|
|
|
/* track device up/down/testing state */
|
|
|
|
unsigned long state;
|
|
|
|
|
|
|
|
/* Interrupt Throttle Rate */
|
2012-01-14 15:10:50 +07:00
|
|
|
u32 requested_itr; /* ints/sec or adaptive */
|
|
|
|
u32 current_itr; /* Actual ITR register value, not ints/sec */
|
2009-04-07 21:37:34 +07:00
|
|
|
|
2015-01-21 16:57:50 +07:00
|
|
|
/* Tx */
|
2009-04-07 21:37:34 +07:00
|
|
|
struct igbvf_ring *tx_ring /* One per active queue */
|
|
|
|
____cacheline_aligned_in_smp;
|
|
|
|
|
|
|
|
unsigned int restart_queue;
|
|
|
|
u32 txd_cmd;
|
|
|
|
|
|
|
|
u32 tx_int_delay;
|
|
|
|
u32 tx_abs_int_delay;
|
|
|
|
|
|
|
|
unsigned int total_tx_bytes;
|
|
|
|
unsigned int total_tx_packets;
|
|
|
|
unsigned int total_rx_bytes;
|
|
|
|
unsigned int total_rx_packets;
|
|
|
|
|
|
|
|
/* Tx stats */
|
|
|
|
u32 tx_timeout_count;
|
|
|
|
u32 tx_fifo_head;
|
|
|
|
u32 tx_head_addr;
|
|
|
|
u32 tx_fifo_size;
|
|
|
|
u32 tx_dma_failed;
|
|
|
|
|
2015-01-21 16:57:50 +07:00
|
|
|
/* Rx */
|
2009-04-07 21:37:34 +07:00
|
|
|
struct igbvf_ring *rx_ring;
|
|
|
|
|
|
|
|
u32 rx_int_delay;
|
|
|
|
u32 rx_abs_int_delay;
|
|
|
|
|
|
|
|
/* Rx stats */
|
|
|
|
u64 hw_csum_err;
|
|
|
|
u64 hw_csum_good;
|
|
|
|
u64 rx_hdr_split;
|
|
|
|
u32 alloc_rx_buff_failed;
|
|
|
|
u32 rx_dma_failed;
|
|
|
|
|
|
|
|
unsigned int rx_ps_hdr_size;
|
|
|
|
u32 max_frame_size;
|
|
|
|
u32 min_frame_size;
|
|
|
|
|
|
|
|
/* OS defined structs */
|
|
|
|
struct net_device *netdev;
|
|
|
|
struct pci_dev *pdev;
|
2015-01-21 16:57:50 +07:00
|
|
|
spinlock_t stats_lock; /* prevent concurrent stats updates */
|
2009-04-07 21:37:34 +07:00
|
|
|
|
|
|
|
/* structs defined in e1000_hw.h */
|
|
|
|
struct e1000_hw hw;
|
|
|
|
|
|
|
|
/* The VF counters don't clear on read so we have to get a base
|
|
|
|
* count on driver start up and always subtract that base on
|
|
|
|
* on the first update, thus the flag..
|
|
|
|
*/
|
|
|
|
struct e1000_vf_stats stats;
|
|
|
|
u64 zero_base;
|
|
|
|
|
|
|
|
struct igbvf_ring test_tx_ring;
|
|
|
|
struct igbvf_ring test_rx_ring;
|
|
|
|
u32 test_icr;
|
|
|
|
|
|
|
|
u32 msg_enable;
|
|
|
|
struct msix_entry *msix_entries;
|
|
|
|
int int_mode;
|
|
|
|
u32 eims_enable_mask;
|
|
|
|
u32 eims_other;
|
|
|
|
u32 int_counter0;
|
|
|
|
u32 int_counter1;
|
|
|
|
|
|
|
|
u32 eeprom_wol;
|
|
|
|
u32 wol;
|
|
|
|
u32 pba;
|
|
|
|
|
|
|
|
bool fc_autoneg;
|
|
|
|
|
|
|
|
unsigned long led_status;
|
|
|
|
|
|
|
|
unsigned int flags;
|
2009-12-12 13:58:14 +07:00
|
|
|
unsigned long last_reset;
|
2009-04-07 21:37:34 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct igbvf_info {
|
2015-01-21 16:57:50 +07:00
|
|
|
enum e1000_mac_type mac;
|
|
|
|
unsigned int flags;
|
|
|
|
u32 pba;
|
|
|
|
void (*init_ops)(struct e1000_hw *);
|
|
|
|
s32 (*get_variants)(struct igbvf_adapter *);
|
2009-04-07 21:37:34 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
/* hardware capability, feature, and workaround flags */
|
2016-04-14 06:08:31 +07:00
|
|
|
#define IGBVF_FLAG_RX_CSUM_DISABLED BIT(0)
|
|
|
|
#define IGBVF_FLAG_RX_LB_VLAN_BSWAP BIT(1)
|
2009-04-07 21:37:34 +07:00
|
|
|
#define IGBVF_RX_DESC_ADV(R, i) \
|
|
|
|
(&((((R).desc))[i].rx_desc))
|
|
|
|
#define IGBVF_TX_DESC_ADV(R, i) \
|
|
|
|
(&((((R).desc))[i].tx_desc))
|
|
|
|
#define IGBVF_TX_CTXTDESC_ADV(R, i) \
|
|
|
|
(&((((R).desc))[i].tx_context_desc))
|
|
|
|
|
|
|
|
enum igbvf_state_t {
|
|
|
|
__IGBVF_TESTING,
|
|
|
|
__IGBVF_RESETTING,
|
|
|
|
__IGBVF_DOWN
|
|
|
|
};
|
|
|
|
|
|
|
|
extern char igbvf_driver_name[];
|
|
|
|
extern const char igbvf_driver_version[];
|
|
|
|
|
2013-09-24 01:37:59 +07:00
|
|
|
void igbvf_check_options(struct igbvf_adapter *);
|
|
|
|
void igbvf_set_ethtool_ops(struct net_device *);
|
|
|
|
|
|
|
|
int igbvf_up(struct igbvf_adapter *);
|
|
|
|
void igbvf_down(struct igbvf_adapter *);
|
|
|
|
void igbvf_reinit_locked(struct igbvf_adapter *);
|
|
|
|
int igbvf_setup_rx_resources(struct igbvf_adapter *, struct igbvf_ring *);
|
|
|
|
int igbvf_setup_tx_resources(struct igbvf_adapter *, struct igbvf_ring *);
|
|
|
|
void igbvf_free_rx_resources(struct igbvf_ring *);
|
|
|
|
void igbvf_free_tx_resources(struct igbvf_ring *);
|
|
|
|
void igbvf_update_stats(struct igbvf_adapter *);
|
2009-04-07 21:37:34 +07:00
|
|
|
|
|
|
|
extern unsigned int copybreak;
|
|
|
|
|
|
|
|
#endif /* _IGBVF_H_ */
|