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