virtchnl2.h 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (C) 2023 Intel Corporation */
  3. #ifndef _VIRTCHNL2_H_
  4. #define _VIRTCHNL2_H_
  5. #include <linux/if_ether.h>
  6. /* All opcodes associated with virtchnl2 are prefixed with virtchnl2 or
  7. * VIRTCHNL2. Any future opcodes, offloads/capabilities, structures,
  8. * and defines must be prefixed with virtchnl2 or VIRTCHNL2 to avoid confusion.
  9. *
  10. * PF/VF uses the virtchnl2 interface defined in this header file to communicate
  11. * with device Control Plane (CP). Driver and the CP may run on different
  12. * platforms with different endianness. To avoid byte order discrepancies,
  13. * all the structures in this header follow little-endian format.
  14. *
  15. * This is an interface definition file where existing enums and their values
  16. * must remain unchanged over time, so we specify explicit values for all enums.
  17. */
  18. /* This macro is used to generate compilation errors if a structure
  19. * is not exactly the correct length.
  20. */
  21. #define VIRTCHNL2_CHECK_STRUCT_LEN(n, X) \
  22. static_assert((n) == sizeof(struct X))
  23. /* New major set of opcodes introduced and so leaving room for
  24. * old misc opcodes to be added in future. Also these opcodes may only
  25. * be used if both the PF and VF have successfully negotiated the
  26. * VIRTCHNL version as 2.0 during VIRTCHNL2_OP_VERSION exchange.
  27. */
  28. enum virtchnl2_op {
  29. VIRTCHNL2_OP_UNKNOWN = 0,
  30. VIRTCHNL2_OP_VERSION = 1,
  31. VIRTCHNL2_OP_GET_CAPS = 500,
  32. VIRTCHNL2_OP_CREATE_VPORT = 501,
  33. VIRTCHNL2_OP_DESTROY_VPORT = 502,
  34. VIRTCHNL2_OP_ENABLE_VPORT = 503,
  35. VIRTCHNL2_OP_DISABLE_VPORT = 504,
  36. VIRTCHNL2_OP_CONFIG_TX_QUEUES = 505,
  37. VIRTCHNL2_OP_CONFIG_RX_QUEUES = 506,
  38. VIRTCHNL2_OP_ENABLE_QUEUES = 507,
  39. VIRTCHNL2_OP_DISABLE_QUEUES = 508,
  40. VIRTCHNL2_OP_ADD_QUEUES = 509,
  41. VIRTCHNL2_OP_DEL_QUEUES = 510,
  42. VIRTCHNL2_OP_MAP_QUEUE_VECTOR = 511,
  43. VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR = 512,
  44. VIRTCHNL2_OP_GET_RSS_KEY = 513,
  45. VIRTCHNL2_OP_SET_RSS_KEY = 514,
  46. VIRTCHNL2_OP_GET_RSS_LUT = 515,
  47. VIRTCHNL2_OP_SET_RSS_LUT = 516,
  48. VIRTCHNL2_OP_GET_RSS_HASH = 517,
  49. VIRTCHNL2_OP_SET_RSS_HASH = 518,
  50. VIRTCHNL2_OP_SET_SRIOV_VFS = 519,
  51. VIRTCHNL2_OP_ALLOC_VECTORS = 520,
  52. VIRTCHNL2_OP_DEALLOC_VECTORS = 521,
  53. VIRTCHNL2_OP_EVENT = 522,
  54. VIRTCHNL2_OP_GET_STATS = 523,
  55. VIRTCHNL2_OP_RESET_VF = 524,
  56. VIRTCHNL2_OP_GET_EDT_CAPS = 525,
  57. VIRTCHNL2_OP_GET_PTYPE_INFO = 526,
  58. /* Opcode 527 and 528 are reserved for VIRTCHNL2_OP_GET_PTYPE_ID and
  59. * VIRTCHNL2_OP_GET_PTYPE_INFO_RAW.
  60. * Opcodes 529, 530, 531, 532 and 533 are reserved.
  61. */
  62. VIRTCHNL2_OP_LOOPBACK = 534,
  63. VIRTCHNL2_OP_ADD_MAC_ADDR = 535,
  64. VIRTCHNL2_OP_DEL_MAC_ADDR = 536,
  65. VIRTCHNL2_OP_CONFIG_PROMISCUOUS_MODE = 537,
  66. };
  67. /**
  68. * enum virtchnl2_vport_type - Type of virtual port.
  69. * @VIRTCHNL2_VPORT_TYPE_DEFAULT: Default virtual port type.
  70. */
  71. enum virtchnl2_vport_type {
  72. VIRTCHNL2_VPORT_TYPE_DEFAULT = 0,
  73. };
  74. /**
  75. * enum virtchnl2_queue_model - Type of queue model.
  76. * @VIRTCHNL2_QUEUE_MODEL_SINGLE: Single queue model.
  77. * @VIRTCHNL2_QUEUE_MODEL_SPLIT: Split queue model.
  78. *
  79. * In the single queue model, the same transmit descriptor queue is used by
  80. * software to post descriptors to hardware and by hardware to post completed
  81. * descriptors to software.
  82. * Likewise, the same receive descriptor queue is used by hardware to post
  83. * completions to software and by software to post buffers to hardware.
  84. *
  85. * In the split queue model, hardware uses transmit completion queues to post
  86. * descriptor/buffer completions to software, while software uses transmit
  87. * descriptor queues to post descriptors to hardware.
  88. * Likewise, hardware posts descriptor completions to the receive descriptor
  89. * queue, while software uses receive buffer queues to post buffers to hardware.
  90. */
  91. enum virtchnl2_queue_model {
  92. VIRTCHNL2_QUEUE_MODEL_SINGLE = 0,
  93. VIRTCHNL2_QUEUE_MODEL_SPLIT = 1,
  94. };
  95. /* Checksum offload capability flags */
  96. enum virtchnl2_cap_txrx_csum {
  97. VIRTCHNL2_CAP_TX_CSUM_L3_IPV4 = BIT(0),
  98. VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP = BIT(1),
  99. VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP = BIT(2),
  100. VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP = BIT(3),
  101. VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP = BIT(4),
  102. VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP = BIT(5),
  103. VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP = BIT(6),
  104. VIRTCHNL2_CAP_TX_CSUM_GENERIC = BIT(7),
  105. VIRTCHNL2_CAP_RX_CSUM_L3_IPV4 = BIT(8),
  106. VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP = BIT(9),
  107. VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP = BIT(10),
  108. VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP = BIT(11),
  109. VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP = BIT(12),
  110. VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP = BIT(13),
  111. VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP = BIT(14),
  112. VIRTCHNL2_CAP_RX_CSUM_GENERIC = BIT(15),
  113. VIRTCHNL2_CAP_TX_CSUM_L3_SINGLE_TUNNEL = BIT(16),
  114. VIRTCHNL2_CAP_TX_CSUM_L3_DOUBLE_TUNNEL = BIT(17),
  115. VIRTCHNL2_CAP_RX_CSUM_L3_SINGLE_TUNNEL = BIT(18),
  116. VIRTCHNL2_CAP_RX_CSUM_L3_DOUBLE_TUNNEL = BIT(19),
  117. VIRTCHNL2_CAP_TX_CSUM_L4_SINGLE_TUNNEL = BIT(20),
  118. VIRTCHNL2_CAP_TX_CSUM_L4_DOUBLE_TUNNEL = BIT(21),
  119. VIRTCHNL2_CAP_RX_CSUM_L4_SINGLE_TUNNEL = BIT(22),
  120. VIRTCHNL2_CAP_RX_CSUM_L4_DOUBLE_TUNNEL = BIT(23),
  121. };
  122. /* Segmentation offload capability flags */
  123. enum virtchnl2_cap_seg {
  124. VIRTCHNL2_CAP_SEG_IPV4_TCP = BIT(0),
  125. VIRTCHNL2_CAP_SEG_IPV4_UDP = BIT(1),
  126. VIRTCHNL2_CAP_SEG_IPV4_SCTP = BIT(2),
  127. VIRTCHNL2_CAP_SEG_IPV6_TCP = BIT(3),
  128. VIRTCHNL2_CAP_SEG_IPV6_UDP = BIT(4),
  129. VIRTCHNL2_CAP_SEG_IPV6_SCTP = BIT(5),
  130. VIRTCHNL2_CAP_SEG_GENERIC = BIT(6),
  131. VIRTCHNL2_CAP_SEG_TX_SINGLE_TUNNEL = BIT(7),
  132. VIRTCHNL2_CAP_SEG_TX_DOUBLE_TUNNEL = BIT(8),
  133. };
  134. /* Receive Side Scaling Flow type capability flags */
  135. enum virtchnl2_cap_rss {
  136. VIRTCHNL2_CAP_RSS_IPV4_TCP = BIT(0),
  137. VIRTCHNL2_CAP_RSS_IPV4_UDP = BIT(1),
  138. VIRTCHNL2_CAP_RSS_IPV4_SCTP = BIT(2),
  139. VIRTCHNL2_CAP_RSS_IPV4_OTHER = BIT(3),
  140. VIRTCHNL2_CAP_RSS_IPV6_TCP = BIT(4),
  141. VIRTCHNL2_CAP_RSS_IPV6_UDP = BIT(5),
  142. VIRTCHNL2_CAP_RSS_IPV6_SCTP = BIT(6),
  143. VIRTCHNL2_CAP_RSS_IPV6_OTHER = BIT(7),
  144. VIRTCHNL2_CAP_RSS_IPV4_AH = BIT(8),
  145. VIRTCHNL2_CAP_RSS_IPV4_ESP = BIT(9),
  146. VIRTCHNL2_CAP_RSS_IPV4_AH_ESP = BIT(10),
  147. VIRTCHNL2_CAP_RSS_IPV6_AH = BIT(11),
  148. VIRTCHNL2_CAP_RSS_IPV6_ESP = BIT(12),
  149. VIRTCHNL2_CAP_RSS_IPV6_AH_ESP = BIT(13),
  150. };
  151. /* Header split capability flags */
  152. enum virtchnl2_cap_rx_hsplit_at {
  153. /* for prepended metadata */
  154. VIRTCHNL2_CAP_RX_HSPLIT_AT_L2 = BIT(0),
  155. /* all VLANs go into header buffer */
  156. VIRTCHNL2_CAP_RX_HSPLIT_AT_L3 = BIT(1),
  157. VIRTCHNL2_CAP_RX_HSPLIT_AT_L4V4 = BIT(2),
  158. VIRTCHNL2_CAP_RX_HSPLIT_AT_L4V6 = BIT(3),
  159. };
  160. /* Receive Side Coalescing offload capability flags */
  161. enum virtchnl2_cap_rsc {
  162. VIRTCHNL2_CAP_RSC_IPV4_TCP = BIT(0),
  163. VIRTCHNL2_CAP_RSC_IPV4_SCTP = BIT(1),
  164. VIRTCHNL2_CAP_RSC_IPV6_TCP = BIT(2),
  165. VIRTCHNL2_CAP_RSC_IPV6_SCTP = BIT(3),
  166. };
  167. /* Other capability flags */
  168. enum virtchnl2_cap_other {
  169. VIRTCHNL2_CAP_RDMA = BIT_ULL(0),
  170. VIRTCHNL2_CAP_SRIOV = BIT_ULL(1),
  171. VIRTCHNL2_CAP_MACFILTER = BIT_ULL(2),
  172. VIRTCHNL2_CAP_FLOW_DIRECTOR = BIT_ULL(3),
  173. /* Queue based scheduling using split queue model */
  174. VIRTCHNL2_CAP_SPLITQ_QSCHED = BIT_ULL(4),
  175. VIRTCHNL2_CAP_CRC = BIT_ULL(5),
  176. VIRTCHNL2_CAP_ADQ = BIT_ULL(6),
  177. VIRTCHNL2_CAP_WB_ON_ITR = BIT_ULL(7),
  178. VIRTCHNL2_CAP_PROMISC = BIT_ULL(8),
  179. VIRTCHNL2_CAP_LINK_SPEED = BIT_ULL(9),
  180. VIRTCHNL2_CAP_INLINE_IPSEC = BIT_ULL(10),
  181. VIRTCHNL2_CAP_LARGE_NUM_QUEUES = BIT_ULL(11),
  182. VIRTCHNL2_CAP_VLAN = BIT_ULL(12),
  183. VIRTCHNL2_CAP_PTP = BIT_ULL(13),
  184. /* EDT: Earliest Departure Time capability used for Timing Wheel */
  185. VIRTCHNL2_CAP_EDT = BIT_ULL(14),
  186. VIRTCHNL2_CAP_ADV_RSS = BIT_ULL(15),
  187. VIRTCHNL2_CAP_FDIR = BIT_ULL(16),
  188. VIRTCHNL2_CAP_RX_FLEX_DESC = BIT_ULL(17),
  189. VIRTCHNL2_CAP_PTYPE = BIT_ULL(18),
  190. VIRTCHNL2_CAP_LOOPBACK = BIT_ULL(19),
  191. /* Other capability 20 is reserved */
  192. /* this must be the last capability */
  193. VIRTCHNL2_CAP_OEM = BIT_ULL(63),
  194. };
  195. /* underlying device type */
  196. enum virtchl2_device_type {
  197. VIRTCHNL2_MEV_DEVICE = 0,
  198. };
  199. /**
  200. * enum virtchnl2_txq_sched_mode - Transmit Queue Scheduling Modes.
  201. * @VIRTCHNL2_TXQ_SCHED_MODE_QUEUE: Queue mode is the legacy mode i.e. inorder
  202. * completions where descriptors and buffers
  203. * are completed at the same time.
  204. * @VIRTCHNL2_TXQ_SCHED_MODE_FLOW: Flow scheduling mode allows for out of order
  205. * packet processing where descriptors are
  206. * cleaned in order, but buffers can be
  207. * completed out of order.
  208. */
  209. enum virtchnl2_txq_sched_mode {
  210. VIRTCHNL2_TXQ_SCHED_MODE_QUEUE = 0,
  211. VIRTCHNL2_TXQ_SCHED_MODE_FLOW = 1,
  212. };
  213. /**
  214. * enum virtchnl2_rxq_flags - Receive Queue Feature flags.
  215. * @VIRTCHNL2_RXQ_RSC: Rx queue RSC flag.
  216. * @VIRTCHNL2_RXQ_HDR_SPLIT: Rx queue header split flag.
  217. * @VIRTCHNL2_RXQ_IMMEDIATE_WRITE_BACK: When set, packet descriptors are flushed
  218. * by hardware immediately after processing
  219. * each packet.
  220. * @VIRTCHNL2_RX_DESC_SIZE_16BYTE: Rx queue 16 byte descriptor size.
  221. * @VIRTCHNL2_RX_DESC_SIZE_32BYTE: Rx queue 32 byte descriptor size.
  222. */
  223. enum virtchnl2_rxq_flags {
  224. VIRTCHNL2_RXQ_RSC = BIT(0),
  225. VIRTCHNL2_RXQ_HDR_SPLIT = BIT(1),
  226. VIRTCHNL2_RXQ_IMMEDIATE_WRITE_BACK = BIT(2),
  227. VIRTCHNL2_RX_DESC_SIZE_16BYTE = BIT(3),
  228. VIRTCHNL2_RX_DESC_SIZE_32BYTE = BIT(4),
  229. };
  230. /* Type of RSS algorithm */
  231. enum virtchnl2_rss_alg {
  232. VIRTCHNL2_RSS_ALG_TOEPLITZ_ASYMMETRIC = 0,
  233. VIRTCHNL2_RSS_ALG_R_ASYMMETRIC = 1,
  234. VIRTCHNL2_RSS_ALG_TOEPLITZ_SYMMETRIC = 2,
  235. VIRTCHNL2_RSS_ALG_XOR_SYMMETRIC = 3,
  236. };
  237. /* Type of event */
  238. enum virtchnl2_event_codes {
  239. VIRTCHNL2_EVENT_UNKNOWN = 0,
  240. VIRTCHNL2_EVENT_LINK_CHANGE = 1,
  241. /* Event type 2, 3 are reserved */
  242. };
  243. /* Transmit and Receive queue types are valid in legacy as well as split queue
  244. * models. With Split Queue model, 2 additional types are introduced -
  245. * TX_COMPLETION and RX_BUFFER. In split queue model, receive corresponds to
  246. * the queue where hardware posts completions.
  247. */
  248. enum virtchnl2_queue_type {
  249. VIRTCHNL2_QUEUE_TYPE_TX = 0,
  250. VIRTCHNL2_QUEUE_TYPE_RX = 1,
  251. VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION = 2,
  252. VIRTCHNL2_QUEUE_TYPE_RX_BUFFER = 3,
  253. VIRTCHNL2_QUEUE_TYPE_CONFIG_TX = 4,
  254. VIRTCHNL2_QUEUE_TYPE_CONFIG_RX = 5,
  255. /* Queue types 6, 7, 8, 9 are reserved */
  256. VIRTCHNL2_QUEUE_TYPE_MBX_TX = 10,
  257. VIRTCHNL2_QUEUE_TYPE_MBX_RX = 11,
  258. };
  259. /* Interrupt throttling rate index */
  260. enum virtchnl2_itr_idx {
  261. VIRTCHNL2_ITR_IDX_0 = 0,
  262. VIRTCHNL2_ITR_IDX_1 = 1,
  263. };
  264. /**
  265. * enum virtchnl2_mac_addr_type - MAC address types.
  266. * @VIRTCHNL2_MAC_ADDR_PRIMARY: PF/VF driver should set this type for the
  267. * primary/device unicast MAC address filter for
  268. * VIRTCHNL2_OP_ADD_MAC_ADDR and
  269. * VIRTCHNL2_OP_DEL_MAC_ADDR. This allows for the
  270. * underlying control plane function to accurately
  271. * track the MAC address and for VM/function reset.
  272. *
  273. * @VIRTCHNL2_MAC_ADDR_EXTRA: PF/VF driver should set this type for any extra
  274. * unicast and/or multicast filters that are being
  275. * added/deleted via VIRTCHNL2_OP_ADD_MAC_ADDR or
  276. * VIRTCHNL2_OP_DEL_MAC_ADDR.
  277. */
  278. enum virtchnl2_mac_addr_type {
  279. VIRTCHNL2_MAC_ADDR_PRIMARY = 1,
  280. VIRTCHNL2_MAC_ADDR_EXTRA = 2,
  281. };
  282. /* Flags used for promiscuous mode */
  283. enum virtchnl2_promisc_flags {
  284. VIRTCHNL2_UNICAST_PROMISC = BIT(0),
  285. VIRTCHNL2_MULTICAST_PROMISC = BIT(1),
  286. };
  287. /* Protocol header type within a packet segment. A segment consists of one or
  288. * more protocol headers that make up a logical group of protocol headers. Each
  289. * logical group of protocol headers encapsulates or is encapsulated using/by
  290. * tunneling or encapsulation protocols for network virtualization.
  291. */
  292. enum virtchnl2_proto_hdr_type {
  293. /* VIRTCHNL2_PROTO_HDR_ANY is a mandatory protocol id */
  294. VIRTCHNL2_PROTO_HDR_ANY = 0,
  295. VIRTCHNL2_PROTO_HDR_PRE_MAC = 1,
  296. /* VIRTCHNL2_PROTO_HDR_MAC is a mandatory protocol id */
  297. VIRTCHNL2_PROTO_HDR_MAC = 2,
  298. VIRTCHNL2_PROTO_HDR_POST_MAC = 3,
  299. VIRTCHNL2_PROTO_HDR_ETHERTYPE = 4,
  300. VIRTCHNL2_PROTO_HDR_VLAN = 5,
  301. VIRTCHNL2_PROTO_HDR_SVLAN = 6,
  302. VIRTCHNL2_PROTO_HDR_CVLAN = 7,
  303. VIRTCHNL2_PROTO_HDR_MPLS = 8,
  304. VIRTCHNL2_PROTO_HDR_UMPLS = 9,
  305. VIRTCHNL2_PROTO_HDR_MMPLS = 10,
  306. VIRTCHNL2_PROTO_HDR_PTP = 11,
  307. VIRTCHNL2_PROTO_HDR_CTRL = 12,
  308. VIRTCHNL2_PROTO_HDR_LLDP = 13,
  309. VIRTCHNL2_PROTO_HDR_ARP = 14,
  310. VIRTCHNL2_PROTO_HDR_ECP = 15,
  311. VIRTCHNL2_PROTO_HDR_EAPOL = 16,
  312. VIRTCHNL2_PROTO_HDR_PPPOD = 17,
  313. VIRTCHNL2_PROTO_HDR_PPPOE = 18,
  314. /* VIRTCHNL2_PROTO_HDR_IPV4 is a mandatory protocol id */
  315. VIRTCHNL2_PROTO_HDR_IPV4 = 19,
  316. /* IPv4 and IPv6 Fragment header types are only associated to
  317. * VIRTCHNL2_PROTO_HDR_IPV4 and VIRTCHNL2_PROTO_HDR_IPV6 respectively,
  318. * cannot be used independently.
  319. */
  320. /* VIRTCHNL2_PROTO_HDR_IPV4_FRAG is a mandatory protocol id */
  321. VIRTCHNL2_PROTO_HDR_IPV4_FRAG = 20,
  322. /* VIRTCHNL2_PROTO_HDR_IPV6 is a mandatory protocol id */
  323. VIRTCHNL2_PROTO_HDR_IPV6 = 21,
  324. /* VIRTCHNL2_PROTO_HDR_IPV6_FRAG is a mandatory protocol id */
  325. VIRTCHNL2_PROTO_HDR_IPV6_FRAG = 22,
  326. VIRTCHNL2_PROTO_HDR_IPV6_EH = 23,
  327. /* VIRTCHNL2_PROTO_HDR_UDP is a mandatory protocol id */
  328. VIRTCHNL2_PROTO_HDR_UDP = 24,
  329. /* VIRTCHNL2_PROTO_HDR_TCP is a mandatory protocol id */
  330. VIRTCHNL2_PROTO_HDR_TCP = 25,
  331. /* VIRTCHNL2_PROTO_HDR_SCTP is a mandatory protocol id */
  332. VIRTCHNL2_PROTO_HDR_SCTP = 26,
  333. /* VIRTCHNL2_PROTO_HDR_ICMP is a mandatory protocol id */
  334. VIRTCHNL2_PROTO_HDR_ICMP = 27,
  335. /* VIRTCHNL2_PROTO_HDR_ICMPV6 is a mandatory protocol id */
  336. VIRTCHNL2_PROTO_HDR_ICMPV6 = 28,
  337. VIRTCHNL2_PROTO_HDR_IGMP = 29,
  338. VIRTCHNL2_PROTO_HDR_AH = 30,
  339. VIRTCHNL2_PROTO_HDR_ESP = 31,
  340. VIRTCHNL2_PROTO_HDR_IKE = 32,
  341. VIRTCHNL2_PROTO_HDR_NATT_KEEP = 33,
  342. /* VIRTCHNL2_PROTO_HDR_PAY is a mandatory protocol id */
  343. VIRTCHNL2_PROTO_HDR_PAY = 34,
  344. VIRTCHNL2_PROTO_HDR_L2TPV2 = 35,
  345. VIRTCHNL2_PROTO_HDR_L2TPV2_CONTROL = 36,
  346. VIRTCHNL2_PROTO_HDR_L2TPV3 = 37,
  347. VIRTCHNL2_PROTO_HDR_GTP = 38,
  348. VIRTCHNL2_PROTO_HDR_GTP_EH = 39,
  349. VIRTCHNL2_PROTO_HDR_GTPCV2 = 40,
  350. VIRTCHNL2_PROTO_HDR_GTPC_TEID = 41,
  351. VIRTCHNL2_PROTO_HDR_GTPU = 42,
  352. VIRTCHNL2_PROTO_HDR_GTPU_UL = 43,
  353. VIRTCHNL2_PROTO_HDR_GTPU_DL = 44,
  354. VIRTCHNL2_PROTO_HDR_ECPRI = 45,
  355. VIRTCHNL2_PROTO_HDR_VRRP = 46,
  356. VIRTCHNL2_PROTO_HDR_OSPF = 47,
  357. /* VIRTCHNL2_PROTO_HDR_TUN is a mandatory protocol id */
  358. VIRTCHNL2_PROTO_HDR_TUN = 48,
  359. VIRTCHNL2_PROTO_HDR_GRE = 49,
  360. VIRTCHNL2_PROTO_HDR_NVGRE = 50,
  361. VIRTCHNL2_PROTO_HDR_VXLAN = 51,
  362. VIRTCHNL2_PROTO_HDR_VXLAN_GPE = 52,
  363. VIRTCHNL2_PROTO_HDR_GENEVE = 53,
  364. VIRTCHNL2_PROTO_HDR_NSH = 54,
  365. VIRTCHNL2_PROTO_HDR_QUIC = 55,
  366. VIRTCHNL2_PROTO_HDR_PFCP = 56,
  367. VIRTCHNL2_PROTO_HDR_PFCP_NODE = 57,
  368. VIRTCHNL2_PROTO_HDR_PFCP_SESSION = 58,
  369. VIRTCHNL2_PROTO_HDR_RTP = 59,
  370. VIRTCHNL2_PROTO_HDR_ROCE = 60,
  371. VIRTCHNL2_PROTO_HDR_ROCEV1 = 61,
  372. VIRTCHNL2_PROTO_HDR_ROCEV2 = 62,
  373. /* Protocol ids up to 32767 are reserved.
  374. * 32768 - 65534 are used for user defined protocol ids.
  375. * VIRTCHNL2_PROTO_HDR_NO_PROTO is a mandatory protocol id.
  376. */
  377. VIRTCHNL2_PROTO_HDR_NO_PROTO = 65535,
  378. };
  379. enum virtchl2_version {
  380. VIRTCHNL2_VERSION_MINOR_0 = 0,
  381. VIRTCHNL2_VERSION_MAJOR_2 = 2,
  382. };
  383. /**
  384. * struct virtchnl2_edt_caps - Get EDT granularity and time horizon.
  385. * @tstamp_granularity_ns: Timestamp granularity in nanoseconds.
  386. * @time_horizon_ns: Total time window in nanoseconds.
  387. *
  388. * Associated with VIRTCHNL2_OP_GET_EDT_CAPS.
  389. */
  390. struct virtchnl2_edt_caps {
  391. __le64 tstamp_granularity_ns;
  392. __le64 time_horizon_ns;
  393. };
  394. VIRTCHNL2_CHECK_STRUCT_LEN(16, virtchnl2_edt_caps);
  395. /**
  396. * struct virtchnl2_version_info - Version information.
  397. * @major: Major version.
  398. * @minor: Minor version.
  399. *
  400. * PF/VF posts its version number to the CP. CP responds with its version number
  401. * in the same format, along with a return code.
  402. * If there is a major version mismatch, then the PF/VF cannot operate.
  403. * If there is a minor version mismatch, then the PF/VF can operate but should
  404. * add a warning to the system log.
  405. *
  406. * This version opcode MUST always be specified as == 1, regardless of other
  407. * changes in the API. The CP must always respond to this message without
  408. * error regardless of version mismatch.
  409. *
  410. * Associated with VIRTCHNL2_OP_VERSION.
  411. */
  412. struct virtchnl2_version_info {
  413. __le32 major;
  414. __le32 minor;
  415. };
  416. VIRTCHNL2_CHECK_STRUCT_LEN(8, virtchnl2_version_info);
  417. /**
  418. * struct virtchnl2_get_capabilities - Capabilities info.
  419. * @csum_caps: See enum virtchnl2_cap_txrx_csum.
  420. * @seg_caps: See enum virtchnl2_cap_seg.
  421. * @hsplit_caps: See enum virtchnl2_cap_rx_hsplit_at.
  422. * @rsc_caps: See enum virtchnl2_cap_rsc.
  423. * @rss_caps: See enum virtchnl2_cap_rss.
  424. * @other_caps: See enum virtchnl2_cap_other.
  425. * @mailbox_dyn_ctl: DYN_CTL register offset and vector id for mailbox
  426. * provided by CP.
  427. * @mailbox_vector_id: Mailbox vector id.
  428. * @num_allocated_vectors: Maximum number of allocated vectors for the device.
  429. * @max_rx_q: Maximum number of supported Rx queues.
  430. * @max_tx_q: Maximum number of supported Tx queues.
  431. * @max_rx_bufq: Maximum number of supported buffer queues.
  432. * @max_tx_complq: Maximum number of supported completion queues.
  433. * @max_sriov_vfs: The PF sends the maximum VFs it is requesting. The CP
  434. * responds with the maximum VFs granted.
  435. * @max_vports: Maximum number of vports that can be supported.
  436. * @default_num_vports: Default number of vports driver should allocate on load.
  437. * @max_tx_hdr_size: Max header length hardware can parse/checksum, in bytes.
  438. * @max_sg_bufs_per_tx_pkt: Max number of scatter gather buffers that can be
  439. * sent per transmit packet without needing to be
  440. * linearized.
  441. * @pad: Padding.
  442. * @reserved: Reserved.
  443. * @device_type: See enum virtchl2_device_type.
  444. * @min_sso_packet_len: Min packet length supported by device for single
  445. * segment offload.
  446. * @max_hdr_buf_per_lso: Max number of header buffers that can be used for
  447. * an LSO.
  448. * @pad1: Padding for future extensions.
  449. *
  450. * Dataplane driver sends this message to CP to negotiate capabilities and
  451. * provides a virtchnl2_get_capabilities structure with its desired
  452. * capabilities, max_sriov_vfs and num_allocated_vectors.
  453. * CP responds with a virtchnl2_get_capabilities structure updated
  454. * with allowed capabilities and the other fields as below.
  455. * If PF sets max_sriov_vfs as 0, CP will respond with max number of VFs
  456. * that can be created by this PF. For any other value 'n', CP responds
  457. * with max_sriov_vfs set to min(n, x) where x is the max number of VFs
  458. * allowed by CP's policy. max_sriov_vfs is not applicable for VFs.
  459. * If dataplane driver sets num_allocated_vectors as 0, CP will respond with 1
  460. * which is default vector associated with the default mailbox. For any other
  461. * value 'n', CP responds with a value <= n based on the CP's policy of
  462. * max number of vectors for a PF.
  463. * CP will respond with the vector ID of mailbox allocated to the PF in
  464. * mailbox_vector_id and the number of itr index registers in itr_idx_map.
  465. * It also responds with default number of vports that the dataplane driver
  466. * should comeup with in default_num_vports and maximum number of vports that
  467. * can be supported in max_vports.
  468. *
  469. * Associated with VIRTCHNL2_OP_GET_CAPS.
  470. */
  471. struct virtchnl2_get_capabilities {
  472. __le32 csum_caps;
  473. __le32 seg_caps;
  474. __le32 hsplit_caps;
  475. __le32 rsc_caps;
  476. __le64 rss_caps;
  477. __le64 other_caps;
  478. __le32 mailbox_dyn_ctl;
  479. __le16 mailbox_vector_id;
  480. __le16 num_allocated_vectors;
  481. __le16 max_rx_q;
  482. __le16 max_tx_q;
  483. __le16 max_rx_bufq;
  484. __le16 max_tx_complq;
  485. __le16 max_sriov_vfs;
  486. __le16 max_vports;
  487. __le16 default_num_vports;
  488. __le16 max_tx_hdr_size;
  489. u8 max_sg_bufs_per_tx_pkt;
  490. u8 pad[3];
  491. u8 reserved[4];
  492. __le32 device_type;
  493. u8 min_sso_packet_len;
  494. u8 max_hdr_buf_per_lso;
  495. u8 pad1[10];
  496. };
  497. VIRTCHNL2_CHECK_STRUCT_LEN(80, virtchnl2_get_capabilities);
  498. /**
  499. * struct virtchnl2_queue_reg_chunk - Single queue chunk.
  500. * @type: See enum virtchnl2_queue_type.
  501. * @start_queue_id: Start Queue ID.
  502. * @num_queues: Number of queues in the chunk.
  503. * @pad: Padding.
  504. * @qtail_reg_start: Queue tail register offset.
  505. * @qtail_reg_spacing: Queue tail register spacing.
  506. * @pad1: Padding for future extensions.
  507. */
  508. struct virtchnl2_queue_reg_chunk {
  509. __le32 type;
  510. __le32 start_queue_id;
  511. __le32 num_queues;
  512. __le32 pad;
  513. __le64 qtail_reg_start;
  514. __le32 qtail_reg_spacing;
  515. u8 pad1[4];
  516. };
  517. VIRTCHNL2_CHECK_STRUCT_LEN(32, virtchnl2_queue_reg_chunk);
  518. /**
  519. * struct virtchnl2_queue_reg_chunks - Specify several chunks of contiguous
  520. * queues.
  521. * @num_chunks: Number of chunks.
  522. * @pad: Padding.
  523. * @chunks: Chunks of queue info.
  524. */
  525. struct virtchnl2_queue_reg_chunks {
  526. __le16 num_chunks;
  527. u8 pad[6];
  528. struct virtchnl2_queue_reg_chunk chunks[] __counted_by_le(num_chunks);
  529. };
  530. VIRTCHNL2_CHECK_STRUCT_LEN(8, virtchnl2_queue_reg_chunks);
  531. /**
  532. * struct virtchnl2_create_vport - Create vport config info.
  533. * @vport_type: See enum virtchnl2_vport_type.
  534. * @txq_model: See virtchnl2_queue_model.
  535. * @rxq_model: See virtchnl2_queue_model.
  536. * @num_tx_q: Number of Tx queues.
  537. * @num_tx_complq: Valid only if txq_model is split queue.
  538. * @num_rx_q: Number of Rx queues.
  539. * @num_rx_bufq: Valid only if rxq_model is split queue.
  540. * @default_rx_q: Relative receive queue index to be used as default.
  541. * @vport_index: Used to align PF and CP in case of default multiple vports,
  542. * it is filled by the PF and CP returns the same value, to
  543. * enable the driver to support multiple asynchronous parallel
  544. * CREATE_VPORT requests and associate a response to a specific
  545. * request.
  546. * @max_mtu: Max MTU. CP populates this field on response.
  547. * @vport_id: Vport id. CP populates this field on response.
  548. * @default_mac_addr: Default MAC address.
  549. * @pad: Padding.
  550. * @rx_desc_ids: See VIRTCHNL2_RX_DESC_IDS definitions.
  551. * @tx_desc_ids: See VIRTCHNL2_TX_DESC_IDS definitions.
  552. * @pad1: Padding.
  553. * @rss_algorithm: RSS algorithm.
  554. * @rss_key_size: RSS key size.
  555. * @rss_lut_size: RSS LUT size.
  556. * @rx_split_pos: See enum virtchnl2_cap_rx_hsplit_at.
  557. * @pad2: Padding.
  558. * @chunks: Chunks of contiguous queues.
  559. *
  560. * PF sends this message to CP to create a vport by filling in required
  561. * fields of virtchnl2_create_vport structure.
  562. * CP responds with the updated virtchnl2_create_vport structure containing the
  563. * necessary fields followed by chunks which in turn will have an array of
  564. * num_chunks entries of virtchnl2_queue_chunk structures.
  565. *
  566. * Associated with VIRTCHNL2_OP_CREATE_VPORT.
  567. */
  568. struct virtchnl2_create_vport {
  569. __le16 vport_type;
  570. __le16 txq_model;
  571. __le16 rxq_model;
  572. __le16 num_tx_q;
  573. __le16 num_tx_complq;
  574. __le16 num_rx_q;
  575. __le16 num_rx_bufq;
  576. __le16 default_rx_q;
  577. __le16 vport_index;
  578. /* CP populates the following fields on response */
  579. __le16 max_mtu;
  580. __le32 vport_id;
  581. u8 default_mac_addr[ETH_ALEN];
  582. __le16 pad;
  583. __le64 rx_desc_ids;
  584. __le64 tx_desc_ids;
  585. u8 pad1[72];
  586. __le32 rss_algorithm;
  587. __le16 rss_key_size;
  588. __le16 rss_lut_size;
  589. __le32 rx_split_pos;
  590. u8 pad2[20];
  591. struct virtchnl2_queue_reg_chunks chunks;
  592. };
  593. VIRTCHNL2_CHECK_STRUCT_LEN(160, virtchnl2_create_vport);
  594. /**
  595. * struct virtchnl2_vport - Vport ID info.
  596. * @vport_id: Vport id.
  597. * @pad: Padding for future extensions.
  598. *
  599. * PF sends this message to CP to destroy, enable or disable a vport by filling
  600. * in the vport_id in virtchnl2_vport structure.
  601. * CP responds with the status of the requested operation.
  602. *
  603. * Associated with VIRTCHNL2_OP_DESTROY_VPORT, VIRTCHNL2_OP_ENABLE_VPORT,
  604. * VIRTCHNL2_OP_DISABLE_VPORT.
  605. */
  606. struct virtchnl2_vport {
  607. __le32 vport_id;
  608. u8 pad[4];
  609. };
  610. VIRTCHNL2_CHECK_STRUCT_LEN(8, virtchnl2_vport);
  611. /**
  612. * struct virtchnl2_txq_info - Transmit queue config info
  613. * @dma_ring_addr: DMA address.
  614. * @type: See enum virtchnl2_queue_type.
  615. * @queue_id: Queue ID.
  616. * @relative_queue_id: Valid only if queue model is split and type is transmit
  617. * queue. Used in many to one mapping of transmit queues to
  618. * completion queue.
  619. * @model: See enum virtchnl2_queue_model.
  620. * @sched_mode: See enum virtchnl2_txq_sched_mode.
  621. * @qflags: TX queue feature flags.
  622. * @ring_len: Ring length.
  623. * @tx_compl_queue_id: Valid only if queue model is split and type is transmit
  624. * queue.
  625. * @peer_type: Valid only if queue type is VIRTCHNL2_QUEUE_TYPE_MAILBOX_TX
  626. * @peer_rx_queue_id: Valid only if queue type is CONFIG_TX and used to deliver
  627. * messages for the respective CONFIG_TX queue.
  628. * @pad: Padding.
  629. * @egress_pasid: Egress PASID info.
  630. * @egress_hdr_pasid: Egress HDR passid.
  631. * @egress_buf_pasid: Egress buf passid.
  632. * @pad1: Padding for future extensions.
  633. */
  634. struct virtchnl2_txq_info {
  635. __le64 dma_ring_addr;
  636. __le32 type;
  637. __le32 queue_id;
  638. __le16 relative_queue_id;
  639. __le16 model;
  640. __le16 sched_mode;
  641. __le16 qflags;
  642. __le16 ring_len;
  643. __le16 tx_compl_queue_id;
  644. __le16 peer_type;
  645. __le16 peer_rx_queue_id;
  646. u8 pad[4];
  647. __le32 egress_pasid;
  648. __le32 egress_hdr_pasid;
  649. __le32 egress_buf_pasid;
  650. u8 pad1[8];
  651. };
  652. VIRTCHNL2_CHECK_STRUCT_LEN(56, virtchnl2_txq_info);
  653. /**
  654. * struct virtchnl2_config_tx_queues - TX queue config.
  655. * @vport_id: Vport id.
  656. * @num_qinfo: Number of virtchnl2_txq_info structs.
  657. * @pad: Padding.
  658. * @qinfo: Tx queues config info.
  659. *
  660. * PF sends this message to set up parameters for one or more transmit queues.
  661. * This message contains an array of num_qinfo instances of virtchnl2_txq_info
  662. * structures. CP configures requested queues and returns a status code. If
  663. * num_qinfo specified is greater than the number of queues associated with the
  664. * vport, an error is returned and no queues are configured.
  665. *
  666. * Associated with VIRTCHNL2_OP_CONFIG_TX_QUEUES.
  667. */
  668. struct virtchnl2_config_tx_queues {
  669. __le32 vport_id;
  670. __le16 num_qinfo;
  671. u8 pad[10];
  672. struct virtchnl2_txq_info qinfo[] __counted_by_le(num_qinfo);
  673. };
  674. VIRTCHNL2_CHECK_STRUCT_LEN(16, virtchnl2_config_tx_queues);
  675. /**
  676. * struct virtchnl2_rxq_info - Receive queue config info.
  677. * @desc_ids: See VIRTCHNL2_RX_DESC_IDS definitions.
  678. * @dma_ring_addr: See VIRTCHNL2_RX_DESC_IDS definitions.
  679. * @type: See enum virtchnl2_queue_type.
  680. * @queue_id: Queue id.
  681. * @model: See enum virtchnl2_queue_model.
  682. * @hdr_buffer_size: Header buffer size.
  683. * @data_buffer_size: Data buffer size.
  684. * @max_pkt_size: Max packet size.
  685. * @ring_len: Ring length.
  686. * @buffer_notif_stride: Buffer notification stride in units of 32-descriptors.
  687. * This field must be a power of 2.
  688. * @pad: Padding.
  689. * @dma_head_wb_addr: Applicable only for receive buffer queues.
  690. * @qflags: Applicable only for receive completion queues.
  691. * See enum virtchnl2_rxq_flags.
  692. * @rx_buffer_low_watermark: Rx buffer low watermark.
  693. * @rx_bufq1_id: Buffer queue index of the first buffer queue associated with
  694. * the Rx queue. Valid only in split queue model.
  695. * @rx_bufq2_id: Buffer queue index of the second buffer queue associated with
  696. * the Rx queue. Valid only in split queue model.
  697. * @bufq2_ena: It indicates if there is a second buffer, rx_bufq2_id is valid
  698. * only if this field is set.
  699. * @pad1: Padding.
  700. * @ingress_pasid: Ingress PASID.
  701. * @ingress_hdr_pasid: Ingress PASID header.
  702. * @ingress_buf_pasid: Ingress PASID buffer.
  703. * @pad2: Padding for future extensions.
  704. */
  705. struct virtchnl2_rxq_info {
  706. __le64 desc_ids;
  707. __le64 dma_ring_addr;
  708. __le32 type;
  709. __le32 queue_id;
  710. __le16 model;
  711. __le16 hdr_buffer_size;
  712. __le32 data_buffer_size;
  713. __le32 max_pkt_size;
  714. __le16 ring_len;
  715. u8 buffer_notif_stride;
  716. u8 pad;
  717. __le64 dma_head_wb_addr;
  718. __le16 qflags;
  719. __le16 rx_buffer_low_watermark;
  720. __le16 rx_bufq1_id;
  721. __le16 rx_bufq2_id;
  722. u8 bufq2_ena;
  723. u8 pad1[3];
  724. __le32 ingress_pasid;
  725. __le32 ingress_hdr_pasid;
  726. __le32 ingress_buf_pasid;
  727. u8 pad2[16];
  728. };
  729. VIRTCHNL2_CHECK_STRUCT_LEN(88, virtchnl2_rxq_info);
  730. /**
  731. * struct virtchnl2_config_rx_queues - Rx queues config.
  732. * @vport_id: Vport id.
  733. * @num_qinfo: Number of instances.
  734. * @pad: Padding.
  735. * @qinfo: Rx queues config info.
  736. *
  737. * PF sends this message to set up parameters for one or more receive queues.
  738. * This message contains an array of num_qinfo instances of virtchnl2_rxq_info
  739. * structures. CP configures requested queues and returns a status code.
  740. * If the number of queues specified is greater than the number of queues
  741. * associated with the vport, an error is returned and no queues are configured.
  742. *
  743. * Associated with VIRTCHNL2_OP_CONFIG_RX_QUEUES.
  744. */
  745. struct virtchnl2_config_rx_queues {
  746. __le32 vport_id;
  747. __le16 num_qinfo;
  748. u8 pad[18];
  749. struct virtchnl2_rxq_info qinfo[] __counted_by_le(num_qinfo);
  750. };
  751. VIRTCHNL2_CHECK_STRUCT_LEN(24, virtchnl2_config_rx_queues);
  752. /**
  753. * struct virtchnl2_add_queues - data for VIRTCHNL2_OP_ADD_QUEUES.
  754. * @vport_id: Vport id.
  755. * @num_tx_q: Number of Tx qieues.
  756. * @num_tx_complq: Number of Tx completion queues.
  757. * @num_rx_q: Number of Rx queues.
  758. * @num_rx_bufq: Number of Rx buffer queues.
  759. * @pad: Padding.
  760. * @chunks: Chunks of contiguous queues.
  761. *
  762. * PF sends this message to request additional transmit/receive queues beyond
  763. * the ones that were assigned via CREATE_VPORT request. virtchnl2_add_queues
  764. * structure is used to specify the number of each type of queues.
  765. * CP responds with the same structure with the actual number of queues assigned
  766. * followed by num_chunks of virtchnl2_queue_chunk structures.
  767. *
  768. * Associated with VIRTCHNL2_OP_ADD_QUEUES.
  769. */
  770. struct virtchnl2_add_queues {
  771. __le32 vport_id;
  772. __le16 num_tx_q;
  773. __le16 num_tx_complq;
  774. __le16 num_rx_q;
  775. __le16 num_rx_bufq;
  776. u8 pad[4];
  777. struct virtchnl2_queue_reg_chunks chunks;
  778. };
  779. VIRTCHNL2_CHECK_STRUCT_LEN(24, virtchnl2_add_queues);
  780. /**
  781. * struct virtchnl2_vector_chunk - Structure to specify a chunk of contiguous
  782. * interrupt vectors.
  783. * @start_vector_id: Start vector id.
  784. * @start_evv_id: Start EVV id.
  785. * @num_vectors: Number of vectors.
  786. * @pad: Padding.
  787. * @dynctl_reg_start: DYN_CTL register offset.
  788. * @dynctl_reg_spacing: register spacing between DYN_CTL registers of 2
  789. * consecutive vectors.
  790. * @itrn_reg_start: ITRN register offset.
  791. * @itrn_reg_spacing: Register spacing between dynctl registers of 2
  792. * consecutive vectors.
  793. * @itrn_index_spacing: Register spacing between itrn registers of the same
  794. * vector where n=0..2.
  795. * @pad1: Padding for future extensions.
  796. *
  797. * Register offsets and spacing provided by CP.
  798. * Dynamic control registers are used for enabling/disabling/re-enabling
  799. * interrupts and updating interrupt rates in the hotpath. Any changes
  800. * to interrupt rates in the dynamic control registers will be reflected
  801. * in the interrupt throttling rate registers.
  802. * itrn registers are used to update interrupt rates for specific
  803. * interrupt indices without modifying the state of the interrupt.
  804. */
  805. struct virtchnl2_vector_chunk {
  806. __le16 start_vector_id;
  807. __le16 start_evv_id;
  808. __le16 num_vectors;
  809. __le16 pad;
  810. __le32 dynctl_reg_start;
  811. __le32 dynctl_reg_spacing;
  812. __le32 itrn_reg_start;
  813. __le32 itrn_reg_spacing;
  814. __le32 itrn_index_spacing;
  815. u8 pad1[4];
  816. };
  817. VIRTCHNL2_CHECK_STRUCT_LEN(32, virtchnl2_vector_chunk);
  818. /**
  819. * struct virtchnl2_vector_chunks - chunks of contiguous interrupt vectors.
  820. * @num_vchunks: number of vector chunks.
  821. * @pad: Padding.
  822. * @vchunks: Chunks of contiguous vector info.
  823. *
  824. * PF sends virtchnl2_vector_chunks struct to specify the vectors it is giving
  825. * away. CP performs requested action and returns status.
  826. *
  827. * Associated with VIRTCHNL2_OP_DEALLOC_VECTORS.
  828. */
  829. struct virtchnl2_vector_chunks {
  830. __le16 num_vchunks;
  831. u8 pad[14];
  832. struct virtchnl2_vector_chunk vchunks[] __counted_by_le(num_vchunks);
  833. };
  834. VIRTCHNL2_CHECK_STRUCT_LEN(16, virtchnl2_vector_chunks);
  835. /**
  836. * struct virtchnl2_alloc_vectors - vector allocation info.
  837. * @num_vectors: Number of vectors.
  838. * @pad: Padding.
  839. * @vchunks: Chunks of contiguous vector info.
  840. *
  841. * PF sends this message to request additional interrupt vectors beyond the
  842. * ones that were assigned via GET_CAPS request. virtchnl2_alloc_vectors
  843. * structure is used to specify the number of vectors requested. CP responds
  844. * with the same structure with the actual number of vectors assigned followed
  845. * by virtchnl2_vector_chunks structure identifying the vector ids.
  846. *
  847. * Associated with VIRTCHNL2_OP_ALLOC_VECTORS.
  848. */
  849. struct virtchnl2_alloc_vectors {
  850. __le16 num_vectors;
  851. u8 pad[14];
  852. struct virtchnl2_vector_chunks vchunks;
  853. };
  854. VIRTCHNL2_CHECK_STRUCT_LEN(32, virtchnl2_alloc_vectors);
  855. /**
  856. * struct virtchnl2_rss_lut - RSS LUT info.
  857. * @vport_id: Vport id.
  858. * @lut_entries_start: Start of LUT entries.
  859. * @lut_entries: Number of LUT entrties.
  860. * @pad: Padding.
  861. * @lut: RSS lookup table.
  862. *
  863. * PF sends this message to get or set RSS lookup table. Only supported if
  864. * both PF and CP drivers set the VIRTCHNL2_CAP_RSS bit during configuration
  865. * negotiation.
  866. *
  867. * Associated with VIRTCHNL2_OP_GET_RSS_LUT and VIRTCHNL2_OP_SET_RSS_LUT.
  868. */
  869. struct virtchnl2_rss_lut {
  870. __le32 vport_id;
  871. __le16 lut_entries_start;
  872. __le16 lut_entries;
  873. u8 pad[4];
  874. __le32 lut[] __counted_by_le(lut_entries);
  875. };
  876. VIRTCHNL2_CHECK_STRUCT_LEN(12, virtchnl2_rss_lut);
  877. /**
  878. * struct virtchnl2_rss_hash - RSS hash info.
  879. * @ptype_groups: Packet type groups bitmap.
  880. * @vport_id: Vport id.
  881. * @pad: Padding for future extensions.
  882. *
  883. * PF sends these messages to get and set the hash filter enable bits for RSS.
  884. * By default, the CP sets these to all possible traffic types that the
  885. * hardware supports. The PF can query this value if it wants to change the
  886. * traffic types that are hashed by the hardware.
  887. * Only supported if both PF and CP drivers set the VIRTCHNL2_CAP_RSS bit
  888. * during configuration negotiation.
  889. *
  890. * Associated with VIRTCHNL2_OP_GET_RSS_HASH and VIRTCHNL2_OP_SET_RSS_HASH
  891. */
  892. struct virtchnl2_rss_hash {
  893. __le64 ptype_groups;
  894. __le32 vport_id;
  895. u8 pad[4];
  896. };
  897. VIRTCHNL2_CHECK_STRUCT_LEN(16, virtchnl2_rss_hash);
  898. /**
  899. * struct virtchnl2_sriov_vfs_info - VFs info.
  900. * @num_vfs: Number of VFs.
  901. * @pad: Padding for future extensions.
  902. *
  903. * This message is used to set number of SRIOV VFs to be created. The actual
  904. * allocation of resources for the VFs in terms of vport, queues and interrupts
  905. * is done by CP. When this call completes, the IDPF driver calls
  906. * pci_enable_sriov to let the OS instantiate the SRIOV PCIE devices.
  907. * The number of VFs set to 0 will destroy all the VFs of this function.
  908. *
  909. * Associated with VIRTCHNL2_OP_SET_SRIOV_VFS.
  910. */
  911. struct virtchnl2_sriov_vfs_info {
  912. __le16 num_vfs;
  913. __le16 pad;
  914. };
  915. VIRTCHNL2_CHECK_STRUCT_LEN(4, virtchnl2_sriov_vfs_info);
  916. /**
  917. * struct virtchnl2_ptype - Packet type info.
  918. * @ptype_id_10: 10-bit packet type.
  919. * @ptype_id_8: 8-bit packet type.
  920. * @proto_id_count: Number of protocol ids the packet supports, maximum of 32
  921. * protocol ids are supported.
  922. * @pad: Padding.
  923. * @proto_id: proto_id_count decides the allocation of protocol id array.
  924. * See enum virtchnl2_proto_hdr_type.
  925. *
  926. * Based on the descriptor type the PF supports, CP fills ptype_id_10 or
  927. * ptype_id_8 for flex and base descriptor respectively. If ptype_id_10 value
  928. * is set to 0xFFFF, PF should consider this ptype as dummy one and it is the
  929. * last ptype.
  930. */
  931. struct virtchnl2_ptype {
  932. __le16 ptype_id_10;
  933. u8 ptype_id_8;
  934. u8 proto_id_count;
  935. __le16 pad;
  936. __le16 proto_id[] __counted_by(proto_id_count);
  937. } __packed __aligned(2);
  938. VIRTCHNL2_CHECK_STRUCT_LEN(6, virtchnl2_ptype);
  939. /**
  940. * struct virtchnl2_get_ptype_info - Packet type info.
  941. * @start_ptype_id: Starting ptype ID.
  942. * @num_ptypes: Number of packet types from start_ptype_id.
  943. * @pad: Padding for future extensions.
  944. *
  945. * The total number of supported packet types is based on the descriptor type.
  946. * For the flex descriptor, it is 1024 (10-bit ptype), and for the base
  947. * descriptor, it is 256 (8-bit ptype). Send this message to the CP by
  948. * populating the 'start_ptype_id' and the 'num_ptypes'. CP responds with the
  949. * 'start_ptype_id', 'num_ptypes', and the array of ptype (virtchnl2_ptype) that
  950. * are added at the end of the 'virtchnl2_get_ptype_info' message (Note: There
  951. * is no specific field for the ptypes but are added at the end of the
  952. * ptype info message. PF/VF is expected to extract the ptypes accordingly.
  953. * Reason for doing this is because compiler doesn't allow nested flexible
  954. * array fields).
  955. *
  956. * If all the ptypes don't fit into one mailbox buffer, CP splits the
  957. * ptype info into multiple messages, where each message will have its own
  958. * 'start_ptype_id', 'num_ptypes', and the ptype array itself. When CP is done
  959. * updating all the ptype information extracted from the package (the number of
  960. * ptypes extracted might be less than what PF/VF expects), it will append a
  961. * dummy ptype (which has 'ptype_id_10' of 'struct virtchnl2_ptype' as 0xFFFF)
  962. * to the ptype array.
  963. *
  964. * PF/VF is expected to receive multiple VIRTCHNL2_OP_GET_PTYPE_INFO messages.
  965. *
  966. * Associated with VIRTCHNL2_OP_GET_PTYPE_INFO.
  967. */
  968. struct virtchnl2_get_ptype_info {
  969. __le16 start_ptype_id;
  970. __le16 num_ptypes;
  971. __le32 pad;
  972. };
  973. VIRTCHNL2_CHECK_STRUCT_LEN(8, virtchnl2_get_ptype_info);
  974. /**
  975. * struct virtchnl2_vport_stats - Vport statistics.
  976. * @vport_id: Vport id.
  977. * @pad: Padding.
  978. * @rx_bytes: Received bytes.
  979. * @rx_unicast: Received unicast packets.
  980. * @rx_multicast: Received multicast packets.
  981. * @rx_broadcast: Received broadcast packets.
  982. * @rx_discards: Discarded packets on receive.
  983. * @rx_errors: Receive errors.
  984. * @rx_unknown_protocol: Unlnown protocol.
  985. * @tx_bytes: Transmitted bytes.
  986. * @tx_unicast: Transmitted unicast packets.
  987. * @tx_multicast: Transmitted multicast packets.
  988. * @tx_broadcast: Transmitted broadcast packets.
  989. * @tx_discards: Discarded packets on transmit.
  990. * @tx_errors: Transmit errors.
  991. * @rx_invalid_frame_length: Packets with invalid frame length.
  992. * @rx_overflow_drop: Packets dropped on buffer overflow.
  993. *
  994. * PF/VF sends this message to CP to get the update stats by specifying the
  995. * vport_id. CP responds with stats in struct virtchnl2_vport_stats.
  996. *
  997. * Associated with VIRTCHNL2_OP_GET_STATS.
  998. */
  999. struct virtchnl2_vport_stats {
  1000. __le32 vport_id;
  1001. u8 pad[4];
  1002. __le64 rx_bytes;
  1003. __le64 rx_unicast;
  1004. __le64 rx_multicast;
  1005. __le64 rx_broadcast;
  1006. __le64 rx_discards;
  1007. __le64 rx_errors;
  1008. __le64 rx_unknown_protocol;
  1009. __le64 tx_bytes;
  1010. __le64 tx_unicast;
  1011. __le64 tx_multicast;
  1012. __le64 tx_broadcast;
  1013. __le64 tx_discards;
  1014. __le64 tx_errors;
  1015. __le64 rx_invalid_frame_length;
  1016. __le64 rx_overflow_drop;
  1017. };
  1018. VIRTCHNL2_CHECK_STRUCT_LEN(128, virtchnl2_vport_stats);
  1019. /**
  1020. * struct virtchnl2_event - Event info.
  1021. * @event: Event opcode. See enum virtchnl2_event_codes.
  1022. * @link_speed: Link_speed provided in Mbps.
  1023. * @vport_id: Vport ID.
  1024. * @link_status: Link status.
  1025. * @pad: Padding.
  1026. * @reserved: Reserved.
  1027. *
  1028. * CP sends this message to inform the PF/VF driver of events that may affect
  1029. * it. No direct response is expected from the driver, though it may generate
  1030. * other messages in response to this one.
  1031. *
  1032. * Associated with VIRTCHNL2_OP_EVENT.
  1033. */
  1034. struct virtchnl2_event {
  1035. __le32 event;
  1036. __le32 link_speed;
  1037. __le32 vport_id;
  1038. u8 link_status;
  1039. u8 pad;
  1040. __le16 reserved;
  1041. };
  1042. VIRTCHNL2_CHECK_STRUCT_LEN(16, virtchnl2_event);
  1043. /**
  1044. * struct virtchnl2_rss_key - RSS key info.
  1045. * @vport_id: Vport id.
  1046. * @key_len: Length of RSS key.
  1047. * @pad: Padding.
  1048. * @key_flex: RSS hash key, packed bytes.
  1049. * PF/VF sends this message to get or set RSS key. Only supported if both
  1050. * PF/VF and CP drivers set the VIRTCHNL2_CAP_RSS bit during configuration
  1051. * negotiation.
  1052. *
  1053. * Associated with VIRTCHNL2_OP_GET_RSS_KEY and VIRTCHNL2_OP_SET_RSS_KEY.
  1054. */
  1055. struct virtchnl2_rss_key {
  1056. __le32 vport_id;
  1057. __le16 key_len;
  1058. u8 pad;
  1059. u8 key_flex[] __counted_by_le(key_len);
  1060. } __packed;
  1061. VIRTCHNL2_CHECK_STRUCT_LEN(7, virtchnl2_rss_key);
  1062. /**
  1063. * struct virtchnl2_queue_chunk - chunk of contiguous queues
  1064. * @type: See enum virtchnl2_queue_type.
  1065. * @start_queue_id: Starting queue id.
  1066. * @num_queues: Number of queues.
  1067. * @pad: Padding for future extensions.
  1068. */
  1069. struct virtchnl2_queue_chunk {
  1070. __le32 type;
  1071. __le32 start_queue_id;
  1072. __le32 num_queues;
  1073. u8 pad[4];
  1074. };
  1075. VIRTCHNL2_CHECK_STRUCT_LEN(16, virtchnl2_queue_chunk);
  1076. /* struct virtchnl2_queue_chunks - chunks of contiguous queues
  1077. * @num_chunks: Number of chunks.
  1078. * @pad: Padding.
  1079. * @chunks: Chunks of contiguous queues info.
  1080. */
  1081. struct virtchnl2_queue_chunks {
  1082. __le16 num_chunks;
  1083. u8 pad[6];
  1084. struct virtchnl2_queue_chunk chunks[] __counted_by_le(num_chunks);
  1085. };
  1086. VIRTCHNL2_CHECK_STRUCT_LEN(8, virtchnl2_queue_chunks);
  1087. /**
  1088. * struct virtchnl2_del_ena_dis_queues - Enable/disable queues info.
  1089. * @vport_id: Vport id.
  1090. * @pad: Padding.
  1091. * @chunks: Chunks of contiguous queues info.
  1092. *
  1093. * PF sends these messages to enable, disable or delete queues specified in
  1094. * chunks. PF sends virtchnl2_del_ena_dis_queues struct to specify the queues
  1095. * to be enabled/disabled/deleted. Also applicable to single queue receive or
  1096. * transmit. CP performs requested action and returns status.
  1097. *
  1098. * Associated with VIRTCHNL2_OP_ENABLE_QUEUES, VIRTCHNL2_OP_DISABLE_QUEUES and
  1099. * VIRTCHNL2_OP_DISABLE_QUEUES.
  1100. */
  1101. struct virtchnl2_del_ena_dis_queues {
  1102. __le32 vport_id;
  1103. u8 pad[4];
  1104. struct virtchnl2_queue_chunks chunks;
  1105. };
  1106. VIRTCHNL2_CHECK_STRUCT_LEN(16, virtchnl2_del_ena_dis_queues);
  1107. /**
  1108. * struct virtchnl2_queue_vector - Queue to vector mapping.
  1109. * @queue_id: Queue id.
  1110. * @vector_id: Vector id.
  1111. * @pad: Padding.
  1112. * @itr_idx: See enum virtchnl2_itr_idx.
  1113. * @queue_type: See enum virtchnl2_queue_type.
  1114. * @pad1: Padding for future extensions.
  1115. */
  1116. struct virtchnl2_queue_vector {
  1117. __le32 queue_id;
  1118. __le16 vector_id;
  1119. u8 pad[2];
  1120. __le32 itr_idx;
  1121. __le32 queue_type;
  1122. u8 pad1[8];
  1123. };
  1124. VIRTCHNL2_CHECK_STRUCT_LEN(24, virtchnl2_queue_vector);
  1125. /**
  1126. * struct virtchnl2_queue_vector_maps - Map/unmap queues info.
  1127. * @vport_id: Vport id.
  1128. * @num_qv_maps: Number of queue vector maps.
  1129. * @pad: Padding.
  1130. * @qv_maps: Queue to vector maps.
  1131. *
  1132. * PF sends this message to map or unmap queues to vectors and interrupt
  1133. * throttling rate index registers. External data buffer contains
  1134. * virtchnl2_queue_vector_maps structure that contains num_qv_maps of
  1135. * virtchnl2_queue_vector structures. CP maps the requested queue vector maps
  1136. * after validating the queue and vector ids and returns a status code.
  1137. *
  1138. * Associated with VIRTCHNL2_OP_MAP_QUEUE_VECTOR and
  1139. * VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR.
  1140. */
  1141. struct virtchnl2_queue_vector_maps {
  1142. __le32 vport_id;
  1143. __le16 num_qv_maps;
  1144. u8 pad[10];
  1145. struct virtchnl2_queue_vector qv_maps[] __counted_by_le(num_qv_maps);
  1146. };
  1147. VIRTCHNL2_CHECK_STRUCT_LEN(16, virtchnl2_queue_vector_maps);
  1148. /**
  1149. * struct virtchnl2_loopback - Loopback info.
  1150. * @vport_id: Vport id.
  1151. * @enable: Enable/disable.
  1152. * @pad: Padding for future extensions.
  1153. *
  1154. * PF/VF sends this message to transition to/from the loopback state. Setting
  1155. * the 'enable' to 1 enables the loopback state and setting 'enable' to 0
  1156. * disables it. CP configures the state to loopback and returns status.
  1157. *
  1158. * Associated with VIRTCHNL2_OP_LOOPBACK.
  1159. */
  1160. struct virtchnl2_loopback {
  1161. __le32 vport_id;
  1162. u8 enable;
  1163. u8 pad[3];
  1164. };
  1165. VIRTCHNL2_CHECK_STRUCT_LEN(8, virtchnl2_loopback);
  1166. /* struct virtchnl2_mac_addr - MAC address info.
  1167. * @addr: MAC address.
  1168. * @type: MAC type. See enum virtchnl2_mac_addr_type.
  1169. * @pad: Padding for future extensions.
  1170. */
  1171. struct virtchnl2_mac_addr {
  1172. u8 addr[ETH_ALEN];
  1173. u8 type;
  1174. u8 pad;
  1175. };
  1176. VIRTCHNL2_CHECK_STRUCT_LEN(8, virtchnl2_mac_addr);
  1177. /**
  1178. * struct virtchnl2_mac_addr_list - List of MAC addresses.
  1179. * @vport_id: Vport id.
  1180. * @num_mac_addr: Number of MAC addresses.
  1181. * @pad: Padding.
  1182. * @mac_addr_list: List with MAC address info.
  1183. *
  1184. * PF/VF driver uses this structure to send list of MAC addresses to be
  1185. * added/deleted to the CP where as CP performs the action and returns the
  1186. * status.
  1187. *
  1188. * Associated with VIRTCHNL2_OP_ADD_MAC_ADDR and VIRTCHNL2_OP_DEL_MAC_ADDR.
  1189. */
  1190. struct virtchnl2_mac_addr_list {
  1191. __le32 vport_id;
  1192. __le16 num_mac_addr;
  1193. u8 pad[2];
  1194. struct virtchnl2_mac_addr mac_addr_list[] __counted_by_le(num_mac_addr);
  1195. };
  1196. VIRTCHNL2_CHECK_STRUCT_LEN(8, virtchnl2_mac_addr_list);
  1197. /**
  1198. * struct virtchnl2_promisc_info - Promisc type info.
  1199. * @vport_id: Vport id.
  1200. * @flags: See enum virtchnl2_promisc_flags.
  1201. * @pad: Padding for future extensions.
  1202. *
  1203. * PF/VF sends vport id and flags to the CP where as CP performs the action
  1204. * and returns the status.
  1205. *
  1206. * Associated with VIRTCHNL2_OP_CONFIG_PROMISCUOUS_MODE.
  1207. */
  1208. struct virtchnl2_promisc_info {
  1209. __le32 vport_id;
  1210. /* See VIRTCHNL2_PROMISC_FLAGS definitions */
  1211. __le16 flags;
  1212. u8 pad[2];
  1213. };
  1214. VIRTCHNL2_CHECK_STRUCT_LEN(8, virtchnl2_promisc_info);
  1215. #endif /* _VIRTCHNL_2_H_ */