ethdev: replace callback getting filter operations
[dpdk.git] / lib / librte_ethdev / rte_flow_driver.h
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                  FILE *file,
79                  struct rte_flow_error *error);
80         /** See rte_flow_get_aged_flows() */
81         int (*get_aged_flows)
82                 (struct rte_eth_dev *dev,
83                  void **context,
84                  uint32_t nb_contexts,
85                  struct rte_flow_error *err);
86         /** See rte_flow_shared_action_create() */
87         struct rte_flow_shared_action *(*shared_action_create)
88                 (struct rte_eth_dev *dev,
89                  const struct rte_flow_shared_action_conf *conf,
90                  const struct rte_flow_action *action,
91                  struct rte_flow_error *error);
92         /** See rte_flow_shared_action_destroy() */
93         int (*shared_action_destroy)
94                 (struct rte_eth_dev *dev,
95                  struct rte_flow_shared_action *shared_action,
96                  struct rte_flow_error *error);
97         /** See rte_flow_shared_action_update() */
98         int (*shared_action_update)
99                 (struct rte_eth_dev *dev,
100                  struct rte_flow_shared_action *shared_action,
101                  const struct rte_flow_action *update,
102                  struct rte_flow_error *error);
103         /** See rte_flow_shared_action_query() */
104         int (*shared_action_query)
105                 (struct rte_eth_dev *dev,
106                  const struct rte_flow_shared_action *shared_action,
107                  void *data,
108                  struct rte_flow_error *error);
109         /** See rte_flow_tunnel_decap_set() */
110         int (*tunnel_decap_set)
111                 (struct rte_eth_dev *dev,
112                  struct rte_flow_tunnel *tunnel,
113                  struct rte_flow_action **pmd_actions,
114                  uint32_t *num_of_actions,
115                  struct rte_flow_error *err);
116         /** See rte_flow_tunnel_match() */
117         int (*tunnel_match)
118                 (struct rte_eth_dev *dev,
119                  struct rte_flow_tunnel *tunnel,
120                  struct rte_flow_item **pmd_items,
121                  uint32_t *num_of_items,
122                  struct rte_flow_error *err);
123         /** See rte_flow_get_rte_flow_restore_info() */
124         int (*get_restore_info)
125                 (struct rte_eth_dev *dev,
126                  struct rte_mbuf *m,
127                  struct rte_flow_restore_info *info,
128                  struct rte_flow_error *err);
129         /** See rte_flow_action_tunnel_decap_release() */
130         int (*tunnel_action_decap_release)
131                 (struct rte_eth_dev *dev,
132                  struct rte_flow_action *pmd_actions,
133                  uint32_t num_of_actions,
134                  struct rte_flow_error *err);
135         /** See rte_flow_item_release() */
136         int (*tunnel_item_release)
137                 (struct rte_eth_dev *dev,
138                  struct rte_flow_item *pmd_items,
139                  uint32_t num_of_items,
140                  struct rte_flow_error *err);
141 };
142
143 /**
144  * Get generic flow operations structure from a port.
145  *
146  * @param port_id
147  *   Port identifier to query.
148  * @param[out] error
149  *   Pointer to flow error structure.
150  *
151  * @return
152  *   The flow operations structure associated with port_id, NULL in case of
153  *   error, in which case rte_errno is set and the error structure contains
154  *   additional details.
155  */
156 const struct rte_flow_ops *
157 rte_flow_ops_get(uint16_t port_id, struct rte_flow_error *error);
158
159 #ifdef __cplusplus
160 }
161 #endif
162
163 #endif /* RTE_FLOW_DRIVER_H_ */