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

link.h (4612B)


      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_LINK_H__
     11 #define __BCM_LINK_H__
     12 
     13 #include <bcm/types.h>
     14 #include <bcm/port.h>
     15 
     16 /* bcm_linkscan_handler_t */
     17 typedef void (*bcm_linkscan_handler_t)(
     18     int unit, 
     19     bcm_port_t port, 
     20     bcm_port_info_t *info);
     21 
     22 /* bcm_linkscan_port_handler_t */
     23 typedef int (*bcm_linkscan_port_handler_t)(
     24     int unit, 
     25     bcm_port_t port, 
     26     int *state);
     27 
     28 #ifndef BCM_HIDE_DISPATCHABLE
     29 
     30 /* Initialize the link scanning subsystem. */
     31 extern int bcm_linkscan_init(
     32     int unit);
     33 
     34 /* Terminate linkscan on the specified unit. */
     35 extern int bcm_linkscan_detach(
     36     int unit);
     37 
     38 #endif /* BCM_HIDE_DISPATCHABLE */
     39 
     40 #define BCM_LINKSCAN_INTERVAL_MIN   10000      
     41 
     42 #define BCM_LINKSCAN_INTERVAL_DEFAULT   250000     
     43 
     44 #ifndef BCM_HIDE_DISPATCHABLE
     45 
     46 /* Enable and disable link scanning or set the polling interval. */
     47 extern int bcm_linkscan_enable_set(
     48     int unit, 
     49     int us);
     50 
     51 /* Enable and disable link scanning or set the polling interval. */
     52 extern int bcm_linkscan_enable_get(
     53     int unit, 
     54     int *us);
     55 
     56 /* Retrieve if linkscan managing a specified port. */
     57 extern int bcm_linkscan_enable_port_get(
     58     int unit, 
     59     bcm_port_t port);
     60 
     61 #endif /* BCM_HIDE_DISPATCHABLE */
     62 
     63 /* bcm_linkscan_mode_e */
     64 typedef enum bcm_linkscan_mode_e {
     65     BCM_LINKSCAN_MODE_NONE     = 0, 
     66     BCM_LINKSCAN_MODE_SW       = 1, 
     67     BCM_LINKSCAN_MODE_HW       = 2, 
     68     BCM_LINKSCAN_MODE_OVERRIDE = 3, 
     69     BCM_LINKSCAN_MODE_COUNT    = 4 
     70 } bcm_linkscan_mode_t;
     71 
     72 #ifndef BCM_HIDE_DISPATCHABLE
     73 
     74 /* Get or set the link scanning mode for a port. */
     75 extern int bcm_linkscan_mode_set(
     76     int unit, 
     77     bcm_port_t port, 
     78     int mode);
     79 
     80 /* Get or set the link scanning mode for a port. */
     81 extern int bcm_linkscan_mode_set_pbm(
     82     int unit, 
     83     bcm_pbmp_t pbm, 
     84     int mode);
     85 
     86 /* Get or set the link scanning mode for a port. */
     87 extern int bcm_linkscan_mode_get(
     88     int unit, 
     89     bcm_port_t port, 
     90     int *mode);
     91 
     92 /* Register and unregister link notification callouts. */
     93 extern int bcm_linkscan_register(
     94     int unit, 
     95     bcm_linkscan_handler_t f);
     96 
     97 /* Register and unregister link notification callouts. */
     98 extern int bcm_linkscan_unregister(
     99     int unit, 
    100     bcm_linkscan_handler_t f);
    101 
    102 /* Register and unregister link status callout. */
    103 extern int bcm_linkscan_port_register(
    104     int unit, 
    105     bcm_port_t port, 
    106     bcm_linkscan_port_handler_t f);
    107 
    108 /* Register and unregister link status callout. */
    109 extern int bcm_linkscan_port_unregister(
    110     int unit, 
    111     bcm_port_t port, 
    112     bcm_linkscan_port_handler_t f);
    113 
    114 /* Wait for a set of links to recognize link up. */
    115 extern int bcm_link_wait(
    116     int unit, 
    117     bcm_pbmp_t *pbm, 
    118     int us);
    119 
    120 /* Force a transient link down event on a port. */
    121 extern int bcm_link_change(
    122     int unit, 
    123     bcm_pbmp_t pbmp);
    124 
    125 /* Check for a change in link status on each link. */
    126 extern int bcm_linkscan_update(
    127     int unit, 
    128     bcm_pbmp_t pbm);
    129 
    130 #if defined(BROADCOM_DEBUG)
    131 /* Display information about linkscan callbacks. */
    132 extern int bcm_linkscan_dump(
    133     int unit);
    134 #endif
    135 
    136 #endif /* BCM_HIDE_DISPATCHABLE */
    137 
    138 /* bcm_linkscan_trigger_event_e */
    139 typedef enum bcm_linkscan_trigger_event_e {
    140     BCM_LINKSCAN_TRIGGER_EVENT_FAULT = 0, /* Trigger only link remote fault
    141                                            checking in Linkscan thread. */
    142     BCM_LINKSCAN_TRIGGER_EVENT_REMOTE_FAULT = BCM_LINKSCAN_TRIGGER_EVENT_FAULT, /* Trigger link remote fault checking. */
    143     BCM_LINKSCAN_TRIGGER_EVENT_LOCAL_FAULT = 1 /* Trigger link local fault checking. */
    144 } bcm_linkscan_trigger_event_t;
    145 
    146 #ifndef BCM_HIDE_DISPATCHABLE
    147 
    148 /* Get/set the link event from/to Linkscan function. */
    149 extern int bcm_linkscan_trigger_event_set(
    150     int unit, 
    151     bcm_port_t port, 
    152     uint32 flags, 
    153     bcm_linkscan_trigger_event_t trigger_event, 
    154     int enable);
    155 
    156 /* Get/set the link event from/to Linkscan function. */
    157 extern int bcm_linkscan_trigger_event_get(
    158     int unit, 
    159     bcm_port_t port, 
    160     uint32 flags, 
    161     bcm_linkscan_trigger_event_t trigger_event, 
    162     int *enable);
    163 
    164 /* Get/set the override link state for the specified port. */
    165 extern int bcm_linkscan_override_link_state_set(
    166     int unit, 
    167     bcm_port_t port, 
    168     int link);
    169 
    170 /* Get/set the override link state for the specified port. */
    171 extern int bcm_linkscan_override_link_state_get(
    172     int unit, 
    173     bcm_port_t port, 
    174     int *link);
    175 
    176 #endif /* BCM_HIDE_DISPATCHABLE */
    177 
    178 #endif /* __BCM_LINK_H__ */