1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 #include "common_def.h"
22 * @brief frequency domain allocation function.
26 * Function: freqDomRscAllocType0
28 * This function does allocation in frequency domain resource.
29 * This is a bitmap defining non-overlapping groups of 6 PRBs in ascending order.
31 * @param[in] startPrb - start PRB from where the freq alloc starts.
32 * @param[in] prbSize - number of PRBs to be allocted.
33 * @param[in] freqDomain - 6 bytes of info, each bit represents a group of 6 PRB.
36 void freqDomRscAllocType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqDomain)
38 uint8_t remBits = prbSize; /* each bit represents 6 PRBs */
39 uint8_t firstByte = 1;
40 uint8_t numBits,startBit,byteCount = 5;
44 /* when the startPrb is not in this byteCount */
52 /* max bytecount is 6 nearly equal to 45 bits*/
56 /* when we are filling the second byte, then the start should be equal to 0 */
62 /* calculate the number of bits to be set in this byte */
63 if((remBits+startPrb) <= 8)
66 numBits = 8 - startBit;
68 /* bit operation to set the bits */
69 SET_BITS_MSB((startBit % 8),numBits,freqDomain[byteCount])
72 /* the ramaining bits should be subtracted with the numBits set in this byte */
78 /*******************************************************************
80 * @brief Reverse and copy fixed buffer to mBuf
84 * Function : oduCpyFixBufToMsg
86 * Functionality: Reverse and copy fixed buffer to mBuf
88 * @params[in] Fixed buffer, msg buffer, length of message
89 * @return ROK - success
92 * ****************************************************************/
93 void oduCpyFixBufToMsg(uint8_t *fixBuf, Buffer *mBuf, uint16_t len)
95 uint16_t idx = 0, revIdx = 0, temp = 0, copyLen = 0;
97 /* ODU_COPY_FIX_BUF_TO_MSG copies fixed buffer in reverse order. \
98 * Hence reversing the fixed buffer before copying in order to \
99 * maintain the actual order*/
100 for(idx = 0, revIdx = len-1; idx < len/2; idx++, revIdx--)
103 fixBuf[idx] = fixBuf[revIdx];
104 fixBuf[revIdx] = temp;
106 ODU_COPY_FIX_BUF_TO_MSG(fixBuf, mBuf, 0, len, (MsgLen *)©Len);
109 /*******************************************************************
111 * @brief Builds PLMN ID
115 * Function : plmnBuildId
117 * Functionality: Building the PLMN ID
119 * @params[in] PLMNID plmn
120 * @params[out] PLMNID in string format
121 * @return ROK - success
124 * ****************************************************************/
125 uint8_t buildPlmnId(Plmn plmn, uint8_t *buf)
129 buf[0] = ((plmn.mcc[1] << 4) | (plmn.mcc[0]));
132 buf[1] = ((0xf0) | (plmn.mcc[2]));
133 buf[2] = ((plmn.mnc[1] << 4) | (plmn.mnc[0]));
137 buf[1] = ((plmn.mnc[0] << 4) | (plmn.mcc[2]));
138 buf[2] = ((plmn.mnc[2] << 4) | (plmn.mnc[1]));
143 /*******************************************************************
145 * @brief SGetSBuf with debug logs
149 * Function : SGetSBufNewForDebug
151 * Functionality: SGetSBuf with debug logs
153 * @params[in] file name, fun name, region, pool, data ptr, size
155 * @return ROK - success
158 * ****************************************************************/
159 uint8_t SGetSBufNewForDebug(char *file, char *func, char *line, Region region, Pool pool, Data **ptr, Size size)
161 if(SGetSBuf(region, pool, ptr, size) == ROK)
163 #ifdef ODU_MEMORY_DEBUG_LOG
164 printf("\nCM_ALLOC=== SGetSBufNewForDebug %s +%d, %s, %d, %p\n",\
165 file, line, func, size, *ptr);
173 /*******************************************************************
175 * @brief SPutSBuf with debug logs
179 * Function : SPutSBufNewForDebug
181 * Functionality: SPutSBuf with debug logs
183 * @params[in] file name, fun name, region, pool, data ptr, size
185 * @return ROK - success
188 * ****************************************************************/
189 uint8_t SPutSBufNewForDebug(char *file, char *func, char *line, Region region, Pool pool, Data *ptr, Size size)
191 if(SPutSBuf(region, pool, ptr, size) == ROK)
193 #ifdef ODU_MEMORY_DEBUG_LOG
194 printf("\nCM_FREE=== SPutSBufNewForDebug %s +%d, %s, %d, %p\n",\
195 file, line, func, size, ptr);
204 /*******************************************************************
206 * @brief SGetStaticBuf with debug logs
210 * Function : SGetStaticBufNewForDebug
212 * Functionality: SGetStaticBuf with debug logs
214 * @params[in] file name, fun name, region, pool, data ptr, size, memType
216 * @return ROK - success
219 * ****************************************************************/
220 uint8_t SGetStaticBufNewForDebug(char *file, char *func, char *line, \
221 Region region, Pool pool, Data **ptr, Size size, uint8_t memType)
223 if(SGetStaticBuffer(region, pool, ptr, size, memType) == ROK)
225 #ifdef ODU_MEMORY_DEBUG_LOG
226 printf("\nCM_ALLOC=== SGetStaticBufNewForDebug %s +%d, %s, %d, %p\n",\
227 file, line, func, size, *ptr);
235 /*******************************************************************
237 * @brief SPutStaticBuf with debug logs
241 * Function : SPutStaticBufNewForDebug
243 * Functionality: SPutStaticBuf with debug logs
245 * @params[in] file name, fun name, region, pool, data ptr, size, memType
247 * @return ROK - success
250 * ****************************************************************/
251 uint8_t SPutStaticBufNewForDebug(char *file, char *func, char *line, \
252 Region region, Pool pool, Data *ptr, Size size, uint8_t memType)
254 if(SPutStaticBuffer(region, pool, ptr, size, memType) == ROK)
256 #ifdef ODU_MEMORY_DEBUG_LOG
257 printf("\nCM_FREE=== SPutStaticBufNewForDebug %s +%d, %s, %d, %p\n",\
258 file, line, func, size, ptr);
265 /**********************************************************************
267 **********************************************************************/