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 "common_def.h"
42 #include "rg_env.h" /* MAC Environment Defines */
43 #include "crg.h" /* CRG Interface defines */
44 #include "rgu.h" /* RGU Interface defines */
45 #include "tfu.h" /* RGU Interface defines */
46 #include "rg_sch_inf.h" /* RGR Interface defines */
47 #include "lrg.h" /* LRG Interface defines */
48 #include "rgr.h" /* LRG Interface defines */
49 #include "rg.h" /* MAC defines */
50 #include "rg_err.h" /* MAC error defines */
52 /* header/extern include files (.x) */
53 #include "crg.x" /* CRG Interface includes */
54 #include "rgu.x" /* RGU Interface includes */
55 #include "tfu.x" /* RGU Interface includes */
56 #include "rg_sch_inf.x" /* SCH Interface includes */
57 #include "rg_prg.x" /* PRG Interface includes */
58 #include "lrg.x" /* LRG Interface includes */
59 #include "rgr.x" /* LRG Interface includes */
60 #include "du_app_mac_inf.h"
61 #include "rg.x" /* MAC includes */
63 #include "ss_diag.h" /* Common log file */
67 #include "lwr_mac.h" /* MAC CL defines */
68 #include "mac_sch_interface.h"
69 #include "lwr_mac_upr_inf.h"
71 #include "lwr_mac_phy.h"
72 #include "lwr_mac_fsm.h"
76 #endif /* __cplusplus */
77 Void rgGetSId ARGS((SystemId *s));
80 #endif /* __cplusplus */
82 /* Public variable declaration */
86 /* forward references */
87 static uint16_t rgLMMGenCfg ARGS((
92 static uint16_t rgLMMSapCfg ARGS((
98 static Void rgLMMShutdown ARGS((
102 static Void rgLMMFillCfmPst ARGS((
108 static Void rgLMMGenCntrl ARGS((
114 static Void rgLMMSapCntrl ARGS((
122 * @brief Task Initiation callback function.
126 * Function : rgActvInit
128 * This function is supplied as one of parameters during MAC's
129 * task registration. SSI will invoke this function once, after
130 * it creates and attaches this TAPA Task to a system task.
132 * @param[in] Ent entity, the entity ID of this task.
133 * @param[in] Inst inst, the instance ID of this task.
134 * @param[in] Region region, the region ID registered for memory
135 * usage of this task.
136 * @param[in] Reason reason.
143 Ent entity, /* entity */
144 Inst inst, /* instance */
145 Region region, /* region */
146 Reason reason /* reason */
149 S16 rgActvInit(entity, inst, region, reason)
150 Ent entity; /* entity */
151 Inst inst; /* instance */
152 Region region; /* region */
153 Reason reason; /* reason */
158 RG_IS_INST_VALID(inst);
160 macInst = inst - RG_INST_START;
161 /* Initialize the MAC TskInit structure to zero */
162 memset (&rgCb[macInst], 0, sizeof(RgCb));
164 /* Initialize the MAC TskInit with received values */
165 rgCb[macInst].rgInit.ent = entity;
166 rgCb[macInst].rgInit.inst = inst;
167 rgCb[macInst].rgInit.region = region;
168 rgCb[macInst].rgInit.pool = 0;
169 rgCb[macInst].rgInit.reason = reason;
170 rgCb[macInst].rgInit.cfgDone = FALSE;
171 rgCb[macInst].rgInit.acnt = FALSE;
172 rgCb[macInst].rgInit.usta = FALSE;
173 rgCb[macInst].rgInit.trc = FALSE;
174 rgCb[macInst].trcLen = 0;
177 /* disabling debugs by default */
178 rgCb[macInst].rgInit.dbgMask = 0xffffffff;
182 rgCb[macInst].rgInit.logMask = 0x0;
184 rgCb[macInst].rgInit.procId = SFndProcId();
185 rgCb[macInst].tfuSap.numBndRetries = 0;
187 /* Initialize Sap state */
188 rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
189 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
190 rgCb[macInst].rguSap = NULLP;
191 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
193 rgCb[macInst].inactiveCell = NULLP;
194 rgCb[macInst].cell = NULLP;
196 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
197 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
200 /* Initializing CL control block */
201 memset(&lwrMacCb, 0, sizeof(LwrMacCb));
202 lwrMacCb.region = region;
204 lwrMacCb.clCfgDone = TRUE;
205 lwrMacCb.numCell = 0;
206 lwrMacCb.phyState = PHY_STATE_IDLE;
208 /* Initialize Scheduler as well */
209 schActvInit(ENTMAC, (DEFAULT_CELLS + SCH_INST_START), DFLT_REGION, PWR_UP);
211 /* Initialize lower mac */
219 * @brief Layer Manager Configuration request handler.
223 * Function : RgMiLrgCfgReq
225 * This function handles the configuration
226 * request received from the Layer Manager.
227 * -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
228 * functions rgHdlGenCfg() or rgHdlSapCfg().
229 * -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
231 * @param[in] Pst *pst, the post structure
232 * @param[in] RgMngmt *cfg, the configuration parameter's structure
239 Pst *pst, /* post structure */
240 RgMngmt *cfg /* config structure */
243 S16 RgMiLrgCfgReq(pst, cfg)
244 Pst *pst; /* post structure */
245 RgMngmt *cfg; /* config structure */
248 uint16_t ret = LCM_PRIM_OK;
249 uint16_t reason = LCM_REASON_NOT_APPL;
256 RG_DIAG_LVL0(inst,0x0a0b0001, RG_DIAG_NA, SS_DIAG_INV_ARG,\
257 "Received CfgReq for MAC layer, Entity = %d, Instance = %d\n", pst->srcEnt, pst->srcInst,0,0);
259 RG_IS_INST_VALID(pst->dstInst);
260 inst = pst->dstInst - RG_INST_START;
262 /* Fill the post structure for sending the confirmation */
263 rgLMMFillCfmPst(pst, &cfmPst, cfg);
265 memset(&cfm, 0, sizeof(RgMngmt));
268 cfm.hdr.transId = cfg->hdr.transId;
272 cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
273 switch(cfg->hdr.elmId.elmnt)
276 reason = rgLMMGenCfg(inst,&cfg->t.cfg);
281 reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
285 reason = LCM_REASON_INVALID_ELMNT;
286 RLOG1(L_ERROR, "Invalid Elmnt=%d",
287 cfg->hdr.elmId.elmnt);
291 if (reason != LCM_REASON_NOT_APPL)
296 cfm.cfm.status = ret;
297 cfm.cfm.reason = reason;
299 RgMiLrgCfgCfm(&cfmPst, &cfm);
302 }/*-- RgMiLrgCfgReq --*/
306 * @brief Layer Manager Statistics request handler.
310 * Function : RgMiLrgStsReq
312 * This function handles the statistics
313 * request received from the Layer Manager.
314 * -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
315 * statistics from the rgCb global control block.
316 * -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
317 * -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
319 * @param[in] Pst *pst, the post structure
320 * @param[in] RgMngmt *sts, the statistics parameter's structure
327 Pst *pst, /* post structure */
328 RgMngmt *sts /* statistics structure */
331 S16 RgMiLrgStsReq(pst, sts)
332 Pst *pst; /* post structure */
333 RgMngmt *sts; /* statistics structure */
340 RG_IS_INST_VALID(pst->dstInst);
341 inst = pst->dstInst - RG_INST_START;
342 /* Fill the post structure for sending the confirmation */
343 rgLMMFillCfmPst(pst, &cfmPst, sts);
345 memset(&cfm, 0, sizeof(RgMngmt));
348 cfm.hdr.transId = sts->hdr.transId;
350 SGetDateTime(&cfm.t.sts.dt);
351 cfm.cfm.status = LCM_PRIM_OK;
352 cfm.cfm.reason = LCM_REASON_NOT_APPL;
353 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
354 cfm.t.sts.action = sts->t.sts.action;
356 /* Check if General Config Done */
357 if(rgCb[inst].rgInit.cfgDone != TRUE)
359 cfm.cfm.status = LCM_PRIM_NOK;
360 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
361 RgMiLrgStsCfm(&cfmPst,&cfm);
362 RLOG0(L_ERROR, "Gen Cfg not done");
366 switch(sts->hdr.elmId.elmnt)
370 memcpy(&(cfm.t.sts.s.genSts), &rgCb[inst].genSts,
372 /* check if action is read and reset */
373 if(sts->t.sts.action == ARST)
375 rgCb[inst].genSts.numHarqFail = 0;
380 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
382 for(cqi=0; cqi <= 14; cqi++)
384 /* Filling DL ACK/NACK stats */
385 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
386 hqFailStats.dlCqiStat[cqi].mcs;
387 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
388 hqFailStats.dlCqiStat[cqi].numOfNacks;
389 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
390 hqFailStats.dlCqiStat[cqi].numOfAcks;
392 /* Filling UL ACK/NACK stats */
393 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
394 hqFailStats.ulCqiStat[cqi].mcs;
395 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
396 hqFailStats.ulCqiStat[cqi].numOfNacks;
397 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
398 hqFailStats.ulCqiStat[cqi].numOfAcks;
400 /* Filling DL HQ Retx stats */
401 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
402 hqRetxStats.dlCqiStat[cqi].mcs;
403 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
404 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
405 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
406 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
407 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
408 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
409 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
410 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
411 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
412 hqRetxStats.dlCqiStat[cqi].totalTx;
414 /* Filling UL HQ Retx stats */
415 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
416 hqRetxStats.ulCqiStat[cqi].mcs;
417 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
418 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
419 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
420 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
421 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
422 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
423 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
424 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
425 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
426 hqRetxStats.ulCqiStat[cqi].totalTx;
428 /* Reset statistics */
429 if(sts->t.sts.action == ZEROSTS)
431 memset(&hqRetxStats, 0, \
432 sizeof(RgSchHqRetxStats));
433 memset(&hqFailStats, 0, \
434 sizeof(RgSchNackAckStats));
437 #endif /* MAC_SCH_STATS*/
441 memcpy(&(cfm.t.sts.s.rguSts), &rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
444 /* check if action is read and reset */
445 if(sts->t.sts.action == ARST)
446 memset(&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
450 memcpy(&(cfm.t.sts.s.crgSts), &rgCb[inst].crgSap.sapSts,
453 /* check if action is read and reset */
454 if(sts->t.sts.action == ARST)
455 memset(&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
459 memcpy(&(cfm.t.sts.s.tfuSts), &rgCb[inst].tfuSap.sapSts,
462 /* check if action is read and reset */
463 if(sts->t.sts.action == ARST)
464 memset(&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
468 cfm.cfm.status = LCM_PRIM_NOK;
469 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
470 RLOG1(L_ERROR, "Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
473 RgMiLrgStsCfm(&cfmPst,&cfm);
475 }/*-- RgMiLrgStsReq --*/
479 * @brief Layer Manager Status request handler.
483 * Function : RgMiLrgStaReq
485 * This function handles the solicited status
486 * request received from the Layer Manager.
487 * -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
488 * particular SAP from the rgCb global control block.
489 * -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
491 * @param[in] Pst *pst, the post structure
492 * @param[in] RgMngmt *sta, the status parameter's structure
499 Pst *pst, /* post structure */
500 RgMngmt *sta /* status structure */
503 S16 RgMiLrgStaReq(pst, sta)
504 Pst *pst; /* post structure */
505 RgMngmt *sta; /* status structure */
513 RG_IS_INST_VALID(pst->dstInst);
514 inst = pst->dstInst - RG_INST_START;
517 /* Fill the post structure for sending the confirmation */
518 rgLMMFillCfmPst(pst, &cfmPst, sta);
520 if (sta->t.ssta.s.sysId.ptNmb != NULLP)
522 SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
525 memset(&cfm, 0, sizeof(RgMngmt));
526 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
529 cfm.hdr.transId = sta->hdr.transId;
531 /* Check if General Config Done */
532 if(rgCb[inst].rgInit.cfgDone != TRUE)
534 SGetDateTime(&cfm.t.ssta.dt);
535 if (SGetSBuf(cfmPst.region, cfmPst.pool,
536 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
539 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
542 memset((cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
543 rgGetSId(&cfm.t.ssta.s.sysId);
544 cfm.cfm.status = LCM_PRIM_NOK;
545 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
546 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
547 RgMiLrgStaCfm(&cfmPst, &cfm);
548 RLOG0(L_ERROR, "Gen Cfg not done");
552 switch(sta->hdr.elmId.elmnt)
555 SGetDateTime(&cfm.t.ssta.dt);
556 if (SGetSBuf(cfmPst.region, cfmPst.pool,
557 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
560 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
563 memset((cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
564 rgGetSId(&cfm.t.ssta.s.sysId);
565 cfm.cfm.status = LCM_PRIM_OK;
566 cfm.cfm.reason = LCM_REASON_NOT_APPL;
567 RgMiLrgStaCfm(&cfmPst, &cfm);
570 cfm.cfm.status = LCM_PRIM_OK;
571 cfm.cfm.reason = LCM_REASON_NOT_APPL;
572 SGetDateTime(&cfm.t.ssta.dt);
573 memcpy(&(cfm.t.ssta.s.rguSapSta),
574 &rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
576 RgMiLrgStaCfm(&cfmPst, &cfm);
579 cfm.cfm.status = LCM_PRIM_OK;
580 cfm.cfm.reason = LCM_REASON_NOT_APPL;
581 SGetDateTime(&cfm.t.ssta.dt);
582 memcpy(&(cfm.t.ssta.s.crgSapSta), &rgCb[inst].crgSap.sapSta,
584 RgMiLrgStaCfm(&cfmPst, &cfm);
587 cfm.cfm.status = LCM_PRIM_OK;
588 cfm.cfm.reason = LCM_REASON_NOT_APPL;
589 SGetDateTime(&cfm.t.ssta.dt);
590 memcpy(&(cfm.t.ssta.s.tfuSapSta), &rgCb[inst].tfuSap.sapSta,
592 RgMiLrgStaCfm(&cfmPst, &cfm);
595 cfm.cfm.status = LCM_PRIM_NOK;
596 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
597 RgMiLrgStaCfm(&cfmPst, &cfm);
598 RLOG1(L_ERROR, "Invalid elmnt=%d",sta->hdr.elmId.elmnt);
602 }/*-- RgMiLrgStaReq --*/
606 * @brief Layer Manager Control request handler.
610 * Function : RgMiLrgCntrlReq
612 * This function handles the control
613 * request received from the Layer Manager.
614 * -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
615 * and cntrl->t.cntrl.subAction, it performs the appropriate control action
616 * of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
617 * and layer shutdown.
618 * -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
620 * @param[in] Pst *pst, the post structure
621 * @param[in] RgMngmt *cntrl, the control parameter's structure
628 Pst *pst, /* post structure */
629 RgMngmt *cntrl /* control structure */
632 S16 RgMiLrgCntrlReq(pst, cntrl)
633 Pst *pst; /* post structure */
634 RgMngmt *cntrl; /* control structure */
637 S16 ret = ROK; /* return value */
641 /* Fill the post structure for sending the confirmation */
643 RG_IS_INST_VALID(pst->dstInst);
644 inst = pst->dstInst - RG_INST_START;
646 rgLMMFillCfmPst(pst, &cfmPst, cntrl);
648 memset(&cfm, 0, sizeof(RgMngmt));
650 cfm.hdr.transId = cntrl->hdr.transId;
652 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
653 cfm.t.cntrl.action = cntrl->t.cntrl.action;
654 cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
656 /* Check if General Config Done*/
657 if(rgCb[inst].rgInit.cfgDone != TRUE)
659 cfm.cfm.status = LCM_PRIM_NOK;
660 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
661 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
662 RgMiLrgCntrlCfm(&cfmPst, &cfm);
663 RLOG0(L_ERROR, "Gen Cfg not done");
667 /* General Config done, process the Control request */
668 switch(cntrl->hdr.elmId.elmnt)
671 rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
676 rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
679 cfm.cfm.status = LCM_PRIM_NOK;
680 cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
681 RgMiLrgCntrlCfm(&cfmPst, &cfm);
682 RLOG1(L_ERROR, "invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
686 }/*-- RgMiLrgCntrlReq --*/
690 * @brief SAP Configuration Handler.
694 * Function : rgLMMSapCfg
696 * This function in called by RgMiLrgCfgReq(). It handles the
697 * interface SAP configuration of the LTE MAC layer. It
698 * initializes the sapState to LRG_UNBND. Returns
699 * reason for success/failure of this function.
701 * @param[in] Inst inst
702 * @param[in] RgCfg *cfg, the Configuaration information
704 * -# LCM_REASON_GENCFG_NOT_DONE
705 * -# LCM_REASON_INVALID_SAP
706 * -# LCM_REASON_NOT_APPL
709 static uint16_t rgLMMSapCfg
712 RgCfg *cfg, /* Configuaration information */
713 Elmnt sapType /* Sap Type */
716 static uint16_t rgLMMSapCfg(inst,cfg,sapType)
718 RgCfg *cfg; /* Configuaration information */
719 Elmnt sapType; /* Sap Type */
722 uint16_t ret = LCM_REASON_NOT_APPL;
723 RgLowSapCfgInfo *lowSapCfg = NULLP;
724 RgUpSapCfgInfo *upSapCfg = NULLP;
725 RgUpSapCb *upSapCb = NULLP;
728 /* Check if Gen Config has been done */
729 if(rgCb[inst].rgInit.cfgDone != TRUE)
730 return (LCM_REASON_GENCFG_NOT_DONE);
735 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
736 (cfg->s.rguSap.selector != ODU_SELECTOR_TC) &&
737 (cfg->s.rguSap.selector != ODU_SELECTOR_LC))
739 ret = LCM_REASON_INVALID_PAR_VAL;
740 RLOG0(L_ERROR, "unsupported Selector value for RGU");
743 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
744 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
746 upSapCb->sapSta.sapState = LRG_UNBND;
748 upSapCfg = &(upSapCb->sapCfg);
749 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
750 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
751 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
752 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
753 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
754 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
755 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
756 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
757 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
758 upSapCfg->sapPst.route = cfg->s.rguSap.route;
759 upSapCfg->sapPst.intfVer = 0;
760 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
761 upSapCfg->suId = cfg->s.rguSap.suId;
762 upSapCfg->spId = cfg->s.rguSap.spId;
763 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
764 * there is cfg request with sap is 1*/
767 if ((cfg->s.crgSap.selector != ODU_SELECTOR_TC) &&
768 (cfg->s.crgSap.selector != ODU_SELECTOR_LC))
770 ret = LCM_REASON_INVALID_PAR_VAL;
771 RLOG0(L_ERROR, "unsupported Selector value for CRG");
774 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
776 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
778 upSapCfg = &rgCb[inst].crgSap.sapCfg;
780 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
781 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
782 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
783 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
784 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
785 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
786 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
787 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
788 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
789 upSapCfg->sapPst.route = cfg->s.crgSap.route;
790 upSapCfg->sapPst.intfVer = 0;
791 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
792 upSapCfg->suId = cfg->s.crgSap.suId;
793 upSapCfg->spId = cfg->s.crgSap.spId;
797 if ((cfg->s.tfuSap.selector != ODU_SELECTOR_TC) &&
798 (cfg->s.tfuSap.selector != ODU_SELECTOR_LC))
800 ret = LCM_REASON_INVALID_PAR_VAL;
801 RLOG0(L_ERROR, "unsupported Selector value for TFU");
805 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
807 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
809 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
811 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
812 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
813 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
814 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
815 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
816 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
817 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
818 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
819 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
820 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
821 lowSapCfg->sapPst.intfVer = 0;
822 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
823 lowSapCfg->suId = cfg->s.tfuSap.suId;
824 lowSapCfg->spId = cfg->s.tfuSap.spId;
825 memcpy(&lowSapCfg->bndTmr, &cfg->s.tfuSap.bndTmr,
829 /* would never reach here */
837 * @brief General Configuration Handler.
841 * Function : rgLMMGenCfg
843 * This function in called by RgMiLrgCfgReq(). It handles the
844 * general configuration of the LTE MAC layer. It initializes
845 * the hash lists of RgCb. Returns
846 * reason for success/failure of this function.
848 * @param[in] Inst inst
849 * @param[in] RgCfg *cfg, the Configuaration information
851 * -# LCM_REASON_NOT_APPL
852 * -# LCM_REASON_INVALID_MSGTYPE
853 * -# LCM_REASON_MEM_NOAVAIL
856 static uint16_t rgLMMGenCfg
859 RgCfg *cfg /* Configuaration information */
862 static uint16_t rgLMMGenCfg(inst,cfg)
864 RgCfg *cfg; /* Configuaration information */
867 uint16_t ret = LCM_REASON_NOT_APPL;
870 /* Check if General Configuration is done already */
871 if (rgCb[inst].rgInit.cfgDone == TRUE)
873 return (LCM_REASON_INVALID_MSGTYPE);
875 if ((cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_TC) &&
876 (cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_LC))
878 RLOG0(L_ERROR, "unsupported Selector value for RGU");
879 return (LCM_REASON_INVALID_PAR_VAL);
881 /* Update the Pst structure for LM interface */
882 memcpy(&rgCb[inst].rgInit.lmPst, &cfg->s.genCfg.lmPst,
885 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
886 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
887 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
888 rgCb[inst].rgInit.lmPst.event = EVTNONE;
890 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
891 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
892 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
894 macCb.macInst = rgCb[inst].rgInit.inst;
895 macCb.procId = rgCb[inst].rgInit.procId;
897 /* Initialize SAP States */
898 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
900 if(cfg->s.genCfg.numRguSaps == 0)
902 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Invalid numRguSap.\n"));
906 /* allocate RGR saps */
907 if (SGetSBuf(rgCb[inst].rgInit.region,
908 rgCb[inst].rgInit.pool,
909 (Data **)&rgCb[inst].rguSap,
910 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
912 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Failed to allocate mem for RGU SAP's.\n"));
915 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
917 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
919 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
920 memset(&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
922 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
923 /* Initialize the timer blocks */
924 cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
925 /* Initialzie the timer queue */
926 memset(&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
927 /* Initialize the timer control point */
928 memset(&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
929 rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
931 /* Timer Registration request to SSI */
932 if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
933 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
936 RLOG0(L_ERROR, "Failed to register timer");
938 SPutSBuf(rgCb[inst].rgInit.region,
939 rgCb[inst].rgInit.pool,
940 (Data *)rgCb[inst].rguSap,
941 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
943 return (LCM_REASON_MEM_NOAVAIL);
946 /* Set Config done in TskInit */
947 rgCb[inst].rgInit.cfgDone = TRUE;
953 /***********************************************************
955 * Func : rgLMMShutdown
958 * Desc : Handles the MAC layer shutdown request. Calls
959 * rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
968 **********************************************************/
970 static Void rgLMMShutdown
975 static Void rgLMMShutdown(inst)
979 RgCellCb *cell = rgCb[inst].cell;
983 /* Unbind the TFU Sap */
984 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
986 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
987 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
989 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
991 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
993 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
995 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
996 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1002 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1004 rgTOMRlsSf(inst,&cell->subFrms[idx]);
1007 rgCFGFreeCellCb(cell);
1010 /* Deleting the RGU SAPs */
1011 SPutSBuf(rgCb[inst].rgInit.region,
1012 rgCb[inst].rgInit.pool,
1013 (Data *)rgCb[inst].rguSap,
1014 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
1015 rgCb[inst].rguSap = NULLP;
1017 rgCb[inst].inactiveCell = NULLP;
1018 rgCb[inst].cell = NULLP;
1020 /* De-register the Timer Service */
1021 (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
1022 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr);
1024 /* call back the task initialization function to intialize
1025 * the global RgCb Struct */
1026 rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region,
1027 rgCb[inst].rgInit.reason);
1033 /***********************************************************
1035 * Func : rgLMMGenCntrl
1038 * Desc : Processes the LM control request for STGEN elmnt.
1047 **********************************************************/
1049 static Void rgLMMGenCntrl
1056 static Void rgLMMGenCntrl(cntrl, cfm, cfmPst)
1062 Inst inst = (cfmPst->srcInst - RG_INST_START);
1064 cfm->cfm.status = LCM_PRIM_OK;
1065 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1068 switch(cntrl->t.cntrl.action)
1071 /* Action is Enable */
1072 switch(cntrl->t.cntrl.subAction)
1076 rgCb[inst].rgInit.trc = TRUE;
1077 rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1078 /*Store the response and TransId for sending the Traces */
1079 memcpy(&rgCb[inst].genCfg.trcResp.response,
1080 &cntrl->hdr.response, sizeof(Resp));
1081 rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1085 /* Enable Unsolicited Status (alarms) */
1086 rgCb[inst].rgInit.usta = TRUE;
1087 /*Store the response and TransId for sending the Alarms */
1088 memcpy(&rgCb[inst].genCfg.ustaResp.response,
1089 &cntrl->hdr.response, sizeof(Resp));
1090 rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1093 /* Enable Debug Printing */
1095 rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1100 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1105 cfm->cfm.status = LCM_PRIM_NOK;
1106 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1107 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1112 /* Action is Diable immidiately */
1113 switch(cntrl->t.cntrl.subAction)
1116 /* Disable Traces */
1117 rgCb[inst].rgInit.trc = FALSE;
1120 /* Disable Unsolicited Status (alarms) */
1121 rgCb[inst].rgInit.usta = FALSE;
1124 /* Disable Debug Printing */
1126 rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1131 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1136 cfm->cfm.status = LCM_PRIM_NOK;
1137 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1138 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1143 /* Free all the memory dynamically allocated by MAC */
1144 rgLMMShutdown(inst);
1147 cfm->cfm.status = LCM_PRIM_NOK;
1148 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1149 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1152 RgMiLrgCntrlCfm(cfmPst, cfm);
1157 /***********************************************************
1159 * Func : rgLMMSapCntrl
1162 * Desc : Processes the LM control request for STxxxSAP elmnt.
1171 **********************************************************/
1173 static Void rgLMMSapCntrl
1180 static Void rgLMMSapCntrl(cntrl, cfm, cfmPst)
1186 Inst inst = cfmPst->srcInst - RG_INST_START;
1188 /* Only TFU Sap can be controlled by LM */
1189 switch(cntrl->hdr.elmId.elmnt)
1192 switch(cntrl->t.cntrl.action)
1195 /* Bind Enable Request */
1196 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1197 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1199 cfm->cfm.status = LCM_PRIM_NOK;
1200 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1204 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1206 rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val,
1207 (PTR)&rgCb[inst].tfuSap);
1209 /* Change SAP state */
1210 rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1211 rgCb[inst].tfuSap.numBndRetries++;
1212 /* Store the response and TransId for sending
1213 * the Control confirm */
1214 memcpy(&rgCb[inst].genCfg.bndCfmResp.response,
1215 &cntrl->hdr.response, sizeof(Resp));
1216 rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1218 /* Sending Status Indication to Layer Manager */
1219 cfm->cfm.status = LCM_PRIM_OK_NDONE;
1220 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1221 RgMiLrgCntrlCfm(cfmPst, cfm);
1223 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1224 rgCb[inst].tfuSap.sapCfg.spId);
1229 /* Unbind request */
1231 /* Check if the SAP is configured */
1232 if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1233 (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1235 cfm->cfm.status = LCM_PRIM_NOK;
1236 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1240 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1241 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1243 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1245 /* Change SAP state */
1246 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1247 cfm->cfm.status = LCM_PRIM_OK;
1248 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1252 /* Delete SAP, does initialization of SAP */
1253 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1254 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1256 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1257 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1259 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1262 memset(&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1263 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1264 cfm->cfm.status = LCM_PRIM_OK;
1265 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1268 cfm->cfm.status = LCM_PRIM_NOK;
1269 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1270 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1271 cntrl->t.cntrl.action));
1276 switch(cntrl->t.cntrl.action)
1279 memset(&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1280 rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1281 cfm->cfm.status = LCM_PRIM_OK;
1282 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1285 cfm->cfm.status = LCM_PRIM_NOK;
1286 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1287 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1288 cntrl->t.cntrl.action));
1293 switch(cntrl->t.cntrl.action)
1296 memset(&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1297 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1298 cfm->cfm.status = LCM_PRIM_OK;
1299 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1302 cfm->cfm.status = LCM_PRIM_NOK;
1303 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1304 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1310 /* Would never here. */
1313 RgMiLrgCntrlCfm(cfmPst, cfm);
1318 /***********************************************************
1320 * Func : rgLMMFillCfmPst
1323 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
1324 * and the cfm->hdr.response.
1333 **********************************************************/
1335 static Void rgLMMFillCfmPst
1342 static Void rgLMMFillCfmPst(reqPst, cfmPst, cfm)
1349 inst = (reqPst->dstInst - RG_INST_START);
1351 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
1352 cfmPst->srcInst = rgCb[inst].rgInit.inst;
1353 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1354 cfmPst->dstEnt = reqPst->srcEnt;
1355 cfmPst->dstInst = reqPst->srcInst;
1356 cfmPst->dstProcId = reqPst->srcProcId;
1358 cfmPst->selector = cfm->hdr.response.selector;
1359 cfmPst->prior = cfm->hdr.response.prior;
1360 cfmPst->route = cfm->hdr.response.route;
1361 cfmPst->region = cfm->hdr.response.mem.region;
1362 cfmPst->pool = cfm->hdr.response.mem.pool;
1369 * @brief Timer start handler.
1373 * Function : rgLMMStartTmr
1375 * This function based on the input parameters starts the timer for
1376 * "tmrVal" duration. As of now MAC uses the timer functionality for
1377 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1379 * @param[in] Inst inst
1380 * @param[in] S16 tmrEvnt, the Timer Event
1381 * @param[in] uint32_t tmrVal, the Wait Time
1382 * @param[in] PTR cb, Entry for which Timer expired
1390 S16 tmrEvnt, /* Timer Event */
1391 uint32_t tmrVal, /* Wait Time */
1392 PTR cb /* Entry for which Timer Expired */
1395 S16 rgLMMStartTmr(tmrEvnt, tmrVal, cb)
1397 S16 tmrEvnt; /* Timer Event */
1398 uint32_t tmrVal; /* Wait Time */
1399 PTR cb; /* Entry for which Timer Expired */
1407 /* Initialize the arg structure */
1408 memset(&arg, 0, sizeof(CmTmrArg));
1410 arg.tqCp = &rgCb[inst].tmrTqCp;
1411 arg.tq = rgCb[inst].tmrTq;
1412 arg.timers = rgCb[inst].tmrBlk;
1415 arg.max = RG_MAX_TIMER;
1416 arg.evnt = RG_BNDREQ_TMR;
1425 * @brief Timer stop handler.
1429 * Function : rgLMMStopTmr
1431 * This function based on the input parameters stops the timer for
1432 * "tmrEvnt". As of now MAC uses the timer functionality for
1433 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1434 * Once the bind happens and this timer is stopped, the timer functionality
1435 * is deregistered with SSI. As there is no further use of timer processing.
1437 * @param[in] Inst inst
1438 * @param[in] S16 tmrEvnt, the Timer Event
1439 * @param[in] PTR cb, Entry for which Timer expired
1447 Inst inst, /* Scheduler instance */
1448 S16 tmrEvnt, /* Timer Event */
1449 PTR cb /* Entry for which Timer Expired */
1452 S16 rgLMMStopTmr(inst,tmrEvnt, cb)
1453 Inst inst; /* Scheduler instance */
1454 S16 tmrEvnt; /* Timer Event */
1455 PTR cb; /* Entry for which Timer Expired */
1465 for(i=0;i<RG_MAX_TIMER;i++)
1467 /* Search for the Timer Blocks */
1468 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1470 /* Initialize the arg structure */
1471 memset(&arg, 0, sizeof(CmTmrArg));
1473 arg.tqCp = &rgCb[inst].tmrTqCp;
1474 arg.tq = rgCb[inst].tmrTq;
1475 arg.timers = rgCb[inst].tmrBlk;
1477 arg.max = RG_MAX_TIMER;
1495 * @brief Timer Expiry handler.
1499 * Function : rgLMMTmrExpiry
1501 * This is a callback function used as an input parameter to cmPrcTmr()
1502 * to check expiry of any timer. In this function, the only concern is
1503 * about tmrEvnt=Bind timer.
1505 * @param[in] PTR cb, Entry for which Timer expired
1506 * @param[in] S16 tmrEvnt, the Timer Event
1513 PTR cb, /* Pointer to timer control block */
1514 S16 tmrEvnt /* Timer Event */
1517 S16 rgLMMTmrExpiry(cb,tmrEvnt)
1518 PTR cb; /* Pointer to timer control block */
1519 S16 tmrEvnt; /* Timer Event */
1523 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1524 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1529 tfuSap->numBndRetries++;
1530 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1532 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1533 LCM_CAUSE_TMR_EXPIRED, NULLP);
1537 /* Restart the bind timer */
1538 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1540 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1544 /* Send bind request */
1545 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1546 rgCb[inst].tfuSap.sapCfg.spId);
1550 RLOG1(L_ERROR, "Invalid tmrEvnt=%d",tmrEvnt);
1560 * @brief Layer Manager Unsolicited Status Indication generation.
1564 * Function : rgLMMStaInd
1566 * This API is used by the other modules of MAC to send a unsolicited
1567 * status indication to the Layer Manager.
1569 * @param[in] Inst inst
1570 * @param[in] uint16_t category, the Alarm category
1571 * @param[in] uint16_t event, the Alarm event
1572 * @param[in] uint16_t cause, the cause of the Alarm
1573 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1587 S16 rgLMMStaInd(inst,category, event, cause, dgn)
1598 if(rgCb[inst].rgInit.usta == FALSE)
1603 memset(&usta, 0, sizeof(RgMngmt));
1605 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1606 usta.t.usta.cmAlarm.category = category;
1607 usta.t.usta.cmAlarm.event = event;
1608 usta.t.usta.cmAlarm.cause = cause;
1611 memcpy(&usta.t.usta.dgn, dgn, sizeof(RgUstaDgn));
1614 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1615 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1616 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1617 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1618 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1619 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1621 return (RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1626 * @brief Layer Manager Trace Indication generation.
1630 * Function : rgLMMTrcInd
1632 * This API is used by the other modules of MAC to send a
1633 * Trace indication to the Layer Manager.
1635 * @param[in] Inst inst
1636 * @param[in] Buffer *srcMbuf, the Message Buffer .
1637 * @param[in] uint8_t event, the trace event.
1644 Buffer *srcMbuf, /* Message Buffer */
1645 uint8_t event /* event */
1648 Void rgLMMTrcInd(inst,srcMbuf,event)
1650 Buffer *srcMbuf; /* Message Buffer */
1651 uint8_t event; /* event */
1654 Buffer *dstMbuf = NULLP;
1663 if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1665 RLOG0(L_ERROR, "Trace Disabled.");
1669 memset(&trc, 0, sizeof(RgMngmt));
1671 pst = rgCb[inst].rgInit.lmPst;
1672 pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1673 pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1674 pst.route = rgCb[inst].genCfg.trcResp.response.route;
1675 pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1676 pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1678 trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1680 SGetDateTime(&trc.t.trc.dt);
1682 /* Check if the whole buffer is to be sent in Trace indication */
1683 if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1685 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1688 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1691 trc.cfm.status = LCM_PRIM_OK;
1692 trc.cfm.reason = LCM_REASON_NOT_APPL;
1693 trc.t.trc.evnt = event;
1695 /* Send Trace Indication to Layer manager */
1696 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1698 /* check if only a specified number of bytes are to be sent */
1699 else if(rgCb[inst].trcLen > 0)
1701 /* Get the length of the recvd message buffer */
1702 if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1704 RLOG0(L_ERROR, "SFndLenMsg Failed.");
1707 /* Check if the recvd buffer size is less than request trace len */
1708 if(bufLen < rgCb[inst].trcLen)
1710 /* Copy the whole of the recvd buffer in trace indication */
1712 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1715 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1719 trc.cfm.status = LCM_PRIM_OK;
1720 trc.cfm.reason = LCM_REASON_NOT_APPL;
1721 trc.t.trc.evnt = event;
1723 /* Send Trace Indication to Layer manager */
1724 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1726 /* if the recvd buffer size is greater than request trace len */
1727 if(bufLen >= rgCb[inst].trcLen)
1729 /* Get a temporary buffer to store the msg */
1730 if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1732 RLOG0(L_ERROR, "rgAllocSBuf Failed.");
1736 /* Copy trcLen nos of bytes from the recvd message */
1737 if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)
1739 RLOG0(L_ERROR, "SCpyMsgFix Failed.");
1743 if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1745 RLOG0(L_ERROR, "dstMbuf Allocation Failed");
1748 /* Copy the tempBuf data to dst mBuf */
1749 if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1751 RLOG0(L_ERROR, "SCpyFixMsg Failed.");
1755 /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1757 /* Free the memory allocated for tempBuf */
1758 rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1760 trc.cfm.status = LCM_PRIM_OK;
1761 trc.cfm.reason = LCM_REASON_NOT_APPL;
1762 trc.t.trc.evnt = event;
1764 /* Send Trace Indication to Layer manager */
1765 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1773 * @brief Layer Manager Control Confirm generation handler
1774 * for Bind Confirm reception at TFU interface.
1775 * RgLiTfuBndCfm() forwards the confirmation to this
1776 * function. All SAP state related handling is restricted
1777 * to LMM modules, hence the cfm forwarding.
1781 * Function : rgLMMBndCfm
1783 * This API is used by the LIM module of MAC to forward
1784 * the Bind Confirm it receives over the TFU interface.
1786 * @param[in] Pst *pst, Post Structure
1787 * @param[in] SuId suId, Service user ID
1788 * @param[in] uint8_t status, Status
1795 Pst *pst, /* Post Structure */
1796 SuId suId, /* Service user ID */
1797 uint8_t status /* Status */
1800 S16 rgLMMBndCfm(pst,suId,status)
1801 Pst *pst; /* Post Structure */
1802 SuId suId; /* Service user ID */
1803 uint8_t status; /* Status */
1806 Inst inst = pst->dstInst - RG_INST_START;
1814 /* Check if the suId is valid */
1815 if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1817 RLOG0(L_ERROR, "Invalid SuId");
1821 /* check the Sap State */
1822 switch(rgCb[inst].tfuSap.sapSta.sapState)
1824 case LRG_WAIT_BNDCFM:
1827 /* SAP is already bound */
1833 cfmPst = rgCb[inst].rgInit.lmPst;
1834 cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1835 cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1836 cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1837 cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1838 cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1840 memset(&cntrlCfm, 0, sizeof(RgMngmt));
1844 case CM_BND_OK: /* status is OK */
1845 /* Change SAP state to Bound */
1846 rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1847 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1849 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1851 /* Send Control Confirm with status as OK to Layer Manager */
1852 cntrlCfm.cfm.status = LCM_PRIM_OK;
1853 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1857 /* Change SAP state to UnBound */
1858 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1859 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1861 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1863 /* Send Control Confirm with status as NOK to Layer Manager */
1864 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1865 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1868 rgCb[inst].tfuSap.numBndRetries = 0;
1869 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1870 cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1872 ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1879 * @brief LTE MAC timer call back function registered with SSI.
1883 * Function : rgActvTmr
1885 * This function is invoked by SSI for every timer activation
1898 S16 rgActvTmr(ent, inst)
1903 Inst macInst = (inst - RG_INST_START);
1905 /* Check if any MAC timer has expired */
1906 cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1910 } /* end of rgActvTmr */
1912 /**********************************************************************
1915 **********************************************************************/