Cleanup common_lib.h
This change reduces the number of dependecies of common_lib.h and simplifies the task of implementing an external OAI radio library.
This commit is contained in:
@@ -365,7 +365,8 @@ void *trx_eth_write_udp_cmd(udpTXelem_t *udpTXelem)
|
||||
int trx_eth_write_udp(openair0_device_t *device, openair0_timestamp_t timestamp, void **buff, int fd_ind, int nsamps, int flags, int nant)
|
||||
{
|
||||
union udpTXReqUnion id = {.s={(uint64_t)timestamp,nsamps,0}};
|
||||
notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(udpTXelem_t), id.p, device->utx[fd_ind]->resp,NULL);
|
||||
eth_state_t *eth = (eth_state_t*)device->priv;
|
||||
notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(udpTXelem_t), id.p, eth->utx[fd_ind]->resp,NULL);
|
||||
udpTXelem_t * udptxelem=(udpTXelem_t *) NotifiedFifoData(req);
|
||||
udptxelem->device = device;
|
||||
udptxelem->timestamp = timestamp;
|
||||
@@ -375,7 +376,7 @@ int trx_eth_write_udp(openair0_device_t *device, openair0_timestamp_t timestamp,
|
||||
udptxelem->nsamps = nsamps;
|
||||
udptxelem->flags = flags;
|
||||
udptxelem->nant = nant;
|
||||
pushNotifiedFIFO(device->utx[fd_ind]->resp, req);
|
||||
pushNotifiedFIFO(eth->utx[fd_ind]->resp, req);
|
||||
LOG_D(PHY,"Pushed to TX FH FIFO, TS %llu, nsamps %d, nant %d buffs[0] %p buffs[1] %p\n",
|
||||
(unsigned long long)timestamp,nsamps,nant,udptxelem->buff[0],udptxelem->buff[1]);
|
||||
return(0);
|
||||
@@ -386,14 +387,11 @@ void *udp_write_thread(void *arg) {
|
||||
utx->resp = malloc(sizeof(*utx->resp));
|
||||
initNotifiedFIFO(utx->resp);
|
||||
LOG_D(PHY,"UDP write thread started on core %d\n",sched_getcpu());
|
||||
reset_meas(&utx->device->tx_fhaul);
|
||||
while (oai_exit == 0) {
|
||||
notifiedFIFO_elt_t *res = pullNotifiedFIFO(utx->resp);
|
||||
udpTXelem_t *udptxelem = (udpTXelem_t *)NotifiedFifoData(res);
|
||||
LOG_D(PHY,"Pulled from TX FH FIFO, TS %llu, nsamps %d, nant %d\n",(unsigned long long)udptxelem->timestamp,udptxelem->nsamps,udptxelem->nant);
|
||||
start_meas(&utx->device->tx_fhaul);
|
||||
trx_eth_write_udp_cmd(udptxelem);
|
||||
stop_meas(&utx->device->tx_fhaul);
|
||||
// send data to RU
|
||||
delNotifiedFIFO_elt(res);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* \brief API to stream I/Q samples over standard ethernet
|
||||
*/
|
||||
|
||||
#include "utils.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <linux/if_packet.h>
|
||||
#include <stdio.h>
|
||||
@@ -37,20 +38,30 @@ int trx_eth_start(openair0_device_t *device)
|
||||
AssertFatal(device->thirdparty_init != NULL, "device->thirdparty_init is null\n");
|
||||
AssertFatal(device->thirdparty_init(device) == 0, "third-party init failed\n");
|
||||
device->openair0_cfg->samples_per_packet = 256;
|
||||
eth->num_fd = 1; //max(device->openair0_cfg->rx_num_channels,device->openair0_cfg->tx_num_channels);
|
||||
udp_ctx_t *u[1+eth->num_fd];
|
||||
device->utx = (udp_ctx_t**)malloc(sizeof(device->utx));
|
||||
for (int i=0;i<eth->num_fd;i++) {
|
||||
u[i] = malloc(sizeof(udp_ctx_t));
|
||||
u[i]->thread_id=i;
|
||||
u[i]->device = device;
|
||||
printf("UDP Read Thread %d on core %d\n",i,device->openair0_cfg->rxfh_cores[i]);
|
||||
threadCreate(&u[i]->pthread,udp_read_thread,u[i],"udp read thread",device->openair0_cfg->rxfh_cores[i],OAI_PRIORITY_RT_MAX);
|
||||
device->utx[i] = malloc(sizeof(udp_ctx_t));
|
||||
device->utx[i]->thread_id=i;
|
||||
device->utx[i]->device = device;
|
||||
printf("UDP Write Thread %d on core %d\n",i,device->openair0_cfg->txfh_cores[i]);
|
||||
threadCreate(&device->utx[i]->pthread,udp_write_thread,device->utx[i],"udp write thread",device->openair0_cfg->txfh_cores[i],OAI_PRIORITY_RT_MAX);
|
||||
eth->num_fd = 1; //max(device->openair0_cfg->rx_num_channels,device->openair0_cfg->tx_num_channels);
|
||||
udp_ctx_t *u[1 + eth->num_fd];
|
||||
eth->utx = malloc_or_fail(sizeof(eth->utx));
|
||||
for (int i = 0; i < eth->num_fd; i++) {
|
||||
u[i] = malloc_or_fail(sizeof(udp_ctx_t));
|
||||
u[i]->thread_id = i;
|
||||
u[i]->device = device;
|
||||
printf("UDP Read Thread %d on core %d\n", i, device->openair0_cfg->rxfh_cores[i]);
|
||||
threadCreate(&u[i]->pthread,
|
||||
udp_read_thread,
|
||||
u[i],
|
||||
"udp read thread",
|
||||
device->openair0_cfg->rxfh_cores[i],
|
||||
OAI_PRIORITY_RT_MAX);
|
||||
eth->utx[i] = malloc_or_fail(sizeof(udp_ctx_t));
|
||||
eth->utx[i]->thread_id = i;
|
||||
eth->utx[i]->device = device;
|
||||
printf("UDP Write Thread %d on core %d\n", i, device->openair0_cfg->txfh_cores[i]);
|
||||
threadCreate(ð->utx[i]->pthread,
|
||||
udp_write_thread,
|
||||
eth->utx[i],
|
||||
"udp write thread",
|
||||
device->openair0_cfg->txfh_cores[i],
|
||||
OAI_PRIORITY_RT_MAX);
|
||||
}
|
||||
device->sampling_rate_ratio_n=1;
|
||||
device->sampling_rate_ratio_d=1;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/ether.h>
|
||||
#include "common/utils/threadPool/notified_fifo.h"
|
||||
|
||||
#define MAX_INST 4
|
||||
|
||||
@@ -29,6 +30,14 @@
|
||||
#define APP_HEADER_SIZE_BYTES (ECPRICOMMON_BYTES + ECPRIPCID_BYTES + sizeof(openair0_timestamp_t))
|
||||
#define ECPRIREV 1 // ECPRI Version 1, C=0 - single ECPRI message per OAI TX packet
|
||||
|
||||
/*! \brief Structure used for initializing UDP read threads */
|
||||
typedef struct {
|
||||
openair0_device_t *device;
|
||||
int thread_id;
|
||||
pthread_t pthread;
|
||||
notifiedFIFO_t *resp;
|
||||
} udp_ctx_t;
|
||||
|
||||
/*!\brief opaque ethernet data structure */
|
||||
typedef struct {
|
||||
|
||||
@@ -115,6 +124,8 @@ typedef struct {
|
||||
struct ether_header ehd;
|
||||
/*!\brief local address (user) for RAW socket*/
|
||||
struct sockaddr_ll local_addrd_ll;
|
||||
/*!brief UDP TX thread context*/
|
||||
udp_ctx_t **utx;
|
||||
} eth_state_t;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user