Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d6a4b570 authored by David S. Miller's avatar David S. Miller
Browse files

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: default avatarDavid S. Miller <davem@davemloft.net>
parents 5c327f67 dc0fe7d4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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 {
+16 −0
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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,
};
+1 −0
Original line number Diff line number Diff line
@@ -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,
};
Loading