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 Layer Manager Interface Module
29 **********************************************************************/
32 @brief This file contains the Layer Management interface module implementation.
33 The functions for the configuration, control, status and statistics
34 request primitives are defined here.
36 static const char* RLOG_MODULE_NAME="MAC";
37 static int RLOG_FILE_ID=220;
38 static int RLOG_MODULE_ID=4096;
40 /* header include files (.h) */
41 #include "envopt.h" /* environment options */
42 #include "envdep.h" /* environment dependent */
43 #include "envind.h" /* environment independent */
44 #include "gen.h" /* general */
45 #include "ssi.h" /* system services */
46 #include "cm_tkns.h" /* Common Token Defines */
47 #include "cm_llist.h" /* Common Link List Defines */
48 #include "cm_hash.h" /* Common Hash List Defines */
49 #include "cm_mblk.h" /* common memory link list library */
50 #include "cm_lte.h" /* Common LTE Defines */
51 #include "rg_env.h" /* MAC Environment Defines */
52 #include "crg.h" /* CRG Interface defines */
53 #include "rgu.h" /* RGU Interface defines */
54 #include "tfu.h" /* RGU Interface defines */
55 #include "rg_sch_inf.h" /* RGR Interface defines */
56 #include "lrg.h" /* LRG Interface defines */
57 #include "rgr.h" /* LRG Interface defines */
58 #include "rg.h" /* MAC defines */
59 #include "rg_err.h" /* MAC error defines */
61 /* header/extern include files (.x) */
62 #include "gen.x" /* general */
63 #include "ssi.x" /* system services */
64 #include "cm5.x" /* system services */
65 #include "cm_tkns.x" /* Common Token Definitions */
66 #include "cm_llist.x" /* Common Link List Definitions */
67 #include "cm_lib.x" /* Common Library Definitions */
68 #include "cm_hash.x" /* Common Hash List Definitions */
69 #include "cm_mblk.x" /* common memory link list library */
70 #include "cm_lte.x" /* Common LTE Defines */
71 #include "crg.x" /* CRG Interface includes */
72 #include "rgu.x" /* RGU Interface includes */
73 #include "tfu.x" /* RGU Interface includes */
74 #include "rg_sch_inf.x" /* SCH Interface includes */
75 #include "rg_prg.x" /* PRG Interface includes */
76 #include "lrg.x" /* LRG Interface includes */
77 #include "rgr.x" /* LRG Interface includes */
78 #include "rg.x" /* MAC includes */
80 #include "ss_diag.h" /* Common log file */
85 #include "rg_cl.h" /* MAC CL defines */
89 #endif /* __cplusplus */
90 EXTERN Void rgGetSId ARGS((SystemId *s));
93 #endif /* __cplusplus */
95 /* Public variable declaration */
98 /* forward references */
99 PRIVATE U16 rgLMMGenCfg ARGS((
104 PRIVATE U16 rgLMMSapCfg ARGS((
110 PRIVATE Void rgLMMShutdown ARGS((
114 PRIVATE Void rgLMMFillCfmPst ARGS((
120 PRIVATE Void rgLMMGenCntrl ARGS((
126 PRIVATE Void rgLMMSapCntrl ARGS((
134 * @brief Task Initiation callback function.
138 * Function : rgActvInit
140 * This function is supplied as one of parameters during MAC's
141 * task registration. SSI will invoke this function once, after
142 * it creates and attaches this TAPA Task to a system task.
144 * @param[in] Ent entity, the entity ID of this task.
145 * @param[in] Inst inst, the instance ID of this task.
146 * @param[in] Region region, the region ID registered for memory
147 * usage of this task.
148 * @param[in] Reason reason.
153 PUBLIC S16 rgActvInit
155 Ent entity, /* entity */
156 Inst inst, /* instance */
157 Region region, /* region */
158 Reason reason /* reason */
161 PUBLIC S16 rgActvInit(entity, inst, region, reason)
162 Ent entity; /* entity */
163 Inst inst; /* instance */
164 Region region; /* region */
165 Reason reason; /* reason */
171 RG_IS_INST_VALID(inst);
173 macInst = inst - RG_INST_START;
174 /* Initialize the MAC TskInit structure to zero */
175 cmMemset ((U8 *)&rgCb[macInst], 0, sizeof(RgCb));
177 /* Initialize the MAC TskInit with received values */
178 rgCb[macInst].rgInit.ent = entity;
179 rgCb[macInst].rgInit.inst = inst;
180 rgCb[macInst].rgInit.region = region;
181 rgCb[macInst].rgInit.pool = 0;
182 rgCb[macInst].rgInit.reason = reason;
183 rgCb[macInst].rgInit.cfgDone = FALSE;
184 rgCb[macInst].rgInit.acnt = FALSE;
185 rgCb[macInst].rgInit.usta = FALSE;
186 rgCb[macInst].rgInit.trc = FALSE;
187 rgCb[macInst].trcLen = 0;
190 /* disabling debugs by default */
191 rgCb[macInst].rgInit.dbgMask = 0xffffffff;
195 rgCb[macInst].rgInit.logMask = 0x0;
197 rgCb[macInst].rgInit.procId = SFndProcId();
198 rgCb[macInst].tfuSap.numBndRetries = 0;
200 /* Initialize Sap state */
201 rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
202 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
203 rgCb[macInst].rguSap = NULLP;
204 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
206 rgCb[macInst].inactiveCell = NULLP;
207 rgCb[macInst].cell = NULLP;
209 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
210 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
213 /* Initializing CL control block */
214 clGlobalCp.region = region;
216 clGlobalCp.clCfgDone = FALSE;
217 clGlobalCp.numOfCells = 0;
218 clGlobalCp.phyState = PHY_STATE_IDLE;
220 if( cmHashListInit(&clGlobalCp.cellCbLst, MAX_NUM_CELL_SUPP, 0x0, FALSE,
221 CM_HASH_KEYTYPE_DEF, clGlobalCp.region, clGlobalCp.pool ) != ROK )
223 printf("\n Cellcb hash list initialization failed for MAC CL");
227 /* Initialize Scheduler as well */
228 schActvInit(ENTRG, (DEFAULT_CELLS + SCH_INST_START), DFLT_REGION, PWR_UP);
235 * @brief Layer Manager Configuration request handler.
239 * Function : RgMiLrgCfgReq
241 * This function handles the configuration
242 * request received from the Layer Manager.
243 * -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
244 * functions rgHdlGenCfg() or rgHdlSapCfg().
245 * -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
247 * @param[in] Pst *pst, the post structure
248 * @param[in] RgMngmt *cfg, the configuration parameter's structure
253 PUBLIC S16 RgMiLrgCfgReq
255 Pst *pst, /* post structure */
256 RgMngmt *cfg /* config structure */
259 PUBLIC S16 RgMiLrgCfgReq(pst, cfg)
260 Pst *pst; /* post structure */
261 RgMngmt *cfg; /* config structure */
264 U16 ret = LCM_PRIM_OK;
265 U16 reason = LCM_REASON_NOT_APPL;
273 RG_DIAG_LVL0(inst,0x0a0b0001, RG_DIAG_NA, SS_DIAG_INV_ARG,
274 "Received CfgReq for MAC layer, Entity = %d, Instance = %d\n",
275 pst->srcEnt, pst->srcInst,0,0);
277 RG_IS_INST_VALID(pst->dstInst);
278 inst = pst->dstInst - RG_INST_START;
280 /* Fill the post structure for sending the confirmation */
281 rgLMMFillCfmPst(pst, &cfmPst, cfg);
283 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
286 cfm.hdr.transId = cfg->hdr.transId;
290 cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
291 switch(cfg->hdr.elmId.elmnt)
294 reason = rgLMMGenCfg(inst,&cfg->t.cfg);
299 reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
302 reason = RgClCellCfgReq(&cfg->t.cfg.s.cellCfg);
305 reason = LCM_REASON_INVALID_ELMNT;
306 RLOG1(L_ERROR, "Invalid Elmnt=%d",
307 cfg->hdr.elmId.elmnt);
311 if (reason != LCM_REASON_NOT_APPL)
316 cfm.cfm.status = ret;
317 cfm.cfm.reason = reason;
319 RgMiLrgCfgCfm(&cfmPst, &cfm);
322 }/*-- RgMiLrgCfgReq --*/
326 * @brief Layer Manager Statistics request handler.
330 * Function : RgMiLrgStsReq
332 * This function handles the statistics
333 * request received from the Layer Manager.
334 * -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
335 * statistics from the rgCb global control block.
336 * -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
337 * -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
339 * @param[in] Pst *pst, the post structure
340 * @param[in] RgMngmt *sts, the statistics parameter's structure
345 PUBLIC S16 RgMiLrgStsReq
347 Pst *pst, /* post structure */
348 RgMngmt *sts /* statistics structure */
351 PUBLIC S16 RgMiLrgStsReq(pst, sts)
352 Pst *pst; /* post structure */
353 RgMngmt *sts; /* statistics structure */
363 RG_IS_INST_VALID(pst->dstInst);
364 inst = pst->dstInst - RG_INST_START;
365 /* Fill the post structure for sending the confirmation */
366 rgLMMFillCfmPst(pst, &cfmPst, sts);
368 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
371 cfm.hdr.transId = sts->hdr.transId;
373 SGetDateTime(&cfm.t.sts.dt);
374 cfm.cfm.status = LCM_PRIM_OK;
375 cfm.cfm.reason = LCM_REASON_NOT_APPL;
376 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
377 cfm.t.sts.action = sts->t.sts.action;
379 /* Check if General Config Done */
380 if(rgCb[inst].rgInit.cfgDone != TRUE)
382 cfm.cfm.status = LCM_PRIM_NOK;
383 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
384 RgMiLrgStsCfm(&cfmPst,&cfm);
385 RLOG0(L_ERROR, "Gen Cfg not done");
389 switch(sts->hdr.elmId.elmnt)
393 cmMemcpy((U8 *)&(cfm.t.sts.s.genSts), (U8 *)&rgCb[inst].genSts,
395 /* check if action is read and reset */
396 if(sts->t.sts.action == ARST)
398 rgCb[inst].genSts.numHarqFail = 0;
403 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
405 for(cqi=0; cqi <= 14; cqi++)
407 /* Filling DL ACK/NACK stats */
408 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
409 hqFailStats.dlCqiStat[cqi].mcs;
410 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
411 hqFailStats.dlCqiStat[cqi].numOfNacks;
412 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
413 hqFailStats.dlCqiStat[cqi].numOfAcks;
415 /* Filling UL ACK/NACK stats */
416 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
417 hqFailStats.ulCqiStat[cqi].mcs;
418 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
419 hqFailStats.ulCqiStat[cqi].numOfNacks;
420 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
421 hqFailStats.ulCqiStat[cqi].numOfAcks;
423 /* Filling DL HQ Retx stats */
424 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
425 hqRetxStats.dlCqiStat[cqi].mcs;
426 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
427 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
428 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
429 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
430 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
431 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
432 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
433 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
434 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
435 hqRetxStats.dlCqiStat[cqi].totalTx;
437 /* Filling UL HQ Retx stats */
438 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
439 hqRetxStats.ulCqiStat[cqi].mcs;
440 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
441 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
442 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
443 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
444 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
445 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
446 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
447 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
448 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
449 hqRetxStats.ulCqiStat[cqi].totalTx;
451 /* Reset statistics */
452 if(sts->t.sts.action == ZEROSTS)
454 cmMemset((U8 *)&hqRetxStats, 0, \
455 sizeof(RgSchHqRetxStats));
456 cmMemset((U8 *)&hqFailStats, 0, \
457 sizeof(RgSchNackAckStats));
460 #endif /* MAC_SCH_STATS*/
464 cmMemcpy((U8 *)&(cfm.t.sts.s.rguSts), (U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
467 /* check if action is read and reset */
468 if(sts->t.sts.action == ARST)
469 cmMemset((U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
473 cmMemcpy((U8 *)&(cfm.t.sts.s.crgSts), (U8 *)&rgCb[inst].crgSap.sapSts,
476 /* check if action is read and reset */
477 if(sts->t.sts.action == ARST)
478 cmMemset((U8 *)&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
482 cmMemcpy((U8 *)&(cfm.t.sts.s.tfuSts), (U8 *)&rgCb[inst].tfuSap.sapSts,
485 /* check if action is read and reset */
486 if(sts->t.sts.action == ARST)
487 cmMemset((U8 *)&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
491 cfm.cfm.status = LCM_PRIM_NOK;
492 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
493 RLOG1(L_ERROR, "Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
496 RgMiLrgStsCfm(&cfmPst,&cfm);
498 }/*-- RgMiLrgStsReq --*/
502 * @brief Layer Manager Status request handler.
506 * Function : RgMiLrgStaReq
508 * This function handles the solicited status
509 * request received from the Layer Manager.
510 * -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
511 * particular SAP from the rgCb global control block.
512 * -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
514 * @param[in] Pst *pst, the post structure
515 * @param[in] RgMngmt *sta, the status parameter's structure
520 PUBLIC S16 RgMiLrgStaReq
522 Pst *pst, /* post structure */
523 RgMngmt *sta /* status structure */
526 PUBLIC S16 RgMiLrgStaReq(pst, sta)
527 Pst *pst; /* post structure */
528 RgMngmt *sta; /* status structure */
538 RG_IS_INST_VALID(pst->dstInst);
539 inst = pst->dstInst - RG_INST_START;
542 /* Fill the post structure for sending the confirmation */
543 rgLMMFillCfmPst(pst, &cfmPst, sta);
545 if (sta->t.ssta.s.sysId.ptNmb != NULLP)
547 SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
550 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
551 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
554 cfm.hdr.transId = sta->hdr.transId;
556 /* Check if General Config Done */
557 if(rgCb[inst].rgInit.cfgDone != TRUE)
559 SGetDateTime(&cfm.t.ssta.dt);
560 if (SGetSBuf(cfmPst.region, cfmPst.pool,
561 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
564 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
567 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
568 rgGetSId(&cfm.t.ssta.s.sysId);
569 cfm.cfm.status = LCM_PRIM_NOK;
570 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
571 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
572 RgMiLrgStaCfm(&cfmPst, &cfm);
573 RLOG0(L_ERROR, "Gen Cfg not done");
577 switch(sta->hdr.elmId.elmnt)
580 SGetDateTime(&cfm.t.ssta.dt);
581 if (SGetSBuf(cfmPst.region, cfmPst.pool,
582 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
585 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
588 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
589 rgGetSId(&cfm.t.ssta.s.sysId);
590 cfm.cfm.status = LCM_PRIM_OK;
591 cfm.cfm.reason = LCM_REASON_NOT_APPL;
592 RgMiLrgStaCfm(&cfmPst, &cfm);
595 cfm.cfm.status = LCM_PRIM_OK;
596 cfm.cfm.reason = LCM_REASON_NOT_APPL;
597 SGetDateTime(&cfm.t.ssta.dt);
598 cmMemcpy((U8 *)&(cfm.t.ssta.s.rguSapSta),
599 (U8 *)&rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
601 RgMiLrgStaCfm(&cfmPst, &cfm);
604 cfm.cfm.status = LCM_PRIM_OK;
605 cfm.cfm.reason = LCM_REASON_NOT_APPL;
606 SGetDateTime(&cfm.t.ssta.dt);
607 cmMemcpy((U8 *)&(cfm.t.ssta.s.crgSapSta), (U8 *)&rgCb[inst].crgSap.sapSta,
609 RgMiLrgStaCfm(&cfmPst, &cfm);
612 cfm.cfm.status = LCM_PRIM_OK;
613 cfm.cfm.reason = LCM_REASON_NOT_APPL;
614 SGetDateTime(&cfm.t.ssta.dt);
615 cmMemcpy((U8 *)&(cfm.t.ssta.s.tfuSapSta), (U8 *)&rgCb[inst].tfuSap.sapSta,
617 RgMiLrgStaCfm(&cfmPst, &cfm);
620 cfm.cfm.status = LCM_PRIM_NOK;
621 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
622 RgMiLrgStaCfm(&cfmPst, &cfm);
623 RLOG1(L_ERROR, "Invalid elmnt=%d",sta->hdr.elmId.elmnt);
627 }/*-- RgMiLrgStaReq --*/
631 * @brief Layer Manager Control request handler.
635 * Function : RgMiLrgCntrlReq
637 * This function handles the control
638 * request received from the Layer Manager.
639 * -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
640 * and cntrl->t.cntrl.subAction, it performs the appropriate control action
641 * of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
642 * and layer shutdown.
643 * -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
645 * @param[in] Pst *pst, the post structure
646 * @param[in] RgMngmt *cntrl, the control parameter's structure
651 PUBLIC S16 RgMiLrgCntrlReq
653 Pst *pst, /* post structure */
654 RgMngmt *cntrl /* control structure */
657 PUBLIC S16 RgMiLrgCntrlReq(pst, cntrl)
658 Pst *pst; /* post structure */
659 RgMngmt *cntrl; /* control structure */
662 S16 ret = ROK; /* return value */
667 TRC2(RgMiLrgCntrlReq)
669 /* Fill the post structure for sending the confirmation */
671 RG_IS_INST_VALID(pst->dstInst);
672 inst = pst->dstInst - RG_INST_START;
674 rgLMMFillCfmPst(pst, &cfmPst, cntrl);
676 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
678 cfm.hdr.transId = cntrl->hdr.transId;
680 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
681 cfm.t.cntrl.action = cntrl->t.cntrl.action;
682 cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
684 /* Check if General Config Done*/
685 if(rgCb[inst].rgInit.cfgDone != TRUE)
687 cfm.cfm.status = LCM_PRIM_NOK;
688 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
689 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
690 RgMiLrgCntrlCfm(&cfmPst, &cfm);
691 RLOG0(L_ERROR, "Gen Cfg not done");
695 /* General Config done, process the Control request */
696 switch(cntrl->hdr.elmId.elmnt)
699 rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
704 rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
707 cfm.cfm.status = LCM_PRIM_NOK;
708 cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
709 RgMiLrgCntrlCfm(&cfmPst, &cfm);
710 RLOG1(L_ERROR, "invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
714 }/*-- RgMiLrgCntrlReq --*/
718 * @brief SAP Configuration Handler.
722 * Function : rgLMMSapCfg
724 * This function in called by RgMiLrgCfgReq(). It handles the
725 * interface SAP configuration of the LTE MAC layer. It
726 * initializes the sapState to LRG_UNBND. Returns
727 * reason for success/failure of this function.
729 * @param[in] Inst inst
730 * @param[in] RgCfg *cfg, the Configuaration information
732 * -# LCM_REASON_GENCFG_NOT_DONE
733 * -# LCM_REASON_INVALID_SAP
734 * -# LCM_REASON_NOT_APPL
737 PRIVATE U16 rgLMMSapCfg
740 RgCfg *cfg, /* Configuaration information */
741 Elmnt sapType /* Sap Type */
744 PRIVATE U16 rgLMMSapCfg(inst,cfg,sapType)
746 RgCfg *cfg; /* Configuaration information */
747 Elmnt sapType; /* Sap Type */
750 U16 ret = LCM_REASON_NOT_APPL;
751 RgLowSapCfgInfo *lowSapCfg = NULLP;
752 RgUpSapCfgInfo *upSapCfg = NULLP;
753 RgUpSapCb *upSapCb = NULLP;
757 /* Check if Gen Config has been done */
758 if(rgCb[inst].rgInit.cfgDone != TRUE)
759 RETVALUE(LCM_REASON_GENCFG_NOT_DONE);
764 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
765 (cfg->s.rguSap.selector != RGU_SEL_TC) &&
766 (cfg->s.rguSap.selector != RGU_SEL_LC))
768 ret = LCM_REASON_INVALID_PAR_VAL;
769 RLOG0(L_ERROR, "unsupported Selector value for RGU");
772 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
773 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
775 upSapCb->sapSta.sapState = LRG_UNBND;
777 upSapCfg = &(upSapCb->sapCfg);
778 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
779 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
780 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
781 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
782 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
783 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
784 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
785 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
786 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
787 upSapCfg->sapPst.route = cfg->s.rguSap.route;
788 upSapCfg->sapPst.intfVer = 0;
789 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
790 upSapCfg->suId = cfg->s.rguSap.suId;
791 upSapCfg->spId = cfg->s.rguSap.spId;
792 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
793 * there is cfg request with sap is 1*/
796 if ((cfg->s.crgSap.selector != CRG_SEL_TC) &&
797 (cfg->s.crgSap.selector != CRG_SEL_LC))
799 ret = LCM_REASON_INVALID_PAR_VAL;
800 RLOG0(L_ERROR, "unsupported Selector value for CRG");
803 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
805 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
807 upSapCfg = &rgCb[inst].crgSap.sapCfg;
809 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
810 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
811 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
812 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
813 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
814 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
815 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
816 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
817 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
818 upSapCfg->sapPst.route = cfg->s.crgSap.route;
819 upSapCfg->sapPst.intfVer = 0;
820 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
821 upSapCfg->suId = cfg->s.crgSap.suId;
822 upSapCfg->spId = cfg->s.crgSap.spId;
826 if ((cfg->s.tfuSap.selector != TFU_SEL_TC) &&
827 (cfg->s.tfuSap.selector != TFU_SEL_LC))
829 ret = LCM_REASON_INVALID_PAR_VAL;
830 RLOG0(L_ERROR, "unsupported Selector value for TFU");
834 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
836 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
838 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
840 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
841 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
842 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
843 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
844 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
845 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
846 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
847 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
848 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
849 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
850 lowSapCfg->sapPst.intfVer = 0;
851 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
852 lowSapCfg->suId = cfg->s.tfuSap.suId;
853 lowSapCfg->spId = cfg->s.tfuSap.spId;
854 cmMemcpy((U8 *)&lowSapCfg->bndTmr, (U8 *)&cfg->s.tfuSap.bndTmr,
858 /* would never reach here */
866 * @brief General Configuration Handler.
870 * Function : rgLMMGenCfg
872 * This function in called by RgMiLrgCfgReq(). It handles the
873 * general configuration of the LTE MAC layer. It initializes
874 * the hash lists of RgCb. Returns
875 * reason for success/failure of this function.
877 * @param[in] Inst inst
878 * @param[in] RgCfg *cfg, the Configuaration information
880 * -# LCM_REASON_NOT_APPL
881 * -# LCM_REASON_INVALID_MSGTYPE
882 * -# LCM_REASON_MEM_NOAVAIL
885 PRIVATE U16 rgLMMGenCfg
888 RgCfg *cfg /* Configuaration information */
891 PRIVATE U16 rgLMMGenCfg(inst,cfg)
893 RgCfg *cfg; /* Configuaration information */
896 U16 ret = LCM_REASON_NOT_APPL;
900 /* Check if General Configuration is done already */
901 if (rgCb[inst].rgInit.cfgDone == TRUE)
903 RETVALUE(LCM_REASON_INVALID_MSGTYPE);
905 if ((cfg->s.genCfg.lmPst.selector != LRG_SEL_TC) &&
906 (cfg->s.genCfg.lmPst.selector != LRG_SEL_LC))
908 RLOG0(L_ERROR, "unsupported Selector value for RGU");
909 RETVALUE(LCM_REASON_INVALID_PAR_VAL);
911 /* Update the Pst structure for LM interface */
912 cmMemcpy((U8 *)&rgCb[inst].rgInit.lmPst, (U8 *)&cfg->s.genCfg.lmPst,
915 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
916 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
917 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
918 rgCb[inst].rgInit.lmPst.event = EVTNONE;
920 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
921 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
922 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
923 /* Initialize SAP States */
924 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
926 if(cfg->s.genCfg.numRguSaps == 0)
928 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Invalid numRguSap.\n"));
932 /* allocate RGR saps */
933 if (SGetSBuf(rgCb[inst].rgInit.region,
934 rgCb[inst].rgInit.pool,
935 (Data **)&rgCb[inst].rguSap,
936 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
938 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Failed to allocate mem for RGU SAP's.\n"));
941 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
943 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
945 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
946 cmMemset((U8 *)&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
948 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
949 /* Initialize the timer blocks */
950 cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
951 /* Initialzie the timer queue */
952 cmMemset((U8 *)&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
953 /* Initialize the timer control point */
954 cmMemset((U8 *)&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
955 rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
956 /* Timer Registration request to SSI */
957 if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
958 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
961 RLOG0(L_ERROR, "Failed to register timer");
963 SPutSBuf(rgCb[inst].rgInit.region,
964 rgCb[inst].rgInit.pool,
965 (Data *)rgCb[inst].rguSap,
966 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
968 RETVALUE(LCM_REASON_MEM_NOAVAIL);
970 /* Set Config done in TskInit */
971 rgCb[inst].rgInit.cfgDone = TRUE;
977 /***********************************************************
979 * Func : rgLMMShutdown
982 * Desc : Handles the MAC layer shutdown request. Calls
983 * rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
992 **********************************************************/
994 PRIVATE Void rgLMMShutdown
999 PRIVATE Void rgLMMShutdown(inst)
1003 RgCellCb *cell = rgCb[inst].cell;
1008 /* Unbind the TFU Sap */
1009 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
1011 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1012 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1014 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1016 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1018 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
1020 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1021 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1027 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1029 rgTOMRlsSf(inst,&cell->subFrms[idx]);
1032 rgCFGFreeCellCb(cell);
1035 /* Deleting the RGU SAPs */
1036 SPutSBuf(rgCb[inst].rgInit.region,
1037 rgCb[inst].rgInit.pool,
1038 (Data *)rgCb[inst].rguSap,
1039 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
1040 rgCb[inst].rguSap = NULLP;
1042 rgCb[inst].inactiveCell = NULLP;
1043 rgCb[inst].cell = NULLP;
1045 /* De-register the Timer Service */
1046 (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
1047 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr);
1049 /* call back the task initialization function to intialize
1050 * the global RgCb Struct */
1051 rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region,
1052 rgCb[inst].rgInit.reason);
1058 /***********************************************************
1060 * Func : rgLMMGenCntrl
1063 * Desc : Processes the LM control request for STGEN elmnt.
1072 **********************************************************/
1074 PRIVATE Void rgLMMGenCntrl
1081 PRIVATE Void rgLMMGenCntrl(cntrl, cfm, cfmPst)
1087 Inst inst = (cfmPst->srcInst - RG_INST_START);
1090 cfm->cfm.status = LCM_PRIM_OK;
1091 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1094 switch(cntrl->t.cntrl.action)
1097 /* Action is Enable */
1098 switch(cntrl->t.cntrl.subAction)
1102 rgCb[inst].rgInit.trc = TRUE;
1103 rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1104 /*Store the response and TransId for sending the Traces */
1105 cmMemcpy((U8 *)&rgCb[inst].genCfg.trcResp.response,
1106 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1107 rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1111 /* Enable Unsolicited Status (alarms) */
1112 rgCb[inst].rgInit.usta = TRUE;
1113 /*Store the response and TransId for sending the Alarms */
1114 cmMemcpy((U8 *)&rgCb[inst].genCfg.ustaResp.response,
1115 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1116 rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1119 /* Enable Debug Printing */
1121 rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1126 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1131 cfm->cfm.status = LCM_PRIM_NOK;
1132 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1133 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1138 /* Action is Diable immidiately */
1139 switch(cntrl->t.cntrl.subAction)
1142 /* Disable Traces */
1143 rgCb[inst].rgInit.trc = FALSE;
1146 /* Disable Unsolicited Status (alarms) */
1147 rgCb[inst].rgInit.usta = FALSE;
1150 /* Disable Debug Printing */
1152 rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1157 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1162 cfm->cfm.status = LCM_PRIM_NOK;
1163 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1164 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1169 /* Free all the memory dynamically allocated by MAC */
1170 rgLMMShutdown(inst);
1173 cfm->cfm.status = LCM_PRIM_NOK;
1174 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1175 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1178 RgMiLrgCntrlCfm(cfmPst, cfm);
1183 /***********************************************************
1185 * Func : rgLMMSapCntrl
1188 * Desc : Processes the LM control request for STxxxSAP elmnt.
1197 **********************************************************/
1199 PRIVATE Void rgLMMSapCntrl
1206 PRIVATE Void rgLMMSapCntrl(cntrl, cfm, cfmPst)
1212 Inst inst = cfmPst->srcInst - RG_INST_START;
1215 /* Only TFU Sap can be controlled by LM */
1216 switch(cntrl->hdr.elmId.elmnt)
1219 switch(cntrl->t.cntrl.action)
1222 /* Bind Enable Request */
1223 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1224 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1226 cfm->cfm.status = LCM_PRIM_NOK;
1227 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1231 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1233 rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val,
1234 (PTR)&rgCb[inst].tfuSap);
1236 /* Change SAP state */
1237 rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1238 rgCb[inst].tfuSap.numBndRetries++;
1239 /* Store the response and TransId for sending
1240 * the Control confirm */
1241 cmMemcpy((U8 *)&rgCb[inst].genCfg.bndCfmResp.response,
1242 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1243 rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1245 /* Sending Status Indication to Layer Manager */
1246 cfm->cfm.status = LCM_PRIM_OK_NDONE;
1247 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1248 RgMiLrgCntrlCfm(cfmPst, cfm);
1250 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1251 rgCb[inst].tfuSap.sapCfg.spId);
1256 /* Unbind request */
1258 /* Check if the SAP is configured */
1259 if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1260 (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1262 cfm->cfm.status = LCM_PRIM_NOK;
1263 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1267 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1268 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1270 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1272 /* Change SAP state */
1273 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1274 cfm->cfm.status = LCM_PRIM_OK;
1275 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1279 /* Delete SAP, does initialization of SAP */
1280 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1281 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1283 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1284 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1286 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1289 cmMemset((U8 *)&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1290 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1291 cfm->cfm.status = LCM_PRIM_OK;
1292 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1295 cfm->cfm.status = LCM_PRIM_NOK;
1296 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1297 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1298 cntrl->t.cntrl.action));
1303 switch(cntrl->t.cntrl.action)
1306 cmMemset((U8 *)&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1307 rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1308 cfm->cfm.status = LCM_PRIM_OK;
1309 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1312 cfm->cfm.status = LCM_PRIM_NOK;
1313 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1314 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1315 cntrl->t.cntrl.action));
1320 switch(cntrl->t.cntrl.action)
1323 cmMemset((U8 *)&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1324 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1325 cfm->cfm.status = LCM_PRIM_OK;
1326 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1329 cfm->cfm.status = LCM_PRIM_NOK;
1330 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1331 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1337 /* Would never here. */
1340 RgMiLrgCntrlCfm(cfmPst, cfm);
1345 /***********************************************************
1347 * Func : rgLMMFillCfmPst
1350 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
1351 * and the cfm->hdr.response.
1360 **********************************************************/
1362 PRIVATE Void rgLMMFillCfmPst
1369 PRIVATE Void rgLMMFillCfmPst(reqPst, cfmPst, cfm)
1376 TRC2(rgLMMFillCfmPst)
1377 inst = (reqPst->dstInst - RG_INST_START);
1379 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
1380 cfmPst->srcInst = rgCb[inst].rgInit.inst;
1381 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1382 cfmPst->dstEnt = reqPst->srcEnt;
1383 cfmPst->dstInst = reqPst->srcInst;
1384 cfmPst->dstProcId = reqPst->srcProcId;
1386 cfmPst->selector = cfm->hdr.response.selector;
1387 cfmPst->prior = cfm->hdr.response.prior;
1388 cfmPst->route = cfm->hdr.response.route;
1389 cfmPst->region = cfm->hdr.response.mem.region;
1390 cfmPst->pool = cfm->hdr.response.mem.pool;
1397 * @brief Timer start handler.
1401 * Function : rgLMMStartTmr
1403 * This function based on the input parameters starts the timer for
1404 * "tmrVal" duration. As of now MAC uses the timer functionality for
1405 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1407 * @param[in] Inst inst
1408 * @param[in] S16 tmrEvnt, the Timer Event
1409 * @param[in] U32 tmrVal, the Wait Time
1410 * @param[in] PTR cb, Entry for which Timer expired
1415 PUBLIC S16 rgLMMStartTmr
1418 S16 tmrEvnt, /* Timer Event */
1419 U32 tmrVal, /* Wait Time */
1420 PTR cb /* Entry for which Timer Expired */
1423 PUBLIC S16 rgLMMStartTmr(tmrEvnt, tmrVal, cb)
1425 S16 tmrEvnt; /* Timer Event */
1426 U32 tmrVal; /* Wait Time */
1427 PTR cb; /* Entry for which Timer Expired */
1436 /* Initialize the arg structure */
1437 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1439 arg.tqCp = &rgCb[inst].tmrTqCp;
1440 arg.tq = rgCb[inst].tmrTq;
1441 arg.timers = rgCb[inst].tmrBlk;
1444 arg.max = RG_MAX_TIMER;
1445 arg.evnt = RG_BNDREQ_TMR;
1454 * @brief Timer stop handler.
1458 * Function : rgLMMStopTmr
1460 * This function based on the input parameters stops the timer for
1461 * "tmrEvnt". As of now MAC uses the timer functionality for
1462 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1463 * Once the bind happens and this timer is stopped, the timer functionality
1464 * is deregistered with SSI. As there is no further use of timer processing.
1466 * @param[in] Inst inst
1467 * @param[in] S16 tmrEvnt, the Timer Event
1468 * @param[in] PTR cb, Entry for which Timer expired
1474 PUBLIC S16 rgLMMStopTmr
1476 Inst inst, /* Scheduler instance */
1477 S16 tmrEvnt, /* Timer Event */
1478 PTR cb /* Entry for which Timer Expired */
1481 PUBLIC S16 rgLMMStopTmr(inst,tmrEvnt, cb)
1482 Inst inst; /* Scheduler instance */
1483 S16 tmrEvnt; /* Timer Event */
1484 PTR cb; /* Entry for which Timer Expired */
1495 for(i=0;i<RG_MAX_TIMER;i++)
1497 /* Search for the Timer Blocks */
1498 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1500 /* Initialize the arg structure */
1501 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1503 arg.tqCp = &rgCb[inst].tmrTqCp;
1504 arg.tq = rgCb[inst].tmrTq;
1505 arg.timers = rgCb[inst].tmrBlk;
1507 arg.max = RG_MAX_TIMER;
1525 * @brief Timer Expiry handler.
1529 * Function : rgLMMTmrExpiry
1531 * This is a callback function used as an input parameter to cmPrcTmr()
1532 * to check expiry of any timer. In this function, the only concern is
1533 * about tmrEvnt=Bind timer.
1535 * @param[in] PTR cb, Entry for which Timer expired
1536 * @param[in] S16 tmrEvnt, the Timer Event
1541 PUBLIC S16 rgLMMTmrExpiry
1543 PTR cb, /* Pointer to timer control block */
1544 S16 tmrEvnt /* Timer Event */
1547 PUBLIC S16 rgLMMTmrExpiry(cb,tmrEvnt)
1548 PTR cb; /* Pointer to timer control block */
1549 S16 tmrEvnt; /* Timer Event */
1553 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1554 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1556 TRC2(rgLMMTmrExpiry)
1562 tfuSap->numBndRetries++;
1563 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1565 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1566 LCM_CAUSE_TMR_EXPIRED, NULLP);
1570 /* Restart the bind timer */
1571 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1573 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1577 /* Send bind request */
1578 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1579 rgCb[inst].tfuSap.sapCfg.spId);
1583 RLOG1(L_ERROR, "Invalid tmrEvnt=%d",tmrEvnt);
1593 * @brief Layer Manager Unsolicited Status Indication generation.
1597 * Function : rgLMMStaInd
1599 * This API is used by the other modules of MAC to send a unsolicited
1600 * status indication to the Layer Manager.
1602 * @param[in] Inst inst
1603 * @param[in] U16 category, the Alarm category
1604 * @param[in] U16 event, the Alarm event
1605 * @param[in] U16 cause, the cause of the Alarm
1606 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1611 PUBLIC S16 rgLMMStaInd
1620 PUBLIC S16 rgLMMStaInd(inst,category, event, cause, dgn)
1632 if(rgCb[inst].rgInit.usta == FALSE)
1637 cmMemset((U8 *)&usta, 0, sizeof(RgMngmt));
1639 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1640 usta.t.usta.cmAlarm.category = category;
1641 usta.t.usta.cmAlarm.event = event;
1642 usta.t.usta.cmAlarm.cause = cause;
1645 cmMemcpy((U8 *)&usta.t.usta.dgn, (U8 *)dgn, sizeof(RgUstaDgn));
1648 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1649 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1650 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1651 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1652 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1653 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1655 RETVALUE(RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1660 * @brief Layer Manager Trace Indication generation.
1664 * Function : rgLMMTrcInd
1666 * This API is used by the other modules of MAC to send a
1667 * Trace indication to the Layer Manager.
1669 * @param[in] Inst inst
1670 * @param[in] Buffer *srcMbuf, the Message Buffer .
1671 * @param[in] U8 event, the trace event.
1675 PUBLIC Void rgLMMTrcInd
1678 Buffer *srcMbuf, /* Message Buffer */
1679 U8 event /* event */
1682 PUBLIC Void rgLMMTrcInd(inst,srcMbuf,event)
1684 Buffer *srcMbuf; /* Message Buffer */
1685 U8 event; /* event */
1688 Buffer *dstMbuf = NULLP;
1698 if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1700 RLOG0(L_ERROR, "Trace Disabled.");
1704 cmMemset((U8 *)&trc, 0, sizeof(RgMngmt));
1706 pst = rgCb[inst].rgInit.lmPst;
1707 pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1708 pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1709 pst.route = rgCb[inst].genCfg.trcResp.response.route;
1710 pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1711 pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1713 trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1715 SGetDateTime(&trc.t.trc.dt);
1717 /* Check if the whole buffer is to be sent in Trace indication */
1718 if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1720 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1723 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1726 trc.cfm.status = LCM_PRIM_OK;
1727 trc.cfm.reason = LCM_REASON_NOT_APPL;
1728 trc.t.trc.evnt = event;
1730 /* Send Trace Indication to Layer manager */
1731 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1733 /* check if only a specified number of bytes are to be sent */
1734 else if(rgCb[inst].trcLen > 0)
1736 /* Get the length of the recvd message buffer */
1737 if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1739 RLOG0(L_ERROR, "SFndLenMsg Failed.");
1742 /* Check if the recvd buffer size is less than request trace len */
1743 if(bufLen < rgCb[inst].trcLen)
1745 /* Copy the whole of the recvd buffer in trace indication */
1747 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1750 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1754 trc.cfm.status = LCM_PRIM_OK;
1755 trc.cfm.reason = LCM_REASON_NOT_APPL;
1756 trc.t.trc.evnt = event;
1758 /* Send Trace Indication to Layer manager */
1759 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1761 /* if the recvd buffer size is greater than request trace len */
1762 if(bufLen >= rgCb[inst].trcLen)
1764 /* Get a temporary buffer to store the msg */
1765 if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1767 RLOG0(L_ERROR, "rgAllocSBuf Failed.");
1771 /* Copy trcLen nos of bytes from the recvd message */
1772 if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)
1774 RLOG0(L_ERROR, "SCpyMsgFix Failed.");
1778 if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1780 RLOG0(L_ERROR, "dstMbuf Allocation Failed");
1783 /* Copy the tempBuf data to dst mBuf */
1784 if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1786 RLOG0(L_ERROR, "SCpyFixMsg Failed.");
1790 /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1792 /* Free the memory allocated for tempBuf */
1793 rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1795 trc.cfm.status = LCM_PRIM_OK;
1796 trc.cfm.reason = LCM_REASON_NOT_APPL;
1797 trc.t.trc.evnt = event;
1799 /* Send Trace Indication to Layer manager */
1800 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1808 * @brief Layer Manager Control Confirm generation handler
1809 * for Bind Confirm reception at TFU interface.
1810 * RgLiTfuBndCfm() forwards the confirmation to this
1811 * function. All SAP state related handling is restricted
1812 * to LMM modules, hence the cfm forwarding.
1816 * Function : rgLMMBndCfm
1818 * This API is used by the LIM module of MAC to forward
1819 * the Bind Confirm it receives over the TFU interface.
1821 * @param[in] Pst *pst, Post Structure
1822 * @param[in] SuId suId, Service user ID
1823 * @param[in] U8 status, Status
1828 PUBLIC S16 rgLMMBndCfm
1830 Pst *pst, /* Post Structure */
1831 SuId suId, /* Service user ID */
1832 U8 status /* Status */
1835 PUBLIC S16 rgLMMBndCfm(pst,suId,status)
1836 Pst *pst; /* Post Structure */
1837 SuId suId; /* Service user ID */
1838 U8 status; /* Status */
1841 Inst inst = pst->dstInst - RG_INST_START;
1850 /* Check if the suId is valid */
1851 if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1853 RLOG0(L_ERROR, "Invalid SuId");
1857 /* check the Sap State */
1858 switch(rgCb[inst].tfuSap.sapSta.sapState)
1860 case LRG_WAIT_BNDCFM:
1863 /* SAP is already bound */
1869 cfmPst = rgCb[inst].rgInit.lmPst;
1870 cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1871 cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1872 cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1873 cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1874 cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1876 cmMemset((U8 *)&cntrlCfm, 0, sizeof(RgMngmt));
1880 case CM_BND_OK: /* status is OK */
1881 /* Change SAP state to Bound */
1882 rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1883 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1885 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1887 /* Send Control Confirm with status as OK to Layer Manager */
1888 cntrlCfm.cfm.status = LCM_PRIM_OK;
1889 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1893 /* Change SAP state to UnBound */
1894 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1895 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1897 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1899 /* Send Control Confirm with status as NOK to Layer Manager */
1900 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1901 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1904 rgCb[inst].tfuSap.numBndRetries = 0;
1905 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1906 cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1908 ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1915 * @brief LTE MAC timer call back function registered with SSI.
1919 * Function : rgActvTmr
1921 * This function is invoked by SSI for every timer activation
1928 PUBLIC S16 rgActvTmr
1934 PUBLIC S16 rgActvTmr(ent, inst)
1939 Inst macInst = (inst - RG_INST_START);
1942 /* Check if any MAC timer has expired */
1943 cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1947 } /* end of rgActvTmr */
1950 * @brief Layer Manager Configuration request handler for Scheduler
1954 * Function : MacSchGenCfgReq
1956 * This function receives general configurations for Scheduler
1957 * from DU APP and forwards to Scheduler.
1959 * @param[in] Pst *pst, the post structure
1960 * @param[in] RgMngmt *cfg, the configuration parameter's structure
1965 PUBLIC S16 MacSchGenCfgReq
1967 Pst *pst, /* post structure */
1968 RgMngmt *cfg /* config structure */
1971 PUBLIC S16 MacSchGenCfgReq(pst, cfg)
1972 Pst *pst; /* post structure */
1973 RgMngmt *cfg; /* config structure */
1976 printf("\nReceived Scheduler gen config at MAC");
1977 pst->dstInst = DEFAULT_CELLS + 1;
1978 HandleSchGenCfgReq(pst, cfg);
1984 * @brief Layer Manager Configuration response from Scheduler
1988 * Function : SchSendCfgCfm
1990 * This function sends general configurations response from
1991 * Scheduler to DU APP.
1993 * @param[in] Pst *pst, the post structure
1994 * @param[in] RgMngmt *cfm, the configuration confirm structure
1999 PUBLIC S16 SchSendCfgCfm
2001 Pst *pst, /* post structure */
2002 RgMngmt *cfm /* config confirm structure */
2005 PUBLIC S16 SchSendCfgCfm(pst, cfm)
2006 Pst *pst; /* post structure */
2007 RgMngmt *cfm; /* config confirm structure */
2010 printf("\nSending Scheduler config confirm to DU APP");
2011 RgMiLrgSchCfgCfm(pst, cfm);
2017 * @brief Layer Manager Configuration request handler.
2021 * Function : MacSchCfgReq
2023 * This function handles the gNB and cell configuration
2024 * request received from DU APP.
2025 * This API unapcks and forwards the config towards SCH
2027 * @param[in] Pst *pst
2028 * @param[in] RgrCfgTransId transId
2029 * @param[in] RgrCfgReqInfo *cfgReqInfo
2034 PUBLIC S16 MacSchCfgReq
2037 RgrCfgTransId transId,
2038 RgrCfgReqInfo *cfgReqInfo
2041 PUBLIC S16 MacSchCfgReq(pst, transId, cfgReqInfo)
2043 RgrCfgTransId transId;
2044 RgrCfgReqInfo *cfgReqInfo;
2047 printf("\nReceived Scheduler config at MAC");
2048 pst->dstInst = DEFAULT_CELLS + 1;
2049 HandleSchCfgReq(pst, transId, cfgReqInfo);
2053 } /* end of MacSchCfgReq*/
2056 /**********************************************************************
2059 **********************************************************************/