Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
/*
 * Copyright (c) 2017-2018 Cavium, Inc. 
 * All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *  1. Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *  2. Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 *
 * $FreeBSD$
 *
 */

#ifndef _DBG_FW_FUNCS_H
#define _DBG_FW_FUNCS_H
/**************************** Public Functions *******************************/

/**
 * @brief ecore_dbg_set_bin_ptr - Sets a pointer to the binary data with debug
 * arrays.
 *
 * @param bin_ptr - a pointer to the binary data with debug arrays.
 */
enum dbg_status ecore_dbg_set_bin_ptr(const u8 * const bin_ptr);

/**
 * @brief ecore_dbg_set_app_ver - Sets the version of the calling app.
 *
 * The application should call this function with the TOOLS_VERSION
 * it compiles with. Must be called before all other debug functions.
 *
 * @return error if one of the following holds:
 *	- the specified app version is not supported
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_set_app_ver(u32 ver);

/**
 * @brief ecore_dbg_get_fw_func_ver - Returns the FW func version.
 *
 * @return the FW func version.
 */
u32 ecore_dbg_get_fw_func_ver(void);

/**
* @brief ecore_dbg_get_chip_id - Returns the FW func version.
*
* @param p_hwfn - HW device data
*
* @return the chip ID.
*/
enum chip_ids ecore_dbg_get_chip_id(struct ecore_hwfn *p_hwfn);

/**
* @brief ecore_read_regs - Reads registers into a buffer (using GRC).
*
* @param p_hwfn -	HW device data
* @param p_ptt -	Ptt window used for writing the registers.
* @param buf -	Destination buffer.
* @param addr -	Source GRC address in dwords.
* @param len -	Number of registers to read.
*/
void ecore_read_regs(struct ecore_hwfn *p_hwfn,
					 struct ecore_ptt *p_ptt,
					 u32 *buf,
					 u32 addr,
					 u32 len);

/**
 * @brief ecore_dbg_bus_reset - Resets the Debug block.
 *
 * After reset:
 * - The last recording is erased.
 * - Recording is directed to the internal buffer.
 * - Wrap-around recording is selected.
 * - All HW blocks are disabled.
 * - All Storms are disabled and all SEM filters are cleared.
 *
 * @param p_hwfn -		    HW device data
 * @param p_ptt -		    Ptt window used for writing the registers.
 * @param one_shot_en -     Enable/Disable one-shot recording. If disabled,
 *			    wrap-around recording is used instead.
 * @param force_hw_dwords - If set to 0, no. of HW/Storm dwords per cycle is
 *			    chosen automatically based on the enabled inputs.
 *			    Otherwise, no. of HW dwords per cycle is forced to
 *			    the specified value. Valid values: 0/2/4/8.
 * @param unify_inputs -    If true, all recorded data is associated with a
 *			    single input, as if all data was received from the
 *			    same block. Otherwise, each data unit is associated
 *			    with its original input.
 * @param grc_input_en -    Enable/Disable recording GRC input. If enabled, the
 *			    GRC input is recorded to the lsb dword of a cycle.
 *
 * @return error if one of the following holds:
 *	- the version wasn't set
 *	- force_hw_dwords is invalid.
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_bus_reset(struct ecore_hwfn *p_hwfn,
									struct ecore_ptt *p_ptt,
									bool one_shot_en,
									u8 force_hw_dwords,
									bool unify_inputs,
									bool grc_input_en);

/**
 * @brief ecore_dbg_bus_set_pci_output - Directs debug output to a PCI buffer.
 *
 * @param p_hwfn -		HW device data
 * @param p_ptt -		Ptt window used for writing the registers.
 * @param buf_size_kb - Size of PCI buffer to allocate (in KB). Must be aligned
 *			to PCI request size.
 *
 * @return error if one of the following holds:
 *	- the Debug block wasn't reset since last recording
 *	- the version wasn't set
 *	- the output was already set
 *	- the PCI buffer size is not aligned to PCI packet size
 *	- the PCI buffer allocation failed
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_bus_set_pci_output(struct ecore_hwfn *p_hwfn,
											 struct ecore_ptt *p_ptt,
											 u16 buf_size_kb);

/**
 * @brief ecore_dbg_bus_set_nw_output - Directs debug output to the network.
 *
 * @param p_hwfn -			HW device data
 * @param p_ptt -			Ptt window used for writing the registers.
 * @param port_id -		Port ID to transmit the debug data on
 * @param dest_addr_lo32 -	Destination MAC address (for Eth header)
 * @param dest_addr_hi16
 * @param data_limit_size_kb -  Data limit size in KB (valid only for one-shot)
 *				If set to 0, data limit won't be configured. 
 * @param send_to_other_engine -If true:
 *				1) The NW output will be sent to the DBG block
 *				   of the other engine.
 *				2) port_id argument is ignored.
 *				3) rcv_from_other_engine should be set to false
 *				   The other engine DBG block should call this
 *				   function with rcv_from_other_engine set to
 *				   true.
 * @param rcv_from_other_engine-If true:
 *				1) the DBG block receives the NW output sent
 *				   from the other engine DBG block, and sends
 *				   it to a NW port in the current engine
 *				   (according to port_id).
 *				2) The src/dest addresses and eth_type
 *				   arguments are ignored.
 *				3) send_to_other_engine should be set to false.
 *				   The other engine DBG block should call this
 *				   function with send_to_other_engine set to
 *				   true.
 *
 * @return error if one of the following holds:
 *	- the Debug block wasn't reset since last recording
 *	- the version wasn't set
 *	- the output was already set
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_bus_set_nw_output(struct ecore_hwfn *p_hwfn,
											struct ecore_ptt *p_ptt,
											u8 port_id,
											u32 dest_addr_lo32,
											u16 dest_addr_hi16,
											u16 data_limit_size_kb,
											bool send_to_other_engine,
											bool rcv_from_other_engine);

/**
 * @brief ecore_dbg_bus_enable_block - Enables recording of the specified block
 *
 * Each recording cycle contains 4 "units". If the recorded HW data requires up
 * to 4 dwords per cycle, each unit is one dword (32 bits). Otherwise, each
 * unit is 2 dwords (64 bits).
 *
 * @param p_hwfn -		HW device data
 * @param block -	block to be enabled.
 * @param line_num -	debug line number to select.
 * @param cycle_en -	4-bit value. If bit i is set, unit i is enabled.
 * @param right_shift -	number of units to  right the debug data (0-3).
 * @param force_valid - 4-bit value. If bit i is set, unit i is forced valid.
 * @param force_frame - 4-bit value. If bit i is set, the frame bit of unit i
 *			is forced.
 *
 * @return error if one of the following holds:
 *	- the Debug block wasn't reset since last recording
 *	- the version wasn't set
 *	- block is not valid
 *	- block was already enabled
 *	- cycle_en, force_valid or force_frame are wider than 4 bits
 *	- right_shift is larger than 3
 *	- cycle unit 0 is enabled, but GRC or timestamp were also enabled.
 *	- Too many inputs were enabled.
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_bus_enable_block(struct ecore_hwfn *p_hwfn,
										   enum block_id block,
										   u8 line_num,
										   u8 cycle_en,
										   u8 right_shift,
										   u8 force_valid,
										   u8 force_frame);

/**
 * @brief ecore_dbg_bus_enable_storm - Enables recording of the specified Storm
 *
 * @param p_hwfn -		HW device data
 * @param storm -	Storm to be enabled.
 * @param storm_mode-	Storm mode
 *
 * @return error if one of the following holds:
 *	- the Debug block wasn't reset since last recording
 *	- the version wasn't set
 *	- the specified storm or mode is invalid
 *	- Storm was already enabled
 *	- only HW data can be recorded
 *	- Too many inputs were enabled.
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_bus_enable_storm(struct ecore_hwfn *p_hwfn,
										   enum dbg_storms storm,
										   enum dbg_bus_storm_modes storm_mode);

/**
 * @brief ecore_dbg_bus_enable_timestamp - Enables timestamp recording.
 *
 * When enabled, the timestamp input is always recorded to the lsb dword of
 * a cycle, with HW ID 0.
 *
 * @param p_hwfn -	     HW device data
 * @param p_ptt -	     Ptt window used for writing the registers.
 * @param valid_en - 3-bit value. The Timestamp will be recorded in a cycle if
 *		     bit i is set and unit i+1 is valid.
 * @param frame_en - 3-bit value. The Timestamp will be recorded in a cycle if
 *		     bit i is set and unit i+1 has frame bit set.
 * @param tick_len - timestamp tick length in cycles, minus 1. A value of 0
 *		     means one cycle.
 *
 * @return error if one of the following holds:
 *	- the Debug block wasn't reset since last recording
 *	- the version wasn't set
 *	- valid_en or frame_en are wider than 4 bits
 *	- Both timestamp and GRC are enabled.
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_bus_enable_timestamp(struct ecore_hwfn *p_hwfn,
											   struct ecore_ptt *p_ptt,
											   u8 valid_en,
											   u8 frame_en,
											   u32 tick_len);

/**
 * @brief ecore_dbg_bus_add_eid_range_sem_filter- Add Event ID range SEM filter
 *
 * @param p_hwfn -     HW device data
 * @param storm -   Storm to be filtered.
 * @param min_eid - minimal Event ID to filter on.
 * @param max_eid - maximal Event ID to filter on.
 *
 * @return error if one of the following holds:
 *	- the specified Storm is invalid
 *	- the specified Storm wasn't enabled
 *	- the EID range is not valid
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_bus_add_eid_range_sem_filter(struct ecore_hwfn *p_hwfn,
													   enum dbg_storms storm,
													   u8 min_eid,
													   u8 max_eid);

/**
 * @brief ecore_dbg_bus_add_eid_mask_sem_filter - Add Event ID mask SEM filter
 *
 * @param p_hwfn -      HW device data
 * @param storm -    Storm to be filtered.
 * @param eid_val -  Event ID value.
 * @param eid_mask - Event ID mask. 0's in the mask = don't care bits.
 *
 * @return error if one of the following holds:
 *	- the specified Storm is invalid
 *	- the specified Storm wasn't enabled
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_bus_add_eid_mask_sem_filter(struct ecore_hwfn *p_hwfn,
													  enum dbg_storms storm,
													  u8 eid_val,
													  u8 eid_mask);

/**
 * @brief ecore_dbg_bus_add_cid_sem_filter - Adds a CID SEM filter.
 *
 * @param p_hwfn -   HW device data
 * @param storm	- Storm to be filtered.
 * @param cid -   CID to filter on.
 *
 * @return error if one of the following holds:
 *	- the specified Storm is invalid
 *	- the specified Storm wasn't enabled
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_bus_add_cid_sem_filter(struct ecore_hwfn *p_hwfn,
												 enum dbg_storms storm,
												 u32 cid);

/**
 * @brief ecore_dbg_bus_enable_filter - Enables the recording filter.
 *
 * A filter contains up to 4 constraints. The data is "filtered in" when the
 * added constraints hold.
 *
 * @param p_hwfn -		  HW device data
 * @param p_ptt -		  Ptt window used for writing the registers.
 * @param block -	  block to filter on.
 * @param const_msg_len	- Constant message length (in cycles) to be used for
 *			  message-based filter constraints. If set to 0,
 *			  message length is based only on frame bit received
 *			  from HW (no constant message length).
 *
 * @return error if one of the following holds:
 *	- the Debug block wasn't reset since last recording
 *	- the version wasn't set
 *	- the filter was already enabled
 *	- block is not valid or not enabled
 *	- more than 4 dwords are recorded per-cycle (forbids filters)
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_bus_enable_filter(struct ecore_hwfn *p_hwfn,
											struct ecore_ptt *p_ptt,
											enum block_id block,
											u8 const_msg_len);

/**
 * @brief ecore_dbg_bus_enable_trigger - Enables the recording trigger.
 *
 * A trigger contains up to 3 states, where each state contains up to
 * 4 constraints. After the constraints of a state hold for a specified number
 * of times, the DBG block moves to the next state. If there's no next state,
 * the DBG block triggers.
 *
 * @param p_hwfn -			HW device data
 * @param p_ptt -			Ptt window used for writing the registers.
 * @param rec_pre_trigger -	if true, recording starts before the trigger.
 *				if false, recording starts at the trigger.
 * @param pre_chunks -		max number of chunks to record before the
 *				trigger (1-47). If set to 0, recording starts
 *				from time 0. Ignored if rec_pre_trigger is
 *				false.
 * @param rec_post_trigger -	if true, recording ends after the trigger.
 *				if false, recording ends at the trigger.
 * @param post_cycles -		max number of cycles to record after the
 *				trigger (0x1-0xffffffff). If set to 0,
 *				recording ends only when stopped by the user.
 *				Ignored if rec_post_trigger is false.
 * @param filter_pre_trigger -	if true, data is filtered before the trigger.
 *				Ignored if the filter wasn't enabled.
 * @param filter_post_trigger -	if true, data is filtered after the trigger.
 *				Ignored if the filter wasn't enabled.
 *
 * @return error if one of the following holds:
 *	- the Debug block wasn't reset since last recording
 *	- the version wasn't set
 *	- the trigger was already enabled
 *	- more than 4 dwords are recorded per-cycle (forbids triggers)
 *	- pre_chunks is not in the range 0-47. 
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_bus_enable_trigger(struct ecore_hwfn *p_hwfn,
											 struct ecore_ptt *p_ptt,
											 bool rec_pre_trigger,
											 u8 pre_chunks,
											 bool rec_post_trigger,
											 u32 post_cycles,
											 bool filter_pre_trigger,
											 bool filter_post_trigger);

/**
 * @brief ecore_dbg_bus_add_trigger_state - Adds a trigger state.
 *
 * Up to 3 trigger states can be added, where each state contains up to
 * 4 constraints. After the constraints of a state hold for the specified
 * number of times, the DBG block moves to the next state. If there's no next
 * state, the DBG block triggers.
 *
 * @param p_hwfn -		  HW device data
 * @param p_ptt -		  Ptt window used for writing the registers.
 * @param block	-	  block to trigger on.
 * @param const_msg_len	- Constant message length (in cycles) to be used for
 *			  message-based filter constraints. If set to 0,
 *			  message length is based only on frame bit received
 *			  from HW (no constant message length).
 * @param count_to_next	- The number of times the constraints of the state
 *			  should hold before moving to the next state. Must be
 *			  non-zero.
 *
 * @return error if one of the following holds:
 *	- The trigger wasn't enabled.
 *	- more than 3 trigger states were added
 *	- block is not valid or not enabled
 *	- count_to_next is 0
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_bus_add_trigger_state(struct ecore_hwfn *p_hwfn,
												struct ecore_ptt *p_ptt,
												enum block_id block,
												u8 const_msg_len,
												u16 count_to_next);

/**
 * @brief ecore_dbg_bus_add_constraint - Adds a filter/trigger constraint.
 *
 * The constraint is added to a filter or trigger state, which ever was added
 * last. The filter/trigger happens if both of the following hold:
 * 1. All mandatory constraints are true.
 * 2. At least one optional (non-mandatory) constraints is true.
 *
 * @param p_hwfn -			  HW device data
 * @param p_ptt -			  Ptt window used for writing the registers.
 * @param op -			  constraint operation
 * @param data -		  32-bit data to compare with the recorded
 *				  data.
 * @param data_mask -		  32-bit mask for data comparison. If mask bit
 *				  i is 1, data bit i is compared, otherwise
 *				  it's ignored.
 *				  For eq/ne operations: any mask can be used.
 *				  For other operations: the mask must be
 *				  non-zero, and the 1's in the mask must be
 *				  continuous.
 * @param compare_frame -	  indicates if the frame bit should be
 *				  compared. Must be false for all operations
 *				  other than eq/ne.
 * @param frame_bit -		  frame bit to compare with the recorded data
 *				  (0/1). ignored if compare_frame is false.
 * @param cycle_offset -	  offset in cycles from the beginning of the
 *				  message, where cycle = 4 dwords.
 * @param dword_offset_in_cycle	- offset in dwords from the beginning of the
 *				  cycle (0-3).
 * @param is_mandatory -	  indicates if this constraint is mandatory
 *				  (true) or optional (false). The data is
 *				  filtered-in if all mandatory constraints hold
 *				  AND at least one optional constraint (if
 *				  added) holds.
 *
 * @return error if one of the following holds:
 *	- a filter or trigger state weren't enabled
 *	- all 4 filter constraints were added already
 *	- the op string is invalid
 *	- the data mask is invalid.
 *	- frame bit is not 0/1.
 *	- cycle_offset and dword_offset are not in the range 0-3.
 *	- compare_frame is true and operation is not eq/ne.
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_bus_add_constraint(struct ecore_hwfn *p_hwfn,
											 struct ecore_ptt *p_ptt,
											 enum dbg_bus_constraint_ops constraint_op,
											 u32 data,
											 u32 data_mask,
											 bool compare_frame,
											 u8 frame_bit,
											 u8 cycle_offset,
											 u8 dword_offset_in_cycle,
											 bool is_mandatory);

/**
 * @brief ecore_dbg_bus_start - Starts the recording.
 *
 * @param p_hwfn - HW device data
 * @param p_ptt - Ptt window used for writing the registers.
 *
 * @return error if one of the following holds:
 *	- the Debug block wasn't reset since last recording
 *	- the version wasn't set
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_bus_start(struct ecore_hwfn *p_hwfn,
									struct ecore_ptt *p_ptt);

/**
 * @brief ecore_dbg_bus_stop - Stops the recording and flushes the internal
 * buffer.
 *
 * @param p_hwfn - HW device data
 * @param p_ptt - Ptt window used for writing the registers.
 *
 * @return error if a recording is not in progress, ok otherwise.
 */
enum dbg_status ecore_dbg_bus_stop(struct ecore_hwfn *p_hwfn,
								   struct ecore_ptt *p_ptt);

/**
 * @brief ecore_dbg_bus_get_dump_buf_size - Returns the required buffer size
 * for Debug Bus recording.
 *
 * @param p_hwfn -      HW device data
 * @param p_ptt -	     Ptt window used for writing the registers.
 * @param buf_size - OUT: the required size (in dwords) of the buffer for
 *		     dumping the recorded Debug Bus data. If recording to the
 *		     internal buffer, the size of the internal buffer is
 *		     returned. If recording to PCI, the size of the PCI buffer
 *		     is returned. Otherwise, 0 is returned.
 *
 * @return error if one of the following holds:
 *	- the version wasn't set
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_bus_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
												struct ecore_ptt *p_ptt,
												u32 *buf_size);

/**
 * @brief ecore_dbg_bus_dump - Dumps the recorded Debug Bus data into the
 * specified buffer.
 *
 * The dumped data starts with a header. If recording to NW, only a header is
 * dumped. The dumped size is assigned to num_dumped_dwords.
 *
 * @param p_hwfn -			HW device data
 * @param p_ptt -			Ptt window used for writing the registers.
 * @param dump_buf -		Pointer to copy the recorded data into.
 * @param buf_size_in_dwords -	Size of the specified buffer in dwords.
 * @param num_dumped_dwords -	OUT: number of dumped dwords.
 *
 * @return error if one of the following holds:
 *	- a recording wasn't started/stopped
 *	- the specified dump buffer is too small
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_bus_dump(struct ecore_hwfn *p_hwfn,
								   struct ecore_ptt *p_ptt,
								   u32 *dump_buf,
								   u32 buf_size_in_dwords,
								   u32 *num_dumped_dwords);

/**
 * @brief ecore_dbg_grc_config - Sets the value of a GRC parameter.
 *
 * @param p_hwfn -		HW device data
 * @param grc_param -	GRC parameter
 * @param val -		Value to set.

 * @return error if one of the following holds:
 *	- the version wasn't set
 *	- grc_param is invalid
 *	- val is outside the allowed boundaries
 */
enum dbg_status ecore_dbg_grc_config(struct ecore_hwfn *p_hwfn,
									 enum dbg_grc_params grc_param,
									 u32 val);

/**
* @brief ecore_dbg_grc_set_params_default - Reverts all GRC parameters to their
* default value.
*
* @param p_hwfn - HW device data
*/
void ecore_dbg_grc_set_params_default(struct ecore_hwfn *p_hwfn);

/**
 * @brief ecore_dbg_grc_get_dump_buf_size - Returns the required buffer size
 * for GRC Dump.
 *
 * @param p_hwfn -      HW device data
 * @param p_ptt -	     Ptt window used for writing the registers.
 * @param buf_size - OUT: required buffer size (in dwords) for GRC Dump data.
 *
 * @return error if one of the following holds:
 *	- the version wasn't set
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_grc_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
												struct ecore_ptt *p_ptt,
												u32 *buf_size);

/**
 * @brief ecore_dbg_grc_dump - Dumps GRC data into the specified buffer.
 *
 * @param p_hwfn -			HW device data
 * @param p_ptt -			Ptt window used for writing the registers.
 * @param dump_buf -		Pointer to write the collected GRC data into.
 * @param buf_size_in_dwords -	Size of the specified buffer in dwords.
 * @param num_dumped_dwords -	OUT: number of dumped dwords.
 *
 * @return error if one of the following holds:
 *	- the version wasn't set
 *	- the specified dump buffer is too small
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_grc_dump(struct ecore_hwfn *p_hwfn,
								   struct ecore_ptt *p_ptt,
								   u32 *dump_buf,
								   u32 buf_size_in_dwords,
								   u32 *num_dumped_dwords);

/**
 * @brief ecore_dbg_idle_chk_get_dump_buf_size - Returns the required buffer
 * size for idle check results.
 *
 * @param p_hwfn -      HW device data
 * @param p_ptt -      Ptt window used for writing the registers.
 * @param buf_size - OUT: required buffer size (in dwords) for idle check data.
 *
 * @return error if one of the following holds:
 *	- the version wasn't set
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_idle_chk_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
													 struct ecore_ptt *p_ptt,
													 u32 *buf_size);

/**
 * @brief ecore_dbg_idle_chk_dump - Performs idle check and writes the results
 * into the specified buffer.
 *
 * @param p_hwfn -			HW device data
 * @param p_ptt -			Ptt window used for writing the registers.
 * @param dump_buf -		Pointer to write the idle check data into.
 * @param buf_size_in_dwords -	Size of the specified buffer in dwords.
 * @param num_dumped_dwords -	OUT: number of dumped dwords.
 *
 * @return error if one of the following holds:
 *	- the version wasn't set
 *	- the specified buffer is too small
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_idle_chk_dump(struct ecore_hwfn *p_hwfn,
										struct ecore_ptt *p_ptt,
										u32 *dump_buf,
										u32 buf_size_in_dwords,
										u32 *num_dumped_dwords);

/**
 * @brief ecore_dbg_mcp_trace_get_dump_buf_size - Returns the required buffer
 * size for mcp trace results.
 *
 * @param p_hwfn -	     HW device data
 * @param p_ptt -	     Ptt window used for writing the registers.
 * @param buf_size - OUT: required buffer size (in dwords) for mcp trace data.
 *
 * @return error if one of the following holds:
 *	- the version wasn't set
 *	- the trace data in MCP scratchpad contain an invalid signature
 *	- the bundle ID in NVRAM is invalid
 *	- the trace meta data cannot be found (in NVRAM or image file)
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_mcp_trace_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
													  struct ecore_ptt *p_ptt,
													  u32 *buf_size);

/**
 * @brief ecore_dbg_mcp_trace_dump - Performs mcp trace and writes the results
 * into the specified buffer.
 *
 * @param p_hwfn -			HW device data
 * @param p_ptt -			Ptt window used for writing the registers.
 * @param dump_buf -		Pointer to write the mcp trace data into.
 * @param buf_size_in_dwords -	Size of the specified buffer in dwords.
 * @param num_dumped_dwords -	OUT: number of dumped dwords.
 *
 * @return error if one of the following holds:
 *	- the version wasn't set
 *	- the specified buffer is too small
 *	- the trace data in MCP scratchpad contain an invalid signature
 *	- the bundle ID in NVRAM is invalid
 *	- the trace meta data cannot be found (in NVRAM or image file)
 *	- the trace meta data cannot be read (from NVRAM or image file)
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_mcp_trace_dump(struct ecore_hwfn *p_hwfn,
										 struct ecore_ptt *p_ptt,
										 u32 *dump_buf,
										 u32 buf_size_in_dwords,
										 u32 *num_dumped_dwords);

/**
 * @brief ecore_dbg_reg_fifo_get_dump_buf_size - Returns the required buffer
 * size for grc trace fifo results.
 *
 * @param p_hwfn -      HW device data
 * @param p_ptt -      Ptt window used for writing the registers.
 * @param buf_size - OUT: required buffer size (in dwords) for reg fifo data.
 *
 * @return error if one of the following holds:
 *	- the version wasn't set
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_reg_fifo_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
													 struct ecore_ptt *p_ptt,
													 u32 *buf_size);

/**
 * @brief ecore_dbg_reg_fifo_dump - Reads the reg fifo and writes the results
 * into the specified buffer.
 *
 * @param p_hwfn -			HW device data
 * @param p_ptt -			Ptt window used for writing the registers.
 * @param dump_buf -		Pointer to write the reg fifo data into.
 * @param buf_size_in_dwords -	Size of the specified buffer in dwords.
 * @param num_dumped_dwords -	OUT: number of dumped dwords.
 *
 * @return error if one of the following holds:
 *	- the version wasn't set
 *	- the specified buffer is too small
 *	- DMAE transaction failed
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_reg_fifo_dump(struct ecore_hwfn *p_hwfn,
										struct ecore_ptt *p_ptt,
										u32 *dump_buf,
										u32 buf_size_in_dwords,
										u32 *num_dumped_dwords);

/**
* @brief ecore_dbg_igu_fifo_get_dump_buf_size - Returns the required buffer
* size for the IGU fifo results.
*
* @param p_hwfn -      HW device data
* @param p_ptt -      Ptt window used for writing the registers.
* @param buf_size - OUT: required buffer size (in dwords) for IGU fifo data.
*
* @return error if one of the following holds:
*	- the version wasn't set
* Otherwise, returns ok.
*/
enum dbg_status ecore_dbg_igu_fifo_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
													 struct ecore_ptt *p_ptt,
													 u32 *buf_size);

/**
* @brief ecore_dbg_igu_fifo_dump - Reads the IGU fifo and writes the results
* into the specified buffer.
*
* @param p_hwfn -			HW device data
* @param p_ptt -			Ptt window used for writing the registers.
* @param dump_buf -		Pointer to write the IGU fifo data into.
* @param buf_size_in_dwords -	Size of the specified buffer in dwords.
* @param num_dumped_dwords -	OUT: number of dumped dwords.
*
* @return error if one of the following holds:
*	- the version wasn't set
*	- the specified buffer is too small
*	- DMAE transaction failed
* Otherwise, returns ok.
*/
enum dbg_status ecore_dbg_igu_fifo_dump(struct ecore_hwfn *p_hwfn,
										struct ecore_ptt *p_ptt,
										u32 *dump_buf,
										u32 buf_size_in_dwords,
										u32 *num_dumped_dwords);

/**
 * @brief ecore_dbg_protection_override_get_dump_buf_size - Return the required
 * buffer size for protection override window results.
 *
 * @param p_hwfn -      HW device data
 * @param p_ptt -      Ptt window used for writing the registers.
 * @param buf_size - OUT: required buffer size (in dwords) for protection
 *		     override data.
 *
 * @return error if one of the following holds:
 *	- the version wasn't set
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_protection_override_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
																struct ecore_ptt *p_ptt,
																u32 *buf_size);
/**
 * @brief ecore_dbg_protection_override_dump - Reads protection override window
 * entries and writes the results into the specified buffer.
 *
 * @param p_hwfn -			HW device data
 * @param p_ptt -			Ptt window used for writing the registers.
 * @param dump_buf -		Pointer to write the protection override data
 *				into.
 * @param buf_size_in_dwords -	Size of the specified buffer in dwords.
 * @param num_dumped_dwords -	OUT: number of dumped dwords.
 *
 * @return error if one of the following holds:
 *	- the version wasn't set
 *	- the specified buffer is too small
 *	- DMAE transaction failed
 * Otherwise, returns ok.
 */
enum dbg_status ecore_dbg_protection_override_dump(struct ecore_hwfn *p_hwfn,
												   struct ecore_ptt *p_ptt,
												   u32 *dump_buf,
												   u32 buf_size_in_dwords,
												   u32 *num_dumped_dwords);

/**
* @brief ecore_dbg_fw_asserts_get_dump_buf_size - Returns the required buffer
* size for FW Asserts results.
*
* @param p_hwfn -	    HW device data
* @param p_ptt -	    Ptt window used for writing the registers.
* @param buf_size - OUT: required buffer size (in dwords) for FW Asserts data.
*
* @return error if one of the following holds:
*	- the version wasn't set
* Otherwise, returns ok.
*/
enum dbg_status ecore_dbg_fw_asserts_get_dump_buf_size(struct ecore_hwfn *p_hwfn,
													   struct ecore_ptt *p_ptt,
													   u32 *buf_size);

/**
* @brief ecore_dbg_fw_asserts_dump - Reads the FW Asserts and writes the
* results into the specified buffer.
*
* @param p_hwfn -			HW device data
* @param p_ptt -			Ptt window used for writing the registers.
* @param dump_buf -		Pointer to write the FW Asserts data into.
* @param buf_size_in_dwords -	Size of the specified buffer in dwords.
* @param num_dumped_dwords -	OUT: number of dumped dwords.
*
* @return error if one of the following holds:
*	- the version wasn't set
*	- the specified buffer is too small
* Otherwise, returns ok.
*/
enum dbg_status ecore_dbg_fw_asserts_dump(struct ecore_hwfn *p_hwfn,
										  struct ecore_ptt *p_ptt,
										  u32 *dump_buf,
										  u32 buf_size_in_dwords,
										  u32 *num_dumped_dwords);

/**
* @brief ecore_dbg_read_attn - Reads the attention registers of the specified
* block and type, and writes the results into the specified buffer.
*
* @param p_hwfn -		HW device data
* @param p_ptt -		Ptt window used for writing the registers.
* @param block -	Block ID.
* @param attn_type -	Attention type.
* @param clear_status -	Indicates if the attention status should be cleared.
* @param results -	OUT: Pointer to write the read results into
*
* @return error if one of the following holds:
*	- the version wasn't set
* Otherwise, returns ok.
*/
enum dbg_status ecore_dbg_read_attn(struct ecore_hwfn *p_hwfn,
									struct ecore_ptt *p_ptt,
									enum block_id block,
									enum dbg_attn_type attn_type,
									bool clear_status,
									struct dbg_attn_block_result *results);
									
/**
* @brief ecore_dbg_print_attn - Prints attention registers values in the
* specified results struct.
*
* @param p_hwfn -     HW device data
* @param results - Pointer to the attention read results
*
* @return error if one of the following holds:
*	- the version wasn't set
* Otherwise, returns ok.
*/
enum dbg_status ecore_dbg_print_attn(struct ecore_hwfn *p_hwfn,
									 struct dbg_attn_block_result *results);

/**
* @brief ecore_is_block_in_reset - Returns true if the specified block is in
* reset, false otherwise.
*
* @param p_hwfn   - HW device data
* @param p_ptt   - Ptt window used for writing the registers.
* @param block - Block ID.
*
* @return true if the specified block is in reset, false otherwise.
*/
bool ecore_is_block_in_reset(struct ecore_hwfn *p_hwfn,
							 struct ecore_ptt *p_ptt,
							 enum block_id block);

#endif