Commit b7ea4e0f authored by Cedric Roux's avatar Cedric Roux

benetel 5g: support for two antennas

parent a9f57407
...@@ -162,8 +162,9 @@ int trx_benetel_ctlrecv(openair0_device *device, void *msg, ssize_t msg_len) ...@@ -162,8 +162,9 @@ int trx_benetel_ctlrecv(openair0_device *device, void *msg, ssize_t msg_len)
cap->FH_fmt = OAI_IF4p5_only; cap->FH_fmt = OAI_IF4p5_only;
cap->num_bands = 1; cap->num_bands = 1;
cap->band_list[0] = 78; cap->band_list[0] = 78;
cap->nb_rx[0] = 1; /* TODO: hardcoded to 1 for the moment, get the real value somehow... */
cap->nb_tx[0] = 1; cap->nb_rx[0] = 1; //device->openair0_cfg->rx_num_channels;
cap->nb_tx[0] = 1; //device->openair0_cfg->tx_num_channels;
cap->max_pdschReferenceSignalPower[0] = -27; cap->max_pdschReferenceSignalPower[0] = -27;
cap->max_rxgain[0] = 90; cap->max_rxgain[0] = 90;
...@@ -201,12 +202,13 @@ void benetel_fh_if4p5_south_in(RU_t *ru, ...@@ -201,12 +202,13 @@ void benetel_fh_if4p5_south_in(RU_t *ru,
NR_DL_FRAME_PARMS *fp; NR_DL_FRAME_PARMS *fp;
int symbol; int symbol;
int32_t *rxdata; int32_t *rxdata;
int antenna = 0; int antenna;
lock_ul_buffer(&s->buffers, *slot); lock_ul_buffer(&s->buffers, *slot);
#if 1 #if 1
next: next:
while (!(s->buffers.ul_busy[*slot] == 0x3fff || while (!((s->buffers.ul_busy[0][*slot] == 0x3fff &&
s->buffers.ul_busy[1][*slot] == 0x3fff) ||
s->buffers.prach_busy[*slot] == 1)) s->buffers.prach_busy[*slot] == 1))
wait_ul_buffer(&s->buffers, *slot); wait_ul_buffer(&s->buffers, *slot);
if (s->buffers.prach_busy[*slot] == 1) { if (s->buffers.prach_busy[*slot] == 1) {
...@@ -226,28 +228,31 @@ next: ...@@ -226,28 +228,31 @@ next:
#endif #endif
fp = ru->nr_frame_parms; fp = ru->nr_frame_parms;
for (symbol = 0; symbol < 14; symbol++) { for (antenna = 0; antenna < ru->nb_rx; antenna++) {
int i; for (symbol = 0; symbol < 14; symbol++) {
int16_t *p = (int16_t *)(&s->buffers.ul[*slot][symbol*1272*4]); int i;
for (i = 0; i < 1272*2; i++) { int16_t *p = (int16_t *)(&s->buffers.ul[antenna][*slot][symbol*1272*4]);
p[i] = (int16_t)(ntohs(p[i])) / 16; for (i = 0; i < 1272*2; i++) {
} p[i] = (int16_t)(ntohs(p[i])) / 16;
rxdata = &ru->common.rxdataF[antenna][symbol * fp->ofdm_symbol_size]; }
rxdata = &ru->common.rxdataF[antenna][symbol * fp->ofdm_symbol_size];
#if 0 #if 0
if (*slot == 0 && symbol == 0) if (*slot == 0 && symbol == 0)
printf("rxdata in benetel_fh_if4p5_south_in %p\n", &ru->common.rxdataF[antenna][0]); printf("rxdata in benetel_fh_if4p5_south_in %p\n", &ru->common.rxdataF[antenna][0]);
#endif #endif
#if 1 #if 1
memcpy(rxdata + 2048 - 1272/2, memcpy(rxdata + 2048 - 1272/2,
&s->buffers.ul[*slot][symbol*1272*4], &s->buffers.ul[antenna][*slot][symbol*1272*4],
(1272/2) * 4); (1272/2) * 4);
memcpy(rxdata, memcpy(rxdata,
&s->buffers.ul[*slot][symbol*1272*4] + (1272/2)*4, &s->buffers.ul[antenna][*slot][symbol*1272*4] + (1272/2)*4,
(1272/2) * 4); (1272/2) * 4);
#endif #endif
}
} }
s->buffers.ul_busy[*slot] = 0; s->buffers.ul_busy[0][*slot] = 0;
s->buffers.ul_busy[1][*slot] = 0;
signal_ul_buffer(&s->buffers, *slot); signal_ul_buffer(&s->buffers, *slot);
unlock_ul_buffer(&s->buffers, *slot); unlock_ul_buffer(&s->buffers, *slot);
...@@ -285,43 +290,47 @@ void benetel_fh_if4p5_south_out(RU_t *ru, ...@@ -285,43 +290,47 @@ void benetel_fh_if4p5_south_out(RU_t *ru,
NR_DL_FRAME_PARMS *fp; NR_DL_FRAME_PARMS *fp;
int symbol; int symbol;
int32_t *txdata; int32_t *txdata;
int aa = 0; int aa;
//printf("BENETEL: %s (f.sf %d.%d ts %ld)\n", __FUNCTION__, frame, slot, timestamp); //printf("BENETEL: %s (f.sf %d.%d ts %ld)\n", __FUNCTION__, frame, slot, timestamp);
lock_dl_buffer(&s->buffers, slot); lock_dl_buffer(&s->buffers, slot);
if (s->buffers.dl_busy[slot]) { if (s->buffers.dl_busy[0][slot] ||
s->buffers.dl_busy[1][slot]) {
printf("%s: fatal: DL buffer busy for subframe %d\n", __FUNCTION__, slot); printf("%s: fatal: DL buffer busy for subframe %d\n", __FUNCTION__, slot);
unlock_dl_buffer(&s->buffers, slot); unlock_dl_buffer(&s->buffers, slot);
return; return;
} }
fp = ru->nr_frame_parms; fp = ru->nr_frame_parms;
if (ru->num_gNB != 1 || ru->nb_tx != 1 || fp->ofdm_symbol_size != 2048 || if (ru->num_gNB != 1 || fp->ofdm_symbol_size != 2048 ||
fp->Ncp != NORMAL || fp->symbols_per_slot != 14) { fp->Ncp != NORMAL || fp->symbols_per_slot != 14) {
printf("%s:%d:%s: unsupported configuration\n", printf("%s:%d:%s: unsupported configuration\n",
__FILE__, __LINE__, __FUNCTION__); __FILE__, __LINE__, __FUNCTION__);
exit(1); exit(1);
} }
for (symbol = 0; symbol < 14; symbol++) { for (aa = 0; aa < ru->nb_tx; aa++) {
txdata = &ru->common.txdataF_BF[aa][symbol * fp->ofdm_symbol_size]; for (symbol = 0; symbol < 14; symbol++) {
txdata = &ru->common.txdataF_BF[aa][symbol * fp->ofdm_symbol_size];
#if 1 #if 1
memcpy(&s->buffers.dl[slot][symbol*1272*4], memcpy(&s->buffers.dl[aa][slot][symbol*1272*4],
txdata + 2048 - (1272/2), txdata + 2048 - (1272/2),
(1272/2) * 4); (1272/2) * 4);
memcpy(&s->buffers.dl[slot][symbol*1272*4] + (1272/2)*4, memcpy(&s->buffers.dl[aa][slot][symbol*1272*4] + (1272/2)*4,
txdata, txdata,
(1272/2) * 4); (1272/2) * 4);
#endif #endif
int i; int i;
uint16_t *p = (uint16_t *)(&s->buffers.dl[slot][symbol*1272*4]); uint16_t *p = (uint16_t *)(&s->buffers.dl[aa][slot][symbol*1272*4]);
for (i = 0; i < 1272*2; i++) { for (i = 0; i < 1272*2; i++) {
p[i] = htons(p[i]<<4); p[i] = htons(p[i]);
}
} }
} }
s->buffers.dl_busy[slot] = 0x3fff; s->buffers.dl_busy[0][slot] = 0x3fff;
s->buffers.dl_busy[1][slot] = 0x3fff;
unlock_dl_buffer(&s->buffers, slot); unlock_dl_buffer(&s->buffers, slot);
} }
......
...@@ -243,21 +243,22 @@ l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid, benetel_t *bs) ...@@ -243,21 +243,22 @@ l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid, benetel_t *bs)
} }
if(PAYLOAD_1 == 0x13 && PAYLOAD_2 == 0xe4 && ANT_NUM == 0x00) { if(PAYLOAD_1 == 0x13 && PAYLOAD_2 == 0xe4) {
int subframe = SUBFRAME >> 4; int subframe = SUBFRAME >> 4;
int slot = ((SUBFRAME & 0x0f) << 2) | ((SYMBOL >> 6) & 0x03); int slot = ((SUBFRAME & 0x0f) << 2) | ((SYMBOL >> 6) & 0x03);
p.frame = FRAME; p.frame = FRAME;
p.slot = subframe * 2 + slot; p.slot = subframe * 2 + slot;
p.symbol = SYMBOL & 0x3f; p.symbol = SYMBOL & 0x3f;
p.antenna = 0; p.antenna = ANT_NUM;
memcpy(p.iq, IQ_ptr, 5088); memcpy(p.iq, IQ_ptr, 5088);
store_ul(bs, &p); store_ul(bs, &p);
// if (p.symbol==0) printf("store ul f.sl.sy %d.%d.%d\n", p.frame, p.slot, p.symbol); // if (p.symbol==0) printf("store ul f.sl.sy %d.%d.%d\n", p.frame, p.slot, p.symbol);
} }
// U-PLANE UL ANT_0 PROCESSING // U-PLANE UL PROCESSING
if(PAYLOAD_1 == 0x13 && PAYLOAD_2 == 0xe4 && ANT_NUM == 0x00 && dl_start == 1) if(PAYLOAD_1 == 0x13 && PAYLOAD_2 == 0xe4 && dl_start == 1)
{ {
int a = ANT_NUM & 0x01;
int frame = FRAME; int frame = FRAME;
int subframe = SUBFRAME >> 4; int subframe = SUBFRAME >> 4;
int slot = ((SUBFRAME & 0x0f) << 2) | ((SYMBOL >> 6) & 0x03); int slot = ((SUBFRAME & 0x0f) << 2) | ((SYMBOL >> 6) & 0x03);
...@@ -282,66 +283,45 @@ l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid, benetel_t *bs) ...@@ -282,66 +283,45 @@ l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid, benetel_t *bs)
} }
} }
ANT_NUM = 0x00;
// Mask the symbol bits from UL packet received and apply the shift. // Mask the symbol bits from UL packet received and apply the shift.
SYMBOL = ((SYMBOL & 0b00111111) + 10) % 14; SYMBOL = ((SYMBOL & 0b00111111) + 10) % 14;
ANT_NUM = 0x00; ANT_NUM = a;
SUBFRAME = sf; SUBFRAME = sf;
if (a == 1)
slot_id_ctrl++;
// Slot id control for DL // Slot id control for DL
if(slot_id_ctrl > 13){ if (slot_id_ctrl > 13) {
SYMBOL = SYMBOL | 0b01000000; SYMBOL = SYMBOL | 0b01000000;
if (a == 1) {
if (slot_id_ctrl > 27) {
slot_id_ctrl = 0;
sf = sf + 0x10;
if (sf > 0x90){
sf = 0;
}
}
}
} }
/* antenna 0 - send actual DL data (if available) */ /* send actual DL data (if available) */
oai_slot = tx_subframe * 2 + tx_slot; oai_slot = tx_subframe * 2 + tx_slot;
lock_dl_buffer(bs->buffers, oai_slot); lock_dl_buffer(bs->buffers, oai_slot);
if (!(bs->buffers->dl_busy[oai_slot] & (1 << tx_symbol))) { if (!(bs->buffers->dl_busy[a][oai_slot] & (1 << tx_symbol))) {
printf("%s: warning, DL underflow (sl.symbol %d.%d)\n", __FUNCTION__, printf("%s: warning, DL underflow (antenna %d sl.symbol %d.%d)\n", __FUNCTION__,
oai_slot, tx_symbol); a, oai_slot, tx_symbol);
memset(IQ_ptr, 0, 1272 * 4); memset(IQ_ptr, 0, 1272 * 4);
} else { } else {
memcpy(IQ_ptr, bs->buffers->dl[oai_slot] + tx_symbol * 1272*4, memcpy(IQ_ptr, bs->buffers->dl[a][oai_slot] + tx_symbol * 1272*4,
1272*4); 1272*4);
} }
//printf("DL buffer f sf slot symbol %d %d %d %d (sf %d)\n", tx_frame, tx_subframe, tx_slot, tx_symbol, (int)sf); //printf("DL buffer f sf slot symbol %d %d %d %d (sf %d)\n", tx_frame, tx_subframe, tx_slot, tx_symbol, (int)sf);
bs->buffers->dl_busy[oai_slot] &= ~(1 << tx_symbol); bs->buffers->dl_busy[a][oai_slot] &= ~(1 << tx_symbol);
unlock_dl_buffer(bs->buffers, oai_slot); unlock_dl_buffer(bs->buffers, oai_slot);
// fill DL Data for ant 0 with 0 value
// memset(IQ_ptr, 0, 5088);
}
// U-PLANE UL ANT_1 PROCESSING
if(PAYLOAD_1 == 0x13 && PAYLOAD_2 == 0xe4 && ANT_NUM == 0x01 && dl_start == 1)
{
// Mask the symbol bits from UL packet received and apply the shift.
SYMBOL = ((SYMBOL & 0b00111111) +10) % 14;
ANT_NUM = 0x01;
SUBFRAME = sf;
slot_id_ctrl++;
// Slot id control for DL
if(slot_id_ctrl > 13){
SYMBOL = SYMBOL | 0b01000000;
if(slot_id_ctrl > 27){
slot_id_ctrl = 0;
sf = sf + 0x10;
if (sf >0x90){
sf = 0;
}
}
}
// fill DL Data for ant 1 with 0 value
memset(IQ_ptr, 0, 5088);
} }
// U-PLANE PRACH PROCESSING // U-PLANE PRACH PROCESSING
......
...@@ -35,63 +35,61 @@ printf("store_ul %d.%ld (%ld)\n", (int)(t.tv_sec % 60), t.tv_nsec, t.tv_nsec - o ...@@ -35,63 +35,61 @@ printf("store_ul %d.%ld (%ld)\n", (int)(t.tv_sec % 60), t.tv_nsec, t.tv_nsec - o
old = t; old = t;
#endif #endif
/* only antenna 0 for the moment */ int a = ul->antenna;
if (ul->antenna != 0)
return;
if (ul->slot != bs->next_slot || if (ul->slot != bs->next_slot[a] ||
ul->symbol != bs->next_symbol) { ul->symbol != bs->next_symbol[a]) {
printf("%s: error, expected frame.sl.symbol %d.%d.%d, got %d.%d.%d\n", printf("%s: error, antenna %d expected frame.sl.symbol %d.%d.%d, got %d.%d.%d\n",
__FUNCTION__, __FUNCTION__,
bs->expected_benetel_frame, bs->next_slot, bs->next_symbol, a, bs->expected_benetel_frame[a], bs->next_slot[a], bs->next_symbol[a],
ul->frame, ul->slot, ul->symbol); ul->frame, ul->slot, ul->symbol);
} }
/* fill missing data with 0s */ /* fill missing data with 0s */
while (ul->slot != bs->next_slot || while (ul->slot != bs->next_slot[a] ||
ul->symbol != bs->next_symbol) { ul->symbol != bs->next_symbol[a]) {
lock_ul_buffer(bs->buffers, bs->next_slot); lock_ul_buffer(bs->buffers, bs->next_slot[a]);
if (bs->buffers->ul_busy[bs->next_slot] & (1 << bs->next_symbol)) { if (bs->buffers->ul_busy[a][bs->next_slot[a]] & (1 << bs->next_symbol[a])) {
printf("%s: warning, UL overflow (sl.symbol %d.%d)\n", __FUNCTION__, printf("%s: warning, antenna %d UL overflow (sl.symbol %d.%d)\n", __FUNCTION__,
bs->next_slot, bs->next_symbol); a, bs->next_slot[a], bs->next_symbol[a]);
} }
memset(bs->buffers->ul[bs->next_slot] + bs->next_symbol * 1272*4, memset(bs->buffers->ul[a][bs->next_slot[a]] + bs->next_symbol[a] * 1272*4,
0, 1272*4); 0, 1272*4);
bs->buffers->ul_busy[bs->next_slot] |= (1 << bs->next_symbol); bs->buffers->ul_busy[a][bs->next_slot[a]] |= (1 << bs->next_symbol[a]);
signal_ul_buffer(bs->buffers, bs->next_slot); signal_ul_buffer(bs->buffers, bs->next_slot[a]);
unlock_ul_buffer(bs->buffers, bs->next_slot); unlock_ul_buffer(bs->buffers, bs->next_slot[a]);
bs->next_symbol++; bs->next_symbol[a]++;
if (bs->next_symbol == 14) { if (bs->next_symbol[a] == 14) {
bs->next_symbol = 0; bs->next_symbol[a] = 0;
bs->next_slot = (bs->next_slot + 1) % 20; bs->next_slot[a] = (bs->next_slot[a] + 1) % 20;
if (bs->next_slot == 0) { if (bs->next_slot[a] == 0) {
bs->expected_benetel_frame++; bs->expected_benetel_frame[a]++;
bs->expected_benetel_frame &= 255; bs->expected_benetel_frame[a] &= 255;
} }
} }
} }
lock_ul_buffer(bs->buffers, bs->next_slot); lock_ul_buffer(bs->buffers, bs->next_slot[a]);
if (bs->buffers->ul_busy[bs->next_slot] & (1 << bs->next_symbol)) { if (bs->buffers->ul_busy[a][bs->next_slot[a]] & (1 << bs->next_symbol[a])) {
printf("%s: warning, UL overflow (sl.symbol %d.%d)\n", __FUNCTION__, printf("%s: warning, antenna %d UL overflow (sl.symbol %d.%d)\n", __FUNCTION__,
bs->next_slot, bs->next_symbol); a, bs->next_slot[a], bs->next_symbol[a]);
} }
memcpy(bs->buffers->ul[bs->next_slot] + bs->next_symbol * 1272*4, memcpy(bs->buffers->ul[a][bs->next_slot[a]] + bs->next_symbol[a] * 1272*4,
ul->iq, 1272*4); ul->iq, 1272*4);
bs->buffers->ul_busy[bs->next_slot] |= (1 << bs->next_symbol); bs->buffers->ul_busy[a][bs->next_slot[a]] |= (1 << bs->next_symbol[a]);
signal_ul_buffer(bs->buffers, bs->next_slot); signal_ul_buffer(bs->buffers, bs->next_slot[a]);
unlock_ul_buffer(bs->buffers, bs->next_slot); unlock_ul_buffer(bs->buffers, bs->next_slot[a]);
bs->next_symbol++; bs->next_symbol[a]++;
if (bs->next_symbol == 14) { if (bs->next_symbol[a] == 14) {
bs->next_symbol = 0; bs->next_symbol[a] = 0;
bs->next_slot = (bs->next_slot + 1) % 20; bs->next_slot[a] = (bs->next_slot[a] + 1) % 20;
if (bs->next_slot == 0) { if (bs->next_slot[a] == 0) {
bs->expected_benetel_frame++; bs->expected_benetel_frame[a]++;
bs->expected_benetel_frame &= 255; bs->expected_benetel_frame[a] &= 255;
} }
} }
} }
......
...@@ -26,9 +26,10 @@ ...@@ -26,9 +26,10 @@
typedef struct { typedef struct {
shared_buffers *buffers; shared_buffers *buffers;
int next_slot; /* [2] is for two antennas */
int next_symbol; int next_slot[2];
int expected_benetel_frame; int next_symbol[2];
int expected_benetel_frame[2];
char *dpdk_main_command_line; char *dpdk_main_command_line;
} benetel_t; } benetel_t;
......
...@@ -68,7 +68,8 @@ void *benetel_start_dpdk(char *ifname, shared_buffers *buffers, char *dpdk_main_ ...@@ -68,7 +68,8 @@ void *benetel_start_dpdk(char *ifname, shared_buffers *buffers, char *dpdk_main_
bs->buffers = buffers; bs->buffers = buffers;
bs->expected_benetel_frame = 255; bs->expected_benetel_frame[0] = 255;
bs->expected_benetel_frame[1] = 255;
bs->dpdk_main_command_line = dpdk_main_command_line; bs->dpdk_main_command_line = dpdk_main_command_line;
......
...@@ -45,11 +45,16 @@ void init_buffers(shared_buffers *s) ...@@ -45,11 +45,16 @@ void init_buffers(shared_buffers *s)
* needs to have slots 1, 2 and 3, 4 and 5 ready. Let's pretend * needs to have slots 1, 2 and 3, 4 and 5 ready. Let's pretend
* they are ready. * they are ready.
*/ */
s->dl_busy[1] = 0x3fff; s->dl_busy[0][1] = 0x3fff;
s->dl_busy[2] = 0x3fff; s->dl_busy[0][2] = 0x3fff;
s->dl_busy[3] = 0x3fff; s->dl_busy[0][3] = 0x3fff;
s->dl_busy[4] = 0x3fff; s->dl_busy[0][4] = 0x3fff;
s->dl_busy[5] = 0x3fff; s->dl_busy[0][5] = 0x3fff;
s->dl_busy[1][1] = 0x3fff;
s->dl_busy[1][2] = 0x3fff;
s->dl_busy[1][3] = 0x3fff;
s->dl_busy[1][4] = 0x3fff;
s->dl_busy[1][5] = 0x3fff;
} }
void lock_dl_buffer(shared_buffers *s, int slot) void lock_dl_buffer(shared_buffers *s, int slot)
......
...@@ -26,10 +26,11 @@ ...@@ -26,10 +26,11 @@
#include <stdint.h> #include <stdint.h>
typedef struct { typedef struct {
unsigned char dl[20][14*1272*4]; /* [2] is for two antennas */
unsigned char ul[20][14*1272*4]; unsigned char dl[2][20][14*1272*4];
uint16_t dl_busy[20]; unsigned char ul[2][20][14*1272*4];
uint16_t ul_busy[20]; uint16_t dl_busy[2][20];
uint16_t ul_busy[2][20];
pthread_mutex_t m_ul[20]; pthread_mutex_t m_ul[20];
pthread_cond_t c_ul[20]; pthread_cond_t c_ul[20];
......
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