latency_monitor.h (4554B)
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: 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 sal_sem_t latency_monitor_counter_sem; 86 _sbusdma_desc_handle_list_t handle_list; 87 uint64 histogram_packet64_counter[COUNTERS_PER_STEP_SET]; 88 uint64 histogram_byte64_counter[COUNTERS_PER_STEP_SET]; 89 uint8 status; 90 uint32 stat_counter_id; 91 uint32 time_step; /* In Micro sec (Min: 100mS) */ 92 uint32 wrap_around_time; /* In Micro sec */ 93 bcm_latency_monitor_mode_t monitor_mode; 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 bcm_latency_monitor_callback_fn cb_fn; /* User callback handler */ 104 void *user_data; /* User data */ 105 } latency_monitor_mem_t; 106 107 typedef struct cb_data_s { 108 uint32 *data; 109 uint8 monitor_id; 110 uint8 write_op; 111 uint8 pipe_num; 112 } cb_data_t; 113 114 typedef enum latency_monitor_id_e { 115 MONITOR_ID_0 = 0, 116 MONITOR_ID_1, 117 MONITOR_ID_2, 118 MONITOR_ID_3 119 } latency_monitor_id_t; 120 121 #ifdef BCM_WARM_BOOT_SUPPORT 122 int _bcm_th3_latency_monitor_sync(int unit); 123 int _bcm_th3_latency_monitor_wb_post_init(int unit); 124 #endif /* BCM_WARM_BOOT_SUPPORT */ 125 126 #endif /* _BCM_LATENCY_MONITOR_H_ */