pkt.h (73001B)
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_PKT_H__ 14 #define __BCM_PKT_H__ 15 16 #include <shared/rx.h> 17 #include <shared/pkt.h> 18 #include <bcm/types.h> 19 #include <bcm/vlan.h> 20 21 /* Default TX and RX DMA channels for the BCM layer. */ 22 #define BCM_TX_CHAN_DFLT 0 23 #define BCM_RX_CHAN_DFLT 1 24 25 /* Minimum packet allocation: MAC addresses, VLAN tag, CRC. */ 26 #define BCM_PKT_ALLOC_MIN (12 + 4 + 4) 27 28 /* 29 * IEEE header: MAC addresses + VLAN tag; does not include type/len 30 * field. 31 */ 32 #define BCM_IEEE_HDR_BYTES (12 + 4) 33 34 /* 35 * The packet structure. The packet layout is as follows: 36 * 37 * DMAC + SMAC 12 bytes 38 * VLAN tag 4 bytes (may be filled in by SW on BCM5670/75) 39 * payload N bytes 40 * CRC 4 bytes 41 * pad M bytes 42 * SL tag 4 bytes (may be unused) 43 * HiGig Header 12 bytes (may be unused) 44 * 45 * The rule is: alloc_len = 12 + 4 + N + 4 + M + 4 + 12 (all of above). 46 * payload_len (below) is N. 47 * 48 * Note that the payload may grow until M == 0; the CRC moves. The SL and 49 * HiGig headers will not move. 50 * 51 * The "IEEE packet" is everything from the DMAC through the CRC 52 * (inclusive), not including SL tag or HiGig header. 53 * 54 * Scatter/gather is used to put the data into the right positions on 55 * transmit and receive. The SL/HiGig headers are parsed on RX into data 56 * members in the packet structure. On TX, bcm_tx will send the packet 57 * according to the unit type. It will not check or affect any fields 58 * except maybe the CRC. Other routines will be provided to ensure the 59 * HiGig and SL tags are properly set up from the data in the packet 60 * structure. 61 */ 62 typedef struct bcm_pkt_s bcm_pkt_t; 63 64 /* bcm_pkt_cb_f */ 65 typedef void (*bcm_pkt_cb_f)( 66 int unit, 67 bcm_pkt_t *pkt, 68 void *cookie); 69 70 /* BCM packet gather block type. */ 71 typedef struct bcm_pkt_blk_s { 72 uint8 *data; 73 int len; 74 } bcm_pkt_blk_t; 75 76 /* Set of 'reasons' (see bcmRxReason*) why a packet came to the CPU. */ 77 typedef _shr_rx_reasons_t bcm_rx_reasons_t; 78 79 /* Stacking header packet forwarding options. */ 80 typedef enum bcm_pkt_stk_forward_e { 81 BCM_PKT_STK_FORWARD_CPU = 0, /* Stacking header packet forwarding 82 option: to Host CPU. */ 83 BCM_PKT_STK_FORWARD_L2_UNICAST = 1, /* Stacking header packet forwarding 84 option: Unicast L2. */ 85 BCM_PKT_STK_FORWARD_L3_UNICAST = 2, /* Stacking header packet forwarding 86 option: Unicast L3. */ 87 BCM_PKT_STK_FORWARD_L2_MULTICAST = 3, /* Stacking header packet forwarding 88 option: Multicast L2. */ 89 BCM_PKT_STK_FORWARD_L2_MULTICAST_UNKNOWN = 4, /* Stacking header packet forwarding 90 option: Unknown Multicast L2. */ 91 BCM_PKT_STK_FORWARD_L3_MULTICAST = 5, /* Stacking header packet forwarding 92 option: Multicast L3. */ 93 BCM_PKT_STK_FORWARD_L3_MULTICAST_UNKNOWN = 6, /* Stacking header packet forwarding 94 option: Unknown Multicast L3. */ 95 BCM_PKT_STK_FORWARD_L2_UNICAST_UNKNOWN = 7, /* Stacking header packet forwarding 96 option: Unknown Unicast L2. */ 97 BCM_PKT_STK_FORWARD_BROADCAST = 8, /* Stacking header packet forwarding 98 option: Broadcast. */ 99 BCM_PKT_STK_FORWARD_MPLS = 9, /* Stacking header packet forwarding 100 option: MPLS. */ 101 BCM_PKT_STK_FORWARD_TRILL = 10, /* Stacking header packet forwarding 102 option: TRILL. */ 103 BCM_PKT_STK_FORWARD_FCOE = 11, /* Stacking header packet forwarding 104 option: FCoE. */ 105 BCM_PKT_STK_FORWARD_SNOOP = 12, /* Stacking header packet forwarding 106 option: Snoop. */ 107 BCM_PKT_STK_FORWARD_TRAFFIC_MANAGEMENT = 13, /* Stacking header packet forwarding 108 option: Traffic Management. */ 109 BCM_PKT_STK_FORWARD_COUNT = 14 /* Must be last. */ 110 } bcm_pkt_stk_forward_t; 111 112 /* Decap Tunnel Types */ 113 typedef enum bcm_rx_decap_tunnel_e { 114 bcmRxDecapNone = _SHR_RX_DECAP_NONE, /* No tunnel Decap */ 115 bcmRxDecapAccessSVP = _SHR_RX_DECAP_ACCESS_SVP, /* Packet ingress on Access SVP (No 116 decap) */ 117 bcmRxDecapMIM = _SHR_RX_DECAP_MIM, /* Decap Mac-in-Mac tunnel */ 118 bcmRxDecapL2GRE = _SHR_RX_DECAP_L2GRE, /* Decap L2GRE tunnel */ 119 bcmRxDecapVXLAN = _SHR_RX_DECAP_VXLAN, /* Decap VXLAN tunnel */ 120 bcmRxDecapAMT = _SHR_RX_DECAP_AMT, /* Decap AMT tunnel */ 121 bcmRxDecapIP = _SHR_RX_DECAP_IP, /* Decap IP tunnel */ 122 bcmRxDecapTRILL = _SHR_RX_DECAP_TRILL, /* Decap TRILL tunnel */ 123 bcmRxDecapMPLS1LABEL = _SHR_RX_DECAP_MPLS_1LABEL, /* Decap MPLS 1 Label, no Control Word */ 124 bcmRxDecapL2MPLS1LABEL = _SHR_RX_DECAP_L2MPLS_1LABEL, /* Decap MPLS 1 Label, L2 payload, no 125 Control Word */ 126 bcmRxDecapMPLS2LABEL = _SHR_RX_DECAP_MPLS_2LABEL, /* Decap MPLS 2 Label, no Control Word */ 127 bcmRxDecapL2MPLS2LABEL = _SHR_RX_DECAP_L2MPLS_2LABEL, /* Decap MPLS 2 Label, L2 payload, no 128 Control Word */ 129 bcmRxDecapMPLS1LABELCW = _SHR_RX_DECAP_MPLS_1LABELCW, /* Decap MPLS 1 Label, Control Word 130 present */ 131 bcmRxDecapL2MPLS1LABELCW = _SHR_RX_DECAP_L2MPLS_1LABELCW, /* Decap MPLS 1 Label, L2 payload, 132 Control Word present */ 133 bcmRxDecapMPLS2LABELCW = _SHR_RX_DECAP_MPLS_2LABELCW, /* Decap MPLS 2 Label, Control Word 134 present */ 135 bcmRxDecapL2MPLS2LABELCW = _SHR_RX_DECAP_L2MPLS_2LABELCW, /* Decap MPLS 2 Label, L2 payload, 136 Control Word present */ 137 bcmRxDecapL3MPLS1LABEL = _SHR_RX_DECAP_L3MPLS_1LABEL, /* Decap MPLS 1 Label, L3 payload, no 138 Control Word present */ 139 bcmRxDecapL3MPLS2LABEL = _SHR_RX_DECAP_L3MPLS_2LABEL, /* Decap MPLS 2 Label, L3 payload, no 140 Control Word present */ 141 bcmRxDecapL3MPLS1LABELCW = _SHR_RX_DECAP_L3MPLS_1LABELCW, /* Decap MPLS 1 Label, L3 payload, 142 Control Word present */ 143 bcmRxDecapL3MPLS2LABELCW = _SHR_RX_DECAP_L3MPLS_2LABELCW, /* Decap MPLS 2 Label, L3 payload, 144 Control Word present */ 145 bcmRxDecapWTP2AC = _SHR_RX_DECAP_WTP2AC, /* Decap WTP2AC Tunnel */ 146 bcmRxDecapAC2AC = _SHR_RX_DECAP_AC2AC, /* Decap AC2AC Tunnel */ 147 bcmRxDecapMPLS3LABEL = _SHR_RX_DECAP_MPLS_3LABEL, /* Decap MPLS 3 Label, no Control Word 148 present */ 149 bcmRxDecapMPLS3LABELCW = _SHR_RX_DECAP_MPLS_3LABELCW, /* Decap MPLS 3 Label, Control Word 150 present */ 151 bcmRxDecapMPLS3LABELENTROPYLABEL = _SHR_RX_DECAP_MPLS_3LABEL_ENTROPY, /* Decap MPLS 3 Label + entropy, no 152 Control Word */ 153 bcmRxDecapMPLS3LABELENTROPYLABELCW = _SHR_RX_DECAP_MPLS_3LABEL_ENTROPYCW, /* Decap MPLS 3 Label + entropy, Control 154 Word present */ 155 bcmRxDecapCount = _SHR_RX_DECAP_COUNT /* Decap Tunnel Max */ 156 } bcm_rx_decap_tunnel_t; 157 158 /* Packet Headers Decapped after Ingress */ 159 typedef enum bcm_rx_decap_hdr_e { 160 bcmRxDecapHdrNone = _SHR_RX_DECAP_HDR_NONE, /* No headers Decapped */ 161 bcmRxDecapSystemHdr = _SHR_RX_DECAP_SYSTEM_HDR, /* Decap System Header */ 162 bcmRxDecapOuterL2Hdr = _SHR_RX_DECAP_OUTER_L2_HDR, /* Decap Outer L2 Header */ 163 bcmRxDecapL3L4TunnelHdr = _SHR_RX_DECAP_L3_L4_TUNNEL_HDR, /* Decap Outer L3/L4/TUNNEL Header */ 164 bcmRxDecapInnerL2Hdr = _SHR_RX_DECAP_INNER_L2_HDR, /* Decap Inner L2 Header */ 165 bcmRxDecapInnerL3L4Hdr = _SHR_RX_DECAP_INNER_L3_L4_HDR /* Decap Inner L3 and L4 Header */ 166 } bcm_rx_decap_hdr_t; 167 168 /* OAM DM timestamp options. */ 169 typedef enum bcm_pkt_timestamp_mode_e { 170 BCM_PKT_TIMESTAMP_MODE_NONE = 0, /* No Timestamp */ 171 BCM_PKT_TIMESTAMP_MODE_PTP = 1, /* Timestamp mode - PTP. */ 172 BCM_PKT_TIMESTAMP_MODE_NTP = 2, /* Timestamp mode - NTP. */ 173 BCM_PKT_TIMESTAMP_MODE_NUM = 3 /* Max value - Not to be used */ 174 } bcm_pkt_timestamp_mode_t; 175 176 /* OAM LM counter options. */ 177 typedef enum bcm_pkt_oam_lm_counter_mode_e { 178 BCM_PKT_OAM_LM_COUNTER_MODE_NONE = 0, /* No LM counter operation */ 179 BCM_PKT_OAM_LM_COUNTER_MODE_INCREMENT = 1, /* Increment LM counter. */ 180 BCM_PKT_OAM_LM_COUNTER_MODE_SAMPLE = 2, /* Sample LM counter. */ 181 BCM_PKT_OAM_LM_COUNTER_MODE_NUM = 3 /* Max value - Not to be used */ 182 } bcm_pkt_oam_lm_counter_mode_t; 183 184 /* OAM Pkt Type */ 185 typedef enum bcm_pkt_rx_oam_type_e { 186 bcmPktRxOamTypeNone = 0, /* Not OAM pkt */ 187 bcmPktRxOamTypeBfdOam = 1, /* BFD OAM packet */ 188 bcmPktRxOamTypeEthOamCcm = 2, /* Ethernet OAM Down MEP CCM packet */ 189 bcmPktRxOamTypeEthOamLm = 3, /* Ethernet OAM Down MEP LM packet */ 190 bcmPktRxOamTypeEthOamDm = 4, /* Ethernet OAM Down MEP DM packet */ 191 bcmPktRxOamTypeEthOamOther = 5, /* Ethernet OAM Down MEP other opcode 192 packet */ 193 bcmPktRxOamTypeBhhOamCcm = 6, /* BHH OAM CCM packet */ 194 bcmPktRxOamTypeBhhOamLm = 7, /* BHH OAM LM packet */ 195 bcmPktRxOamTypeBhhOamDm = 8, /* BHH OAM DM packet */ 196 bcmPktRxOamTypeBhhOamOther = 9, /* BHH OAM other opcode packet */ 197 bcmPktRxOamTypeRfc6374Dlm = 10, /* MPLS LM/DM DLM packet */ 198 bcmPktRxOamTypeRfc6374Dm = 11, /* MPLS LM/DM DM packet */ 199 bcmPktRxOamTypeRfc6374DlmPlusDm = 12, /* MPLS LM/DM DLM + DM packet */ 200 bcmPktRxOamTypeRfc6374Ilm = 13, /* MPLS LM/DM ILM packet */ 201 bcmPktRxOamTypeRfc6374IlmPlusDm = 14, /* MPLS LM/DM ILM + DM packet */ 202 bcmPktRxOamTypeSat = 15, /* Service Activation Test */ 203 bcmPktRxOamTypeOtherAch = 16, /* OAM packets with other ACH types */ 204 bcmPktRxOamTypeEthOamUpMepCcm = 17, /* Ethernet OAM Up MEP CCM packet */ 205 bcmPktRxOamTypeEthOamUpMepLm = 18, /* Ethernet OAM Up MEP LM packet */ 206 bcmPktRxOamTypeEthOamUpMepDm = 19, /* Ethernet OAM Up MEP DM packet */ 207 bcmPktRxOamTypeEthOamUpMepOther = 20, /* Ethernet OAM Up MEP other opcode 208 packet */ 209 bcmPktRxOamTypeUpSat = 21, /* Up Service Activation Test packet */ 210 bcmPktRxOamTypeCount = 22 /* Max value - Not to be used */ 211 } bcm_pkt_rx_oam_type_t; 212 213 /* OAM counter object ID */ 214 typedef enum bcm_pkt_oam_counter_object_e { 215 bcmOamCounterObjectNone = 0, /* Invalid counter object */ 216 bcmOamCounterObjectEndpointId = 1, /* OAM counter object id */ 217 bcmOamCounterObjectFlexStatId = 2 /* OAM counter flex stats ID */ 218 } bcm_pkt_oam_counter_object_t; 219 220 /* Indicates how the packet was forwarded. */ 221 typedef enum bcm_pkt_forwarding_type_e { 222 BCM_PKT_L2_FORWARD = 0, /* Ethernet/NIV/HiGig forwarded. */ 223 BCM_PKT_L3UC = 1, /* L3 UC forwarded. */ 224 BCM_PKT_L2L3 = 2 /* Bridge routed. */ 225 } bcm_pkt_forwarding_type_t; 226 227 /* OAM counter */ 228 typedef struct bcm_pkt_oam_counter_s { 229 bcm_pkt_oam_counter_object_t counter_object; /* OAM counter object type */ 230 uint32 counter_object_id; /* Counter Object Id */ 231 uint32 counter_offset; /* Offset from start of counter group */ 232 bcm_pkt_oam_lm_counter_mode_t counter_mode; /* Counter mode during Tx */ 233 uint32 counter_value_upper; /* Upper 32 bit of OAM LM Counter in Rx 234 Pkt */ 235 uint32 counter_value_lower; /* Lower 32 bit of OAM LM Counter in Rx 236 Pkt */ 237 uint32 oam_lm_byte_count_offset; /* Offset to start byte counting */ 238 } bcm_pkt_oam_counter_t; 239 240 /* OAM counter max object */ 241 #define BCM_PKT_OAM_COUNTER_MAX 3 242 243 /* Rx path definitions */ 244 #define BCM_RX_PATH_SWITCHED (1 << 0) 245 #define BCM_RX_PATH_COPY_TO_CPU (1 << 1) 246 #define BCM_RX_PATH_MIRRORED (1 << 2) 247 248 /* DNX internal header stack array size */ 249 #define BCM_PKT_NOF_DNX_HEADERS _SHR_PKT_NOF_DNX_HEADERS 250 251 /* Pkt DNX types. */ 252 typedef enum bcm_pkt_dnx_type_e { 253 bcmPktDnxTypeItmh = _SHR_PKT_DNX_TYPE_ITMH, /* ITMH Header. */ 254 bcmPktDnxTypeFtmh = _SHR_PKT_DNX_TYPE_FTMH, /* FMTH Header. */ 255 bcmPktDnxTypeOtsh = _SHR_PKT_DNX_TYPE_OTSH, /* OAM-TS Header (OTSH). */ 256 bcmPktDnxTypeOtmh = _SHR_PKT_DNX_TYPE_OTMH, /* OTMH Header. */ 257 bcmPktDnxTypeInternals = _SHR_PKT_DNX_TYPE_INTERNALS /* Dnx Internal fields. */ 258 } bcm_pkt_dnx_type_t; 259 260 /* itmh dest type. */ 261 typedef enum bcm_pkt_dnx_itmh_dest_type_e { 262 bcmPktDnxItmhDestTypeMulticast = _SHR_PKT_DNX_ITMH_DEST_TYPE_MULTICAST, /* ITMH destination type is multicast. */ 263 bcmPktDnxItmhDestTypeFlow = _SHR_PKT_DNX_ITMH_DEST_TYPE_FLOW, /* ITMH destination type is flow. */ 264 bcmPktDnxItmhDestTypeIngressShapingFlow = _SHR_PKT_DNX_ITMH_DEST_TYPE_INGRESS_SHAPING_FLOW, /* ITMH destination type is ingress 265 shaping flow. */ 266 bcmPktDnxItmhDestTypeVport = _SHR_PKT_DNX_ITMH_DEST_TYPE_VPORT, /* ITMH destination type is out lif. */ 267 bcmPktDnxItmhDestTypeSystemPort = _SHR_PKT_DNX_ITMH_DEST_TYPE_SYSTEM_PORT /* ITMH destination type is system port. */ 268 } bcm_pkt_dnx_itmh_dest_type_t; 269 270 /* Itmh destination. */ 271 typedef struct bcm_pkt_dnx_itmh_dest_s { 272 bcm_pkt_dnx_itmh_dest_type_t dest_type; /* Destination type */ 273 bcm_pkt_dnx_itmh_dest_type_t dest_extension_type; /* Destination Extension type */ 274 bcm_gport_t destination; /* Destination Gport */ 275 bcm_multicast_t multicast_id; /* Destination multicast */ 276 bcm_gport_t destination_ext; /* Destination-Extension Gport */ 277 } bcm_pkt_dnx_itmh_dest_t; 278 279 /* Itmh */ 280 typedef struct bcm_pkt_dnx_itmh_s { 281 uint8 inbound_mirror_disable; /* If set, disable inbound mirroring 282 (ITMH.IN_MIRR_DISABLE) */ 283 uint32 snoop_cmnd; /* snoop command (ITMH.SNOOP_CMD) */ 284 uint32 prio; /* Traffic Class (ITMH.FWD_TRAFFIC_CLASS) */ 285 bcm_color_t color; /* Color (aka Drop precedence, ITMH.FWD_DP) */ 286 bcm_pkt_dnx_itmh_dest_t dest; /* Destination information */ 287 } bcm_pkt_dnx_itmh_t; 288 289 /* ftmh action type. */ 290 typedef enum bcm_pkt_dnx_ftmh_action_type_e { 291 bcmPktDnxFtmhActionTypeForward = _SHR_PKT_DNX_FTMH_ACTION_TYPE_FORWARD, /* TM action is forward */ 292 bcmPktDnxFtmhActionTypeSnoop = _SHR_PKT_DNX_FTMH_ACTION_TYPE_SNOOP, /* TM action is snoop */ 293 bcmPktDnxFtmhActionTypeInboundMirror = _SHR_PKT_DNX_FTMH_ACTION_TYPE_INBOUND_MIRROR, /* TM action is inbound mirror. */ 294 bcmPktDnxFtmhActionTypeOutboundMirror = _SHR_PKT_DNX_FTMH_ACTION_TYPE_OUTBOUND_MIRROR /* TM action is outbound mirror. */ 295 } bcm_pkt_dnx_ftmh_action_type_t; 296 297 /* ftmh lb extension. */ 298 typedef struct bcm_pkt_dnx_ftmh_lb_extension_s { 299 uint8 valid; /* Set if the extension is present */ 300 uint32 lb_key; /* Load Balancing Key (FTMH.LB-Key) */ 301 } bcm_pkt_dnx_ftmh_lb_extension_t; 302 303 /* ftmh dest extension. */ 304 typedef struct bcm_pkt_dnx_ftmh_dest_extension_s { 305 uint8 valid; /* Set if the extension is present */ 306 bcm_gport_t dst_sysport; /* Destination System Port 307 (FTMH.Destination-Sys-Port)) */ 308 } bcm_pkt_dnx_ftmh_dest_extension_t; 309 310 /* ftmh stack extension. */ 311 typedef struct bcm_pkt_dnx_ftmh_stack_extension_s { 312 uint8 valid; /* Set if the extension is present */ 313 uint32 stack_route_history_bmp; /* Route bitmap to prevent loops in stacking 314 system 315 (FTMH.Stacking-Route-History-Bitmap) */ 316 } bcm_pkt_dnx_ftmh_stack_extension_t; 317 318 /* ASE type. */ 319 typedef enum bcm_pkt_dnx_ase_type_e { 320 bcmPktDnxAseTypeNone = 0, /* Ase type is None */ 321 bcmPktDnxAseTypeTrajectoryTrace = 1, /* Ase type is Trajectory trace */ 322 bcmPktDnxAseTypeErspan = 2, /* Ase type is ERSPAN */ 323 bcmPktDnxAseTypeSFlow = 3, /* Ase type is sFlow */ 324 bcmPktDnxAseTypeMirrorOnDrop = 4 /* Ase type is Mirror-On-Drop */ 325 } bcm_pkt_dnx_ase_type_t; 326 327 /* ERSPAN header information */ 328 typedef struct bcm_pkt_dnx_erspan_info_s { 329 uint8 direction; /* Direction: 0x0-incoming, 0x1-outgoing */ 330 uint8 truncated_flag; /* Truncated field in ERSPAN header. 0x1-it means 331 the frame copy encapsulated in the ERSPAN packet 332 will be truncated; 0x0-not truncated */ 333 uint8 en; /* The trunk encapsulation type */ 334 uint8 cos; /* Class of service */ 335 uint16 vlan; /* Vlan */ 336 } bcm_pkt_dnx_erspan_info_t; 337 338 /* Ase information */ 339 typedef struct bcm_pkt_dnx_ase_info_s { 340 bcm_pkt_dnx_erspan_info_t erspan_info; /* ERSPAN header information */ 341 } bcm_pkt_dnx_ase_info_t; 342 343 /* ftmh application specific extension. */ 344 typedef struct bcm_pkt_dnx_ftmh_ase_extension_s { 345 uint8 valid; /* Set if the extension is present */ 346 bcm_pkt_dnx_ase_type_t ase_type; /* Application Specific Extension type */ 347 bcm_pkt_dnx_ase_info_t ase_info; /* Application Specific Extension 348 information */ 349 } bcm_pkt_dnx_ftmh_ase_extension_t; 350 351 /* ftmh flow_id extension. */ 352 typedef struct bcm_pkt_dnx_ftmh_flow_id_extension_s { 353 uint8 valid; /* Set if the extension is present */ 354 uint32 flow_id; /* Flow-ID */ 355 uint8 flow_profile; /* Flow-Profile */ 356 } bcm_pkt_dnx_ftmh_flow_id_extension_t; 357 358 /* ftmh */ 359 typedef struct bcm_pkt_dnx_ftmh_s { 360 uint32 packet_size; /* Packet size in bytes 361 (FTMH.Packet-Size) */ 362 uint32 prio; /* Traffic class (FTMH.Traffic-Class) */ 363 bcm_gport_t src_sysport; /* Source System port 364 (FTMH.Source-System-Port-Aggr) */ 365 bcm_gport_t dst_port; /* Destination local port (FTMH.PP_DSP) */ 366 bcm_color_t ftmh_dp; /* Drop precedence (FTMH.DP) */ 367 bcm_pkt_dnx_ftmh_action_type_t action_type; /* Action type (FTMH.TM-Action-Type) */ 368 uint8 out_mirror_disable; /* Disable Outbound mirroring 369 (FTMH.Out-Mirror-Disable) */ 370 uint8 is_mc_traffic; /* Indicate if the traffic is multicast 371 (FTMH.TM-Action-Is-Multicast) */ 372 bcm_multicast_t multicast_id; /* Multicast ID (FTMH.Multicast-ID). 373 Valid only if is_mc_traffic is set */ 374 bcm_gport_t out_vport; /* Virtual port (FTMH.Out-LIF). Valid 375 only if is_mc_traffic is unset */ 376 uint32 cni; /* Congestion indication (FTMH.CNI) */ 377 bcm_pkt_dnx_ftmh_lb_extension_t lb_ext; /* FTMH Load Balancing Key extension */ 378 bcm_pkt_dnx_ftmh_dest_extension_t dest_ext; /* FTMH Destination System Port 379 Extension */ 380 bcm_pkt_dnx_ftmh_stack_extension_t stack_ext; /* FTMH Stacking extension 381 (Stacking-Route-History-Bitmap) */ 382 bcm_pkt_dnx_ftmh_ase_extension_t ase_ext; /* FTMH Application Specific Extension */ 383 bcm_pkt_dnx_ftmh_flow_id_extension_t flow_id_ext; /* FTMH FLow-ID Extension */ 384 } bcm_pkt_dnx_ftmh_t; 385 386 /* TSH header */ 387 typedef struct bcm_pkt_dnx_tsh_s { 388 uint8 valid; /* Set if TSH is present */ 389 } bcm_pkt_dnx_tsh_t; 390 391 /* otsh type */ 392 typedef enum bcm_pkt_dnx_otsh_type_e { 393 bcmPktDnxOtshTypeOam = _SHR_PKT_DNX_OTSH_TYPE_OAM, /* OAM-TS type is OAM */ 394 bcmPktDnxOtshTypeL588v2 = _SHR_PKT_DNX_OTSH_TYPE_L588v2, /* OAM-TS type is 1588v2 */ 395 bcmPktDnxOtshTypeLatency = _SHR_PKT_DNX_OTSH_TYPE_LATENCY /* OAM-TS type is packet latency */ 396 } bcm_pkt_dnx_otsh_type_t; 397 398 /* otsh oam sutype */ 399 typedef enum bcm_pkt_dnx_otsh_oam_subtype_e { 400 bcmPktDnxOtshOamSubtypeNone = _SHR_PKT_DNX_OTSH_OAM_SUBTYPE_NONE, /* None */ 401 bcmPktDnxOtshOamSubtypeLm = _SHR_PKT_DNX_OTSH_OAM_SUBTYPE_LM, /* Loss Measurement (LM) */ 402 bcmPktDnxOtshOamSubtypeDm1588 = _SHR_PKT_DNX_OTSH_OAM_SUBTYPE_DM1588, /* Delay Measurement (DM) - 1588 ToD */ 403 bcmPktDnxOtshOamSubtypeDmNtp = _SHR_PKT_DNX_OTSH_OAM_SUBTYPE_DM_NTP, /* Delay Measurement (DM) - NTP ToD */ 404 bcmPktDnxOtshOamSubtypeOamDefault = _SHR_PKT_DNX_OTSH_OAM_SUBTYPE_OAM_DEFAULT, /* Default OAM type */ 405 bcmPktDnxOtshOamSubtypeLoopback = _SHR_PKT_DNX_OTSH_OAM_SUBTYPE_LOOPBACK, /* Loopback */ 406 bcmPktDnxOtshOamSubtypeEcn = _SHR_PKT_DNX_OTSH_OAM_SUBTYPE_ECN /* ECN */ 407 } bcm_pkt_dnx_otsh_oam_subtype_t; 408 409 /* otsh */ 410 typedef struct bcm_pkt_dnx_otsh_s { 411 bcm_pkt_dnx_otsh_type_t otsh_type; /* OAM-TS(Type). */ 412 bcm_pkt_dnx_otsh_oam_subtype_t oam_sub_type; /* OAM-TS(OAM-Sub-Type). Applies only 413 when otsh_type is oam. */ 414 uint32 oam_up_mep; /* OAM-TS(MEP-Type). Applies only when 415 otsh_type is oam. */ 416 uint32 tp_cmd; /* OAM-TS(TP-Cmd). Applies only when 417 otsh_type is 1588. */ 418 uint8 ts_encap; /* OAM-TS(TS-Encaps). Applies only when 419 otsh_type is 1588. */ 420 uint64 oam_ts_data; /* OAM-TS(OAM-TS-Data) */ 421 uint32 latency_flow_ID; /* Latency flow ID generated by the PMF. */ 422 uint32 offset; /* OAM-TS(offset). Applies only when 423 otsh_type is oam.. */ 424 } bcm_pkt_dnx_otsh_t; 425 426 /* otmh src sysport extension */ 427 typedef struct bcm_pkt_dnx_otmh_src_sysport_extension_s { 428 uint8 valid; /* Set if the extension is present */ 429 bcm_gport_t src_sysport; /* Source System Port (OTMH.Source-System-Port) */ 430 } bcm_pkt_dnx_otmh_src_sysport_extension_t; 431 432 /* otmh vport extension */ 433 typedef struct bcm_pkt_dnx_otmh_vport_extension_s { 434 uint8 valid; /* Set if the extension is present */ 435 bcm_gport_t out_vport; /* Virtual port (OTMH.Out-LIF/CUD) */ 436 } bcm_pkt_dnx_otmh_vport_extension_t; 437 438 /* otmh */ 439 typedef struct bcm_pkt_dnx_otmh_s { 440 bcm_pkt_dnx_ftmh_action_type_t action_type; /* Action type (OTMH.TM-Action-Type) */ 441 bcm_color_t ftmh_dp; /* Drop precedence (OTMH.DP) */ 442 uint8 is_mc_traffic; /* AIndicate if the traffic is multicast 443 (OTMH.System-Multicast) */ 444 uint32 prio; /* Traffic class (OTMH.Traffic-Class) */ 445 bcm_gport_t dst_port; /* Destination local port 446 (OTMH.Destination-Port) */ 447 bcm_pkt_dnx_otmh_src_sysport_extension_t src_sysport_ext; /* OTMH Source System Port Extension */ 448 bcm_pkt_dnx_otmh_vport_extension_t out_vport_ext; /* OTMH Source System Port Extension */ 449 } bcm_pkt_dnx_otmh_t; 450 451 /* Internals */ 452 typedef struct bcm_pkt_dnx_internal_s { 453 uint32 trap_qualifier; /* Trap Qualifier */ 454 uint32 trap_id; /* Trap Id */ 455 } bcm_pkt_dnx_internal_t; 456 457 /* UDH header */ 458 typedef struct bcm_pkt_dnx_udh_s { 459 uint8 size; /* UDH size: 0/1/2/4 */ 460 uint32 data; /* UDH data */ 461 } bcm_pkt_dnx_udh_t; 462 463 /* dnx packet */ 464 typedef struct bcm_pkt_dnx_s { 465 bcm_pkt_dnx_type_t type; /* DNX Header type */ 466 bcm_pkt_dnx_itmh_t itmh; /* ITMH Header */ 467 bcm_pkt_dnx_ftmh_t ftmh; /* FTMH Header */ 468 bcm_pkt_dnx_otsh_t otsh; /* OAM-TS Header (OTSH) */ 469 bcm_pkt_dnx_otmh_t otmh; /* OTMH Header */ 470 bcm_pkt_dnx_internal_t internal; /* Internal Header */ 471 } bcm_pkt_dnx_t; 472 473 /* Initialize a BCM packet structure. */ 474 struct bcm_pkt_s { 475 bcm_pkt_blk_t *pkt_data; /* Pointer to array of data blocks. */ 476 uint8 blk_count; /* Number of blocks in data array. */ 477 uint8 unit; /* Unit number. */ 478 uint8 cos; /* The local COS queue to use. */ 479 uint8 prio_int; /* Internal priority of the packet. */ 480 bcm_vlan_t vlan; /* 802.1q VID or VSI or VPN. */ 481 uint8 vlan_pri; /* Vlan tag priority . */ 482 uint8 vlan_cfi; /* Vlan tag CFI bit. */ 483 bcm_vlan_t inner_vlan; /* Inner VID or VSI or VPN. */ 484 uint8 inner_vlan_pri; /* Inner vlan tag priority . */ 485 uint8 inner_vlan_cfi; /* Inner vlan tag CFI bit. */ 486 bcm_color_t color; /* Packet color. */ 487 int16 src_port; /* Source port used in header/tag. */ 488 bcm_trunk_t src_trunk; /* Source trunk group ID used in 489 header/tag, -1 if src_port set . */ 490 uint16 src_mod; /* Source module ID used in header/tag. */ 491 uint16 dest_port; /* Destination port used in header/tag. */ 492 uint16 dest_mod; /* Destination module ID used in 493 header/tag. */ 494 uint8 opcode; /* BCM_HG_OPCODE_xxx. */ 495 bcm_gport_t dst_gport; /* Destination virtual port */ 496 bcm_gport_t src_gport; /* Source virtual port */ 497 bcm_multicast_t multicast_group; /* Destination multicast group. */ 498 uint32 stk_flags; /* Stacking header flags. */ 499 bcm_pkt_stk_forward_t stk_forward; /* Stacking header forwarding opcode. */ 500 uint32 stk_classification_tag; /* Stacking header classification tag. */ 501 uint32 stk_pkt_prio; /* Stacking header new packet priority. */ 502 uint32 stk_dscp; /* Stacking header new DSCP. */ 503 uint32 stk_load_balancing_number; /* Stacking header load balancing 504 number. */ 505 bcm_if_t stk_encap_id; /* Stacking header encapsulation ID for 506 remote packet replication. */ 507 uint16 pkt_len; /* Packet length according to flags. */ 508 uint16 tot_len; /* Packet length as transmitted or 509 received. */ 510 bcm_pbmp_t tx_pbmp; /* Target ports. */ 511 bcm_pbmp_t tx_upbmp; /* Untagged target ports. */ 512 bcm_pbmp_t tx_l3pbmp; /* L3 ports. */ 513 bcm_port_t pkt_trace_src_port; /* pkt_trace_src_port */ 514 uint8 pfm; /* BCM_PORT_PFM_xxx flags. */ 515 uint32 rx_reason; /* Opcode from packet. */ 516 bcm_rx_reasons_t rx_reasons; /* Set of packet "reasons". */ 517 uint32 rx_path; /* Rx path of packet. */ 518 uint8 rx_unit; /* Local rx unit. */ 519 uint8 rx_port; /* Local rx port; not in HG hdr. */ 520 uint8 rx_cpu_cos; /* CPU may get pkt on diff cos. */ 521 uint8 rx_untagged; /* The packet was untagged on ingress. */ 522 uint32 rx_classification_tag; /* Classification tag. */ 523 uint32 rx_matched; /* Field processor matched rule. */ 524 bcm_if_t rx_l3_intf; /* L3 egress object interface ID. */ 525 bcm_vlan_action_t rx_outer_tag_action; /* Outer-tag action applied to packet. */ 526 bcm_vlan_action_t rx_inner_tag_action; /* Inner-tag action applied to packet. */ 527 uint32 rx_timestamp; /* Time stamp of time sync protocol 528 packets. */ 529 uint32 rx_timestamp_upper; /* Upper 32-bit of 64-bit timestamp of 530 OAM DM. */ 531 uint32 timestamp_flags; /* Timestamp flags. */ 532 void *cookie; /* User data for callback. */ 533 void *cookie2; /* Additional user data for callback. */ 534 bcm_pkt_cb_f call_back; /* Callback function. */ 535 uint32 flags; /* BCM_PKT_F_xxx flags. */ 536 void *next; /* When linked into lists. */ 537 int8 dma_channel; /* DMA channel used; may be -1. */ 538 bcm_pkt_blk_t _pkt_data; /* For single block packets (internal). */ 539 bcm_pkt_t *_last_pkt; /* To link to end of linked lists 540 (internal). */ 541 void *_dv; /* DV controlling this packet 542 (internal). */ 543 int8 _idx; /* Packet's index in the DV for RX 544 (internal). */ 545 bcm_pkt_t *_next; /* For BCM layer linked lists 546 (internal). */ 547 void *alloc_ptr; /* Pointer for deallocation (internal). */ 548 void *trans_ptr; /* Transport pointer associated with 549 packet (internal). */ 550 uint8 _higig[16]; /* HiGig header value (network byte 551 order). */ 552 uint8 _pb_hdr[12]; /* Pipe Bypass Header (network byte 553 order). */ 554 uint8 _sltag[4]; /* SL tag value (network byte order). */ 555 uint8 _vtag[4]; /* VLAN tag if not in packet (network 556 byte order). */ 557 uint8 _dpp_hdr[10]; /* DPP header contents */ 558 int _dpp_hdr_type; /* DPP header and extensions type */ 559 int flow_id; /* Internal flow id. */ 560 uint32 filter_enable; /* filters to be enabled. */ 561 bcm_pbmp_t _dv_tx_pbmp; /* Actual pbmp assigned to tx 562 descriptor(internal). */ 563 bcm_pbmp_t _dv_tx_upbmp; /* Actual upbmp assigned to tx 564 descriptor(internal). */ 565 uint32 flags2; /* BCM_PKT_F2_xxx flags. */ 566 uint8 oam_replacement_type; /* OAM replacement type used in SOBMH 567 header. */ 568 uint8 oam_replacement_offset; /* OAM replacement offset used in SOBMH 569 header. */ 570 uint16 oam_lm_counter_index; /* OAM LM counter index used in SOBMH 571 header. */ 572 uint32 rx_trap_data; /* Additional trap information */ 573 void *_dcb; /* Pointer for dcb. */ 574 uint16 oam_lm_counter_index_2; /* OAM Second LM counter index used in 575 SOBMH header. */ 576 uint16 ma_ptr; /* OAM MA Pointer value. For BCM5645x, 577 this corresponds to endpoint group 578 index */ 579 bcm_pkt_timestamp_mode_t timestamp_mode; /* OAM DM timestamp mode */ 580 bcm_pkt_oam_lm_counter_mode_t counter_mode_1; /* OAM LM counter-1 mode */ 581 bcm_pkt_oam_lm_counter_mode_t counter_mode_2; /* OAM LM counter-2 mode */ 582 uint8 timestamp_offset; /* Offset to place the timestamp in the 583 packet. */ 584 bcm_rx_decap_tunnel_t rx_decap_tunnel; /* Tunnel Decap during packet rx */ 585 bcm_gport_t src_vport; /* Source VPort (In-LIF) */ 586 bcm_gport_t dst_vport; /* Destination VPort (Out-LIF) */ 587 uint32 fwd_hdr_offset; /* Distance (in bytes) to forwarding 588 header from start of packet */ 589 int snoop_cmnd; /* Snoop command */ 590 bcm_gport_t stk_dst_gport; /* Stacking destination port */ 591 uint32 stk_route_tm_domains; /* Bitmap of the traversed TM domains */ 592 uint32 oam_hdr_offset; /* Distance (in bytes) to OAM header 593 from start of packet */ 594 uint8 oam_lm_replacement_offset; /* Replacement offset for LM counter in 595 Bytes */ 596 bcm_pkt_rx_oam_type_t rx_oam_pkt_type; /* OAM Pkt Type. */ 597 bcm_pkt_oam_counter_t oam_counter[BCM_PKT_OAM_COUNTER_MAX]; /* OAM counter array. */ 598 uint32 oam_counter_size; /* Size of Counter array */ 599 uint8 _olp_hdr[20]; /* OLP Header (network byte order). */ 600 bcm_pkt_dnx_t dnx_header_stack[BCM_PKT_NOF_DNX_HEADERS]; /* DNX Header stack */ 601 uint8 dnx_header_count; /* Number of DNX headers */ 602 uint8 _ext_higig[4]; /* Extended Higig Header (network byte 603 order). */ 604 void *tx_header; /* Pointer for Packet tx header 605 (internal). */ 606 uint8 txprocmh_qos_fields_valid; /* QoS properties to be picked up from 607 packet */ 608 uint8 txprocmh_congestion_int; /* Congestion priority of the packet. */ 609 uint8 txprocmh_mcast_lb_index_valid; /* If set, use the value from 610 txprocmh_mcast_lb_index */ 611 uint8 txprocmh_mcast_lb_index; /* Software to select load balancing 612 bitmap */ 613 uint16 txprocmh_ecmp_group_index; /* Single level ECMP group index */ 614 uint16 txprocmh_ecmp_member_index; /* ECMP member table index used by a 615 single level ECMP group */ 616 uint16 txprocmh_destination; /* Destination to be used based on 617 txprocmh_destination_type */ 618 uint8 txprocmh_destination_type; /* Destination Type/opcode of the packet */ 619 uint16 egress_to_cpu_hdr_size; /* Size of egress to CPU header in CMIC 620 devices. This header is applicable 621 only in the new generation of CMIC 622 called CMIC-X. */ 623 uint32 match_id[2]; /* Match ID information. */ 624 uint8 rqe_q_num; /* RQE Queue Number */ 625 uint32 forwarding_type; /* Packet forwarding type */ 626 uint32 forwarding_zone_id; /* Indicates packet was routed - UC OR 627 MC */ 628 }; 629 630 /* HiGig opcodes. */ 631 #define BCM_HG_OPCODE_CPU 0x00 /* CPU Frame. */ 632 #define BCM_HG_OPCODE_UC 0x01 /* Unicast Frame. */ 633 #define BCM_HG_OPCODE_BC 0x02 /* Broadcast or DLF frame. */ 634 #define BCM_HG_OPCODE_MC 0x03 /* Multicast Frame. */ 635 #define BCM_HG_OPCODE_IPMC 0x04 /* IP Multicast Frame. */ 636 637 /* Generic packet opcodes. */ 638 #define BCM_PKT_OPCODE_CPU 0x00 /* CPU Frame. */ 639 #define BCM_PKT_OPCODE_UC 0x01 /* Unicast Frame. */ 640 #define BCM_PKT_OPCODE_BC 0x02 /* Broadcast or DLF frame. */ 641 #define BCM_PKT_OPCODE_MC 0x03 /* Multicast Frame. */ 642 #define BCM_PKT_OPCODE_IPMC 0x04 /* IP Multicast Frame. */ 643 644 /* Packet flags. */ 645 #define BCM_PKT_F_HGHDR 0x1 /* HiGig header is active 646 (internal). */ 647 #define BCM_PKT_F_SLTAG 0x2 /* SL tag is active. */ 648 #define BCM_PKT_F_NO_VTAG 0x4 /* Packet does not contain VLAN 649 tag. */ 650 #define BCM_PKT_F_TX_UNTAG 0x8 /* TX packet untagged (internal). */ 651 #define BCM_TX_CRC_FLD 0xf0 /* CRC information */ 652 #define BCM_TX_CRC_ALLOC 0x10 /* Allocate buffer for CRC. */ 653 #define BCM_TX_CRC_REGEN 0x20 /* Regenerate CRC. */ 654 #define BCM_TX_CRC_APPEND (BCM_TX_CRC_ALLOC + BCM_TX_CRC_REGEN) 655 #define BCM_TX_CRC_FORCE_ERROR 0x40 /* Force CRC error. */ 656 #define BCM_TX_NO_PAD 0x100 /* Do not pad runt packets. */ 657 #define BCM_TX_FAST_PATH 0x200 /* Fast path TX. */ 658 #define BCM_TX_PURGE 0x400 /* XGS3 Set PURGE bit in DCB 659 (internal). */ 660 #define BCM_TX_LINKDOWN_TRANSMIT 0x800 /* Transmit on link down ports */ 661 #define BCM_TX_RELIABLE 0x1000 /* Relay (tunnel) packet 662 reliably. */ 663 #define BCM_TX_BEST_EFFORT 0x2000 /* Use best effort to relay 664 packet. */ 665 #define BCM_TX_LOOPBACK 0x4000 /* Loopback is indicated. */ 666 #define BCM_TX_PKT_PROP_ANY 0xf0000 /* All packet property fields. */ 667 #define BCM_TX_SRC_MOD 0x10000 /* Use the src_mod field from 668 packet. */ 669 #define BCM_TX_SRC_PORT 0x20000 /* Use the src_port field from 670 packet. */ 671 #define BCM_TX_PRIO_INT 0x40000 /* Use the prio_int field from 672 packet. */ 673 #define BCM_TX_PFM 0x80000 /* Use PFM field from packet. */ 674 #define BCM_TX_ETHER 0x100000 /* Fully mapped packet TX. */ 675 #define BCM_TX_HG_READY 0x200000 /* HiGig header in _higig. */ 676 #define BCM_TX_TIME_STAMP_REPORT 0x400000 /* Request transmit time stamp. */ 677 #define BCM_RX_LEARN_DISABLED 0x800000 /* Packet's SA is not learned. */ 678 #define BCM_RX_CRC_STRIP 0x1000000 /* Do not include the CRC in the 679 length of the packet. */ 680 #define BCM_RX_TUNNELLED 0x2000000 /* Packet was tunnelled. */ 681 #define BCM_RX_MIRRORED 0x4000000 /* Packet was mirrored. */ 682 #define BCM_RX_TRUNCATED 0x8000000 /* Packet was truncated. */ 683 #define BCM_PKT_F_TIMESYNC 0x10000000 /* Packet is for Time Sync 684 protocol. */ 685 #define BCM_PKT_F_TRUNK 0x20000000 /* Trunk port. */ 686 #define BCM_PKT_F_TEST 0x40000000 /* Set the Test bit. */ 687 #define BCM_PKT_F_ROUTED 0x80000000 /* L3 switched packet. */ 688 #define BCM_TX_EXT_HG_HDR 0x20 /* Extended Higig Header. */ 689 #define BCM_TX_NO_VISIBILITY_RESUME 0x8000 /* Disable Visibility resume for 690 DNX. */ 691 692 /* Packet flags2. */ 693 #define BCM_PKT_F2_REPLACEMENT_TYPE 0x1 /* OAM replacement type. */ 694 #define BCM_PKT_F2_REPLACEMENT_OFFSET 0x2 /* OAM replacement 695 offset. */ 696 #define BCM_PKT_F2_LM_COUNTER_INDEX 0x4 /* OAM LM counter index. */ 697 #define BCM_PKT_F2_TIMESTAMP_MODE 0x8 /* OAM DM time stamp type 698 - see 699 bcm_pkt_timestamp_mode_t 700 element, No-op by 701 default */ 702 #define BCM_PKT_F2_SAMPLE_RDI 0x10 /* OAM - Sample RDI bit. */ 703 #define BCM_PKT_F2_MA_PTR 0x20 /* OAM - MA Pointer . */ 704 #define BCM_PKT_F2_MEP_TYPE_UPMEP 0x40 /* OAM - MEP type - 705 UP/DOWN */ 706 #define BCM_PKT_F2_LM_COUNTER_INDEX_2 0x80 /* OAM -Second LM counter 707 index. */ 708 #define BCM_PKT_F2_COUNTER_MODE_1 0x100 /* OAM - Counter 1 mode - 709 Use specified counter 710 actions, no-op by 711 default */ 712 #define BCM_PKT_F2_COUNTER_MODE_2 0x200 /* OAM - Counter 2 mode - 713 Use specified counter 714 actions, no-op by 715 default */ 716 #define BCM_PKT_F2_SNOOPED 0x400 /* Packet was snooped */ 717 #define BCM_PKT_F2_UNKNOWN_DEST 0x800 /* packet has unknown 718 destination */ 719 #define BCM_PKT_F2_RX_PORT 0x1000 /* indicate that 720 bcm_pkt_s.rx_port is 721 used as a source port 722 for the 723 masquerade/visibility 724 feature */ 725 #define BCM_PKT_F2_VISIBILITY_PKT 0x2000 /* indication that this 726 is a visibility 727 packet(internal) */ 728 #define BCM_PKT_F2_OAM_TX 0x4000 /* Indicates OAM Packet 729 Tx */ 730 #define BCM_PKT_F2_OLP_READY 0x8000 /* Indicates OLP already 731 constructed in field 732 _olp_hdr */ 733 #define BCM_PKT_F2_LM_REPLACEMENT_OFFSET 0x10000 /* OAM LM replacement 734 offset */ 735 #define BCM_PKT_F2_MEP_TYPE_SAT_DOWNMEP 0x20000 /* SAT MEP TYPE - DOWN */ 736 #define BCM_PKT_F2_MEP_TYPE_SAT_UPMEP 0x40000 /* SAT MEP TYPE - UP */ 737 #define BCM_PKT_F2_MC_QUEUE 0x80000 /* Indicates packet goes 738 to MC queue */ 739 #define BCM_PKT_F2_CPU_TX_PROC 0x100000 /* Indicates CPU TX PROC 740 packet */ 741 #define BCM_PKT_F2_CONG_INT 0x200000 /* use the 742 txprocmh_congestion_int 743 field from packet */ 744 #define BCM_PKT_F2_EXT_HG_HDR 0x400000 /* use the extended higig 745 field from packet */ 746 #define BCM_PKT_F2_TWAMP_OWAMP_TS 0x800000 /* Enable timestamping 747 for TWAMP/OWAMP 748 packets */ 749 750 /* Flags for rx_untagged field in bcm_pkt_t structure. */ 751 #define BCM_PKT_OUTER_UNTAGGED 0x1 /* Packet received without outer vlan 752 tag. */ 753 #define BCM_PKT_INNER_UNTAGGED 0x2 /* Packet received without inner vlan 754 tag. */ 755 756 /* TimeSync Packet Flags. */ 757 #define BCM_TX_TIMESYNC_ONE_STEP 0x1 /* One step timestamp. */ 758 #define BCM_TX_TIMESYNC_ONE_STEP_INGRESS_SIGN 0x2 /* Ingress timestamp sign 759 bit. */ 760 #define BCM_TX_TIMESYNC_ONE_STEP_HDR_START_OFFSET 0x4 /* One step timestamp 761 header offset. */ 762 #define BCM_TX_TIMESYNC_ONE_STEP_REGEN_UDP_CHKSUM 0x8 /* One step timestamp 763 header offset. */ 764 #define BCM_TX_TIMESYNC_INGRESS_SIGN (BCM_TX_TIMESYNC_ONE_STEP_INGRESS_SIGN) /* Ingress timestamp sign 765 bit. */ 766 #define BCM_TX_TIMESYNC_HDR_START_OFFSET (BCM_TX_TIMESYNC_ONE_STEP_HDR_START_OFFSET) /* PTP header offset in 767 packet buffer. */ 768 #define BCM_TX_TIMESYNC_REGEN_UDP_CHKSUM (BCM_TX_TIMESYNC_ONE_STEP_REGEN_UDP_CHKSUM) /* Regenerate UDP header 769 checksum of PTP 770 packet. */ 771 772 /* Stacking Packet flags. */ 773 #define BCM_PKT_STK_F_MIRROR 0x1 /* Mirror packet. */ 774 #define BCM_PKT_STK_F_DO_NOT_MODIFY 0x2 /* Do not alter packet on 775 egress device. */ 776 #define BCM_PKT_STK_F_TRUNK_FAILOVER 0x4 /* Packet is redirected 777 due to trunk failover. */ 778 #define BCM_PKT_STK_F_SRC_PORT 0x8 /* Source GPORT provided. */ 779 #define BCM_PKT_STK_F_DST_PORT 0x10 /* Destination GPORT 780 provided. */ 781 #define BCM_PKT_STK_F_DEFERRED_DROP 0x20 /* Drop in egress device. */ 782 #define BCM_PKT_STK_F_DEFERRED_CHANGE_PKT_PRIO 0x40 /* Update packet priority 783 to stk_pkt_prio in 784 egress device. */ 785 #define BCM_PKT_STK_F_DEFERRED_CHANGE_DSCP 0x80 /* Update DSCP to 786 stk_dscp in egress 787 device. */ 788 #define BCM_PKT_STK_F_CLASSIFICATION_TAG 0x100 /* stk_classification_tag 789 field is valid. */ 790 #define BCM_PKT_STK_F_VLAN_TRANSLATE_NONE 0x200 /* No VLAN translation 791 performed. */ 792 #define BCM_PKT_STK_F_VLAN_TRANSLATE_UNCHANGED 0x400 /* VLAN translation did 793 not change packet. */ 794 #define BCM_PKT_STK_F_VLAN_TRANSLATE_CHANGED 0x800 /* VLAN translation 795 changed packet. */ 796 #define BCM_PKT_STK_F_DO_NOT_LEARN 0x1000 /* Packet should not be 797 learned on egress 798 device. */ 799 #define BCM_PKT_STK_F_PRESERVE_DSCP 0x2000 /* Egress device should 800 not change DSCP. */ 801 #define BCM_PKT_STK_F_PRESERVE_PKT_PRIO 0x4000 /* Egress device should 802 not change packet 803 priority. */ 804 #define BCM_PKT_STK_F_TX_TAG 0x8000 /* The VLAN tag should be 805 included in the packet 806 data (internal). */ 807 #define BCM_PKT_STK_F_ENCAP_ID 0x10000 /* The stk_encap_id value 808 is provided. */ 809 #define BCM_PKT_STK_F_FAILOVER 0x20000 /* Use the protection 810 nexthop instead of the 811 default nexthop. */ 812 813 /* internal packet trace flags */ 814 #define BCM_PKT_TRACE_LEARN 0x1 /* learning ensable on 815 internal trace packet */ 816 #define BCM_PKT_TRACE_NO_IFP 0x2 /* disable ingress field 817 processor lookup on 818 internal trace packet */ 819 #define BCM_PKT_TRACE_FORWARD 0x4 /* forward internal trace 820 packet to egress */ 821 #define BCM_PKT_TRACE_DROP_TO_MMU 0x8 /* Drop trace packet to 822 MMU else forward to 823 egress */ 824 #define BCM_PKT_TRACE_DROP_TO_EGR 0x10 /* Drop trace packet to 825 egress */ 826 #define BCM_PKT_TRACE_RETRIEVE_DATA_ONLY 0x20 /* Get the visibility 827 data with no manual 828 visibility packet 829 inject */ 830 831 /* Filter types. */ 832 #define BCM_PKT_FILTER_LAG 0x1 /* LAG filter. */ 833 #define BCM_PKT_FILTER_TAGGED 0x2 /* Tag filter. */ 834 #define BCM_PKT_FILTER_PORT_MASK 0x4 /* Port mask filter. */ 835 #define BCM_PKT_FILTER_STP 0x8 /* STP filter. */ 836 #define BCM_PKT_FILTER_EAP 0x10 /* EAP filter. */ 837 #define BCM_PKT_FILTER_INGRESS_VLAN 0x20 /* Ingress Vlan filter. */ 838 #define BCM_PKT_FILTER_EGRESS_VLAN 0x40 /* Egress Vlan filter. */ 839 #define BCM_PKT_FILTER_SA 0x80 /* Source address filter. */ 840 841 /* CPU to CPU tunnel modes. */ 842 typedef enum bcm_cpu_tunnel_mode_e { 843 BCM_CPU_TUNNEL_NONE = 0, /* Do not tunnel. */ 844 BCM_CPU_TUNNEL_PACKET_RELIABLE = 1, /* Use reliable transport. */ 845 BCM_CPU_TUNNEL_PACKET_BEST_EFFORT = 2, /* Use best effort transport. */ 846 BCM_CPU_TUNNEL_PACKET = 3 /* Use default mode. */ 847 } bcm_cpu_tunnel_mode_t; 848 849 /* CPU to CPU tunnel flags. */ 850 #define BCM_CPU_TUNNEL_F_UNTAGGED 0x1 /* Untagged packet. */ 851 #define BCM_CPU_TUNNEL_F_L3 0x2 /* L3 packet. */ 852 #define BCM_CPU_TUNNEL_F_PBMP 0x4 /* Use port bitmap, not just 853 port. */ 854 #define BCM_CPU_TUNNEL_F_RELIABLE 0x8 /* Use reliable transport. */ 855 #define BCM_CPU_TUNNEL_F_BEST_EFFORT 0x10 /* Use best effort transport. */ 856 #define BCM_CPU_TUNNEL_F_ALL_UNTAGGED 0x20 /* Use with port bitmap. */ 857 858 /* Backward compatibility. */ 859 #define bcm_tunnel_mode_t bcm_cpu_tunnel_mode_t 860 861 /* Backward compatibility. */ 862 #define BCM_TUNNEL_NONE BCM_CPU_TUNNEL_NONE 863 #define BCM_TUNNEL_PACKET_RELIABLE BCM_CPU_TUNNEL_PACKET_RELIABLE 864 #define BCM_TUNNEL_PACKET_NO_ACK BCM_CPU_TUNNEL_PACKET_BEST_EFFORT 865 #define BCM_TUNNEL_PACKET BCM_CPU_TUNNEL_PACKET 866 867 /* Backward compatibility. */ 868 #define BCM_TUNNEL_F_UNTAGGED BCM_CPU_TUNNEL_F_UNTAGGED 869 #define BCM_TUNNEL_F_L3 BCM_CPU_TUNNEL_F_L3 870 #define BCM_TUNNEL_F_PBMP BCM_CPU_TUNNEL_F_PBMP 871 #define BCM_TUNNEL_F_RELIABLE BCM_CPU_TUNNEL_F_RELIABLE 872 #define BCM_TUNNEL_F_BEST_EFFORT BCM_CPU_TUNNEL_F_BEST_EFFORT 873 #define BCM_TUNNEL_F_ALL_UNTAGGED BCM_CPU_TUNNEL_F_ALL_UNTAGGED 874 875 /* Set up a single buffer packet. */ 876 #define BCM_PKT_ONE_BUF_SETUP(pkt, buf, _len) \ 877 do { \ 878 (pkt)->_pkt_data.data = (buf); \ 879 (pkt)->_pkt_data.len = (_len); \ 880 (pkt)->pkt_data = &(pkt)->_pkt_data; \ 881 (pkt)->blk_count = 1; \ 882 } while (0) 883 884 /* Helper macro for single buffer Ethernet packet (not HiGig). */ 885 #define BCM_PKT_TX_LEN_SET(pkt, _len) \ 886 (pkt)->_pkt_data.len = (_len) 887 888 /* Helper macro for single buffer Ethernet packet (not HiGig). */ 889 #define _BCM_HTONS_CVT_SET(pkt, val, posn) \ 890 do { \ 891 uint16 _tmp; \ 892 _tmp = bcm_htons(val); \ 893 sal_memcpy((pkt)->_pkt_data.data + (posn), &_tmp, 2); \ 894 } while (0) 895 896 /* Helper macro for single buffer Ethernet packet (not HiGig). */ 897 #define BCM_PKT_HDR_DMAC_SET(pkt, mac) \ 898 sal_memcpy((pkt)->_pkt_data.data, (mac), 6) 899 900 /* Helper macro for single buffer Ethernet packet (not HiGig). */ 901 #define BCM_PKT_HDR_SMAC_SET(pkt, mac) \ 902 sal_memcpy((pkt)->_pkt_data.data + 6, (mac), 6) 903 904 /* Helper macro for single buffer Ethernet packet (not HiGig). */ 905 #define BCM_PKT_HDR_TPID_SET(pkt, tpid) \ 906 _BCM_HTONS_CVT_SET(pkt, tpid, 12) 907 908 /* Helper macro for single buffer Ethernet packet (not HiGig). */ 909 #define BCM_PKT_HDR_UNTAGGED_LEN_SET(pkt, len) \ 910 _BCM_HTONS_CVT_SET(pkt, len, 12) 911 912 /* Helper macro for single buffer Ethernet packet (not HiGig). */ 913 #define BCM_PKT_HDR_VTAG_CONTROL_SET(pkt, vtag) \ 914 _BCM_HTONS_CVT_SET(pkt, vtag, 14) 915 916 /* Helper macro for single buffer Ethernet packet (not HiGig). */ 917 #define BCM_PKT_HDR_TAGGED_LEN_SET(pkt, len) \ 918 _BCM_HTONS_CVT_SET(pkt, len, 16) 919 920 /* Helper macro for single buffer Ethernet packet (not HiGig). */ 921 #define BCM_PKT_HDR_SNAP_DSAP_SET(pkt, dsap) \ 922 (pkt)->_pkt_data.data[18] = (dsap) 923 924 /* Helper macro for single buffer Ethernet packet (not HiGig). */ 925 #define BCM_PKT_HDR_SNAP_SSAP_SET(pkt, ssap) \ 926 (pkt)->_pkt_data.data[19] = (ssap) 927 928 /* Helper macro for single buffer Ethernet packet (not HiGig). */ 929 #define BCM_PKT_HDR_SNAP_CONTROL_SET(pkt, ctl) \ 930 (pkt)->_pkt_data.data[20] = (ctl) 931 932 /* Helper macro for single buffer Ethernet packet (not HiGig). */ 933 #define BCM_PKT_HDR_SNAP_ORG_SET(pkt, b1, b2, b3) \ 934 do { \ 935 (pkt)->_pkt_data.data[21] = (b1); \ 936 (pkt)->_pkt_data.data[22] = (b2); \ 937 (pkt)->_pkt_data.data[23] = (b3); \ 938 } while (0) 939 940 /* Helper macro for single buffer Ethernet packet (not HiGig). */ 941 #define BCM_PKT_HDR_SNAP_ETYPE_SET(pkt, etype) \ 942 _BCM_HTONS_CVT_SET(pkt, etype, 24) 943 944 /* Set a single port for a packet for TX. */ 945 #define BCM_PKT_PORT_SET(pkt, _port, _untagged, _l3) \ 946 do { \ 947 BCM_PBMP_PORT_SET((pkt)->tx_pbmp, _port); \ 948 if ((_untagged) != FALSE) { \ 949 BCM_PBMP_PORT_SET((pkt)->tx_upbmp, _port); \ 950 } else { \ 951 BCM_PBMP_CLEAR((pkt)->tx_upbmp); \ 952 } \ 953 if ((_l3) != FALSE) { \ 954 BCM_PBMP_PORT_SET((pkt)->tx_l3pbmp, _port); \ 955 } else { \ 956 BCM_PBMP_CLEAR((pkt)->tx_l3pbmp); \ 957 } \ 958 } while (0) 959 960 /* Check if HiGig header is active in the packet. */ 961 #define BCM_PKT_HAS_HGHDR(pkt) \ 962 (((pkt)->flags & BCM_PKT_F_HGHDR) != 0) 963 964 /* Check if SL tag is active in the packet. */ 965 #define BCM_PKT_HAS_SLTAG(pkt) \ 966 (((pkt)->flags & BCM_PKT_F_SLTAG) != 0) 967 968 /* Check if VLAN tag is not present in packet. */ 969 #define BCM_PKT_NO_VLAN_TAG(pkt) \ 970 (((pkt)->flags & BCM_PKT_F_NO_VTAG) != 0) 971 972 /* Do not include CRC in length on RX. */ 973 #define BCM_PKT_RX_CRC_STRIP(pkt) \ 974 ((pkt)->flags & BCM_RX_CRC_STRIP) 975 976 /* Strip VLAN tag on RX; do not include in length. */ 977 #define BCM_PKT_RX_VLAN_TAG_STRIP(pkt) \ 978 BCM_PKT_NO_VLAN_TAG(pkt) 979 980 #define BCM_TX_PKT_PROP_ANY_TST(pkt) \ 981 (((pkt)->flags & BCM_TX_PKT_PROP_ANY) != 0) 982 983 #define BCM_PKT_TX_ETHER(pkt) \ 984 (((pkt)->flags & BCM_TX_ETHER) != 0) 985 986 #define BCM_PKT_TX_HG_READY(pkt) \ 987 (((pkt)->flags & BCM_TX_HG_READY) != 0) 988 989 /* 990 * Check if fabric mapped, which means that the packet is sent 991 * from the CPU through the HiGig ingress pipeline. 992 */ 993 #define BCM_PKT_TX_FABRIC_MAPPED(pkt) \ 994 ((((pkt)->flags & BCM_TX_ETHER ) !=0 ) && \ 995 (((pkt)->flags & (BCM_TX_PKT_PROP_ANY | BCM_TX_HG_READY) ) !=0 )) 996 997 /* Pointer to beginning of IEEE packet. */ 998 #define BCM_PKT_IEEE(pkt) \ 999 ((uint8*)((pkt)->pkt_data[0].data)) 1000 1001 /* Length of IEEE packet including MAC addresses and CRC. */ 1002 #define BCM_PKT_IEEE_LEN(pkt) \ 1003 ((pkt)->pkt_len) 1004 1005 /* Pointer to destination MAC address. */ 1006 #define BCM_PKT_DMAC(pkt) \ 1007 BCM_PKT_IEEE(pkt) 1008 1009 /* Pointer to VLAN tag (all 4 bytes). */ 1010 #define BCM_PKT_VLAN_PTR(pkt) \ 1011 (((pkt)->flags & BCM_PKT_F_NO_VTAG) ? (pkt)->_vtag : \ 1012 ((BCM_PKT_DMAC(pkt) + 2*sizeof(bcm_mac_t)))) 1013 1014 /* The protocol (eg 0x8100) bytes. */ 1015 #define BCM_PKT_TAG_PROTOCOL(pkt) \ 1016 ((uint16) ((BCM_PKT_VLAN_PTR(pkt)[0] << 8) | (BCM_PKT_VLAN_PTR(pkt)[1]))) 1017 1018 /* The VLAN control tag. */ 1019 #define BCM_PKT_VLAN_CONTROL(pkt) \ 1020 ((uint16) ((BCM_PKT_VLAN_PTR(pkt)[2] << 8) | (BCM_PKT_VLAN_PTR(pkt)[3]))) 1021 1022 /* The ID from the VLAN control tag. */ 1023 #define BCM_PKT_VLAN_ID(pkt) \ 1024 BCM_VLAN_CTRL_ID(BCM_PKT_VLAN_CONTROL(pkt)) 1025 1026 /* The priority from the VLAN control tag. */ 1027 #define BCM_PKT_VLAN_PRI(pkt) \ 1028 BCM_VLAN_CTRL_PRIO(BCM_PKT_VLAN_CONTROL(pkt)) 1029 1030 /* The CFI from the VLAN control tag. */ 1031 #define BCM_PKT_VLAN_CFI(pkt) \ 1032 BCM_VLAN_CTRL_CFI(BCM_PKT_VLAN_CONTROL(pkt)) 1033 1034 /* Pointer to packet's HiGig header. */ 1035 #define BCM_PKT_HG_HDR(pkt) \ 1036 ((pkt)->_higig) 1037 1038 /* Pointer to packet's SL tag. */ 1039 #define BCM_PKT_SL_TAG(pkt) \ 1040 ((pkt)->_sltag) 1041 1042 /* Pointer to packet's Pipeline Bypass header. */ 1043 #define BCM_PKT_PB_HDR(pkt) \ 1044 ((pkt)->_pb_hdr) 1045 1046 /* Pointer to packet's Extended Higig header. */ 1047 #define BCM_PKT_EXT_HG_HDR(pkt) \ 1048 ((pkt)->_ext_higig) 1049 1050 #define BCM_PKT_NO_VTAG_REQUIRE(pkt) \ 1051 ((pkt)->flags |= BCM_PKT_F_NO_VTAG) 1052 1053 #define BCM_PKT_HGHDR_CLR(pkt) \ 1054 ((pkt)->flags &= (~BCM_PKT_F_HGHDR)) 1055 1056 #define BCM_PKT_HGHDR_REQUIRE(pkt) \ 1057 ((pkt)->flags |= BCM_PKT_F_HGHDR) 1058 1059 #define BCM_PKT_SLTAG_REQUIRE(pkt) \ 1060 ((pkt)->flags |= BCM_PKT_F_SLTAG) 1061 1062 /* How many bytes in the data blocks. */ 1063 #define BCM_PKT_BLK_BYTES_CALC(pkt, bytes) \ 1064 do { \ 1065 int i; \ 1066 (bytes) = 0; \ 1067 for (i = 0; i < (pkt)->blk_count; i++) { \ 1068 (bytes) += (pkt)->pkt_data[i].len; \ 1069 } \ 1070 } while (0) 1071 1072 /* Packet length calculated based on flags. */ 1073 #define BCM_PKT_TX_LEN(pkt, bytes) \ 1074 do { \ 1075 BCM_PKT_BLK_BYTES_CALC(pkt, bytes); \ 1076 if (BCM_PKT_HAS_HGHDR(pkt)) (bytes) += 12; \ 1077 if (BCM_PKT_HAS_SLTAG(pkt)) (bytes) += 4; \ 1078 if ((pkt)->flags & BCM_PKT_F_NO_VTAG) (bytes) += 4; \ 1079 } while (0) 1080 1081 /* Packet length including SL, HiGig, VLAN tags. */ 1082 #define BCM_PKT_RX_TOT_LEN(pkt, bytes) \ 1083 (bytes) = (pkt)->tot_len 1084 1085 /* 1086 * BCM packet allocation function. 1087 * 1088 * If unit is specified, the flags should be set up according to the unit 1089 * as best as possible. 1090 * 1091 * If len > 0, then a packet buffer should be allocated and the packet 1092 * will be setup up for a single data block. If len <= 0, no packet 1093 * allocation will be made. 1094 */ 1095 typedef int (*bcm_pkt_alloc_f)( 1096 int unit, 1097 int len, 1098 bcm_pkt_t **pkt_buf); 1099 1100 /* BCM packet free function. */ 1101 typedef int (*bcm_pkt_free_f)( 1102 int unit, 1103 bcm_pkt_t *pkt); 1104 1105 /* Map target ports according to VLAN and L2 tables. */ 1106 typedef int (*bcm_pkt_l2_map_f)( 1107 int unit, 1108 bcm_pkt_t *pkt, 1109 bcm_mac_t dest_mac, 1110 int vid); 1111 1112 /* Initialize and set up a bcm_pkt_t structure. */ 1113 extern int bcm_pkt_clear( 1114 int unit, 1115 bcm_pkt_t *pkt, 1116 bcm_pkt_blk_t *blks, 1117 int blk_count, 1118 uint32 flags, 1119 bcm_pkt_t **pkt_buf); 1120 1121 /* Initialize packet flags based on the type of device. */ 1122 extern int bcm_pkt_flags_init( 1123 int unit, 1124 bcm_pkt_t *pkt, 1125 uint32 init_flags); 1126 1127 /* Set up the length and flags for a bcm_pkt_t structure. */ 1128 extern int bcm_pkt_flags_len_setup( 1129 int unit, 1130 bcm_pkt_t *pkt, 1131 int alloc_bytes, 1132 int payload_len, 1133 uint32 flags); 1134 1135 /* Copy data into the data blocks of a packet structure. */ 1136 extern int bcm_pkt_memcpy( 1137 bcm_pkt_t *pkt, 1138 int dest_byte, 1139 uint8 *src, 1140 int len); 1141 1142 /* Calculate a byte offset in the data buffer for a packet. */ 1143 extern int bcm_pkt_byte_index( 1144 bcm_pkt_t *pkt, 1145 int n, 1146 int *len, 1147 int *blk_idx, 1148 uint8 **location); 1149 1150 /* Allocate a packet structure and packet data. */ 1151 extern int bcm_pkt_alloc( 1152 int unit, 1153 int size, 1154 uint32 flags, 1155 bcm_pkt_t **pkt_buf); 1156 1157 /* Deallocate a packet structure and packet data. */ 1158 extern int bcm_pkt_free( 1159 int unit, 1160 bcm_pkt_t *pkt); 1161 1162 /* Allocate or deallocate an array of packets. */ 1163 extern int bcm_pkt_blk_alloc( 1164 int unit, 1165 int count, 1166 int size, 1167 uint32 flags, 1168 bcm_pkt_t ***packet_array); 1169 1170 /* Allocate or deallocate an array of packets. */ 1171 extern int bcm_pkt_blk_free( 1172 int unit, 1173 bcm_pkt_t **pkt, 1174 int count); 1175 1176 /* Allocate or deallocate a packet structure using =bcm_rx_alloc. */ 1177 extern int bcm_pkt_rx_alloc( 1178 int unit, 1179 int len, 1180 bcm_pkt_t **pkt_buf); 1181 1182 /* Allocate or deallocate a packet structure using =bcm_rx_alloc. */ 1183 extern int bcm_pkt_rx_free( 1184 int unit, 1185 bcm_pkt_t *pkt); 1186 1187 /* Initialize a BCM packet structure. */ 1188 extern void bcm_pkt_t_init( 1189 bcm_pkt_t *pkt); 1190 1191 /* Initialize a BCM packet block structure. */ 1192 extern void bcm_pkt_blk_t_init( 1193 bcm_pkt_blk_t *pkt_blk); 1194 1195 /* Set ECMP group field in the pkt structure */ 1196 extern int bcm_pkt_ecmp_grp_set( 1197 int unit, 1198 bcm_pkt_t *pkt, 1199 bcm_if_t ecmp_group_id); 1200 1201 /* Set ECMP member field in the pkt structure */ 1202 extern int bcm_pkt_ecmp_member_set( 1203 int unit, 1204 bcm_pkt_t *pkt, 1205 bcm_if_t ecmp_group_id, 1206 bcm_if_t ecmp_member_id); 1207 1208 /* Set nexthop field in the pkt structure */ 1209 extern int bcm_pkt_nexthop_set( 1210 int unit, 1211 bcm_pkt_t *pkt, 1212 bcm_if_t nexthop_id); 1213 1214 /* Initialize a BCM RX reasons structure. */ 1215 extern void bcm_rx_reasons_t_init( 1216 bcm_rx_reasons_t *reasons); 1217 1218 /* Packet drop reasons */ 1219 typedef enum bcm_pkt_drop_reason_e { 1220 bcmPktDropReasonEgressVlanTranslateMiss = 0, /* Packet marked for drop due to egress 1221 vlan translate miss */ 1222 bcmPktDropReasonEgressTunnelSnap = 1, /* SNAP packet dropped becasuse it is 1223 being tunneled */ 1224 bcmPktDropReasonEgressColorSelect = 2, /* If control bcmSwitchColorSelect is 1225 not set to BCM_COLOR_OUTER_CFI and 1226 the CFI of the packet is derived as 1227 1, then packet is dropped */ 1228 bcmPktDropReasonEgressTtlError = 3, /* Packet marked for drop due to TTL 1229 error */ 1230 bcmPktDropReasonEgressVlanFilter = 4, /* Packet marked for drop due to port 1231 not being a member of VLAN. This 1232 happens when VLAN filtering is 1233 enabled by passing 1234 BCM_PORT_VLAN_MEMBER_EGRESS flags to 1235 bcm_port_vlan_member_set API */ 1236 bcmPktDropReasonEgressStgBlocked = 5, /* Packet marked for drop due to 1237 Spanning tree in blocking state */ 1238 bcmPktDropReasonEgressIPMCSameVlanPrune = 6, /* IPMC packet marked for drop due to 1239 bcmSwitchDropReasonIpmcSameVlanPruning 1240 setting */ 1241 bcmPktDropReasonEgressMmuPurge = 7, /* Packet marked for drop due to MMU 1242 purge */ 1243 bcmPktDropReasonEgressMmuAge = 8, /* Packet marked for drop due to MMU age */ 1244 bcmPktDropReasonEgressBadTdipDrop = 9, /* Packet marked for drop due to bad 1245 tunnel destination IP in case of 6to4 1246 tunnels and ISATAP tunnels - possible 1247 reasons are incorrect prefix for IPv6 1248 DIP,IPv4 DIP/SIP is 1249 BC/Zero/loopback/Class-D, IPv4 SIP = 1250 DIP */ 1251 bcmPktDropReasonEgressProtection = 10, /* Packets dropped because of protection 1252 drop control */ 1253 bcmPktDropReasonEgressUnknownVlan = 11, /* Packet marked for drop due to unknown 1254 VLAN. This happens when 1255 bcmVlanDropUnknown vlan control is 1256 used to set dropping of unknown VLAN 1257 packets */ 1258 bcmPktDropReasonEgressStgDisabled = 12, /* Packet marked for drop due to 1259 Spanning tree in disable state */ 1260 bcmPktDropReasonEgressHiGig2ReservedPPD = 13, /* Packets dropped because of Higig2 1261 header with reserved ppd going out on 1262 non-hg2 ports */ 1263 bcmPktDropReasonEgressHigigPlusUnknown = 14, /* Unknown HigigPlus packet incoming 1264 from hg source and dest is non-hg */ 1265 bcmPktDropReasonEgressL2MtuExceeded = 15, /* Packet dropped because of L2 MTU 1266 checks configured on the port 1267 (physical/virtual) */ 1268 bcmPktDropReasonEgressCompositeError = 16, /* Packet marked for drop due to parity 1269 error from memories or ISM lookup 1270 fail */ 1271 bcmPktDropReasonEgressMulticastPruned = 17, /* L3 Multicast packets marked for drop 1272 due to BCM_L3_MULTICAST_L3_DROP or 1273 BCM_L3_MULTICAST_L2_DROP setting in 1274 the multicast APIs */ 1275 bcmPktDropReasonEgressHigigPlusInvalidModuleId = 18, /* Unknown HigigPlus packet incoming 1276 from non-hg source and dest is hg and 1277 the modid is greater than 31 */ 1278 bcmPktDropReasonEgressFieldAction = 19, /* Packet dropped due to a egress field 1279 action */ 1280 bcmPktDropReasonEgressSplitHorizon = 20, /* Packet marked for drop due to split 1281 horizon check. This is done by 1282 enabling pruning for DVP network 1283 group via 1284 bcm_switch_network_group_config_set 1285 with 1286 BCM_SWITCH_NETWORK_GROUP_EGRESS_PRUNE_ENABLE */ 1287 bcmPktDropReasonEgressSVPRemoval = 21, /* Packet marked for drop due to virtual 1288 port pruning - SVP = DVP and VP based 1289 pruning is enabled 1290 (DISABLE_VP_PRUNING is set to 0 in 1291 Source VP table) */ 1292 bcmPktDropReasonEgressNivSrcKnockout = 22, /* Outgoing packet dropped due to NIV 1293 pruning check */ 1294 bcmPktDropReasonEgressNonUCPrune = 23, /* Non-unicast packet marked for drop 1295 due to drop condition set in egress 1296 next hop via 1297 bcm_mpls/l2gre/vxlan_port_add API 1298 with BCM_MPLS/L2GRE/VXLAN_PORT_DROP 1299 flag */ 1300 bcmPktDropReasonEgressTrillPacket = 24, /* Trill packets being sent on non-trill 1301 ports */ 1302 bcmPktDropReasonEgressPacketTooSmall = 25, /* Packet dropped since it it too small */ 1303 bcmPktDropReasonEgressNonTrillPacket = 26, /* Non-Trill packets being sent on trill 1304 ports */ 1305 bcmPktDropReasonEgressVpLagPruned = 27, /* Packet dropped because of VP lag 1306 pruning checks in the egress */ 1307 bcmPktDropReasonEgressInvalid1588Packet = 28, /* Packet dropped since it is a invalid 1308 1588 packet */ 1309 bcmPktDropReasonEgressInvalidFcoePacket = 29, /* Packet dropped since it is a invalid 1310 FCOE packet */ 1311 bcmPktDropReasonEgressInvalidCnmPacket = 30, /* Packet dropped since it is a invalid 1312 CNM packet */ 1313 bcmPktDropReasonEgressOriginalPacket = 31, /* Packet dropped in egress due to user 1314 configuration */ 1315 bcmPktDropReasonCount = 32 /* Always Last. Not a usable value */ 1316 } bcm_pkt_drop_reason_t; 1317 1318 typedef struct bcm_pkt_drop_reasons_s { 1319 SHR_BITDCL rbits[_SHR_BITDCLSIZE(bcmPktDropReasonCount)]; 1320 } bcm_pkt_drop_reasons_t; 1321 1322 /* 1323 * Macro to check if a reason (bcmPktDropReason*) is included in a set of 1324 * reasons (bcm_pkt_drop_reasons_t). 1325 * 1326 * Returns: 1327 * zero => reason is not included in the set 1328 * non-zero => reason is included in the set 1329 */ 1330 #define BCM_PKT_DROP_REASON_GET(_drop_reasons, _drop_reason) \ 1331 SHR_BITGET(((_drop_reasons).rbits), (_drop_reason)) 1332 1333 /* 1334 * Macro to add a reason (bcmPktDropReason*) to a set of reasons 1335 * (bcm_pkt_drop_reasons_t). 1336 */ 1337 #define BCM_PKT_DROP_REASON_SET(_drop_reasons, _drop_reason) \ 1338 SHR_BITSET(((_drop_reasons).rbits), (_drop_reason)) 1339 1340 /* 1341 * Macro to add all reasons (bcmPktDropReason*) to a set of reasons 1342 * (bcm_pkt_drop_reasons_t). 1343 */ 1344 #define BCM_PKT_DROP_REASON_SET_ALL(_drop_reasons) \ 1345 SHR_BITSET_RANGE(((_drop_reasons).rbits), 0, bcmPktDropReasonCount) 1346 1347 /* 1348 * Macro to clear a reason (bcmPktDropReason*) from a set of reasons 1349 * (bcm_pkt_drop_reasons_t). 1350 */ 1351 #define BCM_PKT_DROP_REASON_CLEAR(_drop_reasons, _drop_reason) \ 1352 SHR_BITCLR(((_drop_reasons).rbits), (_drop_reason)) 1353 1354 /* Macro to clear a set of reasons (bcm_pkt_drop_reasons_t). */ 1355 #define BCM_PKT_DROP_REASON_CLEAR_ALL(_drop_reasons) \ 1356 SHR_BITCLR_RANGE(((_drop_reasons).rbits), 0, bcmPktDropReasonCount) 1357 1358 /* Macro to check if a set of reasons (bcm_pkt_drop_reasons_t) is empty. */ 1359 #define BCM_PKT_DROP_REASON_IS_NULL(_drop_reasons) \ 1360 SHR_BITNULL_RANGE(((_drop_reasons).rbits), 0, bcmPktDropReasonCount) 1361 1362 /* Macro to itterate over a set of reasons (bcm_pkt_drop_reasons_t). */ 1363 #define BCM_PKT_DROP_REASON_ITER(_drop_reasons, _drop_reason) \ 1364 for(_drop_reason = bcmPktDropReasonEgressVlanTranslateMiss; _drop_reason < (int)bcmPktDropReasonCount; _drop_reason++) if(SHR_BITGET(((_drop_reasons).rbits), (_drop_reason))) 1365 1366 /* 1367 * Macro to count number of active reasons in a set of reasons 1368 * (bcm_pkt_drop_reasons_t). 1369 */ 1370 #define BCM_PKT_DROP_REASON_COUNT(_drop_reasons, count) \ 1371 SHR_BITCOUNT_RANGE(((_drop_reasons).rbits), count, 0, bcmPktDropReasonCount) 1372 1373 1374 /* Macro to compare two sets of reasons (bcm_pkt_drop_reasons_t). */ 1375 #define BCM_PKT_DROP_REASON_EQ(_drop_reasons1, _drop_reasons2) \ 1376 SHR_BITEQ_RANGE(((_drop_reasons1).rbits), ((_drop_reasons2).rbits), 0, bcmPktDropReasonCount) 1377 1378 1379 /* 1380 * Macro to negative compare two sets of reasons 1381 * (bcm_pkt_drop_reasons_t). 1382 */ 1383 #define BCM_PKT_DROP_REASON_NEQ(_drop_reasons1, _drop_reasons2) \ 1384 (!SHR_BITEQ_RANGE(((_drop_reasons1).rbits), ((_drop_reasons2).rbits), 0, bcmPktDropReasonCount)) 1385 1386 1387 /* 1388 * Macro to perform logical AND operation on two sets of reasons 1389 * (bcm_pkt_drop_reasons_t). 1390 */ 1391 #define BCM_PKT_DROP_REASON_AND(_drop_reasons1, _drop_reasons2) \ 1392 SHR_BITAND_RANGE(((_drop_reasons1).rbits), ((_drop_reasons2).rbits), 0, bcmPktDropReasonCount, ((_drop_reasons1).rbits)) 1393 1394 1395 /* 1396 * Macro to perform logical OR operation on two sets of reasons 1397 * (bcm_pkt_drop_reasons_t). 1398 */ 1399 #define BCM_PKT_DROP_REASON_OR(_drop_reasons1, _drop_reasons2) \ 1400 SHR_BITOR_RANGE(((_drop_reasons1).rbits), ((_drop_reasons2).rbits), 0, bcmPktDropReasonCount, ((_drop_reasons1).rbits)) 1401 1402 1403 /* 1404 * Macro to remove set of reasons2 (bcm_pkt_drop_reasons_t) from set of 1405 * reasons1 (bcm_pkt_drop_reasons_t). 1406 */ 1407 #define BCM_PKT_DROP_REASON_REMOVE(_drop_reasons1, _drop_reasons2) \ 1408 SHR_BITREMOVE_RANGE(((_drop_reasons1).rbits), ((_drop_reasons2).rbits), 0, bcmPktDropReasonCount, ((_drop_reasons1).rbits)); 1409 1410 /* Macro to negate two sets of reasons (bcm_pkt_drop_reasons_t). */ 1411 #define BCM_PKT_DROP_REASON_NEGATE(_drop_reasons1, _drop_reasons2) \ 1412 SHR_BITNEGATE_RANGE(((_drop_reasons2).rbits), 0, bcmPktDropReasonCount, ((_drop_reasons1).rbits)); 1413 1414 1415 #endif /* __BCM_PKT_H__ */