1 --- a/drivers/net/ethernet/freescale/gianfar.c
2 +++ b/drivers/net/ethernet/freescale/gianfar.c
3 @@ -132,7 +132,7 @@ static int gfar_poll(struct napi_struct
4 static void gfar_netpoll(struct net_device *dev);
6 int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit);
7 -static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue);
8 +static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue);
9 static void gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
10 int amount_pull, struct napi_struct *napi);
11 void gfar_halt(struct net_device *dev);
12 @@ -2475,7 +2475,7 @@ static void gfar_align_skb(struct sk_buf
15 /* Interrupt Handler for Transmit complete */
16 -static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
17 +static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
19 struct net_device *dev = tx_queue->dev;
20 struct netdev_queue *txq;
21 @@ -2575,6 +2575,8 @@ static void gfar_clean_tx_ring(struct gf
22 tx_queue->dirty_tx = bdp;
24 netdev_tx_completed_queue(txq, howmany, bytes_sent);
29 static void gfar_schedule_cleanup(struct gfar_priv_grp *gfargrp)
30 @@ -2833,82 +2835,62 @@ static int gfar_poll(struct napi_struct
31 struct gfar __iomem *regs = gfargrp->regs;
32 struct gfar_priv_tx_q *tx_queue = NULL;
33 struct gfar_priv_rx_q *rx_queue = NULL;
34 - int work_done = 0, work_done_per_q = 0;
35 - int i, budget_per_q = 0;
37 - unsigned long rstat_rxf;
39 + int rx_cleaned = 0, budget_per_queue = 0, rx_cleaned_per_queue = 0;
40 + int tx_cleaned = 0, i, left_over_budget = budget;
41 + unsigned long serviced_queues = 0;
44 + num_queues = gfargrp->num_rx_queues;
45 + budget_per_queue = budget/num_queues;
47 /* Clear IEVENT, so interrupts aren't called again
48 * because of the packets that have already arrived
50 gfar_write(®s->ievent, IEVENT_RTX_MASK);
52 - rstat_rxf = gfar_read(®s->rstat) & RSTAT_RXF_MASK;
54 - num_act_queues = bitmap_weight(&rstat_rxf, MAX_RX_QS);
56 - budget_per_q = budget/num_act_queues;
60 - for_each_set_bit(i, &gfargrp->tx_bit_map, priv->num_tx_queues) {
61 - tx_queue = priv->tx_queue[i];
62 - /* run Tx cleanup to completion */
63 - if (tx_queue->tx_skbuff[tx_queue->skb_dirtytx]) {
64 - gfar_clean_tx_ring(tx_queue);
68 + while (num_queues && left_over_budget) {
69 + budget_per_queue = left_over_budget/num_queues;
70 + left_over_budget = 0;
72 for_each_set_bit(i, &gfargrp->rx_bit_map, priv->num_rx_queues) {
73 - /* skip queue if not active */
74 - if (!(rstat_rxf & (RSTAT_CLEAR_RXF0 >> i)))
75 + if (test_bit(i, &serviced_queues))
78 rx_queue = priv->rx_queue[i];
80 - gfar_clean_rx_ring(rx_queue, budget_per_q);
81 - work_done += work_done_per_q;
83 - /* finished processing this queue */
84 - if (work_done_per_q < budget_per_q) {
85 - /* clear active queue hw indication */
86 - gfar_write(®s->rstat,
87 - RSTAT_CLEAR_RXF0 >> i);
88 - rstat_rxf &= ~(RSTAT_CLEAR_RXF0 >> i);
91 - if (!num_act_queues)
93 - /* recompute budget per Rx queue */
95 - (budget - work_done) / num_act_queues;
96 + tx_queue = priv->tx_queue[rx_queue->qindex];
98 + tx_cleaned += gfar_clean_tx_ring(tx_queue);
99 + rx_cleaned_per_queue =
100 + gfar_clean_rx_ring(rx_queue, budget_per_queue);
101 + rx_cleaned += rx_cleaned_per_queue;
102 + if (rx_cleaned_per_queue < budget_per_queue) {
103 + left_over_budget = left_over_budget +
104 + (budget_per_queue -
105 + rx_cleaned_per_queue);
106 + set_bit(i, &serviced_queues);
112 - if (work_done >= budget)
115 - if (!num_act_queues && !has_tx_work) {
119 - napi_complete(napi);
120 + if (rx_cleaned < budget) {
121 + napi_complete(napi);
123 - /* Clear the halt bit in RSTAT */
124 - gfar_write(®s->rstat, gfargrp->rstat);
125 + /* Clear the halt bit in RSTAT */
126 + gfar_write(®s->rstat, gfargrp->rstat);
128 - gfar_write(®s->imask, IMASK_DEFAULT);
129 + gfar_write(®s->imask, IMASK_DEFAULT);
131 - /* If we are coalescing interrupts, update the timer
132 - * Otherwise, clear it
134 - gfar_configure_coalescing(priv, gfargrp->rx_bit_map,
135 - gfargrp->tx_bit_map);
138 + /* If we are coalescing interrupts, update the timer
139 + * Otherwise, clear it
141 + gfar_configure_coalescing(priv, gfargrp->rx_bit_map,
142 + gfargrp->tx_bit_map);
149 #ifdef CONFIG_NET_POLL_CONTROLLER
150 --- a/drivers/net/ethernet/freescale/gianfar.h
151 +++ b/drivers/net/ethernet/freescale/gianfar.h
152 @@ -291,9 +291,7 @@ extern const char gfar_driver_version[];
153 #define RCTRL_PADDING(x) ((x << 16) & RCTRL_PAL_MASK)
156 -#define RSTAT_CLEAR_RHALT 0x00800000
157 -#define RSTAT_CLEAR_RXF0 0x00000080
158 -#define RSTAT_RXF_MASK 0x000000ff
159 +#define RSTAT_CLEAR_RHALT 0x00800000
161 #define TCTRL_IPCSEN 0x00004000
162 #define TCTRL_TUCSEN 0x00002000