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 "mac_sch_interface.h"
81 #include "rg.x" /* MAC includes */
83 #include "ss_diag.h" /* Common log file */
88 #include "lwr_mac.h" /* MAC CL defines */
92 #endif /* __cplusplus */
93 EXTERN Void rgGetSId ARGS((SystemId *s));
96 #endif /* __cplusplus */
98 /* Public variable declaration */
101 /* forward references */
102 PRIVATE U16 rgLMMGenCfg ARGS((
107 PRIVATE U16 rgLMMSapCfg ARGS((
113 PRIVATE Void rgLMMShutdown ARGS((
117 PRIVATE Void rgLMMFillCfmPst ARGS((
123 PRIVATE Void rgLMMGenCntrl ARGS((
129 PRIVATE Void rgLMMSapCntrl ARGS((
135 extern U16 packMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm);
137 packMacCellCfgConfirm packMacCellCfmOpts[] =
139 packMacCellCfgCfm, /* packing for loosely coupled */
140 duHandleMacCellCfgCfm, /* packing for tightly coupled */
141 packMacCellCfgCfm, /* packing for light weight loosly coupled */
144 SchCellCfgFunc SchCellCfgOpts[] =
146 packSchCellCfg, /* packing for loosely coupled */
147 SchHdlCellCfgReq, /* packing for tightly coupled */
148 packSchCellCfg /* packing for light weight loosly coupled */
153 * @brief Task Initiation callback function.
157 * Function : rgActvInit
159 * This function is supplied as one of parameters during MAC's
160 * task registration. SSI will invoke this function once, after
161 * it creates and attaches this TAPA Task to a system task.
163 * @param[in] Ent entity, the entity ID of this task.
164 * @param[in] Inst inst, the instance ID of this task.
165 * @param[in] Region region, the region ID registered for memory
166 * usage of this task.
167 * @param[in] Reason reason.
172 PUBLIC S16 rgActvInit
174 Ent entity, /* entity */
175 Inst inst, /* instance */
176 Region region, /* region */
177 Reason reason /* reason */
180 PUBLIC S16 rgActvInit(entity, inst, region, reason)
181 Ent entity; /* entity */
182 Inst inst; /* instance */
183 Region region; /* region */
184 Reason reason; /* reason */
190 RG_IS_INST_VALID(inst);
192 macInst = inst - RG_INST_START;
193 /* Initialize the MAC TskInit structure to zero */
194 cmMemset ((U8 *)&rgCb[macInst], 0, sizeof(RgCb));
196 /* Initialize the MAC TskInit with received values */
197 rgCb[macInst].rgInit.ent = entity;
198 rgCb[macInst].rgInit.inst = inst;
199 rgCb[macInst].rgInit.region = region;
200 rgCb[macInst].rgInit.pool = 0;
201 rgCb[macInst].rgInit.reason = reason;
202 rgCb[macInst].rgInit.cfgDone = FALSE;
203 rgCb[macInst].rgInit.acnt = FALSE;
204 rgCb[macInst].rgInit.usta = FALSE;
205 rgCb[macInst].rgInit.trc = FALSE;
206 rgCb[macInst].trcLen = 0;
209 /* disabling debugs by default */
210 rgCb[macInst].rgInit.dbgMask = 0xffffffff;
214 rgCb[macInst].rgInit.logMask = 0x0;
216 rgCb[macInst].rgInit.procId = SFndProcId();
217 rgCb[macInst].tfuSap.numBndRetries = 0;
219 /* Initialize Sap state */
220 rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
221 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
222 rgCb[macInst].rguSap = NULLP;
223 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
225 rgCb[macInst].inactiveCell = NULLP;
226 rgCb[macInst].cell = NULLP;
228 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
229 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
232 /* Initializing CL control block */
233 clGlobalCp.region = region;
235 clGlobalCp.clCfgDone = FALSE;
236 clGlobalCp.numOfCells = 0;
237 clGlobalCp.phyState = PHY_STATE_IDLE;
239 if( cmHashListInit(&clGlobalCp.cellCbLst, MAX_NUM_CELL_SUPP, 0x0, FALSE,
240 CM_HASH_KEYTYPE_DEF, clGlobalCp.region, clGlobalCp.pool ) != ROK )
242 printf("\n Cellcb hash list initialization failed for MAC CL");
246 /* Initialize Scheduler as well */
247 schActvInit(ENTRG, (DEFAULT_CELLS + SCH_INST_START), DFLT_REGION, PWR_UP);
254 * @brief Layer Manager Configuration request handler.
258 * Function : RgMiLrgCfgReq
260 * This function handles the configuration
261 * request received from the Layer Manager.
262 * -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
263 * functions rgHdlGenCfg() or rgHdlSapCfg().
264 * -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
266 * @param[in] Pst *pst, the post structure
267 * @param[in] RgMngmt *cfg, the configuration parameter's structure
272 PUBLIC S16 RgMiLrgCfgReq
274 Pst *pst, /* post structure */
275 RgMngmt *cfg /* config structure */
278 PUBLIC S16 RgMiLrgCfgReq(pst, cfg)
279 Pst *pst; /* post structure */
280 RgMngmt *cfg; /* config structure */
283 U16 ret = LCM_PRIM_OK;
284 U16 reason = LCM_REASON_NOT_APPL;
292 RG_DIAG_LVL0(inst,0x0a0b0001, RG_DIAG_NA, SS_DIAG_INV_ARG,
293 "Received CfgReq for MAC layer, Entity = %d, Instance = %d\n",
294 pst->srcEnt, pst->srcInst,0,0);
296 RG_IS_INST_VALID(pst->dstInst);
297 inst = pst->dstInst - RG_INST_START;
299 /* Fill the post structure for sending the confirmation */
300 rgLMMFillCfmPst(pst, &cfmPst, cfg);
302 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
305 cfm.hdr.transId = cfg->hdr.transId;
309 cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
310 switch(cfg->hdr.elmId.elmnt)
313 reason = rgLMMGenCfg(inst,&cfg->t.cfg);
318 reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
322 reason = LCM_REASON_INVALID_ELMNT;
323 RLOG1(L_ERROR, "Invalid Elmnt=%d",
324 cfg->hdr.elmId.elmnt);
328 if (reason != LCM_REASON_NOT_APPL)
333 cfm.cfm.status = ret;
334 cfm.cfm.reason = reason;
336 RgMiLrgCfgCfm(&cfmPst, &cfm);
339 }/*-- RgMiLrgCfgReq --*/
343 * @brief Layer Manager Statistics request handler.
347 * Function : RgMiLrgStsReq
349 * This function handles the statistics
350 * request received from the Layer Manager.
351 * -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
352 * statistics from the rgCb global control block.
353 * -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
354 * -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
356 * @param[in] Pst *pst, the post structure
357 * @param[in] RgMngmt *sts, the statistics parameter's structure
362 PUBLIC S16 RgMiLrgStsReq
364 Pst *pst, /* post structure */
365 RgMngmt *sts /* statistics structure */
368 PUBLIC S16 RgMiLrgStsReq(pst, sts)
369 Pst *pst; /* post structure */
370 RgMngmt *sts; /* statistics structure */
380 RG_IS_INST_VALID(pst->dstInst);
381 inst = pst->dstInst - RG_INST_START;
382 /* Fill the post structure for sending the confirmation */
383 rgLMMFillCfmPst(pst, &cfmPst, sts);
385 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
388 cfm.hdr.transId = sts->hdr.transId;
390 SGetDateTime(&cfm.t.sts.dt);
391 cfm.cfm.status = LCM_PRIM_OK;
392 cfm.cfm.reason = LCM_REASON_NOT_APPL;
393 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
394 cfm.t.sts.action = sts->t.sts.action;
396 /* Check if General Config Done */
397 if(rgCb[inst].rgInit.cfgDone != TRUE)
399 cfm.cfm.status = LCM_PRIM_NOK;
400 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
401 RgMiLrgStsCfm(&cfmPst,&cfm);
402 RLOG0(L_ERROR, "Gen Cfg not done");
406 switch(sts->hdr.elmId.elmnt)
410 cmMemcpy((U8 *)&(cfm.t.sts.s.genSts), (U8 *)&rgCb[inst].genSts,
412 /* check if action is read and reset */
413 if(sts->t.sts.action == ARST)
415 rgCb[inst].genSts.numHarqFail = 0;
420 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
422 for(cqi=0; cqi <= 14; cqi++)
424 /* Filling DL ACK/NACK stats */
425 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
426 hqFailStats.dlCqiStat[cqi].mcs;
427 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
428 hqFailStats.dlCqiStat[cqi].numOfNacks;
429 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
430 hqFailStats.dlCqiStat[cqi].numOfAcks;
432 /* Filling UL ACK/NACK stats */
433 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
434 hqFailStats.ulCqiStat[cqi].mcs;
435 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
436 hqFailStats.ulCqiStat[cqi].numOfNacks;
437 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
438 hqFailStats.ulCqiStat[cqi].numOfAcks;
440 /* Filling DL HQ Retx stats */
441 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
442 hqRetxStats.dlCqiStat[cqi].mcs;
443 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
444 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
445 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
446 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
447 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
448 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
449 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
450 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
451 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
452 hqRetxStats.dlCqiStat[cqi].totalTx;
454 /* Filling UL HQ Retx stats */
455 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
456 hqRetxStats.ulCqiStat[cqi].mcs;
457 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
458 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
459 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
460 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
461 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
462 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
463 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
464 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
465 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
466 hqRetxStats.ulCqiStat[cqi].totalTx;
468 /* Reset statistics */
469 if(sts->t.sts.action == ZEROSTS)
471 cmMemset((U8 *)&hqRetxStats, 0, \
472 sizeof(RgSchHqRetxStats));
473 cmMemset((U8 *)&hqFailStats, 0, \
474 sizeof(RgSchNackAckStats));
477 #endif /* MAC_SCH_STATS*/
481 cmMemcpy((U8 *)&(cfm.t.sts.s.rguSts), (U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
484 /* check if action is read and reset */
485 if(sts->t.sts.action == ARST)
486 cmMemset((U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
490 cmMemcpy((U8 *)&(cfm.t.sts.s.crgSts), (U8 *)&rgCb[inst].crgSap.sapSts,
493 /* check if action is read and reset */
494 if(sts->t.sts.action == ARST)
495 cmMemset((U8 *)&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
499 cmMemcpy((U8 *)&(cfm.t.sts.s.tfuSts), (U8 *)&rgCb[inst].tfuSap.sapSts,
502 /* check if action is read and reset */
503 if(sts->t.sts.action == ARST)
504 cmMemset((U8 *)&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
508 cfm.cfm.status = LCM_PRIM_NOK;
509 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
510 RLOG1(L_ERROR, "Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
513 RgMiLrgStsCfm(&cfmPst,&cfm);
515 }/*-- RgMiLrgStsReq --*/
519 * @brief Layer Manager Status request handler.
523 * Function : RgMiLrgStaReq
525 * This function handles the solicited status
526 * request received from the Layer Manager.
527 * -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
528 * particular SAP from the rgCb global control block.
529 * -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
531 * @param[in] Pst *pst, the post structure
532 * @param[in] RgMngmt *sta, the status parameter's structure
537 PUBLIC S16 RgMiLrgStaReq
539 Pst *pst, /* post structure */
540 RgMngmt *sta /* status structure */
543 PUBLIC S16 RgMiLrgStaReq(pst, sta)
544 Pst *pst; /* post structure */
545 RgMngmt *sta; /* status structure */
555 RG_IS_INST_VALID(pst->dstInst);
556 inst = pst->dstInst - RG_INST_START;
559 /* Fill the post structure for sending the confirmation */
560 rgLMMFillCfmPst(pst, &cfmPst, sta);
562 if (sta->t.ssta.s.sysId.ptNmb != NULLP)
564 SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
567 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
568 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
571 cfm.hdr.transId = sta->hdr.transId;
573 /* Check if General Config Done */
574 if(rgCb[inst].rgInit.cfgDone != TRUE)
576 SGetDateTime(&cfm.t.ssta.dt);
577 if (SGetSBuf(cfmPst.region, cfmPst.pool,
578 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
581 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
584 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
585 rgGetSId(&cfm.t.ssta.s.sysId);
586 cfm.cfm.status = LCM_PRIM_NOK;
587 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
588 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
589 RgMiLrgStaCfm(&cfmPst, &cfm);
590 RLOG0(L_ERROR, "Gen Cfg not done");
594 switch(sta->hdr.elmId.elmnt)
597 SGetDateTime(&cfm.t.ssta.dt);
598 if (SGetSBuf(cfmPst.region, cfmPst.pool,
599 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
602 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
605 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
606 rgGetSId(&cfm.t.ssta.s.sysId);
607 cfm.cfm.status = LCM_PRIM_OK;
608 cfm.cfm.reason = LCM_REASON_NOT_APPL;
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.rguSapSta),
616 (U8 *)&rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
618 RgMiLrgStaCfm(&cfmPst, &cfm);
621 cfm.cfm.status = LCM_PRIM_OK;
622 cfm.cfm.reason = LCM_REASON_NOT_APPL;
623 SGetDateTime(&cfm.t.ssta.dt);
624 cmMemcpy((U8 *)&(cfm.t.ssta.s.crgSapSta), (U8 *)&rgCb[inst].crgSap.sapSta,
626 RgMiLrgStaCfm(&cfmPst, &cfm);
629 cfm.cfm.status = LCM_PRIM_OK;
630 cfm.cfm.reason = LCM_REASON_NOT_APPL;
631 SGetDateTime(&cfm.t.ssta.dt);
632 cmMemcpy((U8 *)&(cfm.t.ssta.s.tfuSapSta), (U8 *)&rgCb[inst].tfuSap.sapSta,
634 RgMiLrgStaCfm(&cfmPst, &cfm);
637 cfm.cfm.status = LCM_PRIM_NOK;
638 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
639 RgMiLrgStaCfm(&cfmPst, &cfm);
640 RLOG1(L_ERROR, "Invalid elmnt=%d",sta->hdr.elmId.elmnt);
644 }/*-- RgMiLrgStaReq --*/
648 * @brief Layer Manager Control request handler.
652 * Function : RgMiLrgCntrlReq
654 * This function handles the control
655 * request received from the Layer Manager.
656 * -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
657 * and cntrl->t.cntrl.subAction, it performs the appropriate control action
658 * of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
659 * and layer shutdown.
660 * -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
662 * @param[in] Pst *pst, the post structure
663 * @param[in] RgMngmt *cntrl, the control parameter's structure
668 PUBLIC S16 RgMiLrgCntrlReq
670 Pst *pst, /* post structure */
671 RgMngmt *cntrl /* control structure */
674 PUBLIC S16 RgMiLrgCntrlReq(pst, cntrl)
675 Pst *pst; /* post structure */
676 RgMngmt *cntrl; /* control structure */
679 S16 ret = ROK; /* return value */
684 TRC2(RgMiLrgCntrlReq)
686 /* Fill the post structure for sending the confirmation */
688 RG_IS_INST_VALID(pst->dstInst);
689 inst = pst->dstInst - RG_INST_START;
691 rgLMMFillCfmPst(pst, &cfmPst, cntrl);
693 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
695 cfm.hdr.transId = cntrl->hdr.transId;
697 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
698 cfm.t.cntrl.action = cntrl->t.cntrl.action;
699 cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
701 /* Check if General Config Done*/
702 if(rgCb[inst].rgInit.cfgDone != TRUE)
704 cfm.cfm.status = LCM_PRIM_NOK;
705 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
706 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
707 RgMiLrgCntrlCfm(&cfmPst, &cfm);
708 RLOG0(L_ERROR, "Gen Cfg not done");
712 /* General Config done, process the Control request */
713 switch(cntrl->hdr.elmId.elmnt)
716 rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
721 rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
724 cfm.cfm.status = LCM_PRIM_NOK;
725 cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
726 RgMiLrgCntrlCfm(&cfmPst, &cfm);
727 RLOG1(L_ERROR, "invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
731 }/*-- RgMiLrgCntrlReq --*/
735 * @brief SAP Configuration Handler.
739 * Function : rgLMMSapCfg
741 * This function in called by RgMiLrgCfgReq(). It handles the
742 * interface SAP configuration of the LTE MAC layer. It
743 * initializes the sapState to LRG_UNBND. Returns
744 * reason for success/failure of this function.
746 * @param[in] Inst inst
747 * @param[in] RgCfg *cfg, the Configuaration information
749 * -# LCM_REASON_GENCFG_NOT_DONE
750 * -# LCM_REASON_INVALID_SAP
751 * -# LCM_REASON_NOT_APPL
754 PRIVATE U16 rgLMMSapCfg
757 RgCfg *cfg, /* Configuaration information */
758 Elmnt sapType /* Sap Type */
761 PRIVATE U16 rgLMMSapCfg(inst,cfg,sapType)
763 RgCfg *cfg; /* Configuaration information */
764 Elmnt sapType; /* Sap Type */
767 U16 ret = LCM_REASON_NOT_APPL;
768 RgLowSapCfgInfo *lowSapCfg = NULLP;
769 RgUpSapCfgInfo *upSapCfg = NULLP;
770 RgUpSapCb *upSapCb = NULLP;
774 /* Check if Gen Config has been done */
775 if(rgCb[inst].rgInit.cfgDone != TRUE)
776 RETVALUE(LCM_REASON_GENCFG_NOT_DONE);
781 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
782 (cfg->s.rguSap.selector != RGU_SEL_TC) &&
783 (cfg->s.rguSap.selector != RGU_SEL_LC))
785 ret = LCM_REASON_INVALID_PAR_VAL;
786 RLOG0(L_ERROR, "unsupported Selector value for RGU");
789 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
790 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
792 upSapCb->sapSta.sapState = LRG_UNBND;
794 upSapCfg = &(upSapCb->sapCfg);
795 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
796 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
797 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
798 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
799 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
800 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
801 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
802 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
803 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
804 upSapCfg->sapPst.route = cfg->s.rguSap.route;
805 upSapCfg->sapPst.intfVer = 0;
806 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
807 upSapCfg->suId = cfg->s.rguSap.suId;
808 upSapCfg->spId = cfg->s.rguSap.spId;
809 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
810 * there is cfg request with sap is 1*/
813 if ((cfg->s.crgSap.selector != CRG_SEL_TC) &&
814 (cfg->s.crgSap.selector != CRG_SEL_LC))
816 ret = LCM_REASON_INVALID_PAR_VAL;
817 RLOG0(L_ERROR, "unsupported Selector value for CRG");
820 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
822 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
824 upSapCfg = &rgCb[inst].crgSap.sapCfg;
826 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
827 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
828 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
829 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
830 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
831 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
832 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
833 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
834 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
835 upSapCfg->sapPst.route = cfg->s.crgSap.route;
836 upSapCfg->sapPst.intfVer = 0;
837 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
838 upSapCfg->suId = cfg->s.crgSap.suId;
839 upSapCfg->spId = cfg->s.crgSap.spId;
843 if ((cfg->s.tfuSap.selector != TFU_SEL_TC) &&
844 (cfg->s.tfuSap.selector != TFU_SEL_LC))
846 ret = LCM_REASON_INVALID_PAR_VAL;
847 RLOG0(L_ERROR, "unsupported Selector value for TFU");
851 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
853 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
855 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
857 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
858 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
859 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
860 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
861 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
862 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
863 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
864 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
865 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
866 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
867 lowSapCfg->sapPst.intfVer = 0;
868 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
869 lowSapCfg->suId = cfg->s.tfuSap.suId;
870 lowSapCfg->spId = cfg->s.tfuSap.spId;
871 cmMemcpy((U8 *)&lowSapCfg->bndTmr, (U8 *)&cfg->s.tfuSap.bndTmr,
875 /* would never reach here */
883 * @brief General Configuration Handler.
887 * Function : rgLMMGenCfg
889 * This function in called by RgMiLrgCfgReq(). It handles the
890 * general configuration of the LTE MAC layer. It initializes
891 * the hash lists of RgCb. Returns
892 * reason for success/failure of this function.
894 * @param[in] Inst inst
895 * @param[in] RgCfg *cfg, the Configuaration information
897 * -# LCM_REASON_NOT_APPL
898 * -# LCM_REASON_INVALID_MSGTYPE
899 * -# LCM_REASON_MEM_NOAVAIL
902 PRIVATE U16 rgLMMGenCfg
905 RgCfg *cfg /* Configuaration information */
908 PRIVATE U16 rgLMMGenCfg(inst,cfg)
910 RgCfg *cfg; /* Configuaration information */
913 U16 ret = LCM_REASON_NOT_APPL;
917 /* Check if General Configuration is done already */
918 if (rgCb[inst].rgInit.cfgDone == TRUE)
920 RETVALUE(LCM_REASON_INVALID_MSGTYPE);
922 if ((cfg->s.genCfg.lmPst.selector != LRG_SEL_TC) &&
923 (cfg->s.genCfg.lmPst.selector != LRG_SEL_LC))
925 RLOG0(L_ERROR, "unsupported Selector value for RGU");
926 RETVALUE(LCM_REASON_INVALID_PAR_VAL);
928 /* Update the Pst structure for LM interface */
929 cmMemcpy((U8 *)&rgCb[inst].rgInit.lmPst, (U8 *)&cfg->s.genCfg.lmPst,
932 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
933 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
934 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
935 rgCb[inst].rgInit.lmPst.event = EVTNONE;
937 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
938 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
939 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
940 /* Initialize SAP States */
941 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
943 if(cfg->s.genCfg.numRguSaps == 0)
945 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Invalid numRguSap.\n"));
949 /* allocate RGR saps */
950 if (SGetSBuf(rgCb[inst].rgInit.region,
951 rgCb[inst].rgInit.pool,
952 (Data **)&rgCb[inst].rguSap,
953 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
955 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Failed to allocate mem for RGU SAP's.\n"));
958 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
960 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
962 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
963 cmMemset((U8 *)&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
965 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
966 /* Initialize the timer blocks */
967 cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
968 /* Initialzie the timer queue */
969 cmMemset((U8 *)&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
970 /* Initialize the timer control point */
971 cmMemset((U8 *)&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
972 rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
974 /* Timer Registration request to SSI */
975 if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
976 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
979 RLOG0(L_ERROR, "Failed to register timer");
981 SPutSBuf(rgCb[inst].rgInit.region,
982 rgCb[inst].rgInit.pool,
983 (Data *)rgCb[inst].rguSap,
984 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
986 RETVALUE(LCM_REASON_MEM_NOAVAIL);
989 /* Set Config done in TskInit */
990 rgCb[inst].rgInit.cfgDone = TRUE;
996 /***********************************************************
998 * Func : rgLMMShutdown
1001 * Desc : Handles the MAC layer shutdown request. Calls
1002 * rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
1011 **********************************************************/
1013 PRIVATE Void rgLMMShutdown
1018 PRIVATE Void rgLMMShutdown(inst)
1022 RgCellCb *cell = rgCb[inst].cell;
1027 /* Unbind the TFU Sap */
1028 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
1030 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1031 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1033 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1035 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1037 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
1039 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1040 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1046 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1048 rgTOMRlsSf(inst,&cell->subFrms[idx]);
1051 rgCFGFreeCellCb(cell);
1054 /* Deleting the RGU SAPs */
1055 SPutSBuf(rgCb[inst].rgInit.region,
1056 rgCb[inst].rgInit.pool,
1057 (Data *)rgCb[inst].rguSap,
1058 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
1059 rgCb[inst].rguSap = NULLP;
1061 rgCb[inst].inactiveCell = NULLP;
1062 rgCb[inst].cell = NULLP;
1064 /* De-register the Timer Service */
1065 (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
1066 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr);
1068 /* call back the task initialization function to intialize
1069 * the global RgCb Struct */
1070 rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region,
1071 rgCb[inst].rgInit.reason);
1077 /***********************************************************
1079 * Func : rgLMMGenCntrl
1082 * Desc : Processes the LM control request for STGEN elmnt.
1091 **********************************************************/
1093 PRIVATE Void rgLMMGenCntrl
1100 PRIVATE Void rgLMMGenCntrl(cntrl, cfm, cfmPst)
1106 Inst inst = (cfmPst->srcInst - RG_INST_START);
1109 cfm->cfm.status = LCM_PRIM_OK;
1110 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1113 switch(cntrl->t.cntrl.action)
1116 /* Action is Enable */
1117 switch(cntrl->t.cntrl.subAction)
1121 rgCb[inst].rgInit.trc = TRUE;
1122 rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1123 /*Store the response and TransId for sending the Traces */
1124 cmMemcpy((U8 *)&rgCb[inst].genCfg.trcResp.response,
1125 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1126 rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1130 /* Enable Unsolicited Status (alarms) */
1131 rgCb[inst].rgInit.usta = TRUE;
1132 /*Store the response and TransId for sending the Alarms */
1133 cmMemcpy((U8 *)&rgCb[inst].genCfg.ustaResp.response,
1134 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1135 rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1138 /* Enable Debug Printing */
1140 rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1145 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1150 cfm->cfm.status = LCM_PRIM_NOK;
1151 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1152 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1157 /* Action is Diable immidiately */
1158 switch(cntrl->t.cntrl.subAction)
1161 /* Disable Traces */
1162 rgCb[inst].rgInit.trc = FALSE;
1165 /* Disable Unsolicited Status (alarms) */
1166 rgCb[inst].rgInit.usta = FALSE;
1169 /* Disable Debug Printing */
1171 rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1176 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1181 cfm->cfm.status = LCM_PRIM_NOK;
1182 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1183 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1188 /* Free all the memory dynamically allocated by MAC */
1189 rgLMMShutdown(inst);
1192 cfm->cfm.status = LCM_PRIM_NOK;
1193 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1194 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1197 RgMiLrgCntrlCfm(cfmPst, cfm);
1202 /***********************************************************
1204 * Func : rgLMMSapCntrl
1207 * Desc : Processes the LM control request for STxxxSAP elmnt.
1216 **********************************************************/
1218 PRIVATE Void rgLMMSapCntrl
1225 PRIVATE Void rgLMMSapCntrl(cntrl, cfm, cfmPst)
1231 Inst inst = cfmPst->srcInst - RG_INST_START;
1234 /* Only TFU Sap can be controlled by LM */
1235 switch(cntrl->hdr.elmId.elmnt)
1238 switch(cntrl->t.cntrl.action)
1241 /* Bind Enable Request */
1242 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1243 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1245 cfm->cfm.status = LCM_PRIM_NOK;
1246 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1250 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1252 rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val,
1253 (PTR)&rgCb[inst].tfuSap);
1255 /* Change SAP state */
1256 rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1257 rgCb[inst].tfuSap.numBndRetries++;
1258 /* Store the response and TransId for sending
1259 * the Control confirm */
1260 cmMemcpy((U8 *)&rgCb[inst].genCfg.bndCfmResp.response,
1261 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1262 rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1264 /* Sending Status Indication to Layer Manager */
1265 cfm->cfm.status = LCM_PRIM_OK_NDONE;
1266 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1267 RgMiLrgCntrlCfm(cfmPst, cfm);
1269 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1270 rgCb[inst].tfuSap.sapCfg.spId);
1275 /* Unbind request */
1277 /* Check if the SAP is configured */
1278 if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1279 (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1281 cfm->cfm.status = LCM_PRIM_NOK;
1282 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1286 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1287 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1289 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1291 /* Change SAP state */
1292 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1293 cfm->cfm.status = LCM_PRIM_OK;
1294 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1298 /* Delete SAP, does initialization of SAP */
1299 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1300 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1302 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1303 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1305 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1308 cmMemset((U8 *)&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1309 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1310 cfm->cfm.status = LCM_PRIM_OK;
1311 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1314 cfm->cfm.status = LCM_PRIM_NOK;
1315 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1316 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1317 cntrl->t.cntrl.action));
1322 switch(cntrl->t.cntrl.action)
1325 cmMemset((U8 *)&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1326 rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1327 cfm->cfm.status = LCM_PRIM_OK;
1328 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1331 cfm->cfm.status = LCM_PRIM_NOK;
1332 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1333 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1334 cntrl->t.cntrl.action));
1339 switch(cntrl->t.cntrl.action)
1342 cmMemset((U8 *)&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1343 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1344 cfm->cfm.status = LCM_PRIM_OK;
1345 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1348 cfm->cfm.status = LCM_PRIM_NOK;
1349 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1350 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1356 /* Would never here. */
1359 RgMiLrgCntrlCfm(cfmPst, cfm);
1364 /***********************************************************
1366 * Func : rgLMMFillCfmPst
1369 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
1370 * and the cfm->hdr.response.
1379 **********************************************************/
1381 PRIVATE Void rgLMMFillCfmPst
1388 PRIVATE Void rgLMMFillCfmPst(reqPst, cfmPst, cfm)
1395 TRC2(rgLMMFillCfmPst)
1396 inst = (reqPst->dstInst - RG_INST_START);
1398 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
1399 cfmPst->srcInst = rgCb[inst].rgInit.inst;
1400 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1401 cfmPst->dstEnt = reqPst->srcEnt;
1402 cfmPst->dstInst = reqPst->srcInst;
1403 cfmPst->dstProcId = reqPst->srcProcId;
1405 cfmPst->selector = cfm->hdr.response.selector;
1406 cfmPst->prior = cfm->hdr.response.prior;
1407 cfmPst->route = cfm->hdr.response.route;
1408 cfmPst->region = cfm->hdr.response.mem.region;
1409 cfmPst->pool = cfm->hdr.response.mem.pool;
1416 * @brief Timer start handler.
1420 * Function : rgLMMStartTmr
1422 * This function based on the input parameters starts the timer for
1423 * "tmrVal" duration. As of now MAC uses the timer functionality for
1424 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1426 * @param[in] Inst inst
1427 * @param[in] S16 tmrEvnt, the Timer Event
1428 * @param[in] U32 tmrVal, the Wait Time
1429 * @param[in] PTR cb, Entry for which Timer expired
1434 PUBLIC S16 rgLMMStartTmr
1437 S16 tmrEvnt, /* Timer Event */
1438 U32 tmrVal, /* Wait Time */
1439 PTR cb /* Entry for which Timer Expired */
1442 PUBLIC S16 rgLMMStartTmr(tmrEvnt, tmrVal, cb)
1444 S16 tmrEvnt; /* Timer Event */
1445 U32 tmrVal; /* Wait Time */
1446 PTR cb; /* Entry for which Timer Expired */
1455 /* Initialize the arg structure */
1456 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1458 arg.tqCp = &rgCb[inst].tmrTqCp;
1459 arg.tq = rgCb[inst].tmrTq;
1460 arg.timers = rgCb[inst].tmrBlk;
1463 arg.max = RG_MAX_TIMER;
1464 arg.evnt = RG_BNDREQ_TMR;
1473 * @brief Timer stop handler.
1477 * Function : rgLMMStopTmr
1479 * This function based on the input parameters stops the timer for
1480 * "tmrEvnt". As of now MAC uses the timer functionality for
1481 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1482 * Once the bind happens and this timer is stopped, the timer functionality
1483 * is deregistered with SSI. As there is no further use of timer processing.
1485 * @param[in] Inst inst
1486 * @param[in] S16 tmrEvnt, the Timer Event
1487 * @param[in] PTR cb, Entry for which Timer expired
1493 PUBLIC S16 rgLMMStopTmr
1495 Inst inst, /* Scheduler instance */
1496 S16 tmrEvnt, /* Timer Event */
1497 PTR cb /* Entry for which Timer Expired */
1500 PUBLIC S16 rgLMMStopTmr(inst,tmrEvnt, cb)
1501 Inst inst; /* Scheduler instance */
1502 S16 tmrEvnt; /* Timer Event */
1503 PTR cb; /* Entry for which Timer Expired */
1514 for(i=0;i<RG_MAX_TIMER;i++)
1516 /* Search for the Timer Blocks */
1517 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1519 /* Initialize the arg structure */
1520 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1522 arg.tqCp = &rgCb[inst].tmrTqCp;
1523 arg.tq = rgCb[inst].tmrTq;
1524 arg.timers = rgCb[inst].tmrBlk;
1526 arg.max = RG_MAX_TIMER;
1544 * @brief Timer Expiry handler.
1548 * Function : rgLMMTmrExpiry
1550 * This is a callback function used as an input parameter to cmPrcTmr()
1551 * to check expiry of any timer. In this function, the only concern is
1552 * about tmrEvnt=Bind timer.
1554 * @param[in] PTR cb, Entry for which Timer expired
1555 * @param[in] S16 tmrEvnt, the Timer Event
1560 PUBLIC S16 rgLMMTmrExpiry
1562 PTR cb, /* Pointer to timer control block */
1563 S16 tmrEvnt /* Timer Event */
1566 PUBLIC S16 rgLMMTmrExpiry(cb,tmrEvnt)
1567 PTR cb; /* Pointer to timer control block */
1568 S16 tmrEvnt; /* Timer Event */
1572 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1573 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1575 TRC2(rgLMMTmrExpiry)
1581 tfuSap->numBndRetries++;
1582 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1584 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1585 LCM_CAUSE_TMR_EXPIRED, NULLP);
1589 /* Restart the bind timer */
1590 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1592 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1596 /* Send bind request */
1597 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1598 rgCb[inst].tfuSap.sapCfg.spId);
1602 RLOG1(L_ERROR, "Invalid tmrEvnt=%d",tmrEvnt);
1612 * @brief Layer Manager Unsolicited Status Indication generation.
1616 * Function : rgLMMStaInd
1618 * This API is used by the other modules of MAC to send a unsolicited
1619 * status indication to the Layer Manager.
1621 * @param[in] Inst inst
1622 * @param[in] U16 category, the Alarm category
1623 * @param[in] U16 event, the Alarm event
1624 * @param[in] U16 cause, the cause of the Alarm
1625 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1630 PUBLIC S16 rgLMMStaInd
1639 PUBLIC S16 rgLMMStaInd(inst,category, event, cause, dgn)
1651 if(rgCb[inst].rgInit.usta == FALSE)
1656 cmMemset((U8 *)&usta, 0, sizeof(RgMngmt));
1658 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1659 usta.t.usta.cmAlarm.category = category;
1660 usta.t.usta.cmAlarm.event = event;
1661 usta.t.usta.cmAlarm.cause = cause;
1664 cmMemcpy((U8 *)&usta.t.usta.dgn, (U8 *)dgn, sizeof(RgUstaDgn));
1667 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1668 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1669 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1670 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1671 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1672 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1674 RETVALUE(RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1679 * @brief Layer Manager Trace Indication generation.
1683 * Function : rgLMMTrcInd
1685 * This API is used by the other modules of MAC to send a
1686 * Trace indication to the Layer Manager.
1688 * @param[in] Inst inst
1689 * @param[in] Buffer *srcMbuf, the Message Buffer .
1690 * @param[in] U8 event, the trace event.
1694 PUBLIC Void rgLMMTrcInd
1697 Buffer *srcMbuf, /* Message Buffer */
1698 U8 event /* event */
1701 PUBLIC Void rgLMMTrcInd(inst,srcMbuf,event)
1703 Buffer *srcMbuf; /* Message Buffer */
1704 U8 event; /* event */
1707 Buffer *dstMbuf = NULLP;
1717 if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1719 RLOG0(L_ERROR, "Trace Disabled.");
1723 cmMemset((U8 *)&trc, 0, sizeof(RgMngmt));
1725 pst = rgCb[inst].rgInit.lmPst;
1726 pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1727 pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1728 pst.route = rgCb[inst].genCfg.trcResp.response.route;
1729 pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1730 pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1732 trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1734 SGetDateTime(&trc.t.trc.dt);
1736 /* Check if the whole buffer is to be sent in Trace indication */
1737 if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1739 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1742 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1745 trc.cfm.status = LCM_PRIM_OK;
1746 trc.cfm.reason = LCM_REASON_NOT_APPL;
1747 trc.t.trc.evnt = event;
1749 /* Send Trace Indication to Layer manager */
1750 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1752 /* check if only a specified number of bytes are to be sent */
1753 else if(rgCb[inst].trcLen > 0)
1755 /* Get the length of the recvd message buffer */
1756 if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1758 RLOG0(L_ERROR, "SFndLenMsg Failed.");
1761 /* Check if the recvd buffer size is less than request trace len */
1762 if(bufLen < rgCb[inst].trcLen)
1764 /* Copy the whole of the recvd buffer in trace indication */
1766 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1769 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1773 trc.cfm.status = LCM_PRIM_OK;
1774 trc.cfm.reason = LCM_REASON_NOT_APPL;
1775 trc.t.trc.evnt = event;
1777 /* Send Trace Indication to Layer manager */
1778 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1780 /* if the recvd buffer size is greater than request trace len */
1781 if(bufLen >= rgCb[inst].trcLen)
1783 /* Get a temporary buffer to store the msg */
1784 if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1786 RLOG0(L_ERROR, "rgAllocSBuf Failed.");
1790 /* Copy trcLen nos of bytes from the recvd message */
1791 if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)
1793 RLOG0(L_ERROR, "SCpyMsgFix Failed.");
1797 if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1799 RLOG0(L_ERROR, "dstMbuf Allocation Failed");
1802 /* Copy the tempBuf data to dst mBuf */
1803 if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1805 RLOG0(L_ERROR, "SCpyFixMsg Failed.");
1809 /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1811 /* Free the memory allocated for tempBuf */
1812 rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1814 trc.cfm.status = LCM_PRIM_OK;
1815 trc.cfm.reason = LCM_REASON_NOT_APPL;
1816 trc.t.trc.evnt = event;
1818 /* Send Trace Indication to Layer manager */
1819 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1827 * @brief Layer Manager Control Confirm generation handler
1828 * for Bind Confirm reception at TFU interface.
1829 * RgLiTfuBndCfm() forwards the confirmation to this
1830 * function. All SAP state related handling is restricted
1831 * to LMM modules, hence the cfm forwarding.
1835 * Function : rgLMMBndCfm
1837 * This API is used by the LIM module of MAC to forward
1838 * the Bind Confirm it receives over the TFU interface.
1840 * @param[in] Pst *pst, Post Structure
1841 * @param[in] SuId suId, Service user ID
1842 * @param[in] U8 status, Status
1847 PUBLIC S16 rgLMMBndCfm
1849 Pst *pst, /* Post Structure */
1850 SuId suId, /* Service user ID */
1851 U8 status /* Status */
1854 PUBLIC S16 rgLMMBndCfm(pst,suId,status)
1855 Pst *pst; /* Post Structure */
1856 SuId suId; /* Service user ID */
1857 U8 status; /* Status */
1860 Inst inst = pst->dstInst - RG_INST_START;
1869 /* Check if the suId is valid */
1870 if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1872 RLOG0(L_ERROR, "Invalid SuId");
1876 /* check the Sap State */
1877 switch(rgCb[inst].tfuSap.sapSta.sapState)
1879 case LRG_WAIT_BNDCFM:
1882 /* SAP is already bound */
1888 cfmPst = rgCb[inst].rgInit.lmPst;
1889 cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1890 cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1891 cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1892 cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1893 cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1895 cmMemset((U8 *)&cntrlCfm, 0, sizeof(RgMngmt));
1899 case CM_BND_OK: /* status is OK */
1900 /* Change SAP state to Bound */
1901 rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1902 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1904 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1906 /* Send Control Confirm with status as OK to Layer Manager */
1907 cntrlCfm.cfm.status = LCM_PRIM_OK;
1908 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1912 /* Change SAP state to UnBound */
1913 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1914 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1916 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1918 /* Send Control Confirm with status as NOK to Layer Manager */
1919 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1920 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1923 rgCb[inst].tfuSap.numBndRetries = 0;
1924 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1925 cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1927 ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1934 * @brief LTE MAC timer call back function registered with SSI.
1938 * Function : rgActvTmr
1940 * This function is invoked by SSI for every timer activation
1947 PUBLIC S16 rgActvTmr
1953 PUBLIC S16 rgActvTmr(ent, inst)
1958 Inst macInst = (inst - RG_INST_START);
1961 /* Check if any MAC timer has expired */
1962 cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1966 } /* end of rgActvTmr */
1969 * @brief Layer Manager Configuration request handler for Scheduler
1973 * Function : MacSchGenCfgReq
1975 * This function receives general configurations for Scheduler
1976 * from DU APP and forwards to Scheduler.
1978 * @param[in] Pst *pst, the post structure
1979 * @param[in] RgMngmt *cfg, the configuration parameter's structure
1984 PUBLIC S16 MacSchGenCfgReq
1986 Pst *pst, /* post structure */
1987 RgMngmt *cfg /* config structure */
1990 PUBLIC S16 MacSchGenCfgReq(pst, cfg)
1991 Pst *pst; /* post structure */
1992 RgMngmt *cfg; /* config structure */
1995 printf("\nReceived Scheduler gen config at MAC");
1996 pst->dstInst = DEFAULT_CELLS + 1;
1997 HandleSchGenCfgReq(pst, cfg);
2003 * @brief Layer Manager Configuration response from Scheduler
2007 * Function : SchSendCfgCfm
2009 * This function sends general configurations response from
2010 * Scheduler to DU APP.
2012 * @param[in] Pst *pst, the post structure
2013 * @param[in] RgMngmt *cfm, the configuration confirm structure
2018 PUBLIC S16 SchSendCfgCfm
2020 Pst *pst, /* post structure */
2021 RgMngmt *cfm /* config confirm structure */
2024 PUBLIC S16 SchSendCfgCfm(pst, cfm)
2025 Pst *pst; /* post structure */
2026 RgMngmt *cfm; /* config confirm structure */
2029 printf("\nSending Scheduler config confirm to DU APP");
2030 pst->dstEnt = ENTDUAPP;
2033 pst->selector = MAC_SCH_LC_SELECTOR;
2034 RgMiLrgSchCfgCfm(pst, cfm);
2040 /***********************************************************
2042 * Func : macCellCfgFillCfmPst
2045 * Desc : Fills the Confirmation Post Structure cfmPst
2053 **********************************************************/
2054 Void macCellCfgFillCfmPst
2061 inst = reqPst->dstInst;
2063 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
2064 cfmPst->srcInst = rgCb[inst].rgInit.inst;
2065 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
2067 cfmPst->dstEnt = ENTDUAPP;
2068 cfmPst->dstInst = 0;
2069 cfmPst->dstProcId = cfmPst->srcProcId;
2071 cfmPst->selector = LRG_SEL_LC;
2072 cfmPst->prior = reqPst->prior;
2073 cfmPst->route = reqPst->route;
2074 cfmPst->region = reqPst->region;
2075 cfmPst->pool = reqPst->pool;
2076 cfmPst->event = EVENT_MAC_CELL_CONFIG_CFM;
2082 * @brief Layer Manager Configuration request handler.
2086 * Function : MacHdlCellCfgReq
2088 * This function handles the gNB and cell configuration
2089 * request received from DU APP.
2090 * This API unapcks and forwards the config towards SCH
2092 * @param[in] Pst *pst
2093 * @param[in] MacCellCfg *macCellCfg
2097 int MacHdlCellCfgReq
2100 MacCellCfg *macCellCfg
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 /* Send cell cfg to scheduler */
2121 ret = MacSchCellCfgReq(pst, macCellCfg);
2124 MacCellCfgCfm macCellCfgCfm;
2125 macCellCfgCfm.rsp = RSP_NOK;
2126 macCellCfgCfm.transId = macCellCfg->transId;
2127 macCellCfgFillCfmPst(pst,&cfmPst);
2128 ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
2131 } /* end of MacHdlCellCfgReq */
2134 * @brief Layer Manager Configuration request handler.
2138 * Function : MacSchCellCfgReq
2140 * This function sends cell configuration to SCH
2142 * @param[in] Pst *pst
2143 * @param[in] MacCellCfg *macCellCfg
2147 int MacSchCellCfgReq
2150 MacCellCfg *macCellCfg
2153 SchCellCfg schCellCfg;
2157 cmMemset((U8 *)&cfgPst, 0, sizeof(Pst));
2158 schCellCfg.cellId = macCellCfg->cellId;
2159 schCellCfg.phyCellId = macCellCfg->phyCellId;
2160 schCellCfg.bandwidth = macCellCfg->dlCarrCfg.bw;
2161 schCellCfg.dupMode = macCellCfg->dupType;
2162 schCellCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr;
2163 schCellCfg.scsCommon = macCellCfg->ssbCfg.scsCmn;
2164 schCellCfg.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
2165 schCellCfg.ssbPeriod = macCellCfg->ssbCfg.ssbPeriod;
2166 schCellCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset;
2167 for(uint8_t idx=0; idx<SSB_MASK_SIZE; idx++)
2169 schCellCfg.nSSBMask[idx] = macCellCfg->ssbCfg.ssbMask[idx];
2171 cfgPst.srcProcId = pst->dstProcId;
2172 cfgPst.dstProcId = pst->srcProcId;
2173 cfgPst.srcEnt = ENTRG;
2175 cfgPst.dstEnt = ENTRG;
2177 cfgPst.selector = MAC_SCH_TC_SELECTOR;
2178 cfgPst.event = EVENT_SCH_CELL_CFG;
2180 ret = (*SchCellCfgOpts[cfgPst.selector])(&cfgPst, &schCellCfg);
2182 } /* end of MacSchCellCfgReq */
2185 * @brief Layer Manager Configuration response handler.
2189 * Function : MacProcSchCellCfgCfm
2191 * This function processes cell configuration to SCH
2193 * @param[in] Pst *pst
2194 * @param[in] SchCellCfgCfm *schCellCfgCfm
2198 int MacProcSchCellCfgCfm
2201 SchCellCfgCfm *schCellCfgCfm
2207 MacCellCfgCfm macCellCfgCfm;
2209 cmMemset((U8 *)&cfmPst, 0, sizeof(Pst));
2210 cellCb = rgCb[pst->dstInst].cell;
2211 macCellCfgCfm.transId = cellCb->macCellCfg.transId;
2212 if(schCellCfgCfm->rsp == RSP_OK)
2214 macCellCfgCfm.rsp = RSP_OK;
2218 macCellCfgCfm.rsp = RSP_NOK;
2220 macCellCfgFillCfmPst(pst,&cfmPst);
2221 ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
2224 /**********************************************************************
2227 **********************************************************************/