1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright(c) 2021 Xilinx, Inc.
6 #ifndef _SFC_FLOW_TUNNEL_H
7 #define _SFC_FLOW_TUNNEL_H
21 /** Flow Tunnel (FT) SW entry ID */
22 typedef uint8_t sfc_ft_id_t;
24 #define SFC_FT_TUNNEL_MARK_BITS \
25 (sizeof(sfc_ft_id_t) * CHAR_BIT)
27 #define SFC_FT_USER_MARK_BITS \
28 (sizeof(uint32_t) * CHAR_BIT - SFC_FT_TUNNEL_MARK_BITS)
30 #define SFC_FT_USER_MARK_MASK \
31 RTE_LEN2MASK(SFC_FT_USER_MARK_BITS, uint32_t)
33 #define SFC_FT_GET_TUNNEL_MARK(_mark) \
34 ((_mark) >> SFC_FT_USER_MARK_BITS)
36 #define SFC_FT_TUNNEL_MARK_INVALID (0)
38 #define SFC_FT_TUNNEL_MARK_TO_ID(_tunnel_mark) \
41 #define SFC_FT_ID_TO_TUNNEL_MARK(_id) \
44 #define SFC_FT_ID_TO_MARK(_id) \
45 (SFC_FT_ID_TO_TUNNEL_MARK(_id) << SFC_FT_USER_MARK_BITS)
47 #define SFC_FT_GET_USER_MARK(_mark) \
48 ((_mark) & SFC_FT_USER_MARK_MASK)
50 #define SFC_FT_MAX_NTUNNELS \
51 (RTE_LEN2MASK(SFC_FT_TUNNEL_MARK_BITS, uint8_t) - 1)
53 struct sfc_flow_tunnel {
54 bool jump_rule_is_set;
55 efx_tunnel_protocol_t encap_type;
56 struct rte_flow_tunnel rte_tunnel;
60 struct rte_flow_action_mark action_mark;
61 struct rte_flow_action action;
63 struct rte_flow_item_mark item_mark_v;
64 struct rte_flow_item_mark item_mark_m;
65 struct rte_flow_item item;
70 bool sfc_flow_tunnel_is_supported(struct sfc_adapter *sa);
72 bool sfc_flow_tunnel_is_active(struct sfc_adapter *sa);
74 struct sfc_flow_tunnel *sfc_flow_tunnel_pick(struct sfc_adapter *sa,
77 int sfc_flow_tunnel_detect_jump_rule(struct sfc_adapter *sa,
78 const struct rte_flow_action *actions,
79 struct sfc_flow_spec_mae *spec,
80 struct rte_flow_error *error);
82 int sfc_flow_tunnel_decap_set(struct rte_eth_dev *dev,
83 struct rte_flow_tunnel *tunnel,
84 struct rte_flow_action **pmd_actions,
85 uint32_t *num_of_actions,
86 struct rte_flow_error *err);
88 int sfc_flow_tunnel_match(struct rte_eth_dev *dev,
89 struct rte_flow_tunnel *tunnel,
90 struct rte_flow_item **pmd_items,
91 uint32_t *num_of_items,
92 struct rte_flow_error *err);
94 int sfc_flow_tunnel_item_release(struct rte_eth_dev *dev,
95 struct rte_flow_item *pmd_items,
97 struct rte_flow_error *err);
99 int sfc_flow_tunnel_action_decap_release(struct rte_eth_dev *dev,
100 struct rte_flow_action *pmd_actions,
101 uint32_t num_actions,
102 struct rte_flow_error *err);
104 int sfc_flow_tunnel_get_restore_info(struct rte_eth_dev *dev,
106 struct rte_flow_restore_info *info,
107 struct rte_flow_error *err);
112 #endif /* _SFC_FLOW_TUNNEL_H */