JIRA ID: ODUHIGH-235 Implementation of RRC Reconfig and RRC Registration 17/5017/6
authorsphoorthi <sphoorthi.dayanand@radisys.com>
Mon, 9 Nov 2020 15:29:56 +0000 (20:59 +0530)
committersphoorthi <sphoorthi.dayanand@radisys.com>
Thu, 19 Nov 2020 07:10:10 +0000 (12:40 +0530)
Change-Id: If295e2ba70dde2d718ff4a8dc4d41cfe3dbbe792
Signed-off-by: sphoorthi <sphoorthi.dayanand@radisys.com>
Signed-off-by: lal.harshita <harshita.lal@radisys.com>
Signed-off-by: sphoorthi <sphoorthi.dayanand@radisys.com>
src/cu_stub/cu_f1ap_msg_hdl.c
src/cu_stub/cu_f1ap_msg_hdl.h
src/du_app/du_f1ap_msg_hdl.c
src/phy_stub/l1.h
src/phy_stub/l1_bdy1.c

index 0cfc141..6c23d0f 100644 (file)
@@ -1512,20 +1512,61 @@ uint8_t fillDlDcchRrcMsg(RRCContainer_t *rrcContainer)
 
 uint8_t        BuildDLRRCContainer(uint8_t rrcMsgType, RRCContainer_t *rrcContainer)
 {
-   uint8_t ret = ROK;
-
+   uint8_t ret, idx2, bufLen;
+   
+   ret =ROK;
    if(rrcMsgType == RRC_SETUP)
    { 
       ret = fillDlCcchRrcMsg(rrcContainer);
       if(ret == RFAILED)
-         DU_LOG("\n F1AP: Failed to fill DL-CCCH Msg at BuildDLRRCContainer()");
+          DU_LOG("\n F1AP: Failed to fill DL-CCCH Msg at RRC SETUP");
+   }
+   else if(rrcMsgType == REGISTRATION_ACCEPT)
+   {
+      /*Hardcoded RRC Container from reference logs*/
+      char buf[14] ={0x00, 0x03, 0x2a, 0x80, 0xaf, 0xc0, 0x08, 0x40, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00};
+      bufLen =14;
+      rrcContainer->size = bufLen;
+      CU_ALLOC(rrcContainer->buf, rrcContainer->size);
+      if(rrcContainer->buf != NULLP)
+      {
+         memset(rrcContainer->buf, 0, encBufSize);
+         for(idx2 = 0; idx2 < encBufSize; idx2++)
+         {
+            rrcContainer->buf[idx2] = buf[idx2];
+         }
+      }
    }
    else if(rrcMsgType == RRC_RECONFIG)
    {
-      ret = fillDlDcchRrcMsg(rrcContainer);
-      if(ret == RFAILED)
-         DU_LOG("\n F1AP: Failed at fill DL-DCCH Msg at BuildDLRRCContainer()");
+      /*Hardcoded RRC Container from reference logs*/
+      char buf[196]= { 
+      0x00, 0x04, 0x00, 0xaa, 0x80, 0x40, 0x9a, 0x05, 0x20, 0x00, 0x05, 0xeb, 0xc0, 0x51, 0x50, 0x00,
+      0x03, 0x00, 0x03, 0xf7, 0x56, 0xec, 0x7f, 0x08, 0x42, 0x10, 0x80, 0x00, 0x10, 0x21, 0x47, 0x84,
+      0xd1, 0x00, 0x00, 0x00, 0x02, 0x81, 0x5d, 0x10, 0x0a, 0xc2, 0x44, 0x40, 0x2b, 0xb2, 0x07, 0x41,
+      0x87, 0xa8, 0x02, 0xc7, 0x00, 0x88, 0x05, 0x76, 0x40, 0xe8, 0x30, 0xf5, 0x40, 0x4c, 0x00, 0x10,
+      0x02, 0x00, 0xa5, 0x83, 0xe0, 0x60, 0x02, 0x10, 0x72, 0x01, 0x0c, 0xa0, 0xa0, 0xd8, 0x00, 0x00,
+      0x00, 0x01, 0x0f, 0x02, 0x3c, 0x01, 0x80, 0x10, 0x82, 0xb0, 0x40, 0x00, 0x00, 0x02, 0x1e, 0x04,
+      0x78, 0x07, 0x00, 0x21, 0x05, 0x61, 0x00, 0x00, 0x00, 0x04, 0x3c, 0x08, 0xf0, 0x16, 0x00, 0x42,
+      0x0a, 0xc3, 0x00, 0x00, 0x00, 0x08, 0x78, 0x11, 0xe0, 0x3c, 0x00, 0x84, 0x14, 0x00, 0x07, 0xe5,
+      0xc0, 0xa0, 0xd8, 0x42, 0x20, 0x02, 0x80, 0xa0, 0x02, 0x24, 0x47, 0xa0, 0x20, 0x27, 0xa1, 0x22,
+      0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x24, 0x41, 0x20, 0xc0, 0x80, 0x00, 0x20, 0x80,
+      0x00, 0x25, 0x20, 0xa0, 0x38, 0x00, 0x00, 0x00, 0x44, 0xa2, 0x82, 0x69, 0xee, 0x0c, 0xad, 0xca,
+      0x4c, 0x2c, 0x8d, 0x2e, 0x6f, 0x2e, 0x69, 0x2d, 0xce, 0x8c, 0xae, 0x4d, 0xcc, 0xae, 0x80, 0x00,
+      0x00, 0x00, 0x00, 0x00};
+      bufLen =196;
+      rrcContainer->size = bufLen;
+      CU_ALLOC(rrcContainer->buf, rrcContainer->size);
+      if(rrcContainer->buf != NULLP)
+      {
+         memset(rrcContainer->buf, 0, encBufSize);
+         for(idx2 = 0; idx2 < encBufSize; idx2++)
+         {
+            rrcContainer->buf[idx2] = buf[idx2];
+         }
+      }
    }
+   
    return ret;
 }
 
@@ -1546,7 +1587,7 @@ uint8_t   BuildDLRRCContainer(uint8_t rrcMsgType, RRCContainer_t *rrcContainer)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t BuildAndSendDLRRCMessageTransfer(uint8_t rrcMsgType)
+uint8_t BuildAndSendDLRRCMessageTransfer(uint8_t srbId, uint8_t rrcMsgType)
 {
    uint8_t   elementCnt = 0;
    uint8_t  ieId;
@@ -1635,7 +1676,7 @@ uint8_t BuildAndSendDLRRCMessageTransfer(uint8_t rrcMsgType)
    dlRRCMsg->protocolIEs.list.array[idx]->criticality  =   Criticality_reject;
    dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
                                                          DLRRCMessageTransferIEs__value_PR_SRBID;
-   dlRRCMsg->protocolIEs.list.array[idx]->value.choice.SRBID = SRB0;
+   dlRRCMsg->protocolIEs.list.array[idx]->value.choice.SRBID = srbId;
 
    /* RRCContainer */
    idx++;
@@ -1704,8 +1745,11 @@ uint8_t setDlRRCMsgType()
       case RRC_SETUP:
         rrcMsgType = RRC_SETUP;
         break;
-      case RRC_SECURITY_MODE_COMMAND:
-        rrcMsgType = RRC_SECURITY_MODE_COMMAND;
+      case REGISTRATION_ACCEPT:
+        rrcMsgType = REGISTRATION_ACCEPT;
+        break;
+      case UE_CONTEXT_SETUP_REQ:
+        rrcMsgType = UE_CONTEXT_SETUP_REQ;
         break;
       case RRC_RECONFIG:
         rrcMsgType = RRC_RECONFIG;
@@ -1788,7 +1832,7 @@ uint8_t procInitULRRCMsg(F1AP_PDU_t *f1apMsg)
    {
       f1apMsgDb.dlRrcMsgCount++;
       rrcMsgType = setDlRRCMsgType();
-      ret = BuildAndSendDLRRCMessageTransfer(rrcMsgType);
+      ret = BuildAndSendDLRRCMessageTransfer(SRB0, rrcMsgType);
    }
    return ret;
 }
@@ -5700,7 +5744,7 @@ uint8_t BuildAndSendUeContextSetupReq(uint8_t cuUeF1apId, uint8_t duUeF1apId, \
    uint8_t   SplCellListret;
    uint8_t   SrbSetupret;
    uint8_t   elementCnt;
-   uint8_t   idx;
+   uint8_t   idx, bufLen;
    uint8_t   idx1;
    F1AP_PDU_t          *f1apMsg = NULLP;
    UEContextSetupRequest_t *ueSetReq = NULLP;
@@ -5858,14 +5902,15 @@ uint8_t BuildAndSendUeContextSetupReq(uint8_t cuUeF1apId, uint8_t duUeF1apId, \
       {        
         break;
       }
-      
-      /* RRC Container */
+      /* RRC Container for security mode */
       idx++;
       ueSetReq->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_RRCContainer;
       ueSetReq->protocolIEs.list.array[idx]->criticality = Criticality_reject;
       ueSetReq->protocolIEs.list.array[idx]->value.present = \
          UEContextSetupRequestIEs__value_PR_RRCContainer;
-      ueSetReq->protocolIEs.list.array[idx]->value.choice.RRCContainer.size = rrcContLen;
+      char buf[9]={0x00, 0x02, 0x22, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00};
+      bufLen =9;
+      ueSetReq->protocolIEs.list.array[idx]->value.choice.RRCContainer.size = bufLen;
       CU_ALLOC(ueSetReq->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf,
           ueSetReq->protocolIEs.list.array[idx]->value.choice.RRCContainer.size);
       if(!ueSetReq->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf)
@@ -5873,8 +5918,11 @@ uint8_t BuildAndSendUeContextSetupReq(uint8_t cuUeF1apId, uint8_t duUeF1apId, \
          DU_LOG(" F1AP : Memory allocation for BuildAndSendUeContextSetupReq failed");
          break;
       }
-      memcpy(ueSetReq->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf, \
-         rrcContainer, ueSetReq->protocolIEs.list.array[idx]->value.choice.RRCContainer.size); 
+      memset(ueSetReq->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf, 0, encBufSize);
+      for(idx1 = 0; idx1 < encBufSize; idx1++)
+      {
+        ueSetReq->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf[idx1] = buf[idx1];
+      }
 
       /* RRC delivery status request */
       idx++;
@@ -5990,13 +6038,16 @@ uint8_t procUlRrcMsg(F1AP_PDU_t *f1apMsg)
    {
       f1apMsgDb.dlRrcMsgCount++;
       rrcMsgType = setDlRRCMsgType();
-      if(rrcMsgType == RRC_SECURITY_MODE_COMMAND)
+      if(rrcMsgType == REGISTRATION_ACCEPT)
       {
-         ret = BuildAndSendUeContextSetupReq(cuUeF1apId, duUeF1apId, rrcContLen, rrcContainer);
+         DU_LOG("\nSending DL RRC MSG for RRC Registration Complete"); 
+         ret = BuildAndSendDLRRCMessageTransfer(srbId, rrcMsgType);
       }
-      if(rrcMsgType == RRC_RECONFIG)
+      if(rrcMsgType == UE_CONTEXT_SETUP_REQ)
       {
-         ret = BuildAndSendDLRRCMessageTransfer(rrcMsgType);
+         DU_LOG("\nSending Ue Context Setup Req"); 
+         ret = BuildAndSendUeContextSetupReq(cuUeF1apId, duUeF1apId,\
+           rrcContLen, rrcContainer);
       }
    }
    return ret;
@@ -6290,7 +6341,16 @@ void F1APMsgHdlr(Buffer *mBuf)
            }
             case SuccessfulOutcome__value_PR_UEContextSetupResponse:
            {
+              uint8_t rrcMsgType;
+
                DU_LOG("\nF1AP : UE ContextSetupResponse received");
+               f1apMsgDb.dlRrcMsgCount++;
+               rrcMsgType = setDlRRCMsgType();
+               if(rrcMsgType == RRC_RECONFIG)
+               {
+                  DU_LOG("\nImplementing DL RRC MSG for RRC Reconfig Complete");
+                  BuildAndSendDLRRCMessageTransfer(SRB1, rrcMsgType);
+               }
                break;
            }
             default:
index d20e756..c2df121 100644 (file)
@@ -58,8 +58,9 @@
 #define CU_TO_DU_RRC_INF 4
 
 #define RRC_SETUP 1
-#define RRC_SECURITY_MODE_COMMAND 2
-#define RRC_RECONFIG 3
+#define REGISTRATION_ACCEPT 2
+#define UE_CONTEXT_SETUP_REQ 3
+#define RRC_RECONFIG 4
 typedef struct f1apDb
 {
    uint8_t dlRrcMsgCount;
index 9eda4f3..2d8a8a9 100644 (file)
@@ -7377,7 +7377,14 @@ uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
            }
         case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
            {
-              duUeCb->f1UeDb->dlRrcMsg->deliveryStatRpt = true;
+              if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
+              {
+                 duUeCb->f1UeDb->dlRrcMsg->deliveryStatRpt = true;
+              }
+              else
+              {
+                 DU_LOG("\nIgnoring delivery report, since rrcContainer is not present");
+              }
               break;
            }
         //TODO: To handle maxAggrBitRate case,
index 97e295d..c058d96 100644 (file)
@@ -29,15 +29,16 @@ bool     msg5ShortBsrSent = false;
 bool     msg5Sent = false;
 bool     dlDedMsg = false;
 bool     msgSecurityModeComp =  false;
-
+bool    msgRrcReconfiguration  =  false;
+bool    msgRegistrationComp    = false;
 typedef enum
 {
    MSG_TYPE_MSG3,
    MSG_TYPE_SHORT_BSR,
    MSG_TYPE_MSG5,
    MSG_TYPE_SECURITY_MODE_COMPLETE,
-   MSG_TYPE_RRC_RECONFIG_COMPLETE,
-   MSG_TYPE_REGISTRATION_COMPLETE
+   MSG_TYPE_REGISTRATION_COMPLETE,
+   MSG_TYPE_RRC_RECONFIG_COMPLETE
 }MsgType;
 
 void phyToMac ARGS((uint16_t msgType, uint32_t msgLen,void *msg));
index a9183c7..7ccee21 100644 (file)
@@ -349,6 +349,7 @@ uint16_t l1BuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu_
    {
       msg3Sent = true;
       type = MSG_TYPE_MSG3;
+      sleep(2);
    }
    else if(!msg5ShortBsrSent)
    {
@@ -360,11 +361,21 @@ uint16_t l1BuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu_
       msg5Sent = true;
       type = MSG_TYPE_MSG5;
    }
+   else if(!msgRegistrationComp)
+   {
+      msgRegistrationComp = true;
+      type = MSG_TYPE_REGISTRATION_COMPLETE; 
+   }
    else if(!msgSecurityModeComp)
    {
       msgSecurityModeComp = true;
       type = MSG_TYPE_SECURITY_MODE_COMPLETE;
    }
+   else if(!msgRrcReconfiguration)
+   {
+      msgRrcReconfiguration = true;
+      type = MSG_TYPE_RRC_RECONFIG_COMPLETE;
+   }
    else
       return RFAILED;
 
@@ -423,63 +434,99 @@ uint16_t l1BuildAndSendRxDataInd(uint16_t slot, uint16_t sfn, fapi_ul_pusch_pdu_
 
            break;
         }
-
       case MSG_TYPE_SHORT_BSR:
-        {
-           DU_LOG("\nPHY_STUB: Forming SHORT BSR PDU ");
-           uint8_t lcgId = 0;
-           uint8_t bufferSizeIdx = 6;
-            
-           /* For Short BSR
-              MAC subheader format is R/R/LcId (1Byte)
-              LCId is 61
-              From 38.321 section 6.1.1
-            */
-           pdu[byteIdx++] = 61;    // LCID
-           pdu[byteIdx++] = (lcgId << 5) | bufferSizeIdx;
+      {
+        DU_LOG("\nPHY_STUB: Forming SHORT BSR PDU ");
+        uint8_t lcgId = 0;
+        uint8_t bufferSizeIdx = 6;
+
+        /* For Short BSR
+           MAC subheader format is R/R/LcId (1Byte)
+           LCId is 61
+           From 38.321 section 6.1.1
+         */
+        pdu[byteIdx++] = 61;    // LCID
+        pdu[byteIdx++] = (lcgId << 5) | bufferSizeIdx;
 
-           break;
-        }
+        break;
+      }
 
       case MSG_TYPE_MSG5:
-        {
-           DU_LOG("\nPHY_STUB: Forming MSG5 PDU");
-           uint8_t  msg5PduLen = 33;
-           /* For RRC setup complete
-              MAC subheader format is R/F/LCId/L (2/3 bytes)
-              LCId is 1 for SRB1
-              L is length of PDU i.e 6bytes here 
-              From 38.321 section 6.1.1
-            */
-           uint8_t msg5[] = {1, msg5PduLen, 0, 0, 16, 0, 5, 223, 128, 16, 94, \
-              64, 3, 64, 89, 61, 138, 64, 0, 0, 0, 4, 0, 0, 4, 68, 11, 128, \
+      {
+        DU_LOG("\nPHY_STUB: Forming MSG5 PDU");
+        uint8_t  msg5PduLen = 33;
+        /* For RRC setup complete
+           MAC subheader format is R/F/LCId/L (2/3 bytes)
+           LCId is 1 for SRB1
+           L is length of PDU i.e 6bytes here 
+           From 38.321 section 6.1.1
+         */
+        uint8_t msg5[] = {1, msg5PduLen, 0, 0, 16, 0, 5, 223, 128, 16, 94, \
+           64, 3, 64, 89, 61, 138, 64, 0, 0, 0, 4, 0, 0, 4, 68, 11, 128, \
               184, 56, 0, 0, 0, 0, 0};
 
-           msg5PduLen += 2;  /* 2bytes of header */
-           memcpy(pdu, &msg5, msg5PduLen);
-           byteIdx += msg5PduLen; /* 2 bytes of header */
-           break;
-        }
+        msg5PduLen += 2;  /* 2bytes of header */
+        memcpy(pdu, &msg5, msg5PduLen);
+        byteIdx += msg5PduLen; /* 2 bytes of header */
+        break;
+      }
 
       case MSG_TYPE_SECURITY_MODE_COMPLETE:
-        {
-           DU_LOG("\nPHY_STUB: Forming SECURITY MODE COMPLETE PDU");
-           uint8_t  pduLen = 33;
-           /* For security mode complete
-              MAC subheader format is R/F/LCId/L (2/3 bytes)
-              LCId is 1 for SRB1
-              L is length of PDU i.e 6bytes here 
-              From 38.321 section 6.1.1
-            */
-           uint8_t msg[] = {1, pduLen, 0, 0, 16, 0, 5, 223, 128, 16, 94, \
-              64, 3, 64, 89, 61, 138, 64, 0, 0, 0, 4, 0, 0, 4, 68, 11, 128, \
-              184, 56, 0, 0, 0, 0, 0};
+      {
+        DU_LOG("\nPHY_STUB: Forming SECURITY MODE COMPLETE PDU");
+        uint8_t  pduLen = 12;
+        /* For security mode complete where RRC Container is dummy
+           MAC subheader format is R/F/LCId/L (2/3 bytes)
+           LCId is 1 for SRB1
+           L is length of PDU i.e 6bytes here 
+           From 38.321 section 6.1.1
+         */
+        uint8_t msg[] = {1, pduLen, 0, 3, 0x2a, 0x40, 0, 0, 0, 0, 0, 0, 0, 0};
+
+        pduLen += 2;  /* 2bytes of header */
+        memcpy(pdu, &msg, pduLen);
+        byteIdx += pduLen; /* 2 bytes of header */
+        break;
+      }
+      case MSG_TYPE_REGISTRATION_COMPLETE:
+      {
+          
+         DU_LOG("\nPHY_STUB: Forming RRC REGISTRATION COMPLETE PDU");
+         uint8_t  pduLen = 12;
+         /* For rrc reconfig complete where RRC Container is dummy
+         MAC subheader format is R/F/LCId/L (2/3 bytes)
+         LCId is 1 for SRB1
+         L is length of PDU i.e 6bytes here
+         From 38.321 section 6.1.1
+         */
+         uint8_t msg[] = {1, pduLen, 0, 0x04, 0x3a, 0x81, 0xbf, 0, 0x21, 0x80, 0, \
+         0, 0, 0};
+       
+         pduLen += 2;  /* 2bytes of header */
+         memcpy(pdu, &msg, pduLen);
+         byteIdx += pduLen; /* 2 bytes of header */
+          break;
+      }
+      case MSG_TYPE_RRC_RECONFIG_COMPLETE:
+      {
+         DU_LOG("\nPHY_STUB: Forming RRC RECONFIGURATION PDU");
+         uint8_t  pduLen = 14;
+        /* For rrc reconfig complete where RRC Container is dummy
+        MAC subheader format is R/F/LCId/L (2/3 bytes)
+        LCId is 1 for SRB1
+        L is length of PDU i.e 6bytes here
+        From 38.321 section 6.1.1
+        */
+        uint8_t msg[] = {1, pduLen, 0, 6, 8, 64, 0, 0, 0, 0, \
+                         0, 0, 0, 0, 0};
+       
+        pduLen += 2;  /* 2bytes of header */
+        memcpy(pdu, &msg, pduLen);
+        byteIdx += pduLen; /* 2 bytes of header */
+        break;
 
-           pduLen += 2;  /* 2bytes of header */
-           memcpy(pdu, &msg, pduLen);
-           byteIdx += pduLen; /* 2 bytes of header */
-           break;
-        }
+      }
+      
       default:
         break;
    } /* End of switch(type) */
@@ -957,8 +1004,8 @@ S16 l1HdlUlTtiReq(uint16_t msgLen, void *msg)
       }
       if(ulTtiReq->pdus[numPdus-1].pduType == 1)
       {
-        DU_LOG("\nPHY STUB: PUSCH PDU");                       
-         l1BuildAndSendRxDataInd(ulTtiReq->slot, ulTtiReq->sfn, \
+        DU_LOG("\nPHY STUB: PUSCH PDU");
+        l1BuildAndSendRxDataInd(ulTtiReq->slot, ulTtiReq->sfn, \
               ulTtiReq->pdus[numPdus-1].pdu.pusch_pdu); 
       }
       if(ulTtiReq->pdus[numPdus-1].pduType == 2)