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_action_handle_create() */ 88 struct rte_flow_action_handle *(*action_handle_create) 89 (struct rte_eth_dev *dev, 90 const struct rte_flow_indir_action_conf *conf, 91 const struct rte_flow_action *action, 92 struct rte_flow_error *error); 93 /** See rte_flow_action_handle_destroy() */ 94 int (*action_handle_destroy) 95 (struct rte_eth_dev *dev, 96 struct rte_flow_action_handle *handle, 97 struct rte_flow_error *error); 98 /** See rte_flow_action_handle_update() */ 99 int (*action_handle_update) 100 (struct rte_eth_dev *dev, 101 struct rte_flow_action_handle *handle, 102 const void *update, 103 struct rte_flow_error *error); 104 /** See rte_flow_action_handle_query() */ 105 int (*action_handle_query) 106 (struct rte_eth_dev *dev, 107 const struct rte_flow_action_handle *handle, 108 void *data, 109 struct rte_flow_error *error); 110 /** See rte_flow_tunnel_decap_set() */ 111 int (*tunnel_decap_set) 112 (struct rte_eth_dev *dev, 113 struct rte_flow_tunnel *tunnel, 114 struct rte_flow_action **pmd_actions, 115 uint32_t *num_of_actions, 116 struct rte_flow_error *err); 117 /** See rte_flow_tunnel_match() */ 118 int (*tunnel_match) 119 (struct rte_eth_dev *dev, 120 struct rte_flow_tunnel *tunnel, 121 struct rte_flow_item **pmd_items, 122 uint32_t *num_of_items, 123 struct rte_flow_error *err); 124 /** See rte_flow_get_rte_flow_restore_info() */ 125 int (*get_restore_info) 126 (struct rte_eth_dev *dev, 127 struct rte_mbuf *m, 128 struct rte_flow_restore_info *info, 129 struct rte_flow_error *err); 130 /** See rte_flow_action_tunnel_decap_release() */ 131 int (*tunnel_action_decap_release) 132 (struct rte_eth_dev *dev, 133 struct rte_flow_action *pmd_actions, 134 uint32_t num_of_actions, 135 struct rte_flow_error *err); 136 /** See rte_flow_item_release() */ 137 int (*tunnel_item_release) 138 (struct rte_eth_dev *dev, 139 struct rte_flow_item *pmd_items, 140 uint32_t num_of_items, 141 struct rte_flow_error *err); 142 /** See rte_flow_pick_transfer_proxy() */ 143 int (*pick_transfer_proxy) 144 (struct rte_eth_dev *dev, 145 uint16_t *proxy_port_id, 146 struct rte_flow_error *error); 147 struct rte_flow_item_flex_handle *(*flex_item_create) 148 (struct rte_eth_dev *dev, 149 const struct rte_flow_item_flex_conf *conf, 150 struct rte_flow_error *error); 151 int (*flex_item_release) 152 (struct rte_eth_dev *dev, 153 const struct rte_flow_item_flex_handle *handle, 154 struct rte_flow_error *error); 155 /** See rte_flow_info_get() */ 156 int (*info_get) 157 (struct rte_eth_dev *dev, 158 struct rte_flow_port_info *port_info, 159 struct rte_flow_error *err); 160 /** See rte_flow_configure() */ 161 int (*configure) 162 (struct rte_eth_dev *dev, 163 const struct rte_flow_port_attr *port_attr, 164 struct rte_flow_error *err); 165 /** See rte_flow_pattern_template_create() */ 166 struct rte_flow_pattern_template *(*pattern_template_create) 167 (struct rte_eth_dev *dev, 168 const struct rte_flow_pattern_template_attr *template_attr, 169 const struct rte_flow_item pattern[], 170 struct rte_flow_error *err); 171 /** See rte_flow_pattern_template_destroy() */ 172 int (*pattern_template_destroy) 173 (struct rte_eth_dev *dev, 174 struct rte_flow_pattern_template *pattern_template, 175 struct rte_flow_error *err); 176 /** See rte_flow_actions_template_create() */ 177 struct rte_flow_actions_template *(*actions_template_create) 178 (struct rte_eth_dev *dev, 179 const struct rte_flow_actions_template_attr *template_attr, 180 const struct rte_flow_action actions[], 181 const struct rte_flow_action masks[], 182 struct rte_flow_error *err); 183 /** See rte_flow_actions_template_destroy() */ 184 int (*actions_template_destroy) 185 (struct rte_eth_dev *dev, 186 struct rte_flow_actions_template *actions_template, 187 struct rte_flow_error *err); 188 /** See rte_flow_template_table_create() */ 189 struct rte_flow_template_table *(*template_table_create) 190 (struct rte_eth_dev *dev, 191 const struct rte_flow_template_table_attr *table_attr, 192 struct rte_flow_pattern_template *pattern_templates[], 193 uint8_t nb_pattern_templates, 194 struct rte_flow_actions_template *actions_templates[], 195 uint8_t nb_actions_templates, 196 struct rte_flow_error *err); 197 /** See rte_flow_template_table_destroy() */ 198 int (*template_table_destroy) 199 (struct rte_eth_dev *dev, 200 struct rte_flow_template_table *template_table, 201 struct rte_flow_error *err); 202 }; 203 204 /** 205 * Get generic flow operations structure from a port. 206 * 207 * @param port_id 208 * Port identifier to query. 209 * @param[out] error 210 * Pointer to flow error structure. 211 * 212 * @return 213 * The flow operations structure associated with port_id, NULL in case of 214 * error, in which case rte_errno is set and the error structure contains 215 * additional details. 216 */ 217 const struct rte_flow_ops * 218 rte_flow_ops_get(uint16_t port_id, struct rte_flow_error *error); 219 220 #ifdef __cplusplus 221 } 222 #endif 223 224 #endif /* RTE_FLOW_DRIVER_H_ */ 225