Change-Id: I1dbf91c2a1575d5a82af70bfccdd990310323a8c
Signed-off-by: Jakub Grajciar <Jakub.Grajciar@pantheon.tech>
{
printf ("\t\tqueue id: %u\n", md.rx_queues[e].qid);
printf ("\t\tring size: %u\n", md.rx_queues[e].ring_size);
{
printf ("\t\tqueue id: %u\n", md.rx_queues[e].qid);
printf ("\t\tring size: %u\n", md.rx_queues[e].ring_size);
+ printf ("\t\tring rx mode: %s\n",
+ md.rx_queues[e].flags ? "polling" : "interrupt");
+ printf ("\t\tring head: %u\n", md.rx_queues[e].head);
+ printf ("\t\tring tail: %u\n", md.rx_queues[e].tail);
printf ("\t\tbuffer size: %u\n", md.rx_queues[e].buffer_size);
}
printf ("\ttx queues:\n");
printf ("\t\tbuffer size: %u\n", md.rx_queues[e].buffer_size);
}
printf ("\ttx queues:\n");
{
printf ("\t\tqueue id: %u\n", md.tx_queues[e].qid);
printf ("\t\tring size: %u\n", md.tx_queues[e].ring_size);
{
printf ("\t\tqueue id: %u\n", md.tx_queues[e].qid);
printf ("\t\tring size: %u\n", md.tx_queues[e].ring_size);
+ printf ("\t\tring rx mode: %s\n",
+ md.tx_queues[e].flags ? "polling" : "interrupt");
+ printf ("\t\tring head: %u\n", md.tx_queues[e].head);
+ printf ("\t\tring tail: %u\n", md.tx_queues[e].tail);
printf ("\t\tbuffer size: %u\n", md.tx_queues[e].buffer_size);
}
printf ("\tlink: ");
printf ("\t\tbuffer size: %u\n", md.tx_queues[e].buffer_size);
}
printf ("\tlink: ");
- DBG ("unknown command: %s", ui);
+ INFO ("unknown command: %s", ui);
/** \brief Memif queue details
@param qid - queue id
@param ring_size - size of ring buffer in sharem memory
/** \brief Memif queue details
@param qid - queue id
@param ring_size - size of ring buffer in sharem memory
+ @param flags - ring flags
+ @param head - ring head pointer
+ @param tail - ring tail pointer
@param buffer_size - buffer size on sharem memory
*/
typedef struct
{
uint8_t qid;
uint32_t ring_size;
@param buffer_size - buffer size on sharem memory
*/
typedef struct
{
uint8_t qid;
uint32_t ring_size;
+/** if set queue is in polling mode, else in interrupt mode */
+#define MEMIF_QUEUE_FLAG_POLLING 1
+ uint16_t flags;
+ uint16_t head;
+ uint16_t tail;
- /* add ring information */
} memif_queue_details_t;
/** \brief Memif details
} memif_queue_details_t;
/** \brief Memif details
if (conn == NULL)
return MEMIF_ERR_NOCONN;
uint8_t num =
if (conn == NULL)
return MEMIF_ERR_NOCONN;
uint8_t num =
- (conn->args.is_master) ? conn->run_args.num_s2m_rings : conn->run_args.
- num_m2s_rings;
+ (conn->args.is_master) ? conn->run_args.num_s2m_rings : conn->
+ run_args.num_m2s_rings;
if (qid >= num)
return MEMIF_ERR_QID;
if (qid >= num)
return MEMIF_ERR_QID;
if (((memif_connection_t *) e->data_struct)->on_interrupt != NULL)
{
num =
if (((memif_connection_t *) e->data_struct)->on_interrupt != NULL)
{
num =
- (((memif_connection_t *) e->data_struct)->args.
- is_master) ? ((memif_connection_t *) e->data_struct)->
- run_args.num_s2m_rings : ((memif_connection_t *) e->
- data_struct)->run_args.
- num_m2s_rings;
+ (((memif_connection_t *) e->data_struct)->
+ args.is_master) ? ((memif_connection_t *) e->
+ data_struct)->run_args.
+ num_s2m_rings : ((memif_connection_t *) e->data_struct)->
+ run_args.num_m2s_rings;
for (i = 0; i < num; i++)
{
for (i = 0; i < num; i++)
{
- if (((memif_connection_t *) e->data_struct)->rx_queues[i].
- int_fd == fd)
+ if (((memif_connection_t *) e->data_struct)->
+ rx_queues[i].int_fd == fd)
- ((memif_connection_t *) e->
- data_struct)->on_interrupt ((void *) e->data_struct,
- ((memif_connection_t *)
- e->data_struct)->
- private_ctx, i);
+ ((memif_connection_t *) e->data_struct)->
+ on_interrupt ((void *) e->data_struct,
+ ((memif_connection_t *) e->
+ data_struct)->private_ctx, i);
return MEMIF_ERR_SUCCESS;
}
}
return MEMIF_ERR_SUCCESS;
}
}
if (events & MEMIF_FD_EVENT_READ)
{
err =
if (events & MEMIF_FD_EVENT_READ)
{
err =
- ((memif_connection_t *) e->data_struct)->read_fn (e->
- data_struct);
+ ((memif_connection_t *) e->data_struct)->
+ read_fn (e->data_struct);
if (err != MEMIF_ERR_SUCCESS)
return err;
}
if (events & MEMIF_FD_EVENT_WRITE)
{
err =
if (err != MEMIF_ERR_SUCCESS)
return err;
}
if (events & MEMIF_FD_EVENT_WRITE)
{
err =
- ((memif_connection_t *) e->data_struct)->write_fn (e->
- data_struct);
+ ((memif_connection_t *) e->data_struct)->
+ write_fn (e->data_struct);
if (err != MEMIF_ERR_SUCCESS)
return err;
}
if (events & MEMIF_FD_EVENT_ERROR)
{
err =
if (err != MEMIF_ERR_SUCCESS)
return err;
}
if (events & MEMIF_FD_EVENT_ERROR)
{
err =
- ((memif_connection_t *) e->data_struct)->error_fn (e->
- data_struct);
+ ((memif_connection_t *) e->data_struct)->
+ error_fn (e->data_struct);
if (err != MEMIF_ERR_SUCCESS)
return err;
}
if (err != MEMIF_ERR_SUCCESS)
return err;
}
if (c->tx_queues != NULL)
{
num =
if (c->tx_queues != NULL)
{
num =
- (c->args.is_master) ? c->run_args.num_m2s_rings : c->run_args.
- num_s2m_rings;
+ (c->args.is_master) ? c->run_args.num_m2s_rings : c->
+ run_args.num_s2m_rings;
for (i = 0; i < num; i++)
{
mq = &c->tx_queues[i];
for (i = 0; i < num; i++)
{
mq = &c->tx_queues[i];
if (c->rx_queues != NULL)
{
num =
if (c->rx_queues != NULL)
{
num =
- (c->args.is_master) ? c->run_args.num_s2m_rings : c->run_args.
- num_m2s_rings;
+ (c->args.is_master) ? c->run_args.num_s2m_rings : c->
+ run_args.num_m2s_rings;
for (i = 0; i < num; i++)
{
mq = &c->rx_queues[i];
for (i = 0; i < num; i++)
{
mq = &c->rx_queues[i];
- (c->args.is_master) ? c->run_args.num_m2s_rings : c->run_args.
- num_s2m_rings;
+ (c->args.is_master) ? c->run_args.num_m2s_rings : c->
+ run_args.num_s2m_rings;
for (i = 0; i < num; i++)
{
mq = &c->tx_queues[i];
for (i = 0; i < num; i++)
{
mq = &c->tx_queues[i];
- (c->args.is_master) ? c->run_args.num_s2m_rings : c->run_args.
- num_m2s_rings;
+ (c->args.is_master) ? c->run_args.num_s2m_rings : c->
+ run_args.num_m2s_rings;
for (i = 0; i < num; i++)
{
mq = &c->rx_queues[i];
for (i = 0; i < num; i++)
{
mq = &c->rx_queues[i];
if (c->fd < 0)
return MEMIF_ERR_DISCONNECTED;
uint8_t num =
if (c->fd < 0)
return MEMIF_ERR_DISCONNECTED;
uint8_t num =
- (c->args.is_master) ? c->run_args.num_m2s_rings : c->run_args.
- num_s2m_rings;
+ (c->args.is_master) ? c->run_args.num_m2s_rings : c->
+ run_args.num_s2m_rings;
if (qid >= num)
return MEMIF_ERR_QID;
memif_queue_t *mq = &c->tx_queues[qid];
if (qid >= num)
return MEMIF_ERR_QID;
memif_queue_t *mq = &c->tx_queues[qid];
/* calculate number of chain buffers */
if (size > ring->desc[0].buffer_length)
{
/* calculate number of chain buffers */
if (size > ring->desc[0].buffer_length)
{
- chain_buf = size / ring->desc[s0].buffer_length;
- if (((size % ring->desc[s0].buffer_length) != 0) || (size == 0))
+ chain_buf = size / ring->desc[0].buffer_length;
+ if (((size % ring->desc[0].buffer_length) != 0) || (size == 0))
if (c->fd < 0)
return MEMIF_ERR_DISCONNECTED;
uint8_t num =
if (c->fd < 0)
return MEMIF_ERR_DISCONNECTED;
uint8_t num =
- (c->args.is_master) ? c->run_args.num_s2m_rings : c->run_args.
- num_m2s_rings;
+ (c->args.is_master) ? c->run_args.num_s2m_rings : c->
+ run_args.num_m2s_rings;
if (qid >= num)
return MEMIF_ERR_QID;
libmemif_main_t *lm = &libmemif_main;
if (qid >= num)
return MEMIF_ERR_QID;
libmemif_main_t *lm = &libmemif_main;
b0 = (bufs + *count_out);
b1 = (bufs + *count_out + 1);
chain_buf0 =
b0 = (bufs + *count_out);
b1 = (bufs + *count_out + 1);
chain_buf0 =
- b0->buffer_len / ring->desc[b0->desc_index].buffer_length;
- if ((b0->buffer_len % ring->desc[b0->desc_index].buffer_length) !=
- 0)
+ b0->buffer_len / ring->desc[b0->desc_index & mask].buffer_length;
+ if ((b0->buffer_len %
+ ring->desc[b0->desc_index & mask].buffer_length) != 0)
chain_buf0++;
chain_buf1 =
chain_buf0++;
chain_buf1 =
- b1->buffer_len / ring->desc[b1->desc_index].buffer_length;
- if ((b1->buffer_len % ring->desc[b1->desc_index].buffer_length) !=
- 0)
+ b1->buffer_len / ring->desc[b1->desc_index & mask].buffer_length;
+ if ((b1->buffer_len %
+ ring->desc[b1->desc_index & mask].buffer_length) != 0)
chain_buf1++;
tail = b1->desc_index + chain_buf1;
b0->data = NULL;
chain_buf1++;
tail = b1->desc_index + chain_buf1;
b0->data = NULL;
mq->alloc_bufs -= chain_buf0 + chain_buf1;
}
b0 = (bufs + *count_out);
mq->alloc_bufs -= chain_buf0 + chain_buf1;
}
b0 = (bufs + *count_out);
- chain_buf0 = b0->buffer_len / ring->desc[b0->desc_index].buffer_length;
- if ((b0->buffer_len % ring->desc[b0->desc_index].buffer_length) != 0)
+ chain_buf0 =
+ b0->buffer_len / ring->desc[b0->desc_index & mask].buffer_length;
+ if ((b0->buffer_len %
+ ring->desc[b0->desc_index & mask].buffer_length) != 0)
chain_buf0++;
tail = b0->desc_index + chain_buf0;
b0->data = NULL;
chain_buf0++;
tail = b0->desc_index + chain_buf0;
b0->data = NULL;
if (c->fd < 0)
return MEMIF_ERR_DISCONNECTED;
uint8_t num =
if (c->fd < 0)
return MEMIF_ERR_DISCONNECTED;
uint8_t num =
- (c->args.is_master) ? c->run_args.num_m2s_rings : c->run_args.
- num_s2m_rings;
+ (c->args.is_master) ? c->run_args.num_m2s_rings : c->
+ run_args.num_s2m_rings;
if (qid >= num)
return MEMIF_ERR_QID;
memif_queue_t *mq = &c->tx_queues[qid];
if (qid >= num)
return MEMIF_ERR_QID;
memif_queue_t *mq = &c->tx_queues[qid];
b0 = (bufs + curr_buf);
b1 = (bufs + curr_buf + 1);
chain_buf0 =
b0 = (bufs + curr_buf);
b1 = (bufs + curr_buf + 1);
chain_buf0 =
- b0->buffer_len / ring->desc[b0->desc_index].buffer_length;
- if ((b0->buffer_len % ring->desc[b0->desc_index].buffer_length) !=
- 0)
+ b0->buffer_len / ring->desc[b0->desc_index & mask].buffer_length;
+ if ((b0->buffer_len %
+ ring->desc[b0->desc_index & mask].buffer_length) != 0)
chain_buf0++;
chain_buf1 =
chain_buf0++;
chain_buf1 =
- b1->buffer_len / ring->desc[b1->desc_index].buffer_length;
- if ((b1->buffer_len % ring->desc[b1->desc_index].buffer_length) !=
- 0)
+ b1->buffer_len / ring->desc[b1->desc_index & mask].buffer_length;
+ if ((b1->buffer_len %
+ ring->desc[b1->desc_index & mask].buffer_length) != 0)
chain_buf1++;
for (i = 0; i < memif_min (chain_buf0, chain_buf1); i++)
chain_buf1++;
for (i = 0; i < memif_min (chain_buf0, chain_buf1); i++)
- head = (b1->desc_index + chain_buf1) & mask;
+ head = b1->desc_index + chain_buf1;
b0->data = NULL;
#ifdef MEMIF_DBG
b0->data = NULL;
#ifdef MEMIF_DBG
}
b0 = (bufs + curr_buf);
}
b0 = (bufs + curr_buf);
- chain_buf0 = b0->buffer_len / ring->desc[b0->desc_index].buffer_length;
- if ((b0->buffer_len % ring->desc[b0->desc_index].buffer_length) != 0)
+ chain_buf0 =
+ b0->buffer_len / ring->desc[b0->desc_index & mask].buffer_length;
+ if ((b0->buffer_len %
+ ring->desc[b0->desc_index & mask].buffer_length) != 0)
chain_buf0++;
for (i = 0; i < chain_buf0; i++)
chain_buf0++;
for (i = 0; i < chain_buf0; i++)
#endif /* MEMIF_DBG_SHM */
}
#endif /* MEMIF_DBG_SHM */
}
- head = (b0->desc_index + chain_buf0) & mask;
+ head = b0->desc_index + chain_buf0;
b0->data = NULL;
#ifdef MEMIF_DBG
b0->data = NULL;
#ifdef MEMIF_DBG
if (c->fd < 0)
return MEMIF_ERR_DISCONNECTED;
uint8_t num =
if (c->fd < 0)
return MEMIF_ERR_DISCONNECTED;
uint8_t num =
- (c->args.is_master) ? c->run_args.num_s2m_rings : c->run_args.
- num_m2s_rings;
+ (c->args.is_master) ? c->run_args.num_s2m_rings : c->
+ run_args.num_m2s_rings;
if (qid >= num)
return MEMIF_ERR_QID;
memif_queue_t *mq = &c->rx_queues[qid];
if (qid >= num)
return MEMIF_ERR_QID;
memif_queue_t *mq = &c->rx_queues[qid];
i = 0;
print_bytes (b0->data +
ring->desc[b0->desc_index & mask].buffer_length * i++,
i = 0;
print_bytes (b0->data +
ring->desc[b0->desc_index & mask].buffer_length * i++,
- ring->desc[b0->desc_index & mask].buffer_length, DBG_TX_BUF);
+ ring->desc[b0->desc_index & mask].buffer_length,
+ DBG_TX_BUF);
#endif /* MEMIF_DBG_SHM */
ns--;
*rx += 1;
#endif /* MEMIF_DBG_SHM */
ns--;
*rx += 1;
- while (ring->desc[mq->last_head & mask].flags & MEMIF_DESC_FLAG_NEXT)
+ while (ring->desc[mq->last_head & mask].
+ flags & MEMIF_DESC_FLAG_NEXT)
{
ring->desc[mq->last_head & mask].flags &= ~MEMIF_DESC_FLAG_NEXT;
mq->last_head++;
b0->data_len += ring->desc[mq->last_head & mask].length;
{
ring->desc[mq->last_head & mask].flags &= ~MEMIF_DESC_FLAG_NEXT;
mq->last_head++;
b0->data_len += ring->desc[mq->last_head & mask].length;
- b0->buffer_len += ring->desc[mq->last_head & mask].buffer_length;
+ b0->buffer_len +=
+ ring->desc[mq->last_head & mask].buffer_length;
#ifdef MEMIF_DBG_SHM
print_bytes (b0->data +
#ifdef MEMIF_DBG_SHM
print_bytes (b0->data +
- ring->desc[b0->desc_index & mask].buffer_length * i++,
+ ring->desc[b0->desc_index & mask].buffer_length *
+ i++,
ring->desc[b0->desc_index & mask].buffer_length,
DBG_TX_BUF);
#endif /* MEMIF_DBG_SHM */
ring->desc[b0->desc_index & mask].buffer_length,
DBG_TX_BUF);
#endif /* MEMIF_DBG_SHM */
i = 0;
print_bytes (b1->data +
ring->desc[b1->desc_index & mask].buffer_length * i++,
i = 0;
print_bytes (b1->data +
ring->desc[b1->desc_index & mask].buffer_length * i++,
- ring->desc[b1->desc_index & mask].buffer_length, DBG_TX_BUF);
+ ring->desc[b1->desc_index & mask].buffer_length,
+ DBG_TX_BUF);
#endif /* MEMIF_DBG_SHM */
ns--;
*rx += 1;
#endif /* MEMIF_DBG_SHM */
ns--;
*rx += 1;
- while (ring->desc[mq->last_head & mask].flags & MEMIF_DESC_FLAG_NEXT)
+ while (ring->desc[mq->last_head & mask].
+ flags & MEMIF_DESC_FLAG_NEXT)
{
ring->desc[mq->last_head & mask].flags &= ~MEMIF_DESC_FLAG_NEXT;
mq->last_head++;
b1->data_len += ring->desc[mq->last_head & mask].length;
{
ring->desc[mq->last_head & mask].flags &= ~MEMIF_DESC_FLAG_NEXT;
mq->last_head++;
b1->data_len += ring->desc[mq->last_head & mask].length;
- b1->buffer_len += ring->desc[mq->last_head & mask].buffer_length;
+ b1->buffer_len +=
+ ring->desc[mq->last_head & mask].buffer_length;
#ifdef MEMIF_DBG_SHM
print_bytes (b1->data +
#ifdef MEMIF_DBG_SHM
print_bytes (b1->data +
- ring->desc[b1->desc_index & mask].buffer_length * i++,
+ ring->desc[b1->desc_index & mask].buffer_length *
+ i++,
ring->desc[b1->desc_index & mask].buffer_length,
DBG_TX_BUF);
#endif /* MEMIF_DBG_SHM */
ring->desc[b1->desc_index & mask].buffer_length,
DBG_TX_BUF);
#endif /* MEMIF_DBG_SHM */
b0->data_len = ring->desc[mq->last_head & mask].length;
b0->buffer_len = ring->desc[mq->last_head & mask].buffer_length;
#ifdef MEMIF_DBG_SHM
b0->data_len = ring->desc[mq->last_head & mask].length;
b0->buffer_len = ring->desc[mq->last_head & mask].buffer_length;
#ifdef MEMIF_DBG_SHM
print_bytes (b0->data +
ring->desc[b0->desc_index & mask].buffer_length * i++,
print_bytes (b0->data +
ring->desc[b0->desc_index & mask].buffer_length * i++,
- ring->desc[b0->desc_index & mask].buffer_length, DBG_TX_BUF);
+ ring->desc[b0->desc_index & mask].buffer_length,
+ DBG_TX_BUF);
#endif /* MEMIF_DBG_SHM */
ns--;
*rx += 1;
#endif /* MEMIF_DBG_SHM */
ns--;
*rx += 1;
#ifdef MEMIF_DBG_SHM
print_bytes (b0->data +
ring->desc[b0->desc_index & mask].buffer_length * i++,
#ifdef MEMIF_DBG_SHM
print_bytes (b0->data +
ring->desc[b0->desc_index & mask].buffer_length * i++,
- ring->desc[b0->desc_index & mask].buffer_length, DBG_TX_BUF);
+ ring->desc[b0->desc_index & mask].buffer_length,
+ DBG_TX_BUF);
#endif /* MEMIF_DBG_SHM */
ns--;
*rx += 1;
#endif /* MEMIF_DBG_SHM */
ns--;
*rx += 1;
err = MEMIF_ERR_NOBUF_DET;
md->rx_queues_num =
err = MEMIF_ERR_NOBUF_DET;
md->rx_queues_num =
- (c->args.is_master) ? c->run_args.num_s2m_rings : c->run_args.
- num_m2s_rings;
+ (c->args.is_master) ? c->run_args.num_s2m_rings : c->
+ run_args.num_m2s_rings;
l1 = sizeof (memif_queue_details_t) * md->rx_queues_num;
if (l0 + l1 <= buflen)
l1 = sizeof (memif_queue_details_t) * md->rx_queues_num;
if (l0 + l1 <= buflen)
{
md->rx_queues[i].qid = i;
md->rx_queues[i].ring_size = (1 << c->rx_queues[i].log2_ring_size);
{
md->rx_queues[i].qid = i;
md->rx_queues[i].ring_size = (1 << c->rx_queues[i].log2_ring_size);
+ md->rx_queues[i].flags = c->rx_queues[i].ring->flags;
+ md->rx_queues[i].head = c->rx_queues[i].ring->head;
+ md->rx_queues[i].tail = c->rx_queues[i].ring->tail;
md->rx_queues[i].buffer_size = c->run_args.buffer_size;
}
md->tx_queues_num =
md->rx_queues[i].buffer_size = c->run_args.buffer_size;
}
md->tx_queues_num =
- (c->args.is_master) ? c->run_args.num_m2s_rings : c->run_args.
- num_s2m_rings;
+ (c->args.is_master) ? c->run_args.num_m2s_rings : c->
+ run_args.num_s2m_rings;
l1 = sizeof (memif_queue_details_t) * md->tx_queues_num;
if (l0 + l1 <= buflen)
l1 = sizeof (memif_queue_details_t) * md->tx_queues_num;
if (l0 + l1 <= buflen)
{
md->tx_queues[i].qid = i;
md->tx_queues[i].ring_size = (1 << c->tx_queues[i].log2_ring_size);
{
md->tx_queues[i].qid = i;
md->tx_queues[i].ring_size = (1 << c->tx_queues[i].log2_ring_size);
+ md->tx_queues[i].flags = c->tx_queues[i].ring->flags;
+ md->tx_queues[i].head = c->tx_queues[i].ring->head;
+ md->tx_queues[i].tail = c->tx_queues[i].ring->tail;
md->tx_queues[i].buffer_size = c->run_args.buffer_size;
}
md->tx_queues[i].buffer_size = c->run_args.buffer_size;
}
if (c->fd < 0)
return MEMIF_ERR_DISCONNECTED;
uint8_t num =
if (c->fd < 0)
return MEMIF_ERR_DISCONNECTED;
uint8_t num =
- (c->args.is_master) ? c->run_args.num_s2m_rings : c->run_args.
- num_m2s_rings;
+ (c->args.is_master) ? c->run_args.num_s2m_rings : c->
+ run_args.num_m2s_rings;
if (qid >= num)
return MEMIF_ERR_QID;
if (qid >= num)
return MEMIF_ERR_QID;