i40e.h 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  1. /*******************************************************************************
  2. *
  3. * Intel Ethernet Controller XL710 Family Linux Driver
  4. * Copyright(c) 2013 - 2017 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/hashtable.h>
  41. #include <linux/string.h>
  42. #include <linux/in.h>
  43. #include <linux/ip.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. #include "i40e_client.h"
  58. #include <linux/avf/virtchnl.h>
  59. #include "i40e_virtchnl_pf.h"
  60. #include "i40e_txrx.h"
  61. #include "i40e_dcb.h"
  62. /* Useful i40e defaults */
  63. #define I40E_MAX_VEB 16
  64. #define I40E_MAX_NUM_DESCRIPTORS 4096
  65. #define I40E_MAX_CSR_SPACE (4 * 1024 * 1024 - 64 * 1024)
  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 83 /* LAN, ATR, FCOE, 64 VF */
  72. /* max 16 qps */
  73. #define i40e_default_queues_per_vmdq(pf) \
  74. (((pf)->hw_features & I40E_HW_RSS_AQ_CAPABLE) ? 4 : 1)
  75. #define I40E_DEFAULT_QUEUES_PER_VF 4
  76. #define I40E_DEFAULT_QUEUES_PER_TC 1 /* should be a power of 2 */
  77. #define i40e_pf_get_max_q_per_tc(pf) \
  78. (((pf)->hw_features & I40E_HW_128_QP_RSS_CAPABLE) ? 128 : 64)
  79. #define I40E_FDIR_RING 0
  80. #define I40E_FDIR_RING_COUNT 32
  81. #define I40E_MAX_AQ_BUF_SIZE 4096
  82. #define I40E_AQ_LEN 256
  83. #define I40E_AQ_WORK_LIMIT 66 /* max number of VFs + a little */
  84. #define I40E_MAX_USER_PRIORITY 8
  85. #define I40E_DEFAULT_TRAFFIC_CLASS BIT(0)
  86. #define I40E_DEFAULT_MSG_ENABLE 4
  87. #define I40E_QUEUE_WAIT_RETRY_LIMIT 10
  88. #define I40E_INT_NAME_STR_LEN (IFNAMSIZ + 16)
  89. #define I40E_NVM_VERSION_LO_SHIFT 0
  90. #define I40E_NVM_VERSION_LO_MASK (0xff << I40E_NVM_VERSION_LO_SHIFT)
  91. #define I40E_NVM_VERSION_HI_SHIFT 12
  92. #define I40E_NVM_VERSION_HI_MASK (0xf << I40E_NVM_VERSION_HI_SHIFT)
  93. #define I40E_OEM_VER_BUILD_MASK 0xffff
  94. #define I40E_OEM_VER_PATCH_MASK 0xff
  95. #define I40E_OEM_VER_BUILD_SHIFT 8
  96. #define I40E_OEM_VER_SHIFT 24
  97. #define I40E_PHY_DEBUG_ALL \
  98. (I40E_AQ_PHY_DEBUG_DISABLE_LINK_FW | \
  99. I40E_AQ_PHY_DEBUG_DISABLE_ALL_LINK_FW)
  100. #define I40E_OEM_EETRACK_ID 0xffffffff
  101. #define I40E_OEM_GEN_SHIFT 24
  102. #define I40E_OEM_SNAP_MASK 0x00ff0000
  103. #define I40E_OEM_SNAP_SHIFT 16
  104. #define I40E_OEM_RELEASE_MASK 0x0000ffff
  105. /* The values in here are decimal coded as hex as is the case in the NVM map*/
  106. #define I40E_CURRENT_NVM_VERSION_HI 0x2
  107. #define I40E_CURRENT_NVM_VERSION_LO 0x40
  108. #define I40E_RX_DESC(R, i) \
  109. (&(((union i40e_32byte_rx_desc *)((R)->desc))[i]))
  110. #define I40E_TX_DESC(R, i) \
  111. (&(((struct i40e_tx_desc *)((R)->desc))[i]))
  112. #define I40E_TX_CTXTDESC(R, i) \
  113. (&(((struct i40e_tx_context_desc *)((R)->desc))[i]))
  114. #define I40E_TX_FDIRDESC(R, i) \
  115. (&(((struct i40e_filter_program_desc *)((R)->desc))[i]))
  116. /* default to trying for four seconds */
  117. #define I40E_TRY_LINK_TIMEOUT (4 * HZ)
  118. /* driver state flags */
  119. enum i40e_state_t {
  120. __I40E_TESTING,
  121. __I40E_CONFIG_BUSY,
  122. __I40E_CONFIG_DONE,
  123. __I40E_DOWN,
  124. __I40E_SERVICE_SCHED,
  125. __I40E_ADMINQ_EVENT_PENDING,
  126. __I40E_MDD_EVENT_PENDING,
  127. __I40E_VFLR_EVENT_PENDING,
  128. __I40E_RESET_RECOVERY_PENDING,
  129. __I40E_RESET_INTR_RECEIVED,
  130. __I40E_REINIT_REQUESTED,
  131. __I40E_PF_RESET_REQUESTED,
  132. __I40E_CORE_RESET_REQUESTED,
  133. __I40E_GLOBAL_RESET_REQUESTED,
  134. __I40E_EMP_RESET_REQUESTED,
  135. __I40E_EMP_RESET_INTR_RECEIVED,
  136. __I40E_SUSPENDED,
  137. __I40E_PTP_TX_IN_PROGRESS,
  138. __I40E_BAD_EEPROM,
  139. __I40E_DOWN_REQUESTED,
  140. __I40E_FD_FLUSH_REQUESTED,
  141. __I40E_RESET_FAILED,
  142. __I40E_PORT_SUSPENDED,
  143. __I40E_VF_DISABLE,
  144. /* This must be last as it determines the size of the BITMAP */
  145. __I40E_STATE_SIZE__,
  146. };
  147. /* VSI state flags */
  148. enum i40e_vsi_state_t {
  149. __I40E_VSI_DOWN,
  150. __I40E_VSI_NEEDS_RESTART,
  151. __I40E_VSI_SYNCING_FILTERS,
  152. __I40E_VSI_OVERFLOW_PROMISC,
  153. __I40E_VSI_REINIT_REQUESTED,
  154. __I40E_VSI_DOWN_REQUESTED,
  155. /* This must be last as it determines the size of the BITMAP */
  156. __I40E_VSI_STATE_SIZE__,
  157. };
  158. enum i40e_interrupt_policy {
  159. I40E_INTERRUPT_BEST_CASE,
  160. I40E_INTERRUPT_MEDIUM,
  161. I40E_INTERRUPT_LOWEST
  162. };
  163. struct i40e_lump_tracking {
  164. u16 num_entries;
  165. u16 search_hint;
  166. u16 list[0];
  167. #define I40E_PILE_VALID_BIT 0x8000
  168. #define I40E_IWARP_IRQ_PILE_ID (I40E_PILE_VALID_BIT - 2)
  169. };
  170. #define I40E_DEFAULT_ATR_SAMPLE_RATE 20
  171. #define I40E_FDIR_MAX_RAW_PACKET_SIZE 512
  172. #define I40E_FDIR_BUFFER_FULL_MARGIN 10
  173. #define I40E_FDIR_BUFFER_HEAD_ROOM 32
  174. #define I40E_FDIR_BUFFER_HEAD_ROOM_FOR_ATR (I40E_FDIR_BUFFER_HEAD_ROOM * 4)
  175. #define I40E_HKEY_ARRAY_SIZE ((I40E_PFQF_HKEY_MAX_INDEX + 1) * 4)
  176. #define I40E_HLUT_ARRAY_SIZE ((I40E_PFQF_HLUT_MAX_INDEX + 1) * 4)
  177. #define I40E_VF_HLUT_ARRAY_SIZE ((I40E_VFQF_HLUT1_MAX_INDEX + 1) * 4)
  178. enum i40e_fd_stat_idx {
  179. I40E_FD_STAT_ATR,
  180. I40E_FD_STAT_SB,
  181. I40E_FD_STAT_ATR_TUNNEL,
  182. I40E_FD_STAT_PF_COUNT
  183. };
  184. #define I40E_FD_STAT_PF_IDX(pf_id) ((pf_id) * I40E_FD_STAT_PF_COUNT)
  185. #define I40E_FD_ATR_STAT_IDX(pf_id) \
  186. (I40E_FD_STAT_PF_IDX(pf_id) + I40E_FD_STAT_ATR)
  187. #define I40E_FD_SB_STAT_IDX(pf_id) \
  188. (I40E_FD_STAT_PF_IDX(pf_id) + I40E_FD_STAT_SB)
  189. #define I40E_FD_ATR_TUNNEL_STAT_IDX(pf_id) \
  190. (I40E_FD_STAT_PF_IDX(pf_id) + I40E_FD_STAT_ATR_TUNNEL)
  191. /* The following structure contains the data parsed from the user-defined
  192. * field of the ethtool_rx_flow_spec structure.
  193. */
  194. struct i40e_rx_flow_userdef {
  195. bool flex_filter;
  196. u16 flex_word;
  197. u16 flex_offset;
  198. };
  199. struct i40e_fdir_filter {
  200. struct hlist_node fdir_node;
  201. /* filter ipnut set */
  202. u8 flow_type;
  203. u8 ip4_proto;
  204. /* TX packet view of src and dst */
  205. __be32 dst_ip;
  206. __be32 src_ip;
  207. __be16 src_port;
  208. __be16 dst_port;
  209. __be32 sctp_v_tag;
  210. /* Flexible data to match within the packet payload */
  211. __be16 flex_word;
  212. u16 flex_offset;
  213. bool flex_filter;
  214. /* filter control */
  215. u16 q_index;
  216. u8 flex_off;
  217. u8 pctype;
  218. u16 dest_vsi;
  219. u8 dest_ctl;
  220. u8 fd_status;
  221. u16 cnt_index;
  222. u32 fd_id;
  223. };
  224. #define I40E_ETH_P_LLDP 0x88cc
  225. #define I40E_DCB_PRIO_TYPE_STRICT 0
  226. #define I40E_DCB_PRIO_TYPE_ETS 1
  227. #define I40E_DCB_STRICT_PRIO_CREDITS 127
  228. /* DCB per TC information data structure */
  229. struct i40e_tc_info {
  230. u16 qoffset; /* Queue offset from base queue */
  231. u16 qcount; /* Total Queues */
  232. u8 netdev_tc; /* Netdev TC index if netdev associated */
  233. };
  234. /* TC configuration data structure */
  235. struct i40e_tc_configuration {
  236. u8 numtc; /* Total number of enabled TCs */
  237. u8 enabled_tc; /* TC map */
  238. struct i40e_tc_info tc_info[I40E_MAX_TRAFFIC_CLASS];
  239. };
  240. struct i40e_udp_port_config {
  241. /* AdminQ command interface expects port number in Host byte order */
  242. u16 port;
  243. u8 type;
  244. };
  245. /* macros related to FLX_PIT */
  246. #define I40E_FLEX_SET_FSIZE(fsize) (((fsize) << \
  247. I40E_PRTQF_FLX_PIT_FSIZE_SHIFT) & \
  248. I40E_PRTQF_FLX_PIT_FSIZE_MASK)
  249. #define I40E_FLEX_SET_DST_WORD(dst) (((dst) << \
  250. I40E_PRTQF_FLX_PIT_DEST_OFF_SHIFT) & \
  251. I40E_PRTQF_FLX_PIT_DEST_OFF_MASK)
  252. #define I40E_FLEX_SET_SRC_WORD(src) (((src) << \
  253. I40E_PRTQF_FLX_PIT_SOURCE_OFF_SHIFT) & \
  254. I40E_PRTQF_FLX_PIT_SOURCE_OFF_MASK)
  255. #define I40E_FLEX_PREP_VAL(dst, fsize, src) (I40E_FLEX_SET_DST_WORD(dst) | \
  256. I40E_FLEX_SET_FSIZE(fsize) | \
  257. I40E_FLEX_SET_SRC_WORD(src))
  258. #define I40E_FLEX_PIT_GET_SRC(flex) (((flex) & \
  259. I40E_PRTQF_FLX_PIT_SOURCE_OFF_MASK) >> \
  260. I40E_PRTQF_FLX_PIT_SOURCE_OFF_SHIFT)
  261. #define I40E_FLEX_PIT_GET_DST(flex) (((flex) & \
  262. I40E_PRTQF_FLX_PIT_DEST_OFF_MASK) >> \
  263. I40E_PRTQF_FLX_PIT_DEST_OFF_SHIFT)
  264. #define I40E_FLEX_PIT_GET_FSIZE(flex) (((flex) & \
  265. I40E_PRTQF_FLX_PIT_FSIZE_MASK) >> \
  266. I40E_PRTQF_FLX_PIT_FSIZE_SHIFT)
  267. #define I40E_MAX_FLEX_SRC_OFFSET 0x1F
  268. /* macros related to GLQF_ORT */
  269. #define I40E_ORT_SET_IDX(idx) (((idx) << \
  270. I40E_GLQF_ORT_PIT_INDX_SHIFT) & \
  271. I40E_GLQF_ORT_PIT_INDX_MASK)
  272. #define I40E_ORT_SET_COUNT(count) (((count) << \
  273. I40E_GLQF_ORT_FIELD_CNT_SHIFT) & \
  274. I40E_GLQF_ORT_FIELD_CNT_MASK)
  275. #define I40E_ORT_SET_PAYLOAD(payload) (((payload) << \
  276. I40E_GLQF_ORT_FLX_PAYLOAD_SHIFT) & \
  277. I40E_GLQF_ORT_FLX_PAYLOAD_MASK)
  278. #define I40E_ORT_PREP_VAL(idx, count, payload) (I40E_ORT_SET_IDX(idx) | \
  279. I40E_ORT_SET_COUNT(count) | \
  280. I40E_ORT_SET_PAYLOAD(payload))
  281. #define I40E_L3_GLQF_ORT_IDX 34
  282. #define I40E_L4_GLQF_ORT_IDX 35
  283. /* Flex PIT register index */
  284. #define I40E_FLEX_PIT_IDX_START_L2 0
  285. #define I40E_FLEX_PIT_IDX_START_L3 3
  286. #define I40E_FLEX_PIT_IDX_START_L4 6
  287. #define I40E_FLEX_PIT_TABLE_SIZE 3
  288. #define I40E_FLEX_DEST_UNUSED 63
  289. #define I40E_FLEX_INDEX_ENTRIES 8
  290. /* Flex MASK to disable all flexible entries */
  291. #define I40E_FLEX_INPUT_MASK (I40E_FLEX_50_MASK | I40E_FLEX_51_MASK | \
  292. I40E_FLEX_52_MASK | I40E_FLEX_53_MASK | \
  293. I40E_FLEX_54_MASK | I40E_FLEX_55_MASK | \
  294. I40E_FLEX_56_MASK | I40E_FLEX_57_MASK)
  295. struct i40e_flex_pit {
  296. struct list_head list;
  297. u16 src_offset;
  298. u8 pit_index;
  299. };
  300. /* struct that defines the Ethernet device */
  301. struct i40e_pf {
  302. struct pci_dev *pdev;
  303. struct i40e_hw hw;
  304. DECLARE_BITMAP(state, __I40E_STATE_SIZE__);
  305. struct msix_entry *msix_entries;
  306. bool fc_autoneg_status;
  307. u16 eeprom_version;
  308. u16 num_vmdq_vsis; /* num vmdq vsis this PF has set up */
  309. u16 num_vmdq_qps; /* num queue pairs per vmdq pool */
  310. u16 num_vmdq_msix; /* num queue vectors per vmdq pool */
  311. u16 num_req_vfs; /* num VFs requested for this VF */
  312. u16 num_vf_qps; /* num queue pairs per VF */
  313. u16 num_lan_qps; /* num lan queues this PF has set up */
  314. u16 num_lan_msix; /* num queue vectors for the base PF vsi */
  315. u16 num_fdsb_msix; /* num queue vectors for sideband Fdir */
  316. u16 num_iwarp_msix; /* num of iwarp vectors for this PF */
  317. int iwarp_base_vector;
  318. int queues_left; /* queues left unclaimed */
  319. u16 alloc_rss_size; /* allocated RSS queues */
  320. u16 rss_size_max; /* HW defined max RSS queues */
  321. u16 fdir_pf_filter_count; /* num of guaranteed filters for this PF */
  322. u16 num_alloc_vsi; /* num VSIs this driver supports */
  323. u8 atr_sample_rate;
  324. bool wol_en;
  325. struct hlist_head fdir_filter_list;
  326. u16 fdir_pf_active_filters;
  327. unsigned long fd_flush_timestamp;
  328. u32 fd_flush_cnt;
  329. u32 fd_add_err;
  330. u32 fd_atr_cnt;
  331. /* Book-keeping of side-band filter count per flow-type.
  332. * This is used to detect and handle input set changes for
  333. * respective flow-type.
  334. */
  335. u16 fd_tcp4_filter_cnt;
  336. u16 fd_udp4_filter_cnt;
  337. u16 fd_sctp4_filter_cnt;
  338. u16 fd_ip4_filter_cnt;
  339. /* Flexible filter table values that need to be programmed into
  340. * hardware, which expects L3 and L4 to be programmed separately. We
  341. * need to ensure that the values are in ascended order and don't have
  342. * duplicates, so we track each L3 and L4 values in separate lists.
  343. */
  344. struct list_head l3_flex_pit_list;
  345. struct list_head l4_flex_pit_list;
  346. struct i40e_udp_port_config udp_ports[I40E_MAX_PF_UDP_OFFLOAD_PORTS];
  347. u16 pending_udp_bitmap;
  348. enum i40e_interrupt_policy int_policy;
  349. u16 rx_itr_default;
  350. u16 tx_itr_default;
  351. u32 msg_enable;
  352. char int_name[I40E_INT_NAME_STR_LEN];
  353. u16 adminq_work_limit; /* num of admin receive queue desc to process */
  354. unsigned long service_timer_period;
  355. unsigned long service_timer_previous;
  356. struct timer_list service_timer;
  357. struct work_struct service_task;
  358. u64 hw_features;
  359. #define I40E_HW_RSS_AQ_CAPABLE BIT_ULL(0)
  360. #define I40E_HW_128_QP_RSS_CAPABLE BIT_ULL(1)
  361. #define I40E_HW_ATR_EVICT_CAPABLE BIT_ULL(2)
  362. #define I40E_HW_WB_ON_ITR_CAPABLE BIT_ULL(3)
  363. #define I40E_HW_MULTIPLE_TCP_UDP_RSS_PCTYPE BIT_ULL(4)
  364. #define I40E_HW_NO_PCI_LINK_CHECK BIT_ULL(5)
  365. #define I40E_HW_100M_SGMII_CAPABLE BIT_ULL(6)
  366. #define I40E_HW_NO_DCB_SUPPORT BIT_ULL(7)
  367. #define I40E_HW_USE_SET_LLDP_MIB BIT_ULL(8)
  368. #define I40E_HW_GENEVE_OFFLOAD_CAPABLE BIT_ULL(9)
  369. #define I40E_HW_PTP_L4_CAPABLE BIT_ULL(10)
  370. #define I40E_HW_WOL_MC_MAGIC_PKT_WAKE BIT_ULL(11)
  371. #define I40E_HW_MPLS_HDR_OFFLOAD_CAPABLE BIT_ULL(12)
  372. #define I40E_HW_HAVE_CRT_RETIMER BIT_ULL(13)
  373. #define I40E_HW_OUTER_UDP_CSUM_CAPABLE BIT_ULL(14)
  374. #define I40E_HW_PHY_CONTROLS_LEDS BIT_ULL(15)
  375. #define I40E_HW_STOP_FW_LLDP BIT_ULL(16)
  376. #define I40E_HW_PORT_ID_VALID BIT_ULL(17)
  377. #define I40E_HW_RESTART_AUTONEG BIT_ULL(18)
  378. u64 flags;
  379. #define I40E_FLAG_RX_CSUM_ENABLED BIT_ULL(1)
  380. #define I40E_FLAG_MSI_ENABLED BIT_ULL(2)
  381. #define I40E_FLAG_MSIX_ENABLED BIT_ULL(3)
  382. #define I40E_FLAG_HW_ATR_EVICT_ENABLED BIT_ULL(4)
  383. #define I40E_FLAG_RSS_ENABLED BIT_ULL(6)
  384. #define I40E_FLAG_VMDQ_ENABLED BIT_ULL(7)
  385. #define I40E_FLAG_IWARP_ENABLED BIT_ULL(10)
  386. #define I40E_FLAG_FILTER_SYNC BIT_ULL(15)
  387. #define I40E_FLAG_SERVICE_CLIENT_REQUESTED BIT_ULL(16)
  388. #define I40E_FLAG_SRIOV_ENABLED BIT_ULL(19)
  389. #define I40E_FLAG_DCB_ENABLED BIT_ULL(20)
  390. #define I40E_FLAG_FD_SB_ENABLED BIT_ULL(21)
  391. #define I40E_FLAG_FD_ATR_ENABLED BIT_ULL(22)
  392. #define I40E_FLAG_FD_SB_AUTO_DISABLED BIT_ULL(23)
  393. #define I40E_FLAG_FD_ATR_AUTO_DISABLED BIT_ULL(24)
  394. #define I40E_FLAG_PTP BIT_ULL(25)
  395. #define I40E_FLAG_MFP_ENABLED BIT_ULL(26)
  396. #define I40E_FLAG_UDP_FILTER_SYNC BIT_ULL(27)
  397. #define I40E_FLAG_DCB_CAPABLE BIT_ULL(29)
  398. #define I40E_FLAG_VEB_STATS_ENABLED BIT_ULL(37)
  399. #define I40E_FLAG_LINK_POLLING_ENABLED BIT_ULL(39)
  400. #define I40E_FLAG_VEB_MODE_ENABLED BIT_ULL(40)
  401. #define I40E_FLAG_TRUE_PROMISC_SUPPORT BIT_ULL(51)
  402. #define I40E_FLAG_CLIENT_RESET BIT_ULL(54)
  403. #define I40E_FLAG_TEMP_LINK_POLLING BIT_ULL(55)
  404. #define I40E_FLAG_CLIENT_L2_CHANGE BIT_ULL(56)
  405. #define I40E_FLAG_LEGACY_RX BIT_ULL(58)
  406. struct i40e_client_instance *cinst;
  407. bool stat_offsets_loaded;
  408. struct i40e_hw_port_stats stats;
  409. struct i40e_hw_port_stats stats_offsets;
  410. u32 tx_timeout_count;
  411. u32 tx_timeout_recovery_level;
  412. unsigned long tx_timeout_last_recovery;
  413. u32 tx_sluggish_count;
  414. u32 hw_csum_rx_error;
  415. u32 led_status;
  416. u16 corer_count; /* Core reset count */
  417. u16 globr_count; /* Global reset count */
  418. u16 empr_count; /* EMP reset count */
  419. u16 pfr_count; /* PF reset count */
  420. u16 sw_int_count; /* SW interrupt count */
  421. struct mutex switch_mutex;
  422. u16 lan_vsi; /* our default LAN VSI */
  423. u16 lan_veb; /* initial relay, if exists */
  424. #define I40E_NO_VEB 0xffff
  425. #define I40E_NO_VSI 0xffff
  426. u16 next_vsi; /* Next unallocated VSI - 0-based! */
  427. struct i40e_vsi **vsi;
  428. struct i40e_veb *veb[I40E_MAX_VEB];
  429. struct i40e_lump_tracking *qp_pile;
  430. struct i40e_lump_tracking *irq_pile;
  431. /* switch config info */
  432. u16 pf_seid;
  433. u16 main_vsi_seid;
  434. u16 mac_seid;
  435. struct kobject *switch_kobj;
  436. #ifdef CONFIG_DEBUG_FS
  437. struct dentry *i40e_dbg_pf;
  438. #endif /* CONFIG_DEBUG_FS */
  439. bool cur_promisc;
  440. u16 instance; /* A unique number per i40e_pf instance in the system */
  441. /* sr-iov config info */
  442. struct i40e_vf *vf;
  443. int num_alloc_vfs; /* actual number of VFs allocated */
  444. u32 vf_aq_requests;
  445. u32 arq_overflows; /* Not fatal, possibly indicative of problems */
  446. /* DCBx/DCBNL capability for PF that indicates
  447. * whether DCBx is managed by firmware or host
  448. * based agent (LLDPAD). Also, indicates what
  449. * flavor of DCBx protocol (IEEE/CEE) is supported
  450. * by the device. For now we're supporting IEEE
  451. * mode only.
  452. */
  453. u16 dcbx_cap;
  454. struct i40e_filter_control_settings filter_settings;
  455. struct ptp_clock *ptp_clock;
  456. struct ptp_clock_info ptp_caps;
  457. struct sk_buff *ptp_tx_skb;
  458. unsigned long ptp_tx_start;
  459. struct hwtstamp_config tstamp_config;
  460. struct mutex tmreg_lock; /* Used to protect the SYSTIME registers. */
  461. u64 ptp_base_adj;
  462. u32 tx_hwtstamp_timeouts;
  463. u32 tx_hwtstamp_skipped;
  464. u32 rx_hwtstamp_cleared;
  465. u32 latch_event_flags;
  466. spinlock_t ptp_rx_lock; /* Used to protect Rx timestamp registers. */
  467. unsigned long latch_events[4];
  468. bool ptp_tx;
  469. bool ptp_rx;
  470. u16 rss_table_size; /* HW RSS table size */
  471. u32 max_bw;
  472. u32 min_bw;
  473. u32 ioremap_len;
  474. u32 fd_inv;
  475. u16 phy_led_val;
  476. };
  477. /**
  478. * i40e_mac_to_hkey - Convert a 6-byte MAC Address to a u64 hash key
  479. * @macaddr: the MAC Address as the base key
  480. *
  481. * Simply copies the address and returns it as a u64 for hashing
  482. **/
  483. static inline u64 i40e_addr_to_hkey(const u8 *macaddr)
  484. {
  485. u64 key = 0;
  486. ether_addr_copy((u8 *)&key, macaddr);
  487. return key;
  488. }
  489. enum i40e_filter_state {
  490. I40E_FILTER_INVALID = 0, /* Invalid state */
  491. I40E_FILTER_NEW, /* New, not sent to FW yet */
  492. I40E_FILTER_ACTIVE, /* Added to switch by FW */
  493. I40E_FILTER_FAILED, /* Rejected by FW */
  494. I40E_FILTER_REMOVE, /* To be removed */
  495. /* There is no 'removed' state; the filter struct is freed */
  496. };
  497. struct i40e_mac_filter {
  498. struct hlist_node hlist;
  499. u8 macaddr[ETH_ALEN];
  500. #define I40E_VLAN_ANY -1
  501. s16 vlan;
  502. enum i40e_filter_state state;
  503. };
  504. /* Wrapper structure to keep track of filters while we are preparing to send
  505. * firmware commands. We cannot send firmware commands while holding a
  506. * spinlock, since it might sleep. To avoid this, we wrap the added filters in
  507. * a separate structure, which will track the state change and update the real
  508. * filter while under lock. We can't simply hold the filters in a separate
  509. * list, as this opens a window for a race condition when adding new MAC
  510. * addresses to all VLANs, or when adding new VLANs to all MAC addresses.
  511. */
  512. struct i40e_new_mac_filter {
  513. struct hlist_node hlist;
  514. struct i40e_mac_filter *f;
  515. /* Track future changes to state separately */
  516. enum i40e_filter_state state;
  517. };
  518. struct i40e_veb {
  519. struct i40e_pf *pf;
  520. u16 idx;
  521. u16 veb_idx; /* index of VEB parent */
  522. u16 seid;
  523. u16 uplink_seid;
  524. u16 stats_idx; /* index of VEB parent */
  525. u8 enabled_tc;
  526. u16 bridge_mode; /* Bridge Mode (VEB/VEPA) */
  527. u16 flags;
  528. u16 bw_limit;
  529. u8 bw_max_quanta;
  530. bool is_abs_credits;
  531. u8 bw_tc_share_credits[I40E_MAX_TRAFFIC_CLASS];
  532. u16 bw_tc_limit_credits[I40E_MAX_TRAFFIC_CLASS];
  533. u8 bw_tc_max_quanta[I40E_MAX_TRAFFIC_CLASS];
  534. struct kobject *kobj;
  535. bool stat_offsets_loaded;
  536. struct i40e_eth_stats stats;
  537. struct i40e_eth_stats stats_offsets;
  538. struct i40e_veb_tc_stats tc_stats;
  539. struct i40e_veb_tc_stats tc_stats_offsets;
  540. };
  541. /* struct that defines a VSI, associated with a dev */
  542. struct i40e_vsi {
  543. struct net_device *netdev;
  544. unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
  545. bool netdev_registered;
  546. bool stat_offsets_loaded;
  547. u32 current_netdev_flags;
  548. DECLARE_BITMAP(state, __I40E_VSI_STATE_SIZE__);
  549. #define I40E_VSI_FLAG_FILTER_CHANGED BIT(0)
  550. #define I40E_VSI_FLAG_VEB_OWNER BIT(1)
  551. unsigned long flags;
  552. /* Per VSI lock to protect elements/hash (MAC filter) */
  553. spinlock_t mac_filter_hash_lock;
  554. /* Fixed size hash table with 2^8 buckets for MAC filters */
  555. DECLARE_HASHTABLE(mac_filter_hash, 8);
  556. bool has_vlan_filter;
  557. /* VSI stats */
  558. struct rtnl_link_stats64 net_stats;
  559. struct rtnl_link_stats64 net_stats_offsets;
  560. struct i40e_eth_stats eth_stats;
  561. struct i40e_eth_stats eth_stats_offsets;
  562. u32 tx_restart;
  563. u32 tx_busy;
  564. u64 tx_linearize;
  565. u64 tx_force_wb;
  566. u32 rx_buf_failed;
  567. u32 rx_page_failed;
  568. /* These are containers of ring pointers, allocated at run-time */
  569. struct i40e_ring **rx_rings;
  570. struct i40e_ring **tx_rings;
  571. struct i40e_ring **xdp_rings; /* XDP Tx rings */
  572. u32 active_filters;
  573. u32 promisc_threshold;
  574. u16 work_limit;
  575. u16 int_rate_limit; /* value in usecs */
  576. u16 rss_table_size; /* HW RSS table size */
  577. u16 rss_size; /* Allocated RSS queues */
  578. u8 *rss_hkey_user; /* User configured hash keys */
  579. u8 *rss_lut_user; /* User configured lookup table entries */
  580. u16 max_frame;
  581. u16 rx_buf_len;
  582. struct bpf_prog *xdp_prog;
  583. /* List of q_vectors allocated to this VSI */
  584. struct i40e_q_vector **q_vectors;
  585. int num_q_vectors;
  586. int base_vector;
  587. bool irqs_ready;
  588. u16 seid; /* HW index of this VSI (absolute index) */
  589. u16 id; /* VSI number */
  590. u16 uplink_seid;
  591. u16 base_queue; /* vsi's first queue in hw array */
  592. u16 alloc_queue_pairs; /* Allocated Tx/Rx queues */
  593. u16 req_queue_pairs; /* User requested queue pairs */
  594. u16 num_queue_pairs; /* Used tx and rx pairs */
  595. u16 num_desc;
  596. enum i40e_vsi_type type; /* VSI type, e.g., LAN, FCoE, etc */
  597. s16 vf_id; /* Virtual function ID for SRIOV VSIs */
  598. struct i40e_tc_configuration tc_config;
  599. struct i40e_aqc_vsi_properties_data info;
  600. /* VSI BW limit (absolute across all TCs) */
  601. u16 bw_limit; /* VSI BW Limit (0 = disabled) */
  602. u8 bw_max_quanta; /* Max Quanta when BW limit is enabled */
  603. /* Relative TC credits across VSIs */
  604. u8 bw_ets_share_credits[I40E_MAX_TRAFFIC_CLASS];
  605. /* TC BW limit credits within VSI */
  606. u16 bw_ets_limit_credits[I40E_MAX_TRAFFIC_CLASS];
  607. /* TC BW limit max quanta within VSI */
  608. u8 bw_ets_max_quanta[I40E_MAX_TRAFFIC_CLASS];
  609. struct i40e_pf *back; /* Backreference to associated PF */
  610. u16 idx; /* index in pf->vsi[] */
  611. u16 veb_idx; /* index of VEB parent */
  612. struct kobject *kobj; /* sysfs object */
  613. bool current_isup; /* Sync 'link up' logging */
  614. enum i40e_aq_link_speed current_speed; /* Sync link speed logging */
  615. void *priv; /* client driver data reference. */
  616. /* VSI specific handlers */
  617. irqreturn_t (*irq_handler)(int irq, void *data);
  618. } ____cacheline_internodealigned_in_smp;
  619. struct i40e_netdev_priv {
  620. struct i40e_vsi *vsi;
  621. };
  622. /* struct that defines an interrupt vector */
  623. struct i40e_q_vector {
  624. struct i40e_vsi *vsi;
  625. u16 v_idx; /* index in the vsi->q_vector array. */
  626. u16 reg_idx; /* register index of the interrupt */
  627. struct napi_struct napi;
  628. struct i40e_ring_container rx;
  629. struct i40e_ring_container tx;
  630. u8 num_ringpairs; /* total number of ring pairs in vector */
  631. cpumask_t affinity_mask;
  632. struct irq_affinity_notify affinity_notify;
  633. struct rcu_head rcu; /* to avoid race with update stats on free */
  634. char name[I40E_INT_NAME_STR_LEN];
  635. bool arm_wb_state;
  636. #define ITR_COUNTDOWN_START 100
  637. u8 itr_countdown; /* when 0 should adjust ITR */
  638. } ____cacheline_internodealigned_in_smp;
  639. /* lan device */
  640. struct i40e_device {
  641. struct list_head list;
  642. struct i40e_pf *pf;
  643. };
  644. /**
  645. * i40e_nvm_version_str - format the NVM version strings
  646. * @hw: ptr to the hardware info
  647. **/
  648. static inline char *i40e_nvm_version_str(struct i40e_hw *hw)
  649. {
  650. static char buf[32];
  651. u32 full_ver;
  652. full_ver = hw->nvm.oem_ver;
  653. if (hw->nvm.eetrack == I40E_OEM_EETRACK_ID) {
  654. u8 gen, snap;
  655. u16 release;
  656. gen = (u8)(full_ver >> I40E_OEM_GEN_SHIFT);
  657. snap = (u8)((full_ver & I40E_OEM_SNAP_MASK) >>
  658. I40E_OEM_SNAP_SHIFT);
  659. release = (u16)(full_ver & I40E_OEM_RELEASE_MASK);
  660. snprintf(buf, sizeof(buf), "%x.%x.%x", gen, snap, release);
  661. } else {
  662. u8 ver, patch;
  663. u16 build;
  664. ver = (u8)(full_ver >> I40E_OEM_VER_SHIFT);
  665. build = (u16)((full_ver >> I40E_OEM_VER_BUILD_SHIFT) &
  666. I40E_OEM_VER_BUILD_MASK);
  667. patch = (u8)(full_ver & I40E_OEM_VER_PATCH_MASK);
  668. snprintf(buf, sizeof(buf),
  669. "%x.%02x 0x%x %d.%d.%d",
  670. (hw->nvm.version & I40E_NVM_VERSION_HI_MASK) >>
  671. I40E_NVM_VERSION_HI_SHIFT,
  672. (hw->nvm.version & I40E_NVM_VERSION_LO_MASK) >>
  673. I40E_NVM_VERSION_LO_SHIFT,
  674. hw->nvm.eetrack, ver, build, patch);
  675. }
  676. return buf;
  677. }
  678. /**
  679. * i40e_netdev_to_pf: Retrieve the PF struct for given netdev
  680. * @netdev: the corresponding netdev
  681. *
  682. * Return the PF struct for the given netdev
  683. **/
  684. static inline struct i40e_pf *i40e_netdev_to_pf(struct net_device *netdev)
  685. {
  686. struct i40e_netdev_priv *np = netdev_priv(netdev);
  687. struct i40e_vsi *vsi = np->vsi;
  688. return vsi->back;
  689. }
  690. static inline void i40e_vsi_setup_irqhandler(struct i40e_vsi *vsi,
  691. irqreturn_t (*irq_handler)(int, void *))
  692. {
  693. vsi->irq_handler = irq_handler;
  694. }
  695. /**
  696. * i40e_get_fd_cnt_all - get the total FD filter space available
  697. * @pf: pointer to the PF struct
  698. **/
  699. static inline int i40e_get_fd_cnt_all(struct i40e_pf *pf)
  700. {
  701. return pf->hw.fdir_shared_filter_count + pf->fdir_pf_filter_count;
  702. }
  703. /**
  704. * i40e_read_fd_input_set - reads value of flow director input set register
  705. * @pf: pointer to the PF struct
  706. * @addr: register addr
  707. *
  708. * This function reads value of flow director input set register
  709. * specified by 'addr' (which is specific to flow-type)
  710. **/
  711. static inline u64 i40e_read_fd_input_set(struct i40e_pf *pf, u16 addr)
  712. {
  713. u64 val;
  714. val = i40e_read_rx_ctl(&pf->hw, I40E_PRTQF_FD_INSET(addr, 1));
  715. val <<= 32;
  716. val += i40e_read_rx_ctl(&pf->hw, I40E_PRTQF_FD_INSET(addr, 0));
  717. return val;
  718. }
  719. /**
  720. * i40e_write_fd_input_set - writes value into flow director input set register
  721. * @pf: pointer to the PF struct
  722. * @addr: register addr
  723. * @val: value to be written
  724. *
  725. * This function writes specified value to the register specified by 'addr'.
  726. * This register is input set register based on flow-type.
  727. **/
  728. static inline void i40e_write_fd_input_set(struct i40e_pf *pf,
  729. u16 addr, u64 val)
  730. {
  731. i40e_write_rx_ctl(&pf->hw, I40E_PRTQF_FD_INSET(addr, 1),
  732. (u32)(val >> 32));
  733. i40e_write_rx_ctl(&pf->hw, I40E_PRTQF_FD_INSET(addr, 0),
  734. (u32)(val & 0xFFFFFFFFULL));
  735. }
  736. /* needed by i40e_ethtool.c */
  737. int i40e_up(struct i40e_vsi *vsi);
  738. void i40e_down(struct i40e_vsi *vsi);
  739. extern const char i40e_driver_name[];
  740. extern const char i40e_driver_version_str[];
  741. void i40e_do_reset_safe(struct i40e_pf *pf, u32 reset_flags);
  742. void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags, bool lock_acquired);
  743. int i40e_config_rss(struct i40e_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size);
  744. int i40e_get_rss(struct i40e_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size);
  745. void i40e_fill_rss_lut(struct i40e_pf *pf, u8 *lut,
  746. u16 rss_table_size, u16 rss_size);
  747. struct i40e_vsi *i40e_find_vsi_from_id(struct i40e_pf *pf, u16 id);
  748. /**
  749. * i40e_find_vsi_by_type - Find and return Flow Director VSI
  750. * @pf: PF to search for VSI
  751. * @type: Value indicating type of VSI we are looking for
  752. **/
  753. static inline struct i40e_vsi *
  754. i40e_find_vsi_by_type(struct i40e_pf *pf, u16 type)
  755. {
  756. int i;
  757. for (i = 0; i < pf->num_alloc_vsi; i++) {
  758. struct i40e_vsi *vsi = pf->vsi[i];
  759. if (vsi && vsi->type == type)
  760. return vsi;
  761. }
  762. return NULL;
  763. }
  764. void i40e_update_stats(struct i40e_vsi *vsi);
  765. void i40e_update_eth_stats(struct i40e_vsi *vsi);
  766. struct rtnl_link_stats64 *i40e_get_vsi_stats_struct(struct i40e_vsi *vsi);
  767. int i40e_fetch_switch_configuration(struct i40e_pf *pf,
  768. bool printconfig);
  769. int i40e_add_del_fdir(struct i40e_vsi *vsi,
  770. struct i40e_fdir_filter *input, bool add);
  771. void i40e_fdir_check_and_reenable(struct i40e_pf *pf);
  772. u32 i40e_get_current_fd_count(struct i40e_pf *pf);
  773. u32 i40e_get_cur_guaranteed_fd_count(struct i40e_pf *pf);
  774. u32 i40e_get_current_atr_cnt(struct i40e_pf *pf);
  775. u32 i40e_get_global_fd_count(struct i40e_pf *pf);
  776. bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features);
  777. void i40e_set_ethtool_ops(struct net_device *netdev);
  778. struct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi,
  779. const u8 *macaddr, s16 vlan);
  780. void __i40e_del_filter(struct i40e_vsi *vsi, struct i40e_mac_filter *f);
  781. void i40e_del_filter(struct i40e_vsi *vsi, const u8 *macaddr, s16 vlan);
  782. int i40e_sync_vsi_filters(struct i40e_vsi *vsi);
  783. struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type,
  784. u16 uplink, u32 param1);
  785. int i40e_vsi_release(struct i40e_vsi *vsi);
  786. void i40e_service_event_schedule(struct i40e_pf *pf);
  787. void i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 vf_id,
  788. u8 *msg, u16 len);
  789. int i40e_vsi_start_rings(struct i40e_vsi *vsi);
  790. void i40e_vsi_stop_rings(struct i40e_vsi *vsi);
  791. void i40e_vsi_stop_rings_no_wait(struct i40e_vsi *vsi);
  792. int i40e_vsi_wait_queues_disabled(struct i40e_vsi *vsi);
  793. int i40e_reconfig_rss_queues(struct i40e_pf *pf, int queue_count);
  794. struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 flags, u16 uplink_seid,
  795. u16 downlink_seid, u8 enabled_tc);
  796. void i40e_veb_release(struct i40e_veb *veb);
  797. int i40e_veb_config_tc(struct i40e_veb *veb, u8 enabled_tc);
  798. int i40e_vsi_add_pvid(struct i40e_vsi *vsi, u16 vid);
  799. void i40e_vsi_remove_pvid(struct i40e_vsi *vsi);
  800. void i40e_vsi_reset_stats(struct i40e_vsi *vsi);
  801. void i40e_pf_reset_stats(struct i40e_pf *pf);
  802. #ifdef CONFIG_DEBUG_FS
  803. void i40e_dbg_pf_init(struct i40e_pf *pf);
  804. void i40e_dbg_pf_exit(struct i40e_pf *pf);
  805. void i40e_dbg_init(void);
  806. void i40e_dbg_exit(void);
  807. #else
  808. static inline void i40e_dbg_pf_init(struct i40e_pf *pf) {}
  809. static inline void i40e_dbg_pf_exit(struct i40e_pf *pf) {}
  810. static inline void i40e_dbg_init(void) {}
  811. static inline void i40e_dbg_exit(void) {}
  812. #endif /* CONFIG_DEBUG_FS*/
  813. /* needed by client drivers */
  814. int i40e_lan_add_device(struct i40e_pf *pf);
  815. int i40e_lan_del_device(struct i40e_pf *pf);
  816. void i40e_client_subtask(struct i40e_pf *pf);
  817. void i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi);
  818. void i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset);
  819. void i40e_notify_client_of_vf_enable(struct i40e_pf *pf, u32 num_vfs);
  820. void i40e_notify_client_of_vf_reset(struct i40e_pf *pf, u32 vf_id);
  821. int i40e_vf_client_capable(struct i40e_pf *pf, u32 vf_id);
  822. /**
  823. * i40e_irq_dynamic_enable - Enable default interrupt generation settings
  824. * @vsi: pointer to a vsi
  825. * @vector: enable a particular Hw Interrupt vector, without base_vector
  826. **/
  827. static inline void i40e_irq_dynamic_enable(struct i40e_vsi *vsi, int vector)
  828. {
  829. struct i40e_pf *pf = vsi->back;
  830. struct i40e_hw *hw = &pf->hw;
  831. u32 val;
  832. /* definitely clear the PBA here, as this function is meant to
  833. * clean out all previous interrupts AND enable the interrupt
  834. */
  835. val = I40E_PFINT_DYN_CTLN_INTENA_MASK |
  836. I40E_PFINT_DYN_CTLN_CLEARPBA_MASK |
  837. (I40E_ITR_NONE << I40E_PFINT_DYN_CTLN_ITR_INDX_SHIFT);
  838. wr32(hw, I40E_PFINT_DYN_CTLN(vector + vsi->base_vector - 1), val);
  839. /* skip the flush */
  840. }
  841. void i40e_irq_dynamic_disable_icr0(struct i40e_pf *pf);
  842. void i40e_irq_dynamic_enable_icr0(struct i40e_pf *pf, bool clearpba);
  843. int i40e_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
  844. int i40e_open(struct net_device *netdev);
  845. int i40e_close(struct net_device *netdev);
  846. int i40e_vsi_open(struct i40e_vsi *vsi);
  847. void i40e_vlan_stripping_disable(struct i40e_vsi *vsi);
  848. int i40e_add_vlan_all_mac(struct i40e_vsi *vsi, s16 vid);
  849. int i40e_vsi_add_vlan(struct i40e_vsi *vsi, u16 vid);
  850. void i40e_rm_vlan_all_mac(struct i40e_vsi *vsi, s16 vid);
  851. void i40e_vsi_kill_vlan(struct i40e_vsi *vsi, u16 vid);
  852. struct i40e_mac_filter *i40e_add_mac_filter(struct i40e_vsi *vsi,
  853. const u8 *macaddr);
  854. int i40e_del_mac_filter(struct i40e_vsi *vsi, const u8 *macaddr);
  855. bool i40e_is_vsi_in_vlan(struct i40e_vsi *vsi);
  856. struct i40e_mac_filter *i40e_find_mac(struct i40e_vsi *vsi, const u8 *macaddr);
  857. void i40e_vlan_stripping_enable(struct i40e_vsi *vsi);
  858. #ifdef CONFIG_I40E_DCB
  859. void i40e_dcbnl_flush_apps(struct i40e_pf *pf,
  860. struct i40e_dcbx_config *old_cfg,
  861. struct i40e_dcbx_config *new_cfg);
  862. void i40e_dcbnl_set_all(struct i40e_vsi *vsi);
  863. void i40e_dcbnl_setup(struct i40e_vsi *vsi);
  864. bool i40e_dcb_need_reconfig(struct i40e_pf *pf,
  865. struct i40e_dcbx_config *old_cfg,
  866. struct i40e_dcbx_config *new_cfg);
  867. #endif /* CONFIG_I40E_DCB */
  868. void i40e_ptp_rx_hang(struct i40e_pf *pf);
  869. void i40e_ptp_tx_hang(struct i40e_pf *pf);
  870. void i40e_ptp_tx_hwtstamp(struct i40e_pf *pf);
  871. void i40e_ptp_rx_hwtstamp(struct i40e_pf *pf, struct sk_buff *skb, u8 index);
  872. void i40e_ptp_set_increment(struct i40e_pf *pf);
  873. int i40e_ptp_set_ts_config(struct i40e_pf *pf, struct ifreq *ifr);
  874. int i40e_ptp_get_ts_config(struct i40e_pf *pf, struct ifreq *ifr);
  875. void i40e_ptp_init(struct i40e_pf *pf);
  876. void i40e_ptp_stop(struct i40e_pf *pf);
  877. int i40e_is_vsi_uplink_mode_veb(struct i40e_vsi *vsi);
  878. i40e_status i40e_get_partition_bw_setting(struct i40e_pf *pf);
  879. i40e_status i40e_set_partition_bw_setting(struct i40e_pf *pf);
  880. i40e_status i40e_commit_partition_bw_setting(struct i40e_pf *pf);
  881. void i40e_print_link_message(struct i40e_vsi *vsi, bool isup);
  882. static inline bool i40e_enabled_xdp_vsi(struct i40e_vsi *vsi)
  883. {
  884. return !!vsi->xdp_prog;
  885. }
  886. #endif /* _I40E_H_ */