Implementation of STOP exchange

This implements the STOP.request/indication for all 3 transport mechanisms, the VNF will send the STOP.request to the PNF, indicating it will disconnect, and await a STOP.indication from the PNF

The WLS VNF is reworked to be able to start before the PNF, by calling call rte_eal_init and rte_dev_probe to determine if dpdk has been initialized properly, before calling rte_eal_init in the intended process when it is appropriate to do so
This commit is contained in:
Rúben Soares Silva
2025-10-23 14:08:37 +01:00
parent 3247c2933f
commit e08d904af0
26 changed files with 344 additions and 20 deletions
@@ -25,7 +25,6 @@
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include "wls_lib.h"
#include "nfapi/open-nFAPI/fapi/inc/nr_fapi_p5_utils.h"
#include "nfapi/open-nFAPI/fapi/inc/nr_fapi_p7_utils.h"
@@ -30,4 +30,6 @@ bool wls_pnf_nr_send_p7_message(pnf_p7_t* pnf_p7,nfapi_nr_p7_message_header_t *m
void *wls_fapi_pnf_nr_start_thread(void *ptr);
int wls_fapi_nr_pnf_start();
void wls_pnf_set_p7_config(void *p7_config);
void wls_fapi_nr_pnf_stop();
void wls_pnf_close(pthread_t p5_thread);
#endif // OPENAIRINTERFACE_WLS_PNF_H
@@ -29,4 +29,6 @@ void *wls_fapi_vnf_nr_start_thread(void *ptr);
int wls_fapi_nr_vnf_start();
bool wls_vnf_nr_send_p5_message(vnf_t *vnf,uint16_t p5_idx, nfapi_nr_p4_p5_message_header_t* msg, uint32_t msg_len);
bool wls_vnf_nr_send_p7_message(vnf_p7_t* vnf_p7,nfapi_nr_p7_message_header_t* msg);
void wls_vnf_send_stop_request();
void wls_vnf_stop();
#endif //OPENAIRINTERFACE_WLS_VNF_H
@@ -20,7 +20,7 @@
*/
#include "wls_common.h"
#include "wls_lib.h"
void fill_fapi_list_elem(p_fapi_api_queue_elem_t currElem, p_fapi_api_queue_elem_t nextElem, const uint8_t msgType, const uint8_t numMsgInBlock, const uint32_t alignOffset)
{
currElem->msg_type = msgType;
@@ -90,9 +90,19 @@ uint8_t wls_send_fapi_msg(PWLS_MAC_CTX pWls, const uint16_t message_id, const in
{
int num_avail_blocks = WLS_NumBlocks(pWls->hWls);
NFAPI_TRACE(NFAPI_TRACE_DEBUG,"num_avail_blocks is %d\n", num_avail_blocks);
int counter = 0;
while (num_avail_blocks < 2) {
num_avail_blocks = WLS_NumBlocks(pWls->hWls);
NFAPI_TRACE(NFAPI_TRACE_DEBUG,"num_avail_blocks is %d\n", num_avail_blocks);
if (message_id == NFAPI_NR_PHY_MSG_TYPE_STOP_INDICATION) {
// In the case of the STOP.indication, it can happen that this is called after the VNF stopped
// For example, if it crashed for some reason, in that case, implement a timeout and return
usleep(10 * 1000);
counter++;
if (counter == 10) {
return true;
}
}
}
/* get PA blocks for header and msg */
uint64_t pa_hdr = dequeueBlock(pWls);
@@ -29,9 +29,10 @@
#include <pnf_p7.h>
#include <sys/time.h>
#include "wls_lib.h"
#include "pnf.h"
#include "nr_nfapi_p7.h"
#include "nr_fapi_p5.h"
#include "nfapi/open-nFAPI/fapi/inc/nr_fapi_p7_utils.h"
// A copy of the PNF P7 config is needed for the message processing thread, in other transport mechanisms where P7 is handled in a
// different thread, the config is passed to it upon the thread creation
@@ -65,6 +66,28 @@ void *wls_fapi_pnf_nr_start_thread(void *ptr)
return (void *)0;
}
void wls_pnf_close(pthread_t p5_thread)
{
_this->terminate = 1;
WLS_WakeUp(wls_mac_get_ctx()->hWls);
pthread_join(p5_thread, NULL);
if (WLS_Close(wls_mac_get_ctx()->hWls) != 0) {
NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] WLS_CLose call failed...\n");
} else {
NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] WLS_CLose called successfully...\n");
}
rte_eal_cleanup();
}
void wls_fapi_nr_pnf_stop()
{
AssertFatal(cfg->nr_stop_req, "STOP.request Handler should be set!");
nfapi_nr_stop_request_scf_t req = {0};
req.header.phy_id = 0;
req.header.message_id = NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST;
cfg->nr_stop_req(cfg, 0, &req);
}
int wls_fapi_nr_pnf_start()
{
int64_t ret;
@@ -194,6 +217,9 @@ bool wls_pnf_nr_send_p7_message(pnf_p7_t *pnf_p7, nfapi_nr_p7_message_header_t *
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "num_avail_blocks is %d\n", num_avail_blocks);
while (num_avail_blocks < 2) {
num_avail_blocks = WLS_NumBlocks(pWls->hWls);
if (_this->terminate) {
return false;
}
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "num_avail_blocks is %d\n", num_avail_blocks);
}
/* get PA blocks for header and msg */
@@ -254,7 +280,7 @@ void phy_mac_recv()
bool to_return = false;
while (_this->terminate == 0) {
int numMsgToGet = WLS_Wait(pWls->hWls);
if (numMsgToGet == 0) {
if (numMsgToGet == 0 || _this->terminate) {
continue;
}
uint64_t PAs[numMsgToGet];
@@ -279,6 +305,11 @@ void phy_mac_recv()
}
}
}
// A STOP.indication might have been processed, which set's terminate to 1
// don't return pages in that case
if (_this->terminate) {
break;
}
if (to_return) {
// We only return the pages to be enqueued in case we're using the OAI VNF,
// The Radisys O-DU handles enqueueing the blocks differently, and also doesn't handle receiving a single block
@@ -21,7 +21,8 @@
#include "wls_vnf.h"
#include "vnf_p7.h"
#include "common/utils/LOG/log.h"
#include "wls_lib.h"
#include <rte_eal.h>
#include <rte_string_fns.h>
#include <rte_common.h>
@@ -31,8 +32,9 @@
#include <rte_errno.h>
#include <unistd.h>
#include <common/platform_constants.h>
#include <sys/wait.h>
#include "nfapi_vnf.h"
static nfapi_vnf_config_t *config;
static WLS_MAC_CTX wls_mac_iface;
vnf_t *_vnf = NULL;
@@ -306,6 +308,33 @@ static int vnf_wls_init()
return 1;
}
void wls_vnf_stop()
{
vnf_p7_t *p7_vnf = get_p7_vnf();
_vnf->terminate = 1;
p7_vnf->terminate = 1;
rte_eal_cleanup();
}
void wls_vnf_send_stop_request()
{
PWLS_MAC_CTX pWls = wls_mac_get_ctx();
nfapi_nr_stop_request_scf_t req = {.header.message_id = NFAPI_NR_PHY_MSG_TYPE_STOP_REQUEST, .header.phy_id = 0};
vnf_p7_t *p7_vnf = get_p7_vnf();
nfapi_vnf_config_t * config = get_config();
if (p7_vnf == NULL || pWls->hWls == NULL) {
nfapi_nr_stop_indication_scf_t msg;
msg.header.message_id = NFAPI_NR_PHY_MSG_TYPE_STOP_INDICATION;
msg.header.phy_id = 0;
config->nr_stop_ind(config, 0, &msg);
return;
}
if (pWls->hWls != NULL) {
nfapi_nr_vnf_stop_req(config, 0, &req);
}
}
void *wls_fapi_vnf_nr_start_thread(void *ptr)
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] IN WLS PNF NFAPI start thread %s\n", __FUNCTION__);
@@ -366,7 +395,7 @@ int wls_fapi_nr_vnf_start(nfapi_vnf_config_t *cfg)
PWLS_MAC_CTX pWls = wls_mac_get_ctx();
while (_vnf->terminate == 0) {
int numMsgToGet = WLS_Wait(pWls->hWls);
if (numMsgToGet == 0) {
if (numMsgToGet == 0 || _vnf->terminate) {
continue;
}
@@ -384,6 +413,9 @@ int wls_fapi_nr_vnf_start(nfapi_vnf_config_t *cfg)
procPhyMessages(len, (void *)(msg + 1), msg->msg_type);
}
}
if (_vnf->terminate) {
break;
}
for (int i = 0; i < pa_idx; i++) {
if (WLS_EnqueueBlock(pWls->hWls, PAs[i]) == -1) {
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "Error in WLS_EnqueueBlock for block %lu\n", PAs[i]);