subport.c (5372B)
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: subport.c 8 * Purpose: Subport CoE related functions. 9 */ 10 11 #include <soc/defs.h> 12 #include <sal/core/libc.h> 13 #include <shared/bsl.h> 14 15 #include <soc/drv.h> 16 #include <soc/mem.h> 17 #include <soc/util.h> 18 #include <soc/debug.h> 19 #include <bcm/error.h> 20 #include <bcm/subport.h> 21 22 #include <bcm_int/esw/subport.h> 23 #include <bcm_int/esw_dispatch.h> 24 #include <bcm_int/esw/triumph.h> 25 #include <bcm_int/esw/triumph2.h> 26 #include <bcm_int/esw/xgs5.h> 27 #include <bcm_int/esw/trident3.h> 28 29 /* 30 * Function Vector 31 */ 32 static bcm_esw_subport_drv_t bcm_td3_subport_drv = { 33 34 #if defined(BCM_TRIUMPH2_SUPPORT) && defined(INCLUDE_L3) 35 /* subport_init */ bcm_tr2_subport_init, 36 /* subport_group_create */ bcm_tr2_subport_group_create, 37 /* subport_group_get */ bcm_tr2_subport_group_get, 38 /* subport_group_traverse */ NULL, 39 /* subport_group_destroy */ bcm_tr2_subport_group_destroy, 40 /* subport_linkphy_config_set */ NULL, 41 /* subport_linkphy_config_get */ NULL, 42 /* subport_port_add */ bcm_tr2_subport_port_add, 43 /* subport_port_get */ bcm_tr2_subport_port_get, 44 /* subport_port_traverse */ bcm_tr2_subport_port_traverse, 45 /* subport_port_stat_set */ NULL, 46 /* subport_port_stat_get */ NULL, 47 /* subport_port_delete */ bcm_tr2_subport_port_delete, 48 /* subport_cleanup */ bcm_tr2_subport_cleanup, 49 #else 50 NULL, NULL, NULL, NULL, NULL, 51 NULL, NULL, NULL, NULL, NULL, 52 NULL, NULL, NULL, NULL, 53 #endif 54 55 /* coe_init */ bcm_td3_subport_coe_init, 56 /* coe_group_create */ bcmi_xgs5_subport_coe_group_create, 57 /* coe_group_get */ bcmi_xgs5_subport_coe_group_get, 58 /* coe_group_traverse */ bcmi_xgs5_subport_coe_group_traverse, 59 /* coe_group_destroy */ bcmi_xgs5_subport_coe_group_destroy, 60 /* coe_linkphy_config_set */ NULL, 61 /* coe_linkphy_config_get */ NULL, 62 /* coe_port_add */ bcmi_xgs5_subport_coe_port_add, 63 /* coe_port_get */ bcmi_xgs5_subport_coe_port_get, 64 /* coe_port_traverse */ bcmi_xgs5_subport_coe_port_traverse, 65 /* coe_port_stat_set */ NULL, 66 /* coe_port_stat_get */ NULL, 67 /* coe_port_delete */ bcmi_xgs5_subport_coe_port_delete, 68 /* coe_cleanup */ bcmi_xgs5_subport_coe_cleanup, 69 /* subport_linkphy_rx_error_register */ NULL, 70 /* subport_linkphy_rx_error_unregister */ NULL, 71 /* subport_gport_modport_get */ bcmi_xgs5_subport_gport_modport_get 72 }; 73 74 /* 75 * Device Specific HW Tables 76 */ 77 78 /* ING Port Table */ 79 static bcmi_xgs5_subport_coe_ing_port_table_t bcmi_td3_subport_coe_ing_port_table = { 80 /* mem */ ING_DEVICE_PORTm, 81 /* port_type */ PORT_TYPEf 82 }; 83 84 /* EGR Port Table */ 85 static bcmi_xgs5_subport_coe_egr_port_table_t bcmi_td3_subport_coe_egr_port_table = { 86 /* mem */ EGR_PORTm, 87 /* port_type */ PORT_TYPEf 88 }; 89 90 /* Subport Tag SGPP Memory Table */ 91 static bcmi_xgs5_subport_coe_subport_tag_sgpp_table_t bcmi_td3_subport_coe_subport_tag_sgpp_table = { 92 /* mem */ SUBPORT_ID_TO_SGPP_MAPm, 93 /* valid */ BASE_VALIDf, 94 /* subport_tag */ SUBPORT_IDf, 95 /* subport_tag_mask */ INVALIDf, 96 /* subport_tag_namespace */ SUBPORT_ID_NAMESPACEf, 97 /* subport_tag_namespace_mask */ INVALIDf, 98 /* src_modid */ INVALIDf, /* src port and modid combined in SGPP */ 99 /* src_port */ SGPPf, 100 /* phb_enable */ PHB_ENABLEf, 101 /* int_pri */ INT_PRIf, 102 /* cng */ CNGf 103 }; 104 105 /* Modport map subport Memory Table */ 106 bcmi_xgs5_subport_coe_modport_map_subport_table_t bcmi_td3_subport_coe_modport_map_subport_table = { 107 /* mem */ MODPORT_MAP_SUBPORTm, 108 /* dest */ DESTf, 109 /* is_trunk */ ISTRUNKf, 110 /* enable */ ENABLEf, 111 }; 112 113 /* Egress subport tag dot1p Table */ 114 static bcmi_xgs5_subport_coe_egr_subport_tag_dot1p_table_t bcmi_td3_subport_coe_egr_subport_tag_dot1p_table = { 115 /* mem */ EGR_ZONE_3_DOT1P_MAPPING_TABLE_1m, 116 /* subport_tag_priority */ PRIf, 117 /* subport_tag_cfi */ CFIf 118 }; 119 120 /* HW Definitions */ 121 static bcmi_xgs5_subport_coe_hw_defs_t bcmi_td3_subport_coe_hw_defs; 122 123 int bcm_td3_subport_coe_init(int unit) 124 { 125 /* HW Definition Tables */ 126 sal_memset(&bcmi_td3_subport_coe_hw_defs, 0, sizeof(bcmi_td3_subport_coe_hw_defs)); 127 bcmi_td3_subport_coe_hw_defs.igr_port = 128 &bcmi_td3_subport_coe_ing_port_table; 129 bcmi_td3_subport_coe_hw_defs.egr_port = 130 &bcmi_td3_subport_coe_egr_port_table; 131 bcmi_td3_subport_coe_hw_defs.subport_tag_sgpp = 132 &bcmi_td3_subport_coe_subport_tag_sgpp_table; 133 bcmi_td3_subport_coe_hw_defs.modport_map_subport = 134 &bcmi_td3_subport_coe_modport_map_subport_table; 135 bcmi_td3_subport_coe_hw_defs.egr_subport_tag_dot1p = 136 &bcmi_td3_subport_coe_egr_subport_tag_dot1p_table; 137 138 /* Initialize Common XGS5 CoE module */ 139 BCM_IF_ERROR_RETURN 140 (bcmi_xgs5_subport_init(unit, &bcm_td3_subport_drv, &bcmi_td3_subport_coe_hw_defs)); 141 return 0; 142 }