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

compat_658.c (4254B)


      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  * RPC Compatibility with <=sdk-6.5.8 routines
      8  */
      9 
     10 #ifdef	BCM_RPC_SUPPORT
     11 #include <shared/alloc.h>
     12 #include <bcm/error.h>
     13 #include <bcm_int/compat/compat_658.h>
     14 
     15 #if defined(INCLUDE_L3)
     16 /*
     17  * Function:
     18  *      _bcm_compat658in_ecn_map_t
     19  * Purpose:
     20  *      Convert the bcm_ecn_map_t datatype from <=6.5.8 to
     21  *      SDK 6.5.8+
     22  * Parameters:
     23  *      from        - (IN) The <=6.5.8 version of the datatype
     24  *      to          - (OUT) The SDK 6.5.8+ version of the datatype
     25  * Returns:
     26  *      Nothing
     27  */
     28 STATIC void
     29 _bcm_compat658in_ecn_map_t(bcm_compat658_ecn_map_t *from,
     30                            bcm_ecn_map_t *to)
     31 {
     32     bcm_ecn_map_t_init(to);
     33     to->action_flags = from->action_flags;
     34     to->int_cn = from->int_cn;
     35     to->inner_ecn = from->inner_ecn;
     36     to->ecn = from->ecn;
     37     to->exp = from->exp;
     38     to->new_ecn = from->new_ecn;
     39     to->new_exp = from->new_exp;
     40 }
     41 
     42 /*
     43  * Function:
     44  *      _bcm_compat658out_ecn_map_t
     45  * Purpose:
     46  *      Convert the bcm_field_qset_t datatype from 6.5.8+ to
     47  *      <=6.5.8
     48  * Parameters:
     49  *      from        - (IN) The SDK 6.5.8+ version of the datatype
     50  *      to          - (OUT) The <=6.5.8 version of the datatype
     51  * Returns:
     52  *      Nothing
     53  */
     54 STATIC void
     55 _bcm_compat658out_ecn_map_t(bcm_ecn_map_t *from,
     56                             bcm_compat658_ecn_map_t *to)
     57 {
     58     to->action_flags = from->action_flags;
     59     to->int_cn = from->int_cn;
     60     to->inner_ecn = from->inner_ecn;
     61     to->ecn = from->ecn;
     62     to->exp = from->exp;
     63     to->new_ecn = from->new_ecn;
     64     to->new_exp = from->new_exp;
     65 }
     66 
     67 /*
     68  * Function: bcm_compat658_ecn_map_get
     69  *
     70  * Purpose:
     71  *      Compatibility function for RPC call to bcm_esw_extender_forward_get.
     72  *
     73  * Parameters:
     74  *     unit - (IN) BCM device number.
     75  *     extender_forward_entry - (IN/OUT) Forwarding entry with old format
     76  *
     77  * Returns:
     78  *     BCM_E_XXX
     79  */
     80 int
     81 bcm_compat658_ecn_map_get(int unit, int ecn_map_id,
     82                                    bcm_compat658_ecn_map_t *ecn_map)
     83 {
     84     int rv;
     85     bcm_ecn_map_t *new_ecn_map = NULL;
     86 
     87     if (NULL != ecn_map) {
     88         /* Create from heap to avoid the stack to bloat */
     89         new_ecn_map = (bcm_ecn_map_t *)
     90             sal_alloc(sizeof(bcm_ecn_map_t), "New Ecn Map");
     91         if (NULL == new_ecn_map) {
     92             return BCM_E_MEMORY;
     93         }
     94 
     95         /* Transform the entry from the old format to new one */
     96         _bcm_compat658in_ecn_map_t(ecn_map, new_ecn_map);
     97     }
     98 
     99     /* Call the BCM API with new format */
    100     rv = bcm_ecn_map_get(unit, ecn_map_id, new_ecn_map);
    101 
    102     if (NULL != new_ecn_map) {
    103         /* Transform the entry from the new format to old one */
    104         _bcm_compat658out_ecn_map_t(new_ecn_map, ecn_map);
    105         /* Deallocate memory*/
    106         sal_free(new_ecn_map);
    107     }
    108 
    109     return rv;
    110 }
    111 
    112 /*
    113  * Function: bcm_compat658_ecn_map_set
    114  *
    115  * Purpose:
    116  *      Compatibility function for RPC call to bcm_esw_extender_forward_get.
    117  *
    118  * Parameters:
    119  *     unit - (IN) BCM device number.
    120  *     extender_forward_entry - (IN/OUT) Forwarding entry with old format
    121  *
    122  * Returns:
    123  *     BCM_E_XXX
    124  */
    125 int
    126 bcm_compat658_ecn_map_set(int unit, uint32 options, int ecn_map_id,
    127                                    bcm_compat658_ecn_map_t *ecn_map)
    128 {
    129     int rv;
    130     bcm_ecn_map_t *new_ecn_map = NULL;
    131 
    132     if (NULL != ecn_map) {
    133         /* Create from heap to avoid the stack to bloat */
    134         new_ecn_map = (bcm_ecn_map_t *)
    135             sal_alloc(sizeof(bcm_ecn_map_t), "New Ecn Map");
    136         if (NULL == new_ecn_map) {
    137             return BCM_E_MEMORY;
    138         }
    139 
    140         /* Transform the entry from the old format to new one */
    141         _bcm_compat658in_ecn_map_t(ecn_map, new_ecn_map);
    142     }
    143 
    144     /* Call the BCM API with new format */
    145     rv = bcm_ecn_map_set(unit, options, ecn_map_id, new_ecn_map);
    146 
    147     if (NULL != new_ecn_map) {
    148         /* Transform the entry from the new format to old one */
    149         _bcm_compat658out_ecn_map_t(new_ecn_map, ecn_map);
    150         /* Deallocate memory*/
    151         sal_free(new_ecn_map);
    152     }
    153 
    154     return rv;
    155 }
    156 #endif
    157 #endif  /* BCM_RPC_SUPPORT */