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

eth_lm_dm_pack.c (18942B)


      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:        eth_lm_dm_pack.c
      8  * Purpose:     ETH_LM_DM pack and unpack routines for:
      9  *              - ETH_LM_DM Control messages
     10  *              - Network Packet headers (PDUs)
     11  *
     12  *
     13  * ETH_LM_DM control messages
     14  *
     15  * ETH_LM_DM messages between the Host CPU and uController are sent
     16  * using the uc_message module which allows short messages
     17  * to be passed (see include/soc/shared/mos_msg_common.h)
     18  *
     19  * Additional information for a given message (a long message) is passed
     20  * using DMA.  The ETH_LM_DM control message types defines the format
     21  * for these long messages.
     22  *
     23  * This file is shared between SDK and uKernel.
     24  */
     25 
     26 #include <shared/pack.h>
     27 #include <soc/defs.h>
     28 #include <soc/shared/olp_pkt.h>
     29 #include <soc/shared/olp_pack.h>
     30 #include <bcm_int/esw/eth_lm_dm.h>
     31 #include <soc/shared/eth_lm_dm_msg.h>
     32 #include <soc/shared/eth_lm_dm_pkt.h>
     33 #include <soc/shared/eth_lm_dm_pack.h>
     34 #include <bcm_int/esw/eth_lm_dm.h>
     35 
     36 
     37 /***********************************************************
     38  * ETH_LM_DM Control Message Pack/Unpack
     39  *
     40  * Functions:
     41  *      shr_eth_lm_dm_msg_ctrl_<type>_pack/unpack
     42  * Purpose:
     43  *      The following set of routines pack/unpack specified
     44  *      ETH_LM_DM control message into/from a given buffer
     45  * Parameters:
     46  *   _pack()
     47  *      buffer  - (OUT) Buffer where to pack message.
     48  *      msg     - (IN)  ETH_LM_DM control message to pack.
     49  *   _unpack()
     50  *      buffer  - (IN)  Buffer with message to unpack.
     51  *      msg     - (OUT) Returns ETH_LM_DM control message.
     52  * Returns:
     53  *      Pointer to next position in buffer.
     54  * Notes:
     55  *      Assumes pointers are valid and contain enough memory space.
     56  */
     57 uint8 *
     58 shr_eth_lm_dm_msg_ctrl_init_pack(uint8 *buf, shr_eth_lm_dm_msg_ctrl_init_t *msg)
     59 {
     60    
     61 
     62     _SHR_PACK_U32(buf, msg->num_sessions);
     63     _SHR_PACK_U32(buf, msg->rx_channel);
     64     return buf;
     65 }
     66 
     67 uint8 *
     68 shr_eth_lm_dm_msg_ctrl_init_unpack(uint8 *buf, shr_eth_lm_dm_msg_ctrl_init_t *msg)
     69 {
     70     
     71 
     72     _SHR_UNPACK_U32(buf, msg->num_sessions);
     73     _SHR_UNPACK_U32(buf, msg->rx_channel);
     74     return buf;
     75 }
     76 
     77 
     78 uint8 *
     79 shr_eth_lm_dm_msg_ctrl_sess_delete_pack(uint8 *buf, shr_eth_lm_dm_msg_ctrl_sess_delete_t *msg)
     80 {
     81     _SHR_PACK_U32(buf, msg->sess_id);
     82     return buf;
     83 }
     84 
     85 uint8 *
     86 shr_eth_lm_dm_msg_ctrl_sess_delete_unpack(uint8 *buf, shr_eth_lm_dm_msg_ctrl_sess_delete_t *msg)
     87 {
     88     _SHR_UNPACK_U32(buf, msg->sess_id);
     89     return buf;
     90 }
     91 
     92     uint8 *
     93 shr_eth_lm_dm_msg_ctrl_sess_set_pack(uint8 *buf,
     94         shr_eth_lm_dm_msg_ctrl_sess_set_t *msg)
     95 {
     96     uint16 i;
     97     uint32 l2_encap_length;
     98 
     99     /* Pack OLP and ETH-L2 in the same buffer. OLP Tx will be put into the Tx
    100      * Buffer in between these two L2 encap into the Tx_pkt kept in message
    101      * control structure while loss/delay add
    102      */
    103     l2_encap_length = msg->eth_l2_encap_length + sizeof(soc_olp_l2_hdr_t);
    104 
    105     _SHR_PACK_U32(buf, msg->sess_id);             
    106     _SHR_PACK_U32(buf, msg->flags);
    107     _SHR_PACK_U8(buf, msg->passive);
    108     _SHR_PACK_U8(buf, msg->mel);
    109     _SHR_PACK_U16(buf, msg->mep_id);
    110     _SHR_PACK_U32(buf, msg->period);
    111     _SHR_PACK_U32(buf, msg->eth_l2_encap_length);
    112 
    113     l2_encap_length = msg->eth_l2_encap_length + sizeof(soc_olp_l2_hdr_t);
    114 
    115     for (i = 0; i < l2_encap_length; i++) {
    116         _SHR_PACK_U8(buf, msg->encap_data[i]);
    117     }
    118     _SHR_PACK_U32(buf, msg->tx_port);
    119 
    120     _SHR_PACK_U32(buf, msg->lm_counter_index);
    121     _SHR_PACK_U16(buf, msg->vlan_id);
    122     _SHR_PACK_U16(buf, msg->outer_vlan_id);
    123     _SHR_PACK_U8(buf, msg->mep_type);
    124     _SHR_PACK_U16(buf, msg->group_id);
    125 
    126     return buf;
    127 }
    128 
    129     uint8 *
    130 shr_eth_lm_dm_msg_ctrl_sess_set_unpack(uint8 *buf,
    131         shr_eth_lm_dm_msg_ctrl_sess_set_t *msg)
    132 {
    133     uint16 i;
    134     uint32 l2_encap_length;
    135 
    136     /* UnPack OLP and ETH-L2 in the same buffer. OLP Tx will be retrieved as
    137      * part of loss/delay get
    138      */
    139 
    140     _SHR_UNPACK_U32(buf, msg->sess_id);             
    141     _SHR_UNPACK_U32(buf, msg->flags);
    142     _SHR_UNPACK_U8(buf, msg->passive);
    143     _SHR_UNPACK_U8(buf, msg->mel);
    144     _SHR_UNPACK_U16(buf, msg->mep_id);
    145     _SHR_UNPACK_U32(buf, msg->period);
    146     _SHR_UNPACK_U32(buf, msg->eth_l2_encap_length);
    147 
    148     l2_encap_length = msg->eth_l2_encap_length + sizeof(soc_olp_l2_hdr_t);
    149 
    150     for (i = 0; i < l2_encap_length; i++) {
    151         _SHR_UNPACK_U8(buf, msg->encap_data[i]);
    152     }
    153 
    154     _SHR_UNPACK_U32(buf, msg->tx_port);
    155 
    156     _SHR_UNPACK_U32(buf, msg->lm_counter_index);
    157     _SHR_UNPACK_U16(buf, msg->vlan_id);
    158     _SHR_UNPACK_U16(buf, msg->outer_vlan_id);
    159     _SHR_UNPACK_U8(buf, msg->mep_type);
    160     _SHR_UNPACK_U16(buf, msg->group_id);
    161     return buf;
    162 }
    163 
    164 
    165 
    166 uint8 *
    167 shr_eth_lm_dm_msg_ctrl_sess_get_pack(uint8 *buf,
    168                                shr_eth_lm_dm_msg_ctrl_sess_get_t *msg)
    169 {
    170     int i;
    171     uint32 l2_encap_length;
    172 
    173     /* Pack OLP and ETH-L2 in the same buffer. OLP Tx will be put into the Tx
    174      * Buffer in between these two L2 encap into the Tx_pkt kept in message
    175      * control structure while loss/delay add
    176          */
    177 
    178     _SHR_PACK_U32(buf, msg->sess_id);
    179     _SHR_PACK_U8(buf, msg->enable);
    180     _SHR_PACK_U8(buf, msg->passive);
    181     _SHR_PACK_U8(buf, msg->mel);
    182     _SHR_PACK_U16(buf, msg->mep_id);
    183     _SHR_PACK_U32(buf, msg->period);
    184 
    185     _SHR_PACK_U32(buf, msg->eth_l2_encap_length);
    186     l2_encap_length = msg->eth_l2_encap_length + sizeof(soc_olp_l2_hdr_t);
    187 
    188     for (i = 0; i < l2_encap_length; i++) {
    189         _SHR_PACK_U8(buf, msg->encap_data[i]);
    190     }
    191 
    192     _SHR_PACK_U32(buf, msg->tx_port);
    193 
    194 	_SHR_PACK_U32(buf, msg->lm_counter_index);
    195 	_SHR_PACK_U16(buf, msg->vlan_id);
    196 	_SHR_PACK_U16(buf, msg->outer_vlan_id);
    197 	_SHR_PACK_U8(buf, msg->mep_type);
    198 	_SHR_PACK_U16(buf, msg->group_id);
    199 
    200     return buf;
    201 }
    202 
    203 uint8 *
    204 shr_eth_lm_dm_msg_ctrl_sess_get_unpack(uint8 *buf,
    205                                  shr_eth_lm_dm_msg_ctrl_sess_get_t *msg)
    206 {
    207     int i;
    208     uint32 l2_encap_length;
    209 
    210     /* UnPack OLP and ETH-L2 in the same buffer. OLP Tx will be retrieved as
    211      * part of loss/delay get
    212      */
    213 
    214     _SHR_UNPACK_U32(buf, msg->sess_id);
    215     _SHR_UNPACK_U8(buf, msg->enable);
    216     _SHR_UNPACK_U8(buf, msg->passive); 
    217     _SHR_UNPACK_U8(buf, msg->mel);
    218     _SHR_UNPACK_U16(buf, msg->mep_id);
    219     _SHR_UNPACK_U32(buf, msg->period);
    220     _SHR_UNPACK_U32(buf, msg->eth_l2_encap_length);
    221     l2_encap_length = msg->eth_l2_encap_length + sizeof(soc_olp_l2_hdr_t);
    222 
    223     for (i = 0; i < l2_encap_length; i++) {
    224         _SHR_UNPACK_U8(buf, msg->encap_data[i]);
    225     }
    226 
    227     _SHR_UNPACK_U32(buf, msg->tx_port);
    228     
    229     _SHR_UNPACK_U32(buf, msg->lm_counter_index);
    230 	_SHR_UNPACK_U16(buf, msg->vlan_id);
    231 	_SHR_UNPACK_U16(buf, msg->outer_vlan_id);
    232 	_SHR_UNPACK_U8(buf, msg->mep_type);
    233 	_SHR_UNPACK_U16(buf, msg->group_id);
    234 
    235     return buf;
    236 }
    237 
    238 uint8 *
    239 shr_eth_lm_dm_msg_ctrl_stat_req_pack(uint8 *buf,
    240                                shr_eth_lm_dm_msg_ctrl_stat_req_t *msg)
    241 {
    242     _SHR_PACK_U32(buf, msg->sess_id);
    243     _SHR_PACK_U32(buf, msg->clear);
    244 
    245     return buf;
    246 }
    247 
    248 uint8 *
    249 shr_eth_lm_dm_msg_ctrl_stat_req_unpack(uint8 *buf,
    250                                  shr_eth_lm_dm_msg_ctrl_stat_req_t *msg)
    251 {
    252     _SHR_UNPACK_U32(buf, msg->sess_id);
    253     _SHR_UNPACK_U32(buf, msg->clear);
    254 
    255     return buf;
    256 }
    257 
    258 uint8 *
    259 shr_eth_lm_dm_msg_ctrl_stat_reply_pack(uint8 *buf,
    260                                  shr_eth_lm_dm_msg_ctrl_stat_reply_t *msg)
    261 {
    262     _SHR_PACK_U32(buf, msg->sess_id);
    263     _SHR_PACK_U32(buf, msg->packets_in);
    264     _SHR_PACK_U32(buf, msg->packets_out);
    265     _SHR_PACK_U32(buf, msg->packets_drop);
    266     return buf;
    267 }
    268 
    269 uint8 *
    270 shr_eth_lm_dm_msg_ctrl_stat_reply_unpack(uint8 *buf,
    271                                    shr_eth_lm_dm_msg_ctrl_stat_reply_t *msg)
    272 {
    273     _SHR_UNPACK_U32(buf, msg->sess_id);
    274     _SHR_UNPACK_U32(buf, msg->packets_in);
    275     _SHR_UNPACK_U32(buf, msg->packets_out);
    276     _SHR_UNPACK_U32(buf, msg->packets_drop);
    277 
    278 
    279     return buf;
    280 }
    281 
    282 uint8 *
    283 shr_eth_lm_dm_msg_ctrl_loss_add_pack(uint8 *buf,
    284                                  shr_eth_lm_dm_msg_ctrl_loss_add_t *msg)
    285 {
    286 	int i;
    287     _SHR_PACK_U32(buf, msg->flags);
    288     _SHR_PACK_U32(buf, msg->sess_id);
    289     _SHR_PACK_U32(buf, msg->period);
    290     _SHR_PACK_U32(buf, msg->tx_cos);
    291     _SHR_PACK_U8 (buf, msg->tx_pri);
    292     _SHR_PACK_U32(buf, msg->tx_qnum);
    293 	for (i = 0; i < _ETH_LM_DM_MAC_ADDR_LENGTH; i++) {
    294 		_SHR_PACK_U8(buf, msg->dst_mac[i]);
    295 	}
    296     for (i = 0; i < SHR_ETH_LM_DM_OLP_TX_HDR_LENGTH; i++) {
    297 		_SHR_PACK_U8(buf, msg->olp_tx_hdr[i]);
    298 	}
    299     _SHR_PACK_U32(buf, msg->olp_tx_hdr_length);
    300     _SHR_PACK_U32(buf, msg->remote_mep_id);
    301     return buf;
    302 }
    303 
    304 uint8 *
    305 shr_eth_lm_dm_msg_ctrl_loss_add_unpack(uint8 *buf,
    306                                  shr_eth_lm_dm_msg_ctrl_loss_add_t *msg)
    307 {
    308 
    309 	int i;
    310     _SHR_UNPACK_U32(buf, msg->flags);
    311     _SHR_UNPACK_U32(buf, msg->sess_id);
    312     _SHR_UNPACK_U32(buf, msg->period);
    313     _SHR_UNPACK_U32(buf, msg->tx_cos);
    314     _SHR_UNPACK_U8 (buf, msg->tx_pri);
    315     _SHR_UNPACK_U32(buf, msg->tx_qnum);
    316 	for (i = 0; i < _ETH_LM_DM_MAC_ADDR_LENGTH; i++) {
    317 		_SHR_UNPACK_U8(buf, msg->dst_mac[i]);
    318 	}   
    319     for (i = 0; i < SHR_ETH_LM_DM_OLP_TX_HDR_LENGTH; i++) {
    320 		_SHR_UNPACK_U8(buf, msg->olp_tx_hdr[i]);
    321 	}   
    322     _SHR_UNPACK_U32(buf, msg->olp_tx_hdr_length);
    323     _SHR_UNPACK_U32(buf, msg->remote_mep_id);
    324     return buf;
    325 }
    326 
    327 uint8 *
    328 shr_eth_lm_dm_msg_ctrl_loss_delete_pack(uint8 *buf,
    329                                  shr_eth_lm_dm_msg_ctrl_loss_delete_t *msg)
    330 {
    331     _SHR_PACK_U32(buf, msg->sess_id);
    332 
    333     return buf;
    334 }
    335 
    336 uint8 *
    337 shr_eth_lm_dm_msg_ctrl_loss_delete_unpack(uint8 *buf,
    338                                  shr_eth_lm_dm_msg_ctrl_loss_delete_t *msg)
    339 {
    340     _SHR_UNPACK_U32(buf, msg->sess_id);
    341 
    342     return buf;
    343 }
    344 
    345 uint8 *
    346 shr_eth_lm_dm_msg_ctrl_loss_get_pack(uint8 *buf,
    347                                  shr_eth_lm_dm_msg_ctrl_loss_get_t *msg)
    348 {
    349 	int i;
    350     _SHR_PACK_U32(buf, msg->flags);
    351     _SHR_PACK_U32(buf, msg->sess_id);
    352     _SHR_PACK_U32(buf, msg->period);
    353     _SHR_PACK_U32(buf, msg->loss_threshold);
    354     _SHR_PACK_U32(buf, msg->loss_nearend);
    355 	_SHR_PACK_U32(buf, msg->loss_farend);
    356     _SHR_PACK_U32(buf, msg->tx_nearend);
    357     _SHR_PACK_U32(buf, msg->rx_nearend);
    358     _SHR_PACK_U32(buf, msg->tx_farend);
    359     _SHR_PACK_U32(buf, msg->rx_farend);
    360     _SHR_PACK_U32(buf, msg->rx_oam_packets);
    361     _SHR_PACK_U32(buf, msg->tx_oam_packets);
    362     _SHR_PACK_U32(buf, msg->tx_cos);
    363     _SHR_PACK_U8 (buf, msg->tx_pri);
    364     _SHR_PACK_U32(buf, msg->tx_qnum);
    365 	for (i = 0; i < _ETH_LM_DM_MAC_ADDR_LENGTH; i++) {
    366 		_SHR_PACK_U8(buf, msg->dst_mac[i]);
    367 	}
    368     for (i = 0; i < SHR_ETH_LM_DM_OLP_TX_HDR_LENGTH; i++) {
    369 		_SHR_PACK_U8(buf, msg->olp_tx_hdr[i]);
    370 	}
    371     _SHR_PACK_U32(buf, msg->olp_tx_hdr_length);
    372     _SHR_PACK_U32(buf, msg->remote_mep_id);
    373     return buf;
    374 }
    375 
    376 uint8 *
    377 shr_eth_lm_dm_msg_ctrl_loss_get_unpack(uint8 *buf,
    378                                  shr_eth_lm_dm_msg_ctrl_loss_get_t *msg)
    379 {
    380 	int i;
    381     _SHR_UNPACK_U32(buf, msg->flags);
    382     _SHR_UNPACK_U32(buf, msg->sess_id);
    383     _SHR_UNPACK_U32(buf, msg->period);
    384     _SHR_UNPACK_U32(buf, msg->loss_threshold);
    385     _SHR_UNPACK_U32(buf, msg->loss_nearend);
    386 	_SHR_UNPACK_U32(buf, msg->loss_farend);
    387     _SHR_UNPACK_U32(buf, msg->tx_nearend);
    388     _SHR_UNPACK_U32(buf, msg->rx_nearend);
    389     _SHR_UNPACK_U32(buf, msg->tx_farend);
    390     _SHR_UNPACK_U32(buf, msg->rx_farend);
    391     _SHR_UNPACK_U32(buf, msg->rx_oam_packets);
    392     _SHR_UNPACK_U32(buf, msg->tx_oam_packets);
    393     _SHR_UNPACK_U32(buf, msg->tx_cos);
    394     _SHR_UNPACK_U8 (buf, msg->tx_pri);
    395     _SHR_UNPACK_U32(buf, msg->tx_qnum);
    396 	for (i = 0; i < _ETH_LM_DM_MAC_ADDR_LENGTH; i++) {
    397 		_SHR_UNPACK_U8(buf, msg->dst_mac[i]);
    398 	}
    399     for (i = 0; i < SHR_ETH_LM_DM_OLP_TX_HDR_LENGTH; i++) {
    400 		_SHR_UNPACK_U8(buf, msg->olp_tx_hdr[i]);
    401 	}
    402     _SHR_UNPACK_U32(buf, msg->olp_tx_hdr_length);
    403     _SHR_UNPACK_U32(buf, msg->remote_mep_id);
    404     return buf;
    405 }
    406 
    407 uint8 *
    408 shr_eth_lm_dm_msg_ctrl_delay_add_pack(uint8 *buf,
    409                                  shr_eth_lm_dm_msg_ctrl_delay_add_t *msg)
    410 {
    411 	int i;
    412     _SHR_PACK_U32(buf, msg->flags);
    413     _SHR_PACK_U32(buf, msg->sess_id);
    414     _SHR_PACK_U32(buf, msg->period);
    415     _SHR_PACK_U32(buf, msg->tx_cos);
    416     _SHR_PACK_U8 (buf, msg->tx_pri);
    417     _SHR_PACK_U32(buf, msg->tx_qnum);
    418     _SHR_PACK_U8 (buf, msg->dm_format); 
    419 	for (i = 0; i < _ETH_LM_DM_MAC_ADDR_LENGTH; i++) {
    420 		_SHR_PACK_U8(buf, msg->dst_mac[i]);
    421 	}
    422     for (i = 0; i < SHR_ETH_LM_DM_OLP_TX_HDR_LENGTH; i++) {
    423 		_SHR_PACK_U8(buf, msg->olp_tx_hdr[i]);
    424 	}
    425     _SHR_PACK_U32(buf, msg->olp_tx_hdr_length);
    426     _SHR_PACK_U32(buf, msg->remote_mep_id);
    427     return buf;
    428 }
    429 
    430 uint8 *
    431 shr_eth_lm_dm_msg_ctrl_delay_add_unpack(uint8 *buf,
    432                                  shr_eth_lm_dm_msg_ctrl_delay_add_t *msg)
    433 {
    434     int i;
    435     _SHR_UNPACK_U32(buf, msg->flags);
    436     _SHR_UNPACK_U32(buf, msg->sess_id);
    437     _SHR_UNPACK_U32(buf, msg->period);
    438     _SHR_UNPACK_U32(buf, msg->tx_cos);
    439     _SHR_UNPACK_U8 (buf, msg->tx_pri);
    440     _SHR_UNPACK_U32(buf, msg->tx_qnum);
    441     _SHR_UNPACK_U8 (buf, msg->dm_format);
    442 	for (i = 0; i < _ETH_LM_DM_MAC_ADDR_LENGTH; i++) {
    443 		_SHR_UNPACK_U8(buf, msg->dst_mac[i]);
    444 	}
    445     for (i = 0; i < SHR_ETH_LM_DM_OLP_TX_HDR_LENGTH; i++) {
    446 		_SHR_UNPACK_U8(buf, msg->olp_tx_hdr[i]);
    447 	}
    448     _SHR_UNPACK_U32(buf, msg->olp_tx_hdr_length);
    449     _SHR_UNPACK_U32(buf, msg->remote_mep_id);
    450     return buf;
    451 }
    452 
    453 uint8 *
    454 shr_eth_lm_dm_msg_ctrl_delay_delete_pack(uint8 *buf,
    455                                  shr_eth_lm_dm_msg_ctrl_delay_delete_t *msg)
    456 {
    457     _SHR_PACK_U32(buf, msg->sess_id);
    458 
    459     return buf;
    460 }
    461 
    462 uint8 *
    463 shr_eth_lm_dm_msg_ctrl_delay_delete_unpack(uint8 *buf,
    464                                  shr_eth_lm_dm_msg_ctrl_delay_delete_t *msg)
    465 {
    466     _SHR_UNPACK_U32(buf, msg->sess_id);
    467 
    468     return buf;
    469 }
    470 
    471 uint8 *
    472 shr_eth_lm_dm_msg_ctrl_delay_get_pack(uint8 *buf,
    473                                  shr_eth_lm_dm_msg_ctrl_delay_get_t *msg)
    474 {
    475 	int i;
    476     _SHR_PACK_U32(buf, msg->flags);
    477     _SHR_PACK_U32(buf, msg->sess_id);
    478     _SHR_PACK_U32(buf, msg->period);
    479     _SHR_PACK_U32(buf, msg->delay_seconds);
    480     _SHR_PACK_U32(buf, msg->delay_nanoseconds);
    481     _SHR_PACK_U32(buf, msg->txf_seconds);
    482     _SHR_PACK_U32(buf, msg->txf_nanoseconds);
    483     _SHR_PACK_U32(buf, msg->rxf_seconds);
    484     _SHR_PACK_U32(buf, msg->rxf_nanoseconds);
    485     _SHR_PACK_U32(buf, msg->txb_seconds);
    486     _SHR_PACK_U32(buf, msg->txb_nanoseconds);
    487     _SHR_PACK_U32(buf, msg->rxb_seconds);
    488     _SHR_PACK_U32(buf, msg->rxb_nanoseconds);
    489     _SHR_PACK_U32(buf, msg->rx_oam_packets);
    490     _SHR_PACK_U32(buf, msg->tx_oam_packets);
    491     _SHR_PACK_U32(buf, msg->tx_cos);
    492     _SHR_PACK_U8 (buf, msg->tx_pri);
    493     _SHR_PACK_U32(buf, msg->tx_qnum);
    494     _SHR_PACK_U8 (buf, msg->dm_format);
    495 	for (i = 0; i < _ETH_LM_DM_MAC_ADDR_LENGTH; i++) {
    496 		_SHR_PACK_U8(buf, msg->dst_mac[i]);
    497 	}
    498     for (i = 0; i < SHR_ETH_LM_DM_OLP_TX_HDR_LENGTH; i++) {
    499 		_SHR_PACK_U8(buf, msg->olp_tx_hdr[i]);
    500 	}
    501     _SHR_PACK_U32(buf, msg->olp_tx_hdr_length);
    502     _SHR_PACK_U32(buf, msg->remote_mep_id);
    503     return buf;
    504 }
    505 
    506 uint8 *
    507 shr_eth_lm_dm_msg_ctrl_delay_get_unpack(uint8 *buf,
    508                                  shr_eth_lm_dm_msg_ctrl_delay_get_t *msg)
    509 {
    510 	int i;
    511     _SHR_UNPACK_U32(buf, msg->flags);
    512     _SHR_UNPACK_U32(buf, msg->sess_id);
    513     _SHR_UNPACK_U32(buf, msg->period);
    514     _SHR_UNPACK_U32(buf, msg->delay_seconds);
    515     _SHR_UNPACK_U32(buf, msg->delay_nanoseconds);
    516     _SHR_UNPACK_U32(buf, msg->txf_seconds);
    517     _SHR_UNPACK_U32(buf, msg->txf_nanoseconds);
    518     _SHR_UNPACK_U32(buf, msg->rxf_seconds);
    519     _SHR_UNPACK_U32(buf, msg->rxf_nanoseconds);
    520     _SHR_UNPACK_U32(buf, msg->txb_seconds);
    521     _SHR_UNPACK_U32(buf, msg->txb_nanoseconds);
    522     _SHR_UNPACK_U32(buf, msg->rxb_seconds);
    523     _SHR_UNPACK_U32(buf, msg->rxb_nanoseconds);
    524     _SHR_UNPACK_U32(buf, msg->rx_oam_packets);
    525     _SHR_UNPACK_U32(buf, msg->tx_oam_packets);
    526     _SHR_UNPACK_U32(buf, msg->tx_cos);
    527     _SHR_UNPACK_U8 (buf, msg->tx_pri);
    528     _SHR_UNPACK_U32(buf, msg->tx_qnum);
    529     _SHR_UNPACK_U8 (buf, msg->dm_format);
    530 	for (i = 0; i < _ETH_LM_DM_MAC_ADDR_LENGTH; i++) {
    531 		_SHR_UNPACK_U8(buf, msg->dst_mac[i]);
    532 	}
    533     for (i = 0; i < SHR_ETH_LM_DM_OLP_TX_HDR_LENGTH; i++) {
    534 		_SHR_UNPACK_U8(buf, msg->olp_tx_hdr[i]);
    535 	}
    536     _SHR_UNPACK_U32(buf, msg->olp_tx_hdr_length);
    537     _SHR_UNPACK_U32(buf, msg->remote_mep_id);
    538     return buf;
    539 }
    540 
    541 /*********************************************************
    542  * ETH_LM_DM Network Packet Header Pack/Unpack
    543  *
    544  * Functions:
    545  *      shr_eth_lm_dm_<header>_pack/unpack
    546  * Purpose:
    547  *      The following set of routines pack/unpack specified
    548  *      network packet header to/from given buffer.
    549  * Parameters:
    550  *   _pack()
    551  *      buffer   - (OUT) Buffer where to pack header.
    552  *      <header> - (IN)  Header to pack.
    553  *   _unpack()
    554  *      buffer   - (IN)  Buffer with data to unpack.
    555  *      <header> - (OUT) Returns unpack header.
    556  * Returns:
    557  *      Pointer to next position in buffer.
    558  * Notes:
    559  *      Assumes pointers are valid and contain enough memory space.
    560  */
    561 uint8 *
    562 shr_eth_lm_dm_header_pack(uint8 *buf, shr_eth_lm_dm_header_t *eth_lm_dm)
    563 {
    564     uint32 *ptr;
    565 
    566     ptr = (uint32 *)eth_lm_dm;
    567 
    568     _SHR_PACK_U32(buf, ptr[0]);
    569 #if 0
    570     _SHR_PACK_U8(buf, eth_lm_dm->opcode);
    571     _SHR_PACK_U8(buf, eth_lm_dm->flags);
    572     _SHR_PACK_U8(buf, eth_lm_dm->tlv_offset);
    573 #endif
    574     return buf;
    575 }
    576 
    577 uint8 *
    578 shr_eth_lm_dm_header_unpack(uint8 *buf, shr_eth_lm_dm_header_t *eth_lm_dm)
    579 {
    580     uint32 *ptr;
    581 
    582     ptr = (uint32 *)eth_lm_dm;
    583 
    584     _SHR_UNPACK_U32(buf, ptr[0]);
    585 #if 0
    586     uint8 *byte;
    587 
    588     byte = (uint8 *)eth_lm_dm;
    589 
    590     _SHR_UNPACK_U8(buf, byte[0]);
    591     _SHR_UNPACK_U8(buf, eth_lm_dm->opcode);
    592     _SHR_UNPACK_U8(buf, eth_lm_dm->flags);
    593     _SHR_UNPACK_U8(buf, eth_lm_dm->tlv_offset);
    594 #endif
    595     return buf;
    596 }
    597 
    598 /*********************************************************
    599  * ETH_LM_DM Network Packet SLM info Header Pack/Unpack
    600  *
    601  * Functions:
    602  *      shr_eth_lm_dm_<header>_pack/unpack
    603  * Purpose:
    604  *      The following set of routines pack/unpack specified
    605  *      network packet header to/from given buffer.
    606  * Parameters:
    607  *   _pack()
    608  *      buffer   - (OUT) Buffer where to pack header.
    609  *      <header> - (IN)  Header to pack.
    610  *   _unpack()
    611  *      buffer   - (IN)  Buffer with data to unpack.
    612  *      <header> - (OUT) Returns unpack header.
    613  * Returns:
    614  *      Pointer to next position in buffer.
    615  * Notes:
    616  *      Assumes pointers are valid and contain enough memory space.
    617  */
    618 uint8 *
    619 shr_eth_lm_dm_slm_info_header_pack(uint8 *buf, shr_eth_lm_dm_slm_info_header_t *eth_lm_dm_slm_info)
    620 {
    621 	_SHR_PACK_U16(buf, eth_lm_dm_slm_info->src_mep_id);
    622 	_SHR_PACK_U16(buf, eth_lm_dm_slm_info->resp_mep_id);
    623 	_SHR_PACK_U32(buf, eth_lm_dm_slm_info->test_id);
    624     return buf;
    625 }
    626 
    627 uint8 *
    628 shr_eth_lm_dm_slm_info_header_unpack(uint8 *buf, shr_eth_lm_dm_slm_info_header_t *eth_lm_dm_slm_info)
    629 {
    630 
    631 
    632 	_SHR_UNPACK_U16(buf, eth_lm_dm_slm_info->src_mep_id);
    633 	_SHR_UNPACK_U16(buf, eth_lm_dm_slm_info->resp_mep_id);
    634 	_SHR_UNPACK_U32(buf, eth_lm_dm_slm_info->test_id);
    635 
    636     return buf;
    637 }
    638