qed_mcp.h 23 KB

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