aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwilly tarreau <w@1wt.eu>2014-01-16 02:20:12 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-16 18:15:42 -0500
commit6c4989748759f433bf999f33c1ff3853ed5ca945 (patch)
treeb4b0bbf5fec97d52a515c8bef433ceff2161cff4
parent71f6d1b31fb1f278a345a30a2180515adc7d80ae (diff)
net: mvneta: remove tests for impossible cases in the tx_done path
Currently, mvneta_txq_bufs_free() calls mvneta_tx_done_policy() with a non-null cause to retrieve the pointer to the next queue to process. There are useless tests on the return queue number and on the pointer, all of which are well defined within a known limited set. This code path is fast, although not critical. Removing 3 tests here that the compiler could not optimize (verified) is always desirable. Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: Gregory CLEMENT <gregory.clement@free-electrons.com> Tested-by: Arnaud Ebalard <arno@natisbad.org> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/marvell/mvneta.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index df75a2302740..2fb9559ba6fe 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -1276,13 +1276,16 @@ static void mvneta_rx_csum(struct mvneta_port *pp,
1276 skb->ip_summed = CHECKSUM_NONE; 1276 skb->ip_summed = CHECKSUM_NONE;
1277} 1277}
1278 1278
1279/* Return tx queue pointer (find last set bit) according to causeTxDone reg */ 1279/* Return tx queue pointer (find last set bit) according to <cause> returned
1280 * form tx_done reg. <cause> must not be null. The return value is always a
1281 * valid queue for matching the first one found in <cause>.
1282 */
1280static struct mvneta_tx_queue *mvneta_tx_done_policy(struct mvneta_port *pp, 1283static struct mvneta_tx_queue *mvneta_tx_done_policy(struct mvneta_port *pp,
1281 u32 cause) 1284 u32 cause)
1282{ 1285{
1283 int queue = fls(cause) - 1; 1286 int queue = fls(cause) - 1;
1284 1287
1285 return (queue < 0 || queue >= txq_number) ? NULL : &pp->txqs[queue]; 1288 return &pp->txqs[queue];
1286} 1289}
1287 1290
1288/* Free tx queue skbuffs */ 1291/* Free tx queue skbuffs */
@@ -1651,7 +1654,9 @@ static void mvneta_txq_done_force(struct mvneta_port *pp,
1651 txq->txq_get_index = 0; 1654 txq->txq_get_index = 0;
1652} 1655}
1653 1656
1654/* handle tx done - called from tx done timer callback */ 1657/* Handle tx done - called in softirq context. The <cause_tx_done> argument
1658 * must be a valid cause according to MVNETA_TXQ_INTR_MASK_ALL.
1659 */
1655static u32 mvneta_tx_done_gbe(struct mvneta_port *pp, u32 cause_tx_done, 1660static u32 mvneta_tx_done_gbe(struct mvneta_port *pp, u32 cause_tx_done,
1656 int *tx_todo) 1661 int *tx_todo)
1657{ 1662{
@@ -1660,10 +1665,8 @@ static u32 mvneta_tx_done_gbe(struct mvneta_port *pp, u32 cause_tx_done,
1660 struct netdev_queue *nq; 1665 struct netdev_queue *nq;
1661 1666
1662 *tx_todo = 0; 1667 *tx_todo = 0;
1663 while (cause_tx_done != 0) { 1668 while (cause_tx_done) {
1664 txq = mvneta_tx_done_policy(pp, cause_tx_done); 1669 txq = mvneta_tx_done_policy(pp, cause_tx_done);
1665 if (!txq)
1666 break;
1667 1670
1668 nq = netdev_get_tx_queue(pp->dev, txq->id); 1671 nq = netdev_get_tx_queue(pp->dev, txq->id);
1669 __netif_tx_lock(nq, smp_processor_id()); 1672 __netif_tx_lock(nq, smp_processor_id());