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_657.c (29093B)


      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.7 routines
      8  */
      9 
     10 #ifdef	BCM_RPC_SUPPORT
     11 #include <shared/alloc.h>
     12 #include <bcm/error.h>
     13 #include <bcm_int/compat/compat_657.h>
     14 #include <bcm/port.h> 
     15 #if defined(INCLUDE_L3)
     16 #include <bcm/extender.h>
     17 
     18 /*
     19  * Function:
     20  *      _bcm_compat657in_extender_forward_t
     21  * Purpose:
     22  *      Convert the bcm_extender_forward_t datatype from <=6.5.7 to
     23  *      SDK 6.5.8+
     24  * Parameters:
     25  *      from        - (IN) The <=6.5.7 version of the datatype
     26  *      to          - (OUT) The SDK 6.5.8+ version of the datatype
     27  * Returns:
     28  *      Nothing
     29  */
     30 STATIC void
     31 _bcm_compat657in_extender_forward_t(bcm_compat657_extender_forward_t *from,
     32                                     bcm_extender_forward_t *to)
     33 {
     34     bcm_extender_forward_t_init(to);
     35     to->flags = from->flags;
     36     to->name_space = from->name_space;
     37     to->extended_port_vid = from->extended_port_vid;
     38     to->dest_port = from->dest_port;
     39     to->dest_multicast = from->dest_multicast;
     40     to->extender_forward_id = from->extender_forward_id;
     41 }
     42 
     43 /*
     44  * Function:
     45  *      _bcm_compat657out_extender_forward_t
     46  * Purpose:
     47  *      Convert the bcm_field_qset_t datatype from 6.5.8+ to
     48  *      <=6.5.7
     49  * Parameters:
     50  *      from        - (IN) The SDK 6.5.8+ version of the datatype
     51  *      to          - (OUT) The <=6.5.7 version of the datatype
     52  * Returns:
     53  *      Nothing
     54  */
     55 STATIC void
     56 _bcm_compat657out_extender_forward_t(bcm_extender_forward_t *from,
     57                                      bcm_compat657_extender_forward_t *to)
     58 {
     59     to->flags = from->flags;
     60     to->name_space = from->name_space;
     61     to->extended_port_vid = from->extended_port_vid;
     62     to->dest_port = from->dest_port;
     63     to->dest_multicast = from->dest_multicast;
     64     to->extender_forward_id = from->extender_forward_id;
     65 }
     66 
     67 /*
     68  * Function: bcm_compat657_extender_forward_add
     69  *
     70  * Purpose:
     71  *      Compatibility function for RPC call to bcm_esw_extender_forward_add.
     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_compat657_extender_forward_add(int unit, bcm_compat657_extender_forward_t
     82                                    *extender_forward_entry)
     83 {
     84     int rv;
     85     bcm_extender_forward_t *new_extender_forward_entry = NULL;
     86 
     87     if (NULL != extender_forward_entry) {
     88         /* Create from heap to avoid the stack to bloat */
     89         new_extender_forward_entry = (bcm_extender_forward_t *)
     90             sal_alloc(sizeof(bcm_extender_forward_t), "New Extender Fwd Entry");
     91         if (NULL == new_extender_forward_entry) {
     92             return BCM_E_MEMORY;
     93         }
     94 
     95         /* Transform the entry from the old format to new one */
     96         _bcm_compat657in_extender_forward_t(extender_forward_entry,
     97                                             new_extender_forward_entry);
     98     }
     99 
    100     /* Call the BCM API with new format */
    101     rv = bcm_extender_forward_add(unit, new_extender_forward_entry);
    102 
    103     if (NULL != new_extender_forward_entry) {
    104         /* Transform the entry from the new format to old one */
    105         _bcm_compat657out_extender_forward_t(new_extender_forward_entry,
    106                                              extender_forward_entry);
    107 
    108         /* Deallocate memory*/
    109         sal_free(new_extender_forward_entry);
    110     }
    111 
    112     return rv;
    113 }
    114 
    115 /*
    116  * Function: bcm_compat657_extender_forward_delete
    117  *
    118  * Purpose:
    119  *      Compatibility function for RPC call to bcm_esw_extender_forward_delete.
    120  *
    121  * Parameters:
    122  *     unit - (IN) BCM device number.
    123  *     extender_forward_entry - (IN) Forwarding entry with old format
    124  *
    125  * Returns:
    126  *     BCM_E_XXX
    127  */
    128 int
    129 bcm_compat657_extender_forward_delete(int unit, bcm_compat657_extender_forward_t
    130                                       *extender_forward_entry)
    131 {
    132     int rv;
    133     bcm_extender_forward_t *new_extender_forward_entry = NULL;
    134 
    135     if (NULL != extender_forward_entry) {
    136         /* Create from heap to avoid the stack to bloat */
    137         new_extender_forward_entry = (bcm_extender_forward_t *)
    138             sal_alloc(sizeof(bcm_extender_forward_t), "New Extender Fwd Entry");
    139         if (NULL == new_extender_forward_entry) {
    140             return BCM_E_MEMORY;
    141         }
    142 
    143         /* Transform the entry from the old format to new one */
    144         _bcm_compat657in_extender_forward_t(extender_forward_entry,
    145                                             new_extender_forward_entry);
    146     }
    147 
    148     /* Call the BCM API with new format */
    149     rv = bcm_extender_forward_delete(unit, new_extender_forward_entry);
    150 
    151     if (NULL != new_extender_forward_entry) {
    152         /* Deallocate memory*/
    153         sal_free(new_extender_forward_entry);
    154     }
    155 
    156     return rv;
    157 }
    158 
    159 /*
    160  * Function: bcm_compat657_extender_forward_get
    161  *
    162  * Purpose:
    163  *      Compatibility function for RPC call to bcm_esw_extender_forward_get.
    164  *
    165  * Parameters:
    166  *     unit - (IN) BCM device number.
    167  *     extender_forward_entry - (IN/OUT) Forwarding entry with old format
    168  *
    169  * Returns:
    170  *     BCM_E_XXX
    171  */
    172 int
    173 bcm_compat657_extender_forward_get(int unit, bcm_compat657_extender_forward_t
    174                                    *extender_forward_entry)
    175 {
    176     int rv;
    177     bcm_extender_forward_t *new_extender_forward_entry = NULL;
    178 
    179     if (NULL != extender_forward_entry) {
    180         /* Create from heap to avoid the stack to bloat */
    181         new_extender_forward_entry = (bcm_extender_forward_t *)
    182             sal_alloc(sizeof(bcm_extender_forward_t), "New Extender Fwd Entry");
    183         if (NULL == new_extender_forward_entry) {
    184             return BCM_E_MEMORY;
    185         }
    186 
    187         /* Transform the entry from the old format to new one */
    188         _bcm_compat657in_extender_forward_t(extender_forward_entry,
    189                                             new_extender_forward_entry);
    190     }
    191 
    192     /* Call the BCM API with new format */
    193     rv = bcm_extender_forward_get(unit, new_extender_forward_entry);
    194 
    195     if (NULL != new_extender_forward_entry) {
    196         /* Transform the entry from the new format to old one */
    197         _bcm_compat657out_extender_forward_t(new_extender_forward_entry,
    198                                              extender_forward_entry);
    199         /* Deallocate memory*/
    200         sal_free(new_extender_forward_entry);
    201     }
    202 
    203     return rv;
    204 }
    205 
    206 /*
    207  * Function:
    208  *      _bcm_compat657in_mpls_tunnel_switch_t
    209  * Purpose:
    210  *      Convert the bcm_mpls_tunnel_switch_t datatype from <=6.5.7 to
    211  *      SDK 6.5.8+
    212  * Parameters:
    213  *      from        - (IN) The <=6.5.7 version of the datatype
    214  *      to          - (OUT) The SDK 6.5.8+ version of the datatype
    215  * Returns:
    216  *      Nothing
    217  */
    218 STATIC void
    219 _bcm_compat657in_mpls_tunnel_switch_t(bcm_compat657_mpls_tunnel_switch_t *from,
    220                                     bcm_mpls_tunnel_switch_t *to)
    221 {
    222     bcm_mpls_tunnel_switch_t_init(to);
    223     to->flags = from->flags;
    224     to->label = from->label;
    225     to->second_label = from->second_label;
    226     to->port = from->port;
    227     to->action = from->action;
    228     to->action_if_bos = from->action_if_bos;
    229     to->action_if_not_bos = from->action_if_not_bos;
    230     to->mc_group = from->mc_group;
    231     to->exp_map = from->exp_map;
    232     to->int_pri = from->int_pri;
    233     to->policer_id = from->policer_id;
    234     to->vpn = from->vpn;
    235     to->egress_label = from->egress_label;
    236     to->egress_if = from->egress_if;
    237     to->ingress_if = from->ingress_if;
    238     to->mtu = from->mtu;
    239     to->qos_map_id = from->qos_map_id;
    240     to->failover_id = from->failover_id;
    241     to->tunnel_id = from->tunnel_id;
    242     to->failover_tunnel_id = from->failover_tunnel_id;
    243     to->tunnel_if = from->tunnel_if;
    244     to->egress_port = from->egress_port;
    245     to->oam_global_context_id = from->oam_global_context_id;
    246     to->class_id = from->class_id;
    247     to->inlif_counting_profile = from->inlif_counting_profile;
    248     to->ecn_map_id = from->ecn_map_id;
    249     to->tunnel_term_ecn_map_id = from->tunnel_term_ecn_map_id;
    250 }
    251 
    252 /*
    253  * Function:
    254  *      _bcm_compat657out_mpls_tunnel_switch_t
    255  * Purpose:
    256  *      Convert the bcm_mpls_tunnel_switch_t datatype from 6.5.8+ to
    257  *      <=6.5.7
    258  * Parameters:
    259  *      from        - (IN) The SDK 6.5.8+ version of the datatype
    260  *      to          - (OUT) The <=6.5.7 version of the datatype
    261  * Returns:
    262  *      Nothing
    263  */
    264 STATIC void
    265 _bcm_compat657out_mpls_tunnel_switch_t(bcm_mpls_tunnel_switch_t *from,
    266                                      bcm_compat657_mpls_tunnel_switch_t *to)
    267 {
    268     to->flags = from->flags;
    269     to->label = from->label;
    270     to->second_label = from->second_label;
    271     to->port = from->port;
    272     to->action = from->action;
    273     to->action_if_bos = from->action_if_bos;
    274     to->action_if_not_bos = from->action_if_not_bos;
    275     to->mc_group = from->mc_group;
    276     to->exp_map = from->exp_map;
    277     to->int_pri = from->int_pri;
    278     to->policer_id = from->policer_id;
    279     to->vpn = from->vpn;
    280     to->egress_label = from->egress_label;
    281     to->egress_if = from->egress_if;
    282     to->ingress_if = from->ingress_if;
    283     to->mtu = from->mtu;
    284     to->qos_map_id = from->qos_map_id;
    285     to->failover_id = from->failover_id;
    286     to->tunnel_id = from->tunnel_id;
    287     to->failover_tunnel_id = from->failover_tunnel_id;
    288     to->tunnel_if = from->tunnel_if;
    289     to->egress_port = from->egress_port;
    290     to->oam_global_context_id = from->oam_global_context_id;
    291     to->class_id = from->class_id;
    292     to->inlif_counting_profile = from->inlif_counting_profile;
    293     to->ecn_map_id = from->ecn_map_id;
    294     to->tunnel_term_ecn_map_id = from->tunnel_term_ecn_map_id;
    295 }
    296 
    297 /*
    298  * Function: bcm_compat657_mpls_tunnel_switch_add
    299  *
    300  * Purpose:
    301  *      Compatibility function for RPC call to bcm_mpls_tunnel_switch_add
    302  *
    303  * Parameters:
    304  *     unit - (IN) BCM device number.
    305  *     bcm_mpls_tunnel_switch_t - (IN/OUT) Tunnel entry with old format
    306  *
    307  * Returns:
    308  *     BCM_E_XXX
    309  */
    310 int
    311 bcm_compat657_mpls_tunnel_switch_add (int unit,
    312                                       bcm_compat657_mpls_tunnel_switch_t *info)
    313 {
    314     int rv;
    315     bcm_mpls_tunnel_switch_t *new_info = NULL;
    316 
    317     if (NULL != info) {
    318         /* Create from heap to avoid the stack to bloat */
    319         new_info = (bcm_mpls_tunnel_switch_t *)
    320             sal_alloc(sizeof(bcm_mpls_tunnel_switch_t),
    321                       "New MPLS tunnel switch entry");
    322         if (NULL == new_info) {
    323             return BCM_E_MEMORY;
    324         }
    325 
    326         /* Transform the entry from the old format to new one */
    327         _bcm_compat657in_mpls_tunnel_switch_t(info, new_info);
    328     }
    329 
    330     /* Call the BCM API with new format */
    331     rv = bcm_mpls_tunnel_switch_add (unit, new_info);
    332 
    333     if (NULL != new_info) {
    334         /* Transform the entry from the new format to old one */
    335         _bcm_compat657out_mpls_tunnel_switch_t(new_info , info);
    336 
    337         /* Deallocate memory*/
    338         sal_free(new_info);
    339     }
    340 
    341     return rv;
    342 }
    343 
    344 /*
    345  * Function: bcm_compat657_mpls_tunnel_switch_create
    346  *
    347  * Purpose:
    348  *      Compatibility function for RPC call to bcm_mpls_tunnel_switch_create
    349  *
    350  * Parameters:
    351  *     unit - (IN) BCM device number.
    352  *     bcm_mpls_tunnel_switch_t - (IN/OUT) Tunnel entry with old format
    353  *
    354  * Returns:
    355  *     BCM_E_XXX
    356  */
    357 int
    358 bcm_compat657_mpls_tunnel_switch_create (int unit,
    359                                     bcm_compat657_mpls_tunnel_switch_t *info)
    360 {
    361     int rv;
    362     bcm_mpls_tunnel_switch_t *new_info = NULL;
    363 
    364     if (NULL != info) {
    365         /* Create from heap to avoid the stack to bloat */
    366         new_info = (bcm_mpls_tunnel_switch_t *)
    367             sal_alloc(sizeof(bcm_mpls_tunnel_switch_t),
    368                       "New MPLS tunnel switch entry");
    369         if (NULL == new_info) {
    370             return BCM_E_MEMORY;
    371         }
    372 
    373         /* Transform the entry from the old format to new one */
    374         _bcm_compat657in_mpls_tunnel_switch_t(info, new_info);
    375     }
    376 
    377     /* Call the BCM API with new format */
    378     rv = bcm_mpls_tunnel_switch_create (unit, new_info);
    379 
    380     if (NULL != new_info) {
    381         /* Transform the entry from the new format to old one */
    382         _bcm_compat657out_mpls_tunnel_switch_t(new_info , info);
    383 
    384         /* Deallocate memory*/
    385         sal_free(new_info);
    386     }
    387 
    388     return rv;
    389 }
    390 
    391 /*
    392  * Function: bcm_compat657_mpls_tunnel_switch_delete
    393  *
    394  * Purpose:
    395  *      Compatibility function for RPC call to bcm_mpls_tunnel_switch_delete
    396  *
    397  * Parameters:
    398  *     unit - (IN) BCM device number.
    399  *     bcm_mpls_tunnel_switch_t - (IN/OUT) Tunnel entry with old format
    400  *
    401  * Returns:
    402  *     BCM_E_XXX
    403  */
    404 int
    405 bcm_compat657_mpls_tunnel_switch_delete (int unit,
    406                                     bcm_compat657_mpls_tunnel_switch_t *info)
    407 {
    408     int rv;
    409     bcm_mpls_tunnel_switch_t *new_info = NULL;
    410 
    411     if (NULL != info) {
    412         /* Create from heap to avoid the stack to bloat */
    413         new_info = (bcm_mpls_tunnel_switch_t *)
    414             sal_alloc(sizeof(bcm_mpls_tunnel_switch_t),
    415                       "New MPLS tunnel switch entry");
    416         if (NULL == new_info) {
    417             return BCM_E_MEMORY;
    418         }
    419 
    420         /* Transform the entry from the old format to new one */
    421         _bcm_compat657in_mpls_tunnel_switch_t(info, new_info);
    422     }
    423 
    424     /* Call the BCM API with new format */
    425     rv = bcm_mpls_tunnel_switch_delete (unit, new_info);
    426 
    427     if (NULL != new_info) {
    428         /* Transform the entry from the new format to old one */
    429         _bcm_compat657out_mpls_tunnel_switch_t(new_info , info);
    430 
    431         /* Deallocate memory*/
    432         sal_free(new_info);
    433     }
    434 
    435     return rv;
    436 }
    437 
    438 /*
    439  * Function: bcm_compat657_mpls_tunnel_switch_get
    440  *
    441  * Purpose:
    442  *      Compatibility function for RPC call to bcm_mpls_tunnel_switch_get
    443  *
    444  * Parameters:
    445  *     unit - (IN) BCM device number.
    446  *     bcm_mpls_tunnel_switch_t - (IN/OUT) Tunnel entry with old format
    447  *
    448  * Returns:
    449  *     BCM_E_XXX
    450  */
    451 int
    452 bcm_compat657_mpls_tunnel_switch_get (int unit,
    453                                       bcm_compat657_mpls_tunnel_switch_t *info)
    454 {
    455     int rv;
    456     bcm_mpls_tunnel_switch_t *new_info = NULL;
    457 
    458     if (NULL != info) {
    459         /* Create from heap to avoid the stack to bloat */
    460         new_info = (bcm_mpls_tunnel_switch_t *)
    461             sal_alloc(sizeof(bcm_mpls_tunnel_switch_t),
    462                       "New MPLS tunnel switch entry");
    463         if (NULL == new_info) {
    464             return BCM_E_MEMORY;
    465         }
    466 
    467         /* Transform the entry from the old format to new one */
    468         _bcm_compat657in_mpls_tunnel_switch_t(info, new_info);
    469     }
    470 
    471     /* Call the BCM API with new format */
    472     rv = bcm_mpls_tunnel_switch_get (unit, new_info);
    473 
    474     if (NULL != new_info) {
    475         /* Transform the entry from the new format to old one */
    476         _bcm_compat657out_mpls_tunnel_switch_t(new_info , info);
    477 
    478         /* Deallocate memory*/
    479         sal_free(new_info);
    480     }
    481 
    482     return rv;
    483 }
    484 #endif /* INCLUDE_L3 */
    485 /*
    486  * Function:
    487  *      _bcm_compat657in_port_e2efc_remote_port_config_t
    488  * Purpose:
    489  *      Convert the bcm_port_e2efc_remote_port_config_t datatype from <=6.5.7 to
    490  *      SDK 6.5.8+
    491  * Parameters:
    492  *      from        - (IN) The <=6.5.7 version of the datatype
    493  *      to          - (OUT) The SDK 6.5.8+ version of the datatype
    494  * Returns:
    495  *      Nothing
    496  */
    497 STATIC void
    498 _bcm_compat657in_port_e2efc_remote_port_config_t(bcm_compat657_port_e2efc_remote_port_config_t *from,
    499                                     bcm_port_e2efc_remote_port_config_t *to)
    500 {
    501     bcm_port_e2efc_remote_port_config_t_init(to);
    502     to->remote_module = from->remote_module;
    503     to->remote_port = from->remote_port;
    504     to->xoff_threshold_bytes = from->xoff_threshold_bytes;
    505     to->xoff_threshold_packets = from->xoff_threshold_packets;
    506     to->xon_threshold_bytes = from->xon_threshold_bytes;
    507     to->xon_threshold_packets = from->xon_threshold_packets;
    508     to->drop_threshold_bytes = from->drop_threshold_bytes;
    509     to->drop_threshold_packets = from->drop_threshold_packets;
    510 }
    511 
    512 /*
    513  * Function:
    514  *      _bcm_compat657out_port_e2efc_remote_port_config_t
    515  * Purpose:
    516  *      Convert the bcm_port_e2efc_remote_port_config_t datatype from 6.5.8+ to
    517  *      SDK <= 6.5.7
    518  * Parameters:
    519  *      from        - (IN) The SDK 6.5.8+ version of the datatype
    520  *      to          - (OUT) The SDK <=6.5.7 version of the datatype
    521  * Returns:
    522  *      Nothing
    523  */
    524 STATIC void
    525 _bcm_compat657out_port_e2efc_remote_port_config_t(bcm_port_e2efc_remote_port_config_t *from,
    526                                                   bcm_compat657_port_e2efc_remote_port_config_t *to)
    527 {
    528     to->remote_module = from->remote_module;
    529     to->remote_port = from->remote_port;
    530     to->xoff_threshold_bytes = from->xoff_threshold_bytes;
    531     to->xoff_threshold_packets = from->xoff_threshold_packets;
    532     to->xon_threshold_bytes = from->xon_threshold_bytes;
    533     to->xon_threshold_packets = from->xon_threshold_packets;
    534     to->drop_threshold_bytes = from->drop_threshold_bytes;
    535     to->drop_threshold_packets = from->drop_threshold_packets;
    536 }
    537 /*
    538  * Function: bcm_compat657_port_e2efc_remote_port_add
    539  *
    540  * Purpose:
    541  *      Compatibility function for RPC call to bcm_port_e2efc_remote_port_add
    542  *
    543  * Parameters:
    544  *     unit - (IN) BCM device number.
    545  *     bcm_port_e2efc_remote_port_config_t - (IN) e2efc_remote_port_info with
    546  *                                                old format
    547  *     rport_handle_id - (OUT) output handle to be used in get and set API.
    548  *
    549  * Returns:
    550  *     BCM_E_XXX
    551  */
    552 int
    553 bcm_compat657_port_e2efc_remote_port_add (int unit,
    554                             bcm_compat657_port_e2efc_remote_port_config_t *info,
    555                             int *rport_handle_id)
    556 {
    557     int rv;
    558     bcm_port_e2efc_remote_port_config_t *new_info = NULL;
    559 
    560     if (NULL != info) {
    561         /* Create from heap to avoid the stack to bloat */
    562         new_info = (bcm_port_e2efc_remote_port_config_t *)
    563             sal_alloc(sizeof(bcm_port_e2efc_remote_port_config_t),
    564                       "New E2EFC Remote port info");
    565         if (NULL == new_info) {
    566             return BCM_E_MEMORY;
    567         }
    568 
    569         /* Transform the info from the old format to new one */
    570         _bcm_compat657in_port_e2efc_remote_port_config_t(info, new_info);
    571     }
    572 
    573     /* Call the BCM API with new format */
    574     rv = bcm_port_e2efc_remote_port_add (unit, new_info, rport_handle_id);
    575 
    576     if (NULL != new_info) {
    577         /* Transform the info from the new format to old one */
    578         _bcm_compat657out_port_e2efc_remote_port_config_t(new_info , info);
    579 
    580         /* Deallocate memory*/
    581         sal_free(new_info);
    582     }
    583 
    584     return rv;
    585 }
    586 
    587 /*
    588  * Function: bcm_compat657_port_e2efc_remote_port_set
    589  *
    590  * Purpose:
    591  *      Compatibility function for RPC call to bcm_port_e2efc_remote_port_set
    592  *
    593  * Parameters:
    594  *     unit - (IN) BCM device number.
    595  *     rport_handle_id - (IN) output handle to be used in get and set API.
    596  *     bcm_port_e2efc_remote_port_config_t - (IN) e2efc_remote_port_info with
    597  *                                                old format
    598  *
    599  * Returns:
    600  *     BCM_E_XXX
    601  */
    602 int
    603 bcm_compat657_port_e2efc_remote_port_set (int unit, int rport_handle_id,
    604                             bcm_compat657_port_e2efc_remote_port_config_t *info)
    605 {
    606     int rv;
    607     bcm_port_e2efc_remote_port_config_t *new_info = NULL;
    608 
    609     if (NULL != info) {
    610         /* Create from heap to avoid the stack to bloat */
    611         new_info = (bcm_port_e2efc_remote_port_config_t *)
    612             sal_alloc(sizeof(bcm_port_e2efc_remote_port_config_t),
    613                       "New E2EFC Remote port info");
    614         if (NULL == new_info) {
    615             return BCM_E_MEMORY;
    616         }
    617 
    618         /* Transform the info from the old format to new one */
    619         _bcm_compat657in_port_e2efc_remote_port_config_t(info, new_info);
    620     }
    621 
    622     /* Call the BCM API with new format */
    623     rv = bcm_port_e2efc_remote_port_set (unit, rport_handle_id, new_info);
    624 
    625     if (NULL != new_info) {
    626         /* Transform the info from the new format to old one */
    627         _bcm_compat657out_port_e2efc_remote_port_config_t(new_info , info);
    628 
    629         /* Deallocate memory*/
    630         sal_free(new_info);
    631     }
    632 
    633     return rv;
    634 }
    635 
    636 /*
    637  * Function: bcm_compat657_port_e2efc_remote_port_get
    638  *
    639  * Purpose:
    640  *      Compatibility function for RPC call to bcm_port_e2efc_remote_port_get
    641  *
    642  * Parameters:
    643  *     unit - (IN) BCM device number.
    644  *     rport_handle_id - (IN) output handle to be used in get and set API.
    645  *     bcm_port_e2efc_remote_port_config_t - (OUT) e2efc_remote_port_info with
    646  *                                                 old format
    647  *
    648  * Returns:
    649  *     BCM_E_XXX
    650  */
    651 int
    652 bcm_compat657_port_e2efc_remote_port_get (int unit, int rport_handle_id,
    653                             bcm_compat657_port_e2efc_remote_port_config_t *info)
    654 {
    655     int rv;
    656     bcm_port_e2efc_remote_port_config_t *new_info = NULL;
    657 
    658     if (NULL != info) {
    659         /* Create from heap to avoid the stack to bloat */
    660         new_info = (bcm_port_e2efc_remote_port_config_t *)
    661             sal_alloc(sizeof(bcm_port_e2efc_remote_port_config_t),
    662                       "New E2EFC Remote port info");
    663         if (NULL == new_info) {
    664             return BCM_E_MEMORY;
    665         }
    666 
    667         /* Transform the info from the old format to new one */
    668         _bcm_compat657in_port_e2efc_remote_port_config_t(info, new_info);
    669     }
    670 
    671     /* Call the BCM API with new format */
    672     rv = bcm_port_e2efc_remote_port_get (unit, rport_handle_id, new_info);
    673 
    674     if (NULL != new_info) {
    675         /* Transform the info from the new format to old one */
    676         _bcm_compat657out_port_e2efc_remote_port_config_t(new_info , info);
    677 
    678         /* Deallocate memory*/
    679         sal_free(new_info);
    680     }
    681 
    682     return rv;
    683 }
    684 
    685 /*
    686  * Function:
    687  *      _bcm_compat657in_field_qset_t
    688  * Purpose:
    689  *      Convert the bcm_field_qset_t datatype from SDK 6.5.7 version to
    690  *      SDK 6.5.7+ version
    691  * Parameters:
    692  *      from        - (IN) The old version of the datatype
    693  *      to          - (OUT) The SDK 6.5.7+ version of the datatype
    694  * Returns:
    695  *      Nothing
    696  */
    697 STATIC void
    698 _bcm_compat657in_field_qset_t(
    699     bcm_compat657_field_qset_t *from,
    700     bcm_field_qset_t *to)
    701 {
    702     uint32  field_qualify_cnt_size =
    703         (BCM_COMPAT657_FIELD_QUALIFY_CNT < bcmFieldQualifyCount) ?
    704             BCM_COMPAT657_FIELD_QUALIFY_CNT :  bcmFieldQualifyCount;
    705     uint32  field_user_num_udfs_size =
    706        (BCM_COMPAT657_FIELD_USER_NUM_UDFS < BCM_FIELD_USER_NUM_UDFS) ?
    707         BCM_COMPAT657_FIELD_USER_NUM_UDFS : BCM_FIELD_USER_NUM_UDFS;
    708 
    709     SHR_BITCOPY_RANGE(to->w, 0, from->w, 0, field_qualify_cnt_size);
    710     SHR_BITCOPY_RANGE(to->w, bcmFieldQualifyCount,
    711                       from->w, BCM_COMPAT657_FIELD_QUALIFY_CNT,
    712                       field_user_num_udfs_size);
    713     SHR_BITCOPY_RANGE(to->udf_map, 0,
    714                       from->udf_map, 0,
    715                       field_user_num_udfs_size);
    716 }
    717 
    718 /*
    719  * Function:
    720  *      _bcm_compat657out_field_qset_t
    721  * Purpose:
    722  *      Convert the bcm_field_qset_t datatype from SDK 6.5.7+ to
    723  *      SDK 6.5.7 version
    724  * Parameters:
    725  *      from        - (IN) The SDK 6.5.7+ version of the datatype
    726  *      to          - (OUT) The old version of the datatype
    727  * Returns:
    728  *      Nothing
    729  */
    730 STATIC void
    731 _bcm_compat657out_field_qset_t(
    732     bcm_field_qset_t *from,
    733     bcm_compat657_field_qset_t *to)
    734 {
    735     uint32  field_qualify_cnt_size =
    736         (BCM_COMPAT657_FIELD_QUALIFY_CNT < bcmFieldQualifyCount) ?
    737             BCM_COMPAT657_FIELD_QUALIFY_CNT :  bcmFieldQualifyCount;
    738     uint32  field_user_num_udfs_size =
    739        (BCM_COMPAT657_FIELD_USER_NUM_UDFS < BCM_FIELD_USER_NUM_UDFS) ?
    740         BCM_COMPAT657_FIELD_USER_NUM_UDFS : BCM_FIELD_USER_NUM_UDFS;
    741 
    742     SHR_BITCOPY_RANGE(to->w, 0, from->w, 0, field_qualify_cnt_size);
    743     SHR_BITCOPY_RANGE(to->w, BCM_COMPAT657_FIELD_QUALIFY_CNT,
    744                       from->w, bcmFieldQualifyCount,
    745                       field_user_num_udfs_size);
    746     SHR_BITCOPY_RANGE(to->udf_map, 0,
    747                       from->udf_map, 0,
    748                       field_user_num_udfs_size);
    749 }
    750 
    751 /*
    752  * Function: bcm_compat657_field_group_create
    753  *
    754  * Purpose:
    755  *      Compatibility function for RPC call to bcm_field_group_create.
    756  *      Used to create a FP group using an older version of the datatype.
    757  *
    758  * Parameters:
    759  *     unit - (IN) BCM device number.
    760  *     qset - (IN) Old field qualifier set
    761  *     pri  - (IN) Priority within allowable range,
    762  *                 or BCM_FIELD_GROUP_PRIO_ANY to automatically assign
    763  *                 priority; each priority value may be used only once
    764  *     group - (OUT) New field group ID
    765  *
    766  * Returns:
    767  *     BCM_E_INIT     - BCM unit not initialized
    768  *     BCM_E_PARAM    - pri out of range (0-15 for FB & ER) or group == NULL
    769  *     BCM_E_RESOURCE - no select codes will satisfy qualifier set
    770  *     BCM_E_MEMORY   - allocation failure
    771  *     BCM_E_NONE     - Success
    772  */
    773 int
    774 bcm_compat657_field_group_create(int unit,
    775                                 bcm_compat657_field_qset_t qset,
    776                                 int pri,
    777                                 bcm_field_group_t *group)
    778 {
    779     int rv;
    780     bcm_field_qset_t *p_new_qset;
    781 
    782     /* Create the qualifier set from heap to avoid the stack to bloat */
    783     p_new_qset =
    784         (bcm_field_qset_t *) sal_alloc(sizeof(bcm_field_qset_t), "NewQset");
    785     if (NULL == p_new_qset) {
    786         return BCM_E_MEMORY;
    787     }
    788 
    789     /* Initialize the new qualifier set */
    790     BCM_FIELD_QSET_INIT(*p_new_qset);
    791 
    792     /* Transform the qulaifier set from the old format to new one */
    793     _bcm_compat657in_field_qset_t(&qset, p_new_qset);
    794 
    795     /* Call the BCM API with new qset format */
    796     rv = bcm_field_group_create(unit, *p_new_qset, pri, group);
    797 
    798     /* Deallocate the q set memory */
    799     sal_free(p_new_qset);
    800 
    801     return rv;
    802 }
    803 
    804 /*
    805  * Function: bcm_compat657_field_group_create_id
    806  *
    807  * Purpose:
    808  *      Compatibility function for RPC call to bcm_field_group_create_id.
    809  *      Used to create a FP group using an older version of the datatype.
    810  *
    811  * Parameters:
    812  *     unit - (IN) BCM device number.
    813  *     qset - (IN) Old field qualifier set
    814  *     pri  - (IN) Priority within allowable range,
    815  *                 or BCM_FIELD_GROUP_PRIO_ANY to automatically assign
    816  *                 priority; each priority value may be used only once
    817  *     group - (IN) Requested new field group ID
    818  *
    819  * Returns:
    820  *     BCM_E_INIT      - BCM unit not initialized
    821  *     BCM_E_RESOURCE  - No unused group/slices left
    822  *     BCM_E_PARAM     - priority out of range (0-15 for FB & ER)
    823  *     BCM_E_EXISTS    - group with that id already exists on this unit.
    824  *     BCM_E_MEMORY    - Memory allocation failure
    825  *     BCM_E_NONE      - Success
    826  */
    827 int
    828 bcm_compat657_field_group_create_id(int unit,
    829                                     bcm_compat657_field_qset_t qset,
    830                                     int pri,
    831                                     bcm_field_group_t group)
    832 {
    833     int rv;
    834     bcm_field_qset_t *p_new_qset;
    835 
    836     /* Create the qualifier set from heap to avoid the huge stack variable */
    837     p_new_qset =
    838         (bcm_field_qset_t *) sal_alloc(sizeof(bcm_field_qset_t), "NewQset");
    839     if (NULL == p_new_qset) {
    840         return BCM_E_MEMORY;
    841     }
    842 
    843     /* Initialize the new qualifier set */
    844     BCM_FIELD_QSET_INIT(*p_new_qset);
    845 
    846     /* Transform the qulaifier set from the old format to new one */
    847     _bcm_compat657in_field_qset_t(&qset, p_new_qset);
    848 
    849     /* Call the BCM API with new qset format */
    850     rv = bcm_field_group_create_id(unit, *p_new_qset, pri, group);
    851 
    852     /* Deallocate the q set memory */
    853     sal_free(p_new_qset);
    854 
    855     return (rv);
    856 }
    857 
    858 /*
    859  * Function: bcm_compat657_field_qset_data_qualifier_add
    860  *
    861  * Purpose:
    862  *      Compatibility function for RPC call to bcm_field_qset_data_qualifier_add
    863  *      Used to add field data qualifier to group qset.
    864  *
    865  * Parameters:
    866  *     unit - (IN) BCM device number.
    867  *     qset - (IN/OUT) Old group qualifier set
    868  *     qualifier_id  - (IN) Data qualifier id.
    869  *
    870  * Returns:
    871  *     BCM_E_XXX
    872  */
    873 int
    874 bcm_compat657_field_qset_data_qualifier_add(int unit,
    875                                             bcm_compat657_field_qset_t *qset,
    876                                             int qual_id)
    877 {
    878     int rv;
    879     bcm_field_qset_t *p_new_qset=NULL;
    880 
    881     /* Only tranform qualifier set if given a valid qset */
    882     if (qset) {
    883 
    884         /* Create the qualifier set from heap to avoid the stack to bloat */
    885         p_new_qset =
    886             (bcm_field_qset_t *)sal_alloc(sizeof(bcm_field_qset_t), "NewQset");
    887         if (NULL == p_new_qset) {
    888             return BCM_E_MEMORY;
    889         }
    890 
    891         /* Initialize the new qualifier set */
    892         BCM_FIELD_QSET_INIT(*p_new_qset);
    893 
    894         /* Transform the qualifier set from the old format to new one */
    895         _bcm_compat657in_field_qset_t(qset, p_new_qset);
    896     }
    897 
    898     /* Call the BCM API with new qset format */
    899     rv = bcm_field_qset_data_qualifier_add(unit, p_new_qset, qual_id);
    900 
    901     if (qset) {
    902         /* Copy back the qset from new to old format */
    903         if (BCM_SUCCESS(rv)) {
    904             _bcm_compat657out_field_qset_t(p_new_qset, qset);
    905         }
    906 
    907         /* Deallocate the q set memory */
    908         sal_free(p_new_qset);
    909     }
    910 
    911     return (rv);
    912 }
    913 
    914 #endif  /* BCM_RPC_SUPPORT */