[Epic-ID: ODUHIGH-516][Task-ID: ODUHIGH-534] Handling of reset rsp 62/11862/6
authorpborla <pborla@radisys.com>
Fri, 6 Oct 2023 10:16:07 +0000 (15:46 +0530)
committerpborla <pborla@radisys.com>
Mon, 9 Oct 2023 07:40:10 +0000 (13:10 +0530)
Change-Id: Ifcdd70f8bf5bd0d99adb60596a9f2704f2d59f1d
Signed-off-by: pborla <pborla@radisys.com>
src/du_app/du_e2ap_msg_hdl.c
src/ric_stub/ric_e2ap_msg_hdl.c

index 5a42e63..6f366b6 100644 (file)
@@ -2182,13 +2182,13 @@ void freeAperDecodingOfE2SetupRsp(E2setupResponse_t *e2SetRspMsg)
  *    Functionality: Processes E2 Setup Response sent by RIC
  *
  * @params[in] E2AP_PDU_t ASN decoded E2AP message
- * @return ROK     - success
- *         RFAILED - failure
+ * @return void
  *
  * ****************************************************************/
 
-uint8_t procE2SetupRsp(E2AP_PDU_t *e2apMsg)
+void procE2SetupRsp(E2AP_PDU_t *e2apMsg)
 {
+   bool invalidTransId = false;
    uint8_t arrIdx =0, transId=0, idx=0; 
    uint32_t recvBufLen;             
    E2setupResponse_t *e2SetRspMsg=NULL;
@@ -2216,7 +2216,7 @@ uint8_t procE2SetupRsp(E2AP_PDU_t *e2apMsg)
                else
                {
                   DU_LOG("\nERROR  -->  E2AP : Invalid transaction id [%d]", transId);
-                  return RFAILED;
+                  invalidTransId = true;
                }
                break;
             }
@@ -2226,60 +2226,67 @@ uint8_t procE2SetupRsp(E2AP_PDU_t *e2apMsg)
                /* To store the Ric Id Params */
                recvBufLen = sizeof(e2SetRspMsg->protocolIEs.list.array[arrIdx]->value\
                      .choice.GlobalRIC_ID.pLMN_Identity.size);
-                  memcpy(&duCb.e2apDb.ricId.plmnId, e2SetRspMsg->protocolIEs.list.array[arrIdx]\
-                        ->value.choice.GlobalRIC_ID.pLMN_Identity.buf, recvBufLen);
+               memcpy(&duCb.e2apDb.ricId.plmnId, e2SetRspMsg->protocolIEs.list.array[arrIdx]\
+                     ->value.choice.GlobalRIC_ID.pLMN_Identity.buf, recvBufLen);
                bitStringToInt(&e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.GlobalRIC_ID.ric_ID, &duCb.e2apDb.ricId);
                /*TODO : duCb.e2apDb.ricId.plmnId memory to be deallocated after the usage */
                break;
             }
 
          case ProtocolIE_IDE2_id_E2nodeComponentConfigAdditionAck:
-         {
-            e2NodeCfgAckList = &e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAdditionAck_List;
-            for(idx =0; idx <e2NodeCfgAckList->list.count; idx++)
             {
-               e2NodeAddAckItem = (E2nodeComponentConfigAdditionAck_ItemIEs_t*) e2NodeCfgAckList->list.array[idx];
-               switch(e2NodeAddAckItem->value.choice.E2nodeComponentConfigAdditionAck_Item.e2nodeComponentID.present)
+               e2NodeCfgAckList = &e2SetRspMsg->protocolIEs.list.array[arrIdx]->value.choice.E2nodeComponentConfigAdditionAck_List;
+               for(idx =0; idx <e2NodeCfgAckList->list.count; idx++)
                {
-                  case E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1:
-                     {
-                        e2NodeComponentInfo = fetchE2NodeComponentInfo(F1, E2_NODE_COMPONENT_ADD, &node);
-                        if(!e2NodeComponentInfo)
-                        {
-                           DU_LOG("\nERROR  --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__);
-                           return RFAILED;
-                        }
-                        else
+                  e2NodeAddAckItem = (E2nodeComponentConfigAdditionAck_ItemIEs_t*) e2NodeCfgAckList->list.array[idx];
+                  switch(e2NodeAddAckItem->value.choice.E2nodeComponentConfigAdditionAck_Item.e2nodeComponentID.present)
+                  {
+                     case E2nodeComponentID_PR_e2nodeComponentInterfaceTypeF1:
                         {
-                           cmLListDelFrm(&duCb.e2apDb.e2NodeComponentList, node);
-                           DU_FREE(e2NodeComponentInfo->componentRequestPart, e2NodeComponentInfo->reqBufSize);
-                           DU_FREE(e2NodeComponentInfo->componentResponsePart, e2NodeComponentInfo->rspBufSize);
-                           DU_FREE(e2NodeComponentInfo, sizeof(E2NodeComponent));
-                           DU_FREE(node, sizeof(CmLList));
+                           e2NodeComponentInfo = fetchE2NodeComponentInfo(F1, E2_NODE_COMPONENT_ADD, &node);
+                           if(!e2NodeComponentInfo)
+                           {
+                              DU_LOG("\nERROR  --> E2AP : Received null e2NodeComponentInfo at line number %d",__LINE__);
+                           }
+                           else
+                           {
+                              cmLListDelFrm(&duCb.e2apDb.e2NodeComponentList, node);
+                              DU_FREE(e2NodeComponentInfo->componentRequestPart, e2NodeComponentInfo->reqBufSize);
+                              DU_FREE(e2NodeComponentInfo->componentResponsePart, e2NodeComponentInfo->rspBufSize);
+                              DU_FREE(e2NodeComponentInfo, sizeof(E2NodeComponent));
+                              DU_FREE(node, sizeof(CmLList));
+                           }
+                           break;
                         }
+                     default:
                         break;
-                     }
-                  default:
-                     break;
+                  }
                }
+               break;
             }
-            break;
-         }
 
          default:
-            DU_LOG("\nERROR  -->  E2AP : Invalid IE received in E2SetupRsp:%ld",
-                  e2SetRspMsg->protocolIEs.list.array[arrIdx]->id);
-            break;
+            {
+               DU_LOG("\nERROR  -->  E2AP : Invalid IE received in E2SetupRsp:%ld",
+                     e2SetRspMsg->protocolIEs.list.array[arrIdx]->id);
+               break;
+            }
+      }
+
+      if(invalidTransId == true)
+      {
+         break;
       }
    }
    freeAperDecodingOfE2SetupRsp(e2SetRspMsg);
 
-   if(duSendE2NodeConfigurationUpdate() != ROK)
+   if(invalidTransId == false)
    {
-      DU_LOG("\nERROR  -->  E2AP : Failed to send E2 node config update");
-      return RFAILED;
+      if(duSendE2NodeConfigurationUpdate() != ROK)
+      {
+         DU_LOG("\nERROR  -->  E2AP : Failed to send E2 node config update");
+      }
    }
-   return ROK;
 }
 
 /*******************************************************************
@@ -4488,6 +4495,7 @@ void FreeE2ResetRequest(E2AP_PDU_t *e2apMsg)
  *         - Buld and send the E2 reset request msg to RIC
  *
  * @params[in]
+ *    Reset cause
  * @return ROK     - success
  *         RFAILED - failure
  *
@@ -4573,13 +4581,13 @@ uint8_t BuildAndSendE2ResetRequest(E2FailureCause resetCause)
             encBuf);
       if(encRetVal.encoded == ENCODE_FAIL)
       {
-         DU_LOG("\nERROR  -->  E2AP : Could not encode E2SetupRequest structure (at %s)\n",\
+         DU_LOG("\nERROR  -->  E2AP : Could not encode reset request structure (at %s)\n",\
                encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
          break;
       }
       else
       {
-         DU_LOG("\nDEBUG   -->  E2AP : Created APER encoded buffer for E2SetupRequest\n");
+         DU_LOG("\nDEBUG   -->  E2AP : Created APER encoded buffer for reset request\n");
 #ifdef DEBUG_ASN_PRINT
          for(int i=0; i< encBufSize; i++)
          {
@@ -4661,14 +4669,15 @@ void freeAperDecodingOfE2ResetRsp(ResetResponseE2_t *resetResponse)
  *    Functionality: Processes E2 Reset Response sent by RIC
  *
  * @params[in] E2AP_PDU_t ASN decoded E2AP message
- * @return ROK     - success
- *         RFAILED - failure
+ * @return void
  *
  * ****************************************************************/
-uint8_t procResetResponse(E2AP_PDU_t *e2apMsg)
+void procResetResponse(E2AP_PDU_t *e2apMsg)
 {
-   uint8_t ieIdx =0, transId;
-   ResetResponseE2_t *resetResponse;
+   bool invalidTransId=false;
+   uint8_t ieIdx =0, transId =0;
+   uint16_t ranFuncIdx=0;
+   ResetResponseE2_t *resetResponse =NULLP;
 
    DU_LOG("\nINFO   -->  E2AP : E2 Reset Response received");
    resetResponse = &e2apMsg->choice.successfulOutcome->value.choice.ResetResponseE2;;
@@ -4678,36 +4687,47 @@ uint8_t procResetResponse(E2AP_PDU_t *e2apMsg)
       switch(resetResponse->protocolIEs.list.array[ieIdx]->id)
       {
          case ProtocolIE_IDE2_id_TransactionID:
-            transId = resetResponse->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
-            if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) && \
-                  (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode))
             {
-               memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo));
+               transId = resetResponse->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
+               if((duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].transactionId == transId) && \
+                     (duCb.e2apDb.e2TransInfo.e2InitTransaction[transId].procedureCode == e2apMsg->choice.successfulOutcome->procedureCode))
+               {
+                  memset(&duCb.e2apDb.e2TransInfo.e2InitTransaction[transId], 0, sizeof(E2TransInfo));
+               }
+               else
+               {
+                  DU_LOG("\nERROR  -->  E2AP : Invalid transaction id [%d]", transId);
+                  invalidTransId = true;
+               }
+               break;
             }
-            else
+         case ProtocolIE_IDE2_id_CriticalityDiagnosticsE2:
             {
-               DU_LOG("\nERROR  -->  E2AP : Invalid transaction id [%d]", transId);
-               return RFAILED;
+               for(ranFuncIdx=0; ranFuncIdx<MAX_RAN_FUNCTION; ranFuncIdx++)
+               {
+                  if(duCb.e2apDb.ranFunction[ranFuncIdx].id >0)
+                  {
+                     deleteRicSubscriptionList(&(duCb.e2apDb.ranFunction[ranFuncIdx].subscriptionList));
+                     memset(&(duCb.e2apDb.ranFunction[ranFuncIdx].pendingSubsRspInfo), 0, MAX_PENDING_SUBSCRIPTION_RSP*sizeof(PendingSubsRspInfo));
+                  }
+               }
+               break;
             }
-            break;
-         case ProtocolIE_IDE2_id_CriticalityDiagnosticsE2:
-            /* As per ORAN WG3 E2AP spec v3.0, section 9.2.2
-               Criticality Diagnostics IE is sent by Near-RT RIC when parts of a received message i.e. 
-               Reset Request in this case, have not been comprehended or were missing, or if the message 
-               contained logical errors.
-
-               Processing of this ID should be implemented when negative call flows are to be supported.
-             */
-            break;
          default:
-            DU_LOG("\nERROR  -->  E2AP : Invalid IE received in E2 Reset Response : %ld",
-                  resetResponse->protocolIEs.list.array[ieIdx]->id);
-            break;
+            {
+               DU_LOG("\nERROR  -->  E2AP : Invalid IE received in E2 Reset Response : %ld",
+                     resetResponse->protocolIEs.list.array[ieIdx]->id);
+               break;
+            }
+      }
+
+      if(invalidTransId == true)
+      {
+         break;
       }
    }
 
    freeAperDecodingOfE2ResetRsp(resetResponse);
-   return ROK;
 }
 
 /******************************************************************
index 91f9dae..e648cf6 100644 (file)
@@ -1966,7 +1966,7 @@ uint8_t ProcE2SetupReq(uint32_t *duId, E2setupRequest_t  *e2SetupReq)
 void FreeE2ResetResponse(E2AP_PDU_t *e2apMsg)
 {
    uint8_t ieIdx =0;
-   ResetResponseE2_t *resetResponse;
+   ResetResponseE2_t *resetResponse =NULLP;
 
    if(e2apMsg != NULLP)
    {
@@ -1992,14 +1992,18 @@ void FreeE2ResetResponse(E2AP_PDU_t *e2apMsg)
 
 /*******************************************************************
  *
- * @brief Buld and send the E2 Reset Response msg
+ * @brief Buld and send the Reset Response msg
  *
  * @details
  *
- *    Function : BuildAndSendE2ResetResponse
+ *    Function : BuildAndSendResetResponse 
  *
  *    Functionality:
- *         - Buld and send the E2 Reset Response Message
+ *         - Buld and send the Reset Response Message
+ *
+ * @params[in] 
+ *    DU id
+ *    TransId Id
  * @return ROK     - success
  *         RFAILED - failure
  *
@@ -2009,7 +2013,7 @@ uint8_t BuildAndSendResetResponse(uint32_t duId, uint8_t transId)
    uint8_t           ieIdx = 0, elementCnt = 0;
    uint8_t           ret = RFAILED;
    E2AP_PDU_t        *e2apMsg = NULLP;
-   ResetResponseE2_t *resetResponse;
+   ResetResponseE2_t *resetResponse=NULL;
    asn_enc_rval_t    encRetVal;       /* Encoder return value */
 
    DU_LOG("\nINFO   -->  E2AP : Building E2 Reset Response Message\n");
@@ -2098,75 +2102,6 @@ uint8_t BuildAndSendResetResponse(uint32_t duId, uint8_t transId)
    return ret;
 }
 
-/*******************************************************************
- *
- * @brief process the E2 Reset Request
- *
- * @details
- *
- *    Function : ProcE2ResetReq
- *
- * Functionality: Process E2 Reset Request
- *
- * @return ROK     - success
- *         RFAILED - failure
- *
- ******************************************************************/
-
-uint8_t ProcE2ResetReq(uint32_t duId, ResetRequestE2_t  *resetReq)
-{
-   uint8_t ieIdx = 0;
-   uint8_t transId = 0, cause = 0;
-
-   if(resetReq)
-   {
-      if(resetReq->protocolIEs.list.array)
-      {
-         for(ieIdx=0; ieIdx < resetReq->protocolIEs.list.count; ieIdx++)
-         {
-            if(resetReq->protocolIEs.list.array[ieIdx])
-            {
-               switch(resetReq->protocolIEs.list.array[ieIdx]->id)
-               {
-                  case ProtocolIE_IDE2_id_TransactionID:
-                     transId = resetReq->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
-                     break;
-                  case ProtocolIE_IDE2_id_CauseE2:
-                     DU_LOG("\nDEBUG  -->  E2AP : Reset reason %d", resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.present);
-                     switch(resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.present)
-                     {
-                        case CauseE2_PR_NOTHING:
-                           break;
-                        case CauseE2_PR_ricRequest:
-                           cause = resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.ricRequest;
-                           break;
-                        case CauseE2_PR_ricService:
-                           cause = resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.ricService;
-                           break;
-                        case CauseE2_PR_e2Node:
-                           cause = resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.e2Node;
-                           break;
-                        case CauseE2_PR_transport:
-                           cause = resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.transport;
-                           break;
-                        case CauseE2_PR_protocol:
-                           cause = resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.protocol;
-                           break;
-                        case CauseE2_PR_misc:
-                           cause = resetReq->protocolIEs.list.array[ieIdx]->value.choice.CauseE2.choice.misc;
-                           break;
-                     }
-                     DU_LOG("\nDEBUG  -->  E2AP : Reset cause %d", cause);
-                     break;
-               }
-            }
-         }
-      }
-   }
-   BuildAndSendResetResponse(duId, transId);
-   return ROK;
-}
-
 /*******************************************************************
  *
  * @brief deallocate the memory allocated in building the
@@ -4330,6 +4265,167 @@ uint8_t BuildAndSendResetRequest(DuDb *duDb, CauseE2_PR causePresent, uint8_t re
    return ret;
 }
 
+
+/*******************************************************************
+ *
+ * @brief delete ric subscription information 
+ *
+ * @details
+ *
+ *    Function : deleteRicSubscription 
+ *
+ * Functionality: Process ric subscription information
+ *
+ * @params[in] 
+ *       Pointer to DU database 
+ * @return void
+
+ *
+ ******************************************************************/
+void deleteRicSubscription(DuDb **duDb)
+{
+   RanFunction *ranFuncDb = NULLP;
+   uint16_t ranFuncIdx=0;
+   
+   for(ranFuncIdx =0; ranFuncIdx<MAX_RAN_FUNCTION; ranFuncIdx++)
+   {
+      ranFuncDb = &(*duDb)->ranFunction[ranFuncIdx];
+      if(ranFuncDb->id > 0)
+      {
+         memset(&ranFuncDb->subscriptionList, 0,MAX_RIC_REQUEST*sizeof(RicSubscription));
+         ranFuncDb->numOfSubscription =0;
+      }
+   }
+}
+
+/*******************************************************************
+ *
+ * @brief process the E2 Reset Response
+ *
+ * @details
+ *
+ *    Function : ProcResetResponse 
+ *
+ * Functionality: Process E2 Reset Response 
+ *
+ * @params[in] 
+ *       du Id
+ *       Pointer to reset response 
+ * @return void
+ *
+ ******************************************************************/
+
+void ProcResetResponse(uint32_t duId, ResetResponseE2_t *resetRsp)
+{
+   uint8_t ieIdx = 0, duIdx =0;
+   DuDb *duDb = NULLP;
+
+   SEARCH_DU_DB(duIdx, duId, duDb); 
+   if(duDb == NULLP)
+   {
+      DU_LOG("\nERROR  -->  E2AP : duDb is not present for duId %d",duId);
+      return;
+   }
+   
+   if(!resetRsp)
+   {
+      DU_LOG("\nERROR  -->  E2AP : resetRsp pointer is null"); 
+      return;
+   }
+
+   if(!resetRsp->protocolIEs.list.array)      
+   {
+      DU_LOG("\nERROR  -->  E2AP : resetRsp array pointer is null");
+      return;
+   }
+   
+   for(ieIdx=0; ieIdx < resetRsp->protocolIEs.list.count; ieIdx++)
+   {
+      if(resetRsp->protocolIEs.list.array[ieIdx])
+      {
+         switch(resetRsp->protocolIEs.list.array[ieIdx]->id)
+         {
+            case ProtocolIE_IDE2_id_TransactionID:
+               {
+                  deleteRicSubscription(&duDb);
+                  break;
+               }
+            case ProtocolIE_IDE2_id_CriticalityDiagnosticsE2:
+               {
+                  break;
+               }
+         }
+      }
+   }
+}
+
+
+/*******************************************************************
+ *
+ * @brief process the E2 Reset Request
+ *
+ * @details
+ *
+ *    Function : ProcResetRequest 
+ *
+ * Functionality: Process E2 Reset Request 
+ *
+ * @params[in] 
+ *       du Id
+ *       Pointer to reset response 
+ * @return void
+ *
+ ******************************************************************/
+
+void ProcResetRequest(uint32_t duId, ResetRequestE2_t *resetReq)
+{
+   uint8_t ieIdx = 0, duIdx =0, transId=0;
+   DuDb *duDb = NULLP;
+
+   SEARCH_DU_DB(duIdx, duId, duDb); 
+   if(duDb == NULLP)
+   {
+      DU_LOG("\nERROR  -->  E2AP : duDb is not present for duId %d",duId);
+      return;
+   }
+   
+   if(!resetReq)
+   {
+      DU_LOG("\nERROR  -->  E2AP : resetReq pointer is null"); 
+      return;
+   }
+
+   if(!resetReq->protocolIEs.list.array)      
+   {
+      DU_LOG("\nERROR  -->  E2AP : resetReq array pointer is null");
+      return;
+   }
+   
+   for(ieIdx=0; ieIdx < resetReq->protocolIEs.list.count; ieIdx++)
+   {
+      if(resetReq->protocolIEs.list.array[ieIdx])
+      {
+         switch(resetReq->protocolIEs.list.array[ieIdx]->id)
+         {
+            case ProtocolIE_IDE2_id_TransactionID:
+               {
+                  transId = resetReq->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
+                  break;
+               }
+            case ProtocolIE_IDE2_id_CauseE2:
+               {
+                  deleteRicSubscription(&duDb);
+                  break;
+               }
+         }
+      }
+   }
+
+   if(BuildAndSendResetResponse(duId, transId) !=ROK)
+   {
+      DU_LOG("\nERROR  -->  E2AP : Failed to build and send reset response");
+   }
+}
 /*******************************************************************
 *
 * @brief Handles received E2AP message and sends back response  
@@ -4417,7 +4513,7 @@ void E2APMsgHdlr(uint32_t *duId, Buffer *mBuf)
                case InitiatingMessageE2__value_PR_ResetRequestE2:
                   {
                      DU_LOG("\nINFO  -->  E2AP : E2 Reset Request received");
-                     ProcE2ResetReq(*duId,  &e2apMsg->choice.initiatingMessage->value.choice.ResetRequestE2);
+                     ProcResetRequest(*duId,  &e2apMsg->choice.initiatingMessage->value.choice.ResetRequestE2);
                      break;
                   }
                case InitiatingMessageE2__value_PR_RICindication:
@@ -4457,6 +4553,12 @@ void E2APMsgHdlr(uint32_t *duId, Buffer *mBuf)
          {
             switch(e2apMsg->choice.successfulOutcome->value.present)
             {
+               case SuccessfulOutcomeE2__value_PR_ResetResponseE2:
+                  {
+                     DU_LOG("\nINFO  -->  E2AP : Reset response received");
+                     ProcResetResponse(*duId,  &e2apMsg->choice.successfulOutcome->value.choice.ResetResponseE2);
+                     break;
+                  }
                case SuccessfulOutcomeE2__value_PR_RICsubscriptionResponse:  
                   {
                      ProcRicSubscriptionResponse(*duId, \