net/sfc: use adaptive table entry count in flow action RSS
[dpdk.git] / drivers / net / sfc / sfc_flow_rss.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2022 Xilinx, Inc.
4  */
5
6 #ifndef _SFC_FLOW_RSS_H
7 #define _SFC_FLOW_RSS_H
8
9 #include <stdbool.h>
10 #include <stdint.h>
11
12 #include <rte_flow.h>
13 #include <rte_tailq.h>
14
15 #include "efx.h"
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 struct sfc_flow_rss_conf {
22         uint8_t                         key[EFX_RSS_KEY_SIZE];
23         efx_rx_hash_type_t              efx_hash_types;
24         unsigned int                    nb_qid_offsets;
25         unsigned int                    qid_span;
26 };
27
28 struct sfc_flow_rss_ctx {
29         TAILQ_ENTRY(sfc_flow_rss_ctx)   entries;
30
31         unsigned int                    refcnt;
32         bool                            dummy;
33
34         unsigned int                    nic_handle_refcnt;
35         uint32_t                        nic_handle;
36
37         struct sfc_flow_rss_conf        conf;
38
39         uint16_t                        *qid_offsets;
40 };
41
42 TAILQ_HEAD(sfc_flow_rss_ctx_list, sfc_flow_rss_ctx);
43
44 struct sfc_flow_rss {
45         unsigned int                    nb_tbl_entries_min;
46         unsigned int                    nb_tbl_entries_max;
47         unsigned int                    qid_span_max;
48
49         unsigned int                    *bounce_tbl; /* MAX */
50
51         struct sfc_flow_rss_ctx_list    ctx_list;
52 };
53
54 struct sfc_adapter;
55
56 int sfc_flow_rss_attach(struct sfc_adapter *sa);
57
58 void sfc_flow_rss_detach(struct sfc_adapter *sa);
59
60 int sfc_flow_rss_parse_conf(struct sfc_adapter *sa,
61                             const struct rte_flow_action_rss *in,
62                             struct sfc_flow_rss_conf *out,
63                             uint16_t *sw_qid_minp);
64
65 struct sfc_flow_rss_ctx *sfc_flow_rss_ctx_reuse(struct sfc_adapter *sa,
66                                 const struct sfc_flow_rss_conf *conf,
67                                 uint16_t sw_qid_min, const uint16_t *sw_qids);
68
69 int sfc_flow_rss_ctx_add(struct sfc_adapter *sa,
70                          const struct sfc_flow_rss_conf *conf,
71                          uint16_t sw_qid_min, const uint16_t *sw_qids,
72                          struct sfc_flow_rss_ctx **ctxp);
73
74 void sfc_flow_rss_ctx_del(struct sfc_adapter *sa, struct sfc_flow_rss_ctx *ctx);
75
76 int sfc_flow_rss_ctx_program(struct sfc_adapter *sa,
77                              struct sfc_flow_rss_ctx *ctx);
78
79 void sfc_flow_rss_ctx_terminate(struct sfc_adapter *sa,
80                                 struct sfc_flow_rss_ctx *ctx);
81
82 #ifdef __cplusplus
83 }
84 #endif
85 #endif /* _SFC_FLOW_RSS_H */