199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 299a2dd95SBruce Richardson * Copyright(C) 2019 Marvell International Ltd. 399a2dd95SBruce Richardson * Copyright 2020 Mellanox Technologies, Ltd 499a2dd95SBruce Richardson * Copyright(c) 2020 Intel Corporation 599a2dd95SBruce Richardson */ 699a2dd95SBruce Richardson 799a2dd95SBruce Richardson #ifndef _RTE_REGEXDEV_H_ 899a2dd95SBruce Richardson #define _RTE_REGEXDEV_H_ 999a2dd95SBruce Richardson 1099a2dd95SBruce Richardson /** 1199a2dd95SBruce Richardson * @file 1299a2dd95SBruce Richardson * 1399a2dd95SBruce Richardson * RTE RegEx Device API 1499a2dd95SBruce Richardson * 1599a2dd95SBruce Richardson * Defines RTE RegEx Device APIs for RegEx operations and its provisioning. 1699a2dd95SBruce Richardson * 1799a2dd95SBruce Richardson * The RegEx Device API is composed of two parts: 1899a2dd95SBruce Richardson * 1999a2dd95SBruce Richardson * - The application-oriented RegEx API that includes functions to setup 2099a2dd95SBruce Richardson * a RegEx device (configure it, setup its queue pairs and start it), 2199a2dd95SBruce Richardson * update the rule database and so on. 2299a2dd95SBruce Richardson * 2399a2dd95SBruce Richardson * - The driver-oriented RegEx API that exports a function allowing 2499a2dd95SBruce Richardson * a RegEx poll Mode Driver (PMD) to simultaneously register itself as 2599a2dd95SBruce Richardson * a RegEx device driver. 2699a2dd95SBruce Richardson * 2799a2dd95SBruce Richardson * RegEx device components and definitions: 2899a2dd95SBruce Richardson * 2999a2dd95SBruce Richardson * +-----------------+ 3099a2dd95SBruce Richardson * | | 3199a2dd95SBruce Richardson * | o---------+ rte_regexdev_[en|de]queue_burst() 3299a2dd95SBruce Richardson * | PCRE based o------+ | | 3399a2dd95SBruce Richardson * | RegEx pattern | | | +--------+ | 3499a2dd95SBruce Richardson * | matching engine o------+--+--o | | +------+ 3599a2dd95SBruce Richardson * | | | | | queue |<==o===>|Core 0| 3699a2dd95SBruce Richardson * | o----+ | | | pair 0 | | | 3799a2dd95SBruce Richardson * | | | | | +--------+ +------+ 3899a2dd95SBruce Richardson * +-----------------+ | | | 3999a2dd95SBruce Richardson * ^ | | | +--------+ 4099a2dd95SBruce Richardson * | | | | | | +------+ 4199a2dd95SBruce Richardson * | | +--+--o queue |<======>|Core 1| 4299a2dd95SBruce Richardson * Rule|Database | | | pair 1 | | | 4399a2dd95SBruce Richardson * +------+----------+ | | +--------+ +------+ 4499a2dd95SBruce Richardson * | Group 0 | | | 4599a2dd95SBruce Richardson * | +-------------+ | | | +--------+ +------+ 4699a2dd95SBruce Richardson * | | Rules 0..n | | | | | | |Core 2| 4799a2dd95SBruce Richardson * | +-------------+ | | +--o queue |<======>| | 4899a2dd95SBruce Richardson * | Group 1 | | | pair 2 | +------+ 4999a2dd95SBruce Richardson * | +-------------+ | | +--------+ 5099a2dd95SBruce Richardson * | | Rules 0..n | | | 5199a2dd95SBruce Richardson * | +-------------+ | | +--------+ 5299a2dd95SBruce Richardson * | Group 2 | | | | +------+ 5399a2dd95SBruce Richardson * | +-------------+ | | | queue |<======>|Core n| 5499a2dd95SBruce Richardson * | | Rules 0..n | | +-------o pair n | | | 5599a2dd95SBruce Richardson * | +-------------+ | +--------+ +------+ 5699a2dd95SBruce Richardson * | Group n | 5799a2dd95SBruce Richardson * | +-------------+ |<-------rte_regexdev_rule_db_update() 5899a2dd95SBruce Richardson * | | | |<-------rte_regexdev_rule_db_compile_activate() 5999a2dd95SBruce Richardson * | | Rules 0..n | |<-------rte_regexdev_rule_db_import() 6099a2dd95SBruce Richardson * | +-------------+ |------->rte_regexdev_rule_db_export() 6199a2dd95SBruce Richardson * +-----------------+ 6299a2dd95SBruce Richardson * 6399a2dd95SBruce Richardson * RegEx: A regular expression is a concise and flexible means for matching 6499a2dd95SBruce Richardson * strings of text, such as particular characters, words, or patterns of 6599a2dd95SBruce Richardson * characters. A common abbreviation for this is “RegEx”. 6699a2dd95SBruce Richardson * 6799a2dd95SBruce Richardson * RegEx device: A hardware or software-based implementation of RegEx 6899a2dd95SBruce Richardson * device API for PCRE based pattern matching syntax and semantics. 6999a2dd95SBruce Richardson * 7099a2dd95SBruce Richardson * PCRE RegEx syntax and semantics specification: 7199a2dd95SBruce Richardson * http://regexkit.sourceforge.net/Documentation/pcre/pcrepattern.html 7299a2dd95SBruce Richardson * 7399a2dd95SBruce Richardson * RegEx queue pair: Each RegEx device should have one or more queue pair to 7499a2dd95SBruce Richardson * transmit a burst of pattern matching request and receive a burst of 7599a2dd95SBruce Richardson * receive the pattern matching response. The pattern matching request/response 7699a2dd95SBruce Richardson * embedded in *rte_regex_ops* structure. 7799a2dd95SBruce Richardson * 7899a2dd95SBruce Richardson * Rule: A pattern matching rule expressed in PCRE RegEx syntax along with 7999a2dd95SBruce Richardson * Match ID and Group ID to identify the rule upon the match. 8099a2dd95SBruce Richardson * 8199a2dd95SBruce Richardson * Rule database: The RegEx device accepts regular expressions and converts them 8299a2dd95SBruce Richardson * into a compiled rule database that can then be used to scan data. 8399a2dd95SBruce Richardson * Compilation allows the device to analyze the given pattern(s) and 8499a2dd95SBruce Richardson * pre-determine how to scan for these patterns in an optimized fashion that 8599a2dd95SBruce Richardson * would be far too expensive to compute at run-time. A rule database contains 8699a2dd95SBruce Richardson * a set of rules that compiled in device specific binary form. 8799a2dd95SBruce Richardson * 8899a2dd95SBruce Richardson * Match ID or Rule ID: A unique identifier provided at the time of rule 8999a2dd95SBruce Richardson * creation for the application to identify the rule upon match. 9099a2dd95SBruce Richardson * 9199a2dd95SBruce Richardson * Group ID: Group of rules can be grouped under one group ID to enable 9299a2dd95SBruce Richardson * rule isolation and effective pattern matching. A unique group identifier 9399a2dd95SBruce Richardson * provided at the time of rule creation for the application to identify the 9499a2dd95SBruce Richardson * rule upon match. 9599a2dd95SBruce Richardson * 9699a2dd95SBruce Richardson * Scan: A pattern matching request through *enqueue* API. 9799a2dd95SBruce Richardson * 9899a2dd95SBruce Richardson * It may possible that a given RegEx device may not support all the features 9999a2dd95SBruce Richardson * of PCRE. The application may probe unsupported features through 10099a2dd95SBruce Richardson * struct rte_regexdev_info::pcre_unsup_flags 10199a2dd95SBruce Richardson * 10299a2dd95SBruce Richardson * By default, all the functions of the RegEx Device API exported by a PMD 10399a2dd95SBruce Richardson * are lock-free functions which assume to not be invoked in parallel on 10499a2dd95SBruce Richardson * different logical cores to work on the same target object. For instance, 10599a2dd95SBruce Richardson * the dequeue function of a PMD cannot be invoked in parallel on two logical 10699a2dd95SBruce Richardson * cores to operates on same RegEx queue pair. Of course, this function 10799a2dd95SBruce Richardson * can be invoked in parallel by different logical core on different queue pair. 10899a2dd95SBruce Richardson * It is the responsibility of the upper level application to enforce this rule. 10999a2dd95SBruce Richardson * 11099a2dd95SBruce Richardson * In all functions of the RegEx API, the RegEx device is 11199a2dd95SBruce Richardson * designated by an integer >= 0 named the device identifier *dev_id* 11299a2dd95SBruce Richardson * 11399a2dd95SBruce Richardson * At the RegEx driver level, RegEx devices are represented by a generic 11499a2dd95SBruce Richardson * data structure of type *rte_regexdev*. 11599a2dd95SBruce Richardson * 11699a2dd95SBruce Richardson * RegEx devices are dynamically registered during the PCI/SoC device probing 11799a2dd95SBruce Richardson * phase performed at EAL initialization time. 11899a2dd95SBruce Richardson * When a RegEx device is being probed, a *rte_regexdev* structure and 11999a2dd95SBruce Richardson * a new device identifier are allocated for that device. Then, the 12099a2dd95SBruce Richardson * regexdev_init() function supplied by the RegEx driver matching the probed 12199a2dd95SBruce Richardson * device is invoked to properly initialize the device. 12299a2dd95SBruce Richardson * 12399a2dd95SBruce Richardson * The role of the device init function consists of resetting the hardware or 12499a2dd95SBruce Richardson * software RegEx driver implementations. 12599a2dd95SBruce Richardson * 12699a2dd95SBruce Richardson * If the device init operation is successful, the correspondence between 12799a2dd95SBruce Richardson * the device identifier assigned to the new device and its associated 12899a2dd95SBruce Richardson * *rte_regexdev* structure is effectively registered. 12999a2dd95SBruce Richardson * Otherwise, both the *rte_regexdev* structure and the device identifier are 13099a2dd95SBruce Richardson * freed. 13199a2dd95SBruce Richardson * 13299a2dd95SBruce Richardson * The functions exported by the application RegEx API to setup a device 13399a2dd95SBruce Richardson * designated by its device identifier must be invoked in the following order: 13499a2dd95SBruce Richardson * - rte_regexdev_configure() 13599a2dd95SBruce Richardson * - rte_regexdev_queue_pair_setup() 13699a2dd95SBruce Richardson * - rte_regexdev_start() 13799a2dd95SBruce Richardson * 13899a2dd95SBruce Richardson * Then, the application can invoke, in any order, the functions 13999a2dd95SBruce Richardson * exported by the RegEx API to enqueue pattern matching job, dequeue pattern 14099a2dd95SBruce Richardson * matching response, get the stats, update the rule database, 14199a2dd95SBruce Richardson * get/set device attributes and so on 14299a2dd95SBruce Richardson * 14399a2dd95SBruce Richardson * If the application wants to change the configuration (i.e. call 14499a2dd95SBruce Richardson * rte_regexdev_configure() or rte_regexdev_queue_pair_setup()), it must call 14599a2dd95SBruce Richardson * rte_regexdev_stop() first to stop the device and then do the reconfiguration 14699a2dd95SBruce Richardson * before calling rte_regexdev_start() again. The enqueue and dequeue 14799a2dd95SBruce Richardson * functions should not be invoked when the device is stopped. 14899a2dd95SBruce Richardson * 14999a2dd95SBruce Richardson * Finally, an application can close a RegEx device by invoking the 15099a2dd95SBruce Richardson * rte_regexdev_close() function. 15199a2dd95SBruce Richardson * 15299a2dd95SBruce Richardson * Each function of the application RegEx API invokes a specific function 15399a2dd95SBruce Richardson * of the PMD that controls the target device designated by its device 15499a2dd95SBruce Richardson * identifier. 15599a2dd95SBruce Richardson * 15699a2dd95SBruce Richardson * For this purpose, all device-specific functions of a RegEx driver are 15799a2dd95SBruce Richardson * supplied through a set of pointers contained in a generic structure of type 15899a2dd95SBruce Richardson * *regexdev_ops*. 15999a2dd95SBruce Richardson * The address of the *regexdev_ops* structure is stored in the *rte_regexdev* 16099a2dd95SBruce Richardson * structure by the device init function of the RegEx driver, which is 16199a2dd95SBruce Richardson * invoked during the PCI/SoC device probing phase, as explained earlier. 16299a2dd95SBruce Richardson * 16399a2dd95SBruce Richardson * In other words, each function of the RegEx API simply retrieves the 16499a2dd95SBruce Richardson * *rte_regexdev* structure associated with the device identifier and 16599a2dd95SBruce Richardson * performs an indirect invocation of the corresponding driver function 16699a2dd95SBruce Richardson * supplied in the *regexdev_ops* structure of the *rte_regexdev* structure. 16799a2dd95SBruce Richardson * 16899a2dd95SBruce Richardson * For performance reasons, the address of the fast-path functions of the 16999a2dd95SBruce Richardson * RegEx driver is not contained in the *regexdev_ops* structure. 17099a2dd95SBruce Richardson * Instead, they are directly stored at the beginning of the *rte_regexdev* 17199a2dd95SBruce Richardson * structure to avoid an extra indirect memory access during their invocation. 17299a2dd95SBruce Richardson * 17399a2dd95SBruce Richardson * RTE RegEx device drivers do not use interrupts for enqueue or dequeue 17499a2dd95SBruce Richardson * operation. Instead, RegEx drivers export Poll-Mode enqueue and dequeue 17599a2dd95SBruce Richardson * functions to applications. 17699a2dd95SBruce Richardson * 17799a2dd95SBruce Richardson * The *enqueue* operation submits a burst of RegEx pattern matching request 17899a2dd95SBruce Richardson * to the RegEx device and the *dequeue* operation gets a burst of pattern 17999a2dd95SBruce Richardson * matching response for the ones submitted through *enqueue* operation. 18099a2dd95SBruce Richardson * 18199a2dd95SBruce Richardson * Typical application utilisation of the RegEx device API will follow the 18299a2dd95SBruce Richardson * following programming flow. 18399a2dd95SBruce Richardson * 18499a2dd95SBruce Richardson * - rte_regexdev_configure() 18599a2dd95SBruce Richardson * - rte_regexdev_queue_pair_setup() 18699a2dd95SBruce Richardson * - rte_regexdev_rule_db_update() Needs to invoke if precompiled rule database 18799a2dd95SBruce Richardson * not provided in rte_regexdev_config::rule_db for rte_regexdev_configure() 18899a2dd95SBruce Richardson * and/or application needs to update rule database. 18999a2dd95SBruce Richardson * - rte_regexdev_rule_db_compile_activate() Needs to invoke if 19099a2dd95SBruce Richardson * rte_regexdev_rule_db_update function was used. 19199a2dd95SBruce Richardson * - Create or reuse exiting mempool for *rte_regex_ops* objects. 19299a2dd95SBruce Richardson * - rte_regexdev_start() 19399a2dd95SBruce Richardson * - rte_regexdev_enqueue_burst() 19499a2dd95SBruce Richardson * - rte_regexdev_dequeue_burst() 19599a2dd95SBruce Richardson */ 19699a2dd95SBruce Richardson 19799a2dd95SBruce Richardson #ifdef __cplusplus 19899a2dd95SBruce Richardson extern "C" { 19999a2dd95SBruce Richardson #endif 20099a2dd95SBruce Richardson 2011094dd94SDavid Marchand #include <rte_compat.h> 20299a2dd95SBruce Richardson #include <rte_common.h> 20399a2dd95SBruce Richardson #include <rte_dev.h> 20499a2dd95SBruce Richardson #include <rte_mbuf.h> 20599a2dd95SBruce Richardson 20699a2dd95SBruce Richardson #define RTE_REGEXDEV_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN 20799a2dd95SBruce Richardson 20899a2dd95SBruce Richardson extern int rte_regexdev_logtype; 209*0e21c7c0SDavid Marchand #define RTE_LOGTYPE_REGEXDEV rte_regexdev_logtype 21099a2dd95SBruce Richardson 211*0e21c7c0SDavid Marchand #define RTE_REGEXDEV_LOG_LINE(level, ...) \ 212*0e21c7c0SDavid Marchand RTE_LOG(level, REGEXDEV, RTE_FMT(RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ 213*0e21c7c0SDavid Marchand RTE_FMT_TAIL(__VA_ARGS__ ,))) 21499a2dd95SBruce Richardson 21599a2dd95SBruce Richardson /* Macros to check for valid port */ 21699a2dd95SBruce Richardson #define RTE_REGEXDEV_VALID_DEV_ID_OR_ERR_RET(dev_id, retval) do { \ 21799a2dd95SBruce Richardson if (!rte_regexdev_is_valid_dev(dev_id)) { \ 218*0e21c7c0SDavid Marchand RTE_REGEXDEV_LOG_LINE(ERR, "Invalid dev_id=%u", dev_id); \ 21999a2dd95SBruce Richardson return retval; \ 22099a2dd95SBruce Richardson } \ 22199a2dd95SBruce Richardson } while (0) 22299a2dd95SBruce Richardson 22399a2dd95SBruce Richardson #define RTE_REGEXDEV_VALID_DEV_ID_OR_RET(dev_id) do { \ 22499a2dd95SBruce Richardson if (!rte_regexdev_is_valid_dev(dev_id)) { \ 225*0e21c7c0SDavid Marchand RTE_REGEXDEV_LOG_LINE(ERR, "Invalid dev_id=%u", dev_id); \ 22699a2dd95SBruce Richardson return; \ 22799a2dd95SBruce Richardson } \ 22899a2dd95SBruce Richardson } while (0) 22999a2dd95SBruce Richardson 23099a2dd95SBruce Richardson /** 23189e290ebSThomas Monjalon * @warning 23289e290ebSThomas Monjalon * @b EXPERIMENTAL: this API may change without prior notice. 23389e290ebSThomas Monjalon * 23499a2dd95SBruce Richardson * Check if dev_id is ready. 23599a2dd95SBruce Richardson * 23699a2dd95SBruce Richardson * @param dev_id 23799a2dd95SBruce Richardson * The dev identifier of the RegEx device. 23899a2dd95SBruce Richardson * 23999a2dd95SBruce Richardson * @return 24099a2dd95SBruce Richardson * - 0 if device state is not in ready state. 24199a2dd95SBruce Richardson * - 1 if device state is ready state. 24299a2dd95SBruce Richardson */ 24389e290ebSThomas Monjalon __rte_experimental 24499a2dd95SBruce Richardson int rte_regexdev_is_valid_dev(uint16_t dev_id); 24599a2dd95SBruce Richardson 24699a2dd95SBruce Richardson /** 24799a2dd95SBruce Richardson * @warning 24899a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 24999a2dd95SBruce Richardson * 25099a2dd95SBruce Richardson * Get the total number of RegEx devices that have been successfully 25199a2dd95SBruce Richardson * initialised. 25299a2dd95SBruce Richardson * 25399a2dd95SBruce Richardson * @return 25499a2dd95SBruce Richardson * The total number of usable RegEx devices. 25599a2dd95SBruce Richardson */ 25699a2dd95SBruce Richardson __rte_experimental 25799a2dd95SBruce Richardson uint8_t 25899a2dd95SBruce Richardson rte_regexdev_count(void); 25999a2dd95SBruce Richardson 26099a2dd95SBruce Richardson /** 26199a2dd95SBruce Richardson * @warning 26299a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 26399a2dd95SBruce Richardson * 26499a2dd95SBruce Richardson * Get the device identifier for the named RegEx device. 26599a2dd95SBruce Richardson * 26699a2dd95SBruce Richardson * @param name 26799a2dd95SBruce Richardson * RegEx device name to select the RegEx device identifier. 26899a2dd95SBruce Richardson * 26999a2dd95SBruce Richardson * @return 27099a2dd95SBruce Richardson * Returns RegEx device identifier on success. 27199a2dd95SBruce Richardson * - <0: Failure to find named RegEx device. 27299a2dd95SBruce Richardson */ 27399a2dd95SBruce Richardson __rte_experimental 27499a2dd95SBruce Richardson int 27599a2dd95SBruce Richardson rte_regexdev_get_dev_id(const char *name); 27699a2dd95SBruce Richardson 27799a2dd95SBruce Richardson /* Enumerates RegEx device capabilities */ 27899a2dd95SBruce Richardson #define RTE_REGEXDEV_CAPA_RUNTIME_COMPILATION_F (1ULL << 0) 27999a2dd95SBruce Richardson /**< RegEx device does support compiling the rules at runtime unlike 28099a2dd95SBruce Richardson * loading only the pre-built rule database using 28199a2dd95SBruce Richardson * struct rte_regexdev_config::rule_db in rte_regexdev_configure() 28299a2dd95SBruce Richardson * 28399a2dd95SBruce Richardson * @see struct rte_regexdev_config::rule_db, rte_regexdev_configure() 28499a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 28599a2dd95SBruce Richardson */ 28699a2dd95SBruce Richardson 28799a2dd95SBruce Richardson #define RTE_REGEXDEV_CAPA_SUPP_PCRE_START_ANCHOR_F (1ULL << 1) 28899a2dd95SBruce Richardson /**< RegEx device support PCRE Anchor to start of match flag. 28999a2dd95SBruce Richardson * Example RegEx is `/\Gfoo\d/`. Here `\G` asserts position at the end of the 29099a2dd95SBruce Richardson * previous match or the start of the string for the first match. 29199a2dd95SBruce Richardson * This position will change each time the RegEx is applied to the subject 29299a2dd95SBruce Richardson * string. If the RegEx is applied to `foo1foo2Zfoo3` the first two matches will 29399a2dd95SBruce Richardson * be successful for `foo1foo2` and fail for `Zfoo3`. 29499a2dd95SBruce Richardson * 29599a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 29699a2dd95SBruce Richardson */ 29799a2dd95SBruce Richardson 29899a2dd95SBruce Richardson #define RTE_REGEXDEV_CAPA_SUPP_PCRE_ATOMIC_GROUPING_F (1ULL << 2) 29999a2dd95SBruce Richardson /**< RegEx device support PCRE Atomic grouping. 30099a2dd95SBruce Richardson * Atomic groups are represented by `(?>)`. An atomic group is a group that, 30199a2dd95SBruce Richardson * when the RegEx engine exits from it, automatically throws away all 30299a2dd95SBruce Richardson * backtracking positions remembered by any tokens inside the group. 30399a2dd95SBruce Richardson * Example RegEx is `a(?>bc|b)c` if the given patterns are `abc` and `abcc` then 30499a2dd95SBruce Richardson * `a(bc|b)c` matches both where as `a(?>bc|b)c` matches only abcc because 3057be78d02SJosh Soref * atomic groups don't allow backtracking back to `b`. 30699a2dd95SBruce Richardson * 30799a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 30899a2dd95SBruce Richardson */ 30999a2dd95SBruce Richardson 31099a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_PCRE_BACKTRACKING_CTRL_F (1ULL << 3) 31199a2dd95SBruce Richardson /**< RegEx device support PCRE backtracking control verbs. 3127be78d02SJosh Soref * Some examples of backtracking verbs are (*COMMIT), (*ACCEPT), (*FAIL), 31399a2dd95SBruce Richardson * (*SKIP), (*PRUNE). 31499a2dd95SBruce Richardson * 31599a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 31699a2dd95SBruce Richardson */ 31799a2dd95SBruce Richardson 31899a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_PCRE_CALLOUTS_F (1ULL << 4) 31999a2dd95SBruce Richardson /**< RegEx device support PCRE callouts. 32099a2dd95SBruce Richardson * PCRE supports calling external function in between matches by using `(?C)`. 32199a2dd95SBruce Richardson * Example RegEx `ABC(?C)D` if a given patter is `ABCD` then the RegEx engine 32299a2dd95SBruce Richardson * will parse ABC perform a userdefined callout and return a successful match at 32399a2dd95SBruce Richardson * D. 32499a2dd95SBruce Richardson * 32599a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 32699a2dd95SBruce Richardson */ 32799a2dd95SBruce Richardson 32899a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_PCRE_BACKREFERENCE_F (1ULL << 5) 32999a2dd95SBruce Richardson /**< RegEx device support PCRE backreference. 33099a2dd95SBruce Richardson * Example RegEx is `(\2ABC|(GHI))+` `\2` matches the same text as most recently 33199a2dd95SBruce Richardson * matched by the 2nd capturing group i.e. `GHI`. 33299a2dd95SBruce Richardson * 33399a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 33499a2dd95SBruce Richardson */ 33599a2dd95SBruce Richardson 33699a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_PCRE_GREEDY_F (1ULL << 6) 33799a2dd95SBruce Richardson /**< RegEx device support PCRE Greedy mode. 33899a2dd95SBruce Richardson * For example if the RegEx is `AB\d*?` then `*?` represents zero or unlimited 33999a2dd95SBruce Richardson * matches. In greedy mode the pattern `AB12345` will be matched completely 34099a2dd95SBruce Richardson * where as the ungreedy mode `AB` will be returned as the match. 34199a2dd95SBruce Richardson * 34299a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 34399a2dd95SBruce Richardson */ 34499a2dd95SBruce Richardson 34599a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_PCRE_MATCH_ALL_F (1ULL << 7) 34699a2dd95SBruce Richardson /**< RegEx device support match all mode. 34799a2dd95SBruce Richardson * For example if the RegEx is `AB\d*?` then `*?` represents zero or unlimited 34899a2dd95SBruce Richardson * matches. In match all mode the pattern `AB12345` will return 6 matches. 34999a2dd95SBruce Richardson * AB, AB1, AB12, AB123, AB1234, AB12345. 35099a2dd95SBruce Richardson * 35199a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 35299a2dd95SBruce Richardson */ 35399a2dd95SBruce Richardson 35499a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_PCRE_LOOKAROUND_ASRT_F (1ULL << 8) 35599a2dd95SBruce Richardson /**< RegEx device support PCRE Lookaround assertions 35699a2dd95SBruce Richardson * (Zero-width assertions). Example RegEx is `[a-z]+\d+(?=!{3,})` if 35799a2dd95SBruce Richardson * the given pattern is `dwad1234!` the RegEx engine doesn't report any matches 35899a2dd95SBruce Richardson * because the assert `(?=!{3,})` fails. The pattern `dwad123!!!` would return a 35999a2dd95SBruce Richardson * successful match. 36099a2dd95SBruce Richardson * 36199a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 36299a2dd95SBruce Richardson */ 36399a2dd95SBruce Richardson 36499a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_PCRE_MATCH_POINT_RST_F (1ULL << 9) 36599a2dd95SBruce Richardson /**< RegEx device doesn't support PCRE match point reset directive. 36699a2dd95SBruce Richardson * Example RegEx is `[a-z]+\K\d+` if the pattern is `dwad123` 36799a2dd95SBruce Richardson * then even though the entire pattern matches only `123` 36899a2dd95SBruce Richardson * is reported as a match. 36999a2dd95SBruce Richardson * 37099a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 37199a2dd95SBruce Richardson */ 37299a2dd95SBruce Richardson 37399a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_NEWLINE_CONVENTIONS_F (1ULL << 10) 37499a2dd95SBruce Richardson /**< RegEx support PCRE newline convention. 37599a2dd95SBruce Richardson * Newline conventions are represented as follows: 37699a2dd95SBruce Richardson * (*CR) carriage return 37799a2dd95SBruce Richardson * (*LF) linefeed 37899a2dd95SBruce Richardson * (*CRLF) carriage return, followed by linefeed 37999a2dd95SBruce Richardson * (*ANYCRLF) any of the three above 38099a2dd95SBruce Richardson * (*ANY) all Unicode newline sequences 38199a2dd95SBruce Richardson * 38299a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 38399a2dd95SBruce Richardson */ 38499a2dd95SBruce Richardson 38599a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_PCRE_NEWLINE_SEQ_F (1ULL << 11) 38699a2dd95SBruce Richardson /**< RegEx device support PCRE newline sequence. 38799a2dd95SBruce Richardson * The escape sequence `\R` will match any newline sequence. 38899a2dd95SBruce Richardson * It is equivalent to: `(?>\r\n|\n|\x0b|\f|\r|\x85)`. 38999a2dd95SBruce Richardson * 39099a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 39199a2dd95SBruce Richardson */ 39299a2dd95SBruce Richardson 39399a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_PCRE_POSSESSIVE_QUALIFIERS_F (1ULL << 12) 39499a2dd95SBruce Richardson /**< RegEx device support PCRE possessive qualifiers. 39599a2dd95SBruce Richardson * Example RegEx possessive qualifiers `*+`, `++`, `?+`, `{m,n}+`. 39699a2dd95SBruce Richardson * Possessive quantifier repeats the token as many times as possible and it does 39799a2dd95SBruce Richardson * not give up matches as the engine backtracks. With a possessive quantifier, 39899a2dd95SBruce Richardson * the deal is all or nothing. 39999a2dd95SBruce Richardson * 40099a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 40199a2dd95SBruce Richardson */ 40299a2dd95SBruce Richardson 40399a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_PCRE_SUBROUTINE_REFERENCES_F (1ULL << 13) 40499a2dd95SBruce Richardson /**< RegEx device support PCRE Subroutine references. 40599a2dd95SBruce Richardson * PCRE Subroutine references allow for sub patterns to be assessed 40699a2dd95SBruce Richardson * as part of the RegEx. Example RegEx is `(foo|fuzz)\g<1>+bar` matches the 40799a2dd95SBruce Richardson * pattern `foofoofuzzfoofuzzbar`. 40899a2dd95SBruce Richardson * 40999a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 41099a2dd95SBruce Richardson */ 41199a2dd95SBruce Richardson 41299a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_PCRE_UTF_8_F (1ULL << 14) 41399a2dd95SBruce Richardson /**< RegEx device support UTF-8 character encoding. 41499a2dd95SBruce Richardson * 41599a2dd95SBruce Richardson * @see struct rte_regexdev_info::pcre_unsup_flags 41699a2dd95SBruce Richardson */ 41799a2dd95SBruce Richardson 41899a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_PCRE_UTF_16_F (1ULL << 15) 41999a2dd95SBruce Richardson /**< RegEx device support UTF-16 character encoding. 42099a2dd95SBruce Richardson * 42199a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 42299a2dd95SBruce Richardson */ 42399a2dd95SBruce Richardson 42499a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_PCRE_UTF_32_F (1ULL << 16) 42599a2dd95SBruce Richardson /**< RegEx device support UTF-32 character encoding. 42699a2dd95SBruce Richardson * 42799a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 42899a2dd95SBruce Richardson */ 42999a2dd95SBruce Richardson 43099a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_PCRE_WORD_BOUNDARY_F (1ULL << 17) 43199a2dd95SBruce Richardson /**< RegEx device support word boundaries. 43299a2dd95SBruce Richardson * The meta character `\b` represents word boundary anchor. 43399a2dd95SBruce Richardson * 43499a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 43599a2dd95SBruce Richardson */ 43699a2dd95SBruce Richardson 43799a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_PCRE_FORWARD_REFERENCES_F (1ULL << 18) 43899a2dd95SBruce Richardson /**< RegEx device support Forward references. 43999a2dd95SBruce Richardson * Forward references allow you to use a back reference to a group that appears 44099a2dd95SBruce Richardson * later in the RegEx. Example RegEx is `(\3ABC|(DEF|(GHI)))+` matches the 44199a2dd95SBruce Richardson * following string `GHIGHIABCDEF`. 44299a2dd95SBruce Richardson * 44399a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 44499a2dd95SBruce Richardson */ 44599a2dd95SBruce Richardson 44699a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_MATCH_AS_END_F (1ULL << 19) 44799a2dd95SBruce Richardson /**< RegEx device support match as end. 44899a2dd95SBruce Richardson * Match as end means that the match result holds the end offset of the 44999a2dd95SBruce Richardson * detected match. No len value is set. 45099a2dd95SBruce Richardson * If the device doesn't support this feature it means the match 45199a2dd95SBruce Richardson * result holds the starting position of match and the length of the match. 45299a2dd95SBruce Richardson * 45399a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 45499a2dd95SBruce Richardson */ 45599a2dd95SBruce Richardson 45699a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_CROSS_BUFFER_F (1ULL << 20) 45799a2dd95SBruce Richardson /**< RegEx device support cross buffer match. 45899a2dd95SBruce Richardson * Cross buffer matching means that the match can be detected even if the 45999a2dd95SBruce Richardson * string was started in previous buffer. 46099a2dd95SBruce Richardson * In case the device is configured as RTE_REGEXDEV_CFG_MATCH_AS_END 46199a2dd95SBruce Richardson * the end offset will be relative for the first packet. 46299a2dd95SBruce Richardson * For example RegEx is ABC the first buffer is xxxx second buffer yyyA and 46399a2dd95SBruce Richardson * the last buffer BCzz. 46499a2dd95SBruce Richardson * In case the match as end is configured the end offset will be 10. 46599a2dd95SBruce Richardson * 46699a2dd95SBruce Richardson * @see RTE_REGEXDEV_CFG_MATCH_AS_END_F 46799a2dd95SBruce Richardson * @see RTE_REGEXDEV_CFG_CROSS_BUFFER_SCAN_F 46899a2dd95SBruce Richardson * @see RTE_REGEX_OPS_RSP_PMI_SOJ_F 46999a2dd95SBruce Richardson * @see RTE_REGEX_OPS_RSP_PMI_EOJ_F 47099a2dd95SBruce Richardson */ 47199a2dd95SBruce Richardson 47299a2dd95SBruce Richardson #define RTE_REGEXDEV_SUPP_MATCH_ALL_F (1ULL << 21) 47399a2dd95SBruce Richardson /**< RegEx device support match all. 47499a2dd95SBruce Richardson * Match all means that the RegEx engine will return all possible matches. 47599a2dd95SBruce Richardson * For example, assume the RegEx is `A+b`, given the input AAAb the 47699a2dd95SBruce Richardson * returned matches will be: Ab, AAb and AAAb. 47799a2dd95SBruce Richardson * 47899a2dd95SBruce Richardson * @see RTE_REGEXDEV_CFG_MATCH_ALL_F 47999a2dd95SBruce Richardson */ 48099a2dd95SBruce Richardson 48199a2dd95SBruce Richardson #define RTE_REGEXDEV_CAPA_QUEUE_PAIR_OOS_F (1ULL << 22) 48299a2dd95SBruce Richardson /**< RegEx device supports out of order scan. 48399a2dd95SBruce Richardson * Out of order scan means the response of a specific job can be returned as 48499a2dd95SBruce Richardson * soon as it is ready even if previous jobs on the same queue didn't complete. 48599a2dd95SBruce Richardson * 48699a2dd95SBruce Richardson * @see RTE_REGEX_QUEUE_PAIR_CFG_OOS_F 48799a2dd95SBruce Richardson * @see struct rte_regexdev_info::regexdev_capa 48899a2dd95SBruce Richardson */ 48999a2dd95SBruce Richardson 49099a2dd95SBruce Richardson /* Enumerates PCRE rule flags */ 49199a2dd95SBruce Richardson #define RTE_REGEX_PCRE_RULE_ALLOW_EMPTY_F (1ULL << 0) 49299a2dd95SBruce Richardson /**< When this flag is set, the pattern that can match against an empty string, 49399a2dd95SBruce Richardson * such as `.*` are allowed. 49499a2dd95SBruce Richardson * 49599a2dd95SBruce Richardson * @see struct rte_regexdev_info::rule_flags 49699a2dd95SBruce Richardson * @see struct rte_regexdev_rule::rule_flags 49799a2dd95SBruce Richardson */ 49899a2dd95SBruce Richardson 49999a2dd95SBruce Richardson #define RTE_REGEX_PCRE_RULE_ANCHORED_F (1ULL << 1) 50099a2dd95SBruce Richardson /**< When this flag is set, the pattern is forced to be "anchored", that is, it 50199a2dd95SBruce Richardson * is constrained to match only at the first matching point in the string that 50299a2dd95SBruce Richardson * is being searched. Similar to `^` and represented by `\A`. 50399a2dd95SBruce Richardson * 50499a2dd95SBruce Richardson * @see struct rte_regexdev_info::rule_flags 50599a2dd95SBruce Richardson * @see struct rte_regexdev_rule::rule_flags 50699a2dd95SBruce Richardson */ 50799a2dd95SBruce Richardson 50899a2dd95SBruce Richardson #define RTE_REGEX_PCRE_RULE_CASELESS_F (1ULL << 2) 50999a2dd95SBruce Richardson /**< When this flag is set, letters in the pattern match both upper and lower 51099a2dd95SBruce Richardson * case letters in the subject. 51199a2dd95SBruce Richardson * 51299a2dd95SBruce Richardson * @see struct rte_regexdev_info::rule_flags 51399a2dd95SBruce Richardson * @see struct rte_regexdev_rule::rule_flags 51499a2dd95SBruce Richardson */ 51599a2dd95SBruce Richardson 51699a2dd95SBruce Richardson #define RTE_REGEX_PCRE_RULE_DOTALL_F (1ULL << 3) 51799a2dd95SBruce Richardson /**< When this flag is set, a dot metacharacter in the pattern matches any 51899a2dd95SBruce Richardson * character, including one that indicates a newline. 51999a2dd95SBruce Richardson * 52099a2dd95SBruce Richardson * @see struct rte_regexdev_info::rule_flags 52199a2dd95SBruce Richardson * @see struct rte_regexdev_rule::rule_flags 52299a2dd95SBruce Richardson */ 52399a2dd95SBruce Richardson 52499a2dd95SBruce Richardson #define RTE_REGEX_PCRE_RULE_DUPNAMES_F (1ULL << 4) 52599a2dd95SBruce Richardson /**< When this flag is set, names used to identify capture groups need not be 52699a2dd95SBruce Richardson * unique. 52799a2dd95SBruce Richardson * 52899a2dd95SBruce Richardson * @see struct rte_regexdev_info::rule_flags 52999a2dd95SBruce Richardson * @see struct rte_regexdev_rule::rule_flags 53099a2dd95SBruce Richardson */ 53199a2dd95SBruce Richardson 53299a2dd95SBruce Richardson #define RTE_REGEX_PCRE_RULE_EXTENDED_F (1ULL << 5) 53399a2dd95SBruce Richardson /**< When this flag is set, most white space characters in the pattern are 53499a2dd95SBruce Richardson * totally ignored except when escaped or inside a character class. 53599a2dd95SBruce Richardson * 53699a2dd95SBruce Richardson * @see struct rte_regexdev_info::rule_flags 53799a2dd95SBruce Richardson * @see struct rte_regexdev_rule::rule_flags 53899a2dd95SBruce Richardson */ 53999a2dd95SBruce Richardson 54099a2dd95SBruce Richardson #define RTE_REGEX_PCRE_RULE_MATCH_UNSET_BACKREF_F (1ULL << 6) 54199a2dd95SBruce Richardson /**< When this flag is set, a backreference to an unset capture group matches an 54299a2dd95SBruce Richardson * empty string. 54399a2dd95SBruce Richardson * 54499a2dd95SBruce Richardson * @see struct rte_regexdev_info::rule_flags 54599a2dd95SBruce Richardson * @see struct rte_regexdev_rule::rule_flags 54699a2dd95SBruce Richardson */ 54799a2dd95SBruce Richardson 54899a2dd95SBruce Richardson #define RTE_REGEX_PCRE_RULE_MULTILINE_F (1ULL << 7) 54999a2dd95SBruce Richardson /**< When this flag is set, the `^` and `$` constructs match immediately 55099a2dd95SBruce Richardson * following or immediately before internal newlines in the subject string, 55199a2dd95SBruce Richardson * respectively, as well as at the very start and end. 55299a2dd95SBruce Richardson * 55399a2dd95SBruce Richardson * @see struct rte_regexdev_info::rule_flags 55499a2dd95SBruce Richardson * @see struct rte_regexdev_rule::rule_flags 55599a2dd95SBruce Richardson */ 55699a2dd95SBruce Richardson 55799a2dd95SBruce Richardson #define RTE_REGEX_PCRE_RULE_NO_AUTO_CAPTURE_F (1ULL << 8) 55899a2dd95SBruce Richardson /**< When this Flag is set, it disables the use of numbered capturing 55999a2dd95SBruce Richardson * parentheses in the pattern. References to capture groups (backreferences or 56099a2dd95SBruce Richardson * recursion/subroutine calls) may only refer to named groups, though the 56199a2dd95SBruce Richardson * reference can be by name or by number. 56299a2dd95SBruce Richardson * 56399a2dd95SBruce Richardson * @see struct rte_regexdev_info::rule_flags 56499a2dd95SBruce Richardson * @see struct rte_regexdev_rule::rule_flags 56599a2dd95SBruce Richardson */ 56699a2dd95SBruce Richardson 56799a2dd95SBruce Richardson #define RTE_REGEX_PCRE_RULE_UCP_F (1ULL << 9) 56899a2dd95SBruce Richardson /**< By default, only ASCII characters are recognized, When this flag is set, 56999a2dd95SBruce Richardson * Unicode properties are used instead to classify characters. 57099a2dd95SBruce Richardson * 57199a2dd95SBruce Richardson * @see struct rte_regexdev_info::rule_flags 57299a2dd95SBruce Richardson * @see struct rte_regexdev_rule::rule_flags 57399a2dd95SBruce Richardson */ 57499a2dd95SBruce Richardson 57599a2dd95SBruce Richardson #define RTE_REGEX_PCRE_RULE_UNGREEDY_F (1ULL << 10) 57699a2dd95SBruce Richardson /**< When this flag is set, the "greediness" of the quantifiers is inverted 57799a2dd95SBruce Richardson * so that they are not greedy by default, but become greedy if followed by 57899a2dd95SBruce Richardson * `?`. 57999a2dd95SBruce Richardson * 58099a2dd95SBruce Richardson * @see struct rte_regexdev_info::rule_flags 58199a2dd95SBruce Richardson * @see struct rte_regexdev_rule::rule_flags 58299a2dd95SBruce Richardson */ 58399a2dd95SBruce Richardson 58499a2dd95SBruce Richardson #define RTE_REGEX_PCRE_RULE_UTF_F (1ULL << 11) 58599a2dd95SBruce Richardson /**< When this flag is set, RegEx engine has to regard both the pattern and the 58699a2dd95SBruce Richardson * subject strings that are subsequently processed as strings of UTF characters 58799a2dd95SBruce Richardson * instead of single-code-unit strings. 58899a2dd95SBruce Richardson * 58999a2dd95SBruce Richardson * @see struct rte_regexdev_info::rule_flags 59099a2dd95SBruce Richardson * @see struct rte_regexdev_rule::rule_flags 59199a2dd95SBruce Richardson */ 59299a2dd95SBruce Richardson 59399a2dd95SBruce Richardson #define RTE_REGEX_PCRE_RULE_NEVER_BACKSLASH_C_F (1ULL << 12) 59499a2dd95SBruce Richardson /**< This flag locks out the use of `\C` in the pattern that is being compiled. 59599a2dd95SBruce Richardson * This escape matches one data unit, even in UTF mode which can cause 59699a2dd95SBruce Richardson * unpredictable behavior in UTF-8 or UTF-16 modes, because it may leave the 59799a2dd95SBruce Richardson * current matching point in the mi:set hlsearchddle of a multi-code-unit 59899a2dd95SBruce Richardson * character. 59999a2dd95SBruce Richardson * 60099a2dd95SBruce Richardson * @see struct rte_regexdev_info::rule_flags 60199a2dd95SBruce Richardson * @see struct rte_regexdev_rule::rule_flags 60299a2dd95SBruce Richardson */ 60399a2dd95SBruce Richardson 60499a2dd95SBruce Richardson /** 60599a2dd95SBruce Richardson * RegEx device information 60699a2dd95SBruce Richardson */ 60799a2dd95SBruce Richardson struct rte_regexdev_info { 60899a2dd95SBruce Richardson const char *driver_name; /**< RegEx driver name. */ 60999a2dd95SBruce Richardson struct rte_device *dev; /**< Device information. */ 61099a2dd95SBruce Richardson uint16_t max_matches; 61199a2dd95SBruce Richardson /**< Maximum matches per scan supported by this device. */ 61299a2dd95SBruce Richardson uint16_t max_queue_pairs; 61399a2dd95SBruce Richardson /**< Maximum queue pairs supported by this device. */ 61499a2dd95SBruce Richardson uint16_t max_payload_size; 61599a2dd95SBruce Richardson /**< Maximum payload size for a pattern match request or scan. 61699a2dd95SBruce Richardson * @see RTE_REGEXDEV_CFG_CROSS_BUFFER_SCAN_F 61799a2dd95SBruce Richardson */ 61870f1ea71SGerry Gribbon uint16_t max_segs; 61970f1ea71SGerry Gribbon /**< Maximum number of mbuf segments that can be chained together. */ 62099a2dd95SBruce Richardson uint32_t max_rules_per_group; 62199a2dd95SBruce Richardson /**< Maximum rules supported per group by this device. */ 62299a2dd95SBruce Richardson uint16_t max_groups; 62399a2dd95SBruce Richardson /**< Maximum groups supported by this device. */ 62499a2dd95SBruce Richardson uint32_t regexdev_capa; 62599a2dd95SBruce Richardson /**< RegEx device capabilities. @see RTE_REGEXDEV_CAPA_* */ 62699a2dd95SBruce Richardson uint64_t rule_flags; 62799a2dd95SBruce Richardson /**< Supported compiler rule flags. 62899a2dd95SBruce Richardson * @see RTE_REGEX_PCRE_RULE_*, struct rte_regexdev_rule::rule_flags 62999a2dd95SBruce Richardson */ 63099a2dd95SBruce Richardson }; 63199a2dd95SBruce Richardson 63299a2dd95SBruce Richardson /** 63399a2dd95SBruce Richardson * @warning 63499a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 63599a2dd95SBruce Richardson * 63699a2dd95SBruce Richardson * Retrieve the contextual information of a RegEx device. 63799a2dd95SBruce Richardson * 63899a2dd95SBruce Richardson * @param dev_id 63999a2dd95SBruce Richardson * The identifier of the device. 64099a2dd95SBruce Richardson * 64199a2dd95SBruce Richardson * @param[out] dev_info 64299a2dd95SBruce Richardson * A pointer to a structure of type *rte_regexdev_info* to be filled with the 64399a2dd95SBruce Richardson * contextual information of the device. 64499a2dd95SBruce Richardson * 64599a2dd95SBruce Richardson * @return 64699a2dd95SBruce Richardson * - 0: Success, driver updates the contextual information of the RegEx device 64799a2dd95SBruce Richardson * - <0: Error code returned by the driver info get function. 64899a2dd95SBruce Richardson */ 64999a2dd95SBruce Richardson __rte_experimental 65099a2dd95SBruce Richardson int 65199a2dd95SBruce Richardson rte_regexdev_info_get(uint8_t dev_id, struct rte_regexdev_info *dev_info); 65299a2dd95SBruce Richardson 65399a2dd95SBruce Richardson /* Enumerates RegEx device configuration flags */ 65499a2dd95SBruce Richardson #define RTE_REGEXDEV_CFG_CROSS_BUFFER_SCAN_F (1ULL << 0) 65599a2dd95SBruce Richardson /**< Cross buffer scan refers to the ability to be able to detect 65699a2dd95SBruce Richardson * matches that occur across buffer boundaries, where the buffers are related 65799a2dd95SBruce Richardson * to each other in some way. Enable this flag when to scan payload size 65899a2dd95SBruce Richardson * greater than struct rte_regexdev_info::max_payload_size and/or 65999a2dd95SBruce Richardson * matches can present across scan buffer boundaries. 66099a2dd95SBruce Richardson * 66199a2dd95SBruce Richardson * @see struct rte_regexdev_info::max_payload_size 66299a2dd95SBruce Richardson * @see struct rte_regexdev_config::dev_cfg_flags, rte_regexdev_configure() 66399a2dd95SBruce Richardson * @see RTE_REGEX_OPS_RSP_PMI_SOJ_F 66499a2dd95SBruce Richardson * @see RTE_REGEX_OPS_RSP_PMI_EOJ_F 66599a2dd95SBruce Richardson */ 66699a2dd95SBruce Richardson 66799a2dd95SBruce Richardson #define RTE_REGEXDEV_CFG_MATCH_AS_END_F (1ULL << 1) 66899a2dd95SBruce Richardson /**< Match as end is the ability to return the result as ending offset. 66999a2dd95SBruce Richardson * When this flag is set, the result for each match will hold the ending 67099a2dd95SBruce Richardson * offset of the match in end_offset. 67199a2dd95SBruce Richardson * If this flag is not set, then the match result will hold the starting offset 67299a2dd95SBruce Richardson * in start_offset, and the length of the match in len. 67399a2dd95SBruce Richardson * 67499a2dd95SBruce Richardson * @see RTE_REGEXDEV_SUPP_MATCH_AS_END_F 67599a2dd95SBruce Richardson */ 67699a2dd95SBruce Richardson 67799a2dd95SBruce Richardson #define RTE_REGEXDEV_CFG_MATCH_ALL_F (1ULL << 2) 67899a2dd95SBruce Richardson /**< Match all is the ability to return all possible results. 67999a2dd95SBruce Richardson * 68099a2dd95SBruce Richardson * @see RTE_REGEXDEV_SUPP_MATCH_ALL_F 68199a2dd95SBruce Richardson */ 68299a2dd95SBruce Richardson 68399a2dd95SBruce Richardson /** RegEx device configuration structure */ 68499a2dd95SBruce Richardson struct rte_regexdev_config { 68599a2dd95SBruce Richardson uint16_t nb_max_matches; 68699a2dd95SBruce Richardson /**< Maximum matches per scan configured on this device. 68799a2dd95SBruce Richardson * This value cannot exceed the *max_matches* 68899a2dd95SBruce Richardson * which previously provided in rte_regexdev_info_get(). 68999a2dd95SBruce Richardson * The value 0 is allowed, in which case, value 1 used. 69099a2dd95SBruce Richardson * @see struct rte_regexdev_info::max_matches 69199a2dd95SBruce Richardson */ 69299a2dd95SBruce Richardson uint16_t nb_queue_pairs; 69399a2dd95SBruce Richardson /**< Number of RegEx queue pairs to configure on this device. 69499a2dd95SBruce Richardson * This value cannot exceed the *max_queue_pairs* which previously 69599a2dd95SBruce Richardson * provided in rte_regexdev_info_get(). 69699a2dd95SBruce Richardson * @see struct rte_regexdev_info::max_queue_pairs 69799a2dd95SBruce Richardson */ 69899a2dd95SBruce Richardson uint32_t nb_rules_per_group; 69999a2dd95SBruce Richardson /**< Number of rules per group to configure on this device. 70099a2dd95SBruce Richardson * This value cannot exceed the *max_rules_per_group* 70199a2dd95SBruce Richardson * which previously provided in rte_regexdev_info_get(). 70299a2dd95SBruce Richardson * The value 0 is allowed, in which case, 70399a2dd95SBruce Richardson * struct rte_regexdev_info::max_rules_per_group used. 70499a2dd95SBruce Richardson * @see struct rte_regexdev_info::max_rules_per_group 70599a2dd95SBruce Richardson */ 70699a2dd95SBruce Richardson uint16_t nb_groups; 70799a2dd95SBruce Richardson /**< Number of groups to configure on this device. 70899a2dd95SBruce Richardson * This value cannot exceed the *max_groups* 70999a2dd95SBruce Richardson * which previously provided in rte_regexdev_info_get(). 71099a2dd95SBruce Richardson * @see struct rte_regexdev_info::max_groups 71199a2dd95SBruce Richardson */ 71299a2dd95SBruce Richardson const char *rule_db; 71399a2dd95SBruce Richardson /**< Import initial set of prebuilt rule database on this device. 71499a2dd95SBruce Richardson * The value NULL is allowed, in which case, the device will not 71599a2dd95SBruce Richardson * be configured prebuilt rule database. Application may use 71699a2dd95SBruce Richardson * rte_regexdev_rule_db_update() or rte_regexdev_rule_db_import() API 71799a2dd95SBruce Richardson * to update or import rule database after the 71899a2dd95SBruce Richardson * rte_regexdev_configure(). 71999a2dd95SBruce Richardson * @see rte_regexdev_rule_db_update(), rte_regexdev_rule_db_import() 72099a2dd95SBruce Richardson */ 72199a2dd95SBruce Richardson uint32_t rule_db_len; 72299a2dd95SBruce Richardson /**< Length of *rule_db* buffer. */ 72399a2dd95SBruce Richardson uint32_t dev_cfg_flags; 72499a2dd95SBruce Richardson /**< RegEx device configuration flags, See RTE_REGEXDEV_CFG_* */ 72599a2dd95SBruce Richardson }; 72699a2dd95SBruce Richardson 72799a2dd95SBruce Richardson /** 72899a2dd95SBruce Richardson * @warning 72999a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 73099a2dd95SBruce Richardson * 73199a2dd95SBruce Richardson * Configure a RegEx device. 73299a2dd95SBruce Richardson * 73399a2dd95SBruce Richardson * This function must be invoked first before any other function in the 73499a2dd95SBruce Richardson * API. This function can also be re-invoked when a device is in the 73599a2dd95SBruce Richardson * stopped state. 73699a2dd95SBruce Richardson * 73799a2dd95SBruce Richardson * The caller may use rte_regexdev_info_get() to get the capability of each 73899a2dd95SBruce Richardson * resources available for this regex device. 73999a2dd95SBruce Richardson * 74099a2dd95SBruce Richardson * @param dev_id 74199a2dd95SBruce Richardson * The identifier of the device to configure. 74299a2dd95SBruce Richardson * @param cfg 74399a2dd95SBruce Richardson * The RegEx device configuration structure. 74499a2dd95SBruce Richardson * 74599a2dd95SBruce Richardson * @return 74699a2dd95SBruce Richardson * - 0: Success, device configured. Otherwise negative errno is returned. 74799a2dd95SBruce Richardson */ 74899a2dd95SBruce Richardson __rte_experimental 74999a2dd95SBruce Richardson int 75099a2dd95SBruce Richardson rte_regexdev_configure(uint8_t dev_id, const struct rte_regexdev_config *cfg); 75199a2dd95SBruce Richardson 75299a2dd95SBruce Richardson /* Enumerates RegEx queue pair configuration flags */ 75399a2dd95SBruce Richardson #define RTE_REGEX_QUEUE_PAIR_CFG_OOS_F (1ULL << 0) 75499a2dd95SBruce Richardson /**< Out of order scan, If not set, a scan must retire after previously issued 75599a2dd95SBruce Richardson * in-order scans to this queue pair. If set, this scan can be retired as soon 75699a2dd95SBruce Richardson * as device returns completion. Application should not set out of order scan 75799a2dd95SBruce Richardson * flag if it needs to maintain the ingress order of scan request. 75899a2dd95SBruce Richardson * 75999a2dd95SBruce Richardson * @see struct rte_regexdev_qp_conf::qp_conf_flags 76099a2dd95SBruce Richardson * @see rte_regexdev_queue_pair_setup() 76199a2dd95SBruce Richardson */ 76299a2dd95SBruce Richardson 76399a2dd95SBruce Richardson struct rte_regex_ops; 76499a2dd95SBruce Richardson typedef void (*regexdev_stop_flush_t)(uint8_t dev_id, uint16_t qp_id, 76599a2dd95SBruce Richardson struct rte_regex_ops *op); 76699a2dd95SBruce Richardson /**< Callback function called during rte_regexdev_stop(), invoked once per 76799a2dd95SBruce Richardson * flushed RegEx op. 76899a2dd95SBruce Richardson */ 76999a2dd95SBruce Richardson 77099a2dd95SBruce Richardson /** RegEx queue pair configuration structure */ 77199a2dd95SBruce Richardson struct rte_regexdev_qp_conf { 77299a2dd95SBruce Richardson uint32_t qp_conf_flags; 77399a2dd95SBruce Richardson /**< Queue pair config flags, See RTE_REGEX_QUEUE_PAIR_CFG_* */ 77499a2dd95SBruce Richardson uint16_t nb_desc; 77599a2dd95SBruce Richardson /**< The number of descriptors to allocate for this queue pair. */ 77699a2dd95SBruce Richardson regexdev_stop_flush_t cb; 77799a2dd95SBruce Richardson /**< Callback function called during rte_regexdev_stop(), invoked 77899a2dd95SBruce Richardson * once per flushed regex op. Value NULL is allowed, in which case 77999a2dd95SBruce Richardson * callback will not be invoked. This function can be used to properly 78099a2dd95SBruce Richardson * dispose of outstanding regex ops from response queue, 78199a2dd95SBruce Richardson * for example ops containing memory pointers. 78299a2dd95SBruce Richardson * @see rte_regexdev_stop() 78399a2dd95SBruce Richardson */ 78499a2dd95SBruce Richardson }; 78599a2dd95SBruce Richardson 78699a2dd95SBruce Richardson /** 78799a2dd95SBruce Richardson * @warning 78899a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 78999a2dd95SBruce Richardson * 79099a2dd95SBruce Richardson * Allocate and set up a RegEx queue pair for a RegEx device. 79199a2dd95SBruce Richardson * 79299a2dd95SBruce Richardson * @param dev_id 79399a2dd95SBruce Richardson * The identifier of the device. 79499a2dd95SBruce Richardson * @param queue_pair_id 79599a2dd95SBruce Richardson * The index of the RegEx queue pair to setup. The value must be in the range 79699a2dd95SBruce Richardson * [0, nb_queue_pairs - 1] previously supplied to rte_regexdev_configure(). 79799a2dd95SBruce Richardson * @param qp_conf 79899a2dd95SBruce Richardson * The pointer to the configuration data to be used for the RegEx queue pair. 79999a2dd95SBruce Richardson * NULL value is allowed, in which case default configuration used. 80099a2dd95SBruce Richardson * 80199a2dd95SBruce Richardson * @return 80299a2dd95SBruce Richardson * 0 on success. Otherwise negative errno is returned. 80399a2dd95SBruce Richardson */ 80499a2dd95SBruce Richardson __rte_experimental 80599a2dd95SBruce Richardson int 80699a2dd95SBruce Richardson rte_regexdev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id, 80799a2dd95SBruce Richardson const struct rte_regexdev_qp_conf *qp_conf); 80899a2dd95SBruce Richardson 80999a2dd95SBruce Richardson /** 81099a2dd95SBruce Richardson * @warning 81199a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 81299a2dd95SBruce Richardson * 81399a2dd95SBruce Richardson * Start a RegEx device. 81499a2dd95SBruce Richardson * 81599a2dd95SBruce Richardson * The device start step is the last one and consists of setting the RegEx 81699a2dd95SBruce Richardson * queues to start accepting the pattern matching scan requests. 81799a2dd95SBruce Richardson * 81899a2dd95SBruce Richardson * On success, all basic functions exported by the API (RegEx enqueue, 81999a2dd95SBruce Richardson * RegEx dequeue and so on) can be invoked. 82099a2dd95SBruce Richardson * 82199a2dd95SBruce Richardson * @param dev_id 82299a2dd95SBruce Richardson * RegEx device identifier. 82399a2dd95SBruce Richardson * 82499a2dd95SBruce Richardson * @return 82599a2dd95SBruce Richardson * 0 on success. Otherwise negative errno is returned. 82699a2dd95SBruce Richardson */ 82799a2dd95SBruce Richardson __rte_experimental 82899a2dd95SBruce Richardson int 82999a2dd95SBruce Richardson rte_regexdev_start(uint8_t dev_id); 83099a2dd95SBruce Richardson 83199a2dd95SBruce Richardson /** 83299a2dd95SBruce Richardson * @warning 83399a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 83499a2dd95SBruce Richardson * 83599a2dd95SBruce Richardson * Stop a RegEx device. 83699a2dd95SBruce Richardson * 83799a2dd95SBruce Richardson * Stop a RegEx device. The device can be restarted with a call to 83899a2dd95SBruce Richardson * rte_regexdev_start(). 83999a2dd95SBruce Richardson * 84099a2dd95SBruce Richardson * This function causes all queued response regex ops to be drained in the 84199a2dd95SBruce Richardson * response queue. While draining ops out of the device, 84299a2dd95SBruce Richardson * struct rte_regexdev_qp_conf::cb will be invoked for each ops. 84399a2dd95SBruce Richardson * 84499a2dd95SBruce Richardson * @param dev_id 84599a2dd95SBruce Richardson * RegEx device identifier. 84699a2dd95SBruce Richardson * 84799a2dd95SBruce Richardson * @return 84899a2dd95SBruce Richardson * 0 on success. Otherwise negative errno is returned. 84999a2dd95SBruce Richardson */ 85099a2dd95SBruce Richardson __rte_experimental 85199a2dd95SBruce Richardson int 85299a2dd95SBruce Richardson rte_regexdev_stop(uint8_t dev_id); 85399a2dd95SBruce Richardson 85499a2dd95SBruce Richardson /** 85599a2dd95SBruce Richardson * @warning 85699a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 85799a2dd95SBruce Richardson * 85899a2dd95SBruce Richardson * Close a RegEx device. The device cannot be restarted! 85999a2dd95SBruce Richardson * 86099a2dd95SBruce Richardson * @param dev_id 86199a2dd95SBruce Richardson * RegEx device identifier 86299a2dd95SBruce Richardson * 86399a2dd95SBruce Richardson * @return 86499a2dd95SBruce Richardson * 0 on success. Otherwise negative errno is returned. 86599a2dd95SBruce Richardson */ 86699a2dd95SBruce Richardson __rte_experimental 86799a2dd95SBruce Richardson int 86899a2dd95SBruce Richardson rte_regexdev_close(uint8_t dev_id); 86999a2dd95SBruce Richardson 87099a2dd95SBruce Richardson /* Device get/set attributes */ 87199a2dd95SBruce Richardson 87299a2dd95SBruce Richardson /** Enumerates RegEx device attribute identifier */ 87399a2dd95SBruce Richardson enum rte_regexdev_attr_id { 87499a2dd95SBruce Richardson RTE_REGEXDEV_ATTR_SOCKET_ID, 87599a2dd95SBruce Richardson /**< The NUMA socket id to which the device is connected or 87699a2dd95SBruce Richardson * a default of zero if the socket could not be determined. 87799a2dd95SBruce Richardson * datatype: *int* 87899a2dd95SBruce Richardson * operation: *get* 87999a2dd95SBruce Richardson */ 88099a2dd95SBruce Richardson RTE_REGEXDEV_ATTR_MAX_MATCHES, 88199a2dd95SBruce Richardson /**< Maximum number of matches per scan. 88299a2dd95SBruce Richardson * datatype: *uint8_t* 88399a2dd95SBruce Richardson * operation: *get* and *set* 88499a2dd95SBruce Richardson * @see RTE_REGEX_OPS_RSP_MAX_MATCH_F 88599a2dd95SBruce Richardson */ 88699a2dd95SBruce Richardson RTE_REGEXDEV_ATTR_MAX_SCAN_TIMEOUT, 88799a2dd95SBruce Richardson /**< Upper bound scan time in ns. 88899a2dd95SBruce Richardson * datatype: *uint16_t* 88999a2dd95SBruce Richardson * operation: *get* and *set* 89099a2dd95SBruce Richardson * @see RTE_REGEX_OPS_RSP_MAX_SCAN_TIMEOUT_F 89199a2dd95SBruce Richardson */ 89299a2dd95SBruce Richardson RTE_REGEXDEV_ATTR_MAX_PREFIX, 89399a2dd95SBruce Richardson /**< Maximum number of prefix detected per scan. 89499a2dd95SBruce Richardson * This would be useful for denial of service detection. 89599a2dd95SBruce Richardson * datatype: *uint16_t* 89699a2dd95SBruce Richardson * operation: *get* and *set* 89799a2dd95SBruce Richardson * @see RTE_REGEX_OPS_RSP_MAX_PREFIX_F 89899a2dd95SBruce Richardson */ 89999a2dd95SBruce Richardson }; 90099a2dd95SBruce Richardson 90199a2dd95SBruce Richardson /** 90299a2dd95SBruce Richardson * @warning 90399a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 90499a2dd95SBruce Richardson * 90599a2dd95SBruce Richardson * Get an attribute from a RegEx device. 90699a2dd95SBruce Richardson * 90799a2dd95SBruce Richardson * @param dev_id 90899a2dd95SBruce Richardson * RegEx device identifier. 90999a2dd95SBruce Richardson * @param attr_id 91099a2dd95SBruce Richardson * The attribute ID to retrieve. 91199a2dd95SBruce Richardson * @param attr_value 91299a2dd95SBruce Richardson * A pointer that will be filled in with the attribute 91399a2dd95SBruce Richardson * value if successful. 91499a2dd95SBruce Richardson * 91599a2dd95SBruce Richardson * @return 91699a2dd95SBruce Richardson * - 0: Successfully retrieved attribute value. 91799a2dd95SBruce Richardson * - -EINVAL: Invalid device or *attr_id* provided, or *attr_value* is NULL. 91899a2dd95SBruce Richardson * - -ENOTSUP: if the device doesn't support specific *attr_id*. 91999a2dd95SBruce Richardson */ 92099a2dd95SBruce Richardson __rte_experimental 92199a2dd95SBruce Richardson int 92299a2dd95SBruce Richardson rte_regexdev_attr_get(uint8_t dev_id, enum rte_regexdev_attr_id attr_id, 92399a2dd95SBruce Richardson void *attr_value); 92499a2dd95SBruce Richardson 92599a2dd95SBruce Richardson /** 92699a2dd95SBruce Richardson * @warning 92799a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 92899a2dd95SBruce Richardson * 92999a2dd95SBruce Richardson * Set an attribute to a RegEx device. 93099a2dd95SBruce Richardson * 93199a2dd95SBruce Richardson * @param dev_id 93299a2dd95SBruce Richardson * RegEx device identifier. 93399a2dd95SBruce Richardson * @param attr_id 93499a2dd95SBruce Richardson * The attribute ID to retrieve. 93599a2dd95SBruce Richardson * @param attr_value 93699a2dd95SBruce Richardson * Pointer that will be filled in with the attribute value 93799a2dd95SBruce Richardson * by the application. 93899a2dd95SBruce Richardson * 93999a2dd95SBruce Richardson * @return 94099a2dd95SBruce Richardson * - 0: Successfully applied the attribute value. 94199a2dd95SBruce Richardson * - -EINVAL: Invalid device or *attr_id* provided, or *attr_value* is NULL. 94299a2dd95SBruce Richardson * - -ENOTSUP: if the device doesn't support specific *attr_id*. 94399a2dd95SBruce Richardson */ 94499a2dd95SBruce Richardson __rte_experimental 94599a2dd95SBruce Richardson int 94699a2dd95SBruce Richardson rte_regexdev_attr_set(uint8_t dev_id, enum rte_regexdev_attr_id attr_id, 94799a2dd95SBruce Richardson const void *attr_value); 94899a2dd95SBruce Richardson 94999a2dd95SBruce Richardson /* Rule related APIs */ 95099a2dd95SBruce Richardson /** Enumerates RegEx rule operation. */ 95199a2dd95SBruce Richardson enum rte_regexdev_rule_op { 95299a2dd95SBruce Richardson RTE_REGEX_RULE_OP_ADD, 95399a2dd95SBruce Richardson /**< Add RegEx rule to rule database. */ 95499a2dd95SBruce Richardson RTE_REGEX_RULE_OP_REMOVE 95599a2dd95SBruce Richardson /**< Remove RegEx rule from rule database. */ 95699a2dd95SBruce Richardson }; 95799a2dd95SBruce Richardson 95899a2dd95SBruce Richardson /** Structure to hold a RegEx rule attributes. */ 95999a2dd95SBruce Richardson struct rte_regexdev_rule { 96099a2dd95SBruce Richardson enum rte_regexdev_rule_op op; 96199a2dd95SBruce Richardson /**< OP type of the rule either a OP_ADD or OP_DELETE. */ 96299a2dd95SBruce Richardson uint16_t group_id; 96399a2dd95SBruce Richardson /**< Group identifier to which the rule belongs to. */ 96499a2dd95SBruce Richardson uint32_t rule_id; 96599a2dd95SBruce Richardson /**< Rule identifier which is returned on successful match. */ 96699a2dd95SBruce Richardson const char *pcre_rule; 96799a2dd95SBruce Richardson /**< Buffer to hold the PCRE rule. */ 96899a2dd95SBruce Richardson uint16_t pcre_rule_len; 96999a2dd95SBruce Richardson /**< Length of the PCRE rule. */ 97099a2dd95SBruce Richardson uint64_t rule_flags; 97199a2dd95SBruce Richardson /* PCRE rule flags. Supported device specific PCRE rules enumerated 97299a2dd95SBruce Richardson * in struct rte_regexdev_info::rule_flags. For successful rule 97399a2dd95SBruce Richardson * database update, application needs to provide only supported 97499a2dd95SBruce Richardson * rule flags. 97599a2dd95SBruce Richardson * @See RTE_REGEX_PCRE_RULE_*, struct rte_regexdev_info::rule_flags 97699a2dd95SBruce Richardson */ 97799a2dd95SBruce Richardson }; 97899a2dd95SBruce Richardson 97999a2dd95SBruce Richardson /** 98099a2dd95SBruce Richardson * @warning 98199a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 98299a2dd95SBruce Richardson * 98399a2dd95SBruce Richardson * Update the local rule set. 98499a2dd95SBruce Richardson * This functions only modify the rule set in memory. 98599a2dd95SBruce Richardson * In order for the changes to take effect, the function 98699a2dd95SBruce Richardson * rte_regexdev_rule_db_compile_active must be called. 98799a2dd95SBruce Richardson * 98899a2dd95SBruce Richardson * @param dev_id 98999a2dd95SBruce Richardson * RegEx device identifier. 99099a2dd95SBruce Richardson * @param rules 99199a2dd95SBruce Richardson * Points to an array of *nb_rules* objects of type *rte_regexdev_rule* 99299a2dd95SBruce Richardson * structure which contain the regex rules attributes to be updated 99399a2dd95SBruce Richardson * in rule database. 99499a2dd95SBruce Richardson * @param nb_rules 99599a2dd95SBruce Richardson * The number of PCRE rules to update the rule database. 99699a2dd95SBruce Richardson * 99799a2dd95SBruce Richardson * @return 99899a2dd95SBruce Richardson * The number of regex rules actually updated on the regex device's rule 99999a2dd95SBruce Richardson * database. The return value can be less than the value of the *nb_rules* 100099a2dd95SBruce Richardson * parameter when the regex devices fails to update the rule database or 100199a2dd95SBruce Richardson * if invalid parameters are specified in a *rte_regexdev_rule*. 100299a2dd95SBruce Richardson * If the return value is less than *nb_rules*, the remaining PCRE rules 100399a2dd95SBruce Richardson * at the end of *rules* are not consumed and the caller has to take 100499a2dd95SBruce Richardson * care of them and rte_errno is set accordingly. 100599a2dd95SBruce Richardson * Possible errno values include: 100699a2dd95SBruce Richardson * - -EINVAL: Invalid device ID or rules is NULL 100799a2dd95SBruce Richardson * - -ENOTSUP: The last processed rule is not supported on this device. 100899a2dd95SBruce Richardson * - -ENOSPC: No space available in rule database. 100999a2dd95SBruce Richardson * 101099a2dd95SBruce Richardson * @see rte_regexdev_rule_db_import(), rte_regexdev_rule_db_export(), 101199a2dd95SBruce Richardson * rte_regexdev_rule_db_compile_activate() 101299a2dd95SBruce Richardson */ 101399a2dd95SBruce Richardson __rte_experimental 101499a2dd95SBruce Richardson int 101599a2dd95SBruce Richardson rte_regexdev_rule_db_update(uint8_t dev_id, 101699a2dd95SBruce Richardson const struct rte_regexdev_rule *rules, 101799a2dd95SBruce Richardson uint32_t nb_rules); 101899a2dd95SBruce Richardson 101999a2dd95SBruce Richardson /** 102099a2dd95SBruce Richardson * @warning 102199a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 102299a2dd95SBruce Richardson * 102399a2dd95SBruce Richardson * Compile local rule set and burn the complied result to the 10247be78d02SJosh Soref * RegEx device. 102599a2dd95SBruce Richardson * 102699a2dd95SBruce Richardson * @param dev_id 102799a2dd95SBruce Richardson * RegEx device identifier. 102899a2dd95SBruce Richardson * 102999a2dd95SBruce Richardson * @return 103099a2dd95SBruce Richardson * 0 on success, otherwise negative errno. 103199a2dd95SBruce Richardson * 103299a2dd95SBruce Richardson * @see rte_regexdev_rule_db_import(), rte_regexdev_rule_db_export(), 103399a2dd95SBruce Richardson * rte_regexdev_rule_db_update() 103499a2dd95SBruce Richardson */ 103599a2dd95SBruce Richardson __rte_experimental 103699a2dd95SBruce Richardson int 103799a2dd95SBruce Richardson rte_regexdev_rule_db_compile_activate(uint8_t dev_id); 103899a2dd95SBruce Richardson 103999a2dd95SBruce Richardson /** 104099a2dd95SBruce Richardson * @warning 104199a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 104299a2dd95SBruce Richardson * 104399a2dd95SBruce Richardson * Import a prebuilt rule database from a buffer to a RegEx device. 104499a2dd95SBruce Richardson * 104599a2dd95SBruce Richardson * @param dev_id 104699a2dd95SBruce Richardson * RegEx device identifier. 104799a2dd95SBruce Richardson * @param rule_db 104899a2dd95SBruce Richardson * Points to prebuilt rule database. 104999a2dd95SBruce Richardson * @param rule_db_len 105099a2dd95SBruce Richardson * Length of the rule database. 105199a2dd95SBruce Richardson * 105299a2dd95SBruce Richardson * @return 105399a2dd95SBruce Richardson * - 0: Successfully updated the prebuilt rule database. 105499a2dd95SBruce Richardson * - -EINVAL: Invalid device ID or rule_db is NULL 105599a2dd95SBruce Richardson * - -ENOTSUP: Rule database import is not supported on this device. 105699a2dd95SBruce Richardson * - -ENOSPC: No space available in rule database. 105799a2dd95SBruce Richardson * 105899a2dd95SBruce Richardson * @see rte_regexdev_rule_db_update(), rte_regexdev_rule_db_export() 105999a2dd95SBruce Richardson */ 106099a2dd95SBruce Richardson __rte_experimental 106199a2dd95SBruce Richardson int 106299a2dd95SBruce Richardson rte_regexdev_rule_db_import(uint8_t dev_id, const char *rule_db, 106399a2dd95SBruce Richardson uint32_t rule_db_len); 106499a2dd95SBruce Richardson 106599a2dd95SBruce Richardson /** 106699a2dd95SBruce Richardson * @warning 106799a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 106899a2dd95SBruce Richardson * 106999a2dd95SBruce Richardson * Export the prebuilt rule database from a RegEx device to the buffer. 107099a2dd95SBruce Richardson * 107199a2dd95SBruce Richardson * @param dev_id 107299a2dd95SBruce Richardson * RegEx device identifier. 107399a2dd95SBruce Richardson * @param[out] rule_db 107499a2dd95SBruce Richardson * Block of memory to insert the rule database. Must be at least size in 107599a2dd95SBruce Richardson * capacity. If set to NULL, function returns required capacity. 107699a2dd95SBruce Richardson * 107799a2dd95SBruce Richardson * @return 107899a2dd95SBruce Richardson * - 0: Successfully exported the prebuilt rule database. 107999a2dd95SBruce Richardson * - size: If rule_db set to NULL then required capacity for *rule_db* 108099a2dd95SBruce Richardson * - -EINVAL: Invalid device ID 108199a2dd95SBruce Richardson * - -ENOTSUP: Rule database export is not supported on this device. 108299a2dd95SBruce Richardson * 108399a2dd95SBruce Richardson * @see rte_regexdev_rule_db_update(), rte_regexdev_rule_db_import() 108499a2dd95SBruce Richardson */ 108599a2dd95SBruce Richardson __rte_experimental 108699a2dd95SBruce Richardson int 108799a2dd95SBruce Richardson rte_regexdev_rule_db_export(uint8_t dev_id, char *rule_db); 108899a2dd95SBruce Richardson 108999a2dd95SBruce Richardson /* Extended statistics */ 109099a2dd95SBruce Richardson /** Maximum name length for extended statistics counters */ 109199a2dd95SBruce Richardson #define RTE_REGEXDEV_XSTATS_NAME_SIZE 64 109299a2dd95SBruce Richardson 109399a2dd95SBruce Richardson /** 109499a2dd95SBruce Richardson * A name-key lookup element for extended statistics. 109599a2dd95SBruce Richardson * 109699a2dd95SBruce Richardson * This structure is used to map between names and ID numbers 109799a2dd95SBruce Richardson * for extended RegEx device statistics. 109899a2dd95SBruce Richardson */ 109999a2dd95SBruce Richardson struct rte_regexdev_xstats_map { 110099a2dd95SBruce Richardson uint16_t id; 110199a2dd95SBruce Richardson /**< xstat identifier */ 110299a2dd95SBruce Richardson char name[RTE_REGEXDEV_XSTATS_NAME_SIZE]; 110399a2dd95SBruce Richardson /**< xstat name */ 110499a2dd95SBruce Richardson }; 110599a2dd95SBruce Richardson 110699a2dd95SBruce Richardson /** 110799a2dd95SBruce Richardson * @warning 110899a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 110999a2dd95SBruce Richardson * 111099a2dd95SBruce Richardson * Retrieve names of extended statistics of a regex device. 111199a2dd95SBruce Richardson * 111299a2dd95SBruce Richardson * @param dev_id 111399a2dd95SBruce Richardson * The identifier of the regex device. 111499a2dd95SBruce Richardson * @param[out] xstats_map 111599a2dd95SBruce Richardson * Block of memory to insert id and names into. Must be at least size in 111699a2dd95SBruce Richardson * capacity. If set to NULL, function returns required capacity. 111799a2dd95SBruce Richardson * @return 111899a2dd95SBruce Richardson * - Positive value on success: 111999a2dd95SBruce Richardson * -The return value is the number of entries filled in the stats map. 112099a2dd95SBruce Richardson * -If xstats_map set to NULL then required capacity for xstats_map. 112199a2dd95SBruce Richardson * - Negative value on error: 112299a2dd95SBruce Richardson * -ENODEV for invalid *dev_id* 112399a2dd95SBruce Richardson * -ENOTSUP if the device doesn't support this function. 112499a2dd95SBruce Richardson */ 112599a2dd95SBruce Richardson __rte_experimental 112699a2dd95SBruce Richardson int 112799a2dd95SBruce Richardson rte_regexdev_xstats_names_get(uint8_t dev_id, 112899a2dd95SBruce Richardson struct rte_regexdev_xstats_map *xstats_map); 112999a2dd95SBruce Richardson 113099a2dd95SBruce Richardson /** 113199a2dd95SBruce Richardson * @warning 113299a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 113399a2dd95SBruce Richardson * 113499a2dd95SBruce Richardson * Retrieve extended statistics of an regex device. 113599a2dd95SBruce Richardson * 113699a2dd95SBruce Richardson * @param dev_id 113799a2dd95SBruce Richardson * The identifier of the device. 113899a2dd95SBruce Richardson * @param ids 113999a2dd95SBruce Richardson * The id numbers of the stats to get. The ids can be got from the stat 114099a2dd95SBruce Richardson * position in the stat list from rte_regexdev_xstats_names_get(), or 114199a2dd95SBruce Richardson * by using rte_regexdev_xstats_by_name_get(). 114299a2dd95SBruce Richardson * @param values 114399a2dd95SBruce Richardson * The values for each stats request by ID. 114499a2dd95SBruce Richardson * @param nb_values 114599a2dd95SBruce Richardson * The number of stats requested. 114699a2dd95SBruce Richardson * @return 114799a2dd95SBruce Richardson * - Positive value: number of stat entries filled into the values array 114899a2dd95SBruce Richardson * - Negative value on error: 114999a2dd95SBruce Richardson * -ENODEV for invalid *dev_id* 115099a2dd95SBruce Richardson * -ENOTSUP if the device doesn't support this function. 115199a2dd95SBruce Richardson */ 115299a2dd95SBruce Richardson __rte_experimental 115399a2dd95SBruce Richardson int 115499a2dd95SBruce Richardson rte_regexdev_xstats_get(uint8_t dev_id, const uint16_t *ids, 115599a2dd95SBruce Richardson uint64_t *values, uint16_t nb_values); 115699a2dd95SBruce Richardson 115799a2dd95SBruce Richardson /** 115899a2dd95SBruce Richardson * @warning 115999a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 116099a2dd95SBruce Richardson * 116199a2dd95SBruce Richardson * Retrieve the value of a single stat by requesting it by name. 116299a2dd95SBruce Richardson * 116399a2dd95SBruce Richardson * @param dev_id 116499a2dd95SBruce Richardson * The identifier of the device. 116599a2dd95SBruce Richardson * @param name 116699a2dd95SBruce Richardson * The stat name to retrieve. 116799a2dd95SBruce Richardson * @param id 116899a2dd95SBruce Richardson * If non-NULL, the numerical id of the stat will be returned, so that further 116999a2dd95SBruce Richardson * requests for the stat can be got using rte_regexdev_xstats_get, which will 117099a2dd95SBruce Richardson * be faster as it doesn't need to scan a list of names for the stat. 117199a2dd95SBruce Richardson * @param[out] value 117299a2dd95SBruce Richardson * Must be non-NULL, retrieved xstat value will be stored in this address. 117399a2dd95SBruce Richardson * 117499a2dd95SBruce Richardson * @return 117599a2dd95SBruce Richardson * - 0: Successfully retrieved xstat value. 117699a2dd95SBruce Richardson * - -EINVAL: invalid parameters 117799a2dd95SBruce Richardson * - -ENOTSUP: if not supported. 117899a2dd95SBruce Richardson */ 117999a2dd95SBruce Richardson __rte_experimental 118099a2dd95SBruce Richardson int 118199a2dd95SBruce Richardson rte_regexdev_xstats_by_name_get(uint8_t dev_id, const char *name, 118299a2dd95SBruce Richardson uint16_t *id, uint64_t *value); 118399a2dd95SBruce Richardson 118499a2dd95SBruce Richardson /** 118599a2dd95SBruce Richardson * @warning 118699a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 118799a2dd95SBruce Richardson * 118899a2dd95SBruce Richardson * Reset the values of the xstats of the selected component in the device. 118999a2dd95SBruce Richardson * 119099a2dd95SBruce Richardson * @param dev_id 119199a2dd95SBruce Richardson * The identifier of the device. 119299a2dd95SBruce Richardson * @param ids 119399a2dd95SBruce Richardson * Selects specific statistics to be reset. When NULL, all statistics will be 119499a2dd95SBruce Richardson * reset. If non-NULL, must point to array of at least *nb_ids* size. 119599a2dd95SBruce Richardson * @param nb_ids 119699a2dd95SBruce Richardson * The number of ids available from the *ids* array. Ignored when ids is NULL. 119799a2dd95SBruce Richardson * 119899a2dd95SBruce Richardson * @return 119999a2dd95SBruce Richardson * - 0: Successfully reset the statistics to zero. 120099a2dd95SBruce Richardson * - -EINVAL: invalid parameters. 120199a2dd95SBruce Richardson * - -ENOTSUP: if not supported. 120299a2dd95SBruce Richardson */ 120399a2dd95SBruce Richardson __rte_experimental 120499a2dd95SBruce Richardson int 120599a2dd95SBruce Richardson rte_regexdev_xstats_reset(uint8_t dev_id, const uint16_t *ids, 120699a2dd95SBruce Richardson uint16_t nb_ids); 120799a2dd95SBruce Richardson 120899a2dd95SBruce Richardson /** 120999a2dd95SBruce Richardson * @warning 121099a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 121199a2dd95SBruce Richardson * 121299a2dd95SBruce Richardson * Trigger the RegEx device self test. 121399a2dd95SBruce Richardson * 121499a2dd95SBruce Richardson * @param dev_id 121599a2dd95SBruce Richardson * The identifier of the device. 121699a2dd95SBruce Richardson * @return 121799a2dd95SBruce Richardson * - 0: Selftest successful. 121899a2dd95SBruce Richardson * - -ENOTSUP if the device doesn't support selftest. 121999a2dd95SBruce Richardson * - other values < 0 on failure. 122099a2dd95SBruce Richardson */ 122199a2dd95SBruce Richardson __rte_experimental 122299a2dd95SBruce Richardson int 122399a2dd95SBruce Richardson rte_regexdev_selftest(uint8_t dev_id); 122499a2dd95SBruce Richardson 122599a2dd95SBruce Richardson /** 122699a2dd95SBruce Richardson * @warning 122799a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 122899a2dd95SBruce Richardson * 122999a2dd95SBruce Richardson * Dump internal information about *dev_id* to the FILE* provided in *f*. 123099a2dd95SBruce Richardson * 123199a2dd95SBruce Richardson * @param dev_id 123299a2dd95SBruce Richardson * The identifier of the device. 123399a2dd95SBruce Richardson * @param f 123499a2dd95SBruce Richardson * A pointer to a file for output. 123599a2dd95SBruce Richardson * 123699a2dd95SBruce Richardson * @return 123799a2dd95SBruce Richardson * 0 on success, negative errno on failure. 123899a2dd95SBruce Richardson */ 123999a2dd95SBruce Richardson __rte_experimental 124099a2dd95SBruce Richardson int 124199a2dd95SBruce Richardson rte_regexdev_dump(uint8_t dev_id, FILE *f); 124299a2dd95SBruce Richardson 124399a2dd95SBruce Richardson /* Fast path APIs */ 124499a2dd95SBruce Richardson 124599a2dd95SBruce Richardson /** 124699a2dd95SBruce Richardson * The generic *rte_regexdev_match* structure to hold the RegEx match 124799a2dd95SBruce Richardson * attributes. 124899a2dd95SBruce Richardson * @see struct rte_regex_ops::matches 124999a2dd95SBruce Richardson */ 125099a2dd95SBruce Richardson struct rte_regexdev_match { 125199a2dd95SBruce Richardson union { 125299a2dd95SBruce Richardson uint64_t u64; 125399a2dd95SBruce Richardson struct { 125499a2dd95SBruce Richardson uint32_t rule_id:20; 125599a2dd95SBruce Richardson /**< Rule identifier to which the pattern matched. 125699a2dd95SBruce Richardson * @see struct rte_regexdev_rule::rule_id 125799a2dd95SBruce Richardson */ 125899a2dd95SBruce Richardson uint32_t group_id:12; 125999a2dd95SBruce Richardson /**< Group identifier of the rule which the pattern 126099a2dd95SBruce Richardson * matched. @see struct rte_regexdev_rule::group_id 126199a2dd95SBruce Richardson */ 126299a2dd95SBruce Richardson uint16_t start_offset; 126399a2dd95SBruce Richardson /**< Starting Byte Position for matched rule. */ 126499a2dd95SBruce Richardson union { 126599a2dd95SBruce Richardson uint16_t len; 126699a2dd95SBruce Richardson /**< Length of match in bytes */ 126799a2dd95SBruce Richardson uint16_t end_offset; 126899a2dd95SBruce Richardson /**< The end offset of the match. In case 126999a2dd95SBruce Richardson * MATCH_AS_END configuration is enabled. 127099a2dd95SBruce Richardson * @see RTE_REGEXDEV_CFG_MATCH_AS_END 127199a2dd95SBruce Richardson */ 127299a2dd95SBruce Richardson }; 127399a2dd95SBruce Richardson }; 127499a2dd95SBruce Richardson }; 127599a2dd95SBruce Richardson }; 127699a2dd95SBruce Richardson 127799a2dd95SBruce Richardson /* Enumerates RegEx request flags. */ 127899a2dd95SBruce Richardson #define RTE_REGEX_OPS_REQ_GROUP_ID0_VALID_F (1 << 0) 127999a2dd95SBruce Richardson /**< Set when struct rte_regexdev_rule::group_id0 is valid. */ 128099a2dd95SBruce Richardson 128199a2dd95SBruce Richardson #define RTE_REGEX_OPS_REQ_GROUP_ID1_VALID_F (1 << 1) 128299a2dd95SBruce Richardson /**< Set when struct rte_regexdev_rule::group_id1 is valid. */ 128399a2dd95SBruce Richardson 128499a2dd95SBruce Richardson #define RTE_REGEX_OPS_REQ_GROUP_ID2_VALID_F (1 << 2) 128599a2dd95SBruce Richardson /**< Set when struct rte_regexdev_rule::group_id2 is valid. */ 128699a2dd95SBruce Richardson 128799a2dd95SBruce Richardson #define RTE_REGEX_OPS_REQ_GROUP_ID3_VALID_F (1 << 3) 128899a2dd95SBruce Richardson /**< Set when struct rte_regexdev_rule::group_id3 is valid. */ 128999a2dd95SBruce Richardson 129099a2dd95SBruce Richardson #define RTE_REGEX_OPS_REQ_STOP_ON_MATCH_F (1 << 4) 129199a2dd95SBruce Richardson /**< The RegEx engine will stop scanning and return the first match. */ 129299a2dd95SBruce Richardson 129399a2dd95SBruce Richardson #define RTE_REGEX_OPS_REQ_MATCH_HIGH_PRIORITY_F (1 << 5) 129499a2dd95SBruce Richardson /**< In High Priority mode a maximum of one match will be returned per scan to 129599a2dd95SBruce Richardson * reduce the post-processing required by the application. The match with the 129699a2dd95SBruce Richardson * lowest Rule id, lowest start pointer and lowest match length will be 129799a2dd95SBruce Richardson * returned. 129899a2dd95SBruce Richardson * 129999a2dd95SBruce Richardson * @see struct rte_regex_ops::nb_actual_matches 130099a2dd95SBruce Richardson * @see struct rte_regex_ops::nb_matches 130199a2dd95SBruce Richardson */ 130299a2dd95SBruce Richardson 130399a2dd95SBruce Richardson 130499a2dd95SBruce Richardson /* Enumerates RegEx response flags. */ 130599a2dd95SBruce Richardson #define RTE_REGEX_OPS_RSP_PMI_SOJ_F (1 << 0) 130699a2dd95SBruce Richardson /**< Indicates that the RegEx device has encountered a partial match at the 130799a2dd95SBruce Richardson * start of scan in the given buffer. 130899a2dd95SBruce Richardson * 130999a2dd95SBruce Richardson * @see RTE_REGEXDEV_CFG_CROSS_BUFFER_SCAN_F 131099a2dd95SBruce Richardson */ 131199a2dd95SBruce Richardson 131299a2dd95SBruce Richardson #define RTE_REGEX_OPS_RSP_PMI_EOJ_F (1 << 1) 131399a2dd95SBruce Richardson /**< Indicates that the RegEx device has encountered a partial match at the 131499a2dd95SBruce Richardson * end of scan in the given buffer. 131599a2dd95SBruce Richardson * 131699a2dd95SBruce Richardson * @see RTE_REGEXDEV_CFG_CROSS_BUFFER_SCAN_F 131799a2dd95SBruce Richardson */ 131899a2dd95SBruce Richardson 131999a2dd95SBruce Richardson #define RTE_REGEX_OPS_RSP_MAX_SCAN_TIMEOUT_F (1 << 2) 132099a2dd95SBruce Richardson /**< Indicates that the RegEx device has exceeded the max timeout while 132199a2dd95SBruce Richardson * scanning the given buffer. 132299a2dd95SBruce Richardson * 132399a2dd95SBruce Richardson * @see RTE_REGEXDEV_ATTR_MAX_SCAN_TIMEOUT 132499a2dd95SBruce Richardson */ 132599a2dd95SBruce Richardson 132699a2dd95SBruce Richardson #define RTE_REGEX_OPS_RSP_MAX_MATCH_F (1 << 3) 132799a2dd95SBruce Richardson /**< Indicates that the RegEx device has exceeded the max matches while 132899a2dd95SBruce Richardson * scanning the given buffer. 132999a2dd95SBruce Richardson * 133099a2dd95SBruce Richardson * @see RTE_REGEXDEV_ATTR_MAX_MATCHES 133199a2dd95SBruce Richardson */ 133299a2dd95SBruce Richardson 133399a2dd95SBruce Richardson #define RTE_REGEX_OPS_RSP_MAX_PREFIX_F (1 << 4) 133499a2dd95SBruce Richardson /**< Indicates that the RegEx device has reached the max allowed prefix length 133599a2dd95SBruce Richardson * while scanning the given buffer. 133699a2dd95SBruce Richardson * 133799a2dd95SBruce Richardson * @see RTE_REGEXDEV_ATTR_MAX_PREFIX 133899a2dd95SBruce Richardson */ 133999a2dd95SBruce Richardson 134099a2dd95SBruce Richardson #define RTE_REGEX_OPS_RSP_RESOURCE_LIMIT_REACHED_F (1 << 4) 134199a2dd95SBruce Richardson /**< Indicates that the RegEx device has reached the max allowed resource 134299a2dd95SBruce Richardson * allowed while scanning the given buffer. 134399a2dd95SBruce Richardson */ 134499a2dd95SBruce Richardson 134599a2dd95SBruce Richardson /** 134699a2dd95SBruce Richardson * The generic *rte_regex_ops* structure to hold the RegEx attributes 134799a2dd95SBruce Richardson * for enqueue and dequeue operation. 134899a2dd95SBruce Richardson */ 134999a2dd95SBruce Richardson struct rte_regex_ops { 135099a2dd95SBruce Richardson /* W0 */ 135199a2dd95SBruce Richardson uint16_t req_flags; 135299a2dd95SBruce Richardson /**< Request flags for the RegEx ops. 135399a2dd95SBruce Richardson * @see RTE_REGEX_OPS_REQ_* 135499a2dd95SBruce Richardson */ 135599a2dd95SBruce Richardson uint16_t rsp_flags; 135699a2dd95SBruce Richardson /**< Response flags for the RegEx ops. 135799a2dd95SBruce Richardson * @see RTE_REGEX_OPS_RSP_* 135899a2dd95SBruce Richardson */ 135999a2dd95SBruce Richardson uint16_t nb_actual_matches; 136099a2dd95SBruce Richardson /**< The total number of actual matches detected by the Regex device.*/ 136199a2dd95SBruce Richardson uint16_t nb_matches; 136299a2dd95SBruce Richardson /**< The total number of matches returned by the RegEx device for this 136399a2dd95SBruce Richardson * scan. The size of *rte_regex_ops::matches* zero length array will be 136499a2dd95SBruce Richardson * this value. 136599a2dd95SBruce Richardson * 136699a2dd95SBruce Richardson * @see struct rte_regex_ops::matches, struct rte_regexdev_match 136799a2dd95SBruce Richardson */ 136899a2dd95SBruce Richardson 136999a2dd95SBruce Richardson /* W1 */ 137099a2dd95SBruce Richardson struct rte_mbuf *mbuf; /**< source mbuf, to search in. */ 137199a2dd95SBruce Richardson 137299a2dd95SBruce Richardson /* W2 */ 137399a2dd95SBruce Richardson uint16_t group_id0; 137499a2dd95SBruce Richardson /**< First group_id to match the rule against. At minimum one group 137599a2dd95SBruce Richardson * should be valid. Behaviour is undefined non of the groups are valid. 137699a2dd95SBruce Richardson * 137799a2dd95SBruce Richardson * @see RTE_REGEX_OPS_REQ_GROUP_ID0_VALID_F 137899a2dd95SBruce Richardson */ 137999a2dd95SBruce Richardson uint16_t group_id1; 138099a2dd95SBruce Richardson /**< Second group_id to match the rule against. 138199a2dd95SBruce Richardson * 138299a2dd95SBruce Richardson * @see RTE_REGEX_OPS_REQ_GROUP_ID1_VALID_F 138399a2dd95SBruce Richardson */ 138499a2dd95SBruce Richardson uint16_t group_id2; 138599a2dd95SBruce Richardson /**< Third group_id to match the rule against. 138699a2dd95SBruce Richardson * 138799a2dd95SBruce Richardson * @see RTE_REGEX_OPS_REQ_GROUP_ID2_VALID_F 138899a2dd95SBruce Richardson */ 138999a2dd95SBruce Richardson uint16_t group_id3; 139099a2dd95SBruce Richardson /**< Forth group_id to match the rule against. 139199a2dd95SBruce Richardson * 139299a2dd95SBruce Richardson * @see RTE_REGEX_OPS_REQ_GROUP_ID3_VALID_F 139399a2dd95SBruce Richardson */ 139499a2dd95SBruce Richardson 139599a2dd95SBruce Richardson /* W3 */ 139699a2dd95SBruce Richardson union { 139799a2dd95SBruce Richardson uint64_t user_id; 139899a2dd95SBruce Richardson /**< Application specific opaque value. An application may use 139999a2dd95SBruce Richardson * this field to hold application specific value to share 140099a2dd95SBruce Richardson * between dequeue and enqueue operation. 140199a2dd95SBruce Richardson * Implementation should not modify this field. 140299a2dd95SBruce Richardson */ 140399a2dd95SBruce Richardson void *user_ptr; 140499a2dd95SBruce Richardson /**< Pointer representation of *user_id* */ 140599a2dd95SBruce Richardson }; 140699a2dd95SBruce Richardson 140799a2dd95SBruce Richardson /* W4 */ 140899a2dd95SBruce Richardson union { 140999a2dd95SBruce Richardson uint64_t cross_buf_id; 141099a2dd95SBruce Richardson /**< ID used by the RegEx device in order to support cross 141199a2dd95SBruce Richardson * packet detection. 141299a2dd95SBruce Richardson * This ID is returned from the RegEx device on the dequeue 141399a2dd95SBruce Richardson * function. The application must send it back when calling 141499a2dd95SBruce Richardson * enqueue with the following packet. 141599a2dd95SBruce Richardson */ 141699a2dd95SBruce Richardson void *cross_buf_ptr; 141799a2dd95SBruce Richardson /**< Pointer representation of *corss_buf_id* */ 141899a2dd95SBruce Richardson }; 141999a2dd95SBruce Richardson 142099a2dd95SBruce Richardson /* W5 */ 142199a2dd95SBruce Richardson struct rte_regexdev_match matches[]; 142299a2dd95SBruce Richardson /**< Zero length array to hold the match tuples. 142399a2dd95SBruce Richardson * The struct rte_regex_ops::nb_matches value holds the number of 142499a2dd95SBruce Richardson * elements in this array. 142599a2dd95SBruce Richardson * 142699a2dd95SBruce Richardson * @see struct rte_regex_ops::nb_matches 142799a2dd95SBruce Richardson */ 142899a2dd95SBruce Richardson }; 142999a2dd95SBruce Richardson 143099a2dd95SBruce Richardson #include "rte_regexdev_core.h" 143199a2dd95SBruce Richardson 143299a2dd95SBruce Richardson /** 143399a2dd95SBruce Richardson * @warning 143499a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 143599a2dd95SBruce Richardson * 143699a2dd95SBruce Richardson * Enqueue a burst of scan request on a RegEx device. 143799a2dd95SBruce Richardson * 143899a2dd95SBruce Richardson * The rte_regexdev_enqueue_burst() function is invoked to place 143999a2dd95SBruce Richardson * regex operations on the queue *qp_id* of the device designated by 144099a2dd95SBruce Richardson * its *dev_id*. 144199a2dd95SBruce Richardson * 144299a2dd95SBruce Richardson * The *nb_ops* parameter is the number of operations to process which are 144399a2dd95SBruce Richardson * supplied in the *ops* array of *rte_regexdev_op* structures. 144499a2dd95SBruce Richardson * 144599a2dd95SBruce Richardson * The rte_regexdev_enqueue_burst() function returns the number of 144699a2dd95SBruce Richardson * operations it actually enqueued for processing. A return value equal to 144799a2dd95SBruce Richardson * *nb_ops* means that all packets have been enqueued. 144899a2dd95SBruce Richardson * 144999a2dd95SBruce Richardson * @param dev_id 145099a2dd95SBruce Richardson * The identifier of the device. 145199a2dd95SBruce Richardson * @param qp_id 145299a2dd95SBruce Richardson * The index of the queue pair which packets are to be enqueued for 145399a2dd95SBruce Richardson * processing. The value must be in the range [0, nb_queue_pairs - 1] 145499a2dd95SBruce Richardson * previously supplied to rte_regexdev_configure(). 145599a2dd95SBruce Richardson * @param ops 145699a2dd95SBruce Richardson * The address of an array of *nb_ops* pointers to *rte_regexdev_op* 145799a2dd95SBruce Richardson * structures which contain the regex operations to be processed. 145899a2dd95SBruce Richardson * @param nb_ops 145999a2dd95SBruce Richardson * The number of operations to process. 146099a2dd95SBruce Richardson * 146199a2dd95SBruce Richardson * @return 146299a2dd95SBruce Richardson * The number of operations actually enqueued on the regex device. The return 146399a2dd95SBruce Richardson * value can be less than the value of the *nb_ops* parameter when the 146499a2dd95SBruce Richardson * regex devices queue is full or if invalid parameters are specified in 146599a2dd95SBruce Richardson * a *rte_regexdev_op*. If the return value is less than *nb_ops*, the 146699a2dd95SBruce Richardson * remaining ops at the end of *ops* are not consumed and the caller has 146799a2dd95SBruce Richardson * to take care of them. 146899a2dd95SBruce Richardson */ 146999a2dd95SBruce Richardson __rte_experimental 147099a2dd95SBruce Richardson static inline uint16_t 147199a2dd95SBruce Richardson rte_regexdev_enqueue_burst(uint8_t dev_id, uint16_t qp_id, 147299a2dd95SBruce Richardson struct rte_regex_ops **ops, uint16_t nb_ops) 147399a2dd95SBruce Richardson { 147499a2dd95SBruce Richardson struct rte_regexdev *dev = &rte_regex_devices[dev_id]; 147599a2dd95SBruce Richardson #ifdef RTE_LIBRTE_REGEXDEV_DEBUG 147699a2dd95SBruce Richardson RTE_REGEXDEV_VALID_DEV_ID_OR_ERR_RET(dev_id, -EINVAL); 14778f1d23ecSDavid Marchand if (*dev->enqueue == NULL) 14788f1d23ecSDavid Marchand return -ENOTSUP; 147999a2dd95SBruce Richardson if (qp_id >= dev->data->dev_conf.nb_queue_pairs) { 1480*0e21c7c0SDavid Marchand RTE_REGEXDEV_LOG_LINE(ERR, "Invalid queue %d", qp_id); 148199a2dd95SBruce Richardson return -EINVAL; 148299a2dd95SBruce Richardson } 148399a2dd95SBruce Richardson #endif 148499a2dd95SBruce Richardson return (*dev->enqueue)(dev, qp_id, ops, nb_ops); 148599a2dd95SBruce Richardson } 148699a2dd95SBruce Richardson 148799a2dd95SBruce Richardson /** 148899a2dd95SBruce Richardson * @warning 148999a2dd95SBruce Richardson * @b EXPERIMENTAL: this API may change without prior notice. 149099a2dd95SBruce Richardson * 149199a2dd95SBruce Richardson * Dequeue a burst of scan response from a queue on the RegEx device. 149299a2dd95SBruce Richardson * The dequeued operation are stored in *rte_regexdev_op* structures 149399a2dd95SBruce Richardson * whose pointers are supplied in the *ops* array. 149499a2dd95SBruce Richardson * 149599a2dd95SBruce Richardson * The rte_regexdev_dequeue_burst() function returns the number of ops 149699a2dd95SBruce Richardson * actually dequeued, which is the number of *rte_regexdev_op* data structures 149799a2dd95SBruce Richardson * effectively supplied into the *ops* array. 149899a2dd95SBruce Richardson * 149999a2dd95SBruce Richardson * A return value equal to *nb_ops* indicates that the queue contained 150099a2dd95SBruce Richardson * at least *nb_ops* operations, and this is likely to signify that other 150199a2dd95SBruce Richardson * processed operations remain in the devices output queue. Applications 150299a2dd95SBruce Richardson * implementing a "retrieve as many processed operations as possible" policy 150399a2dd95SBruce Richardson * can check this specific case and keep invoking the 150499a2dd95SBruce Richardson * rte_regexdev_dequeue_burst() function until a value less than 150599a2dd95SBruce Richardson * *nb_ops* is returned. 150699a2dd95SBruce Richardson * 150799a2dd95SBruce Richardson * The rte_regexdev_dequeue_burst() function does not provide any error 150899a2dd95SBruce Richardson * notification to avoid the corresponding overhead. 150999a2dd95SBruce Richardson * 151099a2dd95SBruce Richardson * @param dev_id 151199a2dd95SBruce Richardson * The RegEx device identifier 151299a2dd95SBruce Richardson * @param qp_id 151399a2dd95SBruce Richardson * The index of the queue pair from which to retrieve processed packets. 151499a2dd95SBruce Richardson * The value must be in the range [0, nb_queue_pairs - 1] previously 151599a2dd95SBruce Richardson * supplied to rte_regexdev_configure(). 151699a2dd95SBruce Richardson * @param ops 151799a2dd95SBruce Richardson * The address of an array of pointers to *rte_regexdev_op* structures 151899a2dd95SBruce Richardson * that must be large enough to store *nb_ops* pointers in it. 151999a2dd95SBruce Richardson * @param nb_ops 152099a2dd95SBruce Richardson * The maximum number of operations to dequeue. 152199a2dd95SBruce Richardson * 152299a2dd95SBruce Richardson * @return 152399a2dd95SBruce Richardson * The number of operations actually dequeued, which is the number 152499a2dd95SBruce Richardson * of pointers to *rte_regexdev_op* structures effectively supplied to the 152599a2dd95SBruce Richardson * *ops* array. If the return value is less than *nb_ops*, the remaining 152699a2dd95SBruce Richardson * ops at the end of *ops* are not consumed and the caller has to take care 152799a2dd95SBruce Richardson * of them. 152899a2dd95SBruce Richardson */ 152999a2dd95SBruce Richardson __rte_experimental 153099a2dd95SBruce Richardson static inline uint16_t 153199a2dd95SBruce Richardson rte_regexdev_dequeue_burst(uint8_t dev_id, uint16_t qp_id, 153299a2dd95SBruce Richardson struct rte_regex_ops **ops, uint16_t nb_ops) 153399a2dd95SBruce Richardson { 153499a2dd95SBruce Richardson struct rte_regexdev *dev = &rte_regex_devices[dev_id]; 153599a2dd95SBruce Richardson #ifdef RTE_LIBRTE_REGEXDEV_DEBUG 153699a2dd95SBruce Richardson RTE_REGEXDEV_VALID_DEV_ID_OR_ERR_RET(dev_id, -EINVAL); 15378f1d23ecSDavid Marchand if (*dev->dequeue == NULL) 15388f1d23ecSDavid Marchand return -ENOTSUP; 153999a2dd95SBruce Richardson if (qp_id >= dev->data->dev_conf.nb_queue_pairs) { 1540*0e21c7c0SDavid Marchand RTE_REGEXDEV_LOG_LINE(ERR, "Invalid queue %d", qp_id); 154199a2dd95SBruce Richardson return -EINVAL; 154299a2dd95SBruce Richardson } 154399a2dd95SBruce Richardson #endif 154499a2dd95SBruce Richardson return (*dev->dequeue)(dev, qp_id, ops, nb_ops); 154599a2dd95SBruce Richardson } 154699a2dd95SBruce Richardson 154799a2dd95SBruce Richardson #ifdef __cplusplus 154899a2dd95SBruce Richardson } 154999a2dd95SBruce Richardson #endif 155099a2dd95SBruce Richardson 155199a2dd95SBruce Richardson #endif /* _RTE_REGEXDEV_H_ */ 1552