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 "rg.h" /* MAC defines */
58 #include "rg_err.h" /* MAC error defines */
60 /* header/extern include files (.x) */
61 #include "gen.x" /* general */
62 #include "ssi.x" /* system services */
63 #include "cm5.x" /* system services */
64 #include "cm_tkns.x" /* Common Token Definitions */
65 #include "cm_llist.x" /* Common Link List Definitions */
66 #include "cm_lib.x" /* Common Library Definitions */
67 #include "cm_hash.x" /* Common Hash List Definitions */
68 #include "cm_mblk.x" /* common memory link list library */
69 #include "cm_lte.x" /* Common LTE Defines */
70 #include "crg.x" /* CRG Interface includes */
71 #include "rgu.x" /* RGU Interface includes */
72 #include "tfu.x" /* RGU Interface includes */
73 #include "rg_sch_inf.x" /* SCH Interface includes */
74 #include "rg_prg.x" /* PRG Interface includes */
75 #include "lrg.x" /* LRG Interface includes */
76 #include "rg.x" /* MAC includes */
78 #include "ss_diag.h" /* Common log file */
83 #include "rg_cl.h" /* MAC CL defines */
87 #endif /* __cplusplus */
88 EXTERN Void rgGetSId ARGS((SystemId *s));
91 #endif /* __cplusplus */
93 /* Public variable declaration */
96 /* forward references */
97 PRIVATE U16 rgLMMGenCfg ARGS((
102 PRIVATE U16 rgLMMSapCfg ARGS((
108 PRIVATE Void rgLMMShutdown ARGS((
112 PRIVATE Void rgLMMFillCfmPst ARGS((
118 PRIVATE Void rgLMMGenCntrl ARGS((
124 PRIVATE Void rgLMMSapCntrl ARGS((
132 * @brief Task Initiation callback function.
136 * Function : rgActvInit
138 * This function is supplied as one of parameters during MAC's
139 * task registration. SSI will invoke this function once, after
140 * it creates and attaches this TAPA Task to a system task.
142 * @param[in] Ent entity, the entity ID of this task.
143 * @param[in] Inst inst, the instance ID of this task.
144 * @param[in] Region region, the region ID registered for memory
145 * usage of this task.
146 * @param[in] Reason reason.
151 PUBLIC S16 rgActvInit
153 Ent entity, /* entity */
154 Inst inst, /* instance */
155 Region region, /* region */
156 Reason reason /* reason */
159 PUBLIC S16 rgActvInit(entity, inst, region, reason)
160 Ent entity; /* entity */
161 Inst inst; /* instance */
162 Region region; /* region */
163 Reason reason; /* reason */
169 RG_IS_INST_VALID(inst);
171 macInst = inst - RG_INST_START;
172 /* Initialize the MAC TskInit structure to zero */
173 cmMemset ((U8 *)&rgCb[macInst], 0, sizeof(RgCb));
175 /* Initialize the MAC TskInit with received values */
176 rgCb[macInst].rgInit.ent = entity;
177 rgCb[macInst].rgInit.inst = inst;
178 rgCb[macInst].rgInit.region = region;
179 rgCb[macInst].rgInit.pool = 0;
180 rgCb[macInst].rgInit.reason = reason;
181 rgCb[macInst].rgInit.cfgDone = FALSE;
182 rgCb[macInst].rgInit.acnt = FALSE;
183 rgCb[macInst].rgInit.usta = FALSE;
184 rgCb[macInst].rgInit.trc = FALSE;
185 rgCb[macInst].trcLen = 0;
188 /* disabling debugs by default */
189 rgCb[macInst].rgInit.dbgMask = 0xffffffff;
193 rgCb[macInst].rgInit.logMask = 0x0;
195 rgCb[macInst].rgInit.procId = SFndProcId();
196 rgCb[macInst].tfuSap.numBndRetries = 0;
198 /* Initialize Sap state */
199 rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
200 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
201 rgCb[macInst].rguSap = NULLP;
202 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
204 rgCb[macInst].inactiveCell = NULLP;
205 rgCb[macInst].cell = NULLP;
207 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
208 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
211 /* Initializing CL control block */
212 clGlobalCp.region = region;
214 clGlobalCp.clCfgDone = FALSE;
215 clGlobalCp.numOfCells = 0;
216 clGlobalCp.phyState = PHY_STATE_IDLE;
218 if( cmHashListInit(&clGlobalCp.cellCbLst, MAX_NUM_CELL_SUPP, 0x0, FALSE,
219 CM_HASH_KEYTYPE_DEF, clGlobalCp.region, clGlobalCp.pool ) != ROK )
221 printf("\n Cellcb hash list initialization failed for MAC CL");
230 * @brief Layer Manager Configuration request handler.
234 * Function : RgMiLrgCfgReq
236 * This function handles the configuration
237 * request received from the Layer Manager.
238 * -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
239 * functions rgHdlGenCfg() or rgHdlSapCfg().
240 * -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
242 * @param[in] Pst *pst, the post structure
243 * @param[in] RgMngmt *cfg, the configuration parameter's structure
248 PUBLIC S16 RgMiLrgCfgReq
250 Pst *pst, /* post structure */
251 RgMngmt *cfg /* config structure */
254 PUBLIC S16 RgMiLrgCfgReq(pst, cfg)
255 Pst *pst; /* post structure */
256 RgMngmt *cfg; /* config structure */
259 U16 ret = LCM_PRIM_OK;
260 U16 reason = LCM_REASON_NOT_APPL;
268 RG_DIAG_LVL0(inst,0x0a0b0001, RG_DIAG_NA, SS_DIAG_INV_ARG,
269 "Received CfgReq for MAC layer, Entity = %d, Instance = %d\n",
270 pst->srcEnt, pst->srcInst,0,0);
272 RG_IS_INST_VALID(pst->dstInst);
273 inst = pst->dstInst - RG_INST_START;
275 /* Fill the post structure for sending the confirmation */
276 rgLMMFillCfmPst(pst, &cfmPst, cfg);
278 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
281 cfm.hdr.transId = cfg->hdr.transId;
285 cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
286 switch(cfg->hdr.elmId.elmnt)
289 reason = rgLMMGenCfg(inst,&cfg->t.cfg);
294 reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
297 reason = RgClCellCfgReq(&cfg->t.cfg.s.cellCfg);
300 reason = LCM_REASON_INVALID_ELMNT;
301 RLOG1(L_ERROR, "Invalid Elmnt=%d",
302 cfg->hdr.elmId.elmnt);
306 if (reason != LCM_REASON_NOT_APPL)
311 cfm.cfm.status = ret;
312 cfm.cfm.reason = reason;
314 RgMiLrgCfgCfm(&cfmPst, &cfm);
317 }/*-- RgMiLrgCfgReq --*/
321 * @brief Layer Manager Statistics request handler.
325 * Function : RgMiLrgStsReq
327 * This function handles the statistics
328 * request received from the Layer Manager.
329 * -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
330 * statistics from the rgCb global control block.
331 * -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
332 * -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
334 * @param[in] Pst *pst, the post structure
335 * @param[in] RgMngmt *sts, the statistics parameter's structure
340 PUBLIC S16 RgMiLrgStsReq
342 Pst *pst, /* post structure */
343 RgMngmt *sts /* statistics structure */
346 PUBLIC S16 RgMiLrgStsReq(pst, sts)
347 Pst *pst; /* post structure */
348 RgMngmt *sts; /* statistics structure */
358 RG_IS_INST_VALID(pst->dstInst);
359 inst = pst->dstInst - RG_INST_START;
360 /* Fill the post structure for sending the confirmation */
361 rgLMMFillCfmPst(pst, &cfmPst, sts);
363 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
366 cfm.hdr.transId = sts->hdr.transId;
368 SGetDateTime(&cfm.t.sts.dt);
369 cfm.cfm.status = LCM_PRIM_OK;
370 cfm.cfm.reason = LCM_REASON_NOT_APPL;
371 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
372 cfm.t.sts.action = sts->t.sts.action;
374 /* Check if General Config Done */
375 if(rgCb[inst].rgInit.cfgDone != TRUE)
377 cfm.cfm.status = LCM_PRIM_NOK;
378 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
379 RgMiLrgStsCfm(&cfmPst,&cfm);
380 RLOG0(L_ERROR, "Gen Cfg not done");
384 switch(sts->hdr.elmId.elmnt)
388 cmMemcpy((U8 *)&(cfm.t.sts.s.genSts), (U8 *)&rgCb[inst].genSts,
390 /* check if action is read and reset */
391 if(sts->t.sts.action == ARST)
393 rgCb[inst].genSts.numHarqFail = 0;
398 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
400 for(cqi=0; cqi <= 14; cqi++)
402 /* Filling DL ACK/NACK stats */
403 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
404 hqFailStats.dlCqiStat[cqi].mcs;
405 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
406 hqFailStats.dlCqiStat[cqi].numOfNacks;
407 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
408 hqFailStats.dlCqiStat[cqi].numOfAcks;
410 /* Filling UL ACK/NACK stats */
411 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
412 hqFailStats.ulCqiStat[cqi].mcs;
413 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
414 hqFailStats.ulCqiStat[cqi].numOfNacks;
415 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
416 hqFailStats.ulCqiStat[cqi].numOfAcks;
418 /* Filling DL HQ Retx stats */
419 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
420 hqRetxStats.dlCqiStat[cqi].mcs;
421 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
422 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
423 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
424 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
425 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
426 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
427 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
428 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
429 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
430 hqRetxStats.dlCqiStat[cqi].totalTx;
432 /* Filling UL HQ Retx stats */
433 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
434 hqRetxStats.ulCqiStat[cqi].mcs;
435 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
436 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
437 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
438 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
439 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
440 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
441 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
442 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
443 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
444 hqRetxStats.ulCqiStat[cqi].totalTx;
446 /* Reset statistics */
447 if(sts->t.sts.action == ZEROSTS)
449 cmMemset((U8 *)&hqRetxStats, 0, \
450 sizeof(RgSchHqRetxStats));
451 cmMemset((U8 *)&hqFailStats, 0, \
452 sizeof(RgSchNackAckStats));
455 #endif /* MAC_SCH_STATS*/
459 cmMemcpy((U8 *)&(cfm.t.sts.s.rguSts), (U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
462 /* check if action is read and reset */
463 if(sts->t.sts.action == ARST)
464 cmMemset((U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
468 cmMemcpy((U8 *)&(cfm.t.sts.s.crgSts), (U8 *)&rgCb[inst].crgSap.sapSts,
471 /* check if action is read and reset */
472 if(sts->t.sts.action == ARST)
473 cmMemset((U8 *)&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
477 cmMemcpy((U8 *)&(cfm.t.sts.s.tfuSts), (U8 *)&rgCb[inst].tfuSap.sapSts,
480 /* check if action is read and reset */
481 if(sts->t.sts.action == ARST)
482 cmMemset((U8 *)&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
486 cfm.cfm.status = LCM_PRIM_NOK;
487 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
488 RLOG1(L_ERROR, "Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
491 RgMiLrgStsCfm(&cfmPst,&cfm);
493 }/*-- RgMiLrgStsReq --*/
497 * @brief Layer Manager Status request handler.
501 * Function : RgMiLrgStaReq
503 * This function handles the solicited status
504 * request received from the Layer Manager.
505 * -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
506 * particular SAP from the rgCb global control block.
507 * -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
509 * @param[in] Pst *pst, the post structure
510 * @param[in] RgMngmt *sta, the status parameter's structure
515 PUBLIC S16 RgMiLrgStaReq
517 Pst *pst, /* post structure */
518 RgMngmt *sta /* status structure */
521 PUBLIC S16 RgMiLrgStaReq(pst, sta)
522 Pst *pst; /* post structure */
523 RgMngmt *sta; /* status structure */
533 RG_IS_INST_VALID(pst->dstInst);
534 inst = pst->dstInst - RG_INST_START;
537 /* Fill the post structure for sending the confirmation */
538 rgLMMFillCfmPst(pst, &cfmPst, sta);
540 if (sta->t.ssta.s.sysId.ptNmb != NULLP)
542 SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
545 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
546 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
549 cfm.hdr.transId = sta->hdr.transId;
551 /* Check if General Config Done */
552 if(rgCb[inst].rgInit.cfgDone != TRUE)
554 SGetDateTime(&cfm.t.ssta.dt);
555 if (SGetSBuf(cfmPst.region, cfmPst.pool,
556 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
559 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
562 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
563 rgGetSId(&cfm.t.ssta.s.sysId);
564 cfm.cfm.status = LCM_PRIM_NOK;
565 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
566 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
567 RgMiLrgStaCfm(&cfmPst, &cfm);
568 RLOG0(L_ERROR, "Gen Cfg not done");
572 switch(sta->hdr.elmId.elmnt)
575 SGetDateTime(&cfm.t.ssta.dt);
576 if (SGetSBuf(cfmPst.region, cfmPst.pool,
577 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
580 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
583 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
584 rgGetSId(&cfm.t.ssta.s.sysId);
585 cfm.cfm.status = LCM_PRIM_OK;
586 cfm.cfm.reason = LCM_REASON_NOT_APPL;
587 RgMiLrgStaCfm(&cfmPst, &cfm);
590 cfm.cfm.status = LCM_PRIM_OK;
591 cfm.cfm.reason = LCM_REASON_NOT_APPL;
592 SGetDateTime(&cfm.t.ssta.dt);
593 cmMemcpy((U8 *)&(cfm.t.ssta.s.rguSapSta),
594 (U8 *)&rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
596 RgMiLrgStaCfm(&cfmPst, &cfm);
599 cfm.cfm.status = LCM_PRIM_OK;
600 cfm.cfm.reason = LCM_REASON_NOT_APPL;
601 SGetDateTime(&cfm.t.ssta.dt);
602 cmMemcpy((U8 *)&(cfm.t.ssta.s.crgSapSta), (U8 *)&rgCb[inst].crgSap.sapSta,
604 RgMiLrgStaCfm(&cfmPst, &cfm);
607 cfm.cfm.status = LCM_PRIM_OK;
608 cfm.cfm.reason = LCM_REASON_NOT_APPL;
609 SGetDateTime(&cfm.t.ssta.dt);
610 cmMemcpy((U8 *)&(cfm.t.ssta.s.tfuSapSta), (U8 *)&rgCb[inst].tfuSap.sapSta,
612 RgMiLrgStaCfm(&cfmPst, &cfm);
615 cfm.cfm.status = LCM_PRIM_NOK;
616 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
617 RgMiLrgStaCfm(&cfmPst, &cfm);
618 RLOG1(L_ERROR, "Invalid elmnt=%d",sta->hdr.elmId.elmnt);
622 }/*-- RgMiLrgStaReq --*/
626 * @brief Layer Manager Control request handler.
630 * Function : RgMiLrgCntrlReq
632 * This function handles the control
633 * request received from the Layer Manager.
634 * -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
635 * and cntrl->t.cntrl.subAction, it performs the appropriate control action
636 * of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
637 * and layer shutdown.
638 * -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
640 * @param[in] Pst *pst, the post structure
641 * @param[in] RgMngmt *cntrl, the control parameter's structure
646 PUBLIC S16 RgMiLrgCntrlReq
648 Pst *pst, /* post structure */
649 RgMngmt *cntrl /* control structure */
652 PUBLIC S16 RgMiLrgCntrlReq(pst, cntrl)
653 Pst *pst; /* post structure */
654 RgMngmt *cntrl; /* control structure */
657 S16 ret = ROK; /* return value */
662 TRC2(RgMiLrgCntrlReq)
664 /* Fill the post structure for sending the confirmation */
666 RG_IS_INST_VALID(pst->dstInst);
667 inst = pst->dstInst - RG_INST_START;
669 rgLMMFillCfmPst(pst, &cfmPst, cntrl);
671 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
673 cfm.hdr.transId = cntrl->hdr.transId;
675 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
676 cfm.t.cntrl.action = cntrl->t.cntrl.action;
677 cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
679 /* Check if General Config Done*/
680 if(rgCb[inst].rgInit.cfgDone != TRUE)
682 cfm.cfm.status = LCM_PRIM_NOK;
683 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
684 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
685 RgMiLrgCntrlCfm(&cfmPst, &cfm);
686 RLOG0(L_ERROR, "Gen Cfg not done");
690 /* General Config done, process the Control request */
691 switch(cntrl->hdr.elmId.elmnt)
694 rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
699 rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
702 cfm.cfm.status = LCM_PRIM_NOK;
703 cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
704 RgMiLrgCntrlCfm(&cfmPst, &cfm);
705 RLOG1(L_ERROR, "invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
709 }/*-- RgMiLrgCntrlReq --*/
713 * @brief SAP Configuration Handler.
717 * Function : rgLMMSapCfg
719 * This function in called by RgMiLrgCfgReq(). It handles the
720 * interface SAP configuration of the LTE MAC layer. It
721 * initializes the sapState to LRG_UNBND. Returns
722 * reason for success/failure of this function.
724 * @param[in] Inst inst
725 * @param[in] RgCfg *cfg, the Configuaration information
727 * -# LCM_REASON_GENCFG_NOT_DONE
728 * -# LCM_REASON_INVALID_SAP
729 * -# LCM_REASON_NOT_APPL
732 PRIVATE U16 rgLMMSapCfg
735 RgCfg *cfg, /* Configuaration information */
736 Elmnt sapType /* Sap Type */
739 PRIVATE U16 rgLMMSapCfg(inst,cfg,sapType)
741 RgCfg *cfg; /* Configuaration information */
742 Elmnt sapType; /* Sap Type */
745 U16 ret = LCM_REASON_NOT_APPL;
746 RgLowSapCfgInfo *lowSapCfg = NULLP;
747 RgUpSapCfgInfo *upSapCfg = NULLP;
748 RgUpSapCb *upSapCb = NULLP;
752 /* Check if Gen Config has been done */
753 if(rgCb[inst].rgInit.cfgDone != TRUE)
754 RETVALUE(LCM_REASON_GENCFG_NOT_DONE);
759 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
760 (cfg->s.rguSap.selector != RGU_SEL_TC) &&
761 (cfg->s.rguSap.selector != RGU_SEL_LC))
763 ret = LCM_REASON_INVALID_PAR_VAL;
764 RLOG0(L_ERROR, "unsupported Selector value for RGU");
767 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
768 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
770 upSapCb->sapSta.sapState = LRG_UNBND;
772 upSapCfg = &(upSapCb->sapCfg);
773 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
774 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
775 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
776 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
777 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
778 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
779 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
780 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
781 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
782 upSapCfg->sapPst.route = cfg->s.rguSap.route;
783 upSapCfg->sapPst.intfVer = 0;
784 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
785 upSapCfg->suId = cfg->s.rguSap.suId;
786 upSapCfg->spId = cfg->s.rguSap.spId;
787 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
788 * there is cfg request with sap is 1*/
791 if ((cfg->s.crgSap.selector != CRG_SEL_TC) &&
792 (cfg->s.crgSap.selector != CRG_SEL_LC))
794 ret = LCM_REASON_INVALID_PAR_VAL;
795 RLOG0(L_ERROR, "unsupported Selector value for CRG");
798 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
800 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
802 upSapCfg = &rgCb[inst].crgSap.sapCfg;
804 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
805 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
806 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
807 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
808 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
809 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
810 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
811 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
812 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
813 upSapCfg->sapPst.route = cfg->s.crgSap.route;
814 upSapCfg->sapPst.intfVer = 0;
815 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
816 upSapCfg->suId = cfg->s.crgSap.suId;
817 upSapCfg->spId = cfg->s.crgSap.spId;
821 if ((cfg->s.tfuSap.selector != TFU_SEL_TC) &&
822 (cfg->s.tfuSap.selector != TFU_SEL_LC))
824 ret = LCM_REASON_INVALID_PAR_VAL;
825 RLOG0(L_ERROR, "unsupported Selector value for TFU");
829 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
831 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
833 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
835 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
836 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
837 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
838 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
839 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
840 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
841 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
842 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
843 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
844 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
845 lowSapCfg->sapPst.intfVer = 0;
846 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
847 lowSapCfg->suId = cfg->s.tfuSap.suId;
848 lowSapCfg->spId = cfg->s.tfuSap.spId;
849 cmMemcpy((U8 *)&lowSapCfg->bndTmr, (U8 *)&cfg->s.tfuSap.bndTmr,
853 /* would never reach here */
861 * @brief General Configuration Handler.
865 * Function : rgLMMGenCfg
867 * This function in called by RgMiLrgCfgReq(). It handles the
868 * general configuration of the LTE MAC layer. It initializes
869 * the hash lists of RgCb. Returns
870 * reason for success/failure of this function.
872 * @param[in] Inst inst
873 * @param[in] RgCfg *cfg, the Configuaration information
875 * -# LCM_REASON_NOT_APPL
876 * -# LCM_REASON_INVALID_MSGTYPE
877 * -# LCM_REASON_MEM_NOAVAIL
880 PRIVATE U16 rgLMMGenCfg
883 RgCfg *cfg /* Configuaration information */
886 PRIVATE U16 rgLMMGenCfg(inst,cfg)
888 RgCfg *cfg; /* Configuaration information */
891 U16 ret = LCM_REASON_NOT_APPL;
895 /* Check if General Configuration is done already */
896 if (rgCb[inst].rgInit.cfgDone == TRUE)
898 RETVALUE(LCM_REASON_INVALID_MSGTYPE);
900 if ((cfg->s.genCfg.lmPst.selector != LRG_SEL_TC) &&
901 (cfg->s.genCfg.lmPst.selector != LRG_SEL_LC))
903 RLOG0(L_ERROR, "unsupported Selector value for RGU");
904 RETVALUE(LCM_REASON_INVALID_PAR_VAL);
906 /* Update the Pst structure for LM interface */
907 cmMemcpy((U8 *)&rgCb[inst].rgInit.lmPst, (U8 *)&cfg->s.genCfg.lmPst,
910 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
911 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
912 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
913 rgCb[inst].rgInit.lmPst.event = EVTNONE;
915 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
916 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
917 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
918 /* Initialize SAP States */
919 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
921 if(cfg->s.genCfg.numRguSaps == 0)
923 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Invalid numRguSap.\n"));
927 /* allocate RGR saps */
928 if (SGetSBuf(rgCb[inst].rgInit.region,
929 rgCb[inst].rgInit.pool,
930 (Data **)&rgCb[inst].rguSap,
931 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
933 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Failed to allocate mem for RGU SAP's.\n"));
936 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
938 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
940 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
941 cmMemset((U8 *)&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
943 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
944 /* Initialize the timer blocks */
945 cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
946 /* Initialzie the timer queue */
947 cmMemset((U8 *)&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
948 /* Initialize the timer control point */
949 cmMemset((U8 *)&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
950 rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
951 /* Timer Registration request to SSI */
952 if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
953 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
956 RLOG0(L_ERROR, "Failed to register timer");
958 SPutSBuf(rgCb[inst].rgInit.region,
959 rgCb[inst].rgInit.pool,
960 (Data *)rgCb[inst].rguSap,
961 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
963 RETVALUE(LCM_REASON_MEM_NOAVAIL);
965 /* Set Config done in TskInit */
966 rgCb[inst].rgInit.cfgDone = TRUE;
972 /***********************************************************
974 * Func : rgLMMShutdown
977 * Desc : Handles the MAC layer shutdown request. Calls
978 * rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
987 **********************************************************/
989 PRIVATE Void rgLMMShutdown
994 PRIVATE Void rgLMMShutdown(inst)
998 RgCellCb *cell = rgCb[inst].cell;
1003 /* Unbind the TFU Sap */
1004 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
1006 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1007 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1009 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1011 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1013 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
1015 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1016 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1022 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1024 rgTOMRlsSf(inst,&cell->subFrms[idx]);
1027 rgCFGFreeCellCb(cell);
1030 /* Deleting the RGU SAPs */
1031 SPutSBuf(rgCb[inst].rgInit.region,
1032 rgCb[inst].rgInit.pool,
1033 (Data *)rgCb[inst].rguSap,
1034 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
1035 rgCb[inst].rguSap = NULLP;
1037 rgCb[inst].inactiveCell = NULLP;
1038 rgCb[inst].cell = NULLP;
1040 /* De-register the Timer Service */
1041 (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
1042 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr);
1044 /* call back the task initialization function to intialize
1045 * the global RgCb Struct */
1046 rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region,
1047 rgCb[inst].rgInit.reason);
1053 /***********************************************************
1055 * Func : rgLMMGenCntrl
1058 * Desc : Processes the LM control request for STGEN elmnt.
1067 **********************************************************/
1069 PRIVATE Void rgLMMGenCntrl
1076 PRIVATE Void rgLMMGenCntrl(cntrl, cfm, cfmPst)
1082 Inst inst = (cfmPst->srcInst - RG_INST_START);
1085 cfm->cfm.status = LCM_PRIM_OK;
1086 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1089 switch(cntrl->t.cntrl.action)
1092 /* Action is Enable */
1093 switch(cntrl->t.cntrl.subAction)
1097 rgCb[inst].rgInit.trc = TRUE;
1098 rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1099 /*Store the response and TransId for sending the Traces */
1100 cmMemcpy((U8 *)&rgCb[inst].genCfg.trcResp.response,
1101 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1102 rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1106 /* Enable Unsolicited Status (alarms) */
1107 rgCb[inst].rgInit.usta = TRUE;
1108 /*Store the response and TransId for sending the Alarms */
1109 cmMemcpy((U8 *)&rgCb[inst].genCfg.ustaResp.response,
1110 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1111 rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1114 /* Enable Debug Printing */
1116 rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1121 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1126 cfm->cfm.status = LCM_PRIM_NOK;
1127 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1128 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1133 /* Action is Diable immidiately */
1134 switch(cntrl->t.cntrl.subAction)
1137 /* Disable Traces */
1138 rgCb[inst].rgInit.trc = FALSE;
1141 /* Disable Unsolicited Status (alarms) */
1142 rgCb[inst].rgInit.usta = FALSE;
1145 /* Disable Debug Printing */
1147 rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1152 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1157 cfm->cfm.status = LCM_PRIM_NOK;
1158 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1159 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1164 /* Free all the memory dynamically allocated by MAC */
1165 rgLMMShutdown(inst);
1168 cfm->cfm.status = LCM_PRIM_NOK;
1169 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1170 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1173 RgMiLrgCntrlCfm(cfmPst, cfm);
1178 /***********************************************************
1180 * Func : rgLMMSapCntrl
1183 * Desc : Processes the LM control request for STxxxSAP elmnt.
1192 **********************************************************/
1194 PRIVATE Void rgLMMSapCntrl
1201 PRIVATE Void rgLMMSapCntrl(cntrl, cfm, cfmPst)
1207 Inst inst = cfmPst->srcInst - RG_INST_START;
1210 /* Only TFU Sap can be controlled by LM */
1211 switch(cntrl->hdr.elmId.elmnt)
1214 switch(cntrl->t.cntrl.action)
1217 /* Bind Enable Request */
1218 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1219 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1221 cfm->cfm.status = LCM_PRIM_NOK;
1222 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1226 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1228 rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val,
1229 (PTR)&rgCb[inst].tfuSap);
1231 /* Change SAP state */
1232 rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1233 rgCb[inst].tfuSap.numBndRetries++;
1234 /* Store the response and TransId for sending
1235 * the Control confirm */
1236 cmMemcpy((U8 *)&rgCb[inst].genCfg.bndCfmResp.response,
1237 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1238 rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1240 /* Sending Status Indication to Layer Manager */
1241 cfm->cfm.status = LCM_PRIM_OK_NDONE;
1242 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1243 RgMiLrgCntrlCfm(cfmPst, cfm);
1245 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1246 rgCb[inst].tfuSap.sapCfg.spId);
1251 /* Unbind request */
1253 /* Check if the SAP is configured */
1254 if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1255 (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1257 cfm->cfm.status = LCM_PRIM_NOK;
1258 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1262 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1263 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1265 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1267 /* Change SAP state */
1268 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1269 cfm->cfm.status = LCM_PRIM_OK;
1270 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1274 /* Delete SAP, does initialization of SAP */
1275 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1276 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1278 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1279 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1281 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1284 cmMemset((U8 *)&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1285 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1286 cfm->cfm.status = LCM_PRIM_OK;
1287 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1290 cfm->cfm.status = LCM_PRIM_NOK;
1291 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1292 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1293 cntrl->t.cntrl.action));
1298 switch(cntrl->t.cntrl.action)
1301 cmMemset((U8 *)&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1302 rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1303 cfm->cfm.status = LCM_PRIM_OK;
1304 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1307 cfm->cfm.status = LCM_PRIM_NOK;
1308 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1309 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1310 cntrl->t.cntrl.action));
1315 switch(cntrl->t.cntrl.action)
1318 cmMemset((U8 *)&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1319 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1320 cfm->cfm.status = LCM_PRIM_OK;
1321 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1324 cfm->cfm.status = LCM_PRIM_NOK;
1325 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1326 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1332 /* Would never here. */
1335 RgMiLrgCntrlCfm(cfmPst, cfm);
1340 /***********************************************************
1342 * Func : rgLMMFillCfmPst
1345 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
1346 * and the cfm->hdr.response.
1355 **********************************************************/
1357 PRIVATE Void rgLMMFillCfmPst
1364 PRIVATE Void rgLMMFillCfmPst(reqPst, cfmPst, cfm)
1371 TRC2(rgLMMFillCfmPst)
1372 inst = (reqPst->dstInst - RG_INST_START);
1374 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
1375 cfmPst->srcInst = rgCb[inst].rgInit.inst;
1376 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1377 cfmPst->dstEnt = reqPst->srcEnt;
1378 cfmPst->dstInst = reqPst->srcInst;
1379 cfmPst->dstProcId = reqPst->srcProcId;
1381 cfmPst->selector = cfm->hdr.response.selector;
1382 cfmPst->prior = cfm->hdr.response.prior;
1383 cfmPst->route = cfm->hdr.response.route;
1384 cfmPst->region = cfm->hdr.response.mem.region;
1385 cfmPst->pool = cfm->hdr.response.mem.pool;
1392 * @brief Timer start handler.
1396 * Function : rgLMMStartTmr
1398 * This function based on the input parameters starts the timer for
1399 * "tmrVal" duration. As of now MAC uses the timer functionality for
1400 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1402 * @param[in] Inst inst
1403 * @param[in] S16 tmrEvnt, the Timer Event
1404 * @param[in] U32 tmrVal, the Wait Time
1405 * @param[in] PTR cb, Entry for which Timer expired
1410 PUBLIC S16 rgLMMStartTmr
1413 S16 tmrEvnt, /* Timer Event */
1414 U32 tmrVal, /* Wait Time */
1415 PTR cb /* Entry for which Timer Expired */
1418 PUBLIC S16 rgLMMStartTmr(tmrEvnt, tmrVal, cb)
1420 S16 tmrEvnt; /* Timer Event */
1421 U32 tmrVal; /* Wait Time */
1422 PTR cb; /* Entry for which Timer Expired */
1431 /* Initialize the arg structure */
1432 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1434 arg.tqCp = &rgCb[inst].tmrTqCp;
1435 arg.tq = rgCb[inst].tmrTq;
1436 arg.timers = rgCb[inst].tmrBlk;
1439 arg.max = RG_MAX_TIMER;
1440 arg.evnt = RG_BNDREQ_TMR;
1449 * @brief Timer stop handler.
1453 * Function : rgLMMStopTmr
1455 * This function based on the input parameters stops the timer for
1456 * "tmrEvnt". As of now MAC uses the timer functionality for
1457 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1458 * Once the bind happens and this timer is stopped, the timer functionality
1459 * is deregistered with SSI. As there is no further use of timer processing.
1461 * @param[in] Inst inst
1462 * @param[in] S16 tmrEvnt, the Timer Event
1463 * @param[in] PTR cb, Entry for which Timer expired
1469 PUBLIC S16 rgLMMStopTmr
1471 Inst inst, /* Scheduler instance */
1472 S16 tmrEvnt, /* Timer Event */
1473 PTR cb /* Entry for which Timer Expired */
1476 PUBLIC S16 rgLMMStopTmr(inst,tmrEvnt, cb)
1477 Inst inst; /* Scheduler instance */
1478 S16 tmrEvnt; /* Timer Event */
1479 PTR cb; /* Entry for which Timer Expired */
1490 for(i=0;i<RG_MAX_TIMER;i++)
1492 /* Search for the Timer Blocks */
1493 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1495 /* Initialize the arg structure */
1496 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1498 arg.tqCp = &rgCb[inst].tmrTqCp;
1499 arg.tq = rgCb[inst].tmrTq;
1500 arg.timers = rgCb[inst].tmrBlk;
1502 arg.max = RG_MAX_TIMER;
1520 * @brief Timer Expiry handler.
1524 * Function : rgLMMTmrExpiry
1526 * This is a callback function used as an input parameter to cmPrcTmr()
1527 * to check expiry of any timer. In this function, the only concern is
1528 * about tmrEvnt=Bind timer.
1530 * @param[in] PTR cb, Entry for which Timer expired
1531 * @param[in] S16 tmrEvnt, the Timer Event
1536 PUBLIC S16 rgLMMTmrExpiry
1538 PTR cb, /* Pointer to timer control block */
1539 S16 tmrEvnt /* Timer Event */
1542 PUBLIC S16 rgLMMTmrExpiry(cb,tmrEvnt)
1543 PTR cb; /* Pointer to timer control block */
1544 S16 tmrEvnt; /* Timer Event */
1548 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1549 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1551 TRC2(rgLMMTmrExpiry)
1557 tfuSap->numBndRetries++;
1558 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1560 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1561 LCM_CAUSE_TMR_EXPIRED, NULLP);
1565 /* Restart the bind timer */
1566 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1568 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1572 /* Send bind request */
1573 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1574 rgCb[inst].tfuSap.sapCfg.spId);
1578 RLOG1(L_ERROR, "Invalid tmrEvnt=%d",tmrEvnt);
1588 * @brief Layer Manager Unsolicited Status Indication generation.
1592 * Function : rgLMMStaInd
1594 * This API is used by the other modules of MAC to send a unsolicited
1595 * status indication to the Layer Manager.
1597 * @param[in] Inst inst
1598 * @param[in] U16 category, the Alarm category
1599 * @param[in] U16 event, the Alarm event
1600 * @param[in] U16 cause, the cause of the Alarm
1601 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1606 PUBLIC S16 rgLMMStaInd
1615 PUBLIC S16 rgLMMStaInd(inst,category, event, cause, dgn)
1627 if(rgCb[inst].rgInit.usta == FALSE)
1632 cmMemset((U8 *)&usta, 0, sizeof(RgMngmt));
1634 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1635 usta.t.usta.cmAlarm.category = category;
1636 usta.t.usta.cmAlarm.event = event;
1637 usta.t.usta.cmAlarm.cause = cause;
1640 cmMemcpy((U8 *)&usta.t.usta.dgn, (U8 *)dgn, sizeof(RgUstaDgn));
1643 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1644 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1645 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1646 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1647 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1648 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1650 RETVALUE(RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1655 * @brief Layer Manager Trace Indication generation.
1659 * Function : rgLMMTrcInd
1661 * This API is used by the other modules of MAC to send a
1662 * Trace indication to the Layer Manager.
1664 * @param[in] Inst inst
1665 * @param[in] Buffer *srcMbuf, the Message Buffer .
1666 * @param[in] U8 event, the trace event.
1670 PUBLIC Void rgLMMTrcInd
1673 Buffer *srcMbuf, /* Message Buffer */
1674 U8 event /* event */
1677 PUBLIC Void rgLMMTrcInd(inst,srcMbuf,event)
1679 Buffer *srcMbuf; /* Message Buffer */
1680 U8 event; /* event */
1683 Buffer *dstMbuf = NULLP;
1693 if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1695 RLOG0(L_ERROR, "Trace Disabled.");
1699 cmMemset((U8 *)&trc, 0, sizeof(RgMngmt));
1701 pst = rgCb[inst].rgInit.lmPst;
1702 pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1703 pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1704 pst.route = rgCb[inst].genCfg.trcResp.response.route;
1705 pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1706 pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1708 trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1710 SGetDateTime(&trc.t.trc.dt);
1712 /* Check if the whole buffer is to be sent in Trace indication */
1713 if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1715 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1718 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1721 trc.cfm.status = LCM_PRIM_OK;
1722 trc.cfm.reason = LCM_REASON_NOT_APPL;
1723 trc.t.trc.evnt = event;
1725 /* Send Trace Indication to Layer manager */
1726 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1728 /* check if only a specified number of bytes are to be sent */
1729 else if(rgCb[inst].trcLen > 0)
1731 /* Get the length of the recvd message buffer */
1732 if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1734 RLOG0(L_ERROR, "SFndLenMsg Failed.");
1737 /* Check if the recvd buffer size is less than request trace len */
1738 if(bufLen < rgCb[inst].trcLen)
1740 /* Copy the whole of the recvd buffer in trace indication */
1742 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1745 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1749 trc.cfm.status = LCM_PRIM_OK;
1750 trc.cfm.reason = LCM_REASON_NOT_APPL;
1751 trc.t.trc.evnt = event;
1753 /* Send Trace Indication to Layer manager */
1754 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1756 /* if the recvd buffer size is greater than request trace len */
1757 if(bufLen >= rgCb[inst].trcLen)
1759 /* Get a temporary buffer to store the msg */
1760 if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1762 RLOG0(L_ERROR, "rgAllocSBuf Failed.");
1766 /* Copy trcLen nos of bytes from the recvd message */
1767 if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)
1769 RLOG0(L_ERROR, "SCpyMsgFix Failed.");
1773 if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1775 RLOG0(L_ERROR, "dstMbuf Allocation Failed");
1778 /* Copy the tempBuf data to dst mBuf */
1779 if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1781 RLOG0(L_ERROR, "SCpyFixMsg Failed.");
1785 /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1787 /* Free the memory allocated for tempBuf */
1788 rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1790 trc.cfm.status = LCM_PRIM_OK;
1791 trc.cfm.reason = LCM_REASON_NOT_APPL;
1792 trc.t.trc.evnt = event;
1794 /* Send Trace Indication to Layer manager */
1795 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1803 * @brief Layer Manager Control Confirm generation handler
1804 * for Bind Confirm reception at TFU interface.
1805 * RgLiTfuBndCfm() forwards the confirmation to this
1806 * function. All SAP state related handling is restricted
1807 * to LMM modules, hence the cfm forwarding.
1811 * Function : rgLMMBndCfm
1813 * This API is used by the LIM module of MAC to forward
1814 * the Bind Confirm it receives over the TFU interface.
1816 * @param[in] Pst *pst, Post Structure
1817 * @param[in] SuId suId, Service user ID
1818 * @param[in] U8 status, Status
1823 PUBLIC S16 rgLMMBndCfm
1825 Pst *pst, /* Post Structure */
1826 SuId suId, /* Service user ID */
1827 U8 status /* Status */
1830 PUBLIC S16 rgLMMBndCfm(pst,suId,status)
1831 Pst *pst; /* Post Structure */
1832 SuId suId; /* Service user ID */
1833 U8 status; /* Status */
1836 Inst inst = pst->dstInst - RG_INST_START;
1845 /* Check if the suId is valid */
1846 if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1848 RLOG0(L_ERROR, "Invalid SuId");
1852 /* check the Sap State */
1853 switch(rgCb[inst].tfuSap.sapSta.sapState)
1855 case LRG_WAIT_BNDCFM:
1858 /* SAP is already bound */
1864 cfmPst = rgCb[inst].rgInit.lmPst;
1865 cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1866 cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1867 cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1868 cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1869 cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1871 cmMemset((U8 *)&cntrlCfm, 0, sizeof(RgMngmt));
1875 case CM_BND_OK: /* status is OK */
1876 /* Change SAP state to Bound */
1877 rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1878 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1880 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1882 /* Send Control Confirm with status as OK to Layer Manager */
1883 cntrlCfm.cfm.status = LCM_PRIM_OK;
1884 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1888 /* Change SAP state to UnBound */
1889 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1890 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1892 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1894 /* Send Control Confirm with status as NOK to Layer Manager */
1895 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1896 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1899 rgCb[inst].tfuSap.numBndRetries = 0;
1900 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1901 cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1903 ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1910 * @brief LTE MAC timer call back function registered with SSI.
1914 * Function : rgActvTmr
1916 * This function is invoked by SSI for every timer activation
1923 PUBLIC S16 rgActvTmr
1929 PUBLIC S16 rgActvTmr(ent, inst)
1934 Inst macInst = (inst - RG_INST_START);
1937 /* Check if any MAC timer has expired */
1938 cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1942 } /* end of rgActvTmr */
1945 /**********************************************************************
1948 **********************************************************************/