openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

tsn.h (65201B)


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