18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Header Parser definitions for Marvell PPv2 Network Controller 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2014 Marvell 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Marcin Wojtas <mw@semihalf.com> 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci#ifndef _MVPP2_PRS_H_ 108c2ecf20Sopenharmony_ci#define _MVPP2_PRS_H_ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/kernel.h> 138c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 148c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include "mvpp2.h" 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* Parser constants */ 198c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_SRAM_SIZE 256 208c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_WORDS 6 218c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_WORDS 4 228c2ecf20Sopenharmony_ci#define MVPP2_PRS_FLOW_ID_SIZE 64 238c2ecf20Sopenharmony_ci#define MVPP2_PRS_FLOW_ID_MASK 0x3f 248c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_ENTRY_INVALID 1 258c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_DSA_TAGGED_BIT BIT(5) 268c2ecf20Sopenharmony_ci#define MVPP2_PRS_IPV4_HEAD 0x40 278c2ecf20Sopenharmony_ci#define MVPP2_PRS_IPV4_HEAD_MASK 0xf0 288c2ecf20Sopenharmony_ci#define MVPP2_PRS_IPV4_MC 0xe0 298c2ecf20Sopenharmony_ci#define MVPP2_PRS_IPV4_MC_MASK 0xf0 308c2ecf20Sopenharmony_ci#define MVPP2_PRS_IPV4_BC_MASK 0xff 318c2ecf20Sopenharmony_ci#define MVPP2_PRS_IPV4_IHL 0x5 328c2ecf20Sopenharmony_ci#define MVPP2_PRS_IPV4_IHL_MASK 0xf 338c2ecf20Sopenharmony_ci#define MVPP2_PRS_IPV6_MC 0xff 348c2ecf20Sopenharmony_ci#define MVPP2_PRS_IPV6_MC_MASK 0xff 358c2ecf20Sopenharmony_ci#define MVPP2_PRS_IPV6_HOP_MASK 0xff 368c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_PROTO_MASK 0xff 378c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_PROTO_MASK_L 0x3f 388c2ecf20Sopenharmony_ci#define MVPP2_PRS_DBL_VLANS_MAX 100 398c2ecf20Sopenharmony_ci#define MVPP2_PRS_CAST_MASK BIT(0) 408c2ecf20Sopenharmony_ci#define MVPP2_PRS_MCAST_VAL BIT(0) 418c2ecf20Sopenharmony_ci#define MVPP2_PRS_UCAST_VAL 0x0 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* Tcam structure: 448c2ecf20Sopenharmony_ci * - lookup ID - 4 bits 458c2ecf20Sopenharmony_ci * - port ID - 1 byte 468c2ecf20Sopenharmony_ci * - additional information - 1 byte 478c2ecf20Sopenharmony_ci * - header data - 8 bytes 488c2ecf20Sopenharmony_ci * The fields are represented by MVPP2_PRS_TCAM_DATA_REG(5)->(0). 498c2ecf20Sopenharmony_ci */ 508c2ecf20Sopenharmony_ci#define MVPP2_PRS_AI_BITS 8 518c2ecf20Sopenharmony_ci#define MVPP2_PRS_AI_MASK 0xff 528c2ecf20Sopenharmony_ci#define MVPP2_PRS_PORT_MASK 0xff 538c2ecf20Sopenharmony_ci#define MVPP2_PRS_LU_MASK 0xf 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci/* TCAM entries in registers are accessed using 16 data bits + 16 enable bits */ 568c2ecf20Sopenharmony_ci#define MVPP2_PRS_BYTE_TO_WORD(byte) ((byte) / 2) 578c2ecf20Sopenharmony_ci#define MVPP2_PRS_BYTE_IN_WORD(byte) ((byte) % 2) 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_EN(data) ((data) << 16) 608c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_AI_WORD 4 618c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_AI(ai) (ai) 628c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_AI_EN(ai) MVPP2_PRS_TCAM_EN(MVPP2_PRS_TCAM_AI(ai)) 638c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_PORT_WORD 4 648c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_PORT(p) ((p) << 8) 658c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_PORT_EN(p) MVPP2_PRS_TCAM_EN(MVPP2_PRS_TCAM_PORT(p)) 668c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_LU_WORD 5 678c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_LU(lu) (lu) 688c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_LU_EN(lu) MVPP2_PRS_TCAM_EN(MVPP2_PRS_TCAM_LU(lu)) 698c2ecf20Sopenharmony_ci#define MVPP2_PRS_TCAM_INV_WORD 5 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci#define MVPP2_PRS_VID_TCAM_BYTE 2 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci/* TCAM range for unicast and multicast filtering. We have 25 entries per port, 748c2ecf20Sopenharmony_ci * with 4 dedicated to UC filtering and the rest to multicast filtering. 758c2ecf20Sopenharmony_ci * Additionnally we reserve one entry for the broadcast address, and one for 768c2ecf20Sopenharmony_ci * each port's own address. 778c2ecf20Sopenharmony_ci */ 788c2ecf20Sopenharmony_ci#define MVPP2_PRS_MAC_UC_MC_FILT_MAX 25 798c2ecf20Sopenharmony_ci#define MVPP2_PRS_MAC_RANGE_SIZE 80 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci/* Number of entries per port dedicated to UC and MC filtering */ 828c2ecf20Sopenharmony_ci#define MVPP2_PRS_MAC_UC_FILT_MAX 4 838c2ecf20Sopenharmony_ci#define MVPP2_PRS_MAC_MC_FILT_MAX (MVPP2_PRS_MAC_UC_MC_FILT_MAX - \ 848c2ecf20Sopenharmony_ci MVPP2_PRS_MAC_UC_FILT_MAX) 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci/* There is a TCAM range reserved for VLAN filtering entries, range size is 33 878c2ecf20Sopenharmony_ci * 10 VLAN ID filter entries per port 888c2ecf20Sopenharmony_ci * 1 default VLAN filter entry per port 898c2ecf20Sopenharmony_ci * It is assumed that there are 3 ports for filter, not including loopback port 908c2ecf20Sopenharmony_ci */ 918c2ecf20Sopenharmony_ci#define MVPP2_PRS_VLAN_FILT_MAX 11 928c2ecf20Sopenharmony_ci#define MVPP2_PRS_VLAN_FILT_RANGE_SIZE 33 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci#define MVPP2_PRS_VLAN_FILT_MAX_ENTRY (MVPP2_PRS_VLAN_FILT_MAX - 2) 958c2ecf20Sopenharmony_ci#define MVPP2_PRS_VLAN_FILT_DFLT_ENTRY (MVPP2_PRS_VLAN_FILT_MAX - 1) 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci/* Tcam entries ID */ 988c2ecf20Sopenharmony_ci#define MVPP2_PE_DROP_ALL 0 998c2ecf20Sopenharmony_ci#define MVPP2_PE_FIRST_FREE_TID 1 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci/* MAC filtering range */ 1028c2ecf20Sopenharmony_ci#define MVPP2_PE_MAC_RANGE_END (MVPP2_PE_VID_FILT_RANGE_START - 1) 1038c2ecf20Sopenharmony_ci#define MVPP2_PE_MAC_RANGE_START (MVPP2_PE_MAC_RANGE_END - \ 1048c2ecf20Sopenharmony_ci MVPP2_PRS_MAC_RANGE_SIZE + 1) 1058c2ecf20Sopenharmony_ci/* VLAN filtering range */ 1068c2ecf20Sopenharmony_ci#define MVPP2_PE_VID_FILT_RANGE_END (MVPP2_PRS_TCAM_SRAM_SIZE - 31) 1078c2ecf20Sopenharmony_ci#define MVPP2_PE_VID_FILT_RANGE_START (MVPP2_PE_VID_FILT_RANGE_END - \ 1088c2ecf20Sopenharmony_ci MVPP2_PRS_VLAN_FILT_RANGE_SIZE + 1) 1098c2ecf20Sopenharmony_ci#define MVPP2_PE_LAST_FREE_TID (MVPP2_PE_MAC_RANGE_START - 1) 1108c2ecf20Sopenharmony_ci#define MVPP2_PE_IP6_EXT_PROTO_UN (MVPP2_PRS_TCAM_SRAM_SIZE - 30) 1118c2ecf20Sopenharmony_ci#define MVPP2_PE_IP6_ADDR_UN (MVPP2_PRS_TCAM_SRAM_SIZE - 29) 1128c2ecf20Sopenharmony_ci#define MVPP2_PE_IP4_ADDR_UN (MVPP2_PRS_TCAM_SRAM_SIZE - 28) 1138c2ecf20Sopenharmony_ci#define MVPP2_PE_LAST_DEFAULT_FLOW (MVPP2_PRS_TCAM_SRAM_SIZE - 27) 1148c2ecf20Sopenharmony_ci#define MVPP2_PE_FIRST_DEFAULT_FLOW (MVPP2_PRS_TCAM_SRAM_SIZE - 22) 1158c2ecf20Sopenharmony_ci#define MVPP2_PE_EDSA_TAGGED (MVPP2_PRS_TCAM_SRAM_SIZE - 21) 1168c2ecf20Sopenharmony_ci#define MVPP2_PE_EDSA_UNTAGGED (MVPP2_PRS_TCAM_SRAM_SIZE - 20) 1178c2ecf20Sopenharmony_ci#define MVPP2_PE_DSA_TAGGED (MVPP2_PRS_TCAM_SRAM_SIZE - 19) 1188c2ecf20Sopenharmony_ci#define MVPP2_PE_DSA_UNTAGGED (MVPP2_PRS_TCAM_SRAM_SIZE - 18) 1198c2ecf20Sopenharmony_ci#define MVPP2_PE_ETYPE_EDSA_TAGGED (MVPP2_PRS_TCAM_SRAM_SIZE - 17) 1208c2ecf20Sopenharmony_ci#define MVPP2_PE_ETYPE_EDSA_UNTAGGED (MVPP2_PRS_TCAM_SRAM_SIZE - 16) 1218c2ecf20Sopenharmony_ci#define MVPP2_PE_ETYPE_DSA_TAGGED (MVPP2_PRS_TCAM_SRAM_SIZE - 15) 1228c2ecf20Sopenharmony_ci#define MVPP2_PE_ETYPE_DSA_UNTAGGED (MVPP2_PRS_TCAM_SRAM_SIZE - 14) 1238c2ecf20Sopenharmony_ci#define MVPP2_PE_MH_DEFAULT (MVPP2_PRS_TCAM_SRAM_SIZE - 13) 1248c2ecf20Sopenharmony_ci#define MVPP2_PE_DSA_DEFAULT (MVPP2_PRS_TCAM_SRAM_SIZE - 12) 1258c2ecf20Sopenharmony_ci#define MVPP2_PE_IP6_PROTO_UN (MVPP2_PRS_TCAM_SRAM_SIZE - 11) 1268c2ecf20Sopenharmony_ci#define MVPP2_PE_IP4_PROTO_UN (MVPP2_PRS_TCAM_SRAM_SIZE - 10) 1278c2ecf20Sopenharmony_ci#define MVPP2_PE_ETH_TYPE_UN (MVPP2_PRS_TCAM_SRAM_SIZE - 9) 1288c2ecf20Sopenharmony_ci#define MVPP2_PE_VID_FLTR_DEFAULT (MVPP2_PRS_TCAM_SRAM_SIZE - 8) 1298c2ecf20Sopenharmony_ci#define MVPP2_PE_VID_EDSA_FLTR_DEFAULT (MVPP2_PRS_TCAM_SRAM_SIZE - 7) 1308c2ecf20Sopenharmony_ci#define MVPP2_PE_VLAN_DBL (MVPP2_PRS_TCAM_SRAM_SIZE - 6) 1318c2ecf20Sopenharmony_ci#define MVPP2_PE_VLAN_NONE (MVPP2_PRS_TCAM_SRAM_SIZE - 5) 1328c2ecf20Sopenharmony_ci#define MVPP2_PE_FC_DROP (MVPP2_PRS_TCAM_SRAM_SIZE - 4) 1338c2ecf20Sopenharmony_ci#define MVPP2_PE_MAC_MC_PROMISCUOUS (MVPP2_PRS_TCAM_SRAM_SIZE - 3) 1348c2ecf20Sopenharmony_ci#define MVPP2_PE_MAC_UC_PROMISCUOUS (MVPP2_PRS_TCAM_SRAM_SIZE - 2) 1358c2ecf20Sopenharmony_ci#define MVPP2_PE_MAC_NON_PROMISCUOUS (MVPP2_PRS_TCAM_SRAM_SIZE - 1) 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci#define MVPP2_PRS_VID_PORT_FIRST(port) (MVPP2_PE_VID_FILT_RANGE_START + \ 1388c2ecf20Sopenharmony_ci ((port) * MVPP2_PRS_VLAN_FILT_MAX)) 1398c2ecf20Sopenharmony_ci#define MVPP2_PRS_VID_PORT_LAST(port) (MVPP2_PRS_VID_PORT_FIRST(port) \ 1408c2ecf20Sopenharmony_ci + MVPP2_PRS_VLAN_FILT_MAX_ENTRY) 1418c2ecf20Sopenharmony_ci/* Index of default vid filter for given port */ 1428c2ecf20Sopenharmony_ci#define MVPP2_PRS_VID_PORT_DFLT(port) (MVPP2_PRS_VID_PORT_FIRST(port) \ 1438c2ecf20Sopenharmony_ci + MVPP2_PRS_VLAN_FILT_DFLT_ENTRY) 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci/* Sram structure 1468c2ecf20Sopenharmony_ci * The fields are represented by MVPP2_PRS_TCAM_DATA_REG(3)->(0). 1478c2ecf20Sopenharmony_ci */ 1488c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_RI_OFFS 0 1498c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_RI_WORD 0 1508c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_RI_CTRL_OFFS 32 1518c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_RI_CTRL_WORD 1 1528c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_RI_CTRL_BITS 32 1538c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_SHIFT_OFFS 64 1548c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_SHIFT_SIGN_BIT 72 1558c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_SHIFT_MASK 0xff 1568c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_UDF_OFFS 73 1578c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_UDF_BITS 8 1588c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_UDF_MASK 0xff 1598c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_UDF_SIGN_BIT 81 1608c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_UDF_TYPE_OFFS 82 1618c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_UDF_TYPE_MASK 0x7 1628c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_UDF_TYPE_L3 1 1638c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_UDF_TYPE_L4 4 1648c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_SHIFT_OFFS 85 1658c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_SHIFT_MASK 0x3 1668c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_SHIFT_ADD 1 1678c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_SHIFT_IP4_ADD 2 1688c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_SHIFT_IP6_ADD 3 1698c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_UDF_OFFS 87 1708c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_UDF_BITS 2 1718c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_UDF_MASK 0x3 1728c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_UDF_ADD 0 1738c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_UDF_IP4_ADD 2 1748c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_UDF_IP6_ADD 3 1758c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_OP_SEL_BASE_OFFS 89 1768c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_AI_OFFS 90 1778c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_AI_CTRL_OFFS 98 1788c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_AI_CTRL_BITS 8 1798c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_AI_MASK 0xff 1808c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_NEXT_LU_OFFS 106 1818c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_NEXT_LU_MASK 0xf 1828c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_LU_DONE_BIT 110 1838c2ecf20Sopenharmony_ci#define MVPP2_PRS_SRAM_LU_GEN_BIT 111 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci/* Sram result info bits assignment */ 1868c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_MAC_ME_MASK 0x1 1878c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_DSA_MASK 0x2 1888c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_VLAN_MASK (BIT(2) | BIT(3)) 1898c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_VLAN_NONE 0x0 1908c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_VLAN_SINGLE BIT(2) 1918c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_VLAN_DOUBLE BIT(3) 1928c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_VLAN_TRIPLE (BIT(2) | BIT(3)) 1938c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_CPU_CODE_MASK 0x70 1948c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_CPU_CODE_RX_SPEC BIT(4) 1958c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L2_CAST_MASK (BIT(9) | BIT(10)) 1968c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L2_UCAST 0x0 1978c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L2_MCAST BIT(9) 1988c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L2_BCAST BIT(10) 1998c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_PPPOE_MASK 0x800 2008c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L3_PROTO_MASK (BIT(12) | BIT(13) | BIT(14)) 2018c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L3_UN 0x0 2028c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L3_IP4 BIT(12) 2038c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L3_IP4_OPT BIT(13) 2048c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L3_IP4_OTHER (BIT(12) | BIT(13)) 2058c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L3_IP6 BIT(14) 2068c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L3_IP6_EXT (BIT(12) | BIT(14)) 2078c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L3_ARP (BIT(13) | BIT(14)) 2088c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L3_ADDR_MASK (BIT(15) | BIT(16)) 2098c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L3_UCAST 0x0 2108c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L3_MCAST BIT(15) 2118c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L3_BCAST (BIT(15) | BIT(16)) 2128c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_IP_FRAG_MASK 0x20000 2138c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_IP_FRAG_TRUE BIT(17) 2148c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_UDF3_MASK 0x300000 2158c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_UDF3_RX_SPECIAL BIT(21) 2168c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L4_PROTO_MASK 0x1c00000 2178c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L4_TCP BIT(22) 2188c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L4_UDP BIT(23) 2198c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_L4_OTHER (BIT(22) | BIT(23)) 2208c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_UDF7_MASK 0x60000000 2218c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_UDF7_IP6_LITE BIT(29) 2228c2ecf20Sopenharmony_ci#define MVPP2_PRS_RI_DROP_MASK 0x80000000 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci#define MVPP2_PRS_IP_MASK (MVPP2_PRS_RI_L3_PROTO_MASK | \ 2258c2ecf20Sopenharmony_ci MVPP2_PRS_RI_IP_FRAG_MASK | \ 2268c2ecf20Sopenharmony_ci MVPP2_PRS_RI_L4_PROTO_MASK) 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci/* Sram additional info bits assignment */ 2298c2ecf20Sopenharmony_ci#define MVPP2_PRS_IPV4_DIP_AI_BIT BIT(0) 2308c2ecf20Sopenharmony_ci#define MVPP2_PRS_IPV6_NO_EXT_AI_BIT BIT(0) 2318c2ecf20Sopenharmony_ci#define MVPP2_PRS_IPV6_EXT_AI_BIT BIT(1) 2328c2ecf20Sopenharmony_ci#define MVPP2_PRS_IPV6_EXT_AH_AI_BIT BIT(2) 2338c2ecf20Sopenharmony_ci#define MVPP2_PRS_IPV6_EXT_AH_LEN_AI_BIT BIT(3) 2348c2ecf20Sopenharmony_ci#define MVPP2_PRS_IPV6_EXT_AH_L4_AI_BIT BIT(4) 2358c2ecf20Sopenharmony_ci#define MVPP2_PRS_SINGLE_VLAN_AI 0 2368c2ecf20Sopenharmony_ci#define MVPP2_PRS_DBL_VLAN_AI_BIT BIT(7) 2378c2ecf20Sopenharmony_ci#define MVPP2_PRS_EDSA_VID_AI_BIT BIT(0) 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci/* DSA/EDSA type */ 2408c2ecf20Sopenharmony_ci#define MVPP2_PRS_TAGGED true 2418c2ecf20Sopenharmony_ci#define MVPP2_PRS_UNTAGGED false 2428c2ecf20Sopenharmony_ci#define MVPP2_PRS_EDSA true 2438c2ecf20Sopenharmony_ci#define MVPP2_PRS_DSA false 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci/* MAC entries, shadow udf */ 2468c2ecf20Sopenharmony_cienum mvpp2_prs_udf { 2478c2ecf20Sopenharmony_ci MVPP2_PRS_UDF_MAC_DEF, 2488c2ecf20Sopenharmony_ci MVPP2_PRS_UDF_MAC_RANGE, 2498c2ecf20Sopenharmony_ci MVPP2_PRS_UDF_L2_DEF, 2508c2ecf20Sopenharmony_ci MVPP2_PRS_UDF_L2_DEF_COPY, 2518c2ecf20Sopenharmony_ci MVPP2_PRS_UDF_L2_USER, 2528c2ecf20Sopenharmony_ci}; 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci/* Lookup ID */ 2558c2ecf20Sopenharmony_cienum mvpp2_prs_lookup { 2568c2ecf20Sopenharmony_ci MVPP2_PRS_LU_MH, 2578c2ecf20Sopenharmony_ci MVPP2_PRS_LU_MAC, 2588c2ecf20Sopenharmony_ci MVPP2_PRS_LU_DSA, 2598c2ecf20Sopenharmony_ci MVPP2_PRS_LU_VLAN, 2608c2ecf20Sopenharmony_ci MVPP2_PRS_LU_VID, 2618c2ecf20Sopenharmony_ci MVPP2_PRS_LU_L2, 2628c2ecf20Sopenharmony_ci MVPP2_PRS_LU_PPPOE, 2638c2ecf20Sopenharmony_ci MVPP2_PRS_LU_IP4, 2648c2ecf20Sopenharmony_ci MVPP2_PRS_LU_IP6, 2658c2ecf20Sopenharmony_ci MVPP2_PRS_LU_FLOWS, 2668c2ecf20Sopenharmony_ci MVPP2_PRS_LU_LAST, 2678c2ecf20Sopenharmony_ci}; 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_cistruct mvpp2_prs_entry { 2708c2ecf20Sopenharmony_ci u32 index; 2718c2ecf20Sopenharmony_ci u32 tcam[MVPP2_PRS_TCAM_WORDS]; 2728c2ecf20Sopenharmony_ci u32 sram[MVPP2_PRS_SRAM_WORDS]; 2738c2ecf20Sopenharmony_ci}; 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_cistruct mvpp2_prs_result_info { 2768c2ecf20Sopenharmony_ci u32 ri; 2778c2ecf20Sopenharmony_ci u32 ri_mask; 2788c2ecf20Sopenharmony_ci}; 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_cistruct mvpp2_prs_shadow { 2818c2ecf20Sopenharmony_ci bool valid; 2828c2ecf20Sopenharmony_ci bool finish; 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci /* Lookup ID */ 2858c2ecf20Sopenharmony_ci int lu; 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_ci /* User defined offset */ 2888c2ecf20Sopenharmony_ci int udf; 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci /* Result info */ 2918c2ecf20Sopenharmony_ci u32 ri; 2928c2ecf20Sopenharmony_ci u32 ri_mask; 2938c2ecf20Sopenharmony_ci}; 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ciint mvpp2_prs_default_init(struct platform_device *pdev, struct mvpp2 *priv); 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_ciint mvpp2_prs_init_from_hw(struct mvpp2 *priv, struct mvpp2_prs_entry *pe, 2988c2ecf20Sopenharmony_ci int tid); 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ciunsigned int mvpp2_prs_tcam_port_map_get(struct mvpp2_prs_entry *pe); 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_civoid mvpp2_prs_tcam_data_byte_get(struct mvpp2_prs_entry *pe, 3038c2ecf20Sopenharmony_ci unsigned int offs, unsigned char *byte, 3048c2ecf20Sopenharmony_ci unsigned char *enable); 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ciint mvpp2_prs_mac_da_accept(struct mvpp2_port *port, const u8 *da, bool add); 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ciint mvpp2_prs_tag_mode_set(struct mvpp2 *priv, int port, int type); 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ciint mvpp2_prs_add_flow(struct mvpp2 *priv, int flow, u32 ri, u32 ri_mask); 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ciint mvpp2_prs_def_flow(struct mvpp2_port *port); 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_civoid mvpp2_prs_vid_enable_filtering(struct mvpp2_port *port); 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_civoid mvpp2_prs_vid_disable_filtering(struct mvpp2_port *port); 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ciint mvpp2_prs_vid_entry_add(struct mvpp2_port *port, u16 vid); 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_civoid mvpp2_prs_vid_entry_remove(struct mvpp2_port *port, u16 vid); 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_civoid mvpp2_prs_vid_remove_all(struct mvpp2_port *port); 3238c2ecf20Sopenharmony_ci 3248c2ecf20Sopenharmony_civoid mvpp2_prs_mac_promisc_set(struct mvpp2 *priv, int port, 3258c2ecf20Sopenharmony_ci enum mvpp2_prs_l2_cast l2_cast, bool add); 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_civoid mvpp2_prs_mac_del_all(struct mvpp2_port *port); 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ciint mvpp2_prs_update_mac_da(struct net_device *dev, const u8 *da); 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ciint mvpp2_prs_hits(struct mvpp2 *priv, int index); 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci#endif 334