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

time.h (22785B)


      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_TIME_H__
     11 #define __BCM_TIME_H__
     12 
     13 #include <bcm/types.h>
     14 
     15 /* Time Interface Identifier. */
     16 typedef int bcm_time_if_t;
     17 
     18 #define BCM_TIME_ENABLE         0x00000001 /* Enable Time Synchronization
     19                                               Interface */
     20 #define BCM_TIME_WITH_ID        0x00000002 /* Create/Update interface with valid
     21                                               identifier in the structure */
     22 #define BCM_TIME_REPLACE        0x00000004 /* Replace current interface settings
     23                                               according to flags provided */
     24 #define BCM_TIME_INPUT          0x00000008 /* Current interface will recieve a
     25                                               time sync messages (Act as slave) */
     26 #define BCM_TIME_DRIFT          0x00000020 /* To set/get the drift parameter for
     27                                               Interface */
     28 #define BCM_TIME_OFFSET         0x00000040 /* To set/get the offset parameter
     29                                               for Interface */
     30 #define BCM_TIME_ACCURACY       0x00000080 /* To set/get the accuracy parameter
     31                                               for Interface */
     32 #define BCM_TIME_HEARTBEAT      0x00000100 /* To set the heartbeat frequency for
     33                                               Interface */
     34 #define BCM_TIME_LOCKED         0x00000200 /* To indicate that interface is
     35                                               locked on a grand master's clock */
     36 #define BCM_TIME_REF_CLOCK      0x00000400 /* Enable Reference clock */
     37 #define BCM_TIME_SYNC_STAMPER   0x00000800 /* Enable BroadSync timestamper sync
     38                                               support */
     39 #define BCM_TIME_NTP_OFFSET     0x000001000 /* To set/get the ntp offset
     40                                               parameter for Interface */
     41 #define BCM_TIME_BS_TIME        0x000002000 /* set UTC time or system time for
     42                                               BroadSync Master */
     43 
     44 /* BroadSync Time Source Status. */
     45 typedef enum bcm_bs_time_source_e {
     46     bcmBsTimeSourceNotLocked = 0,       /* No time-code received, Holdover mode
     47                                            or Not Locked */
     48     bcmBsTimeSourceAcquiring = 1,       /* Acquiring state */
     49     bcmBsTimeSourceExcessiveJitter = 2, /* Acquiring state but locked with
     50                                            excessive jitter */
     51     bcmBsTimeSourceLocked = 3           /* Locked State */
     52 } bcm_bs_time_source_t;
     53 
     54 /* Base time structure. */
     55 typedef struct bcm_time_interface_s {
     56     uint32 flags;                   /* Flags BCM_TIME_* */
     57     bcm_time_if_t id;               /* Time Interface Identifier */
     58     bcm_time_spec_t drift;          /* Drift amount per 1 Sec */
     59     bcm_time_spec_t offset;         /* Offset */
     60     bcm_time_spec_t accuracy;       /* Accuracy */
     61     int heartbeat_hz;               /* HeartBeat Rate */
     62     int clk_resolution;             /* Reference clock resolution in nsecs */
     63     int bitclock_hz;                /* BitClock frequency */
     64     bcm_bs_time_source_t status;    /* BroadSync Time Source Status */
     65     bcm_time_spec_t ntp_offset;     /* NTP Offset */
     66     bcm_time_spec_t bs_time;        /* UTC time or system time for BroadSync
     67                                        Master */
     68 } bcm_time_interface_t;
     69 
     70 #define BCM_TIME_CAPTURE_LOCKED             0x00000001 /* Captured Time is
     71                                                           synchronized with
     72                                                           Grand Master */
     73 #define BCM_TIME_CAPTURE_GPIO_0             0x00000002 /* Capture Time at rising
     74                                                           edge of GPIO 0 */
     75 #define BCM_TIME_CAPTURE_GPIO_1             0x00000004 /* Capture Time at rising
     76                                                           edge of GPIO 1 */
     77 #define BCM_TIME_CAPTURE_GPIO_2             0x00000008 /* Capture Time at rising
     78                                                           edge of GPIO 2 */
     79 #define BCM_TIME_CAPTURE_GPIO_3             0x00000010 /* Capture Time at rising
     80                                                           edge of GPIO 3 */
     81 #define BCM_TIME_CAPTURE_GPIO_4             0x00000020 /* Capture Time at rising
     82                                                           edge of GPIO 4 */
     83 #define BCM_TIME_CAPTURE_GPIO_5             0x00000040 /* Capture Time at rising
     84                                                           edge of GPIO 5 */
     85 #define BCM_TIME_CAPTURE_L1_CLOCK_PRIMARY   0x00000080 /* Capture Time at rising
     86                                                           edge of primary L1 */
     87 #define BCM_TIME_CAPTURE_L1_CLOCK_SECONDARY 0x00000100 /* Capture Time at rising
     88                                                           edge of primary L2 */
     89 #define BCM_TIME_CAPTURE_LCPLL              0x00000200 /* Capture Time at rising
     90                                                           edge of LCPLL */
     91 #define BCM_TIME_CAPTURE_IP_DM_0            0x00000400 /* Capture Time at rising
     92                                                           edge of DM0 */
     93 #define BCM_TIME_CAPTURE_IP_DM_1            0x00000800 /* Capture Time at rising
     94                                                           edge of DM1 */
     95 #define BCM_TIME_CAPTURE_IMMEDIATE          0x00001000 /* Capture Immediate */
     96 #define BCM_TIME_CAPTURE_ALL                0x00002000 /* Capture Immediate */
     97 #define BCM_TIME_CAPTURE_BS0HB              0x00004000 /* Capture Time at rising
     98                                                           edge of BroadSync 0 */
     99 #define BCM_TIME_CAPTURE_BS1HB              0x00008000 /* Capture Time at rising
    100                                                           edge of BroadSync 1 */
    101 #define BCM_TIME_CAPTURE_TS1TS              0x00010000 /* Capture Time of TS1
    102                                                           event */
    103 #define BCM_TIME_CAPTURE_BS0PLL             0x00020000 /* Capture Time of rising
    104                                                           edge of BroadSync0 PL */
    105 #define BCM_TIME_CAPTURE_BS1PLL             0x00040000 /* Capture Time of rising
    106                                                           edge of  BroadSync1 PL */
    107 #define BCM_TIME_CAPTURE_RSVD1IF            0x00080000 /* Capture Time of rising
    108                                                           edge of  RSVD1
    109                                                           interfac */
    110 #define BCM_TIME_CAPTURE_RSVD1RF            0x00100000 /* Capture Time of rising
    111                                                           edge of  RSVD2 counte */
    112 #define BCM_TIME_CAPTURE_BS0CONVTC          0x00200000 /* Capture Time of
    113                                                           BroadSync0 converted
    114                                                           timecode */
    115 #define BCM_TIME_CAPTURE_BS1CONVTC          0x00400000 /* Capture Time of
    116                                                           BroadSync1 converted
    117                                                           timecod */
    118 #define BCM_TIME_CAPTURE_LCPLL1             0x00800000 /* Capture Time at rising
    119                                                           edge of LCPLL1 */
    120 #define BCM_TIME_CAPTURE_LCPLL2             0x01000000 /* Capture Time at rising
    121                                                           edge of LCPLL2 */
    122 #define BCM_TIME_CAPTURE_LCPLL3             0x02000000 /* Capture Time at rising
    123                                                           edge of LCPLL3 */
    124 #define BCM_TIME_CAPTURE_PORT               0x04000000 /* Capture Time at port */
    125 
    126 /* Time port events */
    127 typedef enum bcm_time_port_event_e {
    128     bcmTimePortEventRXSOF = 0,  /* CPRI port recieve SOF input event */
    129     bcmTimePortEventTXSOF = 1,  /* CPRI port transmit SOF input event */
    130     bcmTimePortEventROE = 2,    /* CPRI ROE timestamp event */
    131     bcmTimePortEventRXCDR = 3,  /* Port recieve CDR event */
    132     bcmTimePortEventTXPI = 4    /* Port TXPI event */
    133 } bcm_time_port_event_t;
    134 
    135 /* Base time capture structure. */
    136 typedef struct bcm_time_capture_s {
    137     uint32 flags;                       /*  Flags BCM_TIME_CAPTURE_* */
    138     bcm_time_spec_t free;               /* Free running clock */
    139     bcm_time_spec_t syntonous;          /* Syntonous clock */
    140     bcm_time_spec_t synchronous;        /* Synchronous clock */
    141     bcm_time_spec_t received;           /* Received clock */
    142     bcm_time_spec_t received_accuracy;  /* Received clock accuracy */
    143     bcm_port_t port;                    /* Port number */
    144     bcm_time_port_event_t port_event_type; /* Port related event type */
    145     uint32 event_divisor;               /* Divisor value for a ts event */
    146     int ts_counter;                     /* Sample on TS0(0), TS1(1) */
    147 } bcm_time_capture_t;
    148 
    149 /* SyncE Clock Source Type. */
    150 typedef enum bcm_time_synce_clock_src_type_e {
    151     bcmTimeSynceClockSourcePrimary = 0, /* Primary Clock Source */
    152     bcmTimeSynceClockSourceSecondary = 1 /* Secondary Clock Source */
    153 } bcm_time_synce_clock_src_type_t;
    154 
    155 /* SyncE Input Source Type. */
    156 typedef enum bcm_time_synce_input_src_type_e {
    157     bcmTimeSynceInputSourceTypePort = 0, /* Input Source Port */
    158     bcmTimeSynceInputSourceTypePLL = 1  /* Input Source PLL */
    159 } bcm_time_synce_input_src_type_t;
    160 
    161 /* SyncE Stage0 Mode. */
    162 typedef enum bcm_time_synce_stage0_mode_e {
    163     bcmTimeSynceModeBypass = 0,     /* Stage0 Mode Bypass */
    164     bcmTimeSynceModeGap45 = 1,      /* Stage0 Mode GAP 4/5 */
    165     bcmTimeSynceModeSDMFracDiv = 2  /* Stage0 Mode SDM Frac Div */
    166 } bcm_time_synce_stage0_mode_t;
    167 
    168 /* bcm_time_synce_stage1_div_e */
    169 typedef enum bcm_time_synce_stage1_div_e {
    170     bcmTimeSynceStage1Div1 = 0, /* Stage1 Div1 */
    171     bcmTimeSynceStage1Div7 = 1, /* Stage1 Div7 */
    172     bcmTimeSynceStage1Div11 = 2 /* Stage1 Div11 */
    173 } bcm_time_synce_stage1_div_t;
    174 
    175 /* Time Synce Divisor setting structure. */
    176 typedef struct bcm_time_synce_divisor_setting_s {
    177     bcm_time_synce_input_src_type_t input_src; /* Input source type */
    178     uint32 index;                       /* Logical port number or PLL index */
    179     bcm_time_synce_stage0_mode_t stage0_mode; /* Stage0 Mode bcmTimeSynceMode* */
    180     uint32 stage0_sdm_whole;            /* Stage0 SDM whole value */
    181     uint32 stage0_sdm_frac;             /* Stage0 SDM frac value */
    182     bcm_time_synce_stage1_div_t stage1_div; /* Stage1 Div bcmTimeSynceStage1Div* */
    183 } bcm_time_synce_divisor_setting_t;
    184 
    185 /* BS log configuration structure. */
    186 typedef struct bcm_time_bs_log_cfg_s {
    187     uint32 debug_mask;      /* mask indicating log level */
    188     uint64 udp_log_mask;    /* mask indicating UDP log level */
    189     bcm_mac_t src_mac;      /* Source MAC address */
    190     bcm_mac_t dest_mac;     /* Destination MAC address */
    191     uint16 tpid;            /* TPID */
    192     uint16 vid;             /* VLAN ID */
    193     uint8 ttl;              /* Time to live */
    194     bcm_ip_t src_addr;      /* Source IP address */
    195     bcm_ip_t dest_addr;     /* Destination IP address */
    196     uint16 udp_port;        /* UDP port number */
    197 } bcm_time_bs_log_cfg_t;
    198 
    199 #define BCM_BS_LOG_NONE         0x00000000 /* BS log level None */
    200 #define BCM_BS_LOG_SYS_INFO     0x00000001 /* BS log level info */
    201 #define BCM_BS_LOG_SYS_WARN     0x00000002 /* BS log level warning */
    202 #define BCM_BS_LOG_SYS_ERR      0x00000004 /* BS log level error */
    203 #define BCM_BS_LOG_SYS_CRIT     0x00000008 /* BS log level critical */
    204 #define BCM_BS_LOG_SYS_ALL      0x000000FF /* BS log level all */
    205 
    206 #ifndef BCM_HIDE_DISPATCHABLE
    207 
    208 /* Configures the BroadSync logging */
    209 extern int bcm_time_bs_log_configure_set(
    210     int unit, 
    211     bcm_time_bs_log_cfg_t bs_log_cfg);
    212 
    213 /* Get the BroadSync logging configuration */
    214 extern int bcm_time_bs_log_configure_get(
    215     int unit, 
    216     bcm_time_bs_log_cfg_t *bs_log_cfg);
    217 
    218 /* Initialize time module. */
    219 extern int bcm_time_init(
    220     int unit);
    221 
    222 /* Uninitialize time module. */
    223 extern int bcm_time_deinit(
    224     int unit);
    225 
    226 #endif /* BCM_HIDE_DISPATCHABLE */
    227 
    228 /* Initialize bcm_time_spec_t structure. */
    229 extern void bcm_time_spec_t_init(
    230     bcm_time_spec_t *spec);
    231 
    232 /* Initialize bcm_time_interface_t structure */
    233 extern void bcm_time_interface_t_init(
    234     bcm_time_interface_t *intf);
    235 
    236 /* Initialize bcm_time_capture_t structure. */
    237 extern void bcm_time_capture_t_init(
    238     bcm_time_capture_t *capture);
    239 
    240 /* Initialize bcm_time_synce_divisor_setting_t structure. */
    241 extern void bcm_time_synce_divisor_setting_t_init(
    242     bcm_time_synce_divisor_setting_t *divisor);
    243 
    244 #ifndef BCM_HIDE_DISPATCHABLE
    245 
    246 /* Creates a Time Synchronization Interface */
    247 extern int bcm_time_interface_add(
    248     int unit, 
    249     bcm_time_interface_t *intf);
    250 
    251 /* Retrieve the Time Synchronization Interface. */
    252 extern int bcm_time_interface_get(
    253     int unit, 
    254     bcm_time_interface_t *intf);
    255 
    256 /* Deletes a Time Synchronization Interface. */
    257 extern int bcm_time_interface_delete(
    258     int unit, 
    259     bcm_time_if_t intf_id);
    260 
    261 /* Removes all interfaces on a given device. */
    262 extern int bcm_time_interface_delete_all(
    263     int unit);
    264 
    265 #endif /* BCM_HIDE_DISPATCHABLE */
    266 
    267 /* bcm_time_interface_traverse_cb */
    268 typedef int (*bcm_time_interface_traverse_cb)(
    269     int unit, 
    270     bcm_time_interface_t *intf, 
    271     void *user_data);
    272 
    273 #ifndef BCM_HIDE_DISPATCHABLE
    274 
    275 /* Iterates over all Time Synchronization Interfaces. */
    276 extern int bcm_time_interface_traverse(
    277     int unit, 
    278     bcm_time_interface_traverse_cb cb, 
    279     void *user_data);
    280 
    281 /* Retrieves time capture from the device. */
    282 extern int bcm_time_capture_get(
    283     int unit, 
    284     bcm_time_if_t intf_id, 
    285     bcm_time_capture_t *time);
    286 
    287 #endif /* BCM_HIDE_DISPATCHABLE */
    288 
    289 /* bcm_time_heartbeat_cb */
    290 typedef int (*bcm_time_heartbeat_cb)(
    291     int unit, 
    292     bcm_time_if_t id, 
    293     bcm_time_capture_t *time, 
    294     void *user_data);
    295 
    296 #ifndef BCM_HIDE_DISPATCHABLE
    297 
    298 /* Register a callback function to be called on each heartbeat. */
    299 extern int bcm_time_heartbeat_register(
    300     int unit, 
    301     bcm_time_if_t id, 
    302     bcm_time_heartbeat_cb f, 
    303     void *user_data);
    304 
    305 /* Unregister a callback function . */
    306 extern int bcm_time_heartbeat_unregister(
    307     int unit, 
    308     bcm_time_if_t id);
    309 
    310 /* 
    311  * Enables/Disables interrupt handling for each heartbeat provided by a
    312  * clock.
    313  */
    314 extern int bcm_time_heartbeat_enable_set(
    315     int unit, 
    316     bcm_time_if_t id, 
    317     int enable);
    318 
    319 /* 
    320  * Retrieves the status of interrupt handling for each heartbeat provided
    321  * by a clock.
    322  */
    323 extern int bcm_time_heartbeat_enable_get(
    324     int unit, 
    325     bcm_time_if_t id, 
    326     int *enable);
    327 
    328 /* Set External time capture modes */
    329 extern int bcm_time_trigger_enable_set(
    330     int unit, 
    331     bcm_time_if_t id, 
    332     uint32 mode_flags);
    333 
    334 /* Get External time capture modes */
    335 extern int bcm_time_trigger_enable_get(
    336     int unit, 
    337     bcm_time_if_t id, 
    338     uint32 *mode_flags);
    339 
    340 /* Get current syncE input divisor settings */
    341 extern int bcm_time_synce_clock_get(
    342     int unit, 
    343     bcm_time_synce_clock_src_type_t clk_src, 
    344     bcm_time_synce_divisor_setting_t *divisor_setting);
    345 
    346 /* Set syncE clock output frequency beased on the input divisor settings. */
    347 extern int bcm_time_synce_clock_set(
    348     int unit, 
    349     bcm_time_synce_clock_src_type_t clk_src, 
    350     bcm_time_synce_divisor_setting_t *divisor_setting);
    351 
    352 #endif /* BCM_HIDE_DISPATCHABLE */
    353 
    354 /* synce clock source config */
    355 typedef struct bcm_time_synce_clock_source_config_s {
    356     bcm_time_synce_clock_src_type_t clk_src; /* SyncE Clock Source Primary or
    357                                            Secondary */
    358     bcm_time_synce_input_src_type_t input_src; /* Input source type Port or PLL */
    359     uint32 pll_index;                   /* PLL index */
    360     bcm_port_t port;                    /* Logical port number */
    361 } bcm_time_synce_clock_source_config_t;
    362 
    363 /* bcm_time_synce_clock_source_control */
    364 typedef enum bcm_time_synce_clock_source_control_e {
    365     bcmTimeSynceClockSourceControlSquelch = 0, /* Squelch of SyncE source */
    366     bcmTimeSynceClockSourceControlFrequency = 1 /* Frequency of SyncE source */
    367 } bcm_time_synce_clock_source_control_t;
    368 
    369 /* SyncE Frequency */
    370 typedef enum bcm_time_synce_frequency_e {
    371     bcmTimeSyncE23MHz = 1,  /* TSCF - 23.4375 MHz */
    372     bcmTimeSyncE25MHz = 2,  /* SDM - 25MHz */
    373     bcmTimeSyncE28MHz = 3,  /* General - 28.4 MHz */
    374     bcmTimeSyncE46MHz = 4,  /* General - 46.875 MHz */
    375     bcmTimeSyncE125MHz = 5, /* General - 125MHz */
    376     bcmTimeSyncE515MHz = 6, /* General - 515.625MHz */
    377     bcmTimeSyncE7MHz = 7,   /* SDM - 7.8125 MHz */
    378     bcmTimeSyncE12MHz = 8,  /* SDM - 12.5 MHz */
    379     bcmTimeSyncE31MHz = 9,  /* SDM - 31.25 MHz */
    380     bcmTimeSyncE37MHz = 10, /* SDM - 37.5 MHz */
    381     bcmTimeSyncE156MHz = 11 /* General - 156.25 MHz */
    382 } bcm_time_synce_frequency_t;
    383 
    384 #ifndef BCM_HIDE_DISPATCHABLE
    385 
    386 /* Configure Primary or Secondary SyncE Recovered clock. */
    387 extern int bcm_time_synce_clock_source_control_set(
    388     int unit, 
    389     bcm_time_synce_clock_source_config_t *clk_src_config, 
    390     bcm_time_synce_clock_source_control_t control, 
    391     int value);
    392 
    393 /* Configure Primary or Secondary SyncE Recovered clock. */
    394 extern int bcm_time_synce_clock_source_control_get(
    395     int unit, 
    396     bcm_time_synce_clock_source_config_t *clk_src_config, 
    397     bcm_time_synce_clock_source_control_t control, 
    398     int *value);
    399 
    400 /* Retrieves broadsync time from device */
    401 extern int bcm_time_bs_time_get(
    402     int unit, 
    403     bcm_time_spec_t *bs_time);
    404 
    405 #endif /* BCM_HIDE_DISPATCHABLE */
    406 
    407 /* Time formats */
    408 typedef enum bcm_time_format_e {
    409     bcmTimeFormatPTP = 0,   /* The time format is PTP. */
    410     bcmTimeFormatNTP = 1    /* The time format is NTP. */
    411 } bcm_time_format_t;
    412 
    413 /* values to set initial counter in ts clock. */
    414 typedef struct bcm_time_ts_counter_s {
    415     bcm_time_format_t time_format;  /* Time format for counter */
    416     int enable;                     /* Enable/disable control for counter. */
    417     int ts_counter;                 /* TS0/TS1 counter. */
    418     uint64 ts_counter_ns;           /* nanosecond value of counter. */
    419 } bcm_time_ts_counter_t;
    420 
    421 /* Initialize counter structure for timestamping. */
    422 extern void bcm_time_ts_counter_t_init(
    423     bcm_time_ts_counter_t *counter);
    424 
    425 #ifndef BCM_HIDE_DISPATCHABLE
    426 
    427 /* Set counter values for timestamping. */
    428 extern int bcm_time_ts_counter_set(
    429     int unit, 
    430     bcm_time_ts_counter_t *counter);
    431 
    432 /* Set counter values for timestamping. */
    433 extern int bcm_time_ts_counter_get(
    434     int unit, 
    435     bcm_time_ts_counter_t *counter);
    436 
    437 #endif /* BCM_HIDE_DISPATCHABLE */
    438 
    439 /* Time stamping stages. */
    440 #define BCM_TIME_STAGE_INGRESS_FLOWTRACKER  (1U << 0)  /* Ingress Flowtracker
    441                                                           stage for time
    442                                                           stamping. */
    443 #define BCM_TIME_STAGE_EGRESS               (1U << 1)  /* Egress stage for time
    444                                                           stamping. */
    445 #define BCM_TIME_STAGE_LIVE_WIRE_PTP        (1U << 2)  /* Live wire timestamping
    446                                                           in PTP format. */
    447 #define BCM_TIME_STAGE_LIVE_WIRE_NTP        (1U << 3)  /* Live wire timestamping
    448                                                           in NTP format. */
    449 #define BCM_TIME_STAGE_MMU                  (1U << 4)  /* MMU stage for time
    450                                                           stamping. */
    451 #define BCM_TIME_STAGE_ALL                  (1U << 31) /* Timestamping will be
    452                                                           applied to all the
    453                                                           stages. */
    454 
    455 /* Structure for Time of the day values. */
    456 typedef struct bcm_time_tod_s {
    457     int auto_update;                    /* Enable ToD automatic update. */
    458     bcm_time_format_t time_format;      /* Time format for counter. */
    459     bcm_time_spec_t ts;                 /* time of the day values. */
    460     uint64 ts_adjustment_counter_ns;    /* tod value adjustment in nanoseconds. */
    461 } bcm_time_tod_t;
    462 
    463 /* Initialize tod structure for timestamping. */
    464 extern void bcm_time_tod_t_init(
    465     bcm_time_tod_t *tod);
    466 
    467 #ifndef BCM_HIDE_DISPATCHABLE
    468 
    469 /* Set time of the day values at various stages in ASIC. */
    470 extern int bcm_time_tod_set(
    471     int unit, 
    472     uint32 stages, 
    473     bcm_time_tod_t *tod);
    474 
    475 /* Get time of the day values at various stages in ASIC. */
    476 extern int bcm_time_tod_get(
    477     int unit, 
    478     uint32 stages, 
    479     bcm_time_tod_t *tod);
    480 
    481 #endif /* BCM_HIDE_DISPATCHABLE */
    482 
    483 /* Time capture callback types */
    484 typedef enum bcm_time_capture_cb_type_e {
    485     bcmTimeCaptureOverflow = 0,         /* Cb will be called only on overflow */
    486     bcmTimeCapturetFill = 1,            /* Cb will be called only for ts events */
    487     bcmTimeCaptureAll = 2,              /* Cb will be called for both overflow
    488                                            and ts events */
    489     bcmTimeCaptureTS0CntOffsetUpdated = 3, /* Cb will be called when TS0 phase
    490                                            offset gets applied */
    491     bcmTimeCaptureTS1CntOffsetUpdated = 4 /* Cb will be called when TS1 phase
    492                                            offset gets applied */
    493 } bcm_time_capture_cb_type_t;
    494 
    495 #ifndef BCM_HIDE_DISPATCHABLE
    496 
    497 /* Enable/Disable FIFO timestamp capture for a particular event */
    498 extern int bcm_time_capture_enable_set(
    499     int unit, 
    500     bcm_time_if_t id, 
    501     bcm_time_capture_t *time_capture, 
    502     int enable, 
    503     int *capture_handle);
    504 
    505 #endif /* BCM_HIDE_DISPATCHABLE */
    506 
    507 /* Generic callback for time capture events */
    508 typedef int (*bcm_time_capture_cb)(
    509     int unit, 
    510     void *user_data, 
    511     uint32 *cb_data, 
    512     bcm_time_capture_cb_type_t cb_status);
    513 
    514 #ifndef BCM_HIDE_DISPATCHABLE
    515 
    516 /* Register callback function for a given type */
    517 extern int bcm_time_capture_cb_register(
    518     int unit, 
    519     bcm_time_if_t id, 
    520     bcm_time_capture_cb_type_t cb_type, 
    521     bcm_time_capture_cb cb, 
    522     void *user_data);
    523 
    524 /* Un-register callback function for a given time event type */
    525 extern int bcm_time_capture_cb_unregister(
    526     int unit, 
    527     bcm_time_if_t id, 
    528     bcm_time_capture_cb_type_t cb_type);
    529 
    530 /* Set counter values for timestamping. */
    531 extern int bcm_time_ts_offset_set(
    532     int unit, 
    533     int64 ts_offset, 
    534     uint64 ts_update_intv, 
    535     int ts_counter);
    536 
    537 /* Function to reset and enable time counter and timestamp pair */
    538 extern int bcm_time_ts_counter_time_init(
    539     int unit);
    540 
    541 /* Function to periodically to update the 80bit/48bit timestamp pair */
    542 extern int bcm_time_ts_time_update(
    543     int unit);
    544 
    545 /* Function to convert 32bit timestamp to 80bit tod */
    546 extern int bcm_time_ts_time_convert(
    547     int unit, 
    548     uint32 ts_val, 
    549     bcm_time_spec_t *time);
    550 
    551 #endif /* BCM_HIDE_DISPATCHABLE */
    552 
    553 #endif /* __BCM_TIME_H__ */