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

stack.h (16923B)


      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_STACK_H__
     11 #define __BCM_STACK_H__
     12 
     13 #include <bcm/types.h>
     14 
     15 #define BCM_STK_MAX_MODULES                 (72)       /* Maximum number of
     16                                                           modules in stack. */
     17 #define BCM_STK_MODULE_MAX_ALL_REACHABLE    (0x1)      /* All Reachable flag for
     18                                                           stack module max. */
     19 
     20 /* module protocols indicate module communication types */
     21 typedef enum bcm_module_protocol_e {
     22     bcmModuleProtocolNone = 1, 
     23     bcmModuleProtocol1 = 2,         /* QE20 protocol - plane A */
     24     bcmModuleProtocol2 = 3,         /* QE20 protocol - plane B */
     25     bcmModuleProtocol3 = 4,         /* QE40 protocol - A/B */
     26     bcmModuleProtocol4 = 5,         /* QE40 protocol - A fic B local */
     27     bcmModuleProtocol5 = 6,         /* QE40 protocol - A fic */
     28     bcmModuleProtocolCustom1 = 7    /* Custom Device Protocol - A/B */
     29 } bcm_module_protocol_t;
     30 
     31 /* bcm_stk_module_control_t */
     32 typedef enum bcm_stk_module_control_e {
     33     bcmStkModuleAllReachableIgnore = 0, /* Ignore a MODULE ID during all
     34                                            reachable vector calculation */
     35     bcmStkModuleMHPriorityUse = 1       /* Use the Priority/Color from the
     36                                            Module Header */
     37 } bcm_stk_module_control_t;
     38 
     39 #ifndef BCM_HIDE_DISPATCHABLE
     40 
     41 /* Initialize the Stack Control subsystem. */
     42 extern int bcm_stk_init(
     43     int unit);
     44 
     45 /* Gets the list of ports currently in SL stack mode. */
     46 extern int bcm_stk_pbmp_get(
     47     int unit, 
     48     bcm_pbmp_t *cur_pbm, 
     49     bcm_pbmp_t *inactive_pbm);
     50 
     51 /* Set/Get SL stack flags for a port. */
     52 extern int bcm_stk_port_set(
     53     int unit, 
     54     bcm_port_t port, 
     55     uint32 flags);
     56 
     57 /* Set/Get SL stack flags for a port. */
     58 extern int bcm_stk_port_get(
     59     int unit, 
     60     bcm_port_t port, 
     61     uint32 *flags);
     62 
     63 #endif /* BCM_HIDE_DISPATCHABLE */
     64 
     65 /* bcm_stk_update_callback function */
     66 typedef void (*bcm_stk_cb_f)(
     67     int unit, 
     68     bcm_port_t port, 
     69     uint32 flags, 
     70     void *cookie);
     71 
     72 #ifndef BCM_HIDE_DISPATCHABLE
     73 
     74 /* Register a function for stack port updates. */
     75 extern int bcm_stk_update_callback_register(
     76     int unit, 
     77     bcm_stk_cb_f cb, 
     78     void *cookie);
     79 
     80 /* Unregister a function for stack port updates. */
     81 extern int bcm_stk_update_callback_unregister(
     82     int unit, 
     83     bcm_stk_cb_f cb, 
     84     void *cookie);
     85 
     86 #endif /* BCM_HIDE_DISPATCHABLE */
     87 
     88 /* Flags for bcm_stk_port_set/get. */
     89 #define BCM_STK_CAPABLE         0x00000001 /* The port is stack capable, but may
     90                                               not be stacked currently (e.g.
     91                                               Dynamic SL front panel). */
     92 #define BCM_STK_ENABLE          0x00000002 /* The port is in stacking mode. */
     93 #define BCM_STK_INACTIVE        0x00000004 /* Explicitly set inactive to avoid
     94                                               undirected traffic to flow on this
     95                                               link. */
     96 #define BCM_STK_DUPLEX          0x00000008 /* This is a duplex connection. */
     97 #define BCM_STK_SIMPLEX         0x00000010 /* This is a simplex connection
     98                                               (exclusive to _DUPLEX) */
     99 #define BCM_STK_NONE            0x00000020 /* Not a stackable port (currently
    100                                               ignored). */
    101 #define BCM_STK_SL              0x00000040 /* Port is an SL (front panel) stack
    102                                               port (currently ignored). */
    103 #define BCM_STK_HG              0x00000080 /* Port is a HiGig stack port
    104                                               (currently ignored). */
    105 #define BCM_STK_INTERNAL        0x00000100 /* Port is an on-board device
    106                                               connection (set only; currently
    107                                               ignored). */
    108 #define BCM_STK_NO_LINK         0x00000200 /* Port does not have link. Not
    109                                               recorded; provided for callbacks.
    110                                               (set only; currently ignored). */
    111 #define BCM_STK_CUT             0x00000400 /* Port is a "cut" port that blocks
    112                                               multicast and broadcast traffic.
    113                                               (currently ignored). */
    114 #define BCM_STK_FLAGS_MASK      0x000007ff 
    115 
    116 #define BCM_STK_FLAGS_STR       \
    117 { \
    118     "capable", \
    119     "enable", \
    120     "inactive", \
    121     "duplex", \
    122     "simplex", \
    123     "none", \
    124     "sl", \
    125     "hg", \
    126     "internal", \
    127     "no_link", \
    128     "cut", \
    129     "" \
    130 } 
    131 
    132 /* bcm_stk_flags_str */
    133 extern char *bcm_stk_flags_str[];
    134 
    135 /* 
    136  * Pass this as the port parameter to set/get to use the unique IPIC_PORT
    137  * if present.
    138  */
    139 #define BCM_STK_USE_HG_IF       -1         
    140 
    141 #ifndef BCM_HIDE_DISPATCHABLE
    142 
    143 /* Set/Get SL stack mode status */
    144 extern int bcm_stk_mode_set(
    145     int unit, 
    146     uint32 flags);
    147 
    148 /* Set/Get SL stack mode status. */
    149 extern int bcm_stk_mode_get(
    150     int unit, 
    151     uint32 *flags);
    152 
    153 /* Get or set the module ID of the local device. */
    154 extern int bcm_stk_my_modid_set(
    155     int unit, 
    156     int my_modid);
    157 
    158 /* Get or set the module ID of the local device. */
    159 extern int bcm_stk_my_modid_get(
    160     int unit, 
    161     int *my_modid);
    162 
    163 /* Get or set the module ID of the local device. */
    164 extern int bcm_stk_modid_set(
    165     int unit, 
    166     int modid);
    167 
    168 /* Get or set the module ID of the local device. */
    169 extern int bcm_stk_modid_get(
    170     int unit, 
    171     int *modid);
    172 
    173 #endif /* BCM_HIDE_DISPATCHABLE */
    174 
    175 /* module ID types */
    176 typedef enum bcm_stk_modid_type_e {
    177     bcmStkModidTypePrimary = 0,         /* primary module IDs */
    178     bcmStkModidTypeMultiNextHops = 1,   /* multiple next hops module IDs */
    179     bcmStkModidTypeCoe = 2              /* COE module IDs */
    180 } bcm_stk_modid_type_t;
    181 
    182 /* Structure for the configuration of the module. */
    183 typedef struct bcm_stk_modid_config_s {
    184     uint32 flags; 
    185     int modid; 
    186     int num_ports; 
    187     bcm_stk_modid_type_t modid_type; 
    188     int num_mods; 
    189 } bcm_stk_modid_config_t;
    190 
    191 /* Initialize a bcm_stk_modid_config_t structure. */
    192 extern void bcm_stk_modid_config_t_init(
    193     bcm_stk_modid_config_t *pconfig);
    194 
    195 #ifndef BCM_HIDE_DISPATCHABLE
    196 
    197 /* Sets/Gets the module id. */
    198 extern int bcm_stk_modid_config_set(
    199     int unit, 
    200     bcm_stk_modid_config_t *modid);
    201 
    202 /* Sets/Gets the module id. */
    203 extern int bcm_stk_modid_config_get(
    204     int unit, 
    205     bcm_stk_modid_config_t *modid);
    206 
    207 /* Adds a desired module local to the system. */
    208 extern int bcm_stk_modid_config_add(
    209     int unit, 
    210     bcm_stk_modid_config_t *modid);
    211 
    212 /* Deletes a desired module that is local to the system. */
    213 extern int bcm_stk_modid_config_delete(
    214     int unit, 
    215     bcm_stk_modid_config_t *modid);
    216 
    217 /* Deletes all modules added local to the system. */
    218 extern int bcm_stk_modid_config_delete_all(
    219     int unit);
    220 
    221 /* Gets all modules added local to the system. */
    222 extern int bcm_stk_modid_config_get_all(
    223     int unit, 
    224     int modid_max, 
    225     bcm_stk_modid_config_t *modid_array, 
    226     int *modid_count);
    227 
    228 /* Number of module identifiers used by device */
    229 extern int bcm_stk_modid_count(
    230     int unit, 
    231     int *num_modid);
    232 
    233 /* Control module steering. */
    234 extern int bcm_stk_modport_set(
    235     int unit, 
    236     int modid, 
    237     int port);
    238 
    239 /* Control module steering. */
    240 extern int bcm_stk_modport_get(
    241     int unit, 
    242     int modid, 
    243     int *port);
    244 
    245 /* Get module steering */
    246 extern int bcm_stk_modport_get_all(
    247     int unit, 
    248     int modid, 
    249     int port_max, 
    250     int *port_array, 
    251     int *port_count);
    252 
    253 /* Clear module steering. */
    254 extern int bcm_stk_modport_clear(
    255     int unit, 
    256     int modid);
    257 
    258 /* Clear module steering. */
    259 extern int bcm_stk_modport_clear_all(
    260     int unit);
    261 
    262 /* Add or delete more than one path for a given destination module. */
    263 extern int bcm_stk_modport_add(
    264     int unit, 
    265     int modid, 
    266     bcm_port_t port);
    267 
    268 /* Add or delete more than one path for a given destination module. */
    269 extern int bcm_stk_modport_delete(
    270     int unit, 
    271     int modid, 
    272     bcm_port_t port);
    273 
    274 /* Control per ingress port module steering. */
    275 extern int bcm_stk_port_modport_set(
    276     int unit, 
    277     bcm_port_t ing_port, 
    278     bcm_module_t dest_modid, 
    279     bcm_port_t dest_port);
    280 
    281 /* 
    282  * Get a destination path for a given destination module of the ingress
    283  * port.
    284  */
    285 extern int bcm_stk_port_modport_get(
    286     int unit, 
    287     bcm_port_t ing_port, 
    288     bcm_module_t dest_modid, 
    289     bcm_port_t *dest_port);
    290 
    291 /* Get per ingress port module steering */
    292 extern int bcm_stk_port_modport_get_all(
    293     int unit, 
    294     bcm_port_t ing_port, 
    295     bcm_module_t dest_modid, 
    296     int dest_port_max, 
    297     bcm_port_t *dest_port_array, 
    298     int *dest_port_count);
    299 
    300 /* Clear per ingress port module steering. */
    301 extern int bcm_stk_port_modport_clear(
    302     int unit, 
    303     bcm_port_t ing_port, 
    304     bcm_module_t dest_modid);
    305 
    306 /* 
    307  * Clear destination paths for all destination modules of the ingress
    308  * port.
    309  */
    310 extern int bcm_stk_port_modport_clear_all(
    311     int unit, 
    312     bcm_port_t ing_port);
    313 
    314 /* 
    315  * Add or delete more than one path for a given destination module of an
    316  *     ingress port.
    317  */
    318 extern int bcm_stk_port_modport_add(
    319     int unit, 
    320     bcm_port_t ing_port, 
    321     bcm_module_t dest_modid, 
    322     bcm_port_t dest_port);
    323 
    324 /* Delete one path for a given destination module of the ingress port. */
    325 extern int bcm_stk_port_modport_delete(
    326     int unit, 
    327     bcm_port_t ing_port, 
    328     bcm_module_t dest_modid, 
    329     bcm_port_t dest_port);
    330 
    331 /* Set, get, or delete Fabric unicast table entries. */
    332 extern int bcm_stk_ucbitmap_set(
    333     int unit, 
    334     int port, 
    335     int modid, 
    336     bcm_pbmp_t pbmp);
    337 
    338 /* Set, get, or delete Fabric unicast table entries. */
    339 extern int bcm_stk_ucbitmap_get(
    340     int unit, 
    341     int port, 
    342     int modid, 
    343     bcm_pbmp_t *pbmp);
    344 
    345 /* Set, get, or delete Fabric unicast table entries. */
    346 extern int bcm_stk_ucbitmap_del(
    347     int unit, 
    348     bcm_port_t port, 
    349     int modid, 
    350     bcm_pbmp_t pbmp);
    351 
    352 /* Set or get a fabric mapping between fabric and local space. */
    353 extern int bcm_stk_fmod_lmod_mapping_set(
    354     int unit, 
    355     bcm_port_t port, 
    356     bcm_module_t fmod, 
    357     bcm_module_t lmod);
    358 
    359 /* Set or get a fabric mapping between fabric and local space. */
    360 extern int bcm_stk_fmod_lmod_mapping_get(
    361     int unit, 
    362     bcm_port_t port, 
    363     bcm_module_t *fmod, 
    364     bcm_module_t *lmod);
    365 
    366 /* Set or get a fabric mapping between fabric and switch space. */
    367 extern int bcm_stk_fmod_smod_mapping_set(
    368     int unit, 
    369     bcm_port_t port, 
    370     bcm_module_t fmod, 
    371     bcm_module_t smod, 
    372     bcm_port_t sport, 
    373     uint32 nports);
    374 
    375 /* Set or get a fabric mapping between fabric and switch space. */
    376 extern int bcm_stk_fmod_smod_mapping_get(
    377     int unit, 
    378     bcm_port_t port, 
    379     bcm_module_t fmod, 
    380     bcm_module_t *smod, 
    381     bcm_port_t *sport, 
    382     uint32 *nports);
    383 
    384 /* Assign or get fabric port to a module mapping group. */
    385 extern int bcm_stk_port_modmap_group_set(
    386     int unit, 
    387     bcm_port_t port, 
    388     int group);
    389 
    390 /* Assign or get fabric port to a module mapping group. */
    391 extern int bcm_stk_port_modmap_group_get(
    392     int unit, 
    393     bcm_port_t port, 
    394     int *group);
    395 
    396 /* Retrieve the maximum module mapping group on a fabric. */
    397 extern int bcm_stk_port_modmap_group_max_get(
    398     int unit, 
    399     int *max_group);
    400 
    401 /* Enable/Disable or get module mapping on a fabric port. */
    402 extern int bcm_stk_modmap_enable_set(
    403     int unit, 
    404     bcm_port_t port, 
    405     int enable);
    406 
    407 /* Enable/Disable or get module mapping on a fabric port. */
    408 extern int bcm_stk_modmap_enable_get(
    409     int unit, 
    410     bcm_port_t port, 
    411     int *enable);
    412 
    413 #endif /* BCM_HIDE_DISPATCHABLE */
    414 
    415 /* Switch module mapping. */
    416 #define BCM_STK_MODMAP_SET      1          /* Global to local. */
    417 #define BCM_STK_MODMAP_GET      2          /* Local to global. */
    418 
    419 /* bcm_stk_modmap_cb_t */
    420 typedef int (*bcm_stk_modmap_cb_t)(
    421     int unit, 
    422     int setget, 
    423     bcm_module_t mod_in, 
    424     bcm_port_t port_in, 
    425     bcm_module_t *mod_out, 
    426     bcm_port_t *port_out);
    427 
    428 #ifndef BCM_HIDE_DISPATCHABLE
    429 
    430 /* Register a Module Mapping callback. */
    431 extern int bcm_stk_modmap_register(
    432     int unit, 
    433     bcm_stk_modmap_cb_t func);
    434 
    435 /* Register a Module Mapping callback. */
    436 extern int bcm_stk_modmap_unregister(
    437     int unit);
    438 
    439 /* Map or unmap a module identifier. */
    440 extern int bcm_stk_modmap_map(
    441     int unit, 
    442     int setget, 
    443     bcm_module_t mod_in, 
    444     bcm_port_t port_in, 
    445     bcm_module_t *mod_out, 
    446     bcm_port_t *port_out);
    447 
    448 /* Enable or disable a module and specify number of ports. */
    449 extern int bcm_stk_module_enable(
    450     int unit, 
    451     bcm_module_t modid, 
    452     int nports, 
    453     int enable);
    454 
    455 /* Map a SAND System-Port to a Gport */
    456 extern int bcm_stk_sysport_gport_set(
    457     int unit, 
    458     bcm_gport_t sysport, 
    459     bcm_gport_t gport);
    460 
    461 /* Given a SAND System-Port, get the Gport */
    462 extern int bcm_stk_sysport_gport_get(
    463     int unit, 
    464     bcm_gport_t sysport, 
    465     bcm_gport_t *gport);
    466 
    467 /* Given a Gport get the SAND System-Port */
    468 extern int bcm_stk_gport_sysport_get(
    469     int unit, 
    470     bcm_gport_t gport, 
    471     bcm_gport_t *sysport);
    472 
    473 /* Add or delete modid from TM-Domain. */
    474 extern int bcm_stk_modid_domain_add(
    475     int unit, 
    476     int modid, 
    477     int tm_domain);
    478 
    479 /* Delete modid from TM-domain */
    480 extern int bcm_stk_modid_domain_delete(
    481     int unit, 
    482     int modid, 
    483     int tm_domain);
    484 
    485 /* Get array of modid belongs to TM-Domin */
    486 extern int bcm_stk_modid_domain_get(
    487     int unit, 
    488     int tm_domain, 
    489     int mod_max, 
    490     int *mod_array, 
    491     int *mod_count);
    492 
    493 /* Define via which Stacking-Lag the TM-Domain will be reached. */
    494 extern int bcm_stk_domain_stk_trunk_add(
    495     int unit, 
    496     int tm_domain, 
    497     bcm_trunk_t stk_trunk);
    498 
    499 /* Delete a path from stacking trunk to TM-domain */
    500 extern int bcm_stk_domain_stk_trunk_delete(
    501     int unit, 
    502     int tm_domain, 
    503     bcm_trunk_t stk_trunk);
    504 
    505 /* Get array of TM-Domains which are reachable by the Stacking-Lag. */
    506 extern int bcm_stk_domain_stk_trunk_get(
    507     int unit, 
    508     bcm_trunk_t stk_trunk, 
    509     int domain_max, 
    510     int *domain_array, 
    511     int *domain_count);
    512 
    513 #endif /* BCM_HIDE_DISPATCHABLE */
    514 
    515 /* Flags for bcm_stk_system_gport_map_create/get/destroy. */
    516 #define BCM_STK_GPORT_MAP_WITH_ID   0x00000001 /* Add mapping with the specified
    517                                                   ID. */
    518 #define BCM_STK_GPORT_MAP_REPLACE   0x00000002 /* Replace existing mapping. */
    519 
    520 /* Structure for mapping gport to system port ID. */
    521 typedef struct bcm_stk_system_gport_map_s {
    522     uint32 flags; 
    523     bcm_module_t modid;         /* Destination module ID. */
    524     bcm_gport_t dest_gport;     /* Destination gport ID. */
    525     bcm_gport_t system_gport;   /* System gport ID */
    526 } bcm_stk_system_gport_map_t;
    527 
    528 #ifndef BCM_HIDE_DISPATCHABLE
    529 
    530 /* Create mapping from local gport id to system gport id */
    531 extern int bcm_stk_system_gport_map_create(
    532     int unit, 
    533     bcm_stk_system_gport_map_t *sys_gport_map);
    534 
    535 /* Get mapping from local gport id to system gport id */
    536 extern int bcm_stk_system_gport_map_get(
    537     int unit, 
    538     bcm_stk_system_gport_map_t *sys_gport_map);
    539 
    540 /* Destroy mapping from local gport id to system gport id */
    541 extern int bcm_stk_system_gport_map_destroy(
    542     int unit, 
    543     bcm_gport_t system_gport);
    544 
    545 /* Set remote mapping between local port and remote port, remote modid */
    546 extern int bcm_stk_modport_remote_map_set(
    547     int unit, 
    548     bcm_gport_t port, 
    549     uint32 flags, 
    550     int remote_modid, 
    551     bcm_port_t remote_port);
    552 
    553 /* Get remote mapping between local port and remote port, remote modid */
    554 extern int bcm_stk_modport_remote_map_get(
    555     int unit, 
    556     bcm_gport_t port, 
    557     uint32 flags, 
    558     int *remote_modid, 
    559     bcm_port_t *remote_port);
    560 
    561 /* Maximum group ID set/get */
    562 extern int bcm_stk_module_max_set(
    563     int unit, 
    564     uint32 flags, 
    565     bcm_module_t max_module);
    566 
    567 /* Maximum group ID set/get */
    568 extern int bcm_stk_module_max_get(
    569     int unit, 
    570     uint32 flags, 
    571     bcm_module_t *max_module);
    572 
    573 /* Set/get control value. */
    574 extern int bcm_stk_module_control_set(
    575     int unit, 
    576     uint32 flags, 
    577     bcm_module_t module, 
    578     bcm_stk_module_control_t control, 
    579     int arg);
    580 
    581 /* Set/get control value. */
    582 extern int bcm_stk_module_control_get(
    583     int unit, 
    584     uint32 flags, 
    585     bcm_module_t module, 
    586     bcm_stk_module_control_t control, 
    587     int *arg);
    588 
    589 /* 
    590  * Enable remote ports for the specified module based on the specified
    591  * port bitmap.
    592  */
    593 extern int bcm_stk_module_remote_port_enable_set(
    594     int unit, 
    595     int modid, 
    596     bcm_pbmp_t pbmp);
    597 
    598 /* Get enabled remote port bitmap for the specified module. */
    599 extern int bcm_stk_module_remote_port_enable_get(
    600     int unit, 
    601     int modid, 
    602     bcm_pbmp_t *pbmp);
    603 
    604 #endif /* BCM_HIDE_DISPATCHABLE */
    605 
    606 #endif /* __BCM_STACK_H__ */