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 <linux/avf/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. case I40E_DEV_ID_ADAPTIVE_VF:
  69. hw->mac.type = I40E_MAC_VF;
  70. break;
  71. default:
  72. hw->mac.type = I40E_MAC_GENERIC;
  73. break;
  74. }
  75. } else {
  76. status = I40E_ERR_DEVICE_NOT_SUPPORTED;
  77. }
  78. hw_dbg(hw, "i40e_set_mac_type found mac: %d, returns: %d\n",
  79. hw->mac.type, status);
  80. return status;
  81. }
  82. /**
  83. * i40evf_aq_str - convert AQ err code to a string
  84. * @hw: pointer to the HW structure
  85. * @aq_err: the AQ error code to convert
  86. **/
  87. const char *i40evf_aq_str(struct i40e_hw *hw, enum i40e_admin_queue_err aq_err)
  88. {
  89. switch (aq_err) {
  90. case I40E_AQ_RC_OK:
  91. return "OK";
  92. case I40E_AQ_RC_EPERM:
  93. return "I40E_AQ_RC_EPERM";
  94. case I40E_AQ_RC_ENOENT:
  95. return "I40E_AQ_RC_ENOENT";
  96. case I40E_AQ_RC_ESRCH:
  97. return "I40E_AQ_RC_ESRCH";
  98. case I40E_AQ_RC_EINTR:
  99. return "I40E_AQ_RC_EINTR";
  100. case I40E_AQ_RC_EIO:
  101. return "I40E_AQ_RC_EIO";
  102. case I40E_AQ_RC_ENXIO:
  103. return "I40E_AQ_RC_ENXIO";
  104. case I40E_AQ_RC_E2BIG:
  105. return "I40E_AQ_RC_E2BIG";
  106. case I40E_AQ_RC_EAGAIN:
  107. return "I40E_AQ_RC_EAGAIN";
  108. case I40E_AQ_RC_ENOMEM:
  109. return "I40E_AQ_RC_ENOMEM";
  110. case I40E_AQ_RC_EACCES:
  111. return "I40E_AQ_RC_EACCES";
  112. case I40E_AQ_RC_EFAULT:
  113. return "I40E_AQ_RC_EFAULT";
  114. case I40E_AQ_RC_EBUSY:
  115. return "I40E_AQ_RC_EBUSY";
  116. case I40E_AQ_RC_EEXIST:
  117. return "I40E_AQ_RC_EEXIST";
  118. case I40E_AQ_RC_EINVAL:
  119. return "I40E_AQ_RC_EINVAL";
  120. case I40E_AQ_RC_ENOTTY:
  121. return "I40E_AQ_RC_ENOTTY";
  122. case I40E_AQ_RC_ENOSPC:
  123. return "I40E_AQ_RC_ENOSPC";
  124. case I40E_AQ_RC_ENOSYS:
  125. return "I40E_AQ_RC_ENOSYS";
  126. case I40E_AQ_RC_ERANGE:
  127. return "I40E_AQ_RC_ERANGE";
  128. case I40E_AQ_RC_EFLUSHED:
  129. return "I40E_AQ_RC_EFLUSHED";
  130. case I40E_AQ_RC_BAD_ADDR:
  131. return "I40E_AQ_RC_BAD_ADDR";
  132. case I40E_AQ_RC_EMODE:
  133. return "I40E_AQ_RC_EMODE";
  134. case I40E_AQ_RC_EFBIG:
  135. return "I40E_AQ_RC_EFBIG";
  136. }
  137. snprintf(hw->err_str, sizeof(hw->err_str), "%d", aq_err);
  138. return hw->err_str;
  139. }
  140. /**
  141. * i40evf_stat_str - convert status err code to a string
  142. * @hw: pointer to the HW structure
  143. * @stat_err: the status error code to convert
  144. **/
  145. const char *i40evf_stat_str(struct i40e_hw *hw, i40e_status stat_err)
  146. {
  147. switch (stat_err) {
  148. case 0:
  149. return "OK";
  150. case I40E_ERR_NVM:
  151. return "I40E_ERR_NVM";
  152. case I40E_ERR_NVM_CHECKSUM:
  153. return "I40E_ERR_NVM_CHECKSUM";
  154. case I40E_ERR_PHY:
  155. return "I40E_ERR_PHY";
  156. case I40E_ERR_CONFIG:
  157. return "I40E_ERR_CONFIG";
  158. case I40E_ERR_PARAM:
  159. return "I40E_ERR_PARAM";
  160. case I40E_ERR_MAC_TYPE:
  161. return "I40E_ERR_MAC_TYPE";
  162. case I40E_ERR_UNKNOWN_PHY:
  163. return "I40E_ERR_UNKNOWN_PHY";
  164. case I40E_ERR_LINK_SETUP:
  165. return "I40E_ERR_LINK_SETUP";
  166. case I40E_ERR_ADAPTER_STOPPED:
  167. return "I40E_ERR_ADAPTER_STOPPED";
  168. case I40E_ERR_INVALID_MAC_ADDR:
  169. return "I40E_ERR_INVALID_MAC_ADDR";
  170. case I40E_ERR_DEVICE_NOT_SUPPORTED:
  171. return "I40E_ERR_DEVICE_NOT_SUPPORTED";
  172. case I40E_ERR_MASTER_REQUESTS_PENDING:
  173. return "I40E_ERR_MASTER_REQUESTS_PENDING";
  174. case I40E_ERR_INVALID_LINK_SETTINGS:
  175. return "I40E_ERR_INVALID_LINK_SETTINGS";
  176. case I40E_ERR_AUTONEG_NOT_COMPLETE:
  177. return "I40E_ERR_AUTONEG_NOT_COMPLETE";
  178. case I40E_ERR_RESET_FAILED:
  179. return "I40E_ERR_RESET_FAILED";
  180. case I40E_ERR_SWFW_SYNC:
  181. return "I40E_ERR_SWFW_SYNC";
  182. case I40E_ERR_NO_AVAILABLE_VSI:
  183. return "I40E_ERR_NO_AVAILABLE_VSI";
  184. case I40E_ERR_NO_MEMORY:
  185. return "I40E_ERR_NO_MEMORY";
  186. case I40E_ERR_BAD_PTR:
  187. return "I40E_ERR_BAD_PTR";
  188. case I40E_ERR_RING_FULL:
  189. return "I40E_ERR_RING_FULL";
  190. case I40E_ERR_INVALID_PD_ID:
  191. return "I40E_ERR_INVALID_PD_ID";
  192. case I40E_ERR_INVALID_QP_ID:
  193. return "I40E_ERR_INVALID_QP_ID";
  194. case I40E_ERR_INVALID_CQ_ID:
  195. return "I40E_ERR_INVALID_CQ_ID";
  196. case I40E_ERR_INVALID_CEQ_ID:
  197. return "I40E_ERR_INVALID_CEQ_ID";
  198. case I40E_ERR_INVALID_AEQ_ID:
  199. return "I40E_ERR_INVALID_AEQ_ID";
  200. case I40E_ERR_INVALID_SIZE:
  201. return "I40E_ERR_INVALID_SIZE";
  202. case I40E_ERR_INVALID_ARP_INDEX:
  203. return "I40E_ERR_INVALID_ARP_INDEX";
  204. case I40E_ERR_INVALID_FPM_FUNC_ID:
  205. return "I40E_ERR_INVALID_FPM_FUNC_ID";
  206. case I40E_ERR_QP_INVALID_MSG_SIZE:
  207. return "I40E_ERR_QP_INVALID_MSG_SIZE";
  208. case I40E_ERR_QP_TOOMANY_WRS_POSTED:
  209. return "I40E_ERR_QP_TOOMANY_WRS_POSTED";
  210. case I40E_ERR_INVALID_FRAG_COUNT:
  211. return "I40E_ERR_INVALID_FRAG_COUNT";
  212. case I40E_ERR_QUEUE_EMPTY:
  213. return "I40E_ERR_QUEUE_EMPTY";
  214. case I40E_ERR_INVALID_ALIGNMENT:
  215. return "I40E_ERR_INVALID_ALIGNMENT";
  216. case I40E_ERR_FLUSHED_QUEUE:
  217. return "I40E_ERR_FLUSHED_QUEUE";
  218. case I40E_ERR_INVALID_PUSH_PAGE_INDEX:
  219. return "I40E_ERR_INVALID_PUSH_PAGE_INDEX";
  220. case I40E_ERR_INVALID_IMM_DATA_SIZE:
  221. return "I40E_ERR_INVALID_IMM_DATA_SIZE";
  222. case I40E_ERR_TIMEOUT:
  223. return "I40E_ERR_TIMEOUT";
  224. case I40E_ERR_OPCODE_MISMATCH:
  225. return "I40E_ERR_OPCODE_MISMATCH";
  226. case I40E_ERR_CQP_COMPL_ERROR:
  227. return "I40E_ERR_CQP_COMPL_ERROR";
  228. case I40E_ERR_INVALID_VF_ID:
  229. return "I40E_ERR_INVALID_VF_ID";
  230. case I40E_ERR_INVALID_HMCFN_ID:
  231. return "I40E_ERR_INVALID_HMCFN_ID";
  232. case I40E_ERR_BACKING_PAGE_ERROR:
  233. return "I40E_ERR_BACKING_PAGE_ERROR";
  234. case I40E_ERR_NO_PBLCHUNKS_AVAILABLE:
  235. return "I40E_ERR_NO_PBLCHUNKS_AVAILABLE";
  236. case I40E_ERR_INVALID_PBLE_INDEX:
  237. return "I40E_ERR_INVALID_PBLE_INDEX";
  238. case I40E_ERR_INVALID_SD_INDEX:
  239. return "I40E_ERR_INVALID_SD_INDEX";
  240. case I40E_ERR_INVALID_PAGE_DESC_INDEX:
  241. return "I40E_ERR_INVALID_PAGE_DESC_INDEX";
  242. case I40E_ERR_INVALID_SD_TYPE:
  243. return "I40E_ERR_INVALID_SD_TYPE";
  244. case I40E_ERR_MEMCPY_FAILED:
  245. return "I40E_ERR_MEMCPY_FAILED";
  246. case I40E_ERR_INVALID_HMC_OBJ_INDEX:
  247. return "I40E_ERR_INVALID_HMC_OBJ_INDEX";
  248. case I40E_ERR_INVALID_HMC_OBJ_COUNT:
  249. return "I40E_ERR_INVALID_HMC_OBJ_COUNT";
  250. case I40E_ERR_INVALID_SRQ_ARM_LIMIT:
  251. return "I40E_ERR_INVALID_SRQ_ARM_LIMIT";
  252. case I40E_ERR_SRQ_ENABLED:
  253. return "I40E_ERR_SRQ_ENABLED";
  254. case I40E_ERR_ADMIN_QUEUE_ERROR:
  255. return "I40E_ERR_ADMIN_QUEUE_ERROR";
  256. case I40E_ERR_ADMIN_QUEUE_TIMEOUT:
  257. return "I40E_ERR_ADMIN_QUEUE_TIMEOUT";
  258. case I40E_ERR_BUF_TOO_SHORT:
  259. return "I40E_ERR_BUF_TOO_SHORT";
  260. case I40E_ERR_ADMIN_QUEUE_FULL:
  261. return "I40E_ERR_ADMIN_QUEUE_FULL";
  262. case I40E_ERR_ADMIN_QUEUE_NO_WORK:
  263. return "I40E_ERR_ADMIN_QUEUE_NO_WORK";
  264. case I40E_ERR_BAD_IWARP_CQE:
  265. return "I40E_ERR_BAD_IWARP_CQE";
  266. case I40E_ERR_NVM_BLANK_MODE:
  267. return "I40E_ERR_NVM_BLANK_MODE";
  268. case I40E_ERR_NOT_IMPLEMENTED:
  269. return "I40E_ERR_NOT_IMPLEMENTED";
  270. case I40E_ERR_PE_DOORBELL_NOT_ENABLED:
  271. return "I40E_ERR_PE_DOORBELL_NOT_ENABLED";
  272. case I40E_ERR_DIAG_TEST_FAILED:
  273. return "I40E_ERR_DIAG_TEST_FAILED";
  274. case I40E_ERR_NOT_READY:
  275. return "I40E_ERR_NOT_READY";
  276. case I40E_NOT_SUPPORTED:
  277. return "I40E_NOT_SUPPORTED";
  278. case I40E_ERR_FIRMWARE_API_VERSION:
  279. return "I40E_ERR_FIRMWARE_API_VERSION";
  280. }
  281. snprintf(hw->err_str, sizeof(hw->err_str), "%d", stat_err);
  282. return hw->err_str;
  283. }
  284. /**
  285. * i40evf_debug_aq
  286. * @hw: debug mask related to admin queue
  287. * @mask: debug mask
  288. * @desc: pointer to admin queue descriptor
  289. * @buffer: pointer to command buffer
  290. * @buf_len: max length of buffer
  291. *
  292. * Dumps debug log about adminq command with descriptor contents.
  293. **/
  294. void i40evf_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask, void *desc,
  295. void *buffer, u16 buf_len)
  296. {
  297. struct i40e_aq_desc *aq_desc = (struct i40e_aq_desc *)desc;
  298. u8 *buf = (u8 *)buffer;
  299. if ((!(mask & hw->debug_mask)) || (desc == NULL))
  300. return;
  301. i40e_debug(hw, mask,
  302. "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n",
  303. le16_to_cpu(aq_desc->opcode),
  304. le16_to_cpu(aq_desc->flags),
  305. le16_to_cpu(aq_desc->datalen),
  306. le16_to_cpu(aq_desc->retval));
  307. i40e_debug(hw, mask, "\tcookie (h,l) 0x%08X 0x%08X\n",
  308. le32_to_cpu(aq_desc->cookie_high),
  309. le32_to_cpu(aq_desc->cookie_low));
  310. i40e_debug(hw, mask, "\tparam (0,1) 0x%08X 0x%08X\n",
  311. le32_to_cpu(aq_desc->params.internal.param0),
  312. le32_to_cpu(aq_desc->params.internal.param1));
  313. i40e_debug(hw, mask, "\taddr (h,l) 0x%08X 0x%08X\n",
  314. le32_to_cpu(aq_desc->params.external.addr_high),
  315. le32_to_cpu(aq_desc->params.external.addr_low));
  316. if ((buffer != NULL) && (aq_desc->datalen != 0)) {
  317. u16 len = le16_to_cpu(aq_desc->datalen);
  318. i40e_debug(hw, mask, "AQ CMD Buffer:\n");
  319. if (buf_len < len)
  320. len = buf_len;
  321. /* write the full 16-byte chunks */
  322. if (hw->debug_mask & mask) {
  323. char prefix[27];
  324. snprintf(prefix, sizeof(prefix),
  325. "i40evf %02x:%02x.%x: \t0x",
  326. hw->bus.bus_id,
  327. hw->bus.device,
  328. hw->bus.func);
  329. print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_OFFSET,
  330. 16, 1, buf, len, false);
  331. }
  332. }
  333. }
  334. /**
  335. * i40evf_check_asq_alive
  336. * @hw: pointer to the hw struct
  337. *
  338. * Returns true if Queue is enabled else false.
  339. **/
  340. bool i40evf_check_asq_alive(struct i40e_hw *hw)
  341. {
  342. if (hw->aq.asq.len)
  343. return !!(rd32(hw, hw->aq.asq.len) &
  344. I40E_VF_ATQLEN1_ATQENABLE_MASK);
  345. else
  346. return false;
  347. }
  348. /**
  349. * i40evf_aq_queue_shutdown
  350. * @hw: pointer to the hw struct
  351. * @unloading: is the driver unloading itself
  352. *
  353. * Tell the Firmware that we're shutting down the AdminQ and whether
  354. * or not the driver is unloading as well.
  355. **/
  356. i40e_status i40evf_aq_queue_shutdown(struct i40e_hw *hw,
  357. bool unloading)
  358. {
  359. struct i40e_aq_desc desc;
  360. struct i40e_aqc_queue_shutdown *cmd =
  361. (struct i40e_aqc_queue_shutdown *)&desc.params.raw;
  362. i40e_status status;
  363. i40evf_fill_default_direct_cmd_desc(&desc,
  364. i40e_aqc_opc_queue_shutdown);
  365. if (unloading)
  366. cmd->driver_unloading = cpu_to_le32(I40E_AQ_DRIVER_UNLOADING);
  367. status = i40evf_asq_send_command(hw, &desc, NULL, 0, NULL);
  368. return status;
  369. }
  370. /**
  371. * i40e_aq_get_set_rss_lut
  372. * @hw: pointer to the hardware structure
  373. * @vsi_id: vsi fw index
  374. * @pf_lut: for PF table set true, for VSI table set false
  375. * @lut: pointer to the lut buffer provided by the caller
  376. * @lut_size: size of the lut buffer
  377. * @set: set true to set the table, false to get the table
  378. *
  379. * Internal function to get or set RSS look up table
  380. **/
  381. static i40e_status i40e_aq_get_set_rss_lut(struct i40e_hw *hw,
  382. u16 vsi_id, bool pf_lut,
  383. u8 *lut, u16 lut_size,
  384. bool set)
  385. {
  386. i40e_status status;
  387. struct i40e_aq_desc desc;
  388. struct i40e_aqc_get_set_rss_lut *cmd_resp =
  389. (struct i40e_aqc_get_set_rss_lut *)&desc.params.raw;
  390. if (set)
  391. i40evf_fill_default_direct_cmd_desc(&desc,
  392. i40e_aqc_opc_set_rss_lut);
  393. else
  394. i40evf_fill_default_direct_cmd_desc(&desc,
  395. i40e_aqc_opc_get_rss_lut);
  396. /* Indirect command */
  397. desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
  398. desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_RD);
  399. cmd_resp->vsi_id =
  400. cpu_to_le16((u16)((vsi_id <<
  401. I40E_AQC_SET_RSS_LUT_VSI_ID_SHIFT) &
  402. I40E_AQC_SET_RSS_LUT_VSI_ID_MASK));
  403. cmd_resp->vsi_id |= cpu_to_le16((u16)I40E_AQC_SET_RSS_LUT_VSI_VALID);
  404. if (pf_lut)
  405. cmd_resp->flags |= cpu_to_le16((u16)
  406. ((I40E_AQC_SET_RSS_LUT_TABLE_TYPE_PF <<
  407. I40E_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
  408. I40E_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
  409. else
  410. cmd_resp->flags |= cpu_to_le16((u16)
  411. ((I40E_AQC_SET_RSS_LUT_TABLE_TYPE_VSI <<
  412. I40E_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT) &
  413. I40E_AQC_SET_RSS_LUT_TABLE_TYPE_MASK));
  414. status = i40evf_asq_send_command(hw, &desc, lut, lut_size, NULL);
  415. return status;
  416. }
  417. /**
  418. * i40evf_aq_get_rss_lut
  419. * @hw: pointer to the hardware structure
  420. * @vsi_id: vsi fw index
  421. * @pf_lut: for PF table set true, for VSI table set false
  422. * @lut: pointer to the lut buffer provided by the caller
  423. * @lut_size: size of the lut buffer
  424. *
  425. * get the RSS lookup table, PF or VSI type
  426. **/
  427. i40e_status i40evf_aq_get_rss_lut(struct i40e_hw *hw, u16 vsi_id,
  428. bool pf_lut, u8 *lut, u16 lut_size)
  429. {
  430. return i40e_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size,
  431. false);
  432. }
  433. /**
  434. * i40evf_aq_set_rss_lut
  435. * @hw: pointer to the hardware structure
  436. * @vsi_id: vsi fw index
  437. * @pf_lut: for PF table set true, for VSI table set false
  438. * @lut: pointer to the lut buffer provided by the caller
  439. * @lut_size: size of the lut buffer
  440. *
  441. * set the RSS lookup table, PF or VSI type
  442. **/
  443. i40e_status i40evf_aq_set_rss_lut(struct i40e_hw *hw, u16 vsi_id,
  444. bool pf_lut, u8 *lut, u16 lut_size)
  445. {
  446. return i40e_aq_get_set_rss_lut(hw, vsi_id, pf_lut, lut, lut_size, true);
  447. }
  448. /**
  449. * i40e_aq_get_set_rss_key
  450. * @hw: pointer to the hw struct
  451. * @vsi_id: vsi fw index
  452. * @key: pointer to key info struct
  453. * @set: set true to set the key, false to get the key
  454. *
  455. * get the RSS key per VSI
  456. **/
  457. static i40e_status i40e_aq_get_set_rss_key(struct i40e_hw *hw,
  458. u16 vsi_id,
  459. struct i40e_aqc_get_set_rss_key_data *key,
  460. bool set)
  461. {
  462. i40e_status status;
  463. struct i40e_aq_desc desc;
  464. struct i40e_aqc_get_set_rss_key *cmd_resp =
  465. (struct i40e_aqc_get_set_rss_key *)&desc.params.raw;
  466. u16 key_size = sizeof(struct i40e_aqc_get_set_rss_key_data);
  467. if (set)
  468. i40evf_fill_default_direct_cmd_desc(&desc,
  469. i40e_aqc_opc_set_rss_key);
  470. else
  471. i40evf_fill_default_direct_cmd_desc(&desc,
  472. i40e_aqc_opc_get_rss_key);
  473. /* Indirect command */
  474. desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
  475. desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_RD);
  476. cmd_resp->vsi_id =
  477. cpu_to_le16((u16)((vsi_id <<
  478. I40E_AQC_SET_RSS_KEY_VSI_ID_SHIFT) &
  479. I40E_AQC_SET_RSS_KEY_VSI_ID_MASK));
  480. cmd_resp->vsi_id |= cpu_to_le16((u16)I40E_AQC_SET_RSS_KEY_VSI_VALID);
  481. status = i40evf_asq_send_command(hw, &desc, key, key_size, NULL);
  482. return status;
  483. }
  484. /**
  485. * i40evf_aq_get_rss_key
  486. * @hw: pointer to the hw struct
  487. * @vsi_id: vsi fw index
  488. * @key: pointer to key info struct
  489. *
  490. **/
  491. i40e_status i40evf_aq_get_rss_key(struct i40e_hw *hw,
  492. u16 vsi_id,
  493. struct i40e_aqc_get_set_rss_key_data *key)
  494. {
  495. return i40e_aq_get_set_rss_key(hw, vsi_id, key, false);
  496. }
  497. /**
  498. * i40evf_aq_set_rss_key
  499. * @hw: pointer to the hw struct
  500. * @vsi_id: vsi fw index
  501. * @key: pointer to key info struct
  502. *
  503. * set the RSS key per VSI
  504. **/
  505. i40e_status i40evf_aq_set_rss_key(struct i40e_hw *hw,
  506. u16 vsi_id,
  507. struct i40e_aqc_get_set_rss_key_data *key)
  508. {
  509. return i40e_aq_get_set_rss_key(hw, vsi_id, key, true);
  510. }
  511. /* The i40evf_ptype_lookup table is used to convert from the 8-bit ptype in the
  512. * hardware to a bit-field that can be used by SW to more easily determine the
  513. * packet type.
  514. *
  515. * Macros are used to shorten the table lines and make this table human
  516. * readable.
  517. *
  518. * We store the PTYPE in the top byte of the bit field - this is just so that
  519. * we can check that the table doesn't have a row missing, as the index into
  520. * the table should be the PTYPE.
  521. *
  522. * Typical work flow:
  523. *
  524. * IF NOT i40evf_ptype_lookup[ptype].known
  525. * THEN
  526. * Packet is unknown
  527. * ELSE IF i40evf_ptype_lookup[ptype].outer_ip == I40E_RX_PTYPE_OUTER_IP
  528. * Use the rest of the fields to look at the tunnels, inner protocols, etc
  529. * ELSE
  530. * Use the enum i40e_rx_l2_ptype to decode the packet type
  531. * ENDIF
  532. */
  533. /* macro to make the table lines short */
  534. #define I40E_PTT(PTYPE, OUTER_IP, OUTER_IP_VER, OUTER_FRAG, T, TE, TEF, I, PL)\
  535. { PTYPE, \
  536. 1, \
  537. I40E_RX_PTYPE_OUTER_##OUTER_IP, \
  538. I40E_RX_PTYPE_OUTER_##OUTER_IP_VER, \
  539. I40E_RX_PTYPE_##OUTER_FRAG, \
  540. I40E_RX_PTYPE_TUNNEL_##T, \
  541. I40E_RX_PTYPE_TUNNEL_END_##TE, \
  542. I40E_RX_PTYPE_##TEF, \
  543. I40E_RX_PTYPE_INNER_PROT_##I, \
  544. I40E_RX_PTYPE_PAYLOAD_LAYER_##PL }
  545. #define I40E_PTT_UNUSED_ENTRY(PTYPE) \
  546. { PTYPE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
  547. /* shorter macros makes the table fit but are terse */
  548. #define I40E_RX_PTYPE_NOF I40E_RX_PTYPE_NOT_FRAG
  549. #define I40E_RX_PTYPE_FRG I40E_RX_PTYPE_FRAG
  550. #define I40E_RX_PTYPE_INNER_PROT_TS I40E_RX_PTYPE_INNER_PROT_TIMESYNC
  551. /* Lookup table mapping the HW PTYPE to the bit field for decoding */
  552. struct i40e_rx_ptype_decoded i40evf_ptype_lookup[] = {
  553. /* L2 Packet types */
  554. I40E_PTT_UNUSED_ENTRY(0),
  555. I40E_PTT(1, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
  556. I40E_PTT(2, L2, NONE, NOF, NONE, NONE, NOF, TS, PAY2),
  557. I40E_PTT(3, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
  558. I40E_PTT_UNUSED_ENTRY(4),
  559. I40E_PTT_UNUSED_ENTRY(5),
  560. I40E_PTT(6, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
  561. I40E_PTT(7, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
  562. I40E_PTT_UNUSED_ENTRY(8),
  563. I40E_PTT_UNUSED_ENTRY(9),
  564. I40E_PTT(10, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
  565. I40E_PTT(11, L2, NONE, NOF, NONE, NONE, NOF, NONE, NONE),
  566. I40E_PTT(12, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  567. I40E_PTT(13, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  568. I40E_PTT(14, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  569. I40E_PTT(15, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  570. I40E_PTT(16, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  571. I40E_PTT(17, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  572. I40E_PTT(18, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  573. I40E_PTT(19, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  574. I40E_PTT(20, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  575. I40E_PTT(21, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
  576. /* Non Tunneled IPv4 */
  577. I40E_PTT(22, IP, IPV4, FRG, NONE, NONE, NOF, NONE, PAY3),
  578. I40E_PTT(23, IP, IPV4, NOF, NONE, NONE, NOF, NONE, PAY3),
  579. I40E_PTT(24, IP, IPV4, NOF, NONE, NONE, NOF, UDP, PAY4),
  580. I40E_PTT_UNUSED_ENTRY(25),
  581. I40E_PTT(26, IP, IPV4, NOF, NONE, NONE, NOF, TCP, PAY4),
  582. I40E_PTT(27, IP, IPV4, NOF, NONE, NONE, NOF, SCTP, PAY4),
  583. I40E_PTT(28, IP, IPV4, NOF, NONE, NONE, NOF, ICMP, PAY4),
  584. /* IPv4 --> IPv4 */
  585. I40E_PTT(29, IP, IPV4, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
  586. I40E_PTT(30, IP, IPV4, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
  587. I40E_PTT(31, IP, IPV4, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
  588. I40E_PTT_UNUSED_ENTRY(32),
  589. I40E_PTT(33, IP, IPV4, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
  590. I40E_PTT(34, IP, IPV4, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
  591. I40E_PTT(35, IP, IPV4, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
  592. /* IPv4 --> IPv6 */
  593. I40E_PTT(36, IP, IPV4, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
  594. I40E_PTT(37, IP, IPV4, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
  595. I40E_PTT(38, IP, IPV4, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
  596. I40E_PTT_UNUSED_ENTRY(39),
  597. I40E_PTT(40, IP, IPV4, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
  598. I40E_PTT(41, IP, IPV4, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
  599. I40E_PTT(42, IP, IPV4, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
  600. /* IPv4 --> GRE/NAT */
  601. I40E_PTT(43, IP, IPV4, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
  602. /* IPv4 --> GRE/NAT --> IPv4 */
  603. I40E_PTT(44, IP, IPV4, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
  604. I40E_PTT(45, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
  605. I40E_PTT(46, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
  606. I40E_PTT_UNUSED_ENTRY(47),
  607. I40E_PTT(48, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
  608. I40E_PTT(49, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
  609. I40E_PTT(50, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
  610. /* IPv4 --> GRE/NAT --> IPv6 */
  611. I40E_PTT(51, IP, IPV4, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
  612. I40E_PTT(52, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
  613. I40E_PTT(53, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
  614. I40E_PTT_UNUSED_ENTRY(54),
  615. I40E_PTT(55, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
  616. I40E_PTT(56, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
  617. I40E_PTT(57, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
  618. /* IPv4 --> GRE/NAT --> MAC */
  619. I40E_PTT(58, IP, IPV4, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
  620. /* IPv4 --> GRE/NAT --> MAC --> IPv4 */
  621. I40E_PTT(59, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
  622. I40E_PTT(60, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
  623. I40E_PTT(61, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
  624. I40E_PTT_UNUSED_ENTRY(62),
  625. I40E_PTT(63, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
  626. I40E_PTT(64, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
  627. I40E_PTT(65, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
  628. /* IPv4 --> GRE/NAT -> MAC --> IPv6 */
  629. I40E_PTT(66, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
  630. I40E_PTT(67, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
  631. I40E_PTT(68, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
  632. I40E_PTT_UNUSED_ENTRY(69),
  633. I40E_PTT(70, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
  634. I40E_PTT(71, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
  635. I40E_PTT(72, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
  636. /* IPv4 --> GRE/NAT --> MAC/VLAN */
  637. I40E_PTT(73, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
  638. /* IPv4 ---> GRE/NAT -> MAC/VLAN --> IPv4 */
  639. I40E_PTT(74, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
  640. I40E_PTT(75, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
  641. I40E_PTT(76, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
  642. I40E_PTT_UNUSED_ENTRY(77),
  643. I40E_PTT(78, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
  644. I40E_PTT(79, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
  645. I40E_PTT(80, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
  646. /* IPv4 -> GRE/NAT -> MAC/VLAN --> IPv6 */
  647. I40E_PTT(81, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
  648. I40E_PTT(82, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
  649. I40E_PTT(83, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
  650. I40E_PTT_UNUSED_ENTRY(84),
  651. I40E_PTT(85, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
  652. I40E_PTT(86, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
  653. I40E_PTT(87, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
  654. /* Non Tunneled IPv6 */
  655. I40E_PTT(88, IP, IPV6, FRG, NONE, NONE, NOF, NONE, PAY3),
  656. I40E_PTT(89, IP, IPV6, NOF, NONE, NONE, NOF, NONE, PAY3),
  657. I40E_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP, PAY3),
  658. I40E_PTT_UNUSED_ENTRY(91),
  659. I40E_PTT(92, IP, IPV6, NOF, NONE, NONE, NOF, TCP, PAY4),
  660. I40E_PTT(93, IP, IPV6, NOF, NONE, NONE, NOF, SCTP, PAY4),
  661. I40E_PTT(94, IP, IPV6, NOF, NONE, NONE, NOF, ICMP, PAY4),
  662. /* IPv6 --> IPv4 */
  663. I40E_PTT(95, IP, IPV6, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
  664. I40E_PTT(96, IP, IPV6, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
  665. I40E_PTT(97, IP, IPV6, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
  666. I40E_PTT_UNUSED_ENTRY(98),
  667. I40E_PTT(99, IP, IPV6, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
  668. I40E_PTT(100, IP, IPV6, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
  669. I40E_PTT(101, IP, IPV6, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
  670. /* IPv6 --> IPv6 */
  671. I40E_PTT(102, IP, IPV6, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
  672. I40E_PTT(103, IP, IPV6, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
  673. I40E_PTT(104, IP, IPV6, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
  674. I40E_PTT_UNUSED_ENTRY(105),
  675. I40E_PTT(106, IP, IPV6, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
  676. I40E_PTT(107, IP, IPV6, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
  677. I40E_PTT(108, IP, IPV6, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
  678. /* IPv6 --> GRE/NAT */
  679. I40E_PTT(109, IP, IPV6, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
  680. /* IPv6 --> GRE/NAT -> IPv4 */
  681. I40E_PTT(110, IP, IPV6, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
  682. I40E_PTT(111, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
  683. I40E_PTT(112, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
  684. I40E_PTT_UNUSED_ENTRY(113),
  685. I40E_PTT(114, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
  686. I40E_PTT(115, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
  687. I40E_PTT(116, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
  688. /* IPv6 --> GRE/NAT -> IPv6 */
  689. I40E_PTT(117, IP, IPV6, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
  690. I40E_PTT(118, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
  691. I40E_PTT(119, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
  692. I40E_PTT_UNUSED_ENTRY(120),
  693. I40E_PTT(121, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
  694. I40E_PTT(122, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
  695. I40E_PTT(123, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
  696. /* IPv6 --> GRE/NAT -> MAC */
  697. I40E_PTT(124, IP, IPV6, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
  698. /* IPv6 --> GRE/NAT -> MAC -> IPv4 */
  699. I40E_PTT(125, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
  700. I40E_PTT(126, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
  701. I40E_PTT(127, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
  702. I40E_PTT_UNUSED_ENTRY(128),
  703. I40E_PTT(129, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
  704. I40E_PTT(130, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
  705. I40E_PTT(131, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
  706. /* IPv6 --> GRE/NAT -> MAC -> IPv6 */
  707. I40E_PTT(132, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
  708. I40E_PTT(133, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
  709. I40E_PTT(134, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
  710. I40E_PTT_UNUSED_ENTRY(135),
  711. I40E_PTT(136, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
  712. I40E_PTT(137, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
  713. I40E_PTT(138, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
  714. /* IPv6 --> GRE/NAT -> MAC/VLAN */
  715. I40E_PTT(139, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
  716. /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv4 */
  717. I40E_PTT(140, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
  718. I40E_PTT(141, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
  719. I40E_PTT(142, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
  720. I40E_PTT_UNUSED_ENTRY(143),
  721. I40E_PTT(144, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
  722. I40E_PTT(145, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
  723. I40E_PTT(146, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
  724. /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv6 */
  725. I40E_PTT(147, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
  726. I40E_PTT(148, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
  727. I40E_PTT(149, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
  728. I40E_PTT_UNUSED_ENTRY(150),
  729. I40E_PTT(151, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
  730. I40E_PTT(152, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
  731. I40E_PTT(153, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
  732. /* unused entries */
  733. I40E_PTT_UNUSED_ENTRY(154),
  734. I40E_PTT_UNUSED_ENTRY(155),
  735. I40E_PTT_UNUSED_ENTRY(156),
  736. I40E_PTT_UNUSED_ENTRY(157),
  737. I40E_PTT_UNUSED_ENTRY(158),
  738. I40E_PTT_UNUSED_ENTRY(159),
  739. I40E_PTT_UNUSED_ENTRY(160),
  740. I40E_PTT_UNUSED_ENTRY(161),
  741. I40E_PTT_UNUSED_ENTRY(162),
  742. I40E_PTT_UNUSED_ENTRY(163),
  743. I40E_PTT_UNUSED_ENTRY(164),
  744. I40E_PTT_UNUSED_ENTRY(165),
  745. I40E_PTT_UNUSED_ENTRY(166),
  746. I40E_PTT_UNUSED_ENTRY(167),
  747. I40E_PTT_UNUSED_ENTRY(168),
  748. I40E_PTT_UNUSED_ENTRY(169),
  749. I40E_PTT_UNUSED_ENTRY(170),
  750. I40E_PTT_UNUSED_ENTRY(171),
  751. I40E_PTT_UNUSED_ENTRY(172),
  752. I40E_PTT_UNUSED_ENTRY(173),
  753. I40E_PTT_UNUSED_ENTRY(174),
  754. I40E_PTT_UNUSED_ENTRY(175),
  755. I40E_PTT_UNUSED_ENTRY(176),
  756. I40E_PTT_UNUSED_ENTRY(177),
  757. I40E_PTT_UNUSED_ENTRY(178),
  758. I40E_PTT_UNUSED_ENTRY(179),
  759. I40E_PTT_UNUSED_ENTRY(180),
  760. I40E_PTT_UNUSED_ENTRY(181),
  761. I40E_PTT_UNUSED_ENTRY(182),
  762. I40E_PTT_UNUSED_ENTRY(183),
  763. I40E_PTT_UNUSED_ENTRY(184),
  764. I40E_PTT_UNUSED_ENTRY(185),
  765. I40E_PTT_UNUSED_ENTRY(186),
  766. I40E_PTT_UNUSED_ENTRY(187),
  767. I40E_PTT_UNUSED_ENTRY(188),
  768. I40E_PTT_UNUSED_ENTRY(189),
  769. I40E_PTT_UNUSED_ENTRY(190),
  770. I40E_PTT_UNUSED_ENTRY(191),
  771. I40E_PTT_UNUSED_ENTRY(192),
  772. I40E_PTT_UNUSED_ENTRY(193),
  773. I40E_PTT_UNUSED_ENTRY(194),
  774. I40E_PTT_UNUSED_ENTRY(195),
  775. I40E_PTT_UNUSED_ENTRY(196),
  776. I40E_PTT_UNUSED_ENTRY(197),
  777. I40E_PTT_UNUSED_ENTRY(198),
  778. I40E_PTT_UNUSED_ENTRY(199),
  779. I40E_PTT_UNUSED_ENTRY(200),
  780. I40E_PTT_UNUSED_ENTRY(201),
  781. I40E_PTT_UNUSED_ENTRY(202),
  782. I40E_PTT_UNUSED_ENTRY(203),
  783. I40E_PTT_UNUSED_ENTRY(204),
  784. I40E_PTT_UNUSED_ENTRY(205),
  785. I40E_PTT_UNUSED_ENTRY(206),
  786. I40E_PTT_UNUSED_ENTRY(207),
  787. I40E_PTT_UNUSED_ENTRY(208),
  788. I40E_PTT_UNUSED_ENTRY(209),
  789. I40E_PTT_UNUSED_ENTRY(210),
  790. I40E_PTT_UNUSED_ENTRY(211),
  791. I40E_PTT_UNUSED_ENTRY(212),
  792. I40E_PTT_UNUSED_ENTRY(213),
  793. I40E_PTT_UNUSED_ENTRY(214),
  794. I40E_PTT_UNUSED_ENTRY(215),
  795. I40E_PTT_UNUSED_ENTRY(216),
  796. I40E_PTT_UNUSED_ENTRY(217),
  797. I40E_PTT_UNUSED_ENTRY(218),
  798. I40E_PTT_UNUSED_ENTRY(219),
  799. I40E_PTT_UNUSED_ENTRY(220),
  800. I40E_PTT_UNUSED_ENTRY(221),
  801. I40E_PTT_UNUSED_ENTRY(222),
  802. I40E_PTT_UNUSED_ENTRY(223),
  803. I40E_PTT_UNUSED_ENTRY(224),
  804. I40E_PTT_UNUSED_ENTRY(225),
  805. I40E_PTT_UNUSED_ENTRY(226),
  806. I40E_PTT_UNUSED_ENTRY(227),
  807. I40E_PTT_UNUSED_ENTRY(228),
  808. I40E_PTT_UNUSED_ENTRY(229),
  809. I40E_PTT_UNUSED_ENTRY(230),
  810. I40E_PTT_UNUSED_ENTRY(231),
  811. I40E_PTT_UNUSED_ENTRY(232),
  812. I40E_PTT_UNUSED_ENTRY(233),
  813. I40E_PTT_UNUSED_ENTRY(234),
  814. I40E_PTT_UNUSED_ENTRY(235),
  815. I40E_PTT_UNUSED_ENTRY(236),
  816. I40E_PTT_UNUSED_ENTRY(237),
  817. I40E_PTT_UNUSED_ENTRY(238),
  818. I40E_PTT_UNUSED_ENTRY(239),
  819. I40E_PTT_UNUSED_ENTRY(240),
  820. I40E_PTT_UNUSED_ENTRY(241),
  821. I40E_PTT_UNUSED_ENTRY(242),
  822. I40E_PTT_UNUSED_ENTRY(243),
  823. I40E_PTT_UNUSED_ENTRY(244),
  824. I40E_PTT_UNUSED_ENTRY(245),
  825. I40E_PTT_UNUSED_ENTRY(246),
  826. I40E_PTT_UNUSED_ENTRY(247),
  827. I40E_PTT_UNUSED_ENTRY(248),
  828. I40E_PTT_UNUSED_ENTRY(249),
  829. I40E_PTT_UNUSED_ENTRY(250),
  830. I40E_PTT_UNUSED_ENTRY(251),
  831. I40E_PTT_UNUSED_ENTRY(252),
  832. I40E_PTT_UNUSED_ENTRY(253),
  833. I40E_PTT_UNUSED_ENTRY(254),
  834. I40E_PTT_UNUSED_ENTRY(255)
  835. };
  836. /**
  837. * i40evf_aq_rx_ctl_read_register - use FW to read from an Rx control register
  838. * @hw: pointer to the hw struct
  839. * @reg_addr: register address
  840. * @reg_val: ptr to register value
  841. * @cmd_details: pointer to command details structure or NULL
  842. *
  843. * Use the firmware to read the Rx control register,
  844. * especially useful if the Rx unit is under heavy pressure
  845. **/
  846. i40e_status i40evf_aq_rx_ctl_read_register(struct i40e_hw *hw,
  847. u32 reg_addr, u32 *reg_val,
  848. struct i40e_asq_cmd_details *cmd_details)
  849. {
  850. struct i40e_aq_desc desc;
  851. struct i40e_aqc_rx_ctl_reg_read_write *cmd_resp =
  852. (struct i40e_aqc_rx_ctl_reg_read_write *)&desc.params.raw;
  853. i40e_status status;
  854. if (!reg_val)
  855. return I40E_ERR_PARAM;
  856. i40evf_fill_default_direct_cmd_desc(&desc,
  857. i40e_aqc_opc_rx_ctl_reg_read);
  858. cmd_resp->address = cpu_to_le32(reg_addr);
  859. status = i40evf_asq_send_command(hw, &desc, NULL, 0, cmd_details);
  860. if (status == 0)
  861. *reg_val = le32_to_cpu(cmd_resp->value);
  862. return status;
  863. }
  864. /**
  865. * i40evf_read_rx_ctl - read from an Rx control register
  866. * @hw: pointer to the hw struct
  867. * @reg_addr: register address
  868. **/
  869. u32 i40evf_read_rx_ctl(struct i40e_hw *hw, u32 reg_addr)
  870. {
  871. i40e_status status = 0;
  872. bool use_register;
  873. int retry = 5;
  874. u32 val = 0;
  875. use_register = (((hw->aq.api_maj_ver == 1) &&
  876. (hw->aq.api_min_ver < 5)) ||
  877. (hw->mac.type == I40E_MAC_X722));
  878. if (!use_register) {
  879. do_retry:
  880. status = i40evf_aq_rx_ctl_read_register(hw, reg_addr,
  881. &val, NULL);
  882. if (hw->aq.asq_last_status == I40E_AQ_RC_EAGAIN && retry) {
  883. usleep_range(1000, 2000);
  884. retry--;
  885. goto do_retry;
  886. }
  887. }
  888. /* if the AQ access failed, try the old-fashioned way */
  889. if (status || use_register)
  890. val = rd32(hw, reg_addr);
  891. return val;
  892. }
  893. /**
  894. * i40evf_aq_rx_ctl_write_register
  895. * @hw: pointer to the hw struct
  896. * @reg_addr: register address
  897. * @reg_val: register value
  898. * @cmd_details: pointer to command details structure or NULL
  899. *
  900. * Use the firmware to write to an Rx control register,
  901. * especially useful if the Rx unit is under heavy pressure
  902. **/
  903. i40e_status i40evf_aq_rx_ctl_write_register(struct i40e_hw *hw,
  904. u32 reg_addr, u32 reg_val,
  905. struct i40e_asq_cmd_details *cmd_details)
  906. {
  907. struct i40e_aq_desc desc;
  908. struct i40e_aqc_rx_ctl_reg_read_write *cmd =
  909. (struct i40e_aqc_rx_ctl_reg_read_write *)&desc.params.raw;
  910. i40e_status status;
  911. i40evf_fill_default_direct_cmd_desc(&desc,
  912. i40e_aqc_opc_rx_ctl_reg_write);
  913. cmd->address = cpu_to_le32(reg_addr);
  914. cmd->value = cpu_to_le32(reg_val);
  915. status = i40evf_asq_send_command(hw, &desc, NULL, 0, cmd_details);
  916. return status;
  917. }
  918. /**
  919. * i40evf_write_rx_ctl - write to an Rx control register
  920. * @hw: pointer to the hw struct
  921. * @reg_addr: register address
  922. * @reg_val: register value
  923. **/
  924. void i40evf_write_rx_ctl(struct i40e_hw *hw, u32 reg_addr, u32 reg_val)
  925. {
  926. i40e_status status = 0;
  927. bool use_register;
  928. int retry = 5;
  929. use_register = (((hw->aq.api_maj_ver == 1) &&
  930. (hw->aq.api_min_ver < 5)) ||
  931. (hw->mac.type == I40E_MAC_X722));
  932. if (!use_register) {
  933. do_retry:
  934. status = i40evf_aq_rx_ctl_write_register(hw, reg_addr,
  935. reg_val, NULL);
  936. if (hw->aq.asq_last_status == I40E_AQ_RC_EAGAIN && retry) {
  937. usleep_range(1000, 2000);
  938. retry--;
  939. goto do_retry;
  940. }
  941. }
  942. /* if the AQ access failed, try the old-fashioned way */
  943. if (status || use_register)
  944. wr32(hw, reg_addr, reg_val);
  945. }
  946. /**
  947. * i40e_aq_send_msg_to_pf
  948. * @hw: pointer to the hardware structure
  949. * @v_opcode: opcodes for VF-PF communication
  950. * @v_retval: return error code
  951. * @msg: pointer to the msg buffer
  952. * @msglen: msg length
  953. * @cmd_details: pointer to command details
  954. *
  955. * Send message to PF driver using admin queue. By default, this message
  956. * is sent asynchronously, i.e. i40evf_asq_send_command() does not wait for
  957. * completion before returning.
  958. **/
  959. i40e_status i40e_aq_send_msg_to_pf(struct i40e_hw *hw,
  960. enum virtchnl_ops v_opcode,
  961. i40e_status v_retval,
  962. u8 *msg, u16 msglen,
  963. struct i40e_asq_cmd_details *cmd_details)
  964. {
  965. struct i40e_aq_desc desc;
  966. struct i40e_asq_cmd_details details;
  967. i40e_status status;
  968. i40evf_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_send_msg_to_pf);
  969. desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_SI);
  970. desc.cookie_high = cpu_to_le32(v_opcode);
  971. desc.cookie_low = cpu_to_le32(v_retval);
  972. if (msglen) {
  973. desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF
  974. | I40E_AQ_FLAG_RD));
  975. if (msglen > I40E_AQ_LARGE_BUF)
  976. desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
  977. desc.datalen = cpu_to_le16(msglen);
  978. }
  979. if (!cmd_details) {
  980. memset(&details, 0, sizeof(details));
  981. details.async = true;
  982. cmd_details = &details;
  983. }
  984. status = i40evf_asq_send_command(hw, &desc, msg, msglen, cmd_details);
  985. return status;
  986. }
  987. /**
  988. * i40e_vf_parse_hw_config
  989. * @hw: pointer to the hardware structure
  990. * @msg: pointer to the virtual channel VF resource structure
  991. *
  992. * Given a VF resource message from the PF, populate the hw struct
  993. * with appropriate information.
  994. **/
  995. void i40e_vf_parse_hw_config(struct i40e_hw *hw,
  996. struct virtchnl_vf_resource *msg)
  997. {
  998. struct virtchnl_vsi_resource *vsi_res;
  999. int i;
  1000. vsi_res = &msg->vsi_res[0];
  1001. hw->dev_caps.num_vsis = msg->num_vsis;
  1002. hw->dev_caps.num_rx_qp = msg->num_queue_pairs;
  1003. hw->dev_caps.num_tx_qp = msg->num_queue_pairs;
  1004. hw->dev_caps.num_msix_vectors_vf = msg->max_vectors;
  1005. hw->dev_caps.dcb = msg->vf_cap_flags &
  1006. VIRTCHNL_VF_OFFLOAD_L2;
  1007. hw->dev_caps.fcoe = 0;
  1008. for (i = 0; i < msg->num_vsis; i++) {
  1009. if (vsi_res->vsi_type == VIRTCHNL_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, 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. }