net/qede/base: remove unused parameters
[dpdk.git] / drivers / net / qede / base / ecore_mcp.h
1 /*
2  * Copyright (c) 2016 QLogic Corporation.
3  * All rights reserved.
4  * www.qlogic.com
5  *
6  * See LICENSE.qede_pmd for copyright and licensing details.
7  */
8
9 #ifndef __ECORE_MCP_H__
10 #define __ECORE_MCP_H__
11
12 #include "bcm_osal.h"
13 #include "mcp_public.h"
14 #include "ecore.h"
15 #include "ecore_mcp_api.h"
16 #include "ecore_dev_api.h"
17
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].
23  */
24 #define MCP_PF_ID_BY_REL(p_hwfn, rel_pfid) (ECORE_IS_BB((p_hwfn)->p_dev) ? \
25                                             ((rel_pfid) | \
26                                              ((p_hwfn)->abs_pf_id & 1) << 3) : \
27                                              rel_pfid)
28 #define MCP_PF_ID(p_hwfn) MCP_PF_ID_BY_REL(p_hwfn, (p_hwfn)->rel_pf_id)
29
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)))
33
34 struct ecore_mcp_info {
35         /* List for mailbox commands which were sent and wait for a response */
36         osal_list_t cmd_list;
37
38         /* Spinlock used for protecting the access to the mailbox commands list
39          * and the sending of the commands.
40          */
41         osal_spinlock_t cmd_lock;
42
43         /* Flag to indicate whether sending a MFW mailbox command is blocked */
44         bool b_block_cmd;
45
46         /* Spinlock used for syncing SW link-changes and link-changes
47          * originating from attention context.
48          */
49         osal_spinlock_t link_lock;
50
51         /* Address of the MCP public area */
52         u32 public_base;
53         /* Address of the driver mailbox */
54         u32 drv_mb_addr;
55         /* Address of the MFW mailbox */
56         u32 mfw_mb_addr;
57         /* Address of the port configuration (link) */
58         u32 port_addr;
59
60         /* Current driver mailbox sequence */
61         u16 drv_mb_seq;
62         /* Current driver pulse sequence */
63         u16 drv_pulse_seq;
64
65         struct ecore_mcp_link_params       link_input;
66         struct ecore_mcp_link_state        link_output;
67         struct ecore_mcp_link_capabilities link_capabilities;
68
69         struct ecore_mcp_function_info     func_info;
70
71         u8 *mfw_mb_cur;
72         u8 *mfw_mb_shadow;
73         u16 mfw_mb_length;
74         u32 mcp_hist;
75
76         /* Capabilties negotiated with the MFW */
77         u32 capabilities;
78 };
79
80 struct ecore_mcp_mb_params {
81         u32 cmd;
82         u32 param;
83         void *p_data_src;
84         u8 data_src_size;
85         void *p_data_dst;
86         u8 data_dst_size;
87         u32 mcp_resp;
88         u32 mcp_param;
89 };
90
91 struct ecore_drv_tlv_hdr {
92         u8 tlv_type;    /* According to the enum below */
93         u8 tlv_length;  /* In dwords - not including this header */
94         u8 tlv_reserved;
95 #define ECORE_DRV_TLV_FLAGS_CHANGED 0x01
96         u8 tlv_flags;
97 };
98
99 /**
100  * @brief Initialize the interface with the MCP
101  *
102  * @param p_hwfn - HW func
103  * @param p_ptt - PTT required for register access
104  *
105  * @return enum _ecore_status_t
106  */
107 enum _ecore_status_t ecore_mcp_cmd_init(struct ecore_hwfn *p_hwfn,
108                                         struct ecore_ptt *p_ptt);
109
110 /**
111  * @brief Initialize the port interface with the MCP
112  *
113  * @param p_hwfn
114  * @param p_ptt
115  * Can only be called after `num_ports_in_engines' is set
116  */
117 void ecore_mcp_cmd_port_init(struct ecore_hwfn *p_hwfn,
118                              struct ecore_ptt *p_ptt);
119 /**
120  * @brief Releases resources allocated during the init process.
121  *
122  * @param p_hwfn - HW func
123  * @param p_ptt - PTT required for register access
124  *
125  * @return enum _ecore_status_t
126  */
127
128 enum _ecore_status_t ecore_mcp_free(struct ecore_hwfn *p_hwfn);
129
130 /**
131  * @brief This function is called from the DPC context. After
132  * pointing PTT to the mfw mb, check for events sent by the MCP
133  * to the driver and ack them. In case a critical event
134  * detected, it will be handled here, otherwise the work will be
135  * queued to a sleepable work-queue.
136  *
137  * @param p_hwfn - HW function
138  * @param p_ptt - PTT required for register access
139  * @return enum _ecore_status_t - ECORE_SUCCESS - operation
140  * was successul.
141  */
142 enum _ecore_status_t ecore_mcp_handle_events(struct ecore_hwfn *p_hwfn,
143                                              struct ecore_ptt *p_ptt);
144
145 /**
146  * @brief When MFW doesn't get driver pulse for couple of seconds, at some
147  * threshold before timeout expires, it will generate interrupt
148  * through a dedicated status block (DPSB - Driver Pulse Status
149  * Block), which the driver should respond immediately, by
150  * providing keepalive indication after setting the PTT to the
151  * driver-MFW mailbox. This function is called directly from the
152  * DPC upon receiving the DPSB attention.
153  *
154  * @param p_hwfn - hw function
155  * @param p_ptt - PTT required for register access
156  * @return enum _ecore_status_t - ECORE_SUCCESS - operation
157  * was successful.
158  */
159 enum _ecore_status_t ecore_issue_pulse(struct ecore_hwfn *p_hwfn,
160                                        struct ecore_ptt *p_ptt);
161
162 enum ecore_drv_role {
163         ECORE_DRV_ROLE_OS,
164         ECORE_DRV_ROLE_KDUMP,
165 };
166
167 struct ecore_load_req_params {
168         /* Input params */
169         enum ecore_drv_role drv_role;
170         u8 timeout_val; /* 1..254, '0' - default value, '255' - no timeout */
171         bool avoid_eng_reset;
172         enum ecore_override_force_load override_force_load;
173
174         /* Output params */
175         u32 load_code;
176 };
177
178 /**
179  * @brief Sends a LOAD_REQ to the MFW, and in case the operation succeeds,
180  *        returns whether this PF is the first on the engine/port or function.
181  *
182  * @param p_hwfn
183  * @param p_ptt
184  * @param p_params
185  *
186  * @return enum _ecore_status_t - ECORE_SUCCESS - Operation was successful.
187  */
188 enum _ecore_status_t ecore_mcp_load_req(struct ecore_hwfn *p_hwfn,
189                                         struct ecore_ptt *p_ptt,
190                                         struct ecore_load_req_params *p_params);
191
192 /**
193  * @brief Sends a LOAD_DONE message to the MFW
194  *
195  * @param p_hwfn
196  * @param p_ptt
197  *
198  * @return enum _ecore_status_t - ECORE_SUCCESS - Operation was successful.
199  */
200 enum _ecore_status_t ecore_mcp_load_done(struct ecore_hwfn *p_hwfn,
201                                          struct ecore_ptt *p_ptt);
202
203 /**
204  * @brief Sends a UNLOAD_REQ message to the MFW
205  *
206  * @param p_hwfn
207  * @param p_ptt
208  *
209  * @return enum _ecore_status_t - ECORE_SUCCESS - Operation was successful.
210  */
211 enum _ecore_status_t ecore_mcp_unload_req(struct ecore_hwfn *p_hwfn,
212                                           struct ecore_ptt *p_ptt);
213
214 /**
215  * @brief Sends a UNLOAD_DONE message to the MFW
216  *
217  * @param p_hwfn
218  * @param p_ptt
219  *
220  * @return enum _ecore_status_t - ECORE_SUCCESS - Operation was successful.
221  */
222 enum _ecore_status_t ecore_mcp_unload_done(struct ecore_hwfn *p_hwfn,
223                                            struct ecore_ptt *p_ptt);
224
225 /**
226  * @brief Read the MFW mailbox into Current buffer.
227  *
228  * @param p_hwfn
229  * @param p_ptt
230  */
231 void ecore_mcp_read_mb(struct ecore_hwfn *p_hwfn,
232                        struct ecore_ptt *p_ptt);
233
234 /**
235  * @brief Ack to mfw that driver finished FLR process for VFs
236  *
237  * @param p_hwfn
238  * @param p_ptt
239  * @param vfs_to_ack - bit mask of all engine VFs for which the PF acks.
240  *
241  * @param return enum _ecore_status_t - ECORE_SUCCESS upon success.
242  */
243 enum _ecore_status_t ecore_mcp_ack_vf_flr(struct ecore_hwfn *p_hwfn,
244                                           struct ecore_ptt *p_ptt,
245                                           u32 *vfs_to_ack);
246
247 /**
248  * @brief - calls during init to read shmem of all function-related info.
249  *
250  * @param p_hwfn
251  *
252  * @param return ECORE_SUCCESS upon success.
253  */
254 enum _ecore_status_t ecore_mcp_fill_shmem_func_info(struct ecore_hwfn *p_hwfn,
255                                                     struct ecore_ptt *p_ptt);
256
257 /**
258  * @brief - Reset the MCP using mailbox command.
259  *
260  * @param p_hwfn
261  * @param p_ptt
262  *
263  * @param return ECORE_SUCCESS upon success.
264  */
265 enum _ecore_status_t ecore_mcp_reset(struct ecore_hwfn *p_hwfn,
266                                      struct ecore_ptt *p_ptt);
267
268 /**
269  * @brief indicates whether the MFW objects [under mcp_info] are accessible
270  *
271  * @param p_hwfn
272  *
273  * @return true iff MFW is running and mcp_info is initialized
274  */
275 bool ecore_mcp_is_init(struct ecore_hwfn *p_hwfn);
276
277 /**
278  * @brief request MFW to configure MSI-X for a VF
279  *
280  * @param p_hwfn
281  * @param p_ptt
282  * @param vf_id - absolute inside engine
283  * @param num_sbs - number of entries to request
284  *
285  * @return enum _ecore_status_t
286  */
287 enum _ecore_status_t ecore_mcp_config_vf_msix(struct ecore_hwfn *p_hwfn,
288                                               struct ecore_ptt *p_ptt,
289                                               u8 vf_id, u8 num);
290
291 /**
292  * @brief - Halt the MCP.
293  *
294  * @param p_hwfn
295  * @param p_ptt
296  *
297  * @param return ECORE_SUCCESS upon success.
298  */
299 enum _ecore_status_t ecore_mcp_halt(struct ecore_hwfn *p_hwfn,
300                                     struct ecore_ptt *p_ptt);
301
302 /**
303  * @brief - Wake up the MCP.
304  *
305  * @param p_hwfn
306  * @param p_ptt
307  *
308  * @param return ECORE_SUCCESS upon success.
309  */
310 enum _ecore_status_t ecore_mcp_resume(struct ecore_hwfn *p_hwfn,
311                                       struct ecore_ptt *p_ptt);
312 int __ecore_configure_pf_max_bandwidth(struct ecore_hwfn *p_hwfn,
313                                        struct ecore_ptt *p_ptt,
314                                        struct ecore_mcp_link_state *p_link,
315                                        u8 max_bw);
316 int __ecore_configure_pf_min_bandwidth(struct ecore_hwfn *p_hwfn,
317                                        struct ecore_ptt *p_ptt,
318                                        struct ecore_mcp_link_state *p_link,
319                                        u8 min_bw);
320 enum _ecore_status_t ecore_mcp_mask_parities(struct ecore_hwfn *p_hwfn,
321                                              struct ecore_ptt *p_ptt,
322                                              u32 mask_parities);
323 /**
324  * @brief - Sends crash mdump related info to the MFW.
325  *
326  * @param p_hwfn
327  * @param p_ptt
328  *
329  * @param return ECORE_SUCCESS upon success.
330  */
331 enum _ecore_status_t ecore_mcp_mdump_set_values(struct ecore_hwfn *p_hwfn,
332                                                 struct ecore_ptt *p_ptt,
333                                                 u32 epoch);
334
335 /**
336  * @brief - Triggers a MFW crash dump procedure.
337  *
338  * @param p_hwfn
339  * @param p_ptt
340  * @param epoch
341  *
342  * @param return ECORE_SUCCESS upon success.
343  */
344 enum _ecore_status_t ecore_mcp_mdump_trigger(struct ecore_hwfn *p_hwfn,
345                                              struct ecore_ptt *p_ptt);
346
347 struct ecore_mdump_retain_data {
348         u32 valid;
349         u32 epoch;
350         u32 pf;
351         u32 status;
352 };
353
354 /**
355  * @brief - Gets the mdump retained data from the MFW.
356  *
357  * @param p_hwfn
358  * @param p_ptt
359  * @param p_mdump_retain
360  *
361  * @param return ECORE_SUCCESS upon success.
362  */
363 enum _ecore_status_t
364 ecore_mcp_mdump_get_retain(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
365                            struct ecore_mdump_retain_data *p_mdump_retain);
366
367 /**
368  * @brief - Sets the MFW's max value for the given resource
369  *
370  *  @param p_hwfn
371  *  @param p_ptt
372  *  @param res_id
373  *  @param resc_max_val
374  *  @param p_mcp_resp
375  *
376  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
377  */
378 enum _ecore_status_t
379 ecore_mcp_set_resc_max_val(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
380                            enum ecore_resources res_id, u32 resc_max_val,
381                            u32 *p_mcp_resp);
382
383 /**
384  * @brief - Gets the MFW allocation info for the given resource
385  *
386  *  @param p_hwfn
387  *  @param p_ptt
388  *  @param res_id
389  *  @param p_mcp_resp
390  *  @param p_resc_num
391  *  @param p_resc_start
392  *
393  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
394  */
395 enum _ecore_status_t
396 ecore_mcp_get_resc_info(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
397                         enum ecore_resources res_id, u32 *p_mcp_resp,
398                         u32 *p_resc_num, u32 *p_resc_start);
399
400 /**
401  * @brief - Initiates PF FLR
402  *
403  * @param p_hwfn
404  * @param p_ptt
405  *
406  * @param return ECORE_SUCCESS upon success.
407  */
408 enum _ecore_status_t ecore_mcp_initiate_pf_flr(struct ecore_hwfn *p_hwfn,
409                                                struct ecore_ptt *p_ptt);
410
411 #define ECORE_MCP_RESC_LOCK_MIN_VAL     RESOURCE_DUMP /* 0 */
412 #define ECORE_MCP_RESC_LOCK_MAX_VAL     31
413
414 enum ecore_resc_lock {
415         ECORE_RESC_LOCK_DBG_DUMP = ECORE_MCP_RESC_LOCK_MIN_VAL,
416         /* Locks that the MFW is aware of should be added here downwards */
417
418         /* Ecore only locks should be added here upwards */
419         ECORE_RESC_LOCK_RESC_ALLOC = ECORE_MCP_RESC_LOCK_MAX_VAL,
420
421         /* A dummy value to be used for auxiliary functions in need of
422          * returning an 'error' value.
423          */
424         ECORE_RESC_LOCK_RESC_INVALID,
425 };
426
427 struct ecore_resc_lock_params {
428         /* Resource number [valid values are 0..31] */
429         u8 resource;
430
431         /* Lock timeout value in seconds [default, none or 1..254] */
432         u8 timeout;
433 #define ECORE_MCP_RESC_LOCK_TO_DEFAULT  0
434 #define ECORE_MCP_RESC_LOCK_TO_NONE     255
435
436         /* Number of times to retry locking */
437         u8 retry_num;
438 #define ECORE_MCP_RESC_LOCK_RETRY_CNT_DFLT      10
439
440         /* The interval in usec between retries */
441         u16 retry_interval;
442 #define ECORE_MCP_RESC_LOCK_RETRY_VAL_DFLT      10000
443
444         /* Use sleep or delay between retries */
445         bool sleep_b4_retry;
446
447         /* Will be set as true if the resource is free and granted */
448         bool b_granted;
449
450         /* Will be filled with the resource owner.
451          * [0..15 = PF0-15, 16 = MFW, 17 = diag over serial]
452          */
453         u8 owner;
454 };
455
456 /**
457  * @brief Acquires MFW generic resource lock
458  *
459  *  @param p_hwfn
460  *  @param p_ptt
461  *  @param p_params
462  *
463  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
464  */
465 enum _ecore_status_t
466 ecore_mcp_resc_lock(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
467                     struct ecore_resc_lock_params *p_params);
468
469 struct ecore_resc_unlock_params {
470         /* Resource number [valid values are 0..31] */
471         u8 resource;
472
473         /* Allow to release a resource even if belongs to another PF */
474         bool b_force;
475
476         /* Will be set as true if the resource is released */
477         bool b_released;
478 };
479
480 /**
481  * @brief Releases MFW generic resource lock
482  *
483  *  @param p_hwfn
484  *  @param p_ptt
485  *  @param p_params
486  *
487  * @return enum _ecore_status_t - ECORE_SUCCESS - operation was successful.
488  */
489 enum _ecore_status_t
490 ecore_mcp_resc_unlock(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
491                       struct ecore_resc_unlock_params *p_params);
492
493 /**
494  * @brief - default initialization for lock/unlock resource structs
495  *
496  * @param p_lock - lock params struct to be initialized; Can be OSAL_NULL
497  * @param p_unlock - unlock params struct to be initialized; Can be OSAL_NULL
498  * @param resource - the requested resource
499  * @paral b_is_permanent - disable retries & aging when set
500  */
501 void ecore_mcp_resc_lock_default_init(struct ecore_resc_lock_params *p_lock,
502                                       struct ecore_resc_unlock_params *p_unlock,
503                                       enum ecore_resc_lock resource,
504                                       bool b_is_permanent);
505
506 /**
507  * @brief Learn of supported MFW features; To be done during early init
508  *
509  * @param p_hwfn
510  * @param p_ptt
511  */
512 enum _ecore_status_t ecore_mcp_get_capabilities(struct ecore_hwfn *p_hwfn,
513                                                 struct ecore_ptt *p_ptt);
514
515 /**
516  * @brief Inform MFW of set of features supported by driver. Should be done
517  * inside the contet of the LOAD_REQ.
518  *
519  * @param p_hwfn
520  * @param p_ptt
521  */
522 enum _ecore_status_t ecore_mcp_set_capabilities(struct ecore_hwfn *p_hwfn,
523                                                 struct ecore_ptt *p_ptt);
524
525 #endif /* __ECORE_MCP_H__ */