sat.h (16199B)
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: sat.h 8 * Purpose: SAT definitions common to SDK 9 */ 10 11 #ifndef _SOC_SHARED_SAT_H 12 #define _SOC_SHARED_SAT_H 13 14 #include <sal/types.h> 15 #include <bcm/pkt.h> 16 #include <bcm_int/common/sat.h> 17 #include <soc/error.h> 18 19 #ifndef SOC_SAND_IN 20 #define SOC_SAND_IN const 21 #define SOC_SAND_OUT 22 #define SOC_SAND_INOUT 23 #endif 24 25 #define BCM_SAT_GTF_STAT_FIX 0x1 26 #define BCM_SAT_DBG 0x1 27 28 /* During CRC calculation the packet data bits are reversed */ 29 #define SOC_SAT_CONFIG_CRC_REVERSED_DATA 0x01 30 /* During CRC calculation the result is inverted and reversed before stamping */ 31 #define SOC_SAT_CONFIG_CRC_INVERT 0x02 32 /* During CRC calculations, reset CRC value is taken to be 32'hffffffff */ 33 #define SOC_SAT_CONFIG_CRC_HIGH_RESET 0x04 34 /* During PRBS calculations the next bit is created using NXOR (and not XOR) */ 35 #define SOC_SAT_CONFIG_PRBS_USE_NXOR 0x08 36 #define SOC_SAT_MEP_100K_SCAN_IN_SEC 166 /* 1.66ms interval. Avoid floating pt.*/ 37 #define SOC_SAT_100K_NUM 100000 38 39 /* GTF macro */ 40 #define SOC_SAT_GTF_OBJ_COMMON _BCM_SAT_GTF_OBJ_COMMON 41 #define SOC_SAT_GTF_OBJ_CIR _BCM_SAT_GTF_OBJ_CIR 42 #define SOC_SAT_GTF_OBJ_EIR _BCM_SAT_GTF_OBJ_EIR 43 44 #define SOC_SAT_GTF_WITH_ID 0x0001 /* Use the specified GTF ID */ 45 #define SOC_SAT_GTF_PACKET_LENGTH_NUM_OF_PATTERNS 8 46 #define SOC_SAT_GTF_PACKET_MAX_PATTERN_LENGTH 32 47 #define SOC_SAT_GTF_MAX_STAMPS 3 48 #define SOC_SAT_GTF_PACKET_EDIT_ADD_END_TLV 0x01 49 #define SOC_SAT_GTF_PACKET_EDIT_ADD_CRC 0x02 50 #define SOC_SAT_GTF_NUM_OF_PRIORITIES 2 /* CIR and EIR */ 51 #define SOC_SAT_GTF_RATE_PATTERN_STOP_INTERVAL_EQ_BURST 0x01 /* If set, INTERVAL state limit is set to the configuration, 52 otherwise to the number of packets sent in BURST state */ 53 #define SOC_SAT_GTF_SEQ_NUM_DISABLE -1 54 55 #define SOC_SAT_GTF_RATE_IN_BYTES 0 56 #define SOC_SAT_GTF_RATE_IN_PACKETS 1 57 #define SOC_SAT_GTF_RATE_WITH_GRANULARITY 2 58 59 60 61 62 #define SOC_SAT_PAYLOAD_MAX_PATTERN_NOF_U8 8 63 #define SOC_SAT_PAYLOAD_MAX_PATTERN_NOF_U32 2 64 65 #define SOC_SAT_PKT_HERDER_LSB_FIELD_SIZE 18 66 #define SOC_SAT_PKT_HERDER_MSB_FIELD_SIZE 15 67 #define SOC_SAT_PKT_LENGTH_PATTERN_FIELD_SIZE 3 68 69 /* Table, register index */ 70 #define SAT_TX_EVC_PARAMS_ENTRY_1_TBL_INDX(gtf_id) \ 71 ((gtf_id<<1)) /* Per evc parameters, two memory entries are needed. Occupy entries 0-15 (even entries) */ 72 #define SAT_TX_EVC_PARAMS_ENTRY_2_TBL_INDX(gtf_id) \ 73 ((gtf_id<<1) + 1) /* Per evc parameters, two memory entries are needed. Occupy entries 0-15 (odd entries) */ 74 #define SAT_TX_GEN_PARAMS_TBL_INDX(gtf_id, priority) \ 75 ((gtf_id<<1) + priority + 16) /* Per generator parameters, occupy entries 16-31 */ 76 #define SAT_TX_PER_GENERATOR_INDX(gtf_id, priority) \ 77 ((gtf_id<<1) + priority) /* per generator index */ 78 #define SAT_TX_PER_EVC_INDX(gtf_id) \ 79 (gtf_id) /* per evc index */ 80 81 #define SAT_TX_GEN_PRM_ENTRY_1_TBL_INDX(gtf_id, priority) \ 82 ((gtf_id<<2) + (priority<<1)) /* per generator parameters, two memory entries are needed, only for QAX*/ 83 84 #define SAT_TX_GEN_PRM_ENTRY_2_TBL_INDX(gtf_id, priority) \ 85 ((gtf_id<<2) + (priority<<1) + 1) /* per generator parameters, two memory entries are needed, only for QAX*/ 86 87 88 89 /* CTF macro */ 90 #define SOC_SAT_CTF_WITH_ID 0x0001 /* Use the specified CTF ID */ 91 /* SAT CTF packet config flags */ 92 /* If set, add end tlv, otherwise not add end tlv */ 93 #define SOC_SAT_CTF_PACKET_INFO_ADD_END_TLV 0x01 94 /* If set, add crc, otherwise not add crc */ 95 #define SOC_SAT_CTF_PACKET_INFO_ADD_CRC 0x02 96 97 #define SOC_SAT_STAT_MAX_NUM_OF_BINS 10 98 #define SOC_SAT_CTF_BINS_LIMIT_CNT 9 99 #define SOC_SAT_CTF_REPORT_ADD_SEQ_NUM 0x01 100 #define SOC_SAT_CTF_REPORT_ADD_DELAY 0x02 101 #define SOC_SAT_CTF_TRAP_ID_MAX_NUM 3 102 #define SOC_SAT_CTF_TRAP_ID_BITS_NOF 8 103 #define SOC_SAT_CTF_REPORT_SAMPLING_PER_MAX 100 104 #define SOC_SAT_CTF_RX_FLOW_PARAMS_ENTRY_SIZE 9 105 #define SOC_SAT_CTF_STAT_DO_NOT_CLR_ON_READ 0x1 106 107 /*CTF rx flow params offset*/ 108 #define SOC_SAT_CRC_OFFSET (SOC_IS_QAX(unit) ? 31 : 32) 109 #define SOC_SAT_SEQ_NUM_OFFSET (SOC_IS_QAX(unit) ? 47 : 48) 110 #define SOC_SAT_EXP_RPT_PATTERN_OFFSET (SOC_IS_QAX(unit) ? 63 : 64) 111 #define SOC_SAT_ADD_END_TLV_OFFSET (SOC_IS_QAX(unit) ? 127 : 128) 112 #define SOC_SAT_ADD_CRC_OFFSET (SOC_IS_QAX(unit) ? 128 : 129) 113 #define SOC_SAT_TIME_STAMP_OFFSET (SOC_IS_QAX(unit) ? 129 : 130) 114 #define SOC_SAT_USE_4_BYTE_PATTERN_OFFSET (SOC_IS_QAX(unit) ? 145 : 146) 115 #define SOC_SAT_USE_PRBS_PAYLOAD_OFFSET (SOC_IS_QAX(unit) ? 146 : 147) 116 #define SOC_SAT_USE_RPT_PTRN_PAYLOAD_OFFSET (SOC_IS_QAX(unit) ? 147 : 148) 117 118 119 #define SAT_CTF_IDENTIFIER_TO_INDEX(session_id, trap_id, color, tc) \ 120 (((session_id) << 7) | ((trap_id) << 5) | ((color) << 3) | (tc)) 121 122 typedef enum soc_sat_rx_flv_bin_limit_s { 123 socSATRxFLVBinLimit0 = 0, 124 socSATRxFLVBinLimit1 = 1, 125 socSATRxFLVBinLimit2 = 2, 126 socSATRxFLVBinLimit3 = 3, 127 socSATRxFLVBinLimit4 = 4, 128 socSATRxFLVBinLimit5 = 5, 129 socSATRxFLVBinLimit6 = 6, 130 socSATRxFLVBinLimit7 = 7, 131 socSATRxFLVBinLimit8 = 8, 132 socSATRxFLVBinLimitCnt = 9 133 }soc_sat_rx_flv_bin_limit_s; 134 135 typedef enum soc_sat_stamp_type_s { 136 socSatStampInvalid = 0, 137 socSatStampConstant2Bit = 1, 138 socSatStampCounter8Bit = 2, 139 socSatStampCounter16Bit = 3, 140 socSatStampConstant16Bit = 4, 141 socSatStampCount 142 } soc_sat_stamp_type_t; 143 144 typedef enum soc_sat_payload_type_e { 145 socSatPayloadConstant8Bytes = 0, 146 socSatPayloadConstant4Bytes = 1, 147 socSatPayloadPRBS = 2, 148 socSatPayloadsCount 149 } soc_sat_payload_type_t; 150 151 typedef enum soc_sat_header_type_e { 152 socSatHeaderUserDefined = 0, 153 socSatHeaderMEF = 1, 154 socSatHeaderY1564 = 2, 155 socSatHeadersCount 156 } soc_sat_header_type_t; 157 158 typedef enum soc_sat_stamp_field_s { 159 socSatStampFieldUserDefined = 0, 160 socSatStampFieldTc = 1, 161 socSatStampFieldDp = 2, 162 socSatStampFieldSrcMac = 3, 163 socSatStampFieldDestMac = 4, 164 socSatStampFieldInnerVlan = 5, 165 socSatStampFieldOuterVlan = 6, 166 socSatStampFieldsCount 167 } soc_sat_stamp_field_t; 168 169 typedef enum soc_sat_gtf_rate_pattern_mode_e { 170 socSatGtfRatePatternContinues = 0, 171 socSatGtfRatePatternSimpleBurst = 1, 172 socSatGtfRatePatternCombined = 2, 173 socSatGtfRatePatternInterval = 3, 174 socSatGtfRatePatternsCount 175 } soc_sat_gtf_rate_pattern_mode_t; 176 177 typedef enum soc_sat_gtf_stat_counter_e { 178 socSatGtfStatPacketCount = 0, 179 socSatGtfStatCount 180 } soc_sat_gtf_stat_counter_t; 181 182 /* SAT Timestamp Formats */ 183 typedef enum soc_sat_timestamp_format_e { 184 socSATTimestampFormatIEEE1588v1 = 0x00, /* Low-order 64 bits of the IEEE 185 1588-2008 (1588v2) Precision Time 186 Protocol timestamp format [IEEE1588] */ 187 socSATTimestampFormatNTP = 0x01 /* Network Time Protocol version 4 188 64-bit timestamp format [RFC5905] */ 189 } soc_sat_timestamp_format_t; 190 191 typedef struct soc_sat_init_s { 192 uint32 cmic_tod_mode; 193 uint32 rate_num_clks_cycle; 194 uint32 num_clks_sec; 195 } soc_sat_init_t; 196 197 /* Sat common configuration Object */ 198 typedef struct soc_sat_config_s { 199 soc_sat_timestamp_format_t timestamp_format; /* SAT timestamp format */ 200 uint32 config_flags; 201 } soc_sat_config_t; 202 203 /* GTF */ 204 typedef int soc_sat_gtf_t; 205 206 typedef struct soc_sat_header_user_define_offsets_s { 207 int payload_offset; 208 int timestamp_offset; 209 int seq_number_offset; 210 int crc_byte_offset; 211 } soc_sat_header_user_define_offsets_t; 212 213 typedef struct soc_sat_stamp_s { 214 soc_sat_stamp_type_t stamp_type; 215 soc_sat_stamp_field_t field_type; 216 uint32 inc_step; /* for counter stamp */ 217 uint32 inc_period_packets; /* for counter stamp */ 218 uint32 value; /* for constant stamp */ 219 uint32 offset; /* offset in bits, for user defined field type */ 220 } soc_sat_stamp_t; 221 222 typedef struct soc_sat_payload_s { 223 soc_sat_payload_type_t payload_type; 224 uint8 payload_pattern [SOC_SAT_PAYLOAD_MAX_PATTERN_NOF_U8]; 225 } soc_sat_payload_t; 226 227 typedef struct soc_sat_gtf_packet_edit_s { 228 uint32 packet_length[SOC_SAT_GTF_PACKET_LENGTH_NUM_OF_PATTERNS]; 229 uint32 packet_length_pattern[SOC_SAT_GTF_PACKET_MAX_PATTERN_LENGTH]; 230 uint32 pattern_length; 231 soc_sat_stamp_t stamps[SOC_SAT_GTF_MAX_STAMPS]; 232 uint32 number_of_stamps; 233 uint32 number_of_ctfs; 234 uint32 flags; 235 } soc_sat_gtf_packet_edit_t; 236 237 typedef struct soc_sat_gtf_packet_config_s { 238 soc_sat_header_type_t sat_header_type; 239 bcm_pkt_t header_info; 240 soc_sat_payload_t payload; 241 soc_sat_gtf_packet_edit_t packet_edit[SOC_SAT_GTF_NUM_OF_PRIORITIES]; 242 uint32 packet_context_id; 243 soc_sat_header_user_define_offsets_t offsets; 244 }soc_sat_gtf_packet_config_t; 245 246 247 typedef struct soc_sat_gtf_bandwidth_s { 248 uint32 flags; 249 uint32 rate; 250 uint32 max_burst; 251 uint32 granularity; 252 } soc_sat_gtf_bandwidth_t; 253 254 typedef struct soc_sat_gtf_rate_pattern_s { 255 soc_sat_gtf_rate_pattern_mode_t rate_pattern_mode; 256 uint32 high_threshold; 257 uint32 low_threshold; 258 uint32 stop_iter_count; 259 uint32 stop_burst_count; 260 uint32 stop_interval_count; 261 uint32 burst_packet_weight; 262 uint32 interval_packet_weight; 263 uint32 flags; 264 } soc_sat_gtf_rate_pattern_t; 265 266 /* CTF */ 267 typedef int soc_sat_ctf_t; 268 269 typedef struct soc_sat_ctf_packet_info_s { 270 soc_sat_header_type_t sat_header_type; 271 soc_sat_payload_t payload; 272 uint32 flags; 273 soc_sat_header_user_define_offsets_t offsets; /* for user defined only */ 274 } soc_sat_ctf_packet_info_t; 275 276 typedef struct soc_sat_ctf_identifier_s { 277 uint32 tc; 278 uint32 color; 279 uint32 trap_id; 280 uint32 session_id; 281 } soc_sat_ctf_identifier_t; 282 283 typedef struct soc_sat_ctf_bin_limit_s { 284 uint32 bin_select; /* 0-8 in Jericho*/ 285 uint32 bin_limit; 286 } soc_sat_ctf_bin_limit_t; 287 288 typedef struct soc_sat_ctf_stat_config_s { 289 uint32 use_global_bin_config; 290 uint32 bin_min_delay; 291 uint32 bin_step; 292 uint32 update_counters_in_unvavail_state; 293 } soc_sat_ctf_stat_config_t; 294 295 typedef struct soc_sat_ctf_stat_s { 296 uint64 received_packet_cnt; 297 uint64 out_of_order_packet_cnt; 298 uint64 err_packet_cnt; 299 uint64 received_octet_cnt; 300 uint64 out_of_order_octet_cnt; 301 uint64 err_octet_cnt; 302 uint64 last_packet_delay; 303 uint64 bin_delay_counters[SOC_SAT_STAT_MAX_NUM_OF_BINS]; 304 uint64 accumulated_delay_count; 305 uint64 max_packet_delay; 306 uint64 min_packet_delay; 307 uint64 time_of_day_stamp; 308 uint64 sec_in_avail_state_counter; 309 uint64 last_packet_seq_number; /* Last received packet sequence number */ 310 } soc_sat_ctf_stat_t; 311 312 typedef struct soc_sat_ctf_availability_config_s { 313 uint32 switch_state_num_of_slots; 314 uint32 switch_state_threshold_per_slot; 315 } soc_sat_ctf_availability_config_t ; 316 317 typedef struct soc_sat_ctf_report_config_s { 318 uint32 report_sampling_percent; 319 uint32 flags; 320 } soc_sat_ctf_report_config_t; 321 322 typedef struct soc_sat_report_event_data_s { 323 int sequence_number; 324 int sequence_number_valid; 325 int delay; 326 int delay_valid; 327 } soc_sat_report_event_data_t; 328 329 typedef int (*soc_sat_handler_t)(int unit); 330 331 /* Functions */ 332 extern soc_error_t soc_sat_config_set ( 333 SOC_SAND_IN int unit, 334 SOC_SAND_IN soc_sat_config_t* conf 335 ); 336 337 extern soc_error_t soc_sat_config_get ( 338 SOC_SAND_IN int unit, 339 SOC_SAND_OUT soc_sat_config_t* conf 340 ); 341 342 extern soc_error_t soc_sat_general_cfg_init ( 343 SOC_SAND_IN int unit, 344 SOC_SAND_IN soc_sat_init_t *sat_init 345 ); 346 347 extern soc_error_t soc_sat_gtf_packet_gen_set ( 348 SOC_SAND_IN int unit, 349 SOC_SAND_IN soc_sat_gtf_t gtf_id, 350 SOC_SAND_IN int priority, 351 SOC_SAND_IN int enable 352 ); 353 354 extern soc_error_t soc_sat_gtf_packet_gen_get ( 355 SOC_SAND_IN int unit, 356 SOC_SAND_IN soc_sat_gtf_t gtf_id, 357 SOC_SAND_IN int priority, 358 SOC_SAND_OUT int *enable 359 ); 360 361 extern soc_error_t soc_sat_gtf_packet_config ( 362 SOC_SAND_IN int unit, 363 SOC_SAND_IN soc_sat_gtf_t gtf_id, 364 SOC_SAND_IN soc_sat_gtf_packet_config_t *config 365 ); 366 367 extern soc_error_t soc_sat_gtf_bandwidth_set ( 368 SOC_SAND_IN int unit, 369 SOC_SAND_IN soc_sat_gtf_t gtf_id, 370 SOC_SAND_IN int priority, 371 SOC_SAND_IN soc_sat_gtf_bandwidth_t *bw 372 ); 373 374 extern soc_error_t soc_sat_gtf_bandwidth_get ( 375 SOC_SAND_IN int unit, 376 SOC_SAND_IN soc_sat_gtf_t gtf_id, 377 SOC_SAND_IN int priority, 378 SOC_SAND_OUT soc_sat_gtf_bandwidth_t *bw 379 ); 380 381 extern soc_error_t soc_sat_gtf_rate_pattern_set ( 382 SOC_SAND_IN int unit, 383 SOC_SAND_IN soc_sat_gtf_t gtf_id, 384 SOC_SAND_IN int priority, 385 SOC_SAND_IN soc_sat_gtf_rate_pattern_t *config 386 ); 387 388 extern soc_error_t soc_sat_gtf_rate_pattern_get ( 389 SOC_SAND_IN int unit, 390 SOC_SAND_IN soc_sat_gtf_t gtf_id, 391 SOC_SAND_IN int priority, 392 SOC_SAND_OUT soc_sat_gtf_rate_pattern_t *config 393 ); 394 395 extern soc_error_t soc_sat_gtf_stat_get ( 396 SOC_SAND_IN int unit, 397 SOC_SAND_IN soc_sat_gtf_t gtf_id, 398 SOC_SAND_IN int priority, 399 SOC_SAND_IN uint32 flags, 400 SOC_SAND_IN soc_sat_gtf_stat_counter_t type, 401 SOC_SAND_OUT uint64* value 402 ); 403 404 extern soc_error_t soc_sat_ctf_packet_config ( 405 SOC_SAND_IN int unit, 406 SOC_SAND_IN soc_sat_ctf_t ctf_id, 407 SOC_SAND_IN soc_sat_ctf_packet_info_t *packet_info 408 ); 409 410 extern soc_error_t soc_sat_ctf_identifier_map ( 411 SOC_SAND_IN int unit, 412 SOC_SAND_IN soc_sat_ctf_identifier_t *identifier, 413 SOC_SAND_IN soc_sat_ctf_t ctf_id 414 ); 415 416 extern soc_error_t soc_sat_ctf_identifier_unmap ( 417 SOC_SAND_IN int unit, 418 SOC_SAND_IN soc_sat_ctf_identifier_t *identifier 419 ); 420 421 extern soc_error_t soc_sat_ctf_trap_set ( 422 SOC_SAND_IN int unit, 423 SOC_SAND_IN uint32 trap_id_cnt, 424 SOC_SAND_IN uint32* trap_id 425 ); 426 427 extern soc_error_t soc_sat_ctf_bin_limit_set ( 428 SOC_SAND_IN int unit, 429 SOC_SAND_IN int bins_count, 430 SOC_SAND_IN soc_sat_ctf_bin_limit_t* bins 431 ); 432 433 extern soc_error_t soc_sat_ctf_bin_limit_get ( 434 SOC_SAND_IN int unit, 435 SOC_SAND_IN int max_bins_count, 436 SOC_SAND_OUT int * bins_count, 437 SOC_SAND_OUT soc_sat_ctf_bin_limit_t* bins 438 ); 439 440 extern soc_error_t soc_sat_ctf_stat_config_set ( 441 SOC_SAND_IN int unit, 442 SOC_SAND_IN soc_sat_ctf_t ctf_id, 443 SOC_SAND_IN soc_sat_ctf_stat_config_t *stat 444 ); 445 446 extern soc_error_t soc_sat_ctf_stat_get ( 447 SOC_SAND_IN int unit, 448 SOC_SAND_IN soc_sat_ctf_t ctf_id, 449 SOC_SAND_IN uint32 flags, 450 SOC_SAND_OUT soc_sat_ctf_stat_t* stat 451 ); 452 453 extern soc_error_t soc_sat_ctf_availability_config_set ( 454 SOC_SAND_IN int unit, 455 SOC_SAND_IN soc_sat_ctf_t ctf_id, 456 SOC_SAND_IN soc_sat_ctf_availability_config_t *config 457 ); 458 459 extern soc_error_t soc_sat_ctf_trap_data_to_session_map ( 460 SOC_SAND_IN int unit, 461 SOC_SAND_IN uint32 trap_data, 462 SOC_SAND_IN uint32 trap_data_mask, 463 SOC_SAND_IN uint32 entry_idx, 464 SOC_SAND_IN uint32 session_id 465 ); 466 467 extern soc_error_t soc_sat_ctf_trap_data_to_session_unmap ( 468 SOC_SAND_IN int unit, 469 SOC_SAND_IN uint32 entry_idx 470 ); 471 472 extern soc_error_t soc_sat_ctf_reports_config_set ( 473 SOC_SAND_IN int unit, 474 SOC_SAND_IN soc_sat_ctf_t ctf_id, 475 SOC_SAND_IN soc_sat_ctf_report_config_t *reports 476 ); 477 478 extern soc_error_t soc_sat_oamp_stat_event_control( 479 SOC_SAND_IN int unit, 480 SOC_SAND_IN int enable); 481 482 extern soc_error_t soc_sat_oamp_stat_event_clear( 483 SOC_SAND_IN int unit); 484 485 extern soc_error_t soc_common_sat_handler_register( 486 SOC_SAND_IN int unit, 487 SOC_SAND_IN soc_sat_handler_t handler); 488 489 extern soc_error_t soc_common_sat_handler_get( 490 SOC_SAND_IN int unit, 491 SOC_SAND_OUT soc_sat_handler_t *handler); 492 493 extern int soc_sat_session_inuse( 494 SOC_SAND_IN int unit, 495 SOC_SAND_IN int session_id); 496 497 #ifdef BCM_WARM_BOOT_SUPPORT 498 int soc_sat_wb_init(int unit); 499 int soc_sat_wb_sync(int unit, int sync); 500 int soc_sat_wb_deinit(int unit); 501 #endif 502 503 #endif /* _SOC_SHARED_SAT_H */