]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/dpdk/lib/librte_reorder/rte_reorder.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / dpdk / lib / librte_reorder / rte_reorder.h
CommitLineData
11fdf7f2
TL
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
7c673cae
FG
3 */
4
5#ifndef _RTE_REORDER_H_
6#define _RTE_REORDER_H_
7
8/**
9 * @file
10 * RTE reorder
11 *
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.
15 *
16 */
17
18#include <rte_mbuf.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24struct rte_reorder_buffer;
25
26/**
27 * Create a new reorder buffer instance
28 *
29 * Allocate memory and initialize a new reorder buffer in that
30 * memory, returning the reorder buffer pointer to the user
31 *
32 * @param name
33 * The name to be given to the reorder buffer instance.
34 * @param socket_id
35 * The NUMA node on which the memory for the reorder buffer
36 * instance is to be reserved.
37 * @param size
38 * Max number of elements that can be stored in the reorder buffer
39 * @return
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
44 */
45struct rte_reorder_buffer *
46rte_reorder_create(const char *name, unsigned socket_id, unsigned int size);
47
48/**
49 * Initializes given reorder buffer instance
50 *
51 * @param b
52 * Reorder buffer instance to initialize
53 * @param bufsize
54 * Size of the reorder buffer
55 * @param name
56 * The name to be given to the reorder buffer
57 * @param size
58 * Number of elements that can be stored in reorder buffer
59 * @return
60 * The initialized reorder buffer instance, or NULL on error
61 * On error case, rte_errno will be set appropriately:
62 * - EINVAL - invalid parameters
63 */
64struct rte_reorder_buffer *
65rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize,
66 const char *name, unsigned int size);
67
68/**
69 * Find an existing reorder buffer instance
70 * and return a pointer to it.
71 *
72 * @param name
9f95a23c 73 * Name of the reorder buffer instance as passed to rte_reorder_create()
7c673cae
FG
74 * @return
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
79 */
80struct rte_reorder_buffer *
81rte_reorder_find_existing(const char *name);
82
83/**
84 * Reset the given reorder buffer instance with initial values.
85 *
86 * @param b
87 * Reorder buffer instance which has to be reset
88 */
89void
90rte_reorder_reset(struct rte_reorder_buffer *b);
91
92/**
93 * Free reorder buffer instance.
94 *
95 * @param b
96 * reorder buffer instance
97 * @return
98 * None
99 */
100void
101rte_reorder_free(struct rte_reorder_buffer *b);
102
103/**
104 * Insert given mbuf in reorder buffer in its correct position
105 *
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()
110 * API.
111 *
112 * @param b
113 * Reorder buffer where the mbuf has to be inserted.
114 * @param mbuf
115 * mbuf of packet that needs to be inserted in reorder buffer.
116 * @return
117 * 0 on success
118 * -1 on error
119 * On error case, rte_errno will be set appropriately:
120 * - ENOSPC - Cannot move existing mbufs from reorder buffer to accommodate
11fdf7f2 121 * early mbuf, but it can be accommodated by performing drain and then insert.
7c673cae 122 * - ERANGE - Too early or late mbuf which is vastly out of range of expected
11fdf7f2 123 * window should be ignored without any handling.
7c673cae
FG
124 */
125int
126rte_reorder_insert(struct rte_reorder_buffer *b, struct rte_mbuf *mbuf);
127
128/**
129 * Fetch reordered buffers
130 *
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.
135 *
136 * @param b
137 * Reorder buffer instance from which packets are to be drained
138 * @param mbufs
139 * array of mbufs where reordered packets will be inserted from reorder buffer
140 * @param max_mbufs
141 * the number of elements in the mbufs array.
142 * @return
143 * number of mbuf pointers written to mbufs. 0 <= N < max_mbufs.
144 */
145unsigned int
146rte_reorder_drain(struct rte_reorder_buffer *b, struct rte_mbuf **mbufs,
147 unsigned max_mbufs);
148
149#ifdef __cplusplus
150}
151#endif
152
153#endif /* _RTE_REORDER_H_ */