1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright(c) 2019-2020 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 /* RSS configuration storage */
31 unsigned int rxq_hw_index_min;
32 unsigned int rxq_hw_index_max;
33 unsigned int rss_hash_types;
34 uint8_t rss_key[EFX_RSS_KEY_SIZE];
35 unsigned int rss_tbl[EFX_RSS_TBL_SIZE];
38 /* Flow engines supported by the implementation */
39 enum sfc_flow_spec_type {
40 SFC_FLOW_SPEC_FILTER = 0,
46 /* VNIC-specific flow specification */
47 struct sfc_flow_spec_filter {
48 /* partial specification from flow rule */
49 efx_filter_spec_t template;
50 /* fully elaborated hardware filters specifications */
51 efx_filter_spec_t filters[SF_FLOW_SPEC_NB_FILTERS_MAX];
52 /* number of complete specifications */
57 boolean_t rss_hash_required;
58 /* RSS configuration */
59 struct sfc_flow_rss rss_conf;
62 /* MAE-specific flow specification */
63 struct sfc_flow_spec_mae {
64 /* Desired priority level */
65 unsigned int priority;
66 /* EFX match specification */
67 efx_mae_match_spec_t *match_spec;
68 /* Action set registry entry */
69 struct sfc_mae_action_set *action_set;
72 /* Flow specification */
73 struct sfc_flow_spec {
74 /* Flow specification type (engine-based) */
75 enum sfc_flow_spec_type type;
79 /* Filter-based (VNIC level flows) specification */
80 struct sfc_flow_spec_filter filter;
81 /* MAE-based (lower-level HW switch flows) specification */
82 struct sfc_flow_spec_mae mae;
86 /* PMD-specific definition of the opaque type from rte_flow.h */
88 struct sfc_flow_spec spec; /* flow specification */
89 TAILQ_ENTRY(rte_flow) entries; /* flow list entries */
92 TAILQ_HEAD(sfc_flow_list, rte_flow);
94 extern const struct rte_flow_ops sfc_flow_ops;
96 enum sfc_flow_item_layers {
97 SFC_FLOW_ITEM_ANY_LAYER,
98 SFC_FLOW_ITEM_START_LAYER,
104 /* Flow parse context types */
105 enum sfc_flow_parse_ctx_type {
106 SFC_FLOW_PARSE_CTX_FILTER = 0,
107 SFC_FLOW_PARSE_CTX_MAE,
109 SFC_FLOW_PARSE_CTX_NTYPES
112 /* Flow parse context */
113 struct sfc_flow_parse_ctx {
114 enum sfc_flow_parse_ctx_type type;
118 /* Context pointer valid for filter-based (VNIC) flows */
119 efx_filter_spec_t *filter;
120 /* Context pointer valid for MAE-based flows */
121 struct sfc_mae_parse_ctx *mae;
125 typedef int (sfc_flow_item_parse)(const struct rte_flow_item *item,
126 struct sfc_flow_parse_ctx *parse_ctx,
127 struct rte_flow_error *error);
129 struct sfc_flow_item {
130 enum rte_flow_item_type type; /* Type of item */
131 enum sfc_flow_item_layers layer; /* Layer of item */
132 enum sfc_flow_item_layers prev_layer; /* Previous layer of item */
133 enum sfc_flow_parse_ctx_type ctx_type; /* Parse context type */
134 sfc_flow_item_parse *parse; /* Parsing function */
137 int sfc_flow_parse_pattern(const struct sfc_flow_item *flow_items,
138 unsigned int nb_flow_items,
139 const struct rte_flow_item pattern[],
140 struct sfc_flow_parse_ctx *parse_ctx,
141 struct rte_flow_error *error);
143 int sfc_flow_parse_init(const struct rte_flow_item *item,
144 const void **spec_ptr,
145 const void **mask_ptr,
146 const void *supp_mask,
147 const void *def_mask,
149 struct rte_flow_error *error);
153 void sfc_flow_init(struct sfc_adapter *sa);
154 void sfc_flow_fini(struct sfc_adapter *sa);
155 int sfc_flow_start(struct sfc_adapter *sa);
156 void sfc_flow_stop(struct sfc_adapter *sa);
158 typedef int (sfc_flow_parse_cb_t)(struct rte_eth_dev *dev,
159 const struct rte_flow_item items[],
160 const struct rte_flow_action actions[],
161 struct rte_flow *flow,
162 struct rte_flow_error *error);
164 typedef int (sfc_flow_verify_cb_t)(struct sfc_adapter *sa,
165 struct rte_flow *flow);
167 typedef void (sfc_flow_cleanup_cb_t)(struct sfc_adapter *sa,
168 struct rte_flow *flow);
170 typedef int (sfc_flow_insert_cb_t)(struct sfc_adapter *sa,
171 struct rte_flow *flow);
173 typedef int (sfc_flow_remove_cb_t)(struct sfc_adapter *sa,
174 struct rte_flow *flow);
179 #endif /* _SFC_FLOW_H */