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