net/sfc: support jump flows in tunnel offload
[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 "efx.h"
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 /** Flow Tunnel (FT) SW entry ID */
20 typedef uint8_t sfc_ft_id_t;
21
22 #define SFC_FT_TUNNEL_MARK_BITS \
23         (sizeof(sfc_ft_id_t) * CHAR_BIT)
24
25 #define SFC_FT_USER_MARK_BITS \
26         (sizeof(uint32_t) * CHAR_BIT - SFC_FT_TUNNEL_MARK_BITS)
27
28 #define SFC_FT_USER_MARK_MASK \
29         RTE_LEN2MASK(SFC_FT_USER_MARK_BITS, uint32_t)
30
31 #define SFC_FT_GET_TUNNEL_MARK(_mark) \
32         ((_mark) >> SFC_FT_USER_MARK_BITS)
33
34 #define SFC_FT_TUNNEL_MARK_INVALID      (0)
35
36 #define SFC_FT_TUNNEL_MARK_TO_ID(_tunnel_mark) \
37         ((_tunnel_mark) - 1)
38
39 #define SFC_FT_ID_TO_TUNNEL_MARK(_id) \
40         ((_id) + 1)
41
42 #define SFC_FT_MAX_NTUNNELS \
43         (RTE_LEN2MASK(SFC_FT_TUNNEL_MARK_BITS, uint8_t) - 1)
44
45 struct sfc_flow_tunnel {
46         bool                            jump_rule_is_set;
47         efx_tunnel_protocol_t           encap_type;
48         unsigned int                    refcnt;
49         sfc_ft_id_t                     id;
50 };
51
52 struct sfc_adapter;
53
54 bool sfc_flow_tunnel_is_supported(struct sfc_adapter *sa);
55
56 bool sfc_flow_tunnel_is_active(struct sfc_adapter *sa);
57
58 struct sfc_flow_tunnel *sfc_flow_tunnel_pick(struct sfc_adapter *sa,
59                                              uint32_t ft_mark);
60
61 int sfc_flow_tunnel_detect_jump_rule(struct sfc_adapter *sa,
62                                      const struct rte_flow_action *actions,
63                                      struct sfc_flow_spec_mae *spec,
64                                      struct rte_flow_error *error);
65
66 #ifdef __cplusplus
67 }
68 #endif
69 #endif /* _SFC_FLOW_TUNNEL_H */