proc_hdr.h (9608B)
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: proc_hdr.h 8 */ 9 10 #include <soc/defs.h> 11 #include <soc/enet.h> 12 13 #ifndef _SOC_PROC_HDR_H 14 #define _SOC_PROC_HDR_H 15 16 #if defined(BCM_XGS_SUPPORT) && defined(BCM_CPU_TX_PROC_SUPPORT) 17 18 /**************************************************************************** 19 * CPU TX PROC Header Format 20 * 21 * ANSI only permits signed or unsigned int for bit field type. This 22 * structure will only work for compilers for which uint32 is unsigned 23 * int, and which completely pack bit fields beginning at the MSbit for 24 * big-endian machines and at the LSbit for little-endian machines. 25 * 26 * NOTE: these structures already put the the individual bytes in memory 27 * in big endian order for both big- and little-endian machines, so no 28 * further swapping is required. 29 */ 30 31 typedef union soc_proc_hdr_u { 32 struct { 33 uint8 bytes[16]; 34 } overlay0; 35 36 #if defined(LE_HOST) 37 38 struct { /* Byte # */ 39 uint32 start:8; /* 0 */ 40 uint32 header_types_4_1:4; /* 1 */ 41 uint32 input_pri:4; 42 uint32 source_15_10:6; /* 2 */ 43 uint32 source_type:1; 44 uint32 header_types_0:1; 45 uint32 source_9_2:8; /* 3 */ 46 uint32 rsvd_9_8:2; /* 4 */ 47 uint32 pkt_profile:3; 48 uint32 visibility_pkt:1; 49 uint32 source_1_0:2; 50 uint32 rsvd_7_9:8; /* 5 */ 51 uint32 mcast_lb_idx_7_2:6; /* 6 */ 52 uint32 mcast_lb_idx_valid:1; 53 uint32 rsvd:1; 54 uint32 rsvd_4_0:5; /* 7 */ 55 uint32 zero:1; 56 uint32 mcast_lb_idx_1_0:2; 57 uint32 ecmp_member_id_11_4:8; /* 8 */ 58 uint32 int_pri_3_2:2; /* 9 */ 59 uint32 dp:2; 60 uint32 ecmp_member_id_3_0:4; 61 uint32 rsvd_11_10:2; /* 10 */ 62 uint32 routed_pkt:1; 63 uint32 qos_fields_valid:1; 64 uint32 int_cn:2; 65 uint32 int_pri_1_0:2; 66 uint32 rsvd_9_2:8; /* 11 */ 67 uint32 destination_15_10:6; /* 12 */ 68 uint32 rsvd_1_0:2; 69 uint32 destination_9_2:8; /* 13 */ 70 uint32 subflow_type:2; /* 14 */ 71 uint32 destination_type:4; 72 uint32 destination_1_0:2; 73 uint32 pp_port:8; /* 15 */ 74 } overlay1; 75 76 #else /* !LE_HOST */ 77 78 struct { /* Byte # */ 79 uint32 start:8; /* 0 */ 80 uint32 input_pri:4; /* 1 */ 81 uint32 header_types_4_1:4; 82 uint32 header_types_0:1; /* 2 */ 83 uint32 source_type:1; 84 uint32 source_15_10:6; 85 uint32 source_9_2:8; /* 3 */ 86 uint32 source_1_0:2; /* 4 */ 87 uint32 visibility_pkt:1; 88 uint32 pkt_profile:3; 89 uint32 rsvd_9_8:2; 90 uint32 rsvd_7_9:8; /* 5 */ 91 uint32 rsvd:1; /* 6 */ 92 uint32 mcast_lb_idx_valid:1; 93 uint32 mcast_lb_idx_7_2:6; 94 uint32 mcast_lb_idx_1_0:2; /* 7 */ 95 uint32 zero:1; 96 uint32 rsvd_4_0:5; 97 uint32 ecmp_member_id_11_4:8; /* 8 */ 98 uint32 ecmp_member_id_3_0:4; /* 9 */ 99 uint32 dp:2; 100 uint32 int_pri_3_2:2; 101 uint32 int_pri_1_0:2; /* 10 */ 102 uint32 int_cn:2; 103 uint32 qos_fields_valid:1; 104 uint32 routed_pkt:1; 105 uint32 rsvd_11_10:2; 106 uint32 rsvd_9_2:8; /* 11 */ 107 uint32 rsvd_1_0:2; /* 12 */ 108 uint32 destination_15_10:6; 109 uint32 destination_9_2:8; /* 13 */ 110 uint32 destination_1_0:2; /* 14 */ 111 uint32 destination_type:4; 112 uint32 subflow_type:2; 113 uint32 pp_port:8; /* 15 */ 114 } overlay1; 115 116 #endif 117 } soc_proc_hdr_t; 118 119 #define SOC_PROC_HDR_SIZE ((int) sizeof(soc_proc_hdr_t)) 120 121 /* default SOP Symbol */ 122 #define SOC_TX_PROC_START 0xfb /* Default Start */ 123 124 /* 125 * TX PROC Header Field Manipulation 126 */ 127 128 typedef enum { 129 /* NOTE: strings in soc_proc_hdr_field_names[] must match */ 130 PH_invalid = -1, 131 PH_start = 0, 132 PH_input_pri, 133 PH_header_types, 134 PH_source_type, 135 PH_source, 136 PH_visibility_pkt, 137 PH_pkt_profile, 138 PH_mcast_lb_idx_valid, 139 PH_mcast_lb_idx, 140 PH_zero, 141 PH_ecmp_member_id, 142 PH_dp, 143 PH_int_pri, 144 PH_int_cn, 145 PH_qos_fields_valid, 146 PH_routed_pkt, 147 PH_destination, 148 PH_destination_type, 149 PH_subflow_type, 150 PH_pp_port, 151 PH_COUNT 152 } soc_proc_hdr_field_t; 153 154 /* NOTE: strings must match soc_proc_hdr_field_t */ 155 #define SOC_PROC_HDR_FIELD_NAMES_INIT \ 156 "start", \ 157 "input_pri", \ 158 "header_types", \ 159 "source_type", \ 160 "source", \ 161 "visibility_pkt", \ 162 "pkt_profile", \ 163 "mcast_lb_idx_valid", \ 164 "mcast_lb_idx", \ 165 "zero", \ 166 "ecmp_member_id", \ 167 "dp", \ 168 "int_pri", \ 169 "int_cn", \ 170 "qos_fields_valid", \ 171 "routed_pkt", \ 172 "destination", \ 173 "destination_type", \ 174 "subflow_type", \ 175 "pp_port", \ 176 NULL 177 178 /* 179 * Function Name: 180 * soc_proc_hdr_name_to_field 181 * Purpose: 182 * To convert field name to the field 183 * Parameters: 184 * [IN] unit - unit number 185 * [IN] name - ascii name of the field 186 * Return: 187 * Proc HDR Field or invalid code 188 */ 189 extern soc_proc_hdr_field_t soc_proc_hdr_name_to_field(int unit, char *name); 190 191 /* 192 * Function Name: 193 * soc_proc_hdr_field_to_name 194 * Purpose: 195 * To convert field to field name 196 * Parameters: 197 * [IN] unit - unit number 198 * [IN] name - field in the proc hdr 199 * Return: 200 * Field character name or ?? on ERROR 201 */ 202 extern char *soc_proc_hdr_field_to_name(int unit, soc_proc_hdr_field_t f); 203 204 /* 205 * Function Name: 206 * soc_proc_hdr_field_get 207 * Purpose: 208 * To get the value of a field in the proc header 209 * Parameters: 210 * [IN] unit - unit number 211 * [INOUT] ph - proc header to be modified 212 * [IN] field - field to be modified 213 * Return: 214 * value of the field, if field is not found then Log Warning 215 */ 216 extern uint32 soc_proc_hdr_field_get(int unit, soc_proc_hdr_t *ph, 217 soc_proc_hdr_field_t field); 218 219 /* 220 * Function Name: 221 * soc_proc_hdr_field_set 222 * Purpose: 223 * To set the value of a field in the proc header 224 * Parameters: 225 * [IN] unit - unit number 226 * [IN] ph - proc header to be modified 227 * [IN] field - field to be modified 228 * [IN] val - value of the field 229 * Return: 230 * None 231 */ 232 233 extern void soc_proc_hdr_field_set(int unit, soc_proc_hdr_t *ph, 234 soc_proc_hdr_field_t field, uint32 val); 235 236 /* 237 * Function Name: 238 * soc_proc_hdr_field_dump 239 * Purpose: 240 * to output the entire proc header in a user friendly format 241 * Parameters: 242 * [IN] unit - unit number 243 * [IN] pfx - character prefix to be appended to the header output. 244 * [IN] ph - proc header to be modified 245 * Return: 246 * None 247 */ 248 extern void soc_proc_hdr_dump(int unit, char *pfx, soc_proc_hdr_t *ph); 249 250 /* 251 * Function: 252 * soc_lbport_num_get 253 * Description: 254 * return FIRST loopback port of the chip 255 * Parameters: 256 * unit device number 257 * Return: 258 * first loopback port on the given device 259 */ 260 extern int soc_lbport_num_get(int unit, uint32 pipe); 261 262 /* 263 * Function: 264 * soc_pipe_get 265 * Description: 266 * return the pipe of the chip 267 * Parameters: 268 * unit device number 269 * logical_src_port source port 270 * Return: 271 * pipe number based on logical src port 272 */ 273 extern int soc_pipe_get(int unit, uint32 logical_src_port); 274 275 /* CPU TX PROC header Op-Codes */ 276 #define SOC_TX_PROC_OP_DGPP 0x00 /* Destination GPP */ 277 #define SOC_TX_PROC_OP_NHI 0x01 /* Next Hop */ 278 #define SOC_TX_PROC_OP_ECMP 0x02 /* ECMP group */ 279 #define SOC_TX_PROC_OP_ECMP_MEMBER 0x03 /* ECMP member */ 280 #define SOC_TX_PROC_OP_IPMC 0x04 /* IP Multicast Frame */ 281 #define SOC_TX_PROC_OP_L2MC 0x05 /* L2 Multicast Frame */ 282 #define SOC_TX_PROC_OP_VLAN_FLOOD 0x06 /* VLAN Flood */ 283 284 #define SOC_TX_PROC_ETHERNET_HEADER_TYPE 0x03 /* Ethernet */ 285 #define SOC_TX_PROC_SOURCE_TYPE 0x01 /* Source type for SGPP */ 286 #define SOC_TX_PROC_SUBFLOW_TYPE 0x01 /* Subflow type for CPU_TX_PROC */ 287 #define SOC_TX_PROC_VISIBILITY_PKT 0 /* CPU TX PROC is not a visibility packet */ 288 #define SOC_TX_PROC_ROUTED_PKT 1 /* L3 routed packet */ 289 290 #endif /* BCM_XGS_SUPPORT && BCM_CPU_TX_PROC_SUPPORT */ 291 292 #endif /* !_SOC_PROC_HDR_H */