gport_mgmt.h (35332B)
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: gport_mgmt.h 8 * Purpose: GPORT Management internal definitions to the BCM library. 9 */ 10 11 #ifndef INCLUDE_GPORT_MGMT_H 12 #define INCLUDE_GPORT_MGMT_H 13 14 #include <bcm/types.h> 15 /*#include <bcm/vlan.h>*/ 16 #include <bcm/mpls.h> 17 #include <bcm/mim.h> 18 #include <bcm/trill.h> 19 #include <bcm/tunnel.h> 20 #include <bcm/extender.h> 21 22 #include <bcm_int/dpp/port.h> 23 #include <bcm_int/dpp/trill.h> 24 #include <bcm_int/dpp/alloc_mngr_local_lif.h> 25 26 #include <soc/dpp/PPD/ppd_api_general.h> 27 #include <soc/dpp/PPD/ppd_api_lif.h> 28 #include <soc/dpp/PPD/ppd_api_frwrd_fec.h> 29 #include <soc/dpp/TMC/tmc_api_general.h> 30 #include <soc/dpp/PPD/ppd_api_mymac.h> 31 #include <soc/dpp/PPD/ppd_api_eg_ac.h> 32 33 #include <shared/hash_tbl.h> 34 #include <shared/swstate/sw_state.h> 35 #include <shared/swstate/sw_state_hash_tbl.h> 36 37 38 /* Number of LIFs as gports */ 39 #define _BCM_DPP_NOF_GPORTS(unit) ((SOC_DPP_CONFIG(unit))->l2.nof_lifs) 40 41 /* Following enum presents LIF type (per application/feature) */ 42 typedef enum _bcm_lif_type_s { 43 _bcmDppLifTypeAny=0, /* Any LIF, usually mean not exist LIF */ 44 _bcmDppLifTypeMplsPort, /* MPLS LIF (PWE) */ 45 _bcmDppLifTypeMim, /* MIM LIF */ 46 _bcmDppLifTypeTrill, /* TRILL LIF */ 47 _bcmDppLifTypeVlan, /* VLAN LIF (AC) */ 48 _bcmDppLifTypeMplsTunnel, /* MPLS Tunnel LIF */ 49 _bcmDppLifTypeIpTunnel, /* IP Tunnel LIF */ 50 _bcmDppLifTypeL2Gre, /* L2Gre LIF */ 51 _bcmDppLifTypeVxlan, /* VxLan LIF */ 52 _bcmDppLifTypeLinkLayer, /* Link layer LIF */ 53 _bcmDppLifTypeOverlayLinkLayer, /* Link layer for Overlay encapsulation, used only in ROO applications */ 54 _bcmDppLifTypeCpuL2Encap, /* Encapsulated Link layer for PUNT applications */ 55 _bcmDppLifTypeExtender, /* Port Extender layer (802.1BR) */ 56 _bcmDppLifTypeNativeVlan, /* Native vlan lif */ 57 _bcmDppLifTypeLawfulInterception, /* Lawful Interception */ 58 _bcmDppLifTypeNopMplsTunnel, /*NOP Mpls tunnel LIF*/ 59 _bcmDppLifTypeDataMplsTunnel, /*Mpls tunnel LIF with Data entry, Push/Swap operation*/ 60 _bcmDppLifTypeL2SrcEncap, /* L2 Source Mac Encap */ 61 _bcmDppLifTypeL2tpTunnelDataEntry, /* L2TP egress data entry */ 62 _bcmDppLifTypeL2tpTunnel, /* L2TP tunnel terminator, ingress-only */ 63 _bcmDppLifTypePppoeTunnel /* PPPoE tunnel terminator, ingress-only */ 64 } _bcm_lif_type_e; 65 66 /* 67 * Gport resolution type information, 68 * Used to retreive Forwarding Information of a given GPORT 69 * Note: Not all logical gports have forwarding information 70 * (for example when GPORT is not expected to be located in Forwarding databases) 71 */ 72 73 #define _BCM_DPP_GPORT_RESOLVE_TYPE_IS_FEC(resolve_type) ((resolve_type==_bcmDppGportResolveTypeProtectedFec) || (resolve_type==_bcmDppGportResolveTypeForwardFec)) 74 75 typedef enum _bcm_dpp_gport_resolve_type_s { 76 _bcmDppGportResolveTypeInvalid=0, /* invalid gport type or not initialized */ 77 _bcmDppGportResolveTypeProtectedFec=1, /* gport-id includes FEC only, FEC usually includes: port + EEP */ 78 _bcmDppGportResolveTypeAC=2, /* gport is AC-OutLIF: phy = physical port + encap-id = AC */ 79 _bcmDppGportResolveTypeMC=3, /* gport is MC, usually for 1+1 protection */ 80 _bcmDppGportResolveTypePhy=4, /* gport is only physical port, encap_id is not relevant */ 81 _bcmDppGportResolveTypeFecVC=5, /* gport is FEC+VC (For PWE application): phy = FEC + encap-id = VC */ 82 _bcmDppGportResolveTypePhyEEP=6, /* gport is Port+OutLIF (EEP) for PWE: phy = physical port + encap-id = EEP */ 83 _bcmDppGportResolveTypeFecEEP=7, /* gport is FEC+OutLIF (EEP) for PWE: phy = FEC + encap-id = EEP */ 84 _bcmDppGportResolveTypeMimMP=8, /* gport is FEC for MIM MP: phy = B-SA LSB + encap-id = {B-SA MSB,B-VID} */ 85 _bcmDppGportResolveTypeTrillMC=9, /* gport is MC for trill Multicast */ 86 _bcmDppGportResolveTypeMimP2P=10, /* gport is FEC for MIM P2P: phy = LIF + encap-id = B-VID */ 87 _bcmDppGportResolveTypeIPTunnel=11, /* gport is out-lif/EEP for ip-tunnel: phy = physical port + encap-id = EEP */ 88 _bcmDppGportResolveTypeL2Gre=12, /* l2gre gport: gport is in-lif for ip-tunnel: phy = physical port + encap-id = out-LIF */ 89 _bcmDppGportResolveTypeL2GreEgFec=13, /* l2gre gport: gport is in-lif for ip-tunnel: phy = FEC + encap-id = out-LIF */ 90 _bcmDppGportResolveTypeVxlan=14, /* vxlan gport: gport is in-lif for ip-tunnel: phy = physical port + encap-id = out-LIF */ 91 _bcmDppGportResolveTypeVxlanEgFec=15, /* vxlan gport: gport is in-lif for ip-tunnel: phy = FEC + encap-id = out-LIF */ 92 _bcmDppGportResolveTypeRing=16, /* ring gport for AC: phy = FEC + encap-id */ 93 _bcmDppGportResolveTypeForwardFec=17, /* gport-id includes FEC only, not used for protection */ 94 _bcmDppGportResolveTypeFecEEI=18, /* gport is FEC+EEI.outLIF for PWE: phy = FEC + encap-id */ 95 _bcmDppGportResolveTypeMimMPNoLearn=19 /* gport is FEC for MIM MP with NO LEARN entry for the mim_port: phy = B-SA LSB + encap-id = {B-SA MSB,B-VID} */ 96 } _bcm_dpp_gport_resolve_type_e; 97 98 /* 99 * Struct present the forwarding information of a given GPORT 100 * Including: 101 * - _bcm_dpp_gport_resolve_type_e - The forwarding information type 102 * - phy_gport - The physical information of a gport. May be for example destination-port,trunk or FEC. 103 * According to _bcm_dpp_gport_resolve_type_e. 104 * - encap_id - The encapsulation information of a gport. May be for example OutLIF, EEI or additional information required by a specific application. 105 * According to _bcm_dpp_gport_resolve_type_e. 106 */ 107 typedef struct { 108 _bcm_dpp_gport_resolve_type_e type; 109 int phy_gport;/* physical information, according to resolve type */ 110 int encap_id;/* encapsulation information or additional info , according to resolve type */ 111 int fec_id; /* fec id which is allocated by bcm_l3_egress_create() API, only used for vlan ingress 1+1 protection learning*/ 112 } _BCM_GPORT_PHY_PORT_INFO; 113 114 /* per LIF what is match key */ 115 116 /* Flags for _bcm_dpp_sw_resources_inlif_t */ 117 #define _BCM_DPP_INFLIF_MATCH_INFO_MPLS_PORT_NO_OUTLIF (0x1) 118 #define _BCM_DPP_INFLIF_MATCH_INFO_P2P (0x2) 119 120 /* Flags for _bcm_dpp_sw_resources_outlif_t */ 121 #define _BCM_DPP_OUTLIF_MATCH_INFO_MPLS_EXTENDED_LABEL (0x1) 122 #define _BCM_DPP_OUTLIF_IP_TUNNEL_MATCH_INFO_GRE_WITH_LB (0x2) 123 #define _BCM_DPP_OUTLIF_MATCH_INFO_MPLS_EXTENDED_LABEL_TAGGED (0x4) 124 125 #define GPORT_HASH_VLAN_NOT_FOUND(phy_port,rv) BCM_FAILURE(rv) 126 127 #define _BCM_DPP_LIF_TO_GPORT_INGRESS 0x02 128 #define _BCM_DPP_LIF_TO_GPORT_EGRESS 0x04 129 #define _BCM_DPP_LIF_TO_GPORT_GLOBAL_LIF 0x08 130 #define _BCM_DPP_LIF_TO_GPORT_LOCAL_LIF 0x10 131 132 /* for LIF-index, what is the match creteria */ 133 /* Note: some attributes can be reused, for example vsi is for mp only and gport_id for p2p only */ 134 typedef struct _bcm_dpp_sw_resources_inlif_s { 135 _bcm_lif_type_e lif_type; 136 uint32 flags; 137 int criteria; 138 bcm_port_t port; /* Port */ 139 int match1; 140 int match2; 141 int match_tunnel; /* For VLAN-Port used for PON application, for MPLS-Port used for label2 applications */ 142 int match_ethertype; 143 /* for MP lif --> gport, can be resoted from HW, from learning info*/ 144 bcm_gport_t gport_id; /* relevant only for p2p, given lif return gport*/ 145 int key1; /* only for p2p, part of the lif entry key */ 146 bcm_gport_t peer_gport; /* only for p2p, gport_id of the peer gport */ 147 148 bcm_gport_t learn_gport_id; /* only for MP, the learning gport, needed when configure LIF and the learning info is FEC 149 (maybe shared with gport_id) */ 150 _bcm_petra_tpid_profile_t tpid_profile_type; 151 /* tpid profile is used for the case of PWE/I-SID. 152 Tpid profile state let us know the status of tpid profile assignment. 153 By default tpid profile type should be none as PWE/I-SID doesn't use any assigned tpid profile. 154 In order to change tpid profile type use APIs bcm_port_tpid_* */ 155 int vsi; /* only for MP service tell what the VSI LIF is attached to, 156 can be restored/read from HW, set in SW to improve performance */ 157 uint32 additional_flags;/* Additional flags to represent more inlif options. */ 158 159 } _bcm_dpp_sw_resources_inlif_t; 160 161 /* OutLIF match information. Managed by WB SW DB */ 162 typedef struct _bcm_dpp_sw_resources_outlif_s { 163 _bcm_lif_type_e lif_type; 164 uint32 flags; 165 } _bcm_dpp_sw_resources_outlif_t; 166 167 typedef struct { 168 _bcm_dpp_sw_resources_inlif_t in_lif_sw_resources; /* Global-LIF, Invalid when not exist */ 169 _bcm_dpp_sw_resources_outlif_t out_lif_sw_resources; /* Global-LIF, Invalid when not exist */ 170 } _bcm_dpp_gport_sw_resources; 171 172 typedef struct { 173 PARSER_HINT_ARR uint32 *fec_remote_lif; 174 PARSER_HINT_ARR bcm_gport_t *bcm_dpp_sw_resources_fec_to_gport; 175 PARSER_HINT_ARR _bcm_dpp_sw_resources_outlif_t *outlif_info; 176 PARSER_HINT_ARR _bcm_dpp_sw_resources_inlif_t *inlif_info; 177 int vlan_port_db_htb_handle; 178 /* Trill port info : map trill to mc_id or fec*/ 179 int trill_info_db_htb_handle; 180 /* map MC to trill*/ 181 int mc_trill_db_htb_handle; 182 int trill_vpn_db_htb_handle; 183 }bcm_dpp_gport_mgmt_info_t; 184 185 186 /* 187 * Defines 188 */ 189 190 #define _BCM_GPORT_NOF_LIFS DPP_WB_ENGINE_NOF_LIFS 191 #define _BCM_GPORT_NOF_VSIS ((SOC_DPP_CONFIG(unit))->l2.nof_vsis) 192 #define _BCM_PPD_VSI_P2P_SERVICE ((SOC_DPP_CONFIG(unit))->l2.nof_vsis - 2) 193 194 #define _BCM_GPORT_ENCAP_ID_LIF_INVALID (-1) 195 196 /* In-LIF Protection defines */ 197 /* '-2' value is reserved for Invalid. In Coupled mode, there's one bit less for the Protection-Pointer */ 198 #define _BCM_INGRESS_PROTECTION_POINTER_INVALID ((SOC_DPP_DEFS_GET(unit, failover_ingress_last_hw_id) >> \ 199 (SOC_IS_JERICHO(unit) ? (SOC_DPP_IS_PROTECTION_INGRESS_COUPLED(unit)) : 0)) - 1) 200 #define _BCM_INGRESS_PROTECTION_POINTER_DEFAULT (0) 201 202 /* 203 * MACROS 204 */ 205 206 207 #define _BCM_PPD_IS_VALID_FAILOVER_ID(failover_id) ((failover_id)>0) 208 209 /* set failover id in case of encoding*/ 210 #define _BCM_PPD_FAILOVER_ID_PLUS_1_TO_ID(_failover_id, _ingress_failover_id) (DPP_FAILOVER_ID_GET((_failover_id), (_ingress_failover_id))) 211 212 /* is the given gport working gport in protection, assuming gport has protection*/ 213 #define _BCM_PPD_GPORT_IS_WORKING_PORT(gport) ((gport)->failover_port_id != BCM_GPORT_TYPE_NONE) 214 215 /* is the given gport working gport in ingress protection, assuming gport has protection*/ 216 #define _BCM_PPD_GPORT_IS_INGRESS_WORKING_PORT(gport) ((gport)->ingress_failover_port_id != BCM_GPORT_TYPE_NONE) 217 218 /* is the given gport working gport in egress protection, assuming gport has egress protection */ 219 #define _BCM_PPD_GPORT_IS_EGRESS_WORKING_PORT(gport) ((gport)->egress_failover_port_id != 0) 220 221 /* is the given gport of type mpls tunnel working gport in ingress protection, assuming gport has ingress protection */ 222 #define _BCM_PPD_GPORT_IS_INGRESS_WORKING_TUNNEL(tunnel) ((tunnel)->failover_tunnel_id != 0) 223 224 /* given FEC for protecting gport returns FEC for working gport*/ 225 #define _BCM_PPD_GPORT_PROTECT_TO_WORK_FEC(protec_fec) (protec_fec-1) 226 227 /* given FEC for working gport returns FEC for protection gport*/ 228 #define _BCM_PPD_GPORT_WORK_TO_PROTECT_FEC(work_fec) (work_fec+1) 229 230 /* given FEC returns working FEC */ 231 #define _BCM_PPD_GPORT_FEC_TO_WORK_FEC(fec) ((((fec)%2) == 1)?(fec-1):(fec)) 232 233 /* indicate if the gport is an overlay gport: vxlan, l2gre, trill, vpls (identify by mpls gport) */ 234 #define _BCM_GPORT_IS_OVERLAY(_gport) \ 235 _SHR_GPORT_IS_VXLAN_PORT(_gport) \ 236 || _SHR_GPORT_IS_L2GRE_PORT(_gport) \ 237 || _SHR_GPORT_IS_TRILL_PORT(_gport) \ 238 || _SHR_GPORT_IS_MPLS_PORT(_gport) \ 239 || _SHR_GPORT_IS_FORWARD_PORT(_gport) 240 241 242 /* 243 * Functions 244 */ 245 246 /* 247 * GENERAL GPORT MGMT FUNCTIONS 248 */ 249 250 251 /* 252 * Function: 253 * _bcm_dpp_gport_mgmt_init 254 * Purpose: 255 * init Gport module 256 * Parameters: 257 * Note: 258 * Returns: 259 * BCM_E_XXX 260 */ 261 262 int 263 _bcm_dpp_gport_mgmt_init(int unit); 264 265 extern int 266 _bcm_dpp_gport_mgmt_sw_state_cleanup(int unit); 267 268 269 /* 270 * Gport compare type information, 271 * Used to specify the criteria for gport compare 272 */ 273 typedef enum _bcm_dpp_gport_compare_type_s { 274 _bcmDppGportCompareTypeSystemPort=0, /* compare system port */ 275 _bcmDppGportCompareTypeInLif=1, /* compare Global In Lif */ 276 _bcmDppGportCompareTypeOutLif=2 /* compare Global Out Lif */ 277 } _bcm_dpp_gport_compare_type_e; 278 279 /* 280 * Function: 281 * _bcm_dpp_gport_compare 282 * Description: 283 * compare two gports 284 * Parameters: 285 * unit - [IN] DPP device unit number (driver internal). 286 * gport1 - [IN] general port 1 287 * gport2 - [IN] general port 2 288 * is_equal - [OUT] result of comparison 289 * Returns: 290 * BCM_E_XXX 291 */ 292 int 293 _bcm_dpp_gport_compare(int unit, bcm_gport_t gport1, bcm_gport_t gport2, _bcm_dpp_gport_compare_type_e type, uint8 * is_equal); 294 295 /* 296 * given vpn and iter return next gport-value in vpn 297 * caller still need to call 298 */ 299 int _bcm_dpp_vpn_get_next_gport( 300 int unit, 301 bcm_vpn_t vpn, /* if -1 then get next gport belongs to any vsi */ 302 int *iter, 303 bcm_gport_t *port_val, 304 int *cur_vsi /* the vsi of the return LIF*/ 305 ); 306 307 /* Gport parse type */ 308 typedef enum _bcm_dpp_gport_parse_type_s { 309 _bcmDppGportParseTypeProtectedFec=0, /* Fec used for bundle protection */ 310 _bcmDppGportParseTypeEncap, /* LIF ID */ 311 _bcmDppGportParseTypeMC, /* Multicast-ID */ 312 _bcmDppGportParseTypeSimple, /* Simple , physical */ 313 _bcmDppGportParseTypeForwardFec, /* Fec used for forwarding and not protected */ 314 _bcmDppGportParseTypePushProfile /* Push-profile ID, for PWE application*/ 315 } _bcm_dpp_gport_parse_type_e; 316 317 /* Additional information on parsing */ 318 #define _BCM_DPP_GPORT_PARSE_PRIMARY (1 << 0) /* May be valid only when type is MC */ 319 #define _BCM_DPP_GPORT_PARSE_SECONDARY (1 << 1) /* May be valid only when type is MC */ 320 #define _BCM_DPP_GPORT_PARSE_INGRESS_ONLY (1 << 2) /* May be valid only when type is ENCAP */ 321 #define _BCM_DPP_GPORT_PARSE_EGRESS_ONLY (1 << 3) /* May be valid only when type is ENCAP */ 322 323 typedef struct _bcm_dpp_gport_parse_info_s { 324 _bcm_dpp_gport_parse_type_e type; /* type of the object */ 325 int val; /* Object ID */ 326 uint32 flags; /* Additional information on object: _BCM_DPP_GPORT_PARSE_XXX */ 327 } _bcm_dpp_gport_parse_info_t; 328 /* 329 * Function: 330 * _bcm_dpp_gport_parse 331 * Description: 332 * Parse gport-id encoding to indicate the type of the object and its value. 333 * Done only according to gport-id encoding (without any SW DB). 334 * Input: gport 335 * Output: Structure gport_parse includes: 336 * Type: _bcmDppGportParseTypeProtectedFec, Val: FEC-ID, Flags: None 337 * Type: _bcmDppGportParseTypeForwardFec, Val: FEC-ID, Flags: None 338 * Type: _bcmDppGportParseTypeMC, Val: MC-ID, Flags: Primary/Secondary 339 * Type: _bcmDppGportParseTypeEncap, Val: LIF-ID, Flags: Ingress/Egress Only 340 * Type: _bcmDppGportParseTypeSimple Val: physical-port 341 * Type: _bcmDppGportParseTypePushProfile Val: Push-profile ID 342 * Note: 343 * For more encoding information of gport see drv.h 344 */ 345 int _bcm_dpp_gport_parse(int unit, bcm_gport_t port, _bcm_dpp_gport_parse_info_t *gport_parse_info); 346 347 int _bcm_dpp_gport_is_protected(int unit, bcm_gport_t gport, int *is_protected); 348 349 /* if set then don't check if gport already exist, should be in construction */ 350 #define _BCM_DPP_GPORT_RESOLVE_FLAG_NO_CHECK (0x1) 351 352 /* 353 * Should be internal function. 354 * Note: Structure should be used only when gport is supposed to be located in forwarding databases. 355 * For example GPORT of symetric AC (VLAN-Port) may reside in MACT, MC-DB , etc. 356 * But when GPORT of AC is assymetric (INGRESS / EGRESS ONLY) and used only for VLAN translation then no forwarding information is needed 357 */ 358 int 359 _bcm_dpp_gport_resolve(int unit, bcm_gport_t gport, int flags, SOC_SAND_PP_DESTINATION_ID *dest_id, int *encap_id,_bcm_dpp_gport_resolve_type_e *gport_type); 360 361 362 typedef struct _bcm_dpp_gport_info_s { 363 bcm_pbmp_t pbmp_local_ports; 364 bcm_port_t local_port; /* one of the ports in pbmp_local_ports*/ 365 uint32 sys_port; 366 uint32 flags; 367 int lane; 368 int phyn; 369 } _bcm_dpp_gport_info_t; 370 371 #define _BCM_DPP_GPORT_INFO_F_IS_LOCAL_PORT 0x01 372 #define _BCM_DPP_GPORT_INFO_F_IS_LAG 0x02 373 #define _BCM_DPP_GPORT_INFO_F_IS_SYS_SIDE 0x08 374 #define _BCM_DPP_GPORT_INFO_F_IS_BLACK_HOLE 0x10 375 376 #define _BCM_DPP_GPORT_INFO_IS_LOCAL_PORT(gport_info) (gport_info.flags & _BCM_DPP_GPORT_INFO_F_IS_LOCAL_PORT ? 1: 0) 377 #define _BCM_DPP_GPORT_INFO_IS_LAG(gport_info) (gport_info.flags & _BCM_DPP_GPORT_INFO_F_IS_LAG ? 1: 0) 378 #define _BCM_DPP_GPORT_INFO_IS_SYS_SIDE(gport_info) (gport_info.flags & _BCM_DPP_GPORT_INFO_F_IS_SYS_SIDE ? 1: 0) 379 380 /* 381 * Function: 382 * _bcm_dpp_gport_to_phy_port 383 * Description: 384 * map gport to PPD local and system port 385 * Parameters: 386 * unit - [IN] DPP device unit number (driver internal). 387 * gport - [IN] general port 388 * operations - [IN] see _BCM_DPP_GPORT_TO_PHY_OP_... 389 * gport_info - [OUT] Retrive information 390 * Returns: 391 * BCM_E_XXX 392 */ 393 394 #define _BCM_DPP_GPORT_TO_PHY_OP_RETRIVE_SYS_PORT 0x1 395 #define _BCM_DPP_GPORT_TO_PHY_OP_LOCAL_IS_MANDATORY 0x2 396 #define _BCM_DPP_GPORT_TO_PHY_OP_IGNORE_DISABLED_PORTS 0x4 397 int 398 _bcm_dpp_gport_to_phy_port(int unit, bcm_gport_t gport, uint32 operations, _bcm_dpp_gport_info_t* gport_info); 399 400 /* given gport, return if it's local in this unit */ 401 int 402 _bcm_dpp_gport_is_local(int unit, bcm_gport_t port, int *is_local); 403 404 405 406 /* 407 * L2 INTERFACE FUNCTIONS 408 */ 409 410 /* Internal functions for l2 interface APIs (vlan_port_create and mpld_port_add) */ 411 int _bcm_dpp_gport_l2_intf_determine_ingress_egress(bcm_gport_t gport_id, uint8 *is_ingress, uint8 *is_egress); 412 413 int _bcm_dpp_gport_l2_intf_calculate_act_fec(void *gport, int *act_fec, int gport_type); 414 415 int _bcm_dpp_gport_l2_intf_calculate_port_id(int unit, int act_fec, SOC_PPC_LIF_ID global_lif_id, void *gport, int gport_type); 416 417 int _bcm_dpp_gport_l2_intf_get_global_lif_from_port_id(void *gport, uint8 is_protected, uint8 is_mc_ingress, SOC_PPC_LIF_ID *global_lif_id, int gport_type); 418 419 int _bcm_dpp_gport_l2_intf_ingress_egress_only_validation(void *gport, uint8 validate, uint8 *is_ingress, uint8 *is_egress, int gport_type); 420 421 int _bcm_dpp_gport_l2_intf_protection_validation(int unit, void *gport, int gport_type, uint8 validate, int *is_protected, uint8 *is_ingress_protected, 422 uint8 *is_mc_ingress, uint8 *is_1_plus_1, uint8 *is_egress_protected); 423 424 int _bcm_dpp_gport_l2_intf_gport_has_remote_destination(int unit, bcm_gport_t gport_id, uint8 *remote_destination); 425 426 427 int _bcm_dpp_lif_to_gport( 428 int unit, 429 int lif_id, /* InLIF ID */ 430 uint32 flags, 431 bcm_gport_t *gport_id 432 ); 433 434 /* 435 * FORWARDING INFORMATION FUNCTIONS 436 */ 437 438 /* 439 * Function: 440 * _bcm_dpp_gport_to_port_encap 441 * Description: 442 * map gport to forwarding info <phy-port (can be FEC) and encap that store LIF or EEI) 443 * Parameters: 444 * unit - [IN] DPP device unit number (driver internal). 445 * gport - [IN] general port 446 * dest_port - [OUT] dest_port is physical TM port or FEC. i.e. pp-destination 447 * encap_id - [OUT] encap-info includes eei or outlif 448 * Returns: 449 * BCM_E_XXX 450 */int 451 _bcm_dpp_gport_to_port_encap(int unit, bcm_gport_t gport, int *dest_port, int *encap_id); 452 /* 453 * Function: 454 * _bcm_dpp_gport_encap_to_fwd_decision 455 * Description: 456 * Parse gport+encap to soc-ppd-forwarding decision 457 * Parameters: 458 * unit - [IN] DPP device unit number (driver internal). 459 * gport - [IN] general port 460 * encap_info - [IN] encap_id EEI or outlif. 461 * if invalid then 462 * fwd_decsion - [OUT] PPD forwarding decision 463 * Returns: 464 * BCM_E_XXX 465 */ 466 int 467 _bcm_dpp_port_encap_to_fwd_decision(int unit, bcm_gport_t gport, int encap_id, SOC_PPC_FRWRD_DECISION_INFO *fwd_decsion); 468 469 470 /* 471 * Function: 472 * _bcm_dpp_gport_and_encap_from_fwd_decision 473 * Description: 474 * Parse soc-ppd-forwarding decision to gport+encap 475 * Parameters: 476 * unit - [IN] DPP device unit number (driver internal). 477 * gport - [OUT] general port 478 * encap_id - [OUT] encap_id EEI or outlif. 479 * if invalid then 480 * fwd_decsion - [IN] PPD forwarding decision 481 * encap_usage - [IN] AC,PWE,MIM, General, -1 in case encap is not required 482 * force_destination - [IN] Return: gport as destination port (not outlif) + encap_id 483 * Returns: 484 * BCM_E_XXX 485 */ 486 int 487 _bcm_dpp_gport_and_encap_from_fwd_decision(int unit, bcm_gport_t *gport, int *encap_id, SOC_PPC_FRWRD_DECISION_INFO *fwd_decsion, uint32 encap_usage, uint8 force_destination); 488 489 /* 490 * Function: 491 * _bcm_dpp_gport_to_fwd_decision 492 * Description: 493 * Parse gport 494 * Parameters: 495 * unit - [IN] DPP device unit number (driver internal). 496 * gport - [IN] general port 497 * encap_id - [IN] encap_id considered only if gport is logical port 498 * fwd_decsion - [OUT] PPD forwarding decision 499 * Returns: 500 * BCM_E_XXX 501 */ 502 int 503 _bcm_dpp_gport_to_fwd_decision(int unit, bcm_gport_t gport, SOC_PPC_FRWRD_DECISION_INFO *fwd_decsion); 504 505 /* 506 * Function: 507 * _bcm_dpp_gport_to_sand_pp_dest 508 * Description: 509 * convert gport from soc_sand-pp-destination 510 * Parameters: 511 * unit - [IN] DPP device unit number (driver internal). 512 * gport - [IN] general port 513 * dest_id - [IN] SOC_SAND destination 514 * Returns: 515 * BCM_E_XXX 516 */ 517 int 518 _bcm_dpp_gport_to_sand_pp_dest(int unit, bcm_gport_t gport, SOC_SAND_PP_DESTINATION_ID *dest_id); 519 520 521 /* 522 * Function: 523 * _bcm_dpp_gport_to_fwd_decision 524 * Description: 525 * convert gport to forwardubg decision (destination + editting information) 526 * Parameters: 527 * unit - [IN] DPP device unit number (driver internal). 528 * gport - [IN] general port 529 * encap_id - [IN] encap_id considered only if gport is logical port 530 * fwd_decsion - [OUT] PPD forwarding decision 531 * Returns: 532 * BCM_E_XXX 533 */ 534 int 535 _bcm_dpp_gport_to_tm_dest_info(int unit, bcm_gport_t gport, SOC_TMC_DEST_INFO *soc_petra_dest_info); 536 537 /* 538 * Function: 539 * _bcm_dpp_gport_to_tm_dest_info 540 * Description: 541 * convert gport from TM dest information 542 * Parameters: 543 * unit - [IN] DPP device unit number (driver internal). 544 * gport - [OUT] general port 545 * soc_petra_dest_info - [OUT] Soc_petra destination info 546 * Returns: 547 * BCM_E_XXX 548 */ 549 int 550 _bcm_dpp_gport_from_tm_dest_info(int unit, bcm_gport_t *gport, SOC_TMC_DEST_INFO *soc_petra_dest_info); 551 552 /* 553 * Function: 554 * _bcm_dpp_gport_from_sand_pp_dest 555 * Description: 556 * convert gport from soc_sand-pp-destination 557 * Parameters: 558 * unit - [IN] DPP device unit number (driver internal). 559 * gport - [IN] general port 560 * dest_id - [IN] SOC_SAND destination 561 * Returns: 562 * BCM_E_XXX 563 */ 564 int 565 _bcm_dpp_gport_from_sand_pp_dest(int unit, bcm_gport_t *gport, SOC_SAND_PP_DESTINATION_ID *dest_id); 566 567 568 569 /* 570 * SOFTWARE RESOURCES FUNCTIONS 571 */ 572 573 /* _BCM_DPP_GPORT_SW_RESOURCES_XXX information, represents which SW resource to retreive */ 574 #define _BCM_DPP_GPORT_SW_RESOURCES_INGRESS (1 << 0) /* Retreive Ingress SW resources */ 575 #define _BCM_DPP_GPORT_SW_RESOURCES_EGRESS (1 << 1) /* Retreive Egress SW resources */ 576 577 /* Use this macros when iterating over the egress sw resources. 578 * See documenation of ARAD_PP_EG_ENCAP_EEDB_INDEX_TO_OUTLIF for details on this macro. 579 */ 580 581 #define _BCM_DPP_GPORT_LIF_SW_RESOURCES_EGRESS_ITER_START(_unit) \ 582 (ARAD_PP_EG_ENCAP_EEDB_INDEX_TO_OUTLIF(_unit, 0)) 583 584 #define _BCM_DPP_GPORT_LIF_SW_RESOURCES_EGRESS_ITER_END(_unit) \ 585 (ARAD_PP_EG_ENCAP_EEDB_INDEX_TO_OUTLIF(_unit, SOC_DPP_DEFS_GET(unit, nof_out_lifs))) 586 587 /* 588 * Function: 589 * _bcm_dpp_local_lif_to_sw_resources 590 * Description: 591 * map local_lif to its SW resources 592 * Parameters: 593 * unit - [IN] DPP device unit number (driver internal). 594 * local_in_lif - [IN] in lif 595 * local_out_lif - [IN] out lif 596 * flags - [IN] See .h for _BCM_DPP_GPORT_SW_RESOURCES_XXX information 597 * gport_sw_resources [OUT] GPORT SW resources. See .h for structure information 598 * Notes: 599 */ 600 int 601 _bcm_dpp_local_lif_to_sw_resources(int unit, int local_in_lif, int local_out_lif, uint32 flags, _bcm_dpp_gport_sw_resources *gport_sw_resources); 602 603 /* 604 * Function: 605 * _bcm_dpp_local_lif_sw_resources_set 606 * Description: 607 * fill set SW resources according to lif 608 * Parameters: 609 * unit - [IN] DPP device unit number (driver internal). 610 * local_in_lif - [IN] in lif 611 * local_out_lif - [IN] out lif 612 * flags - [IN] See .h for _BCM_DPP_GPORT_SW_RESOURCES_XXX information 613 * gport_sw_resources [OUT] GPORT SW resources. See .h for structure information 614 * Notes: 615 */ 616 int 617 _bcm_dpp_local_lif_sw_resources_set(int unit, int in_local_lif, int local_out_lif, uint32 flags, _bcm_dpp_gport_sw_resources *gport_sw_resources); 618 619 /* 620 * Function: 621 * _bcm_dpp_lif_sw_resources_delete 622 * Description: 623 * delete SW resources according to lif 624 * Parameters: 625 * unit - [IN] DPP device unit number (driver internal). 626 * local_in_lif - [IN] in lif 627 * local_out_lif - [IN] out lif 628 * flags - [IN] See .h for _BCM_DPP_GPORT_SW_RESOURCES_XXX information 629 * Notes: 630 */ 631 int 632 _bcm_dpp_local_lif_sw_resources_delete(int unit, int local_in_lif, int local_out_lif, uint32 flags); 633 634 /* LIF Usage */ 635 int _bcm_dpp_local_lif_sw_resources_lif_usage_get(int unit, int local_in_lif, int local_out_lif, _bcm_lif_type_e *in_lif_usage, _bcm_lif_type_e *out_lif_usage); 636 int _bcm_dpp_local_lif_sw_resources_lif_usage_set(int unit, int in_lif, int out_lif, _bcm_lif_type_e in_lif_usage, _bcm_lif_type_e out_lif_usage); 637 int _bcm_dpp_lif_sw_resources_gport_usage_get(int unit, bcm_gport_t gport, _bcm_lif_type_e *used_type); 638 639 /* Learn (InLIF only) */ 640 int _bcm_dpp_local_lif_sw_resources_learn_gport_set(int unit, int local_in_lif, int learn_gport); 641 int _bcm_dpp_local_lif_sw_resources_learn_gport_get(int unit, int local_in_lif, int * learn_gport); 642 643 /* store and get vsi */ 644 int _bcm_dpp_local_lif_sw_resources_vsi_set(int unit, int local_in_lif, int vsi); 645 int _bcm_dpp_local_lif_sw_resources_vsi_get(int unit, int local_in_lif, int *vsi); 646 647 /* get flags */ 648 int _bcm_dpp_local_outlif_sw_resources_flags_get(int unit, int local_out_lif, uint32 *flags); 649 650 /* *** FEC SW DB ***/ 651 652 /* Mark the FEC as remote */ 653 int 654 bcm_dpp_gport_mgmt_fec_remote_destination_set( 655 int unit, 656 uint32 fec_id, 657 uint8 is_remote); 658 659 /* Add FEC to GPORT mapping */ 660 int 661 bcm_dpp_gport_mgmt_sw_resources_fec_to_gport_set( 662 int unit, 663 uint32 fec_id, 664 uint32 gport); 665 666 /* Get FEC to GPORT mapping */ 667 int 668 bcm_dpp_gport_mgmt_sw_resources_fec_to_gport_get( 669 int unit, 670 uint32 fec_id, 671 bcm_gport_t *gport); 672 673 /* 674 * HARDWARE RESOURCES FUNCTIONS 675 */ 676 677 typedef struct { 678 int global_in_lif; /* Global-LIF, Invalid when not exist */ 679 int global_out_lif; /* Global-LIF, Invalid when not exist */ 680 int local_in_lif; /* Local-LIF, Invalid when not exist */ 681 int local_out_lif; /* Local-LIF, Invaild when not exist */ 682 int fec_id; /* FEC, invalid when not exist */ 683 } _bcm_dpp_gport_hw_resources; 684 685 /* _BCM_DPP_GPORT_HW_RESOURCES_XXX information, represents which HW resource to retreive */ 686 #define _BCM_DPP_GPORT_HW_RESOURCES_FEC (1 << 0) /* Retreive FEC resource */ 687 #define _BCM_DPP_GPORT_HW_RESOURCES_GLOBAL_LIF_INGRESS (1 << 1) /* Retreive Ingress Global LIF */ 688 #define _BCM_DPP_GPORT_HW_RESOURCES_GLOBAL_LIF_EGRESS (1 << 2) /* Retreive Egress Global LIF */ 689 #define _BCM_DPP_GPORT_HW_RESOURCES_LOCAL_LIF_INGRESS (1 << 3) /* Retreive Ingress Local LIF */ 690 #define _BCM_DPP_GPORT_HW_RESOURCES_LOCAL_LIF_EGRESS (1 << 4) /* Retreive Egress Local LIF */ 691 #define _BCM_DPP_GPORT_HW_RESOURCES_STRICT_CHECK (1 << 5) /* Return error in case required and invalid resource */ 692 /* Retreive Local LIF resources */ 693 #define _BCM_DPP_GPORT_HW_RESOURCES_LOCAL_LIF (_BCM_DPP_GPORT_HW_RESOURCES_LOCAL_LIF_INGRESS | _BCM_DPP_GPORT_HW_RESOURCES_LOCAL_LIF_EGRESS) 694 /* Retreive Global LIF resources */ 695 #define _BCM_DPP_GPORT_HW_RESOURCES_GLOBAL_LIF (_BCM_DPP_GPORT_HW_RESOURCES_GLOBAL_LIF_INGRESS | _BCM_DPP_GPORT_HW_RESOURCES_GLOBAL_LIF_EGRESS) 696 /* Retreive Local and Global LIF resources */ 697 #define _BCM_DPP_GPORT_HW_RESOURCES_LOCAL_AND_GLOBAL_LIF (_BCM_DPP_GPORT_HW_RESOURCES_GLOBAL_LIF | _BCM_DPP_GPORT_HW_RESOURCES_LOCAL_LIF) 698 699 /* 700 * Function: 701 * _bcm_dpp_gport_to_hw_resources 702 * Description: 703 * map gport to its HW resources (LIF, FEC) 704 * Parameters: 705 * unit - [IN] DPP device unit number (driver internal). 706 * gport - [IN] general port 707 * flags - [IN] See .h for _BCM_DPP_GPORT_HW_RESOURCES_XXX information 708 * gport_hw_resources [OUT] GPORT HW resources. See .h for structure information 709 * Notes: 710 */ 711 int 712 _bcm_dpp_gport_to_hw_resources(int unit, bcm_gport_t gport, uint32 flags, _bcm_dpp_gport_hw_resources *gport_hw_resources); 713 714 /* 715 * Function: 716 * _bcm_dpp_gport_from_hw_resources 717 * Description: 718 * get gport from its HW resources (LIF, FEC) 719 * Parameters: 720 * unit - [IN] DPP device unit number (driver internal). 721 * gport - [OUT] general port 722 * flags - [IN] See .h for _BCM_DPP_GPORT_HW_RESOURCES_XXX information 723 * gport_hw_resources [IN] GPORT HW resources. See .h for structure information 724 * Notes: 725 */ 726 int 727 _bcm_dpp_gport_from_hw_resources(int unit, bcm_gport_t *gport, uint32 flags, _bcm_dpp_gport_hw_resources *gport_hw_resources); 728 729 /* 730 * Function: 731 * _bcm_dpp_gport_alloc_global_and_local_lif 732 * Purpose: 733 * Allocates global lif and local lifs according to given arguements: 734 * If in_lif_data == NULL && out_lif_data == NULL returns error. 735 * If in_lif_data != NULL, allocates a local in lif and a global in lif. 736 * If out_lif_data != NULL, allocates a local out lif, and if lif is mapped allocates a global lif and writes to GLEM. 737 * 738 * Parameters: 739 * unit - (IN) Device Number 740 * flags - (IN) Only BCM_DPP_AM_FLAG_ALLOC_WITH_ID is supported. 741 * global_lif_id - (INOUT) Fill with the global lif id if WITH_ID, otherwise will be filled with the allocated globall if id. 742 * local_inlif_info - (INOUT) Local inlif data, will be filled with the allocated local in lif id. 743 * local_outlif_info - (INOUT) Local outlif data, will be filled with the allocated local out lif id. 744 * 745 * Returns: 746 * BCM_E_XXX 747 */ 748 int 749 _bcm_dpp_gport_alloc_global_and_local_lif(int unit, 750 uint32 flags, 751 int *global_lif_id, 752 bcm_dpp_am_local_inlif_info_t *local_in_lif_info, 753 bcm_dpp_am_local_out_lif_info_t *local_out_lif_info); 754 755 /* 756 * Function: 757 * _bcm_dpp_gport_delete_global_and_local_lif 758 * Purpose: 759 * Given global and local lif, removes them. If remove_glem_entry is set, removes the glem entry according to global lif as well. 760 * Parameters: 761 * unit - (IN) Device Number 762 * global_lif - (IN) Global lif to be deallocated. 763 * local_inlif_id - (IN) Local inlif to be deallocated. 764 * local_outlif_id - (IN) Local outlif to be deallocated. 765 * 766 * Returns: 767 * BCM_E_XXX 768 */ 769 int 770 _bcm_dpp_gport_delete_global_and_local_lif(int unit, int global_lif, int local_inlif_id, int local_outlif_id); 771 772 773 /* 774 * Function: 775 * _bcm_dpp_gport_to_global_and_local_lif 776 * Purpose: 777 * Given a gport id, returns the global and local lifs for this gport, as well as fec and remote lif indication. 778 * 779 * Parameters: 780 * unit - (IN) Device number 781 * gport_id - (IN) Gport to be checked. 782 * global_lif - (OUT) Global lif for this gport. 783 * local_in_lif - (OUT) Local in lif for this gport. 784 * local_out_lif - (OUT) LOCAL out lif for this gport. If port is a pon vlan port and soc is arad b1 and below, 785 * this would hold the out ac. 786 * fec_id - (OUT) Fec for this gport. 787 * is_local - (OUT) Local/remote lif indication. 788 * 789 * Returns: 790 * BCM_E_NONE - If the value was retrieved successfully.. 791 * BCM_E_* - Otherwise. 792 */ 793 int _bcm_dpp_gport_to_global_and_local_lif(int unit, 794 bcm_gport_t gport_id, 795 int *global_lif, 796 int *local_in_lif, 797 int *local_out_lif, 798 int *fec_id, 799 int *is_local); 800 801 /* 802 * Function: 803 * _bcm_dpp_local_lif_to_vsi 804 * Purpose: 805 * Given lif return VSI this lif is assoicated to, return -1 if there is no VSI 806 * 807 * Parameters: 808 * unit - (IN) Device Number 809 * local_lif - (IN) Lif to check. 810 * vsi - (OUT) Fill with the VSI the lif is assosiated with. 811 * sw_state - (IN) If set retrieve from SW state (optimized call). 812 * gport - (OUT) Return gport as well. Valid for mp and p2p, for p2p read from SW db. 813 * 814 * Returns: 815 * BCM_E_XXX 816 */ 817 int _bcm_dpp_local_lif_to_vsi( 818 int unit, 819 int local_lif, 820 int *vsi, 821 bcm_gport_t *gport 822 ); 823 824 825 826 /* 827 * MISC functions 828 */ 829 830 /* VLAN HASH */ 831 832 int 833 _bcm_dpp_sw_db_hash_vlan_find(int unit, sw_state_htb_key_t key, sw_state_htb_data_t data, int remove); 834 835 int 836 _bcm_dpp_sw_db_hash_vlan_insert(int unit, sw_state_htb_key_t key, sw_state_htb_data_t data); 837 838 int 839 _bcm_dpp_sw_db_hash_vlan_iterate(int unit, sw_state_htb_cb_t restore_cb); 840 841 842 /* 1+1 protection*/ 843 int 844 _bcm_dpp_gport_plus_1_mc_to_id(int mc_id, int is_primary, int *gport_val); 845 int 846 _bcm_dpp_gport_plus_1_id_to_mc(int gport_val, int *mc_id , int *is_primary); 847 848 849 /* FEC handling */ 850 #define BCM_DPP_GPORT_TYPE_EGRESS_IF (0x50) 851 852 int 853 _bcm_dpp_l2_gport_fill_fec(int unit, void *gport, int gport_type, SOC_PPC_FEC_ID fec_id, SOC_PPC_FRWRD_FEC_ENTRY_INFO *work_fec); 854 855 int 856 _bcm_dpp_l2_fec_fill_gport(int unit, SOC_PPC_FEC_ID fec_id, void *gport, int gport_type); 857 858 #endif /* INCLUDE_GPORT_MGMT_H */ 859