i40e_virtchnl.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. /*******************************************************************************
  2. *
  3. * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
  4. * Copyright(c) 2013 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. * The full GNU General Public License is included in this distribution in
  16. * the file called "COPYING".
  17. *
  18. * Contact Information:
  19. * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  20. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  21. *
  22. ******************************************************************************/
  23. #ifndef _I40E_VIRTCHNL_H_
  24. #define _I40E_VIRTCHNL_H_
  25. #include "i40e_type.h"
  26. /* Description:
  27. * This header file describes the VF-PF communication protocol used
  28. * by the various i40e drivers.
  29. *
  30. * Admin queue buffer usage:
  31. * desc->opcode is always i40e_aqc_opc_send_msg_to_pf
  32. * flags, retval, datalen, and data addr are all used normally.
  33. * Firmware copies the cookie fields when sending messages between the PF and
  34. * VF, but uses all other fields internally. Due to this limitation, we
  35. * must send all messages as "indirect", i.e. using an external buffer.
  36. *
  37. * All the vsi indexes are relative to the VF. Each VF can have maximum of
  38. * three VSIs. All the queue indexes are relative to the VSI. Each VF can
  39. * have a maximum of sixteen queues for all of its VSIs.
  40. *
  41. * The PF is required to return a status code in v_retval for all messages
  42. * except RESET_VF, which does not require any response. The return value is of
  43. * i40e_status_code type, defined in the i40e_type.h.
  44. *
  45. * In general, VF driver initialization should roughly follow the order of these
  46. * opcodes. The VF driver must first validate the API version of the PF driver,
  47. * then request a reset, then get resources, then configure queues and
  48. * interrupts. After these operations are complete, the VF driver may start
  49. * its queues, optionally add MAC and VLAN filters, and process traffic.
  50. */
  51. /* Opcodes for VF-PF communication. These are placed in the v_opcode field
  52. * of the virtchnl_msg structure.
  53. */
  54. enum i40e_virtchnl_ops {
  55. /* VF sends req. to pf for the following
  56. * ops.
  57. */
  58. I40E_VIRTCHNL_OP_UNKNOWN = 0,
  59. I40E_VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */
  60. I40E_VIRTCHNL_OP_RESET_VF,
  61. I40E_VIRTCHNL_OP_GET_VF_RESOURCES,
  62. I40E_VIRTCHNL_OP_CONFIG_TX_QUEUE,
  63. I40E_VIRTCHNL_OP_CONFIG_RX_QUEUE,
  64. I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES,
  65. I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP,
  66. I40E_VIRTCHNL_OP_ENABLE_QUEUES,
  67. I40E_VIRTCHNL_OP_DISABLE_QUEUES,
  68. I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS,
  69. I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS,
  70. I40E_VIRTCHNL_OP_ADD_VLAN,
  71. I40E_VIRTCHNL_OP_DEL_VLAN,
  72. I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE,
  73. I40E_VIRTCHNL_OP_GET_STATS,
  74. I40E_VIRTCHNL_OP_FCOE,
  75. /* PF sends status change events to vfs using
  76. * the following op.
  77. */
  78. I40E_VIRTCHNL_OP_EVENT,
  79. };
  80. /* Virtual channel message descriptor. This overlays the admin queue
  81. * descriptor. All other data is passed in external buffers.
  82. */
  83. struct i40e_virtchnl_msg {
  84. u8 pad[8]; /* AQ flags/opcode/len/retval fields */
  85. enum i40e_virtchnl_ops v_opcode; /* avoid confusion with desc->opcode */
  86. i40e_status v_retval; /* ditto for desc->retval */
  87. u32 vfid; /* used by PF when sending to VF */
  88. };
  89. /* Message descriptions and data structures.*/
  90. /* I40E_VIRTCHNL_OP_VERSION
  91. * VF posts its version number to the PF. PF responds with its version number
  92. * in the same format, along with a return code.
  93. * Reply from PF has its major/minor versions also in param0 and param1.
  94. * If there is a major version mismatch, then the VF cannot operate.
  95. * If there is a minor version mismatch, then the VF can operate but should
  96. * add a warning to the system log.
  97. *
  98. * This enum element MUST always be specified as == 1, regardless of other
  99. * changes in the API. The PF must always respond to this message without
  100. * error regardless of version mismatch.
  101. */
  102. #define I40E_VIRTCHNL_VERSION_MAJOR 1
  103. #define I40E_VIRTCHNL_VERSION_MINOR 0
  104. struct i40e_virtchnl_version_info {
  105. u32 major;
  106. u32 minor;
  107. };
  108. /* I40E_VIRTCHNL_OP_RESET_VF
  109. * VF sends this request to PF with no parameters
  110. * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
  111. * until reset completion is indicated. The admin queue must be reinitialized
  112. * after this operation.
  113. *
  114. * When reset is complete, PF must ensure that all queues in all VSIs associated
  115. * with the VF are stopped, all queue configurations in the HMC are set to 0,
  116. * and all MAC and VLAN filters (except the default MAC address) on all VSIs
  117. * are cleared.
  118. */
  119. /* I40E_VIRTCHNL_OP_GET_VF_RESOURCES
  120. * VF sends this request to PF with no parameters
  121. * PF responds with an indirect message containing
  122. * i40e_virtchnl_vf_resource and one or more
  123. * i40e_virtchnl_vsi_resource structures.
  124. */
  125. struct i40e_virtchnl_vsi_resource {
  126. u16 vsi_id;
  127. u16 num_queue_pairs;
  128. enum i40e_vsi_type vsi_type;
  129. u16 qset_handle;
  130. u8 default_mac_addr[ETH_ALEN];
  131. };
  132. /* VF offload flags */
  133. #define I40E_VIRTCHNL_VF_OFFLOAD_L2 0x00000001
  134. #define I40E_VIRTCHNL_VF_OFFLOAD_FCOE 0x00000004
  135. #define I40E_VIRTCHNL_VF_OFFLOAD_VLAN 0x00010000
  136. struct i40e_virtchnl_vf_resource {
  137. u16 num_vsis;
  138. u16 num_queue_pairs;
  139. u16 max_vectors;
  140. u16 max_mtu;
  141. u32 vf_offload_flags;
  142. u32 max_fcoe_contexts;
  143. u32 max_fcoe_filters;
  144. struct i40e_virtchnl_vsi_resource vsi_res[1];
  145. };
  146. /* I40E_VIRTCHNL_OP_CONFIG_TX_QUEUE
  147. * VF sends this message to set up parameters for one TX queue.
  148. * External data buffer contains one instance of i40e_virtchnl_txq_info.
  149. * PF configures requested queue and returns a status code.
  150. */
  151. /* Tx queue config info */
  152. struct i40e_virtchnl_txq_info {
  153. u16 vsi_id;
  154. u16 queue_id;
  155. u16 ring_len; /* number of descriptors, multiple of 8 */
  156. u16 headwb_enabled;
  157. u64 dma_ring_addr;
  158. u64 dma_headwb_addr;
  159. };
  160. /* I40E_VIRTCHNL_OP_CONFIG_RX_QUEUE
  161. * VF sends this message to set up parameters for one RX queue.
  162. * External data buffer contains one instance of i40e_virtchnl_rxq_info.
  163. * PF configures requested queue and returns a status code.
  164. */
  165. /* Rx queue config info */
  166. struct i40e_virtchnl_rxq_info {
  167. u16 vsi_id;
  168. u16 queue_id;
  169. u32 ring_len; /* number of descriptors, multiple of 32 */
  170. u16 hdr_size;
  171. u16 splithdr_enabled;
  172. u32 databuffer_size;
  173. u32 max_pkt_size;
  174. u64 dma_ring_addr;
  175. enum i40e_hmc_obj_rx_hsplit_0 rx_split_pos;
  176. };
  177. /* I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES
  178. * VF sends this message to set parameters for all active TX and RX queues
  179. * associated with the specified VSI.
  180. * PF configures queues and returns status.
  181. * If the number of queues specified is greater than the number of queues
  182. * associated with the VSI, an error is returned and no queues are configured.
  183. */
  184. struct i40e_virtchnl_queue_pair_info {
  185. /* NOTE: vsi_id and queue_id should be identical for both queues. */
  186. struct i40e_virtchnl_txq_info txq;
  187. struct i40e_virtchnl_rxq_info rxq;
  188. };
  189. struct i40e_virtchnl_vsi_queue_config_info {
  190. u16 vsi_id;
  191. u16 num_queue_pairs;
  192. struct i40e_virtchnl_queue_pair_info qpair[1];
  193. };
  194. /* I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP
  195. * VF uses this message to map vectors to queues.
  196. * The rxq_map and txq_map fields are bitmaps used to indicate which queues
  197. * are to be associated with the specified vector.
  198. * The "other" causes are always mapped to vector 0.
  199. * PF configures interrupt mapping and returns status.
  200. */
  201. struct i40e_virtchnl_vector_map {
  202. u16 vsi_id;
  203. u16 vector_id;
  204. u16 rxq_map;
  205. u16 txq_map;
  206. u16 rxitr_idx;
  207. u16 txitr_idx;
  208. };
  209. struct i40e_virtchnl_irq_map_info {
  210. u16 num_vectors;
  211. struct i40e_virtchnl_vector_map vecmap[1];
  212. };
  213. /* I40E_VIRTCHNL_OP_ENABLE_QUEUES
  214. * I40E_VIRTCHNL_OP_DISABLE_QUEUES
  215. * VF sends these message to enable or disable TX/RX queue pairs.
  216. * The queues fields are bitmaps indicating which queues to act upon.
  217. * (Currently, we only support 16 queues per VF, but we make the field
  218. * u32 to allow for expansion.)
  219. * PF performs requested action and returns status.
  220. */
  221. struct i40e_virtchnl_queue_select {
  222. u16 vsi_id;
  223. u16 pad;
  224. u32 rx_queues;
  225. u32 tx_queues;
  226. };
  227. /* I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS
  228. * VF sends this message in order to add one or more unicast or multicast
  229. * address filters for the specified VSI.
  230. * PF adds the filters and returns status.
  231. */
  232. /* I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS
  233. * VF sends this message in order to remove one or more unicast or multicast
  234. * filters for the specified VSI.
  235. * PF removes the filters and returns status.
  236. */
  237. struct i40e_virtchnl_ether_addr {
  238. u8 addr[ETH_ALEN];
  239. u8 pad[2];
  240. };
  241. struct i40e_virtchnl_ether_addr_list {
  242. u16 vsi_id;
  243. u16 num_elements;
  244. struct i40e_virtchnl_ether_addr list[1];
  245. };
  246. /* I40E_VIRTCHNL_OP_ADD_VLAN
  247. * VF sends this message to add one or more VLAN tag filters for receives.
  248. * PF adds the filters and returns status.
  249. * If a port VLAN is configured by the PF, this operation will return an
  250. * error to the VF.
  251. */
  252. /* I40E_VIRTCHNL_OP_DEL_VLAN
  253. * VF sends this message to remove one or more VLAN tag filters for receives.
  254. * PF removes the filters and returns status.
  255. * If a port VLAN is configured by the PF, this operation will return an
  256. * error to the VF.
  257. */
  258. struct i40e_virtchnl_vlan_filter_list {
  259. u16 vsi_id;
  260. u16 num_elements;
  261. u16 vlan_id[1];
  262. };
  263. /* I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
  264. * VF sends VSI id and flags.
  265. * PF returns status code in retval.
  266. * Note: we assume that broadcast accept mode is always enabled.
  267. */
  268. struct i40e_virtchnl_promisc_info {
  269. u16 vsi_id;
  270. u16 flags;
  271. };
  272. #define I40E_FLAG_VF_UNICAST_PROMISC 0x00000001
  273. #define I40E_FLAG_VF_MULTICAST_PROMISC 0x00000002
  274. /* I40E_VIRTCHNL_OP_GET_STATS
  275. * VF sends this message to request stats for the selected VSI. VF uses
  276. * the i40e_virtchnl_queue_select struct to specify the VSI. The queue_id
  277. * field is ignored by the PF.
  278. *
  279. * PF replies with struct i40e_eth_stats in an external buffer.
  280. */
  281. /* I40E_VIRTCHNL_OP_EVENT
  282. * PF sends this message to inform the VF driver of events that may affect it.
  283. * No direct response is expected from the VF, though it may generate other
  284. * messages in response to this one.
  285. */
  286. enum i40e_virtchnl_event_codes {
  287. I40E_VIRTCHNL_EVENT_UNKNOWN = 0,
  288. I40E_VIRTCHNL_EVENT_LINK_CHANGE,
  289. I40E_VIRTCHNL_EVENT_RESET_IMPENDING,
  290. I40E_VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
  291. };
  292. #define I40E_PF_EVENT_SEVERITY_INFO 0
  293. #define I40E_PF_EVENT_SEVERITY_CERTAIN_DOOM 255
  294. struct i40e_virtchnl_pf_event {
  295. enum i40e_virtchnl_event_codes event;
  296. union {
  297. struct {
  298. enum i40e_aq_link_speed link_speed;
  299. bool link_status;
  300. } link_event;
  301. } event_data;
  302. int severity;
  303. };
  304. /* The following are TBD, not necessary for LAN functionality.
  305. * I40E_VIRTCHNL_OP_FCOE
  306. */
  307. /* VF reset states - these are written into the RSTAT register:
  308. * I40E_VFGEN_RSTAT1 on the PF
  309. * I40E_VFGEN_RSTAT on the VF
  310. * When the PF initiates a reset, it writes 0
  311. * When the reset is complete, it writes 1
  312. * When the PF detects that the VF has recovered, it writes 2
  313. * VF checks this register periodically to determine if a reset has occurred,
  314. * then polls it to know when the reset is complete.
  315. * If either the PF or VF reads the register while the hardware
  316. * is in a reset state, it will return DEADBEEF, which, when masked
  317. * will result in 3.
  318. */
  319. enum i40e_vfr_states {
  320. I40E_VFR_INPROGRESS = 0,
  321. I40E_VFR_COMPLETED,
  322. I40E_VFR_VFACTIVE,
  323. I40E_VFR_UNKNOWN,
  324. };
  325. #endif /* _I40E_VIRTCHNL_H_ */