1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Header Parser definitions for Marvell PPv2 Network Controller 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Copyright (C) 2014 Marvell 6*4882a593Smuzhiyun * 7*4882a593Smuzhiyun * Marcin Wojtas <mw@semihalf.com> 8*4882a593Smuzhiyun */ 9*4882a593Smuzhiyun #ifndef _MVPP2_PRS_H_ 10*4882a593Smuzhiyun #define _MVPP2_PRS_H_ 11*4882a593Smuzhiyun 12*4882a593Smuzhiyun #include <linux/kernel.h> 13*4882a593Smuzhiyun #include <linux/netdevice.h> 14*4882a593Smuzhiyun #include <linux/platform_device.h> 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun #include "mvpp2.h" 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun /* Parser constants */ 19*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_SRAM_SIZE 256 20*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_WORDS 6 21*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_WORDS 4 22*4882a593Smuzhiyun #define MVPP2_PRS_FLOW_ID_SIZE 64 23*4882a593Smuzhiyun #define MVPP2_PRS_FLOW_ID_MASK 0x3f 24*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_ENTRY_INVALID 1 25*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_DSA_TAGGED_BIT BIT(5) 26*4882a593Smuzhiyun #define MVPP2_PRS_IPV4_HEAD 0x40 27*4882a593Smuzhiyun #define MVPP2_PRS_IPV4_HEAD_MASK 0xf0 28*4882a593Smuzhiyun #define MVPP2_PRS_IPV4_MC 0xe0 29*4882a593Smuzhiyun #define MVPP2_PRS_IPV4_MC_MASK 0xf0 30*4882a593Smuzhiyun #define MVPP2_PRS_IPV4_BC_MASK 0xff 31*4882a593Smuzhiyun #define MVPP2_PRS_IPV4_IHL 0x5 32*4882a593Smuzhiyun #define MVPP2_PRS_IPV4_IHL_MASK 0xf 33*4882a593Smuzhiyun #define MVPP2_PRS_IPV6_MC 0xff 34*4882a593Smuzhiyun #define MVPP2_PRS_IPV6_MC_MASK 0xff 35*4882a593Smuzhiyun #define MVPP2_PRS_IPV6_HOP_MASK 0xff 36*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_PROTO_MASK 0xff 37*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_PROTO_MASK_L 0x3f 38*4882a593Smuzhiyun #define MVPP2_PRS_DBL_VLANS_MAX 100 39*4882a593Smuzhiyun #define MVPP2_PRS_CAST_MASK BIT(0) 40*4882a593Smuzhiyun #define MVPP2_PRS_MCAST_VAL BIT(0) 41*4882a593Smuzhiyun #define MVPP2_PRS_UCAST_VAL 0x0 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun /* Tcam structure: 44*4882a593Smuzhiyun * - lookup ID - 4 bits 45*4882a593Smuzhiyun * - port ID - 1 byte 46*4882a593Smuzhiyun * - additional information - 1 byte 47*4882a593Smuzhiyun * - header data - 8 bytes 48*4882a593Smuzhiyun * The fields are represented by MVPP2_PRS_TCAM_DATA_REG(5)->(0). 49*4882a593Smuzhiyun */ 50*4882a593Smuzhiyun #define MVPP2_PRS_AI_BITS 8 51*4882a593Smuzhiyun #define MVPP2_PRS_AI_MASK 0xff 52*4882a593Smuzhiyun #define MVPP2_PRS_PORT_MASK 0xff 53*4882a593Smuzhiyun #define MVPP2_PRS_LU_MASK 0xf 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun /* TCAM entries in registers are accessed using 16 data bits + 16 enable bits */ 56*4882a593Smuzhiyun #define MVPP2_PRS_BYTE_TO_WORD(byte) ((byte) / 2) 57*4882a593Smuzhiyun #define MVPP2_PRS_BYTE_IN_WORD(byte) ((byte) % 2) 58*4882a593Smuzhiyun 59*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_EN(data) ((data) << 16) 60*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_AI_WORD 4 61*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_AI(ai) (ai) 62*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_AI_EN(ai) MVPP2_PRS_TCAM_EN(MVPP2_PRS_TCAM_AI(ai)) 63*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_PORT_WORD 4 64*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_PORT(p) ((p) << 8) 65*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_PORT_EN(p) MVPP2_PRS_TCAM_EN(MVPP2_PRS_TCAM_PORT(p)) 66*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_LU_WORD 5 67*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_LU(lu) (lu) 68*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_LU_EN(lu) MVPP2_PRS_TCAM_EN(MVPP2_PRS_TCAM_LU(lu)) 69*4882a593Smuzhiyun #define MVPP2_PRS_TCAM_INV_WORD 5 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun #define MVPP2_PRS_VID_TCAM_BYTE 2 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun /* TCAM range for unicast and multicast filtering. We have 25 entries per port, 74*4882a593Smuzhiyun * with 4 dedicated to UC filtering and the rest to multicast filtering. 75*4882a593Smuzhiyun * Additionnally we reserve one entry for the broadcast address, and one for 76*4882a593Smuzhiyun * each port's own address. 77*4882a593Smuzhiyun */ 78*4882a593Smuzhiyun #define MVPP2_PRS_MAC_UC_MC_FILT_MAX 25 79*4882a593Smuzhiyun #define MVPP2_PRS_MAC_RANGE_SIZE 80 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun /* Number of entries per port dedicated to UC and MC filtering */ 82*4882a593Smuzhiyun #define MVPP2_PRS_MAC_UC_FILT_MAX 4 83*4882a593Smuzhiyun #define MVPP2_PRS_MAC_MC_FILT_MAX (MVPP2_PRS_MAC_UC_MC_FILT_MAX - \ 84*4882a593Smuzhiyun MVPP2_PRS_MAC_UC_FILT_MAX) 85*4882a593Smuzhiyun 86*4882a593Smuzhiyun /* There is a TCAM range reserved for VLAN filtering entries, range size is 33 87*4882a593Smuzhiyun * 10 VLAN ID filter entries per port 88*4882a593Smuzhiyun * 1 default VLAN filter entry per port 89*4882a593Smuzhiyun * It is assumed that there are 3 ports for filter, not including loopback port 90*4882a593Smuzhiyun */ 91*4882a593Smuzhiyun #define MVPP2_PRS_VLAN_FILT_MAX 11 92*4882a593Smuzhiyun #define MVPP2_PRS_VLAN_FILT_RANGE_SIZE 33 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun #define MVPP2_PRS_VLAN_FILT_MAX_ENTRY (MVPP2_PRS_VLAN_FILT_MAX - 2) 95*4882a593Smuzhiyun #define MVPP2_PRS_VLAN_FILT_DFLT_ENTRY (MVPP2_PRS_VLAN_FILT_MAX - 1) 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun /* Tcam entries ID */ 98*4882a593Smuzhiyun #define MVPP2_PE_DROP_ALL 0 99*4882a593Smuzhiyun #define MVPP2_PE_FIRST_FREE_TID 1 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun /* MAC filtering range */ 102*4882a593Smuzhiyun #define MVPP2_PE_MAC_RANGE_END (MVPP2_PE_VID_FILT_RANGE_START - 1) 103*4882a593Smuzhiyun #define MVPP2_PE_MAC_RANGE_START (MVPP2_PE_MAC_RANGE_END - \ 104*4882a593Smuzhiyun MVPP2_PRS_MAC_RANGE_SIZE + 1) 105*4882a593Smuzhiyun /* VLAN filtering range */ 106*4882a593Smuzhiyun #define MVPP2_PE_VID_FILT_RANGE_END (MVPP2_PRS_TCAM_SRAM_SIZE - 31) 107*4882a593Smuzhiyun #define MVPP2_PE_VID_FILT_RANGE_START (MVPP2_PE_VID_FILT_RANGE_END - \ 108*4882a593Smuzhiyun MVPP2_PRS_VLAN_FILT_RANGE_SIZE + 1) 109*4882a593Smuzhiyun #define MVPP2_PE_LAST_FREE_TID (MVPP2_PE_MAC_RANGE_START - 1) 110*4882a593Smuzhiyun #define MVPP2_PE_IP6_EXT_PROTO_UN (MVPP2_PRS_TCAM_SRAM_SIZE - 30) 111*4882a593Smuzhiyun #define MVPP2_PE_IP6_ADDR_UN (MVPP2_PRS_TCAM_SRAM_SIZE - 29) 112*4882a593Smuzhiyun #define MVPP2_PE_IP4_ADDR_UN (MVPP2_PRS_TCAM_SRAM_SIZE - 28) 113*4882a593Smuzhiyun #define MVPP2_PE_LAST_DEFAULT_FLOW (MVPP2_PRS_TCAM_SRAM_SIZE - 27) 114*4882a593Smuzhiyun #define MVPP2_PE_FIRST_DEFAULT_FLOW (MVPP2_PRS_TCAM_SRAM_SIZE - 22) 115*4882a593Smuzhiyun #define MVPP2_PE_EDSA_TAGGED (MVPP2_PRS_TCAM_SRAM_SIZE - 21) 116*4882a593Smuzhiyun #define MVPP2_PE_EDSA_UNTAGGED (MVPP2_PRS_TCAM_SRAM_SIZE - 20) 117*4882a593Smuzhiyun #define MVPP2_PE_DSA_TAGGED (MVPP2_PRS_TCAM_SRAM_SIZE - 19) 118*4882a593Smuzhiyun #define MVPP2_PE_DSA_UNTAGGED (MVPP2_PRS_TCAM_SRAM_SIZE - 18) 119*4882a593Smuzhiyun #define MVPP2_PE_ETYPE_EDSA_TAGGED (MVPP2_PRS_TCAM_SRAM_SIZE - 17) 120*4882a593Smuzhiyun #define MVPP2_PE_ETYPE_EDSA_UNTAGGED (MVPP2_PRS_TCAM_SRAM_SIZE - 16) 121*4882a593Smuzhiyun #define MVPP2_PE_ETYPE_DSA_TAGGED (MVPP2_PRS_TCAM_SRAM_SIZE - 15) 122*4882a593Smuzhiyun #define MVPP2_PE_ETYPE_DSA_UNTAGGED (MVPP2_PRS_TCAM_SRAM_SIZE - 14) 123*4882a593Smuzhiyun #define MVPP2_PE_MH_DEFAULT (MVPP2_PRS_TCAM_SRAM_SIZE - 13) 124*4882a593Smuzhiyun #define MVPP2_PE_DSA_DEFAULT (MVPP2_PRS_TCAM_SRAM_SIZE - 12) 125*4882a593Smuzhiyun #define MVPP2_PE_IP6_PROTO_UN (MVPP2_PRS_TCAM_SRAM_SIZE - 11) 126*4882a593Smuzhiyun #define MVPP2_PE_IP4_PROTO_UN (MVPP2_PRS_TCAM_SRAM_SIZE - 10) 127*4882a593Smuzhiyun #define MVPP2_PE_ETH_TYPE_UN (MVPP2_PRS_TCAM_SRAM_SIZE - 9) 128*4882a593Smuzhiyun #define MVPP2_PE_VID_FLTR_DEFAULT (MVPP2_PRS_TCAM_SRAM_SIZE - 8) 129*4882a593Smuzhiyun #define MVPP2_PE_VID_EDSA_FLTR_DEFAULT (MVPP2_PRS_TCAM_SRAM_SIZE - 7) 130*4882a593Smuzhiyun #define MVPP2_PE_VLAN_DBL (MVPP2_PRS_TCAM_SRAM_SIZE - 6) 131*4882a593Smuzhiyun #define MVPP2_PE_VLAN_NONE (MVPP2_PRS_TCAM_SRAM_SIZE - 5) 132*4882a593Smuzhiyun #define MVPP2_PE_FC_DROP (MVPP2_PRS_TCAM_SRAM_SIZE - 4) 133*4882a593Smuzhiyun #define MVPP2_PE_MAC_MC_PROMISCUOUS (MVPP2_PRS_TCAM_SRAM_SIZE - 3) 134*4882a593Smuzhiyun #define MVPP2_PE_MAC_UC_PROMISCUOUS (MVPP2_PRS_TCAM_SRAM_SIZE - 2) 135*4882a593Smuzhiyun #define MVPP2_PE_MAC_NON_PROMISCUOUS (MVPP2_PRS_TCAM_SRAM_SIZE - 1) 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun #define MVPP2_PRS_VID_PORT_FIRST(port) (MVPP2_PE_VID_FILT_RANGE_START + \ 138*4882a593Smuzhiyun ((port) * MVPP2_PRS_VLAN_FILT_MAX)) 139*4882a593Smuzhiyun #define MVPP2_PRS_VID_PORT_LAST(port) (MVPP2_PRS_VID_PORT_FIRST(port) \ 140*4882a593Smuzhiyun + MVPP2_PRS_VLAN_FILT_MAX_ENTRY) 141*4882a593Smuzhiyun /* Index of default vid filter for given port */ 142*4882a593Smuzhiyun #define MVPP2_PRS_VID_PORT_DFLT(port) (MVPP2_PRS_VID_PORT_FIRST(port) \ 143*4882a593Smuzhiyun + MVPP2_PRS_VLAN_FILT_DFLT_ENTRY) 144*4882a593Smuzhiyun 145*4882a593Smuzhiyun /* Sram structure 146*4882a593Smuzhiyun * The fields are represented by MVPP2_PRS_TCAM_DATA_REG(3)->(0). 147*4882a593Smuzhiyun */ 148*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_RI_OFFS 0 149*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_RI_WORD 0 150*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_RI_CTRL_OFFS 32 151*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_RI_CTRL_WORD 1 152*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_RI_CTRL_BITS 32 153*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_SHIFT_OFFS 64 154*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_SHIFT_SIGN_BIT 72 155*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_SHIFT_MASK 0xff 156*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_UDF_OFFS 73 157*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_UDF_BITS 8 158*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_UDF_MASK 0xff 159*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_UDF_SIGN_BIT 81 160*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_UDF_TYPE_OFFS 82 161*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_UDF_TYPE_MASK 0x7 162*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_UDF_TYPE_L3 1 163*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_UDF_TYPE_L4 4 164*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_OP_SEL_SHIFT_OFFS 85 165*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_OP_SEL_SHIFT_MASK 0x3 166*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_OP_SEL_SHIFT_ADD 1 167*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_OP_SEL_SHIFT_IP4_ADD 2 168*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_OP_SEL_SHIFT_IP6_ADD 3 169*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_OP_SEL_UDF_OFFS 87 170*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_OP_SEL_UDF_BITS 2 171*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_OP_SEL_UDF_MASK 0x3 172*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_OP_SEL_UDF_ADD 0 173*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_OP_SEL_UDF_IP4_ADD 2 174*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_OP_SEL_UDF_IP6_ADD 3 175*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_OP_SEL_BASE_OFFS 89 176*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_AI_OFFS 90 177*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_AI_CTRL_OFFS 98 178*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_AI_CTRL_BITS 8 179*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_AI_MASK 0xff 180*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_NEXT_LU_OFFS 106 181*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_NEXT_LU_MASK 0xf 182*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_LU_DONE_BIT 110 183*4882a593Smuzhiyun #define MVPP2_PRS_SRAM_LU_GEN_BIT 111 184*4882a593Smuzhiyun 185*4882a593Smuzhiyun /* Sram result info bits assignment */ 186*4882a593Smuzhiyun #define MVPP2_PRS_RI_MAC_ME_MASK 0x1 187*4882a593Smuzhiyun #define MVPP2_PRS_RI_DSA_MASK 0x2 188*4882a593Smuzhiyun #define MVPP2_PRS_RI_VLAN_MASK (BIT(2) | BIT(3)) 189*4882a593Smuzhiyun #define MVPP2_PRS_RI_VLAN_NONE 0x0 190*4882a593Smuzhiyun #define MVPP2_PRS_RI_VLAN_SINGLE BIT(2) 191*4882a593Smuzhiyun #define MVPP2_PRS_RI_VLAN_DOUBLE BIT(3) 192*4882a593Smuzhiyun #define MVPP2_PRS_RI_VLAN_TRIPLE (BIT(2) | BIT(3)) 193*4882a593Smuzhiyun #define MVPP2_PRS_RI_CPU_CODE_MASK 0x70 194*4882a593Smuzhiyun #define MVPP2_PRS_RI_CPU_CODE_RX_SPEC BIT(4) 195*4882a593Smuzhiyun #define MVPP2_PRS_RI_L2_CAST_MASK (BIT(9) | BIT(10)) 196*4882a593Smuzhiyun #define MVPP2_PRS_RI_L2_UCAST 0x0 197*4882a593Smuzhiyun #define MVPP2_PRS_RI_L2_MCAST BIT(9) 198*4882a593Smuzhiyun #define MVPP2_PRS_RI_L2_BCAST BIT(10) 199*4882a593Smuzhiyun #define MVPP2_PRS_RI_PPPOE_MASK 0x800 200*4882a593Smuzhiyun #define MVPP2_PRS_RI_L3_PROTO_MASK (BIT(12) | BIT(13) | BIT(14)) 201*4882a593Smuzhiyun #define MVPP2_PRS_RI_L3_UN 0x0 202*4882a593Smuzhiyun #define MVPP2_PRS_RI_L3_IP4 BIT(12) 203*4882a593Smuzhiyun #define MVPP2_PRS_RI_L3_IP4_OPT BIT(13) 204*4882a593Smuzhiyun #define MVPP2_PRS_RI_L3_IP4_OTHER (BIT(12) | BIT(13)) 205*4882a593Smuzhiyun #define MVPP2_PRS_RI_L3_IP6 BIT(14) 206*4882a593Smuzhiyun #define MVPP2_PRS_RI_L3_IP6_EXT (BIT(12) | BIT(14)) 207*4882a593Smuzhiyun #define MVPP2_PRS_RI_L3_ARP (BIT(13) | BIT(14)) 208*4882a593Smuzhiyun #define MVPP2_PRS_RI_L3_ADDR_MASK (BIT(15) | BIT(16)) 209*4882a593Smuzhiyun #define MVPP2_PRS_RI_L3_UCAST 0x0 210*4882a593Smuzhiyun #define MVPP2_PRS_RI_L3_MCAST BIT(15) 211*4882a593Smuzhiyun #define MVPP2_PRS_RI_L3_BCAST (BIT(15) | BIT(16)) 212*4882a593Smuzhiyun #define MVPP2_PRS_RI_IP_FRAG_MASK 0x20000 213*4882a593Smuzhiyun #define MVPP2_PRS_RI_IP_FRAG_TRUE BIT(17) 214*4882a593Smuzhiyun #define MVPP2_PRS_RI_UDF3_MASK 0x300000 215*4882a593Smuzhiyun #define MVPP2_PRS_RI_UDF3_RX_SPECIAL BIT(21) 216*4882a593Smuzhiyun #define MVPP2_PRS_RI_L4_PROTO_MASK 0x1c00000 217*4882a593Smuzhiyun #define MVPP2_PRS_RI_L4_TCP BIT(22) 218*4882a593Smuzhiyun #define MVPP2_PRS_RI_L4_UDP BIT(23) 219*4882a593Smuzhiyun #define MVPP2_PRS_RI_L4_OTHER (BIT(22) | BIT(23)) 220*4882a593Smuzhiyun #define MVPP2_PRS_RI_UDF7_MASK 0x60000000 221*4882a593Smuzhiyun #define MVPP2_PRS_RI_UDF7_IP6_LITE BIT(29) 222*4882a593Smuzhiyun #define MVPP2_PRS_RI_DROP_MASK 0x80000000 223*4882a593Smuzhiyun 224*4882a593Smuzhiyun #define MVPP2_PRS_IP_MASK (MVPP2_PRS_RI_L3_PROTO_MASK | \ 225*4882a593Smuzhiyun MVPP2_PRS_RI_IP_FRAG_MASK | \ 226*4882a593Smuzhiyun MVPP2_PRS_RI_L4_PROTO_MASK) 227*4882a593Smuzhiyun 228*4882a593Smuzhiyun /* Sram additional info bits assignment */ 229*4882a593Smuzhiyun #define MVPP2_PRS_IPV4_DIP_AI_BIT BIT(0) 230*4882a593Smuzhiyun #define MVPP2_PRS_IPV6_NO_EXT_AI_BIT BIT(0) 231*4882a593Smuzhiyun #define MVPP2_PRS_IPV6_EXT_AI_BIT BIT(1) 232*4882a593Smuzhiyun #define MVPP2_PRS_IPV6_EXT_AH_AI_BIT BIT(2) 233*4882a593Smuzhiyun #define MVPP2_PRS_IPV6_EXT_AH_LEN_AI_BIT BIT(3) 234*4882a593Smuzhiyun #define MVPP2_PRS_IPV6_EXT_AH_L4_AI_BIT BIT(4) 235*4882a593Smuzhiyun #define MVPP2_PRS_SINGLE_VLAN_AI 0 236*4882a593Smuzhiyun #define MVPP2_PRS_DBL_VLAN_AI_BIT BIT(7) 237*4882a593Smuzhiyun #define MVPP2_PRS_EDSA_VID_AI_BIT BIT(0) 238*4882a593Smuzhiyun 239*4882a593Smuzhiyun /* DSA/EDSA type */ 240*4882a593Smuzhiyun #define MVPP2_PRS_TAGGED true 241*4882a593Smuzhiyun #define MVPP2_PRS_UNTAGGED false 242*4882a593Smuzhiyun #define MVPP2_PRS_EDSA true 243*4882a593Smuzhiyun #define MVPP2_PRS_DSA false 244*4882a593Smuzhiyun 245*4882a593Smuzhiyun /* MAC entries, shadow udf */ 246*4882a593Smuzhiyun enum mvpp2_prs_udf { 247*4882a593Smuzhiyun MVPP2_PRS_UDF_MAC_DEF, 248*4882a593Smuzhiyun MVPP2_PRS_UDF_MAC_RANGE, 249*4882a593Smuzhiyun MVPP2_PRS_UDF_L2_DEF, 250*4882a593Smuzhiyun MVPP2_PRS_UDF_L2_DEF_COPY, 251*4882a593Smuzhiyun MVPP2_PRS_UDF_L2_USER, 252*4882a593Smuzhiyun }; 253*4882a593Smuzhiyun 254*4882a593Smuzhiyun /* Lookup ID */ 255*4882a593Smuzhiyun enum mvpp2_prs_lookup { 256*4882a593Smuzhiyun MVPP2_PRS_LU_MH, 257*4882a593Smuzhiyun MVPP2_PRS_LU_MAC, 258*4882a593Smuzhiyun MVPP2_PRS_LU_DSA, 259*4882a593Smuzhiyun MVPP2_PRS_LU_VLAN, 260*4882a593Smuzhiyun MVPP2_PRS_LU_VID, 261*4882a593Smuzhiyun MVPP2_PRS_LU_L2, 262*4882a593Smuzhiyun MVPP2_PRS_LU_PPPOE, 263*4882a593Smuzhiyun MVPP2_PRS_LU_IP4, 264*4882a593Smuzhiyun MVPP2_PRS_LU_IP6, 265*4882a593Smuzhiyun MVPP2_PRS_LU_FLOWS, 266*4882a593Smuzhiyun MVPP2_PRS_LU_LAST, 267*4882a593Smuzhiyun }; 268*4882a593Smuzhiyun 269*4882a593Smuzhiyun struct mvpp2_prs_entry { 270*4882a593Smuzhiyun u32 index; 271*4882a593Smuzhiyun u32 tcam[MVPP2_PRS_TCAM_WORDS]; 272*4882a593Smuzhiyun u32 sram[MVPP2_PRS_SRAM_WORDS]; 273*4882a593Smuzhiyun }; 274*4882a593Smuzhiyun 275*4882a593Smuzhiyun struct mvpp2_prs_result_info { 276*4882a593Smuzhiyun u32 ri; 277*4882a593Smuzhiyun u32 ri_mask; 278*4882a593Smuzhiyun }; 279*4882a593Smuzhiyun 280*4882a593Smuzhiyun struct mvpp2_prs_shadow { 281*4882a593Smuzhiyun bool valid; 282*4882a593Smuzhiyun bool finish; 283*4882a593Smuzhiyun 284*4882a593Smuzhiyun /* Lookup ID */ 285*4882a593Smuzhiyun int lu; 286*4882a593Smuzhiyun 287*4882a593Smuzhiyun /* User defined offset */ 288*4882a593Smuzhiyun int udf; 289*4882a593Smuzhiyun 290*4882a593Smuzhiyun /* Result info */ 291*4882a593Smuzhiyun u32 ri; 292*4882a593Smuzhiyun u32 ri_mask; 293*4882a593Smuzhiyun }; 294*4882a593Smuzhiyun 295*4882a593Smuzhiyun int mvpp2_prs_default_init(struct platform_device *pdev, struct mvpp2 *priv); 296*4882a593Smuzhiyun 297*4882a593Smuzhiyun int mvpp2_prs_init_from_hw(struct mvpp2 *priv, struct mvpp2_prs_entry *pe, 298*4882a593Smuzhiyun int tid); 299*4882a593Smuzhiyun 300*4882a593Smuzhiyun unsigned int mvpp2_prs_tcam_port_map_get(struct mvpp2_prs_entry *pe); 301*4882a593Smuzhiyun 302*4882a593Smuzhiyun void mvpp2_prs_tcam_data_byte_get(struct mvpp2_prs_entry *pe, 303*4882a593Smuzhiyun unsigned int offs, unsigned char *byte, 304*4882a593Smuzhiyun unsigned char *enable); 305*4882a593Smuzhiyun 306*4882a593Smuzhiyun int mvpp2_prs_mac_da_accept(struct mvpp2_port *port, const u8 *da, bool add); 307*4882a593Smuzhiyun 308*4882a593Smuzhiyun int mvpp2_prs_tag_mode_set(struct mvpp2 *priv, int port, int type); 309*4882a593Smuzhiyun 310*4882a593Smuzhiyun int mvpp2_prs_add_flow(struct mvpp2 *priv, int flow, u32 ri, u32 ri_mask); 311*4882a593Smuzhiyun 312*4882a593Smuzhiyun int mvpp2_prs_def_flow(struct mvpp2_port *port); 313*4882a593Smuzhiyun 314*4882a593Smuzhiyun void mvpp2_prs_vid_enable_filtering(struct mvpp2_port *port); 315*4882a593Smuzhiyun 316*4882a593Smuzhiyun void mvpp2_prs_vid_disable_filtering(struct mvpp2_port *port); 317*4882a593Smuzhiyun 318*4882a593Smuzhiyun int mvpp2_prs_vid_entry_add(struct mvpp2_port *port, u16 vid); 319*4882a593Smuzhiyun 320*4882a593Smuzhiyun void mvpp2_prs_vid_entry_remove(struct mvpp2_port *port, u16 vid); 321*4882a593Smuzhiyun 322*4882a593Smuzhiyun void mvpp2_prs_vid_remove_all(struct mvpp2_port *port); 323*4882a593Smuzhiyun 324*4882a593Smuzhiyun void mvpp2_prs_mac_promisc_set(struct mvpp2 *priv, int port, 325*4882a593Smuzhiyun enum mvpp2_prs_l2_cast l2_cast, bool add); 326*4882a593Smuzhiyun 327*4882a593Smuzhiyun void mvpp2_prs_mac_del_all(struct mvpp2_port *port); 328*4882a593Smuzhiyun 329*4882a593Smuzhiyun int mvpp2_prs_update_mac_da(struct net_device *dev, const u8 *da); 330*4882a593Smuzhiyun 331*4882a593Smuzhiyun int mvpp2_prs_hits(struct mvpp2 *priv, int index); 332*4882a593Smuzhiyun 333*4882a593Smuzhiyun #endif 334