algo_gpm.h (27851B)
1 /** \file algo_gpm.h 2 * 3 * 4 * Internal DNX Gport Managment APIs 5 * 6 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 7 * 8 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 9 */ 10 11 #ifndef ALGO_GPM_H_INCLUDED 12 /* 13 * { 14 */ 15 #define ALGO_GPM_H_INCLUDED 16 17 #ifndef BCM_DNX_SUPPORT 18 #error "This file is for use by DNX (JR2) family only!" 19 #endif 20 21 /* 22 * Includes. 23 * { 24 */ 25 #include <bcm/types.h> 26 #include <soc/dnx/dbal/auto_generated/dbal_defines_tables.h> 27 #include <soc/dnx/dnx_data/auto_generated/dnx_data_max_device.h> 28 #include <bcm_int/dnx/algo/lif_mngr/lif_mngr_api.h> 29 #include <bcm_int/dnx/algo/l3/algo_l3_egr_pointed.h> 30 31 /* 32 * } 33 */ 34 35 /** 36 * Invalid LIF indication (both ingress, egress, global and 37 * local) 38 */ 39 #define DNX_ALGO_GPM_LIF_INVALID (-1) 40 /** 41 * Invalid FEC indication 42 */ 43 #define DNX_ALGO_GPM_FEC_INVALID (-1) 44 45 /** 46 * \addtogroup Flags DNX_ALGO_GPM_GPORT_INFO_F_XXX 47 * Flags for dnx_algo_gpm_gport_phy_info_t struct 48 * 49 * @{ 50 */ 51 /* 52 * { 53 */ 54 /** 55 * Gport is Local Port 56 */ 57 #define DNX_ALGO_GPM_GPORT_INFO_F_IS_LOCAL_PORT SAL_BIT(0) 58 /** 59 * Gport is LAG 60 */ 61 #define DNX_ALGO_GPM_GPORT_INFO_F_IS_LAG SAL_BIT(1) 62 /** 63 * Gport is system side 64 */ 65 #define DNX_ALGO_GPM_GPORT_INFO_F_IS_SYS_SIDE SAL_BIT(2) 66 /** 67 * Gport is Black Hole (drop) 68 */ 69 #define DNX_ALGO_GPM_GPORT_INFO_F_IS_BLACK_HOLE SAL_BIT(3) 70 /* 71 * } 72 */ 73 /** @}*/ 74 75 /** 76 * \brief GPORT PP port physical information. 77 * 78 * This structure contains pp ports of a GPORT. 79 * In case of LAG this information can contain several pp ports, each configured on a different core. 80 * In other cases it will be a single pp port on a single core. 81 */ 82 typedef struct 83 { 84 /** 85 * Number of PP ports configured on the gport 86 * usually 1, can be 0/1/2 for LAGs 87 */ 88 int nof_pp_ports; 89 /** 90 * Array of internal pp ports configured on the gport, matching the core ids below 91 */ 92 int pp_port[DNX_DATA_MAX_DEVICE_GENERAL_NOF_CORES]; 93 /** 94 * Array of core ids per pp port, matching the pp ports above 95 */ 96 int core_id[DNX_DATA_MAX_DEVICE_GENERAL_NOF_CORES]; 97 } dnx_algo_gpm_gport_phy_pp_port_info_t; 98 99 /** 100 * \brief GPORT physical information. 101 * 102 * This structure contains physical information of a GPORT. 103 * Relevant for GPORTs which are of type other than: 104 * 1. FEC (like BCM_GPORT_VLAN/MPLS_PORT of subtype BCM_GPORT_SUB_TYPE_FORWARD_GROUP) 105 * 2. Lif (like BCM_GPORT_VLAN/MPLS_PORT of subtype BCM_GPORT_SUB_TYPE_LIF) 106 * 3. MC pointer (like BCM_GPORT_VLAN/MPLS_PORT of subtype BCM_GPORT_SUB_TYPE_MULTICAST) 107 * 4. Push Profile (BCM_GPORT_MPLS_PORT of subtype BCM_GPORT_SUB_TYPE_MPLS_PUSH_PROFILE) 108 * \see 109 * dnx_algo_gpm_gport_phy_info_get 110 */ 111 typedef struct 112 { 113 /** 114 * Local port, first in case of LAG 115 */ 116 bcm_port_t local_port; 117 /** 118 * Local ports bitmap (relevant only for LAG) 119 */ 120 bcm_pbmp_t local_port_bmp; 121 /** 122 * System port 123 */ 124 uint32 sys_port; 125 /** 126 * flags DNX_ALGO_GPM_GPORT_INFO_F_XXX, for example 127 * \ref DNX_ALGO_GPM_GPORT_INFO_F_IS_LOCAL_PORT 128 */ 129 uint32 flags; 130 /** 131 * Lane number 132 */ 133 int lane; 134 /** 135 * Internal information: pp port per core. 136 */ 137 dnx_algo_gpm_gport_phy_pp_port_info_t internal_port_pp_info; 138 } dnx_algo_gpm_gport_phy_info_t; 139 140 /** 141 * \addtogroup Operations Operations 142 * Field of dnx_algo_gpm_gport_phy_info_get api 143 * 144 * @{ 145 */ 146 /* 147 * { 148 */ 149 /** 150 * No Operation 151 */ 152 #define DNX_ALGO_GPM_GPORT_TO_PHY_OP_NONE 0 153 /** 154 * Force system port retrieve 155 */ 156 #define DNX_ALGO_GPM_GPORT_TO_PHY_OP_RETRIVE_SYS_PORT SAL_BIT(0) 157 /** 158 * Force local port retrieve 159 */ 160 #define DNX_ALGO_GPM_GPORT_TO_PHY_OP_LOCAL_IS_MANDATORY SAL_BIT(1) 161 /** 162 * Force pp port retrieve 163 */ 164 #define DNX_ALGO_GPM_GPORT_TO_PHY_OP_PP_PORT_IS_MANDATORY SAL_BIT(2) 165 166 /* 167 * } 168 */ 169 170 /** 171 * brief - flag of algo_gpm_gport_core_get() 172 * If set throw an error when core == BCM_CORE_ALL 173 */ 174 #define ALGO_GPM_GPORT_CORE_F_NO_CORE_ALL (1) 175 176 /** 177 *\brief - gport types used by algo_gpm_gport_verify(). 178 */ 179 typedef enum 180 { 181 ALGO_GPM_GPORT_VERIFY_TYPE_SYSTEM_PORT, 182 ALGO_GPM_GPORT_VERIFY_TYPE_MODPORT, 183 ALGO_GPM_GPORT_VERIFY_TYPE_DEVPORT, 184 ALGO_GPM_GPORT_VERIFY_TYPE_LOCAL_PORT, 185 ALGO_GPM_GPORT_VERIFY_TYPE_PORT, 186 ALGO_GPM_GPORT_VERIFY_TYPE_CORE, 187 ALGO_GPM_GPORT_VERIFY_TYPE_UCAST_QUEUE_GROUP, 188 ALGO_GPM_GPORT_VERIFY_TYPE_MCAST_QUEUE_GROUP, 189 ALGO_GPM_GPORT_VERIFY_TYPE_LOCAL_CPU, 190 ALGO_GPM_GPORT_VERIFY_TYPE_PHYN, 191 ALGO_GPM_GPORT_VERIFY_TYPE_PHYN_LANE, 192 ALGO_GPM_GPORT_VERIFY_TYPE_PHYN_SYS_SIDE, 193 ALGO_GPM_GPORT_VERIFY_TYPE_PHYN_SYS_SIDE_LANE, 194 ALGO_GPM_GPORT_VERIFY_TYPE_LANE, 195 ALGO_GPM_GPORT_VERIFY_TYPE_TRUNK, 196 ALGO_GPM_GPORT_VERIFY_TYPE_LOCAL_FABRIC, 197 ALGO_GPM_GPORT_VERIFY_TYPE_BLACK_HOLE, 198 ALGO_GPM_GPORT_VERIFY_TYPE_MCAST, 199 200 ALGO_GPM_GPORT_VERIFY_TYPE_NOF 201 } algo_gpm_gport_verify_type_e; 202 203 /** @}*/ 204 205 /** 206 * \brief 207 * Given a gport, return physical information on physical ports 208 * Return error on unsupported types, see dnx_algo_gpm_gport_phy_info_t 209 * for more information on supported types. 210 * dnx_algo_gpm_gport_is_physical can be used to check whether GPORT is physical 211 * 212 * Physical information includes port (system/pp/tm ports) and core id. 213 * Operations flags specify whether system port should be retrieved and 214 * whether local port is mandatory. 215 * 216 * Also supports local port input (not encoded as bcm_gport_t). 217 * 218 * \param [in] unit - 219 * Relevant unit. 220 * \param [in] port - 221 * In GPORT given by user 222 * \param [in] operation - 223 * Operation requested according to DNX_ALGO_GPM_GPORT_TO_PHY_OP_XXX, 224 * for example \ref DNX_ALGO_GPM_GPORT_TO_PHY_OP_NONE 225 * \param [out] phy_gport_info - 226 * Physical information in case gport is physical port. 227 * In case gport is LAG, only system port will be retrieved. 228 * \return 229 * shr_error_e - 230 * Error return value 231 * \remark 232 * None 233 * \see 234 * dnx_algo_gpm_gport_phy_info_t 235 * dnx_algo_gpm_gport_is_physical 236 * shr_error_e 237 */ 238 shr_error_e dnx_algo_gpm_gport_phy_info_get( 239 int unit, 240 bcm_gport_t port, 241 uint32 operation, 242 dnx_algo_gpm_gport_phy_info_t * phy_gport_info); 243 244 /** 245 * \brief 246 * Given a gport, extract logical port. 247 * Note: 248 * Not all the gports are covered. 249 * Before using this function, make sure that the required gports are already covered. 250 * Additional gports support will be added upon requirement. 251 * 252 * \param [in] unit - 253 * Relevant unit. 254 * \param [in] flags - 255 * Currently no flags supported 256 * \param [in] gport - 257 * In GPORT given by user. 258 * Supported types: 259 * - Local port 260 * - BCM_GPORT_IS_LOCAL(gport) 261 * - BCM_GPORT_IS_LOCAL_INTERFACE(gport) 262 * - BCM_COSQ_GPORT_IS_PORT_TC(gport) 263 * - BCM_COSQ_GPORT_IS_PORT_TCG(gport) 264 * - BCM_COSQ_GPORT_IS_E2E_PORT(gport) 265 * - BCM_COSQ_GPORT_IS_E2E_INTERFACE(gport) 266 * - BCM_COSQ_GPORT_IS_E2E_PORT_TC(gport) 267 * - BCM_COSQ_GPORT_IS_E2E_PORT_TCG(gport) 268 * - BCM_COSQ_GPORT_IS_UCAST_EGRESS_QUEUE(gport) 269 * - BCM_COSQ_GPORT_IS_MCAST_EGRESS_QUEUE(gport) 270 * - BCM_GPORT_IS_MODPORT(gport) 271 * 272 * \param [out] port - 273 * The extracted logical port 274 * \return 275 * shr_error_e - 276 * Error return value 277 * \remark 278 * None 279 * \see 280 * None 281 */ 282 shr_error_e algo_gpm_tm_gport_to_port_get( 283 int unit, 284 uint32 flags, 285 bcm_gport_t gport, 286 bcm_port_t * port); 287 288 /** 289 * \brief 290 * Given a gport, extract the core, 291 * In a case the device is single core, the function will return the 0. 292 * In a case the gport points to both cores, BCM_CORE_ALL, 293 * In a case core cann't be extracted, BCM_E_PORT error will be raised. 294 * Note: 295 * Not all the gports are covered. 296 * Before using this function, make sure that the required gports are already covered. 297 * Additional gports support will be added upon requirement. 298 * 299 * \param [in] unit - 300 * Relevant unit. 301 * \param [in] flags - 302 * See ALGO_GPM_GPORT_CORE_F_XXX. 303 * \param [in] gport - 304 * In GPORT given by user. Supported gports are: 305 * * BCM_COSQ_GPORT_IS_CORE(gport) 306 * * BCM_GPORT_IS_SCHEDULER(gport) 307 * * BCM_COSQ_GPORT_IS_VOQ_CONNECTOR(gport) 308 * * BCM_COSQ_GPORT_IS_SCHED_CIR(gport) 309 * * BCM_COSQ_GPORT_IS_SCHED_PIR(gport) 310 * * BCM_COSQ_GPORT_IS_SHARED_SHAPER_ELEM(gport) 311 * * BCM_COSQ_GPORT_IS_COMPOSITE_SF2(gport) 312 * * BCM_GPORT_IS_UCAST_QUEUE_GROUP(gport) 313 * * BCM_GPORT_IS_MCAST_QUEUE_GROUP(gport) 314 * * Local port 315 * * BCM_GPORT_IS_LOCAL(gport) 316 * * BCM_GPORT_IS_LOCAL_INTERFACE(gport) 317 * * BCM_COSQ_GPORT_IS_PORT_TC(gport) 318 * * BCM_COSQ_GPORT_IS_PORT_TCG(gport) 319 * * BCM_COSQ_GPORT_IS_E2E_PORT(gport) 320 * * BCM_COSQ_GPORT_IS_E2E_INTERFACE(gport) 321 * * BCM_COSQ_GPORT_IS_E2E_PORT_TC(gport) 322 * * BCM_COSQ_GPORT_IS_E2E_PORT_TCG(gport) 323 * 324 * \param [out] core - 325 * The extracted core ID or BCM_CORE_ALL for both. 326 * \return 327 * shr_error_e - 328 * Error return value 329 * \remark 330 * None 331 * \see 332 * None 333 */ 334 shr_error_e algo_gpm_tm_gport_to_core_get( 335 int unit, 336 uint32 flags, 337 bcm_gport_t gport, 338 bcm_core_t * core); 339 340 /** 341 * \brief - verify gport type. 342 * The function throws an error in a case the gport type is not included in the array allowed_types. 343 * Note: 344 * Not all gports are covered by this function (the support list can be found in algo_gpm_gport_verify_type_e). 345 * Before using this function, make sure that the required gports are already covered. 346 * Additional gports support will be added upon requirement. 347 * 348 * Example: 349 * " 350 * algo_gpm_gport_verify_type_e allowed_types[] = {ALGO_GPM_GPORT_VERIFY_TYPE_SYSTEM_PORT. ALGO_GPM_GPORT_VERIFY_TYPE_LOCAL_PORT, ALGO_GPM_GPORT_VERIFY_TYPE_PORT}; 351 * SHR_IF_ERR_EXIT(algo_gpm_gport_verify(unit, gport, COUNTOF(allowed_types), allowed_types)); 352 * " 353 * \param [in] unit - unit ID 354 * \param [in] gport - gport to verify 355 * \param [in] nof_allowed_types - size of array allowed_types 356 * \param [in] allowed_types = array of all the supported types 357 * \return 358 * shr_error_e - Non-zero in case of an error. 359 * \remark 360 * * None 361 * \see 362 * * None 363 */ 364 shr_error_e algo_gpm_gport_verify( 365 int unit, 366 bcm_gport_t gport, 367 uint32 nof_allowed_types, 368 algo_gpm_gport_verify_type_e * allowed_types); 369 370 /** 371 * \brief 372 * Given a gport, returns whether the gport is physical port. 373 * GPORT is physical in case it's not one of the following types: 374 * VPAN PORT / MPLS PORT / MIM PORT / TRILL PORT / TUNNEL / 375 * L2GRE PORT / VXLAN PORT / FORWARD PORT / EXTENDER PORT 376 * 377 * \param [in] unit - 378 * Relevant unit. 379 * \param [in] port - 380 * In GPORT given by user 381 * \param [out] is_physical_port - 382 * Boolean return value indicating given gport is physical. 383 * Meaning the gport is not of type FEC/Lif/MC pointer/Push Profile 384 * \return 385 * shr_error_e - 386 * Error return value 387 * \remark 388 * None 389 * \see 390 * shr_error_e 391 */ 392 shr_error_e dnx_algo_gpm_gport_is_physical( 393 int unit, 394 bcm_gport_t port, 395 uint8 *is_physical_port); 396 397 /** 398 * \brief 399 * Given a system port, returns the gport it's mapped to. 400 * This returned gport can be either a system gport or a trunk gport. 401 * 402 * \param [in] unit - 403 * Relevant unit. 404 * \param [in] system_port - 405 * System port to translate to gport. 406 * \param [out] gport - 407 * Gport mapped to this system port. 408 * 409 * \remark 410 * None 411 */ 412 shr_error_e dnx_algo_gpm_gport_from_system_port( 413 int unit, 414 int system_port, 415 bcm_gport_t * gport); 416 417 /* 418 * HARDWARE RESOURCES FUNCTIONS 419 */ 420 /* 421 * { 422 */ 423 /** 424 * \brief GPORT hardware resources information. 425 * 426 * This structure contains HW information of a GPORT. 427 * 1. Local and Global LIFs (like BCM_GPORT_VLAN/MPLS_PORT of subtype 428 * BCM_GPORT_SUB_TYPE_LIF) 429 * 2. FEC (like BCM_GPORT_VLAN/MPLS_PORT of subtype 430 * BCM_GPORT_SUB_TYPE_FORWARD_GROUP) 431 * Each HW resource field can be filled if valid or mark as invalid if does not exist. 432 * \see 433 * dnx_algo_gpm_gport_to_hw_resources 434 */ 435 typedef struct 436 { 437 /** 438 * Global-LIF, Invalid when does not exist 439 */ 440 int global_in_lif; 441 /** 442 * Global-LIF, Invalid when does not exist 443 */ 444 int global_out_lif; 445 /** 446 * Local-LIF, Invalid when does not exist 447 */ 448 int local_in_lif; 449 /** 450 * Local inlif core. Can be either a specific core (if lif is DPC and allocated only on one core) or _SHR_CORE_ALL, 451 * if lif is SBC or DPC and allocated on all cores. 452 */ 453 int local_in_lif_core; 454 /** 455 * Local-LIF, Invaild when does not exist 456 */ 457 int local_out_lif; 458 /** 459 * The table relevant to the inlif DBAL_TABLE_XXX 460 */ 461 dbal_tables_e inlif_dbal_table_id; 462 /** 463 * The result type relevant to the inlif DBAL_RESULT_TYPE_XXX 464 */ 465 uint32 inlif_dbal_result_type; 466 /** 467 * The table relevant to the outlif DBAL_TABLE_XXX 468 */ 469 dbal_tables_e outlif_dbal_table_id; 470 /** 471 * The result type relevant to the outlif DBAL_RESULT_TYPE_XXX 472 */ 473 uint32 outlif_dbal_result_type; 474 /** 475 * The eedb phase this outlif is mapped to. 476 */ 477 lif_mngr_outlif_phase_e outlif_phase; 478 /** 479 * FEC, invalid when does not exist 480 */ 481 int fec_id; 482 } dnx_algo_gpm_gport_hw_resources_t; 483 484 /** 485 * \addtogroup flags DNX_ALGO_GPM_GPORT_HW_RESOURCES_XXX 486 * Information representing which HW resource to 487 * retrieve. Used by 488 * dnx_algo_gpm_gport_to_hw_resources 489 * 490 * @{ 491 */ 492 /** 493 * Retrieve FEC resource 494 */ 495 #define DNX_ALGO_GPM_GPORT_HW_RESOURCES_FEC SAL_BIT(0) 496 /** 497 * Retrieve Ingress Global LIF 498 */ 499 #define DNX_ALGO_GPM_GPORT_HW_RESOURCES_GLOBAL_LIF_INGRESS SAL_BIT(1) 500 /** 501 * Retrieve Egress Global LIF 502 */ 503 #define DNX_ALGO_GPM_GPORT_HW_RESOURCES_GLOBAL_LIF_EGRESS SAL_BIT(2) 504 /** 505 * Retrieve Ingress Local LIF 506 */ 507 #define DNX_ALGO_GPM_GPORT_HW_RESOURCES_LOCAL_LIF_INGRESS SAL_BIT(3) 508 /** 509 * Retrieve Egress Local LIF 510 */ 511 #define DNX_ALGO_GPM_GPORT_HW_RESOURCES_LOCAL_LIF_EGRESS SAL_BIT(4) 512 /** 513 * Don't return error in case required and invalid resource 514 */ 515 #define DNX_ALGO_GPM_GPORT_HW_RESOURCES_NON_STRICT SAL_BIT(5) 516 /** 517 * Retrieve DPC local lif. Only relevant for \ref dnx_algo_gpm_gport_from_lif 518 */ 519 #define DNX_ALGO_GPM_GPORT_HW_RESOURCES_DPC_LOCAL_LIF_INGRESS SAL_BIT(6) 520 /** 521 * Retrieve SBC local lif. Only relevant for \ref dnx_algo_gpm_gport_from_lif 522 */ 523 #define DNX_ALGO_GPM_GPORT_HW_RESOURCES_SBC_LOCAL_LIF_INGRESS SAL_BIT(7) 524 /** 525 * Retrieve Egress Local LIF 526 */ 527 #define DNX_ALGO_GPM_GPORT_HW_RESOURCES_VIRTUAL_EGRESS SAL_BIT(8) 528 /** 529 * Retrieve Local LIF resources 530 */ 531 #define DNX_ALGO_GPM_GPORT_HW_RESOURCES_LOCAL_LIF \ 532 (DNX_ALGO_GPM_GPORT_HW_RESOURCES_LOCAL_LIF_INGRESS | DNX_ALGO_GPM_GPORT_HW_RESOURCES_LOCAL_LIF_EGRESS) 533 /** 534 * Retrieve Global LIF resources 535 */ 536 #define DNX_ALGO_GPM_GPORT_HW_RESOURCES_GLOBAL_LIF \ 537 (DNX_ALGO_GPM_GPORT_HW_RESOURCES_GLOBAL_LIF_INGRESS | DNX_ALGO_GPM_GPORT_HW_RESOURCES_GLOBAL_LIF_EGRESS) 538 /** 539 * Retrieve Local and Global LIF resources 540 */ 541 #define DNX_ALGO_GPM_GPORT_HW_RESOURCES_LOCAL_AND_GLOBAL_LIF \ 542 (DNX_ALGO_GPM_GPORT_HW_RESOURCES_GLOBAL_LIF | DNX_ALGO_GPM_GPORT_HW_RESOURCES_LOCAL_LIF) 543 /** 544 * Retrieve Egress resources - Local LIF or virtual 545 */ 546 #define DNX_ALGO_GPM_GPORT_HW_RESOURCES_EGRESS_LOCAL_LIF_OR_VIRTUAL \ 547 (DNX_ALGO_GPM_GPORT_HW_RESOURCES_VIRTUAL_EGRESS | DNX_ALGO_GPM_GPORT_HW_RESOURCES_LOCAL_LIF_EGRESS) 548 /** @}*/ 549 550 /** 551 * \brief 552 * Given a gport, returns related HW resources - LIF or FEC. 553 * In case of LIF, both global and local can be retrieved. 554 * Also ingress and egress options are available. 555 * In case of ergress, virtual gport is supported by filling 556 * gport_hw_resources->outlif_dbal_table_id 557 * 558 * \param [in] unit - 559 * Relevant unit. 560 * \param [in] gport - 561 * GPORT given by user 562 * \param [in] flags - 563 * flags of options what to retrieve. See for example 564 * \ref DNX_ALGO_GPM_GPORT_HW_RESOURCES_FEC in 565 * DNX_ALGO_GPM_GPORT_HW_RESOURCES_XXX 566 * \param [out] gport_hw_resources - 567 * GPORT HW resources. Note that if GPORT is encoded as 568 * having subtype _SHR_L3_ITF_SUB_TYPE_VIRTUAL_EGRESS_POINTED, 569 * then 'egr_pointed' object is returned on 570 * gport_hw_resources->global_out_lif 571 * \return 572 * shr_error_e - 573 * Error return value 574 * \remark 575 * None 576 * \see 577 * dnx_algo_gpm_gport_hw_resources_t 578 * _SHR_L3_ITF_SUB_TYPE_IS_VIRTUAL_EGRESS_POINTED 579 * shr_error_e 580 */ 581 shr_error_e dnx_algo_gpm_gport_to_hw_resources( 582 int unit, 583 bcm_gport_t gport, 584 uint32 flags, 585 dnx_algo_gpm_gport_hw_resources_t * gport_hw_resources); 586 587 /** 588 * \brief GPORT hardware resources information. 589 * 590 * This structure contains HW information of a RIF: 591 * DBAL table id and result type 592 * \see 593 * dnx_algo_gpm_rif_to_hw_resources 594 */ 595 typedef struct 596 { 597 /** 598 * The table relevant to the outlif DBAL_TABLE_XXX 599 */ 600 dbal_tables_e outlif_dbal_table_id; 601 /** 602 * The result type relevant to the outlif DBAL_RESULT_TYPE_XXX 603 */ 604 uint32 outlif_dbal_result_type; 605 } dnx_algo_gpm_rif_hw_resources_t; 606 607 /** 608 * \brief 609 * Given an interface , returns related HW OUTLIF resources. 610 * In case not found, return error 611 * 612 * \param [in] unit - 613 * Relevant unit. 614 * \param [in] intf - 615 * Interface given by user 616 * \param [out] rif_hw_resources - GPORT HW resources. 617 * \return 618 * shr_error_e - 619 * Error return value 620 * \remark 621 * None 622 * \see 623 * dnx_algo_gpm_gport_hw_resources_t 624 * shr_error_e 625 */ 626 shr_error_e dnx_algo_gpm_rif_intf_to_hw_resources( 627 int unit, 628 bcm_if_t intf, 629 dnx_algo_gpm_rif_hw_resources_t * rif_hw_resources); 630 631 /** 632 * \brief 633 * Given a global or local lif and core id, returns related gport. 634 * 635 * \param [in] unit - 636 * Relevant unit. 637 * \param [in] flags - 638 * flags to indicate ingress/egress lif. Supported values: 639 * \ref DNX_ALGO_GPM_GPORT_HW_RESOURCES_LOCAL_LIF_EGRESS \ref DNX_ALGO_GPM_GPORT_HW_RESOURCES_DPC_LOCAL_LIF_INGRESS, 640 * \ref DNX_ALGO_GPM_GPORT_HW_RESOURCES_SBC_LOCAL_LIF_INGRESS, \ref DNX_ALGO_GPM_GPORT_HW_RESOURCES_GLOBAL_LIF_INGRESS, 641 * \ref DNX_ALGO_GPM_GPORT_HW_RESOURCES_GLOBAL_LIF_EGRESS, \ref DNX_ALGO_GPM_GPORT_HW_RESOURCES_NON_STRICT 642 * \param [in] core_id - core 643 * \param [in] lif - lif given by user 644 * \param [out] gport - gport related to the given lif. See remarks below. 645 * \return 646 * shr_error_e - 647 * Error return value 648 * \remark 649 * * Only one flag is allowed to be set! \n 650 * * If 'flags' indicates 'local + egress' then encoded gport may be of \n 651 * subtype _SHR_GPORT_SUB_TYPE_VIRTUAL_EGRESS_POINTED. \n 652 * The reason is that some local out_lifs are assigned to 'egr_pointed' objects while \n 653 * others are assigned to 'global_lif'. This procedure detects which is which and encodes \n 654 * gport accordingly. 655 * \see 656 * dnx_algo_gpm_gport_hw_resources_t 657 * shr_error_e 658 */ 659 shr_error_e dnx_algo_gpm_gport_from_lif( 660 int unit, 661 uint32 flags, 662 int core_id, 663 int lif, 664 bcm_gport_t * gport); 665 666 /** 667 * \brief 668 * Given a gport, and it's resources fill a handle with the key for the HW table. 669 * 670 * \param [in] unit - 671 * Relevant unit. 672 * \param [in,out] entry_handle_id - 673 * dbal handle id for the HW table (allocated with the correct table id) 674 * \param [in] gport - 675 * GPORT given by user 676 * \param [in] gport_hw_resources - 677 * GPORT HW resources. Relevant information will be used to fill the handle key 678 * \return 679 * shr_error_e - 680 * Error return value 681 * \remark 682 * None 683 * \see 684 * dnx_algo_gpm_gport_hw_resources_t 685 */ 686 shr_error_e algo_gpm_gport_egress_hw_key_set( 687 int unit, 688 uint32 entry_handle_id, 689 bcm_gport_t gport, 690 dnx_algo_gpm_gport_hw_resources_t * gport_hw_resources); 691 /* 692 * END OF HARDWARE RESOURCES FUNCTIONS 693 */ 694 /* 695 * } 696 */ 697 698 /* 699 * FORWARD INFORMATION FUNCTIONS 700 */ 701 /* 702 * { 703 */ 704 /** 705 * No Flags 706 */ 707 #define ALGO_GPM_ENCODE_DESTINATION_FLAGS_NONE 0 708 /** 709 * Destination is for egress multicast use 710 */ 711 #define ALGO_GPM_ENCODE_DESTINATION_EGRESS_MULTICAST SAL_BIT(0) 712 /** 713 * \brief 714 * Given a gport, returns forward destination encoded by this gport. 715 * The destination can be then used for MACT, Cross-Connect 716 * and other forwarding databases. 717 * Used to store forwarding information in SW state 718 * 719 * \param [in] unit - 720 * Relevant unit. 721 * \param [in] flags - one of ALGO_GPM_ENCODE_DESTINATION_XXX 722 * \param [in] port - 723 * GPORT given by user, might be port or gport. 724 * Supported gports - physical gports and FEC gports. 725 * \param [out] destination - 726 * DBAL encoding for destination field. 727 * Can be FEC/PORT/LAG/TRAP/FLOW-ID 728 * \return 729 * shr_error_e - 730 * Error return value 731 * \remark 732 * This function is used only for filling SW state table 733 * DBAL_TABLE_SW_STATE_GPORT_TO_FORWARDING_INFO. For HW tables 734 * configuration algo_gpm_gport_and_encap_to_forward_information should be used. 735 * \see 736 * algo_gpm_gport_and_encap_to_forward_information 737 * shr_error_e 738 */ 739 shr_error_e algo_gpm_encode_destination_field_from_gport( 740 int unit, 741 uint32 flags, 742 bcm_gport_t port, 743 uint32 *destination); 744 745 /** 746 * \brief 747 * Given a gport, returns forward destination encoded by this gport. 748 * The destination can be then used for MACT, Cross-Connect 749 * and other forwarding databases. 750 * Used to store forwarding information in SW state 751 * 752 * \param [in] unit - 753 * Relevant unit. 754 * \param [in] flags - one of ALGO_GPM_ENCODE_DESTINATION_XXX 755 * \param [in] destination - given by user 756 * DBAL encoding for destination field. 757 * Can be FEC/PORT/LAG/TRAP/FLOW-ID 758 * \param [out] gport - GPORT mapped by this destination. 759 * \return 760 * shr_error_e - 761 * Error return value 762 * \remark 763 * Physical ports have several possible mapping, we are 764 * choosing BCM_SYSTEM_PORT for these ports. 765 * \see 766 * algo_gpm_gport_and_encap_to_forward_information 767 * shr_error_e 768 */ 769 shr_error_e algo_gpm_gport_from_encoded_destination_field( 770 int unit, 771 uint32 flags, 772 uint32 destination, 773 bcm_gport_t * gport); 774 775 /** 776 * \brief Forward information. 777 * 778 * This structure contains pre-fec forward information. it's 779 * used when retrieving forward info in 780 * algo_gpm_gport_and_encap_to_forward_information. The type 781 * specifies which fields of forward information are relevant. 782 * \see 783 * algo_gpm_gport_and_encap_to_forward_information 784 */ 785 typedef struct 786 { 787 /** 788 * type of forwarding information 789 */ 790 dbal_enum_value_result_type_l2_gport_to_forwarding_sw_info_e fwd_info_result_type; 791 /** 792 * destination field, as set by DBAL in forwarding tables. must 793 * be valid for all types 794 */ 795 uint32 destination; 796 /** 797 * outlif field, as set by DBAL in forwarding tables. valid for 798 * DEST_OUTLIF type only 799 */ 800 uint32 outlif; 801 /** 802 * eei field, as set by DBAL in forwarding tables. valid for 803 * DEST_EEI type only 804 */ 805 uint32 eei; 806 } dnx_algo_gpm_forward_info_t; 807 808 /** 809 * \brief 810 * Given a gport and forward information used in forwarding 811 * stage (MAC table result), fill SW state in both directions 812 * (gport to and from forward info). 813 * 814 * \param [in] unit - 815 * Relevant unit. 816 * \param [in] is_replace - 817 * If forward info is not being replaced, writing to existing entry will return error. 818 * \param [in] gport - 819 * GPORT given by user 820 * \param [in] forward_info - 821 * Forwarding information struct 822 * \return 823 * shr_error_e - 824 * Error return value 825 * \remark 826 * None 827 * \see 828 * dnx_algo_gpm_forward_info_t 829 * algo_gpm_gport_to_and_from_forward_information_free_sw_state 830 * algo_gpm_gport_and_encap_to_forward_information 831 * algo_gpm_gport_and_encap_from_forward_information 832 */ 833 shr_error_e algo_gpm_gport_l2_forward_info_add( 834 int unit, 835 uint8 is_replace, 836 bcm_gport_t gport, 837 dnx_algo_gpm_forward_info_t * forward_info); 838 839 /** 840 * \brief 841 * Given a gport, get forward information used in forwarding 842 * stage (MAC table result) from SW state 843 * (gport to forward info). 844 * 845 * \param [in] unit - 846 * Relevant unit. 847 * \param [in] gport - 848 * GPORT given by user 849 * \param [out] forward_info - 850 * Forwarding information struct 851 * \return 852 * shr_error_e - 853 * Error return value 854 * \remark 855 * None 856 * \see 857 * dnx_algo_gpm_forward_info_t 858 * algo_gpm_gport_to_and_from_forward_information_free_sw_state 859 * algo_gpm_gport_and_encap_to_forward_information 860 * algo_gpm_gport_and_encap_from_forward_information 861 */ 862 shr_error_e algo_gpm_gport_l2_forward_info_get( 863 int unit, 864 bcm_gport_t gport, 865 dnx_algo_gpm_forward_info_t * forward_info); 866 867 /** 868 * \brief 869 * Free SW state in both directions - gport to and from forward 870 * info. 871 * 872 * \param [in] unit - 873 * Relevant unit. 874 * \param [in] gport - 875 * GPORT given by user that should be removed from both SW 876 * states 877 * \return 878 * shr_error_e - 879 * Error return value 880 * \remark 881 * None 882 * \see 883 * dnx_algo_gpm_forward_info_t 884 * algo_gpm_gport_to_and_from_forward_information_fill_sw_state 885 * algo_gpm_gport_and_encap_to_forward_information 886 * algo_gpm_gport_and_encap_from_forward_information 887 */ 888 shr_error_e algo_gpm_gport_l2_forward_info_delete( 889 int unit, 890 bcm_gport_t gport); 891 892 /** 893 * \brief 894 * Given a gport and encap id, returns forward information as 895 * used in forwarding stage (MAC table result). 896 * encap_id can be invalid (indicated by 897 * BCM_FORWARD_ENCAP_ID_INVALID), in that case it won't be 898 * used. 899 * 900 * \param [in] unit - 901 * Relevant unit. 902 * \param [in] gport - 903 * GPORT given by user 904 * \param [in] encap_id - 905 * encapsulation id - can be outlif or EEI, encoded with 906 * BCM_FORWARD_ENCAP_ID_XXX macros. 907 * \param [out] forward_info - 908 * Pointer to forward info structure that was retrieved 909 * \return 910 * shr_error_e - 911 * Error return value 912 * \remark 913 * None 914 * \see 915 * dnx_algo_gpm_forward_info_t 916 * BCM_FORWARD_ENCAP_ID_INVALID 917 * algo_gpm_gport_and_encap_from_forward_information 918 */ 919 shr_error_e algo_gpm_gport_and_encap_to_forward_information( 920 int unit, 921 bcm_gport_t gport, 922 uint32 encap_id, 923 dnx_algo_gpm_forward_info_t * forward_info); 924 925 /** 926 * \brief 927 * Given forward information as used in forwarding stage (MAC 928 * table result) returns associated gport OR physical port + 929 * encap_id. The decision between them is done according to the 930 * following logic: 931 * IF (advanced rsrc mgmt AND api is forwarding api (MACT, 932 * CC...) OR (destination type = destination_only) OR (force 933 * destination is set) 934 * THEN return port + encap 935 * ELSE try to get gport, if not found return port + encap 936 * 937 * \param [in] unit - 938 * Relevant unit. 939 * \param [out] gport - 940 * GPORT retrieved. Can be either logical port or physical 941 * port. 942 * \param [out] encap_id - 943 * encapsulation id, in case returning port+encap and not 944 * gport. Can be outlif or EEI(in Jericho mode only), 945 * encoded with BCM_FORWARD_ENCAP_ID_XXX macros. 946 * \param [in] forward_info - 947 * Pointer to forward info structure given by the user 948 * \param [in] force_port_and_encap - 949 * Force port+encap id to be returned and not gport 950 * 951 * \return 952 * shr_error_e - 953 * Error return value 954 * \remark 955 * None 956 * \see 957 * dnx_algo_gpm_forward_info_t 958 * algo_gpm_gport_and_encap_to_forward_information 959 */ 960 shr_error_e algo_gpm_gport_and_encap_from_forward_information( 961 int unit, 962 bcm_gport_t * gport, 963 uint32 *encap_id, 964 dnx_algo_gpm_forward_info_t * forward_info, 965 uint8 force_port_and_encap); 966 967 /* 968 * END OF FORWARD INFORMATION FUNCTIONS 969 */ 970 /* 971 * } 972 */ 973 974 /* 975 * } 976 */ 977 #endif/*_ALGO_GPM_API_INCLUDED__*/