Subject: Re: [PATCH v3] Ethernet driver for the WIZnet W5300 chip

From: Mike Sinkovsky <[email-masked]>
Date: Mon, 26 Mar 2012 15:05:04 +0600

24.03.2012 22:10, Eric Dumazet wrote:
> As there is no tx interrupt at the end of transmit to eventually XON the
> queue, you cant XOFF it when there it no room in transmit queue.

Actually there is, but is unused in original driver, don't know why.

> Rule to use NETDEV_TX_BUSY is :
>
> Before returning NETDEV_TX_BUSY, qdisc must have been stopped by
> netif_stop_queue(ndev) (and tx completion might call netif_wake_queue()
> later)

I tried handle this situation, and it seems to work perfectly:

@@ -377,7 +377,8 @@ static int w5300_start_tx(struct sk_buff *skb, 
struct net_device *ndev)
          struct w5300_private *priv = netdev_priv(ndev);

          if (unlikely(w5300_read32(priv, W5300_S0_TX_FSR) < skb->len)) {
-                ndev->stats.tx_dropped++;
+                netif_stop_queue(ndev);
+                w5300_write(priv, W5300_S0_IMR, S0_IR_RECV | S0_IR_SENDOK);
                  return NETDEV_TX_BUSY;
          }

@@ -443,6 +444,12 @@ static irqreturn_t w5300_interrupt(int irq, void 
*ndev_instance)
                  __napi_schedule(&priv->napi);
          }

+        if (unlikely(netif_queue_stopped(ndev))) {
+                w5300_write(priv, W5300_S0_IR, S0_IR_SENDOK);
+                w5300_write(priv, W5300_S0_IMR, S0_IR_RECV);
+                netif_wake_queue(ndev);
+        }
+
          return IRQ_HANDLED;
  }

-- 
Mike