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_6512.c (28994B)


      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.12 routines
      8  */
      9 
     10 #ifdef	BCM_RPC_SUPPORT
     11 #include <shared/alloc.h>
     12 
     13 #include <bcm/types.h>
     14 #include <bcm/error.h>
     15 #include <bcm/l2.h>
     16 
     17 #include <bcm_int/compat/compat_6512.h>
     18 
     19 #if defined(INCLUDE_L3)
     20 /*
     21  * Function:
     22  *      _bcm_compat6512in_vxlan_vpn_config_t
     23  * Purpose:
     24  *      Convert the bcm_vxlan_vpn_config_t datatype from <=6.5.12 to
     25  *      SDK 6.5.12+
     26  * Parameters:
     27  *      from        - (IN) The <=6.5.12 version of the datatype
     28  *      to          - (OUT) The SDK 6.5.12+ version of the datatype
     29  * Returns:
     30  *      Nothing
     31  */
     32 STATIC void
     33 _bcm_compat6512in_vxlan_vpn_config_t(bcm_compat6512_vxlan_vpn_config_t *from,
     34                            bcm_vxlan_vpn_config_t *to)
     35 {
     36     bcm_vxlan_vpn_config_t_init(to);
     37     to->flags= from->flags;
     38     to->vpn = from->vpn;
     39     to->vnid = from->vnid;
     40     to->pkt_pri = from->pkt_pri;
     41     to->pkt_cfi = from->pkt_cfi;
     42     to->egress_service_tpid = from->egress_service_tpid;
     43     to->egress_service_vlan = from->egress_service_vlan;
     44     to->broadcast_group = from->broadcast_group;
     45     to->unknown_unicast_group = from->unknown_multicast_group;
     46     to->protocol_pkt = from->protocol_pkt;
     47     to->vlan = from->vlan;
     48     to->match_port_class = from->match_port_class;
     49  }
     50 
     51 /*
     52  * Function:
     53  *      _bcm_compat6512out_ecn_map_t
     54  * Purpose:
     55  *      Convert the bcm_vxlan_vpn_config_t datatype from 6.5.12+ to
     56  *      <=6.5.12
     57  * Parameters:
     58  *      from        - (IN) The SDK 6.5.8+ version of the datatype
     59  *      to          - (OUT) The <=6.5.8 version of the datatype
     60  * Returns:
     61  *      Nothing
     62  */
     63 STATIC void
     64 _bcm_compat6512out_vxlan_vpn_config_t(bcm_vxlan_vpn_config_t *from,
     65                             bcm_compat6512_vxlan_vpn_config_t *to)
     66 {
     67     to->flags= from->flags;
     68     to->vpn = from->vpn;
     69     to->vnid = from->vnid;
     70     to->pkt_pri = from->pkt_pri;
     71     to->pkt_cfi = from->pkt_cfi;
     72     to->egress_service_tpid = from->egress_service_tpid;
     73     to->egress_service_vlan = from->egress_service_vlan;
     74     to->broadcast_group = from->broadcast_group;
     75     to->unknown_unicast_group = from->unknown_multicast_group;
     76     to->protocol_pkt = from->protocol_pkt;
     77     to->vlan = from->vlan;
     78     to->match_port_class = from->match_port_class;
     79 }
     80 
     81 /*
     82  * Function: bcm_compat6512_vxlan_vpn_get
     83  *
     84  * Purpose:
     85  *      Compatibility function for RPC call to bcm_vxlan_vpn_get.
     86  *
     87  * Parameters:
     88  *      unit     - (IN)Device Number
     89  *      l2vpn   - (IN)VXLAN VPN
     90  *      info     - (IN/OUT)VXLAN VPN Config
     91  * Returns:
     92  *      BCM_E_XXXX
     93  */
     94 int
     95 bcm_compat6512_vxlan_vpn_get(int unit, bcm_vpn_t l2vpn,
     96                                      bcm_compat6512_vxlan_vpn_config_t *info)
     97 {
     98     int rv;
     99     bcm_vxlan_vpn_config_t *new_info = NULL;
    100 
    101     if (NULL != info) {
    102         /* Create from heap to avoid the stack to bloat */
    103         new_info = (bcm_vxlan_vpn_config_t *)
    104             sal_alloc(sizeof(bcm_vxlan_vpn_config_t), "New vxlan vpn config");
    105         if (NULL == new_info) {
    106             return BCM_E_MEMORY;
    107         }
    108 
    109         /* Transform the entry from the old format to new one */
    110         _bcm_compat6512in_vxlan_vpn_config_t(info, new_info);
    111     }
    112 
    113     /* Call the BCM API with new format */
    114     rv = bcm_vxlan_vpn_get(unit, l2vpn, new_info);
    115 
    116     if (NULL != new_info) {
    117         /* Transform the entry from the new format to old one */
    118         _bcm_compat6512out_vxlan_vpn_config_t(new_info, info);
    119         /* Deallocate memory*/
    120         sal_free(new_info);
    121     }
    122 
    123     return rv;
    124 }
    125 
    126 /*
    127  * Function: bcm_compat6512_vxlan_vpn_create
    128  *
    129  * Purpose:
    130  *      Compatibility function for RPC call to bcm_esw_vxlan_vpn_create.
    131  *
    132  * Parameters:
    133  *      unit     - (IN)Device Number
    134  *      info     - (IN/OUT)VXLAN VPN Config
    135  * Returns:
    136  *      BCM_E_XXXX
    137  */
    138 int
    139 bcm_compat6512_vxlan_vpn_create(int unit,
    140                                          bcm_compat6512_vxlan_vpn_config_t *info)
    141 {
    142     int rv;
    143     bcm_vxlan_vpn_config_t *new_info = NULL;
    144 
    145     if (NULL != info) {
    146         /* Create from heap to avoid the stack to bloat */
    147         new_info = (bcm_vxlan_vpn_config_t *)
    148             sal_alloc(sizeof(bcm_vxlan_vpn_config_t), "New vxlan vpn config");
    149         if (NULL == new_info) {
    150             return BCM_E_MEMORY;
    151         }
    152 
    153         /* Transform the entry from the old format to new one */
    154         _bcm_compat6512in_vxlan_vpn_config_t(info, new_info);
    155     }
    156 
    157     /* Call the BCM API with new format */
    158     rv = bcm_vxlan_vpn_create(unit, new_info);
    159 
    160     if (NULL != new_info) {
    161         /* Transform the entry from the new format to old one */
    162         _bcm_compat6512out_vxlan_vpn_config_t(new_info, info);
    163         /* Deallocate memory*/
    164         sal_free(new_info);
    165     }
    166 
    167     return rv;
    168 }
    169 #endif
    170 
    171 /*
    172  * Function:
    173  *      _bcm_compat6512in_fcoe_vsan_action_set_t
    174  * Purpose:
    175  *      Convert the bcm_ecn_map_t datatype from <=6.5.12 to
    176  *      SDK 6.5.12+
    177  * Parameters:
    178  *      from        - (IN) The <=6.5.12 version of the datatype
    179  *      to          - (OUT) The SDK 6.5.12+ version of the datatype
    180  * Returns:
    181  *      Nothing
    182  */
    183 STATIC void
    184 _bcm_compat6512in_fcoe_vsan_action_set_t(
    185     bcm_compat6512_fcoe_vsan_action_set_t *from,
    186     bcm_fcoe_vsan_action_set_t *to)
    187 {
    188     bcm_fcoe_vsan_action_set_t_init(to);
    189     to->flags = from->flags;
    190     to->new_vsan = from->new_vsan;
    191     to->new_vsan_pri = from->new_vsan_pri;
    192     to->vft = from->vft;
    193     to->ingress_if = from->ingress_if;
    194     to->dt_vsan = from->dt_vsan;
    195     to->dt_vsan_pri = from->dt_vsan_pri;
    196     to->it_vsan = from->it_vsan;
    197     to->it_vsan_pri = from->it_vsan_pri;
    198     to->ot_vsan = from->ot_vsan;
    199     to->ot_vsan_pri = from->ot_vsan_pri;
    200     to->ut_vsan = from->ut_vsan;
    201     to->ut_vsan_pri = from->ut_vsan_pri;
    202 }
    203 
    204 /*
    205  * Function:
    206  *      _bcm_compat6512out_fcoe_vsan_action_set_t
    207  * Purpose:
    208  *      Convert the bcm_field_qset_t datatype from 6.5.12+ to
    209  *      <=6.5.12
    210  * Parameters:
    211  *      from        - (IN) The SDK 6.5.12+ version of the datatype
    212  *      to          - (OUT) The <=6.5.12 version of the datatype
    213  * Returns:
    214  *      Nothing
    215  */
    216 STATIC void
    217 _bcm_compat6512out_fcoe_vsan_action_set_t(
    218     bcm_fcoe_vsan_action_set_t *from,
    219     bcm_compat6512_fcoe_vsan_action_set_t *to)
    220 {
    221     to->flags = from->flags;
    222     to->new_vsan = from->new_vsan;
    223     to->new_vsan_pri = from->new_vsan_pri;
    224     to->vft = from->vft;
    225     to->ingress_if = from->ingress_if;
    226     to->dt_vsan = from->dt_vsan;
    227     to->dt_vsan_pri = from->dt_vsan_pri;
    228     to->it_vsan = from->it_vsan;
    229     to->it_vsan_pri = from->it_vsan_pri;
    230     to->ot_vsan = from->ot_vsan;
    231     to->ot_vsan_pri = from->ot_vsan_pri;
    232     to->ut_vsan = from->ut_vsan;
    233     to->ut_vsan_pri = from->ut_vsan_pri;
    234 }
    235 
    236 /*
    237  * Function: bcm_compat658_ecn_map_get
    238  *
    239  * Purpose:
    240  *      Compatibility function for RPC call to bcm_esw_extender_forward_get.
    241  *
    242  * Parameters:
    243  *     unit - (IN) BCM device number.
    244  *     extender_forward_entry - (IN/OUT) Forwarding entry with old format
    245  *
    246  * Returns:
    247  *     BCM_E_XXX
    248  */
    249 int
    250 bcm_compat6512_fcoe_vsan_translate_action_add(int unit,
    251     bcm_fcoe_vsan_translate_key_config_t *key,
    252     bcm_compat6512_fcoe_vsan_action_set_t *action)
    253 {
    254     int rv;
    255     bcm_fcoe_vsan_action_set_t *new_action = NULL;
    256 
    257     if (NULL != action) {
    258         /* Create from heap to avoid the stack to bloat */
    259         new_action = (bcm_fcoe_vsan_action_set_t *)
    260             sal_alloc(sizeof(bcm_fcoe_vsan_action_set_t), "New Action");
    261         if (NULL == new_action) {
    262             return BCM_E_MEMORY;
    263         }
    264 
    265         /* Transform the entry from the old format to new one */
    266         _bcm_compat6512in_fcoe_vsan_action_set_t(action, new_action);
    267     }
    268 
    269     /* Call the BCM API with new format */
    270     rv = bcm_fcoe_vsan_translate_action_add(unit, key, new_action);
    271 
    272     if (NULL != new_action) {
    273         /* Transform the entry from the new format to old one */
    274         _bcm_compat6512out_fcoe_vsan_action_set_t(new_action, action);
    275         /* Deallocate memory*/
    276         sal_free(new_action);
    277     }
    278 
    279     return rv;
    280 }
    281 
    282 /*
    283  * Function:
    284  *  _bcm_compat6512in_l2_addr_t
    285  * Purpose:
    286  *  Convert the bcm_l2_addr_t datatype from <=6.5.12 to
    287  *  SDK 6.5.12+
    288  * Parameters:
    289  *  from        - (IN) The <=6.5.12 version of the datatype
    290  *  to          - (OUT) The SDK 6.5.12+ version of the datatype
    291  * Returns:
    292  *      Nothing
    293  */
    294 STATIC void
    295 _bcm_compat6512in_l2_addr_t(bcm_compat6512_l2_addr_t *from,
    296                                          bcm_l2_addr_t *to)
    297 {
    298     to->flags = from->flags;
    299     to->flags2 = from->flags2;
    300     to->station_flags = from->station_flags;
    301     sal_memcpy(to->mac, from->mac, sizeof(bcm_mac_t));
    302     to->vid = from->vid;
    303     to->port = from->port;
    304     to->modid = from->modid;
    305     to->tgid = from->tgid;
    306     to->cos_dst = from->cos_dst;
    307     to->cos_src = from->cos_src;
    308     to->l2mc_group = from->l2mc_group;
    309     to->egress_if = from->egress_if;
    310     to->block_bitmap = from->block_bitmap;
    311     to->auth = from->auth;
    312     to->group = from->group;
    313     to->distribution_class = from->distribution_class;
    314     to->encap_id = from->encap_id;
    315     to->age_state = from->age_state;
    316     to->flow_handle = from-> flow_handle;
    317     to->flow_option_handle = from->flow_option_handle;
    318     sal_memcpy(to->logical_fields, from->logical_fields,
    319             BCM_FLOW_MAX_NOF_LOGICAL_FIELDS * sizeof(bcm_flow_logical_field_t));
    320     to->num_of_fields = from->num_of_fields;
    321     to->sa_source_filter_pbmp = from->sa_source_filter_pbmp;
    322     to->tsn_flowset = from->tsn_flowset;
    323     to->sr_flowset = from->sr_flowset;
    324     to->policer_id = from->policer_id;
    325     to->taf_gate_primap = from->taf_gate_primap;
    326     to->l3mc_group = 0;
    327 }
    328 
    329 /*
    330  * Function:
    331  *  _bcm_compat6512out_l2_addr_t
    332  * Purpose:
    333  *  Convert the bcm_l2_addr_t datatype from 6.5.12+ to
    334  *  <=6.5.12
    335  * Parameters:
    336  *  from        - (IN) The SDK 6.5.12+ version of the datatype
    337  *  to          - (OUT) The <=6.5.12 version of the datatype
    338  * Returns:
    339  *  Nothing
    340  */
    341 STATIC void
    342 _bcm_compat6512out_l2_addr_t(bcm_l2_addr_t *from,
    343                              bcm_compat6512_l2_addr_t *to)
    344 {
    345     to->flags = from->flags;
    346     to->flags2 = from->flags2;
    347     to->station_flags = from->station_flags;
    348     sal_memcpy(to->mac, from->mac, sizeof(bcm_mac_t));
    349     to->vid = from->vid;
    350     to->port = from->port;
    351     to->modid = from->modid;
    352     to->tgid = from->tgid;
    353     to->cos_dst = from->cos_dst;
    354     to->cos_src = from->cos_src;
    355     to->l2mc_group = from->l2mc_group;
    356     to->egress_if = from->egress_if;
    357     to->block_bitmap = from->block_bitmap;
    358     to->auth = from->auth;
    359     to->group = from->group;
    360     to->distribution_class = from->distribution_class;
    361     to->encap_id = from->encap_id;
    362     to->age_state = from->age_state;
    363     to->flow_handle = from-> flow_handle;
    364     to->flow_option_handle = from->flow_option_handle;
    365     sal_memcpy(to->logical_fields, from->logical_fields,
    366             BCM_FLOW_MAX_NOF_LOGICAL_FIELDS * sizeof(bcm_flow_logical_field_t));
    367     to->num_of_fields = from->num_of_fields;
    368     to->sa_source_filter_pbmp = from->sa_source_filter_pbmp;
    369     to->tsn_flowset = from->tsn_flowset;
    370     to->sr_flowset = from->sr_flowset;
    371     to->policer_id = from->policer_id;
    372     to->taf_gate_primap = from->taf_gate_primap;
    373 }
    374 
    375 /*
    376  * Function: bcm_compat6512_l2_addr_add
    377  *
    378  * Purpose:
    379  *  Compatibility function for RPC call to bcm_l2_addr_add.
    380  *
    381  * Parameters:
    382  *  unit   - (IN) BCM device number.
    383  *  l2addr - (IN) l2 address entry with old format
    384  *
    385  * Returns:
    386  *     BCM_E_XXX
    387  */
    388 int
    389 bcm_compat6512_l2_addr_add(int unit,
    390                            bcm_compat6512_l2_addr_t *l2addr)
    391 {
    392     int rv = BCM_E_NONE;
    393     bcm_l2_addr_t *newl2addr = NULL;
    394 
    395     if (NULL != l2addr) {
    396         /* Create from heap to avoid the stack to bloat */
    397         newl2addr = (bcm_l2_addr_t *)
    398             sal_alloc(sizeof(bcm_l2_addr_t), "New l2 addr");
    399         if (NULL == newl2addr) {
    400             return BCM_E_MEMORY;
    401         }
    402 
    403         /* Transform the entry from the old format to new one */
    404         _bcm_compat6512in_l2_addr_t(l2addr, newl2addr);
    405     } else {
    406         return BCM_E_PARAM;
    407     }
    408 
    409     /* Call the BCM API with new format */
    410     rv = bcm_l2_addr_add(unit, newl2addr);
    411 
    412     /* Transform the entry from the new format to old one */
    413     _bcm_compat6512out_l2_addr_t(newl2addr, l2addr);
    414 
    415     /* Deallocate memory*/
    416     sal_free(newl2addr);
    417 
    418     return rv;
    419 }
    420 
    421 /*
    422  * Function: bcm_compat6512_l2_addr_multi_add
    423  *
    424  * Purpose:
    425  *  Compatibility function for RPC call to bcm_l2_addr_multi_add.
    426  *
    427  * Parameters:
    428  *  unit   - (IN) BCM device number.
    429  *  l2addr - (IN) l2 address entry with old format.
    430  *  count  - (IN) count of l2 address to add.
    431  *
    432  * Returns:
    433  *  BCM_E_XXX
    434  */
    435 int
    436 bcm_compat6512_l2_addr_multi_add(int unit,
    437                                  bcm_compat6512_l2_addr_t *l2addr,
    438                                  int count)
    439 {
    440     int rv = BCM_E_NONE;
    441     bcm_l2_addr_t *newl2addr = NULL;
    442 
    443     if (NULL != l2addr) {
    444         /* Create from heap to avoid the stack to bloat */
    445         newl2addr = (bcm_l2_addr_t *)
    446             sal_alloc(sizeof(bcm_l2_addr_t), "New l2 addr");
    447         if (NULL == newl2addr) {
    448             return BCM_E_MEMORY;
    449         }
    450 
    451         /* Transform the entry from the old format to new one */
    452         _bcm_compat6512in_l2_addr_t(l2addr, newl2addr);
    453     } else {
    454         return BCM_E_PARAM;
    455     }
    456 
    457     /* Call the BCM API with new format */
    458     rv = bcm_l2_addr_multi_add(unit, newl2addr,count);
    459 
    460     /* Transform the entry from the new format to old one */
    461     _bcm_compat6512out_l2_addr_t(newl2addr, l2addr);
    462 
    463     /* Deallocate memory*/
    464     sal_free(newl2addr);
    465 
    466     return rv;
    467 }
    468 
    469 /*
    470  * Function: bcm_compat6512_l2_addr_multi_delete
    471  *
    472  * Purpose:
    473  *  Compatibility function for RPC call to bcm_l2_addr_multi_delete.
    474  *
    475  * Parameters:
    476  *  unit   - (IN) BCM device number.
    477  *  l2addr - (IN) L2 address entry with old format.
    478  *  count  - (IN) count of l2 address to delete.
    479  *
    480  * Returns:
    481  *  BCM_E_XXX
    482  */
    483 int
    484 bcm_compat6512_l2_addr_multi_delete(int unit,
    485                                     bcm_compat6512_l2_addr_t *l2addr,
    486                                     int count)
    487 {
    488     int rv = BCM_E_NONE;
    489     bcm_l2_addr_t *newl2addr = NULL;
    490 
    491     if (NULL != l2addr) {
    492         /* Create from heap to avoid the stack to bloat */
    493         newl2addr = (bcm_l2_addr_t *)
    494             sal_alloc(sizeof(bcm_l2_addr_t), "New l2 addr");
    495         if (NULL == newl2addr) {
    496             return BCM_E_MEMORY;
    497         }
    498 
    499         /* Transform the entry from the old format to new one */
    500         _bcm_compat6512in_l2_addr_t(l2addr, newl2addr);
    501     } else {
    502         return BCM_E_PARAM;
    503     }
    504 
    505     /* Call the BCM API with new format */
    506     rv = bcm_l2_addr_multi_delete(unit, newl2addr,count);
    507 
    508     /* Transform the entry from the new format to old one */
    509     _bcm_compat6512out_l2_addr_t(newl2addr, l2addr);
    510 
    511     /* Deallocate memory*/
    512     sal_free(newl2addr);
    513 
    514     return rv;
    515 }
    516 
    517 /*
    518  * Function: bcm_compat6512_l2_addr_get
    519  *
    520  * Purpose:
    521  *  Compatibility function for RPC call to bcm_l2_addr_get.
    522  *
    523  * Parameters:
    524  *  unit     - (IN)  BCM device number.
    525  *  mac_addr - (IN)  Input mac address entry to search.
    526  *  vid      - (IN)  Input VLAN ID to search.
    527  *  l2addr   - (OUT) l2 address entry with old format.
    528  *
    529  * Returns:
    530  *  BCM_E_XXX
    531  */
    532 int
    533 bcm_compat6512_l2_addr_get(int unit,
    534                            bcm_mac_t mac_addr, bcm_vlan_t vid,
    535                            bcm_compat6512_l2_addr_t *l2addr)
    536 {
    537     int rv = BCM_E_NONE;
    538     bcm_l2_addr_t *newl2addr = NULL;
    539 
    540     if (NULL != l2addr) {
    541         /* Create from heap to avoid the stack to bloat */
    542         newl2addr = (bcm_l2_addr_t *)
    543             sal_alloc(sizeof(bcm_l2_addr_t), "New l2 addr");
    544         if (NULL == newl2addr) {
    545             return BCM_E_MEMORY;
    546         }
    547 
    548         /* Transform the entry from the old format to new one */
    549         _bcm_compat6512in_l2_addr_t(l2addr, newl2addr);
    550     } else {
    551         return BCM_E_PARAM;
    552     }
    553 
    554     /* Call the BCM API with new format */
    555     rv = bcm_l2_addr_get(unit, mac_addr, vid, newl2addr);
    556 
    557     /* Transform the entry from the new format to old one */
    558     _bcm_compat6512out_l2_addr_t(newl2addr, l2addr);
    559 
    560     /* Deallocate memory*/
    561     sal_free(newl2addr);
    562 
    563     return rv;
    564 }
    565 
    566 /*
    567  * Function: bcm_compat6512_l2_conflict_get
    568  *
    569  * Purpose:
    570  *  Compatibility function for RPC call to bcm_l2_conflict_get.
    571  *
    572  * Parameters:
    573  *  unit     - (IN)  BCM device number.
    574  *  addr     - (IN)  l2 address entry with old format.
    575  *  cf_array - (OUT) conflicting address array.
    576  *  cf_max   - (IN)  maximum conflicting address.
    577  *  cf_count - (OUT) actual count of conflicting address found.
    578  *
    579  * Returns:
    580  *  BCM_E_XXX
    581  */
    582 int
    583 bcm_compat6512_l2_conflict_get(int unit, bcm_compat6512_l2_addr_t *addr,
    584                                bcm_compat6512_l2_addr_t *cf_array, int cf_max,
    585                                int *cf_count)
    586 {
    587     int rv = BCM_E_NONE;
    588     bcm_l2_addr_t naddr;
    589     bcm_l2_addr_t *ncf_array = NULL;
    590     int i = 0;
    591 
    592     if ((NULL != addr) && (NULL != cf_array) && (0 < cf_max)) {
    593         /* Create from heap to avoid the stack to bloat */
    594         ncf_array = (bcm_l2_addr_t *)
    595                      sal_alloc(cf_max * sizeof(bcm_l2_addr_t),
    596                     "compat6512_l2_conflict_get");
    597         if (NULL == ncf_array) {
    598             return BCM_E_MEMORY;
    599         }
    600     } else {
    601         return BCM_E_PARAM;
    602     }
    603 
    604     /* Transform the entry from the old format to new one */
    605     _bcm_compat6512in_l2_addr_t(addr, &naddr);
    606 
    607     /* Call the BCM API with new format */
    608     rv = bcm_l2_conflict_get(unit, &naddr, ncf_array, cf_max, cf_count);
    609 
    610     if (rv >= 0) {
    611         for(i = 0; i < *cf_count; i++) {
    612             _bcm_compat6512out_l2_addr_t(&ncf_array[i], &cf_array[i]);
    613         }
    614     }
    615 
    616     /* Deallocate memory*/
    617     sal_free(ncf_array);
    618     return rv;
    619 }
    620 
    621 /*
    622  * Function: bcm_compat6512_l2_replace
    623  *
    624  * Purpose:
    625  *  Compatibility function for RPC call to bcm_l2_replace.
    626  *
    627  * Parameters:
    628  *  unit       - (IN) BCM device number.
    629  *  flags      - (IN) L2 replace flags.
    630  *  match_addr - (IN) L2 address entry with old format.
    631  *  new_module - (IN) module id.
    632  *  new_port   - (IN) port.
    633  *  new_trunk  - (IN) trunk group id.
    634  *
    635  * Returns:
    636  *  BCM_E_XXX
    637  */
    638 int
    639 bcm_compat6512_l2_replace(int unit, uint32 flags,
    640                           bcm_compat6512_l2_addr_t *match_addr,
    641                           bcm_module_t new_module,
    642                           bcm_port_t new_port, bcm_trunk_t new_trunk)
    643 {
    644     int rv = BCM_E_NONE;
    645     bcm_l2_addr_t *newmatch_addr = NULL;
    646 
    647     if (NULL != match_addr) {
    648         /* Create from heap to avoid the stack to bloat */
    649         newmatch_addr = (bcm_l2_addr_t *)
    650             sal_alloc(sizeof(bcm_l2_addr_t), "New l2 addr");
    651         if (NULL == newmatch_addr) {
    652             return BCM_E_MEMORY;
    653         }
    654 
    655         /* Transform the entry from the old format to new one */
    656         _bcm_compat6512in_l2_addr_t(match_addr, newmatch_addr);
    657     } else {
    658         return BCM_E_PARAM;
    659     }
    660 
    661     /* Call the BCM API with new format */
    662     rv = bcm_l2_replace(unit, flags, newmatch_addr, new_module, new_port, new_trunk);
    663 
    664     /* Transform the entry from the new format to old one */
    665     _bcm_compat6512out_l2_addr_t(newmatch_addr, match_addr);
    666 
    667     /* Deallocate memory*/
    668     sal_free(newmatch_addr);
    669 
    670     return rv;
    671 }
    672 
    673 /*
    674  * Function: bcm_compat6512_l2_replace_match
    675  *
    676  * Purpose:
    677  *  Compatibility function for RPC call to bcm_l2_replace_match.
    678  *
    679  * Parameters:
    680  *  unit              - (IN) BCM device number.
    681  *  match_addr        - (IN) l2 address entry with old format.
    682  *  mask_addr         - (IN) mask l2 address entry with old format.
    683  *  replace_addr      - (IN) replace l2 address entry in old format.
    684  *  replace_mask_addr - (IN) replace l2 mask address entry in old format.
    685  *
    686  * Returns:
    687  *  BCM_E_XXX
    688  */
    689 int
    690 bcm_compat6512_l2_replace_match(int unit, uint32 flags,
    691                                 bcm_compat6512_l2_addr_t *match_addr,
    692                                 bcm_compat6512_l2_addr_t *mask_addr,
    693                                 bcm_compat6512_l2_addr_t *replace_addr,
    694                                 bcm_compat6512_l2_addr_t *replace_mask_addr)
    695 {
    696     int rv = BCM_E_NONE;
    697     bcm_l2_addr_t *newmatch_addr = NULL;
    698     bcm_l2_addr_t *newmask_addr = NULL;
    699     bcm_l2_addr_t *newreplace_addr = NULL;
    700     bcm_l2_addr_t *newreplace_mask_addr = NULL;
    701 
    702     if ((NULL != match_addr) && (NULL != mask_addr) &&
    703             (NULL != replace_addr) && (NULL != replace_mask_addr)) {
    704         /* Create from heap to avoid the stack to bloat */
    705         newmatch_addr = (bcm_l2_addr_t *)
    706             sal_alloc(sizeof(bcm_l2_addr_t), "New l2 addr");
    707         if (NULL == newmatch_addr) {
    708             return BCM_E_MEMORY;
    709         }
    710 
    711         newmask_addr = (bcm_l2_addr_t *)
    712             sal_alloc(sizeof(bcm_l2_addr_t), "New l2 addr mask");
    713         if (NULL == newmask_addr) {
    714             sal_free(newmatch_addr);
    715             return BCM_E_MEMORY;
    716         }
    717 
    718         newreplace_addr = (bcm_l2_addr_t *)
    719             sal_alloc(sizeof(bcm_l2_addr_t), "Replace l2 addr");
    720         if (NULL == newreplace_addr) {
    721             sal_free(newmatch_addr);
    722             sal_free(newmask_addr);
    723             return BCM_E_MEMORY;
    724         }
    725 
    726         newreplace_mask_addr = (bcm_l2_addr_t *)
    727             sal_alloc(sizeof(bcm_l2_addr_t), "Replace l2 addr mask");
    728         if (NULL == newreplace_mask_addr) {
    729             sal_free(newmatch_addr);
    730             sal_free(newmask_addr);
    731             sal_free(newreplace_addr);
    732             return BCM_E_MEMORY;
    733         }
    734 
    735         /* Transform the entry from the old format to new one */
    736         _bcm_compat6512in_l2_addr_t(match_addr, newmatch_addr);
    737         _bcm_compat6512in_l2_addr_t(mask_addr, newmask_addr);
    738         _bcm_compat6512in_l2_addr_t(replace_addr, newreplace_addr);
    739         _bcm_compat6512in_l2_addr_t(replace_mask_addr, newreplace_mask_addr);
    740     } else {
    741         return BCM_E_PARAM;
    742     }
    743 
    744     /* Call the BCM API with new format */
    745     rv = bcm_l2_replace_match(unit, flags, newmatch_addr, newmask_addr,
    746             newreplace_addr, newreplace_mask_addr);
    747 
    748     /* Transform the entry from the new format to old one */
    749     _bcm_compat6512out_l2_addr_t(newmatch_addr, match_addr);
    750     _bcm_compat6512out_l2_addr_t(newmask_addr, mask_addr);
    751     _bcm_compat6512out_l2_addr_t(newreplace_addr, replace_addr);
    752     _bcm_compat6512out_l2_addr_t(newreplace_mask_addr, replace_mask_addr);
    753 
    754     /* Deallocate memory*/
    755     sal_free(newmatch_addr);
    756     sal_free(newmask_addr);
    757     sal_free(newreplace_addr);
    758     sal_free(newreplace_mask_addr);
    759 
    760     return rv;
    761 }
    762 
    763 /*
    764  * Function: bcm_compat6512_l2_stat_get
    765  *
    766  * Purpose:
    767  *  Compatibility function for RPC call to bcm_l2_stat_get.
    768  *
    769  * Parameters:
    770  *  unit   - (IN)  BCM device number.
    771  *  l2addr - (IN)  l2 address entry with old format.
    772  *  stat   - (IN)  stat to collect.
    773  *  val    - (OUT) stat value.
    774  *
    775  * Returns:
    776  *  BCM_E_XXX
    777  */
    778 int
    779 bcm_compat6512_l2_stat_get(int unit,
    780                            bcm_compat6512_l2_addr_t *l2addr,
    781                            bcm_l2_stat_t stat, uint64 *val)
    782 {
    783     int rv = BCM_E_NONE;
    784     bcm_l2_addr_t *newl2addr = NULL;
    785 
    786     if (NULL != l2addr) {
    787         /* Create from heap to avoid the stack to bloat */
    788         newl2addr = (bcm_l2_addr_t *)
    789             sal_alloc(sizeof(bcm_l2_addr_t), "New l2 addr");
    790         if (NULL == newl2addr) {
    791             return BCM_E_MEMORY;
    792         }
    793 
    794         /* Transform the entry from the old format to new one */
    795         _bcm_compat6512in_l2_addr_t(l2addr, newl2addr);
    796     } else {
    797         return BCM_E_PARAM;
    798     }
    799 
    800     /* Call the BCM API with new format */
    801     rv = bcm_l2_stat_get(unit, newl2addr, stat, val);
    802 
    803     /* Transform the entry from the new format to old one */
    804     _bcm_compat6512out_l2_addr_t(newl2addr, l2addr);
    805 
    806     /* Deallocate memory*/
    807     sal_free(newl2addr);
    808 
    809     return rv;
    810 }
    811 
    812 /*
    813  * Function: bcm_compat6512_l2_stat_get32
    814  *
    815  * Purpose:
    816  *  Compatibility function for RPC call to bcm_l2_stat_get32.
    817  *
    818  * Parameters:
    819  *  unit   - (IN)  BCM device number.
    820  *  l2addr - (IN)  l2 address entry with old format.
    821  *  stat   - (IN)  stat to collect.
    822  *  val    - (OUT) stat value.
    823  *
    824  * Returns:
    825  *  BCM_E_XXX
    826  */
    827 int
    828 bcm_compat6512_l2_stat_get32(int unit,
    829                              bcm_compat6512_l2_addr_t *l2addr,
    830                              bcm_l2_stat_t stat, uint32 *val)
    831 {
    832     int rv = BCM_E_NONE;
    833     bcm_l2_addr_t *newl2addr = NULL;
    834 
    835     if (NULL != l2addr) {
    836         /* Create from heap to avoid the stack to bloat */
    837         newl2addr = (bcm_l2_addr_t *)
    838             sal_alloc(sizeof(bcm_l2_addr_t), "New l2 addr");
    839         if (NULL == newl2addr) {
    840             return BCM_E_MEMORY;
    841         }
    842 
    843         /* Transform the entry from the old format to new one */
    844         _bcm_compat6512in_l2_addr_t(l2addr, newl2addr);
    845     } else {
    846         return BCM_E_PARAM;
    847     }
    848 
    849     /* Call the BCM API with new format */
    850     rv = bcm_l2_stat_get32(unit, newl2addr, stat, val);
    851 
    852     /* Transform the entry from the new format to old one */
    853     _bcm_compat6512out_l2_addr_t(newl2addr, l2addr);
    854 
    855     /* Deallocate memory*/
    856     sal_free(newl2addr);
    857 
    858     return rv;
    859 }
    860 
    861 /*
    862  * Function: bcm_compat6512_l2_stat_set
    863  *
    864  * Purpose:
    865  *  Compatibility function for RPC call to bcm_l2_stat_set.
    866  *
    867  * Parameters:
    868  *  unit   - (IN) BCM device number.
    869  *  l2addr - (IN) l2 address entry with old format.
    870  *  stat   - (IN) stat to set.
    871  *  val    - (IN) stat value.
    872  *
    873  * Returns:
    874  *  BCM_E_XXX
    875  */
    876 int
    877 bcm_compat6512_l2_stat_set(int unit,
    878                            bcm_compat6512_l2_addr_t *l2addr,
    879                            bcm_l2_stat_t stat, uint64 val)
    880 {
    881     int rv = BCM_E_NONE;
    882     bcm_l2_addr_t *newl2addr = NULL;
    883 
    884     if (NULL != l2addr) {
    885         /* Create from heap to avoid the stack to bloat */
    886         newl2addr = (bcm_l2_addr_t *)
    887             sal_alloc(sizeof(bcm_l2_addr_t), "New l2 addr");
    888         if (NULL == newl2addr) {
    889             return BCM_E_MEMORY;
    890         }
    891 
    892         /* Transform the entry from the old format to new one */
    893         _bcm_compat6512in_l2_addr_t(l2addr, newl2addr);
    894     } else {
    895         return BCM_E_PARAM;
    896     }
    897 
    898     /* Call the BCM API with new format */
    899     rv = bcm_l2_stat_set(unit, newl2addr, stat, val);
    900 
    901     /* Transform the entry from the new format to old one */
    902     _bcm_compat6512out_l2_addr_t(newl2addr, l2addr);
    903 
    904     /* Deallocate memory*/
    905     sal_free(newl2addr);
    906 
    907     return rv;
    908 }
    909 
    910 /*
    911  * Function: bcm_compat6512_l2_stat_set32
    912  *
    913  * Purpose:
    914  *  Compatibility function for RPC call to bcm_l2_stat_set32.
    915  *
    916  * Parameters:
    917  *  unit   - (IN) BCM device number.
    918  *  l2addr - (IN) l2 address entry with old format.
    919  *  stat   - (IN) stat to set.
    920  *  val    - (IN) stat value.
    921  *
    922  * Returns:
    923  *  BCM_E_XXX
    924  */
    925 int
    926 bcm_compat6512_l2_stat_set32(int unit,
    927                              bcm_compat6512_l2_addr_t *l2addr,
    928                              bcm_l2_stat_t stat, uint32 val)
    929 {
    930     int rv = BCM_E_NONE;
    931     bcm_l2_addr_t *newl2addr = NULL;
    932 
    933     if (NULL != l2addr) {
    934         /* Create from heap to avoid the stack to bloat */
    935         newl2addr = (bcm_l2_addr_t *)
    936             sal_alloc(sizeof(bcm_l2_addr_t), "New l2 addr");
    937         if (NULL == newl2addr) {
    938             return BCM_E_MEMORY;
    939         }
    940 
    941         /* Transform the entry from the old format to new one */
    942         _bcm_compat6512in_l2_addr_t(l2addr, newl2addr);
    943     } else {
    944         return BCM_E_PARAM;
    945     }
    946 
    947     /* Call the BCM API with new format */
    948     rv = bcm_l2_stat_set32(unit, newl2addr, stat, val);
    949 
    950     /* Transform the entry from the new format to old one */
    951     _bcm_compat6512out_l2_addr_t(newl2addr, l2addr);
    952 
    953     /* Deallocate memory*/
    954     sal_free(newl2addr);
    955 
    956     return rv;
    957 }
    958 
    959 /*
    960  * Function: bcm_compat6512_l2_stat_enable_set
    961  *
    962  * Purpose:
    963  *  Compatibility function for RPC call to bcm_l2_stat_enable_set.
    964  *
    965  * Parameters:
    966  *  unit   - (IN) BCM device number.
    967  *  l2addr - (IN) l2 address entry with old format.
    968  *  enable - (IN) enable value.
    969  *
    970  * Returns:
    971  *  BCM_E_XXX
    972  */
    973 int
    974 bcm_compat6512_l2_stat_enable_set(int unit,
    975                                   bcm_compat6512_l2_addr_t *l2addr,
    976                                   int enable)
    977 {
    978     int rv = BCM_E_NONE;
    979     bcm_l2_addr_t *newl2addr = NULL;
    980 
    981     if (NULL != l2addr) {
    982         /* Create from heap to avoid the stack to bloat */
    983         newl2addr = (bcm_l2_addr_t *)
    984             sal_alloc(sizeof(bcm_l2_addr_t), "New l2 addr");
    985         if (NULL == newl2addr) {
    986             return BCM_E_MEMORY;
    987         }
    988 
    989         /* Transform the entry from the old format to new one */
    990         _bcm_compat6512in_l2_addr_t(l2addr, newl2addr);
    991     } else {
    992         return BCM_E_PARAM;
    993     }
    994 
    995     /* Call the BCM API with new format */
    996     rv = bcm_l2_stat_enable_set(unit, newl2addr, enable);
    997 
    998     /* Transform the entry from the new format to old one */
    999     _bcm_compat6512out_l2_addr_t(newl2addr, l2addr);
   1000 
   1001     /* Deallocate memory*/
   1002     sal_free(newl2addr);
   1003 
   1004     return rv;
   1005 }
   1006 #endif  /* BCM_RPC_SUPPORT */