openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

diag_signals_dump.h (8190B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2020 Broadcom Inc. All rights reserved.
      6  *
      7  * File:        diag_signals_dump.h
      8  * Purpose:     
      9  */
     10 
     11 #ifndef   _DIAG_SIGNALS_DUMP_H_
     12 #define   _DIAG_SIGNALS_DUMP_H_
     13 
     14 #include <appl/diag/shell.h>
     15 #include <appl/diag/parse.h>
     16 
     17 #ifdef BCM_PETRA_SUPPORT
     18 /*This macro handles an allocation error*/
     19 #define IF_ALLOC_ERROR_EXIT(rv,func)                       \
     20     if (rv == NULL) {                                      \
     21         sal_printf("ERROR: %s function failed!\n", func);  \
     22         return CMD_FAIL;                                   \
     23     }      
     24 
     25 /*This macro handles an allocation error*/
     26 #define IF_ALLOC_ERROR_GOTO_EXIT(rv,func)                  \
     27     if (rv == NULL) {                                      \
     28         sal_printf("ERROR: %s function failed!\n", func);  \
     29         goto exit;                                         \
     30     }      
     31 
     32 /*This macro handles an error represented as uint32*/
     33 #define IF_ERROR_EXIT(rv,func)                             \
     34     if (soc_sand_get_error_code_from_error_word(rv) != 0) {\
     35         sal_printf("ERROR: %s function failed!\n", func);  \
     36         return CMD_FAIL;                                   \
     37     }                                                      \
     38 
     39 /*This macro handles an error represented as uint32*/
     40 #define IF_ERROR_GOTO_EXIT(rv,func)                        \
     41     if (soc_sand_get_error_code_from_error_word(rv) != 0) {\
     42         sal_printf("ERROR: %s function failed!\n", func);  \
     43         goto exit;                                         \
     44     }                                                      \
     45 
     46 /*This macro handles an error of type cmd_result_t*/
     47 #define IF_CMD_ERROR_EXIT(res,func)                        \
     48     if (res == CMD_FAIL) {                                 \
     49         sal_printf("ERROR: %s function failed!\n", func);  \
     50         return CMD_FAIL;                                   \
     51     }                                                      \
     52 
     53 /*This macro handles an error of type cmd_result_t*/
     54 #define IF_CMD_ERROR_GOTO_EXIT(res,func)                   \
     55     if (res == CMD_FAIL) {                                 \
     56         sal_printf("ERROR: %s function failed!\n", func);  \
     57         goto exit;                                         \
     58     }                                                      \
     59 
     60 /*This macro handles a print request 
     61   If filename is NULL - print to the screen*/
     62 #define PRINT_TO_TARGET(file_dsc,cli_out_args, sal_fprintf_args)    \
     63     if (file_dsc == NULL) {                                         \
     64         bsl_printf cli_out_args;                                    \
     65     } else{                                                         \
     66         sal_fprintf sal_fprintf_args;                               \
     67     }                                                               \
     68 
     69 /*********************************************************************
     70  *     Creates a dump file of the packet signals,
     71  *     parsed to match the verilog format.
     72  *     Currently set to match ARAD & ARAD+
     73  */
     74 cmd_result_t 
     75   cmd_dpp_diag_parsed_signals_get(
     76         int unit,
     77         int core_id,
     78         char * filename);
     79 
     80 #ifndef NO_FILEIO /*If no IO - block all inner functions - they are not relevant*/
     81 /*********************************************************************
     82  *     Writes parsed signals to a buffer or to the output file
     83  *     (or both), in the verilog format.
     84  *  
     85  *     This funtion should be used only for a signal that is stored in
     86  *     a single address
     87  *  
     88  *     buffer is almost always filled. special cases below.
     89  *  
     90  *     Parameters:
     91  *  
     92  *          line_index  - the line number to be writen at the beginning
     93  *          of the line.
     94  *  
     95  *          prm_*       - these parameters refer to the location of the
     96  *          raw signal data.
     97  *  
     98  *          write_to_file -
     99  *              0 : in this option you choose to not print to file.
    100  *              1 : this is the regular case, when the program writes a
    101  *                  new signal to the file
    102  *  
    103  *     Note: if you want the data to be zeroes, assign
    104  *     (prm_addr_msb == 0) &&( prm_addr_lsb == 0) &&( prm_fld_msb == 0)
    105  *     prm_fld_lsb == amount of zeroes.
    106  *     for this option the buffer will not be filled.
    107  */
    108 cmd_result_t
    109 cmd_dpp_diag_psd_parse_signal(
    110     int core_id,
    111     int line_index,
    112     char* field_name,
    113      int prm_addr_msb,
    114      int prm_addr_lsb,
    115      int prm_fld_msb,
    116      int prm_fld_lsb,
    117      int write_to_file );
    118     
    119 
    120 
    121 /**********************************************************************
    122  * Fills the file with the specified amount of zeroes
    123  */
    124 void
    125     cmd_dpp_diag_psd_print_zeroes_to_file(
    126         int amount, FILE *fp);
    127 
    128 
    129 /**********************************************************************
    130  * Add the input data (number),as a string in hex format, 
    131  * to the input str. the data is appended to the str. 
    132  * hex_digits is the amount of nibbles to be added.
    133  */
    134 void
    135     cmd_dpp_diag_psd_add_hex_to_str( 
    136         int hex_digits,
    137         int data,
    138         char *str)
    139 ;
    140 
    141 /**********************************************************************
    142  * Parses and prints gen_header signal to output file
    143  */
    144 cmd_result_t
    145 cmd_dpp_diag_psd_get_gen_header(
    146     int core_id,
    147     int line_index
    148     )
    149 ;
    150 
    151 /**********************************************************************
    152  * Writes gen_header given data from one adress to the buffer
    153  */
    154 int 
    155 cmd_dpp_diag_psd_get_gen_header_line(
    156     int full_regs_amount,
    157     int bit_res_old,
    158     int bit_res_amount
    159     ) 
    160 ;
    161 
    162 /**********************************************************************
    163  * Prints registers data to output file
    164  */
    165 cmd_result_t
    166 cmd_dpp_diag_psd_get_registers(
    167     int unit,
    168     int core_id,
    169     int line_index
    170     )
    171 ;
    172 
    173 /**********************************************************************
    174  * Insert data to resolved_data->p2_oam_id_and_oam_sub_type
    175  */
    176 void
    177 cmd_dpp_diag_psd_get_p2_oam_id_and_oam_sub_type_again(void);
    178 
    179 /**********************************************************************
    180  * Print resolved data to the signals dump file
    181  */
    182 void
    183 cmd_dpp_diag_psd_print_resolved_data(
    184     int line_index
    185     )
    186 ;
    187 
    188 /**********************************************************************
    189  * Print out_pp_port to the signals dump file
    190  */
    191 cmd_result_t
    192 cmd_dpp_diag_psd_get_out_pp_port(
    193      int core_id,
    194     int line_index
    195     )
    196 ;
    197 
    198 /**********************************************************************
    199  * Print prge_program to the signals dump file
    200  */
    201 void
    202 cmd_dpp_diag_psd_get_prge_program(
    203     int unit,
    204     int line_index
    205     )
    206 ;
    207 
    208 /**********************************************************************
    209  * Print original_packet to the signals dump file
    210  */
    211 cmd_result_t
    212 cmd_dpp_diag_psd_get_original_packet(
    213     int unit,
    214     int core_id,
    215     int line_index
    216     )
    217 ;
    218 
    219 /**********************************************************************
    220  * Parses the content of regs_val (a uint32 array) to str, 
    221  * as a hex number.  parameters prm_fld_lsb, prm_fld_msb represent 
    222  * the amount of bits in the array. 
    223  */
    224 void
    225 cmd_dpp_diag_psd_regs_val_to_str(
    226     int prm_fld_msb,
    227     int prm_fld_lsb,
    228     char *str
    229     )
    230 ;
    231 
    232 /**********************************************************************
    233  * Fills the global variable tbl_data with relevant data
    234  */
    235 cmd_result_t
    236 cmd_dpp_diag_psd_get_table_data_for_signals_dump(
    237     int unit, 
    238     int core_id);
    239 
    240 /**********************************************************************
    241  * Update the original packet with ftmh_base fields
    242  */
    243 cmd_result_t
    244 cmd_dpp_diag_psd_update_ftmh_base(
    245     int bits_to_add,
    246     int core_id);
    247 
    248 /**********************************************************************
    249  * Update ftmh_base specific field
    250  */
    251 void
    252 cmd_dpp_diag_psd_update_ftmh_base_field(
    253     int data, 
    254     int bit_start, 
    255     int bit_end, 
    256     int ftmh_base_offset
    257     )
    258 ;
    259 
    260 /*****************************
    261 * Dividing the ints, and ceiling the result
    262  */ 
    263 int
    264 cmd_dpp_diag_psd_ceil_div(int dividend, int divisor) ;
    265 #endif /*FOR FILE IO*/
    266 #endif /* BCM_PETRA_SUPPORT */
    267 #endif /* _DIAG_SIGNALS_DUMP_H_ */
    268