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 "du_app_mac_inf.h"
79 #include "rg.x" /* MAC includes */
81 #include "ss_diag.h" /* Common log file */
86 #include "lwr_mac.h" /* MAC CL defines */
90 #endif /* __cplusplus */
91 EXTERN Void rgGetSId ARGS((SystemId *s));
94 #endif /* __cplusplus */
96 /* Public variable declaration */
99 /* forward references */
100 PRIVATE U16 rgLMMGenCfg ARGS((
105 PRIVATE U16 rgLMMSapCfg ARGS((
111 PRIVATE Void rgLMMShutdown ARGS((
115 PRIVATE Void rgLMMFillCfmPst ARGS((
121 PRIVATE Void rgLMMGenCntrl ARGS((
127 PRIVATE Void rgLMMSapCntrl ARGS((
133 extern U16 cmPackMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm);
135 packMacCellCfgCfm packMacCellCfmOpts[] =
137 cmPackMacCellCfgCfm, /* packing for loosely coupled */
138 duHandleMacCellCfgCfm, /* packing for tightly coupled */
139 cmPackMacCellCfgCfm, /* packing for light weight loosly coupled */
143 * @brief Task Initiation callback function.
147 * Function : rgActvInit
149 * This function is supplied as one of parameters during MAC's
150 * task registration. SSI will invoke this function once, after
151 * it creates and attaches this TAPA Task to a system task.
153 * @param[in] Ent entity, the entity ID of this task.
154 * @param[in] Inst inst, the instance ID of this task.
155 * @param[in] Region region, the region ID registered for memory
156 * usage of this task.
157 * @param[in] Reason reason.
162 PUBLIC S16 rgActvInit
164 Ent entity, /* entity */
165 Inst inst, /* instance */
166 Region region, /* region */
167 Reason reason /* reason */
170 PUBLIC S16 rgActvInit(entity, inst, region, reason)
171 Ent entity; /* entity */
172 Inst inst; /* instance */
173 Region region; /* region */
174 Reason reason; /* reason */
180 RG_IS_INST_VALID(inst);
182 macInst = inst - RG_INST_START;
183 /* Initialize the MAC TskInit structure to zero */
184 cmMemset ((U8 *)&rgCb[macInst], 0, sizeof(RgCb));
186 /* Initialize the MAC TskInit with received values */
187 rgCb[macInst].rgInit.ent = entity;
188 rgCb[macInst].rgInit.inst = inst;
189 rgCb[macInst].rgInit.region = region;
190 rgCb[macInst].rgInit.pool = 0;
191 rgCb[macInst].rgInit.reason = reason;
192 rgCb[macInst].rgInit.cfgDone = FALSE;
193 rgCb[macInst].rgInit.acnt = FALSE;
194 rgCb[macInst].rgInit.usta = FALSE;
195 rgCb[macInst].rgInit.trc = FALSE;
196 rgCb[macInst].trcLen = 0;
199 /* disabling debugs by default */
200 rgCb[macInst].rgInit.dbgMask = 0xffffffff;
204 rgCb[macInst].rgInit.logMask = 0x0;
206 rgCb[macInst].rgInit.procId = SFndProcId();
207 rgCb[macInst].tfuSap.numBndRetries = 0;
209 /* Initialize Sap state */
210 rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
211 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
212 rgCb[macInst].rguSap = NULLP;
213 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
215 rgCb[macInst].inactiveCell = NULLP;
216 rgCb[macInst].cell = NULLP;
218 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
219 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
222 /* Initializing CL control block */
223 clGlobalCp.region = region;
225 clGlobalCp.clCfgDone = FALSE;
226 clGlobalCp.numOfCells = 0;
227 clGlobalCp.phyState = PHY_STATE_IDLE;
229 if( cmHashListInit(&clGlobalCp.cellCbLst, MAX_NUM_CELL_SUPP, 0x0, FALSE,
230 CM_HASH_KEYTYPE_DEF, clGlobalCp.region, clGlobalCp.pool ) != ROK )
232 printf("\n Cellcb hash list initialization failed for MAC CL");
236 /* Initialize Scheduler as well */
237 schActvInit(ENTRG, (DEFAULT_CELLS + SCH_INST_START), DFLT_REGION, PWR_UP);
244 * @brief Layer Manager Configuration request handler.
248 * Function : RgMiLrgCfgReq
250 * This function handles the configuration
251 * request received from the Layer Manager.
252 * -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
253 * functions rgHdlGenCfg() or rgHdlSapCfg().
254 * -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
256 * @param[in] Pst *pst, the post structure
257 * @param[in] RgMngmt *cfg, the configuration parameter's structure
262 PUBLIC S16 RgMiLrgCfgReq
264 Pst *pst, /* post structure */
265 RgMngmt *cfg /* config structure */
268 PUBLIC S16 RgMiLrgCfgReq(pst, cfg)
269 Pst *pst; /* post structure */
270 RgMngmt *cfg; /* config structure */
273 U16 ret = LCM_PRIM_OK;
274 U16 reason = LCM_REASON_NOT_APPL;
282 RG_DIAG_LVL0(inst,0x0a0b0001, RG_DIAG_NA, SS_DIAG_INV_ARG,
283 "Received CfgReq for MAC layer, Entity = %d, Instance = %d\n",
284 pst->srcEnt, pst->srcInst,0,0);
286 RG_IS_INST_VALID(pst->dstInst);
287 inst = pst->dstInst - RG_INST_START;
289 /* Fill the post structure for sending the confirmation */
290 rgLMMFillCfmPst(pst, &cfmPst, cfg);
292 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
295 cfm.hdr.transId = cfg->hdr.transId;
299 cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
300 switch(cfg->hdr.elmId.elmnt)
303 reason = rgLMMGenCfg(inst,&cfg->t.cfg);
308 reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
312 reason = LCM_REASON_INVALID_ELMNT;
313 RLOG1(L_ERROR, "Invalid Elmnt=%d",
314 cfg->hdr.elmId.elmnt);
318 if (reason != LCM_REASON_NOT_APPL)
323 cfm.cfm.status = ret;
324 cfm.cfm.reason = reason;
326 RgMiLrgCfgCfm(&cfmPst, &cfm);
329 }/*-- RgMiLrgCfgReq --*/
333 * @brief Layer Manager Statistics request handler.
337 * Function : RgMiLrgStsReq
339 * This function handles the statistics
340 * request received from the Layer Manager.
341 * -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
342 * statistics from the rgCb global control block.
343 * -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
344 * -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
346 * @param[in] Pst *pst, the post structure
347 * @param[in] RgMngmt *sts, the statistics parameter's structure
352 PUBLIC S16 RgMiLrgStsReq
354 Pst *pst, /* post structure */
355 RgMngmt *sts /* statistics structure */
358 PUBLIC S16 RgMiLrgStsReq(pst, sts)
359 Pst *pst; /* post structure */
360 RgMngmt *sts; /* statistics structure */
370 RG_IS_INST_VALID(pst->dstInst);
371 inst = pst->dstInst - RG_INST_START;
372 /* Fill the post structure for sending the confirmation */
373 rgLMMFillCfmPst(pst, &cfmPst, sts);
375 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
378 cfm.hdr.transId = sts->hdr.transId;
380 SGetDateTime(&cfm.t.sts.dt);
381 cfm.cfm.status = LCM_PRIM_OK;
382 cfm.cfm.reason = LCM_REASON_NOT_APPL;
383 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
384 cfm.t.sts.action = sts->t.sts.action;
386 /* Check if General Config Done */
387 if(rgCb[inst].rgInit.cfgDone != TRUE)
389 cfm.cfm.status = LCM_PRIM_NOK;
390 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
391 RgMiLrgStsCfm(&cfmPst,&cfm);
392 RLOG0(L_ERROR, "Gen Cfg not done");
396 switch(sts->hdr.elmId.elmnt)
400 cmMemcpy((U8 *)&(cfm.t.sts.s.genSts), (U8 *)&rgCb[inst].genSts,
402 /* check if action is read and reset */
403 if(sts->t.sts.action == ARST)
405 rgCb[inst].genSts.numHarqFail = 0;
410 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
412 for(cqi=0; cqi <= 14; cqi++)
414 /* Filling DL ACK/NACK stats */
415 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
416 hqFailStats.dlCqiStat[cqi].mcs;
417 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
418 hqFailStats.dlCqiStat[cqi].numOfNacks;
419 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
420 hqFailStats.dlCqiStat[cqi].numOfAcks;
422 /* Filling UL ACK/NACK stats */
423 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
424 hqFailStats.ulCqiStat[cqi].mcs;
425 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
426 hqFailStats.ulCqiStat[cqi].numOfNacks;
427 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
428 hqFailStats.ulCqiStat[cqi].numOfAcks;
430 /* Filling DL HQ Retx stats */
431 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
432 hqRetxStats.dlCqiStat[cqi].mcs;
433 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
434 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
435 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
436 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
437 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
438 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
439 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
440 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
441 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
442 hqRetxStats.dlCqiStat[cqi].totalTx;
444 /* Filling UL HQ Retx stats */
445 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
446 hqRetxStats.ulCqiStat[cqi].mcs;
447 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
448 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
449 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
450 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
451 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
452 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
453 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
454 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
455 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
456 hqRetxStats.ulCqiStat[cqi].totalTx;
458 /* Reset statistics */
459 if(sts->t.sts.action == ZEROSTS)
461 cmMemset((U8 *)&hqRetxStats, 0, \
462 sizeof(RgSchHqRetxStats));
463 cmMemset((U8 *)&hqFailStats, 0, \
464 sizeof(RgSchNackAckStats));
467 #endif /* MAC_SCH_STATS*/
471 cmMemcpy((U8 *)&(cfm.t.sts.s.rguSts), (U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
474 /* check if action is read and reset */
475 if(sts->t.sts.action == ARST)
476 cmMemset((U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
480 cmMemcpy((U8 *)&(cfm.t.sts.s.crgSts), (U8 *)&rgCb[inst].crgSap.sapSts,
483 /* check if action is read and reset */
484 if(sts->t.sts.action == ARST)
485 cmMemset((U8 *)&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
489 cmMemcpy((U8 *)&(cfm.t.sts.s.tfuSts), (U8 *)&rgCb[inst].tfuSap.sapSts,
492 /* check if action is read and reset */
493 if(sts->t.sts.action == ARST)
494 cmMemset((U8 *)&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
498 cfm.cfm.status = LCM_PRIM_NOK;
499 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
500 RLOG1(L_ERROR, "Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
503 RgMiLrgStsCfm(&cfmPst,&cfm);
505 }/*-- RgMiLrgStsReq --*/
509 * @brief Layer Manager Status request handler.
513 * Function : RgMiLrgStaReq
515 * This function handles the solicited status
516 * request received from the Layer Manager.
517 * -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
518 * particular SAP from the rgCb global control block.
519 * -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
521 * @param[in] Pst *pst, the post structure
522 * @param[in] RgMngmt *sta, the status parameter's structure
527 PUBLIC S16 RgMiLrgStaReq
529 Pst *pst, /* post structure */
530 RgMngmt *sta /* status structure */
533 PUBLIC S16 RgMiLrgStaReq(pst, sta)
534 Pst *pst; /* post structure */
535 RgMngmt *sta; /* status structure */
545 RG_IS_INST_VALID(pst->dstInst);
546 inst = pst->dstInst - RG_INST_START;
549 /* Fill the post structure for sending the confirmation */
550 rgLMMFillCfmPst(pst, &cfmPst, sta);
552 if (sta->t.ssta.s.sysId.ptNmb != NULLP)
554 SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
557 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
558 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
561 cfm.hdr.transId = sta->hdr.transId;
563 /* Check if General Config Done */
564 if(rgCb[inst].rgInit.cfgDone != TRUE)
566 SGetDateTime(&cfm.t.ssta.dt);
567 if (SGetSBuf(cfmPst.region, cfmPst.pool,
568 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
571 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
574 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
575 rgGetSId(&cfm.t.ssta.s.sysId);
576 cfm.cfm.status = LCM_PRIM_NOK;
577 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
578 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
579 RgMiLrgStaCfm(&cfmPst, &cfm);
580 RLOG0(L_ERROR, "Gen Cfg not done");
584 switch(sta->hdr.elmId.elmnt)
587 SGetDateTime(&cfm.t.ssta.dt);
588 if (SGetSBuf(cfmPst.region, cfmPst.pool,
589 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
592 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
595 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
596 rgGetSId(&cfm.t.ssta.s.sysId);
597 cfm.cfm.status = LCM_PRIM_OK;
598 cfm.cfm.reason = LCM_REASON_NOT_APPL;
599 RgMiLrgStaCfm(&cfmPst, &cfm);
602 cfm.cfm.status = LCM_PRIM_OK;
603 cfm.cfm.reason = LCM_REASON_NOT_APPL;
604 SGetDateTime(&cfm.t.ssta.dt);
605 cmMemcpy((U8 *)&(cfm.t.ssta.s.rguSapSta),
606 (U8 *)&rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
608 RgMiLrgStaCfm(&cfmPst, &cfm);
611 cfm.cfm.status = LCM_PRIM_OK;
612 cfm.cfm.reason = LCM_REASON_NOT_APPL;
613 SGetDateTime(&cfm.t.ssta.dt);
614 cmMemcpy((U8 *)&(cfm.t.ssta.s.crgSapSta), (U8 *)&rgCb[inst].crgSap.sapSta,
616 RgMiLrgStaCfm(&cfmPst, &cfm);
619 cfm.cfm.status = LCM_PRIM_OK;
620 cfm.cfm.reason = LCM_REASON_NOT_APPL;
621 SGetDateTime(&cfm.t.ssta.dt);
622 cmMemcpy((U8 *)&(cfm.t.ssta.s.tfuSapSta), (U8 *)&rgCb[inst].tfuSap.sapSta,
624 RgMiLrgStaCfm(&cfmPst, &cfm);
627 cfm.cfm.status = LCM_PRIM_NOK;
628 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
629 RgMiLrgStaCfm(&cfmPst, &cfm);
630 RLOG1(L_ERROR, "Invalid elmnt=%d",sta->hdr.elmId.elmnt);
634 }/*-- RgMiLrgStaReq --*/
638 * @brief Layer Manager Control request handler.
642 * Function : RgMiLrgCntrlReq
644 * This function handles the control
645 * request received from the Layer Manager.
646 * -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
647 * and cntrl->t.cntrl.subAction, it performs the appropriate control action
648 * of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
649 * and layer shutdown.
650 * -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
652 * @param[in] Pst *pst, the post structure
653 * @param[in] RgMngmt *cntrl, the control parameter's structure
658 PUBLIC S16 RgMiLrgCntrlReq
660 Pst *pst, /* post structure */
661 RgMngmt *cntrl /* control structure */
664 PUBLIC S16 RgMiLrgCntrlReq(pst, cntrl)
665 Pst *pst; /* post structure */
666 RgMngmt *cntrl; /* control structure */
669 S16 ret = ROK; /* return value */
674 TRC2(RgMiLrgCntrlReq)
676 /* Fill the post structure for sending the confirmation */
678 RG_IS_INST_VALID(pst->dstInst);
679 inst = pst->dstInst - RG_INST_START;
681 rgLMMFillCfmPst(pst, &cfmPst, cntrl);
683 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
685 cfm.hdr.transId = cntrl->hdr.transId;
687 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
688 cfm.t.cntrl.action = cntrl->t.cntrl.action;
689 cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
691 /* Check if General Config Done*/
692 if(rgCb[inst].rgInit.cfgDone != TRUE)
694 cfm.cfm.status = LCM_PRIM_NOK;
695 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
696 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
697 RgMiLrgCntrlCfm(&cfmPst, &cfm);
698 RLOG0(L_ERROR, "Gen Cfg not done");
702 /* General Config done, process the Control request */
703 switch(cntrl->hdr.elmId.elmnt)
706 rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
711 rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
714 cfm.cfm.status = LCM_PRIM_NOK;
715 cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
716 RgMiLrgCntrlCfm(&cfmPst, &cfm);
717 RLOG1(L_ERROR, "invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
721 }/*-- RgMiLrgCntrlReq --*/
725 * @brief SAP Configuration Handler.
729 * Function : rgLMMSapCfg
731 * This function in called by RgMiLrgCfgReq(). It handles the
732 * interface SAP configuration of the LTE MAC layer. It
733 * initializes the sapState to LRG_UNBND. Returns
734 * reason for success/failure of this function.
736 * @param[in] Inst inst
737 * @param[in] RgCfg *cfg, the Configuaration information
739 * -# LCM_REASON_GENCFG_NOT_DONE
740 * -# LCM_REASON_INVALID_SAP
741 * -# LCM_REASON_NOT_APPL
744 PRIVATE U16 rgLMMSapCfg
747 RgCfg *cfg, /* Configuaration information */
748 Elmnt sapType /* Sap Type */
751 PRIVATE U16 rgLMMSapCfg(inst,cfg,sapType)
753 RgCfg *cfg; /* Configuaration information */
754 Elmnt sapType; /* Sap Type */
757 U16 ret = LCM_REASON_NOT_APPL;
758 RgLowSapCfgInfo *lowSapCfg = NULLP;
759 RgUpSapCfgInfo *upSapCfg = NULLP;
760 RgUpSapCb *upSapCb = NULLP;
764 /* Check if Gen Config has been done */
765 if(rgCb[inst].rgInit.cfgDone != TRUE)
766 RETVALUE(LCM_REASON_GENCFG_NOT_DONE);
771 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
772 (cfg->s.rguSap.selector != RGU_SEL_TC) &&
773 (cfg->s.rguSap.selector != RGU_SEL_LC))
775 ret = LCM_REASON_INVALID_PAR_VAL;
776 RLOG0(L_ERROR, "unsupported Selector value for RGU");
779 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
780 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
782 upSapCb->sapSta.sapState = LRG_UNBND;
784 upSapCfg = &(upSapCb->sapCfg);
785 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
786 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
787 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
788 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
789 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
790 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
791 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
792 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
793 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
794 upSapCfg->sapPst.route = cfg->s.rguSap.route;
795 upSapCfg->sapPst.intfVer = 0;
796 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
797 upSapCfg->suId = cfg->s.rguSap.suId;
798 upSapCfg->spId = cfg->s.rguSap.spId;
799 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
800 * there is cfg request with sap is 1*/
803 if ((cfg->s.crgSap.selector != CRG_SEL_TC) &&
804 (cfg->s.crgSap.selector != CRG_SEL_LC))
806 ret = LCM_REASON_INVALID_PAR_VAL;
807 RLOG0(L_ERROR, "unsupported Selector value for CRG");
810 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
812 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
814 upSapCfg = &rgCb[inst].crgSap.sapCfg;
816 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
817 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
818 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
819 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
820 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
821 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
822 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
823 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
824 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
825 upSapCfg->sapPst.route = cfg->s.crgSap.route;
826 upSapCfg->sapPst.intfVer = 0;
827 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
828 upSapCfg->suId = cfg->s.crgSap.suId;
829 upSapCfg->spId = cfg->s.crgSap.spId;
833 if ((cfg->s.tfuSap.selector != TFU_SEL_TC) &&
834 (cfg->s.tfuSap.selector != TFU_SEL_LC))
836 ret = LCM_REASON_INVALID_PAR_VAL;
837 RLOG0(L_ERROR, "unsupported Selector value for TFU");
841 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
843 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
845 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
847 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
848 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
849 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
850 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
851 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
852 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
853 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
854 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
855 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
856 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
857 lowSapCfg->sapPst.intfVer = 0;
858 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
859 lowSapCfg->suId = cfg->s.tfuSap.suId;
860 lowSapCfg->spId = cfg->s.tfuSap.spId;
861 cmMemcpy((U8 *)&lowSapCfg->bndTmr, (U8 *)&cfg->s.tfuSap.bndTmr,
865 /* would never reach here */
873 * @brief General Configuration Handler.
877 * Function : rgLMMGenCfg
879 * This function in called by RgMiLrgCfgReq(). It handles the
880 * general configuration of the LTE MAC layer. It initializes
881 * the hash lists of RgCb. Returns
882 * reason for success/failure of this function.
884 * @param[in] Inst inst
885 * @param[in] RgCfg *cfg, the Configuaration information
887 * -# LCM_REASON_NOT_APPL
888 * -# LCM_REASON_INVALID_MSGTYPE
889 * -# LCM_REASON_MEM_NOAVAIL
892 PRIVATE U16 rgLMMGenCfg
895 RgCfg *cfg /* Configuaration information */
898 PRIVATE U16 rgLMMGenCfg(inst,cfg)
900 RgCfg *cfg; /* Configuaration information */
903 U16 ret = LCM_REASON_NOT_APPL;
907 /* Check if General Configuration is done already */
908 if (rgCb[inst].rgInit.cfgDone == TRUE)
910 RETVALUE(LCM_REASON_INVALID_MSGTYPE);
912 if ((cfg->s.genCfg.lmPst.selector != LRG_SEL_TC) &&
913 (cfg->s.genCfg.lmPst.selector != LRG_SEL_LC))
915 RLOG0(L_ERROR, "unsupported Selector value for RGU");
916 RETVALUE(LCM_REASON_INVALID_PAR_VAL);
918 /* Update the Pst structure for LM interface */
919 cmMemcpy((U8 *)&rgCb[inst].rgInit.lmPst, (U8 *)&cfg->s.genCfg.lmPst,
922 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
923 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
924 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
925 rgCb[inst].rgInit.lmPst.event = EVTNONE;
927 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
928 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
929 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
930 /* Initialize SAP States */
931 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
933 if(cfg->s.genCfg.numRguSaps == 0)
935 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Invalid numRguSap.\n"));
939 /* allocate RGR saps */
940 if (SGetSBuf(rgCb[inst].rgInit.region,
941 rgCb[inst].rgInit.pool,
942 (Data **)&rgCb[inst].rguSap,
943 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
945 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Failed to allocate mem for RGU SAP's.\n"));
948 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
950 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
952 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
953 cmMemset((U8 *)&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
955 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
956 /* Initialize the timer blocks */
957 cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
958 /* Initialzie the timer queue */
959 cmMemset((U8 *)&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
960 /* Initialize the timer control point */
961 cmMemset((U8 *)&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
962 rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
963 /* Timer Registration request to SSI */
964 if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
965 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
968 RLOG0(L_ERROR, "Failed to register timer");
970 SPutSBuf(rgCb[inst].rgInit.region,
971 rgCb[inst].rgInit.pool,
972 (Data *)rgCb[inst].rguSap,
973 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
975 RETVALUE(LCM_REASON_MEM_NOAVAIL);
977 /* Set Config done in TskInit */
978 rgCb[inst].rgInit.cfgDone = TRUE;
984 /***********************************************************
986 * Func : rgLMMShutdown
989 * Desc : Handles the MAC layer shutdown request. Calls
990 * rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
999 **********************************************************/
1001 PRIVATE Void rgLMMShutdown
1006 PRIVATE Void rgLMMShutdown(inst)
1010 RgCellCb *cell = rgCb[inst].cell;
1015 /* Unbind the TFU Sap */
1016 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
1018 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1019 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1021 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1023 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1025 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
1027 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1028 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1034 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1036 rgTOMRlsSf(inst,&cell->subFrms[idx]);
1039 rgCFGFreeCellCb(cell);
1042 /* Deleting the RGU SAPs */
1043 SPutSBuf(rgCb[inst].rgInit.region,
1044 rgCb[inst].rgInit.pool,
1045 (Data *)rgCb[inst].rguSap,
1046 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
1047 rgCb[inst].rguSap = NULLP;
1049 rgCb[inst].inactiveCell = NULLP;
1050 rgCb[inst].cell = NULLP;
1052 /* De-register the Timer Service */
1053 (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
1054 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr);
1056 /* call back the task initialization function to intialize
1057 * the global RgCb Struct */
1058 rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region,
1059 rgCb[inst].rgInit.reason);
1065 /***********************************************************
1067 * Func : rgLMMGenCntrl
1070 * Desc : Processes the LM control request for STGEN elmnt.
1079 **********************************************************/
1081 PRIVATE Void rgLMMGenCntrl
1088 PRIVATE Void rgLMMGenCntrl(cntrl, cfm, cfmPst)
1094 Inst inst = (cfmPst->srcInst - RG_INST_START);
1097 cfm->cfm.status = LCM_PRIM_OK;
1098 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1101 switch(cntrl->t.cntrl.action)
1104 /* Action is Enable */
1105 switch(cntrl->t.cntrl.subAction)
1109 rgCb[inst].rgInit.trc = TRUE;
1110 rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1111 /*Store the response and TransId for sending the Traces */
1112 cmMemcpy((U8 *)&rgCb[inst].genCfg.trcResp.response,
1113 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1114 rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1118 /* Enable Unsolicited Status (alarms) */
1119 rgCb[inst].rgInit.usta = TRUE;
1120 /*Store the response and TransId for sending the Alarms */
1121 cmMemcpy((U8 *)&rgCb[inst].genCfg.ustaResp.response,
1122 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1123 rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1126 /* Enable Debug Printing */
1128 rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1133 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1138 cfm->cfm.status = LCM_PRIM_NOK;
1139 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1140 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1145 /* Action is Diable immidiately */
1146 switch(cntrl->t.cntrl.subAction)
1149 /* Disable Traces */
1150 rgCb[inst].rgInit.trc = FALSE;
1153 /* Disable Unsolicited Status (alarms) */
1154 rgCb[inst].rgInit.usta = FALSE;
1157 /* Disable Debug Printing */
1159 rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1164 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1169 cfm->cfm.status = LCM_PRIM_NOK;
1170 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1171 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1176 /* Free all the memory dynamically allocated by MAC */
1177 rgLMMShutdown(inst);
1180 cfm->cfm.status = LCM_PRIM_NOK;
1181 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1182 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1185 RgMiLrgCntrlCfm(cfmPst, cfm);
1190 /***********************************************************
1192 * Func : rgLMMSapCntrl
1195 * Desc : Processes the LM control request for STxxxSAP elmnt.
1204 **********************************************************/
1206 PRIVATE Void rgLMMSapCntrl
1213 PRIVATE Void rgLMMSapCntrl(cntrl, cfm, cfmPst)
1219 Inst inst = cfmPst->srcInst - RG_INST_START;
1222 /* Only TFU Sap can be controlled by LM */
1223 switch(cntrl->hdr.elmId.elmnt)
1226 switch(cntrl->t.cntrl.action)
1229 /* Bind Enable Request */
1230 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1231 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1233 cfm->cfm.status = LCM_PRIM_NOK;
1234 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1238 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1240 rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val,
1241 (PTR)&rgCb[inst].tfuSap);
1243 /* Change SAP state */
1244 rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1245 rgCb[inst].tfuSap.numBndRetries++;
1246 /* Store the response and TransId for sending
1247 * the Control confirm */
1248 cmMemcpy((U8 *)&rgCb[inst].genCfg.bndCfmResp.response,
1249 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1250 rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1252 /* Sending Status Indication to Layer Manager */
1253 cfm->cfm.status = LCM_PRIM_OK_NDONE;
1254 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1255 RgMiLrgCntrlCfm(cfmPst, cfm);
1257 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1258 rgCb[inst].tfuSap.sapCfg.spId);
1263 /* Unbind request */
1265 /* Check if the SAP is configured */
1266 if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1267 (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1269 cfm->cfm.status = LCM_PRIM_NOK;
1270 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1274 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1275 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1277 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1279 /* Change SAP state */
1280 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1281 cfm->cfm.status = LCM_PRIM_OK;
1282 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1286 /* Delete SAP, does initialization of SAP */
1287 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1288 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1290 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1291 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1293 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1296 cmMemset((U8 *)&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1297 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1298 cfm->cfm.status = LCM_PRIM_OK;
1299 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1302 cfm->cfm.status = LCM_PRIM_NOK;
1303 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1304 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1305 cntrl->t.cntrl.action));
1310 switch(cntrl->t.cntrl.action)
1313 cmMemset((U8 *)&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1314 rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1315 cfm->cfm.status = LCM_PRIM_OK;
1316 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1319 cfm->cfm.status = LCM_PRIM_NOK;
1320 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1321 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1322 cntrl->t.cntrl.action));
1327 switch(cntrl->t.cntrl.action)
1330 cmMemset((U8 *)&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1331 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1332 cfm->cfm.status = LCM_PRIM_OK;
1333 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1336 cfm->cfm.status = LCM_PRIM_NOK;
1337 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1338 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1344 /* Would never here. */
1347 RgMiLrgCntrlCfm(cfmPst, cfm);
1352 /***********************************************************
1354 * Func : rgLMMFillCfmPst
1357 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
1358 * and the cfm->hdr.response.
1367 **********************************************************/
1369 PRIVATE Void rgLMMFillCfmPst
1376 PRIVATE Void rgLMMFillCfmPst(reqPst, cfmPst, cfm)
1383 TRC2(rgLMMFillCfmPst)
1384 inst = (reqPst->dstInst - RG_INST_START);
1386 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
1387 cfmPst->srcInst = rgCb[inst].rgInit.inst;
1388 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1389 cfmPst->dstEnt = reqPst->srcEnt;
1390 cfmPst->dstInst = reqPst->srcInst;
1391 cfmPst->dstProcId = reqPst->srcProcId;
1393 cfmPst->selector = cfm->hdr.response.selector;
1394 cfmPst->prior = cfm->hdr.response.prior;
1395 cfmPst->route = cfm->hdr.response.route;
1396 cfmPst->region = cfm->hdr.response.mem.region;
1397 cfmPst->pool = cfm->hdr.response.mem.pool;
1404 * @brief Timer start handler.
1408 * Function : rgLMMStartTmr
1410 * This function based on the input parameters starts the timer for
1411 * "tmrVal" duration. As of now MAC uses the timer functionality for
1412 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1414 * @param[in] Inst inst
1415 * @param[in] S16 tmrEvnt, the Timer Event
1416 * @param[in] U32 tmrVal, the Wait Time
1417 * @param[in] PTR cb, Entry for which Timer expired
1422 PUBLIC S16 rgLMMStartTmr
1425 S16 tmrEvnt, /* Timer Event */
1426 U32 tmrVal, /* Wait Time */
1427 PTR cb /* Entry for which Timer Expired */
1430 PUBLIC S16 rgLMMStartTmr(tmrEvnt, tmrVal, cb)
1432 S16 tmrEvnt; /* Timer Event */
1433 U32 tmrVal; /* Wait Time */
1434 PTR cb; /* Entry for which Timer Expired */
1443 /* Initialize the arg structure */
1444 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1446 arg.tqCp = &rgCb[inst].tmrTqCp;
1447 arg.tq = rgCb[inst].tmrTq;
1448 arg.timers = rgCb[inst].tmrBlk;
1451 arg.max = RG_MAX_TIMER;
1452 arg.evnt = RG_BNDREQ_TMR;
1461 * @brief Timer stop handler.
1465 * Function : rgLMMStopTmr
1467 * This function based on the input parameters stops the timer for
1468 * "tmrEvnt". As of now MAC uses the timer functionality for
1469 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1470 * Once the bind happens and this timer is stopped, the timer functionality
1471 * is deregistered with SSI. As there is no further use of timer processing.
1473 * @param[in] Inst inst
1474 * @param[in] S16 tmrEvnt, the Timer Event
1475 * @param[in] PTR cb, Entry for which Timer expired
1481 PUBLIC S16 rgLMMStopTmr
1483 Inst inst, /* Scheduler instance */
1484 S16 tmrEvnt, /* Timer Event */
1485 PTR cb /* Entry for which Timer Expired */
1488 PUBLIC S16 rgLMMStopTmr(inst,tmrEvnt, cb)
1489 Inst inst; /* Scheduler instance */
1490 S16 tmrEvnt; /* Timer Event */
1491 PTR cb; /* Entry for which Timer Expired */
1502 for(i=0;i<RG_MAX_TIMER;i++)
1504 /* Search for the Timer Blocks */
1505 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1507 /* Initialize the arg structure */
1508 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1510 arg.tqCp = &rgCb[inst].tmrTqCp;
1511 arg.tq = rgCb[inst].tmrTq;
1512 arg.timers = rgCb[inst].tmrBlk;
1514 arg.max = RG_MAX_TIMER;
1532 * @brief Timer Expiry handler.
1536 * Function : rgLMMTmrExpiry
1538 * This is a callback function used as an input parameter to cmPrcTmr()
1539 * to check expiry of any timer. In this function, the only concern is
1540 * about tmrEvnt=Bind timer.
1542 * @param[in] PTR cb, Entry for which Timer expired
1543 * @param[in] S16 tmrEvnt, the Timer Event
1548 PUBLIC S16 rgLMMTmrExpiry
1550 PTR cb, /* Pointer to timer control block */
1551 S16 tmrEvnt /* Timer Event */
1554 PUBLIC S16 rgLMMTmrExpiry(cb,tmrEvnt)
1555 PTR cb; /* Pointer to timer control block */
1556 S16 tmrEvnt; /* Timer Event */
1560 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1561 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1563 TRC2(rgLMMTmrExpiry)
1569 tfuSap->numBndRetries++;
1570 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1572 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1573 LCM_CAUSE_TMR_EXPIRED, NULLP);
1577 /* Restart the bind timer */
1578 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1580 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1584 /* Send bind request */
1585 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1586 rgCb[inst].tfuSap.sapCfg.spId);
1590 RLOG1(L_ERROR, "Invalid tmrEvnt=%d",tmrEvnt);
1600 * @brief Layer Manager Unsolicited Status Indication generation.
1604 * Function : rgLMMStaInd
1606 * This API is used by the other modules of MAC to send a unsolicited
1607 * status indication to the Layer Manager.
1609 * @param[in] Inst inst
1610 * @param[in] U16 category, the Alarm category
1611 * @param[in] U16 event, the Alarm event
1612 * @param[in] U16 cause, the cause of the Alarm
1613 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1618 PUBLIC S16 rgLMMStaInd
1627 PUBLIC S16 rgLMMStaInd(inst,category, event, cause, dgn)
1639 if(rgCb[inst].rgInit.usta == FALSE)
1644 cmMemset((U8 *)&usta, 0, sizeof(RgMngmt));
1646 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1647 usta.t.usta.cmAlarm.category = category;
1648 usta.t.usta.cmAlarm.event = event;
1649 usta.t.usta.cmAlarm.cause = cause;
1652 cmMemcpy((U8 *)&usta.t.usta.dgn, (U8 *)dgn, sizeof(RgUstaDgn));
1655 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1656 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1657 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1658 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1659 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1660 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1662 RETVALUE(RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1667 * @brief Layer Manager Trace Indication generation.
1671 * Function : rgLMMTrcInd
1673 * This API is used by the other modules of MAC to send a
1674 * Trace indication to the Layer Manager.
1676 * @param[in] Inst inst
1677 * @param[in] Buffer *srcMbuf, the Message Buffer .
1678 * @param[in] U8 event, the trace event.
1682 PUBLIC Void rgLMMTrcInd
1685 Buffer *srcMbuf, /* Message Buffer */
1686 U8 event /* event */
1689 PUBLIC Void rgLMMTrcInd(inst,srcMbuf,event)
1691 Buffer *srcMbuf; /* Message Buffer */
1692 U8 event; /* event */
1695 Buffer *dstMbuf = NULLP;
1705 if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1707 RLOG0(L_ERROR, "Trace Disabled.");
1711 cmMemset((U8 *)&trc, 0, sizeof(RgMngmt));
1713 pst = rgCb[inst].rgInit.lmPst;
1714 pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1715 pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1716 pst.route = rgCb[inst].genCfg.trcResp.response.route;
1717 pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1718 pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1720 trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1722 SGetDateTime(&trc.t.trc.dt);
1724 /* Check if the whole buffer is to be sent in Trace indication */
1725 if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1727 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1730 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1733 trc.cfm.status = LCM_PRIM_OK;
1734 trc.cfm.reason = LCM_REASON_NOT_APPL;
1735 trc.t.trc.evnt = event;
1737 /* Send Trace Indication to Layer manager */
1738 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1740 /* check if only a specified number of bytes are to be sent */
1741 else if(rgCb[inst].trcLen > 0)
1743 /* Get the length of the recvd message buffer */
1744 if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1746 RLOG0(L_ERROR, "SFndLenMsg Failed.");
1749 /* Check if the recvd buffer size is less than request trace len */
1750 if(bufLen < rgCb[inst].trcLen)
1752 /* Copy the whole of the recvd buffer in trace indication */
1754 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1757 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1761 trc.cfm.status = LCM_PRIM_OK;
1762 trc.cfm.reason = LCM_REASON_NOT_APPL;
1763 trc.t.trc.evnt = event;
1765 /* Send Trace Indication to Layer manager */
1766 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1768 /* if the recvd buffer size is greater than request trace len */
1769 if(bufLen >= rgCb[inst].trcLen)
1771 /* Get a temporary buffer to store the msg */
1772 if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1774 RLOG0(L_ERROR, "rgAllocSBuf Failed.");
1778 /* Copy trcLen nos of bytes from the recvd message */
1779 if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)
1781 RLOG0(L_ERROR, "SCpyMsgFix Failed.");
1785 if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1787 RLOG0(L_ERROR, "dstMbuf Allocation Failed");
1790 /* Copy the tempBuf data to dst mBuf */
1791 if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1793 RLOG0(L_ERROR, "SCpyFixMsg Failed.");
1797 /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1799 /* Free the memory allocated for tempBuf */
1800 rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1802 trc.cfm.status = LCM_PRIM_OK;
1803 trc.cfm.reason = LCM_REASON_NOT_APPL;
1804 trc.t.trc.evnt = event;
1806 /* Send Trace Indication to Layer manager */
1807 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1815 * @brief Layer Manager Control Confirm generation handler
1816 * for Bind Confirm reception at TFU interface.
1817 * RgLiTfuBndCfm() forwards the confirmation to this
1818 * function. All SAP state related handling is restricted
1819 * to LMM modules, hence the cfm forwarding.
1823 * Function : rgLMMBndCfm
1825 * This API is used by the LIM module of MAC to forward
1826 * the Bind Confirm it receives over the TFU interface.
1828 * @param[in] Pst *pst, Post Structure
1829 * @param[in] SuId suId, Service user ID
1830 * @param[in] U8 status, Status
1835 PUBLIC S16 rgLMMBndCfm
1837 Pst *pst, /* Post Structure */
1838 SuId suId, /* Service user ID */
1839 U8 status /* Status */
1842 PUBLIC S16 rgLMMBndCfm(pst,suId,status)
1843 Pst *pst; /* Post Structure */
1844 SuId suId; /* Service user ID */
1845 U8 status; /* Status */
1848 Inst inst = pst->dstInst - RG_INST_START;
1857 /* Check if the suId is valid */
1858 if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1860 RLOG0(L_ERROR, "Invalid SuId");
1864 /* check the Sap State */
1865 switch(rgCb[inst].tfuSap.sapSta.sapState)
1867 case LRG_WAIT_BNDCFM:
1870 /* SAP is already bound */
1876 cfmPst = rgCb[inst].rgInit.lmPst;
1877 cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1878 cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1879 cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1880 cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1881 cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1883 cmMemset((U8 *)&cntrlCfm, 0, sizeof(RgMngmt));
1887 case CM_BND_OK: /* status is OK */
1888 /* Change SAP state to Bound */
1889 rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1890 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1892 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1894 /* Send Control Confirm with status as OK to Layer Manager */
1895 cntrlCfm.cfm.status = LCM_PRIM_OK;
1896 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1900 /* Change SAP state to UnBound */
1901 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1902 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1904 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1906 /* Send Control Confirm with status as NOK to Layer Manager */
1907 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1908 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1911 rgCb[inst].tfuSap.numBndRetries = 0;
1912 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1913 cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1915 ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1922 * @brief LTE MAC timer call back function registered with SSI.
1926 * Function : rgActvTmr
1928 * This function is invoked by SSI for every timer activation
1935 PUBLIC S16 rgActvTmr
1941 PUBLIC S16 rgActvTmr(ent, inst)
1946 Inst macInst = (inst - RG_INST_START);
1949 /* Check if any MAC timer has expired */
1950 cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1954 } /* end of rgActvTmr */
1957 * @brief Layer Manager Configuration request handler for Scheduler
1961 * Function : MacSchGenCfgReq
1963 * This function receives general configurations for Scheduler
1964 * from DU APP and forwards to Scheduler.
1966 * @param[in] Pst *pst, the post structure
1967 * @param[in] RgMngmt *cfg, the configuration parameter's structure
1972 PUBLIC S16 MacSchGenCfgReq
1974 Pst *pst, /* post structure */
1975 RgMngmt *cfg /* config structure */
1978 PUBLIC S16 MacSchGenCfgReq(pst, cfg)
1979 Pst *pst; /* post structure */
1980 RgMngmt *cfg; /* config structure */
1983 printf("\nReceived Scheduler gen config at MAC");
1984 pst->dstInst = DEFAULT_CELLS + 1;
1985 HandleSchGenCfgReq(pst, cfg);
1991 * @brief Layer Manager Configuration response from Scheduler
1995 * Function : SchSendCfgCfm
1997 * This function sends general configurations response from
1998 * Scheduler to DU APP.
2000 * @param[in] Pst *pst, the post structure
2001 * @param[in] RgMngmt *cfm, the configuration confirm structure
2006 PUBLIC S16 SchSendCfgCfm
2008 Pst *pst, /* post structure */
2009 RgMngmt *cfm /* config confirm structure */
2012 PUBLIC S16 SchSendCfgCfm(pst, cfm)
2013 Pst *pst; /* post structure */
2014 RgMngmt *cfm; /* config confirm structure */
2017 printf("\nSending Scheduler config confirm to DU APP");
2018 RgMiLrgSchCfgCfm(pst, cfm);
2024 * @brief Layer Manager Configuration request handler.
2028 * Function : MacSchCfgReq
2030 * This function handles the gNB and cell configuration
2031 * request received from DU APP.
2032 * This API unapcks and forwards the config towards SCH
2034 * @param[in] Pst *pst
2035 * @param[in] RgrCfgTransId transId
2036 * @param[in] RgrCfgReqInfo *cfgReqInfo
2041 PUBLIC S16 MacSchCfgReq
2044 RgrCfgTransId transId,
2045 RgrCfgReqInfo *cfgReqInfo
2048 PUBLIC S16 MacSchCfgReq(pst, transId, cfgReqInfo)
2050 RgrCfgTransId transId;
2051 RgrCfgReqInfo *cfgReqInfo;
2054 printf("\nReceived Scheduler config at MAC");
2055 pst->dstInst = DEFAULT_CELLS + 1;
2056 HandleSchCfgReq(pst, transId, cfgReqInfo);
2060 } /* end of MacSchCfgReq*/
2063 /***********************************************************
2065 * Func : macCellCfgFillCfmPst
2068 * Desc : Fills the Confirmation Post Structure cfmPst
2076 **********************************************************/
2077 Void macCellCfgFillCfmPst
2084 inst = reqPst->dstInst;
2086 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
2087 cfmPst->srcInst = rgCb[inst].rgInit.inst;
2088 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
2090 cfmPst->srcEnt = reqPst->dstEnt;
2091 cfmPst->dstEnt = reqPst->srcEnt;
2092 cfmPst->srcInst = reqPst->dstInst;
2093 cfmPst->dstInst = reqPst->srcInst;
2094 cfmPst->srcProcId = reqPst->dstProcId;
2095 cfmPst->dstProcId = reqPst->srcProcId;
2097 cfmPst->selector = LRG_SEL_LC;
2098 cfmPst->prior = reqPst->prior;
2099 cfmPst->route = reqPst->route;
2100 cfmPst->region = reqPst->region;
2101 cfmPst->pool = reqPst->pool;
2102 cfmPst->event = EVENT_MAC_CELL_CONFIG_CFM;
2108 * @brief Layer Manager Configuration request handler.
2112 * Function : MacHdlCellCfgReq
2114 * This function handles the gNB and cell configuration
2115 * request received from DU APP.
2116 * This API unapcks and forwards the config towards SCH
2118 * @param[in] Pst *pst
2119 * @param[in] MacCellCfg *macCellCfg
2123 S16 MacHdlCellCfgReq
2126 MacCellCfg *macCellCfg
2130 MacCellCfgCfm macCellCfgCfm;
2133 Inst inst = pst->dstInst;
2135 cellCb = rgCb[inst].cell;
2136 memcpy(&cellCb->macCellCfg,macCellCfg,sizeof(MacCellCfg));
2138 macCellCfgFillCfmPst(pst,&cnfPst);
2140 macCellCfgCfm.transId = macCellCfg->transId;
2142 ret = (*packMacCellCfmOpts[cnfPst.selector])(&cnfPst,&macCellCfgCfm);
2144 } /* end of MacHdlCellCfgReq */
2147 /**********************************************************************
2150 **********************************************************************/