aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sis900.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sis900.c')
-rw-r--r--drivers/net/sis900.c56
1 files changed, 25 insertions, 31 deletions
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index b3750f284279..2cb2e156c758 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -1160,7 +1160,6 @@ sis900_init_rx_ring(struct net_device *net_dev)
1160 buffer */ 1160 buffer */
1161 break; 1161 break;
1162 } 1162 }
1163 skb->dev = net_dev;
1164 sis_priv->rx_skbuff[i] = skb; 1163 sis_priv->rx_skbuff[i] = skb;
1165 sis_priv->rx_ring[i].cmdsts = RX_BUF_SIZE; 1164 sis_priv->rx_ring[i].cmdsts = RX_BUF_SIZE;
1166 sis_priv->rx_ring[i].bufptr = pci_map_single(sis_priv->pci_dev, 1165 sis_priv->rx_ring[i].bufptr = pci_map_single(sis_priv->pci_dev,
@@ -1754,6 +1753,25 @@ static int sis900_rx(struct net_device *net_dev)
1754 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE; 1753 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE;
1755 } else { 1754 } else {
1756 struct sk_buff * skb; 1755 struct sk_buff * skb;
1756 struct sk_buff * rx_skb;
1757
1758 pci_unmap_single(sis_priv->pci_dev,
1759 sis_priv->rx_ring[entry].bufptr, RX_BUF_SIZE,
1760 PCI_DMA_FROMDEVICE);
1761
1762 /* refill the Rx buffer, what if there is not enought
1763 * memory for new socket buffer ?? */
1764 if ((skb = dev_alloc_skb(RX_BUF_SIZE)) == NULL) {
1765 /*
1766 * Not enough memory to refill the buffer
1767 * so we need to recycle the old one so
1768 * as to avoid creating a memory hole
1769 * in the rx ring
1770 */
1771 skb = sis_priv->rx_skbuff[entry];
1772 sis_priv->stats.rx_dropped++;
1773 goto refill_rx_ring;
1774 }
1757 1775
1758 /* This situation should never happen, but due to 1776 /* This situation should never happen, but due to
1759 some unknow bugs, it is possible that 1777 some unknow bugs, it is possible that
@@ -1768,14 +1786,11 @@ static int sis900_rx(struct net_device *net_dev)
1768 break; 1786 break;
1769 } 1787 }
1770 1788
1771 pci_unmap_single(sis_priv->pci_dev,
1772 sis_priv->rx_ring[entry].bufptr, RX_BUF_SIZE,
1773 PCI_DMA_FROMDEVICE);
1774 /* give the socket buffer to upper layers */ 1789 /* give the socket buffer to upper layers */
1775 skb = sis_priv->rx_skbuff[entry]; 1790 rx_skb = sis_priv->rx_skbuff[entry];
1776 skb_put(skb, rx_size); 1791 skb_put(rx_skb, rx_size);
1777 skb->protocol = eth_type_trans(skb, net_dev); 1792 rx_skb->protocol = eth_type_trans(rx_skb, net_dev);
1778 netif_rx(skb); 1793 netif_rx(rx_skb);
1779 1794
1780 /* some network statistics */ 1795 /* some network statistics */
1781 if ((rx_status & BCAST) == MCAST) 1796 if ((rx_status & BCAST) == MCAST)
@@ -1783,33 +1798,13 @@ static int sis900_rx(struct net_device *net_dev)
1783 net_dev->last_rx = jiffies; 1798 net_dev->last_rx = jiffies;
1784 sis_priv->stats.rx_bytes += rx_size; 1799 sis_priv->stats.rx_bytes += rx_size;
1785 sis_priv->stats.rx_packets++; 1800 sis_priv->stats.rx_packets++;
1786 1801 sis_priv->dirty_rx++;
1787 /* refill the Rx buffer, what if there is not enought 1802refill_rx_ring:
1788 * memory for new socket buffer ?? */
1789 if ((skb = dev_alloc_skb(RX_BUF_SIZE)) == NULL) {
1790 /* not enough memory for skbuff, this makes a
1791 * "hole" on the buffer ring, it is not clear
1792 * how the hardware will react to this kind
1793 * of degenerated buffer */
1794 if (netif_msg_rx_status(sis_priv))
1795 printk(KERN_INFO "%s: Memory squeeze,"
1796 "deferring packet.\n",
1797 net_dev->name);
1798 sis_priv->rx_skbuff[entry] = NULL;
1799 /* reset buffer descriptor state */
1800 sis_priv->rx_ring[entry].cmdsts = 0;
1801 sis_priv->rx_ring[entry].bufptr = 0;
1802 sis_priv->stats.rx_dropped++;
1803 sis_priv->cur_rx++;
1804 break;
1805 }
1806 skb->dev = net_dev;
1807 sis_priv->rx_skbuff[entry] = skb; 1803 sis_priv->rx_skbuff[entry] = skb;
1808 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE; 1804 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE;
1809 sis_priv->rx_ring[entry].bufptr = 1805 sis_priv->rx_ring[entry].bufptr =
1810 pci_map_single(sis_priv->pci_dev, skb->data, 1806 pci_map_single(sis_priv->pci_dev, skb->data,
1811 RX_BUF_SIZE, PCI_DMA_FROMDEVICE); 1807 RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
1812 sis_priv->dirty_rx++;
1813 } 1808 }
1814 sis_priv->cur_rx++; 1809 sis_priv->cur_rx++;
1815 entry = sis_priv->cur_rx % NUM_RX_DESC; 1810 entry = sis_priv->cur_rx % NUM_RX_DESC;
@@ -1836,7 +1831,6 @@ static int sis900_rx(struct net_device *net_dev)
1836 sis_priv->stats.rx_dropped++; 1831 sis_priv->stats.rx_dropped++;
1837 break; 1832 break;
1838 } 1833 }
1839 skb->dev = net_dev;
1840 sis_priv->rx_skbuff[entry] = skb; 1834 sis_priv->rx_skbuff[entry] = skb;
1841 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE; 1835 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE;
1842 sis_priv->rx_ring[entry].bufptr = 1836 sis_priv->rx_ring[entry].bufptr =