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