162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Header Parser definitions for Marvell PPv2 Network Controller
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2014 Marvell
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Marcin Wojtas <mw@semihalf.com>
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci#ifndef _MVPP2_PRS_H_
1062306a36Sopenharmony_ci#define _MVPP2_PRS_H_
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#include <linux/kernel.h>
1362306a36Sopenharmony_ci#include <linux/netdevice.h>
1462306a36Sopenharmony_ci#include <linux/platform_device.h>
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#include "mvpp2.h"
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci/* Parser constants */
1962306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_SRAM_SIZE	256
2062306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_WORDS		6
2162306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_WORDS		4
2262306a36Sopenharmony_ci#define MVPP2_PRS_FLOW_ID_SIZE		64
2362306a36Sopenharmony_ci#define MVPP2_PRS_FLOW_ID_MASK		0x3f
2462306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_ENTRY_INVALID	1
2562306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_DSA_TAGGED_BIT	BIT(5)
2662306a36Sopenharmony_ci#define MVPP2_PRS_IPV4_HEAD		0x40
2762306a36Sopenharmony_ci#define MVPP2_PRS_IPV4_HEAD_MASK	0xf0
2862306a36Sopenharmony_ci#define MVPP2_PRS_IPV4_MC		0xe0
2962306a36Sopenharmony_ci#define MVPP2_PRS_IPV4_MC_MASK		0xf0
3062306a36Sopenharmony_ci#define MVPP2_PRS_IPV4_BC_MASK		0xff
3162306a36Sopenharmony_ci#define MVPP2_PRS_IPV4_IHL_MIN		0x5
3262306a36Sopenharmony_ci#define MVPP2_PRS_IPV4_IHL_MAX		0xf
3362306a36Sopenharmony_ci#define MVPP2_PRS_IPV4_IHL_MASK		0xf
3462306a36Sopenharmony_ci#define MVPP2_PRS_IPV6_MC		0xff
3562306a36Sopenharmony_ci#define MVPP2_PRS_IPV6_MC_MASK		0xff
3662306a36Sopenharmony_ci#define MVPP2_PRS_IPV6_HOP_MASK		0xff
3762306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_PROTO_MASK	0xff
3862306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_PROTO_MASK_L	0x3f
3962306a36Sopenharmony_ci#define MVPP2_PRS_DBL_VLANS_MAX		100
4062306a36Sopenharmony_ci#define MVPP2_PRS_CAST_MASK		BIT(0)
4162306a36Sopenharmony_ci#define MVPP2_PRS_MCAST_VAL		BIT(0)
4262306a36Sopenharmony_ci#define MVPP2_PRS_UCAST_VAL		0x0
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci/* Tcam structure:
4562306a36Sopenharmony_ci * - lookup ID - 4 bits
4662306a36Sopenharmony_ci * - port ID - 1 byte
4762306a36Sopenharmony_ci * - additional information - 1 byte
4862306a36Sopenharmony_ci * - header data - 8 bytes
4962306a36Sopenharmony_ci * The fields are represented by MVPP2_PRS_TCAM_DATA_REG(5)->(0).
5062306a36Sopenharmony_ci */
5162306a36Sopenharmony_ci#define MVPP2_PRS_AI_BITS			8
5262306a36Sopenharmony_ci#define MVPP2_PRS_AI_MASK			0xff
5362306a36Sopenharmony_ci#define MVPP2_PRS_PORT_MASK			0xff
5462306a36Sopenharmony_ci#define MVPP2_PRS_LU_MASK			0xf
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/* TCAM entries in registers are accessed using 16 data bits + 16 enable bits */
5762306a36Sopenharmony_ci#define MVPP2_PRS_BYTE_TO_WORD(byte)	((byte) / 2)
5862306a36Sopenharmony_ci#define MVPP2_PRS_BYTE_IN_WORD(byte)	((byte) % 2)
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_EN(data)		((data) << 16)
6162306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_AI_WORD		4
6262306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_AI(ai)		(ai)
6362306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_AI_EN(ai)	MVPP2_PRS_TCAM_EN(MVPP2_PRS_TCAM_AI(ai))
6462306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_PORT_WORD	4
6562306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_PORT(p)		((p) << 8)
6662306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_PORT_EN(p)	MVPP2_PRS_TCAM_EN(MVPP2_PRS_TCAM_PORT(p))
6762306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_LU_WORD		5
6862306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_LU(lu)		(lu)
6962306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_LU_EN(lu)	MVPP2_PRS_TCAM_EN(MVPP2_PRS_TCAM_LU(lu))
7062306a36Sopenharmony_ci#define MVPP2_PRS_TCAM_INV_WORD		5
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci#define MVPP2_PRS_VID_TCAM_BYTE         2
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci/* TCAM range for unicast and multicast filtering. We have 25 entries per port,
7562306a36Sopenharmony_ci * with 4 dedicated to UC filtering and the rest to multicast filtering.
7662306a36Sopenharmony_ci * Additionnally we reserve one entry for the broadcast address, and one for
7762306a36Sopenharmony_ci * each port's own address.
7862306a36Sopenharmony_ci */
7962306a36Sopenharmony_ci#define MVPP2_PRS_MAC_UC_MC_FILT_MAX	25
8062306a36Sopenharmony_ci#define MVPP2_PRS_MAC_RANGE_SIZE	80
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci/* Number of entries per port dedicated to UC and MC filtering */
8362306a36Sopenharmony_ci#define MVPP2_PRS_MAC_UC_FILT_MAX	4
8462306a36Sopenharmony_ci#define MVPP2_PRS_MAC_MC_FILT_MAX	(MVPP2_PRS_MAC_UC_MC_FILT_MAX - \
8562306a36Sopenharmony_ci					 MVPP2_PRS_MAC_UC_FILT_MAX)
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci/* There is a TCAM range reserved for VLAN filtering entries, range size is 33
8862306a36Sopenharmony_ci * 10 VLAN ID filter entries per port
8962306a36Sopenharmony_ci * 1 default VLAN filter entry per port
9062306a36Sopenharmony_ci * It is assumed that there are 3 ports for filter, not including loopback port
9162306a36Sopenharmony_ci */
9262306a36Sopenharmony_ci#define MVPP2_PRS_VLAN_FILT_MAX		11
9362306a36Sopenharmony_ci#define MVPP2_PRS_VLAN_FILT_RANGE_SIZE	33
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci#define MVPP2_PRS_VLAN_FILT_MAX_ENTRY   (MVPP2_PRS_VLAN_FILT_MAX - 2)
9662306a36Sopenharmony_ci#define MVPP2_PRS_VLAN_FILT_DFLT_ENTRY  (MVPP2_PRS_VLAN_FILT_MAX - 1)
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ci/* Tcam entries ID */
9962306a36Sopenharmony_ci#define MVPP2_PE_DROP_ALL		0
10062306a36Sopenharmony_ci#define MVPP2_PE_FIRST_FREE_TID		1
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci/* MAC filtering range */
10362306a36Sopenharmony_ci#define MVPP2_PE_MAC_RANGE_END		(MVPP2_PE_VID_FILT_RANGE_START - 1)
10462306a36Sopenharmony_ci#define MVPP2_PE_MAC_RANGE_START	(MVPP2_PE_MAC_RANGE_END - \
10562306a36Sopenharmony_ci						MVPP2_PRS_MAC_RANGE_SIZE + 1)
10662306a36Sopenharmony_ci/* VLAN filtering range */
10762306a36Sopenharmony_ci#define MVPP2_PE_VID_FILT_RANGE_END     (MVPP2_PRS_TCAM_SRAM_SIZE - 32)
10862306a36Sopenharmony_ci#define MVPP2_PE_VID_FILT_RANGE_START   (MVPP2_PE_VID_FILT_RANGE_END - \
10962306a36Sopenharmony_ci					 MVPP2_PRS_VLAN_FILT_RANGE_SIZE + 1)
11062306a36Sopenharmony_ci#define MVPP2_PE_LAST_FREE_TID          (MVPP2_PE_MAC_RANGE_START - 1)
11162306a36Sopenharmony_ci#define MVPP2_PE_MH_SKIP_PRS		(MVPP2_PRS_TCAM_SRAM_SIZE - 31)
11262306a36Sopenharmony_ci#define MVPP2_PE_IP6_EXT_PROTO_UN	(MVPP2_PRS_TCAM_SRAM_SIZE - 30)
11362306a36Sopenharmony_ci#define MVPP2_PE_IP6_ADDR_UN		(MVPP2_PRS_TCAM_SRAM_SIZE - 29)
11462306a36Sopenharmony_ci#define MVPP2_PE_IP4_ADDR_UN		(MVPP2_PRS_TCAM_SRAM_SIZE - 28)
11562306a36Sopenharmony_ci#define MVPP2_PE_LAST_DEFAULT_FLOW	(MVPP2_PRS_TCAM_SRAM_SIZE - 27)
11662306a36Sopenharmony_ci#define MVPP2_PE_FIRST_DEFAULT_FLOW	(MVPP2_PRS_TCAM_SRAM_SIZE - 22)
11762306a36Sopenharmony_ci#define MVPP2_PE_EDSA_TAGGED		(MVPP2_PRS_TCAM_SRAM_SIZE - 21)
11862306a36Sopenharmony_ci#define MVPP2_PE_EDSA_UNTAGGED		(MVPP2_PRS_TCAM_SRAM_SIZE - 20)
11962306a36Sopenharmony_ci#define MVPP2_PE_DSA_TAGGED		(MVPP2_PRS_TCAM_SRAM_SIZE - 19)
12062306a36Sopenharmony_ci#define MVPP2_PE_DSA_UNTAGGED		(MVPP2_PRS_TCAM_SRAM_SIZE - 18)
12162306a36Sopenharmony_ci#define MVPP2_PE_ETYPE_EDSA_TAGGED	(MVPP2_PRS_TCAM_SRAM_SIZE - 17)
12262306a36Sopenharmony_ci#define MVPP2_PE_ETYPE_EDSA_UNTAGGED	(MVPP2_PRS_TCAM_SRAM_SIZE - 16)
12362306a36Sopenharmony_ci#define MVPP2_PE_ETYPE_DSA_TAGGED	(MVPP2_PRS_TCAM_SRAM_SIZE - 15)
12462306a36Sopenharmony_ci#define MVPP2_PE_ETYPE_DSA_UNTAGGED	(MVPP2_PRS_TCAM_SRAM_SIZE - 14)
12562306a36Sopenharmony_ci#define MVPP2_PE_MH_DEFAULT		(MVPP2_PRS_TCAM_SRAM_SIZE - 13)
12662306a36Sopenharmony_ci#define MVPP2_PE_DSA_DEFAULT		(MVPP2_PRS_TCAM_SRAM_SIZE - 12)
12762306a36Sopenharmony_ci#define MVPP2_PE_IP6_PROTO_UN		(MVPP2_PRS_TCAM_SRAM_SIZE - 11)
12862306a36Sopenharmony_ci#define MVPP2_PE_IP4_PROTO_UN		(MVPP2_PRS_TCAM_SRAM_SIZE - 10)
12962306a36Sopenharmony_ci#define MVPP2_PE_ETH_TYPE_UN		(MVPP2_PRS_TCAM_SRAM_SIZE - 9)
13062306a36Sopenharmony_ci#define MVPP2_PE_VID_FLTR_DEFAULT	(MVPP2_PRS_TCAM_SRAM_SIZE - 8)
13162306a36Sopenharmony_ci#define MVPP2_PE_VID_EDSA_FLTR_DEFAULT	(MVPP2_PRS_TCAM_SRAM_SIZE - 7)
13262306a36Sopenharmony_ci#define MVPP2_PE_VLAN_DBL		(MVPP2_PRS_TCAM_SRAM_SIZE - 6)
13362306a36Sopenharmony_ci#define MVPP2_PE_VLAN_NONE		(MVPP2_PRS_TCAM_SRAM_SIZE - 5)
13462306a36Sopenharmony_ci#define MVPP2_PE_FC_DROP		(MVPP2_PRS_TCAM_SRAM_SIZE - 4)
13562306a36Sopenharmony_ci#define MVPP2_PE_MAC_MC_PROMISCUOUS	(MVPP2_PRS_TCAM_SRAM_SIZE - 3)
13662306a36Sopenharmony_ci#define MVPP2_PE_MAC_UC_PROMISCUOUS	(MVPP2_PRS_TCAM_SRAM_SIZE - 2)
13762306a36Sopenharmony_ci#define MVPP2_PE_MAC_NON_PROMISCUOUS	(MVPP2_PRS_TCAM_SRAM_SIZE - 1)
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci#define MVPP2_PRS_VID_PORT_FIRST(port)	(MVPP2_PE_VID_FILT_RANGE_START + \
14062306a36Sopenharmony_ci					 ((port) * MVPP2_PRS_VLAN_FILT_MAX))
14162306a36Sopenharmony_ci#define MVPP2_PRS_VID_PORT_LAST(port)	(MVPP2_PRS_VID_PORT_FIRST(port) \
14262306a36Sopenharmony_ci					 + MVPP2_PRS_VLAN_FILT_MAX_ENTRY)
14362306a36Sopenharmony_ci/* Index of default vid filter for given port */
14462306a36Sopenharmony_ci#define MVPP2_PRS_VID_PORT_DFLT(port)	(MVPP2_PRS_VID_PORT_FIRST(port) \
14562306a36Sopenharmony_ci					 + MVPP2_PRS_VLAN_FILT_DFLT_ENTRY)
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_ci/* Sram structure
14862306a36Sopenharmony_ci * The fields are represented by MVPP2_PRS_TCAM_DATA_REG(3)->(0).
14962306a36Sopenharmony_ci */
15062306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_RI_OFFS			0
15162306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_RI_WORD			0
15262306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_RI_CTRL_OFFS		32
15362306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_RI_CTRL_WORD		1
15462306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_RI_CTRL_BITS		32
15562306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_SHIFT_OFFS		64
15662306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_SHIFT_SIGN_BIT		72
15762306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_SHIFT_MASK		0xff
15862306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_UDF_OFFS			73
15962306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_UDF_BITS			8
16062306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_UDF_MASK			0xff
16162306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_UDF_SIGN_BIT		81
16262306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_UDF_TYPE_OFFS		82
16362306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_UDF_TYPE_MASK		0x7
16462306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_UDF_TYPE_L3		1
16562306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_UDF_TYPE_L4		4
16662306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_SHIFT_OFFS	85
16762306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_SHIFT_MASK	0x3
16862306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_SHIFT_ADD		1
16962306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_SHIFT_IP4_ADD	2
17062306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_SHIFT_IP6_ADD	3
17162306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_UDF_OFFS		87
17262306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_UDF_BITS		2
17362306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_UDF_MASK		0x3
17462306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_UDF_ADD		0
17562306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_UDF_IP4_ADD	2
17662306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_UDF_IP6_ADD	3
17762306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_BASE_OFFS		89
17862306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_AI_OFFS			90
17962306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_AI_CTRL_OFFS		98
18062306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_AI_CTRL_BITS		8
18162306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_AI_MASK			0xff
18262306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_NEXT_LU_OFFS		106
18362306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_NEXT_LU_MASK		0xf
18462306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_LU_DONE_BIT		110
18562306a36Sopenharmony_ci#define MVPP2_PRS_SRAM_LU_GEN_BIT		111
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_ci/* Sram result info bits assignment */
18862306a36Sopenharmony_ci#define MVPP2_PRS_RI_MAC_ME_MASK		0x1
18962306a36Sopenharmony_ci#define MVPP2_PRS_RI_DSA_MASK			0x2
19062306a36Sopenharmony_ci#define MVPP2_PRS_RI_VLAN_MASK			(BIT(2) | BIT(3))
19162306a36Sopenharmony_ci#define MVPP2_PRS_RI_VLAN_NONE			0x0
19262306a36Sopenharmony_ci#define MVPP2_PRS_RI_VLAN_SINGLE		BIT(2)
19362306a36Sopenharmony_ci#define MVPP2_PRS_RI_VLAN_DOUBLE		BIT(3)
19462306a36Sopenharmony_ci#define MVPP2_PRS_RI_VLAN_TRIPLE		(BIT(2) | BIT(3))
19562306a36Sopenharmony_ci#define MVPP2_PRS_RI_CPU_CODE_MASK		0x70
19662306a36Sopenharmony_ci#define MVPP2_PRS_RI_CPU_CODE_RX_SPEC		BIT(4)
19762306a36Sopenharmony_ci#define MVPP2_PRS_RI_L2_CAST_MASK		(BIT(9) | BIT(10))
19862306a36Sopenharmony_ci#define MVPP2_PRS_RI_L2_UCAST			0x0
19962306a36Sopenharmony_ci#define MVPP2_PRS_RI_L2_MCAST			BIT(9)
20062306a36Sopenharmony_ci#define MVPP2_PRS_RI_L2_BCAST			BIT(10)
20162306a36Sopenharmony_ci#define MVPP2_PRS_RI_PPPOE_MASK			0x800
20262306a36Sopenharmony_ci#define MVPP2_PRS_RI_L3_PROTO_MASK		(BIT(12) | BIT(13) | BIT(14))
20362306a36Sopenharmony_ci#define MVPP2_PRS_RI_L3_UN			0x0
20462306a36Sopenharmony_ci#define MVPP2_PRS_RI_L3_IP4			BIT(12)
20562306a36Sopenharmony_ci#define MVPP2_PRS_RI_L3_IP4_OPT			BIT(13)
20662306a36Sopenharmony_ci#define MVPP2_PRS_RI_L3_IP4_OTHER		(BIT(12) | BIT(13))
20762306a36Sopenharmony_ci#define MVPP2_PRS_RI_L3_IP6			BIT(14)
20862306a36Sopenharmony_ci#define MVPP2_PRS_RI_L3_IP6_EXT			(BIT(12) | BIT(14))
20962306a36Sopenharmony_ci#define MVPP2_PRS_RI_L3_ARP			(BIT(13) | BIT(14))
21062306a36Sopenharmony_ci#define MVPP2_PRS_RI_L3_ADDR_MASK		(BIT(15) | BIT(16))
21162306a36Sopenharmony_ci#define MVPP2_PRS_RI_L3_UCAST			0x0
21262306a36Sopenharmony_ci#define MVPP2_PRS_RI_L3_MCAST			BIT(15)
21362306a36Sopenharmony_ci#define MVPP2_PRS_RI_L3_BCAST			(BIT(15) | BIT(16))
21462306a36Sopenharmony_ci#define MVPP2_PRS_RI_IP_FRAG_MASK		0x20000
21562306a36Sopenharmony_ci#define MVPP2_PRS_RI_IP_FRAG_TRUE		BIT(17)
21662306a36Sopenharmony_ci#define MVPP2_PRS_RI_UDF3_MASK			0x300000
21762306a36Sopenharmony_ci#define MVPP2_PRS_RI_UDF3_RX_SPECIAL		BIT(21)
21862306a36Sopenharmony_ci#define MVPP2_PRS_RI_L4_PROTO_MASK		0x1c00000
21962306a36Sopenharmony_ci#define MVPP2_PRS_RI_L4_TCP			BIT(22)
22062306a36Sopenharmony_ci#define MVPP2_PRS_RI_L4_UDP			BIT(23)
22162306a36Sopenharmony_ci#define MVPP2_PRS_RI_L4_OTHER			(BIT(22) | BIT(23))
22262306a36Sopenharmony_ci#define MVPP2_PRS_RI_UDF7_MASK			0x60000000
22362306a36Sopenharmony_ci#define MVPP2_PRS_RI_UDF7_IP6_LITE		BIT(29)
22462306a36Sopenharmony_ci#define MVPP2_PRS_RI_DROP_MASK			0x80000000
22562306a36Sopenharmony_ci
22662306a36Sopenharmony_ci#define MVPP2_PRS_IP_MASK			(MVPP2_PRS_RI_L3_PROTO_MASK | \
22762306a36Sopenharmony_ci						MVPP2_PRS_RI_IP_FRAG_MASK | \
22862306a36Sopenharmony_ci						MVPP2_PRS_RI_L4_PROTO_MASK)
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_ci/* Sram additional info bits assignment */
23162306a36Sopenharmony_ci#define MVPP2_PRS_IPV4_DIP_AI_BIT		BIT(0)
23262306a36Sopenharmony_ci#define MVPP2_PRS_IPV6_NO_EXT_AI_BIT		BIT(0)
23362306a36Sopenharmony_ci#define MVPP2_PRS_IPV6_EXT_AI_BIT		BIT(1)
23462306a36Sopenharmony_ci#define MVPP2_PRS_IPV6_EXT_AH_AI_BIT		BIT(2)
23562306a36Sopenharmony_ci#define MVPP2_PRS_IPV6_EXT_AH_LEN_AI_BIT	BIT(3)
23662306a36Sopenharmony_ci#define MVPP2_PRS_IPV6_EXT_AH_L4_AI_BIT		BIT(4)
23762306a36Sopenharmony_ci#define MVPP2_PRS_SINGLE_VLAN_AI		0
23862306a36Sopenharmony_ci#define MVPP2_PRS_DBL_VLAN_AI_BIT		BIT(7)
23962306a36Sopenharmony_ci#define MVPP2_PRS_EDSA_VID_AI_BIT		BIT(0)
24062306a36Sopenharmony_ci
24162306a36Sopenharmony_ci/* DSA/EDSA type */
24262306a36Sopenharmony_ci#define MVPP2_PRS_TAGGED		true
24362306a36Sopenharmony_ci#define MVPP2_PRS_UNTAGGED		false
24462306a36Sopenharmony_ci#define MVPP2_PRS_EDSA			true
24562306a36Sopenharmony_ci#define MVPP2_PRS_DSA			false
24662306a36Sopenharmony_ci
24762306a36Sopenharmony_ci/* MAC entries, shadow udf */
24862306a36Sopenharmony_cienum mvpp2_prs_udf {
24962306a36Sopenharmony_ci	MVPP2_PRS_UDF_MAC_DEF,
25062306a36Sopenharmony_ci	MVPP2_PRS_UDF_MAC_RANGE,
25162306a36Sopenharmony_ci	MVPP2_PRS_UDF_L2_DEF,
25262306a36Sopenharmony_ci	MVPP2_PRS_UDF_L2_DEF_COPY,
25362306a36Sopenharmony_ci	MVPP2_PRS_UDF_L2_USER,
25462306a36Sopenharmony_ci};
25562306a36Sopenharmony_ci
25662306a36Sopenharmony_ci/* Lookup ID */
25762306a36Sopenharmony_cienum mvpp2_prs_lookup {
25862306a36Sopenharmony_ci	MVPP2_PRS_LU_MH,
25962306a36Sopenharmony_ci	MVPP2_PRS_LU_MAC,
26062306a36Sopenharmony_ci	MVPP2_PRS_LU_DSA,
26162306a36Sopenharmony_ci	MVPP2_PRS_LU_VLAN,
26262306a36Sopenharmony_ci	MVPP2_PRS_LU_VID,
26362306a36Sopenharmony_ci	MVPP2_PRS_LU_L2,
26462306a36Sopenharmony_ci	MVPP2_PRS_LU_PPPOE,
26562306a36Sopenharmony_ci	MVPP2_PRS_LU_IP4,
26662306a36Sopenharmony_ci	MVPP2_PRS_LU_IP6,
26762306a36Sopenharmony_ci	MVPP2_PRS_LU_FLOWS,
26862306a36Sopenharmony_ci	MVPP2_PRS_LU_LAST,
26962306a36Sopenharmony_ci};
27062306a36Sopenharmony_ci
27162306a36Sopenharmony_cistruct mvpp2_prs_entry {
27262306a36Sopenharmony_ci	u32 index;
27362306a36Sopenharmony_ci	u32 tcam[MVPP2_PRS_TCAM_WORDS];
27462306a36Sopenharmony_ci	u32 sram[MVPP2_PRS_SRAM_WORDS];
27562306a36Sopenharmony_ci};
27662306a36Sopenharmony_ci
27762306a36Sopenharmony_cistruct mvpp2_prs_result_info {
27862306a36Sopenharmony_ci	u32 ri;
27962306a36Sopenharmony_ci	u32 ri_mask;
28062306a36Sopenharmony_ci};
28162306a36Sopenharmony_ci
28262306a36Sopenharmony_cistruct mvpp2_prs_shadow {
28362306a36Sopenharmony_ci	bool valid;
28462306a36Sopenharmony_ci	bool finish;
28562306a36Sopenharmony_ci
28662306a36Sopenharmony_ci	/* Lookup ID */
28762306a36Sopenharmony_ci	int lu;
28862306a36Sopenharmony_ci
28962306a36Sopenharmony_ci	/* User defined offset */
29062306a36Sopenharmony_ci	int udf;
29162306a36Sopenharmony_ci
29262306a36Sopenharmony_ci	/* Result info */
29362306a36Sopenharmony_ci	u32 ri;
29462306a36Sopenharmony_ci	u32 ri_mask;
29562306a36Sopenharmony_ci};
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ciint mvpp2_prs_default_init(struct platform_device *pdev, struct mvpp2 *priv);
29862306a36Sopenharmony_ci
29962306a36Sopenharmony_ciint mvpp2_prs_init_from_hw(struct mvpp2 *priv, struct mvpp2_prs_entry *pe,
30062306a36Sopenharmony_ci			   int tid);
30162306a36Sopenharmony_ci
30262306a36Sopenharmony_ciunsigned int mvpp2_prs_tcam_port_map_get(struct mvpp2_prs_entry *pe);
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_civoid mvpp2_prs_tcam_data_byte_get(struct mvpp2_prs_entry *pe,
30562306a36Sopenharmony_ci				  unsigned int offs, unsigned char *byte,
30662306a36Sopenharmony_ci				  unsigned char *enable);
30762306a36Sopenharmony_ci
30862306a36Sopenharmony_ciint mvpp2_prs_mac_da_accept(struct mvpp2_port *port, const u8 *da, bool add);
30962306a36Sopenharmony_ci
31062306a36Sopenharmony_ciint mvpp2_prs_tag_mode_set(struct mvpp2 *priv, int port, int type);
31162306a36Sopenharmony_ci
31262306a36Sopenharmony_ciint mvpp2_prs_add_flow(struct mvpp2 *priv, int flow, u32 ri, u32 ri_mask);
31362306a36Sopenharmony_ci
31462306a36Sopenharmony_ciint mvpp2_prs_def_flow(struct mvpp2_port *port);
31562306a36Sopenharmony_ci
31662306a36Sopenharmony_civoid mvpp2_prs_vid_enable_filtering(struct mvpp2_port *port);
31762306a36Sopenharmony_ci
31862306a36Sopenharmony_civoid mvpp2_prs_vid_disable_filtering(struct mvpp2_port *port);
31962306a36Sopenharmony_ci
32062306a36Sopenharmony_ciint mvpp2_prs_vid_entry_add(struct mvpp2_port *port, u16 vid);
32162306a36Sopenharmony_ci
32262306a36Sopenharmony_civoid mvpp2_prs_vid_entry_remove(struct mvpp2_port *port, u16 vid);
32362306a36Sopenharmony_ci
32462306a36Sopenharmony_civoid mvpp2_prs_vid_remove_all(struct mvpp2_port *port);
32562306a36Sopenharmony_ci
32662306a36Sopenharmony_civoid mvpp2_prs_mac_promisc_set(struct mvpp2 *priv, int port,
32762306a36Sopenharmony_ci			       enum mvpp2_prs_l2_cast l2_cast, bool add);
32862306a36Sopenharmony_ci
32962306a36Sopenharmony_civoid mvpp2_prs_mac_del_all(struct mvpp2_port *port);
33062306a36Sopenharmony_ci
33162306a36Sopenharmony_ciint mvpp2_prs_update_mac_da(struct net_device *dev, const u8 *da);
33262306a36Sopenharmony_ci
33362306a36Sopenharmony_ciint mvpp2_prs_hits(struct mvpp2 *priv, int index);
33462306a36Sopenharmony_ci
33562306a36Sopenharmony_ci#endif
336