Commit 6a76a666 authored by Joanne Hugé's avatar Joanne Hugé

wip

parent a4ea2cdd
......@@ -369,8 +369,10 @@ static void *recv_thread(void *p) {
#endif
cpu_set_t mask;
uint8_t * data;
int stop = 0;
struct mmsghdr msgh[MAX_RX_BURST];
struct iovec msgv[MAX_RX_BURST];
uint8_t * data;
TRXEcpriState * s = (TRXEcpriState *) p;
log_info("RECV_THREAD", "Thread init");
......@@ -383,9 +385,6 @@ static void *recv_thread(void *p) {
for(int64_t i = 0;; i++) {
struct mmsghdr msgh[MAX_RX_BURST];
struct iovec msgv[MAX_RX_BURST];
memset(msgv, 0, sizeof(msgv));
memset(msgh, 0, sizeof(msgh));
......@@ -395,21 +394,28 @@ static void *recv_thread(void *p) {
msgh[j].msg_hdr.msg_iov = &msgv[j];
msgh[j].msg_hdr.msg_iovlen = 1;
}
int ret = recvmmsg(recv_sockfd, msgh, s->rx_burst, 0, NULL);
if(ret <= -1)
error(EXIT_FAILURE, errno, "recvmmsg error");
for(int j = 0; j < ret; j++) {
data = rx_buf + j * PACKET_SIZE;
if( ((uint16_t *) data)[6] != 0xaefe)
continue;
else if((msgh + j)->msg_len != PACKET_SIZE)
continue;
if( ((uint16_t *) data)[6] != 0xfeae) {
stop = 1;
log_info("DECODE_THREAD", "%d != %d\n", ((uint16_t *) data)[6], 0xaefe);
break;
}
else if((msgh + j)->msg_len != PACKET_SIZE) {
stop = 1;
log_info("DECODE_THREAD", "Packet doesn't have correct size (%d != %d)", (msgh + j)->msg_len, PACKET_SIZE);
break;
}
int offset = ETHERNET_HEADER + ECPRI_COMMON_HEADER;
uint16_t antenna_id = ntohs(*((uint16_t *) (data + offset + 0)));
uint8_t _seq_id = ((uint8_t) (*((uint16_t * ) (data + offset + 2)) >> 8));
uint8_t _seq_id = data[offset + 2];
if ( (((int) prev_seq_id) - ((int) _seq_id) + 256) % 256 != 1 ) {
if ( ((((int) _seq_id) + 256) - ((int) prev_seq_id)) % 256 != 1 ) {
stop = 1;
log_info("DECODE_THREAD", "seq_ids are not sequential (%d, %d)", prev_seq_id, _seq_id);
break;
......@@ -492,7 +498,8 @@ static void *send_thread(void *p) {
// PC_ID
*((uint16_t *) (data + j + 0)) = htons(antenna_id);
// SEQ_ID
*((uint16_t *) (data + j + 2)) = htons( (((uint16_t) seq_id++) << 8) + 0x80);
data[j + 2] = seq_id++;
data[j + 3] = 0x80;
j = ETHERNET_HEADER + ECPRI_IQ_HEADER;
// ORAN counters
data[j + 1] = frame_id;
......
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