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

oam_pm_pack.c (5614B)


      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:        oam_pm.c
      8  * Purpose:     OAM_PM pack and unpack routines for:
      9  *              - OAM_PM Control messages
     10  *              - Network Packet headers (PDUs)
     11  *
     12  *
     13  * OAM_PM control messages
     14  *
     15  * OAM_PM 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 OAM_PM 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/shared/oam_pm_pack.h>
     28 
     29 
     30 uint8 *
     31 shr_oam_pm_msg_ctrl_pm_stats_get_pack(uint8 *buf,
     32                                  shr_oam_pm_msg_ctrl_pm_stats_get_t *msg)
     33 {
     34 
     35     int i;
     36     _SHR_PACK_U32(buf,msg->flags);
     37     _SHR_PACK_U32(buf,msg->sess_id);
     38     _SHR_PACK_U32(buf,msg->far_loss_min);
     39     _SHR_PACK_U32(buf,msg->far_tx_min);
     40     _SHR_PACK_U32(buf,msg->far_loss_max);
     41     _SHR_PACK_U32(buf,msg->far_tx_max);
     42     _SHR_PACK_U32(buf,msg->far_loss);
     43     _SHR_PACK_U32(buf,msg->near_loss_min);
     44     _SHR_PACK_U32(buf,msg->near_tx_min);
     45     _SHR_PACK_U32(buf,msg->near_loss_max);
     46     _SHR_PACK_U32(buf,msg->near_tx_max);
     47     _SHR_PACK_U32(buf,msg->near_loss);
     48     _SHR_PACK_U32(buf,msg->lm_tx_count);
     49     _SHR_PACK_U32(buf,msg->DM_min);
     50     _SHR_PACK_U32(buf,msg->DM_max);
     51     _SHR_PACK_U32(buf,msg->DM_avg);
     52     _SHR_PACK_U32(buf,msg->dm_tx_count);
     53     _SHR_PACK_U8(buf,msg->profile_id);
     54     for (i = 0; i < (SHR_OAM_PM_MAX_PM_BIN_EDGES+1); i++) {
     55         _SHR_PACK_U32(buf, msg->bin_counters[i]);
     56     }
     57 
     58     return buf;
     59 }
     60 
     61 uint8 *
     62 shr_oam_pm_msg_ctrl_pm_stats_get_unpack(uint8 *buf,
     63                                  shr_oam_pm_msg_ctrl_pm_stats_get_t *msg,
     64                                  uint8 pm_stat_extra_elem_feature)
     65 {
     66     int i;
     67 
     68     _SHR_UNPACK_U32(buf,msg->flags);
     69     _SHR_UNPACK_U32(buf,msg->sess_id);
     70     _SHR_UNPACK_U32(buf,msg->far_loss_min);
     71     _SHR_UNPACK_U32(buf,msg->far_tx_min);
     72     _SHR_UNPACK_U32(buf,msg->far_loss_max);
     73     _SHR_UNPACK_U32(buf,msg->far_tx_max);
     74     _SHR_UNPACK_U32(buf,msg->far_loss);
     75     _SHR_UNPACK_U32(buf,msg->near_loss_min);
     76     _SHR_UNPACK_U32(buf,msg->near_tx_min);
     77     _SHR_UNPACK_U32(buf,msg->near_loss_max);
     78     _SHR_UNPACK_U32(buf,msg->near_tx_max);
     79     _SHR_UNPACK_U32(buf,msg->near_loss);
     80     _SHR_UNPACK_U32(buf,msg->lm_tx_count);
     81     _SHR_UNPACK_U32(buf,msg->DM_min);
     82     _SHR_UNPACK_U32(buf,msg->DM_max);
     83     _SHR_UNPACK_U32(buf,msg->DM_avg);
     84     _SHR_UNPACK_U32(buf,msg->dm_tx_count);
     85     _SHR_UNPACK_U8(buf,msg->profile_id);
     86     for (i = 0; i < (SHR_OAM_PM_MAX_PM_BIN_EDGES+1); i++) {
     87         _SHR_UNPACK_U32(buf, msg->bin_counters[i]);
     88     }
     89 
     90     if(pm_stat_extra_elem_feature) {
     91         _SHR_UNPACK_U32(buf, msg->lm_rx_count);
     92         _SHR_UNPACK_U32(buf, msg->dm_rx_count);
     93         _SHR_UNPACK_U32(buf, msg->far_total_tx_pkt_count);
     94         _SHR_UNPACK_U32(buf, msg->near_total_tx_pkt_count);
     95     }
     96     
     97     return buf;
     98 }
     99 
    100 uint8 *
    101 shr_oam_pm_msg_ctrl_profile_attach_pack(uint8 *buf,
    102                                  shr_oam_pm_msg_ctrl_profile_attach_t *msg)
    103 {
    104 
    105     int i;
    106     _SHR_PACK_U32(buf,msg->sess_id);
    107     _SHR_PACK_U32(buf,msg->profile_flags);
    108     _SHR_PACK_U8(buf,msg->profile_id);
    109     for (i = 0; i < SHR_OAM_PM_MAX_PM_BIN_EDGES; i++) {
    110         _SHR_PACK_U32(buf, msg->profile_edges[i]);
    111     }
    112 
    113     return buf;
    114 }
    115 
    116 uint8 *
    117 shr_oam_pm_msg_ctrl_profile_attach_unpack(uint8 *buf,
    118                                  shr_oam_pm_msg_ctrl_profile_attach_t *msg)
    119 {
    120     int i;
    121     _SHR_UNPACK_U32(buf,msg->sess_id);
    122     _SHR_UNPACK_U32(buf,msg->profile_flags);
    123     _SHR_UNPACK_U8(buf,msg->profile_id);
    124     for (i = 0; i < SHR_OAM_PM_MAX_PM_BIN_EDGES; i++) {
    125         _SHR_UNPACK_U32(buf, msg->profile_edges[i]);
    126     }
    127     
    128     return buf;
    129 }
    130 
    131 uint8 *
    132 shr_oam_pm_msg_ctrl_raw_buffer_unpack(uint8 *buf,
    133                                  shr_oam_pm_msg_ctrl_raw_buffer_t *msg)
    134 {
    135     int i, j;
    136     _SHR_UNPACK_U32(buf, msg->seq_num);
    137     for (i = 0; i < SHR_OAM_MAX_PM_ENDPOINTS; i++) {
    138 
    139         _SHR_UNPACK_U32(buf, msg->raw_sample[i].pm_id);
    140         _SHR_UNPACK_U32(buf, msg->raw_sample[i].lm_count);
    141         _SHR_UNPACK_U32(buf, msg->raw_sample[i].dm_count);
    142         for (j = 0; j < SHR_OAM_PM_RAW_DATA_MAX_SAMPLES; j++) {
    143             _SHR_UNPACK_U32(buf, msg->raw_sample[i].raw_counter[j].tx_fcf);
    144             _SHR_UNPACK_U32(buf, msg->raw_sample[i].raw_counter[j].rx_fcf);
    145             _SHR_UNPACK_U32(buf, msg->raw_sample[i].raw_counter[j].tx_fcb);
    146             _SHR_UNPACK_U32(buf, msg->raw_sample[i].raw_counter[j].rx_fcb);
    147         }
    148         for (j = 0; j < SHR_OAM_PM_RAW_DATA_MAX_SAMPLES; j++) {
    149             _SHR_UNPACK_U32(buf, msg->raw_sample[i].raw_timestamp[j].tx_tsf_secs);
    150             _SHR_UNPACK_U32(buf, msg->raw_sample[i].raw_timestamp[j].tx_tsf_nsecs);
    151             _SHR_UNPACK_U32(buf, msg->raw_sample[i].raw_timestamp[j].rx_tsf_secs);
    152             _SHR_UNPACK_U32(buf, msg->raw_sample[i].raw_timestamp[j].rx_tsf_nsecs);
    153             _SHR_UNPACK_U32(buf, msg->raw_sample[i].raw_timestamp[j].tx_tsb_secs);
    154             _SHR_UNPACK_U32(buf, msg->raw_sample[i].raw_timestamp[j].tx_tsb_nsecs);
    155             _SHR_UNPACK_U32(buf, msg->raw_sample[i].raw_timestamp[j].rx_tsb_secs);
    156             _SHR_UNPACK_U32(buf, msg->raw_sample[i].raw_timestamp[j].rx_tsb_nsecs);
    157         }
    158     }
    159 
    160     return buf;
    161 }