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

ifa_sdk_pack.c (2725B)


      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  * File:        ifa_sdk_pack.c
      8  * Purpose:     IFA pack and unpack routines for:
      9  *              - IFA Control messages
     10  *
     11  * This file is shared between SDK and uKernel.
     12  */
     13 
     14 #if defined(INCLUDE_IFA)
     15 #include <shared/pack.h>
     16 #include <bcm_int/esw/ifa_sdk_msg.h>
     17 #include <bcm_int/esw/ifa_sdk_pack.h>
     18 
     19 /*
     20  * Create IFA config information - pack
     21  */
     22 uint8*
     23 ifa_sdk_msg_ctrl_config_info_pack(uint8* buf,
     24                                   ifa_sdk_msg_ctrl_config_info_t *msg)
     25 {
     26     int i;
     27 
     28     _SHR_PACK_U32(buf, msg->probemarker_1);
     29     _SHR_PACK_U32(buf, msg->probemarker_2);
     30     _SHR_PACK_U32(buf, msg->device_id);
     31     _SHR_PACK_U16(buf, msg->lb_port_1);
     32     _SHR_PACK_U16(buf, msg->lb_port_2);
     33     _SHR_PACK_U16(buf, msg->module_id);
     34 
     35     _SHR_PACK_U16(buf, msg->rx_packet_payload_length);
     36     _SHR_PACK_U16(buf, msg->max_payload_length);
     37     _SHR_PACK_U8(buf, msg->optional_headers);
     38     _SHR_PACK_U8(buf, msg->hop_limit);
     39 
     40     _SHR_PACK_U16(buf, msg->int_encap_length);
     41     for (i = 0; i < msg->int_encap_length; i++) {
     42         _SHR_PACK_U8(buf, msg->int_encap[i]);
     43     }
     44 
     45     _SHR_PACK_U16(buf, msg->lb_encap_length);
     46     for (i = 0; i < msg->lb_encap_length; i++) {
     47         _SHR_PACK_U8(buf, msg->lb_encap[i]);
     48     }
     49 
     50     if (IFA_UC_FEATURE_CHECK(IFA_CONFIG_TRUE_HOP_COUNT)) {
     51         _SHR_PACK_U8(buf, msg->true_hop_count);
     52     }
     53 
     54     return buf;
     55 }
     56 
     57 /*
     58  * Create IFA config information - unpack
     59  */
     60 uint8*
     61 ifa_sdk_msg_ctrl_config_info_unpack(uint8* buf,
     62                                     ifa_sdk_msg_ctrl_config_info_t *msg)
     63 {
     64     int i;
     65 
     66     _SHR_UNPACK_U32(buf, msg->probemarker_1);
     67     _SHR_UNPACK_U32(buf, msg->probemarker_2);
     68     _SHR_UNPACK_U32(buf, msg->device_id);
     69     _SHR_UNPACK_U16(buf, msg->lb_port_1);
     70     _SHR_UNPACK_U16(buf, msg->lb_port_2);
     71     _SHR_UNPACK_U16(buf, msg->module_id);
     72 
     73     _SHR_UNPACK_U16(buf, msg->rx_packet_payload_length);
     74     _SHR_UNPACK_U16(buf, msg->max_payload_length);
     75     _SHR_UNPACK_U8(buf, msg->optional_headers);
     76     _SHR_UNPACK_U8(buf, msg->hop_limit);
     77 
     78     _SHR_UNPACK_U16(buf, msg->int_encap_length);
     79     for (i = 0; i < msg->int_encap_length; i++) {
     80         _SHR_UNPACK_U8(buf, msg->int_encap[i]);
     81     }
     82 
     83     _SHR_UNPACK_U16(buf, msg->lb_encap_length);
     84     for (i = 0; i < msg->lb_encap_length; i++) {
     85         _SHR_UNPACK_U8(buf, msg->lb_encap[i]);
     86     }
     87 
     88     if (IFA_UC_FEATURE_CHECK(IFA_CONFIG_TRUE_HOP_COUNT)) {
     89         _SHR_UNPACK_U8(buf, msg->true_hop_count);
     90     }
     91 
     92     return buf;
     93 }
     94 #else
     95 typedef int bcm_make_iso_compilers_happy;
     96 #endif /* INCLUDE_IFA */