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 *******************************************************************************/
18 /* header include files (.h) */
19 #include "common_def.h"
22 #include "du_app_mac_inf.h"
23 #include "mac_sch_interface.h"
24 #include "lwr_mac_upr_inf.h"
26 #include "mac_utils.h"
28 /* Function pointer for sending rach ind from MAC to SCH */
29 MacSchRachIndFunc macSchRachIndOpts[]=
36 /*******************************************************************
38 * @brief Sends RACH indication to SCH
42 * Function : sendRachIndMacToSch
45 * Sends RACH indication to SCH
47 * @params[in] RACH indication info
48 * @return ROK - success
51 * ****************************************************************/
52 uint8_t sendRachIndMacToSch(RachIndInfo *rachInd)
56 FILL_PST_MAC_TO_SCH(pst, EVENT_RACH_IND_TO_SCH);
57 return(*macSchRachIndOpts[pst.selector])(&pst, rachInd);
60 /*******************************************************************
62 * @brief Processes RACH indication from PHY
66 * Function : fapiMacRachInd
69 * Processes RACH indication from PHY
71 * @params[in] Post structure
72 * Rach indication message
73 * @return ROK - success
76 * ****************************************************************/
77 uint8_t fapiMacRachInd(Pst *pst, RachInd *rachInd)
81 RachIndInfo rachIndInfo;
83 DU_LOG("\nMAC : Received RACH indication");
84 /* Considering one pdu and one preamble */
88 rachIndInfo.cellId = rachInd->rachPdu[pduIdx].pci;
89 /* TODO : A.ocate unique crnti for each ue */
90 rachIndInfo.crnti = 100;
91 rachIndInfo.timingInfo.sfn = rachInd->timingInfo.sfn;
92 rachIndInfo.timingInfo.slot = rachInd->timingInfo.slot;
93 rachIndInfo.slotIdx = rachInd->rachPdu[pduIdx].slotIdx;
94 rachIndInfo.symbolIdx = rachInd->rachPdu[pduIdx].symbolIdx;
95 rachIndInfo.freqIdx = rachInd->rachPdu[pduIdx].freqIdx;
96 rachIndInfo.preambleIdx = \
97 rachInd->rachPdu[pduIdx].preamInfo[preambleIdx].preamIdx;
98 rachIndInfo.timingAdv = \
99 rachInd->rachPdu[pduIdx].preamInfo[preambleIdx].timingAdv;
101 /* storing the value in macRaCb */
102 createMacRaCb(rachIndInfo.cellId, rachIndInfo.crnti);
104 return(sendRachIndMacToSch(&rachIndInfo));
107 /* spec-38.211 Table 6.3.3.1-7 */
108 uint8_t UnrestrictedSetNcsTable[MAX_ZERO_CORR_CFG_IDX] =
109 {0, 2, 4, 6, 8, 10, 12, 13, 15, 17, 19, 23, 27, 34, 46, 69};
111 /*******************************************************************
113 * @brief Processes UL scheduling info from SCH
117 * Function : MacProcUlSchInfo
119 * Functionality: Processes UL scheduling info from SCH
121 * @params[in] Post structure
123 * @return ROK - success
126 * ****************************************************************/
127 uint8_t MacProcUlSchInfo(Pst *pst, UlSchedInfo *ulSchedInfo)
131 GET_CELL_IDX(ulSchedInfo->cellId, cellIdx);
132 if(ulSchedInfo != NULLP)
134 MacUlSlot *currUlSlot =
135 &macCb.macCell[cellIdx]->ulSlot[ulSchedInfo->slotIndInfo.slot % MAX_SLOT_SUPPORTED];
136 memcpy(&currUlSlot->ulInfo, ulSchedInfo, sizeof(UlSchedInfo));
141 /**********************************************************************
143 **********************************************************************/