1. 25 2月, 2016 1 次提交
    • C
      gianfar: Map head TxBD first · e19d0839
      Claudiu Manoil 提交于
      Move the mapping of the head BD before the mapping of fragments.
      The TOE (h/w offload) decision logic block can be also moved up
      (as the TOE flag belongs to the head BD), resulting in more
      localized code (TOE logic vs BD mapping code blocks).
      Note that, for this h/w, the R (status) bit for the head BD of a S/G
      frame needs to be written last for a reliable transmission.
      For the fragmented skb case, a local variable is used to temporarily
      store the status info of the first BD, replacing a BD status read.
      A merge of 2 "if(do_tstamp)" blocks was also possible.
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e19d0839
  2. 08 1月, 2016 1 次提交
  3. 17 12月, 2015 1 次提交
  4. 01 12月, 2015 1 次提交
  5. 23 11月, 2015 1 次提交
  6. 19 11月, 2015 1 次提交
  7. 28 10月, 2015 1 次提交
  8. 26 10月, 2015 2 次提交
    • C
      gianfar: Fix Rx BSY error handling · 1de65a5e
      Claudiu Manoil 提交于
      The Rx BSY error interrupt indicates that a frame was
      received and discarded due to lack of buffers, so it's
      a rx ring overflow condition and has nothing to do with
      with bad rx packets.  Use the right counter.
      
      BSY conditions happen when the SoC is under performance
      stress.  Doing *more* work in stress situations by trying
      to schedule NAPI is not a good idea as the stressed system
      becomes still more stressed.  The Rx interrupt is already
      at work making sure the NAPI is scheduled.
      So calling gfar_receive() here does not help.  This issue
      was present since day 1.
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1de65a5e
    • C
      gianfar: Don't enable the Filer w/o the Parser · 15bf176d
      Claudiu Manoil 提交于
      Under one unusual circumstance it's possible to wrongly set
      FILREN without enabling PRSDEP as well in the RCTRL register,
      against the hardware specifications.  With the default config
      this does not happen because the default Rx offloads (Rx csum
      and Rx VLAN) properly enable PRSDEP.  But if anyone disables
      all these offloads (via ethtool), we get a wrong configuration
      were the Rx flow classification and hashing, and other Filer
      based features (e.g. wake-on-filer interrupt) won't work.
      This patch fixes the issue.
      Also, account for Rx FCB insertion which happens every time
      PRSDEP is set.
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      15bf176d
  9. 07 10月, 2015 1 次提交
    • C
      gianfar: Add WAKE_UCAST and "wake-on-filer" support · 3e905b80
      Claudiu Manoil 提交于
      This enables eTSEC's filer (Rx parser) and the FGPI Rx
      interrupt (Filer General Purpose Interrupt) as a wakeup
      source event.
      
      Upon entering suspend state, the eTSEC filer is given
      a rule to match incoming L2 unicast packets.  A packet
      matching the rule will be enqueued in the Rx ring and
      a FGPI Rx interrupt will be asserted by the filer to
      wakeup the system.  Other packet types will be dropped.
      On resume the filer table is restored to the content
      before entering suspend state.
      The set of rules from gfar_filer_config_wol() could be
      extended to implement other WoL capabilities as well.
      
      The "fsl,wake-on-filer" DT binding enables this capability
      on certain platforms that feature the necessary power
      management infrastructure, targeting mainly printing and
      imaging applications.
      (refer to Power Management section of the SoC Ref Man)
      
      Cc: Li Yang <leoli@freescale.com>
      Cc: Zhao Chenhui <chenhui.zhao@freescale.com>
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3e905b80
  10. 25 9月, 2015 3 次提交
  11. 14 8月, 2015 1 次提交
    • C
      gianfar: Restore link state settings after MAC reset · 2a4eebf0
      Claudiu Manoil 提交于
      There are some MAC registers that need to be kept in sync
      with the link state parameters, see adjust_link().
      However, after a MAC soft reset default values for
      these registers are assumed.  In some cases (excepting
      if down/ if up for example) adjust_link() does not see
      that these values were reset to default because the
      priv->old* link parameters were left unchanged.
      So, reset the priv->old* link params as well during a
      MAC reset to let adjust_link() restore the MAC link
      settings to the actual link state values.
      
      Fixes following case, for example:
      Setting link to 100M, changing MTU (implies MAC reset),
      link state remains unchanged to 100M but MAC registers
      were reset to default (1G) breaking the connectivity w/
      the PHY.  Closing and re-opening the interface would
      restore the MAC link parameters to the correct values.
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2a4eebf0
  12. 01 8月, 2015 3 次提交
    • C
      gianfar: Enable device wakeup when appropriate · b0734b6d
      Claudiu Manoil 提交于
      The wol_en flag is 0 by default anyway, and we have the
      following inconsistency: a MAGIC packet wol capable eth
      interface is registered as a wake-up source but unable
      to wake-up the system as wol_en is 0 (wake-on flag set to 'd').
      Calling set_wakeup_enable() at netdev open is just redundant
      because wol_en is 0 by default.
      Let only ethtool call set_wakeup_enable() for now.
      
      The bflock is obviously obsoleted, its utility has been corroded
      over time.  The bitfield flags used today in gianfar are accessed
      only on the init/ config path, with no real possibility of
      concurrency - nothing that would justify smth. like bflock.
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b0734b6d
    • C
      gianfar: Fix suspend/resume for wol magic packet · 614b4242
      Claudiu Manoil 提交于
      If we disable NAPI in the first place we can mask the device's
      interrupts (and halt it) without fearing that imask may be
      concurrently accessed from interrupt context, so there's
      no need to do local_irq_save() around gfar_halt_nodisable().
      lock_rx_qs()/unlock_tx_qs() are just obsoleted and potentially
      buggy routines.  The txlock is currently used in the driver only
      to manage TX congestion, it has nothing to do with halting the
      device.  With these changes, the TX processing is stopped before
      gfar_halt().
      
      Compact gfar_halt() is used instead of gfar_halt_nodisable(),
      as it disables Rx/TX DMA h/w blocks and the Rx/TX h/w queues.
      gfar_start() re-enables all these blocks on resume.  Enabling
      the magic-packet mode remains the same, note that the RX block
      is re-enabled just before entering sleep mode.
      
      Add IRQF_NO_SUSPEND flag for the error interrupt line, to signal
      that the interrupt line must remain active during sleep in order
      to wake the system by magic packet (MAG) reception interrupt.
      (On some systems the MAG interrupt did trigger w/o this flag
      as well, but on others it didn't.)
      
      Without these fixes, when suspended during fair Tx traffic the
      interface occasionally failed to be woken up by magic packet.
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      614b4242
    • C
      gianfar: Fix warning when CONFIG_PM off · 84868305
      Claudiu Manoil 提交于
      CC      drivers/net/ethernet/freescale/gianfar.o
      drivers/net/ethernet/freescale/gianfar.c:568:13: warning: 'lock_tx_qs'
      defined but not used [-Wunused-function]
       static void lock_tx_qs(struct gfar_private *priv)
                   ^
      drivers/net/ethernet/freescale/gianfar.c:576:13: warning: 'unlock_tx_qs'
      defined but not used [-Wunused-function]
       static void unlock_tx_qs(struct gfar_private *priv)
                   ^
      Reported-by: NScott Wood <scottwood@freescale.com>
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      84868305
  13. 30 7月, 2015 1 次提交
  14. 16 7月, 2015 4 次提交
    • C
      gianfar: Add paged allocation and Rx S/G · 75354148
      Claudiu Manoil 提交于
      The eTSEC h/w is capable of scatter/gather on the receive side
      too if MAXFRM > MRBLR, when the allowed maximum Rx frame size
      is set to be greater than the maximum Rx buffer size (MRBLR).
      It's about time the driver makes use of this h/w capability,
      by supporting fixed buffer sizes and Rx S/G.
      
      The buffer size given to eTSEC for reception is fixed to
      1536B (must be multiple of 64), which is the same default
      buffer size as before, used to accommodate standard MTU
      (1500B) size frames.  As before, eTSEC can receive frames of
      up to 9600B.  Individual Rx buffers are mapped to page halves
      (page size for eTSEC systems is 4KB).  The skb is built around
      the first buffer of a frame (using build_skb()).  In case the
      frame spans multiple buffers, the trailing buffers are added
      as Rx fragments to the skb.  The last buffer in frame is marked
      by the L status flag.  A mechanism is in place to reuse the pages
      owned by the driver (for Rx) for subsequent receptions.
      
      Supporting fixed size buffers allows the implementation of Rx S/G,
      which in turn removes the memory pressure issues the driver had
      before when MTU was set for jumbo frame reception.
      Also, in most cases, the Rx path becomes faster due to Rx page
      reusal, since the overhead of allocating new rx buffers is removed
      from the fast path.
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      75354148
    • C
      gianfar: Use ndev, more Rx path cleanup · f23223f1
      Claudiu Manoil 提交于
      Use "ndev" instead of "dev", as the rx queue back pointer
      to a net_device struct, to avoid name clashing with a
      "struct device" reference.  This prepares the addition of a
      "struct device" back pointer to the rx queue structure.
      
      Remove duplicated rxq registration in the process.
      Move napi_gro_receive() outside gfar_process_frame().
      Signed-off-by: NClaudiu Manoil <claudiu.manoil@freescale.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f23223f1
    • 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
  15. 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
  16. 18 3月, 2015 1 次提交
  17. 16 3月, 2015 3 次提交
  18. 06 3月, 2015 1 次提交
  19. 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
  20. 30 1月, 2015 1 次提交
  21. 14 1月, 2015 1 次提交
  22. 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
  23. 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
  24. 30 10月, 2014 3 次提交
  25. 20 10月, 2014 1 次提交
  26. 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