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

latency_monitor.h (4409B)


      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  * File:        latency_monitor.h,
      8  * Purpose:     
      9  */
     10 #ifndef _BCM_LATENCY_MONITOR_H_
     11 #define _BCM_LATENCY_MONITOR_H_
     12 
     13 #include <bcm/latency_monitor.h>
     14 
     15 #define LATENCY_MONITOR_QUEUE_COUNT         12
     16 #define LATENCY_MONITOR_BUCKET_COUNT        8
     17 #define TIME_STEP_SET_COUNT                 10
     18 #define COUNTERS_PER_STEP_SET               (LATENCY_MONITOR_QUEUE_COUNT * LATENCY_MONITOR_BUCKET_COUNT)
     19 #define TIME_STEP_COUNTER_INCR              COUNTERS_PER_STEP_SET
     20 
     21 #define LATENCY_LIMIT_QUANTA                64  /* Minimum value fo the latency is 64 nSec */
     22 #define LATENCY_LIMIT_TABLE_SIZE            32
     23 #define LATENCY_HISTOGRAM_BUCKET_COUNT      8
     24 #define LATENCY_MONITOR_MAX_COUNT           4
     25 
     26 #define LATENCY_MONITOR_SW_BUF_WIDTH        8   /* Width of Software ring buffer in Bytes */
     27 
     28 #define LATENCY_MONITOR_STATE_IDLE          1
     29 #define LATENCY_MONITOR_STATE_RUNNING       2
     30 #define LATENCY_MONITOR_STATE_ERROR         3
     31 #define LATENCY_MONITOR_STATE_CLEANUP       4
     32 
     33 #define LATENCY_MONITOR_DEFAULT_FRAG_COUNT  2
     34 
     35 #define LATENCY_MONITOR_MIN_TIME_STEP       100000  /* 100 mSec */
     36 
     37 typedef struct  {
     38     uint8   pipe;
     39     uint32  *dbuf;
     40 } _sbusdma_desc_handle_data_t;
     41 
     42 typedef struct  _sbusdma_desc_handle_node_s{
     43    _sbusdma_desc_handle_data_t  *data;
     44    struct _sbusdma_desc_handle_node_s * next;
     45 }_sbusdma_desc_handle_node_t;
     46 
     47 typedef struct  {
     48    _sbusdma_desc_handle_node_t * head;
     49    _sbusdma_desc_handle_node_t * tail;
     50 }_sbusdma_desc_handle_list_t;
     51 
     52 typedef struct latency_monitor_data_s {
     53     volatile int    run[LATENCY_MONITOR_MAX_COUNT];
     54     int             mem_done[LATENCY_MONITOR_MAX_COUNT];
     55 
     56     int             big_endian;
     57     int             desc_mode;  /* Descriptor based SBUS DMA mode */
     58     int             dma_wr_en;  /* SBUS DMA write enable */
     59     int             dma_rd_en;  /* SBUS DMA read enable */
     60     int             num_mem;    /* Number of memories to be tested in parallel */
     61     int             init_done;
     62     sal_sem_t       sbusdma_run_lock;
     63     int             monitors_in_use_count; /* Counts the number of monitors in use */
     64 } latency_monitor_driver_data_t;
     65 
     66 typedef struct latency_monitor_cosq_info_s {
     67     uint8           bucket_count;
     68 }latency_monitor_cosq_info_t;
     69 
     70 typedef struct latency_monitor_mem_s {
     71     soc_mem_t       mem;
     72     int             init_done;
     73     int             copyno;
     74     int             index_min;
     75     int             index_max;
     76     int             count;
     77     int             frag_count;
     78     int             frag_index_max[LATENCY_MONITOR_DEFAULT_FRAG_COUNT];
     79     int             frag_index_min[LATENCY_MONITOR_DEFAULT_FRAG_COUNT];
     80     int             bufwords;
     81     int             entwords;
     82     sal_sem_t       latency_monitor_thread_trigger;
     83     sal_sem_t       dma_handle_counter_sem;
     84     sal_sem_t       dma_handle_queue_lock;
     85     _sbusdma_desc_handle_list_t handle_list;
     86     uint64          histogram_packet64_counter[COUNTERS_PER_STEP_SET];
     87     uint64          histogram_byte64_counter[COUNTERS_PER_STEP_SET];
     88     uint8           status;
     89     uint32          stat_counter_id;
     90     uint32          time_step;           /* In Micro sec (Min: 100mS) */
     91     uint32          wrap_around_time;    /* In Micro sec */
     92     bcm_latency_monitor_mode_t   monitor_mode;
     93     bcm_latency_monitor_cb  cb;
     94     void            *sw_buf_addr;
     95     uint32          sw_buf_size;
     96     uint32          sw_buf_wr_idx;
     97     int             flex_ctr_wrap_ctr;
     98     latency_monitor_cosq_info_t cosq_info[LATENCY_MONITOR_QUEUE_COUNT];
     99     uint32          dma_schedule_period;
    100     int             sbusdma_read_thread_pid;
    101     uint32          dest_pbmp_pipe_map;  /* Destination port bmp pipe map */
    102     uint32          pipe_map_temp;       /* Temporary pipe map */
    103 } latency_monitor_mem_t;
    104 
    105 typedef struct cb_data_s {
    106     uint32 *data;
    107     uint8   monitor_id;
    108     uint8   write_op;
    109     uint8   pipe_num;
    110 } cb_data_t;
    111 
    112 typedef enum latency_monitor_id_e {
    113     MONITOR_ID_0 = 0,
    114     MONITOR_ID_1,
    115     MONITOR_ID_2,
    116     MONITOR_ID_3
    117 } latency_monitor_id_t;
    118 
    119 #ifdef BCM_WARM_BOOT_SUPPORT
    120 int _bcm_th3_latency_monitor_sync(int unit);
    121 int _bcm_th3_latency_monitor_wb_post_init(int unit);
    122 #endif /* BCM_WARM_BOOT_SUPPORT */
    123 
    124 #endif  /* _BCM_LATENCY_MONITOR_H_ */