i40e.h 25 KB

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