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 */
144 * @brief Task Initiation callback function.
148 * Function : rgActvInit
150 * This function is supplied as one of parameters during MAC's
151 * task registration. SSI will invoke this function once, after
152 * it creates and attaches this TAPA Task to a system task.
154 * @param[in] Ent entity, the entity ID of this task.
155 * @param[in] Inst inst, the instance ID of this task.
156 * @param[in] Region region, the region ID registered for memory
157 * usage of this task.
158 * @param[in] Reason reason.
163 PUBLIC S16 rgActvInit
165 Ent entity, /* entity */
166 Inst inst, /* instance */
167 Region region, /* region */
168 Reason reason /* reason */
171 PUBLIC S16 rgActvInit(entity, inst, region, reason)
172 Ent entity; /* entity */
173 Inst inst; /* instance */
174 Region region; /* region */
175 Reason reason; /* reason */
181 RG_IS_INST_VALID(inst);
183 macInst = inst - RG_INST_START;
184 /* Initialize the MAC TskInit structure to zero */
185 cmMemset ((U8 *)&rgCb[macInst], 0, sizeof(RgCb));
187 /* Initialize the MAC TskInit with received values */
188 rgCb[macInst].rgInit.ent = entity;
189 rgCb[macInst].rgInit.inst = inst;
190 rgCb[macInst].rgInit.region = region;
191 rgCb[macInst].rgInit.pool = 0;
192 rgCb[macInst].rgInit.reason = reason;
193 rgCb[macInst].rgInit.cfgDone = FALSE;
194 rgCb[macInst].rgInit.acnt = FALSE;
195 rgCb[macInst].rgInit.usta = FALSE;
196 rgCb[macInst].rgInit.trc = FALSE;
197 rgCb[macInst].trcLen = 0;
200 /* disabling debugs by default */
201 rgCb[macInst].rgInit.dbgMask = 0xffffffff;
205 rgCb[macInst].rgInit.logMask = 0x0;
207 rgCb[macInst].rgInit.procId = SFndProcId();
208 rgCb[macInst].tfuSap.numBndRetries = 0;
210 /* Initialize Sap state */
211 rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
212 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
213 rgCb[macInst].rguSap = NULLP;
214 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
216 rgCb[macInst].inactiveCell = NULLP;
217 rgCb[macInst].cell = NULLP;
219 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
220 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
223 /* Initializing CL control block */
224 clGlobalCp.region = region;
226 clGlobalCp.clCfgDone = FALSE;
227 clGlobalCp.numOfCells = 0;
228 clGlobalCp.phyState = PHY_STATE_IDLE;
230 if( cmHashListInit(&clGlobalCp.cellCbLst, MAX_NUM_CELL_SUPP, 0x0, FALSE,
231 CM_HASH_KEYTYPE_DEF, clGlobalCp.region, clGlobalCp.pool ) != ROK )
233 printf("\n Cellcb hash list initialization failed for MAC CL");
237 /* Initialize Scheduler as well */
238 schActvInit(ENTRG, (DEFAULT_CELLS + SCH_INST_START), DFLT_REGION, PWR_UP);
245 * @brief Layer Manager Configuration request handler.
249 * Function : RgMiLrgCfgReq
251 * This function handles the configuration
252 * request received from the Layer Manager.
253 * -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
254 * functions rgHdlGenCfg() or rgHdlSapCfg().
255 * -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
257 * @param[in] Pst *pst, the post structure
258 * @param[in] RgMngmt *cfg, the configuration parameter's structure
263 PUBLIC S16 RgMiLrgCfgReq
265 Pst *pst, /* post structure */
266 RgMngmt *cfg /* config structure */
269 PUBLIC S16 RgMiLrgCfgReq(pst, cfg)
270 Pst *pst; /* post structure */
271 RgMngmt *cfg; /* config structure */
274 U16 ret = LCM_PRIM_OK;
275 U16 reason = LCM_REASON_NOT_APPL;
283 RG_DIAG_LVL0(inst,0x0a0b0001, RG_DIAG_NA, SS_DIAG_INV_ARG,
284 "Received CfgReq for MAC layer, Entity = %d, Instance = %d\n",
285 pst->srcEnt, pst->srcInst,0,0);
287 RG_IS_INST_VALID(pst->dstInst);
288 inst = pst->dstInst - RG_INST_START;
290 /* Fill the post structure for sending the confirmation */
291 rgLMMFillCfmPst(pst, &cfmPst, cfg);
293 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
296 cfm.hdr.transId = cfg->hdr.transId;
300 cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
301 switch(cfg->hdr.elmId.elmnt)
304 reason = rgLMMGenCfg(inst,&cfg->t.cfg);
309 reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
313 reason = LCM_REASON_INVALID_ELMNT;
314 RLOG1(L_ERROR, "Invalid Elmnt=%d",
315 cfg->hdr.elmId.elmnt);
319 if (reason != LCM_REASON_NOT_APPL)
324 cfm.cfm.status = ret;
325 cfm.cfm.reason = reason;
327 RgMiLrgCfgCfm(&cfmPst, &cfm);
330 }/*-- RgMiLrgCfgReq --*/
334 * @brief Layer Manager Statistics request handler.
338 * Function : RgMiLrgStsReq
340 * This function handles the statistics
341 * request received from the Layer Manager.
342 * -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
343 * statistics from the rgCb global control block.
344 * -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
345 * -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
347 * @param[in] Pst *pst, the post structure
348 * @param[in] RgMngmt *sts, the statistics parameter's structure
353 PUBLIC S16 RgMiLrgStsReq
355 Pst *pst, /* post structure */
356 RgMngmt *sts /* statistics structure */
359 PUBLIC S16 RgMiLrgStsReq(pst, sts)
360 Pst *pst; /* post structure */
361 RgMngmt *sts; /* statistics structure */
371 RG_IS_INST_VALID(pst->dstInst);
372 inst = pst->dstInst - RG_INST_START;
373 /* Fill the post structure for sending the confirmation */
374 rgLMMFillCfmPst(pst, &cfmPst, sts);
376 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
379 cfm.hdr.transId = sts->hdr.transId;
381 SGetDateTime(&cfm.t.sts.dt);
382 cfm.cfm.status = LCM_PRIM_OK;
383 cfm.cfm.reason = LCM_REASON_NOT_APPL;
384 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
385 cfm.t.sts.action = sts->t.sts.action;
387 /* Check if General Config Done */
388 if(rgCb[inst].rgInit.cfgDone != TRUE)
390 cfm.cfm.status = LCM_PRIM_NOK;
391 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
392 RgMiLrgStsCfm(&cfmPst,&cfm);
393 RLOG0(L_ERROR, "Gen Cfg not done");
397 switch(sts->hdr.elmId.elmnt)
401 cmMemcpy((U8 *)&(cfm.t.sts.s.genSts), (U8 *)&rgCb[inst].genSts,
403 /* check if action is read and reset */
404 if(sts->t.sts.action == ARST)
406 rgCb[inst].genSts.numHarqFail = 0;
411 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
413 for(cqi=0; cqi <= 14; cqi++)
415 /* Filling DL ACK/NACK stats */
416 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
417 hqFailStats.dlCqiStat[cqi].mcs;
418 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
419 hqFailStats.dlCqiStat[cqi].numOfNacks;
420 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
421 hqFailStats.dlCqiStat[cqi].numOfAcks;
423 /* Filling UL ACK/NACK stats */
424 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
425 hqFailStats.ulCqiStat[cqi].mcs;
426 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
427 hqFailStats.ulCqiStat[cqi].numOfNacks;
428 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
429 hqFailStats.ulCqiStat[cqi].numOfAcks;
431 /* Filling DL HQ Retx stats */
432 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
433 hqRetxStats.dlCqiStat[cqi].mcs;
434 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
435 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
436 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
437 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
438 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
439 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
440 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
441 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
442 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
443 hqRetxStats.dlCqiStat[cqi].totalTx;
445 /* Filling UL HQ Retx stats */
446 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
447 hqRetxStats.ulCqiStat[cqi].mcs;
448 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
449 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
450 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
451 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
452 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
453 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
454 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
455 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
456 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
457 hqRetxStats.ulCqiStat[cqi].totalTx;
459 /* Reset statistics */
460 if(sts->t.sts.action == ZEROSTS)
462 cmMemset((U8 *)&hqRetxStats, 0, \
463 sizeof(RgSchHqRetxStats));
464 cmMemset((U8 *)&hqFailStats, 0, \
465 sizeof(RgSchNackAckStats));
468 #endif /* MAC_SCH_STATS*/
472 cmMemcpy((U8 *)&(cfm.t.sts.s.rguSts), (U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
475 /* check if action is read and reset */
476 if(sts->t.sts.action == ARST)
477 cmMemset((U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
481 cmMemcpy((U8 *)&(cfm.t.sts.s.crgSts), (U8 *)&rgCb[inst].crgSap.sapSts,
484 /* check if action is read and reset */
485 if(sts->t.sts.action == ARST)
486 cmMemset((U8 *)&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
490 cmMemcpy((U8 *)&(cfm.t.sts.s.tfuSts), (U8 *)&rgCb[inst].tfuSap.sapSts,
493 /* check if action is read and reset */
494 if(sts->t.sts.action == ARST)
495 cmMemset((U8 *)&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
499 cfm.cfm.status = LCM_PRIM_NOK;
500 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
501 RLOG1(L_ERROR, "Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
504 RgMiLrgStsCfm(&cfmPst,&cfm);
506 }/*-- RgMiLrgStsReq --*/
510 * @brief Layer Manager Status request handler.
514 * Function : RgMiLrgStaReq
516 * This function handles the solicited status
517 * request received from the Layer Manager.
518 * -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
519 * particular SAP from the rgCb global control block.
520 * -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
522 * @param[in] Pst *pst, the post structure
523 * @param[in] RgMngmt *sta, the status parameter's structure
528 PUBLIC S16 RgMiLrgStaReq
530 Pst *pst, /* post structure */
531 RgMngmt *sta /* status structure */
534 PUBLIC S16 RgMiLrgStaReq(pst, sta)
535 Pst *pst; /* post structure */
536 RgMngmt *sta; /* status structure */
546 RG_IS_INST_VALID(pst->dstInst);
547 inst = pst->dstInst - RG_INST_START;
550 /* Fill the post structure for sending the confirmation */
551 rgLMMFillCfmPst(pst, &cfmPst, sta);
553 if (sta->t.ssta.s.sysId.ptNmb != NULLP)
555 SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
558 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
559 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
562 cfm.hdr.transId = sta->hdr.transId;
564 /* Check if General Config Done */
565 if(rgCb[inst].rgInit.cfgDone != TRUE)
567 SGetDateTime(&cfm.t.ssta.dt);
568 if (SGetSBuf(cfmPst.region, cfmPst.pool,
569 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
572 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
575 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
576 rgGetSId(&cfm.t.ssta.s.sysId);
577 cfm.cfm.status = LCM_PRIM_NOK;
578 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
579 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
580 RgMiLrgStaCfm(&cfmPst, &cfm);
581 RLOG0(L_ERROR, "Gen Cfg not done");
585 switch(sta->hdr.elmId.elmnt)
588 SGetDateTime(&cfm.t.ssta.dt);
589 if (SGetSBuf(cfmPst.region, cfmPst.pool,
590 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
593 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
596 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
597 rgGetSId(&cfm.t.ssta.s.sysId);
598 cfm.cfm.status = LCM_PRIM_OK;
599 cfm.cfm.reason = LCM_REASON_NOT_APPL;
600 RgMiLrgStaCfm(&cfmPst, &cfm);
603 cfm.cfm.status = LCM_PRIM_OK;
604 cfm.cfm.reason = LCM_REASON_NOT_APPL;
605 SGetDateTime(&cfm.t.ssta.dt);
606 cmMemcpy((U8 *)&(cfm.t.ssta.s.rguSapSta),
607 (U8 *)&rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
609 RgMiLrgStaCfm(&cfmPst, &cfm);
612 cfm.cfm.status = LCM_PRIM_OK;
613 cfm.cfm.reason = LCM_REASON_NOT_APPL;
614 SGetDateTime(&cfm.t.ssta.dt);
615 cmMemcpy((U8 *)&(cfm.t.ssta.s.crgSapSta), (U8 *)&rgCb[inst].crgSap.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.tfuSapSta), (U8 *)&rgCb[inst].tfuSap.sapSta,
625 RgMiLrgStaCfm(&cfmPst, &cfm);
628 cfm.cfm.status = LCM_PRIM_NOK;
629 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
630 RgMiLrgStaCfm(&cfmPst, &cfm);
631 RLOG1(L_ERROR, "Invalid elmnt=%d",sta->hdr.elmId.elmnt);
635 }/*-- RgMiLrgStaReq --*/
639 * @brief Layer Manager Control request handler.
643 * Function : RgMiLrgCntrlReq
645 * This function handles the control
646 * request received from the Layer Manager.
647 * -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
648 * and cntrl->t.cntrl.subAction, it performs the appropriate control action
649 * of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
650 * and layer shutdown.
651 * -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
653 * @param[in] Pst *pst, the post structure
654 * @param[in] RgMngmt *cntrl, the control parameter's structure
659 PUBLIC S16 RgMiLrgCntrlReq
661 Pst *pst, /* post structure */
662 RgMngmt *cntrl /* control structure */
665 PUBLIC S16 RgMiLrgCntrlReq(pst, cntrl)
666 Pst *pst; /* post structure */
667 RgMngmt *cntrl; /* control structure */
670 S16 ret = ROK; /* return value */
675 TRC2(RgMiLrgCntrlReq)
677 /* Fill the post structure for sending the confirmation */
679 RG_IS_INST_VALID(pst->dstInst);
680 inst = pst->dstInst - RG_INST_START;
682 rgLMMFillCfmPst(pst, &cfmPst, cntrl);
684 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
686 cfm.hdr.transId = cntrl->hdr.transId;
688 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
689 cfm.t.cntrl.action = cntrl->t.cntrl.action;
690 cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
692 /* Check if General Config Done*/
693 if(rgCb[inst].rgInit.cfgDone != TRUE)
695 cfm.cfm.status = LCM_PRIM_NOK;
696 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
697 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
698 RgMiLrgCntrlCfm(&cfmPst, &cfm);
699 RLOG0(L_ERROR, "Gen Cfg not done");
703 /* General Config done, process the Control request */
704 switch(cntrl->hdr.elmId.elmnt)
707 rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
712 rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
715 cfm.cfm.status = LCM_PRIM_NOK;
716 cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
717 RgMiLrgCntrlCfm(&cfmPst, &cfm);
718 RLOG1(L_ERROR, "invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
722 }/*-- RgMiLrgCntrlReq --*/
726 * @brief SAP Configuration Handler.
730 * Function : rgLMMSapCfg
732 * This function in called by RgMiLrgCfgReq(). It handles the
733 * interface SAP configuration of the LTE MAC layer. It
734 * initializes the sapState to LRG_UNBND. Returns
735 * reason for success/failure of this function.
737 * @param[in] Inst inst
738 * @param[in] RgCfg *cfg, the Configuaration information
740 * -# LCM_REASON_GENCFG_NOT_DONE
741 * -# LCM_REASON_INVALID_SAP
742 * -# LCM_REASON_NOT_APPL
745 PRIVATE U16 rgLMMSapCfg
748 RgCfg *cfg, /* Configuaration information */
749 Elmnt sapType /* Sap Type */
752 PRIVATE U16 rgLMMSapCfg(inst,cfg,sapType)
754 RgCfg *cfg; /* Configuaration information */
755 Elmnt sapType; /* Sap Type */
758 U16 ret = LCM_REASON_NOT_APPL;
759 RgLowSapCfgInfo *lowSapCfg = NULLP;
760 RgUpSapCfgInfo *upSapCfg = NULLP;
761 RgUpSapCb *upSapCb = NULLP;
765 /* Check if Gen Config has been done */
766 if(rgCb[inst].rgInit.cfgDone != TRUE)
767 RETVALUE(LCM_REASON_GENCFG_NOT_DONE);
772 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
773 (cfg->s.rguSap.selector != RGU_SEL_TC) &&
774 (cfg->s.rguSap.selector != RGU_SEL_LC))
776 ret = LCM_REASON_INVALID_PAR_VAL;
777 RLOG0(L_ERROR, "unsupported Selector value for RGU");
780 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
781 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
783 upSapCb->sapSta.sapState = LRG_UNBND;
785 upSapCfg = &(upSapCb->sapCfg);
786 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
787 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
788 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
789 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
790 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
791 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
792 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
793 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
794 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
795 upSapCfg->sapPst.route = cfg->s.rguSap.route;
796 upSapCfg->sapPst.intfVer = 0;
797 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
798 upSapCfg->suId = cfg->s.rguSap.suId;
799 upSapCfg->spId = cfg->s.rguSap.spId;
800 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
801 * there is cfg request with sap is 1*/
804 if ((cfg->s.crgSap.selector != CRG_SEL_TC) &&
805 (cfg->s.crgSap.selector != CRG_SEL_LC))
807 ret = LCM_REASON_INVALID_PAR_VAL;
808 RLOG0(L_ERROR, "unsupported Selector value for CRG");
811 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
813 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
815 upSapCfg = &rgCb[inst].crgSap.sapCfg;
817 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
818 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
819 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
820 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
821 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
822 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
823 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
824 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
825 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
826 upSapCfg->sapPst.route = cfg->s.crgSap.route;
827 upSapCfg->sapPst.intfVer = 0;
828 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
829 upSapCfg->suId = cfg->s.crgSap.suId;
830 upSapCfg->spId = cfg->s.crgSap.spId;
834 if ((cfg->s.tfuSap.selector != TFU_SEL_TC) &&
835 (cfg->s.tfuSap.selector != TFU_SEL_LC))
837 ret = LCM_REASON_INVALID_PAR_VAL;
838 RLOG0(L_ERROR, "unsupported Selector value for TFU");
842 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
844 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
846 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
848 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
849 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
850 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
851 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
852 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
853 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
854 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
855 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
856 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
857 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
858 lowSapCfg->sapPst.intfVer = 0;
859 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
860 lowSapCfg->suId = cfg->s.tfuSap.suId;
861 lowSapCfg->spId = cfg->s.tfuSap.spId;
862 cmMemcpy((U8 *)&lowSapCfg->bndTmr, (U8 *)&cfg->s.tfuSap.bndTmr,
866 /* would never reach here */
874 * @brief General Configuration Handler.
878 * Function : rgLMMGenCfg
880 * This function in called by RgMiLrgCfgReq(). It handles the
881 * general configuration of the LTE MAC layer. It initializes
882 * the hash lists of RgCb. Returns
883 * reason for success/failure of this function.
885 * @param[in] Inst inst
886 * @param[in] RgCfg *cfg, the Configuaration information
888 * -# LCM_REASON_NOT_APPL
889 * -# LCM_REASON_INVALID_MSGTYPE
890 * -# LCM_REASON_MEM_NOAVAIL
893 PRIVATE U16 rgLMMGenCfg
896 RgCfg *cfg /* Configuaration information */
899 PRIVATE U16 rgLMMGenCfg(inst,cfg)
901 RgCfg *cfg; /* Configuaration information */
904 U16 ret = LCM_REASON_NOT_APPL;
908 /* Check if General Configuration is done already */
909 if (rgCb[inst].rgInit.cfgDone == TRUE)
911 RETVALUE(LCM_REASON_INVALID_MSGTYPE);
913 if ((cfg->s.genCfg.lmPst.selector != LRG_SEL_TC) &&
914 (cfg->s.genCfg.lmPst.selector != LRG_SEL_LC))
916 RLOG0(L_ERROR, "unsupported Selector value for RGU");
917 RETVALUE(LCM_REASON_INVALID_PAR_VAL);
919 /* Update the Pst structure for LM interface */
920 cmMemcpy((U8 *)&rgCb[inst].rgInit.lmPst, (U8 *)&cfg->s.genCfg.lmPst,
923 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
924 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
925 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
926 rgCb[inst].rgInit.lmPst.event = EVTNONE;
928 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
929 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
930 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
931 /* Initialize SAP States */
932 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
934 if(cfg->s.genCfg.numRguSaps == 0)
936 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Invalid numRguSap.\n"));
940 /* allocate RGR saps */
941 if (SGetSBuf(rgCb[inst].rgInit.region,
942 rgCb[inst].rgInit.pool,
943 (Data **)&rgCb[inst].rguSap,
944 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
946 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Failed to allocate mem for RGU SAP's.\n"));
949 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
951 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
953 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
954 cmMemset((U8 *)&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
956 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
957 /* Initialize the timer blocks */
958 cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
959 /* Initialzie the timer queue */
960 cmMemset((U8 *)&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
961 /* Initialize the timer control point */
962 cmMemset((U8 *)&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
963 rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
964 /* Timer Registration request to SSI */
965 if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
966 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
969 RLOG0(L_ERROR, "Failed to register timer");
971 SPutSBuf(rgCb[inst].rgInit.region,
972 rgCb[inst].rgInit.pool,
973 (Data *)rgCb[inst].rguSap,
974 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
976 RETVALUE(LCM_REASON_MEM_NOAVAIL);
978 /* Set Config done in TskInit */
979 rgCb[inst].rgInit.cfgDone = TRUE;
985 /***********************************************************
987 * Func : rgLMMShutdown
990 * Desc : Handles the MAC layer shutdown request. Calls
991 * rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
1000 **********************************************************/
1002 PRIVATE Void rgLMMShutdown
1007 PRIVATE Void rgLMMShutdown(inst)
1011 RgCellCb *cell = rgCb[inst].cell;
1016 /* Unbind the TFU Sap */
1017 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
1019 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1020 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1022 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1024 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1026 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
1028 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1029 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1035 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1037 rgTOMRlsSf(inst,&cell->subFrms[idx]);
1040 rgCFGFreeCellCb(cell);
1043 /* Deleting the RGU SAPs */
1044 SPutSBuf(rgCb[inst].rgInit.region,
1045 rgCb[inst].rgInit.pool,
1046 (Data *)rgCb[inst].rguSap,
1047 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
1048 rgCb[inst].rguSap = NULLP;
1050 rgCb[inst].inactiveCell = NULLP;
1051 rgCb[inst].cell = NULLP;
1053 /* De-register the Timer Service */
1054 (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
1055 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr);
1057 /* call back the task initialization function to intialize
1058 * the global RgCb Struct */
1059 rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region,
1060 rgCb[inst].rgInit.reason);
1066 /***********************************************************
1068 * Func : rgLMMGenCntrl
1071 * Desc : Processes the LM control request for STGEN elmnt.
1080 **********************************************************/
1082 PRIVATE Void rgLMMGenCntrl
1089 PRIVATE Void rgLMMGenCntrl(cntrl, cfm, cfmPst)
1095 Inst inst = (cfmPst->srcInst - RG_INST_START);
1098 cfm->cfm.status = LCM_PRIM_OK;
1099 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1102 switch(cntrl->t.cntrl.action)
1105 /* Action is Enable */
1106 switch(cntrl->t.cntrl.subAction)
1110 rgCb[inst].rgInit.trc = TRUE;
1111 rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1112 /*Store the response and TransId for sending the Traces */
1113 cmMemcpy((U8 *)&rgCb[inst].genCfg.trcResp.response,
1114 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1115 rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1119 /* Enable Unsolicited Status (alarms) */
1120 rgCb[inst].rgInit.usta = TRUE;
1121 /*Store the response and TransId for sending the Alarms */
1122 cmMemcpy((U8 *)&rgCb[inst].genCfg.ustaResp.response,
1123 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1124 rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1127 /* Enable Debug Printing */
1129 rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1134 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1139 cfm->cfm.status = LCM_PRIM_NOK;
1140 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1141 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1146 /* Action is Diable immidiately */
1147 switch(cntrl->t.cntrl.subAction)
1150 /* Disable Traces */
1151 rgCb[inst].rgInit.trc = FALSE;
1154 /* Disable Unsolicited Status (alarms) */
1155 rgCb[inst].rgInit.usta = FALSE;
1158 /* Disable Debug Printing */
1160 rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1165 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1170 cfm->cfm.status = LCM_PRIM_NOK;
1171 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1172 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1177 /* Free all the memory dynamically allocated by MAC */
1178 rgLMMShutdown(inst);
1181 cfm->cfm.status = LCM_PRIM_NOK;
1182 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1183 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1186 RgMiLrgCntrlCfm(cfmPst, cfm);
1191 /***********************************************************
1193 * Func : rgLMMSapCntrl
1196 * Desc : Processes the LM control request for STxxxSAP elmnt.
1205 **********************************************************/
1207 PRIVATE Void rgLMMSapCntrl
1214 PRIVATE Void rgLMMSapCntrl(cntrl, cfm, cfmPst)
1220 Inst inst = cfmPst->srcInst - RG_INST_START;
1223 /* Only TFU Sap can be controlled by LM */
1224 switch(cntrl->hdr.elmId.elmnt)
1227 switch(cntrl->t.cntrl.action)
1230 /* Bind Enable Request */
1231 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1232 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1234 cfm->cfm.status = LCM_PRIM_NOK;
1235 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1239 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1241 rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val,
1242 (PTR)&rgCb[inst].tfuSap);
1244 /* Change SAP state */
1245 rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1246 rgCb[inst].tfuSap.numBndRetries++;
1247 /* Store the response and TransId for sending
1248 * the Control confirm */
1249 cmMemcpy((U8 *)&rgCb[inst].genCfg.bndCfmResp.response,
1250 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1251 rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1253 /* Sending Status Indication to Layer Manager */
1254 cfm->cfm.status = LCM_PRIM_OK_NDONE;
1255 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1256 RgMiLrgCntrlCfm(cfmPst, cfm);
1258 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1259 rgCb[inst].tfuSap.sapCfg.spId);
1264 /* Unbind request */
1266 /* Check if the SAP is configured */
1267 if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1268 (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1270 cfm->cfm.status = LCM_PRIM_NOK;
1271 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1275 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1276 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1278 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1280 /* Change SAP state */
1281 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1282 cfm->cfm.status = LCM_PRIM_OK;
1283 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1287 /* Delete SAP, does initialization of SAP */
1288 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1289 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1291 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1292 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1294 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1297 cmMemset((U8 *)&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1298 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1299 cfm->cfm.status = LCM_PRIM_OK;
1300 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1303 cfm->cfm.status = LCM_PRIM_NOK;
1304 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1305 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1306 cntrl->t.cntrl.action));
1311 switch(cntrl->t.cntrl.action)
1314 cmMemset((U8 *)&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1315 rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1316 cfm->cfm.status = LCM_PRIM_OK;
1317 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1320 cfm->cfm.status = LCM_PRIM_NOK;
1321 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1322 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1323 cntrl->t.cntrl.action));
1328 switch(cntrl->t.cntrl.action)
1331 cmMemset((U8 *)&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1332 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1333 cfm->cfm.status = LCM_PRIM_OK;
1334 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1337 cfm->cfm.status = LCM_PRIM_NOK;
1338 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1339 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1345 /* Would never here. */
1348 RgMiLrgCntrlCfm(cfmPst, cfm);
1353 /***********************************************************
1355 * Func : rgLMMFillCfmPst
1358 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
1359 * and the cfm->hdr.response.
1368 **********************************************************/
1370 PRIVATE Void rgLMMFillCfmPst
1377 PRIVATE Void rgLMMFillCfmPst(reqPst, cfmPst, cfm)
1384 TRC2(rgLMMFillCfmPst)
1385 inst = (reqPst->dstInst - RG_INST_START);
1387 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
1388 cfmPst->srcInst = rgCb[inst].rgInit.inst;
1389 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1390 cfmPst->dstEnt = reqPst->srcEnt;
1391 cfmPst->dstInst = reqPst->srcInst;
1392 cfmPst->dstProcId = reqPst->srcProcId;
1394 cfmPst->selector = cfm->hdr.response.selector;
1395 cfmPst->prior = cfm->hdr.response.prior;
1396 cfmPst->route = cfm->hdr.response.route;
1397 cfmPst->region = cfm->hdr.response.mem.region;
1398 cfmPst->pool = cfm->hdr.response.mem.pool;
1405 * @brief Timer start handler.
1409 * Function : rgLMMStartTmr
1411 * This function based on the input parameters starts the timer for
1412 * "tmrVal" duration. As of now MAC uses the timer functionality for
1413 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1415 * @param[in] Inst inst
1416 * @param[in] S16 tmrEvnt, the Timer Event
1417 * @param[in] U32 tmrVal, the Wait Time
1418 * @param[in] PTR cb, Entry for which Timer expired
1423 PUBLIC S16 rgLMMStartTmr
1426 S16 tmrEvnt, /* Timer Event */
1427 U32 tmrVal, /* Wait Time */
1428 PTR cb /* Entry for which Timer Expired */
1431 PUBLIC S16 rgLMMStartTmr(tmrEvnt, tmrVal, cb)
1433 S16 tmrEvnt; /* Timer Event */
1434 U32 tmrVal; /* Wait Time */
1435 PTR cb; /* Entry for which Timer Expired */
1444 /* Initialize the arg structure */
1445 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1447 arg.tqCp = &rgCb[inst].tmrTqCp;
1448 arg.tq = rgCb[inst].tmrTq;
1449 arg.timers = rgCb[inst].tmrBlk;
1452 arg.max = RG_MAX_TIMER;
1453 arg.evnt = RG_BNDREQ_TMR;
1462 * @brief Timer stop handler.
1466 * Function : rgLMMStopTmr
1468 * This function based on the input parameters stops the timer for
1469 * "tmrEvnt". As of now MAC uses the timer functionality for
1470 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1471 * Once the bind happens and this timer is stopped, the timer functionality
1472 * is deregistered with SSI. As there is no further use of timer processing.
1474 * @param[in] Inst inst
1475 * @param[in] S16 tmrEvnt, the Timer Event
1476 * @param[in] PTR cb, Entry for which Timer expired
1482 PUBLIC S16 rgLMMStopTmr
1484 Inst inst, /* Scheduler instance */
1485 S16 tmrEvnt, /* Timer Event */
1486 PTR cb /* Entry for which Timer Expired */
1489 PUBLIC S16 rgLMMStopTmr(inst,tmrEvnt, cb)
1490 Inst inst; /* Scheduler instance */
1491 S16 tmrEvnt; /* Timer Event */
1492 PTR cb; /* Entry for which Timer Expired */
1503 for(i=0;i<RG_MAX_TIMER;i++)
1505 /* Search for the Timer Blocks */
1506 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1508 /* Initialize the arg structure */
1509 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1511 arg.tqCp = &rgCb[inst].tmrTqCp;
1512 arg.tq = rgCb[inst].tmrTq;
1513 arg.timers = rgCb[inst].tmrBlk;
1515 arg.max = RG_MAX_TIMER;
1533 * @brief Timer Expiry handler.
1537 * Function : rgLMMTmrExpiry
1539 * This is a callback function used as an input parameter to cmPrcTmr()
1540 * to check expiry of any timer. In this function, the only concern is
1541 * about tmrEvnt=Bind timer.
1543 * @param[in] PTR cb, Entry for which Timer expired
1544 * @param[in] S16 tmrEvnt, the Timer Event
1549 PUBLIC S16 rgLMMTmrExpiry
1551 PTR cb, /* Pointer to timer control block */
1552 S16 tmrEvnt /* Timer Event */
1555 PUBLIC S16 rgLMMTmrExpiry(cb,tmrEvnt)
1556 PTR cb; /* Pointer to timer control block */
1557 S16 tmrEvnt; /* Timer Event */
1561 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1562 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1564 TRC2(rgLMMTmrExpiry)
1570 tfuSap->numBndRetries++;
1571 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1573 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1574 LCM_CAUSE_TMR_EXPIRED, NULLP);
1578 /* Restart the bind timer */
1579 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1581 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1585 /* Send bind request */
1586 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1587 rgCb[inst].tfuSap.sapCfg.spId);
1591 RLOG1(L_ERROR, "Invalid tmrEvnt=%d",tmrEvnt);
1601 * @brief Layer Manager Unsolicited Status Indication generation.
1605 * Function : rgLMMStaInd
1607 * This API is used by the other modules of MAC to send a unsolicited
1608 * status indication to the Layer Manager.
1610 * @param[in] Inst inst
1611 * @param[in] U16 category, the Alarm category
1612 * @param[in] U16 event, the Alarm event
1613 * @param[in] U16 cause, the cause of the Alarm
1614 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1619 PUBLIC S16 rgLMMStaInd
1628 PUBLIC S16 rgLMMStaInd(inst,category, event, cause, dgn)
1640 if(rgCb[inst].rgInit.usta == FALSE)
1645 cmMemset((U8 *)&usta, 0, sizeof(RgMngmt));
1647 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1648 usta.t.usta.cmAlarm.category = category;
1649 usta.t.usta.cmAlarm.event = event;
1650 usta.t.usta.cmAlarm.cause = cause;
1653 cmMemcpy((U8 *)&usta.t.usta.dgn, (U8 *)dgn, sizeof(RgUstaDgn));
1656 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1657 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1658 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1659 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1660 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1661 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1663 RETVALUE(RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1668 * @brief Layer Manager Trace Indication generation.
1672 * Function : rgLMMTrcInd
1674 * This API is used by the other modules of MAC to send a
1675 * Trace indication to the Layer Manager.
1677 * @param[in] Inst inst
1678 * @param[in] Buffer *srcMbuf, the Message Buffer .
1679 * @param[in] U8 event, the trace event.
1683 PUBLIC Void rgLMMTrcInd
1686 Buffer *srcMbuf, /* Message Buffer */
1687 U8 event /* event */
1690 PUBLIC Void rgLMMTrcInd(inst,srcMbuf,event)
1692 Buffer *srcMbuf; /* Message Buffer */
1693 U8 event; /* event */
1696 Buffer *dstMbuf = NULLP;
1706 if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1708 RLOG0(L_ERROR, "Trace Disabled.");
1712 cmMemset((U8 *)&trc, 0, sizeof(RgMngmt));
1714 pst = rgCb[inst].rgInit.lmPst;
1715 pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1716 pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1717 pst.route = rgCb[inst].genCfg.trcResp.response.route;
1718 pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1719 pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1721 trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1723 SGetDateTime(&trc.t.trc.dt);
1725 /* Check if the whole buffer is to be sent in Trace indication */
1726 if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1728 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1731 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1734 trc.cfm.status = LCM_PRIM_OK;
1735 trc.cfm.reason = LCM_REASON_NOT_APPL;
1736 trc.t.trc.evnt = event;
1738 /* Send Trace Indication to Layer manager */
1739 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1741 /* check if only a specified number of bytes are to be sent */
1742 else if(rgCb[inst].trcLen > 0)
1744 /* Get the length of the recvd message buffer */
1745 if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1747 RLOG0(L_ERROR, "SFndLenMsg Failed.");
1750 /* Check if the recvd buffer size is less than request trace len */
1751 if(bufLen < rgCb[inst].trcLen)
1753 /* Copy the whole of the recvd buffer in trace indication */
1755 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1758 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1762 trc.cfm.status = LCM_PRIM_OK;
1763 trc.cfm.reason = LCM_REASON_NOT_APPL;
1764 trc.t.trc.evnt = event;
1766 /* Send Trace Indication to Layer manager */
1767 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1769 /* if the recvd buffer size is greater than request trace len */
1770 if(bufLen >= rgCb[inst].trcLen)
1772 /* Get a temporary buffer to store the msg */
1773 if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1775 RLOG0(L_ERROR, "rgAllocSBuf Failed.");
1779 /* Copy trcLen nos of bytes from the recvd message */
1780 if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)
1782 RLOG0(L_ERROR, "SCpyMsgFix Failed.");
1786 if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1788 RLOG0(L_ERROR, "dstMbuf Allocation Failed");
1791 /* Copy the tempBuf data to dst mBuf */
1792 if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1794 RLOG0(L_ERROR, "SCpyFixMsg Failed.");
1798 /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1800 /* Free the memory allocated for tempBuf */
1801 rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1803 trc.cfm.status = LCM_PRIM_OK;
1804 trc.cfm.reason = LCM_REASON_NOT_APPL;
1805 trc.t.trc.evnt = event;
1807 /* Send Trace Indication to Layer manager */
1808 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1816 * @brief Layer Manager Control Confirm generation handler
1817 * for Bind Confirm reception at TFU interface.
1818 * RgLiTfuBndCfm() forwards the confirmation to this
1819 * function. All SAP state related handling is restricted
1820 * to LMM modules, hence the cfm forwarding.
1824 * Function : rgLMMBndCfm
1826 * This API is used by the LIM module of MAC to forward
1827 * the Bind Confirm it receives over the TFU interface.
1829 * @param[in] Pst *pst, Post Structure
1830 * @param[in] SuId suId, Service user ID
1831 * @param[in] U8 status, Status
1836 PUBLIC S16 rgLMMBndCfm
1838 Pst *pst, /* Post Structure */
1839 SuId suId, /* Service user ID */
1840 U8 status /* Status */
1843 PUBLIC S16 rgLMMBndCfm(pst,suId,status)
1844 Pst *pst; /* Post Structure */
1845 SuId suId; /* Service user ID */
1846 U8 status; /* Status */
1849 Inst inst = pst->dstInst - RG_INST_START;
1858 /* Check if the suId is valid */
1859 if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1861 RLOG0(L_ERROR, "Invalid SuId");
1865 /* check the Sap State */
1866 switch(rgCb[inst].tfuSap.sapSta.sapState)
1868 case LRG_WAIT_BNDCFM:
1871 /* SAP is already bound */
1877 cfmPst = rgCb[inst].rgInit.lmPst;
1878 cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1879 cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1880 cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1881 cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1882 cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1884 cmMemset((U8 *)&cntrlCfm, 0, sizeof(RgMngmt));
1888 case CM_BND_OK: /* status is OK */
1889 /* Change SAP state to Bound */
1890 rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1891 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1893 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1895 /* Send Control Confirm with status as OK to Layer Manager */
1896 cntrlCfm.cfm.status = LCM_PRIM_OK;
1897 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1901 /* Change SAP state to UnBound */
1902 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1903 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1905 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1907 /* Send Control Confirm with status as NOK to Layer Manager */
1908 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1909 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1912 rgCb[inst].tfuSap.numBndRetries = 0;
1913 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1914 cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1916 ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1923 * @brief LTE MAC timer call back function registered with SSI.
1927 * Function : rgActvTmr
1929 * This function is invoked by SSI for every timer activation
1936 PUBLIC S16 rgActvTmr
1942 PUBLIC S16 rgActvTmr(ent, inst)
1947 Inst macInst = (inst - RG_INST_START);
1950 /* Check if any MAC timer has expired */
1951 cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1955 } /* end of rgActvTmr */
1958 * @brief Layer Manager Configuration request handler for Scheduler
1962 * Function : MacSchGenCfgReq
1964 * This function receives general configurations for Scheduler
1965 * from DU APP and forwards to Scheduler.
1967 * @param[in] Pst *pst, the post structure
1968 * @param[in] RgMngmt *cfg, the configuration parameter's structure
1973 PUBLIC S16 MacSchGenCfgReq
1975 Pst *pst, /* post structure */
1976 RgMngmt *cfg /* config structure */
1979 PUBLIC S16 MacSchGenCfgReq(pst, cfg)
1980 Pst *pst; /* post structure */
1981 RgMngmt *cfg; /* config structure */
1984 printf("\nReceived Scheduler gen config at MAC");
1985 pst->dstInst = DEFAULT_CELLS + 1;
1986 HandleSchGenCfgReq(pst, cfg);
1992 * @brief Layer Manager Configuration response from Scheduler
1996 * Function : SchSendCfgCfm
1998 * This function sends general configurations response from
1999 * Scheduler to DU APP.
2001 * @param[in] Pst *pst, the post structure
2002 * @param[in] RgMngmt *cfm, the configuration confirm structure
2007 PUBLIC S16 SchSendCfgCfm
2009 Pst *pst, /* post structure */
2010 RgMngmt *cfm /* config confirm structure */
2013 PUBLIC S16 SchSendCfgCfm(pst, cfm)
2014 Pst *pst; /* post structure */
2015 RgMngmt *cfm; /* config confirm structure */
2018 printf("\nSending Scheduler config confirm to DU APP");
2019 RgMiLrgSchCfgCfm(pst, cfm);
2025 * @brief Layer Manager Configuration request handler.
2029 * Function : MacSchCfgReq
2031 * This function handles the gNB and cell configuration
2032 * request received from DU APP.
2033 * This API unapcks and forwards the config towards SCH
2035 * @param[in] Pst *pst
2036 * @param[in] RgrCfgTransId transId
2037 * @param[in] RgrCfgReqInfo *cfgReqInfo
2042 PUBLIC S16 MacSchCfgReq
2045 RgrCfgTransId transId,
2046 RgrCfgReqInfo *cfgReqInfo
2049 PUBLIC S16 MacSchCfgReq(pst, transId, cfgReqInfo)
2051 RgrCfgTransId transId;
2052 RgrCfgReqInfo *cfgReqInfo;
2055 printf("\nReceived Scheduler config at MAC");
2056 pst->dstInst = DEFAULT_CELLS + 1;
2057 HandleSchCfgReq(pst, transId, cfgReqInfo);
2061 } /* end of MacSchCfgReq*/
2064 /***********************************************************
2066 * Func : macCellCfgFillCfmPst
2069 * Desc : Fills the Confirmation Post Structure cfmPst
2077 **********************************************************/
2078 Void macCellCfgFillCfmPst
2085 inst = reqPst->dstInst;
2087 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
2088 cfmPst->srcInst = rgCb[inst].rgInit.inst;
2089 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
2091 cfmPst->srcEnt = reqPst->dstEnt;
2092 cfmPst->dstEnt = reqPst->srcEnt;
2093 cfmPst->srcInst = reqPst->dstInst;
2094 cfmPst->dstInst = reqPst->srcInst;
2095 cfmPst->srcProcId = reqPst->dstProcId;
2096 cfmPst->dstProcId = reqPst->srcProcId;
2098 cfmPst->selector = LRG_SEL_LC;
2099 cfmPst->prior = reqPst->prior;
2100 cfmPst->route = reqPst->route;
2101 cfmPst->region = reqPst->region;
2102 cfmPst->pool = reqPst->pool;
2103 cfmPst->event = EVENT_MAC_CELL_CONFIG_CFM;
2109 * @brief Layer Manager Configuration request handler.
2113 * Function : MacHdlCellCfgReq
2115 * This function handles the gNB and cell configuration
2116 * request received from DU APP.
2117 * This API unapcks and forwards the config towards SCH
2119 * @param[in] Pst *pst
2120 * @param[in] MacCellCfg *macCellCfg
2124 S16 MacHdlCellCfgReq
2127 MacCellCfg *macCellCfg
2131 MacCellCfgCfm macCellCfgCfm;
2134 Inst inst = pst->dstInst;
2136 cellCb = rgCb[inst].cell;
2137 MAC_ALLOC(cellCb,sizeof(RgCellCb));
2141 DU_LOG("\nMAC : cellCb is NULL at handling of macCellCfg\n");
2145 memcpy(&cellCb->macCellCfg,macCellCfg,sizeof(MacCellCfg));
2147 macCellCfgFillCfmPst(pst,&cnfPst);
2149 macCellCfgCfm.transId = macCellCfg->transId;
2151 ret = (*packMacCellCfmOpts[cnfPst.selector])(&cnfPst,&macCellCfgCfm);
2153 } /* end of MacHdlCellCfgReq */
2156 /**********************************************************************
2159 **********************************************************************/