162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/* Copyright (c) 2019, Intel Corporation. */
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci#ifndef _ICE_FLOW_H_
562306a36Sopenharmony_ci#define _ICE_FLOW_H_
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#include "ice_flex_type.h"
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#define ICE_FLOW_ENTRY_HANDLE_INVAL	0
1062306a36Sopenharmony_ci#define ICE_FLOW_FLD_OFF_INVAL		0xffff
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci/* Generate flow hash field from flow field type(s) */
1362306a36Sopenharmony_ci#define ICE_FLOW_HASH_ETH	\
1462306a36Sopenharmony_ci	(BIT_ULL(ICE_FLOW_FIELD_IDX_ETH_DA) | \
1562306a36Sopenharmony_ci	 BIT_ULL(ICE_FLOW_FIELD_IDX_ETH_SA))
1662306a36Sopenharmony_ci#define ICE_FLOW_HASH_IPV4	\
1762306a36Sopenharmony_ci	(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA) | \
1862306a36Sopenharmony_ci	 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA))
1962306a36Sopenharmony_ci#define ICE_FLOW_HASH_IPV6	\
2062306a36Sopenharmony_ci	(BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA) | \
2162306a36Sopenharmony_ci	 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA))
2262306a36Sopenharmony_ci#define ICE_FLOW_HASH_TCP_PORT	\
2362306a36Sopenharmony_ci	(BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT) | \
2462306a36Sopenharmony_ci	 BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT))
2562306a36Sopenharmony_ci#define ICE_FLOW_HASH_UDP_PORT	\
2662306a36Sopenharmony_ci	(BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT) | \
2762306a36Sopenharmony_ci	 BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT))
2862306a36Sopenharmony_ci#define ICE_FLOW_HASH_SCTP_PORT	\
2962306a36Sopenharmony_ci	(BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT) | \
3062306a36Sopenharmony_ci	 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT))
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci#define ICE_HASH_INVALID	0
3362306a36Sopenharmony_ci#define ICE_HASH_TCP_IPV4	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_TCP_PORT)
3462306a36Sopenharmony_ci#define ICE_HASH_TCP_IPV6	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_TCP_PORT)
3562306a36Sopenharmony_ci#define ICE_HASH_UDP_IPV4	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_UDP_PORT)
3662306a36Sopenharmony_ci#define ICE_HASH_UDP_IPV6	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_UDP_PORT)
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci#define ICE_FLOW_HASH_GTP_TEID \
3962306a36Sopenharmony_ci	(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPC_TEID))
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#define ICE_FLOW_HASH_GTP_IPV4_TEID \
4262306a36Sopenharmony_ci	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_TEID)
4362306a36Sopenharmony_ci#define ICE_FLOW_HASH_GTP_IPV6_TEID \
4462306a36Sopenharmony_ci	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_TEID)
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci#define ICE_FLOW_HASH_GTP_U_TEID \
4762306a36Sopenharmony_ci	(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_IP_TEID))
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci#define ICE_FLOW_HASH_GTP_U_IPV4_TEID \
5062306a36Sopenharmony_ci	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_U_TEID)
5162306a36Sopenharmony_ci#define ICE_FLOW_HASH_GTP_U_IPV6_TEID \
5262306a36Sopenharmony_ci	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_U_TEID)
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci#define ICE_FLOW_HASH_GTP_U_EH_TEID \
5562306a36Sopenharmony_ci	(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_EH_TEID))
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci#define ICE_FLOW_HASH_GTP_U_EH_QFI \
5862306a36Sopenharmony_ci	(BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_EH_QFI))
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci#define ICE_FLOW_HASH_GTP_U_IPV4_EH \
6162306a36Sopenharmony_ci	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_GTP_U_EH_TEID | \
6262306a36Sopenharmony_ci	 ICE_FLOW_HASH_GTP_U_EH_QFI)
6362306a36Sopenharmony_ci#define ICE_FLOW_HASH_GTP_U_IPV6_EH \
6462306a36Sopenharmony_ci	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_GTP_U_EH_TEID | \
6562306a36Sopenharmony_ci	 ICE_FLOW_HASH_GTP_U_EH_QFI)
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci#define ICE_FLOW_HASH_PPPOE_SESS_ID \
6862306a36Sopenharmony_ci	(BIT_ULL(ICE_FLOW_FIELD_IDX_PPPOE_SESS_ID))
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci#define ICE_FLOW_HASH_PPPOE_SESS_ID_ETH \
7162306a36Sopenharmony_ci	(ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_PPPOE_SESS_ID)
7262306a36Sopenharmony_ci#define ICE_FLOW_HASH_PPPOE_TCP_ID \
7362306a36Sopenharmony_ci	(ICE_FLOW_HASH_TCP_PORT | ICE_FLOW_HASH_PPPOE_SESS_ID)
7462306a36Sopenharmony_ci#define ICE_FLOW_HASH_PPPOE_UDP_ID \
7562306a36Sopenharmony_ci	(ICE_FLOW_HASH_UDP_PORT | ICE_FLOW_HASH_PPPOE_SESS_ID)
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci#define ICE_FLOW_HASH_PFCP_SEID \
7862306a36Sopenharmony_ci	(BIT_ULL(ICE_FLOW_FIELD_IDX_PFCP_SEID))
7962306a36Sopenharmony_ci#define ICE_FLOW_HASH_PFCP_IPV4_SEID \
8062306a36Sopenharmony_ci	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_PFCP_SEID)
8162306a36Sopenharmony_ci#define ICE_FLOW_HASH_PFCP_IPV6_SEID \
8262306a36Sopenharmony_ci	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_PFCP_SEID)
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci#define ICE_FLOW_HASH_L2TPV3_SESS_ID \
8562306a36Sopenharmony_ci	(BIT_ULL(ICE_FLOW_FIELD_IDX_L2TPV3_SESS_ID))
8662306a36Sopenharmony_ci#define ICE_FLOW_HASH_L2TPV3_IPV4_SESS_ID \
8762306a36Sopenharmony_ci	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_L2TPV3_SESS_ID)
8862306a36Sopenharmony_ci#define ICE_FLOW_HASH_L2TPV3_IPV6_SESS_ID \
8962306a36Sopenharmony_ci	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_L2TPV3_SESS_ID)
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci#define ICE_FLOW_HASH_ESP_SPI \
9262306a36Sopenharmony_ci	(BIT_ULL(ICE_FLOW_FIELD_IDX_ESP_SPI))
9362306a36Sopenharmony_ci#define ICE_FLOW_HASH_ESP_IPV4_SPI \
9462306a36Sopenharmony_ci	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_ESP_SPI)
9562306a36Sopenharmony_ci#define ICE_FLOW_HASH_ESP_IPV6_SPI \
9662306a36Sopenharmony_ci	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_ESP_SPI)
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ci#define ICE_FLOW_HASH_AH_SPI \
9962306a36Sopenharmony_ci	(BIT_ULL(ICE_FLOW_FIELD_IDX_AH_SPI))
10062306a36Sopenharmony_ci#define ICE_FLOW_HASH_AH_IPV4_SPI \
10162306a36Sopenharmony_ci	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_AH_SPI)
10262306a36Sopenharmony_ci#define ICE_FLOW_HASH_AH_IPV6_SPI \
10362306a36Sopenharmony_ci	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_AH_SPI)
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci#define ICE_FLOW_HASH_NAT_T_ESP_SPI \
10662306a36Sopenharmony_ci	(BIT_ULL(ICE_FLOW_FIELD_IDX_NAT_T_ESP_SPI))
10762306a36Sopenharmony_ci#define ICE_FLOW_HASH_NAT_T_ESP_IPV4_SPI \
10862306a36Sopenharmony_ci	(ICE_FLOW_HASH_IPV4 | ICE_FLOW_HASH_NAT_T_ESP_SPI)
10962306a36Sopenharmony_ci#define ICE_FLOW_HASH_NAT_T_ESP_IPV6_SPI \
11062306a36Sopenharmony_ci	(ICE_FLOW_HASH_IPV6 | ICE_FLOW_HASH_NAT_T_ESP_SPI)
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci/* Protocol header fields within a packet segment. A segment consists of one or
11362306a36Sopenharmony_ci * more protocol headers that make up a logical group of protocol headers. Each
11462306a36Sopenharmony_ci * logical group of protocol headers encapsulates or is encapsulated using/by
11562306a36Sopenharmony_ci * tunneling or encapsulation protocols for network virtualization such as GRE,
11662306a36Sopenharmony_ci * VxLAN, etc.
11762306a36Sopenharmony_ci */
11862306a36Sopenharmony_cienum ice_flow_seg_hdr {
11962306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_NONE		= 0x00000000,
12062306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_ETH		= 0x00000001,
12162306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_VLAN		= 0x00000002,
12262306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_IPV4		= 0x00000004,
12362306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_IPV6		= 0x00000008,
12462306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_ARP		= 0x00000010,
12562306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_ICMP		= 0x00000020,
12662306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_TCP		= 0x00000040,
12762306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_UDP		= 0x00000080,
12862306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_SCTP		= 0x00000100,
12962306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_GRE		= 0x00000200,
13062306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_GTPC		= 0x00000400,
13162306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_GTPC_TEID	= 0x00000800,
13262306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_GTPU_IP	= 0x00001000,
13362306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_GTPU_EH	= 0x00002000,
13462306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_GTPU_DWN	= 0x00004000,
13562306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_GTPU_UP	= 0x00008000,
13662306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_PPPOE		= 0x00010000,
13762306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_PFCP_NODE	= 0x00020000,
13862306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_PFCP_SESSION	= 0x00040000,
13962306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_L2TPV3		= 0x00080000,
14062306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_ESP		= 0x00100000,
14162306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_AH		= 0x00200000,
14262306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_NAT_T_ESP	= 0x00400000,
14362306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_ETH_NON_IP	= 0x00800000,
14462306a36Sopenharmony_ci	/* The following is an additive bit for ICE_FLOW_SEG_HDR_IPV4 and
14562306a36Sopenharmony_ci	 * ICE_FLOW_SEG_HDR_IPV6 which include the IPV4 other PTYPEs
14662306a36Sopenharmony_ci	 */
14762306a36Sopenharmony_ci	ICE_FLOW_SEG_HDR_IPV_OTHER      = 0x20000000,
14862306a36Sopenharmony_ci};
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci/* These segments all have the same PTYPES, but are otherwise distinguished by
15162306a36Sopenharmony_ci * the value of the gtp_eh_pdu and gtp_eh_pdu_link flags:
15262306a36Sopenharmony_ci *
15362306a36Sopenharmony_ci *                                gtp_eh_pdu     gtp_eh_pdu_link
15462306a36Sopenharmony_ci * ICE_FLOW_SEG_HDR_GTPU_IP           0              0
15562306a36Sopenharmony_ci * ICE_FLOW_SEG_HDR_GTPU_EH           1              don't care
15662306a36Sopenharmony_ci * ICE_FLOW_SEG_HDR_GTPU_DWN          1              0
15762306a36Sopenharmony_ci * ICE_FLOW_SEG_HDR_GTPU_UP           1              1
15862306a36Sopenharmony_ci */
15962306a36Sopenharmony_ci#define ICE_FLOW_SEG_HDR_GTPU (ICE_FLOW_SEG_HDR_GTPU_IP | \
16062306a36Sopenharmony_ci			       ICE_FLOW_SEG_HDR_GTPU_EH | \
16162306a36Sopenharmony_ci			       ICE_FLOW_SEG_HDR_GTPU_DWN | \
16262306a36Sopenharmony_ci			       ICE_FLOW_SEG_HDR_GTPU_UP)
16362306a36Sopenharmony_ci#define ICE_FLOW_SEG_HDR_PFCP (ICE_FLOW_SEG_HDR_PFCP_NODE | \
16462306a36Sopenharmony_ci			       ICE_FLOW_SEG_HDR_PFCP_SESSION)
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_cienum ice_flow_field {
16762306a36Sopenharmony_ci	/* L2 */
16862306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_ETH_DA,
16962306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_ETH_SA,
17062306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_S_VLAN,
17162306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_C_VLAN,
17262306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_ETH_TYPE,
17362306a36Sopenharmony_ci	/* L3 */
17462306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_IPV4_DSCP,
17562306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_IPV6_DSCP,
17662306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_IPV4_TTL,
17762306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_IPV4_PROT,
17862306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_IPV6_TTL,
17962306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_IPV6_PROT,
18062306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_IPV4_SA,
18162306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_IPV4_DA,
18262306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_IPV6_SA,
18362306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_IPV6_DA,
18462306a36Sopenharmony_ci	/* L4 */
18562306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_TCP_SRC_PORT,
18662306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_TCP_DST_PORT,
18762306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_UDP_SRC_PORT,
18862306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_UDP_DST_PORT,
18962306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT,
19062306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_SCTP_DST_PORT,
19162306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_TCP_FLAGS,
19262306a36Sopenharmony_ci	/* ARP */
19362306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_ARP_SIP,
19462306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_ARP_DIP,
19562306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_ARP_SHA,
19662306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_ARP_DHA,
19762306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_ARP_OP,
19862306a36Sopenharmony_ci	/* ICMP */
19962306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_ICMP_TYPE,
20062306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_ICMP_CODE,
20162306a36Sopenharmony_ci	/* GRE */
20262306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_GRE_KEYID,
20362306a36Sopenharmony_ci	/* GTPC_TEID */
20462306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_GTPC_TEID,
20562306a36Sopenharmony_ci	/* GTPU_IP */
20662306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_GTPU_IP_TEID,
20762306a36Sopenharmony_ci	/* GTPU_EH */
20862306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_GTPU_EH_TEID,
20962306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_GTPU_EH_QFI,
21062306a36Sopenharmony_ci	/* GTPU_UP */
21162306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_GTPU_UP_TEID,
21262306a36Sopenharmony_ci	/* GTPU_DWN */
21362306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_GTPU_DWN_TEID,
21462306a36Sopenharmony_ci	/* PPPoE */
21562306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_PPPOE_SESS_ID,
21662306a36Sopenharmony_ci	/* PFCP */
21762306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_PFCP_SEID,
21862306a36Sopenharmony_ci	/* L2TPv3 */
21962306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_L2TPV3_SESS_ID,
22062306a36Sopenharmony_ci	/* ESP */
22162306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_ESP_SPI,
22262306a36Sopenharmony_ci	/* AH */
22362306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_AH_SPI,
22462306a36Sopenharmony_ci	/* NAT_T ESP */
22562306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_NAT_T_ESP_SPI,
22662306a36Sopenharmony_ci	 /* The total number of enums must not exceed 64 */
22762306a36Sopenharmony_ci	ICE_FLOW_FIELD_IDX_MAX
22862306a36Sopenharmony_ci};
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_ci/* Flow headers and fields for AVF support */
23162306a36Sopenharmony_cienum ice_flow_avf_hdr_field {
23262306a36Sopenharmony_ci	/* Values 0 - 28 are reserved for future use */
23362306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_INVALID		= 0,
23462306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_UNICAST_IPV4_UDP	= 29,
23562306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_MULTICAST_IPV4_UDP,
23662306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_IPV4_UDP,
23762306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_IPV4_TCP_SYN_NO_ACK,
23862306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_IPV4_TCP,
23962306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_IPV4_SCTP,
24062306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_IPV4_OTHER,
24162306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_FRAG_IPV4,
24262306a36Sopenharmony_ci	/* Values 37-38 are reserved */
24362306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_UNICAST_IPV6_UDP	= 39,
24462306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_MULTICAST_IPV6_UDP,
24562306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_IPV6_UDP,
24662306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_IPV6_TCP_SYN_NO_ACK,
24762306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_IPV6_TCP,
24862306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_IPV6_SCTP,
24962306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_IPV6_OTHER,
25062306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_FRAG_IPV6,
25162306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_RSVD47,
25262306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_FCOE_OX,
25362306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_FCOE_RX,
25462306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_FCOE_OTHER,
25562306a36Sopenharmony_ci	/* Values 51-62 are reserved */
25662306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_L2_PAYLOAD		= 63,
25762306a36Sopenharmony_ci	ICE_AVF_FLOW_FIELD_MAX
25862306a36Sopenharmony_ci};
25962306a36Sopenharmony_ci
26062306a36Sopenharmony_ci/* Supported RSS offloads  This macro is defined to support
26162306a36Sopenharmony_ci * VIRTCHNL_OP_GET_RSS_HENA_CAPS ops. PF driver sends the RSS hardware
26262306a36Sopenharmony_ci * capabilities to the caller of this ops.
26362306a36Sopenharmony_ci */
26462306a36Sopenharmony_ci#define ICE_DEFAULT_RSS_HENA ( \
26562306a36Sopenharmony_ci	BIT_ULL(ICE_AVF_FLOW_FIELD_IPV4_UDP) | \
26662306a36Sopenharmony_ci	BIT_ULL(ICE_AVF_FLOW_FIELD_IPV4_SCTP) | \
26762306a36Sopenharmony_ci	BIT_ULL(ICE_AVF_FLOW_FIELD_IPV4_TCP) | \
26862306a36Sopenharmony_ci	BIT_ULL(ICE_AVF_FLOW_FIELD_IPV4_OTHER) | \
26962306a36Sopenharmony_ci	BIT_ULL(ICE_AVF_FLOW_FIELD_FRAG_IPV4) | \
27062306a36Sopenharmony_ci	BIT_ULL(ICE_AVF_FLOW_FIELD_IPV6_UDP) | \
27162306a36Sopenharmony_ci	BIT_ULL(ICE_AVF_FLOW_FIELD_IPV6_TCP) | \
27262306a36Sopenharmony_ci	BIT_ULL(ICE_AVF_FLOW_FIELD_IPV6_SCTP) | \
27362306a36Sopenharmony_ci	BIT_ULL(ICE_AVF_FLOW_FIELD_IPV6_OTHER) | \
27462306a36Sopenharmony_ci	BIT_ULL(ICE_AVF_FLOW_FIELD_FRAG_IPV6) | \
27562306a36Sopenharmony_ci	BIT_ULL(ICE_AVF_FLOW_FIELD_IPV4_TCP_SYN_NO_ACK) | \
27662306a36Sopenharmony_ci	BIT_ULL(ICE_AVF_FLOW_FIELD_UNICAST_IPV4_UDP) | \
27762306a36Sopenharmony_ci	BIT_ULL(ICE_AVF_FLOW_FIELD_MULTICAST_IPV4_UDP) | \
27862306a36Sopenharmony_ci	BIT_ULL(ICE_AVF_FLOW_FIELD_IPV6_TCP_SYN_NO_ACK) | \
27962306a36Sopenharmony_ci	BIT_ULL(ICE_AVF_FLOW_FIELD_UNICAST_IPV6_UDP) | \
28062306a36Sopenharmony_ci	BIT_ULL(ICE_AVF_FLOW_FIELD_MULTICAST_IPV6_UDP))
28162306a36Sopenharmony_ci
28262306a36Sopenharmony_cienum ice_flow_dir {
28362306a36Sopenharmony_ci	ICE_FLOW_RX		= 0x02,
28462306a36Sopenharmony_ci};
28562306a36Sopenharmony_ci
28662306a36Sopenharmony_cienum ice_flow_priority {
28762306a36Sopenharmony_ci	ICE_FLOW_PRIO_LOW,
28862306a36Sopenharmony_ci	ICE_FLOW_PRIO_NORMAL,
28962306a36Sopenharmony_ci	ICE_FLOW_PRIO_HIGH
29062306a36Sopenharmony_ci};
29162306a36Sopenharmony_ci
29262306a36Sopenharmony_ci#define ICE_FLOW_SEG_MAX		2
29362306a36Sopenharmony_ci#define ICE_FLOW_SEG_RAW_FLD_MAX	2
29462306a36Sopenharmony_ci#define ICE_FLOW_FV_EXTRACT_SZ		2
29562306a36Sopenharmony_ci
29662306a36Sopenharmony_ci#define ICE_FLOW_SET_HDRS(seg, val)	((seg)->hdrs |= (u32)(val))
29762306a36Sopenharmony_ci
29862306a36Sopenharmony_cistruct ice_flow_seg_xtrct {
29962306a36Sopenharmony_ci	u8 prot_id;	/* Protocol ID of extracted header field */
30062306a36Sopenharmony_ci	u16 off;	/* Starting offset of the field in header in bytes */
30162306a36Sopenharmony_ci	u8 idx;		/* Index of FV entry used */
30262306a36Sopenharmony_ci	u8 disp;	/* Displacement of field in bits fr. FV entry's start */
30362306a36Sopenharmony_ci	u16 mask;	/* Mask for field */
30462306a36Sopenharmony_ci};
30562306a36Sopenharmony_ci
30662306a36Sopenharmony_cienum ice_flow_fld_match_type {
30762306a36Sopenharmony_ci	ICE_FLOW_FLD_TYPE_REG,		/* Value, mask */
30862306a36Sopenharmony_ci	ICE_FLOW_FLD_TYPE_RANGE,	/* Value, mask, last (upper bound) */
30962306a36Sopenharmony_ci	ICE_FLOW_FLD_TYPE_PREFIX,	/* IP address, prefix, size of prefix */
31062306a36Sopenharmony_ci	ICE_FLOW_FLD_TYPE_SIZE,		/* Value, mask, size of match */
31162306a36Sopenharmony_ci};
31262306a36Sopenharmony_ci
31362306a36Sopenharmony_cistruct ice_flow_fld_loc {
31462306a36Sopenharmony_ci	/* Describe offsets of field information relative to the beginning of
31562306a36Sopenharmony_ci	 * input buffer provided when adding flow entries.
31662306a36Sopenharmony_ci	 */
31762306a36Sopenharmony_ci	u16 val;	/* Offset where the value is located */
31862306a36Sopenharmony_ci	u16 mask;	/* Offset where the mask/prefix value is located */
31962306a36Sopenharmony_ci	u16 last;	/* Length or offset where the upper value is located */
32062306a36Sopenharmony_ci};
32162306a36Sopenharmony_ci
32262306a36Sopenharmony_cistruct ice_flow_fld_info {
32362306a36Sopenharmony_ci	enum ice_flow_fld_match_type type;
32462306a36Sopenharmony_ci	/* Location where to retrieve data from an input buffer */
32562306a36Sopenharmony_ci	struct ice_flow_fld_loc src;
32662306a36Sopenharmony_ci	/* Location where to put the data into the final entry buffer */
32762306a36Sopenharmony_ci	struct ice_flow_fld_loc entry;
32862306a36Sopenharmony_ci	struct ice_flow_seg_xtrct xtrct;
32962306a36Sopenharmony_ci};
33062306a36Sopenharmony_ci
33162306a36Sopenharmony_cistruct ice_flow_seg_fld_raw {
33262306a36Sopenharmony_ci	struct ice_flow_fld_info info;
33362306a36Sopenharmony_ci	u16 off;	/* Offset from the start of the segment */
33462306a36Sopenharmony_ci};
33562306a36Sopenharmony_ci
33662306a36Sopenharmony_cistruct ice_flow_seg_info {
33762306a36Sopenharmony_ci	u32 hdrs;	/* Bitmask indicating protocol headers present */
33862306a36Sopenharmony_ci	u64 match;	/* Bitmask indicating header fields to be matched */
33962306a36Sopenharmony_ci	u64 range;	/* Bitmask indicating header fields matched as ranges */
34062306a36Sopenharmony_ci
34162306a36Sopenharmony_ci	struct ice_flow_fld_info fields[ICE_FLOW_FIELD_IDX_MAX];
34262306a36Sopenharmony_ci
34362306a36Sopenharmony_ci	u8 raws_cnt;	/* Number of raw fields to be matched */
34462306a36Sopenharmony_ci	struct ice_flow_seg_fld_raw raws[ICE_FLOW_SEG_RAW_FLD_MAX];
34562306a36Sopenharmony_ci};
34662306a36Sopenharmony_ci
34762306a36Sopenharmony_ci/* This structure describes a flow entry, and is tracked only in this file */
34862306a36Sopenharmony_cistruct ice_flow_entry {
34962306a36Sopenharmony_ci	struct list_head l_entry;
35062306a36Sopenharmony_ci
35162306a36Sopenharmony_ci	u64 id;
35262306a36Sopenharmony_ci	struct ice_flow_prof *prof;
35362306a36Sopenharmony_ci	/* Flow entry's content */
35462306a36Sopenharmony_ci	void *entry;
35562306a36Sopenharmony_ci	enum ice_flow_priority priority;
35662306a36Sopenharmony_ci	u16 vsi_handle;
35762306a36Sopenharmony_ci	u16 entry_sz;
35862306a36Sopenharmony_ci};
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_ci#define ICE_FLOW_ENTRY_HNDL(e)	((u64)(uintptr_t)e)
36162306a36Sopenharmony_ci#define ICE_FLOW_ENTRY_PTR(h)	((struct ice_flow_entry *)(uintptr_t)(h))
36262306a36Sopenharmony_ci
36362306a36Sopenharmony_cistruct ice_flow_prof {
36462306a36Sopenharmony_ci	struct list_head l_entry;
36562306a36Sopenharmony_ci
36662306a36Sopenharmony_ci	u64 id;
36762306a36Sopenharmony_ci	enum ice_flow_dir dir;
36862306a36Sopenharmony_ci	u8 segs_cnt;
36962306a36Sopenharmony_ci
37062306a36Sopenharmony_ci	/* Keep track of flow entries associated with this flow profile */
37162306a36Sopenharmony_ci	struct mutex entries_lock;
37262306a36Sopenharmony_ci	struct list_head entries;
37362306a36Sopenharmony_ci
37462306a36Sopenharmony_ci	struct ice_flow_seg_info segs[ICE_FLOW_SEG_MAX];
37562306a36Sopenharmony_ci
37662306a36Sopenharmony_ci	/* software VSI handles referenced by this flow profile */
37762306a36Sopenharmony_ci	DECLARE_BITMAP(vsis, ICE_MAX_VSI);
37862306a36Sopenharmony_ci};
37962306a36Sopenharmony_ci
38062306a36Sopenharmony_cistruct ice_rss_cfg {
38162306a36Sopenharmony_ci	struct list_head l_entry;
38262306a36Sopenharmony_ci	/* bitmap of VSIs added to the RSS entry */
38362306a36Sopenharmony_ci	DECLARE_BITMAP(vsis, ICE_MAX_VSI);
38462306a36Sopenharmony_ci	u64 hashed_flds;
38562306a36Sopenharmony_ci	u32 packet_hdr;
38662306a36Sopenharmony_ci};
38762306a36Sopenharmony_ci
38862306a36Sopenharmony_ciint
38962306a36Sopenharmony_ciice_flow_add_prof(struct ice_hw *hw, enum ice_block blk, enum ice_flow_dir dir,
39062306a36Sopenharmony_ci		  u64 prof_id, struct ice_flow_seg_info *segs, u8 segs_cnt,
39162306a36Sopenharmony_ci		  struct ice_flow_prof **prof);
39262306a36Sopenharmony_ciint ice_flow_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 prof_id);
39362306a36Sopenharmony_ciint
39462306a36Sopenharmony_ciice_flow_add_entry(struct ice_hw *hw, enum ice_block blk, u64 prof_id,
39562306a36Sopenharmony_ci		   u64 entry_id, u16 vsi, enum ice_flow_priority prio,
39662306a36Sopenharmony_ci		   void *data, u64 *entry_h);
39762306a36Sopenharmony_ciint ice_flow_rem_entry(struct ice_hw *hw, enum ice_block blk, u64 entry_h);
39862306a36Sopenharmony_civoid
39962306a36Sopenharmony_ciice_flow_set_fld(struct ice_flow_seg_info *seg, enum ice_flow_field fld,
40062306a36Sopenharmony_ci		 u16 val_loc, u16 mask_loc, u16 last_loc, bool range);
40162306a36Sopenharmony_civoid
40262306a36Sopenharmony_ciice_flow_add_fld_raw(struct ice_flow_seg_info *seg, u16 off, u8 len,
40362306a36Sopenharmony_ci		     u16 val_loc, u16 mask_loc);
40462306a36Sopenharmony_ciint ice_flow_rem_vsi_prof(struct ice_hw *hw, u16 vsi_handle, u64 prof_id);
40562306a36Sopenharmony_civoid ice_rem_vsi_rss_list(struct ice_hw *hw, u16 vsi_handle);
40662306a36Sopenharmony_ciint ice_replay_rss_cfg(struct ice_hw *hw, u16 vsi_handle);
40762306a36Sopenharmony_ciint ice_add_avf_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u64 hashed_flds);
40862306a36Sopenharmony_ciint ice_rem_vsi_rss_cfg(struct ice_hw *hw, u16 vsi_handle);
40962306a36Sopenharmony_ciint
41062306a36Sopenharmony_ciice_add_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u64 hashed_flds,
41162306a36Sopenharmony_ci		u32 addl_hdrs);
41262306a36Sopenharmony_ciint
41362306a36Sopenharmony_ciice_rem_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u64 hashed_flds,
41462306a36Sopenharmony_ci		u32 addl_hdrs);
41562306a36Sopenharmony_ciu64 ice_get_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u32 hdrs);
41662306a36Sopenharmony_ci#endif /* _ICE_FLOW_H_ */
417