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 */
48 #include "mac_utils.h"
50 /* header/extern include files (.x) */
51 #include "crg.x" /* CRG Interface includes */
52 #include "rgu.x" /* RGU Interface includes */
53 #include "tfu.x" /* RGU Interface includes */
54 #include "rg_sch_inf.x" /* SCH Interface includes */
55 #include "rg_prg.x" /* PRG Interface includes */
56 #include "lrg.x" /* LRG Interface includes */
57 #include "rgr.x" /* LRG Interface includes */
58 #include "du_app_mac_inf.h"
59 #include "rg.x" /* MAC includes */
61 #include "ss_diag.h" /* Common log file */
65 #include "mac_sch_interface.h"
66 #include "lwr_mac_upr_inf.h"
68 #include "lwr_mac_fsm.h"
69 #include "lwr_mac_phy.h"
73 #endif /* __cplusplus */
74 Void rgGetSId ARGS((SystemId *s));
77 #endif /* __cplusplus */
79 /* Public variable declaration */
82 /* forward references */
83 static uint16_t rgLMMGenCfg ARGS((
88 static uint16_t rgLMMSapCfg ARGS((
94 static Void rgLMMShutdown ARGS((
98 static Void rgLMMFillCfmPst ARGS((
104 static Void rgLMMGenCntrl ARGS((
110 static Void rgLMMSapCntrl ARGS((
118 * @brief Task Initiation callback function.
122 * Function : rgActvInit
124 * This function is supplied as one of parameters during MAC's
125 * task registration. SSI will invoke this function once, after
126 * it creates and attaches this TAPA Task to a system task.
128 * @param[in] Ent entity, the entity ID of this task.
129 * @param[in] Inst inst, the instance ID of this task.
130 * @param[in] Region region, the region ID registered for memory
131 * usage of this task.
132 * @param[in] Reason reason.
138 Ent entity, /* entity */
139 Inst inst, /* instance */
140 Region region, /* region */
141 Reason reason /* reason */
146 RG_IS_INST_VALID(inst);
148 macInst = inst - RG_INST_START;
149 /* Initialize the MAC TskInit structure to zero */
150 memset (&rgCb[macInst], 0, sizeof(RgCb));
152 /* Initialize the MAC TskInit with received values */
153 rgCb[macInst].rgInit.ent = entity;
154 rgCb[macInst].rgInit.inst = inst;
155 rgCb[macInst].rgInit.region = region;
156 rgCb[macInst].rgInit.pool = 0;
157 rgCb[macInst].rgInit.reason = reason;
158 rgCb[macInst].rgInit.cfgDone = FALSE;
159 rgCb[macInst].rgInit.acnt = FALSE;
160 rgCb[macInst].rgInit.usta = FALSE;
161 rgCb[macInst].rgInit.trc = FALSE;
162 rgCb[macInst].trcLen = 0;
165 /* disabling debugs by default */
166 rgCb[macInst].rgInit.dbgMask = 0xffffffff;
170 rgCb[macInst].rgInit.logMask = 0x0;
172 rgCb[macInst].rgInit.procId = SFndProcId();
173 rgCb[macInst].tfuSap.numBndRetries = 0;
175 /* Initialize Sap state */
176 rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
177 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
178 rgCb[macInst].rguSap = NULLP;
179 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
181 rgCb[macInst].inactiveCell = NULLP;
182 rgCb[macInst].cell = NULLP;
184 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
185 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
188 /* Initialize Scheduler as well */
189 schActvInit(ENTMAC, SCH_INST_START, DFLT_REGION, PWR_UP);
191 /* Initialize lower mac */
192 lwrMacLayerInit(region, 0);
199 * @brief Layer Manager Configuration request handler.
203 * Function : RgMiLrgCfgReq
205 * This function handles the configuration
206 * request received from the Layer Manager.
207 * -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
208 * functions rgHdlGenCfg() or rgHdlSapCfg().
209 * -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
211 * @param[in] Pst *pst, the post structure
212 * @param[in] RgMngmt *cfg, the configuration parameter's structure
218 Pst *pst, /* post structure */
219 RgMngmt *cfg /* config structure */
222 uint16_t ret = LCM_PRIM_OK;
223 uint16_t reason = LCM_REASON_NOT_APPL;
230 DU_LOG("\nINFO --> MAC : Received CfgReq for MAC layer, Entity = %d, Instance = %d", pst->srcEnt, pst->srcInst);
232 RG_IS_INST_VALID(pst->dstInst);
233 inst = pst->dstInst - RG_INST_START;
235 /* Fill the post structure for sending the confirmation */
236 rgLMMFillCfmPst(pst, &cfmPst, cfg);
238 memset(&cfm, 0, sizeof(RgMngmt));
241 cfm.hdr.transId = cfg->hdr.transId;
245 cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
246 switch(cfg->hdr.elmId.elmnt)
250 /* Start WLS message receiver thread */
251 LwrMacStartWlsRcvr();
253 reason = rgLMMGenCfg(inst,&cfg->t.cfg);
258 reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
262 reason = LCM_REASON_INVALID_ELMNT;
263 DU_LOG("\nERROR --> MAC : Invalid Elmnt=%d",
264 cfg->hdr.elmId.elmnt);
268 if (reason != LCM_REASON_NOT_APPL)
273 cfm.cfm.status = ret;
274 cfm.cfm.reason = reason;
276 RgMiLrgCfgCfm(&cfmPst, &cfm);
279 }/*-- RgMiLrgCfgReq --*/
283 * @brief Layer Manager Statistics request handler.
287 * Function : RgMiLrgStsReq
289 * This function handles the statistics
290 * request received from the Layer Manager.
291 * -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
292 * statistics from the rgCb global control block.
293 * -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
294 * -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
296 * @param[in] Pst *pst, the post structure
297 * @param[in] RgMngmt *sts, the statistics parameter's structure
303 Pst *pst, /* post structure */
304 RgMngmt *sts /* statistics structure */
311 RG_IS_INST_VALID(pst->dstInst);
312 inst = pst->dstInst - RG_INST_START;
313 /* Fill the post structure for sending the confirmation */
314 rgLMMFillCfmPst(pst, &cfmPst, sts);
316 memset(&cfm, 0, sizeof(RgMngmt));
319 cfm.hdr.transId = sts->hdr.transId;
321 SGetDateTime(&cfm.t.sts.dt);
322 cfm.cfm.status = LCM_PRIM_OK;
323 cfm.cfm.reason = LCM_REASON_NOT_APPL;
324 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
325 cfm.t.sts.action = sts->t.sts.action;
327 /* Check if General Config Done */
328 if(rgCb[inst].rgInit.cfgDone != TRUE)
330 cfm.cfm.status = LCM_PRIM_NOK;
331 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
332 RgMiLrgStsCfm(&cfmPst,&cfm);
333 DU_LOG("\nERROR --> MAC : Gen Cfg not done");
337 switch(sts->hdr.elmId.elmnt)
341 memcpy(&(cfm.t.sts.s.genSts), &rgCb[inst].genSts,
343 /* check if action is read and reset */
344 if(sts->t.sts.action == ARST)
346 rgCb[inst].genSts.numHarqFail = 0;
351 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
353 for(cqi=0; cqi <= 14; cqi++)
355 /* Filling DL ACK/NACK stats */
356 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
357 hqFailStats.dlCqiStat[cqi].mcs;
358 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
359 hqFailStats.dlCqiStat[cqi].numOfNacks;
360 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
361 hqFailStats.dlCqiStat[cqi].numOfAcks;
363 /* Filling UL ACK/NACK stats */
364 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
365 hqFailStats.ulCqiStat[cqi].mcs;
366 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
367 hqFailStats.ulCqiStat[cqi].numOfNacks;
368 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
369 hqFailStats.ulCqiStat[cqi].numOfAcks;
371 /* Filling DL HQ Retx stats */
372 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
373 hqRetxStats.dlCqiStat[cqi].mcs;
374 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
375 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
376 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
377 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
378 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
379 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
380 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
381 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
382 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
383 hqRetxStats.dlCqiStat[cqi].totalTx;
385 /* Filling UL HQ Retx stats */
386 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
387 hqRetxStats.ulCqiStat[cqi].mcs;
388 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
389 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
390 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
391 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
392 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
393 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
394 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
395 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
396 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
397 hqRetxStats.ulCqiStat[cqi].totalTx;
399 /* Reset statistics */
400 if(sts->t.sts.action == ZEROSTS)
402 memset(&hqRetxStats, 0, \
403 sizeof(RgSchHqRetxStats));
404 memset(&hqFailStats, 0, \
405 sizeof(RgSchNackAckStats));
408 #endif /* MAC_SCH_STATS*/
412 memcpy(&(cfm.t.sts.s.rguSts), &rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
415 /* check if action is read and reset */
416 if(sts->t.sts.action == ARST)
417 memset(&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
421 memcpy(&(cfm.t.sts.s.crgSts), &rgCb[inst].crgSap.sapSts,
424 /* check if action is read and reset */
425 if(sts->t.sts.action == ARST)
426 memset(&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
430 memcpy(&(cfm.t.sts.s.tfuSts), &rgCb[inst].tfuSap.sapSts,
433 /* check if action is read and reset */
434 if(sts->t.sts.action == ARST)
435 memset(&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
439 cfm.cfm.status = LCM_PRIM_NOK;
440 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
441 DU_LOG("\nERROR --> MAC : Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
444 RgMiLrgStsCfm(&cfmPst,&cfm);
446 }/*-- RgMiLrgStsReq --*/
450 * @brief Layer Manager Status request handler.
454 * Function : RgMiLrgStaReq
456 * This function handles the solicited status
457 * request received from the Layer Manager.
458 * -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
459 * particular SAP from the rgCb global control block.
460 * -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
462 * @param[in] Pst *pst, the post structure
463 * @param[in] RgMngmt *sta, the status parameter's structure
469 Pst *pst, /* post structure */
470 RgMngmt *sta /* status structure */
478 RG_IS_INST_VALID(pst->dstInst);
479 inst = pst->dstInst - RG_INST_START;
482 /* Fill the post structure for sending the confirmation */
483 rgLMMFillCfmPst(pst, &cfmPst, sta);
485 if (sta->t.ssta.s.sysId.ptNmb != NULLP)
487 MAC_FREE(sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
490 memset(&cfm, 0, sizeof(RgMngmt));
491 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
494 cfm.hdr.transId = sta->hdr.transId;
496 /* Check if General Config Done */
497 if(rgCb[inst].rgInit.cfgDone != TRUE)
499 SGetDateTime(&cfm.t.ssta.dt);
500 MAC_ALLOC(cfm.t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
501 if(cfm.t.ssta.s.sysId.ptNmb == NULLP)
503 DU_LOG("\nERROR --> MAC : Memory Unavailable for Confirmation");
506 memset((cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
507 rgGetSId(&cfm.t.ssta.s.sysId);
508 cfm.cfm.status = LCM_PRIM_NOK;
509 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
510 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
511 RgMiLrgStaCfm(&cfmPst, &cfm);
512 DU_LOG("\nERROR --> MAC : Gen Cfg not done");
516 switch(sta->hdr.elmId.elmnt)
519 SGetDateTime(&cfm.t.ssta.dt);
520 MAC_ALLOC(cfm.t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
521 if(cfm.t.ssta.s.sysId.ptNmb == NULLP)
523 DU_LOG("\nERROR --> MAC : Memory Unavailable for Confirmation");
526 memset((cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
527 rgGetSId(&cfm.t.ssta.s.sysId);
528 cfm.cfm.status = LCM_PRIM_OK;
529 cfm.cfm.reason = LCM_REASON_NOT_APPL;
530 RgMiLrgStaCfm(&cfmPst, &cfm);
533 cfm.cfm.status = LCM_PRIM_OK;
534 cfm.cfm.reason = LCM_REASON_NOT_APPL;
535 SGetDateTime(&cfm.t.ssta.dt);
536 memcpy(&(cfm.t.ssta.s.rguSapSta),
537 &rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
539 RgMiLrgStaCfm(&cfmPst, &cfm);
542 cfm.cfm.status = LCM_PRIM_OK;
543 cfm.cfm.reason = LCM_REASON_NOT_APPL;
544 SGetDateTime(&cfm.t.ssta.dt);
545 memcpy(&(cfm.t.ssta.s.crgSapSta), &rgCb[inst].crgSap.sapSta,
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.tfuSapSta), &rgCb[inst].tfuSap.sapSta,
555 RgMiLrgStaCfm(&cfmPst, &cfm);
558 cfm.cfm.status = LCM_PRIM_NOK;
559 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
560 RgMiLrgStaCfm(&cfmPst, &cfm);
561 DU_LOG("\nERROR --> MAC : Invalid elmnt=%d",sta->hdr.elmId.elmnt);
565 }/*-- RgMiLrgStaReq --*/
569 * @brief Layer Manager Control request handler.
573 * Function : RgMiLrgCntrlReq
575 * This function handles the control
576 * request received from the Layer Manager.
577 * -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
578 * and cntrl->t.cntrl.subAction, it performs the appropriate control action
579 * of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
580 * and layer shutdown.
581 * -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
583 * @param[in] Pst *pst, the post structure
584 * @param[in] RgMngmt *cntrl, the control parameter's structure
590 Pst *pst, /* post structure */
591 RgMngmt *cntrl /* control structure */
594 S16 ret = ROK; /* return value */
598 /* Fill the post structure for sending the confirmation */
600 RG_IS_INST_VALID(pst->dstInst);
601 inst = pst->dstInst - RG_INST_START;
603 rgLMMFillCfmPst(pst, &cfmPst, cntrl);
605 memset(&cfm, 0, sizeof(RgMngmt));
607 cfm.hdr.transId = cntrl->hdr.transId;
609 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
610 cfm.t.cntrl.action = cntrl->t.cntrl.action;
611 cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
613 /* Check if General Config Done*/
614 if(rgCb[inst].rgInit.cfgDone != TRUE)
616 cfm.cfm.status = LCM_PRIM_NOK;
617 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
618 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
619 RgMiLrgCntrlCfm(&cfmPst, &cfm);
620 DU_LOG("\nERROR --> MAC : Gen Cfg not done");
624 /* General Config done, process the Control request */
625 switch(cntrl->hdr.elmId.elmnt)
628 rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
633 rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
636 cfm.cfm.status = LCM_PRIM_NOK;
637 cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
638 RgMiLrgCntrlCfm(&cfmPst, &cfm);
639 DU_LOG("\nERROR --> MAC : invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
643 }/*-- RgMiLrgCntrlReq --*/
647 * @brief SAP Configuration Handler.
651 * Function : rgLMMSapCfg
653 * This function in called by RgMiLrgCfgReq(). It handles the
654 * interface SAP configuration of the LTE MAC layer. It
655 * initializes the sapState to LRG_UNBND. Returns
656 * reason for success/failure of this function.
658 * @param[in] Inst inst
659 * @param[in] RgCfg *cfg, the Configuaration information
661 * -# LCM_REASON_GENCFG_NOT_DONE
662 * -# LCM_REASON_INVALID_SAP
663 * -# LCM_REASON_NOT_APPL
665 static uint16_t rgLMMSapCfg
668 RgCfg *cfg, /* Configuaration information */
669 Elmnt sapType /* Sap Type */
672 uint16_t ret = LCM_REASON_NOT_APPL;
673 RgLowSapCfgInfo *lowSapCfg = NULLP;
674 RgUpSapCfgInfo *upSapCfg = NULLP;
675 RgUpSapCb *upSapCb = NULLP;
678 /* Check if Gen Config has been done */
679 if(rgCb[inst].rgInit.cfgDone != TRUE)
680 return (LCM_REASON_GENCFG_NOT_DONE);
685 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
686 (cfg->s.rguSap.selector != ODU_SELECTOR_TC) &&
687 (cfg->s.rguSap.selector != ODU_SELECTOR_LC))
689 ret = LCM_REASON_INVALID_PAR_VAL;
690 DU_LOG("\nERROR --> MAC : unsupported Selector value for RGU");
693 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
694 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
696 upSapCb->sapSta.sapState = LRG_UNBND;
698 upSapCfg = &(upSapCb->sapCfg);
699 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
700 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
701 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
702 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
703 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
704 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
705 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
706 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
707 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
708 upSapCfg->sapPst.route = cfg->s.rguSap.route;
709 upSapCfg->sapPst.intfVer = 0;
710 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
711 upSapCfg->suId = cfg->s.rguSap.suId;
712 upSapCfg->spId = cfg->s.rguSap.spId;
713 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
714 * there is cfg request with sap is 1*/
717 if ((cfg->s.crgSap.selector != ODU_SELECTOR_TC) &&
718 (cfg->s.crgSap.selector != ODU_SELECTOR_LC))
720 ret = LCM_REASON_INVALID_PAR_VAL;
721 DU_LOG("\nERROR --> MAC : unsupported Selector value for CRG");
724 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
726 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
728 upSapCfg = &rgCb[inst].crgSap.sapCfg;
730 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
731 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
732 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
733 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
734 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
735 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
736 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
737 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
738 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
739 upSapCfg->sapPst.route = cfg->s.crgSap.route;
740 upSapCfg->sapPst.intfVer = 0;
741 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
742 upSapCfg->suId = cfg->s.crgSap.suId;
743 upSapCfg->spId = cfg->s.crgSap.spId;
747 if ((cfg->s.tfuSap.selector != ODU_SELECTOR_TC) &&
748 (cfg->s.tfuSap.selector != ODU_SELECTOR_LC))
750 ret = LCM_REASON_INVALID_PAR_VAL;
751 DU_LOG("\nERROR --> MAC : unsupported Selector value for TFU");
755 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
757 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
759 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
761 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
762 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
763 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
764 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
765 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
766 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
767 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
768 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
769 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
770 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
771 lowSapCfg->sapPst.intfVer = 0;
772 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
773 lowSapCfg->suId = cfg->s.tfuSap.suId;
774 lowSapCfg->spId = cfg->s.tfuSap.spId;
775 memcpy(&lowSapCfg->bndTmr, &cfg->s.tfuSap.bndTmr,
779 /* would never reach here */
787 * @brief General Configuration Handler.
791 * Function : rgLMMGenCfg
793 * This function in called by RgMiLrgCfgReq(). It handles the
794 * general configuration of the LTE MAC layer. It initializes
795 * the hash lists of RgCb. Returns
796 * reason for success/failure of this function.
798 * @param[in] Inst inst
799 * @param[in] RgCfg *cfg, the Configuaration information
801 * -# LCM_REASON_NOT_APPL
802 * -# LCM_REASON_INVALID_MSGTYPE
803 * -# LCM_REASON_MEM_NOAVAIL
805 static uint16_t rgLMMGenCfg
808 RgCfg *cfg /* Configuaration information */
811 uint16_t ret = LCM_REASON_NOT_APPL;
814 /* Check if General Configuration is done already */
815 if (rgCb[inst].rgInit.cfgDone == TRUE)
817 return (LCM_REASON_INVALID_MSGTYPE);
819 if ((cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_TC) &&
820 (cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_LC))
822 DU_LOG("\nERROR --> MAC : unsupported Selector value for RGU");
823 return (LCM_REASON_INVALID_PAR_VAL);
825 /* Update the Pst structure for LM interface */
826 memcpy(&rgCb[inst].rgInit.lmPst, &cfg->s.genCfg.lmPst,
829 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
830 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
831 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
832 rgCb[inst].rgInit.lmPst.event = EVTNONE;
834 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
835 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
836 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
838 macCb.tmrRes = cfg->s.genCfg.tmrRes;
839 macCb.macInst = rgCb[inst].rgInit.inst;
840 macCb.procId = rgCb[inst].rgInit.procId;
842 /* Initialize SAP States */
843 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
845 if(cfg->s.genCfg.numRguSaps == 0)
847 DU_LOG("\nERROR --> MAC : rgGenCfg(): Invalid numRguSap.\n");
851 /* allocate RGR saps */
852 MAC_ALLOC(rgCb[inst].rguSap, sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps);
853 if(rgCb[inst].rguSap == NULLP)
855 DU_LOG("\nERROR --> MAC : rgGenCfg(): Failed to allocate mem for RGU SAP's.\n");
858 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
860 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
862 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
863 memset(&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
865 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
866 /* Initialize the timer blocks */
867 cmInitTimers(macCb.tmrBlk, MAX_NUM_TIMER);
868 /* Initialzie the timer queue */
869 memset(&macCb.tmrTq, 0, sizeof(CmTqType) * MAC_TQ_SIZE);
870 /* Initialize the timer control point */
871 memset(&macCb.tmrTqCp, 0, sizeof(CmTqCp));
872 macCb.tmrTqCp.tmrLen = MAC_TQ_SIZE;
874 /* Timer Registration request to SSI */
875 if(ODU_REG_TMR_MT(ENTMAC, macCb.macInst, macCb.tmrRes, macActvTmr) != ROK)
878 DU_LOG("\nERROR --> MAC : Failed to register timer");
880 MAC_FREE(rgCb[inst].rguSap,
881 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
883 return (LCM_REASON_MEM_NOAVAIL);
886 /* Set Config done in TskInit */
887 rgCb[inst].rgInit.cfgDone = TRUE;
893 /***********************************************************
895 * Func : rgLMMShutdown
898 * Desc : Handles the MAC layer shutdown request. Calls
899 * rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
908 **********************************************************/
909 static Void rgLMMShutdown(Inst inst)
911 RgCellCb *cell = rgCb[inst].cell;
915 /* Unbind the TFU Sap */
916 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
918 //rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
919 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
921 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
923 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
925 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
927 //rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
928 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
934 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
936 rgTOMRlsSf(inst,&cell->subFrms[idx]);
939 rgCFGFreeCellCb(cell);
942 /* Deleting the RGU SAPs */
943 MAC_FREE(rgCb[inst].rguSap,
944 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
946 rgCb[inst].inactiveCell = NULLP;
947 rgCb[inst].cell = NULLP;
949 /* De-register the Timer Service */
950 (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
951 (S16)rgCb[inst].genCfg.tmrRes, macActvTmr);
953 /* call back the task initialization function to intialize
954 * the global RgCb Struct */
955 rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region,
956 rgCb[inst].rgInit.reason);
962 /***********************************************************
964 * Func : rgLMMGenCntrl
967 * Desc : Processes the LM control request for STGEN elmnt.
976 **********************************************************/
977 static Void rgLMMGenCntrl
984 Inst inst = (cfmPst->srcInst - RG_INST_START);
986 cfm->cfm.status = LCM_PRIM_OK;
987 cfm->cfm.reason = LCM_REASON_NOT_APPL;
990 switch(cntrl->t.cntrl.action)
993 /* Action is Enable */
994 switch(cntrl->t.cntrl.subAction)
998 rgCb[inst].rgInit.trc = TRUE;
999 rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1000 /*Store the response and TransId for sending the Traces */
1001 memcpy(&rgCb[inst].genCfg.trcResp.response,
1002 &cntrl->hdr.response, sizeof(Resp));
1003 rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1007 /* Enable Unsolicited Status (alarms) */
1008 rgCb[inst].rgInit.usta = TRUE;
1009 /*Store the response and TransId for sending the Alarms */
1010 memcpy(&rgCb[inst].genCfg.ustaResp.response,
1011 &cntrl->hdr.response, sizeof(Resp));
1012 rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1015 /* Enable Debug Printing */
1017 rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1022 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1027 cfm->cfm.status = LCM_PRIM_NOK;
1028 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1029 DU_LOG("\nERROR --> MAC : invalid subaction=%d",cntrl->t.cntrl.subAction);
1034 /* Action is Diable immidiately */
1035 switch(cntrl->t.cntrl.subAction)
1038 /* Disable Traces */
1039 rgCb[inst].rgInit.trc = FALSE;
1042 /* Disable Unsolicited Status (alarms) */
1043 rgCb[inst].rgInit.usta = FALSE;
1046 /* Disable Debug Printing */
1048 rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1053 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1058 cfm->cfm.status = LCM_PRIM_NOK;
1059 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1060 DU_LOG("\nERROR --> MAC : invalid subaction=%d",cntrl->t.cntrl.subAction);
1065 /* Free all the memory dynamically allocated by MAC */
1066 rgLMMShutdown(inst);
1069 cfm->cfm.status = LCM_PRIM_NOK;
1070 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1071 DU_LOG("\nERROR --> MAC : invalid action=%d",cntrl->t.cntrl.action);
1074 RgMiLrgCntrlCfm(cfmPst, cfm);
1079 /***********************************************************
1081 * Func : rgLMMSapCntrl
1084 * Desc : Processes the LM control request for STxxxSAP elmnt.
1093 **********************************************************/
1094 static Void rgLMMSapCntrl
1101 Inst inst = cfmPst->srcInst - RG_INST_START;
1103 /* Only TFU Sap can be controlled by LM */
1104 switch(cntrl->hdr.elmId.elmnt)
1107 switch(cntrl->t.cntrl.action)
1110 /* Bind Enable Request */
1111 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1112 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1114 cfm->cfm.status = LCM_PRIM_NOK;
1115 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1119 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1121 rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val,
1122 (PTR)&rgCb[inst].tfuSap);
1124 /* Change SAP state */
1125 rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1126 rgCb[inst].tfuSap.numBndRetries++;
1127 /* Store the response and TransId for sending
1128 * the Control confirm */
1129 memcpy(&rgCb[inst].genCfg.bndCfmResp.response,
1130 &cntrl->hdr.response, sizeof(Resp));
1131 rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1133 /* Sending Status Indication to Layer Manager */
1134 cfm->cfm.status = LCM_PRIM_OK_NDONE;
1135 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1136 RgMiLrgCntrlCfm(cfmPst, cfm);
1138 //rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1139 //rgCb[inst].tfuSap.sapCfg.spId);
1144 /* Unbind request */
1146 /* Check if the SAP is configured */
1147 if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1148 (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1150 cfm->cfm.status = LCM_PRIM_NOK;
1151 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1155 //rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1156 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1158 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1160 /* Change SAP state */
1161 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1162 cfm->cfm.status = LCM_PRIM_OK;
1163 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1167 /* Delete SAP, does initialization of SAP */
1168 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1169 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1171 //rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1172 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1174 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1177 memset(&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1178 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1179 cfm->cfm.status = LCM_PRIM_OK;
1180 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1183 cfm->cfm.status = LCM_PRIM_NOK;
1184 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1185 DU_LOG("\nERROR --> MAC : rgLMMSapCntrl(): invalid action=%d",
1186 cntrl->t.cntrl.action);
1191 switch(cntrl->t.cntrl.action)
1194 memset(&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1195 rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1196 cfm->cfm.status = LCM_PRIM_OK;
1197 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1200 cfm->cfm.status = LCM_PRIM_NOK;
1201 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1202 DU_LOG("\nERROR --> MAC : rgLMMSapCntrl(): invalid action=%d",
1203 cntrl->t.cntrl.action);
1208 switch(cntrl->t.cntrl.action)
1211 memset(&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1212 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1213 cfm->cfm.status = LCM_PRIM_OK;
1214 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1217 cfm->cfm.status = LCM_PRIM_NOK;
1218 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1219 DU_LOG("\nERROR --> MAC : invalid action=%d",cntrl->t.cntrl.action);
1225 /* Would never here. */
1228 RgMiLrgCntrlCfm(cfmPst, cfm);
1233 /***********************************************************
1235 * Func : rgLMMFillCfmPst
1238 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
1239 * and the cfm->hdr.response.
1248 **********************************************************/
1249 static Void rgLMMFillCfmPst
1257 inst = (reqPst->dstInst - RG_INST_START);
1259 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
1260 cfmPst->srcInst = rgCb[inst].rgInit.inst;
1261 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1262 cfmPst->dstEnt = reqPst->srcEnt;
1263 cfmPst->dstInst = reqPst->srcInst;
1264 cfmPst->dstProcId = reqPst->srcProcId;
1266 cfmPst->selector = cfm->hdr.response.selector;
1267 cfmPst->prior = cfm->hdr.response.prior;
1268 cfmPst->route = cfm->hdr.response.route;
1269 cfmPst->region = cfm->hdr.response.mem.region;
1270 cfmPst->pool = cfm->hdr.response.mem.pool;
1277 * @brief Timer start handler.
1281 * Function : rgLMMStartTmr
1283 * This function based on the input parameters starts the timer for
1284 * "tmrVal" duration. As of now MAC uses the timer functionality for
1285 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1287 * @param[in] Inst inst
1288 * @param[in] S16 tmrEvnt, the Timer Event
1289 * @param[in] uint32_t tmrVal, the Wait Time
1290 * @param[in] PTR cb, Entry for which Timer expired
1297 S16 tmrEvnt, /* Timer Event */
1298 uint32_t tmrVal, /* Wait Time */
1299 PTR cb /* Entry for which Timer Expired */
1307 /* Initialize the arg structure */
1308 memset(&arg, 0, sizeof(CmTmrArg));
1310 arg.tqCp = &rgCb[inst].tmrTqCp;
1311 arg.tq = rgCb[inst].tmrTq;
1312 arg.timers = rgCb[inst].tmrBlk;
1315 arg.max = RG_MAX_TIMER;
1316 arg.evnt = RG_BNDREQ_TMR;
1325 * @brief Timer stop handler.
1329 * Function : rgLMMStopTmr
1331 * This function based on the input parameters stops the timer for
1332 * "tmrEvnt". As of now MAC uses the timer functionality for
1333 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1334 * Once the bind happens and this timer is stopped, the timer functionality
1335 * is deregistered with SSI. As there is no further use of timer processing.
1337 * @param[in] Inst inst
1338 * @param[in] S16 tmrEvnt, the Timer Event
1339 * @param[in] PTR cb, Entry for which Timer expired
1346 Inst inst, /* Scheduler instance */
1347 S16 tmrEvnt, /* Timer Event */
1348 PTR cb /* Entry for which Timer Expired */
1358 for(i=0;i<RG_MAX_TIMER;i++)
1360 /* Search for the Timer Blocks */
1361 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1363 /* Initialize the arg structure */
1364 memset(&arg, 0, sizeof(CmTmrArg));
1366 arg.tqCp = &rgCb[inst].tmrTqCp;
1367 arg.tq = rgCb[inst].tmrTq;
1368 arg.timers = rgCb[inst].tmrBlk;
1370 arg.max = RG_MAX_TIMER;
1388 * @brief Timer Expiry handler.
1392 * Function : rgLMMTmrExpiry
1394 * This is a callback function used as an input parameter to cmPrcTmr()
1395 * to check expiry of any timer. In this function, the only concern is
1396 * about tmrEvnt=Bind timer.
1398 * @param[in] PTR cb, Entry for which Timer expired
1399 * @param[in] S16 tmrEvnt, the Timer Event
1405 PTR cb, /* Pointer to timer control block */
1406 S16 tmrEvnt /* Timer Event */
1410 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1411 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1416 tfuSap->numBndRetries++;
1417 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1419 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1420 LCM_CAUSE_TMR_EXPIRED, NULLP);
1424 /* Restart the bind timer */
1425 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1427 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1431 /* Send bind request */
1432 //rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1433 //rgCb[inst].tfuSap.sapCfg.spId);
1437 DU_LOG("\nERROR --> MAC : Invalid tmrEvnt=%d",tmrEvnt);
1447 * @brief Layer Manager Unsolicited Status Indication generation.
1451 * Function : rgLMMStaInd
1453 * This API is used by the other modules of MAC to send a unsolicited
1454 * status indication to the Layer Manager.
1456 * @param[in] Inst inst
1457 * @param[in] uint16_t category, the Alarm category
1458 * @param[in] uint16_t event, the Alarm event
1459 * @param[in] uint16_t cause, the cause of the Alarm
1460 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1474 if(rgCb[inst].rgInit.usta == FALSE)
1479 memset(&usta, 0, sizeof(RgMngmt));
1481 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1482 usta.t.usta.cmAlarm.category = category;
1483 usta.t.usta.cmAlarm.event = event;
1484 usta.t.usta.cmAlarm.cause = cause;
1487 memcpy(&usta.t.usta.dgn, dgn, sizeof(RgUstaDgn));
1490 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1491 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1492 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1493 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1494 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1495 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1497 return (RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1502 * @brief Layer Manager Trace Indication generation.
1506 * Function : rgLMMTrcInd
1508 * This API is used by the other modules of MAC to send a
1509 * Trace indication to the Layer Manager.
1511 * @param[in] Inst inst
1512 * @param[in] Buffer *srcMbuf, the Message Buffer .
1513 * @param[in] uint8_t event, the trace event.
1519 Buffer *srcMbuf, /* Message Buffer */
1520 uint8_t event /* event */
1523 Buffer *dstMbuf = NULLP;
1532 if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1534 DU_LOG("\nERROR --> MAC : Trace Disabled.");
1538 memset(&trc, 0, sizeof(RgMngmt));
1540 pst = rgCb[inst].rgInit.lmPst;
1541 pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1542 pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1543 pst.route = rgCb[inst].genCfg.trcResp.response.route;
1544 pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1545 pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1547 trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1549 SGetDateTime(&trc.t.trc.dt);
1551 /* Check if the whole buffer is to be sent in Trace indication */
1552 if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1554 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1557 DU_LOG("\nERROR --> MAC : SCpyMsgMsg Failed.");
1560 trc.cfm.status = LCM_PRIM_OK;
1561 trc.cfm.reason = LCM_REASON_NOT_APPL;
1562 trc.t.trc.evnt = event;
1564 /* Send Trace Indication to Layer manager */
1565 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1567 /* check if only a specified number of bytes are to be sent */
1568 else if(rgCb[inst].trcLen > 0)
1570 /* Get the length of the recvd message buffer */
1571 if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1573 DU_LOG("\nERROR --> MAC : SFndLenMsg Failed.");
1576 /* Check if the recvd buffer size is less than request trace len */
1577 if(bufLen < rgCb[inst].trcLen)
1579 /* Copy the whole of the recvd buffer in trace indication */
1581 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1584 DU_LOG("\nERROR --> MAC : SCpyMsgMsg Failed.");
1588 trc.cfm.status = LCM_PRIM_OK;
1589 trc.cfm.reason = LCM_REASON_NOT_APPL;
1590 trc.t.trc.evnt = event;
1592 /* Send Trace Indication to Layer manager */
1593 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1595 /* if the recvd buffer size is greater than request trace len */
1596 if(bufLen >= rgCb[inst].trcLen)
1598 /* Get a temporary buffer to store the msg */
1599 if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1601 DU_LOG("\nERROR --> MAC : rgAllocSBuf Failed.");
1605 /* Copy trcLen nos of bytes from the recvd message */
1606 if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)
1608 DU_LOG("\nERROR --> MAC : SCpyMsgFix Failed.");
1612 if (ODU_GET_MSG_BUF(pst.region, pst.pool, &dstMbuf) != ROK)
1614 DU_LOG("\nERROR --> MAC : dstMbuf Allocation Failed");
1617 /* Copy the tempBuf data to dst mBuf */
1618 if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1620 DU_LOG("\nERROR --> MAC : SCpyFixMsg Failed.");
1624 /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1626 /* Free the memory allocated for tempBuf */
1627 rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1629 trc.cfm.status = LCM_PRIM_OK;
1630 trc.cfm.reason = LCM_REASON_NOT_APPL;
1631 trc.t.trc.evnt = event;
1633 /* Send Trace Indication to Layer manager */
1634 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1642 * @brief Layer Manager Control Confirm generation handler
1643 * for Bind Confirm reception at TFU interface.
1644 * RgLiTfuBndCfm() forwards the confirmation to this
1645 * function. All SAP state related handling is restricted
1646 * to LMM modules, hence the cfm forwarding.
1650 * Function : rgLMMBndCfm
1652 * This API is used by the LIM module of MAC to forward
1653 * the Bind Confirm it receives over the TFU interface.
1655 * @param[in] Pst *pst, Post Structure
1656 * @param[in] SuId suId, Service user ID
1657 * @param[in] uint8_t status, Status
1663 Pst *pst, /* Post Structure */
1664 SuId suId, /* Service user ID */
1665 uint8_t status /* Status */
1668 Inst inst = pst->dstInst - RG_INST_START;
1676 /* Check if the suId is valid */
1677 if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1679 DU_LOG("\nERROR --> MAC : Invalid SuId");
1683 /* check the Sap State */
1684 switch(rgCb[inst].tfuSap.sapSta.sapState)
1686 case LRG_WAIT_BNDCFM:
1689 /* SAP is already bound */
1695 cfmPst = rgCb[inst].rgInit.lmPst;
1696 cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1697 cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1698 cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1699 cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1700 cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1702 memset(&cntrlCfm, 0, sizeof(RgMngmt));
1706 case CM_BND_OK: /* status is OK */
1707 /* Change SAP state to Bound */
1708 rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1709 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1711 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1713 /* Send Control Confirm with status as OK to Layer Manager */
1714 cntrlCfm.cfm.status = LCM_PRIM_OK;
1715 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1719 /* Change SAP state to UnBound */
1720 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1721 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1723 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1725 /* Send Control Confirm with status as NOK to Layer Manager */
1726 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1727 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1730 rgCb[inst].tfuSap.numBndRetries = 0;
1731 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1732 cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1734 ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1739 /**********************************************************************
1742 **********************************************************************/