1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
5 #ifndef _RTE_REORDER_H_
6 #define _RTE_REORDER_H_
12 * Reorder library is a component which is designed to
13 * provide ordering of out of ordered packets based on
14 * sequence number present in mbuf.
24 struct rte_reorder_buffer;
27 * Create a new reorder buffer instance
29 * Allocate memory and initialize a new reorder buffer in that
30 * memory, returning the reorder buffer pointer to the user
33 * The name to be given to the reorder buffer instance.
35 * The NUMA node on which the memory for the reorder buffer
36 * instance is to be reserved.
38 * Max number of elements that can be stored in the reorder buffer
40 * The initialized reorder buffer instance, or NULL on error
41 * On error case, rte_errno will be set appropriately:
42 * - ENOMEM - no appropriate memory area found in which to create memzone
43 * - EINVAL - invalid parameters
45 struct rte_reorder_buffer *
46 rte_reorder_create(const char *name, unsigned socket_id, unsigned int size);
49 * Initializes given reorder buffer instance
52 * Reorder buffer instance to initialize
54 * Size of the reorder buffer
56 * The name to be given to the reorder buffer
58 * Number of elements that can be stored in reorder buffer
60 * The initialized reorder buffer instance, or NULL on error
61 * On error case, rte_errno will be set appropriately:
62 * - EINVAL - invalid parameters
64 struct rte_reorder_buffer *
65 rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize,
66 const char *name, unsigned int size);
69 * Find an existing reorder buffer instance
70 * and return a pointer to it.
73 * Name of the reorder buffer instacne as passed to rte_reorder_create()
75 * Pointer to reorder buffer instance or NULL if object not found with rte_errno
76 * set appropriately. Possible rte_errno values include:
77 * - ENOENT - required entry not available to return.
78 * reorder instance list
80 struct rte_reorder_buffer *
81 rte_reorder_find_existing(const char *name);
84 * Reset the given reorder buffer instance with initial values.
87 * Reorder buffer instance which has to be reset
90 rte_reorder_reset(struct rte_reorder_buffer *b);
93 * Free reorder buffer instance.
96 * reorder buffer instance
101 rte_reorder_free(struct rte_reorder_buffer *b);
104 * Insert given mbuf in reorder buffer in its correct position
106 * The given mbuf is to be reordered relative to other mbufs in the system.
107 * The mbuf must contain a sequence number which is then used to place
108 * the buffer in the correct position in the reorder buffer. Reordered
109 * packets can later be taken from the buffer using the rte_reorder_drain()
113 * Reorder buffer where the mbuf has to be inserted.
115 * mbuf of packet that needs to be inserted in reorder buffer.
119 * On error case, rte_errno will be set appropriately:
120 * - ENOSPC - Cannot move existing mbufs from reorder buffer to accommodate
121 * early mbuf, but it can be accommodated by performing drain and then insert.
122 * - ERANGE - Too early or late mbuf which is vastly out of range of expected
123 * window should be ignored without any handling.
126 rte_reorder_insert(struct rte_reorder_buffer *b, struct rte_mbuf *mbuf);
129 * Fetch reordered buffers
131 * Returns a set of in-order buffers from the reorder buffer structure. Gaps
132 * may be present in the sequence numbers of the mbuf if packets have been
133 * delayed too long before reaching the reorder window, or have been previously
134 * dropped by the system.
137 * Reorder buffer instance from which packets are to be drained
139 * array of mbufs where reordered packets will be inserted from reorder buffer
141 * the number of elements in the mbufs array.
143 * number of mbuf pointers written to mbufs. 0 <= N < max_mbufs.
146 rte_reorder_drain(struct rte_reorder_buffer *b, struct rte_mbuf **mbufs,
153 #endif /* _RTE_REORDER_H_ */