]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - drivers/net/ethernet/intel/i40e/i40e.h
i40e: enable packet split only when IOMMU present
[mirror_ubuntu-jammy-kernel.git] / drivers / net / ethernet / intel / i40e / i40e.h
1 /*******************************************************************************
2 *
3 * Intel Ethernet Controller XL710 Family Linux Driver
4 * Copyright(c) 2013 - 2015 Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
20 *
21 * Contact Information:
22 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
25 ******************************************************************************/
26
27 #ifndef _I40E_H_
28 #define _I40E_H_
29
30 #include <net/tcp.h>
31 #include <net/udp.h>
32 #include <linux/types.h>
33 #include <linux/errno.h>
34 #include <linux/module.h>
35 #include <linux/pci.h>
36 #include <linux/aer.h>
37 #include <linux/netdevice.h>
38 #include <linux/ioport.h>
39 #include <linux/iommu.h>
40 #include <linux/slab.h>
41 #include <linux/list.h>
42 #include <linux/string.h>
43 #include <linux/in.h>
44 #include <linux/ip.h>
45 #include <linux/tcp.h>
46 #include <linux/sctp.h>
47 #include <linux/pkt_sched.h>
48 #include <linux/ipv6.h>
49 #include <net/checksum.h>
50 #include <net/ip6_checksum.h>
51 #include <linux/ethtool.h>
52 #include <linux/if_vlan.h>
53 #include <linux/clocksource.h>
54 #include <linux/net_tstamp.h>
55 #include <linux/ptp_clock_kernel.h>
56 #include "i40e_type.h"
57 #include "i40e_prototype.h"
58 #ifdef I40E_FCOE
59 #include "i40e_fcoe.h"
60 #endif
61 #include "i40e_virtchnl.h"
62 #include "i40e_virtchnl_pf.h"
63 #include "i40e_txrx.h"
64 #include "i40e_dcb.h"
65
66 /* Useful i40e defaults */
67 #define I40E_BASE_PF_SEID 16
68 #define I40E_BASE_VSI_SEID 512
69 #define I40E_BASE_VEB_SEID 288
70 #define I40E_MAX_VEB 16
71
72 #define I40E_MAX_NUM_DESCRIPTORS 4096
73 #define I40E_MAX_REGISTER 0x800000
74 #define I40E_DEFAULT_NUM_DESCRIPTORS 512
75 #define I40E_REQ_DESCRIPTOR_MULTIPLE 32
76 #define I40E_MIN_NUM_DESCRIPTORS 64
77 #define I40E_MIN_MSIX 2
78 #define I40E_DEFAULT_NUM_VMDQ_VSI 8 /* max 256 VSIs */
79 #define I40E_MIN_VSI_ALLOC 51 /* LAN, ATR, FCOE, 32 VF, 16 VMDQ */
80 #define I40E_DEFAULT_QUEUES_PER_VMDQ 2 /* max 16 qps */
81 #define I40E_DEFAULT_QUEUES_PER_VF 4
82 #define I40E_DEFAULT_QUEUES_PER_TC 1 /* should be a power of 2 */
83 #define I40E_MAX_QUEUES_PER_TC 64 /* should be a power of 2 */
84 #define I40E_FDIR_RING 0
85 #define I40E_FDIR_RING_COUNT 32
86 #ifdef I40E_FCOE
87 #define I40E_DEFAULT_FCOE 8 /* default number of QPs for FCoE */
88 #define I40E_MINIMUM_FCOE 1 /* minimum number of QPs for FCoE */
89 #endif /* I40E_FCOE */
90 #define I40E_MAX_AQ_BUF_SIZE 4096
91 #define I40E_AQ_LEN 256
92 #define I40E_AQ_WORK_LIMIT 32
93 #define I40E_MAX_USER_PRIORITY 8
94 #define I40E_DEFAULT_MSG_ENABLE 4
95 #define I40E_QUEUE_WAIT_RETRY_LIMIT 10
96 #define I40E_INT_NAME_STR_LEN (IFNAMSIZ + 9)
97
98 #define I40E_NVM_VERSION_LO_SHIFT 0
99 #define I40E_NVM_VERSION_LO_MASK (0xff << I40E_NVM_VERSION_LO_SHIFT)
100 #define I40E_NVM_VERSION_HI_SHIFT 12
101 #define I40E_NVM_VERSION_HI_MASK (0xf << I40E_NVM_VERSION_HI_SHIFT)
102
103 /* The values in here are decimal coded as hex as is the case in the NVM map*/
104 #define I40E_CURRENT_NVM_VERSION_HI 0x2
105 #define I40E_CURRENT_NVM_VERSION_LO 0x40
106
107 /* magic for getting defines into strings */
108 #define STRINGIFY(foo) #foo
109 #define XSTRINGIFY(bar) STRINGIFY(bar)
110
111 #define I40E_RX_DESC(R, i) \
112 ((ring_is_16byte_desc_enabled(R)) \
113 ? (union i40e_32byte_rx_desc *) \
114 (&(((union i40e_16byte_rx_desc *)((R)->desc))[i])) \
115 : (&(((union i40e_32byte_rx_desc *)((R)->desc))[i])))
116 #define I40E_TX_DESC(R, i) \
117 (&(((struct i40e_tx_desc *)((R)->desc))[i]))
118 #define I40E_TX_CTXTDESC(R, i) \
119 (&(((struct i40e_tx_context_desc *)((R)->desc))[i]))
120 #define I40E_TX_FDIRDESC(R, i) \
121 (&(((struct i40e_filter_program_desc *)((R)->desc))[i]))
122
123 /* default to trying for four seconds */
124 #define I40E_TRY_LINK_TIMEOUT (4 * HZ)
125
126 /* driver state flags */
127 enum i40e_state_t {
128 __I40E_TESTING,
129 __I40E_CONFIG_BUSY,
130 __I40E_CONFIG_DONE,
131 __I40E_DOWN,
132 __I40E_NEEDS_RESTART,
133 __I40E_SERVICE_SCHED,
134 __I40E_ADMINQ_EVENT_PENDING,
135 __I40E_MDD_EVENT_PENDING,
136 __I40E_VFLR_EVENT_PENDING,
137 __I40E_RESET_RECOVERY_PENDING,
138 __I40E_RESET_INTR_RECEIVED,
139 __I40E_REINIT_REQUESTED,
140 __I40E_PF_RESET_REQUESTED,
141 __I40E_CORE_RESET_REQUESTED,
142 __I40E_GLOBAL_RESET_REQUESTED,
143 __I40E_EMP_RESET_REQUESTED,
144 __I40E_EMP_RESET_INTR_RECEIVED,
145 __I40E_FILTER_OVERFLOW_PROMISC,
146 __I40E_SUSPENDED,
147 __I40E_PTP_TX_IN_PROGRESS,
148 __I40E_BAD_EEPROM,
149 __I40E_DOWN_REQUESTED,
150 __I40E_FD_FLUSH_REQUESTED,
151 __I40E_RESET_FAILED,
152 __I40E_PORT_TX_SUSPENDED,
153 __I40E_VF_DISABLE,
154 };
155
156 enum i40e_interrupt_policy {
157 I40E_INTERRUPT_BEST_CASE,
158 I40E_INTERRUPT_MEDIUM,
159 I40E_INTERRUPT_LOWEST
160 };
161
162 struct i40e_lump_tracking {
163 u16 num_entries;
164 u16 search_hint;
165 u16 list[0];
166 #define I40E_PILE_VALID_BIT 0x8000
167 };
168
169 #define I40E_DEFAULT_ATR_SAMPLE_RATE 20
170 #define I40E_FDIR_MAX_RAW_PACKET_SIZE 512
171 #define I40E_FDIR_BUFFER_FULL_MARGIN 10
172 #define I40E_FDIR_BUFFER_HEAD_ROOM 32
173
174 enum i40e_fd_stat_idx {
175 I40E_FD_STAT_ATR,
176 I40E_FD_STAT_SB,
177 I40E_FD_STAT_PF_COUNT
178 };
179 #define I40E_FD_STAT_PF_IDX(pf_id) ((pf_id) * I40E_FD_STAT_PF_COUNT)
180 #define I40E_FD_ATR_STAT_IDX(pf_id) \
181 (I40E_FD_STAT_PF_IDX(pf_id) + I40E_FD_STAT_ATR)
182 #define I40E_FD_SB_STAT_IDX(pf_id) \
183 (I40E_FD_STAT_PF_IDX(pf_id) + I40E_FD_STAT_SB)
184
185 struct i40e_fdir_filter {
186 struct hlist_node fdir_node;
187 /* filter ipnut set */
188 u8 flow_type;
189 u8 ip4_proto;
190 /* TX packet view of src and dst */
191 __be32 dst_ip[4];
192 __be32 src_ip[4];
193 __be16 src_port;
194 __be16 dst_port;
195 __be32 sctp_v_tag;
196 /* filter control */
197 u16 q_index;
198 u8 flex_off;
199 u8 pctype;
200 u16 dest_vsi;
201 u8 dest_ctl;
202 u8 fd_status;
203 u16 cnt_index;
204 u32 fd_id;
205 };
206
207 #define I40E_ETH_P_LLDP 0x88cc
208
209 #define I40E_DCB_PRIO_TYPE_STRICT 0
210 #define I40E_DCB_PRIO_TYPE_ETS 1
211 #define I40E_DCB_STRICT_PRIO_CREDITS 127
212 #define I40E_MAX_USER_PRIORITY 8
213 /* DCB per TC information data structure */
214 struct i40e_tc_info {
215 u16 qoffset; /* Queue offset from base queue */
216 u16 qcount; /* Total Queues */
217 u8 netdev_tc; /* Netdev TC index if netdev associated */
218 };
219
220 /* TC configuration data structure */
221 struct i40e_tc_configuration {
222 u8 numtc; /* Total number of enabled TCs */
223 u8 enabled_tc; /* TC map */
224 struct i40e_tc_info tc_info[I40E_MAX_TRAFFIC_CLASS];
225 };
226
227 /* struct that defines the Ethernet device */
228 struct i40e_pf {
229 struct pci_dev *pdev;
230 struct i40e_hw hw;
231 unsigned long state;
232 unsigned long link_check_timeout;
233 struct msix_entry *msix_entries;
234 bool fc_autoneg_status;
235
236 u16 eeprom_version;
237 u16 num_vmdq_vsis; /* num vmdq vsis this pf has set up */
238 u16 num_vmdq_qps; /* num queue pairs per vmdq pool */
239 u16 num_vmdq_msix; /* num queue vectors per vmdq pool */
240 u16 num_req_vfs; /* num vfs requested for this vf */
241 u16 num_vf_qps; /* num queue pairs per vf */
242 #ifdef I40E_FCOE
243 u16 num_fcoe_qps; /* num fcoe queues this pf has set up */
244 u16 num_fcoe_msix; /* num queue vectors per fcoe pool */
245 #endif /* I40E_FCOE */
246 u16 num_lan_qps; /* num lan queues this pf has set up */
247 u16 num_lan_msix; /* num queue vectors for the base pf vsi */
248 int queues_left; /* queues left unclaimed */
249 u16 rss_size; /* num queues in the RSS array */
250 u16 rss_size_max; /* HW defined max RSS queues */
251 u16 fdir_pf_filter_count; /* num of guaranteed filters for this PF */
252 u16 num_alloc_vsi; /* num VSIs this driver supports */
253 u8 atr_sample_rate;
254 bool wol_en;
255
256 struct hlist_head fdir_filter_list;
257 u16 fdir_pf_active_filters;
258 u16 fd_sb_cnt_idx;
259 u16 fd_atr_cnt_idx;
260 unsigned long fd_flush_timestamp;
261 u32 fd_flush_cnt;
262 u32 fd_add_err;
263 u32 fd_atr_cnt;
264 u32 fd_tcp_rule;
265
266 #ifdef CONFIG_I40E_VXLAN
267 __be16 vxlan_ports[I40E_MAX_PF_UDP_OFFLOAD_PORTS];
268 u16 pending_vxlan_bitmap;
269
270 #endif
271 enum i40e_interrupt_policy int_policy;
272 u16 rx_itr_default;
273 u16 tx_itr_default;
274 u16 msg_enable;
275 char int_name[I40E_INT_NAME_STR_LEN];
276 u16 adminq_work_limit; /* num of admin receive queue desc to process */
277 unsigned long service_timer_period;
278 unsigned long service_timer_previous;
279 struct timer_list service_timer;
280 struct work_struct service_task;
281
282 u64 flags;
283 #define I40E_FLAG_RX_CSUM_ENABLED (u64)(1 << 1)
284 #define I40E_FLAG_MSI_ENABLED (u64)(1 << 2)
285 #define I40E_FLAG_MSIX_ENABLED (u64)(1 << 3)
286 #define I40E_FLAG_RX_1BUF_ENABLED (u64)(1 << 4)
287 #define I40E_FLAG_RX_PS_ENABLED (u64)(1 << 5)
288 #define I40E_FLAG_RSS_ENABLED (u64)(1 << 6)
289 #define I40E_FLAG_VMDQ_ENABLED (u64)(1 << 7)
290 #define I40E_FLAG_FDIR_REQUIRES_REINIT (u64)(1 << 8)
291 #define I40E_FLAG_NEED_LINK_UPDATE (u64)(1 << 9)
292 #ifdef I40E_FCOE
293 #define I40E_FLAG_FCOE_ENABLED (u64)(1 << 11)
294 #endif /* I40E_FCOE */
295 #define I40E_FLAG_IN_NETPOLL (u64)(1 << 12)
296 #define I40E_FLAG_16BYTE_RX_DESC_ENABLED (u64)(1 << 13)
297 #define I40E_FLAG_CLEAN_ADMINQ (u64)(1 << 14)
298 #define I40E_FLAG_FILTER_SYNC (u64)(1 << 15)
299 #define I40E_FLAG_PROCESS_MDD_EVENT (u64)(1 << 17)
300 #define I40E_FLAG_PROCESS_VFLR_EVENT (u64)(1 << 18)
301 #define I40E_FLAG_SRIOV_ENABLED (u64)(1 << 19)
302 #define I40E_FLAG_DCB_ENABLED (u64)(1 << 20)
303 #define I40E_FLAG_FD_SB_ENABLED (u64)(1 << 21)
304 #define I40E_FLAG_FD_ATR_ENABLED (u64)(1 << 22)
305 #define I40E_FLAG_PTP (u64)(1 << 25)
306 #define I40E_FLAG_MFP_ENABLED (u64)(1 << 26)
307 #ifdef CONFIG_I40E_VXLAN
308 #define I40E_FLAG_VXLAN_FILTER_SYNC (u64)(1 << 27)
309 #endif
310 #define I40E_FLAG_PORT_ID_VALID (u64)(1 << 28)
311 #define I40E_FLAG_DCB_CAPABLE (u64)(1 << 29)
312
313 /* tracks features that get auto disabled by errors */
314 u64 auto_disable_flags;
315
316 #ifdef I40E_FCOE
317 struct i40e_fcoe fcoe;
318
319 #endif /* I40E_FCOE */
320 bool stat_offsets_loaded;
321 struct i40e_hw_port_stats stats;
322 struct i40e_hw_port_stats stats_offsets;
323 u32 tx_timeout_count;
324 u32 tx_timeout_recovery_level;
325 unsigned long tx_timeout_last_recovery;
326 u32 tx_sluggish_count;
327 u32 hw_csum_rx_error;
328 u32 led_status;
329 u16 corer_count; /* Core reset count */
330 u16 globr_count; /* Global reset count */
331 u16 empr_count; /* EMP reset count */
332 u16 pfr_count; /* PF reset count */
333 u16 sw_int_count; /* SW interrupt count */
334
335 struct mutex switch_mutex;
336 u16 lan_vsi; /* our default LAN VSI */
337 u16 lan_veb; /* initial relay, if exists */
338 #define I40E_NO_VEB 0xffff
339 #define I40E_NO_VSI 0xffff
340 u16 next_vsi; /* Next unallocated VSI - 0-based! */
341 struct i40e_vsi **vsi;
342 struct i40e_veb *veb[I40E_MAX_VEB];
343
344 struct i40e_lump_tracking *qp_pile;
345 struct i40e_lump_tracking *irq_pile;
346
347 /* switch config info */
348 u16 pf_seid;
349 u16 main_vsi_seid;
350 u16 mac_seid;
351 struct kobject *switch_kobj;
352 #ifdef CONFIG_DEBUG_FS
353 struct dentry *i40e_dbg_pf;
354 #endif /* CONFIG_DEBUG_FS */
355
356 u16 instance; /* A unique number per i40e_pf instance in the system */
357
358 /* sr-iov config info */
359 struct i40e_vf *vf;
360 int num_alloc_vfs; /* actual number of VFs allocated */
361 u32 vf_aq_requests;
362
363 /* DCBx/DCBNL capability for PF that indicates
364 * whether DCBx is managed by firmware or host
365 * based agent (LLDPAD). Also, indicates what
366 * flavor of DCBx protocol (IEEE/CEE) is supported
367 * by the device. For now we're supporting IEEE
368 * mode only.
369 */
370 u16 dcbx_cap;
371
372 u32 fcoe_hmc_filt_num;
373 u32 fcoe_hmc_cntx_num;
374 struct i40e_filter_control_settings filter_settings;
375
376 struct ptp_clock *ptp_clock;
377 struct ptp_clock_info ptp_caps;
378 struct sk_buff *ptp_tx_skb;
379 struct hwtstamp_config tstamp_config;
380 unsigned long last_rx_ptp_check;
381 spinlock_t tmreg_lock; /* Used to protect the device time registers. */
382 u64 ptp_base_adj;
383 u32 tx_hwtstamp_timeouts;
384 u32 rx_hwtstamp_cleared;
385 bool ptp_tx;
386 bool ptp_rx;
387 u16 rss_table_size;
388 };
389
390 struct i40e_mac_filter {
391 struct list_head list;
392 u8 macaddr[ETH_ALEN];
393 #define I40E_VLAN_ANY -1
394 s16 vlan;
395 u8 counter; /* number of instances of this filter */
396 bool is_vf; /* filter belongs to a VF */
397 bool is_netdev; /* filter belongs to a netdev */
398 bool changed; /* filter needs to be sync'd to the HW */
399 bool is_laa; /* filter is a Locally Administered Address */
400 };
401
402 struct i40e_veb {
403 struct i40e_pf *pf;
404 u16 idx;
405 u16 veb_idx; /* index of VEB parent */
406 u16 seid;
407 u16 uplink_seid;
408 u16 stats_idx; /* index of VEB parent */
409 u8 enabled_tc;
410 u16 flags;
411 u16 bw_limit;
412 u8 bw_max_quanta;
413 bool is_abs_credits;
414 u8 bw_tc_share_credits[I40E_MAX_TRAFFIC_CLASS];
415 u16 bw_tc_limit_credits[I40E_MAX_TRAFFIC_CLASS];
416 u8 bw_tc_max_quanta[I40E_MAX_TRAFFIC_CLASS];
417 struct kobject *kobj;
418 bool stat_offsets_loaded;
419 struct i40e_eth_stats stats;
420 struct i40e_eth_stats stats_offsets;
421 };
422
423 /* struct that defines a VSI, associated with a dev */
424 struct i40e_vsi {
425 struct net_device *netdev;
426 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
427 bool netdev_registered;
428 bool stat_offsets_loaded;
429
430 u32 current_netdev_flags;
431 unsigned long state;
432 #define I40E_VSI_FLAG_FILTER_CHANGED (1<<0)
433 #define I40E_VSI_FLAG_VEB_OWNER (1<<1)
434 unsigned long flags;
435
436 struct list_head mac_filter_list;
437
438 /* VSI stats */
439 struct rtnl_link_stats64 net_stats;
440 struct rtnl_link_stats64 net_stats_offsets;
441 struct i40e_eth_stats eth_stats;
442 struct i40e_eth_stats eth_stats_offsets;
443 #ifdef I40E_FCOE
444 struct i40e_fcoe_stats fcoe_stats;
445 struct i40e_fcoe_stats fcoe_stats_offsets;
446 bool fcoe_stat_offsets_loaded;
447 #endif
448 u32 tx_restart;
449 u32 tx_busy;
450 u32 rx_buf_failed;
451 u32 rx_page_failed;
452
453 /* These are containers of ring pointers, allocated at run-time */
454 struct i40e_ring **rx_rings;
455 struct i40e_ring **tx_rings;
456
457 u16 work_limit;
458 /* high bit set means dynamic, use accessor routines to read/write.
459 * hardware only supports 2us resolution for the ITR registers.
460 * these values always store the USER setting, and must be converted
461 * before programming to a register.
462 */
463 u16 rx_itr_setting;
464 u16 tx_itr_setting;
465
466 u16 max_frame;
467 u16 rx_hdr_len;
468 u16 rx_buf_len;
469 u8 dtype;
470
471 /* List of q_vectors allocated to this VSI */
472 struct i40e_q_vector **q_vectors;
473 int num_q_vectors;
474 int base_vector;
475 bool irqs_ready;
476
477 u16 seid; /* HW index of this VSI (absolute index) */
478 u16 id; /* VSI number */
479 u16 uplink_seid;
480
481 u16 base_queue; /* vsi's first queue in hw array */
482 u16 alloc_queue_pairs; /* Allocated Tx/Rx queues */
483 u16 num_queue_pairs; /* Used tx and rx pairs */
484 u16 num_desc;
485 enum i40e_vsi_type type; /* VSI type, e.g., LAN, FCoE, etc */
486 u16 vf_id; /* Virtual function ID for SRIOV VSIs */
487
488 struct i40e_tc_configuration tc_config;
489 struct i40e_aqc_vsi_properties_data info;
490
491 /* VSI BW limit (absolute across all TCs) */
492 u16 bw_limit; /* VSI BW Limit (0 = disabled) */
493 u8 bw_max_quanta; /* Max Quanta when BW limit is enabled */
494
495 /* Relative TC credits across VSIs */
496 u8 bw_ets_share_credits[I40E_MAX_TRAFFIC_CLASS];
497 /* TC BW limit credits within VSI */
498 u16 bw_ets_limit_credits[I40E_MAX_TRAFFIC_CLASS];
499 /* TC BW limit max quanta within VSI */
500 u8 bw_ets_max_quanta[I40E_MAX_TRAFFIC_CLASS];
501
502 struct i40e_pf *back; /* Backreference to associated PF */
503 u16 idx; /* index in pf->vsi[] */
504 u16 veb_idx; /* index of VEB parent */
505 struct kobject *kobj; /* sysfs object */
506
507 /* VSI specific handlers */
508 irqreturn_t (*irq_handler)(int irq, void *data);
509
510 /* current rxnfc data */
511 struct ethtool_rxnfc rxnfc; /* current rss hash opts */
512 } ____cacheline_internodealigned_in_smp;
513
514 struct i40e_netdev_priv {
515 struct i40e_vsi *vsi;
516 };
517
518 /* struct that defines an interrupt vector */
519 struct i40e_q_vector {
520 struct i40e_vsi *vsi;
521
522 u16 v_idx; /* index in the vsi->q_vector array. */
523 u16 reg_idx; /* register index of the interrupt */
524
525 struct napi_struct napi;
526
527 struct i40e_ring_container rx;
528 struct i40e_ring_container tx;
529
530 u8 num_ringpairs; /* total number of ring pairs in vector */
531
532 cpumask_t affinity_mask;
533 struct rcu_head rcu; /* to avoid race with update stats on free */
534 char name[I40E_INT_NAME_STR_LEN];
535 } ____cacheline_internodealigned_in_smp;
536
537 /* lan device */
538 struct i40e_device {
539 struct list_head list;
540 struct i40e_pf *pf;
541 };
542
543 /**
544 * i40e_fw_version_str - format the FW and NVM version strings
545 * @hw: ptr to the hardware info
546 **/
547 static inline char *i40e_fw_version_str(struct i40e_hw *hw)
548 {
549 static char buf[32];
550
551 snprintf(buf, sizeof(buf),
552 "f%d.%d a%d.%d n%02x.%02x e%08x",
553 hw->aq.fw_maj_ver, hw->aq.fw_min_ver,
554 hw->aq.api_maj_ver, hw->aq.api_min_ver,
555 (hw->nvm.version & I40E_NVM_VERSION_HI_MASK) >>
556 I40E_NVM_VERSION_HI_SHIFT,
557 (hw->nvm.version & I40E_NVM_VERSION_LO_MASK) >>
558 I40E_NVM_VERSION_LO_SHIFT,
559 hw->nvm.eetrack);
560
561 return buf;
562 }
563
564 /**
565 * i40e_netdev_to_pf: Retrieve the PF struct for given netdev
566 * @netdev: the corresponding netdev
567 *
568 * Return the PF struct for the given netdev
569 **/
570 static inline struct i40e_pf *i40e_netdev_to_pf(struct net_device *netdev)
571 {
572 struct i40e_netdev_priv *np = netdev_priv(netdev);
573 struct i40e_vsi *vsi = np->vsi;
574
575 return vsi->back;
576 }
577
578 static inline void i40e_vsi_setup_irqhandler(struct i40e_vsi *vsi,
579 irqreturn_t (*irq_handler)(int, void *))
580 {
581 vsi->irq_handler = irq_handler;
582 }
583
584 /**
585 * i40e_rx_is_programming_status - check for programming status descriptor
586 * @qw: the first quad word of the program status descriptor
587 *
588 * The value of in the descriptor length field indicate if this
589 * is a programming status descriptor for flow director or FCoE
590 * by the value of I40E_RX_PROG_STATUS_DESC_LENGTH, otherwise
591 * it is a packet descriptor.
592 **/
593 static inline bool i40e_rx_is_programming_status(u64 qw)
594 {
595 return I40E_RX_PROG_STATUS_DESC_LENGTH ==
596 (qw >> I40E_RX_PROG_STATUS_DESC_LENGTH_SHIFT);
597 }
598
599 /**
600 * i40e_get_fd_cnt_all - get the total FD filter space available
601 * @pf: pointer to the pf struct
602 **/
603 static inline int i40e_get_fd_cnt_all(struct i40e_pf *pf)
604 {
605 return pf->hw.fdir_shared_filter_count + pf->fdir_pf_filter_count;
606 }
607
608 /* needed by i40e_ethtool.c */
609 int i40e_up(struct i40e_vsi *vsi);
610 void i40e_down(struct i40e_vsi *vsi);
611 extern const char i40e_driver_name[];
612 extern const char i40e_driver_version_str[];
613 void i40e_do_reset_safe(struct i40e_pf *pf, u32 reset_flags);
614 void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags);
615 void i40e_update_stats(struct i40e_vsi *vsi);
616 void i40e_update_eth_stats(struct i40e_vsi *vsi);
617 struct rtnl_link_stats64 *i40e_get_vsi_stats_struct(struct i40e_vsi *vsi);
618 int i40e_fetch_switch_configuration(struct i40e_pf *pf,
619 bool printconfig);
620
621 int i40e_program_fdir_filter(struct i40e_fdir_filter *fdir_data, u8 *raw_packet,
622 struct i40e_pf *pf, bool add);
623 int i40e_add_del_fdir(struct i40e_vsi *vsi,
624 struct i40e_fdir_filter *input, bool add);
625 void i40e_fdir_check_and_reenable(struct i40e_pf *pf);
626 int i40e_get_current_fd_count(struct i40e_pf *pf);
627 int i40e_get_cur_guaranteed_fd_count(struct i40e_pf *pf);
628 int i40e_get_current_atr_cnt(struct i40e_pf *pf);
629 bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features);
630 void i40e_set_ethtool_ops(struct net_device *netdev);
631 struct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi,
632 u8 *macaddr, s16 vlan,
633 bool is_vf, bool is_netdev);
634 void i40e_del_filter(struct i40e_vsi *vsi, u8 *macaddr, s16 vlan,
635 bool is_vf, bool is_netdev);
636 int i40e_sync_vsi_filters(struct i40e_vsi *vsi);
637 struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type,
638 u16 uplink, u32 param1);
639 int i40e_vsi_release(struct i40e_vsi *vsi);
640 struct i40e_vsi *i40e_vsi_lookup(struct i40e_pf *pf, enum i40e_vsi_type type,
641 struct i40e_vsi *start_vsi);
642 #ifdef I40E_FCOE
643 void i40e_vsi_setup_queue_map(struct i40e_vsi *vsi,
644 struct i40e_vsi_context *ctxt,
645 u8 enabled_tc, bool is_add);
646 #endif
647 int i40e_vsi_control_rings(struct i40e_vsi *vsi, bool enable);
648 int i40e_reconfig_rss_queues(struct i40e_pf *pf, int queue_count);
649 struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 flags, u16 uplink_seid,
650 u16 downlink_seid, u8 enabled_tc);
651 void i40e_veb_release(struct i40e_veb *veb);
652
653 int i40e_veb_config_tc(struct i40e_veb *veb, u8 enabled_tc);
654 i40e_status i40e_vsi_add_pvid(struct i40e_vsi *vsi, u16 vid);
655 void i40e_vsi_remove_pvid(struct i40e_vsi *vsi);
656 void i40e_vsi_reset_stats(struct i40e_vsi *vsi);
657 void i40e_pf_reset_stats(struct i40e_pf *pf);
658 #ifdef CONFIG_DEBUG_FS
659 void i40e_dbg_pf_init(struct i40e_pf *pf);
660 void i40e_dbg_pf_exit(struct i40e_pf *pf);
661 void i40e_dbg_init(void);
662 void i40e_dbg_exit(void);
663 #else
664 static inline void i40e_dbg_pf_init(struct i40e_pf *pf) {}
665 static inline void i40e_dbg_pf_exit(struct i40e_pf *pf) {}
666 static inline void i40e_dbg_init(void) {}
667 static inline void i40e_dbg_exit(void) {}
668 #endif /* CONFIG_DEBUG_FS*/
669 void i40e_irq_dynamic_enable(struct i40e_vsi *vsi, int vector);
670 void i40e_irq_dynamic_disable(struct i40e_vsi *vsi, int vector);
671 void i40e_irq_dynamic_disable_icr0(struct i40e_pf *pf);
672 void i40e_irq_dynamic_enable_icr0(struct i40e_pf *pf);
673 #ifdef I40E_FCOE
674 struct rtnl_link_stats64 *i40e_get_netdev_stats_struct(
675 struct net_device *netdev,
676 struct rtnl_link_stats64 *storage);
677 int i40e_set_mac(struct net_device *netdev, void *p);
678 void i40e_set_rx_mode(struct net_device *netdev);
679 #endif
680 int i40e_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
681 #ifdef I40E_FCOE
682 void i40e_tx_timeout(struct net_device *netdev);
683 int i40e_vlan_rx_add_vid(struct net_device *netdev,
684 __always_unused __be16 proto, u16 vid);
685 int i40e_vlan_rx_kill_vid(struct net_device *netdev,
686 __always_unused __be16 proto, u16 vid);
687 #endif
688 int i40e_vsi_open(struct i40e_vsi *vsi);
689 void i40e_vlan_stripping_disable(struct i40e_vsi *vsi);
690 int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid);
691 int i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid);
692 struct i40e_mac_filter *i40e_put_mac_in_vlan(struct i40e_vsi *vsi, u8 *macaddr,
693 bool is_vf, bool is_netdev);
694 bool i40e_is_vsi_in_vlan(struct i40e_vsi *vsi);
695 struct i40e_mac_filter *i40e_find_mac(struct i40e_vsi *vsi, u8 *macaddr,
696 bool is_vf, bool is_netdev);
697 #ifdef I40E_FCOE
698 int i40e_open(struct net_device *netdev);
699 int i40e_close(struct net_device *netdev);
700 int i40e_setup_tc(struct net_device *netdev, u8 tc);
701 void i40e_netpoll(struct net_device *netdev);
702 int i40e_fcoe_enable(struct net_device *netdev);
703 int i40e_fcoe_disable(struct net_device *netdev);
704 int i40e_fcoe_vsi_init(struct i40e_vsi *vsi, struct i40e_vsi_context *ctxt);
705 u8 i40e_get_fcoe_tc_map(struct i40e_pf *pf);
706 void i40e_fcoe_config_netdev(struct net_device *netdev, struct i40e_vsi *vsi);
707 void i40e_fcoe_vsi_setup(struct i40e_pf *pf);
708 int i40e_init_pf_fcoe(struct i40e_pf *pf);
709 int i40e_fcoe_setup_ddp_resources(struct i40e_vsi *vsi);
710 void i40e_fcoe_free_ddp_resources(struct i40e_vsi *vsi);
711 int i40e_fcoe_handle_offload(struct i40e_ring *rx_ring,
712 union i40e_rx_desc *rx_desc,
713 struct sk_buff *skb);
714 void i40e_fcoe_handle_status(struct i40e_ring *rx_ring,
715 union i40e_rx_desc *rx_desc, u8 prog_id);
716 #endif /* I40E_FCOE */
717 void i40e_vlan_stripping_enable(struct i40e_vsi *vsi);
718 #ifdef CONFIG_I40E_DCB
719 void i40e_dcbnl_flush_apps(struct i40e_pf *pf,
720 struct i40e_dcbx_config *new_cfg);
721 void i40e_dcbnl_set_all(struct i40e_vsi *vsi);
722 void i40e_dcbnl_setup(struct i40e_vsi *vsi);
723 bool i40e_dcb_need_reconfig(struct i40e_pf *pf,
724 struct i40e_dcbx_config *old_cfg,
725 struct i40e_dcbx_config *new_cfg);
726 #endif /* CONFIG_I40E_DCB */
727 void i40e_ptp_rx_hang(struct i40e_vsi *vsi);
728 void i40e_ptp_tx_hwtstamp(struct i40e_pf *pf);
729 void i40e_ptp_rx_hwtstamp(struct i40e_pf *pf, struct sk_buff *skb, u8 index);
730 void i40e_ptp_set_increment(struct i40e_pf *pf);
731 int i40e_ptp_set_ts_config(struct i40e_pf *pf, struct ifreq *ifr);
732 int i40e_ptp_get_ts_config(struct i40e_pf *pf, struct ifreq *ifr);
733 void i40e_ptp_init(struct i40e_pf *pf);
734 void i40e_ptp_stop(struct i40e_pf *pf);
735 #endif /* _I40E_H_ */