xref: /dpdk/drivers/net/ntnic/include/create_elements.h (revision effa04693274e59d82b24907c5ee4d1f8eef3cd7)
1 /*
2  * SPDX-License-Identifier: BSD-3-Clause
3  * Copyright(c) 2023 Napatech A/S
4  */
5 
6 #ifndef __CREATE_ELEMENTS_H__
7 #define __CREATE_ELEMENTS_H__
8 
9 #include "stdint.h"
10 
11 #include "stream_binary_flow_api.h"
12 #include <rte_flow.h>
13 
14 #define MAX_ELEMENTS 64
15 #define MAX_ACTIONS 32
16 
17 struct cnv_match_s {
18 	struct rte_flow_item rte_flow_item[MAX_ELEMENTS];
19 };
20 
21 struct cnv_attr_s {
22 	struct cnv_match_s match;
23 	struct rte_flow_attr attr;
24 	uint16_t forced_vlan_vid;
25 	uint16_t caller_id;
26 };
27 
28 struct cnv_action_s {
29 	struct rte_flow_action flow_actions[MAX_ACTIONS];
30 	struct rte_flow_action_rss flow_rss;
31 	struct flow_action_raw_encap encap;
32 	struct flow_action_raw_decap decap;
33 	struct rte_flow_action_queue queue;
34 };
35 
36 /*
37  * Only needed because it eases the use of statistics through NTAPI
38  * for faster integration into NTAPI version of driver
39  * Therefore, this is only a good idea when running on a temporary NTAPI
40  * The query() functionality must go to flow engine, when moved to Open Source driver
41  */
42 
43 struct rte_flow {
44 	void *flw_hdl;
45 	int used;
46 
47 	uint32_t flow_stat_id;
48 
49 	uint64_t stat_pkts;
50 	uint64_t stat_bytes;
51 	uint8_t stat_tcp_flags;
52 
53 	uint16_t caller_id;
54 };
55 
56 enum nt_rte_flow_item_type {
57 	NT_RTE_FLOW_ITEM_TYPE_END = INT_MIN,
58 	NT_RTE_FLOW_ITEM_TYPE_TUNNEL,
59 };
60 
61 extern rte_spinlock_t flow_lock;
62 
63 int interpret_raw_data(uint8_t *data, uint8_t *preserve, int size, struct rte_flow_item *out);
64 int convert_error(struct rte_flow_error *error, struct rte_flow_error *rte_flow_error);
65 int create_attr(struct cnv_attr_s *attribute, const struct rte_flow_attr *attr);
66 int create_match_elements(struct cnv_match_s *match, const struct rte_flow_item items[],
67 	int max_elem);
68 int create_action_elements_inline(struct cnv_action_s *action,
69 	const struct rte_flow_action actions[],
70 	int max_elem,
71 	uint32_t queue_offset);
72 
73 #endif	/* __CREATE_ELEMENTS_H__ */
74