Commit 9a2f7a76 authored by Jeff Garzik's avatar Jeff Garzik

Merge redhat.com:/spare/repo/linux-2.5

into redhat.com:/spare/repo/net-drivers-2.5
parents 99e5aa34 325188e8
...@@ -997,6 +997,11 @@ static void set_multicast_list(struct net_device *dev) ...@@ -997,6 +997,11 @@ static void set_multicast_list(struct net_device *dev)
spin_unlock_irqrestore(&ei_local->page_lock, flags); spin_unlock_irqrestore(&ei_local->page_lock, flags);
} }
static inline void ei_device_init(struct ei_device *ei_local)
{
spin_lock_init(&ei_local->page_lock);
}
/** /**
* ethdev_init - init rest of 8390 device struct * ethdev_init - init rest of 8390 device struct
* @dev: network device structure to init * @dev: network device structure to init
...@@ -1012,14 +1017,11 @@ int ethdev_init(struct net_device *dev) ...@@ -1012,14 +1017,11 @@ int ethdev_init(struct net_device *dev)
if (dev->priv == NULL) if (dev->priv == NULL)
{ {
struct ei_device *ei_local;
dev->priv = kmalloc(sizeof(struct ei_device), GFP_KERNEL); dev->priv = kmalloc(sizeof(struct ei_device), GFP_KERNEL);
if (dev->priv == NULL) if (dev->priv == NULL)
return -ENOMEM; return -ENOMEM;
memset(dev->priv, 0, sizeof(struct ei_device)); memset(dev->priv, 0, sizeof(struct ei_device));
ei_local = (struct ei_device *)dev->priv; ei_device_init(dev->priv);
spin_lock_init(&ei_local->page_lock);
} }
dev->hard_start_xmit = &ei_start_xmit; dev->hard_start_xmit = &ei_start_xmit;
...@@ -1030,6 +1032,29 @@ int ethdev_init(struct net_device *dev) ...@@ -1030,6 +1032,29 @@ int ethdev_init(struct net_device *dev)
return 0; return 0;
} }
/* wrapper to make alloc_netdev happy; probably should just cast... */
static void __ethdev_init(struct net_device *dev)
{
ethdev_init(dev);
}
/**
* alloc_ei_netdev - alloc_etherdev counterpart for 8390
*
* Allocate 8390-specific net_device.
*/
struct net_device *alloc_ei_netdev(void)
{
struct net_device *dev;
dev = alloc_netdev(sizeof(struct ei_device), "eth%d", __ethdev_init);
if (dev)
ei_device_init(dev->priv);
return dev;
}
...@@ -1133,6 +1158,7 @@ EXPORT_SYMBOL(ei_interrupt); ...@@ -1133,6 +1158,7 @@ EXPORT_SYMBOL(ei_interrupt);
EXPORT_SYMBOL(ei_tx_timeout); EXPORT_SYMBOL(ei_tx_timeout);
EXPORT_SYMBOL(ethdev_init); EXPORT_SYMBOL(ethdev_init);
EXPORT_SYMBOL(NS8390_init); EXPORT_SYMBOL(NS8390_init);
EXPORT_SYMBOL(alloc_ei_netdev);
#if defined(MODULE) #if defined(MODULE)
......
...@@ -44,6 +44,7 @@ extern void NS8390_init(struct net_device *dev, int startp); ...@@ -44,6 +44,7 @@ extern void NS8390_init(struct net_device *dev, int startp);
extern int ei_open(struct net_device *dev); extern int ei_open(struct net_device *dev);
extern int ei_close(struct net_device *dev); extern int ei_close(struct net_device *dev);
extern irqreturn_t ei_interrupt(int irq, void *dev_id, struct pt_regs *regs); extern irqreturn_t ei_interrupt(int irq, void *dev_id, struct pt_regs *regs);
extern struct net_device *alloc_ei_netdev(void);
/* You have one of these per-board */ /* You have one of these per-board */
struct ei_device { struct ei_device {
......
...@@ -174,7 +174,7 @@ static void ne2k_pci_block_input(struct net_device *dev, int count, ...@@ -174,7 +174,7 @@ static void ne2k_pci_block_input(struct net_device *dev, int count,
struct sk_buff *skb, int ring_offset); struct sk_buff *skb, int ring_offset);
static void ne2k_pci_block_output(struct net_device *dev, const int count, static void ne2k_pci_block_output(struct net_device *dev, const int count,
const unsigned char *buf, const int start_page); const unsigned char *buf, const int start_page);
static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); static struct ethtool_ops ne2k_pci_ethtool_ops;
...@@ -259,7 +259,8 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev, ...@@ -259,7 +259,8 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
} }
} }
dev = alloc_etherdev(0); /* Allocate net_device, dev->priv; fill in 8390 specific dev fields. */
dev = alloc_ei_netdev();
if (!dev) { if (!dev) {
printk (KERN_ERR PFX "cannot allocate ethernet device\n"); printk (KERN_ERR PFX "cannot allocate ethernet device\n");
goto err_out_free_res; goto err_out_free_res;
...@@ -331,13 +332,6 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev, ...@@ -331,13 +332,6 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
dev->base_addr = ioaddr; dev->base_addr = ioaddr;
pci_set_drvdata(pdev, dev); pci_set_drvdata(pdev, dev);
/* Allocate dev->priv and fill in 8390 specific dev fields. */
if (ethdev_init(dev)) {
printk (KERN_ERR "ne2kpci(%s): unable to get memory for dev->priv.\n",
pci_name(pdev));
goto err_out_free_netdev;
}
ei_status.name = pci_clone_list[chip_idx].name; ei_status.name = pci_clone_list[chip_idx].name;
ei_status.tx_start_page = start_page; ei_status.tx_start_page = start_page;
ei_status.stop_page = stop_page; ei_status.stop_page = stop_page;
...@@ -361,12 +355,12 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev, ...@@ -361,12 +355,12 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
ei_status.priv = (unsigned long) pdev; ei_status.priv = (unsigned long) pdev;
dev->open = &ne2k_pci_open; dev->open = &ne2k_pci_open;
dev->stop = &ne2k_pci_close; dev->stop = &ne2k_pci_close;
dev->do_ioctl = &netdev_ioctl; dev->ethtool_ops = &ne2k_pci_ethtool_ops;
NS8390_init(dev, 0); NS8390_init(dev, 0);
i = register_netdev(dev); i = register_netdev(dev);
if (i) if (i)
goto err_out_free_8390; goto err_out_free_netdev;
printk("%s: %s found at %#lx, IRQ %d, ", printk("%s: %s found at %#lx, IRQ %d, ",
dev->name, pci_clone_list[chip_idx].name, ioaddr, dev->irq); dev->name, pci_clone_list[chip_idx].name, ioaddr, dev->irq);
...@@ -377,10 +371,8 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev, ...@@ -377,10 +371,8 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
return 0; return 0;
err_out_free_8390:
kfree(dev->priv);
err_out_free_netdev: err_out_free_netdev:
kfree (dev); free_netdev (dev);
err_out_free_res: err_out_free_res:
release_region (ioaddr, NE_IO_EXTENT); release_region (ioaddr, NE_IO_EXTENT);
pci_set_drvdata (pdev, NULL); pci_set_drvdata (pdev, NULL);
...@@ -591,40 +583,22 @@ static void ne2k_pci_block_output(struct net_device *dev, int count, ...@@ -591,40 +583,22 @@ static void ne2k_pci_block_output(struct net_device *dev, int count,
return; return;
} }
static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr) static void ne2k_pci_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{ {
struct ei_device *ei = dev->priv; struct ei_device *ei = dev->priv;
struct pci_dev *pci_dev = (struct pci_dev *) ei->priv; struct pci_dev *pci_dev = (struct pci_dev *) ei->priv;
u32 ethcmd;
if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
return -EFAULT;
switch (ethcmd) {
case ETHTOOL_GDRVINFO: {
struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
strcpy(info.driver, DRV_NAME);
strcpy(info.version, DRV_VERSION);
strcpy(info.bus_info, pci_name(pci_dev));
if (copy_to_user(useraddr, &info, sizeof(info)))
return -EFAULT;
return 0;
}
} strcpy(info->driver, DRV_NAME);
strcpy(info->version, DRV_VERSION);
return -EOPNOTSUPP; strcpy(info->bus_info, pci_name(pci_dev));
} }
static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) static struct ethtool_ops ne2k_pci_ethtool_ops = {
{ .get_drvinfo = ne2k_pci_get_drvinfo,
switch(cmd) { .get_tx_csum = ethtool_op_get_tx_csum,
case SIOCETHTOOL: .get_sg = ethtool_op_get_sg,
return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); };
default:
return -EOPNOTSUPP;
}
}
static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev) static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev)
{ {
...@@ -635,8 +609,8 @@ static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev) ...@@ -635,8 +609,8 @@ static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev)
unregister_netdev(dev); unregister_netdev(dev);
release_region(dev->base_addr, NE_IO_EXTENT); release_region(dev->base_addr, NE_IO_EXTENT);
kfree(dev->priv);
free_netdev(dev); free_netdev(dev);
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
} }
......
...@@ -267,38 +267,6 @@ static void tg3_enable_ints(struct tg3 *tp) ...@@ -267,38 +267,6 @@ static void tg3_enable_ints(struct tg3 *tp)
tg3_cond_int(tp); tg3_cond_int(tp);
} }
/* these netif_xxx funcs should be moved into generic net layer */
static void netif_poll_disable(struct net_device *dev)
{
while (test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state)) {
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(1);
}
}
static inline void netif_poll_enable(struct net_device *dev)
{
clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
}
/* same as netif_rx_complete, except that local_irq_save(flags)
* has already been issued
*/
static inline void __netif_rx_complete(struct net_device *dev)
{
if (!test_bit(__LINK_STATE_RX_SCHED, &dev->state)) BUG();
list_del(&dev->poll_list);
smp_mb__before_clear_bit();
clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
}
static inline void netif_tx_disable(struct net_device *dev)
{
spin_lock_bh(&dev->xmit_lock);
netif_stop_queue(dev);
spin_unlock_bh(&dev->xmit_lock);
}
static inline void tg3_netif_stop(struct tg3 *tp) static inline void tg3_netif_stop(struct tg3 *tp)
{ {
netif_poll_disable(tp->dev); netif_poll_disable(tp->dev);
......
...@@ -832,6 +832,38 @@ static inline void netif_rx_complete(struct net_device *dev) ...@@ -832,6 +832,38 @@ static inline void netif_rx_complete(struct net_device *dev)
local_irq_restore(flags); local_irq_restore(flags);
} }
static inline void netif_poll_disable(struct net_device *dev)
{
while (test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state)) {
/* No hurry. */
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(1);
}
}
static inline void netif_poll_enable(struct net_device *dev)
{
clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
}
/* same as netif_rx_complete, except that local_irq_save(flags)
* has already been issued
*/
static inline void __netif_rx_complete(struct net_device *dev)
{
if (!test_bit(__LINK_STATE_RX_SCHED, &dev->state)) BUG();
list_del(&dev->poll_list);
smp_mb__before_clear_bit();
clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
}
static inline void netif_tx_disable(struct net_device *dev)
{
spin_lock_bh(&dev->xmit_lock);
netif_stop_queue(dev);
spin_unlock_bh(&dev->xmit_lock);
}
/* These functions live elsewhere (drivers/net/net_init.c, but related) */ /* These functions live elsewhere (drivers/net/net_init.c, but related) */
extern void ether_setup(struct net_device *dev); extern void ether_setup(struct net_device *dev);
......
...@@ -845,11 +845,7 @@ int dev_close(struct net_device *dev) ...@@ -845,11 +845,7 @@ int dev_close(struct net_device *dev)
* engine, but this requires more changes in devices. */ * engine, but this requires more changes in devices. */
smp_mb__after_clear_bit(); /* Commit netif_running(). */ smp_mb__after_clear_bit(); /* Commit netif_running(). */
while (test_bit(__LINK_STATE_RX_SCHED, &dev->state)) { netif_poll_disable(dev);
/* No hurry. */
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(1);
}
/* /*
* Call the device specific close. This cannot fail. * Call the device specific close. This cannot fail.
...@@ -1657,7 +1653,7 @@ static int process_backlog(struct net_device *backlog_dev, int *budget) ...@@ -1657,7 +1653,7 @@ static int process_backlog(struct net_device *backlog_dev, int *budget)
list_del(&backlog_dev->poll_list); list_del(&backlog_dev->poll_list);
smp_mb__before_clear_bit(); smp_mb__before_clear_bit();
clear_bit(__LINK_STATE_RX_SCHED, &backlog_dev->state); netif_poll_enable(backlog_dev);
if (queue->throttle) { if (queue->throttle) {
queue->throttle = 0; queue->throttle = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment