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

telemetry.h (6627B)


      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:        telemetry.h
      8  * Purpose:     
      9  */
     10 #ifndef _BCM_INT_TELEMETRY_H_
     11 #define _BCM_INT_TELEMETRY_H_
     12 
     13 #if defined(INCLUDE_TELEMETRY)
     14 
     15 #include <bcm/telemetry.h>
     16 #include <bcm/collector.h>
     17 #include <shared/idxres_fl.h>
     18 #include <soc/shared/st.h>
     19 
     20 /* Maximum number of telemetry instances. */
     21 #define BCM_INT_TELEMETRY_MAX_INSTANCES 1
     22 
     23 /* Telemetry module invalid index definition */
     24 #define BCM_TELEMETRY_INVALID_INDEX -1
     25 
     26 /* Telemetry module MAX system ID  length */
     27 #define BCM_TELEMETRY_MAX_SYSTEM_ID_LENGTH 32
     28 
     29 /*
     30  * Macro:
     31  *     _BCM_TELEMETRY_ALLOC
     32  * Purpose:
     33  *      Generic memory allocation routine.
     34  * Parameters:
     35  *    _ptr_     - Pointer to allocated memory.
     36  *    _ptype_   - Pointer type.
     37  *    _size_    - Size of heap memory to be allocated.
     38  *    _descr_   - Information about this memory allocation.
     39  */
     40 #define _BCM_TELEMETRY_ALLOC(_ptr_,_ptype_,_size_,_descr_)               \
     41             do {                                                         \
     42                 if (NULL == (_ptr_)) {                                   \
     43                    (_ptr_) = (_ptype_ *) sal_alloc((_size_), (_descr_)); \
     44                 }                                                        \
     45                 if((_ptr_) != NULL) {                                    \
     46                     sal_memset((_ptr_), 0, (_size_));                    \
     47                 }  else {                                                \
     48                     LOG_ERROR(BSL_LS_BCM_TELEMETRY, \
     49                               (BSL_META("Telemetry Error: Allocation"    \
     50                               " failure %s\n"),                          \
     51                                (_descr_)));                              \
     52                 }                                                        \
     53             } while (0)
     54 
     55 /* Internal data structure to store
     56  * telemetry global information.
     57  */
     58 typedef struct _bcm_telemetry_global_info_s {
     59 
     60     /* flags, See BCM_INT_TELEMETRY_INFO_FLAGS_XXX */
     61     uint32 flags;
     62     
     63     /* Number of telemrty instances configured */
     64     uint32 num_telemetry_instances;
     65 
     66     /* System Identification to be used in export data to collector. */
     67     uint8 system_id[BCM_TELEMETRY_MAX_SYSTEM_ID_LENGTH];
     68     
     69     /* system ID length */
     70     uint8 system_id_length;
     71 
     72     /* Maximum size of the packet sent by telemetry application */
     73     uint32 max_pkt_size;
     74 
     75     /* Internal BTE Export profile ID pool */
     76     shr_idxres_list_handle_t int_profile_pool;
     77 
     78     /* Internal BTE Collector ID pool */
     79     shr_idxres_list_handle_t int_collector_pool;
     80 
     81     /* Number of valid ports at any point of time */
     82     uint16 num_ports;
     83 
     84     /* List of ports used for stats monitoring */
     85     uint16 lports[SHR_ST_MAX_PORTS];
     86 
     87     /* Maximum number of ports to be monitored */
     88     uint16 max_num_ports;
     89 
     90     /* DMA Buffer used for messaging between SDK and
     91      * UKERNEL.
     92      */
     93     uint8 *dma_buffer;
     94     /* Length of the DMA buffer */
     95     int dma_buffer_len;
     96 
     97     /* Flag to indicate whether the app is loaded */
     98     uint8 uc_loaded;
     99 
    100     /* uC number on which the app is loaded */
    101     uint8 uC;
    102 } _bcm_telemetry_global_info_t;
    103 
    104 /* Internal data structure to store per telemetry information
    105  */
    106 typedef struct _bcm_telemetry_instance_info_s {
    107     /* Telemetry instance ID configured by applocation */
    108     int instance_id;
    109     
    110     /* Fw ARM core on which telemetry instance is being run */
    111     int core;
    112 
    113     /* Telemetry config object count */
    114     int config_count;
    115 
    116     /* Telemetry config structure */
    117     bcm_telemetry_config_t *telemetry_config;
    118 
    119     /* Collector associated with this instance */
    120     bcm_collector_t collector_id;
    121 
    122     /* Export profile  associated with this instance */
    123     int export_profile_id;
    124 
    125     /* Number of collectors configured on this instance */
    126     uint32 num_collectors;
    127 
    128 } _bcm_telemetry_instance_info_t;
    129 
    130 /* Global data structures extern declarations */
    131 extern _bcm_telemetry_global_info_t *telemetry_global_info[BCM_MAX_NUM_UNITS];
    132 
    133 /* Utility functions */
    134 extern void _bcm_esw_telemetry_sw_dump(int unit);
    135 extern void _bcm_xgs5_telemetry_sw_dump(int unit);
    136 
    137 /* Gets the TELEMETRY_GLOBAL_INFO struct for the unit */
    138 #define TELEMETRY_GLOBAL_INFO_GET(_u) telemetry_global_info[(_u)]
    139 
    140 extern int _bcm_xgs5_telemetry_instance_config_update(int unit,
    141                            int telemetry_instance_id,
    142                            int core,
    143                            int config_count,
    144                            bcm_telemetry_config_t *telemetry_config);
    145 extern int _bcm_xgs5_telemetry_instance_config_get(int unit,
    146                            int telemetry_instance_id,
    147                            int core,
    148                            int max_count,
    149                            bcm_telemetry_config_t *telemetry_config,
    150                            int *config_count);
    151 extern int _bcm_xgs5_telemetry_instance_export_config_update(int unit,
    152                            int telemetry_instance_id,
    153                            bcm_collector_t collector_id,
    154                            int export_profile_id);
    155 
    156 extern int _bcm_xgs5_telemetry_instance_export_config_get(int unit,
    157                            int telemetry_instance_id,
    158                            bcm_collector_t *collector_id,
    159                            int *export_profile_id);
    160 extern int _bcm_xgs5_telemetry_system_id_get(int unit, int max_system_id_len,
    161                            int *system_id_len, uint8 *system_id);
    162 extern int _bcm_xgs5_telemetry_system_id_set(int unit, int system_id_len,
    163                            uint8 *system_id);
    164 
    165 extern int bcm_xgs5_telemetry_instance_export_stats_get(
    166                                     int unit,
    167                                     int telemetry_instance,
    168                                     bcm_collector_t collector_id,
    169                                     bcm_telemetry_instance_export_stats_t *stats);
    170 
    171 extern int bcm_xgs5_telemetry_instance_export_stats_set(
    172                                     int unit,
    173                                     int telemetry_instance,
    174                                     bcm_collector_t collector_id,
    175                                     bcm_telemetry_instance_export_stats_t *stats);
    176 
    177 extern int _bcm_xgs5_telemetry_init(int unit);
    178 extern int _bcm_xgs5_telemetry_detach(int unit);
    179 extern int _bcm_xgs5_telemetry_sync(int unit);
    180 
    181 extern int _bcm_esw_telemetry_sync(int unit);
    182 #endif /* INCLUDE_TELEMETRY */
    183 #endif  /* !_BCM_INT_TELEMETRY_H_ */