Commit 1a7ce303 authored by Titouan Soulard's avatar Titouan Soulard

Add an TRX driver: libtrx_rdma

- Move libcapulet to a shared library
- Ignore file from Amarisoft
- Create a useless driver
parent 05e67288
out/*
**/*.o
**/*.lo
libtrx/include/trx_driver.h
CFLAGS = -Wall -O3
INCLUDE_FLAGS = -Ilibcapulet/include/
LIB_FLAGS =-libverbs
INCLUDE_FLAGS = -Ilibcapulet/include -Ilibtrx/include
LIB_FLAGS =-lc -libverbs
all: out/rdma_standalone
all: out/libcapulet.so out/libtrx_rdma.so out/rdma_standalone
install: all
ln -sr out/libcapulet.so /usr/local/lib/
ln -sr out/librtx_rdma.so /usr/local/lib/
ldconfig
ln -sr out/rdma_standalone /usr/local/bin/
clean:
rm out/*
rm **/*.o
rm out/* ||:
rm **/*.o ||:
rm **/*.lo ||:
%.o: %.c
gcc -c $(CFLAGS) $(INCLUDE_FLAGS) $< -o $@
gcc -c $< $(CFLAGS) $(INCLUDE_FLAGS) -o $@
%.lo: %.c
gcc -c $< $(CFLAGS) -fPIC -DPIC $(INCLUDE_FLAGS) -o $@
out/libcapulet.so: libcapulet/net_udp.lo libcapulet/rdma_ib.lo libcapulet/rdma_mr_mgr.lo
gcc -shared -fPIC -DPIC -o $@ $^ $(LIB_FLAGS)
out/libcapulet.a: libcapulet/net_udp.o libcapulet/rdma_ib.o libcapulet/rdma_mr_mgr.o
ar -rc $@ $^
out/libtrx_rdma.so: libtrx/trx_rdma.lo out/libcapulet.so
gcc -shared -fPIC -DPIC -o $@ $< $(LIB_FLAGS) -L./out -lcapulet
out/rdma_standalone: example/rdma_standalone.o out/libcapulet.a
gcc $(CFLAGS) -o $@ $^ $(LIB_FLAGS)
out/rdma_standalone: example/rdma_standalone.o out/libcapulet.so
gcc $(CFLAGS) -o $@ $< $(LIB_FLAGS) -L./out -lcapulet
# RDMA minimal working example
# libcapulet and RDMA minimal working examples
Minimal working example for RDMA with multiple slaves: one machine serves a portion of memory and the others can read it.
Minimal working examples for RDMA: standalone server and client and library for a TRX driver.
## Configuring the RDMA interface
## Configuring an RDMA interface
In order to run this RDMA example, you will need to create a RDMA interface on two virtual machines:
......@@ -13,19 +13,26 @@ rdma link show
mkdir -p /sys/kernel/config/rdma_cm/rxe0
```
## Launching the program
## Standalone server and client
The provided `rdma_standalone` example allows reading the memory of one computer from another one.
On one machine, run the server program, which will read content to be put in the shared memory from STDIN:
```bash
make
out/rdma_standalone < README.md
make install
rdma_standalone < README.md
```
The other machine will act as a client, so we need to pass it the IP address of the server:
```bash
make
out/rdma_standalone -c 192.168.16.10
make install
rdma_standalone -c 192.168.16.10
```
## TRX driver
In order to compile the TRX driver, you will need to provide your own `trx_driver.h` file from Amarisoft.
Copy the file in `libtrx/include` and run `make install`, the library driver will be located at `out/libtrx_rdma.so`.
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "rdma_ib.h"
#include "trx_driver.h"
#include "net_udp.h"
struct SDRMetadata {
uint8_t version;
uint16_t mr_length;
uint8_t __unused[27];
};
struct SDRMemoryRegion {
struct SDRMetadata meta;
float iq[4096];
};
struct SDRContext {
struct CapuletRdmaIbContext ib_ctx;
struct CapuletNetUdpContext *udp_ctx;
struct SDRMemoryRegion *in;
struct SDRMemoryRegion *out;
};
#include "trx_rdma.h"
static int trx_rdma_start(TRXState *s, const TRXDriverParams *p) {
struct SDRContext *sdr_context = s->opaque;
}
static void trx_rdma_write(TRXState *s, trx_timestamp_t timestamp, const void **samples, int count, int flags, int rf_port_index) {
}
static int trx_rdma_read(TRXState *s, trx_timestamp_t *ptimestamp, void **psamples, int count, int rf_port) {
}
static int trx_rdma_get_sample_rate(TRXState *s, TRXFraction *psample_rate, int *psample_rate_num, int sample_rate_min) {
// -1 means not implemented
return -1;
}
static void trx_rdma_end(TRXState *s) {
}
int trx_driver_init(TRXState *s) {
struct SDRContext *sdr_context;
sdr_context = calloc(1, sizeof(struct SDRContext));
if(s->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", s->trx_api_version, TRX_API_VERSION);
return -1;
}
s->opaque = sdr_context;
s->trx_start_func = trx_rdma_start;
s->trx_write_func = trx_rdma_write;
s->trx_read_func = trx_rdma_read;
s->trx_get_sample_rate_func = trx_rdma_get_sample_rate;
s->trx_end_func = trx_rdma_end;
return 0;
}
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