Skip to content

Commit

Permalink
sunvnet: allow admin to set sunvnet MTU
Browse files Browse the repository at this point in the history
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.

Signed-off-by: David L Stevens <david.stevens@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David L Stevens authored and David S. Miller committed Sep 30, 2014
1 parent 8e845f4 commit 42db672
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion arch/sparc/kernel/ldc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2159,7 +2159,7 @@ int ldc_map_single(struct ldc_channel *lp,
state.pte_idx = (base - iommu->page_table);
state.nc = 0;
fill_cookies(&state, (pa & PAGE_MASK), (pa & ~PAGE_MASK), len);
BUG_ON(state.nc != 1);
BUG_ON(state.nc > ncookies);

return state.nc;
}
Expand Down
7 changes: 5 additions & 2 deletions drivers/net/ethernet/sun/sunvnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,9 @@ static int vnet_start_xmit(struct sk_buff *skb, struct net_device *dev)
if (unlikely(!skb))
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];
Expand Down Expand Up @@ -944,7 +947,7 @@ static int vnet_start_xmit(struct sk_buff *skb, struct net_device *dev)
skb = NULL;

err = ldc_map_single(port->vio.lp, start, nlen,
port->tx_bufs[txi].cookies, 2,
port->tx_bufs[txi].cookies, VNET_MAXCOOKIES,
(LDC_MAP_SHADOW | LDC_MAP_DIRECT | LDC_MAP_RW));
if (err < 0) {
netdev_info(dev, "tx buffer map error %d\n", err);
Expand Down Expand Up @@ -1182,7 +1185,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;
Expand Down
6 changes: 4 additions & 2 deletions drivers/net/ethernet/sun/sunvnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
#define VNET_CLEAN_TIMEOUT ((HZ/100)+1)

#define VNET_MAXPACKET 1518ULL /* ETH_FRAMELEN + VLAN_HDR */
#define VNET_MAXPACKET (65535ULL + ETH_HLEN + VLAN_HLEN)
#define VNET_TX_RING_SIZE 512
#define VNET_TX_WAKEUP_THRESH(dr) ((dr)->pending / 4)

Expand All @@ -26,10 +26,12 @@
*/
#define VNET_PACKET_SKIP 6

#define VNET_MAXCOOKIES (VNET_MAXPACKET/PAGE_SIZE + 1)

struct vnet_tx_entry {
struct sk_buff *skb;
unsigned int ncookies;
struct ldc_trans_cookie cookies[2];
struct ldc_trans_cookie cookies[VNET_MAXCOOKIES];
};

struct vnet;
Expand Down

0 comments on commit 42db672

Please sign in to comment.