1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /************************************************************************
25 Desc: C source code for Layer Manager Interface Module
29 **********************************************************************/
32 @brief This file contains the Layer Management interface module implementation.
33 The functions for the configuration, control, status and statistics
34 request primitives are defined here.
36 static const char* RLOG_MODULE_NAME="MAC";
37 static int RLOG_FILE_ID=220;
38 static int RLOG_MODULE_ID=4096;
40 /* header include files (.h) */
41 #include "envopt.h" /* environment options */
42 #include "envdep.h" /* environment dependent */
43 #include "envind.h" /* environment independent */
44 #include "gen.h" /* general */
45 #include "ssi.h" /* system services */
46 #include "cm_tkns.h" /* Common Token Defines */
47 #include "cm_llist.h" /* Common Link List Defines */
48 #include "cm_hash.h" /* Common Hash List Defines */
49 #include "cm_mblk.h" /* common memory link list library */
50 #include "cm_lte.h" /* Common LTE Defines */
51 #include "rg_env.h" /* MAC Environment Defines */
52 #include "crg.h" /* CRG Interface defines */
53 #include "rgu.h" /* RGU Interface defines */
54 #include "tfu.h" /* RGU Interface defines */
55 #include "rg_sch_inf.h" /* RGR Interface defines */
56 #include "lrg.h" /* LRG Interface defines */
57 #include "rgr.h" /* LRG Interface defines */
58 #include "rg.h" /* MAC defines */
59 #include "rg_err.h" /* MAC error defines */
61 /* header/extern include files (.x) */
62 #include "gen.x" /* general */
63 #include "ssi.x" /* system services */
64 #include "cm5.x" /* system services */
65 #include "cm_tkns.x" /* Common Token Definitions */
66 #include "cm_llist.x" /* Common Link List Definitions */
67 #include "cm_lib.x" /* Common Library Definitions */
68 #include "cm_hash.x" /* Common Hash List Definitions */
69 #include "cm_mblk.x" /* common memory link list library */
70 #include "cm_lte.x" /* Common LTE Defines */
71 #include "crg.x" /* CRG Interface includes */
72 #include "rgu.x" /* RGU Interface includes */
73 #include "tfu.x" /* RGU Interface includes */
74 #include "rg_sch_inf.x" /* SCH Interface includes */
75 #include "rg_prg.x" /* PRG Interface includes */
76 #include "lrg.x" /* LRG Interface includes */
77 #include "rgr.x" /* LRG Interface includes */
78 #include "mac_interface.h"
79 #include "rg.x" /* MAC includes */
81 #include "ss_diag.h" /* Common log file */
86 #include "rg_cl.h" /* MAC CL defines */
90 #endif /* __cplusplus */
91 EXTERN Void rgGetSId ARGS((SystemId *s));
94 #endif /* __cplusplus */
96 /* Public variable declaration */
99 /* forward references */
100 PRIVATE U16 rgLMMGenCfg ARGS((
105 PRIVATE U16 rgLMMSapCfg ARGS((
111 PRIVATE Void rgLMMShutdown ARGS((
115 PRIVATE Void rgLMMFillCfmPst ARGS((
121 PRIVATE Void rgLMMGenCntrl ARGS((
127 PRIVATE Void rgLMMSapCntrl ARGS((
133 extern U16 cmPackLcMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm);
134 extern U16 cmPackTcMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm);
135 extern U16 cmPackLwlcMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm);
137 packMacCellCfgCfm packMacCellCfmMt[] =
139 cmPackLcMacCellCfgCfm, /* packing for loosely coupled */
140 cmPackTcMacCellCfgCfm, /* packing for tightly coupled */
141 cmPackLwlcMacCellCfgCfm, /* packing for light weight loosly coupled */
145 * @brief Task Initiation callback function.
149 * Function : rgActvInit
151 * This function is supplied as one of parameters during MAC's
152 * task registration. SSI will invoke this function once, after
153 * it creates and attaches this TAPA Task to a system task.
155 * @param[in] Ent entity, the entity ID of this task.
156 * @param[in] Inst inst, the instance ID of this task.
157 * @param[in] Region region, the region ID registered for memory
158 * usage of this task.
159 * @param[in] Reason reason.
164 PUBLIC S16 rgActvInit
166 Ent entity, /* entity */
167 Inst inst, /* instance */
168 Region region, /* region */
169 Reason reason /* reason */
172 PUBLIC S16 rgActvInit(entity, inst, region, reason)
173 Ent entity; /* entity */
174 Inst inst; /* instance */
175 Region region; /* region */
176 Reason reason; /* reason */
182 RG_IS_INST_VALID(inst);
184 macInst = inst - RG_INST_START;
185 /* Initialize the MAC TskInit structure to zero */
186 cmMemset ((U8 *)&rgCb[macInst], 0, sizeof(RgCb));
188 /* Initialize the MAC TskInit with received values */
189 rgCb[macInst].rgInit.ent = entity;
190 rgCb[macInst].rgInit.inst = inst;
191 rgCb[macInst].rgInit.region = region;
192 rgCb[macInst].rgInit.pool = 0;
193 rgCb[macInst].rgInit.reason = reason;
194 rgCb[macInst].rgInit.cfgDone = FALSE;
195 rgCb[macInst].rgInit.acnt = FALSE;
196 rgCb[macInst].rgInit.usta = FALSE;
197 rgCb[macInst].rgInit.trc = FALSE;
198 rgCb[macInst].trcLen = 0;
201 /* disabling debugs by default */
202 rgCb[macInst].rgInit.dbgMask = 0xffffffff;
206 rgCb[macInst].rgInit.logMask = 0x0;
208 rgCb[macInst].rgInit.procId = SFndProcId();
209 rgCb[macInst].tfuSap.numBndRetries = 0;
211 /* Initialize Sap state */
212 rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
213 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
214 rgCb[macInst].rguSap = NULLP;
215 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
217 rgCb[macInst].inactiveCell = NULLP;
218 rgCb[macInst].cell = NULLP;
220 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
221 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
224 /* Initializing CL control block */
225 clGlobalCp.region = region;
227 clGlobalCp.clCfgDone = FALSE;
228 clGlobalCp.numOfCells = 0;
229 clGlobalCp.phyState = PHY_STATE_IDLE;
231 if( cmHashListInit(&clGlobalCp.cellCbLst, MAX_NUM_CELL_SUPP, 0x0, FALSE,
232 CM_HASH_KEYTYPE_DEF, clGlobalCp.region, clGlobalCp.pool ) != ROK )
234 printf("\n Cellcb hash list initialization failed for MAC CL");
238 /* Initialize Scheduler as well */
239 schActvInit(ENTRG, (DEFAULT_CELLS + SCH_INST_START), DFLT_REGION, PWR_UP);
246 * @brief Layer Manager Configuration request handler.
250 * Function : RgMiLrgCfgReq
252 * This function handles the configuration
253 * request received from the Layer Manager.
254 * -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
255 * functions rgHdlGenCfg() or rgHdlSapCfg().
256 * -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
258 * @param[in] Pst *pst, the post structure
259 * @param[in] RgMngmt *cfg, the configuration parameter's structure
264 PUBLIC S16 RgMiLrgCfgReq
266 Pst *pst, /* post structure */
267 RgMngmt *cfg /* config structure */
270 PUBLIC S16 RgMiLrgCfgReq(pst, cfg)
271 Pst *pst; /* post structure */
272 RgMngmt *cfg; /* config structure */
275 U16 ret = LCM_PRIM_OK;
276 U16 reason = LCM_REASON_NOT_APPL;
284 RG_DIAG_LVL0(inst,0x0a0b0001, RG_DIAG_NA, SS_DIAG_INV_ARG,
285 "Received CfgReq for MAC layer, Entity = %d, Instance = %d\n",
286 pst->srcEnt, pst->srcInst,0,0);
288 RG_IS_INST_VALID(pst->dstInst);
289 inst = pst->dstInst - RG_INST_START;
291 /* Fill the post structure for sending the confirmation */
292 rgLMMFillCfmPst(pst, &cfmPst, cfg);
294 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
297 cfm.hdr.transId = cfg->hdr.transId;
301 cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
302 switch(cfg->hdr.elmId.elmnt)
305 reason = rgLMMGenCfg(inst,&cfg->t.cfg);
310 reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
314 reason = LCM_REASON_INVALID_ELMNT;
315 RLOG1(L_ERROR, "Invalid Elmnt=%d",
316 cfg->hdr.elmId.elmnt);
320 if (reason != LCM_REASON_NOT_APPL)
325 cfm.cfm.status = ret;
326 cfm.cfm.reason = reason;
328 RgMiLrgCfgCfm(&cfmPst, &cfm);
331 }/*-- RgMiLrgCfgReq --*/
335 * @brief Layer Manager Statistics request handler.
339 * Function : RgMiLrgStsReq
341 * This function handles the statistics
342 * request received from the Layer Manager.
343 * -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
344 * statistics from the rgCb global control block.
345 * -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
346 * -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
348 * @param[in] Pst *pst, the post structure
349 * @param[in] RgMngmt *sts, the statistics parameter's structure
354 PUBLIC S16 RgMiLrgStsReq
356 Pst *pst, /* post structure */
357 RgMngmt *sts /* statistics structure */
360 PUBLIC S16 RgMiLrgStsReq(pst, sts)
361 Pst *pst; /* post structure */
362 RgMngmt *sts; /* statistics structure */
372 RG_IS_INST_VALID(pst->dstInst);
373 inst = pst->dstInst - RG_INST_START;
374 /* Fill the post structure for sending the confirmation */
375 rgLMMFillCfmPst(pst, &cfmPst, sts);
377 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
380 cfm.hdr.transId = sts->hdr.transId;
382 SGetDateTime(&cfm.t.sts.dt);
383 cfm.cfm.status = LCM_PRIM_OK;
384 cfm.cfm.reason = LCM_REASON_NOT_APPL;
385 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
386 cfm.t.sts.action = sts->t.sts.action;
388 /* Check if General Config Done */
389 if(rgCb[inst].rgInit.cfgDone != TRUE)
391 cfm.cfm.status = LCM_PRIM_NOK;
392 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
393 RgMiLrgStsCfm(&cfmPst,&cfm);
394 RLOG0(L_ERROR, "Gen Cfg not done");
398 switch(sts->hdr.elmId.elmnt)
402 cmMemcpy((U8 *)&(cfm.t.sts.s.genSts), (U8 *)&rgCb[inst].genSts,
404 /* check if action is read and reset */
405 if(sts->t.sts.action == ARST)
407 rgCb[inst].genSts.numHarqFail = 0;
412 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
414 for(cqi=0; cqi <= 14; cqi++)
416 /* Filling DL ACK/NACK stats */
417 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
418 hqFailStats.dlCqiStat[cqi].mcs;
419 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
420 hqFailStats.dlCqiStat[cqi].numOfNacks;
421 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
422 hqFailStats.dlCqiStat[cqi].numOfAcks;
424 /* Filling UL ACK/NACK stats */
425 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
426 hqFailStats.ulCqiStat[cqi].mcs;
427 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
428 hqFailStats.ulCqiStat[cqi].numOfNacks;
429 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
430 hqFailStats.ulCqiStat[cqi].numOfAcks;
432 /* Filling DL HQ Retx stats */
433 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
434 hqRetxStats.dlCqiStat[cqi].mcs;
435 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
436 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
437 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
438 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
439 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
440 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
441 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
442 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
443 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
444 hqRetxStats.dlCqiStat[cqi].totalTx;
446 /* Filling UL HQ Retx stats */
447 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
448 hqRetxStats.ulCqiStat[cqi].mcs;
449 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
450 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
451 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
452 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
453 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
454 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
455 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
456 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
457 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
458 hqRetxStats.ulCqiStat[cqi].totalTx;
460 /* Reset statistics */
461 if(sts->t.sts.action == ZEROSTS)
463 cmMemset((U8 *)&hqRetxStats, 0, \
464 sizeof(RgSchHqRetxStats));
465 cmMemset((U8 *)&hqFailStats, 0, \
466 sizeof(RgSchNackAckStats));
469 #endif /* MAC_SCH_STATS*/
473 cmMemcpy((U8 *)&(cfm.t.sts.s.rguSts), (U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
476 /* check if action is read and reset */
477 if(sts->t.sts.action == ARST)
478 cmMemset((U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
482 cmMemcpy((U8 *)&(cfm.t.sts.s.crgSts), (U8 *)&rgCb[inst].crgSap.sapSts,
485 /* check if action is read and reset */
486 if(sts->t.sts.action == ARST)
487 cmMemset((U8 *)&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
491 cmMemcpy((U8 *)&(cfm.t.sts.s.tfuSts), (U8 *)&rgCb[inst].tfuSap.sapSts,
494 /* check if action is read and reset */
495 if(sts->t.sts.action == ARST)
496 cmMemset((U8 *)&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
500 cfm.cfm.status = LCM_PRIM_NOK;
501 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
502 RLOG1(L_ERROR, "Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
505 RgMiLrgStsCfm(&cfmPst,&cfm);
507 }/*-- RgMiLrgStsReq --*/
511 * @brief Layer Manager Status request handler.
515 * Function : RgMiLrgStaReq
517 * This function handles the solicited status
518 * request received from the Layer Manager.
519 * -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
520 * particular SAP from the rgCb global control block.
521 * -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
523 * @param[in] Pst *pst, the post structure
524 * @param[in] RgMngmt *sta, the status parameter's structure
529 PUBLIC S16 RgMiLrgStaReq
531 Pst *pst, /* post structure */
532 RgMngmt *sta /* status structure */
535 PUBLIC S16 RgMiLrgStaReq(pst, sta)
536 Pst *pst; /* post structure */
537 RgMngmt *sta; /* status structure */
547 RG_IS_INST_VALID(pst->dstInst);
548 inst = pst->dstInst - RG_INST_START;
551 /* Fill the post structure for sending the confirmation */
552 rgLMMFillCfmPst(pst, &cfmPst, sta);
554 if (sta->t.ssta.s.sysId.ptNmb != NULLP)
556 SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
559 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
560 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
563 cfm.hdr.transId = sta->hdr.transId;
565 /* Check if General Config Done */
566 if(rgCb[inst].rgInit.cfgDone != TRUE)
568 SGetDateTime(&cfm.t.ssta.dt);
569 if (SGetSBuf(cfmPst.region, cfmPst.pool,
570 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
573 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
576 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
577 rgGetSId(&cfm.t.ssta.s.sysId);
578 cfm.cfm.status = LCM_PRIM_NOK;
579 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
580 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
581 RgMiLrgStaCfm(&cfmPst, &cfm);
582 RLOG0(L_ERROR, "Gen Cfg not done");
586 switch(sta->hdr.elmId.elmnt)
589 SGetDateTime(&cfm.t.ssta.dt);
590 if (SGetSBuf(cfmPst.region, cfmPst.pool,
591 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
594 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
597 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
598 rgGetSId(&cfm.t.ssta.s.sysId);
599 cfm.cfm.status = LCM_PRIM_OK;
600 cfm.cfm.reason = LCM_REASON_NOT_APPL;
601 RgMiLrgStaCfm(&cfmPst, &cfm);
604 cfm.cfm.status = LCM_PRIM_OK;
605 cfm.cfm.reason = LCM_REASON_NOT_APPL;
606 SGetDateTime(&cfm.t.ssta.dt);
607 cmMemcpy((U8 *)&(cfm.t.ssta.s.rguSapSta),
608 (U8 *)&rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
610 RgMiLrgStaCfm(&cfmPst, &cfm);
613 cfm.cfm.status = LCM_PRIM_OK;
614 cfm.cfm.reason = LCM_REASON_NOT_APPL;
615 SGetDateTime(&cfm.t.ssta.dt);
616 cmMemcpy((U8 *)&(cfm.t.ssta.s.crgSapSta), (U8 *)&rgCb[inst].crgSap.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.tfuSapSta), (U8 *)&rgCb[inst].tfuSap.sapSta,
626 RgMiLrgStaCfm(&cfmPst, &cfm);
629 cfm.cfm.status = LCM_PRIM_NOK;
630 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
631 RgMiLrgStaCfm(&cfmPst, &cfm);
632 RLOG1(L_ERROR, "Invalid elmnt=%d",sta->hdr.elmId.elmnt);
636 }/*-- RgMiLrgStaReq --*/
640 * @brief Layer Manager Control request handler.
644 * Function : RgMiLrgCntrlReq
646 * This function handles the control
647 * request received from the Layer Manager.
648 * -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
649 * and cntrl->t.cntrl.subAction, it performs the appropriate control action
650 * of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
651 * and layer shutdown.
652 * -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
654 * @param[in] Pst *pst, the post structure
655 * @param[in] RgMngmt *cntrl, the control parameter's structure
660 PUBLIC S16 RgMiLrgCntrlReq
662 Pst *pst, /* post structure */
663 RgMngmt *cntrl /* control structure */
666 PUBLIC S16 RgMiLrgCntrlReq(pst, cntrl)
667 Pst *pst; /* post structure */
668 RgMngmt *cntrl; /* control structure */
671 S16 ret = ROK; /* return value */
676 TRC2(RgMiLrgCntrlReq)
678 /* Fill the post structure for sending the confirmation */
680 RG_IS_INST_VALID(pst->dstInst);
681 inst = pst->dstInst - RG_INST_START;
683 rgLMMFillCfmPst(pst, &cfmPst, cntrl);
685 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
687 cfm.hdr.transId = cntrl->hdr.transId;
689 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
690 cfm.t.cntrl.action = cntrl->t.cntrl.action;
691 cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
693 /* Check if General Config Done*/
694 if(rgCb[inst].rgInit.cfgDone != TRUE)
696 cfm.cfm.status = LCM_PRIM_NOK;
697 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
698 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
699 RgMiLrgCntrlCfm(&cfmPst, &cfm);
700 RLOG0(L_ERROR, "Gen Cfg not done");
704 /* General Config done, process the Control request */
705 switch(cntrl->hdr.elmId.elmnt)
708 rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
713 rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
716 cfm.cfm.status = LCM_PRIM_NOK;
717 cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
718 RgMiLrgCntrlCfm(&cfmPst, &cfm);
719 RLOG1(L_ERROR, "invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
723 }/*-- RgMiLrgCntrlReq --*/
727 * @brief SAP Configuration Handler.
731 * Function : rgLMMSapCfg
733 * This function in called by RgMiLrgCfgReq(). It handles the
734 * interface SAP configuration of the LTE MAC layer. It
735 * initializes the sapState to LRG_UNBND. Returns
736 * reason for success/failure of this function.
738 * @param[in] Inst inst
739 * @param[in] RgCfg *cfg, the Configuaration information
741 * -# LCM_REASON_GENCFG_NOT_DONE
742 * -# LCM_REASON_INVALID_SAP
743 * -# LCM_REASON_NOT_APPL
746 PRIVATE U16 rgLMMSapCfg
749 RgCfg *cfg, /* Configuaration information */
750 Elmnt sapType /* Sap Type */
753 PRIVATE U16 rgLMMSapCfg(inst,cfg,sapType)
755 RgCfg *cfg; /* Configuaration information */
756 Elmnt sapType; /* Sap Type */
759 U16 ret = LCM_REASON_NOT_APPL;
760 RgLowSapCfgInfo *lowSapCfg = NULLP;
761 RgUpSapCfgInfo *upSapCfg = NULLP;
762 RgUpSapCb *upSapCb = NULLP;
766 /* Check if Gen Config has been done */
767 if(rgCb[inst].rgInit.cfgDone != TRUE)
768 RETVALUE(LCM_REASON_GENCFG_NOT_DONE);
773 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
774 (cfg->s.rguSap.selector != RGU_SEL_TC) &&
775 (cfg->s.rguSap.selector != RGU_SEL_LC))
777 ret = LCM_REASON_INVALID_PAR_VAL;
778 RLOG0(L_ERROR, "unsupported Selector value for RGU");
781 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
782 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
784 upSapCb->sapSta.sapState = LRG_UNBND;
786 upSapCfg = &(upSapCb->sapCfg);
787 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
788 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
789 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
790 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
791 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
792 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
793 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
794 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
795 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
796 upSapCfg->sapPst.route = cfg->s.rguSap.route;
797 upSapCfg->sapPst.intfVer = 0;
798 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
799 upSapCfg->suId = cfg->s.rguSap.suId;
800 upSapCfg->spId = cfg->s.rguSap.spId;
801 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
802 * there is cfg request with sap is 1*/
805 if ((cfg->s.crgSap.selector != CRG_SEL_TC) &&
806 (cfg->s.crgSap.selector != CRG_SEL_LC))
808 ret = LCM_REASON_INVALID_PAR_VAL;
809 RLOG0(L_ERROR, "unsupported Selector value for CRG");
812 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
814 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
816 upSapCfg = &rgCb[inst].crgSap.sapCfg;
818 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
819 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
820 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
821 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
822 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
823 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
824 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
825 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
826 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
827 upSapCfg->sapPst.route = cfg->s.crgSap.route;
828 upSapCfg->sapPst.intfVer = 0;
829 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
830 upSapCfg->suId = cfg->s.crgSap.suId;
831 upSapCfg->spId = cfg->s.crgSap.spId;
835 if ((cfg->s.tfuSap.selector != TFU_SEL_TC) &&
836 (cfg->s.tfuSap.selector != TFU_SEL_LC))
838 ret = LCM_REASON_INVALID_PAR_VAL;
839 RLOG0(L_ERROR, "unsupported Selector value for TFU");
843 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
845 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
847 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
849 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
850 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
851 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
852 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
853 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
854 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
855 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
856 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
857 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
858 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
859 lowSapCfg->sapPst.intfVer = 0;
860 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
861 lowSapCfg->suId = cfg->s.tfuSap.suId;
862 lowSapCfg->spId = cfg->s.tfuSap.spId;
863 cmMemcpy((U8 *)&lowSapCfg->bndTmr, (U8 *)&cfg->s.tfuSap.bndTmr,
867 /* would never reach here */
875 * @brief General Configuration Handler.
879 * Function : rgLMMGenCfg
881 * This function in called by RgMiLrgCfgReq(). It handles the
882 * general configuration of the LTE MAC layer. It initializes
883 * the hash lists of RgCb. Returns
884 * reason for success/failure of this function.
886 * @param[in] Inst inst
887 * @param[in] RgCfg *cfg, the Configuaration information
889 * -# LCM_REASON_NOT_APPL
890 * -# LCM_REASON_INVALID_MSGTYPE
891 * -# LCM_REASON_MEM_NOAVAIL
894 PRIVATE U16 rgLMMGenCfg
897 RgCfg *cfg /* Configuaration information */
900 PRIVATE U16 rgLMMGenCfg(inst,cfg)
902 RgCfg *cfg; /* Configuaration information */
905 U16 ret = LCM_REASON_NOT_APPL;
909 /* Check if General Configuration is done already */
910 if (rgCb[inst].rgInit.cfgDone == TRUE)
912 RETVALUE(LCM_REASON_INVALID_MSGTYPE);
914 if ((cfg->s.genCfg.lmPst.selector != LRG_SEL_TC) &&
915 (cfg->s.genCfg.lmPst.selector != LRG_SEL_LC))
917 RLOG0(L_ERROR, "unsupported Selector value for RGU");
918 RETVALUE(LCM_REASON_INVALID_PAR_VAL);
920 /* Update the Pst structure for LM interface */
921 cmMemcpy((U8 *)&rgCb[inst].rgInit.lmPst, (U8 *)&cfg->s.genCfg.lmPst,
924 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
925 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
926 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
927 rgCb[inst].rgInit.lmPst.event = EVTNONE;
929 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
930 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
931 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
932 /* Initialize SAP States */
933 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
935 if(cfg->s.genCfg.numRguSaps == 0)
937 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Invalid numRguSap.\n"));
941 /* allocate RGR saps */
942 if (SGetSBuf(rgCb[inst].rgInit.region,
943 rgCb[inst].rgInit.pool,
944 (Data **)&rgCb[inst].rguSap,
945 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
947 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Failed to allocate mem for RGU SAP's.\n"));
950 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
952 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
954 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
955 cmMemset((U8 *)&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
957 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
958 /* Initialize the timer blocks */
959 cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
960 /* Initialzie the timer queue */
961 cmMemset((U8 *)&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
962 /* Initialize the timer control point */
963 cmMemset((U8 *)&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
964 rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
965 /* Timer Registration request to SSI */
966 if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
967 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
970 RLOG0(L_ERROR, "Failed to register timer");
972 SPutSBuf(rgCb[inst].rgInit.region,
973 rgCb[inst].rgInit.pool,
974 (Data *)rgCb[inst].rguSap,
975 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
977 RETVALUE(LCM_REASON_MEM_NOAVAIL);
979 /* Set Config done in TskInit */
980 rgCb[inst].rgInit.cfgDone = TRUE;
986 /***********************************************************
988 * Func : rgLMMShutdown
991 * Desc : Handles the MAC layer shutdown request. Calls
992 * rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
1001 **********************************************************/
1003 PRIVATE Void rgLMMShutdown
1008 PRIVATE Void rgLMMShutdown(inst)
1012 RgCellCb *cell = rgCb[inst].cell;
1017 /* Unbind the TFU Sap */
1018 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
1020 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1021 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1023 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1025 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1027 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
1029 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1030 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1036 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1038 rgTOMRlsSf(inst,&cell->subFrms[idx]);
1041 rgCFGFreeCellCb(cell);
1044 /* Deleting the RGU SAPs */
1045 SPutSBuf(rgCb[inst].rgInit.region,
1046 rgCb[inst].rgInit.pool,
1047 (Data *)rgCb[inst].rguSap,
1048 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
1049 rgCb[inst].rguSap = NULLP;
1051 rgCb[inst].inactiveCell = NULLP;
1052 rgCb[inst].cell = NULLP;
1054 /* De-register the Timer Service */
1055 (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
1056 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr);
1058 /* call back the task initialization function to intialize
1059 * the global RgCb Struct */
1060 rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region,
1061 rgCb[inst].rgInit.reason);
1067 /***********************************************************
1069 * Func : rgLMMGenCntrl
1072 * Desc : Processes the LM control request for STGEN elmnt.
1081 **********************************************************/
1083 PRIVATE Void rgLMMGenCntrl
1090 PRIVATE Void rgLMMGenCntrl(cntrl, cfm, cfmPst)
1096 Inst inst = (cfmPst->srcInst - RG_INST_START);
1099 cfm->cfm.status = LCM_PRIM_OK;
1100 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1103 switch(cntrl->t.cntrl.action)
1106 /* Action is Enable */
1107 switch(cntrl->t.cntrl.subAction)
1111 rgCb[inst].rgInit.trc = TRUE;
1112 rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1113 /*Store the response and TransId for sending the Traces */
1114 cmMemcpy((U8 *)&rgCb[inst].genCfg.trcResp.response,
1115 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1116 rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1120 /* Enable Unsolicited Status (alarms) */
1121 rgCb[inst].rgInit.usta = TRUE;
1122 /*Store the response and TransId for sending the Alarms */
1123 cmMemcpy((U8 *)&rgCb[inst].genCfg.ustaResp.response,
1124 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1125 rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1128 /* Enable Debug Printing */
1130 rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1135 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1140 cfm->cfm.status = LCM_PRIM_NOK;
1141 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1142 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1147 /* Action is Diable immidiately */
1148 switch(cntrl->t.cntrl.subAction)
1151 /* Disable Traces */
1152 rgCb[inst].rgInit.trc = FALSE;
1155 /* Disable Unsolicited Status (alarms) */
1156 rgCb[inst].rgInit.usta = FALSE;
1159 /* Disable Debug Printing */
1161 rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1166 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1171 cfm->cfm.status = LCM_PRIM_NOK;
1172 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1173 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1178 /* Free all the memory dynamically allocated by MAC */
1179 rgLMMShutdown(inst);
1182 cfm->cfm.status = LCM_PRIM_NOK;
1183 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1184 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1187 RgMiLrgCntrlCfm(cfmPst, cfm);
1192 /***********************************************************
1194 * Func : rgLMMSapCntrl
1197 * Desc : Processes the LM control request for STxxxSAP elmnt.
1206 **********************************************************/
1208 PRIVATE Void rgLMMSapCntrl
1215 PRIVATE Void rgLMMSapCntrl(cntrl, cfm, cfmPst)
1221 Inst inst = cfmPst->srcInst - RG_INST_START;
1224 /* Only TFU Sap can be controlled by LM */
1225 switch(cntrl->hdr.elmId.elmnt)
1228 switch(cntrl->t.cntrl.action)
1231 /* Bind Enable Request */
1232 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1233 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1235 cfm->cfm.status = LCM_PRIM_NOK;
1236 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1240 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1242 rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val,
1243 (PTR)&rgCb[inst].tfuSap);
1245 /* Change SAP state */
1246 rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1247 rgCb[inst].tfuSap.numBndRetries++;
1248 /* Store the response and TransId for sending
1249 * the Control confirm */
1250 cmMemcpy((U8 *)&rgCb[inst].genCfg.bndCfmResp.response,
1251 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1252 rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1254 /* Sending Status Indication to Layer Manager */
1255 cfm->cfm.status = LCM_PRIM_OK_NDONE;
1256 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1257 RgMiLrgCntrlCfm(cfmPst, cfm);
1259 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1260 rgCb[inst].tfuSap.sapCfg.spId);
1265 /* Unbind request */
1267 /* Check if the SAP is configured */
1268 if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1269 (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1271 cfm->cfm.status = LCM_PRIM_NOK;
1272 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1276 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1277 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1279 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1281 /* Change SAP state */
1282 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1283 cfm->cfm.status = LCM_PRIM_OK;
1284 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1288 /* Delete SAP, does initialization of SAP */
1289 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1290 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1292 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1293 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1295 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1298 cmMemset((U8 *)&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1299 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1300 cfm->cfm.status = LCM_PRIM_OK;
1301 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1304 cfm->cfm.status = LCM_PRIM_NOK;
1305 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1306 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1307 cntrl->t.cntrl.action));
1312 switch(cntrl->t.cntrl.action)
1315 cmMemset((U8 *)&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1316 rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1317 cfm->cfm.status = LCM_PRIM_OK;
1318 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1321 cfm->cfm.status = LCM_PRIM_NOK;
1322 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1323 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1324 cntrl->t.cntrl.action));
1329 switch(cntrl->t.cntrl.action)
1332 cmMemset((U8 *)&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1333 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1334 cfm->cfm.status = LCM_PRIM_OK;
1335 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1338 cfm->cfm.status = LCM_PRIM_NOK;
1339 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1340 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1346 /* Would never here. */
1349 RgMiLrgCntrlCfm(cfmPst, cfm);
1354 /***********************************************************
1356 * Func : rgLMMFillCfmPst
1359 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
1360 * and the cfm->hdr.response.
1369 **********************************************************/
1371 PRIVATE Void rgLMMFillCfmPst
1378 PRIVATE Void rgLMMFillCfmPst(reqPst, cfmPst, cfm)
1385 TRC2(rgLMMFillCfmPst)
1386 inst = (reqPst->dstInst - RG_INST_START);
1388 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
1389 cfmPst->srcInst = rgCb[inst].rgInit.inst;
1390 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1391 cfmPst->dstEnt = reqPst->srcEnt;
1392 cfmPst->dstInst = reqPst->srcInst;
1393 cfmPst->dstProcId = reqPst->srcProcId;
1395 cfmPst->selector = cfm->hdr.response.selector;
1396 cfmPst->prior = cfm->hdr.response.prior;
1397 cfmPst->route = cfm->hdr.response.route;
1398 cfmPst->region = cfm->hdr.response.mem.region;
1399 cfmPst->pool = cfm->hdr.response.mem.pool;
1406 * @brief Timer start handler.
1410 * Function : rgLMMStartTmr
1412 * This function based on the input parameters starts the timer for
1413 * "tmrVal" duration. As of now MAC uses the timer functionality for
1414 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1416 * @param[in] Inst inst
1417 * @param[in] S16 tmrEvnt, the Timer Event
1418 * @param[in] U32 tmrVal, the Wait Time
1419 * @param[in] PTR cb, Entry for which Timer expired
1424 PUBLIC S16 rgLMMStartTmr
1427 S16 tmrEvnt, /* Timer Event */
1428 U32 tmrVal, /* Wait Time */
1429 PTR cb /* Entry for which Timer Expired */
1432 PUBLIC S16 rgLMMStartTmr(tmrEvnt, tmrVal, cb)
1434 S16 tmrEvnt; /* Timer Event */
1435 U32 tmrVal; /* Wait Time */
1436 PTR cb; /* Entry for which Timer Expired */
1445 /* Initialize the arg structure */
1446 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1448 arg.tqCp = &rgCb[inst].tmrTqCp;
1449 arg.tq = rgCb[inst].tmrTq;
1450 arg.timers = rgCb[inst].tmrBlk;
1453 arg.max = RG_MAX_TIMER;
1454 arg.evnt = RG_BNDREQ_TMR;
1463 * @brief Timer stop handler.
1467 * Function : rgLMMStopTmr
1469 * This function based on the input parameters stops the timer for
1470 * "tmrEvnt". As of now MAC uses the timer functionality for
1471 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1472 * Once the bind happens and this timer is stopped, the timer functionality
1473 * is deregistered with SSI. As there is no further use of timer processing.
1475 * @param[in] Inst inst
1476 * @param[in] S16 tmrEvnt, the Timer Event
1477 * @param[in] PTR cb, Entry for which Timer expired
1483 PUBLIC S16 rgLMMStopTmr
1485 Inst inst, /* Scheduler instance */
1486 S16 tmrEvnt, /* Timer Event */
1487 PTR cb /* Entry for which Timer Expired */
1490 PUBLIC S16 rgLMMStopTmr(inst,tmrEvnt, cb)
1491 Inst inst; /* Scheduler instance */
1492 S16 tmrEvnt; /* Timer Event */
1493 PTR cb; /* Entry for which Timer Expired */
1504 for(i=0;i<RG_MAX_TIMER;i++)
1506 /* Search for the Timer Blocks */
1507 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1509 /* Initialize the arg structure */
1510 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1512 arg.tqCp = &rgCb[inst].tmrTqCp;
1513 arg.tq = rgCb[inst].tmrTq;
1514 arg.timers = rgCb[inst].tmrBlk;
1516 arg.max = RG_MAX_TIMER;
1534 * @brief Timer Expiry handler.
1538 * Function : rgLMMTmrExpiry
1540 * This is a callback function used as an input parameter to cmPrcTmr()
1541 * to check expiry of any timer. In this function, the only concern is
1542 * about tmrEvnt=Bind timer.
1544 * @param[in] PTR cb, Entry for which Timer expired
1545 * @param[in] S16 tmrEvnt, the Timer Event
1550 PUBLIC S16 rgLMMTmrExpiry
1552 PTR cb, /* Pointer to timer control block */
1553 S16 tmrEvnt /* Timer Event */
1556 PUBLIC S16 rgLMMTmrExpiry(cb,tmrEvnt)
1557 PTR cb; /* Pointer to timer control block */
1558 S16 tmrEvnt; /* Timer Event */
1562 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1563 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1565 TRC2(rgLMMTmrExpiry)
1571 tfuSap->numBndRetries++;
1572 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1574 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1575 LCM_CAUSE_TMR_EXPIRED, NULLP);
1579 /* Restart the bind timer */
1580 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1582 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1586 /* Send bind request */
1587 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1588 rgCb[inst].tfuSap.sapCfg.spId);
1592 RLOG1(L_ERROR, "Invalid tmrEvnt=%d",tmrEvnt);
1602 * @brief Layer Manager Unsolicited Status Indication generation.
1606 * Function : rgLMMStaInd
1608 * This API is used by the other modules of MAC to send a unsolicited
1609 * status indication to the Layer Manager.
1611 * @param[in] Inst inst
1612 * @param[in] U16 category, the Alarm category
1613 * @param[in] U16 event, the Alarm event
1614 * @param[in] U16 cause, the cause of the Alarm
1615 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1620 PUBLIC S16 rgLMMStaInd
1629 PUBLIC S16 rgLMMStaInd(inst,category, event, cause, dgn)
1641 if(rgCb[inst].rgInit.usta == FALSE)
1646 cmMemset((U8 *)&usta, 0, sizeof(RgMngmt));
1648 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1649 usta.t.usta.cmAlarm.category = category;
1650 usta.t.usta.cmAlarm.event = event;
1651 usta.t.usta.cmAlarm.cause = cause;
1654 cmMemcpy((U8 *)&usta.t.usta.dgn, (U8 *)dgn, sizeof(RgUstaDgn));
1657 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1658 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1659 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1660 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1661 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1662 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1664 RETVALUE(RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1669 * @brief Layer Manager Trace Indication generation.
1673 * Function : rgLMMTrcInd
1675 * This API is used by the other modules of MAC to send a
1676 * Trace indication to the Layer Manager.
1678 * @param[in] Inst inst
1679 * @param[in] Buffer *srcMbuf, the Message Buffer .
1680 * @param[in] U8 event, the trace event.
1684 PUBLIC Void rgLMMTrcInd
1687 Buffer *srcMbuf, /* Message Buffer */
1688 U8 event /* event */
1691 PUBLIC Void rgLMMTrcInd(inst,srcMbuf,event)
1693 Buffer *srcMbuf; /* Message Buffer */
1694 U8 event; /* event */
1697 Buffer *dstMbuf = NULLP;
1707 if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1709 RLOG0(L_ERROR, "Trace Disabled.");
1713 cmMemset((U8 *)&trc, 0, sizeof(RgMngmt));
1715 pst = rgCb[inst].rgInit.lmPst;
1716 pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1717 pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1718 pst.route = rgCb[inst].genCfg.trcResp.response.route;
1719 pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1720 pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1722 trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1724 SGetDateTime(&trc.t.trc.dt);
1726 /* Check if the whole buffer is to be sent in Trace indication */
1727 if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1729 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1732 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1735 trc.cfm.status = LCM_PRIM_OK;
1736 trc.cfm.reason = LCM_REASON_NOT_APPL;
1737 trc.t.trc.evnt = event;
1739 /* Send Trace Indication to Layer manager */
1740 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1742 /* check if only a specified number of bytes are to be sent */
1743 else if(rgCb[inst].trcLen > 0)
1745 /* Get the length of the recvd message buffer */
1746 if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1748 RLOG0(L_ERROR, "SFndLenMsg Failed.");
1751 /* Check if the recvd buffer size is less than request trace len */
1752 if(bufLen < rgCb[inst].trcLen)
1754 /* Copy the whole of the recvd buffer in trace indication */
1756 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1759 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1763 trc.cfm.status = LCM_PRIM_OK;
1764 trc.cfm.reason = LCM_REASON_NOT_APPL;
1765 trc.t.trc.evnt = event;
1767 /* Send Trace Indication to Layer manager */
1768 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1770 /* if the recvd buffer size is greater than request trace len */
1771 if(bufLen >= rgCb[inst].trcLen)
1773 /* Get a temporary buffer to store the msg */
1774 if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1776 RLOG0(L_ERROR, "rgAllocSBuf Failed.");
1780 /* Copy trcLen nos of bytes from the recvd message */
1781 if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)
1783 RLOG0(L_ERROR, "SCpyMsgFix Failed.");
1787 if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1789 RLOG0(L_ERROR, "dstMbuf Allocation Failed");
1792 /* Copy the tempBuf data to dst mBuf */
1793 if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1795 RLOG0(L_ERROR, "SCpyFixMsg Failed.");
1799 /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1801 /* Free the memory allocated for tempBuf */
1802 rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1804 trc.cfm.status = LCM_PRIM_OK;
1805 trc.cfm.reason = LCM_REASON_NOT_APPL;
1806 trc.t.trc.evnt = event;
1808 /* Send Trace Indication to Layer manager */
1809 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1817 * @brief Layer Manager Control Confirm generation handler
1818 * for Bind Confirm reception at TFU interface.
1819 * RgLiTfuBndCfm() forwards the confirmation to this
1820 * function. All SAP state related handling is restricted
1821 * to LMM modules, hence the cfm forwarding.
1825 * Function : rgLMMBndCfm
1827 * This API is used by the LIM module of MAC to forward
1828 * the Bind Confirm it receives over the TFU interface.
1830 * @param[in] Pst *pst, Post Structure
1831 * @param[in] SuId suId, Service user ID
1832 * @param[in] U8 status, Status
1837 PUBLIC S16 rgLMMBndCfm
1839 Pst *pst, /* Post Structure */
1840 SuId suId, /* Service user ID */
1841 U8 status /* Status */
1844 PUBLIC S16 rgLMMBndCfm(pst,suId,status)
1845 Pst *pst; /* Post Structure */
1846 SuId suId; /* Service user ID */
1847 U8 status; /* Status */
1850 Inst inst = pst->dstInst - RG_INST_START;
1859 /* Check if the suId is valid */
1860 if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1862 RLOG0(L_ERROR, "Invalid SuId");
1866 /* check the Sap State */
1867 switch(rgCb[inst].tfuSap.sapSta.sapState)
1869 case LRG_WAIT_BNDCFM:
1872 /* SAP is already bound */
1878 cfmPst = rgCb[inst].rgInit.lmPst;
1879 cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1880 cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1881 cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1882 cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1883 cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1885 cmMemset((U8 *)&cntrlCfm, 0, sizeof(RgMngmt));
1889 case CM_BND_OK: /* status is OK */
1890 /* Change SAP state to Bound */
1891 rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1892 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1894 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1896 /* Send Control Confirm with status as OK to Layer Manager */
1897 cntrlCfm.cfm.status = LCM_PRIM_OK;
1898 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1902 /* Change SAP state to UnBound */
1903 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1904 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1906 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1908 /* Send Control Confirm with status as NOK to Layer Manager */
1909 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1910 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1913 rgCb[inst].tfuSap.numBndRetries = 0;
1914 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1915 cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1917 ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1924 * @brief LTE MAC timer call back function registered with SSI.
1928 * Function : rgActvTmr
1930 * This function is invoked by SSI for every timer activation
1937 PUBLIC S16 rgActvTmr
1943 PUBLIC S16 rgActvTmr(ent, inst)
1948 Inst macInst = (inst - RG_INST_START);
1951 /* Check if any MAC timer has expired */
1952 cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1956 } /* end of rgActvTmr */
1959 * @brief Layer Manager Configuration request handler for Scheduler
1963 * Function : MacSchGenCfgReq
1965 * This function receives general configurations for Scheduler
1966 * from DU APP and forwards to Scheduler.
1968 * @param[in] Pst *pst, the post structure
1969 * @param[in] RgMngmt *cfg, the configuration parameter's structure
1974 PUBLIC S16 MacSchGenCfgReq
1976 Pst *pst, /* post structure */
1977 RgMngmt *cfg /* config structure */
1980 PUBLIC S16 MacSchGenCfgReq(pst, cfg)
1981 Pst *pst; /* post structure */
1982 RgMngmt *cfg; /* config structure */
1985 printf("\nReceived Scheduler gen config at MAC");
1986 pst->dstInst = DEFAULT_CELLS + 1;
1987 HandleSchGenCfgReq(pst, cfg);
1993 * @brief Layer Manager Configuration response from Scheduler
1997 * Function : SchSendCfgCfm
1999 * This function sends general configurations response from
2000 * Scheduler to DU APP.
2002 * @param[in] Pst *pst, the post structure
2003 * @param[in] RgMngmt *cfm, the configuration confirm structure
2008 PUBLIC S16 SchSendCfgCfm
2010 Pst *pst, /* post structure */
2011 RgMngmt *cfm /* config confirm structure */
2014 PUBLIC S16 SchSendCfgCfm(pst, cfm)
2015 Pst *pst; /* post structure */
2016 RgMngmt *cfm; /* config confirm structure */
2019 printf("\nSending Scheduler config confirm to DU APP");
2020 RgMiLrgSchCfgCfm(pst, cfm);
2026 * @brief Layer Manager Configuration request handler.
2030 * Function : MacSchCfgReq
2032 * This function handles the gNB and cell configuration
2033 * request received from DU APP.
2034 * This API unapcks and forwards the config towards SCH
2036 * @param[in] Pst *pst
2037 * @param[in] RgrCfgTransId transId
2038 * @param[in] RgrCfgReqInfo *cfgReqInfo
2043 PUBLIC S16 MacSchCfgReq
2046 RgrCfgTransId transId,
2047 RgrCfgReqInfo *cfgReqInfo
2050 PUBLIC S16 MacSchCfgReq(pst, transId, cfgReqInfo)
2052 RgrCfgTransId transId;
2053 RgrCfgReqInfo *cfgReqInfo;
2056 printf("\nReceived Scheduler config at MAC");
2057 pst->dstInst = DEFAULT_CELLS + 1;
2058 HandleSchCfgReq(pst, transId, cfgReqInfo);
2062 } /* end of MacSchCfgReq*/
2065 /***********************************************************
2067 * Func : macCellCfgFillCfmPst
2070 * Desc : Fills the Confirmation Post Structure cfmPst
2078 **********************************************************/
2079 Void macCellCfgFillCfmPst
2086 inst = reqPst->dstInst;
2088 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
2089 cfmPst->srcInst = rgCb[inst].rgInit.inst;
2090 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
2092 cfmPst->srcEnt = reqPst->dstEnt;
2093 cfmPst->dstEnt = reqPst->srcEnt;
2094 cfmPst->srcInst = reqPst->dstInst;
2095 cfmPst->dstInst = reqPst->srcInst;
2096 cfmPst->srcProcId = reqPst->dstProcId;
2097 cfmPst->dstProcId = reqPst->srcProcId;
2099 cfmPst->selector = LRG_SEL_LC;
2100 cfmPst->prior = reqPst->prior;
2101 cfmPst->route = reqPst->route;
2102 cfmPst->region = reqPst->region;
2103 cfmPst->pool = reqPst->pool;
2104 cfmPst->event = EVENT_MAC_CELL_CONFIG_CFM;
2110 * @brief Layer Manager Configuration request handler.
2114 * Function : unpackMacCellCfgReq
2116 * This function handles the gNB and cell configuration
2117 * request received from DU APP.
2118 * This API unapcks and forwards the config towards SCH
2120 * @param[in] Pst *pst
2121 * @param[in] MacCellCfg *macCellCfg
2125 S16 unpackMacCellCfgReq
2128 MacCellCfg *macCellCfg
2132 MacCellCfgCfm macCellCfgCfm;
2134 Inst inst = pst->dstInst;
2136 memcpy(&rgCb[inst].macCellCfg,macCellCfg,sizeof(MacCellCfg));
2138 macCellCfgFillCfmPst(pst,&cnfPst);
2140 macCellCfgCfm.transId = macCellCfg->transId;
2141 //ret = cmPackLcMacCellCfgCfm(&cnfPst,&macCellCfgCfm);
2142 ret = (*packMacCellCfmMt[cnfPst.selector])(&cnfPst,&macCellCfgCfm);
2144 } /* end of unpackMacCellCfgReq */
2147 /**********************************************************************
2150 **********************************************************************/