Netdev List
 help / color / mirror / Atom feed
* [PATCH 1/1] net: phylib: remove the length limitation of mii bus id
From: Dong Aisheng @ 2012-03-20  4:23 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-kernel, linux-arm-kernel

From: Dong Aisheng <dong.aisheng@linaro.org>

When convert to dt, the length of old mii bus id (17 bytes) is not
sufficent to use.
For example, the bus id could be 800f0000.ethernet-1:00 in DT.

This patch removes the bus id length limitation by changing the
bus id to a const char pionter and user could dynamically set the
bus id via kasprintf function call.

Since then no users use MII_BUS_ID_SIZE any more, just remove it.

Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
---
The simplest way may just change MII_BUS_ID_SIZE to a more bigger size,
but i'm not sure that's gonna be accepted.
So changed to remove the bus id length limitation, a lot of handwork.

Since this patch changes a lot of other ethernet drivers and i did
not have condition to test it, need each corresponding driver owners
to help review.

I just greped the macro MII_BUS_ID_SIZE in the latest kernel tree and
did the replacement.
In case any one missed(may not use MII_BUS_ID_SIZE), that driver owner
should help change it.

Only tested the fec driver on i.MX28 EVK board.
---
 arch/powerpc/platforms/82xx/ep8248e.c              |    2 +-
 arch/powerpc/platforms/pasemi/gpio_mdio.c          |    2 +-
 drivers/net/ethernet/8390/ax88796.c                |    4 +---
 drivers/net/ethernet/adi/bfin_mac.c                |    3 +--
 drivers/net/ethernet/aeroflex/greth.c              |    2 +-
 drivers/net/ethernet/amd/au1000_eth.c              |    3 +--
 drivers/net/ethernet/broadcom/bcm63xx_enet.c       |   10 +++++-----
 drivers/net/ethernet/broadcom/sb1250-mac.c         |    2 +-
 drivers/net/ethernet/broadcom/tg3.c                |    4 ++--
 drivers/net/ethernet/cadence/macb.c                |    2 +-
 drivers/net/ethernet/dnet.c                        |    2 +-
 drivers/net/ethernet/ethoc.c                       |    2 +-
 drivers/net/ethernet/faraday/ftgmac100.c           |    2 +-
 drivers/net/ethernet/freescale/fec.c               |   16 +++++++++-------
 drivers/net/ethernet/freescale/fec_mpc52xx_phy.c   |    2 +-
 .../net/ethernet/freescale/fs_enet/mii-bitbang.c   |    2 +-
 drivers/net/ethernet/freescale/fs_enet/mii-fec.c   |    2 +-
 drivers/net/ethernet/freescale/fsl_pq_mdio.c       |    6 +++---
 drivers/net/ethernet/freescale/fsl_pq_mdio.h       |    2 +-
 drivers/net/ethernet/lantiq_etop.c                 |    2 +-
 drivers/net/ethernet/marvell/mv643xx_eth.c         |    2 +-
 drivers/net/ethernet/marvell/pxa168_eth.c          |    2 +-
 drivers/net/ethernet/rdc/r6040.c                   |    4 ++--
 drivers/net/ethernet/renesas/sh_eth.c              |    7 ++++---
 drivers/net/ethernet/s6gmac.c                      |    2 +-
 drivers/net/ethernet/smsc/smsc911x.c               |    4 ++--
 drivers/net/ethernet/smsc/smsc9420.c               |    2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |   10 ++++++----
 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c  |    4 ++--
 drivers/net/ethernet/ti/cpmac.c                    |   16 ++++++++--------
 drivers/net/ethernet/ti/davinci_mdio.c             |    4 ++--
 drivers/net/ethernet/toshiba/tc35815.c             |    2 +-
 drivers/net/ethernet/xilinx/ll_temac_mdio.c        |    2 +-
 drivers/net/ethernet/xilinx/xilinx_emaclite.c      |    2 +-
 drivers/net/ethernet/xscale/ixp4xx_eth.c           |    7 ++++---
 drivers/net/phy/fixed.c                            |    2 +-
 drivers/net/phy/mdio-gpio.c                        |    2 +-
 drivers/net/phy/mdio-octeon.c                      |    2 +-
 drivers/net/phy/phy_device.c                       |    2 +-
 drivers/of/of_mdio.c                               |    5 +++--
 drivers/staging/et131x/et131x.c                    |    2 +-
 include/linux/phy.h                                |   10 ++--------
 net/dsa/slave.c                                    |    2 +-
 43 files changed, 83 insertions(+), 86 deletions(-)

diff --git a/arch/powerpc/platforms/82xx/ep8248e.c b/arch/powerpc/platforms/82xx/ep8248e.c
index 10ff526..21658de 100644
--- a/arch/powerpc/platforms/82xx/ep8248e.c
+++ b/arch/powerpc/platforms/82xx/ep8248e.c
@@ -139,7 +139,7 @@ static int __devinit ep8248e_mdio_probe(struct platform_device *ofdev)
 
 	bus->name = "ep8248e-mdio-bitbang";
 	bus->parent = &ofdev->dev;
-	snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start);
+	bus->id = kasprintf(GFP_KERNEL, "%x", res.start);
 
 	ret = of_mdiobus_register(bus, ofdev->dev.of_node);
 	if (ret)
diff --git a/arch/powerpc/platforms/pasemi/gpio_mdio.c b/arch/powerpc/platforms/pasemi/gpio_mdio.c
index 9886296..3b55962 100644
--- a/arch/powerpc/platforms/pasemi/gpio_mdio.c
+++ b/arch/powerpc/platforms/pasemi/gpio_mdio.c
@@ -241,7 +241,7 @@ static int __devinit gpio_mdio_probe(struct platform_device *ofdev)
 	new_bus->reset = &gpio_mdio_reset;
 
 	prop = of_get_property(np, "reg", NULL);
-	snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", *prop);
+	new_bus->id = kasprintf(GFP_KERNEL, "%x", *prop);
 	new_bus->priv = priv;
 
 	new_bus->irq = priv->mdio_irqs;
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index 0f92e35..c70067c 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -623,9 +623,7 @@ static int ax_mii_init(struct net_device *dev)
 
 	ax->mii_bus->name = "ax88796_mii_bus";
 	ax->mii_bus->parent = dev->dev.parent;
-	snprintf(ax->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
-		pdev->name, pdev->id);
-
+	ax->mii_bus->id = kasprintf(GFP_KERNEL, "%s-%x", pdev->name, pdev->id);
 	ax->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
 	if (!ax->mii_bus->irq) {
 		err = -ENOMEM;
diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c
index d812a10..77d473a 100644
--- a/drivers/net/ethernet/adi/bfin_mac.c
+++ b/drivers/net/ethernet/adi/bfin_mac.c
@@ -1670,8 +1670,7 @@ static int __devinit bfin_mii_bus_probe(struct platform_device *pdev)
 	miibus->name = "bfin_mii_bus";
 	miibus->phy_mask = mii_bus_pd->phy_mask;
 
-	snprintf(miibus->id, MII_BUS_ID_SIZE, "%s-%x",
-		pdev->name, pdev->id);
+	miibus->id = kasprintf(GFP_KERNEL, "%s-%x", pdev->name, pdev->id);
 	miibus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
 	if (!miibus->irq)
 		goto out_err_irq_alloc;
diff --git a/drivers/net/ethernet/aeroflex/greth.c b/drivers/net/ethernet/aeroflex/greth.c
index c885aa9..df635f2 100644
--- a/drivers/net/ethernet/aeroflex/greth.c
+++ b/drivers/net/ethernet/aeroflex/greth.c
@@ -1332,7 +1332,7 @@ static int greth_mdio_init(struct greth_private *greth)
 	}
 
 	greth->mdio->name = "greth-mdio";
-	snprintf(greth->mdio->id, MII_BUS_ID_SIZE, "%s-%d", greth->mdio->name, greth->irq);
+	greth->mdio->id = kasprintf(GFP_KERNEL, "%s-%d", greth->mdio->name, greth->irq);
 	greth->mdio->read = greth_mdio_read;
 	greth->mdio->write = greth_mdio_write;
 	greth->mdio->reset = greth_mdio_reset;
diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
index 8b95dd3..99e0ebb 100644
--- a/drivers/net/ethernet/amd/au1000_eth.c
+++ b/drivers/net/ethernet/amd/au1000_eth.c
@@ -1171,8 +1171,7 @@ static int __devinit au1000_probe(struct platform_device *pdev)
 	aup->mii_bus->write = au1000_mdiobus_write;
 	aup->mii_bus->reset = au1000_mdiobus_reset;
 	aup->mii_bus->name = "au1000_eth_mii";
-	snprintf(aup->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
-		pdev->name, aup->mac_id);
+	aup->mii_bus->id =  kasprintf(GFP_KERNEL, "%s-%x", pdev->name, aup->mac_id);
 	aup->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
 	if (aup->mii_bus->irq == NULL)
 		goto err_out;
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index 986019b..8118878 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -787,7 +787,7 @@ static int bcm_enet_open(struct net_device *dev)
 	struct phy_device *phydev;
 	int i, ret;
 	unsigned int size;
-	char phy_id[MII_BUS_ID_SIZE + 3];
+	const char *phy_id;
 	void *p;
 	u32 val;
 
@@ -796,12 +796,12 @@ static int bcm_enet_open(struct net_device *dev)
 
 	if (priv->has_phy) {
 		/* connect to PHY */
-		snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT,
-			 priv->mac_id ? "1" : "0", priv->phy_id);
+		phy_id = kasprintf(GFP_KERNEL, PHY_ID_FMT,
+				priv->mac_id ? "1" : "0", priv->phy_id);
 
 		phydev = phy_connect(dev, phy_id, bcm_enet_adjust_phy_link, 0,
 				     PHY_INTERFACE_MODE_MII);
-
+		kfree(phy_id);
 		if (IS_ERR(phydev)) {
 			dev_err(kdev, "could not attach to PHY\n");
 			return PTR_ERR(phydev);
@@ -1727,7 +1727,7 @@ static int __devinit bcm_enet_probe(struct platform_device *pdev)
 		bus->priv = priv;
 		bus->read = bcm_enet_mdio_read_phylib;
 		bus->write = bcm_enet_mdio_write_phylib;
-		sprintf(bus->id, "%s-%d", pdev->name, priv->mac_id);
+		bus->id = kasprintf(GFP_KERNEL, "%s-%d", pdev->name, priv->mac_id);
 
 		/* only probe bus where we think the PHY is, because
 		 * the mdio read operation return 0 instead of 0xffff
diff --git a/drivers/net/ethernet/broadcom/sb1250-mac.c b/drivers/net/ethernet/broadcom/sb1250-mac.c
index 084904c..7fd5654 100644
--- a/drivers/net/ethernet/broadcom/sb1250-mac.c
+++ b/drivers/net/ethernet/broadcom/sb1250-mac.c
@@ -2259,7 +2259,7 @@ static int sbmac_init(struct platform_device *pldev, long long base)
 	}
 
 	sc->mii_bus->name = sbmac_mdio_string;
-	snprintf(sc->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
+	sc->mii_bus->id = kasprintf(GFP_KERNEL, "%s-%x",
 		pldev->name, idx);
 	sc->mii_bus->priv = sc;
 	sc->mii_bus->read = sbmac_mii_read;
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index d529af9..2750e49 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -1328,8 +1328,8 @@ static int tg3_mdio_init(struct tg3 *tp)
 		return -ENOMEM;
 
 	tp->mdio_bus->name     = "tg3 mdio bus";
-	snprintf(tp->mdio_bus->id, MII_BUS_ID_SIZE, "%x",
-		 (tp->pdev->bus->number << 8) | tp->pdev->devfn);
+	tp->mdio_bus->id = kasprintf(GFP_KERNEL, "%x",
+		(tp->pdev->bus->number << 8) | tp->pdev->devfn);
 	tp->mdio_bus->priv     = tp;
 	tp->mdio_bus->parent   = &tp->pdev->dev;
 	tp->mdio_bus->read     = &tg3_mdio_read;
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 2320068..62e4465 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -243,7 +243,7 @@ static int macb_mii_init(struct macb *bp)
 	bp->mii_bus->read = &macb_mdio_read;
 	bp->mii_bus->write = &macb_mdio_write;
 	bp->mii_bus->reset = &macb_mdio_reset;
-	snprintf(bp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
+	bp->mii_bus->id = kasprintf(GFP_KERNEL, "%s-%x",
 		bp->pdev->name, bp->pdev->id);
 	bp->mii_bus->priv = bp;
 	bp->mii_bus->parent = &bp->dev->dev;
diff --git a/drivers/net/ethernet/dnet.c b/drivers/net/ethernet/dnet.c
index 925c9ba..18c3c92 100644
--- a/drivers/net/ethernet/dnet.c
+++ b/drivers/net/ethernet/dnet.c
@@ -325,7 +325,7 @@ static int dnet_mii_init(struct dnet *bp)
 	bp->mii_bus->write = &dnet_mdio_write;
 	bp->mii_bus->reset = &dnet_mdio_reset;
 
-	snprintf(bp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
+	bp->mii_bus->id = kasprintf(GFP_KERNEL, "%s-%x",
 		bp->pdev->name, bp->pdev->id);
 
 	bp->mii_bus->priv = bp;
diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 60f0e78..e9195a5 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -1063,7 +1063,7 @@ static int __devinit ethoc_probe(struct platform_device *pdev)
 	}
 
 	priv->mdio->name = "ethoc-mdio";
-	snprintf(priv->mdio->id, MII_BUS_ID_SIZE, "%s-%d",
+	priv->mdio->id = kasprintf(GFP_KERNEL, "%s-%d",
 			priv->mdio->name, pdev->id);
 	priv->mdio->read = ethoc_mdio_read;
 	priv->mdio->write = ethoc_mdio_write;
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index fb5579a..af418cd 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1255,7 +1255,7 @@ static int ftgmac100_probe(struct platform_device *pdev)
 	}
 
 	priv->mii_bus->name = "ftgmac100_mdio";
-	snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "ftgmac100_mii");
+	priv->mii_bus->id = kstrdup("ftgmac100_mii", GFP_KERNEL);
 
 	priv->mii_bus->priv = netdev;
 	priv->mii_bus->read = ftgmac100_mdiobus_read;
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index 7b25e9c..6e82c2d 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -961,8 +961,8 @@ static int fec_enet_mii_probe(struct net_device *ndev)
 	const struct platform_device_id *id_entry =
 				platform_get_device_id(fep->pdev);
 	struct phy_device *phy_dev = NULL;
-	char mdio_bus_id[MII_BUS_ID_SIZE];
-	char phy_name[MII_BUS_ID_SIZE + 3];
+	const char *mdio_bus_id;
+	const char *phy_name;
 	int phy_id;
 	int dev_id = fep->dev_id;
 
@@ -978,7 +978,7 @@ static int fec_enet_mii_probe(struct net_device *ndev)
 			continue;
 		if (dev_id--)
 			continue;
-		strncpy(mdio_bus_id, fep->mii_bus->id, MII_BUS_ID_SIZE);
+		mdio_bus_id = kstrdup(fep->mii_bus->id, GFP_KERNEL);
 		break;
 	}
 
@@ -986,13 +986,15 @@ static int fec_enet_mii_probe(struct net_device *ndev)
 		printk(KERN_INFO
 			"%s: no PHY, assuming direct connection to switch\n",
 			ndev->name);
-		strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE);
+		mdio_bus_id = kstrdup("0", GFP_KERNEL);
 		phy_id = 0;
 	}
 
-	snprintf(phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id);
+	phy_name= kasprintf(GFP_KERNEL, PHY_ID_FMT, mdio_bus_id, phy_id);
 	phy_dev = phy_connect(ndev, phy_name, &fec_enet_adjust_link, 0,
 			      fep->phy_interface);
+	kfree(mdio_bus_id);
+	kfree(phy_name);
 	if (IS_ERR(phy_dev)) {
 		printk(KERN_ERR "%s: could not attach to PHY\n", ndev->name);
 		return PTR_ERR(phy_dev);
@@ -1080,8 +1082,8 @@ static int fec_enet_mii_init(struct platform_device *pdev)
 	fep->mii_bus->read = fec_enet_mdio_read;
 	fep->mii_bus->write = fec_enet_mdio_write;
 	fep->mii_bus->reset = fec_enet_mdio_reset;
-	snprintf(fep->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
-		pdev->name, fep->dev_id + 1);
+	fep->mii_bus->id = kasprintf(GFP_KERNEL, "%s-%x",
+					pdev->name, fep->dev_id +1);
 	fep->mii_bus->priv = fep;
 	fep->mii_bus->parent = &pdev->dev;
 
diff --git a/drivers/net/ethernet/freescale/fec_mpc52xx_phy.c b/drivers/net/ethernet/freescale/fec_mpc52xx_phy.c
index 360a578..7724be7 100644
--- a/drivers/net/ethernet/freescale/fec_mpc52xx_phy.c
+++ b/drivers/net/ethernet/freescale/fec_mpc52xx_phy.c
@@ -96,7 +96,7 @@ static int mpc52xx_fec_mdio_probe(struct platform_device *of)
 		goto out_free;
 	}
 
-	snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start);
+	bus->id = kasprintf(GFP_KERNEL, "%x", res.start);
 	bus->priv = priv;
 
 	bus->parent = dev;
diff --git a/drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c b/drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c
index 0f2d1a7..9e6eac9 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c
@@ -127,7 +127,7 @@ static int __devinit fs_mii_bitbang_init(struct mii_bus *bus,
 	 * we get is an int, and the odds of multiple bitbang mdio buses
 	 * is low enough that it's not worth going too crazy.
 	 */
-	snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start);
+	bus->id = kasprintf(GFP_KERNEL, "%x", res.start);
 
 	data = of_get_property(np, "fsl,mdio-pin", &len);
 	if (!data || len != 4)
diff --git a/drivers/net/ethernet/freescale/fs_enet/mii-fec.c b/drivers/net/ethernet/freescale/fs_enet/mii-fec.c
index 55bb867..5242f4d 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mii-fec.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mii-fec.c
@@ -134,7 +134,7 @@ static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev)
 	if (ret)
 		goto out_res;
 
-	snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", res.start);
+	new_bus->id = kasprintf(GFP_KERNEL, "%x", res.start);
 
 	fec->fecp = ioremap(res.start, resource_size(&res));
 	if (!fec->fecp)
diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
index 9eb8159..773acd5 100644
--- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c
+++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
@@ -169,7 +169,7 @@ static int fsl_pq_mdio_reset(struct mii_bus *bus)
 	return 0;
 }
 
-void fsl_pq_mdio_bus_name(char *name, struct device_node *np)
+void fsl_pq_mdio_bus_name(char **name, struct device_node *np)
 {
 	const u32 *addr;
 	u64 taddr = OF_BAD_ADDR;
@@ -178,7 +178,7 @@ void fsl_pq_mdio_bus_name(char *name, struct device_node *np)
 	if (addr)
 		taddr = of_translate_address(np, addr);
 
-	snprintf(name, MII_BUS_ID_SIZE, "%s@%llx", np->name,
+	*name = kasprintf(GFP_KERNEL, "%s@%llx", np->name,
 		(unsigned long long)taddr);
 }
 EXPORT_SYMBOL_GPL(fsl_pq_mdio_bus_name);
@@ -277,7 +277,7 @@ static int fsl_pq_mdio_probe(struct platform_device *ofdev)
 	new_bus->write = &fsl_pq_mdio_write,
 	new_bus->reset = &fsl_pq_mdio_reset,
 	new_bus->priv = priv;
-	fsl_pq_mdio_bus_name(new_bus->id, np);
+	fsl_pq_mdio_bus_name(&new_bus->id, np);
 
 	addrp = of_get_address(np, 0, &size, NULL);
 	if (!addrp) {
diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.h b/drivers/net/ethernet/freescale/fsl_pq_mdio.h
index bd17a2a..b563ef7 100644
--- a/drivers/net/ethernet/freescale/fsl_pq_mdio.h
+++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.h
@@ -48,5 +48,5 @@ int fsl_pq_local_mdio_write(struct fsl_pq_mdio __iomem *regs, int mii_id,
 int fsl_pq_local_mdio_read(struct fsl_pq_mdio __iomem *regs, int mii_id, int regnum);
 int __init fsl_pq_mdio_init(void);
 void fsl_pq_mdio_exit(void);
-void fsl_pq_mdio_bus_name(char *name, struct device_node *np);
+void fsl_pq_mdio_bus_name(char **name, struct device_node *np);
 #endif /* FSL_PQ_MDIO_H */
diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
index 85e2c6c..742e7dd 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -437,7 +437,7 @@ ltq_etop_mdio_init(struct net_device *dev)
 	priv->mii_bus->read = ltq_etop_mdio_rd;
 	priv->mii_bus->write = ltq_etop_mdio_wr;
 	priv->mii_bus->name = "ltq_mii";
-	snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
+	priv->mii_bus->id = kasprintf(GFP_KERNEL, "%s-%x",
 		priv->pdev->name, priv->pdev->id);
 	priv->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
 	if (!priv->mii_bus->irq) {
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 9c049d2..e18707f 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -2613,7 +2613,7 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
 		msp->smi_bus->name = "mv643xx_eth smi";
 		msp->smi_bus->read = smi_bus_read;
 		msp->smi_bus->write = smi_bus_write,
-		snprintf(msp->smi_bus->id, MII_BUS_ID_SIZE, "%s-%d",
+		msp->smi_bus->id = kasprintf(GFP_KERNEL, "%s-%d",
 			pdev->name, pdev->id);
 		msp->smi_bus->parent = &pdev->dev;
 		msp->smi_bus->phy_mask = 0xffffffff;
diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c
index 953ba58..bf19af7 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -1552,7 +1552,7 @@ static int pxa168_eth_probe(struct platform_device *pdev)
 	pep->smi_bus->name = "pxa168_eth smi";
 	pep->smi_bus->read = pxa168_smi_read;
 	pep->smi_bus->write = pxa168_smi_write;
-	snprintf(pep->smi_bus->id, MII_BUS_ID_SIZE, "%s-%d",
+	pep->smi_bus->id = kasprintf(GFP_KERNEL, "%s-%d",
 		pdev->name, pdev->id);
 	pep->smi_bus->parent = &pdev->dev;
 	pep->smi_bus->phy_mask = 0xffffffff;
diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c
index cb0eca8..9d890b2 100644
--- a/drivers/net/ethernet/rdc/r6040.c
+++ b/drivers/net/ethernet/rdc/r6040.c
@@ -1181,8 +1181,8 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
 	lp->mii_bus->write = r6040_mdiobus_write;
 	lp->mii_bus->reset = r6040_mdiobus_reset;
 	lp->mii_bus->name = "r6040_eth_mii";
-	snprintf(lp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
-		dev_name(&pdev->dev), card_idx);
+	lp->mii_bus->id = kasprintf(GFP_KERNEL, "%s-%x",
+			dev_name(&pdev->dev), card_idx);
 	lp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
 	if (!lp->mii_bus->irq) {
 		dev_err(&pdev->dev, "mii_bus irq allocation failed\n");
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 813d41c..3210fd9 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1213,10 +1213,10 @@ static void sh_eth_adjust_link(struct net_device *ndev)
 static int sh_eth_phy_init(struct net_device *ndev)
 {
 	struct sh_eth_private *mdp = netdev_priv(ndev);
-	char phy_id[MII_BUS_ID_SIZE + 3];
+	const char *phy_id;
 	struct phy_device *phydev = NULL;
 
-	snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT,
+	phy_id = kasprintf(GFP_KERNEL, PHY_ID_FMT,
 		mdp->mii_bus->id , mdp->phy_id);
 
 	mdp->link = PHY_DOWN;
@@ -1226,6 +1226,7 @@ static int sh_eth_phy_init(struct net_device *ndev)
 	/* Try connect to PHY */
 	phydev = phy_connect(ndev, phy_id, sh_eth_adjust_link,
 				0, mdp->phy_interface);
+	kfree(phy_id);
 	if (IS_ERR(phydev)) {
 		dev_err(&ndev->dev, "phy_connect failed\n");
 		return PTR_ERR(phydev);
@@ -1702,7 +1703,7 @@ static int sh_mdio_init(struct net_device *ndev, int id,
 	/* Hook up MII support for ethtool */
 	mdp->mii_bus->name = "sh_mii";
 	mdp->mii_bus->parent = &ndev->dev;
-	snprintf(mdp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
+	mdp->mii_bus->id = kasprintf(GFP_KERNEL, "%s-%x",
 		mdp->pdev->name, id);
 
 	/* PHY IRQ */
diff --git a/drivers/net/ethernet/s6gmac.c b/drivers/net/ethernet/s6gmac.c
index 22e9c01..dd5f29b 100644
--- a/drivers/net/ethernet/s6gmac.c
+++ b/drivers/net/ethernet/s6gmac.c
@@ -1004,7 +1004,7 @@ static int __devinit s6gmac_probe(struct platform_device *pdev)
 	mb->write = s6mii_write;
 	mb->reset = s6mii_reset;
 	mb->priv = pd;
-	snprintf(mb->id, MII_BUS_ID_SIZE, "%s-%x", pdev->name, pdev->id);
+	mb->id = kasprintf(GFP_KERNEL, "%s-%x", pdev->name, pdev->id);
 	mb->phy_mask = ~(1 << 0);
 	mb->irq = &pd->mii.irq[0];
 	for (i = 0; i < PHY_MAX_ADDR; i++) {
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 24d2df0..4aab696 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -1044,8 +1044,8 @@ static int __devinit smsc911x_mii_init(struct platform_device *pdev,
 	}
 
 	pdata->mii_bus->name = SMSC_MDIONAME;
-	snprintf(pdata->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
-		pdev->name, pdev->id);
+	pdata->mii_bus->id = kasprintf(GFP_KERNEL, "%s-%x",
+			pdev->name, pdev->id);
 	pdata->mii_bus->priv = pdata;
 	pdata->mii_bus->read = smsc911x_mii_read;
 	pdata->mii_bus->write = smsc911x_mii_write;
diff --git a/drivers/net/ethernet/smsc/smsc9420.c b/drivers/net/ethernet/smsc/smsc9420.c
index a9efbdf..bffd175 100644
--- a/drivers/net/ethernet/smsc/smsc9420.c
+++ b/drivers/net/ethernet/smsc/smsc9420.c
@@ -1211,7 +1211,7 @@ static int smsc9420_mii_init(struct net_device *dev)
 		goto err_out_1;
 	}
 	pd->mii_bus->name = DRV_MDIONAME;
-	snprintf(pd->mii_bus->id, MII_BUS_ID_SIZE, "%x",
+	pd->mii_bus->id = kasprintf(GFP_KERNEL, "%x",
 		(pd->pdev->bus->number << 8) | pd->pdev->devfn);
 	pd->mii_bus->priv = pd;
 	pd->mii_bus->read = smsc9420_mii_read;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 96fa2da..c72a50e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -300,19 +300,21 @@ static int stmmac_init_phy(struct net_device *dev)
 {
 	struct stmmac_priv *priv = netdev_priv(dev);
 	struct phy_device *phydev;
-	char phy_id[MII_BUS_ID_SIZE + 3];
-	char bus_id[MII_BUS_ID_SIZE];
+	const char *phy_id;
+	const char *bus_id;
 	int interface = priv->plat->interface;
 	priv->oldlink = 0;
 	priv->speed = 0;
 	priv->oldduplex = -1;
 
-	snprintf(bus_id, MII_BUS_ID_SIZE, "stmmac-%x", priv->plat->bus_id);
-	snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, bus_id,
+	bus_id = kasprintf(GFP_KERNEL, "stmmac-%x", priv->plat->bus_id);
+	phy_id = kasprintf(GFP_KERNEL, PHY_ID_FMT, bus_id,
 		 priv->plat->phy_addr);
 	pr_debug("stmmac_init_phy:  trying to attach to %s\n", phy_id);
 
 	phydev = phy_connect(dev, phy_id, &stmmac_adjust_link, 0, interface);
+	kfree(phy_id);
+	kfree(bus_id);
 
 	if (IS_ERR(phydev)) {
 		pr_err("%s: Could not attach to PHY\n", dev->name);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index da4a104..6a72265 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -158,8 +158,8 @@ int stmmac_mdio_register(struct net_device *ndev)
 	new_bus->read = &stmmac_mdio_read;
 	new_bus->write = &stmmac_mdio_write;
 	new_bus->reset = &stmmac_mdio_reset;
-	snprintf(new_bus->id, MII_BUS_ID_SIZE, "%s-%x",
-		new_bus->name, mdio_bus_data->bus_id);
+	new_bus->id = kasprintf(GFP_KERNEL, "%s-%x",
+			new_bus->name, mdio_bus_data->bus_id);
 	new_bus->priv = ndev;
 	new_bus->irq = irqlist;
 	new_bus->phy_mask = mdio_bus_data->phy_mask;
diff --git a/drivers/net/ethernet/ti/cpmac.c b/drivers/net/ethernet/ti/cpmac.c
index 4d9a28f..b448cca 100644
--- a/drivers/net/ethernet/ti/cpmac.c
+++ b/drivers/net/ethernet/ti/cpmac.c
@@ -205,7 +205,7 @@ struct cpmac_priv {
 	void __iomem *regs;
 	struct mii_bus *mii_bus;
 	struct phy_device *phy;
-	char phy_name[MII_BUS_ID_SIZE + 3];
+	const char *phy_name;
 	int oldlink, oldspeed, oldduplex;
 	u32 msg_enable;
 	struct net_device *dev;
@@ -1113,7 +1113,7 @@ static int external_switch;
 static int __devinit cpmac_probe(struct platform_device *pdev)
 {
 	int rc, phy_id;
-	char mdio_bus_id[MII_BUS_ID_SIZE];
+	const char *mdio_bus_id;
 	struct resource *mem;
 	struct cpmac_priv *priv;
 	struct net_device *dev;
@@ -1122,7 +1122,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
 	pdata = pdev->dev.platform_data;
 
 	if (external_switch || dumb_switch) {
-		strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE); /* fixed phys bus */
+		mdio_bus_id = kstrdup("0", GFP_KERNEL); /* fixed phys bus */
 		phy_id = pdev->id;
 	} else {
 		for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
@@ -1130,7 +1130,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
 				continue;
 			if (!cpmac_mii->phy_map[phy_id])
 				continue;
-			strncpy(mdio_bus_id, cpmac_mii->id, MII_BUS_ID_SIZE);
+			mdio_bus_id = kstrdup(cpmac_mii->id, GFP_KERNEL);
 			break;
 		}
 	}
@@ -1138,7 +1138,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
 	if (phy_id == PHY_MAX_ADDR) {
 		dev_err(&pdev->dev, "no PHY present, falling back "
 					"to switch on MDIO bus 0\n");
-		strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE); /* fixed phys bus */
+		mdio_bus_id = kstrdup("0", GFP_KERNEL); /* fixed phys bus */
 		phy_id = pdev->id;
 	}
 
@@ -1173,8 +1173,8 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
 	priv->msg_enable = netif_msg_init(debug_level, 0xff);
 	memcpy(dev->dev_addr, pdata->dev_addr, sizeof(pdata->dev_addr));
 
-	snprintf(priv->phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT,
-						mdio_bus_id, phy_id);
+	priv->phy_name= kasprintf(GFP_KERNEL, PHY_ID_FMT, mdio_bus_id, phy_id);
+	kfree(mdio_bus_id);
 
 	priv->phy = phy_connect(dev, priv->phy_name, cpmac_adjust_link, 0,
 						PHY_INTERFACE_MODE_MII);
@@ -1269,7 +1269,7 @@ int __devinit cpmac_init(void)
 	}
 
 	cpmac_mii->phy_mask = ~(mask | 0x80000000);
-	snprintf(cpmac_mii->id, MII_BUS_ID_SIZE, "cpmac-1");
+	cpmac_mii->id = kstrdup("cpmac-1", GFP_KERNEL);
 
 	res = mdiobus_register(cpmac_mii);
 	if (res)
diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index ef7c9c1..67ddf87 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -313,8 +313,8 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev)
 	data->bus->reset	= davinci_mdio_reset,
 	data->bus->parent	= dev;
 	data->bus->priv		= data;
-	snprintf(data->bus->id, MII_BUS_ID_SIZE, "%s-%x",
-		pdev->name, pdev->id);
+	data->bus->id = kasprintf(GFP_KERNEL, "%s-%x",
+			pdev->name, pdev->id);
 
 	data->clk = clk_get(dev, NULL);
 	if (IS_ERR(data->clk)) {
diff --git a/drivers/net/ethernet/toshiba/tc35815.c b/drivers/net/ethernet/toshiba/tc35815.c
index 71b785c..8ffacd6 100644
--- a/drivers/net/ethernet/toshiba/tc35815.c
+++ b/drivers/net/ethernet/toshiba/tc35815.c
@@ -682,7 +682,7 @@ static int tc_mii_init(struct net_device *dev)
 	lp->mii_bus->name = "tc35815_mii_bus";
 	lp->mii_bus->read = tc_mdio_read;
 	lp->mii_bus->write = tc_mdio_write;
-	snprintf(lp->mii_bus->id, MII_BUS_ID_SIZE, "%x",
+	lp->mii_bus->id = kasprintf(GFP_KERNEL, "%x",
 		 (lp->pci_dev->bus->number << 8) | lp->pci_dev->devfn);
 	lp->mii_bus->priv = dev;
 	lp->mii_bus->parent = &lp->pci_dev->dev;
diff --git a/drivers/net/ethernet/xilinx/ll_temac_mdio.c b/drivers/net/ethernet/xilinx/ll_temac_mdio.c
index 8cf9d4f..aa9d0d5 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_mdio.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_mdio.c
@@ -86,7 +86,7 @@ int temac_mdio_setup(struct temac_local *lp, struct device_node *np)
 		return -ENOMEM;
 
 	of_address_to_resource(np, 0, &res);
-	snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx",
+	bus->id = kasprintf(GFP_KERNEL, "%.8llx",
 		 (unsigned long long)res.start);
 	bus->priv = lp;
 	bus->name = "Xilinx TEMAC MDIO";
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 79013e5..c476861 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -866,7 +866,7 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
 		return -ENOMEM;
 
 	of_address_to_resource(np, 0, &res);
-	snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx",
+	bus->id = kasprintf(GFP_KERNEL, "%.8llx",
 		 (unsigned long long)res.start);
 	bus->priv = lp;
 	bus->name = "Xilinx Emaclite MDIO";
diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index 72a854f..3794959 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -529,7 +529,7 @@ static int ixp4xx_mdio_register(void)
 	mdio_bus->name = "IXP4xx MII Bus";
 	mdio_bus->read = &ixp4xx_mdio_read;
 	mdio_bus->write = &ixp4xx_mdio_write;
-	snprintf(mdio_bus->id, MII_BUS_ID_SIZE, "ixp4xx-eth-0");
+	mdio_bus->id = kstrdup("ixp4xx-eth-0", GFP_KERNEL);
 
 	if ((err = mdiobus_register(mdio_bus)))
 		mdiobus_free(mdio_bus);
@@ -1353,7 +1353,7 @@ static int __devinit eth_init_one(struct platform_device *pdev)
 	struct net_device *dev;
 	struct eth_plat_info *plat = pdev->dev.platform_data;
 	u32 regs_phys;
-	char phy_id[MII_BUS_ID_SIZE + 3];
+	const char *phy_id;
 	int err;
 
 	if (ptp_filter_init(ptp_filter, ARRAY_SIZE(ptp_filter))) {
@@ -1416,9 +1416,10 @@ static int __devinit eth_init_one(struct platform_device *pdev)
 	__raw_writel(DEFAULT_CORE_CNTRL, &port->regs->core_control);
 	udelay(50);
 
-	snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, "0", plat->phy);
+	phy_id = kasprintf(GFP_KERNEL, PHY_ID_FMT, "0", plat->phy);
 	port->phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link, 0,
 				   PHY_INTERFACE_MODE_MII);
+	kfree(phy_id);
 	if (IS_ERR(port->phydev)) {
 		err = PTR_ERR(port->phydev);
 		goto err_free_mem;
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
index 633680d..947c7e1 100644
--- a/drivers/net/phy/fixed.c
+++ b/drivers/net/phy/fixed.c
@@ -220,7 +220,7 @@ static int __init fixed_mdio_bus_init(void)
 		goto err_mdiobus_reg;
 	}
 
-	snprintf(fmb->mii_bus->id, MII_BUS_ID_SIZE, "fixed-0");
+	fmb->mii_bus->id = kstrdup("fixed-0", GFP_KERNEL);
 	fmb->mii_bus->name = "Fixed MDIO Bus";
 	fmb->mii_bus->priv = fmb;
 	fmb->mii_bus->parent = &pdev->dev;
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
index 50e8e5e..0a89f0b 100644
--- a/drivers/net/phy/mdio-gpio.c
+++ b/drivers/net/phy/mdio-gpio.c
@@ -116,7 +116,7 @@ static struct mii_bus * __devinit mdio_gpio_bus_init(struct device *dev,
 		if (!new_bus->irq[i])
 			new_bus->irq[i] = PHY_POLL;
 
-	snprintf(new_bus->id, MII_BUS_ID_SIZE, "gpio-%x", bus_id);
+	new_bus->id = kasprintf(GFP_KERNEL, "gpio-%x", bus_id);
 
 	if (gpio_request(bitbang->mdc, "mdc"))
 		goto out_free_bus;
diff --git a/drivers/net/phy/mdio-octeon.c b/drivers/net/phy/mdio-octeon.c
index 826d961..1158353 100644
--- a/drivers/net/phy/mdio-octeon.c
+++ b/drivers/net/phy/mdio-octeon.c
@@ -118,7 +118,7 @@ static int __devinit octeon_mdiobus_probe(struct platform_device *pdev)
 	bus->mii_bus->priv = bus;
 	bus->mii_bus->irq = bus->phy_irq;
 	bus->mii_bus->name = "mdio-octeon";
-	snprintf(bus->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
+	bus->mii_bus->id = kasprintf(GFP_KERNEL, "%s-%x",
 		bus->mii_bus->name, bus->unit);
 	bus->mii_bus->parent = &pdev->dev;
 
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index f320f46..6879e86 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -78,7 +78,7 @@ int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
 	if (!fixup)
 		return -ENOMEM;
 
-	strlcpy(fixup->bus_id, bus_id, sizeof(fixup->bus_id));
+	fixup->bus_id = kstrdup(bus_id, GFP_KERNEL);
 	fixup->phy_uid = phy_uid;
 	fixup->phy_uid_mask = phy_uid_mask;
 	fixup->run = run;
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index 980c079..4150655 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -166,7 +166,7 @@ struct phy_device *of_phy_connect_fixed_link(struct net_device *dev,
 					     phy_interface_t iface)
 {
 	struct device_node *net_np;
-	char bus_id[MII_BUS_ID_SIZE + 3];
+	const char *bus_id;
 	struct phy_device *phy;
 	const __be32 *phy_id;
 	int sz;
@@ -182,9 +182,10 @@ struct phy_device *of_phy_connect_fixed_link(struct net_device *dev,
 	if (!phy_id || sz < sizeof(*phy_id))
 		return NULL;
 
-	sprintf(bus_id, PHY_ID_FMT, "0", be32_to_cpu(phy_id[0]));
+	bus_id = kasprintf(GFP_KERNEL, PHY_ID_FMT, "0", be32_to_cpu(phy_id[0]));
 
 	phy = phy_connect(dev, bus_id, hndlr, 0, iface);
+	kfree(bus_id);
 	return IS_ERR(phy) ? NULL : phy;
 }
 EXPORT_SYMBOL(of_phy_connect_fixed_link);
diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
index 2c4069f..5199386 100644
--- a/drivers/staging/et131x/et131x.c
+++ b/drivers/staging/et131x/et131x.c
@@ -5358,7 +5358,7 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev,
 	}
 
 	adapter->mii_bus->name = "et131x_eth_mii";
-	snprintf(adapter->mii_bus->id, MII_BUS_ID_SIZE, "%x",
+	adapter->mii_bus->id = kasprintf(GFP_KERNEL, "%x",
 		(adapter->pdev->bus->number << 8) | adapter->pdev->devfn);
 	adapter->mii_bus->priv = netdev;
 	adapter->mii_bus->read = et131x_mdio_read;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index c599f7e..bf051a7 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -78,12 +78,6 @@ typedef enum {
 /* Used when trying to connect to a specific phy (mii bus id:phy device id) */
 #define PHY_ID_FMT "%s:%02x"
 
-/*
- * Need to be a little smaller than phydev->dev.bus_id to leave room
- * for the ":%02x"
- */
-#define MII_BUS_ID_SIZE	(20 - 3)
-
 /* Or MII_ADDR_C45 into regnum for read/write on mii_bus to enable the 21 bit
    IEEE 802.3ae clause 45 addressing mode used by 10GIGE phy chips. */
 #define MII_ADDR_C45 (1<<30)
@@ -94,7 +88,7 @@ typedef enum {
  */
 struct mii_bus {
 	const char *name;
-	char id[MII_BUS_ID_SIZE];
+	const char *id;
 	void *priv;
 	int (*read)(struct mii_bus *bus, int phy_id, int regnum);
 	int (*write)(struct mii_bus *bus, int phy_id, int regnum, u16 val);
@@ -441,7 +435,7 @@ struct phy_driver {
 /* A Structure for boards to register fixups with the PHY Lib */
 struct phy_fixup {
 	struct list_head list;
-	char bus_id[20];
+	const char *bus_id;
 	u32 phy_uid;
 	u32 phy_uid_mask;
 	int (*run)(struct phy_device *phydev);
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 56cf9b8..ae0e3ea 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -41,7 +41,7 @@ void dsa_slave_mii_bus_init(struct dsa_switch *ds)
 	ds->slave_mii_bus->name = "dsa slave smi";
 	ds->slave_mii_bus->read = dsa_slave_phy_read;
 	ds->slave_mii_bus->write = dsa_slave_phy_write;
-	snprintf(ds->slave_mii_bus->id, MII_BUS_ID_SIZE, "%s:%.2x",
+	ds->slave_mii_bus->id = kasprintf(GFP_KERNEL, "%s:%.2x",
 			ds->master_mii_bus->id, ds->pd->sw_addr);
 	ds->slave_mii_bus->parent = &ds->master_mii_bus->dev;
 }
-- 
1.7.0.4

^ permalink raw reply related

* Re: [PATCH v5 0/2] Adding new TI Common Platform ethernet SWitch driver
From: Eric Dumazet @ 2012-03-20  4:06 UTC (permalink / raw)
  To: David Miller; +Cc: mugunthanvnm, netdev
In-Reply-To: <20120319.180659.2108026289616852615.davem@davemloft.net>

On Mon, 2012-03-19 at 18:06 -0400, David Miller wrote:
> From: Mugunthan V N <mugunthanvnm@ti.com>
> Date: Mon, 19 Mar 2012 11:47:52 +0530
> 
> > The following series contains driver implementation for TI Common Platform
> > ethernet SWitch (CPSW) driver.
> > 
> > CPSW is found in following SoC.
> > * AM335X - http://www.ti.com/litv/pdf/spruh73c
> > * DM814X - http://www.ti.com/litv/pdf/sprugz8
> > 
> > CPSW:
> > The three port switch gigabit ethernet subsystem provides ethernet packet
> > communication and can be configured as an ethernet switch.  It
> > supports 10/100/1000 Mbps. It provides the gigabit media independent
> > interface (G/MII), reduced gigabit media independent interface (RGMII),
> > reduced media independent interface (RMII), the management data input
> > output (MDIO) for physical layer device (PHY) management.
> 
> All applied.

It appears this driver doesnt have a ndo_change_mtu method, so I suspect
some bad things could happen.

I wonder if we should WARN is netdev_ops->ndo_change_mtu is NULL

For an ethernet driver, using eth_change_mtu seems the right thing.

^ permalink raw reply

* Re: [PATCH wireless-next 2/3] ath5k: Introduce _ath5k_printk to reduce code/text
From: Joe Perches @ 2012-03-20  3:48 UTC (permalink / raw)
  To: Adrian Chadd
  Cc: Jiri Slaby, ath5k-devel-xDcbHBWguxEUs3QNXV6qNA,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA, John W. Linville,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <CAJ-Vmom4n7Sk5P=HMb+Z-FNyfyk87Xbf5Q1kPA4i2eXwQ72kXQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Mon, 2012-03-19 at 20:39 -0700, Adrian Chadd wrote:
> On 18 March 2012 22:18, Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org> wrote:
> >> Otherwise compiling in debugging will cause a _lot_ of spurious
> >> register reads to occur that are then tossed. This was one of the big
> >> reasons for instability and slow performance when AH_DEBUG was
> >> enabled.
> > That doesn't make any sense in this case.
> >
> > It's either a call to printk or _ath5_printk
> > but it's still a call to a function.
> 
> The FreeBSD HAL used to be like this. I changed it so it didn't
> evaluate the arguments before it figured out whether or not to do the
> (k)printf().
> 
> I'm just pointing it out as you're (currently) knee deep in the
> debugging code and it may be useful for you to also think about
> implementing.

I see, thanks for the heads-up.

The no_printk function could/does eval args
and can cause those sorts of issues.

So care does need to be used.

cheers, Joe

^ permalink raw reply

* Re: [PATCH wireless-next 2/3] ath5k: Introduce _ath5k_printk to reduce code/text
From: Adrian Chadd @ 2012-03-20  3:39 UTC (permalink / raw)
  To: Joe Perches
  Cc: Jiri Slaby, Nick Kossifidis, Luis R. Rodriguez, Bob Copeland,
	John W. Linville, linux-wireless, ath5k-devel, netdev,
	linux-kernel
In-Reply-To: <1332134336.23125.60.camel@joe2Laptop>

On 18 March 2012 22:18, Joe Perches <joe@perches.com> wrote:

>> Otherwise compiling in debugging will cause a _lot_ of spurious
>> register reads to occur that are then tossed. This was one of the big
>> reasons for instability and slow performance when AH_DEBUG was
>> enabled.
>
> That doesn't make any sense in this case.
>
> It's either a call to printk or _ath5_printk
> but it's still a call to a function.

The FreeBSD HAL used to be like this. I changed it so it didn't
evaluate the arguments before it figured out whether or not to do the
(k)printf().

I'm just pointing it out as you're (currently) knee deep in the
debugging code and it may be useful for you to also think about
implementing.


adrian

^ permalink raw reply

* Re: Kernel Panic with bonding + IPoIB on 3.2.9
From: Joseph Glanville @ 2012-03-20  3:33 UTC (permalink / raw)
  To: Roland Dreier; +Cc: linux-rdma, linux-kernel, netdev
In-Reply-To: <CAL1RGDVAd-LiS0sy6RAFNzkUuXrcuGv829nADcnxUnC2tfx3bw@mail.gmail.com>

On 20 March 2012 06:05, Roland Dreier <roland@purestorage.com> wrote:
> On Sun, Mar 18, 2012 at 1:21 PM, Joseph Glanville
> <joseph.glanville@orionvm.com.au> wrote:
>> [  422.047024] kernel BUG at net/core/dev.c:1896!
>
> So this line is
>
>        BUG_ON(offset >= skb_headlen(skb));
>
> right?  No paritcular idea how we hit this, though...

Yep... I have looked through most of /drivers/net/bonding and I can't
really see why it should be blowing up there.. it really should cause
the BUG_ON under normal IPoIB if the MTU was the cause - yet I have
not experienced this.
The bonding code doesn't seem to do anything special with the MTU
other than propagating changes to the slaves.

-- 
Founder | Director | VP Research
Orion Virtualisation Solutions | www.orionvm.com.au | Phone: 1300 56
99 52 | Mobile: 0428 754 846

^ permalink raw reply

* [PATCH v2] ipv6: fix incorrent ipv6 ipsec packet fragment
From: Gao feng @ 2012-03-20  3:22 UTC (permalink / raw)
  To: steffen.klassert; +Cc: davem, netdev, Gao feng
In-Reply-To: <20120319080220.GA29891@secunet.com>

Since commit 299b0767(ipv6: Fix IPsec slowpath fragmentation problem)
In func ip6_append_data,after call skb_put(skb, fraglen + dst_exthdrlen)
the skb->len contains dst_exthdrlen,and we don't reduce dst_exthdrlen at last
This will make fraggap>0 in next "while cycle",and cause the size of skb incorrent

Fix this by reserve headroom for dst_exthdrlen.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
---
 net/ipv6/ip6_output.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index d97e071..8d5d204 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1418,6 +1418,8 @@ alloc_new_skb:
 			skb->csum = 0;
 			/* reserve for fragmentation */
 			skb_reserve(skb, hh_len+sizeof(struct frag_hdr));
+			/* reserve for ipsec header */
+			skb_reserve(skb, dst_exthdrlen);
 
 			if (sk->sk_type == SOCK_DGRAM)
 				skb_shinfo(skb)->tx_flags = tx_flags;
@@ -1425,9 +1427,9 @@ alloc_new_skb:
 			/*
 			 *	Find where to start putting bytes
 			 */
-			data = skb_put(skb, fraglen + dst_exthdrlen);
-			skb_set_network_header(skb, exthdrlen + dst_exthdrlen);
-			data += fragheaderlen + dst_exthdrlen;
+			data = skb_put(skb, fraglen);
+			skb_set_network_header(skb, exthdrlen);
+			data += fragheaderlen;
 			skb->transport_header = (skb->network_header +
 						 fragheaderlen);
 			if (fraggap) {
-- 
1.7.7.6

^ permalink raw reply related

* Re: [PATCH] net: bpf_jit: Simplify code by always using offset8 or offset32.
From: Eric Dumazet @ 2012-03-20  2:59 UTC (permalink / raw)
  To: Indan Zupancic
  Cc: Will Drewry, linux-kernel, linux-arch, linux-doc,
	kernel-hardening, netdev, x86, arnd, davem, hpa, mingo, oleg,
	peterz, rdunlap, mcgrathr, tglx, luto, eparis, serge.hallyn, djm,
	scarybeasts, pmoore, akpm, corbet, markus, coreyb, keescook
In-Reply-To: <371a1925e68e68f873e30381e0fa60ea.squirrel@webmail.greenhost.nl>

On Tue, 2012-03-20 at 13:24 +1100, Indan Zupancic wrote:

> If it does then perhaps the fast path should be made faster by inlining
> the code instead of calling a function which may not be cached.
> 

inlining 400 times a sequence of code is waste of icache, you probably
missed this.

I spent a lot of time on working on this implementation, tried many
different strategies before choosing the one in place.

Listen, I am tired of this thread, it seems you want to push changes
that have almost no value but still need lot of review.

Unless you make benchmarks and can make at least 5 % improvement of the
speed, or improve maintainability of this code, I am not interested.

We certainly _can_ one day have sizeof(struct sk_buff) > 256, and actual
code is ready for this. You want to break this for absolutely no valid
reason.

We _can_ change fields order anytime in struct sk_buff, even if you
state "its very unlikely that those fields are ever moved to the end
of sk_buff".




^ permalink raw reply

* Re: [net-next PATCH v0 0/5] Series short description
From: Stephen Hemminger @ 2012-03-20  2:51 UTC (permalink / raw)
  To: John Fastabend
  Cc: David Miller, jhs, bhutchings, roprabhu, jeffrey.t.kirsher,
	netdev, mst, chrisw, gregory.v.rose, kvm, sri, chealy
In-Reply-To: <4F67F04E.8060800@intel.com>

On Mon, 19 Mar 2012 19:49:50 -0700
John Fastabend <john.r.fastabend@intel.com> wrote:

> On 3/19/2012 5:35 PM, David Miller wrote:
> > From: John Fastabend <john.r.fastabend@intel.com>
> > Date: Mon, 19 Mar 2012 17:27:00 -0700
> > 
> >> Dave, its probably fine to push this to 3.5 then.
> > 
> > Fair enough.
> 
> Stephen, please let me know if you see any issues though
> because without these we have no way to forward packets
> correctly in the embedded switch. So we can't really
> use SR-IOV and virtual interfaces together correctly. And
> the macvlan device in passthru mode is putting the device
> in promiscuous mode which isn't great either.
> 
> .John

I am more worried about evaluating ABI compatibility with older
utilities.

^ permalink raw reply

* Re: [net-next PATCH v0 0/5] Series short description
From: John Fastabend @ 2012-03-20  2:49 UTC (permalink / raw)
  To: David Miller, shemminger
  Cc: jhs, bhutchings, roprabhu, jeffrey.t.kirsher, netdev, mst, chrisw,
	gregory.v.rose, kvm, sri, chealy
In-Reply-To: <20120319.203541.1126968121556911783.davem@davemloft.net>

On 3/19/2012 5:35 PM, David Miller wrote:
> From: John Fastabend <john.r.fastabend@intel.com>
> Date: Mon, 19 Mar 2012 17:27:00 -0700
> 
>> Dave, its probably fine to push this to 3.5 then.
> 
> Fair enough.

Stephen, please let me know if you see any issues though
because without these we have no way to forward packets
correctly in the embedded switch. So we can't really
use SR-IOV and virtual interfaces together correctly. And
the macvlan device in passthru mode is putting the device
in promiscuous mode which isn't great either.

.John

^ permalink raw reply

* [PATCH] net: bpf_jit: Simplify code by always using offset8 or offset32.
From: Indan Zupancic @ 2012-03-20  2:24 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Will Drewry, linux-kernel, linux-arch, linux-doc,
	kernel-hardening, netdev, x86, arnd, davem, hpa, mingo, oleg,
	peterz, rdunlap, mcgrathr, tglx, luto, eparis, serge.hallyn, djm,
	scarybeasts, pmoore, akpm, corbet, markus, coreyb, keescook
In-Reply-To: <1332075121.3722.34.camel@edumazet-laptop>

On Sun, March 18, 2012 23:52, Eric Dumazet wrote:
> Le dimanche 18 mars 2012 à 19:35 +1100, Indan Zupancic a écrit :
>
>> Yes. The main difference would be that the JIT could always generate imm8
>> offsets, saving 4 bytes per long offset while also simplifying the compiler
>> code. The %rdi + 127 is 4 bytes, and if the rest become slightly faster
>> because they're imm8 then it's worth the extra instruction.
>>
>
> Do you understand you try to save 3 bytes in the function prolog, but
> your single EMIT4(0x48, 0x83, 0xc7, 127); /* addq $127,%rdi */
> defeats this ?

That's not what I'm trying to do, I'm trying to simplify the code
so it's easier to verify and less cluttered. I admit the fixup in
bpf_slow_path_common makes it a bad idea over all. But if that one
extra addq would have been all that was needed then it would have
been worth it I think. Even if it makes the prologue one byte longer.

>
> Ancillary instructions are rarely used, libpcap for example doesnt have
> support for them.
>
>> I first thought the +127 could be done in two bytes, but 4 bytes are
>> needed, so maybe it's not worth it.
> ...
>> The add 127 would be at the start, the first instruction using it would
>> be a couple of instructions later, so I don't think the dependency is a
>> problem.
>>
>> You're right about skb_copy_bits(), I did a quick search for rdi usage
>> but missed it was the first parameter too. It would need one extra
>> sub 127 or add -127 in the slow path, after the push. But it's the slow
>> path already, one extra instruction won't make much difference.
>
> It will, because new NIC drivers tend to provide skbs with fragments.

If it does then perhaps the fast path should be made faster by inlining
the code instead of calling a function which may not be cached.

>
> Using libpcap filter like "udp[100]" calls the skb_copy_bits() helper in
> this case.
>
> There is no difference in instruction timing using offset32 or offset8,
> so the code you add will slow the filter anyway.

I assumed optimising for imm8 was worthwile, but if it's the same speed,
saving a few bytes here and there while wasting kilobytes of memory
any way doesn't make much sense.

Greetings,

Indan


[PATCH] net: bpf_jit: Simplify code by always using offset8 or offset32.

Instruction timing of offset32 or offset8 is the same, do not bother saving
a few bytes of code here and there. Only use offset8 for skb.len, skb.data_len
and skb.dev: It is very unlikely that those fields are ever moved to the end
of sk_buff. The other fields are used in ancillary instructions, for those
always use offset32.

Signed-off-by: Indan Zupancic <indan@nul.nu>

 arch/x86/net/bpf_jit_comp.c |  104 +++++++++++++------------------------------
 1 files changed, 31 insertions(+), 73 deletions(-)
---
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 7c1b765..5ddb82b 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -102,6 +102,12 @@ do {								\
 		f_op = FOP;		\
 		goto cond_branch

+#define SKB_OFF8(field) ({				\
+	int _off = offsetof(struct sk_buff, field);	\
+	BUILD_BUG_ON(_off > 127);			\
+	_off;						\
+	})
+

 #define SEEN_DATAREF 1 /* might call external helpers */
 #define SEEN_XREG    2 /* ebx is used */
@@ -172,30 +178,13 @@ void bpf_jit_compile(struct sk_filter *fp)
 			 *  r8 = skb->data
 			 */
 			if (seen_or_pass0 & SEEN_DATAREF) {
-				if (offsetof(struct sk_buff, len) <= 127)
-					/* mov    off8(%rdi),%r9d */
-					EMIT4(0x44, 0x8b, 0x4f, offsetof(struct sk_buff, len));
-				else {
-					/* mov    off32(%rdi),%r9d */
-					EMIT3(0x44, 0x8b, 0x8f);
-					EMIT(offsetof(struct sk_buff, len), 4);
-				}
-				if (is_imm8(offsetof(struct sk_buff, data_len)))
-					/* sub    off8(%rdi),%r9d */
-					EMIT4(0x44, 0x2b, 0x4f, offsetof(struct sk_buff, data_len));
-				else {
-					EMIT3(0x44, 0x2b, 0x8f);
-					EMIT(offsetof(struct sk_buff, data_len), 4);
-				}
-
-				if (is_imm8(offsetof(struct sk_buff, data)))
-					/* mov off8(%rdi),%r8 */
-					EMIT4(0x4c, 0x8b, 0x47, offsetof(struct sk_buff, data));
-				else {
-					/* mov off32(%rdi),%r8 */
-					EMIT3(0x4c, 0x8b, 0x87);
-					EMIT(offsetof(struct sk_buff, data), 4);
-				}
+				/* mov    off8(%rdi),%r9d */
+				EMIT4(0x44, 0x8b, 0x4f, SKB_OFF8(len));
+				/* sub    off8(%rdi),%r9d */
+				EMIT4(0x44, 0x2b, 0x4f, SKB_OFF8(data_len));
+				/* mov off32(%rdi),%r8 */
+				EMIT3(0x4c, 0x8b, 0x87);
+				EMIT(offsetof(struct sk_buff, data), 4);
 			}
 		}

@@ -391,43 +380,24 @@ void bpf_jit_compile(struct sk_filter *fp)
 				break;
 			case BPF_S_LD_W_LEN: /*	A = skb->len; */
 				BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, len) != 4);
-				if (is_imm8(offsetof(struct sk_buff, len)))
-					/* mov    off8(%rdi),%eax */
-					EMIT3(0x8b, 0x47, offsetof(struct sk_buff, len));
-				else {
-					EMIT2(0x8b, 0x87);
-					EMIT(offsetof(struct sk_buff, len), 4);
-				}
+				/* mov    off8(%rdi),%eax */
+				EMIT3(0x8b, 0x47, SKB_OFF8(len));
 				break;
 			case BPF_S_LDX_W_LEN: /* X = skb->len; */
 				seen |= SEEN_XREG;
-				if (is_imm8(offsetof(struct sk_buff, len)))
-					/* mov off8(%rdi),%ebx */
-					EMIT3(0x8b, 0x5f, offsetof(struct sk_buff, len));
-				else {
-					EMIT2(0x8b, 0x9f);
-					EMIT(offsetof(struct sk_buff, len), 4);
-				}
+				/* mov off8(%rdi),%ebx */
+				EMIT3(0x8b, 0x5f, SKB_OFF8(len));
 				break;
 			case BPF_S_ANC_PROTOCOL: /* A = ntohs(skb->protocol); */
 				BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, protocol) != 2);
-				if (is_imm8(offsetof(struct sk_buff, protocol))) {
-					/* movzwl off8(%rdi),%eax */
-					EMIT4(0x0f, 0xb7, 0x47, offsetof(struct sk_buff, protocol));
-				} else {
-					EMIT3(0x0f, 0xb7, 0x87); /* movzwl off32(%rdi),%eax */
-					EMIT(offsetof(struct sk_buff, protocol), 4);
-				}
+				/* movzwl off32(%rdi),%eax */
+				EMIT3(0x0f, 0xb7, 0x87);
+				EMIT(offsetof(struct sk_buff, protocol), 4);
 				EMIT2(0x86, 0xc4); /* ntohs() : xchg   %al,%ah */
 				break;
 			case BPF_S_ANC_IFINDEX:
-				if (is_imm8(offsetof(struct sk_buff, dev))) {
-					/* movq off8(%rdi),%rax */
-					EMIT4(0x48, 0x8b, 0x47, offsetof(struct sk_buff, dev));
-				} else {
-					EMIT3(0x48, 0x8b, 0x87); /* movq off32(%rdi),%rax */
-					EMIT(offsetof(struct sk_buff, dev), 4);
-				}
+				/* movq off8(%rdi),%rax */
+				EMIT4(0x48, 0x8b, 0x47, SKB_OFF8(dev));
 				EMIT3(0x48, 0x85, 0xc0);	/* test %rax,%rax */
 				EMIT_COND_JMP(X86_JE, cleanup_addr - (addrs[i] - 6));
 				BUILD_BUG_ON(FIELD_SIZEOF(struct net_device, ifindex) != 4);
@@ -436,33 +406,21 @@ void bpf_jit_compile(struct sk_filter *fp)
 				break;
 			case BPF_S_ANC_MARK:
 				BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, mark) != 4);
-				if (is_imm8(offsetof(struct sk_buff, mark))) {
-					/* mov off8(%rdi),%eax */
-					EMIT3(0x8b, 0x47, offsetof(struct sk_buff, mark));
-				} else {
-					EMIT2(0x8b, 0x87);
-					EMIT(offsetof(struct sk_buff, mark), 4);
-				}
+				/* mov off32(%rdi),%eax */
+				EMIT2(0x8b, 0x87);
+				EMIT(offsetof(struct sk_buff, mark), 4);
 				break;
 			case BPF_S_ANC_RXHASH:
 				BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, rxhash) != 4);
-				if (is_imm8(offsetof(struct sk_buff, rxhash))) {
-					/* mov off8(%rdi),%eax */
-					EMIT3(0x8b, 0x47, offsetof(struct sk_buff, rxhash));
-				} else {
-					EMIT2(0x8b, 0x87);
-					EMIT(offsetof(struct sk_buff, rxhash), 4);
-				}
+				/* mov off32(%rdi),%eax */
+				EMIT2(0x8b, 0x87);
+				EMIT(offsetof(struct sk_buff, rxhash), 4);
 				break;
 			case BPF_S_ANC_QUEUE:
 				BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, queue_mapping) != 2);
-				if (is_imm8(offsetof(struct sk_buff, queue_mapping))) {
-					/* movzwl off8(%rdi),%eax */
-					EMIT4(0x0f, 0xb7, 0x47, offsetof(struct sk_buff, queue_mapping));
-				} else {
-					EMIT3(0x0f, 0xb7, 0x87); /* movzwl off32(%rdi),%eax */
-					EMIT(offsetof(struct sk_buff, queue_mapping), 4);
-				}
+				/* movzwl off32(%rdi),%eax */
+				EMIT3(0x0f, 0xb7, 0x87);
+				EMIT(offsetof(struct sk_buff, queue_mapping), 4);
 				break;
 			case BPF_S_ANC_CPU:
 #ifdef CONFIG_SMP

^ permalink raw reply related

* Re: [PATCH] adjust __net_exit
From: Eric W. Biederman @ 2012-03-20  2:17 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Sam Ravnborg, David Miller, xemul, netdev, netfilter-devel
In-Reply-To: <4F6705ED0200007800079343@nat28.tlf.novell.com>

"Jan Beulich" <JBeulich@suse.com> writes:

>>>> On 19.03.12 at 09:47, Sam Ravnborg <sam@ravnborg.org> wrote:
>>> >> > Using the (bogus and unused elsewhere)
>>> >> > __exit_refok to implement this is inefficient - any non-modular code
>>> >> > really can reside in __init (as non-modular __exit code is never used).
>> 
>>> > 2) fix up the bogus commit message
>>> 
>>> Bogus in what way?
>> 
>> I fail to see that __exit_refok is bogus.
>
> Either an exit function references only permitted code (in which case
> it is legitimately using __exit), or it references non-__exit code, in
> which case it shouldn't have an override at all. Permitting an exit
> function to reference e.g. __init code is suspicious (at best) in all
> cases I can think of (in contrast to allowing a non-init function to
> reference __init code on a code path that can be proven to be taken
> only during system startup).

My apologies I said that there was nothing network namespace specific
left to talk about and I had goofed in my analysis.  The weirdness with
references comes from how struct pernet_operations is used.

Structures of type struct pernet_operations hold holds pointers to .init
functions marked as __net_init and .exit and .exit_batch marked as
__net_exit.

The assertion is that references from static instances of struct
pernet_operations that live in __net_initdata should be ok.


Structures of type pernet_operations are passed to
register_pernet_subsys or register_pernet_device which ultimately call
register_pernet_operations.  Register pernet_operations when the network
namespace is disabled simply calls the .init function when the network
namespace code is compiled out.  The .exit and .exit_batch functions
are not referenced at all.

When the network namespace code is compiled in __net_init __net_exit
and __net_initdata all go away.

So the exit function references only permitted code.  But the exit
function is being referenced by data in an init section which requires
the override.

How should we mark functions in __net_exit that can be thrown away
when outside of a module and never even loaded when compiled into the
kernel when the network namespace is disabled?

The original definition of __exit_refok seemed to say this very clearly
to me.  This is an __exit section but references to it from __init data
are ok.

Eric

^ permalink raw reply

* (unknown), 
From: FINAL PAYMENT SETTLEMENT BOARD. @ 2012-03-20  1:29 UTC (permalink / raw)





FINAL PAYMENT SETTLEMENT BOARD.
London United Kingdom
24 Grosvenor Square London,

I write to notify you about your outstanding compensation
Payment from the United Nations Human Settlements Board.

During our last annual calculation of all your banking and Internet
activities, we realized that you are eligible to receive compensation
Payment of $850,000 USD. This compensation is being made to all banks
and internet users.

You are required to contact him with the following details, as
this will enable us to process and release your cash prize.
NOTE THAT THESE DETAILS ARE VERY IMPORTANT FOR YOUR PAYMENT

Provide the information below:
1.Full Names:....    2.Address:.........
3.Sex and Age:............    4.Country:.............
5.Occupation:..........    6.Phone no:........
7.Company Name:..........

contact E-mail: debt.settlement1board@ozledim.net

Regards
Robin Steven

^ permalink raw reply

* Re: [PATCH] ipv6: fix incorrent ipv6 ipsec packet fragment
From: Gao feng @ 2012-03-20  1:09 UTC (permalink / raw)
  To: Steffen Klassert; +Cc: davem, eric.dumazet, netdev
In-Reply-To: <20120319080220.GA29891@secunet.com>

于 2012年03月19日 16:02, Steffen Klassert 写道:
> On Fri, Mar 16, 2012 at 04:57:15PM +0800, Gao feng wrote:
>> Since commit 299b0767(ipv6: Fix IPsec slowpath fragmentation problem)
>> In func ip6_append_data,after call skb_put(skb, fraglen + dst_exthdrlen)
>> the skb->len contains dst_exthdrlen,and we don't reduce dst_exthdrlen at last
>> This will make fraggap>0 in next "while cycle",and cause the size of skb incorrent
> 
> Good catch!
> 
>>
>> Call skb_pull reduce skb->len before next "while cycle"
> 
> I think it would be better to just reserve headroom for
> dst_exthdrlen instead of adding and removing data to/from
> the skb.
> 

Hi steffen & David:

Thanks for your comment.
Agree with you,I will send v2 patch.

^ permalink raw reply

* [ANNOUNCE] iproute2 3.3.0
From: Stephen Hemminger @ 2012-03-20  1:03 UTC (permalink / raw)
  To: netdev, linux-kernel

The Sabre toothed Squirrel is released, and this means it is time for another
version of iproute2 (Maniac Moose??)

The main new features are:
  * Updated qdisc parameters in sfq and red
  * Netem extensions for shaping 
  * L2TP tunnelling
  * Lots of manual page corrections

Source:
  http://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-3.3.0.tar.gz

Repository:
  git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git

This version is signed with my GPG public key

Report problems (or enhancements) to the netdev@vger.kernel.org mailing list.

---
Andreas Henriksson (1):
      iproute: fix tc -iec display of Mibit rates

Anton Danilov (1):
      csum action, fix typo

Eric Dumazet (8):
      red: Add adaptative algo
      red: fix adaptive spelling
      sfq: add optional RED on top of SFQ
      choke: support TCA_CHOKE_MAX_P
      gred: support TCA_GRED_MAX_P attribute
      tc-red: update man page
      tc-sfq: update man page
      ss: should support CONFIG_INET_UDP_DIAG=n kernels

Florian Westphal (1):
      ip: xfrm: report nat-t/encapsulation portmapping updates

Greg Rose (1):
      iproute2: Add VF spoofchk command description to ip-link.8 man page

Hagen Paul Pfeifer (2):
      utils: add s32 parser
      tc: netem rate shaping and cell extension

Kenyon Ralph (1):
      Update ip address manual page

Masatake YAMATO (1):
      using NLM_F_DUMP flag constant in libnetlink.c

Matt Tierney (1):
      ss: Close file descriptors in tcp_show_netlink.

Pavel Emelyanov (1):
      iproute: Dump unix sockets via netlink

Petr Sabata (1):
      iproute2: tc - mqprio formatted print fix

Stephen Hemminger (23):
      iplt2p: remove unused libnl headers
      Fix man page whatis entry errors
      Update to kernel v3.3 headers
      Update to 3.3 headers (with inet_diag fix)
      netem: add rate extension to man page
      ip: make 'ip l' be 'ip link'
      Merge branch 'master' of nehalam:src/iproute2
      Fix unix socket diagnostic build
      Add cast to rta_getattr_str
      red: add missing include math.h
      Don't put configure files in /tmp
      dhcp-client-script: don't use /tmp
      ss: simplify code
      arpd: allow configuring polling interval
      ipaddress: cleanup code for link stats64
      Keep cscope around after make clean
      iproute: allow changing gretap parameters
      Fix ip-monitor manual page what-is entry
      update to 3.3-rc7 kernel headers
      Fix rta_getattr_u32 wrapper and add getattr_u8
      gre: allow 0 as a legal key value
      ip: allow set and display of link mode parameter
      v3.3.0

Tony Zelenoff (2):
      Modify neighbour proxy show
      Adjust man page for new functionality

Vijay Subramanian (4):
      netem: Add missing '}' in man page
      netem: Fail cleanly if user input is wrong
      netem: Fix up grammatical errors in man page
      netem: Fix 'reorder' section of man page

Yegor Yefremov (1):
      iproute2: cleanup dependencies

nick black (1):
      Update ip manpage

^ permalink raw reply

* Re: [net-next PATCH v0 0/5] Series short description
From: David Miller @ 2012-03-20  0:35 UTC (permalink / raw)
  To: john.r.fastabend
  Cc: shemminger, jhs, bhutchings, roprabhu, jeffrey.t.kirsher, netdev,
	mst, chrisw, gregory.v.rose, kvm, sri, chealy
In-Reply-To: <4F67CED4.4000700@intel.com>

From: John Fastabend <john.r.fastabend@intel.com>
Date: Mon, 19 Mar 2012 17:27:00 -0700

> Dave, its probably fine to push this to 3.5 then.

Fair enough.

^ permalink raw reply

* Re: [net-next PATCH v0 0/5] Series short description
From: John Fastabend @ 2012-03-20  0:27 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: David Miller, jhs, bhutchings, roprabhu, jeffrey.t.kirsher,
	netdev, mst, chrisw, gregory.v.rose, kvm, sri, chealy
In-Reply-To: <20120319155537.79d5802c@nehalam.linuxnetplumber.net>

On 3/19/2012 3:55 PM, Stephen Hemminger wrote:
> On Mon, 19 Mar 2012 18:38:08 -0400 (EDT)
> David Miller <davem@davemloft.net> wrote:
> 
>> From: John Fastabend <john.r.fastabend@intel.com>
>> Date: Sun, 18 Mar 2012 23:51:45 -0700
>>
>>> This series is a follow up to this thread:
>>>
>>> http://www.spinics.net/lists/netdev/msg191360.html
>>
>> Can the interested parties please review this series?
>>
>> I'm willing to apply this right now if it looks OK, but if
>> it needs more revisions we'll have to defer.
> 
> Please don't rush this into this merge window. It needs more than
> 1 full day of review.

Dave, its probably fine to push this to 3.5 then. I can
resubmit after you close the merge window if you want? This
has been somewhat broken for SR-IOV cards for multiple
kernel releases now anyways one more wont hurt too much.

I'll work with Roopa to get the macvlan driver plugged into
the fdb ops in the meantime and maybe get DSA as well.

Thanks,
John

^ permalink raw reply

* [PATCH] net: bpf_jit: Document evilness of negative indirect loads
From: Indan Zupancic @ 2012-03-20  0:16 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David Miller, Will Drewry, linux-kernel, linux-arch, linux-doc,
	kernel-hardening, netdev, x86, arnd, hpa, mingo, oleg, peterz,
	rdunlap, mcgrathr, tglx, luto, eparis, serge.hallyn, djm,
	scarybeasts, pmoore, akpm, corbet, markus, coreyb, keescook,
	Matt Evans
In-Reply-To: <1332074448.3722.25.camel@edumazet-laptop>

On Sun, March 18, 2012 23:40, Eric Dumazet wrote:
> Le dimanche 18 mars 2012 à 19:35 +1100, Indan Zupancic a écrit :
>
>> And in the 00.00001% case that the filter uses a computed negative
>> offset the BPF JIT fails at runtime. So to not be buggy you need at
>> least a call to __load_pointer() for the negative case.
>
> Please show me how and why a real (I mean useful one...) filter could
> generate a dynamic negative value, and I'll change the code.
>
>
> Negative values are there to allow access to network/mac header
> components. I cant see how a BPF code could have a valid use of dynamic
> indexes in these headers.

E.g. when poking in a variable length IP header with a filter
attached to a TCP/UDP socket. Still a bit far fetched though.

>
> Right now we consider such code is evil and filter does "return 0"
> saying so.

I'm fine with that, but this should be documented somewhere I think.

Greetings,

Indan


[PATCH] net: bpf_jit: Document evilness of negative indirect loads

Negative offsets are used to access ancillary data. In the case of
SKF_NET_OFF and SKF_LL_OFF users may expect negative indirect loads
to work. If BPF JIT is used then such loads will fail. In any case,
negative indirect loads are considered evil and are not supported.

---

Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Indan Zupancic <indan@nul.nu>

diff --git a/include/linux/filter.h b/include/linux/filter.h
index 8eeb205..2bd4bbb 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -114,6 +114,9 @@ struct sock_fprog {	/* Required for SO_ATTACH_FILTER. */
    We use them to reference ancillary data.
    Unlike introduction new instructions, it does not break
    existing compilers/optimizers.
+
+   Do not expect negative indirect loads to work, they are
+   considered evil.
  */
 #define SKF_AD_OFF    (-0x1000)
 #define SKF_AD_PROTOCOL 0

^ permalink raw reply related

* [PATCH] gre: propagate state of link back go to tunnel
From: Stephen Hemminger @ 2012-03-19 23:58 UTC (permalink / raw)
  To: Herbert Xu, David Miller; +Cc: netdev

GRE tunnels like other layered devices should propagate
carrier and RFC2863 state from lower device to tunnel.
Based on similar code in vlan device driver.
By using operstate it is possible for user mode to create tunnel
and use stepped outlined in Documentation/networking/operstate.txt
to control carrier.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

---
Not urgent, can wait if the release window is already over the
queue limit

--- a/net/ipv4/ip_gre.c	2012-03-19 16:09:46.662376422 -0700
+++ b/net/ipv4/ip_gre.c	2012-03-19 16:13:49.845108466 -0700
@@ -961,6 +961,7 @@ static int ipgre_tunnel_bind_dev(struct
 	if (tdev) {
 		hlen = tdev->hard_header_len + tdev->needed_headroom;
 		mtu = tdev->mtu;
+		netif_stacked_transfer_operstate(tdev, dev);
 	}
 	dev->iflink = tunnel->parms.link;
 
@@ -1545,6 +1546,7 @@ static int ipgre_newlink(struct net *src
 
 	dev_hold(dev);
 	ipgre_tunnel_link(ign, nt);
+	linkwatch_fire_event(dev); /* _MUST_ call rfc2863_policy() */
 
 out:
 	return err;
@@ -1701,6 +1703,34 @@ static struct rtnl_link_ops ipgre_tap_op
 	.fill_info	= ipgre_fill_info,
 };
 
+/* If lower device changes state, reflect that to the tunnel. */
+static int ipgre_notify(struct notifier_block *unused,
+			unsigned long event, void *ptr)
+{
+	struct net_device *dev = ptr;
+	struct net *net = dev_net(dev);
+	struct ipgre_net *ign = net_generic(net, ipgre_net_id);
+	unsigned int i, h;
+	struct ip_tunnel *t;
+
+	if (event == NETDEV_CHANGE)
+		return NOTIFY_DONE;
+
+	for (i = 0; i < 4; i++)
+		for (h = 0; h < HASH_SIZE; h++)
+			for(t = ign->tunnels[i][h]; t; t = t->next) {
+				if (dev->ifindex != t->dev->iflink)
+					continue;
+				netif_stacked_transfer_operstate(dev, t->dev);
+			}
+
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block ipgre_notifier = {
+	.notifier_call = ipgre_notify,
+};
+
 /*
  *	And now the modules code and kernel interface.
  */
@@ -1729,9 +1759,15 @@ static int __init ipgre_init(void)
 	if (err < 0)
 		goto tap_ops_failed;
 
+	err = register_netdevice_notifier(&ipgre_notifier);
+	if (err < 0)
+		goto notify_failed;
+
 out:
 	return err;
 
+notify_failed:
+	rtnl_link_unregister(&ipgre_tap_ops);
 tap_ops_failed:
 	rtnl_link_unregister(&ipgre_link_ops);
 rtnl_link_failed:
@@ -1743,6 +1779,7 @@ add_proto_failed:
 
 static void __exit ipgre_fini(void)
 {
+	unregister_netdevice_notifier(&ipgre_notifier);
 	rtnl_link_unregister(&ipgre_tap_ops);
 	rtnl_link_unregister(&ipgre_link_ops);
 	if (gre_del_protocol(&ipgre_protocol, GREPROTO_CISCO) < 0)

^ permalink raw reply

* balancing crypto with NAPI flow vs. tasklet (was: Re: Hi,)
From: Kim Phillips @ 2012-03-19 23:38 UTC (permalink / raw)
  To: horia.geanta; +Cc: linux-crypto, netdev, herbert, davem, Sandeep.Malik
In-Reply-To: <1331556267-3920-1-git-send-email-horia.geanta@freescale.com>

On Mon, 12 Mar 2012 14:44:27 +0200
<horia.geanta@freescale.com> wrote:

> This patch replaces the back-half implementation of talitos crypto engine from
> tasklet to NAPI. The decision to do this was based on improved performance
> (around 7%).
> A similiar patch (not posted yet) was tested for caam crypto engine, with
> 10-15% improvement over tasklet.
> 
> Since having crypto engines use the net softirq is probably not acceptable,
> I would like to hear your comments on what options do I have to make this
> upstreamable.
> Besides current approach, I am considering the following:
> - defining a new softirq for crypto engines, having a higher priority than the
> NET_RX_SOFTIRQ

but the priority just has to be equal to NET_RX_SOFTIRQ to get the
net--crypto performance balance, not necessarily higher IIRC.

> - using tasklet_hi_schedule instead of tasklet_schedule

this has done close to nothing for performance in my experience -
but there is no other tasklet competing for the slice in my IPSec
fwding tests either.

> Let me know if any of these two fits better or if something else is preferred.

Herbert/Dave,

Is it ok for a crypto driver to depend on NET?  If not, how should
the NAPI-style flow be abstracted out of NET?

Thanks,

Kim

> Thank you
> 
> From 20f30ef6fdfe641f1c30f94320891715ffee33a2 Mon Sep 17 00:00:00 2001
> From: Sandeep Malik <Sandeep.Malik@freescale.com>
> Date: Sat, 12 Jun 2010 14:08:47 +0800
> Subject: [RFC,PATCH] crypto: talitos - Replace the tasklet implementation with NAPI
> 
> This patch updates the current tasklet implement to NAPI so as
> the system is more balanced in the terms that the packet submission
> and the packet forwarding after being processed can be done at
> the same priority.
> 
> Signed-off-by: Sandeep Malik <Sandeep.Malik@freescale.com>
> Signed-off-by: Horia Geanta <horia.geanta@freescale.com>
> ---
>  drivers/crypto/Kconfig   |    2 +-
>  drivers/crypto/talitos.c |  145 +++++++++++++++++++++++++++++++++-------------
>  drivers/crypto/talitos.h |    4 +-
>  3 files changed, 109 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
> index e707979..682096b 100644
> --- a/drivers/crypto/Kconfig
> +++ b/drivers/crypto/Kconfig
> @@ -218,7 +218,7 @@ config CRYPTO_DEV_TALITOS
>  	select CRYPTO_ALGAPI
>  	select CRYPTO_AUTHENC
>  	select HW_RANDOM
> -	depends on FSL_SOC
> +	depends on FSL_SOC && NET
>  	help
>  	  Say 'Y' here to use the Freescale Security Engine (SEC)
>  	  to offload cryptographic algorithm computation.
> diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
> index dc641c7..f368579 100644
> --- a/drivers/crypto/talitos.c
> +++ b/drivers/crypto/talitos.c
> @@ -1,7 +1,7 @@
>  /*
>   * talitos - Freescale Integrated Security Engine (SEC) device driver
>   *
> - * Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
> + * Copyright (c) 2008-2012 Freescale Semiconductor, Inc.
>   *
>   * Scatterlist Crypto API glue code copied from files with the following:
>   * Copyright (c) 2006-2007 Herbert Xu <herbert@gondor.apana.org.au>
> @@ -37,6 +37,7 @@
>  #include <linux/io.h>
>  #include <linux/spinlock.h>
>  #include <linux/rtnetlink.h>
> +#include <linux/netdevice.h>
>  #include <linux/slab.h>
>  
>  #include <crypto/algapi.h>
> @@ -121,6 +122,7 @@ struct talitos_channel {
>  struct talitos_private {
>  	struct device *dev;
>  	struct platform_device *ofdev;
> +	struct net_device __percpu *netdev;
>  	void __iomem *reg;
>  	int irq[2];
>  
> @@ -145,8 +147,8 @@ struct talitos_private {
>  	/* next channel to be assigned next incoming descriptor */
>  	atomic_t last_chan ____cacheline_aligned;
>  
> -	/* request callback tasklet */
> -	struct tasklet_struct done_task[2];
> +	/* request callback napi */
> +	struct napi_struct __percpu *done_task[2];
>  
>  	/* list of registered algorithms */
>  	struct list_head alg_list;
> @@ -349,17 +351,18 @@ static int talitos_submit(struct device *dev, int ch, struct talitos_desc *desc,
>  /*
>   * process what was done, notify callback of error if not
>   */
> -static void flush_channel(struct device *dev, int ch, int error, int reset_ch)
> +static int flush_channel(struct device *dev, int ch, int error, int reset_ch,
> +			 int weight)
>  {
>  	struct talitos_private *priv = dev_get_drvdata(dev);
>  	struct talitos_request *request, saved_req;
>  	unsigned long flags;
> -	int tail, status;
> +	int tail, status, count = 0;
>  
>  	spin_lock_irqsave(&priv->chan[ch].tail_lock, flags);
>  
>  	tail = priv->chan[ch].tail;
> -	while (priv->chan[ch].fifo[tail].desc) {
> +	while (priv->chan[ch].fifo[tail].desc && (count < weight)) {
>  		request = &priv->chan[ch].fifo[tail];
>  
>  		/* descriptors with their done bits set don't get the error */
> @@ -396,43 +399,55 @@ static void flush_channel(struct device *dev, int ch, int error, int reset_ch)
>  				   status);
>  		/* channel may resume processing in single desc error case */
>  		if (error && !reset_ch && status == error)
> -			return;
> +			return 0;
>  		spin_lock_irqsave(&priv->chan[ch].tail_lock, flags);
>  		tail = priv->chan[ch].tail;
> +		count++;
>  	}
>  
>  	spin_unlock_irqrestore(&priv->chan[ch].tail_lock, flags);
> +
> +	return count;
>  }
>  
>  /*
>   * process completed requests for channels that have done status
>   */
> -#define DEF_TALITOS_DONE(name, ch_done_mask)				\
> -static void talitos_done_##name(unsigned long data)			\
> +#define DEF_TALITOS_DONE(name, ch_done_mask, num_ch)			\
> +static int talitos_done_##name(struct napi_struct *napi, int budget)	\
>  {									\
> -	struct device *dev = (struct device *)data;			\
> +	struct device *dev = &napi->dev->dev;				\
>  	struct talitos_private *priv = dev_get_drvdata(dev);		\
> +	int budget_per_ch, work_done = 0;				\
>  									\
> +	budget_per_ch = budget / num_ch;				\
>  	if (ch_done_mask & 1)						\
> -		flush_channel(dev, 0, 0, 0);				\
> +		work_done += flush_channel(dev, 0, 0, 0, budget_per_ch);\
>  	if (priv->num_channels == 1)					\
>  		goto out;						\
>  	if (ch_done_mask & (1 << 2))					\
> -		flush_channel(dev, 1, 0, 0);				\
> +		work_done += flush_channel(dev, 1, 0, 0, budget_per_ch);\
>  	if (ch_done_mask & (1 << 4))					\
> -		flush_channel(dev, 2, 0, 0);				\
> +		work_done += flush_channel(dev, 2, 0, 0, budget_per_ch);\
>  	if (ch_done_mask & (1 << 6))					\
> -		flush_channel(dev, 3, 0, 0);				\
> +		work_done += flush_channel(dev, 3, 0, 0, budget_per_ch);\
>  									\
>  out:									\
> -	/* At this point, all completed channels have been processed */	\
> -	/* Unmask done interrupts for channels completed later on. */	\
> -	setbits32(priv->reg + TALITOS_IMR, ch_done_mask);		\
> -	setbits32(priv->reg + TALITOS_IMR_LO, TALITOS_IMR_LO_INIT);	\
> +	if (work_done < budget) {					\
> +		napi_complete(napi);					\
> +		/* At this point, all completed channels have been */	\
> +		/* processed. Unmask done interrupts for channels */	\
> +		/* completed later on. */				\
> +		setbits32(priv->reg + TALITOS_IMR, ch_done_mask);	\
> +		setbits32(priv->reg + TALITOS_IMR_LO,			\
> +			  TALITOS_IMR_LO_INIT);				\
> +	}								\
> +									\
> +	return work_done;						\
>  }
> -DEF_TALITOS_DONE(4ch, TALITOS_ISR_4CHDONE)
> -DEF_TALITOS_DONE(ch0_2, TALITOS_ISR_CH_0_2_DONE)
> -DEF_TALITOS_DONE(ch1_3, TALITOS_ISR_CH_1_3_DONE)
> +DEF_TALITOS_DONE(4ch, TALITOS_ISR_4CHDONE, 4)
> +DEF_TALITOS_DONE(ch0_2, TALITOS_ISR_CH_0_2_DONE, 2)
> +DEF_TALITOS_DONE(ch1_3, TALITOS_ISR_CH_1_3_DONE, 2)
>  
>  /*
>   * locate current (offending) descriptor
> @@ -582,7 +597,7 @@ static void talitos_error(struct device *dev, u32 isr, u32 isr_lo)
>  		if (v_lo & TALITOS_CCPSR_LO_SRL)
>  			dev_err(dev, "scatter return/length error\n");
>  
> -		flush_channel(dev, ch, error, reset_ch);
> +		flush_channel(dev, ch, error, reset_ch, priv->fifo_len);
>  
>  		if (reset_ch) {
>  			reset_channel(dev, ch);
> @@ -606,14 +621,14 @@ static void talitos_error(struct device *dev, u32 isr, u32 isr_lo)
>  
>  		/* purge request queues */
>  		for (ch = 0; ch < priv->num_channels; ch++)
> -			flush_channel(dev, ch, -EIO, 1);
> +			flush_channel(dev, ch, -EIO, 1, priv->fifo_len);
>  
>  		/* reset and reinitialize the device */
>  		init_device(dev);
>  	}
>  }
>  
> -#define DEF_TALITOS_INTERRUPT(name, ch_done_mask, ch_err_mask, tlet)	       \
> +#define DEF_TALITOS_INTERRUPT(name, ch_done_mask, ch_err_mask, sirq)	       \
>  static irqreturn_t talitos_interrupt_##name(int irq, void *data)	       \
>  {									       \
>  	struct device *dev = data;					       \
> @@ -633,7 +648,8 @@ static irqreturn_t talitos_interrupt_##name(int irq, void *data)	       \
>  			/* mask further done interrupts. */		       \
>  			clrbits32(priv->reg + TALITOS_IMR, ch_done_mask);      \
>  			/* done_task will unmask done interrupts at exit */    \
> -			tasklet_schedule(&priv->done_task[tlet]);	       \
> +			napi_schedule(per_cpu_ptr(priv->done_task[sirq],       \
> +						  smp_processor_id()));	       \
>  		}							       \
>  									       \
>  	return (isr & (ch_done_mask | ch_err_mask) || isr_lo) ? IRQ_HANDLED :  \
> @@ -2555,7 +2571,7 @@ static int talitos_remove(struct platform_device *ofdev)
>  	struct device *dev = &ofdev->dev;
>  	struct talitos_private *priv = dev_get_drvdata(dev);
>  	struct talitos_crypto_alg *t_alg, *n;
> -	int i;
> +	int i, j;
>  
>  	list_for_each_entry_safe(t_alg, n, &priv->alg_list, entry) {
>  		switch (t_alg->algt.type) {
> @@ -2574,25 +2590,32 @@ static int talitos_remove(struct platform_device *ofdev)
>  	if (hw_supports(dev, DESC_HDR_SEL0_RNG))
>  		talitos_unregister_rng(dev);
>  
> -	for (i = 0; i < priv->num_channels; i++)
> -		kfree(priv->chan[i].fifo);
> -
> -	kfree(priv->chan);
> -
>  	for (i = 0; i < 2; i++)
>  		if (priv->irq[i]) {
>  			free_irq(priv->irq[i], dev);
>  			irq_dispose_mapping(priv->irq[i]);
> +
> +			for_each_possible_cpu(j) {
> +				napi_disable(per_cpu_ptr(priv->done_task[i],
> +							 j));
> +				netif_napi_del(per_cpu_ptr(priv->done_task[i],
> +							   j));
> +			}
> +
> +			free_percpu(priv->done_task[i]);
>  		}
>  
> -	tasklet_kill(&priv->done_task[0]);
> -	if (priv->irq[1])
> -		tasklet_kill(&priv->done_task[1]);
> +	for (i = 0; i < priv->num_channels; i++)
> +		kfree(priv->chan[i].fifo);
> +
> +	kfree(priv->chan);
>  
>  	iounmap(priv->reg);
>  
>  	dev_set_drvdata(dev, NULL);
>  
> +	free_percpu(priv->netdev);
> +
>  	kfree(priv);
>  
>  	return 0;
> @@ -2718,19 +2741,61 @@ static int talitos_probe(struct platform_device *ofdev)
>  	dev_set_drvdata(dev, priv);
>  
>  	priv->ofdev = ofdev;
> +	priv->dev = dev;
> +
> +	priv->netdev = alloc_percpu(struct net_device);
> +	if (!priv->netdev) {
> +		dev_err(dev, "failed to allocate netdevice\n");
> +		err = -ENOMEM;
> +		goto err_out;
> +	}
> +
> +	for_each_possible_cpu(i) {
> +		err = init_dummy_netdev(per_cpu_ptr(priv->netdev, i));
> +		if (err) {
> +			dev_err(dev, "failed to initialize dummy netdevice\n");
> +			goto err_out;
> +		}
> +		(per_cpu_ptr(priv->netdev, i))->dev = *dev;
> +	}
>  
>  	err = talitos_probe_irq(ofdev);
>  	if (err)
>  		goto err_out;
>  
> +	priv->done_task[0] = alloc_percpu(struct napi_struct);
> +	if (!priv->done_task[0]) {
> +		dev_err(dev, "failed to allocate napi for 1st irq\n");
> +		err = -ENOMEM;
> +		goto err_out;
> +	}
> +
>  	if (!priv->irq[1]) {
> -		tasklet_init(&priv->done_task[0], talitos_done_4ch,
> -			     (unsigned long)dev);
> +		for_each_possible_cpu(i) {
> +			netif_napi_add(per_cpu_ptr(priv->netdev, i),
> +				       per_cpu_ptr(priv->done_task[0], i),
> +				       talitos_done_4ch, TALITOS_NAPI_WEIGHT);
> +			napi_enable(per_cpu_ptr(priv->done_task[0], i));
> +		}
>  	} else {
> -		tasklet_init(&priv->done_task[0], talitos_done_ch0_2,
> -			     (unsigned long)dev);
> -		tasklet_init(&priv->done_task[1], talitos_done_ch1_3,
> -			     (unsigned long)dev);
> +		priv->done_task[1] = alloc_percpu(struct napi_struct);
> +		if (!priv->done_task[1]) {
> +			dev_err(dev, "failed to allocate napi for 2nd irq\n");
> +			err = -ENOMEM;
> +			goto err_out;
> +		}
> +
> +		for_each_possible_cpu(i) {
> +			netif_napi_add(per_cpu_ptr(priv->netdev, i),
> +				       per_cpu_ptr(priv->done_task[0], i),
> +				       talitos_done_ch0_2, TALITOS_NAPI_WEIGHT);
> +			napi_enable(per_cpu_ptr(priv->done_task[0], i));
> +
> +			netif_napi_add(per_cpu_ptr(priv->netdev, i),
> +				       per_cpu_ptr(priv->done_task[1], i),
> +				       talitos_done_ch1_3, TALITOS_NAPI_WEIGHT);
> +			napi_enable(per_cpu_ptr(priv->done_task[1], i));
> +		}
>  	}
>  
>  	INIT_LIST_HEAD(&priv->alg_list);
> diff --git a/drivers/crypto/talitos.h b/drivers/crypto/talitos.h
> index 3c17395..ba62abc 100644
> --- a/drivers/crypto/talitos.h
> +++ b/drivers/crypto/talitos.h
> @@ -1,7 +1,7 @@
>  /*
>   * Freescale SEC (talitos) device register and descriptor header defines
>   *
> - * Copyright (c) 2006-2011 Freescale Semiconductor, Inc.
> + * Copyright (c) 2006-2012 Freescale Semiconductor, Inc.
>   *
>   * Redistribution and use in source and binary forms, with or without
>   * modification, are permitted provided that the following conditions
> @@ -28,6 +28,8 @@
>   *
>   */
>  
> +#define TALITOS_NAPI_WEIGHT     12
> +
>  /*
>   * TALITOS_xxx_LO addresses point to the low data bits (32-63) of the register
>   */
> -- 
> 1.7.3.4
> 

^ permalink raw reply

* Re: VLAN regression caused by: e1000: do vlan cleanup (799d531).
From: Ben Greear @ 2012-03-19 23:24 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: e1000-devel list, netdev
In-Reply-To: <20120319130836.GD2192@minipsycho.brq.redhat.com>

On 03/19/2012 06:08 AM, Jiri Pirko wrote:
> Tue, Mar 13, 2012 at 07:44:18PM CET, greearb@candelatech.com wrote:

>>> I have suspition that vlan filter must be on/offed along with vlan
>>> accel.
>>
>> Ok, if I disable rx-vlan-hw-parse on both NICs, traffic starts working.
>>
>> And, if I re-enable rx-vlan-hw-parse on both NICs, it continues to work.
>>
>> Maybe the initialization logic needs some fixing?
>
> Could you please try following patch?

That patches fixes the problem for me.  Only lightly tested
at this point, but I have verified VLAN traffic works as desired.

Thanks,
Ben

>
> diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
> index 6419a88..b06c31c 100644
> --- a/drivers/net/ethernet/intel/e1000/e1000_main.c
> +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
> @@ -164,6 +164,8 @@ static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter,
>   static bool e1000_vlan_used(struct e1000_adapter *adapter);
>   static void e1000_vlan_mode(struct net_device *netdev,
>   			    netdev_features_t features);
> +static void e1000_vlan_filter_on_off(struct e1000_adapter *adapter,
> +				     bool filter_on);
>   static int e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid);
>   static int e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid);
>   static void e1000_restore_vlan(struct e1000_adapter *adapter);
> @@ -1214,7 +1216,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
>   	if (err)
>   		goto err_register;
>
> -	e1000_vlan_mode(netdev, netdev->features);
> +	e1000_vlan_filter_on_off(adapter, false);
>
>   	/* print bus type/speed/width info */
>   	e_info(probe, "(PCI%s:%dMHz:%d-bit) %pM\n",
> @@ -4772,6 +4774,22 @@ static bool e1000_vlan_used(struct e1000_adapter *adapter)
>   	return false;
>   }
>
> +static void __e1000_vlan_mode(struct e1000_adapter *adapter,
> +			      netdev_features_t features)
> +{
> +	struct e1000_hw *hw =&adapter->hw;
> +	u32 ctrl;
> +
> +	ctrl = er32(CTRL);
> +	if (features&  NETIF_F_HW_VLAN_RX) {
> +		/* enable VLAN tag insert/strip */
> +		ctrl |= E1000_CTRL_VME;
> +	} else {
> +		/* disable VLAN tag insert/strip */
> +		ctrl&= ~E1000_CTRL_VME;
> +	}
> +	ew32(CTRL, ctrl);
> +}
>   static void e1000_vlan_filter_on_off(struct e1000_adapter *adapter,
>   				     bool filter_on)
>   {
> @@ -4781,6 +4799,7 @@ static void e1000_vlan_filter_on_off(struct e1000_adapter *adapter,
>   	if (!test_bit(__E1000_DOWN,&adapter->flags))
>   		e1000_irq_disable(adapter);
>
> +	__e1000_vlan_mode(adapter, adapter->netdev->features);
>   	if (filter_on) {
>   		/* enable VLAN receive filtering */
>   		rctl = er32(RCTL);
> @@ -4801,24 +4820,14 @@ static void e1000_vlan_filter_on_off(struct e1000_adapter *adapter,
>   }
>
>   static void e1000_vlan_mode(struct net_device *netdev,
> -	netdev_features_t features)
> +			    netdev_features_t features)
>   {
>   	struct e1000_adapter *adapter = netdev_priv(netdev);
> -	struct e1000_hw *hw =&adapter->hw;
> -	u32 ctrl;
>
>   	if (!test_bit(__E1000_DOWN,&adapter->flags))
>   		e1000_irq_disable(adapter);
>
> -	ctrl = er32(CTRL);
> -	if (features&  NETIF_F_HW_VLAN_RX) {
> -		/* enable VLAN tag insert/strip */
> -		ctrl |= E1000_CTRL_VME;
> -	} else {
> -		/* disable VLAN tag insert/strip */
> -		ctrl&= ~E1000_CTRL_VME;
> -	}
> -	ew32(CTRL, ctrl);
> +	__e1000_vlan_mode(adapter, features);
>
>   	if (!test_bit(__E1000_DOWN,&adapter->flags))
>   		e1000_irq_enable(adapter);


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit http://communities.intel.com/community/wired

^ permalink raw reply

* Re: Improve rds_sendmsg printk
From: Joe Perches @ 2012-03-19 23:08 UTC (permalink / raw)
  To: Dave Jones; +Cc: venkat.x.venkatsubra, netdev
In-Reply-To: <20120319224008.GA23036@redhat.com>

On Mon, 2012-03-19 at 18:40 -0400, Dave Jones wrote:
> - Given this can be called by any user, prevent them from flooding
>   the logs by using printk_ratelimited
> - Also add a rds: prefix, so it's clear where the message is coming from.
> 
> Signed-off-by: Dave Jones <davej@redhat.com>
> 
> --- linux/net/rds/send.c	2011-11-07 12:00:32.000000000 -0500
> +++ linux/net/rds/send.c	2012-03-19 18:36:21.804991923 -0400
> @@ -935,7 +935,7 @@ int rds_sendmsg(struct kiocb *iocb, stru
>  	/* Mirror Linux UDP mirror of BSD error message compatibility */
>  	/* XXX: Perhaps MSG_MORE someday */
>  	if (msg->msg_flags & ~(MSG_DONTWAIT | MSG_CMSG_COMPAT)) {
> -		printk(KERN_INFO "msg_flags 0x%08X\n", msg->msg_flags);
> +		printk_ratelimited(KERN_INFO "rds: msg_flags 0x%08X\n", msg->msg_flags);

It might be better to use net_ratelimit
for all the rds printk_ratelimited calls.

That's a bit more standardized across net/

^ permalink raw reply

* Remove printk from rds_sendmsg
From: Dave Jones @ 2012-03-19 23:01 UTC (permalink / raw)
  To: David Miller; +Cc: venkat.x.venkatsubra, netdev
In-Reply-To: <20120319.184335.1229962428916453634.davem@davemloft.net>

no socket layer outputs a message for this error and neither should rds.

Signed-off-by: Dave Jones <davej@redhat.com>

--- linux/net/rds/send.c	2011-11-07 12:00:32.000000000 -0500
+++ linux/net/rds/send.c	2012-03-19 18:59:55.905890597 -0400
@@ -935,7 +935,6 @@ int rds_sendmsg(struct kiocb *iocb, stru
 	/* Mirror Linux UDP mirror of BSD error message compatibility */
 	/* XXX: Perhaps MSG_MORE someday */
 	if (msg->msg_flags & ~(MSG_DONTWAIT | MSG_CMSG_COMPAT)) {
-		printk(KERN_INFO "msg_flags 0x%08X\n", msg->msg_flags);
 		ret = -EOPNOTSUPP;
 		goto out;
 	}

^ permalink raw reply

* kernel 3.3, regression, bnx2 firmware missing in tar.bz2
From: Denys Fedoryshchenko @ 2012-03-19 22:31 UTC (permalink / raw)
  To: netdev

Hi

Just loaded to 2.6.39 machine newest 3.3 kernel and got dead network 
interface:

Mar 20 03:28:37 localhost kernel: bnx2: Can't load firmware file 
"bnx2/bnx2-mips-06-6.2.3.fw"

On one side i agree that firmware can have non-GPL license, but at any 
case while it is working in old kernel, if it is dead in new - and it is 
very bad. Just checked commit

Actually i am expecting to have working network interfaces with 
downloaded tar.bz2 of stable kernel release, especially if it was 
working before, otherwise it is plain regression. Or i am wrong?

Sure i know how to use git, but it is non-trivial to find about git tree 
with this firmware in git.kernel.org, nothing mentioned in 
documentation. It will be perfect, if make process at least will try to 
fetch firmwares from git or note about it at end of compiling.

Thanks.


	

^ permalink raw reply

* Re: [net-next PATCH v0 0/5] Series short description
From: Stephen Hemminger @ 2012-03-19 22:55 UTC (permalink / raw)
  To: David Miller
  Cc: john.r.fastabend, jhs, bhutchings, roprabhu, jeffrey.t.kirsher,
	netdev, mst, chrisw, gregory.v.rose, kvm, sri, chealy
In-Reply-To: <20120319.183808.976759898435189612.davem@davemloft.net>

On Mon, 19 Mar 2012 18:38:08 -0400 (EDT)
David Miller <davem@davemloft.net> wrote:

> From: John Fastabend <john.r.fastabend@intel.com>
> Date: Sun, 18 Mar 2012 23:51:45 -0700
> 
> > This series is a follow up to this thread:
> > 
> > http://www.spinics.net/lists/netdev/msg191360.html
> 
> Can the interested parties please review this series?
> 
> I'm willing to apply this right now if it looks OK, but if
> it needs more revisions we'll have to defer.

Please don't rush this into this merge window. It needs more than
1 full day of review.

^ permalink raw reply

* Re: iproute2: iplink_ stuff cleanup
From: Stephen Hemminger @ 2012-03-19 22:53 UTC (permalink / raw)
  To: Yegor Yefremov; +Cc: netdev
In-Reply-To: <CAGm1_kvbqOtArw4dUpnzTRB1JtfBCaAAeyFYCPrcaGYUF10NSg@mail.gmail.com>

On Mon, 19 Mar 2012 23:22:59 +0100
Yegor Yefremov <yegorslists@googlemail.com> wrote:

> >> I'm still struggling to get ip/iplink_* routines to show up in
> >> Android's ip binary
> >> (https://groups.google.com/d/topic/android-building/yjV4iYnT1Zc/discussion).
> >> I've looked at the algorithm that is used to access those functions
> >> (like can_parse_opt, vlan_parse_opt etc.)
> >>
> >>  snprintf(buf, sizeof(buf), LIBDIR "/ip/link_%s.so", id);
> >>         dlh = dlopen(buf, RTLD_LAZY);
> >>         if (dlh == NULL) {
> >>                 /* look in current binary, only open once */
> >>                 dlh = BODY;
> >>                 if (dlh == NULL) {
> >>                         dlh = BODY = dlopen(NULL, RTLD_LAZY);
> >>                         if (dlh == NULL)
> >>                                 return NULL;
> >>                 }
> >>         }
> >>
> >>         snprintf(buf, sizeof(buf), "%s_link_util", id);
> >>         l = dlsym(dlh, buf);
> >>         if (l == NULL)
> >>                 return NULL;
> >>
> >> as far as I can see from the ip/Makefile there are no dynamic libs
> >> like /ip/link_%s.so. Wouldn't it be simpler to let all iplink_*
> >> objects to export their interfaces via header files and just make a
> >> table in ip/iplink.c to hold protocol ID and pointer at link_utils
> >> struct.
> >>
> >> struct link_util can_link_util = {
> >>         .id             = "can",
> >>         .maxattr        = IFLA_CAN_MAX,
> >>         .parse_opt      = can_parse_opt,
> >>         .print_opt      = can_print_opt,
> >>         .print_xstats   = can_print_xstats,
> >> };
> >>
> >> Am I missing something?
> >>
> >> Regards,
> >> Yegor
> >
> > Ip utilities have dynamic extensibility, it is possible for someone
> > to add shared libraries for new functionality. This is a cool feature
> > but isn't used directly by the standard code. It does use it indirectly
> > by using dlopen() to find functions locally.
> >
> > Think of it as introspection in C.
> >
> > I won't take it out of the standard version, but you may have to find
> > another way to handle it on the Android universe.
> 
> The solution turned out to be simple:
> https://android-review.googlesource.com/#/c/34240/.
> -Wl,--no-gc-sections did the job.
> 
> Can you suggest some more pro arguments for dynamic method of
> exporting API routines?

You could make it optional on your platform, but for mainline Linux
it has been around long enough that someone surely depends on it.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox