• Home
  • Raw
  • Download

Lines Matching full:ppe

26 static void ppe_w32(struct mtk_ppe *ppe, u32 reg, u32 val)  in ppe_w32()  argument
28 writel(val, ppe->base + reg); in ppe_w32()
31 static u32 ppe_r32(struct mtk_ppe *ppe, u32 reg) in ppe_r32() argument
33 return readl(ppe->base + reg); in ppe_r32()
36 static u32 ppe_m32(struct mtk_ppe *ppe, u32 reg, u32 mask, u32 set) in ppe_m32() argument
40 val = ppe_r32(ppe, reg); in ppe_m32()
43 ppe_w32(ppe, reg, val); in ppe_m32()
48 static u32 ppe_set(struct mtk_ppe *ppe, u32 reg, u32 val) in ppe_set() argument
50 return ppe_m32(ppe, reg, 0, val); in ppe_set()
53 static u32 ppe_clear(struct mtk_ppe *ppe, u32 reg, u32 val) in ppe_clear() argument
55 return ppe_m32(ppe, reg, val, 0); in ppe_clear()
63 static int mtk_ppe_wait_busy(struct mtk_ppe *ppe) in mtk_ppe_wait_busy() argument
68 ret = readl_poll_timeout(ppe->base + MTK_PPE_GLO_CFG, val, in mtk_ppe_wait_busy()
73 dev_err(ppe->dev, "PPE table busy"); in mtk_ppe_wait_busy()
78 static int mtk_ppe_mib_wait_busy(struct mtk_ppe *ppe) in mtk_ppe_mib_wait_busy() argument
83 ret = readl_poll_timeout(ppe->base + MTK_PPE_MIB_SER_CR, val, in mtk_ppe_mib_wait_busy()
88 dev_err(ppe->dev, "MIB table busy"); in mtk_ppe_mib_wait_busy()
93 static int mtk_mib_entry_read(struct mtk_ppe *ppe, u16 index, u64 *bytes, u64 *packets) in mtk_mib_entry_read() argument
99 ppe_w32(ppe, MTK_PPE_MIB_SER_CR, val); in mtk_mib_entry_read()
101 ret = mtk_ppe_mib_wait_busy(ppe); in mtk_mib_entry_read()
105 cnt_r0 = readl(ppe->base + MTK_PPE_MIB_SER_R0); in mtk_mib_entry_read()
106 cnt_r1 = readl(ppe->base + MTK_PPE_MIB_SER_R1); in mtk_mib_entry_read()
107 cnt_r2 = readl(ppe->base + MTK_PPE_MIB_SER_R2); in mtk_mib_entry_read()
109 if (mtk_is_netsys_v3_or_greater(ppe->eth)) { in mtk_mib_entry_read()
111 u32 cnt_r3 = readl(ppe->base + MTK_PPE_MIB_SER_R3); in mtk_mib_entry_read()
127 static void mtk_ppe_cache_clear(struct mtk_ppe *ppe) in mtk_ppe_cache_clear() argument
129 ppe_set(ppe, MTK_PPE_CACHE_CTL, MTK_PPE_CACHE_CTL_CLEAR); in mtk_ppe_cache_clear()
130 ppe_clear(ppe, MTK_PPE_CACHE_CTL, MTK_PPE_CACHE_CTL_CLEAR); in mtk_ppe_cache_clear()
133 static void mtk_ppe_cache_enable(struct mtk_ppe *ppe, bool enable) in mtk_ppe_cache_enable() argument
135 mtk_ppe_cache_clear(ppe); in mtk_ppe_cache_enable()
137 ppe_m32(ppe, MTK_PPE_CACHE_CTL, MTK_PPE_CACHE_CTL_EN, in mtk_ppe_cache_enable()
499 __mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) in __mtk_foe_entry_clear() argument
505 rhashtable_remove_fast(&ppe->l2_flows, &entry->l2_node, in __mtk_foe_entry_clear()
510 __mtk_foe_entry_clear(ppe, entry); in __mtk_foe_entry_clear()
516 struct mtk_foe_entry *hwe = mtk_foe_get_entry(ppe, entry->hash); in __mtk_foe_entry_clear()
521 mtk_ppe_cache_clear(ppe); in __mtk_foe_entry_clear()
523 if (ppe->accounting) { in __mtk_foe_entry_clear()
526 acct = ppe->acct_table + entry->hash * sizeof(*acct); in __mtk_foe_entry_clear()
540 static int __mtk_foe_entry_idle_time(struct mtk_ppe *ppe, u32 ib1) in __mtk_foe_entry_idle_time() argument
542 u32 ib1_ts_mask = mtk_get_ib1_ts_mask(ppe->eth); in __mtk_foe_entry_idle_time()
543 u16 now = mtk_eth_timestamp(ppe->eth); in __mtk_foe_entry_idle_time()
553 mtk_flow_entry_update_l2(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) in mtk_flow_entry_update_l2() argument
555 u32 ib1_ts_mask = mtk_get_ib1_ts_mask(ppe->eth); in mtk_flow_entry_update_l2()
561 idle = __mtk_foe_entry_idle_time(ppe, entry->data.ib1); in mtk_flow_entry_update_l2()
566 hwe = mtk_foe_get_entry(ppe, cur->hash); in mtk_flow_entry_update_l2()
571 __mtk_foe_entry_clear(ppe, cur); in mtk_flow_entry_update_l2()
575 cur_idle = __mtk_foe_entry_idle_time(ppe, ib1); in mtk_flow_entry_update_l2()
586 mtk_flow_entry_update(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) in mtk_flow_entry_update() argument
594 mtk_flow_entry_update_l2(ppe, entry); in mtk_flow_entry_update()
601 hwe = mtk_foe_get_entry(ppe, entry->hash); in mtk_flow_entry_update()
602 memcpy(&foe, hwe, ppe->eth->soc->foe_entry_size); in mtk_flow_entry_update()
603 if (!mtk_flow_entry_match(ppe->eth, entry, &foe)) { in mtk_flow_entry_update()
615 __mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_foe_entry *entry, in __mtk_foe_entry_commit() argument
618 struct mtk_eth *eth = ppe->eth; in __mtk_foe_entry_commit()
633 hwe = mtk_foe_get_entry(ppe, hash); in __mtk_foe_entry_commit()
638 if (ppe->accounting) { in __mtk_foe_entry_commit()
648 mtk_ppe_cache_clear(ppe); in __mtk_foe_entry_commit()
651 void mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) in mtk_foe_entry_clear() argument
654 __mtk_foe_entry_clear(ppe, entry); in mtk_foe_entry_clear()
659 mtk_foe_entry_commit_l2(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) in mtk_foe_entry_commit_l2() argument
665 prev = rhashtable_lookup_get_insert_fast(&ppe->l2_flows, &entry->l2_node, in mtk_foe_entry_commit_l2()
673 return rhashtable_replace_fast(&ppe->l2_flows, &prev->l2_node, in mtk_foe_entry_commit_l2()
677 int mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) in mtk_foe_entry_commit() argument
679 const struct mtk_soc_data *soc = ppe->eth->soc; in mtk_foe_entry_commit()
680 int type = mtk_get_ib1_pkt_type(ppe->eth, entry->data.ib1); in mtk_foe_entry_commit()
684 return mtk_foe_entry_commit_l2(ppe, entry); in mtk_foe_entry_commit()
686 hash = mtk_ppe_hash_entry(ppe->eth, &entry->data); in mtk_foe_entry_commit()
689 hlist_add_head(&entry->list, &ppe->foe_flow[hash / soc->hash_offset]); in mtk_foe_entry_commit()
696 mtk_foe_entry_commit_subflow(struct mtk_ppe *ppe, struct mtk_flow_entry *entry, in mtk_foe_entry_commit_subflow() argument
699 const struct mtk_soc_data *soc = ppe->eth->soc; in mtk_foe_entry_commit_subflow()
703 u32 ib1_mask = mtk_get_ib1_pkt_type_mask(ppe->eth) | MTK_FOE_IB1_UDP; in mtk_foe_entry_commit_subflow()
714 &ppe->foe_flow[hash / soc->hash_offset]); in mtk_foe_entry_commit_subflow()
717 hwe = mtk_foe_get_entry(ppe, hash); in mtk_foe_entry_commit_subflow()
722 l2 = mtk_foe_entry_l2(ppe->eth, &foe); in mtk_foe_entry_commit_subflow()
725 type = mtk_get_ib1_pkt_type(ppe->eth, foe.ib1); in mtk_foe_entry_commit_subflow()
731 *mtk_foe_entry_ib2(ppe->eth, &foe) = entry->data.bridge.ib2; in mtk_foe_entry_commit_subflow()
733 __mtk_foe_entry_commit(ppe, &foe, hash); in mtk_foe_entry_commit_subflow()
736 void __mtk_ppe_check_skb(struct mtk_ppe *ppe, struct sk_buff *skb, u16 hash) in __mtk_ppe_check_skb() argument
738 const struct mtk_soc_data *soc = ppe->eth->soc; in __mtk_ppe_check_skb()
739 struct hlist_head *head = &ppe->foe_flow[hash / soc->hash_offset]; in __mtk_ppe_check_skb()
740 struct mtk_foe_entry *hwe = mtk_foe_get_entry(ppe, hash); in __mtk_ppe_check_skb()
760 __mtk_foe_entry_clear(ppe, entry); in __mtk_ppe_check_skb()
764 if (found || !mtk_flow_entry_match(ppe->eth, entry, hwe)) { in __mtk_ppe_check_skb()
771 __mtk_foe_entry_commit(ppe, &entry->data, hash); in __mtk_ppe_check_skb()
805 entry = rhashtable_lookup_fast(&ppe->l2_flows, &key, mtk_flow_l2_ht_params); in __mtk_ppe_check_skb()
809 mtk_foe_entry_commit_subflow(ppe, entry, hash); in __mtk_ppe_check_skb()
815 int mtk_foe_entry_idle_time(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) in mtk_foe_entry_idle_time() argument
817 mtk_flow_entry_update(ppe, entry); in mtk_foe_entry_idle_time()
819 return __mtk_foe_entry_idle_time(ppe, entry->data.ib1); in mtk_foe_entry_idle_time()
822 int mtk_ppe_prepare_reset(struct mtk_ppe *ppe) in mtk_ppe_prepare_reset() argument
824 if (!ppe) in mtk_ppe_prepare_reset()
828 ppe_clear(ppe, MTK_PPE_TB_CFG, MTK_PPE_TB_CFG_KEEPALIVE); in mtk_ppe_prepare_reset()
829 ppe_clear(ppe, MTK_PPE_BIND_LMT1, MTK_PPE_NTU_KEEPALIVE); in mtk_ppe_prepare_reset()
830 ppe_w32(ppe, MTK_PPE_KEEPALIVE, 0); in mtk_ppe_prepare_reset()
834 ppe_set(ppe, MTK_PPE_BIND_LMT1, MTK_PPE_NTU_KEEPALIVE); in mtk_ppe_prepare_reset()
835 ppe_w32(ppe, MTK_PPE_KEEPALIVE, 0xffffffff); in mtk_ppe_prepare_reset()
838 ppe_set(ppe, MTK_PPE_TB_CFG, MTK_PPE_TB_TICK_SEL); in mtk_ppe_prepare_reset()
839 ppe_set(ppe, MTK_PPE_TB_CFG, MTK_PPE_TB_CFG_KEEPALIVE); in mtk_ppe_prepare_reset()
843 ppe_clear(ppe, MTK_PPE_TB_CFG, MTK_PPE_TB_CFG_SCAN_MODE); in mtk_ppe_prepare_reset()
846 return mtk_ppe_wait_busy(ppe); in mtk_ppe_prepare_reset()
849 struct mtk_foe_accounting *mtk_foe_entry_get_mib(struct mtk_ppe *ppe, u32 index, in mtk_foe_entry_get_mib() argument
856 if (!ppe->accounting) in mtk_foe_entry_get_mib()
859 if (mtk_mib_entry_read(ppe, index, &bytes, &packets)) in mtk_foe_entry_get_mib()
862 acct = ppe->acct_table + index * size; in mtk_foe_entry_get_mib()
882 struct mtk_ppe *ppe; in mtk_ppe_init() local
886 ppe = devm_kzalloc(dev, sizeof(*ppe), GFP_KERNEL); in mtk_ppe_init()
887 if (!ppe) in mtk_ppe_init()
890 rhashtable_init(&ppe->l2_flows, &mtk_flow_l2_ht_params); in mtk_ppe_init()
892 /* need to allocate a separate device, since it PPE DMA access is in mtk_ppe_init()
895 ppe->base = base; in mtk_ppe_init()
896 ppe->eth = eth; in mtk_ppe_init()
897 ppe->dev = dev; in mtk_ppe_init()
898 ppe->version = eth->soc->offload_version; in mtk_ppe_init()
899 ppe->accounting = accounting; in mtk_ppe_init()
901 foe = dmam_alloc_coherent(ppe->dev, in mtk_ppe_init()
903 &ppe->foe_phys, GFP_KERNEL); in mtk_ppe_init()
907 ppe->foe_table = foe; in mtk_ppe_init()
910 sizeof(*ppe->foe_flow); in mtk_ppe_init()
911 ppe->foe_flow = devm_kzalloc(dev, foe_flow_size, GFP_KERNEL); in mtk_ppe_init()
912 if (!ppe->foe_flow) in mtk_ppe_init()
916 mib = dmam_alloc_coherent(ppe->dev, MTK_PPE_ENTRIES * sizeof(*mib), in mtk_ppe_init()
917 &ppe->mib_phys, GFP_KERNEL); in mtk_ppe_init()
921 ppe->mib_table = mib; in mtk_ppe_init()
929 ppe->acct_table = acct; in mtk_ppe_init()
932 mtk_ppe_debugfs_init(ppe, index); in mtk_ppe_init()
934 return ppe; in mtk_ppe_init()
937 rhashtable_destroy(&ppe->l2_flows); in mtk_ppe_init()
945 for (i = 0; i < ARRAY_SIZE(eth->ppe); i++) { in mtk_ppe_deinit()
946 if (!eth->ppe[i]) in mtk_ppe_deinit()
948 rhashtable_destroy(&eth->ppe[i]->l2_flows); in mtk_ppe_deinit()
952 static void mtk_ppe_init_foe_table(struct mtk_ppe *ppe) in mtk_ppe_init_foe_table() argument
957 memset(ppe->foe_table, 0, in mtk_ppe_init_foe_table()
958 MTK_PPE_ENTRIES * ppe->eth->soc->foe_entry_size); in mtk_ppe_init_foe_table()
968 hwe = mtk_foe_get_entry(ppe, i + skip[k]); in mtk_ppe_init_foe_table()
974 void mtk_ppe_start(struct mtk_ppe *ppe) in mtk_ppe_start() argument
978 if (!ppe) in mtk_ppe_start()
981 mtk_ppe_init_foe_table(ppe); in mtk_ppe_start()
982 ppe_w32(ppe, MTK_PPE_TB_BASE, ppe->foe_phys); in mtk_ppe_start()
998 if (mtk_is_netsys_v2_or_greater(ppe->eth)) in mtk_ppe_start()
1000 if (!mtk_is_netsys_v3_or_greater(ppe->eth)) in mtk_ppe_start()
1002 ppe_w32(ppe, MTK_PPE_TB_CFG, val); in mtk_ppe_start()
1004 ppe_w32(ppe, MTK_PPE_IP_PROTO_CHK, in mtk_ppe_start()
1007 mtk_ppe_cache_enable(ppe, true); in mtk_ppe_start()
1016 if (mtk_is_netsys_v2_or_greater(ppe->eth)) in mtk_ppe_start()
1024 ppe_w32(ppe, MTK_PPE_FLOW_CFG, val); in mtk_ppe_start()
1028 ppe_w32(ppe, MTK_PPE_UNBIND_AGE, val); in mtk_ppe_start()
1032 ppe_w32(ppe, MTK_PPE_BIND_AGE0, val); in mtk_ppe_start()
1036 ppe_w32(ppe, MTK_PPE_BIND_AGE1, val); in mtk_ppe_start()
1039 ppe_w32(ppe, MTK_PPE_BIND_LIMIT0, val); in mtk_ppe_start()
1043 ppe_w32(ppe, MTK_PPE_BIND_LIMIT1, val); in mtk_ppe_start()
1047 ppe_w32(ppe, MTK_PPE_BIND_RATE, val); in mtk_ppe_start()
1049 /* enable PPE */ in mtk_ppe_start()
1054 ppe_w32(ppe, MTK_PPE_GLO_CFG, val); in mtk_ppe_start()
1056 ppe_w32(ppe, MTK_PPE_DEFAULT_CPU_PORT, 0); in mtk_ppe_start()
1058 if (mtk_is_netsys_v2_or_greater(ppe->eth)) { in mtk_ppe_start()
1059 ppe_w32(ppe, MTK_PPE_DEFAULT_CPU_PORT1, 0xcb777); in mtk_ppe_start()
1060 ppe_w32(ppe, MTK_PPE_SBW_CTRL, 0x7f); in mtk_ppe_start()
1063 if (ppe->accounting && ppe->mib_phys) { in mtk_ppe_start()
1064 ppe_w32(ppe, MTK_PPE_MIB_TB_BASE, ppe->mib_phys); in mtk_ppe_start()
1065 ppe_m32(ppe, MTK_PPE_MIB_CFG, MTK_PPE_MIB_CFG_EN, in mtk_ppe_start()
1067 ppe_m32(ppe, MTK_PPE_MIB_CFG, MTK_PPE_MIB_CFG_RD_CLR, in mtk_ppe_start()
1069 ppe_m32(ppe, MTK_PPE_MIB_CACHE_CTL, MTK_PPE_MIB_CACHE_CTL_EN, in mtk_ppe_start()
1074 int mtk_ppe_stop(struct mtk_ppe *ppe) in mtk_ppe_stop() argument
1079 if (!ppe) in mtk_ppe_stop()
1083 struct mtk_foe_entry *hwe = mtk_foe_get_entry(ppe, i); in mtk_ppe_stop()
1089 mtk_ppe_cache_enable(ppe, false); in mtk_ppe_stop()
1092 ppe_clear(ppe, MTK_PPE_GLO_CFG, MTK_PPE_GLO_CFG_EN); in mtk_ppe_stop()
1093 ppe_w32(ppe, MTK_PPE_FLOW_CFG, 0); in mtk_ppe_stop()
1101 ppe_clear(ppe, MTK_PPE_TB_CFG, val); in mtk_ppe_stop()
1103 return mtk_ppe_wait_busy(ppe); in mtk_ppe_stop()