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

failover.c (4681B)


      1 /* 
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * File:        bcmx/failover.c
      8  * Purpose:     BCMX Forwarding Failover Protection APIs
      9  */
     10 #include <bcm/types.h>
     11 
     12 #include <bcmx/failover.h>
     13 
     14 #ifdef INCLUDE_L3
     15 
     16 #include "bcmx_int.h"
     17 
     18 #define BCMX_FAILOVER_INIT_CHECK    BCMX_READY_CHECK
     19 
     20 #define BCMX_FAILOVER_ERROR_CHECK(_unit, _check, _rv)    \
     21     BCMX_ERROR_CHECK(_unit, _check, _rv)
     22 
     23 #define BCMX_FAILOVER_SET_ERROR_CHECK(_unit, _check, _rv)    \
     24     BCMX_SET_ERROR_CHECK(_unit, _check, _rv)
     25 
     26 #define BCMX_FAILOVER_DELETE_ERROR_CHECK(_unit, _check, _rv)    \
     27     BCMX_DELETE_ERROR_CHECK(_unit, _check, _rv)
     28 
     29 #define BCMX_FAILOVER_GET_IS_VALID(_unit, _rv)    \
     30     BCMX_ERROR_IS_VALID(_unit, _rv)
     31 
     32 
     33 /*
     34  * Function:
     35  *     bcmx_failover_init
     36  */
     37 int
     38 bcmx_failover_init(void)
     39 {
     40     int  rv = BCM_E_UNAVAIL, tmp_rv;
     41     int  i, bcm_unit;
     42 
     43     BCMX_FAILOVER_INIT_CHECK;
     44 
     45     BCMX_UNIT_ITER(bcm_unit, i) {
     46         tmp_rv = bcm_failover_init(bcm_unit);
     47         BCM_IF_ERROR_RETURN(BCMX_FAILOVER_ERROR_CHECK(bcm_unit, tmp_rv, &rv));
     48     }
     49 
     50     return rv;
     51 }
     52 
     53 
     54 /*
     55  * Function:
     56  *     bcmx_failover_cleanup
     57  */
     58 int
     59 bcmx_failover_cleanup(void)
     60 {
     61     int  rv = BCM_E_UNAVAIL, tmp_rv;
     62     int  i, bcm_unit;
     63 
     64     BCMX_FAILOVER_INIT_CHECK;
     65 
     66     BCMX_UNIT_ITER(bcm_unit, i) {
     67         tmp_rv = bcm_failover_cleanup(bcm_unit);
     68         BCM_IF_ERROR_RETURN(BCMX_FAILOVER_ERROR_CHECK(bcm_unit, tmp_rv, &rv));
     69     }
     70 
     71     return rv;
     72 }
     73 
     74 
     75 /*
     76  * Function:
     77  *     bcmx_failover_create
     78  */
     79 int
     80 bcmx_failover_create(uint32 flags, bcm_failover_t *failover_id)
     81 {
     82     int  rv = BCM_E_UNAVAIL, tmp_rv;
     83     int  i, bcm_unit;
     84 
     85     BCMX_FAILOVER_INIT_CHECK;
     86 
     87     BCMX_PARAM_NULL_CHECK(failover_id);
     88 
     89     BCMX_UNIT_ITER(bcm_unit, i) {
     90 
     91         tmp_rv = bcm_failover_create(bcm_unit, flags, failover_id);
     92         BCM_IF_ERROR_RETURN
     93             (BCMX_FAILOVER_SET_ERROR_CHECK(bcm_unit, tmp_rv, &rv));
     94 
     95         /*
     96          * Use the ID from first successful 'create' if group ID
     97          * is not specified.
     98          */
     99         if (!(flags & BCM_FAILOVER_WITH_ID)) {
    100             if (BCM_SUCCESS(tmp_rv)) {
    101                 flags |= BCM_FAILOVER_WITH_ID;
    102             }
    103         }
    104     }
    105 
    106     return rv;
    107 }
    108 
    109 
    110 /*
    111  * Function:
    112  *     bcmx_failover_destroy
    113  */
    114 int
    115 bcmx_failover_destroy(bcm_failover_t failover_id)
    116 {
    117     int  rv = BCM_E_UNAVAIL, tmp_rv;
    118     int  i, bcm_unit;
    119 
    120     BCMX_FAILOVER_INIT_CHECK;
    121 
    122     BCMX_UNIT_ITER(bcm_unit, i) {
    123         tmp_rv = bcm_failover_destroy(bcm_unit, failover_id);
    124         BCM_IF_ERROR_RETURN
    125             (BCMX_FAILOVER_DELETE_ERROR_CHECK(bcm_unit, tmp_rv, &rv));
    126     }
    127 
    128     return rv;
    129 }
    130 
    131 
    132 /*
    133  * Function:
    134  *     bcmx_failover_set
    135  */
    136 int
    137 bcmx_failover_set(bcm_failover_t failover_id, int enable)
    138 {
    139     int  rv = BCM_E_UNAVAIL, tmp_rv;
    140     int  i, bcm_unit;
    141 
    142     BCMX_FAILOVER_INIT_CHECK;
    143 
    144     BCMX_UNIT_ITER(bcm_unit, i) {
    145         tmp_rv = bcm_failover_set(bcm_unit, failover_id, enable);
    146         BCM_IF_ERROR_RETURN
    147             (BCMX_FAILOVER_SET_ERROR_CHECK(bcm_unit, tmp_rv, &rv));
    148     }
    149 
    150     return rv;
    151 }
    152 
    153 
    154 /*
    155  * Function:
    156  *     bcmx_failover_get
    157  */
    158 int
    159 bcmx_failover_get(bcm_failover_t failover_id, int *enable)
    160 {
    161     int  rv;
    162     int  i;
    163     int  bcm_unit;
    164 
    165     BCMX_FAILOVER_INIT_CHECK;
    166 
    167     BCMX_PARAM_NULL_CHECK(enable);
    168 
    169     BCMX_UNIT_ITER(bcm_unit, i) {
    170         rv = bcm_failover_get(bcm_unit, failover_id, enable);
    171         if (BCMX_FAILOVER_GET_IS_VALID(bcm_unit, rv)) {
    172             return rv;
    173         }
    174     }
    175 
    176     return BCM_E_UNAVAIL;
    177 }
    178 
    179 #else /* INCLUDE_L3 */
    180 /*
    181  * Function:
    182  *     bcmx_failover_init
    183  */
    184 int
    185 bcmx_failover_init(void)
    186 {
    187     return BCM_E_UNAVAIL;
    188 }
    189 
    190 
    191 /*
    192  * Function:
    193  *     bcmx_failover_cleanup
    194  */
    195 int
    196 bcmx_failover_cleanup(void)
    197 {
    198     return BCM_E_UNAVAIL;
    199 }
    200 
    201 
    202 /*
    203  * Function:
    204  *     bcmx_failover_create
    205  */
    206 int
    207 bcmx_failover_create(uint32 flags, bcm_failover_t *failover_id)
    208 {
    209     COMPILER_REFERENCE(flags);
    210     COMPILER_REFERENCE(failover_id);
    211     return BCM_E_UNAVAIL;
    212 }
    213 
    214 
    215 /*
    216  * Function:
    217  *     bcmx_failover_destroy
    218  */
    219 int
    220 bcmx_failover_destroy(bcm_failover_t failover_id)
    221 {
    222     COMPILER_REFERENCE(failover_id);
    223     return BCM_E_UNAVAIL;
    224 }
    225 
    226 
    227 /*
    228  * Function:
    229  *     bcmx_failover_set
    230  */
    231 int
    232 bcmx_failover_set(bcm_failover_t failover_id, int enable)
    233 {
    234     COMPILER_REFERENCE(failover_id);
    235     COMPILER_REFERENCE(enable);
    236     return BCM_E_UNAVAIL;
    237 }
    238 
    239 
    240 /*
    241  * Function:
    242  *     bcmx_failover_get
    243  */
    244 int
    245 bcmx_failover_get(bcm_failover_t failover_id, int *enable)
    246 {
    247     COMPILER_REFERENCE(failover_id);
    248     COMPILER_REFERENCE(enable);
    249     return BCM_E_UNAVAIL;
    250 }
    251 #endif /* INCLUDE_L3 */