来源:
https://docs.o-ran-sc.org/projects/o-ran-sc-o-du-phy/en/latest/wls-lib.html
Wls_lib是英特尔开元的一个无线服务库,支持实现gNb或eNb的应用程序使用的共享内存和缓冲区管理。该库使用DPDK、libhugetlbfs和pthreads,通过从DPDK的角度共享相同的内存区域,在二级应用程序、API转换器模块和一级应用程序之间提供无内存的数据交换。
Project Resources
The source code is avalable from the Linux Foundation Gerrit server: https://gerrit.o-ran-sc.org/r/gitweb?p=o-du/phy.git;a=summary —- 可以自选一个snapshot查看源码实现
https://gerrit.o-ran-sc.org/r/gitweb?p=o-du/phy.git
Library Functions 基本库函数
WLS_Open() and WLS_Open_Dual() that open a single or dual wls instance interface and registers the instance with the kernel space driver. WLS_Close(), WLS_Close1() closes the wls instance and deregisters it from the kernel space driver. WLS_Ready(), WLS_Ready1() checks state of remote peer of WLS interface and returns 1 if remote peer is available. WLS_Alloc() allocates a memory block for data exchange shared memory. This block uses hugepages. WLS_Free() frees memory block for data exchange shared memory. WLS_Put(), WLS_Put1() puts memory block (or group of blocks) allocated from WLS memory into the interface for transfer to remote peer. WLS_Check(), WLS_Check1() checks if there are memory blocks with data from remote peer and returns number of blocks available for “get” operation. WLS_Get(), WLS_Get1() gets memory block from interface received from remote peer. Function is a non-blocking operation and returns NULL if no blocks available. WLS_Wait(), WLS_Wait1() waits for new memory block from remote peer. This Function is a blocking call and returns number of blocks received. WLS_WakeUp(), WLS_WakeUp1() performs “wakeup” notification to remote peer to unblock “wait” operations pending. WLS_Get(), WLS_Get1() gets a memory block from the interface received from remote peer. This Function is blocking operation and waits till next memory block from remote peer. WLS_VA2PA() converts virtual address (VA) to physical address (PA). WLS_PA2VA() converts physical address (PA) to virtual address (VA). WLS_EnqueueBlock(), WLS_EnqueueBlock1() This function is used by a master or secondary master to provide memory blocks to a slave for next slave to master (sec master) transfer of data. WLS_NumBlocks() returns number of current available blocks provided by master for a new transfer of data from the slave. The _1() functions are only needed when using the WLS_Open_Dual().
Building and Installation
Retrieve the source files from the Linux Foundation Gerrit server: https://gerrit.o-ran-sc.org/r/gitweb?p=o-du/phy.git;a=summary
- cd wls_lib
- wls_lib$ ./build.sh xclean
- wls_lib$ ./build.sh
The shared library is available at wls_lib/lib
This library is used by the ODUHIGH, shin layer implementing a 5G FAPI to IAPI translator and the ODULOW components.
Please define an environment variable DIR_WIRELESS_WLS with the path to the root folder of the wls_lib as it is needed for the fapi_5g build process.
编译依赖DPDK,需要编译好DPDK lib提供基本的rte静态库和头文件。
下载最新的节点,看看里面都用了啥?
phy-81a0969.tar.gz
wls_lib 下 Makefile
ifeq ((RTE_SDK),) #依赖dpdk的编译结果(error “Please define RTE_SDK environment variable”)endif# Default target, can be overridden by command line or environmentRTE_TARGET ?= x86_64-native-linuxapp-icc # 默认英特尔的 ICC 我们可以设置成 gccRTE_OUTPUT =
include $(RTE_SDK)/mk/rte.vars.mk SRCS-y := wls_lib_dpdk.c syslib.c # 实现代码都在这2个C文件中 SHARED = libwls.so # 输出动态库
CFLAGS =-Wall -fstack-protector EXTRA_CFLAGS =-g include $(RTE_SDK)/mk/rte.extshared.mk #依赖dpdk的环境变量设置
##############################################################
wls_initialize
初始化由 RTE_PROC_PRIMARY 进程执行
rte_memzone_reserve_aligned
多申请sizeof(wls_drv_ctx_t)保存上下文信息;该wls_drv_ctx_t信息是保存在数据位尾部分
pthread_mutexattr_init(&attr); pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); if (ret = pthread_mutex_init(&mng_ctx->mng_mutex, &attr)) { PLIB_ERR(“Failed to initialize mng_mutex %dn”, ret); pthread_mutexattr_destroy(&attr); return ret; } pthread_mutexattr_destroy(&attr);
pWls_us=wls_create_us_ctx
初始化队列
SFL_DefQueue(&pUsCtx->ul_free_block_pq, pUsCtx->ul_free_block_storage, UL_FREE_BLOCK_QUEUE_SIZE * sizeof (void*)); WLS_MsgDefineQueue(&pUsCtx->get_queue, pUsCtx->get_storage, WLS_GET_QUEUE_N_ELEMENTS, 0); WLS_MsgDefineQueue(&pUsCtx->put_queue, pUsCtx->put_storage, WLS_PUT_QUEUE_N_ELEMENTS, 0);
sem_init(&pUs_priv->sema.sem
将 pWls_us 返回给用户
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/168128.html原文链接:https://javaforall.cn