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 /************************************************************************
25 Desc: C source code for Entry point fucntions
29 **********************************************************************/
32 @brief It has APIs exposed by Lower Interface Modulue of MAC. It acts as an
33 Interface handler for lower interface APIs.
35 /* header include files -- defines (.h) */
36 #include "common_def.h"
37 #include "rgu.h" /* RGU defines */
38 #include "tfu.h" /* RGU defines */
39 #include "lrg.h" /* layer management defines for LTE-MAC */
40 #include "crg.h" /* layer management defines for LTE-MAC */
41 #include "rg_sch_inf.h" /* layer management defines for LTE-MAC */
42 #include "rg_env.h" /* customisable defines and macros for MAC */
43 #include "rg.h" /* defines and macros for MAC */
45 /* header/extern include files (.x) */
46 #include "rgu.x" /* RGU types */
47 #include "tfu.x" /* RGU types */
48 #include "lrg.x" /* layer management typedefs for MAC */
49 #include "crg.x" /* layer management typedefs for MAC */
50 #include "rg_sch_inf.x" /* SCH interface typedefs */
51 #include "rg_prg.x" /* PRG interface typedefs */
52 #include "rg.x" /* typedefs for MAC */
56 static S16 rgLIMValidateSap ARGS((Inst inst,SuId suId));
58 static Void rgLIMUtlFreeDatIndEvnt ARGS((TfuDatIndInfo *datInd,
61 static Void rgLIMUtlFreeDatReqEvnt ARGS((TfuDatReqInfo *datReq,
64 /* forward references */
67 * @brief Bind confirm API for TFU SAP
71 * Function : RgLiTfuBndCfm
73 * This API is invoked by PHY to confirm TFU SAP bind.
77 * @param[in] SuId suId
78 * @param[in] uint8_t status
96 RG_IS_INST_VALID(pst->dstInst);
97 inst = pst->dstInst - RG_INST_START;
98 /* Lets validate suId first */
100 tfuSap = &(rgCb[inst].tfuSap);
102 if (suId != tfuSap->sapCfg.suId)
104 DU_LOG("\nERROR --> MAC : Incorrect SuId. Configured (%d) Recieved (%d)",
105 tfuSap->sapCfg.suId, suId);
108 ret = rgLMMBndCfm (pst, suId, status);
110 } /* RgLiTfuBndCfm */
112 /** @brief This function Validates the SAP information received along with the
113 * primitive from the lower layer.
115 * Validates SAP information.
116 * @param[in] Inst inst
117 * @param suId The SAP Id
123 static S16 rgLIMValidateSap(Inst inst,SuId suId)
128 tfuSap = &(rgCb[inst].tfuSap);
130 /* First lets check the suId */
131 if( suId != tfuSap->sapCfg.suId)
133 DU_LOG("\nERROR --> MAC : Incorrect SuId. Configured (%d) Recieved (%d)",
134 tfuSap->sapCfg.suId, suId);
137 if (tfuSap->sapSta.sapState != LRG_BND)
139 DU_LOG("\nERROR --> MAC : Lower SAP not enabled SuId (%d)",
140 tfuSap->sapCfg.suId);
144 } /* end of rgLIMValidateSap */
146 /** @brief This function frees up the TfuDatIndInfo structure
150 * Function: rgLIMUtlFreeDatIndEvnt
151 * - Function frees up the TfuDatIndInfo structure, in case of error it shall
152 * free up the buffer's present in the datIndLst.
155 * @param [in] TfuDatIndInfo *datInd
156 * @param [in] Bool *error
159 static Void rgLIMUtlFreeDatIndEvnt(TfuDatIndInfo *datInd,Bool error)
165 /* Steps of freeing up the TfuDatInd.
166 * 1. loop through the datIndLst and free up all the buffers.
167 * 2. free up the whole event
169 if ((error == TRUE) && (datInd->datIndLst.count > 0))
171 node = datInd->datIndLst.first;
174 datInfo = (TfuDatInfo*)node->node;
175 RG_FREE_MSG(datInfo->mBuf);
181 } /* end of rgLIMUtlFreeDatIndEvnt*/
184 * @brief Downlink data indication from PHY.
188 * Function : RgLiTfuDatInd
190 * This API is invoked by PHY to send data indication to MAC on
191 * recieving data from UEs.
193 * @param[in] Pst *pst
194 * @param[in] SuId suId
195 * @param[in] TfuDatIndInfo *datInd
204 TfuDatIndInfo *datInd
209 volatile uint32_t startTime=0;
212 // DU_LOG("5GTF:: DatindRcvd\n");
214 RG_IS_INST_VALID(pst->dstInst);
215 inst = pst->dstInst - RG_INST_START;
217 SStartTask(&startTime, PID_MAC_TFU_DATIND);
220 if ((ret = rgLIMValidateSap (inst,suId)) != ROK)
222 DU_LOG("\nERROR --> MAC : SAP Validation failed");
223 rgLIMUtlFreeDatIndEvnt(datInd, TRUE);
227 /* Now call the TOM (Tfu ownership module) primitive to process further */
228 rgCb[inst].tfuSap.sapSts.numPduRcvd +=
229 datInd->datIndLst.count;
230 ret = rgTOMDatInd(inst,datInd);
231 /* Fix: sriky memory corruption precautions */
232 /* Free up the memory for the request structure */
235 rgLIMUtlFreeDatIndEvnt(datInd, FALSE);
239 rgLIMUtlFreeDatIndEvnt(datInd, TRUE);
243 SStopTask(startTime, PID_MAC_TFU_DATIND);
249 /** @brief This function frees up the TfuDatReqInfo structure.
253 * Function: rgLIMUtlFreeDatReqEvnt
254 * - Function frees up the TfuDatReqInfo structure, in case of error it shall
255 * free up the buffer's present in the PDUs list.
258 * @param [in] TfuDatReqInfo *datReq
259 * @param [in] Bool *error
262 static Void rgLIMUtlFreeDatReqEvnt(TfuDatReqInfo *datReq,Bool error)
265 TfuDatReqPduInfo *datInfo;
269 /* Steps of freeing up the TfuDatReq.
270 * 1. Free the bch buffer.
271 * 2. loop through the pdus list and free up all the buffers.
272 * 3. free up the whole event
276 if (datReq->bchDat.pres == PRSNT_NODEF)
278 RG_FREE_MSG(datReq->bchDat.val);
280 if (datReq->pdus.count > 0)
282 node = datReq->pdus.first;
285 datInfo = (TfuDatReqPduInfo*)node->node;
286 for (i=0; i<datInfo->nmbOfTBs; i++)
288 if (datInfo->mBuf[i] != NULLP)
290 RG_FREE_MSG(datInfo->mBuf[i]);
299 } /* end of rgLIMUtlFreeDatReqEvnt*/
304 * @brief This API is invoked to send Data to PHY.
308 * Function : rgLIMTfuDelDatReq
310 * This API is invoked to send Data to PHY. It
311 * fills in the Pst structure, spId value and invokes Data
312 * request primitive at TFU.
314 * @param[in] Inst inst
315 * @param[in] TfuDelDatReqInfo *datReq
320 S16 rgLIMTfuDelDatReq(Inst inst,TfuDelDatReqInfo *delDatReq)
326 /* Get the lower SAP control block from the layer control block. */
327 tfuSap = &(rgCb[inst].tfuSap);
330 if (tfuSap->sapSta.sapState != LRG_BND)
332 DU_LOG("\nERROR --> MAC : Lower SAP not bound (%d)",
333 tfuSap->sapSta.sapState);
338 if((ret = RgLiTfuDelDatReq (&tfuSap->sapCfg.sapPst, tfuSap->sapCfg.spId,
341 DU_LOG("\nERROR --> MAC : Call to RgLiTfuDelDatReq() failed");
344 } /* rgLIMTfuDatReq*/
347 #if defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD)
349 * @brief Transmission of non-rt indication from CL.
353 * Function : RgLiTfuNonRtInd
355 * This API is invoked by CL to indicate non-rt processing indication to MAC for a cell.
357 * @param[in] Pst *pst
358 * @param[in] SuId suId
363 S16 RgLiTfuNonRtInd(Pst *pst,SuId suId)
367 if (rgLIMValidateSap (pst->dstInst - RG_INST_START, suId) != ROK)
369 DU_LOG("\nERROR --> MAC : RgLiTfuNonRtInd() SAP Validation failed.\n");
373 rgDHMFreeTbBufs(pst->dstInst - RG_INST_START);
375 } /* RgLiTfuNonRtInd */
378 /**********************************************************************
381 **********************************************************************/