xref: /dpdk/drivers/net/sfc/sfc_flow_rss.h (revision 68cde2a3bd106934869205636c4399e0e02fdd38)
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 	enum rte_eth_hash_function	rte_hash_function;
24 	efx_rx_hash_type_t		efx_hash_types;
25 	unsigned int			nb_qid_offsets;
26 	unsigned int			qid_span;
27 };
28 
29 struct sfc_flow_rss_ctx {
30 	TAILQ_ENTRY(sfc_flow_rss_ctx)	entries;
31 
32 	unsigned int			refcnt;
33 	bool				dummy;
34 
35 	unsigned int			nic_handle_refcnt;
36 	uint32_t			nic_handle;
37 
38 	struct sfc_flow_rss_conf	conf;
39 
40 	uint16_t			*qid_offsets;
41 };
42 
43 TAILQ_HEAD(sfc_flow_rss_ctx_list, sfc_flow_rss_ctx);
44 
45 struct sfc_flow_rss {
46 	unsigned int			nb_tbl_entries_min;
47 	unsigned int			nb_tbl_entries_max;
48 	unsigned int			qid_span_max;
49 
50 	unsigned int			*bounce_tbl; /* MAX */
51 
52 	struct sfc_flow_rss_ctx_list	ctx_list;
53 };
54 
55 struct sfc_adapter;
56 
57 int sfc_flow_rss_attach(struct sfc_adapter *sa);
58 
59 void sfc_flow_rss_detach(struct sfc_adapter *sa);
60 
61 int sfc_flow_rss_parse_conf(struct sfc_adapter *sa,
62 			    const struct rte_flow_action_rss *in,
63 			    struct sfc_flow_rss_conf *out,
64 			    uint16_t *sw_qid_minp);
65 
66 struct sfc_flow_rss_ctx *sfc_flow_rss_ctx_reuse(struct sfc_adapter *sa,
67 				const struct sfc_flow_rss_conf *conf,
68 				uint16_t sw_qid_min, const uint16_t *sw_qids);
69 
70 int sfc_flow_rss_ctx_add(struct sfc_adapter *sa,
71 			 const struct sfc_flow_rss_conf *conf,
72 			 uint16_t sw_qid_min, const uint16_t *sw_qids,
73 			 struct sfc_flow_rss_ctx **ctxp);
74 
75 void sfc_flow_rss_ctx_del(struct sfc_adapter *sa, struct sfc_flow_rss_ctx *ctx);
76 
77 int sfc_flow_rss_ctx_program(struct sfc_adapter *sa,
78 			     struct sfc_flow_rss_ctx *ctx);
79 
80 void sfc_flow_rss_ctx_terminate(struct sfc_adapter *sa,
81 				struct sfc_flow_rss_ctx *ctx);
82 
83 #ifdef __cplusplus
84 }
85 #endif
86 #endif /* _SFC_FLOW_RSS_H */
87