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 Scheduler as well */
173 schActvInit(ENTMAC, SCH_INST_START, DFLT_REGION, PWR_UP);
175 /* Initialize lower mac */
176 lwrMacLayerInit(region, 0);
183 * @brief Layer Manager Configuration request handler.
187 * Function : RgMiLrgCfgReq
189 * This function handles the configuration
190 * request received from the Layer Manager.
191 * -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
192 * functions rgHdlGenCfg() or rgHdlSapCfg().
193 * -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
195 * @param[in] Pst *pst, the post structure
196 * @param[in] RgMngmt *cfg, the configuration parameter's structure
202 Pst *pst, /* post structure */
203 RgMngmt *cfg /* config structure */
206 uint16_t ret = LCM_PRIM_OK;
207 uint16_t reason = LCM_REASON_NOT_APPL;
214 DU_LOG("\nINFO --> MAC : Received CfgReq for MAC layer, Entity = %d, Instance = %d", pst->srcEnt, pst->srcInst);
216 RG_IS_INST_VALID(pst->dstInst);
217 inst = pst->dstInst - RG_INST_START;
219 /* Fill the post structure for sending the confirmation */
220 rgLMMFillCfmPst(pst, &cfmPst, cfg);
222 memset(&cfm, 0, sizeof(RgMngmt));
225 cfm.hdr.transId = cfg->hdr.transId;
229 cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
230 switch(cfg->hdr.elmId.elmnt)
234 /* Start WLS message receiver thread */
235 LwrMacStartWlsRcvr();
237 reason = rgLMMGenCfg(inst,&cfg->t.cfg);
242 reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
246 reason = LCM_REASON_INVALID_ELMNT;
247 DU_LOG("\nERROR --> MAC : Invalid Elmnt=%d",
248 cfg->hdr.elmId.elmnt);
252 if (reason != LCM_REASON_NOT_APPL)
257 cfm.cfm.status = ret;
258 cfm.cfm.reason = reason;
260 RgMiLrgCfgCfm(&cfmPst, &cfm);
263 }/*-- RgMiLrgCfgReq --*/
267 * @brief Layer Manager Statistics request handler.
271 * Function : RgMiLrgStsReq
273 * This function handles the statistics
274 * request received from the Layer Manager.
275 * -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
276 * statistics from the rgCb global control block.
277 * -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
278 * -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
280 * @param[in] Pst *pst, the post structure
281 * @param[in] RgMngmt *sts, the statistics parameter's structure
287 Pst *pst, /* post structure */
288 RgMngmt *sts /* statistics structure */
295 RG_IS_INST_VALID(pst->dstInst);
296 inst = pst->dstInst - RG_INST_START;
297 /* Fill the post structure for sending the confirmation */
298 rgLMMFillCfmPst(pst, &cfmPst, sts);
300 memset(&cfm, 0, sizeof(RgMngmt));
303 cfm.hdr.transId = sts->hdr.transId;
305 SGetDateTime(&cfm.t.sts.dt);
306 cfm.cfm.status = LCM_PRIM_OK;
307 cfm.cfm.reason = LCM_REASON_NOT_APPL;
308 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
309 cfm.t.sts.action = sts->t.sts.action;
311 /* Check if General Config Done */
312 if(rgCb[inst].rgInit.cfgDone != TRUE)
314 cfm.cfm.status = LCM_PRIM_NOK;
315 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
316 RgMiLrgStsCfm(&cfmPst,&cfm);
317 DU_LOG("\nERROR --> MAC : Gen Cfg not done");
321 switch(sts->hdr.elmId.elmnt)
325 memcpy(&(cfm.t.sts.s.genSts), &rgCb[inst].genSts,
327 /* check if action is read and reset */
328 if(sts->t.sts.action == ARST)
330 rgCb[inst].genSts.numHarqFail = 0;
335 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
337 for(cqi=0; cqi <= 14; cqi++)
339 /* Filling DL ACK/NACK stats */
340 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
341 hqFailStats.dlCqiStat[cqi].mcs;
342 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
343 hqFailStats.dlCqiStat[cqi].numOfNacks;
344 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
345 hqFailStats.dlCqiStat[cqi].numOfAcks;
347 /* Filling UL ACK/NACK stats */
348 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
349 hqFailStats.ulCqiStat[cqi].mcs;
350 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
351 hqFailStats.ulCqiStat[cqi].numOfNacks;
352 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
353 hqFailStats.ulCqiStat[cqi].numOfAcks;
355 /* Filling DL HQ Retx stats */
356 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
357 hqRetxStats.dlCqiStat[cqi].mcs;
358 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
359 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
360 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
361 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
362 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
363 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
364 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
365 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
366 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
367 hqRetxStats.dlCqiStat[cqi].totalTx;
369 /* Filling UL HQ Retx stats */
370 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
371 hqRetxStats.ulCqiStat[cqi].mcs;
372 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
373 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
374 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
375 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
376 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
377 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
378 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
379 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
380 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
381 hqRetxStats.ulCqiStat[cqi].totalTx;
383 /* Reset statistics */
384 if(sts->t.sts.action == ZEROSTS)
386 memset(&hqRetxStats, 0, \
387 sizeof(RgSchHqRetxStats));
388 memset(&hqFailStats, 0, \
389 sizeof(RgSchNackAckStats));
392 #endif /* MAC_SCH_STATS*/
396 memcpy(&(cfm.t.sts.s.rguSts), &rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
399 /* check if action is read and reset */
400 if(sts->t.sts.action == ARST)
401 memset(&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
405 memcpy(&(cfm.t.sts.s.crgSts), &rgCb[inst].crgSap.sapSts,
408 /* check if action is read and reset */
409 if(sts->t.sts.action == ARST)
410 memset(&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
414 memcpy(&(cfm.t.sts.s.tfuSts), &rgCb[inst].tfuSap.sapSts,
417 /* check if action is read and reset */
418 if(sts->t.sts.action == ARST)
419 memset(&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
423 cfm.cfm.status = LCM_PRIM_NOK;
424 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
425 DU_LOG("\nERROR --> MAC : Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
428 RgMiLrgStsCfm(&cfmPst,&cfm);
430 }/*-- RgMiLrgStsReq --*/
434 * @brief SAP Configuration Handler.
438 * Function : rgLMMSapCfg
440 * This function in called by RgMiLrgCfgReq(). It handles the
441 * interface SAP configuration of the LTE MAC layer. It
442 * initializes the sapState to LRG_UNBND. Returns
443 * reason for success/failure of this function.
445 * @param[in] Inst inst
446 * @param[in] RgCfg *cfg, the Configuaration information
448 * -# LCM_REASON_GENCFG_NOT_DONE
449 * -# LCM_REASON_INVALID_SAP
450 * -# LCM_REASON_NOT_APPL
452 static uint16_t rgLMMSapCfg
455 RgCfg *cfg, /* Configuaration information */
456 Elmnt sapType /* Sap Type */
459 uint16_t ret = LCM_REASON_NOT_APPL;
460 RgLowSapCfgInfo *lowSapCfg = NULLP;
461 RgUpSapCfgInfo *upSapCfg = NULLP;
462 RgUpSapCb *upSapCb = NULLP;
465 /* Check if Gen Config has been done */
466 if(rgCb[inst].rgInit.cfgDone != TRUE)
467 return (LCM_REASON_GENCFG_NOT_DONE);
472 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
473 (cfg->s.rguSap.selector != ODU_SELECTOR_TC) &&
474 (cfg->s.rguSap.selector != ODU_SELECTOR_LC))
476 ret = LCM_REASON_INVALID_PAR_VAL;
477 DU_LOG("\nERROR --> MAC : unsupported Selector value for RGU");
480 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
481 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
483 upSapCb->sapSta.sapState = LRG_UNBND;
485 upSapCfg = &(upSapCb->sapCfg);
486 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
487 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
488 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
489 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
490 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
491 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
492 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
493 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
494 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
495 upSapCfg->sapPst.route = cfg->s.rguSap.route;
496 upSapCfg->sapPst.intfVer = 0;
497 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
498 upSapCfg->suId = cfg->s.rguSap.suId;
499 upSapCfg->spId = cfg->s.rguSap.spId;
500 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
501 * there is cfg request with sap is 1*/
504 if ((cfg->s.crgSap.selector != ODU_SELECTOR_TC) &&
505 (cfg->s.crgSap.selector != ODU_SELECTOR_LC))
507 ret = LCM_REASON_INVALID_PAR_VAL;
508 DU_LOG("\nERROR --> MAC : unsupported Selector value for CRG");
511 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
513 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
515 upSapCfg = &rgCb[inst].crgSap.sapCfg;
517 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
518 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
519 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
520 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
521 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
522 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
523 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
524 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
525 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
526 upSapCfg->sapPst.route = cfg->s.crgSap.route;
527 upSapCfg->sapPst.intfVer = 0;
528 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
529 upSapCfg->suId = cfg->s.crgSap.suId;
530 upSapCfg->spId = cfg->s.crgSap.spId;
534 if ((cfg->s.tfuSap.selector != ODU_SELECTOR_TC) &&
535 (cfg->s.tfuSap.selector != ODU_SELECTOR_LC))
537 ret = LCM_REASON_INVALID_PAR_VAL;
538 DU_LOG("\nERROR --> MAC : unsupported Selector value for TFU");
542 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
544 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
546 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
548 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
549 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
550 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
551 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
552 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
553 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
554 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
555 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
556 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
557 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
558 lowSapCfg->sapPst.intfVer = 0;
559 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
560 lowSapCfg->suId = cfg->s.tfuSap.suId;
561 lowSapCfg->spId = cfg->s.tfuSap.spId;
562 memcpy(&lowSapCfg->bndTmr, &cfg->s.tfuSap.bndTmr,
566 /* would never reach here */
574 * @brief General Configuration Handler.
578 * Function : rgLMMGenCfg
580 * This function in called by RgMiLrgCfgReq(). It handles the
581 * general configuration of the LTE MAC layer. It initializes
582 * the hash lists of RgCb. Returns
583 * reason for success/failure of this function.
585 * @param[in] Inst inst
586 * @param[in] RgCfg *cfg, the Configuaration information
588 * -# LCM_REASON_NOT_APPL
589 * -# LCM_REASON_INVALID_MSGTYPE
590 * -# LCM_REASON_MEM_NOAVAIL
592 static uint16_t rgLMMGenCfg
595 RgCfg *cfg /* Configuaration information */
598 uint16_t ret = LCM_REASON_NOT_APPL;
601 /* Check if General Configuration is done already */
602 if (rgCb[inst].rgInit.cfgDone == TRUE)
604 return (LCM_REASON_INVALID_MSGTYPE);
606 if ((cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_TC) &&
607 (cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_LC))
609 DU_LOG("\nERROR --> MAC : unsupported Selector value for RGU");
610 return (LCM_REASON_INVALID_PAR_VAL);
612 /* Update the Pst structure for LM interface */
613 memcpy(&rgCb[inst].rgInit.lmPst, &cfg->s.genCfg.lmPst,
616 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
617 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
618 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
619 rgCb[inst].rgInit.lmPst.event = EVTNONE;
621 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
622 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
623 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
625 macCb.tmrRes = cfg->s.genCfg.tmrRes;
626 macCb.macInst = rgCb[inst].rgInit.inst;
627 macCb.procId = rgCb[inst].rgInit.procId;
629 /* Initialize SAP States */
630 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
632 if(cfg->s.genCfg.numRguSaps == 0)
634 DU_LOG("\nERROR --> MAC : rgGenCfg(): Invalid numRguSap.\n");
638 /* allocate RGR saps */
639 MAC_ALLOC(rgCb[inst].rguSap, sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps);
640 if(rgCb[inst].rguSap == NULLP)
642 DU_LOG("\nERROR --> MAC : rgGenCfg(): Failed to allocate mem for RGU SAP's.\n");
645 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
647 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
649 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
650 memset(&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
652 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
653 /* Initialize the timer blocks */
654 cmInitTimers(macCb.tmrBlk, MAX_NUM_TIMER);
655 /* Initialzie the timer queue */
656 memset(&macCb.tmrTq, 0, sizeof(CmTqType) * MAC_TQ_SIZE);
657 /* Initialize the timer control point */
658 memset(&macCb.tmrTqCp, 0, sizeof(CmTqCp));
659 macCb.tmrTqCp.tmrLen = MAC_TQ_SIZE;
661 /* Timer Registration request to SSI */
662 if(ODU_REG_TMR_MT(ENTMAC, macCb.macInst, macCb.tmrRes, macActvTmr) != ROK)
665 DU_LOG("\nERROR --> MAC : Failed to register timer");
667 MAC_FREE(rgCb[inst].rguSap,
668 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
670 return (LCM_REASON_MEM_NOAVAIL);
673 /* Set Config done in TskInit */
674 rgCb[inst].rgInit.cfgDone = TRUE;
680 /***********************************************************
682 * Func : rgLMMFillCfmPst
685 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
686 * and the cfm->hdr.response.
695 **********************************************************/
696 static Void rgLMMFillCfmPst
704 inst = (reqPst->dstInst - RG_INST_START);
706 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
707 cfmPst->srcInst = rgCb[inst].rgInit.inst;
708 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
709 cfmPst->dstEnt = reqPst->srcEnt;
710 cfmPst->dstInst = reqPst->srcInst;
711 cfmPst->dstProcId = reqPst->srcProcId;
713 cfmPst->selector = cfm->hdr.response.selector;
714 cfmPst->prior = cfm->hdr.response.prior;
715 cfmPst->route = cfm->hdr.response.route;
716 cfmPst->region = cfm->hdr.response.mem.region;
717 cfmPst->pool = cfm->hdr.response.mem.pool;
724 * @brief Timer start handler.
728 * Function : rgLMMStartTmr
730 * This function based on the input parameters starts the timer for
731 * "tmrVal" duration. As of now MAC uses the timer functionality for
732 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
734 * @param[in] Inst inst
735 * @param[in] S16 tmrEvnt, the Timer Event
736 * @param[in] uint32_t tmrVal, the Wait Time
737 * @param[in] PTR cb, Entry for which Timer expired
744 S16 tmrEvnt, /* Timer Event */
745 uint32_t tmrVal, /* Wait Time */
746 PTR cb /* Entry for which Timer Expired */
754 /* Initialize the arg structure */
755 memset(&arg, 0, sizeof(CmTmrArg));
757 arg.tqCp = &rgCb[inst].tmrTqCp;
758 arg.tq = rgCb[inst].tmrTq;
759 arg.timers = rgCb[inst].tmrBlk;
762 arg.max = RG_MAX_TIMER;
763 arg.evnt = RG_BNDREQ_TMR;
772 * @brief Timer stop handler.
776 * Function : rgLMMStopTmr
778 * This function based on the input parameters stops the timer for
779 * "tmrEvnt". As of now MAC uses the timer functionality for
780 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
781 * Once the bind happens and this timer is stopped, the timer functionality
782 * is deregistered with SSI. As there is no further use of timer processing.
784 * @param[in] Inst inst
785 * @param[in] S16 tmrEvnt, the Timer Event
786 * @param[in] PTR cb, Entry for which Timer expired
793 Inst inst, /* Scheduler instance */
794 S16 tmrEvnt, /* Timer Event */
795 PTR cb /* Entry for which Timer Expired */
805 for(i=0;i<RG_MAX_TIMER;i++)
807 /* Search for the Timer Blocks */
808 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
810 /* Initialize the arg structure */
811 memset(&arg, 0, sizeof(CmTmrArg));
813 arg.tqCp = &rgCb[inst].tmrTqCp;
814 arg.tq = rgCb[inst].tmrTq;
815 arg.timers = rgCb[inst].tmrBlk;
817 arg.max = RG_MAX_TIMER;
835 * @brief Timer Expiry handler.
839 * Function : rgLMMTmrExpiry
841 * This is a callback function used as an input parameter to cmPrcTmr()
842 * to check expiry of any timer. In this function, the only concern is
843 * about tmrEvnt=Bind timer.
845 * @param[in] PTR cb, Entry for which Timer expired
846 * @param[in] S16 tmrEvnt, the Timer Event
852 PTR cb, /* Pointer to timer control block */
853 S16 tmrEvnt /* Timer Event */
857 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
858 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
863 tfuSap->numBndRetries++;
864 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
866 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
867 LCM_CAUSE_TMR_EXPIRED, NULLP);
871 /* Restart the bind timer */
872 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
874 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
878 /* Send bind request */
879 //rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
880 //rgCb[inst].tfuSap.sapCfg.spId);
884 DU_LOG("\nERROR --> MAC : Invalid tmrEvnt=%d",tmrEvnt);
894 * @brief Layer Manager Unsolicited Status Indication generation.
898 * Function : rgLMMStaInd
900 * This API is used by the other modules of MAC to send a unsolicited
901 * status indication to the Layer Manager.
903 * @param[in] Inst inst
904 * @param[in] uint16_t category, the Alarm category
905 * @param[in] uint16_t event, the Alarm event
906 * @param[in] uint16_t cause, the cause of the Alarm
907 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
921 if(rgCb[inst].rgInit.usta == FALSE)
926 memset(&usta, 0, sizeof(RgMngmt));
928 SGetDateTime(&usta.t.usta.cmAlarm.dt);
929 usta.t.usta.cmAlarm.category = category;
930 usta.t.usta.cmAlarm.event = event;
931 usta.t.usta.cmAlarm.cause = cause;
934 memcpy(&usta.t.usta.dgn, dgn, sizeof(RgUstaDgn));
937 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
938 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
939 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
940 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
941 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
942 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
944 return (RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
947 /**********************************************************************
950 **********************************************************************/