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,
45 /* VNIC-specific flow specification */
46 struct sfc_flow_spec_filter {
47 /* partial specification from flow rule */
48 efx_filter_spec_t template;
49 /* fully elaborated hardware filters specifications */
50 efx_filter_spec_t filters[SF_FLOW_SPEC_NB_FILTERS_MAX];
51 /* number of complete specifications */
55 /* RSS configuration */
56 struct sfc_flow_rss rss_conf;
59 /* Flow specification */
60 struct sfc_flow_spec {
61 /* Flow specification type (engine-based) */
62 enum sfc_flow_spec_type type;
66 /* Filter-based (VNIC level flows) specification */
67 struct sfc_flow_spec_filter filter;
71 /* PMD-specific definition of the opaque type from rte_flow.h */
73 struct sfc_flow_spec spec; /* flow specification */
74 TAILQ_ENTRY(rte_flow) entries; /* flow list entries */
77 TAILQ_HEAD(sfc_flow_list, rte_flow);
79 extern const struct rte_flow_ops sfc_flow_ops;
81 enum sfc_flow_item_layers {
82 SFC_FLOW_ITEM_ANY_LAYER,
83 SFC_FLOW_ITEM_START_LAYER,
89 /* Flow parse context types */
90 enum sfc_flow_parse_ctx_type {
91 SFC_FLOW_PARSE_CTX_FILTER = 0,
93 SFC_FLOW_PARSE_CTX_NTYPES
96 /* Flow parse context */
97 struct sfc_flow_parse_ctx {
98 enum sfc_flow_parse_ctx_type type;
102 /* Context pointer valid for filter-based (VNIC) flows */
103 efx_filter_spec_t *filter;
107 typedef int (sfc_flow_item_parse)(const struct rte_flow_item *item,
108 struct sfc_flow_parse_ctx *parse_ctx,
109 struct rte_flow_error *error);
111 struct sfc_flow_item {
112 enum rte_flow_item_type type; /* Type of item */
113 enum sfc_flow_item_layers layer; /* Layer of item */
114 enum sfc_flow_item_layers prev_layer; /* Previous layer of item */
115 enum sfc_flow_parse_ctx_type ctx_type; /* Parse context type */
116 sfc_flow_item_parse *parse; /* Parsing function */
119 int sfc_flow_parse_pattern(const struct sfc_flow_item *flow_items,
120 unsigned int nb_flow_items,
121 const struct rte_flow_item pattern[],
122 struct sfc_flow_parse_ctx *parse_ctx,
123 struct rte_flow_error *error);
125 int sfc_flow_parse_init(const struct rte_flow_item *item,
126 const void **spec_ptr,
127 const void **mask_ptr,
128 const void *supp_mask,
129 const void *def_mask,
131 struct rte_flow_error *error);
135 void sfc_flow_init(struct sfc_adapter *sa);
136 void sfc_flow_fini(struct sfc_adapter *sa);
137 int sfc_flow_start(struct sfc_adapter *sa);
138 void sfc_flow_stop(struct sfc_adapter *sa);
140 typedef int (sfc_flow_parse_cb_t)(struct rte_eth_dev *dev,
141 const struct rte_flow_item items[],
142 const struct rte_flow_action actions[],
143 struct rte_flow *flow,
144 struct rte_flow_error *error);
146 typedef int (sfc_flow_insert_cb_t)(struct sfc_adapter *sa,
147 struct rte_flow *flow);
149 typedef int (sfc_flow_remove_cb_t)(struct sfc_adapter *sa,
150 struct rte_flow *flow);
155 #endif /* _SFC_FLOW_H */