Commit 1bdd99e3 authored by Matt Porter's avatar Matt Porter Committed by Jeff Garzik

[PATCH] emac: fix skb allocation for full-size jumbo frames

Sets jumbo frame handling based on MTU and allocates rx buffers
large to handle full-size jumbo frames.
Signed-off-by: default avatarMatt Porter <mporter@kernel.crashing.org>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent ae38ce02
......@@ -1041,7 +1041,7 @@ static int emac_adjust_to_link(struct ocp_enet_private *fep)
/* set speed (default is 10Mb) */
switch (speed) {
case SPEED_1000:
mode_reg |= EMAC_M1_JUMBO_ENABLE | EMAC_M1_RFS_16K;
mode_reg |= EMAC_M1_RFS_16K;
if (fep->rgmii_dev) {
struct ibm_ocp_rgmii *rgmii = RGMII_PRIV(fep->rgmii_dev);
......@@ -1118,6 +1118,7 @@ static int emac_change_mtu(struct net_device *dev, int new_mtu)
{
struct ocp_enet_private *fep = dev->priv;
int old_mtu = dev->mtu;
unsigned long mode_reg;
emac_t *emacp = fep->emacp;
u32 em0mr0;
int i, full;
......@@ -1160,10 +1161,17 @@ static int emac_change_mtu(struct net_device *dev, int new_mtu)
fep->rx_skb[i] = NULL;
}
/* Set new rx_buffer_size and advertise new mtu */
fep->rx_buffer_size =
new_mtu + ENET_HEADER_SIZE + ENET_FCS_SIZE;
/* Set new rx_buffer_size, jumbo cap, and advertise new mtu */
mode_reg = in_be32(&emacp->em0mr1);
if (new_mtu > ENET_DEF_MTU_SIZE) {
mode_reg |= EMAC_M1_JUMBO_ENABLE;
fep->rx_buffer_size = EMAC_MAX_FRAME;
} else {
mode_reg &= ~EMAC_M1_JUMBO_ENABLE;
fep->rx_buffer_size = ENET_DEF_BUF_SIZE;
}
dev->mtu = new_mtu;
out_be32(&emacp->em0mr1, mode_reg);
/* Re-init rx skbs */
fep->rx_slot = 0;
......
......@@ -77,6 +77,8 @@
#define ENET_HEADER_SIZE 14
#define ENET_FCS_SIZE 4
#define ENET_DEF_MTU_SIZE 1500
#define ENET_DEF_BUF_SIZE (ENET_DEF_MTU_SIZE + ENET_HEADER_SIZE + ENET_FCS_SIZE)
#define EMAC_MIN_FRAME 64
#define EMAC_MAX_FRAME 9018
#define EMAC_MIN_MTU (EMAC_MIN_FRAME - ENET_HEADER_SIZE - ENET_FCS_SIZE)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment