[][openwrt][mt7988][crypto][Refactor to unify EIP driver]
[Description]
Refactor to unify EIP driver.
1. Sync CAPWAP-DTLS functions for TOPS from neptune/eip_driver
2. Decoupled with hnat, IPSec inline mode is available even when hnat is
not activated now.
[Release-log]
N/A
Change-Id: Id53b483924fb90bc784570545b37e67e860a6024
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8868628
diff --git a/feed/kernel/crypto-eip/src/xfrm-offload.c b/feed/kernel/crypto-eip/src/xfrm-offload.c
index 28f4555..4954acc 100644
--- a/feed/kernel/crypto-eip/src/xfrm-offload.c
+++ b/feed/kernel/crypto-eip/src/xfrm-offload.c
@@ -9,8 +9,11 @@
#include <linux/bitops.h>
#include <mtk_eth_soc.h>
+
+#if IS_ENABLED(CONFIG_NET_MEDIATEK_HNAT)
#include <mtk_hnat/hnat.h>
#include <mtk_hnat/nf_hnat_mtk.h>
+#endif // HNAT
#include <pce/cdrt.h>
#include <pce/cls.h>
@@ -26,6 +29,9 @@
static LIST_HEAD(xfrm_params_head);
+#if IS_ENABLED(CONFIG_NET_MEDIATEK_HNAT)
+extern int (*ra_sw_nat_hook_tx)(struct sk_buff *skb, int gmac_no);
+
static inline bool is_tops_udp_tunnel(struct sk_buff *skb)
{
return skb_hnat_tops(skb) && (ntohs(skb->protocol) == ETH_P_IP) &&
@@ -41,6 +47,7 @@
{
return is_magic_tag_valid(skb) && (skb_hnat_reason(skb) == HIT_UNBIND_RATE_REACH);
}
+#endif // HNAT
static void mtk_xfrm_offload_cdrt_tear_down(struct mtk_xfrm_params *xfrm_params)
{
@@ -341,19 +348,26 @@
rcu_read_unlock_bh();
xfrm_params = (struct mtk_xfrm_params *)xs->xso.offload_handle;
- skb_hnat_cdrt(skb) = xfrm_params->cdrt->idx;
+#if IS_ENABLED(CONFIG_NET_MEDIATEK_HNAT)
+ skb_hnat_cdrt(skb) = xfrm_params->cdrt->idx;
/*
* EIP197 does not support fragmentation. As a result, we can not bind UDP
* flow since it may cause network fail due to fragmentation
*/
- if ((is_tops_udp_tunnel(skb) || is_tcp(skb)) && is_hnat_rate_reach(skb))
+ if (ra_sw_nat_hook_tx &&
+ ((is_tops_udp_tunnel(skb) || is_tcp(skb)) && is_hnat_rate_reach(skb)))
hnat_bind_crypto_entry(skb, dst->dev);
- /* Since we're going to tx directly, set skb->dev to dst->dev */
- skb->dev = dst->dev;
/* Set magic tag for tport setting, reset to 0 after tport is set */
skb_hnat_magic_tag(skb) = HNAT_MAGIC_TAG;
+#else
+ skb_tnl_cdrt(skb) = xfrm_params->cdrt->idx;
+ skb_tnl_magic_tag(skb) = TNL_MAGIC_TAG;
+#endif // HNAT
+
+ /* Since we're going to tx directly, set skb->dev to dst->dev */
+ skb->dev = dst->dev;
/*
* Since skb headroom may not be copy when segment, we cannot rely on