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

ipmc.c (3192B)


      1 /*
      2  *  
      3  *
      4  * File:        ipmc.c
      5  * Purpose:     Handle Trident2plus specific IPMC implementation
      6  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      7  * 
      8  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      9  */
     10 #include <shared/bsl.h>
     11 #include <soc/defs.h>
     12 #include <assert.h>
     13 #include <sal/core/libc.h>
     14 #include <shared/util.h>
     15 
     16 #if (defined(BCM_TRIDENT2PLUS_SUPPORT) && defined(INCLUDE_L3))
     17 #include <soc/mem.h>
     18 #include <soc/l3x.h>
     19 #include <bcm/l3.h>
     20 #include <bcm/error.h>
     21 #include <bcm_int/esw/mbcm.h>
     22 #include <bcm_int/esw/firebolt.h>
     23 #include <bcm_int/esw/l3.h>
     24 
     25 #include <bcm_int/esw/trident2plus.h>
     26 #include <bcm_int/esw/ipmc.h>
     27 
     28 #ifdef BCM_WARM_BOOT_SUPPORT
     29 #include <bcm_int/esw/switch.h>
     30 #endif /* BCM_WARM_BOOT_SUPPORT */
     31 
     32 #define TD2P_DEFIP_USED_SET(n)  \
     33 {                                     \
     34     defip_ipmc_info[n]++;             \
     35 }
     36 
     37 #define TD2P_DEFIP_USED_GET(n)  defip_ipmc_info[n]
     38 
     39 int *defip_ipmc_info;
     40 
     41 /*
     42  * Function:
     43  *      bcm_td2p_defip_mc_route_check
     44  * Purpose:
     45  *      Check if the entry is a MC route and take appropriate action.
     46  * Parameters:
     47  *      unit       - (IN)SOC unit number
     48  *      lpm_cfg    - (IN)DEFIP information
     49  * Returns:
     50  *      BCM_E_XXX
     51  */
     52 int
     53 bcm_td2p_defip_mc_route_check (int unit, _bcm_defip_cfg_t *lpm_cfg)
     54 {
     55     int ipmc_group;
     56 
     57     if (lpm_cfg->defip_flags & BCM_L3_IPMC) {
     58         ipmc_group = lpm_cfg->defip_mc_group;
     59         TD2P_DEFIP_USED_SET(ipmc_group);
     60     }
     61     return BCM_E_NONE;
     62 }
     63 
     64 /*
     65  * Function:
     66  *      bcm_td2p_defip_ipmc_count_update
     67  * Purpose:
     68  *      Update IPMC DEFIP ref count based on local ref count
     69  * Parameters:
     70  *      unit       - (IN)SOC unit number
     71  * Returns:
     72  *      BCM_E_XXX
     73  */
     74 int
     75 bcm_td2p_defip_ipmc_count_update(int unit)
     76 {
     77     int i, ipmc_count;
     78 
     79     for (i = 0; i < IPMC_GROUP_NUM(unit); i++) {
     80         ipmc_count = TD2P_DEFIP_USED_GET(i);
     81         if (ipmc_count) {
     82             IPMC_DEFIP_COUNT_SET(unit, i, ipmc_count);
     83         }
     84     }
     85     bcm_td2p_l3_defip_deinit(unit);
     86     return BCM_E_NONE;
     87 }
     88 
     89 /*
     90  * Function:
     91  *      bcm_td2p_l3_defip_init
     92  * Purpose:
     93  *      Initialize defip_ipmc_info array to holdinformation about
     94  *      IPMC groups used by DEFIP Multicast entries
     95  * Parameters:
     96  *      unit       - (IN)SOC unit number
     97  * Returns:
     98  *      BCM_E_XXX
     99  */
    100 int
    101 bcm_td2p_l3_defip_init(int unit)
    102 {
    103     int ipmc_count;
    104     ipmc_count = soc_mem_index_count(unit, L3_IPMCm);
    105 
    106     if (defip_ipmc_info != NULL) {
    107         bcm_td2p_l3_defip_deinit(unit);
    108     }
    109     defip_ipmc_info = sal_alloc(ipmc_count * sizeof(int),
    110             "DEFIP IPMC info");
    111     if (defip_ipmc_info == NULL) {
    112         return (BCM_E_MEMORY);
    113     }
    114 
    115     sal_memset(defip_ipmc_info, 0, ipmc_count * sizeof(int));
    116     return BCM_E_NONE;
    117 }
    118 
    119 /*
    120  * Function:
    121  *      bcm_td2p_l3_defip_deinit
    122  * Purpose:
    123  *      Free defip_ipmc_info array
    124  * Parameters:
    125  *      unit       - (IN)SOC unit number
    126  * Returns:
    127  *      None
    128  */
    129 void
    130 bcm_td2p_l3_defip_deinit(int unit)
    131 {
    132     if (defip_ipmc_info != NULL) {
    133         sal_free(defip_ipmc_info);
    134         defip_ipmc_info = NULL;
    135     }
    136 }
    137 
    138 #endif /* BCM_TRIDENT2PLUS_SUPPORT && INCLUDE_L3 */