162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* Copyright (C) 2020 Felix Fietkau <nbd@nbd.name> */ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci#ifndef __MTK_PPE_H 562306a36Sopenharmony_ci#define __MTK_PPE_H 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#include <linux/kernel.h> 862306a36Sopenharmony_ci#include <linux/bitfield.h> 962306a36Sopenharmony_ci#include <linux/rhashtable.h> 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#define MTK_PPE_ENTRIES_SHIFT 3 1262306a36Sopenharmony_ci#define MTK_PPE_ENTRIES (1024 << MTK_PPE_ENTRIES_SHIFT) 1362306a36Sopenharmony_ci#define MTK_PPE_HASH_MASK (MTK_PPE_ENTRIES - 1) 1462306a36Sopenharmony_ci#define MTK_PPE_WAIT_TIMEOUT_US 1000000 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci#define MTK_FOE_IB1_UNBIND_TIMESTAMP GENMASK(7, 0) 1762306a36Sopenharmony_ci#define MTK_FOE_IB1_UNBIND_PACKETS GENMASK(23, 8) 1862306a36Sopenharmony_ci#define MTK_FOE_IB1_UNBIND_PREBIND BIT(24) 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#define MTK_FOE_IB1_BIND_TIMESTAMP GENMASK(14, 0) 2162306a36Sopenharmony_ci#define MTK_FOE_IB1_BIND_KEEPALIVE BIT(15) 2262306a36Sopenharmony_ci#define MTK_FOE_IB1_BIND_VLAN_LAYER GENMASK(18, 16) 2362306a36Sopenharmony_ci#define MTK_FOE_IB1_BIND_PPPOE BIT(19) 2462306a36Sopenharmony_ci#define MTK_FOE_IB1_BIND_VLAN_TAG BIT(20) 2562306a36Sopenharmony_ci#define MTK_FOE_IB1_BIND_PKT_SAMPLE BIT(21) 2662306a36Sopenharmony_ci#define MTK_FOE_IB1_BIND_CACHE BIT(22) 2762306a36Sopenharmony_ci#define MTK_FOE_IB1_BIND_TUNNEL_DECAP BIT(23) 2862306a36Sopenharmony_ci#define MTK_FOE_IB1_BIND_TTL BIT(24) 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define MTK_FOE_IB1_PACKET_TYPE GENMASK(27, 25) 3162306a36Sopenharmony_ci#define MTK_FOE_IB1_STATE GENMASK(29, 28) 3262306a36Sopenharmony_ci#define MTK_FOE_IB1_UDP BIT(30) 3362306a36Sopenharmony_ci#define MTK_FOE_IB1_STATIC BIT(31) 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/* CONFIG_MEDIATEK_NETSYS_V2 */ 3662306a36Sopenharmony_ci#define MTK_FOE_IB1_BIND_TIMESTAMP_V2 GENMASK(7, 0) 3762306a36Sopenharmony_ci#define MTK_FOE_IB1_BIND_VLAN_LAYER_V2 GENMASK(16, 14) 3862306a36Sopenharmony_ci#define MTK_FOE_IB1_BIND_PPPOE_V2 BIT(17) 3962306a36Sopenharmony_ci#define MTK_FOE_IB1_BIND_VLAN_TAG_V2 BIT(18) 4062306a36Sopenharmony_ci#define MTK_FOE_IB1_BIND_CACHE_V2 BIT(20) 4162306a36Sopenharmony_ci#define MTK_FOE_IB1_BIND_TTL_V2 BIT(22) 4262306a36Sopenharmony_ci#define MTK_FOE_IB1_PACKET_TYPE_V2 GENMASK(27, 23) 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_cienum { 4562306a36Sopenharmony_ci MTK_PPE_PKT_TYPE_IPV4_HNAPT = 0, 4662306a36Sopenharmony_ci MTK_PPE_PKT_TYPE_IPV4_ROUTE = 1, 4762306a36Sopenharmony_ci MTK_PPE_PKT_TYPE_BRIDGE = 2, 4862306a36Sopenharmony_ci MTK_PPE_PKT_TYPE_IPV4_DSLITE = 3, 4962306a36Sopenharmony_ci MTK_PPE_PKT_TYPE_IPV6_ROUTE_3T = 4, 5062306a36Sopenharmony_ci MTK_PPE_PKT_TYPE_IPV6_ROUTE_5T = 5, 5162306a36Sopenharmony_ci MTK_PPE_PKT_TYPE_IPV6_6RD = 7, 5262306a36Sopenharmony_ci}; 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci#define MTK_FOE_IB2_QID GENMASK(3, 0) 5562306a36Sopenharmony_ci#define MTK_FOE_IB2_PSE_QOS BIT(4) 5662306a36Sopenharmony_ci#define MTK_FOE_IB2_DEST_PORT GENMASK(7, 5) 5762306a36Sopenharmony_ci#define MTK_FOE_IB2_MULTICAST BIT(8) 5862306a36Sopenharmony_ci#define MTK_FOE_IB2_MIB_CNT BIT(10) 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci#define MTK_FOE_IB2_WDMA_QID2 GENMASK(13, 12) 6162306a36Sopenharmony_ci#define MTK_FOE_IB2_MIB_CNT_V2 BIT(15) 6262306a36Sopenharmony_ci#define MTK_FOE_IB2_WDMA_DEVIDX BIT(16) 6362306a36Sopenharmony_ci#define MTK_FOE_IB2_WDMA_WINFO BIT(17) 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci#define MTK_FOE_IB2_PORT_MG GENMASK(17, 12) 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci#define MTK_FOE_IB2_RX_IDX GENMASK(18, 17) 6862306a36Sopenharmony_ci#define MTK_FOE_IB2_PORT_AG GENMASK(23, 18) 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci#define MTK_FOE_IB2_DSCP GENMASK(31, 24) 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/* CONFIG_MEDIATEK_NETSYS_V2 */ 7362306a36Sopenharmony_ci#define MTK_FOE_IB2_QID_V2 GENMASK(6, 0) 7462306a36Sopenharmony_ci#define MTK_FOE_IB2_PORT_MG_V2 BIT(7) 7562306a36Sopenharmony_ci#define MTK_FOE_IB2_PSE_QOS_V2 BIT(8) 7662306a36Sopenharmony_ci#define MTK_FOE_IB2_DEST_PORT_V2 GENMASK(12, 9) 7762306a36Sopenharmony_ci#define MTK_FOE_IB2_MULTICAST_V2 BIT(13) 7862306a36Sopenharmony_ci#define MTK_FOE_IB2_WDMA_WINFO_V2 BIT(19) 7962306a36Sopenharmony_ci#define MTK_FOE_IB2_PORT_AG_V2 GENMASK(23, 20) 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci#define MTK_FOE_VLAN2_WINFO_BSS GENMASK(5, 0) 8262306a36Sopenharmony_ci#define MTK_FOE_VLAN2_WINFO_WCID GENMASK(13, 6) 8362306a36Sopenharmony_ci#define MTK_FOE_VLAN2_WINFO_RING GENMASK(15, 14) 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci#define MTK_FOE_WINFO_BSS GENMASK(5, 0) 8662306a36Sopenharmony_ci#define MTK_FOE_WINFO_WCID GENMASK(15, 6) 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci#define MTK_FOE_WINFO_BSS_V3 GENMASK(23, 16) 8962306a36Sopenharmony_ci#define MTK_FOE_WINFO_WCID_V3 GENMASK(15, 0) 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci#define MTK_FOE_WINFO_PAO_USR_INFO GENMASK(15, 0) 9262306a36Sopenharmony_ci#define MTK_FOE_WINFO_PAO_TID GENMASK(19, 16) 9362306a36Sopenharmony_ci#define MTK_FOE_WINFO_PAO_IS_FIXEDRATE BIT(20) 9462306a36Sopenharmony_ci#define MTK_FOE_WINFO_PAO_IS_PRIOR BIT(21) 9562306a36Sopenharmony_ci#define MTK_FOE_WINFO_PAO_IS_SP BIT(22) 9662306a36Sopenharmony_ci#define MTK_FOE_WINFO_PAO_HF BIT(23) 9762306a36Sopenharmony_ci#define MTK_FOE_WINFO_PAO_AMSDU_EN BIT(24) 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_cienum { 10062306a36Sopenharmony_ci MTK_FOE_STATE_INVALID, 10162306a36Sopenharmony_ci MTK_FOE_STATE_UNBIND, 10262306a36Sopenharmony_ci MTK_FOE_STATE_BIND, 10362306a36Sopenharmony_ci MTK_FOE_STATE_FIN 10462306a36Sopenharmony_ci}; 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_cistruct mtk_foe_mac_info { 10762306a36Sopenharmony_ci u16 vlan1; 10862306a36Sopenharmony_ci u16 etype; 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci u32 dest_mac_hi; 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci u16 vlan2; 11362306a36Sopenharmony_ci u16 dest_mac_lo; 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci u32 src_mac_hi; 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci u16 pppoe_id; 11862306a36Sopenharmony_ci u16 src_mac_lo; 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci /* netsys_v2 */ 12162306a36Sopenharmony_ci u16 minfo; 12262306a36Sopenharmony_ci u16 winfo; 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci /* netsys_v3 */ 12562306a36Sopenharmony_ci u32 w3info; 12662306a36Sopenharmony_ci u32 wpao; 12762306a36Sopenharmony_ci}; 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci/* software-only entry type */ 13062306a36Sopenharmony_cistruct mtk_foe_bridge { 13162306a36Sopenharmony_ci u8 dest_mac[ETH_ALEN]; 13262306a36Sopenharmony_ci u8 src_mac[ETH_ALEN]; 13362306a36Sopenharmony_ci u16 vlan; 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ci struct {} key_end; 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci u32 ib2; 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci struct mtk_foe_mac_info l2; 14062306a36Sopenharmony_ci}; 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_cistruct mtk_ipv4_tuple { 14362306a36Sopenharmony_ci u32 src_ip; 14462306a36Sopenharmony_ci u32 dest_ip; 14562306a36Sopenharmony_ci union { 14662306a36Sopenharmony_ci struct { 14762306a36Sopenharmony_ci u16 dest_port; 14862306a36Sopenharmony_ci u16 src_port; 14962306a36Sopenharmony_ci }; 15062306a36Sopenharmony_ci struct { 15162306a36Sopenharmony_ci u8 protocol; 15262306a36Sopenharmony_ci u8 _pad[3]; /* fill with 0xa5a5a5 */ 15362306a36Sopenharmony_ci }; 15462306a36Sopenharmony_ci u32 ports; 15562306a36Sopenharmony_ci }; 15662306a36Sopenharmony_ci}; 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_cistruct mtk_foe_ipv4 { 15962306a36Sopenharmony_ci struct mtk_ipv4_tuple orig; 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci u32 ib2; 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_ci struct mtk_ipv4_tuple new; 16462306a36Sopenharmony_ci 16562306a36Sopenharmony_ci u16 timestamp; 16662306a36Sopenharmony_ci u16 _rsv0[3]; 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci u32 udf_tsid; 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci struct mtk_foe_mac_info l2; 17162306a36Sopenharmony_ci}; 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_cistruct mtk_foe_ipv4_dslite { 17462306a36Sopenharmony_ci struct mtk_ipv4_tuple ip4; 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_ci u32 tunnel_src_ip[4]; 17762306a36Sopenharmony_ci u32 tunnel_dest_ip[4]; 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci u8 flow_label[3]; 18062306a36Sopenharmony_ci u8 priority; 18162306a36Sopenharmony_ci 18262306a36Sopenharmony_ci u32 udf_tsid; 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci u32 ib2; 18562306a36Sopenharmony_ci 18662306a36Sopenharmony_ci struct mtk_foe_mac_info l2; 18762306a36Sopenharmony_ci}; 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_cistruct mtk_foe_ipv6 { 19062306a36Sopenharmony_ci u32 src_ip[4]; 19162306a36Sopenharmony_ci u32 dest_ip[4]; 19262306a36Sopenharmony_ci 19362306a36Sopenharmony_ci union { 19462306a36Sopenharmony_ci struct { 19562306a36Sopenharmony_ci u8 protocol; 19662306a36Sopenharmony_ci u8 _pad[3]; /* fill with 0xa5a5a5 */ 19762306a36Sopenharmony_ci }; /* 3-tuple */ 19862306a36Sopenharmony_ci struct { 19962306a36Sopenharmony_ci u16 dest_port; 20062306a36Sopenharmony_ci u16 src_port; 20162306a36Sopenharmony_ci }; /* 5-tuple */ 20262306a36Sopenharmony_ci u32 ports; 20362306a36Sopenharmony_ci }; 20462306a36Sopenharmony_ci 20562306a36Sopenharmony_ci u32 _rsv[3]; 20662306a36Sopenharmony_ci 20762306a36Sopenharmony_ci u32 udf; 20862306a36Sopenharmony_ci 20962306a36Sopenharmony_ci u32 ib2; 21062306a36Sopenharmony_ci struct mtk_foe_mac_info l2; 21162306a36Sopenharmony_ci}; 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_cistruct mtk_foe_ipv6_6rd { 21462306a36Sopenharmony_ci u32 src_ip[4]; 21562306a36Sopenharmony_ci u32 dest_ip[4]; 21662306a36Sopenharmony_ci u16 dest_port; 21762306a36Sopenharmony_ci u16 src_port; 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_ci u32 tunnel_src_ip; 22062306a36Sopenharmony_ci u32 tunnel_dest_ip; 22162306a36Sopenharmony_ci 22262306a36Sopenharmony_ci u16 hdr_csum; 22362306a36Sopenharmony_ci u8 dscp; 22462306a36Sopenharmony_ci u8 ttl; 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_ci u8 flag; 22762306a36Sopenharmony_ci u8 pad; 22862306a36Sopenharmony_ci u8 per_flow_6rd_id; 22962306a36Sopenharmony_ci u8 pad2; 23062306a36Sopenharmony_ci 23162306a36Sopenharmony_ci u32 ib2; 23262306a36Sopenharmony_ci struct mtk_foe_mac_info l2; 23362306a36Sopenharmony_ci}; 23462306a36Sopenharmony_ci 23562306a36Sopenharmony_ci#define MTK_FOE_ENTRY_V1_SIZE 80 23662306a36Sopenharmony_ci#define MTK_FOE_ENTRY_V2_SIZE 96 23762306a36Sopenharmony_ci#define MTK_FOE_ENTRY_V3_SIZE 128 23862306a36Sopenharmony_ci 23962306a36Sopenharmony_cistruct mtk_foe_entry { 24062306a36Sopenharmony_ci u32 ib1; 24162306a36Sopenharmony_ci 24262306a36Sopenharmony_ci union { 24362306a36Sopenharmony_ci struct mtk_foe_bridge bridge; 24462306a36Sopenharmony_ci struct mtk_foe_ipv4 ipv4; 24562306a36Sopenharmony_ci struct mtk_foe_ipv4_dslite dslite; 24662306a36Sopenharmony_ci struct mtk_foe_ipv6 ipv6; 24762306a36Sopenharmony_ci struct mtk_foe_ipv6_6rd ipv6_6rd; 24862306a36Sopenharmony_ci u32 data[31]; 24962306a36Sopenharmony_ci }; 25062306a36Sopenharmony_ci}; 25162306a36Sopenharmony_ci 25262306a36Sopenharmony_cienum { 25362306a36Sopenharmony_ci MTK_PPE_CPU_REASON_TTL_EXCEEDED = 0x02, 25462306a36Sopenharmony_ci MTK_PPE_CPU_REASON_OPTION_HEADER = 0x03, 25562306a36Sopenharmony_ci MTK_PPE_CPU_REASON_NO_FLOW = 0x07, 25662306a36Sopenharmony_ci MTK_PPE_CPU_REASON_IPV4_FRAG = 0x08, 25762306a36Sopenharmony_ci MTK_PPE_CPU_REASON_IPV4_DSLITE_FRAG = 0x09, 25862306a36Sopenharmony_ci MTK_PPE_CPU_REASON_IPV4_DSLITE_NO_TCP_UDP = 0x0a, 25962306a36Sopenharmony_ci MTK_PPE_CPU_REASON_IPV6_6RD_NO_TCP_UDP = 0x0b, 26062306a36Sopenharmony_ci MTK_PPE_CPU_REASON_TCP_FIN_SYN_RST = 0x0c, 26162306a36Sopenharmony_ci MTK_PPE_CPU_REASON_UN_HIT = 0x0d, 26262306a36Sopenharmony_ci MTK_PPE_CPU_REASON_HIT_UNBIND = 0x0e, 26362306a36Sopenharmony_ci MTK_PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED = 0x0f, 26462306a36Sopenharmony_ci MTK_PPE_CPU_REASON_HIT_BIND_TCP_FIN = 0x10, 26562306a36Sopenharmony_ci MTK_PPE_CPU_REASON_HIT_TTL_1 = 0x11, 26662306a36Sopenharmony_ci MTK_PPE_CPU_REASON_HIT_BIND_VLAN_VIOLATION = 0x12, 26762306a36Sopenharmony_ci MTK_PPE_CPU_REASON_KEEPALIVE_UC_OLD_HDR = 0x13, 26862306a36Sopenharmony_ci MTK_PPE_CPU_REASON_KEEPALIVE_MC_NEW_HDR = 0x14, 26962306a36Sopenharmony_ci MTK_PPE_CPU_REASON_KEEPALIVE_DUP_OLD_HDR = 0x15, 27062306a36Sopenharmony_ci MTK_PPE_CPU_REASON_HIT_BIND_FORCE_CPU = 0x16, 27162306a36Sopenharmony_ci MTK_PPE_CPU_REASON_TUNNEL_OPTION_HEADER = 0x17, 27262306a36Sopenharmony_ci MTK_PPE_CPU_REASON_MULTICAST_TO_CPU = 0x18, 27362306a36Sopenharmony_ci MTK_PPE_CPU_REASON_MULTICAST_TO_GMAC1_CPU = 0x19, 27462306a36Sopenharmony_ci MTK_PPE_CPU_REASON_HIT_PRE_BIND = 0x1a, 27562306a36Sopenharmony_ci MTK_PPE_CPU_REASON_PACKET_SAMPLING = 0x1b, 27662306a36Sopenharmony_ci MTK_PPE_CPU_REASON_EXCEED_MTU = 0x1c, 27762306a36Sopenharmony_ci MTK_PPE_CPU_REASON_PPE_BYPASS = 0x1e, 27862306a36Sopenharmony_ci MTK_PPE_CPU_REASON_INVALID = 0x1f, 27962306a36Sopenharmony_ci}; 28062306a36Sopenharmony_ci 28162306a36Sopenharmony_cienum { 28262306a36Sopenharmony_ci MTK_FLOW_TYPE_L4, 28362306a36Sopenharmony_ci MTK_FLOW_TYPE_L2, 28462306a36Sopenharmony_ci MTK_FLOW_TYPE_L2_SUBFLOW, 28562306a36Sopenharmony_ci}; 28662306a36Sopenharmony_ci 28762306a36Sopenharmony_cistruct mtk_flow_entry { 28862306a36Sopenharmony_ci union { 28962306a36Sopenharmony_ci struct hlist_node list; 29062306a36Sopenharmony_ci struct { 29162306a36Sopenharmony_ci struct rhash_head l2_node; 29262306a36Sopenharmony_ci struct hlist_head l2_flows; 29362306a36Sopenharmony_ci }; 29462306a36Sopenharmony_ci }; 29562306a36Sopenharmony_ci u8 type; 29662306a36Sopenharmony_ci s8 wed_index; 29762306a36Sopenharmony_ci u8 ppe_index; 29862306a36Sopenharmony_ci u16 hash; 29962306a36Sopenharmony_ci union { 30062306a36Sopenharmony_ci struct mtk_foe_entry data; 30162306a36Sopenharmony_ci struct { 30262306a36Sopenharmony_ci struct mtk_flow_entry *base_flow; 30362306a36Sopenharmony_ci struct hlist_node list; 30462306a36Sopenharmony_ci } l2_data; 30562306a36Sopenharmony_ci }; 30662306a36Sopenharmony_ci struct rhash_head node; 30762306a36Sopenharmony_ci unsigned long cookie; 30862306a36Sopenharmony_ci}; 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_cistruct mtk_mib_entry { 31162306a36Sopenharmony_ci u32 byt_cnt_l; 31262306a36Sopenharmony_ci u16 byt_cnt_h; 31362306a36Sopenharmony_ci u32 pkt_cnt_l; 31462306a36Sopenharmony_ci u8 pkt_cnt_h; 31562306a36Sopenharmony_ci u8 _rsv0; 31662306a36Sopenharmony_ci u32 _rsv1; 31762306a36Sopenharmony_ci} __packed; 31862306a36Sopenharmony_ci 31962306a36Sopenharmony_cistruct mtk_foe_accounting { 32062306a36Sopenharmony_ci u64 bytes; 32162306a36Sopenharmony_ci u64 packets; 32262306a36Sopenharmony_ci}; 32362306a36Sopenharmony_ci 32462306a36Sopenharmony_cistruct mtk_ppe { 32562306a36Sopenharmony_ci struct mtk_eth *eth; 32662306a36Sopenharmony_ci struct device *dev; 32762306a36Sopenharmony_ci void __iomem *base; 32862306a36Sopenharmony_ci int version; 32962306a36Sopenharmony_ci char dirname[5]; 33062306a36Sopenharmony_ci bool accounting; 33162306a36Sopenharmony_ci 33262306a36Sopenharmony_ci void *foe_table; 33362306a36Sopenharmony_ci dma_addr_t foe_phys; 33462306a36Sopenharmony_ci 33562306a36Sopenharmony_ci struct mtk_mib_entry *mib_table; 33662306a36Sopenharmony_ci dma_addr_t mib_phys; 33762306a36Sopenharmony_ci 33862306a36Sopenharmony_ci u16 foe_check_time[MTK_PPE_ENTRIES]; 33962306a36Sopenharmony_ci struct hlist_head *foe_flow; 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci struct rhashtable l2_flows; 34262306a36Sopenharmony_ci 34362306a36Sopenharmony_ci void *acct_table; 34462306a36Sopenharmony_ci}; 34562306a36Sopenharmony_ci 34662306a36Sopenharmony_cistruct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, int index); 34762306a36Sopenharmony_ci 34862306a36Sopenharmony_civoid mtk_ppe_deinit(struct mtk_eth *eth); 34962306a36Sopenharmony_civoid mtk_ppe_start(struct mtk_ppe *ppe); 35062306a36Sopenharmony_ciint mtk_ppe_stop(struct mtk_ppe *ppe); 35162306a36Sopenharmony_ciint mtk_ppe_prepare_reset(struct mtk_ppe *ppe); 35262306a36Sopenharmony_ci 35362306a36Sopenharmony_civoid __mtk_ppe_check_skb(struct mtk_ppe *ppe, struct sk_buff *skb, u16 hash); 35462306a36Sopenharmony_ci 35562306a36Sopenharmony_cistatic inline void 35662306a36Sopenharmony_cimtk_ppe_check_skb(struct mtk_ppe *ppe, struct sk_buff *skb, u16 hash) 35762306a36Sopenharmony_ci{ 35862306a36Sopenharmony_ci u16 now, diff; 35962306a36Sopenharmony_ci 36062306a36Sopenharmony_ci if (!ppe) 36162306a36Sopenharmony_ci return; 36262306a36Sopenharmony_ci 36362306a36Sopenharmony_ci if (hash > MTK_PPE_HASH_MASK) 36462306a36Sopenharmony_ci return; 36562306a36Sopenharmony_ci 36662306a36Sopenharmony_ci now = (u16)jiffies; 36762306a36Sopenharmony_ci diff = now - ppe->foe_check_time[hash]; 36862306a36Sopenharmony_ci if (diff < HZ / 10) 36962306a36Sopenharmony_ci return; 37062306a36Sopenharmony_ci 37162306a36Sopenharmony_ci ppe->foe_check_time[hash] = now; 37262306a36Sopenharmony_ci __mtk_ppe_check_skb(ppe, skb, hash); 37362306a36Sopenharmony_ci} 37462306a36Sopenharmony_ci 37562306a36Sopenharmony_ciint mtk_foe_entry_prepare(struct mtk_eth *eth, struct mtk_foe_entry *entry, 37662306a36Sopenharmony_ci int type, int l4proto, u8 pse_port, u8 *src_mac, 37762306a36Sopenharmony_ci u8 *dest_mac); 37862306a36Sopenharmony_ciint mtk_foe_entry_set_pse_port(struct mtk_eth *eth, 37962306a36Sopenharmony_ci struct mtk_foe_entry *entry, u8 port); 38062306a36Sopenharmony_ciint mtk_foe_entry_set_ipv4_tuple(struct mtk_eth *eth, 38162306a36Sopenharmony_ci struct mtk_foe_entry *entry, bool orig, 38262306a36Sopenharmony_ci __be32 src_addr, __be16 src_port, 38362306a36Sopenharmony_ci __be32 dest_addr, __be16 dest_port); 38462306a36Sopenharmony_ciint mtk_foe_entry_set_ipv6_tuple(struct mtk_eth *eth, 38562306a36Sopenharmony_ci struct mtk_foe_entry *entry, 38662306a36Sopenharmony_ci __be32 *src_addr, __be16 src_port, 38762306a36Sopenharmony_ci __be32 *dest_addr, __be16 dest_port); 38862306a36Sopenharmony_ciint mtk_foe_entry_set_dsa(struct mtk_eth *eth, struct mtk_foe_entry *entry, 38962306a36Sopenharmony_ci int port); 39062306a36Sopenharmony_ciint mtk_foe_entry_set_vlan(struct mtk_eth *eth, struct mtk_foe_entry *entry, 39162306a36Sopenharmony_ci int vid); 39262306a36Sopenharmony_ciint mtk_foe_entry_set_pppoe(struct mtk_eth *eth, struct mtk_foe_entry *entry, 39362306a36Sopenharmony_ci int sid); 39462306a36Sopenharmony_ciint mtk_foe_entry_set_wdma(struct mtk_eth *eth, struct mtk_foe_entry *entry, 39562306a36Sopenharmony_ci int wdma_idx, int txq, int bss, int wcid); 39662306a36Sopenharmony_ciint mtk_foe_entry_set_queue(struct mtk_eth *eth, struct mtk_foe_entry *entry, 39762306a36Sopenharmony_ci unsigned int queue); 39862306a36Sopenharmony_ciint mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_flow_entry *entry); 39962306a36Sopenharmony_civoid mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry); 40062306a36Sopenharmony_ciint mtk_foe_entry_idle_time(struct mtk_ppe *ppe, struct mtk_flow_entry *entry); 40162306a36Sopenharmony_ciint mtk_ppe_debugfs_init(struct mtk_ppe *ppe, int index); 40262306a36Sopenharmony_cistruct mtk_foe_accounting *mtk_foe_entry_get_mib(struct mtk_ppe *ppe, u32 index, 40362306a36Sopenharmony_ci struct mtk_foe_accounting *diff); 40462306a36Sopenharmony_ci 40562306a36Sopenharmony_ci#endif 406