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.
142 Ent entity, /* entity */
143 Inst inst, /* instance */
144 Region region, /* region */
145 Reason reason /* reason */
150 RG_IS_INST_VALID(inst);
152 macInst = inst - RG_INST_START;
153 /* Initialize the MAC TskInit structure to zero */
154 memset (&rgCb[macInst], 0, sizeof(RgCb));
156 /* Initialize the MAC TskInit with received values */
157 rgCb[macInst].rgInit.ent = entity;
158 rgCb[macInst].rgInit.inst = inst;
159 rgCb[macInst].rgInit.region = region;
160 rgCb[macInst].rgInit.pool = 0;
161 rgCb[macInst].rgInit.reason = reason;
162 rgCb[macInst].rgInit.cfgDone = FALSE;
163 rgCb[macInst].rgInit.acnt = FALSE;
164 rgCb[macInst].rgInit.usta = FALSE;
165 rgCb[macInst].rgInit.trc = FALSE;
166 rgCb[macInst].trcLen = 0;
169 /* disabling debugs by default */
170 rgCb[macInst].rgInit.dbgMask = 0xffffffff;
174 rgCb[macInst].rgInit.logMask = 0x0;
176 rgCb[macInst].rgInit.procId = SFndProcId();
177 rgCb[macInst].tfuSap.numBndRetries = 0;
179 /* Initialize Sap state */
180 rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
181 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
182 rgCb[macInst].rguSap = NULLP;
183 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
185 rgCb[macInst].inactiveCell = NULLP;
186 rgCb[macInst].cell = NULLP;
188 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
189 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
192 /* Initializing CL control block */
193 memset(&lwrMacCb, 0, sizeof(LwrMacCb));
194 lwrMacCb.region = region;
196 lwrMacCb.clCfgDone = TRUE;
197 lwrMacCb.numCell = 0;
198 lwrMacCb.phyState = PHY_STATE_IDLE;
200 /* Initialize Scheduler as well */
201 schActvInit(ENTMAC, (DEFAULT_CELLS + SCH_INST_START), DFLT_REGION, PWR_UP);
203 /* Initialize lower mac */
211 * @brief Layer Manager Configuration request handler.
215 * Function : RgMiLrgCfgReq
217 * This function handles the configuration
218 * request received from the Layer Manager.
219 * -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
220 * functions rgHdlGenCfg() or rgHdlSapCfg().
221 * -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
223 * @param[in] Pst *pst, the post structure
224 * @param[in] RgMngmt *cfg, the configuration parameter's structure
230 Pst *pst, /* post structure */
231 RgMngmt *cfg /* config structure */
234 uint16_t ret = LCM_PRIM_OK;
235 uint16_t reason = LCM_REASON_NOT_APPL;
242 RG_DIAG_LVL0(inst,0x0a0b0001, RG_DIAG_NA, SS_DIAG_INV_ARG,\
243 "Received CfgReq for MAC layer, Entity = %d, Instance = %d\n", pst->srcEnt, pst->srcInst,0,0);
245 RG_IS_INST_VALID(pst->dstInst);
246 inst = pst->dstInst - RG_INST_START;
248 /* Fill the post structure for sending the confirmation */
249 rgLMMFillCfmPst(pst, &cfmPst, cfg);
251 memset(&cfm, 0, sizeof(RgMngmt));
254 cfm.hdr.transId = cfg->hdr.transId;
258 cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
259 switch(cfg->hdr.elmId.elmnt)
263 /* Start WLS message receiver thread */
264 LwrMacStartWlsRcvr();
265 /* Allocate memory for UL transmissions */
266 LwrMacEnqueueWlsBlock();
268 reason = rgLMMGenCfg(inst,&cfg->t.cfg);
273 reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
277 reason = LCM_REASON_INVALID_ELMNT;
278 RLOG1(L_ERROR, "Invalid Elmnt=%d",
279 cfg->hdr.elmId.elmnt);
283 if (reason != LCM_REASON_NOT_APPL)
288 cfm.cfm.status = ret;
289 cfm.cfm.reason = reason;
291 RgMiLrgCfgCfm(&cfmPst, &cfm);
294 }/*-- RgMiLrgCfgReq --*/
298 * @brief Layer Manager Statistics request handler.
302 * Function : RgMiLrgStsReq
304 * This function handles the statistics
305 * request received from the Layer Manager.
306 * -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
307 * statistics from the rgCb global control block.
308 * -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
309 * -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
311 * @param[in] Pst *pst, the post structure
312 * @param[in] RgMngmt *sts, the statistics parameter's structure
318 Pst *pst, /* post structure */
319 RgMngmt *sts /* statistics structure */
326 RG_IS_INST_VALID(pst->dstInst);
327 inst = pst->dstInst - RG_INST_START;
328 /* Fill the post structure for sending the confirmation */
329 rgLMMFillCfmPst(pst, &cfmPst, sts);
331 memset(&cfm, 0, sizeof(RgMngmt));
334 cfm.hdr.transId = sts->hdr.transId;
336 SGetDateTime(&cfm.t.sts.dt);
337 cfm.cfm.status = LCM_PRIM_OK;
338 cfm.cfm.reason = LCM_REASON_NOT_APPL;
339 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
340 cfm.t.sts.action = sts->t.sts.action;
342 /* Check if General Config Done */
343 if(rgCb[inst].rgInit.cfgDone != TRUE)
345 cfm.cfm.status = LCM_PRIM_NOK;
346 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
347 RgMiLrgStsCfm(&cfmPst,&cfm);
348 RLOG0(L_ERROR, "Gen Cfg not done");
352 switch(sts->hdr.elmId.elmnt)
356 memcpy(&(cfm.t.sts.s.genSts), &rgCb[inst].genSts,
358 /* check if action is read and reset */
359 if(sts->t.sts.action == ARST)
361 rgCb[inst].genSts.numHarqFail = 0;
366 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
368 for(cqi=0; cqi <= 14; cqi++)
370 /* Filling DL ACK/NACK stats */
371 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
372 hqFailStats.dlCqiStat[cqi].mcs;
373 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
374 hqFailStats.dlCqiStat[cqi].numOfNacks;
375 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
376 hqFailStats.dlCqiStat[cqi].numOfAcks;
378 /* Filling UL ACK/NACK stats */
379 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
380 hqFailStats.ulCqiStat[cqi].mcs;
381 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
382 hqFailStats.ulCqiStat[cqi].numOfNacks;
383 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
384 hqFailStats.ulCqiStat[cqi].numOfAcks;
386 /* Filling DL HQ Retx stats */
387 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
388 hqRetxStats.dlCqiStat[cqi].mcs;
389 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
390 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
391 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
392 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
393 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
394 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
395 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
396 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
397 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
398 hqRetxStats.dlCqiStat[cqi].totalTx;
400 /* Filling UL HQ Retx stats */
401 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
402 hqRetxStats.ulCqiStat[cqi].mcs;
403 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
404 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
405 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
406 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
407 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
408 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
409 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
410 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
411 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
412 hqRetxStats.ulCqiStat[cqi].totalTx;
414 /* Reset statistics */
415 if(sts->t.sts.action == ZEROSTS)
417 memset(&hqRetxStats, 0, \
418 sizeof(RgSchHqRetxStats));
419 memset(&hqFailStats, 0, \
420 sizeof(RgSchNackAckStats));
423 #endif /* MAC_SCH_STATS*/
427 memcpy(&(cfm.t.sts.s.rguSts), &rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
430 /* check if action is read and reset */
431 if(sts->t.sts.action == ARST)
432 memset(&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
436 memcpy(&(cfm.t.sts.s.crgSts), &rgCb[inst].crgSap.sapSts,
439 /* check if action is read and reset */
440 if(sts->t.sts.action == ARST)
441 memset(&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
445 memcpy(&(cfm.t.sts.s.tfuSts), &rgCb[inst].tfuSap.sapSts,
448 /* check if action is read and reset */
449 if(sts->t.sts.action == ARST)
450 memset(&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
454 cfm.cfm.status = LCM_PRIM_NOK;
455 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
456 RLOG1(L_ERROR, "Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
459 RgMiLrgStsCfm(&cfmPst,&cfm);
461 }/*-- RgMiLrgStsReq --*/
465 * @brief Layer Manager Status request handler.
469 * Function : RgMiLrgStaReq
471 * This function handles the solicited status
472 * request received from the Layer Manager.
473 * -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
474 * particular SAP from the rgCb global control block.
475 * -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
477 * @param[in] Pst *pst, the post structure
478 * @param[in] RgMngmt *sta, the status parameter's structure
484 Pst *pst, /* post structure */
485 RgMngmt *sta /* status structure */
493 RG_IS_INST_VALID(pst->dstInst);
494 inst = pst->dstInst - RG_INST_START;
497 /* Fill the post structure for sending the confirmation */
498 rgLMMFillCfmPst(pst, &cfmPst, sta);
500 if (sta->t.ssta.s.sysId.ptNmb != NULLP)
502 SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
505 memset(&cfm, 0, sizeof(RgMngmt));
506 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
509 cfm.hdr.transId = sta->hdr.transId;
511 /* Check if General Config Done */
512 if(rgCb[inst].rgInit.cfgDone != TRUE)
514 SGetDateTime(&cfm.t.ssta.dt);
515 if (SGetSBuf(cfmPst.region, cfmPst.pool,
516 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
519 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
522 memset((cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
523 rgGetSId(&cfm.t.ssta.s.sysId);
524 cfm.cfm.status = LCM_PRIM_NOK;
525 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
526 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
527 RgMiLrgStaCfm(&cfmPst, &cfm);
528 RLOG0(L_ERROR, "Gen Cfg not done");
532 switch(sta->hdr.elmId.elmnt)
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_OK;
546 cfm.cfm.reason = LCM_REASON_NOT_APPL;
547 RgMiLrgStaCfm(&cfmPst, &cfm);
550 cfm.cfm.status = LCM_PRIM_OK;
551 cfm.cfm.reason = LCM_REASON_NOT_APPL;
552 SGetDateTime(&cfm.t.ssta.dt);
553 memcpy(&(cfm.t.ssta.s.rguSapSta),
554 &rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
556 RgMiLrgStaCfm(&cfmPst, &cfm);
559 cfm.cfm.status = LCM_PRIM_OK;
560 cfm.cfm.reason = LCM_REASON_NOT_APPL;
561 SGetDateTime(&cfm.t.ssta.dt);
562 memcpy(&(cfm.t.ssta.s.crgSapSta), &rgCb[inst].crgSap.sapSta,
564 RgMiLrgStaCfm(&cfmPst, &cfm);
567 cfm.cfm.status = LCM_PRIM_OK;
568 cfm.cfm.reason = LCM_REASON_NOT_APPL;
569 SGetDateTime(&cfm.t.ssta.dt);
570 memcpy(&(cfm.t.ssta.s.tfuSapSta), &rgCb[inst].tfuSap.sapSta,
572 RgMiLrgStaCfm(&cfmPst, &cfm);
575 cfm.cfm.status = LCM_PRIM_NOK;
576 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
577 RgMiLrgStaCfm(&cfmPst, &cfm);
578 RLOG1(L_ERROR, "Invalid elmnt=%d",sta->hdr.elmId.elmnt);
582 }/*-- RgMiLrgStaReq --*/
586 * @brief Layer Manager Control request handler.
590 * Function : RgMiLrgCntrlReq
592 * This function handles the control
593 * request received from the Layer Manager.
594 * -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
595 * and cntrl->t.cntrl.subAction, it performs the appropriate control action
596 * of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
597 * and layer shutdown.
598 * -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
600 * @param[in] Pst *pst, the post structure
601 * @param[in] RgMngmt *cntrl, the control parameter's structure
607 Pst *pst, /* post structure */
608 RgMngmt *cntrl /* control structure */
611 S16 ret = ROK; /* return value */
615 /* Fill the post structure for sending the confirmation */
617 RG_IS_INST_VALID(pst->dstInst);
618 inst = pst->dstInst - RG_INST_START;
620 rgLMMFillCfmPst(pst, &cfmPst, cntrl);
622 memset(&cfm, 0, sizeof(RgMngmt));
624 cfm.hdr.transId = cntrl->hdr.transId;
626 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
627 cfm.t.cntrl.action = cntrl->t.cntrl.action;
628 cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
630 /* Check if General Config Done*/
631 if(rgCb[inst].rgInit.cfgDone != TRUE)
633 cfm.cfm.status = LCM_PRIM_NOK;
634 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
635 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
636 RgMiLrgCntrlCfm(&cfmPst, &cfm);
637 RLOG0(L_ERROR, "Gen Cfg not done");
641 /* General Config done, process the Control request */
642 switch(cntrl->hdr.elmId.elmnt)
645 rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
650 rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
653 cfm.cfm.status = LCM_PRIM_NOK;
654 cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
655 RgMiLrgCntrlCfm(&cfmPst, &cfm);
656 RLOG1(L_ERROR, "invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
660 }/*-- RgMiLrgCntrlReq --*/
664 * @brief SAP Configuration Handler.
668 * Function : rgLMMSapCfg
670 * This function in called by RgMiLrgCfgReq(). It handles the
671 * interface SAP configuration of the LTE MAC layer. It
672 * initializes the sapState to LRG_UNBND. Returns
673 * reason for success/failure of this function.
675 * @param[in] Inst inst
676 * @param[in] RgCfg *cfg, the Configuaration information
678 * -# LCM_REASON_GENCFG_NOT_DONE
679 * -# LCM_REASON_INVALID_SAP
680 * -# LCM_REASON_NOT_APPL
682 static uint16_t rgLMMSapCfg
685 RgCfg *cfg, /* Configuaration information */
686 Elmnt sapType /* Sap Type */
689 uint16_t ret = LCM_REASON_NOT_APPL;
690 RgLowSapCfgInfo *lowSapCfg = NULLP;
691 RgUpSapCfgInfo *upSapCfg = NULLP;
692 RgUpSapCb *upSapCb = NULLP;
695 /* Check if Gen Config has been done */
696 if(rgCb[inst].rgInit.cfgDone != TRUE)
697 return (LCM_REASON_GENCFG_NOT_DONE);
702 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
703 (cfg->s.rguSap.selector != ODU_SELECTOR_TC) &&
704 (cfg->s.rguSap.selector != ODU_SELECTOR_LC))
706 ret = LCM_REASON_INVALID_PAR_VAL;
707 RLOG0(L_ERROR, "unsupported Selector value for RGU");
710 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
711 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
713 upSapCb->sapSta.sapState = LRG_UNBND;
715 upSapCfg = &(upSapCb->sapCfg);
716 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
717 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
718 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
719 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
720 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
721 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
722 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
723 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
724 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
725 upSapCfg->sapPst.route = cfg->s.rguSap.route;
726 upSapCfg->sapPst.intfVer = 0;
727 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
728 upSapCfg->suId = cfg->s.rguSap.suId;
729 upSapCfg->spId = cfg->s.rguSap.spId;
730 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
731 * there is cfg request with sap is 1*/
734 if ((cfg->s.crgSap.selector != ODU_SELECTOR_TC) &&
735 (cfg->s.crgSap.selector != ODU_SELECTOR_LC))
737 ret = LCM_REASON_INVALID_PAR_VAL;
738 RLOG0(L_ERROR, "unsupported Selector value for CRG");
741 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
743 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
745 upSapCfg = &rgCb[inst].crgSap.sapCfg;
747 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
748 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
749 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
750 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
751 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
752 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
753 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
754 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
755 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
756 upSapCfg->sapPst.route = cfg->s.crgSap.route;
757 upSapCfg->sapPst.intfVer = 0;
758 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
759 upSapCfg->suId = cfg->s.crgSap.suId;
760 upSapCfg->spId = cfg->s.crgSap.spId;
764 if ((cfg->s.tfuSap.selector != ODU_SELECTOR_TC) &&
765 (cfg->s.tfuSap.selector != ODU_SELECTOR_LC))
767 ret = LCM_REASON_INVALID_PAR_VAL;
768 RLOG0(L_ERROR, "unsupported Selector value for TFU");
772 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
774 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
776 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
778 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
779 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
780 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
781 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
782 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
783 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
784 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
785 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
786 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
787 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
788 lowSapCfg->sapPst.intfVer = 0;
789 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
790 lowSapCfg->suId = cfg->s.tfuSap.suId;
791 lowSapCfg->spId = cfg->s.tfuSap.spId;
792 memcpy(&lowSapCfg->bndTmr, &cfg->s.tfuSap.bndTmr,
796 /* would never reach here */
804 * @brief General Configuration Handler.
808 * Function : rgLMMGenCfg
810 * This function in called by RgMiLrgCfgReq(). It handles the
811 * general configuration of the LTE MAC layer. It initializes
812 * the hash lists of RgCb. Returns
813 * reason for success/failure of this function.
815 * @param[in] Inst inst
816 * @param[in] RgCfg *cfg, the Configuaration information
818 * -# LCM_REASON_NOT_APPL
819 * -# LCM_REASON_INVALID_MSGTYPE
820 * -# LCM_REASON_MEM_NOAVAIL
822 static uint16_t rgLMMGenCfg
825 RgCfg *cfg /* Configuaration information */
828 uint16_t ret = LCM_REASON_NOT_APPL;
831 /* Check if General Configuration is done already */
832 if (rgCb[inst].rgInit.cfgDone == TRUE)
834 return (LCM_REASON_INVALID_MSGTYPE);
836 if ((cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_TC) &&
837 (cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_LC))
839 RLOG0(L_ERROR, "unsupported Selector value for RGU");
840 return (LCM_REASON_INVALID_PAR_VAL);
842 /* Update the Pst structure for LM interface */
843 memcpy(&rgCb[inst].rgInit.lmPst, &cfg->s.genCfg.lmPst,
846 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
847 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
848 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
849 rgCb[inst].rgInit.lmPst.event = EVTNONE;
851 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
852 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
853 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
855 macCb.macInst = rgCb[inst].rgInit.inst;
856 macCb.procId = rgCb[inst].rgInit.procId;
858 /* Initialize SAP States */
859 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
861 if(cfg->s.genCfg.numRguSaps == 0)
863 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Invalid numRguSap.\n"));
867 /* allocate RGR saps */
868 if (SGetSBuf(rgCb[inst].rgInit.region,
869 rgCb[inst].rgInit.pool,
870 (Data **)&rgCb[inst].rguSap,
871 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
873 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Failed to allocate mem for RGU SAP's.\n"));
876 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
878 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
880 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
881 memset(&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
883 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
884 /* Initialize the timer blocks */
885 cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
886 /* Initialzie the timer queue */
887 memset(&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
888 /* Initialize the timer control point */
889 memset(&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
890 rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
892 /* Timer Registration request to SSI */
893 if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
894 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
897 RLOG0(L_ERROR, "Failed to register timer");
899 SPutSBuf(rgCb[inst].rgInit.region,
900 rgCb[inst].rgInit.pool,
901 (Data *)rgCb[inst].rguSap,
902 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
904 return (LCM_REASON_MEM_NOAVAIL);
907 /* Set Config done in TskInit */
908 rgCb[inst].rgInit.cfgDone = TRUE;
914 /***********************************************************
916 * Func : rgLMMShutdown
919 * Desc : Handles the MAC layer shutdown request. Calls
920 * rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
929 **********************************************************/
930 static Void rgLMMShutdown(Inst inst)
932 RgCellCb *cell = rgCb[inst].cell;
936 /* Unbind the TFU Sap */
937 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
939 //rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
940 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
942 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
944 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
946 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
948 //rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
949 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
955 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
957 rgTOMRlsSf(inst,&cell->subFrms[idx]);
960 rgCFGFreeCellCb(cell);
963 /* Deleting the RGU SAPs */
964 SPutSBuf(rgCb[inst].rgInit.region,
965 rgCb[inst].rgInit.pool,
966 (Data *)rgCb[inst].rguSap,
967 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
968 rgCb[inst].rguSap = NULLP;
970 rgCb[inst].inactiveCell = NULLP;
971 rgCb[inst].cell = NULLP;
973 /* De-register the Timer Service */
974 (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
975 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr);
977 /* call back the task initialization function to intialize
978 * the global RgCb Struct */
979 rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region,
980 rgCb[inst].rgInit.reason);
986 /***********************************************************
988 * Func : rgLMMGenCntrl
991 * Desc : Processes the LM control request for STGEN elmnt.
1000 **********************************************************/
1001 static Void rgLMMGenCntrl
1008 Inst inst = (cfmPst->srcInst - RG_INST_START);
1010 cfm->cfm.status = LCM_PRIM_OK;
1011 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1014 switch(cntrl->t.cntrl.action)
1017 /* Action is Enable */
1018 switch(cntrl->t.cntrl.subAction)
1022 rgCb[inst].rgInit.trc = TRUE;
1023 rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1024 /*Store the response and TransId for sending the Traces */
1025 memcpy(&rgCb[inst].genCfg.trcResp.response,
1026 &cntrl->hdr.response, sizeof(Resp));
1027 rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1031 /* Enable Unsolicited Status (alarms) */
1032 rgCb[inst].rgInit.usta = TRUE;
1033 /*Store the response and TransId for sending the Alarms */
1034 memcpy(&rgCb[inst].genCfg.ustaResp.response,
1035 &cntrl->hdr.response, sizeof(Resp));
1036 rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1039 /* Enable Debug Printing */
1041 rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1046 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1051 cfm->cfm.status = LCM_PRIM_NOK;
1052 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1053 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1058 /* Action is Diable immidiately */
1059 switch(cntrl->t.cntrl.subAction)
1062 /* Disable Traces */
1063 rgCb[inst].rgInit.trc = FALSE;
1066 /* Disable Unsolicited Status (alarms) */
1067 rgCb[inst].rgInit.usta = FALSE;
1070 /* Disable Debug Printing */
1072 rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1077 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1082 cfm->cfm.status = LCM_PRIM_NOK;
1083 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1084 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1089 /* Free all the memory dynamically allocated by MAC */
1090 rgLMMShutdown(inst);
1093 cfm->cfm.status = LCM_PRIM_NOK;
1094 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1095 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1098 RgMiLrgCntrlCfm(cfmPst, cfm);
1103 /***********************************************************
1105 * Func : rgLMMSapCntrl
1108 * Desc : Processes the LM control request for STxxxSAP elmnt.
1117 **********************************************************/
1118 static Void rgLMMSapCntrl
1125 Inst inst = cfmPst->srcInst - RG_INST_START;
1127 /* Only TFU Sap can be controlled by LM */
1128 switch(cntrl->hdr.elmId.elmnt)
1131 switch(cntrl->t.cntrl.action)
1134 /* Bind Enable Request */
1135 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1136 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1138 cfm->cfm.status = LCM_PRIM_NOK;
1139 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1143 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1145 rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val,
1146 (PTR)&rgCb[inst].tfuSap);
1148 /* Change SAP state */
1149 rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1150 rgCb[inst].tfuSap.numBndRetries++;
1151 /* Store the response and TransId for sending
1152 * the Control confirm */
1153 memcpy(&rgCb[inst].genCfg.bndCfmResp.response,
1154 &cntrl->hdr.response, sizeof(Resp));
1155 rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1157 /* Sending Status Indication to Layer Manager */
1158 cfm->cfm.status = LCM_PRIM_OK_NDONE;
1159 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1160 RgMiLrgCntrlCfm(cfmPst, cfm);
1162 //rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1163 //rgCb[inst].tfuSap.sapCfg.spId);
1168 /* Unbind request */
1170 /* Check if the SAP is configured */
1171 if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1172 (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1174 cfm->cfm.status = LCM_PRIM_NOK;
1175 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1179 //rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1180 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1182 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1184 /* Change SAP state */
1185 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1186 cfm->cfm.status = LCM_PRIM_OK;
1187 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1191 /* Delete SAP, does initialization of SAP */
1192 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1193 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1195 //rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1196 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1198 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1201 memset(&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1202 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1203 cfm->cfm.status = LCM_PRIM_OK;
1204 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1207 cfm->cfm.status = LCM_PRIM_NOK;
1208 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1209 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1210 cntrl->t.cntrl.action));
1215 switch(cntrl->t.cntrl.action)
1218 memset(&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1219 rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1220 cfm->cfm.status = LCM_PRIM_OK;
1221 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1224 cfm->cfm.status = LCM_PRIM_NOK;
1225 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1226 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1227 cntrl->t.cntrl.action));
1232 switch(cntrl->t.cntrl.action)
1235 memset(&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1236 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1237 cfm->cfm.status = LCM_PRIM_OK;
1238 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1241 cfm->cfm.status = LCM_PRIM_NOK;
1242 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1243 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1249 /* Would never here. */
1252 RgMiLrgCntrlCfm(cfmPst, cfm);
1257 /***********************************************************
1259 * Func : rgLMMFillCfmPst
1262 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
1263 * and the cfm->hdr.response.
1272 **********************************************************/
1273 static Void rgLMMFillCfmPst
1281 inst = (reqPst->dstInst - RG_INST_START);
1283 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
1284 cfmPst->srcInst = rgCb[inst].rgInit.inst;
1285 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1286 cfmPst->dstEnt = reqPst->srcEnt;
1287 cfmPst->dstInst = reqPst->srcInst;
1288 cfmPst->dstProcId = reqPst->srcProcId;
1290 cfmPst->selector = cfm->hdr.response.selector;
1291 cfmPst->prior = cfm->hdr.response.prior;
1292 cfmPst->route = cfm->hdr.response.route;
1293 cfmPst->region = cfm->hdr.response.mem.region;
1294 cfmPst->pool = cfm->hdr.response.mem.pool;
1301 * @brief Timer start handler.
1305 * Function : rgLMMStartTmr
1307 * This function based on the input parameters starts the timer for
1308 * "tmrVal" duration. As of now MAC uses the timer functionality for
1309 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1311 * @param[in] Inst inst
1312 * @param[in] S16 tmrEvnt, the Timer Event
1313 * @param[in] uint32_t tmrVal, the Wait Time
1314 * @param[in] PTR cb, Entry for which Timer expired
1321 S16 tmrEvnt, /* Timer Event */
1322 uint32_t tmrVal, /* Wait Time */
1323 PTR cb /* Entry for which Timer Expired */
1331 /* Initialize the arg structure */
1332 memset(&arg, 0, sizeof(CmTmrArg));
1334 arg.tqCp = &rgCb[inst].tmrTqCp;
1335 arg.tq = rgCb[inst].tmrTq;
1336 arg.timers = rgCb[inst].tmrBlk;
1339 arg.max = RG_MAX_TIMER;
1340 arg.evnt = RG_BNDREQ_TMR;
1349 * @brief Timer stop handler.
1353 * Function : rgLMMStopTmr
1355 * This function based on the input parameters stops the timer for
1356 * "tmrEvnt". As of now MAC uses the timer functionality for
1357 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1358 * Once the bind happens and this timer is stopped, the timer functionality
1359 * is deregistered with SSI. As there is no further use of timer processing.
1361 * @param[in] Inst inst
1362 * @param[in] S16 tmrEvnt, the Timer Event
1363 * @param[in] PTR cb, Entry for which Timer expired
1370 Inst inst, /* Scheduler instance */
1371 S16 tmrEvnt, /* Timer Event */
1372 PTR cb /* Entry for which Timer Expired */
1382 for(i=0;i<RG_MAX_TIMER;i++)
1384 /* Search for the Timer Blocks */
1385 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1387 /* Initialize the arg structure */
1388 memset(&arg, 0, sizeof(CmTmrArg));
1390 arg.tqCp = &rgCb[inst].tmrTqCp;
1391 arg.tq = rgCb[inst].tmrTq;
1392 arg.timers = rgCb[inst].tmrBlk;
1394 arg.max = RG_MAX_TIMER;
1412 * @brief Timer Expiry handler.
1416 * Function : rgLMMTmrExpiry
1418 * This is a callback function used as an input parameter to cmPrcTmr()
1419 * to check expiry of any timer. In this function, the only concern is
1420 * about tmrEvnt=Bind timer.
1422 * @param[in] PTR cb, Entry for which Timer expired
1423 * @param[in] S16 tmrEvnt, the Timer Event
1429 PTR cb, /* Pointer to timer control block */
1430 S16 tmrEvnt /* Timer Event */
1434 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1435 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1440 tfuSap->numBndRetries++;
1441 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1443 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1444 LCM_CAUSE_TMR_EXPIRED, NULLP);
1448 /* Restart the bind timer */
1449 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1451 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1455 /* Send bind request */
1456 //rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1457 //rgCb[inst].tfuSap.sapCfg.spId);
1461 RLOG1(L_ERROR, "Invalid tmrEvnt=%d",tmrEvnt);
1471 * @brief Layer Manager Unsolicited Status Indication generation.
1475 * Function : rgLMMStaInd
1477 * This API is used by the other modules of MAC to send a unsolicited
1478 * status indication to the Layer Manager.
1480 * @param[in] Inst inst
1481 * @param[in] uint16_t category, the Alarm category
1482 * @param[in] uint16_t event, the Alarm event
1483 * @param[in] uint16_t cause, the cause of the Alarm
1484 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1498 if(rgCb[inst].rgInit.usta == FALSE)
1503 memset(&usta, 0, sizeof(RgMngmt));
1505 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1506 usta.t.usta.cmAlarm.category = category;
1507 usta.t.usta.cmAlarm.event = event;
1508 usta.t.usta.cmAlarm.cause = cause;
1511 memcpy(&usta.t.usta.dgn, dgn, sizeof(RgUstaDgn));
1514 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1515 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1516 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1517 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1518 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1519 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1521 return (RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1526 * @brief Layer Manager Trace Indication generation.
1530 * Function : rgLMMTrcInd
1532 * This API is used by the other modules of MAC to send a
1533 * Trace indication to the Layer Manager.
1535 * @param[in] Inst inst
1536 * @param[in] Buffer *srcMbuf, the Message Buffer .
1537 * @param[in] uint8_t event, the trace event.
1543 Buffer *srcMbuf, /* Message Buffer */
1544 uint8_t event /* event */
1547 Buffer *dstMbuf = NULLP;
1556 if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1558 RLOG0(L_ERROR, "Trace Disabled.");
1562 memset(&trc, 0, sizeof(RgMngmt));
1564 pst = rgCb[inst].rgInit.lmPst;
1565 pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1566 pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1567 pst.route = rgCb[inst].genCfg.trcResp.response.route;
1568 pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1569 pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1571 trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1573 SGetDateTime(&trc.t.trc.dt);
1575 /* Check if the whole buffer is to be sent in Trace indication */
1576 if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1578 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1581 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1584 trc.cfm.status = LCM_PRIM_OK;
1585 trc.cfm.reason = LCM_REASON_NOT_APPL;
1586 trc.t.trc.evnt = event;
1588 /* Send Trace Indication to Layer manager */
1589 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1591 /* check if only a specified number of bytes are to be sent */
1592 else if(rgCb[inst].trcLen > 0)
1594 /* Get the length of the recvd message buffer */
1595 if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1597 RLOG0(L_ERROR, "SFndLenMsg Failed.");
1600 /* Check if the recvd buffer size is less than request trace len */
1601 if(bufLen < rgCb[inst].trcLen)
1603 /* Copy the whole of the recvd buffer in trace indication */
1605 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1608 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1612 trc.cfm.status = LCM_PRIM_OK;
1613 trc.cfm.reason = LCM_REASON_NOT_APPL;
1614 trc.t.trc.evnt = event;
1616 /* Send Trace Indication to Layer manager */
1617 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1619 /* if the recvd buffer size is greater than request trace len */
1620 if(bufLen >= rgCb[inst].trcLen)
1622 /* Get a temporary buffer to store the msg */
1623 if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1625 RLOG0(L_ERROR, "rgAllocSBuf Failed.");
1629 /* Copy trcLen nos of bytes from the recvd message */
1630 if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)
1632 RLOG0(L_ERROR, "SCpyMsgFix Failed.");
1636 if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1638 RLOG0(L_ERROR, "dstMbuf Allocation Failed");
1641 /* Copy the tempBuf data to dst mBuf */
1642 if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1644 RLOG0(L_ERROR, "SCpyFixMsg Failed.");
1648 /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1650 /* Free the memory allocated for tempBuf */
1651 rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1653 trc.cfm.status = LCM_PRIM_OK;
1654 trc.cfm.reason = LCM_REASON_NOT_APPL;
1655 trc.t.trc.evnt = event;
1657 /* Send Trace Indication to Layer manager */
1658 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1666 * @brief Layer Manager Control Confirm generation handler
1667 * for Bind Confirm reception at TFU interface.
1668 * RgLiTfuBndCfm() forwards the confirmation to this
1669 * function. All SAP state related handling is restricted
1670 * to LMM modules, hence the cfm forwarding.
1674 * Function : rgLMMBndCfm
1676 * This API is used by the LIM module of MAC to forward
1677 * the Bind Confirm it receives over the TFU interface.
1679 * @param[in] Pst *pst, Post Structure
1680 * @param[in] SuId suId, Service user ID
1681 * @param[in] uint8_t status, Status
1687 Pst *pst, /* Post Structure */
1688 SuId suId, /* Service user ID */
1689 uint8_t status /* Status */
1692 Inst inst = pst->dstInst - RG_INST_START;
1700 /* Check if the suId is valid */
1701 if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1703 RLOG0(L_ERROR, "Invalid SuId");
1707 /* check the Sap State */
1708 switch(rgCb[inst].tfuSap.sapSta.sapState)
1710 case LRG_WAIT_BNDCFM:
1713 /* SAP is already bound */
1719 cfmPst = rgCb[inst].rgInit.lmPst;
1720 cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1721 cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1722 cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1723 cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1724 cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1726 memset(&cntrlCfm, 0, sizeof(RgMngmt));
1730 case CM_BND_OK: /* status is OK */
1731 /* Change SAP state to Bound */
1732 rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1733 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1735 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1737 /* Send Control Confirm with status as OK to Layer Manager */
1738 cntrlCfm.cfm.status = LCM_PRIM_OK;
1739 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1743 /* Change SAP state to UnBound */
1744 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1745 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1747 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1749 /* Send Control Confirm with status as NOK to Layer Manager */
1750 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1751 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1754 rgCb[inst].tfuSap.numBndRetries = 0;
1755 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1756 cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1758 ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1765 * @brief LTE MAC timer call back function registered with SSI.
1769 * Function : rgActvTmr
1771 * This function is invoked by SSI for every timer activation
1777 S16 rgActvTmr(Ent ent,Inst inst)
1779 Inst macInst = (inst - RG_INST_START);
1781 /* Check if any MAC timer has expired */
1782 cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1786 } /* end of rgActvTmr */
1788 /**********************************************************************
1791 **********************************************************************/