xref: /dpdk/drivers/net/intel/cpfl/cpfl_flow.h (revision c1d145834f287aa8cf53de914618a7312f2c360e)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2023 Intel Corporation
3  */
4 
5 #ifndef _CPFL_FLOW_H_
6 #define _CPFL_FLOW_H_
7 
8 #include <rte_flow.h>
9 #include "cpfl_ethdev.h"
10 
11 #define CPFL_PREC_MAX 7
12 
13 extern const struct rte_flow_ops cpfl_flow_ops;
14 
15 enum cpfl_flow_engine_type {
16 	CPFL_FLOW_ENGINE_NONE = 0,
17 	CPFL_FLOW_ENGINE_FXP,
18 };
19 
20 typedef int (*engine_init_t)(struct cpfl_adapter_ext *ad);
21 typedef void (*engine_uninit_t)(struct cpfl_adapter_ext *ad);
22 typedef int (*engine_create_t)(struct rte_eth_dev *dev,
23 			       struct rte_flow *flow,
24 			       void *meta,
25 			       struct rte_flow_error *error);
26 typedef int (*engine_destroy_t)(struct rte_eth_dev *dev,
27 				struct rte_flow *flow,
28 				struct rte_flow_error *error);
29 typedef int (*engine_query_t)(struct rte_eth_dev *dev,
30 			      struct rte_flow *flow,
31 			      struct rte_flow_query_count *count,
32 			      struct rte_flow_error *error);
33 typedef void (*engine_free_t) (struct rte_flow *flow);
34 typedef int (*engine_parse_pattern_action_t)(struct rte_eth_dev *dev,
35 					     const struct rte_flow_attr *attr,
36 					     const struct rte_flow_item pattern[],
37 					     const struct rte_flow_action actions[],
38 					     void **meta);
39 
40 struct cpfl_flow_engine {
41 	TAILQ_ENTRY(cpfl_flow_engine) node;
42 	enum cpfl_flow_engine_type type;
43 	engine_init_t init;
44 	engine_uninit_t uninit;
45 	engine_create_t create;
46 	engine_destroy_t destroy;
47 	engine_query_t query_count;
48 	engine_free_t free;
49 	engine_parse_pattern_action_t parse_pattern_action;
50 };
51 
52 struct rte_flow {
53 	TAILQ_ENTRY(rte_flow) next;
54 	struct cpfl_flow_engine *engine;
55 	void *rule;
56 };
57 
58 void cpfl_flow_engine_register(struct cpfl_flow_engine *engine);
59 struct cpfl_flow_engine *cpfl_flow_engine_match(struct rte_eth_dev *dev,
60 						const struct rte_flow_attr *attr,
61 						const struct rte_flow_item pattern[],
62 						const struct rte_flow_action actions[],
63 						void **meta);
64 int cpfl_flow_engine_init(struct cpfl_adapter_ext *adapter);
65 void cpfl_flow_engine_uninit(struct cpfl_adapter_ext *adapter);
66 int cpfl_flow_init(struct cpfl_adapter_ext *ad, struct cpfl_devargs *devargs);
67 void cpfl_flow_uninit(struct cpfl_adapter_ext *ad);
68 struct rte_flow *cpfl_flow_create(struct rte_eth_dev *dev,
69 				  const struct rte_flow_attr *attr,
70 				  const struct rte_flow_item pattern[],
71 				  const struct rte_flow_action actions[],
72 				  struct rte_flow_error *error);
73 int cpfl_flow_validate(struct rte_eth_dev *dev,
74 		       const struct rte_flow_attr *attr,
75 		       const struct rte_flow_item pattern[],
76 		       const struct rte_flow_action actions[],
77 		       struct rte_flow_error *error);
78 int cpfl_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, struct rte_flow_error *error);
79 int cpfl_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error);
80 int cpfl_flow_query(struct rte_eth_dev *dev,
81 		    struct rte_flow *flow,
82 		    const struct rte_flow_action *actions,
83 		    void *data,
84 		    struct rte_flow_error *error);
85 #endif
86