libmemif: set next free buffer
Adds memif_set_next_free_buffer - set internal pointer to next free descriptor for any tx queue. Type: feature Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: Ia24345a886a52c25c1723c6dbce023f2aed4a42c
This commit is contained in:

committed by
Damjan Marion

parent
18327be5d4
commit
47e68de222
@ -648,6 +648,17 @@ int memif_buffer_alloc (memif_conn_handle_t conn, uint16_t qid,
|
||||
memif_buffer_t * bufs, uint16_t count,
|
||||
uint16_t * count_out, uint16_t size);
|
||||
|
||||
/** \brief Memif set next free buffer
|
||||
@param conn - memif connection handle
|
||||
@param qid - number identifying queue
|
||||
@param buf - next free buffer
|
||||
|
||||
Sets next free descriptor pointer for specified tx queue.
|
||||
The next allocation will happen at this buffer.
|
||||
*/
|
||||
int memif_set_next_free_buffer (memif_conn_handle_t conn, uint16_t qid,
|
||||
memif_buffer_t *buf);
|
||||
|
||||
/** \brief Memif refill queue
|
||||
@param conn - memif connection handle
|
||||
@param qid - number identifying queue
|
||||
|
@ -2151,6 +2151,36 @@ memif_init_regions_and_queues (memif_connection_t * conn)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
memif_set_next_free_buffer (memif_conn_handle_t conn, uint16_t qid,
|
||||
memif_buffer_t *buf)
|
||||
{
|
||||
memif_connection_t *c = (memif_connection_t *) conn;
|
||||
if (EXPECT_FALSE (c == NULL))
|
||||
return MEMIF_ERR_NOCONN;
|
||||
if (EXPECT_FALSE (qid >= c->tx_queues_num))
|
||||
return MEMIF_ERR_QID;
|
||||
if (EXPECT_FALSE (buf == NULL))
|
||||
return MEMIF_ERR_INVAL_ARG;
|
||||
|
||||
uint16_t ring_size, ns;
|
||||
memif_queue_t *mq = &c->tx_queues[qid];
|
||||
memif_ring_t *ring = mq->ring;
|
||||
|
||||
ring_size = (1 << mq->log2_ring_size);
|
||||
if (c->args.is_master)
|
||||
ns = ring->head - mq->next_buf;
|
||||
else
|
||||
ns = ring_size - mq->next_buf + ring->tail;
|
||||
|
||||
if ((mq->next_buf - buf->desc_index) > ns)
|
||||
return MEMIF_ERR_INVAL_ARG;
|
||||
|
||||
mq->next_buf = buf->desc_index;
|
||||
|
||||
return MEMIF_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
memif_buffer_enq_at_idx_internal (memif_queue_t *from_q, memif_queue_t *to_q,
|
||||
memif_buffer_t *buf, uint16_t slot)
|
||||
|
Reference in New Issue
Block a user