Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'gianfar-next'

Claudiu Manoil says:

====================
gianfar: Tx timeout issue

There's an older Tx timeout issue showing up on etsec2 devices
with 2 CPUs. I pinned this issue down to processing overhead
incurred by supporting multiple Tx/Rx rings, as explained in
the 2nd patch below. But before this, there's also a concurency
issue leading to Rx/Tx spurrious interrupts, addressed by the
'Tx NAPI' patch below.
The Tx timeout can be triggered with multiple Tx flows,
'iperf -c -N 8' commands, on a 2 CPUs etsec2 based (P1020) board.

Before the patches:
"""
root@p1020rdb-pc:~# iperf -c 172.16.1.3 -n 1000M -P 8 &
[...]
root@p1020rdb-pc:~# NETDEV WATCHDOG: eth1 (fsl-gianfar): transmit queue 1 timed out
WARNING: at net/sched/sch_generic.c:279
Modules linked in:
CPU: 1 PID: 0 Comm: swapper/1 Not tainted 3.13.0-rc3-03386-g89ea59c #23
task: ed84ef40 ti: ed868000 task.ti: ed868000
NIP: c04627a8 LR: c04627a8 CTR: c02fb270
REGS: ed869d00 TRAP: 0700 Not tainted (3.13.0-rc3-03386-g89ea59c)
MSR: 00029000 <CE,EE,ME> CR: 44000022 XER: 20000000
[...]

root@p1020rdb-pc:~# [ ID] Interval Transfer Bandwidth
[ 5] 0.0-19.3 sec 1000 MBytes 434 Mbits/sec
[ 8] 0.0-39.7 sec 1000 MBytes 211 Mbits/sec
[ 9] 0.0-40.1 sec 1000 MBytes 209 Mbits/sec
[ 3] 0.0-40.2 sec 1000 MBytes 209 Mbits/sec
[ 10] 0.0-59.0 sec 1000 MBytes 142 Mbits/sec
[ 7] 0.0-74.6 sec 1000 MBytes 112 Mbits/sec
[ 6] 0.0-74.7 sec 1000 MBytes 112 Mbits/sec
[ 4] 0.0-74.7 sec 1000 MBytes 112 Mbits/sec
[SUM] 0.0-74.7 sec 7.81 GBytes 898 Mbits/sec

root@p1020rdb-pc:~# ifconfig eth1
eth1 Link encap:Ethernet HWaddr 00:04:9f:00:13:01
inet addr:172.16.1.1 Bcast:172.16.255.255 Mask:255.255.0.0
inet6 addr: fe80::204:9fff:fe00:1301/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:708722 errors:0 dropped:0 overruns:0 frame:0
TX packets:8717849 errors:6 dropped:0 overruns:1470 carrier:0
collisions:0 txqueuelen:1000
RX bytes:58118018 (55.4 MiB) TX bytes:274069482 (261.3 MiB)
Base address:0xa000

"""

After applying the patches:
"""
root@p1020rdb-pc:~# iperf -c 172.16.1.3 -n 1000M -P 8 &
[...]
root@p1020rdb-pc:~# [ ID] Interval Transfer Bandwidth
[ 9] 0.0-70.5 sec 1000 MBytes 119 Mbits/sec
[ 5] 0.0-70.5 sec 1000 MBytes 119 Mbits/sec
[ 6] 0.0-70.7 sec 1000 MBytes 119 Mbits/sec
[ 4] 0.0-71.0 sec 1000 MBytes 118 Mbits/sec
[ 8] 0.0-71.1 sec 1000 MBytes 118 Mbits/sec
[ 3] 0.0-71.2 sec 1000 MBytes 118 Mbits/sec
[ 10] 0.0-71.3 sec 1000 MBytes 118 Mbits/sec
[ 7] 0.0-71.3 sec 1000 MBytes 118 Mbits/sec
[SUM] 0.0-71.3 sec 7.81 GBytes 942 Mbits/sec

root@p1020rdb-pc:~# ifconfig eth1
eth1 Link encap:Ethernet HWaddr 00:04:9f:00:13:01
inet addr:172.16.1.1 Bcast:172.16.255.255 Mask:255.255.0.0
inet6 addr: fe80::204:9fff:fe00:1301/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:728446 errors:0 dropped:0 overruns:0 frame:0
TX packets:8690057 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:59732650 (56.9 MiB) TX bytes:271554306 (258.9 MiB)
Base address:0xa000
"""
v2: PATCH 2:
Replaced CPP check with run-time condition to
limit the number of queues. Updated comments.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+232 -94
+194 -80
drivers/net/ethernet/freescale/gianfar.c
··· 128 128 static void gfar_set_multi(struct net_device *dev); 129 129 static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr); 130 130 static void gfar_configure_serdes(struct net_device *dev); 131 - static int gfar_poll(struct napi_struct *napi, int budget); 132 - static int gfar_poll_sq(struct napi_struct *napi, int budget); 131 + static int gfar_poll_rx(struct napi_struct *napi, int budget); 132 + static int gfar_poll_tx(struct napi_struct *napi, int budget); 133 + static int gfar_poll_rx_sq(struct napi_struct *napi, int budget); 134 + static int gfar_poll_tx_sq(struct napi_struct *napi, int budget); 133 135 #ifdef CONFIG_NET_POLL_CONTROLLER 134 136 static void gfar_netpoll(struct net_device *dev); 135 137 #endif ··· 363 361 if (priv->rx_filer_enable) { 364 362 rctrl |= RCTRL_FILREN; 365 363 /* Program the RIR0 reg with the required distribution */ 366 - gfar_write(&regs->rir0, DEFAULT_RIR0); 364 + if (priv->poll_mode == GFAR_SQ_POLLING) 365 + gfar_write(&regs->rir0, DEFAULT_2RXQ_RIR0); 366 + else /* GFAR_MQ_POLLING */ 367 + gfar_write(&regs->rir0, DEFAULT_8RXQ_RIR0); 367 368 } 368 369 369 370 /* Restore PROMISC mode */ ··· 619 614 { 620 615 int i; 621 616 622 - for (i = 0; i < priv->num_grps; i++) 623 - napi_disable(&priv->gfargrp[i].napi); 617 + for (i = 0; i < priv->num_grps; i++) { 618 + napi_disable(&priv->gfargrp[i].napi_rx); 619 + napi_disable(&priv->gfargrp[i].napi_tx); 620 + } 624 621 } 625 622 626 623 static void enable_napi(struct gfar_private *priv) 627 624 { 628 625 int i; 629 626 630 - for (i = 0; i < priv->num_grps; i++) 631 - napi_enable(&priv->gfargrp[i].napi); 627 + for (i = 0; i < priv->num_grps; i++) { 628 + napi_enable(&priv->gfargrp[i].napi_rx); 629 + napi_enable(&priv->gfargrp[i].napi_tx); 630 + } 632 631 } 633 632 634 633 static int gfar_parse_group(struct device_node *np, 635 634 struct gfar_private *priv, const char *model) 636 635 { 637 636 struct gfar_priv_grp *grp = &priv->gfargrp[priv->num_grps]; 638 - u32 *queue_mask; 639 637 int i; 640 638 641 639 for (i = 0; i < GFAR_NUM_IRQS; i++) { ··· 667 659 grp->priv = priv; 668 660 spin_lock_init(&grp->grplock); 669 661 if (priv->mode == MQ_MG_MODE) { 670 - queue_mask = (u32 *)of_get_property(np, "fsl,rx-bit-map", NULL); 671 - grp->rx_bit_map = queue_mask ? 672 - *queue_mask : (DEFAULT_MAPPING >> priv->num_grps); 673 - queue_mask = (u32 *)of_get_property(np, "fsl,tx-bit-map", NULL); 674 - grp->tx_bit_map = queue_mask ? 675 - *queue_mask : (DEFAULT_MAPPING >> priv->num_grps); 662 + u32 *rxq_mask, *txq_mask; 663 + rxq_mask = (u32 *)of_get_property(np, "fsl,rx-bit-map", NULL); 664 + txq_mask = (u32 *)of_get_property(np, "fsl,tx-bit-map", NULL); 665 + 666 + if (priv->poll_mode == GFAR_SQ_POLLING) { 667 + /* One Q per interrupt group: Q0 to G0, Q1 to G1 */ 668 + grp->rx_bit_map = (DEFAULT_MAPPING >> priv->num_grps); 669 + grp->tx_bit_map = (DEFAULT_MAPPING >> priv->num_grps); 670 + } else { /* GFAR_MQ_POLLING */ 671 + grp->rx_bit_map = rxq_mask ? 672 + *rxq_mask : (DEFAULT_MAPPING >> priv->num_grps); 673 + grp->tx_bit_map = txq_mask ? 674 + *txq_mask : (DEFAULT_MAPPING >> priv->num_grps); 675 + } 676 676 } else { 677 677 grp->rx_bit_map = 0xFF; 678 678 grp->tx_bit_map = 0xFF; ··· 696 680 * also assign queues to groups 697 681 */ 698 682 for_each_set_bit(i, &grp->rx_bit_map, priv->num_rx_queues) { 683 + if (!grp->rx_queue) 684 + grp->rx_queue = priv->rx_queue[i]; 699 685 grp->num_rx_queues++; 700 686 grp->rstat |= (RSTAT_CLEAR_RHALT >> i); 701 687 priv->rqueue |= ((RQUEUE_EN0 | RQUEUE_EX0) >> i); ··· 705 687 } 706 688 707 689 for_each_set_bit(i, &grp->tx_bit_map, priv->num_tx_queues) { 690 + if (!grp->tx_queue) 691 + grp->tx_queue = priv->tx_queue[i]; 708 692 grp->num_tx_queues++; 709 693 grp->tstat |= (TSTAT_CLEAR_THALT >> i); 710 694 priv->tqueue |= (TQUEUE_EN0 >> i); ··· 737 717 if (!np || !of_device_is_available(np)) 738 718 return -ENODEV; 739 719 740 - /* parse the num of tx and rx queues */ 720 + /* parse the num of HW tx and rx queues */ 741 721 tx_queues = (u32 *)of_get_property(np, "fsl,num_tx_queues", NULL); 742 - num_tx_qs = tx_queues ? *tx_queues : 1; 722 + rx_queues = (u32 *)of_get_property(np, "fsl,num_rx_queues", NULL); 723 + 724 + if (priv->mode == SQ_SG_MODE) { 725 + num_tx_qs = 1; 726 + num_rx_qs = 1; 727 + } else { /* MQ_MG_MODE */ 728 + if (priv->poll_mode == GFAR_SQ_POLLING) { 729 + num_tx_qs = 2; /* one q per int group */ 730 + num_rx_qs = 2; /* one q per int group */ 731 + } else { /* GFAR_MQ_POLLING */ 732 + num_tx_qs = tx_queues ? *tx_queues : 1; 733 + num_rx_qs = rx_queues ? *rx_queues : 1; 734 + } 735 + } 743 736 744 737 if (num_tx_qs > MAX_TX_QS) { 745 738 pr_err("num_tx_qs(=%d) greater than MAX_TX_QS(=%d)\n", ··· 760 727 pr_err("Cannot do alloc_etherdev, aborting\n"); 761 728 return -EINVAL; 762 729 } 763 - 764 - rx_queues = (u32 *)of_get_property(np, "fsl,num_rx_queues", NULL); 765 - num_rx_qs = rx_queues ? *rx_queues : 1; 766 730 767 731 if (num_rx_qs > MAX_RX_QS) { 768 732 pr_err("num_rx_qs(=%d) greater than MAX_RX_QS(=%d)\n", ··· 801 771 /* Parse and initialize group specific information */ 802 772 if (of_device_is_compatible(np, "fsl,etsec2")) { 803 773 priv->mode = MQ_MG_MODE; 774 + priv->poll_mode = GFAR_SQ_POLLING; 804 775 for_each_child_of_node(np, child) { 805 776 err = gfar_parse_group(child, priv, model); 806 777 if (err) ··· 809 778 } 810 779 } else { 811 780 priv->mode = SQ_SG_MODE; 781 + priv->poll_mode = GFAR_SQ_POLLING; 812 782 err = gfar_parse_group(np, priv, model); 813 783 if (err) 814 784 goto err_grp_init; ··· 1289 1257 dev->ethtool_ops = &gfar_ethtool_ops; 1290 1258 1291 1259 /* Register for napi ...We are registering NAPI for each grp */ 1292 - if (priv->mode == SQ_SG_MODE) 1293 - netif_napi_add(dev, &priv->gfargrp[0].napi, gfar_poll_sq, 1294 - GFAR_DEV_WEIGHT); 1295 - else 1296 - for (i = 0; i < priv->num_grps; i++) 1297 - netif_napi_add(dev, &priv->gfargrp[i].napi, gfar_poll, 1298 - GFAR_DEV_WEIGHT); 1260 + for (i = 0; i < priv->num_grps; i++) { 1261 + if (priv->poll_mode == GFAR_SQ_POLLING) { 1262 + netif_napi_add(dev, &priv->gfargrp[i].napi_rx, 1263 + gfar_poll_rx_sq, GFAR_DEV_WEIGHT); 1264 + netif_napi_add(dev, &priv->gfargrp[i].napi_tx, 1265 + gfar_poll_tx_sq, 2); 1266 + } else { 1267 + netif_napi_add(dev, &priv->gfargrp[i].napi_rx, 1268 + gfar_poll_rx, GFAR_DEV_WEIGHT); 1269 + netif_napi_add(dev, &priv->gfargrp[i].napi_tx, 1270 + gfar_poll_tx, 2); 1271 + } 1272 + } 1299 1273 1300 1274 if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) { 1301 1275 dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG | ··· 2576 2538 netdev_tx_completed_queue(txq, howmany, bytes_sent); 2577 2539 } 2578 2540 2579 - static void gfar_schedule_cleanup(struct gfar_priv_grp *gfargrp) 2580 - { 2581 - unsigned long flags; 2582 - 2583 - spin_lock_irqsave(&gfargrp->grplock, flags); 2584 - if (napi_schedule_prep(&gfargrp->napi)) { 2585 - gfar_write(&gfargrp->regs->imask, IMASK_RTX_DISABLED); 2586 - __napi_schedule(&gfargrp->napi); 2587 - } else { 2588 - /* Clear IEVENT, so interrupts aren't called again 2589 - * because of the packets that have already arrived. 2590 - */ 2591 - gfar_write(&gfargrp->regs->ievent, IEVENT_RTX_MASK); 2592 - } 2593 - spin_unlock_irqrestore(&gfargrp->grplock, flags); 2594 - 2595 - } 2596 - 2597 - /* Interrupt Handler for Transmit complete */ 2598 - static irqreturn_t gfar_transmit(int irq, void *grp_id) 2599 - { 2600 - gfar_schedule_cleanup((struct gfar_priv_grp *)grp_id); 2601 - return IRQ_HANDLED; 2602 - } 2603 - 2604 2541 static void gfar_new_rxbdp(struct gfar_priv_rx_q *rx_queue, struct rxbd8 *bdp, 2605 2542 struct sk_buff *skb) 2606 2543 { ··· 2646 2633 2647 2634 irqreturn_t gfar_receive(int irq, void *grp_id) 2648 2635 { 2649 - gfar_schedule_cleanup((struct gfar_priv_grp *)grp_id); 2636 + struct gfar_priv_grp *grp = (struct gfar_priv_grp *)grp_id; 2637 + unsigned long flags; 2638 + u32 imask; 2639 + 2640 + if (likely(napi_schedule_prep(&grp->napi_rx))) { 2641 + spin_lock_irqsave(&grp->grplock, flags); 2642 + imask = gfar_read(&grp->regs->imask); 2643 + imask &= IMASK_RX_DISABLED; 2644 + gfar_write(&grp->regs->imask, imask); 2645 + spin_unlock_irqrestore(&grp->grplock, flags); 2646 + __napi_schedule(&grp->napi_rx); 2647 + } else { 2648 + /* Clear IEVENT, so interrupts aren't called again 2649 + * because of the packets that have already arrived. 2650 + */ 2651 + gfar_write(&grp->regs->ievent, IEVENT_RX_MASK); 2652 + } 2653 + 2654 + return IRQ_HANDLED; 2655 + } 2656 + 2657 + /* Interrupt Handler for Transmit complete */ 2658 + static irqreturn_t gfar_transmit(int irq, void *grp_id) 2659 + { 2660 + struct gfar_priv_grp *grp = (struct gfar_priv_grp *)grp_id; 2661 + unsigned long flags; 2662 + u32 imask; 2663 + 2664 + if (likely(napi_schedule_prep(&grp->napi_tx))) { 2665 + spin_lock_irqsave(&grp->grplock, flags); 2666 + imask = gfar_read(&grp->regs->imask); 2667 + imask &= IMASK_TX_DISABLED; 2668 + gfar_write(&grp->regs->imask, imask); 2669 + spin_unlock_irqrestore(&grp->grplock, flags); 2670 + __napi_schedule(&grp->napi_tx); 2671 + } else { 2672 + /* Clear IEVENT, so interrupts aren't called again 2673 + * because of the packets that have already arrived. 2674 + */ 2675 + gfar_write(&grp->regs->ievent, IEVENT_TX_MASK); 2676 + } 2677 + 2650 2678 return IRQ_HANDLED; 2651 2679 } 2652 2680 ··· 2811 2757 rx_queue->stats.rx_bytes += pkt_len; 2812 2758 skb_record_rx_queue(skb, rx_queue->qindex); 2813 2759 gfar_process_frame(dev, skb, amount_pull, 2814 - &rx_queue->grp->napi); 2760 + &rx_queue->grp->napi_rx); 2815 2761 2816 2762 } else { 2817 2763 netif_warn(priv, rx_err, dev, "Missing skb!\n"); ··· 2840 2786 return howmany; 2841 2787 } 2842 2788 2843 - static int gfar_poll_sq(struct napi_struct *napi, int budget) 2789 + static int gfar_poll_rx_sq(struct napi_struct *napi, int budget) 2844 2790 { 2845 2791 struct gfar_priv_grp *gfargrp = 2846 - container_of(napi, struct gfar_priv_grp, napi); 2792 + container_of(napi, struct gfar_priv_grp, napi_rx); 2847 2793 struct gfar __iomem *regs = gfargrp->regs; 2848 - struct gfar_priv_tx_q *tx_queue = gfargrp->priv->tx_queue[0]; 2849 - struct gfar_priv_rx_q *rx_queue = gfargrp->priv->rx_queue[0]; 2794 + struct gfar_priv_rx_q *rx_queue = gfargrp->rx_queue; 2850 2795 int work_done = 0; 2851 2796 2852 2797 /* Clear IEVENT, so interrupts aren't called again 2853 2798 * because of the packets that have already arrived 2854 2799 */ 2855 - gfar_write(&regs->ievent, IEVENT_RTX_MASK); 2856 - 2857 - /* run Tx cleanup to completion */ 2858 - if (tx_queue->tx_skbuff[tx_queue->skb_dirtytx]) 2859 - gfar_clean_tx_ring(tx_queue); 2800 + gfar_write(&regs->ievent, IEVENT_RX_MASK); 2860 2801 2861 2802 work_done = gfar_clean_rx_ring(rx_queue, budget); 2862 2803 2863 2804 if (work_done < budget) { 2805 + u32 imask; 2864 2806 napi_complete(napi); 2865 2807 /* Clear the halt bit in RSTAT */ 2866 2808 gfar_write(&regs->rstat, gfargrp->rstat); 2867 2809 2868 - gfar_write(&regs->imask, IMASK_DEFAULT); 2810 + spin_lock_irq(&gfargrp->grplock); 2811 + imask = gfar_read(&regs->imask); 2812 + imask |= IMASK_RX_DEFAULT; 2813 + gfar_write(&regs->imask, imask); 2814 + spin_unlock_irq(&gfargrp->grplock); 2869 2815 } 2870 2816 2871 2817 return work_done; 2872 2818 } 2873 2819 2874 - static int gfar_poll(struct napi_struct *napi, int budget) 2820 + static int gfar_poll_tx_sq(struct napi_struct *napi, int budget) 2875 2821 { 2876 2822 struct gfar_priv_grp *gfargrp = 2877 - container_of(napi, struct gfar_priv_grp, napi); 2823 + container_of(napi, struct gfar_priv_grp, napi_tx); 2824 + struct gfar __iomem *regs = gfargrp->regs; 2825 + struct gfar_priv_tx_q *tx_queue = gfargrp->tx_queue; 2826 + u32 imask; 2827 + 2828 + /* Clear IEVENT, so interrupts aren't called again 2829 + * because of the packets that have already arrived 2830 + */ 2831 + gfar_write(&regs->ievent, IEVENT_TX_MASK); 2832 + 2833 + /* run Tx cleanup to completion */ 2834 + if (tx_queue->tx_skbuff[tx_queue->skb_dirtytx]) 2835 + gfar_clean_tx_ring(tx_queue); 2836 + 2837 + napi_complete(napi); 2838 + 2839 + spin_lock_irq(&gfargrp->grplock); 2840 + imask = gfar_read(&regs->imask); 2841 + imask |= IMASK_TX_DEFAULT; 2842 + gfar_write(&regs->imask, imask); 2843 + spin_unlock_irq(&gfargrp->grplock); 2844 + 2845 + return 0; 2846 + } 2847 + 2848 + static int gfar_poll_rx(struct napi_struct *napi, int budget) 2849 + { 2850 + struct gfar_priv_grp *gfargrp = 2851 + container_of(napi, struct gfar_priv_grp, napi_rx); 2878 2852 struct gfar_private *priv = gfargrp->priv; 2879 2853 struct gfar __iomem *regs = gfargrp->regs; 2880 - struct gfar_priv_tx_q *tx_queue = NULL; 2881 2854 struct gfar_priv_rx_q *rx_queue = NULL; 2882 2855 int work_done = 0, work_done_per_q = 0; 2883 2856 int i, budget_per_q = 0; 2884 - int has_tx_work = 0; 2885 2857 unsigned long rstat_rxf; 2886 2858 int num_act_queues; 2887 2859 2888 2860 /* Clear IEVENT, so interrupts aren't called again 2889 2861 * because of the packets that have already arrived 2890 2862 */ 2891 - gfar_write(&regs->ievent, IEVENT_RTX_MASK); 2863 + gfar_write(&regs->ievent, IEVENT_RX_MASK); 2892 2864 2893 2865 rstat_rxf = gfar_read(&regs->rstat) & RSTAT_RXF_MASK; 2894 2866 2895 2867 num_act_queues = bitmap_weight(&rstat_rxf, MAX_RX_QS); 2896 2868 if (num_act_queues) 2897 2869 budget_per_q = budget/num_act_queues; 2898 - 2899 - for_each_set_bit(i, &gfargrp->tx_bit_map, priv->num_tx_queues) { 2900 - tx_queue = priv->tx_queue[i]; 2901 - /* run Tx cleanup to completion */ 2902 - if (tx_queue->tx_skbuff[tx_queue->skb_dirtytx]) { 2903 - gfar_clean_tx_ring(tx_queue); 2904 - has_tx_work = 1; 2905 - } 2906 - } 2907 2870 2908 2871 for_each_set_bit(i, &gfargrp->rx_bit_map, priv->num_rx_queues) { 2909 2872 /* skip queue if not active */ ··· 2944 2873 } 2945 2874 } 2946 2875 2947 - if (!num_act_queues && !has_tx_work) { 2948 - 2876 + if (!num_act_queues) { 2877 + u32 imask; 2949 2878 napi_complete(napi); 2950 2879 2951 2880 /* Clear the halt bit in RSTAT */ 2952 2881 gfar_write(&regs->rstat, gfargrp->rstat); 2953 2882 2954 - gfar_write(&regs->imask, IMASK_DEFAULT); 2883 + spin_lock_irq(&gfargrp->grplock); 2884 + imask = gfar_read(&regs->imask); 2885 + imask |= IMASK_RX_DEFAULT; 2886 + gfar_write(&regs->imask, imask); 2887 + spin_unlock_irq(&gfargrp->grplock); 2955 2888 } 2956 2889 2957 2890 return work_done; 2958 2891 } 2892 + 2893 + static int gfar_poll_tx(struct napi_struct *napi, int budget) 2894 + { 2895 + struct gfar_priv_grp *gfargrp = 2896 + container_of(napi, struct gfar_priv_grp, napi_tx); 2897 + struct gfar_private *priv = gfargrp->priv; 2898 + struct gfar __iomem *regs = gfargrp->regs; 2899 + struct gfar_priv_tx_q *tx_queue = NULL; 2900 + int has_tx_work = 0; 2901 + int i; 2902 + 2903 + /* Clear IEVENT, so interrupts aren't called again 2904 + * because of the packets that have already arrived 2905 + */ 2906 + gfar_write(&regs->ievent, IEVENT_TX_MASK); 2907 + 2908 + for_each_set_bit(i, &gfargrp->tx_bit_map, priv->num_tx_queues) { 2909 + tx_queue = priv->tx_queue[i]; 2910 + /* run Tx cleanup to completion */ 2911 + if (tx_queue->tx_skbuff[tx_queue->skb_dirtytx]) { 2912 + gfar_clean_tx_ring(tx_queue); 2913 + has_tx_work = 1; 2914 + } 2915 + } 2916 + 2917 + if (!has_tx_work) { 2918 + u32 imask; 2919 + napi_complete(napi); 2920 + 2921 + spin_lock_irq(&gfargrp->grplock); 2922 + imask = gfar_read(&regs->imask); 2923 + imask |= IMASK_TX_DEFAULT; 2924 + gfar_write(&regs->imask, imask); 2925 + spin_unlock_irq(&gfargrp->grplock); 2926 + } 2927 + 2928 + return 0; 2929 + } 2930 + 2959 2931 2960 2932 #ifdef CONFIG_NET_POLL_CONTROLLER 2961 2933 /* Polling 'interrupt' - used by things like netconsole to send skbs
+38 -14
drivers/net/ethernet/freescale/gianfar.h
··· 377 377 IMASK_RXFEN0 | IMASK_BSY | IMASK_EBERR | IMASK_BABR | \ 378 378 IMASK_XFUN | IMASK_RXC | IMASK_BABT | IMASK_DPE \ 379 379 | IMASK_PERR) 380 - #define IMASK_RTX_DISABLED ((~(IMASK_RXFEN0 | IMASK_TXFEN | IMASK_BSY)) \ 381 - & IMASK_DEFAULT) 380 + #define IMASK_RX_DEFAULT (IMASK_RXFEN0 | IMASK_BSY) 381 + #define IMASK_TX_DEFAULT (IMASK_TXFEN | IMASK_TXBEN) 382 + 383 + #define IMASK_RX_DISABLED ((~(IMASK_RX_DEFAULT)) & IMASK_DEFAULT) 384 + #define IMASK_TX_DISABLED ((~(IMASK_TX_DEFAULT)) & IMASK_DEFAULT) 382 385 383 386 /* Fifo management */ 384 387 #define FIFO_TX_THR_MASK 0x01ff ··· 412 409 413 410 /* This default RIR value directly corresponds 414 411 * to the 3-bit hash value generated */ 415 - #define DEFAULT_RIR0 0x05397700 412 + #define DEFAULT_8RXQ_RIR0 0x05397700 413 + /* Map even hash values to Q0, and odd ones to Q1 */ 414 + #define DEFAULT_2RXQ_RIR0 0x04104100 416 415 417 416 /* RQFCR register bits */ 418 417 #define RQFCR_GPI 0x80000000 ··· 909 904 MQ_MG_MODE 910 905 }; 911 906 907 + /* GFAR_SQ_POLLING: Single Queue NAPI polling mode 908 + * The driver supports a single pair of RX/Tx queues 909 + * per interrupt group (Rx/Tx int line). MQ_MG mode 910 + * devices have 2 interrupt groups, so the device will 911 + * have a total of 2 Tx and 2 Rx queues in this case. 912 + * GFAR_MQ_POLLING: Multi Queue NAPI polling mode 913 + * The driver supports all the 8 Rx and Tx HW queues 914 + * each queue mapped by the Device Tree to one of 915 + * the 2 interrupt groups. This mode implies significant 916 + * processing overhead (CPU and controller level). 917 + */ 918 + enum gfar_poll_mode { 919 + GFAR_SQ_POLLING = 0, 920 + GFAR_MQ_POLLING 921 + }; 922 + 912 923 /* 913 924 * Per TX queue stats 914 925 */ ··· 1034 1013 */ 1035 1014 1036 1015 struct gfar_priv_grp { 1037 - spinlock_t grplock __attribute__ ((aligned (SMP_CACHE_BYTES))); 1038 - struct napi_struct napi; 1039 - struct gfar_private *priv; 1016 + spinlock_t grplock __aligned(SMP_CACHE_BYTES); 1017 + struct napi_struct napi_rx; 1018 + struct napi_struct napi_tx; 1040 1019 struct gfar __iomem *regs; 1041 - unsigned int rstat; 1042 - unsigned long num_rx_queues; 1043 - unsigned long rx_bit_map; 1044 - /* cacheline 3 */ 1020 + struct gfar_priv_tx_q *tx_queue; 1021 + struct gfar_priv_rx_q *rx_queue; 1045 1022 unsigned int tstat; 1023 + unsigned int rstat; 1024 + 1025 + struct gfar_private *priv; 1046 1026 unsigned long num_tx_queues; 1047 1027 unsigned long tx_bit_map; 1028 + unsigned long num_rx_queues; 1029 + unsigned long rx_bit_map; 1048 1030 1049 1031 struct gfar_irqinfo *irqinfo[GFAR_NUM_IRQS]; 1050 1032 }; ··· 1077 1053 * the buffer descriptor determines the actual condition. 1078 1054 */ 1079 1055 struct gfar_private { 1080 - unsigned int num_rx_queues; 1081 - 1082 1056 struct device *dev; 1083 1057 struct net_device *ndev; 1084 1058 enum gfar_errata errata; ··· 1084 1062 1085 1063 u16 uses_rxfcb; 1086 1064 u16 padding; 1065 + u32 device_flags; 1087 1066 1088 1067 /* HW time stamping enabled flag */ 1089 1068 int hwts_rx_en; ··· 1095 1072 struct gfar_priv_grp gfargrp[MAXGROUPS]; 1096 1073 1097 1074 unsigned long state; 1098 - u32 device_flags; 1099 1075 1100 - unsigned int mode; 1076 + unsigned short mode; 1077 + unsigned short poll_mode; 1101 1078 unsigned int num_tx_queues; 1079 + unsigned int num_rx_queues; 1102 1080 unsigned int num_grps; 1103 1081 1104 1082 /* Network Statistics */