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 This module acts as an interface handler for upper interface and
33 manages Pst and Sap related information for upper interface APIs.
37 /* header include files -- defines (.h) */
39 /* header/extern include files (.x) */
40 /* header include files (.h) */
41 #include "common_def.h"
42 #include "crg.h" /* CRG defines */
43 #include "lrg.h" /* layer management defines for LTE-MAC */
46 #include "rg_sch_inf.h"
47 #include "rg_env.h" /* customizable defines and macros for MAC */
48 #include "rg.h" /* defines and macros for MAC */
49 #include "rg_err.h" /* RG error defines */
50 #include "mac_utils.h"
52 /* header/extern include files (.x) */
54 #include "crg.x" /* CRG types */
55 #include "lrg.x" /* layer management typedefs for MAC */
58 #include "rg_sch_inf.x"
59 #include "rg_prg.x" /* PRG interface typedefs*/
60 #include "du_app_mac_inf.h"
61 #include "rg.x" /* typedefs for MAC */
72 /* forward references */
77 * @brief Handler for Bind request.
81 * Function : RgUiRguBndReq
83 * This function handles the bind request from MAC Service User.
87 * @param[in] SuId suId
88 * @param[in] SpId spId
102 Pst tmpPst; /* Temporary Post Structure */
103 RgUstaDgn dgn; /* Alarm diagnostics structure */
105 RG_IS_INST_VALID(pst->dstInst);
106 inst = pst->dstInst - RG_INST_START;
108 tmpPst.prior = pst->prior;
109 tmpPst.route = pst->route;
110 tmpPst.selector = pst->selector;
111 tmpPst.region = rgCb[inst].rgInit.region;
112 tmpPst.pool = rgCb[inst].rgInit.pool;
113 tmpPst.srcProcId = rgCb[inst].rgInit.procId;
114 tmpPst.srcEnt = rgCb[inst].rgInit.ent;
115 tmpPst.srcInst = rgCb[inst].rgInit.inst;
116 tmpPst.event = EVTNONE;
117 tmpPst.dstProcId = pst->srcProcId;
118 tmpPst.dstEnt = pst->srcEnt;
119 tmpPst.dstInst = pst->srcInst;
121 if(spId == rgCb[inst].rguSap[spId].sapCfg.spId)
123 /* Check the state of the SAP */
124 switch (rgCb[inst].rguSap[spId].sapSta.sapState)
126 case LRG_NOT_CFG: /* SAP Not configured */
127 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
128 ret = rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE,LRG_NOT_CFG,
129 LCM_CAUSE_INV_SAP, &dgn);
130 DU_LOG("\nDEBUG --> MAC : SAP Not Configured");
131 ret = RgUiRguBndCfm(&tmpPst, suId, CM_BND_NOK);
133 case LRG_UNBND: /* SAP is not bound */
134 DU_LOG("\nDEBUG --> MAC : SAP Not yet bound");
135 rgCb[inst].rguSap[spId].sapSta.sapState = LRG_BND;
136 rgCb[inst].rguSap[spId].sapCfg.suId = suId;
137 /* Send Bind Confirm with status as SUCCESS */
138 /*T2K - Passing spId as it is required to access the SAP CB*/
139 ret = rgUIMRguBndCfm(inst,spId, CM_BND_OK);
140 /* Indicate to Layer manager */
141 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
142 ret = rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE,LRG_EVENT_RGUSAP_ENB,
143 LCM_CAUSE_UNKNOWN, &dgn);
145 case LRG_BND: /* SAP is already bound*/
146 DU_LOG("\nDEBUG --> MAC : SAP already bound");
147 /*T2K - Passing spId as it is required to access the SAP CB*/
148 ret = rgUIMRguBndCfm(inst,spId, CM_BND_OK);
150 default: /* Should Never Enter here */
151 #if (ERRCLASS & ERRCLS_ADD_RES)
152 DU_LOG("\nERROR --> MAC : Invalid SAP State:RgUiRguBndReq failed\n");
154 /*T2K - Passing spId as it is required to access the SAP CB*/
155 ret = rgUIMRguBndCfm(inst,spId, CM_BND_NOK);
161 #if (ERRCLASS & ERRCLS_ADD_RES)
162 DU_LOG("\nERROR --> MAC : Invalid SAP Id:RgUiRguBndReq failed\n");
164 /*T2K - Passing spId as it is required to access the SAP CB*/
165 ret = rgUIMRguBndCfm(inst,spId, CM_BND_NOK);
168 } /* RgUiRguBndReq */
172 * @brief Handler for Unbind request.
176 * Function : RgUiRguUbndReq
178 * This function handles the unbind request from MAC Service User.
181 * @param[in] Pst *pst
182 * @param[in] SpId spId
183 * @param[in] Reason reason
197 RG_IS_INST_VALID(pst->dstInst);
198 inst = pst->dstInst - RG_INST_START;
199 /* SAP Id validation */
200 if (spId == rgCb[inst].rguSap[spId].sapCfg.spId)
202 switch(rgCb[inst].rguSap[spId].sapSta.sapState)
204 case LRG_BND: /* SAP is already bound*/
205 DU_LOG("\nDEBUG --> MAC : SAP already bound");
206 /* setting SAP state to UN BOUND */
207 rgCb[inst].rguSap[spId].sapSta.sapState = LRG_UNBND;
210 #if (ERRCLASS & ERRCLS_ADD_RES)
211 DU_LOG("\nERROR --> MAC : Invalid SAP State:%d RgUiRguUbndReq failed",
212 rgCb[inst].rguSap[spId].sapSta.sapState);
220 #if (ERRCLASS & ERRCLS_ADD_RES)
221 DU_LOG("\nERROR --> MAC : Invalid SAP Id:RgUiRguUbndReq failed\n");
226 } /* RgUiRguUbndReq */
228 * @brief API for sending bind confirm from MAC to RLC
232 * Function: rgUIMRguBndCfm
234 * This API is invoked to send bind confirm from MAC to RLC.
235 * This API fills in Pst structure and SAP Ids and invokes
236 * bind confirm API towards RLC.
238 * @param[in] Inst inst
239 * @param[in] SuId suId
240 * @param[in] uint8_t status
245 S16 rgUIMRguBndCfm(Inst inst,SpId spId,uint8_t status)
249 ret = RgUiRguBndCfm(&rgCb[inst].rguSap[spId].sapCfg.sapPst,
250 rgCb[inst].rguSap[spId].sapCfg.suId, status);
254 DU_LOG("\nERROR --> MAC : RgUiRguBndCfm Failed ");
258 } /* rgUIMRguBndCfm*/
263 * @brief Handler for L2M MeasReq from RGU
267 * Function :RgUiRguL2MUlThrpMeasReq
269 * This function validates SAP and invokes ROM for further processing
271 * @param[in] Pst *pst
272 * @param[in] SpId spId
273 * @param[in] RguL2MUlThrpMeasReqInfo *measReq
278 S16 RgUiRguL2MUlThrpMeasReq
282 RguL2MUlThrpMeasReqInfo *measReq
289 RG_IS_INST_VALID(pst->dstInst);
290 inst = pst->dstInst - RG_INST_START;
292 if (measReq == NULLP)
294 DU_LOG("\nERROR --> MAC : Input Response Buffer is NULL");
298 if (spId == rgCb[inst].rguSap[spId].sapCfg.spId)
300 switch (rgCb[inst].rguSap[spId].sapSta.sapState)
302 case LRG_BND: /* SAP is bound */
303 DU_LOG("\nERROR --> MAC : SAP is already bound");
305 default: /* Should never reach here */
306 #if (ERRCLASS & ERRCLS_ADD_RES)
307 DU_LOG("\nERROR --> MAC : Invalid SAP State:%d RgUiRguL2MUlThrpMeasReq failed",
308 rgCb[inst].rguSap[spId].sapSta.sapState);
315 #if (ERRCLASS & ERRCLS_ADD_RES)
316 DU_LOG("\nERROR --> MAC : Invalid SAP Id:%d RgUiRguL2MUlThrpMeasReq failed",spId);
322 ret = rgROML2MUlThrpMeasReq(inst,measReq);
325 DU_LOG("\nERROR --> MAC : Processing Of Meas Request Failed");
328 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, (Data *)measReq,sizeof(RguL2MUlThrpMeasReqInfo));
330 } /* RgUiRguL2MUlThrpMeasReq */
334 * @brief Handler for sending staInd to dedicated logical channels of a UE
338 * Function : rgUIMSndDedStaInd
340 * This function fills SAP and Pst information to send the staInd to
344 * @param[in] Inst inst
345 * @param[in] RgUpSapCb *rguSap
346 * @param[in] RgRguDedStaInd *staInd
351 S16 rgUIMSndDedStaInd
355 RgRguDedStaInd *staInd
360 DU_LOG("\nINFO --> MAC : rgUIMSndDedStaInd(): staInd = %p;\n", (void *)staInd);
362 ret = RgUiRguDStaInd(&(rguSap->sapCfg.sapPst), rguSap->sapCfg.suId,
366 DU_LOG("\nERROR --> MAC : RgUiRguDStaInd Failed");
370 } /* rgUIMSndDedStaInd */
374 * @brief Handler for sending staInd to a common logical channel.
378 * Function : rgUIMSndCmnStaInd
380 * This function fills SAP and Pst information to send the staInd to
381 * a common logical channel.
384 * @param[in] Inst inst
385 * @param[in] RgUpSapCb *rguSap
386 * @param[in] RgRguCmnStaInd *staInd
391 S16 rgUIMSndCmnStaInd
395 RgRguCmnStaInd *staInd
400 ret = RgUiRguCStaInd(&(rguDlSap->sapCfg.sapPst), rguDlSap->sapCfg.suId,
404 DU_LOG("\nERROR --> MAC : RgUiRguCStaInd Failed");
408 } /* rgUIMSndCmnStaInd */
412 * @brief Handler for sending datInd to dedicated logical channels of a UE
416 * Function : rgUIMSndDedDatInd
418 * This function fills SAP and Pst information to send the datInd to
422 * @param[in] Inst inst
423 * @param[in] RgUpSapCb *rguUlSap
424 * @param[in] RgRguDedDatInd *datInd
429 S16 rgUIMSndDedDatInd
433 RgRguDedDatInd *datInd
438 rguUlSap->sapSts.numPduTxmit += datInd->numLch;
440 ret = RgUiRguDDatInd(&(rguUlSap->sapCfg.sapPst), rguUlSap->sapCfg.suId,
444 DU_LOG("\nERROR --> MAC : RgUiRguDdatInd Failed");
448 SRngIncrWIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
449 SsRngInfoTbl[SS_RNG_BUF_ULMAC_TO_ULRLC].pktRate++;
452 } /* rgUIMSndDedDatInd */
456 * @brief Handler for sending datInd to a common logical channel.
460 * Function : rgUIMSndCmnDatInd
462 * This function fills SAP and Pst information to send the datInd to
463 * a common logical channel.
466 * @param[in] Inst inst
467 * @param[in] RgUpSapCb *rguSap
468 * @param[in] RgRguCmnDatInd *datInd
473 S16 rgUIMSndCmnDatInd(Inst inst,RgUpSapCb *rguUlSap,RgRguCmnDatInd *datInd)
477 DU_LOG("\nDEBUG --> MAC : rgUIMSndCmnDatInd(): staInd = %p;\n", (void *)datInd);
479 rguUlSap->sapSts.numPduTxmit++;
481 DU_LOG("\nDEBUG --> MAC : rgUIMSndCmnDatInd suId = %d\n", rguUlSap->sapCfg.suId);
482 ret = RgUiRguCDatInd(&(rguUlSap->sapCfg.sapPst), rguUlSap->sapCfg.suId,
486 DU_LOG("\nERROR --> MAC : RgUiRguCDatInd Failed");
490 } /* rgUIMSndCmnDatInd */
494 * @brief API for bind request from RRC towards MAC.
498 * Function: RgUiCrgBndReq
500 * This API is invoked by RRC towards MAC to bind CRG SAP.
501 * These API validates the Pst, spId, suId and sends the bind confirm to RRC.
504 * @param[in] Pst *pst
505 * @param[in] SuId suId
506 * @param[in] SpId spId
511 S16 RgUiCrgBndReq(Pst *pst, SuId suId,SpId spId)
514 Pst tmpPst; /* Temporary Post Structure */
515 RgUstaDgn dgn; /* Alarm diagnostics structure */
518 RG_IS_INST_VALID(pst->dstInst);
519 inst = pst->dstInst - RG_INST_START;
521 tmpPst.prior = pst->prior;
522 tmpPst.route = pst->route;
523 tmpPst.selector = pst->selector;
524 tmpPst.region = rgCb[inst].rgInit.region;
525 tmpPst.pool = rgCb[inst].rgInit.pool;
526 tmpPst.srcProcId = rgCb[inst].rgInit.procId;
527 tmpPst.srcEnt = rgCb[inst].rgInit.ent;
528 tmpPst.srcInst = rgCb[inst].rgInit.inst;
529 tmpPst.event = EVTNONE;
530 tmpPst.dstProcId = pst->srcProcId;
531 tmpPst.dstEnt = pst->srcEnt;
532 tmpPst.dstInst = pst->srcInst;
535 if(spId == rgCb[inst].crgSap.sapCfg.spId)
537 /* Check the state of the SAP */
538 switch (rgCb[inst].crgSap.sapSta.sapState)
540 case LRG_NOT_CFG: /* SAP Not configured */
542 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
543 ret = rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE,LRG_NOT_CFG,
544 LCM_CAUSE_INV_SAP, &dgn);
545 DU_LOG("\nDEBUG --> MAC : SAP Not Configured");
546 ret = RgUiCrgBndCfm(&tmpPst, suId, CM_BND_NOK);
548 case LRG_UNBND: /* SAP is not bound */
549 DU_LOG("\nERROR --> MAC : SAP Not yet bound");
551 rgCb[inst].crgSap.sapSta.sapState = LRG_BND;
552 rgCb[inst].crgSap.sapCfg.suId = suId;
553 /* Send Bind Confirm with status as SUCCESS */
554 ret = rgUIMCrgBndCfm(inst,suId, CM_BND_OK);
555 /* Indicate to Layer manager */
556 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
557 ret = rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE,LRG_EVENT_CRGSAP_ENB,
558 LCM_CAUSE_UNKNOWN, &dgn);
560 case LRG_BND: /* SAP is already bound*/
561 DU_LOG("\nDEBUG --> MAC : SAP is already bound");
563 ret = rgUIMCrgBndCfm(inst,suId, CM_BND_OK);
565 default: /* Should Never Enter here */
566 #if (ERRCLASS & ERRCLS_ADD_RES)
567 DU_LOG("\nERROR --> MAC : Invalid SAP State:%d RgUiCrgBndReq failed",
568 rgCb[inst].crgSap.sapSta.sapState);
570 ret = rgUIMCrgBndCfm(inst,suId, CM_BND_NOK);
576 #if (ERRCLASS & ERRCLS_ADD_RES)
577 DU_LOG("\nERROR --> MAC : Invalid SAP Id:%d RgUiCrgBndReq failed",
578 rgCb[inst].crgSap.sapCfg.spId);
580 ret = rgUIMCrgBndCfm(inst,suId, CM_BND_NOK);
583 } /* RgUiCrgBndReq */
587 * @brief API for unbind request from RRC towards MAC.
591 * Function: RgUiCrgUbndReq
593 * This API is invoked by RRC towards MAC to unbind CRG SAP.
594 * These API validates the Pst, spId, suId and sends the bind confirm to RRC.
597 * @param[in] Pst *pst
598 * @param[in] SuId suId
599 * @param[in] Reason reason
604 S16 RgUiCrgUbndReq(Pst *pst,SpId spId,Reason reason)
608 RG_IS_INST_VALID(pst->dstInst);
609 inst = pst->dstInst - RG_INST_START;
610 /* SAP Id validation */
611 if (spId == rgCb[inst].crgSap.sapCfg.spId)
613 switch(rgCb[inst].crgSap.sapSta.sapState)
615 case LRG_BND: /* SAP is already bound*/
616 /* setting SAP state to UN BOUND */
617 DU_LOG("\nDEBUG --> MAC : SAP is already bound");
619 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
622 #if (ERRCLASS & ERRCLS_ADD_RES)
623 DU_LOG("\nERROR --> MAC : Invalid SAP State:%d RgUiCrgUbndReq failed",
624 rgCb[inst].crgSap.sapSta.sapState);
631 #if (ERRCLASS & ERRCLS_ADD_RES)
632 DU_LOG("\nERROR --> MAC : Invalid SAP Id:%d RgUiCrgUbndReq failed",
633 rgCb[inst].crgSap.sapCfg.spId);
638 } /* RgUiCrgUbndReq */
641 * @brief API for sending bind confirm from MAC to RRC
645 * Function: rgUIMRgrBndCfm
647 * This API is invoked to send bind confirm from MAC to RRC.
648 * This API fills in Pst structure and SAP Ids and invokes
649 * bind confirm API towards RRC.
651 * @param[in] Inst inst
652 * @param[in] SuId suId
653 * @param[in] uint8_t status
658 S16 rgUIMCrgBndCfm(Inst inst,SuId suId,uint8_t status)
661 if(RgUiCrgBndCfm(&(rgCb[inst].crgSap.sapCfg.sapPst), rgCb[inst].crgSap.sapCfg.suId, status) != ROK)
663 DU_LOG("\nERROR --> MAC : RgUiCrgBndCfm Failed ");
668 } /* rgUIMCrgBndCfm*/
671 * @brief API for sending configuration confirm from MAC to RRC
675 * Function: rgUIMCrgCfgCfm
677 * This API is invoked to send configuration confirm from MAC to RRC.
678 * This API fills in Pst structure and SAP Ids and invokes
679 * config confirm API towards RRC.
681 * @param[in] Inst inst
682 * @param[in] CrgCfgTransId transId
683 * @param[in] uint8_t status
691 CrgCfgTransId transId,
696 uint8_t prntTrans[CRG_CFG_TRANSID_SIZE+1];
698 memcpy(prntTrans, transId.trans, CRG_CFG_TRANSID_SIZE);
699 prntTrans[CRG_CFG_TRANSID_SIZE] = '\0';
702 ret = RgUiCrgCfgCfm(&(rgCb[inst].crgSap.sapCfg.sapPst), rgCb[inst].crgSap.sapCfg.suId, transId, status);
705 DU_LOG("\nERROR --> MAC : RgUiCrgCfgCfm Failed ");
710 } /* rgUIMCrgCfgCfm */
712 /**********************************************************************
715 **********************************************************************/