i40e_common.c 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345
  1. /*******************************************************************************
  2. *
  3. * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
  4. * Copyright(c) 2013 - 2014 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * The full GNU General Public License is included in this distribution in
  19. * the file called "COPYING".
  20. *
  21. * Contact Information:
  22. * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. ******************************************************************************/
  26. #include "i40e_type.h"
  27. #include "i40e_adminq.h"
  28. #include "i40e_prototype.h"
  29. #include "i40e_virtchnl.h"
  30. /**
  31. * i40e_set_mac_type - Sets MAC type
  32. * @hw: pointer to the HW structure
  33. *
  34. * This function sets the mac type of the adapter based on the
  35. * vendor ID and device ID stored in the hw structure.
  36. **/
  37. i40e_status i40e_set_mac_type(struct i40e_hw *hw)
  38. {
  39. i40e_status status = 0;
  40. if (hw->vendor_id == PCI_VENDOR_ID_INTEL) {
  41. switch (hw->device_id) {
  42. case I40E_DEV_ID_SFP_XL710:
  43. case I40E_DEV_ID_QEMU:
  44. case I40E_DEV_ID_KX_B:
  45. case I40E_DEV_ID_KX_C:
  46. case I40E_DEV_ID_QSFP_A:
  47. case I40E_DEV_ID_QSFP_B:
  48. case I40E_DEV_ID_QSFP_C:
  49. case I40E_DEV_ID_10G_BASE_T:
  50. case I40E_DEV_ID_10G_BASE_T4:
  51. case I40E_DEV_ID_20G_KR2:
  52. case I40E_DEV_ID_20G_KR2_A:
  53. case I40E_DEV_ID_25G_B:
  54. case I40E_DEV_ID_25G_SFP28:
  55. hw->mac.type = I40E_MAC_XL710;
  56. break;
  57. case I40E_DEV_ID_SFP_X722:
  58. case I40E_DEV_ID_1G_BASE_T_X722:
  59. case I40E_DEV_ID_10G_BASE_T_X722:
  60. case I40E_DEV_ID_SFP_I_X722:
  61. hw->mac.type = I40E_MAC_X722;
  62. break;
  63. case I40E_DEV_ID_X722_VF:
  64. hw->mac.type = I40E_MAC_X722_VF;
  65. break;
  66. case I40E_DEV_ID_VF:
  67. case I40E_DEV_ID_VF_HV:
  68. hw->mac.type = I40E_MAC_VF;
  69. break;
  70. default:
  71. hw->mac.type = I40E_MAC_GENERIC;
  72. break;
  73. }
  74. } else {
  75. status = I40E_ERR_DEVICE_NOT_SUPPORTED;
  76. }
  77. hw_dbg(hw, "i40e_set_mac_type found mac: %d, returns: %d\n",
  78. hw->mac.type, status);
  79. return status;
  80. }
  81. /**
  82. * i40evf_aq_str - convert AQ err code to a string
  83. * @hw: pointer to the HW structure
  84. * @aq_err: the AQ error code to convert
  85. **/
  86. const char *i40evf_aq_str(struct i40e_hw *hw, enum i40e_admin_queue_err aq_err)
  87. {
  88. switch (aq_err) {
  89. case I40E_AQ_RC_OK:
  90. return "OK";
  91. case I40E_AQ_RC_EPERM:
  92. return "I40E_AQ_RC_EPERM";
  93. case I40E_AQ_RC_ENOENT:
  94. return "I40E_AQ_RC_ENOENT";
  95. case I40E_AQ_RC_ESRCH:
  96. return "I40E_AQ_RC_ESRCH";
  97. case I40E_AQ_RC_EINTR:
  98. return "I40E_AQ_RC_EINTR";
  99. case I40E_AQ_RC_EIO:
  100. return "I40E_AQ_RC_EIO";
  101. case I40E_AQ_RC_ENXIO:
  102. return "I40E_AQ_RC_ENXIO";
  103. case I40E_AQ_RC_E2BIG:
  104. return "I40E_AQ_RC_E2BIG";
  105. case I40E_AQ_RC_EAGAIN:
  106. return "I40E_AQ_RC_EAGAIN";
  107. case I40E_AQ_RC_ENOMEM:
  108. return "I40E_AQ_RC_ENOMEM";
  109. case I40E_AQ_RC_EACCES:
  110. return "I40E_AQ_RC_EACCES";
  111. case I40E_AQ_RC_EFAULT:
  112. return "I40E_AQ_RC_EFAULT";
  113. case I40E_AQ_RC_EBUSY:
  114. return "I40E_AQ_RC_EBUSY";
  115. case I40E_AQ_RC_EEXIST:
  116. return "I40E_AQ_RC_EEXIST";
  117. case I40E_AQ_RC_EINVAL:
  118. return "I40E_AQ_RC_EINVAL";
  119. case I40E_AQ_RC_ENOTTY:
  120. return "I40E_AQ_RC_ENOTTY";
  121. case I40E_AQ_RC_ENOSPC:
  122. return "I40E_AQ_RC_ENOSPC";
  123. case I40E_AQ_RC_ENOSYS:
  124. return "I40E_AQ_RC_ENOSYS";
  125. case I40E_AQ_RC_ERANGE:
  126. return "I40E_AQ_RC_ERANGE";
  127. case I40E_AQ_RC_EFLUSHED:
  128. return "I40E_AQ_RC_EFLUSHED";
  129. case I40E_AQ_RC_BAD_ADDR:
  130. return "I40E_AQ_RC_BAD_ADDR";
  131. case I40E_AQ_RC_EMODE:
  132. return "I40E_AQ_RC_EMODE";
  133. case I40E_AQ_RC_EFBIG:
  134. return "I40E_AQ_RC_EFBIG";
  135. }
  136. snprintf(hw->err_str, sizeof(hw->err_str), "%d", aq_err);
  137. return hw->err_str;
  138. }
  139. /**
  140. * i40evf_stat_str - convert status err code to a string
  141. * @hw: pointer to the HW structure
  142. * @stat_err: the status error code to convert
  143. **/
  144. const char *i40evf_stat_str(struct i40e_hw *hw, i40e_status stat_err)
  145. {
  146. switch (stat_err) {
  147. case 0:
  148. return "OK";
  149. case I40E_ERR_NVM:
  150. return "I40E_ERR_NVM";
  151. case I40E_ERR_NVM_CHECKSUM:
  152. return "I40E_ERR_NVM_CHECKSUM";
  153. case I40E_ERR_PHY:
  154. return "I40E_ERR_PHY";
  155. case I40E_ERR_CONFIG:
  156. return "I40E_ERR_CONFIG";
  157. case I40E_ERR_PARAM:
  158. return "I40E_ERR_PARAM";
  159. case I40E_ERR_MAC_TYPE:
  160. return "I40E_ERR_MAC_TYPE";
  161. case I40E_ERR_UNKNOWN_PHY:
  162. return "I40E_ERR_UNKNOWN_PHY";
  163. case I40E_ERR_LINK_SETUP:
  164. return "I40E_ERR_LINK_SETUP";
  165. case I40E_ERR_ADAPTER_STOPPED:
  166. return "I40E_ERR_ADAPTER_STOPPED";
  167. case I40E_ERR_INVALID_MAC_ADDR:
  168. return "I40E_ERR_INVALID_MAC_ADDR";
  169. case I40E_ERR_DEVICE_NOT_SUPPORTED:
  170. return "I40E_ERR_DEVICE_NOT_SUPPORTED";
  171. case I40E_ERR_MASTER_REQUESTS_PENDING:
  172. return "I40E_ERR_MASTER_REQUESTS_PENDING";
  173. case I40E_ERR_INVALID_LINK_SETTINGS:
  174. return "I40E_ERR_INVALID_LINK_SETTINGS";
  175. case I40E_ERR_AUTONEG_NOT_COMPLETE:
  176. return "I40E_ERR_AUTONEG_NOT_COMPLETE";
  177. case I40E_ERR_RESET_FAILED:
  178. return "I40E_ERR_RESET_FAILED";
  179. case I40E_ERR_SWFW_SYNC:
  180. return "I40E_ERR_SWFW_SYNC";
  181. case I40E_ERR_NO_AVAILABLE_VSI:
  182. return "I40E_ERR_NO_AVAILABLE_VSI";
  183. case I40E_ERR_NO_MEMORY:
  184. return "I40E_ERR_NO_MEMORY";
  185. case I40E_ERR_BAD_PTR:
  186. return "I40E_ERR_BAD_PTR";
  187. case I40E_ERR_RING_FULL:
  188. return "I40E_ERR_RING_FULL";
  189. case I40E_ERR_INVALID_PD_ID:
  190. return "I40E_ERR_INVALID_PD_ID";
  191. case I40E_ERR_INVALID_QP_ID:
  192. return "I40E_ERR_INVALID_QP_ID";
  193. case I40E_ERR_INVALID_CQ_ID:
  194. return "I40E_ERR_INVALID_CQ_ID";
  195. case I40E_ERR_INVALID_CEQ_ID:
  196. return "I40E_ERR_INVALID_CEQ_ID";
  197. case I40E_ERR_INVALID_AEQ_ID:
  198. return "I40E_ERR_INVALID_AEQ_ID";
  199. case I40E_ERR_INVALID_SIZE:
  200. return "I40E_ERR_INVALID_SIZE";
  201. case I40E_ERR_INVALID_ARP_INDEX:
  202. return "I40E_ERR_INVALID_ARP_INDEX";
  203. case I40E_ERR_INVALID_FPM_FUNC_ID:
  204. return "I40E_ERR_INVALID_FPM_FUNC_ID";
  205. case I40E_ERR_QP_INVALID_MSG_SIZE:
  206. return "I40E_ERR_QP_INVALID_MSG_SIZE";
  207. case I40E_ERR_QP_TOOMANY_WRS_POSTED:
  208. return "I40E_ERR_QP_TOOMANY_WRS_POSTED";
  209. case I40E_ERR_INVALID_FRAG_COUNT:
  210. return "I40E_ERR_INVALID_FRAG_COUNT";
  211. case I40E_ERR_QUEUE_EMPTY:
  212. return "I40E_ERR_QUEUE_EMPTY";
  213. case I40E_ERR_INVALID_ALIGNMENT:
  214. return "I40E_ERR_INVALID_ALIGNMENT";
  215. case I40E_ERR_FLUSHED_QUEUE:
  216. return "I40E_ERR_FLUSHED_QUEUE";
  217. case I40E_ERR_INVALID_PUSH_PAGE_INDEX:
  218. return "I40E_ERR_INVALID_PUSH_PAGE_INDEX";
  219. case I40E_ERR_INVALID_IMM_DATA_SIZE:
  220. return "I40E_ERR_INVALID_IMM_DATA_SIZE";
  221. case I40E_ERR_TIMEOUT:
  222. return "I40E_ERR_TIMEOUT";
  223. case I40E_ERR_OPCODE_MISMATCH:
  224. return "I40E_ERR_OPCODE_MISMATCH";
  225. case I40E_ERR_CQP_COMPL_ERROR:
  226. return "I40E_ERR_CQP_COMPL_ERROR";
  227. case I40E_ERR_INVALID_VF_ID:
  228. return "I40E_ERR_INVALID_VF_ID";
  229. case I40E_ERR_INVALID_HMCFN_ID:
  230. return "I40E_ERR_INVALID_HMCFN_ID";
  231. case I40E_ERR_BACKING_PAGE_ERROR:
  232. return "I40E_ERR_BACKING_PAGE_ERROR";
  233. case I40E_ERR_NO_PBLCHUNKS_AVAILABLE:
  234. return "I40E_ERR_NO_PBLCHUNKS_AVAILABLE";
  235. case I40E_ERR_INVALID_PBLE_INDEX:
  236. return "I40E_ERR_INVALID_PBLE_INDEX";
  237. case I40E_ERR_INVALID_SD_INDEX:
  238. return "I40E_ERR_INVALID_SD_INDEX";
  239. case I40E_ERR_INVALID_PAGE_DESC_INDEX:
  240. return "I40E_ERR_INVALID_PAGE_DESC_INDEX";
  241. case I40E_ERR_INVALID_SD_TYPE:
  242. return "I40E_ERR_INVALID_SD_TYPE";
  243. case I40E_ERR_MEMCPY_FAILED:
  244. return "I40E_ERR_MEMCPY_FAILED";
  245. case I40E_ERR_INVALID_HMC_OBJ_INDEX:
  246. return "I40E_ERR_INVALID_HMC_OBJ_INDEX";
  247. case I40E_ERR_INVALID_HMC_OBJ_COUNT:
  248. return "I40E_ERR_INVALID_HMC_OBJ_COUNT";
  249. case I40E_ERR_INVALID_SRQ_ARM_LIMIT:
  250. return "I40E_ERR_INVALID_SRQ_ARM_LIMIT";
  251. case I40E_ERR_SRQ_ENABLED:
  252. return "I40E_ERR_SRQ_ENABLED";
  253. case I40E_ERR_ADMIN_QUEUE_ERROR:
  254. return "I40E_ERR_ADMIN_QUEUE_ERROR";
  255. case I40E_ERR_ADMIN_QUEUE_TIMEOUT:
  256. return "I40E_ERR_ADMIN_QUEUE_TIMEOUT";
  257. case I40E_ERR_BUF_TOO_SHORT:
  258. return "I40E_ERR_BUF_TOO_SHORT";
  259. case I40E_ERR_ADMIN_QUEUE_FULL:
  260. return "I40E_ERR_ADMIN_QUEUE_FULL";
  261. case I40E_ERR_ADMIN_QUEUE_NO_WORK:
  262. return "I40E_ERR_ADMIN_QUEUE_NO_WORK";
  263. case I40E_ERR_BAD_IWARP_CQE:
  264. return "I40E_ERR_BAD_IWARP_CQE";
  265. case I40E_ERR_NVM_BLANK_MODE:
  266. return "I40E_ERR_NVM_BLANK_MODE";
  267. case I40E_ERR_NOT_IMPLEMENTED:
  268. return "I40E_ERR_NOT_IMPLEMENTED";
  269. case I40E_ERR_PE_DOORBELL_NOT_ENABLED:
  270. return "I40E_ERR_PE_DOORBELL_NOT_ENABLED";
  271. case I40E_ERR_DIAG_TEST_FAILED:
  272. return "I40E_ERR_DIAG_TEST_FAILED";
  273. case I40E_ERR_NOT_READY:
  274. return "I40E_ERR_NOT_READY";
  275. case I40E_NOT_SUPPORTED:
  276. return "I40E_NOT_SUPPORTED";
  277. case I40E_ERR_FIRMWARE_API_VERSION:
  278. return "I40E_ERR_FIRMWARE_API_VERSION";
  279. }
  280. snprintf(hw->err_str, sizeof(hw->err_str), "%d", stat_err);
  281. return hw->err_str;
  282. }
  283. /**
  284. * i40evf_debug_aq
  285. * @hw: debug mask related to admin queue
  286. * @mask: debug mask
  287. * @desc: pointer to admin queue descriptor
  288. * @buffer: pointer to command buffer
  289. * @buf_len: max length of buffer
  290. *
  291. * Dumps debug log about adminq command with descriptor contents.
  292. **/
  293. void i40evf_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask, void *desc,
  294. void *buffer, u16 buf_len)
  295. {
  296. struct i40e_aq_desc *aq_desc = (struct i40e_aq_desc *)desc;
  297. u8 *buf = (u8 *)buffer;
  298. if ((!(mask & hw->debug_mask)) || (desc == NULL))
  299. return;
  300. i40e_debug(hw, mask,
  301. "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n",
  302. le16_to_cpu(aq_desc->opcode),
  303. le16_to_cpu(aq_desc->flags),
  304. le16_to_cpu(aq_desc->datalen),
  305. le16_to_cpu(aq_desc->retval));
  306. i40e_debug(hw, mask, "\tcookie (h,l) 0x%08X 0x%08X\n",
  307. le32_to_cpu(aq_desc->cookie_high),
  308. le32_to_cpu(aq_desc->cookie_low));
  309. i40e_debug(hw, mask, "\tparam (0,1) 0x%08X 0x%08X\n",
  310. le32_to_cpu(aq_desc->params.internal.param0),
  311. le32_to_cpu(aq_desc->params.internal.param1));
  312. i40e_debug(hw, mask, "\taddr (h,l) 0x%08X 0x%08X\n",
  313. le32_to_cpu(aq_desc->params.external.addr_high),
  314. le32_to_cpu(aq_desc->params.external.addr_low));
  315. if ((buffer != NULL) && (aq_desc->datalen != 0)) {
  316. u16 len = le16_to_cpu(aq_desc->datalen);
  317. i40e_debug(hw, mask, "AQ CMD Buffer:\n");
  318. if (buf_len < len)
  319. len = buf_len;
  320. /* write the full 16-byte chunks */
  321. if (hw->debug_mask & mask) {
  322. char prefix[20];
  323. snprintf(prefix, 20,
  324. "i40evf %02x:%02x.%x: \t0x",
  325. hw->bus.bus_id,
  326. hw->bus.device,
  327. hw->bus.func);
  328. print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_OFFSET,
  329. 16, 1, buf, len, false);
  330. }
  331. }
  332. }
  333. /**
  334. * i40evf_check_asq_alive
  335. * @hw: pointer to the hw struct
  336. *
  337. * Returns true if Queue is enabled else false.
  338. **/
  339. bool i40evf_check_asq_alive(struct i40e_hw *hw)
  340. {
  341. if (hw->aq.asq.len)
  342. return !!(rd32(hw, hw->aq.asq.len) &
  343. I40E_VF_ATQLEN1_ATQENABLE_MASK);
  344. else
  345. return false;
  346. }
  347. /**
  348. * i40evf_aq_queue_shutdown
  349. * @hw: pointer to the hw struct
  350. * @unloading: is the driver unloading itself
  351. *
  352. * Tell the Firmware that we're shutting down the AdminQ and whether
  353. * or not the driver is unloading as well.
  354. **/
  355. i40e_status i40evf_aq_queue_shutdown(struct i40e_hw *hw,
  356. bool unloading)
  357. {
  358. struct i40e_aq_desc desc;
  359. struct i40e_aqc_queue_shutdown *cmd =
  360. (struct i40e_aqc_queue_shutdown *)&desc.params.raw;
  361. i40e_status status;
  362. i40evf_fill_default_direct_cmd_desc(&desc,
  363. i40e_aqc_opc_queue_shutdown);
  364. if (unloading)
  365. cmd->driver_unloading = cpu_to_le32(I40E_AQ_DRIVER_UNLOADING);
  366. status = i40evf_asq_send_command(hw, &desc, NULL, 0, NULL);
  367. return status;
  368. }
  369. /**
  370. * i40e_aq_get_set_rss_lut
  371. * @hw: pointer to the hardware structure
  372. * @vsi_id: vsi fw index
  373. * @pf_lut: for PF table set true, for VSI table set false
  374. * @lut: pointer to the lut buffer provided by the caller
  375. * @lut_size: size of the lut buffer
  376. * @set: set true to set the table, false to get the table
  377. *
  378. * Internal function to get or set RSS look up table
  379. **/
  380. static i40e_status i40e_aq_get_set_rss_lut(struct i40e_hw *hw,
  381. u16 vsi_id, bool pf_lut,
  382. u8 *lut, u16 lut_size,
  383. bool set)
  384. {
  385. i40e_status status;
  386. struct i40e_aq_desc desc;
  387. struct i40e_aqc_get_set_rss_lut *cmd_resp =
  388. (struct i40e_aqc_get_set_rss_lut *)&desc.params.raw;
  389. if (set)
  390. i40evf_fill_default_direct_cmd_desc(&desc,
  391. i40e_aqc_opc_set_rss_lut);
  392. else
  393. i40evf_fill_default_direct_cmd_desc(&desc,
  394. i40e_aqc_opc_get_rss_lut);
  395. /* Indirect command */
  396. desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
  397. desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_RD);
  398. cmd_resp->vsi_id =
  399. cpu_to_le16((u16)((vsi_id <<
  400. I40E_AQC_SET_RSS_LUT_VSI_ID_SHIFT) &
  401. I40E_AQC_SET_RSS_LUT_VSI_ID_MASK));
  402. cmd_resp->vsi_id |= cpu_to_le16((u16)I40E_AQC_SET_RSS_LUT_VSI_VALID);
  403. if (pf_lut)
  404. cmd_resp->flags |= cpu_to_le16((u16)
  405. ((I40E_AQC_SET_RSS_LUT_TABLE_TYPE_PF <<
  406. I40E_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
  407. I40E_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
  408. else
  409. cmd_resp->flags |= cpu_to_le16((u16)
  410. ((I40E_AQC_SET_RSS_LUT_TABLE_TYPE_VSI <<
  411. I40E_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
  412. I40E_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
  413. status = i40evf_asq_send_command(hw, &desc, lut, lut_size, NULL);
  414. return status;
  415. }
  416. /**
  417. * i40evf_aq_get_rss_lut
  418. * @hw: pointer to the hardware structure
  419. * @vsi_id: vsi fw index
  420. * @pf_lut: for PF table set true, for VSI table set false
  421. * @lut: pointer to the lut buffer provided by the caller
  422. * @lut_size: size of the lut buffer
  423. *
  424. * get the RSS lookup table, PF or VSI type
  425. **/
  426. i40e_status i40evf_aq_get_rss_lut(struct i40e_hw *hw, u16 vsi_id,
  427. bool pf_lut, u8 *lut, u16 lut_size)
  428. {
  429. return i40e_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size,
  430. false);
  431. }
  432. /**
  433. * i40evf_aq_set_rss_lut
  434. * @hw: pointer to the hardware structure
  435. * @vsi_id: vsi fw index
  436. * @pf_lut: for PF table set true, for VSI table set false
  437. * @lut: pointer to the lut buffer provided by the caller
  438. * @lut_size: size of the lut buffer
  439. *
  440. * set the RSS lookup table, PF or VSI type
  441. **/
  442. i40e_status i40evf_aq_set_rss_lut(struct i40e_hw *hw, u16 vsi_id,
  443. bool pf_lut, u8 *lut, u16 lut_size)
  444. {
  445. return i40e_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size, true);
  446. }
  447. /**
  448. * i40e_aq_get_set_rss_key
  449. * @hw: pointer to the hw struct
  450. * @vsi_id: vsi fw index
  451. * @key: pointer to key info struct
  452. * @set: set true to set the key, false to get the key
  453. *
  454. * get the RSS key per VSI
  455. **/
  456. static i40e_status i40e_aq_get_set_rss_key(struct i40e_hw *hw,
  457. u16 vsi_id,
  458. struct i40e_aqc_get_set_rss_key_data *key,
  459. bool set)
  460. {
  461. i40e_status status;
  462. struct i40e_aq_desc desc;
  463. struct i40e_aqc_get_set_rss_key *cmd_resp =
  464. (struct i40e_aqc_get_set_rss_key *)&desc.params.raw;
  465. u16 key_size = sizeof(struct i40e_aqc_get_set_rss_key_data);
  466. if (set)
  467. i40evf_fill_default_direct_cmd_desc(&desc,
  468. i40e_aqc_opc_set_rss_key);
  469. else
  470. i40evf_fill_default_direct_cmd_desc(&desc,
  471. i40e_aqc_opc_get_rss_key);
  472. /* Indirect command */
  473. desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
  474. desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_RD);
  475. cmd_resp->vsi_id =
  476. cpu_to_le16((u16)((vsi_id <<
  477. I40E_AQC_SET_RSS_KEY_VSI_ID_SHIFT) &
  478. I40E_AQC_SET_RSS_KEY_VSI_ID_MASK));
  479. cmd_resp->vsi_id |= cpu_to_le16((u16)I40E_AQC_SET_RSS_KEY_VSI_VALID);
  480. status = i40evf_asq_send_command(hw, &desc, key, key_size, NULL);
  481. return status;
  482. }
  483. /**
  484. * i40evf_aq_get_rss_key
  485. * @hw: pointer to the hw struct
  486. * @vsi_id: vsi fw index
  487. * @key: pointer to key info struct
  488. *
  489. **/
  490. i40e_status i40evf_aq_get_rss_key(struct i40e_hw *hw,
  491. u16 vsi_id,
  492. struct i40e_aqc_get_set_rss_key_data *key)
  493. {
  494. return i40e_aq_get_set_rss_key(hw, vsi_id, key, false);
  495. }
  496. /**
  497. * i40evf_aq_set_rss_key
  498. * @hw: pointer to the hw struct
  499. * @vsi_id: vsi fw index
  500. * @key: pointer to key info struct
  501. *
  502. * set the RSS key per VSI
  503. **/
  504. i40e_status i40evf_aq_set_rss_key(struct i40e_hw *hw,
  505. u16 vsi_id,
  506. struct i40e_aqc_get_set_rss_key_data *key)
  507. {
  508. return i40e_aq_get_set_rss_key(hw, vsi_id, key, true);
  509. }
  510. /* The i40evf_ptype_lookup table is used to convert from the 8-bit ptype in the
  511. * hardware to a bit-field that can be used by SW to more easily determine the
  512. * packet type.
  513. *
  514. * Macros are used to shorten the table lines and make this table human
  515. * readable.
  516. *
  517. * We store the PTYPE in the top byte of the bit field - this is just so that
  518. * we can check that the table doesn't have a row missing, as the index into
  519. * the table should be the PTYPE.
  520. *
  521. * Typical work flow:
  522. *
  523. * IF NOT i40evf_ptype_lookup[ptype].known
  524. * THEN
  525. * Packet is unknown
  526. * ELSE IF i40evf_ptype_lookup[ptype].outer_ip == I40E_RX_PTYPE_OUTER_IP
  527. * Use the rest of the fields to look at the tunnels, inner protocols, etc
  528. * ELSE
  529. * Use the enum i40e_rx_l2_ptype to decode the packet type
  530. * ENDIF
  531. */
  532. /* macro to make the table lines short */
  533. #define I40E_PTT(PTYPE, OUTER_IP, OUTER_IP_VER, OUTER_FRAG, T, TE, TEF, I, PL)\
  534. { PTYPE, \
  535. 1, \
  536. I40E_RX_PTYPE_OUTER_##OUTER_IP, \
  537. I40E_RX_PTYPE_OUTER_##OUTER_IP_VER, \
  538. I40E_RX_PTYPE_##OUTER_FRAG, \
  539. I40E_RX_PTYPE_TUNNEL_##T, \
  540. I40E_RX_PTYPE_TUNNEL_END_##TE, \
  541. I40E_RX_PTYPE_##TEF, \
  542. I40E_RX_PTYPE_INNER_PROT_##I, \
  543. I40E_RX_PTYPE_PAYLOAD_LAYER_##PL }
  544. #define I40E_PTT_UNUSED_ENTRY(PTYPE) \
  545. { PTYPE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
  546. /* shorter macros makes the table fit but are terse */
  547. #define I40E_RX_PTYPE_NOF I40E_RX_PTYPE_NOT_FRAG
  548. #define I40E_RX_PTYPE_FRG I40E_RX_PTYPE_FRAG
  549. #define I40E_RX_PTYPE_INNER_PROT_TS I40E_RX_PTYPE_INNER_PROT_TIMESYNC
  550. /* Lookup table mapping the HW PTYPE to the bit field for decoding */
  551. struct i40e_rx_ptype_decoded i40evf_ptype_lookup[] = {
  552. /* L2 Packet types */
  553. I40E_PTT_UNUSED_ENTRY(0),
  554. I40E_PTT(1, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
  555. I40E_PTT(2, L2, NONE, NOF, NONE, NONE, NOF, TS, PAY2),
  556. I40E_PTT(3, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
  557. I40E_PTT_UNUSED_ENTRY(4),
  558. I40E_PTT_UNUSED_ENTRY(5),
  559. I40E_PTT(6, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
  560. I40E_PTT(7, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
  561. I40E_PTT_UNUSED_ENTRY(8),
  562. I40E_PTT_UNUSED_ENTRY(9),
  563. I40E_PTT(10, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
  564. I40E_PTT(11, L2, NONE, NOF, NONE, NONE, NOF, NONE, NONE),
  565. I40E_PTT(12, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  566. I40E_PTT(13, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  567. I40E_PTT(14, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  568. I40E_PTT(15, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  569. I40E_PTT(16, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  570. I40E_PTT(17, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  571. I40E_PTT(18, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  572. I40E_PTT(19, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  573. I40E_PTT(20, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  574. I40E_PTT(21, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  575. /* Non Tunneled IPv4 */
  576. I40E_PTT(22, IP, IPV4, FRG, NONE, NONE, NOF, NONE, PAY3),
  577. I40E_PTT(23, IP, IPV4, NOF, NONE, NONE, NOF, NONE, PAY3),
  578. I40E_PTT(24, IP, IPV4, NOF, NONE, NONE, NOF, UDP, PAY4),
  579. I40E_PTT_UNUSED_ENTRY(25),
  580. I40E_PTT(26, IP, IPV4, NOF, NONE, NONE, NOF, TCP, PAY4),
  581. I40E_PTT(27, IP, IPV4, NOF, NONE, NONE, NOF, SCTP, PAY4),
  582. I40E_PTT(28, IP, IPV4, NOF, NONE, NONE, NOF, ICMP, PAY4),
  583. /* IPv4 --> IPv4 */
  584. I40E_PTT(29, IP, IPV4, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
  585. I40E_PTT(30, IP, IPV4, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
  586. I40E_PTT(31, IP, IPV4, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
  587. I40E_PTT_UNUSED_ENTRY(32),
  588. I40E_PTT(33, IP, IPV4, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
  589. I40E_PTT(34, IP, IPV4, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
  590. I40E_PTT(35, IP, IPV4, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
  591. /* IPv4 --> IPv6 */
  592. I40E_PTT(36, IP, IPV4, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
  593. I40E_PTT(37, IP, IPV4, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
  594. I40E_PTT(38, IP, IPV4, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
  595. I40E_PTT_UNUSED_ENTRY(39),
  596. I40E_PTT(40, IP, IPV4, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
  597. I40E_PTT(41, IP, IPV4, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
  598. I40E_PTT(42, IP, IPV4, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
  599. /* IPv4 --> GRE/NAT */
  600. I40E_PTT(43, IP, IPV4, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
  601. /* IPv4 --> GRE/NAT --> IPv4 */
  602. I40E_PTT(44, IP, IPV4, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
  603. I40E_PTT(45, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
  604. I40E_PTT(46, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
  605. I40E_PTT_UNUSED_ENTRY(47),
  606. I40E_PTT(48, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
  607. I40E_PTT(49, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
  608. I40E_PTT(50, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
  609. /* IPv4 --> GRE/NAT --> IPv6 */
  610. I40E_PTT(51, IP, IPV4, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
  611. I40E_PTT(52, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
  612. I40E_PTT(53, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
  613. I40E_PTT_UNUSED_ENTRY(54),
  614. I40E_PTT(55, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
  615. I40E_PTT(56, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
  616. I40E_PTT(57, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
  617. /* IPv4 --> GRE/NAT --> MAC */
  618. I40E_PTT(58, IP, IPV4, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
  619. /* IPv4 --> GRE/NAT --> MAC --> IPv4 */
  620. I40E_PTT(59, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
  621. I40E_PTT(60, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
  622. I40E_PTT(61, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
  623. I40E_PTT_UNUSED_ENTRY(62),
  624. I40E_PTT(63, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
  625. I40E_PTT(64, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
  626. I40E_PTT(65, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
  627. /* IPv4 --> GRE/NAT -> MAC --> IPv6 */
  628. I40E_PTT(66, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
  629. I40E_PTT(67, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
  630. I40E_PTT(68, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
  631. I40E_PTT_UNUSED_ENTRY(69),
  632. I40E_PTT(70, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
  633. I40E_PTT(71, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
  634. I40E_PTT(72, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
  635. /* IPv4 --> GRE/NAT --> MAC/VLAN */
  636. I40E_PTT(73, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
  637. /* IPv4 ---> GRE/NAT -> MAC/VLAN --> IPv4 */
  638. I40E_PTT(74, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
  639. I40E_PTT(75, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
  640. I40E_PTT(76, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
  641. I40E_PTT_UNUSED_ENTRY(77),
  642. I40E_PTT(78, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
  643. I40E_PTT(79, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
  644. I40E_PTT(80, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
  645. /* IPv4 -> GRE/NAT -> MAC/VLAN --> IPv6 */
  646. I40E_PTT(81, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
  647. I40E_PTT(82, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
  648. I40E_PTT(83, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
  649. I40E_PTT_UNUSED_ENTRY(84),
  650. I40E_PTT(85, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
  651. I40E_PTT(86, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
  652. I40E_PTT(87, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
  653. /* Non Tunneled IPv6 */
  654. I40E_PTT(88, IP, IPV6, FRG, NONE, NONE, NOF, NONE, PAY3),
  655. I40E_PTT(89, IP, IPV6, NOF, NONE, NONE, NOF, NONE, PAY3),
  656. I40E_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP, PAY3),
  657. I40E_PTT_UNUSED_ENTRY(91),
  658. I40E_PTT(92, IP, IPV6, NOF, NONE, NONE, NOF, TCP, PAY4),
  659. I40E_PTT(93, IP, IPV6, NOF, NONE, NONE, NOF, SCTP, PAY4),
  660. I40E_PTT(94, IP, IPV6, NOF, NONE, NONE, NOF, ICMP, PAY4),
  661. /* IPv6 --> IPv4 */
  662. I40E_PTT(95, IP, IPV6, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
  663. I40E_PTT(96, IP, IPV6, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
  664. I40E_PTT(97, IP, IPV6, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
  665. I40E_PTT_UNUSED_ENTRY(98),
  666. I40E_PTT(99, IP, IPV6, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
  667. I40E_PTT(100, IP, IPV6, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
  668. I40E_PTT(101, IP, IPV6, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
  669. /* IPv6 --> IPv6 */
  670. I40E_PTT(102, IP, IPV6, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
  671. I40E_PTT(103, IP, IPV6, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
  672. I40E_PTT(104, IP, IPV6, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
  673. I40E_PTT_UNUSED_ENTRY(105),
  674. I40E_PTT(106, IP, IPV6, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
  675. I40E_PTT(107, IP, IPV6, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
  676. I40E_PTT(108, IP, IPV6, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
  677. /* IPv6 --> GRE/NAT */
  678. I40E_PTT(109, IP, IPV6, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
  679. /* IPv6 --> GRE/NAT -> IPv4 */
  680. I40E_PTT(110, IP, IPV6, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
  681. I40E_PTT(111, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
  682. I40E_PTT(112, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
  683. I40E_PTT_UNUSED_ENTRY(113),
  684. I40E_PTT(114, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
  685. I40E_PTT(115, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
  686. I40E_PTT(116, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
  687. /* IPv6 --> GRE/NAT -> IPv6 */
  688. I40E_PTT(117, IP, IPV6, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
  689. I40E_PTT(118, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
  690. I40E_PTT(119, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
  691. I40E_PTT_UNUSED_ENTRY(120),
  692. I40E_PTT(121, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
  693. I40E_PTT(122, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
  694. I40E_PTT(123, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
  695. /* IPv6 --> GRE/NAT -> MAC */
  696. I40E_PTT(124, IP, IPV6, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
  697. /* IPv6 --> GRE/NAT -> MAC -> IPv4 */
  698. I40E_PTT(125, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
  699. I40E_PTT(126, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
  700. I40E_PTT(127, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
  701. I40E_PTT_UNUSED_ENTRY(128),
  702. I40E_PTT(129, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
  703. I40E_PTT(130, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
  704. I40E_PTT(131, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
  705. /* IPv6 --> GRE/NAT -> MAC -> IPv6 */
  706. I40E_PTT(132, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
  707. I40E_PTT(133, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
  708. I40E_PTT(134, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
  709. I40E_PTT_UNUSED_ENTRY(135),
  710. I40E_PTT(136, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
  711. I40E_PTT(137, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
  712. I40E_PTT(138, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
  713. /* IPv6 --> GRE/NAT -> MAC/VLAN */
  714. I40E_PTT(139, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
  715. /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv4 */
  716. I40E_PTT(140, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
  717. I40E_PTT(141, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
  718. I40E_PTT(142, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
  719. I40E_PTT_UNUSED_ENTRY(143),
  720. I40E_PTT(144, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
  721. I40E_PTT(145, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
  722. I40E_PTT(146, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
  723. /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv6 */
  724. I40E_PTT(147, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
  725. I40E_PTT(148, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
  726. I40E_PTT(149, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
  727. I40E_PTT_UNUSED_ENTRY(150),
  728. I40E_PTT(151, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
  729. I40E_PTT(152, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
  730. I40E_PTT(153, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
  731. /* unused entries */
  732. I40E_PTT_UNUSED_ENTRY(154),
  733. I40E_PTT_UNUSED_ENTRY(155),
  734. I40E_PTT_UNUSED_ENTRY(156),
  735. I40E_PTT_UNUSED_ENTRY(157),
  736. I40E_PTT_UNUSED_ENTRY(158),
  737. I40E_PTT_UNUSED_ENTRY(159),
  738. I40E_PTT_UNUSED_ENTRY(160),
  739. I40E_PTT_UNUSED_ENTRY(161),
  740. I40E_PTT_UNUSED_ENTRY(162),
  741. I40E_PTT_UNUSED_ENTRY(163),
  742. I40E_PTT_UNUSED_ENTRY(164),
  743. I40E_PTT_UNUSED_ENTRY(165),
  744. I40E_PTT_UNUSED_ENTRY(166),
  745. I40E_PTT_UNUSED_ENTRY(167),
  746. I40E_PTT_UNUSED_ENTRY(168),
  747. I40E_PTT_UNUSED_ENTRY(169),
  748. I40E_PTT_UNUSED_ENTRY(170),
  749. I40E_PTT_UNUSED_ENTRY(171),
  750. I40E_PTT_UNUSED_ENTRY(172),
  751. I40E_PTT_UNUSED_ENTRY(173),
  752. I40E_PTT_UNUSED_ENTRY(174),
  753. I40E_PTT_UNUSED_ENTRY(175),
  754. I40E_PTT_UNUSED_ENTRY(176),
  755. I40E_PTT_UNUSED_ENTRY(177),
  756. I40E_PTT_UNUSED_ENTRY(178),
  757. I40E_PTT_UNUSED_ENTRY(179),
  758. I40E_PTT_UNUSED_ENTRY(180),
  759. I40E_PTT_UNUSED_ENTRY(181),
  760. I40E_PTT_UNUSED_ENTRY(182),
  761. I40E_PTT_UNUSED_ENTRY(183),
  762. I40E_PTT_UNUSED_ENTRY(184),
  763. I40E_PTT_UNUSED_ENTRY(185),
  764. I40E_PTT_UNUSED_ENTRY(186),
  765. I40E_PTT_UNUSED_ENTRY(187),
  766. I40E_PTT_UNUSED_ENTRY(188),
  767. I40E_PTT_UNUSED_ENTRY(189),
  768. I40E_PTT_UNUSED_ENTRY(190),
  769. I40E_PTT_UNUSED_ENTRY(191),
  770. I40E_PTT_UNUSED_ENTRY(192),
  771. I40E_PTT_UNUSED_ENTRY(193),
  772. I40E_PTT_UNUSED_ENTRY(194),
  773. I40E_PTT_UNUSED_ENTRY(195),
  774. I40E_PTT_UNUSED_ENTRY(196),
  775. I40E_PTT_UNUSED_ENTRY(197),
  776. I40E_PTT_UNUSED_ENTRY(198),
  777. I40E_PTT_UNUSED_ENTRY(199),
  778. I40E_PTT_UNUSED_ENTRY(200),
  779. I40E_PTT_UNUSED_ENTRY(201),
  780. I40E_PTT_UNUSED_ENTRY(202),
  781. I40E_PTT_UNUSED_ENTRY(203),
  782. I40E_PTT_UNUSED_ENTRY(204),
  783. I40E_PTT_UNUSED_ENTRY(205),
  784. I40E_PTT_UNUSED_ENTRY(206),
  785. I40E_PTT_UNUSED_ENTRY(207),
  786. I40E_PTT_UNUSED_ENTRY(208),
  787. I40E_PTT_UNUSED_ENTRY(209),
  788. I40E_PTT_UNUSED_ENTRY(210),
  789. I40E_PTT_UNUSED_ENTRY(211),
  790. I40E_PTT_UNUSED_ENTRY(212),
  791. I40E_PTT_UNUSED_ENTRY(213),
  792. I40E_PTT_UNUSED_ENTRY(214),
  793. I40E_PTT_UNUSED_ENTRY(215),
  794. I40E_PTT_UNUSED_ENTRY(216),
  795. I40E_PTT_UNUSED_ENTRY(217),
  796. I40E_PTT_UNUSED_ENTRY(218),
  797. I40E_PTT_UNUSED_ENTRY(219),
  798. I40E_PTT_UNUSED_ENTRY(220),
  799. I40E_PTT_UNUSED_ENTRY(221),
  800. I40E_PTT_UNUSED_ENTRY(222),
  801. I40E_PTT_UNUSED_ENTRY(223),
  802. I40E_PTT_UNUSED_ENTRY(224),
  803. I40E_PTT_UNUSED_ENTRY(225),
  804. I40E_PTT_UNUSED_ENTRY(226),
  805. I40E_PTT_UNUSED_ENTRY(227),
  806. I40E_PTT_UNUSED_ENTRY(228),
  807. I40E_PTT_UNUSED_ENTRY(229),
  808. I40E_PTT_UNUSED_ENTRY(230),
  809. I40E_PTT_UNUSED_ENTRY(231),
  810. I40E_PTT_UNUSED_ENTRY(232),
  811. I40E_PTT_UNUSED_ENTRY(233),
  812. I40E_PTT_UNUSED_ENTRY(234),
  813. I40E_PTT_UNUSED_ENTRY(235),
  814. I40E_PTT_UNUSED_ENTRY(236),
  815. I40E_PTT_UNUSED_ENTRY(237),
  816. I40E_PTT_UNUSED_ENTRY(238),
  817. I40E_PTT_UNUSED_ENTRY(239),
  818. I40E_PTT_UNUSED_ENTRY(240),
  819. I40E_PTT_UNUSED_ENTRY(241),
  820. I40E_PTT_UNUSED_ENTRY(242),
  821. I40E_PTT_UNUSED_ENTRY(243),
  822. I40E_PTT_UNUSED_ENTRY(244),
  823. I40E_PTT_UNUSED_ENTRY(245),
  824. I40E_PTT_UNUSED_ENTRY(246),
  825. I40E_PTT_UNUSED_ENTRY(247),
  826. I40E_PTT_UNUSED_ENTRY(248),
  827. I40E_PTT_UNUSED_ENTRY(249),
  828. I40E_PTT_UNUSED_ENTRY(250),
  829. I40E_PTT_UNUSED_ENTRY(251),
  830. I40E_PTT_UNUSED_ENTRY(252),
  831. I40E_PTT_UNUSED_ENTRY(253),
  832. I40E_PTT_UNUSED_ENTRY(254),
  833. I40E_PTT_UNUSED_ENTRY(255)
  834. };
  835. /**
  836. * i40evf_aq_rx_ctl_read_register - use FW to read from an Rx control register
  837. * @hw: pointer to the hw struct
  838. * @reg_addr: register address
  839. * @reg_val: ptr to register value
  840. * @cmd_details: pointer to command details structure or NULL
  841. *
  842. * Use the firmware to read the Rx control register,
  843. * especially useful if the Rx unit is under heavy pressure
  844. **/
  845. i40e_status i40evf_aq_rx_ctl_read_register(struct i40e_hw *hw,
  846. u32 reg_addr, u32 *reg_val,
  847. struct i40e_asq_cmd_details *cmd_details)
  848. {
  849. struct i40e_aq_desc desc;
  850. struct i40e_aqc_rx_ctl_reg_read_write *cmd_resp =
  851. (struct i40e_aqc_rx_ctl_reg_read_write *)&desc.params.raw;
  852. i40e_status status;
  853. if (!reg_val)
  854. return I40E_ERR_PARAM;
  855. i40evf_fill_default_direct_cmd_desc(&desc,
  856. i40e_aqc_opc_rx_ctl_reg_read);
  857. cmd_resp->address = cpu_to_le32(reg_addr);
  858. status = i40evf_asq_send_command(hw, &desc, NULL, 0, cmd_details);
  859. if (status == 0)
  860. *reg_val = le32_to_cpu(cmd_resp->value);
  861. return status;
  862. }
  863. /**
  864. * i40evf_read_rx_ctl - read from an Rx control register
  865. * @hw: pointer to the hw struct
  866. * @reg_addr: register address
  867. **/
  868. u32 i40evf_read_rx_ctl(struct i40e_hw *hw, u32 reg_addr)
  869. {
  870. i40e_status status = 0;
  871. bool use_register;
  872. int retry = 5;
  873. u32 val = 0;
  874. use_register = (((hw->aq.api_maj_ver == 1) &&
  875. (hw->aq.api_min_ver < 5)) ||
  876. (hw->mac.type == I40E_MAC_X722));
  877. if (!use_register) {
  878. do_retry:
  879. status = i40evf_aq_rx_ctl_read_register(hw, reg_addr,
  880. &val, NULL);
  881. if (hw->aq.asq_last_status == I40E_AQ_RC_EAGAIN && retry) {
  882. usleep_range(1000, 2000);
  883. retry--;
  884. goto do_retry;
  885. }
  886. }
  887. /* if the AQ access failed, try the old-fashioned way */
  888. if (status || use_register)
  889. val = rd32(hw, reg_addr);
  890. return val;
  891. }
  892. /**
  893. * i40evf_aq_rx_ctl_write_register
  894. * @hw: pointer to the hw struct
  895. * @reg_addr: register address
  896. * @reg_val: register value
  897. * @cmd_details: pointer to command details structure or NULL
  898. *
  899. * Use the firmware to write to an Rx control register,
  900. * especially useful if the Rx unit is under heavy pressure
  901. **/
  902. i40e_status i40evf_aq_rx_ctl_write_register(struct i40e_hw *hw,
  903. u32 reg_addr, u32 reg_val,
  904. struct i40e_asq_cmd_details *cmd_details)
  905. {
  906. struct i40e_aq_desc desc;
  907. struct i40e_aqc_rx_ctl_reg_read_write *cmd =
  908. (struct i40e_aqc_rx_ctl_reg_read_write *)&desc.params.raw;
  909. i40e_status status;
  910. i40evf_fill_default_direct_cmd_desc(&desc,
  911. i40e_aqc_opc_rx_ctl_reg_write);
  912. cmd->address = cpu_to_le32(reg_addr);
  913. cmd->value = cpu_to_le32(reg_val);
  914. status = i40evf_asq_send_command(hw, &desc, NULL, 0, cmd_details);
  915. return status;
  916. }
  917. /**
  918. * i40evf_write_rx_ctl - write to an Rx control register
  919. * @hw: pointer to the hw struct
  920. * @reg_addr: register address
  921. * @reg_val: register value
  922. **/
  923. void i40evf_write_rx_ctl(struct i40e_hw *hw, u32 reg_addr, u32 reg_val)
  924. {
  925. i40e_status status = 0;
  926. bool use_register;
  927. int retry = 5;
  928. use_register = (((hw->aq.api_maj_ver == 1) &&
  929. (hw->aq.api_min_ver < 5)) ||
  930. (hw->mac.type == I40E_MAC_X722));
  931. if (!use_register) {
  932. do_retry:
  933. status = i40evf_aq_rx_ctl_write_register(hw, reg_addr,
  934. reg_val, NULL);
  935. if (hw->aq.asq_last_status == I40E_AQ_RC_EAGAIN && retry) {
  936. usleep_range(1000, 2000);
  937. retry--;
  938. goto do_retry;
  939. }
  940. }
  941. /* if the AQ access failed, try the old-fashioned way */
  942. if (status || use_register)
  943. wr32(hw, reg_addr, reg_val);
  944. }
  945. /**
  946. * i40e_aq_send_msg_to_pf
  947. * @hw: pointer to the hardware structure
  948. * @v_opcode: opcodes for VF-PF communication
  949. * @v_retval: return error code
  950. * @msg: pointer to the msg buffer
  951. * @msglen: msg length
  952. * @cmd_details: pointer to command details
  953. *
  954. * Send message to PF driver using admin queue. By default, this message
  955. * is sent asynchronously, i.e. i40evf_asq_send_command() does not wait for
  956. * completion before returning.
  957. **/
  958. i40e_status i40e_aq_send_msg_to_pf(struct i40e_hw *hw,
  959. enum i40e_virtchnl_ops v_opcode,
  960. i40e_status v_retval,
  961. u8 *msg, u16 msglen,
  962. struct i40e_asq_cmd_details *cmd_details)
  963. {
  964. struct i40e_aq_desc desc;
  965. struct i40e_asq_cmd_details details;
  966. i40e_status status;
  967. i40evf_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_send_msg_to_pf);
  968. desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_SI);
  969. desc.cookie_high = cpu_to_le32(v_opcode);
  970. desc.cookie_low = cpu_to_le32(v_retval);
  971. if (msglen) {
  972. desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF
  973. | I40E_AQ_FLAG_RD));
  974. if (msglen > I40E_AQ_LARGE_BUF)
  975. desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
  976. desc.datalen = cpu_to_le16(msglen);
  977. }
  978. if (!cmd_details) {
  979. memset(&details, 0, sizeof(details));
  980. details.async = true;
  981. cmd_details = &details;
  982. }
  983. status = i40evf_asq_send_command(hw, &desc, msg, msglen, cmd_details);
  984. return status;
  985. }
  986. /**
  987. * i40e_vf_parse_hw_config
  988. * @hw: pointer to the hardware structure
  989. * @msg: pointer to the virtual channel VF resource structure
  990. *
  991. * Given a VF resource message from the PF, populate the hw struct
  992. * with appropriate information.
  993. **/
  994. void i40e_vf_parse_hw_config(struct i40e_hw *hw,
  995. struct i40e_virtchnl_vf_resource *msg)
  996. {
  997. struct i40e_virtchnl_vsi_resource *vsi_res;
  998. int i;
  999. vsi_res = &msg->vsi_res[0];
  1000. hw->dev_caps.num_vsis = msg->num_vsis;
  1001. hw->dev_caps.num_rx_qp = msg->num_queue_pairs;
  1002. hw->dev_caps.num_tx_qp = msg->num_queue_pairs;
  1003. hw->dev_caps.num_msix_vectors_vf = msg->max_vectors;
  1004. hw->dev_caps.dcb = msg->vf_offload_flags &
  1005. I40E_VIRTCHNL_VF_OFFLOAD_L2;
  1006. hw->dev_caps.fcoe = (msg->vf_offload_flags &
  1007. I40E_VIRTCHNL_VF_OFFLOAD_FCOE) ? 1 : 0;
  1008. for (i = 0; i < msg->num_vsis; i++) {
  1009. if (vsi_res->vsi_type == I40E_VSI_SRIOV) {
  1010. ether_addr_copy(hw->mac.perm_addr,
  1011. vsi_res->default_mac_addr);
  1012. ether_addr_copy(hw->mac.addr,
  1013. vsi_res->default_mac_addr);
  1014. }
  1015. vsi_res++;
  1016. }
  1017. }
  1018. /**
  1019. * i40e_vf_reset
  1020. * @hw: pointer to the hardware structure
  1021. *
  1022. * Send a VF_RESET message to the PF. Does not wait for response from PF
  1023. * as none will be forthcoming. Immediately after calling this function,
  1024. * the admin queue should be shut down and (optionally) reinitialized.
  1025. **/
  1026. i40e_status i40e_vf_reset(struct i40e_hw *hw)
  1027. {
  1028. return i40e_aq_send_msg_to_pf(hw, I40E_VIRTCHNL_OP_RESET_VF,
  1029. 0, NULL, 0, NULL);
  1030. }
  1031. /**
  1032. * i40evf_aq_write_ppp - Write pipeline personalization profile (ppp)
  1033. * @hw: pointer to the hw struct
  1034. * @buff: command buffer (size in bytes = buff_size)
  1035. * @buff_size: buffer size in bytes
  1036. * @track_id: package tracking id
  1037. * @error_offset: returns error offset
  1038. * @error_info: returns error information
  1039. * @cmd_details: pointer to command details structure or NULL
  1040. **/
  1041. enum
  1042. i40e_status_code i40evf_aq_write_ppp(struct i40e_hw *hw, void *buff,
  1043. u16 buff_size, u32 track_id,
  1044. u32 *error_offset, u32 *error_info,
  1045. struct i40e_asq_cmd_details *cmd_details)
  1046. {
  1047. struct i40e_aq_desc desc;
  1048. struct i40e_aqc_write_personalization_profile *cmd =
  1049. (struct i40e_aqc_write_personalization_profile *)
  1050. &desc.params.raw;
  1051. struct i40e_aqc_write_ppp_resp *resp;
  1052. i40e_status status;
  1053. i40evf_fill_default_direct_cmd_desc(&desc,
  1054. i40e_aqc_opc_write_personalization_profile);
  1055. desc.flags |= cpu_to_le16(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD);
  1056. if (buff_size > I40E_AQ_LARGE_BUF)
  1057. desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
  1058. desc.datalen = cpu_to_le16(buff_size);
  1059. cmd->profile_track_id = cpu_to_le32(track_id);
  1060. status = i40evf_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
  1061. if (!status) {
  1062. resp = (struct i40e_aqc_write_ppp_resp *)&desc.params.raw;
  1063. if (error_offset)
  1064. *error_offset = le32_to_cpu(resp->error_offset);
  1065. if (error_info)
  1066. *error_info = le32_to_cpu(resp->error_info);
  1067. }
  1068. return status;
  1069. }
  1070. /**
  1071. * i40evf_aq_get_ppp_list - Read pipeline personalization profile (ppp)
  1072. * @hw: pointer to the hw struct
  1073. * @buff: command buffer (size in bytes = buff_size)
  1074. * @buff_size: buffer size in bytes
  1075. * @cmd_details: pointer to command details structure or NULL
  1076. **/
  1077. enum
  1078. i40e_status_code i40evf_aq_get_ppp_list(struct i40e_hw *hw, void *buff,
  1079. u16 buff_size, u8 flags,
  1080. struct i40e_asq_cmd_details *cmd_details)
  1081. {
  1082. struct i40e_aq_desc desc;
  1083. struct i40e_aqc_get_applied_profiles *cmd =
  1084. (struct i40e_aqc_get_applied_profiles *)&desc.params.raw;
  1085. i40e_status status;
  1086. i40evf_fill_default_direct_cmd_desc(&desc,
  1087. i40e_aqc_opc_get_personalization_profile_list);
  1088. desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
  1089. if (buff_size > I40E_AQ_LARGE_BUF)
  1090. desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
  1091. desc.datalen = cpu_to_le16(buff_size);
  1092. cmd->flags = flags;
  1093. status = i40evf_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
  1094. return status;
  1095. }
  1096. /**
  1097. * i40evf_find_segment_in_package
  1098. * @segment_type: the segment type to search for (i.e., SEGMENT_TYPE_I40E)
  1099. * @pkg_hdr: pointer to the package header to be searched
  1100. *
  1101. * This function searches a package file for a particular segment type. On
  1102. * success it returns a pointer to the segment header, otherwise it will
  1103. * return NULL.
  1104. **/
  1105. struct i40e_generic_seg_header *
  1106. i40evf_find_segment_in_package(u32 segment_type,
  1107. struct i40e_package_header *pkg_hdr)
  1108. {
  1109. struct i40e_generic_seg_header *segment;
  1110. u32 i;
  1111. /* Search all package segments for the requested segment type */
  1112. for (i = 0; i < pkg_hdr->segment_count; i++) {
  1113. segment =
  1114. (struct i40e_generic_seg_header *)((u8 *)pkg_hdr +
  1115. pkg_hdr->segment_offset[i]);
  1116. if (segment->type == segment_type)
  1117. return segment;
  1118. }
  1119. return NULL;
  1120. }
  1121. /**
  1122. * i40evf_write_profile
  1123. * @hw: pointer to the hardware structure
  1124. * @profile: pointer to the profile segment of the package to be downloaded
  1125. * @track_id: package tracking id
  1126. *
  1127. * Handles the download of a complete package.
  1128. */
  1129. enum i40e_status_code
  1130. i40evf_write_profile(struct i40e_hw *hw, struct i40e_profile_segment *profile,
  1131. u32 track_id)
  1132. {
  1133. i40e_status status = 0;
  1134. struct i40e_section_table *sec_tbl;
  1135. struct i40e_profile_section_header *sec = NULL;
  1136. u32 dev_cnt;
  1137. u32 vendor_dev_id;
  1138. u32 *nvm;
  1139. u32 section_size = 0;
  1140. u32 offset = 0, info = 0;
  1141. u32 i;
  1142. if (!track_id) {
  1143. i40e_debug(hw, I40E_DEBUG_PACKAGE, "Track_id can't be 0.");
  1144. return I40E_NOT_SUPPORTED;
  1145. }
  1146. dev_cnt = profile->device_table_count;
  1147. for (i = 0; i < dev_cnt; i++) {
  1148. vendor_dev_id = profile->device_table[i].vendor_dev_id;
  1149. if ((vendor_dev_id >> 16) == PCI_VENDOR_ID_INTEL)
  1150. if (hw->device_id == (vendor_dev_id & 0xFFFF))
  1151. break;
  1152. }
  1153. if (i == dev_cnt) {
  1154. i40e_debug(hw, I40E_DEBUG_PACKAGE, "Device doesn't support PPP");
  1155. return I40E_ERR_DEVICE_NOT_SUPPORTED;
  1156. }
  1157. nvm = (u32 *)&profile->device_table[dev_cnt];
  1158. sec_tbl = (struct i40e_section_table *)&nvm[nvm[0] + 1];
  1159. for (i = 0; i < sec_tbl->section_count; i++) {
  1160. sec = (struct i40e_profile_section_header *)((u8 *)profile +
  1161. sec_tbl->section_offset[i]);
  1162. /* Skip 'AQ', 'note' and 'name' sections */
  1163. if (sec->section.type != SECTION_TYPE_MMIO)
  1164. continue;
  1165. section_size = sec->section.size +
  1166. sizeof(struct i40e_profile_section_header);
  1167. /* Write profile */
  1168. status = i40evf_aq_write_ppp(hw, (void *)sec, (u16)section_size,
  1169. track_id, &offset, &info, NULL);
  1170. if (status) {
  1171. i40e_debug(hw, I40E_DEBUG_PACKAGE,
  1172. "Failed to write profile: offset %d, info %d",
  1173. offset, info);
  1174. break;
  1175. }
  1176. }
  1177. return status;
  1178. }
  1179. /**
  1180. * i40evf_add_pinfo_to_list
  1181. * @hw: pointer to the hardware structure
  1182. * @profile: pointer to the profile segment of the package
  1183. * @profile_info_sec: buffer for information section
  1184. * @track_id: package tracking id
  1185. *
  1186. * Register a profile to the list of loaded profiles.
  1187. */
  1188. enum i40e_status_code
  1189. i40evf_add_pinfo_to_list(struct i40e_hw *hw,
  1190. struct i40e_profile_segment *profile,
  1191. u8 *profile_info_sec, u32 track_id)
  1192. {
  1193. i40e_status status = 0;
  1194. struct i40e_profile_section_header *sec = NULL;
  1195. struct i40e_profile_info *pinfo;
  1196. u32 offset = 0, info = 0;
  1197. sec = (struct i40e_profile_section_header *)profile_info_sec;
  1198. sec->tbl_size = 1;
  1199. sec->data_end = sizeof(struct i40e_profile_section_header) +
  1200. sizeof(struct i40e_profile_info);
  1201. sec->section.type = SECTION_TYPE_INFO;
  1202. sec->section.offset = sizeof(struct i40e_profile_section_header);
  1203. sec->section.size = sizeof(struct i40e_profile_info);
  1204. pinfo = (struct i40e_profile_info *)(profile_info_sec +
  1205. sec->section.offset);
  1206. pinfo->track_id = track_id;
  1207. pinfo->version = profile->version;
  1208. pinfo->op = I40E_PPP_ADD_TRACKID;
  1209. memcpy(pinfo->name, profile->name, I40E_PPP_NAME_SIZE);
  1210. status = i40evf_aq_write_ppp(hw, (void *)sec, sec->data_end,
  1211. track_id, &offset, &info, NULL);
  1212. return status;
  1213. }