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);
144 enum ecore_drv_role {
146 ECORE_DRV_ROLE_KDUMP,
149 struct ecore_load_req_params {
150 enum ecore_drv_role drv_role;
151 u8 timeout_val; /* 1..254, '0' - default value, '255' - no timeout */
152 bool avoid_eng_reset;
157 * @brief Sends a LOAD_REQ to the MFW, and in case the operation succeeds,
158 * returns whether this PF is the first on the engine/port or function.
164 * @return enum _ecore_status_t - ECORE_SUCCESS - Operation was successful.
166 enum _ecore_status_t ecore_mcp_load_req(struct ecore_hwfn *p_hwfn,
167 struct ecore_ptt *p_ptt,
168 struct ecore_load_req_params *p_params);
171 * @brief Read the MFW mailbox into Current buffer.
176 void ecore_mcp_read_mb(struct ecore_hwfn *p_hwfn,
177 struct ecore_ptt *p_ptt);
180 * @brief Ack to mfw that driver finished FLR process for VFs
184 * @param vfs_to_ack - bit mask of all engine VFs for which the PF acks.
186 * @param return enum _ecore_status_t - ECORE_SUCCESS upon success.
188 enum _ecore_status_t ecore_mcp_ack_vf_flr(struct ecore_hwfn *p_hwfn,
189 struct ecore_ptt *p_ptt,
193 * @brief - calls during init to read shmem of all function-related info.
197 * @param return ECORE_SUCCESS upon success.
199 enum _ecore_status_t ecore_mcp_fill_shmem_func_info(struct ecore_hwfn *p_hwfn,
200 struct ecore_ptt *p_ptt);
203 * @brief - Reset the MCP using mailbox command.
208 * @param return ECORE_SUCCESS upon success.
210 enum _ecore_status_t ecore_mcp_reset(struct ecore_hwfn *p_hwfn,
211 struct ecore_ptt *p_ptt);
214 * @brief - Sends an NVM write command request to the MFW with
219 * @param cmd - Command: Either DRV_MSG_CODE_NVM_WRITE_NVRAM or
220 * DRV_MSG_CODE_NVM_PUT_FILE_DATA
221 * @param param - [0:23] - Offset [24:31] - Size
222 * @param o_mcp_resp - MCP response
223 * @param o_mcp_param - MCP response param
224 * @param i_txn_size - Buffer size
225 * @param i_buf - Pointer to the buffer
227 * @param return ECORE_SUCCESS upon success.
229 enum _ecore_status_t ecore_mcp_nvm_wr_cmd(struct ecore_hwfn *p_hwfn,
230 struct ecore_ptt *p_ptt,
239 * @brief - Sends an NVM read command request to the MFW to get
244 * @param cmd - Command: DRV_MSG_CODE_NVM_GET_FILE_DATA or
245 * DRV_MSG_CODE_NVM_READ_NVRAM commands
246 * @param param - [0:23] - Offset [24:31] - Size
247 * @param o_mcp_resp - MCP response
248 * @param o_mcp_param - MCP response param
249 * @param o_txn_size - Buffer size output
250 * @param o_buf - Pointer to the buffer returned by the MFW.
252 * @param return ECORE_SUCCESS upon success.
254 enum _ecore_status_t ecore_mcp_nvm_rd_cmd(struct ecore_hwfn *p_hwfn,
255 struct ecore_ptt *p_ptt,
264 * @brief indicates whether the MFW objects [under mcp_info] are accessible
268 * @return true iff MFW is running and mcp_info is initialized
270 bool ecore_mcp_is_init(struct ecore_hwfn *p_hwfn);
273 * @brief request MFW to configure MSI-X for a VF
277 * @param vf_id - absolute inside engine
278 * @param num_sbs - number of entries to request
280 * @return enum _ecore_status_t
282 enum _ecore_status_t ecore_mcp_config_vf_msix(struct ecore_hwfn *p_hwfn,
283 struct ecore_ptt *p_ptt,
287 * @brief - Halt the MCP.
292 * @param return ECORE_SUCCESS upon success.
294 enum _ecore_status_t ecore_mcp_halt(struct ecore_hwfn *p_hwfn,
295 struct ecore_ptt *p_ptt);
298 * @brief - Wake up the MCP.
303 * @param return ECORE_SUCCESS upon success.
305 enum _ecore_status_t ecore_mcp_resume(struct ecore_hwfn *p_hwfn,
306 struct ecore_ptt *p_ptt);
307 int __ecore_configure_pf_max_bandwidth(struct ecore_hwfn *p_hwfn,
308 struct ecore_ptt *p_ptt,
309 struct ecore_mcp_link_state *p_link,
311 int __ecore_configure_pf_min_bandwidth(struct ecore_hwfn *p_hwfn,
312 struct ecore_ptt *p_ptt,
313 struct ecore_mcp_link_state *p_link,
315 enum _ecore_status_t ecore_mcp_mask_parities(struct ecore_hwfn *p_hwfn,
316 struct ecore_ptt *p_ptt,
319 * @brief - Sends crash mdump related info to the MFW.
324 * @param return ECORE_SUCCESS upon success.
326 enum _ecore_status_t ecore_mcp_mdump_set_values(struct ecore_hwfn *p_hwfn,
327 struct ecore_ptt *p_ptt,
331 * @brief - Triggers a MFW crash dump procedure.
336 * @param return ECORE_SUCCESS upon success.
338 enum _ecore_status_t ecore_mcp_mdump_trigger(struct ecore_hwfn *p_hwfn,
339 struct ecore_ptt *p_ptt);
342 * @brief - Gets the MFW allocation info for the given resource
350 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
352 enum _ecore_status_t ecore_mcp_get_resc_info(struct ecore_hwfn *p_hwfn,
353 struct ecore_ptt *p_ptt,
354 struct resource_info *p_resc_info,
355 u32 *p_mcp_resp, u32 *p_mcp_param);
358 * @brief - Initiates PF FLR
363 * @param return ECORE_SUCCESS upon success.
365 enum _ecore_status_t ecore_mcp_initiate_pf_flr(struct ecore_hwfn *p_hwfn,
366 struct ecore_ptt *p_ptt);
368 #define ECORE_MCP_RESC_LOCK_TO_DEFAULT 0
369 #define ECORE_MCP_RESC_LOCK_TO_NONE 255
372 * @brief Acquires MFW generic resource lock
376 * @param resource_num - valid values are 0..31
377 * @param timeout - lock timeout value in seconds
378 * (1..254, '0' - default value, '255' - no timeout).
379 * @param p_granted - will be filled as true if the resource is free and
380 * granted, or false if it is busy.
381 * @param p_owner - A pointer to a variable to be filled with the resource
382 * owner (0..15 = PF0-15, 16 = MFW, 17 = diag over serial).
384 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
386 enum _ecore_status_t ecore_mcp_resc_lock(struct ecore_hwfn *p_hwfn,
387 struct ecore_ptt *p_ptt,
388 u8 resource_num, u8 timeout,
389 bool *p_granted, u8 *p_owner);
392 * @brief Releases MFW generic resource lock
396 * @param resource_num
397 * @param force - allows to release a reeource even if belongs to another PF
398 * @param p_released - will be filled as true if the resource is released (or
399 * has been already released), and false if the resource is
400 * acquired by another PF and the `force' flag was not set.
402 * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
404 enum _ecore_status_t ecore_mcp_resc_unlock(struct ecore_hwfn *p_hwfn,
405 struct ecore_ptt *p_ptt,
406 u8 resource_num, bool force,
409 #endif /* __ECORE_MCP_H__ */