- if((priv->tx_skb[tx] == 0) && (priv->tx_skb[tx_next] == 0))
- {
- if(!(priv->tx[tx].txd2 & TX_DMA_DONE) || !(priv->tx[tx_next].txd2 & TX_DMA_DONE))
- {
- kfree_skb(skb);
- dev->stats.tx_dropped++;
- printk(KERN_ERR "%s: dropping\n", dev->name);
- return 0;
- }
- priv->tx[tx].txd1 = virt_to_phys(skb->data);
- priv->tx[tx].txd2 &= ~(TX_DMA_PLEN0_MASK | TX_DMA_DONE);
- priv->tx[tx].txd2 |= TX_DMA_PLEN0(skb->len);
- wmb();
- ramips_fe_wr((tx + 1) % NUM_TX_DESC, RAMIPS_TX_CTX_IDX0);
- dev->stats.tx_packets++;
- dev->stats.tx_bytes += skb->len;
- priv->tx_skb[tx] = skb;
- wmb();
- ramips_fe_wr((tx + 1) % NUM_TX_DESC, RAMIPS_TX_CTX_IDX0);
- } else {
- dev->stats.tx_dropped++;
- kfree_skb(skb);
- }
- return 0;
+ if((priv->tx_skb[tx]) || (priv->tx_skb[tx_next]) ||
+ !(priv->tx[tx].txd2 & TX_DMA_DONE) || !(priv->tx[tx_next].txd2 & TX_DMA_DONE))
+ goto out;
+ priv->tx[tx].txd1 = mapped_addr;
+ priv->tx[tx].txd2 &= ~(TX_DMA_PLEN0_MASK | TX_DMA_DONE);
+ priv->tx[tx].txd2 |= TX_DMA_PLEN0(skb->len);
+ dev->stats.tx_packets++;
+ dev->stats.tx_bytes += skb->len;
+ priv->tx_skb[tx] = skb;
+ wmb();
+ ramips_fe_wr((tx + 1) % NUM_TX_DESC, RAMIPS_TX_CTX_IDX0);
+ spin_unlock_irqrestore(&priv->page_lock, flags);
+ return NETDEV_TX_OK;
+out:
+ spin_unlock_irqrestore(&priv->page_lock, flags);
+ dev->stats.tx_dropped++;
+ kfree_skb(skb);
+ return NETDEV_TX_OK;