qed_mcp.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  1. /* QLogic qed NIC Driver
  2. * Copyright (c) 2015-2017 QLogic Corporation
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and /or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. */
  32. #ifndef _QED_MCP_H
  33. #define _QED_MCP_H
  34. #include <linux/types.h>
  35. #include <linux/delay.h>
  36. #include <linux/slab.h>
  37. #include <linux/spinlock.h>
  38. #include <linux/qed/qed_fcoe_if.h>
  39. #include "qed_hsi.h"
  40. #include "qed_dev_api.h"
  41. struct qed_mcp_link_speed_params {
  42. bool autoneg;
  43. u32 advertised_speeds; /* bitmask of DRV_SPEED_CAPABILITY */
  44. u32 forced_speed; /* In Mb/s */
  45. };
  46. struct qed_mcp_link_pause_params {
  47. bool autoneg;
  48. bool forced_rx;
  49. bool forced_tx;
  50. };
  51. struct qed_mcp_link_params {
  52. struct qed_mcp_link_speed_params speed;
  53. struct qed_mcp_link_pause_params pause;
  54. u32 loopback_mode;
  55. };
  56. struct qed_mcp_link_capabilities {
  57. u32 speed_capabilities;
  58. bool default_speed_autoneg;
  59. };
  60. struct qed_mcp_link_state {
  61. bool link_up;
  62. u32 min_pf_rate;
  63. /* Actual link speed in Mb/s */
  64. u32 line_speed;
  65. /* PF max speed in Mb/s, deduced from line_speed
  66. * according to PF max bandwidth configuration.
  67. */
  68. u32 speed;
  69. bool full_duplex;
  70. bool an;
  71. bool an_complete;
  72. bool parallel_detection;
  73. bool pfc_enabled;
  74. #define QED_LINK_PARTNER_SPEED_1G_HD BIT(0)
  75. #define QED_LINK_PARTNER_SPEED_1G_FD BIT(1)
  76. #define QED_LINK_PARTNER_SPEED_10G BIT(2)
  77. #define QED_LINK_PARTNER_SPEED_20G BIT(3)
  78. #define QED_LINK_PARTNER_SPEED_25G BIT(4)
  79. #define QED_LINK_PARTNER_SPEED_40G BIT(5)
  80. #define QED_LINK_PARTNER_SPEED_50G BIT(6)
  81. #define QED_LINK_PARTNER_SPEED_100G BIT(7)
  82. u32 partner_adv_speed;
  83. bool partner_tx_flow_ctrl_en;
  84. bool partner_rx_flow_ctrl_en;
  85. #define QED_LINK_PARTNER_SYMMETRIC_PAUSE (1)
  86. #define QED_LINK_PARTNER_ASYMMETRIC_PAUSE (2)
  87. #define QED_LINK_PARTNER_BOTH_PAUSE (3)
  88. u8 partner_adv_pause;
  89. bool sfp_tx_fault;
  90. };
  91. struct qed_mcp_function_info {
  92. u8 pause_on_host;
  93. enum qed_pci_personality protocol;
  94. u8 bandwidth_min;
  95. u8 bandwidth_max;
  96. u8 mac[ETH_ALEN];
  97. u64 wwn_port;
  98. u64 wwn_node;
  99. #define QED_MCP_VLAN_UNSET (0xffff)
  100. u16 ovlan;
  101. u16 mtu;
  102. };
  103. struct qed_mcp_nvm_common {
  104. u32 offset;
  105. u32 param;
  106. u32 resp;
  107. u32 cmd;
  108. };
  109. struct qed_mcp_drv_version {
  110. u32 version;
  111. u8 name[MCP_DRV_VER_STR_SIZE - 4];
  112. };
  113. struct qed_mcp_lan_stats {
  114. u64 ucast_rx_pkts;
  115. u64 ucast_tx_pkts;
  116. u32 fcs_err;
  117. };
  118. struct qed_mcp_fcoe_stats {
  119. u64 rx_pkts;
  120. u64 tx_pkts;
  121. u32 fcs_err;
  122. u32 login_failure;
  123. };
  124. struct qed_mcp_iscsi_stats {
  125. u64 rx_pdus;
  126. u64 tx_pdus;
  127. u64 rx_bytes;
  128. u64 tx_bytes;
  129. };
  130. struct qed_mcp_rdma_stats {
  131. u64 rx_pkts;
  132. u64 tx_pkts;
  133. u64 rx_bytes;
  134. u64 tx_byts;
  135. };
  136. enum qed_mcp_protocol_type {
  137. QED_MCP_LAN_STATS,
  138. QED_MCP_FCOE_STATS,
  139. QED_MCP_ISCSI_STATS,
  140. QED_MCP_RDMA_STATS
  141. };
  142. union qed_mcp_protocol_stats {
  143. struct qed_mcp_lan_stats lan_stats;
  144. struct qed_mcp_fcoe_stats fcoe_stats;
  145. struct qed_mcp_iscsi_stats iscsi_stats;
  146. struct qed_mcp_rdma_stats rdma_stats;
  147. };
  148. enum qed_ov_eswitch {
  149. QED_OV_ESWITCH_NONE,
  150. QED_OV_ESWITCH_VEB,
  151. QED_OV_ESWITCH_VEPA
  152. };
  153. enum qed_ov_client {
  154. QED_OV_CLIENT_DRV,
  155. QED_OV_CLIENT_USER,
  156. QED_OV_CLIENT_VENDOR_SPEC
  157. };
  158. enum qed_ov_driver_state {
  159. QED_OV_DRIVER_STATE_NOT_LOADED,
  160. QED_OV_DRIVER_STATE_DISABLED,
  161. QED_OV_DRIVER_STATE_ACTIVE
  162. };
  163. enum qed_ov_wol {
  164. QED_OV_WOL_DEFAULT,
  165. QED_OV_WOL_DISABLED,
  166. QED_OV_WOL_ENABLED
  167. };
  168. /**
  169. * @brief - returns the link params of the hw function
  170. *
  171. * @param p_hwfn
  172. *
  173. * @returns pointer to link params
  174. */
  175. struct qed_mcp_link_params *qed_mcp_get_link_params(struct qed_hwfn *);
  176. /**
  177. * @brief - return the link state of the hw function
  178. *
  179. * @param p_hwfn
  180. *
  181. * @returns pointer to link state
  182. */
  183. struct qed_mcp_link_state *qed_mcp_get_link_state(struct qed_hwfn *);
  184. /**
  185. * @brief - return the link capabilities of the hw function
  186. *
  187. * @param p_hwfn
  188. *
  189. * @returns pointer to link capabilities
  190. */
  191. struct qed_mcp_link_capabilities
  192. *qed_mcp_get_link_capabilities(struct qed_hwfn *p_hwfn);
  193. /**
  194. * @brief Request the MFW to set the the link according to 'link_input'.
  195. *
  196. * @param p_hwfn
  197. * @param p_ptt
  198. * @param b_up - raise link if `true'. Reset link if `false'.
  199. *
  200. * @return int
  201. */
  202. int qed_mcp_set_link(struct qed_hwfn *p_hwfn,
  203. struct qed_ptt *p_ptt,
  204. bool b_up);
  205. /**
  206. * @brief Get the management firmware version value
  207. *
  208. * @param p_hwfn
  209. * @param p_ptt
  210. * @param p_mfw_ver - mfw version value
  211. * @param p_running_bundle_id - image id in nvram; Optional.
  212. *
  213. * @return int - 0 - operation was successful.
  214. */
  215. int qed_mcp_get_mfw_ver(struct qed_hwfn *p_hwfn,
  216. struct qed_ptt *p_ptt,
  217. u32 *p_mfw_ver, u32 *p_running_bundle_id);
  218. /**
  219. * @brief Get media type value of the port.
  220. *
  221. * @param cdev - qed dev pointer
  222. * @param mfw_ver - media type value
  223. *
  224. * @return int -
  225. * 0 - Operation was successul.
  226. * -EBUSY - Operation failed
  227. */
  228. int qed_mcp_get_media_type(struct qed_dev *cdev,
  229. u32 *media_type);
  230. /**
  231. * @brief General function for sending commands to the MCP
  232. * mailbox. It acquire mutex lock for the entire
  233. * operation, from sending the request until the MCP
  234. * response. Waiting for MCP response will be checked up
  235. * to 5 seconds every 5ms.
  236. *
  237. * @param p_hwfn - hw function
  238. * @param p_ptt - PTT required for register access
  239. * @param cmd - command to be sent to the MCP.
  240. * @param param - Optional param
  241. * @param o_mcp_resp - The MCP response code (exclude sequence).
  242. * @param o_mcp_param- Optional parameter provided by the MCP
  243. * response
  244. * @return int - 0 - operation
  245. * was successul.
  246. */
  247. int qed_mcp_cmd(struct qed_hwfn *p_hwfn,
  248. struct qed_ptt *p_ptt,
  249. u32 cmd,
  250. u32 param,
  251. u32 *o_mcp_resp,
  252. u32 *o_mcp_param);
  253. /**
  254. * @brief - drains the nig, allowing completion to pass in case of pauses.
  255. * (Should be called only from sleepable context)
  256. *
  257. * @param p_hwfn
  258. * @param p_ptt
  259. */
  260. int qed_mcp_drain(struct qed_hwfn *p_hwfn,
  261. struct qed_ptt *p_ptt);
  262. /**
  263. * @brief Get the flash size value
  264. *
  265. * @param p_hwfn
  266. * @param p_ptt
  267. * @param p_flash_size - flash size in bytes to be filled.
  268. *
  269. * @return int - 0 - operation was successul.
  270. */
  271. int qed_mcp_get_flash_size(struct qed_hwfn *p_hwfn,
  272. struct qed_ptt *p_ptt,
  273. u32 *p_flash_size);
  274. /**
  275. * @brief Send driver version to MFW
  276. *
  277. * @param p_hwfn
  278. * @param p_ptt
  279. * @param version - Version value
  280. * @param name - Protocol driver name
  281. *
  282. * @return int - 0 - operation was successul.
  283. */
  284. int
  285. qed_mcp_send_drv_version(struct qed_hwfn *p_hwfn,
  286. struct qed_ptt *p_ptt,
  287. struct qed_mcp_drv_version *p_ver);
  288. /**
  289. * @brief Notify MFW about the change in base device properties
  290. *
  291. * @param p_hwfn
  292. * @param p_ptt
  293. * @param client - qed client type
  294. *
  295. * @return int - 0 - operation was successful.
  296. */
  297. int qed_mcp_ov_update_current_config(struct qed_hwfn *p_hwfn,
  298. struct qed_ptt *p_ptt,
  299. enum qed_ov_client client);
  300. /**
  301. * @brief Notify MFW about the driver state
  302. *
  303. * @param p_hwfn
  304. * @param p_ptt
  305. * @param drv_state - Driver state
  306. *
  307. * @return int - 0 - operation was successful.
  308. */
  309. int qed_mcp_ov_update_driver_state(struct qed_hwfn *p_hwfn,
  310. struct qed_ptt *p_ptt,
  311. enum qed_ov_driver_state drv_state);
  312. /**
  313. * @brief Send MTU size to MFW
  314. *
  315. * @param p_hwfn
  316. * @param p_ptt
  317. * @param mtu - MTU size
  318. *
  319. * @return int - 0 - operation was successful.
  320. */
  321. int qed_mcp_ov_update_mtu(struct qed_hwfn *p_hwfn,
  322. struct qed_ptt *p_ptt, u16 mtu);
  323. /**
  324. * @brief Send MAC address to MFW
  325. *
  326. * @param p_hwfn
  327. * @param p_ptt
  328. * @param mac - MAC address
  329. *
  330. * @return int - 0 - operation was successful.
  331. */
  332. int qed_mcp_ov_update_mac(struct qed_hwfn *p_hwfn,
  333. struct qed_ptt *p_ptt, u8 *mac);
  334. /**
  335. * @brief Send WOL mode to MFW
  336. *
  337. * @param p_hwfn
  338. * @param p_ptt
  339. * @param wol - WOL mode
  340. *
  341. * @return int - 0 - operation was successful.
  342. */
  343. int qed_mcp_ov_update_wol(struct qed_hwfn *p_hwfn,
  344. struct qed_ptt *p_ptt,
  345. enum qed_ov_wol wol);
  346. /**
  347. * @brief Set LED status
  348. *
  349. * @param p_hwfn
  350. * @param p_ptt
  351. * @param mode - LED mode
  352. *
  353. * @return int - 0 - operation was successful.
  354. */
  355. int qed_mcp_set_led(struct qed_hwfn *p_hwfn,
  356. struct qed_ptt *p_ptt,
  357. enum qed_led_mode mode);
  358. /**
  359. * @brief Read from nvm
  360. *
  361. * @param cdev
  362. * @param addr - nvm offset
  363. * @param p_buf - nvm read buffer
  364. * @param len - buffer len
  365. *
  366. * @return int - 0 - operation was successful.
  367. */
  368. int qed_mcp_nvm_read(struct qed_dev *cdev, u32 addr, u8 *p_buf, u32 len);
  369. /**
  370. * @brief Bist register test
  371. *
  372. * @param p_hwfn - hw function
  373. * @param p_ptt - PTT required for register access
  374. *
  375. * @return int - 0 - operation was successful.
  376. */
  377. int qed_mcp_bist_register_test(struct qed_hwfn *p_hwfn,
  378. struct qed_ptt *p_ptt);
  379. /**
  380. * @brief Bist clock test
  381. *
  382. * @param p_hwfn - hw function
  383. * @param p_ptt - PTT required for register access
  384. *
  385. * @return int - 0 - operation was successful.
  386. */
  387. int qed_mcp_bist_clock_test(struct qed_hwfn *p_hwfn,
  388. struct qed_ptt *p_ptt);
  389. /**
  390. * @brief Bist nvm test - get number of images
  391. *
  392. * @param p_hwfn - hw function
  393. * @param p_ptt - PTT required for register access
  394. * @param num_images - number of images if operation was
  395. * successful. 0 if not.
  396. *
  397. * @return int - 0 - operation was successful.
  398. */
  399. int qed_mcp_bist_nvm_test_get_num_images(struct qed_hwfn *p_hwfn,
  400. struct qed_ptt *p_ptt,
  401. u32 *num_images);
  402. /**
  403. * @brief Bist nvm test - get image attributes by index
  404. *
  405. * @param p_hwfn - hw function
  406. * @param p_ptt - PTT required for register access
  407. * @param p_image_att - Attributes of image
  408. * @param image_index - Index of image to get information for
  409. *
  410. * @return int - 0 - operation was successful.
  411. */
  412. int qed_mcp_bist_nvm_test_get_image_att(struct qed_hwfn *p_hwfn,
  413. struct qed_ptt *p_ptt,
  414. struct bist_nvm_image_att *p_image_att,
  415. u32 image_index);
  416. /* Using hwfn number (and not pf_num) is required since in CMT mode,
  417. * same pf_num may be used by two different hwfn
  418. * TODO - this shouldn't really be in .h file, but until all fields
  419. * required during hw-init will be placed in their correct place in shmem
  420. * we need it in qed_dev.c [for readin the nvram reflection in shmem].
  421. */
  422. #define MCP_PF_ID_BY_REL(p_hwfn, rel_pfid) (QED_IS_BB((p_hwfn)->cdev) ? \
  423. ((rel_pfid) | \
  424. ((p_hwfn)->abs_pf_id & 1) << 3) : \
  425. rel_pfid)
  426. #define MCP_PF_ID(p_hwfn) MCP_PF_ID_BY_REL(p_hwfn, (p_hwfn)->rel_pf_id)
  427. #define MFW_PORT(_p_hwfn) ((_p_hwfn)->abs_pf_id % \
  428. ((_p_hwfn)->cdev->num_ports_in_engines * \
  429. qed_device_num_engines((_p_hwfn)->cdev)))
  430. struct qed_mcp_info {
  431. /* List for mailbox commands which were sent and wait for a response */
  432. struct list_head cmd_list;
  433. /* Spinlock used for protecting the access to the mailbox commands list
  434. * and the sending of the commands.
  435. */
  436. spinlock_t cmd_lock;
  437. /* Spinlock used for syncing SW link-changes and link-changes
  438. * originating from attention context.
  439. */
  440. spinlock_t link_lock;
  441. bool block_mb_sending;
  442. u32 public_base;
  443. u32 drv_mb_addr;
  444. u32 mfw_mb_addr;
  445. u32 port_addr;
  446. u16 drv_mb_seq;
  447. u16 drv_pulse_seq;
  448. struct qed_mcp_link_params link_input;
  449. struct qed_mcp_link_state link_output;
  450. struct qed_mcp_link_capabilities link_capabilities;
  451. struct qed_mcp_function_info func_info;
  452. u8 *mfw_mb_cur;
  453. u8 *mfw_mb_shadow;
  454. u16 mfw_mb_length;
  455. u32 mcp_hist;
  456. };
  457. struct qed_mcp_mb_params {
  458. u32 cmd;
  459. u32 param;
  460. void *p_data_src;
  461. u8 data_src_size;
  462. void *p_data_dst;
  463. u8 data_dst_size;
  464. u32 mcp_resp;
  465. u32 mcp_param;
  466. };
  467. /**
  468. * @brief Initialize the interface with the MCP
  469. *
  470. * @param p_hwfn - HW func
  471. * @param p_ptt - PTT required for register access
  472. *
  473. * @return int
  474. */
  475. int qed_mcp_cmd_init(struct qed_hwfn *p_hwfn,
  476. struct qed_ptt *p_ptt);
  477. /**
  478. * @brief Initialize the port interface with the MCP
  479. *
  480. * @param p_hwfn
  481. * @param p_ptt
  482. * Can only be called after `num_ports_in_engines' is set
  483. */
  484. void qed_mcp_cmd_port_init(struct qed_hwfn *p_hwfn,
  485. struct qed_ptt *p_ptt);
  486. /**
  487. * @brief Releases resources allocated during the init process.
  488. *
  489. * @param p_hwfn - HW func
  490. * @param p_ptt - PTT required for register access
  491. *
  492. * @return int
  493. */
  494. int qed_mcp_free(struct qed_hwfn *p_hwfn);
  495. /**
  496. * @brief This function is called from the DPC context. After
  497. * pointing PTT to the mfw mb, check for events sent by the MCP
  498. * to the driver and ack them. In case a critical event
  499. * detected, it will be handled here, otherwise the work will be
  500. * queued to a sleepable work-queue.
  501. *
  502. * @param p_hwfn - HW function
  503. * @param p_ptt - PTT required for register access
  504. * @return int - 0 - operation
  505. * was successul.
  506. */
  507. int qed_mcp_handle_events(struct qed_hwfn *p_hwfn,
  508. struct qed_ptt *p_ptt);
  509. enum qed_drv_role {
  510. QED_DRV_ROLE_OS,
  511. QED_DRV_ROLE_KDUMP,
  512. };
  513. struct qed_load_req_params {
  514. /* Input params */
  515. enum qed_drv_role drv_role;
  516. u8 timeout_val;
  517. bool avoid_eng_reset;
  518. enum qed_override_force_load override_force_load;
  519. /* Output params */
  520. u32 load_code;
  521. };
  522. /**
  523. * @brief Sends a LOAD_REQ to the MFW, and in case the operation succeeds,
  524. * returns whether this PF is the first on the engine/port or function.
  525. *
  526. * @param p_hwfn
  527. * @param p_ptt
  528. * @param p_params
  529. *
  530. * @return int - 0 - Operation was successful.
  531. */
  532. int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
  533. struct qed_ptt *p_ptt,
  534. struct qed_load_req_params *p_params);
  535. /**
  536. * @brief Sends a UNLOAD_REQ message to the MFW
  537. *
  538. * @param p_hwfn
  539. * @param p_ptt
  540. *
  541. * @return int - 0 - Operation was successful.
  542. */
  543. int qed_mcp_unload_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
  544. /**
  545. * @brief Sends a UNLOAD_DONE message to the MFW
  546. *
  547. * @param p_hwfn
  548. * @param p_ptt
  549. *
  550. * @return int - 0 - Operation was successful.
  551. */
  552. int qed_mcp_unload_done(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
  553. /**
  554. * @brief Read the MFW mailbox into Current buffer.
  555. *
  556. * @param p_hwfn
  557. * @param p_ptt
  558. */
  559. void qed_mcp_read_mb(struct qed_hwfn *p_hwfn,
  560. struct qed_ptt *p_ptt);
  561. /**
  562. * @brief Ack to mfw that driver finished FLR process for VFs
  563. *
  564. * @param p_hwfn
  565. * @param p_ptt
  566. * @param vfs_to_ack - bit mask of all engine VFs for which the PF acks.
  567. *
  568. * @param return int - 0 upon success.
  569. */
  570. int qed_mcp_ack_vf_flr(struct qed_hwfn *p_hwfn,
  571. struct qed_ptt *p_ptt, u32 *vfs_to_ack);
  572. /**
  573. * @brief - calls during init to read shmem of all function-related info.
  574. *
  575. * @param p_hwfn
  576. *
  577. * @param return 0 upon success.
  578. */
  579. int qed_mcp_fill_shmem_func_info(struct qed_hwfn *p_hwfn,
  580. struct qed_ptt *p_ptt);
  581. /**
  582. * @brief - Reset the MCP using mailbox command.
  583. *
  584. * @param p_hwfn
  585. * @param p_ptt
  586. *
  587. * @param return 0 upon success.
  588. */
  589. int qed_mcp_reset(struct qed_hwfn *p_hwfn,
  590. struct qed_ptt *p_ptt);
  591. /**
  592. * @brief - Sends an NVM read command request to the MFW to get
  593. * a buffer.
  594. *
  595. * @param p_hwfn
  596. * @param p_ptt
  597. * @param cmd - Command: DRV_MSG_CODE_NVM_GET_FILE_DATA or
  598. * DRV_MSG_CODE_NVM_READ_NVRAM commands
  599. * @param param - [0:23] - Offset [24:31] - Size
  600. * @param o_mcp_resp - MCP response
  601. * @param o_mcp_param - MCP response param
  602. * @param o_txn_size - Buffer size output
  603. * @param o_buf - Pointer to the buffer returned by the MFW.
  604. *
  605. * @param return 0 upon success.
  606. */
  607. int qed_mcp_nvm_rd_cmd(struct qed_hwfn *p_hwfn,
  608. struct qed_ptt *p_ptt,
  609. u32 cmd,
  610. u32 param,
  611. u32 *o_mcp_resp,
  612. u32 *o_mcp_param, u32 *o_txn_size, u32 *o_buf);
  613. /**
  614. * @brief indicates whether the MFW objects [under mcp_info] are accessible
  615. *
  616. * @param p_hwfn
  617. *
  618. * @return true iff MFW is running and mcp_info is initialized
  619. */
  620. bool qed_mcp_is_init(struct qed_hwfn *p_hwfn);
  621. /**
  622. * @brief request MFW to configure MSI-X for a VF
  623. *
  624. * @param p_hwfn
  625. * @param p_ptt
  626. * @param vf_id - absolute inside engine
  627. * @param num_sbs - number of entries to request
  628. *
  629. * @return int
  630. */
  631. int qed_mcp_config_vf_msix(struct qed_hwfn *p_hwfn,
  632. struct qed_ptt *p_ptt, u8 vf_id, u8 num);
  633. /**
  634. * @brief - Halt the MCP.
  635. *
  636. * @param p_hwfn
  637. * @param p_ptt
  638. *
  639. * @param return 0 upon success.
  640. */
  641. int qed_mcp_halt(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
  642. /**
  643. * @brief - Wake up the MCP.
  644. *
  645. * @param p_hwfn
  646. * @param p_ptt
  647. *
  648. * @param return 0 upon success.
  649. */
  650. int qed_mcp_resume(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
  651. int qed_configure_pf_min_bandwidth(struct qed_dev *cdev, u8 min_bw);
  652. int qed_configure_pf_max_bandwidth(struct qed_dev *cdev, u8 max_bw);
  653. int __qed_configure_pf_max_bandwidth(struct qed_hwfn *p_hwfn,
  654. struct qed_ptt *p_ptt,
  655. struct qed_mcp_link_state *p_link,
  656. u8 max_bw);
  657. int __qed_configure_pf_min_bandwidth(struct qed_hwfn *p_hwfn,
  658. struct qed_ptt *p_ptt,
  659. struct qed_mcp_link_state *p_link,
  660. u8 min_bw);
  661. int qed_mcp_mask_parities(struct qed_hwfn *p_hwfn,
  662. struct qed_ptt *p_ptt, u32 mask_parities);
  663. /**
  664. * @brief - Sets the MFW's max value for the given resource
  665. *
  666. * @param p_hwfn
  667. * @param p_ptt
  668. * @param res_id
  669. * @param resc_max_val
  670. * @param p_mcp_resp
  671. *
  672. * @return int - 0 - operation was successful.
  673. */
  674. int
  675. qed_mcp_set_resc_max_val(struct qed_hwfn *p_hwfn,
  676. struct qed_ptt *p_ptt,
  677. enum qed_resources res_id,
  678. u32 resc_max_val, u32 *p_mcp_resp);
  679. /**
  680. * @brief - Gets the MFW allocation info for the given resource
  681. *
  682. * @param p_hwfn
  683. * @param p_ptt
  684. * @param res_id
  685. * @param p_mcp_resp
  686. * @param p_resc_num
  687. * @param p_resc_start
  688. *
  689. * @return int - 0 - operation was successful.
  690. */
  691. int
  692. qed_mcp_get_resc_info(struct qed_hwfn *p_hwfn,
  693. struct qed_ptt *p_ptt,
  694. enum qed_resources res_id,
  695. u32 *p_mcp_resp, u32 *p_resc_num, u32 *p_resc_start);
  696. /**
  697. * @brief Send eswitch mode to MFW
  698. *
  699. * @param p_hwfn
  700. * @param p_ptt
  701. * @param eswitch - eswitch mode
  702. *
  703. * @return int - 0 - operation was successful.
  704. */
  705. int qed_mcp_ov_update_eswitch(struct qed_hwfn *p_hwfn,
  706. struct qed_ptt *p_ptt,
  707. enum qed_ov_eswitch eswitch);
  708. #define QED_MCP_RESC_LOCK_MIN_VAL RESOURCE_DUMP
  709. #define QED_MCP_RESC_LOCK_MAX_VAL 31
  710. enum qed_resc_lock {
  711. QED_RESC_LOCK_DBG_DUMP = QED_MCP_RESC_LOCK_MIN_VAL,
  712. QED_RESC_LOCK_PTP_PORT0,
  713. QED_RESC_LOCK_PTP_PORT1,
  714. QED_RESC_LOCK_PTP_PORT2,
  715. QED_RESC_LOCK_PTP_PORT3,
  716. QED_RESC_LOCK_RESC_ALLOC = QED_MCP_RESC_LOCK_MAX_VAL,
  717. QED_RESC_LOCK_RESC_INVALID
  718. };
  719. /**
  720. * @brief - Initiates PF FLR
  721. *
  722. * @param p_hwfn
  723. * @param p_ptt
  724. *
  725. * @return int - 0 - operation was successful.
  726. */
  727. int qed_mcp_initiate_pf_flr(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
  728. struct qed_resc_lock_params {
  729. /* Resource number [valid values are 0..31] */
  730. u8 resource;
  731. /* Lock timeout value in seconds [default, none or 1..254] */
  732. u8 timeout;
  733. #define QED_MCP_RESC_LOCK_TO_DEFAULT 0
  734. #define QED_MCP_RESC_LOCK_TO_NONE 255
  735. /* Number of times to retry locking */
  736. u8 retry_num;
  737. #define QED_MCP_RESC_LOCK_RETRY_CNT_DFLT 10
  738. /* The interval in usec between retries */
  739. u16 retry_interval;
  740. #define QED_MCP_RESC_LOCK_RETRY_VAL_DFLT 10000
  741. /* Use sleep or delay between retries */
  742. bool sleep_b4_retry;
  743. /* Will be set as true if the resource is free and granted */
  744. bool b_granted;
  745. /* Will be filled with the resource owner.
  746. * [0..15 = PF0-15, 16 = MFW]
  747. */
  748. u8 owner;
  749. };
  750. /**
  751. * @brief Acquires MFW generic resource lock
  752. *
  753. * @param p_hwfn
  754. * @param p_ptt
  755. * @param p_params
  756. *
  757. * @return int - 0 - operation was successful.
  758. */
  759. int
  760. qed_mcp_resc_lock(struct qed_hwfn *p_hwfn,
  761. struct qed_ptt *p_ptt, struct qed_resc_lock_params *p_params);
  762. struct qed_resc_unlock_params {
  763. /* Resource number [valid values are 0..31] */
  764. u8 resource;
  765. /* Allow to release a resource even if belongs to another PF */
  766. bool b_force;
  767. /* Will be set as true if the resource is released */
  768. bool b_released;
  769. };
  770. /**
  771. * @brief Releases MFW generic resource lock
  772. *
  773. * @param p_hwfn
  774. * @param p_ptt
  775. * @param p_params
  776. *
  777. * @return int - 0 - operation was successful.
  778. */
  779. int
  780. qed_mcp_resc_unlock(struct qed_hwfn *p_hwfn,
  781. struct qed_ptt *p_ptt,
  782. struct qed_resc_unlock_params *p_params);
  783. /**
  784. * @brief - default initialization for lock/unlock resource structs
  785. *
  786. * @param p_lock - lock params struct to be initialized; Can be NULL
  787. * @param p_unlock - unlock params struct to be initialized; Can be NULL
  788. * @param resource - the requested resource
  789. * @paral b_is_permanent - disable retries & aging when set
  790. */
  791. void qed_mcp_resc_lock_default_init(struct qed_resc_lock_params *p_lock,
  792. struct qed_resc_unlock_params *p_unlock,
  793. enum qed_resc_lock
  794. resource, bool b_is_permanent);
  795. #endif