Commit c233cf40 authored by Claudiu Manoil's avatar Claudiu Manoil Committed by David S. Miller

gianfar: Fix tx napi polling

There are 2 issues with the current napi poll routine, with regards
to tx ring cleanup:
1) for multi-queue devices (MQ_MG_MODE), should tx_bit_map != rx_bit_map,
which is possible (and supported in h/w) if the DT property "fsl,tx-bit-map"
holds a different value than rx_bit_map, the current polling routine will
service the wrong Tx queues in this case (i.e. the interrupt group will
receive interrupts from tx queues that it will not service)
2) Tx cleanup completion consumes napi budget, whereas the napi budget
should be reserved for Rx work only.

The patch fixes these issues and provides a clean napi polling routine.
Napi poll completion is reached when all the Rx queues have been
serviced and there is no Tx work to do.
Signed-off-by: default avatarClaudiu Manoil <claudiu.manoil@freescale.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3e5289d5
...@@ -132,7 +132,7 @@ static int gfar_poll(struct napi_struct *napi, int budget); ...@@ -132,7 +132,7 @@ static int gfar_poll(struct napi_struct *napi, int budget);
static void gfar_netpoll(struct net_device *dev); static void gfar_netpoll(struct net_device *dev);
#endif #endif
int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit); int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit);
static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue); static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue);
static void gfar_process_frame(struct net_device *dev, struct sk_buff *skb, static void gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
int amount_pull, struct napi_struct *napi); int amount_pull, struct napi_struct *napi);
void gfar_halt(struct net_device *dev); void gfar_halt(struct net_device *dev);
...@@ -2468,7 +2468,7 @@ static void gfar_align_skb(struct sk_buff *skb) ...@@ -2468,7 +2468,7 @@ static void gfar_align_skb(struct sk_buff *skb)
} }
/* Interrupt Handler for Transmit complete */ /* Interrupt Handler for Transmit complete */
static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
{ {
struct net_device *dev = tx_queue->dev; struct net_device *dev = tx_queue->dev;
struct netdev_queue *txq; struct netdev_queue *txq;
...@@ -2570,8 +2570,6 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) ...@@ -2570,8 +2570,6 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
tx_queue->dirty_tx = bdp; tx_queue->dirty_tx = bdp;
netdev_tx_completed_queue(txq, howmany, bytes_sent); netdev_tx_completed_queue(txq, howmany, bytes_sent);
return howmany;
} }
static void gfar_schedule_cleanup(struct gfar_priv_grp *gfargrp) static void gfar_schedule_cleanup(struct gfar_priv_grp *gfargrp)
...@@ -2834,47 +2832,55 @@ static int gfar_poll(struct napi_struct *napi, int budget) ...@@ -2834,47 +2832,55 @@ static int gfar_poll(struct napi_struct *napi, int budget)
struct gfar __iomem *regs = gfargrp->regs; struct gfar __iomem *regs = gfargrp->regs;
struct gfar_priv_tx_q *tx_queue = NULL; struct gfar_priv_tx_q *tx_queue = NULL;
struct gfar_priv_rx_q *rx_queue = NULL; struct gfar_priv_rx_q *rx_queue = NULL;
int rx_cleaned = 0, budget_per_queue = 0, rx_cleaned_per_queue = 0; int work_done = 0, work_done_per_q = 0;
int tx_cleaned = 0, i, left_over_budget = budget; int i, budget_per_q;
int has_tx_work;
unsigned long serviced_queues = 0; unsigned long serviced_queues = 0;
int num_queues = 0; int num_queues = gfargrp->num_rx_queues;
num_queues = gfargrp->num_rx_queues;
budget_per_queue = budget/num_queues;
budget_per_q = budget/num_queues;
/* Clear IEVENT, so interrupts aren't called again /* Clear IEVENT, so interrupts aren't called again
* because of the packets that have already arrived * because of the packets that have already arrived
*/ */
gfar_write(&regs->ievent, IEVENT_RTX_MASK); gfar_write(&regs->ievent, IEVENT_RTX_MASK);
while (num_queues && left_over_budget) { while (1) {
budget_per_queue = left_over_budget/num_queues; has_tx_work = 0;
left_over_budget = 0; for_each_set_bit(i, &gfargrp->tx_bit_map, priv->num_tx_queues) {
tx_queue = priv->tx_queue[i];
/* run Tx cleanup to completion */
if (tx_queue->tx_skbuff[tx_queue->skb_dirtytx]) {
gfar_clean_tx_ring(tx_queue);
has_tx_work = 1;
}
}
for_each_set_bit(i, &gfargrp->rx_bit_map, priv->num_rx_queues) { for_each_set_bit(i, &gfargrp->rx_bit_map, priv->num_rx_queues) {
if (test_bit(i, &serviced_queues)) if (test_bit(i, &serviced_queues))
continue; continue;
rx_queue = priv->rx_queue[i]; rx_queue = priv->rx_queue[i];
tx_queue = priv->tx_queue[rx_queue->qindex]; work_done_per_q =
gfar_clean_rx_ring(rx_queue, budget_per_q);
tx_cleaned += gfar_clean_tx_ring(tx_queue); work_done += work_done_per_q;
rx_cleaned_per_queue =
gfar_clean_rx_ring(rx_queue, budget_per_queue); /* finished processing this queue */
rx_cleaned += rx_cleaned_per_queue; if (work_done_per_q < budget_per_q) {
if (rx_cleaned_per_queue < budget_per_queue) {
left_over_budget = left_over_budget +
(budget_per_queue -
rx_cleaned_per_queue);
set_bit(i, &serviced_queues); set_bit(i, &serviced_queues);
num_queues--; num_queues--;
} if (!num_queues)
break;
/* recompute budget per Rx queue */
budget_per_q =
(budget - work_done) / num_queues;
} }
} }
if (tx_cleaned) if (work_done >= budget)
return budget; break;
if (!num_queues && !has_tx_work) {
if (rx_cleaned < budget) {
napi_complete(napi); napi_complete(napi);
/* Clear the halt bit in RSTAT */ /* Clear the halt bit in RSTAT */
...@@ -2887,9 +2893,11 @@ static int gfar_poll(struct napi_struct *napi, int budget) ...@@ -2887,9 +2893,11 @@ static int gfar_poll(struct napi_struct *napi, int budget)
*/ */
gfar_configure_coalescing(priv, gfargrp->rx_bit_map, gfar_configure_coalescing(priv, gfargrp->rx_bit_map,
gfargrp->tx_bit_map); gfargrp->tx_bit_map);
break;
}
} }
return rx_cleaned; return work_done;
} }
#ifdef CONFIG_NET_POLL_CONTROLLER #ifdef CONFIG_NET_POLL_CONTROLLER
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment