Commit c4fba315 authored by Joanne Hugé's avatar Joanne Hugé

First eCPRI driver version

parent ae54ba42
......@@ -3,7 +3,6 @@
CC=gcc -m64 -msse4.1
CXX=g++ -m64 -msse4.1
#CFLAGS=-O2 -Wall -pedantic -std=gnu17
CFLAGS=-O2 -fno-strict-aliasing -Wall -pedantic -std=gnu17
CFLAGS +=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
CFLAGS += -DALLOW_EXPERIMENTAL_API
......
......@@ -86,10 +86,10 @@ int main(int argc, char * argv[]) {
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";
#if 1
s->rec_mac = "b8:59:9f:07:7d:da";
s->re_mac = "04:09:a5:0f:9f:4c";
s->rec_if = "ens9f0np0";
#else
s->rec_mac = "b8:ce:f6:4b:00:22";
s->re_mac = "b8:ce:f6:4b:00:23";
......
......@@ -53,10 +53,10 @@
#define PACKET_SIZE 262
#define DATA_SIZE 244
#define FRAME_FREQ INT64_C(3840000)
#define SEND_LIMIT (1250 * 10)
//#define SEND_LIMIT (1250 * 10)
#define TRX_WB_MAX_PARTS 1000
#define TRX_BUF_MAX_SIZE 1000
#define STATISTIC_REFRESH_RATE INT64_C(100 * 1000 * 1000)
#define STATISTIC_REFRESH_RATE INT64_C(500 * 1000 * 1000)
static void log_error(const char * section, const char * msg, ...) {
time_t t;
......@@ -328,6 +328,7 @@ static void init_dpdk(int argc, char ** argv) {
static void send_packets(int port) {
struct rte_mbuf * pkt[BURST_SIZE];
struct rte_ether_hdr *eth_hdr;
uint16_t nb_tx = 0;
for(int i = 0; i < BURST_SIZE; i++) {
int pkt_size;
......@@ -340,22 +341,25 @@ static void send_packets(int port) {
eth_hdr->d_addr = d_addr;
eth_hdr->s_addr = s_addr;
}
eth_hdr->ether_type = 0xaefe;
eth_hdr->ether_type = htons(0xaefe);
memcpy(rte_pktmbuf_mtod_offset(pkt[i], uint8_t *, sizeof(struct rte_ether_hdr)), data[i], DATA_SIZE);
pkt_size = DATA_SIZE + sizeof(struct rte_ether_hdr);
pkt[i]->data_len = pkt_size;
pkt[i]->pkt_len = pkt_size;
}
const uint16_t nb_tx = rte_eth_tx_burst(port, 0, pkt, BURST_SIZE);
while(nb_tx < BURST_SIZE) {
nb_tx = rte_eth_tx_burst(port, 0, pkt + nb_tx, BURST_SIZE - nb_tx);
}
/* Free any unsent packets. */
if (unlikely(nb_tx < BURST_SIZE)) {
if (nb_tx < BURST_SIZE) {
uint16_t buf;
for (buf = nb_tx; buf < BURST_SIZE; buf++)
rte_pktmbuf_free(pkt[buf]);
fprintf(stderr, "Sent %d packets instead of %d\n", nb_tx, BURST_SIZE);
exit(EXIT_FAILURE);
}
}
// TODO store received packets' data in buffer
static int recv_packets(int port) {
......@@ -421,7 +425,7 @@ static void *send_thread(void *p) {
clock_gettime(CLOCK_TAI, &initial);
for(int64_t i = 1;; i++) {
#ifdef DEBUG
#ifdef SEND_LIMIT
if(i > SEND_LIMIT) {
int64_t d;
clock_gettime(CLOCK_TAI, &next);
......@@ -580,8 +584,9 @@ static void *decompress_thread(void *p) {
pthread_exit(EXIT_SUCCESS);
}
static void *statistic_thread(void *p) {
struct timespec next, initial;
struct timespec next, initial, current;
cpu_set_t mask;
int64_t duration_ns;
TRXEcpriState * s = (TRXEcpriState *) p;
log_info("STATISTIC_THREAD", "Thread init");
......@@ -596,11 +601,14 @@ static void *statistic_thread(void *p) {
next = initial;
for(;;) {
add_ns(&next, STATISTIC_REFRESH_RATE);
log_info("STATS", "%14" PRIi64 " - %14" PRIi64 " - %14" PRIi64 " - %14" PRIi64,
clock_gettime(CLOCK_TAI, &current);
duration_ns = calcdiff_ns(current, initial);
log_info("STATS", "%14" PRIi64 " - %14" PRIi64 " - %14" PRIi64 " - %14" PRIi64 " - %14" PRIi64 "pps",
prepared_frame_count,
read_frame_count,
sent_frame_count,
recv_frame_count);
recv_frame_count,
(NSEC_PER_SEC * sent_frame_count) / duration_ns);
clock_nanosleep(CLOCK_TAI, TIMER_ABSTIME, &next, NULL);
}
pthread_exit(EXIT_SUCCESS);
......@@ -706,6 +714,7 @@ static int start_threads(TRXEcpriState * s) {
int startdpdk(TRXEcpriState * s) {
uint8_t ecpri_message[DATA_SIZE];
#define USE10G
#define ARGC 11
#define ARGC_LEN 256
char _argv[ARGC][ARGC_LEN] = {
......@@ -714,10 +723,16 @@ int startdpdk(TRXEcpriState * s) {
"28",
"-b",
"0000:04:00.0",
#ifdef USE10G
"-b",
"0000:3b:00.0",
#endif
"-b",
"0000:3b:00.1",
#ifndef USE10G
"-b",
"0000:5e:00.0",
#endif
"-b",
"0000:5e:00.1",
};
......
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