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 rgLMMFillCfmPst ARGS((
102 * @brief Task Initiation callback function.
106 * Function : macActvInit
108 * This function is supplied as one of parameters during MAC's
109 * task registration. SSI will invoke this function once, after
110 * it creates and attaches this TAPA Task to a system task.
112 * @param[in] Ent entity, the entity ID of this task.
113 * @param[in] Inst inst, the instance ID of this task.
114 * @param[in] Region region, the region ID registered for memory
115 * usage of this task.
116 * @param[in] Reason reason.
122 Ent entity, /* entity */
123 Inst inst, /* instance */
124 Region region, /* region */
125 Reason reason /* reason */
130 RG_IS_INST_VALID(inst);
132 macInst = inst - RG_INST_START;
133 /* Initialize the MAC TskInit structure to zero */
134 memset (&rgCb[macInst], 0, sizeof(RgCb));
136 /* Initialize the MAC TskInit with received values */
137 rgCb[macInst].rgInit.ent = entity;
138 rgCb[macInst].rgInit.inst = inst;
139 rgCb[macInst].rgInit.region = region;
140 rgCb[macInst].rgInit.pool = 0;
141 rgCb[macInst].rgInit.reason = reason;
142 rgCb[macInst].rgInit.cfgDone = FALSE;
143 rgCb[macInst].rgInit.acnt = FALSE;
144 rgCb[macInst].rgInit.usta = FALSE;
145 rgCb[macInst].rgInit.trc = FALSE;
146 rgCb[macInst].trcLen = 0;
149 /* disabling debugs by default */
150 rgCb[macInst].rgInit.dbgMask = 0xffffffff;
154 rgCb[macInst].rgInit.logMask = 0x0;
156 rgCb[macInst].rgInit.procId = SFndProcId();
157 rgCb[macInst].tfuSap.numBndRetries = 0;
159 /* Initialize Sap state */
160 rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
161 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
162 rgCb[macInst].rguSap = NULLP;
163 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
165 rgCb[macInst].inactiveCell = NULLP;
166 rgCb[macInst].cell = NULLP;
168 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
169 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
172 /* Initialize lower mac */
173 lwrMacLayerInit(region, 0);
180 * @brief Layer Manager Configuration request handler.
184 * Function : RgMiLrgCfgReq
186 * This function handles the configuration
187 * request received from the Layer Manager.
188 * -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
189 * functions rgHdlGenCfg() or rgHdlSapCfg().
190 * -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
192 * @param[in] Pst *pst, the post structure
193 * @param[in] RgMngmt *cfg, the configuration parameter's structure
199 Pst *pst, /* post structure */
200 RgMngmt *cfg /* config structure */
203 uint16_t ret = LCM_PRIM_OK;
204 uint16_t reason = LCM_REASON_NOT_APPL;
211 DU_LOG("\nINFO --> MAC : Received CfgReq for MAC layer, Entity = %d, Instance = %d", pst->srcEnt, pst->srcInst);
213 RG_IS_INST_VALID(pst->dstInst);
214 inst = pst->dstInst - RG_INST_START;
216 /* Fill the post structure for sending the confirmation */
217 rgLMMFillCfmPst(pst, &cfmPst, cfg);
219 memset(&cfm, 0, sizeof(RgMngmt));
222 cfm.hdr.transId = cfg->hdr.transId;
226 cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
227 switch(cfg->hdr.elmId.elmnt)
231 /* Start WLS message receiver thread */
232 LwrMacStartWlsRcvr();
234 reason = rgLMMGenCfg(inst,&cfg->t.cfg);
239 reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
243 reason = LCM_REASON_INVALID_ELMNT;
244 DU_LOG("\nERROR --> MAC : Invalid Elmnt=%d",
245 cfg->hdr.elmId.elmnt);
249 if (reason != LCM_REASON_NOT_APPL)
254 cfm.cfm.status = ret;
255 cfm.cfm.reason = reason;
257 RgMiLrgCfgCfm(&cfmPst, &cfm);
260 }/*-- RgMiLrgCfgReq --*/
264 * @brief Layer Manager Statistics request handler.
268 * Function : RgMiLrgStsReq
270 * This function handles the statistics
271 * request received from the Layer Manager.
272 * -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
273 * statistics from the rgCb global control block.
274 * -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
275 * -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
277 * @param[in] Pst *pst, the post structure
278 * @param[in] RgMngmt *sts, the statistics parameter's structure
284 Pst *pst, /* post structure */
285 RgMngmt *sts /* statistics structure */
292 RG_IS_INST_VALID(pst->dstInst);
293 inst = pst->dstInst - RG_INST_START;
294 /* Fill the post structure for sending the confirmation */
295 rgLMMFillCfmPst(pst, &cfmPst, sts);
297 memset(&cfm, 0, sizeof(RgMngmt));
300 cfm.hdr.transId = sts->hdr.transId;
302 SGetDateTime(&cfm.t.sts.dt);
303 cfm.cfm.status = LCM_PRIM_OK;
304 cfm.cfm.reason = LCM_REASON_NOT_APPL;
305 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
306 cfm.t.sts.action = sts->t.sts.action;
308 /* Check if General Config Done */
309 if(rgCb[inst].rgInit.cfgDone != TRUE)
311 cfm.cfm.status = LCM_PRIM_NOK;
312 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
313 RgMiLrgStsCfm(&cfmPst,&cfm);
314 DU_LOG("\nERROR --> MAC : Gen Cfg not done");
318 switch(sts->hdr.elmId.elmnt)
322 memcpy(&(cfm.t.sts.s.genSts), &rgCb[inst].genSts,
324 /* check if action is read and reset */
325 if(sts->t.sts.action == ARST)
327 rgCb[inst].genSts.numHarqFail = 0;
332 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
334 for(cqi=0; cqi <= 14; cqi++)
336 /* Filling DL ACK/NACK stats */
337 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
338 hqFailStats.dlCqiStat[cqi].mcs;
339 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
340 hqFailStats.dlCqiStat[cqi].numOfNacks;
341 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
342 hqFailStats.dlCqiStat[cqi].numOfAcks;
344 /* Filling UL ACK/NACK stats */
345 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
346 hqFailStats.ulCqiStat[cqi].mcs;
347 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
348 hqFailStats.ulCqiStat[cqi].numOfNacks;
349 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
350 hqFailStats.ulCqiStat[cqi].numOfAcks;
352 /* Filling DL HQ Retx stats */
353 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
354 hqRetxStats.dlCqiStat[cqi].mcs;
355 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
356 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
357 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
358 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
359 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
360 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
361 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
362 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
363 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
364 hqRetxStats.dlCqiStat[cqi].totalTx;
366 /* Filling UL HQ Retx stats */
367 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
368 hqRetxStats.ulCqiStat[cqi].mcs;
369 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
370 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
371 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
372 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
373 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
374 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
375 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
376 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
377 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
378 hqRetxStats.ulCqiStat[cqi].totalTx;
380 /* Reset statistics */
381 if(sts->t.sts.action == ZEROSTS)
383 memset(&hqRetxStats, 0, \
384 sizeof(RgSchHqRetxStats));
385 memset(&hqFailStats, 0, \
386 sizeof(RgSchNackAckStats));
389 #endif /* MAC_SCH_STATS*/
393 memcpy(&(cfm.t.sts.s.rguSts), &rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
396 /* check if action is read and reset */
397 if(sts->t.sts.action == ARST)
398 memset(&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
402 memcpy(&(cfm.t.sts.s.crgSts), &rgCb[inst].crgSap.sapSts,
405 /* check if action is read and reset */
406 if(sts->t.sts.action == ARST)
407 memset(&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
411 memcpy(&(cfm.t.sts.s.tfuSts), &rgCb[inst].tfuSap.sapSts,
414 /* check if action is read and reset */
415 if(sts->t.sts.action == ARST)
416 memset(&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
420 cfm.cfm.status = LCM_PRIM_NOK;
421 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
422 DU_LOG("\nERROR --> MAC : Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
425 RgMiLrgStsCfm(&cfmPst,&cfm);
427 }/*-- RgMiLrgStsReq --*/
431 * @brief SAP Configuration Handler.
435 * Function : rgLMMSapCfg
437 * This function in called by RgMiLrgCfgReq(). It handles the
438 * interface SAP configuration of the LTE MAC layer. It
439 * initializes the sapState to LRG_UNBND. Returns
440 * reason for success/failure of this function.
442 * @param[in] Inst inst
443 * @param[in] RgCfg *cfg, the Configuaration information
445 * -# LCM_REASON_GENCFG_NOT_DONE
446 * -# LCM_REASON_INVALID_SAP
447 * -# LCM_REASON_NOT_APPL
449 static uint16_t rgLMMSapCfg
452 RgCfg *cfg, /* Configuaration information */
453 Elmnt sapType /* Sap Type */
456 uint16_t ret = LCM_REASON_NOT_APPL;
457 RgLowSapCfgInfo *lowSapCfg = NULLP;
458 RgUpSapCfgInfo *upSapCfg = NULLP;
459 RgUpSapCb *upSapCb = NULLP;
462 /* Check if Gen Config has been done */
463 if(rgCb[inst].rgInit.cfgDone != TRUE)
464 return (LCM_REASON_GENCFG_NOT_DONE);
469 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
470 (cfg->s.rguSap.selector != ODU_SELECTOR_TC) &&
471 (cfg->s.rguSap.selector != ODU_SELECTOR_LC))
473 ret = LCM_REASON_INVALID_PAR_VAL;
474 DU_LOG("\nERROR --> MAC : unsupported Selector value for RGU");
477 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
478 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
480 upSapCb->sapSta.sapState = LRG_UNBND;
482 upSapCfg = &(upSapCb->sapCfg);
483 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
484 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
485 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
486 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
487 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
488 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
489 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
490 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
491 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
492 upSapCfg->sapPst.route = cfg->s.rguSap.route;
493 upSapCfg->sapPst.intfVer = 0;
494 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
495 upSapCfg->suId = cfg->s.rguSap.suId;
496 upSapCfg->spId = cfg->s.rguSap.spId;
497 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
498 * there is cfg request with sap is 1*/
501 if ((cfg->s.crgSap.selector != ODU_SELECTOR_TC) &&
502 (cfg->s.crgSap.selector != ODU_SELECTOR_LC))
504 ret = LCM_REASON_INVALID_PAR_VAL;
505 DU_LOG("\nERROR --> MAC : unsupported Selector value for CRG");
508 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
510 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
512 upSapCfg = &rgCb[inst].crgSap.sapCfg;
514 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
515 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
516 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
517 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
518 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
519 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
520 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
521 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
522 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
523 upSapCfg->sapPst.route = cfg->s.crgSap.route;
524 upSapCfg->sapPst.intfVer = 0;
525 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
526 upSapCfg->suId = cfg->s.crgSap.suId;
527 upSapCfg->spId = cfg->s.crgSap.spId;
531 if ((cfg->s.tfuSap.selector != ODU_SELECTOR_TC) &&
532 (cfg->s.tfuSap.selector != ODU_SELECTOR_LC))
534 ret = LCM_REASON_INVALID_PAR_VAL;
535 DU_LOG("\nERROR --> MAC : unsupported Selector value for TFU");
539 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
541 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
543 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
545 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
546 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
547 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
548 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
549 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
550 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
551 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
552 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
553 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
554 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
555 lowSapCfg->sapPst.intfVer = 0;
556 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
557 lowSapCfg->suId = cfg->s.tfuSap.suId;
558 lowSapCfg->spId = cfg->s.tfuSap.spId;
559 memcpy(&lowSapCfg->bndTmr, &cfg->s.tfuSap.bndTmr,
563 /* would never reach here */
571 * @brief General Configuration Handler.
575 * Function : rgLMMGenCfg
577 * This function in called by RgMiLrgCfgReq(). It handles the
578 * general configuration of the LTE MAC layer. It initializes
579 * the hash lists of RgCb. Returns
580 * reason for success/failure of this function.
582 * @param[in] Inst inst
583 * @param[in] RgCfg *cfg, the Configuaration information
585 * -# LCM_REASON_NOT_APPL
586 * -# LCM_REASON_INVALID_MSGTYPE
587 * -# LCM_REASON_MEM_NOAVAIL
589 static uint16_t rgLMMGenCfg
592 RgCfg *cfg /* Configuaration information */
595 uint16_t ret = LCM_REASON_NOT_APPL;
598 /* Check if General Configuration is done already */
599 if (rgCb[inst].rgInit.cfgDone == TRUE)
601 return (LCM_REASON_INVALID_MSGTYPE);
603 if ((cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_TC) &&
604 (cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_LC))
606 DU_LOG("\nERROR --> MAC : unsupported Selector value for RGU");
607 return (LCM_REASON_INVALID_PAR_VAL);
609 /* Update the Pst structure for LM interface */
610 memcpy(&rgCb[inst].rgInit.lmPst, &cfg->s.genCfg.lmPst,
613 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
614 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
615 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
616 rgCb[inst].rgInit.lmPst.event = EVTNONE;
618 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
619 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
620 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
622 macCb.tmrRes = cfg->s.genCfg.tmrRes;
623 macCb.macInst = rgCb[inst].rgInit.inst;
624 macCb.procId = rgCb[inst].rgInit.procId;
626 /* Initialize SAP States */
627 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
629 if(cfg->s.genCfg.numRguSaps == 0)
631 DU_LOG("\nERROR --> MAC : rgGenCfg(): Invalid numRguSap.\n");
635 /* allocate RGR saps */
636 MAC_ALLOC(rgCb[inst].rguSap, sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps);
637 if(rgCb[inst].rguSap == NULLP)
639 DU_LOG("\nERROR --> MAC : rgGenCfg(): Failed to allocate mem for RGU SAP's.\n");
642 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
644 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
646 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
647 memset(&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
649 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
650 /* Initialize the timer blocks */
651 cmInitTimers(macCb.tmrBlk, MAX_NUM_TIMER);
652 /* Initialzie the timer queue */
653 memset(&macCb.tmrTq, 0, sizeof(CmTqType) * MAC_TQ_SIZE);
654 /* Initialize the timer control point */
655 memset(&macCb.tmrTqCp, 0, sizeof(CmTqCp));
656 macCb.tmrTqCp.tmrLen = MAC_TQ_SIZE;
658 /* Timer Registration request to SSI */
659 if(ODU_REG_TMR_MT(ENTMAC, macCb.macInst, macCb.tmrRes, macActvTmr) != ROK)
662 DU_LOG("\nERROR --> MAC : Failed to register timer");
664 MAC_FREE(rgCb[inst].rguSap,
665 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
667 return (LCM_REASON_MEM_NOAVAIL);
670 /* Set Config done in TskInit */
671 rgCb[inst].rgInit.cfgDone = TRUE;
677 /***********************************************************
679 * Func : rgLMMFillCfmPst
682 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
683 * and the cfm->hdr.response.
692 **********************************************************/
693 static Void rgLMMFillCfmPst
701 inst = (reqPst->dstInst - RG_INST_START);
703 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
704 cfmPst->srcInst = rgCb[inst].rgInit.inst;
705 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
706 cfmPst->dstEnt = reqPst->srcEnt;
707 cfmPst->dstInst = reqPst->srcInst;
708 cfmPst->dstProcId = reqPst->srcProcId;
710 cfmPst->selector = cfm->hdr.response.selector;
711 cfmPst->prior = cfm->hdr.response.prior;
712 cfmPst->route = cfm->hdr.response.route;
713 cfmPst->region = cfm->hdr.response.mem.region;
714 cfmPst->pool = cfm->hdr.response.mem.pool;
721 * @brief Timer start handler.
725 * Function : rgLMMStartTmr
727 * This function based on the input parameters starts the timer for
728 * "tmrVal" duration. As of now MAC uses the timer functionality for
729 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
731 * @param[in] Inst inst
732 * @param[in] S16 tmrEvnt, the Timer Event
733 * @param[in] uint32_t tmrVal, the Wait Time
734 * @param[in] PTR cb, Entry for which Timer expired
741 S16 tmrEvnt, /* Timer Event */
742 uint32_t tmrVal, /* Wait Time */
743 PTR cb /* Entry for which Timer Expired */
751 /* Initialize the arg structure */
752 memset(&arg, 0, sizeof(CmTmrArg));
754 arg.tqCp = &rgCb[inst].tmrTqCp;
755 arg.tq = rgCb[inst].tmrTq;
756 arg.timers = rgCb[inst].tmrBlk;
759 arg.max = RG_MAX_TIMER;
760 arg.evnt = RG_BNDREQ_TMR;
769 * @brief Timer stop handler.
773 * Function : rgLMMStopTmr
775 * This function based on the input parameters stops the timer for
776 * "tmrEvnt". As of now MAC uses the timer functionality for
777 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
778 * Once the bind happens and this timer is stopped, the timer functionality
779 * is deregistered with SSI. As there is no further use of timer processing.
781 * @param[in] Inst inst
782 * @param[in] S16 tmrEvnt, the Timer Event
783 * @param[in] PTR cb, Entry for which Timer expired
790 Inst inst, /* Scheduler instance */
791 S16 tmrEvnt, /* Timer Event */
792 PTR cb /* Entry for which Timer Expired */
802 for(i=0;i<RG_MAX_TIMER;i++)
804 /* Search for the Timer Blocks */
805 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
807 /* Initialize the arg structure */
808 memset(&arg, 0, sizeof(CmTmrArg));
810 arg.tqCp = &rgCb[inst].tmrTqCp;
811 arg.tq = rgCb[inst].tmrTq;
812 arg.timers = rgCb[inst].tmrBlk;
814 arg.max = RG_MAX_TIMER;
832 * @brief Timer Expiry handler.
836 * Function : rgLMMTmrExpiry
838 * This is a callback function used as an input parameter to cmPrcTmr()
839 * to check expiry of any timer. In this function, the only concern is
840 * about tmrEvnt=Bind timer.
842 * @param[in] PTR cb, Entry for which Timer expired
843 * @param[in] S16 tmrEvnt, the Timer Event
849 PTR cb, /* Pointer to timer control block */
850 S16 tmrEvnt /* Timer Event */
854 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
855 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
860 tfuSap->numBndRetries++;
861 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
863 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
864 LCM_CAUSE_TMR_EXPIRED, NULLP);
868 /* Restart the bind timer */
869 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
871 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
875 /* Send bind request */
876 //rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
877 //rgCb[inst].tfuSap.sapCfg.spId);
881 DU_LOG("\nERROR --> MAC : Invalid tmrEvnt=%d",tmrEvnt);
891 * @brief Layer Manager Unsolicited Status Indication generation.
895 * Function : rgLMMStaInd
897 * This API is used by the other modules of MAC to send a unsolicited
898 * status indication to the Layer Manager.
900 * @param[in] Inst inst
901 * @param[in] uint16_t category, the Alarm category
902 * @param[in] uint16_t event, the Alarm event
903 * @param[in] uint16_t cause, the cause of the Alarm
904 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
918 if(rgCb[inst].rgInit.usta == FALSE)
923 memset(&usta, 0, sizeof(RgMngmt));
925 SGetDateTime(&usta.t.usta.cmAlarm.dt);
926 usta.t.usta.cmAlarm.category = category;
927 usta.t.usta.cmAlarm.event = event;
928 usta.t.usta.cmAlarm.cause = cause;
931 memcpy(&usta.t.usta.dgn, dgn, sizeof(RgUstaDgn));
934 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
935 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
936 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
937 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
938 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
939 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
941 return (RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
944 /**********************************************************************
947 **********************************************************************/