1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright(c) 2019-2021 Xilinx, Inc.
4 * Copyright(c) 2017-2019 Solarflare Communications Inc.
6 * This software was jointly developed between OKTET Labs (under contract
7 * for Solarflare) and Solarflare Communications, Inc.
13 #include <rte_tailq.h>
14 #include <rte_flow_driver.h>
23 * The maximum number of fully elaborated hardware filter specifications
24 * which can be produced from a template by means of multiplication, if
25 * missing match flags are needed to be taken into account
27 #define SF_FLOW_SPEC_NB_FILTERS_MAX 8
29 /* Used to guard action masks */
30 #define SFC_BUILD_SET_OVERFLOW(_action, _set) \
31 RTE_BUILD_BUG_ON((_action) >= sizeof(_set) * CHAR_BIT)
33 /* RSS configuration storage */
35 unsigned int rxq_hw_index_min;
36 unsigned int rxq_hw_index_max;
37 unsigned int rss_hash_types;
38 uint8_t rss_key[EFX_RSS_KEY_SIZE];
39 unsigned int rss_tbl[EFX_RSS_TBL_SIZE];
42 /* Flow engines supported by the implementation */
43 enum sfc_flow_spec_type {
44 SFC_FLOW_SPEC_FILTER = 0,
50 /* VNIC-specific flow specification */
51 struct sfc_flow_spec_filter {
52 /* partial specification from flow rule */
53 efx_filter_spec_t template;
54 /* fully elaborated hardware filters specifications */
55 efx_filter_spec_t filters[SF_FLOW_SPEC_NB_FILTERS_MAX];
56 /* number of complete specifications */
61 boolean_t rss_hash_required;
62 /* RSS configuration */
63 struct sfc_flow_rss rss_conf;
66 /* MAE-specific flow specification */
67 struct sfc_flow_spec_mae {
68 /* Desired priority level */
69 unsigned int priority;
70 /* Outer rule registry entry */
71 struct sfc_mae_outer_rule *outer_rule;
72 /* EFX match specification */
73 efx_mae_match_spec_t *match_spec;
74 /* Action set registry entry */
75 struct sfc_mae_action_set *action_set;
76 /* Firmware-allocated rule ID */
77 efx_mae_rule_id_t rule_id;
80 /* Flow specification */
81 struct sfc_flow_spec {
82 /* Flow specification type (engine-based) */
83 enum sfc_flow_spec_type type;
87 /* Filter-based (VNIC level flows) specification */
88 struct sfc_flow_spec_filter filter;
89 /* MAE-based (lower-level HW switch flows) specification */
90 struct sfc_flow_spec_mae mae;
94 /* PMD-specific definition of the opaque type from rte_flow.h */
96 struct sfc_flow_spec spec; /* flow specification */
97 TAILQ_ENTRY(rte_flow) entries; /* flow list entries */
100 TAILQ_HEAD(sfc_flow_list, rte_flow);
102 extern const struct rte_flow_ops sfc_flow_ops;
104 enum sfc_flow_item_layers {
105 SFC_FLOW_ITEM_ANY_LAYER,
106 SFC_FLOW_ITEM_START_LAYER,
112 /* Flow parse context types */
113 enum sfc_flow_parse_ctx_type {
114 SFC_FLOW_PARSE_CTX_FILTER = 0,
115 SFC_FLOW_PARSE_CTX_MAE,
117 SFC_FLOW_PARSE_CTX_NTYPES
120 /* Flow parse context */
121 struct sfc_flow_parse_ctx {
122 enum sfc_flow_parse_ctx_type type;
126 /* Context pointer valid for filter-based (VNIC) flows */
127 efx_filter_spec_t *filter;
128 /* Context pointer valid for MAE-based flows */
129 struct sfc_mae_parse_ctx *mae;
133 typedef int (sfc_flow_item_parse)(const struct rte_flow_item *item,
134 struct sfc_flow_parse_ctx *parse_ctx,
135 struct rte_flow_error *error);
137 struct sfc_flow_item {
138 enum rte_flow_item_type type; /* Type of item */
139 enum sfc_flow_item_layers layer; /* Layer of item */
140 enum sfc_flow_item_layers prev_layer; /* Previous layer of item */
141 enum sfc_flow_parse_ctx_type ctx_type; /* Parse context type */
142 sfc_flow_item_parse *parse; /* Parsing function */
145 int sfc_flow_parse_pattern(const struct sfc_flow_item *flow_items,
146 unsigned int nb_flow_items,
147 const struct rte_flow_item pattern[],
148 struct sfc_flow_parse_ctx *parse_ctx,
149 struct rte_flow_error *error);
151 int sfc_flow_parse_init(const struct rte_flow_item *item,
152 const void **spec_ptr,
153 const void **mask_ptr,
154 const void *supp_mask,
155 const void *def_mask,
157 struct rte_flow_error *error);
161 void sfc_flow_init(struct sfc_adapter *sa);
162 void sfc_flow_fini(struct sfc_adapter *sa);
163 int sfc_flow_start(struct sfc_adapter *sa);
164 void sfc_flow_stop(struct sfc_adapter *sa);
166 typedef int (sfc_flow_parse_cb_t)(struct rte_eth_dev *dev,
167 const struct rte_flow_item items[],
168 const struct rte_flow_action actions[],
169 struct rte_flow *flow,
170 struct rte_flow_error *error);
172 typedef int (sfc_flow_verify_cb_t)(struct sfc_adapter *sa,
173 struct rte_flow *flow);
175 typedef void (sfc_flow_cleanup_cb_t)(struct sfc_adapter *sa,
176 struct rte_flow *flow);
178 typedef int (sfc_flow_insert_cb_t)(struct sfc_adapter *sa,
179 struct rte_flow *flow);
181 typedef int (sfc_flow_remove_cb_t)(struct sfc_adapter *sa,
182 struct rte_flow *flow);
187 #endif /* _SFC_FLOW_H */