policer.c (5944B)
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: policer.c 8 * Purpose: Manages common POLICER functions 9 */ 10 11 #include <sal/core/libc.h> 12 13 #include <soc/drv.h> 14 #include <soc/debug.h> 15 16 #include <bcm/policer.h> 17 18 /* 19 * Function: 20 * bcm_policer_config_t_init 21 * Purpose: 22 * Initialize the policer config struct 23 * Parameters: 24 * pol_cfg - Pointer to the struct to be init'ed 25 */ 26 27 void 28 bcm_policer_config_t_init(bcm_policer_config_t *pol_cfg) 29 { 30 if (pol_cfg != NULL) { 31 sal_memset(pol_cfg, 0, sizeof(*pol_cfg)); 32 } 33 return; 34 } 35 36 /* 37 * Function: 38 * bcm_policer_group_mode_attr_selector_t_init 39 * Purpose: 40 * Initialize the policer group attribute selector structure 41 * Parameters: 42 * pol_group_mode_attr_selector - Pointer to the struct to be init'ed 43 */ 44 45 void 46 bcm_policer_group_mode_attr_selector_t_init(bcm_policer_group_mode_attr_selector_t 47 *pol_group_mode_attr_selector) 48 { 49 if (pol_group_mode_attr_selector != NULL) { 50 sal_memset(pol_group_mode_attr_selector, 0, 51 sizeof(*pol_group_mode_attr_selector)); 52 } 53 return; 54 } 55 56 /* 57 * Function: 58 * bcm_policer_map_t_init 59 * Purpose: 60 * Initialize the policer map struct 61 * Parameters: 62 * offset_map - Pointer to the struct to be init'ed 63 */ 64 void 65 bcm_policer_map_t_init(bcm_policer_map_t *offset_map) 66 { 67 if (offset_map != NULL) { 68 sal_memset(offset_map, 0, sizeof(*offset_map)); 69 } 70 return; 71 } 72 73 /* 74 * Function: 75 * bcm_policer_global_meter_config_t_init 76 * Purpose: 77 * Initialize the Global Meter Configuration structure 78 * Parameters: 79 * config - Pointer to the struct to be init'ed 80 */ 81 void 82 bcm_policer_global_meter_config_t_init(bcm_policer_global_meter_config_t *config) 83 { 84 if (config != NULL) { 85 sal_memset(config, 0, sizeof(*config)); 86 } 87 return; 88 } 89 90 /* 91 * Function: 92 * bcm_policer_primary_color_resolution_key_t_init 93 * Purpose: 94 * Initialize a policer_primary_color_resolution_key object struct. 95 * Parameters: 96 * policer_primary_color_resolution_key - pointer to object struct. 97 * Returns: 98 * NONE 99 */ 100 void bcm_policer_primary_color_resolution_key_t_init( 101 bcm_policer_primary_color_resolution_key_t *policer_primary_color_resolution_key) 102 { 103 if (policer_primary_color_resolution_key != NULL) { 104 sal_memset(policer_primary_color_resolution_key, 0, sizeof(*policer_primary_color_resolution_key)); 105 } 106 return; 107 } 108 109 /* 110 * Function: 111 * bcm_policer_primary_color_resolution_config_t_init 112 * Purpose: 113 * Initialize a policer_primary_color_resolution_config object struct. 114 * Parameters: 115 * policer_primary_color_resolution_config - pointer to object struct. 116 * Returns: 117 * NONE 118 */ 119 void bcm_policer_primary_color_resolution_config_t_init( 120 bcm_policer_primary_color_resolution_config_t *policer_primary_color_resolution_config) 121 { 122 if (policer_primary_color_resolution_config != NULL) { 123 sal_memset(policer_primary_color_resolution_config, 0, sizeof(*policer_primary_color_resolution_config)); 124 } 125 return; 126 } 127 128 /* 129 * Function: 130 * bcm_policer_engine_t_init 131 * Purpose: 132 * Initialize a policer_engine object struct. 133 * Parameters: 134 * policer_engine - pointer to object struct. 135 * Returns: 136 * NONE 137 */ 138 void bcm_policer_engine_t_init( 139 bcm_policer_engine_t *policer_engine) 140 { 141 if (policer_engine != NULL) { 142 sal_memset(policer_engine, 0, sizeof(*policer_engine)); 143 } 144 return; 145 } 146 147 /* 148 * Function: 149 * bcm_policer_database_attach_config_t_init 150 * Purpose: 151 * Initialize a policer_database_attach_config object struct. 152 * Parameters: 153 * policer_engine - pointer to object struct. 154 * Returns: 155 * NONE 156 */ 157 void bcm_policer_database_attach_config_t_init( 158 bcm_policer_database_attach_config_t *policer_database_attach_config) 159 { 160 if (policer_database_attach_config != NULL) { 161 sal_memset(policer_database_attach_config, 0, sizeof(*policer_database_attach_config)); 162 } 163 return; 164 } 165 166 /* 167 * Function: 168 * bcm_policer_database_config_t_init 169 * Purpose: 170 * Initialize a policer_database_config object struct. 171 * Parameters: 172 * policer_database_config - pointer to object struct. 173 * Returns: 174 * NONE 175 */ 176 void bcm_policer_database_config_t_init( 177 bcm_policer_database_config_t *policer_database_config) 178 { 179 if (policer_database_config != NULL) { 180 sal_memset(policer_database_config, 0, sizeof(*policer_database_config)); 181 } 182 return; 183 } 184 185 /* 186 * Function: 187 * bcm_policer_expansion_group_t_init 188 * Purpose: 189 * Initialize a policer_expansion_group object struct. 190 * Parameters: 191 * policer_expansion_group - pointer to object struct. 192 * Returns: 193 * NONE 194 */ 195 void bcm_policer_expansion_group_t_init( 196 bcm_policer_expansion_group_t *policer_expansion_group) 197 { 198 if (policer_expansion_group != NULL) { 199 sal_memset(policer_expansion_group, 0, sizeof(*policer_expansion_group)); 200 } 201 return; 202 } 203 204 /* 205 * Function: 206 * bcm_policer_color_resolution_t_init 207 * Purpose: 208 * Initialize a bcm_policer_color_resolution_t struct. 209 * Parameters: 210 * policer_color_resolution - pointer to object struct. 211 * Returns: 212 * NONE 213 */ 214 void bcm_policer_color_resolution_t_init( 215 bcm_policer_color_resolution_t *policer_color_resolution) 216 { 217 if (policer_color_resolution != NULL) { 218 sal_memset(policer_color_resolution, 0, sizeof(*policer_color_resolution)); 219 } 220 return; 221 } 222 223 /* 224 * Function: 225 * bcm_policer_group_info_t_init 226 * Purpose: 227 * Initialize a bcm_policer_group_info_t struct. 228 * Parameters: 229 * policer_group_info - pointer to object struct. 230 * Returns: 231 * NONE 232 */ 233 void bcm_policer_group_info_t_init( 234 bcm_policer_group_info_t *policer_group_info) 235 { 236 if (policer_group_info != NULL) { 237 sal_memset(policer_group_info, 0, sizeof(*policer_group_info)); 238 } 239 return; 240 }