1 /*
2  * Copyright (c) 2017-2018 Cavium, Inc.
3  * All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions
7  *  are met:
8  *
9  *  1. Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  *  2. Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  *
15  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  *  POSSIBILITY OF SUCH DAMAGE.
26  *
27  */
28 
29 #ifndef _DBG_FW_FUNCS_H
30 #define _DBG_FW_FUNCS_H
31 /**************************** Public Functions *******************************/
32 
33 /**
34  * @brief ecore_dbg_set_bin_ptr - Sets a pointer to the binary data with debug
35  * arrays.
36  *
37  * @param bin_ptr - a pointer to the binary data with debug arrays.
38  */
39 enum dbg_status ecore_dbg_set_bin_ptr(const u8 * const bin_ptr);
40 
41 /**
42  * @brief ecore_dbg_set_app_ver - Sets the version of the calling app.
43  *
44  * The application should call this function with the TOOLS_VERSION
45  * it compiles with. Must be called before all other debug functions.
46  *
47  * @return error if one of the following holds:
48  *	- the specified app version is not supported
49  * Otherwise, returns ok.
50  */
51 enum dbg_status ecore_dbg_set_app_ver(u32 ver);
52 
53 /**
54  * @brief ecore_dbg_get_fw_func_ver - Returns the FW func version.
55  *
56  * @return the FW func version.
57  */
58 u32 ecore_dbg_get_fw_func_ver(void);
59 
60 /**
61 * @brief ecore_dbg_get_chip_id - Returns the FW func version.
62 *
63 * @param p_hwfn - HW device data
64 *
65 * @return the chip ID.
66 */
67 enum chip_ids ecore_dbg_get_chip_id(struct ecore_hwfn *p_hwfn);
68 
69 /**
70 * @brief ecore_read_regs - Reads registers into a buffer (using GRC).
71 *
72 * @param p_hwfn -	HW device data
73 * @param p_ptt -	Ptt window used for writing the registers.
74 * @param buf -	Destination buffer.
75 * @param addr -	Source GRC address in dwords.
76 * @param len -	Number of registers to read.
77 */
78 void ecore_read_regs(struct ecore_hwfn *p_hwfn,
79 					 struct ecore_ptt *p_ptt,
80 					 u32 *buf,
81 					 u32 addr,
82 					 u32 len);
83 
84 /**
85  * @brief ecore_dbg_bus_reset - Resets the Debug block.
86  *
87  * After reset:
88  * - The last recording is erased.
89  * - Recording is directed to the internal buffer.
90  * - Wrap-around recording is selected.
91  * - All HW blocks are disabled.
92  * - All Storms are disabled and all SEM filters are cleared.
93  *
94  * @param p_hwfn -		    HW device data
95  * @param p_ptt -		    Ptt window used for writing the registers.
96  * @param one_shot_en -     Enable/Disable one-shot recording. If disabled,
97  *			    wrap-around recording is used instead.
98  * @param force_hw_dwords - If set to 0, no. of HW/Storm dwords per cycle is
99  *			    chosen automatically based on the enabled inputs.
100  *			    Otherwise, no. of HW dwords per cycle is forced to
101  *			    the specified value. Valid values: 0/2/4/8.
102  * @param unify_inputs -    If true, all recorded data is associated with a
103  *			    single input, as if all data was received from the
104  *			    same block. Otherwise, each data unit is associated
105  *			    with its original input.
106  * @param grc_input_en -    Enable/Disable recording GRC input. If enabled, the
107  *			    GRC input is recorded to the lsb dword of a cycle.
108  *
109  * @return error if one of the following holds:
110  *	- the version wasn't set
111  *	- force_hw_dwords is invalid.
112  * Otherwise, returns ok.
113  */
114 enum dbg_status ecore_dbg_bus_reset(struct ecore_hwfn *p_hwfn,
115 									struct ecore_ptt *p_ptt,
116 									bool one_shot_en,
117 									u8 force_hw_dwords,
118 									bool unify_inputs,
119 									bool grc_input_en);
120 
121 /**
122  * @brief ecore_dbg_bus_set_pci_output - Directs debug output to a PCI buffer.
123  *
124  * @param p_hwfn -		HW device data
125  * @param p_ptt -		Ptt window used for writing the registers.
126  * @param buf_size_kb - Size of PCI buffer to allocate (in KB). Must be aligned
127  *			to PCI request size.
128  *
129  * @return error if one of the following holds:
130  *	- the Debug block wasn't reset since last recording
131  *	- the version wasn't set
132  *	- the output was already set
133  *	- the PCI buffer size is not aligned to PCI packet size
134  *	- the PCI buffer allocation failed
135  * Otherwise, returns ok.
136  */
137 enum dbg_status ecore_dbg_bus_set_pci_output(struct ecore_hwfn *p_hwfn,
138 											 struct ecore_ptt *p_ptt,
139 											 u16 buf_size_kb);
140 
141 /**
142  * @brief ecore_dbg_bus_set_nw_output - Directs debug output to the network.
143  *
144  * @param p_hwfn -			HW device data
145  * @param p_ptt -			Ptt window used for writing the registers.
146  * @param port_id -		Port ID to transmit the debug data on
147  * @param dest_addr_lo32 -	Destination MAC address (for Eth header)
148  * @param dest_addr_hi16
149  * @param data_limit_size_kb -  Data limit size in KB (valid only for one-shot)
150  *				If set to 0, data limit won't be configured.
151  * @param send_to_other_engine -If true:
152  *				1) The NW output will be sent to the DBG block
153  *				   of the other engine.
154  *				2) port_id argument is ignored.
155  *				3) rcv_from_other_engine should be set to false
156  *				   The other engine DBG block should call this
157  *				   function with rcv_from_other_engine set to
158  *				   true.
159  * @param rcv_from_other_engine-If true:
160  *				1) the DBG block receives the NW output sent
161  *				   from the other engine DBG block, and sends
162  *				   it to a NW port in the current engine
163  *				   (according to port_id).
164  *				2) The src/dest addresses and eth_type
165  *				   arguments are ignored.
166  *				3) send_to_other_engine should be set to false.
167  *				   The other engine DBG block should call this
168  *				   function with send_to_other_engine set to
169  *				   true.
170  *
171  * @return error if one of the following holds:
172  *	- the Debug block wasn't reset since last recording
173  *	- the version wasn't set
174  *	- the output was already set
175  * Otherwise, returns ok.
176  */
177 enum dbg_status ecore_dbg_bus_set_nw_output(struct ecore_hwfn *p_hwfn,
178 											struct ecore_ptt *p_ptt,
179 											u8 port_id,
180 											u32 dest_addr_lo32,
181 											u16 dest_addr_hi16,
182 											u16 data_limit_size_kb,
183 											bool send_to_other_engine,
184 											bool rcv_from_other_engine);
185 
186 /**
187  * @brief ecore_dbg_bus_enable_block - Enables recording of the specified block
188  *
189  * Each recording cycle contains 4 "units". If the recorded HW data requires up
190  * to 4 dwords per cycle, each unit is one dword (32 bits). Otherwise, each
191  * unit is 2 dwords (64 bits).
192  *
193  * @param p_hwfn -		HW device data
194  * @param block -	block to be enabled.
195  * @param line_num -	debug line number to select.
196  * @param cycle_en -	4-bit value. If bit i is set, unit i is enabled.
197  * @param right_shift -	number of units to  right the debug data (0-3).
198  * @param force_valid - 4-bit value. If bit i is set, unit i is forced valid.
199  * @param force_frame - 4-bit value. If bit i is set, the frame bit of unit i
200  *			is forced.
201  *
202  * @return error if one of the following holds:
203  *	- the Debug block wasn't reset since last recording
204  *	- the version wasn't set
205  *	- block is not valid
206  *	- block was already enabled
207  *	- cycle_en, force_valid or force_frame are wider than 4 bits
208  *	- right_shift is larger than 3
209  *	- cycle unit 0 is enabled, but GRC or timestamp were also enabled.
210  *	- Too many inputs were enabled.
211  * Otherwise, returns ok.
212  */
213 enum dbg_status ecore_dbg_bus_enable_block(struct ecore_hwfn *p_hwfn,
214 										   enum block_id block,
215 										   u8 line_num,
216 										   u8 cycle_en,
217 										   u8 right_shift,
218 										   u8 force_valid,
219 										   u8 force_frame);
220 
221 /**
222  * @brief ecore_dbg_bus_enable_storm - Enables recording of the specified Storm
223  *
224  * @param p_hwfn -		HW device data
225  * @param storm -	Storm to be enabled.
226  * @param storm_mode-	Storm mode
227  *
228  * @return error if one of the following holds:
229  *	- the Debug block wasn't reset since last recording
230  *	- the version wasn't set
231  *	- the specified storm or mode is invalid
232  *	- Storm was already enabled
233  *	- only HW data can be recorded
234  *	- Too many inputs were enabled.
235  * Otherwise, returns ok.
236  */
237 enum dbg_status ecore_dbg_bus_enable_storm(struct ecore_hwfn *p_hwfn,
238 										   enum dbg_storms storm,
239 										   enum dbg_bus_storm_modes storm_mode);
240 
241 /**
242  * @brief ecore_dbg_bus_enable_timestamp - Enables timestamp recording.
243  *
244  * When enabled, the timestamp input is always recorded to the lsb dword of
245  * a cycle, with HW ID 0.
246  *
247  * @param p_hwfn -	     HW device data
248  * @param p_ptt -	     Ptt window used for writing the registers.
249  * @param valid_en - 3-bit value. The Timestamp will be recorded in a cycle if
250  *		     bit i is set and unit i+1 is valid.
251  * @param frame_en - 3-bit value. The Timestamp will be recorded in a cycle if
252  *		     bit i is set and unit i+1 has frame bit set.
253  * @param tick_len - timestamp tick length in cycles, minus 1. A value of 0
254  *		     means one cycle.
255  *
256  * @return error if one of the following holds:
257  *	- the Debug block wasn't reset since last recording
258  *	- the version wasn't set
259  *	- valid_en or frame_en are wider than 4 bits
260  *	- Both timestamp and GRC are enabled.
261  * Otherwise, returns ok.
262  */
263 enum dbg_status ecore_dbg_bus_enable_timestamp(struct ecore_hwfn *p_hwfn,
264 											   struct ecore_ptt *p_ptt,
265 											   u8 valid_en,
266 											   u8 frame_en,
267 											   u32 tick_len);
268 
269 /**
270  * @brief ecore_dbg_bus_add_eid_range_sem_filter- Add Event ID range SEM filter
271  *
272  * @param p_hwfn -     HW device data
273  * @param storm -   Storm to be filtered.
274  * @param min_eid - minimal Event ID to filter on.
275  * @param max_eid - maximal Event ID to filter on.
276  *
277  * @return error if one of the following holds:
278  *	- the specified Storm is invalid
279  *	- the specified Storm wasn't enabled
280  *	- the EID range is not valid
281  * Otherwise, returns ok.
282  */
283 enum dbg_status ecore_dbg_bus_add_eid_range_sem_filter(struct ecore_hwfn *p_hwfn,
284 													   enum dbg_storms storm,
285 													   u8 min_eid,
286 													   u8 max_eid);
287 
288 /**
289  * @brief ecore_dbg_bus_add_eid_mask_sem_filter - Add Event ID mask SEM filter
290  *
291  * @param p_hwfn -      HW device data
292  * @param storm -    Storm to be filtered.
293  * @param eid_val -  Event ID value.
294  * @param eid_mask - Event ID mask. 0's in the mask = don't care bits.
295  *
296  * @return error if one of the following holds:
297  *	- the specified Storm is invalid
298  *	- the specified Storm wasn't enabled
299  * Otherwise, returns ok.
300  */
301 enum dbg_status ecore_dbg_bus_add_eid_mask_sem_filter(struct ecore_hwfn *p_hwfn,
302 													  enum dbg_storms storm,
303 													  u8 eid_val,
304 													  u8 eid_mask);
305 
306 /**
307  * @brief ecore_dbg_bus_add_cid_sem_filter - Adds a CID SEM filter.
308  *
309  * @param p_hwfn -   HW device data
310  * @param storm	- Storm to be filtered.
311  * @param cid -   CID to filter on.
312  *
313  * @return error if one of the following holds:
314  *	- the specified Storm is invalid
315  *	- the specified Storm wasn't enabled
316  * Otherwise, returns ok.
317  */
318 enum dbg_status ecore_dbg_bus_add_cid_sem_filter(struct ecore_hwfn *p_hwfn,
319 												 enum dbg_storms storm,
320 												 u32 cid);
321 
322 /**
323  * @brief ecore_dbg_bus_enable_filter - Enables the recording filter.
324  *
325  * A filter contains up to 4 constraints. The data is "filtered in" when the
326  * added constraints hold.
327  *
328  * @param p_hwfn -		  HW device data
329  * @param p_ptt -		  Ptt window used for writing the registers.
330  * @param block -	  block to filter on.
331  * @param const_msg_len	- Constant message length (in cycles) to be used for
332  *			  message-based filter constraints. If set to 0,
333  *			  message length is based only on frame bit received
334  *			  from HW (no constant message length).
335  *
336  * @return error if one of the following holds:
337  *	- the Debug block wasn't reset since last recording
338  *	- the version wasn't set
339  *	- the filter was already enabled
340  *	- block is not valid or not enabled
341  *	- more than 4 dwords are recorded per-cycle (forbids filters)
342  * Otherwise, returns ok.
343  */
344 enum dbg_status ecore_dbg_bus_enable_filter(struct ecore_hwfn *p_hwfn,
345 											struct ecore_ptt *p_ptt,
346 											enum block_id block,
347 											u8 const_msg_len);
348 
349 /**
350  * @brief ecore_dbg_bus_enable_trigger - Enables the recording trigger.
351  *
352  * A trigger contains up to 3 states, where each state contains up to
353  * 4 constraints. After the constraints of a state hold for a specified number
354  * of times, the DBG block moves to the next state. If there's no next state,
355  * the DBG block triggers.
356  *
357  * @param p_hwfn -			HW device data
358  * @param p_ptt -			Ptt window used for writing the registers.
359  * @param rec_pre_trigger -	if true, recording starts before the trigger.
360  *				if false, recording starts at the trigger.
361  * @param pre_chunks -		max number of chunks to record before the
362  *				trigger (1-47). If set to 0, recording starts
363  *				from time 0. Ignored if rec_pre_trigger is
364  *				false.
365  * @param rec_post_trigger -	if true, recording ends after the trigger.
366  *				if false, recording ends at the trigger.
367  * @param post_cycles -		max number of cycles to record after the
368  *				trigger (0x1-0xffffffff). If set to 0,
369  *				recording ends only when stopped by the user.
370  *				Ignored if rec_post_trigger is false.
371  * @param filter_pre_trigger -	if true, data is filtered before the trigger.
372  *				Ignored if the filter wasn't enabled.
373  * @param filter_post_trigger -	if true, data is filtered after the trigger.
374  *				Ignored if the filter wasn't enabled.
375  *
376  * @return error if one of the following holds:
377  *	- the Debug block wasn't reset since last recording
378  *	- the version wasn't set
379  *	- the trigger was already enabled
380  *	- more than 4 dwords are recorded per-cycle (forbids triggers)
381  *	- pre_chunks is not in the range 0-47.
382  * Otherwise, returns ok.
383  */
384 enum dbg_status ecore_dbg_bus_enable_trigger(struct ecore_hwfn *p_hwfn,
385 											 struct ecore_ptt *p_ptt,
386 											 bool rec_pre_trigger,
387 											 u8 pre_chunks,
388 											 bool rec_post_trigger,
389 											 u32 post_cycles,
390 											 bool filter_pre_trigger,
391 											 bool filter_post_trigger);
392 
393 /**
394  * @brief ecore_dbg_bus_add_trigger_state - Adds a trigger state.
395  *
396  * Up to 3 trigger states can be added, where each state contains up to
397  * 4 constraints. After the constraints of a state hold for the specified
398  * number of times, the DBG block moves to the next state. If there's no next
399  * state, the DBG block triggers.
400  *
401  * @param p_hwfn -		  HW device data
402  * @param p_ptt -		  Ptt window used for writing the registers.
403  * @param block	-	  block to trigger on.
404  * @param const_msg_len	- Constant message length (in cycles) to be used for
405  *			  message-based filter constraints. If set to 0,
406  *			  message length is based only on frame bit received
407  *			  from HW (no constant message length).
408  * @param count_to_next	- The number of times the constraints of the state
409  *			  should hold before moving to the next state. Must be
410  *			  non-zero.
411  *
412  * @return error if one of the following holds:
413  *	- The trigger wasn't enabled.
414  *	- more than 3 trigger states were added
415  *	- block is not valid or not enabled
416  *	- count_to_next is 0
417  * Otherwise, returns ok.
418  */
419 enum dbg_status ecore_dbg_bus_add_trigger_state(struct ecore_hwfn *p_hwfn,
420 												struct ecore_ptt *p_ptt,
421 												enum block_id block,
422 												u8 const_msg_len,
423 												u16 count_to_next);
424 
425 /**
426  * @brief ecore_dbg_bus_add_constraint - Adds a filter/trigger constraint.
427  *
428  * The constraint is added to a filter or trigger state, which ever was added
429  * last. The filter/trigger happens if both of the following hold:
430  * 1. All mandatory constraints are true.
431  * 2. At least one optional (non-mandatory) constraints is true.
432  *
433  * @param p_hwfn -			  HW device data
434  * @param p_ptt -			  Ptt window used for writing the registers.
435  * @param op -			  constraint operation
436  * @param data -		  32-bit data to compare with the recorded
437  *				  data.
438  * @param data_mask -		  32-bit mask for data comparison. If mask bit
439  *				  i is 1, data bit i is compared, otherwise
440  *				  it's ignored.
441  *				  For eq/ne operations: any mask can be used.
442  *				  For other operations: the mask must be
443  *				  non-zero, and the 1's in the mask must be
444  *				  continuous.
445  * @param compare_frame -	  indicates if the frame bit should be
446  *				  compared. Must be false for all operations
447  *				  other than eq/ne.
448  * @param frame_bit -		  frame bit to compare with the recorded data
449  *				  (0/1). ignored if compare_frame is false.
450  * @param cycle_offset -	  offset in cycles from the beginning of the
451  *				  message, where cycle = 4 dwords.
452  * @param dword_offset_in_cycle	- offset in dwords from the beginning of the
453  *				  cycle (0-3).
454  * @param is_mandatory -	  indicates if this constraint is mandatory
455  *				  (true) or optional (false). The data is
456  *				  filtered-in if all mandatory constraints hold
457  *				  AND at least one optional constraint (if
458  *				  added) holds.
459  *
460  * @return error if one of the following holds:
461  *	- a filter or trigger state weren't enabled
462  *	- all 4 filter constraints were added already
463  *	- the op string is invalid
464  *	- the data mask is invalid.
465  *	- frame bit is not 0/1.
466  *	- cycle_offset and dword_offset are not in the range 0-3.
467  *	- compare_frame is true and operation is not eq/ne.
468  * Otherwise, returns ok.
469  */
470 enum dbg_status ecore_dbg_bus_add_constraint(struct ecore_hwfn *p_hwfn,
471 											 struct ecore_ptt *p_ptt,
472 											 enum dbg_bus_constraint_ops constraint_op,
473 											 u32 data,
474 											 u32 data_mask,
475 											 bool compare_frame,
476 											 u8 frame_bit,
477 											 u8 cycle_offset,
478 											 u8 dword_offset_in_cycle,
479 											 bool is_mandatory);
480 
481 /**
482  * @brief ecore_dbg_bus_start - Starts the recording.
483  *
484  * @param p_hwfn - HW device data
485  * @param p_ptt - Ptt window used for writing the registers.
486  *
487  * @return error if one of the following holds:
488  *	- the Debug block wasn't reset since last recording
489  *	- the version wasn't set
490  * Otherwise, returns ok.
491  */
492 enum dbg_status ecore_dbg_bus_start(struct ecore_hwfn *p_hwfn,
493 									struct ecore_ptt *p_ptt);
494 
495 /**
496  * @brief ecore_dbg_bus_stop - Stops the recording and flushes the internal
497  * buffer.
498  *
499  * @param p_hwfn - HW device data
500  * @param p_ptt - Ptt window used for writing the registers.
501  *
502  * @return error if a recording is not in progress, ok otherwise.
503  */
504 enum dbg_status ecore_dbg_bus_stop(struct ecore_hwfn *p_hwfn,
505 								   struct ecore_ptt *p_ptt);
506 
507 /**
508  * @brief ecore_dbg_bus_get_dump_buf_size - Returns the required buffer size
509  * for Debug Bus recording.
510  *
511  * @param p_hwfn -      HW device data
512  * @param p_ptt -	     Ptt window used for writing the registers.
513  * @param buf_size - OUT: the required size (in dwords) of the buffer for
514  *		     dumping the recorded Debug Bus data. If recording to the
515  *		     internal buffer, the size of the internal buffer is
516  *		     returned. If recording to PCI, the size of the PCI buffer
517  *		     is returned. Otherwise, 0 is returned.
518  *
519  * @return error if one of the following holds:
520  *	- the version wasn't set
521  * Otherwise, returns ok.
522  */
523 enum dbg_status ecore_dbg_bus_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
524 												struct ecore_ptt *p_ptt,
525 												u32 *buf_size);
526 
527 /**
528  * @brief ecore_dbg_bus_dump - Dumps the recorded Debug Bus data into the
529  * specified buffer.
530  *
531  * The dumped data starts with a header. If recording to NW, only a header is
532  * dumped. The dumped size is assigned to num_dumped_dwords.
533  *
534  * @param p_hwfn -			HW device data
535  * @param p_ptt -			Ptt window used for writing the registers.
536  * @param dump_buf -		Pointer to copy the recorded data into.
537  * @param buf_size_in_dwords -	Size of the specified buffer in dwords.
538  * @param num_dumped_dwords -	OUT: number of dumped dwords.
539  *
540  * @return error if one of the following holds:
541  *	- a recording wasn't started/stopped
542  *	- the specified dump buffer is too small
543  * Otherwise, returns ok.
544  */
545 enum dbg_status ecore_dbg_bus_dump(struct ecore_hwfn *p_hwfn,
546 								   struct ecore_ptt *p_ptt,
547 								   u32 *dump_buf,
548 								   u32 buf_size_in_dwords,
549 								   u32 *num_dumped_dwords);
550 
551 /**
552  * @brief ecore_dbg_grc_config - Sets the value of a GRC parameter.
553  *
554  * @param p_hwfn -		HW device data
555  * @param grc_param -	GRC parameter
556  * @param val -		Value to set.
557 
558  * @return error if one of the following holds:
559  *	- the version wasn't set
560  *	- grc_param is invalid
561  *	- val is outside the allowed boundaries
562  */
563 enum dbg_status ecore_dbg_grc_config(struct ecore_hwfn *p_hwfn,
564 									 enum dbg_grc_params grc_param,
565 									 u32 val);
566 
567 /**
568 * @brief ecore_dbg_grc_set_params_default - Reverts all GRC parameters to their
569 * default value.
570 *
571 * @param p_hwfn - HW device data
572 */
573 void ecore_dbg_grc_set_params_default(struct ecore_hwfn *p_hwfn);
574 
575 /**
576  * @brief ecore_dbg_grc_get_dump_buf_size - Returns the required buffer size
577  * for GRC Dump.
578  *
579  * @param p_hwfn -      HW device data
580  * @param p_ptt -	     Ptt window used for writing the registers.
581  * @param buf_size - OUT: required buffer size (in dwords) for GRC Dump data.
582  *
583  * @return error if one of the following holds:
584  *	- the version wasn't set
585  * Otherwise, returns ok.
586  */
587 enum dbg_status ecore_dbg_grc_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
588 												struct ecore_ptt *p_ptt,
589 												u32 *buf_size);
590 
591 /**
592  * @brief ecore_dbg_grc_dump - Dumps GRC data into the specified buffer.
593  *
594  * @param p_hwfn -			HW device data
595  * @param p_ptt -			Ptt window used for writing the registers.
596  * @param dump_buf -		Pointer to write the collected GRC data into.
597  * @param buf_size_in_dwords -	Size of the specified buffer in dwords.
598  * @param num_dumped_dwords -	OUT: number of dumped dwords.
599  *
600  * @return error if one of the following holds:
601  *	- the version wasn't set
602  *	- the specified dump buffer is too small
603  * Otherwise, returns ok.
604  */
605 enum dbg_status ecore_dbg_grc_dump(struct ecore_hwfn *p_hwfn,
606 								   struct ecore_ptt *p_ptt,
607 								   u32 *dump_buf,
608 								   u32 buf_size_in_dwords,
609 								   u32 *num_dumped_dwords);
610 
611 /**
612  * @brief ecore_dbg_idle_chk_get_dump_buf_size - Returns the required buffer
613  * size for idle check results.
614  *
615  * @param p_hwfn -      HW device data
616  * @param p_ptt -      Ptt window used for writing the registers.
617  * @param buf_size - OUT: required buffer size (in dwords) for idle check data.
618  *
619  * @return error if one of the following holds:
620  *	- the version wasn't set
621  * Otherwise, returns ok.
622  */
623 enum dbg_status ecore_dbg_idle_chk_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
624 													 struct ecore_ptt *p_ptt,
625 													 u32 *buf_size);
626 
627 /**
628  * @brief ecore_dbg_idle_chk_dump - Performs idle check and writes the results
629  * into the specified buffer.
630  *
631  * @param p_hwfn -			HW device data
632  * @param p_ptt -			Ptt window used for writing the registers.
633  * @param dump_buf -		Pointer to write the idle check data into.
634  * @param buf_size_in_dwords -	Size of the specified buffer in dwords.
635  * @param num_dumped_dwords -	OUT: number of dumped dwords.
636  *
637  * @return error if one of the following holds:
638  *	- the version wasn't set
639  *	- the specified buffer is too small
640  * Otherwise, returns ok.
641  */
642 enum dbg_status ecore_dbg_idle_chk_dump(struct ecore_hwfn *p_hwfn,
643 										struct ecore_ptt *p_ptt,
644 										u32 *dump_buf,
645 										u32 buf_size_in_dwords,
646 										u32 *num_dumped_dwords);
647 
648 /**
649  * @brief ecore_dbg_mcp_trace_get_dump_buf_size - Returns the required buffer
650  * size for mcp trace results.
651  *
652  * @param p_hwfn -	     HW device data
653  * @param p_ptt -	     Ptt window used for writing the registers.
654  * @param buf_size - OUT: required buffer size (in dwords) for mcp trace data.
655  *
656  * @return error if one of the following holds:
657  *	- the version wasn't set
658  *	- the trace data in MCP scratchpad contain an invalid signature
659  *	- the bundle ID in NVRAM is invalid
660  *	- the trace meta data cannot be found (in NVRAM or image file)
661  * Otherwise, returns ok.
662  */
663 enum dbg_status ecore_dbg_mcp_trace_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
664 													  struct ecore_ptt *p_ptt,
665 													  u32 *buf_size);
666 
667 /**
668  * @brief ecore_dbg_mcp_trace_dump - Performs mcp trace and writes the results
669  * into the specified buffer.
670  *
671  * @param p_hwfn -			HW device data
672  * @param p_ptt -			Ptt window used for writing the registers.
673  * @param dump_buf -		Pointer to write the mcp trace data into.
674  * @param buf_size_in_dwords -	Size of the specified buffer in dwords.
675  * @param num_dumped_dwords -	OUT: number of dumped dwords.
676  *
677  * @return error if one of the following holds:
678  *	- the version wasn't set
679  *	- the specified buffer is too small
680  *	- the trace data in MCP scratchpad contain an invalid signature
681  *	- the bundle ID in NVRAM is invalid
682  *	- the trace meta data cannot be found (in NVRAM or image file)
683  *	- the trace meta data cannot be read (from NVRAM or image file)
684  * Otherwise, returns ok.
685  */
686 enum dbg_status ecore_dbg_mcp_trace_dump(struct ecore_hwfn *p_hwfn,
687 										 struct ecore_ptt *p_ptt,
688 										 u32 *dump_buf,
689 										 u32 buf_size_in_dwords,
690 										 u32 *num_dumped_dwords);
691 
692 /**
693  * @brief ecore_dbg_reg_fifo_get_dump_buf_size - Returns the required buffer
694  * size for grc trace fifo results.
695  *
696  * @param p_hwfn -      HW device data
697  * @param p_ptt -      Ptt window used for writing the registers.
698  * @param buf_size - OUT: required buffer size (in dwords) for reg fifo data.
699  *
700  * @return error if one of the following holds:
701  *	- the version wasn't set
702  * Otherwise, returns ok.
703  */
704 enum dbg_status ecore_dbg_reg_fifo_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
705 													 struct ecore_ptt *p_ptt,
706 													 u32 *buf_size);
707 
708 /**
709  * @brief ecore_dbg_reg_fifo_dump - Reads the reg fifo and writes the results
710  * into the specified buffer.
711  *
712  * @param p_hwfn -			HW device data
713  * @param p_ptt -			Ptt window used for writing the registers.
714  * @param dump_buf -		Pointer to write the reg fifo data into.
715  * @param buf_size_in_dwords -	Size of the specified buffer in dwords.
716  * @param num_dumped_dwords -	OUT: number of dumped dwords.
717  *
718  * @return error if one of the following holds:
719  *	- the version wasn't set
720  *	- the specified buffer is too small
721  *	- DMAE transaction failed
722  * Otherwise, returns ok.
723  */
724 enum dbg_status ecore_dbg_reg_fifo_dump(struct ecore_hwfn *p_hwfn,
725 										struct ecore_ptt *p_ptt,
726 										u32 *dump_buf,
727 										u32 buf_size_in_dwords,
728 										u32 *num_dumped_dwords);
729 
730 /**
731 * @brief ecore_dbg_igu_fifo_get_dump_buf_size - Returns the required buffer
732 * size for the IGU fifo results.
733 *
734 * @param p_hwfn -      HW device data
735 * @param p_ptt -      Ptt window used for writing the registers.
736 * @param buf_size - OUT: required buffer size (in dwords) for IGU fifo data.
737 *
738 * @return error if one of the following holds:
739 *	- the version wasn't set
740 * Otherwise, returns ok.
741 */
742 enum dbg_status ecore_dbg_igu_fifo_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
743 													 struct ecore_ptt *p_ptt,
744 													 u32 *buf_size);
745 
746 /**
747 * @brief ecore_dbg_igu_fifo_dump - Reads the IGU fifo and writes the results
748 * into the specified buffer.
749 *
750 * @param p_hwfn -			HW device data
751 * @param p_ptt -			Ptt window used for writing the registers.
752 * @param dump_buf -		Pointer to write the IGU fifo data into.
753 * @param buf_size_in_dwords -	Size of the specified buffer in dwords.
754 * @param num_dumped_dwords -	OUT: number of dumped dwords.
755 *
756 * @return error if one of the following holds:
757 *	- the version wasn't set
758 *	- the specified buffer is too small
759 *	- DMAE transaction failed
760 * Otherwise, returns ok.
761 */
762 enum dbg_status ecore_dbg_igu_fifo_dump(struct ecore_hwfn *p_hwfn,
763 										struct ecore_ptt *p_ptt,
764 										u32 *dump_buf,
765 										u32 buf_size_in_dwords,
766 										u32 *num_dumped_dwords);
767 
768 /**
769  * @brief ecore_dbg_protection_override_get_dump_buf_size - Return the required
770  * buffer size for protection override window results.
771  *
772  * @param p_hwfn -      HW device data
773  * @param p_ptt -      Ptt window used for writing the registers.
774  * @param buf_size - OUT: required buffer size (in dwords) for protection
775  *		     override data.
776  *
777  * @return error if one of the following holds:
778  *	- the version wasn't set
779  * Otherwise, returns ok.
780  */
781 enum dbg_status ecore_dbg_protection_override_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
782 																struct ecore_ptt *p_ptt,
783 																u32 *buf_size);
784 /**
785  * @brief ecore_dbg_protection_override_dump - Reads protection override window
786  * entries and writes the results into the specified buffer.
787  *
788  * @param p_hwfn -			HW device data
789  * @param p_ptt -			Ptt window used for writing the registers.
790  * @param dump_buf -		Pointer to write the protection override data
791  *				into.
792  * @param buf_size_in_dwords -	Size of the specified buffer in dwords.
793  * @param num_dumped_dwords -	OUT: number of dumped dwords.
794  *
795  * @return error if one of the following holds:
796  *	- the version wasn't set
797  *	- the specified buffer is too small
798  *	- DMAE transaction failed
799  * Otherwise, returns ok.
800  */
801 enum dbg_status ecore_dbg_protection_override_dump(struct ecore_hwfn *p_hwfn,
802 												   struct ecore_ptt *p_ptt,
803 												   u32 *dump_buf,
804 												   u32 buf_size_in_dwords,
805 												   u32 *num_dumped_dwords);
806 
807 /**
808 * @brief ecore_dbg_fw_asserts_get_dump_buf_size - Returns the required buffer
809 * size for FW Asserts results.
810 *
811 * @param p_hwfn -	    HW device data
812 * @param p_ptt -	    Ptt window used for writing the registers.
813 * @param buf_size - OUT: required buffer size (in dwords) for FW Asserts data.
814 *
815 * @return error if one of the following holds:
816 *	- the version wasn't set
817 * Otherwise, returns ok.
818 */
819 enum dbg_status ecore_dbg_fw_asserts_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
820 													   struct ecore_ptt *p_ptt,
821 													   u32 *buf_size);
822 
823 /**
824 * @brief ecore_dbg_fw_asserts_dump - Reads the FW Asserts and writes the
825 * results into the specified buffer.
826 *
827 * @param p_hwfn -			HW device data
828 * @param p_ptt -			Ptt window used for writing the registers.
829 * @param dump_buf -		Pointer to write the FW Asserts data into.
830 * @param buf_size_in_dwords -	Size of the specified buffer in dwords.
831 * @param num_dumped_dwords -	OUT: number of dumped dwords.
832 *
833 * @return error if one of the following holds:
834 *	- the version wasn't set
835 *	- the specified buffer is too small
836 * Otherwise, returns ok.
837 */
838 enum dbg_status ecore_dbg_fw_asserts_dump(struct ecore_hwfn *p_hwfn,
839 										  struct ecore_ptt *p_ptt,
840 										  u32 *dump_buf,
841 										  u32 buf_size_in_dwords,
842 										  u32 *num_dumped_dwords);
843 
844 /**
845 * @brief ecore_dbg_read_attn - Reads the attention registers of the specified
846 * block and type, and writes the results into the specified buffer.
847 *
848 * @param p_hwfn -		HW device data
849 * @param p_ptt -		Ptt window used for writing the registers.
850 * @param block -	Block ID.
851 * @param attn_type -	Attention type.
852 * @param clear_status -	Indicates if the attention status should be cleared.
853 * @param results -	OUT: Pointer to write the read results into
854 *
855 * @return error if one of the following holds:
856 *	- the version wasn't set
857 * Otherwise, returns ok.
858 */
859 enum dbg_status ecore_dbg_read_attn(struct ecore_hwfn *p_hwfn,
860 									struct ecore_ptt *p_ptt,
861 									enum block_id block,
862 									enum dbg_attn_type attn_type,
863 									bool clear_status,
864 									struct dbg_attn_block_result *results);
865 
866 /**
867 * @brief ecore_dbg_print_attn - Prints attention registers values in the
868 * specified results struct.
869 *
870 * @param p_hwfn -     HW device data
871 * @param results - Pointer to the attention read results
872 *
873 * @return error if one of the following holds:
874 *	- the version wasn't set
875 * Otherwise, returns ok.
876 */
877 enum dbg_status ecore_dbg_print_attn(struct ecore_hwfn *p_hwfn,
878 									 struct dbg_attn_block_result *results);
879 
880 /**
881 * @brief ecore_is_block_in_reset - Returns true if the specified block is in
882 * reset, false otherwise.
883 *
884 * @param p_hwfn   - HW device data
885 * @param p_ptt   - Ptt window used for writing the registers.
886 * @param block - Block ID.
887 *
888 * @return true if the specified block is in reset, false otherwise.
889 */
890 bool ecore_is_block_in_reset(struct ecore_hwfn *p_hwfn,
891 							 struct ecore_ptt *p_ptt,
892 							 enum block_id block);
893 
894 #endif
895