<JIRA ID: ODUHIGH-368 : Slice information associated during PDU session establishment...
[o-du/l2.git] / src / 5gnrmac / mac_demux.c
index e397001..1ef38fe 100644 (file)
@@ -26,7 +26,6 @@
 #include "mac.h"
 #include "mac_utils.h"
 
-extern uint32_t shortBsrBytesTable[MAX_SHORT_BSR_TABLE_ENTRIES];
 
 /*******************************************************************
  *
@@ -45,17 +44,17 @@ extern uint32_t shortBsrBytesTable[MAX_SHORT_BSR_TABLE_ENTRIES];
  *         RFAILED
  *
  * ****************************************************************/
-uint8_t unpackRxData(uint16_t cellId, SlotIndInfo slotInfo, RxDataIndPdu *rxDataIndPdu)
+uint8_t unpackRxData(uint16_t cellId, SlotTimingInfo slotInfo, RxDataIndPdu *rxDataIndPdu)
 {
-   uint8_t   ueIdx;       /* Iterator for UE list */
-   uint8_t   lcId;        /* LC ID of a sub pdu */
-   uint8_t   fBit = 0;    /* Value of F Bit in MAC sub-header */
-   uint8_t   idx = 0;     /* Iterator for received PDU */
-   uint16_t  length;      /* Length of payload in a sub-PDU */ 
-   uint8_t   *pdu;        /* Payload in sub-PDU */
-   uint16_t  pduLen;      /* Length of undecoded PDU */
-   uint8_t   *rxDataPdu;  /* Received PDU in Rx Data Ind */
-   uint16_t  cellIdx;     /* Cell Index */
+   uint8_t   ueIdx = 0;       /* Iterator for UE list */
+   uint8_t   lcId = 0;        /* LC ID of a sub pdu */
+   uint8_t   fBit = 0;        /* Value of F Bit in MAC sub-header */
+   uint8_t   idx = 0;         /* Iterator for received PDU */
+   uint16_t  length = 0;      /* Length of payload in a sub-PDU */ 
+   uint8_t   *pdu = NULLP;    /* Payload in sub-PDU */
+   uint16_t  pduLen = 0;      /* Length of undecoded PDU */
+   uint8_t   *rxDataPdu = NULLP;  /* Received PDU in Rx Data Ind */
+   uint16_t  cellIdx = 0;     /* Cell Index */
    uint8_t   ret =ROK;
 
    GET_CELL_IDX(cellId, cellIdx);
@@ -86,7 +85,7 @@ uint8_t unpackRxData(uint16_t cellId, SlotIndInfo slotInfo, RxDataIndPdu *rxData
               MAC_ALLOC_SHRABL_BUF(pdu, length);
               if(!pdu)
               {
-                 DU_LOG("\nMAC : UL CCCH PDU memory allocation failed");
+                 DU_LOG("\nERROR  -->  MAC : UL CCCH PDU memory allocation failed");
                  return RFAILED;
               }  
               idx++;
@@ -104,7 +103,7 @@ uint8_t unpackRxData(uint16_t cellId, SlotIndInfo slotInfo, RxDataIndPdu *rxData
 
         case MAC_LCID_MIN ... MAC_LCID_MAX :
            {
-              DU_LOG("\nMAC : PDU received for LC ID %d", lcId);
+              DU_LOG("\nINFO   -->  MAC : PDU received for LC ID %d", lcId);
               pduLen--;
               idx++;
 
@@ -120,7 +119,7 @@ uint8_t unpackRxData(uint16_t cellId, SlotIndInfo slotInfo, RxDataIndPdu *rxData
               MAC_ALLOC_SHRABL_BUF(pdu, length);
               if(!pdu)
               {
-                 DU_LOG("\nMAC : Memory allocation failed while demuxing Rx Data PDU");
+                 DU_LOG("\nERROR  -->  MAC : Memory allocation failed while demuxing Rx Data PDU");
                  return RFAILED;
               }
               pduLen--;
@@ -133,12 +132,12 @@ uint8_t unpackRxData(uint16_t cellId, SlotIndInfo slotInfo, RxDataIndPdu *rxData
               if(macCb.macCell[cellIdx]->macRaCb[ueIdx].crnti == rxDataIndPdu->rnti)
               {
                  MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, \
-                    macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
-                  MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \
-                      macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize);
+                         macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
+             MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TxPdu, \
+                      macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4TbSize - TX_PAYLOAD_HDR_LEN);
                  memset(&macCb.macCell[cellIdx]->macRaCb[ueIdx], 0, sizeof(MacRaCbInfo));
               }
-              
+
               /* Send UL Data to RLC */
               ret = macProcUlData(cellId, rxDataIndPdu->rnti, slotInfo, lcId, length, pdu);
 
@@ -206,7 +205,7 @@ uint8_t unpackRxData(uint16_t cellId, SlotIndInfo slotInfo, RxDataIndPdu *rxData
         
         default:
            {
-              DU_LOG("\nMAC : Invalid LC Id %d", lcId);
+              DU_LOG("\nERROR  -->  MAC : Invalid LC Id %d", lcId);
               return RFAILED;
            }
       } /* End of switch */