wlan-ap-Telecominfraproject/feeds/qca-wifi-7/ipq53xx/patches-6.1/0451-net-Enable-fast-path-support-for-6RD-DS-Lite.patch
John Crispin 68cf54d9f7 qca-wifi-7: update to ath12.5.5
Signed-off-by: John Crispin <john@phrozen.org>
2025-02-27 12:45:52 +01:00

135 lines
4.5 KiB
Diff

From 7597bff7a41974d1b9848f17e7dc51456806ecd1 Mon Sep 17 00:00:00 2001
From: Murat Sezgin <quic_msezgin@quicinc.com>
Date: Tue, 20 Jun 2023 13:19:29 -0700
Subject: [PATCH] net: Enable fast path support for 6RD, DS-Lite
1). Added stats update function
2). Added changes to set the skb->skb_iif to tunnel dev
Change-Id: I7f43746436b4f6483952997fdf91180096d3ed62
Signed-off-by: Shyam Sunder <ssunde@codeaurora.org>
Signed-off-by: Murat Sezgin <msezgin@codeaurora.org>
Signed-off-by: John Sanli <quic_jsanli@quicinc.com>
Signed-off-by: Pavithra R <quic_pavir@quicinc.com>
---
net/ipv4/ip_tunnel_core.c | 2 +-
net/ipv6/ip6_tunnel.c | 24 +++++++++++++++++++++++-
net/ipv6/sit.c | 18 ++++++++++++++++++
3 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
index 71dfac0c0d64..a0fd98c561c6 100644
--- a/net/ipv4/ip_tunnel_core.c
+++ b/net/ipv4/ip_tunnel_core.c
@@ -61,7 +61,7 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
int skb_iif;
/* Save input interface index */
- skb_iif = skb->skb_iif;
+ skb_iif = skb->skb_iif;
skb_scrub_packet(skb, xnet);
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 8f3ee2ae7e19..43eda4945e1e 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -100,6 +100,23 @@ static inline int ip6_tnl_mpls_supported(void)
#define for_each_ip6_tunnel_rcu(start) \
for (t = rcu_dereference(start); t; t = rcu_dereference(t->next))
+/*
+ * Update offload stats
+ */
+void ip6_update_offload_stats(struct net_device *dev, void *ptr)
+{
+ struct pcpu_sw_netstats *tstats = per_cpu_ptr(dev->tstats, 0);
+ const struct pcpu_sw_netstats *offload_stats =
+ (struct pcpu_sw_netstats *)ptr;
+
+ u64_stats_update_begin(&tstats->syncp);
+ u64_stats_add(&tstats->tx_packets, u64_stats_read(&offload_stats->tx_packets));
+ u64_stats_add(&tstats->tx_bytes, u64_stats_read(&offload_stats->tx_bytes));
+ u64_stats_add(&tstats->rx_packets, u64_stats_read(&offload_stats->rx_packets));
+ u64_stats_add(&tstats->rx_bytes, u64_stats_read(&offload_stats->rx_bytes));
+ u64_stats_update_end(&tstats->syncp);
+}
+
/**
* ip6_tnl_lookup - fetch tunnel matching the end-point addresses
* @net: network namespace
@@ -1009,6 +1026,9 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
if (tun_dst)
skb_dst_set(skb, (struct dst_entry *)tun_dst);
+ /* Reset the skb_iif to Tunnels interface index */
+ skb->skb_iif = tunnel->dev->ifindex;
+
gro_cells_receive(&tunnel->gro_cells, skb);
return 0;
@@ -1090,7 +1110,6 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,
rcu_read_unlock();
return ret;
-
drop:
rcu_read_unlock();
kfree_skb(skb);
@@ -1410,6 +1429,9 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
ipv6h->nexthdr = proto;
ipv6h->saddr = fl6->saddr;
ipv6h->daddr = fl6->daddr;
+
+ /* Reset the skb_iif to Tunnels interface index */
+ skb->skb_iif = dev->ifindex;
ip6tunnel_xmit(NULL, skb, dev);
return 0;
tx_err_link_failure:
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 3ffb6a5b1f82..62b09bd65395 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -90,6 +90,20 @@ static inline struct sit_net *dev_to_sit_net(struct net_device *dev)
return net_generic(t->net, sit_net_id);
}
+void ipip6_update_offload_stats(struct net_device *dev, void *ptr)
+{
+ struct pcpu_sw_netstats *tstats = per_cpu_ptr(dev->tstats, 0);
+ const struct pcpu_sw_netstats *offload_stats =
+ (struct pcpu_sw_netstats *)ptr;
+
+ u64_stats_update_begin(&tstats->syncp);
+ u64_stats_add(&tstats->tx_packets, u64_stats_read(&offload_stats->tx_packets));
+ u64_stats_add(&tstats->tx_bytes, u64_stats_read(&offload_stats->tx_bytes));
+ u64_stats_add(&tstats->rx_packets, u64_stats_read(&offload_stats->rx_packets));
+ u64_stats_add(&tstats->rx_bytes, u64_stats_read(&offload_stats->rx_bytes));
+ u64_stats_update_end(&tstats->syncp);
+}
+
/*
* Must be invoked with rcu_read_lock
*/
@@ -722,6 +736,8 @@ static int ipip6_rcv(struct sk_buff *skb)
dev_sw_netstats_rx_add(tunnel->dev, skb->len);
+ /* Reset the skb_iif to Tunnels interface index */
+ skb->skb_iif = tunnel->dev->ifindex;
netif_rx(skb);
return 0;
@@ -1031,6 +1047,8 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
skb_set_inner_ipproto(skb, IPPROTO_IPV6);
+ /* Reset the skb_iif to Tunnels interface index */
+ skb->skb_iif = tunnel->dev->ifindex;
iptunnel_xmit(NULL, rt, skb, fl4.saddr, fl4.daddr, protocol, tos, ttl,
df, !net_eq(tunnel->net, dev_net(dev)));
return NETDEV_TX_OK;
--
2.34.1