net/sfc: generalise flow specification structure
[dpdk.git] / drivers / net / sfc / sfc_flow.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright (c) 2017-2018 Solarflare Communications Inc.
4  * All rights reserved.
5  *
6  * This software was jointly developed between OKTET Labs (under contract
7  * for Solarflare) and Solarflare Communications, Inc.
8  */
9
10 #ifndef _SFC_FLOW_H
11 #define _SFC_FLOW_H
12
13 #include <rte_tailq.h>
14 #include <rte_flow_driver.h>
15
16 #include "efx.h"
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 /*
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
26  */
27 #define SF_FLOW_SPEC_NB_FILTERS_MAX 8
28
29 /* RSS configuration storage */
30 struct sfc_flow_rss {
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];
36 };
37
38 /* Flow engines supported by the implementation */
39 enum sfc_flow_spec_type {
40         SFC_FLOW_SPEC_FILTER = 0,
41
42         SFC_FLOW_SPEC_NTYPES
43 };
44
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 */
52         unsigned int count;
53         /* RSS toggle */
54         boolean_t rss;
55         /* RSS configuration */
56         struct sfc_flow_rss rss_conf;
57 };
58
59 /* Flow specification */
60 struct sfc_flow_spec {
61         /* Flow specification type (engine-based) */
62         enum sfc_flow_spec_type type;
63
64         RTE_STD_C11
65         union {
66                 /* Filter-based (VNIC level flows) specification */
67                 struct sfc_flow_spec_filter filter;
68         };
69 };
70
71 /* PMD-specific definition of the opaque type from rte_flow.h */
72 struct rte_flow {
73         struct sfc_flow_spec spec;      /* flow specification */
74         TAILQ_ENTRY(rte_flow) entries;  /* flow list entries */
75 };
76
77 TAILQ_HEAD(sfc_flow_list, rte_flow);
78
79 extern const struct rte_flow_ops sfc_flow_ops;
80
81 struct sfc_adapter;
82
83 void sfc_flow_init(struct sfc_adapter *sa);
84 void sfc_flow_fini(struct sfc_adapter *sa);
85 int sfc_flow_start(struct sfc_adapter *sa);
86 void sfc_flow_stop(struct sfc_adapter *sa);
87
88 #ifdef __cplusplus
89 }
90 #endif
91 #endif /* _SFC_FLOW_H */