| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* Copyright(c) 2009 - 2018 Intel Corporation. */ |
| 3 |
|
| 4 |
/* Linux PRO/1000 Ethernet Driver main header file */ |
| 5 |
|
| 6 |
#ifndef _IGBVF_H_ |
| 7 |
#define _IGBVF_H_ |
| 8 |
|
| 9 |
#include <linux/types.h> |
| 10 |
#include <linux/timer.h> |
| 11 |
#include <linux/io.h> |
| 12 |
#include <linux/netdevice.h> |
| 13 |
#include <linux/if_vlan.h> |
| 14 |
|
| 15 |
#include "vf.h" |
| 16 |
|
| 17 |
/* Forward declarations */ |
| 18 |
struct igbvf_info; |
| 19 |
struct igbvf_adapter; |
| 20 |
|
| 21 |
/* Interrupt defines */ |
| 22 |
#define IGBVF_START_ITR 488 /* ~8000 ints/sec */ |
| 23 |
#define IGBVF_4K_ITR 980 |
| 24 |
#define IGBVF_20K_ITR 196 |
| 25 |
#define IGBVF_70K_ITR 56 |
| 26 |
|
| 27 |
enum latency_range { |
| 28 |
lowest_latency = 0, |
| 29 |
low_latency = 1, |
| 30 |
bulk_latency = 2, |
| 31 |
latency_invalid = 255 |
| 32 |
}; |
| 33 |
|
| 34 |
/* Interrupt modes, as used by the IntMode parameter */ |
| 35 |
#define IGBVF_INT_MODE_LEGACY 0 |
| 36 |
#define IGBVF_INT_MODE_MSI 1 |
| 37 |
#define IGBVF_INT_MODE_MSIX 2 |
| 38 |
|
| 39 |
/* Tx/Rx descriptor defines */ |
| 40 |
#define IGBVF_DEFAULT_TXD 256 |
| 41 |
#define IGBVF_MAX_TXD 4096 |
| 42 |
#define IGBVF_MIN_TXD 64 |
| 43 |
|
| 44 |
#define IGBVF_DEFAULT_RXD 256 |
| 45 |
#define IGBVF_MAX_RXD 4096 |
| 46 |
#define IGBVF_MIN_RXD 64 |
| 47 |
|
| 48 |
#define IGBVF_MIN_ITR_USECS 10 /* 100000 irq/sec */ |
| 49 |
#define IGBVF_MAX_ITR_USECS 10000 /* 100 irq/sec */ |
| 50 |
|
| 51 |
/* RX descriptor control thresholds. |
| 52 |
* PTHRESH - MAC will consider prefetch if it has fewer than this number of |
| 53 |
* descriptors available in its onboard memory. |
| 54 |
* Setting this to 0 disables RX descriptor prefetch. |
| 55 |
* HTHRESH - MAC will only prefetch if there are at least this many descriptors |
| 56 |
* available in host memory. |
| 57 |
* If PTHRESH is 0, this should also be 0. |
| 58 |
* WTHRESH - RX descriptor writeback threshold - MAC will delay writing back |
| 59 |
* descriptors until either it has this many to write back, or the |
| 60 |
* ITR timer expires. |
| 61 |
*/ |
| 62 |
#define IGBVF_RX_PTHRESH 16 |
| 63 |
#define IGBVF_RX_HTHRESH 8 |
| 64 |
#define IGBVF_RX_WTHRESH 1 |
| 65 |
|
| 66 |
/* this is the size past which hardware will drop packets when setting LPE=0 */ |
| 67 |
#define MAXIMUM_ETHERNET_VLAN_SIZE 1522 |
| 68 |
|
| 69 |
#define IGBVF_FC_PAUSE_TIME 0x0680 /* 858 usec */ |
| 70 |
|
| 71 |
/* How many Tx Descriptors do we need to call netif_wake_queue ? */ |
| 72 |
#define IGBVF_TX_QUEUE_WAKE 32 |
| 73 |
/* How many Rx Buffers do we bundle into one write to the hardware ? */ |
| 74 |
#define IGBVF_RX_BUFFER_WRITE 16 /* Must be power of 2 */ |
| 75 |
|
| 76 |
#define AUTO_ALL_MODES 0 |
| 77 |
#define IGBVF_EEPROM_APME 0x0400 |
| 78 |
|
| 79 |
#define IGBVF_MNG_VLAN_NONE (-1) |
| 80 |
|
| 81 |
#define IGBVF_MAX_MAC_FILTERS 3 |
| 82 |
|
| 83 |
/* Number of packet split data buffers (not including the header buffer) */ |
| 84 |
#define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1) |
| 85 |
|
| 86 |
enum igbvf_boards { |
| 87 |
board_vf, |
| 88 |
board_i350_vf, |
| 89 |
}; |
| 90 |
|
| 91 |
struct igbvf_queue_stats { |
| 92 |
u64 packets; |
| 93 |
u64 bytes; |
| 94 |
}; |
| 95 |
|
| 96 |
/* wrappers around a pointer to a socket buffer, |
| 97 |
* so a DMA handle can be stored along with the buffer |
| 98 |
*/ |
| 99 |
struct igbvf_buffer { |
| 100 |
dma_addr_t dma; |
| 101 |
struct sk_buff *skb; |
| 102 |
union { |
| 103 |
/* Tx */ |
| 104 |
struct { |
| 105 |
unsigned long time_stamp; |
| 106 |
union e1000_adv_tx_desc *next_to_watch; |
| 107 |
u16 length; |
| 108 |
u16 mapped_as_page; |
| 109 |
}; |
| 110 |
/* Rx */ |
| 111 |
struct { |
| 112 |
struct page *page; |
| 113 |
u64 page_dma; |
| 114 |
unsigned int page_offset; |
| 115 |
}; |
| 116 |
}; |
| 117 |
}; |
| 118 |
|
| 119 |
union igbvf_desc { |
| 120 |
union e1000_adv_rx_desc rx_desc; |
| 121 |
union e1000_adv_tx_desc tx_desc; |
| 122 |
struct e1000_adv_tx_context_desc tx_context_desc; |
| 123 |
}; |
| 124 |
|
| 125 |
struct igbvf_ring { |
| 126 |
struct igbvf_adapter *adapter; /* backlink */ |
| 127 |
union igbvf_desc *desc; /* pointer to ring memory */ |
| 128 |
dma_addr_t dma; /* phys address of ring */ |
| 129 |
unsigned int size; /* length of ring in bytes */ |
| 130 |
unsigned int count; /* number of desc. in ring */ |
| 131 |
|
| 132 |
u16 next_to_use; |
| 133 |
u16 next_to_clean; |
| 134 |
|
| 135 |
u16 head; |
| 136 |
u16 tail; |
| 137 |
|
| 138 |
/* array of buffer information structs */ |
| 139 |
struct igbvf_buffer *buffer_info; |
| 140 |
struct napi_struct napi; |
| 141 |
|
| 142 |
char name[IFNAMSIZ + 5]; |
| 143 |
u32 eims_value; |
| 144 |
u32 itr_val; |
| 145 |
enum latency_range itr_range; |
| 146 |
u16 itr_register; |
| 147 |
int set_itr; |
| 148 |
|
| 149 |
struct sk_buff *rx_skb_top; |
| 150 |
|
| 151 |
struct igbvf_queue_stats stats; |
| 152 |
}; |
| 153 |
|
| 154 |
/* board specific private data structure */ |
| 155 |
struct igbvf_adapter { |
| 156 |
struct timer_list watchdog_timer; |
| 157 |
|
| 158 |
struct work_struct reset_task; |
| 159 |
struct work_struct watchdog_task; |
| 160 |
|
| 161 |
const struct igbvf_info *ei; |
| 162 |
|
| 163 |
unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; |
| 164 |
u32 rx_buffer_len; |
| 165 |
u16 link_speed; |
| 166 |
u16 link_duplex; |
| 167 |
|
| 168 |
/* track device up/down/testing state */ |
| 169 |
unsigned long state; |
| 170 |
|
| 171 |
/* Interrupt Throttle Rate */ |
| 172 |
u32 requested_itr; /* ints/sec or adaptive */ |
| 173 |
u32 current_itr; /* Actual ITR register value, not ints/sec */ |
| 174 |
|
| 175 |
/* Tx */ |
| 176 |
struct igbvf_ring *tx_ring /* One per active queue */ |
| 177 |
____cacheline_aligned_in_smp; |
| 178 |
|
| 179 |
unsigned int restart_queue; |
| 180 |
u32 txd_cmd; |
| 181 |
|
| 182 |
unsigned int total_tx_bytes; |
| 183 |
unsigned int total_tx_packets; |
| 184 |
unsigned int total_rx_bytes; |
| 185 |
unsigned int total_rx_packets; |
| 186 |
|
| 187 |
/* Tx stats */ |
| 188 |
u32 tx_timeout_count; |
| 189 |
|
| 190 |
/* Rx */ |
| 191 |
struct igbvf_ring *rx_ring; |
| 192 |
|
| 193 |
/* Rx stats */ |
| 194 |
u64 hw_csum_err; |
| 195 |
u64 hw_csum_good; |
| 196 |
u64 rx_hdr_split; |
| 197 |
u32 alloc_rx_buff_failed; |
| 198 |
|
| 199 |
unsigned int rx_ps_hdr_size; |
| 200 |
u32 max_frame_size; |
| 201 |
u32 min_frame_size; |
| 202 |
|
| 203 |
/* OS defined structs */ |
| 204 |
struct net_device *netdev; |
| 205 |
struct pci_dev *pdev; |
| 206 |
|
| 207 |
/* structs defined in e1000_hw.h */ |
| 208 |
struct e1000_hw hw; |
| 209 |
|
| 210 |
/* The VF counters don't clear on read so we have to get a base |
| 211 |
* count on driver start up and always subtract that base on |
| 212 |
* the first update, thus the flag.. |
| 213 |
*/ |
| 214 |
struct e1000_vf_stats stats; |
| 215 |
u64 zero_base; |
| 216 |
|
| 217 |
u32 msg_enable; |
| 218 |
struct msix_entry *msix_entries; |
| 219 |
u32 eims_enable_mask; |
| 220 |
u32 eims_other; |
| 221 |
|
| 222 |
u32 wol; |
| 223 |
u32 pba; |
| 224 |
|
| 225 |
unsigned int flags; |
| 226 |
unsigned long last_reset; |
| 227 |
}; |
| 228 |
|
| 229 |
struct igbvf_info { |
| 230 |
enum e1000_mac_type mac; |
| 231 |
unsigned int flags; |
| 232 |
u32 pba; |
| 233 |
void (*init_ops)(struct e1000_hw *); |
| 234 |
s32 (*get_variants)(struct igbvf_adapter *); |
| 235 |
}; |
| 236 |
|
| 237 |
/* hardware capability, feature, and workaround flags */ |
| 238 |
#define IGBVF_FLAG_RX_CSUM_DISABLED BIT(0) |
| 239 |
#define IGBVF_FLAG_RX_LB_VLAN_BSWAP BIT(1) |
| 240 |
#define IGBVF_RX_DESC_ADV(R, i) \ |
| 241 |
(&((((R).desc))[i].rx_desc)) |
| 242 |
#define IGBVF_TX_DESC_ADV(R, i) \ |
| 243 |
(&((((R).desc))[i].tx_desc)) |
| 244 |
#define IGBVF_TX_CTXTDESC_ADV(R, i) \ |
| 245 |
(&((((R).desc))[i].tx_context_desc)) |
| 246 |
|
| 247 |
enum igbvf_state_t { |
| 248 |
__IGBVF_TESTING, |
| 249 |
__IGBVF_RESETTING, |
| 250 |
__IGBVF_DOWN |
| 251 |
}; |
| 252 |
|
| 253 |
extern char igbvf_driver_name[]; |
| 254 |
|
| 255 |
void igbvf_set_ethtool_ops(struct net_device *); |
| 256 |
|
| 257 |
int igbvf_up(struct igbvf_adapter *); |
| 258 |
void igbvf_down(struct igbvf_adapter *); |
| 259 |
void igbvf_reinit_locked(struct igbvf_adapter *); |
| 260 |
int igbvf_setup_rx_resources(struct igbvf_adapter *, struct igbvf_ring *); |
| 261 |
int igbvf_setup_tx_resources(struct igbvf_adapter *, struct igbvf_ring *); |
| 262 |
void igbvf_free_rx_resources(struct igbvf_ring *); |
| 263 |
void igbvf_free_tx_resources(struct igbvf_ring *); |
| 264 |
void igbvf_update_stats(struct igbvf_adapter *); |
| 265 |
|
| 266 |
extern unsigned int copybreak; |
| 267 |
|
| 268 |
#endif /* _IGBVF_H_ */ |