WLS
來源:
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%2Fphy.git;a=summary—- 可以自選一個snapshot查看源碼實現
https://gerrit.o-ran-sc.org/r/gitweb?p=o-du%2Fphy.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%2Fphy.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 environment
RTE_TARGET?= x86_64-native-linuxapp-icc # 默認英特爾的 ICC 我們可以設置成 gcc
RTE_OUTPUT = ${PWD}
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 %d\n”, 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 返回給用戶
總結
- 上一篇: HTTP、HTTPS常用的默认端口号(十
- 下一篇: 使用:focus-within实现下拉菜