Commit 7c18dfd9 authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/remove-benetel-radio-drivers' into...

Merge remote-tracking branch 'origin/remove-benetel-radio-drivers' into integration_2025_w43 (!3719)

Remove Benetel-specific radio drivers

These drivers are superseded by the O-RAN 7.2 FHI
parents f7639e05 ece13813
...@@ -92,7 +92,7 @@ Options: ...@@ -92,7 +92,7 @@ Options:
USRP, BLADERF, LMSSDR, IRIS, SIMU, AW2SORI, AERIAL, None (Default) USRP, BLADERF, LMSSDR, IRIS, SIMU, AW2SORI, AERIAL, None (Default)
Adds this RF board support (in external packages installation and in compilation) Adds this RF board support (in external packages installation and in compilation)
-t | --transport -t | --transport
Selects the transport protocol type, options: None, Ethernet, benetel4g, benetel5g, oran_fhlib_5g, oran_fhlib_5g_mplane, WLS Selects the transport protocol type, options: None, Ethernet, oran_fhlib_5g, oran_fhlib_5g_mplane, WLS
-P | --phy_simulators -P | --phy_simulators
Makes the unitary tests Layer 1 simulators Makes the unitary tests Layer 1 simulators
-V | --vcd -V | --vcd
...@@ -278,10 +278,6 @@ function main() { ...@@ -278,10 +278,6 @@ function main() {
TARGET_LIST="$TARGET_LIST oai_eth_transpro" TARGET_LIST="$TARGET_LIST oai_eth_transpro"
CMAKE_CMD="$CMAKE_CMD -DOAI_${2^^}=ON" # ^^ makes uppercase CMAKE_CMD="$CMAKE_CMD -DOAI_${2^^}=ON" # ^^ makes uppercase
;; ;;
"benetel4g" | "benetel5g" | "oran_fhlib_4g")
TARGET_LIST="$TARGET_LIST $2"
CMAKE_CMD="$CMAKE_CMD -DOAI_${2^^}=ON" # ^^ makes uppercase
;;
"oran_fhlib_5g") "oran_fhlib_5g")
TARGET_LIST="$TARGET_LIST $2" TARGET_LIST="$TARGET_LIST $2"
CMAKE_CMD="$CMAKE_CMD -DOAI_FHI72=ON" CMAKE_CMD="$CMAKE_CMD -DOAI_FHI72=ON"
......
...@@ -9,5 +9,3 @@ set_target_properties(oai_eth_transpro PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMA ...@@ -9,5 +9,3 @@ set_target_properties(oai_eth_transpro PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMA
add_custom_command(TARGET oai_eth_transpro POST_BUILD add_custom_command(TARGET oai_eth_transpro POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink liboai_eth_transpro.so liboai_transpro.so COMMAND ${CMAKE_COMMAND} -E create_symlink liboai_eth_transpro.so liboai_transpro.so
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_subdirectory(benetel)
pkg_check_modules(libdpdk REQUIRED libdpdk=20.05.0)
add_library(benetel_4g MODULE
benetel.c
shared_buffers.c
low.c
low_dpdk.c
dpdk_driver.c
)
target_compile_definitions(benetel_4g PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -I$ENV{RTE_SDK}/$ENV{RTE_TARGET}/include")
SET(DPDK_LIBS "-Wl,-rpath,$ENV{RTE_SDK}/$ENV{RTE_TARGET}/lib -Wl,--whole-archive -L$ENV{RTE_SDK}/$ENV{RTE_TARGET}/lib -ldpdk -Wl,--no-whole-archive")
target_include_directories(benetel_4g PRIVATE ${libdpdk_INCLUDE_DIRS})
target_link_libraries(benetel_4g PRIVATE ${libdpdk_LIBRARIES})
target_link_libraries(benetel_4g PRIVATE pthread dl rt m numa)
set_target_properties(benetel_4g PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
add_custom_command(TARGET benetel_4g POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink libbenetel_4g.so liboai_transpro.so
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
This diff is collapsed.
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "low.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void store_ul(benetel_t *bs, ul_packet_t *ul)
{
int a = ul->antenna;
if (ul->subframe != bs->next_subframe[a] ||
ul->symbol != bs->next_symbol[a]) {
printf("%s: fatal, antenna %d expected frame.sf.symbol %d.%d.%d, got %d.%d.%d\n",
__FUNCTION__,
a,
bs->expected_benetel_frame[a], bs->next_subframe[a], bs->next_symbol[a],
ul->frame, ul->subframe, ul->symbol);
exit(1);
}
lock_ul_buffer(bs->buffers, bs->next_subframe[a]);
if (bs->buffers->ul_busy[a][bs->next_subframe[a]] & (1 << bs->next_symbol[a])) {
printf("%s: warning, UL overflow (sf.symbol %d.%d)\n", __FUNCTION__,
bs->next_subframe[a], bs->next_symbol[a]);
}
memcpy(bs->buffers->ul[a][bs->next_subframe[a]] + bs->next_symbol[a] * 1200*4,
ul->iq, 1200*4);
bs->buffers->ul_busy[a][bs->next_subframe[a]] |= (1 << bs->next_symbol[a]);
signal_ul_buffer(bs->buffers, bs->next_subframe[a]);
unlock_ul_buffer(bs->buffers, bs->next_subframe[a]);
bs->next_symbol[a]++;
if (bs->next_symbol[a] == 14) {
bs->next_symbol[a] = 0;
bs->next_subframe[a] = (bs->next_subframe[a] + 1) % 10;
if (bs->next_subframe[a] == 0) {
bs->expected_benetel_frame[a]++;
bs->expected_benetel_frame[a] &= 255;
}
}
}
void store_prach(benetel_t *bs, int frame, int subframe, void *data)
{
static int last_frame = -1;
static int last_subframe = -1;
/* hack: antenna number is always 0, discard second packet with same f/sf */
if (frame == last_frame && subframe == last_subframe) return;
last_frame = frame;
last_subframe = subframe;
lock_ul_buffer(bs->buffers, subframe);
if (bs->buffers->prach_busy[subframe]) {
printf("store_prach: fatal: previous prach buffer not processed\n");
unlock_ul_buffer(bs->buffers, subframe);
return;
}
bs->buffers->prach_busy[subframe] = 1;
memcpy(bs->buffers->prach[subframe], data, 849*4);
signal_ul_buffer(bs->buffers, subframe);
unlock_ul_buffer(bs->buffers, subframe);
}
void *benetel_start_dpdk(char *ifname, shared_buffers *buffers, char *dpdk_main_command_line);
void *benetel_start(char *ifname, shared_buffers *buffers, char *dpdk_main_command_line)
{
if (!strcmp(ifname, "dpdk"))
return benetel_start_dpdk(ifname, buffers, dpdk_main_command_line);
printf("benetel: fatal: interface %s not supported, only dpdpk is supported\n", ifname);
exit(1);
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _BENETEL_4G_LOW_H_
#define _BENETEL_4G_LOW_H_
#include "shared_buffers.h"
typedef struct {
shared_buffers *buffers;
/* [2] is for two antennas */
int next_subframe[2];
int next_symbol[2];
int expected_benetel_frame[2];
char *dpdk_main_command_line;
} benetel_t;
typedef struct {
int frame;
int subframe;
int slot;
int symbol;
int antenna;
unsigned char iq[4800];
} ul_packet_t;
void *benetel_start(char *ifname, shared_buffers *buffers, char *dpdk_main_command_line);
void store_ul(benetel_t *bs, ul_packet_t *ul);
void store_prach(benetel_t *bs, int frame, int subframe, void *data);
#endif /* _BENETEL_4G_LOW_H_ */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/* those 2 lines for CPU_SET */
#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "low.h"
int dpdk_main(int argc, char **argv, benetel_t *);
void *dpdk_thread(void *_bs)
{
benetel_t *bs = _bs;
int n = 0;
char **v = NULL; // { "softmodem", "-n", "2", "-l", "8", "--", "-p", "0x2" };
char *s = bs->dpdk_main_command_line;
char *tok;
while ((tok = strtok(s, " ")) != NULL) {
n++;
v = realloc(v, n * sizeof(char *));
if (v == NULL) {
printf("%s: out of memory\n", __FUNCTION__);
exit(1);
}
v[n-1] = tok;
s = NULL;
}
dpdk_main(n, v, bs);
exit(1);
return 0;
}
void *benetel_start_dpdk(char *ifname, shared_buffers *buffers, char *dpdk_main_command_line)
{
benetel_t *bs;
bs = calloc(1, sizeof(benetel_t));
if (bs == NULL) {
printf("%s: out of memory\n", __FUNCTION__);
exit(1);
}
bs->buffers = buffers;
bs->expected_benetel_frame[0] = 255;
bs->expected_benetel_frame[1] = 255;
bs->dpdk_main_command_line = dpdk_main_command_line;
pthread_attr_t attr;
if (pthread_attr_init(&attr) != 0) {
printf("pthread_attr_init failed\n");
exit(1);
}
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(12,&cpuset);
if (pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset) != 0) {
printf("pthread_attr_setaffinity_np failed\n");
exit(1);
}
if (pthread_attr_setschedpolicy(&attr, SCHED_FIFO) != 0) {
printf("pthread_attr_setschedpolicy failed\n");
exit(1);
}
struct sched_param params;
params.sched_priority = sched_get_priority_max(SCHED_FIFO);
if (sched_get_priority_max(SCHED_FIFO) == -1) {
printf("sched_get_priority_max failed\n");
exit(1);
}
if (pthread_attr_setschedparam(&attr, &params) != 0) {
printf("pthread_setschedparam failed\n");
exit(1);
}
pthread_t t;
if (pthread_create(&t, &attr, dpdk_thread, bs) != 0) {
printf("%s: thread creation failed\n", __FUNCTION__);
exit(1);
}
if (pthread_attr_destroy(&attr) != 0) {
printf("pthread_attr_init failed\n");
exit(1);
}
return bs;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "shared_buffers.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void init_buffers(shared_buffers *s)
{
int subframe;
memset(s, 0, sizeof(*s));
for (subframe = 0; subframe < 10; subframe++) {
if (pthread_mutex_init(&s->m_dl[subframe], NULL) != 0 ||
pthread_cond_init(&s->c_dl[subframe], NULL) != 0 ||
pthread_mutex_init(&s->m_ul[subframe], NULL) != 0 ||
pthread_cond_init(&s->c_ul[subframe], NULL) != 0) {
printf("%s: error initializing mutex/cond\n", __FUNCTION__);
exit(1);
}
}
/* in FDD the eNB's first transmitted DL subframe is 4 but the device
* needs to have subframes 1, 2 and 3 ready. Let's pretend there are ready.
*/
s->dl_busy[0][1] = 0x3fff;
s->dl_busy[0][2] = 0x3fff;
s->dl_busy[0][3] = 0x3fff;
s->dl_busy[1][1] = 0x3fff;
s->dl_busy[1][2] = 0x3fff;
s->dl_busy[1][3] = 0x3fff;
}
void lock_dl_buffer(shared_buffers *s, int subframe)
{
if (pthread_mutex_lock(&s->m_dl[subframe]) != 0) {
printf("%s: fatal: lock fails\n", __FUNCTION__);
exit(1);
}
}
void unlock_dl_buffer(shared_buffers *s, int subframe)
{
if (pthread_mutex_unlock(&s->m_dl[subframe]) != 0) {
printf("%s: fatal: unlock fails\n", __FUNCTION__);
exit(1);
}
}
void wait_dl_buffer(shared_buffers *s, int subframe)
{
if (pthread_cond_wait(&s->c_dl[subframe], &s->m_dl[subframe]) != 0) {
printf("%s: fatal: cond_wait fails\n", __FUNCTION__);
exit(1);
}
}
void signal_dl_buffer(shared_buffers *s, int subframe)
{
if (pthread_cond_broadcast(&s->c_dl[subframe]) != 0) {
printf("%s: fatal: cond_broadcast fails\n", __FUNCTION__);
exit(1);
}
}
void lock_ul_buffer(shared_buffers *s, int subframe)
{
if (pthread_mutex_lock(&s->m_ul[subframe]) != 0) {
printf("%s: fatal: lock fails\n", __FUNCTION__);
exit(1);
}
}
void unlock_ul_buffer(shared_buffers *s, int subframe)
{
if (pthread_mutex_unlock(&s->m_ul[subframe]) != 0) {
printf("%s: fatal: unlock fails\n", __FUNCTION__);
exit(1);
}
}
void wait_ul_buffer(shared_buffers *s, int subframe)
{
if (pthread_cond_wait(&s->c_ul[subframe], &s->m_ul[subframe]) != 0) {
printf("%s: fatal: cond_wait fails\n", __FUNCTION__);
exit(1);
}
}
void signal_ul_buffer(shared_buffers *s, int subframe)
{
if (pthread_cond_broadcast(&s->c_ul[subframe]) != 0) {
printf("%s: fatal: cond_broadcast fails\n", __FUNCTION__);
exit(1);
}
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _BENETEL_4G_SHARED_BUFFERS_H_
#define _BENETEL_4G_SHARED_BUFFERS_H_
#include <pthread.h>
#include <stdint.h>
typedef struct {
/* [2] is for two antennas */
unsigned char dl[2][10][14*1200*4];
unsigned char ul[2][10][14*1200*4];
uint16_t dl_busy[2][10];
uint16_t ul_busy[2][10];
pthread_mutex_t m_ul[10];
pthread_cond_t c_ul[10];
pthread_mutex_t m_dl[10];
pthread_cond_t c_dl[10];
unsigned char prach[10][849*4];
unsigned char prach_busy[10];
/* statistics/error counting */
int ul_overflow;
int dl_underflow;
} shared_buffers;
void init_buffers(shared_buffers *s);
void lock_dl_buffer(shared_buffers *s, int subframe);
void unlock_dl_buffer(shared_buffers *s, int subframe);
void wait_dl_buffer(shared_buffers *s, int subframe);
void signal_dl_buffer(shared_buffers *s, int subframe);
void lock_ul_buffer(shared_buffers *s, int subframe);
void unlock_ul_buffer(shared_buffers *s, int subframe);
void wait_ul_buffer(shared_buffers *s, int subframe);
void signal_ul_buffer(shared_buffers *s, int subframe);
#endif /* _BENETEL_4G_SHARED_BUFFERS_H_ */
pkg_check_modules(libdpdk REQUIRED libdpdk=20.05.0)
add_library(benetel_5g MODULE
benetel.c
shared_buffers.c
low.c
low_dpdk.c
dpdk_driver.c
)
SET(DPDK_LIBS "-Wl,-rpath,$ENV{RTE_SDK}/$ENV{RTE_TARGET}/lib -Wl,--whole-archive -L$ENV{RTE_SDK}/$ENV{RTE_TARGET}/lib -ldpdk -Wl,--no-whole-archive")
target_include_directories(benetel_5g PRIVATE ${libdpdk_INCLUDE_DIRS})
target_link_libraries(benetel_5g PRIVATE ${libdpdk_LIBRARIES})
target_link_libraries(benetel_5g PRIVATE pthread dl rt m numa)
set_target_properties(benetel_5g PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -I$ENV{RTE_SDK}/$ENV{RTE_TARGET}/include")
set_target_properties(benetel_5g PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
add_custom_command(TARGET benetel_5g POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink libbenetel_5g.so liboai_transpro.so
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
This diff is collapsed.
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "low.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void store_ul(benetel_t *bs, ul_packet_t *ul)
{
#if 0
struct timespec t;
static struct timespec old;
clock_gettime(CLOCK_REALTIME, &t);
printf("store_ul %d.%ld (%ld)\n", (int)(t.tv_sec % 60), t.tv_nsec, t.tv_nsec - old.tv_nsec);
old = t;
#endif
int a = ul->antenna;
if (ul->slot != bs->next_slot[a] ||
ul->symbol != bs->next_symbol[a]) {
printf("%s: error, antenna %d expected frame.sl.symbol %d.%d.%d, got %d.%d.%d\n",
__FUNCTION__,
a, bs->expected_benetel_frame[a], bs->next_slot[a], bs->next_symbol[a],
ul->frame, ul->slot, ul->symbol);
}
/* fill missing data with 0s */
while (ul->slot != bs->next_slot[a] ||
ul->symbol != bs->next_symbol[a]) {
lock_ul_buffer(bs->buffers, bs->next_slot[a]);
if (bs->buffers->ul_busy[a][bs->next_slot[a]] & (1 << bs->next_symbol[a])) {
printf("%s: warning, antenna %d UL overflow (sl.symbol %d.%d)\n", __FUNCTION__,
a, bs->next_slot[a], bs->next_symbol[a]);
}
memset(bs->buffers->ul[a][bs->next_slot[a]] + bs->next_symbol[a] * 1272*4,
0, 1272*4);
bs->buffers->ul_busy[a][bs->next_slot[a]] |= (1 << bs->next_symbol[a]);
signal_ul_buffer(bs->buffers, bs->next_slot[a]);
unlock_ul_buffer(bs->buffers, bs->next_slot[a]);
bs->next_symbol[a]++;
if (bs->next_symbol[a] == 14) {
bs->next_symbol[a] = 0;
bs->next_slot[a] = (bs->next_slot[a] + 1) % 20;
if (bs->next_slot[a] == 0) {
bs->expected_benetel_frame[a]++;
bs->expected_benetel_frame[a] &= 255;
}
}
}
lock_ul_buffer(bs->buffers, bs->next_slot[a]);
if (bs->buffers->ul_busy[a][bs->next_slot[a]] & (1 << bs->next_symbol[a])) {
printf("%s: warning, antenna %d UL overflow (sl.symbol %d.%d)\n", __FUNCTION__,
a, bs->next_slot[a], bs->next_symbol[a]);
}
memcpy(bs->buffers->ul[a][bs->next_slot[a]] + bs->next_symbol[a] * 1272*4,
ul->iq, 1272*4);
bs->buffers->ul_busy[a][bs->next_slot[a]] |= (1 << bs->next_symbol[a]);
signal_ul_buffer(bs->buffers, bs->next_slot[a]);
unlock_ul_buffer(bs->buffers, bs->next_slot[a]);
bs->next_symbol[a]++;
if (bs->next_symbol[a] == 14) {
bs->next_symbol[a] = 0;
bs->next_slot[a] = (bs->next_slot[a] + 1) % 20;
if (bs->next_slot[a] == 0) {
bs->expected_benetel_frame[a]++;
bs->expected_benetel_frame[a] &= 255;
}
}
}
void store_prach(benetel_t *bs, int frame, int slot, void *data)
{
static int last_frame = -1;
static int last_slot = -1;
/* hack: antenna number is always 0, discard second packet with same f/sf */
//if (frame == last_frame && slot == last_slot) return;
if (frame == last_frame && slot == last_slot) { printf("got f.sl %d.%d twice\n", frame, slot); return; }
last_frame = frame;
last_slot = slot;
lock_ul_buffer(bs->buffers, slot);
if (bs->buffers->prach_busy[slot]) {
printf("store_prach: fatal: previous prach buffer not processed\n");
unlock_ul_buffer(bs->buffers, slot);
return;
}
bs->buffers->prach_busy[slot] = 1;
memcpy(bs->buffers->prach[slot], data, 839*4);
signal_ul_buffer(bs->buffers, slot);
unlock_ul_buffer(bs->buffers, slot);
}
void *benetel_start_dpdk(char *ifname, shared_buffers *buffers, char *dpdk_main_command_line);
void *benetel_start(char *ifname, shared_buffers *buffers, char *dpdk_main_command_line)
{
if (!strcmp(ifname, "dpdk"))
return benetel_start_dpdk(ifname, buffers, dpdk_main_command_line);
printf("benetel: fatal: interface %s not supported, only dpdpk is supported\n", ifname);
exit(1);
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _BENETEL_5G_LOW_H_
#define _BENETEL_5G_LOW_H_
#include "shared_buffers.h"
typedef struct {
shared_buffers *buffers;
/* [2] is for two antennas */
int next_slot[2];
int next_symbol[2];
int expected_benetel_frame[2];
char *dpdk_main_command_line;
} benetel_t;
typedef struct {
int frame;
int slot;
int symbol;
int antenna;
unsigned char iq[5088];
} ul_packet_t;
void *benetel_start(char *ifname, shared_buffers *buffers, char *dpdk_main_command_line);
void store_ul(benetel_t *bs, ul_packet_t *ul);
void store_prach(benetel_t *bs, int frame, int slot, void *data);
#endif /* _BENETEL_5G_LOW_H_ */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/* those 2 lines for CPU_SET */
#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "low.h"
int dpdk_main(int argc, char **argv, benetel_t *);
void *dpdk_thread(void *_bs)
{
benetel_t *bs = _bs;
int n = 0;
char **v = NULL; // = { "softmodem", "-n", "2", "--file-prefix", "pg2", "-l", "6", "--", "-p", "0x1" };
char *s = bs->dpdk_main_command_line;
char *tok;
while ((tok = strtok(s, " ")) != NULL) {
n++;
v = realloc(v, n * sizeof(char *));
if (v == NULL) {
printf("%s: out of memory\n", __FUNCTION__);
exit(1);
}
v[n-1] = tok;
s = NULL;
}
dpdk_main(n, v, bs);
exit(1);
return 0;
}
void *benetel_start_dpdk(char *ifname, shared_buffers *buffers, char *dpdk_main_command_line)
{
benetel_t *bs;
bs = calloc(1, sizeof(benetel_t));
if (bs == NULL) {
printf("%s: out of memory\n", __FUNCTION__);
exit(1);
}
bs->buffers = buffers;
bs->expected_benetel_frame[0] = 255;
bs->expected_benetel_frame[1] = 255;
bs->dpdk_main_command_line = dpdk_main_command_line;
pthread_attr_t attr;
if (pthread_attr_init(&attr) != 0) {
printf("pthread_attr_init failed\n");
exit(1);
}
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(10,&cpuset);
if (pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset) != 0) {
printf("pthread_attr_setaffinity_np failed\n");
exit(1);
}
if (pthread_attr_setschedpolicy(&attr, SCHED_FIFO) != 0) {
printf("pthread_attr_setschedpolicy failed\n");
exit(1);
}
struct sched_param params;
params.sched_priority = sched_get_priority_max(SCHED_FIFO);
if (sched_get_priority_max(SCHED_FIFO) == -1) {
printf("sched_get_priority_max failed\n");
exit(1);
}
if (pthread_attr_setschedparam(&attr, &params) != 0) {
printf("pthread_setschedparam failed\n");
exit(1);
}
pthread_t t;
if (pthread_create(&t, &attr, dpdk_thread, bs) != 0) {
printf("%s: thread creation failed\n", __FUNCTION__);
exit(1);
}
if (pthread_attr_destroy(&attr) != 0) {
printf("pthread_attr_init failed\n");
exit(1);
}
return bs;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "shared_buffers.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void init_buffers(shared_buffers *s)
{
int slot;
memset(s, 0, sizeof(*s));
for (slot = 0; slot < 20; slot++) {
if (pthread_mutex_init(&s->m_dl[slot], NULL) != 0 ||
pthread_cond_init(&s->c_dl[slot], NULL) != 0 ||
pthread_mutex_init(&s->m_ul[slot], NULL) != 0 ||
pthread_cond_init(&s->c_ul[slot], NULL) != 0) {
printf("%s: error initializing mutex/cond\n", __FUNCTION__);
exit(1);
}
}
/* the gNB's first transmitted DL slot is 6 but the device
* needs to have slots 1, 2 and 3, 4 and 5 ready. Let's pretend
* they are ready.
*/
s->dl_busy[0][1] = 0x3fff;
s->dl_busy[0][2] = 0x3fff;
s->dl_busy[0][3] = 0x3fff;
s->dl_busy[0][4] = 0x3fff;
s->dl_busy[0][5] = 0x3fff;
s->dl_busy[1][1] = 0x3fff;
s->dl_busy[1][2] = 0x3fff;
s->dl_busy[1][3] = 0x3fff;
s->dl_busy[1][4] = 0x3fff;
s->dl_busy[1][5] = 0x3fff;
}
void lock_dl_buffer(shared_buffers *s, int slot)
{
if (pthread_mutex_lock(&s->m_dl[slot]) != 0) {
printf("%s: fatal: lock fails\n", __FUNCTION__);
exit(1);
}
}
void unlock_dl_buffer(shared_buffers *s, int slot)
{
if (pthread_mutex_unlock(&s->m_dl[slot]) != 0) {
printf("%s: fatal: unlock fails\n", __FUNCTION__);
exit(1);
}
}
void wait_dl_buffer(shared_buffers *s, int slot)
{
if (pthread_cond_wait(&s->c_dl[slot], &s->m_dl[slot]) != 0) {
printf("%s: fatal: cond_wait fails\n", __FUNCTION__);
exit(1);
}
}
void signal_dl_buffer(shared_buffers *s, int slot)
{
if (pthread_cond_broadcast(&s->c_dl[slot]) != 0) {
printf("%s: fatal: cond_broadcast fails\n", __FUNCTION__);
exit(1);
}
}
void lock_ul_buffer(shared_buffers *s, int slot)
{
if (pthread_mutex_lock(&s->m_ul[slot]) != 0) {
printf("%s: fatal: lock fails\n", __FUNCTION__);
printf("%s: fatal: lock fails slot %d\n", __FUNCTION__, slot);
exit(1);
}
}
void unlock_ul_buffer(shared_buffers *s, int slot)
{
if (pthread_mutex_unlock(&s->m_ul[slot]) != 0) {
printf("%s: fatal: unlock fails\n", __FUNCTION__);
exit(1);
}
}
void wait_ul_buffer(shared_buffers *s, int slot)
{
if (pthread_cond_wait(&s->c_ul[slot], &s->m_ul[slot]) != 0) {
printf("%s: fatal: cond_wait fails\n", __FUNCTION__);
exit(1);
}
}
void signal_ul_buffer(shared_buffers *s, int slot)
{
if (pthread_cond_broadcast(&s->c_ul[slot]) != 0) {
printf("%s: fatal: cond_broadcast fails\n", __FUNCTION__);
exit(1);
}
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _BENETEL_5G_SHARED_BUFFERS_H_
#define _BENETEL_5G_SHARED_BUFFERS_H_
#include <pthread.h>
#include <stdint.h>
typedef struct {
/* [2] is for two antennas */
unsigned char dl[2][20][14*1272*4];
unsigned char ul[2][20][14*1272*4];
uint16_t dl_busy[2][20];
uint16_t ul_busy[2][20];
pthread_mutex_t m_ul[20];
pthread_cond_t c_ul[20];
pthread_mutex_t m_dl[20];
pthread_cond_t c_dl[20];
unsigned char prach[20][849*4];
unsigned char prach_busy[20];
/* statistics/error counting */
int ul_overflow;
int dl_underflow;
} shared_buffers;
void init_buffers(shared_buffers *s);
void lock_dl_buffer(shared_buffers *s, int slot);
void unlock_dl_buffer(shared_buffers *s, int slot);
void wait_dl_buffer(shared_buffers *s, int slot);
void signal_dl_buffer(shared_buffers *s, int slot);
void lock_ul_buffer(shared_buffers *s, int slot);
void unlock_ul_buffer(shared_buffers *s, int slot);
void wait_ul_buffer(shared_buffers *s, int slot);
void signal_ul_buffer(shared_buffers *s, int slot);
#endif /* _BENETEL_5G_SHARED_BUFFERS_H_ */
add_boolean_option(OAI_BENETEL4G OFF "Activate OAI's Benetel 4G radio driver" OFF)
if(OAI_BENETEL4G)
add_subdirectory(4g)
endif()
add_boolean_option(OAI_BENETEL5G OFF "Activate OAI's Benetel 5G radio driver" OFF)
if(OAI_BENETEL5G)
add_subdirectory(5g)
endif()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment