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_6513.c (14528B)


      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.13 routines
      8  */
      9 
     10 #ifdef   BCM_RPC_SUPPORT
     11 #include <shared/alloc.h>
     12 #include <bcm/error.h>
     13 #include <bcm_int/compat/compat_6513.h>
     14 
     15 #if defined(INCLUDE_L3)
     16 /*
     17  * Function:
     18  *      _bcm_compat6513in_flow_encap_config_t
     19  * Purpose:
     20  *      Convert the bcm_flow_encap_config_t datatype from <=6.5.13 to
     21  *      SDK 6.5.13+
     22  * Parameters:
     23  *      from        - (IN) The <=6.5.13 version of the datatype
     24  *      to          - (OUT) The SDK 6.5.13+ version of the datatype
     25  * Returns:
     26  *      Nothing
     27  */
     28 STATIC void
     29 _bcm_compat6513in_flow_encap_config_t(bcm_compat6513_flow_encap_config_t *from,
     30                            bcm_flow_encap_config_t *to)
     31 {
     32     bcm_flow_encap_config_t_init(to);
     33     to->vpn = from->vpn;
     34     to->flow_port = from->flow_port;
     35     to->intf_id = from->intf_id;
     36     to->dvp_group = from->dvp_group;
     37     to->oif_group = from->oif_group;
     38     to->vnid = from->vnid;
     39     to->pri = from->pri;
     40     to->cfi = from->cfi;
     41     to->tpid = from->tpid;
     42     to->vlan = from->vlan;
     43     to->flags = from->flags;
     44     to->options = from->options;
     45     to->criteria = from->criteria;
     46     to->valid_elements = from->valid_elements;
     47     to->flow_handle = from->flow_handle;
     48     to->flow_option = from->flow_option;
     49  }
     50 
     51 /*
     52  * Function:
     53  *      _bcm_compat6513out_ecn_map_t
     54  * Purpose:
     55  *      Convert the bcm_flow_encap_config_t datatype from 6.5.13+ to
     56  *      <=6.5.13
     57  * Parameters:
     58  *      from        - (IN) The SDK 6.5.13+ version of the datatype
     59  *      to          - (OUT) The <=6.5.13 version of the datatype
     60  * Returns:
     61  *      Nothing
     62  */
     63 STATIC void
     64 _bcm_compat6513out_flow_encap_config_t(bcm_flow_encap_config_t *from,
     65                             bcm_compat6513_flow_encap_config_t *to)
     66 {
     67     to->vpn = from->vpn;
     68     to->flow_port = from->flow_port;
     69     to->intf_id = from->intf_id;
     70     to->dvp_group = from->dvp_group;
     71     to->oif_group = from->oif_group;
     72     to->vnid = from->vnid;
     73     to->pri = from->pri;
     74     to->cfi = from->cfi;
     75     to->tpid = from->tpid;
     76     to->vlan = from->vlan;
     77     to->flags = from->flags;
     78     to->options = from->options;
     79     to->criteria = from->criteria;
     80     to->valid_elements = from->valid_elements;
     81     to->flow_handle = from->flow_handle;
     82     to->flow_option = from->flow_option;
     83     
     84 }
     85 
     86 /*
     87  * Function: bcm_compat6513_flow_encap_get
     88  *
     89  * Purpose:
     90  *      Compatibility function for RPC call to bcm_flow_encap_get.
     91  *
     92  * Parameters:
     93  *      unit     - (IN)Device Number
     94  *      info     - (IN/OUT)flow encap Config
     95  *      num_of_fields - (IN) Number of logical fields
     96  *      field    - (IN/OUT)Point to logical field array
     97  * Returns:
     98  *      BCM_E_XXXX
     99  */
    100 int
    101 bcm_compat6513_flow_encap_get(int unit, 
    102     bcm_compat6513_flow_encap_config_t *info, 
    103     uint32 num_of_fields, 
    104     bcm_flow_logical_field_t *field)
    105 {
    106     int rv;
    107     bcm_flow_encap_config_t *new_info = NULL;
    108 
    109     if (NULL != info) {
    110         /* Create from heap to avoid the stack to bloat */
    111         new_info = (bcm_flow_encap_config_t *)
    112             sal_alloc(sizeof(bcm_flow_encap_config_t), "New flow encap config");
    113         if (NULL == new_info) {
    114             return BCM_E_MEMORY;
    115         }
    116 
    117         /* Transform the entry from the old format to new one */
    118         _bcm_compat6513in_flow_encap_config_t(info, new_info);
    119     }
    120 
    121     /* Call the BCM API with new format */
    122     rv = bcm_flow_encap_get(unit, new_info, num_of_fields, field);
    123 
    124     if (NULL != new_info) {
    125         /* Transform the entry from the new format to old one */
    126         _bcm_compat6513out_flow_encap_config_t(new_info, info);
    127         /* Deallocate memory*/
    128         sal_free(new_info);
    129     }
    130 
    131     return rv;
    132 }
    133 
    134 /*
    135  * Function: bcm_compat6513_flow_encap_delete
    136  *
    137  * Purpose:
    138  *      Compatibility function for RPC call to bcm_esw_flow_encap_delete.
    139  *
    140  * Parameters:
    141  *      unit     - (IN)Device Number
    142  *      info     - (IN/OUT)flow encap Config
    143  *      num_of_fields - (IN) Number of logical fields
    144  *      field    - (IN/OUT)Point to logical field array
    145  * Returns:
    146  *      BCM_E_XXXX
    147  */
    148 int
    149 bcm_compat6513_flow_encap_delete(int unit, 
    150     bcm_compat6513_flow_encap_config_t *info, 
    151     uint32 num_of_fields, 
    152     bcm_flow_logical_field_t *field)
    153 {
    154     int rv;
    155     bcm_flow_encap_config_t *new_info = NULL;
    156 
    157     if (NULL != info) {
    158         /* Create from heap to avoid the stack to bloat */
    159         new_info = (bcm_flow_encap_config_t *)
    160             sal_alloc(sizeof(bcm_flow_encap_config_t), "New flow encap config");
    161         if (NULL == new_info) {
    162             return BCM_E_MEMORY;
    163         }
    164 
    165         /* Transform the entry from the old format to new one */
    166         _bcm_compat6513in_flow_encap_config_t(info, new_info);
    167     }
    168 
    169     /* Call the BCM API with new format */
    170     rv = bcm_flow_encap_delete(unit, new_info, num_of_fields, field);
    171 
    172     if (NULL != new_info) {
    173         /* Transform the entry from the new format to old one */
    174         _bcm_compat6513out_flow_encap_config_t(new_info, info);
    175         /* Deallocate memory*/
    176         sal_free(new_info);
    177     }
    178 
    179     return rv;
    180 }
    181 
    182 /*
    183  * Function: bcm_compat6513_flow_encap_add
    184  *
    185  * Purpose:
    186  *      Compatibility function for RPC call to bcm_esw_flow_encap_add.
    187  *
    188  * Parameters:
    189  *      unit     - (IN)Device Number
    190  *      info     - (IN/OUT)flow encap Config
    191  *      num_of_fields - (IN) Number of logical fields
    192  *      field    - (IN/OUT)Point to logical field array
    193  * Returns:
    194  *      BCM_E_XXXX
    195  */
    196 int
    197 bcm_compat6513_flow_encap_add(int unit, 
    198     bcm_compat6513_flow_encap_config_t *info, 
    199     uint32 num_of_fields, 
    200     bcm_flow_logical_field_t *field)
    201 {
    202     int rv;
    203     bcm_flow_encap_config_t *new_info = NULL;
    204 
    205     if (NULL != info) {
    206         /* Create from heap to avoid the stack to bloat */
    207         new_info = (bcm_flow_encap_config_t *)
    208             sal_alloc(sizeof(bcm_flow_encap_config_t), "New flow encap config");
    209         if (NULL == new_info) {
    210             return BCM_E_MEMORY;
    211         }
    212 
    213         /* Transform the entry from the old format to new one */
    214         _bcm_compat6513in_flow_encap_config_t(info, new_info);
    215     }
    216 
    217     /* Call the BCM API with new format */
    218     rv = bcm_flow_encap_add(unit, new_info, num_of_fields, field);
    219 
    220     if (NULL != new_info) {
    221         /* Transform the entry from the new format to old one */
    222         _bcm_compat6513out_flow_encap_config_t(new_info, info);
    223         /* Deallocate memory*/
    224         sal_free(new_info);
    225     }
    226 
    227     return rv;
    228 }
    229 
    230 /*
    231  * Function:
    232  *      _bcm_compat6513in_l3_egress_t
    233  * Purpose:
    234  *      Convert the bcm_l3_egress_t datatype from <=6.5.13 to
    235  *      SDK 6.5.13+
    236  * Parameters:
    237  *      from        - (IN) The <=6.5.13 version of the datatype
    238  *      to          - (OUT) The SDK 6.5.13+ version of the datatype
    239  * Returns:
    240  *      Nothing
    241  */
    242 STATIC void
    243 _bcm_compat6513in_l3_egress_t(
    244     bcm_compat6513_l3_egress_t *from,
    245     bcm_l3_egress_t *to)
    246 {
    247     int i = 0;
    248 
    249     bcm_l3_egress_t_init(to);
    250     to->flags = from->flags;
    251     to->flags2 = from->flags2;
    252     to->intf = from->intf;
    253     sal_memcpy(to->mac_addr, from->mac_addr, sizeof(bcm_mac_t));
    254     to->vlan = from->vlan;
    255     to->module = from->module;
    256     to->port = from->port;
    257     to->trunk = from->trunk;
    258     to->mpls_flags = from->mpls_flags;
    259     to->mpls_label = from->mpls_label;
    260     to->mpls_action = from->mpls_action;
    261     to->mpls_qos_map_id = from->mpls_qos_map_id;
    262     to->mpls_ttl = from->mpls_ttl;
    263     to->mpls_pkt_pri = from->mpls_pkt_pri;
    264     to->mpls_pkt_cfi = from->mpls_pkt_cfi;
    265     to->mpls_exp = from->mpls_exp;
    266     to->qos_map_id = from->qos_map_id;
    267     to->encap_id = from->encap_id;
    268     to->failover_id = from->failover_id;
    269     to->failover_if_id = from->failover_if_id;
    270     to->failover_mc_group = from->failover_mc_group;
    271     to->dynamic_load_weight = from->dynamic_load_weight;
    272     to->dynamic_queue_size_weight = from->dynamic_queue_size_weight;
    273     to->intf_class = from->intf_class;
    274     to->multicast_flags = from->multicast_flags;
    275     to->oam_global_context_id = from->oam_global_context_id;
    276     to->vntag = from->vntag;
    277     to->vntag_action = from->vntag_action;
    278     to->etag = from->etag;
    279     to->etag_action = from->etag_action;
    280     to->flow_handle = from->flow_handle;
    281     to->flow_option_handle = from->flow_option_handle;
    282     to->flow_label_option_handle = from->flow_label_option_handle;
    283     for (i = 0; i < BCM_FLOW_MAX_NOF_LOGICAL_FIELDS; i++) {
    284         to->logical_fields[i] = from->logical_fields[i];
    285     }
    286     to->num_of_fields = from->num_of_fields;
    287     to->counting_profile = from->counting_profile;
    288     to->mpls_ecn_map_id = from->mpls_ecn_map_id;
    289     to->urpf_mode = from->urpf_mode;
    290 }
    291 
    292 /*
    293  * Function:
    294  *      _bcm_compat6513out_l3_egress_t
    295  * Purpose:
    296  *      Convert the bcm_l3_egress_t datatype from 6.5.13+ to
    297  *      <=6.5.13
    298  * Parameters:
    299  *      from        - (IN) The SDK 6.5.13+ version of the datatype
    300  *      to          - (OUT) The <=6.5.13 version of the datatype
    301  * Returns:
    302  *      Nothing
    303  */
    304 STATIC void
    305 _bcm_compat6512out_l3_egress_t(
    306     bcm_l3_egress_t *from,
    307     bcm_compat6513_l3_egress_t *to)
    308 {
    309     int i = 0;
    310 
    311     to->flags = from->flags;
    312     to->flags2 = from->flags2;
    313     to->intf = from->intf;
    314     sal_memcpy(to->mac_addr, from->mac_addr, sizeof(bcm_mac_t));
    315     to->vlan = from->vlan;
    316     to->module = from->module;
    317     to->port = from->port;
    318     to->trunk = from->trunk;
    319     to->mpls_flags = from->mpls_flags;
    320     to->mpls_label = from->mpls_label;
    321     to->mpls_action = from->mpls_action;
    322     to->mpls_qos_map_id = from->mpls_qos_map_id;
    323     to->mpls_ttl = from->mpls_ttl;
    324     to->mpls_pkt_pri = from->mpls_pkt_pri;
    325     to->mpls_pkt_cfi = from->mpls_pkt_cfi;
    326     to->mpls_exp = from->mpls_exp;
    327     to->qos_map_id = from->qos_map_id;
    328     to->encap_id = from->encap_id;
    329     to->failover_id = from->failover_id;
    330     to->failover_if_id = from->failover_if_id;
    331     to->failover_mc_group = from->failover_mc_group;
    332     to->dynamic_load_weight = from->dynamic_load_weight;
    333     to->dynamic_queue_size_weight = from->dynamic_queue_size_weight;
    334     to->intf_class = from->intf_class;
    335     to->multicast_flags = from->multicast_flags;
    336     to->oam_global_context_id = from->oam_global_context_id;
    337     to->vntag = from->vntag;
    338     to->vntag_action = from->vntag_action;
    339     to->etag = from->etag;
    340     to->etag_action = from->etag_action;
    341     to->flow_handle = from->flow_handle;
    342     to->flow_option_handle = from->flow_option_handle;
    343     to->flow_label_option_handle = from->flow_label_option_handle;
    344     for (i = 0; i < BCM_FLOW_MAX_NOF_LOGICAL_FIELDS; i++) {
    345         to->logical_fields[i] = from->logical_fields[i];
    346     }
    347     to->num_of_fields = from->num_of_fields;
    348     to->counting_profile = from->counting_profile;
    349     to->mpls_ecn_map_id = from->mpls_ecn_map_id;
    350     to->urpf_mode = from->urpf_mode;
    351 }
    352 
    353 /*
    354  * Function: bcm_compat6513_l3_egress_create
    355  *
    356  * Purpose:
    357  *      Compatibility function for RPC call to bcm_esw_l3_egress_create.
    358  *
    359  * Parameters:
    360  *     unit - (IN) BCM device number.
    361  *     extender_forward_entry - (IN/OUT) Forwarding entry with old format
    362  *
    363  * Returns:
    364  *     BCM_E_XXX
    365  */
    366 int
    367 bcm_compat6513_l3_egress_create(int unit, uint32 flags,
    368                                 bcm_compat6513_l3_egress_t *egr,
    369                                 bcm_if_t *intf)
    370 {
    371     int rv;
    372     bcm_l3_egress_t *new_egr = NULL;
    373 
    374     if (NULL != egr) {
    375         /* Create from heap to avoid the stack to bloat */
    376         new_egr = (bcm_l3_egress_t *)
    377             sal_alloc(sizeof(bcm_l3_egress_t), "New Egress");
    378         if (NULL == new_egr) {
    379             return BCM_E_MEMORY;
    380         }
    381 
    382         /* Transform the entry from the old format to new one */
    383         _bcm_compat6513in_l3_egress_t(egr, new_egr);
    384     }
    385 
    386     /* Call the BCM API with new format */
    387     rv = bcm_l3_egress_create(unit, flags, new_egr, intf);
    388 
    389     if (NULL != new_egr) {
    390         /* Transform the entry from the new format to old one */
    391         _bcm_compat6512out_l3_egress_t(new_egr, egr);
    392         /* Deallocate memory*/
    393         sal_free(new_egr);
    394     }
    395 
    396     return rv;
    397 }
    398 
    399 /*
    400  * Function: bcm_compat6513_l3_egress_get
    401  *
    402  * Purpose:
    403  *      Compatibility function for RPC call to bcm_esw_l3_egress_get.
    404  *
    405  * Parameters:
    406  *     unit - (IN) BCM device number.
    407  *     extender_forward_entry - (IN/OUT) Forwarding entry with old format
    408  *
    409  * Returns:
    410  *     BCM_E_XXX
    411  */
    412 int
    413 bcm_compat6513_l3_egress_get(int unit, bcm_if_t intf,
    414                              bcm_compat6513_l3_egress_t *egr)
    415 {
    416     int rv;
    417     bcm_l3_egress_t *new_egr = NULL;
    418 
    419     if (NULL != egr) {
    420         /* Create from heap to avoid the stack to bloat */
    421         new_egr = (bcm_l3_egress_t *)
    422             sal_alloc(sizeof(bcm_l3_egress_t), "New Egress");
    423         if (NULL == new_egr) {
    424             return BCM_E_MEMORY;
    425         }
    426 
    427         /* Transform the entry from the old format to new one */
    428         _bcm_compat6513in_l3_egress_t(egr, new_egr);
    429     }
    430 
    431     /* Call the BCM API with new format */
    432     rv = bcm_l3_egress_get(unit, intf, new_egr);
    433 
    434     if (NULL != new_egr) {
    435         /* Transform the entry from the new format to old one */
    436         _bcm_compat6512out_l3_egress_t(new_egr, egr);
    437         /* Deallocate memory*/
    438         sal_free(new_egr);
    439     }
    440 
    441     return rv;
    442 }
    443 
    444 /*
    445  * Function: bcm_compat6513_l3_egress_find
    446  *
    447  * Purpose:
    448  *      Compatibility function for RPC call to bcm_esw_l3_egress_find.
    449  *
    450  * Parameters:
    451  *     unit - (IN) BCM device number.
    452  *     extender_forward_entry - (IN/OUT) Forwarding entry with old format
    453  *
    454  * Returns:
    455  *     BCM_E_XXX
    456  */
    457 int
    458 bcm_compat6513_l3_egress_find(int unit, bcm_compat6513_l3_egress_t *egr,
    459                               bcm_if_t *intf)
    460 {
    461     int rv;
    462     bcm_l3_egress_t *new_egr = NULL;
    463 
    464     if (NULL != egr) {
    465         /* Create from heap to avoid the stack to bloat */
    466         new_egr = (bcm_l3_egress_t *)
    467             sal_alloc(sizeof(bcm_l3_egress_t), "New Egress");
    468         if (NULL == new_egr) {
    469             return BCM_E_MEMORY;
    470         }
    471 
    472         /* Transform the entry from the old format to new one */
    473         _bcm_compat6513in_l3_egress_t(egr, new_egr);
    474     }
    475 
    476     /* Call the BCM API with new format */
    477     rv = bcm_l3_egress_find(unit, new_egr, intf);
    478 
    479     if (NULL != new_egr) {
    480         /* Transform the entry from the new format to old one */
    481         _bcm_compat6512out_l3_egress_t(new_egr, egr);
    482         /* Deallocate memory*/
    483         sal_free(new_egr);
    484     }
    485 
    486     return rv;
    487 }
    488 #endif
    489 #endif  /* BCM_RPC_SUPPORT */
    490