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

sw_state_utils.h (3458B)


      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 
      8 #ifndef _SHR_SW_STATE_UTILS_H
      9 #define _SHR_SW_STATE_UTILS_H
     10 
     11 #include <soc/types.h>
     12 #include <shared/swstate/sw_state.h>
     13 #include <shared/swstate/layout/sw_state_layout.h> 
     14 
     15 /* scache operations */
     16 typedef enum shr_sw_state_scache_oper_e {
     17     socSwStateScacheRetreive,
     18     socSwStateScacheCreate,
     19     socSwStateScacheRealloc
     20 } shr_sw_state_scache_oper_t;
     21 
     22 typedef enum
     23 {
     24     SHR_SW_STATE_SCACHE_HANDLE_DATA_BLOCK,
     25     SHR_SW_STATE_SCACHE_HANDLE_JOURNAL
     26 } SHR_SW_STATE_SCACHE_HANDLES;
     27 
     28 #define SW_STATE_NODE_ID_CHECK(unit, node_id) \
     29     do{ \
     30         if (node_id >= SW_STATE_LAYOUT_NOF_MAX_LAYOUT_NODES) {\
     31             _SOC_EXIT_WITH_ERR(BCM_E_FULL, \
     32                        (BSL_META_U(unit, \
     33                           "Unit:%d sw state ERROR: the ds_layout_nodes array is full.\n"), unit)); \
     34         }\
     35     } while(0)
     36 
     37 /*
     38  *           ------ 
     39  *          | node |
     40  *          -------\
     41  *            |     \-----------------------------|
     42  *            v                                   v
     43  *          -------     -------     ------- 
     44  *          | node |--->| node |--->| node |--> ...
     45  *          -------     -------     ------- 
     46  * 
     47  * ex:
     48  *          -------
     49  *          | dpp |
     50  *          -------
     51  *            |    \-------------------|
     52  *            v                        v
     53  *          -------     -------     --------- 
     54  *          | bcm  |--->| soc  |--->| shared |
     55  *          -------     -------     --------- 
     56 
     57  * Note: layout is saved in sw state header (shr_sw_state_data_block_header)
     58  *       offsets are relative to shr_sw_state_data_block_header address
     59  *       layout node: an element of a struct
     60  *       children of a node: they are the element of parent node's struct 
     61  *       root: *sw_state 
     62  */
     63 
     64 
     65 /**********************************************/
     66 /***********      Functions     ***************/
     67 /**********************************************/
     68 
     69 uint8 sw_state_is_flag_on(
     70     uint32 flags,
     71     uint32 flag);
     72 
     73 uint8 dnxc_sw_state_alloc_during_test_set(
     74     int unit,
     75     uint8 flag);
     76 
     77 uint8 dnxc_sw_state_alloc_during_test_get(
     78     int unit);
     79 
     80 int shr_sw_state_ds_layout_node_t_clear(shr_sw_state_ds_layout_node_t *node); 
     81 
     82 int shr_sw_state_ds_layout_node_set(int unit, 
     83                                     int node_id, 
     84                                     char* name, 
     85                                     int size, 
     86                                     int nof_pointer,
     87                                     char* type, 
     88                                     int array_size_0, 
     89                                     int array_size_1); 
     90 int shr_sw_state_ds_layout_add_child(int unit, int parent_node_id, int child_node_id); 
     91 int shr_sw_state_ds_layout_add_brother(int unit, int older_brother_node_id, int younger_brother_node_id); 
     92 int shr_sw_state_ds_layout_update_offset(int unit, int node_id, int offset); 
     93 
     94 int shr_sw_state_utils_init(int unit);
     95 int shr_sw_state_utils_deinit(int unit);
     96 
     97 int shr_sw_state_scache_ptr_get(int unit, soc_scache_handle_t handle, shr_sw_state_scache_oper_t oper,
     98                              int flags, uint32 *size, uint8 **scache_ptr, int *already_exists);
     99 
    100 int shr_sw_state_scache_sync(int unit, soc_scache_handle_t handle, int offset, int size);
    101 
    102 
    103 
    104 
    105 #endif  /* _SHR_SW_STATE_UTILS_H */