range.h (7302B)
1 /* 2 * 3 * 4 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 5 * 6 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 7 * 8 * DO NOT EDIT THIS FILE! 9 * This file is auto-generated. 10 * Edits to this file will be lost when it is regenerated. 11 */ 12 13 #ifndef __BCM_RANGE_H__ 14 #define __BCM_RANGE_H__ 15 16 #include <bcm/types.h> 17 #include <shared/switch.h> 18 19 /* Range checker Types. */ 20 typedef enum bcm_range_type_e { 21 bcmRangeTypeL4SrcPort = 0, /* Check L4 Source port range. */ 22 bcmRangeTypeL4DstPort = 1, /* Check L4 Destination port range. */ 23 bcmRangeTypeOuterVlan = 2, /* Check Outer Vlan range. */ 24 bcmRangeTypePacketLength = 3, /* Check IP payload length range. */ 25 bcmRangeTypeUdf = 4, /* Check Udf range. */ 26 bcmRangeTypeCount = 5 /* Always last. Not a usable value. */ 27 } bcm_range_type_t; 28 29 #define BCM_RANGE_TYPE \ 30 { \ 31 "L4SrcPort", \ 32 "L4DstPort", \ 33 "OuterVlan", \ 34 "PacketLength", \ 35 "Udf" \ 36 } 37 38 /* bcm_range_oper_mode_e */ 39 typedef enum bcm_range_oper_mode_e { 40 bcmRangeOperModeGlobal = 0, /* Range Checkers Operate in Global Mode 41 Value. i.e. for a given packet on any 42 port from any pipe will have the same 43 range check Result. */ 44 bcmRangeOperModePipeLocal = 1, /* Range Checkers Operate in Per Pipe Mode 45 Value. i.e. for a given packet on ports 46 from different pipes can have the 47 different range check Result. */ 48 bcmRangeOperModeCount = 2 /* Always last. Not a usable value. */ 49 } bcm_range_oper_mode_t; 50 51 #define BCM_RANGE_OPER_MODE \ 52 { \ 53 "Global", \ 54 "PipeLocal", \ 55 "Count" \ 56 } 57 58 /* Opaque handle to a range. */ 59 typedef uint32 bcm_range_t; 60 61 /* 62 * Range configuration structure used to create a range with specific 63 * attributes. 64 */ 65 typedef struct bcm_range_config_s { 66 bcm_range_t rid; /* Range Check Id */ 67 bcm_range_type_t rtype; /* Range Check Type(bcmRangeTypeXXX) */ 68 uint32 min; /* Lower limit of Range inclusive. */ 69 uint32 max; /* Upper limit of Range inclusive. */ 70 uint8 offset; /* Offset (in bits) for mask to apply before range 71 check comparison. */ 72 uint8 width; /* Width(in bits) from offset specified for mask to 73 apply before range check comparison. */ 74 bcm_udf_id_t udf_id; /* UDF id created using bcm_udf_create API. */ 75 bcm_pbmp_t ports; /* Port bitmap to decide XGS pipe */ 76 } bcm_range_config_t; 77 78 /* 79 * Range Module Flags. These flags can be passed to bcm_range_create API 80 * via flags parameter. 81 */ 82 #define BCM_RANGE_CREATE_WITH_ID (1 << 0) 83 84 /* 85 * Initialize all members in bcm_range_config_t structure to default 86 * values. 87 */ 88 extern void bcm_range_config_t_init( 89 bcm_range_config_t *range_cfg); 90 91 #ifndef BCM_HIDE_DISPATCHABLE 92 93 /* 94 * This API is to create a Layer 4 TCP/UDP port range checker or a VLAN 95 * ranger checker or a packet length range checker or a UDF range checker 96 * and returns an identifier that can be passed to 97 * 'bcm_field_qualify_RangeCheck' API, to qualify a Field entry with 98 * Range Checker match criteria. 99 */ 100 extern int bcm_range_create( 101 int unit, 102 int flags, 103 bcm_range_config_t *range_cfg); 104 105 /* 106 * This API is to retrieve the operational configuration for a given 107 * range id. 108 */ 109 extern int bcm_range_get( 110 int unit, 111 bcm_range_config_t *range_cfg); 112 113 /* 114 * Destroys a range checker and releases resources allocated to the range 115 * checker. Hardware resources will also be freed. But this API will 116 * return BCM_E_BUSY, ifthe range checker is in use. 117 */ 118 extern int bcm_range_destroy( 119 int unit, 120 bcm_range_t rid); 121 122 /* 123 * Configure Operational mode of Range Module to either Global or Pipe 124 * Local. 125 */ 126 extern int bcm_range_oper_mode_set( 127 int unit, 128 bcm_range_oper_mode_t oper_mode); 129 130 /* Get current operational mode of the Range Module. */ 131 extern int bcm_range_oper_mode_get( 132 int unit, 133 bcm_range_oper_mode_t *oper_mode); 134 135 #endif /* BCM_HIDE_DISPATCHABLE */ 136 137 /* 138 * Device Range Id's traverse callback function. Customer Applications 139 * can create function of this prototype and pass that function pointer 140 * to bcm_range_travers API, so that for every valid range id , function 141 * pointer will be called with some meta data 142 */ 143 typedef int (*bcm_range_traverse_cb)( 144 int unit, 145 bcm_range_config_t *range_cfg, 146 void *user_data); 147 148 #ifndef BCM_HIDE_DISPATCHABLE 149 150 /* 151 * Traverse all the range checkers in the system, calling a specified 152 * callback for each one 153 */ 154 extern int bcm_range_traverse( 155 int unit, 156 bcm_range_traverse_cb callback, 157 void *user_data); 158 159 #endif /* BCM_HIDE_DISPATCHABLE */ 160 161 #define BCM_RANGE_ID_MAX ((64 * _SHR_SWITCH_MAX_PIPES) - 1) 162 163 /* Bitmap of Range IDs. */ 164 typedef struct bcm_range_id_bmp_s { 165 SHR_BITDCL w[_SHR_BITDCLSIZE(BCM_RANGE_ID_MAX)]; 166 } bcm_range_id_bmp_t; 167 168 /* Range group configuration structure. */ 169 typedef struct bcm_range_group_config_s { 170 uint16 flags; /* To hold any specific flags. */ 171 bcm_pbmp_t ports; /* Port bitmap for particular pipe 172 instance. */ 173 bcm_range_id_bmp_t range_bmp; /* Bitmap to hold Range IDs. */ 174 uint32 range_group_id; /* Range Group Identifier */ 175 } bcm_range_group_config_t; 176 177 #define BCM_RANGE_ID_BMP_ADD(range_bmp, range_id) SHR_BITSET(((range_bmp).w), (range_id)) 178 179 #define BCM_RANGE_ID_BMP_REMOVE(range_bmp, range_id) SHR_BITCLR(((range_bmp).w), (range_id)) 180 181 #define BCM_RANGE_ID_BMP_TEST(range_bmp, range_id) SHR_BITGET(((range_bmp).w), (range_id)) 182 183 #ifndef BCM_HIDE_DISPATCHABLE 184 185 /* 186 * This API will help to combine different Range Checkers into a single 187 * group. It returns a range group identifier that can be passed to 188 * 'bcm_field_qualify_RangeGroup' API, to qualify a Field entry with 189 * Range Group match criteria. The Individual RangeCheck conditions and 190 * its IDs has to be created separately using bcm_range_create API. 191 */ 192 extern int bcm_range_group_create( 193 int unit, 194 bcm_range_group_config_t *range_group_config); 195 196 /* 197 * This API will help to delete the range group created using 198 * bcm_range_group_create. 199 */ 200 extern int bcm_range_group_delete( 201 int unit, 202 bcm_range_group_config_t *range_group_config); 203 204 /* 205 * This API will help to update the range IDs in the range group created 206 * using bcm_range_group_create. 207 */ 208 extern int bcm_range_group_update( 209 int unit, 210 bcm_range_group_config_t *range_group_config); 211 212 /* 213 * This API will help to fetch the range group configuration created 214 * using bcm_range_group_create. 215 */ 216 extern int bcm_range_group_get( 217 int unit, 218 bcm_range_group_config_t *range_group_config); 219 220 #endif /* BCM_HIDE_DISPATCHABLE */ 221 222 /* 223 * Initialize all members in bcm_range_group_config_t structure to 224 * default values. 225 */ 226 extern void bcm_range_group_config_t_init( 227 bcm_range_group_config_t *range_group_config); 228 229 #endif /* __BCM_RANGE_H__ */