1*2d9fd380Sjfb8856606 /* SPDX-License-Identifier: BSD-3-Clause
2*2d9fd380Sjfb8856606  * Copyright(C) 2019 Marvell International Ltd.
3*2d9fd380Sjfb8856606  * Copyright 2020 Mellanox Technologies, Ltd
4*2d9fd380Sjfb8856606  * Copyright(c) 2020 Intel Corporation
5*2d9fd380Sjfb8856606  */
6*2d9fd380Sjfb8856606 
7*2d9fd380Sjfb8856606 #ifndef _RTE_REGEXDEV_H_
8*2d9fd380Sjfb8856606 #define _RTE_REGEXDEV_H_
9*2d9fd380Sjfb8856606 
10*2d9fd380Sjfb8856606 /**
11*2d9fd380Sjfb8856606  * @file
12*2d9fd380Sjfb8856606  *
13*2d9fd380Sjfb8856606  * RTE RegEx Device API
14*2d9fd380Sjfb8856606  *
15*2d9fd380Sjfb8856606  * Defines RTE RegEx Device APIs for RegEx operations and its provisioning.
16*2d9fd380Sjfb8856606  *
17*2d9fd380Sjfb8856606  * The RegEx Device API is composed of two parts:
18*2d9fd380Sjfb8856606  *
19*2d9fd380Sjfb8856606  * - The application-oriented RegEx API that includes functions to setup
20*2d9fd380Sjfb8856606  *   a RegEx device (configure it, setup its queue pairs and start it),
21*2d9fd380Sjfb8856606  *   update the rule database and so on.
22*2d9fd380Sjfb8856606  *
23*2d9fd380Sjfb8856606  * - The driver-oriented RegEx API that exports a function allowing
24*2d9fd380Sjfb8856606  *   a RegEx poll Mode Driver (PMD) to simultaneously register itself as
25*2d9fd380Sjfb8856606  *   a RegEx device driver.
26*2d9fd380Sjfb8856606  *
27*2d9fd380Sjfb8856606  * RegEx device components and definitions:
28*2d9fd380Sjfb8856606  *
29*2d9fd380Sjfb8856606  *     +-----------------+
30*2d9fd380Sjfb8856606  *     |                 |
31*2d9fd380Sjfb8856606  *     |                 o---------+    rte_regexdev_[en|de]queue_burst()
32*2d9fd380Sjfb8856606  *     |   PCRE based    o------+  |               |
33*2d9fd380Sjfb8856606  *     |  RegEx pattern  |      |  |  +--------+   |
34*2d9fd380Sjfb8856606  *     | matching engine o------+--+--o        |   |    +------+
35*2d9fd380Sjfb8856606  *     |                 |      |  |  | queue  |<==o===>|Core 0|
36*2d9fd380Sjfb8856606  *     |                 o----+ |  |  | pair 0 |        |      |
37*2d9fd380Sjfb8856606  *     |                 |    | |  |  +--------+        +------+
38*2d9fd380Sjfb8856606  *     +-----------------+    | |  |
39*2d9fd380Sjfb8856606  *            ^               | |  |  +--------+
40*2d9fd380Sjfb8856606  *            |               | |  |  |        |        +------+
41*2d9fd380Sjfb8856606  *            |               | +--+--o queue  |<======>|Core 1|
42*2d9fd380Sjfb8856606  *        Rule|Database       |    |  | pair 1 |        |      |
43*2d9fd380Sjfb8856606  *     +------+----------+    |    |  +--------+        +------+
44*2d9fd380Sjfb8856606  *     |     Group 0     |    |    |
45*2d9fd380Sjfb8856606  *     | +-------------+ |    |    |  +--------+        +------+
46*2d9fd380Sjfb8856606  *     | | Rules 0..n  | |    |    |  |        |        |Core 2|
47*2d9fd380Sjfb8856606  *     | +-------------+ |    |    +--o queue  |<======>|      |
48*2d9fd380Sjfb8856606  *     |     Group 1     |    |       | pair 2 |        +------+
49*2d9fd380Sjfb8856606  *     | +-------------+ |    |       +--------+
50*2d9fd380Sjfb8856606  *     | | Rules 0..n  | |    |
51*2d9fd380Sjfb8856606  *     | +-------------+ |    |       +--------+
52*2d9fd380Sjfb8856606  *     |     Group 2     |    |       |        |        +------+
53*2d9fd380Sjfb8856606  *     | +-------------+ |    |       | queue  |<======>|Core n|
54*2d9fd380Sjfb8856606  *     | | Rules 0..n  | |    +-------o pair n |        |      |
55*2d9fd380Sjfb8856606  *     | +-------------+ |            +--------+        +------+
56*2d9fd380Sjfb8856606  *     |     Group n     |
57*2d9fd380Sjfb8856606  *     | +-------------+ |<-------rte_regexdev_rule_db_update()
58*2d9fd380Sjfb8856606  *     | |             | |<-------rte_regexdev_rule_db_compile_activate()
59*2d9fd380Sjfb8856606  *     | | Rules 0..n  | |<-------rte_regexdev_rule_db_import()
60*2d9fd380Sjfb8856606  *     | +-------------+ |------->rte_regexdev_rule_db_export()
61*2d9fd380Sjfb8856606  *     +-----------------+
62*2d9fd380Sjfb8856606  *
63*2d9fd380Sjfb8856606  * RegEx: A regular expression is a concise and flexible means for matching
64*2d9fd380Sjfb8856606  * strings of text, such as particular characters, words, or patterns of
65*2d9fd380Sjfb8856606  * characters. A common abbreviation for this is “RegEx”.
66*2d9fd380Sjfb8856606  *
67*2d9fd380Sjfb8856606  * RegEx device: A hardware or software-based implementation of RegEx
68*2d9fd380Sjfb8856606  * device API for PCRE based pattern matching syntax and semantics.
69*2d9fd380Sjfb8856606  *
70*2d9fd380Sjfb8856606  * PCRE RegEx syntax and semantics specification:
71*2d9fd380Sjfb8856606  * http://regexkit.sourceforge.net/Documentation/pcre/pcrepattern.html
72*2d9fd380Sjfb8856606  *
73*2d9fd380Sjfb8856606  * RegEx queue pair: Each RegEx device should have one or more queue pair to
74*2d9fd380Sjfb8856606  * transmit a burst of pattern matching request and receive a burst of
75*2d9fd380Sjfb8856606  * receive the pattern matching response. The pattern matching request/response
76*2d9fd380Sjfb8856606  * embedded in *rte_regex_ops* structure.
77*2d9fd380Sjfb8856606  *
78*2d9fd380Sjfb8856606  * Rule: A pattern matching rule expressed in PCRE RegEx syntax along with
79*2d9fd380Sjfb8856606  * Match ID and Group ID to identify the rule upon the match.
80*2d9fd380Sjfb8856606  *
81*2d9fd380Sjfb8856606  * Rule database: The RegEx device accepts regular expressions and converts them
82*2d9fd380Sjfb8856606  * into a compiled rule database that can then be used to scan data.
83*2d9fd380Sjfb8856606  * Compilation allows the device to analyze the given pattern(s) and
84*2d9fd380Sjfb8856606  * pre-determine how to scan for these patterns in an optimized fashion that
85*2d9fd380Sjfb8856606  * would be far too expensive to compute at run-time. A rule database contains
86*2d9fd380Sjfb8856606  * a set of rules that compiled in device specific binary form.
87*2d9fd380Sjfb8856606  *
88*2d9fd380Sjfb8856606  * Match ID or Rule ID: A unique identifier provided at the time of rule
89*2d9fd380Sjfb8856606  * creation for the application to identify the rule upon match.
90*2d9fd380Sjfb8856606  *
91*2d9fd380Sjfb8856606  * Group ID: Group of rules can be grouped under one group ID to enable
92*2d9fd380Sjfb8856606  * rule isolation and effective pattern matching. A unique group identifier
93*2d9fd380Sjfb8856606  * provided at the time of rule creation for the application to identify the
94*2d9fd380Sjfb8856606  * rule upon match.
95*2d9fd380Sjfb8856606  *
96*2d9fd380Sjfb8856606  * Scan: A pattern matching request through *enqueue* API.
97*2d9fd380Sjfb8856606  *
98*2d9fd380Sjfb8856606  * It may possible that a given RegEx device may not support all the features
99*2d9fd380Sjfb8856606  * of PCRE. The application may probe unsupported features through
100*2d9fd380Sjfb8856606  * struct rte_regexdev_info::pcre_unsup_flags
101*2d9fd380Sjfb8856606  *
102*2d9fd380Sjfb8856606  * By default, all the functions of the RegEx Device API exported by a PMD
103*2d9fd380Sjfb8856606  * are lock-free functions which assume to not be invoked in parallel on
104*2d9fd380Sjfb8856606  * different logical cores to work on the same target object. For instance,
105*2d9fd380Sjfb8856606  * the dequeue function of a PMD cannot be invoked in parallel on two logical
106*2d9fd380Sjfb8856606  * cores to operates on same RegEx queue pair. Of course, this function
107*2d9fd380Sjfb8856606  * can be invoked in parallel by different logical core on different queue pair.
108*2d9fd380Sjfb8856606  * It is the responsibility of the upper level application to enforce this rule.
109*2d9fd380Sjfb8856606  *
110*2d9fd380Sjfb8856606  * In all functions of the RegEx API, the RegEx device is
111*2d9fd380Sjfb8856606  * designated by an integer >= 0 named the device identifier *dev_id*
112*2d9fd380Sjfb8856606  *
113*2d9fd380Sjfb8856606  * At the RegEx driver level, RegEx devices are represented by a generic
114*2d9fd380Sjfb8856606  * data structure of type *rte_regexdev*.
115*2d9fd380Sjfb8856606  *
116*2d9fd380Sjfb8856606  * RegEx devices are dynamically registered during the PCI/SoC device probing
117*2d9fd380Sjfb8856606  * phase performed at EAL initialization time.
118*2d9fd380Sjfb8856606  * When a RegEx device is being probed, a *rte_regexdev* structure and
119*2d9fd380Sjfb8856606  * a new device identifier are allocated for that device. Then, the
120*2d9fd380Sjfb8856606  * regexdev_init() function supplied by the RegEx driver matching the probed
121*2d9fd380Sjfb8856606  * device is invoked to properly initialize the device.
122*2d9fd380Sjfb8856606  *
123*2d9fd380Sjfb8856606  * The role of the device init function consists of resetting the hardware or
124*2d9fd380Sjfb8856606  * software RegEx driver implementations.
125*2d9fd380Sjfb8856606  *
126*2d9fd380Sjfb8856606  * If the device init operation is successful, the correspondence between
127*2d9fd380Sjfb8856606  * the device identifier assigned to the new device and its associated
128*2d9fd380Sjfb8856606  * *rte_regexdev* structure is effectively registered.
129*2d9fd380Sjfb8856606  * Otherwise, both the *rte_regexdev* structure and the device identifier are
130*2d9fd380Sjfb8856606  * freed.
131*2d9fd380Sjfb8856606  *
132*2d9fd380Sjfb8856606  * The functions exported by the application RegEx API to setup a device
133*2d9fd380Sjfb8856606  * designated by its device identifier must be invoked in the following order:
134*2d9fd380Sjfb8856606  *     - rte_regexdev_configure()
135*2d9fd380Sjfb8856606  *     - rte_regexdev_queue_pair_setup()
136*2d9fd380Sjfb8856606  *     - rte_regexdev_start()
137*2d9fd380Sjfb8856606  *
138*2d9fd380Sjfb8856606  * Then, the application can invoke, in any order, the functions
139*2d9fd380Sjfb8856606  * exported by the RegEx API to enqueue pattern matching job, dequeue pattern
140*2d9fd380Sjfb8856606  * matching response, get the stats, update the rule database,
141*2d9fd380Sjfb8856606  * get/set device attributes and so on
142*2d9fd380Sjfb8856606  *
143*2d9fd380Sjfb8856606  * If the application wants to change the configuration (i.e. call
144*2d9fd380Sjfb8856606  * rte_regexdev_configure() or rte_regexdev_queue_pair_setup()), it must call
145*2d9fd380Sjfb8856606  * rte_regexdev_stop() first to stop the device and then do the reconfiguration
146*2d9fd380Sjfb8856606  * before calling rte_regexdev_start() again. The enqueue and dequeue
147*2d9fd380Sjfb8856606  * functions should not be invoked when the device is stopped.
148*2d9fd380Sjfb8856606  *
149*2d9fd380Sjfb8856606  * Finally, an application can close a RegEx device by invoking the
150*2d9fd380Sjfb8856606  * rte_regexdev_close() function.
151*2d9fd380Sjfb8856606  *
152*2d9fd380Sjfb8856606  * Each function of the application RegEx API invokes a specific function
153*2d9fd380Sjfb8856606  * of the PMD that controls the target device designated by its device
154*2d9fd380Sjfb8856606  * identifier.
155*2d9fd380Sjfb8856606  *
156*2d9fd380Sjfb8856606  * For this purpose, all device-specific functions of a RegEx driver are
157*2d9fd380Sjfb8856606  * supplied through a set of pointers contained in a generic structure of type
158*2d9fd380Sjfb8856606  * *regexdev_ops*.
159*2d9fd380Sjfb8856606  * The address of the *regexdev_ops* structure is stored in the *rte_regexdev*
160*2d9fd380Sjfb8856606  * structure by the device init function of the RegEx driver, which is
161*2d9fd380Sjfb8856606  * invoked during the PCI/SoC device probing phase, as explained earlier.
162*2d9fd380Sjfb8856606  *
163*2d9fd380Sjfb8856606  * In other words, each function of the RegEx API simply retrieves the
164*2d9fd380Sjfb8856606  * *rte_regexdev* structure associated with the device identifier and
165*2d9fd380Sjfb8856606  * performs an indirect invocation of the corresponding driver function
166*2d9fd380Sjfb8856606  * supplied in the *regexdev_ops* structure of the *rte_regexdev* structure.
167*2d9fd380Sjfb8856606  *
168*2d9fd380Sjfb8856606  * For performance reasons, the address of the fast-path functions of the
169*2d9fd380Sjfb8856606  * RegEx driver is not contained in the *regexdev_ops* structure.
170*2d9fd380Sjfb8856606  * Instead, they are directly stored at the beginning of the *rte_regexdev*
171*2d9fd380Sjfb8856606  * structure to avoid an extra indirect memory access during their invocation.
172*2d9fd380Sjfb8856606  *
173*2d9fd380Sjfb8856606  * RTE RegEx device drivers do not use interrupts for enqueue or dequeue
174*2d9fd380Sjfb8856606  * operation. Instead, RegEx drivers export Poll-Mode enqueue and dequeue
175*2d9fd380Sjfb8856606  * functions to applications.
176*2d9fd380Sjfb8856606  *
177*2d9fd380Sjfb8856606  * The *enqueue* operation submits a burst of RegEx pattern matching request
178*2d9fd380Sjfb8856606  * to the RegEx device and the *dequeue* operation gets a burst of pattern
179*2d9fd380Sjfb8856606  * matching response for the ones submitted through *enqueue* operation.
180*2d9fd380Sjfb8856606  *
181*2d9fd380Sjfb8856606  * Typical application utilisation of the RegEx device API will follow the
182*2d9fd380Sjfb8856606  * following programming flow.
183*2d9fd380Sjfb8856606  *
184*2d9fd380Sjfb8856606  * - rte_regexdev_configure()
185*2d9fd380Sjfb8856606  * - rte_regexdev_queue_pair_setup()
186*2d9fd380Sjfb8856606  * - rte_regexdev_rule_db_update() Needs to invoke if precompiled rule database
187*2d9fd380Sjfb8856606  *   not provided in rte_regexdev_config::rule_db for rte_regexdev_configure()
188*2d9fd380Sjfb8856606  *   and/or application needs to update rule database.
189*2d9fd380Sjfb8856606  * - rte_regexdev_rule_db_compile_activate() Needs to invoke if
190*2d9fd380Sjfb8856606  *   rte_regexdev_rule_db_update function was used.
191*2d9fd380Sjfb8856606  * - Create or reuse exiting mempool for *rte_regex_ops* objects.
192*2d9fd380Sjfb8856606  * - rte_regexdev_start()
193*2d9fd380Sjfb8856606  * - rte_regexdev_enqueue_burst()
194*2d9fd380Sjfb8856606  * - rte_regexdev_dequeue_burst()
195*2d9fd380Sjfb8856606  */
196*2d9fd380Sjfb8856606 
197*2d9fd380Sjfb8856606 #ifdef __cplusplus
198*2d9fd380Sjfb8856606 extern "C" {
199*2d9fd380Sjfb8856606 #endif
200*2d9fd380Sjfb8856606 
201*2d9fd380Sjfb8856606 #include <rte_common.h>
202*2d9fd380Sjfb8856606 #include <rte_config.h>
203*2d9fd380Sjfb8856606 #include <rte_dev.h>
204*2d9fd380Sjfb8856606 #include <rte_errno.h>
205*2d9fd380Sjfb8856606 #include <rte_mbuf.h>
206*2d9fd380Sjfb8856606 #include <rte_memory.h>
207*2d9fd380Sjfb8856606 
208*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN
209*2d9fd380Sjfb8856606 
210*2d9fd380Sjfb8856606 extern int rte_regexdev_logtype;
211*2d9fd380Sjfb8856606 
212*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_LOG(level, ...) \
213*2d9fd380Sjfb8856606 	rte_log(RTE_LOG_ ## level, rte_regexdev_logtype, "" __VA_ARGS__)
214*2d9fd380Sjfb8856606 
215*2d9fd380Sjfb8856606 /* Macros to check for valid port */
216*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_VALID_DEV_ID_OR_ERR_RET(dev_id, retval) do { \
217*2d9fd380Sjfb8856606 	if (!rte_regexdev_is_valid_dev(dev_id)) { \
218*2d9fd380Sjfb8856606 		RTE_REGEXDEV_LOG(ERR, "Invalid dev_id=%u\n", dev_id); \
219*2d9fd380Sjfb8856606 		return retval; \
220*2d9fd380Sjfb8856606 	} \
221*2d9fd380Sjfb8856606 } while (0)
222*2d9fd380Sjfb8856606 
223*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_VALID_DEV_ID_OR_RET(dev_id) do { \
224*2d9fd380Sjfb8856606 	if (!rte_regexdev_is_valid_dev(dev_id)) { \
225*2d9fd380Sjfb8856606 		RTE_REGEXDEV_LOG(ERR, "Invalid dev_id=%u\n", dev_id); \
226*2d9fd380Sjfb8856606 		return; \
227*2d9fd380Sjfb8856606 	} \
228*2d9fd380Sjfb8856606 } while (0)
229*2d9fd380Sjfb8856606 
230*2d9fd380Sjfb8856606 /**
231*2d9fd380Sjfb8856606  * Check if dev_id is ready.
232*2d9fd380Sjfb8856606  *
233*2d9fd380Sjfb8856606  * @param dev_id
234*2d9fd380Sjfb8856606  *   The dev identifier of the RegEx device.
235*2d9fd380Sjfb8856606  *
236*2d9fd380Sjfb8856606  * @return
237*2d9fd380Sjfb8856606  *   - 0 if device state is not in ready state.
238*2d9fd380Sjfb8856606  *   - 1 if device state is ready state.
239*2d9fd380Sjfb8856606  */
240*2d9fd380Sjfb8856606 int rte_regexdev_is_valid_dev(uint16_t dev_id);
241*2d9fd380Sjfb8856606 
242*2d9fd380Sjfb8856606 /**
243*2d9fd380Sjfb8856606  * @warning
244*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
245*2d9fd380Sjfb8856606  *
246*2d9fd380Sjfb8856606  * Get the total number of RegEx devices that have been successfully
247*2d9fd380Sjfb8856606  * initialised.
248*2d9fd380Sjfb8856606  *
249*2d9fd380Sjfb8856606  * @return
250*2d9fd380Sjfb8856606  *   The total number of usable RegEx devices.
251*2d9fd380Sjfb8856606  */
252*2d9fd380Sjfb8856606 __rte_experimental
253*2d9fd380Sjfb8856606 uint8_t
254*2d9fd380Sjfb8856606 rte_regexdev_count(void);
255*2d9fd380Sjfb8856606 
256*2d9fd380Sjfb8856606 /**
257*2d9fd380Sjfb8856606  * @warning
258*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
259*2d9fd380Sjfb8856606  *
260*2d9fd380Sjfb8856606  * Get the device identifier for the named RegEx device.
261*2d9fd380Sjfb8856606  *
262*2d9fd380Sjfb8856606  * @param name
263*2d9fd380Sjfb8856606  *   RegEx device name to select the RegEx device identifier.
264*2d9fd380Sjfb8856606  *
265*2d9fd380Sjfb8856606  * @return
266*2d9fd380Sjfb8856606  *   Returns RegEx device identifier on success.
267*2d9fd380Sjfb8856606  *   - <0: Failure to find named RegEx device.
268*2d9fd380Sjfb8856606  */
269*2d9fd380Sjfb8856606 __rte_experimental
270*2d9fd380Sjfb8856606 int
271*2d9fd380Sjfb8856606 rte_regexdev_get_dev_id(const char *name);
272*2d9fd380Sjfb8856606 
273*2d9fd380Sjfb8856606 /* Enumerates RegEx device capabilities */
274*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_CAPA_RUNTIME_COMPILATION_F (1ULL << 0)
275*2d9fd380Sjfb8856606 /**< RegEx device does support compiling the rules at runtime unlike
276*2d9fd380Sjfb8856606  * loading only the pre-built rule database using
277*2d9fd380Sjfb8856606  * struct rte_regexdev_config::rule_db in rte_regexdev_configure()
278*2d9fd380Sjfb8856606  *
279*2d9fd380Sjfb8856606  * @see struct rte_regexdev_config::rule_db, rte_regexdev_configure()
280*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
281*2d9fd380Sjfb8856606  */
282*2d9fd380Sjfb8856606 
283*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_CAPA_SUPP_PCRE_START_ANCHOR_F (1ULL << 1)
284*2d9fd380Sjfb8856606 /**< RegEx device support PCRE Anchor to start of match flag.
285*2d9fd380Sjfb8856606  * Example RegEx is `/\Gfoo\d/`. Here `\G` asserts position at the end of the
286*2d9fd380Sjfb8856606  * previous match or the start of the string for the first match.
287*2d9fd380Sjfb8856606  * This position will change each time the RegEx is applied to the subject
288*2d9fd380Sjfb8856606  * string. If the RegEx is applied to `foo1foo2Zfoo3` the first two matches will
289*2d9fd380Sjfb8856606  * be successful for `foo1foo2` and fail for `Zfoo3`.
290*2d9fd380Sjfb8856606  *
291*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
292*2d9fd380Sjfb8856606  */
293*2d9fd380Sjfb8856606 
294*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_CAPA_SUPP_PCRE_ATOMIC_GROUPING_F (1ULL << 2)
295*2d9fd380Sjfb8856606 /**< RegEx device support PCRE Atomic grouping.
296*2d9fd380Sjfb8856606  * Atomic groups are represented by `(?>)`. An atomic group is a group that,
297*2d9fd380Sjfb8856606  * when the RegEx engine exits from it, automatically throws away all
298*2d9fd380Sjfb8856606  * backtracking positions remembered by any tokens inside the group.
299*2d9fd380Sjfb8856606  * Example RegEx is `a(?>bc|b)c` if the given patterns are `abc` and `abcc` then
300*2d9fd380Sjfb8856606  * `a(bc|b)c` matches both where as `a(?>bc|b)c` matches only abcc because
301*2d9fd380Sjfb8856606  * atomic groups don't allow backtracing back to `b`.
302*2d9fd380Sjfb8856606  *
303*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
304*2d9fd380Sjfb8856606  */
305*2d9fd380Sjfb8856606 
306*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_PCRE_BACKTRACKING_CTRL_F (1ULL << 3)
307*2d9fd380Sjfb8856606 /**< RegEx device support PCRE backtracking control verbs.
308*2d9fd380Sjfb8856606  * Some examples of backtracing verbs are (*COMMIT), (*ACCEPT), (*FAIL),
309*2d9fd380Sjfb8856606  * (*SKIP), (*PRUNE).
310*2d9fd380Sjfb8856606  *
311*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
312*2d9fd380Sjfb8856606  */
313*2d9fd380Sjfb8856606 
314*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_PCRE_CALLOUTS_F (1ULL << 4)
315*2d9fd380Sjfb8856606 /**< RegEx device support PCRE callouts.
316*2d9fd380Sjfb8856606  * PCRE supports calling external function in between matches by using `(?C)`.
317*2d9fd380Sjfb8856606  * Example RegEx `ABC(?C)D` if a given patter is `ABCD` then the RegEx engine
318*2d9fd380Sjfb8856606  * will parse ABC perform a userdefined callout and return a successful match at
319*2d9fd380Sjfb8856606  * D.
320*2d9fd380Sjfb8856606  *
321*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
322*2d9fd380Sjfb8856606  */
323*2d9fd380Sjfb8856606 
324*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_PCRE_BACKREFERENCE_F (1ULL << 5)
325*2d9fd380Sjfb8856606 /**< RegEx device support PCRE backreference.
326*2d9fd380Sjfb8856606  * Example RegEx is `(\2ABC|(GHI))+` `\2` matches the same text as most recently
327*2d9fd380Sjfb8856606  * matched by the 2nd capturing group i.e. `GHI`.
328*2d9fd380Sjfb8856606  *
329*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
330*2d9fd380Sjfb8856606  */
331*2d9fd380Sjfb8856606 
332*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_PCRE_GREEDY_F (1ULL << 6)
333*2d9fd380Sjfb8856606 /**< RegEx device support PCRE Greedy mode.
334*2d9fd380Sjfb8856606  * For example if the RegEx is `AB\d*?` then `*?` represents zero or unlimited
335*2d9fd380Sjfb8856606  * matches. In greedy mode the pattern `AB12345` will be matched completely
336*2d9fd380Sjfb8856606  * where as the ungreedy mode `AB` will be returned as the match.
337*2d9fd380Sjfb8856606  *
338*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
339*2d9fd380Sjfb8856606  */
340*2d9fd380Sjfb8856606 
341*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_PCRE_MATCH_ALL_F (1ULL << 7)
342*2d9fd380Sjfb8856606 /**< RegEx device support match all mode.
343*2d9fd380Sjfb8856606  * For example if the RegEx is `AB\d*?` then `*?` represents zero or unlimited
344*2d9fd380Sjfb8856606  * matches. In match all mode the pattern `AB12345` will return 6 matches.
345*2d9fd380Sjfb8856606  * AB, AB1, AB12, AB123, AB1234, AB12345.
346*2d9fd380Sjfb8856606  *
347*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
348*2d9fd380Sjfb8856606  */
349*2d9fd380Sjfb8856606 
350*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_PCRE_LOOKAROUND_ASRT_F (1ULL << 8)
351*2d9fd380Sjfb8856606 /**< RegEx device support PCRE Lookaround assertions
352*2d9fd380Sjfb8856606  * (Zero-width assertions). Example RegEx is `[a-z]+\d+(?=!{3,})` if
353*2d9fd380Sjfb8856606  * the given pattern is `dwad1234!` the RegEx engine doesn't report any matches
354*2d9fd380Sjfb8856606  * because the assert `(?=!{3,})` fails. The pattern `dwad123!!!` would return a
355*2d9fd380Sjfb8856606  * successful match.
356*2d9fd380Sjfb8856606  *
357*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
358*2d9fd380Sjfb8856606  */
359*2d9fd380Sjfb8856606 
360*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_PCRE_MATCH_POINT_RST_F (1ULL << 9)
361*2d9fd380Sjfb8856606 /**< RegEx device doesn't support PCRE match point reset directive.
362*2d9fd380Sjfb8856606  * Example RegEx is `[a-z]+\K\d+` if the pattern is `dwad123`
363*2d9fd380Sjfb8856606  * then even though the entire pattern matches only `123`
364*2d9fd380Sjfb8856606  * is reported as a match.
365*2d9fd380Sjfb8856606  *
366*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
367*2d9fd380Sjfb8856606  */
368*2d9fd380Sjfb8856606 
369*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_NEWLINE_CONVENTIONS_F (1ULL << 10)
370*2d9fd380Sjfb8856606 /**< RegEx support PCRE newline convention.
371*2d9fd380Sjfb8856606  * Newline conventions are represented as follows:
372*2d9fd380Sjfb8856606  * (*CR)        carriage return
373*2d9fd380Sjfb8856606  * (*LF)        linefeed
374*2d9fd380Sjfb8856606  * (*CRLF)      carriage return, followed by linefeed
375*2d9fd380Sjfb8856606  * (*ANYCRLF)   any of the three above
376*2d9fd380Sjfb8856606  * (*ANY)       all Unicode newline sequences
377*2d9fd380Sjfb8856606  *
378*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
379*2d9fd380Sjfb8856606  */
380*2d9fd380Sjfb8856606 
381*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_PCRE_NEWLINE_SEQ_F (1ULL << 11)
382*2d9fd380Sjfb8856606 /**< RegEx device support PCRE newline sequence.
383*2d9fd380Sjfb8856606  * The escape sequence `\R` will match any newline sequence.
384*2d9fd380Sjfb8856606  * It is equivalent to: `(?>\r\n|\n|\x0b|\f|\r|\x85)`.
385*2d9fd380Sjfb8856606  *
386*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
387*2d9fd380Sjfb8856606  */
388*2d9fd380Sjfb8856606 
389*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_PCRE_POSSESSIVE_QUALIFIERS_F (1ULL << 12)
390*2d9fd380Sjfb8856606 /**< RegEx device support PCRE possessive qualifiers.
391*2d9fd380Sjfb8856606  * Example RegEx possessive qualifiers `*+`, `++`, `?+`, `{m,n}+`.
392*2d9fd380Sjfb8856606  * Possessive quantifier repeats the token as many times as possible and it does
393*2d9fd380Sjfb8856606  * not give up matches as the engine backtracks. With a possessive quantifier,
394*2d9fd380Sjfb8856606  * the deal is all or nothing.
395*2d9fd380Sjfb8856606  *
396*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
397*2d9fd380Sjfb8856606  */
398*2d9fd380Sjfb8856606 
399*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_PCRE_SUBROUTINE_REFERENCES_F (1ULL << 13)
400*2d9fd380Sjfb8856606 /**< RegEx device support PCRE Subroutine references.
401*2d9fd380Sjfb8856606  * PCRE Subroutine references allow for sub patterns to be assessed
402*2d9fd380Sjfb8856606  * as part of the RegEx. Example RegEx is `(foo|fuzz)\g<1>+bar` matches the
403*2d9fd380Sjfb8856606  * pattern `foofoofuzzfoofuzzbar`.
404*2d9fd380Sjfb8856606  *
405*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
406*2d9fd380Sjfb8856606  */
407*2d9fd380Sjfb8856606 
408*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_PCRE_UTF_8_F (1ULL << 14)
409*2d9fd380Sjfb8856606 /**< RegEx device support UTF-8 character encoding.
410*2d9fd380Sjfb8856606  *
411*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::pcre_unsup_flags
412*2d9fd380Sjfb8856606  */
413*2d9fd380Sjfb8856606 
414*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_PCRE_UTF_16_F (1ULL << 15)
415*2d9fd380Sjfb8856606 /**< RegEx device support UTF-16 character encoding.
416*2d9fd380Sjfb8856606  *
417*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
418*2d9fd380Sjfb8856606  */
419*2d9fd380Sjfb8856606 
420*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_PCRE_UTF_32_F (1ULL << 16)
421*2d9fd380Sjfb8856606 /**< RegEx device support UTF-32 character encoding.
422*2d9fd380Sjfb8856606  *
423*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
424*2d9fd380Sjfb8856606  */
425*2d9fd380Sjfb8856606 
426*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_PCRE_WORD_BOUNDARY_F (1ULL << 17)
427*2d9fd380Sjfb8856606 /**< RegEx device support word boundaries.
428*2d9fd380Sjfb8856606  * The meta character `\b` represents word boundary anchor.
429*2d9fd380Sjfb8856606  *
430*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
431*2d9fd380Sjfb8856606  */
432*2d9fd380Sjfb8856606 
433*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_PCRE_FORWARD_REFERENCES_F (1ULL << 18)
434*2d9fd380Sjfb8856606 /**< RegEx device support Forward references.
435*2d9fd380Sjfb8856606  * Forward references allow you to use a back reference to a group that appears
436*2d9fd380Sjfb8856606  * later in the RegEx. Example RegEx is `(\3ABC|(DEF|(GHI)))+` matches the
437*2d9fd380Sjfb8856606  * following string `GHIGHIABCDEF`.
438*2d9fd380Sjfb8856606  *
439*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
440*2d9fd380Sjfb8856606  */
441*2d9fd380Sjfb8856606 
442*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_MATCH_AS_END_F (1ULL << 19)
443*2d9fd380Sjfb8856606 /**< RegEx device support match as end.
444*2d9fd380Sjfb8856606  * Match as end means that the match result holds the end offset of the
445*2d9fd380Sjfb8856606  * detected match. No len value is set.
446*2d9fd380Sjfb8856606  * If the device doesn't support this feature it means the match
447*2d9fd380Sjfb8856606  * result holds the starting position of match and the length of the match.
448*2d9fd380Sjfb8856606  *
449*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
450*2d9fd380Sjfb8856606  */
451*2d9fd380Sjfb8856606 
452*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_CROSS_BUFFER_F (1ULL << 20)
453*2d9fd380Sjfb8856606 /**< RegEx device support cross buffer match.
454*2d9fd380Sjfb8856606  * Cross buffer matching means that the match can be detected even if the
455*2d9fd380Sjfb8856606  * string was started in previous buffer.
456*2d9fd380Sjfb8856606  * In case the device is configured as RTE_REGEXDEV_CFG_MATCH_AS_END
457*2d9fd380Sjfb8856606  * the end offset will be relative for the first packet.
458*2d9fd380Sjfb8856606  * For example RegEx is ABC the first buffer is xxxx second buffer yyyA and
459*2d9fd380Sjfb8856606  * the last buffer BCzz.
460*2d9fd380Sjfb8856606  * In case the match as end is configured the end offset will be 10.
461*2d9fd380Sjfb8856606  *
462*2d9fd380Sjfb8856606  * @see RTE_REGEXDEV_CFG_MATCH_AS_END_F
463*2d9fd380Sjfb8856606  * @see RTE_REGEXDEV_CFG_CROSS_BUFFER_SCAN_F
464*2d9fd380Sjfb8856606  * @see RTE_REGEX_OPS_RSP_PMI_SOJ_F
465*2d9fd380Sjfb8856606  * @see RTE_REGEX_OPS_RSP_PMI_EOJ_F
466*2d9fd380Sjfb8856606  */
467*2d9fd380Sjfb8856606 
468*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_SUPP_MATCH_ALL_F (1ULL << 21)
469*2d9fd380Sjfb8856606 /**< RegEx device support match all.
470*2d9fd380Sjfb8856606  * Match all means that the RegEx engine will return all possible matches.
471*2d9fd380Sjfb8856606  * For example, assume the RegEx is `A+b`, given the input AAAb the
472*2d9fd380Sjfb8856606  * returned matches will be: Ab, AAb and AAAb.
473*2d9fd380Sjfb8856606  *
474*2d9fd380Sjfb8856606  * @see RTE_REGEXDEV_CFG_MATCH_ALL_F
475*2d9fd380Sjfb8856606  */
476*2d9fd380Sjfb8856606 
477*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_CAPA_QUEUE_PAIR_OOS_F (1ULL << 22)
478*2d9fd380Sjfb8856606 /**< RegEx device supports out of order scan.
479*2d9fd380Sjfb8856606  * Out of order scan means the response of a specific job can be returned as
480*2d9fd380Sjfb8856606  * soon as it is ready even if previous jobs on the same queue didn't complete.
481*2d9fd380Sjfb8856606  *
482*2d9fd380Sjfb8856606  * @see RTE_REGEX_QUEUE_PAIR_CFG_OOS_F
483*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::regexdev_capa
484*2d9fd380Sjfb8856606  */
485*2d9fd380Sjfb8856606 
486*2d9fd380Sjfb8856606 /* Enumerates PCRE rule flags */
487*2d9fd380Sjfb8856606 #define RTE_REGEX_PCRE_RULE_ALLOW_EMPTY_F (1ULL << 0)
488*2d9fd380Sjfb8856606 /**< When this flag is set, the pattern that can match against an empty string,
489*2d9fd380Sjfb8856606  * such as `.*` are allowed.
490*2d9fd380Sjfb8856606  *
491*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::rule_flags
492*2d9fd380Sjfb8856606  * @see struct rte_regexdev_rule::rule_flags
493*2d9fd380Sjfb8856606  */
494*2d9fd380Sjfb8856606 
495*2d9fd380Sjfb8856606 #define RTE_REGEX_PCRE_RULE_ANCHORED_F (1ULL << 1)
496*2d9fd380Sjfb8856606 /**< When this flag is set, the pattern is forced to be "anchored", that is, it
497*2d9fd380Sjfb8856606  * is constrained to match only at the first matching point in the string that
498*2d9fd380Sjfb8856606  * is being searched. Similar to `^` and represented by `\A`.
499*2d9fd380Sjfb8856606  *
500*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::rule_flags
501*2d9fd380Sjfb8856606  * @see struct rte_regexdev_rule::rule_flags
502*2d9fd380Sjfb8856606  */
503*2d9fd380Sjfb8856606 
504*2d9fd380Sjfb8856606 #define RTE_REGEX_PCRE_RULE_CASELESS_F (1ULL << 2)
505*2d9fd380Sjfb8856606 /**< When this flag is set, letters in the pattern match both upper and lower
506*2d9fd380Sjfb8856606  * case letters in the subject.
507*2d9fd380Sjfb8856606  *
508*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::rule_flags
509*2d9fd380Sjfb8856606  * @see struct rte_regexdev_rule::rule_flags
510*2d9fd380Sjfb8856606  */
511*2d9fd380Sjfb8856606 
512*2d9fd380Sjfb8856606 #define RTE_REGEX_PCRE_RULE_DOTALL_F (1ULL << 3)
513*2d9fd380Sjfb8856606 /**< When this flag is set, a dot metacharacter in the pattern matches any
514*2d9fd380Sjfb8856606  * character, including one that indicates a newline.
515*2d9fd380Sjfb8856606  *
516*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::rule_flags
517*2d9fd380Sjfb8856606  * @see struct rte_regexdev_rule::rule_flags
518*2d9fd380Sjfb8856606  */
519*2d9fd380Sjfb8856606 
520*2d9fd380Sjfb8856606 #define RTE_REGEX_PCRE_RULE_DUPNAMES_F (1ULL << 4)
521*2d9fd380Sjfb8856606 /**< When this flag is set, names used to identify capture groups need not be
522*2d9fd380Sjfb8856606  * unique.
523*2d9fd380Sjfb8856606  *
524*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::rule_flags
525*2d9fd380Sjfb8856606  * @see struct rte_regexdev_rule::rule_flags
526*2d9fd380Sjfb8856606  */
527*2d9fd380Sjfb8856606 
528*2d9fd380Sjfb8856606 #define RTE_REGEX_PCRE_RULE_EXTENDED_F (1ULL << 5)
529*2d9fd380Sjfb8856606 /**< When this flag is set, most white space characters in the pattern are
530*2d9fd380Sjfb8856606  * totally ignored except when escaped or inside a character class.
531*2d9fd380Sjfb8856606  *
532*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::rule_flags
533*2d9fd380Sjfb8856606  * @see struct rte_regexdev_rule::rule_flags
534*2d9fd380Sjfb8856606  */
535*2d9fd380Sjfb8856606 
536*2d9fd380Sjfb8856606 #define RTE_REGEX_PCRE_RULE_MATCH_UNSET_BACKREF_F (1ULL << 6)
537*2d9fd380Sjfb8856606 /**< When this flag is set, a backreference to an unset capture group matches an
538*2d9fd380Sjfb8856606  * empty string.
539*2d9fd380Sjfb8856606  *
540*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::rule_flags
541*2d9fd380Sjfb8856606  * @see struct rte_regexdev_rule::rule_flags
542*2d9fd380Sjfb8856606  */
543*2d9fd380Sjfb8856606 
544*2d9fd380Sjfb8856606 #define RTE_REGEX_PCRE_RULE_MULTILINE_F (1ULL << 7)
545*2d9fd380Sjfb8856606 /**< When this flag  is set, the `^` and `$` constructs match immediately
546*2d9fd380Sjfb8856606  * following or immediately before internal newlines in the subject string,
547*2d9fd380Sjfb8856606  * respectively, as well as at the very start and end.
548*2d9fd380Sjfb8856606  *
549*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::rule_flags
550*2d9fd380Sjfb8856606  * @see struct rte_regexdev_rule::rule_flags
551*2d9fd380Sjfb8856606  */
552*2d9fd380Sjfb8856606 
553*2d9fd380Sjfb8856606 #define RTE_REGEX_PCRE_RULE_NO_AUTO_CAPTURE_F (1ULL << 8)
554*2d9fd380Sjfb8856606 /**< When this Flag is set, it disables the use of numbered capturing
555*2d9fd380Sjfb8856606  * parentheses in the pattern. References to capture groups (backreferences or
556*2d9fd380Sjfb8856606  * recursion/subroutine calls) may only refer to named groups, though the
557*2d9fd380Sjfb8856606  * reference can be by name or by number.
558*2d9fd380Sjfb8856606  *
559*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::rule_flags
560*2d9fd380Sjfb8856606  * @see struct rte_regexdev_rule::rule_flags
561*2d9fd380Sjfb8856606  */
562*2d9fd380Sjfb8856606 
563*2d9fd380Sjfb8856606 #define RTE_REGEX_PCRE_RULE_UCP_F (1ULL << 9)
564*2d9fd380Sjfb8856606 /**< By default, only ASCII characters are recognized, When this flag is set,
565*2d9fd380Sjfb8856606  * Unicode properties are used instead to classify characters.
566*2d9fd380Sjfb8856606  *
567*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::rule_flags
568*2d9fd380Sjfb8856606  * @see struct rte_regexdev_rule::rule_flags
569*2d9fd380Sjfb8856606  */
570*2d9fd380Sjfb8856606 
571*2d9fd380Sjfb8856606 #define RTE_REGEX_PCRE_RULE_UNGREEDY_F (1ULL << 10)
572*2d9fd380Sjfb8856606 /**< When this flag is set, the "greediness" of the quantifiers is inverted
573*2d9fd380Sjfb8856606  * so that they are not greedy by default, but become greedy if followed by
574*2d9fd380Sjfb8856606  * `?`.
575*2d9fd380Sjfb8856606  *
576*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::rule_flags
577*2d9fd380Sjfb8856606  * @see struct rte_regexdev_rule::rule_flags
578*2d9fd380Sjfb8856606  */
579*2d9fd380Sjfb8856606 
580*2d9fd380Sjfb8856606 #define RTE_REGEX_PCRE_RULE_UTF_F (1ULL << 11)
581*2d9fd380Sjfb8856606 /**< When this flag is set, RegEx engine has to regard both the pattern and the
582*2d9fd380Sjfb8856606  * subject strings that are subsequently processed as strings of UTF characters
583*2d9fd380Sjfb8856606  * instead of single-code-unit strings.
584*2d9fd380Sjfb8856606  *
585*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::rule_flags
586*2d9fd380Sjfb8856606  * @see struct rte_regexdev_rule::rule_flags
587*2d9fd380Sjfb8856606  */
588*2d9fd380Sjfb8856606 
589*2d9fd380Sjfb8856606 #define RTE_REGEX_PCRE_RULE_NEVER_BACKSLASH_C_F (1ULL << 12)
590*2d9fd380Sjfb8856606 /**< This flag locks out the use of `\C` in the pattern that is being compiled.
591*2d9fd380Sjfb8856606  * This escape matches one data unit, even in UTF mode which can cause
592*2d9fd380Sjfb8856606  * unpredictable behavior in UTF-8 or UTF-16 modes, because it may leave the
593*2d9fd380Sjfb8856606  * current matching point in the mi:set hlsearchddle of a multi-code-unit
594*2d9fd380Sjfb8856606  * character.
595*2d9fd380Sjfb8856606  *
596*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::rule_flags
597*2d9fd380Sjfb8856606  * @see struct rte_regexdev_rule::rule_flags
598*2d9fd380Sjfb8856606  */
599*2d9fd380Sjfb8856606 
600*2d9fd380Sjfb8856606 /**
601*2d9fd380Sjfb8856606  * RegEx device information
602*2d9fd380Sjfb8856606  */
603*2d9fd380Sjfb8856606 struct rte_regexdev_info {
604*2d9fd380Sjfb8856606 	const char *driver_name; /**< RegEx driver name. */
605*2d9fd380Sjfb8856606 	struct rte_device *dev;	/**< Device information. */
606*2d9fd380Sjfb8856606 	uint16_t max_matches;
607*2d9fd380Sjfb8856606 	/**< Maximum matches per scan supported by this device. */
608*2d9fd380Sjfb8856606 	uint16_t max_queue_pairs;
609*2d9fd380Sjfb8856606 	/**< Maximum queue pairs supported by this device. */
610*2d9fd380Sjfb8856606 	uint16_t max_payload_size;
611*2d9fd380Sjfb8856606 	/**< Maximum payload size for a pattern match request or scan.
612*2d9fd380Sjfb8856606 	 * @see RTE_REGEXDEV_CFG_CROSS_BUFFER_SCAN_F
613*2d9fd380Sjfb8856606 	 */
614*2d9fd380Sjfb8856606 	uint32_t max_rules_per_group;
615*2d9fd380Sjfb8856606 	/**< Maximum rules supported per group by this device. */
616*2d9fd380Sjfb8856606 	uint16_t max_groups;
617*2d9fd380Sjfb8856606 	/**< Maximum groups supported by this device. */
618*2d9fd380Sjfb8856606 	uint32_t regexdev_capa;
619*2d9fd380Sjfb8856606 	/**< RegEx device capabilities. @see RTE_REGEXDEV_CAPA_* */
620*2d9fd380Sjfb8856606 	uint64_t rule_flags;
621*2d9fd380Sjfb8856606 	/**< Supported compiler rule flags.
622*2d9fd380Sjfb8856606 	 * @see RTE_REGEX_PCRE_RULE_*, struct rte_regexdev_rule::rule_flags
623*2d9fd380Sjfb8856606 	 */
624*2d9fd380Sjfb8856606 };
625*2d9fd380Sjfb8856606 
626*2d9fd380Sjfb8856606 /**
627*2d9fd380Sjfb8856606  * @warning
628*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
629*2d9fd380Sjfb8856606  *
630*2d9fd380Sjfb8856606  * Retrieve the contextual information of a RegEx device.
631*2d9fd380Sjfb8856606  *
632*2d9fd380Sjfb8856606  * @param dev_id
633*2d9fd380Sjfb8856606  *   The identifier of the device.
634*2d9fd380Sjfb8856606  *
635*2d9fd380Sjfb8856606  * @param[out] dev_info
636*2d9fd380Sjfb8856606  *   A pointer to a structure of type *rte_regexdev_info* to be filled with the
637*2d9fd380Sjfb8856606  *   contextual information of the device.
638*2d9fd380Sjfb8856606  *
639*2d9fd380Sjfb8856606  * @return
640*2d9fd380Sjfb8856606  *   - 0: Success, driver updates the contextual information of the RegEx device
641*2d9fd380Sjfb8856606  *   - <0: Error code returned by the driver info get function.
642*2d9fd380Sjfb8856606  */
643*2d9fd380Sjfb8856606 __rte_experimental
644*2d9fd380Sjfb8856606 int
645*2d9fd380Sjfb8856606 rte_regexdev_info_get(uint8_t dev_id, struct rte_regexdev_info *dev_info);
646*2d9fd380Sjfb8856606 
647*2d9fd380Sjfb8856606 /* Enumerates RegEx device configuration flags */
648*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_CFG_CROSS_BUFFER_SCAN_F (1ULL << 0)
649*2d9fd380Sjfb8856606 /**< Cross buffer scan refers to the ability to be able to detect
650*2d9fd380Sjfb8856606  * matches that occur across buffer boundaries, where the buffers are related
651*2d9fd380Sjfb8856606  * to each other in some way. Enable this flag when to scan payload size
652*2d9fd380Sjfb8856606  * greater than struct rte_regexdev_info::max_payload_size and/or
653*2d9fd380Sjfb8856606  * matches can present across scan buffer boundaries.
654*2d9fd380Sjfb8856606  *
655*2d9fd380Sjfb8856606  * @see struct rte_regexdev_info::max_payload_size
656*2d9fd380Sjfb8856606  * @see struct rte_regexdev_config::dev_cfg_flags, rte_regexdev_configure()
657*2d9fd380Sjfb8856606  * @see RTE_REGEX_OPS_RSP_PMI_SOJ_F
658*2d9fd380Sjfb8856606  * @see RTE_REGEX_OPS_RSP_PMI_EOJ_F
659*2d9fd380Sjfb8856606  */
660*2d9fd380Sjfb8856606 
661*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_CFG_MATCH_AS_END_F (1ULL << 1)
662*2d9fd380Sjfb8856606 /**< Match as end is the ability to return the result as ending offset.
663*2d9fd380Sjfb8856606  * When this flag is set, the result for each match will hold the ending
664*2d9fd380Sjfb8856606  * offset of the match in end_offset.
665*2d9fd380Sjfb8856606  * If this flag is not set, then the match result will hold the starting offset
666*2d9fd380Sjfb8856606  * in start_offset, and the length of the match in len.
667*2d9fd380Sjfb8856606  *
668*2d9fd380Sjfb8856606  * @see RTE_REGEXDEV_SUPP_MATCH_AS_END_F
669*2d9fd380Sjfb8856606  */
670*2d9fd380Sjfb8856606 
671*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_CFG_MATCH_ALL_F (1ULL << 2)
672*2d9fd380Sjfb8856606 /**< Match all is the ability to return all possible results.
673*2d9fd380Sjfb8856606  *
674*2d9fd380Sjfb8856606  * @see RTE_REGEXDEV_SUPP_MATCH_ALL_F
675*2d9fd380Sjfb8856606  */
676*2d9fd380Sjfb8856606 
677*2d9fd380Sjfb8856606 /** RegEx device configuration structure */
678*2d9fd380Sjfb8856606 struct rte_regexdev_config {
679*2d9fd380Sjfb8856606 	uint16_t nb_max_matches;
680*2d9fd380Sjfb8856606 	/**< Maximum matches per scan configured on this device.
681*2d9fd380Sjfb8856606 	 * This value cannot exceed the *max_matches*
682*2d9fd380Sjfb8856606 	 * which previously provided in rte_regexdev_info_get().
683*2d9fd380Sjfb8856606 	 * The value 0 is allowed, in which case, value 1 used.
684*2d9fd380Sjfb8856606 	 * @see struct rte_regexdev_info::max_matches
685*2d9fd380Sjfb8856606 	 */
686*2d9fd380Sjfb8856606 	uint16_t nb_queue_pairs;
687*2d9fd380Sjfb8856606 	/**< Number of RegEx queue pairs to configure on this device.
688*2d9fd380Sjfb8856606 	 * This value cannot exceed the *max_queue_pairs* which previously
689*2d9fd380Sjfb8856606 	 * provided in rte_regexdev_info_get().
690*2d9fd380Sjfb8856606 	 * @see struct rte_regexdev_info::max_queue_pairs
691*2d9fd380Sjfb8856606 	 */
692*2d9fd380Sjfb8856606 	uint32_t nb_rules_per_group;
693*2d9fd380Sjfb8856606 	/**< Number of rules per group to configure on this device.
694*2d9fd380Sjfb8856606 	 * This value cannot exceed the *max_rules_per_group*
695*2d9fd380Sjfb8856606 	 * which previously provided in rte_regexdev_info_get().
696*2d9fd380Sjfb8856606 	 * The value 0 is allowed, in which case,
697*2d9fd380Sjfb8856606 	 * struct rte_regexdev_info::max_rules_per_group used.
698*2d9fd380Sjfb8856606 	 * @see struct rte_regexdev_info::max_rules_per_group
699*2d9fd380Sjfb8856606 	 */
700*2d9fd380Sjfb8856606 	uint16_t nb_groups;
701*2d9fd380Sjfb8856606 	/**< Number of groups to configure on this device.
702*2d9fd380Sjfb8856606 	 * This value cannot exceed the *max_groups*
703*2d9fd380Sjfb8856606 	 * which previously provided in rte_regexdev_info_get().
704*2d9fd380Sjfb8856606 	 * @see struct rte_regexdev_info::max_groups
705*2d9fd380Sjfb8856606 	 */
706*2d9fd380Sjfb8856606 	const char *rule_db;
707*2d9fd380Sjfb8856606 	/**< Import initial set of prebuilt rule database on this device.
708*2d9fd380Sjfb8856606 	 * The value NULL is allowed, in which case, the device will not
709*2d9fd380Sjfb8856606 	 * be configured prebuilt rule database. Application may use
710*2d9fd380Sjfb8856606 	 * rte_regexdev_rule_db_update() or rte_regexdev_rule_db_import() API
711*2d9fd380Sjfb8856606 	 * to update or import rule database after the
712*2d9fd380Sjfb8856606 	 * rte_regexdev_configure().
713*2d9fd380Sjfb8856606 	 * @see rte_regexdev_rule_db_update(), rte_regexdev_rule_db_import()
714*2d9fd380Sjfb8856606 	 */
715*2d9fd380Sjfb8856606 	uint32_t rule_db_len;
716*2d9fd380Sjfb8856606 	/**< Length of *rule_db* buffer. */
717*2d9fd380Sjfb8856606 	uint32_t dev_cfg_flags;
718*2d9fd380Sjfb8856606 	/**< RegEx device configuration flags, See RTE_REGEXDEV_CFG_*  */
719*2d9fd380Sjfb8856606 };
720*2d9fd380Sjfb8856606 
721*2d9fd380Sjfb8856606 /**
722*2d9fd380Sjfb8856606  * @warning
723*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
724*2d9fd380Sjfb8856606  *
725*2d9fd380Sjfb8856606  * Configure a RegEx device.
726*2d9fd380Sjfb8856606  *
727*2d9fd380Sjfb8856606  * This function must be invoked first before any other function in the
728*2d9fd380Sjfb8856606  * API. This function can also be re-invoked when a device is in the
729*2d9fd380Sjfb8856606  * stopped state.
730*2d9fd380Sjfb8856606  *
731*2d9fd380Sjfb8856606  * The caller may use rte_regexdev_info_get() to get the capability of each
732*2d9fd380Sjfb8856606  * resources available for this regex device.
733*2d9fd380Sjfb8856606  *
734*2d9fd380Sjfb8856606  * @param dev_id
735*2d9fd380Sjfb8856606  *   The identifier of the device to configure.
736*2d9fd380Sjfb8856606  * @param cfg
737*2d9fd380Sjfb8856606  *   The RegEx device configuration structure.
738*2d9fd380Sjfb8856606  *
739*2d9fd380Sjfb8856606  * @return
740*2d9fd380Sjfb8856606  *   - 0: Success, device configured. Otherwise negative errno is returned.
741*2d9fd380Sjfb8856606  */
742*2d9fd380Sjfb8856606 __rte_experimental
743*2d9fd380Sjfb8856606 int
744*2d9fd380Sjfb8856606 rte_regexdev_configure(uint8_t dev_id, const struct rte_regexdev_config *cfg);
745*2d9fd380Sjfb8856606 
746*2d9fd380Sjfb8856606 /* Enumerates RegEx queue pair configuration flags */
747*2d9fd380Sjfb8856606 #define RTE_REGEX_QUEUE_PAIR_CFG_OOS_F (1ULL << 0)
748*2d9fd380Sjfb8856606 /**< Out of order scan, If not set, a scan must retire after previously issued
749*2d9fd380Sjfb8856606  * in-order scans to this queue pair. If set, this scan can be retired as soon
750*2d9fd380Sjfb8856606  * as device returns completion. Application should not set out of order scan
751*2d9fd380Sjfb8856606  * flag if it needs to maintain the ingress order of scan request.
752*2d9fd380Sjfb8856606  *
753*2d9fd380Sjfb8856606  * @see struct rte_regexdev_qp_conf::qp_conf_flags
754*2d9fd380Sjfb8856606  * @see rte_regexdev_queue_pair_setup()
755*2d9fd380Sjfb8856606  */
756*2d9fd380Sjfb8856606 
757*2d9fd380Sjfb8856606 struct rte_regex_ops;
758*2d9fd380Sjfb8856606 typedef void (*regexdev_stop_flush_t)(uint8_t dev_id, uint16_t qp_id,
759*2d9fd380Sjfb8856606 				      struct rte_regex_ops *op);
760*2d9fd380Sjfb8856606 /**< Callback function called during rte_regexdev_stop(), invoked once per
761*2d9fd380Sjfb8856606  * flushed RegEx op.
762*2d9fd380Sjfb8856606  */
763*2d9fd380Sjfb8856606 
764*2d9fd380Sjfb8856606 /** RegEx queue pair configuration structure */
765*2d9fd380Sjfb8856606 struct rte_regexdev_qp_conf {
766*2d9fd380Sjfb8856606 	uint32_t qp_conf_flags;
767*2d9fd380Sjfb8856606 	/**< Queue pair config flags, See RTE_REGEX_QUEUE_PAIR_CFG_* */
768*2d9fd380Sjfb8856606 	uint16_t nb_desc;
769*2d9fd380Sjfb8856606 	/**< The number of descriptors to allocate for this queue pair. */
770*2d9fd380Sjfb8856606 	regexdev_stop_flush_t cb;
771*2d9fd380Sjfb8856606 	/**< Callback function called during rte_regexdev_stop(), invoked
772*2d9fd380Sjfb8856606 	 * once per flushed regex op. Value NULL is allowed, in which case
773*2d9fd380Sjfb8856606 	 * callback will not be invoked. This function can be used to properly
774*2d9fd380Sjfb8856606 	 * dispose of outstanding regex ops from response queue,
775*2d9fd380Sjfb8856606 	 * for example ops containing memory pointers.
776*2d9fd380Sjfb8856606 	 * @see rte_regexdev_stop()
777*2d9fd380Sjfb8856606 	 */
778*2d9fd380Sjfb8856606 };
779*2d9fd380Sjfb8856606 
780*2d9fd380Sjfb8856606 /**
781*2d9fd380Sjfb8856606  * @warning
782*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
783*2d9fd380Sjfb8856606  *
784*2d9fd380Sjfb8856606  * Allocate and set up a RegEx queue pair for a RegEx device.
785*2d9fd380Sjfb8856606  *
786*2d9fd380Sjfb8856606  * @param dev_id
787*2d9fd380Sjfb8856606  *   The identifier of the device.
788*2d9fd380Sjfb8856606  * @param queue_pair_id
789*2d9fd380Sjfb8856606  *   The index of the RegEx queue pair to setup. The value must be in the range
790*2d9fd380Sjfb8856606  *   [0, nb_queue_pairs - 1] previously supplied to rte_regexdev_configure().
791*2d9fd380Sjfb8856606  * @param qp_conf
792*2d9fd380Sjfb8856606  *   The pointer to the configuration data to be used for the RegEx queue pair.
793*2d9fd380Sjfb8856606  *   NULL value is allowed, in which case default configuration	used.
794*2d9fd380Sjfb8856606  *
795*2d9fd380Sjfb8856606  * @return
796*2d9fd380Sjfb8856606  *   0 on success. Otherwise negative errno is returned.
797*2d9fd380Sjfb8856606  */
798*2d9fd380Sjfb8856606 __rte_experimental
799*2d9fd380Sjfb8856606 int
800*2d9fd380Sjfb8856606 rte_regexdev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
801*2d9fd380Sjfb8856606 			      const struct rte_regexdev_qp_conf *qp_conf);
802*2d9fd380Sjfb8856606 
803*2d9fd380Sjfb8856606 /**
804*2d9fd380Sjfb8856606  * @warning
805*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
806*2d9fd380Sjfb8856606  *
807*2d9fd380Sjfb8856606  * Start a RegEx device.
808*2d9fd380Sjfb8856606  *
809*2d9fd380Sjfb8856606  * The device start step is the last one and consists of setting the RegEx
810*2d9fd380Sjfb8856606  * queues to start accepting the pattern matching scan requests.
811*2d9fd380Sjfb8856606  *
812*2d9fd380Sjfb8856606  * On success, all basic functions exported by the API (RegEx enqueue,
813*2d9fd380Sjfb8856606  * RegEx dequeue and so on) can be invoked.
814*2d9fd380Sjfb8856606  *
815*2d9fd380Sjfb8856606  * @param dev_id
816*2d9fd380Sjfb8856606  *   RegEx device identifier.
817*2d9fd380Sjfb8856606  *
818*2d9fd380Sjfb8856606  * @return
819*2d9fd380Sjfb8856606  *   0 on success. Otherwise negative errno is returned.
820*2d9fd380Sjfb8856606  */
821*2d9fd380Sjfb8856606 __rte_experimental
822*2d9fd380Sjfb8856606 int
823*2d9fd380Sjfb8856606 rte_regexdev_start(uint8_t dev_id);
824*2d9fd380Sjfb8856606 
825*2d9fd380Sjfb8856606 /**
826*2d9fd380Sjfb8856606  * @warning
827*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
828*2d9fd380Sjfb8856606  *
829*2d9fd380Sjfb8856606  * Stop a RegEx device.
830*2d9fd380Sjfb8856606  *
831*2d9fd380Sjfb8856606  * Stop a RegEx device. The device can be restarted with a call to
832*2d9fd380Sjfb8856606  * rte_regexdev_start().
833*2d9fd380Sjfb8856606  *
834*2d9fd380Sjfb8856606  * This function causes all queued response regex ops to be drained in the
835*2d9fd380Sjfb8856606  * response queue. While draining ops out of the device,
836*2d9fd380Sjfb8856606  * struct rte_regexdev_qp_conf::cb will be invoked for each ops.
837*2d9fd380Sjfb8856606  *
838*2d9fd380Sjfb8856606  * @param dev_id
839*2d9fd380Sjfb8856606  *   RegEx device identifier.
840*2d9fd380Sjfb8856606  *
841*2d9fd380Sjfb8856606  * @return
842*2d9fd380Sjfb8856606  *   0 on success. Otherwise negative errno is returned.
843*2d9fd380Sjfb8856606  */
844*2d9fd380Sjfb8856606 __rte_experimental
845*2d9fd380Sjfb8856606 int
846*2d9fd380Sjfb8856606 rte_regexdev_stop(uint8_t dev_id);
847*2d9fd380Sjfb8856606 
848*2d9fd380Sjfb8856606 /**
849*2d9fd380Sjfb8856606  * @warning
850*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
851*2d9fd380Sjfb8856606  *
852*2d9fd380Sjfb8856606  * Close a RegEx device. The device cannot be restarted!
853*2d9fd380Sjfb8856606  *
854*2d9fd380Sjfb8856606  * @param dev_id
855*2d9fd380Sjfb8856606  *   RegEx device identifier
856*2d9fd380Sjfb8856606  *
857*2d9fd380Sjfb8856606  * @return
858*2d9fd380Sjfb8856606  *   0 on success. Otherwise negative errno is returned.
859*2d9fd380Sjfb8856606  */
860*2d9fd380Sjfb8856606 __rte_experimental
861*2d9fd380Sjfb8856606 int
862*2d9fd380Sjfb8856606 rte_regexdev_close(uint8_t dev_id);
863*2d9fd380Sjfb8856606 
864*2d9fd380Sjfb8856606 /* Device get/set attributes */
865*2d9fd380Sjfb8856606 
866*2d9fd380Sjfb8856606 /** Enumerates RegEx device attribute identifier */
867*2d9fd380Sjfb8856606 enum rte_regexdev_attr_id {
868*2d9fd380Sjfb8856606 	RTE_REGEXDEV_ATTR_SOCKET_ID,
869*2d9fd380Sjfb8856606 	/**< The NUMA socket id to which the device is connected or
870*2d9fd380Sjfb8856606 	 * a default of zero if the socket could not be determined.
871*2d9fd380Sjfb8856606 	 * datatype: *int*
872*2d9fd380Sjfb8856606 	 * operation: *get*
873*2d9fd380Sjfb8856606 	 */
874*2d9fd380Sjfb8856606 	RTE_REGEXDEV_ATTR_MAX_MATCHES,
875*2d9fd380Sjfb8856606 	/**< Maximum number of matches per scan.
876*2d9fd380Sjfb8856606 	 * datatype: *uint8_t*
877*2d9fd380Sjfb8856606 	 * operation: *get* and *set*
878*2d9fd380Sjfb8856606 	 * @see RTE_REGEX_OPS_RSP_MAX_MATCH_F
879*2d9fd380Sjfb8856606 	 */
880*2d9fd380Sjfb8856606 	RTE_REGEXDEV_ATTR_MAX_SCAN_TIMEOUT,
881*2d9fd380Sjfb8856606 	/**< Upper bound scan time in ns.
882*2d9fd380Sjfb8856606 	 * datatype: *uint16_t*
883*2d9fd380Sjfb8856606 	 * operation: *get* and *set*
884*2d9fd380Sjfb8856606 	 * @see RTE_REGEX_OPS_RSP_MAX_SCAN_TIMEOUT_F
885*2d9fd380Sjfb8856606 	 */
886*2d9fd380Sjfb8856606 	RTE_REGEXDEV_ATTR_MAX_PREFIX,
887*2d9fd380Sjfb8856606 	/**< Maximum number of prefix detected per scan.
888*2d9fd380Sjfb8856606 	 * This would be useful for denial of service detection.
889*2d9fd380Sjfb8856606 	 * datatype: *uint16_t*
890*2d9fd380Sjfb8856606 	 * operation: *get* and *set*
891*2d9fd380Sjfb8856606 	 * @see RTE_REGEX_OPS_RSP_MAX_PREFIX_F
892*2d9fd380Sjfb8856606 	 */
893*2d9fd380Sjfb8856606 };
894*2d9fd380Sjfb8856606 
895*2d9fd380Sjfb8856606 /**
896*2d9fd380Sjfb8856606  * @warning
897*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
898*2d9fd380Sjfb8856606  *
899*2d9fd380Sjfb8856606  * Get an attribute from a RegEx device.
900*2d9fd380Sjfb8856606  *
901*2d9fd380Sjfb8856606  * @param dev_id
902*2d9fd380Sjfb8856606  *   RegEx device identifier.
903*2d9fd380Sjfb8856606  * @param attr_id
904*2d9fd380Sjfb8856606  *   The attribute ID to retrieve.
905*2d9fd380Sjfb8856606  * @param attr_value
906*2d9fd380Sjfb8856606  *   A pointer that will be filled in with the attribute
907*2d9fd380Sjfb8856606  *   value if successful.
908*2d9fd380Sjfb8856606  *
909*2d9fd380Sjfb8856606  * @return
910*2d9fd380Sjfb8856606  *   - 0: Successfully retrieved attribute value.
911*2d9fd380Sjfb8856606  *   - -EINVAL: Invalid device or  *attr_id* provided, or *attr_value* is NULL.
912*2d9fd380Sjfb8856606  *   - -ENOTSUP: if the device doesn't support specific *attr_id*.
913*2d9fd380Sjfb8856606  */
914*2d9fd380Sjfb8856606 __rte_experimental
915*2d9fd380Sjfb8856606 int
916*2d9fd380Sjfb8856606 rte_regexdev_attr_get(uint8_t dev_id, enum rte_regexdev_attr_id attr_id,
917*2d9fd380Sjfb8856606 		      void *attr_value);
918*2d9fd380Sjfb8856606 
919*2d9fd380Sjfb8856606 /**
920*2d9fd380Sjfb8856606  * @warning
921*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
922*2d9fd380Sjfb8856606  *
923*2d9fd380Sjfb8856606  * Set an attribute to a RegEx device.
924*2d9fd380Sjfb8856606  *
925*2d9fd380Sjfb8856606  * @param dev_id
926*2d9fd380Sjfb8856606  *   RegEx device identifier.
927*2d9fd380Sjfb8856606  * @param attr_id
928*2d9fd380Sjfb8856606  *   The attribute ID to retrieve.
929*2d9fd380Sjfb8856606  * @param attr_value
930*2d9fd380Sjfb8856606  *   Pointer that will be filled in with the attribute value
931*2d9fd380Sjfb8856606  *   by the application.
932*2d9fd380Sjfb8856606  *
933*2d9fd380Sjfb8856606  * @return
934*2d9fd380Sjfb8856606  *   - 0: Successfully applied the attribute value.
935*2d9fd380Sjfb8856606  *   - -EINVAL: Invalid device or  *attr_id* provided, or *attr_value* is NULL.
936*2d9fd380Sjfb8856606  *   - -ENOTSUP: if the device doesn't support specific *attr_id*.
937*2d9fd380Sjfb8856606  */
938*2d9fd380Sjfb8856606 __rte_experimental
939*2d9fd380Sjfb8856606 int
940*2d9fd380Sjfb8856606 rte_regexdev_attr_set(uint8_t dev_id, enum rte_regexdev_attr_id attr_id,
941*2d9fd380Sjfb8856606 		      const void *attr_value);
942*2d9fd380Sjfb8856606 
943*2d9fd380Sjfb8856606 /* Rule related APIs */
944*2d9fd380Sjfb8856606 /** Enumerates RegEx rule operation. */
945*2d9fd380Sjfb8856606 enum rte_regexdev_rule_op {
946*2d9fd380Sjfb8856606 	RTE_REGEX_RULE_OP_ADD,
947*2d9fd380Sjfb8856606 	/**< Add RegEx rule to rule database. */
948*2d9fd380Sjfb8856606 	RTE_REGEX_RULE_OP_REMOVE
949*2d9fd380Sjfb8856606 	/**< Remove RegEx rule from rule database. */
950*2d9fd380Sjfb8856606 };
951*2d9fd380Sjfb8856606 
952*2d9fd380Sjfb8856606 /** Structure to hold a RegEx rule attributes. */
953*2d9fd380Sjfb8856606 struct rte_regexdev_rule {
954*2d9fd380Sjfb8856606 	enum rte_regexdev_rule_op op;
955*2d9fd380Sjfb8856606 	/**< OP type of the rule either a OP_ADD or OP_DELETE. */
956*2d9fd380Sjfb8856606 	uint16_t group_id;
957*2d9fd380Sjfb8856606 	/**< Group identifier to which the rule belongs to. */
958*2d9fd380Sjfb8856606 	uint32_t rule_id;
959*2d9fd380Sjfb8856606 	/**< Rule identifier which is returned on successful match. */
960*2d9fd380Sjfb8856606 	const char *pcre_rule;
961*2d9fd380Sjfb8856606 	/**< Buffer to hold the PCRE rule. */
962*2d9fd380Sjfb8856606 	uint16_t pcre_rule_len;
963*2d9fd380Sjfb8856606 	/**< Length of the PCRE rule. */
964*2d9fd380Sjfb8856606 	uint64_t rule_flags;
965*2d9fd380Sjfb8856606 	/* PCRE rule flags. Supported device specific PCRE rules enumerated
966*2d9fd380Sjfb8856606 	 * in struct rte_regexdev_info::rule_flags. For successful rule
967*2d9fd380Sjfb8856606 	 * database update, application needs to provide only supported
968*2d9fd380Sjfb8856606 	 * rule flags.
969*2d9fd380Sjfb8856606 	 * @See RTE_REGEX_PCRE_RULE_*, struct rte_regexdev_info::rule_flags
970*2d9fd380Sjfb8856606 	 */
971*2d9fd380Sjfb8856606 };
972*2d9fd380Sjfb8856606 
973*2d9fd380Sjfb8856606 /**
974*2d9fd380Sjfb8856606  * @warning
975*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
976*2d9fd380Sjfb8856606  *
977*2d9fd380Sjfb8856606  * Update the local rule set.
978*2d9fd380Sjfb8856606  * This functions only modify the rule set in memory.
979*2d9fd380Sjfb8856606  * In order for the changes to take effect, the function
980*2d9fd380Sjfb8856606  * rte_regexdev_rule_db_compile_active must be called.
981*2d9fd380Sjfb8856606  *
982*2d9fd380Sjfb8856606  * @param dev_id
983*2d9fd380Sjfb8856606  *   RegEx device identifier.
984*2d9fd380Sjfb8856606  * @param rules
985*2d9fd380Sjfb8856606  *   Points to an array of *nb_rules* objects of type *rte_regexdev_rule*
986*2d9fd380Sjfb8856606  *   structure which contain the regex rules attributes to be updated
987*2d9fd380Sjfb8856606  *   in rule database.
988*2d9fd380Sjfb8856606  * @param nb_rules
989*2d9fd380Sjfb8856606  *   The number of PCRE rules to update the rule database.
990*2d9fd380Sjfb8856606  *
991*2d9fd380Sjfb8856606  * @return
992*2d9fd380Sjfb8856606  *   The number of regex rules actually updated on the regex device's rule
993*2d9fd380Sjfb8856606  *   database. The return value can be less than the value of the *nb_rules*
994*2d9fd380Sjfb8856606  *   parameter when the regex devices fails to update the rule database or
995*2d9fd380Sjfb8856606  *   if invalid parameters are specified in a *rte_regexdev_rule*.
996*2d9fd380Sjfb8856606  *   If the return value is less than *nb_rules*, the remaining PCRE rules
997*2d9fd380Sjfb8856606  *   at the end of *rules* are not consumed and the caller has to take
998*2d9fd380Sjfb8856606  *   care of them and rte_errno is set accordingly.
999*2d9fd380Sjfb8856606  *   Possible errno values include:
1000*2d9fd380Sjfb8856606  *   - -EINVAL:  Invalid device ID or rules is NULL
1001*2d9fd380Sjfb8856606  *   - -ENOTSUP: The last processed rule is not supported on this device.
1002*2d9fd380Sjfb8856606  *   - -ENOSPC: No space available in rule database.
1003*2d9fd380Sjfb8856606  *
1004*2d9fd380Sjfb8856606  * @see rte_regexdev_rule_db_import(), rte_regexdev_rule_db_export(),
1005*2d9fd380Sjfb8856606  *   rte_regexdev_rule_db_compile_activate()
1006*2d9fd380Sjfb8856606  */
1007*2d9fd380Sjfb8856606 __rte_experimental
1008*2d9fd380Sjfb8856606 int
1009*2d9fd380Sjfb8856606 rte_regexdev_rule_db_update(uint8_t dev_id,
1010*2d9fd380Sjfb8856606 			    const struct rte_regexdev_rule *rules,
1011*2d9fd380Sjfb8856606 			    uint32_t nb_rules);
1012*2d9fd380Sjfb8856606 
1013*2d9fd380Sjfb8856606 /**
1014*2d9fd380Sjfb8856606  * @warning
1015*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
1016*2d9fd380Sjfb8856606  *
1017*2d9fd380Sjfb8856606  * Compile local rule set and burn the complied result to the
1018*2d9fd380Sjfb8856606  * RegEx deive.
1019*2d9fd380Sjfb8856606  *
1020*2d9fd380Sjfb8856606  * @param dev_id
1021*2d9fd380Sjfb8856606  *   RegEx device identifier.
1022*2d9fd380Sjfb8856606  *
1023*2d9fd380Sjfb8856606  * @return
1024*2d9fd380Sjfb8856606  *   0 on success, otherwise negative errno.
1025*2d9fd380Sjfb8856606  *
1026*2d9fd380Sjfb8856606  * @see rte_regexdev_rule_db_import(), rte_regexdev_rule_db_export(),
1027*2d9fd380Sjfb8856606  *   rte_regexdev_rule_db_update()
1028*2d9fd380Sjfb8856606  */
1029*2d9fd380Sjfb8856606 __rte_experimental
1030*2d9fd380Sjfb8856606 int
1031*2d9fd380Sjfb8856606 rte_regexdev_rule_db_compile_activate(uint8_t dev_id);
1032*2d9fd380Sjfb8856606 
1033*2d9fd380Sjfb8856606 /**
1034*2d9fd380Sjfb8856606  * @warning
1035*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
1036*2d9fd380Sjfb8856606  *
1037*2d9fd380Sjfb8856606  * Import a prebuilt rule database from a buffer to a RegEx device.
1038*2d9fd380Sjfb8856606  *
1039*2d9fd380Sjfb8856606  * @param dev_id
1040*2d9fd380Sjfb8856606  *   RegEx device identifier.
1041*2d9fd380Sjfb8856606  * @param rule_db
1042*2d9fd380Sjfb8856606  *   Points to prebuilt rule database.
1043*2d9fd380Sjfb8856606  * @param rule_db_len
1044*2d9fd380Sjfb8856606  *   Length of the rule database.
1045*2d9fd380Sjfb8856606  *
1046*2d9fd380Sjfb8856606  * @return
1047*2d9fd380Sjfb8856606  *   - 0: Successfully updated the prebuilt rule database.
1048*2d9fd380Sjfb8856606  *   - -EINVAL:  Invalid device ID or rule_db is NULL
1049*2d9fd380Sjfb8856606  *   - -ENOTSUP: Rule database import is not supported on this device.
1050*2d9fd380Sjfb8856606  *   - -ENOSPC: No space available in rule database.
1051*2d9fd380Sjfb8856606  *
1052*2d9fd380Sjfb8856606  * @see rte_regexdev_rule_db_update(), rte_regexdev_rule_db_export()
1053*2d9fd380Sjfb8856606  */
1054*2d9fd380Sjfb8856606 __rte_experimental
1055*2d9fd380Sjfb8856606 int
1056*2d9fd380Sjfb8856606 rte_regexdev_rule_db_import(uint8_t dev_id, const char *rule_db,
1057*2d9fd380Sjfb8856606 			    uint32_t rule_db_len);
1058*2d9fd380Sjfb8856606 
1059*2d9fd380Sjfb8856606 /**
1060*2d9fd380Sjfb8856606  * @warning
1061*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
1062*2d9fd380Sjfb8856606  *
1063*2d9fd380Sjfb8856606  * Export the prebuilt rule database from a RegEx device to the buffer.
1064*2d9fd380Sjfb8856606  *
1065*2d9fd380Sjfb8856606  * @param dev_id
1066*2d9fd380Sjfb8856606  *   RegEx device identifier.
1067*2d9fd380Sjfb8856606  * @param[out] rule_db
1068*2d9fd380Sjfb8856606  *   Block of memory to insert the rule database. Must be at least size in
1069*2d9fd380Sjfb8856606  *   capacity. If set to NULL, function returns required capacity.
1070*2d9fd380Sjfb8856606  *
1071*2d9fd380Sjfb8856606  * @return
1072*2d9fd380Sjfb8856606  *   - 0: Successfully exported the prebuilt rule database.
1073*2d9fd380Sjfb8856606  *   - size: If rule_db set to NULL then required capacity for *rule_db*
1074*2d9fd380Sjfb8856606  *   - -EINVAL:  Invalid device ID
1075*2d9fd380Sjfb8856606  *   - -ENOTSUP: Rule database export is not supported on this device.
1076*2d9fd380Sjfb8856606  *
1077*2d9fd380Sjfb8856606  * @see rte_regexdev_rule_db_update(), rte_regexdev_rule_db_import()
1078*2d9fd380Sjfb8856606  */
1079*2d9fd380Sjfb8856606 __rte_experimental
1080*2d9fd380Sjfb8856606 int
1081*2d9fd380Sjfb8856606 rte_regexdev_rule_db_export(uint8_t dev_id, char *rule_db);
1082*2d9fd380Sjfb8856606 
1083*2d9fd380Sjfb8856606 /* Extended statistics */
1084*2d9fd380Sjfb8856606 /** Maximum name length for extended statistics counters */
1085*2d9fd380Sjfb8856606 #define RTE_REGEXDEV_XSTATS_NAME_SIZE 64
1086*2d9fd380Sjfb8856606 
1087*2d9fd380Sjfb8856606 /**
1088*2d9fd380Sjfb8856606  * A name-key lookup element for extended statistics.
1089*2d9fd380Sjfb8856606  *
1090*2d9fd380Sjfb8856606  * This structure is used to map between names and ID numbers
1091*2d9fd380Sjfb8856606  * for extended RegEx device statistics.
1092*2d9fd380Sjfb8856606  */
1093*2d9fd380Sjfb8856606 struct rte_regexdev_xstats_map {
1094*2d9fd380Sjfb8856606 	uint16_t id;
1095*2d9fd380Sjfb8856606 	/**< xstat identifier */
1096*2d9fd380Sjfb8856606 	char name[RTE_REGEXDEV_XSTATS_NAME_SIZE];
1097*2d9fd380Sjfb8856606 	/**< xstat name */
1098*2d9fd380Sjfb8856606 };
1099*2d9fd380Sjfb8856606 
1100*2d9fd380Sjfb8856606 /**
1101*2d9fd380Sjfb8856606  * @warning
1102*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
1103*2d9fd380Sjfb8856606  *
1104*2d9fd380Sjfb8856606  * Retrieve names of extended statistics of a regex device.
1105*2d9fd380Sjfb8856606  *
1106*2d9fd380Sjfb8856606  * @param dev_id
1107*2d9fd380Sjfb8856606  *   The identifier of the regex device.
1108*2d9fd380Sjfb8856606  * @param[out] xstats_map
1109*2d9fd380Sjfb8856606  *   Block of memory to insert id and names into. Must be at least size in
1110*2d9fd380Sjfb8856606  *   capacity. If set to NULL, function returns required capacity.
1111*2d9fd380Sjfb8856606  * @return
1112*2d9fd380Sjfb8856606  *   - Positive value on success:
1113*2d9fd380Sjfb8856606  *        -The return value is the number of entries filled in the stats map.
1114*2d9fd380Sjfb8856606  *        -If xstats_map set to NULL then required capacity for xstats_map.
1115*2d9fd380Sjfb8856606  *   - Negative value on error:
1116*2d9fd380Sjfb8856606  *      -ENODEV for invalid *dev_id*
1117*2d9fd380Sjfb8856606  *      -ENOTSUP if the device doesn't support this function.
1118*2d9fd380Sjfb8856606  */
1119*2d9fd380Sjfb8856606 __rte_experimental
1120*2d9fd380Sjfb8856606 int
1121*2d9fd380Sjfb8856606 rte_regexdev_xstats_names_get(uint8_t dev_id,
1122*2d9fd380Sjfb8856606 			      struct rte_regexdev_xstats_map *xstats_map);
1123*2d9fd380Sjfb8856606 
1124*2d9fd380Sjfb8856606 /**
1125*2d9fd380Sjfb8856606  * @warning
1126*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
1127*2d9fd380Sjfb8856606  *
1128*2d9fd380Sjfb8856606  * Retrieve extended statistics of an regex device.
1129*2d9fd380Sjfb8856606  *
1130*2d9fd380Sjfb8856606  * @param dev_id
1131*2d9fd380Sjfb8856606  *   The identifier of the device.
1132*2d9fd380Sjfb8856606  * @param ids
1133*2d9fd380Sjfb8856606  *   The id numbers of the stats to get. The ids can be got from the stat
1134*2d9fd380Sjfb8856606  *   position in the stat list from rte_regexdev_xstats_names_get(), or
1135*2d9fd380Sjfb8856606  *   by using rte_regexdev_xstats_by_name_get().
1136*2d9fd380Sjfb8856606  * @param values
1137*2d9fd380Sjfb8856606  *   The values for each stats request by ID.
1138*2d9fd380Sjfb8856606  * @param nb_values
1139*2d9fd380Sjfb8856606  *   The number of stats requested.
1140*2d9fd380Sjfb8856606  * @return
1141*2d9fd380Sjfb8856606  *   - Positive value: number of stat entries filled into the values array
1142*2d9fd380Sjfb8856606  *   - Negative value on error:
1143*2d9fd380Sjfb8856606  *      -ENODEV for invalid *dev_id*
1144*2d9fd380Sjfb8856606  *      -ENOTSUP if the device doesn't support this function.
1145*2d9fd380Sjfb8856606  */
1146*2d9fd380Sjfb8856606 __rte_experimental
1147*2d9fd380Sjfb8856606 int
1148*2d9fd380Sjfb8856606 rte_regexdev_xstats_get(uint8_t dev_id, const uint16_t *ids,
1149*2d9fd380Sjfb8856606 			uint64_t *values, uint16_t nb_values);
1150*2d9fd380Sjfb8856606 
1151*2d9fd380Sjfb8856606 /**
1152*2d9fd380Sjfb8856606  * @warning
1153*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
1154*2d9fd380Sjfb8856606  *
1155*2d9fd380Sjfb8856606  * Retrieve the value of a single stat by requesting it by name.
1156*2d9fd380Sjfb8856606  *
1157*2d9fd380Sjfb8856606  * @param dev_id
1158*2d9fd380Sjfb8856606  *   The identifier of the device.
1159*2d9fd380Sjfb8856606  * @param name
1160*2d9fd380Sjfb8856606  *   The stat name to retrieve.
1161*2d9fd380Sjfb8856606  * @param id
1162*2d9fd380Sjfb8856606  *   If non-NULL, the numerical id of the stat will be returned, so that further
1163*2d9fd380Sjfb8856606  *   requests for the stat can be got using rte_regexdev_xstats_get, which will
1164*2d9fd380Sjfb8856606  *   be faster as it doesn't need to scan a list of names for the stat.
1165*2d9fd380Sjfb8856606  * @param[out] value
1166*2d9fd380Sjfb8856606  *   Must be non-NULL, retrieved xstat value will be stored in this address.
1167*2d9fd380Sjfb8856606  *
1168*2d9fd380Sjfb8856606  * @return
1169*2d9fd380Sjfb8856606  *   - 0: Successfully retrieved xstat value.
1170*2d9fd380Sjfb8856606  *   - -EINVAL: invalid parameters
1171*2d9fd380Sjfb8856606  *   - -ENOTSUP: if not supported.
1172*2d9fd380Sjfb8856606  */
1173*2d9fd380Sjfb8856606 __rte_experimental
1174*2d9fd380Sjfb8856606 int
1175*2d9fd380Sjfb8856606 rte_regexdev_xstats_by_name_get(uint8_t dev_id, const char *name,
1176*2d9fd380Sjfb8856606 				uint16_t *id, uint64_t *value);
1177*2d9fd380Sjfb8856606 
1178*2d9fd380Sjfb8856606 /**
1179*2d9fd380Sjfb8856606  * @warning
1180*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
1181*2d9fd380Sjfb8856606  *
1182*2d9fd380Sjfb8856606  * Reset the values of the xstats of the selected component in the device.
1183*2d9fd380Sjfb8856606  *
1184*2d9fd380Sjfb8856606  * @param dev_id
1185*2d9fd380Sjfb8856606  *   The identifier of the device.
1186*2d9fd380Sjfb8856606  * @param ids
1187*2d9fd380Sjfb8856606  *   Selects specific statistics to be reset. When NULL, all statistics will be
1188*2d9fd380Sjfb8856606  *   reset. If non-NULL, must point to array of at least *nb_ids* size.
1189*2d9fd380Sjfb8856606  * @param nb_ids
1190*2d9fd380Sjfb8856606  *   The number of ids available from the *ids* array. Ignored when ids is NULL.
1191*2d9fd380Sjfb8856606  *
1192*2d9fd380Sjfb8856606  * @return
1193*2d9fd380Sjfb8856606  *   - 0: Successfully reset the statistics to zero.
1194*2d9fd380Sjfb8856606  *   - -EINVAL: invalid parameters.
1195*2d9fd380Sjfb8856606  *   - -ENOTSUP: if not supported.
1196*2d9fd380Sjfb8856606  */
1197*2d9fd380Sjfb8856606 __rte_experimental
1198*2d9fd380Sjfb8856606 int
1199*2d9fd380Sjfb8856606 rte_regexdev_xstats_reset(uint8_t dev_id, const uint16_t *ids,
1200*2d9fd380Sjfb8856606 			  uint16_t nb_ids);
1201*2d9fd380Sjfb8856606 
1202*2d9fd380Sjfb8856606 /**
1203*2d9fd380Sjfb8856606  * @warning
1204*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
1205*2d9fd380Sjfb8856606  *
1206*2d9fd380Sjfb8856606  * Trigger the RegEx device self test.
1207*2d9fd380Sjfb8856606  *
1208*2d9fd380Sjfb8856606  * @param dev_id
1209*2d9fd380Sjfb8856606  *   The identifier of the device.
1210*2d9fd380Sjfb8856606  * @return
1211*2d9fd380Sjfb8856606  *   - 0: Selftest successful.
1212*2d9fd380Sjfb8856606  *   - -ENOTSUP if the device doesn't support selftest.
1213*2d9fd380Sjfb8856606  *   - other values < 0 on failure.
1214*2d9fd380Sjfb8856606  */
1215*2d9fd380Sjfb8856606 __rte_experimental
1216*2d9fd380Sjfb8856606 int
1217*2d9fd380Sjfb8856606 rte_regexdev_selftest(uint8_t dev_id);
1218*2d9fd380Sjfb8856606 
1219*2d9fd380Sjfb8856606 /**
1220*2d9fd380Sjfb8856606  * @warning
1221*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
1222*2d9fd380Sjfb8856606  *
1223*2d9fd380Sjfb8856606  * Dump internal information about *dev_id* to the FILE* provided in *f*.
1224*2d9fd380Sjfb8856606  *
1225*2d9fd380Sjfb8856606  * @param dev_id
1226*2d9fd380Sjfb8856606  *   The identifier of the device.
1227*2d9fd380Sjfb8856606  * @param f
1228*2d9fd380Sjfb8856606  *   A pointer to a file for output.
1229*2d9fd380Sjfb8856606  *
1230*2d9fd380Sjfb8856606  * @return
1231*2d9fd380Sjfb8856606  *   0 on success, negative errno on failure.
1232*2d9fd380Sjfb8856606  */
1233*2d9fd380Sjfb8856606 __rte_experimental
1234*2d9fd380Sjfb8856606 int
1235*2d9fd380Sjfb8856606 rte_regexdev_dump(uint8_t dev_id, FILE *f);
1236*2d9fd380Sjfb8856606 
1237*2d9fd380Sjfb8856606 /* Fast path APIs */
1238*2d9fd380Sjfb8856606 
1239*2d9fd380Sjfb8856606 /**
1240*2d9fd380Sjfb8856606  * The generic *rte_regexdev_match* structure to hold the RegEx match
1241*2d9fd380Sjfb8856606  * attributes.
1242*2d9fd380Sjfb8856606  * @see struct rte_regex_ops::matches
1243*2d9fd380Sjfb8856606  */
1244*2d9fd380Sjfb8856606 struct rte_regexdev_match {
1245*2d9fd380Sjfb8856606 	RTE_STD_C11
1246*2d9fd380Sjfb8856606 	union {
1247*2d9fd380Sjfb8856606 		uint64_t u64;
1248*2d9fd380Sjfb8856606 		struct {
1249*2d9fd380Sjfb8856606 			uint32_t rule_id:20;
1250*2d9fd380Sjfb8856606 			/**< Rule identifier to which the pattern matched.
1251*2d9fd380Sjfb8856606 			 * @see struct rte_regexdev_rule::rule_id
1252*2d9fd380Sjfb8856606 			 */
1253*2d9fd380Sjfb8856606 			uint32_t group_id:12;
1254*2d9fd380Sjfb8856606 			/**< Group identifier of the rule which the pattern
1255*2d9fd380Sjfb8856606 			 * matched. @see struct rte_regexdev_rule::group_id
1256*2d9fd380Sjfb8856606 			 */
1257*2d9fd380Sjfb8856606 			uint16_t start_offset;
1258*2d9fd380Sjfb8856606 			/**< Starting Byte Position for matched rule. */
1259*2d9fd380Sjfb8856606 			RTE_STD_C11
1260*2d9fd380Sjfb8856606 			union {
1261*2d9fd380Sjfb8856606 				uint16_t len;
1262*2d9fd380Sjfb8856606 				/**< Length of match in bytes */
1263*2d9fd380Sjfb8856606 				uint16_t end_offset;
1264*2d9fd380Sjfb8856606 				/**< The end offset of the match. In case
1265*2d9fd380Sjfb8856606 				 * MATCH_AS_END configuration is enabled.
1266*2d9fd380Sjfb8856606 				 * @see RTE_REGEXDEV_CFG_MATCH_AS_END
1267*2d9fd380Sjfb8856606 				 */
1268*2d9fd380Sjfb8856606 			};
1269*2d9fd380Sjfb8856606 		};
1270*2d9fd380Sjfb8856606 	};
1271*2d9fd380Sjfb8856606 };
1272*2d9fd380Sjfb8856606 
1273*2d9fd380Sjfb8856606 /* Enumerates RegEx request flags. */
1274*2d9fd380Sjfb8856606 #define RTE_REGEX_OPS_REQ_GROUP_ID0_VALID_F (1 << 0)
1275*2d9fd380Sjfb8856606 /**< Set when struct rte_regexdev_rule::group_id0 is valid. */
1276*2d9fd380Sjfb8856606 
1277*2d9fd380Sjfb8856606 #define RTE_REGEX_OPS_REQ_GROUP_ID1_VALID_F (1 << 1)
1278*2d9fd380Sjfb8856606 /**< Set when struct rte_regexdev_rule::group_id1 is valid. */
1279*2d9fd380Sjfb8856606 
1280*2d9fd380Sjfb8856606 #define RTE_REGEX_OPS_REQ_GROUP_ID2_VALID_F (1 << 2)
1281*2d9fd380Sjfb8856606 /**< Set when struct rte_regexdev_rule::group_id2 is valid. */
1282*2d9fd380Sjfb8856606 
1283*2d9fd380Sjfb8856606 #define RTE_REGEX_OPS_REQ_GROUP_ID3_VALID_F (1 << 3)
1284*2d9fd380Sjfb8856606 /**< Set when struct rte_regexdev_rule::group_id3 is valid. */
1285*2d9fd380Sjfb8856606 
1286*2d9fd380Sjfb8856606 #define RTE_REGEX_OPS_REQ_STOP_ON_MATCH_F (1 << 4)
1287*2d9fd380Sjfb8856606 /**< The RegEx engine will stop scanning and return the first match. */
1288*2d9fd380Sjfb8856606 
1289*2d9fd380Sjfb8856606 #define RTE_REGEX_OPS_REQ_MATCH_HIGH_PRIORITY_F (1 << 5)
1290*2d9fd380Sjfb8856606 /**< In High Priority mode a maximum of one match will be returned per scan to
1291*2d9fd380Sjfb8856606  * reduce the post-processing required by the application. The match with the
1292*2d9fd380Sjfb8856606  * lowest Rule id, lowest start pointer and lowest match length will be
1293*2d9fd380Sjfb8856606  * returned.
1294*2d9fd380Sjfb8856606  *
1295*2d9fd380Sjfb8856606  * @see struct rte_regex_ops::nb_actual_matches
1296*2d9fd380Sjfb8856606  * @see struct rte_regex_ops::nb_matches
1297*2d9fd380Sjfb8856606  */
1298*2d9fd380Sjfb8856606 
1299*2d9fd380Sjfb8856606 
1300*2d9fd380Sjfb8856606 /* Enumerates RegEx response flags. */
1301*2d9fd380Sjfb8856606 #define RTE_REGEX_OPS_RSP_PMI_SOJ_F (1 << 0)
1302*2d9fd380Sjfb8856606 /**< Indicates that the RegEx device has encountered a partial match at the
1303*2d9fd380Sjfb8856606  * start of scan in the given buffer.
1304*2d9fd380Sjfb8856606  *
1305*2d9fd380Sjfb8856606  * @see RTE_REGEXDEV_CFG_CROSS_BUFFER_SCAN_F
1306*2d9fd380Sjfb8856606  */
1307*2d9fd380Sjfb8856606 
1308*2d9fd380Sjfb8856606 #define RTE_REGEX_OPS_RSP_PMI_EOJ_F (1 << 1)
1309*2d9fd380Sjfb8856606 /**< Indicates that the RegEx device has encountered a partial match at the
1310*2d9fd380Sjfb8856606  * end of scan in the given buffer.
1311*2d9fd380Sjfb8856606  *
1312*2d9fd380Sjfb8856606  * @see RTE_REGEXDEV_CFG_CROSS_BUFFER_SCAN_F
1313*2d9fd380Sjfb8856606  */
1314*2d9fd380Sjfb8856606 
1315*2d9fd380Sjfb8856606 #define RTE_REGEX_OPS_RSP_MAX_SCAN_TIMEOUT_F (1 << 2)
1316*2d9fd380Sjfb8856606 /**< Indicates that the RegEx device has exceeded the max timeout while
1317*2d9fd380Sjfb8856606  * scanning the given buffer.
1318*2d9fd380Sjfb8856606  *
1319*2d9fd380Sjfb8856606  * @see RTE_REGEXDEV_ATTR_MAX_SCAN_TIMEOUT
1320*2d9fd380Sjfb8856606  */
1321*2d9fd380Sjfb8856606 
1322*2d9fd380Sjfb8856606 #define RTE_REGEX_OPS_RSP_MAX_MATCH_F (1 << 3)
1323*2d9fd380Sjfb8856606 /**< Indicates that the RegEx device has exceeded the max matches while
1324*2d9fd380Sjfb8856606  * scanning the given buffer.
1325*2d9fd380Sjfb8856606  *
1326*2d9fd380Sjfb8856606  * @see RTE_REGEXDEV_ATTR_MAX_MATCHES
1327*2d9fd380Sjfb8856606  */
1328*2d9fd380Sjfb8856606 
1329*2d9fd380Sjfb8856606 #define RTE_REGEX_OPS_RSP_MAX_PREFIX_F (1 << 4)
1330*2d9fd380Sjfb8856606 /**< Indicates that the RegEx device has reached the max allowed prefix length
1331*2d9fd380Sjfb8856606  * while scanning the given buffer.
1332*2d9fd380Sjfb8856606  *
1333*2d9fd380Sjfb8856606  * @see RTE_REGEXDEV_ATTR_MAX_PREFIX
1334*2d9fd380Sjfb8856606  */
1335*2d9fd380Sjfb8856606 
1336*2d9fd380Sjfb8856606 /**
1337*2d9fd380Sjfb8856606  * The generic *rte_regex_ops* structure to hold the RegEx attributes
1338*2d9fd380Sjfb8856606  * for enqueue and dequeue operation.
1339*2d9fd380Sjfb8856606  */
1340*2d9fd380Sjfb8856606 struct rte_regex_ops {
1341*2d9fd380Sjfb8856606 	/* W0 */
1342*2d9fd380Sjfb8856606 	uint16_t req_flags;
1343*2d9fd380Sjfb8856606 	/**< Request flags for the RegEx ops.
1344*2d9fd380Sjfb8856606 	 * @see RTE_REGEX_OPS_REQ_*
1345*2d9fd380Sjfb8856606 	 */
1346*2d9fd380Sjfb8856606 	uint16_t rsp_flags;
1347*2d9fd380Sjfb8856606 	/**< Response flags for the RegEx ops.
1348*2d9fd380Sjfb8856606 	 * @see RTE_REGEX_OPS_RSP_*
1349*2d9fd380Sjfb8856606 	 */
1350*2d9fd380Sjfb8856606 	uint16_t nb_actual_matches;
1351*2d9fd380Sjfb8856606 	/**< The total number of actual matches detected by the Regex device.*/
1352*2d9fd380Sjfb8856606 	uint16_t nb_matches;
1353*2d9fd380Sjfb8856606 	/**< The total number of matches returned by the RegEx device for this
1354*2d9fd380Sjfb8856606 	 * scan. The size of *rte_regex_ops::matches* zero length array will be
1355*2d9fd380Sjfb8856606 	 * this value.
1356*2d9fd380Sjfb8856606 	 *
1357*2d9fd380Sjfb8856606 	 * @see struct rte_regex_ops::matches, struct rte_regexdev_match
1358*2d9fd380Sjfb8856606 	 */
1359*2d9fd380Sjfb8856606 
1360*2d9fd380Sjfb8856606 	/* W1 */
1361*2d9fd380Sjfb8856606 	struct rte_mbuf *mbuf; /**< source mbuf, to search in. */
1362*2d9fd380Sjfb8856606 
1363*2d9fd380Sjfb8856606 	/* W2 */
1364*2d9fd380Sjfb8856606 	uint16_t group_id0;
1365*2d9fd380Sjfb8856606 	/**< First group_id to match the rule against. At minimum one group
1366*2d9fd380Sjfb8856606 	 * should be valid. Behaviour is undefined non of the groups are valid.
1367*2d9fd380Sjfb8856606 	 *
1368*2d9fd380Sjfb8856606 	 * @see RTE_REGEX_OPS_REQ_GROUP_ID0_VALID_F
1369*2d9fd380Sjfb8856606 	 */
1370*2d9fd380Sjfb8856606 	uint16_t group_id1;
1371*2d9fd380Sjfb8856606 	/**< Second group_id to match the rule against.
1372*2d9fd380Sjfb8856606 	 *
1373*2d9fd380Sjfb8856606 	 * @see RTE_REGEX_OPS_REQ_GROUP_ID1_VALID_F
1374*2d9fd380Sjfb8856606 	 */
1375*2d9fd380Sjfb8856606 	uint16_t group_id2;
1376*2d9fd380Sjfb8856606 	/**< Third group_id to match the rule against.
1377*2d9fd380Sjfb8856606 	 *
1378*2d9fd380Sjfb8856606 	 * @see RTE_REGEX_OPS_REQ_GROUP_ID2_VALID_F
1379*2d9fd380Sjfb8856606 	 */
1380*2d9fd380Sjfb8856606 	uint16_t group_id3;
1381*2d9fd380Sjfb8856606 	/**< Forth group_id to match the rule against.
1382*2d9fd380Sjfb8856606 	 *
1383*2d9fd380Sjfb8856606 	 * @see RTE_REGEX_OPS_REQ_GROUP_ID3_VALID_F
1384*2d9fd380Sjfb8856606 	 */
1385*2d9fd380Sjfb8856606 
1386*2d9fd380Sjfb8856606 	/* W3 */
1387*2d9fd380Sjfb8856606 	RTE_STD_C11
1388*2d9fd380Sjfb8856606 	union {
1389*2d9fd380Sjfb8856606 		uint64_t user_id;
1390*2d9fd380Sjfb8856606 		/**< Application specific opaque value. An application may use
1391*2d9fd380Sjfb8856606 		 * this field to hold application specific value to share
1392*2d9fd380Sjfb8856606 		 * between dequeue and enqueue operation.
1393*2d9fd380Sjfb8856606 		 * Implementation should not modify this field.
1394*2d9fd380Sjfb8856606 		 */
1395*2d9fd380Sjfb8856606 		void *user_ptr;
1396*2d9fd380Sjfb8856606 		/**< Pointer representation of *user_id* */
1397*2d9fd380Sjfb8856606 	};
1398*2d9fd380Sjfb8856606 
1399*2d9fd380Sjfb8856606 	/* W4 */
1400*2d9fd380Sjfb8856606 	RTE_STD_C11
1401*2d9fd380Sjfb8856606 	union {
1402*2d9fd380Sjfb8856606 		uint64_t cross_buf_id;
1403*2d9fd380Sjfb8856606 		/**< ID used by the RegEx device in order to support cross
1404*2d9fd380Sjfb8856606 		 * packet detection.
1405*2d9fd380Sjfb8856606 		 * This ID is returned from the RegEx device on the dequeue
1406*2d9fd380Sjfb8856606 		 * function. The application must send it back when calling
1407*2d9fd380Sjfb8856606 		 * enqueue with the following packet.
1408*2d9fd380Sjfb8856606 		 */
1409*2d9fd380Sjfb8856606 		void *cross_buf_ptr;
1410*2d9fd380Sjfb8856606 		/**< Pointer representation of *corss_buf_id* */
1411*2d9fd380Sjfb8856606 	};
1412*2d9fd380Sjfb8856606 
1413*2d9fd380Sjfb8856606 	/* W5 */
1414*2d9fd380Sjfb8856606 	struct rte_regexdev_match matches[];
1415*2d9fd380Sjfb8856606 	/**< Zero length array to hold the match tuples.
1416*2d9fd380Sjfb8856606 	 * The struct rte_regex_ops::nb_matches value holds the number of
1417*2d9fd380Sjfb8856606 	 * elements in this array.
1418*2d9fd380Sjfb8856606 	 *
1419*2d9fd380Sjfb8856606 	 * @see struct rte_regex_ops::nb_matches
1420*2d9fd380Sjfb8856606 	 */
1421*2d9fd380Sjfb8856606 };
1422*2d9fd380Sjfb8856606 
1423*2d9fd380Sjfb8856606 #include "rte_regexdev_core.h"
1424*2d9fd380Sjfb8856606 
1425*2d9fd380Sjfb8856606 /**
1426*2d9fd380Sjfb8856606  * @warning
1427*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
1428*2d9fd380Sjfb8856606  *
1429*2d9fd380Sjfb8856606  * Enqueue a burst of scan request on a RegEx device.
1430*2d9fd380Sjfb8856606  *
1431*2d9fd380Sjfb8856606  * The rte_regexdev_enqueue_burst() function is invoked to place
1432*2d9fd380Sjfb8856606  * regex operations on the queue *qp_id* of the device designated by
1433*2d9fd380Sjfb8856606  * its *dev_id*.
1434*2d9fd380Sjfb8856606  *
1435*2d9fd380Sjfb8856606  * The *nb_ops* parameter is the number of operations to process which are
1436*2d9fd380Sjfb8856606  * supplied in the *ops* array of *rte_regexdev_op* structures.
1437*2d9fd380Sjfb8856606  *
1438*2d9fd380Sjfb8856606  * The rte_regexdev_enqueue_burst() function returns the number of
1439*2d9fd380Sjfb8856606  * operations it actually enqueued for processing. A return value equal to
1440*2d9fd380Sjfb8856606  * *nb_ops* means that all packets have been enqueued.
1441*2d9fd380Sjfb8856606  *
1442*2d9fd380Sjfb8856606  * @param dev_id
1443*2d9fd380Sjfb8856606  *   The identifier of the device.
1444*2d9fd380Sjfb8856606  * @param qp_id
1445*2d9fd380Sjfb8856606  *   The index of the queue pair which packets are to be enqueued for
1446*2d9fd380Sjfb8856606  *   processing. The value must be in the range [0, nb_queue_pairs - 1]
1447*2d9fd380Sjfb8856606  *   previously supplied to rte_regexdev_configure().
1448*2d9fd380Sjfb8856606  * @param ops
1449*2d9fd380Sjfb8856606  *   The address of an array of *nb_ops* pointers to *rte_regexdev_op*
1450*2d9fd380Sjfb8856606  *   structures which contain the regex operations to be processed.
1451*2d9fd380Sjfb8856606  * @param nb_ops
1452*2d9fd380Sjfb8856606  *   The number of operations to process.
1453*2d9fd380Sjfb8856606  *
1454*2d9fd380Sjfb8856606  * @return
1455*2d9fd380Sjfb8856606  *   The number of operations actually enqueued on the regex device. The return
1456*2d9fd380Sjfb8856606  *   value can be less than the value of the *nb_ops* parameter when the
1457*2d9fd380Sjfb8856606  *   regex devices queue is full or if invalid parameters are specified in
1458*2d9fd380Sjfb8856606  *   a *rte_regexdev_op*. If the return value is less than *nb_ops*, the
1459*2d9fd380Sjfb8856606  *   remaining ops at the end of *ops* are not consumed and the caller has
1460*2d9fd380Sjfb8856606  *   to take care of them.
1461*2d9fd380Sjfb8856606  */
1462*2d9fd380Sjfb8856606 __rte_experimental
1463*2d9fd380Sjfb8856606 static inline uint16_t
rte_regexdev_enqueue_burst(uint8_t dev_id,uint16_t qp_id,struct rte_regex_ops ** ops,uint16_t nb_ops)1464*2d9fd380Sjfb8856606 rte_regexdev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
1465*2d9fd380Sjfb8856606 			   struct rte_regex_ops **ops, uint16_t nb_ops)
1466*2d9fd380Sjfb8856606 {
1467*2d9fd380Sjfb8856606 	struct rte_regexdev *dev = &rte_regex_devices[dev_id];
1468*2d9fd380Sjfb8856606 #ifdef RTE_LIBRTE_REGEXDEV_DEBUG
1469*2d9fd380Sjfb8856606 	RTE_REGEXDEV_VALID_DEV_ID_OR_ERR_RET(dev_id, -EINVAL);
1470*2d9fd380Sjfb8856606 	RTE_FUNC_PTR_OR_ERR_RET(*dev->enqueue, -ENOTSUP);
1471*2d9fd380Sjfb8856606 	if (qp_id >= dev->data->dev_conf.nb_queue_pairs) {
1472*2d9fd380Sjfb8856606 		RTE_REGEXDEV_LOG(ERR, "Invalid queue %d\n", qp_id);
1473*2d9fd380Sjfb8856606 		return -EINVAL;
1474*2d9fd380Sjfb8856606 	}
1475*2d9fd380Sjfb8856606 #endif
1476*2d9fd380Sjfb8856606 	return (*dev->enqueue)(dev, qp_id, ops, nb_ops);
1477*2d9fd380Sjfb8856606 }
1478*2d9fd380Sjfb8856606 
1479*2d9fd380Sjfb8856606 /**
1480*2d9fd380Sjfb8856606  * @warning
1481*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
1482*2d9fd380Sjfb8856606  *
1483*2d9fd380Sjfb8856606  * Dequeue a burst of scan response from a queue on the RegEx device.
1484*2d9fd380Sjfb8856606  * The dequeued operation are stored in *rte_regexdev_op* structures
1485*2d9fd380Sjfb8856606  * whose pointers are supplied in the *ops* array.
1486*2d9fd380Sjfb8856606  *
1487*2d9fd380Sjfb8856606  * The rte_regexdev_dequeue_burst() function returns the number of ops
1488*2d9fd380Sjfb8856606  * actually dequeued, which is the number of *rte_regexdev_op* data structures
1489*2d9fd380Sjfb8856606  * effectively supplied into the *ops* array.
1490*2d9fd380Sjfb8856606  *
1491*2d9fd380Sjfb8856606  * A return value equal to *nb_ops* indicates that the queue contained
1492*2d9fd380Sjfb8856606  * at least *nb_ops* operations, and this is likely to signify that other
1493*2d9fd380Sjfb8856606  * processed operations remain in the devices output queue. Applications
1494*2d9fd380Sjfb8856606  * implementing a "retrieve as many processed operations as possible" policy
1495*2d9fd380Sjfb8856606  * can check this specific case and keep invoking the
1496*2d9fd380Sjfb8856606  * rte_regexdev_dequeue_burst() function until a value less than
1497*2d9fd380Sjfb8856606  * *nb_ops* is returned.
1498*2d9fd380Sjfb8856606  *
1499*2d9fd380Sjfb8856606  * The rte_regexdev_dequeue_burst() function does not provide any error
1500*2d9fd380Sjfb8856606  * notification to avoid the corresponding overhead.
1501*2d9fd380Sjfb8856606  *
1502*2d9fd380Sjfb8856606  * @param dev_id
1503*2d9fd380Sjfb8856606  *   The RegEx device identifier
1504*2d9fd380Sjfb8856606  * @param qp_id
1505*2d9fd380Sjfb8856606  *   The index of the queue pair from which to retrieve processed packets.
1506*2d9fd380Sjfb8856606  *   The value must be in the range [0, nb_queue_pairs - 1] previously
1507*2d9fd380Sjfb8856606  *   supplied to rte_regexdev_configure().
1508*2d9fd380Sjfb8856606  * @param ops
1509*2d9fd380Sjfb8856606  *   The address of an array of pointers to *rte_regexdev_op* structures
1510*2d9fd380Sjfb8856606  *   that must be large enough to store *nb_ops* pointers in it.
1511*2d9fd380Sjfb8856606  * @param nb_ops
1512*2d9fd380Sjfb8856606  *   The maximum number of operations to dequeue.
1513*2d9fd380Sjfb8856606  *
1514*2d9fd380Sjfb8856606  * @return
1515*2d9fd380Sjfb8856606  *   The number of operations actually dequeued, which is the number
1516*2d9fd380Sjfb8856606  *   of pointers to *rte_regexdev_op* structures effectively supplied to the
1517*2d9fd380Sjfb8856606  *   *ops* array. If the return value is less than *nb_ops*, the remaining
1518*2d9fd380Sjfb8856606  *   ops at the end of *ops* are not consumed and the caller has to take care
1519*2d9fd380Sjfb8856606  *   of them.
1520*2d9fd380Sjfb8856606  */
1521*2d9fd380Sjfb8856606 __rte_experimental
1522*2d9fd380Sjfb8856606 static inline uint16_t
rte_regexdev_dequeue_burst(uint8_t dev_id,uint16_t qp_id,struct rte_regex_ops ** ops,uint16_t nb_ops)1523*2d9fd380Sjfb8856606 rte_regexdev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,
1524*2d9fd380Sjfb8856606 			   struct rte_regex_ops **ops, uint16_t nb_ops)
1525*2d9fd380Sjfb8856606 {
1526*2d9fd380Sjfb8856606 	struct rte_regexdev *dev = &rte_regex_devices[dev_id];
1527*2d9fd380Sjfb8856606 #ifdef RTE_LIBRTE_REGEXDEV_DEBUG
1528*2d9fd380Sjfb8856606 	RTE_REGEXDEV_VALID_DEV_ID_OR_ERR_RET(dev_id, -EINVAL);
1529*2d9fd380Sjfb8856606 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dequeue, -ENOTSUP);
1530*2d9fd380Sjfb8856606 	if (qp_id >= dev->data->dev_conf.nb_queue_pairs) {
1531*2d9fd380Sjfb8856606 		RTE_REGEXDEV_LOG(ERR, "Invalid queue %d\n", qp_id);
1532*2d9fd380Sjfb8856606 		return -EINVAL;
1533*2d9fd380Sjfb8856606 	}
1534*2d9fd380Sjfb8856606 #endif
1535*2d9fd380Sjfb8856606 	return (*dev->dequeue)(dev, qp_id, ops, nb_ops);
1536*2d9fd380Sjfb8856606 }
1537*2d9fd380Sjfb8856606 
1538*2d9fd380Sjfb8856606 #ifdef __cplusplus
1539*2d9fd380Sjfb8856606 }
1540*2d9fd380Sjfb8856606 #endif
1541*2d9fd380Sjfb8856606 
1542*2d9fd380Sjfb8856606 #endif /* _RTE_REGEXDEV_H_ */
1543