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 EXTERN Void rgGetSId ARGS((SystemId *s));
80 #endif /* __cplusplus */
82 /* Public variable declaration */
86 /* forward references */
87 PRIVATE U16 rgLMMGenCfg ARGS((
92 PRIVATE U16 rgLMMSapCfg ARGS((
98 PRIVATE Void rgLMMShutdown ARGS((
102 PRIVATE Void rgLMMFillCfmPst ARGS((
108 PRIVATE Void rgLMMGenCntrl ARGS((
114 PRIVATE 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 U16 ret = LCM_PRIM_OK;
249 U16 reason = LCM_REASON_NOT_APPL;
255 RG_DIAG_LVL0(inst,0x0a0b0001, RG_DIAG_NA, SS_DIAG_INV_ARG,
256 "Received CfgReq for MAC layer, Entity = %d, Instance = %d\n",
257 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 */
341 RG_IS_INST_VALID(pst->dstInst);
342 inst = pst->dstInst - RG_INST_START;
343 /* Fill the post structure for sending the confirmation */
344 rgLMMFillCfmPst(pst, &cfmPst, sts);
346 memset(&cfm, 0, sizeof(RgMngmt));
349 cfm.hdr.transId = sts->hdr.transId;
351 SGetDateTime(&cfm.t.sts.dt);
352 cfm.cfm.status = LCM_PRIM_OK;
353 cfm.cfm.reason = LCM_REASON_NOT_APPL;
354 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
355 cfm.t.sts.action = sts->t.sts.action;
357 /* Check if General Config Done */
358 if(rgCb[inst].rgInit.cfgDone != TRUE)
360 cfm.cfm.status = LCM_PRIM_NOK;
361 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
362 RgMiLrgStsCfm(&cfmPst,&cfm);
363 RLOG0(L_ERROR, "Gen Cfg not done");
367 switch(sts->hdr.elmId.elmnt)
371 memcpy(&(cfm.t.sts.s.genSts), &rgCb[inst].genSts,
373 /* check if action is read and reset */
374 if(sts->t.sts.action == ARST)
376 rgCb[inst].genSts.numHarqFail = 0;
381 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
383 for(cqi=0; cqi <= 14; cqi++)
385 /* Filling DL ACK/NACK stats */
386 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
387 hqFailStats.dlCqiStat[cqi].mcs;
388 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
389 hqFailStats.dlCqiStat[cqi].numOfNacks;
390 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
391 hqFailStats.dlCqiStat[cqi].numOfAcks;
393 /* Filling UL ACK/NACK stats */
394 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
395 hqFailStats.ulCqiStat[cqi].mcs;
396 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
397 hqFailStats.ulCqiStat[cqi].numOfNacks;
398 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
399 hqFailStats.ulCqiStat[cqi].numOfAcks;
401 /* Filling DL HQ Retx stats */
402 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
403 hqRetxStats.dlCqiStat[cqi].mcs;
404 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
405 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
406 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
407 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
408 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
409 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
410 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
411 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
412 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
413 hqRetxStats.dlCqiStat[cqi].totalTx;
415 /* Filling UL HQ Retx stats */
416 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
417 hqRetxStats.ulCqiStat[cqi].mcs;
418 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
419 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
420 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
421 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
422 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
423 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
424 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
425 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
426 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
427 hqRetxStats.ulCqiStat[cqi].totalTx;
429 /* Reset statistics */
430 if(sts->t.sts.action == ZEROSTS)
432 memset(&hqRetxStats, 0, \
433 sizeof(RgSchHqRetxStats));
434 memset(&hqFailStats, 0, \
435 sizeof(RgSchNackAckStats));
438 #endif /* MAC_SCH_STATS*/
442 memcpy(&(cfm.t.sts.s.rguSts), &rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
445 /* check if action is read and reset */
446 if(sts->t.sts.action == ARST)
447 memset(&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
451 memcpy(&(cfm.t.sts.s.crgSts), &rgCb[inst].crgSap.sapSts,
454 /* check if action is read and reset */
455 if(sts->t.sts.action == ARST)
456 memset(&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
460 memcpy(&(cfm.t.sts.s.tfuSts), &rgCb[inst].tfuSap.sapSts,
463 /* check if action is read and reset */
464 if(sts->t.sts.action == ARST)
465 memset(&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
469 cfm.cfm.status = LCM_PRIM_NOK;
470 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
471 RLOG1(L_ERROR, "Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
474 RgMiLrgStsCfm(&cfmPst,&cfm);
476 }/*-- RgMiLrgStsReq --*/
480 * @brief Layer Manager Status request handler.
484 * Function : RgMiLrgStaReq
486 * This function handles the solicited status
487 * request received from the Layer Manager.
488 * -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
489 * particular SAP from the rgCb global control block.
490 * -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
492 * @param[in] Pst *pst, the post structure
493 * @param[in] RgMngmt *sta, the status parameter's structure
500 Pst *pst, /* post structure */
501 RgMngmt *sta /* status structure */
504 S16 RgMiLrgStaReq(pst, sta)
505 Pst *pst; /* post structure */
506 RgMngmt *sta; /* status structure */
514 RG_IS_INST_VALID(pst->dstInst);
515 inst = pst->dstInst - RG_INST_START;
518 /* Fill the post structure for sending the confirmation */
519 rgLMMFillCfmPst(pst, &cfmPst, sta);
521 if (sta->t.ssta.s.sysId.ptNmb != NULLP)
523 SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
526 memset(&cfm, 0, sizeof(RgMngmt));
527 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
530 cfm.hdr.transId = sta->hdr.transId;
532 /* Check if General Config Done */
533 if(rgCb[inst].rgInit.cfgDone != TRUE)
535 SGetDateTime(&cfm.t.ssta.dt);
536 if (SGetSBuf(cfmPst.region, cfmPst.pool,
537 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
540 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
543 memset((cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
544 rgGetSId(&cfm.t.ssta.s.sysId);
545 cfm.cfm.status = LCM_PRIM_NOK;
546 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
547 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
548 RgMiLrgStaCfm(&cfmPst, &cfm);
549 RLOG0(L_ERROR, "Gen Cfg not done");
553 switch(sta->hdr.elmId.elmnt)
556 SGetDateTime(&cfm.t.ssta.dt);
557 if (SGetSBuf(cfmPst.region, cfmPst.pool,
558 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
561 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
564 memset((cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
565 rgGetSId(&cfm.t.ssta.s.sysId);
566 cfm.cfm.status = LCM_PRIM_OK;
567 cfm.cfm.reason = LCM_REASON_NOT_APPL;
568 RgMiLrgStaCfm(&cfmPst, &cfm);
571 cfm.cfm.status = LCM_PRIM_OK;
572 cfm.cfm.reason = LCM_REASON_NOT_APPL;
573 SGetDateTime(&cfm.t.ssta.dt);
574 memcpy(&(cfm.t.ssta.s.rguSapSta),
575 &rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
577 RgMiLrgStaCfm(&cfmPst, &cfm);
580 cfm.cfm.status = LCM_PRIM_OK;
581 cfm.cfm.reason = LCM_REASON_NOT_APPL;
582 SGetDateTime(&cfm.t.ssta.dt);
583 memcpy(&(cfm.t.ssta.s.crgSapSta), &rgCb[inst].crgSap.sapSta,
585 RgMiLrgStaCfm(&cfmPst, &cfm);
588 cfm.cfm.status = LCM_PRIM_OK;
589 cfm.cfm.reason = LCM_REASON_NOT_APPL;
590 SGetDateTime(&cfm.t.ssta.dt);
591 memcpy(&(cfm.t.ssta.s.tfuSapSta), &rgCb[inst].tfuSap.sapSta,
593 RgMiLrgStaCfm(&cfmPst, &cfm);
596 cfm.cfm.status = LCM_PRIM_NOK;
597 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
598 RgMiLrgStaCfm(&cfmPst, &cfm);
599 RLOG1(L_ERROR, "Invalid elmnt=%d",sta->hdr.elmId.elmnt);
603 }/*-- RgMiLrgStaReq --*/
607 * @brief Layer Manager Control request handler.
611 * Function : RgMiLrgCntrlReq
613 * This function handles the control
614 * request received from the Layer Manager.
615 * -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
616 * and cntrl->t.cntrl.subAction, it performs the appropriate control action
617 * of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
618 * and layer shutdown.
619 * -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
621 * @param[in] Pst *pst, the post structure
622 * @param[in] RgMngmt *cntrl, the control parameter's structure
629 Pst *pst, /* post structure */
630 RgMngmt *cntrl /* control structure */
633 S16 RgMiLrgCntrlReq(pst, cntrl)
634 Pst *pst; /* post structure */
635 RgMngmt *cntrl; /* control structure */
638 S16 ret = ROK; /* return value */
644 /* Fill the post structure for sending the confirmation */
646 RG_IS_INST_VALID(pst->dstInst);
647 inst = pst->dstInst - RG_INST_START;
649 rgLMMFillCfmPst(pst, &cfmPst, cntrl);
651 memset(&cfm, 0, sizeof(RgMngmt));
653 cfm.hdr.transId = cntrl->hdr.transId;
655 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
656 cfm.t.cntrl.action = cntrl->t.cntrl.action;
657 cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
659 /* Check if General Config Done*/
660 if(rgCb[inst].rgInit.cfgDone != TRUE)
662 cfm.cfm.status = LCM_PRIM_NOK;
663 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
664 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
665 RgMiLrgCntrlCfm(&cfmPst, &cfm);
666 RLOG0(L_ERROR, "Gen Cfg not done");
670 /* General Config done, process the Control request */
671 switch(cntrl->hdr.elmId.elmnt)
674 rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
679 rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
682 cfm.cfm.status = LCM_PRIM_NOK;
683 cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
684 RgMiLrgCntrlCfm(&cfmPst, &cfm);
685 RLOG1(L_ERROR, "invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
689 }/*-- RgMiLrgCntrlReq --*/
693 * @brief SAP Configuration Handler.
697 * Function : rgLMMSapCfg
699 * This function in called by RgMiLrgCfgReq(). It handles the
700 * interface SAP configuration of the LTE MAC layer. It
701 * initializes the sapState to LRG_UNBND. Returns
702 * reason for success/failure of this function.
704 * @param[in] Inst inst
705 * @param[in] RgCfg *cfg, the Configuaration information
707 * -# LCM_REASON_GENCFG_NOT_DONE
708 * -# LCM_REASON_INVALID_SAP
709 * -# LCM_REASON_NOT_APPL
712 PRIVATE U16 rgLMMSapCfg
715 RgCfg *cfg, /* Configuaration information */
716 Elmnt sapType /* Sap Type */
719 PRIVATE U16 rgLMMSapCfg(inst,cfg,sapType)
721 RgCfg *cfg; /* Configuaration information */
722 Elmnt sapType; /* Sap Type */
725 U16 ret = LCM_REASON_NOT_APPL;
726 RgLowSapCfgInfo *lowSapCfg = NULLP;
727 RgUpSapCfgInfo *upSapCfg = NULLP;
728 RgUpSapCb *upSapCb = NULLP;
731 /* Check if Gen Config has been done */
732 if(rgCb[inst].rgInit.cfgDone != TRUE)
733 return (LCM_REASON_GENCFG_NOT_DONE);
738 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
739 (cfg->s.rguSap.selector != ODU_SELECTOR_TC) &&
740 (cfg->s.rguSap.selector != ODU_SELECTOR_LC))
742 ret = LCM_REASON_INVALID_PAR_VAL;
743 RLOG0(L_ERROR, "unsupported Selector value for RGU");
746 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
747 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
749 upSapCb->sapSta.sapState = LRG_UNBND;
751 upSapCfg = &(upSapCb->sapCfg);
752 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
753 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
754 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
755 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
756 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
757 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
758 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
759 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
760 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
761 upSapCfg->sapPst.route = cfg->s.rguSap.route;
762 upSapCfg->sapPst.intfVer = 0;
763 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
764 upSapCfg->suId = cfg->s.rguSap.suId;
765 upSapCfg->spId = cfg->s.rguSap.spId;
766 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
767 * there is cfg request with sap is 1*/
770 if ((cfg->s.crgSap.selector != ODU_SELECTOR_TC) &&
771 (cfg->s.crgSap.selector != ODU_SELECTOR_LC))
773 ret = LCM_REASON_INVALID_PAR_VAL;
774 RLOG0(L_ERROR, "unsupported Selector value for CRG");
777 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
779 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
781 upSapCfg = &rgCb[inst].crgSap.sapCfg;
783 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
784 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
785 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
786 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
787 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
788 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
789 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
790 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
791 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
792 upSapCfg->sapPst.route = cfg->s.crgSap.route;
793 upSapCfg->sapPst.intfVer = 0;
794 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
795 upSapCfg->suId = cfg->s.crgSap.suId;
796 upSapCfg->spId = cfg->s.crgSap.spId;
800 if ((cfg->s.tfuSap.selector != ODU_SELECTOR_TC) &&
801 (cfg->s.tfuSap.selector != ODU_SELECTOR_LC))
803 ret = LCM_REASON_INVALID_PAR_VAL;
804 RLOG0(L_ERROR, "unsupported Selector value for TFU");
808 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
810 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
812 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
814 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
815 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
816 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
817 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
818 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
819 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
820 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
821 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
822 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
823 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
824 lowSapCfg->sapPst.intfVer = 0;
825 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
826 lowSapCfg->suId = cfg->s.tfuSap.suId;
827 lowSapCfg->spId = cfg->s.tfuSap.spId;
828 memcpy(&lowSapCfg->bndTmr, &cfg->s.tfuSap.bndTmr,
832 /* would never reach here */
840 * @brief General Configuration Handler.
844 * Function : rgLMMGenCfg
846 * This function in called by RgMiLrgCfgReq(). It handles the
847 * general configuration of the LTE MAC layer. It initializes
848 * the hash lists of RgCb. Returns
849 * reason for success/failure of this function.
851 * @param[in] Inst inst
852 * @param[in] RgCfg *cfg, the Configuaration information
854 * -# LCM_REASON_NOT_APPL
855 * -# LCM_REASON_INVALID_MSGTYPE
856 * -# LCM_REASON_MEM_NOAVAIL
859 PRIVATE U16 rgLMMGenCfg
862 RgCfg *cfg /* Configuaration information */
865 PRIVATE U16 rgLMMGenCfg(inst,cfg)
867 RgCfg *cfg; /* Configuaration information */
870 U16 ret = LCM_REASON_NOT_APPL;
873 /* Check if General Configuration is done already */
874 if (rgCb[inst].rgInit.cfgDone == TRUE)
876 return (LCM_REASON_INVALID_MSGTYPE);
878 if ((cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_TC) &&
879 (cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_LC))
881 RLOG0(L_ERROR, "unsupported Selector value for RGU");
882 return (LCM_REASON_INVALID_PAR_VAL);
884 /* Update the Pst structure for LM interface */
885 memcpy(&rgCb[inst].rgInit.lmPst, &cfg->s.genCfg.lmPst,
888 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
889 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
890 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
891 rgCb[inst].rgInit.lmPst.event = EVTNONE;
893 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
894 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
895 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
897 macCb.macInst = rgCb[inst].rgInit.inst;
898 macCb.procId = rgCb[inst].rgInit.procId;
900 /* Initialize SAP States */
901 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
903 if(cfg->s.genCfg.numRguSaps == 0)
905 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Invalid numRguSap.\n"));
909 /* allocate RGR saps */
910 if (SGetSBuf(rgCb[inst].rgInit.region,
911 rgCb[inst].rgInit.pool,
912 (Data **)&rgCb[inst].rguSap,
913 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
915 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Failed to allocate mem for RGU SAP's.\n"));
918 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
920 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
922 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
923 memset(&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
925 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
926 /* Initialize the timer blocks */
927 cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
928 /* Initialzie the timer queue */
929 memset(&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
930 /* Initialize the timer control point */
931 memset(&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
932 rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
934 /* Timer Registration request to SSI */
935 if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
936 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
939 RLOG0(L_ERROR, "Failed to register timer");
941 SPutSBuf(rgCb[inst].rgInit.region,
942 rgCb[inst].rgInit.pool,
943 (Data *)rgCb[inst].rguSap,
944 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
946 return (LCM_REASON_MEM_NOAVAIL);
949 /* Set Config done in TskInit */
950 rgCb[inst].rgInit.cfgDone = TRUE;
956 /***********************************************************
958 * Func : rgLMMShutdown
961 * Desc : Handles the MAC layer shutdown request. Calls
962 * rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
971 **********************************************************/
973 PRIVATE Void rgLMMShutdown
978 PRIVATE Void rgLMMShutdown(inst)
982 RgCellCb *cell = rgCb[inst].cell;
986 /* Unbind the TFU Sap */
987 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
989 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
990 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
992 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
994 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
996 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
998 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
999 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1005 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1007 rgTOMRlsSf(inst,&cell->subFrms[idx]);
1010 rgCFGFreeCellCb(cell);
1013 /* Deleting the RGU SAPs */
1014 SPutSBuf(rgCb[inst].rgInit.region,
1015 rgCb[inst].rgInit.pool,
1016 (Data *)rgCb[inst].rguSap,
1017 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
1018 rgCb[inst].rguSap = NULLP;
1020 rgCb[inst].inactiveCell = NULLP;
1021 rgCb[inst].cell = NULLP;
1023 /* De-register the Timer Service */
1024 (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
1025 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr);
1027 /* call back the task initialization function to intialize
1028 * the global RgCb Struct */
1029 rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region,
1030 rgCb[inst].rgInit.reason);
1036 /***********************************************************
1038 * Func : rgLMMGenCntrl
1041 * Desc : Processes the LM control request for STGEN elmnt.
1050 **********************************************************/
1052 PRIVATE Void rgLMMGenCntrl
1059 PRIVATE Void rgLMMGenCntrl(cntrl, cfm, cfmPst)
1065 Inst inst = (cfmPst->srcInst - RG_INST_START);
1067 cfm->cfm.status = LCM_PRIM_OK;
1068 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1071 switch(cntrl->t.cntrl.action)
1074 /* Action is Enable */
1075 switch(cntrl->t.cntrl.subAction)
1079 rgCb[inst].rgInit.trc = TRUE;
1080 rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1081 /*Store the response and TransId for sending the Traces */
1082 memcpy(&rgCb[inst].genCfg.trcResp.response,
1083 &cntrl->hdr.response, sizeof(Resp));
1084 rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1088 /* Enable Unsolicited Status (alarms) */
1089 rgCb[inst].rgInit.usta = TRUE;
1090 /*Store the response and TransId for sending the Alarms */
1091 memcpy(&rgCb[inst].genCfg.ustaResp.response,
1092 &cntrl->hdr.response, sizeof(Resp));
1093 rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1096 /* Enable Debug Printing */
1098 rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1103 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1108 cfm->cfm.status = LCM_PRIM_NOK;
1109 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1110 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1115 /* Action is Diable immidiately */
1116 switch(cntrl->t.cntrl.subAction)
1119 /* Disable Traces */
1120 rgCb[inst].rgInit.trc = FALSE;
1123 /* Disable Unsolicited Status (alarms) */
1124 rgCb[inst].rgInit.usta = FALSE;
1127 /* Disable Debug Printing */
1129 rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1134 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1139 cfm->cfm.status = LCM_PRIM_NOK;
1140 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1141 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1146 /* Free all the memory dynamically allocated by MAC */
1147 rgLMMShutdown(inst);
1150 cfm->cfm.status = LCM_PRIM_NOK;
1151 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1152 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1155 RgMiLrgCntrlCfm(cfmPst, cfm);
1160 /***********************************************************
1162 * Func : rgLMMSapCntrl
1165 * Desc : Processes the LM control request for STxxxSAP elmnt.
1174 **********************************************************/
1176 PRIVATE Void rgLMMSapCntrl
1183 PRIVATE Void rgLMMSapCntrl(cntrl, cfm, cfmPst)
1189 Inst inst = cfmPst->srcInst - RG_INST_START;
1191 /* Only TFU Sap can be controlled by LM */
1192 switch(cntrl->hdr.elmId.elmnt)
1195 switch(cntrl->t.cntrl.action)
1198 /* Bind Enable Request */
1199 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1200 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1202 cfm->cfm.status = LCM_PRIM_NOK;
1203 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1207 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1209 rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val,
1210 (PTR)&rgCb[inst].tfuSap);
1212 /* Change SAP state */
1213 rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1214 rgCb[inst].tfuSap.numBndRetries++;
1215 /* Store the response and TransId for sending
1216 * the Control confirm */
1217 memcpy(&rgCb[inst].genCfg.bndCfmResp.response,
1218 &cntrl->hdr.response, sizeof(Resp));
1219 rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1221 /* Sending Status Indication to Layer Manager */
1222 cfm->cfm.status = LCM_PRIM_OK_NDONE;
1223 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1224 RgMiLrgCntrlCfm(cfmPst, cfm);
1226 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1227 rgCb[inst].tfuSap.sapCfg.spId);
1232 /* Unbind request */
1234 /* Check if the SAP is configured */
1235 if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1236 (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1238 cfm->cfm.status = LCM_PRIM_NOK;
1239 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1243 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1244 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1246 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1248 /* Change SAP state */
1249 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1250 cfm->cfm.status = LCM_PRIM_OK;
1251 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1255 /* Delete SAP, does initialization of SAP */
1256 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1257 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1259 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1260 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1262 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1265 memset(&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1266 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1267 cfm->cfm.status = LCM_PRIM_OK;
1268 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1271 cfm->cfm.status = LCM_PRIM_NOK;
1272 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1273 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1274 cntrl->t.cntrl.action));
1279 switch(cntrl->t.cntrl.action)
1282 memset(&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1283 rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1284 cfm->cfm.status = LCM_PRIM_OK;
1285 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1288 cfm->cfm.status = LCM_PRIM_NOK;
1289 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1290 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1291 cntrl->t.cntrl.action));
1296 switch(cntrl->t.cntrl.action)
1299 memset(&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1300 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1301 cfm->cfm.status = LCM_PRIM_OK;
1302 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1305 cfm->cfm.status = LCM_PRIM_NOK;
1306 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1307 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1313 /* Would never here. */
1316 RgMiLrgCntrlCfm(cfmPst, cfm);
1321 /***********************************************************
1323 * Func : rgLMMFillCfmPst
1326 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
1327 * and the cfm->hdr.response.
1336 **********************************************************/
1338 PRIVATE Void rgLMMFillCfmPst
1345 PRIVATE Void rgLMMFillCfmPst(reqPst, cfmPst, cfm)
1352 inst = (reqPst->dstInst - RG_INST_START);
1354 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
1355 cfmPst->srcInst = rgCb[inst].rgInit.inst;
1356 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1357 cfmPst->dstEnt = reqPst->srcEnt;
1358 cfmPst->dstInst = reqPst->srcInst;
1359 cfmPst->dstProcId = reqPst->srcProcId;
1361 cfmPst->selector = cfm->hdr.response.selector;
1362 cfmPst->prior = cfm->hdr.response.prior;
1363 cfmPst->route = cfm->hdr.response.route;
1364 cfmPst->region = cfm->hdr.response.mem.region;
1365 cfmPst->pool = cfm->hdr.response.mem.pool;
1372 * @brief Timer start handler.
1376 * Function : rgLMMStartTmr
1378 * This function based on the input parameters starts the timer for
1379 * "tmrVal" duration. As of now MAC uses the timer functionality for
1380 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1382 * @param[in] Inst inst
1383 * @param[in] S16 tmrEvnt, the Timer Event
1384 * @param[in] U32 tmrVal, the Wait Time
1385 * @param[in] PTR cb, Entry for which Timer expired
1393 S16 tmrEvnt, /* Timer Event */
1394 U32 tmrVal, /* Wait Time */
1395 PTR cb /* Entry for which Timer Expired */
1398 S16 rgLMMStartTmr(tmrEvnt, tmrVal, cb)
1400 S16 tmrEvnt; /* Timer Event */
1401 U32 tmrVal; /* Wait Time */
1402 PTR cb; /* Entry for which Timer Expired */
1410 /* Initialize the arg structure */
1411 memset(&arg, 0, sizeof(CmTmrArg));
1413 arg.tqCp = &rgCb[inst].tmrTqCp;
1414 arg.tq = rgCb[inst].tmrTq;
1415 arg.timers = rgCb[inst].tmrBlk;
1418 arg.max = RG_MAX_TIMER;
1419 arg.evnt = RG_BNDREQ_TMR;
1428 * @brief Timer stop handler.
1432 * Function : rgLMMStopTmr
1434 * This function based on the input parameters stops the timer for
1435 * "tmrEvnt". As of now MAC uses the timer functionality for
1436 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1437 * Once the bind happens and this timer is stopped, the timer functionality
1438 * is deregistered with SSI. As there is no further use of timer processing.
1440 * @param[in] Inst inst
1441 * @param[in] S16 tmrEvnt, the Timer Event
1442 * @param[in] PTR cb, Entry for which Timer expired
1450 Inst inst, /* Scheduler instance */
1451 S16 tmrEvnt, /* Timer Event */
1452 PTR cb /* Entry for which Timer Expired */
1455 S16 rgLMMStopTmr(inst,tmrEvnt, cb)
1456 Inst inst; /* Scheduler instance */
1457 S16 tmrEvnt; /* Timer Event */
1458 PTR cb; /* Entry for which Timer Expired */
1468 for(i=0;i<RG_MAX_TIMER;i++)
1470 /* Search for the Timer Blocks */
1471 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1473 /* Initialize the arg structure */
1474 memset(&arg, 0, sizeof(CmTmrArg));
1476 arg.tqCp = &rgCb[inst].tmrTqCp;
1477 arg.tq = rgCb[inst].tmrTq;
1478 arg.timers = rgCb[inst].tmrBlk;
1480 arg.max = RG_MAX_TIMER;
1498 * @brief Timer Expiry handler.
1502 * Function : rgLMMTmrExpiry
1504 * This is a callback function used as an input parameter to cmPrcTmr()
1505 * to check expiry of any timer. In this function, the only concern is
1506 * about tmrEvnt=Bind timer.
1508 * @param[in] PTR cb, Entry for which Timer expired
1509 * @param[in] S16 tmrEvnt, the Timer Event
1516 PTR cb, /* Pointer to timer control block */
1517 S16 tmrEvnt /* Timer Event */
1520 S16 rgLMMTmrExpiry(cb,tmrEvnt)
1521 PTR cb; /* Pointer to timer control block */
1522 S16 tmrEvnt; /* Timer Event */
1526 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1527 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1532 tfuSap->numBndRetries++;
1533 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1535 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1536 LCM_CAUSE_TMR_EXPIRED, NULLP);
1540 /* Restart the bind timer */
1541 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1543 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1547 /* Send bind request */
1548 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1549 rgCb[inst].tfuSap.sapCfg.spId);
1553 RLOG1(L_ERROR, "Invalid tmrEvnt=%d",tmrEvnt);
1563 * @brief Layer Manager Unsolicited Status Indication generation.
1567 * Function : rgLMMStaInd
1569 * This API is used by the other modules of MAC to send a unsolicited
1570 * status indication to the Layer Manager.
1572 * @param[in] Inst inst
1573 * @param[in] U16 category, the Alarm category
1574 * @param[in] U16 event, the Alarm event
1575 * @param[in] U16 cause, the cause of the Alarm
1576 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1590 S16 rgLMMStaInd(inst,category, event, cause, dgn)
1601 if(rgCb[inst].rgInit.usta == FALSE)
1606 memset(&usta, 0, sizeof(RgMngmt));
1608 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1609 usta.t.usta.cmAlarm.category = category;
1610 usta.t.usta.cmAlarm.event = event;
1611 usta.t.usta.cmAlarm.cause = cause;
1614 memcpy(&usta.t.usta.dgn, dgn, sizeof(RgUstaDgn));
1617 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1618 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1619 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1620 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1621 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1622 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1624 return (RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1629 * @brief Layer Manager Trace Indication generation.
1633 * Function : rgLMMTrcInd
1635 * This API is used by the other modules of MAC to send a
1636 * Trace indication to the Layer Manager.
1638 * @param[in] Inst inst
1639 * @param[in] Buffer *srcMbuf, the Message Buffer .
1640 * @param[in] U8 event, the trace event.
1647 Buffer *srcMbuf, /* Message Buffer */
1648 U8 event /* event */
1651 Void rgLMMTrcInd(inst,srcMbuf,event)
1653 Buffer *srcMbuf; /* Message Buffer */
1654 U8 event; /* event */
1657 Buffer *dstMbuf = NULLP;
1666 if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1668 RLOG0(L_ERROR, "Trace Disabled.");
1672 memset(&trc, 0, sizeof(RgMngmt));
1674 pst = rgCb[inst].rgInit.lmPst;
1675 pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1676 pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1677 pst.route = rgCb[inst].genCfg.trcResp.response.route;
1678 pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1679 pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1681 trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1683 SGetDateTime(&trc.t.trc.dt);
1685 /* Check if the whole buffer is to be sent in Trace indication */
1686 if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1688 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1691 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1694 trc.cfm.status = LCM_PRIM_OK;
1695 trc.cfm.reason = LCM_REASON_NOT_APPL;
1696 trc.t.trc.evnt = event;
1698 /* Send Trace Indication to Layer manager */
1699 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1701 /* check if only a specified number of bytes are to be sent */
1702 else if(rgCb[inst].trcLen > 0)
1704 /* Get the length of the recvd message buffer */
1705 if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1707 RLOG0(L_ERROR, "SFndLenMsg Failed.");
1710 /* Check if the recvd buffer size is less than request trace len */
1711 if(bufLen < rgCb[inst].trcLen)
1713 /* Copy the whole of the recvd buffer in trace indication */
1715 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1718 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1722 trc.cfm.status = LCM_PRIM_OK;
1723 trc.cfm.reason = LCM_REASON_NOT_APPL;
1724 trc.t.trc.evnt = event;
1726 /* Send Trace Indication to Layer manager */
1727 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1729 /* if the recvd buffer size is greater than request trace len */
1730 if(bufLen >= rgCb[inst].trcLen)
1732 /* Get a temporary buffer to store the msg */
1733 if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1735 RLOG0(L_ERROR, "rgAllocSBuf Failed.");
1739 /* Copy trcLen nos of bytes from the recvd message */
1740 if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)
1742 RLOG0(L_ERROR, "SCpyMsgFix Failed.");
1746 if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1748 RLOG0(L_ERROR, "dstMbuf Allocation Failed");
1751 /* Copy the tempBuf data to dst mBuf */
1752 if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1754 RLOG0(L_ERROR, "SCpyFixMsg Failed.");
1758 /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1760 /* Free the memory allocated for tempBuf */
1761 rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1763 trc.cfm.status = LCM_PRIM_OK;
1764 trc.cfm.reason = LCM_REASON_NOT_APPL;
1765 trc.t.trc.evnt = event;
1767 /* Send Trace Indication to Layer manager */
1768 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1776 * @brief Layer Manager Control Confirm generation handler
1777 * for Bind Confirm reception at TFU interface.
1778 * RgLiTfuBndCfm() forwards the confirmation to this
1779 * function. All SAP state related handling is restricted
1780 * to LMM modules, hence the cfm forwarding.
1784 * Function : rgLMMBndCfm
1786 * This API is used by the LIM module of MAC to forward
1787 * the Bind Confirm it receives over the TFU interface.
1789 * @param[in] Pst *pst, Post Structure
1790 * @param[in] SuId suId, Service user ID
1791 * @param[in] U8 status, Status
1798 Pst *pst, /* Post Structure */
1799 SuId suId, /* Service user ID */
1800 U8 status /* Status */
1803 S16 rgLMMBndCfm(pst,suId,status)
1804 Pst *pst; /* Post Structure */
1805 SuId suId; /* Service user ID */
1806 U8 status; /* Status */
1809 Inst inst = pst->dstInst - RG_INST_START;
1817 /* Check if the suId is valid */
1818 if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1820 RLOG0(L_ERROR, "Invalid SuId");
1824 /* check the Sap State */
1825 switch(rgCb[inst].tfuSap.sapSta.sapState)
1827 case LRG_WAIT_BNDCFM:
1830 /* SAP is already bound */
1836 cfmPst = rgCb[inst].rgInit.lmPst;
1837 cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1838 cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1839 cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1840 cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1841 cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1843 memset(&cntrlCfm, 0, sizeof(RgMngmt));
1847 case CM_BND_OK: /* status is OK */
1848 /* Change SAP state to Bound */
1849 rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1850 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1852 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1854 /* Send Control Confirm with status as OK to Layer Manager */
1855 cntrlCfm.cfm.status = LCM_PRIM_OK;
1856 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1860 /* Change SAP state to UnBound */
1861 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1862 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1864 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1866 /* Send Control Confirm with status as NOK to Layer Manager */
1867 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1868 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1871 rgCb[inst].tfuSap.numBndRetries = 0;
1872 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1873 cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1875 ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1882 * @brief LTE MAC timer call back function registered with SSI.
1886 * Function : rgActvTmr
1888 * This function is invoked by SSI for every timer activation
1901 S16 rgActvTmr(ent, inst)
1906 Inst macInst = (inst - RG_INST_START);
1908 /* Check if any MAC timer has expired */
1909 cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1913 } /* end of rgActvTmr */
1915 /**********************************************************************
1918 **********************************************************************/