1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2020 Mellanox Technologies, Ltd
5 #ifndef _RTE_REGEX_CORE_H_
6 #define _RTE_REGEX_CORE_H_
11 * RTE RegEx Device internal header.
13 * This header contains internal data types, that are used by the RegEx devices
14 * in order to expose their ops to the class.
16 * Applications should not use these API directly.
22 typedef int (*regexdev_info_get_t)(struct rte_regexdev *dev,
23 struct rte_regexdev_info *info);
24 /**< @internal Get the RegEx device info. */
26 typedef int (*regexdev_configure_t)(struct rte_regexdev *dev,
27 const struct rte_regexdev_config *cfg);
28 /**< @internal Configure the RegEx device. */
30 typedef int (*regexdev_qp_setup_t)(struct rte_regexdev *dev, uint16_t id,
31 const struct rte_regexdev_qp_conf *qp_conf);
32 /**< @internal Setup a queue pair.*/
34 typedef int (*regexdev_start_t)(struct rte_regexdev *dev);
35 /**< @internal Start the RegEx device. */
37 typedef int (*regexdev_stop_t)(struct rte_regexdev *dev);
38 /**< @internal Stop the RegEx device. */
40 typedef int (*regexdev_close_t)(struct rte_regexdev *dev);
41 /**< @internal Close the RegEx device. */
43 typedef int (*regexdev_attr_get_t)(struct rte_regexdev *dev,
44 enum rte_regexdev_attr_id id,
46 /**< @internal Get selected attribute from RegEx device. */
48 typedef int (*regexdev_attr_set_t)(struct rte_regexdev *dev,
49 enum rte_regexdev_attr_id id,
51 /**< @internal Set selected attribute to RegEx device. */
53 typedef int (*regexdev_rule_db_update_t)(struct rte_regexdev *dev,
54 const struct rte_regexdev_rule *rules,
56 /**< @internal Update the rule database for the RegEx device. */
58 typedef int (*regexdev_rule_db_compile_activate_t)(struct rte_regexdev *dev);
59 /**< @internal Compile the rule database and activate it. */
61 typedef int (*regexdev_rule_db_import_t)(struct rte_regexdev *dev,
63 uint32_t rule_db_len);
64 /**< @internal Upload a pre created rule database to the RegEx device. */
66 typedef int (*regexdev_rule_db_export_t)(struct rte_regexdev *dev,
68 /**< @internal Export the current rule database from the RegEx device. */
70 typedef int (*regexdev_xstats_names_get_t)(struct rte_regexdev *dev,
71 struct rte_regexdev_xstats_map
73 /**< @internal Get xstats name map for the RegEx device. */
75 typedef int (*regexdev_xstats_get_t)(struct rte_regexdev *dev,
76 const uint16_t *ids, uint64_t *values,
78 /**< @internal Get xstats values for the RegEx device. */
80 typedef int (*regexdev_xstats_by_name_get_t)(struct rte_regexdev *dev,
81 const char *name, uint16_t *id,
83 /**< @internal Get xstat value for the RegEx device based on the xstats name. */
85 typedef int (*regexdev_xstats_reset_t)(struct rte_regexdev *dev,
88 /**< @internal Reset xstats values for the RegEx device. */
90 typedef int (*regexdev_selftest_t)(struct rte_regexdev *dev);
91 /**< @internal Trigger RegEx self test. */
93 typedef int (*regexdev_dump_t)(struct rte_regexdev *dev, FILE *f);
94 /**< @internal Dump internal information about the RegEx device. */
96 typedef uint16_t (*regexdev_enqueue_t)(struct rte_regexdev *dev, uint16_t qp_id,
97 struct rte_regex_ops **ops,
99 /**< @internal Enqueue a burst of scan requests to a queue on RegEx device. */
101 typedef uint16_t (*regexdev_dequeue_t)(struct rte_regexdev *dev, uint16_t qp_id,
102 struct rte_regex_ops **ops,
104 /**< @internal Dequeue a burst of scan response from a queue on RegEx device. */
107 * RegEx device operations
109 struct rte_regexdev_ops {
110 regexdev_info_get_t dev_info_get;
111 regexdev_configure_t dev_configure;
112 regexdev_qp_setup_t dev_qp_setup;
113 regexdev_start_t dev_start;
114 regexdev_stop_t dev_stop;
115 regexdev_close_t dev_close;
116 regexdev_attr_get_t dev_attr_get;
117 regexdev_attr_set_t dev_attr_set;
118 regexdev_rule_db_update_t dev_rule_db_update;
119 regexdev_rule_db_compile_activate_t dev_rule_db_compile_activate;
120 regexdev_rule_db_import_t dev_db_import;
121 regexdev_rule_db_export_t dev_db_export;
122 regexdev_xstats_names_get_t dev_xstats_names_get;
123 regexdev_xstats_get_t dev_xstats_get;
124 regexdev_xstats_by_name_get_t dev_xstats_by_name_get;
125 regexdev_xstats_reset_t dev_xstats_reset;
126 regexdev_selftest_t dev_selftest;
127 regexdev_dump_t dev_dump;
131 * Possible states of a RegEx device.
133 enum rte_regexdev_state {
134 RTE_REGEXDEV_UNUSED = 0, /**< Device is unused. */
135 RTE_REGEXDEV_REGISTERED,
136 /**< Device is registered, but not ready to be used. */
138 /**< Device is ready for use. This is set by the PMD. */
143 * The data part, with no function pointers, associated with each RegEx device.
145 * This structure is safe to place in shared memory to be common among different
146 * processes in a multi-process configuration.
148 struct rte_regexdev_data {
149 void *dev_private; /**< PMD-specific private data. */
150 char dev_name[RTE_REGEXDEV_NAME_MAX_LEN]; /**< Unique identifier name */
151 uint16_t dev_id; /**< Device [external] identifier. */
152 struct rte_regexdev_config dev_conf; /**< RegEx configuration. */
153 uint8_t dev_started : 1; /**< Device started to work. */
154 } __rte_cache_aligned;
158 * The generic data structure associated with each RegEx device.
160 * Pointers to burst-oriented packet receive and transmit functions are
161 * located at the beginning of the structure, along with the pointer to
162 * where all the data elements for the particular device are stored in shared
163 * memory. This split allows the function pointer and driver data to be per-
164 * process, while the actual configuration data for the device is shared.
166 struct rte_regexdev {
167 regexdev_enqueue_t enqueue;
168 regexdev_dequeue_t dequeue;
169 const struct rte_regexdev_ops *dev_ops;
170 /**< Functions exported by PMD */
171 struct rte_device *device; /**< Backing device */
172 enum rte_regexdev_state state; /**< The device state. */
173 struct rte_regexdev_data *data; /**< Pointer to device data. */
174 } __rte_cache_aligned;
178 * The pool of *rte_regexdev* structures. The size of the pool
179 * is configured at compile-time in the <rte_regexdev.c> file.
181 extern struct rte_regexdev rte_regex_devices[];
183 #endif /* _RTE_REGEX_CORE_H_ */