4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef _RTE_REORDER_H_
35 #define _RTE_REORDER_H_
41 * Reorder library is a component which is designed to
42 * provide ordering of out of ordered packets based on
43 * sequence number present in mbuf.
51 struct rte_reorder_buffer;
54 * Create a new reorder buffer instance
56 * Allocate memory and initialize a new reorder buffer in that
57 * memory, returning the reorder buffer pointer to the user
60 * The name to be given to the reorder buffer instance.
62 * The NUMA node on which the memory for the reorder buffer
63 * instance is to be reserved.
65 * Max number of elements that can be stored in the reorder buffer
67 * The initialized reorder buffer instance, or NULL on error
68 * On error case, rte_errno will be set appropriately:
69 * - ENOMEM - no appropriate memory area found in which to create memzone
70 * - EINVAL - invalid parameters
72 struct rte_reorder_buffer *
73 rte_reorder_create(const char *name, unsigned socket_id, unsigned int size);
76 * Initializes given reorder buffer instance
79 * Reorder buffer instance to initialize
81 * Size of the reorder buffer
83 * The name to be given to the reorder buffer
85 * Number of elements that can be stored in reorder buffer
87 * The initialized reorder buffer instance, or NULL on error
88 * On error case, rte_errno will be set appropriately:
89 * - EINVAL - invalid parameters
91 struct rte_reorder_buffer *
92 rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize,
93 const char *name, unsigned int size);
96 * Find an existing reorder buffer instance
97 * and return a pointer to it.
100 * Name of the reorder buffer instacne as passed to rte_reorder_create()
102 * Pointer to reorder buffer instance or NULL if object not found with rte_errno
103 * set appropriately. Possible rte_errno values include:
104 * - ENOENT - required entry not available to return.
105 * - E_RTE_NO_TAILQ - no tailq list could be got for the
106 * reorder instance list
108 struct rte_reorder_buffer *
109 rte_reorder_find_existing(const char *name);
112 * Reset the given reorder buffer instance with initial values.
115 * Reorder buffer instance which has to be reset
118 rte_reorder_reset(struct rte_reorder_buffer *b);
121 * Free reorder buffer instance.
124 * reorder buffer instance
129 rte_reorder_free(struct rte_reorder_buffer *b);
132 * Insert given mbuf in reorder buffer in its correct position
134 * The given mbuf is to be reordered relative to other mbufs in the system.
135 * The mbuf must contain a sequence number which is then used to place
136 * the buffer in the correct position in the reorder buffer. Reordered
137 * packets can later be taken from the buffer using the rte_reorder_drain()
141 * Reorder buffer where the mbuf has to be inserted.
143 * mbuf of packet that needs to be inserted in reorder buffer.
147 * On error case, rte_errno will be set appropriately:
148 * - ENOSPC - Cannot move existing mbufs from reorder buffer to accommodate
149 * ealry mbuf, but it can be accomodated by performing drain and then insert.
150 * - ERANGE - Too early or late mbuf which is vastly out of range of expected
151 * window should be ingnored without any handling.
154 rte_reorder_insert(struct rte_reorder_buffer *b, struct rte_mbuf *mbuf);
157 * Fetch reordered buffers
159 * Returns a set of in-order buffers from the reorder buffer structure. Gaps
160 * may be present in the sequence numbers of the mbuf if packets have been
161 * delayed too long before reaching the reorder window, or have been previously
162 * dropped by the system.
165 * Reorder buffer instance from which packets are to be drained
167 * array of mbufs where reordered packets will be inserted from reorder buffer
169 * the number of elements in the mbufs array.
171 * number of mbuf pointers written to mbufs. 0 <= N < max_mbufs.
174 rte_reorder_drain(struct rte_reorder_buffer *b, struct rte_mbuf **mbufs,
181 #endif /* _RTE_REORDER_H_ */