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

l3.c (3703B)


      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:        l3.c
      8  * Purpose:     Hurricane L3 function implementations
      9  */
     10 #include <soc/defs.h>
     11 #ifdef INCLUDE_L3
     12 
     13 #include <assert.h>
     14 
     15 #include <sal/core/libc.h>
     16 
     17 #include <shared/util.h>
     18 #include <soc/mem.h>
     19 #include <soc/cm.h>
     20 #include <soc/drv.h>
     21 #include <soc/register.h>
     22 #include <soc/memory.h>
     23 #include <soc/l3x.h>
     24 #include <soc/lpm.h>
     25 #include <soc/tnl_term.h>
     26 
     27 #include <bcm/l3.h>
     28 #include <bcm/error.h>
     29 
     30 #include <bcm_int/esw/mbcm.h>
     31 #include <bcm_int/esw/firebolt.h>
     32 #include <bcm_int/esw/trx.h>
     33 #include <bcm_int/esw/virtual.h>
     34 #include <bcm_int/esw/triumph.h>
     35 #include <bcm_int/esw/hurricane.h>
     36 #include <bcm_int/esw/l3.h>
     37 #include <bcm_int/esw/xgs3.h>
     38 
     39 #include <bcm_int/esw_dispatch.h>
     40 
     41 
     42 
     43 /*
     44  * Function:
     45  *      _bcm_hu_l3_intf_mtu_set
     46  * Purpose:
     47  *      Set  L3 interface MTU value. 
     48  * Parameters:
     49  *      unit      - (IN)SOC unit number.
     50  *      intf_info - (IN)Interface information.
     51  * Returns:
     52  *      BCM_E_XXX
     53  */
     54 int
     55 _bcm_hu_l3_intf_mtu_set(int unit, _bcm_l3_intf_cfg_t *intf_info)
     56 {
     57     mtu_values_entry_t mtu_value_buf;  /* Buffer to write mtu. */
     58     uint32  *mtu_value_buf_p;          /* Write buffer address.*/
     59     void *null_entry = soc_mem_entry_null(unit, L3_MTU_VALUESm);
     60 
     61     /* Input parameters check */
     62     if (NULL == intf_info) {
     63         return (BCM_E_PARAM);
     64     }
     65 
     66     /* coverity[large_shift : FALSE] */
     67     if(!SOC_MEM_FIELD32_VALUE_FIT(unit, L3_MTU_VALUESm, 
     68                                   MTU_SIZEf, intf_info->l3i_mtu)) {
     69         return (BCM_E_PARAM);
     70     }
     71 
     72     if ((intf_info->l3i_index < soc_mem_index_min(unit, L3_MTU_VALUESm)) || 
     73         (intf_info->l3i_index > soc_mem_index_max(unit, L3_MTU_VALUESm))) {
     74         return (BCM_E_PARAM);
     75     }
     76 
     77     /* Reset the buffer to default value. */
     78     mtu_value_buf_p = (uint32 *)&mtu_value_buf;
     79     sal_memcpy(mtu_value_buf_p, null_entry, sizeof(mtu_values_entry_t));
     80 
     81     if (intf_info->l3i_mtu) {
     82         /* Set mtu. */
     83         soc_mem_field32_set(unit, L3_MTU_VALUESm, mtu_value_buf_p, 
     84                             MTU_SIZEf, intf_info->l3i_mtu);
     85     }
     86 
     87     return BCM_XGS3_MEM_WRITE(unit, L3_MTU_VALUESm, 
     88                               intf_info->l3i_index, mtu_value_buf_p);
     89 }
     90 
     91 /*
     92  * Function:
     93  *      _bcm_hu_l3_intf_mtu_get
     94  * Purpose:
     95  *      Get  L3 interface MTU value. 
     96  * Parameters:
     97  *      unit      - (IN)SOC unit number.
     98  *      intf_info - (IN/OUT)Interface information with updated mtu.
     99  * Returns:
    100  *      BCM_E_XXX
    101  */
    102 int
    103 _bcm_hu_l3_intf_mtu_get(int unit, _bcm_l3_intf_cfg_t *intf_info)
    104 {
    105     mtu_values_entry_t mtu_value_buf;  /* Buffer to write mtu. */
    106     uint32  *mtu_value_buf_p;          /* Write buffer address.           */
    107 
    108     /* Input parameters check */
    109     if (NULL == intf_info) {
    110         return (BCM_E_PARAM);
    111     }
    112 
    113     if ((intf_info->l3i_index < soc_mem_index_min(unit, L3_MTU_VALUESm)) || 
    114         (intf_info->l3i_index > soc_mem_index_max(unit, L3_MTU_VALUESm))) {
    115         return (BCM_E_PARAM);
    116     }
    117     
    118     /* Zero the buffer. */
    119     mtu_value_buf_p = (uint32 *)&mtu_value_buf;
    120     sal_memset(mtu_value_buf_p, 0, sizeof(mtu_values_entry_t));
    121 
    122     /* Read mtu table entry by index. */
    123     BCM_IF_ERROR_RETURN(BCM_XGS3_MEM_READ(unit, L3_MTU_VALUESm,
    124                                           intf_info->l3i_index, mtu_value_buf_p));
    125     intf_info->l3i_mtu = 
    126         soc_mem_field32_get(unit, L3_MTU_VALUESm, mtu_value_buf_p, MTU_SIZEf);
    127 
    128     return (BCM_E_NONE);
    129 }
    130 
    131 
    132 #else  /* INCLUDE_L3 */
    133 int bcm_esw_hurricane_l3_not_empty;
    134 #endif /* INCLUDE_L3 */