i40e.h 35 KB

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