net/ena: fix build with GCC 12
[dpdk.git] / drivers / net / sfc / sfc_flow_tunnel.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2021 Xilinx, Inc.
4  */
5
6 #ifndef _SFC_FLOW_TUNNEL_H
7 #define _SFC_FLOW_TUNNEL_H
8
9 #include <limits.h>
10 #include <stdbool.h>
11 #include <stdint.h>
12
13 #include <rte_flow.h>
14
15 #include "efx.h"
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 /** Flow Tunnel (FT) SW entry ID */
22 typedef uint8_t sfc_ft_ctx_id_t;
23
24 #define SFC_FT_CTX_MARK_BITS \
25         (sizeof(sfc_ft_ctx_id_t) * CHAR_BIT)
26
27 #define SFC_FT_USER_MARK_BITS \
28         (sizeof(uint32_t) * CHAR_BIT - SFC_FT_CTX_MARK_BITS)
29
30 #define SFC_FT_USER_MARK_MASK \
31         RTE_LEN2MASK(SFC_FT_USER_MARK_BITS, uint32_t)
32
33 #define SFC_FT_FLOW_MARK_TO_CTX_MARK(_flow_mark) \
34         ((_flow_mark) >> SFC_FT_USER_MARK_BITS)
35
36 #define SFC_FT_CTX_MARK_INVALID (0)
37
38 #define SFC_FT_CTX_MARK_TO_CTX_ID(_ctx_mark) \
39         ((_ctx_mark) - 1)
40
41 #define SFC_FT_CTX_ID_TO_CTX_MARK(_ctx_id) \
42         ((_ctx_id) + 1)
43
44 #define SFC_FT_CTX_ID_TO_FLOW_MARK(_ctx_id) \
45         (SFC_FT_CTX_ID_TO_CTX_MARK(_ctx_id) << SFC_FT_USER_MARK_BITS)
46
47 #define SFC_FT_FLOW_MARK_TO_USER_MARK(_flow_mark) \
48         ((_flow_mark) & SFC_FT_USER_MARK_MASK)
49
50 #define SFC_FT_MAX_NTUNNELS \
51         (RTE_LEN2MASK(SFC_FT_CTX_MARK_BITS, uint8_t) - 1)
52
53 struct sfc_ft_ctx {
54         bool                            tunnel_rule_is_set;
55         efx_tunnel_protocol_t           encap_type;
56         struct rte_flow_tunnel          tunnel;
57         unsigned int                    refcnt;
58         sfc_ft_ctx_id_t                 id;
59
60         struct rte_flow_action_mark     action_mark;
61         struct rte_flow_action          action;
62
63         struct rte_flow_item_mark       item_mark_v;
64         struct rte_flow_item_mark       item_mark_m;
65         struct rte_flow_item            item;
66
67         uint64_t                        reset_tunnel_hit_counter;
68         uint64_t                        switch_hit_counter;
69 };
70
71 struct sfc_adapter;
72
73 bool sfc_ft_is_supported(struct sfc_adapter *sa);
74
75 bool sfc_ft_is_active(struct sfc_adapter *sa);
76
77 struct sfc_ft_ctx *sfc_ft_ctx_pick(struct sfc_adapter *sa, uint32_t flow_mark);
78
79 int sfc_ft_tunnel_rule_detect(struct sfc_adapter *sa,
80                               const struct rte_flow_action *actions,
81                               struct sfc_flow_spec_mae *spec,
82                               struct rte_flow_error *error);
83
84 int sfc_ft_decap_set(struct rte_eth_dev *dev, struct rte_flow_tunnel *tunnel,
85                      struct rte_flow_action **pmd_actions,
86                      uint32_t *num_of_actions, struct rte_flow_error *err);
87
88 int sfc_ft_match(struct rte_eth_dev *dev, struct rte_flow_tunnel *tunnel,
89                  struct rte_flow_item **pmd_items, uint32_t *num_of_items,
90                  struct rte_flow_error *err);
91
92 int sfc_ft_item_release(struct rte_eth_dev *dev,
93                         struct rte_flow_item *pmd_items, uint32_t num_items,
94                         struct rte_flow_error *err);
95
96 int sfc_ft_action_decap_release(struct rte_eth_dev *dev,
97                                 struct rte_flow_action *pmd_actions,
98                                 uint32_t num_actions,
99                                 struct rte_flow_error *err);
100
101 int sfc_ft_get_restore_info(struct rte_eth_dev *dev, struct rte_mbuf *m,
102                             struct rte_flow_restore_info *info,
103                             struct rte_flow_error *err);
104
105 void sfc_ft_counters_reset(struct sfc_adapter *sa);
106
107 #ifdef __cplusplus
108 }
109 #endif
110 #endif /* _SFC_FLOW_TUNNEL_H */