lif_lib.h (13977B)
1 /* 2 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 3 * 4 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 5 */ 6 7 /** \file lif_lib.h 8 * 9 * 10 * This file contains the APIs required to perform general lif HW writes, as well as lif allocation. 11 */ 12 13 #ifndef INCLUDE_LIF_LIB_H 14 #define INCLUDE_LIF_LIB_H 15 16 /************* 17 * INCLUDES * 18 */ 19 /* 20 * { 21 */ 22 23 #include <bcm_int/dnx/algo/lif_mngr/lif_mngr_api.h> 24 25 /* 26 * } 27 */ 28 /************* 29 * DEFINES * 30 */ 31 /* 32 * { 33 */ 34 /** 35 * \brief 36 * Do not replace the value of current filed in GLEM (can be used for either outlif or lif profile field 37 * \see 38 * dnx_lif_lib_replace_glem 39 */ 40 #define LIF_LIB_GLEM_KEEP_OLD_VALUE 0xFFFFFFFF 41 /* 42 * } 43 */ 44 /************* 45 * MACROS * 46 */ 47 /* 48 * { 49 */ 50 /** 51 * \brief 52 * If LIF_LIB_GLEM_ACCESS_IS_OPTIONAL is non-zero then the code accepts failure to 53 * read an entry from GLEM provided it is 'not found'. 54 * This is mainly for 'remove', in which case, this passes silently. 55 * For 'read', it is up to the caller to decide. 56 * Most probably this flag and option will be removed on the final version. 57 */ 58 #define LIF_LIB_GLEM_ACCESS_IS_OPTIONAL 1 59 /* 60 * } 61 */ 62 /************* 63 * TYPE DEFS * 64 */ 65 /* 66 * { 67 */ 68 69 /* 70 * } 71 */ 72 /************* 73 * GLOBALS * 74 */ 75 /* 76 * { 77 */ 78 79 /* 80 * } 81 */ 82 /************* 83 * FUNCTIONS * 84 */ 85 /* 86 * { 87 */ 88 89 /** 90 * \brief 91 * Allocate local inlif and save its dbal table and result in sw state. 92 * 93 * \param [in] unit - 94 * Identifier of the device to access. 95 * \param [in,out] inlif_info - 96 * Pointer to memory for local inlif allocation input/output. \n 97 * \b As \b input - \n 98 * All elements in inlif info are required as input, except for local_inlif which will be ignored. 99 * In the case of duplicated per core lif table, the field 'core_id' will specify which core is used 100 * for allocation, or it can be set to _SHR_CORE_ALL to allocate one lif per core. 101 * See \ref lif_mngr_local_inlif_info_t for detailed description of each field. 102 * \b As \b output - \n 103 * This procedure loads the field inlif_info->local_inlifs with the local in lifs allocated, in the manner 104 * detailed in the struct's description. 105 * 106 * \return 107 * \retval Zero if no error was detected 108 * \retval Negative if error was detected. See \ref shr_error_e 109 * \remark 110 * None. 111 */ 112 shr_error_e dnx_lif_lib_inlif_allocate( 113 int unit, 114 lif_mngr_local_inlif_info_t * inlif_info); 115 116 /** 117 * \brief 118 * Deallocate the given local inlif. 119 * 120 * \param [in] unit - 121 * Identifier of the device to access. 122 * \param [in] inlif_info - 123 * Pointer to memory for local inlif deallocation. \n 124 * \b As \b input - \n 125 * The local inlif[s] in the local_inlifs array will be freed. \n 126 * All elements in inlif info are required as input, except for dbal_result_type, which should be 0. 127 * See \ref lif_mngr_local_inlif_info_t for detailed description of each field. 128 * 129 * \return 130 * \retval Zero if no error was detected 131 * \retval Negative if error was detected. See \ref shr_error_e 132 * \remark 133 * None. 134 */ 135 shr_error_e dnx_lif_lib_inlif_free( 136 int unit, 137 lif_mngr_local_inlif_info_t * inlif_info); 138 139 /** 140 * \brief 141 * Allocate local outlif, save its dbal table and result in sw state and configure HW. 142 * 143 * This API performs several functions: 144 * 1. Allocate local outlif and save its dbal table+result. 145 * 2. Sometimes, configured the HW to map this lif to its logical phase and match it with Linked list entry. 146 * 3. Link list on entry can be forced (with or without) using DNX_ALGO_LIF_MNGR_LOCAL_OUTLIF_FORCE_LINKED_LIST, 147 * DNX_ALGO_LIF_MNGR_LOCAL_OUTLIF_NO_LINKED_LIST (see documentation) 148 * 149 * \param [in] unit - 150 * Identifier of the device to access. 151 * \param [in,out] outlif_info - 152 * Pointer to memory for local outlif allocation input/output. \n 153 * \b As \b input - \n 154 * All elements in outlif info are inputs, except for local_outlif. 155 * \b As \b output - \n 156 * This procedure loads the field outlif_info->local_outlif with the local out lif allocated. 157 * 158 * \return 159 * \retval Zero if no error was detected 160 * \retval Negative if error was detected. See \ref shr_error_e 161 * \remark 162 * None. 163 */ 164 shr_error_e dnx_lif_lib_outlif_allocate( 165 int unit, 166 lif_mngr_local_outlif_info_t * outlif_info); 167 168 /** 169 * \brief 170 * Deallocate the given local outlif. 171 * 172 * All the steps described in lif_lib_allocate_outlif will be reverted. 173 * 174 * \param [in] unit - 175 * Identifier of the device to access. 176 * \param [in] local_outlif - 177 * Local outlif to be freed. 178 * 179 * \return 180 * \retval Zero if no error was detected 181 * \retval Negative if error was detected. See \ref shr_error_e 182 * \remark 183 * None. 184 */ 185 shr_error_e dnx_lif_lib_outlif_free( 186 int unit, 187 int local_outlif); 188 189 /* 190 * } 191 */ 192 193 /************* 194 * FUNCTIONS * 195 */ 196 /* 197 * { 198 */ 199 200 /** 201 * \brief 202 * Allocate global lif and local lif, create mapping between them, and configure HW. 203 * 204 * This API performs several functions: 205 * 1. Allocate local and global lifs (ingress and egress, as required). 206 * 2. Keep mapping of global to local lifs and vice versa in the sw state. 207 * 3. Keep LIF TABLE DBAL ID and type in SW state. 208 * 4. If outlif was allocated, then the HW will be configured to map this lif 209 * to its logical phase and match it with Linked list entry. 210 * 211 * \param [in] unit - 212 * Identifier of the device to access. 213 * \param [in] flags - 214 * Currently supported flag is \ref LIF_MNGR_GLOBAL_LIF_WITH_ID \n 215 * to allocate the global lif with the ID given in global lif argument. 216 * \param [in,out] global_lif - 217 * Int pointer to memory to write output into. \n 218 * For \ref LIF_MNGR_GLOBAL_LIF_WITH_ID, this may also be indirect input. 219 * \b As \b output - \n 220 * This procedure loads pointed memory with the global lif allocated. \n 221 * Not used as output when \ref DNX_ALGO_RES_ALLOCATE_WITH_ID is used. 222 * \b As \b input - \n 223 * If flag LIF_MNGR_GLOBAL_LIF_WITH_ID is set, this holds 224 * the id to be allocated. 225 * \param [in,out] inlif_info - 226 * Pointer to memory for local inlif allocation input/output. \n 227 * If NULL, then this will be ignored, local inlifs will not be allocated, 228 * and outlif_info must not be NULL. 229 * \b As \b input - \n 230 * All elements in inlif info are required as input, except for local_inlifs which will be ignored. 231 * In the case of duplicated per core lif table, the field 'core_id' will specify which core is used 232 * for allocation, or it can be set to _SHR_CORE_ALL to allocate one lif per core. 233 * See \ref lif_mngr_local_inlif_info_t for detailed description of each field. 234 * \b As \b output - \n 235 * This procedure loads the field inlif_info->local_inlifs with the local in lifs allocated, in the manner 236 * detailed in the struct's description. 237 * \param [in,out] outlif_info - 238 * Pointer to memory for local outlif allocation input/output. \n 239 * If NULL, then this will be ignored, local outlif will not be allocated, 240 * and inlif_info must not be NULL. 241 * \b As \b input - \n 242 * All elements in outlif info are inputs, except for local_outlif. 243 * \b As \b output - \n 244 * This procedure loads the field outlif_info->local_outlif with the local out lif allocated. 245 * 246 * \return 247 * \retval Zero if no error was detected 248 * \retval Negative if error was detected. See \ref shr_error_e 249 * \remark 250 * None. 251 */ 252 shr_error_e dnx_lif_lib_allocate( 253 int unit, 254 uint32 flags, 255 int *global_lif, 256 lif_mngr_local_inlif_info_t * inlif_info, 257 lif_mngr_local_outlif_info_t * outlif_info); 258 259 /** 260 * \brief 261 * Deallocate the given global lif and its local in/outlif. 262 * 263 * All the steps described in lif_lib_allocate will be reverted. 264 * 265 * \param [in] unit - 266 * Identifier of the device to access. 267 * \param [in] global_lif - 268 * Global lif to be deallocated. 269 * \param [in] inlif_info - 270 * Pointer to memory for local inlif deallocation. \n 271 * If NULL, then this will be ignored, local inlif will not be freed, 272 * and local_outlif must not be LIF_MNGR_INVALID. 273 * \b As \b input - \n 274 * The local inlif[s] in the local_inlifs array will be freed. \n 275 * All elements in inlif info are required as input, except for dbal_result_type, which should be 0. 276 * See \ref lif_mngr_local_inlif_info_t for detailed description of each field. 277 * \param [in] local_outlif - 278 * Local outlif to be deallocated, or LIF_MNGR_INVALID to deallocate ingress only. 279 * 280 * \return 281 * \retval Zero if no error was detected 282 * \retval Negative if error was detected. See \ref shr_error_e 283 * \remark 284 * None. 285 */ 286 shr_error_e dnx_lif_lib_free( 287 int unit, 288 int global_lif, 289 lif_mngr_local_inlif_info_t * inlif_info, 290 int local_outlif); 291 292 /** 293 * \brief 294 * Given core and egress global and local lifs, adds mapping from the global lif to the local lif in the GLEM table. 295 * 296 * This function should be called after calling dnx_lif_mngr_lif_allocate, and use the allocated global and local lifs 297 * for the mapping. 298 * 299 * \par DIRECT INPUT 300 * \param [in] unit - 301 * Identifier of the device to access. 302 * \param [in] core_id - 303 * Relevant core. Can be either a single core, or _BCM_CORE_ALL if both cores are used. 304 * \param [in] global_lif - 305 * Global lif to be written as key. 306 * \param [in] local_lif - 307 * Local lif to be written as result. 308 * \par INDIRECT INPUT 309 * None 310 * \par DIRECT OUTPUT 311 * \retval Zero if no error was detected 312 * \retval _SHR_E_PARAM if one of the arguments is illegal, \ref dbal_entry_commit errors if dbal failed. 313 * See \ref shr_error_e 314 * \remark 315 * None. 316 * \see 317 * dnx_lif_mngr_lif_allocate 318 */ 319 shr_error_e dnx_lif_lib_add_to_glem( 320 int unit, 321 int core_id, 322 uint32 global_lif, 323 uint32 local_lif); 324 325 /** 326 * \brief 327 * Same as dnx_lif_lib_add_to_glem but for existing glem entries 328 * 329 * \par DIRECT INPUT 330 * \param [in] unit - 331 * Identifier of the device to access. 332 * \param [in] core_id - 333 * Relevant core. Can be either a single core, or _BCM_CORE_ALL if both cores are used. 334 * \param [in] global_lif - 335 * Global lif to be written as key. 336 * \param [in] local_lif - 337 * Local lif to be written as result, LIF_LIB_GLEM_KEEP_OLD_VALUE if to be kept. 338 * \param [in] outlif_profile - 339 * Outlif profile lif to be written as result, LIF_LIB_GLEM_KEEP_OLD_VALUE if to be kept. 340 * \par INDIRECT INPUT 341 * None 342 * \par DIRECT OUTPUT 343 * \retval Zero if no error was detected 344 * \retval _SHR_E_PARAM if one of the arguments is illegal, \ref dbal_entry_commit errors if dbal failed. 345 * See \ref shr_error_e 346 * \remark 347 * None. 348 * \see 349 * dnx_lif_lib_add_to_glem 350 */ 351 shr_error_e dnx_lif_lib_replace_glem( 352 int unit, 353 int core_id, 354 uint32 global_lif, 355 uint32 local_lif, 356 uint32 outlif_profile); 357 358 /** 359 * \brief 360 * Given egress global lif and core, returns the local lif mapped to this global lif and the lif profile. 361 * 362 * \par DIRECT INPUT 363 * \param [in] unit - 364 * Identifier of the device to access. 365 * \param [in] core_id - 366 * Relevant core. Must be explicit core, because CORE_ALL would be meaningless. 367 * \param [in] global_lif - 368 * Global lif key. 369 * \param [out] local_lif_p - 370 * Pointer to uint32. 371 * This procedure loads the pointer with the local lif mapped from this core_id X global lif combination, 372 * in case global lif is not a rif. 373 * \param [out] outlif_profile_p - 374 * Pointer to uint32. 375 * This procedure loads the pointer with the ERPP outlif profile mapped from this core_id X global lif combination. 376 * \par INDIRECT INPUT 377 * None 378 * \par DIRECT OUTPUT 379 * \retval Zero if no error was detected 380 * \retval _SHR_E_PARAM if one of the arguments is illegal, \ref dbal_entry_get errors if dbal failed. 381 * See \ref shr_error_e 382 * \remark 383 * None. 384 */ 385 shr_error_e dnx_lif_lib_read_from_glem( 386 int unit, 387 int core_id, 388 uint32 global_lif, 389 uint32 *local_lif_p, 390 uint32 *outlif_profile_p); 391 392 /** 393 * \brief 394 * Given egress global lif and core, removes the mapping for this global lif from the GLEM table. 395 * 396 * This function should be called after calling dnx_lif_mngr_lif_free, and use the allocated global and local lifs 397 * for the mapping. 398 * 399 * \par DIRECT INPUT 400 * \param [in] unit - 401 * Identifier of the device to access. 402 * \param [in] core_id - 403 * Relevant core. Can be either a single core, or _BCM_CORE_ALL if both cores are used. 404 * \param [in] global_lif - 405 * Global lif key to remove. 406 * \par INDIRECT INPUT 407 * None 408 * \par DIRECT OUTPUT 409 * \retval Zero if no error was detected 410 * \retval _SHR_E_PARAM if one of the arguments is illegal, \ref dbal_entry_clear errors if dbal failed. 411 * See \ref shr_error_e 412 * \remark 413 * None. 414 * \see 415 * dnx_lif_mngr_lif_free 416 */ 417 shr_error_e dnx_lif_lib_remove_from_glem( 418 int unit, 419 int core_id, 420 uint32 global_lif); 421 422 /** 423 * \brief 424 * Initialize lif lib module. 425 * Submodules initialized in this function: 426 * - Outlif logical to physical mapping. 427 * - Outrif mapping in EEDB. 428 * 429 * \param [in] unit - Unit-ID 430 * 431 * \return 432 * shr_error_e 433 */ 434 shr_error_e dnx_lif_lib_init( 435 int unit); 436 437 /** 438 * \brief 439 * close lif logger verbosity 440 * 441 * \param [in] unit - Unit-ID 442 * \param [out] orig_severity - original severity 443 * 444 * \return 445 * shr_error_e 446 */ 447 shr_error_e dnx_lif_lib_logger_close( 448 int unit, 449 bsl_severity_t * orig_severity); 450 451 /** 452 * \brief 453 * restore lif logger verbosity 454 * 455 * \param [in] unit - Unit-ID 456 * \param [out] orig_severity - original severity - to be re-set 457 * 458 * \return 459 * shr_error_e 460 */ 461 shr_error_e dnx_lif_lib_logger_restore( 462 int unit, 463 bsl_severity_t orig_severity); 464 /* 465 * } 466 */ 467 468 #endif /* INCLUDE_LIF_LIB_H */