1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright 2016 6WIND S.A. 3 * Copyright 2016 Mellanox Technologies, Ltd 4 */ 5 6 #ifndef RTE_FLOW_DRIVER_H_ 7 #define RTE_FLOW_DRIVER_H_ 8 9 /** 10 * @file 11 * RTE generic flow API (driver side) 12 * 13 * This file provides implementation helpers for internal use by PMDs, they 14 * are not intended to be exposed to applications and are not subject to ABI 15 * versioning. 16 */ 17 18 #include <stdint.h> 19 20 #include "rte_ethdev.h" 21 #include "ethdev_driver.h" 22 #include "rte_flow.h" 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 /** 29 * Generic flow operations structure implemented and returned by PMDs. 30 * 31 * These callback functions are not supposed to be used by applications 32 * directly, which must rely on the API defined in rte_flow.h. 33 * 34 * Public-facing wrapper functions perform a few consistency checks so that 35 * unimplemented (i.e. NULL) callbacks simply return -ENOTSUP. These 36 * callbacks otherwise only differ by their first argument (with port ID 37 * already resolved to a pointer to struct rte_eth_dev). 38 */ 39 struct rte_flow_ops { 40 /** See rte_flow_validate(). */ 41 int (*validate) 42 (struct rte_eth_dev *, 43 const struct rte_flow_attr *, 44 const struct rte_flow_item [], 45 const struct rte_flow_action [], 46 struct rte_flow_error *); 47 /** See rte_flow_create(). */ 48 struct rte_flow *(*create) 49 (struct rte_eth_dev *, 50 const struct rte_flow_attr *, 51 const struct rte_flow_item [], 52 const struct rte_flow_action [], 53 struct rte_flow_error *); 54 /** See rte_flow_destroy(). */ 55 int (*destroy) 56 (struct rte_eth_dev *, 57 struct rte_flow *, 58 struct rte_flow_error *); 59 /** See rte_flow_flush(). */ 60 int (*flush) 61 (struct rte_eth_dev *, 62 struct rte_flow_error *); 63 /** See rte_flow_query(). */ 64 int (*query) 65 (struct rte_eth_dev *, 66 struct rte_flow *, 67 const struct rte_flow_action *, 68 void *, 69 struct rte_flow_error *); 70 /** See rte_flow_isolate(). */ 71 int (*isolate) 72 (struct rte_eth_dev *, 73 int, 74 struct rte_flow_error *); 75 /** See rte_flow_dev_dump(). */ 76 int (*dev_dump) 77 (struct rte_eth_dev *dev, 78 struct rte_flow *flow, 79 FILE *file, 80 struct rte_flow_error *error); 81 /** See rte_flow_get_aged_flows() */ 82 int (*get_aged_flows) 83 (struct rte_eth_dev *dev, 84 void **context, 85 uint32_t nb_contexts, 86 struct rte_flow_error *err); 87 /** See rte_flow_get_q_aged_flows() */ 88 int (*get_q_aged_flows) 89 (struct rte_eth_dev *dev, 90 uint32_t queue_id, 91 void **contexts, 92 uint32_t nb_contexts, 93 struct rte_flow_error *error); 94 /** See rte_flow_action_handle_create() */ 95 struct rte_flow_action_handle *(*action_handle_create) 96 (struct rte_eth_dev *dev, 97 const struct rte_flow_indir_action_conf *conf, 98 const struct rte_flow_action *action, 99 struct rte_flow_error *error); 100 /** See rte_flow_action_handle_destroy() */ 101 int (*action_handle_destroy) 102 (struct rte_eth_dev *dev, 103 struct rte_flow_action_handle *handle, 104 struct rte_flow_error *error); 105 /** See rte_flow_action_handle_update() */ 106 int (*action_handle_update) 107 (struct rte_eth_dev *dev, 108 struct rte_flow_action_handle *handle, 109 const void *update, 110 struct rte_flow_error *error); 111 /** See rte_flow_action_handle_query() */ 112 int (*action_handle_query) 113 (struct rte_eth_dev *dev, 114 const struct rte_flow_action_handle *handle, 115 void *data, 116 struct rte_flow_error *error); 117 /** See rte_flow_action_handle_query_update() */ 118 int (*action_handle_query_update) 119 (struct rte_eth_dev *dev, 120 struct rte_flow_action_handle *handle, 121 const void *update, void *query, 122 enum rte_flow_query_update_mode qu_mode, 123 struct rte_flow_error *error); 124 /** See rte_flow_tunnel_decap_set() */ 125 int (*tunnel_decap_set) 126 (struct rte_eth_dev *dev, 127 struct rte_flow_tunnel *tunnel, 128 struct rte_flow_action **pmd_actions, 129 uint32_t *num_of_actions, 130 struct rte_flow_error *err); 131 /** See rte_flow_tunnel_match() */ 132 int (*tunnel_match) 133 (struct rte_eth_dev *dev, 134 struct rte_flow_tunnel *tunnel, 135 struct rte_flow_item **pmd_items, 136 uint32_t *num_of_items, 137 struct rte_flow_error *err); 138 /** See rte_flow_get_rte_flow_restore_info() */ 139 int (*get_restore_info) 140 (struct rte_eth_dev *dev, 141 struct rte_mbuf *m, 142 struct rte_flow_restore_info *info, 143 struct rte_flow_error *err); 144 /** See rte_flow_action_tunnel_decap_release() */ 145 int (*tunnel_action_decap_release) 146 (struct rte_eth_dev *dev, 147 struct rte_flow_action *pmd_actions, 148 uint32_t num_of_actions, 149 struct rte_flow_error *err); 150 /** See rte_flow_item_release() */ 151 int (*tunnel_item_release) 152 (struct rte_eth_dev *dev, 153 struct rte_flow_item *pmd_items, 154 uint32_t num_of_items, 155 struct rte_flow_error *err); 156 /** See rte_flow_pick_transfer_proxy() */ 157 int (*pick_transfer_proxy) 158 (struct rte_eth_dev *dev, 159 uint16_t *proxy_port_id, 160 struct rte_flow_error *error); 161 struct rte_flow_item_flex_handle *(*flex_item_create) 162 (struct rte_eth_dev *dev, 163 const struct rte_flow_item_flex_conf *conf, 164 struct rte_flow_error *error); 165 int (*flex_item_release) 166 (struct rte_eth_dev *dev, 167 const struct rte_flow_item_flex_handle *handle, 168 struct rte_flow_error *error); 169 /** See rte_flow_info_get() */ 170 int (*info_get) 171 (struct rte_eth_dev *dev, 172 struct rte_flow_port_info *port_info, 173 struct rte_flow_queue_info *queue_info, 174 struct rte_flow_error *err); 175 /** See rte_flow_configure() */ 176 int (*configure) 177 (struct rte_eth_dev *dev, 178 const struct rte_flow_port_attr *port_attr, 179 uint16_t nb_queue, 180 const struct rte_flow_queue_attr *queue_attr[], 181 struct rte_flow_error *err); 182 /** See rte_flow_pattern_template_create() */ 183 struct rte_flow_pattern_template *(*pattern_template_create) 184 (struct rte_eth_dev *dev, 185 const struct rte_flow_pattern_template_attr *template_attr, 186 const struct rte_flow_item pattern[], 187 struct rte_flow_error *err); 188 /** See rte_flow_pattern_template_destroy() */ 189 int (*pattern_template_destroy) 190 (struct rte_eth_dev *dev, 191 struct rte_flow_pattern_template *pattern_template, 192 struct rte_flow_error *err); 193 /** See rte_flow_actions_template_create() */ 194 struct rte_flow_actions_template *(*actions_template_create) 195 (struct rte_eth_dev *dev, 196 const struct rte_flow_actions_template_attr *template_attr, 197 const struct rte_flow_action actions[], 198 const struct rte_flow_action masks[], 199 struct rte_flow_error *err); 200 /** See rte_flow_actions_template_destroy() */ 201 int (*actions_template_destroy) 202 (struct rte_eth_dev *dev, 203 struct rte_flow_actions_template *actions_template, 204 struct rte_flow_error *err); 205 /** See rte_flow_template_table_create() */ 206 struct rte_flow_template_table *(*template_table_create) 207 (struct rte_eth_dev *dev, 208 const struct rte_flow_template_table_attr *table_attr, 209 struct rte_flow_pattern_template *pattern_templates[], 210 uint8_t nb_pattern_templates, 211 struct rte_flow_actions_template *actions_templates[], 212 uint8_t nb_actions_templates, 213 struct rte_flow_error *err); 214 /** See rte_flow_template_table_destroy() */ 215 int (*template_table_destroy) 216 (struct rte_eth_dev *dev, 217 struct rte_flow_template_table *template_table, 218 struct rte_flow_error *err); 219 /** See rte_flow_async_create() */ 220 struct rte_flow *(*async_create) 221 (struct rte_eth_dev *dev, 222 uint32_t queue_id, 223 const struct rte_flow_op_attr *op_attr, 224 struct rte_flow_template_table *template_table, 225 const struct rte_flow_item pattern[], 226 uint8_t pattern_template_index, 227 const struct rte_flow_action actions[], 228 uint8_t actions_template_index, 229 void *user_data, 230 struct rte_flow_error *err); 231 /** See rte_flow_async_create_by_index() */ 232 struct rte_flow *(*async_create_by_index) 233 (struct rte_eth_dev *dev, 234 uint32_t queue_id, 235 const struct rte_flow_op_attr *op_attr, 236 struct rte_flow_template_table *template_table, 237 uint32_t rule_index, 238 const struct rte_flow_action actions[], 239 uint8_t actions_template_index, 240 void *user_data, 241 struct rte_flow_error *err); 242 /** See rte_flow_async_destroy() */ 243 int (*async_destroy) 244 (struct rte_eth_dev *dev, 245 uint32_t queue_id, 246 const struct rte_flow_op_attr *op_attr, 247 struct rte_flow *flow, 248 void *user_data, 249 struct rte_flow_error *err); 250 /** See rte_flow_push() */ 251 int (*push) 252 (struct rte_eth_dev *dev, 253 uint32_t queue_id, 254 struct rte_flow_error *err); 255 /** See rte_flow_pull() */ 256 int (*pull) 257 (struct rte_eth_dev *dev, 258 uint32_t queue_id, 259 struct rte_flow_op_result res[], 260 uint16_t n_res, 261 struct rte_flow_error *error); 262 /** See rte_flow_async_action_handle_create() */ 263 struct rte_flow_action_handle *(*async_action_handle_create) 264 (struct rte_eth_dev *dev, 265 uint32_t queue_id, 266 const struct rte_flow_op_attr *op_attr, 267 const struct rte_flow_indir_action_conf *indir_action_conf, 268 const struct rte_flow_action *action, 269 void *user_data, 270 struct rte_flow_error *err); 271 /** See rte_flow_async_action_handle_destroy() */ 272 int (*async_action_handle_destroy) 273 (struct rte_eth_dev *dev, 274 uint32_t queue_id, 275 const struct rte_flow_op_attr *op_attr, 276 struct rte_flow_action_handle *action_handle, 277 void *user_data, 278 struct rte_flow_error *error); 279 /** See rte_flow_async_action_handle_update() */ 280 int (*async_action_handle_update) 281 (struct rte_eth_dev *dev, 282 uint32_t queue_id, 283 const struct rte_flow_op_attr *op_attr, 284 struct rte_flow_action_handle *action_handle, 285 const void *update, 286 void *user_data, 287 struct rte_flow_error *error); 288 /** See rte_flow_async_action_handle_query() */ 289 int (*async_action_handle_query) 290 (struct rte_eth_dev *dev, 291 uint32_t queue_id, 292 const struct rte_flow_op_attr *op_attr, 293 const struct rte_flow_action_handle *action_handle, 294 void *data, 295 void *user_data, 296 struct rte_flow_error *error); 297 /** See rte_flow_async_action_handle_query_update */ 298 int (*async_action_handle_query_update) 299 (struct rte_eth_dev *dev, uint32_t queue_id, 300 const struct rte_flow_op_attr *op_attr, 301 struct rte_flow_action_handle *action_handle, 302 const void *update, void *query, 303 enum rte_flow_query_update_mode qu_mode, 304 void *user_data, struct rte_flow_error *error); 305 }; 306 307 /** 308 * Get generic flow operations structure from a port. 309 * 310 * @param port_id 311 * Port identifier to query. 312 * @param[out] error 313 * Pointer to flow error structure. 314 * 315 * @return 316 * The flow operations structure associated with port_id, NULL in case of 317 * error, in which case rte_errno is set and the error structure contains 318 * additional details. 319 */ 320 const struct rte_flow_ops * 321 rte_flow_ops_get(uint16_t port_id, struct rte_flow_error *error); 322 323 #ifdef __cplusplus 324 } 325 #endif 326 327 #endif /* RTE_FLOW_DRIVER_H_ */ 328