ethdev: add shared actions to flow API
[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 "rte_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  * To implement this API, PMDs must handle the RTE_ETH_FILTER_GENERIC filter
32  * type in their .filter_ctrl callback function (struct eth_dev_ops) as well
33  * as the RTE_ETH_FILTER_GET filter operation.
34  *
35  * If successful, this operation must result in a pointer to a PMD-specific
36  * struct rte_flow_ops written to the argument address as described below:
37  *
38  * \code
39  *
40  * // PMD filter_ctrl callback
41  *
42  * static const struct rte_flow_ops pmd_flow_ops = { ... };
43  *
44  * switch (filter_type) {
45  * case RTE_ETH_FILTER_GENERIC:
46  *     if (filter_op != RTE_ETH_FILTER_GET)
47  *         return -EINVAL;
48  *     *(const void **)arg = &pmd_flow_ops;
49  *     return 0;
50  * }
51  *
52  * \endcode
53  *
54  * See also rte_flow_ops_get().
55  *
56  * These callback functions are not supposed to be used by applications
57  * directly, which must rely on the API defined in rte_flow.h.
58  *
59  * Public-facing wrapper functions perform a few consistency checks so that
60  * unimplemented (i.e. NULL) callbacks simply return -ENOTSUP. These
61  * callbacks otherwise only differ by their first argument (with port ID
62  * already resolved to a pointer to struct rte_eth_dev).
63  */
64 struct rte_flow_ops {
65         /** See rte_flow_validate(). */
66         int (*validate)
67                 (struct rte_eth_dev *,
68                  const struct rte_flow_attr *,
69                  const struct rte_flow_item [],
70                  const struct rte_flow_action [],
71                  struct rte_flow_error *);
72         /** See rte_flow_create(). */
73         struct rte_flow *(*create)
74                 (struct rte_eth_dev *,
75                  const struct rte_flow_attr *,
76                  const struct rte_flow_item [],
77                  const struct rte_flow_action [],
78                  struct rte_flow_error *);
79         /** See rte_flow_destroy(). */
80         int (*destroy)
81                 (struct rte_eth_dev *,
82                  struct rte_flow *,
83                  struct rte_flow_error *);
84         /** See rte_flow_flush(). */
85         int (*flush)
86                 (struct rte_eth_dev *,
87                  struct rte_flow_error *);
88         /** See rte_flow_query(). */
89         int (*query)
90                 (struct rte_eth_dev *,
91                  struct rte_flow *,
92                  const struct rte_flow_action *,
93                  void *,
94                  struct rte_flow_error *);
95         /** See rte_flow_isolate(). */
96         int (*isolate)
97                 (struct rte_eth_dev *,
98                  int,
99                  struct rte_flow_error *);
100         /** See rte_flow_dev_dump(). */
101         int (*dev_dump)
102                 (struct rte_eth_dev *dev,
103                  FILE *file,
104                  struct rte_flow_error *error);
105         /** See rte_flow_get_aged_flows() */
106         int (*get_aged_flows)
107                 (struct rte_eth_dev *dev,
108                  void **context,
109                  uint32_t nb_contexts,
110                  struct rte_flow_error *err);
111         /** See rte_flow_shared_action_create() */
112         struct rte_flow_shared_action *(*shared_action_create)
113                 (struct rte_eth_dev *dev,
114                  const struct rte_flow_shared_action_conf *conf,
115                  const struct rte_flow_action *action,
116                  struct rte_flow_error *error);
117         /** See rte_flow_shared_action_destroy() */
118         int (*shared_action_destroy)
119                 (struct rte_eth_dev *dev,
120                  struct rte_flow_shared_action *shared_action,
121                  struct rte_flow_error *error);
122         /** See rte_flow_shared_action_update() */
123         int (*shared_action_update)
124                 (struct rte_eth_dev *dev,
125                  struct rte_flow_shared_action *shared_action,
126                  const struct rte_flow_action *update,
127                  struct rte_flow_error *error);
128         /** See rte_flow_shared_action_query() */
129         int (*shared_action_query)
130                 (struct rte_eth_dev *dev,
131                  const struct rte_flow_shared_action *shared_action,
132                  void *data,
133                  struct rte_flow_error *error);
134 };
135
136 /**
137  * Get generic flow operations structure from a port.
138  *
139  * @param port_id
140  *   Port identifier to query.
141  * @param[out] error
142  *   Pointer to flow error structure.
143  *
144  * @return
145  *   The flow operations structure associated with port_id, NULL in case of
146  *   error, in which case rte_errno is set and the error structure contains
147  *   additional details.
148  */
149 const struct rte_flow_ops *
150 rte_flow_ops_get(uint16_t port_id, struct rte_flow_error *error);
151
152 #ifdef __cplusplus
153 }
154 #endif
155
156 #endif /* RTE_FLOW_DRIVER_H_ */