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_ctx_id_t;
24 #define SFC_FT_CTX_MARK_BITS \
25 (sizeof(sfc_ft_ctx_id_t) * CHAR_BIT)
27 #define SFC_FT_USER_MARK_BITS \
28 (sizeof(uint32_t) * CHAR_BIT - SFC_FT_CTX_MARK_BITS)
30 #define SFC_FT_USER_MARK_MASK \
31 RTE_LEN2MASK(SFC_FT_USER_MARK_BITS, uint32_t)
33 #define SFC_FT_FLOW_MARK_TO_CTX_MARK(_flow_mark) \
34 ((_flow_mark) >> SFC_FT_USER_MARK_BITS)
36 #define SFC_FT_CTX_MARK_INVALID (0)
38 #define SFC_FT_CTX_MARK_TO_CTX_ID(_ctx_mark) \
41 #define SFC_FT_CTX_ID_TO_CTX_MARK(_ctx_id) \
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)
47 #define SFC_FT_FLOW_MARK_TO_USER_MARK(_flow_mark) \
48 ((_flow_mark) & SFC_FT_USER_MARK_MASK)
50 #define SFC_FT_MAX_NTUNNELS \
51 (RTE_LEN2MASK(SFC_FT_CTX_MARK_BITS, uint8_t) - 1)
54 bool tunnel_rule_is_set;
55 efx_tunnel_protocol_t encap_type;
56 struct rte_flow_tunnel 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;
67 uint64_t reset_tunnel_hit_counter;
68 uint64_t switch_hit_counter;
73 bool sfc_ft_is_supported(struct sfc_adapter *sa);
75 bool sfc_ft_is_active(struct sfc_adapter *sa);
77 struct sfc_ft_ctx *sfc_ft_ctx_pick(struct sfc_adapter *sa, uint32_t flow_mark);
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);
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);
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);
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);
96 int sfc_ft_action_decap_release(struct rte_eth_dev *dev,
97 struct rte_flow_action *pmd_actions,
99 struct rte_flow_error *err);
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);
105 void sfc_ft_counters_reset(struct sfc_adapter *sa);
110 #endif /* _SFC_FLOW_TUNNEL_H */