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_530.c (7939B)


      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-5.3.0 routines
      8  */
      9 
     10 #ifdef	BCM_RPC_SUPPORT
     11 
     12 #include <sal/core/libc.h>
     13 #include <shared/alloc.h>
     14 
     15 #include <bcm/types.h>
     16 #include <bcm/error.h>
     17 #include <bcm/l2.h>
     18 #include <bcm/l3.h>
     19 
     20 #include <bcm_int/compat/compat_530.h>
     21 
     22 /* bcm_l2_addr_t conversion functions */
     23 STATIC void
     24 _bcm_compat530in_l2_addr_add_t(
     25     bcm_compat530_l2_addr_t *from,
     26     bcm_l2_addr_t *to)
     27 {
     28     to->flags = from->flags;
     29     sal_memcpy(to->mac, from->mac, sizeof(bcm_mac_t));
     30     to->vid = from->vid;
     31     to->port = from->port;
     32     to->modid = from->modid;
     33     to->tgid = from->tgid;
     34     to->cos_dst = from->cos_dst;
     35     to->cos_src = from->cos_src;
     36     to->l2mc_group = from->l2mc_index;
     37     to->block_bitmap = from->block_bitmap;
     38     to->auth = from->auth;
     39     to->group = 0;
     40 }
     41 
     42 STATIC void
     43 _bcm_compat530out_l2_addr_add_t(
     44     bcm_l2_addr_t *from,
     45     bcm_compat530_l2_addr_t *to)
     46 {
     47     to->flags = from->flags;
     48     sal_memcpy(to->mac, from->mac, sizeof(bcm_mac_t));
     49     to->vid = from->vid;
     50     to->port = from->port;
     51     to->modid = from->modid;
     52     to->tgid = from->tgid;
     53     to->cos_dst = from->cos_dst;
     54     to->cos_src = from->cos_src;
     55     to->l2mc_index = from->l2mc_group;
     56     to->block_bitmap = from->block_bitmap;
     57     to->auth = from->auth;
     58     /* ignore from->group */
     59 }
     60 
     61 int
     62 bcm_compat530_l2_addr_add(
     63     int unit,
     64     bcm_compat530_l2_addr_t *l2addr)
     65 {
     66     int			rv;
     67     bcm_l2_addr_t	nl2addr;
     68 
     69     if (l2addr == NULL) {
     70         return BCM_E_PARAM;
     71     }
     72     _bcm_compat530in_l2_addr_add_t(l2addr, &nl2addr);
     73     rv = bcm_l2_addr_add(unit, &nl2addr);
     74     return rv;
     75 }
     76 
     77 int
     78 bcm_compat530_l2_conflict_get(
     79     int unit,
     80     bcm_compat530_l2_addr_t *addr,
     81     bcm_compat530_l2_addr_t *cf_array,
     82     int cf_max,
     83     int *cf_count)
     84 {
     85     int			rv, i;
     86     bcm_l2_addr_t	naddr;
     87     bcm_l2_addr_t	*ncf_array;
     88 
     89     if (addr == NULL || cf_array == NULL) {
     90         return BCM_E_PARAM;
     91     }
     92     ncf_array = sal_alloc(sizeof(bcm_l2_addr_t) * cf_max,
     93 			  "compat530_l2_conflict_get");
     94     if (ncf_array == NULL) {
     95 	return BCM_E_MEMORY;
     96     }
     97     _bcm_compat530in_l2_addr_add_t(addr, &naddr);
     98     rv = bcm_l2_conflict_get(unit, &naddr, ncf_array, cf_max, cf_count);
     99     if (rv >= 0) {
    100 	for (i = 0; i < *cf_count; i++) {
    101 	    _bcm_compat530out_l2_addr_add_t(&ncf_array[i], &cf_array[i]);
    102 	}
    103     }
    104     sal_free(ncf_array);
    105     return rv;
    106 }
    107 
    108 int
    109 bcm_compat530_l2_addr_get(
    110     int unit,
    111     bcm_mac_t mac_addr,
    112     bcm_vlan_t vid,
    113     bcm_compat530_l2_addr_t *l2addr)
    114 {
    115     int			rv;
    116     bcm_l2_addr_t	nl2addr;
    117 
    118     if (l2addr == NULL || mac_addr == NULL) {
    119         return BCM_E_PARAM;
    120     }
    121     bcm_l2_addr_t_init(&nl2addr, mac_addr, vid);
    122     rv = bcm_l2_addr_get(unit, mac_addr, vid, &nl2addr);
    123     if (rv >= 0) {
    124         _bcm_compat530out_l2_addr_add_t(&nl2addr, l2addr);
    125     }
    126     return rv;
    127 }
    128 
    129 
    130 #ifdef INCLUDE_L3
    131 
    132 /* bcm_tunnel_initiator_t conversion functions */
    133 STATIC void
    134 _bcm_compat530in_l3_tunnel_initiator_t(
    135     bcm_compat530_l3_tunnel_initiator_t *from,
    136     bcm_tunnel_initiator_t *to)
    137 {
    138     to->flags = from->l3t_flags;
    139     to->type = from->l3t_type;
    140     to->ttl = from->l3t_ttl;
    141     sal_memcpy(to->dmac, from->l3t_dmac, sizeof(bcm_mac_t));
    142     if(from->l3t_ip4_df_sel) {
    143         if(from->l3t_ip4_df_sel == 1) {
    144             to->flags |= BCM_TUNNEL_INIT_IPV4_SET_DF;
    145         } else {
    146             to->flags |= BCM_TUNNEL_INIT_USE_INNER_DF;
    147         }
    148     }
    149     if(from->l3t_ip6_df_sel) {
    150         to->flags |= BCM_TUNNEL_INIT_IPV6_SET_DF;
    151     }
    152     to->dip = from->l3t_dip;
    153     to->sip = from->l3t_sip;
    154     to->dscp_sel = from->l3t_dscp_sel;
    155     to->dscp = from->l3t_dscp;
    156     to->dscp_map = 0;
    157 }
    158 
    159 STATIC void
    160 _bcm_compat530out_l3_tunnel_initiator_t(
    161     bcm_tunnel_initiator_t *from,
    162     bcm_compat530_l3_tunnel_initiator_t *to)
    163 {
    164     to->l3t_flags = from->flags;
    165     to->l3t_type = from->type;
    166     to->l3t_ttl = from->ttl;
    167     sal_memcpy(to->l3t_dmac, from->dmac, sizeof(bcm_mac_t));
    168     if(from->flags & BCM_TUNNEL_INIT_USE_INNER_DF) {
    169        to->l3t_ip4_df_sel = 0x2;
    170     }
    171     if(from->flags & BCM_TUNNEL_INIT_IPV4_SET_DF) {
    172        to->l3t_ip4_df_sel = 0x1;
    173     }
    174     if(from->flags & BCM_TUNNEL_INIT_IPV6_SET_DF) {
    175        to->l3t_ip6_df_sel = 0x1;
    176     }
    177     to->l3t_dip = from->dip;
    178     to->l3t_sip = from->sip;
    179     to->l3t_dscp_sel = from->dscp_sel;
    180     to->l3t_dscp = from->dscp;
    181     /* ignore from->l3t_dscp_map */
    182 }
    183 
    184 /* bcm_tunnel_terminator_t conversion functions */
    185 STATIC void
    186 _bcm_compat530in_l3_tunnel_terminator_t(
    187     bcm_compat530_l3_tunnel_terminator_t *from,
    188     bcm_tunnel_terminator_t *to)
    189 {
    190     to->flags = from->l3t_flags;
    191     to->vrf = 0;
    192     to->sip = from->l3t_sip;
    193     to->dip = from->l3t_dip;
    194     to->sip_mask = from->l3t_sip_mask;
    195     to->dip_mask = from->l3t_dip_mask;
    196     to->udp_dst_port = from->l3t_udp_dst_port;
    197     to->udp_src_port = from->l3t_udp_src_port;
    198     to->type = from->l3t_type;
    199     to->pbmp = from->l3t_pbmp;
    200     to->vlan = from->l3t_vlan;
    201 }
    202 
    203 STATIC void
    204 _bcm_compat530out_l3_tunnel_terminator_t(
    205     bcm_tunnel_terminator_t *from,
    206     bcm_compat530_l3_tunnel_terminator_t *to)
    207 {
    208     to->l3t_flags = from->flags;
    209     /* ignore from->vrf */
    210     to->l3t_sip = from->sip;
    211     to->l3t_dip = from->dip;
    212     to->l3t_sip_mask = from->sip_mask;
    213     to->l3t_dip_mask = from->dip_mask;
    214     to->l3t_udp_dst_port = from->udp_dst_port;
    215     to->l3t_udp_src_port = from->udp_src_port;
    216     to->l3t_type = from->type;
    217     to->l3t_pbmp = from->pbmp;
    218     to->l3t_vlan = from->vlan;
    219 }
    220 
    221 int
    222 bcm_compat530_l3_tunnel_initiator_set(
    223     int unit,
    224     bcm_l3_intf_t *intf,
    225     bcm_compat530_l3_tunnel_initiator_t *tunnel)
    226 {
    227     int		rv;
    228     bcm_tunnel_initiator_t	ntunnel;
    229 
    230     if (tunnel == NULL) {
    231         return BCM_E_PARAM;
    232     }
    233     _bcm_compat530in_l3_tunnel_initiator_t(tunnel, &ntunnel);
    234     rv = bcm_tunnel_initiator_set(unit, intf, &ntunnel);
    235     return rv;
    236 }
    237 
    238 int
    239 bcm_compat530_l3_tunnel_initiator_get(
    240     int unit,
    241     bcm_l3_intf_t *intf,
    242     bcm_compat530_l3_tunnel_initiator_t *tunnel)
    243 {
    244     int		rv;
    245     bcm_tunnel_initiator_t	ntunnel;
    246 
    247     if (tunnel == NULL) {
    248         return BCM_E_PARAM;
    249     }
    250     rv = bcm_tunnel_initiator_get(unit, intf, &ntunnel);
    251     if (rv >= 0) {
    252 	_bcm_compat530out_l3_tunnel_initiator_t(&ntunnel, tunnel);
    253     }
    254     return rv;
    255 }
    256 
    257 int
    258 bcm_compat530_l3_tunnel_terminator_add(
    259     int unit,
    260     bcm_compat530_l3_tunnel_terminator_t *info)
    261 {
    262     int		rv;
    263     bcm_tunnel_terminator_t	ninfo;
    264 
    265     if (info == NULL) {
    266         return BCM_E_PARAM;
    267     }
    268     _bcm_compat530in_l3_tunnel_terminator_t(info, &ninfo);
    269     rv = bcm_tunnel_terminator_add(unit, &ninfo);
    270     return rv;
    271 }
    272 
    273 int
    274 bcm_compat530_l3_tunnel_terminator_delete(
    275     int unit,
    276     bcm_compat530_l3_tunnel_terminator_t *info)
    277 {
    278     int		rv;
    279     bcm_tunnel_terminator_t	ninfo;
    280 
    281     if (info == NULL) {
    282         return BCM_E_PARAM;
    283     }
    284     _bcm_compat530in_l3_tunnel_terminator_t(info, &ninfo);
    285     rv = bcm_tunnel_terminator_delete(unit, &ninfo);
    286     return rv;
    287 }
    288 
    289 int
    290 bcm_compat530_l3_tunnel_terminator_update(
    291     int unit,
    292     bcm_compat530_l3_tunnel_terminator_t *info)
    293 {
    294     int		rv;
    295     bcm_tunnel_terminator_t	ninfo;
    296 
    297     if (info == NULL) {
    298         return BCM_E_PARAM;
    299     }
    300     _bcm_compat530in_l3_tunnel_terminator_t(info, &ninfo);
    301     rv = bcm_tunnel_terminator_update(unit, &ninfo);
    302     return rv;
    303 }
    304 
    305 int
    306 bcm_compat530_l3_tunnel_terminator_get(
    307     int unit,
    308     bcm_compat530_l3_tunnel_terminator_t *info)
    309 {
    310     int		rv;
    311     bcm_tunnel_terminator_t	ninfo;
    312 
    313     if (info == NULL) {
    314         return BCM_E_PARAM;
    315     }
    316     _bcm_compat530in_l3_tunnel_terminator_t(info, &ninfo);
    317     rv = bcm_tunnel_terminator_get(unit, &ninfo);
    318     if (rv >= 0) {
    319 	_bcm_compat530out_l3_tunnel_terminator_t(&ninfo, info);
    320     }
    321     return rv;
    322 }
    323 
    324 #endif	/* INCLUDE_L3 */
    325 
    326 #endif	/* BCM_RPC_SUPPORT */