UL TTI Request for PRACH PDU 58/3458/3
authorBalaji Shankaran <balaji.shankaran@radisys.com>
Sat, 25 Apr 2020 15:10:33 +0000 (20:40 +0530)
committerBalaji Shankaran <balaji.shankaran@radisys.com>
Sun, 26 Apr 2020 12:00:46 +0000 (17:30 +0530)
Change-Id: I0411cdb828d0afc2e7df7479f0dcfcfc773af8ac
Signed-off-by: Balaji Shankaran <balaji.shankaran@radisys.com>
src/5gnrmac/lwr_mac_fsm.c
src/5gnrmac/mac.h
src/5gnrmac/mac_rach.c
src/5gnrmac/rg_tom.c
src/phy_stub/l1_bdy1.c

index 820a73f..77e5447 100644 (file)
 #define PDCCH_PDU_TYPE 0
 #define PDSCH_PDU_TYPE 1
 #define SSB_PDU_TYPE 3
+#define PRACH_PDU_TYPE 0
+#define PDU_PRESENT 1
 #define SETLENGTH(x, size) x += size
 
 extern void fapiMacConfigRsp();
+extern uint8_t UnrestrictedSetNcsTable[MAX_ZERO_CORR_CFG_IDX];
+
 /* Global variables */
 SlotIndInfo slotIndInfo;
 uint8_t slotIndIdx;
@@ -2490,7 +2494,7 @@ S16 handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo)
    RgCellCb  *cellCbParams = NULLP;
        MacDlSlot *currDlSlot = NULLP;
    MacCellCfg macCellCfg;
-       cmMemset((U8 *)&macCellCfg, 0, sizeof(MacCellCfg));
+       memset(&macCellCfg, 0, sizeof(MacCellCfg));
    Inst inst = 0;
 
    if(clGlobalCp.phyState == PHY_STATE_RUNNING)
@@ -2586,6 +2590,218 @@ S16 handleDlTtiReq(CmLteTimingInfo *dlTtiReqtimingInfo)
    return ROK;
 }
 
+/***********************************************************************
+ *
+ * @brief calculates the total size to be allocated for UL TTI Req
+ *
+ * @details
+ *
+ *    Function : getnPdus
+ *
+ *    Functionality:
+ *         -calculates the total pdu count to be allocated for UL TTI Req
+ *
+ * @params[in] Pointer to fapi Ul TTI Req
+ *             Pointer to CurrUlSlot
+ * @return count
+ * ********************************************************************/
+#ifdef FAPI
+uint8_t getnPdus(fapi_ul_tti_req_t *ulTtiReq, MacUlSlot *currUlSlot)
+{
+       uint8_t pduCount = 0;
+
+       if(currUlSlot != NULLP)
+   {
+          if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PRACH)
+          {
+             pduCount++;
+             ulTtiReq->rachPresent = PDU_PRESENT;
+               }
+               if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_PUSCH_UCI)
+               {
+                  pduCount++;
+                       ulTtiReq->nUlsch = PDU_PRESENT;
+               }
+               if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_UCI)
+               {
+                  pduCount++;
+                       ulTtiReq->nUlcch = PDU_PRESENT;
+               }
+               if(currUlSlot->ulCellInfo.dataType & SCH_DATATYPE_SRS)
+               {
+                  pduCount++;
+               }
+   }
+       return pduCount;
+} 
+#endif 
+
+/***********************************************************************
+ *
+ * @brief Set the value of zero correlation config in PRACH PDU
+ *
+ * @details
+ *
+ *    Function : setNumCs
+ *
+ *    Functionality:
+ *         -Set the value of zero correlation config in PRACH PDU
+ *
+ * @params[in] Pointer to zero correlation config
+ *             Pointer to MacCellCfg
+ * ********************************************************************/
+
+void setNumCs(uint8_t *numCs, MacCellCfg *macCellCfg)
+{
+#ifdef FAPI
+   uint8_t idx;
+       if(macCellCfg != NULLP)
+       {
+          idx = macCellCfg->prachCfg.fdm[0].zeroCorrZoneCfg; 
+          *numCs = UnrestrictedSetNcsTable[idx];
+       }
+#endif
+}
+
+/***********************************************************************
+ *
+ * @brief Fills the PRACH PDU in UL TTI Request
+ *
+ * @details
+ *
+ *    Function : fillPrachPdu
+ *
+ *    Functionality:
+ *         -Fills the PRACH PDU in UL TTI Request
+ *
+ * @params[in] Pointer to Prach Pdu
+ *             Pointer to CurrUlSlot
+ *             Pointer to macCellCfg
+ *             Pointer to msgLen
+ * ********************************************************************/
+
+#ifdef FAPI
+void fillPrachPdu(fapi_ul_tti_req_pdu_t *ulTtiReqPdu, MacCellCfg *macCellCfg, MacUlSlot *currUlSlot, uint32_t *msgLen)
+{
+   if(ulTtiReqPdu != NULLP)
+   {
+      ulTtiReqPdu->pduType = PRACH_PDU_TYPE; 
+      ulTtiReqPdu->u.prach_pdu.physCellId = macCellCfg->phyCellId;
+      ulTtiReqPdu->u.prach_pdu.numPrachOcas = currUlSlot->ulCellInfo.prachSchInfo.numPrachOcas;
+      ulTtiReqPdu->u.prach_pdu.prachFormat = \
+               currUlSlot->ulCellInfo.prachSchInfo.prachFormat;
+      ulTtiReqPdu->u.prach_pdu.numRa = currUlSlot->ulCellInfo.prachSchInfo.numRa;
+      ulTtiReqPdu->u.prach_pdu.prachStartSymbol = \
+               currUlSlot->ulCellInfo.prachSchInfo.prachStartSymb;
+      setNumCs(&ulTtiReqPdu->u.prach_pdu.numCs, macCellCfg);
+      ulTtiReqPdu->u.prach_pdu.beamforming.numPrgs = 0;
+      ulTtiReqPdu->u.prach_pdu.beamforming.prgSize = 0;
+      ulTtiReqPdu->u.prach_pdu.beamforming.digBfInterfaces = 0;
+      ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].pmIdx = 0;
+      ulTtiReqPdu->u.prach_pdu.beamforming.pmi_bfi[0].beamIdx[0].beamidx = 0;
+      ulTtiReqPdu->pduSize = sizeof(fapi_ul_prach_pdu_t); 
+      SETLENGTH(*msgLen, sizeof(fapi_dl_pdsch_pdu_t));
+   }
+}
+#endif
+
+/*******************************************************************
+ *
+ * @brief Sends UL TTI Request to PHY
+ *
+ * @details
+ *
+ *    Function : handleUlTtiReq
+ *
+ *    Functionality:
+ *         -Sends FAPI Param req to PHY
+ *
+ * @params[in]  Pointer to CmLteTimingInfo
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ ******************************************************************/
+S16 handleUlTtiReq(CmLteTimingInfo *currTimingInfo)
+{
+#ifdef FAPI
+   uint32_t msgLen = 0;
+   fapi_ul_tti_req_t *ulTtiReq = NULLP;
+   fapi_ul_tti_req_pdu_t *ulTtiReqPdu = NULLP;
+   RgCellCb  *cellCbParams = NULLP;
+   MacUlSlot *currUlSlot = NULLP;
+   MacCellCfg macCellCfg;
+       memset(&macCellCfg, 0, sizeof(MacCellCfg));
+   Inst inst = 0;
+
+   if(clGlobalCp.phyState == PHY_STATE_RUNNING)
+   {
+      cellCbParams = rgCb[inst].cell;
+      macCellCfg = cellCbParams->macCellCfg;
+
+      if(currTimingInfo != NULLP)
+      {
+#ifdef INTEL_WLS
+         WLS_MEM_ALLOC(ulTtiReq, sizeof(fapi_ul_tti_req_t));
+#else
+         MAC_ALLOC(ulTtiReq, sizeof(fapi_ul_tti_req_t));
+#endif
+         if(ulTtiReq != NULLP)
+         {
+            ulTtiReq->sfn = currTimingInfo->sfn;
+            ulTtiReq->slot = currTimingInfo->slot;
+            currUlSlot = &macCb.macCell->ulSlot[ulTtiReq->slot % MAX_SLOT_SUPPORTED];
+                ulTtiReq->nPdus = getnPdus(ulTtiReq, currUlSlot);
+            ulTtiReq->nGroup = 0;
+            if(ulTtiReq->nPdus > 0)
+            {
+#ifdef INTEL_WLS
+               WLS_MEM_ALLOC(ulTtiReqPdu, (ulTtiReq->nPdus * sizeof(fapi_ul_tti_req_pdu_t)));
+#else
+               MAC_ALLOC(ulTtiReqPdu, (ulTtiReq->nPdus * sizeof(fapi_ul_tti_req_pdu_t)));
+#endif
+               /* Fill Prach Pdu */
+               if(ulTtiReq->rachPresent)
+               {
+                 if(ulTtiReqPdu != NULLP)
+                 {
+                    fillPrachPdu(ulTtiReqPdu, &macCellCfg, currUlSlot, &msgLen);
+                    ulTtiReq->pdus = ulTtiReqPdu;
+                 }
+                 msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t);
+                 fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
+                 LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgLen, (void *)ulTtiReq);
+                                         MAC_FREE(ulTtiReqPdu, (ulTtiReq->nPdus * sizeof(fapi_ul_tti_req_pdu_t)));
+               }
+            } 
+            else
+            {
+                msgLen = sizeof(fapi_ul_tti_req_t) - sizeof(fapi_msg_t);
+                fillMsgHeader(&ulTtiReq->header, FAPI_UL_TTI_REQUEST, msgLen);
+                LwrMacSendToPhy(ulTtiReq->header.message_type_id, msgLen, (void *)ulTtiReq);
+            }
+                               MAC_FREE(ulTtiReq, sizeof(fapi_ul_tti_req_t));
+                               return ROK;
+         }
+             else
+             {
+                DU_LOG("\nLOWER MAC: Failed to allocate memory for UL TTI Request");
+            return RFAILED;
+         }
+      }
+      else
+      {
+         DU_LOG("\nLOWER MAC: Current TTI Info in UL is NULL");
+         return RFAILED;
+      }
+   }
+   else
+   {
+       lwr_mac_handleInvalidEvt(currTimingInfo);
+   }
+#endif
+   return ROK;
+}
+
 lwrMacFsmHdlr fapiEvtHdlr[MAX_STATE][MAX_EVENT] =
 {
    {
index a8a0a86..68e02a5 100644 (file)
@@ -57,10 +57,16 @@ typedef struct macDlSlot
 
 }MacDlSlot;
 
+typedef struct macUlSlot
+{
+   UlSchInfo    ulCellInfo;
+}MacUlSlot;
+
 typedef struct macCellCb
 {
    uint16_t   cellId;
    MacDlSlot  dlSlot[MAX_SLOT_SUPPORTED];
+   MacUlSlot  ulSlot[MAX_SLOT_SUPPORTED];
 }MacCellCb;
 
 typedef struct macCb
index 19faa2b..3789350 100644 (file)
@@ -49,7 +49,12 @@ uint8_t UnrestrictedSetNcsTable[MAX_ZERO_CORR_CFG_IDX] =
 
 int MacProcUlSchInfo(Pst *pst, UlSchInfo *ulSchInfo)
 {
-
+   if(ulSchInfo != NULLP)
+       {
+      MacUlSlot *currUlSlot = 
+          &macCb.macCell->ulSlot[ulSchInfo->slotIndInfo.slot % MAX_SLOT_SUPPORTED];
+      memcpy(&currUlSlot->ulCellInfo, ulSchInfo, sizeof(UlSchInfo)); 
+   }
    return ROK;
 }
 
index c94d2a8..e4f3127 100755 (executable)
@@ -614,9 +614,10 @@ SlotIndInfo slotInd
 #endif
 
 /* Trigger for DL TTI REQ */
-   CmLteTimingInfo   dlTtiReqtimingInfo;
-   RGADDTOCRNTTIME(cellCb->crntTime, dlTtiReqtimingInfo, TFU_DELTA);
-   handleDlTtiReq(&dlTtiReqtimingInfo);
+   CmLteTimingInfo   timingInfo;
+   RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DELTA);
+   handleDlTtiReq(&timingInfo);
+   handleUlTtiReq(&timingInfo);
 
    dlSf = &cellCb->subFrms[(slotInd.slot % RG_NUM_SUB_FRAMES)];
 
index aeda96e..79dc9c0 100644 (file)
@@ -34,6 +34,7 @@
 #endif
 #include "lphy_stub.h"
 #include "du_log.h"
+#include "rg.h"
 
 #define MAX_SLOT_VALUE   9
 #define MAX_SFN_VALUE    1023
@@ -387,11 +388,50 @@ PUBLIC S16 l1HdlDlTtiReq(uint16_t msgLen, void *msg)
 
                numPdus--;
        }
+   MAC_FREE(dlTtiReq, sizeof(fapi_dl_tti_req_t));
+#endif
+   return ROK;
+}
+
+/*******************************************************************
+*
+* @brief Handles Ul Tti request received from MAC
+*
+* @details
+*
+*    Function : l1HdlUlTtiReq
+*
+*    Functionality:
+*          -Handles Ul Tti request received from MAC
+*
+* @params[in]   Message length
+*               Ul Tti request message pointer
+*
+* @return void
+*
+* ****************************************************************/
 
-   SPutSBuf(0, 0, (Data *)dlTtiReq, sizeof(fapi_dl_tti_req_t));
+PUBLIC S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg)
+{
+#ifdef FAPI
+   fapi_ul_tti_req_t *ulTtiReq;
+   ulTtiReq = (fapi_ul_tti_req_t *)msg;
+   uint8_t numPdus = ulTtiReq->nPdus;
+       if(numPdus == 0)
+       {
+               DU_LOG("\nPHY STUB: No PDU in UL TTI \n");
+   }
+       while(numPdus)
+       {
+               if(ulTtiReq->pdus->pduType == 0)
+                       DU_LOG("\n PHY STUB: PRACH PDU\n");
+               numPdus--;
+       }
+       MAC_FREE(ulTtiReq, sizeof(fapi_ul_tti_req_t));
 #endif
    return ROK;
 }
+
 /*******************************************************************
  *
  * @brief Receives message from MAC
@@ -428,6 +468,9 @@ void processFapiRequest(uint8_t msgType, uint32_t msgLen, void *msg)
       case FAPI_DL_TTI_REQUEST:
          l1HdlDlTtiReq(msgLen, msg);
          break;
+      case FAPI_UL_TTI_REQUEST:
+         l1HdlUlTtiReq(msgLen, msg);
+         break;
       default:
          DU_LOG("\nPHY_STUB: Invalid message type[%x] received at PHY", msgType);
          break;