1 /******************************************************************************
3 * Copyright (c) 2019 Intel.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 *******************************************************************************/
20 * @file This file has Shared Memory interface functions between FAPI and PHY
21 * @defgroup nr5g_fapi_source_framework_wls_lib_group
24 #include "nr5g_fapi_framework.h"
25 #include "nr5g_fapi_internal.h"
26 #include "nr5g_fapi_wls.h"
27 #include "nr5g_fapi_config_loader.h"
28 #include "nr5g_fapi_log.h"
29 #include "nr5g_fapi_memory.h"
31 nr5g_fapi_wls_context_t g_wls_ctx;
33 static uint8_t alloc_track[ALLOC_TRACK_SIZE];
35 //------------------------------------------------------------------------------
36 /** @ingroup nr5g_fapi_source_framework_wls_lib_group
40 * @return A pointer to WLS Context stucture
43 * This function returns the WLS Context structure which has WLS related parameters
46 //------------------------------------------------------------------------------
47 inline p_nr5g_fapi_wls_context_t nr5g_fapi_wls_context(
53 //----------------------------------------------------------------------------------
54 /** @ingroup nr5g_fapi_source_framework_wls_fapi2phy_group
58 * @return 0 if SUCCESS
61 * This function is called at WLS init and waits in an infinite for L1 to respond back with some information
65 //----------------------------------------------------------------------------------
66 inline uint8_t nr5g_fapi_fapi2phy_wls_ready(
70 p_nr5g_fapi_wls_context_t p_wls = nr5g_fapi_wls_context();
72 retval = WLS_Ready(p_wls->h_wls[NR5G_FAPI2PHY_WLS_INST]);
77 //----------------------------------------------------------------------------------
78 /** @ingroup nr5g_fapi_source_framework_wls_fapi2phy_group
82 * @return 0 if SUCCESS
85 * This function is called at WLS init and waits in an infinite for L1 to respond back with some information
89 //----------------------------------------------------------------------------------
90 inline uint8_t nr5g_fapi_fapi2mac_wls_ready(
94 p_nr5g_fapi_wls_context_t p_wls = nr5g_fapi_wls_context();
96 retval = WLS_Ready1(p_wls->h_wls[NR5G_FAPI2MAC_WLS_INST]);
101 //------------------------------------------------------------------------------
102 /** @ingroup nr5g_fapi_source_framework_wls_lib_group
104 * @param[in] ptr Pointer to display
105 * @param[in] size Size of data
110 * This function displays content of Buffer - Used for debugging
113 //------------------------------------------------------------------------------
114 void nr5g_fapi_wls_show_data(
121 for (i = 0; i < size; i++) {
124 printf("%02x ", d[i]);
129 //------------------------------------------------------------------------------
130 /** @ingroup nr5g_fapi_source_framework_wls_lib_group
137 * This function prints to the console FAPI stats
140 //------------------------------------------------------------------------------
141 void nr5g_fapi_wls_print_stats(
144 p_nr5g_fapi_wls_context_t pWls = nr5g_fapi_wls_context();
145 printf(" nTotalBlocks[%5d] nAllocBlocks[%5d] nFreeBlocks[%5d]\n",
146 pWls->nTotalBlocks, pWls->nAllocBlocks,
147 (pWls->nTotalBlocks - pWls->nAllocBlocks));
148 printf(" nTotalAllocCnt[%5d] nTotalFreeCnt[%5d] Diff[%5d]\n",
149 pWls->nTotalAllocCnt, pWls->nTotalFreeCnt,
150 (pWls->nTotalAllocCnt - pWls->nTotalFreeCnt));
151 uint32_t nFinalTotalDlBufAllocCnt = 0, nFinalTotalDlBufFreeCnt = 0, idx;
153 //#define PRINTF_DEBUG(fmt, args...) //printf(fmt, ## args)
154 #define PRINTF_DEBUG(fmt, args...)
156 PRINTF_DEBUG("\n nDlBufAllocCnt: \n");
157 for (idx = 0; idx < MEM_STAT_DEFAULT; idx++) {
158 nFinalTotalDlBufAllocCnt += pWls->nTotalDlBufAllocCnt[idx];
159 PRINTF_DEBUG("[%3d:%5d] ", idx, pWls->nTotalDlBufAllocCnt[idx]);
162 PRINTF_DEBUG("\n nDlBufFreeCnt: \n");
163 for (idx = 0; idx < MEM_STAT_DEFAULT; idx++) {
164 nFinalTotalDlBufFreeCnt += pWls->nTotalDlBufFreeCnt[idx];
165 PRINTF_DEBUG("[%3d:%5d] ", idx, pWls->nTotalDlBufFreeCnt[idx]);
167 PRINTF_DEBUG("\n\n");
169 printf(" nDlBufAllocCnt[%5d] nDlBufFreeCnt[%5d] Diff[%5d]\n",
170 nFinalTotalDlBufAllocCnt, nFinalTotalDlBufFreeCnt,
171 (nFinalTotalDlBufAllocCnt - nFinalTotalDlBufFreeCnt));
173 (" nUlBufAllocCnt[%5d] nUlBufFreeCnt[%5d] Diff[%5d]\n\n",
174 pWls->nTotalUlBufAllocCnt, pWls->nTotalUlBufFreeCnt,
175 (pWls->nTotalUlBufAllocCnt - pWls->nTotalUlBufFreeCnt));
178 //------------------------------------------------------------------------------
179 /** @ingroup nr5g_fapi_source_framework_wls_lib_group
181 * @param[in] ptr Address to convert
183 * @return Converted address
186 * This function converts Virtual Address to Physical Address
189 //------------------------------------------------------------------------------
190 uint64_t nr5g_fapi_wls_va_to_pa(
194 return ((uint64_t) WLS_VA2PA(h_wls, ptr));
197 //------------------------------------------------------------------------------
198 /** @ingroup nr5g_fapi_source_framework_wls_lib_group
200 * @param[in] ptr Address to convert
202 * @return Converted address
205 * This function converts Physical Address to Virtual Address
208 //------------------------------------------------------------------------------
209 void *nr5g_fapi_wls_pa_to_va(
213 return ((void *)WLS_PA2VA(h_wls, ptr));
216 //------------------------------------------------------------------------------
217 /** @ingroup nr5g_fapi_source_framework_wls_lib_group
221 * @return Number of blocks added
224 * This function add WLS blocks to the L1 Array which will be used by L1 in
225 * every TTI to populate and send back APIs to the MAC
228 //------------------------------------------------------------------------------
229 uint8_t wls_fapi_add_blocks_to_ul(
233 p_nr5g_fapi_wls_context_t pWls = nr5g_fapi_wls_context();
234 WLS_HANDLE h_wls = pWls->h_wls[NR5G_FAPI2PHY_WLS_INST];
236 void *pMsg = wls_fapi_alloc_buffer(0, MIN_UL_BUF_LOCATIONS);
241 /* allocate blocks for UL transmittion */
242 while (WLS_EnqueueBlock(h_wls, nr5g_fapi_wls_va_to_pa(h_wls, pMsg)) > 0) {
244 pMsg = wls_fapi_alloc_buffer(0, MIN_UL_BUF_LOCATIONS);
249 // free not enqueued block
251 wls_fapi_free_buffer(pMsg, MIN_UL_BUF_LOCATIONS);
257 //------------------------------------------------------------------------------
258 /** @ingroup nr5g_fapi_source_framework_wls_lib_group
260 * @param A pointer to the phy instance table.
262 * @return 0 if SUCCESS
264 * @description This function initializes WLS layer primitives and allocates
265 * memory needed to exchange APIs between FAPI and PHY.
267 //------------------------------------------------------------------------------
268 uint8_t nr5g_fapi_wls_init(
269 p_nr5g_fapi_cfg_t cfg)
271 p_nr5g_fapi_wls_context_t p_wls_ctx = nr5g_fapi_wls_context();
272 const char *dev_name = "wls0";
274 if (p_wls_ctx->h_wls[NR5G_FAPI2PHY_WLS_INST] &&
275 p_wls_ctx->h_wls[NR5G_FAPI2MAC_WLS_INST]) {
276 // NR5G_FAPI_LOG(ERROR_LOG, ("WLS instance already opened!"));
280 p_wls_ctx->shmem_size = cfg->wls.shmem_size;
281 p_wls_ctx->h_wls[NR5G_FAPI2MAC_WLS_INST] =
282 WLS_Open_Dual(dev_name, WLS_SLAVE_CLIENT,
283 cfg->wls.shmem_size, &p_wls_ctx->h_wls[NR5G_FAPI2PHY_WLS_INST]);
284 if ((NULL == p_wls_ctx->h_wls[NR5G_FAPI2PHY_WLS_INST]) &&
285 (NULL == p_wls_ctx->h_wls[NR5G_FAPI2MAC_WLS_INST])) {
286 NR5G_FAPI_LOG(ERROR_LOG, ("[NR5G_FAPI_ WLS] WLS Open Dual Failed."));
289 // Issue WLS_Alloc() for FAPI2MAC
290 p_wls_ctx->shmem = WLS_Alloc(p_wls_ctx->h_wls[NR5G_FAPI2MAC_WLS_INST],
291 p_wls_ctx->shmem_size);
293 if (NULL == p_wls_ctx->shmem) {
294 printf("Unable to alloc WLS Memory for FAPI2MAC\n");
298 p_wls_ctx->shmem = WLS_Alloc(p_wls_ctx->h_wls[NR5G_FAPI2PHY_WLS_INST],
299 p_wls_ctx->shmem_size);
300 p_wls_ctx->pWlsMemBase = p_wls_ctx->shmem;
301 p_wls_ctx->nTotalMemorySize = p_wls_ctx->shmem_size;
302 if (NULL == p_wls_ctx->shmem) {
303 printf("Unable to alloc WLS Memory\n");
306 // Now the L2 is up so let's make sure that the L1 was started first
308 // First let's wait for the L1 and L2 to be present
309 while (nr5g_fapi_fapi2phy_wls_ready()) ;
310 NR5G_FAPI_LOG(INFO_LOG, ("L1 is up..."));
311 // Now the L2 is up so let's make sure that the L1 was started first
312 while (nr5g_fapi_fapi2mac_wls_ready()) ;
313 NR5G_FAPI_LOG(INFO_LOG, ("L2 is up..."));
315 // Now that the L2 is up and has completed the Common Memory initialization
317 if (FAILURE == nr5g_fapi_wls_memory_init()) {
321 pthread_mutex_init((pthread_mutex_t *)
322 & p_wls_ctx->fapi2phy_lock_send, NULL);
323 pthread_mutex_init((pthread_mutex_t *)
324 & p_wls_ctx->fapi2phy_lock_alloc, NULL);
325 pthread_mutex_init((pthread_mutex_t *)
326 & p_wls_ctx->fapi2mac_lock_send, NULL);
327 pthread_mutex_init((pthread_mutex_t *)
328 & p_wls_ctx->fapi2mac_lock_alloc, NULL);
332 //-------------------------------------------------------------------------------------------
333 /** @ingroup nr5g_fapi_source_framework_wls_lib_group
335 * @param[in] pMemArray Pointer to WLS Memory Management Structure
336 * @param[in] pMemArrayMmeory pointer to flat buffer that was allocated
337 * @param[in] totalSize total size of flat buffer allocated
338 * @param[in] nBlockSize Size of each block that needs to be partitoned by the memory manager
340 * @return 0 if SUCCESS
343 * This function creates memory blocks from a flat buffer which will be used for communication between FAPI and PHY
346 //-------------------------------------------------------------------------------------------
347 uint32_t wls_fapi_create_mem_array(
348 PWLS_FAPI_MEM_STRUCT pMemArray,
349 void *pMemArrayMemory,
354 int numBlocks = totalSize / nBlockSize;
359 ("wls_fapi_create_mem_array: pMemArray[%p] pMemArrayMemory[%p] totalSize[%d] nBlockSize[%d] numBlocks[%d]\n",
360 pMemArray, pMemArrayMemory, totalSize, nBlockSize, numBlocks);
362 // Can't be less than pointer size
363 if (nBlockSize < sizeof(void *)) {
366 // Can't be less than one block
367 if (totalSize < sizeof(void *)) {
371 pMemArray->ppFreeBlock = (void **)pMemArrayMemory;
372 pMemArray->pStorage = pMemArrayMemory;
373 pMemArray->pEndOfStorage =
374 ((unsigned long *)pMemArrayMemory) +
375 numBlocks * nBlockSize / sizeof(unsigned long);
376 pMemArray->nBlockSize = nBlockSize;
377 pMemArray->nBlockCount = numBlocks;
379 // Initialize single-linked list of free blocks;
380 ptr = (void **)pMemArrayMemory;
381 for (i = 0; i < pMemArray->nBlockCount; i++) {
382 #ifdef MEMORY_CORRUPTION_DETECT
383 // Fill with some pattern
384 uint8_t *p = (uint8_t *) ptr;
387 p += (nBlockSize - 16);
388 for (j = 0; j < 16; j++) {
389 p[j] = MEMORY_CORRUPTION_DETECT_FLAG;
393 if (i == pMemArray->nBlockCount - 1) {
394 *ptr = NULL; // End of list
396 // Points to the next block
397 *ptr = (void **)(((uint8_t *) ptr) + nBlockSize);
398 ptr += nBlockSize / sizeof(unsigned long);
402 NR5G_FAPI_MEMSET(alloc_track, sizeof(uint8_t) * ALLOC_TRACK_SIZE, 0,
403 sizeof(uint8_t) * ALLOC_TRACK_SIZE);
408 //-------------------------------------------------------------------------------------------
409 /** @ingroup nr5g_fapi_source_framework_wls_lib_group
411 * @param[in] pWls Pointer to the nr5g_fapi_wls_ctx structure
413 * @return 0 if SUCCESS
416 * This function created a partition and blocks of WLS memory for API exchange between FAPI and PHY
419 //-------------------------------------------------------------------------------------------
420 uint8_t wls_fapi_create_partition(
421 p_nr5g_fapi_wls_context_t pWls)
423 #define WLS_HUGE_DEF_PAGE_SIZEA 0x40000000LL
424 static long hugePageSize = WLS_HUGE_DEF_PAGE_SIZEA;
425 // NR5G_FAPI_MEMSET(pWls->pWlsMemBase , 0xCC, pWls->nTotalMemorySize); // This is done by the Master Only
426 pWls->pPartitionMemBase =
427 (void *)(((uint8_t *) pWls->pWlsMemBase) + hugePageSize);
428 pWls->nPartitionMemSize = (pWls->nTotalMemorySize - hugePageSize);
430 pWls->nTotalBlocks = pWls->nPartitionMemSize / MSG_MAXSIZE;
431 return wls_fapi_create_mem_array(&pWls->sWlsStruct, pWls->pPartitionMemBase,
432 pWls->nPartitionMemSize, MSG_MAXSIZE);
435 //------------------------------------------------------------------------------
436 /** @ingroup nr5g_fapi_source_framework_wls_lib_group
438 * @param[in] A pointer to the FAPI Memory Structure (Initialized by L2)
439 * @param[out] ppBlock Pointer where the allocated memory block is stored
441 * @return 0 if SUCCESS
443 * @description This function allocates a memory block from the pool
446 //------------------------------------------------------------------------------
447 uint32_t wls_fapi_alloc_mem_array(
448 PWLS_FAPI_MEM_STRUCT pMemArray,
453 if (pMemArray->ppFreeBlock == NULL) {
454 printf("wls_fapi_alloc_mem_array pMemArray->ppFreeBlock = NULL\n");
457 // FIXME: Remove after debugging
458 if (((void *)pMemArray->ppFreeBlock < pMemArray->pStorage) ||
459 ((void *)pMemArray->ppFreeBlock >= pMemArray->pEndOfStorage)) {
461 ("wls_fapi_alloc_mem_array ERROR: Corrupted MemArray;Arr=%p,Stor=%p,Free=%p\n",
462 pMemArray, pMemArray->pStorage, pMemArray->ppFreeBlock);
466 pMemArray->ppFreeBlock =
467 (void **)((unsigned long)pMemArray->ppFreeBlock & 0xFFFFFFFFFFFFFFF0);
468 *pMemArray->ppFreeBlock =
469 (void **)((unsigned long)*pMemArray->ppFreeBlock & 0xFFFFFFFFFFFFFFF0);
471 if ((*pMemArray->ppFreeBlock != NULL) &&
472 (((*pMemArray->ppFreeBlock) < pMemArray->pStorage) ||
473 ((*pMemArray->ppFreeBlock) >= pMemArray->pEndOfStorage))) {
475 "ERROR: Corrupted MemArray;Arr=%p,Stor=%p,Free=%p,Curr=%p\n",
476 pMemArray, pMemArray->pStorage, pMemArray->ppFreeBlock,
477 *pMemArray->ppFreeBlock);
481 *ppBlock = (void *)pMemArray->ppFreeBlock;
482 pMemArray->ppFreeBlock = (void **)(*pMemArray->ppFreeBlock);
485 (((uint64_t) * ppBlock -
486 (uint64_t) pMemArray->pStorage)) / pMemArray->nBlockSize;
487 if (alloc_track[idx]) {
489 ("wls_fapi_alloc_mem_array Double alloc Arr=%p,Stor=%p,Free=%p,Curr=%p\n",
490 pMemArray, pMemArray->pStorage, pMemArray->ppFreeBlock,
491 *pMemArray->ppFreeBlock);
494 #ifdef MEMORY_CORRUPTION_DETECT
495 uint32_t nBlockSize = pMemArray->nBlockSize, i;
496 uint8_t *p = (uint8_t *) * ppBlock;
498 p += (nBlockSize - 16);
499 for (i = 0; i < 16; i++) {
500 p[i] = MEMORY_CORRUPTION_DETECT_FLAG;
503 alloc_track[idx] = 1;
506 //printf("Block allocd [%p,%p]\n", pMemArray, *ppBlock);
511 //------------------------------------------------------------------------------
512 /** @ingroup nr5g_fapi_source_framework_wls_lib_group
514 * @param[in] A pointer to the FAPI Memory Structure (Initialized by L2)
515 * @param[in] pBlock Pointer where the allocated memory block is stored
517 * @return 0 if SUCCESS
519 * @description This function frees a WLS block of memory and adds
520 * it back to the pool
523 //------------------------------------------------------------------------------
524 uint32_t wls_fapi_free_mem_array(
525 PWLS_FAPI_MEM_STRUCT pMemArray,
529 unsigned long mask = (((unsigned long)pMemArray->nBlockSize) - 1);
531 pBlock = (void *)((unsigned long)pBlock & ~mask);
533 if ((pBlock < pMemArray->pStorage) || (pBlock >= pMemArray->pEndOfStorage)) {
535 ("wls_fapi_free_mem_array WARNING: Trying to free foreign block;Arr=%p,Blk=%p pStorage [%p .. %p]\n",
536 pMemArray, pBlock, pMemArray->pStorage, pMemArray->pEndOfStorage);
541 (int)(((uint64_t) pBlock -
542 (uint64_t) pMemArray->pStorage)) / pMemArray->nBlockSize;
544 if (alloc_track[idx] == 0) {
546 ("wls_fapi_free_mem_array ERROR: Double free Arr=%p,Stor=%p,Free=%p,Curr=%p\n",
547 pMemArray, pMemArray->pStorage, pMemArray->ppFreeBlock, pBlock);
550 #ifdef MEMORY_CORRUPTION_DETECT
551 uint32_t nBlockSize = pMemArray->nBlockSize, i;
552 uint8_t *p = (uint8_t *) pBlock;
554 p += (nBlockSize - 16);
555 for (i = 0; i < 16; i++) {
556 if (p[i] != MEMORY_CORRUPTION_DETECT_FLAG) {
557 printf("ERROR: Corruption\n");
558 nr5g_fapi_wls_print_stats();
563 alloc_track[idx] = 0;
566 if (((void *)pMemArray->ppFreeBlock) == pBlock) {
567 // Simple protection against freeing of already freed block
570 // FIXME: Remove after debugging
571 if ((pMemArray->ppFreeBlock != NULL)
572 && (((void *)pMemArray->ppFreeBlock < pMemArray->pStorage)
573 || ((void *)pMemArray->ppFreeBlock >= pMemArray->pEndOfStorage))) {
575 ("wls_fapi_free_mem_array ERROR: Corrupted MemArray;Arr=%p,Stor=%p,Free=%p\n",
576 pMemArray, pMemArray->pStorage, pMemArray->ppFreeBlock);
579 // FIXME: Remove after debugging
580 if ((pBlock < pMemArray->pStorage) || (pBlock >= pMemArray->pEndOfStorage)) {
581 printf("wls_fapi_free_mem_array ERROR: Invalid block;Arr=%p,Blk=%p\n",
587 (void **)((unsigned long)pMemArray->ppFreeBlock & 0xFFFFFFFFFFFFFFF0);
588 pMemArray->ppFreeBlock =
589 (void **)((unsigned long)pBlock & 0xFFFFFFFFFFFFFFF0);
591 //printf("Block freed [%p,%p]\n", pMemArray, pBlock);
596 //------------------------------------------------------------------------------
597 /** @ingroup nr5g_fapi_source_framework_wls_lib_group
599 * @param size (if 0 fixed size from pool)
600 * @param Number of locations
602 * @return 0 if SUCCESS
604 * @description This function initializes WLS layer primitives and allocates
605 * memory needed to exchange APIs between FAPI and PHY.
607 //------------------------------------------------------------------------------
608 void *wls_fapi_alloc_buffer(
613 p_nr5g_fapi_wls_context_t pWls = nr5g_fapi_wls_context();
615 if (pthread_mutex_lock((pthread_mutex_t *) & pWls->fapi2phy_lock_alloc)) {
616 NR5G_FAPI_LOG(ERROR_LOG, ("unable to get lock alloc pthread mutex"));
620 if (wls_fapi_alloc_mem_array(&pWls->sWlsStruct, &pBlock) != SUCCESS) {
621 printf("wls_fapi_alloc_buffer alloc error size[%d] loc[%d]\n", size,
623 nr5g_fapi_wls_print_stats();
626 pWls->nAllocBlocks++;
629 //printf("----------------wls_fapi_alloc_buffer: size[%d] loc[%d] buf[%p] nAllocBlocks[%d]\n", size, loc, pBlock, pWls->nAllocBlocks);
631 //printf("[%p]\n", pBlock);
633 pWls->nTotalAllocCnt++;
634 if (loc < MAX_DL_BUF_LOCATIONS)
635 pWls->nTotalDlBufAllocCnt[loc]++;
636 else if (loc < MAX_UL_BUF_LOCATIONS)
637 pWls->nTotalUlBufAllocCnt++;
639 if (pthread_mutex_unlock((pthread_mutex_t *) & pWls->fapi2phy_lock_alloc)) {
640 NR5G_FAPI_LOG(ERROR_LOG, ("unable to unlock alloc pthread mutex"));
647 //------------------------------------------------------------------------------
648 /** @ingroup nr5g_fapi_source_framework_wls_lib_group
650 * @param[in] *pMsg Pointer to free
654 * @descriptioni This function frees a block of memory and adds it back to
658 //------------------------------------------------------------------------------
659 void wls_fapi_free_buffer(
663 p_nr5g_fapi_wls_context_t pWls = nr5g_fapi_wls_context();
665 if (pthread_mutex_lock((pthread_mutex_t *) & pWls->fapi2phy_lock_alloc)) {
666 NR5G_FAPI_LOG(ERROR_LOG, ("unable to lock alloc pthread mutex"));
669 //printf("----------------wls_fapi_free_buffer: buf[%p] loc[%d]\n", pMsg, loc);
670 if (wls_fapi_free_mem_array(&pWls->sWlsStruct, (void *)pMsg) == SUCCESS) {
671 pWls->nAllocBlocks--;
673 printf("wls_fapi_free_buffer Free error\n");
674 nr5g_fapi_wls_print_stats();
678 pWls->nTotalFreeCnt++;
679 if (loc < MAX_DL_BUF_LOCATIONS)
680 pWls->nTotalDlBufFreeCnt[loc]++;
681 else if (loc < MAX_UL_BUF_LOCATIONS)
682 pWls->nTotalUlBufFreeCnt++;
684 if (pthread_mutex_unlock((pthread_mutex_t *) & pWls->fapi2phy_lock_alloc)) {
685 NR5G_FAPI_LOG(ERROR_LOG, ("unable to unlock alloc pthread mutex"));
690 //------------------------------------------------------------------------------
691 /** @ingroup nr5g_fapi_source_framework_wls_lib_group
693 * @param A pointer to a wls instance
695 * @return 0 if SUCCESS
697 * @description This function initializes the WLS layer FAPI2PHY interface
698 * primitives and allocates memory needed to exchange APIs
699 * between FAPI and PHY.
701 //------------------------------------------------------------------------------
702 uint8_t nr5g_fapi_wls_memory_init(
706 p_nr5g_fapi_wls_context_t p_wls = nr5g_fapi_wls_context();
708 if (FAILURE == wls_fapi_create_partition(p_wls))
711 if ((nBlocks = wls_fapi_add_blocks_to_ul()) == 0) {
712 NR5G_FAPI_LOG(ERROR_LOG, ("Unable to allocate blocks to PHY"));