i40e.h 35 KB

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