Skip to content

Commit 5329022

Browse files
dangowrtfrank-w
authored andcommitted
tag_mxl862xx*: remove support for older kernel versions
to be squashed into the previous commit before upstream submission
1 parent baeb90e commit 5329022

File tree

2 files changed

+0
-152
lines changed

2 files changed

+0
-152
lines changed

net/dsa/tag_mxl862xx.c

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,7 @@
2424
#include <linux/etherdevice.h>
2525
#include <linux/skbuff.h>
2626
#include <net/dsa.h>
27-
28-
#ifndef LINUX_VERSION_CODE
29-
#include <linux/version.h>
30-
#else
31-
#define KERNEL_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
32-
#endif
33-
34-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
35-
#include "dsa_priv.h"
36-
#else
3727
#include "tag.h"
38-
#endif
3928

4029
#define MXL862_NAME "mxl862xx"
4130

@@ -59,14 +48,7 @@
5948
static struct sk_buff *mxl862_tag_xmit(struct sk_buff *skb,
6049
struct net_device *dev)
6150
{
62-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
63-
int err;
64-
#endif
65-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0))
66-
struct dsa_port *dp = dsa_slave_to_port(dev);
67-
#else
6851
struct dsa_port *dp = dsa_user_to_port(dev);
69-
#endif
7052
struct dsa_port *cpu_dp = dp->cpu_dp;
7153
unsigned int cpu_port = cpu_dp->index + 1;
7254
unsigned int usr_port = dp->index + 1;
@@ -76,12 +58,6 @@ static struct sk_buff *mxl862_tag_xmit(struct sk_buff *skb,
7658
if (skb == NULL)
7759
return skb;
7860

79-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
80-
err = skb_cow_head(skb, MXL862_TX_HEADER_LEN);
81-
if (err)
82-
return NULL;
83-
#endif
84-
8561
/* provide additional space 'MXL862_TX_HEADER_LEN' bytes */
8662
skb_push(skb, MXL862_TX_HEADER_LEN);
8763

@@ -103,20 +79,11 @@ static struct sk_buff *mxl862_tag_xmit(struct sk_buff *skb,
10379
return skb;
10480
}
10581

106-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0))
107-
static struct sk_buff *mxl862_tag_rcv(struct sk_buff *skb,
108-
struct net_device *dev,
109-
struct packet_type *pt)
110-
#else
11182
static struct sk_buff *mxl862_tag_rcv(struct sk_buff *skb,
11283
struct net_device *dev)
113-
#endif
11484
{
11585
int port;
11686
u8 *mxl862_tag;
117-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
118-
struct dsa_port *dp;
119-
#endif
12087

12188
if (unlikely(!pskb_may_pull(skb, MXL862_RX_HEADER_LEN))) {
12289
dev_warn_ratelimited(&dev->dev,
@@ -142,11 +109,7 @@ static struct sk_buff *mxl862_tag_rcv(struct sk_buff *skb,
142109
/* Get source port information */
143110
port = (mxl862_tag[7] & MXL862_IGP_EGP_MASK) >> MXL862_IGP_EGP_SHIFT;
144111
port = port - 1;
145-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0))
146-
skb->dev = dsa_master_find_slave(dev, 0, port);
147-
#else
148112
skb->dev = dsa_conduit_find_user(dev, 0, port);
149-
#endif
150113
if (!skb->dev) {
151114
dev_warn_ratelimited(
152115
&dev->dev,
@@ -164,44 +127,20 @@ static struct sk_buff *mxl862_tag_rcv(struct sk_buff *skb,
164127
skb_pull_rcsum(skb, MXL862_RX_HEADER_LEN);
165128
memmove(skb->data - ETH_HLEN,
166129
skb->data - (ETH_HLEN + MXL862_RX_HEADER_LEN), 2 * ETH_ALEN);
167-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
168-
dp = dsa_slave_to_port(skb->dev);
169-
if (dp->bridge_dev)
170-
skb->offload_fwd_mark = 1;
171-
#else
172130
dsa_default_offload_fwd_mark(skb);
173-
#endif
174131

175132
return skb;
176133
}
177134

178-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0))
179-
const struct dsa_device_ops mxl862_netdev_ops = {
180-
.xmit = mxl862_tag_xmit,
181-
.rcv = mxl862_tag_rcv,
182-
};
183-
#else
184-
185135
static const struct dsa_device_ops mxl862_netdev_ops = {
186136
.name = "mxl862",
187137
.proto = DSA_TAG_PROTO_MXL862,
188138
.xmit = mxl862_tag_xmit,
189139
.rcv = mxl862_tag_rcv,
190-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0))
191-
.overhead = MXL862_RX_HEADER_LEN,
192-
#else
193140
.needed_headroom = MXL862_RX_HEADER_LEN,
194-
#endif
195141
};
196142

197143
MODULE_LICENSE("GPL");
198-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
199-
MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_MXL862);
200-
#else
201144
MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_MXL862, MXL862_NAME);
202-
#endif
203-
204145
module_dsa_tag_driver(mxl862_netdev_ops);
205-
#endif
206146

207-
MODULE_LICENSE("GPL");

net/dsa/tag_mxl862xx_8021q.c

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,9 @@
2020
*
2121
*/
2222

23-
#ifndef LINUX_VERSION_CODE
24-
#include <linux/version.h>
25-
#else
26-
#define KERNEL_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
27-
#endif
28-
2923
#include <linux/dsa/8021q.h>
30-
#if (LINUX_VERSION_CODE > KERNEL_VERSION(6, 1, 0))
3124
#include "tag_8021q.h"
32-
#endif
33-
#include <net/dsa.h>
34-
35-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
36-
#include "dsa_priv.h"
37-
#else
3825
#include "tag.h"
39-
#endif
4026

4127

4228
#define MXL862_NAME "mxl862xx"
@@ -53,58 +39,12 @@
5339

5440
/* special tag in TX path header */
5541

56-
#if (LINUX_VERSION_CODE < KERNEL_VERSION (5, 14, 0))
57-
static void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id)
58-
{
59-
u16 vid, tci;
60-
61-
skb_push_rcsum(skb, ETH_HLEN);
62-
if (skb_vlan_tag_present(skb)) {
63-
tci = skb_vlan_tag_get(skb);
64-
__vlan_hwaccel_clear_tag(skb);
65-
} else {
66-
__skb_vlan_pop(skb, &tci);
67-
}
68-
skb_pull_rcsum(skb, ETH_HLEN);
69-
70-
vid = tci & VLAN_VID_MASK;
71-
72-
*source_port = dsa_8021q_rx_source_port(vid);
73-
*switch_id = dsa_8021q_rx_switch_id(vid);
74-
skb->priority = (tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT;
75-
}
76-
77-
/* If the ingress port offloads the bridge, we mark the frame as autonomously
78-
* forwarded by hardware, so the software bridge doesn't forward in twice, back
79-
* to us, because we already did. However, if we're in fallback mode and we do
80-
* software bridging, we are not offloading it, therefore the dp->bridge_dev
81-
* pointer is not populated, and flooding needs to be done by software (we are
82-
* effectively operating in standalone ports mode).
83-
*/
84-
static inline void dsa_default_offload_fwd_mark(struct sk_buff *skb)
85-
{
86-
struct dsa_port *dp = dsa_slave_to_port(skb->dev);
87-
88-
skb->offload_fwd_mark = !!(dp->bridge_dev);
89-
}
90-
#endif
91-
9242
static struct sk_buff *mxl862_8021q_tag_xmit(struct sk_buff *skb,
9343
struct net_device *dev)
9444
{
95-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0))
96-
struct dsa_port *dp = dsa_slave_to_port(dev);
97-
#else
9845
struct dsa_port *dp = dsa_user_to_port(dev);
99-
#endif
10046

101-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0))
102-
u16 tx_vid = dsa_8021q_tx_vid(dp->ds, dp->index);
103-
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0))
104-
u16 tx_vid = dsa_tag_8021q_tx_vid(dp);
105-
#else
10647
u16 tx_vid = dsa_tag_8021q_standalone_vid(dp);
107-
#endif
10848
u16 queue_mapping = skb_get_queue_mapping(skb);
10949
u8 pcp = netdev_txq_to_tc(dev, queue_mapping);
11050

@@ -114,36 +54,20 @@ static struct sk_buff *mxl862_8021q_tag_xmit(struct sk_buff *skb,
11454
return skb;
11555
}
11656

117-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0))
118-
static struct sk_buff *mxl862_8021q_tag_rcv(struct sk_buff *skb,
119-
struct net_device *dev,
120-
struct packet_type *pt)
121-
#else
12257
static struct sk_buff *mxl862_8021q_tag_rcv(struct sk_buff *skb,
12358
struct net_device *dev)
124-
#endif
12559
{
12660
int src_port = -1;
12761
int switch_id = -1;
12862

12963
/* removes Outer VLAN tag */
130-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0))
131-
dsa_8021q_rcv(skb, &src_port, &switch_id);
132-
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0))
133-
dsa_8021q_rcv(skb, &src_port, &switch_id, NULL);
134-
#else
13564
dsa_8021q_rcv(skb, &src_port, &switch_id, NULL, NULL);
136-
#endif
13765
if (src_port == -1 || switch_id == -1) {
13866
dev_warn_ratelimited(&dev->dev, "Dropping packet due to invalid outer 802.1Q tag: switch %d port %d\n", switch_id, src_port);
13967
return NULL;
14068
}
14169

142-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0))
143-
skb->dev = dsa_master_find_slave(dev, switch_id, src_port);
144-
#else
14570
skb->dev = dsa_conduit_find_user(dev, switch_id, src_port);
146-
#endif
14771
if (!skb->dev) {
14872
dev_warn_ratelimited(&dev->dev, "Dropping packet due to invalid source port: %d\n", src_port);
14973
return NULL;
@@ -159,25 +83,10 @@ static const struct dsa_device_ops mxl862_8021q_netdev_ops = {
15983
.proto = DSA_TAG_PROTO_MXL862_8021Q,
16084
.xmit = mxl862_8021q_tag_xmit,
16185
.rcv = mxl862_8021q_tag_rcv,
162-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0))
163-
.overhead = VLAN_HLEN,
164-
#else
16586
.needed_headroom = VLAN_HLEN,
166-
#endif
167-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0) && \
168-
LINUX_VERSION_CODE > KERNEL_VERSION(5, 10, 0))
169-
.promisc_on_master = true,
170-
#elif (LINUX_VERSION_CODE > KERNEL_VERSION(6, 7, 0))
17187
.promisc_on_conduit = true,
172-
#endif
17388
};
17489

175-
17690
MODULE_LICENSE("GPL");
177-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
178-
MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_MXL862_8021Q);
179-
#else
18091
MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_MXL862_8021Q, MXL862_NAME);
181-
#endif
182-
18392
module_dsa_tag_driver(mxl862_8021q_netdev_ops);

0 commit comments

Comments
 (0)