Skip to content

Commit d6a4b57

Browse files
committed
Merge branch 'dsa-mtu'
Andrew Lunn says: ==================== Adjust MTU of DSA master interface DSA makes use of additional headers to direct a frame in/out of a specific port of the switch. When the slave interfaces uses an MTU of 1500, the master interface can be asked to handle frames with an MTU of 1504, or 1508 bytes. Some Ethernet interfaces won't transmit/receive frames which are bigger than their MTU. Automate the increasing of the MTU on the master interface, by adding to each tagging driver how much overhead they need, and then calling dev_set_mtu() of the master interface to increase its MTU as needed. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 5c327f6 + dc0fe7d commit d6a4b57

File tree

11 files changed

+27
-0
lines changed

11 files changed

+27
-0
lines changed

include/net/dsa.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ struct dsa_device_ops {
113113
struct packet_type *pt);
114114
int (*flow_dissect)(const struct sk_buff *skb, __be16 *proto,
115115
int *offset);
116+
unsigned int overhead;
116117
};
117118

118119
struct dsa_switch_tree {

net/dsa/master.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,24 @@ static void dsa_master_ethtool_teardown(struct net_device *dev)
158158
cpu_dp->orig_ethtool_ops = NULL;
159159
}
160160

161+
void dsa_master_set_mtu(struct net_device *dev, struct dsa_port *cpu_dp)
162+
{
163+
unsigned int mtu = ETH_DATA_LEN + cpu_dp->tag_ops->overhead;
164+
int err;
165+
166+
rtnl_lock();
167+
if (mtu <= dev->max_mtu) {
168+
err = dev_set_mtu(dev, mtu);
169+
if (err)
170+
netdev_dbg(dev, "Unable to set MTU to include for DSA overheads\n");
171+
}
172+
rtnl_unlock();
173+
}
174+
161175
int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
162176
{
177+
dsa_master_set_mtu(dev, cpu_dp);
178+
163179
/* If we use a tagging format that doesn't have an ethertype
164180
* field, make sure that all packets from this point on get
165181
* sent to the tag format's receive function.

net/dsa/tag_brcm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev,
174174
const struct dsa_device_ops brcm_netdev_ops = {
175175
.xmit = brcm_tag_xmit,
176176
.rcv = brcm_tag_rcv,
177+
.overhead = BRCM_TAG_LEN,
177178
};
178179
#endif
179180

@@ -196,5 +197,6 @@ static struct sk_buff *brcm_tag_rcv_prepend(struct sk_buff *skb,
196197
const struct dsa_device_ops brcm_prepend_netdev_ops = {
197198
.xmit = brcm_tag_xmit_prepend,
198199
.rcv = brcm_tag_rcv_prepend,
200+
.overhead = BRCM_TAG_LEN,
199201
};
200202
#endif

net/dsa/tag_dsa.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,5 @@ static struct sk_buff *dsa_rcv(struct sk_buff *skb, struct net_device *dev,
149149
const struct dsa_device_ops dsa_netdev_ops = {
150150
.xmit = dsa_xmit,
151151
.rcv = dsa_rcv,
152+
.overhead = DSA_HLEN,
152153
};

net/dsa/tag_edsa.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,5 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev,
168168
const struct dsa_device_ops edsa_netdev_ops = {
169169
.xmit = edsa_xmit,
170170
.rcv = edsa_rcv,
171+
.overhead = EDSA_HLEN,
171172
};

net/dsa/tag_gswip.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,5 @@ static struct sk_buff *gswip_tag_rcv(struct sk_buff *skb,
106106
const struct dsa_device_ops gswip_netdev_ops = {
107107
.xmit = gswip_tag_xmit,
108108
.rcv = gswip_tag_rcv,
109+
.overhead = GSWIP_RX_HEADER_LEN,
109110
};

net/dsa/tag_ksz.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,5 @@ static struct sk_buff *ksz_rcv(struct sk_buff *skb, struct net_device *dev,
9999
const struct dsa_device_ops ksz_netdev_ops = {
100100
.xmit = ksz_xmit,
101101
.rcv = ksz_rcv,
102+
.overhead = KSZ_INGRESS_TAG_LEN,
102103
};

net/dsa/tag_lan9303.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,5 @@ static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev,
140140
const struct dsa_device_ops lan9303_netdev_ops = {
141141
.xmit = lan9303_xmit,
142142
.rcv = lan9303_rcv,
143+
.overhead = LAN9303_TAG_LEN,
143144
};

net/dsa/tag_mtk.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,5 @@ const struct dsa_device_ops mtk_netdev_ops = {
109109
.xmit = mtk_tag_xmit,
110110
.rcv = mtk_tag_rcv,
111111
.flow_dissect = mtk_tag_flow_dissect,
112+
.overhead = MTK_HDR_LEN,
112113
};

net/dsa/tag_qca.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,5 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev,
101101
const struct dsa_device_ops qca_netdev_ops = {
102102
.xmit = qca_tag_xmit,
103103
.rcv = qca_tag_rcv,
104+
.overhead = QCA_HDR_LEN,
104105
};

net/dsa/tag_trailer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,5 @@ static struct sk_buff *trailer_rcv(struct sk_buff *skb, struct net_device *dev,
8484
const struct dsa_device_ops trailer_netdev_ops = {
8585
.xmit = trailer_xmit,
8686
.rcv = trailer_rcv,
87+
.overhead = 4,
8788
};

0 commit comments

Comments
 (0)