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

init_mem.h (7875B)


      1 /** \file init_mem.h
      2  * DNX init memories. 
      3  * - Set memories to default values 
      4  * - Get the default value defined per each memory 
      5  */
      6 
      7 /*
      8  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      9  * 
     10  * Copyright 2007-2020 Broadcom Inc. All rights reserved.
     11  */
     12 
     13 #ifndef _BCMINT_DNX_INIT_INIT_MEM_H_INCLUDED
     14 /*
     15  * { 
     16  */
     17 #define _BCMINT_DNX_INIT_INIT_MEM_H_INCLUDED
     18 
     19 #ifndef BCM_DNX_SUPPORT
     20 #error "This file is for use by DNX family only!"
     21 #endif
     22 
     23 /*
     24  * Include files.
     25  * {
     26  */
     27 #include <bcm/types.h>
     28 #include <bcm/error.h>
     29 #include <bcm_int/control.h>
     30 
     31 #ifdef DNX_DATA_INTERNAL
     32 #undef DNX_DATA_INTERNAL
     33 #endif
     34 #include <soc/mcm/allenum.h>
     35 
     36 #include <shared/bsl.h>
     37 #include <shared/shrextend/shrextend_debug.h>
     38 /*
     39  * }
     40  */
     41 #define DNX_DYNAMIC_MEMORY_ACCESS_SET(unit, _blk_, _mem_, enable) \
     42     dnx_dynamic_memory_access_set(unit, _blk_##_ENABLE_DYNAMIC_MEMORY_ACCESSr, ENABLE_DYNAMIC_MEMORY_ACCESS_##_mem_##f, enable)
     43 
     44 /** 
     45   * the macro is aim to disable write protection for array memory 
     46   * For array memory, there are different field in blk_ENABLE_DYNAMIC_MEMORY_ACCESSr register, each represent an array
     47   * such as OCB_ENABLE_DYNAMIC_MEMORY_ACCESSr ENABLE_DYNAMIC_MEMORY_ACCESS_FBM_BANK_MEM_0f ~ ENABLE_DYNAMIC_MEMORY_ACCESS_FBM_BANK_MEM_31f
     48   */
     49 #define DNX_DYNAMIC_MEMORY_ARRAY_ACCESS_SET(unit, _blk_, mem, enable) \
     50     dnx_dynamic_memory_access_set_internal(unit, _blk_##_ENABLE_DYNAMIC_MEMORY_ACCESSr, mem, enable)
     51 
     52 /* 
     53  * Typedefs 
     54  * { 
     55  */
     56  /**
     57   * \brief - each valid writable memory default value will be set according to mode
     58   */
     59 typedef enum
     60 {
     61     /**
     62      * Set default value to zero
     63      */
     64     dnx_init_mem_default_mode_zero = 0,
     65     /**
     66      * Do not set default value.  
     67      * Might be used if the table will be set in module init. 
     68      */
     69     dnx_init_mem_default_mode_none = 1,
     70     /**
     71      * Set default value to all ones (0xFFFF...)  
     72      */
     73     dnx_init_mem_default_mode_all_ones = 2,
     74     /**
     75      * Each entry value will be the index.
     76      */
     77     dnx_init_mem_default_mode_index = 3,
     78     /**
     79      * Custom, expected a callback to provide the default value.
     80      * This mode do not support a default value per entry (all the input parameters in the callback shuld be ignored).
     81      */
     82     dnx_init_mem_default_mode_custom = 4,
     83 
     84     /**
     85      * Custom per entry, expected a callback to provide the default value.
     86      * This mode does not use slam dma and therefore less optimized
     87      */
     88     dnx_init_mem_default_mode_custom_per_entry = 5
     89 } dnx_init_mem_default_mode_e;
     90 
     91 /**
     92  * \brief - memory reset mode.
     93  *          Specify the method used to reset all writable memories that are not listed in dnx data (module='dev_init', sub_module='mem', table='default')
     94  */
     95 typedef enum
     96 {
     97     /**
     98      * Do not reset memories
     99      */
    100     dnx_init_mem_reset_mode_none = 0,
    101     /**
    102      * Reset using slam DMA
    103      */
    104     dnx_init_mem_reset_mode_dma = 1,
    105     /**
    106      * Reset using indirect commands mechanism
    107      */
    108     dnx_init_mem_reset_mode_indirect = 2
    109 } dnx_init_mem_reset_mode_e;
    110 
    111 /** 
    112  * \brief 
    113  * Callback to get custom default value. 
    114  * For simple custom mode all the input parameters should be ignored (one table for all the memory)
    115  */
    116 typedef int (
    117     *dnx_init_mem_default_get_f) (
    118     int unit,
    119     unsigned array_index,
    120     int copyno,
    121     int index,
    122     uint32 *entry_data);
    123 /*
    124  * } 
    125  */
    126 
    127 /**
    128  * \brief - 
    129  * Set default values for all valid writable memories.
    130  * This function use slam dma or dma to efficiently write to memories.
    131  * If the memory included in table dnx_data_dev_init.mem.default, the default value will be set accordingly.
    132  * Otherwise the memory will be set to 0. 
    133  *  
    134  * In a case the memory initialized manually - memory mode should be set to 'skip'. 
    135  * In a case the memory should be set to 0 - done automatically (no need to add to dnx data table) 
    136  * Otherwise the memory should be add to dnx data table (instructions below) 
    137  *  
    138  *  
    139  * Defining default value for memory:
    140  * ----------------------------------
    141  * 1. Go to device xml in dnx data (module='dev_init', sub_module='mem', table='default')
    142  * 2. Increase table size by 1
    143  * 3. Add a new entry:
    144  *        'index' - is just a running index.
    145  *        'mem' - is memory define
    146  *        'mode' - is one of the modes defined in enum 'dnx_init_mem_default_mode_e'
    147  *        'default_get_cb' - is optional (set to NULL if not required).
    148  *                           A callback to get the default data.
    149  *                           in a case the mode is 'custom' all the input parameters in callback should ignored (same default for all entries).
    150  *                           in a case the mode is 'custom_per_entry' different defaults for different entries might be defined.
    151  *         'field' - set just specific field (all the reset will be set to 0) - not relevant for custom modes
    152  * 4. Run dnxdata autocoder            
    153  *             
    154  * 
    155  * \param [in] unit - unit # 
    156  *  
    157  * \return
    158  *   See shr_error_e
    159  * \remark
    160  *   * None
    161  * \see
    162  *   * None
    163  */
    164 shr_error_e dnx_init_mem_default_init(
    165     int unit);
    166 /**
    167  * \brief - Release SW resources allocated in mem default init process ( dnx_init_mem_default_init() )
    168  *            
    169  * \param [in] unit - unit # 
    170  *  
    171  * \return
    172  *   See shr_error_e
    173  * \remark
    174  *   * None
    175  * \see
    176  *   * None
    177  */
    178 shr_error_e dnx_init_mem_default_deinit(
    179     int unit);
    180 
    181 /**
    182  * \brief - check if the memory has non standard default value and return it is_non_standard (non standard means that 
    183  *        not all zero).
    184  *  
    185  * \param [in] unit - unit # 
    186  * \param [in] mem - required memory
    187  * \param [in] is_non_standard - pointer to the result 0 means standard (all zero)
    188  * \return
    189  *   See shr_error_e
    190  * \remark
    191  *   * None
    192  * \see
    193  *   * None
    194  */
    195 shr_error_e dnx_init_mem_default_mode_get(
    196     int unit,
    197     soc_mem_t mem,
    198     int *is_non_standard);
    199 
    200 /**
    201  * \brief - Get default value of memory.
    202  *          Return the value which defined explicitly in dnx_data_dev_init.mem.default.
    203  *          If not found will return zero.
    204  * 
    205  * \param [in] unit - unit # 
    206  * \param [in] mem - required memory
    207  * \param [in] array_index - used for memory arrays (if not relevant set to 0) 
    208  * \param [in] copyno - block index 
    209  * \param [in] index - entry index 
    210  * \param [out] entry - pointer to uint32 buffer (size must be > SOC_MEM_WORDS(unit, mem))
    211  * \param [out] mode - the mode used to set the defaults
    212  * \return
    213  *   See shr_error_e
    214  * \remark
    215  *   * None
    216  * \see
    217  *   * None
    218  */
    219 shr_error_e dnx_init_mem_default_get(
    220     int unit,
    221     soc_mem_t mem,
    222     int array_index,
    223     int copyno,
    224     int index,
    225     uint32 *entry,
    226     dnx_init_mem_default_mode_e * mode);
    227 
    228 /**
    229  * \brief - Enable dynamic memory access.
    230  * 
    231  * \param [in] unit - unit # 
    232  * \param [in] reg - enable dynamic access register
    233  * \param [in] field - field
    234  * \param [in] enable - enable dynamic memory access or not 
    235  * \return
    236  *   See shr_error_e
    237  * \remark
    238  *   * None
    239  * \see
    240  *   * None
    241  */
    242 int dnx_dynamic_memory_access_set(
    243     int unit,
    244     soc_reg_t reg,
    245     soc_field_t field,
    246     int enable);
    247 
    248 /**
    249  * \brief - Enable dynamic memory access according to specific memory.
    250  * 
    251  * \param [in] unit - unit # 
    252  * \param [in] reg - enable dynamic access register
    253  * \param [in] mem - required memory
    254  * \param [in] enable - enable dynamic memory access or not 
    255  * \return
    256  *   See shr_error_e
    257  * \remark
    258  *   * None
    259  * \see
    260  *   * None
    261  */
    262 int dnx_dynamic_memory_access_set_internal(
    263     int unit,
    264     soc_reg_t reg,
    265     soc_mem_t mem,
    266     int enable);
    267 /**
    268  * \brief - test dynamic memory access, enable/disable memory write protection to test
    269  * 
    270  * \param [in] unit - unit # 
    271  * \return
    272  *   See shr_error_e
    273  * \remark
    274  *   * None
    275  * \see
    276  *   * None
    277  */
    278 int dnx_test_dynamic_memory_access(
    279     int unit);
    280 
    281 #endif /* _BCMINT_DNX_INIT_INIT_MEM_H_INCLUDED */