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)
277 /* Start WLS message receiver thread */
278 LwrMacStartWlsRcvr();
279 /* Allocate memory for UL transmissions */
280 LwrMacEnqueueWlsBlock();
282 reason = rgLMMGenCfg(inst,&cfg->t.cfg);
287 reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
291 reason = LCM_REASON_INVALID_ELMNT;
292 RLOG1(L_ERROR, "Invalid Elmnt=%d",
293 cfg->hdr.elmId.elmnt);
297 if (reason != LCM_REASON_NOT_APPL)
302 cfm.cfm.status = ret;
303 cfm.cfm.reason = reason;
305 RgMiLrgCfgCfm(&cfmPst, &cfm);
308 }/*-- RgMiLrgCfgReq --*/
312 * @brief Layer Manager Statistics request handler.
316 * Function : RgMiLrgStsReq
318 * This function handles the statistics
319 * request received from the Layer Manager.
320 * -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
321 * statistics from the rgCb global control block.
322 * -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
323 * -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
325 * @param[in] Pst *pst, the post structure
326 * @param[in] RgMngmt *sts, the statistics parameter's structure
333 Pst *pst, /* post structure */
334 RgMngmt *sts /* statistics structure */
337 S16 RgMiLrgStsReq(pst, sts)
338 Pst *pst; /* post structure */
339 RgMngmt *sts; /* statistics structure */
346 RG_IS_INST_VALID(pst->dstInst);
347 inst = pst->dstInst - RG_INST_START;
348 /* Fill the post structure for sending the confirmation */
349 rgLMMFillCfmPst(pst, &cfmPst, sts);
351 memset(&cfm, 0, sizeof(RgMngmt));
354 cfm.hdr.transId = sts->hdr.transId;
356 SGetDateTime(&cfm.t.sts.dt);
357 cfm.cfm.status = LCM_PRIM_OK;
358 cfm.cfm.reason = LCM_REASON_NOT_APPL;
359 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
360 cfm.t.sts.action = sts->t.sts.action;
362 /* Check if General Config Done */
363 if(rgCb[inst].rgInit.cfgDone != TRUE)
365 cfm.cfm.status = LCM_PRIM_NOK;
366 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
367 RgMiLrgStsCfm(&cfmPst,&cfm);
368 RLOG0(L_ERROR, "Gen Cfg not done");
372 switch(sts->hdr.elmId.elmnt)
376 memcpy(&(cfm.t.sts.s.genSts), &rgCb[inst].genSts,
378 /* check if action is read and reset */
379 if(sts->t.sts.action == ARST)
381 rgCb[inst].genSts.numHarqFail = 0;
386 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
388 for(cqi=0; cqi <= 14; cqi++)
390 /* Filling DL ACK/NACK stats */
391 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
392 hqFailStats.dlCqiStat[cqi].mcs;
393 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
394 hqFailStats.dlCqiStat[cqi].numOfNacks;
395 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
396 hqFailStats.dlCqiStat[cqi].numOfAcks;
398 /* Filling UL ACK/NACK stats */
399 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
400 hqFailStats.ulCqiStat[cqi].mcs;
401 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
402 hqFailStats.ulCqiStat[cqi].numOfNacks;
403 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
404 hqFailStats.ulCqiStat[cqi].numOfAcks;
406 /* Filling DL HQ Retx stats */
407 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
408 hqRetxStats.dlCqiStat[cqi].mcs;
409 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
410 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
411 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
412 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
413 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
414 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
415 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
416 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
417 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
418 hqRetxStats.dlCqiStat[cqi].totalTx;
420 /* Filling UL HQ Retx stats */
421 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
422 hqRetxStats.ulCqiStat[cqi].mcs;
423 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
424 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
425 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
426 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
427 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
428 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
429 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
430 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
431 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
432 hqRetxStats.ulCqiStat[cqi].totalTx;
434 /* Reset statistics */
435 if(sts->t.sts.action == ZEROSTS)
437 memset(&hqRetxStats, 0, \
438 sizeof(RgSchHqRetxStats));
439 memset(&hqFailStats, 0, \
440 sizeof(RgSchNackAckStats));
443 #endif /* MAC_SCH_STATS*/
447 memcpy(&(cfm.t.sts.s.rguSts), &rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
450 /* check if action is read and reset */
451 if(sts->t.sts.action == ARST)
452 memset(&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
456 memcpy(&(cfm.t.sts.s.crgSts), &rgCb[inst].crgSap.sapSts,
459 /* check if action is read and reset */
460 if(sts->t.sts.action == ARST)
461 memset(&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
465 memcpy(&(cfm.t.sts.s.tfuSts), &rgCb[inst].tfuSap.sapSts,
468 /* check if action is read and reset */
469 if(sts->t.sts.action == ARST)
470 memset(&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
474 cfm.cfm.status = LCM_PRIM_NOK;
475 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
476 RLOG1(L_ERROR, "Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
479 RgMiLrgStsCfm(&cfmPst,&cfm);
481 }/*-- RgMiLrgStsReq --*/
485 * @brief Layer Manager Status request handler.
489 * Function : RgMiLrgStaReq
491 * This function handles the solicited status
492 * request received from the Layer Manager.
493 * -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
494 * particular SAP from the rgCb global control block.
495 * -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
497 * @param[in] Pst *pst, the post structure
498 * @param[in] RgMngmt *sta, the status parameter's structure
505 Pst *pst, /* post structure */
506 RgMngmt *sta /* status structure */
509 S16 RgMiLrgStaReq(pst, sta)
510 Pst *pst; /* post structure */
511 RgMngmt *sta; /* status structure */
519 RG_IS_INST_VALID(pst->dstInst);
520 inst = pst->dstInst - RG_INST_START;
523 /* Fill the post structure for sending the confirmation */
524 rgLMMFillCfmPst(pst, &cfmPst, sta);
526 if (sta->t.ssta.s.sysId.ptNmb != NULLP)
528 SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
531 memset(&cfm, 0, sizeof(RgMngmt));
532 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
535 cfm.hdr.transId = sta->hdr.transId;
537 /* Check if General Config Done */
538 if(rgCb[inst].rgInit.cfgDone != TRUE)
540 SGetDateTime(&cfm.t.ssta.dt);
541 if (SGetSBuf(cfmPst.region, cfmPst.pool,
542 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
545 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
548 memset((cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
549 rgGetSId(&cfm.t.ssta.s.sysId);
550 cfm.cfm.status = LCM_PRIM_NOK;
551 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
552 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
553 RgMiLrgStaCfm(&cfmPst, &cfm);
554 RLOG0(L_ERROR, "Gen Cfg not done");
558 switch(sta->hdr.elmId.elmnt)
561 SGetDateTime(&cfm.t.ssta.dt);
562 if (SGetSBuf(cfmPst.region, cfmPst.pool,
563 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
566 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
569 memset((cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
570 rgGetSId(&cfm.t.ssta.s.sysId);
571 cfm.cfm.status = LCM_PRIM_OK;
572 cfm.cfm.reason = LCM_REASON_NOT_APPL;
573 RgMiLrgStaCfm(&cfmPst, &cfm);
576 cfm.cfm.status = LCM_PRIM_OK;
577 cfm.cfm.reason = LCM_REASON_NOT_APPL;
578 SGetDateTime(&cfm.t.ssta.dt);
579 memcpy(&(cfm.t.ssta.s.rguSapSta),
580 &rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
582 RgMiLrgStaCfm(&cfmPst, &cfm);
585 cfm.cfm.status = LCM_PRIM_OK;
586 cfm.cfm.reason = LCM_REASON_NOT_APPL;
587 SGetDateTime(&cfm.t.ssta.dt);
588 memcpy(&(cfm.t.ssta.s.crgSapSta), &rgCb[inst].crgSap.sapSta,
590 RgMiLrgStaCfm(&cfmPst, &cfm);
593 cfm.cfm.status = LCM_PRIM_OK;
594 cfm.cfm.reason = LCM_REASON_NOT_APPL;
595 SGetDateTime(&cfm.t.ssta.dt);
596 memcpy(&(cfm.t.ssta.s.tfuSapSta), &rgCb[inst].tfuSap.sapSta,
598 RgMiLrgStaCfm(&cfmPst, &cfm);
601 cfm.cfm.status = LCM_PRIM_NOK;
602 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
603 RgMiLrgStaCfm(&cfmPst, &cfm);
604 RLOG1(L_ERROR, "Invalid elmnt=%d",sta->hdr.elmId.elmnt);
608 }/*-- RgMiLrgStaReq --*/
612 * @brief Layer Manager Control request handler.
616 * Function : RgMiLrgCntrlReq
618 * This function handles the control
619 * request received from the Layer Manager.
620 * -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
621 * and cntrl->t.cntrl.subAction, it performs the appropriate control action
622 * of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
623 * and layer shutdown.
624 * -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
626 * @param[in] Pst *pst, the post structure
627 * @param[in] RgMngmt *cntrl, the control parameter's structure
634 Pst *pst, /* post structure */
635 RgMngmt *cntrl /* control structure */
638 S16 RgMiLrgCntrlReq(pst, cntrl)
639 Pst *pst; /* post structure */
640 RgMngmt *cntrl; /* control structure */
643 S16 ret = ROK; /* return value */
647 /* Fill the post structure for sending the confirmation */
649 RG_IS_INST_VALID(pst->dstInst);
650 inst = pst->dstInst - RG_INST_START;
652 rgLMMFillCfmPst(pst, &cfmPst, cntrl);
654 memset(&cfm, 0, sizeof(RgMngmt));
656 cfm.hdr.transId = cntrl->hdr.transId;
658 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
659 cfm.t.cntrl.action = cntrl->t.cntrl.action;
660 cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
662 /* Check if General Config Done*/
663 if(rgCb[inst].rgInit.cfgDone != TRUE)
665 cfm.cfm.status = LCM_PRIM_NOK;
666 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
667 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
668 RgMiLrgCntrlCfm(&cfmPst, &cfm);
669 RLOG0(L_ERROR, "Gen Cfg not done");
673 /* General Config done, process the Control request */
674 switch(cntrl->hdr.elmId.elmnt)
677 rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
682 rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
685 cfm.cfm.status = LCM_PRIM_NOK;
686 cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
687 RgMiLrgCntrlCfm(&cfmPst, &cfm);
688 RLOG1(L_ERROR, "invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
692 }/*-- RgMiLrgCntrlReq --*/
696 * @brief SAP Configuration Handler.
700 * Function : rgLMMSapCfg
702 * This function in called by RgMiLrgCfgReq(). It handles the
703 * interface SAP configuration of the LTE MAC layer. It
704 * initializes the sapState to LRG_UNBND. Returns
705 * reason for success/failure of this function.
707 * @param[in] Inst inst
708 * @param[in] RgCfg *cfg, the Configuaration information
710 * -# LCM_REASON_GENCFG_NOT_DONE
711 * -# LCM_REASON_INVALID_SAP
712 * -# LCM_REASON_NOT_APPL
715 static uint16_t rgLMMSapCfg
718 RgCfg *cfg, /* Configuaration information */
719 Elmnt sapType /* Sap Type */
722 static uint16_t rgLMMSapCfg(inst,cfg,sapType)
724 RgCfg *cfg; /* Configuaration information */
725 Elmnt sapType; /* Sap Type */
728 uint16_t ret = LCM_REASON_NOT_APPL;
729 RgLowSapCfgInfo *lowSapCfg = NULLP;
730 RgUpSapCfgInfo *upSapCfg = NULLP;
731 RgUpSapCb *upSapCb = NULLP;
734 /* Check if Gen Config has been done */
735 if(rgCb[inst].rgInit.cfgDone != TRUE)
736 return (LCM_REASON_GENCFG_NOT_DONE);
741 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
742 (cfg->s.rguSap.selector != ODU_SELECTOR_TC) &&
743 (cfg->s.rguSap.selector != ODU_SELECTOR_LC))
745 ret = LCM_REASON_INVALID_PAR_VAL;
746 RLOG0(L_ERROR, "unsupported Selector value for RGU");
749 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
750 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
752 upSapCb->sapSta.sapState = LRG_UNBND;
754 upSapCfg = &(upSapCb->sapCfg);
755 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
756 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
757 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
758 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
759 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
760 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
761 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
762 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
763 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
764 upSapCfg->sapPst.route = cfg->s.rguSap.route;
765 upSapCfg->sapPst.intfVer = 0;
766 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
767 upSapCfg->suId = cfg->s.rguSap.suId;
768 upSapCfg->spId = cfg->s.rguSap.spId;
769 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
770 * there is cfg request with sap is 1*/
773 if ((cfg->s.crgSap.selector != ODU_SELECTOR_TC) &&
774 (cfg->s.crgSap.selector != ODU_SELECTOR_LC))
776 ret = LCM_REASON_INVALID_PAR_VAL;
777 RLOG0(L_ERROR, "unsupported Selector value for CRG");
780 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
782 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
784 upSapCfg = &rgCb[inst].crgSap.sapCfg;
786 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
787 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
788 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
789 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
790 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
791 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
792 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
793 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
794 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
795 upSapCfg->sapPst.route = cfg->s.crgSap.route;
796 upSapCfg->sapPst.intfVer = 0;
797 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
798 upSapCfg->suId = cfg->s.crgSap.suId;
799 upSapCfg->spId = cfg->s.crgSap.spId;
803 if ((cfg->s.tfuSap.selector != ODU_SELECTOR_TC) &&
804 (cfg->s.tfuSap.selector != ODU_SELECTOR_LC))
806 ret = LCM_REASON_INVALID_PAR_VAL;
807 RLOG0(L_ERROR, "unsupported Selector value for TFU");
811 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
813 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
815 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
817 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
818 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
819 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
820 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
821 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
822 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
823 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
824 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
825 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
826 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
827 lowSapCfg->sapPst.intfVer = 0;
828 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
829 lowSapCfg->suId = cfg->s.tfuSap.suId;
830 lowSapCfg->spId = cfg->s.tfuSap.spId;
831 memcpy(&lowSapCfg->bndTmr, &cfg->s.tfuSap.bndTmr,
835 /* would never reach here */
843 * @brief General Configuration Handler.
847 * Function : rgLMMGenCfg
849 * This function in called by RgMiLrgCfgReq(). It handles the
850 * general configuration of the LTE MAC layer. It initializes
851 * the hash lists of RgCb. Returns
852 * reason for success/failure of this function.
854 * @param[in] Inst inst
855 * @param[in] RgCfg *cfg, the Configuaration information
857 * -# LCM_REASON_NOT_APPL
858 * -# LCM_REASON_INVALID_MSGTYPE
859 * -# LCM_REASON_MEM_NOAVAIL
862 static uint16_t rgLMMGenCfg
865 RgCfg *cfg /* Configuaration information */
868 static uint16_t rgLMMGenCfg(inst,cfg)
870 RgCfg *cfg; /* Configuaration information */
873 uint16_t ret = LCM_REASON_NOT_APPL;
876 /* Check if General Configuration is done already */
877 if (rgCb[inst].rgInit.cfgDone == TRUE)
879 return (LCM_REASON_INVALID_MSGTYPE);
881 if ((cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_TC) &&
882 (cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_LC))
884 RLOG0(L_ERROR, "unsupported Selector value for RGU");
885 return (LCM_REASON_INVALID_PAR_VAL);
887 /* Update the Pst structure for LM interface */
888 memcpy(&rgCb[inst].rgInit.lmPst, &cfg->s.genCfg.lmPst,
891 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
892 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
893 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
894 rgCb[inst].rgInit.lmPst.event = EVTNONE;
896 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
897 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
898 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
900 macCb.macInst = rgCb[inst].rgInit.inst;
901 macCb.procId = rgCb[inst].rgInit.procId;
903 /* Initialize SAP States */
904 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
906 if(cfg->s.genCfg.numRguSaps == 0)
908 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Invalid numRguSap.\n"));
912 /* allocate RGR saps */
913 if (SGetSBuf(rgCb[inst].rgInit.region,
914 rgCb[inst].rgInit.pool,
915 (Data **)&rgCb[inst].rguSap,
916 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
918 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Failed to allocate mem for RGU SAP's.\n"));
921 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
923 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
925 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
926 memset(&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
928 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
929 /* Initialize the timer blocks */
930 cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
931 /* Initialzie the timer queue */
932 memset(&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
933 /* Initialize the timer control point */
934 memset(&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
935 rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
937 /* Timer Registration request to SSI */
938 if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
939 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
942 RLOG0(L_ERROR, "Failed to register timer");
944 SPutSBuf(rgCb[inst].rgInit.region,
945 rgCb[inst].rgInit.pool,
946 (Data *)rgCb[inst].rguSap,
947 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
949 return (LCM_REASON_MEM_NOAVAIL);
952 /* Set Config done in TskInit */
953 rgCb[inst].rgInit.cfgDone = TRUE;
959 /***********************************************************
961 * Func : rgLMMShutdown
964 * Desc : Handles the MAC layer shutdown request. Calls
965 * rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
974 **********************************************************/
976 static Void rgLMMShutdown
981 static Void rgLMMShutdown(inst)
985 RgCellCb *cell = rgCb[inst].cell;
989 /* Unbind the TFU Sap */
990 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
992 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
993 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
995 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
997 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
999 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
1001 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1002 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1008 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1010 rgTOMRlsSf(inst,&cell->subFrms[idx]);
1013 rgCFGFreeCellCb(cell);
1016 /* Deleting the RGU SAPs */
1017 SPutSBuf(rgCb[inst].rgInit.region,
1018 rgCb[inst].rgInit.pool,
1019 (Data *)rgCb[inst].rguSap,
1020 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
1021 rgCb[inst].rguSap = NULLP;
1023 rgCb[inst].inactiveCell = NULLP;
1024 rgCb[inst].cell = NULLP;
1026 /* De-register the Timer Service */
1027 (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
1028 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr);
1030 /* call back the task initialization function to intialize
1031 * the global RgCb Struct */
1032 rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region,
1033 rgCb[inst].rgInit.reason);
1039 /***********************************************************
1041 * Func : rgLMMGenCntrl
1044 * Desc : Processes the LM control request for STGEN elmnt.
1053 **********************************************************/
1055 static Void rgLMMGenCntrl
1062 static Void rgLMMGenCntrl(cntrl, cfm, cfmPst)
1068 Inst inst = (cfmPst->srcInst - RG_INST_START);
1070 cfm->cfm.status = LCM_PRIM_OK;
1071 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1074 switch(cntrl->t.cntrl.action)
1077 /* Action is Enable */
1078 switch(cntrl->t.cntrl.subAction)
1082 rgCb[inst].rgInit.trc = TRUE;
1083 rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1084 /*Store the response and TransId for sending the Traces */
1085 memcpy(&rgCb[inst].genCfg.trcResp.response,
1086 &cntrl->hdr.response, sizeof(Resp));
1087 rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1091 /* Enable Unsolicited Status (alarms) */
1092 rgCb[inst].rgInit.usta = TRUE;
1093 /*Store the response and TransId for sending the Alarms */
1094 memcpy(&rgCb[inst].genCfg.ustaResp.response,
1095 &cntrl->hdr.response, sizeof(Resp));
1096 rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1099 /* Enable Debug Printing */
1101 rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1106 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1111 cfm->cfm.status = LCM_PRIM_NOK;
1112 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1113 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1118 /* Action is Diable immidiately */
1119 switch(cntrl->t.cntrl.subAction)
1122 /* Disable Traces */
1123 rgCb[inst].rgInit.trc = FALSE;
1126 /* Disable Unsolicited Status (alarms) */
1127 rgCb[inst].rgInit.usta = FALSE;
1130 /* Disable Debug Printing */
1132 rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1137 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1142 cfm->cfm.status = LCM_PRIM_NOK;
1143 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1144 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1149 /* Free all the memory dynamically allocated by MAC */
1150 rgLMMShutdown(inst);
1153 cfm->cfm.status = LCM_PRIM_NOK;
1154 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1155 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1158 RgMiLrgCntrlCfm(cfmPst, cfm);
1163 /***********************************************************
1165 * Func : rgLMMSapCntrl
1168 * Desc : Processes the LM control request for STxxxSAP elmnt.
1177 **********************************************************/
1179 static Void rgLMMSapCntrl
1186 static Void rgLMMSapCntrl(cntrl, cfm, cfmPst)
1192 Inst inst = cfmPst->srcInst - RG_INST_START;
1194 /* Only TFU Sap can be controlled by LM */
1195 switch(cntrl->hdr.elmId.elmnt)
1198 switch(cntrl->t.cntrl.action)
1201 /* Bind Enable Request */
1202 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1203 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1205 cfm->cfm.status = LCM_PRIM_NOK;
1206 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1210 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1212 rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val,
1213 (PTR)&rgCb[inst].tfuSap);
1215 /* Change SAP state */
1216 rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1217 rgCb[inst].tfuSap.numBndRetries++;
1218 /* Store the response and TransId for sending
1219 * the Control confirm */
1220 memcpy(&rgCb[inst].genCfg.bndCfmResp.response,
1221 &cntrl->hdr.response, sizeof(Resp));
1222 rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1224 /* Sending Status Indication to Layer Manager */
1225 cfm->cfm.status = LCM_PRIM_OK_NDONE;
1226 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1227 RgMiLrgCntrlCfm(cfmPst, cfm);
1229 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1230 rgCb[inst].tfuSap.sapCfg.spId);
1235 /* Unbind request */
1237 /* Check if the SAP is configured */
1238 if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1239 (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1241 cfm->cfm.status = LCM_PRIM_NOK;
1242 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1246 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1247 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1249 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1251 /* Change SAP state */
1252 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1253 cfm->cfm.status = LCM_PRIM_OK;
1254 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1258 /* Delete SAP, does initialization of SAP */
1259 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1260 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
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);
1268 memset(&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1269 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1270 cfm->cfm.status = LCM_PRIM_OK;
1271 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1274 cfm->cfm.status = LCM_PRIM_NOK;
1275 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1276 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1277 cntrl->t.cntrl.action));
1282 switch(cntrl->t.cntrl.action)
1285 memset(&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1286 rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1287 cfm->cfm.status = LCM_PRIM_OK;
1288 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1291 cfm->cfm.status = LCM_PRIM_NOK;
1292 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1293 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1294 cntrl->t.cntrl.action));
1299 switch(cntrl->t.cntrl.action)
1302 memset(&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1303 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1304 cfm->cfm.status = LCM_PRIM_OK;
1305 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1308 cfm->cfm.status = LCM_PRIM_NOK;
1309 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1310 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1316 /* Would never here. */
1319 RgMiLrgCntrlCfm(cfmPst, cfm);
1324 /***********************************************************
1326 * Func : rgLMMFillCfmPst
1329 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
1330 * and the cfm->hdr.response.
1339 **********************************************************/
1341 static Void rgLMMFillCfmPst
1348 static Void rgLMMFillCfmPst(reqPst, cfmPst, cfm)
1355 inst = (reqPst->dstInst - RG_INST_START);
1357 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
1358 cfmPst->srcInst = rgCb[inst].rgInit.inst;
1359 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1360 cfmPst->dstEnt = reqPst->srcEnt;
1361 cfmPst->dstInst = reqPst->srcInst;
1362 cfmPst->dstProcId = reqPst->srcProcId;
1364 cfmPst->selector = cfm->hdr.response.selector;
1365 cfmPst->prior = cfm->hdr.response.prior;
1366 cfmPst->route = cfm->hdr.response.route;
1367 cfmPst->region = cfm->hdr.response.mem.region;
1368 cfmPst->pool = cfm->hdr.response.mem.pool;
1375 * @brief Timer start handler.
1379 * Function : rgLMMStartTmr
1381 * This function based on the input parameters starts the timer for
1382 * "tmrVal" duration. As of now MAC uses the timer functionality for
1383 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1385 * @param[in] Inst inst
1386 * @param[in] S16 tmrEvnt, the Timer Event
1387 * @param[in] uint32_t tmrVal, the Wait Time
1388 * @param[in] PTR cb, Entry for which Timer expired
1396 S16 tmrEvnt, /* Timer Event */
1397 uint32_t tmrVal, /* Wait Time */
1398 PTR cb /* Entry for which Timer Expired */
1401 S16 rgLMMStartTmr(tmrEvnt, tmrVal, cb)
1403 S16 tmrEvnt; /* Timer Event */
1404 uint32_t tmrVal; /* Wait Time */
1405 PTR cb; /* Entry for which Timer Expired */
1413 /* Initialize the arg structure */
1414 memset(&arg, 0, sizeof(CmTmrArg));
1416 arg.tqCp = &rgCb[inst].tmrTqCp;
1417 arg.tq = rgCb[inst].tmrTq;
1418 arg.timers = rgCb[inst].tmrBlk;
1421 arg.max = RG_MAX_TIMER;
1422 arg.evnt = RG_BNDREQ_TMR;
1431 * @brief Timer stop handler.
1435 * Function : rgLMMStopTmr
1437 * This function based on the input parameters stops the timer for
1438 * "tmrEvnt". As of now MAC uses the timer functionality for
1439 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1440 * Once the bind happens and this timer is stopped, the timer functionality
1441 * is deregistered with SSI. As there is no further use of timer processing.
1443 * @param[in] Inst inst
1444 * @param[in] S16 tmrEvnt, the Timer Event
1445 * @param[in] PTR cb, Entry for which Timer expired
1453 Inst inst, /* Scheduler instance */
1454 S16 tmrEvnt, /* Timer Event */
1455 PTR cb /* Entry for which Timer Expired */
1458 S16 rgLMMStopTmr(inst,tmrEvnt, cb)
1459 Inst inst; /* Scheduler instance */
1460 S16 tmrEvnt; /* Timer Event */
1461 PTR cb; /* Entry for which Timer Expired */
1471 for(i=0;i<RG_MAX_TIMER;i++)
1473 /* Search for the Timer Blocks */
1474 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1476 /* Initialize the arg structure */
1477 memset(&arg, 0, sizeof(CmTmrArg));
1479 arg.tqCp = &rgCb[inst].tmrTqCp;
1480 arg.tq = rgCb[inst].tmrTq;
1481 arg.timers = rgCb[inst].tmrBlk;
1483 arg.max = RG_MAX_TIMER;
1501 * @brief Timer Expiry handler.
1505 * Function : rgLMMTmrExpiry
1507 * This is a callback function used as an input parameter to cmPrcTmr()
1508 * to check expiry of any timer. In this function, the only concern is
1509 * about tmrEvnt=Bind timer.
1511 * @param[in] PTR cb, Entry for which Timer expired
1512 * @param[in] S16 tmrEvnt, the Timer Event
1519 PTR cb, /* Pointer to timer control block */
1520 S16 tmrEvnt /* Timer Event */
1523 S16 rgLMMTmrExpiry(cb,tmrEvnt)
1524 PTR cb; /* Pointer to timer control block */
1525 S16 tmrEvnt; /* Timer Event */
1529 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1530 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1535 tfuSap->numBndRetries++;
1536 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1538 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1539 LCM_CAUSE_TMR_EXPIRED, NULLP);
1543 /* Restart the bind timer */
1544 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1546 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1550 /* Send bind request */
1551 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1552 rgCb[inst].tfuSap.sapCfg.spId);
1556 RLOG1(L_ERROR, "Invalid tmrEvnt=%d",tmrEvnt);
1566 * @brief Layer Manager Unsolicited Status Indication generation.
1570 * Function : rgLMMStaInd
1572 * This API is used by the other modules of MAC to send a unsolicited
1573 * status indication to the Layer Manager.
1575 * @param[in] Inst inst
1576 * @param[in] uint16_t category, the Alarm category
1577 * @param[in] uint16_t event, the Alarm event
1578 * @param[in] uint16_t cause, the cause of the Alarm
1579 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1593 S16 rgLMMStaInd(inst,category, event, cause, dgn)
1604 if(rgCb[inst].rgInit.usta == FALSE)
1609 memset(&usta, 0, sizeof(RgMngmt));
1611 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1612 usta.t.usta.cmAlarm.category = category;
1613 usta.t.usta.cmAlarm.event = event;
1614 usta.t.usta.cmAlarm.cause = cause;
1617 memcpy(&usta.t.usta.dgn, dgn, sizeof(RgUstaDgn));
1620 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1621 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1622 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1623 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1624 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1625 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1627 return (RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1632 * @brief Layer Manager Trace Indication generation.
1636 * Function : rgLMMTrcInd
1638 * This API is used by the other modules of MAC to send a
1639 * Trace indication to the Layer Manager.
1641 * @param[in] Inst inst
1642 * @param[in] Buffer *srcMbuf, the Message Buffer .
1643 * @param[in] uint8_t event, the trace event.
1650 Buffer *srcMbuf, /* Message Buffer */
1651 uint8_t event /* event */
1654 Void rgLMMTrcInd(inst,srcMbuf,event)
1656 Buffer *srcMbuf; /* Message Buffer */
1657 uint8_t event; /* event */
1660 Buffer *dstMbuf = NULLP;
1669 if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1671 RLOG0(L_ERROR, "Trace Disabled.");
1675 memset(&trc, 0, sizeof(RgMngmt));
1677 pst = rgCb[inst].rgInit.lmPst;
1678 pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1679 pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1680 pst.route = rgCb[inst].genCfg.trcResp.response.route;
1681 pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1682 pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1684 trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1686 SGetDateTime(&trc.t.trc.dt);
1688 /* Check if the whole buffer is to be sent in Trace indication */
1689 if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1691 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1694 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1697 trc.cfm.status = LCM_PRIM_OK;
1698 trc.cfm.reason = LCM_REASON_NOT_APPL;
1699 trc.t.trc.evnt = event;
1701 /* Send Trace Indication to Layer manager */
1702 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1704 /* check if only a specified number of bytes are to be sent */
1705 else if(rgCb[inst].trcLen > 0)
1707 /* Get the length of the recvd message buffer */
1708 if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1710 RLOG0(L_ERROR, "SFndLenMsg Failed.");
1713 /* Check if the recvd buffer size is less than request trace len */
1714 if(bufLen < rgCb[inst].trcLen)
1716 /* Copy the whole of the recvd buffer in trace indication */
1718 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1721 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1725 trc.cfm.status = LCM_PRIM_OK;
1726 trc.cfm.reason = LCM_REASON_NOT_APPL;
1727 trc.t.trc.evnt = event;
1729 /* Send Trace Indication to Layer manager */
1730 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1732 /* if the recvd buffer size is greater than request trace len */
1733 if(bufLen >= rgCb[inst].trcLen)
1735 /* Get a temporary buffer to store the msg */
1736 if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1738 RLOG0(L_ERROR, "rgAllocSBuf Failed.");
1742 /* Copy trcLen nos of bytes from the recvd message */
1743 if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)
1745 RLOG0(L_ERROR, "SCpyMsgFix Failed.");
1749 if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1751 RLOG0(L_ERROR, "dstMbuf Allocation Failed");
1754 /* Copy the tempBuf data to dst mBuf */
1755 if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1757 RLOG0(L_ERROR, "SCpyFixMsg Failed.");
1761 /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1763 /* Free the memory allocated for tempBuf */
1764 rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1766 trc.cfm.status = LCM_PRIM_OK;
1767 trc.cfm.reason = LCM_REASON_NOT_APPL;
1768 trc.t.trc.evnt = event;
1770 /* Send Trace Indication to Layer manager */
1771 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1779 * @brief Layer Manager Control Confirm generation handler
1780 * for Bind Confirm reception at TFU interface.
1781 * RgLiTfuBndCfm() forwards the confirmation to this
1782 * function. All SAP state related handling is restricted
1783 * to LMM modules, hence the cfm forwarding.
1787 * Function : rgLMMBndCfm
1789 * This API is used by the LIM module of MAC to forward
1790 * the Bind Confirm it receives over the TFU interface.
1792 * @param[in] Pst *pst, Post Structure
1793 * @param[in] SuId suId, Service user ID
1794 * @param[in] uint8_t status, Status
1801 Pst *pst, /* Post Structure */
1802 SuId suId, /* Service user ID */
1803 uint8_t status /* Status */
1806 S16 rgLMMBndCfm(pst,suId,status)
1807 Pst *pst; /* Post Structure */
1808 SuId suId; /* Service user ID */
1809 uint8_t status; /* Status */
1812 Inst inst = pst->dstInst - RG_INST_START;
1820 /* Check if the suId is valid */
1821 if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1823 RLOG0(L_ERROR, "Invalid SuId");
1827 /* check the Sap State */
1828 switch(rgCb[inst].tfuSap.sapSta.sapState)
1830 case LRG_WAIT_BNDCFM:
1833 /* SAP is already bound */
1839 cfmPst = rgCb[inst].rgInit.lmPst;
1840 cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1841 cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1842 cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1843 cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1844 cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1846 memset(&cntrlCfm, 0, sizeof(RgMngmt));
1850 case CM_BND_OK: /* status is OK */
1851 /* Change SAP state to Bound */
1852 rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1853 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1855 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1857 /* Send Control Confirm with status as OK to Layer Manager */
1858 cntrlCfm.cfm.status = LCM_PRIM_OK;
1859 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1863 /* Change SAP state to UnBound */
1864 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1865 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1867 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1869 /* Send Control Confirm with status as NOK to Layer Manager */
1870 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1871 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1874 rgCb[inst].tfuSap.numBndRetries = 0;
1875 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1876 cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1878 ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1885 * @brief LTE MAC timer call back function registered with SSI.
1889 * Function : rgActvTmr
1891 * This function is invoked by SSI for every timer activation
1904 S16 rgActvTmr(ent, inst)
1909 Inst macInst = (inst - RG_INST_START);
1911 /* Check if any MAC timer has expired */
1912 cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1916 } /* end of rgActvTmr */
1918 /**********************************************************************
1921 **********************************************************************/