tsn.h (65849B)
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 */ 9 10 #ifndef __BCM_TSN_H__ 11 #define __BCM_TSN_H__ 12 13 #include <bcm/types.h> 14 15 /* Seamless Redundancy (SR) - Port SR type */ 16 typedef enum bcm_tsn_sr_port_type_e { 17 bcmTsnSrPortTypeNone = 0, /* SR disabled on this port */ 18 bcmTsnSrPortTypeEthernet = 1, /* Ethernet */ 19 bcmTsnSrPortTypePrp = 2, /* PRP */ 20 bcmTsnSrPortTypeHsr = 3, /* HSR */ 21 bcmTsnSrPortTypeDot1cb = 4, /* 802.1CB */ 22 bcmTsnSrPortTypeCount = 5 /* Always last. Not a usable value. */ 23 } bcm_tsn_sr_port_type_t; 24 25 /* Seamless Redundancy (SR) - Port SR mode */ 26 typedef enum bcm_tsn_sr_port_mode_e { 27 bcmTsnSrPortModeDefault = 0, /* Default mode (custom value 0) */ 28 bcmTsnSrPortModeInterworkingPrp = 1, /* It's a PRP port in an interworking 29 box */ 30 bcmTsnSrPortModeCustom1 = 2, /* Custom value 1 */ 31 bcmTsnSrPortModeCustom2 = 3, /* Custom value 2 */ 32 bcmTsnSrPortModeCustom3 = 4, /* Custom value 3 */ 33 bcmTsnSrPortModeCustom4 = 5, /* Custom value 4 */ 34 bcmTsnSrPortModeCustom5 = 6, /* Custom value 5 */ 35 bcmTsnSrPortModeCustom6 = 7, /* Custom value 6 */ 36 bcmTsnSrPortModeCount = 8 /* Always last. Not a usable value. */ 37 } bcm_tsn_sr_port_mode_t; 38 39 /* Seamless Redundancy (SR) - port SR configuration */ 40 typedef struct bcm_tsn_sr_port_config_s { 41 bcm_tsn_sr_port_type_t port_type; /* Port type */ 42 uint8 interlink_role; /* Specifies whether it's an interlink 43 port */ 44 uint8 mac_da_flows; /* SR flows classified by MAC-DA; 0 45 otherwise */ 46 uint8 lan_id; /* 0 for LAN A, 1 for LAN B */ 47 uint8 net_id; /* NET_ID 0~7, 0 means don't care */ 48 bcm_tsn_sr_port_mode_t port_mode; /* Port mode */ 49 } bcm_tsn_sr_port_config_t; 50 51 #ifndef BCM_HIDE_DISPATCHABLE 52 53 /* Initialize the TSN module */ 54 extern int bcm_tsn_init( 55 int unit); 56 57 /* De-initialize the TSN module */ 58 extern int bcm_tsn_detach( 59 int unit); 60 61 #endif /* BCM_HIDE_DISPATCHABLE */ 62 63 /* Initialize a port SR configuration structure. */ 64 extern void bcm_tsn_sr_port_config_t_init( 65 bcm_tsn_sr_port_config_t *port_config); 66 67 #ifndef BCM_HIDE_DISPATCHABLE 68 69 /* Set or get Seamless Redundancy configuration on a port. */ 70 extern int bcm_tsn_sr_port_config_set( 71 int unit, 72 bcm_gport_t port, 73 bcm_tsn_sr_port_config_t *config); 74 75 /* Set or get Seamless Redundancy configuration on a port. */ 76 extern int bcm_tsn_sr_port_config_get( 77 int unit, 78 bcm_gport_t port, 79 bcm_tsn_sr_port_config_t *config); 80 81 #endif /* BCM_HIDE_DISPATCHABLE */ 82 83 /* Flags for bcm_tsn_pri_map_entry_t */ 84 #define BCM_TSN_PRI_MAP_ENTRY_FLOW_OFFSET 0x00000001 85 #define BCM_TSN_PRI_MAP_ENTRY_NEW_INT_PRI 0x00000002 86 #define BCM_TSN_PRI_MAP_ENTRY_PROFILE_ID 0x00000004 87 #define BCM_BCM_TSN_PRI_MAP_ENTRY_TAF_GATE_EXPRESS 0x00000008 /* specify TAF gate id 88 for express traffic */ 89 #define BCM_BCM_TSN_PRI_MAP_ENTRY_TAF_GATE_PREEMPT 0x00000010 /* specify TAF gate id 90 for preemptable 91 traffic */ 92 93 /* TSN priority mapping entry (one instance for one priority) */ 94 typedef struct bcm_tsn_pri_map_entry_s { 95 uint32 flags; /* See BCM_TSN_PRI_MAP_ENTRY_xxx flags */ 96 int flow_offset; /* Flow ID offset (0~7) */ 97 int new_int_pri; /* New internal priority */ 98 int profile_id; /* Profile ID */ 99 int taf_gate_express; /* TAF gate for express traffic */ 100 int taf_gate_preempt; /* TAF gate for preemptable traffic */ 101 } bcm_tsn_pri_map_entry_t; 102 103 /* Initialize a bcm_tsn_pri_map_entry_t structure */ 104 extern void bcm_tsn_pri_map_entry_t_init( 105 bcm_tsn_pri_map_entry_t *entry); 106 107 /* TSN priority map type */ 108 typedef enum bcm_tsn_pri_map_type_e { 109 bcmTsnPriMapTypeTsnFlow = 0, /* Mapping priority to TSN flows (TSN 110 circuit ID) */ 111 bcmTsnPriMapTypeSrFlow = 1, /* Mapping priority to SR flows */ 112 bcmTsnPriMapTypeEgressMtuProfile = 2, /* Mapping priority to egress MTU 113 profile index */ 114 bcmTsnPriMapTypeEgressStuProfile = 3, /* Mapping priority to egress STU 115 profile index */ 116 bcmTsnPriMapTypeTafGate = 4, /* Mapping priority to TAF gate */ 117 bcmTsnPriMapTypeCount = 5 /* Always last. Not a usable value. */ 118 } bcm_tsn_pri_map_type_t; 119 120 /* Used when priority map is not required (eg. default mapping is used). */ 121 #define BCM_TSN_PRI_MAP_INVALID ((bcm_tsn_pri_map_t) 0) 122 123 /* TSN priority map configuration */ 124 typedef struct bcm_tsn_pri_map_config_s { 125 bcm_tsn_pri_map_type_t map_type; /* Type of this priority map */ 126 int num_map_entries; /* Number of entries specified */ 127 bcm_tsn_pri_map_entry_t map_entries[16]; /* Mapping entry. The array index is the 128 priority value to map. Index 0 (first 129 entry in array) for priority 0, index 130 1 for priority 1, and so forth. */ 131 } bcm_tsn_pri_map_config_t; 132 133 /* Initialize a bcm_tsn_pri_map_config_t structure */ 134 extern void bcm_tsn_pri_map_config_t_init( 135 bcm_tsn_pri_map_config_t *config); 136 137 #ifndef BCM_HIDE_DISPATCHABLE 138 139 /* Create a Priority Map ID object. */ 140 extern int bcm_tsn_pri_map_create( 141 int unit, 142 bcm_tsn_pri_map_config_t *config, 143 bcm_tsn_pri_map_t *map_id); 144 145 /* Set the information to specified Priority Map ID. */ 146 extern int bcm_tsn_pri_map_set( 147 int unit, 148 bcm_tsn_pri_map_t map_id, 149 bcm_tsn_pri_map_config_t *config); 150 151 /* Get the information to specified Priority Map ID. */ 152 extern int bcm_tsn_pri_map_get( 153 int unit, 154 bcm_tsn_pri_map_t map_id, 155 bcm_tsn_pri_map_config_t *config); 156 157 /* Destroy a Priority Map object. */ 158 extern int bcm_tsn_pri_map_destroy( 159 int unit, 160 bcm_tsn_pri_map_t map_id); 161 162 #endif /* BCM_HIDE_DISPATCHABLE */ 163 164 /* TSN priority map traverse callback */ 165 typedef int (*bcm_tsn_pri_map_traverse_cb)( 166 int unit, 167 bcm_tsn_pri_map_t map_id, 168 void *user_data); 169 170 #ifndef BCM_HIDE_DISPATCHABLE 171 172 /* Traverse all Priority Map. */ 173 extern int bcm_tsn_pri_map_traverse( 174 int unit, 175 bcm_tsn_pri_map_traverse_cb cb, 176 void *user_data); 177 178 #endif /* BCM_HIDE_DISPATCHABLE */ 179 180 /* SR flow */ 181 typedef uint32 bcm_tsn_sr_flow_t; 182 183 /* Flags for bcm_tsn_sr_tx_flow_config_t */ 184 #define BCM_TSN_SR_TX_FLOW_CONFIG_DO_NOT_CUT_THROUGH 0x00000001 /* Do not cut-through for 185 the flow */ 186 187 /* SR TX flow configuration */ 188 typedef struct bcm_tsn_sr_tx_flow_config_s { 189 uint32 flags; 190 uint32 seq_num; /* Initial sequence number */ 191 int ingress_mtu_profile; 192 } bcm_tsn_sr_tx_flow_config_t; 193 194 /* Initialize an SR TX flow configuration structure */ 195 extern void bcm_tsn_sr_tx_flow_config_t_init( 196 bcm_tsn_sr_tx_flow_config_t *flow_config); 197 198 #ifndef BCM_HIDE_DISPATCHABLE 199 200 /* Create an SR TX flow set */ 201 extern int bcm_tsn_sr_tx_flowset_create( 202 int unit, 203 bcm_tsn_pri_map_t pri_map, 204 bcm_tsn_sr_tx_flow_config_t *default_config, 205 bcm_tsn_sr_flowset_t *flowset); 206 207 /* Retrieve the initial configuration for an SR TX flow set */ 208 extern int bcm_tsn_sr_tx_flowset_config_get( 209 int unit, 210 bcm_tsn_sr_flowset_t flowset, 211 bcm_tsn_pri_map_t *pri_map, 212 bcm_tsn_sr_tx_flow_config_t *default_config); 213 214 #endif /* BCM_HIDE_DISPATCHABLE */ 215 216 /* Flags for bcm_tsn_sr_rx_flow_config_t */ 217 #define BCM_TSN_SR_RX_FLOW_CONFIG_ACCEPT_DUPLICATES 0x00000001 /* Accept (don't drop) SR 218 duplicate packets */ 219 #define BCM_TSN_SR_RX_FLOW_CONFIG_ACCEPT_PKT_IN_DROP_WINDOW 0x00000002 /* Accept (don't drop) 220 packets with the 221 sequence number in the 222 drop window */ 223 #define BCM_TSN_SR_RX_FLOW_CONFIG_DROP_OUT_OF_ORDER 0x00000004 /* Drop out of order 224 packets */ 225 #define BCM_TSN_SR_RX_FLOW_CONFIG_DO_NOT_CUT_THROUGH 0x00000008 /* Do not cut-through for 226 the flow */ 227 228 /* SR RX flow configuration */ 229 typedef struct bcm_tsn_sr_rx_flow_config_s { 230 uint32 flags; 231 uint32 seqnum_accept_win_size; /* Sequence number acceptance window: 512, 232 1024, ... 65536 */ 233 uint32 seqnum_history_win_size; /* Sequence number history window: 1, 64, 234 128, ... 4096 */ 235 uint32 age_timeout; /* Age timeout in ticks specified by 236 bcmSrControlAgeTickInterval. 0 to disable 237 aging. */ 238 int ingress_mtu_profile; 239 } bcm_tsn_sr_rx_flow_config_t; 240 241 /* Initialize an SR RX flow configuration structure */ 242 extern void bcm_tsn_sr_rx_flow_config_t_init( 243 bcm_tsn_sr_rx_flow_config_t *config); 244 245 #ifndef BCM_HIDE_DISPATCHABLE 246 247 /* Create an SR RX flow set */ 248 extern int bcm_tsn_sr_rx_flowset_create( 249 int unit, 250 bcm_tsn_pri_map_t pri_map, 251 bcm_tsn_sr_rx_flow_config_t *default_config, 252 bcm_tsn_sr_flowset_t *flowset); 253 254 /* Retrieve the initial configuration for an SR RX flow set */ 255 extern int bcm_tsn_sr_rx_flowset_config_get( 256 int unit, 257 bcm_tsn_sr_flowset_t flowset, 258 bcm_tsn_pri_map_t *pri_map, 259 bcm_tsn_sr_rx_flow_config_t *default_config); 260 261 #endif /* BCM_HIDE_DISPATCHABLE */ 262 263 /* SR flow set status */ 264 typedef struct bcm_tsn_sr_flowset_status_s { 265 int count; /* Actual number of flows in this flowset */ 266 int active; /* Indicates whether it's active */ 267 } bcm_tsn_sr_flowset_status_t; 268 269 /* Initialize an SR flow set status structure */ 270 extern void bcm_tsn_sr_flowset_status_t_init( 271 bcm_tsn_sr_flowset_status_t *status); 272 273 #ifndef BCM_HIDE_DISPATCHABLE 274 275 /* Retrieve the current status for an SR TX or RX flow set */ 276 extern int bcm_tsn_sr_flowset_status_get( 277 int unit, 278 bcm_tsn_sr_flowset_t flowset, 279 bcm_tsn_sr_flowset_status_t *status); 280 281 #endif /* BCM_HIDE_DISPATCHABLE */ 282 283 /* SR flow set traverse callback */ 284 typedef int (*bcm_tsn_sr_flowset_traverse_cb)( 285 int unit, 286 bcm_tsn_sr_flowset_t flowset, 287 void *user_data); 288 289 #ifndef BCM_HIDE_DISPATCHABLE 290 291 /* Traverse all the created SR flow sets */ 292 extern int bcm_tsn_sr_flowset_traverse( 293 int unit, 294 int is_rx, 295 bcm_tsn_sr_flowset_traverse_cb cb, 296 void *user_data); 297 298 /* Destroy an SR flow set */ 299 extern int bcm_tsn_sr_flowset_destroy( 300 int unit, 301 bcm_tsn_sr_flowset_t flowset); 302 303 /* 304 * Retrieve an individual SR flow ID based on the flow offset from a flow 305 * set. 306 */ 307 extern int bcm_tsn_sr_flowset_flow_get( 308 int unit, 309 bcm_tsn_sr_flowset_t flowset, 310 int index, 311 bcm_tsn_sr_flow_t *flow_id); 312 313 /* Retrieve the flow configuration for an SR TX flow */ 314 extern int bcm_tsn_sr_tx_flow_config_get( 315 int unit, 316 bcm_tsn_sr_flow_t flow_id, 317 bcm_tsn_sr_tx_flow_config_t *config); 318 319 /* Set (modify) the flow configuration for an SR TX flow */ 320 extern int bcm_tsn_sr_tx_flow_config_set( 321 int unit, 322 bcm_tsn_sr_flow_t flow_id, 323 bcm_tsn_sr_tx_flow_config_t *config); 324 325 #endif /* BCM_HIDE_DISPATCHABLE */ 326 327 /* SR TX flow status */ 328 typedef struct bcm_tsn_sr_tx_flow_status_s { 329 uint32 seq_num; /* Next sequence number to use */ 330 } bcm_tsn_sr_tx_flow_status_t; 331 332 /* Initialize an SR TX flow status structure */ 333 extern void bcm_tsn_sr_tx_flow_status_t_init( 334 bcm_tsn_sr_tx_flow_status_t *status); 335 336 #ifndef BCM_HIDE_DISPATCHABLE 337 338 /* Retrieve the current status for an SR TX flow */ 339 extern int bcm_tsn_sr_tx_flow_status_get( 340 int unit, 341 bcm_tsn_sr_flow_t flow_id, 342 bcm_tsn_sr_tx_flow_status_t *status); 343 344 /* Retrieve the flow configuration for an SR RX flow */ 345 extern int bcm_tsn_sr_rx_flow_config_get( 346 int unit, 347 bcm_tsn_sr_flow_t flow_id, 348 bcm_tsn_sr_rx_flow_config_t *config); 349 350 /* Set (modify) the flow configuration for an SR RX flow */ 351 extern int bcm_tsn_sr_rx_flow_config_set( 352 int unit, 353 bcm_tsn_sr_flow_t flow_id, 354 bcm_tsn_sr_rx_flow_config_t *config); 355 356 #endif /* BCM_HIDE_DISPATCHABLE */ 357 358 /* SR RX flow status */ 359 typedef struct bcm_tsn_sr_rx_flow_status_s { 360 int seqnum_win_in_reset; /* Sequence number window is in reset 361 state */ 362 int seqnum_age_countdown; /* Sequence number age count down (in 363 ticks) */ 364 uint32 last_history_win_seqnum; /* Last sequence number received in the 365 sequence number history window */ 366 uint32 last_accepted_seqnum_lan[2]; /* Last sequence number accepted for LAN 367 A/B */ 368 int wrong_lan[2]; /* Set if any packet received on wrong 369 LAN A/B */ 370 int wrong_lan_age_countdown[2]; /* Count down (in ticks) to clear wrong 371 LAN A/B status */ 372 } bcm_tsn_sr_rx_flow_status_t; 373 374 /* Initialize an SR RX flow status structure */ 375 extern void bcm_tsn_sr_rx_flow_status_t_init( 376 bcm_tsn_sr_rx_flow_status_t *status); 377 378 #ifndef BCM_HIDE_DISPATCHABLE 379 380 /* Retrieve the current status for an SR RX flow */ 381 extern int bcm_tsn_sr_rx_flow_status_get( 382 int unit, 383 bcm_tsn_sr_flow_t flow_id, 384 bcm_tsn_sr_rx_flow_status_t *status); 385 386 #endif /* BCM_HIDE_DISPATCHABLE */ 387 388 /* Flags for bcm_tsn_sr_rx_flow_reset */ 389 #define BCM_TSN_SR_RX_FLOW_RESET_SEQNUM_WIN_STATE 0x00000001 /* Reset sequence number 390 window state */ 391 #define BCM_TSN_SR_RX_FLOW_RESET_SEQNUM_WIN_HISTORY 0x00000002 /* Reset sequence number 392 history values */ 393 #define BCM_TSN_SR_RX_FLOW_RESET_SEQNUM_AGE_COUNTDOWN 0x00000004 /* Restart sequence 394 number age countdown */ 395 #define BCM_TSN_SR_RX_FLOW_RESET_WRONGLAN_A_AGE_COUNTDOWN 0x00000008 /* Restart wrong LAN A 396 clear age countdown */ 397 #define BCM_TSN_SR_RX_FLOW_RESET_WRONGLAN_B_AGE_COUNTDOWN 0x00000010 /* Restart wrong LAN B 398 clear age countdown */ 399 #define BCM_TSN_SR_RX_FLOW_RESET_ALL (BCM_TSN_SR_RX_FLOW_RESET_SEQNUM_WIN_STATE |\ 400 BCM_TSN_SR_RX_FLOW_RESET_SEQNUM_WIN_HISTORY |\ 401 BCM_TSN_SR_RX_FLOW_RESET_SEQNUM_AGE_COUNTDOWN |\ 402 BCM_TSN_SR_RX_FLOW_RESET_WRONGLAN_A_AGE_COUNTDOWN |\ 403 BCM_TSN_SR_RX_FLOW_RESET_WRONGLAN_B_AGE_COUNTDOWN) 404 405 #ifndef BCM_HIDE_DISPATCHABLE 406 407 /* Reset an SR RX flow */ 408 extern int bcm_tsn_sr_rx_flow_reset( 409 int unit, 410 uint32 flags, 411 bcm_tsn_sr_flow_t flow_id); 412 413 /* Set the sequence number history bits in the RX flow. */ 414 extern int bcm_tsn_sr_rx_flow_seqnum_history_set( 415 int unit, 416 bcm_tsn_sr_flow_t flow_id, 417 int offset_in_bits, 418 int size_in_bits, 419 uint8 *history_bits); 420 421 /* Get the sequence number history bits in the RX flow. */ 422 extern int bcm_tsn_sr_rx_flow_seqnum_history_get( 423 int unit, 424 bcm_tsn_sr_flow_t flow_id, 425 int offset_in_bits, 426 int max_size_in_bits, 427 uint8 *history_bits, 428 int *actual_size_in_bits); 429 430 #endif /* BCM_HIDE_DISPATCHABLE */ 431 432 /* TSN flow */ 433 typedef uint32 bcm_tsn_flow_t; 434 435 /* Flags for bcm_tsn_flow_config_t */ 436 #define BCM_TSN_FLOW_CONFIG_DO_NOT_CUT_THROUGH 0x00000001 /* Do not cut-through for 437 the flow */ 438 439 /* TSN flow configuration */ 440 typedef struct bcm_tsn_flow_config_s { 441 uint32 flags; 442 int ingress_mtu_profile; /* Ingress MTU profile ID */ 443 } bcm_tsn_flow_config_t; 444 445 /* Initialize a TSN flow configuration structure */ 446 extern void bcm_tsn_flow_config_t_init( 447 bcm_tsn_flow_config_t *flow_config); 448 449 #ifndef BCM_HIDE_DISPATCHABLE 450 451 /* Create a TSN flow set */ 452 extern int bcm_tsn_flowset_create( 453 int unit, 454 bcm_tsn_pri_map_t pri_map, 455 bcm_tsn_flow_config_t *default_config, 456 bcm_tsn_flowset_t *flowset); 457 458 #endif /* BCM_HIDE_DISPATCHABLE */ 459 460 /* TSN flow set status */ 461 typedef struct bcm_tsn_flowset_status_s { 462 int count; /* Actual number of flows in this flowset */ 463 int active; /* Indicates whether it's active */ 464 } bcm_tsn_flowset_status_t; 465 466 /* Initialize a TSN flow set status structure */ 467 extern void bcm_tsn_flowset_status_t_init( 468 bcm_tsn_flowset_status_t *status); 469 470 #ifndef BCM_HIDE_DISPATCHABLE 471 472 /* Retrieve the current status for a TSN flow set */ 473 extern int bcm_tsn_flowset_status_get( 474 int unit, 475 bcm_tsn_flowset_t flowset, 476 bcm_tsn_flowset_status_t *status); 477 478 /* 479 * Retrieve an individual TSN flow ID based on the flow offset from a 480 * flow set. 481 */ 482 extern int bcm_tsn_flowset_flow_get( 483 int unit, 484 bcm_tsn_flowset_t flowset, 485 int index, 486 bcm_tsn_flow_t *flow_id); 487 488 /* Retrieve the initial configuration for a TSN flow set */ 489 extern int bcm_tsn_flowset_config_get( 490 int unit, 491 bcm_tsn_flowset_t flowset, 492 bcm_tsn_pri_map_t *pri_map, 493 bcm_tsn_flow_config_t *default_config); 494 495 #endif /* BCM_HIDE_DISPATCHABLE */ 496 497 /* TSN flow set traverse callback */ 498 typedef int (*bcm_tsn_flowset_traverse_cb)( 499 int unit, 500 bcm_tsn_flowset_t flowset, 501 void *user_data); 502 503 #ifndef BCM_HIDE_DISPATCHABLE 504 505 /* Traverse all the created TSN flow sets */ 506 extern int bcm_tsn_flowset_traverse( 507 int unit, 508 bcm_tsn_flowset_traverse_cb cb, 509 void *user_data); 510 511 /* Destroy a TSN flow set */ 512 extern int bcm_tsn_flowset_destroy( 513 int unit, 514 bcm_tsn_flowset_t flowset); 515 516 /* Retrieve the flow configuration for a TSN flow */ 517 extern int bcm_tsn_flow_config_get( 518 int unit, 519 bcm_tsn_flow_t flow_id, 520 bcm_tsn_flow_config_t *config); 521 522 /* Set (modify) the flow configuration for a TSN flow */ 523 extern int bcm_tsn_flow_config_set( 524 int unit, 525 bcm_tsn_flow_t flow_id, 526 bcm_tsn_flow_config_t *config); 527 528 #endif /* BCM_HIDE_DISPATCHABLE */ 529 530 /* Flags for bcm_tsn_sr_auto_learn_group_config_t */ 531 #define BCM_TSN_SR_AUTO_LEARN_GROUP_PROXY_FILTERING 0x00000001 /* Enable Proxy MAC 532 filtering */ 533 534 /* SR auto learn group configuration */ 535 typedef struct bcm_tsn_sr_auto_learn_group_config_s { 536 uint32 flags; /* BCM_TSN_SR_AUTO_LEARN_GROUP_xxx flags */ 537 bcm_pbmp_t interlink_ports; /* Bitmap of interlink ports in this group */ 538 bcm_pbmp_t redundant_ports; /* Bitmap of SR redundant ports in this group */ 539 } bcm_tsn_sr_auto_learn_group_config_t; 540 541 /* Initialize a bcm_tsn_sr_auto_learn_group_config_t structure */ 542 extern void bcm_tsn_sr_auto_learn_group_config_t_init( 543 bcm_tsn_sr_auto_learn_group_config_t *config); 544 545 #ifndef BCM_HIDE_DISPATCHABLE 546 547 /* Create an SR auto learn group. */ 548 extern int bcm_tsn_sr_auto_learn_group_create( 549 int unit, 550 bcm_tsn_sr_auto_learn_group_config_t *config, 551 int *group_id); 552 553 /* Get the information to specified auto learn group ID. */ 554 extern int bcm_tsn_sr_auto_learn_group_get( 555 int unit, 556 int group_id, 557 bcm_tsn_sr_auto_learn_group_config_t *config); 558 559 /* Set the information to specified auto learn group ID. */ 560 extern int bcm_tsn_sr_auto_learn_group_set( 561 int unit, 562 int group_id, 563 bcm_tsn_sr_auto_learn_group_config_t *config); 564 565 /* Destroy a auto learn group object. */ 566 extern int bcm_tsn_sr_auto_learn_group_destroy( 567 int unit, 568 int group_id); 569 570 #endif /* BCM_HIDE_DISPATCHABLE */ 571 572 /* Traverse all SR auto learn groups */ 573 typedef int (*bcm_tsn_sr_auto_learn_group_traverse_cb)( 574 int unit, 575 int group_id, 576 void *user_data); 577 578 #ifndef BCM_HIDE_DISPATCHABLE 579 580 /* Traverse all auto learn groups. */ 581 extern int bcm_tsn_sr_auto_learn_group_traverse( 582 int unit, 583 bcm_tsn_sr_auto_learn_group_traverse_cb cb, 584 void *user_data); 585 586 #endif /* BCM_HIDE_DISPATCHABLE */ 587 588 /* SR auto learn configuration */ 589 typedef struct bcm_tsn_sr_auto_learn_config_s { 590 int num_tx_flows; /* Number of TX flows for auto learn */ 591 int num_rx_flows; /* Number of RX flows for auto learn */ 592 bcm_tsn_sr_tx_flow_config_t tx_flow_config; /* Default TX flow configuration */ 593 bcm_tsn_sr_rx_flow_config_t rx_flow_config; /* Default RX flow configuration */ 594 } bcm_tsn_sr_auto_learn_config_t; 595 596 /* Initialize a bcm_tsn_sr_auto_learn_config_t structure */ 597 extern void bcm_tsn_sr_auto_learn_config_t_init( 598 bcm_tsn_sr_auto_learn_config_t *config); 599 600 #ifndef BCM_HIDE_DISPATCHABLE 601 602 /* Enable or disable the global SR auto learn feature. */ 603 extern int bcm_tsn_sr_auto_learn_enable( 604 int unit, 605 int enable, 606 bcm_tsn_sr_auto_learn_config_t *config); 607 608 /* Get the current status of SR auto learn. */ 609 extern int bcm_tsn_sr_auto_learn_enable_get( 610 int unit, 611 int *enabled, 612 bcm_tsn_sr_auto_learn_config_t *config); 613 614 #endif /* BCM_HIDE_DISPATCHABLE */ 615 616 /* Sequence number window reset mode when aged out */ 617 #define BCM_TSN_CONTROL_SR_SEQNUM_WINDOW_RESET_MODE_HW1 1 /* Hardware mode 1: 618 always accept the 619 first packet */ 620 #define BCM_TSN_CONTROL_SR_SEQNUM_WINDOW_RESET_MODE_HW2 2 /* Hardware mode 2: 621 expect sequence number 622 0 for the first SR 623 packet received */ 624 #define BCM_TSN_CONTROL_SR_SEQNUM_WINDOW_RESET_MODE_SW 3 /* Software (custom) 625 reset mode */ 626 627 /* TSN controls */ 628 typedef enum bcm_tsn_control_e { 629 bcmTsnControlSrAgeTickInterval = 0, /* Age timer tick interval in msecs */ 630 bcmTsnControlSrAgeOutEnable = 1, /* Global age out enable */ 631 bcmTsnControlSrSeqNumWindowResetMode = 2, /* See 632 BCM_TSN_CONTROL_SR_SEQNUM_WINDOW_RESET_MODE_xxx */ 633 bcmTsnControlSrLooseOutOfOrder = 3, /* Loose out of order definition. An SR 634 packet is considered out of order if 635 it's in the acceptance window and the 636 equence number is less than previous 637 received packet. */ 638 bcmTsnControlSrHsrEthertype = 4, /* The EtherType value for the HSR tag */ 639 bcmTsnControlSrPrpEthertype = 5, /* The EtherType (suffix) value for the 640 PRP RCT trailer */ 641 bcmTsnControlSrDot1cbEthertype = 6, /* The EtherType value for the 802.1CB 642 tag */ 643 bcmTsnControlIngressMtuProfile = 7, /* Ingress MTU profile ID (per port) */ 644 bcmTsnControlEgressMtuPriorityMap = 8, /* Priority mapping for egress MTU check 645 (per-port) */ 646 bcmTsnControlIngressStuProfile = 9, /* Ingress STU profile ID (per port) */ 647 bcmTsnControlEgressStuPriorityMap = 10, /* Priority mapping for egress STU check 648 (per-port) */ 649 bcmTsnControlTafEnable = 11, /* Enable TAF (Time Aware Filtering) 650 (per-port) */ 651 bcmTsnControlTafGatePriMap = 12, /* TAF gate priority mapping (per-port) */ 652 bcmTsnControlTafGatePriMapL2Select = 13, /* TAF gate priority mapping lookup by 653 MAC-SA(0) or MAC-DA(1) (per-port) */ 654 bcmTsnControlCount = 14 /* Always last. Not a usable value. */ 655 } bcm_tsn_control_t; 656 657 #ifndef BCM_HIDE_DISPATCHABLE 658 659 /* Configure device-wide operation modes for TSN */ 660 extern int bcm_tsn_control_set( 661 int unit, 662 bcm_tsn_control_t type, 663 uint32 arg); 664 665 /* Configure device-wide operation modes for TSN */ 666 extern int bcm_tsn_control_get( 667 int unit, 668 bcm_tsn_control_t type, 669 uint32 *arg); 670 671 /* Configure port-specific operation modes for TSN */ 672 extern int bcm_tsn_port_control_set( 673 int unit, 674 bcm_gport_t port, 675 bcm_tsn_control_t type, 676 uint32 arg); 677 678 /* Configure port-specific operation modes for TSN */ 679 extern int bcm_tsn_port_control_get( 680 int unit, 681 bcm_gport_t port, 682 bcm_tsn_control_t type, 683 uint32 *arg); 684 685 #endif /* BCM_HIDE_DISPATCHABLE */ 686 687 /* TSN stat types */ 688 typedef enum bcm_tsn_stat_e { 689 bcmTsnStatIngressSrTaggedPackets = 0, /* Number of SR tagged packets received */ 690 bcmTsnStatIngressNonLinkLocalPackets = 1, /* Number of all non-link-local packets 691 received */ 692 bcmTsnStatIngressSrWrongLanPackets = 2, /* Number of PRP packets with wrong LAN 693 ID */ 694 bcmTsnStatIngressSrRxErrorPackets = 3, /* Number of packets received with 695 invalid flow or dropped due to errors */ 696 bcmTsnStatIngressSrTagErrorPackets = 4, /* Number of packets received with 697 invalid SR tag */ 698 bcmTsnStatIngressSrDuplicatePackets = 5, /* Number of duplicate SR packets 699 received */ 700 bcmTsnStatIngressSrOutOfOrderSrPackets = 6, /* Number of SR packets received out of 701 order */ 702 bcmTsnStatIngressSrOwnRxPackets = 7, /* Number of SR packets received that 703 originated from this device */ 704 bcmTsnStatIngressSrUnexpectedPackets = 8, /* Number of packets received with wrong 705 SR tag */ 706 bcmTsnStatIngressMtuErrorPackets = 9, /* Number of packets received that have 707 violated MTU size */ 708 bcmTsnStatIngressStuErrorPackets = 10, /* Number of packets received that have 709 violated STU size */ 710 bcmTsnStatIngressSrAcceptedSrPackets = 11, /* Number of SR packets that are 711 accepted and pass the duplicate 712 discard mechanism */ 713 bcmTsnStatIngressSrSaSrcFilteredPackets = 12, /* Number of SR packets that dropped due 714 to source port filtering */ 715 bcmTsnStatIngressTafMeterDrop = 13, /* Number of packets got dropped by the 716 meter */ 717 bcmTsnStatIngressTafGatePass = 14, /* Number of packets passed through the 718 TAF gate */ 719 bcmTsnStatIngressTafGateCloseDrop = 15, /* Number of packets got dropped by TAF 720 gate during close state */ 721 bcmTsnStatIngressTafGateNoByteDrop = 16, /* Number of packets got dropped by TAF 722 gate during open state because of max 723 bytes check failed */ 724 bcmTsnStatIngressTafMtuPass = 17, /* Number of packets passed the MTU 725 check */ 726 bcmTsnStatEgressSrTaggedPackets = 18, /* Number of SR tagged packets 727 transmitted */ 728 bcmTsnStatEgressNonLinkLocalPackets = 19, /* Number of all non-link-local packets 729 transmitted */ 730 bcmTsnStatEgressMtuErrorPackets = 20, /* Number of packets transmitted that 731 have violated MTU size */ 732 bcmTsnStatEgressStuErrorPackets = 21, /* Number of packets transmitted that 733 have violated STU size */ 734 bcmTsnStatCount = 22 /* Always last. Not a usable value. */ 735 } bcm_tsn_stat_t; 736 737 /* TSN TAF gate stat types */ 738 typedef enum bcm_tsn_taf_gate_stat_e { 739 bcmTsnTafGateStatPassed = 0, /* Number of packets passed TAF gate */ 740 bcmTsnTafGateStatDrop = 1, /* Number of packets dropped by TAF gate */ 741 bcmTsnTafGateStatCount = 2 /* Always last. Not a usable value. */ 742 } bcm_tsn_taf_gate_stat_t; 743 744 #ifndef BCM_HIDE_DISPATCHABLE 745 746 /* Set the specified TSN statistic type to the device. */ 747 extern int bcm_tsn_port_stat_set( 748 int unit, 749 bcm_gport_t port, 750 bcm_tsn_stat_t stat, 751 uint64 val); 752 753 /* Set the specified TSN statistic type to the device. */ 754 extern int bcm_tsn_port_stat_set32( 755 int unit, 756 bcm_gport_t port, 757 bcm_tsn_stat_t stat, 758 uint32 val); 759 760 /* Get the specified TSN statistic type from the device. */ 761 extern int bcm_tsn_port_stat_get( 762 int unit, 763 bcm_gport_t port, 764 bcm_tsn_stat_t stat, 765 uint64 *val); 766 767 /* Get the specified TSN statistic type from the device. */ 768 extern int bcm_tsn_port_stat_get32( 769 int unit, 770 bcm_gport_t port, 771 bcm_tsn_stat_t stat, 772 uint32 *val); 773 774 /* Set the specified multiple TSN statistics to the device. */ 775 extern int bcm_tsn_port_stat_multi_set( 776 int unit, 777 bcm_gport_t port, 778 int nstat, 779 bcm_tsn_stat_t *stat_arr, 780 uint64 *value_arr); 781 782 /* Set the specified multiple TSN statistics to the device. */ 783 extern int bcm_tsn_port_stat_multi_set32( 784 int unit, 785 bcm_gport_t port, 786 int nstat, 787 bcm_tsn_stat_t *stat_arr, 788 uint32 *value_arr); 789 790 /* Get the specified multiple TSN statistics from the device. */ 791 extern int bcm_tsn_port_stat_multi_get( 792 int unit, 793 bcm_gport_t port, 794 int nstat, 795 bcm_tsn_stat_t *stat_arr, 796 uint64 *value_arr); 797 798 /* Get the specified multiple TSN statistics from the device. */ 799 extern int bcm_tsn_port_stat_multi_get32( 800 int unit, 801 bcm_gport_t port, 802 int nstat, 803 bcm_tsn_stat_t *stat_arr, 804 uint32 *value_arr); 805 806 /* 807 * Force an immediate counter update and get TSN statistics for a 808 * specified device. 809 */ 810 extern int bcm_tsn_port_stat_sync_get( 811 int unit, 812 bcm_gport_t port, 813 bcm_tsn_stat_t stat, 814 uint64 *val); 815 816 /* 817 * Force an immediate counter update and get TSN statistics for a 818 * specified device. 819 */ 820 extern int bcm_tsn_port_stat_sync_get32( 821 int unit, 822 bcm_gport_t port, 823 bcm_tsn_stat_t stat, 824 uint32 *val); 825 826 /* 827 * Force an immediate counter update and get a set of statistics for a 828 * specified device. 829 */ 830 extern int bcm_tsn_port_stat_sync_multi_get( 831 int unit, 832 bcm_gport_t port, 833 int nstat, 834 bcm_tsn_stat_t *stat_arr, 835 uint64 *value_arr); 836 837 /* 838 * Force an immediate counter update and get a set of statistics for a 839 * specified device. 840 */ 841 extern int bcm_tsn_port_stat_sync_multi_get32( 842 int unit, 843 bcm_gport_t port, 844 int nstat, 845 bcm_tsn_stat_t *stat_arr, 846 uint32 *value_arr); 847 848 #endif /* BCM_HIDE_DISPATCHABLE */ 849 850 /* TSN statistic group */ 851 typedef int bcm_tsn_stat_group_t; 852 853 /* TSN statistic group type */ 854 typedef enum bcm_tsn_stat_group_type_e { 855 bcmTsnStatGroupTypeIngress = 0, /* Group for bcmTsnStatIngressXXX stats */ 856 bcmTsnStatGroupTypeEgress = 1, /* Group for bcmTsnStatEgressXXX stats */ 857 bcmTsnStatGroupTypeCount = 2 /* Always last. Not a usable value. */ 858 } bcm_tsn_stat_group_type_t; 859 860 #ifndef BCM_HIDE_DISPATCHABLE 861 862 /* Create a TSN stat group */ 863 extern int bcm_tsn_stat_group_create( 864 int unit, 865 bcm_tsn_stat_group_type_t group_type, 866 int count, 867 bcm_tsn_stat_t *stat_arr, 868 bcm_tsn_stat_group_t *id); 869 870 /* Get configuration of the TSN stat group */ 871 extern int bcm_tsn_stat_group_get( 872 int unit, 873 bcm_tsn_stat_group_t id, 874 bcm_tsn_stat_group_type_t *group_type, 875 int max, 876 bcm_tsn_stat_t *stat_arr, 877 int *count); 878 879 /* Set configuration of the TSN stat group */ 880 extern int bcm_tsn_stat_group_set( 881 int unit, 882 bcm_tsn_stat_group_t id, 883 int count, 884 bcm_tsn_stat_t *stat_arr); 885 886 /* Destroy a TSN stat group. */ 887 extern int bcm_tsn_stat_group_destroy( 888 int unit, 889 bcm_tsn_stat_group_t id); 890 891 #endif /* BCM_HIDE_DISPATCHABLE */ 892 893 /* TSN stat group traverse callback */ 894 typedef int (*bcm_tsn_stat_group_traverse_cb)( 895 int unit, 896 bcm_tsn_stat_group_t id, 897 void *user_data); 898 899 #ifndef BCM_HIDE_DISPATCHABLE 900 901 /* Traverse TSN stat groups */ 902 extern int bcm_tsn_stat_group_traverse( 903 int unit, 904 bcm_tsn_stat_group_traverse_cb cb, 905 void *user_data); 906 907 #endif /* BCM_HIDE_DISPATCHABLE */ 908 909 /* Invalid TSN stat group. Used when counting is disabled. */ 910 #define BCM_TSN_STAT_GROUP_INVALID ((bcm_tsn_stat_group_t) -1) 911 912 #ifndef BCM_HIDE_DISPATCHABLE 913 914 /* Set flow attached to stat group */ 915 extern int bcm_tsn_sr_flow_stat_group_set( 916 int unit, 917 bcm_tsn_sr_flow_t flow, 918 bcm_tsn_stat_group_type_t group_type, 919 bcm_tsn_stat_group_t stat_group); 920 921 /* Get the stat group attached on this flow */ 922 extern int bcm_tsn_sr_flow_stat_group_get( 923 int unit, 924 bcm_tsn_sr_flow_t flow, 925 bcm_tsn_stat_group_type_t group_type, 926 bcm_tsn_stat_group_t *stat_group); 927 928 /* Set the specified TSN statistic type to the flow. */ 929 extern int bcm_tsn_sr_flow_stat_set( 930 int unit, 931 bcm_tsn_sr_flow_t flow, 932 bcm_tsn_stat_t stat, 933 uint64 val); 934 935 /* Set the specified TSN statistic type to the flow. */ 936 extern int bcm_tsn_sr_flow_stat_set32( 937 int unit, 938 bcm_tsn_sr_flow_t flow, 939 bcm_tsn_stat_t stat, 940 uint32 val); 941 942 /* Get the specified TSN statistic type on this flow. */ 943 extern int bcm_tsn_sr_flow_stat_get( 944 int unit, 945 bcm_tsn_sr_flow_t flow, 946 bcm_tsn_stat_t stat, 947 uint64 *val); 948 949 /* Get the specified TSN statistic type on this flow. */ 950 extern int bcm_tsn_sr_flow_stat_get32( 951 int unit, 952 bcm_tsn_sr_flow_t flow, 953 bcm_tsn_stat_t stat, 954 uint32 *val); 955 956 /* Set the specified multiple TSN statistics to the flow. */ 957 extern int bcm_tsn_sr_flow_stat_multi_set( 958 int unit, 959 bcm_tsn_sr_flow_t flow, 960 int nstat, 961 bcm_tsn_stat_t *stat_arr, 962 uint64 *value_arr); 963 964 /* Set the specified multiple TSN statistics to the flow. */ 965 extern int bcm_tsn_sr_flow_stat_multi_set32( 966 int unit, 967 bcm_tsn_sr_flow_t flow, 968 int nstat, 969 bcm_tsn_stat_t *stat_arr, 970 uint32 *value_arr); 971 972 /* Get the specified multiple TSN statistics on the flow. */ 973 extern int bcm_tsn_sr_flow_stat_multi_get( 974 int unit, 975 bcm_tsn_sr_flow_t flow, 976 int nstat, 977 bcm_tsn_stat_t *stat_arr, 978 uint64 *value_arr); 979 980 /* Get the specified multiple TSN statistics on the flow. */ 981 extern int bcm_tsn_sr_flow_stat_multi_get32( 982 int unit, 983 bcm_tsn_sr_flow_t flow, 984 int nstat, 985 bcm_tsn_stat_t *stat_arr, 986 uint32 *value_arr); 987 988 /* 989 * Force an immediate counter update and get TSN statistics for a 990 * specified flow. 991 */ 992 extern int bcm_tsn_sr_flow_stat_sync_get( 993 int unit, 994 bcm_tsn_sr_flow_t flow, 995 bcm_tsn_stat_t stat, 996 uint64 *val); 997 998 /* 999 * Force an immediate counter update and get TSN statistics for a 1000 * specified flow. 1001 */ 1002 extern int bcm_tsn_sr_flow_stat_sync_get32( 1003 int unit, 1004 bcm_tsn_sr_flow_t flow, 1005 bcm_tsn_stat_t stat, 1006 uint32 *val); 1007 1008 /* 1009 * Force an immediate counter update and get a set of statistics for a 1010 * specified device. 1011 */ 1012 extern int bcm_tsn_sr_flow_stat_sync_multi_get( 1013 int unit, 1014 bcm_tsn_sr_flow_t flow, 1015 int nstat, 1016 bcm_tsn_stat_t *stat_arr, 1017 uint64 *value_arr); 1018 1019 /* 1020 * Force an immediate counter update and get a set of statistics for a 1021 * specified device. 1022 */ 1023 extern int bcm_tsn_sr_flow_stat_sync_multi_get32( 1024 int unit, 1025 bcm_tsn_sr_flow_t flow, 1026 int nstat, 1027 bcm_tsn_stat_t *stat_arr, 1028 uint32 *value_arr); 1029 1030 /* Set the specified TAF gate statistic. */ 1031 extern int bcm_tsn_taf_gate_stat_set( 1032 int unit, 1033 int taf_gate_id, 1034 bcm_tsn_taf_gate_stat_t stat, 1035 uint64 val); 1036 1037 /* Set the specified TAF gate statistic. */ 1038 extern int bcm_tsn_taf_gate_stat_set32( 1039 int unit, 1040 int taf_gate_id, 1041 bcm_tsn_taf_gate_stat_t stat, 1042 uint32 val); 1043 1044 /* Get the specified TAF gate statistic. */ 1045 extern int bcm_tsn_taf_gate_stat_get( 1046 int unit, 1047 int taf_gate_id, 1048 bcm_tsn_taf_gate_stat_t stat, 1049 uint64 *val); 1050 1051 /* Get the specified TAF gate statistic. */ 1052 extern int bcm_tsn_taf_gate_stat_get32( 1053 int unit, 1054 int taf_gate_id, 1055 bcm_tsn_taf_gate_stat_t stat, 1056 uint32 *val); 1057 1058 /* Set the specified multiple TSN statistics. */ 1059 extern int bcm_tsn_taf_gate_stat_multi_set( 1060 int unit, 1061 int taf_gate_id, 1062 int nstat, 1063 bcm_tsn_taf_gate_stat_t *stat_arr, 1064 uint64 *val_arr); 1065 1066 /* Set the specified multiple TSN statistics. */ 1067 extern int bcm_tsn_taf_gate_stat_multi_set32( 1068 int unit, 1069 int taf_gate_id, 1070 int nstat, 1071 bcm_tsn_taf_gate_stat_t *stat_arr, 1072 uint32 *val_arr); 1073 1074 /* Get the specified multiple TSN statistics on the gate. */ 1075 extern int bcm_tsn_taf_gate_stat_multi_get( 1076 int unit, 1077 int taf_gate_id, 1078 int nstat, 1079 bcm_tsn_taf_gate_stat_t *stat_arr, 1080 uint64 *val_arr); 1081 1082 /* Get the specified multiple TSN statistics on the gate. */ 1083 extern int bcm_tsn_taf_gate_stat_multi_get32( 1084 int unit, 1085 int taf_gate_id, 1086 int nstat, 1087 bcm_tsn_taf_gate_stat_t *stat_arr, 1088 uint32 *val_arr); 1089 1090 /* 1091 * Force an immediate counter update and get TSN statistics for a 1092 * specified gate. 1093 */ 1094 extern int bcm_tsn_taf_gate_stat_sync_get( 1095 int unit, 1096 int taf_gate_id, 1097 bcm_tsn_taf_gate_stat_t stat, 1098 uint64 *val); 1099 1100 /* 1101 * Force an immediate counter update and get TSN statistics for a 1102 * specified gate. 1103 */ 1104 extern int bcm_tsn_taf_gate_stat_sync_get32( 1105 int unit, 1106 int taf_gate_id, 1107 bcm_tsn_taf_gate_stat_t stat, 1108 uint32 *val); 1109 1110 /* 1111 * Force an immediate counter update and get a set of statistics for a 1112 * specified device. 1113 */ 1114 extern int bcm_tsn_taf_gate_stat_sync_multi_get( 1115 int unit, 1116 int taf_gate_id, 1117 int nstat, 1118 bcm_tsn_taf_gate_stat_t *stat_arr, 1119 uint64 *val_arr); 1120 1121 /* 1122 * Force an immediate counter update and get a set of statistics for a 1123 * specified device. 1124 */ 1125 extern int bcm_tsn_taf_gate_stat_sync_multi_get32( 1126 int unit, 1127 int taf_gate_id, 1128 int nstat, 1129 bcm_tsn_taf_gate_stat_t *stat_arr, 1130 uint32 *val_arr); 1131 1132 #endif /* BCM_HIDE_DISPATCHABLE */ 1133 1134 /* Flags for bcm_tsn_stat_threshold_config_t */ 1135 #define BCM_TSN_STAT_THRESHOLD_EVENT_NOTIFICATION 0x00000001 /* Notify via registered 1136 event notification 1137 callback */ 1138 #define BCM_TSN_STAT_THRESHOLD_COPY_TO_CPU 0x00000002 /* Copy the packet to CPU */ 1139 1140 /* TSN stat threshold configuration */ 1141 typedef struct bcm_tsn_stat_threshold_config_s { 1142 uint32 flags; /* See BCM_TSN_STAT_THRESHOLD_xxx. If it's 0, no 1143 threshold checking will be performed. */ 1144 uint32 threshold; /* Threshold value. 0 means disabled. */ 1145 } bcm_tsn_stat_threshold_config_t; 1146 1147 /* Initialize a TSN statistics threshold configuration structure */ 1148 extern void bcm_tsn_stat_threshold_config_t_init( 1149 bcm_tsn_stat_threshold_config_t *config); 1150 1151 /* Stat source for TSN stat threshold check */ 1152 typedef enum bcm_tsn_stat_threshold_source_e { 1153 bcmTsnStatThresholdSourcePort = 0, /* Threshold check on a specific port */ 1154 bcmTsnStatThresholdSourceSRFlow = 1 /* Threshold check on a specific SR flow */ 1155 } bcm_tsn_stat_threshold_source_t; 1156 1157 #ifndef BCM_HIDE_DISPATCHABLE 1158 1159 /* 1160 * Configure/Get threshold for a specific statistics type on a specific 1161 * source. 1162 */ 1163 extern int bcm_tsn_stat_threshold_set( 1164 int unit, 1165 bcm_tsn_stat_threshold_source_t source, 1166 bcm_tsn_stat_t stat, 1167 bcm_tsn_stat_threshold_config_t *config); 1168 1169 /* 1170 * Configure/Get threshold for a specific statistics type on a specific 1171 * source. 1172 */ 1173 extern int bcm_tsn_stat_threshold_get( 1174 int unit, 1175 bcm_tsn_stat_threshold_source_t source, 1176 bcm_tsn_stat_t stat, 1177 bcm_tsn_stat_threshold_config_t *config); 1178 1179 #endif /* BCM_HIDE_DISPATCHABLE */ 1180 1181 /* TSN event types */ 1182 typedef enum bcm_tsn_event_type_e { 1183 bcmTsnEventTypeCounterExceeded = 0, /* Counter threshold exceeds (flow or 1184 port) */ 1185 bcmTsnEventTypeSrWrongLanA = 1, /* Wrong LAN packet received on LAN A 1186 (per flow) */ 1187 bcmTsnEventTypeSrWrongLanB = 2, /* Wrong LAN packet received on LAN B 1188 (per flow) */ 1189 bcmTsnEventTypeSrSeqNumWindowAgeOut = 3, /* Sequence number window aged out if 1190 using software reset mode (per flow) */ 1191 bcmTsnEventTypeCount = 4 /* Always Last. Not a usable value. */ 1192 } bcm_tsn_event_type_t; 1193 1194 /* TSN event source types */ 1195 #define BCM_TSN_EVENT_SOURCE_TYPE_SYSTEM 0 /* System event or source 1196 unknown */ 1197 #define BCM_TSN_EVENT_SOURCE_TYPE_PORT 1 /* Event from a specific 1198 port */ 1199 #define BCM_TSN_EVENT_SOURCE_TYPE_SR_FLOW 2 /* Event from a specific 1200 SR flow */ 1201 1202 /* The source that triggers the TSN event */ 1203 typedef struct bcm_tsn_event_source_s { 1204 int source_type; /* Type of the event source */ 1205 bcm_gport_t port; /* Port number. Valid only if the source is a 1206 port */ 1207 bcm_tsn_sr_flow_t sr_flow; /* SR flow ID. Valid only if the source is an SR 1208 flow */ 1209 } bcm_tsn_event_source_t; 1210 1211 /* Initialize a TSN event source structure */ 1212 extern void bcm_tsn_event_source_t_init( 1213 bcm_tsn_event_source_t *source); 1214 1215 /* TSN event notification callback function prototype */ 1216 typedef int (*bcm_tsn_event_cb)( 1217 int unit, 1218 bcm_tsn_event_type_t event, 1219 bcm_tsn_event_source_t *source, 1220 void *user_data); 1221 1222 #ifndef BCM_HIDE_DISPATCHABLE 1223 1224 /* Register/unregister a callback function for handling TSN events */ 1225 extern int bcm_tsn_event_register( 1226 int unit, 1227 bcm_tsn_event_type_t event, 1228 bcm_tsn_event_source_t *src, 1229 bcm_tsn_event_cb cb, 1230 void *user_data); 1231 1232 /* Register/unregister a callback function for handling TSN events */ 1233 extern int bcm_tsn_event_unregister( 1234 int unit, 1235 bcm_tsn_event_type_t event, 1236 bcm_tsn_event_source_t *src, 1237 bcm_tsn_event_cb cb); 1238 1239 #endif /* BCM_HIDE_DISPATCHABLE */ 1240 1241 /* TSN event notification traverse callback */ 1242 typedef int (*bcm_tsn_event_notification_traverse_cb)( 1243 int unit, 1244 bcm_tsn_event_type_t event, 1245 bcm_tsn_event_source_t *src, 1246 bcm_tsn_event_cb cb, 1247 void *event_cb_user_data, 1248 void *user_data); 1249 1250 #ifndef BCM_HIDE_DISPATCHABLE 1251 1252 /* Traverse all registered event notification callbacks */ 1253 extern int bcm_tsn_event_notification_traverse( 1254 int unit, 1255 bcm_tsn_event_notification_traverse_cb cb, 1256 void *user_data); 1257 1258 #endif /* BCM_HIDE_DISPATCHABLE */ 1259 1260 /* MTU profile configuration for TSN */ 1261 typedef struct bcm_tsn_mtu_config_s { 1262 uint16 size; /* Size in bytes to check. 0 to disable checking. */ 1263 uint8 drop; /* Drop violated packets if 1 */ 1264 } bcm_tsn_mtu_config_t; 1265 1266 /* Initialize a TSN MTU profile configuration structure */ 1267 extern void bcm_tsn_mtu_config_t_init( 1268 bcm_tsn_mtu_config_t *config); 1269 1270 /* Types of MTU profiles */ 1271 typedef enum bcm_tsn_mtu_profile_type_e { 1272 bcmTsnMtuProfileTypeIngress = 0, /* MTU checking on ingress */ 1273 bcmTsnMtuProfileTypeEgress = 1, /* MTU checking on egress */ 1274 bcmTsnMtuProfileTypeCount = 2 /* Always last. Not a usable value. */ 1275 } bcm_tsn_mtu_profile_type_t; 1276 1277 #ifndef BCM_HIDE_DISPATCHABLE 1278 1279 /* 1280 * Create an MTU profile with the config file and return the assigned 1281 * profile id. 1282 */ 1283 extern int bcm_tsn_mtu_profile_create( 1284 int unit, 1285 bcm_tsn_mtu_profile_type_t type, 1286 bcm_tsn_mtu_config_t *config, 1287 int *mtu_profile_id); 1288 1289 /* Get the existing MTU profile configuration with the profile id. */ 1290 extern int bcm_tsn_mtu_profile_get( 1291 int unit, 1292 int mtu_profile_id, 1293 bcm_tsn_mtu_profile_type_t *type, 1294 bcm_tsn_mtu_config_t *config); 1295 1296 /* Set the existing MTU profile with the profile id and config file. */ 1297 extern int bcm_tsn_mtu_profile_set( 1298 int unit, 1299 int mtu_profile_id, 1300 bcm_tsn_mtu_config_t *config); 1301 1302 /* Clear the existing MTU profile with the profile id. */ 1303 extern int bcm_tsn_mtu_profile_destroy( 1304 int unit, 1305 int mtu_profile_id); 1306 1307 #endif /* BCM_HIDE_DISPATCHABLE */ 1308 1309 /* TSN MTU profile traverse callback */ 1310 typedef int (*bcm_tsn_mtu_profile_traverse_cb)( 1311 int unit, 1312 int profile_id, 1313 void *user_data); 1314 1315 #ifndef BCM_HIDE_DISPATCHABLE 1316 1317 /* Traverse the created MTU profile. */ 1318 extern int bcm_tsn_mtu_profile_traverse( 1319 int unit, 1320 bcm_tsn_mtu_profile_traverse_cb cb, 1321 void *user_data); 1322 1323 #endif /* BCM_HIDE_DISPATCHABLE */ 1324 1325 /* Sources from which ingress MTU profile to check is determined */ 1326 typedef enum bcm_tsn_mtu_source_e { 1327 bcmTsnMtuSourceTsnFlow = 0, /* MTU profile from TSN flow */ 1328 bcmTsnMtuSourceSrFlow = 1, /* MTU profile from SR flow */ 1329 bcmTsnMtuSourcePort = 2, /* MTU profile from port */ 1330 bcmTsnMtuSourceFieldLookup = 3, /* MTU profile from VFP action */ 1331 bcmTsnMtuSourceCount = 4 /* Always last. Not a usable value. */ 1332 } bcm_tsn_mtu_source_t; 1333 1334 /* Ingress MTU system configuration */ 1335 typedef struct bcm_tsn_ingress_mtu_config_s { 1336 bcm_tsn_mtu_source_t source_order[bcmTsnMtuSourceCount]; /* Specify MTU sources in the order of 1337 precedence. Source at array index 0 1338 has highest precedence. */ 1339 int source_order_count; 1340 } bcm_tsn_ingress_mtu_config_t; 1341 1342 /* Initialize a TSN ingress MTU configuration structure */ 1343 extern void bcm_tsn_ingress_mtu_config_t_init( 1344 bcm_tsn_ingress_mtu_config_t *config); 1345 1346 #ifndef BCM_HIDE_DISPATCHABLE 1347 1348 /* 1349 * Set up global configuration for ingress MTU, including the priority of 1350 * the 1351 * following sources: port, VFP, SR flow and TSN flow. 1352 */ 1353 extern int bcm_tsn_ingress_mtu_config_set( 1354 int unit, 1355 bcm_tsn_ingress_mtu_config_t *config); 1356 1357 /* Get the global configuration for ingress MTU source priority sequence. */ 1358 extern int bcm_tsn_ingress_mtu_config_get( 1359 int unit, 1360 bcm_tsn_ingress_mtu_config_t *config); 1361 1362 #endif /* BCM_HIDE_DISPATCHABLE */ 1363 1364 /* STU profile configuration for TSN */ 1365 typedef struct bcm_tsn_stu_config_s { 1366 uint16 size; /* Size in bytes to check. 0 to disable checking. */ 1367 uint8 drop; /* Drop violated packets if 1 */ 1368 } bcm_tsn_stu_config_t; 1369 1370 /* Initialize a TSN STU profile configuration structure */ 1371 extern void bcm_tsn_stu_config_t_init( 1372 bcm_tsn_stu_config_t *config); 1373 1374 /* Types of STU profiles */ 1375 typedef enum bcm_tsn_stu_profile_type_e { 1376 bcmTsnStuProfileTypeIngress = 0, /* STU checking on ingress */ 1377 bcmTsnStuProfileTypeEgress = 1, /* STU checking on egress */ 1378 bcmTsnStuProfileTypeCount = 2 /* Always last. Not a usable value. */ 1379 } bcm_tsn_stu_profile_type_t; 1380 1381 #ifndef BCM_HIDE_DISPATCHABLE 1382 1383 /* 1384 * Create an STU profile with the config file and return the assigned 1385 * profile id. 1386 */ 1387 extern int bcm_tsn_stu_profile_create( 1388 int unit, 1389 bcm_tsn_stu_profile_type_t type, 1390 bcm_tsn_stu_config_t *config, 1391 int *stu_profile_id); 1392 1393 /* Get the existing STU profile configuration with the profile id. */ 1394 extern int bcm_tsn_stu_profile_get( 1395 int unit, 1396 int stu_profile_id, 1397 bcm_tsn_stu_profile_type_t *type, 1398 bcm_tsn_stu_config_t *config); 1399 1400 /* Set the existing STU profile with the profile id and config file. */ 1401 extern int bcm_tsn_stu_profile_set( 1402 int unit, 1403 int stu_profile_id, 1404 bcm_tsn_stu_config_t *config); 1405 1406 /* Clear the existing STU profile with the profile id. */ 1407 extern int bcm_tsn_stu_profile_destroy( 1408 int unit, 1409 int stu_profile_id); 1410 1411 #endif /* BCM_HIDE_DISPATCHABLE */ 1412 1413 /* TSN STU profile traverse callback */ 1414 typedef int (*bcm_tsn_stu_profile_traverse_cb)( 1415 int unit, 1416 int profile_id, 1417 void *user_data); 1418 1419 #ifndef BCM_HIDE_DISPATCHABLE 1420 1421 /* Traverse the created STU profile. */ 1422 extern int bcm_tsn_stu_profile_traverse( 1423 int unit, 1424 bcm_tsn_stu_profile_traverse_cb cb, 1425 void *user_data); 1426 1427 #endif /* BCM_HIDE_DISPATCHABLE */ 1428 1429 /* Sources from which ingress STU profile to check is determined */ 1430 typedef enum bcm_tsn_stu_source_e { 1431 bcmTsnStuSourceFieldLookup = 0, /* STU profile from VFP action */ 1432 bcmTsnStuSourcePort = 1, /* STU profile from port */ 1433 bcmTsnStuSourceCount = 2 /* Always last. Not a usable value. */ 1434 } bcm_tsn_stu_source_t; 1435 1436 /* Ingress STU system configuration */ 1437 typedef struct bcm_tsn_ingress_stu_config_s { 1438 bcm_tsn_stu_source_t source_order[bcmTsnStuSourceCount]; /* Specify STU sources in the order or 1439 precedence. Source at array index 0 1440 has highest precedence. */ 1441 int source_order_count; 1442 } bcm_tsn_ingress_stu_config_t; 1443 1444 /* Initialize a TSN ingress STU configuration structure */ 1445 extern void bcm_tsn_ingress_stu_config_t_init( 1446 bcm_tsn_ingress_stu_config_t *config); 1447 1448 #ifndef BCM_HIDE_DISPATCHABLE 1449 1450 /* 1451 * Set up global configuration for ingress STU, including the priority of 1452 * the following sources: port, VFP. 1453 */ 1454 extern int bcm_tsn_ingress_stu_config_set( 1455 int unit, 1456 bcm_tsn_ingress_stu_config_t *config); 1457 1458 /* Get the global configuration for ingress STU source priority sequence. */ 1459 extern int bcm_tsn_ingress_stu_config_get( 1460 int unit, 1461 bcm_tsn_ingress_stu_config_t *config); 1462 1463 #endif /* BCM_HIDE_DISPATCHABLE */ 1464 1465 /* Use the specified gate Id. */ 1466 #define BCM_TSN_TAF_WITH_ID (1 << 0) 1467 1468 #ifndef BCM_HIDE_DISPATCHABLE 1469 1470 /* Create/Destroy TAF gate */ 1471 extern int bcm_tsn_taf_gate_create( 1472 int unit, 1473 int flags, 1474 int *taf_gate_id); 1475 1476 /* Create/Destroy TAF gate */ 1477 extern int bcm_tsn_taf_gate_destroy( 1478 int unit, 1479 int taf_gate_id); 1480 1481 #endif /* BCM_HIDE_DISPATCHABLE */ 1482 1483 /* TSN traverse callback function for TAF gates */ 1484 typedef int (*bcm_tsn_taf_gate_traverse_cb)( 1485 int unit, 1486 int taf_gate, 1487 void *user_data); 1488 1489 #ifndef BCM_HIDE_DISPATCHABLE 1490 1491 /* Traverse TAF gate */ 1492 extern int bcm_tsn_taf_gate_traverse( 1493 int unit, 1494 bcm_tsn_taf_gate_traverse_cb cb, 1495 void *user_data); 1496 1497 #endif /* BCM_HIDE_DISPATCHABLE */ 1498 1499 /* TAF status type */ 1500 typedef enum bcm_tsn_taf_status_e { 1501 bcmTsnTafStatusGateState = 0, /* The current TAF gate state. */ 1502 bcmTsnTafStatusGateStateSet = 1, /* Reflect which control gate source is 1503 selected. The value = 0 indicates the 1504 gate state is from INIT GATE STATE 1505 settings, value = 1 indicates the 1506 gate state is from active control 1507 list table, value = 2 indicates the 1508 gate state is from ERR GATE STATE 1509 settings */ 1510 bcmTsnTafStatusGateCosProfile = 2, /* The Cos profile this TAF gate use. */ 1511 bcmTsnTafStatusGateMaxBytesProfile = 3, /* The max bytes profile this TAF gate 1512 use. */ 1513 bcmTsnTafStatusTickGranularity = 4, /* The granularity of the calendar table 1514 time clock in ns. */ 1515 bcmTsnTafStatusMaxCalendarEntries = 5, /* The max entries could be support in 1516 calendar table. */ 1517 bcmTsnTafStatusGatMaxBytesLeft = 6, /* Bytes available that can pass through 1518 that gate during current open state. */ 1519 bcmTsnTafStatusCount = 7 /* This should be the last one. */ 1520 } bcm_tsn_taf_status_t; 1521 1522 #ifndef BCM_HIDE_DISPATCHABLE 1523 1524 /* Get the TAF status */ 1525 extern int bcm_tsn_taf_status_get( 1526 int unit, 1527 int taf_gate, 1528 bcm_tsn_taf_status_t type, 1529 uint32 *arg); 1530 1531 #endif /* BCM_HIDE_DISPATCHABLE */ 1532 1533 /* TAF control type */ 1534 typedef enum bcm_tsn_taf_control_e { 1535 bcmTsnTafControlEnable = 0, /* Enable the TAF. */ 1536 bcmTsnTafControlUsePTPTime = 1, /* PTP time is used for TAF synchronous 1537 operation. */ 1538 bcmTsnTafControlInitGateState = 2, /* Gate state when TAF is disabled. Or 1539 the init gate state in the *Restart* 1540 process. */ 1541 bcmTsnTafControlInitCosProfile = 3, /* Cos Profile when TAF is disabled. Or 1542 the init cos Profile in the *Restart* 1543 process. */ 1544 bcmTsnTafControlInitMaxBytesProfile = 4, /* Max bytes Profile when TAF is 1545 disabled. Or the init max bytes 1546 Profile in the *Restart* process. */ 1547 bcmTsnTafControlErrGateState = 5, /* Gate state when error condition 1548 occurs during an old cycle is 1549 running. */ 1550 bcmTsnTafControlErrCosProfile = 6, /* Cos profile when error condition 1551 occurs during an old cycle is 1552 running. */ 1553 bcmTsnTafControlErrMaxByteProfile = 7, /* Max bytes profile when error 1554 condition occurs during an old cycle 1555 is running. */ 1556 bcmTsnTafControlGateCloseControl = 8, /* if set, it will override the gate 1557 purge and drop decisions during gate 1558 close state and it will let the 1559 packet go. */ 1560 bcmTsnTafControlBytesLeftCheckEnable = 9, /* Enable byte left check or not */ 1561 bcmTsnTafControlGateControlTickInterval = 10, /* Gate control ticks interval in ns. */ 1562 bcmTsnTafControlTAFPTPLock = 11, /* Indicate the PTP time is locked or 1563 out of sync. This type is on system 1564 basis. */ 1565 bcmTsnTafControlCount = 12 /* This should be the last one. */ 1566 } bcm_tsn_taf_control_t; 1567 1568 #ifndef BCM_HIDE_DISPATCHABLE 1569 1570 /* Set/get TAF control configurations. */ 1571 extern int bcm_tsn_taf_control_set( 1572 int unit, 1573 int taf_gate, 1574 bcm_tsn_taf_control_t type, 1575 uint32 arg); 1576 1577 /* Set/get TAF control configurations. */ 1578 extern int bcm_tsn_taf_control_get( 1579 int unit, 1580 int taf_gate, 1581 bcm_tsn_taf_control_t type, 1582 uint32 *arg); 1583 1584 #endif /* BCM_HIDE_DISPATCHABLE */ 1585 1586 /* The maximum TAF calendar table size. */ 1587 #define BCM_TSN_TAF_CALENDAR_TABLE_SIZE (16) 1588 1589 /* 1590 * The encoded value used to assigned in ticks field on 1591 * bcm_tsn_taf_entry_t 1592 */ 1593 #define BCM_TSN_TAF_ENTRY_TICKS_STAY (-1) /* Specify to stay in 1594 this entry forever in 1595 non PTP_MODE or until 1596 the next cycle in 1597 PTP_MODE. */ 1598 #define BCM_TSN_TAF_ENTRY_TICKS_GO_FIRST (0) /* Specify to jump to the 1599 first entry. The state 1600 of this entry will be 1601 ignored. */ 1602 1603 /* The TAF entry data structure */ 1604 typedef struct bcm_tsn_taf_entry_s { 1605 uint32 ticks; /* The scheduling interval in ticks */ 1606 uint32 state; /* Specify gate state (1:open, 0:close) */ 1607 int cos_profile; /* Class of service (COS) mapping profile, value 0 1608 for default */ 1609 int maxbyte_profile; /* Max bytes profile, value 0 for default */ 1610 } bcm_tsn_taf_entry_t; 1611 1612 /* The TAF profile data structure */ 1613 typedef struct bcm_tsn_taf_profile_s { 1614 int num_entries; /* Specify the number of entries in the 1615 calendar table. */ 1616 bcm_tsn_taf_entry_t entries[BCM_TSN_TAF_CALENDAR_TABLE_SIZE]; /* Specify the interval, gate states, 1617 attribute entry sets in the calendar 1618 table. */ 1619 bcm_ptp_timestamp_t ptp_base_time; /* Specify base time in PTP time. */ 1620 uint32 ptp_cycle_time; /* Specify cycle time in ns. */ 1621 uint32 ptp_max_cycle_extension; /* Specify max cycle extension time in 1622 ns. Maximum time allowed for a cycle 1623 to be extended before profile change. */ 1624 } bcm_tsn_taf_profile_t; 1625 1626 /* TAF profile state */ 1627 typedef enum bcm_tsn_taf_profile_state_e { 1628 bcmTsnTafProfileInit = 0, /* the state after profile created. */ 1629 bcmTsnTafProfileCommitted = 1, /* the state after profile committed but not 1630 yet written to HW table */ 1631 bcmTsnTafProfilePending = 2, /* the state after profile is set to 1632 hardware but not yet effective */ 1633 bcmTsnTafProfileActive = 3, /* the state indicate the profile is 1634 effective */ 1635 bcmTsnTafProfileExpired = 4, /* The profile is no longer effective. */ 1636 bcmTsnTafProfileError = 5, /* the state indicate the profile is error 1637 when any error event happens */ 1638 bcmTsnTafProfileCount = 6 /* This should be the last one. */ 1639 } bcm_tsn_taf_profile_state_t; 1640 1641 /* TAF profile id */ 1642 typedef int bcm_tsn_taf_profile_id_t; 1643 1644 /* Initialize the bcm_tsn_taf_profile_t structure */ 1645 extern void bcm_tsn_taf_profile_t_init( 1646 bcm_tsn_taf_profile_t *profile); 1647 1648 #ifndef BCM_HIDE_DISPATCHABLE 1649 1650 /* Create the TAF profile */ 1651 extern int bcm_tsn_taf_profile_create( 1652 int unit, 1653 int taf_gate, 1654 bcm_tsn_taf_profile_t *profile, 1655 bcm_tsn_taf_profile_id_t *pid); 1656 1657 /* Destroy the TAF profile */ 1658 extern int bcm_tsn_taf_profile_destroy( 1659 int unit, 1660 int taf_gate, 1661 bcm_tsn_taf_profile_id_t pid); 1662 1663 /* Destroy all TAF profiles. */ 1664 extern int bcm_tsn_taf_profile_destroy_all( 1665 int unit, 1666 int taf_gate); 1667 1668 /* Get/set TAF profile information */ 1669 extern int bcm_tsn_taf_profile_set( 1670 int unit, 1671 int taf_gate, 1672 bcm_tsn_taf_profile_id_t pid, 1673 bcm_tsn_taf_profile_t *profile); 1674 1675 /* Get/set TAF profile information */ 1676 extern int bcm_tsn_taf_profile_get( 1677 int unit, 1678 int taf_gate, 1679 bcm_tsn_taf_profile_id_t pid, 1680 bcm_tsn_taf_profile_t *profile); 1681 1682 /* Commit the TAF profile */ 1683 extern int bcm_tsn_taf_profile_commit( 1684 int unit, 1685 int taf_gate, 1686 bcm_tsn_taf_profile_id_t pid); 1687 1688 #endif /* BCM_HIDE_DISPATCHABLE */ 1689 1690 /* TAF profile traverse callback */ 1691 typedef int (*bcm_tsn_taf_profile_traverse_cb)( 1692 int unit, 1693 int taf_gate, 1694 bcm_tsn_taf_profile_id_t pid, 1695 void *user_data); 1696 1697 #ifndef BCM_HIDE_DISPATCHABLE 1698 1699 /* Traverse the TAF profile */ 1700 extern int bcm_tsn_taf_profile_traverse( 1701 int unit, 1702 int taf_gate, 1703 bcm_tsn_taf_profile_traverse_cb cb, 1704 void *user_data); 1705 1706 #endif /* BCM_HIDE_DISPATCHABLE */ 1707 1708 /* The TAF profile status structure */ 1709 typedef struct bcm_tsn_taf_profile_status_s { 1710 bcm_tsn_taf_profile_state_t profile_state; /* profile state */ 1711 bcm_ptp_timestamp_t config_change_time; /* The actual config change time */ 1712 int num_entries; /* The actual number of entries in 1713 hardware calendar table. */ 1714 bcm_tsn_taf_entry_t entries[BCM_TSN_TAF_CALENDAR_TABLE_SIZE]; /* The actual entries in hardware 1715 calendar table. */ 1716 } bcm_tsn_taf_profile_status_t; 1717 1718 /* Initialize the bcm_tsn_taf_profile_status_t structure */ 1719 extern void bcm_tsn_taf_profile_status_t_init( 1720 bcm_tsn_taf_profile_status_t *profile_status); 1721 1722 #ifndef BCM_HIDE_DISPATCHABLE 1723 1724 /* Get the TAF profile status */ 1725 extern int bcm_tsn_taf_profile_status_get( 1726 int unit, 1727 int taf_gate, 1728 bcm_tsn_taf_profile_id_t pid, 1729 bcm_tsn_taf_profile_status_t *status); 1730 1731 #endif /* BCM_HIDE_DISPATCHABLE */ 1732 1733 /* Tsn Taf event type */ 1734 typedef enum bcm_tsn_taf_event_type_e { 1735 bcmTsnTafEventTAFProfileChange = 0, /* TAF: the profile change is completed. */ 1736 bcmTsnTafEventTAFECCErr = 1, /* TAF: uncorrectable ECC error in 1737 profile calendar table. */ 1738 bcmTsnTafEventTAFNextCycleTimeErr = 2, /* TAF: next cycle start time has 1739 passed. */ 1740 bcmTsnTafEventTAFBaseTimeErr = 3, /* TAF: base time for the new profile 1741 has passed. */ 1742 bcmTsnTafEventTAFProfilePtrErr = 4, /* TAF: index to the profile calendar 1743 table is overrun. */ 1744 bcmTsnTafEventTAFPTPOutOfSyncErr = 5, /* TAF: IEEE1588 PTP time is out of 1745 sync. */ 1746 bcmTsnTafEventCount = 6 /* This should be the last one. */ 1747 } bcm_tsn_taf_event_type_t; 1748 1749 typedef struct bcm_tsn_taf_event_types_s { 1750 SHR_BITDCL w[_SHR_BITDCLSIZE(bcmTsnTafEventCount)]; 1751 } bcm_tsn_taf_event_types_t; 1752 1753 /* helper macro for TAF event handling */ 1754 #define BCM_TSN_TAF_EVENT_TYPE_SET(_event_types, _event_type) SHR_BITSET(((_event_types).w), (_event_type)) 1755 1756 #define BCM_TSN_TAF_EVENT_TYPE_GET(_event_types, _event_type) SHR_BITGET(((_event_types).w), (_event_type)) 1757 1758 #define BCM_TSN_TAF_EVENT_TYPE_CLEAR(_event_types, _event_type) SHR_BITCLR(((_event_types).w), (_event_type)) 1759 1760 #define BCM_TSN_TAF_EVENT_TYPE_SET_ALL(_event_types) SHR_BITSET_RANGE(((_event_types).w), 0, bcmTsnTafEventCount) 1761 1762 #define BCM_TSN_TAF_EVENT_TYPE_CLEAR_ALL(_event_types) SHR_BITCLR_RANGE(((_event_types).w), 0, bcmTsnTafEventCount) 1763 1764 /* Callback function type for Tsn Taf event handling */ 1765 typedef int (*bcm_tsn_taf_event_cb)( 1766 int unit, 1767 bcm_tsn_taf_event_type_t event_type, 1768 int taf_gate, 1769 void *user_data); 1770 1771 #ifndef BCM_HIDE_DISPATCHABLE 1772 1773 /* Register/unregister a callback to handle the TAF events */ 1774 extern int bcm_tsn_taf_event_register( 1775 int unit, 1776 bcm_tsn_taf_event_types_t event_types, 1777 int taf_gate, 1778 bcm_tsn_taf_event_cb cb, 1779 void *user_data); 1780 1781 /* Register/unregister a callback to handle the TAF events */ 1782 extern int bcm_tsn_taf_event_unregister( 1783 int unit, 1784 bcm_tsn_taf_event_types_t event_types, 1785 int taf_gate, 1786 bcm_tsn_taf_event_cb cb); 1787 1788 /* Create/destroy profile of maximum bytes that pass through the TAF gate */ 1789 extern int bcm_tsn_taf_gate_max_bytes_profile_create( 1790 int unit, 1791 int taf_gate_id, 1792 uint64 max_bytes, 1793 int *profile_id); 1794 1795 /* Set/get profile of maximum bytes that pass through the TAF gate */ 1796 extern int bcm_tsn_taf_gate_max_bytes_profile_set( 1797 int unit, 1798 int taf_gate_id, 1799 int profile_id, 1800 uint64 max_bytes); 1801 1802 /* Set/get profile of maximum bytes that pass through the TAF gate */ 1803 extern int bcm_tsn_taf_gate_max_bytes_profile_get( 1804 int unit, 1805 int taf_gate_id, 1806 int profile_id, 1807 uint64 *max_bytes); 1808 1809 /* Create/destroy profile of maximum bytes that pass through the TAF gate */ 1810 extern int bcm_tsn_taf_gate_max_bytes_profile_destroy( 1811 int unit, 1812 int taf_gate_id, 1813 int profile_id); 1814 1815 #endif /* BCM_HIDE_DISPATCHABLE */ 1816 1817 /* TSN traverse callback function for TAF gate max bytes */ 1818 typedef int (*bcm_tsn_taf_gate_max_bytes_profile_traverse_cb)( 1819 int unit, 1820 int taf_gate_id, 1821 int profile_id, 1822 void *user_data); 1823 1824 #ifndef BCM_HIDE_DISPATCHABLE 1825 1826 /* Traverse profile of maximum bytes that pass through the TAF gate */ 1827 extern int bcm_tsn_taf_gate_max_bytes_profile_traverse( 1828 int unit, 1829 int taf_gate_id, 1830 bcm_tsn_taf_gate_max_bytes_profile_traverse_cb cb, 1831 void *user_data); 1832 1833 /* Create/destroy TAF Cos mapping profile */ 1834 extern int bcm_tsn_taf_cosq_mapping_profile_create( 1835 int unit, 1836 int *cosq_profile); 1837 1838 /* Set/get TAF Cos mapping profile */ 1839 extern int bcm_tsn_taf_cosq_mapping_profile_set( 1840 int unit, 1841 int cosq_profile, 1842 bcm_cos_t priority, 1843 bcm_cos_queue_t cosq); 1844 1845 /* Set/get TAF Cos mapping profile */ 1846 extern int bcm_tsn_taf_cosq_mapping_profile_get( 1847 int unit, 1848 int cosq_profile, 1849 bcm_cos_t priority, 1850 bcm_cos_queue_t *cosq); 1851 1852 /* Create/destroy TAF Cos mapping profile */ 1853 extern int bcm_tsn_taf_cosq_mapping_profile_destroy( 1854 int unit, 1855 int cosq_profile); 1856 1857 #endif /* BCM_HIDE_DISPATCHABLE */ 1858 1859 /* TSN traverse callback function for TAF Cos mapping profile */ 1860 typedef int (*bcm_tsn_taf_cosq_mapping_profile_traverse_cb)( 1861 int unit, 1862 int cosq_profile, 1863 void *user_data); 1864 1865 #ifndef BCM_HIDE_DISPATCHABLE 1866 1867 /* Traverse TAF Cos mapping profile */ 1868 extern int bcm_tsn_taf_cosq_mapping_profile_traverse( 1869 int unit, 1870 bcm_tsn_taf_cosq_mapping_profile_traverse_cb cb, 1871 void *user_data); 1872 1873 #endif /* BCM_HIDE_DISPATCHABLE */ 1874 1875 #endif /* __BCM_TSN_H__ */