1. 16 7月, 2015 2 次提交
    • C
      gianfar: Fix and cleanup rxbd status handling · f966082e
      Claudiu Manoil 提交于
      There are several (long standing) problems about how the status
      field of the rx buffer descriptor (rxbd) is currently handled on
      the error path:
      - too many unnecessary 16bit reads of the two halves of the rxbd
      status field (32bit), also resulting in overuse of endianness
      convesion macros;
      - "bdp->status = RXBD_LARGE" makes no sense, since the "large"
      flag is read only (only eTSEC can write it), and trying to clear
      the other status bits is also error prone in this context
      (most of the rx status bits are read only anyway).
      
      This is fixed with a single 32bit read of the "status" field,
      and then the appropriate 16bit shifting is applied to access
      the various status bits or the rx frame length. Also corrected
      the use of the RXBD_LARGE flag.
      
      Additional fix:
      "rx_over_errors" stat is incremented instead of "rx_crc_errors"
      in case of RXBD_OVERRUN occurrence.
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f966082e
    • C
      gianfar: Bundle Rx allocation, cleanup · 76f31e8b
      Claudiu Manoil 提交于
      Use a more common consumer/ producer index design to improve
      rx buffer allocation.  Instead of allocating a single new buffer
      (skb) on each iteration, bundle the allocation of several rx
      buffers at a time.  This also opens the path for further memory
      optimizations.
      
      Remove useless check of rxq->rfbptr, since this patch touches
      rx pause frame handling code as well.  rxq->rfbptr is always
      initialized as part of Rx BD ring init.
      Remove redundant (and misleading) 'amount_pull' parameter.
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      76f31e8b
  2. 10 5月, 2015 2 次提交
    • C
      gianfar: Enable changing mac addr when if up · 3d23a05c
      Claudiu Manoil 提交于
      Use device flag IFF_LIVE_ADDR_CHANGE to signal that
      the device supports changing the hardware address when
      the device is running.
      This allows eth_mac_addr() to change the mac address
      also when the network device's interface is open.
      This capability is required by certain applications,
      like bonding mode 6 (Adaptive Load Balancing).
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3d23a05c
    • C
      gianfar: Move TxFIFO underrun handling to reset path · bc602280
      Claudiu Manoil 提交于
      Handle TxFIFO underrun exceptions outside the fast path.
      A controller reset is more reliable in this exceptional
      case, as opposed to re-enabling on-the-fly the Tx DMA.
      
      As the controller reset is handled outside the fast path
      by the reset_gfar() workqueue handler, the locking
      scheme on the Tx path is significantly simplified.
      Because the Tx processing (xmit queues and tx napi) is
      disabled during controller reset, tstat access from xmit
      does not require locking.  So the scope of the txlock on
      the processing path is now reduced to num_txbdfree, which
      is shared only between process context (xmit) and softirq
      (clean_tx_ring).  As a result, the txlock must not guard
      against interrupt context, and the spin_lock_irqsave()
      from xmit can be replaced by spin_lock_bh().  Likewise,
      the locking has been downgraded for clean_tx_ring().
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      bc602280
  3. 18 3月, 2015 1 次提交
  4. 16 3月, 2015 3 次提交
  5. 06 3月, 2015 1 次提交
  6. 04 3月, 2015 1 次提交
    • G
      gianfar: Reduce logging noise seen due to phy polling if link is down · 0ae93b2c
      Guenter Roeck 提交于
      Commit 6ce29b0e ("gianfar: Avoid unnecessary reg accesses in adjust_link()")
      eliminates unnecessary calls to adjust_link for phy devices which don't support
      interrupts and need polling. As part of that work, the 'new_state' local flag,
      which was used to reduce logging noise on the console, was eliminated.
      
      Unfortunately, that means that a 'Link is Down' log message will now be
      issued continuously if a link is configured as UP, the link state is down,
      and the associated phy requires polling. This occurs because priv->oldduplex
      is -1 in this case, which always differs from phydev->duplex. In addition,
      phydev->speed may also differ from priv->oldspeed.  gfar_update_link_state()
      is therefore called each time a phy is polled, even if the link state did not
      change.
      
      Cc: Claudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Reviewed-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0ae93b2c
  7. 30 1月, 2015 1 次提交
  8. 14 1月, 2015 1 次提交
  9. 31 12月, 2014 2 次提交
    • K
      net: gianfar: add missing __iomem annotation · 03366a33
      Kevin Hao 提交于
      Fix the following spare warning:
      drivers/net/ethernet/freescale/gianfar.c:3521:60: warning: incorrect type in argument 1 (different address spaces)
      drivers/net/ethernet/freescale/gianfar.c:3521:60:    expected unsigned int [noderef] <asn:2>*addr
      drivers/net/ethernet/freescale/gianfar.c:3521:60:    got unsigned int [usertype] *rfbptr
      drivers/net/ethernet/freescale/gianfar.c:205:16: warning: incorrect type in assignment (different address spaces)
      drivers/net/ethernet/freescale/gianfar.c:205:16:    expected unsigned int [usertype] *rfbptr
      drivers/net/ethernet/freescale/gianfar.c:205:16:    got unsigned int [noderef] <asn:2>*<noident>
      drivers/net/ethernet/freescale/gianfar.c:2918:44: warning: incorrect type in argument 1 (different address spaces)
      drivers/net/ethernet/freescale/gianfar.c:2918:44:    expected unsigned int [noderef] <asn:2>*addr
      drivers/net/ethernet/freescale/gianfar.c:2918:44:    got unsigned int [usertype] *rfbptr
      Signed-off-by: NKevin Hao <haokexin@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      03366a33
    • K
      net: gianfar: mark the local functions static · 91c53f76
      Kevin Hao 提交于
      Signed-off-by: NKevin Hao <haokexin@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      91c53f76
  10. 12 12月, 2014 1 次提交
    • K
      gianfar: Fix dma check map error when DMA_API_DEBUG is enabled · 0a4b5a24
      Kevin Hao 提交于
      We need to use dma_mapping_error() to check the dma address returned
      by dma_map_single/page(). Otherwise we would get warning like this:
        WARNING: at lib/dma-debug.c:1140
        Modules linked in:
        CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.18.0-rc2-next-20141029 #196
        task: c0834300 ti: effe6000 task.ti: c0874000
        NIP: c02b2c98 LR: c02b2c98 CTR: c030abc4
        REGS: effe7d70 TRAP: 0700   Not tainted  (3.18.0-rc2-next-20141029)
        MSR: 00021000 <CE,ME>  CR: 22044022  XER: 20000000
      
        GPR00: c02b2c98 effe7e20 c0834300 00000098 00021000 00000000 c030b898 00000003
        GPR08: 00000001 00000000 00000001 749eec9d 22044022 1001abe0 00000020 ef278678
        GPR16: ef278670 ef278668 ef278660 070a8040 c087f99c c08cdc60 00029000 c0840d44
        GPR24: c08be6e8 c0840000 effe7e78 ef041340 00000600 ef114e10 00000000 c08be6e0
        NIP [c02b2c98] check_unmap+0x51c/0x9e4
        LR [c02b2c98] check_unmap+0x51c/0x9e4
        Call Trace:
        [effe7e20] [c02b2c98] check_unmap+0x51c/0x9e4 (unreliable)
        [effe7e70] [c02b31d8] debug_dma_unmap_page+0x78/0x8c
        [effe7ed0] [c03d1640] gfar_clean_rx_ring+0x208/0x488
        [effe7f40] [c03d1a9c] gfar_poll_rx_sq+0x3c/0xa8
        [effe7f60] [c04f8714] net_rx_action+0xc0/0x178
        [effe7f90] [c00435a0] __do_softirq+0x100/0x1fc
        [effe7fe0] [c0043958] irq_exit+0xa4/0xc8
        [effe7ff0] [c000d14c] call_do_irq+0x24/0x3c
        [c0875e90] [c00048a0] do_IRQ+0x8c/0xf8
        [c0875eb0] [c000ed10] ret_from_except+0x0/0x18
      
      For TX, we need to unmap the pages which has already been mapped and
      free the skb before return.
      
      For RX, move the dma mapping and error check to gfar_new_skb(). We
      would reuse the original skb in the rx ring when either allocating
      skb failure or dma mapping error.
      Signed-off-by: NKevin Hao <haokexin@gmail.com>
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Reviewed-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0a4b5a24
  11. 30 10月, 2014 3 次提交
  12. 20 10月, 2014 1 次提交
  13. 16 10月, 2014 1 次提交
    • C
      gianfar: Add FCS to rx buffer size (fix) · f5b720b8
      Claudiu Manoil 提交于
      For each Rx frame the eTSEC writes its FCS (Frame Check Sequence)
      to the Rx buffer.
      
      The eTSEC h/w manual states in the "Receive Buffer Descriptor Field
      Descriptions" table:
      "Data length is the number of octets written by the eTSEC into this BD's
      data buffer if L is cleared (the value is equal to MRBLR), or, if L is
      set, the length of the frame including *CRC*, FCB (if RCTRL[PRSDEP > 00),
      preamble (if MACCFG2[PreAmRxEn]=1), time stamp (if RCTRL[TS] = 1) and
      any padding (RCTRL[PAL])."
      
      Though the FCS bytes are removed by the driver before passing the skb
      to the net stack, the Rx buffer size computation does not currently
      take into account the FCS bytes (4 bytes).
      Because the Rx buffer size is multiple of 512 bytes, leaving out the
      FCS is not a problem for the default MTU of 1500, as the Rx buffer size
      is 1536 in this case.  However, for custom MTUs, where the difference
      between the MTU size and the Rx buffer size is less, this can be a
      problem as the computed Rx buffer size won't be enough to accomodate
      the FCS for a received frame that is big enough (close to MTU size).
      In such case the received frame is considered to be incomplete (L flag
      not set in the RxBD status) and silently dropped.
      
      Note that the driver does not currently support S/G on Rx, so it has to
      compute its Rx buffer size based on the MTU of the device.
      Reported-by: NKristian Otnes <kotnes@cisco.com>
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f5b720b8
  14. 09 10月, 2014 5 次提交
  15. 08 8月, 2014 2 次提交
  16. 06 6月, 2014 1 次提交
  17. 05 6月, 2014 1 次提交
    • X
      gianfar: Fix the section mismatch warnings. · 898157ed
      Xiubo Li 提交于
      Building with CONFIG_DEBUG_SECTION_MISMATCH enabled, the following
      WARNING is occured:
      
        LD      drivers/net/built-in.o
      WARNING: drivers/net/built-in.o(.text+0xcd4c): Section mismatch in
      reference from the function gfar_probe() to the function
      .init.text:gfar_init_addr_hash_table()
      The function gfar_probe() references
      the function __init gfar_init_addr_hash_table().
      This is often because gfar_probe lacks a __init
      annotation or the annotation of gfar_init_addr_hash_table is wrong.
      Signed-off-by: NXiubo Li <Li.Xiubo@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      898157ed
  18. 23 5月, 2014 1 次提交
  19. 01 5月, 2014 1 次提交
    • C
      gianfar: Avoid unnecessary reg accesses in adjust_link() · 6ce29b0e
      Claudiu Manoil 提交于
      For phy devices that don't issue interrupts upon link
      state changes, phylib polls the link state resulting in
      repeated calls to adjust_link(), even if the link state
      didn't change.  As a result, some mac registers are
      repeatedly read and written with the same values, which
      is not ok.
      
      To fix this, adjust_link() has been refactored to check
      first whether the link state has changed and to take action
      only if needed, updating mac registers and local state
      variables.  The 'new_state' local flag, set if one of the
      link params changed (link, speed or duplex), has been
      rendered useless and removed by this refactoring.
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6ce29b0e
  20. 18 4月, 2014 1 次提交
  21. 24 3月, 2014 1 次提交
    • C
      gianfar: Fix P1010 config regression (SQ polling) · c65d7533
      Claudiu Manoil 提交于
      The P1010 device tree restricts the number of
      supported interrupt groups to 1, although the eth
      controller can support 2 interrupt groups and the
      driver assumes the Multi-Group mode ("fsl,etsec2" model).
      
      So, in this case the assumption that the Multi-Group
      mode (MQ_MG_MODE) devices always support 2 interrupt
      groups is false.  To fix this, a check for the actual
      number of interrupt groups enabled in the board's
      device tree has been added in gfar_probe for the
      "fsl,etsec2" devices.
      
      Without this fix, P1010 based boards claim support for
      2 Tx queues to the net stack but only one is actually
      allocated, leading to NULL access in xmit.  This issue
      was introduced by enabling Single-Queue polling for
      the P1010 devices.
      (71ff9e3d gianfar: Use Single-Queue polling for
      "fsl,etsec2")
      
      Fixes: 71ff9e3dSigned-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c65d7533
  22. 13 3月, 2014 1 次提交
  23. 12 3月, 2014 1 次提交
  24. 11 3月, 2014 2 次提交
    • C
      gianfar: Use Single-Queue polling for "fsl,etsec2" · 71ff9e3d
      Claudiu Manoil 提交于
      For the "fsl,etsec2" compatible models the driver currently
      supports 8 Tx and Rx DMA rings (aka HW queues).  However, there
      are only 2 pairs of Rx/Tx interrupt lines, as these controllers
      are integrated in low power SoCs with 2 CPUs at most.  As a result,
      there are at most 2 NAPI instances that have to service multiple
      Tx and Rx queues for these devices.  This complicates the NAPI
      polling routine having to iterate over the mutiple Rx/Tx queues
      hooked to the same interrupt lines.  And there's also an overhead
      at HW level, as the controller needs to service all the 8 Tx rings
      in a round robin manner.  The combined overhead shows up for multi
      parallel Tx flows transmitted by the kernel stack, when the driver
      usually starts returning NETDEV_TX_BUSY leading to NETDEV WATCHDOG
      Tx timeout triggering if the Tx path is congested for too long.
      
      As an alternative, this patch makes the driver support only one
      Tx/Rx DMA ring per NAPI instance (per interrupt group or pair
      of Tx/Rx interrupt lines) by default.  The simplified single queue
      polling routine (gfar_poll_sq) will be the default napi poll routine
      for the etsec2 devices too.  Some adjustments needed to be made to
      link the Tx/Rx HW queues with each NAPI instance (2 in this case).
      The gfar_poll_sq() is already successfully used by older SQ_SG_MODE
      (single interrupt group) controllers.
      This patch fixes Tx timeout triggering under heavy Tx traffic load
      (i.e. iperf -c -P 8) for the "fsl,etsec2" (currently the only
      MQ_MG_MODE devices).  There's also a significant memory footprint
      reduction by supporting 2 Rx/Tx DMA rings (at most), instead of 8,
      for these devices.
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      71ff9e3d
    • C
      gianfar: Separate out the Tx interrupt handling (Tx NAPI) · aeb12c5e
      Claudiu Manoil 提交于
      There are some concurrency issues on devices w/ 2 CPUs related
      to the handling of Rx and Tx interrupts.  eTSEC has separate
      interrupt lines for Rx and Tx but a single imask register
      to mask these interrupts and a single NAPI instance to handle
      both Rx and Tx work.  As a result, the Rx and Tx ISRs are
      identical, both are invoking gfar_schedule_cleanup(), however
      both handlers can be entered at the same time when the Rx and
      Tx interrupts are taken by different CPUs.  In this case
      spurrious interrupts (SPU) show up (in /proc/interrupts)
      indicating a concurrency issue.  Also, Tx overruns followed
      by Tx timeout have been observed under heavy Tx traffic load.
      
      To address these issues, the schedule cleanup ISR part has
      been changed to handle the Rx and Tx interrupts independently.
      The patch adds a separate NAPI poll routine for Tx cleanup to
      be triggerred independently by the Tx confirmation interrupts
      only.  Existing poll functions are modified to handle only
      the Rx path processing.  The Tx poll routine does not need a
      budget, since Tx processing doesn't consume NAPI budget, and
      hence it is registered with minimum NAPI weight.
      NAPI scheduling does not require locking since there are
      different NAPI instances between the Rx and Tx confirmation
      paths now.
      So, the patch fixes the occurence of spurrious Rx/Tx interrupts.
      Tx overruns also occur less frequently now.
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      aeb12c5e
  25. 25 2月, 2014 3 次提交
    • C
      gianfar: Fix Tx int miss, dont write IC on-the-fly · f19015ba
      Claudiu Manoil 提交于
      Programming the interrupt coalescing (IC) registers while
      the controller/DMA is on may incur the loss of one Tx
      confirmation interrupt, under certain conditions.  This is
      a subtle hw race because it does not occur during a burst
      of Tx packets.  It has been observed on p2020 devices that,
      if just one packet is being xmit'ed, the Tx confirmation
      doesn't trigger and BQL evetually blocks the Tx queues,
      followed by Tx timeout and an un-responsive device.
      This issue was not apparent prior to introducing BQL
      support, as a late Tx confirmation was not an issue back then
      and the next burst of Tx frames would have triggered the
      Tx confirmation/ Tx ring cleanup anyway.
      
      Bottom line, the hw specifications state that the IC registers
      should not be programmed while the Rx/Tx blocks (the DMA) are
      enabled. Further more, these registers are currently re-written
      with the same values on the processing path, over and over again.
      To fix this, rewriting the IC registers has been removed from
      the processing path (napi poll).  A complete MAC reset procedure
      has been implemented for the ethtool -c option instead, to
      reliably update these registers while the controller is stopped.
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f19015ba
    • C
      gianfar: Fix device reset races (oops) for Tx · 0851133b
      Claudiu Manoil 提交于
      The device reset procedure, stop_gfar()/startup_gfar(), has
      concurrency issues.
      "Kernel access of bad area" oopses show up during Tx timeout
      device reset or other reset cases (like changing MTU) that
      happen while the interface still has traffic. The oopses
      happen in start_xmit and clean_tx_ring when accessing tx_queue->
      tx_skbuff which is NULL. The race comes from de-allocating the
      tx_skbuff while transmission and napi processing are still
      active. Though the Tx queues get temoprarily stopped when Tx
      timeout occurs, they get re-enabled as a result of Tx congestion
      handling inside the napi context (see clean_tx_ring()). Not
      disabling the napi during reset is also a bug, because
      clean_tx_ring() will try to access tx_skbuff while it is being
      de-alloc'ed and re-alloc'ed.
      
      To fix this, stop_gfar() needs to disable napi processing
      after stopping the Tx queues. However, in order to prevent
      clean_tx_ring() to re-enable the Tx queue before the napi
      gets disabled, the device state DOWN has been introduced.
      It prevents the Tx congestion management from re-enabling the
      de-congested Tx queue while the device is brought down.
      An additional locking state, RESETTING, has been introduced
      to prevent simultaneous resets or to prevent configuring the
      device while it is resetting.
      The bogus 'rxlock's (for each Rx queue) have been removed since
      their purpose is not justified, as they don't prevent nor are
      suited to prevent device reset/reconfig races (such as this one).
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0851133b
    • C
      gianfar: Don't free/request irqs on device reset · 80ec396c
      Claudiu Manoil 提交于
      Resetting the device (stop_gfar()/startup_gfar()) should
      be fast and to the point, in order to timely recover
      from an error condition (like Tx timeout) or during
      device reconfig.  The irq free/ request routines are just
      redundant here, and they should be part of the device
      close/ open routines instead.
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      80ec396c