aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhayeswang <hayeswang@realtek.com>2013-11-20 04:30:56 -0500
committerDavid S. Miller <davem@davemloft.net>2013-11-20 15:09:42 -0500
commitdd1b119c835632f5d939f2a7351ad95001d9cb52 (patch)
tree005ce53b5939c72b15ee60a676b9298fa798dd37
parent61598788582cafad52816d5d1db879334d8bd561 (diff)
r8152: support stopping/waking tx queue
The maximum packet number which a tx aggregation buffer could contain is the tx_qlen. tx_qlen = buffer size / (packet size + descriptor size). If the tx buffer is empty and the queued packets are more than the maximum value which is defined above, stop the tx queue. Wake the tx queue if tx queue is stopped and the queued packets are less than tx_qlen. Signed-off-by: Hayes Wang <hayeswang@realtek.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/usb/r8152.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 8a786b65d883..f92e0cfb5d87 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -365,6 +365,7 @@ struct r8152 {
365 struct mii_if_info mii; 365 struct mii_if_info mii;
366 int intr_interval; 366 int intr_interval;
367 u32 msg_enable; 367 u32 msg_enable;
368 u32 tx_qlen;
368 u16 ocp_base; 369 u16 ocp_base;
369 u8 *intr_buff; 370 u8 *intr_buff;
370 u8 version; 371 u8 version;
@@ -1173,6 +1174,14 @@ static int r8152_tx_agg_fill(struct r8152 *tp, struct tx_agg *agg)
1173 remain = rx_buf_sz - (int)(tx_agg_align(tx_data) - agg->head); 1174 remain = rx_buf_sz - (int)(tx_agg_align(tx_data) - agg->head);
1174 } 1175 }
1175 1176
1177 netif_tx_lock(tp->netdev);
1178
1179 if (netif_queue_stopped(tp->netdev) &&
1180 skb_queue_len(&tp->tx_queue) < tp->tx_qlen)
1181 netif_wake_queue(tp->netdev);
1182
1183 netif_tx_unlock(tp->netdev);
1184
1176 usb_fill_bulk_urb(agg->urb, tp->udev, usb_sndbulkpipe(tp->udev, 2), 1185 usb_fill_bulk_urb(agg->urb, tp->udev, usb_sndbulkpipe(tp->udev, 2),
1177 agg->head, (int)(tx_data - (u8 *)agg->head), 1186 agg->head, (int)(tx_data - (u8 *)agg->head),
1178 (usb_complete_t)write_bulk_callback, agg); 1187 (usb_complete_t)write_bulk_callback, agg);
@@ -1393,6 +1402,10 @@ static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb,
1393 1402
1394 skb_queue_tail(&tp->tx_queue, skb); 1403 skb_queue_tail(&tp->tx_queue, skb);
1395 1404
1405 if (list_empty(&tp->tx_free) &&
1406 skb_queue_len(&tp->tx_queue) > tp->tx_qlen)
1407 netif_stop_queue(netdev);
1408
1396 if (!list_empty(&tp->tx_free)) 1409 if (!list_empty(&tp->tx_free))
1397 tasklet_schedule(&tp->tl); 1410 tasklet_schedule(&tp->tl);
1398 1411
@@ -1423,6 +1436,14 @@ static void rtl8152_nic_reset(struct r8152 *tp)
1423 } 1436 }
1424} 1437}
1425 1438
1439static void set_tx_qlen(struct r8152 *tp)
1440{
1441 struct net_device *netdev = tp->netdev;
1442
1443 tp->tx_qlen = rx_buf_sz / (netdev->mtu + VLAN_ETH_HLEN + VLAN_HLEN +
1444 sizeof(struct tx_desc));
1445}
1446
1426static inline u8 rtl8152_get_speed(struct r8152 *tp) 1447static inline u8 rtl8152_get_speed(struct r8152 *tp)
1427{ 1448{
1428 return ocp_read_byte(tp, MCU_TYPE_PLA, PLA_PHYSTATUS); 1449 return ocp_read_byte(tp, MCU_TYPE_PLA, PLA_PHYSTATUS);
@@ -1434,6 +1455,7 @@ static int rtl8152_enable(struct r8152 *tp)
1434 int i, ret; 1455 int i, ret;
1435 u8 speed; 1456 u8 speed;
1436 1457
1458 set_tx_qlen(tp);
1437 speed = rtl8152_get_speed(tp); 1459 speed = rtl8152_get_speed(tp);
1438 if (speed & _10bps) { 1460 if (speed & _10bps) {
1439 ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR); 1461 ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR);