Merge "Added a new Flag ODU_LWR_MAC_DEBUG in the code"
[o-du/l2.git] / src / 5gnrmac / mac_msg_hdl.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 /* header include files -- defines (.h)  */
20 #include "common_def.h"
21 #include "lrg.h"
22 #include "lrg.x"
23 #include "du_app_mac_inf.h"
24 #include "mac_sch_interface.h"
25 #include "rlc_mac_inf.h"
26 #include "mac_upr_inf_api.h"
27 #include "lwr_mac.h"
28 #ifdef INTEL_FAPI
29 #include "fapi_interface.h"
30 #endif
31 #include "lwr_mac_fsm.h"
32 #include "lwr_mac_upr_inf.h"
33 #include "mac.h"
34 #include "mac_utils.h"
35
36 /* This file contains message handling functionality for MAC */
37
38 extern MacCb  macCb;
39
40 uint16_t buildMacPdu(RlcData *dlData);
41 #ifdef EGTP_TEST
42 void macStubBuildUlData(Buffer *mBuf);
43 #endif
44
45 /* Function pointer for sending crc ind from MAC to SCH */
46 MacSchCrcIndFunc macSchCrcIndOpts[]=
47 {
48    packMacSchCrcInd,
49    MacSchCrcInd,
50    packMacSchCrcInd
51 };
52
53 /* Function pointer for sending DL RLC BO Info from MAC to SCH */
54 MacSchDlRlcBoInfoFunc macSchDlRlcBoInfoOpts[]=
55 {
56    packMacSchDlRlcBoInfo,
57    MacSchDlRlcBoInfo,
58    packMacSchDlRlcBoInfo
59 };
60
61 /* Function pointer for sending short BSR from MAC to SCH */
62 MacSchBsrFunc macSchBsrOpts[]=
63 {
64    packMacSchBsr,
65    MacSchBsr,
66    packMacSchBsr
67 };
68
69 /* Function pointer for sending SR Uci ind from MAC to SCH */
70 MacSchSrUciIndFunc macSchSrUciIndOpts[]=
71 {
72    packMacSchSrUciInd,
73    MacSchSrUciInd,
74    packMacSchSrUciInd
75 };
76
77 /*******************************************************************
78  *
79  * @brief Sends DL BO Info to SCH
80  *
81  * @details
82  *
83  *    Function : sendDlRlcBoInfoToSch
84  *
85  *    Functionality:
86  *       Sends DL BO Info to SCH
87  *
88  * @params[in] 
89  * @return ROK     - success
90  *         RFAILED - failure
91  *
92  ****************************************************************/
93 uint8_t sendDlRlcBoInfoToSch(DlRlcBoInfo *dlBoInfo)
94 {
95    Pst pst;
96
97    FILL_PST_MAC_TO_SCH(pst, EVENT_DL_RLC_BO_INFO_TO_SCH);
98    return(*macSchDlRlcBoInfoOpts[pst.selector])(&pst, dlBoInfo);
99 }
100
101 /*******************************************************************
102  *
103  * @brief Sends CRC Indication to SCH
104  *
105  * @details
106  *
107  *    Function : sendCrcIndMacToSch 
108  *
109  *    Functionality:
110  *       Sends CRC Indication to SCH
111  *
112  * @params[in] 
113  * @return ROK     - success
114  *         RFAILED - failure
115  *
116  ****************************************************************/
117 uint8_t sendCrcIndMacToSch(CrcIndInfo *crcInd)
118 {
119    Pst pst;
120
121    FILL_PST_MAC_TO_SCH(pst, EVENT_CRC_IND_TO_SCH);
122    return(*macSchCrcIndOpts[pst.selector])(&pst, crcInd);
123 }
124
125 /*******************************************************************
126  *
127  * @brief Processes CRC Indication from PHY
128  *
129  * @details
130  *
131  *    Function : fapiMacCrcInd
132  *
133  *    Functionality:
134  *       Processes CRC Indication from PHY
135  *
136  * @params[in] Post Structure Pointer
137  *             Crc Indication Pointer
138  * @return ROK     - success
139  *         RFAILED - failure
140  *
141  * ****************************************************************/
142 uint8_t fapiMacCrcInd(Pst *pst, CrcInd *crcInd)
143 {
144    uint16_t     cellIdx;
145    CrcIndInfo   crcIndInfo;
146    DU_LOG("\nMAC : Received CRC indication");
147    GET_CELL_IDX(crcInd->cellId, cellIdx);
148    /* Considering one pdu and one preamble */ 
149    crcIndInfo.cellId = macCb.macCell[cellIdx]->cellId;;
150    crcIndInfo.crnti = crcInd->crcInfo[0].rnti;
151    crcIndInfo.timingInfo.sfn = crcInd->timingInfo.sfn;
152    crcIndInfo.timingInfo.slot = crcInd->timingInfo.slot;
153    crcIndInfo.numCrcInd = crcInd->crcInfo[0].numCb;
154    crcIndInfo.crcInd[0] = crcInd->crcInfo[0].cbCrcStatus[0];
155
156    return(sendCrcIndMacToSch(&crcIndInfo));
157 }
158
159 /*******************************************************************
160  *
161  * @brief Process Rx Data Ind at MAC
162  *
163  * @details
164  *
165  *    Function : fapiMacRxDataInd
166  *
167  *    Functionality:
168  *       Process Rx Data Ind at MAC
169  *
170  * @params[in] Post structure
171  *             Rx Data Indication
172  * @return ROK     - success
173  *         RFAILED - failure
174  *
175  * ****************************************************************/
176 uint8_t fapiMacRxDataInd(Pst *pst, RxDataInd *rxDataInd)
177 {
178    uint16_t pduIdx;
179    DU_LOG("\nMAC : Received Rx Data indication");
180    /* TODO : compare the handle received in RxDataInd with handle send in PUSCH
181     * PDU, which is stored in raCb */
182
183    for(pduIdx = 0; pduIdx < rxDataInd->numPdus; pduIdx++)
184    {
185       unpackRxData(rxDataInd->cellId, rxDataInd->timingInfo, &rxDataInd->pdus[pduIdx]);
186    }
187    return ROK;
188 }
189
190 /*******************************************************************
191  *
192  * @brief Processes DL data from RLC
193  *
194  * @details
195  *
196  *    Function : MacProcRlcDlData 
197  *
198  *    Functionality:
199  *      Processes DL data from RLC
200  *
201  * @params[in] Post structure
202  *             DL data
203  * @return ROK     - success
204  *         RFAILED - failure
205  *
206  * ****************************************************************/
207 uint8_t MacProcRlcDlData(Pst* pstInfo, RlcData *dlData)
208 {
209    uint8_t pduIdx;
210    uint8_t  *txPdu;
211    uint16_t tbSize;
212    MacDlData macDlData;
213    MacDlSlot *currDlSlot = NULLP;
214
215    DU_LOG("\nMAC: Received DL data for sfn=%d slot=%d", \
216       dlData->slotInfo.sfn, dlData->slotInfo.slot);
217    /* Copy the pdus to be muxed into mac Dl data */
218    macDlData.numPdu = dlData->numPdu;
219    for(pduIdx = 0;  pduIdx < dlData->numPdu; pduIdx++)
220    {
221       macDlData.pduInfo[pduIdx].lcId = dlData->pduInfo[pduIdx].lcId;
222       macDlData.pduInfo[pduIdx].pduLen = dlData->pduInfo[pduIdx].pduLen;
223       macDlData.pduInfo[pduIdx].dlPdu = dlData->pduInfo[pduIdx].pduBuf;
224    }
225
226    /* Store DL data in the scheduled slot */
227    currDlSlot = &macCb.macCell[dlData->cellId -1]->dlSlot[dlData->slotInfo.slot];
228    if(currDlSlot)
229    {
230       if(currDlSlot->dlInfo.dlMsgAlloc)
231       {
232          tbSize = currDlSlot->dlInfo.dlMsgAlloc->dlMsgPdschCfg.codeword[0].tbSize;
233          MAC_ALLOC(txPdu, tbSize);
234          if(!txPdu)
235          {
236             DU_LOG("\nMAC : Memory allocation failed in MacProcRlcDlData");
237             return RFAILED;
238          }
239          macMuxPdu(&macDlData, NULLP, txPdu, tbSize);
240
241          currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.dlMsgPduLen = tbSize;
242          currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.dlMsgPdu = txPdu;
243       }
244    }
245
246    /* Free memory */
247    for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
248    {
249       MAC_FREE_SHRABL_BUF(pstInfo->region, pstInfo->pool, dlData->pduInfo[pduIdx].pduBuf,\
250          dlData->pduInfo[pduIdx].pduLen);
251    }
252    if(pstInfo->selector == ODU_SELECTOR_LWLC)
253    {
254       MAC_FREE_SHRABL_BUF(pstInfo->region, pstInfo->pool, dlData, sizeof(RlcData));
255    }
256
257    return ROK;
258 }
259
260 /*******************************************************************
261  *
262  * @brief Builds and Sends UL Data to RLC
263  *
264  * @details
265  *
266  *    Function : macProcUlData
267  *
268  *    Functionality: Builds and Sends UL Data to RLC
269  *
270  * @params[in] CellId
271  *             CRNTI
272  *             Slot information
273  *             LC Id on which payload was received
274  *             Pointer to the payload
275  *             Length of payload
276  * @return ROK     - success
277  *         RFAILED - failure
278  *
279  * ****************************************************************/
280 uint8_t macProcUlData(uint16_t cellId, uint16_t rnti, SlotIndInfo slotInfo, \
281 uint8_t lcId, uint16_t pduLen, uint8_t *pdu)
282 {
283    Pst         pst;
284    RlcData  *ulData;
285
286    /* Filling RLC Ul Data*/
287    MAC_ALLOC_SHRABL_BUF(ulData, sizeof(RlcData));
288    if(!ulData)
289    {
290       DU_LOG("\nMAC : Memory allocation failed while sending UL data to RLC");
291       return RFAILED;
292    }
293    memset(ulData, 0, sizeof(RlcData));
294    ulData->cellId = cellId; 
295    ulData->rnti = rnti;
296    memcpy(&ulData->slotInfo, &slotInfo, sizeof(SlotIndInfo));
297    ulData->slotInfo.cellId = cellId;
298
299    /* Filling pdu info */
300    if(lcId == SRB1_LCID || lcId == SRB2_LCID)
301    {
302       ulData->pduInfo[ulData->numPdu].commCh = true;
303    }
304    ulData->pduInfo[ulData->numPdu].lcId = lcId;
305    ulData->pduInfo[ulData->numPdu].pduBuf = pdu;
306    ulData->pduInfo[ulData->numPdu].pduLen = pduLen;
307    ulData->numPdu++;
308
309    /* Filling Post and send to RLC */
310    memset(&pst, 0, sizeof(Pst));
311    FILL_PST_MAC_TO_RLC(pst, 0, EVENT_UL_DATA_TO_RLC);
312    MacSendUlDataToRlc(&pst, ulData);
313
314    return ROK;
315 }
316
317
318 /*******************************************************************
319  *
320  * @brief Processes BO status from RLC
321  *
322  * @details
323  *
324  *    Function : MacProcRlcBOStatus
325  *
326  *    Functionality:
327  *      Processes BO status from RLC
328  *
329  * @params[in] Post structure
330  *             BO status
331  * @return ROK     - success
332  *         RFAILED - failure
333  *
334  * ****************************************************************/
335 uint8_t MacProcRlcBoStatus(Pst* pst, RlcBoStatus* boStatus)
336 {
337    DlRlcBoInfo  dlBoInfo;
338
339    dlBoInfo.cellId = boStatus->cellId;
340    GET_CRNTI(dlBoInfo.crnti, boStatus->ueIdx);
341    dlBoInfo.lcId = boStatus->lcId;
342    dlBoInfo.dataVolume = boStatus->bo;
343
344    sendDlRlcBoInfoToSch(&dlBoInfo); 
345
346    if(pst->selector == ODU_SELECTOR_LWLC)
347    {
348       MAC_FREE_SHRABL_BUF(pst->region, pst->pool, boStatus, sizeof(RlcBoStatus));
349    }
350
351    return ROK;
352 }
353
354 /*******************************************************************
355  *
356  * @brief Send LC schedule result report to RLC
357  *
358  * @details
359  *
360  *    Function : sendSchRptToRlc 
361  *
362  *    Functionality: Send LC schedule result report to RLC
363  *
364  * @params[in] 
365  * @return ROK     - success
366  *         RFAILED - failure
367  *
368  * ****************************************************************/
369 uint8_t sendSchedRptToRlc(DlSchedInfo dlInfo, SlotIndInfo slotInfo)
370 {
371    Pst      pst;
372    uint8_t  lcIdx;
373    RlcSchedResultRpt  *schedRpt = NULLP;
374    
375    MAC_ALLOC_SHRABL_BUF(schedRpt, sizeof(RlcSchedResultRpt));
376    if(!schedRpt)
377    {
378       DU_LOG("\nMAC: Memory allocation failure in sendSchResultRepToRlc");
379       return RFAILED;
380    }
381
382    DU_LOG("\nMAC: Send scheduled result report for sfn %d slot %d", slotInfo.sfn, slotInfo.slot);
383    schedRpt->cellId = dlInfo.cellId;
384    schedRpt->rnti = dlInfo.dlMsgAlloc->crnti;
385    schedRpt->numLc = dlInfo.dlMsgAlloc->numLc;
386    schedRpt->slotInfo.sfn = slotInfo.sfn;
387    schedRpt->slotInfo.slot = slotInfo.slot;
388
389    for(lcIdx = 0; lcIdx < schedRpt->numLc; lcIdx++)
390    {
391       schedRpt->lcSch[lcIdx].lcId = dlInfo.dlMsgAlloc->lcSchInfo[lcIdx].lcId;
392       schedRpt->lcSch[lcIdx].bufSize = dlInfo.dlMsgAlloc->lcSchInfo[lcIdx].schBytes;
393       schedRpt->lcSch[lcIdx].commCh = false;
394    }
395
396    /* Fill Pst */
397    FILL_PST_MAC_TO_RLC(pst, RLC_DL_INST, EVENT_SCHED_RESULT_TO_RLC);
398    if(MacSendSchedResultRptToRlc(&pst, schedRpt) != ROK)
399    {
400       DU_LOG("\nMAC: Failed to send Schedule result report to RLC");
401       MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, schedRpt, sizeof(RlcSchedResultRpt));
402       return RFAILED;
403    }
404
405    return ROK;
406 }
407
408 /*******************************************************************
409  *
410  * @brief Handles cell start reuqest from DU APP
411  *
412  * @details
413  *
414  *    Function : MacProcCellStartReq
415  *
416  *    Functionality:
417  *      Handles cell start reuqest from DU APP
418  *
419  * @params[in] Post structure pointer
420  *             Cell Start Request info pointer 
421  * @return ROK     - success
422  *         RFAILED - failure
423  *
424  * ****************************************************************/
425 uint8_t MacProcCellStartReq(Pst *pst, MacCellStartInfo  *cellStartInfo)
426 {
427    DU_LOG("\nMAC : Handling cell start request");
428    sendToLowerMac(START_REQUEST, 0, cellStartInfo);
429
430    MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellStartInfo, \
431          sizeof(MacCellStartInfo));
432
433    return ROK;
434 }
435
436 /*******************************************************************
437  *
438  * @brief Handles cell stop request from DU APP
439  *
440  * @details
441  *
442  *    Function : MacProcCellStartReq
443  *
444  *    Functionality:
445  *        Handles cell stop request from DU APP
446  *
447  * @params[in] Post structure pointer
448  *             Mac Cell stop information
449  * @return ROK     - success
450  *         RFAILED - failure
451  *
452  * ****************************************************************/
453 uint8_t MacProcCellStopReq(Pst *pst, MacCellStopInfo  *cellStopInfo)
454 {
455 #ifdef INTEL_FAPI
456    DU_LOG("\nMAC : Sending cell stop request to Lower Mac");
457    sendToLowerMac(FAPI_STOP_REQUEST, 0, cellStopInfo);
458 #endif
459
460    MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellStopInfo, \
461          sizeof(MacCellStopInfo));
462
463    return ROK;
464 }
465
466 /*******************************************************************
467  *
468  * @brief Handles DL CCCH Ind from DU APP
469  *
470  * @details
471  *
472  *    Function : MacProcDlCcchInd 
473  *
474  *    Functionality:
475  *      Handles DL CCCH Ind from DU APP
476  *
477  * @params[in] Post structure pointer
478  *             DL CCCH Ind pointer 
479  * @return ROK     - success
480  *         RFAILED - failure
481  *
482  * ****************************************************************/
483 uint8_t MacProcDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo)
484 {
485    uint8_t  ueIdx = 0;
486    uint16_t cellIdx;
487    uint16_t idx;
488    DlRlcBoInfo  dlBoInfo;
489    memset(&dlBoInfo, 0, sizeof(DlRlcBoInfo));
490
491    DU_LOG("\nMAC : Handling DL CCCH IND");
492
493    GET_CELL_IDX(dlCcchIndInfo->cellId, cellIdx);
494
495    dlBoInfo.cellId = dlCcchIndInfo->cellId;
496    dlBoInfo.crnti = dlCcchIndInfo->crnti;
497
498    if(dlCcchIndInfo->msgType == RRC_SETUP)
499    {
500       dlBoInfo.lcId = SRB0_LCID;    // SRB ID 0 for msg4
501       dlBoInfo.dataVolume = dlCcchIndInfo->dlCcchMsgLen;
502
503       /* storing Msg4 Pdu in raCb */
504       GET_UE_IDX(dlBoInfo.crnti, ueIdx);
505       ueIdx = ueIdx -1;
506       if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == dlCcchIndInfo->crnti)
507       {
508          macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen = dlCcchIndInfo->dlCcchMsgLen;
509          MAC_ALLOC(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
510             macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
511          if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu)
512          {
513             for(idx = 0; idx < dlCcchIndInfo->dlCcchMsgLen; idx++)
514             {
515                macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu[idx] =\
516                   dlCcchIndInfo->dlCcchMsg[idx];
517             }
518          }
519       }
520    }
521    sendDlRlcBoInfoToSch(&dlBoInfo);
522
523    MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo->dlCcchMsg, \
524          dlCcchIndInfo->dlCcchMsgLen);
525    MAC_FREE_SHRABL_BUF(pst->region, pst->pool, dlCcchIndInfo, sizeof(DlCcchIndInfo));
526    return ROK;
527
528 }
529
530 /*******************************************************************
531  *
532  * @brief Sends UL CCCH Ind to DU APP
533  *
534  * @details
535  *
536  *    Function : macProcUlCcchInd
537  *
538  *    Functionality:
539  *        MAC sends UL CCCH Ind to DU APP
540  *
541  * @params[in] Post structure pointer
542  *            
543  * @return ROK     - success
544  *         RFAILED - failure
545  *
546  * ****************************************************************/
547 uint8_t macProcUlCcchInd(uint16_t cellId, uint16_t crnti, uint16_t rrcContSize, uint8_t *rrcContainer)
548 {
549    Pst pst;
550    uint8_t ret = ROK;
551    UlCcchIndInfo *ulCcchIndInfo = NULLP;
552
553    MAC_ALLOC_SHRABL_BUF(ulCcchIndInfo, sizeof(UlCcchIndInfo));
554    if(!ulCcchIndInfo)
555    {
556       DU_LOG("\nMAC: Memory failed in macProcUlCcchInd");
557       return RFAILED;
558    }
559
560    ulCcchIndInfo->cellId = cellId;
561    ulCcchIndInfo->crnti  = crnti;
562    ulCcchIndInfo->ulCcchMsgLen = rrcContSize;
563    ulCcchIndInfo->ulCcchMsg = rrcContainer;
564
565    /* Fill Pst */
566    FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_UL_CCCH_IND);
567
568    if(MacDuAppUlCcchInd(&pst, ulCcchIndInfo) != ROK)
569    {
570       DU_LOG("\nMAC: Failed to send UL CCCH Ind to DU APP");
571       MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
572       MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
573       ret = RFAILED;
574    }
575    return ret;
576 }
577
578 /*******************************************************************
579  *
580  * @brief Processes received short BSR
581  *
582  * @details
583  *
584  *    Function : macProcShortBsr
585  *
586  *    Functionality:
587  *        MAC sends Short BSR to SCH
588  *
589  * @params[in] cell ID
590  *             crnti
591  *             lcg ID
592  *             buffer size
593  *
594  *
595  * ****************************************************************/
596 uint8_t macProcShortBsr(uint16_t cellId, uint16_t crnti, uint8_t lcgId, uint32_t bufferSize)
597 {
598    Pst                  pst;
599    UlBufferStatusRptInd bsrInd;
600
601    memset(&pst, 0, sizeof(Pst));
602    memset(&bsrInd, 0, sizeof(UlBufferStatusRptInd));
603
604    bsrInd.cellId                 = cellId;
605    bsrInd.crnti                  = crnti;
606    bsrInd.bsrType                = SHORT_BSR;
607    bsrInd.numLcg                 = 1; /* short bsr reports one lcg at a time */
608    bsrInd.dataVolInfo[0].lcgId   = lcgId;
609    bsrInd.dataVolInfo[0].dataVol = bufferSize;
610
611    FILL_PST_MAC_TO_SCH(pst, EVENT_SHORT_BSR);
612    return(*macSchBsrOpts[pst.selector])(&pst, &bsrInd);
613 }
614
615 /*******************************************************************
616  *
617  * @brief Builds and send SR UCI Indication to SCH
618  *
619  * @details
620  *
621  *    Function : buildAndSendSrInd
622  *
623  *    Functionality:
624  *       Builds and send SR UCI Indication to SCH
625  *
626  * @params[in] SrUciIndInfo Pointer
627  *             crnti value
628  * @return ROK     - success
629  *         RFAILED - failure
630  *
631  * ****************************************************************/
632 uint8_t buildAndSendSrInd(UciInd *macUciInd, uint8_t crnti)
633 {
634    uint16_t cellIdx;
635    Pst pst;
636    SrUciIndInfo   srUciInd;
637    memset(&pst, 0, sizeof(Pst));
638    memset(&srUciInd, 0, sizeof(SrUciIndInfo));
639
640    GET_CELL_IDX(macUciInd->cellId, cellIdx);
641    srUciInd.cellId       = macCb.macCell[cellIdx]->cellId;;
642    srUciInd.crnti        = crnti;
643    srUciInd.slotInd.sfn  = macUciInd->slotInd.sfn;
644    srUciInd.slotInd.slot = macUciInd->slotInd.slot;
645    srUciInd.numSrBits++;
646    memset(srUciInd.srPayload, 0, MAX_SR_BITS_IN_BYTES);
647
648    /* Fill Pst */
649    FILL_PST_MAC_TO_SCH(pst, EVENT_UCI_IND_TO_SCH);
650
651    return(*macSchSrUciIndOpts[pst.selector])(&pst, &srUciInd);
652 }
653
654 /*******************************************************************
655  *
656  * @brief Processes UCI Indication from PHY
657  *
658  * @details
659  *
660  *    Function : fapiMacUciInd
661  *
662  *    Functionality:
663  *       Processes UCI Indication from PHY
664  *
665  * @params[in] Post Structure Pointer
666  *             UCI Indication Pointer
667  * @return ROK     - success
668  *         RFAILED - failure
669  *
670  * ****************************************************************/
671 uint8_t FapiMacUciInd(Pst *pst, UciInd *macUciInd)
672 {
673    uint8_t     pduIdx = 0;
674    uint8_t     ret = ROK;
675    uint16_t    nPdus;
676    uint16_t    crnti;
677
678    if(macUciInd)
679    {
680       nPdus = macUciInd->numUcis;
681       while(nPdus)
682       {
683          switch(macUciInd->pdus[pduIdx].pduType)
684          {
685             case UCI_IND_PUSCH:
686                break;
687             case UCI_IND_PUCCH_F0F1:
688                if(macUciInd->pdus[pduIdx].uci.uciPucchF0F1.srInfo.srIndPres)
689                {
690                   DU_LOG("\nMAC : Received SR UCI indication");
691                   crnti = macUciInd->pdus[pduIdx].uci.uciPucchF0F1.crnti; 
692                   ret = buildAndSendSrInd(macUciInd, crnti);
693                }
694                break;
695             case UCI_IND_PUCCH_F2F3F4:
696                break;
697             default:
698                DU_LOG("\nMAC: Invalid Pdu Type %d at FapiMacUciInd", macUciInd->pdus[pduIdx].pduType);
699                ret = RFAILED;
700                break;
701          }
702          pduIdx++;
703          nPdus--;
704       }
705    }
706    else
707    {
708       DU_LOG("\nMAC: Received Uci Ind is NULL at FapiMacUciInd()");
709       ret = RFAILED;
710    }
711    return ret;
712 }
713
714
715 /**********************************************************************
716   End of file
717  **********************************************************************/
718