From 96fd74b2d9b59edeed7ea1287d322b7661d549ca Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 24 Oct 2007 18:23:19 +0200 Subject: drivers/net/ipg.c: cleanups This patch contains the following cleanups: - make ipg_nic_get_stats() static - move DefaultPhyParam[] from ipg.h to ipg.c and make it static Signed-off-by: Adrian Bunk Signed-off-by: Jeff Garzik --- drivers/net/ipg.c | 22 +++++++++++++++++++++- drivers/net/ipg.h | 20 -------------------- 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'drivers') diff --git a/drivers/net/ipg.c b/drivers/net/ipg.c index 68887235d7e..dbd23bb65d1 100644 --- a/drivers/net/ipg.c +++ b/drivers/net/ipg.c @@ -55,6 +55,26 @@ MODULE_DESCRIPTION("IC Plus IP1000 Gigabit Ethernet Adapter Linux Driver " DrvVer); MODULE_LICENSE("GPL"); +//variable record -- index by leading revision/length +//Revision/Length(=N*4), Address1, Data1, Address2, Data2,...,AddressN,DataN +static unsigned short DefaultPhyParam[] = { + // 11/12/03 IP1000A v1-3 rev=0x40 + /*-------------------------------------------------------------------------- + (0x4000|(15*4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 22, 0x85bd, 24, 0xfff2, + 27, 0x0c10, 28, 0x0c10, 29, 0x2c10, 31, 0x0003, 23, 0x92f6, + 31, 0x0000, 23, 0x003d, 30, 0x00de, 20, 0x20e7, 9, 0x0700, + --------------------------------------------------------------------------*/ + // 12/17/03 IP1000A v1-4 rev=0x40 + (0x4000 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31, + 0x0000, + 30, 0x005e, 9, 0x0700, + // 01/09/04 IP1000A v1-5 rev=0x41 + (0x4100 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31, + 0x0000, + 30, 0x005e, 9, 0x0700, + 0x0000 +}; + static const char *ipg_brand_name[] = { "IC PLUS IP1000 1000/100/10 based NIC", "Sundance Technology ST2021 based NIC", @@ -990,7 +1010,7 @@ static void ipg_nic_txcleanup(struct net_device *dev) } /* Provides statistical information about the IPG NIC. */ -struct net_device_stats *ipg_nic_get_stats(struct net_device *dev) +static struct net_device_stats *ipg_nic_get_stats(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; diff --git a/drivers/net/ipg.h b/drivers/net/ipg.h index e418b9035ca..d5d092c9d0a 100644 --- a/drivers/net/ipg.h +++ b/drivers/net/ipg.h @@ -833,24 +833,4 @@ struct ipg_nic_private { struct delayed_work task; }; -//variable record -- index by leading revision/length -//Revision/Length(=N*4), Address1, Data1, Address2, Data2,...,AddressN,DataN -unsigned short DefaultPhyParam[] = { - // 11/12/03 IP1000A v1-3 rev=0x40 - /*-------------------------------------------------------------------------- - (0x4000|(15*4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 22, 0x85bd, 24, 0xfff2, - 27, 0x0c10, 28, 0x0c10, 29, 0x2c10, 31, 0x0003, 23, 0x92f6, - 31, 0x0000, 23, 0x003d, 30, 0x00de, 20, 0x20e7, 9, 0x0700, - --------------------------------------------------------------------------*/ - // 12/17/03 IP1000A v1-4 rev=0x40 - (0x4000 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31, - 0x0000, - 30, 0x005e, 9, 0x0700, - // 01/09/04 IP1000A v1-5 rev=0x41 - (0x4100 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31, - 0x0000, - 30, 0x005e, 9, 0x0700, - 0x0000 -}; - #endif /* __LINUX_IPG_H */ -- cgit v1.2.3-18-g5258 From c50b85d0fbca0a2017b8c0b1e2aeb650724c0a71 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 24 Oct 2007 18:23:17 +0200 Subject: make bonding/bond_main.c:bond_deinit() static bond_deinit() can now become static. Signed-off-by: Adrian Bunk Signed-off-by: Jeff Garzik --- drivers/net/bonding/bond_main.c | 3 ++- drivers/net/bonding/bonding.h | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 6909becb10f..e5fab4be398 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -188,6 +188,7 @@ struct bond_parm_tbl arp_validate_tbl[] = { /*-------------------------- Forward declarations ---------------------------*/ static void bond_send_gratuitous_arp(struct bonding *bond); +static void bond_deinit(struct net_device *bond_dev); /*---------------------------- General routines -----------------------------*/ @@ -4449,7 +4450,7 @@ static int bond_init(struct net_device *bond_dev, struct bond_params *params) /* De-initialize device specific data. * Caller must hold rtnl_lock. */ -void bond_deinit(struct net_device *bond_dev) +static void bond_deinit(struct net_device *bond_dev) { struct bonding *bond = bond_dev->priv; diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index d1ed14bf1cc..61c1b4536d3 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h @@ -302,7 +302,6 @@ int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_de int bond_create(char *name, struct bond_params *params, struct bonding **newbond); void bond_destroy(struct bonding *bond); int bond_release_and_destroy(struct net_device *bond_dev, struct net_device *slave_dev); -void bond_deinit(struct net_device *bond_dev); int bond_create_sysfs(void); void bond_destroy_sysfs(void); void bond_destroy_sysfs_entry(struct bonding *bond); -- cgit v1.2.3-18-g5258 From a40745f5ef38f4542d120bd67c2c4a07702eb1da Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 24 Oct 2007 18:27:43 +0200 Subject: bonding/bond_main.c: fix cut'n'paste error This patch fixes a cut'n'paste error in commit 1b76b31693d4a6088dec104ff6a6ead54081a3c2. Signed-off-by: Adrian Bunk Signed-off-by: Jeff Garzik --- drivers/net/bonding/bond_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index e5fab4be398..6937ef0e727 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -3682,7 +3682,7 @@ static int bond_open(struct net_device *bond_dev) } if (bond->params.mode == BOND_MODE_8023AD) { - INIT_DELAYED_WORK(&bond->ad_work, bond_alb_monitor); + INIT_DELAYED_WORK(&bond->ad_work, bond_3ad_state_machine_handler); queue_delayed_work(bond->wq, &bond->ad_work, 0); /* register to receive LACPDUs */ bond_register_lacpdu(bond); -- cgit v1.2.3-18-g5258 From 0173b793ca477aa2ca516ebf0a35e137b678d466 Mon Sep 17 00:00:00 2001 From: Jan-Bernd Themann Date: Wed, 24 Oct 2007 11:53:34 +0200 Subject: ehea: fix port_napi_disable/enable napi_disable / napi_enable must be applied on all ehea queues. Signed-off-by: Jan-Bernd Themann Signed-off-by: Jeff Garzik --- drivers/net/ehea/ehea.h | 2 +- drivers/net/ehea/ehea_main.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h index b557bb44a36..4b4b74e47a6 100644 --- a/drivers/net/ehea/ehea.h +++ b/drivers/net/ehea/ehea.h @@ -40,7 +40,7 @@ #include #define DRV_NAME "ehea" -#define DRV_VERSION "EHEA_0078" +#define DRV_VERSION "EHEA_0079" /* eHEA capability flags */ #define DLPAR_PORT_ADD_REM 1 diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c index 2809c99906e..0a7e7892554 100644 --- a/drivers/net/ehea/ehea_main.c +++ b/drivers/net/ehea/ehea_main.c @@ -2329,7 +2329,7 @@ static void port_napi_disable(struct ehea_port *port) { int i; - for (i = 0; i < port->num_def_qps; i++) + for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) napi_disable(&port->port_res[i].napi); } @@ -2337,7 +2337,7 @@ static void port_napi_enable(struct ehea_port *port) { int i; - for (i = 0; i < port->num_def_qps; i++) + for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) napi_enable(&port->port_res[i].napi); } @@ -2373,8 +2373,6 @@ static int ehea_down(struct net_device *dev) ehea_drop_multicast_list(dev); ehea_free_interrupts(dev); - port_napi_disable(port); - port->state = EHEA_PORT_DOWN; ret = ehea_clean_all_portres(port); @@ -2396,6 +2394,7 @@ static int ehea_stop(struct net_device *dev) flush_scheduled_work(); down(&port->port_lock); netif_stop_queue(dev); + port_napi_disable(port); ret = ehea_down(dev); up(&port->port_lock); return ret; -- cgit v1.2.3-18-g5258 From bbbab5ca835fb7676434815a47add8f2c696bec7 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Wed, 24 Oct 2007 13:58:57 +0200 Subject: natsemi: fix oops, link back netdevice from private-struct * Andrew Nelless wrote: > Hi, > > I booted up 2.6.24-rc1 this morning [Real early over a brew ;-)] and > was having a problems with multiple ~5 second hangs on SATA/drive init > (Something to do with "EH" something-or-other and resets but I'll > email in separately about it later unless its fixed by the time I get > the chance). > > Anyway, I went to fire up netconsole to get a decent log dump and hit > across the following nasty. Netconsole works fine in 2.6.23.1 with a > similar config and the same kernel parameters. > > A shot of the screen is the only method I could come up with to > capture the log, I hope that is OK, it is pretty readable. > > > The nasty: > http://andotnet.nfshost.com/linux/2.6.24-rc1-netconsole-nullderef.jpg the NULL dereference is here: (gdb) list *0xffffffff804a9504 0xffffffff804a9504 is in natsemi_poll (drivers/net/natsemi.c:717). 712 return count; 713 } 714 715 static inline void __iomem *ns_ioaddr(struct net_device *dev) 716 { 717 return (void __iomem *) dev->base_addr; 718 } 719 which is this code from natsemi.c: 2227 struct net_device *dev = np->dev; 2228 void __iomem * ioaddr = ns_ioaddr(dev); 2229 int work_done = 0; seems like the NAPI changes in -rc1 added an np->dev field but forgot to initialize it ... does the patch below fix the oops for you? Ingo --------------------> Subject: natsemi: fix oops, link back netdevice from private-struct From: Ingo Molnar this commit: commit bea3348eef27e6044b6161fd04c3152215f96411 Author: Stephen Hemminger Date: Wed Oct 3 16:41:36 2007 -0700 [NET]: Make NAPI polling independent of struct net_device objects. added np->dev to drivers/net/natsemi.c's struct netdev_private, but forgot to initialize that new field upon driver init. The result was a predictable NULL dereference oops the first time the hardware generated an interrupt. Reported-by: Andrew Nelless Signed-off-by: Ingo Molnar Signed-off-by: Jeff Garzik --- drivers/net/natsemi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c index 953117152bb..87cde062fd6 100644 --- a/drivers/net/natsemi.c +++ b/drivers/net/natsemi.c @@ -864,6 +864,7 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev, np = netdev_priv(dev); netif_napi_add(dev, &np->napi, natsemi_poll, 64); + np->dev = dev; np->pci_dev = pdev; pci_set_drvdata(pdev, dev); -- cgit v1.2.3-18-g5258 From df523b5cd9950485350fb1b7d97d5b8882d94a4e Mon Sep 17 00:00:00 2001 From: Eugene Konev Date: Wed, 24 Oct 2007 10:42:01 +0800 Subject: cpmac: use print_mac() instead of MAC_FMT Switch to using DECLARE_MAC_BUF/print_mac() added by commit 0795af5729b18218767fab27c44b1384f72dc9ad [NET]: Introduce and use print_mac() and DECLARE_MAC_BUF(). Signed-off-by: Eugene Konev Signed-off-by: Jeff Garzik --- drivers/net/cpmac.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c index 57541d2d9e1..0598d4d438f 100644 --- a/drivers/net/cpmac.c +++ b/drivers/net/cpmac.c @@ -53,12 +53,6 @@ MODULE_PARM_DESC(debug_level, "Number of NETIF_MSG bits to enable"); MODULE_PARM_DESC(dumb_switch, "Assume switch is not connected to MDIO bus"); #define CPMAC_VERSION "0.5.0" -/* stolen from net/ieee80211.h */ -#ifndef MAC_FMT -#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" -#define MAC_ARG(x) ((u8*)(x))[0], ((u8*)(x))[1], ((u8*)(x))[2], \ - ((u8*)(x))[3], ((u8*)(x))[4], ((u8*)(x))[5] -#endif /* frame size + 802.1q tag */ #define CPMAC_SKB_SIZE (ETH_FRAME_LEN + 4) #define CPMAC_QUEUES 8 @@ -1006,6 +1000,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev) struct cpmac_priv *priv; struct net_device *dev; struct plat_cpmac_data *pdata; + DECLARE_MAC_BUF(mac); pdata = pdev->dev.platform_data; @@ -1077,9 +1072,9 @@ static int __devinit cpmac_probe(struct platform_device *pdev) if (netif_msg_probe(priv)) { printk(KERN_INFO - "cpmac: device %s (regs: %p, irq: %d, phy: %s, mac: " - MAC_FMT ")\n", dev->name, (void *)mem->start, dev->irq, - priv->phy_name, MAC_ARG(dev->dev_addr)); + "cpmac: device %s (regs: %p, irq: %d, phy: %s, " + "mac: %s)\n", dev->name, (void *)mem->start, dev->irq, + priv->phy_name, print_mac(mac, dev->dev_addr)); } return 0; -- cgit v1.2.3-18-g5258 From 67d129d14da1555bb3eaca754f6f81c02cacbe0e Mon Sep 17 00:00:00 2001 From: Eugene Konev Date: Wed, 24 Oct 2007 10:42:02 +0800 Subject: cpmac: convert to napi_struct interface Convert cpmac to new napi_struct API introduced by bea3348eef27e6044b6161fd04c3152215f96411 [NET]: Make NAPI polling independent of struct net_device objects. Only disable rx interrupts if napi actually has been scheduled. Signed-off-by: Eugene Konev Signed-off-by: Jeff Garzik --- drivers/net/cpmac.c | 68 +++++++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 31 deletions(-) (limited to 'drivers') diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c index 0598d4d438f..486c82b2dab 100644 --- a/drivers/net/cpmac.c +++ b/drivers/net/cpmac.c @@ -205,6 +205,7 @@ struct cpmac_priv { struct net_device *dev; struct work_struct reset_work; struct platform_device *pdev; + struct napi_struct napi; }; static irqreturn_t cpmac_irq(int, void *); @@ -356,47 +357,48 @@ static void cpmac_set_multicast_list(struct net_device *dev) } } -static struct sk_buff *cpmac_rx_one(struct net_device *dev, - struct cpmac_priv *priv, +static struct sk_buff *cpmac_rx_one(struct cpmac_priv *priv, struct cpmac_desc *desc) { struct sk_buff *skb, *result = NULL; if (unlikely(netif_msg_hw(priv))) - cpmac_dump_desc(dev, desc); + cpmac_dump_desc(priv->dev, desc); cpmac_write(priv->regs, CPMAC_RX_ACK(0), (u32)desc->mapping); if (unlikely(!desc->datalen)) { if (netif_msg_rx_err(priv) && net_ratelimit()) printk(KERN_WARNING "%s: rx: spurious interrupt\n", - dev->name); + priv->dev->name); return NULL; } - skb = netdev_alloc_skb(dev, CPMAC_SKB_SIZE); + skb = netdev_alloc_skb(priv->dev, CPMAC_SKB_SIZE); if (likely(skb)) { skb_reserve(skb, 2); skb_put(desc->skb, desc->datalen); - desc->skb->protocol = eth_type_trans(desc->skb, dev); + desc->skb->protocol = eth_type_trans(desc->skb, priv->dev); desc->skb->ip_summed = CHECKSUM_NONE; - dev->stats.rx_packets++; - dev->stats.rx_bytes += desc->datalen; + priv->dev->stats.rx_packets++; + priv->dev->stats.rx_bytes += desc->datalen; result = desc->skb; - dma_unmap_single(&dev->dev, desc->data_mapping, CPMAC_SKB_SIZE, - DMA_FROM_DEVICE); + dma_unmap_single(&priv->dev->dev, desc->data_mapping, + CPMAC_SKB_SIZE, DMA_FROM_DEVICE); desc->skb = skb; - desc->data_mapping = dma_map_single(&dev->dev, skb->data, + desc->data_mapping = dma_map_single(&priv->dev->dev, skb->data, CPMAC_SKB_SIZE, DMA_FROM_DEVICE); desc->hw_data = (u32)desc->data_mapping; if (unlikely(netif_msg_pktdata(priv))) { - printk(KERN_DEBUG "%s: received packet:\n", dev->name); - cpmac_dump_skb(dev, result); + printk(KERN_DEBUG "%s: received packet:\n", + priv->dev->name); + cpmac_dump_skb(priv->dev, result); } } else { if (netif_msg_rx_err(priv) && net_ratelimit()) printk(KERN_WARNING - "%s: low on skbs, dropping packet\n", dev->name); - dev->stats.rx_dropped++; + "%s: low on skbs, dropping packet\n", + priv->dev->name); + priv->dev->stats.rx_dropped++; } desc->buflen = CPMAC_SKB_SIZE; @@ -405,25 +407,25 @@ static struct sk_buff *cpmac_rx_one(struct net_device *dev, return result; } -static int cpmac_poll(struct net_device *dev, int *budget) +static int cpmac_poll(struct napi_struct *napi, int budget) { struct sk_buff *skb; struct cpmac_desc *desc; - int received = 0, quota = min(dev->quota, *budget); - struct cpmac_priv *priv = netdev_priv(dev); + int received = 0; + struct cpmac_priv *priv = container_of(napi, struct cpmac_priv, napi); spin_lock(&priv->rx_lock); if (unlikely(!priv->rx_head)) { if (netif_msg_rx_err(priv) && net_ratelimit()) printk(KERN_WARNING "%s: rx: polling, but no queue\n", - dev->name); - netif_rx_complete(dev); + priv->dev->name); + netif_rx_complete(priv->dev, napi); return 0; } desc = priv->rx_head; - while ((received < quota) && ((desc->dataflags & CPMAC_OWN) == 0)) { - skb = cpmac_rx_one(dev, priv, desc); + while (((desc->dataflags & CPMAC_OWN) == 0) && (received < budget)) { + skb = cpmac_rx_one(priv, desc); if (likely(skb)) { netif_receive_skb(skb); received++; @@ -433,13 +435,11 @@ static int cpmac_poll(struct net_device *dev, int *budget) priv->rx_head = desc; spin_unlock(&priv->rx_lock); - *budget -= received; - dev->quota -= received; if (unlikely(netif_msg_rx_status(priv))) - printk(KERN_DEBUG "%s: poll processed %d packets\n", dev->name, - received); + printk(KERN_DEBUG "%s: poll processed %d packets\n", + priv->dev->name, received); if (desc->dataflags & CPMAC_OWN) { - netif_rx_complete(dev); + netif_rx_complete(priv->dev, napi); cpmac_write(priv->regs, CPMAC_RX_PTR(0), (u32)desc->mapping); cpmac_write(priv->regs, CPMAC_RX_INT_ENABLE, 1); return 0; @@ -649,6 +649,7 @@ static void cpmac_hw_error(struct work_struct *work) spin_unlock(&priv->rx_lock); cpmac_clear_tx(priv->dev); cpmac_hw_start(priv->dev); + napi_enable(&priv->napi); netif_start_queue(priv->dev); } @@ -675,8 +676,10 @@ static irqreturn_t cpmac_irq(int irq, void *dev_id) if (status & MAC_INT_RX) { queue = (status >> 8) & 7; - netif_rx_schedule(dev); - cpmac_write(priv->regs, CPMAC_RX_INT_CLEAR, 1 << queue); + if (netif_rx_schedule_prep(dev, &priv->napi)) { + cpmac_write(priv->regs, CPMAC_RX_INT_CLEAR, 1 << queue); + __netif_rx_schedule(dev, &priv->napi); + } } cpmac_write(priv->regs, CPMAC_MAC_EOI_VECTOR, 0); @@ -686,6 +689,7 @@ static irqreturn_t cpmac_irq(int irq, void *dev_id) printk(KERN_ERR "%s: hw error, resetting...\n", dev->name); netif_stop_queue(dev); + napi_disable(&priv->napi); cpmac_hw_stop(dev); schedule_work(&priv->reset_work); if (unlikely(netif_msg_hw(priv))) @@ -921,6 +925,7 @@ static int cpmac_open(struct net_device *dev) INIT_WORK(&priv->reset_work, cpmac_hw_error); cpmac_hw_start(dev); + napi_enable(&priv->napi); priv->phy->state = PHY_CHANGELINK; phy_start(priv->phy); @@ -959,6 +964,7 @@ static int cpmac_stop(struct net_device *dev) netif_stop_queue(dev); cancel_work_sync(&priv->reset_work); + napi_disable(&priv->napi); phy_stop(priv->phy); phy_disconnect(priv->phy); priv->phy = NULL; @@ -1048,10 +1054,10 @@ static int __devinit cpmac_probe(struct platform_device *pdev) dev->set_multicast_list = cpmac_set_multicast_list; dev->tx_timeout = cpmac_tx_timeout; dev->ethtool_ops = &cpmac_ethtool_ops; - dev->poll = cpmac_poll; - dev->weight = 64; dev->features |= NETIF_F_MULTI_QUEUE; + netif_napi_add(dev, &priv->napi, cpmac_poll, 64); + spin_lock_init(&priv->lock); spin_lock_init(&priv->rx_lock); priv->dev = dev; -- cgit v1.2.3-18-g5258 From b88219f8a2028a1ca2dd17aa7c9d9b643615646e Mon Sep 17 00:00:00 2001 From: Eugene Konev Date: Wed, 24 Oct 2007 10:42:03 +0800 Subject: cpmac: update to new fixed phy driver interface Use fixed_mdio_get_phydev for obtaining fixed phy instances and adopt to changed fixed phy device naming. Signed-off-by: Eugene Konev Signed-off-by: Jeff Garzik --- drivers/net/cpmac.c | 64 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 18 deletions(-) (limited to 'drivers') diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c index 486c82b2dab..6fd95a2c8ce 100644 --- a/drivers/net/cpmac.c +++ b/drivers/net/cpmac.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -847,6 +848,15 @@ static void cpmac_adjust_link(struct net_device *dev) spin_unlock(&priv->lock); } +static int cpmac_link_update(struct net_device *dev, + struct fixed_phy_status *status) +{ + status->link = 1; + status->speed = 100; + status->duplex = 1; + return 0; +} + static int cpmac_open(struct net_device *dev) { int i, size, res; @@ -855,15 +865,6 @@ static int cpmac_open(struct net_device *dev) struct cpmac_desc *desc; struct sk_buff *skb; - priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, - 0, PHY_INTERFACE_MODE_MII); - if (IS_ERR(priv->phy)) { - if (netif_msg_drv(priv)) - printk(KERN_ERR "%s: Could not attach to PHY\n", - dev->name); - return PTR_ERR(priv->phy); - } - mem = platform_get_resource_byname(priv->pdev, IORESOURCE_MEM, "regs"); if (!request_mem_region(mem->start, mem->end - mem->start, dev->name)) { if (netif_msg_drv(priv)) @@ -950,8 +951,6 @@ fail_remap: release_mem_region(mem->start, mem->end - mem->start); fail_reserve: - phy_disconnect(priv->phy); - return res; } @@ -966,8 +965,6 @@ static int cpmac_stop(struct net_device *dev) cancel_work_sync(&priv->reset_work); napi_disable(&priv->napi); phy_stop(priv->phy); - phy_disconnect(priv->phy); - priv->phy = NULL; cpmac_hw_stop(dev); @@ -1001,11 +998,12 @@ static int external_switch; static int __devinit cpmac_probe(struct platform_device *pdev) { - int rc, phy_id; + int rc, phy_id, i; struct resource *mem; struct cpmac_priv *priv; struct net_device *dev; struct plat_cpmac_data *pdata; + struct fixed_info *fixed_phy; DECLARE_MAC_BUF(mac); pdata = pdev->dev.platform_data; @@ -1064,11 +1062,41 @@ static int __devinit cpmac_probe(struct platform_device *pdev) priv->ring_size = 64; priv->msg_enable = netif_msg_init(debug_level, 0xff); memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); + if (phy_id == 31) { - snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, - cpmac_mii.id, phy_id); - } else - snprintf(priv->phy_name, BUS_ID_SIZE, "fixed@%d:%d", 100, 1); + snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, cpmac_mii.id, + phy_id); + } else { + /* Let's try to get a free fixed phy... */ + for (i = 0; i < MAX_PHY_AMNT; i++) { + fixed_phy = fixed_mdio_get_phydev(i); + if (!fixed_phy) + continue; + if (!fixed_phy->phydev->attached_dev) { + strncpy(priv->phy_name, + fixed_phy->phydev->dev.bus_id, + BUS_ID_SIZE); + fixed_mdio_set_link_update(fixed_phy->phydev, + &cpmac_link_update); + goto phy_found; + } + } + if (netif_msg_drv(priv)) + printk(KERN_ERR "%s: Could not find fixed PHY\n", + dev->name); + rc = -ENODEV; + goto fail; + } + +phy_found: + priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0, + PHY_INTERFACE_MODE_MII); + if (IS_ERR(priv->phy)) { + if (netif_msg_drv(priv)) + printk(KERN_ERR "%s: Could not attach to PHY\n", + dev->name); + return PTR_ERR(priv->phy); + } if ((rc = register_netdev(dev))) { printk(KERN_ERR "cpmac: error %i registering device %s\n", rc, -- cgit v1.2.3-18-g5258 From 500d2c2f7b8c1cf6194dc9e8f47c6e2295fc5be5 Mon Sep 17 00:00:00 2001 From: Thomas Sailer Date: Wed, 24 Oct 2007 00:47:19 +0200 Subject: rndis_host: reduce MTU instead of refusing to talk to devices with low max packet size This patch makes the host RNDIS driver talk to RNDIS devices with an MTU less than 1.5k, instead of refusing to talk to such a device. Signed-Off-by: Thomas Sailer Acked-by: David Brownell -- Hi Jeff, are you the right person to send this to? Nobody else seems to be wanting to forward this to Linus... Thanks, Tom Signed-off-by: Jeff Garzik --- drivers/net/usb/rndis_host.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c index cd991a0f75b..1ebe3259be0 100644 --- a/drivers/net/usb/rndis_host.c +++ b/drivers/net/usb/rndis_host.c @@ -512,11 +512,19 @@ static int rndis_bind(struct usbnet *dev, struct usb_interface *intf) } tmp = le32_to_cpu(u.init_c->max_transfer_size); if (tmp < dev->hard_mtu) { - dev_err(&intf->dev, - "dev can't take %u byte packets (max %u)\n", - dev->hard_mtu, tmp); - retval = -EINVAL; - goto fail_and_release; + if (tmp <= net->hard_header_len) { + dev_err(&intf->dev, + "dev can't take %u byte packets (max %u)\n", + dev->hard_mtu, tmp); + retval = -EINVAL; + goto fail_and_release; + } + dev->hard_mtu = tmp; + net->mtu = dev->hard_mtu - net->hard_header_len; + dev_warn(&intf->dev, + "dev can't take %u byte packets (max %u), " + "adjusting MTU to %u\n", + dev->hard_mtu, tmp, net->mtu); } /* REVISIT: peripheral "alignment" request is ignored ... */ -- cgit v1.2.3-18-g5258 From 96fd4cd3e40e240f0c385af87f58e74da8b7099a Mon Sep 17 00:00:00 2001 From: Ayaz Abdulla Date: Thu, 25 Oct 2007 03:36:42 -0400 Subject: [netdrvr] forcedeth: add MCP77 device IDs Signed-off-by: Jeff Garzik --- drivers/net/forcedeth.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'drivers') diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c index 70ddf1acfd8..92ce2e38f0d 100644 --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c @@ -5597,6 +5597,22 @@ static struct pci_device_id pci_tbl[] = { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_31), .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, }, + { /* MCP77 Ethernet Controller */ + PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_32), + .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, + }, + { /* MCP77 Ethernet Controller */ + PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_33), + .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, + }, + { /* MCP77 Ethernet Controller */ + PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_34), + .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, + }, + { /* MCP77 Ethernet Controller */ + PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_35), + .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, + }, {0,}, }; -- cgit v1.2.3-18-g5258