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.
53 struct rte_reorder_buffer;
56 * Create a new reorder buffer instance
58 * Allocate memory and initialize a new reorder buffer in that
59 * memory, returning the reorder buffer pointer to the user
62 * The name to be given to the reorder buffer instance.
64 * The NUMA node on which the memory for the reorder buffer
65 * instance is to be reserved.
67 * Max number of elements that can be stored in the reorder buffer
69 * The initialized reorder buffer instance, or NULL on error
70 * On error case, rte_errno will be set appropriately:
71 * - ENOMEM - no appropriate memory area found in which to create memzone
72 * - EINVAL - invalid parameters
74 struct rte_reorder_buffer *
75 rte_reorder_create(const char *name, unsigned socket_id, unsigned int size);
78 * Initializes given reorder buffer instance
81 * Reorder buffer instance to initialize
83 * Size of the reorder buffer
85 * The name to be given to the reorder buffer
87 * Number of elements that can be stored in reorder buffer
89 * The initialized reorder buffer instance, or NULL on error
90 * On error case, rte_errno will be set appropriately:
91 * - EINVAL - invalid parameters
93 struct rte_reorder_buffer *
94 rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize,
95 const char *name, unsigned int size);
98 * Find an existing reorder buffer instance
99 * and return a pointer to it.
102 * Name of the reorder buffer instacne as passed to rte_reorder_create()
104 * Pointer to reorder buffer instance or NULL if object not found with rte_errno
105 * set appropriately. Possible rte_errno values include:
106 * - ENOENT - required entry not available to return.
107 * reorder instance list
109 struct rte_reorder_buffer *
110 rte_reorder_find_existing(const char *name);
113 * Reset the given reorder buffer instance with initial values.
116 * Reorder buffer instance which has to be reset
119 rte_reorder_reset(struct rte_reorder_buffer *b);
122 * Free reorder buffer instance.
125 * reorder buffer instance
130 rte_reorder_free(struct rte_reorder_buffer *b);
133 * Insert given mbuf in reorder buffer in its correct position
135 * The given mbuf is to be reordered relative to other mbufs in the system.
136 * The mbuf must contain a sequence number which is then used to place
137 * the buffer in the correct position in the reorder buffer. Reordered
138 * packets can later be taken from the buffer using the rte_reorder_drain()
142 * Reorder buffer where the mbuf has to be inserted.
144 * mbuf of packet that needs to be inserted in reorder buffer.
148 * On error case, rte_errno will be set appropriately:
149 * - ENOSPC - Cannot move existing mbufs from reorder buffer to accommodate
150 * ealry mbuf, but it can be accomodated by performing drain and then insert.
151 * - ERANGE - Too early or late mbuf which is vastly out of range of expected
152 * window should be ingnored without any handling.
155 rte_reorder_insert(struct rte_reorder_buffer *b, struct rte_mbuf *mbuf);
158 * Fetch reordered buffers
160 * Returns a set of in-order buffers from the reorder buffer structure. Gaps
161 * may be present in the sequence numbers of the mbuf if packets have been
162 * delayed too long before reaching the reorder window, or have been previously
163 * dropped by the system.
166 * Reorder buffer instance from which packets are to be drained
168 * array of mbufs where reordered packets will be inserted from reorder buffer
170 * the number of elements in the mbufs array.
172 * number of mbuf pointers written to mbufs. 0 <= N < max_mbufs.
175 rte_reorder_drain(struct rte_reorder_buffer *b, struct rte_mbuf **mbufs,
182 #endif /* _RTE_REORDER_H_ */