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

Initial commit

parents
ecpri-tests/client
ecpri-tests/server
*.swp
*.swo
CC=gcc -m64 -msse4.1
CXX=g++ -m64 -msse4.1
CFLAGS=-O2 -fno-strict-aliasing
CFLAGS+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
CFLAGS+=-MMD -g
CXXFLAGS=$(CFLAGS)
PROGS= trx_ecpri.so
all: $(PROGS)
clean:
rm -f $(PROGS) *.lo *~ *.d
trx_ecpri.so: trx_ecpri.lo
$(CC) -shared $(LDFLAGS) -o $@ $< -lm
%.lo: %.c
$(CC) $(CFLAGS) -fpic -c -o $@ $<
-include $(wildcard *.d)
# TRX eCPRI Repository
TRX eCPRI driver for Amarisoft stack
# Copyright (C) 2014-2021 Amarisoft
# TRX Makefile version 2021-07-12
CC=gcc -m64 -msse4.1
CXX=g++ -m64 -msse4.1
CFLAGS=-O2 -fno-strict-aliasing -Wall -pedantic
CFLAGS+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
CFLAGS+=-MMD -g
CXXFLAGS=$(CFLAGS)
SRCCLIENT=trx_ecpri.c client.c
SRCSERVER=trx_ecpri.c server.c
OBJCLIENT=$(SRCCLIENT:%.c=%.o)
OBJSERVER=$(SRCSERVER:%.c=%.o)
CLIENT=client
SERVER=server
all: $(SERVER) $(CLIENT)
clean:
rm -f $(SERVER) $(CLIENT) *.o *~ *.d
$(SERVER): $(OBJSERVER)
$(CC) $(LDFLAGS) -o $@ $^ -lm -lpthread
$(CLIENT): $(OBJCLIENT)
$(CC) $(LDFLAGS) -o $@ $^ -lm -lpthread
%.o: %.c
$(CC) $(CFLAGS) -fpic -c -o $@ $<
-include $(wildcard *.d)
#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;
}
../trx_ecpri.c
\ No newline at end of file
#ifndef TRX_ECPRI_H
#define TRX_ECPRI_H
typedef struct {
const char * re_mac;
const char * rec_mac;
const char * rec_if;
int recv_affinity;
int send_affinity;
int prepare_affinity;
int decompress_affinity;
int ecpri_period;
int flow_id;
int sample_rate;
} TRXEcpriState;
int start(TRXEcpriState * s);
void log_error(const char * section, const char * msg, ...) {
time_t t;
struct tm ts;
char line[256];
va_list arglist;
time(&t);
ts = *localtime(&t);
strftime(line, 80, "%m-%d %H:%M:%S", &ts);
sprintf(line + strlen(line), " ERROR [%s] ", section);
va_start(arglist, msg);
vsprintf(line + strlen(line), msg, arglist);
va_end(arglist);
puts(line);
exit(EXIT_FAILURE);
}
void log_info(const char * section, const char * msg, ...) {
time_t t;
struct tm ts;
char line[256];
va_list arglist;
time(&t);
ts = *localtime(&t);
strftime(line, 80, "%m-%d %H:%M:%S", &ts);
sprintf(line + strlen(line), " INFO [%s] ", section);
va_start(arglist, msg);
vsprintf(line + strlen(line), msg, arglist);
va_end(arglist);
puts(line);
}
#ifdef DEBUG
void log_debug(const char * section, const char * msg, ...) {
time_t t;
struct tm ts;
char line[256];
va_list arglist;
time(&t);
ts = *localtime(&t);
strftime(line, 80, "%m-%d %H:%M:%S", &ts);
sprintf(line + strlen(line), " DEBUG [%s] ", section);
va_start(arglist, msg);
vsprintf(line + strlen(line), msg, arglist);
va_end(arglist);
puts(line);
}
#else
#define log_debug(...)
#endif
#endif
chrt -f 97 taskset -c 39 phc2sys -m -c ens9f1 -s CLOCK_REALTIME -O0 -f $HOME/linuxptp/configs/G.8275.1.cfg
chrt -f 97 taskset -c 38 ptp4l -H -i ens9f1 -m -f $HOME/linuxptp/configs/G.8275.1.cfg
This diff is collapsed.
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