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.
37 /* header include files (.h) */
38 #include "common_def.h"
39 #include "rg_env.h" /* MAC Environment Defines */
40 #include "crg.h" /* CRG Interface defines */
41 #include "rgu.h" /* RGU Interface defines */
42 #include "tfu.h" /* RGU Interface defines */
43 #include "rg_sch_inf.h" /* RGR Interface defines */
44 #include "lrg.h" /* LRG Interface defines */
45 #include "rgr.h" /* LRG Interface defines */
46 #include "rg.h" /* MAC defines */
47 #include "rg_err.h" /* MAC error defines */
49 /* header/extern include files (.x) */
50 #include "crg.x" /* CRG Interface includes */
51 #include "rgu.x" /* RGU Interface includes */
52 #include "tfu.x" /* RGU Interface includes */
53 #include "rg_sch_inf.x" /* SCH Interface includes */
54 #include "rg_prg.x" /* PRG Interface includes */
55 #include "lrg.x" /* LRG Interface includes */
56 #include "rgr.x" /* LRG Interface includes */
57 #include "du_app_mac_inf.h"
58 #include "rg.x" /* MAC includes */
60 #include "ss_diag.h" /* Common log file */
64 #include "lwr_mac.h" /* MAC CL defines */
65 #include "mac_sch_interface.h"
66 #include "lwr_mac_upr_inf.h"
68 #include "lwr_mac_phy.h"
69 #include "lwr_mac_fsm.h"
73 #endif /* __cplusplus */
74 Void rgGetSId ARGS((SystemId *s));
77 #endif /* __cplusplus */
79 /* Public variable declaration */
83 /* forward references */
84 static uint16_t rgLMMGenCfg ARGS((
89 static uint16_t rgLMMSapCfg ARGS((
95 static Void rgLMMShutdown ARGS((
99 static Void rgLMMFillCfmPst ARGS((
105 static Void rgLMMGenCntrl ARGS((
111 static Void rgLMMSapCntrl ARGS((
119 * @brief Task Initiation callback function.
123 * Function : rgActvInit
125 * This function is supplied as one of parameters during MAC's
126 * task registration. SSI will invoke this function once, after
127 * it creates and attaches this TAPA Task to a system task.
129 * @param[in] Ent entity, the entity ID of this task.
130 * @param[in] Inst inst, the instance ID of this task.
131 * @param[in] Region region, the region ID registered for memory
132 * usage of this task.
133 * @param[in] Reason reason.
139 Ent entity, /* entity */
140 Inst inst, /* instance */
141 Region region, /* region */
142 Reason reason /* reason */
147 RG_IS_INST_VALID(inst);
149 macInst = inst - RG_INST_START;
150 /* Initialize the MAC TskInit structure to zero */
151 memset (&rgCb[macInst], 0, sizeof(RgCb));
153 /* Initialize the MAC TskInit with received values */
154 rgCb[macInst].rgInit.ent = entity;
155 rgCb[macInst].rgInit.inst = inst;
156 rgCb[macInst].rgInit.region = region;
157 rgCb[macInst].rgInit.pool = 0;
158 rgCb[macInst].rgInit.reason = reason;
159 rgCb[macInst].rgInit.cfgDone = FALSE;
160 rgCb[macInst].rgInit.acnt = FALSE;
161 rgCb[macInst].rgInit.usta = FALSE;
162 rgCb[macInst].rgInit.trc = FALSE;
163 rgCb[macInst].trcLen = 0;
166 /* disabling debugs by default */
167 rgCb[macInst].rgInit.dbgMask = 0xffffffff;
171 rgCb[macInst].rgInit.logMask = 0x0;
173 rgCb[macInst].rgInit.procId = SFndProcId();
174 rgCb[macInst].tfuSap.numBndRetries = 0;
176 /* Initialize Sap state */
177 rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
178 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
179 rgCb[macInst].rguSap = NULLP;
180 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
182 rgCb[macInst].inactiveCell = NULLP;
183 rgCb[macInst].cell = NULLP;
185 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
186 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
189 /* Initializing CL control block */
190 memset(&lwrMacCb, 0, sizeof(LwrMacCb));
191 lwrMacCb.region = region;
193 lwrMacCb.clCfgDone = TRUE;
194 lwrMacCb.numCell = 0;
195 lwrMacCb.phyState = PHY_STATE_IDLE;
197 /* Initialize Scheduler as well */
198 schActvInit(ENTMAC, (DEFAULT_CELLS + SCH_INST_START), DFLT_REGION, PWR_UP);
200 /* Initialize lower mac */
208 * @brief Layer Manager Configuration request handler.
212 * Function : RgMiLrgCfgReq
214 * This function handles the configuration
215 * request received from the Layer Manager.
216 * -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
217 * functions rgHdlGenCfg() or rgHdlSapCfg().
218 * -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
220 * @param[in] Pst *pst, the post structure
221 * @param[in] RgMngmt *cfg, the configuration parameter's structure
227 Pst *pst, /* post structure */
228 RgMngmt *cfg /* config structure */
231 uint16_t ret = LCM_PRIM_OK;
232 uint16_t reason = LCM_REASON_NOT_APPL;
239 DU_LOG("\nINFO --> MAC : Received CfgReq for MAC layer, Entity = %d, Instance = %d", pst->srcEnt, pst->srcInst);
241 RG_IS_INST_VALID(pst->dstInst);
242 inst = pst->dstInst - RG_INST_START;
244 /* Fill the post structure for sending the confirmation */
245 rgLMMFillCfmPst(pst, &cfmPst, cfg);
247 memset(&cfm, 0, sizeof(RgMngmt));
250 cfm.hdr.transId = cfg->hdr.transId;
254 cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
255 switch(cfg->hdr.elmId.elmnt)
259 /* Start WLS message receiver thread */
260 LwrMacStartWlsRcvr();
261 /* Allocate memory for UL transmissions */
262 LwrMacEnqueueWlsBlock();
264 reason = rgLMMGenCfg(inst,&cfg->t.cfg);
269 reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
273 reason = LCM_REASON_INVALID_ELMNT;
274 DU_LOG("\nERROR --> MAC : Invalid Elmnt=%d",
275 cfg->hdr.elmId.elmnt);
279 if (reason != LCM_REASON_NOT_APPL)
284 cfm.cfm.status = ret;
285 cfm.cfm.reason = reason;
287 RgMiLrgCfgCfm(&cfmPst, &cfm);
290 }/*-- RgMiLrgCfgReq --*/
294 * @brief Layer Manager Statistics request handler.
298 * Function : RgMiLrgStsReq
300 * This function handles the statistics
301 * request received from the Layer Manager.
302 * -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
303 * statistics from the rgCb global control block.
304 * -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
305 * -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
307 * @param[in] Pst *pst, the post structure
308 * @param[in] RgMngmt *sts, the statistics parameter's structure
314 Pst *pst, /* post structure */
315 RgMngmt *sts /* statistics structure */
322 RG_IS_INST_VALID(pst->dstInst);
323 inst = pst->dstInst - RG_INST_START;
324 /* Fill the post structure for sending the confirmation */
325 rgLMMFillCfmPst(pst, &cfmPst, sts);
327 memset(&cfm, 0, sizeof(RgMngmt));
330 cfm.hdr.transId = sts->hdr.transId;
332 SGetDateTime(&cfm.t.sts.dt);
333 cfm.cfm.status = LCM_PRIM_OK;
334 cfm.cfm.reason = LCM_REASON_NOT_APPL;
335 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
336 cfm.t.sts.action = sts->t.sts.action;
338 /* Check if General Config Done */
339 if(rgCb[inst].rgInit.cfgDone != TRUE)
341 cfm.cfm.status = LCM_PRIM_NOK;
342 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
343 RgMiLrgStsCfm(&cfmPst,&cfm);
344 DU_LOG("\nERROR --> MAC : Gen Cfg not done");
348 switch(sts->hdr.elmId.elmnt)
352 memcpy(&(cfm.t.sts.s.genSts), &rgCb[inst].genSts,
354 /* check if action is read and reset */
355 if(sts->t.sts.action == ARST)
357 rgCb[inst].genSts.numHarqFail = 0;
362 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
364 for(cqi=0; cqi <= 14; cqi++)
366 /* Filling DL ACK/NACK stats */
367 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
368 hqFailStats.dlCqiStat[cqi].mcs;
369 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
370 hqFailStats.dlCqiStat[cqi].numOfNacks;
371 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
372 hqFailStats.dlCqiStat[cqi].numOfAcks;
374 /* Filling UL ACK/NACK stats */
375 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
376 hqFailStats.ulCqiStat[cqi].mcs;
377 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
378 hqFailStats.ulCqiStat[cqi].numOfNacks;
379 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
380 hqFailStats.ulCqiStat[cqi].numOfAcks;
382 /* Filling DL HQ Retx stats */
383 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
384 hqRetxStats.dlCqiStat[cqi].mcs;
385 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
386 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
387 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
388 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
389 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
390 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
391 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
392 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
393 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
394 hqRetxStats.dlCqiStat[cqi].totalTx;
396 /* Filling UL HQ Retx stats */
397 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
398 hqRetxStats.ulCqiStat[cqi].mcs;
399 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
400 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
401 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
402 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
403 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
404 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
405 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
406 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
407 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
408 hqRetxStats.ulCqiStat[cqi].totalTx;
410 /* Reset statistics */
411 if(sts->t.sts.action == ZEROSTS)
413 memset(&hqRetxStats, 0, \
414 sizeof(RgSchHqRetxStats));
415 memset(&hqFailStats, 0, \
416 sizeof(RgSchNackAckStats));
419 #endif /* MAC_SCH_STATS*/
423 memcpy(&(cfm.t.sts.s.rguSts), &rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
426 /* check if action is read and reset */
427 if(sts->t.sts.action == ARST)
428 memset(&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
432 memcpy(&(cfm.t.sts.s.crgSts), &rgCb[inst].crgSap.sapSts,
435 /* check if action is read and reset */
436 if(sts->t.sts.action == ARST)
437 memset(&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
441 memcpy(&(cfm.t.sts.s.tfuSts), &rgCb[inst].tfuSap.sapSts,
444 /* check if action is read and reset */
445 if(sts->t.sts.action == ARST)
446 memset(&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
450 cfm.cfm.status = LCM_PRIM_NOK;
451 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
452 DU_LOG("\nERROR --> MAC : Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
455 RgMiLrgStsCfm(&cfmPst,&cfm);
457 }/*-- RgMiLrgStsReq --*/
461 * @brief Layer Manager Status request handler.
465 * Function : RgMiLrgStaReq
467 * This function handles the solicited status
468 * request received from the Layer Manager.
469 * -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
470 * particular SAP from the rgCb global control block.
471 * -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
473 * @param[in] Pst *pst, the post structure
474 * @param[in] RgMngmt *sta, the status parameter's structure
480 Pst *pst, /* post structure */
481 RgMngmt *sta /* status structure */
489 RG_IS_INST_VALID(pst->dstInst);
490 inst = pst->dstInst - RG_INST_START;
493 /* Fill the post structure for sending the confirmation */
494 rgLMMFillCfmPst(pst, &cfmPst, sta);
496 if (sta->t.ssta.s.sysId.ptNmb != NULLP)
498 SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
501 memset(&cfm, 0, sizeof(RgMngmt));
502 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
505 cfm.hdr.transId = sta->hdr.transId;
507 /* Check if General Config Done */
508 if(rgCb[inst].rgInit.cfgDone != TRUE)
510 SGetDateTime(&cfm.t.ssta.dt);
511 if (SGetSBuf(cfmPst.region, cfmPst.pool,
512 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
515 DU_LOG("\nERROR --> MAC : Memory Unavailable for Confirmation");
518 memset((cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
519 rgGetSId(&cfm.t.ssta.s.sysId);
520 cfm.cfm.status = LCM_PRIM_NOK;
521 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
522 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
523 RgMiLrgStaCfm(&cfmPst, &cfm);
524 DU_LOG("\nERROR --> MAC : Gen Cfg not done");
528 switch(sta->hdr.elmId.elmnt)
531 SGetDateTime(&cfm.t.ssta.dt);
532 if (SGetSBuf(cfmPst.region, cfmPst.pool,
533 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
536 DU_LOG("\nERROR --> MAC : Memory Unavailable for Confirmation");
539 memset((cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
540 rgGetSId(&cfm.t.ssta.s.sysId);
541 cfm.cfm.status = LCM_PRIM_OK;
542 cfm.cfm.reason = LCM_REASON_NOT_APPL;
543 RgMiLrgStaCfm(&cfmPst, &cfm);
546 cfm.cfm.status = LCM_PRIM_OK;
547 cfm.cfm.reason = LCM_REASON_NOT_APPL;
548 SGetDateTime(&cfm.t.ssta.dt);
549 memcpy(&(cfm.t.ssta.s.rguSapSta),
550 &rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
552 RgMiLrgStaCfm(&cfmPst, &cfm);
555 cfm.cfm.status = LCM_PRIM_OK;
556 cfm.cfm.reason = LCM_REASON_NOT_APPL;
557 SGetDateTime(&cfm.t.ssta.dt);
558 memcpy(&(cfm.t.ssta.s.crgSapSta), &rgCb[inst].crgSap.sapSta,
560 RgMiLrgStaCfm(&cfmPst, &cfm);
563 cfm.cfm.status = LCM_PRIM_OK;
564 cfm.cfm.reason = LCM_REASON_NOT_APPL;
565 SGetDateTime(&cfm.t.ssta.dt);
566 memcpy(&(cfm.t.ssta.s.tfuSapSta), &rgCb[inst].tfuSap.sapSta,
568 RgMiLrgStaCfm(&cfmPst, &cfm);
571 cfm.cfm.status = LCM_PRIM_NOK;
572 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
573 RgMiLrgStaCfm(&cfmPst, &cfm);
574 DU_LOG("\nERROR --> MAC : Invalid elmnt=%d",sta->hdr.elmId.elmnt);
578 }/*-- RgMiLrgStaReq --*/
582 * @brief Layer Manager Control request handler.
586 * Function : RgMiLrgCntrlReq
588 * This function handles the control
589 * request received from the Layer Manager.
590 * -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
591 * and cntrl->t.cntrl.subAction, it performs the appropriate control action
592 * of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
593 * and layer shutdown.
594 * -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
596 * @param[in] Pst *pst, the post structure
597 * @param[in] RgMngmt *cntrl, the control parameter's structure
603 Pst *pst, /* post structure */
604 RgMngmt *cntrl /* control structure */
607 S16 ret = ROK; /* return value */
611 /* Fill the post structure for sending the confirmation */
613 RG_IS_INST_VALID(pst->dstInst);
614 inst = pst->dstInst - RG_INST_START;
616 rgLMMFillCfmPst(pst, &cfmPst, cntrl);
618 memset(&cfm, 0, sizeof(RgMngmt));
620 cfm.hdr.transId = cntrl->hdr.transId;
622 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
623 cfm.t.cntrl.action = cntrl->t.cntrl.action;
624 cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
626 /* Check if General Config Done*/
627 if(rgCb[inst].rgInit.cfgDone != TRUE)
629 cfm.cfm.status = LCM_PRIM_NOK;
630 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
631 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
632 RgMiLrgCntrlCfm(&cfmPst, &cfm);
633 DU_LOG("\nERROR --> MAC : Gen Cfg not done");
637 /* General Config done, process the Control request */
638 switch(cntrl->hdr.elmId.elmnt)
641 rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
646 rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
649 cfm.cfm.status = LCM_PRIM_NOK;
650 cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
651 RgMiLrgCntrlCfm(&cfmPst, &cfm);
652 DU_LOG("\nERROR --> MAC : invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
656 }/*-- RgMiLrgCntrlReq --*/
660 * @brief SAP Configuration Handler.
664 * Function : rgLMMSapCfg
666 * This function in called by RgMiLrgCfgReq(). It handles the
667 * interface SAP configuration of the LTE MAC layer. It
668 * initializes the sapState to LRG_UNBND. Returns
669 * reason for success/failure of this function.
671 * @param[in] Inst inst
672 * @param[in] RgCfg *cfg, the Configuaration information
674 * -# LCM_REASON_GENCFG_NOT_DONE
675 * -# LCM_REASON_INVALID_SAP
676 * -# LCM_REASON_NOT_APPL
678 static uint16_t rgLMMSapCfg
681 RgCfg *cfg, /* Configuaration information */
682 Elmnt sapType /* Sap Type */
685 uint16_t ret = LCM_REASON_NOT_APPL;
686 RgLowSapCfgInfo *lowSapCfg = NULLP;
687 RgUpSapCfgInfo *upSapCfg = NULLP;
688 RgUpSapCb *upSapCb = NULLP;
691 /* Check if Gen Config has been done */
692 if(rgCb[inst].rgInit.cfgDone != TRUE)
693 return (LCM_REASON_GENCFG_NOT_DONE);
698 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
699 (cfg->s.rguSap.selector != ODU_SELECTOR_TC) &&
700 (cfg->s.rguSap.selector != ODU_SELECTOR_LC))
702 ret = LCM_REASON_INVALID_PAR_VAL;
703 DU_LOG("\nERROR --> MAC : unsupported Selector value for RGU");
706 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
707 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
709 upSapCb->sapSta.sapState = LRG_UNBND;
711 upSapCfg = &(upSapCb->sapCfg);
712 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
713 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
714 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
715 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
716 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
717 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
718 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
719 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
720 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
721 upSapCfg->sapPst.route = cfg->s.rguSap.route;
722 upSapCfg->sapPst.intfVer = 0;
723 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
724 upSapCfg->suId = cfg->s.rguSap.suId;
725 upSapCfg->spId = cfg->s.rguSap.spId;
726 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
727 * there is cfg request with sap is 1*/
730 if ((cfg->s.crgSap.selector != ODU_SELECTOR_TC) &&
731 (cfg->s.crgSap.selector != ODU_SELECTOR_LC))
733 ret = LCM_REASON_INVALID_PAR_VAL;
734 DU_LOG("\nERROR --> MAC : unsupported Selector value for CRG");
737 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
739 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
741 upSapCfg = &rgCb[inst].crgSap.sapCfg;
743 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
744 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
745 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
746 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
747 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
748 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
749 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
750 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
751 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
752 upSapCfg->sapPst.route = cfg->s.crgSap.route;
753 upSapCfg->sapPst.intfVer = 0;
754 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
755 upSapCfg->suId = cfg->s.crgSap.suId;
756 upSapCfg->spId = cfg->s.crgSap.spId;
760 if ((cfg->s.tfuSap.selector != ODU_SELECTOR_TC) &&
761 (cfg->s.tfuSap.selector != ODU_SELECTOR_LC))
763 ret = LCM_REASON_INVALID_PAR_VAL;
764 DU_LOG("\nERROR --> MAC : unsupported Selector value for TFU");
768 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
770 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
772 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
774 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
775 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
776 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
777 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
778 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
779 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
780 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
781 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
782 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
783 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
784 lowSapCfg->sapPst.intfVer = 0;
785 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
786 lowSapCfg->suId = cfg->s.tfuSap.suId;
787 lowSapCfg->spId = cfg->s.tfuSap.spId;
788 memcpy(&lowSapCfg->bndTmr, &cfg->s.tfuSap.bndTmr,
792 /* would never reach here */
800 * @brief General Configuration Handler.
804 * Function : rgLMMGenCfg
806 * This function in called by RgMiLrgCfgReq(). It handles the
807 * general configuration of the LTE MAC layer. It initializes
808 * the hash lists of RgCb. Returns
809 * reason for success/failure of this function.
811 * @param[in] Inst inst
812 * @param[in] RgCfg *cfg, the Configuaration information
814 * -# LCM_REASON_NOT_APPL
815 * -# LCM_REASON_INVALID_MSGTYPE
816 * -# LCM_REASON_MEM_NOAVAIL
818 static uint16_t rgLMMGenCfg
821 RgCfg *cfg /* Configuaration information */
824 uint16_t ret = LCM_REASON_NOT_APPL;
827 /* Check if General Configuration is done already */
828 if (rgCb[inst].rgInit.cfgDone == TRUE)
830 return (LCM_REASON_INVALID_MSGTYPE);
832 if ((cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_TC) &&
833 (cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_LC))
835 DU_LOG("\nERROR --> MAC : unsupported Selector value for RGU");
836 return (LCM_REASON_INVALID_PAR_VAL);
838 /* Update the Pst structure for LM interface */
839 memcpy(&rgCb[inst].rgInit.lmPst, &cfg->s.genCfg.lmPst,
842 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
843 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
844 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
845 rgCb[inst].rgInit.lmPst.event = EVTNONE;
847 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
848 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
849 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
851 macCb.macInst = rgCb[inst].rgInit.inst;
852 macCb.procId = rgCb[inst].rgInit.procId;
854 /* Initialize SAP States */
855 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
857 if(cfg->s.genCfg.numRguSaps == 0)
859 DU_LOG("\nERROR --> MAC : rgGenCfg(): Invalid numRguSap.\n");
863 /* allocate RGR saps */
864 if (SGetSBuf(rgCb[inst].rgInit.region,
865 rgCb[inst].rgInit.pool,
866 (Data **)&rgCb[inst].rguSap,
867 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
869 DU_LOG("\nERROR --> MAC : rgGenCfg(): Failed to allocate mem for RGU SAP's.\n");
872 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
874 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
876 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
877 memset(&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
879 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
880 /* Initialize the timer blocks */
881 cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
882 /* Initialzie the timer queue */
883 memset(&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
884 /* Initialize the timer control point */
885 memset(&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
886 rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
888 /* Timer Registration request to SSI */
889 if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
890 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
893 DU_LOG("\nERROR --> MAC : Failed to register timer");
895 SPutSBuf(rgCb[inst].rgInit.region,
896 rgCb[inst].rgInit.pool,
897 (Data *)rgCb[inst].rguSap,
898 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
900 return (LCM_REASON_MEM_NOAVAIL);
903 /* Set Config done in TskInit */
904 rgCb[inst].rgInit.cfgDone = TRUE;
910 /***********************************************************
912 * Func : rgLMMShutdown
915 * Desc : Handles the MAC layer shutdown request. Calls
916 * rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
925 **********************************************************/
926 static Void rgLMMShutdown(Inst inst)
928 RgCellCb *cell = rgCb[inst].cell;
932 /* Unbind the TFU Sap */
933 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
935 //rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
936 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
938 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
940 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
942 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
944 //rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
945 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
951 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
953 rgTOMRlsSf(inst,&cell->subFrms[idx]);
956 rgCFGFreeCellCb(cell);
959 /* Deleting the RGU SAPs */
960 SPutSBuf(rgCb[inst].rgInit.region,
961 rgCb[inst].rgInit.pool,
962 (Data *)rgCb[inst].rguSap,
963 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
964 rgCb[inst].rguSap = NULLP;
966 rgCb[inst].inactiveCell = NULLP;
967 rgCb[inst].cell = NULLP;
969 /* De-register the Timer Service */
970 (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
971 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr);
973 /* call back the task initialization function to intialize
974 * the global RgCb Struct */
975 rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region,
976 rgCb[inst].rgInit.reason);
982 /***********************************************************
984 * Func : rgLMMGenCntrl
987 * Desc : Processes the LM control request for STGEN elmnt.
996 **********************************************************/
997 static Void rgLMMGenCntrl
1004 Inst inst = (cfmPst->srcInst - RG_INST_START);
1006 cfm->cfm.status = LCM_PRIM_OK;
1007 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1010 switch(cntrl->t.cntrl.action)
1013 /* Action is Enable */
1014 switch(cntrl->t.cntrl.subAction)
1018 rgCb[inst].rgInit.trc = TRUE;
1019 rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1020 /*Store the response and TransId for sending the Traces */
1021 memcpy(&rgCb[inst].genCfg.trcResp.response,
1022 &cntrl->hdr.response, sizeof(Resp));
1023 rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1027 /* Enable Unsolicited Status (alarms) */
1028 rgCb[inst].rgInit.usta = TRUE;
1029 /*Store the response and TransId for sending the Alarms */
1030 memcpy(&rgCb[inst].genCfg.ustaResp.response,
1031 &cntrl->hdr.response, sizeof(Resp));
1032 rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1035 /* Enable Debug Printing */
1037 rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1042 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1047 cfm->cfm.status = LCM_PRIM_NOK;
1048 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1049 DU_LOG("\nERROR --> MAC : invalid subaction=%d",cntrl->t.cntrl.subAction);
1054 /* Action is Diable immidiately */
1055 switch(cntrl->t.cntrl.subAction)
1058 /* Disable Traces */
1059 rgCb[inst].rgInit.trc = FALSE;
1062 /* Disable Unsolicited Status (alarms) */
1063 rgCb[inst].rgInit.usta = FALSE;
1066 /* Disable Debug Printing */
1068 rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1073 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1078 cfm->cfm.status = LCM_PRIM_NOK;
1079 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1080 DU_LOG("\nERROR --> MAC : invalid subaction=%d",cntrl->t.cntrl.subAction);
1085 /* Free all the memory dynamically allocated by MAC */
1086 rgLMMShutdown(inst);
1089 cfm->cfm.status = LCM_PRIM_NOK;
1090 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1091 DU_LOG("\nERROR --> MAC : invalid action=%d",cntrl->t.cntrl.action);
1094 RgMiLrgCntrlCfm(cfmPst, cfm);
1099 /***********************************************************
1101 * Func : rgLMMSapCntrl
1104 * Desc : Processes the LM control request for STxxxSAP elmnt.
1113 **********************************************************/
1114 static Void rgLMMSapCntrl
1121 Inst inst = cfmPst->srcInst - RG_INST_START;
1123 /* Only TFU Sap can be controlled by LM */
1124 switch(cntrl->hdr.elmId.elmnt)
1127 switch(cntrl->t.cntrl.action)
1130 /* Bind Enable Request */
1131 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1132 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1134 cfm->cfm.status = LCM_PRIM_NOK;
1135 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1139 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1141 rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val,
1142 (PTR)&rgCb[inst].tfuSap);
1144 /* Change SAP state */
1145 rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1146 rgCb[inst].tfuSap.numBndRetries++;
1147 /* Store the response and TransId for sending
1148 * the Control confirm */
1149 memcpy(&rgCb[inst].genCfg.bndCfmResp.response,
1150 &cntrl->hdr.response, sizeof(Resp));
1151 rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1153 /* Sending Status Indication to Layer Manager */
1154 cfm->cfm.status = LCM_PRIM_OK_NDONE;
1155 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1156 RgMiLrgCntrlCfm(cfmPst, cfm);
1158 //rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1159 //rgCb[inst].tfuSap.sapCfg.spId);
1164 /* Unbind request */
1166 /* Check if the SAP is configured */
1167 if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1168 (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1170 cfm->cfm.status = LCM_PRIM_NOK;
1171 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1175 //rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1176 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1178 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1180 /* Change SAP state */
1181 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1182 cfm->cfm.status = LCM_PRIM_OK;
1183 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1187 /* Delete SAP, does initialization of SAP */
1188 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1189 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1191 //rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1192 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1194 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1197 memset(&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1198 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1199 cfm->cfm.status = LCM_PRIM_OK;
1200 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1203 cfm->cfm.status = LCM_PRIM_NOK;
1204 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1205 DU_LOG("\nERROR --> MAC : rgLMMSapCntrl(): invalid action=%d",
1206 cntrl->t.cntrl.action);
1211 switch(cntrl->t.cntrl.action)
1214 memset(&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1215 rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1216 cfm->cfm.status = LCM_PRIM_OK;
1217 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1220 cfm->cfm.status = LCM_PRIM_NOK;
1221 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1222 DU_LOG("\nERROR --> MAC : rgLMMSapCntrl(): invalid action=%d",
1223 cntrl->t.cntrl.action);
1228 switch(cntrl->t.cntrl.action)
1231 memset(&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1232 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1233 cfm->cfm.status = LCM_PRIM_OK;
1234 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1237 cfm->cfm.status = LCM_PRIM_NOK;
1238 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1239 DU_LOG("\nERROR --> MAC : invalid action=%d",cntrl->t.cntrl.action);
1245 /* Would never here. */
1248 RgMiLrgCntrlCfm(cfmPst, cfm);
1253 /***********************************************************
1255 * Func : rgLMMFillCfmPst
1258 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
1259 * and the cfm->hdr.response.
1268 **********************************************************/
1269 static Void rgLMMFillCfmPst
1277 inst = (reqPst->dstInst - RG_INST_START);
1279 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
1280 cfmPst->srcInst = rgCb[inst].rgInit.inst;
1281 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1282 cfmPst->dstEnt = reqPst->srcEnt;
1283 cfmPst->dstInst = reqPst->srcInst;
1284 cfmPst->dstProcId = reqPst->srcProcId;
1286 cfmPst->selector = cfm->hdr.response.selector;
1287 cfmPst->prior = cfm->hdr.response.prior;
1288 cfmPst->route = cfm->hdr.response.route;
1289 cfmPst->region = cfm->hdr.response.mem.region;
1290 cfmPst->pool = cfm->hdr.response.mem.pool;
1297 * @brief Timer start handler.
1301 * Function : rgLMMStartTmr
1303 * This function based on the input parameters starts the timer for
1304 * "tmrVal" duration. As of now MAC uses the timer functionality for
1305 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1307 * @param[in] Inst inst
1308 * @param[in] S16 tmrEvnt, the Timer Event
1309 * @param[in] uint32_t tmrVal, the Wait Time
1310 * @param[in] PTR cb, Entry for which Timer expired
1317 S16 tmrEvnt, /* Timer Event */
1318 uint32_t tmrVal, /* Wait Time */
1319 PTR cb /* Entry for which Timer Expired */
1327 /* Initialize the arg structure */
1328 memset(&arg, 0, sizeof(CmTmrArg));
1330 arg.tqCp = &rgCb[inst].tmrTqCp;
1331 arg.tq = rgCb[inst].tmrTq;
1332 arg.timers = rgCb[inst].tmrBlk;
1335 arg.max = RG_MAX_TIMER;
1336 arg.evnt = RG_BNDREQ_TMR;
1345 * @brief Timer stop handler.
1349 * Function : rgLMMStopTmr
1351 * This function based on the input parameters stops the timer for
1352 * "tmrEvnt". As of now MAC uses the timer functionality for
1353 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1354 * Once the bind happens and this timer is stopped, the timer functionality
1355 * is deregistered with SSI. As there is no further use of timer processing.
1357 * @param[in] Inst inst
1358 * @param[in] S16 tmrEvnt, the Timer Event
1359 * @param[in] PTR cb, Entry for which Timer expired
1366 Inst inst, /* Scheduler instance */
1367 S16 tmrEvnt, /* Timer Event */
1368 PTR cb /* Entry for which Timer Expired */
1378 for(i=0;i<RG_MAX_TIMER;i++)
1380 /* Search for the Timer Blocks */
1381 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1383 /* Initialize the arg structure */
1384 memset(&arg, 0, sizeof(CmTmrArg));
1386 arg.tqCp = &rgCb[inst].tmrTqCp;
1387 arg.tq = rgCb[inst].tmrTq;
1388 arg.timers = rgCb[inst].tmrBlk;
1390 arg.max = RG_MAX_TIMER;
1408 * @brief Timer Expiry handler.
1412 * Function : rgLMMTmrExpiry
1414 * This is a callback function used as an input parameter to cmPrcTmr()
1415 * to check expiry of any timer. In this function, the only concern is
1416 * about tmrEvnt=Bind timer.
1418 * @param[in] PTR cb, Entry for which Timer expired
1419 * @param[in] S16 tmrEvnt, the Timer Event
1425 PTR cb, /* Pointer to timer control block */
1426 S16 tmrEvnt /* Timer Event */
1430 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1431 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1436 tfuSap->numBndRetries++;
1437 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1439 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1440 LCM_CAUSE_TMR_EXPIRED, NULLP);
1444 /* Restart the bind timer */
1445 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1447 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1451 /* Send bind request */
1452 //rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1453 //rgCb[inst].tfuSap.sapCfg.spId);
1457 DU_LOG("\nERROR --> MAC : Invalid tmrEvnt=%d",tmrEvnt);
1467 * @brief Layer Manager Unsolicited Status Indication generation.
1471 * Function : rgLMMStaInd
1473 * This API is used by the other modules of MAC to send a unsolicited
1474 * status indication to the Layer Manager.
1476 * @param[in] Inst inst
1477 * @param[in] uint16_t category, the Alarm category
1478 * @param[in] uint16_t event, the Alarm event
1479 * @param[in] uint16_t cause, the cause of the Alarm
1480 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1494 if(rgCb[inst].rgInit.usta == FALSE)
1499 memset(&usta, 0, sizeof(RgMngmt));
1501 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1502 usta.t.usta.cmAlarm.category = category;
1503 usta.t.usta.cmAlarm.event = event;
1504 usta.t.usta.cmAlarm.cause = cause;
1507 memcpy(&usta.t.usta.dgn, dgn, sizeof(RgUstaDgn));
1510 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1511 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1512 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1513 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1514 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1515 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1517 return (RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1522 * @brief Layer Manager Trace Indication generation.
1526 * Function : rgLMMTrcInd
1528 * This API is used by the other modules of MAC to send a
1529 * Trace indication to the Layer Manager.
1531 * @param[in] Inst inst
1532 * @param[in] Buffer *srcMbuf, the Message Buffer .
1533 * @param[in] uint8_t event, the trace event.
1539 Buffer *srcMbuf, /* Message Buffer */
1540 uint8_t event /* event */
1543 Buffer *dstMbuf = NULLP;
1552 if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1554 DU_LOG("\nERROR --> MAC : Trace Disabled.");
1558 memset(&trc, 0, sizeof(RgMngmt));
1560 pst = rgCb[inst].rgInit.lmPst;
1561 pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1562 pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1563 pst.route = rgCb[inst].genCfg.trcResp.response.route;
1564 pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1565 pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1567 trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1569 SGetDateTime(&trc.t.trc.dt);
1571 /* Check if the whole buffer is to be sent in Trace indication */
1572 if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1574 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1577 DU_LOG("\nERROR --> MAC : SCpyMsgMsg Failed.");
1580 trc.cfm.status = LCM_PRIM_OK;
1581 trc.cfm.reason = LCM_REASON_NOT_APPL;
1582 trc.t.trc.evnt = event;
1584 /* Send Trace Indication to Layer manager */
1585 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1587 /* check if only a specified number of bytes are to be sent */
1588 else if(rgCb[inst].trcLen > 0)
1590 /* Get the length of the recvd message buffer */
1591 if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1593 DU_LOG("\nERROR --> MAC : SFndLenMsg Failed.");
1596 /* Check if the recvd buffer size is less than request trace len */
1597 if(bufLen < rgCb[inst].trcLen)
1599 /* Copy the whole of the recvd buffer in trace indication */
1601 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1604 DU_LOG("\nERROR --> MAC : SCpyMsgMsg Failed.");
1608 trc.cfm.status = LCM_PRIM_OK;
1609 trc.cfm.reason = LCM_REASON_NOT_APPL;
1610 trc.t.trc.evnt = event;
1612 /* Send Trace Indication to Layer manager */
1613 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1615 /* if the recvd buffer size is greater than request trace len */
1616 if(bufLen >= rgCb[inst].trcLen)
1618 /* Get a temporary buffer to store the msg */
1619 if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1621 DU_LOG("\nERROR --> MAC : rgAllocSBuf Failed.");
1625 /* Copy trcLen nos of bytes from the recvd message */
1626 if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)
1628 DU_LOG("\nERROR --> MAC : SCpyMsgFix Failed.");
1632 if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1634 DU_LOG("\nERROR --> MAC : dstMbuf Allocation Failed");
1637 /* Copy the tempBuf data to dst mBuf */
1638 if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1640 DU_LOG("\nERROR --> MAC : SCpyFixMsg Failed.");
1644 /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1646 /* Free the memory allocated for tempBuf */
1647 rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1649 trc.cfm.status = LCM_PRIM_OK;
1650 trc.cfm.reason = LCM_REASON_NOT_APPL;
1651 trc.t.trc.evnt = event;
1653 /* Send Trace Indication to Layer manager */
1654 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1662 * @brief Layer Manager Control Confirm generation handler
1663 * for Bind Confirm reception at TFU interface.
1664 * RgLiTfuBndCfm() forwards the confirmation to this
1665 * function. All SAP state related handling is restricted
1666 * to LMM modules, hence the cfm forwarding.
1670 * Function : rgLMMBndCfm
1672 * This API is used by the LIM module of MAC to forward
1673 * the Bind Confirm it receives over the TFU interface.
1675 * @param[in] Pst *pst, Post Structure
1676 * @param[in] SuId suId, Service user ID
1677 * @param[in] uint8_t status, Status
1683 Pst *pst, /* Post Structure */
1684 SuId suId, /* Service user ID */
1685 uint8_t status /* Status */
1688 Inst inst = pst->dstInst - RG_INST_START;
1696 /* Check if the suId is valid */
1697 if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1699 DU_LOG("\nERROR --> MAC : Invalid SuId");
1703 /* check the Sap State */
1704 switch(rgCb[inst].tfuSap.sapSta.sapState)
1706 case LRG_WAIT_BNDCFM:
1709 /* SAP is already bound */
1715 cfmPst = rgCb[inst].rgInit.lmPst;
1716 cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1717 cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1718 cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1719 cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1720 cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1722 memset(&cntrlCfm, 0, sizeof(RgMngmt));
1726 case CM_BND_OK: /* status is OK */
1727 /* Change SAP state to Bound */
1728 rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1729 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1731 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1733 /* Send Control Confirm with status as OK to Layer Manager */
1734 cntrlCfm.cfm.status = LCM_PRIM_OK;
1735 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1739 /* Change SAP state to UnBound */
1740 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1741 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1743 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1745 /* Send Control Confirm with status as NOK to Layer Manager */
1746 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1747 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1750 rgCb[inst].tfuSap.numBndRetries = 0;
1751 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1752 cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1754 ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1761 * @brief LTE MAC timer call back function registered with SSI.
1765 * Function : rgActvTmr
1767 * This function is invoked by SSI for every timer activation
1773 S16 rgActvTmr(Ent ent,Inst inst)
1775 Inst macInst = (inst - RG_INST_START);
1777 /* Check if any MAC timer has expired */
1778 cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1782 } /* end of rgActvTmr */
1784 /**********************************************************************
1787 **********************************************************************/