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 */
62 /* header/extern include files (.x) */
63 #include "gen.x" /* general */
64 #include "ssi.x" /* system services */
65 #include "cm5.x" /* system services */
66 #include "cm_tkns.x" /* Common Token Definitions */
67 #include "cm_llist.x" /* Common Link List Definitions */
68 #include "cm_lib.x" /* Common Library Definitions */
69 #include "cm_hash.x" /* Common Hash List Definitions */
70 #include "cm_mblk.x" /* common memory link list library */
71 #include "cm_lte.x" /* Common LTE Defines */
72 #include "crg.x" /* CRG Interface includes */
73 #include "rgu.x" /* RGU Interface includes */
74 #include "tfu.x" /* RGU Interface includes */
75 #include "rg_sch_inf.x" /* SCH Interface includes */
76 #include "rg_prg.x" /* PRG Interface includes */
77 #include "lrg.x" /* LRG Interface includes */
78 #include "rgr.x" /* LRG Interface includes */
79 #include "du_app_mac_inf.h"
80 #include "rg.x" /* MAC includes */
82 #include "ss_diag.h" /* Common log file */
87 #include "lwr_mac.h" /* MAC CL defines */
91 #endif /* __cplusplus */
92 EXTERN Void rgGetSId ARGS((SystemId *s));
95 #endif /* __cplusplus */
97 /* Public variable declaration */
100 /* forward references */
101 PRIVATE U16 rgLMMGenCfg ARGS((
106 PRIVATE U16 rgLMMSapCfg ARGS((
112 PRIVATE Void rgLMMShutdown ARGS((
116 PRIVATE Void rgLMMFillCfmPst ARGS((
122 PRIVATE Void rgLMMGenCntrl ARGS((
128 PRIVATE Void rgLMMSapCntrl ARGS((
134 extern U16 packMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm);
136 packMacCellCfgConfirm packMacCellCfmOpts[] =
138 packMacCellCfgCfm, /* packing for loosely coupled */
139 duHandleMacCellCfgCfm, /* packing for tightly coupled */
140 packMacCellCfgCfm, /* packing for light weight loosly coupled */
143 SchCellCfgFunc SchCellCfgOpts[] =
145 packSchCellCfg, /* packing for loosely coupled */
146 SchHdlCellCfgReq, /* packing for tightly coupled */
147 packSchCellCfg /* packing for light weight loosly coupled */
152 * @brief Task Initiation callback function.
156 * Function : rgActvInit
158 * This function is supplied as one of parameters during MAC's
159 * task registration. SSI will invoke this function once, after
160 * it creates and attaches this TAPA Task to a system task.
162 * @param[in] Ent entity, the entity ID of this task.
163 * @param[in] Inst inst, the instance ID of this task.
164 * @param[in] Region region, the region ID registered for memory
165 * usage of this task.
166 * @param[in] Reason reason.
171 PUBLIC S16 rgActvInit
173 Ent entity, /* entity */
174 Inst inst, /* instance */
175 Region region, /* region */
176 Reason reason /* reason */
179 PUBLIC S16 rgActvInit(entity, inst, region, reason)
180 Ent entity; /* entity */
181 Inst inst; /* instance */
182 Region region; /* region */
183 Reason reason; /* reason */
189 RG_IS_INST_VALID(inst);
191 macInst = inst - RG_INST_START;
192 /* Initialize the MAC TskInit structure to zero */
193 cmMemset ((U8 *)&rgCb[macInst], 0, sizeof(RgCb));
195 /* Initialize the MAC TskInit with received values */
196 rgCb[macInst].rgInit.ent = entity;
197 rgCb[macInst].rgInit.inst = inst;
198 rgCb[macInst].rgInit.region = region;
199 rgCb[macInst].rgInit.pool = 0;
200 rgCb[macInst].rgInit.reason = reason;
201 rgCb[macInst].rgInit.cfgDone = FALSE;
202 rgCb[macInst].rgInit.acnt = FALSE;
203 rgCb[macInst].rgInit.usta = FALSE;
204 rgCb[macInst].rgInit.trc = FALSE;
205 rgCb[macInst].trcLen = 0;
208 /* disabling debugs by default */
209 rgCb[macInst].rgInit.dbgMask = 0xffffffff;
213 rgCb[macInst].rgInit.logMask = 0x0;
215 rgCb[macInst].rgInit.procId = SFndProcId();
216 rgCb[macInst].tfuSap.numBndRetries = 0;
218 /* Initialize Sap state */
219 rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
220 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
221 rgCb[macInst].rguSap = NULLP;
222 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
224 rgCb[macInst].inactiveCell = NULLP;
225 rgCb[macInst].cell = NULLP;
227 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
228 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
231 /* Initializing CL control block */
232 clGlobalCp.region = region;
234 clGlobalCp.clCfgDone = FALSE;
235 clGlobalCp.numOfCells = 0;
236 clGlobalCp.phyState = PHY_STATE_IDLE;
238 if( cmHashListInit(&clGlobalCp.cellCbLst, MAX_NUM_CELL_SUPP, 0x0, FALSE,
239 CM_HASH_KEYTYPE_DEF, clGlobalCp.region, clGlobalCp.pool ) != ROK )
241 printf("\n Cellcb hash list initialization failed for MAC CL");
245 /* Initialize Scheduler as well */
246 schActvInit(ENTRG, (DEFAULT_CELLS + SCH_INST_START), DFLT_REGION, PWR_UP);
253 * @brief Layer Manager Configuration request handler.
257 * Function : RgMiLrgCfgReq
259 * This function handles the configuration
260 * request received from the Layer Manager.
261 * -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
262 * functions rgHdlGenCfg() or rgHdlSapCfg().
263 * -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
265 * @param[in] Pst *pst, the post structure
266 * @param[in] RgMngmt *cfg, the configuration parameter's structure
271 PUBLIC S16 RgMiLrgCfgReq
273 Pst *pst, /* post structure */
274 RgMngmt *cfg /* config structure */
277 PUBLIC S16 RgMiLrgCfgReq(pst, cfg)
278 Pst *pst; /* post structure */
279 RgMngmt *cfg; /* config structure */
282 U16 ret = LCM_PRIM_OK;
283 U16 reason = LCM_REASON_NOT_APPL;
291 RG_DIAG_LVL0(inst,0x0a0b0001, RG_DIAG_NA, SS_DIAG_INV_ARG,
292 "Received CfgReq for MAC layer, Entity = %d, Instance = %d\n",
293 pst->srcEnt, pst->srcInst,0,0);
295 RG_IS_INST_VALID(pst->dstInst);
296 inst = pst->dstInst - RG_INST_START;
298 /* Fill the post structure for sending the confirmation */
299 rgLMMFillCfmPst(pst, &cfmPst, cfg);
301 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
304 cfm.hdr.transId = cfg->hdr.transId;
308 cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
309 switch(cfg->hdr.elmId.elmnt)
312 reason = rgLMMGenCfg(inst,&cfg->t.cfg);
317 reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
321 reason = LCM_REASON_INVALID_ELMNT;
322 RLOG1(L_ERROR, "Invalid Elmnt=%d",
323 cfg->hdr.elmId.elmnt);
327 if (reason != LCM_REASON_NOT_APPL)
332 cfm.cfm.status = ret;
333 cfm.cfm.reason = reason;
335 RgMiLrgCfgCfm(&cfmPst, &cfm);
338 }/*-- RgMiLrgCfgReq --*/
342 * @brief Layer Manager Statistics request handler.
346 * Function : RgMiLrgStsReq
348 * This function handles the statistics
349 * request received from the Layer Manager.
350 * -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
351 * statistics from the rgCb global control block.
352 * -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
353 * -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
355 * @param[in] Pst *pst, the post structure
356 * @param[in] RgMngmt *sts, the statistics parameter's structure
361 PUBLIC S16 RgMiLrgStsReq
363 Pst *pst, /* post structure */
364 RgMngmt *sts /* statistics structure */
367 PUBLIC S16 RgMiLrgStsReq(pst, sts)
368 Pst *pst; /* post structure */
369 RgMngmt *sts; /* statistics structure */
379 RG_IS_INST_VALID(pst->dstInst);
380 inst = pst->dstInst - RG_INST_START;
381 /* Fill the post structure for sending the confirmation */
382 rgLMMFillCfmPst(pst, &cfmPst, sts);
384 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
387 cfm.hdr.transId = sts->hdr.transId;
389 SGetDateTime(&cfm.t.sts.dt);
390 cfm.cfm.status = LCM_PRIM_OK;
391 cfm.cfm.reason = LCM_REASON_NOT_APPL;
392 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
393 cfm.t.sts.action = sts->t.sts.action;
395 /* Check if General Config Done */
396 if(rgCb[inst].rgInit.cfgDone != TRUE)
398 cfm.cfm.status = LCM_PRIM_NOK;
399 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
400 RgMiLrgStsCfm(&cfmPst,&cfm);
401 RLOG0(L_ERROR, "Gen Cfg not done");
405 switch(sts->hdr.elmId.elmnt)
409 cmMemcpy((U8 *)&(cfm.t.sts.s.genSts), (U8 *)&rgCb[inst].genSts,
411 /* check if action is read and reset */
412 if(sts->t.sts.action == ARST)
414 rgCb[inst].genSts.numHarqFail = 0;
419 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
421 for(cqi=0; cqi <= 14; cqi++)
423 /* Filling DL ACK/NACK stats */
424 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
425 hqFailStats.dlCqiStat[cqi].mcs;
426 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
427 hqFailStats.dlCqiStat[cqi].numOfNacks;
428 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
429 hqFailStats.dlCqiStat[cqi].numOfAcks;
431 /* Filling UL ACK/NACK stats */
432 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
433 hqFailStats.ulCqiStat[cqi].mcs;
434 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
435 hqFailStats.ulCqiStat[cqi].numOfNacks;
436 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
437 hqFailStats.ulCqiStat[cqi].numOfAcks;
439 /* Filling DL HQ Retx stats */
440 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
441 hqRetxStats.dlCqiStat[cqi].mcs;
442 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
443 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
444 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
445 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
446 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
447 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
448 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
449 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
450 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
451 hqRetxStats.dlCqiStat[cqi].totalTx;
453 /* Filling UL HQ Retx stats */
454 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
455 hqRetxStats.ulCqiStat[cqi].mcs;
456 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
457 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
458 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
459 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
460 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
461 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
462 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
463 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
464 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
465 hqRetxStats.ulCqiStat[cqi].totalTx;
467 /* Reset statistics */
468 if(sts->t.sts.action == ZEROSTS)
470 cmMemset((U8 *)&hqRetxStats, 0, \
471 sizeof(RgSchHqRetxStats));
472 cmMemset((U8 *)&hqFailStats, 0, \
473 sizeof(RgSchNackAckStats));
476 #endif /* MAC_SCH_STATS*/
480 cmMemcpy((U8 *)&(cfm.t.sts.s.rguSts), (U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
483 /* check if action is read and reset */
484 if(sts->t.sts.action == ARST)
485 cmMemset((U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
489 cmMemcpy((U8 *)&(cfm.t.sts.s.crgSts), (U8 *)&rgCb[inst].crgSap.sapSts,
492 /* check if action is read and reset */
493 if(sts->t.sts.action == ARST)
494 cmMemset((U8 *)&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
498 cmMemcpy((U8 *)&(cfm.t.sts.s.tfuSts), (U8 *)&rgCb[inst].tfuSap.sapSts,
501 /* check if action is read and reset */
502 if(sts->t.sts.action == ARST)
503 cmMemset((U8 *)&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
507 cfm.cfm.status = LCM_PRIM_NOK;
508 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
509 RLOG1(L_ERROR, "Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
512 RgMiLrgStsCfm(&cfmPst,&cfm);
514 }/*-- RgMiLrgStsReq --*/
518 * @brief Layer Manager Status request handler.
522 * Function : RgMiLrgStaReq
524 * This function handles the solicited status
525 * request received from the Layer Manager.
526 * -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
527 * particular SAP from the rgCb global control block.
528 * -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
530 * @param[in] Pst *pst, the post structure
531 * @param[in] RgMngmt *sta, the status parameter's structure
536 PUBLIC S16 RgMiLrgStaReq
538 Pst *pst, /* post structure */
539 RgMngmt *sta /* status structure */
542 PUBLIC S16 RgMiLrgStaReq(pst, sta)
543 Pst *pst; /* post structure */
544 RgMngmt *sta; /* status structure */
554 RG_IS_INST_VALID(pst->dstInst);
555 inst = pst->dstInst - RG_INST_START;
558 /* Fill the post structure for sending the confirmation */
559 rgLMMFillCfmPst(pst, &cfmPst, sta);
561 if (sta->t.ssta.s.sysId.ptNmb != NULLP)
563 SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
566 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
567 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
570 cfm.hdr.transId = sta->hdr.transId;
572 /* Check if General Config Done */
573 if(rgCb[inst].rgInit.cfgDone != TRUE)
575 SGetDateTime(&cfm.t.ssta.dt);
576 if (SGetSBuf(cfmPst.region, cfmPst.pool,
577 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
580 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
583 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
584 rgGetSId(&cfm.t.ssta.s.sysId);
585 cfm.cfm.status = LCM_PRIM_NOK;
586 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
587 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
588 RgMiLrgStaCfm(&cfmPst, &cfm);
589 RLOG0(L_ERROR, "Gen Cfg not done");
593 switch(sta->hdr.elmId.elmnt)
596 SGetDateTime(&cfm.t.ssta.dt);
597 if (SGetSBuf(cfmPst.region, cfmPst.pool,
598 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
601 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
604 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
605 rgGetSId(&cfm.t.ssta.s.sysId);
606 cfm.cfm.status = LCM_PRIM_OK;
607 cfm.cfm.reason = LCM_REASON_NOT_APPL;
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.rguSapSta),
615 (U8 *)&rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
617 RgMiLrgStaCfm(&cfmPst, &cfm);
620 cfm.cfm.status = LCM_PRIM_OK;
621 cfm.cfm.reason = LCM_REASON_NOT_APPL;
622 SGetDateTime(&cfm.t.ssta.dt);
623 cmMemcpy((U8 *)&(cfm.t.ssta.s.crgSapSta), (U8 *)&rgCb[inst].crgSap.sapSta,
625 RgMiLrgStaCfm(&cfmPst, &cfm);
628 cfm.cfm.status = LCM_PRIM_OK;
629 cfm.cfm.reason = LCM_REASON_NOT_APPL;
630 SGetDateTime(&cfm.t.ssta.dt);
631 cmMemcpy((U8 *)&(cfm.t.ssta.s.tfuSapSta), (U8 *)&rgCb[inst].tfuSap.sapSta,
633 RgMiLrgStaCfm(&cfmPst, &cfm);
636 cfm.cfm.status = LCM_PRIM_NOK;
637 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
638 RgMiLrgStaCfm(&cfmPst, &cfm);
639 RLOG1(L_ERROR, "Invalid elmnt=%d",sta->hdr.elmId.elmnt);
643 }/*-- RgMiLrgStaReq --*/
647 * @brief Layer Manager Control request handler.
651 * Function : RgMiLrgCntrlReq
653 * This function handles the control
654 * request received from the Layer Manager.
655 * -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
656 * and cntrl->t.cntrl.subAction, it performs the appropriate control action
657 * of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
658 * and layer shutdown.
659 * -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
661 * @param[in] Pst *pst, the post structure
662 * @param[in] RgMngmt *cntrl, the control parameter's structure
667 PUBLIC S16 RgMiLrgCntrlReq
669 Pst *pst, /* post structure */
670 RgMngmt *cntrl /* control structure */
673 PUBLIC S16 RgMiLrgCntrlReq(pst, cntrl)
674 Pst *pst; /* post structure */
675 RgMngmt *cntrl; /* control structure */
678 S16 ret = ROK; /* return value */
683 TRC2(RgMiLrgCntrlReq)
685 /* Fill the post structure for sending the confirmation */
687 RG_IS_INST_VALID(pst->dstInst);
688 inst = pst->dstInst - RG_INST_START;
690 rgLMMFillCfmPst(pst, &cfmPst, cntrl);
692 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
694 cfm.hdr.transId = cntrl->hdr.transId;
696 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
697 cfm.t.cntrl.action = cntrl->t.cntrl.action;
698 cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
700 /* Check if General Config Done*/
701 if(rgCb[inst].rgInit.cfgDone != TRUE)
703 cfm.cfm.status = LCM_PRIM_NOK;
704 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
705 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
706 RgMiLrgCntrlCfm(&cfmPst, &cfm);
707 RLOG0(L_ERROR, "Gen Cfg not done");
711 /* General Config done, process the Control request */
712 switch(cntrl->hdr.elmId.elmnt)
715 rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
720 rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
723 cfm.cfm.status = LCM_PRIM_NOK;
724 cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
725 RgMiLrgCntrlCfm(&cfmPst, &cfm);
726 RLOG1(L_ERROR, "invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
730 }/*-- RgMiLrgCntrlReq --*/
734 * @brief SAP Configuration Handler.
738 * Function : rgLMMSapCfg
740 * This function in called by RgMiLrgCfgReq(). It handles the
741 * interface SAP configuration of the LTE MAC layer. It
742 * initializes the sapState to LRG_UNBND. Returns
743 * reason for success/failure of this function.
745 * @param[in] Inst inst
746 * @param[in] RgCfg *cfg, the Configuaration information
748 * -# LCM_REASON_GENCFG_NOT_DONE
749 * -# LCM_REASON_INVALID_SAP
750 * -# LCM_REASON_NOT_APPL
753 PRIVATE U16 rgLMMSapCfg
756 RgCfg *cfg, /* Configuaration information */
757 Elmnt sapType /* Sap Type */
760 PRIVATE U16 rgLMMSapCfg(inst,cfg,sapType)
762 RgCfg *cfg; /* Configuaration information */
763 Elmnt sapType; /* Sap Type */
766 U16 ret = LCM_REASON_NOT_APPL;
767 RgLowSapCfgInfo *lowSapCfg = NULLP;
768 RgUpSapCfgInfo *upSapCfg = NULLP;
769 RgUpSapCb *upSapCb = NULLP;
773 /* Check if Gen Config has been done */
774 if(rgCb[inst].rgInit.cfgDone != TRUE)
775 RETVALUE(LCM_REASON_GENCFG_NOT_DONE);
780 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
781 (cfg->s.rguSap.selector != RGU_SEL_TC) &&
782 (cfg->s.rguSap.selector != RGU_SEL_LC))
784 ret = LCM_REASON_INVALID_PAR_VAL;
785 RLOG0(L_ERROR, "unsupported Selector value for RGU");
788 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
789 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
791 upSapCb->sapSta.sapState = LRG_UNBND;
793 upSapCfg = &(upSapCb->sapCfg);
794 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
795 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
796 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
797 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
798 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
799 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
800 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
801 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
802 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
803 upSapCfg->sapPst.route = cfg->s.rguSap.route;
804 upSapCfg->sapPst.intfVer = 0;
805 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
806 upSapCfg->suId = cfg->s.rguSap.suId;
807 upSapCfg->spId = cfg->s.rguSap.spId;
808 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
809 * there is cfg request with sap is 1*/
812 if ((cfg->s.crgSap.selector != CRG_SEL_TC) &&
813 (cfg->s.crgSap.selector != CRG_SEL_LC))
815 ret = LCM_REASON_INVALID_PAR_VAL;
816 RLOG0(L_ERROR, "unsupported Selector value for CRG");
819 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
821 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
823 upSapCfg = &rgCb[inst].crgSap.sapCfg;
825 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
826 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
827 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
828 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
829 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
830 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
831 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
832 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
833 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
834 upSapCfg->sapPst.route = cfg->s.crgSap.route;
835 upSapCfg->sapPst.intfVer = 0;
836 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
837 upSapCfg->suId = cfg->s.crgSap.suId;
838 upSapCfg->spId = cfg->s.crgSap.spId;
842 if ((cfg->s.tfuSap.selector != TFU_SEL_TC) &&
843 (cfg->s.tfuSap.selector != TFU_SEL_LC))
845 ret = LCM_REASON_INVALID_PAR_VAL;
846 RLOG0(L_ERROR, "unsupported Selector value for TFU");
850 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
852 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
854 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
856 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
857 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
858 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
859 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
860 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
861 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
862 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
863 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
864 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
865 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
866 lowSapCfg->sapPst.intfVer = 0;
867 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
868 lowSapCfg->suId = cfg->s.tfuSap.suId;
869 lowSapCfg->spId = cfg->s.tfuSap.spId;
870 cmMemcpy((U8 *)&lowSapCfg->bndTmr, (U8 *)&cfg->s.tfuSap.bndTmr,
874 /* would never reach here */
882 * @brief General Configuration Handler.
886 * Function : rgLMMGenCfg
888 * This function in called by RgMiLrgCfgReq(). It handles the
889 * general configuration of the LTE MAC layer. It initializes
890 * the hash lists of RgCb. Returns
891 * reason for success/failure of this function.
893 * @param[in] Inst inst
894 * @param[in] RgCfg *cfg, the Configuaration information
896 * -# LCM_REASON_NOT_APPL
897 * -# LCM_REASON_INVALID_MSGTYPE
898 * -# LCM_REASON_MEM_NOAVAIL
901 PRIVATE U16 rgLMMGenCfg
904 RgCfg *cfg /* Configuaration information */
907 PRIVATE U16 rgLMMGenCfg(inst,cfg)
909 RgCfg *cfg; /* Configuaration information */
912 U16 ret = LCM_REASON_NOT_APPL;
916 /* Check if General Configuration is done already */
917 if (rgCb[inst].rgInit.cfgDone == TRUE)
919 RETVALUE(LCM_REASON_INVALID_MSGTYPE);
921 if ((cfg->s.genCfg.lmPst.selector != LRG_SEL_TC) &&
922 (cfg->s.genCfg.lmPst.selector != LRG_SEL_LC))
924 RLOG0(L_ERROR, "unsupported Selector value for RGU");
925 RETVALUE(LCM_REASON_INVALID_PAR_VAL);
927 /* Update the Pst structure for LM interface */
928 cmMemcpy((U8 *)&rgCb[inst].rgInit.lmPst, (U8 *)&cfg->s.genCfg.lmPst,
931 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
932 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
933 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
934 rgCb[inst].rgInit.lmPst.event = EVTNONE;
936 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
937 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
938 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
939 /* Initialize SAP States */
940 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
942 if(cfg->s.genCfg.numRguSaps == 0)
944 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Invalid numRguSap.\n"));
948 /* allocate RGR saps */
949 if (SGetSBuf(rgCb[inst].rgInit.region,
950 rgCb[inst].rgInit.pool,
951 (Data **)&rgCb[inst].rguSap,
952 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
954 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Failed to allocate mem for RGU SAP's.\n"));
957 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
959 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
961 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
962 cmMemset((U8 *)&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
964 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
965 /* Initialize the timer blocks */
966 cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
967 /* Initialzie the timer queue */
968 cmMemset((U8 *)&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
969 /* Initialize the timer control point */
970 cmMemset((U8 *)&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
971 rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
973 /* Timer Registration request to SSI */
974 if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
975 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
978 RLOG0(L_ERROR, "Failed to register timer");
980 SPutSBuf(rgCb[inst].rgInit.region,
981 rgCb[inst].rgInit.pool,
982 (Data *)rgCb[inst].rguSap,
983 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
985 RETVALUE(LCM_REASON_MEM_NOAVAIL);
988 /* Set Config done in TskInit */
989 rgCb[inst].rgInit.cfgDone = TRUE;
995 /***********************************************************
997 * Func : rgLMMShutdown
1000 * Desc : Handles the MAC layer shutdown request. Calls
1001 * rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
1010 **********************************************************/
1012 PRIVATE Void rgLMMShutdown
1017 PRIVATE Void rgLMMShutdown(inst)
1021 RgCellCb *cell = rgCb[inst].cell;
1026 /* Unbind the TFU Sap */
1027 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
1029 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1030 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1032 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1034 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1036 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
1038 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1039 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1045 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1047 rgTOMRlsSf(inst,&cell->subFrms[idx]);
1050 rgCFGFreeCellCb(cell);
1053 /* Deleting the RGU SAPs */
1054 SPutSBuf(rgCb[inst].rgInit.region,
1055 rgCb[inst].rgInit.pool,
1056 (Data *)rgCb[inst].rguSap,
1057 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
1058 rgCb[inst].rguSap = NULLP;
1060 rgCb[inst].inactiveCell = NULLP;
1061 rgCb[inst].cell = NULLP;
1063 /* De-register the Timer Service */
1064 (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
1065 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr);
1067 /* call back the task initialization function to intialize
1068 * the global RgCb Struct */
1069 rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region,
1070 rgCb[inst].rgInit.reason);
1076 /***********************************************************
1078 * Func : rgLMMGenCntrl
1081 * Desc : Processes the LM control request for STGEN elmnt.
1090 **********************************************************/
1092 PRIVATE Void rgLMMGenCntrl
1099 PRIVATE Void rgLMMGenCntrl(cntrl, cfm, cfmPst)
1105 Inst inst = (cfmPst->srcInst - RG_INST_START);
1108 cfm->cfm.status = LCM_PRIM_OK;
1109 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1112 switch(cntrl->t.cntrl.action)
1115 /* Action is Enable */
1116 switch(cntrl->t.cntrl.subAction)
1120 rgCb[inst].rgInit.trc = TRUE;
1121 rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1122 /*Store the response and TransId for sending the Traces */
1123 cmMemcpy((U8 *)&rgCb[inst].genCfg.trcResp.response,
1124 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1125 rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1129 /* Enable Unsolicited Status (alarms) */
1130 rgCb[inst].rgInit.usta = TRUE;
1131 /*Store the response and TransId for sending the Alarms */
1132 cmMemcpy((U8 *)&rgCb[inst].genCfg.ustaResp.response,
1133 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1134 rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1137 /* Enable Debug Printing */
1139 rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1144 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1149 cfm->cfm.status = LCM_PRIM_NOK;
1150 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1151 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1156 /* Action is Diable immidiately */
1157 switch(cntrl->t.cntrl.subAction)
1160 /* Disable Traces */
1161 rgCb[inst].rgInit.trc = FALSE;
1164 /* Disable Unsolicited Status (alarms) */
1165 rgCb[inst].rgInit.usta = FALSE;
1168 /* Disable Debug Printing */
1170 rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1175 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1180 cfm->cfm.status = LCM_PRIM_NOK;
1181 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1182 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1187 /* Free all the memory dynamically allocated by MAC */
1188 rgLMMShutdown(inst);
1191 cfm->cfm.status = LCM_PRIM_NOK;
1192 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1193 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1196 RgMiLrgCntrlCfm(cfmPst, cfm);
1201 /***********************************************************
1203 * Func : rgLMMSapCntrl
1206 * Desc : Processes the LM control request for STxxxSAP elmnt.
1215 **********************************************************/
1217 PRIVATE Void rgLMMSapCntrl
1224 PRIVATE Void rgLMMSapCntrl(cntrl, cfm, cfmPst)
1230 Inst inst = cfmPst->srcInst - RG_INST_START;
1233 /* Only TFU Sap can be controlled by LM */
1234 switch(cntrl->hdr.elmId.elmnt)
1237 switch(cntrl->t.cntrl.action)
1240 /* Bind Enable Request */
1241 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1242 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1244 cfm->cfm.status = LCM_PRIM_NOK;
1245 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1249 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1251 rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val,
1252 (PTR)&rgCb[inst].tfuSap);
1254 /* Change SAP state */
1255 rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1256 rgCb[inst].tfuSap.numBndRetries++;
1257 /* Store the response and TransId for sending
1258 * the Control confirm */
1259 cmMemcpy((U8 *)&rgCb[inst].genCfg.bndCfmResp.response,
1260 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1261 rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1263 /* Sending Status Indication to Layer Manager */
1264 cfm->cfm.status = LCM_PRIM_OK_NDONE;
1265 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1266 RgMiLrgCntrlCfm(cfmPst, cfm);
1268 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1269 rgCb[inst].tfuSap.sapCfg.spId);
1274 /* Unbind request */
1276 /* Check if the SAP is configured */
1277 if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1278 (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1280 cfm->cfm.status = LCM_PRIM_NOK;
1281 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1285 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1286 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1288 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1290 /* Change SAP state */
1291 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1292 cfm->cfm.status = LCM_PRIM_OK;
1293 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1297 /* Delete SAP, does initialization of SAP */
1298 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1299 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1301 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1302 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1304 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1307 cmMemset((U8 *)&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1308 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1309 cfm->cfm.status = LCM_PRIM_OK;
1310 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1313 cfm->cfm.status = LCM_PRIM_NOK;
1314 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1315 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1316 cntrl->t.cntrl.action));
1321 switch(cntrl->t.cntrl.action)
1324 cmMemset((U8 *)&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1325 rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1326 cfm->cfm.status = LCM_PRIM_OK;
1327 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1330 cfm->cfm.status = LCM_PRIM_NOK;
1331 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1332 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1333 cntrl->t.cntrl.action));
1338 switch(cntrl->t.cntrl.action)
1341 cmMemset((U8 *)&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1342 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1343 cfm->cfm.status = LCM_PRIM_OK;
1344 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1347 cfm->cfm.status = LCM_PRIM_NOK;
1348 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1349 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1355 /* Would never here. */
1358 RgMiLrgCntrlCfm(cfmPst, cfm);
1363 /***********************************************************
1365 * Func : rgLMMFillCfmPst
1368 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
1369 * and the cfm->hdr.response.
1378 **********************************************************/
1380 PRIVATE Void rgLMMFillCfmPst
1387 PRIVATE Void rgLMMFillCfmPst(reqPst, cfmPst, cfm)
1394 TRC2(rgLMMFillCfmPst)
1395 inst = (reqPst->dstInst - RG_INST_START);
1397 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
1398 cfmPst->srcInst = rgCb[inst].rgInit.inst;
1399 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1400 cfmPst->dstEnt = reqPst->srcEnt;
1401 cfmPst->dstInst = reqPst->srcInst;
1402 cfmPst->dstProcId = reqPst->srcProcId;
1404 cfmPst->selector = cfm->hdr.response.selector;
1405 cfmPst->prior = cfm->hdr.response.prior;
1406 cfmPst->route = cfm->hdr.response.route;
1407 cfmPst->region = cfm->hdr.response.mem.region;
1408 cfmPst->pool = cfm->hdr.response.mem.pool;
1415 * @brief Timer start handler.
1419 * Function : rgLMMStartTmr
1421 * This function based on the input parameters starts the timer for
1422 * "tmrVal" duration. As of now MAC uses the timer functionality for
1423 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1425 * @param[in] Inst inst
1426 * @param[in] S16 tmrEvnt, the Timer Event
1427 * @param[in] U32 tmrVal, the Wait Time
1428 * @param[in] PTR cb, Entry for which Timer expired
1433 PUBLIC S16 rgLMMStartTmr
1436 S16 tmrEvnt, /* Timer Event */
1437 U32 tmrVal, /* Wait Time */
1438 PTR cb /* Entry for which Timer Expired */
1441 PUBLIC S16 rgLMMStartTmr(tmrEvnt, tmrVal, cb)
1443 S16 tmrEvnt; /* Timer Event */
1444 U32 tmrVal; /* Wait Time */
1445 PTR cb; /* Entry for which Timer Expired */
1454 /* Initialize the arg structure */
1455 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1457 arg.tqCp = &rgCb[inst].tmrTqCp;
1458 arg.tq = rgCb[inst].tmrTq;
1459 arg.timers = rgCb[inst].tmrBlk;
1462 arg.max = RG_MAX_TIMER;
1463 arg.evnt = RG_BNDREQ_TMR;
1472 * @brief Timer stop handler.
1476 * Function : rgLMMStopTmr
1478 * This function based on the input parameters stops the timer for
1479 * "tmrEvnt". As of now MAC uses the timer functionality for
1480 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1481 * Once the bind happens and this timer is stopped, the timer functionality
1482 * is deregistered with SSI. As there is no further use of timer processing.
1484 * @param[in] Inst inst
1485 * @param[in] S16 tmrEvnt, the Timer Event
1486 * @param[in] PTR cb, Entry for which Timer expired
1492 PUBLIC S16 rgLMMStopTmr
1494 Inst inst, /* Scheduler instance */
1495 S16 tmrEvnt, /* Timer Event */
1496 PTR cb /* Entry for which Timer Expired */
1499 PUBLIC S16 rgLMMStopTmr(inst,tmrEvnt, cb)
1500 Inst inst; /* Scheduler instance */
1501 S16 tmrEvnt; /* Timer Event */
1502 PTR cb; /* Entry for which Timer Expired */
1513 for(i=0;i<RG_MAX_TIMER;i++)
1515 /* Search for the Timer Blocks */
1516 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1518 /* Initialize the arg structure */
1519 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1521 arg.tqCp = &rgCb[inst].tmrTqCp;
1522 arg.tq = rgCb[inst].tmrTq;
1523 arg.timers = rgCb[inst].tmrBlk;
1525 arg.max = RG_MAX_TIMER;
1543 * @brief Timer Expiry handler.
1547 * Function : rgLMMTmrExpiry
1549 * This is a callback function used as an input parameter to cmPrcTmr()
1550 * to check expiry of any timer. In this function, the only concern is
1551 * about tmrEvnt=Bind timer.
1553 * @param[in] PTR cb, Entry for which Timer expired
1554 * @param[in] S16 tmrEvnt, the Timer Event
1559 PUBLIC S16 rgLMMTmrExpiry
1561 PTR cb, /* Pointer to timer control block */
1562 S16 tmrEvnt /* Timer Event */
1565 PUBLIC S16 rgLMMTmrExpiry(cb,tmrEvnt)
1566 PTR cb; /* Pointer to timer control block */
1567 S16 tmrEvnt; /* Timer Event */
1571 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1572 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1574 TRC2(rgLMMTmrExpiry)
1580 tfuSap->numBndRetries++;
1581 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1583 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1584 LCM_CAUSE_TMR_EXPIRED, NULLP);
1588 /* Restart the bind timer */
1589 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1591 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1595 /* Send bind request */
1596 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1597 rgCb[inst].tfuSap.sapCfg.spId);
1601 RLOG1(L_ERROR, "Invalid tmrEvnt=%d",tmrEvnt);
1611 * @brief Layer Manager Unsolicited Status Indication generation.
1615 * Function : rgLMMStaInd
1617 * This API is used by the other modules of MAC to send a unsolicited
1618 * status indication to the Layer Manager.
1620 * @param[in] Inst inst
1621 * @param[in] U16 category, the Alarm category
1622 * @param[in] U16 event, the Alarm event
1623 * @param[in] U16 cause, the cause of the Alarm
1624 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1629 PUBLIC S16 rgLMMStaInd
1638 PUBLIC S16 rgLMMStaInd(inst,category, event, cause, dgn)
1650 if(rgCb[inst].rgInit.usta == FALSE)
1655 cmMemset((U8 *)&usta, 0, sizeof(RgMngmt));
1657 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1658 usta.t.usta.cmAlarm.category = category;
1659 usta.t.usta.cmAlarm.event = event;
1660 usta.t.usta.cmAlarm.cause = cause;
1663 cmMemcpy((U8 *)&usta.t.usta.dgn, (U8 *)dgn, sizeof(RgUstaDgn));
1666 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1667 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1668 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1669 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1670 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1671 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1673 RETVALUE(RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1678 * @brief Layer Manager Trace Indication generation.
1682 * Function : rgLMMTrcInd
1684 * This API is used by the other modules of MAC to send a
1685 * Trace indication to the Layer Manager.
1687 * @param[in] Inst inst
1688 * @param[in] Buffer *srcMbuf, the Message Buffer .
1689 * @param[in] U8 event, the trace event.
1693 PUBLIC Void rgLMMTrcInd
1696 Buffer *srcMbuf, /* Message Buffer */
1697 U8 event /* event */
1700 PUBLIC Void rgLMMTrcInd(inst,srcMbuf,event)
1702 Buffer *srcMbuf; /* Message Buffer */
1703 U8 event; /* event */
1706 Buffer *dstMbuf = NULLP;
1716 if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1718 RLOG0(L_ERROR, "Trace Disabled.");
1722 cmMemset((U8 *)&trc, 0, sizeof(RgMngmt));
1724 pst = rgCb[inst].rgInit.lmPst;
1725 pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1726 pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1727 pst.route = rgCb[inst].genCfg.trcResp.response.route;
1728 pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1729 pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1731 trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1733 SGetDateTime(&trc.t.trc.dt);
1735 /* Check if the whole buffer is to be sent in Trace indication */
1736 if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1738 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1741 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1744 trc.cfm.status = LCM_PRIM_OK;
1745 trc.cfm.reason = LCM_REASON_NOT_APPL;
1746 trc.t.trc.evnt = event;
1748 /* Send Trace Indication to Layer manager */
1749 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1751 /* check if only a specified number of bytes are to be sent */
1752 else if(rgCb[inst].trcLen > 0)
1754 /* Get the length of the recvd message buffer */
1755 if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1757 RLOG0(L_ERROR, "SFndLenMsg Failed.");
1760 /* Check if the recvd buffer size is less than request trace len */
1761 if(bufLen < rgCb[inst].trcLen)
1763 /* Copy the whole of the recvd buffer in trace indication */
1765 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1768 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1772 trc.cfm.status = LCM_PRIM_OK;
1773 trc.cfm.reason = LCM_REASON_NOT_APPL;
1774 trc.t.trc.evnt = event;
1776 /* Send Trace Indication to Layer manager */
1777 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1779 /* if the recvd buffer size is greater than request trace len */
1780 if(bufLen >= rgCb[inst].trcLen)
1782 /* Get a temporary buffer to store the msg */
1783 if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1785 RLOG0(L_ERROR, "rgAllocSBuf Failed.");
1789 /* Copy trcLen nos of bytes from the recvd message */
1790 if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)
1792 RLOG0(L_ERROR, "SCpyMsgFix Failed.");
1796 if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1798 RLOG0(L_ERROR, "dstMbuf Allocation Failed");
1801 /* Copy the tempBuf data to dst mBuf */
1802 if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1804 RLOG0(L_ERROR, "SCpyFixMsg Failed.");
1808 /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1810 /* Free the memory allocated for tempBuf */
1811 rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1813 trc.cfm.status = LCM_PRIM_OK;
1814 trc.cfm.reason = LCM_REASON_NOT_APPL;
1815 trc.t.trc.evnt = event;
1817 /* Send Trace Indication to Layer manager */
1818 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1826 * @brief Layer Manager Control Confirm generation handler
1827 * for Bind Confirm reception at TFU interface.
1828 * RgLiTfuBndCfm() forwards the confirmation to this
1829 * function. All SAP state related handling is restricted
1830 * to LMM modules, hence the cfm forwarding.
1834 * Function : rgLMMBndCfm
1836 * This API is used by the LIM module of MAC to forward
1837 * the Bind Confirm it receives over the TFU interface.
1839 * @param[in] Pst *pst, Post Structure
1840 * @param[in] SuId suId, Service user ID
1841 * @param[in] U8 status, Status
1846 PUBLIC S16 rgLMMBndCfm
1848 Pst *pst, /* Post Structure */
1849 SuId suId, /* Service user ID */
1850 U8 status /* Status */
1853 PUBLIC S16 rgLMMBndCfm(pst,suId,status)
1854 Pst *pst; /* Post Structure */
1855 SuId suId; /* Service user ID */
1856 U8 status; /* Status */
1859 Inst inst = pst->dstInst - RG_INST_START;
1868 /* Check if the suId is valid */
1869 if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1871 RLOG0(L_ERROR, "Invalid SuId");
1875 /* check the Sap State */
1876 switch(rgCb[inst].tfuSap.sapSta.sapState)
1878 case LRG_WAIT_BNDCFM:
1881 /* SAP is already bound */
1887 cfmPst = rgCb[inst].rgInit.lmPst;
1888 cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1889 cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1890 cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1891 cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1892 cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1894 cmMemset((U8 *)&cntrlCfm, 0, sizeof(RgMngmt));
1898 case CM_BND_OK: /* status is OK */
1899 /* Change SAP state to Bound */
1900 rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1901 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1903 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1905 /* Send Control Confirm with status as OK to Layer Manager */
1906 cntrlCfm.cfm.status = LCM_PRIM_OK;
1907 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1911 /* Change SAP state to UnBound */
1912 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1913 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1915 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1917 /* Send Control Confirm with status as NOK to Layer Manager */
1918 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1919 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1922 rgCb[inst].tfuSap.numBndRetries = 0;
1923 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1924 cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1926 ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1933 * @brief LTE MAC timer call back function registered with SSI.
1937 * Function : rgActvTmr
1939 * This function is invoked by SSI for every timer activation
1946 PUBLIC S16 rgActvTmr
1952 PUBLIC S16 rgActvTmr(ent, inst)
1957 Inst macInst = (inst - RG_INST_START);
1960 /* Check if any MAC timer has expired */
1961 cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1965 } /* end of rgActvTmr */
1968 * @brief Layer Manager Configuration request handler for Scheduler
1972 * Function : MacSchGenCfgReq
1974 * This function receives general configurations for Scheduler
1975 * from DU APP and forwards to Scheduler.
1977 * @param[in] Pst *pst, the post structure
1978 * @param[in] RgMngmt *cfg, the configuration parameter's structure
1983 PUBLIC S16 MacSchGenCfgReq
1985 Pst *pst, /* post structure */
1986 RgMngmt *cfg /* config structure */
1989 PUBLIC S16 MacSchGenCfgReq(pst, cfg)
1990 Pst *pst; /* post structure */
1991 RgMngmt *cfg; /* config structure */
1994 printf("\nReceived Scheduler gen config at MAC");
1995 pst->dstInst = DEFAULT_CELLS + 1;
1996 HandleSchGenCfgReq(pst, cfg);
2002 * @brief Layer Manager Configuration response from Scheduler
2006 * Function : SchSendCfgCfm
2008 * This function sends general configurations response from
2009 * Scheduler to DU APP.
2011 * @param[in] Pst *pst, the post structure
2012 * @param[in] RgMngmt *cfm, the configuration confirm structure
2017 PUBLIC S16 SchSendCfgCfm
2019 Pst *pst, /* post structure */
2020 RgMngmt *cfm /* config confirm structure */
2023 PUBLIC S16 SchSendCfgCfm(pst, cfm)
2024 Pst *pst; /* post structure */
2025 RgMngmt *cfm; /* config confirm structure */
2028 printf("\nSending Scheduler config confirm to DU APP");
2029 pst->dstEnt = ENTDUAPP;
2032 pst->selector = MAC_SCH_LC_SELECTOR;
2033 RgMiLrgSchCfgCfm(pst, cfm);
2039 /***********************************************************
2041 * Func : macCellCfgFillCfmPst
2044 * Desc : Fills the Confirmation Post Structure cfmPst
2052 **********************************************************/
2053 Void macCellCfgFillCfmPst
2060 inst = reqPst->dstInst;
2062 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
2063 cfmPst->srcInst = rgCb[inst].rgInit.inst;
2064 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
2066 cfmPst->dstEnt = ENTDUAPP;
2067 cfmPst->dstInst = 0;
2068 cfmPst->dstProcId = cfmPst->srcProcId;
2070 cfmPst->selector = LRG_SEL_LC;
2071 cfmPst->prior = reqPst->prior;
2072 cfmPst->route = reqPst->route;
2073 cfmPst->region = reqPst->region;
2074 cfmPst->pool = reqPst->pool;
2075 cfmPst->event = EVENT_MAC_CELL_CONFIG_CFM;
2081 * @brief Layer Manager Configuration request handler.
2085 * Function : MacHdlCellCfgReq
2087 * This function handles the gNB and cell configuration
2088 * request received from DU APP.
2089 * This API unapcks and forwards the config towards SCH
2091 * @param[in] Pst *pst
2092 * @param[in] MacCellCfg *macCellCfg
2096 int MacHdlCellCfgReq
2099 MacCellCfg *macCellCfg
2105 MacCellCb *macCellCb;
2106 Inst inst = pst->dstInst;
2108 cmMemset((U8 *)&cfmPst, 0, sizeof(Pst));
2109 MAC_ALLOC(cellCb,sizeof(RgCellCb));
2113 DU_LOG("\nMAC : cellCb is NULL at handling of macCellCfg\n");
2117 memcpy(&cellCb->macCellCfg,macCellCfg,sizeof(MacCellCfg));
2118 rgCb[inst].cell = cellCb;
2120 MAC_ALLOC(macCellCb,sizeof(MacCellCb));
2121 if(macCellCb == NULLP)
2123 DU_LOG("\nMAC : macCellCb is NULL at handling of macCellCfg\n");
2126 macCb.macCell = macCellCb;
2127 /* Send cell cfg to scheduler */
2128 ret = MacSchCellCfgReq(pst, macCellCfg);
2131 MacCellCfgCfm macCellCfgCfm;
2132 macCellCfgCfm.rsp = RSP_NOK;
2133 macCellCfgCfm.transId = macCellCfg->transId;
2134 macCellCfgFillCfmPst(pst,&cfmPst);
2135 ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
2138 } /* end of MacHdlCellCfgReq */
2141 * @brief Layer Manager Configuration request handler.
2145 * Function : MacSchCellCfgReq
2147 * This function sends cell configuration to SCH
2149 * @param[in] Pst *pst
2150 * @param[in] MacCellCfg *macCellCfg
2154 int MacSchCellCfgReq
2157 MacCellCfg *macCellCfg
2160 SchCellCfg schCellCfg;
2164 cmMemset((U8 *)&cfgPst, 0, sizeof(Pst));
2165 schCellCfg.cellId = macCellCfg->cellId;
2166 schCellCfg.phyCellId = macCellCfg->phyCellId;
2167 schCellCfg.bandwidth = macCellCfg->dlCarrCfg.bw;
2168 schCellCfg.dupMode = macCellCfg->dupType;
2169 schCellCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr;
2170 schCellCfg.scsCommon = macCellCfg->ssbCfg.scsCmn;
2171 schCellCfg.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
2172 schCellCfg.ssbPeriod = macCellCfg->ssbCfg.ssbPeriod;
2173 schCellCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset;
2174 for(uint8_t idx=0; idx<SSB_MASK_SIZE; idx++)
2176 schCellCfg.nSSBMask[idx] = macCellCfg->ssbCfg.ssbMask[idx];
2178 cfgPst.srcProcId = pst->dstProcId;
2179 cfgPst.dstProcId = pst->srcProcId;
2180 cfgPst.srcEnt = ENTRG;
2182 cfgPst.dstEnt = ENTRG;
2184 cfgPst.selector = MAC_SCH_TC_SELECTOR;
2185 cfgPst.event = EVENT_SCH_CELL_CFG;
2187 ret = (*SchCellCfgOpts[cfgPst.selector])(&cfgPst, &schCellCfg);
2189 } /* end of MacSchCellCfgReq */
2192 * @brief Layer Manager Configuration response handler.
2196 * Function : MacProcSchCellCfgCfm
2198 * This function processes cell configuration to SCH
2200 * @param[in] Pst *pst
2201 * @param[in] SchCellCfgCfm *schCellCfgCfm
2205 int MacProcSchCellCfgCfm
2208 SchCellCfgCfm *schCellCfgCfm
2214 MacCellCfgCfm macCellCfgCfm;
2216 cmMemset((U8 *)&cfmPst, 0, sizeof(Pst));
2217 cellCb = rgCb[pst->dstInst].cell;
2218 macCellCfgCfm.transId = cellCb->macCellCfg.transId;
2219 if(schCellCfgCfm->rsp == RSP_OK)
2221 macCellCfgCfm.rsp = RSP_OK;
2225 macCellCfgCfm.rsp = RSP_NOK;
2227 macCellCfgFillCfmPst(pst,&cfmPst);
2228 ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
2231 /**********************************************************************
2234 **********************************************************************/