ia64/xen-unstable

changeset 246:0feeef527323

bitkeeper revision 1.104 (3e5cf351zM_u_gdQ7xC6wyGYbvtLAA)

e1000_main.c, e1000.h, Makefile:
Add some locking to Intel's shoddy e1000 driver.
author kaf24@labyrinth.cl.cam.ac.uk
date Wed Feb 26 17:03:13 2003 +0000 (2003-02-26)
parents ce6eb0deb0c7
children 0a7d144921ff
files xen/drivers/net/Makefile xen/drivers/net/e1000/e1000.h xen/drivers/net/e1000/e1000_main.c
line diff
     1.1 --- a/xen/drivers/net/Makefile	Wed Feb 26 15:57:33 2003 +0000
     1.2 +++ b/xen/drivers/net/Makefile	Wed Feb 26 17:03:13 2003 +0000
     1.3 @@ -8,6 +8,7 @@ default: $(OBJS)
     1.4  
     1.5  clean:
     1.6  	$(MAKE) -C ne clean
     1.7 +	$(MAKE) -C e1000 clean
     1.8  	rm -f *.o *~ core
     1.9  
    1.10  .PHONY: default clean
     2.1 --- a/xen/drivers/net/e1000/e1000.h	Wed Feb 26 15:57:33 2003 +0000
     2.2 +++ b/xen/drivers/net/e1000/e1000.h	Wed Feb 26 17:03:13 2003 +0000
     2.3 @@ -200,9 +200,10 @@ struct e1000_adapter {
     2.4  	struct e1000_phy_info phy_info;
     2.5  	struct e1000_phy_stats phy_stats;
     2.6  
     2.7 -
     2.8 -
     2.9  	uint32_t pci_state[16];
    2.10  	char ifname[IFNAMSIZ];
    2.11 +
    2.12 +	/* All new definitions should go below this point! */
    2.13 +	spinlock_t tx_lock;
    2.14  };
    2.15  #endif /* _E1000_H_ */
     3.1 --- a/xen/drivers/net/e1000/e1000_main.c	Wed Feb 26 15:57:33 2003 +0000
     3.2 +++ b/xen/drivers/net/e1000/e1000_main.c	Wed Feb 26 17:03:13 2003 +0000
     3.3 @@ -362,6 +362,7 @@ e1000_probe(struct pci_dev *pdev,
     3.4  	adapter->netdev = netdev;
     3.5  	adapter->pdev = pdev;
     3.6  	adapter->hw.back = adapter;
     3.7 +	spin_lock_init(&adapter->tx_lock);
     3.8  
     3.9  	mmio_start = pci_resource_start(pdev, BAR_0);
    3.10  	mmio_len = pci_resource_len(pdev, BAR_0);
    3.11 @@ -1439,6 +1440,7 @@ e1000_xmit_frame(struct sk_buff *skb, st
    3.12  		count++;
    3.13  
    3.14  	if(E1000_DESC_UNUSED(&adapter->tx_ring) < count) {
    3.15 +		printk("%s: BUG! Ring full with queue awake!\n", netdev->name);
    3.16  		netif_stop_queue(netdev);
    3.17  		return 1;
    3.18  	}
    3.19 @@ -1448,15 +1450,22 @@ e1000_xmit_frame(struct sk_buff *skb, st
    3.20  
    3.21  	if(adapter->vlgrp && vlan_tx_tag_present(skb)) {
    3.22  		tx_flags |= E1000_TX_FLAGS_VLAN;
    3.23 -		tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
    3.24 +		tx_flags |= (vlan_tx_tag_get(skb)<<E1000_TX_FLAGS_VLAN_SHIFT);
    3.25  	}
    3.26  
    3.27 +	spin_lock_irq(&adapter->tx_lock);
    3.28 +
    3.29  	count = e1000_tx_map(adapter, skb);
    3.30  
    3.31  	e1000_tx_queue(adapter, count, tx_flags);
    3.32  
    3.33  	netdev->trans_start = jiffies;
    3.34  
    3.35 +	if(E1000_DESC_UNUSED(&adapter->tx_ring) < (MAX_SKB_FRAGS + 1))
    3.36 +		netif_stop_queue(netdev);
    3.37 +
    3.38 +	spin_unlock_irq(&adapter->tx_lock);
    3.39 +
    3.40  	return 0;
    3.41  }
    3.42  
    3.43 @@ -1759,6 +1768,9 @@ e1000_clean_tx_irq(struct e1000_adapter 
    3.44  	struct pci_dev *pdev = adapter->pdev;
    3.45  	struct e1000_tx_desc *tx_desc;
    3.46  	int i;
    3.47 +	unsigned long flags;
    3.48 +
    3.49 +	spin_lock_irqsave(&adapter->tx_lock, flags);
    3.50  
    3.51  	i = tx_ring->next_to_clean;
    3.52  	tx_desc = E1000_TX_DESC(*tx_ring, i);
    3.53 @@ -1795,6 +1807,8 @@ e1000_clean_tx_irq(struct e1000_adapter 
    3.54  
    3.55  		netif_wake_queue(netdev);
    3.56  	}
    3.57 +
    3.58 +	spin_unlock_irqrestore(&adapter->tx_lock, flags);
    3.59  }
    3.60  
    3.61  /**