Skip to content

Commit dd8e605

Browse files
aryansrivastava-atlcarlgsmith
authored andcommitted
linux: update for 6.12 compatibility
Update ipt_netmap driver to be resilient from kernel upgrades, along with dsa shortcut being updated with new struct member name. Also regenerate the mvpp2 patch for the 6.12 kernel.
1 parent 6c08ee1 commit dd8e605

4 files changed

Lines changed: 131 additions & 1 deletion

File tree

File renamed without changes.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
diff --git a/mvpp2/mvpp2_main.c b/mvpp2/mvpp2_main.c
2+
index 3880dcc0418b..3ea0c4928921 100644
3+
--- a/mvpp2/mvpp2_main.c
4+
+++ b/mvpp2/mvpp2_main.c
5+
@@ -43,6 +43,10 @@
6+
#include "mvpp2_prs.h"
7+
#include "mvpp2_cls.h"
8+
9+
+#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE)
10+
+#include <mvpp2_netmap.h>
11+
+#endif
12+
+
13+
enum mvpp2_bm_pool_log_num {
14+
MVPP2_BM_SHORT,
15+
MVPP2_BM_LONG,
16+
@@ -687,7 +691,7 @@ static int mvpp2_bm_init(struct device *dev, struct mvpp2 *priv)
17+
}
18+
19+
/* Allocate and initialize BM pools */
20+
- priv->bm_pools = devm_kcalloc(dev, poolnum,
21+
+ priv->bm_pools = devm_kcalloc(dev, MVPP2_BM_MAX_POOLS,
22+
sizeof(*priv->bm_pools), GFP_KERNEL);
23+
if (!priv->bm_pools)
24+
return -ENOMEM;
25+
@@ -1460,7 +1464,11 @@ static void mvpp2_interrupts_unmask(void *arg)
26+
27+
val = MVPP2_CAUSE_MISC_SUM_MASK |
28+
MVPP2_CAUSE_RXQ_OCCUP_DESC_ALL_MASK(port->priv->hw_version);
29+
+#ifdef CONFIG_NETMAP
30+
+ if (port->has_tx_irqs && !nm_netmap_on(NA(port->dev)))
31+
+#else
32+
if (port->has_tx_irqs)
33+
+#endif
34+
val |= MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_MASK;
35+
36+
mvpp2_thread_write(port->priv, thread,
37+
@@ -2987,7 +2995,11 @@ static int mvpp2_rxq_init(struct mvpp2_port *port,
38+
put_cpu();
39+
40+
/* Set Offset */
41+
+#ifdef CONFIG_NETMAP
42+
+ mvpp2_netmap_rxq_offset_set(port, rxq->id);
43+
+#else
44+
mvpp2_rxq_offset_set(port, rxq->id, MVPP2_SKB_HEADROOM);
45+
+#endif
46+
47+
/* Set coalescing pkts and time */
48+
mvpp2_rx_pkts_coal_set(port, rxq);
49+
@@ -3377,6 +3389,11 @@ static irqreturn_t mvpp2_isr(int irq, void *dev_id)
50+
{
51+
struct mvpp2_queue_vector *qv = dev_id;
52+
53+
+#ifdef CONFIG_NETMAP
54+
+ if (mvpp2_netmap_rx_irq(qv))
55+
+ return IRQ_HANDLED;
56+
+#endif /* DEV_NETMAP */
57+
+
58+
mvpp2_qvec_interrupt_disable(qv);
59+
60+
napi_schedule(&qv->napi);
61+
@@ -4394,6 +4411,12 @@ static netdev_tx_t mvpp2_tx(struct sk_buff *skb, struct net_device *dev)
62+
}
63+
frags = skb_shinfo(skb)->nr_frags + 1;
64+
65+
+#ifdef CONFIG_NETMAP
66+
+ /* Process all TX queues on this port for this thread/core */
67+
+ if (port->has_tx_irqs && nm_netmap_on(NA(dev))) {
68+
+ mvpp2_tx_done(port, ((1 << port->ntxqs) - 1), thread);
69+
+ }
70+
+#endif
71+
/* Check number of available descriptors */
72+
if (mvpp2_aggr_desc_num_check(port, aggr_txq, frags) ||
73+
mvpp2_txq_reserved_desc_num_proc(port, txq, txq_pcpu, frags)) {
74+
@@ -5778,7 +5801,11 @@ static const struct net_device_ops mvpp2_netdev_ops = {
75+
.ndo_start_xmit = mvpp2_tx,
76+
.ndo_set_rx_mode = mvpp2_set_rx_mode,
77+
.ndo_set_mac_address = mvpp2_set_mac_address,
78+
+#ifdef CONFIG_NETMAP
79+
+ .ndo_change_mtu = mvpp2_netmap_change_mtu,
80+
+#else
81+
.ndo_change_mtu = mvpp2_change_mtu,
82+
+#endif
83+
.ndo_get_stats64 = mvpp2_get_stats64,
84+
.ndo_eth_ioctl = mvpp2_ioctl,
85+
.ndo_vlan_rx_add_vid = mvpp2_vlan_rx_add_vid,
86+
@@ -7088,6 +7115,9 @@ static void mvpp2_port_remove(struct mvpp2_port *port)
87+
{
88+
int i;
89+
90+
+#ifdef CONFIG_NETMAP
91+
+ mvpp2_netmap_detach(port);
92+
+#endif /* CONFIG_NETMAP */
93+
unregister_netdev(port->dev);
94+
if (port->phylink)
95+
phylink_destroy(port->phylink);
96+
@@ -7691,6 +7721,14 @@ static int mvpp2_probe(struct platform_device *pdev)
97+
mvpp2_dbgfs_init(priv, pdev->name);
98+
99+
platform_set_drvdata(pdev, priv);
100+
+#ifdef CONFIG_NETMAP
101+
+ i = 0;
102+
+ device_for_each_child_node_scoped(&pdev->dev, port_fwnode) {
103+
+ if (priv->port_list[i])
104+
+ mvpp2_netmap_attach(priv->port_list[i]);
105+
+ i++;
106+
+ }
107+
+#endif /* CONFIG_NETMAP */
108+
return 0;
109+
110+
err_port_probe:

LINUX/ipt_netmap/ipt_netmap.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
#endif
3030
#include "ipt_netmap.h"
3131

32+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
33+
#include <net/hotdata.h>
34+
#define netdev_max_backlog net_hotdata.max_backlog
35+
#endif
36+
3237
MODULE_LICENSE("GPL");
3338
MODULE_AUTHOR("Sheena Mira-ato");
3439
MODULE_DESCRIPTION("A loadable kernel module that adds an NMRING target for iptables");
@@ -133,7 +138,11 @@ static bool ipt_ipv4_route(struct net *net, struct sk_buff *skb)
133138

134139
#ifdef CONFIG_XFRM
135140
if (!(IPCB(skb)->flags & IPSKB_XFRM_TRANSFORMED) &&
141+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,7,0)
142+
xfrm_decode_session(net, skb, flowi4_to_flowi(&fl4), AF_INET) == 0) {
143+
#else
136144
xfrm_decode_session(skb, flowi4_to_flowi(&fl4), AF_INET) == 0) {
145+
#endif
137146
struct dst_entry *dst = skb_dst(skb);
138147
skb_dst_set(skb, NULL);
139148
dst = xfrm_lookup(net, dst, flowi4_to_flowi(&fl4), skb->sk, 0);
@@ -171,7 +180,11 @@ static bool ipt_ipv6_route(struct net *net, struct sk_buff *skb)
171180

172181
#ifdef CONFIG_XFRM
173182
if (!(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) &&
183+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,7,0)
184+
xfrm_decode_session(net, skb, flowi6_to_flowi(&fl6), AF_INET6) == 0) {
185+
#else
174186
xfrm_decode_session(skb, flowi6_to_flowi(&fl6), AF_INET6) == 0) {
187+
#endif
175188
skb_dst_set(skb, NULL);
176189
dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), skb->sk, 0);
177190
if (IS_ERR(dst))
@@ -885,7 +898,9 @@ static unsigned int nmring_tg6(struct sk_buff *skb,
885898
return NF_STOLEN;
886899
}
887900
else if ((skb->len > mtu)||
901+
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,7,0)
888902
(skb_dst(skb) && dst_allfrag(skb_dst(skb))) ||
903+
#endif
889904
(IP6CB(skb)->frag_max_size &&
890905
skb->len > IP6CB(skb)->frag_max_size)) {
891906
if (skb_dst(skb)) {
@@ -1032,7 +1047,7 @@ static struct pernet_operations ipt_netmap_net_ops = {
10321047
.pre_exit = ipt_netmap_net_exit,
10331048
#endif
10341049
.id = &ipt_netmap_net_id,
1035-
.size = 0,
1050+
.size = sizeof(struct ipt_netmap_priv),
10361051
};
10371052

10381053
static int __init nmring_tg_init(void)

LINUX/netmap_linux.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#ifdef ATL_CHANGE
4040
#include <uapi/linux/if_arp.h>
4141
#include <net/dsa.h>
42+
#include <linux/version.h>
4243
#endif
4344
#include <net/pkt_sched.h>
4445
#include <net/sch_generic.h>
@@ -490,7 +491,11 @@ nm_os_send_up(struct ifnet *ifp, struct mbuf *m, struct mbuf *prev)
490491
skb_pull_rcsum(m, 4);
491492
memmove(m->data - ETH_HLEN, m->data - ETH_HLEN - 4, 2 * ETH_ALEN);
492493
skb_push(m, ETH_HLEN);
494+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,7,0)
495+
m->dev = dp->user;
496+
#else
493497
m->dev = dp->slave;
498+
#endif
494499
m->pkt_type = PACKET_HOST;
495500
m->protocol = eth_type_trans(m, m->dev);
496501
skb_set_l2_port_ifindex(m, m->dev->ifindex);

0 commit comments

Comments
 (0)