2 * Copyright (c) 2016 QLogic Corporation.
6 * See LICENSE.qede_pmd for copyright and licensing details.
9 #ifndef __ECORE_MCP_H__
10 #define __ECORE_MCP_H__
13 #include "mcp_public.h"
15 #include "ecore_mcp_api.h"
17 /* Using hwfn number (and not pf_num) is required since in CMT mode,
18 * same pf_num may be used by two different hwfn
19 * TODO - this shouldn't really be in .h file, but until all fields
20 * required during hw-init will be placed in their correct place in shmem
21 * we need it in ecore_dev.c [for readin the nvram reflection in shmem].
23 #define MCP_PF_ID_BY_REL(p_hwfn, rel_pfid) (ECORE_IS_BB((p_hwfn)->p_dev) ? \
25 ((p_hwfn)->abs_pf_id & 1) << 3) : \
27 #define MCP_PF_ID(p_hwfn) MCP_PF_ID_BY_REL(p_hwfn, (p_hwfn)->rel_pf_id)
29 #define MFW_PORT(_p_hwfn) ((_p_hwfn)->abs_pf_id % \
30 ((_p_hwfn)->p_dev->num_ports_in_engines * \
31 ecore_device_num_engines((_p_hwfn)->p_dev)))
33 struct ecore_mcp_info {
34 /* Spinlock used for protecting the access to the MFW mailbox */
36 /* Flag to indicate whether sending a MFW mailbox is forbidden */
37 bool block_mb_sending;
39 /* Address of the MCP public area */
41 /* Address of the driver mailbox */
43 /* Address of the MFW mailbox */
45 /* Address of the port configuration (link) */
48 /* Current driver mailbox sequence */
50 /* Current driver pulse sequence */
53 struct ecore_mcp_link_params link_input;
54 struct ecore_mcp_link_state link_output;
55 struct ecore_mcp_link_capabilities link_capabilities;
57 struct ecore_mcp_function_info func_info;
64 /* Capabilties negotiated with the MFW */
68 struct ecore_mcp_mb_params {
79 struct ecore_drv_tlv_hdr {
80 u8 tlv_type; /* According to the enum below */
81 u8 tlv_length; /* In dwords - not including this header */
83 #define ECORE_DRV_TLV_FLAGS_CHANGED 0x01
88 * @brief Initialize the interface with the MCP
90 * @param p_hwfn - HW func
91 * @param p_ptt - PTT required for register access
93 * @return enum _ecore_status_t
95 enum _ecore_status_t ecore_mcp_cmd_init(struct ecore_hwfn *p_hwfn,
96 struct ecore_ptt *p_ptt);
99 * @brief Initialize the port interface with the MCP
103 * Can only be called after `num_ports_in_engines' is set
105 void ecore_mcp_cmd_port_init(struct ecore_hwfn *p_hwfn,
106 struct ecore_ptt *p_ptt);
108 * @brief Releases resources allocated during the init process.
110 * @param p_hwfn - HW func
111 * @param p_ptt - PTT required for register access
113 * @return enum _ecore_status_t
116 enum _ecore_status_t ecore_mcp_free(struct ecore_hwfn *p_hwfn);
119 * @brief This function is called from the DPC context. After
120 * pointing PTT to the mfw mb, check for events sent by the MCP
121 * to the driver and ack them. In case a critical event
122 * detected, it will be handled here, otherwise the work will be
123 * queued to a sleepable work-queue.
125 * @param p_hwfn - HW function
126 * @param p_ptt - PTT required for register access
127 * @return enum _ecore_status_t - ECORE_SUCCESS - operation
130 enum _ecore_status_t ecore_mcp_handle_events(struct ecore_hwfn *p_hwfn,
131 struct ecore_ptt *p_ptt);
134 * @brief When MFW doesn't get driver pulse for couple of seconds, at some
135 * threshold before timeout expires, it will generate interrupt
136 * through a dedicated status block (DPSB - Driver Pulse Status
137 * Block), which the driver should respond immediately, by
138 * providing keepalive indication after setting the PTT to the
139 * driver-MFW mailbox. This function is called directly from the
140 * DPC upon receiving the DPSB attention.
142 * @param p_hwfn - hw function
143 * @param p_ptt - PTT required for register access
144 * @return enum _ecore_status_t - ECORE_SUCCESS - operation
147 enum _ecore_status_t ecore_issue_pulse(struct ecore_hwfn *p_hwfn,
148 struct ecore_ptt *p_ptt);
150 enum ecore_drv_role {
152 ECORE_DRV_ROLE_KDUMP,
155 struct ecore_load_req_params {
156 enum ecore_drv_role drv_role;
157 u8 timeout_val; /* 1..254, '0' - default value, '255' - no timeout */
158 bool avoid_eng_reset;
163 * @brief Sends a LOAD_REQ to the MFW, and in case the operation succeeds,
164 * returns whether this PF is the first on the engine/port or function.
170 * @return enum _ecore_status_t - ECORE_SUCCESS - Operation was successful.
172 enum _ecore_status_t ecore_mcp_load_req(struct ecore_hwfn *p_hwfn,
173 struct ecore_ptt *p_ptt,
174 struct ecore_load_req_params *p_params);
177 * @brief Sends a LOAD_DONE message to the MFW
182 * @return enum _ecore_status_t - ECORE_SUCCESS - Operation was successful.
184 enum _ecore_status_t ecore_mcp_load_done(struct ecore_hwfn *p_hwfn,
185 struct ecore_ptt *p_ptt);
188 * @brief Sends a UNLOAD_REQ message to the MFW
193 * @return enum _ecore_status_t - ECORE_SUCCESS - Operation was successful.
195 enum _ecore_status_t ecore_mcp_unload_req(struct ecore_hwfn *p_hwfn,
196 struct ecore_ptt *p_ptt);
199 * @brief Sends a UNLOAD_DONE message to the MFW
204 * @return enum _ecore_status_t - ECORE_SUCCESS - Operation was successful.
206 enum _ecore_status_t ecore_mcp_unload_done(struct ecore_hwfn *p_hwfn,
207 struct ecore_ptt *p_ptt);
210 * @brief Read the MFW mailbox into Current buffer.
215 void ecore_mcp_read_mb(struct ecore_hwfn *p_hwfn,
216 struct ecore_ptt *p_ptt);
219 * @brief Ack to mfw that driver finished FLR process for VFs
223 * @param vfs_to_ack - bit mask of all engine VFs for which the PF acks.
225 * @param return enum _ecore_status_t - ECORE_SUCCESS upon success.
227 enum _ecore_status_t ecore_mcp_ack_vf_flr(struct ecore_hwfn *p_hwfn,
228 struct ecore_ptt *p_ptt,
232 * @brief - calls during init to read shmem of all function-related info.
236 * @param return ECORE_SUCCESS upon success.
238 enum _ecore_status_t ecore_mcp_fill_shmem_func_info(struct ecore_hwfn *p_hwfn,
239 struct ecore_ptt *p_ptt);
242 * @brief - Reset the MCP using mailbox command.
247 * @param return ECORE_SUCCESS upon success.
249 enum _ecore_status_t ecore_mcp_reset(struct ecore_hwfn *p_hwfn,
250 struct ecore_ptt *p_ptt);
253 * @brief - Sends an NVM write command request to the MFW with
258 * @param cmd - Command: Either DRV_MSG_CODE_NVM_WRITE_NVRAM or
259 * DRV_MSG_CODE_NVM_PUT_FILE_DATA
260 * @param param - [0:23] - Offset [24:31] - Size
261 * @param o_mcp_resp - MCP response
262 * @param o_mcp_param - MCP response param
263 * @param i_txn_size - Buffer size
264 * @param i_buf - Pointer to the buffer
266 * @param return ECORE_SUCCESS upon success.
268 enum _ecore_status_t ecore_mcp_nvm_wr_cmd(struct ecore_hwfn *p_hwfn,
269 struct ecore_ptt *p_ptt,
278 * @brief - Sends an NVM read command request to the MFW to get
283 * @param cmd - Command: DRV_MSG_CODE_NVM_GET_FILE_DATA or
284 * DRV_MSG_CODE_NVM_READ_NVRAM commands
285 * @param param - [0:23] - Offset [24:31] - Size
286 * @param o_mcp_resp - MCP response
287 * @param o_mcp_param - MCP response param
288 * @param o_txn_size - Buffer size output
289 * @param o_buf - Pointer to the buffer returned by the MFW.
291 * @param return ECORE_SUCCESS upon success.
293 enum _ecore_status_t ecore_mcp_nvm_rd_cmd(struct ecore_hwfn *p_hwfn,
294 struct ecore_ptt *p_ptt,
303 * @brief indicates whether the MFW objects [under mcp_info] are accessible
307 * @return true iff MFW is running and mcp_info is initialized
309 bool ecore_mcp_is_init(struct ecore_hwfn *p_hwfn);
312 * @brief request MFW to configure MSI-X for a VF
316 * @param vf_id - absolute inside engine
317 * @param num_sbs - number of entries to request
319 * @return enum _ecore_status_t
321 enum _ecore_status_t ecore_mcp_config_vf_msix(struct ecore_hwfn *p_hwfn,
322 struct ecore_ptt *p_ptt,
326 * @brief - Halt the MCP.
331 * @param return ECORE_SUCCESS upon success.
333 enum _ecore_status_t ecore_mcp_halt(struct ecore_hwfn *p_hwfn,
334 struct ecore_ptt *p_ptt);
337 * @brief - Wake up the MCP.
342 * @param return ECORE_SUCCESS upon success.
344 enum _ecore_status_t ecore_mcp_resume(struct ecore_hwfn *p_hwfn,
345 struct ecore_ptt *p_ptt);
346 int __ecore_configure_pf_max_bandwidth(struct ecore_hwfn *p_hwfn,
347 struct ecore_ptt *p_ptt,
348 struct ecore_mcp_link_state *p_link,
350 int __ecore_configure_pf_min_bandwidth(struct ecore_hwfn *p_hwfn,
351 struct ecore_ptt *p_ptt,
352 struct ecore_mcp_link_state *p_link,
354 enum _ecore_status_t ecore_mcp_mask_parities(struct ecore_hwfn *p_hwfn,
355 struct ecore_ptt *p_ptt,
358 * @brief - Sends crash mdump related info to the MFW.
363 * @param return ECORE_SUCCESS upon success.
365 enum _ecore_status_t ecore_mcp_mdump_set_values(struct ecore_hwfn *p_hwfn,
366 struct ecore_ptt *p_ptt,
370 * @brief - Triggers a MFW crash dump procedure.
375 * @param return ECORE_SUCCESS upon success.
377 enum _ecore_status_t ecore_mcp_mdump_trigger(struct ecore_hwfn *p_hwfn,
378 struct ecore_ptt *p_ptt);
381 * @brief - Sets the MFW's max value for the given resource
386 * @param resc_max_val
389 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
392 ecore_mcp_set_resc_max_val(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
393 enum ecore_resources res_id, u32 resc_max_val,
397 * @brief - Gets the MFW allocation info for the given resource
404 * @param p_resc_start
406 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
409 ecore_mcp_get_resc_info(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
410 enum ecore_resources res_id, u32 *p_mcp_resp,
411 u32 *p_resc_num, u32 *p_resc_start);
414 * @brief - Initiates PF FLR
419 * @param return ECORE_SUCCESS upon success.
421 enum _ecore_status_t ecore_mcp_initiate_pf_flr(struct ecore_hwfn *p_hwfn,
422 struct ecore_ptt *p_ptt);
424 #define ECORE_MCP_RESC_LOCK_MIN_VAL RESOURCE_DUMP /* 0 */
425 #define ECORE_MCP_RESC_LOCK_MAX_VAL 31
427 enum ecore_resc_lock {
428 ECORE_RESC_LOCK_DBG_DUMP = ECORE_MCP_RESC_LOCK_MIN_VAL,
429 /* Locks that the MFW is aware of should be added here downwards */
431 /* Ecore only locks should be added here upwards */
432 ECORE_RESC_LOCK_RESC_ALLOC = ECORE_MCP_RESC_LOCK_MAX_VAL
435 struct ecore_resc_lock_params {
436 /* Resource number [valid values are 0..31] */
439 /* Lock timeout value in seconds [default, none or 1..254] */
441 #define ECORE_MCP_RESC_LOCK_TO_DEFAULT 0
442 #define ECORE_MCP_RESC_LOCK_TO_NONE 255
444 /* Number of times to retry locking */
447 /* The interval in usec between retries */
450 /* Use sleep or delay between retries */
453 /* Will be set as true if the resource is free and granted */
456 /* Will be filled with the resource owner.
457 * [0..15 = PF0-15, 16 = MFW, 17 = diag over serial]
463 * @brief Acquires MFW generic resource lock
469 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
472 ecore_mcp_resc_lock(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
473 struct ecore_resc_lock_params *p_params);
475 struct ecore_resc_unlock_params {
476 /* Resource number [valid values are 0..31] */
479 /* Allow to release a resource even if belongs to another PF */
482 /* Will be set as true if the resource is released */
487 * @brief Releases MFW generic resource lock
493 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
496 ecore_mcp_resc_unlock(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
497 struct ecore_resc_unlock_params *p_params);
500 * @brief Learn of supported MFW features; To be done during early init
505 enum _ecore_status_t ecore_mcp_get_capabilities(struct ecore_hwfn *p_hwfn,
506 struct ecore_ptt *p_ptt);
509 * @brief Inform MFW of set of features supported by driver. Should be done
510 * inside the contet of the LOAD_REQ.
515 enum _ecore_status_t ecore_mcp_set_capabilities(struct ecore_hwfn *p_hwfn,
516 struct ecore_ptt *p_ptt);
518 #endif /* __ECORE_MCP_H__ */