l3.c (4548B)
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: l3.c 8 * Purpose: Greyhound2 L3 function implementations 9 */ 10 11 #include <soc/defs.h> 12 #include <sal/core/libc.h> 13 14 #if defined(BCM_GREYHOUND2_SUPPORT) && defined(INCLUDE_L3) 15 #include <bcm/l3.h> 16 #include <bcm_int/esw/triumph2.h> 17 #include <bcm_int/esw/greyhound2.h> 18 19 /* 20 * Function: 21 * bcmi_gh2_l3_intf_qos_set 22 * Purpose: 23 * Set L3 Interface QoS parameters 24 * Parameters: 25 * unit - (IN) Unit number 26 * l3_if_entry_p - (IN) Pointer to buffer 27 * intf_info - (IN) Intf_info 28 * Returns: 29 * BCM_E_XXX. 30 */ 31 int 32 bcmi_gh2_l3_intf_qos_set( 33 int unit, 34 uint32 *l3_if_entry_p, 35 _bcm_l3_intf_cfg_t *intf_info) 36 { 37 soc_mem_t mem; 38 int hw_map_idx = 0; 39 40 if (!soc_feature(unit, soc_feature_vxlan_lite_riot)) { 41 return BCM_E_UNAVAIL; 42 } 43 44 /* Input parameters check */ 45 if ((NULL == l3_if_entry_p) || (NULL == intf_info)) { 46 return BCM_E_PARAM; 47 } 48 49 mem = EGR_L3_INTFm; 50 51 /* GH2 doesn't support L3 Interface OVLAN/IVLAN QoS parameters */ 52 if (intf_info->vlan_qos.flags & BCM_L3_INTF_QOS_OUTER_VLAN_PRI_COPY || 53 intf_info->vlan_qos.flags & BCM_L3_INTF_QOS_OUTER_VLAN_PRI_SET || 54 intf_info->vlan_qos.flags & BCM_L3_INTF_QOS_OUTER_VLAN_PRI_REMARK || 55 intf_info->vlan_qos.flags & BCM_L3_INTF_QOS_INNER_VLAN_PRI_COPY || 56 intf_info->vlan_qos.flags & BCM_L3_INTF_QOS_INNER_VLAN_PRI_SET || 57 intf_info->vlan_qos.flags & BCM_L3_INTF_QOS_INNER_VLAN_PRI_REMARK) { 58 return BCM_E_PARAM; 59 } 60 61 if (intf_info->dscp_qos.flags & BCM_L3_INTF_QOS_DSCP_COPY) { 62 /* DSCP_SELf = 0x0: Do not modify DSCP */ 63 soc_mem_field32_set(unit, mem, l3_if_entry_p, DSCP_SELf, 0x0); 64 } else if (intf_info->dscp_qos.flags & BCM_L3_INTF_QOS_DSCP_SET) { 65 /* DSCP_SELf = 0x1: Use DSCP from this table */ 66 soc_mem_field32_set(unit, mem, l3_if_entry_p, DSCP_SELf, 0x1); 67 soc_mem_field32_set(unit, mem, l3_if_entry_p, 68 DSCPf, intf_info->dscp_qos.dscp); 69 } else if (intf_info->dscp_qos.flags & BCM_L3_INTF_QOS_DSCP_REMARK) { 70 /* DSCP_SELf = 0x2: Use DSCP_MAPPING_PTR from this table */ 71 soc_mem_field32_set(unit, mem, l3_if_entry_p, DSCP_SELf, 0x2); 72 73 BCM_IF_ERROR_RETURN( 74 _bcm_tr2_qos_id2idx(unit, intf_info->dscp_qos.qos_map_id, 75 &hw_map_idx)); 76 soc_mem_field32_set(unit, mem, l3_if_entry_p, 77 DSCP_MAPPING_PTRf, hw_map_idx); 78 } else { 79 /* DSCP_SELf = 0x3: Pick up from packet */ 80 soc_mem_field32_set(unit, mem, l3_if_entry_p, DSCP_SELf, 0x3); 81 } 82 83 return BCM_E_NONE; 84 } 85 86 /* 87 * Function: 88 * bcmi_gh2_l3_intf_qos_get 89 * Purpose: 90 * Get L3 Interface QoS parameters 91 * Parameters: 92 * unit - (IN) Unit number 93 * l3_if_entry_p - (IN) Pointer to buffer 94 * intf_info - (OUT) Intf_info 95 * Returns: 96 * BCM_E_XXX. 97 */ 98 int 99 bcmi_gh2_l3_intf_qos_get( 100 int unit, 101 uint32 *l3_if_entry_p, 102 _bcm_l3_intf_cfg_t *intf_info) 103 { 104 soc_mem_t mem; 105 uint32 dscp_sel = 0; 106 int hw_map_idx = 0; 107 108 if (!soc_feature(unit, soc_feature_vxlan_lite_riot)) { 109 return BCM_E_UNAVAIL; 110 } 111 112 /* Input parameters check */ 113 if ((NULL == l3_if_entry_p) || (NULL == intf_info)) { 114 return BCM_E_PARAM; 115 } 116 117 mem = EGR_L3_INTFm; 118 119 dscp_sel = soc_mem_field32_get(unit, mem, l3_if_entry_p, DSCP_SELf); 120 121 if (dscp_sel == 0x0) { 122 /* Do not modify DSCP */ 123 intf_info->dscp_qos.flags |= BCM_L3_INTF_QOS_DSCP_COPY; 124 } else if (dscp_sel == 0x1) { 125 /* Use DSCP from this table */ 126 intf_info->dscp_qos.flags |= BCM_L3_INTF_QOS_DSCP_SET; 127 intf_info->dscp_qos.dscp = 128 soc_mem_field32_get(unit, mem, l3_if_entry_p, DSCPf); 129 } else if (dscp_sel == 0x2) { 130 /* Use DSCP_MAPPING_PTR from this table */ 131 intf_info->dscp_qos.flags |= BCM_L3_INTF_QOS_DSCP_REMARK; 132 hw_map_idx = 133 soc_mem_field32_get(unit, mem, l3_if_entry_p, 134 DSCP_MAPPING_PTRf); 135 BCM_IF_ERROR_RETURN( 136 _bcm_tr2_qos_idx2id(unit, hw_map_idx, 137 _BCM_QOS_MAP_TYPE_EGR_DSCP_TABLE, 138 &intf_info->dscp_qos.qos_map_id)); 139 } 140 141 return BCM_E_NONE; 142 } 143 144 #endif /* BCM_GREYHOUND2_SUPPORT && INCLUDE_L3 */