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 /* This file contains all utility functions for MAC CL */
21 #include "common_def.h"
24 /*******************************************************************
26 * @brief Fetch cellCb from Hash list
30 * Function : rgClUtlGetCellCb
33 * - Searches for a cell entry at MAC CL
36 * @return Pointer to cellCb - success
39 * ****************************************************************/
40 LwrMacCellCb * lwrMacGetCellCb
47 if(cellId >= MAX_NUM_CELL)
49 DU_LOG("\nERROR --> Invalid Cell Id [%d]. rgClUtlGetCellCb failed.", cellId);
53 cellCb = &lwrMacCb.cellCb[cellId -1];
58 /*******************************************************************
60 * @brief Reverses bits in a number
64 * Function : reverseBits
67 * Reverses bits in a number
69 * @params[in] Number to be reversed
70 * Number of bits to be reversed
71 * @return Reversed number
73 * ****************************************************************/
74 uint32_t reverseBits(uint32_t num, uint8_t numBits)
76 uint32_t reverse_num = 0;
78 for (bitIdx = 0; bitIdx < numBits; bitIdx++)
80 if((num & (1 << bitIdx)))
81 reverse_num |= 1 << ((numBits - 1) - bitIdx);
86 /*******************************************************************
88 * @brief Fills DL DCI payload byte by byte
92 * Function : fillDlDciPayload
95 * Fills DL DCI payload byte by byte
97 * @params[in] Payload buffer pointer
98 * Current Byte position in buffer
99 * Current Bit Position in current byte
101 * Number of bits in value
104 * ****************************************************************/
106 void fillDlDciPayload(uint8_t *buf, uint8_t *bytePos, uint8_t *bitPos,\
107 uint32_t val, uint8_t valSize)
112 uint8_t bytePart1Size;
113 uint8_t bytePart2Size;
115 if(*bitPos + valSize <= 8)
117 bytePart1 = (uint8_t)val;
118 bytePart1 = (~((~0) << valSize)) & bytePart1;
119 buf[*bytePos] |= bytePart1;
122 else if(*bitPos + valSize > 8)
125 bytePart1Size = 8 - *bitPos;
126 bytePart2Size = valSize - bytePart1Size;
128 bytePart1 = ((~((~0) << bytePart1Size)) & temp) << *bitPos;
129 bytePart2 = val >> bytePart1Size;
131 buf[*bytePos] |= bytePart1;
134 fillDlDciPayload(buf, bytePos, bitPos, bytePart2, bytePart2Size);
140 /**********************************************************************
142 **********************************************************************/