xref: /linux/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h (revision da1d9caf95def6f0320819cf941c9fd1069ba9e1)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2021, Intel Corporation. */
3 
4 #ifndef _IAVF_ADV_RSS_H_
5 #define _IAVF_ADV_RSS_H_
6 
7 struct iavf_adapter;
8 
9 /* State of advanced RSS configuration */
10 enum iavf_adv_rss_state_t {
11 	IAVF_ADV_RSS_ADD_REQUEST,	/* User requests to add RSS */
12 	IAVF_ADV_RSS_ADD_PENDING,	/* RSS pending add by the PF */
13 	IAVF_ADV_RSS_DEL_REQUEST,	/* Driver requests to delete RSS */
14 	IAVF_ADV_RSS_DEL_PENDING,	/* RSS pending delete by the PF */
15 	IAVF_ADV_RSS_ACTIVE,		/* RSS configuration is active */
16 };
17 
18 enum iavf_adv_rss_flow_seg_hdr {
19 	IAVF_ADV_RSS_FLOW_SEG_HDR_NONE	= 0x00000000,
20 	IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4	= 0x00000001,
21 	IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6	= 0x00000002,
22 	IAVF_ADV_RSS_FLOW_SEG_HDR_TCP	= 0x00000004,
23 	IAVF_ADV_RSS_FLOW_SEG_HDR_UDP	= 0x00000008,
24 	IAVF_ADV_RSS_FLOW_SEG_HDR_SCTP	= 0x00000010,
25 };
26 
27 #define IAVF_ADV_RSS_FLOW_SEG_HDR_L3		\
28 	(IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4	|	\
29 	 IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6)
30 
31 #define IAVF_ADV_RSS_FLOW_SEG_HDR_L4		\
32 	(IAVF_ADV_RSS_FLOW_SEG_HDR_TCP |	\
33 	 IAVF_ADV_RSS_FLOW_SEG_HDR_UDP |	\
34 	 IAVF_ADV_RSS_FLOW_SEG_HDR_SCTP)
35 
36 enum iavf_adv_rss_flow_field {
37 	/* L3 */
38 	IAVF_ADV_RSS_FLOW_FIELD_IDX_IPV4_SA,
39 	IAVF_ADV_RSS_FLOW_FIELD_IDX_IPV4_DA,
40 	IAVF_ADV_RSS_FLOW_FIELD_IDX_IPV6_SA,
41 	IAVF_ADV_RSS_FLOW_FIELD_IDX_IPV6_DA,
42 	/* L4 */
43 	IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_SRC_PORT,
44 	IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_DST_PORT,
45 	IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_SRC_PORT,
46 	IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_DST_PORT,
47 	IAVF_ADV_RSS_FLOW_FIELD_IDX_SCTP_SRC_PORT,
48 	IAVF_ADV_RSS_FLOW_FIELD_IDX_SCTP_DST_PORT,
49 
50 	/* The total number of enums must not exceed 64 */
51 	IAVF_ADV_RSS_FLOW_FIELD_IDX_MAX
52 };
53 
54 #define IAVF_ADV_RSS_HASH_INVALID	0
55 #define IAVF_ADV_RSS_HASH_FLD_IPV4_SA	\
56 	BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_IPV4_SA)
57 #define IAVF_ADV_RSS_HASH_FLD_IPV6_SA	\
58 	BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_IPV6_SA)
59 #define IAVF_ADV_RSS_HASH_FLD_IPV4_DA	\
60 	BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_IPV4_DA)
61 #define IAVF_ADV_RSS_HASH_FLD_IPV6_DA	\
62 	BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_IPV6_DA)
63 #define IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT	\
64 	BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_SRC_PORT)
65 #define IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT	\
66 	BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_DST_PORT)
67 #define IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT	\
68 	BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_SRC_PORT)
69 #define IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT	\
70 	BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_DST_PORT)
71 #define IAVF_ADV_RSS_HASH_FLD_SCTP_SRC_PORT	\
72 	BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_SCTP_SRC_PORT)
73 #define IAVF_ADV_RSS_HASH_FLD_SCTP_DST_PORT	\
74 	BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_SCTP_DST_PORT)
75 
76 /* bookkeeping of advanced RSS configuration */
77 struct iavf_adv_rss {
78 	enum iavf_adv_rss_state_t state;
79 	struct list_head list;
80 
81 	u32 packet_hdrs;
82 	u64 hash_flds;
83 
84 	struct virtchnl_rss_cfg cfg_msg;
85 };
86 
87 int
88 iavf_fill_adv_rss_cfg_msg(struct virtchnl_rss_cfg *rss_cfg,
89 			  u32 packet_hdrs, u64 hash_flds);
90 struct iavf_adv_rss *
91 iavf_find_adv_rss_cfg_by_hdrs(struct iavf_adapter *adapter, u32 packet_hdrs);
92 void
93 iavf_print_adv_rss_cfg(struct iavf_adapter *adapter, struct iavf_adv_rss *rss,
94 		       const char *action, const char *result);
95 #endif /* _IAVF_ADV_RSS_H_ */
96