reorder: switch sequence number to dynamic mbuf field
The reorder library used sequence numbers stored in the deprecated field seqn. It is moved to a dynamic mbuf field in order to allow removal of seqn. Signed-off-by: David Marchand <david.marchand@redhat.com> Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
This commit is contained in:
parent
fea8ea1883
commit
01f3496695
@ -149,7 +149,7 @@ test_reorder_insert(void)
|
|||||||
for (i = 0; i < num_bufs; i++) {
|
for (i = 0; i < num_bufs; i++) {
|
||||||
bufs[i] = rte_pktmbuf_alloc(p);
|
bufs[i] = rte_pktmbuf_alloc(p);
|
||||||
TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n");
|
TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n");
|
||||||
bufs[i]->seqn = i;
|
*rte_reorder_seqn(bufs[i]) = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This should fill up order buffer:
|
/* This should fill up order buffer:
|
||||||
@ -183,7 +183,7 @@ test_reorder_insert(void)
|
|||||||
bufs[4] = NULL;
|
bufs[4] = NULL;
|
||||||
|
|
||||||
/* early packet from current sequence window - full ready buffer */
|
/* early packet from current sequence window - full ready buffer */
|
||||||
bufs[5]->seqn = 2 * size;
|
*rte_reorder_seqn(bufs[5]) = 2 * size;
|
||||||
ret = rte_reorder_insert(b, bufs[5]);
|
ret = rte_reorder_insert(b, bufs[5]);
|
||||||
if (!((ret == -1) && (rte_errno == ENOSPC))) {
|
if (!((ret == -1) && (rte_errno == ENOSPC))) {
|
||||||
printf("%s:%d: No error inserting early packet with full ready buffer\n",
|
printf("%s:%d: No error inserting early packet with full ready buffer\n",
|
||||||
@ -194,7 +194,7 @@ test_reorder_insert(void)
|
|||||||
bufs[5] = NULL;
|
bufs[5] = NULL;
|
||||||
|
|
||||||
/* late packet */
|
/* late packet */
|
||||||
bufs[6]->seqn = 3 * size;
|
*rte_reorder_seqn(bufs[6]) = 3 * size;
|
||||||
ret = rte_reorder_insert(b, bufs[6]);
|
ret = rte_reorder_insert(b, bufs[6]);
|
||||||
if (!((ret == -1) && (rte_errno == ERANGE))) {
|
if (!((ret == -1) && (rte_errno == ERANGE))) {
|
||||||
printf("%s:%d: No error inserting late packet with seqn:"
|
printf("%s:%d: No error inserting late packet with seqn:"
|
||||||
@ -250,7 +250,7 @@ test_reorder_drain(void)
|
|||||||
for (i = 0; i < num_bufs; i++) {
|
for (i = 0; i < num_bufs; i++) {
|
||||||
bufs[i] = rte_pktmbuf_alloc(p);
|
bufs[i] = rte_pktmbuf_alloc(p);
|
||||||
TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n");
|
TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n");
|
||||||
bufs[i]->seqn = i;
|
*rte_reorder_seqn(bufs[i]) = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert packet with seqn 1:
|
/* Insert packet with seqn 1:
|
||||||
|
@ -451,7 +451,7 @@ rx_thread(struct rte_ring *ring_out)
|
|||||||
|
|
||||||
/* mark sequence number */
|
/* mark sequence number */
|
||||||
for (i = 0; i < nb_rx_pkts; )
|
for (i = 0; i < nb_rx_pkts; )
|
||||||
pkts[i++]->seqn = seqn++;
|
*rte_reorder_seqn(pkts[i++]) = seqn++;
|
||||||
|
|
||||||
/* enqueue to rx_to_workers ring */
|
/* enqueue to rx_to_workers ring */
|
||||||
ret = rte_ring_enqueue_burst(ring_out,
|
ret = rte_ring_enqueue_burst(ring_out,
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <rte_string_fns.h>
|
#include <rte_string_fns.h>
|
||||||
#include <rte_log.h>
|
#include <rte_log.h>
|
||||||
#include <rte_mbuf.h>
|
#include <rte_mbuf.h>
|
||||||
|
#include <rte_mbuf_dyn.h>
|
||||||
#include <rte_eal_memconfig.h>
|
#include <rte_eal_memconfig.h>
|
||||||
#include <rte_errno.h>
|
#include <rte_errno.h>
|
||||||
#include <rte_malloc.h>
|
#include <rte_malloc.h>
|
||||||
@ -29,6 +30,9 @@ EAL_REGISTER_TAILQ(rte_reorder_tailq)
|
|||||||
/* Macros for printing using RTE_LOG */
|
/* Macros for printing using RTE_LOG */
|
||||||
#define RTE_LOGTYPE_REORDER RTE_LOGTYPE_USER1
|
#define RTE_LOGTYPE_REORDER RTE_LOGTYPE_USER1
|
||||||
|
|
||||||
|
#define RTE_REORDER_SEQN_DYNFIELD_NAME "rte_reorder_seqn_dynfield"
|
||||||
|
int rte_reorder_seqn_dynfield_offset = -1;
|
||||||
|
|
||||||
/* A generic circular buffer */
|
/* A generic circular buffer */
|
||||||
struct cir_buffer {
|
struct cir_buffer {
|
||||||
unsigned int size; /**< Number of entries that can be stored */
|
unsigned int size; /**< Number of entries that can be stored */
|
||||||
@ -103,6 +107,11 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
|
|||||||
struct rte_reorder_list *reorder_list;
|
struct rte_reorder_list *reorder_list;
|
||||||
const unsigned int bufsize = sizeof(struct rte_reorder_buffer) +
|
const unsigned int bufsize = sizeof(struct rte_reorder_buffer) +
|
||||||
(2 * size * sizeof(struct rte_mbuf *));
|
(2 * size * sizeof(struct rte_mbuf *));
|
||||||
|
static const struct rte_mbuf_dynfield reorder_seqn_dynfield_desc = {
|
||||||
|
.name = RTE_REORDER_SEQN_DYNFIELD_NAME,
|
||||||
|
.size = sizeof(rte_reorder_seqn_t),
|
||||||
|
.align = __alignof__(rte_reorder_seqn_t),
|
||||||
|
};
|
||||||
|
|
||||||
reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
|
reorder_list = RTE_TAILQ_CAST(rte_reorder_tailq.head, rte_reorder_list);
|
||||||
|
|
||||||
@ -120,6 +129,14 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rte_reorder_seqn_dynfield_offset =
|
||||||
|
rte_mbuf_dynfield_register(&reorder_seqn_dynfield_desc);
|
||||||
|
if (rte_reorder_seqn_dynfield_offset < 0) {
|
||||||
|
RTE_LOG(ERR, REORDER, "Failed to register mbuf field for reorder sequence number\n");
|
||||||
|
rte_errno = ENOMEM;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
rte_mcfg_tailq_write_lock();
|
rte_mcfg_tailq_write_lock();
|
||||||
|
|
||||||
/* guarantee there's no existing */
|
/* guarantee there's no existing */
|
||||||
@ -310,7 +327,7 @@ rte_reorder_insert(struct rte_reorder_buffer *b, struct rte_mbuf *mbuf)
|
|||||||
|
|
||||||
order_buf = &b->order_buf;
|
order_buf = &b->order_buf;
|
||||||
if (!b->is_initialized) {
|
if (!b->is_initialized) {
|
||||||
b->min_seqn = mbuf->seqn;
|
b->min_seqn = *rte_reorder_seqn(mbuf);
|
||||||
b->is_initialized = 1;
|
b->is_initialized = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +339,7 @@ rte_reorder_insert(struct rte_reorder_buffer *b, struct rte_mbuf *mbuf)
|
|||||||
* mbuf_seqn = 0x0010
|
* mbuf_seqn = 0x0010
|
||||||
* offset = 0x0010 - 0xFFFD = 0x13
|
* offset = 0x0010 - 0xFFFD = 0x13
|
||||||
*/
|
*/
|
||||||
offset = mbuf->seqn - b->min_seqn;
|
offset = *rte_reorder_seqn(mbuf) - b->min_seqn;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* action to take depends on offset.
|
* action to take depends on offset.
|
||||||
@ -352,7 +369,7 @@ rte_reorder_insert(struct rte_reorder_buffer *b, struct rte_mbuf *mbuf)
|
|||||||
rte_errno = ENOSPC;
|
rte_errno = ENOSPC;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
offset = mbuf->seqn - b->min_seqn;
|
offset = *rte_reorder_seqn(mbuf) - b->min_seqn;
|
||||||
position = (order_buf->head + offset) & order_buf->mask;
|
position = (order_buf->head + offset) & order_buf->mask;
|
||||||
order_buf->entries[position] = mbuf;
|
order_buf->entries[position] = mbuf;
|
||||||
} else {
|
} else {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <rte_mbuf.h>
|
#include <rte_mbuf.h>
|
||||||
|
#include <rte_mbuf_dyn.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -23,6 +24,26 @@ extern "C" {
|
|||||||
|
|
||||||
struct rte_reorder_buffer;
|
struct rte_reorder_buffer;
|
||||||
|
|
||||||
|
typedef uint32_t rte_reorder_seqn_t;
|
||||||
|
extern int rte_reorder_seqn_dynfield_offset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @warning
|
||||||
|
* @b EXPERIMENTAL: this API may change without prior notice
|
||||||
|
*
|
||||||
|
* Read reorder sequence number from mbuf.
|
||||||
|
*
|
||||||
|
* @param mbuf Structure to read from.
|
||||||
|
* @return pointer to reorder sequence number.
|
||||||
|
*/
|
||||||
|
__rte_experimental
|
||||||
|
static inline rte_reorder_seqn_t *
|
||||||
|
rte_reorder_seqn(struct rte_mbuf *mbuf)
|
||||||
|
{
|
||||||
|
return RTE_MBUF_DYNFIELD(mbuf, rte_reorder_seqn_dynfield_offset,
|
||||||
|
rte_reorder_seqn_t *);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new reorder buffer instance
|
* Create a new reorder buffer instance
|
||||||
*
|
*
|
||||||
|
@ -11,3 +11,9 @@ DPDK_21 {
|
|||||||
|
|
||||||
local: *;
|
local: *;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
EXPERIMENTAL {
|
||||||
|
global:
|
||||||
|
|
||||||
|
rte_reorder_seqn_dynfield_offset;
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user