target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c
static int bcm6368_enetsw_tx_reclaim(struct net_device *dev, int force)
{
	struct bcm6368_enetsw *priv = netdev_priv(dev);
	int released = 0;

	while (priv->tx_desc_count < priv->tx_ring_size) {
		struct bcm6368_enetsw_desc *desc;
		struct sk_buff *skb;

		/* We run in a bh and fight against start_xmit, which
		 * is called with bh disabled */
		spin_lock(&priv->tx_lock);

		desc = &priv->tx_desc_cpu[priv->tx_dirty_desc];

		if (!force && (desc->len_stat & DMADESC_OWNER_MASK)) {
			spin_unlock(&priv->tx_lock);
			break;
		}

		/* ensure other field of the descriptor were not read
		 * before we checked ownership */
		rmb();

		skb = priv->tx_skb[priv->tx_dirty_desc];
		priv->tx_skb[priv->tx_dirty_desc] = NULL;
		dma_unmap_single(&priv->pdev->dev, desc->address, skb->len,
				 DMA_TO_DEVICE);

		priv->tx_dirty_desc++;
		if (priv->tx_dirty_desc == priv->tx_ring_size)
			priv->tx_dirty_desc = 0;
		priv->tx_desc_count++;

		spin_unlock(&priv->tx_lock);

		if (desc->len_stat & DMADESC_UNDER_MASK)
			dev->stats.tx_errors++;

		dev_kfree_skb(skb);
		released++;
	}

	if (netif_queue_stopped(dev) && released)
		netif_wake_queue(dev);

	return released;
}
/*
 * try to or force reclaim of transmitted buffers
 */
try to or force reclaim of transmitted buffers
try to or force reclaim of transmitted buffers
static int bcm6368_enetsw_tx_reclaim(struct net_device *dev, int force)
{
	struct bcm6368_enetsw *priv = netdev_priv(dev);
	int released = 0;
	while (priv->tx_desc_count < priv->tx_ring_size) {
		struct bcm6368_enetsw_desc *desc;
		struct sk_buff *skb;
		spin_lock(&priv->tx_lock);
		desc = &priv->tx_desc_cpu[priv->tx_dirty_desc];
		if (!force && (desc->len_stat & DMADESC_OWNER_MASK)) {
			spin_unlock(&priv->tx_lock);
			break;
		}
		rmb();
		skb = priv->tx_skb[priv->tx_dirty_desc];
		priv->tx_skb[priv->tx_dirty_desc] = NULL;
		dma_unmap_single(&priv->pdev->dev, desc->address, skb->len,
				 DMA_TO_DEVICE);
		priv->tx_dirty_desc++;
		if (priv->tx_dirty_desc == priv->tx_ring_size)
			priv->tx_dirty_desc = 0;
		priv->tx_desc_count++;
		spin_unlock(&priv->tx_lock);
		if (desc->len_stat & DMADESC_UNDER_MASK)
			dev->stats.tx_errors++;
		dev_kfree_skb(skb);
		released++;
	}
	if (netif_queue_stopped(dev) && released)
		netif_wake_queue(dev);
	return released;
}
static int bcm6368_enetsw_tx_reclaim ( struct net_device * dev , int force ) { struct bcm6368_enetsw * priv = netdev_priv ( dev ) ; int released = 0 ; while ( priv -> tx_desc_count < priv -> tx_ring_size ) { struct bcm6368_enetsw_desc * desc ; struct sk_buff * skb ; spin_lock ( & priv -> tx_lock ) ; desc = & priv -> tx_desc_cpu [ priv -> tx_dirty_desc ] ; if ( ! force && ( desc -> len_stat & DMADESC_OWNER_MASK ) ) { spin_unlock ( & priv -> tx_lock ) ; break ; } rmb ( ) ; skb = priv -> tx_skb [ priv -> tx_dirty_desc ] ; priv -> tx_skb [ priv -> tx_dirty_desc ] = NULL ; dma_unmap_single ( & priv -> pdev -> dev , desc -> address , skb -> len , DMA_TO_DEVICE ) ; priv -> tx_dirty_desc ++ ; if ( priv -> tx_dirty_desc == priv -> tx_ring_size ) priv -> tx_dirty_desc = 0 ; priv -> tx_desc_count ++ ; spin_unlock ( & priv -> tx_lock ) ; if ( desc -> len_stat & DMADESC_UNDER_MASK ) dev -> stats . tx_errors ++ ; dev_kfree_skb ( skb ) ; released ++ ; } if ( netif_queue_stopped ( dev ) && released ) netif_wake_queue ( dev ) ; return released ; }
try to or force reclaim of transmitted buffers
try to or force reclaim of transmitted buffers
/* We run in a bh and fight against start_xmit, which
		 * is called with bh disabled */ /* ensure other field of the descriptor were not read
		 * before we checked ownership */