/* This file contains APIs to send/receive messages from PHY */
-#include "stdio.h"
-#include "envdep.h"
-#include "ssi.h"
+#include "common_def.h"
+#include "lrg.h"
+#include "lrg.x"
+#include "du_app_mac_inf.h"
+#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 "mac_utils.h"
-#include "rg_cl_phy.h"
-#include "fapi.h"
+#ifdef INTEL_WLS
+#include "wls_lib.h"
+#endif
+
+EXTERN uint8_t rgClHndlCfgReq ARGS((void *msg));
+EXTERN void l1ProcessFapiRequest ARGS((uint8_t msgType, uint32_t msgLen, void *msg));
+#ifdef INTEL_WLS
-EXTERN S16 rgClHndlCfgReq ARGS((void *msg));
-EXTERN void macToPhy ARGS((U16 msgType, U32 msgLen, void *msg));
-EXTERN void processRequest ARGS((U16 msgType, U32 msgLen, void *msg));
-/******************************************************************
+/*******************************************************************
*
- * @brief Receives message to PHY
+ * @brief Enqueues memory blocks for use by L1
*
* @details
*
- * Function : phyToMac
+ * Function : LwrMacEnqueueWlsBlock
*
* Functionality:
- * -Receives Msg from PHY
- *
- * @params[in] Message Pointer
+ * Enqueues memory blocks for use by L1
*
+ * @params[in]
* @return void
*
- ******************************************************************/
+ * ****************************************************************/
+void LwrMacEnqueueWlsBlock()
+{
+ void *memPtr;
+ void *wlsHdlr;
+
+ WLS_MEM_ALLOC(memPtr, LWR_MAC_WLS_BUF_SIZE);
+
+ if(memPtr)
+ {
+ wlsHdlr = mtGetWlsHdl();
-void phyToMac(U16 msgType, U32 msgLen,void *msg)
+ /* allocate blocks for UL transmittion */
+ while(WLS_EnqueueBlock(wlsHdlr, WLS_VA2PA(wlsHdlr, memPtr)))
+ {
+ WLS_MEM_ALLOC(memPtr, LWR_MAC_WLS_BUF_SIZE);
+ if(!memPtr)
+ break;
+ }
+
+ // free not enqueued block
+ if(memPtr)
+ {
+ WLS_MEM_FREE(memPtr, LWR_MAC_WLS_BUF_SIZE);
+ }
+ }
+}/* LwrMacEnqueueWlsBlock */
+
+/*******************************************************************
+ *
+ * @brief Enqueue N number of blocks
+ *
+ * @details
+ *
+ * Function : enqueueNBlocks
+ *
+ * Functionality:
+ * Enqueue N number of memory blocks
+ *
+ * @params[in] Number of blocks
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint16_t enqueueNBlocks(uint32_t numBlocks)
{
- switch(msgType)
+ void *memPtr;
+ void *wlsHdlr; /* WLS handler */
+
+ wlsHdlr = mtGetWlsHdl();
+ while(numBlocks)
{
- case MSG_TYPE_CONFIG_RSP:
- rgClHndlCfgReq(msg);
- break;
+ numBlocks--;
- default:
- printf("\nInvalid message type[%x] from PHY", msgType);
+ memPtr = (void *)NULL;
+ WLS_MEM_ALLOC(memPtr, LWR_MAC_WLS_BUF_SIZE);
+ if(memPtr)
+ {
+ WLS_EnqueueBlock(wlsHdlr, WLS_VA2PA(wlsHdlr, memPtr));
+ }
}
-}
+ return ROK;
+}/* enqueueNBlocks */
/*******************************************************************
*
- * @brief Sends message to PHY
+ * @brief Add memory block (to be freed later) to list
*
* @details
*
- * Function : sendToPhy
+ * Function : addWlsBlockToFree
*
* Functionality:
- * -Sends message to PHY
+ * Add memory block (to be freed later) to list
*
- * @params[in] Message Type
- * Message Length
- * Messaga Pointer
+ * @params[in]
+ * @return ROK - success
+ * RFAILED - failure
*
- * @return void
+ * ****************************************************************/
+void addWlsBlockToFree(void *msg, uint32_t msgLen, uint8_t idx)
+{
+ CmLList *node;
+ WlsBlockToFree *block;
+ MAC_ALLOC(block, sizeof(WlsBlockToFree));
+ if(block)
+ {
+ MAC_ALLOC(node, sizeof(CmLList));
+ if(node)
+ {
+ block->ptr = msg;
+ block->size = msgLen;
+
+ node->node = (PTR)block;
+ cmLListAdd2Tail(&wlsBlockToFreeList[idx], node);
+ }
+ }
+}/* addWlsBlockToFree */
+
+void freeWlsBlockList(uint8_t idx)
+{
+ CmLList *node;
+ WlsBlockToFree *block;
+ if(wlsBlockToFreeList[idx].count)
+ {
+ CM_LLIST_FIRST_NODE(&wlsBlockToFreeList[idx], node);
+ while(node)
+ {
+ block = (WlsBlockToFree *)node->node;
+ cmLListDelFrm(&wlsBlockToFreeList[idx], node);
+ WLS_MEM_FREE(block->ptr, block->size);
+ MAC_FREE(block, sizeof(WlsBlockToFree));
+ MAC_FREE(node, sizeof(CmLList));
+ node = NULL;
+ CM_LLIST_FIRST_NODE(&wlsBlockToFreeList[idx], node);
+ }
+ }
+}
+
+/*******************************************************************
*
-******************************************************************/
+ * @brief Receives msg from L1
+ *
+ * @details
+ *
+ * Function :LwrMacRecvPhyMsg
+ *
+ * Functionality:
+ * Receives L1 Msg and enqueues memort for UL msg
+ *
+ * @params[in]
+ * @return
+ * ****************************************************************/
+void LwrMacRecvPhyMsg()
+{
+ uint32_t numL1Msg; /* Number of L1 messaes received */
+ uint32_t numToGet; /* Number of Memory blocks to get */
+ void *wlsHdlr; /* WLS handler */
+ uint64_t l1Msg; /* Message received */
+ void *l1MsgPtr;
+ uint32_t msgSize;
+ uint16_t msgType;
+ uint16_t flag;
+
+ wlsHdlr = mtGetWlsHdl();
+ if(WLS_Ready(wlsHdlr))
+ {
+ numToGet = WLS_Wait(wlsHdlr);
-PUBLIC S16 sendToPhy(U16 msgType, U32 msgLen, void *msg)
+ numL1Msg = numToGet;
+
+ while(numToGet)
+ {
+ l1Msg = (uint64_t) NULL;
+ l1Msg = WLS_Get(wlsHdlr, &msgSize, &msgType, &flag);
+ if(l1Msg)
+ {
+ l1MsgPtr = WLS_PA2VA(wlsHdlr, l1Msg);
+ procPhyMessages(msgType, msgSize, l1MsgPtr);
+ }
+ numToGet--;
+ }
+
+ if(numL1Msg)
+ {
+ enqueueNBlocks(numL1Msg);
+ }
+
+ }
+} /* LwrMacRecvPhyMsg */
+
+#endif /* INTEL_WLS */
+
+/*******************************************************************
+ *
+ * @brief Sends message to PHY
+ *
+ * @details
+ *
+ * Function : LwrMacSendToPhy
+ * Functionality:
+ * -Sends message to PHY
+ *
+ * @params[in] Message Type
+ * Message Length
+ * Messaga Pointer
+ *
+ * @return void
+ *
+ * *****************************************************************/
+
+uint8_t LwrMacSendToPhy(uint8_t msgType, uint32_t msgLen, void *msg)
{
-#if 0
- S8 ret;
- void *pMsg;
+#ifdef INTEL_WLS
+ uint8_t ret;
+ unsigned long long pMsg;
- pMsg = (void *)WLS_VA2PA(mtGetWlsHdl(), msg);
- ret = WLS_put(mtGetWlsHdl(), (PTR)pMsg, msgLen, msgType, 0);
+ pMsg = WLS_VA2PA(mtGetWlsHdl(), msg);
+ ret = WLS_Put(mtGetWlsHdl(), pMsg, msgLen, msgType, 0);
if(ret != 0)
{
printf("\nFailure in sending message to PHY");
- RETVALUE(RFAILED);
+ WLS_MEM_FREE(msg, msgLen);
+ return RFAILED;
}
+ else
+ {
+ addWlsBlockToFree(msg, msgLen, (slotIndIdx-1));
+ }
+#else
+ l1ProcessFapiRequest(msgType, msgLen, msg);
#endif
-
- processRequest(msgType, msgLen, msg);
-}
+ return ROK;
+} /* LwrMacSendToPhy */
/**********************************************************************
- End of file
-**********************************************************************/
+ End of file
+ **********************************************************************/