From 7eccb26dc8f6d09660b22fcbd868572d050df26f Mon Sep 17 00:00:00 2001
From: Dave Taht <dave.taht@bufferbloat.net>
Date: Thu, 6 Nov 2014 08:45:30 -0800
Subject: [PATCH] Add BQL support to the TI cpsw driver
Tested on the beaglebone black.
I get a huge improvement in both throughput and latency.
Latency goes from 60ms worst case with pfifo_fast, and 12ms worst case with
sch_fq to 2.5ms with BQL enabled.
Throughput improved also.
---
drivers/net/ethernet/ti/cpsw.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
@@ -118,7 +118,7 @@ do { \
#define CPDMA_TXCP 0x40
#define CPDMA_RXCP 0x60
-#define CPSW_POLL_WEIGHT 64
+#define CPSW_POLL_WEIGHT 16
#define CPSW_MIN_PACKET_SIZE 60
#define CPSW_MAX_PACKET_SIZE (1500 + 14 + 4 + 4)
@@ -693,6 +693,7 @@ static void cpsw_tx_handler(void *token, int len, int status)
cpts_tx_timestamp(priv->cpts, skb);
ndev->stats.tx_packets++;
ndev->stats.tx_bytes += len;
+ netdev_completed_queue(ndev,1,len);
dev_kfree_skb_any(skb);
}
@@ -1307,6 +1308,8 @@ static int cpsw_ndo_open(struct net_device *ndev)
cpsw_set_coalesce(ndev, &coal);
}
+ netdev_reset_queue(ndev);
+ dev_info(priv->dev, "BQL enabled\n");
napi_enable(&priv->napi);
cpdma_ctlr_start(priv->dma);
cpsw_intr_enable(priv);
@@ -1341,6 +1344,7 @@ static int cpsw_ndo_stop(struct net_device *ndev)
netif_stop_queue(priv->ndev);
napi_disable(&priv->napi);
netif_carrier_off(priv->ndev);
+ netdev_reset_queue(priv->ndev);
if (cpsw_common_res_usage_state(priv) <= 1) {
cpts_unregister(priv->cpts);
@@ -1361,6 +1365,7 @@ static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb,
{
struct cpsw_priv *priv = netdev_priv(ndev);
int ret;
+ int len;
ndev->trans_start = jiffies;
@@ -1375,9 +1380,11 @@ static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb,
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
skb_tx_timestamp(skb);
-
+ len = max(skb->len, CPSW_MIN_PACKET_SIZE);
+ netdev_sent_queue(ndev,len);
ret = cpsw_tx_packet_submit(ndev, priv, skb);
if (unlikely(ret != 0)) {
+ netdev_completed_queue(ndev,1,len);
cpsw_err(priv, tx_err, "desc submit failed\n");
goto fail;
}
--
1.9.1