i40e.h 35 KB

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