|
|
|
@ -27,16 +27,14 @@ struct srslte_pnf_info_t {
|
|
|
|
|
|
|
|
|
|
struct srslte_vnf_info_t {};
|
|
|
|
|
|
|
|
|
|
srslte_basic_vnf::srslte_basic_vnf(const vnf_args_t& args_, srslte::logger* logger_, stack_interface_phy_nr* stack_) :
|
|
|
|
|
srslte_basic_vnf::srslte_basic_vnf(const vnf_args_t& args_, stack_interface_phy_nr* stack_) :
|
|
|
|
|
m_args(args_),
|
|
|
|
|
m_logger(logger_),
|
|
|
|
|
thread("BASIC_VNF_P7"),
|
|
|
|
|
m_tx_req_msg(new basic_vnf_api::tx_request_msg_t),
|
|
|
|
|
log_h("VNF"),
|
|
|
|
|
m_pool(srslte::byte_buffer_pool::get_instance())
|
|
|
|
|
{
|
|
|
|
|
log_h->set_level(m_args.log_level);
|
|
|
|
|
log_h->set_hex_limit(m_args.log_hex_limit);
|
|
|
|
|
logger.set_level(srslog::str_to_basic_level(m_args.log_level));
|
|
|
|
|
logger.set_hex_dump_max_size(m_args.log_hex_limit);
|
|
|
|
|
|
|
|
|
|
if (m_args.type == "gnb" || m_args.type == "ue") {
|
|
|
|
|
if (m_args.type == "gnb") {
|
|
|
|
@ -45,10 +43,10 @@ srslte_basic_vnf::srslte_basic_vnf(const vnf_args_t& args_, srslte::logger* logg
|
|
|
|
|
m_ue_stack = (srsue::stack_interface_phy_nr*)stack_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log_h->info("Initializing VNF for gNB\n");
|
|
|
|
|
logger.info("Initializing VNF for gNB");
|
|
|
|
|
start();
|
|
|
|
|
} else {
|
|
|
|
|
log_h->error("Unknown VNF type. Exiting\n.");
|
|
|
|
|
logger.error("Unknown VNF type. Exiting.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -98,7 +96,7 @@ void srslte_basic_vnf::run_thread()
|
|
|
|
|
|
|
|
|
|
running = true;
|
|
|
|
|
|
|
|
|
|
log_h->info("Started VNF handler listening on %s:%d\n", m_args.bind_addr.c_str(), m_args.bind_port);
|
|
|
|
|
logger.info("Started VNF handler listening on %s:%d", m_args.bind_addr.c_str(), m_args.bind_port);
|
|
|
|
|
|
|
|
|
|
while (running) {
|
|
|
|
|
int ret = poll(&fd, 1, RX_TIMEOUT_MS);
|
|
|
|
@ -118,14 +116,14 @@ void srslte_basic_vnf::run_thread()
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
log_h->info("VNF thread stopped\n");
|
|
|
|
|
logger.info("VNF thread stopped");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int srslte_basic_vnf::handle_msg(const uint8_t* buffer, const uint32_t len)
|
|
|
|
|
{
|
|
|
|
|
basic_vnf_api::msg_header_t* header = (basic_vnf_api::msg_header_t*)buffer;
|
|
|
|
|
|
|
|
|
|
log_h->info("Received %s (%d B)\n", basic_vnf_api::msg_type_text[header->type], len);
|
|
|
|
|
logger.info("Received %s (%d B)", basic_vnf_api::msg_type_text[header->type], len);
|
|
|
|
|
|
|
|
|
|
switch (header->type) {
|
|
|
|
|
case basic_vnf_api::SF_IND:
|
|
|
|
@ -153,7 +151,7 @@ int srslte_basic_vnf::handle_msg(const uint8_t* buffer, const uint32_t len)
|
|
|
|
|
int srslte_basic_vnf::handle_sf_ind(basic_vnf_api::sf_ind_msg_t* msg)
|
|
|
|
|
{
|
|
|
|
|
int ret = SRSLTE_SUCCESS;
|
|
|
|
|
log_h->info("Received %s for TTI=%d\n", basic_vnf_api::msg_type_text[msg->header.type], msg->tti);
|
|
|
|
|
logger.info("Received %s for TTI=%d", basic_vnf_api::msg_type_text[msg->header.type], msg->tti);
|
|
|
|
|
|
|
|
|
|
// store Rx timestamp
|
|
|
|
|
last_sf_indication_time = msg->t1;
|
|
|
|
@ -172,7 +170,7 @@ int srslte_basic_vnf::handle_sf_ind(basic_vnf_api::sf_ind_msg_t* msg)
|
|
|
|
|
int srslte_basic_vnf::handle_dl_ind(basic_vnf_api::dl_ind_msg_t* msg)
|
|
|
|
|
{
|
|
|
|
|
int ret = SRSLTE_ERROR;
|
|
|
|
|
log_h->info("Received %s for TTI=%d\n", basic_vnf_api::msg_type_text[msg->header.type], msg->tti);
|
|
|
|
|
logger.info("Received %s for TTI=%d", basic_vnf_api::msg_type_text[msg->header.type], msg->tti);
|
|
|
|
|
|
|
|
|
|
uint32_t cc_idx = 0;
|
|
|
|
|
|
|
|
|
@ -181,7 +179,7 @@ int srslte_basic_vnf::handle_dl_ind(basic_vnf_api::dl_ind_msg_t* msg)
|
|
|
|
|
dl_grant.tti = msg->tti;
|
|
|
|
|
|
|
|
|
|
if (msg->nof_pdus > SRSLTE_MAX_TB) {
|
|
|
|
|
log_h->error("Too many TBs (%d > %d)\n", msg->nof_pdus, SRSLTE_MAX_TB);
|
|
|
|
|
logger.error("Too many TBs (%d > %d)", msg->nof_pdus, SRSLTE_MAX_TB);
|
|
|
|
|
goto exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -194,7 +192,7 @@ int srslte_basic_vnf::handle_dl_ind(basic_vnf_api::dl_ind_msg_t* msg)
|
|
|
|
|
m_ue_stack->tb_decoded(cc_idx, dl_grant);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
log_h->error("TB too big to fit into buffer (%d > %d)\n", msg->pdus[i].length, dl_grant.tb[i]->get_tailroom());
|
|
|
|
|
logger.error("TB too big to fit into buffer (%d > %d)", msg->pdus[i].length, dl_grant.tb[i]->get_tailroom());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -207,10 +205,10 @@ exit:
|
|
|
|
|
|
|
|
|
|
int srslte_basic_vnf::handle_ul_ind(basic_vnf_api::ul_ind_msg_t* msg)
|
|
|
|
|
{
|
|
|
|
|
log_h->info("Received %s for TTI=%d\n", basic_vnf_api::msg_type_text[msg->header.type], msg->tti);
|
|
|
|
|
logger.info("Received %s for TTI=%d", basic_vnf_api::msg_type_text[msg->header.type], msg->tti);
|
|
|
|
|
|
|
|
|
|
if (msg->pdus.type != basic_vnf_api::PUSCH) {
|
|
|
|
|
log_h->error("Received UL indication for wrong PDU type\n");
|
|
|
|
|
logger.error("Received UL indication for wrong PDU type");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -228,10 +226,10 @@ int srslte_basic_vnf::handle_ul_ind(basic_vnf_api::ul_ind_msg_t* msg)
|
|
|
|
|
|
|
|
|
|
int srslte_basic_vnf::handle_rx_data_ind(basic_vnf_api::rx_data_ind_msg_t* msg)
|
|
|
|
|
{
|
|
|
|
|
log_h->info("Received %s for TTI=%d\n", basic_vnf_api::msg_type_text[msg->header.type], msg->sfn);
|
|
|
|
|
logger.info("Received %s for TTI=%d", basic_vnf_api::msg_type_text[msg->header.type], msg->sfn);
|
|
|
|
|
|
|
|
|
|
if (msg->nof_pdus != 1 || msg->pdus[0].type != basic_vnf_api::PUSCH) {
|
|
|
|
|
log_h->error("Received UL indication for wrong PDU type\n");
|
|
|
|
|
logger.error("Received UL indication for wrong PDU type");
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -267,10 +265,10 @@ int srslte_basic_vnf::dl_config_request(const srsenb::phy_interface_stack_nr::dl
|
|
|
|
|
uint32_t len = sizeof(dl_conf);
|
|
|
|
|
|
|
|
|
|
// Send it to PNF
|
|
|
|
|
log_h->info("Sending %s (%d B)\n", basic_vnf_api::msg_type_text[dl_conf.header.type], len);
|
|
|
|
|
logger.info("Sending %s (%d B)", basic_vnf_api::msg_type_text[dl_conf.header.type], len);
|
|
|
|
|
int n = 0;
|
|
|
|
|
if ((n = sendto(sockfd, &dl_conf, len, MSG_CONFIRM, (struct sockaddr*)&client_addr, sizeof(client_addr))) < 0) {
|
|
|
|
|
log_h->error("sendto failed, ret=%d\n", n);
|
|
|
|
|
logger.error("sendto failed, ret=%d", n);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
@ -294,7 +292,7 @@ int srslte_basic_vnf::tx_request(const srsue::phy_interface_stack_nr::tx_request
|
|
|
|
|
// copy data from TB0
|
|
|
|
|
memcpy(m_tx_req_msg->pdus[0].data, request.data, request.tb_len);
|
|
|
|
|
} else {
|
|
|
|
|
log_h->error("Trying to send %d B PDU. Maximum size is %d B\n", request.tb_len, MAX_PDU_SIZE);
|
|
|
|
|
logger.error("Trying to send %d B PDU. Maximum size is %d B", request.tb_len, MAX_PDU_SIZE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// calculate actual length of
|
|
|
|
@ -304,11 +302,11 @@ int srslte_basic_vnf::tx_request(const srsue::phy_interface_stack_nr::tx_request
|
|
|
|
|
m_tx_req_msg->header.msg_len = len - sizeof(basic_vnf_api::msg_header_t);
|
|
|
|
|
|
|
|
|
|
// Send it to PNF
|
|
|
|
|
log_h->info("Sending %s (%d B)\n", basic_vnf_api::msg_type_text[m_tx_req_msg->header.type], len);
|
|
|
|
|
logger.info("Sending %s (%d B)", basic_vnf_api::msg_type_text[m_tx_req_msg->header.type], len);
|
|
|
|
|
int n = 0;
|
|
|
|
|
if ((n = sendto(sockfd, m_tx_req_msg.get(), len, MSG_CONFIRM, (struct sockaddr*)&client_addr, sizeof(client_addr))) <
|
|
|
|
|
0) {
|
|
|
|
|
log_h->error("sendto failed, ret=%d\n", n);
|
|
|
|
|
logger.error("sendto failed, ret=%d", n);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
@ -317,7 +315,7 @@ int srslte_basic_vnf::tx_request(const srsue::phy_interface_stack_nr::tx_request
|
|
|
|
|
int srslte_basic_vnf::tx_request(const srsenb::phy_interface_stack_nr::tx_request_t& request)
|
|
|
|
|
{
|
|
|
|
|
if (request.nof_pdus > MAX_NUM_PDUS) {
|
|
|
|
|
log_h->error("Trying to send %d PDUs but only %d supported\n", request.nof_pdus, MAX_NUM_PDUS);
|
|
|
|
|
logger.error("Trying to send %d PDUs but only %d supported", request.nof_pdus, MAX_NUM_PDUS);
|
|
|
|
|
return SRSLTE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
if (request.nof_pdus == 0) {
|
|
|
|
@ -339,7 +337,7 @@ int srslte_basic_vnf::tx_request(const srsenb::phy_interface_stack_nr::tx_reques
|
|
|
|
|
// copy data from TB0
|
|
|
|
|
memcpy(m_tx_req_msg->pdus[i].data, request.pdus[i].data[0], m_tx_req_msg->pdus[i].length);
|
|
|
|
|
} else {
|
|
|
|
|
log_h->error("Trying to send %d B PDU. Maximum size is %d B\n", request.pdus[i].length, MAX_PDU_SIZE);
|
|
|
|
|
logger.error("Trying to send %d B PDU. Maximum size is %d B", request.pdus[i].length, MAX_PDU_SIZE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -350,21 +348,21 @@ int srslte_basic_vnf::tx_request(const srsenb::phy_interface_stack_nr::tx_reques
|
|
|
|
|
m_tx_req_msg->header.msg_len = len - sizeof(basic_vnf_api::msg_header_t);
|
|
|
|
|
|
|
|
|
|
// Send it to PNF
|
|
|
|
|
log_h->info("Sending %s (%d B)\n", basic_vnf_api::msg_type_text[m_tx_req_msg->header.type], len);
|
|
|
|
|
if (log_h->get_level() == LOG_LEVEL_DEBUG) {
|
|
|
|
|
logger.info("Sending %s (%d B)", basic_vnf_api::msg_type_text[m_tx_req_msg->header.type], len);
|
|
|
|
|
if (logger.debug.enabled()) {
|
|
|
|
|
for (uint32_t i = 0; i < m_tx_req_msg->nof_pdus; ++i) {
|
|
|
|
|
log_h->debug_hex(m_tx_req_msg->pdus[i].data,
|
|
|
|
|
m_tx_req_msg->pdus[i].length,
|
|
|
|
|
"Sending PDU %s:%d (%d bytes)\n",
|
|
|
|
|
basic_vnf_api::msg_type_text[m_tx_req_msg->header.type],
|
|
|
|
|
m_tx_req_msg->pdus[i].index,
|
|
|
|
|
m_tx_req_msg->pdus[i].length);
|
|
|
|
|
logger.debug(m_tx_req_msg->pdus[i].data,
|
|
|
|
|
m_tx_req_msg->pdus[i].length,
|
|
|
|
|
"Sending PDU %s:%d (%d bytes)",
|
|
|
|
|
basic_vnf_api::msg_type_text[m_tx_req_msg->header.type],
|
|
|
|
|
m_tx_req_msg->pdus[i].index,
|
|
|
|
|
m_tx_req_msg->pdus[i].length);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int n = 0;
|
|
|
|
|
if ((n = sendto(sockfd, m_tx_req_msg.get(), len, MSG_CONFIRM, (struct sockaddr*)&client_addr, sizeof(client_addr))) <
|
|
|
|
|
0) {
|
|
|
|
|
log_h->error("sendto failed, ret=%d\n", n);
|
|
|
|
|
logger.error("sendto failed, ret=%d", n);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|