Skip to contentSkip to conversation

sunvnet: allow admin to set sunvnet MTU

PATCH Superseded David L Stevens 3 participants 4 messages Sep 16, 2014 – Sep 17, 2014

Subsystems (2)

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 2/3 sunvnet: allow admin to set sunvnet MTU

This patch allows an admin to set the MTU on a sunvnet device to arbitrary values between the minimum (68) and maximum (65535) IPv4 packet sizes.

---
 drivers/net/ethernet/sun/sunvnet.c |    5 ++++-
 drivers/net/ethernet/sun/sunvnet.h |    2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/sun/sunvnet.c +4 -1
index a9638c1..5619798 100644
@@ -791,6 +791,9 @@ static int vnet_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	if (unlikely(!port))
 		goto out_dropped;
 
+	if (skb->len > port->rmtu)
+		goto out_dropped;
+
 	spin_lock_irqsave(&port->vio.lock, flags);
 
 	dr = &port->vio.drings[VIO_DRIVER_TX_RING];
@@ -1038,7 +1041,7 @@ static void vnet_set_rx_mode(struct net_device *dev)
 
 static int vnet_change_mtu(struct net_device *dev, int new_mtu)
 {
-	if (new_mtu != ETH_DATA_LEN)
+	if (new_mtu < 68 || new_mtu > 65535)
 		return -EINVAL;
 
 	dev->mtu = new_mtu;
drivers/net/ethernet/sun/sunvnet.h +1 -1
index 986e04b..809b122 100644
@@ -11,7 +11,7 @@
  */
 #define VNET_TX_TIMEOUT			(5 * HZ)
 
-#define VNET_MAXPACKET			1518ULL /* ETH_FRAMELEN + VLAN_HDR */
+#define VNET_MAXPACKET			65553ULL /* 64K-1  +ETH HDR +VLAN HDR*/
 #define VNET_TX_RING_SIZE		512
 #define VNET_TX_WAKEUP_THRESH(dr)	((dr)->pending / 4)
 
Signature · 1 line
1.7.1
#1 lore raw

drivers/net/ethernet/sun/sunvnet.h line 16

Quoted 7 lines · David L Stevens

*/
#define VNET_TX_TIMEOUT (5 * HZ)

drivers/net/ethernet/sun/sunvnet.h +1 -1
-#define VNET_MAXPACKET			1518ULL /* ETH_FRAMELEN + VLAN_HDR */
+#define VNET_MAXPACKET			65553ULL /* 64K-1  +ETH HDR +VLAN HDR*/
 #define VNET_TX_RING_SIZE		512
 #define VNET_TX_WAKEUP_THRESH(dr)	((dr)->pending / 4)

While looking at adding TSO support, I've turned up a bug with this.

The transmit buffer mapping should be using a cookie per-page and this increases the page count (without page alignment) from 2 with a 1500-byte MTU to 10 with a 64K MTU
+ framing and allowing from unaligned buffers.

I think it worked during my testing because the pages were contiguous, but the tx buffer allocation code is assuming 2 pages (and 2 cookies) max.

So, it's incorrect. I'll fix and repost; please don't apply these yet.

							+-DLS
maintainer
#2 lore raw

From: David L Stevens <[email protected]>
Date: Tue, 16 Sep 2014 14:51:37 -0400

Quoted 2 lines

So, it's incorrect. I'll fix and repost; please don't apply these yet.

Ok, thanks for the heads up.

#3 lore raw
In reply to David L Stevens

From: David L Stevens

Quoted 7 lines · David L Stevens

drivers/net/ethernet/sun/sunvnet.h line 14

Quoted 6 lines

*/
#define VNET_TX_TIMEOUT (5 * HZ)

drivers/net/ethernet/sun/sunvnet.h +1 -1
-#define VNET_MAXPACKET			1518ULL /* ETH_FRAMELEN + VLAN_HDR */
+#define VNET_MAXPACKET			65553ULL /* 64K-1  +ETH HDR +VLAN HDR*/

That would be better as the expression (0xffffull + 14 + 4).

Quoted 2 lines
Quoted 2 lines

#define VNET_TX_RING_SIZE 512
#define VNET_TX_WAKEUP_THRESH(dr) ((dr)->pending / 4)

David