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

olp_pack.c (2564B)


      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:        olp_pack.c
      8  * Purpose:     OLP pack and unpack routines for:
      9  *              - OLP tx/rx header 
     10  *
     11  *
     12  * OLP control messages
     13  *
     14  * OLP messages between the Host CPU and uController are sent
     15  * using the uc_message module which allows short messages
     16  * to be passed (see include/soc/shared/mos_msg_common.h)
     17  *
     18  * Additional information for a given message (a long message) is passed
     19  * using DMA.  The OLP control message types defines the format
     20  * for these long messages.
     21  *
     22  * This file is shared between SDK and uKernel.
     23  */
     24 
     25 #include <soc/defs.h>
     26 #include <shared/pack.h>
     27 #include <soc/shared/olp_pkt.h>
     28 #include <soc/shared/olp_pack.h>
     29 
     30 /*********************************************************
     31  * OLP Tx/Rx Network Packet Header Pack/Unpack
     32  *
     33  * Functions:
     34  *      shr_olp_tx/rx_<header>_pack/unpack
     35  * Purpose:
     36  *      The following set of routines pack/unpack specified
     37  *      network packet header to/from given buffer.
     38  * Parameters:
     39  *   _pack()
     40  *      buffer   - (OUT) Buffer where to pack header.
     41  *      <header> - (IN)  Header to pack.
     42  *   _unpack()
     43  *      buffer   - (IN)  Buffer with data to unpack.
     44  *      <header> - (OUT) Returns unpack header.
     45  * Returns:
     46  *      Pointer to next position in buffer.
     47  * Notes:
     48  *      Assumes pointers are valid and contain enough memory space.
     49  */
     50 uint8 *
     51 shr_olp_tx_header_unpack(uint8 *bufp, soc_olp_tx_hdr_t *opt)
     52 {
     53 
     54     _SHR_UNPACK_U32(bufp,opt->u1.h1);
     55     _SHR_UNPACK_U32(bufp,opt->u2.h2);
     56     _SHR_UNPACK_U32(bufp,opt->u3.h3);
     57     _SHR_UNPACK_U32(bufp,opt->u4.h4);
     58     return bufp;
     59 }
     60 
     61 uint8 *
     62 shr_olp_tx_header_pack(uint8 *bufp, soc_olp_tx_hdr_t *opt)
     63 {
     64 
     65     _SHR_PACK_U32(bufp,opt->u1.h1);
     66     _SHR_PACK_U32(bufp,opt->u2.h2);
     67     _SHR_PACK_U32(bufp,opt->u3.h3);
     68     _SHR_PACK_U32(bufp,opt->u4.h4);
     69     return bufp;
     70 }
     71 
     72 uint8 *
     73 shr_olp_rx_header_unpack(uint8 *bufp, soc_olp_rx_hdr_t *opr)
     74 {
     75     _SHR_UNPACK_U32(bufp,opr->u1.h1);
     76     _SHR_UNPACK_U32(bufp,opr->u2.h2);
     77     _SHR_UNPACK_U32(bufp,opr->u3.h3);
     78     _SHR_UNPACK_U32(bufp,opr->u4.h4);
     79     _SHR_UNPACK_U32(bufp,opr->u5.h5);
     80     return bufp;
     81 }
     82 
     83 uint8 *
     84 shr_olp_rx_header_pack(uint8 *bufp, soc_olp_rx_hdr_t *opr)
     85 {
     86     _SHR_PACK_U32(bufp,opr->u1.h1);
     87     _SHR_PACK_U32(bufp,opr->u2.h2);
     88     _SHR_PACK_U32(bufp,opr->u3.h3);
     89     _SHR_PACK_U32(bufp,opr->u4.h4);
     90     _SHR_PACK_U32(bufp,opr->u5.h5);
     91     return bufp;
     92 }