[Epic-Id: ODUHIGH-576][Task-Id: ODUHIGH-594][SubTask-Id: ODUHIGH-617] | NFAPI_BRANCH... 05/13205/2
authorsvaidhya <svaidhya@radisys.com>
Tue, 23 Jul 2024 09:44:21 +0000 (15:14 +0530)
committersvaidhya <svaidhya@radisys.com>
Mon, 5 Aug 2024 05:08:24 +0000 (10:38 +0530)
Change-Id: I518c4d0ae1edbfb59e0f1d25902ee79ee31fc06d
Signed-off-by: svaidhya <svaidhya@radisys.com>
src/5gnrmac/nfapi_p7_msg_hdl.c
src/pnf_stub/pnf_stub.h
src/pnf_stub/pnf_stub_p7_msg_hdl.c
src/pnf_stub/pnf_stub_p7_udp.h

index 8edcce7..6c777f1 100644 (file)
@@ -1073,6 +1073,214 @@ uint8_t nfapiP7ProcRxDataInd(Buffer *mBuf)
     return ret;
 }
 
+/*******************************************************************
+ *
+ * @brief Fills Uci Ind Pdu Info carried on Pucch Format 0/Format 1
+ *
+ * @details
+ *
+ *    Function : nfapiFillUciIndPucchF0F1
+ *
+ *    Functionality:
+ *       Fills Uci Ind Pdu Info carried on Pucch Format 0/Format 1
+ *
+ *@params[in] UciPucchF0F1 *
+ *            fapi_uci_o_pucch_f0f1_t *
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t nfapiFillUciIndPucchF0F1(UciPucchF0F1 *pduInfo, fapi_uci_o_pucch_f0f1_t *fapiPduInfo)
+{
+   uint8_t harqIdx;
+  
+   if(fapiPduInfo == NULLP)
+   {
+      DU_LOG("\nERROR  --> NFAPI_VNF: nfapiFillUciIndPucchF0F1(): UCI PDU is NULL ");
+      return RFAILED;
+   }
+
+   pduInfo->handle        = fapiPduInfo->handle;
+   pduInfo->pduBitmap     = fapiPduInfo->pduBitmap;
+   pduInfo->pucchFormat   = fapiPduInfo->pucchFormat;
+   pduInfo->ul_cqi        = fapiPduInfo->ul_cqi;
+   pduInfo->crnti         = fapiPduInfo->rnti;
+   pduInfo->timingAdvance = fapiPduInfo->timingAdvance;
+   pduInfo->rssi          = fapiPduInfo->rssi;   
+   if(fapiPduInfo->srInfo.srIndication)
+   {
+      pduInfo->srInfo.srIndPres = fapiPduInfo->srInfo.srIndication;
+      pduInfo->srInfo.srConfdcLevel = fapiPduInfo->srInfo.srConfidenceLevel;
+   }
+   if(fapiPduInfo->harqInfo.numHarq)
+   {
+      pduInfo->harqInfo.numHarq = fapiPduInfo->harqInfo.numHarq;
+      pduInfo->harqInfo.harqConfdcLevel = fapiPduInfo->harqInfo.harqConfidenceLevel;
+      for(harqIdx = 0; harqIdx < pduInfo->harqInfo.numHarq; harqIdx++)
+      {
+         pduInfo->harqInfo.harqValue[harqIdx] = fapiPduInfo->harqInfo.harqValue[harqIdx];
+      }
+   }
+   return ROK;
+}
+
+/*******************************************************************
+ *
+ * @brief Build And Sends UCI indication to MAC
+ *
+ * @details
+ *
+ *    Function : nfapiSendUciIndToMac
+ *
+ *    Functionality:
+ *      Builds and Sends EVENT_UCI_IND to MAC
+ *
+ * @params[in] fapi_uci_indication_t message pointer
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t nfapiSendUciIndToMac(fapi_uci_ind_msg_body *nfapiUciInd)
+{
+   uint8_t pduIdx;
+   uint8_t ret = ROK;
+   Pst     pst;
+   UciInd  *macUciInd = NULLP;
+
+   MAC_ALLOC_SHRABL_BUF(macUciInd, sizeof(UciInd));
+   if(!macUciInd)
+   {
+      DU_LOG("ERROR  -->  NFAPI_VNF: Memory Allocation failed in nfapiSendUciIndToMac");
+      return RFAILED;
+   }
+
+   DU_LOG("DEBUG  -->  NFAPI_VNF: Processing UCI Indication");
+   memset(macUciInd, 0, sizeof(UciInd));
+   macUciInd->cellId = vnfDb.cellId;
+   macUciInd->slotInd.sfn = nfapiUciInd->sfn; 
+   macUciInd->slotInd.slot = nfapiUciInd->slot;
+   macUciInd->numUcis = nfapiUciInd->numUcis;
+
+   for(pduIdx = 0; pduIdx < macUciInd->numUcis; pduIdx++)
+   {
+      macUciInd->pdus[pduIdx].pduType = nfapiUciInd->uciPdu[pduIdx].pduType;
+      switch(macUciInd->pdus[pduIdx].pduType)
+      {
+         case UCI_IND_PUSCH:
+         break;
+         case UCI_IND_PUCCH_F0F1:
+         {
+            UciPucchF0F1 *pduInfo = NULLP;
+            macUciInd->pdus[pduIdx].pduSize = nfapiUciInd->uciPdu[pduIdx].pduSize;
+            pduInfo = &macUciInd->pdus[pduIdx].uci.uciPucchF0F1;
+            ret = nfapiFillUciIndPucchF0F1(pduInfo, &nfapiUciInd->uciPdu[pduIdx].uci.uciPucchF0F1);
+            break;
+         }
+         case UCI_IND_PUCCH_F2F3F4:
+            break;
+         default:
+         {
+            DU_LOG("ERROR  -->  NFAPI_VNF: Invalid Pdu Type %d at nfapiSendUciIndToMac()", macUciInd->pdus[pduIdx].pduType);
+                ret = RFAILED;
+            break;
+         }
+      }
+   }
+   if(!ret)
+   {
+      FILL_PST_LWR_MAC_TO_MAC(pst, EVENT_UCI_IND_TO_MAC);
+      pst.selector = ODU_SELECTOR_LWLC;
+      ret = packUciInd(&pst, macUciInd);
+   }
+   else
+   {
+      DU_LOG("ERROR  -->  NFAPI_VNF: Failed sending UCI Ind to MAC");
+   }
+   return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Process FAPI_UCI_IND from PNF
+ *
+ * @details
+ *
+ *    Function : nfapiP7ProcUciInd
+ *
+ *    Functionality:
+ *           Processes FAPI_UCI_IND received from PNF
+ *           Parametes can be referred from SCF222v2222.10.03, Sec 3.4.9
+ *
+ * @params[in] UDP Buffer 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+
+uint8_t nfapiP7ProcUciInd(Buffer *mBuf)
+{
+    uint8_t uciIdx = 0, ret = ROK;
+    uint16_t harqIdx = 0;
+    fapi_uci_ind_msg_body  nfapiUciInd;
+
+    CMCHKPK(oduUnpackUInt16, &(nfapiUciInd.sfn), mBuf); 
+    CMCHKPK(oduUnpackUInt16, &(nfapiUciInd.slot), mBuf); 
+    CMCHKPK(oduUnpackUInt16, &(nfapiUciInd.numUcis), mBuf); 
+
+    for(uciIdx = 0; uciIdx < nfapiUciInd.numUcis; uciIdx++)
+    {
+       CMCHKPK(oduUnpackUInt16, &(nfapiUciInd.uciPdu[uciIdx].pduType), mBuf); 
+       CMCHKPK(oduUnpackUInt16, &(nfapiUciInd.uciPdu[uciIdx].pduSize), mBuf);
+       switch(nfapiUciInd.uciPdu[uciIdx].pduType)
+       {
+          case UCI_IND_PUSCH:
+          break;
+          case UCI_IND_PUCCH_F0F1:
+          {
+             CMCHKPK(oduUnpackUInt32, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.handle), mBuf);
+             CMCHKPK(oduUnpackUInt8, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.pduBitmap), mBuf);
+             CMCHKPK(oduUnpackUInt8, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.pucchFormat), mBuf);
+             CMCHKPK(oduUnpackUInt8, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.ul_cqi), mBuf);
+             CMCHKPK(oduUnpackUInt8, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.pad), mBuf);
+             CMCHKPK(oduUnpackUInt16, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.rnti), mBuf);
+             CMCHKPK(oduUnpackUInt16, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.timingAdvance), mBuf);
+             CMCHKPK(oduUnpackUInt16, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.rssi), mBuf);
+             CMCHKPK(oduUnpackUInt8, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.pad1[0]), mBuf);
+             CMCHKPK(oduUnpackUInt8, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.pad1[1]), mBuf);
+
+             //Extract fapi_sr_f0f1_info_t
+             CMCHKPK(oduUnpackUInt8, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.srInfo.srIndication), mBuf);
+             CMCHKPK(oduUnpackUInt8, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.srInfo.srConfidenceLevel), mBuf);
+             CMCHKPK(oduUnpackUInt8, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.srInfo.pad[0]), mBuf);
+             CMCHKPK(oduUnpackUInt8, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.srInfo.pad[1]), mBuf);
+
+             //Extract fapi_harq_f0f1_info_t
+             CMCHKPK(oduUnpackUInt8, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.harqInfo.numHarq), mBuf);
+             CMCHKPK(oduUnpackUInt8, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.harqInfo.harqConfidenceLevel), mBuf);
+             for(harqIdx = 0;harqIdx <nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.harqInfo.numHarq;harqIdx++)
+             {
+                CMCHKPK(oduUnpackUInt8, &(nfapiUciInd.uciPdu[uciIdx].uci.uciPucchF0F1.harqInfo.harqValue[harqIdx]), mBuf);
+             
+             }
+
+             break;
+          }
+          case UCI_IND_PUCCH_F2F3F4:
+          break;
+          default:
+          {
+             DU_LOG("ERROR  --> NFAPI_VNF: Incorrect UCI PDUType:%d",nfapiUciInd.uciPdu[uciIdx].pduType);
+             return RFAILED;
+          }
+       }
+    }
+
+    ret = nfapiSendUciIndToMac(&nfapiUciInd);
+    return ret; 
+}
+
+
 /*******************************************************************
  *
  * @brief Processed the NFAPI P7 message from UDP socket 
@@ -1125,6 +1333,12 @@ uint8_t nfapiP7MsgHandler(Buffer *mBuf)
          nfapiP7ProcRxDataInd(mBuf);
          break;
       }
+      case FAPI_UCI_INDICATION:
+      {
+         DU_LOG("INFO  --> NFAPI_VNF: Received UCI INDICATIOn");
+         nfapiP7ProcUciInd(mBuf);
+         break;
+      }
       default:
       {
          DU_LOG("ERROR --> NFAPI_VNF: Wrong MsgId:%d", msgHdr.msg_id);
index 36a87fc..40edd3c 100644 (file)
    _sfnSlot.sfn = _delta / NUM_SLOTS_PER_SUBFRAME;   \
 }
 
+#define ADD_DELTA_TO_TIME(crntTime, toFill, incr, numOfSlot)          \
+{                                                          \
+   if ((crntTime.slot + incr) > (numOfSlot - 1))           \
+   {                                                       \
+      toFill.sfn = (crntTime.sfn + 1);                     \
+   }                                                       \
+   else                                                    \
+   {                                                       \
+      toFill.sfn = crntTime.sfn;                           \
+   }                                                       \
+   toFill.slot = (crntTime.slot + incr) % numOfSlot;       \
+   if (toFill.sfn >= 1024)                              \
+   {                                                       \
+      toFill.sfn %= 1024;                                 \
+   }                                                       \
+}
+
 /*P7 UDP Teansport Cfg Details*/
 #define PNF_P7_UDP_PORT 9876
 #define VNF_P7_UDP_PORT 6789
 #define PUSCH_PDU_TYPE 1
 #define PUCCH_PDU_TYPE 2
 
+//UCI
+#define UCI_IND_PUSCH     0      /* UCI Indication carried on PUSCH */
+#define UCI_IND_PUCCH_F0F1   1   /* UCI Indication carried on PUCCH Format 0, 1 */
+#define UCI_IND_PUCCH_F2F3F4 2   /* UCI Indication carried on PUCCH Format 2, 3, 4 */
+#define SR_PDU_BITMASK    1      /* Bit Mask for SR_PDU */
+#define HARQ_PDU_BITMASK  2      /* Bit Mask for HARQ PDU */
+#define SR_NOT_DETECTED   0      /* SR not detected */
+#define SR_DETECTED       1      /* SR detected */
+#define CONFDC_LEVEL_GOOD 0      /* Confidence Level HARQ/SR */
+#define CONFDC_LEVEL_BAD  1
+#define SLOT_DELAY        3
+
 uint32_t PER_TTI_TIME_USEC;
 uint8_t  NUM_SLOTS_PER_SUBFRAME;
 
index 5f3c9b0..7817938 100644 (file)
@@ -39,6 +39,7 @@
 #include "pnf_stub.h"
 
 extern PnfGlobalCb pnfCb;
+extern uint8_t  NUM_SLOTS_PER_SUBFRAME;
 
 /*********************************************************************************
  * @Brief: Filling of Ul Node Sync
@@ -369,7 +370,7 @@ uint16_t pnfBuildAndSendCrcInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu_t
  * ****************************************************************/
 uint16_t pnfBuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu_t puschPdu)
 {
-   uint8_t idx = 0, ueId = 0;
+   uint8_t idx = 0, ueId = 0, pduIdx = 0;
    fapi_rx_data_indication_t *rxDataInd =NULLP;
    fapi_pdu_ind_info_t       *pduInfo =NULLP;
    uint8_t  *pdu = NULLP;
@@ -491,7 +492,6 @@ uint16_t pnfBuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu
             byteIdx++;
             break;
          }
-#if 0
       case MSG_TYPE_SHORT_BSR:
          {
             DU_LOG("DEBUG  -->  NFAPI_PNF: Forming SHORT BSR PDU ");
@@ -523,15 +523,19 @@ uint16_t pnfBuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu
           * RLC subheader for AM PDU is D/C/P/SI/SN (2 bytes for 12-bit SN)
           * From 38.322, section 6.2.2.4
           */
-         DU_LOG("DEBUG  -->  PHY_STUB: Forming MSG5 PDU");
+         DU_LOG("DEBUG  -->  NFAPI_PNF: Forming MSG5 PDU");
          uint8_t  msg5PduLen = 33; /* Length of MSG5 */
          msg5PduLen += 2; /* RLC subheader */
          uint8_t msg5[] = {1, msg5PduLen, 128, pnfCb.pnfUeCb[ueId-1].rlcSnForSrb1++, 0, pnfCb.pnfUeCb[ueId-1].pdcpSn++, 16, 0, \
             5, 223, 128, 16, 94, 64, 3, 64, 68, 252, 97, 0, 0, 0, 0, 4, 0, 0, 4, 68, 11, 128, 184, 56, 0, 0, 0, 0, 0};
 
          msg5PduLen += 2;  /* 2 bytes of MAC header */
-         memcpy(pdu, &msg5, msg5PduLen);
-         byteIdx += msg5PduLen; /* 4 bytes of header : MAC+RLC */
+
+         for(pduIdx = 0; pduIdx < msg5PduLen; pduIdx++)
+         {
+             CMCHKPK(oduPackPostUInt8, msg5[pduIdx], mBuf);
+             byteIdx++;
+         }
          break;
       }
 
@@ -547,7 +551,7 @@ uint16_t pnfBuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu
           * RLC subheader for AM PDU is D/C/P/SI/SN (2 bytes for 12-bit SN)
           * From 38.322, section 6.2.2.4
           */
-         DU_LOG("DEBUG  -->  PHY_STUB: Forming AUTHENTICATION RESPONSE PDU");
+         DU_LOG("DEBUG  -->  NFAPI_PNF: Forming AUTHENTICATION RESPONSE PDU");
          uint8_t  pduLen = 37; /* Length of PDU */
          pduLen += 2; /* RLC subheader */
          uint8_t msg[] = {1, pduLen, 128, pnfCb.pnfUeCb[ueId-1].rlcSnForSrb1++, 0, pnfCb.pnfUeCb[ueId-1].pdcpSn++, 0x3a, \
@@ -555,8 +559,11 @@ uint16_t pnfBuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu
                           0x8b, 0xea, 0xae, 0x45, 0xd1, 0x01, 0xfd, 0x34, 0xd4, 0xfd, 0xd5, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00};
 
          pduLen += 2;  /* 2 bytes of MAC header */
-         memcpy(pdu, &msg, pduLen);
-         byteIdx += pduLen; /* 4 bytes of header : MAC+RLC */
+         for(pduIdx = 0; pduIdx < pduLen; pduIdx++)
+         {
+             CMCHKPK(oduPackPostUInt8, msg[pduIdx], mBuf);
+             byteIdx++;
+         }
          break;
       }
       
@@ -572,7 +579,7 @@ uint16_t pnfBuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu
           * RLC subheader for AM PDU is D/C/P/SI/SN (2 bytes for 12-bit SN)
           * From 38.322, section 6.2.2.4
           */
-         DU_LOG("DEBUG  -->  PHY_STUB: Forming NAS SECURITY MODE COMPLETE PDU");
+         DU_LOG("DEBUG  -->  NFAPI_PNF: Forming NAS SECURITY MODE COMPLETE PDU");
          uint8_t  pduLen = 93; /* Length of PDU */
          pduLen += 2; /* RLC subheader */
          uint8_t msg[] = {1, pduLen, 128, pnfCb.pnfUeCb[ueId-1].rlcSnForSrb1++, 0, pnfCb.pnfUeCb[ueId-1].pdcpSn++, 0x3a, 0x2a, 0x3f, 
@@ -583,8 +590,11 @@ uint16_t pnfBuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu
                           0x50, 0x0c, 0x00, 0x80, 0x3a, 0x00, 0x00, 0x48, 0x29, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00};
 
          pduLen += 2;  /* 2 bytes of MAC header */
-         memcpy(pdu, &msg, pduLen);
-         byteIdx += pduLen; /* 4 bytes of header : MAC+RLC */
+         for(pduIdx = 0; pduIdx < pduLen; pduIdx++)
+         {
+             CMCHKPK(oduPackPostUInt8, msg[pduIdx], mBuf);
+             byteIdx++;
+         }
          break;
       }
 
@@ -600,15 +610,18 @@ uint16_t pnfBuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu
           * RLC subheader for AM PDU is D/C/P/SI/SN (2 bytes for 12-bit SN)
           * From 38.322, section 6.2.2.4
           */
-         DU_LOG("DEBUG  -->  PHY_STUB: Forming RRC SECURITY MODE COMPLETE PDU");
+         DU_LOG("DEBUG  -->  NFAPI_PNF: Forming RRC SECURITY MODE COMPLETE PDU");
          uint8_t  pduLen = 12; /* Length of PDU */
          pduLen += 2; /* RLC subheader */
          uint8_t msg[] = {1, pduLen, 128, pnfCb.pnfUeCb[ueId-1].rlcSnForSrb1++, 0, pnfCb.pnfUeCb[ueId-1].pdcpSn++, 0x2a, 0x40, \
             0, 0, 0, 0, 0, 0, 0, 0};
 
          pduLen += 2;  /* 2 bytes of MAC header */
-         memcpy(pdu, &msg, pduLen);
-         byteIdx += pduLen; /* 4 bytes of header : MAC+RLC */
+         for(pduIdx = 0; pduIdx < pduLen; pduIdx++)
+         {
+             CMCHKPK(oduPackPostUInt8, msg[pduIdx], mBuf);
+             byteIdx++;
+         }
          break;
       }
 
@@ -624,15 +637,18 @@ uint16_t pnfBuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu
           * RLC subheader for AM PDU is D/C/P/SI/SN (2 bytes for 12-bit SN)
           * From 38.322, section 6.2.2.4
           */
-         DU_LOG("DEBUG  -->  PHY_STUB: Forming RRC REGISTRATION COMPLETE PDU");
+         DU_LOG("DEBUG  -->  NFAPI_PNF: Forming RRC REGISTRATION COMPLETE PDU");
          uint8_t  pduLen = 12; /* Length of PDU */
          pduLen += 2; /* RLC subheader */
          uint8_t msg[] = {1, pduLen, 128, pnfCb.pnfUeCb[ueId-1].rlcSnForSrb1++, 0, pnfCb.pnfUeCb[ueId-1].pdcpSn++, 0x3a, 0x81, \
             0xbf, 0, 0x21, 0x80, 0, 0, 0, 0};
 
          pduLen += 2;  /* 2 bytes of MAC header */
-         memcpy(pdu, &msg, pduLen);
-         byteIdx += pduLen; /* 4 bytes of header : MAC+RLC */
+         for(pduIdx = 0; pduIdx < pduLen; pduIdx++)
+         {
+             CMCHKPK(oduPackPostUInt8, msg[pduIdx], mBuf);
+             byteIdx++;
+         }
          break;
       }
 
@@ -648,19 +664,20 @@ uint16_t pnfBuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu
           * RLC subheader for AM PDU is D/C/P/SI/SN (2 bytes for 12-bit SN)
           * From 38.322, section 6.2.2.4
           */
-         DU_LOG("DEBUG  -->  PHY_STUB: Forming RRC RECONFIGURATION COMPLETE PDU");
+         DU_LOG("DEBUG  -->  NFAPI_PNF: Forming RRC RECONFIGURATION COMPLETE PDU");
          uint8_t  pduLen = 13; /* PDU length */
          pduLen += 2; /* RLC sub header */
          uint8_t msg[] = {1, pduLen, 128, pnfCb.pnfUeCb[ueId-1].rlcSnForSrb1++, 0, pnfCb.pnfUeCb[ueId-1].pdcpSn++, 8, 64, 0, 0,\
             0, 0, 0, 0, 0, 0, 0};
 
          pduLen += 2;  /* 2bytes of MAC header */
-         memcpy(pdu, &msg, pduLen);
-         byteIdx += pduLen; /* 4 bytes of header : MAC+RLC*/
+         for(pduIdx = 0; pduIdx < pduLen; pduIdx++)
+         {
+             CMCHKPK(oduPackPostUInt8, msg[pduIdx], mBuf);
+             byteIdx++;
+         }
          break;
-
       }
-#endif
       default:
       break;
    } /* End of switch(type) */
@@ -692,6 +709,207 @@ uint16_t pnfBuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu
    return ROK;
 }
 
+/*******************************************************************
+ *
+ * @brief Fills Uci Ind Pdu Info carried on Pucch Format 0/Format 1
+ *
+ * @details
+ *
+ *    Function : pnfFillPucchF0F1PduInfo
+ *
+ *    Functionality:
+ *       Fills Uci Ind Pdu Info carried on Pucch Format 0/Format 1 
+ *
+ * @params[in] fapi_uci_o_pucch_f0f1_t *
+ *             pucchPdu
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t pnfFillPucchF0F1PduInfo(fapi_uci_o_pucch_f0f1_t *pduInfo, fapi_ul_pucch_pdu_t pucchPdu)
+{
+   uint8_t idx = 0;
+   static uint8_t ind=0;
+   uint8_t result[]={0,//msg4
+                     0,//Security Mode Command
+                     0,//Registration Accept
+                     0,//RRC Reconfiguration
+                     0,//Data 1
+                     0,//Data 2
+                     0,//Data 3
+                     0,//Data 4
+                     0,0,0,0,0,
+                     0,0,0,0,0,
+                     0,0,0,0,0,
+                     0,0,0,0,0,
+                     0,0,0,0,0,
+                     0,0,0,0,0,
+                     0,0,0,0,0,
+                     0,0,0,0,0,
+                     0,0,0,0,0,
+                     0,0,0,0,0,
+                     0,0,0,0,0,
+                     0,0,0,0,0,
+                     0,0,0,0,0,};
+
+   pduInfo->handle = pucchPdu.handle;
+   pduInfo->pduBitmap = 1;  //hardcoded for SR
+   if (pucchPdu.bitLenHarq)
+   {
+      pduInfo->pduBitmap |= HARQ_PDU_BITMASK;
+   }
+   pduInfo->pucchFormat = pucchPdu.formatType;
+   pduInfo->ul_cqi = 0;
+   pduInfo->rnti = pucchPdu.rnti;
+   pduInfo->timingAdvance = 0;
+   pduInfo->rssi = 0;
+   if(pduInfo->pduBitmap & SR_PDU_BITMASK)
+   {
+      if (result[ind % sizeof(result)] == 0)
+      {
+         pduInfo->srInfo.srIndication = SR_DETECTED;
+         pduInfo->srInfo.srConfidenceLevel = CONFDC_LEVEL_GOOD;
+      }
+   }
+   if(pduInfo->pduBitmap & HARQ_PDU_BITMASK)
+   {
+      pduInfo->harqInfo.numHarq++;
+      pduInfo->harqInfo.harqConfidenceLevel = CONFDC_LEVEL_GOOD;
+      for(idx = 0; idx < pduInfo->harqInfo.numHarq; idx++)
+      {
+         pduInfo->harqInfo.harqValue[idx] = result[ind % sizeof(result)];
+         ind++;
+      }
+   }
+   return ROK;
+}
+/*******************************************************************
+ *
+ * @brief Fills UCI Pdu Information
+ *
+ * @details
+ *
+ *    Function : pnfFillUciPduInfo
+ *
+ *    Functionality:
+ *       Fills UCI Pdu Information
+ *
+ * @params[in] Pointer to mBuf
+ *             pucchPdu
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t pnfFillUciPduInfo(Buffer *mBuf, fapi_ul_pucch_pdu_t pucchPdu)
+{
+   uint8_t ret = ROK, harqIdx = 0;
+   fapi_uci_pdu_info_t uciPduInfo;
+  
+   memset(&uciPduInfo, 0, sizeof(fapi_uci_pdu_info_t));
+
+   uciPduInfo.pduType = UCI_IND_PUCCH_F0F1;
+   /*TODO: The pduType is hardcoded here to support 
+     UCI Ind for PUCCH forat0/format1. This is to be
+     modified when we get SR form UE */
+   switch(uciPduInfo.pduType)
+   {
+      case UCI_IND_PUSCH:
+         break;
+      case UCI_IND_PUCCH_F0F1:
+         {
+            fapi_uci_o_pucch_f0f1_t *pduInfo = NULLP;
+
+            pduInfo = &uciPduInfo.uci.uciPucchF0F1;
+            memset(pduInfo, 0, sizeof(fapi_uci_o_pucch_f0f1_t));
+            ret = pnfFillPucchF0F1PduInfo(pduInfo, pucchPdu);
+            uciPduInfo.pduSize = sizeof(fapi_uci_o_pucch_f0f1_t);
+            
+            CMCHKPK(oduPackPostUInt16, uciPduInfo.pduType, mBuf);
+            CMCHKPK(oduPackPostUInt16, uciPduInfo.pduSize, mBuf);
+            CMCHKPK(oduPackPostUInt32, pduInfo->handle, mBuf);
+            CMCHKPK(oduPackPostUInt8, pduInfo->pduBitmap, mBuf);
+            CMCHKPK(oduPackPostUInt8, pduInfo->pucchFormat, mBuf);
+            CMCHKPK(oduPackPostUInt8, pduInfo->ul_cqi, mBuf);
+            CMCHKPK(oduPackPostUInt8, 0, mBuf);//pad
+            CMCHKPK(oduPackPostUInt16, pduInfo->rnti, mBuf);//pad
+            CMCHKPK(oduPackPostUInt16, pduInfo->timingAdvance, mBuf);
+            CMCHKPK(oduPackPostUInt16, pduInfo->rssi, mBuf);
+            CMCHKPK(oduPackPostUInt8, 0, mBuf);//pad1[0]
+            CMCHKPK(oduPackPostUInt8, 0, mBuf);//pad1[1]
+
+            //Fill fapi_sr_f0f1_info_t
+            CMCHKPK(oduPackPostUInt8, pduInfo->srInfo.srIndication, mBuf);
+            CMCHKPK(oduPackPostUInt8, pduInfo->srInfo.srConfidenceLevel, mBuf);
+            CMCHKPK(oduPackPostUInt8, 0, mBuf); //pad[0]
+            CMCHKPK(oduPackPostUInt8, 0, mBuf); //pad[1]
+             
+            //Fill fapi_harq_f0f1_info_t
+            CMCHKPK(oduPackPostUInt8, pduInfo->harqInfo.numHarq, mBuf);
+            CMCHKPK(oduPackPostUInt8, pduInfo->harqInfo.harqConfidenceLevel, mBuf);
+            for(harqIdx = 0; harqIdx < pduInfo->harqInfo.numHarq; harqIdx++)
+            {
+               CMCHKPK(oduPackPostUInt8, pduInfo->harqInfo.harqValue[harqIdx], mBuf);
+            }
+         }
+         break;
+      case UCI_IND_PUCCH_F2F3F4:
+         break;
+      default:
+         DU_LOG("ERROR  -->  PHY_STUB: Invalid Pdu Type %d", uciPduInfo.pduType);
+         break;
+   }
+   return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Build and send Uci indication
+ *
+ * @details
+ *
+ *    Function : l1BuildAndSendUciInd
+ *
+ *    Functionality:
+ *       Build and send Uci indication
+ *
+ * @params[in] SFN
+ *             Slot
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t pnfBuildAndSendUciInd(PnfSlotInfo ulSlotInfo, fapi_ul_pucch_pdu_t pucchPdu)
+{
+   uint8_t ret = ROK;
+   Buffer *mBuf = NULLP;
+
+   if (ODU_GET_MSG_BUF(PNF_APP_MEM_REG, PNF_POOL, &mBuf) != ROK)
+   {
+      DU_LOG("ERROR  --> NFAPI_PNF : Memory allocation failed in start response");
+      return RFAILED;
+   }
+   nfapiFillP7Hdr(mBuf, (sizeof(fapi_uci_ind_msg_body) + sizeof(nFapi_msg_header)), 0, 0);
+   nfapiFillMsgHdr(mBuf, 1, FAPI_UCI_INDICATION, sizeof(fapi_uci_ind_msg_body));
+
+   CMCHKPK(oduPackPostUInt16, ulSlotInfo.sfn, mBuf);
+   CMCHKPK(oduPackPostUInt16, ulSlotInfo.slot, mBuf);
+   CMCHKPK(oduPackPostUInt16, 1, mBuf); //numUcis
+   
+   ret = pnfFillUciPduInfo(mBuf, pucchPdu);
+
+   if(ret == ROK)
+   {
+      /* Sending UCI indication to MAC */
+      DU_LOG("INFO   -->  NFAPI_PNF : Sending UCI Indication to VNF");
+      if(pnfP7UdpSendMsg(mBuf) != ROK)
+      { 
+         return RFAILED;
+      }
+   }
+   return ret;
+}
+
 /*********************************************************************************
  * @Brief: Processes UL_TTI_REQ received from VNF
  *
@@ -705,7 +923,7 @@ uint16_t pnfBuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu
  *
  * ******************************************************************************/
 
-void pnfProcUlTtiReq(fapi_ul_tti_req_msg_body *pnfUlTtiReq)
+uint8_t pnfProcUlTtiReq(fapi_ul_tti_req_msg_body *pnfUlTtiReq)
 {
    uint8_t numPdus = pnfUlTtiReq->nPdus;
    uint8_t ret = ROK;
@@ -745,7 +963,13 @@ void pnfProcUlTtiReq(fapi_ul_tti_req_msg_body *pnfUlTtiReq)
       if(pnfUlTtiReq->pdus[numPdus-1].pduType == PUCCH_PDU_TYPE)
       {
          DU_LOG("INFO   --> NFAPI_PNF: PUCCH PDU");
-         /*TODO: UCI_IND to be built and sent*/ 
+         
+         PnfSlotInfo ulTtiSlotInfo;
+         memset(&ulTtiSlotInfo, 0, sizeof(PnfSlotInfo));
+         ulTtiSlotInfo.slot = pnfUlTtiReq->slot;
+         ulTtiSlotInfo.sfn  = pnfUlTtiReq->sfn;
+         ADD_DELTA_TO_TIME(ulTtiSlotInfo, ulTtiSlotInfo, SLOT_DELAY, NUM_SLOTS_PER_SUBFRAME);
+         pnfBuildAndSendUciInd(ulTtiSlotInfo, pnfUlTtiReq->pdus[numPdus-1].pdu.pucch_pdu);
       }
       numPdus--;
    }
@@ -930,12 +1154,16 @@ uint8_t pnfUlTtiReq(Buffer *mBuf)
          default:
          {
             DU_LOG("ERROR  --> NFAPI_VNF: Incorrect PduType:%d",fapiMsgBody.pdus[pduCnt].pduType);
-            return;
+            return RFAILED;
          }
       }
    }
 
-   pnfProcUlTtiReq(&fapiMsgBody);
+   if(pnfProcUlTtiReq(&fapiMsgBody) != ROK)
+   {
+      DU_LOG("ERROR -> NFAPI_PNF: UL_TTI_REQ processing failed");
+      return RFAILED;
+   }
 
    return ROK;
 }
@@ -979,6 +1207,16 @@ uint8_t  pnfP7MsgHandler(Buffer *mBuf)
          ret = pnfUlTtiReq(mBuf);
          break;
       }
+      case FAPI_TX_DATA_REQUEST:
+      {
+         DU_LOG("\nINFO   --> NFAPI_PNF: TX_DATA_REQ recevied.");
+         break;
+      }
+      case FAPI_UL_DCI_REQUEST:
+      {
+         DU_LOG("\nINFO   --> NFAPI_PNF: UL_DCI_REQ recevied.");
+         break;
+      }
       default:
       {
          DU_LOG("ERROR  --> NFAPI_PNF: Wrong MSGID of NFAPI P7 Message:%d",msgHdr.msg_id);
index 6ebaf49..69961e9 100644 (file)
@@ -42,6 +42,7 @@ PnfP7UdpGlobalCb pnfP7Cb;
 uint8_t pnfP7UdpActvInit();
 uint8_t pnfP7UdpCfgReq();
 void    pnfP7UdpHdlRecvMsg(Buffer *buf);
+S16 pnfP7UdpSendMsg(Buffer *mBuf);
 
 #endif