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

gianfar: Poll only active Rx queues

Split the napi budget fairly among the active queues only, instead
of dividing it by the total number of Rx queues assigned to the
given interrupt group.
Use the h/w indication field RXFi in rstat (receive status register)
to identify the active rx queues from the current interrupt group
(i.e. receive event occured on ring i, if ring i is part of the current
interrupt group). This indication field in rstat, RXFi i=0..7,
allows us to find out on which queues of the same interrupt group
do we have incomming traffic once we entered the polling routine for
the given interrupt group. After servicing the ring i, the corresponding
bit RXFi will be written with 1 to clear the active queue indication for
that ring.
Signed-off-by: default avatarClaudiu Manoil <claudiu.manoil@freescale.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c233cf40
...@@ -2835,15 +2835,20 @@ static int gfar_poll(struct napi_struct *napi, int budget) ...@@ -2835,15 +2835,20 @@ static int gfar_poll(struct napi_struct *napi, int budget)
int work_done = 0, work_done_per_q = 0; int work_done = 0, work_done_per_q = 0;
int i, budget_per_q; int i, budget_per_q;
int has_tx_work; int has_tx_work;
unsigned long serviced_queues = 0; unsigned long rstat_rxf;
int num_queues = gfargrp->num_rx_queues; int num_act_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);
rstat_rxf = gfar_read(&regs->rstat) & RSTAT_RXF_MASK;
num_act_queues = bitmap_weight(&rstat_rxf, MAX_RX_QS);
if (num_act_queues)
budget_per_q = budget/num_act_queues;
while (1) { while (1) {
has_tx_work = 0; has_tx_work = 0;
for_each_set_bit(i, &gfargrp->tx_bit_map, priv->num_tx_queues) { for_each_set_bit(i, &gfargrp->tx_bit_map, priv->num_tx_queues) {
...@@ -2856,7 +2861,8 @@ static int gfar_poll(struct napi_struct *napi, int budget) ...@@ -2856,7 +2861,8 @@ static int gfar_poll(struct napi_struct *napi, int budget)
} }
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)) /* skip queue if not active */
if (!(rstat_rxf & (RSTAT_CLEAR_RXF0 >> i)))
continue; continue;
rx_queue = priv->rx_queue[i]; rx_queue = priv->rx_queue[i];
...@@ -2866,20 +2872,24 @@ static int gfar_poll(struct napi_struct *napi, int budget) ...@@ -2866,20 +2872,24 @@ static int gfar_poll(struct napi_struct *napi, int budget)
/* finished processing this queue */ /* finished processing this queue */
if (work_done_per_q < budget_per_q) { if (work_done_per_q < budget_per_q) {
set_bit(i, &serviced_queues); /* clear active queue hw indication */
num_queues--; gfar_write(&regs->rstat,
if (!num_queues) RSTAT_CLEAR_RXF0 >> i);
rstat_rxf &= ~(RSTAT_CLEAR_RXF0 >> i);
num_act_queues--;
if (!num_act_queues)
break; break;
/* recompute budget per Rx queue */ /* recompute budget per Rx queue */
budget_per_q = budget_per_q =
(budget - work_done) / num_queues; (budget - work_done) / num_act_queues;
} }
} }
if (work_done >= budget) if (work_done >= budget)
break; break;
if (!num_queues && !has_tx_work) { if (!num_act_queues && !has_tx_work) {
napi_complete(napi); napi_complete(napi);
......
...@@ -292,6 +292,8 @@ extern const char gfar_driver_version[]; ...@@ -292,6 +292,8 @@ extern const char gfar_driver_version[];
#define RSTAT_CLEAR_RHALT 0x00800000 #define RSTAT_CLEAR_RHALT 0x00800000
#define RSTAT_CLEAR_RXF0 0x00000080
#define RSTAT_RXF_MASK 0x000000ff
#define TCTRL_IPCSEN 0x00004000 #define TCTRL_IPCSEN 0x00004000
#define TCTRL_TUCSEN 0x00002000 #define TCTRL_TUCSEN 0x00002000
......
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