algo_oamp.h (12951B)
1 /** 2 * \file algo_oamp.h Internal DNX OAMP Template Management 3 ent This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 ent 5 ent Copyright 2007-2020 Broadcom Inc. All rights reserved. 6 */ 7 8 #ifndef ALGO_OAMP_H_INCLUDED 9 /* 10 * { 11 */ 12 #define ALGO_OAMP_H_INCLUDED 13 14 #include <shared/shrextend/shrextend_debug.h> 15 #include <bcm/oam.h> 16 17 #ifndef BCM_DNX_SUPPORT 18 #error "This file is for use by DNX (JR2) family only!" 19 #endif 20 21 #include <bcm_int/dnx/algo/template_mngr/template_manager_types.h> 22 23 /** 24 * Resource name defines for algo oamp 25 * \see 26 * dnx_oam_init_templates 27 * { 28 */ 29 30 #define DNX_ALGO_OAMP_2B_MAID_FULL_MEP_ID "OAMP_2B_MAID_FULL_MEP_ID" 31 #define DNX_ALGO_OAMP_2B_MAID_SHORT_MEP_ID "OAMP_2B_MAID_SHORT_MEP_ID" 32 #define DNX_ALGO_OAMP_ICC_MAID_FULL_MEP_ID "OAMP_ICC_MAID_FULL_MEP_ID" 33 #define DNX_ALGO_OAMP_ICC_MAID_SHORT_MEP_ID "OAMP_ICC_MAID_SHORT_MEP_ID" 34 #define DNX_ALGO_OAMP_EXTRA_MEP_ID "OAMP_EXTRA_MEP_ID" 35 #define DNX_ALGO_OAMP_FULL_TUPLES_MEP_ID "OAMP_FULL_TUPLES_MEP_ID" 36 /* 37 * Callback defines for the sw state resource manager. 38 */ 39 #define SW_STATE_ALGO_OAMP_2B_MAID_FULL_MEP_ID algo_oamp_db.oamp_2b_maid_full_mep_id 40 #define SW_STATE_ALGO_OAMP_2B_MAID_SHORT_MEP_ID algo_oamp_db.oamp_2b_maid_short_mep_id 41 #define SW_STATE_ALGO_OAMP_ICC_MAID_FULL_MEP_ID algo_oamp_db.oamp_icc_maid_full_mep_id 42 #define SW_STATE_ALGO_OAMP_ICC_MAID_SHORT_MEP_ID algo_oamp_db.oamp_icc_maid_short_mep_id 43 #define SW_STATE_ALGO_OAMP_EXTRA_MEP_ID algo_oamp_db.oamp_extra_mep_id 44 #define SW_STATE_ALGO_OAMP_FULL_TUPLES_MEP_ID algo_oamp_db.oamp_full_tuples_mep_id 45 46 #define DNX_ALGO_OAMP_PP_PORT_2_SYS_PORT_TEMPLATE "OAMP_PP_PORT_2_SYS_PORT" 47 #define DNX_ALGO_OAMP_PUNT_GOOD_PROFILE_TEMPLATE "OAMP_PUNT_GOOD_PROFILE" 48 49 #define DNX_ALGO_OAMP_MEP_DB_ENTRY "OAMP_MEP_DB_ENTRY" 50 51 /** Pool name where mep_id is located according group name type and entry type */ 52 #define DNX_OAMP_MEP_ID_RESOURCE_NAME(is_2byte_maid, is_full, is_extra_pool) ( \ 53 (is_extra_pool) ? DNX_ALGO_OAMP_EXTRA_MEP_ID : \ 54 ((is_2byte_maid && is_full) ? DNX_ALGO_OAMP_2B_MAID_FULL_MEP_ID : \ 55 (((is_2byte_maid && !is_full) ? DNX_ALGO_OAMP_2B_MAID_SHORT_MEP_ID : \ 56 (((!is_2byte_maid && is_full) ? DNX_ALGO_OAMP_ICC_MAID_FULL_MEP_ID : \ 57 DNX_ALGO_OAMP_ICC_MAID_SHORT_MEP_ID)))))) 58 59 /** Resource callback where mep_id is located according group name type and entry type */ 60 #define DNX_OAMP_MEP_ID_RESOURCE(is_2byte_maid, is_full, is_extra_pool, exec) ( \ 61 (is_extra_pool) ? SW_STATE_ALGO_OAMP_EXTRA_MEP_ID.exec : \ 62 ((is_2byte_maid && is_full) ? SW_STATE_ALGO_OAMP_2B_MAID_FULL_MEP_ID.exec : \ 63 (((is_2byte_maid && !is_full) ? SW_STATE_ALGO_OAMP_2B_MAID_SHORT_MEP_ID.exec : \ 64 (((!is_2byte_maid && is_full) ? SW_STATE_ALGO_OAMP_ICC_MAID_FULL_MEP_ID.exec : \ 65 SW_STATE_ALGO_OAMP_ICC_MAID_SHORT_MEP_ID.exec)))))) 66 67 /** Number of sub entries that couldn't be used for endpoint in ICC MAID group in one MEP_DB entry */ 68 #define DNX_OAM_NUM_OF_SHORT_ENTRIES_IN_MEP_DB_LINE 3 69 70 /** Steps of entry for jumbo TLV */ 71 #define JUMBO_TLV_ENTRIES_STEPS 16 72 73 /** Structure used for MEP_DB memory type parameters */ 74 typedef struct 75 { 76 /** 77 * Relevant for OAM only. 78 * Type of mep_id used for 2byte maid or icc maid group. 79 * MEP_ID for ICC MAID group should be multiple of 4. 80 */ 81 uint8 is_2byte_maid; 82 83 /** 84 * Type of MEP ID: 85 * Short('0') - MEP ID resides below the threshold and allocate 1/4 MEP ID entry 86 * Full('1') - MEP ID resides above the threshold and allocate full MEP ID entry 87 */ 88 uint8 is_full; 89 90 /** 91 * MEP_ID Location: if it extra_pool it mean that MEP ID located in in banks 9-12. 92 */ 93 uint8 is_extra_pool; 94 95 } dnx_oamp_mep_db_memory_type_t; 96 97 /** 98 * \brief - This function calculate the largest index that could be allocated in short entries bank according: 99 * Device frequency, number of banks, number of entries etc... 100 * Generally each entry in MEP DB takes 40 cycles for scan machine, but some of them 101 * could have extra data and this case it takes additional 40 cycles. 102 * Scan machine doesn't have enough time to scan short entries bank in 3.3ms. 103 * 104 * \param [in] unit - Number of hardware unit used. 105 * \param [in] highest_index -highest index that could be allocated in short bank 106 * 107 * \return 108 * void 109 * 110 * \remark 111 * * None 112 * 113 * \see 114 */ 115 void dnx_oam_mep_db_highest_index_get( 116 int unit, 117 uint32 *highest_index); 118 /** 119 * \brief - Function map mep_id to pool and index inside pool. 120 * 121 * \param [in] unit - Number of hardware unit used. 122 * \param [in] mep_id - mep id 123 * \param [out] memory_type - map id memory type 124 * \param [out] index - index of mep id inside pool 125 * \return 126 * shr_error_e 127 * 128 * \remark 129 * * None 130 * 131 * \see 132 * dnx_oam_mep_id_alloc 133 * dnx_oam_mep_id_dealloc 134 * dnx_oamp_mep_db_memory_type_t 135 */ 136 void dnx_mep_id_to_pool_type_and_index( 137 int unit, 138 uint32 mep_id, 139 dnx_oamp_mep_db_memory_type_t * memory_type, 140 int *index); 141 142 /** 143 * \brief - Printing callback for the PP Port profile template, 144 * which is used for mapping local port(pp port) to system port. 145 * 146 * \param [in] unit - Number of hardware unit used. 147 * \param [in] data - Pointer to template profile data. 148 * 149 * \return 150 * 151 * \remark 152 * * A print callback function is required to create a 153 * template. It is later used for BCM shell diagnostics. 154 * \see 155 * * None 156 */ 157 void dnx_oamp_pp_port_profile_print_cb( 158 int unit, 159 const void *data); 160 161 /** 162 * \brief - This function allocate mep id. 163 * 164 * \param [in] unit - Number of hardware unit used. 165 * \param [in] flags - DNX_ALGO_RES_ALLOCATE_WITH_ID flag in use. Allocate specific mep id. 166 * \param [in] mep_id_memory_type - requested memory type 167 * \param [out] mep_id - MEP ID 168 * 169 * \return 170 * shr_error_e 171 * 172 * \remark 173 * * None 174 * 175 * \see 176 * dnx_* 177 */ 178 shr_error_e dnx_algo_oamp_mep_id_alloc( 179 int unit, 180 uint32 flags, 181 dnx_oamp_mep_db_memory_type_t * mep_id_memory_type, 182 uint32 *mep_id); 183 184 /** 185 * \brief -This function checks if mep id is allocated 186 * 187 * \param [in] unit - Number of hardware unit used. 188 * \param [in] mep_id - mep id that is checked. 189 * \param [out] is_alloc - is allocated or not. 190 * 191 * \return 192 * shr_error_e 193 * 194 * \remark 195 * * None 196 * 197 * \see 198 * dnx_* 199 */ 200 shr_error_e dnx_algo_oamp_mep_id_is_allocated( 201 int unit, 202 uint32 mep_id, 203 uint8 *is_alloc); 204 205 /** 206 * \brief -This function release mep id from pool. 207 * 208 * \param [in] unit - Number of hardware unit used. 209 * \param [in] mep_id - mep id that should be free 210 * 211 * \return 212 * shr_error_e 213 * 214 * \remark 215 * * None 216 * 217 * \see 218 * dnx_* 219 */ 220 shr_error_e dnx_algo_oamp_mep_id_dealloc( 221 int unit, 222 uint32 mep_id); 223 224 /** 225 * \brief - initialize templates for all oamp profile types. 226 * 227 * \param [in] unit - Number of hardware unit used. 228 * 229 * \return 230 * shr_error_e 231 * 232 * \remark 233 * * None 234 * \see 235 * * None 236 */ 237 shr_error_e dnx_algo_oamp_init( 238 int unit); 239 240 /** 241 * \brief - Utility function for Remote MEP creation 242 * This function deletes the new RMEP ID 243 * 244 * \param [in] unit - Number of hardware unit used. 245 * \param [in] rmep_id - ID of the remote endpoint. 246 * 247 * \return 248 * shr_error_e 249 * 250 * \see 251 * * None 252 */ 253 shr_error_e dnx_oam_remote_endpoint_id_free( 254 int unit, 255 bcm_oam_endpoint_t rmep_id); 256 257 /** 258 * \brief - Utility function for Remote MEP creation 259 * This function allocates the new RMEP ID 260 * and handles WITH_ID case as well. 261 * 262 * \param [in] unit - Number of hardware unit used. 263 * \param [in] alloc_flags - flags variable to be used 264 * for resource allocation 265 * \param [in,out] rmep_id - Resulting ID. If ID is 266 * specified, this is an output argument. 267 * Otherwise, it's an input argument. 268 * 269 * \return 270 * shr_error_e 271 * 272 * \see 273 * * None 274 */ 275 shr_error_e dnx_oam_remote_endpoint_id_alloc( 276 int unit, 277 int alloc_flags, 278 bcm_oam_endpoint_t * rmep_id); 279 280 /** 281 * \brief - Printing callback for the OAM/BFD TC/DP profile 282 * templates. The TC/DP profiles are used to construct 283 * the ITMH header for packets transmitted from OAM/BFD 284 * endpoints. 285 * 286 * \param [in] unit - Number of hardware unit used. 287 * \param [in] data - Pointer to template profile data. The 288 * OAM/BFD TC/DP profile structure dnx_oam_tc_dp_t is 289 * defined and described above. 290 * \return 291 * \remark 292 * * A print callback function is required to create a 293 * template. It is later used for BCM shell diagnostics. 294 * \see 295 * * None 296 */ 297 void dnx_oam_itmh_priority_profile_print_cb( 298 int unit, 299 const void *data); 300 301 /** 302 * \brief - Printing callback for the OAM/BFD MPLS/PWE push 303 * profile templates. The push profiles are used to 304 * construct the packets transmitted from MPLS/PWE 305 * OAM/BFD endpoints. 306 * 307 * \param [in] unit - Number of hardware unit used. 308 * \param [in] data - Pointer to template profile data. The 309 * OAM/BFD MPLS/PWE PUSH profile structure 310 * dnx_oam_push_profile_t is defined and described above. 311 * \return 312 * \remark 313 * * A print callback function is required to create a 314 * template. It is later used for BCM shell diagnostics. 315 * \see 316 * * None 317 */ 318 void dnx_oam_mpls_pwe_exp_ttl_profile_print_cb( 319 int unit, 320 const void *data); 321 322 /** 323 * \brief - Callback function for printing OAM punt profile template data 324 * 325 * \param [in] unit - Number of hardware unit used. 326 * \param [in] data - Punt profile template data to be printed. 327 * \return 328 * shr_error_e 329 * 330 * \remark 331 * * None 332 * \see 333 * * None 334 */ 335 void dnx_oam_punt_profile_print_cb( 336 int unit, 337 const void *data); 338 339 /** 340 * \brief - Callback function for printing OAM punt good profile 341 * template data. 342 * 343 * \param [in] unit - Number of hardware unit used. 344 * \param [in] data - Punt profile template data to be printed. 345 * 346 * \return 347 * 348 * \remark 349 * * A print callback function is required to create a 350 * template. It is later used for BCM shell diagnostics. 351 * \see 352 * * None 353 */ 354 void dnx_oamp_punt_good_profile_print_cb( 355 int unit, 356 const void *data); 357 358 /** 359 * \brief - Utility function for reserving IDs for 360 * OAMP_MEP_DB entries. This is used 361 * automatically by dbal and should not 362 * be used otherwise. 363 * 364 * \param [in] unit - Number of hardware unit used. 365 * \param [in] oamp_entry_index - Index to be used 366 * for resource allocation. 367 */ 368 shr_error_e dnx_algo_oamp_mep_entry_alloc( 369 int unit, 370 int *oamp_entry_index); 371 372 /** 373 * \brief - Utility function for freeing IDs for 374 * OAMP_MEP_DB entries. This is used 375 * automatically by dbal and should not 376 * be used otherwise. 377 * 378 * \param [in] unit - Number of hardware unit used. 379 * \param [in] oamp_entry_index - Index of resource 380 * to be freed. 381 */ 382 shr_error_e dnx_algo_oamp_mep_entry_dealloc( 383 int unit, 384 int oamp_entry_index); 385 386 /** 387 * \brief - Callback function for printing OAM MEP profile template data 388 * 389 * \param [in] unit - Number of hardware unit used. 390 * \param [in] data - MEP profile template data to be printed. 391 * \return 392 * shr_error_e 393 * 394 * \remark 395 * * None 396 * \see 397 * * None 398 */ 399 void dnx_algo_oam_oamp_mep_profile_print_cb( 400 int unit, 401 const void *data); 402 403 /** 404 * \brief - This function finds the next allocated short 405 * entry with sub-index 0 406 * 407 * \param [in] unit - Number of hardware unit used. 408 * \param [in,out] icc_id_in_out - MEP ID. As input, this is 409 * the starting point of the search. As output, this is 410 * the result. 411 * \param [out] entry_found - TRUE if search successful, FALSE 412 * otherwise 413 * \return 414 * shr_error_e 415 * 416 * \remark 417 * * None 418 * \see 419 * * None 420 */ 421 shr_error_e dnx_oam_oamp_get_next_icc_entry( 422 int unit, 423 uint32 *icc_id_in_out, 424 uint8 *entry_found); 425 426 /** 427 * \brief - This function finds the next free short 428 * entry with sub-index 0 429 * 430 * \param [in] unit - Number of hardware unit used. 431 * \param [out] icc_id_out - resulting MEP ID. 432 * \param [out] entry_not_found - FALSE if search successful, TRUE 433 * otherwise 434 * \return 435 * shr_error_e 436 * 437 * \remark 438 * * None 439 * \see 440 * * None 441 */ 442 shr_error_e dnx_algo_oamp_mep_id_get_free_icc_id( 443 int unit, 444 uint32 *icc_id_out, 445 uint8 *entry_not_found); 446 /* 447 * } 448 */ 449 #endif /* ALGO_OAMP_H_INCLUDED */