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_659.c (28801B)


      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.9 routines
      8  */
      9 
     10 #ifdef	BCM_RPC_SUPPORT
     11 #include <shared/alloc.h>
     12 #include <bcm/error.h>
     13 #include <bcm_int/compat/compat_659.h>
     14 
     15 #if defined(INCLUDE_L3)
     16 /*
     17  * Function:
     18  *      _bcm_compat659in_vlan_port_t
     19  * Purpose:
     20  *      Convert the bcm_vlan_port_t datatype from <=6.5.9 to
     21  *      SDK 6.5.9+
     22  * Parameters:
     23  *      from        - (IN) The <=6.5.9 version of the datatype
     24  *      to          - (OUT) The SDK 6.5.9+ version of the datatype
     25  * Returns:
     26  *      Nothing
     27  */
     28 STATIC void
     29 _bcm_compat659in_vlan_port_t(bcm_compat659_vlan_port_t *from,
     30                            bcm_vlan_port_t *to)
     31 {
     32     bcm_vlan_port_t_init(to);
     33     to->flags                    = from->flags;
     34     to->criteria                 = from->criteria;
     35     to->vsi                      = from->vsi;
     36     to->match_vlan               = from->match_vlan;
     37     to->match_inner_vlan         = from->match_inner_vlan;
     38     to->match_pcp                = from->match_pcp;
     39     to->match_tunnel_value       = from->match_tunnel_value;
     40     to->match_ethertype          = from->match_ethertype;
     41     to->port                     = from->port;
     42     to->pkt_pri                  = from->pkt_pri;
     43     to->pkt_cfi                  = from->pkt_cfi;
     44     to->egress_service_tpid      = from->egress_service_tpid;
     45     to->egress_vlan              = from->egress_vlan;
     46     to->egress_inner_vlan        = from->egress_inner_vlan;
     47     to->egress_tunnel_value      = from->egress_tunnel_value;
     48     to->encap_id                 = from->encap_id;
     49     to->qos_map_id               = from->qos_map_id;
     50     to->policer_id               = from->policer_id;
     51     to->egress_policer_id        = from->egress_policer_id;
     52     to->failover_id              = from->failover_id;
     53     to->failover_port_id         = from->failover_port_id;
     54     to->vlan_port_id             = from->vlan_port_id;
     55     to->failover_mc_group        = from->failover_mc_group;
     56     to->ingress_failover_id      = from->ingress_failover_id;
     57     to->egress_failover_id       = from->egress_failover_id;
     58     to->egress_failover_port_id  = from->egress_failover_port_id;
     59     to->ingress_network_group_id = from->ingress_network_group_id;
     60     to->egress_network_group_id  = from->egress_network_group_id;
     61     to->inlif_counting_profile   = from->inlif_counting_profile;
     62     to->outlif_counting_profile  = from->outlif_counting_profile;
     63 }
     64 
     65 /*
     66  * Function:
     67  *      _bcm_compat659out_vlan_port_t
     68  * Purpose:
     69  *      Convert the bcm_vlan_port_t datatype from 6.5.9+ to
     70  *      <=6.5.9
     71  * Parameters:
     72  *      from        - (IN) The SDK 6.5.9+ version of the datatype
     73  *      to          - (OUT) The <=6.5.9 version of the datatype
     74  * Returns:
     75  *      Nothing
     76  */
     77 STATIC void
     78 _bcm_compat659out_vlan_port_t(bcm_vlan_port_t *from,
     79                             bcm_compat659_vlan_port_t *to)
     80 {
     81     from->flags                     = to->flags;
     82     from->criteria                  = to->criteria;
     83     from->vsi                       = to->vsi;
     84     from->match_vlan                = to->match_vlan;
     85     from->match_inner_vlan          = to->match_inner_vlan;
     86     from->match_pcp                 = to->match_pcp;
     87     from->match_tunnel_value        = to->match_tunnel_value;
     88     from->match_ethertype           = to->match_ethertype;
     89     from->port                      = to->port;
     90     from->pkt_pri                   = to->pkt_pri;
     91     from->pkt_cfi                   = to->pkt_cfi;
     92     from->egress_service_tpid       = to->egress_service_tpid;
     93     from->egress_vlan               = to->egress_vlan;
     94     from->egress_inner_vlan         = to->egress_inner_vlan;
     95     from->egress_tunnel_value       = to->egress_tunnel_value;
     96     from->encap_id                  = to->encap_id;
     97     from->qos_map_id                = to->qos_map_id;
     98     from->policer_id                = to->policer_id;
     99     from->egress_policer_id         = to->egress_policer_id;
    100     from->failover_id               = to->failover_id;
    101     from->failover_port_id          = to->failover_port_id;
    102     from->vlan_port_id              = to->vlan_port_id;
    103     from->failover_mc_group         = to->failover_mc_group;
    104     from->ingress_failover_id       = to->ingress_failover_id;
    105     from->egress_failover_id        = to->egress_failover_id;
    106     from->egress_failover_port_id   = to->egress_failover_port_id;
    107     from->ingress_network_group_id  = to->ingress_network_group_id;
    108     from->egress_network_group_id   = to->egress_network_group_id;
    109     from->inlif_counting_profile    = to->inlif_counting_profile;
    110     from->outlif_counting_profile   = to->outlif_counting_profile;
    111 
    112 }
    113 
    114 /*
    115  * Function: bcm_compat659_vlan_port_find
    116  *
    117  * Purpose:
    118  *      Compatibility function for RPC call to bcm_vlan_port_find.
    119  *
    120  * Parameters:
    121  *     unit - (IN) BCM device number.
    122  *     vlan_port - (IN/OUT) vlan port with old format
    123  *
    124  * Returns:
    125  *     BCM_E_XXX
    126  */
    127 int
    128 bcm_compat659_vlan_port_find(int unit, bcm_compat659_vlan_port_t *vlan_port)
    129 {
    130     int rv;
    131     bcm_vlan_port_t *new_vlan_port = NULL;
    132 
    133     if (NULL != vlan_port) {
    134         /* Create from heap to avoid the stack to bloat */
    135         new_vlan_port = (bcm_vlan_port_t *)
    136             sal_alloc(sizeof(bcm_vlan_port_t), "New vlan port");
    137         if (NULL == new_vlan_port) {
    138             return BCM_E_MEMORY;
    139         }
    140 
    141         /* Transform the entry from the old format to new one */
    142         _bcm_compat659in_vlan_port_t(vlan_port, new_vlan_port);
    143     } else {
    144         return BCM_E_PARAM;
    145     }
    146 
    147     /* Call the BCM API with new format */
    148     rv = bcm_vlan_port_find(unit, new_vlan_port);
    149 
    150     /* Transform the entry from the new format to old one */
    151     _bcm_compat659out_vlan_port_t(new_vlan_port, vlan_port);
    152     /* Deallocate memory*/
    153     sal_free(new_vlan_port);
    154 
    155     return rv;
    156 }
    157 
    158 /*
    159  * Function: bcm_compat659_vlan_port_create
    160  *
    161  * Purpose:
    162  *      Compatibility function for RPC call to bcm_vlan_port_create.
    163  *
    164  * Parameters:
    165  *     unit - (IN) BCM device number.
    166  *     vlan_port - (IN/OUT) vlan port with old format
    167  *
    168  * Returns:
    169  *     BCM_E_XXX
    170  */
    171 int
    172 bcm_compat659_vlan_port_create(int unit, bcm_compat659_vlan_port_t *vlan_port)
    173 {
    174     int rv;
    175     bcm_vlan_port_t *new_vlan_port = NULL;
    176 
    177     if (NULL != vlan_port) {
    178         /* Create from heap to avoid the stack to bloat */
    179         new_vlan_port = (bcm_vlan_port_t *)
    180             sal_alloc(sizeof(bcm_vlan_port_t), "New vlan port");
    181         if (NULL == new_vlan_port) {
    182             return BCM_E_MEMORY;
    183         }
    184 
    185         /* Transform the entry from the old format to new one */
    186         _bcm_compat659in_vlan_port_t(vlan_port, new_vlan_port);
    187     } else {
    188         return BCM_E_PARAM;
    189     }
    190 
    191     /* Call the BCM API with new format */
    192     rv = bcm_vlan_port_create(unit, new_vlan_port);
    193 
    194     /* Transform the entry from the new format to old one */
    195     _bcm_compat659out_vlan_port_t(new_vlan_port, vlan_port);
    196     /* Deallocate memory*/
    197     sal_free(new_vlan_port);
    198 
    199     return rv;
    200 }
    201 
    202 #endif
    203 
    204 /*
    205  * Function:
    206  *      _bcm_compat659in_vlan_control_vlan_t
    207  * Purpose:
    208  *      Convert the bcm_vlan_control_vlan_t datatype from <=6.5.9 to
    209  *      SDK 6.5.9+
    210  * Parameters:
    211  *      from        - (IN) The <=6.5.9 version of the datatype
    212  *      to          - (OUT) The SDK 6.5.9+ version of the datatype
    213  * Returns:
    214  *      Nothing
    215  */
    216 STATIC void
    217 _bcm_compat659in_vlan_control_vlan_t(
    218                            bcm_compat659_vlan_control_vlan_t *from,
    219                            bcm_vlan_control_vlan_t *to)
    220 {
    221     bcm_vlan_control_vlan_t_init(to);
    222     to->vrf                                        = from->vrf;
    223     to->forwarding_vlan                            = from->forwarding_vlan;
    224     to->ingress_if                                 = from->ingress_if;
    225     to->outer_tpid                                 = from->outer_tpid;
    226     to->flags                                      = from->flags;
    227     to->ip6_mcast_flood_mode                       = from->ip6_mcast_flood_mode;
    228     to->ip4_mcast_flood_mode                       = from->ip4_mcast_flood_mode;
    229     to->l2_mcast_flood_mode                        = from->l2_mcast_flood_mode;
    230     to->if_class                                   = from->if_class;
    231     to->forwarding_mode                            = from->forwarding_mode;
    232     to->urpf_mode                                  = from->urpf_mode;
    233     to->cosq                                       = from->cosq;
    234     to->qos_map_id                                 = from->qos_map_id;
    235     to->distribution_class                         = from->distribution_class;
    236     to->broadcast_group                            = from->broadcast_group;
    237     to->unknown_multicast_group                    = from->unknown_multicast_group;
    238     to->unknown_unicast_group                      = from->unknown_unicast_group;
    239     to->trill_nonunicast_group                     = from->trill_nonunicast_group;
    240     to->source_trill_name                          = from->source_trill_name;
    241     to->trunk_index                                = from->trunk_index;
    242     to->protocol_pkt.mmrp_action                   = from->protocol_pkt.mmrp_action;
    243     to->protocol_pkt.srp_action                    = from->protocol_pkt.srp_action;
    244     to->protocol_pkt.arp_reply_action              = from->protocol_pkt.arp_reply_action;
    245     to->protocol_pkt.arp_request_action            = from->protocol_pkt.arp_request_action;
    246     to->protocol_pkt.nd_action                     = from->protocol_pkt.nd_action;
    247     to->protocol_pkt.dhcp_action                   = from->protocol_pkt.dhcp_action;
    248     to->protocol_pkt.igmp_report_leave_action      = from->protocol_pkt.igmp_report_leave_action;
    249     to->protocol_pkt.igmp_query_action             = from->protocol_pkt.igmp_query_action;
    250     to->protocol_pkt.igmp_unknown_msg_action       = from->protocol_pkt.igmp_unknown_msg_action;
    251     to->protocol_pkt.mld_report_done_action        = from->protocol_pkt.mld_report_done_action;
    252     to->protocol_pkt.mld_query_action              = from->protocol_pkt.mld_query_action;
    253     to->protocol_pkt.ip4_rsvd_mc_action            = from->protocol_pkt.ip4_rsvd_mc_action;
    254     to->protocol_pkt.ip6_rsvd_mc_action            = from->protocol_pkt.ip6_rsvd_mc_action;
    255     to->protocol_pkt.ip4_mc_router_adv_action      = from->protocol_pkt.ip4_mc_router_adv_action;
    256     to->protocol_pkt.ip6_mc_router_adv_action      = from->protocol_pkt.ip6_mc_router_adv_action;
    257     to->protocol_pkt.flood_action_according_to_pfm = from->protocol_pkt.flood_action_according_to_pfm;
    258     to->nat_realm_id                               = from->nat_realm_id;
    259     to->l3_if_class                                = from->l3_if_class;
    260     to->vp_mc_ctrl                                 = from->vp_mc_ctrl;
    261     to->aging_cycles                               = from->aging_cycles;
    262     to->entropy_id                                 = from->entropy_id;
    263     to->vpn                                        = from->vpn;
    264     to->egress_vlan                                = from->egress_vlan;
    265     to->learn_flags                                = from->learn_flags;
    266     to->sr_flags                                   = from->sr_flags;
    267 }
    268 
    269 /*
    270  * Function:
    271  *      _bcm_compat659out_vlan_control_vlan_t
    272  * Purpose:
    273  *      Convert the bcm_vlan_control_vlan_t datatype from 6.5.9+ to
    274  *      <=6.5.9
    275  * Parameters:
    276  *      from        - (IN) The SDK 6.5.9+ version of the datatype
    277  *      to          - (OUT) The <=6.5.9 version of the datatype
    278  * Returns:
    279  *      Nothing
    280  */
    281 STATIC void
    282 _bcm_compat659out_vlan_control_vlan_t(bcm_vlan_control_vlan_t *from,
    283                                           bcm_compat659_vlan_control_vlan_t *to)
    284 {
    285     to->vrf                                        = from->vrf;
    286     to->forwarding_vlan                            = from->forwarding_vlan;
    287     to->ingress_if                                 = from->ingress_if;
    288     to->outer_tpid                                 = from->outer_tpid;
    289     to->flags                                      = from->flags;
    290     to->ip6_mcast_flood_mode                       = from->ip6_mcast_flood_mode;
    291     to->ip4_mcast_flood_mode                       = from->ip4_mcast_flood_mode;
    292     to->l2_mcast_flood_mode                        = from->l2_mcast_flood_mode;
    293     to->if_class                                   = from->if_class;
    294     to->forwarding_mode                            = from->forwarding_mode;
    295     to->urpf_mode                                  = from->urpf_mode;
    296     to->cosq                                       = from->cosq;
    297     to->qos_map_id                                 = from->qos_map_id;
    298     to->distribution_class                         = from->distribution_class;
    299     to->broadcast_group                            = from->broadcast_group;
    300     to->unknown_multicast_group                    = from->unknown_multicast_group;
    301     to->unknown_unicast_group                      = from->unknown_unicast_group;
    302     to->trill_nonunicast_group                     = from->trill_nonunicast_group;
    303     to->source_trill_name                          = from->source_trill_name;
    304     to->trunk_index                                = from->trunk_index;
    305     to->protocol_pkt.mmrp_action                   = from->protocol_pkt.mmrp_action;
    306     to->protocol_pkt.srp_action                    = from->protocol_pkt.srp_action;
    307     to->protocol_pkt.arp_reply_action              = from->protocol_pkt.arp_reply_action;
    308     to->protocol_pkt.arp_request_action            = from->protocol_pkt.arp_request_action;
    309     to->protocol_pkt.nd_action                     = from->protocol_pkt.nd_action;
    310     to->protocol_pkt.dhcp_action                   = from->protocol_pkt.dhcp_action;
    311     to->protocol_pkt.igmp_report_leave_action      = from->protocol_pkt.igmp_report_leave_action;
    312     to->protocol_pkt.igmp_query_action             = from->protocol_pkt.igmp_query_action;
    313     to->protocol_pkt.igmp_unknown_msg_action       = from->protocol_pkt.igmp_unknown_msg_action;
    314     to->protocol_pkt.mld_report_done_action        = from->protocol_pkt.mld_report_done_action;
    315     to->protocol_pkt.mld_query_action              = from->protocol_pkt.mld_query_action;
    316     to->protocol_pkt.ip4_rsvd_mc_action            = from->protocol_pkt.ip4_rsvd_mc_action;
    317     to->protocol_pkt.ip6_rsvd_mc_action            = from->protocol_pkt.ip6_rsvd_mc_action;
    318     to->protocol_pkt.ip4_mc_router_adv_action      = from->protocol_pkt.ip4_mc_router_adv_action;
    319     to->protocol_pkt.ip6_mc_router_adv_action      = from->protocol_pkt.ip6_mc_router_adv_action;
    320     to->protocol_pkt.flood_action_according_to_pfm = from->protocol_pkt.flood_action_according_to_pfm;
    321     to->nat_realm_id                               = from->nat_realm_id;
    322     to->l3_if_class                                = from->l3_if_class;
    323     to->vp_mc_ctrl                                 = from->vp_mc_ctrl;
    324     to->aging_cycles                               = from->aging_cycles;
    325     to->entropy_id                                 = from->entropy_id;
    326     to->vpn                                        = from->vpn;
    327     to->egress_vlan                                = from->egress_vlan;
    328     to->learn_flags                                = from->learn_flags;
    329     to->sr_flags                                   = from->sr_flags;
    330 }
    331 
    332 /*
    333  * Function: bcm_compat659_vlan_control_vlan_selective_set
    334  *
    335  * Purpose:
    336  *      Compatibility function for RPC call to bcm_vlan_control_vlan_selective_set.
    337  *
    338  * Parameters:
    339  *     unit - (IN) BCM device number.
    340  *     vlan     - (IN) VLAN to get the flood setting for.
    341  *     valid_fields - (IN) Valid fields for VLAN control structure,
    342  *     BCM_VLAN_CONTROL_VLAN_XXX_MASK.
    343  *     control - (IN) VLAN control structure
    344  *
    345  * Returns:
    346  *     BCM_E_XXX
    347  */
    348 int
    349 bcm_compat659_vlan_control_vlan_selective_set(int unit,
    350                                  bcm_vlan_t vlan, uint32 valid_fields,
    351                                  bcm_compat659_vlan_control_vlan_t *control)
    352 {
    353     int rv;
    354     bcm_vlan_control_vlan_t *new_vlan_control = NULL;
    355 
    356     if (NULL != control) {
    357         /* Create from heap to avoid the stack to bloat */
    358         new_vlan_control = (bcm_vlan_control_vlan_t *)
    359             sal_alloc(sizeof(bcm_vlan_control_vlan_t), "New vlan control vlan");
    360         if (NULL == new_vlan_control) {
    361             return BCM_E_MEMORY;
    362         }
    363 
    364         /* Transform the entry from the old format to new one */
    365         _bcm_compat659in_vlan_control_vlan_t(control, new_vlan_control);
    366     } else {
    367         return BCM_E_PARAM;
    368     }
    369 
    370     /* Call the BCM API with new format */
    371     rv = bcm_vlan_control_vlan_selective_set(unit, vlan, valid_fields,
    372                                              new_vlan_control);
    373 
    374     /* Transform the entry from the new format to old one */
    375     _bcm_compat659out_vlan_control_vlan_t(new_vlan_control, control);
    376     /* Deallocate memory*/
    377     sal_free(new_vlan_control);
    378 
    379     return rv;
    380 }
    381 
    382 /*
    383  * Function: bcm_compat659_vlan_control_vlan_selective_get
    384  *
    385  * Purpose:
    386  *      Compatibility function for RPC call to bcm_vlan_control_vlan_selective_get.
    387  *
    388  * Parameters:
    389  *     unit - (IN) BCM device number.
    390  *     vlan     - (IN) VLAN to get the flood setting for.
    391  *     valid_fields - (IN) Valid fields for VLAN control structure,
    392  *     BCM_VLAN_CONTROL_VLAN_XXX_MASK.
    393  *     control - (OUT) VLAN control structure
    394  *
    395  * Returns:
    396  *     BCM_E_XXX
    397  */
    398 int
    399 bcm_compat659_vlan_control_vlan_selective_get(int unit,
    400                                  bcm_vlan_t vlan, uint32 valid_fields,
    401                                  bcm_compat659_vlan_control_vlan_t *control)
    402 {
    403     int rv;
    404     bcm_vlan_control_vlan_t *new_vlan_control = NULL;
    405 
    406     if (NULL != control) {
    407         /* Create from heap to avoid the stack to bloat */
    408         new_vlan_control = (bcm_vlan_control_vlan_t *)
    409             sal_alloc(sizeof(bcm_vlan_control_vlan_t), "New vlan control vlan");
    410         if (NULL == new_vlan_control) {
    411             return BCM_E_MEMORY;
    412         }
    413 
    414         /* Transform the entry from the old format to new one */
    415         _bcm_compat659in_vlan_control_vlan_t(control, new_vlan_control);
    416     } else {
    417         return BCM_E_PARAM;
    418     }
    419 
    420     /* Call the BCM API with new format */
    421     rv = bcm_vlan_control_vlan_selective_get(unit, vlan, valid_fields,
    422                                              new_vlan_control);
    423 
    424     /* Transform the entry from the new format to old one */
    425     _bcm_compat659out_vlan_control_vlan_t(new_vlan_control, control);
    426     /* Deallocate memory*/
    427     sal_free(new_vlan_control);
    428 
    429     return rv;
    430 }
    431 
    432 /*
    433  * Function: bcm_compat659_vlan_control_vlan_set
    434  *
    435  * Purpose:
    436  *      Compatibility function for RPC call to bcm_vlan_control_vlan_set.
    437  *
    438  * Parameters:
    439  *      unit    - (IN) StrataSwitch PCI device unit number (driver internal).
    440  *      vlan     - (IN) VLAN to get the flood setting for.
    441  *      control - (IN) VLAN control structure
    442  *
    443  * Returns:
    444  *     BCM_E_XXX
    445  */
    446 int
    447 bcm_compat659_vlan_control_vlan_set(int unit, bcm_vlan_t vlan,
    448                                               /* coverity[pass_by_value] */
    449                                               bcm_compat659_vlan_control_vlan_t control)
    450 {
    451     int rv;
    452     bcm_vlan_control_vlan_t *new_vlan_control = NULL;
    453 
    454     /* Create from heap to avoid the stack to bloat */
    455     new_vlan_control = (bcm_vlan_control_vlan_t *)
    456         sal_alloc(sizeof(bcm_vlan_control_vlan_t), "New vlan control vlan");
    457     if (NULL == new_vlan_control) {
    458         return BCM_E_MEMORY;
    459     }
    460 
    461     /* Transform the entry from the old format to new one */
    462     _bcm_compat659in_vlan_control_vlan_t(&control, new_vlan_control);
    463 
    464 
    465     /* Call the BCM API with new format */
    466     rv = bcm_vlan_control_vlan_set(unit, vlan, *new_vlan_control);
    467 
    468     /* Transform the entry from the new format to old one */
    469     _bcm_compat659out_vlan_control_vlan_t(new_vlan_control, &control);
    470     /* Deallocate memory*/
    471     sal_free(new_vlan_control);
    472 
    473     return rv;
    474 }
    475 
    476 
    477 /*
    478  * Function: bcm_compat659_vlan_control_vlan_get
    479  *
    480  * Purpose:
    481  *      Compatibility function for RPC call to bcm_vlan_control_vlan_get.
    482  *
    483  * Parameters:
    484  *      unit    - (IN) StrataSwitch PCI device unit number (driver internal).
    485  *      vlan     - (IN) VLAN to get the flood setting for.
    486  *      control - (OUT) VLAN control structure
    487  *
    488  * Returns:
    489  *     BCM_E_XXX
    490  */
    491 int
    492 bcm_compat659_vlan_control_vlan_get(int unit,
    493                                  bcm_vlan_t vlan,
    494                                  bcm_compat659_vlan_control_vlan_t *control)
    495 {
    496     int rv;
    497     bcm_vlan_control_vlan_t *new_vlan_control = NULL;
    498 
    499     if (NULL != control) {
    500         /* Create from heap to avoid the stack to bloat */
    501         new_vlan_control = (bcm_vlan_control_vlan_t *)
    502             sal_alloc(sizeof(bcm_vlan_control_vlan_t), "New vlan control vlan");
    503         if (NULL == new_vlan_control) {
    504             return BCM_E_MEMORY;
    505         }
    506 
    507         /* Transform the entry from the old format to new one */
    508         _bcm_compat659in_vlan_control_vlan_t(control, new_vlan_control);
    509     } else {
    510         return BCM_E_PARAM;
    511     }
    512 
    513     /* Call the BCM API with new format */
    514     rv = bcm_vlan_control_vlan_get(unit, vlan, new_vlan_control);
    515 
    516     /* Transform the entry from the new format to old one */
    517     _bcm_compat659out_vlan_control_vlan_t(new_vlan_control, control);
    518     /* Deallocate memory*/
    519     sal_free(new_vlan_control);
    520 
    521     return rv;
    522 }
    523 
    524 
    525 /*
    526  * Function:
    527  *      _bcm_compat659in_cosq_gport_discard_t
    528  * Purpose:
    529  *      Convert the bcm_cosq_gport_discard_t datatype from <=6.5.9 to
    530  *      SDK 6.5.9+
    531  * Parameters:
    532  *      from        - (IN) The <=6.5.9 version of the datatype
    533  *      to          - (OUT) The SDK 6.5.9+ version of the datatype
    534  * Returns:
    535  *      Nothing
    536  */
    537 STATIC void
    538 _bcm_compat659in_cosq_gport_discard_t(bcm_compat659_cosq_gport_discard_t *from,
    539                            bcm_cosq_gport_discard_t *to)
    540 {
    541     bcm_cosq_gport_discard_t_init(to);
    542     to->flags                    = from->flags;
    543     to->min_thresh               = from->min_thresh;
    544     to->max_thresh               = from->max_thresh;
    545     to->drop_probability         = from->drop_probability;
    546     to->gain                     = from->gain;
    547     to->ecn_thresh               = from->ecn_thresh;
    548     to->refresh_time             = from->refresh_time;
    549 }
    550 
    551 /*
    552  * Function:
    553  *      _bcm_compat659out_cosq_gport_discard_t
    554  * Purpose:
    555  *      Convert the bcm_cosq_gport_discard_t datatype from 6.5.9+ to
    556  *      <=6.5.9
    557  * Parameters:
    558  *      from        - (IN) The SDK 6.5.9+ version of the datatype
    559  *      to          - (OUT) The <=6.5.9 version of the datatype
    560  * Returns:
    561  *      Nothing
    562  */
    563 STATIC void
    564 _bcm_compat659out_cosq_gport_discard_t(bcm_cosq_gport_discard_t *from,
    565                             bcm_compat659_cosq_gport_discard_t *to)
    566 {
    567     to->flags                    = from->flags;
    568     to->min_thresh               = from->min_thresh;
    569     to->max_thresh               = from->max_thresh;
    570     to->drop_probability         = from->drop_probability;
    571     to->gain                     = from->gain;
    572     to->ecn_thresh               = from->ecn_thresh;
    573     to->refresh_time             = from->refresh_time;
    574 }
    575 
    576 /*
    577  * Function: bcm_compat659_cosq_gport_discard_set
    578  *
    579  * Purpose:
    580  *      Compatibility function for RPC call to bcm_cosq_gport_discard_set.
    581  *
    582  * Parameters:
    583  *      unit    - (IN) Unit number.
    584  *      port    - (IN) GPORT ID.
    585  *      cosq    - (IN) COS queue to configure
    586  *      discard - (IN) Discard settings
    587  *
    588  * Returns:
    589  *     BCM_E_XXX
    590  */
    591 int
    592 bcm_compat659_cosq_gport_discard_set(int unit, bcm_gport_t gport,
    593                                      bcm_cos_queue_t cosq, 
    594                                      bcm_compat659_cosq_gport_discard_t *discard)
    595 {
    596     int rv;
    597     bcm_cosq_gport_discard_t *new_discard = NULL;
    598 
    599     if (NULL != discard) {
    600         /* Create from heap to avoid the stack to bloat */
    601         new_discard = (bcm_cosq_gport_discard_t *)
    602             sal_alloc(sizeof(bcm_cosq_gport_discard_t), "New discard");
    603         if (NULL == new_discard) {
    604             return BCM_E_MEMORY;
    605         }
    606 
    607         /* Transform the entry from the old format to new one */
    608         _bcm_compat659in_cosq_gport_discard_t(discard, new_discard);
    609     }
    610 
    611     /* Call the BCM API with new format */
    612     rv = bcm_cosq_gport_discard_set(unit, gport, cosq, new_discard);
    613 
    614     if (NULL != new_discard) {
    615         /* Transform the entry from the new format to old one */
    616         _bcm_compat659out_cosq_gport_discard_t(new_discard, discard);
    617         /* Deallocate memory*/
    618         sal_free(new_discard);
    619     }
    620 
    621     return rv;
    622 }
    623 
    624 /*
    625  * Function: bcm_compat659_cosq_gport_discard_get
    626  *
    627  * Purpose:
    628  *      Compatibility function for RPC call to bcm_cosq_gport_discard_get.
    629  *
    630  * Parameters:
    631  *      unit    - (IN) Unit number.
    632  *      port    - (IN) GPORT ID.
    633  *      cosq    - (IN) COS queue to get
    634  *      discard - (IN/OUT) Discard settings
    635  *
    636  * Returns:
    637  *     BCM_E_XXX
    638  */
    639 int
    640 bcm_compat659_cosq_gport_discard_get(int unit, bcm_gport_t gport,
    641                                      bcm_cos_queue_t cosq, 
    642                                      bcm_compat659_cosq_gport_discard_t *discard)
    643 {
    644     int rv;
    645     bcm_cosq_gport_discard_t *new_discard = NULL;
    646 
    647     /* Create from heap to avoid the stack to bloat */
    648     if (NULL != discard) {
    649         new_discard = (bcm_cosq_gport_discard_t *)
    650             sal_alloc(sizeof(bcm_cosq_gport_discard_t), "New discard");
    651         if (NULL == new_discard) {
    652             return BCM_E_MEMORY;
    653         }
    654 
    655         /* Transform the entry from the old format to new one */
    656         _bcm_compat659in_cosq_gport_discard_t(discard, new_discard);
    657     }
    658 
    659     /* Call the BCM API with new format */
    660     rv = bcm_cosq_gport_discard_get(unit, gport, cosq, new_discard);
    661 
    662     if (NULL != new_discard) {
    663         /* Transform the entry from the new format to old one */
    664         _bcm_compat659out_cosq_gport_discard_t(new_discard, discard);
    665         /* Deallocate memory*/
    666         sal_free(new_discard);
    667     }
    668 
    669     return rv;
    670 }
    671 
    672 /*
    673  * Function: bcm_compat659_cosq_gport_discard_extended_set
    674  *
    675  * Purpose:
    676  *      Compatibility function for RPC call to bcm_cosq_gport_discard_extended_set.
    677  *
    678  * Parameters:
    679  *      unit    - (IN) Unit number.
    680  *      id      - (IN) Integrated cosq index
    681  *      discard - (IN) Discard settings
    682  *
    683  * Returns:
    684  *     BCM_E_XXX
    685  */
    686 int
    687 bcm_compat659_cosq_gport_discard_extended_set(int unit, bcm_cosq_object_id_t *id,
    688                                      bcm_compat659_cosq_gport_discard_t *discard)
    689 {
    690     int rv;
    691     bcm_cosq_gport_discard_t *new_discard = NULL;
    692 
    693     if (NULL != discard) {
    694         /* Create from heap to avoid the stack to bloat */
    695         new_discard = (bcm_cosq_gport_discard_t *)
    696             sal_alloc(sizeof(bcm_cosq_gport_discard_t), "New discard");
    697         if (NULL == new_discard) {
    698             return BCM_E_MEMORY;
    699         }
    700 
    701         /* Transform the entry from the old format to new one */
    702         _bcm_compat659in_cosq_gport_discard_t(discard, new_discard);
    703     }
    704 
    705     /* Call the BCM API with new format */
    706     rv = bcm_cosq_gport_discard_extended_set(unit, id, new_discard);
    707 
    708     if (NULL != new_discard) {
    709         /* Transform the entry from the new format to old one */
    710         _bcm_compat659out_cosq_gport_discard_t(new_discard, discard);
    711         /* Deallocate memory*/
    712         sal_free(new_discard);
    713     }
    714 
    715     return rv;
    716 }
    717 
    718 /*
    719  * Function: bcm_compat659_cosq_gport_discard_extended_get
    720  *
    721  * Purpose:
    722  *      Compatibility function for RPC call to bcm_cosq_gport_discard_extended_get.
    723  *
    724  * Parameters:
    725  *      unit    - (IN) Unit number.
    726  *      id      - (IN) Integrated cosq index
    727  *      discard - (IN) Discard settings
    728  *
    729  * Returns:
    730  *     BCM_E_XXX
    731  */
    732 int
    733 bcm_compat659_cosq_gport_discard_extended_get(int unit, bcm_cosq_object_id_t *id,
    734                                      bcm_compat659_cosq_gport_discard_t *discard)
    735 {
    736     int rv;
    737     bcm_cosq_gport_discard_t *new_discard = NULL;
    738 
    739     /* Create from heap to avoid the stack to bloat */
    740     if (NULL != discard) {
    741         new_discard = (bcm_cosq_gport_discard_t *)
    742             sal_alloc(sizeof(bcm_cosq_gport_discard_t), "New discard");
    743         if (NULL == new_discard) {
    744             return BCM_E_MEMORY;
    745         }
    746 
    747         /* Transform the entry from the old format to new one */
    748         _bcm_compat659in_cosq_gport_discard_t(discard, new_discard);
    749     }
    750 
    751     /* Call the BCM API with new format */
    752     rv = bcm_cosq_gport_discard_extended_get(unit, id, new_discard);
    753 
    754     if (NULL != new_discard) {
    755         /* Transform the entry from the new format to old one */
    756         _bcm_compat659out_cosq_gport_discard_t(new_discard, discard);
    757         /* Deallocate memory*/
    758         sal_free(new_discard);
    759     }
    760 
    761     return rv;
    762 }
    763 
    764 #endif  /* BCM_RPC_SUPPORT */