1. 24 Aug, 2012 16 commits
    • Ben Hutchings's avatar
      sfc: Fix reset vs probe/remove/PM races involving efx_nic::state · 7153f623
      Ben Hutchings authored
      We try to defer resets while the device is not READY, but we're not
      doing this quite correctly.  In particular, changes to efx_nic::state
      are documented as serialised by the RTNL lock, but they aren't.
      
      1. We check whether a reset was requested during probe (suggesting
      broken hardware) before we allow requested resets to be scheduled.
      This leaves a window where a requested reset would be deferred
      indefinitely.
      
      2. Although we cancel the reset work item during device removal,
      there are still later operations that can cause it to be scheduled
      again.  We need to check the state before scheduling it.
      
      3. Since the state can change between scheduling and running of
      the work item, we still need to check it there, and we need to
      do so *after* acquiring the RTNL lock which serialises state
      changes.
      
      4. We must cancel the reset work item during device removal, if the
      state could ever have been READY.  This wasn't done in some of the
      failure paths from efx_pci_probe().  Move the cancellation to
      efx_pci_remove_main().
      Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
      7153f623
    • Ben Hutchings's avatar
      sfc: Improve log messages in case we abort probe due to a pending reset · b812f8b7
      Ben Hutchings authored
      The current informational message doesn't properly explain what
      happens, and could also appear if we defer a reset during
      suspend/resume.
      Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
      b812f8b7
    • Ben Hutchings's avatar
      sfc: Never try to stop and start a NIC that is disabled · 8b7325b4
      Ben Hutchings authored
      efx_change_mtu() and efx_realloc_channels() each stop and start much
      of the NIC, even if it has been disabled.  Since efx_start_all() is a
      no-op when the NIC is disabled, this is probably harmless in the case
      of efx_change_mtu(), but efx_realloc_channels() also reenables
      interrupts which could be a bad thing to do.
      
      Change efx_start_all() and efx_start_interrupts() to assert that the
      NIC is not disabled, but make efx_stop_interrupts() do nothing if the
      NIC is disabled (since it is already stopped), consistent with
      efx_stop_all().
      
      Update comments for efx_start_all() and efx_stop_all() to describe
      their purpose and preconditions more accurately.
      
      Add a common function to check and log if the NIC is disabled, and use
      it in efx_net_open(), efx_change_mtu() and efx_realloc_channels().
      Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
      8b7325b4
    • Ben Hutchings's avatar
      sfc: Hold RTNL lock (only) when calling efx_stop_interrupts() · 5642ceef
      Ben Hutchings authored
      Interrupt state should be consistently guarded by the RTNL lock once
      the net device is registered.
      Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
      5642ceef
    • Ben Hutchings's avatar
      sfc: Keep disabled NICs quiescent during suspend/resume · 6032fb56
      Ben Hutchings authored
      Currently we ignore and clear the disabled state.
      Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
      6032fb56
    • Ben Hutchings's avatar
      sfc: Hold the RTNL lock for more of the suspend/resume cycle · 61da026d
      Ben Hutchings authored
      I don't think these PM functions can race with userland net device
      operations, but it's much easier to reason about locking if state is
      consistently guarded by the same lock.
      Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
      61da026d
    • Ben Hutchings's avatar
      sfc: Change state names to be clearer, and comment them · f16aeea0
      Ben Hutchings authored
      STATE_INIT and STATE_FINI are equivalent and represent incompletely
      initialised states; combine them as STATE_UNINIT.
      
      Rename STATE_RUNNING to STATE_READY, to avoid confusion with
      netif_running() and IFF_RUNNING.
      
      The comments do not quite match current usage, but this will be
      corrected in subsequent fixes.
      Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
      f16aeea0
    • Ben Hutchings's avatar
    • Ben Hutchings's avatar
      sfc: Replace tso_state::full_packet_space with ip_base_len · 53cb13c6
      Ben Hutchings authored
      We only use tso_state::full_packet_space to calculate the IPv4 tot_len
      or IPv6 payload_len, not to set tso_state::packet_space.  Replace it
      with an ip_base_len field holding the value of tot_len or payload_len
      before including the TCP payload, which is much more useful when
      constructing the new headers.
      Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
      53cb13c6
    • Ben Hutchings's avatar
      sfc: Simplify TSO header buffer allocation · f7251a9c
      Ben Hutchings authored
      TSO header buffers contain a control structure immediately followed by
      the packet headers, and are kept on a free list when not in use.  This
      complicates buffer management and tends to result in cache read misses
      when we recycle such buffers (particularly if DMA-coherent memory
      requires caches to be disabled).
      
      Replace the free list with a simple mapping by descriptor index.  We
      know that there is always a payload descriptor between any two
      descriptors with TSO header buffers, so we can allocate only one
      such buffer for each two descriptors.
      
      While we're at it, use a standard error code for allocation failure,
      not -1.
      Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
      f7251a9c
    • Ben Hutchings's avatar
      sfc: Stop TX queues before they fill up · 14bf718f
      Ben Hutchings authored
      We now have a definite upper bound on the number of descriptors per
      skb; use that to stop the queue when the next packet might not fit.
      Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
      14bf718f
    • Ben Hutchings's avatar
      sfc: Refactor struct efx_tx_buffer to use a flags field · 7668ff9c
      Ben Hutchings authored
      Add a flags field to struct efx_tx_buffer, replacing the
      continuation and map_single booleans.
      
      Since a single descriptor cannot be both a TSO header and the last
      descriptor for an skb, unionise efx_tx_buffer::{skb,tsoh} and add
      flags for validity of these fields.
      
      Clear all flags in free buffers (whereas previously the continuation
      flag would be set).
      Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
      7668ff9c
    • Ben Hutchings's avatar
      net: Set device operstate at registration time · 8f4cccbb
      Ben Hutchings authored
      The operstate of a device is initially IF_OPER_UNKNOWN and is updated
      asynchronously by linkwatch after each change of carrier state
      reported by the driver.  The default carrier state of a net device is
      on, and this will never be changed on drivers that do not support
      carrier detection, thus the operstate remains IF_OPER_UNKNOWN.
      
      For devices that do support carrier detection, the driver must set the
      carrier state to off initially, then poll the hardware state when the
      device is opened.  However, we must not activate linkwatch for a
      unregistered device, and commit b4730016 ('net: Do not fire linkwatch
      events until the device is registered.') ensured that we don't.  But
      this means that the operstate for many devices that support carrier
      detection remains IF_OPER_UNKNOWN when it should be IF_OPER_DOWN.
      
      The same issue exists with the dormant state.
      
      The proper initialisation sequence, avoiding a race with opening of
      the device, is:
      
              rtnl_lock();
              rc = register_netdevice(dev);
              if (rc)
                      goto out_unlock;
              netif_carrier_off(dev); /* or netif_dormant_on(dev) */
              rtnl_unlock();
      
      but it seems silly that this should have to be repeated in so many
      drivers.  Further, the operstate seen immediately after opening the
      device may still be IF_OPER_UNKNOWN due to the asynchronous nature of
      linkwatch.
      
      Commit 22604c86 ('net: Fix for initial link state in 2.6.28') attempted
      to fix this by setting the operstate synchronously, but it was
      reverted as it could lead to deadlock.
      
      This initialises the operstate synchronously at registration time
      only.
      Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8f4cccbb
    • Timur Tabi's avatar
      net/fsl: introduce Freescale 10G MDIO driver · 9f35a734
      Timur Tabi authored
      Similar to fsl_pq_mdio.c, this driver is for the 10G MDIO controller on
      Freescale Frame Manager Ethernet controllers.
      Signed-off-by: default avatarTimur Tabi <timur@freescale.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9f35a734
    • Neil Horman's avatar
      cls_cgroup: Allow classifier cgroups to have their classid reset to 0 · 3afa6d00
      Neil Horman authored
      The network classifier cgroup initalizes each cgroups instance classid value to
      0.  However, the sock_update_classid function only updates classid's in sockets
      if the tasks cgroup classid is not zero, and if it differs from the current
      classid.  The later check is to prevent cache line dirtying, but the former is
      detrimental, as it prevents resetting a classid for a cgroup to 0.  While this
      is not a common action, it has administrative usefulness (if the admin wants to
      disable classification of a certain group temporarily for instance).
      
      Easy fix, just remove the zero check.  Tested successfully by myself
      Signed-off-by: default avatarNeil Horman <nhorman@tuxdriver.com>
      CC: "David S. Miller" <davem@davemloft.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3afa6d00
    • David S. Miller's avatar
      Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge · e6e94e39
      David S. Miller authored
      Antonio Quartulli says:
      
      ====================
      Included changes:
      - a set of codestyle rearrangements/fixes
      - new feature to early detect new joining (mesh-unaware) clients
      - a minor fix for the gw-feature
      - substitution of shift operations with the BIT() macro
      - reorganization of the main batman-adv structure (struct batadv_priv)
      - some more (very) minor cleanups and fixes
      ===================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e6e94e39
  2. 23 Aug, 2012 24 commits