* [PATCH net-next 0/2] Adjust MTU of DSA master interface
@ 2018-12-06 10:36 Andrew Lunn
2018-12-06 10:36 ` [PATCH net-next 1/2] net: dsa: Add overhead to tag protocol ops Andrew Lunn
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Andrew Lunn @ 2018-12-06 10:36 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Florian Fainelli, Vivien Didelot, Andrew Lunn
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.
Andrew Lunn (2):
net: dsa: Add overhead to tag protocol ops.
net: dsa: Set the master device's MTU to account for DSA overheads
include/net/dsa.h | 1 +
net/dsa/master.c | 16 ++++++++++++++++
net/dsa/tag_brcm.c | 2 ++
net/dsa/tag_dsa.c | 1 +
net/dsa/tag_edsa.c | 1 +
net/dsa/tag_gswip.c | 1 +
net/dsa/tag_ksz.c | 1 +
net/dsa/tag_lan9303.c | 1 +
net/dsa/tag_mtk.c | 1 +
net/dsa/tag_qca.c | 1 +
net/dsa/tag_trailer.c | 1 +
11 files changed, 27 insertions(+)
--
2.19.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH net-next 1/2] net: dsa: Add overhead to tag protocol ops. 2018-12-06 10:36 [PATCH net-next 0/2] Adjust MTU of DSA master interface Andrew Lunn @ 2018-12-06 10:36 ` Andrew Lunn 2018-12-06 10:36 ` [PATCH net-next 2/2] net: dsa: Set the master device's MTU to account for DSA overheads Andrew Lunn 2018-12-06 20:18 ` [PATCH net-next 0/2] Adjust MTU of DSA master interface David Miller 2 siblings, 0 replies; 8+ messages in thread From: Andrew Lunn @ 2018-12-06 10:36 UTC (permalink / raw) To: David Miller; +Cc: netdev, Florian Fainelli, Vivien Didelot, Andrew Lunn Each DSA tag protocol needs to add additional headers to the Ethernet frame in order to direct it towards a specific switch egress port. It must also remove the head from a frame received from a switch. Indicate the maximum size of these headers in the tag protocol ops structure, so the core can take these overheads into account. Signed-off-by: Andrew Lunn <andrew@lunn.ch> --- include/net/dsa.h | 1 + net/dsa/tag_brcm.c | 2 ++ net/dsa/tag_dsa.c | 1 + net/dsa/tag_edsa.c | 1 + net/dsa/tag_gswip.c | 1 + net/dsa/tag_ksz.c | 1 + net/dsa/tag_lan9303.c | 1 + net/dsa/tag_mtk.c | 1 + net/dsa/tag_qca.c | 1 + net/dsa/tag_trailer.c | 1 + 10 files changed, 11 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index 23690c44e167..6ee2e24e0a6e 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -113,6 +113,7 @@ struct dsa_device_ops { struct packet_type *pt); int (*flow_dissect)(const struct sk_buff *skb, __be16 *proto, int *offset); + unsigned int overhead; }; struct dsa_switch_tree { diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c index 2b06bb91318b..4aa1d368a5ae 100644 --- a/net/dsa/tag_brcm.c +++ b/net/dsa/tag_brcm.c @@ -174,6 +174,7 @@ static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev, const struct dsa_device_ops brcm_netdev_ops = { .xmit = brcm_tag_xmit, .rcv = brcm_tag_rcv, + .overhead = BRCM_TAG_LEN, }; #endif @@ -196,5 +197,6 @@ static struct sk_buff *brcm_tag_rcv_prepend(struct sk_buff *skb, const struct dsa_device_ops brcm_prepend_netdev_ops = { .xmit = brcm_tag_xmit_prepend, .rcv = brcm_tag_rcv_prepend, + .overhead = BRCM_TAG_LEN, }; #endif diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c index cd13cfc542ce..8b2f92e3f3a2 100644 --- a/net/dsa/tag_dsa.c +++ b/net/dsa/tag_dsa.c @@ -149,4 +149,5 @@ static struct sk_buff *dsa_rcv(struct sk_buff *skb, struct net_device *dev, const struct dsa_device_ops dsa_netdev_ops = { .xmit = dsa_xmit, .rcv = dsa_rcv, + .overhead = DSA_HLEN, }; diff --git a/net/dsa/tag_edsa.c b/net/dsa/tag_edsa.c index 4083326b806e..f5b87ee5c94e 100644 --- a/net/dsa/tag_edsa.c +++ b/net/dsa/tag_edsa.c @@ -168,4 +168,5 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev, const struct dsa_device_ops edsa_netdev_ops = { .xmit = edsa_xmit, .rcv = edsa_rcv, + .overhead = EDSA_HLEN, }; diff --git a/net/dsa/tag_gswip.c b/net/dsa/tag_gswip.c index 49e9b73f1be3..cb6f82ffe5eb 100644 --- a/net/dsa/tag_gswip.c +++ b/net/dsa/tag_gswip.c @@ -106,4 +106,5 @@ static struct sk_buff *gswip_tag_rcv(struct sk_buff *skb, const struct dsa_device_ops gswip_netdev_ops = { .xmit = gswip_tag_xmit, .rcv = gswip_tag_rcv, + .overhead = GSWIP_RX_HEADER_LEN, }; diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c index 0f62effad88f..96411f70ab9f 100644 --- a/net/dsa/tag_ksz.c +++ b/net/dsa/tag_ksz.c @@ -99,4 +99,5 @@ static struct sk_buff *ksz_rcv(struct sk_buff *skb, struct net_device *dev, const struct dsa_device_ops ksz_netdev_ops = { .xmit = ksz_xmit, .rcv = ksz_rcv, + .overhead = KSZ_INGRESS_TAG_LEN, }; diff --git a/net/dsa/tag_lan9303.c b/net/dsa/tag_lan9303.c index 548c00254c07..f48889e46ff7 100644 --- a/net/dsa/tag_lan9303.c +++ b/net/dsa/tag_lan9303.c @@ -140,4 +140,5 @@ static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev, const struct dsa_device_ops lan9303_netdev_ops = { .xmit = lan9303_xmit, .rcv = lan9303_rcv, + .overhead = LAN9303_TAG_LEN, }; diff --git a/net/dsa/tag_mtk.c b/net/dsa/tag_mtk.c index 11535bc70743..f39f4dfeda34 100644 --- a/net/dsa/tag_mtk.c +++ b/net/dsa/tag_mtk.c @@ -109,4 +109,5 @@ const struct dsa_device_ops mtk_netdev_ops = { .xmit = mtk_tag_xmit, .rcv = mtk_tag_rcv, .flow_dissect = mtk_tag_flow_dissect, + .overhead = MTK_HDR_LEN, }; diff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c index 613f4ee97771..ed4f6dc26365 100644 --- a/net/dsa/tag_qca.c +++ b/net/dsa/tag_qca.c @@ -101,4 +101,5 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev, const struct dsa_device_ops qca_netdev_ops = { .xmit = qca_tag_xmit, .rcv = qca_tag_rcv, + .overhead = QCA_HDR_LEN, }; diff --git a/net/dsa/tag_trailer.c b/net/dsa/tag_trailer.c index 56197f0d9608..b40756ed6e57 100644 --- a/net/dsa/tag_trailer.c +++ b/net/dsa/tag_trailer.c @@ -84,4 +84,5 @@ static struct sk_buff *trailer_rcv(struct sk_buff *skb, struct net_device *dev, const struct dsa_device_ops trailer_netdev_ops = { .xmit = trailer_xmit, .rcv = trailer_rcv, + .overhead = 4, }; -- 2.19.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 2/2] net: dsa: Set the master device's MTU to account for DSA overheads 2018-12-06 10:36 [PATCH net-next 0/2] Adjust MTU of DSA master interface Andrew Lunn 2018-12-06 10:36 ` [PATCH net-next 1/2] net: dsa: Add overhead to tag protocol ops Andrew Lunn @ 2018-12-06 10:36 ` Andrew Lunn 2018-12-06 20:21 ` Florian Fainelli 2018-12-06 22:14 ` Stephen Hemminger 2018-12-06 20:18 ` [PATCH net-next 0/2] Adjust MTU of DSA master interface David Miller 2 siblings, 2 replies; 8+ messages in thread From: Andrew Lunn @ 2018-12-06 10:36 UTC (permalink / raw) To: David Miller; +Cc: netdev, Florian Fainelli, Vivien Didelot, Andrew Lunn DSA tagging of frames sent over the master interface to the switch increases the size of the frame. Such frames can then be bigger than the normal MTU of the master interface, and it may drop them. Use the overhead information from the tagger to set the MTU of the master device to include this overhead. Signed-off-by: Andrew Lunn <andrew@lunn.ch> --- net/dsa/master.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/dsa/master.c b/net/dsa/master.c index c90ee3227dea..42f525bc68e2 100644 --- a/net/dsa/master.c +++ b/net/dsa/master.c @@ -158,8 +158,24 @@ static void dsa_master_ethtool_teardown(struct net_device *dev) cpu_dp->orig_ethtool_ops = NULL; } +void dsa_master_set_mtu(struct net_device *dev, struct dsa_port *cpu_dp) +{ + unsigned int mtu = ETH_DATA_LEN + cpu_dp->tag_ops->overhead; + int err; + + rtnl_lock(); + if (mtu <= dev->max_mtu) { + err = dev_set_mtu(dev, mtu); + if (err) + netdev_dbg(dev, "Unable to set MTU to include for DSA overheads\n"); + } + rtnl_unlock(); +} + int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp) { + dsa_master_set_mtu(dev, cpu_dp); + /* If we use a tagging format that doesn't have an ethertype * field, make sure that all packets from this point on get * sent to the tag format's receive function. -- 2.19.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 2/2] net: dsa: Set the master device's MTU to account for DSA overheads 2018-12-06 10:36 ` [PATCH net-next 2/2] net: dsa: Set the master device's MTU to account for DSA overheads Andrew Lunn @ 2018-12-06 20:21 ` Florian Fainelli 2018-12-06 20:48 ` Andrew Lunn 2018-12-06 22:14 ` Stephen Hemminger 1 sibling, 1 reply; 8+ messages in thread From: Florian Fainelli @ 2018-12-06 20:21 UTC (permalink / raw) To: Andrew Lunn, David Miller; +Cc: netdev, Vivien Didelot On 12/6/18 2:36 AM, Andrew Lunn wrote: > DSA tagging of frames sent over the master interface to the switch > increases the size of the frame. Such frames can then be bigger than > the normal MTU of the master interface, and it may drop them. Use the > overhead information from the tagger to set the MTU of the master > device to include this overhead. > > Signed-off-by: Andrew Lunn <andrew@lunn.ch> > --- > net/dsa/master.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/net/dsa/master.c b/net/dsa/master.c > index c90ee3227dea..42f525bc68e2 100644 > --- a/net/dsa/master.c > +++ b/net/dsa/master.c > @@ -158,8 +158,24 @@ static void dsa_master_ethtool_teardown(struct net_device *dev) > cpu_dp->orig_ethtool_ops = NULL; > } > > +void dsa_master_set_mtu(struct net_device *dev, struct dsa_port *cpu_dp) > +{ > + unsigned int mtu = ETH_DATA_LEN + cpu_dp->tag_ops->overhead; > + int err; > + > + rtnl_lock(); > + if (mtu <= dev->max_mtu) { > + err = dev_set_mtu(dev, mtu); > + if (err) > + netdev_dbg(dev, "Unable to set MTU to include for DSA overheads\n"); > + } Would it make sense to warn the user that there might be transmit/receive issues with the DSA tagging protocol if either dev_set_mtu() fails or mtu > dev->max_mtu? > + rtnl_unlock(); > +} > + > int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp) > { > + dsa_master_set_mtu(dev, cpu_dp); Not that I think it matters too much to people because unbinding the switch driver and expecting the CPU port to continue operating is wishful thinking, but we should probably unwind that operation in dsa_master_teardown(), right? > + > /* If we use a tagging format that doesn't have an ethertype > * field, make sure that all packets from this point on get > * sent to the tag format's receive function. > -- Florian ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 2/2] net: dsa: Set the master device's MTU to account for DSA overheads 2018-12-06 20:21 ` Florian Fainelli @ 2018-12-06 20:48 ` Andrew Lunn 2018-12-06 21:35 ` David Miller 0 siblings, 1 reply; 8+ messages in thread From: Andrew Lunn @ 2018-12-06 20:48 UTC (permalink / raw) To: Florian Fainelli; +Cc: David Miller, netdev, Vivien Didelot On Thu, Dec 06, 2018 at 12:21:31PM -0800, Florian Fainelli wrote: > On 12/6/18 2:36 AM, Andrew Lunn wrote: > > DSA tagging of frames sent over the master interface to the switch > > increases the size of the frame. Such frames can then be bigger than > > the normal MTU of the master interface, and it may drop them. Use the > > overhead information from the tagger to set the MTU of the master > > device to include this overhead. > > > > Signed-off-by: Andrew Lunn <andrew@lunn.ch> > > --- > > net/dsa/master.c | 16 ++++++++++++++++ > > 1 file changed, 16 insertions(+) > > > > diff --git a/net/dsa/master.c b/net/dsa/master.c > > index c90ee3227dea..42f525bc68e2 100644 > > --- a/net/dsa/master.c > > +++ b/net/dsa/master.c > > @@ -158,8 +158,24 @@ static void dsa_master_ethtool_teardown(struct net_device *dev) > > cpu_dp->orig_ethtool_ops = NULL; > > } > > > > +void dsa_master_set_mtu(struct net_device *dev, struct dsa_port *cpu_dp) > > +{ > > + unsigned int mtu = ETH_DATA_LEN + cpu_dp->tag_ops->overhead; > > + int err; > > + > > + rtnl_lock(); > > + if (mtu <= dev->max_mtu) { > > + err = dev_set_mtu(dev, mtu); > > + if (err) > > + netdev_dbg(dev, "Unable to set MTU to include for DSA overheads\n"); > > + } > > Would it make sense to warn the user that there might be > transmit/receive issues with the DSA tagging protocol if either > dev_set_mtu() fails or mtu > dev->max_mtu? I thought about that. But we have setups which work today with the standard MTU. The master might not implement the set_mtu op, or might impose the standard MTU, but be quite happy to deal with our DSA packets. So i wanted to make this a hint to the master device, not a strong requirement. > Not that I think it matters too much to people because unbinding the > switch driver and expecting the CPU port to continue operating is > wishful thinking, but we should probably unwind that operation in > dsa_master_teardown(), right? That would make sense. David has already accepted the patchset, so i will add a followup patch. Andrew ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 2/2] net: dsa: Set the master device's MTU to account for DSA overheads 2018-12-06 20:48 ` Andrew Lunn @ 2018-12-06 21:35 ` David Miller 0 siblings, 0 replies; 8+ messages in thread From: David Miller @ 2018-12-06 21:35 UTC (permalink / raw) To: andrew; +Cc: f.fainelli, netdev, vivien.didelot From: Andrew Lunn <andrew@lunn.ch> Date: Thu, 6 Dec 2018 21:48:46 +0100 > David has already accepted the patchset, so i will add a followup > patch. Yeah sorry for jumping the gun, the changes looked pretty straightforward to me. :-/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 2/2] net: dsa: Set the master device's MTU to account for DSA overheads 2018-12-06 10:36 ` [PATCH net-next 2/2] net: dsa: Set the master device's MTU to account for DSA overheads Andrew Lunn 2018-12-06 20:21 ` Florian Fainelli @ 2018-12-06 22:14 ` Stephen Hemminger 1 sibling, 0 replies; 8+ messages in thread From: Stephen Hemminger @ 2018-12-06 22:14 UTC (permalink / raw) To: Andrew Lunn; +Cc: David Miller, netdev, Florian Fainelli, Vivien Didelot On Thu, 6 Dec 2018 11:36:05 +0100 Andrew Lunn <andrew@lunn.ch> wrote: > +void dsa_master_set_mtu(struct net_device *dev, struct dsa_port *cpu_dp) > +{ > + unsigned int mtu = ETH_DATA_LEN + cpu_dp->tag_ops->overhead; > + int err; > + > + rtnl_lock(); > + if (mtu <= dev->max_mtu) { > + err = dev_set_mtu(dev, mtu); > + if (err) > + netdev_dbg(dev, "Unable to set MTU to include for DSA overheads\n"); > + } > + rtnl_unlock(); > +} > + You don't need the debug message. Use err_ack instead? Debug messages are usually disabled in most distributions. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 0/2] Adjust MTU of DSA master interface 2018-12-06 10:36 [PATCH net-next 0/2] Adjust MTU of DSA master interface Andrew Lunn 2018-12-06 10:36 ` [PATCH net-next 1/2] net: dsa: Add overhead to tag protocol ops Andrew Lunn 2018-12-06 10:36 ` [PATCH net-next 2/2] net: dsa: Set the master device's MTU to account for DSA overheads Andrew Lunn @ 2018-12-06 20:18 ` David Miller 2 siblings, 0 replies; 8+ messages in thread From: David Miller @ 2018-12-06 20:18 UTC (permalink / raw) To: andrew; +Cc: netdev, f.fainelli, vivien.didelot From: Andrew Lunn <andrew@lunn.ch> Date: Thu, 6 Dec 2018 11:36:03 +0100 > 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. Series applied, thanks Andrew. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-12-06 22:14 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-12-06 10:36 [PATCH net-next 0/2] Adjust MTU of DSA master interface Andrew Lunn 2018-12-06 10:36 ` [PATCH net-next 1/2] net: dsa: Add overhead to tag protocol ops Andrew Lunn 2018-12-06 10:36 ` [PATCH net-next 2/2] net: dsa: Set the master device's MTU to account for DSA overheads Andrew Lunn 2018-12-06 20:21 ` Florian Fainelli 2018-12-06 20:48 ` Andrew Lunn 2018-12-06 21:35 ` David Miller 2018-12-06 22:14 ` Stephen Hemminger 2018-12-06 20:18 ` [PATCH net-next 0/2] Adjust MTU of DSA master interface David Miller
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).