range.h (7152B)
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: range.h 8 * Purpose: Internal Range module data structure definitions for the 9 * BCM library. 10 */ 11 12 #ifndef _BCM_INT_RANGE_H 13 #define _BCM_INT_RANGE_H 14 15 #include <bcm/range.h> 16 17 #include <soc/mem.h> 18 #include <bcm/types.h> 19 #include <bcm_int/esw/field.h> 20 21 /* 22 * Typedef: 23 * _range_t 24 * Purpose: 25 * Internal management of Range Checkers. 26 * 27 * rtype : Range Checker type - UDF/Outer Vlan/L4 Src Port/L4 Dst Port/ 28 * IP Pkt length 29 * rid : Range Checker ID. 30 * min : Lower range to match (inclusive) and mandatory for all range 31 * checker types. 32 * max : Upper range to match (inclusive) and mandatory for all range 33 * checker types. 34 * hw_index: Hardware index currently being used by this range checker. 35 * 36 * The fields offset/width/udf_id are applicable only when the Range 37 * Checker Type is ****bcmRangeTypeUdf****. 38 * 39 * udf_id : This is required to know UDF chunk used by this UDF can be 40 * used range checking. 41 * offset : This is the offset(in bits) for mask to apply before range 42 * check comparison with min and max values. 43 * width : This is the width(in bits) from offset specified for mask 44 * to apply before range check comparison with min and max 45 * values. 46 * 47 * ports : This is a PBMP to specify for which pipe of XGS pipeline user 48 * wants to create this range checker. 49 * User can specify a specific pipe or all pipes. User needs to 50 * call bcm_port_config_get API to get "per pipe"/"all pipe" PBMP. 51 * This parameter is mandatory for all range checker types. 52 * 53 * pipe_instance : Pipe instance 54 */ 55 typedef struct _range_s { 56 bcm_range_type_t rtype; 57 bcm_range_t rid; 58 uint32 min; 59 uint32 max; 60 int hw_index; 61 uint8 offset; 62 uint8 width; 63 bcm_udf_id_t udf_id; 64 bcm_pbmp_t ports; 65 int pipe_instance; 66 struct _range_s *next; 67 } _range_t; 68 69 70 typedef struct bcmi_xgs5_range_ctrl_s { 71 soc_mem_t range_mem; /* Tcam memory */ 72 sal_mutex_t range_mutex; /* Range lock */ 73 uint32 flags; /* misc. info */ 74 uint8 num_ranges; /* Number of Ranges existing in the system */ 75 uint32 max_ranges; /* Restrict maximum ranges */ 76 uint32 max_groups; /* Restrict maximum range groups */ 77 uint32 hw_bmap; /* HW bitmap */ 78 struct _range_s *ranges; /* List of all ranges allocated.*/ 79 int range_oper_mode; /* Range module Oper mode. */ 80 uint8 range_used_by_module; /* Range used by module: 81 0 - used by none 82 1 - used by Range module 83 2 - used by field module */ 84 SHR_BITDCL range_group_used_bitmap[SOC_MAX_NUM_PIPES]; /* Used HW masks of the range group */ 85 }bcmi_xgs5_range_ctrl_t; 86 87 /* Range Module Initialised state */ 88 extern int _bcm_xgs5_range_init[BCM_MAX_NUM_UNITS]; 89 90 extern bcmi_xgs5_range_ctrl_t *range_control[BCM_MAX_NUM_UNITS]; 91 92 #define RANGE_INIT_CHECK(unit) \ 93 do { \ 94 if (range_control[unit] == NULL) { \ 95 return BCM_E_INIT; \ 96 } \ 97 } while(0) 98 99 #define _RANGE_GROUP_MAX(u) (SOC_IS_TOMAHAWK3(u) ? 16 : 8) 100 101 #define _RANGE_ID_BASE (0) 102 #define _RANGE_ID_MAX(u) ((SOC_IS_TOMAHAWK3(u) ? 64 : 32) * (SOC_MAX_NUM_PIPES) - 1) 103 104 /* 105 * Macro: RANGE_CTRL 106 * Purpose: Range control 107 */ 108 #define RANGE_CTRL(u) range_control[u] 109 110 /* 111 * Macro: RANGE_LOCK 112 * Purpose: Lock to take the Range Mutex 113 */ 114 115 #define RANGE_LOCK(u) sal_mutex_take((RANGE_CTRL(u)->range_mutex), sal_mutex_FOREVER); 116 117 /* 118 * Macro: RANGE_UNLOCK 119 * Purpose: Release the Range Mutex 120 */ 121 122 #define RANGE_UNLOCK(u) sal_mutex_give(RANGE_CTRL(u)->range_mutex); 123 124 /* Flags for range used by module */ 125 #define RANGE_USED_BY_FIELD_MODULE 0 126 #define RANGE_USED_BY_RANGE_MODULE 1 127 128 /* Extern function declarations */ 129 extern int bcmi_xgs5_range_init(int unit); 130 extern int bcmi_xgs5_range_detach(int unit); 131 132 #ifdef BCM_WARM_BOOT_SUPPORT 133 extern int _bcm_esw_range_scache_sync(int unit); 134 extern int bcmi_xgs5_range_wb_sync(int unit); 135 #endif /* BCM_WARM_BOOT_SUPPORT */ 136 137 extern int bcm_esw_range_init(int unit); 138 extern int bcm_esw_range_detach(int unit); 139 140 extern int bcm_range_id_generate(int unit, bcm_range_t rid); 141 142 extern int bcmi_xgs5_range_create(int unit, int flags, bcm_range_config_t *range_config); 143 extern int bcmi_xgs5_range_get(int unit, bcm_range_config_t *range_config); 144 extern int bcmi_xgs5_range_destroy(int unit, bcm_range_t rid); 145 146 extern int bcmi_xgs5_range_node_get(int unit, bcm_range_config_t *range_config); 147 extern int bcmi_range_check_set(int unit, _range_t *range, int hw_index, int enable, uint16 udf_mask); 148 149 extern int bcmi_xgs5_range_oper_mode_set(int unit, bcm_range_oper_mode_t oper_mode); 150 extern int bcmi_xgs5_range_oper_mode_get(int unit, bcm_range_oper_mode_t *oper_mode); 151 152 extern int bcmi_xgs5_range_traverse(int unit, bcm_range_traverse_cb callback, void *user_data); 153 154 extern int bcmi_xgs5_range_get_hw_index(int unit, bcm_range_t rid, int *hw_index); 155 156 extern int bcmi_xgs5_range_validate_port_config(int unit, bcm_range_oper_mode_t oper_mode, bcm_pbmp_t ports, int *instance); 157 extern int bcmi_xgs5_range_validate_field_stage_oper_mode(int unit, bcm_field_group_oper_mode_t grp_oper_mode); 158 extern int bcmi_xgs5_range_validate_field_group_instance(int unit, bcm_range_t range, int instance); 159 160 extern int bcmi_xgs5_range_RangeCheckersAPIType_set (int unit, int api_type); 161 extern int bcmi_xgs5_range_RangeCheckersAPIType_get (int unit, int *api_type); 162 163 extern int bcmi_xgs5_range_group_create(int unit, bcm_range_group_config_t *range_group_config); 164 extern int bcmi_xgs5_range_group_delete(int unit, bcm_range_group_config_t *range_group_config); 165 extern int bcmi_xgs5_range_group_update(int unit, bcm_range_group_config_t *range_group_config); 166 extern int bcmi_xgs5_range_group_get(int unit, bcm_range_group_config_t *range_group_config); 167 168 extern int bcmi_xgs5_range_group_hw_idx_get( 169 int unit, 170 uint8 range_grp_id, 171 uint8 pipe_id, 172 uint8 *hw_index); 173 extern int bcmi_xgs5_range_group_id_get( 174 int unit, 175 uint8 pipe_id, 176 uint8 *range_grp_id); 177 #endif