gve_adminq.c 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506
  1. // SPDX-License-Identifier: (GPL-2.0 OR MIT)
  2. /* Google virtual Ethernet (gve) driver
  3. *
  4. * Copyright (C) 2015-2021 Google, Inc.
  5. */
  6. #include <linux/etherdevice.h>
  7. #include <linux/pci.h>
  8. #include "gve.h"
  9. #include "gve_adminq.h"
  10. #include "gve_register.h"
  11. #define GVE_MAX_ADMINQ_RELEASE_CHECK 500
  12. #define GVE_ADMINQ_SLEEP_LEN 20
  13. #define GVE_MAX_ADMINQ_EVENT_COUNTER_CHECK 100
  14. #define GVE_DEVICE_OPTION_ERROR_FMT "%s option error:\n" \
  15. "Expected: length=%d, feature_mask=%x.\n" \
  16. "Actual: length=%d, feature_mask=%x.\n"
  17. #define GVE_DEVICE_OPTION_TOO_BIG_FMT "Length of %s option larger than expected. Possible older version of guest driver.\n"
  18. static
  19. struct gve_device_option *gve_get_next_option(struct gve_device_descriptor *descriptor,
  20. struct gve_device_option *option)
  21. {
  22. void *option_end, *descriptor_end;
  23. option_end = (void *)(option + 1) + be16_to_cpu(option->option_length);
  24. descriptor_end = (void *)descriptor + be16_to_cpu(descriptor->total_length);
  25. return option_end > descriptor_end ? NULL : (struct gve_device_option *)option_end;
  26. }
  27. #define GVE_DEVICE_OPTION_NO_MIN_RING_SIZE 8
  28. static
  29. void gve_parse_device_option(struct gve_priv *priv,
  30. struct gve_device_descriptor *device_descriptor,
  31. struct gve_device_option *option,
  32. struct gve_device_option_gqi_rda **dev_op_gqi_rda,
  33. struct gve_device_option_gqi_qpl **dev_op_gqi_qpl,
  34. struct gve_device_option_dqo_rda **dev_op_dqo_rda,
  35. struct gve_device_option_jumbo_frames **dev_op_jumbo_frames,
  36. struct gve_device_option_dqo_qpl **dev_op_dqo_qpl,
  37. struct gve_device_option_buffer_sizes **dev_op_buffer_sizes,
  38. struct gve_device_option_flow_steering **dev_op_flow_steering,
  39. struct gve_device_option_rss_config **dev_op_rss_config,
  40. struct gve_device_option_modify_ring **dev_op_modify_ring)
  41. {
  42. u32 req_feat_mask = be32_to_cpu(option->required_features_mask);
  43. u16 option_length = be16_to_cpu(option->option_length);
  44. u16 option_id = be16_to_cpu(option->option_id);
  45. /* If the length or feature mask doesn't match, continue without
  46. * enabling the feature.
  47. */
  48. switch (option_id) {
  49. case GVE_DEV_OPT_ID_GQI_RAW_ADDRESSING:
  50. if (option_length != GVE_DEV_OPT_LEN_GQI_RAW_ADDRESSING ||
  51. req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_GQI_RAW_ADDRESSING) {
  52. dev_warn(&priv->pdev->dev, GVE_DEVICE_OPTION_ERROR_FMT,
  53. "Raw Addressing",
  54. GVE_DEV_OPT_LEN_GQI_RAW_ADDRESSING,
  55. GVE_DEV_OPT_REQ_FEAT_MASK_GQI_RAW_ADDRESSING,
  56. option_length, req_feat_mask);
  57. break;
  58. }
  59. dev_info(&priv->pdev->dev,
  60. "Gqi raw addressing device option enabled.\n");
  61. priv->queue_format = GVE_GQI_RDA_FORMAT;
  62. break;
  63. case GVE_DEV_OPT_ID_GQI_RDA:
  64. if (option_length < sizeof(**dev_op_gqi_rda) ||
  65. req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_GQI_RDA) {
  66. dev_warn(&priv->pdev->dev, GVE_DEVICE_OPTION_ERROR_FMT,
  67. "GQI RDA", (int)sizeof(**dev_op_gqi_rda),
  68. GVE_DEV_OPT_REQ_FEAT_MASK_GQI_RDA,
  69. option_length, req_feat_mask);
  70. break;
  71. }
  72. if (option_length > sizeof(**dev_op_gqi_rda)) {
  73. dev_warn(&priv->pdev->dev,
  74. GVE_DEVICE_OPTION_TOO_BIG_FMT, "GQI RDA");
  75. }
  76. *dev_op_gqi_rda = (void *)(option + 1);
  77. break;
  78. case GVE_DEV_OPT_ID_GQI_QPL:
  79. if (option_length < sizeof(**dev_op_gqi_qpl) ||
  80. req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_GQI_QPL) {
  81. dev_warn(&priv->pdev->dev, GVE_DEVICE_OPTION_ERROR_FMT,
  82. "GQI QPL", (int)sizeof(**dev_op_gqi_qpl),
  83. GVE_DEV_OPT_REQ_FEAT_MASK_GQI_QPL,
  84. option_length, req_feat_mask);
  85. break;
  86. }
  87. if (option_length > sizeof(**dev_op_gqi_qpl)) {
  88. dev_warn(&priv->pdev->dev,
  89. GVE_DEVICE_OPTION_TOO_BIG_FMT, "GQI QPL");
  90. }
  91. *dev_op_gqi_qpl = (void *)(option + 1);
  92. break;
  93. case GVE_DEV_OPT_ID_DQO_RDA:
  94. if (option_length < sizeof(**dev_op_dqo_rda) ||
  95. req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_DQO_RDA) {
  96. dev_warn(&priv->pdev->dev, GVE_DEVICE_OPTION_ERROR_FMT,
  97. "DQO RDA", (int)sizeof(**dev_op_dqo_rda),
  98. GVE_DEV_OPT_REQ_FEAT_MASK_DQO_RDA,
  99. option_length, req_feat_mask);
  100. break;
  101. }
  102. if (option_length > sizeof(**dev_op_dqo_rda)) {
  103. dev_warn(&priv->pdev->dev,
  104. GVE_DEVICE_OPTION_TOO_BIG_FMT, "DQO RDA");
  105. }
  106. *dev_op_dqo_rda = (void *)(option + 1);
  107. break;
  108. case GVE_DEV_OPT_ID_DQO_QPL:
  109. if (option_length < sizeof(**dev_op_dqo_qpl) ||
  110. req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_DQO_QPL) {
  111. dev_warn(&priv->pdev->dev, GVE_DEVICE_OPTION_ERROR_FMT,
  112. "DQO QPL", (int)sizeof(**dev_op_dqo_qpl),
  113. GVE_DEV_OPT_REQ_FEAT_MASK_DQO_QPL,
  114. option_length, req_feat_mask);
  115. break;
  116. }
  117. if (option_length > sizeof(**dev_op_dqo_qpl)) {
  118. dev_warn(&priv->pdev->dev,
  119. GVE_DEVICE_OPTION_TOO_BIG_FMT, "DQO QPL");
  120. }
  121. *dev_op_dqo_qpl = (void *)(option + 1);
  122. break;
  123. case GVE_DEV_OPT_ID_JUMBO_FRAMES:
  124. if (option_length < sizeof(**dev_op_jumbo_frames) ||
  125. req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_JUMBO_FRAMES) {
  126. dev_warn(&priv->pdev->dev, GVE_DEVICE_OPTION_ERROR_FMT,
  127. "Jumbo Frames",
  128. (int)sizeof(**dev_op_jumbo_frames),
  129. GVE_DEV_OPT_REQ_FEAT_MASK_JUMBO_FRAMES,
  130. option_length, req_feat_mask);
  131. break;
  132. }
  133. if (option_length > sizeof(**dev_op_jumbo_frames)) {
  134. dev_warn(&priv->pdev->dev,
  135. GVE_DEVICE_OPTION_TOO_BIG_FMT,
  136. "Jumbo Frames");
  137. }
  138. *dev_op_jumbo_frames = (void *)(option + 1);
  139. break;
  140. case GVE_DEV_OPT_ID_BUFFER_SIZES:
  141. if (option_length < sizeof(**dev_op_buffer_sizes) ||
  142. req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_BUFFER_SIZES) {
  143. dev_warn(&priv->pdev->dev, GVE_DEVICE_OPTION_ERROR_FMT,
  144. "Buffer Sizes",
  145. (int)sizeof(**dev_op_buffer_sizes),
  146. GVE_DEV_OPT_REQ_FEAT_MASK_BUFFER_SIZES,
  147. option_length, req_feat_mask);
  148. break;
  149. }
  150. if (option_length > sizeof(**dev_op_buffer_sizes))
  151. dev_warn(&priv->pdev->dev,
  152. GVE_DEVICE_OPTION_TOO_BIG_FMT,
  153. "Buffer Sizes");
  154. *dev_op_buffer_sizes = (void *)(option + 1);
  155. break;
  156. case GVE_DEV_OPT_ID_MODIFY_RING:
  157. if (option_length < GVE_DEVICE_OPTION_NO_MIN_RING_SIZE ||
  158. req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_MODIFY_RING) {
  159. dev_warn(&priv->pdev->dev, GVE_DEVICE_OPTION_ERROR_FMT,
  160. "Modify Ring", (int)sizeof(**dev_op_modify_ring),
  161. GVE_DEV_OPT_REQ_FEAT_MASK_MODIFY_RING,
  162. option_length, req_feat_mask);
  163. break;
  164. }
  165. if (option_length > sizeof(**dev_op_modify_ring)) {
  166. dev_warn(&priv->pdev->dev,
  167. GVE_DEVICE_OPTION_TOO_BIG_FMT, "Modify Ring");
  168. }
  169. *dev_op_modify_ring = (void *)(option + 1);
  170. /* device has not provided min ring size */
  171. if (option_length == GVE_DEVICE_OPTION_NO_MIN_RING_SIZE)
  172. priv->default_min_ring_size = true;
  173. break;
  174. case GVE_DEV_OPT_ID_FLOW_STEERING:
  175. if (option_length < sizeof(**dev_op_flow_steering) ||
  176. req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING) {
  177. dev_warn(&priv->pdev->dev, GVE_DEVICE_OPTION_ERROR_FMT,
  178. "Flow Steering",
  179. (int)sizeof(**dev_op_flow_steering),
  180. GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING,
  181. option_length, req_feat_mask);
  182. break;
  183. }
  184. if (option_length > sizeof(**dev_op_flow_steering))
  185. dev_warn(&priv->pdev->dev,
  186. GVE_DEVICE_OPTION_TOO_BIG_FMT,
  187. "Flow Steering");
  188. *dev_op_flow_steering = (void *)(option + 1);
  189. break;
  190. case GVE_DEV_OPT_ID_RSS_CONFIG:
  191. if (option_length < sizeof(**dev_op_rss_config) ||
  192. req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_RSS_CONFIG) {
  193. dev_warn(&priv->pdev->dev, GVE_DEVICE_OPTION_ERROR_FMT,
  194. "RSS config",
  195. (int)sizeof(**dev_op_rss_config),
  196. GVE_DEV_OPT_REQ_FEAT_MASK_RSS_CONFIG,
  197. option_length, req_feat_mask);
  198. break;
  199. }
  200. if (option_length > sizeof(**dev_op_rss_config))
  201. dev_warn(&priv->pdev->dev,
  202. GVE_DEVICE_OPTION_TOO_BIG_FMT,
  203. "RSS config");
  204. *dev_op_rss_config = (void *)(option + 1);
  205. break;
  206. default:
  207. /* If we don't recognize the option just continue
  208. * without doing anything.
  209. */
  210. dev_dbg(&priv->pdev->dev, "Unrecognized device option 0x%hx not enabled.\n",
  211. option_id);
  212. }
  213. }
  214. /* Process all device options for a given describe device call. */
  215. static int
  216. gve_process_device_options(struct gve_priv *priv,
  217. struct gve_device_descriptor *descriptor,
  218. struct gve_device_option_gqi_rda **dev_op_gqi_rda,
  219. struct gve_device_option_gqi_qpl **dev_op_gqi_qpl,
  220. struct gve_device_option_dqo_rda **dev_op_dqo_rda,
  221. struct gve_device_option_jumbo_frames **dev_op_jumbo_frames,
  222. struct gve_device_option_dqo_qpl **dev_op_dqo_qpl,
  223. struct gve_device_option_buffer_sizes **dev_op_buffer_sizes,
  224. struct gve_device_option_flow_steering **dev_op_flow_steering,
  225. struct gve_device_option_rss_config **dev_op_rss_config,
  226. struct gve_device_option_modify_ring **dev_op_modify_ring)
  227. {
  228. const int num_options = be16_to_cpu(descriptor->num_device_options);
  229. struct gve_device_option *dev_opt;
  230. int i;
  231. /* The options struct directly follows the device descriptor. */
  232. dev_opt = (void *)(descriptor + 1);
  233. for (i = 0; i < num_options; i++) {
  234. struct gve_device_option *next_opt;
  235. next_opt = gve_get_next_option(descriptor, dev_opt);
  236. if (!next_opt) {
  237. dev_err(&priv->dev->dev,
  238. "options exceed device_descriptor's total length.\n");
  239. return -EINVAL;
  240. }
  241. gve_parse_device_option(priv, descriptor, dev_opt,
  242. dev_op_gqi_rda, dev_op_gqi_qpl,
  243. dev_op_dqo_rda, dev_op_jumbo_frames,
  244. dev_op_dqo_qpl, dev_op_buffer_sizes,
  245. dev_op_flow_steering, dev_op_rss_config,
  246. dev_op_modify_ring);
  247. dev_opt = next_opt;
  248. }
  249. return 0;
  250. }
  251. int gve_adminq_alloc(struct device *dev, struct gve_priv *priv)
  252. {
  253. priv->adminq_pool = dma_pool_create("adminq_pool", dev,
  254. GVE_ADMINQ_BUFFER_SIZE, 0, 0);
  255. if (unlikely(!priv->adminq_pool))
  256. return -ENOMEM;
  257. priv->adminq = dma_pool_alloc(priv->adminq_pool, GFP_KERNEL,
  258. &priv->adminq_bus_addr);
  259. if (unlikely(!priv->adminq)) {
  260. dma_pool_destroy(priv->adminq_pool);
  261. return -ENOMEM;
  262. }
  263. priv->adminq_mask =
  264. (GVE_ADMINQ_BUFFER_SIZE / sizeof(union gve_adminq_command)) - 1;
  265. priv->adminq_prod_cnt = 0;
  266. priv->adminq_cmd_fail = 0;
  267. priv->adminq_timeouts = 0;
  268. priv->adminq_describe_device_cnt = 0;
  269. priv->adminq_cfg_device_resources_cnt = 0;
  270. priv->adminq_register_page_list_cnt = 0;
  271. priv->adminq_unregister_page_list_cnt = 0;
  272. priv->adminq_create_tx_queue_cnt = 0;
  273. priv->adminq_create_rx_queue_cnt = 0;
  274. priv->adminq_destroy_tx_queue_cnt = 0;
  275. priv->adminq_destroy_rx_queue_cnt = 0;
  276. priv->adminq_dcfg_device_resources_cnt = 0;
  277. priv->adminq_set_driver_parameter_cnt = 0;
  278. priv->adminq_report_stats_cnt = 0;
  279. priv->adminq_report_link_speed_cnt = 0;
  280. priv->adminq_get_ptype_map_cnt = 0;
  281. priv->adminq_query_flow_rules_cnt = 0;
  282. priv->adminq_cfg_flow_rule_cnt = 0;
  283. priv->adminq_cfg_rss_cnt = 0;
  284. priv->adminq_query_rss_cnt = 0;
  285. /* Setup Admin queue with the device */
  286. if (priv->pdev->revision < 0x1) {
  287. iowrite32be(priv->adminq_bus_addr / PAGE_SIZE,
  288. &priv->reg_bar0->adminq_pfn);
  289. } else {
  290. iowrite16be(GVE_ADMINQ_BUFFER_SIZE,
  291. &priv->reg_bar0->adminq_length);
  292. #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
  293. iowrite32be(priv->adminq_bus_addr >> 32,
  294. &priv->reg_bar0->adminq_base_address_hi);
  295. #endif
  296. iowrite32be(priv->adminq_bus_addr,
  297. &priv->reg_bar0->adminq_base_address_lo);
  298. iowrite32be(GVE_DRIVER_STATUS_RUN_MASK, &priv->reg_bar0->driver_status);
  299. }
  300. mutex_init(&priv->adminq_lock);
  301. gve_set_admin_queue_ok(priv);
  302. return 0;
  303. }
  304. void gve_adminq_release(struct gve_priv *priv)
  305. {
  306. int i = 0;
  307. /* Tell the device the adminq is leaving */
  308. if (priv->pdev->revision < 0x1) {
  309. iowrite32be(0x0, &priv->reg_bar0->adminq_pfn);
  310. while (ioread32be(&priv->reg_bar0->adminq_pfn)) {
  311. /* If this is reached the device is unrecoverable and still
  312. * holding memory. Continue looping to avoid memory corruption,
  313. * but WARN so it is visible what is going on.
  314. */
  315. if (i == GVE_MAX_ADMINQ_RELEASE_CHECK)
  316. WARN(1, "Unrecoverable platform error!");
  317. i++;
  318. msleep(GVE_ADMINQ_SLEEP_LEN);
  319. }
  320. } else {
  321. iowrite32be(GVE_DRIVER_STATUS_RESET_MASK, &priv->reg_bar0->driver_status);
  322. while (!(ioread32be(&priv->reg_bar0->device_status)
  323. & GVE_DEVICE_STATUS_DEVICE_IS_RESET)) {
  324. if (i == GVE_MAX_ADMINQ_RELEASE_CHECK)
  325. WARN(1, "Unrecoverable platform error!");
  326. i++;
  327. msleep(GVE_ADMINQ_SLEEP_LEN);
  328. }
  329. }
  330. gve_clear_device_rings_ok(priv);
  331. gve_clear_device_resources_ok(priv);
  332. gve_clear_admin_queue_ok(priv);
  333. }
  334. void gve_adminq_free(struct device *dev, struct gve_priv *priv)
  335. {
  336. if (!gve_get_admin_queue_ok(priv))
  337. return;
  338. gve_adminq_release(priv);
  339. dma_pool_free(priv->adminq_pool, priv->adminq, priv->adminq_bus_addr);
  340. dma_pool_destroy(priv->adminq_pool);
  341. gve_clear_admin_queue_ok(priv);
  342. }
  343. static void gve_adminq_kick_cmd(struct gve_priv *priv, u32 prod_cnt)
  344. {
  345. iowrite32be(prod_cnt, &priv->reg_bar0->adminq_doorbell);
  346. }
  347. static bool gve_adminq_wait_for_cmd(struct gve_priv *priv, u32 prod_cnt)
  348. {
  349. int i;
  350. for (i = 0; i < GVE_MAX_ADMINQ_EVENT_COUNTER_CHECK; i++) {
  351. if (ioread32be(&priv->reg_bar0->adminq_event_counter)
  352. == prod_cnt)
  353. return true;
  354. msleep(GVE_ADMINQ_SLEEP_LEN);
  355. }
  356. return false;
  357. }
  358. static int gve_adminq_parse_err(struct gve_priv *priv, u32 status)
  359. {
  360. if (status != GVE_ADMINQ_COMMAND_PASSED &&
  361. status != GVE_ADMINQ_COMMAND_UNSET) {
  362. dev_err(&priv->pdev->dev, "AQ command failed with status %d\n", status);
  363. priv->adminq_cmd_fail++;
  364. }
  365. switch (status) {
  366. case GVE_ADMINQ_COMMAND_PASSED:
  367. return 0;
  368. case GVE_ADMINQ_COMMAND_UNSET:
  369. dev_err(&priv->pdev->dev, "parse_aq_err: err and status both unset, this should not be possible.\n");
  370. return -EINVAL;
  371. case GVE_ADMINQ_COMMAND_ERROR_ABORTED:
  372. case GVE_ADMINQ_COMMAND_ERROR_CANCELLED:
  373. case GVE_ADMINQ_COMMAND_ERROR_DATALOSS:
  374. case GVE_ADMINQ_COMMAND_ERROR_FAILED_PRECONDITION:
  375. case GVE_ADMINQ_COMMAND_ERROR_UNAVAILABLE:
  376. return -EAGAIN;
  377. case GVE_ADMINQ_COMMAND_ERROR_ALREADY_EXISTS:
  378. case GVE_ADMINQ_COMMAND_ERROR_INTERNAL_ERROR:
  379. case GVE_ADMINQ_COMMAND_ERROR_INVALID_ARGUMENT:
  380. case GVE_ADMINQ_COMMAND_ERROR_NOT_FOUND:
  381. case GVE_ADMINQ_COMMAND_ERROR_OUT_OF_RANGE:
  382. case GVE_ADMINQ_COMMAND_ERROR_UNKNOWN_ERROR:
  383. return -EINVAL;
  384. case GVE_ADMINQ_COMMAND_ERROR_DEADLINE_EXCEEDED:
  385. return -ETIME;
  386. case GVE_ADMINQ_COMMAND_ERROR_PERMISSION_DENIED:
  387. case GVE_ADMINQ_COMMAND_ERROR_UNAUTHENTICATED:
  388. return -EACCES;
  389. case GVE_ADMINQ_COMMAND_ERROR_RESOURCE_EXHAUSTED:
  390. return -ENOMEM;
  391. case GVE_ADMINQ_COMMAND_ERROR_UNIMPLEMENTED:
  392. return -EOPNOTSUPP;
  393. default:
  394. dev_err(&priv->pdev->dev, "parse_aq_err: unknown status code %d\n", status);
  395. return -EINVAL;
  396. }
  397. }
  398. /* Flushes all AQ commands currently queued and waits for them to complete.
  399. * If there are failures, it will return the first error.
  400. */
  401. static int gve_adminq_kick_and_wait(struct gve_priv *priv)
  402. {
  403. int tail, head;
  404. int i;
  405. tail = ioread32be(&priv->reg_bar0->adminq_event_counter);
  406. head = priv->adminq_prod_cnt;
  407. gve_adminq_kick_cmd(priv, head);
  408. if (!gve_adminq_wait_for_cmd(priv, head)) {
  409. dev_err(&priv->pdev->dev, "AQ commands timed out, need to reset AQ\n");
  410. priv->adminq_timeouts++;
  411. return -ENOTRECOVERABLE;
  412. }
  413. for (i = tail; i < head; i++) {
  414. union gve_adminq_command *cmd;
  415. u32 status, err;
  416. cmd = &priv->adminq[i & priv->adminq_mask];
  417. status = be32_to_cpu(READ_ONCE(cmd->status));
  418. err = gve_adminq_parse_err(priv, status);
  419. if (err)
  420. // Return the first error if we failed.
  421. return err;
  422. }
  423. return 0;
  424. }
  425. /* This function is not threadsafe - the caller is responsible for any
  426. * necessary locks.
  427. */
  428. static int gve_adminq_issue_cmd(struct gve_priv *priv,
  429. union gve_adminq_command *cmd_orig)
  430. {
  431. union gve_adminq_command *cmd;
  432. u32 opcode;
  433. u32 tail;
  434. tail = ioread32be(&priv->reg_bar0->adminq_event_counter);
  435. // Check if next command will overflow the buffer.
  436. if (((priv->adminq_prod_cnt + 1) & priv->adminq_mask) ==
  437. (tail & priv->adminq_mask)) {
  438. int err;
  439. // Flush existing commands to make room.
  440. err = gve_adminq_kick_and_wait(priv);
  441. if (err)
  442. return err;
  443. // Retry.
  444. tail = ioread32be(&priv->reg_bar0->adminq_event_counter);
  445. if (((priv->adminq_prod_cnt + 1) & priv->adminq_mask) ==
  446. (tail & priv->adminq_mask)) {
  447. // This should never happen. We just flushed the
  448. // command queue so there should be enough space.
  449. return -ENOMEM;
  450. }
  451. }
  452. cmd = &priv->adminq[priv->adminq_prod_cnt & priv->adminq_mask];
  453. priv->adminq_prod_cnt++;
  454. memcpy(cmd, cmd_orig, sizeof(*cmd_orig));
  455. opcode = be32_to_cpu(READ_ONCE(cmd->opcode));
  456. if (opcode == GVE_ADMINQ_EXTENDED_COMMAND)
  457. opcode = be32_to_cpu(cmd->extended_command.inner_opcode);
  458. switch (opcode) {
  459. case GVE_ADMINQ_DESCRIBE_DEVICE:
  460. priv->adminq_describe_device_cnt++;
  461. break;
  462. case GVE_ADMINQ_CONFIGURE_DEVICE_RESOURCES:
  463. priv->adminq_cfg_device_resources_cnt++;
  464. break;
  465. case GVE_ADMINQ_REGISTER_PAGE_LIST:
  466. priv->adminq_register_page_list_cnt++;
  467. break;
  468. case GVE_ADMINQ_UNREGISTER_PAGE_LIST:
  469. priv->adminq_unregister_page_list_cnt++;
  470. break;
  471. case GVE_ADMINQ_CREATE_TX_QUEUE:
  472. priv->adminq_create_tx_queue_cnt++;
  473. break;
  474. case GVE_ADMINQ_CREATE_RX_QUEUE:
  475. priv->adminq_create_rx_queue_cnt++;
  476. break;
  477. case GVE_ADMINQ_DESTROY_TX_QUEUE:
  478. priv->adminq_destroy_tx_queue_cnt++;
  479. break;
  480. case GVE_ADMINQ_DESTROY_RX_QUEUE:
  481. priv->adminq_destroy_rx_queue_cnt++;
  482. break;
  483. case GVE_ADMINQ_DECONFIGURE_DEVICE_RESOURCES:
  484. priv->adminq_dcfg_device_resources_cnt++;
  485. break;
  486. case GVE_ADMINQ_SET_DRIVER_PARAMETER:
  487. priv->adminq_set_driver_parameter_cnt++;
  488. break;
  489. case GVE_ADMINQ_REPORT_STATS:
  490. priv->adminq_report_stats_cnt++;
  491. break;
  492. case GVE_ADMINQ_REPORT_LINK_SPEED:
  493. priv->adminq_report_link_speed_cnt++;
  494. break;
  495. case GVE_ADMINQ_GET_PTYPE_MAP:
  496. priv->adminq_get_ptype_map_cnt++;
  497. break;
  498. case GVE_ADMINQ_VERIFY_DRIVER_COMPATIBILITY:
  499. priv->adminq_verify_driver_compatibility_cnt++;
  500. break;
  501. case GVE_ADMINQ_QUERY_FLOW_RULES:
  502. priv->adminq_query_flow_rules_cnt++;
  503. break;
  504. case GVE_ADMINQ_CONFIGURE_FLOW_RULE:
  505. priv->adminq_cfg_flow_rule_cnt++;
  506. break;
  507. case GVE_ADMINQ_CONFIGURE_RSS:
  508. priv->adminq_cfg_rss_cnt++;
  509. break;
  510. case GVE_ADMINQ_QUERY_RSS:
  511. priv->adminq_query_rss_cnt++;
  512. break;
  513. default:
  514. dev_err(&priv->pdev->dev, "unknown AQ command opcode %d\n", opcode);
  515. return -EINVAL;
  516. }
  517. return 0;
  518. }
  519. static int gve_adminq_execute_cmd(struct gve_priv *priv,
  520. union gve_adminq_command *cmd_orig)
  521. {
  522. u32 tail, head;
  523. int err;
  524. mutex_lock(&priv->adminq_lock);
  525. tail = ioread32be(&priv->reg_bar0->adminq_event_counter);
  526. head = priv->adminq_prod_cnt;
  527. if (tail != head) {
  528. err = -EINVAL;
  529. goto out;
  530. }
  531. err = gve_adminq_issue_cmd(priv, cmd_orig);
  532. if (err)
  533. goto out;
  534. err = gve_adminq_kick_and_wait(priv);
  535. out:
  536. mutex_unlock(&priv->adminq_lock);
  537. return err;
  538. }
  539. static int gve_adminq_execute_extended_cmd(struct gve_priv *priv, u32 opcode,
  540. size_t cmd_size, void *cmd_orig)
  541. {
  542. union gve_adminq_command cmd;
  543. dma_addr_t inner_cmd_bus;
  544. void *inner_cmd;
  545. int err;
  546. inner_cmd = dma_alloc_coherent(&priv->pdev->dev, cmd_size,
  547. &inner_cmd_bus, GFP_KERNEL);
  548. if (!inner_cmd)
  549. return -ENOMEM;
  550. memcpy(inner_cmd, cmd_orig, cmd_size);
  551. memset(&cmd, 0, sizeof(cmd));
  552. cmd.opcode = cpu_to_be32(GVE_ADMINQ_EXTENDED_COMMAND);
  553. cmd.extended_command = (struct gve_adminq_extended_command) {
  554. .inner_opcode = cpu_to_be32(opcode),
  555. .inner_length = cpu_to_be32(cmd_size),
  556. .inner_command_addr = cpu_to_be64(inner_cmd_bus),
  557. };
  558. err = gve_adminq_execute_cmd(priv, &cmd);
  559. dma_free_coherent(&priv->pdev->dev, cmd_size, inner_cmd, inner_cmd_bus);
  560. return err;
  561. }
  562. /* The device specifies that the management vector can either be the first irq
  563. * or the last irq. ntfy_blk_msix_base_idx indicates the first irq assigned to
  564. * the ntfy blks. It if is 0 then the management vector is last, if it is 1 then
  565. * the management vector is first.
  566. *
  567. * gve arranges the msix vectors so that the management vector is last.
  568. */
  569. #define GVE_NTFY_BLK_BASE_MSIX_IDX 0
  570. int gve_adminq_configure_device_resources(struct gve_priv *priv,
  571. dma_addr_t counter_array_bus_addr,
  572. u32 num_counters,
  573. dma_addr_t db_array_bus_addr,
  574. u32 num_ntfy_blks)
  575. {
  576. union gve_adminq_command cmd;
  577. memset(&cmd, 0, sizeof(cmd));
  578. cmd.opcode = cpu_to_be32(GVE_ADMINQ_CONFIGURE_DEVICE_RESOURCES);
  579. cmd.configure_device_resources =
  580. (struct gve_adminq_configure_device_resources) {
  581. .counter_array = cpu_to_be64(counter_array_bus_addr),
  582. .num_counters = cpu_to_be32(num_counters),
  583. .irq_db_addr = cpu_to_be64(db_array_bus_addr),
  584. .num_irq_dbs = cpu_to_be32(num_ntfy_blks),
  585. .irq_db_stride = cpu_to_be32(sizeof(*priv->irq_db_indices)),
  586. .ntfy_blk_msix_base_idx =
  587. cpu_to_be32(GVE_NTFY_BLK_BASE_MSIX_IDX),
  588. .queue_format = priv->queue_format,
  589. };
  590. return gve_adminq_execute_cmd(priv, &cmd);
  591. }
  592. int gve_adminq_deconfigure_device_resources(struct gve_priv *priv)
  593. {
  594. union gve_adminq_command cmd;
  595. memset(&cmd, 0, sizeof(cmd));
  596. cmd.opcode = cpu_to_be32(GVE_ADMINQ_DECONFIGURE_DEVICE_RESOURCES);
  597. return gve_adminq_execute_cmd(priv, &cmd);
  598. }
  599. static int gve_adminq_create_tx_queue(struct gve_priv *priv, u32 queue_index)
  600. {
  601. struct gve_tx_ring *tx = &priv->tx[queue_index];
  602. union gve_adminq_command cmd;
  603. memset(&cmd, 0, sizeof(cmd));
  604. cmd.opcode = cpu_to_be32(GVE_ADMINQ_CREATE_TX_QUEUE);
  605. cmd.create_tx_queue = (struct gve_adminq_create_tx_queue) {
  606. .queue_id = cpu_to_be32(queue_index),
  607. .queue_resources_addr =
  608. cpu_to_be64(tx->q_resources_bus),
  609. .tx_ring_addr = cpu_to_be64(tx->bus),
  610. .ntfy_id = cpu_to_be32(tx->ntfy_id),
  611. .tx_ring_size = cpu_to_be16(priv->tx_desc_cnt),
  612. };
  613. if (gve_is_gqi(priv)) {
  614. u32 qpl_id = priv->queue_format == GVE_GQI_RDA_FORMAT ?
  615. GVE_RAW_ADDRESSING_QPL_ID : tx->tx_fifo.qpl->id;
  616. cmd.create_tx_queue.queue_page_list_id = cpu_to_be32(qpl_id);
  617. } else {
  618. u32 qpl_id = 0;
  619. if (priv->queue_format == GVE_DQO_RDA_FORMAT)
  620. qpl_id = GVE_RAW_ADDRESSING_QPL_ID;
  621. else
  622. qpl_id = tx->dqo.qpl->id;
  623. cmd.create_tx_queue.queue_page_list_id = cpu_to_be32(qpl_id);
  624. cmd.create_tx_queue.tx_comp_ring_addr =
  625. cpu_to_be64(tx->complq_bus_dqo);
  626. cmd.create_tx_queue.tx_comp_ring_size =
  627. cpu_to_be16(priv->tx_desc_cnt);
  628. }
  629. return gve_adminq_issue_cmd(priv, &cmd);
  630. }
  631. int gve_adminq_create_tx_queues(struct gve_priv *priv, u32 start_id, u32 num_queues)
  632. {
  633. int err;
  634. int i;
  635. for (i = start_id; i < start_id + num_queues; i++) {
  636. err = gve_adminq_create_tx_queue(priv, i);
  637. if (err)
  638. return err;
  639. }
  640. return gve_adminq_kick_and_wait(priv);
  641. }
  642. static void gve_adminq_get_create_rx_queue_cmd(struct gve_priv *priv,
  643. union gve_adminq_command *cmd,
  644. u32 queue_index)
  645. {
  646. struct gve_rx_ring *rx = &priv->rx[queue_index];
  647. memset(cmd, 0, sizeof(*cmd));
  648. cmd->opcode = cpu_to_be32(GVE_ADMINQ_CREATE_RX_QUEUE);
  649. cmd->create_rx_queue = (struct gve_adminq_create_rx_queue) {
  650. .queue_id = cpu_to_be32(queue_index),
  651. .ntfy_id = cpu_to_be32(rx->ntfy_id),
  652. .queue_resources_addr = cpu_to_be64(rx->q_resources_bus),
  653. .rx_ring_size = cpu_to_be16(priv->rx_desc_cnt),
  654. };
  655. if (gve_is_gqi(priv)) {
  656. u32 qpl_id = priv->queue_format == GVE_GQI_RDA_FORMAT ?
  657. GVE_RAW_ADDRESSING_QPL_ID : rx->data.qpl->id;
  658. cmd->create_rx_queue.rx_desc_ring_addr =
  659. cpu_to_be64(rx->desc.bus);
  660. cmd->create_rx_queue.rx_data_ring_addr =
  661. cpu_to_be64(rx->data.data_bus);
  662. cmd->create_rx_queue.index = cpu_to_be32(queue_index);
  663. cmd->create_rx_queue.queue_page_list_id = cpu_to_be32(qpl_id);
  664. cmd->create_rx_queue.packet_buffer_size = cpu_to_be16(rx->packet_buffer_size);
  665. } else {
  666. u32 qpl_id = 0;
  667. if (priv->queue_format == GVE_DQO_RDA_FORMAT)
  668. qpl_id = GVE_RAW_ADDRESSING_QPL_ID;
  669. else
  670. qpl_id = rx->dqo.qpl->id;
  671. cmd->create_rx_queue.queue_page_list_id = cpu_to_be32(qpl_id);
  672. cmd->create_rx_queue.rx_desc_ring_addr =
  673. cpu_to_be64(rx->dqo.complq.bus);
  674. cmd->create_rx_queue.rx_data_ring_addr =
  675. cpu_to_be64(rx->dqo.bufq.bus);
  676. cmd->create_rx_queue.packet_buffer_size =
  677. cpu_to_be16(priv->data_buffer_size_dqo);
  678. cmd->create_rx_queue.rx_buff_ring_size =
  679. cpu_to_be16(priv->rx_desc_cnt);
  680. cmd->create_rx_queue.enable_rsc =
  681. !!(priv->dev->features & NETIF_F_LRO);
  682. if (priv->header_split_enabled)
  683. cmd->create_rx_queue.header_buffer_size =
  684. cpu_to_be16(priv->header_buf_size);
  685. }
  686. }
  687. static int gve_adminq_create_rx_queue(struct gve_priv *priv, u32 queue_index)
  688. {
  689. union gve_adminq_command cmd;
  690. gve_adminq_get_create_rx_queue_cmd(priv, &cmd, queue_index);
  691. return gve_adminq_issue_cmd(priv, &cmd);
  692. }
  693. /* Unlike gve_adminq_create_rx_queue, this actually rings the doorbell */
  694. int gve_adminq_create_single_rx_queue(struct gve_priv *priv, u32 queue_index)
  695. {
  696. union gve_adminq_command cmd;
  697. gve_adminq_get_create_rx_queue_cmd(priv, &cmd, queue_index);
  698. return gve_adminq_execute_cmd(priv, &cmd);
  699. }
  700. int gve_adminq_create_rx_queues(struct gve_priv *priv, u32 num_queues)
  701. {
  702. int err;
  703. int i;
  704. for (i = 0; i < num_queues; i++) {
  705. err = gve_adminq_create_rx_queue(priv, i);
  706. if (err)
  707. return err;
  708. }
  709. return gve_adminq_kick_and_wait(priv);
  710. }
  711. static int gve_adminq_destroy_tx_queue(struct gve_priv *priv, u32 queue_index)
  712. {
  713. union gve_adminq_command cmd;
  714. int err;
  715. memset(&cmd, 0, sizeof(cmd));
  716. cmd.opcode = cpu_to_be32(GVE_ADMINQ_DESTROY_TX_QUEUE);
  717. cmd.destroy_tx_queue = (struct gve_adminq_destroy_tx_queue) {
  718. .queue_id = cpu_to_be32(queue_index),
  719. };
  720. err = gve_adminq_issue_cmd(priv, &cmd);
  721. if (err)
  722. return err;
  723. return 0;
  724. }
  725. int gve_adminq_destroy_tx_queues(struct gve_priv *priv, u32 start_id, u32 num_queues)
  726. {
  727. int err;
  728. int i;
  729. for (i = start_id; i < start_id + num_queues; i++) {
  730. err = gve_adminq_destroy_tx_queue(priv, i);
  731. if (err)
  732. return err;
  733. }
  734. return gve_adminq_kick_and_wait(priv);
  735. }
  736. static void gve_adminq_make_destroy_rx_queue_cmd(union gve_adminq_command *cmd,
  737. u32 queue_index)
  738. {
  739. memset(cmd, 0, sizeof(*cmd));
  740. cmd->opcode = cpu_to_be32(GVE_ADMINQ_DESTROY_RX_QUEUE);
  741. cmd->destroy_rx_queue = (struct gve_adminq_destroy_rx_queue) {
  742. .queue_id = cpu_to_be32(queue_index),
  743. };
  744. }
  745. static int gve_adminq_destroy_rx_queue(struct gve_priv *priv, u32 queue_index)
  746. {
  747. union gve_adminq_command cmd;
  748. gve_adminq_make_destroy_rx_queue_cmd(&cmd, queue_index);
  749. return gve_adminq_issue_cmd(priv, &cmd);
  750. }
  751. /* Unlike gve_adminq_destroy_rx_queue, this actually rings the doorbell */
  752. int gve_adminq_destroy_single_rx_queue(struct gve_priv *priv, u32 queue_index)
  753. {
  754. union gve_adminq_command cmd;
  755. gve_adminq_make_destroy_rx_queue_cmd(&cmd, queue_index);
  756. return gve_adminq_execute_cmd(priv, &cmd);
  757. }
  758. int gve_adminq_destroy_rx_queues(struct gve_priv *priv, u32 num_queues)
  759. {
  760. int err;
  761. int i;
  762. for (i = 0; i < num_queues; i++) {
  763. err = gve_adminq_destroy_rx_queue(priv, i);
  764. if (err)
  765. return err;
  766. }
  767. return gve_adminq_kick_and_wait(priv);
  768. }
  769. static void gve_set_default_desc_cnt(struct gve_priv *priv,
  770. const struct gve_device_descriptor *descriptor)
  771. {
  772. priv->tx_desc_cnt = be16_to_cpu(descriptor->tx_queue_entries);
  773. priv->rx_desc_cnt = be16_to_cpu(descriptor->rx_queue_entries);
  774. /* set default ranges */
  775. priv->max_tx_desc_cnt = priv->tx_desc_cnt;
  776. priv->max_rx_desc_cnt = priv->rx_desc_cnt;
  777. priv->min_tx_desc_cnt = priv->tx_desc_cnt;
  778. priv->min_rx_desc_cnt = priv->rx_desc_cnt;
  779. }
  780. static void gve_enable_supported_features(struct gve_priv *priv,
  781. u32 supported_features_mask,
  782. const struct gve_device_option_jumbo_frames
  783. *dev_op_jumbo_frames,
  784. const struct gve_device_option_dqo_qpl
  785. *dev_op_dqo_qpl,
  786. const struct gve_device_option_buffer_sizes
  787. *dev_op_buffer_sizes,
  788. const struct gve_device_option_flow_steering
  789. *dev_op_flow_steering,
  790. const struct gve_device_option_rss_config
  791. *dev_op_rss_config,
  792. const struct gve_device_option_modify_ring
  793. *dev_op_modify_ring)
  794. {
  795. /* Before control reaches this point, the page-size-capped max MTU from
  796. * the gve_device_descriptor field has already been stored in
  797. * priv->dev->max_mtu. We overwrite it with the true max MTU below.
  798. */
  799. if (dev_op_jumbo_frames &&
  800. (supported_features_mask & GVE_SUP_JUMBO_FRAMES_MASK)) {
  801. dev_info(&priv->pdev->dev,
  802. "JUMBO FRAMES device option enabled.\n");
  803. priv->dev->max_mtu = be16_to_cpu(dev_op_jumbo_frames->max_mtu);
  804. }
  805. /* Override pages for qpl for DQO-QPL */
  806. if (dev_op_dqo_qpl) {
  807. priv->tx_pages_per_qpl =
  808. be16_to_cpu(dev_op_dqo_qpl->tx_pages_per_qpl);
  809. if (priv->tx_pages_per_qpl == 0)
  810. priv->tx_pages_per_qpl = DQO_QPL_DEFAULT_TX_PAGES;
  811. }
  812. if (dev_op_buffer_sizes &&
  813. (supported_features_mask & GVE_SUP_BUFFER_SIZES_MASK)) {
  814. priv->max_rx_buffer_size =
  815. be16_to_cpu(dev_op_buffer_sizes->packet_buffer_size);
  816. priv->header_buf_size =
  817. be16_to_cpu(dev_op_buffer_sizes->header_buffer_size);
  818. dev_info(&priv->pdev->dev,
  819. "BUFFER SIZES device option enabled with max_rx_buffer_size of %u, header_buf_size of %u.\n",
  820. priv->max_rx_buffer_size, priv->header_buf_size);
  821. }
  822. /* Read and store ring size ranges given by device */
  823. if (dev_op_modify_ring &&
  824. (supported_features_mask & GVE_SUP_MODIFY_RING_MASK)) {
  825. priv->modify_ring_size_enabled = true;
  826. /* max ring size for DQO QPL should not be overwritten because of device limit */
  827. if (priv->queue_format != GVE_DQO_QPL_FORMAT) {
  828. priv->max_rx_desc_cnt = be16_to_cpu(dev_op_modify_ring->max_rx_ring_size);
  829. priv->max_tx_desc_cnt = be16_to_cpu(dev_op_modify_ring->max_tx_ring_size);
  830. }
  831. if (priv->default_min_ring_size) {
  832. /* If device hasn't provided minimums, use default minimums */
  833. priv->min_tx_desc_cnt = GVE_DEFAULT_MIN_TX_RING_SIZE;
  834. priv->min_rx_desc_cnt = GVE_DEFAULT_MIN_RX_RING_SIZE;
  835. } else {
  836. priv->min_rx_desc_cnt = be16_to_cpu(dev_op_modify_ring->min_rx_ring_size);
  837. priv->min_tx_desc_cnt = be16_to_cpu(dev_op_modify_ring->min_tx_ring_size);
  838. }
  839. }
  840. if (dev_op_flow_steering &&
  841. (supported_features_mask & GVE_SUP_FLOW_STEERING_MASK)) {
  842. if (dev_op_flow_steering->max_flow_rules) {
  843. priv->max_flow_rules =
  844. be32_to_cpu(dev_op_flow_steering->max_flow_rules);
  845. priv->dev->hw_features |= NETIF_F_NTUPLE;
  846. dev_info(&priv->pdev->dev,
  847. "FLOW STEERING device option enabled with max rule limit of %u.\n",
  848. priv->max_flow_rules);
  849. }
  850. }
  851. if (dev_op_rss_config &&
  852. (supported_features_mask & GVE_SUP_RSS_CONFIG_MASK)) {
  853. priv->rss_key_size =
  854. be16_to_cpu(dev_op_rss_config->hash_key_size);
  855. priv->rss_lut_size =
  856. be16_to_cpu(dev_op_rss_config->hash_lut_size);
  857. }
  858. }
  859. int gve_adminq_describe_device(struct gve_priv *priv)
  860. {
  861. struct gve_device_option_flow_steering *dev_op_flow_steering = NULL;
  862. struct gve_device_option_buffer_sizes *dev_op_buffer_sizes = NULL;
  863. struct gve_device_option_jumbo_frames *dev_op_jumbo_frames = NULL;
  864. struct gve_device_option_modify_ring *dev_op_modify_ring = NULL;
  865. struct gve_device_option_rss_config *dev_op_rss_config = NULL;
  866. struct gve_device_option_gqi_rda *dev_op_gqi_rda = NULL;
  867. struct gve_device_option_gqi_qpl *dev_op_gqi_qpl = NULL;
  868. struct gve_device_option_dqo_rda *dev_op_dqo_rda = NULL;
  869. struct gve_device_option_dqo_qpl *dev_op_dqo_qpl = NULL;
  870. struct gve_device_descriptor *descriptor;
  871. u32 supported_features_mask = 0;
  872. union gve_adminq_command cmd;
  873. dma_addr_t descriptor_bus;
  874. int err = 0;
  875. u8 *mac;
  876. u16 mtu;
  877. memset(&cmd, 0, sizeof(cmd));
  878. descriptor = dma_pool_alloc(priv->adminq_pool, GFP_KERNEL,
  879. &descriptor_bus);
  880. if (!descriptor)
  881. return -ENOMEM;
  882. cmd.opcode = cpu_to_be32(GVE_ADMINQ_DESCRIBE_DEVICE);
  883. cmd.describe_device.device_descriptor_addr =
  884. cpu_to_be64(descriptor_bus);
  885. cmd.describe_device.device_descriptor_version =
  886. cpu_to_be32(GVE_ADMINQ_DEVICE_DESCRIPTOR_VERSION);
  887. cmd.describe_device.available_length =
  888. cpu_to_be32(GVE_ADMINQ_BUFFER_SIZE);
  889. err = gve_adminq_execute_cmd(priv, &cmd);
  890. if (err)
  891. goto free_device_descriptor;
  892. err = gve_process_device_options(priv, descriptor, &dev_op_gqi_rda,
  893. &dev_op_gqi_qpl, &dev_op_dqo_rda,
  894. &dev_op_jumbo_frames, &dev_op_dqo_qpl,
  895. &dev_op_buffer_sizes,
  896. &dev_op_flow_steering,
  897. &dev_op_rss_config,
  898. &dev_op_modify_ring);
  899. if (err)
  900. goto free_device_descriptor;
  901. /* If the GQI_RAW_ADDRESSING option is not enabled and the queue format
  902. * is not set to GqiRda, choose the queue format in a priority order:
  903. * DqoRda, DqoQpl, GqiRda, GqiQpl. Use GqiQpl as default.
  904. */
  905. if (dev_op_dqo_rda) {
  906. priv->queue_format = GVE_DQO_RDA_FORMAT;
  907. dev_info(&priv->pdev->dev,
  908. "Driver is running with DQO RDA queue format.\n");
  909. supported_features_mask =
  910. be32_to_cpu(dev_op_dqo_rda->supported_features_mask);
  911. } else if (dev_op_dqo_qpl) {
  912. priv->queue_format = GVE_DQO_QPL_FORMAT;
  913. supported_features_mask =
  914. be32_to_cpu(dev_op_dqo_qpl->supported_features_mask);
  915. } else if (dev_op_gqi_rda) {
  916. priv->queue_format = GVE_GQI_RDA_FORMAT;
  917. dev_info(&priv->pdev->dev,
  918. "Driver is running with GQI RDA queue format.\n");
  919. supported_features_mask =
  920. be32_to_cpu(dev_op_gqi_rda->supported_features_mask);
  921. } else if (priv->queue_format == GVE_GQI_RDA_FORMAT) {
  922. dev_info(&priv->pdev->dev,
  923. "Driver is running with GQI RDA queue format.\n");
  924. } else {
  925. priv->queue_format = GVE_GQI_QPL_FORMAT;
  926. if (dev_op_gqi_qpl)
  927. supported_features_mask =
  928. be32_to_cpu(dev_op_gqi_qpl->supported_features_mask);
  929. dev_info(&priv->pdev->dev,
  930. "Driver is running with GQI QPL queue format.\n");
  931. }
  932. /* set default descriptor counts */
  933. gve_set_default_desc_cnt(priv, descriptor);
  934. /* DQO supports LRO. */
  935. if (!gve_is_gqi(priv))
  936. priv->dev->hw_features |= NETIF_F_LRO;
  937. priv->max_registered_pages =
  938. be64_to_cpu(descriptor->max_registered_pages);
  939. mtu = be16_to_cpu(descriptor->mtu);
  940. if (mtu < ETH_MIN_MTU) {
  941. dev_err(&priv->pdev->dev, "MTU %d below minimum MTU\n", mtu);
  942. err = -EINVAL;
  943. goto free_device_descriptor;
  944. }
  945. priv->dev->max_mtu = mtu;
  946. priv->num_event_counters = be16_to_cpu(descriptor->counters);
  947. eth_hw_addr_set(priv->dev, descriptor->mac);
  948. mac = descriptor->mac;
  949. dev_info(&priv->pdev->dev, "MAC addr: %pM\n", mac);
  950. priv->tx_pages_per_qpl = be16_to_cpu(descriptor->tx_pages_per_qpl);
  951. priv->default_num_queues = be16_to_cpu(descriptor->default_num_queues);
  952. gve_enable_supported_features(priv, supported_features_mask,
  953. dev_op_jumbo_frames, dev_op_dqo_qpl,
  954. dev_op_buffer_sizes, dev_op_flow_steering,
  955. dev_op_rss_config, dev_op_modify_ring);
  956. free_device_descriptor:
  957. dma_pool_free(priv->adminq_pool, descriptor, descriptor_bus);
  958. return err;
  959. }
  960. int gve_adminq_register_page_list(struct gve_priv *priv,
  961. struct gve_queue_page_list *qpl)
  962. {
  963. struct device *hdev = &priv->pdev->dev;
  964. u32 num_entries = qpl->num_entries;
  965. u32 size = num_entries * sizeof(qpl->page_buses[0]);
  966. union gve_adminq_command cmd;
  967. dma_addr_t page_list_bus;
  968. __be64 *page_list;
  969. int err;
  970. int i;
  971. memset(&cmd, 0, sizeof(cmd));
  972. page_list = dma_alloc_coherent(hdev, size, &page_list_bus, GFP_KERNEL);
  973. if (!page_list)
  974. return -ENOMEM;
  975. for (i = 0; i < num_entries; i++)
  976. page_list[i] = cpu_to_be64(qpl->page_buses[i]);
  977. cmd.opcode = cpu_to_be32(GVE_ADMINQ_REGISTER_PAGE_LIST);
  978. cmd.reg_page_list = (struct gve_adminq_register_page_list) {
  979. .page_list_id = cpu_to_be32(qpl->id),
  980. .num_pages = cpu_to_be32(num_entries),
  981. .page_address_list_addr = cpu_to_be64(page_list_bus),
  982. .page_size = cpu_to_be64(PAGE_SIZE),
  983. };
  984. err = gve_adminq_execute_cmd(priv, &cmd);
  985. dma_free_coherent(hdev, size, page_list, page_list_bus);
  986. return err;
  987. }
  988. int gve_adminq_unregister_page_list(struct gve_priv *priv, u32 page_list_id)
  989. {
  990. union gve_adminq_command cmd;
  991. memset(&cmd, 0, sizeof(cmd));
  992. cmd.opcode = cpu_to_be32(GVE_ADMINQ_UNREGISTER_PAGE_LIST);
  993. cmd.unreg_page_list = (struct gve_adminq_unregister_page_list) {
  994. .page_list_id = cpu_to_be32(page_list_id),
  995. };
  996. return gve_adminq_execute_cmd(priv, &cmd);
  997. }
  998. int gve_adminq_set_mtu(struct gve_priv *priv, u64 mtu)
  999. {
  1000. union gve_adminq_command cmd;
  1001. memset(&cmd, 0, sizeof(cmd));
  1002. cmd.opcode = cpu_to_be32(GVE_ADMINQ_SET_DRIVER_PARAMETER);
  1003. cmd.set_driver_param = (struct gve_adminq_set_driver_parameter) {
  1004. .parameter_type = cpu_to_be32(GVE_SET_PARAM_MTU),
  1005. .parameter_value = cpu_to_be64(mtu),
  1006. };
  1007. return gve_adminq_execute_cmd(priv, &cmd);
  1008. }
  1009. int gve_adminq_report_stats(struct gve_priv *priv, u64 stats_report_len,
  1010. dma_addr_t stats_report_addr, u64 interval)
  1011. {
  1012. union gve_adminq_command cmd;
  1013. memset(&cmd, 0, sizeof(cmd));
  1014. cmd.opcode = cpu_to_be32(GVE_ADMINQ_REPORT_STATS);
  1015. cmd.report_stats = (struct gve_adminq_report_stats) {
  1016. .stats_report_len = cpu_to_be64(stats_report_len),
  1017. .stats_report_addr = cpu_to_be64(stats_report_addr),
  1018. .interval = cpu_to_be64(interval),
  1019. };
  1020. return gve_adminq_execute_cmd(priv, &cmd);
  1021. }
  1022. int gve_adminq_verify_driver_compatibility(struct gve_priv *priv,
  1023. u64 driver_info_len,
  1024. dma_addr_t driver_info_addr)
  1025. {
  1026. union gve_adminq_command cmd;
  1027. memset(&cmd, 0, sizeof(cmd));
  1028. cmd.opcode = cpu_to_be32(GVE_ADMINQ_VERIFY_DRIVER_COMPATIBILITY);
  1029. cmd.verify_driver_compatibility = (struct gve_adminq_verify_driver_compatibility) {
  1030. .driver_info_len = cpu_to_be64(driver_info_len),
  1031. .driver_info_addr = cpu_to_be64(driver_info_addr),
  1032. };
  1033. return gve_adminq_execute_cmd(priv, &cmd);
  1034. }
  1035. int gve_adminq_report_link_speed(struct gve_priv *priv)
  1036. {
  1037. union gve_adminq_command gvnic_cmd;
  1038. dma_addr_t link_speed_region_bus;
  1039. __be64 *link_speed_region;
  1040. int err;
  1041. link_speed_region =
  1042. dma_alloc_coherent(&priv->pdev->dev, sizeof(*link_speed_region),
  1043. &link_speed_region_bus, GFP_KERNEL);
  1044. if (!link_speed_region)
  1045. return -ENOMEM;
  1046. memset(&gvnic_cmd, 0, sizeof(gvnic_cmd));
  1047. gvnic_cmd.opcode = cpu_to_be32(GVE_ADMINQ_REPORT_LINK_SPEED);
  1048. gvnic_cmd.report_link_speed.link_speed_address =
  1049. cpu_to_be64(link_speed_region_bus);
  1050. err = gve_adminq_execute_cmd(priv, &gvnic_cmd);
  1051. priv->link_speed = be64_to_cpu(*link_speed_region);
  1052. dma_free_coherent(&priv->pdev->dev, sizeof(*link_speed_region), link_speed_region,
  1053. link_speed_region_bus);
  1054. return err;
  1055. }
  1056. int gve_adminq_get_ptype_map_dqo(struct gve_priv *priv,
  1057. struct gve_ptype_lut *ptype_lut)
  1058. {
  1059. struct gve_ptype_map *ptype_map;
  1060. union gve_adminq_command cmd;
  1061. dma_addr_t ptype_map_bus;
  1062. int err = 0;
  1063. int i;
  1064. memset(&cmd, 0, sizeof(cmd));
  1065. ptype_map = dma_alloc_coherent(&priv->pdev->dev, sizeof(*ptype_map),
  1066. &ptype_map_bus, GFP_KERNEL);
  1067. if (!ptype_map)
  1068. return -ENOMEM;
  1069. cmd.opcode = cpu_to_be32(GVE_ADMINQ_GET_PTYPE_MAP);
  1070. cmd.get_ptype_map = (struct gve_adminq_get_ptype_map) {
  1071. .ptype_map_len = cpu_to_be64(sizeof(*ptype_map)),
  1072. .ptype_map_addr = cpu_to_be64(ptype_map_bus),
  1073. };
  1074. err = gve_adminq_execute_cmd(priv, &cmd);
  1075. if (err)
  1076. goto err;
  1077. /* Populate ptype_lut. */
  1078. for (i = 0; i < GVE_NUM_PTYPES; i++) {
  1079. ptype_lut->ptypes[i].l3_type =
  1080. ptype_map->ptypes[i].l3_type;
  1081. ptype_lut->ptypes[i].l4_type =
  1082. ptype_map->ptypes[i].l4_type;
  1083. }
  1084. err:
  1085. dma_free_coherent(&priv->pdev->dev, sizeof(*ptype_map), ptype_map,
  1086. ptype_map_bus);
  1087. return err;
  1088. }
  1089. static int
  1090. gve_adminq_configure_flow_rule(struct gve_priv *priv,
  1091. struct gve_adminq_configure_flow_rule *flow_rule_cmd)
  1092. {
  1093. int err = gve_adminq_execute_extended_cmd(priv,
  1094. GVE_ADMINQ_CONFIGURE_FLOW_RULE,
  1095. sizeof(struct gve_adminq_configure_flow_rule),
  1096. flow_rule_cmd);
  1097. if (err == -ETIME) {
  1098. dev_err(&priv->pdev->dev, "Timeout to configure the flow rule, trigger reset");
  1099. gve_reset(priv, true);
  1100. } else if (!err) {
  1101. priv->flow_rules_cache.rules_cache_synced = false;
  1102. }
  1103. return err;
  1104. }
  1105. int gve_adminq_add_flow_rule(struct gve_priv *priv, struct gve_adminq_flow_rule *rule, u32 loc)
  1106. {
  1107. struct gve_adminq_configure_flow_rule flow_rule_cmd = {
  1108. .opcode = cpu_to_be16(GVE_FLOW_RULE_CFG_ADD),
  1109. .location = cpu_to_be32(loc),
  1110. .rule = *rule,
  1111. };
  1112. return gve_adminq_configure_flow_rule(priv, &flow_rule_cmd);
  1113. }
  1114. int gve_adminq_del_flow_rule(struct gve_priv *priv, u32 loc)
  1115. {
  1116. struct gve_adminq_configure_flow_rule flow_rule_cmd = {
  1117. .opcode = cpu_to_be16(GVE_FLOW_RULE_CFG_DEL),
  1118. .location = cpu_to_be32(loc),
  1119. };
  1120. return gve_adminq_configure_flow_rule(priv, &flow_rule_cmd);
  1121. }
  1122. int gve_adminq_reset_flow_rules(struct gve_priv *priv)
  1123. {
  1124. struct gve_adminq_configure_flow_rule flow_rule_cmd = {
  1125. .opcode = cpu_to_be16(GVE_FLOW_RULE_CFG_RESET),
  1126. };
  1127. return gve_adminq_configure_flow_rule(priv, &flow_rule_cmd);
  1128. }
  1129. int gve_adminq_configure_rss(struct gve_priv *priv, struct ethtool_rxfh_param *rxfh)
  1130. {
  1131. dma_addr_t lut_bus = 0, key_bus = 0;
  1132. u16 key_size = 0, lut_size = 0;
  1133. union gve_adminq_command cmd;
  1134. __be32 *lut = NULL;
  1135. u8 hash_alg = 0;
  1136. u8 *key = NULL;
  1137. int err = 0;
  1138. u16 i;
  1139. switch (rxfh->hfunc) {
  1140. case ETH_RSS_HASH_NO_CHANGE:
  1141. break;
  1142. case ETH_RSS_HASH_TOP:
  1143. hash_alg = ETH_RSS_HASH_TOP;
  1144. break;
  1145. default:
  1146. return -EOPNOTSUPP;
  1147. }
  1148. if (rxfh->indir) {
  1149. lut_size = priv->rss_lut_size;
  1150. lut = dma_alloc_coherent(&priv->pdev->dev,
  1151. lut_size * sizeof(*lut),
  1152. &lut_bus, GFP_KERNEL);
  1153. if (!lut)
  1154. return -ENOMEM;
  1155. for (i = 0; i < priv->rss_lut_size; i++)
  1156. lut[i] = cpu_to_be32(rxfh->indir[i]);
  1157. }
  1158. if (rxfh->key) {
  1159. key_size = priv->rss_key_size;
  1160. key = dma_alloc_coherent(&priv->pdev->dev,
  1161. key_size, &key_bus, GFP_KERNEL);
  1162. if (!key) {
  1163. err = -ENOMEM;
  1164. goto out;
  1165. }
  1166. memcpy(key, rxfh->key, key_size);
  1167. }
  1168. /* Zero-valued fields in the cmd.configure_rss instruct the device to
  1169. * not update those fields.
  1170. */
  1171. memset(&cmd, 0, sizeof(cmd));
  1172. cmd.opcode = cpu_to_be32(GVE_ADMINQ_CONFIGURE_RSS);
  1173. cmd.configure_rss = (struct gve_adminq_configure_rss) {
  1174. .hash_types = cpu_to_be16(BIT(GVE_RSS_HASH_TCPV4) |
  1175. BIT(GVE_RSS_HASH_UDPV4) |
  1176. BIT(GVE_RSS_HASH_TCPV6) |
  1177. BIT(GVE_RSS_HASH_UDPV6)),
  1178. .hash_alg = hash_alg,
  1179. .hash_key_size = cpu_to_be16(key_size),
  1180. .hash_lut_size = cpu_to_be16(lut_size),
  1181. .hash_key_addr = cpu_to_be64(key_bus),
  1182. .hash_lut_addr = cpu_to_be64(lut_bus),
  1183. };
  1184. err = gve_adminq_execute_cmd(priv, &cmd);
  1185. out:
  1186. if (lut)
  1187. dma_free_coherent(&priv->pdev->dev,
  1188. lut_size * sizeof(*lut),
  1189. lut, lut_bus);
  1190. if (key)
  1191. dma_free_coherent(&priv->pdev->dev,
  1192. key_size, key, key_bus);
  1193. return err;
  1194. }
  1195. /* In the dma memory that the driver allocated for the device to query the flow rules, the device
  1196. * will first write it with a struct of gve_query_flow_rules_descriptor. Next to it, the device
  1197. * will write an array of rules or rule ids with the count that specified in the descriptor.
  1198. * For GVE_FLOW_RULE_QUERY_STATS, the device will only write the descriptor.
  1199. */
  1200. static int gve_adminq_process_flow_rules_query(struct gve_priv *priv, u16 query_opcode,
  1201. struct gve_query_flow_rules_descriptor *descriptor)
  1202. {
  1203. struct gve_flow_rules_cache *flow_rules_cache = &priv->flow_rules_cache;
  1204. u32 num_queried_rules, total_memory_len, rule_info_len;
  1205. void *rule_info;
  1206. total_memory_len = be32_to_cpu(descriptor->total_length);
  1207. num_queried_rules = be32_to_cpu(descriptor->num_queried_rules);
  1208. rule_info = (void *)(descriptor + 1);
  1209. switch (query_opcode) {
  1210. case GVE_FLOW_RULE_QUERY_RULES:
  1211. rule_info_len = num_queried_rules * sizeof(*flow_rules_cache->rules_cache);
  1212. if (sizeof(*descriptor) + rule_info_len != total_memory_len) {
  1213. dev_err(&priv->dev->dev, "flow rules query is out of memory.\n");
  1214. return -ENOMEM;
  1215. }
  1216. memcpy(flow_rules_cache->rules_cache, rule_info, rule_info_len);
  1217. flow_rules_cache->rules_cache_num = num_queried_rules;
  1218. break;
  1219. case GVE_FLOW_RULE_QUERY_IDS:
  1220. rule_info_len = num_queried_rules * sizeof(*flow_rules_cache->rule_ids_cache);
  1221. if (sizeof(*descriptor) + rule_info_len != total_memory_len) {
  1222. dev_err(&priv->dev->dev, "flow rule ids query is out of memory.\n");
  1223. return -ENOMEM;
  1224. }
  1225. memcpy(flow_rules_cache->rule_ids_cache, rule_info, rule_info_len);
  1226. flow_rules_cache->rule_ids_cache_num = num_queried_rules;
  1227. break;
  1228. case GVE_FLOW_RULE_QUERY_STATS:
  1229. priv->num_flow_rules = be32_to_cpu(descriptor->num_flow_rules);
  1230. priv->max_flow_rules = be32_to_cpu(descriptor->max_flow_rules);
  1231. return 0;
  1232. default:
  1233. return -EINVAL;
  1234. }
  1235. return 0;
  1236. }
  1237. int gve_adminq_query_flow_rules(struct gve_priv *priv, u16 query_opcode, u32 starting_loc)
  1238. {
  1239. struct gve_query_flow_rules_descriptor *descriptor;
  1240. union gve_adminq_command cmd;
  1241. dma_addr_t descriptor_bus;
  1242. int err = 0;
  1243. memset(&cmd, 0, sizeof(cmd));
  1244. descriptor = dma_pool_alloc(priv->adminq_pool, GFP_KERNEL, &descriptor_bus);
  1245. if (!descriptor)
  1246. return -ENOMEM;
  1247. cmd.opcode = cpu_to_be32(GVE_ADMINQ_QUERY_FLOW_RULES);
  1248. cmd.query_flow_rules = (struct gve_adminq_query_flow_rules) {
  1249. .opcode = cpu_to_be16(query_opcode),
  1250. .starting_rule_id = cpu_to_be32(starting_loc),
  1251. .available_length = cpu_to_be64(GVE_ADMINQ_BUFFER_SIZE),
  1252. .rule_descriptor_addr = cpu_to_be64(descriptor_bus),
  1253. };
  1254. err = gve_adminq_execute_cmd(priv, &cmd);
  1255. if (err)
  1256. goto out;
  1257. err = gve_adminq_process_flow_rules_query(priv, query_opcode, descriptor);
  1258. out:
  1259. dma_pool_free(priv->adminq_pool, descriptor, descriptor_bus);
  1260. return err;
  1261. }
  1262. static int gve_adminq_process_rss_query(struct gve_priv *priv,
  1263. struct gve_query_rss_descriptor *descriptor,
  1264. struct ethtool_rxfh_param *rxfh)
  1265. {
  1266. u32 total_memory_length;
  1267. u16 hash_lut_length;
  1268. void *rss_info_addr;
  1269. __be32 *lut;
  1270. u16 i;
  1271. total_memory_length = be32_to_cpu(descriptor->total_length);
  1272. hash_lut_length = priv->rss_lut_size * sizeof(*rxfh->indir);
  1273. if (sizeof(*descriptor) + priv->rss_key_size + hash_lut_length != total_memory_length) {
  1274. dev_err(&priv->dev->dev,
  1275. "rss query desc from device has invalid length parameter.\n");
  1276. return -EINVAL;
  1277. }
  1278. rxfh->hfunc = descriptor->hash_alg;
  1279. rss_info_addr = (void *)(descriptor + 1);
  1280. if (rxfh->key)
  1281. memcpy(rxfh->key, rss_info_addr, priv->rss_key_size);
  1282. rss_info_addr += priv->rss_key_size;
  1283. lut = (__be32 *)rss_info_addr;
  1284. if (rxfh->indir) {
  1285. for (i = 0; i < priv->rss_lut_size; i++)
  1286. rxfh->indir[i] = be32_to_cpu(lut[i]);
  1287. }
  1288. return 0;
  1289. }
  1290. int gve_adminq_query_rss_config(struct gve_priv *priv, struct ethtool_rxfh_param *rxfh)
  1291. {
  1292. struct gve_query_rss_descriptor *descriptor;
  1293. union gve_adminq_command cmd;
  1294. dma_addr_t descriptor_bus;
  1295. int err = 0;
  1296. descriptor = dma_pool_alloc(priv->adminq_pool, GFP_KERNEL, &descriptor_bus);
  1297. if (!descriptor)
  1298. return -ENOMEM;
  1299. memset(&cmd, 0, sizeof(cmd));
  1300. cmd.opcode = cpu_to_be32(GVE_ADMINQ_QUERY_RSS);
  1301. cmd.query_rss = (struct gve_adminq_query_rss) {
  1302. .available_length = cpu_to_be64(GVE_ADMINQ_BUFFER_SIZE),
  1303. .rss_descriptor_addr = cpu_to_be64(descriptor_bus),
  1304. };
  1305. err = gve_adminq_execute_cmd(priv, &cmd);
  1306. if (err)
  1307. goto out;
  1308. err = gve_adminq_process_rss_query(priv, descriptor, rxfh);
  1309. out:
  1310. dma_pool_free(priv->adminq_pool, descriptor, descriptor_bus);
  1311. return err;
  1312. }