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

hw_log.h (5170B)


      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-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * This file contains structure and routine declarations for the
      8  * Crash Recovery Mechanism.
      9  *
     10  * This file also includes the more common include files so the
     11  * individual driver files don't have to include as much.
     12  */
     13 
     14 #ifndef _HW_LOG_H
     15 #define _HW_LOG_H
     16 
     17 #ifdef CRASH_RECOVERY_SUPPORT
     18 #include <sal/core/thread.h>
     19 #include <sal/core/time.h>
     20 #include <soc/register.h>
     21 
     22 extern int
     23 soc_hw_log_get_working_mode(int unit);
     24 
     25 extern int
     26 soc_hw_log_do_hwlog_read_write(int unit);
     27 
     28 #endif /* CRASH_RECOVERY_SUPPORT */
     29 
     30 extern int
     31 soc_hw_log_suppress(int unit);
     32 
     33 extern int
     34 soc_hw_log_unsuppress(int unit);
     35 
     36 extern int
     37 soc_hw_log_ensure_not_suppressed(int unit);
     38 
     39 #if defined(BCM_PETRA_SUPPORT) && defined(CRASH_RECOVERY_SUPPORT)
     40 #define         BCM_UNIT_DO_HW_READ_WRITE(unit)                 soc_hw_log_do_hwlog_read_write(unit)
     41 #else
     42 #define         BCM_UNIT_DO_HW_READ_WRITE(unit)                 (0)
     43 #endif
     44 
     45 #ifdef CRASH_RECOVERY_SUPPORT
     46 
     47 #define HWLOG_MAX(a,b) ((a) > (b) ? (a) : (b))
     48 #define HWLOG_MIN(a,b) ((a) < (b) ? (a) : (b))
     49 
     50 #define HW_LOG_DMA_BUFFER_SIZE 1048576
     51 
     52 typedef enum LogEntry_Type
     53 {
     54     LOG_ENTRY_TYPE_UnKnown = 0,
     55     LOG_ENTRY_TYPE_Memory,
     56     LOG_ENTRY_TYPE_Register32,
     57     LOG_ENTRY_TYPE_Register64,
     58     LOG_ENTRY_TYPE_Register_Above64,
     59     LOG_ENTRY_TYPE_Polling,
     60     LOG_ENTRY_TYPE_FastRegData,
     61     LOG_ENTRY_TYPE_DirectRegWrite,
     62     LOG_ENTRY_TYPE_SocRegData,
     63     LOG_ENTRY_TYPE_SocRegNoCacheData,
     64     LOG_ENTRY_TYPE_SbusDMA
     65 } LogEntry_Type_t;
     66 
     67 typedef struct SbusDMA
     68 {
     69     int         flags;
     70     soc_mem_t   mem;
     71     unsigned    array_index_start;
     72     unsigned    array_index_end;
     73     int         copyno;
     74     int         index_begin;
     75     int         index_end;
     76     void        *buffer;
     77     uint8       mem_clear;
     78     int         clear_buf_ent;
     79     int         vchan;
     80     uint8       IsCoreAll;
     81 } SbusDMA_t;
     82 
     83 typedef struct MemData
     84 {
     85     soc_mem_t               Mem;
     86     uint32                  ArrayIndex;
     87     int                     Blk /*(copyno)*/;
     88     uint8                   IsCoreAll;
     89     int                     Index;
     90     char                    EntryData[SOC_REG_ABOVE_64_MAX_SIZE_U32 * sizeof(int)];
     91     uint8                   DescDMA;
     92 } MemData_t;
     93 
     94 typedef struct RegData
     95 {
     96     soc_reg_t               Reg;
     97     int                     Port;
     98     int                     Index;
     99     soc_reg_above_64_val_t  EntryData;
    100 } RegData_t;
    101 
    102 typedef struct PollingData
    103 {
    104     sal_usecs_t             TimeOut;
    105     int32                   MinPolls;
    106     soc_reg_t               Reg;
    107     int32                   Port;
    108     int32                   Index;
    109     soc_field_t             Field;
    110     int32                   ExpectedValue;
    111 } PollingData_t;
    112 
    113 typedef struct DirectReg_Data_s
    114 {
    115     int                     CmicBlock;
    116     uint32                  Addr;
    117     uint32                  DwcWrite;
    118     uint32                  EntryData;
    119 } DirectRegData_t;
    120 
    121 typedef struct FastReg_Data_s
    122 {
    123     soc_reg_t               Reg;
    124     int                     AccType;
    125     int                     Addr;
    126     int                     Block;
    127     soc_reg_above_64_val_t  EntryData;
    128 } FastReg_Data_t;
    129 
    130 typedef union LogEntry_Data
    131 {
    132     MemData_t               MemData;
    133     RegData_t               RegData;
    134     PollingData_t           PollingData;
    135     DirectRegData_t         DirectRegData;
    136     FastReg_Data_t          FastRegData;
    137     SbusDMA_t               SbusDMA;
    138 } LogEntry_Data_t;
    139 
    140 typedef struct LogEntry_s
    141 {
    142     LogEntry_Type_t   Type;
    143     LogEntry_Data_t   Data;
    144 } LogEntry_t;
    145 
    146 typedef struct HwLogEntry_s
    147 {
    148     LogEntry_t Entry;
    149 } HwLogEntry_t;
    150 
    151 typedef struct hw_log_header_s {
    152     uint32 max_elements;
    153     uint32 nof_elements;
    154     uint32 hw_log_commit_index;
    155     uint32 dma_allocated_size;
    156 } hw_log_header_t;
    157 
    158 typedef struct LogList
    159 {
    160     uint8               init;
    161     hw_log_header_t    *header;
    162     HwLogEntry_t       *journal;
    163     uint32              size;
    164     uint8               ImmediateAccess;    /* Bypass Hw Log */
    165     uint32              access_ct;
    166     uint8               brcd_blocks[SOC_MAX_NUM_BLKS];
    167     uint8               is_suppressed;      /* Commit and bypass Hw Log to the end of current API */
    168     soc_hw_log_access_t Access_cb;          /* Access callbacks*/
    169 } LogList_t;
    170 
    171 extern int
    172 soc_hw_log_init(int unit, uint32 size);
    173 
    174 extern int
    175 soc_hw_log_deinit(int unit);
    176 
    177 extern int
    178 soc_hw_log_commit(int unit);
    179 
    180 extern int
    181 soc_hw_log_sync(int unit);
    182 
    183 extern int
    184 soc_hw_log_purge(int unit);
    185 
    186 extern int
    187 soc_hw_log_mem_test(int unit, soc_mem_t mem, void* data);
    188 
    189 extern int
    190 soc_hw_log_print_list(int unit);
    191 
    192 extern int
    193 soc_hw_log_reg_test(int unit);
    194 
    195 extern int
    196 soc_mem_single_test(int unit, soc_mem_t mem);
    197 
    198 extern int 
    199 soc_hw_reset_immediate_hw_access_counter(int unit);
    200 
    201 extern int
    202 soc_hw_set_immediate_hw_access(int unit);
    203 
    204 extern int
    205 soc_hw_restore_immediate_hw_access(int unit);
    206 
    207 extern int
    208 soc_hw_ensure_immediate_hw_access_disabled(int unit);
    209 
    210 extern LogList_t Hw_Log_List[SOC_MAX_NUM_DEVICES];
    211 
    212 #endif 
    213 #endif /*_HW_LOG_H*/