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"
16 #include "ecore_dev_api.h"
18 /* Using hwfn number (and not pf_num) is required since in CMT mode,
19 * same pf_num may be used by two different hwfn
20 * TODO - this shouldn't really be in .h file, but until all fields
21 * required during hw-init will be placed in their correct place in shmem
22 * we need it in ecore_dev.c [for readin the nvram reflection in shmem].
24 #define MCP_PF_ID_BY_REL(p_hwfn, rel_pfid) (ECORE_IS_BB((p_hwfn)->p_dev) ? \
26 ((p_hwfn)->abs_pf_id & 1) << 3) : \
28 #define MCP_PF_ID(p_hwfn) MCP_PF_ID_BY_REL(p_hwfn, (p_hwfn)->rel_pf_id)
30 #define MFW_PORT(_p_hwfn) ((_p_hwfn)->abs_pf_id % \
31 ((_p_hwfn)->p_dev->num_ports_in_engines * \
32 ecore_device_num_engines((_p_hwfn)->p_dev)))
34 struct ecore_mcp_info {
35 /* List for mailbox commands which were sent and wait for a response */
38 /* Spinlock used for protecting the access to the mailbox commands list
39 * and the sending of the commands.
41 osal_spinlock_t cmd_lock;
43 /* Spinlock used for syncing SW link-changes and link-changes
44 * originating from attention context.
46 osal_spinlock_t link_lock;
48 /* Address of the MCP public area */
50 /* Address of the driver mailbox */
52 /* Address of the MFW mailbox */
54 /* Address of the port configuration (link) */
57 /* Current driver mailbox sequence */
59 /* Current driver pulse sequence */
62 struct ecore_mcp_link_params link_input;
63 struct ecore_mcp_link_state link_output;
64 struct ecore_mcp_link_capabilities link_capabilities;
66 struct ecore_mcp_function_info func_info;
73 /* Capabilties negotiated with the MFW */
77 struct ecore_mcp_mb_params {
88 struct ecore_drv_tlv_hdr {
89 u8 tlv_type; /* According to the enum below */
90 u8 tlv_length; /* In dwords - not including this header */
92 #define ECORE_DRV_TLV_FLAGS_CHANGED 0x01
97 * @brief Initialize the interface with the MCP
99 * @param p_hwfn - HW func
100 * @param p_ptt - PTT required for register access
102 * @return enum _ecore_status_t
104 enum _ecore_status_t ecore_mcp_cmd_init(struct ecore_hwfn *p_hwfn,
105 struct ecore_ptt *p_ptt);
108 * @brief Initialize the port interface with the MCP
112 * Can only be called after `num_ports_in_engines' is set
114 void ecore_mcp_cmd_port_init(struct ecore_hwfn *p_hwfn,
115 struct ecore_ptt *p_ptt);
117 * @brief Releases resources allocated during the init process.
119 * @param p_hwfn - HW func
120 * @param p_ptt - PTT required for register access
122 * @return enum _ecore_status_t
125 enum _ecore_status_t ecore_mcp_free(struct ecore_hwfn *p_hwfn);
128 * @brief This function is called from the DPC context. After
129 * pointing PTT to the mfw mb, check for events sent by the MCP
130 * to the driver and ack them. In case a critical event
131 * detected, it will be handled here, otherwise the work will be
132 * queued to a sleepable work-queue.
134 * @param p_hwfn - HW function
135 * @param p_ptt - PTT required for register access
136 * @return enum _ecore_status_t - ECORE_SUCCESS - operation
139 enum _ecore_status_t ecore_mcp_handle_events(struct ecore_hwfn *p_hwfn,
140 struct ecore_ptt *p_ptt);
143 * @brief When MFW doesn't get driver pulse for couple of seconds, at some
144 * threshold before timeout expires, it will generate interrupt
145 * through a dedicated status block (DPSB - Driver Pulse Status
146 * Block), which the driver should respond immediately, by
147 * providing keepalive indication after setting the PTT to the
148 * driver-MFW mailbox. This function is called directly from the
149 * DPC upon receiving the DPSB attention.
151 * @param p_hwfn - hw function
152 * @param p_ptt - PTT required for register access
153 * @return enum _ecore_status_t - ECORE_SUCCESS - operation
156 enum _ecore_status_t ecore_issue_pulse(struct ecore_hwfn *p_hwfn,
157 struct ecore_ptt *p_ptt);
159 enum ecore_drv_role {
161 ECORE_DRV_ROLE_KDUMP,
164 struct ecore_load_req_params {
166 enum ecore_drv_role drv_role;
167 u8 timeout_val; /* 1..254, '0' - default value, '255' - no timeout */
168 bool avoid_eng_reset;
169 enum ecore_override_force_load override_force_load;
176 * @brief Sends a LOAD_REQ to the MFW, and in case the operation succeeds,
177 * returns whether this PF is the first on the engine/port or function.
183 * @return enum _ecore_status_t - ECORE_SUCCESS - Operation was successful.
185 enum _ecore_status_t ecore_mcp_load_req(struct ecore_hwfn *p_hwfn,
186 struct ecore_ptt *p_ptt,
187 struct ecore_load_req_params *p_params);
190 * @brief Sends a LOAD_DONE message to the MFW
195 * @return enum _ecore_status_t - ECORE_SUCCESS - Operation was successful.
197 enum _ecore_status_t ecore_mcp_load_done(struct ecore_hwfn *p_hwfn,
198 struct ecore_ptt *p_ptt);
201 * @brief Sends a UNLOAD_REQ message to the MFW
206 * @return enum _ecore_status_t - ECORE_SUCCESS - Operation was successful.
208 enum _ecore_status_t ecore_mcp_unload_req(struct ecore_hwfn *p_hwfn,
209 struct ecore_ptt *p_ptt);
212 * @brief Sends a UNLOAD_DONE message to the MFW
217 * @return enum _ecore_status_t - ECORE_SUCCESS - Operation was successful.
219 enum _ecore_status_t ecore_mcp_unload_done(struct ecore_hwfn *p_hwfn,
220 struct ecore_ptt *p_ptt);
223 * @brief Read the MFW mailbox into Current buffer.
228 void ecore_mcp_read_mb(struct ecore_hwfn *p_hwfn,
229 struct ecore_ptt *p_ptt);
232 * @brief Ack to mfw that driver finished FLR process for VFs
236 * @param vfs_to_ack - bit mask of all engine VFs for which the PF acks.
238 * @param return enum _ecore_status_t - ECORE_SUCCESS upon success.
240 enum _ecore_status_t ecore_mcp_ack_vf_flr(struct ecore_hwfn *p_hwfn,
241 struct ecore_ptt *p_ptt,
245 * @brief - calls during init to read shmem of all function-related info.
249 * @param return ECORE_SUCCESS upon success.
251 enum _ecore_status_t ecore_mcp_fill_shmem_func_info(struct ecore_hwfn *p_hwfn,
252 struct ecore_ptt *p_ptt);
255 * @brief - Reset the MCP using mailbox command.
260 * @param return ECORE_SUCCESS upon success.
262 enum _ecore_status_t ecore_mcp_reset(struct ecore_hwfn *p_hwfn,
263 struct ecore_ptt *p_ptt);
266 * @brief indicates whether the MFW objects [under mcp_info] are accessible
270 * @return true iff MFW is running and mcp_info is initialized
272 bool ecore_mcp_is_init(struct ecore_hwfn *p_hwfn);
275 * @brief request MFW to configure MSI-X for a VF
279 * @param vf_id - absolute inside engine
280 * @param num_sbs - number of entries to request
282 * @return enum _ecore_status_t
284 enum _ecore_status_t ecore_mcp_config_vf_msix(struct ecore_hwfn *p_hwfn,
285 struct ecore_ptt *p_ptt,
289 * @brief - Halt the MCP.
294 * @param return ECORE_SUCCESS upon success.
296 enum _ecore_status_t ecore_mcp_halt(struct ecore_hwfn *p_hwfn,
297 struct ecore_ptt *p_ptt);
300 * @brief - Wake up the MCP.
305 * @param return ECORE_SUCCESS upon success.
307 enum _ecore_status_t ecore_mcp_resume(struct ecore_hwfn *p_hwfn,
308 struct ecore_ptt *p_ptt);
309 int __ecore_configure_pf_max_bandwidth(struct ecore_hwfn *p_hwfn,
310 struct ecore_ptt *p_ptt,
311 struct ecore_mcp_link_state *p_link,
313 int __ecore_configure_pf_min_bandwidth(struct ecore_hwfn *p_hwfn,
314 struct ecore_ptt *p_ptt,
315 struct ecore_mcp_link_state *p_link,
317 enum _ecore_status_t ecore_mcp_mask_parities(struct ecore_hwfn *p_hwfn,
318 struct ecore_ptt *p_ptt,
321 * @brief - Sends crash mdump related info to the MFW.
326 * @param return ECORE_SUCCESS upon success.
328 enum _ecore_status_t ecore_mcp_mdump_set_values(struct ecore_hwfn *p_hwfn,
329 struct ecore_ptt *p_ptt,
333 * @brief - Triggers a MFW crash dump procedure.
339 * @param return ECORE_SUCCESS upon success.
341 enum _ecore_status_t ecore_mcp_mdump_trigger(struct ecore_hwfn *p_hwfn,
342 struct ecore_ptt *p_ptt);
344 struct ecore_mdump_retain_data {
352 * @brief - Gets the mdump retained data from the MFW.
356 * @param p_mdump_retain
358 * @param return ECORE_SUCCESS upon success.
361 ecore_mcp_mdump_get_retain(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
362 struct ecore_mdump_retain_data *p_mdump_retain);
365 * @brief - Sets the MFW's max value for the given resource
370 * @param resc_max_val
373 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
376 ecore_mcp_set_resc_max_val(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
377 enum ecore_resources res_id, u32 resc_max_val,
381 * @brief - Gets the MFW allocation info for the given resource
388 * @param p_resc_start
390 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
393 ecore_mcp_get_resc_info(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
394 enum ecore_resources res_id, u32 *p_mcp_resp,
395 u32 *p_resc_num, u32 *p_resc_start);
398 * @brief - Initiates PF FLR
403 * @param return ECORE_SUCCESS upon success.
405 enum _ecore_status_t ecore_mcp_initiate_pf_flr(struct ecore_hwfn *p_hwfn,
406 struct ecore_ptt *p_ptt);
408 #define ECORE_MCP_RESC_LOCK_MIN_VAL RESOURCE_DUMP /* 0 */
409 #define ECORE_MCP_RESC_LOCK_MAX_VAL 31
411 enum ecore_resc_lock {
412 ECORE_RESC_LOCK_DBG_DUMP = ECORE_MCP_RESC_LOCK_MIN_VAL,
413 /* Locks that the MFW is aware of should be added here downwards */
415 /* Ecore only locks should be added here upwards */
416 ECORE_RESC_LOCK_RESC_ALLOC = ECORE_MCP_RESC_LOCK_MAX_VAL
419 struct ecore_resc_lock_params {
420 /* Resource number [valid values are 0..31] */
423 /* Lock timeout value in seconds [default, none or 1..254] */
425 #define ECORE_MCP_RESC_LOCK_TO_DEFAULT 0
426 #define ECORE_MCP_RESC_LOCK_TO_NONE 255
428 /* Number of times to retry locking */
431 /* The interval in usec between retries */
434 /* Use sleep or delay between retries */
437 /* Will be set as true if the resource is free and granted */
440 /* Will be filled with the resource owner.
441 * [0..15 = PF0-15, 16 = MFW, 17 = diag over serial]
447 * @brief Acquires MFW generic resource lock
453 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
456 ecore_mcp_resc_lock(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
457 struct ecore_resc_lock_params *p_params);
459 struct ecore_resc_unlock_params {
460 /* Resource number [valid values are 0..31] */
463 /* Allow to release a resource even if belongs to another PF */
466 /* Will be set as true if the resource is released */
471 * @brief Releases MFW generic resource lock
477 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
480 ecore_mcp_resc_unlock(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
481 struct ecore_resc_unlock_params *p_params);
484 * @brief Learn of supported MFW features; To be done during early init
489 enum _ecore_status_t ecore_mcp_get_capabilities(struct ecore_hwfn *p_hwfn,
490 struct ecore_ptt *p_ptt);
493 * @brief Inform MFW of set of features supported by driver. Should be done
494 * inside the contet of the LOAD_REQ.
499 enum _ecore_status_t ecore_mcp_set_capabilities(struct ecore_hwfn *p_hwfn,
500 struct ecore_ptt *p_ptt);
502 #endif /* __ECORE_MCP_H__ */