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;
73 struct ecore_drv_tlv_hdr {
74 u8 tlv_type; /* According to the enum below */
75 u8 tlv_length; /* In dwords - not including this header */
77 #define ECORE_DRV_TLV_FLAGS_CHANGED 0x01
82 * @brief Initialize the interface with the MCP
84 * @param p_hwfn - HW func
85 * @param p_ptt - PTT required for register access
87 * @return enum _ecore_status_t
89 enum _ecore_status_t ecore_mcp_cmd_init(struct ecore_hwfn *p_hwfn,
90 struct ecore_ptt *p_ptt);
93 * @brief Initialize the port interface with the MCP
97 * Can only be called after `num_ports_in_engines' is set
99 void ecore_mcp_cmd_port_init(struct ecore_hwfn *p_hwfn,
100 struct ecore_ptt *p_ptt);
102 * @brief Releases resources allocated during the init process.
104 * @param p_hwfn - HW func
105 * @param p_ptt - PTT required for register access
107 * @return enum _ecore_status_t
110 enum _ecore_status_t ecore_mcp_free(struct ecore_hwfn *p_hwfn);
113 * @brief This function is called from the DPC context. After
114 * pointing PTT to the mfw mb, check for events sent by the MCP
115 * to the driver and ack them. In case a critical event
116 * detected, it will be handled here, otherwise the work will be
117 * queued to a sleepable work-queue.
119 * @param p_hwfn - HW function
120 * @param p_ptt - PTT required for register access
121 * @return enum _ecore_status_t - ECORE_SUCCESS - operation
124 enum _ecore_status_t ecore_mcp_handle_events(struct ecore_hwfn *p_hwfn,
125 struct ecore_ptt *p_ptt);
128 * @brief When MFW doesn't get driver pulse for couple of seconds, at some
129 * threshold before timeout expires, it will generate interrupt
130 * through a dedicated status block (DPSB - Driver Pulse Status
131 * Block), which the driver should respond immediately, by
132 * providing keepalive indication after setting the PTT to the
133 * driver-MFW mailbox. This function is called directly from the
134 * DPC upon receiving the DPSB attention.
136 * @param p_hwfn - hw function
137 * @param p_ptt - PTT required for register access
138 * @return enum _ecore_status_t - ECORE_SUCCESS - operation
141 enum _ecore_status_t ecore_issue_pulse(struct ecore_hwfn *p_hwfn,
142 struct ecore_ptt *p_ptt);
145 * @brief Sends a LOAD_REQ to the MFW, and in case operation
146 * succeed, returns whether this PF is the first on the
147 * chip/engine/port or function. This function should be
148 * called when driver is ready to accept MFW events after
149 * Storms initializations are done.
151 * @param p_hwfn - hw function
152 * @param p_ptt - PTT required for register access
153 * @param p_load_code - The MCP response param containing one
155 * FW_MSG_CODE_DRV_LOAD_ENGINE
156 * FW_MSG_CODE_DRV_LOAD_PORT
157 * FW_MSG_CODE_DRV_LOAD_FUNCTION
158 * @return enum _ecore_status_t -
159 * ECORE_SUCCESS - Operation was successul.
160 * ECORE_BUSY - Operation failed
162 enum _ecore_status_t ecore_mcp_load_req(struct ecore_hwfn *p_hwfn,
163 struct ecore_ptt *p_ptt,
167 * @brief Read the MFW mailbox into Current buffer.
172 void ecore_mcp_read_mb(struct ecore_hwfn *p_hwfn,
173 struct ecore_ptt *p_ptt);
176 * @brief Ack to mfw that driver finished FLR process for VFs
180 * @param vfs_to_ack - bit mask of all engine VFs for which the PF acks.
182 * @param return enum _ecore_status_t - ECORE_SUCCESS upon success.
184 enum _ecore_status_t ecore_mcp_ack_vf_flr(struct ecore_hwfn *p_hwfn,
185 struct ecore_ptt *p_ptt,
189 * @brief - calls during init to read shmem of all function-related info.
193 * @param return ECORE_SUCCESS upon success.
195 enum _ecore_status_t ecore_mcp_fill_shmem_func_info(struct ecore_hwfn *p_hwfn,
196 struct ecore_ptt *p_ptt);
199 * @brief - Reset the MCP using mailbox command.
204 * @param return ECORE_SUCCESS upon success.
206 enum _ecore_status_t ecore_mcp_reset(struct ecore_hwfn *p_hwfn,
207 struct ecore_ptt *p_ptt);
210 * @brief - Sends an NVM write command request to the MFW with
215 * @param cmd - Command: Either DRV_MSG_CODE_NVM_WRITE_NVRAM or
216 * DRV_MSG_CODE_NVM_PUT_FILE_DATA
217 * @param param - [0:23] - Offset [24:31] - Size
218 * @param o_mcp_resp - MCP response
219 * @param o_mcp_param - MCP response param
220 * @param i_txn_size - Buffer size
221 * @param i_buf - Pointer to the buffer
223 * @param return ECORE_SUCCESS upon success.
225 enum _ecore_status_t ecore_mcp_nvm_wr_cmd(struct ecore_hwfn *p_hwfn,
226 struct ecore_ptt *p_ptt,
235 * @brief - Sends an NVM read command request to the MFW to get
240 * @param cmd - Command: DRV_MSG_CODE_NVM_GET_FILE_DATA or
241 * DRV_MSG_CODE_NVM_READ_NVRAM commands
242 * @param param - [0:23] - Offset [24:31] - Size
243 * @param o_mcp_resp - MCP response
244 * @param o_mcp_param - MCP response param
245 * @param o_txn_size - Buffer size output
246 * @param o_buf - Pointer to the buffer returned by the MFW.
248 * @param return ECORE_SUCCESS upon success.
250 enum _ecore_status_t ecore_mcp_nvm_rd_cmd(struct ecore_hwfn *p_hwfn,
251 struct ecore_ptt *p_ptt,
260 * @brief indicates whether the MFW objects [under mcp_info] are accessible
264 * @return true iff MFW is running and mcp_info is initialized
266 bool ecore_mcp_is_init(struct ecore_hwfn *p_hwfn);
269 * @brief request MFW to configure MSI-X for a VF
273 * @param vf_id - absolute inside engine
274 * @param num_sbs - number of entries to request
276 * @return enum _ecore_status_t
278 enum _ecore_status_t ecore_mcp_config_vf_msix(struct ecore_hwfn *p_hwfn,
279 struct ecore_ptt *p_ptt,
283 * @brief - Halt the MCP.
288 * @param return ECORE_SUCCESS upon success.
290 enum _ecore_status_t ecore_mcp_halt(struct ecore_hwfn *p_hwfn,
291 struct ecore_ptt *p_ptt);
294 * @brief - Wake up the MCP.
299 * @param return ECORE_SUCCESS upon success.
301 enum _ecore_status_t ecore_mcp_resume(struct ecore_hwfn *p_hwfn,
302 struct ecore_ptt *p_ptt);
303 int __ecore_configure_pf_max_bandwidth(struct ecore_hwfn *p_hwfn,
304 struct ecore_ptt *p_ptt,
305 struct ecore_mcp_link_state *p_link,
307 int __ecore_configure_pf_min_bandwidth(struct ecore_hwfn *p_hwfn,
308 struct ecore_ptt *p_ptt,
309 struct ecore_mcp_link_state *p_link,
311 enum _ecore_status_t ecore_mcp_mask_parities(struct ecore_hwfn *p_hwfn,
312 struct ecore_ptt *p_ptt,
315 * @brief - Sends crash mdump related info to the MFW.
320 * @param return ECORE_SUCCESS upon success.
322 enum _ecore_status_t ecore_mcp_mdump_set_values(struct ecore_hwfn *p_hwfn,
323 struct ecore_ptt *p_ptt,
327 * @brief - Triggers a MFW crash dump procedure.
332 * @param return ECORE_SUCCESS upon success.
334 enum _ecore_status_t ecore_mcp_mdump_trigger(struct ecore_hwfn *p_hwfn,
335 struct ecore_ptt *p_ptt);
338 * @brief - Gets the MFW allocation info for the given resource
346 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
348 enum _ecore_status_t ecore_mcp_get_resc_info(struct ecore_hwfn *p_hwfn,
349 struct ecore_ptt *p_ptt,
350 struct resource_info *p_resc_info,
351 u32 *p_mcp_resp, u32 *p_mcp_param);
354 * @brief - Initiates PF FLR
359 * @param return ECORE_SUCCESS upon success.
361 enum _ecore_status_t ecore_mcp_initiate_pf_flr(struct ecore_hwfn *p_hwfn,
362 struct ecore_ptt *p_ptt);
364 #endif /* __ECORE_MCP_H__ */