i40e.h 21 KB

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