sum_pack.c (2804B)
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: sum_pack.c 8 * Purpose: SUM pack and unpack routines for: 9 * - SUM Control messages 10 * 11 * SUM control messages 12 * 13 * SUM messages between the Host CPU and uController are sent 14 * using the uc_message module which allows short messages 15 * to be passed (see include/soc/shared/mos_msg_common.h) 16 * 17 * Additional information for a given message (a long message) is passed 18 * using DMA. The SUM control message types defines the format 19 * for these long messages. 20 * 21 * This file is shared between SDK and uKernel. 22 */ 23 24 #include <shared/pack.h> 25 #include <soc/shared/sum.h> 26 #include <soc/shared/sum_msg.h> 27 #include <soc/shared/sum_pack.h> 28 29 /* 30 * Create SUM config information - pack 31 */ 32 uint8* 33 shr_sum_msg_ctrl_config_pack(uint8 *buf, shr_sum_msg_ctrl_config_t *msg) 34 { 35 int i; 36 37 _SHR_PACK_U32(buf, msg->host_buf_addr); 38 _SHR_PACK_U32(buf, msg->usec_sample_interval); 39 _SHR_PACK_U32(buf, msg->max_history); 40 _SHR_PACK_U32(buf, msg->sum_type); 41 42 _SHR_PACK_U32(buf, msg->num_ports); 43 for (i = 0; i < msg->num_ports; i++) { 44 _SHR_PACK_U32(buf, msg->lports[i]); 45 _SHR_PACK_U32(buf, msg->pports[i]); 46 } 47 _SHR_PACK_U32(buf, msg->mib_tbl_addr); 48 _SHR_PACK_U8(buf, msg->mib_tbl_acc_type); 49 _SHR_PACK_U8(buf, msg->sum_wb_indicate); 50 51 return buf; 52 } 53 54 /* 55 * Create SUM config information - unpack 56 */ 57 uint8* 58 shr_sum_msg_ctrl_config_unpack(uint8 *buf, shr_sum_msg_ctrl_config_t *msg) 59 { 60 int i; 61 62 _SHR_UNPACK_U32(buf, msg->host_buf_addr); 63 _SHR_UNPACK_U32(buf, msg->usec_sample_interval); 64 _SHR_UNPACK_U32(buf, msg->max_history); 65 _SHR_UNPACK_U32(buf, msg->sum_type); 66 67 _SHR_UNPACK_U32(buf, msg->num_ports); 68 for (i = 0; i < msg->num_ports; i++) { 69 _SHR_UNPACK_U32(buf, msg->lports[i]); 70 _SHR_UNPACK_U32(buf, msg->pports[i]); 71 } 72 _SHR_UNPACK_U32(buf, msg->mib_tbl_addr); 73 _SHR_UNPACK_U8(buf, msg->mib_tbl_acc_type); 74 _SHR_UNPACK_U8(buf, msg->sum_wb_indicate); 75 76 return buf; 77 } 78 79 /* 80 * Create SUM stats config information - pack 81 */ 82 uint8* 83 shr_sum_msg_ctrl_stat_config_pack(uint8 *buf, shr_sum_msg_buf_info_t *msg) 84 { 85 _SHR_PACK_U32(buf, msg->host_buf_cur_offset); 86 _SHR_PACK_U32(buf, msg->host_buf_status); 87 _SHR_PACK_U32(buf, msg->sample_interval); 88 89 return buf; 90 } 91 92 /* 93 * Create SUM stats config information - unpack 94 */ 95 uint8* 96 shr_sum_msg_ctrl_stat_config_unpack(uint8 *buf, shr_sum_msg_buf_info_t *msg) 97 { 98 _SHR_UNPACK_U32(buf, msg->host_buf_cur_offset); 99 _SHR_UNPACK_U32(buf, msg->host_buf_status); 100 _SHR_UNPACK_U32(buf, msg->sample_interval); 101 102 return buf; 103 }