Commit 7b4b19a8 authored by Joanne Hugé's avatar Joanne Hugé

Clean up

parent ada02d83
ecpri-tests/client
ecpri-tests/server
test-eNB/client
test-eNB/server
*.swp
*.swo
af-xdp-test/af_xdp
af-xdp-test/af_xdp.d
af-xdp-test/af_xdp.o
raw-socket-test/raw_socket
raw-socket-test/raw_socket.d
raw-socket-test/raw_socket.o
dpdk-test/build
*.so
*.o
*.d
int start_udp(TRXEcpriState * s) {
struct addrinfo server_hints, client_hints, *server_info, *client_info, *p;
int rv;
char ip_string[INET6_ADDRSTRLEN];
if(init_buffers()) {
fprintf(stderr, "Init buffer failed\n");
exit(EXIT_FAILURE);
}
memset((uint8_t *) ecpri_packet, 0, MAX_PACKET_SIZE);
memset((uint8_t *) empty_ecpri_packet, 0, MAX_PACKET_SIZE);
memset(&server_hints, 0, sizeof server_hints);
memset(&client_hints, 0, sizeof client_hints);
server_hints.ai_family = AF_UNSPEC;
server_hints.ai_socktype = SOCK_DGRAM;
client_hints.ai_family = AF_INET;
client_hints.ai_socktype = SOCK_DGRAM;
client_hints.ai_flags = AI_PASSIVE;
if ((rv = getaddrinfo(NULL, s->rec_port, &client_hints, &client_info)) != 0) {
fprintf(stderr, "client getaddrinfo: %s\n", gai_strerror(rv));
return 1;
}
if ((recv_sockfd = socket(client_info->ai_family, client_info->ai_socktype,
client_info->ai_protocol)) == -1) {
perror("client: socket");
return 1;
}
if ((send_sockfd = socket(client_info->ai_family, client_info->ai_socktype,
client_info->ai_protocol)) == -1) {
perror("client: socket");
return 1;
}
if (bind(recv_sockfd, client_info->ai_addr, client_info->ai_addrlen) == -1) {
close(recv_sockfd);
perror("client: connect");
return 1;
}
freeaddrinfo(client_info);
if ((rv = getaddrinfo(s->re_ip, s->re_port, &server_hints, &server_info)) != 0) {
fprintf(stderr, "server getaddrinfo: %s\n", gai_strerror(rv));
return 1;
}
for(p = server_info; p != NULL; p = p->ai_next) {
if (connect(send_sockfd, p->ai_addr, p->ai_addrlen) == -1) {
perror("client: connect");
continue;
}
break;
}
if (p == NULL) {
fprintf(stderr, "client: failed to connect\n");
return 1;
}
inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr), ip_string, sizeof ip_string);
log_info("TRX_ECPRI", "Connected to %s\n", ip_string);
freeaddrinfo(server_info);
_start();
return 0;
}
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
#include <error.h>
#include <fcntl.h>
#include <getopt.h>
#include <immintrin.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <netdb.h>
#include <netinet/in.h>
#include <pthread.h>
#include <sched.h>
#include <semaphore.h>
#include <signal.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include "trx_ecpri.h"
#define DEBUG
int main(int argc, char ** argv) {
TRXEcpriState *s;
s = malloc(sizeof(TRXEcpriState));
memset(s, 0, sizeof(*s));
#if 0
s->rec_mac = "80:fa:5b:92:39:c3";
s->re_mac = "00:e0:4c:90:20:d3";
s->rec_if = "enp53s0";
#else
s->rec_mac = "b8:59:9f:07:7d:db";
s->re_mac = "04:09:a5:0f:9f:4c";
s->rec_if = "ens9f1";
#endif
s->recv_affinity = 39;
s->send_affinity = 39;
s->prepare_affinity = 38;
s->decompress_affinity = 37;
s->ecpri_period = 800;
s->flow_id = 0;
s->sample_rate = 122880000;
log_info("CLIENT", "Starting client...\n");
log_info("CLIENT", "rec-mac: %s, re-mac: %s, rec-if: %s", s->rec_mac, s->re_mac, s->rec_if);
start(s);
for(int i = 0; i < 1000; i++) {
sleep(1);
}
}
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
#include <error.h>
#include <fcntl.h>
#include <getopt.h>
#include <immintrin.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <netdb.h>
#include <netinet/in.h>
#include <pthread.h>
#include <sched.h>
#include <semaphore.h>
#include <signal.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include "trx_ecpri.h"
int main(int argc, char ** argv) {
return 0;
}
#!/bin/bash
cd ..;
make;
cd ecpri-tests;
make all;
export LD_LIBRARY_PATH="/root/enb"
~/enb/lteenb ~/enb/config/enb.cfg
../trx_ecpri.c
\ No newline at end of file
......@@ -34,7 +34,7 @@ rf_driver: {
//rec_if: "ens9f1",
//dpdk_options: "-l 10,20 -b 0000:04:00.0 -b 0000:3b:00.0 -b 0000:3b:00.1 -b 0000:5e:00.1 ",
rec_mac: "b8:59:9f:07:86:43",
re_mac: "b8:59:9f:07:7e:2b", /* HFR Switch */
re_mac: "b8:59:9f:07:7e:2b", /* Tiogapass003 */
rec_if: "ens9f1",
dpdk_options: "-l 10,20 -b 0000:04:00.0 -b 0000:3b:00.0 -b 0000:3b:00.1 -b 0000:5e:00.0 ",
recv_affinity: 39,
......
/*
* Dummy transceiver driver (receives zeros and sync to real time)
*
* Copyright (C) 2012-2021 Amarisoft
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <inttypes.h>
#include <string.h>
#include <getopt.h>
#include <math.h>
#include <assert.h>
#include <unistd.h>
#include <sys/time.h>
#include "trx_driver.h"
typedef int BOOL;
typedef struct {
int sample_rate;
int tx_channel_count;
int rx_channel_count;
int64_t rx_timestamp;
int64_t rx_count;
int64_t tx_count;
BOOL dump_max;
float max_sample;
int sat_count;
int64_t last_disp_time;
} TRXDummyState;
static int64_t get_time_us(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
}
static void trx_dummy_end(TRXState *s1)
{
TRXDummyState *s = s1->opaque;
printf("rx_count: %" PRId64 "\n", s->rx_count);
printf("tx_count: %" PRId64 "\n", s->tx_count);
free(s);
}
static inline int64_t ts_to_time(TRXDummyState *s, int64_t ts)
{
int n, r;
n = (ts / s->sample_rate);
r = (ts % s->sample_rate);
return (int64_t)n * 1000000 + (((int64_t)r * 1000000) / s->sample_rate);
}
static void trx_dummy_write(TRXState *s1, trx_timestamp_t timestamp, const void **samples, int count, int flags, int rf_port_index)
{
TRXDummyState *s = s1->opaque;
if (!(flags & TRX_WRITE_FLAG_PADDING) && s->dump_max) {
const float *tab;
int i, j;
float v_max, v;
v_max = s->max_sample;
for(j = 0; j < s->tx_channel_count; j++) {
tab = (const float *)samples[j];
for(i = 0; i < count * 2; i++) {
v = fabsf(tab[i]);
/* Note: 1.0 corresponds to the maximum value */
if (v >= 1.0)
s->sat_count++;
if (v > v_max) {
v_max = v;
}
}
}
s->max_sample = v_max;
if ((get_time_us() - s->last_disp_time) >= 2000000) {
printf("max_sample=%0.3f sat=%d\n", s->max_sample, s->sat_count);
s->max_sample = 0;
s->sat_count = 0;
s->last_disp_time = get_time_us();
}
}
s->tx_count += count;
}
static int trx_dummy_read(TRXState *s1, trx_timestamp_t *ptimestamp, void **psamples, int count, int rf_port)
{
TRXDummyState *s = s1->opaque;
int64_t end_time, d;
TRXComplex *samples;
int j;
*ptimestamp = s->rx_timestamp;
s->rx_timestamp += count;
s->rx_count += count;
end_time = ts_to_time(s, s->rx_timestamp);
/* Since we don't have a real sample source, we just return zero
samples and use the PC real time clock as time source */
for(;;) {
d = end_time - get_time_us();
if (d <= 0)
break;
if (d > 10000)
d = 10000;
usleep(d);
}
for(j = 0; j < s->rx_channel_count; j++) {
samples = psamples[j];
memset(samples, 0, count * sizeof(TRXComplex));
}
return count;
}
/* This function can be used to automatically set the sample
rate. Here we don't implement it, so the user has to force a given
sample rate with the "sample_rate" configuration option */
static int trx_dummy_get_sample_rate(TRXState *s, TRXFraction *psample_rate,
int *psample_rate_num, int sample_rate_min)
{
return -1;
}
static int trx_dummy_start(TRXState *s1, const TRXDriverParams *p)
{
TRXDummyState *s = s1->opaque;
struct timeval tv;
if (p->rf_port_count != 1)
return -1; /* only one TX port is supported */
s->sample_rate = p->sample_rate[0].num / p->sample_rate[0].den;
s->tx_channel_count = p->tx_channel_count;
s->rx_channel_count = p->rx_channel_count;
gettimeofday(&tv, NULL);
/* compute first RX timetamp in sample rate units */
s->rx_timestamp = (int64_t)tv.tv_sec * s->sample_rate +
((int64_t)tv.tv_usec * s->sample_rate / 1000000);
s->last_disp_time = get_time_us();
return 0;
}
int trx_driver_init(TRXState *s1)
{
TRXDummyState *s;
double val;
if (s1->trx_api_version != TRX_API_VERSION) {
fprintf(stderr, "ABI compatibility mismatch between LTEENB and TRX driver (LTEENB ABI version=%d, TRX driver ABI version=%d)\n",
s1->trx_api_version, TRX_API_VERSION);
return -1;
}
s = malloc(sizeof(TRXDummyState));
memset(s, 0, sizeof(*s));
s->dump_max = 0;
/* option to dump the maximum sample value */
if (trx_get_param_double(s1, &val, "dump_max") >= 0)
s->dump_max = (val != 0);
s1->opaque = s;
s1->trx_end_func = trx_dummy_end;
s1->trx_write_func = trx_dummy_write;
s1->trx_read_func = trx_dummy_read;
s1->trx_start_func = trx_dummy_start;
s1->trx_get_sample_rate_func = trx_dummy_get_sample_rate;
return 0;
}
#!/bin/bash
DIR=$(dirname $(realpath $0))
#HFR
#DPDK_INSTALL=/root/dpdk-stable-20.11.3
#Tiogapass004
DPDK_INSTALL=/root/dpdk-21.11
cd $DPDK_INSTALL/usertools;
python3 dpdk-hugepages.py --setup 2G;
cd $DIR/..;
make;
cd test-eNB;
make all;
ln -sf /root/ecpri-priv/libtrx_ecpri_dpdk.so /root/enb/trx_ecpri.so
ln -sf /root/ecpri-priv/enb.cfg /root/enb/config/enb.cfg
#!/bin/bash
PRIV="/root/ecpri-priv"
PUBL="/root/trx-ecpri"
rsync -ah --delete --exclude .git $PRIV/ $PUBL/;
rm -rf \
$PUBL/private.c\
$PUBL/trx_driver.h\
$PUBL/push-public.sh\
$PUBL/test-eNB/private.c\
$PUBL/test-eNB/trx_driver.h\
;
#!/bin/bash
/root/stop-cpri.sh
systemctl start lte
#!/bin/bash
DIR=$(dirname $(realpath $0))
#HFR
#LOGD=/home/hfr
#Tiogapass004
LOGD=/root/ecpri-logs
systemctl stop lte;
$DIR/stop-ecpri.sh;
cd $DIR/..;
make;
cd test-eNB;
make all;
export LD_LIBRARY_PATH="/root/ecpri-priv:/root/enb:$LD_LIBRARY_PATH"
export AMARISOFT_PATH="/root/.amarisoft"
cd $DIR/../test-eNB;
$DIR/../launch-ptp > $LOGD/ptp.log 2> $LOGD/ptp.error &
$DIR/../launch-phc2sys > $LOGD/phc2sys.log 2> $LOGD/phc2sys.error &
#./test-dpdk-ecpri > $LOGD/ecpri.log 2> $LOGD/ecpri.error &
~/enb/lteenb ~/enb/config/enb.cfg
#!/bin/bash
systemctl stop lte
#!/bin/bash
ECPRI_PID=$(ps aux | grep test-dpdk-ecpri | grep -v grep | awk '{print $2;}')
if [ -n "$ECPRI_PID" ]; then
kill $ECPRI_PID;
fi
LTE_PID=$(ps -ec -o pid,cmd | grep lteenb | grep -v grep | awk '{print $1;}')
if [ -n "$LTE_PID" ]; then
kill -9 $LTE_PID;
fi
killall ptp4l 2> /dev/null;
killall phc2sys 2> /dev/null;
......@@ -129,11 +129,68 @@ int main(int argc, char * argv[]) {
s = malloc(sizeof(TRXEcpriState));
memset(s, 0, sizeof(*s));
#if 0
// tiogapass-003 MT27710
s->rec_mac = "b8:59:9f:07:7e:2a";
//s->re_mac = "04:09:a5:0f:9f:4c"; // Lille M6424 Switch
s->re_mac = "b8:59:9f:07:86:42"; // tiogapass-004 MT27710
//s->re_mac = "b4:96:91:a7:1c:f4"; // tiogapass-004 XXV710DA2T port0
s->rec_if = "ens9f0";
s->dpdk_options = "-l 10,20 -b 0000:04:00.0 -b 0000:5e:00.1 ";
#endif
#if 0
// tiogapass-003 MT27710 port1
s->rec_mac = "b8:59:9f:07:7e:2b";
s->re_mac = "04:09:a5:0f:9f:4c"; // Lille M6424 Switch
//s->re_mac = "b8:59:9f:07:86:42"; // tiogapass-004 MT27710
//s->re_mac = "b4:96:91:a7:1c:f5"; // tiogapass-004 XXV710DA2T port1
s->rec_if = "ens9f1";
s->dpdk_options = "-l 10,20 -b 0000:04:00.0 -b 0000:5e:00.0 ";
#endif
#if 0
// hfr-tiogapass-001 MT27710
s->rec_mac = "b8:59:9f:07:82:ca";
s->re_mac = "04:09:a5:0f:76:1c"; // HFR M6424 switch
s->rec_if = "ens9f0";
s->dpdk_options = "-l 10,20 -b 0000:04:00.0 -b 0000:18:00.0 -b 0000:18:00.1 -b 0000:5e:00.1 ";
#endif
#if 0
// hfr-tiogapass-001 XXV710DA2T
s->rec_mac = "b4:96:91:a7:1b:28";
s->re_mac = "04:09:a5:0f:76:1c"; // HFR M6424 switch
s->rec_if = "ens1f0";
s->dpdk_options = "-l 10,20 -b 0000:04:00.0 -b 0000:18:00.1 -b 0000:5e:00.0 -b 0000:5e:00.1 ";
#endif
#if 0
// tiogapass-004 MT27710
s->rec_mac = "b8:59:9f:07:86:42";
s->re_mac = "04:09:a5:0f:9f:4a"; // Lille M6424 Switch
//s->re_mac = "b8:59:9f:07:7e:2a"; // tiogapass-003 MT27710
s->rec_if = "ens9f0";
s->dpdk_options = "-l 10,20 -b 0000:04:00.0 -b 0000:3b:00.0 -b 0000:3b:00.1 -b 0000:5e:00.1 ";
#endif
#if 1
// tiogapass-004 MT27710 port1
s->rec_mac = "b8:59:9f:07:86:43";
//s->re_mac = "04:09:a5:0f:9f:4c"; // Lille M6424 Switch
s->re_mac = "b8:59:9f:07:0e:2b"; // tiogapass-003 MT27710 port 1
s->rec_if = "ens9f1";
s->dpdk_options = "-l 10,20 -b 0000:04:00.0 -b 0000:3b:00.0 -b 0000:3b:00.1 -b 0000:5e:00.0 ";
#endif
#if 0
// tiogapass-004 XXV710DA2T
s->rec_mac = "b4:96:91:a7:1c:f4";
s->re_mac = "04:09:a5:0f:9f:4c";
s->re_mac = "b8:59:9f:07:7e:2a";
s->re_mac = "04:09:a5:0f:9f:4c"; // Lille M6424 Switch
s->re_mac = "b8:59:9f:07:7e:2a"; // tiogapass-003 MT27710
s->rec_if = "ens5f0";
s->dpdk_options = "-l 10,20 -b 0000:04:00.0 -b 0000:3b:00.1 -b 0000:5e:00.0 -b 0000:5e:00.1 ";
#endif
s->recv_affinity = 39;
s->send_affinity = 38;
......@@ -178,7 +235,9 @@ static void enb(TRXState * s1, TRXEcpriState * s) {
int64_t tx_timestamp = 256 * (INT64_C(3840000) * ((int64_t) p * i + p)) / (INT64_C(1000000000));
add_ns(&next, p);
//log_info("TEST-DPDK-ECPRI", "Reading 256 samples");
s1->trx_read_func2(s1, &ptimestamp, rx_samples, 256 * m, 0, NULL);
//log_info("TEST-DPDK-ECPRI", "Writing 256 samples, %" PRIi64, tx_timestamp);
s1->trx_write_func2(s1, tx_timestamp, tx_samples, 256 * m, 0, NULL);
s1->trx_write_func2(s1, tx_timestamp + 256 * m + 100, tx_samples, 256 * m, 0, NULL);
s1->trx_write_func2(s1, tx_timestamp + 2 * 256 * m + 110, tx_samples, 256 * m, 0, NULL);
......
......@@ -4,6 +4,6 @@ export LD_LIBRARY_PATH="/root/ecpri-priv:$LD_LIBRARY_PATH"
cd .. &&
make &&
cd ecpri-tests &&
cd test-eNB &&
make all &&
./test-dpdk-ecpri
......@@ -43,18 +43,21 @@
#include "trx_driver.h"
#define DEBUG
#define SSE4 /* define if CPU supports SSE4.1 */
// Tiogapass004
#define DST_ADDR_SYNTAX
#define DEBUG // Enables / deactivates log_debug
#define SSE4 // define if CPU supports SSE4.1
#define DST_ADDR_SYNTAX // Depends on DPDK version
/* Proprietary code:
- compression / decompression of IQ samples
- fast conversion between int16_t and float
*/
#include "private.c"
/* eCPRI Send and Recv */
#define N_SAMPLES 256
#define PACKET_SIZE 262
#define DATA_SIZE 248
#define FRAME_FREQ INT64_C(3840000)
#define FRAME_FREQ INT64_C(3840000) // Basic frame frequency
//#define SEND_LIMIT (1250 * 10)
#define TRX_WB_MAX_PARTS 1000
#define TRX_BUF_MAX_SIZE 1000
......@@ -135,7 +138,6 @@ static void log_debug(const char * section, const char * msg, ...) {
#define log_debug(...)
#endif
static int latency_target_fd = -1;
static int32_t latency_target_value = 0;
......@@ -410,6 +412,7 @@ static void send_packets(int port) {
}
}
// TODO store received packets' data in buffer
static int recv_packets(int port) {
struct rte_mbuf * pkt[1024];
uint8_t * buf;
......@@ -689,9 +692,6 @@ static void *decompress_thread(void *p) {
ether_type,
ecpri_protocol_rev, ecpri_message_type, ecpri_payload_size,
pc_id, seq_id);
fprintf(trace_file_desc, "RAW PACKET: ");
for(int l = 0; l < 262; l++)
fprintf(trace_file_desc, "|%x", *(RBUF_READ(rx_rbuf, uint8_t) + l));
fprintf(trace_file_desc, "\n");
fflush(trace_file_desc);
}
......@@ -892,6 +892,7 @@ int startdpdk(TRXEcpriState * s) {
}
}
argv[0] = "";
init_dpdk(argc, argv);
log_info("TRX_ECPRI", "Start");
......@@ -970,6 +971,8 @@ static void trx_ecpri_write(TRXState *s1, trx_timestamp_t timestamp, const void
int write_count = count / 256;
int64_t ts = timestamp / 256;
log_limit("TRX_ECPRI_WRITE", "timestamp = %li, next = %li, write_count = %li, samples = %s", ts, ts + write_count, write_count, __samples ? "yes" : "no");
if(!__samples)
return;
......@@ -996,6 +999,8 @@ static int trx_ecpri_read(TRXState *s1, trx_timestamp_t *ptimestamp, void **__sa
float ** _samples = (float **) __samples;
int read_count = (count / 256);
log_limit("TRX_ECPRI_READ", "count = %ld", count);
for(int k = 0; k < read_count; k++) {
float * trx_samples;
sem_wait(&trx_read_sem);
......@@ -1027,6 +1032,7 @@ static int trx_ecpri_start(TRXState *s1, const TRXDriverParams *params)
log_info("TRX_ECPRI_START", "trx_api_version: %d", s1->trx_api_version);
log_info("TRX_ECPRI_START", "config file: %s", s1->path);
log_info("TEST-DPDK-ECPRI", "rec-mac: %s, re-mac: %s, rec-if: %s", s->rec_mac, s->re_mac, s->rec_if);
s->sample_rate = params->sample_rate[0].num / params->sample_rate[0].den;
......@@ -1046,8 +1052,7 @@ int trx_driver_init(TRXState *s1)
TRXEcpriState *s;
double val;
// Lock all current and future pages from preventing of being paged to
// swap
// Lock all current and future pages from preventing of being paged to swap
if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
log_error("TRX_ECPRI", "mlockall failed");
}
......
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