Merge "Cleanup of message sib1"
[o-du/l2.git] / src / 5gnrmac / rg_lmm.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18
19 /************************************************************************
20  
21      Name:     LTE-MAC layer
22   
23      Type:     C source file
24   
25      Desc:     C source code for Layer Manager Interface Module 
26   
27      File:     rg_lmm.c 
28   
29 **********************************************************************/
30
31 /** @file rg_lmm.c
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.
35 */
36 static const char* RLOG_MODULE_NAME="MAC";
37 static int RLOG_FILE_ID=220;
38 static int RLOG_MODULE_ID=4096;
39
40 /* header include files (.h) */
41 #include "envopt.h"        /* environment options */
42 #include "envdep.h"        /* environment dependent */
43 #include "envind.h"        /* environment independent */
44 #include "gen.h"           /* general */
45 #include "ssi.h"           /* system services */
46 #include "cm_tkns.h"       /* Common Token Defines */
47 #include "cm_llist.h"      /* Common Link List Defines */
48 #include "cm_hash.h"       /* Common Hash List Defines */
49 #include "cm_mblk.h"       /* common memory link list library */
50 #include "cm_lte.h"        /* Common LTE Defines */
51 #include "rg_env.h"        /* MAC Environment Defines */
52 #include "crg.h"           /* CRG Interface defines */
53 #include "rgu.h"           /* RGU Interface defines */
54 #include "tfu.h"           /* RGU Interface defines */
55 #include "rg_sch_inf.h"    /* RGR Interface defines */
56 #include "lrg.h"           /* LRG Interface defines */
57 #include "rgr.h"           /* LRG Interface defines */
58 #include "rg.h"            /* MAC defines */
59 #include "rg_err.h"        /* MAC error defines */
60 #include "du_log.h"
61
62 /* header/extern include files (.x) */
63 #include "gen.x"           /* general */
64 #include "ssi.x"           /* system services */
65 #include "cm5.x"           /* system services */
66 #include "cm_tkns.x"       /* Common Token Definitions */
67 #include "cm_llist.x"      /* Common Link List Definitions */
68 #include "cm_lib.x"        /* Common Library Definitions */
69 #include "cm_hash.x"       /* Common Hash List Definitions */
70 #include "cm_mblk.x"       /* common memory link list library */
71 #include "cm_lte.x"        /* Common LTE Defines */
72 #include "crg.x"           /* CRG Interface includes */
73 #include "rgu.x"           /* RGU Interface includes */
74 #include "tfu.x"           /* RGU Interface includes */
75 #include "rg_sch_inf.x"    /* SCH Interface includes */
76 #include "rg_prg.x"    /* PRG Interface includes */
77 #include "lrg.x"           /* LRG Interface includes */
78 #include "rgr.x"           /* LRG Interface includes */
79 #include "du_app_mac_inf.h"
80 #include "rg.x"            /* MAC includes */
81 #ifdef SS_DIAG
82 #include "ss_diag.h"        /* Common log file */
83 #endif
84 #include "ss_rbuf.h"
85 #include "ss_rbuf.x"
86 #include "lwr_mac.h"         /* MAC CL defines */
87 #include "mac.h"
88 #include "lwr_mac_phy.h"
89 #include "lwr_mac_fsm.h"
90
91 #ifdef __cplusplus
92 extern "C" {
93 #endif /* __cplusplus */
94 EXTERN Void rgGetSId ARGS((SystemId *s));
95 #ifdef __cplusplus
96 }
97 #endif /* __cplusplus */
98
99 /* Public variable declaration */
100 ClCb   clGlobalCp;
101 extern MacCb  macCb;
102
103 int MacSchCellCfgReq(Pst *pst,MacCellCfg *macCellCfg);
104
105 /* forward references */
106 PRIVATE U16 rgLMMGenCfg ARGS((
107    Inst           inst,
108    RgCfg          *cfg           
109 ));
110
111 PRIVATE U16 rgLMMSapCfg ARGS((
112    Inst           inst,
113    RgCfg          *cfg,
114    Elmnt          sapType
115 ));
116
117 PRIVATE Void rgLMMShutdown ARGS((
118    Inst           inst
119 ));
120
121 PRIVATE Void rgLMMFillCfmPst ARGS((
122    Pst           *reqPst,
123    Pst           *cfmPst,
124    RgMngmt       *cfm
125 ));
126
127 PRIVATE Void rgLMMGenCntrl ARGS((
128 RgMngmt       *cntrl,
129 RgMngmt       *cfm,
130 Pst           *cfmPst
131 ));
132
133 PRIVATE Void rgLMMSapCntrl ARGS((
134 RgMngmt       *cntrl,
135 RgMngmt       *cfm,
136 Pst           *cfmPst
137 ));
138
139 extern int packMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm);
140
141 packMacCellCfgConfirm packMacCellCfmOpts[] =
142 {
143    packMacCellCfgCfm,      /* packing for loosely coupled */
144    duHandleMacCellCfgCfm,      /* packing for tightly coupled */
145    packMacCellCfgCfm,    /* packing for light weight loosly coupled */
146 };
147
148 SchCellCfgFunc SchCellCfgOpts[] = 
149 {
150    packSchCellCfg,   /* packing for loosely coupled */
151         SchHdlCellCfgReq, /* packing for tightly coupled */
152    packSchCellCfg    /* packing for light weight loosly coupled */
153 };
154
155 \f
156 /**
157  * @brief Task Initiation callback function. 
158  *
159  * @details
160  *
161  *     Function : rgActvInit
162  *     
163  *     This function is supplied as one of parameters during MAC's 
164  *     task registration. SSI will invoke this function once, after
165  *     it creates and attaches this TAPA Task to a system task.
166  *     
167  *  @param[in]  Ent entity, the entity ID of this task.     
168  *  @param[in]  Inst inst, the instance ID of this task.
169  *  @param[in]  Region region, the region ID registered for memory 
170  *              usage of this task.
171  *  @param[in]  Reason reason.
172  *  @return  S16
173  *      -# ROK
174  **/
175 #ifdef ANSI
176 PUBLIC S16 rgActvInit
177 (
178 Ent entity,            /* entity */
179 Inst inst,             /* instance */
180 Region region,         /* region */
181 Reason reason          /* reason */
182 )
183 #else
184 PUBLIC S16 rgActvInit(entity, inst, region, reason)
185 Ent entity;            /* entity */
186 Inst inst;             /* instance */
187 Region region;         /* region */
188 Reason reason;         /* reason */
189 #endif
190 {
191    Inst macInst ;
192    TRC2(rgActvInit);
193
194    RG_IS_INST_VALID(inst);
195
196    macInst = inst - RG_INST_START;
197    /* Initialize the MAC TskInit structure to zero */
198    cmMemset ((U8 *)&rgCb[macInst], 0, sizeof(RgCb));
199
200    /* Initialize the MAC TskInit with received values */
201    rgCb[macInst].rgInit.ent = entity;
202    rgCb[macInst].rgInit.inst = inst;
203    rgCb[macInst].rgInit.region = region;
204    rgCb[macInst].rgInit.pool = 0;
205    rgCb[macInst].rgInit.reason = reason;
206    rgCb[macInst].rgInit.cfgDone = FALSE;
207    rgCb[macInst].rgInit.acnt = FALSE;
208    rgCb[macInst].rgInit.usta = FALSE;
209    rgCb[macInst].rgInit.trc = FALSE;
210    rgCb[macInst].trcLen = 0; 
211 #ifdef DEBUGP
212 #ifdef RG_DEBUG
213    /* disabling debugs by default */
214     rgCb[macInst].rgInit.dbgMask = 0xffffffff; 
215 #endif
216 #endif /* DEBUGP */
217 #ifdef SS_DIAG
218    rgCb[macInst].rgInit.logMask = 0x0;
219 #endif
220    rgCb[macInst].rgInit.procId = SFndProcId();
221    rgCb[macInst].tfuSap.numBndRetries = 0;
222
223    /* Initialize Sap state */
224    rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
225    rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
226    rgCb[macInst].rguSap = NULLP;
227    rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
228
229    rgCb[macInst].inactiveCell = NULLP;
230    rgCb[macInst].cell         = NULLP;
231 #ifdef SS_RBUF
232    SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
233    SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
234 #endif
235
236    /* Initializing CL control block */
237    clGlobalCp.region = region;
238    clGlobalCp.pool = 0;
239    clGlobalCp.clCfgDone = FALSE;
240    clGlobalCp.numOfCells = 0;
241    clGlobalCp.phyState = PHY_STATE_IDLE; 
242
243    if( cmHashListInit(&clGlobalCp.cellCbLst, MAX_NUM_CELL_SUPP, 0x0, FALSE, 
244                   CM_HASH_KEYTYPE_DEF, clGlobalCp.region, clGlobalCp.pool ) != ROK )
245    {
246       printf("\n Cellcb hash list initialization failed for MAC CL");
247       RETVALUE(RFAILED);
248    }
249
250    /* Initialize Scheduler as well */
251    schActvInit(ENTRG, (DEFAULT_CELLS + SCH_INST_START), DFLT_REGION, PWR_UP);
252
253    /* Initialize lower mac */
254    lwrMacInit();
255
256    RETVALUE(ROK);
257
258 } /* rgActvInit */
259 \f
260 /**
261  * @brief Layer Manager Configuration request handler. 
262  *
263  * @details
264  *
265  *     Function : RgMiLrgCfgReq
266  *     
267  *     This function handles the configuration
268  *     request received from the Layer Manager.
269  *     -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
270  *        functions rgHdlGenCfg() or rgHdlSapCfg().
271  *     -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
272  *     
273  *  @param[in]  Pst *pst, the post structure     
274  *  @param[in]  RgMngmt *cfg, the configuration parameter's structure
275  *  @return  S16
276  *      -# ROK
277  **/
278 #ifdef ANSI
279 PUBLIC S16 RgMiLrgCfgReq
280 (
281 Pst      *pst,    /* post structure  */
282 RgMngmt  *cfg     /* config structure  */
283 )
284 #else
285 PUBLIC S16 RgMiLrgCfgReq(pst, cfg)
286 Pst      *pst;    /* post structure  */
287 RgMngmt  *cfg;    /* config structure  */
288 #endif    
289 {
290    U16       ret = LCM_PRIM_OK;
291    U16       reason = LCM_REASON_NOT_APPL;
292    RgMngmt   cfm;
293    Pst       cfmPst;
294    Inst      inst;
295
296    TRC2(RgMiLrgCfgReq)
297    
298
299    RG_DIAG_LVL0(inst,0x0a0b0001, RG_DIAG_NA, SS_DIAG_INV_ARG,
300               "Received CfgReq for MAC layer, Entity = %d, Instance = %d\n",
301               pst->srcEnt, pst->srcInst,0,0);
302
303    RG_IS_INST_VALID(pst->dstInst);
304    inst = pst->dstInst - RG_INST_START;
305
306    /* Fill the post structure for sending the confirmation */
307    rgLMMFillCfmPst(pst, &cfmPst, cfg);
308
309    cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
310
311 #ifdef LMINT3
312    cfm.hdr.transId = cfg->hdr.transId;
313 #endif
314
315
316    cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
317    switch(cfg->hdr.elmId.elmnt)
318    {
319       case STGEN:
320          reason = rgLMMGenCfg(inst,&cfg->t.cfg); 
321          break;
322       case STRGUSAP:
323       case STCRGSAP:
324       case STTFUSAP:
325          reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
326          break;
327       default:
328          ret = LCM_PRIM_NOK;
329          reason = LCM_REASON_INVALID_ELMNT;
330          RLOG1(L_ERROR, "Invalid Elmnt=%d",
331                   cfg->hdr.elmId.elmnt);
332          break;
333    }
334
335    if (reason != LCM_REASON_NOT_APPL)
336    {
337       ret = LCM_PRIM_NOK;
338    }
339
340    cfm.cfm.status = ret;
341    cfm.cfm.reason = reason;
342
343    RgMiLrgCfgCfm(&cfmPst, &cfm);
344    
345    RETVALUE(ROK);
346 }/*-- RgMiLrgCfgReq --*/
347
348 \f
349 /**
350  * @brief Layer Manager Statistics request handler. 
351  *
352  * @details
353  *
354  *     Function : RgMiLrgStsReq
355  *     
356  *     This function handles the statistics
357  *     request received from the Layer Manager.
358  *      -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
359  *      statistics from the rgCb global control block.
360  *      -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
361  *      -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
362  *     
363  *  @param[in]  Pst *pst, the post structure     
364  *  @param[in]  RgMngmt *sts, the statistics parameter's structure
365  *  @return  S16
366  *      -# ROK
367  **/
368 #ifdef ANSI
369 PUBLIC S16 RgMiLrgStsReq
370 (
371 Pst      *pst,    /* post structure  */
372 RgMngmt  *sts     /* statistics structure  */
373 )
374 #else
375 PUBLIC S16 RgMiLrgStsReq(pst, sts)
376 Pst      *pst;    /* post structure  */
377 RgMngmt  *sts;    /* statistics structure  */
378 #endif    
379 {
380    Pst       cfmPst;
381    RgMngmt   cfm;
382    Inst      inst;
383
384    TRC2(RgMiLrgStsReq)
385    
386
387    RG_IS_INST_VALID(pst->dstInst);
388    inst = pst->dstInst - RG_INST_START;
389    /* Fill the post structure for sending the confirmation */
390    rgLMMFillCfmPst(pst, &cfmPst, sts);
391
392    cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
393
394 #ifdef LMINT3
395    cfm.hdr.transId = sts->hdr.transId;
396 #endif
397    SGetDateTime(&cfm.t.sts.dt);
398    cfm.cfm.status = LCM_PRIM_OK;
399    cfm.cfm.reason = LCM_REASON_NOT_APPL;
400    cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
401    cfm.t.sts.action = sts->t.sts.action;
402
403    /* Check if General Config Done */
404    if(rgCb[inst].rgInit.cfgDone != TRUE) 
405    {
406       cfm.cfm.status = LCM_PRIM_NOK;
407       cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
408       RgMiLrgStsCfm(&cfmPst,&cfm);
409       RLOG0(L_ERROR, "Gen Cfg not done");
410       RETVALUE(ROK);
411    }
412
413    switch(sts->hdr.elmId.elmnt)
414    {
415       case STGEN:
416          {
417             cmMemcpy((U8 *)&(cfm.t.sts.s.genSts), (U8 *)&rgCb[inst].genSts,
418                   sizeof(RgGenSts));
419             /* check if action is read and reset */
420             if(sts->t.sts.action == ARST)
421             {
422                rgCb[inst].genSts.numHarqFail = 0;
423             }
424             /* L2 statistics */
425 #ifdef MAC_SCH_STATS
426             {
427                RgGenSts *genSts = &(cfm.t.sts.s.genSts);
428                U8       cqi = 0;
429                for(cqi=0; cqi <= 14; cqi++)
430                {
431                   /* Filling DL ACK/NACK stats */
432                   genSts->nackAckStats.dlCqiStat[cqi].mcs = \
433                      hqFailStats.dlCqiStat[cqi].mcs;
434                   genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
435                      hqFailStats.dlCqiStat[cqi].numOfNacks;
436                   genSts->nackAckStats.dlCqiStat[cqi].numOfAcks = 
437                      hqFailStats.dlCqiStat[cqi].numOfAcks;
438
439                   /* Filling UL ACK/NACK stats */
440                   genSts->nackAckStats.ulCqiStat[cqi].mcs = \
441                      hqFailStats.ulCqiStat[cqi].mcs;
442                   genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
443                      hqFailStats.ulCqiStat[cqi].numOfNacks;
444                   genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
445                      hqFailStats.ulCqiStat[cqi].numOfAcks;
446
447                   /* Filling DL HQ Retx stats */
448                   genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
449                      hqRetxStats.dlCqiStat[cqi].mcs;
450                   genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
451                      hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
452                   genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
453                      hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
454                   genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
455                      hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
456                   genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
457                      hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
458                   genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
459                      hqRetxStats.dlCqiStat[cqi].totalTx;
460
461                   /* Filling UL HQ Retx stats */
462                   genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
463                      hqRetxStats.ulCqiStat[cqi].mcs;
464                   genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
465                      hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
466                   genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
467                      hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
468                   genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
469                      hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
470                   genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
471                      hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
472                   genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
473                      hqRetxStats.ulCqiStat[cqi].totalTx;
474                }
475                /* Reset statistics */
476                if(sts->t.sts.action == ZEROSTS)
477                {
478                   cmMemset((U8 *)&hqRetxStats, 0, \
479                         sizeof(RgSchHqRetxStats));
480                   cmMemset((U8 *)&hqFailStats, 0, \
481                         sizeof(RgSchNackAckStats));
482                }
483             }
484 #endif /* MAC_SCH_STATS*/
485          }
486          break;
487       case STRGUSAP:
488          cmMemcpy((U8 *)&(cfm.t.sts.s.rguSts), (U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
489                   sizeof(RgSapSts));
490
491          /* check if action is read and reset */
492          if(sts->t.sts.action == ARST)
493             cmMemset((U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
494
495          break;
496       case STCRGSAP:
497          cmMemcpy((U8 *)&(cfm.t.sts.s.crgSts), (U8 *)&rgCb[inst].crgSap.sapSts,
498                   sizeof(RgSapSts));
499
500          /* check if action is read and reset */
501          if(sts->t.sts.action == ARST)
502             cmMemset((U8 *)&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
503
504          break;
505       case STTFUSAP:
506          cmMemcpy((U8 *)&(cfm.t.sts.s.tfuSts), (U8 *)&rgCb[inst].tfuSap.sapSts,
507                   sizeof(RgSapSts));
508
509          /* check if action is read and reset */
510          if(sts->t.sts.action == ARST)
511             cmMemset((U8 *)&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
512
513          break;
514       default:
515          cfm.cfm.status = LCM_PRIM_NOK;
516          cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
517          RLOG1(L_ERROR, "Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
518          break;     
519    }
520    RgMiLrgStsCfm(&cfmPst,&cfm);
521    RETVALUE(ROK);
522 }/*-- RgMiLrgStsReq --*/
523
524 \f
525 /**
526  * @brief Layer Manager Status request handler. 
527  *
528  * @details
529  *
530  *     Function : RgMiLrgStaReq
531  *     
532  *     This function handles the solicited status
533  *     request received from the Layer Manager.
534  *      -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
535  *      particular SAP from the rgCb global control block.
536  *      -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
537  *     
538  *  @param[in]  Pst *pst, the post structure     
539  *  @param[in]  RgMngmt *sta, the status parameter's structure
540  *  @return  S16
541  *      -# ROK
542  **/
543 #ifdef ANSI
544 PUBLIC S16 RgMiLrgStaReq
545 (
546 Pst      *pst,    /* post structure  */
547 RgMngmt  *sta     /* status structure  */
548 )
549 #else
550 PUBLIC S16 RgMiLrgStaReq(pst, sta)
551 Pst      *pst;    /* post structure  */
552 RgMngmt  *sta;    /* status structure  */
553 #endif    
554 {
555    Pst       cfmPst;
556    RgMngmt   cfm;
557    Inst      inst ;
558
559    TRC2(RgMiLrgStaReq)
560    
561
562    RG_IS_INST_VALID(pst->dstInst);
563    inst = pst->dstInst - RG_INST_START;
564
565
566    /* Fill the post structure for sending the confirmation */
567    rgLMMFillCfmPst(pst, &cfmPst, sta);
568
569    if (sta->t.ssta.s.sysId.ptNmb != NULLP)
570    {
571       SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
572    }
573    
574    cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
575    cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
576
577 #ifdef LMINT3
578    cfm.hdr.transId = sta->hdr.transId;
579 #endif
580    /* Check if General Config Done */
581    if(rgCb[inst].rgInit.cfgDone != TRUE) 
582    {
583       SGetDateTime(&cfm.t.ssta.dt);
584       if (SGetSBuf(cfmPst.region, cfmPst.pool, 
585           (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
586          != ROK)
587       {
588          RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
589          RETVALUE(ROK);
590       } 
591       cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
592       rgGetSId(&cfm.t.ssta.s.sysId);
593       cfm.cfm.status = LCM_PRIM_NOK;
594       cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
595       cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
596       RgMiLrgStaCfm(&cfmPst, &cfm);
597       RLOG0(L_ERROR, "Gen Cfg not done");
598       RETVALUE(ROK);
599    }
600
601    switch(sta->hdr.elmId.elmnt)
602    {
603       case STGEN:
604          SGetDateTime(&cfm.t.ssta.dt);
605          if (SGetSBuf(cfmPst.region, cfmPst.pool, 
606              (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
607             != ROK)
608          {
609             RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
610             RETVALUE(ROK);
611          } 
612          cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
613          rgGetSId(&cfm.t.ssta.s.sysId);
614          cfm.cfm.status = LCM_PRIM_OK;
615          cfm.cfm.reason = LCM_REASON_NOT_APPL;
616          RgMiLrgStaCfm(&cfmPst, &cfm);
617          break;
618       case STRGUSAP:
619          cfm.cfm.status = LCM_PRIM_OK;
620          cfm.cfm.reason = LCM_REASON_NOT_APPL;
621          SGetDateTime(&cfm.t.ssta.dt);
622          cmMemcpy((U8 *)&(cfm.t.ssta.s.rguSapSta), 
623                                 (U8 *)&rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
624             sizeof(RgSapSta));
625          RgMiLrgStaCfm(&cfmPst, &cfm);
626          break;
627       case STCRGSAP:
628          cfm.cfm.status = LCM_PRIM_OK;
629          cfm.cfm.reason = LCM_REASON_NOT_APPL;
630          SGetDateTime(&cfm.t.ssta.dt);
631          cmMemcpy((U8 *)&(cfm.t.ssta.s.crgSapSta), (U8 *)&rgCb[inst].crgSap.sapSta,
632          sizeof(RgSapSta));
633          RgMiLrgStaCfm(&cfmPst, &cfm);
634          break;
635       case STTFUSAP:
636          cfm.cfm.status = LCM_PRIM_OK;
637          cfm.cfm.reason = LCM_REASON_NOT_APPL;
638          SGetDateTime(&cfm.t.ssta.dt);
639          cmMemcpy((U8 *)&(cfm.t.ssta.s.tfuSapSta), (U8 *)&rgCb[inst].tfuSap.sapSta,
640          sizeof(RgSapSta));
641          RgMiLrgStaCfm(&cfmPst, &cfm);
642          break;
643       default:
644          cfm.cfm.status = LCM_PRIM_NOK;
645          cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
646          RgMiLrgStaCfm(&cfmPst, &cfm);
647          RLOG1(L_ERROR, "Invalid elmnt=%d",sta->hdr.elmId.elmnt);
648          break;     
649    }
650    RETVALUE(ROK);
651 }/*-- RgMiLrgStaReq --*/
652
653 \f
654 /**
655  * @brief Layer Manager Control request handler. 
656  *
657  * @details
658  *
659  *     Function : RgMiLrgCntrlReq
660  *     
661  *     This function handles the control
662  *     request received from the Layer Manager.
663  *      -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
664  *      and cntrl->t.cntrl.subAction, it performs the appropriate control action
665  *      of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
666  *      and layer shutdown.
667  *      -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
668  *     
669  *  @param[in]  Pst *pst, the post structure     
670  *  @param[in]  RgMngmt *cntrl, the control parameter's structure
671  *  @return  S16
672  *      -# ROK
673  **/
674 #ifdef ANSI
675 PUBLIC S16 RgMiLrgCntrlReq
676 (
677 Pst      *pst,    /* post structure  */
678 RgMngmt  *cntrl   /* control structure  */
679 )
680 #else
681 PUBLIC S16 RgMiLrgCntrlReq(pst, cntrl)
682 Pst      *pst;    /* post structure  */
683 RgMngmt  *cntrl;  /* control structure  */
684 #endif    
685 {
686    S16       ret = ROK;            /* return value */
687    Pst       cfmPst;
688    RgMngmt   cfm;
689    Inst      inst;
690    
691    TRC2(RgMiLrgCntrlReq)
692    
693    /* Fill the post structure for sending the confirmation */
694
695    RG_IS_INST_VALID(pst->dstInst);
696    inst = pst->dstInst - RG_INST_START;
697
698    rgLMMFillCfmPst(pst, &cfmPst, cntrl);
699
700    cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
701 #ifdef LMINT3
702    cfm.hdr.transId = cntrl->hdr.transId;
703 #endif
704    cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
705    cfm.t.cntrl.action = cntrl->t.cntrl.action;
706    cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
707
708    /* Check if General Config Done*/
709    if(rgCb[inst].rgInit.cfgDone != TRUE)
710    {
711       cfm.cfm.status = LCM_PRIM_NOK;
712       cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
713       cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
714       RgMiLrgCntrlCfm(&cfmPst, &cfm);
715       RLOG0(L_ERROR, "Gen Cfg not done");
716       RETVALUE(ROK);
717    }
718  
719    /* General Config done, process the Control request */   
720    switch(cntrl->hdr.elmId.elmnt)
721    {
722       case STGEN:
723          rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
724          break;
725       case STTFUSAP:
726       case STRGUSAP:
727       case STCRGSAP:
728          rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
729          break;
730       default:
731          cfm.cfm.status = LCM_PRIM_NOK;
732          cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
733          RgMiLrgCntrlCfm(&cfmPst, &cfm);
734          RLOG1(L_ERROR, "invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
735          break;
736    }
737    RETVALUE(ret);
738 }/*-- RgMiLrgCntrlReq --*/
739
740 \f
741 /**
742  * @brief SAP Configuration Handler. 
743  *
744  * @details
745  *
746  *     Function : rgLMMSapCfg
747  *     
748  *     This function in called by RgMiLrgCfgReq(). It handles the
749  *     interface SAP configuration of the LTE MAC layer. It 
750  *     initializes the sapState to LRG_UNBND. Returns
751  *     reason for success/failure of this function.
752  *     
753  *  @param[in]  Inst        inst
754  *  @param[in]  RgCfg *cfg, the Configuaration information 
755  *  @return  U16
756  *      -# LCM_REASON_GENCFG_NOT_DONE
757  *      -# LCM_REASON_INVALID_SAP
758  *      -# LCM_REASON_NOT_APPL
759  **/
760 #ifdef ANSI
761 PRIVATE U16 rgLMMSapCfg
762 (
763 Inst  inst,
764 RgCfg *cfg,            /* Configuaration information */
765 Elmnt sapType             /* Sap Type */
766 )
767 #else
768 PRIVATE U16 rgLMMSapCfg(inst,cfg,sapType)
769 Inst  inst;
770 RgCfg *cfg;            /* Configuaration information */
771 Elmnt sapType;            /* Sap Type */
772 #endif
773 {
774    U16               ret = LCM_REASON_NOT_APPL;
775    RgLowSapCfgInfo   *lowSapCfg = NULLP;
776    RgUpSapCfgInfo    *upSapCfg = NULLP;
777    RgUpSapCb          *upSapCb  = NULLP;
778
779    TRC2(rgLMMSapCfg)
780
781    /* Check if Gen Config has been done */
782    if(rgCb[inst].rgInit.cfgDone != TRUE)
783       RETVALUE(LCM_REASON_GENCFG_NOT_DONE);
784
785    switch(sapType)
786    {   
787       case STRGUSAP:
788          if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
789              (cfg->s.rguSap.selector != RGU_SEL_TC) &&
790              (cfg->s.rguSap.selector != RGU_SEL_LC))
791          {
792             ret = LCM_REASON_INVALID_PAR_VAL;
793             RLOG0(L_ERROR, "unsupported Selector value for RGU");
794             break;
795          }
796          upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
797          if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
798          { 
799             upSapCb->sapSta.sapState = LRG_UNBND;
800          }
801          upSapCfg = &(upSapCb->sapCfg);
802          upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
803          upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
804          upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
805          upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
806          upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
807          upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
808          upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
809          upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
810          upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
811          upSapCfg->sapPst.route = cfg->s.rguSap.route;
812          upSapCfg->sapPst.intfVer = 0; 
813          upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
814          upSapCfg->suId = cfg->s.rguSap.suId;
815          upSapCfg->spId = cfg->s.rguSap.spId;
816          /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
817           * there is cfg request with sap is 1*/
818          break;
819       case STCRGSAP:
820          if ((cfg->s.crgSap.selector != CRG_SEL_TC) &&
821              (cfg->s.crgSap.selector != CRG_SEL_LC))
822          {
823             ret = LCM_REASON_INVALID_PAR_VAL;
824             RLOG0(L_ERROR, "unsupported Selector value for CRG");
825             break;
826          }
827          if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
828          { 
829             rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
830          }
831          upSapCfg = &rgCb[inst].crgSap.sapCfg;
832
833          upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
834          upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
835          upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
836          upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
837          upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
838          upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
839          upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
840          upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
841          upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
842          upSapCfg->sapPst.route = cfg->s.crgSap.route;
843          upSapCfg->sapPst.intfVer = 0; 
844          upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
845          upSapCfg->suId = cfg->s.crgSap.suId;
846          upSapCfg->spId = cfg->s.crgSap.spId;
847          break;
848       case STTFUSAP:
849 #ifndef CL_MAC_LWLC 
850          if ((cfg->s.tfuSap.selector != TFU_SEL_TC) &&
851              (cfg->s.tfuSap.selector != TFU_SEL_LC))
852          {
853             ret = LCM_REASON_INVALID_PAR_VAL;
854             RLOG0(L_ERROR, "unsupported Selector value for TFU");
855             break;
856          }
857 #endif
858          if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) 
859          { 
860             rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
861          }
862          lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
863
864          lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
865          lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
866          lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
867          lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
868          lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
869          lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
870          lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
871          lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
872          lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
873          lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
874          lowSapCfg->sapPst.intfVer = 0; 
875          lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
876          lowSapCfg->suId = cfg->s.tfuSap.suId;
877          lowSapCfg->spId = cfg->s.tfuSap.spId;
878          cmMemcpy((U8 *)&lowSapCfg->bndTmr, (U8 *)&cfg->s.tfuSap.bndTmr,
879                    sizeof(TmrCfg));
880          break;
881       default:
882          /* would never reach here */
883          break;
884    }
885    RETVALUE(ret);
886 }
887
888 \f
889 /**
890  * @brief General Configuration Handler. 
891  *
892  * @details
893  *
894  *     Function : rgLMMGenCfg
895  *     
896  *     This function in called by RgMiLrgCfgReq(). It handles the
897  *     general configuration of the LTE MAC layer. It initializes 
898  *     the hash lists of RgCb. Returns
899  *     reason for success/failure of this function.
900  *     
901  *  @param[in]  Inst        inst
902  *  @param[in]  RgCfg *cfg, the Configuaration information 
903  *  @return  U16
904  *      -# LCM_REASON_NOT_APPL 
905  *      -# LCM_REASON_INVALID_MSGTYPE
906  *      -# LCM_REASON_MEM_NOAVAIL
907  **/
908 #ifdef ANSI
909 PRIVATE U16 rgLMMGenCfg
910 (
911 Inst inst,
912 RgCfg *cfg            /* Configuaration information */
913 )
914 #else
915 PRIVATE U16 rgLMMGenCfg(inst,cfg)
916 Inst inst;
917 RgCfg *cfg;            /* Configuaration information */
918 #endif
919 {
920    U16    ret = LCM_REASON_NOT_APPL;
921
922    TRC2(rgLMMGenCfg)
923
924    /* Check if General Configuration is done already */
925    if (rgCb[inst].rgInit.cfgDone == TRUE)
926    {
927       RETVALUE(LCM_REASON_INVALID_MSGTYPE);
928    }
929    if ((cfg->s.genCfg.lmPst.selector != LRG_SEL_TC) &&
930        (cfg->s.genCfg.lmPst.selector != LRG_SEL_LC))
931    {
932       RLOG0(L_ERROR, "unsupported Selector value for RGU");
933       RETVALUE(LCM_REASON_INVALID_PAR_VAL);
934    }
935    /* Update the Pst structure for LM interface */
936    cmMemcpy((U8 *)&rgCb[inst].rgInit.lmPst, (U8 *)&cfg->s.genCfg.lmPst,
937              sizeof(Pst));
938
939    rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
940    rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
941    rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
942    rgCb[inst].rgInit.lmPst.event = EVTNONE;
943
944    rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
945    rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
946    rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
947
948    macCb.macInst = rgCb[inst].rgInit.inst;
949
950    /* Initialize SAP States */
951    rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
952
953    if(cfg->s.genCfg.numRguSaps == 0)
954    {
955       RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Invalid numRguSap.\n"));
956       RETVALUE(RFAILED);
957    }
958
959    /* allocate RGR saps */
960    if (SGetSBuf(rgCb[inst].rgInit.region,
961                 rgCb[inst].rgInit.pool,
962                 (Data **)&rgCb[inst].rguSap,
963                 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
964    {
965       RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Failed to allocate mem for RGU SAP's.\n"));
966       RETVALUE(RFAILED);
967    }
968    rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
969
970    for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
971    {
972       rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
973       cmMemset((U8 *)&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
974    }
975    rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
976    /* Initialize the timer blocks */
977    cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
978    /* Initialzie the timer queue */   
979    cmMemset((U8 *)&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
980    /* Initialize the timer control point */
981    cmMemset((U8 *)&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
982    rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
983 #if 0
984    /* Timer Registration request to SSI */
985    if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
986             (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
987    {
988       
989       RLOG0(L_ERROR, "Failed to register timer");
990
991       SPutSBuf(rgCb[inst].rgInit.region,
992                 rgCb[inst].rgInit.pool,
993                 (Data *)rgCb[inst].rguSap,
994                 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
995
996       RETVALUE(LCM_REASON_MEM_NOAVAIL);
997    }
998 #endif
999    /* Set Config done in TskInit */
1000    rgCb[inst].rgInit.cfgDone = TRUE;
1001
1002    RETVALUE(ret);
1003 }
1004
1005 \f
1006 /***********************************************************
1007  *
1008  *     Func : rgLMMShutdown
1009  *        
1010  *
1011  *     Desc : Handles the MAC layer shutdown request. Calls 
1012  *     rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
1013  *            
1014  *
1015  *     Ret  : Void
1016  *
1017  *     Notes: 
1018  *
1019  *     File : rg_lmm.c 
1020  *
1021  **********************************************************/
1022 #ifdef ANSI
1023 PRIVATE Void rgLMMShutdown
1024 (
1025 Inst inst
1026 )
1027 #else
1028 PRIVATE Void rgLMMShutdown(inst)
1029 Inst inst;
1030 #endif
1031 {
1032    RgCellCb   *cell = rgCb[inst].cell;
1033    U8 idx;
1034
1035    TRC2(rgLMMShutdown)
1036
1037    /* Unbind the TFU Sap */
1038    if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
1039    {
1040       rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1041       if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1042       {
1043          rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap); 
1044       }
1045       rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1046    }
1047    if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
1048    {
1049       rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1050       rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1051    }
1052
1053
1054    if(cell != NULLP)
1055    {
1056       for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1057       {
1058          rgTOMRlsSf(inst,&cell->subFrms[idx]);
1059       }
1060
1061       rgCFGFreeCellCb(cell);
1062    }
1063
1064    /* Deleting the RGU SAPs */
1065    SPutSBuf(rgCb[inst].rgInit.region,
1066                 rgCb[inst].rgInit.pool,
1067                 (Data *)rgCb[inst].rguSap,
1068                 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
1069    rgCb[inst].rguSap = NULLP;
1070
1071    rgCb[inst].inactiveCell = NULLP;
1072    rgCb[inst].cell         = NULLP;
1073
1074    /* De-register the Timer Service */
1075    (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
1076                      (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr); 
1077
1078    /* call back the task initialization function to intialize
1079     * the global RgCb Struct */
1080    rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region, 
1081               rgCb[inst].rgInit.reason);
1082
1083    RETVOID;
1084 }
1085
1086 \f
1087 /***********************************************************
1088  *
1089  *     Func : rgLMMGenCntrl 
1090  *        
1091  *
1092  *     Desc : Processes the LM control request for STGEN elmnt.
1093  *            
1094  *
1095  *     Ret  : Void
1096  *
1097  *     Notes: 
1098  *
1099  *     File : rg_lmm.c 
1100  *
1101  **********************************************************/
1102 #ifdef ANSI
1103 PRIVATE Void rgLMMGenCntrl 
1104 (
1105 RgMngmt       *cntrl,
1106 RgMngmt       *cfm,
1107 Pst           *cfmPst
1108 )
1109 #else
1110 PRIVATE Void rgLMMGenCntrl(cntrl, cfm, cfmPst)
1111 RgMngmt       *cntrl;
1112 RgMngmt       *cfm;
1113 Pst           *cfmPst;
1114 #endif
1115 {
1116    Inst      inst = (cfmPst->srcInst - RG_INST_START);
1117    TRC2(rgLMMGenCntrl)
1118
1119    cfm->cfm.status = LCM_PRIM_OK;
1120    cfm->cfm.reason = LCM_REASON_NOT_APPL;
1121    
1122
1123    switch(cntrl->t.cntrl.action)
1124    {
1125       case AENA:
1126          /* Action is Enable */
1127          switch(cntrl->t.cntrl.subAction)
1128          {
1129             case SATRC:
1130             /* Enable Traces */
1131                rgCb[inst].rgInit.trc = TRUE;
1132                rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1133                /*Store the response and TransId for sending the Traces */
1134                cmMemcpy((U8 *)&rgCb[inst].genCfg.trcResp.response, 
1135                (U8 *)&cntrl->hdr.response, sizeof(Resp));
1136                rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1137                
1138                break;
1139             case SAUSTA:   
1140             /* Enable Unsolicited Status (alarms) */
1141                rgCb[inst].rgInit.usta = TRUE;
1142                /*Store the response and TransId for sending the Alarms */
1143                cmMemcpy((U8 *)&rgCb[inst].genCfg.ustaResp.response, 
1144                (U8 *)&cntrl->hdr.response, sizeof(Resp));
1145                rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1146                break;
1147             case SADBG:
1148             /* Enable Debug Printing */
1149 #ifdef DEBUGP
1150                rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1151 #endif
1152                break;
1153 #ifdef SS_DIAG
1154             case SALOG:
1155                rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1156                break;
1157 #endif
1158
1159             default:
1160                cfm->cfm.status = LCM_PRIM_NOK;
1161                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1162                RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1163                break;
1164          }
1165          break;
1166       case ADISIMM:
1167          /* Action is Diable immidiately */
1168          switch(cntrl->t.cntrl.subAction)
1169          {
1170             case SATRC:
1171             /* Disable Traces */
1172                rgCb[inst].rgInit.trc = FALSE;
1173                break;
1174             case SAUSTA:
1175             /* Disable Unsolicited Status (alarms) */
1176                rgCb[inst].rgInit.usta = FALSE;
1177                break;
1178             case SADBG:
1179             /* Disable Debug Printing */
1180 #ifdef DEBUGP
1181                rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1182 #endif
1183                break;
1184 #ifdef SS_DIAG
1185             case SALOG:
1186                rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1187                 break;
1188 #endif
1189
1190             default:
1191                cfm->cfm.status = LCM_PRIM_NOK;
1192                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1193                RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1194                break;
1195          }
1196          break;
1197       case ASHUTDOWN:
1198          /* Free all the memory dynamically allocated by MAC */
1199          rgLMMShutdown(inst);
1200          break;
1201       default:
1202          cfm->cfm.status = LCM_PRIM_NOK;
1203          cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1204          RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1205          break;
1206    }
1207    RgMiLrgCntrlCfm(cfmPst, cfm);
1208    RETVOID;
1209 }
1210
1211 \f
1212 /***********************************************************
1213  *
1214  *     Func : rgLMMSapCntrl 
1215  *        
1216  *
1217  *     Desc : Processes the LM control request for STxxxSAP elmnt.
1218  *            
1219  *
1220  *     Ret  : Void
1221  *
1222  *     Notes: 
1223  *
1224  *     File : rg_lmm.c 
1225  *
1226  **********************************************************/
1227 #ifdef ANSI
1228 PRIVATE Void rgLMMSapCntrl 
1229 (
1230 RgMngmt       *cntrl,
1231 RgMngmt       *cfm,
1232 Pst           *cfmPst
1233 )
1234 #else
1235 PRIVATE Void rgLMMSapCntrl(cntrl, cfm, cfmPst)
1236 RgMngmt       *cntrl;
1237 RgMngmt       *cfm;
1238 Pst           *cfmPst;
1239 #endif
1240 {
1241    Inst      inst = cfmPst->srcInst - RG_INST_START;
1242    TRC2(rgLMMSapCntrl)
1243
1244    /* Only TFU Sap can be controlled by LM */
1245    switch(cntrl->hdr.elmId.elmnt)
1246    {
1247       case STTFUSAP:
1248          switch(cntrl->t.cntrl.action)
1249          {
1250             case ABND:
1251             /* Bind Enable Request */
1252                if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1253                    (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1254                {
1255                   cfm->cfm.status = LCM_PRIM_NOK;
1256                   cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1257                }
1258                else
1259                {
1260                   if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1261                   {
1262                      rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val, 
1263                      (PTR)&rgCb[inst].tfuSap);
1264                   }
1265                   /* Change SAP state */
1266                   rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1267                   rgCb[inst].tfuSap.numBndRetries++;
1268                   /* Store the response and TransId for sending 
1269                    * the Control confirm */
1270                   cmMemcpy((U8 *)&rgCb[inst].genCfg.bndCfmResp.response,
1271                            (U8 *)&cntrl->hdr.response, sizeof(Resp));
1272                   rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1273
1274                   /* Sending Status Indication to Layer Manager */
1275                   cfm->cfm.status = LCM_PRIM_OK_NDONE;
1276                   cfm->cfm.reason = LCM_REASON_NOT_APPL;
1277                   RgMiLrgCntrlCfm(cfmPst, cfm);
1278
1279                   rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1280                                       rgCb[inst].tfuSap.sapCfg.spId);
1281                   RETVOID;
1282                }
1283                break;
1284             case AUBND:
1285             /* Unbind request */
1286
1287                /* Check if the SAP is configured */
1288                if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1289                      (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1290                {
1291                   cfm->cfm.status = LCM_PRIM_NOK;
1292                   cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1293                }
1294                else
1295                {
1296                   rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1297                   if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1298                   {
1299                      rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1300                   }
1301                   /* Change SAP state */
1302                   rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1303                   cfm->cfm.status = LCM_PRIM_OK;
1304                   cfm->cfm.reason = LCM_REASON_NOT_APPL;
1305                }
1306                break;
1307             case ADEL:
1308                /* Delete SAP, does initialization of SAP */
1309                if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1310                    (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1311                {
1312                   rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1313                   if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1314                   {
1315                      rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1316                   }
1317                }
1318                cmMemset((U8 *)&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1319                rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1320                cfm->cfm.status = LCM_PRIM_OK;
1321                cfm->cfm.reason = LCM_REASON_NOT_APPL;
1322                break;
1323             default:
1324                cfm->cfm.status = LCM_PRIM_NOK;
1325                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1326                RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1327                cntrl->t.cntrl.action));
1328                break;
1329          }
1330          break;
1331       case STRGUSAP:
1332          switch(cntrl->t.cntrl.action)
1333          {
1334             case ADEL:
1335                cmMemset((U8 *)&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1336                rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1337                cfm->cfm.status = LCM_PRIM_OK;
1338                cfm->cfm.reason = LCM_REASON_NOT_APPL;
1339                break;
1340             default:
1341                cfm->cfm.status = LCM_PRIM_NOK;
1342                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1343                RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1344                cntrl->t.cntrl.action));
1345                break;
1346          }
1347          break;
1348       case STCRGSAP:
1349          switch(cntrl->t.cntrl.action)
1350          {
1351             case ADEL:
1352                cmMemset((U8 *)&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1353                rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1354                cfm->cfm.status = LCM_PRIM_OK;
1355                cfm->cfm.reason = LCM_REASON_NOT_APPL;
1356                break;
1357             default:
1358                cfm->cfm.status = LCM_PRIM_NOK;
1359                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1360                RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1361                
1362                break;
1363          }
1364          break;
1365       default:
1366          /* Would never here. */
1367          RETVOID;
1368    }
1369    RgMiLrgCntrlCfm(cfmPst, cfm);
1370    RETVOID;
1371 }
1372
1373 \f
1374 /***********************************************************
1375  *
1376  *     Func : rgLMMFillCfmPst 
1377  *        
1378  *
1379  *     Desc : Fills the Confirmation Post Structure cfmPst using the reqPst 
1380  *            and the cfm->hdr.response.
1381  *            
1382  *
1383  *     Ret  : Void
1384  *
1385  *     Notes: 
1386  *
1387  *     File : rg_lmm.c 
1388  *
1389  **********************************************************/
1390 #ifdef ANSI
1391 PRIVATE Void rgLMMFillCfmPst
1392 (
1393 Pst           *reqPst,
1394 Pst           *cfmPst,
1395 RgMngmt       *cfm
1396 )
1397 #else
1398 PRIVATE Void rgLMMFillCfmPst(reqPst, cfmPst, cfm)
1399 Pst           *reqPst;
1400 Pst           *cfmPst;
1401 RgMngmt       *cfm;
1402 #endif
1403 {
1404    Inst inst;
1405    TRC2(rgLMMFillCfmPst)
1406    inst = (reqPst->dstInst - RG_INST_START);
1407
1408    cfmPst->srcEnt    = rgCb[inst].rgInit.ent;
1409    cfmPst->srcInst   = rgCb[inst].rgInit.inst;
1410    cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1411    cfmPst->dstEnt    = reqPst->srcEnt;
1412    cfmPst->dstInst   = reqPst->srcInst;
1413    cfmPst->dstProcId = reqPst->srcProcId;
1414
1415    cfmPst->selector  = cfm->hdr.response.selector;
1416    cfmPst->prior     = cfm->hdr.response.prior;
1417    cfmPst->route     = cfm->hdr.response.route;
1418    cfmPst->region    = cfm->hdr.response.mem.region;
1419    cfmPst->pool      = cfm->hdr.response.mem.pool;
1420
1421    RETVOID;
1422 }
1423
1424 \f
1425 /**
1426  * @brief Timer start handler. 
1427  *
1428  * @details
1429  *
1430  *     Function : rgLMMStartTmr
1431  *     
1432  *     This function based on the input parameters starts the timer for 
1433  *     "tmrVal" duration. As of now MAC uses the timer functionality for 
1434  *     BndReq only. Hence there is no conditional code based on "tmrEvnt".
1435  *     
1436  *  @param[in]  Inst        inst
1437  *  @param[in]  S16   tmrEvnt, the Timer Event    
1438  *  @param[in]  U32   tmrVal,  the Wait Time
1439  *  @param[in]  PTR   cb,  Entry for which Timer expired
1440  *  @return  S16
1441  *      -# ROK
1442  **/
1443 #ifdef ANSI
1444 PUBLIC S16 rgLMMStartTmr
1445 (
1446 Inst               inst,
1447 S16                tmrEvnt,            /* Timer Event */
1448 U32                tmrVal,             /* Wait Time */
1449 PTR                cb                  /* Entry for which Timer Expired */
1450 )
1451 #else
1452 PUBLIC S16 rgLMMStartTmr(tmrEvnt, tmrVal, cb)
1453 Inst               inst;
1454 S16                tmrEvnt;            /* Timer Event */
1455 U32                tmrVal;             /* Wait Time */
1456 PTR                cb;                 /* Entry for which Timer Expired */
1457 #endif
1458 {
1459    CmTmrArg    arg;
1460
1461    TRC2(rgLMMStartTmr)
1462
1463    UNUSED(tmrEvnt);
1464
1465    /* Initialize the arg structure */
1466    cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1467
1468    arg.tqCp = &rgCb[inst].tmrTqCp;
1469    arg.tq = rgCb[inst].tmrTq;
1470    arg.timers = rgCb[inst].tmrBlk;
1471    arg.cb = cb;
1472    arg.tNum = 0;
1473    arg.max = RG_MAX_TIMER;
1474    arg.evnt = RG_BNDREQ_TMR;
1475    arg.wait = tmrVal;      
1476    cmPlcCbTq(&arg);
1477
1478    RETVALUE(ROK);
1479 }
1480
1481 \f
1482 /**
1483  * @brief Timer stop handler. 
1484  *
1485  * @details
1486  *
1487  *     Function : rgLMMStopTmr
1488  *     
1489  *     This function based on the input parameters stops the timer for 
1490  *     "tmrEvnt". As of now MAC uses the timer functionality for 
1491  *     BndReq only. Hence there is no conditional code based on "tmrEvnt".
1492  *     Once the bind happens and this timer is stopped, the timer functionality
1493  *     is deregistered with SSI. As there is no further use of timer processing.
1494  *     
1495  *  @param[in]  Inst        inst
1496  *  @param[in]  S16   tmrEvnt, the Timer Event    
1497  *  @param[in]  PTR   cb,  Entry for which Timer expired
1498  *  @return  S16
1499  *      -# ROK
1500  *      -# RFAILED
1501  **/
1502 #ifdef ANSI
1503 PUBLIC S16 rgLMMStopTmr
1504 (
1505 Inst               inst,             /* Scheduler instance */
1506 S16                tmrEvnt,            /* Timer Event */
1507 PTR                cb                  /* Entry for which Timer Expired */
1508 )
1509 #else
1510 PUBLIC S16 rgLMMStopTmr(inst,tmrEvnt, cb)
1511 Inst               inst;             /* Scheduler instance */
1512 S16                tmrEvnt;            /* Timer Event */
1513 PTR                cb;                 /* Entry for which Timer Expired */
1514 #endif
1515 {
1516    CmTmrArg   arg;
1517    U8         i;
1518    S16        ret; 
1519
1520    TRC2(rgLMMStopTmr)
1521
1522    ret = RFAILED;
1523
1524    for(i=0;i<RG_MAX_TIMER;i++)
1525    {
1526       /* Search for the Timer Blocks */
1527       if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1528       {
1529          /* Initialize the arg structure */
1530          cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1531
1532          arg.tqCp = &rgCb[inst].tmrTqCp;
1533          arg.tq = rgCb[inst].tmrTq;
1534          arg.timers = rgCb[inst].tmrBlk;
1535          arg.cb = cb;
1536          arg.max = RG_MAX_TIMER;
1537          arg.evnt = NOTUSED;
1538          arg.wait = NOTUSED;
1539
1540          arg.tNum = i;   
1541          cmRmvCbTq(&arg);
1542          ret = ROK;
1543          break;
1544       }
1545
1546    }
1547
1548
1549    RETVALUE(ret);
1550 }
1551
1552 \f
1553 /**
1554  * @brief Timer Expiry handler. 
1555  *
1556  * @details
1557  *
1558  *     Function : rgLMMTmrExpiry
1559  *     
1560  *     This is a callback function used as an input parameter to cmPrcTmr()
1561  *     to check expiry of any timer. In this function, the only concern is
1562  *     about tmrEvnt=Bind timer.
1563  *     
1564  *  @param[in]  PTR   cb,  Entry for which Timer expired
1565  *  @param[in]  S16   tmrEvnt, the Timer Event    
1566  *  @return  S16
1567  *      -# ROK
1568  **/
1569 #ifdef ANSI
1570 PUBLIC S16 rgLMMTmrExpiry
1571 (
1572 PTR cb,               /* Pointer to timer control block */
1573 S16 tmrEvnt           /* Timer Event */
1574 )
1575 #else
1576 PUBLIC S16 rgLMMTmrExpiry(cb,tmrEvnt)
1577 PTR cb;               /* Pointer to timer control block */
1578 S16 tmrEvnt;          /* Timer Event */
1579 #endif
1580 {
1581    S16        ret = ROK;
1582    RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1583    Inst          inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1584
1585    TRC2(rgLMMTmrExpiry)
1586
1587    
1588    switch(tmrEvnt)
1589    {
1590       case RG_BNDREQ_TMR:
1591          tfuSap->numBndRetries++;
1592          if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1593          {
1594             rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1595                         LCM_CAUSE_TMR_EXPIRED, NULLP);
1596          }
1597          else
1598          {
1599             /* Restart the bind timer */
1600             if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1601             {
1602                ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1603                cb);
1604             }
1605
1606             /* Send bind request */
1607             rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1608                                 rgCb[inst].tfuSap.sapCfg.spId);
1609          }
1610          break;
1611       default:
1612          RLOG1(L_ERROR, "Invalid tmrEvnt=%d",tmrEvnt);
1613          ret = RFAILED;
1614          break;
1615    }
1616    RETVALUE(ret);
1617 }
1618
1619
1620 \f
1621 /**
1622  * @brief Layer Manager Unsolicited Status Indication generation. 
1623  *
1624  * @details
1625  *
1626  *     Function : rgLMMStaInd 
1627  *     
1628  *     This API is used by the other modules of MAC to send a unsolicited
1629  *     status indication to the Layer Manager.
1630  *     
1631  *  @param[in]  Inst        inst
1632  *  @param[in]  U16 category, the Alarm category
1633  *  @param[in]  U16 event, the Alarm event
1634  *  @param[in]  U16 cause, the cause of the Alarm
1635  *  @param[in]  RgUstaDgn *dgn, Alarm Diagonostics
1636  *  @return  S16
1637  *      -# ROK
1638  **/
1639 #ifdef ANSI
1640 PUBLIC S16 rgLMMStaInd
1641 (
1642 Inst inst,
1643 U16 category,
1644 U16 event,
1645 U16 cause,
1646 RgUstaDgn *dgn
1647 )
1648 #else
1649 PUBLIC S16 rgLMMStaInd(inst,category, event, cause, dgn) 
1650 Inst inst;
1651 U16 category;
1652 U16 event;
1653 U16 cause;
1654 RgUstaDgn *dgn;
1655 #endif
1656 {
1657    RgMngmt    usta;
1658
1659    TRC2(rgLMMStaInd)
1660
1661    if(rgCb[inst].rgInit.usta == FALSE)
1662    {
1663       RETVALUE(ROK);
1664    }
1665
1666    cmMemset((U8 *)&usta, 0, sizeof(RgMngmt));
1667
1668    SGetDateTime(&usta.t.usta.cmAlarm.dt);
1669    usta.t.usta.cmAlarm.category = category;
1670    usta.t.usta.cmAlarm.event = event;
1671    usta.t.usta.cmAlarm.cause = cause;
1672    if (dgn != NULLP)
1673    {
1674       cmMemcpy((U8 *)&usta.t.usta.dgn, (U8 *)dgn, sizeof(RgUstaDgn));
1675    }
1676
1677    rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1678    rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1679    rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1680    rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1681    rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1682    usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1683
1684    RETVALUE(RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1685 }
1686
1687 \f
1688 /**
1689  * @brief Layer Manager Trace Indication generation. 
1690  *
1691  * @details
1692  *
1693  *     Function : rgLMMTrcInd 
1694  *     
1695  *     This API is used by the other modules of MAC to send a 
1696  *     Trace indication to the Layer Manager.
1697  *     
1698  *  @param[in]  Inst        inst
1699  *  @param[in]   Buffer *srcMbuf, the Message Buffer .
1700  *  @param[in]   U8 event, the trace event.
1701  *  @return Void 
1702  **/
1703 #ifdef ANSI
1704 PUBLIC Void rgLMMTrcInd
1705 (
1706 Inst   inst,
1707 Buffer *srcMbuf,    /* Message Buffer */
1708 U8 event            /* event */
1709 )
1710 #else
1711 PUBLIC Void rgLMMTrcInd(inst,srcMbuf,event)
1712 Inst   inst;
1713 Buffer *srcMbuf;    /* Message Buffer */
1714 U8 event;           /* event */
1715 #endif
1716 {
1717    Buffer   *dstMbuf = NULLP;   
1718    MsgLen   bufLen  = 0;
1719    Data     *tempBuf;
1720    MsgLen   tempCnt;
1721    RgMngmt  trc;
1722    Pst      pst;
1723
1724    TRC2(rgLMMTrcInd)
1725
1726
1727    if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1728    {
1729       RLOG0(L_ERROR, "Trace Disabled.");
1730       RETVOID;
1731    }
1732    
1733    cmMemset((U8 *)&trc, 0, sizeof(RgMngmt));
1734
1735    pst = rgCb[inst].rgInit.lmPst;
1736    pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1737    pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1738    pst.route = rgCb[inst].genCfg.trcResp.response.route;
1739    pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1740    pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1741
1742    trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1743
1744    SGetDateTime(&trc.t.trc.dt);
1745       
1746    /* Check if the whole buffer is to be sent in Trace indication */
1747    if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1748    {
1749       if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1750          != ROK)
1751       {
1752          RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1753          RETVOID;
1754       }
1755       trc.cfm.status = LCM_PRIM_OK;
1756       trc.cfm.reason = LCM_REASON_NOT_APPL;
1757       trc.t.trc.evnt = event;
1758          
1759       /* Send Trace Indication to Layer manager */
1760       RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1761    }
1762    /* check if only a specified number of bytes are to be sent */
1763    else if(rgCb[inst].trcLen > 0)
1764    {
1765       /* Get the length of the recvd message buffer */
1766       if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1767       {
1768          RLOG0(L_ERROR, "SFndLenMsg Failed.");
1769          RETVOID;
1770       }
1771       /* Check if the recvd buffer size is less than request trace len */
1772       if(bufLen < rgCb[inst].trcLen)
1773       {
1774          /* Copy the whole of the recvd buffer in trace indication */
1775       
1776          if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1777             != ROK)
1778          {
1779             RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1780             RETVOID;
1781          }
1782          
1783          trc.cfm.status = LCM_PRIM_OK;
1784          trc.cfm.reason = LCM_REASON_NOT_APPL;
1785          trc.t.trc.evnt = event;
1786
1787          /* Send Trace Indication to Layer manager */
1788          RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1789       }
1790       /* if the recvd buffer size is greater than request trace len */
1791       if(bufLen >= rgCb[inst].trcLen)
1792       {
1793          /* Get a temporary buffer to store the msg */
1794          if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1795          {
1796             RLOG0(L_ERROR, "rgAllocSBuf Failed.");
1797             RETVOID;
1798          }
1799          
1800          /* Copy trcLen nos of bytes from the recvd message */
1801          if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)   
1802          {
1803             RLOG0(L_ERROR, "SCpyMsgFix Failed.");
1804             RETVOID;
1805          }
1806
1807          if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1808          {
1809             RLOG0(L_ERROR, "dstMbuf Allocation Failed");
1810             RETVOID;
1811          }
1812          /* Copy the tempBuf data to dst mBuf */
1813          if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1814          {
1815             RLOG0(L_ERROR, "SCpyFixMsg Failed.");
1816             RETVOID;
1817          }
1818
1819          /*ccpu00117052 - MOD - Passing double pointer for proper NULLP 
1820                                assignment */
1821          /* Free the memory allocated for tempBuf */
1822          rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1823                
1824          trc.cfm.status = LCM_PRIM_OK;
1825          trc.cfm.reason = LCM_REASON_NOT_APPL;
1826          trc.t.trc.evnt = event;
1827       
1828          /* Send Trace Indication to Layer manager */
1829          RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1830       }
1831    }
1832    RETVOID;
1833 }
1834
1835 \f
1836 /**
1837  * @brief Layer Manager Control Confirm generation handler
1838  *        for Bind Confirm reception at TFU interface.
1839  *        RgLiTfuBndCfm() forwards the confirmation to this 
1840  *        function. All SAP state related handling is restricted
1841  *        to LMM modules, hence the cfm forwarding.
1842  *
1843  * @details
1844  *
1845  *     Function : rgLMMBndCfm 
1846  *     
1847  *     This API is used by the LIM module of MAC to forward
1848  *     the Bind Confirm it receives over the TFU interface.
1849  *     
1850  *  @param[in]   Pst *pst, Post Structure
1851  *  @param[in]   SuId suId, Service user ID
1852  *  @param[in]   U8 status, Status
1853  *  @return  S16
1854  *      -# ROK
1855  **/
1856 #ifdef ANSI
1857 PUBLIC S16 rgLMMBndCfm
1858 (
1859 Pst *pst,               /* Post Structure */
1860 SuId suId,              /* Service user ID */
1861 U8 status               /* Status */
1862 )
1863 #else
1864 PUBLIC S16 rgLMMBndCfm(pst,suId,status)
1865 Pst *pst;               /* Post Structure */
1866 SuId suId;              /* Service user ID */
1867 U8 status;              /* Status */
1868 #endif
1869 {
1870    Inst      inst = pst->dstInst - RG_INST_START;
1871    S16       ret = ROK;
1872    RgMngmt   cntrlCfm;
1873    Pst       cfmPst;
1874
1875    TRC3(rgLMMBndCfm)
1876
1877    UNUSED(pst);
1878
1879    /* Check if the suId is valid */
1880    if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1881    {
1882       RLOG0(L_ERROR, "Invalid SuId");
1883       RETVALUE(RFAILED);
1884    }
1885
1886    /* check the Sap State */
1887    switch(rgCb[inst].tfuSap.sapSta.sapState)
1888    {
1889       case LRG_WAIT_BNDCFM:
1890          break;
1891       case LRG_BND:
1892          /* SAP is already bound */
1893          RETVALUE(ROK);
1894       default:
1895          RETVALUE(RFAILED);
1896    }
1897
1898    cfmPst = rgCb[inst].rgInit.lmPst;
1899    cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1900    cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1901    cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1902    cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1903    cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1904    
1905    cmMemset((U8 *)&cntrlCfm, 0, sizeof(RgMngmt));
1906
1907    switch(status)
1908    {
1909       case CM_BND_OK: /* status is OK */
1910          /* Change SAP state to Bound */
1911          rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1912          if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1913          {
1914             ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1915          }
1916          /* Send Control Confirm with status as OK to Layer Manager */
1917          cntrlCfm.cfm.status = LCM_PRIM_OK;
1918          cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1919          break;
1920
1921       default:
1922          /* Change SAP state to UnBound */
1923          rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1924          if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1925          {
1926             ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1927          }
1928          /* Send Control Confirm with status as NOK to Layer Manager */
1929          cntrlCfm.cfm.status = LCM_PRIM_NOK;
1930          cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1931          break;
1932    }
1933    rgCb[inst].tfuSap.numBndRetries = 0;
1934    cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1935    cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1936
1937    ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1938
1939    RETVALUE(ret);
1940 }
1941
1942 \f
1943 /**
1944  * @brief LTE MAC timer call back function registered with SSI. 
1945  *
1946  * @details
1947  *
1948  *     Function :  rgActvTmr
1949  *     
1950  *     This function is invoked by SSI for every timer activation
1951  *     period expiry.
1952  *     
1953  *  @return  S16
1954  *      -# ROK
1955  **/
1956 #ifdef ANSI
1957 PUBLIC S16 rgActvTmr
1958 (
1959  Ent     ent,
1960  Inst    inst
1961 )
1962 #else
1963 PUBLIC S16 rgActvTmr(ent, inst)
1964 Ent     ent;
1965 Inst    inst;
1966 #endif
1967 {
1968    Inst macInst = (inst  - RG_INST_START);
1969    TRC3(rgActvTmr)
1970
1971    /* Check if any MAC timer has expired */ 
1972    cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1973  
1974    RETVALUE(ROK);
1975  
1976 } /* end of rgActvTmr */
1977
1978 /**
1979  * @brief Layer Manager  Configuration request handler for Scheduler
1980  *
1981  * @details
1982  *
1983  *     Function : MacSchGenCfgReq
1984  *     
1985  *     This function receives general configurations for Scheduler
1986  *     from DU APP and forwards to Scheduler.
1987  *     
1988  *  @param[in]  Pst *pst, the post structure     
1989  *  @param[in]  RgMngmt *cfg, the configuration parameter's structure
1990  *  @return  S16
1991  *      -# ROK
1992  **/
1993 #ifdef ANSI
1994 PUBLIC int MacSchGenCfgReq
1995 (
1996 Pst      *pst,    /* post structure  */
1997 RgMngmt  *cfg     /* config structure  */
1998 )
1999 #else
2000 PUBLIC int MacSchGenCfgReq(pst, cfg)
2001 Pst      *pst;    /* post structure  */
2002 RgMngmt  *cfg;    /* config structure  */
2003 #endif    
2004 {
2005    printf("\nReceived Scheduler gen config at MAC");
2006    pst->dstInst = DEFAULT_CELLS + 1;
2007    HandleSchGenCfgReq(pst, cfg);
2008
2009    return ROK;
2010 }
2011
2012 /**
2013  * @brief Layer Manager Configuration response from Scheduler
2014  *
2015  * @details
2016  *
2017  *     Function : SchSendCfgCfm
2018  *     
2019  *     This function sends general configurations response from
2020  *     Scheduler to DU APP.
2021  *     
2022  *  @param[in]  Pst *pst, the post structure     
2023  *  @param[in]  RgMngmt *cfm, the configuration confirm structure
2024  *  @return  S16
2025  *      -# ROK
2026  **/
2027 #ifdef ANSI
2028 PUBLIC S16 SchSendCfgCfm 
2029 (
2030 Pst      *pst,    /* post structure  */
2031 RgMngmt  *cfm     /* config confirm structure  */
2032 )
2033 #else
2034 PUBLIC S16 SchSendCfgCfm(pst, cfm)
2035 Pst      *pst;    /* post structure  */
2036 RgMngmt  *cfm;    /* config confirm structure  */
2037 #endif    
2038 {
2039    printf("\nSending Scheduler config confirm to DU APP");
2040         pst->dstEnt = ENTDUAPP;
2041         pst->dstInst = 0;
2042         pst->srcInst = 0;
2043         pst->selector = MAC_SCH_LC_SELECTOR; 
2044    RgMiLrgSchCfgCfm(pst, cfm);
2045    
2046    RETVALUE(ROK);
2047 }
2048
2049 \f
2050 /***********************************************************
2051  *
2052  *     Func : macCellCfgFillCfmPst 
2053  *        
2054  *
2055  *     Desc : Fills the Confirmation Post Structure cfmPst 
2056  *
2057  *     Ret  : Void
2058  *
2059  *     Notes: 
2060  *
2061  *     File : rg_lmm.c 
2062  *
2063  **********************************************************/
2064 Void macCellCfgFillCfmPst
2065 (
2066 Pst           *reqPst,
2067 Pst           *cfmPst
2068 )
2069 {
2070    Inst inst;
2071    inst = reqPst->dstInst;
2072
2073    cfmPst->srcEnt    = rgCb[inst].rgInit.ent;
2074    cfmPst->srcInst   = rgCb[inst].rgInit.inst;
2075    cfmPst->srcProcId = rgCb[inst].rgInit.procId;
2076
2077    cfmPst->dstEnt    = ENTDUAPP;
2078    cfmPst->dstInst   = 0;
2079    cfmPst->dstProcId = cfmPst->srcProcId;
2080
2081    cfmPst->selector  = LRG_SEL_LC;
2082    cfmPst->prior     = reqPst->prior;
2083    cfmPst->route     = reqPst->route;
2084    cfmPst->region    = reqPst->region;
2085    cfmPst->pool      = reqPst->pool;
2086    cfmPst->event     = EVENT_MAC_CELL_CONFIG_CFM;
2087
2088    RETVOID;
2089 }
2090
2091 /**
2092  * @brief Layer Manager Configuration request handler. 
2093  *
2094  * @details
2095  *
2096  *     Function : MacHdlCellCfgReq 
2097  *     
2098  *     This function handles the gNB and cell configuration
2099  *     request received from DU APP.
2100  *     This API unapcks and forwards the config towards SCH
2101  *     
2102  *  @param[in]  Pst           *pst
2103  *  @param[in]  MacCellCfg    *macCellCfg 
2104  *  @return  S16
2105  *      -# ROK
2106  **/
2107 int MacHdlCellCfgReq
2108 (
2109  Pst           *pst,
2110  MacCellCfg    *macCellCfg
2111 )
2112 {
2113    Pst cfmPst;
2114    uint16_t ret = ROK;
2115    RgCellCb      *cellCb;
2116         MacCellCb     *macCellCb;
2117    Inst inst = pst->dstInst;
2118
2119    cmMemset((U8 *)&cfmPst, 0, sizeof(Pst));
2120    MAC_ALLOC(cellCb,sizeof(RgCellCb));
2121
2122    if(cellCb == NULLP)
2123    {
2124       DU_LOG("\nMAC : cellCb is NULL at handling of macCellCfg\n");
2125       return RFAILED;
2126    }
2127
2128    memcpy(&cellCb->macCellCfg,macCellCfg,sizeof(MacCellCfg));
2129    rgCb[inst].cell = cellCb;
2130
2131    MAC_ALLOC(macCellCb,sizeof(MacCellCb));
2132         if(macCellCb == NULLP)
2133         {
2134       DU_LOG("\nMAC : macCellCb is NULL at handling of macCellCfg\n");
2135       return RFAILED;
2136    }
2137    macCb.macCell = macCellCb;
2138    macCb.macCell->cellId = macCellCfg->cellId;
2139    /* Send cell cfg to scheduler */
2140    ret = MacSchCellCfgReq(pst, macCellCfg);
2141         if(ret != ROK)
2142         {
2143                 MacCellCfgCfm macCellCfgCfm;
2144                 macCellCfgCfm.rsp = RSP_NOK;
2145                 macCellCfgCfm.transId = macCellCfg->transId;
2146                 macCellCfgFillCfmPst(pst,&cfmPst);
2147                 ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
2148         }
2149 #ifdef INTEL_WLS
2150    LwrMacEnqueueWlsBlock();
2151 #endif
2152    return ret;
2153 } /* end of MacHdlCellCfgReq */
2154
2155 /**
2156  * @brief Layer Manager Configuration request handler. 
2157  *
2158  * @details
2159  *
2160  *     Function : MacSchCellCfgReq 
2161  *     
2162  *     This function sends cell configuration to SCH
2163  *     
2164  *  @param[in]  Pst           *pst
2165  *  @param[in]  MacCellCfg    *macCellCfg 
2166  *  @return  S16
2167  *      -# ROK
2168  **/
2169 int MacSchCellCfgReq
2170 (
2171  Pst           *pst,
2172  MacCellCfg    *macCellCfg
2173 )
2174 {
2175    SchCellCfg schCellCfg;
2176         Pst        cfgPst;
2177         int ret;
2178
2179    cmMemset((U8 *)&cfgPst, 0, sizeof(Pst));
2180         schCellCfg.cellId = macCellCfg->cellId;
2181         schCellCfg.phyCellId = macCellCfg->phyCellId;
2182         schCellCfg.bandwidth = macCellCfg->dlCarrCfg.bw;
2183         schCellCfg.dupMode = macCellCfg->dupType;
2184
2185         /* fill ssb scheduler parameters */
2186         schCellCfg.ssbSchCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr;
2187         schCellCfg.ssbSchCfg.scsCommon = macCellCfg->ssbCfg.scsCmn;
2188         schCellCfg.ssbSchCfg.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
2189         schCellCfg.ssbSchCfg.ssbPeriod = macCellCfg->ssbCfg.ssbPeriod;
2190         schCellCfg.ssbSchCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset;
2191         for(uint8_t idx=0; idx<SSB_MASK_SIZE; idx++)
2192         {
2193       schCellCfg.ssbSchCfg.nSSBMask[idx] = macCellCfg->ssbCfg.ssbMask[idx]; 
2194         }
2195
2196         /* fill SIB1 scheduler parameters */
2197         schCellCfg.sib1SchCfg.sib1PduLen = macCellCfg->sib1Cfg.sib1PduLen; 
2198         schCellCfg.sib1SchCfg.sib1NewTxPeriod = macCellCfg->sib1Cfg.sib1NewTxPeriod; 
2199         schCellCfg.sib1SchCfg.sib1RepetitionPeriod = macCellCfg->sib1Cfg.sib1RepetitionPeriod; 
2200         schCellCfg.sib1SchCfg.coresetZeroIndex = macCellCfg->sib1Cfg.coresetZeroIndex; 
2201         schCellCfg.sib1SchCfg.searchSpaceZeroIndex = macCellCfg->sib1Cfg.searchSpaceZeroIndex; 
2202         schCellCfg.sib1SchCfg.sib1Mcs = macCellCfg->sib1Cfg.sib1Mcs; 
2203
2204         /* fill RACH config params */
2205         schCellCfg.schRachCfg.prachCfgIdx = macCellCfg->prachCfg.prachCfgIdx;
2206         schCellCfg.schRachCfg.prachSubcSpacing = \
2207            macCellCfg->prachCfg.prachSubcSpacing;
2208         schCellCfg.schRachCfg.msg1FreqStart = macCellCfg->prachCfg.msg1FreqStart;
2209         schCellCfg.schRachCfg.msg1Fdm       = macCellCfg->prachCfg.msg1Fdm;
2210         schCellCfg.schRachCfg.rootSeqIdx    = macCellCfg->prachCfg.fdm[0].rootSeqIdx;
2211         schCellCfg.schRachCfg.numRootSeq    = macCellCfg->prachCfg.fdm[0].numRootSeq;
2212         schCellCfg.schRachCfg.k1            = macCellCfg->prachCfg.fdm[0].k1;
2213         schCellCfg.schRachCfg.ssbPerRach    = macCellCfg->prachCfg.ssbPerRach;
2214         schCellCfg.schRachCfg.prachMultCarrBand = \
2215            macCellCfg->prachCfg.prachMultCarrBand;
2216         schCellCfg.schRachCfg.raContResTmr  = macCellCfg->prachCfg.raContResTmr;
2217         schCellCfg.schRachCfg.rsrpThreshSsb = macCellCfg->prachCfg.rsrpThreshSsb;
2218         schCellCfg.schRachCfg.raRspWindow   = macCellCfg->prachCfg.raRspWindow;
2219
2220    /* fill initial DL BWP */
2221    schCellCfg.schInitialDlBwp.bwp.firstPrb = macCellCfg->initialDlBwp.bwp.firstPrb;
2222    schCellCfg.schInitialDlBwp.bwp.numPrb = macCellCfg->initialDlBwp.bwp.numPrb;
2223    schCellCfg.schInitialDlBwp.bwp.scs = macCellCfg->initialDlBwp.bwp.scs;
2224    schCellCfg.schInitialDlBwp.bwp.cyclicPrefix = macCellCfg->initialDlBwp.bwp.cyclicPrefix;
2225    schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.searchSpaceId =
2226            macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.searchSpaceId;
2227    schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.coresetId =
2228       macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.coresetId;
2229    schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.monitoringSlot =
2230       macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.monitoringSlot;
2231    schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.duration =
2232       macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.duration;
2233    schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.monitoringSymbol =
2234       macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.monitoringSymbol;
2235    schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel1 =
2236       macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel1;
2237    schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel2 =
2238       macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel2;
2239    schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel4 =
2240       macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel4;
2241    schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel8 =
2242       macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel8;
2243    schCellCfg.schInitialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel16 =
2244       macCellCfg->initialDlBwp.pdcchCommon.raSearchSpace.candidate.aggLevel16;
2245    schCellCfg.schInitialDlBwp.pdschCommon.k0 = macCellCfg->initialDlBwp.pdschCommon.k0;
2246    schCellCfg.schInitialDlBwp.pdschCommon.mappingType =
2247       macCellCfg->initialDlBwp.pdschCommon.mappingType;
2248    schCellCfg.schInitialDlBwp.pdschCommon.startSymbol =
2249       macCellCfg->initialDlBwp.pdschCommon.startSymbol;
2250    schCellCfg.schInitialDlBwp.pdschCommon.lengthSymbol =
2251       macCellCfg->initialDlBwp.pdschCommon.lengthSymbol;
2252
2253    /* fill initial DL BWP */
2254    schCellCfg.schInitialUlBwp.bwp.firstPrb = macCellCfg->initialUlBwp.bwp.firstPrb;
2255    schCellCfg.schInitialUlBwp.bwp.numPrb = macCellCfg->initialUlBwp.bwp.numPrb;
2256    schCellCfg.schInitialUlBwp.bwp.scs = macCellCfg->initialUlBwp.bwp.scs;
2257    schCellCfg.schInitialUlBwp.bwp.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix;
2258    schCellCfg.schInitialUlBwp.puschCommon.k2 = macCellCfg->initialUlBwp.puschCommon.k2;
2259    schCellCfg.schInitialUlBwp.puschCommon.mappingType =
2260       macCellCfg->initialUlBwp.puschCommon.mappingType;
2261    schCellCfg.schInitialUlBwp.puschCommon.startSymbol =
2262       macCellCfg->initialUlBwp.puschCommon.startSymbol;
2263    schCellCfg.schInitialUlBwp.puschCommon.lengthSymbol =
2264       macCellCfg->initialUlBwp.puschCommon.lengthSymbol;
2265
2266
2267    cfgPst.srcProcId = pst->dstProcId;
2268         cfgPst.dstProcId = pst->srcProcId;
2269         cfgPst.srcEnt    = ENTRG;
2270         cfgPst.srcInst   = 0;
2271         cfgPst.dstEnt    = ENTRG;
2272         cfgPst.dstInst   = 1;
2273         cfgPst.selector  = MAC_SCH_TC_SELECTOR;
2274         cfgPst.event     = EVENT_SCH_CELL_CFG;
2275
2276         ret = (*SchCellCfgOpts[cfgPst.selector])(&cfgPst, &schCellCfg);
2277         return ret;
2278 } /* end of MacSchCellCfgReq */
2279
2280
2281 /*******************************************************************
2282  *
2283  * @brief Sends Cell config confirm to DU APP
2284  *
2285  * @details
2286  *
2287  *    Function : MacSendCellCfgCfm 
2288  *
2289  *    Functionality:
2290  *      Sends Cell config confirm to DU APP
2291  *
2292  * @params[in] Response status
2293  * @return void
2294  *
2295  * ****************************************************************/
2296 void MacSendCellCfgCfm(uint8_t response)
2297 {
2298    Pst pst;
2299    RgCellCb      *cellCb;
2300    MacCellCfgCfm macCellCfgCfm;
2301  
2302    cmMemset((U8 *)&pst, 0, sizeof(Pst));
2303    cellCb = rgCb[macCb.macInst].cell;
2304  
2305    macCellCfgCfm.transId = cellCb->macCellCfg.transId;
2306    macCellCfgCfm.rsp = response;
2307
2308    memcpy((void *)&pst, (void *)&rgCb[macCb.macInst].rgInit.lmPst, sizeof(Pst));
2309    pst.event = EVENT_MAC_CELL_CONFIG_CFM;
2310    (*packMacCellCfmOpts[pst.selector])(&pst,&macCellCfgCfm);
2311 }
2312
2313
2314 /**
2315  * @brief Layer Manager Configuration response handler. 
2316  *
2317  * @details
2318  *
2319  *     Function : MacProcSchCellCfgCfm
2320  *     
2321  *     This function processes cell configuration to SCH
2322  *     
2323  *  @param[in]  Pst           *pst
2324  *  @param[in]  SchCellCfgCfm *schCellCfgCfm
2325  *  @return  int
2326  *      -# ROK
2327  **/
2328 int MacProcSchCellCfgCfm 
2329 (
2330  Pst           *pst,
2331  SchCellCfgCfm *schCellCfgCfm
2332 )
2333 {
2334         if(schCellCfgCfm->rsp == RSP_OK)
2335         {
2336       sendToLowerMac(CONFIG_REQUEST, 0, (void *)NULL);
2337         }
2338         else
2339         {
2340       MacSendCellCfgCfm(RSP_NOK);
2341         }
2342    return ROK;  
2343 }
2344
2345 /**********************************************************************
2346  
2347          End of file
2348 **********************************************************************/