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"
14 #include "ecore_mcp_api.h"
16 /* Using hwfn number (and not pf_num) is required since in CMT mode,
17 * same pf_num may be used by two different hwfn
18 * TODO - this shouldn't really be in .h file, but until all fields
19 * required during hw-init will be placed in their correct place in shmem
20 * we need it in ecore_dev.c [for readin the nvram reflection in shmem].
22 #define MCP_PF_ID_BY_REL(p_hwfn, rel_pfid) (ECORE_IS_BB((p_hwfn)->p_dev) ? \
24 ((p_hwfn)->abs_pf_id & 1) << 3) : \
26 #define MCP_PF_ID(p_hwfn) MCP_PF_ID_BY_REL(p_hwfn, (p_hwfn)->rel_pf_id)
28 #define MFW_PORT(_p_hwfn) ((_p_hwfn)->abs_pf_id % \
29 ((_p_hwfn)->p_dev->num_ports_in_engines * \
30 ecore_device_num_engines((_p_hwfn)->p_dev)))
32 struct ecore_mcp_info {
33 /* Spinlock used for protecting the access to the MFW mailbox */
35 /* Flag to indicate whether sending a MFW mailbox is forbidden */
36 bool block_mb_sending;
38 /* Address of the MCP public area */
40 /* Address of the driver mailbox */
42 /* Address of the MFW mailbox */
44 /* Address of the port configuration (link) */
47 /* Current driver mailbox sequence */
49 /* Current driver pulse sequence */
52 struct ecore_mcp_link_params link_input;
53 struct ecore_mcp_link_state link_output;
54 struct ecore_mcp_link_capabilities link_capabilities;
56 struct ecore_mcp_function_info func_info;
64 struct ecore_mcp_mb_params {
67 union drv_union_data *p_data_src;
68 union drv_union_data *p_data_dst;
74 * @brief Initialize the interface with the MCP
76 * @param p_hwfn - HW func
77 * @param p_ptt - PTT required for register access
79 * @return enum _ecore_status_t
81 enum _ecore_status_t ecore_mcp_cmd_init(struct ecore_hwfn *p_hwfn,
82 struct ecore_ptt *p_ptt);
85 * @brief Initialize the port interface with the MCP
89 * Can only be called after `num_ports_in_engines' is set
91 void ecore_mcp_cmd_port_init(struct ecore_hwfn *p_hwfn,
92 struct ecore_ptt *p_ptt);
94 * @brief Releases resources allocated during the init process.
96 * @param p_hwfn - HW func
97 * @param p_ptt - PTT required for register access
99 * @return enum _ecore_status_t
102 enum _ecore_status_t ecore_mcp_free(struct ecore_hwfn *p_hwfn);
105 * @brief This function is called from the DPC context. After
106 * pointing PTT to the mfw mb, check for events sent by the MCP
107 * to the driver and ack them. In case a critical event
108 * detected, it will be handled here, otherwise the work will be
109 * queued to a sleepable work-queue.
111 * @param p_hwfn - HW function
112 * @param p_ptt - PTT required for register access
113 * @return enum _ecore_status_t - ECORE_SUCCESS - operation
116 enum _ecore_status_t ecore_mcp_handle_events(struct ecore_hwfn *p_hwfn,
117 struct ecore_ptt *p_ptt);
120 * @brief When MFW doesn't get driver pulse for couple of seconds, at some
121 * threshold before timeout expires, it will generate interrupt
122 * through a dedicated status block (DPSB - Driver Pulse Status
123 * Block), which the driver should respond immediately, by
124 * providing keepalive indication after setting the PTT to the
125 * driver-MFW mailbox. This function is called directly from the
126 * DPC upon receiving the DPSB attention.
128 * @param p_hwfn - hw function
129 * @param p_ptt - PTT required for register access
130 * @return enum _ecore_status_t - ECORE_SUCCESS - operation
133 enum _ecore_status_t ecore_issue_pulse(struct ecore_hwfn *p_hwfn,
134 struct ecore_ptt *p_ptt);
137 * @brief Sends a LOAD_REQ to the MFW, and in case operation
138 * succeed, returns whether this PF is the first on the
139 * chip/engine/port or function. This function should be
140 * called when driver is ready to accept MFW events after
141 * Storms initializations are done.
143 * @param p_hwfn - hw function
144 * @param p_ptt - PTT required for register access
145 * @param p_load_code - The MCP response param containing one
147 * FW_MSG_CODE_DRV_LOAD_ENGINE
148 * FW_MSG_CODE_DRV_LOAD_PORT
149 * FW_MSG_CODE_DRV_LOAD_FUNCTION
150 * @return enum _ecore_status_t -
151 * ECORE_SUCCESS - Operation was successul.
152 * ECORE_BUSY - Operation failed
154 enum _ecore_status_t ecore_mcp_load_req(struct ecore_hwfn *p_hwfn,
155 struct ecore_ptt *p_ptt,
159 * @brief Read the MFW mailbox into Current buffer.
164 void ecore_mcp_read_mb(struct ecore_hwfn *p_hwfn,
165 struct ecore_ptt *p_ptt);
168 * @brief Ack to mfw that driver finished FLR process for VFs
172 * @param vfs_to_ack - bit mask of all engine VFs for which the PF acks.
174 * @param return enum _ecore_status_t - ECORE_SUCCESS upon success.
176 enum _ecore_status_t ecore_mcp_ack_vf_flr(struct ecore_hwfn *p_hwfn,
177 struct ecore_ptt *p_ptt,
181 * @brief - calls during init to read shmem of all function-related info.
185 * @param return ECORE_SUCCESS upon success.
187 enum _ecore_status_t ecore_mcp_fill_shmem_func_info(struct ecore_hwfn *p_hwfn,
188 struct ecore_ptt *p_ptt);
191 * @brief - Reset the MCP using mailbox command.
196 * @param return ECORE_SUCCESS upon success.
198 enum _ecore_status_t ecore_mcp_reset(struct ecore_hwfn *p_hwfn,
199 struct ecore_ptt *p_ptt);
202 * @brief - Sends an NVM write command request to the MFW with
207 * @param cmd - Command: Either DRV_MSG_CODE_NVM_WRITE_NVRAM or
208 * DRV_MSG_CODE_NVM_PUT_FILE_DATA
209 * @param param - [0:23] - Offset [24:31] - Size
210 * @param o_mcp_resp - MCP response
211 * @param o_mcp_param - MCP response param
212 * @param i_txn_size - Buffer size
213 * @param i_buf - Pointer to the buffer
215 * @param return ECORE_SUCCESS upon success.
217 enum _ecore_status_t ecore_mcp_nvm_wr_cmd(struct ecore_hwfn *p_hwfn,
218 struct ecore_ptt *p_ptt,
227 * @brief - Sends an NVM read command request to the MFW to get
232 * @param cmd - Command: DRV_MSG_CODE_NVM_GET_FILE_DATA or
233 * DRV_MSG_CODE_NVM_READ_NVRAM commands
234 * @param param - [0:23] - Offset [24:31] - Size
235 * @param o_mcp_resp - MCP response
236 * @param o_mcp_param - MCP response param
237 * @param o_txn_size - Buffer size output
238 * @param o_buf - Pointer to the buffer returned by the MFW.
240 * @param return ECORE_SUCCESS upon success.
242 enum _ecore_status_t ecore_mcp_nvm_rd_cmd(struct ecore_hwfn *p_hwfn,
243 struct ecore_ptt *p_ptt,
252 * @brief indicates whether the MFW objects [under mcp_info] are accessible
256 * @return true iff MFW is running and mcp_info is initialized
258 bool ecore_mcp_is_init(struct ecore_hwfn *p_hwfn);
261 * @brief request MFW to configure MSI-X for a VF
265 * @param vf_id - absolute inside engine
266 * @param num_sbs - number of entries to request
268 * @return enum _ecore_status_t
270 enum _ecore_status_t ecore_mcp_config_vf_msix(struct ecore_hwfn *p_hwfn,
271 struct ecore_ptt *p_ptt,
275 * @brief - Halt the MCP.
280 * @param return ECORE_SUCCESS upon success.
282 enum _ecore_status_t ecore_mcp_halt(struct ecore_hwfn *p_hwfn,
283 struct ecore_ptt *p_ptt);
286 * @brief - Wake up the MCP.
291 * @param return ECORE_SUCCESS upon success.
293 enum _ecore_status_t ecore_mcp_resume(struct ecore_hwfn *p_hwfn,
294 struct ecore_ptt *p_ptt);
295 int __ecore_configure_pf_max_bandwidth(struct ecore_hwfn *p_hwfn,
296 struct ecore_ptt *p_ptt,
297 struct ecore_mcp_link_state *p_link,
299 int __ecore_configure_pf_min_bandwidth(struct ecore_hwfn *p_hwfn,
300 struct ecore_ptt *p_ptt,
301 struct ecore_mcp_link_state *p_link,
303 enum _ecore_status_t ecore_mcp_mask_parities(struct ecore_hwfn *p_hwfn,
304 struct ecore_ptt *p_ptt,
307 * @brief - Sends crash mdump related info to the MFW.
312 * @param return ECORE_SUCCESS upon success.
314 enum _ecore_status_t ecore_mcp_mdump_set_values(struct ecore_hwfn *p_hwfn,
315 struct ecore_ptt *p_ptt,
319 * @brief - Triggers a MFW crash dump procedure.
324 * @param return ECORE_SUCCESS upon success.
326 enum _ecore_status_t ecore_mcp_mdump_trigger(struct ecore_hwfn *p_hwfn,
327 struct ecore_ptt *p_ptt);
330 * @brief - Gets the MFW allocation info for the given resource
338 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
340 enum _ecore_status_t ecore_mcp_get_resc_info(struct ecore_hwfn *p_hwfn,
341 struct ecore_ptt *p_ptt,
342 struct resource_info *p_resc_info,
343 u32 *p_mcp_resp, u32 *p_mcp_param);
346 * @brief - Initiates PF FLR
351 * @param return ECORE_SUCCESS upon success.
353 enum _ecore_status_t ecore_mcp_initiate_pf_flr(struct ecore_hwfn *p_hwfn,
354 struct ecore_ptt *p_ptt);
356 #endif /* __ECORE_MCP_H__ */