blob: 57a1ddec4996c53a076480153a15e6949f474d39 [file] [log] [blame]
developere5e687d2023-08-08 16:05:33 +08001--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
2+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
developer84f378f2023-08-24 18:26:50 +08003@@ -245,6 +245,9 @@ static const char * const mtk_clks_sourc
developere5e687d2023-08-08 16:05:33 +08004 "top_netsys_warp_sel",
5 };
6
7+struct net_device *(*mtk_get_tnl_dev)(int tnl_idx) = NULL;
8+EXPORT_SYMBOL(mtk_get_tnl_dev);
9+
10 void mtk_w32(struct mtk_eth *eth, u32 val, unsigned reg)
11 {
12 __raw_writel(val, eth->base + reg);
developer84f378f2023-08-24 18:26:50 +080013@@ -2171,6 +2174,7 @@ static int mtk_poll_rx(struct napi_struc
developere5e687d2023-08-08 16:05:33 +080014 u64 addr64 = 0;
15 u8 *data, *new_data;
16 struct mtk_rx_dma_v2 *rxd, trxd;
17+ int tnl_idx = 0;
18 int done = 0;
19
20 if (unlikely(!ring))
developer84f378f2023-08-24 18:26:50 +080021@@ -2214,11 +2218,20 @@ static int mtk_poll_rx(struct napi_struc
developere5e687d2023-08-08 16:05:33 +080022 0 : RX_DMA_GET_SPORT(trxd.rxd4) - 1;
23 }
24
25- if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
26- !eth->netdev[mac]))
27- goto release_desc;
28+ tnl_idx = RX_DMA_GET_TOPS_CRSN(trxd.rxd6);
29+ if (mtk_get_tnl_dev && tnl_idx) {
30+ netdev = mtk_get_tnl_dev(tnl_idx);
31+ if (unlikely(IS_ERR(netdev)))
32+ netdev = NULL;
33+ }
34
35- netdev = eth->netdev[mac];
36+ if (!netdev) {
37+ if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
38+ !eth->netdev[mac]))
39+ goto release_desc;
40+
41+ netdev = eth->netdev[mac];
42+ }
43
44 if (unlikely(test_bit(MTK_RESETTING, &eth->state)))
45 goto release_desc;
developer84f378f2023-08-24 18:26:50 +080046@@ -2303,6 +2316,8 @@ static int mtk_poll_rx(struct napi_struc
developere5e687d2023-08-08 16:05:33 +080047 skb_hnat_alg(skb) = 0;
48 skb_hnat_filled(skb) = 0;
49 skb_hnat_magic_tag(skb) = HNAT_MAGIC_TAG;
50+ skb_hnat_set_tops(skb, 0);
51+ skb_hnat_set_is_decap(skb, 0);
52
53 if (skb_hnat_reason(skb) == HIT_BIND_FORCE_TO_CPU) {
54 trace_printk("[%s] reason=0x%x(force to CPU) from WAN to Ext\n",
55--- a/drivers/net/ethernet/mediatek/mtk_hnat/hnat.c
56+++ b/drivers/net/ethernet/mediatek/mtk_hnat/hnat.c
57@@ -43,6 +43,12 @@ void (*ppe_dev_register_hook)(struct net
58 EXPORT_SYMBOL(ppe_dev_register_hook);
59 void (*ppe_dev_unregister_hook)(struct net_device *dev) = NULL;
60 EXPORT_SYMBOL(ppe_dev_unregister_hook);
61+int (*mtk_tnl_encap_offload)(struct sk_buff *skb) = NULL;
62+EXPORT_SYMBOL(mtk_tnl_encap_offload);
63+int (*mtk_tnl_decap_offload)(struct sk_buff *skb) = NULL;
64+EXPORT_SYMBOL(mtk_tnl_decap_offload);
65+bool (*mtk_tnl_decap_offloadable)(struct sk_buff *skb) = NULL;
66+EXPORT_SYMBOL(mtk_tnl_decap_offloadable);
67
68 static void hnat_sma_build_entry(struct timer_list *t)
69 {
70@@ -53,6 +59,16 @@ static void hnat_sma_build_entry(struct
71 SMA, SMA_FWD_CPU_BUILD_ENTRY);
72 }
73
74+struct foe_entry *hnat_get_foe_entry(u32 ppe_id, u32 index)
75+{
76+ if (index == 0x7fff || index >= hnat_priv->foe_etry_num
77+ || ppe_id >= CFG_PPE_NUM)
78+ return ERR_PTR(-EINVAL);
79+
80+ return &hnat_priv->foe_table_cpu[ppe_id][index];
81+}
82+EXPORT_SYMBOL(hnat_get_foe_entry);
83+
84 void hnat_cache_ebl(int enable)
85 {
86 int i;
87@@ -63,6 +79,7 @@ void hnat_cache_ebl(int enable)
88 cr_set_field(hnat_priv->ppe_base[i] + PPE_CAH_CTRL, CAH_EN, enable);
89 }
90 }
91+EXPORT_SYMBOL(hnat_cache_ebl);
92
93 static void hnat_reset_timestamp(struct timer_list *t)
94 {
95--- a/drivers/net/ethernet/mediatek/mtk_hnat/hnat.h
96+++ b/drivers/net/ethernet/mediatek/mtk_hnat/hnat.h
developerf88469b2023-08-18 16:01:49 +080097@@ -1087,6 +1087,8 @@ enum FoeIpAct {
developere5e687d2023-08-08 16:05:33 +080098 #define NR_WDMA1_PORT 9
developerf88469b2023-08-18 16:01:49 +080099 #define NR_WDMA2_PORT 13
developere5e687d2023-08-08 16:05:33 +0800100 #define NR_GMAC3_PORT 15
101+#define NR_TDMA_TPORT 4
102+#define NR_TDMA_QDMA_TPORT 5
103 #define LAN_DEV_NAME hnat_priv->lan
104 #define LAN2_DEV_NAME hnat_priv->lan2
105 #define IS_WAN(dev) \
developerf88469b2023-08-18 16:01:49 +0800106@@ -1210,6 +1212,8 @@ static inline bool hnat_dsa_is_enable(st
developere5e687d2023-08-08 16:05:33 +0800107 }
108 #endif
109
110+struct foe_entry *hnat_get_foe_entry(u32 ppe_id, u32 index);
111+
112 void hnat_deinit_debugfs(struct mtk_hnat *h);
113 int hnat_init_debugfs(struct mtk_hnat *h);
114 int hnat_register_nf_hooks(void);
developerf88469b2023-08-18 16:01:49 +0800115@@ -1226,6 +1230,9 @@ extern int qos_ul_toggle;
developere5e687d2023-08-08 16:05:33 +0800116 extern int hook_toggle;
117 extern int mape_toggle;
118 extern int qos_toggle;
119+extern int (*mtk_tnl_encap_offload)(struct sk_buff *skb);
120+extern int (*mtk_tnl_decap_offload)(struct sk_buff *skb);
121+extern bool (*mtk_tnl_decap_offloadable)(struct sk_buff *skb);
122
123 int ext_if_add(struct extdev_entry *ext_entry);
124 int ext_if_del(struct extdev_entry *ext_entry);
125--- a/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c
126+++ b/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c
127@@ -726,10 +726,14 @@ static unsigned int is_ppe_support_type(
128 case ETH_P_IP:
129 iph = ip_hdr(skb);
130
131- /* do not accelerate non tcp/udp traffic */
132- if ((iph->protocol == IPPROTO_TCP) ||
133+ if (mtk_tnl_decap_offloadable && mtk_tnl_decap_offloadable(skb)) {
134+ /* tunnel protocol is offloadable */
135+ skb_hnat_set_is_decap(skb, 1);
136+ return 1;
137+ } else if ((iph->protocol == IPPROTO_TCP) ||
138 (iph->protocol == IPPROTO_UDP) ||
139 (iph->protocol == IPPROTO_IPV6)) {
140+ /* do not accelerate non tcp/udp traffic */
141 return 1;
142 }
143
144@@ -846,6 +850,13 @@ mtk_hnat_ipv4_nf_pre_routing(void *priv,
145
146 hnat_set_head_frags(state, skb, -1, hnat_set_iif);
147
148+ if (skb_hnat_tops(skb) && skb_hnat_is_decap(skb)
149+ && is_magic_tag_valid(skb)
150+ && skb_hnat_iface(skb) == FOE_MAGIC_GE_VIRTUAL
151+ && mtk_tnl_decap_offload && mtk_tnl_decap_offload(skb)) {
152+ return NF_ACCEPT;
153+ }
154+
155 /*
156 * Avoid mistakenly binding of outer IP, ports in SW L2TP decap flow.
157 * In pre-routing, if dev is virtual iface, TOPS module is not loaded,
158@@ -922,6 +933,13 @@ mtk_hnat_br_nf_local_in(void *priv, stru
159
160 hnat_set_head_frags(state, skb, -1, hnat_set_iif);
161
162+ if (skb_hnat_tops(skb) && skb_hnat_is_decap(skb)
163+ && is_magic_tag_valid(skb)
164+ && skb_hnat_iface(skb) == FOE_MAGIC_GE_VIRTUAL
165+ && mtk_tnl_decap_offload && mtk_tnl_decap_offload(skb)) {
166+ return NF_ACCEPT;
167+ }
168+
169 pre_routing_print(skb, state->in, state->out, __func__);
170
171 if (unlikely(debug_level >= 7)) {
172@@ -1074,9 +1092,22 @@ static unsigned int hnat_ipv4_get_nextho
173 return -1;
174 }
175
176+ /*
177+ * if this packet is a tunnel packet and is about to construct
178+ * outer header, we must update its outer mac header pointer
179+ * before filling outer mac or it may screw up inner mac
180+ */
181+ if (skb_hnat_tops(skb) && skb_hnat_is_encap(skb)) {
182+ skb_push(skb, sizeof(struct ethhdr));
183+ skb_reset_mac_header(skb);
184+ }
185+
186 memcpy(eth_hdr(skb)->h_dest, neigh->ha, ETH_ALEN);
187 memcpy(eth_hdr(skb)->h_source, out->dev_addr, ETH_ALEN);
188
189+ if (skb_hnat_tops(skb) && skb_hnat_is_encap(skb))
190+ skb_pull(skb, sizeof(struct ethhdr));
191+
192 rcu_read_unlock_bh();
193
194 return 0;
developer84f378f2023-08-24 18:26:50 +0800195@@ -1202,6 +1233,81 @@ static struct ethhdr *get_ipv6_ipip_ethh
developere5e687d2023-08-08 16:05:33 +0800196 return eth;
197 }
198
199+static inline void hnat_get_filled_unbind_entry(struct sk_buff *skb,
200+ struct foe_entry *entry)
201+{
202+ if (unlikely(!skb || !entry))
203+ return;
204+
205+ memcpy(entry,
206+ &hnat_priv->foe_table_cpu[skb_hnat_ppe(skb)][skb_hnat_entry(skb)],
207+ sizeof(*entry));
developer84f378f2023-08-24 18:26:50 +0800208+
209+#if defined(CONFIG_MEDIATEK_NETSYS_V2) || defined(CONFIG_MEDIATEK_NETSYS_V3)
210+ entry->bfib1.mc = 0;
211+#endif /* defined(CONFIG_MEDIATEK_NETSYS_V2) || defined(CONFIG_MEDIATEK_NETSYS_V3) */
212+ entry->bfib1.ka = 0;
213+ entry->bfib1.vlan_layer = 0;
214+ entry->bfib1.psn = 0;
215+ entry->bfib1.vpm = 0;
216+ entry->bfib1.ps = 0;
developere5e687d2023-08-08 16:05:33 +0800217+}
218+
developerf88469b2023-08-18 16:01:49 +0800219+static inline void hnat_qos_tnl(u32 id, const struct net_device *dev)
220+{
221+ u32 cfg;
222+ u32 max_man = 0;
223+ u32 max_exp = 0;
224+ const struct mtk_mac *mac;
225+
226+ if (!dev)
227+ return;
228+ mac = netdev_priv(dev);
229+
230+ switch (mac->speed) {
231+ case SPEED_100:
232+ case SPEED_1000:
233+ case SPEED_2500:
234+ case SPEED_5000:
235+ case SPEED_10000:
236+ max_man = mac->speed / SPEED_100;
237+ max_exp = 5;
238+ break;
239+ default:
240+ return;
241+ }
242+
243+ cfg = QTX_SCH_MIN_RATE_EN | QTX_SCH_MAX_RATE_EN;
244+ cfg |= (1 << QTX_SCH_MIN_RATE_MAN_OFFSET) |
245+ (4 << QTX_SCH_MIN_RATE_EXP_OFFSET) |
246+ (max_man << QTX_SCH_MAX_RATE_MAN_OFFSET) |
247+ (max_exp << QTX_SCH_MAX_RATE_EXP_OFFSET) |
248+ (4 << QTX_SCH_MAX_RATE_WGHT_OFFSET);
249+ writel(cfg, hnat_priv->fe_base + QTX_SCH(id % NUM_OF_Q_PER_PAGE));
250+}
251+
developere5e687d2023-08-08 16:05:33 +0800252+static inline void hnat_fill_offload_engine_entry(struct sk_buff *skb,
developerf88469b2023-08-18 16:01:49 +0800253+ struct foe_entry *entry,
254+ const struct net_device *dev)
developere5e687d2023-08-08 16:05:33 +0800255+{
256+#if defined(CONFIG_MEDIATEK_NETSYS_V3)
257+ if (skb_hnat_tops(skb) && skb_hnat_is_encap(skb)) {
258+ /*
259+ * if skb_hnat_tops(skb) is setup for encapsulation,
260+ * we fill in hnat tport and tops_entry for tunnel encapsulation
261+ * offloading
262+ */
263+ entry->ipv4_hnapt.tport_id = NR_TDMA_QDMA_TPORT;
264+ entry->ipv4_hnapt.tops_entry = skb_hnat_tops(skb);
265+ } else {
266+ return;
267+ }
268+
269+ entry->ipv4_hnapt.iblk2.qid = 12; /* offload engine use QID 12 */
developerf88469b2023-08-18 16:01:49 +0800270+ hnat_qos_tnl(12, dev); /* set rate limit to line rate */
developere5e687d2023-08-08 16:05:33 +0800271+#endif /* defined(CONFIG_MEDIATEK_NETSYS_V3) */
272+}
273+
274 static unsigned int skb_to_hnat_info(struct sk_buff *skb,
275 const struct net_device *dev,
276 struct foe_entry *foe,
developer84f378f2023-08-24 18:26:50 +0800277@@ -1238,6 +1344,11 @@ static unsigned int skb_to_hnat_info(str
developere5e687d2023-08-08 16:05:33 +0800278 if (whnat && is_hnat_pre_filled(foe))
279 return 0;
280
281+ if (skb_hnat_tops(skb) && !(hw_path->flags & FLOW_OFFLOAD_PATH_TNL)) {
282+ hnat_get_filled_unbind_entry(skb, &entry);
283+ goto hnat_entry_bind;
284+ }
285+
286 entry.bfib1.pkt_type = foe->udib1.pkt_type; /* Get packte type state*/
287 entry.bfib1.state = foe->udib1.state;
288
developer84f378f2023-08-24 18:26:50 +0800289@@ -1633,6 +1744,10 @@ static unsigned int skb_to_hnat_info(str
developere5e687d2023-08-08 16:05:33 +0800290 /* Fill Layer2 Info.*/
291 entry = ppe_fill_L2_info(eth, entry, hw_path);
292
293+ if (skb_hnat_tops(skb) && hw_path->flags & FLOW_OFFLOAD_PATH_TNL)
294+ goto hnat_entry_skip_bind;
295+
296+hnat_entry_bind:
297 /* Fill Info Blk*/
298 entry = ppe_fill_info_blk(eth, entry, hw_path);
299
developer84f378f2023-08-24 18:26:50 +0800300@@ -1833,7 +1948,20 @@ static unsigned int skb_to_hnat_info(str
developere5e687d2023-08-08 16:05:33 +0800301 entry.ipv6_5t_route.act_dp |= UDF_HNAT_PRE_FILLED;
302 }
303
304+#if defined(CONFIG_MEDIATEK_NETSYS_V3)
developerf88469b2023-08-18 16:01:49 +0800305+ hnat_fill_offload_engine_entry(skb, &entry, dev);
developere5e687d2023-08-08 16:05:33 +0800306+#endif
307+
308+hnat_entry_skip_bind:
309 wmb();
310+
311+ /*
312+ * final check before we write BIND info.
313+ * If this entry is already bound, we should not modify it right now
314+ */
315+ if (entry_hnat_is_bound(foe))
316+ return 0;
317+
318 memcpy(foe, &entry, sizeof(entry));
319 /*reset statistic for this entry*/
320 if (hnat_priv->data->per_flow_accounting &&
developer84f378f2023-08-24 18:26:50 +0800321@@ -1886,6 +2014,7 @@ int mtk_sw_nat_hook_tx(struct sk_buff *s
developere5e687d2023-08-08 16:05:33 +0800322 return NF_ACCEPT;
323
324 eth = eth_hdr(skb);
325+
326 memcpy(&bfib1_tx, &entry->bfib1, sizeof(entry->bfib1));
327
328 /*not bind multicast if PPE mcast not enable*/
developer84f378f2023-08-24 18:26:50 +0800329@@ -1905,6 +2034,12 @@ int mtk_sw_nat_hook_tx(struct sk_buff *s
developere5e687d2023-08-08 16:05:33 +0800330 switch ((int)bfib1_tx.pkt_type) {
331 case IPV4_HNAPT:
332 case IPV4_HNAT:
333+ /*
334+ * skip if packet is an encap tnl packet or it may
335+ * screw up inner mac header
336+ */
337+ if (skb_hnat_tops(skb) && skb_hnat_is_encap(skb))
338+ break;
339 entry->ipv4_hnapt.smac_hi = swab32(*((u32 *)eth->h_source));
340 entry->ipv4_hnapt.smac_lo = swab16(*((u16 *)&eth->h_source[4]));
341 break;
developer84f378f2023-08-24 18:26:50 +0800342@@ -2066,6 +2201,10 @@ int mtk_sw_nat_hook_tx(struct sk_buff *s
developere5e687d2023-08-08 16:05:33 +0800343 entry->ipv6_5t_route.iblk2.dp = gmac_no;
344 }
345
346+#if defined(CONFIG_MEDIATEK_NETSYS_V3)
developerf88469b2023-08-18 16:01:49 +0800347+ hnat_fill_offload_engine_entry(skb, entry, NULL);
developere5e687d2023-08-08 16:05:33 +0800348+#endif
349+
350 bfib1_tx.ttl = 1;
351 bfib1_tx.state = BIND;
352 wmb();
developer84f378f2023-08-24 18:26:50 +0800353@@ -2087,6 +2226,7 @@ int mtk_sw_nat_hook_rx(struct sk_buff *s
developere5e687d2023-08-08 16:05:33 +0800354 }
355
356 skb_hnat_alg(skb) = 0;
357+ skb_hnat_set_tops(skb, 0);
358 skb_hnat_magic_tag(skb) = HNAT_MAGIC_TAG;
359
360 if (skb_hnat_iface(skb) == FOE_MAGIC_WED0)
developer84f378f2023-08-24 18:26:50 +0800361@@ -2535,6 +2675,7 @@ static unsigned int mtk_hnat_nf_post_rou
developere5e687d2023-08-08 16:05:33 +0800362 struct flow_offload_hw_path hw_path = { .dev = (struct net_device*)out,
363 .virt_dev = (struct net_device*)out };
364 const struct net_device *arp_dev = out;
365+ bool is_virt_dev = false;
366
367 if (xlat_toggle && !mtk_464xlat_post_process(skb, out))
368 return 0;
developer973c5bf2023-09-04 13:54:47 +0800369@@ -2551,10 +2692,29 @@ static unsigned int mtk_hnat_nf_post_rou
developere5e687d2023-08-08 16:05:33 +0800370
371 if (out->netdev_ops->ndo_flow_offload_check) {
372 out->netdev_ops->ndo_flow_offload_check(&hw_path);
373+
374 out = (IS_GMAC1_MODE) ? hw_path.virt_dev : hw_path.dev;
developer973c5bf2023-09-04 13:54:47 +0800375+ if (hw_path.flags & FLOW_OFFLOAD_PATH_TNL && mtk_tnl_encap_offload) {
376+ if (ntohs(skb->protocol) == ETH_P_IP
377+ && ip_hdr(skb)->protocol == IPPROTO_TCP) {
378+ skb_hnat_set_tops(skb, hw_path.tnl_type + 1);
379+ } else {
380+ /*
381+ * we are not support protocols other than IPv4 TCP
382+ * for tunnel protocol offload yet
383+ */
384+ skb_hnat_alg(skb) = 1;
385+ return 0;
386+ }
387+ }
developere5e687d2023-08-08 16:05:33 +0800388 }
389
390 if (!IS_LAN_GRP(out) && !IS_WAN(out) && !IS_EXT(out))
391+ is_virt_dev = true;
392+
393+ if (is_virt_dev
394+ && !(skb_hnat_tops(skb) && skb_hnat_is_encap(skb)
395+ && (hw_path.flags & FLOW_OFFLOAD_PATH_TNL)))
396 return 0;
397
398 trace_printk("[%s] case hit, %x-->%s, reason=%x\n", __func__,
developer973c5bf2023-09-04 13:54:47 +0800399@@ -2574,9 +2734,18 @@ static unsigned int mtk_hnat_nf_post_rou
developere5e687d2023-08-08 16:05:33 +0800400 if (fn && !mtk_hnat_accel_type(skb))
401 break;
402
403- if (fn && fn(skb, arp_dev, &hw_path))
404+ if (!is_virt_dev && fn && fn(skb, arp_dev, &hw_path))
405 break;
406
407+ /* skb_hnat_tops(skb) is updated in mtk_tnl_offload() */
408+ if (skb_hnat_tops(skb)) {
409+ if (skb_hnat_is_encap(skb) && !is_virt_dev
410+ && mtk_tnl_encap_offload && mtk_tnl_encap_offload(skb))
411+ break;
412+ if (skb_hnat_is_decap(skb))
413+ break;
414+ }
415+
416 skb_to_hnat_info(skb, out, entry, &hw_path);
417 break;
418 case HIT_BIND_KEEPALIVE_DUP_OLD_HDR:
developer973c5bf2023-09-04 13:54:47 +0800419@@ -2847,7 +3016,7 @@ mtk_hnat_ipv4_nf_local_out(void *priv, s
developere5e687d2023-08-08 16:05:33 +0800420 if (iph->protocol == IPPROTO_IPV6) {
421 entry->udib1.pkt_type = IPV6_6RD;
422 hnat_set_head_frags(state, skb, 0, hnat_set_alg);
423- } else {
424+ } else if (!skb_hnat_tops(skb)) {
425 hnat_set_head_frags(state, skb, 1, hnat_set_alg);
426 }
427
428--- a/drivers/net/ethernet/mediatek/mtk_hnat/nf_hnat_mtk.h
429+++ b/drivers/net/ethernet/mediatek/mtk_hnat/nf_hnat_mtk.h
430@@ -44,7 +44,9 @@ struct hnat_desc {
431 u32 is_sp : 1;
432 u32 hf : 1;
433 u32 amsdu : 1;
434- u32 resv3 : 19;
435+ u32 tops : 6;
436+ u32 is_decap : 1;
437+ u32 resv3 : 12;
438 u32 magic_tag_protect : 16;
439 } __packed;
440 #elif defined(CONFIG_MEDIATEK_NETSYS_RX_V2)
441@@ -91,6 +93,19 @@ struct hnat_desc {
442 ((((skb_headroom(skb) >= FOE_INFO_LEN) ? 1 : 0)))
443
444 #define skb_hnat_info(skb) ((struct hnat_desc *)(skb->head))
445+#if defined(CONFIG_MEDIATEK_NETSYS_V3)
446+#define skb_hnat_tops(skb) (((struct hnat_desc *)((skb)->head))->tops)
447+#define skb_hnat_is_decap(skb) (((struct hnat_desc *)((skb)->head))->is_decap)
448+#define skb_hnat_is_encap(skb) (!skb_hnat_is_decap(skb))
449+#define skb_hnat_set_tops(skb, tops) ((skb_hnat_tops(skb)) = (tops))
450+#define skb_hnat_set_is_decap(skb, is_decap) ((skb_hnat_is_decap(skb)) = (is_decap))
451+#else /* !defined(CONFIG_MEDIATEK_NETSYS_V3) */
452+#define skb_hnat_tops(skb) (0)
453+#define skb_hnat_is_decap(skb) (0)
454+#define skb_hnat_is_encap(skb) (0)
455+#define skb_hnat_set_tops(skb, tops)
456+#define skb_hnat_set_is_decap(skb, is_decap)
457+#endif /* defined(CONFIG_MEDIATEK_NETSYS_V3) */
458 #define skb_hnat_magic(skb) (((struct hnat_desc *)(skb->head))->magic)
459 #define skb_hnat_reason(skb) (((struct hnat_desc *)(skb->head))->crsn)
460 #define skb_hnat_entry(skb) (((struct hnat_desc *)(skb->head))->entry)
461--- a/include/net/netfilter/nf_flow_table.h
462+++ b/include/net/netfilter/nf_flow_table.h
463@@ -98,10 +98,22 @@ struct flow_offload {
464 #define FLOW_OFFLOAD_PATH_6RD BIT(5)
465 #define FLOW_OFFLOAD_PATH_TNL BIT(6)
466
467+enum flow_offload_tnl {
468+ FLOW_OFFLOAD_TNL_GRETAP,
469+ FLOW_OFFLOAD_TNL_PPTP,
470+ FLOW_OFFLOAD_TNL_IP_L2TP,
471+ FLOW_OFFLOAD_TNL_UDP_L2TP_CTRL,
472+ FLOW_OFFLOAD_TNL_UDP_L2TP_DATA,
473+ FLOW_OFFLOAD_VXLAN,
474+ FLOW_OFFLOAD_NATT,
475+ __FLOW_OFFLOAD_MAX,
476+};
477+
478 struct flow_offload_hw_path {
479 struct net_device *dev;
480 struct net_device *virt_dev;
481 u32 flags;
482+ u32 tnl_type;
483
484 u8 eth_src[ETH_ALEN];
485 u8 eth_dest[ETH_ALEN];
486--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
487+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
developerf88469b2023-08-18 16:01:49 +0800488@@ -1874,6 +1874,9 @@ extern const struct of_device_id of_mtk_
developere5e687d2023-08-08 16:05:33 +0800489 extern u32 mtk_hwlro_stats_ebl;
490 extern u32 dbg_show_level;
491
492+/* tunnel offload related */
493+extern struct net_device *(*mtk_get_tnl_dev)(int tnl_idx);
494+
495 /* read the hardware status register */
496 void mtk_stats_update_mac(struct mtk_mac *mac);
497