i40e_virtchnl.h 12 KB

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