[Task-ID: ODUHIGH-455] Changes to support new L1 20.11
[o-du/l2.git] / src / 5gnrmac / lwr_mac_phy.c
index 1b6d0c9..23571ae 100644 (file)
 #include "mac_sch_interface.h"
 #include "lwr_mac_upr_inf.h"
 #include "mac.h"
-#include "lwr_mac_phy.h"
 #include "lwr_mac_fsm.h"
+#include "lwr_mac_phy.h"
 #include "mac_utils.h"
 #include "lwr_mac_utils.h"
+#include "lwr_mac.h"
 #ifdef INTEL_FAPI
-#include "fapi.h"
+#include "nr5g_fapi_internal.h"
 #include "fapi_vendor_extension.h"
 #endif
 #ifdef INTEL_WLS_MEM
@@ -62,7 +63,7 @@ void LwrMacStartWlsRcvr()
    Pst pst;
    Buffer *mBuf;
 
-   DU_LOG("\nLWR MAC: Requesting to start WLS receiver thread");
+   DU_LOG("\nINFO  -->  LWR MAC : Requesting to start WLS receiver thread");
 
    /* Filling post */
    memset(&pst, 0, sizeof(Pst));
@@ -70,7 +71,7 @@ void LwrMacStartWlsRcvr()
 
    if (ODU_GET_MSG_BUF(pst.region, pst.pool, &mBuf) != ROK)
    {
-      DU_LOG("\nLWR MAC : Memory allocation failed for LwrMacStartWlsRcvr");
+      DU_LOG("\nERROR  -->  LWR MAC : Memory allocation failed for LwrMacStartWlsRcvr");
       return;
    }
 
@@ -136,8 +137,8 @@ void LwrMacEnqueueWlsBlock()
  * ****************************************************************/
 void addWlsBlockToFree(void *msg, uint32_t msgLen, uint8_t idx)
 {
-   CmLList         *node;
-   WlsBlockToFree  *block;
+   CmLList         *node = NULLP;
+   WlsBlockToFree  *block = NULLP;
    MAC_ALLOC(block, sizeof(WlsBlockToFree));
    if(block)
    {
@@ -214,7 +215,6 @@ void LwrMacRecvPhyMsg()
    uint16_t msgType;
    uint16_t flag = 0;
    p_fapi_api_queue_elem_t currElem  = NULLP;
-   struct timeval time;
 
    mtGetWlsHdl(&wlsHdlr);
    if(WLS_Ready(wlsHdlr) == 0) 
@@ -227,7 +227,6 @@ void LwrMacRecvPhyMsg()
            continue;
         }
 
-        printf("\nLWR_MAC: numMsgToGet %d", numMsgToGet);
         while(numMsgToGet--)
         {
            currElem = NULLP;
@@ -253,41 +252,13 @@ void LwrMacRecvPhyMsg()
 
 #endif /* INTEL_WLS_MEM */
 
-/*******************************************************************
- * 
- *  @brief Sends message to PHY Stub
- * 
- *  @details
- * 
- *    Function : LwrMacSendToPhy
- *    Functionality:
- *      -Sends message to PHY Stub
- *      -Once super header and vendor specific message is
- *       implemented for all FAPI messages, this function 
- *       can be deleted. LwrMacSendToFapi() should be used.
- * 
- *  @params[in] Message Type
- *              Message Length
- *              Messaga Pointer
- * 
- *  @return void
- * 
- * *****************************************************************/
-
-uint8_t LwrMacSendToPhy(uint8_t msgType, uint32_t msgLen, void *msg)
-{
-   l1ProcessFapiRequest(msgType, msgLen, msg);
-   return ROK;
-} /* LwrMacSendToPhy */
-
-
 /*******************************************************************
  *
  * @brief Send FAPI messages to Intel PHY/Phy stub
  *
  * @details
  *
- *    Function : LwrMacSendToFapi
+ *    Function : LwrMacSendToL1
  *
  *    Functionality: Send FAPI messages to Intel PHY/Phy stub
  *
@@ -296,13 +267,55 @@ uint8_t LwrMacSendToPhy(uint8_t msgType, uint32_t msgLen, void *msg)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t LwrMacSendToFapi(void *msg)
+uint8_t LwrMacSendToL1(void *msg)
 {
    uint8_t ret = ROK;
 #ifdef INTEL_FAPI
-   uint16_t msgLen;
+   uint16_t msgLen =0;
    p_fapi_api_queue_elem_t currMsg = NULLP;
 
+#ifdef CALL_FLOW_DEBUG_LOG   
+   char message[100];
+
+   currMsg = (p_fapi_api_queue_elem_t)msg;
+   while(currMsg)
+   {
+      switch(currMsg->msg_type)
+      {
+         case FAPI_PARAM_REQUEST:
+            strcpy(message, "FAPI_PARAM_REQUEST");
+            break;
+         case FAPI_CONFIG_REQUEST:
+            strcpy(message, "FAPI_CONFIG_REQUEST");
+            break;
+         case FAPI_START_REQUEST:
+            strcpy(message, "FAPI_START_REQUEST");
+            break;
+         case FAPI_DL_TTI_REQUEST:
+            strcpy(message, "FAPI_DL_TTI_REQUEST");
+            break;
+         case FAPI_TX_DATA_REQUEST:
+            strcpy(message, "FAPI_TX_DATA_REQUEST");
+            break;
+         case FAPI_UL_TTI_REQUEST:
+            strcpy(message, "FAPI_UL_TTI_REQUEST");
+            break;
+         case FAPI_STOP_REQUEST:
+            strcpy(message, "FAPI_STOP_REQUEST");
+            break;
+         case FAPI_UL_DCI_REQUEST:
+            strcpy(message, "FAPI_UL_DCI_REQUEST");
+            break;
+         default:
+            strcpy(message, "INVALID_MSG");
+            break;
+      }
+      DU_LOG("\nCall Flow: ENTLWRMAC -> PHY : %s\n",message);
+      currMsg = currMsg->p_next;
+   }
+#endif
+
+
 #ifdef INTEL_WLS_MEM
    void * wlsHdlr = NULLP;
 
@@ -311,10 +324,10 @@ uint8_t LwrMacSendToFapi(void *msg)
    {
       currMsg = (p_fapi_api_queue_elem_t)msg;
       msgLen = currMsg->msg_len + sizeof(fapi_api_queue_elem_t);
-      addWlsBlockToFree(currMsg, msgLen, (slotIndIdx-1));
+      addWlsBlockToFree(currMsg, msgLen, (lwrMacCb.phySlotIndCntr-1));
       if(currMsg->p_next == NULLP)
       {
-        DU_LOG("\nThere cannot be only one block to send");
+        DU_LOG("\nERROR  -->  LWR MAC : There cannot be only one block to send");
         return RFAILED;
       }
 
@@ -322,7 +335,7 @@ uint8_t LwrMacSendToFapi(void *msg)
       ret = WLS_Put(wlsHdlr, WLS_VA2PA(wlsHdlr, currMsg), msgLen, currMsg->msg_type, WLS_SG_FIRST);
       if(ret != 0)
       {
-        DU_LOG("\nFailure in sending message to PHY");
+        DU_LOG("\nERROR  -->  LWR MAC : Failure in sending message to PHY");
         return RFAILED;
       }
       currMsg = currMsg->p_next;
@@ -331,13 +344,13 @@ uint8_t LwrMacSendToFapi(void *msg)
       {
         /* Sending the next msg */
         msgLen = currMsg->msg_len + sizeof(fapi_api_queue_elem_t);
-        addWlsBlockToFree(currMsg, msgLen, (slotIndIdx-1));
+        addWlsBlockToFree(currMsg, msgLen, (lwrMacCb.phySlotIndCntr-1));
         if(currMsg->p_next != NULLP)
         {
            ret = WLS_Put(wlsHdlr, WLS_VA2PA(wlsHdlr, currMsg), msgLen, currMsg->msg_type, WLS_SG_NEXT);
            if(ret != 0)
            {
-              DU_LOG("\nFailure in sending message to PHY");
+              DU_LOG("\nERROR  -->  LWR MAC : Failure in sending message to PHY");
               return RFAILED;
            }
            currMsg = currMsg->p_next;
@@ -348,7 +361,7 @@ uint8_t LwrMacSendToFapi(void *msg)
            ret = WLS_Put(wlsHdlr, WLS_VA2PA(wlsHdlr, currMsg), msgLen, currMsg->msg_type, WLS_SG_LAST);
            if(ret != 0)
            {
-              DU_LOG("\nFailure in sending message to PHY");
+              DU_LOG("\nERROR  -->  LWR MAC : Failure in sending message to PHY");
               return RFAILED;
            }
            currMsg = NULLP;
@@ -372,7 +385,7 @@ uint8_t LwrMacSendToFapi(void *msg)
       }
       else
       {
-        MAC_FREE(currMsg, msgLen);   
+        LWR_MAC_FREE(currMsg, msgLen);   
       }
       currMsg = nextMsg;
    }