i40e_virtchnl.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. /*******************************************************************************
  2. *
  3. * Intel Ethernet Controller XL710 Family Linux Driver
  4. * Copyright(c) 2013 - 2014 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * The full GNU General Public License is included in this distribution in
  19. * the file called "COPYING".
  20. *
  21. * Contact Information:
  22. * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. ******************************************************************************/
  26. #ifndef _I40E_VIRTCHNL_H_
  27. #define _I40E_VIRTCHNL_H_
  28. #include "i40e_type.h"
  29. /* Description:
  30. * This header file describes the VF-PF communication protocol used
  31. * by the various i40e drivers.
  32. *
  33. * Admin queue buffer usage:
  34. * desc->opcode is always i40e_aqc_opc_send_msg_to_pf
  35. * flags, retval, datalen, and data addr are all used normally.
  36. * Firmware copies the cookie fields when sending messages between the PF and
  37. * VF, but uses all other fields internally. Due to this limitation, we
  38. * must send all messages as "indirect", i.e. using an external buffer.
  39. *
  40. * All the vsi indexes are relative to the VF. Each VF can have maximum of
  41. * three VSIs. All the queue indexes are relative to the VSI. Each VF can
  42. * have a maximum of sixteen queues for all of its VSIs.
  43. *
  44. * The PF is required to return a status code in v_retval for all messages
  45. * except RESET_VF, which does not require any response. The return value is of
  46. * i40e_status_code type, defined in the i40e_type.h.
  47. *
  48. * In general, VF driver initialization should roughly follow the order of these
  49. * opcodes. The VF driver must first validate the API version of the PF driver,
  50. * then request a reset, then get resources, then configure queues and
  51. * interrupts. After these operations are complete, the VF driver may start
  52. * its queues, optionally add MAC and VLAN filters, and process traffic.
  53. */
  54. /* Opcodes for VF-PF communication. These are placed in the v_opcode field
  55. * of the virtchnl_msg structure.
  56. */
  57. enum i40e_virtchnl_ops {
  58. /* The PF sends status change events to VFs using
  59. * the I40E_VIRTCHNL_OP_EVENT opcode.
  60. * VFs send requests to the PF using the other ops.
  61. */
  62. I40E_VIRTCHNL_OP_UNKNOWN = 0,
  63. I40E_VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */
  64. I40E_VIRTCHNL_OP_RESET_VF = 2,
  65. I40E_VIRTCHNL_OP_GET_VF_RESOURCES = 3,
  66. I40E_VIRTCHNL_OP_CONFIG_TX_QUEUE = 4,
  67. I40E_VIRTCHNL_OP_CONFIG_RX_QUEUE = 5,
  68. I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES = 6,
  69. I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP = 7,
  70. I40E_VIRTCHNL_OP_ENABLE_QUEUES = 8,
  71. I40E_VIRTCHNL_OP_DISABLE_QUEUES = 9,
  72. I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS = 10,
  73. I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS = 11,
  74. I40E_VIRTCHNL_OP_ADD_VLAN = 12,
  75. I40E_VIRTCHNL_OP_DEL_VLAN = 13,
  76. I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14,
  77. I40E_VIRTCHNL_OP_GET_STATS = 15,
  78. I40E_VIRTCHNL_OP_FCOE = 16,
  79. I40E_VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */
  80. I40E_VIRTCHNL_OP_IWARP = 20,
  81. I40E_VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP = 21,
  82. I40E_VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP = 22,
  83. I40E_VIRTCHNL_OP_CONFIG_RSS_KEY = 23,
  84. I40E_VIRTCHNL_OP_CONFIG_RSS_LUT = 24,
  85. I40E_VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25,
  86. I40E_VIRTCHNL_OP_SET_RSS_HENA = 26,
  87. };
  88. /* Virtual channel message descriptor. This overlays the admin queue
  89. * descriptor. All other data is passed in external buffers.
  90. */
  91. struct i40e_virtchnl_msg {
  92. u8 pad[8]; /* AQ flags/opcode/len/retval fields */
  93. enum i40e_virtchnl_ops v_opcode; /* avoid confusion with desc->opcode */
  94. i40e_status v_retval; /* ditto for desc->retval */
  95. u32 vfid; /* used by PF when sending to VF */
  96. };
  97. /* Message descriptions and data structures.*/
  98. /* I40E_VIRTCHNL_OP_VERSION
  99. * VF posts its version number to the PF. PF responds with its version number
  100. * in the same format, along with a return code.
  101. * Reply from PF has its major/minor versions also in param0 and param1.
  102. * If there is a major version mismatch, then the VF cannot operate.
  103. * If there is a minor version mismatch, then the VF can operate but should
  104. * add a warning to the system log.
  105. *
  106. * This enum element MUST always be specified as == 1, regardless of other
  107. * changes in the API. The PF must always respond to this message without
  108. * error regardless of version mismatch.
  109. */
  110. #define I40E_VIRTCHNL_VERSION_MAJOR 1
  111. #define I40E_VIRTCHNL_VERSION_MINOR 1
  112. #define I40E_VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0
  113. struct i40e_virtchnl_version_info {
  114. u32 major;
  115. u32 minor;
  116. };
  117. /* I40E_VIRTCHNL_OP_RESET_VF
  118. * VF sends this request to PF with no parameters
  119. * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
  120. * until reset completion is indicated. The admin queue must be reinitialized
  121. * after this operation.
  122. *
  123. * When reset is complete, PF must ensure that all queues in all VSIs associated
  124. * with the VF are stopped, all queue configurations in the HMC are set to 0,
  125. * and all MAC and VLAN filters (except the default MAC address) on all VSIs
  126. * are cleared.
  127. */
  128. /* I40E_VIRTCHNL_OP_GET_VF_RESOURCES
  129. * Version 1.0 VF sends this request to PF with no parameters
  130. * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities
  131. * PF responds with an indirect message containing
  132. * i40e_virtchnl_vf_resource and one or more
  133. * i40e_virtchnl_vsi_resource structures.
  134. */
  135. struct i40e_virtchnl_vsi_resource {
  136. u16 vsi_id;
  137. u16 num_queue_pairs;
  138. enum i40e_vsi_type vsi_type;
  139. u16 qset_handle;
  140. u8 default_mac_addr[ETH_ALEN];
  141. };
  142. /* VF offload flags */
  143. #define I40E_VIRTCHNL_VF_OFFLOAD_L2 0x00000001
  144. #define I40E_VIRTCHNL_VF_OFFLOAD_IWARP 0x00000002
  145. #define I40E_VIRTCHNL_VF_OFFLOAD_FCOE 0x00000004
  146. #define I40E_VIRTCHNL_VF_OFFLOAD_RSS_AQ 0x00000008
  147. #define I40E_VIRTCHNL_VF_OFFLOAD_RSS_REG 0x00000010
  148. #define I40E_VIRTCHNL_VF_OFFLOAD_WB_ON_ITR 0x00000020
  149. #define I40E_VIRTCHNL_VF_OFFLOAD_VLAN 0x00010000
  150. #define I40E_VIRTCHNL_VF_OFFLOAD_RX_POLLING 0x00020000
  151. #define I40E_VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 0x00040000
  152. #define I40E_VIRTCHNL_VF_OFFLOAD_RSS_PF 0X00080000
  153. #define I40E_VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM 0X00100000
  154. struct i40e_virtchnl_vf_resource {
  155. u16 num_vsis;
  156. u16 num_queue_pairs;
  157. u16 max_vectors;
  158. u16 max_mtu;
  159. u32 vf_offload_flags;
  160. u32 rss_key_size;
  161. u32 rss_lut_size;
  162. struct i40e_virtchnl_vsi_resource vsi_res[1];
  163. };
  164. /* I40E_VIRTCHNL_OP_CONFIG_TX_QUEUE
  165. * VF sends this message to set up parameters for one TX queue.
  166. * External data buffer contains one instance of i40e_virtchnl_txq_info.
  167. * PF configures requested queue and returns a status code.
  168. */
  169. /* Tx queue config info */
  170. struct i40e_virtchnl_txq_info {
  171. u16 vsi_id;
  172. u16 queue_id;
  173. u16 ring_len; /* number of descriptors, multiple of 8 */
  174. u16 headwb_enabled;
  175. u64 dma_ring_addr;
  176. u64 dma_headwb_addr;
  177. };
  178. /* I40E_VIRTCHNL_OP_CONFIG_RX_QUEUE
  179. * VF sends this message to set up parameters for one RX queue.
  180. * External data buffer contains one instance of i40e_virtchnl_rxq_info.
  181. * PF configures requested queue and returns a status code.
  182. */
  183. /* Rx queue config info */
  184. struct i40e_virtchnl_rxq_info {
  185. u16 vsi_id;
  186. u16 queue_id;
  187. u32 ring_len; /* number of descriptors, multiple of 32 */
  188. u16 hdr_size;
  189. u16 splithdr_enabled;
  190. u32 databuffer_size;
  191. u32 max_pkt_size;
  192. u64 dma_ring_addr;
  193. enum i40e_hmc_obj_rx_hsplit_0 rx_split_pos;
  194. };
  195. /* I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES
  196. * VF sends this message to set parameters for all active TX and RX queues
  197. * associated with the specified VSI.
  198. * PF configures queues and returns status.
  199. * If the number of queues specified is greater than the number of queues
  200. * associated with the VSI, an error is returned and no queues are configured.
  201. */
  202. struct i40e_virtchnl_queue_pair_info {
  203. /* NOTE: vsi_id and queue_id should be identical for both queues. */
  204. struct i40e_virtchnl_txq_info txq;
  205. struct i40e_virtchnl_rxq_info rxq;
  206. };
  207. struct i40e_virtchnl_vsi_queue_config_info {
  208. u16 vsi_id;
  209. u16 num_queue_pairs;
  210. struct i40e_virtchnl_queue_pair_info qpair[1];
  211. };
  212. /* I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP
  213. * VF uses this message to map vectors to queues.
  214. * The rxq_map and txq_map fields are bitmaps used to indicate which queues
  215. * are to be associated with the specified vector.
  216. * The "other" causes are always mapped to vector 0.
  217. * PF configures interrupt mapping and returns status.
  218. */
  219. struct i40e_virtchnl_vector_map {
  220. u16 vsi_id;
  221. u16 vector_id;
  222. u16 rxq_map;
  223. u16 txq_map;
  224. u16 rxitr_idx;
  225. u16 txitr_idx;
  226. };
  227. struct i40e_virtchnl_irq_map_info {
  228. u16 num_vectors;
  229. struct i40e_virtchnl_vector_map vecmap[1];
  230. };
  231. /* I40E_VIRTCHNL_OP_ENABLE_QUEUES
  232. * I40E_VIRTCHNL_OP_DISABLE_QUEUES
  233. * VF sends these message to enable or disable TX/RX queue pairs.
  234. * The queues fields are bitmaps indicating which queues to act upon.
  235. * (Currently, we only support 16 queues per VF, but we make the field
  236. * u32 to allow for expansion.)
  237. * PF performs requested action and returns status.
  238. */
  239. struct i40e_virtchnl_queue_select {
  240. u16 vsi_id;
  241. u16 pad;
  242. u32 rx_queues;
  243. u32 tx_queues;
  244. };
  245. /* I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS
  246. * VF sends this message in order to add one or more unicast or multicast
  247. * address filters for the specified VSI.
  248. * PF adds the filters and returns status.
  249. */
  250. /* I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS
  251. * VF sends this message in order to remove one or more unicast or multicast
  252. * filters for the specified VSI.
  253. * PF removes the filters and returns status.
  254. */
  255. struct i40e_virtchnl_ether_addr {
  256. u8 addr[ETH_ALEN];
  257. u8 pad[2];
  258. };
  259. struct i40e_virtchnl_ether_addr_list {
  260. u16 vsi_id;
  261. u16 num_elements;
  262. struct i40e_virtchnl_ether_addr list[1];
  263. };
  264. /* I40E_VIRTCHNL_OP_ADD_VLAN
  265. * VF sends this message to add one or more VLAN tag filters for receives.
  266. * PF adds the filters and returns status.
  267. * If a port VLAN is configured by the PF, this operation will return an
  268. * error to the VF.
  269. */
  270. /* I40E_VIRTCHNL_OP_DEL_VLAN
  271. * VF sends this message to remove one or more VLAN tag filters for receives.
  272. * PF removes the filters and returns status.
  273. * If a port VLAN is configured by the PF, this operation will return an
  274. * error to the VF.
  275. */
  276. struct i40e_virtchnl_vlan_filter_list {
  277. u16 vsi_id;
  278. u16 num_elements;
  279. u16 vlan_id[1];
  280. };
  281. /* I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
  282. * VF sends VSI id and flags.
  283. * PF returns status code in retval.
  284. * Note: we assume that broadcast accept mode is always enabled.
  285. */
  286. struct i40e_virtchnl_promisc_info {
  287. u16 vsi_id;
  288. u16 flags;
  289. };
  290. #define I40E_FLAG_VF_UNICAST_PROMISC 0x00000001
  291. #define I40E_FLAG_VF_MULTICAST_PROMISC 0x00000002
  292. /* I40E_VIRTCHNL_OP_GET_STATS
  293. * VF sends this message to request stats for the selected VSI. VF uses
  294. * the i40e_virtchnl_queue_select struct to specify the VSI. The queue_id
  295. * field is ignored by the PF.
  296. *
  297. * PF replies with struct i40e_eth_stats in an external buffer.
  298. */
  299. /* I40E_VIRTCHNL_OP_CONFIG_RSS_KEY
  300. * I40E_VIRTCHNL_OP_CONFIG_RSS_LUT
  301. * VF sends these messages to configure RSS. Only supported if both PF
  302. * and VF drivers set the I40E_VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
  303. * configuration negotiation. If this is the case, then the RSS fields in
  304. * the VF resource struct are valid.
  305. * Both the key and LUT are initialized to 0 by the PF, meaning that
  306. * RSS is effectively disabled until set up by the VF.
  307. */
  308. struct i40e_virtchnl_rss_key {
  309. u16 vsi_id;
  310. u16 key_len;
  311. u8 key[1]; /* RSS hash key, packed bytes */
  312. };
  313. struct i40e_virtchnl_rss_lut {
  314. u16 vsi_id;
  315. u16 lut_entries;
  316. u8 lut[1]; /* RSS lookup table*/
  317. };
  318. /* I40E_VIRTCHNL_OP_GET_RSS_HENA_CAPS
  319. * I40E_VIRTCHNL_OP_SET_RSS_HENA
  320. * VF sends these messages to get and set the hash filter enable bits for RSS.
  321. * By default, the PF sets these to all possible traffic types that the
  322. * hardware supports. The VF can query this value if it wants to change the
  323. * traffic types that are hashed by the hardware.
  324. * Traffic types are defined in the i40e_filter_pctype enum in i40e_type.h
  325. */
  326. struct i40e_virtchnl_rss_hena {
  327. u64 hena;
  328. };
  329. /* I40E_VIRTCHNL_OP_EVENT
  330. * PF sends this message to inform the VF driver of events that may affect it.
  331. * No direct response is expected from the VF, though it may generate other
  332. * messages in response to this one.
  333. */
  334. enum i40e_virtchnl_event_codes {
  335. I40E_VIRTCHNL_EVENT_UNKNOWN = 0,
  336. I40E_VIRTCHNL_EVENT_LINK_CHANGE,
  337. I40E_VIRTCHNL_EVENT_RESET_IMPENDING,
  338. I40E_VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
  339. };
  340. #define I40E_PF_EVENT_SEVERITY_INFO 0
  341. #define I40E_PF_EVENT_SEVERITY_CERTAIN_DOOM 255
  342. struct i40e_virtchnl_pf_event {
  343. enum i40e_virtchnl_event_codes event;
  344. union {
  345. struct {
  346. enum i40e_aq_link_speed link_speed;
  347. bool link_status;
  348. } link_event;
  349. } event_data;
  350. int severity;
  351. };
  352. /* I40E_VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP
  353. * VF uses this message to request PF to map IWARP vectors to IWARP queues.
  354. * The request for this originates from the VF IWARP driver through
  355. * a client interface between VF LAN and VF IWARP driver.
  356. * A vector could have an AEQ and CEQ attached to it although
  357. * there is a single AEQ per VF IWARP instance in which case
  358. * most vectors will have an INVALID_IDX for aeq and valid idx for ceq.
  359. * There will never be a case where there will be multiple CEQs attached
  360. * to a single vector.
  361. * PF configures interrupt mapping and returns status.
  362. */
  363. /* HW does not define a type value for AEQ; only for RX/TX and CEQ.
  364. * In order for us to keep the interface simple, SW will define a
  365. * unique type value for AEQ.
  366. */
  367. #define I40E_QUEUE_TYPE_PE_AEQ 0x80
  368. #define I40E_QUEUE_INVALID_IDX 0xFFFF
  369. struct i40e_virtchnl_iwarp_qv_info {
  370. u32 v_idx; /* msix_vector */
  371. u16 ceq_idx;
  372. u16 aeq_idx;
  373. u8 itr_idx;
  374. };
  375. struct i40e_virtchnl_iwarp_qvlist_info {
  376. u32 num_vectors;
  377. struct i40e_virtchnl_iwarp_qv_info qv_info[1];
  378. };
  379. /* VF reset states - these are written into the RSTAT register:
  380. * I40E_VFGEN_RSTAT1 on the PF
  381. * I40E_VFGEN_RSTAT on the VF
  382. * When the PF initiates a reset, it writes 0
  383. * When the reset is complete, it writes 1
  384. * When the PF detects that the VF has recovered, it writes 2
  385. * VF checks this register periodically to determine if a reset has occurred,
  386. * then polls it to know when the reset is complete.
  387. * If either the PF or VF reads the register while the hardware
  388. * is in a reset state, it will return DEADBEEF, which, when masked
  389. * will result in 3.
  390. */
  391. enum i40e_vfr_states {
  392. I40E_VFR_INPROGRESS = 0,
  393. I40E_VFR_COMPLETED,
  394. I40E_VFR_VFACTIVE,
  395. I40E_VFR_UNKNOWN,
  396. };
  397. #endif /* _I40E_VIRTCHNL_H_ */