xref: /dpdk/lib/regexdev/rte_regexdev_core.h (revision 33e71acf3d446ced520f07e4d75769323e0ec22c)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2020 Mellanox Technologies, Ltd
3  */
4 
5 #ifndef _RTE_REGEX_CORE_H_
6 #define _RTE_REGEX_CORE_H_
7 
8 /**
9  * @file
10  *
11  * RTE RegEx Device internal header.
12  *
13  * This header contains internal data types, that are used by the RegEx devices
14  * in order to expose their ops to the class.
15  *
16  * Applications should not use these API directly.
17  *
18  */
19 
20 struct rte_regexdev;
21 
22 typedef int (*regexdev_info_get_t)(struct rte_regexdev *dev,
23 				   struct rte_regexdev_info *info);
24 /**< @internal Get the RegEx device info. */
25 
26 typedef int (*regexdev_configure_t)(struct rte_regexdev *dev,
27 				    const struct rte_regexdev_config *cfg);
28 /**< @internal Configure the RegEx device. */
29 
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.*/
33 
34 typedef int (*regexdev_start_t)(struct rte_regexdev *dev);
35 /**< @internal Start the RegEx device. */
36 
37 typedef int (*regexdev_stop_t)(struct rte_regexdev *dev);
38 /**< @internal Stop the RegEx device. */
39 
40 typedef int (*regexdev_close_t)(struct rte_regexdev *dev);
41 /**< @internal Close the RegEx device. */
42 
43 typedef int (*regexdev_attr_get_t)(struct rte_regexdev *dev,
44 				   enum rte_regexdev_attr_id id,
45 				   void *value);
46 /**< @internal Get selected attribute from RegEx device. */
47 
48 typedef int (*regexdev_attr_set_t)(struct rte_regexdev *dev,
49 				   enum rte_regexdev_attr_id id,
50 				   const void *value);
51 /**< @internal Set selected attribute to RegEx device. */
52 
53 typedef int (*regexdev_rule_db_update_t)(struct rte_regexdev *dev,
54 					 const struct rte_regexdev_rule *rules,
55 					 uint16_t nb_rules);
56 /**< @internal Update the rule database for the RegEx device. */
57 
58 typedef int (*regexdev_rule_db_compile_activate_t)(struct rte_regexdev *dev);
59 /**< @internal Compile the rule database and activate it. */
60 
61 typedef int (*regexdev_rule_db_import_t)(struct rte_regexdev *dev,
62 					 const  char *rule_db,
63 					 uint32_t rule_db_len);
64 /**< @internal Upload a pre created rule database to the RegEx device. */
65 
66 typedef int (*regexdev_rule_db_export_t)(struct rte_regexdev *dev,
67 					 char *rule_db);
68 /**< @internal Export the current rule database from the RegEx device. */
69 
70 typedef int (*regexdev_xstats_names_get_t)(struct rte_regexdev *dev,
71 					   struct rte_regexdev_xstats_map
72 					   *xstats_map);
73 /**< @internal Get xstats name map for the RegEx device. */
74 
75 typedef int (*regexdev_xstats_get_t)(struct rte_regexdev *dev,
76 				     const uint16_t *ids, uint64_t *values,
77 				     uint16_t nb_values);
78 /**< @internal Get xstats values for the RegEx device. */
79 
80 typedef int (*regexdev_xstats_by_name_get_t)(struct rte_regexdev *dev,
81 					     const char *name, uint16_t *id,
82 					     uint64_t *value);
83 /**< @internal Get xstat value for the RegEx device based on the xstats name. */
84 
85 typedef int (*regexdev_xstats_reset_t)(struct rte_regexdev *dev,
86 				       const uint16_t *ids,
87 				       uint16_t nb_ids);
88 /**< @internal Reset xstats values for the RegEx device. */
89 
90 typedef int (*regexdev_selftest_t)(struct rte_regexdev *dev);
91 /**< @internal Trigger RegEx self test. */
92 
93 typedef int (*regexdev_dump_t)(struct rte_regexdev *dev, FILE *f);
94 /**< @internal Dump internal information about the RegEx device. */
95 
96 typedef uint16_t (*regexdev_enqueue_t)(struct rte_regexdev *dev, uint16_t qp_id,
97 				       struct rte_regex_ops **ops,
98 				       uint16_t nb_ops);
99 /**< @internal Enqueue a burst of scan requests to a queue on RegEx device. */
100 
101 typedef uint16_t (*regexdev_dequeue_t)(struct rte_regexdev *dev, uint16_t qp_id,
102 				       struct rte_regex_ops **ops,
103 				       uint16_t nb_ops);
104 /**< @internal Dequeue a burst of scan response from a queue on RegEx device. */
105 
106 /**
107  * RegEx device operations
108  */
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;
128 };
129 
130 /**
131  * Possible states of a RegEx device.
132  */
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. */
137 	RTE_REGEXDEV_READY,
138 	/**< Device is ready for use. This is set by the PMD. */
139 };
140 
141 /**
142  * @internal
143  * The data part, with no function pointers, associated with each RegEx device.
144  *
145  * This structure is safe to place in shared memory to be common among different
146  * processes in a multi-process configuration.
147  */
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;
155 
156 /**
157  * @internal
158  * The generic data structure associated with each RegEx device.
159  *
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.
165  */
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;
175 
176 /**
177  * @internal
178  * The pool of *rte_regexdev* structures. The size of the pool
179  * is configured at compile-time in the <rte_regexdev.c> file.
180  */
181 extern struct rte_regexdev rte_regex_devices[];
182 
183 #endif /* _RTE_REGEX_CORE_H_ */
184