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

wip

parent 7378b8be
......@@ -83,6 +83,15 @@ eCPRI concatenated frames
| Header #0 | | | Header #1 | |
+-----------+------------------+---------+-----------+------------------+
IQ sample pair: 32 bit (4 bytes)
IQ / second / antenna: 30 720 000
IQ payload per frame: 8832 bytes = 2208 IQ samples
IQ throughput (4 * 20 MHz): 3 932 160 000 bytes
1 radio frame = 10 subframes
1 subframe = 2 slots
1 slot = 7 symbols
*/
typedef struct {
......@@ -154,7 +163,7 @@ static volatile counter_stat_t rx_drop_counter; // frames sent to RRH
static volatile counter_stat_t tx_drop_counter; // frames sent to RRH
// Network
static volatile int seq_id;
static volatile uint8_t seq_id;
static volatile uint8_t frame_id;
static volatile uint8_t sub_frame_id;
static volatile uint8_t slot_id;
......@@ -444,59 +453,63 @@ static void *encode_thread(void *p) {
// If there are frames from trx_write callback to encode
if(to_write && to_read) {
data = rbuf_write(&tx_rbuf);
memcpy(data, packet_header, PACKET_HEADER);
j = ETHERNET_HEADER + ECPRI_COMMON_HEADER;
// SEQ_ID
*((uint16_t *) data[j + 2]) = htons(seq_id++);
j = ETHERNET_HEADER + ECPRI_IQ_HEADER;
// ORAN counters
data[j + 1] = frame_id;
16_bit = (uint16_t *) data[j + 2];
*16_bit = sub_frame_id << 8;
*16_bit |= slot_id << 4 ;
*16_bit |= symbol_id;
for(uint16_t antenna_id = 0 ; antenna_id < 4; antenna_id++) {
data = rbuf_write(&tx_rbuf);
memcpy(data, packet_header, PACKET_HEADER);
j = ETHERNET_HEADER + ECPRI_COMMON_HEADER;
// PC_ID
*((uint16_t *) data[j + 0]) = htons(antenna_id);
// SEQ_ID
*((uint16_t *) data[j + 2]) = htons(seq_id++ << 8 + 0x80);
j = ETHERNET_HEADER + ECPRI_IQ_HEADER;
// ORAN counters
data[j + 1] = frame_id;
16_bit = (uint16_t *) data[j + 2];
*16_bit = sub_frame_id << 8;
*16_bit |= slot_id << 4 ;
*16_bit |= symbol_id;
// 8832 bytes of IQ samples
// TODO
int nc;
int nf = 8832;
while((nc = rbuf_contiguous_copy(&trxw_rbuf[antenna_id], &tx_rbuf, nf))) {
memcpy(data[PACKET_HEADER] + (8832 - nf),
rbuf_read(&trxw_rbuf[antenna_id], 8832 - nf),
nc);
rbuf_increment_read(&trxw_rbuf[antenna_id], nc);
tx_rbuf.write_index = (tx_rbuf.write_index + nc) % tx_rbuf.buf_len;
trxw_rbuf[0].read_index = (trxw_rbuf[0].read_index + nc) % trxw_rbuf[0].buf_len;
nf -= nc;
}
if(nf)
exit(EXIT_FAILURE);
}
update_counter(&encode_counter, nb_frames);
/* How to compute counters:
- How much IQ samples are sent ?
- How much IQ samples / second ?
*/
if(!g->count) {
rbuf_update_read_index(&trxw_group_rbuf);
}
frame_id = (frame_id + 1) % 100;
sub_frame_id = (frame_id + 1) % 100;
}
// TODO
int nc;
int nf = nb_frames;
while((nc = rbuf_contiguous_copy(&trxw_rbuf[0], &tx_rbuf, nf))) {
Complex * iq_samples[4];
uint8_t * buf = RBUF_WRITE0(tx_rbuf, uint8_t) + 8;
for(int j = 0; j < s->tx_n_channel; j++)
iq_samples[j] = ((Complex *) trxw_rbuf[j].buffer) + (trxw_rbuf[0].read_index * trxw_rbuf[0].len);
for(int i = 0; i < nc; i++) {
for(int i = 0; i < s->tx_n_channel ; i++)
encode_s64_b60_2(buf + i * 60, (float *) iq_samples[i]);
*((uint16_t *)(buf - 2)) = htons(seq_id++);
for(int j = 0; j < s->tx_n_channel; j++)
iq_samples[j] += trxw_rbuf[0].len;
buf += tx_rbuf.len;
slot_id = (slot_id + 1) % 2;
if(!slot_id) {
sub_frame_id = (sub_frame_id + 1) % 10;
if(!sub_frame_id) {
frame_id = (frame_id + 1) % 100;
}
tx_rbuf.write_index = (tx_rbuf.write_index + nc) % tx_rbuf.buf_len;
trxw_rbuf[0].read_index = (trxw_rbuf[0].read_index + nc) % trxw_rbuf[0].buf_len;
nf -= nc;
}
if(nf)
exit(EXIT_FAILURE);
}
update_counter(&encode_counter, nb_frames);
if(!g->count) {
rbuf_update_read_index(&trxw_group_rbuf);
}
// TODO
int nc;
int nf = nb_frames;
}
}
pthread_exit(EXIT_SUCCESS);
......
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