ces_pack.c (4339B)
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: ces_pack.c 8 * Purpose: CES pack and unpack routines for CES control messages. 9 * 10 * CES messages between the Host CPU and uController are sent 11 * using the uc_message module which allows short messages 12 * to be passed (see include/soc/shared/mos_msg_common.h) 13 * 14 * Additional information for a given message (a long message) is passed 15 * using DMA. The CES control message types defines the format 16 * for these long messages. 17 * 18 * This file is shared between SDK and uKernel. 19 */ 20 #ifdef BCM_UKERNEL 21 /* Build for uKernel not SDK */ 22 #include "sdk_typedefs.h" 23 #else 24 #include <sal/types.h> 25 #endif 26 #include <shared/pack.h> 27 #include <soc/shared/mos_msg_ces.h> 28 #include <soc/shared/ces_pack.h> 29 30 uint8 * 31 bcm_ces_crm_init_msg_pack(uint8 *buf, bcm_ces_crm_init_msg_t *msg) 32 { 33 _SHR_PACK_U8(buf, msg->flags); 34 35 return buf; 36 } 37 38 uint8 * 39 bcm_ces_crm_init_msg_unpack(uint8 *buf, bcm_ces_crm_init_msg_t *msg) 40 { 41 _SHR_UNPACK_U8(buf, msg->flags); 42 43 return buf; 44 } 45 46 uint8 * 47 bcm_ces_crm_cclk_config_msg_pack(uint8 *buf, bcm_ces_crm_cclk_config_msg_t *msg) 48 { 49 _SHR_PACK_U8(buf, msg->flags); 50 _SHR_PACK_U8(buf, msg->e_cclk_select); 51 _SHR_PACK_U8(buf, msg->e_ref_clk_1_select); 52 _SHR_PACK_U8(buf, msg->e_ref_clk_2_select); 53 _SHR_PACK_U32(buf, msg->n_ref_clk_1_port); 54 _SHR_PACK_U32(buf, msg->n_ref_clk_2_port); 55 _SHR_PACK_U8(buf, msg->e_protocol); 56 57 return buf; 58 } 59 60 uint8 * 61 bcm_ces_crm_cclk_config_msg_unpack(uint8 *buf, bcm_ces_crm_cclk_config_msg_t *msg) 62 { 63 _SHR_UNPACK_U8(buf, msg->flags); 64 _SHR_UNPACK_U8(buf, msg->e_cclk_select); 65 _SHR_UNPACK_U8(buf, msg->e_ref_clk_1_select); 66 _SHR_UNPACK_U8(buf, msg->e_ref_clk_2_select); 67 _SHR_UNPACK_U32(buf, msg->n_ref_clk_1_port); 68 _SHR_UNPACK_U32(buf, msg->n_ref_clk_2_port); 69 _SHR_UNPACK_U8(buf, msg->e_protocol); 70 71 return buf; 72 } 73 74 uint8 * 75 bcm_ces_crm_rclock_config_msg_pack(uint8 *buf, bcm_ces_crm_rclock_config_msg_t *msg) 76 { 77 _SHR_PACK_U8(buf, msg->flags); 78 _SHR_PACK_U8(buf, msg->b_enable); 79 _SHR_PACK_U8(buf, msg->e_protocol); 80 _SHR_PACK_U8(buf, msg->b_structured); 81 _SHR_PACK_U8(buf, msg->output_brg); 82 _SHR_PACK_U8(buf, msg->rclock); 83 _SHR_PACK_U8(buf, msg->port); 84 _SHR_PACK_U8(buf, msg->recovery_type); 85 _SHR_PACK_U16(buf, msg->tdm_clocks_per_packet); 86 _SHR_PACK_U8(buf, msg->service); 87 /*Add new fields*/ 88 _SHR_PACK_U8(buf, msg->rcr_flags); 89 _SHR_PACK_U32(buf, msg->ho_q_count); 90 _SHR_PACK_U32(buf, msg->ho_a_threshold); 91 _SHR_PACK_U32(buf, msg->ho_a_threshold); 92 _SHR_PACK_U32(buf, msg->ho_a_threshold); 93 return buf; 94 } 95 96 uint8 * 97 bcm_ces_crm_rclock_config_msg_unpack(uint8 *buf, bcm_ces_crm_rclock_config_msg_t *msg) 98 { 99 _SHR_UNPACK_U8(buf, msg->flags); 100 _SHR_UNPACK_U8(buf, msg->b_enable); 101 _SHR_UNPACK_U8(buf, msg->e_protocol); 102 _SHR_UNPACK_U8(buf, msg->b_structured); 103 _SHR_UNPACK_U8(buf, msg->output_brg); 104 _SHR_UNPACK_U8(buf, msg->rclock); 105 _SHR_UNPACK_U8(buf, msg->port); 106 _SHR_UNPACK_U8(buf, msg->recovery_type); 107 _SHR_UNPACK_U16(buf, msg->tdm_clocks_per_packet); 108 _SHR_UNPACK_U8(buf, msg->service); 109 /*Add new fields*/ 110 _SHR_UNPACK_U8(buf, msg->rcr_flags); 111 _SHR_UNPACK_U32(buf, msg->ho_q_count); 112 _SHR_UNPACK_U32(buf, msg->ho_a_threshold); 113 _SHR_UNPACK_U32(buf, msg->ho_a_threshold); 114 _SHR_UNPACK_U32(buf, msg->ho_a_threshold); 115 116 return buf; 117 } 118 119 uint8 * 120 bcm_ces_crm_status_msg_pack(uint8 *buf, bcm_ces_crm_status_msg_t *msg) 121 { 122 _SHR_PACK_U8(buf, msg->rclock); 123 _SHR_PACK_U8(buf, msg->clock_state); 124 _SHR_PACK_U32(buf, msg->seconds_locked); 125 _SHR_PACK_U32(buf, msg->seconds_active); 126 _SHR_PACK_U32(buf, msg->calculated_frequency_w); 127 _SHR_PACK_U32(buf, msg->calculated_frequency_f); 128 129 return buf; 130 } 131 132 uint8 * 133 bcm_ces_crm_status_msg_unpack(uint8 *buf, bcm_ces_crm_status_msg_t *msg) 134 { 135 _SHR_UNPACK_U8(buf, msg->rclock); 136 _SHR_UNPACK_U8(buf, msg->clock_state); 137 _SHR_UNPACK_U32(buf, msg->seconds_locked); 138 _SHR_UNPACK_U32(buf, msg->seconds_active); 139 _SHR_UNPACK_U32(buf, msg->calculated_frequency_w); 140 _SHR_UNPACK_U32(buf, msg->calculated_frequency_f); 141 142 return buf; 143 }