mirror.h (9001B)
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 * Mirror - Broadcom Mirror API. 8 */ 9 #ifndef _DPP_PETRA_MIRROR_H_ 10 #define _DPP_PETRA_MIRROR_H_ 11 #include <bcm/mirror.h> 12 #include <shared/swstate/sw_state.h> 13 #include <soc/dpp/ARAD/arad_api_action_cmd.h> 14 15 /****************************************************************************** 16 * 17 * Configuration 18 */ 19 20 /* 21 * Controls whether certain (perhaps excessively) verbose messages will be 22 * emitted by the diagnostics. These messages are the FIELD_EVERB messages, 23 * which will be emitted at VVERB level if enabled. 24 */ 25 #define _BCM_PETRA_MIRROR_EXCESS_VERBOSITY TRUE 26 27 /****************************************************************************** 28 * 29 * Module-wide definitions 30 */ 31 32 /* number of supported ingress mirror templates */ 33 #define SOC_PETRA_IGR_MIRRORS(_unit) 16 34 #define BCM_PETRA_MIRROR_MODE_PORT_SET 1 35 #define BCM_PETRA_MIRROR_MODE_DESTINATION_CREATE 0 36 37 /* 38 * Describes a single mirror 39 */ 40 typedef struct _bcm_petra_mirror_data_s { 41 unsigned int refCount; /* references to this template */ 42 SOC_TMC_ACTION_CMD_SNOOP_MIRROR_INFO mirrorInfo; /* mirror information */ 43 } _bcm_petra_mirror_data_t; 44 45 /* 46 * Describes the state per unit for mirroring 47 */ 48 typedef struct _bcm_petra_mirror_unit_data_s { 49 unsigned int ingressCount; /* ingress mirrors */ 50 PARSER_HINT_ARR _bcm_petra_mirror_data_t *ingress; /* ingr mirror info */ 51 } _bcm_petra_mirror_unit_data_t; 52 53 54 55 /* 56 * Function 57 * bcm_petra_mirror_detach 58 * Purpose 59 * Initialise the mirror APIs. 60 * Parameters 61 * (in) int unit = the unit number 62 * Returns 63 * int (implied cast from bcm_error_t) 64 * BCM_E_NONE if successful 65 * BCM_E_* appropriately if not 66 * Notes 67 */ 68 extern int 69 bcm_petra_mirror_detach(int unit); 70 71 /* 72 * Function 73 * bcm_petra_ingress_mirror_alloc 74 * Purpose 75 * Allocate an ingress mirror template according to the parameters 76 * Arguments 77 * (in) int unit = unit number 78 * (in) bcm_module_t myModule = the local unit's module ID 79 * (in) bcm_module_t destMod = destination module 80 * (in) bcm_port_t destPort = destination port 81 * (out) int *mirrorId = where to put allocated ingress mirror ID 82 * Returns 83 * bcm_error_t cast as int 84 * BCM_E_NONE for success 85 * BCM_E_* otherwise as appropriate 86 * Notes 87 * Builds a mirror descriptor and uses the template manager to allocate a 88 * mirror template according to that decriptor. 89 * 90 * Right now, only configures destination in mirror action so that is all it 91 * compares when looking for a matching template. 92 * 93 * On success, this increments the use count for the returned template. 94 * 95 * The change function is an optimisation more than anything else. In the 96 * simple case, the alloc function will suffice. However, alloc new 97 * template then free old template will not work if there are no free 98 * templates; change can work if there are no free templates but the one 99 * being changed has only one reference. 100 */ 101 extern int 102 bcm_petra_ingress_mirror_alloc(int unit, 103 bcm_module_t myModule, 104 bcm_module_t destMod, 105 bcm_port_t destPort, 106 int *mirrorId); 107 108 /* 109 * Function 110 * bcm_petra_ingress_mirror_reference 111 * Purpose 112 * Add a reference to an ingress mirror template 113 * Arguments 114 * (in) int unit = unit number 115 * (in) int mirrorId = mirror template ID for the reference 116 * Returns 117 * bcm_error_t cast as int 118 * BCM_E_NONE for success 119 * BCM_E_* otherwise as appropriate 120 * Notes 121 * This is intended to be used as part of warm boot or similar. When other 122 * modules are rebuilding their state, they call this function as they 123 * encounter references to mirror templates. This allows the mirror module 124 * to know how many outstanding references there are to each template. 125 * 126 * Template 0 is reserved (for no-mirror) and should never be freed. 127 */ 128 extern int 129 bcm_petra_ingress_mirror_reference(int unit, 130 int mirrorId); 131 132 /* 133 * Function 134 * bcm_petra_ingress_mirror_free 135 * Purpose 136 * Free a specified ingress mirror 137 * Arguments 138 * (in) int unit = unit number 139 * (in) int mirrorId = ingress mirror ID to free 140 * Returns 141 * bcm_error_t cast as int 142 * BCM_E_NONE for success 143 * BCM_E_* otherwise as appropriate 144 * Notes 145 * Frees (one reference to) an ingress mirror template. 146 * 147 * Template 0 is reserved (for no-mirror) and should never be freed. 148 */ 149 extern int 150 bcm_petra_ingress_mirror_free(int unit, 151 int mirrorId); 152 153 /* 154 * Function 155 * bcm_petra_ingress_mirror_change 156 * Purpose 157 * Change an ingress mirror 158 * Arguments 159 * (in) int unit = unit number 160 * (in) int oldMirrorId = old ingress mirror ID 161 * (in) bcm_module_t myModule = the local unit's module ID 162 * (in) bcm_module_t destMod = destination module 163 * (in) bcm_port_t destPort = destination port 164 * (out) int *newMirrorId = where to put new ingress mirror ID 165 * Returns 166 * bcm_error_t cast as int 167 * BCM_E_NONE for success 168 * BCM_E_* otherwise as appropriate 169 * Notes 170 * This will only edit the template in-place if there is exactly one 171 * reference to it. If there is more than one reference to the template, it 172 * will allocate a replacement template and provide that, releasing one 173 * reference to the old template. If success and the oldMirrorId and 174 * newMirrorId values are the same, the template was edited in place and 175 * there should be no need to make changes to the reference. 176 * 177 * Once the other table (field entry, port descriptor, &c) has been updated 178 * to use the new mirror template, the old one must be freed (this is not 179 * done automatically here). If such edits fail, the new mirror template 180 * should be freed instead of the old one. This is done so that a template 181 * will not be overwritten if there are other things happening or more than 182 * one subsystem updates mirror targets concurrently. 183 * 184 * The change function is an optimisation more than anything else. In the 185 * simple case, the alloc function will suffice. However, alloc new 186 * template then free old template will not work if there are no free 187 * templates; change can work if there are no free templates but the one 188 * being changed has only one reference. 189 */ 190 extern int 191 bcm_petra_ingress_mirror_change(int unit, 192 int oldMirrorId, 193 bcm_module_t myModule, 194 bcm_module_t destMod, 195 bcm_port_t destPort, 196 int *newMirrorId); 197 198 /* 199 * Function 200 * _bcm_petra_ingress_mirror_get 201 * Purpose 202 * Get information about an ingress mirror 203 * Arguments 204 * (in) int unit = unit number 205 * (in) int mirrorId = ingress mirror ID 206 * (out) bcm_module_t *destMod = where to put destination module 207 * (out) bcm_port_t *destPort = where to put destination port 208 * Returns 209 * bcm_error_t cast as int 210 * BCM_E_NONE for success 211 * BCM_E_* otherwise as appropriate 212 * Notes 213 * This will only edit the template in-place if there is exactly one 214 * reference to it. If there is more than one reference to the template, it 215 * will allocate a replacement template and provide that, releasing one 216 * reference to the old template. 217 */ 218 extern int 219 bcm_petra_ingress_mirror_get(int unit, 220 int mirrorId, 221 bcm_module_t *destMod, 222 bcm_port_t *destPort); 223 224 225 /* Function 226 * bcm_petra_mirror_destination_tunnel_create 227 * Purpose 228 * build ERSPAN/SPAN tunnel on [given] outlif 229 * - In case mirror destination is over ip tunnel with/out ERSPAN. 230 * build ERSPAN tunnel if needed, and make mirror profile points to erspan outlif 231 * - build RSPAN tunnel 232 * Parameters 233 * (in) int unit = the unit number 234 * (in) bcm_mirror_destination_t *mirror_dest: mirror destination as given by BCM call 235 * (in) uint32 action_profile_id: mirror profile used 236 * Returns 237 * int (implied cast from bcm_error_t) 238 * BCM_E_NONE if successful 239 * BCM_E_* appropriately if not 240 * Notes 241 */ 242 int 243 bcm_petra_mirror_destination_tunnel_create( 244 int unit, 245 bcm_mirror_destination_t *mirror_dest, 246 uint32 action_profile_id, 247 int *global_outlif, 248 uint8 *outlif_valid, 249 uint8 update); 250 251 252 /*creates mirror or snoop profile and sets it. dest is set if $set_dest*/ 253 int _bcm_petra_mirror_or_snoop_destination_create(int unit,bcm_mirror_destination_t *mirror_dest, uint8 set_dest); 254 255 #endif /* ndef _DPP_PETRA_MIRROR_H_ */