Commit 977bcccf authored by Joanne Hugé's avatar Joanne Hugé

Fix trx_ecpri_write bug

parent 51f2267e
......@@ -52,13 +52,13 @@
//#define DEBUG // Enables / deactivates log_debug
//#define TRACE
#define MONITOR
#define MONITOR_EXIT
//#define MONITOR
//#define MONITOR_EXIT
#define RECV_PPS_THRESHOLD (EFREQ * 100 * 9 / 10)
#define RECV_STOP_THRESHOLD 2
#define PPS_UPDATE_PERIOD INT64_C(1000000000)
#define START_SENDING
//#define START_SENDING
//#define START_RECEIVING
#define STAT_FRAME_INTERVAL INT64_C(EFREQ * 500)
......@@ -129,6 +129,7 @@ typedef struct {
- fast conversion between int16_t and float
*/
#include "private/bf1_avx2.c"
//#include "private/bf1_avx2_nop.c"
// Buffers
static ring_buffer_t rx_rbuf; // Received packets
......@@ -1089,7 +1090,7 @@ static int64_t prev_count = 0;
static void trx_ecpri_write(TRXState *s1, trx_timestamp_t timestamp, const void **__samples, int count, int tx_port_index, TRXWriteMetadata *md)
{
(void) s1;
int write_count; int64_t ts; sample_group_t * g; int nc;
int write_count; int64_t ts; sample_group_t * g; int nc; int nk = 0;
float ** _samples = (float **) __samples;
write_count = count / M;
ts = timestamp / M;
......@@ -1128,11 +1129,16 @@ static void trx_ecpri_write(TRXState *s1, trx_timestamp_t timestamp, const void
g->count = write_count;
while((nc = rbuf_contiguous_copy(NULL, &trxw_rbuf[0], write_count))) {
int len = nc * trxr_rbuf[0].len * sizeof(Complex);
if(__samples)
for(int i = 0; i < TX_N_CHANNEL; i++)
memcpy(((uint8_t *) trxw_rbuf[i].buffer) + trxw_rbuf[0].write_index * trxw_rbuf[0].len * sizeof(Complex), (uint8_t*) _samples[i], nc * trxw_rbuf[0].len * sizeof(Complex));
for(int i = 0; i < TX_N_CHANNEL; i++) {
uint8_t * src = ((uint8_t*) _samples[i]) + len;
uint8_t * dst = ((uint8_t *) trxw_rbuf[i].buffer) + trxw_rbuf[0].write_index * trxw_rbuf[0].len * sizeof(Complex);
memcpy(dst, src, len);
}
trxw_rbuf[0].write_index = (trxw_rbuf[0].write_index + nc) % trxw_rbuf[0].buf_len;
write_count -= nc;
nk += nc;
}
rbuf_update_write_index(&trxw_group_rbuf);
......@@ -1205,6 +1211,177 @@ void dummy_enb_init(TRXState *s1, TRXEcpriState *s) {
startdpdk(s);
}
/* Called to start the tranceiver. Return 0 if OK, < 0 if */
int trx_start_func(TRXState *s, const TRXDriverParams *p) {
log_info("DEBUG", "trx_start_func");
return 0;
}
/* Deprecated, use trx_write_func2 instead.
Write 'count' samples on each channel of the TX port
'tx_port_index'. samples[0] is the array for the first
channel. timestamp is the time (in samples) at which the first
sample must be sent. When the TRX_WRITE_FLAG_PADDING flag is
set, samples is set to NULL. It indicates that no data should
be sent (TDD receive time). TRX_WRITE_FLAG_END_OF_BURST is set
to indicate in advance that the next write call will have the
TRX_WRITE_FLAG_PADDING flag set. Note:
TRX_WRITE_FLAG_END_OF_BURST and TRX_WRITE_FLAG_PADDING are
never set simultaneously.
*/
void trx_write_func(TRXState *s, trx_timestamp_t timestamp, const void **samples, int count, int flags, int tx_port_index) {
log_info("DEBUG", "**");
}
/* Deprecated, use trx_read_func2 instead.
Read 'count' samples from each channel. samples[0] is the array
for the first channel. *ptimestamp is the time at which the
first samples was received. Return the number of sample read
(=count).
Note: It is explicitely allowed that the application calls
trx_write_func, trx_read_func, trx_set_tx_gain_func and
trx_set_rx_gain_func from different threads.
*/
int trx_read_func(TRXState *s, trx_timestamp_t *ptimestamp, void **samples, int count, int rx_port_index) {
log_info("DEBUG", "**");
return 0;
}
/* Dynamic set the transmit gain (in dB). The origin and range are
driver dependent.
Note: this function is only used for user supplied dynamic
adjustements.
*/
void trx_set_tx_gain_func(TRXState *s, double gain, int channel_num) {
log_info("DEBUG", "trx_set_tx_gain_func");
}
/* Dynamic set the receive gain (in dB). The origin and range are
driver dependent.
Note: this function is only used for user supplied dynamic
adjustements.
*/
void trx_set_rx_gain_func(TRXState *s, double gain, int channel_num) {
log_info("DEBUG", "trx_set_rx_gain_func");
}
/* Return the maximum number of samples per TX packet. Called by
* the application after trx_start_func.
* Optional
*/
int trx_get_tx_samples_per_packet_func(TRXState *s) {
log_info("DEBUG", "trx_get_tx_samples_per_packet_func");
return 0;
}
/* Return some statistics. Return 0 if OK, < 0 if not available. */
int trx_get_stats(TRXState *s, TRXStatistics *m) {
log_info("DEBUG", "trx_get_stats");
return 0;
}
/* Callback must allocate info buffer that will be displayed */
void trx_dump_info(TRXState *s, trx_printf_cb cb, void *opaque) {
log_info("DEBUG", "*opaque");
}
/* Return the absolute TX power in dBm for the TX channel
'channel_num' assuming a square signal of maximum
amplitude. This function can be called from any thread and
needs to be fast. Return 0 if OK, -1 if the result is not
available. */
int trx_get_abs_tx_power_func(TRXState *s,
float *presult, int channel_num) {
log_info("DEBUG", "trx_get_abs_tx_power_func");
return 0;
}
/* Return the absolute RX power in dBm for the RX channel
'channel_num' assuming a square signal of maximum
amplitude. This function can be called from any thread and
needs to be fast. Return 0 if OK, -1 if the result is not
available. */
int trx_get_abs_rx_power_func(TRXState *s,
float *presult, int channel_num) {
log_info("DEBUG", "trx_get_abs_rx_power_func");
return 0;
}
/* Remote API communication
* Available since API v14
* trx_msg_recv_func: called for each trx received messages
* trx_msg_send_func: call it to send trx messages (They must be registered by client)
* For each message, a call to send API must be done
*/
void trx_msg_recv_func(TRXState *s, TRXMsg *msg) {
log_info("DEBUG", "trx_msg_recv_func");
}
TRXMsg* trx_msg_send_func(TRXState *s) {
log_info("DEBUG", "trx_msg_send_func");
return NULL;
}
/* Return actual transmit gain (in dB). The origin and range are
driver dependent.
*/
void trx_get_tx_gain_func(TRXState *s, double *gain, int channel_num) {
log_info("DEBUG", "trx_get_tx_gain_func");
}
/* Returns actual receive gain (in dB). The origin and range are
driver dependent.
*/
void trx_get_rx_gain_func(TRXState *s, double *gain, int channel_num) {
log_info("DEBUG", "trx_get_rx_gain_func");
}
/* Stop operation of the transceiver - to be called after trx_start.
resources allocated in init are not released, so trx_call can be called again */
void trx_stop_func(TRXState *s) {
log_info("DEBUG", "trx_stop_func");
}
/* OFDM mode: experimental 7.2 API */
/* read the current timestamp (only used in OFDM mode). Return 0
if OK, < 0 if not supported by device. */
int trx_read_timestamp(TRXState *s, trx_timestamp_t *ptimestamp,
int port_index) {
log_info("DEBUG", "trx_read_timestamp");
return 0;
}
void trx_set_tx_streams(TRXState *s, int rf_port_index,
int n_streams, const TRXOFDMStreamInfo *streams) {
log_info("DEBUG", "trx_set_tx_streams");
}
void trx_set_rx_streams(TRXState *s, int rf_port_index,
int n_streams, const TRXOFDMStreamInfo *streams) {
log_info("DEBUG", "trx_set_rx_streams");
}
/* schedule the reading of OFDM symbols. Return 0 if OK, < 0 if
error. */
int trx_schedule_read(TRXState *s, int rf_port_index,
const TRXScheduledSymbol *symbols,
int n_symbols) {
log_info("DEBUG", "trx_schedule_read");
return 0;
}
/* AGC functions */
int trx_set_agc_func(TRXState *s, const TRXAGCParams *p, int channel) {
log_info("DEBUG", "trx_set_agc_func");
return 0;
}
int trx_get_agc_func(TRXState *s, TRXAGCParams *p, int channel) {
log_info("DEBUG", "trx_get_agc_func");
return 0;
}
int trx_driver_init(TRXState *s1)
{
TRXEcpriState *s;
......@@ -1257,5 +1434,27 @@ int trx_driver_init(TRXState *s1)
s1->trx_read_func2 = trx_ecpri_read;
s1->trx_start_func = trx_ecpri_start;
s1->trx_get_sample_rate_func = trx_ecpri_get_sample_rate;
//s1->trx_write_func = trx_write_func;
//s1->trx_read_func = trx_read_func;
//s1->trx_set_tx_gain_func = trx_set_tx_gain_func;
//s1->trx_set_rx_gain_func = trx_set_rx_gain_func;
//s1->trx_get_tx_samples_per_packet_func = trx_get_tx_samples_per_packet_func;
//s1->trx_get_stats = trx_get_stats;
//s1->trx_dump_info = trx_dump_info;
//s1->trx_get_abs_tx_power_func = trx_get_abs_tx_power_func;
//s1->trx_get_abs_rx_power_func = trx_get_abs_rx_power_func;
//s1->trx_msg_recv_func = trx_msg_recv_func;
//s1->trx_get_tx_gain_func = trx_get_tx_gain_func;
//s1->trx_get_rx_gain_func = trx_get_rx_gain_func;
//s1->trx_stop_func = trx_stop_func;
//s1->trx_read_timestamp = trx_read_timestamp;
//s1->trx_set_tx_streams = trx_set_tx_streams;
//s1->trx_set_rx_streams = trx_set_rx_streams;
//s1->trx_schedule_read = trx_schedule_read;
//s1->trx_set_agc_func = trx_set_agc_func;
//s1->trx_get_agc_func = trx_get_agc_func;
//s1->trx_msg_send_func = trx_msg_send_func;
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