History log of /drivers/net/ethernet/sfc/efx.c
Revision Date Author Comments
9baa3c34ac4e27f7e062f266f50cc5dbea26a6c1 08-Aug-2014 Benoit Taine <benoit.taine@lip6.fr> PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use

We should prefer `struct pci_device_id` over `DEFINE_PCI_DEVICE_TABLE` to
meet kernel coding style guidelines. This issue was reported by checkpatch.

A simplified version of the semantic patch that makes this change is as
follows (http://coccinelle.lip6.fr/):

// <smpl>

@@
identifier i;
declarer name DEFINE_PCI_DEVICE_TABLE;
initializer z;
@@

- DEFINE_PCI_DEVICE_TABLE(i)
+ const struct pci_device_id i[]
= z;

// </smpl>

[bhelgaas: add semantic patch]
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
36763266bbe8a2e93a7639b99bac2fee2c42bc5b 22-Jul-2014 Alexandre Rames <arames@solarflare.com> sfc: Add support for busy polling

This patch adds the sfc driver code for implementing busy polling.
It adds ndo_busy_poll method and locking between it and napi poll.
It also adds each napi to the napi_hash right after netif_napi_add().

Uses efx_start_eventq and efx_stop_eventq in the self tests.

Signed-off-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
e4d112e4f9502083fd27f9ac1a4cd690e3f01421 15-Jul-2014 Edward Cree <ecree@solarflare.com> sfc: add extra RX drop counters for nodesc_trunc and noskb_drop

Added a counter rx_noskb_drop for failure to allocate an skb.
Summed the per-channel rx_nodesc_trunc counters earlier so that they can
be included in rx_dropped.

Signed-off-by: Edward Cree <ecree@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3b06a00e65fbb5c526371143beaaa2221d39d577 14-Jul-2014 Mateusz Wrzesinski <mwrzesinski@solarflare.com> sfc: Adding PCI ID for Solarflare 7000 series 40G network adapter.

Signed-off-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7ad24ea4bf620a32631d7b3069c3e30c078b0c3e 11-May-2014 Wilfried Klaebe <w-lkml@lebenslange-mailadresse.de> net: get rid of SET_ETHTOOL_OPS

net: get rid of SET_ETHTOOL_OPS

Dave Miller mentioned he'd like to see SET_ETHTOOL_OPS gone.
This does that.

Mostly done via coccinelle script:
@@
struct ethtool_ops *ops;
struct net_device *dev;
@@
- SET_ETHTOOL_OPS(dev, ops);
+ dev->ethtool_ops = ops;

Compile tested only, but I'd seriously wonder if this broke anything.

Suggested-by: Dave Miller <davem@davemloft.net>
Signed-off-by: Wilfried Klaebe <w-lkml@lebenslange-mailadresse.de>
Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
e283546c0465dd3026bc94f7b1a9de7f6b8969ec 16-Apr-2014 Edward Cree <ecree@solarflare.com> sfc:On MCDI timeout, issue an FLR (and mark MCDI to fail-fast)

When an MCDI command times out (whether or not we find it
completed when we poll), call efx_mcdi_abandon(), which tells
all subsequent MCDI calls to fail-fast, and queues up an FLR.

Because an FLR doesn't lead to receiving any reboot even from
the MC (unlike most other types of reset), we have to call
efx_ef10_reset_mc_allocations.
In efx_start_all(), if a reset (of any kind) is pending, we
bail out.
Without this, attempts to reconfigure (e.g. change mtu) can
cause driver/mc state inconsistency if the first MCDI call
triggers an FLR.

For similar reasons, on EF10, in
efx_reset_down(method=RESET_TYPE_MCDI_TIMEOUT), set the number
of active queues to zero before calling efx_stop_all().
And, on farch, in efx_reset_up(method=RESET_TYPE_MCDI_TIMEOUT),
set active_queues and flushes pending & outstanding to zero.

efx_mcdi_mode_{poll,event}() should not take us out of fail-fast
mode. Instead, this is done by efx_mcdi_reset() after the FLR
completes.

The new FLR reset_type RESET_TYPE_MCDI_TIMEOUT doesn't really
fit into the hierarchy of reset 'scopes' whereby efx_reset()
decides some resets subsume others. Thus, it uses separate logic.

Also, fixed up some inconsistency around RESET_TYPE_MC_BIST,
which was in the wrong place in that hierarchy.

Signed-off-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
52ad762b85ed7947ec9eff6b036eb985352f6874 01-Apr-2014 Daniel Pieczko <dpieczko@solarflare.com> Call efx_set_channels() before efx->type->dimension_resources()

When using the "separate_tx_channels=1" module parameter, the TX queues are
initially numbered starting from the first TX-only channel number (after all the
RX-only channels). efx_set_channels() renumbers the queues so that they are
indexed from zero.

On EF10, the TX queues need to be relabelled in this way before calling the
dimension_resources NIC type operation, otherwise the TX queue PIO buffers can be
linked to the wrong VIs when using "separate_tx_channels=1".

Added comments to explain UC/WC mappings for PIO buffers

Signed-off-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
cd84ff4da1f46cbdc2d73366eabe9a8f818447cd 07-Mar-2014 Edward Cree <ecree@solarflare.com> sfc: Use ether_addr_copy and eth_broadcast_addr

Faster than memcpy/memset on some architectures.

Signed-off-by: Edward Cree <ecree@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
184603d8825773afae24279e055440dddada478d 18-Feb-2014 Alexander Gordeev <agordeev@redhat.com> sfc: Use pci_enable_msix_range() instead of pci_enable_msix()

As result of deprecation of MSI-X/MSI enablement functions
pci_enable_msix() and pci_enable_msi_block() all drivers
using these two interfaces need to be updated to use the
new pci_enable_msi_range() and pci_enable_msix_range()
interfaces.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Cc: Shradha Shah <sshah@solarflare.com>
Cc: linux-net-drivers@solarflare.com
Cc: netdev@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Acked-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6a350fdb609a9d8959d96858e8f9a25e3f5c017a 12-Feb-2014 Ben Hutchings <bhutchings@solarflare.com> sfc: Update product naming

We don't use 'Solarstorm' or 'Solarflare Communications' in full
any more.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
e0b3ae30a2a4d4303ea394e4c2edd8f215dbb13b 12-Feb-2014 Ben Hutchings <bhutchings@solarflare.com> sfc: Use canonical pointer type for MAC address in efx_set_mac_address()

Functions such as is_valid_ether_addr() expect u8 *, so use that
instead of char *.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2fa25cf1e1cad74df4b465710e55a62386743614 12-Feb-2014 Ben Hutchings <bhutchings@solarflare.com> sfc: Preserve rx_frm_trunc counters when resizing DMA rings

We allocate efx_channel structures with kzalloc() so we don't need to
zero-initialise individual fields in efx_probe_channel(). Further,
this function will be called again during DMA ring resizing and we
should not reset any statistics then.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
fbd791202b8c5a06c8c9312bf191d69c0bb5136c 21-Nov-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Implement efx_nic_type::filter_clear_rx operation for EF10

The operation can now fail, so change its return type to int.

Remove the inline wrapper while we're changing the signature.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
0bcf4a645fc027d05d15e79ce48b5893cff28082 18-Oct-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Associate primary and secondary functions of controller

The primary function of an EF10 controller will share its clock
device with other functions in the same domain (which we call
secondary functions). To this end, we need to associate functions
on the same controller.

We do not control probe order, so allow primary and secondary
functions to appear in any order. Maintain global lists of all
primary functions and of unassociated secondary functions,
and a list of secondary functions on each primary function.

Use the VPD serial number to tell whether functions are part of the
same controller. VPD will not be readable by virtual functions, so
this may need to be revisited later.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
ef215e64760ef6bd756c2999e7c8cee95b98e30a 05-Dec-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Store VPD serial number at probe time

Original version by Stuart Hodgson.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
bd9a265db26cdbfe74a303111381d90e66f56877 18-Nov-2013 Jon Cooper <jcooper@solarflare.com> sfc: Add RX packet timestamping for EF10

The EF10 firmware can optionally insert RX timestamps in the packet
prefix. These only include the clock minor value. We must also
enable periodic time sync events on each event queue which provide
the high bits of the clock value.

[bwh: Combined and rebased several changes.
Added the above description and some sanity checks for inline vs
separate timestamps.
Changed efx_rx_skb_attach_timestamp() to read the packet prefix
from the skb head area.]
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
d615c03937f2b26d3b346d4bdcd9ef342df2ce18 08-Oct-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Fold efx_flush_all() into efx_stop_port() and update comments

efx_flush_all() is a really misleading name - it has nothing to do
with e.g. flushing DMA queues. Since it's called immediately after
efx_stop_port() and is highly dependent on what that does, combine
the two functions.

Update comments to explain what this is doing a little better.
Also update an related and erroneous comment in efx_start_port().

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
f8f3b5ae3ea45ef6b00b471fed0fc90552a3c4af 30-Sep-2013 Jon Cooper <jcooper@solarflare.com> sfc: Correct RX dropped count for drops while interface is down

We don't directly control RX ingress on Siena or any later
controllers, and so we cannot prevent packets from entering the RX
datapath while the RX queues are not set up. This results in
the hardware incrementing RX_NODESC_DROP_CNT, but it's not an
error and we should not include it in error stats.

When bringing an interface up or down, pull (or wait for) stats and
count the number of packets that were dropped while the interface was
down. Subtract this from the reported RX dropped count.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
cce28794bc99c15f0d4c98936a473ac6e21be0ad 02-Oct-2013 Jon Cooper <jcooper@solarflare.com> sfc: Make initial fill of RX descriptors synchronous

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
74cd60a4d7b4f686146efd7ed211974691f0c2c1 16-Sep-2013 Jon Cooper <jcooper@solarflare.com> sfc: Add MC BISTs to ethtool offline self test on EF10

To run BISTs the MC goes down in to a special mode where it will only
respond to MCDI from the testing PF, and TX, RX and event queues are
torn down. Other PFs get a message as it goes down to tell them it's
going down.

When the other PFs get this message, they check the soft status
register to tell when the MC has rebooted after BIST mode and they can
start recovery.

[bwh: Convert the test result to 1 or -1 as for earlier NICs]
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
3166950070ce6b9d1443758d82c0a42779a02153 08-Dec-2013 Jingoo Han <jg1.han@samsung.com> net: sfc: remove unnecessary pci_set_drvdata()

The driver core clears the driver data to NULL after device_release
or on probe failure. Thus, it is not needed to manually clear the
device driver data to NULL.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2ec030144f648a6dd208f95f55ece212f1b72771 16-Nov-2013 Andrew Rybchenko <Andrew.Rybchenko@oktetlabs.ru> sfc: RX buffer allocation takes prefix size into account in IP header alignment

rx_prefix_size is 4-bytes aligned on Falcon/Siena (16 bytes), but it is equal
to 14 on EF10. So, it should be taken into account if arch requires IP header
to be 4-bytes aligned (via NET_IP_ALIGN).

Fixes: 8127d661e77f ('sfc: Add support for Solarflare SFC9100 family')
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2ea4dc28a5bcec408e01a8772763871638a5ec79 08-Nov-2013 Alexandre Rames <arames@solarflare.com> sfc: Stop/re-start PTP when stopping/starting the datapath.

This disables PTP when we bring the interface down to avoid getting
unmatched RX timestamp events, and tries to re-enable it when bringing
the interface up.

[bwh: Make efx_ptp_stop() safe on Falcon. Introduce
efx_ptp_{start,stop}_datapath() functions; we'll expand them later.]

Fixes: 7c236c43b838 ('sfc: Add support for IEEE-1588 PTP')
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
433dc9b3d123e72a0f5988c1f0d1c9319a735276 14-Nov-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Implement the SIOCGHWTSTAMP ioctl

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
9663dedafa302bb7fd511f9ae75d9ce33865477e 27-Jun-2013 Russell King <rmk+kernel@arm.linux.org.uk> DMA-API: net: sfc/efx.c: replace dma_set_mask()+dma_set_coherent_mask() with new helper

Replace the following sequence:

dma_set_mask(dev, mask);
dma_set_coherent_mask(dev, mask);

with a call to the new helper dma_set_mask_and_coherent().

Acked-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
f7a6d2c4427790cc8695401576dc594fcce8fc80 30-Aug-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Update copyright banners

Update the dates for files that have been added to in 2012-2013.
Drop the 'Solarstorm' brand name that's still lingering here.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
8127d661e77f5ec410093bce411f540afa34593f 29-Aug-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Add support for Solarflare SFC9100 family

This adds support for the EF10 network controller architecture and the
SFC9100 family, starting with SFC9120 'Farmingdale', and bumps the
driver version to 4.0.

New features in the SFC9100 family include:

- Flexible allocation of internal resources to PCIe physical and virtual
functions under firmware control
- RX event merging to reduce DMA writes at high packet rates
- Integrated RX timestamping
- PIO buffers for lower TX latency
- Firmware-driven data path that supports additional offload features
and filter types
- Delivery of packets between functions and to multiple recipients,
allowing firmware to implement a vswitch
- Multiple RX flow hash (RSS) contexts with their own hash keys and
indirection tables
- 40G MAC (single port only)

...not all of which are enabled in this initial driver or the initial
firmware release.

Much of the new code is by Jon Cooper.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
3881d8ab065b23bb07400aa820e737d80fdaced3 10-Jun-2013 Alexandre Rames <arames@solarflare.com> sfc: Use a global count of active queues instead of pending drains

On EF10, the firmware will initiate a queue flush in certain
error cases. We need to accept that flush events might appear
at any time after a queue has been initialised, not just when
we try to flush them.

We can handle Falcon-architecture in just the same way.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
e8c68c0a09279107b5b239ca6fa7c5839717b7e2 08-Mar-2013 Jon Cooper <jcooper@solarflare.com> sfc: Prepare for RX scatter on EF10

RX DMA scatter is always enabled on EF10. Adjust the common RX
completion handling to allow for this.

RX completion events on EF10 include the length used from a single
descriptor, not the cumulative length used. Add a field to struct
efx_rx_queue to hold the cumulative length.

[bwh: Also fix a related comment]
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
15acb1cea5d9298eac511b80380183be624fa31c 01-May-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Initialise IRQ moderation for all NIC types from efx_init_eventq()

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
c15eed220fd1dd31d7ad2e4893b679331e6f1e74 29-Aug-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Allow efx_nic_type::dimension_resources to fail

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
261e4d96b45476fa7386130a309bc15af9eca2e0 15-Apr-2013 Jon Cooper <jcooper@solarflare.com> sfc: Allow event queue initialisation to fail

On EF10, event queue initialisation requires an MCDI request which
may return failure.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
cade715ff18440dda53e59c10c606586c92be33e 28-Aug-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Implement asynchronous MCDI requests

This will allow use of MCDI from the data path, in particular for
accelerated RFS.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
43a3739d559f02cb00d92a51d8f2a7d294a1b5e5 18-Oct-2012 Jon Cooper <jcooper@solarflare.com> sfc: Generalise packet hash lookup to support EF10 RX prefix

EF10 uses an entirely different RX prefix format from Falcon-arch.
Extend struct efx_nic_type to describe this.

[bwh: Also replace the magic numbers used for the Falcon-arch RX prefix]
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
ba388fdd08ff458fabc8588e565b5d031191c50a 27-Jun-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Remove early call to efx_nic_type::reconfigure_mac in efx_reset_up()

efx_reset_up() calls efx_nic_type::reconfigure_mac once directly,
then again through efx_start_all() -> efx_start_port() ->
efx->type->reconfigure_mac().

This first call is also made too early to work properly on EF10.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
3de82b91ea604d7178925ce80ab821c968009c21 13-Jun-2013 Alexandre Rames <arames@solarflare.com> sfc: Add EF10 support for TX/RX DMA error events handling.

Also, since we handle all DMA errors in the same way, merge
RESET_TYPE_(RX|TX)_DESC_FETCH into RESET_TYPE_DMA_ERROR.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
cd0ecc9a6d279c8c5c5336f576330c45f5c80939 14-Dec-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Delegate MAC/NIC statistic description to efx_nic_type

Various hardware statistics that are available for Siena are
unavailable or meaningless for Falcon. Huntington adds further to the
NIC-type-specific statistics, as it has different MAC blocks from
Falcon/Siena.

All NIC types still provide most statistics by DMA, and use
little-endian byte order.

Therefore:
1. Add some general utility functions for reporting hardware statistics,
efx_nic_describe_stats() and efx_nic_update_stats().
2. Add an efx_nic_type::describe_stats operation to get the number and
names of statistics, implemented using efx_nic_describe_stats()
3. Change efx_nic_type::update_stats to store the core statistics
(struct rtnl_link_stats64) or full statistics (array of u64) in a
caller-provided buffer. Use efx_nic_update_stats() to aid in the
implementation.
4. Rename struct efx_ethtool_stat to struct efx_sw_stat_desc and
EFX_ETHTOOL_NUM_STATS to EFX_ETHTOOL_SW_STAT_COUNT.
5. Remove efx_nic::mac_stats and struct efx_mac_stats.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
964e61355e94905e4234839d4b41678998d617b7 20-Nov-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Cleanup Falcon-arch simple MAC filter state

On Falcon we implement MAC filtering requested by the stack using the
MAC wrapper's single unicast filter and multicast hash filter. Siena
is very similar, though MAC configuration is mediated by the MC.

Since MCDI operations may sleep, reconfiguration is deferred from
ndo_set_rx_mode to a work item. However, it still updates the private
variables describing the filter state synchronously. Contrary to
comments, the later use of these variables is not protected using the
address lock, resulting in race conditions.

Move the state update to a new function
efx_farch_filter_sync_rx_mode() and make the Falcon-arch MAC
configuration functions call that, so that its use is consistently
serialised by the mac_lock.

Invert and rename the promiscuous flag to the more accurate
unicast_filter, and comment that both this and multicast_hash are
not used on EF10.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
add7247718c003c8f7c275954083f7db85405bd9 08-Nov-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Make most filter operations NIC-type-specific

Aside from accelerated RFS, there is almost nothing that can be shared
between the filter table implementations for the Falcon architecture
and EF10.

Move the few shared functions into efx.c and rx.c and the rest into
farch.c. Introduce efx_nic_type operations for the implementation and
inline wrapper functions that call these.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
be3fc09cdd4aca438613b1d50d00afa77e9b2046 08-Oct-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Do not assume efx_nic_type::ev_fini is idempotent

efx_fini_eventq() needs to be idempotent but EF10 firmware is
picky about queue states.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
b105798fa5597f248256fa03ec25c2fbef922f92 19-Sep-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Get rid of per-NIC-type phys_addr_channels and mem_map_size

EF10 functions don't have a fixed BAR size, and the minimum is not
large enough for all the queues we might want to allocate. We have to
find out the BAR size at run-time, and therefore phys_addr_channels
and mem_map_size cannot be defined per-NIC-type.

Change efx_nic_type::mem_map_size to a function pointer which is
called to find the wanted memory map size (before probe).

Replace efx_nic_type::phys_addr_channels with efx_nic::max_channels,
to be initialised by the probe function.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
86094f7f38ff711f3db8497fcb4d2e109100f497 21-Aug-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Move and rename Falcon/Siena common NIC operations

Add efx_nic_type operations for the many efx_nic functions that need
to be implemented different on EF10. For now, change most of the
existing efx_nic_*() functions into inline wrappers. As a later step,
we may be able to improve branch prediction for operations used on the
fast path by copying the pointers into each queue/channel structure.

Move the Falcon/Siena implementations to new file farch.c and rename
the functions and static data to use a prefix of 'efx_farch_'.

Move efx_may_push_tx_desc() to nic.h, as the EF10 TX code will also
use it.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
e42c3d85af629697699c89aecba481527a1da898 27-May-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Refactor queue teardown sequence to allow for EF10 flush behaviour

Currently efx_stop_datapath() will try to flush our DMA queues (if DMA
is enabled), then finalise software and hardware state for each queue.
However, for EF10 we must ask the MC to finalise each queue, which
implicitly starts flushing it, and then wait for the flush events.
We therefore need to delegate more of this to the NIC type.

Combine all the hardware operations into a new NIC-type operation
efx_nic_type::fini_dmaq, and call this before tearing down the
software state and buffers for all the DMA queues.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
501a248cf6995286a4da0c2aa93c0fa9c5941453 27-May-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Remove bogus call to efx_release_tx_buffers()

efx_unregister_netdev() should not call efx_release_tx_buffers()
directly, as it is already done when closing the device:
efx_net_stop() -> efx_stop_all() -> efx_stop_datapath() ->
efx_fini_tx_queue() -> efx_release_tx_buffers().

(This was presumably a workaround for a race between efx_stop_all()
and the data path that has since been properly fixed.)

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
d8aec745ddaf278ba187d7712c1becc5ffd0f7da 27-May-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Stop RX refill before flushing RX queues

rx_queue::enabled guards refill, so rename it to reflect that. Clear
it at the start of the queue teardown process rather than waiting for
the RX queue to be flushed.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
d829118705f8213ffeffa4fefa8931dea6b7f016 06-Oct-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Rework IRQ enable/disable

There are many problems with the current efx_stop_interrupts() and
efx_start_interrupts():

1. On Siena, it is unsafe to disable the master IRQ enable bit
(DRV_INT_EN_KER) while any IRQ sources are enabled.

2. On EF10 there is no master IRQ enable bit, so we cannot expect to
defer IRQs without tearing down event queues. (Though I don't think
we will need to keep any event queues around while the device is down,
as we do for VFDI on Siena.)

3. synchronize_irq() only waits for a running IRQ handler to finish,
not for any propagation through IRQ controllers. Therefore an IRQ may
still be received and handled after efx_stop_interrupts() returns.
IRQ handlers can then race with channel reallocation.

To fix this:

a. Introduce a software IRQ enable flag. So long as this is clear,
IRQ handlers will only acknowledge IRQs and not touch the channel
structures.

b. Define a new struct efx_msi_context as the context for MSIs. This
is never reallocated and is sufficient to find the software enable
flag and the channel structure. It also includes the channel/IRQ
name, which was previously separated out as it must also not be
reallocated.

c. Split efx_{start,stop}_interrupts() into
efx_{,soft_}_{enable,disable}_interrupts(). The 'soft' functions
don't touch the hardware master enable flag (if it exists) and don't
reinitialise or tear down channels with the keep_eventq flag set.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
514bedbc3a07e466b040f76319b8f2a4c7b0c7a4 05-Oct-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Remove efx_process_channel_now()

efx_process_channel_now() is unneeded since self-tests can rely on
normal NAPI polling. Remove it and all calls to it.

efx_channel::work_pending and efx_channel_processed() are also
unneeded (the latter being the same as efx_nic_eventq_read_ack()).

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
1899c111a535e43046b14ae13639747d9d2544d6 22-May-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Fix IRQ cleanup in case of a probe failure

The lifetime of an irq_cpu_rmap is odd: we have to allocate it before
installing IRQ handlers and free it before removing the IRQ handlers.
As a result of this asymmetry, it was omitted from some failure paths.

On another failure path, we could try to remove IRQ handlers we
had not yet installed.

Move the irq_cpu_rmap allocation and freeing alongside IRQ handler
installation and removal, in efx_nic_{init,fini}_interrupts().
Count the number of IRQ handlers successfully installed and only
remove those on the failure path.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
b28405b0f25c91b52350fd558c219f08e5033eaf 21-Mar-2013 Alexandre Rames <arames@solarflare.com> sfc: Fix EEH with legacy interrupts.

PCI legacy interrupts are level-triggered, and we cannot mask them up
on an isolated device. Instead, disable the IRQ at the controller
until we have recovered.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
776fbcc9cbece10756bdb67b48a0798e6446f16b 18-Jun-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Remove write permission from phy_type attribute

Driver probe currently results in:

WARNING: at drivers/base/core.c:576 device_create_file+0x57/0x7e()
Attribute phy_type: write permission without 'store'

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
351638e7deeed2ec8ce451b53d33921b3da68f83 28-May-2013 Jiri Pirko <jiri@resnulli.us> net: pass info struct via netdevice notifier

So far, only net_device * could be passed along with netdevice notifier
event. This patch provides a possibility to pass custom structure
able to provide info that event listener needs to know.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>

v2->v3: fix typo on simeth
shortened dev_getter
shortened notifier_info struct name
v1->v2: fix notifier_call parameter in call_netdevice_notifier()
Signed-off-by: David S. Miller <davem@davemloft.net>
950c54df1e503ece4e2987b0cf6e2e4e22817c0c 13-May-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Reduce RX scatter buffer size, and reduce alignment if appropriate

efx_start_datapath() asserts that we can fit 2 RX scatter buffers plus
a software structure, each appropriately aligned, into a single page.
Where L1_CACHE_BYTES == 256 and PAGE_SIZE == 4096, which is the case
on s390, this assertion fails.

The current scatter buffer size is also not a multiple of 64 or 128,
which are more common cache line sizes. If we can make both the start
and end of a scatter buffer cache-aligned, this will reduce the need
for read-modify-write operations on inter- processor links.

Fix the alignment by reducing EFX_RX_USR_BUF_SIZE to 2048 - 256 ==
1792. (We could use 2048 - L1_CACHE_BYTES, but EFX_RX_USR_BUF_SIZE
also affects user-level networking where a larger amount of
housekeeping data may be needed. Although this version of the driver
does not support user-level networking, I prefer to keep scattering
behaviour consistent with the out-of-tree version.)

This still doesn't fix the s390 build because like most architectures
it has NET_IP_ALIGN == 2. When NET_IP_ALIGN != 0 we cannot achieve
cache line alignment at either the start or end of a scatter buffer,
so there is actually no point in padding the buffers to a multiple of
the cache line size. All we need is 4-byte alignment of the network
header, so do that.

Adjust the assertions accordingly.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reported-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
c14ff2ea2d5818c811e5c6e67e794df4a71a6094 13-May-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Delete EFX_PAGE_IP_ALIGN, equivalent to NET_IP_ALIGN

The two architectures that define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
(powerpc and x86) now both define NET_IP_ALIGN as 0, so there is no
need for this optimisation any more.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
debd0034de1f68585ab5d1d3d693d38f19d48e5d 16-Mar-2013 stephen hemminger <stephen@networkplumber.org> sfc: make local functions static

Trivial sparse detected functions that should be static.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
df594563fc8503d8473341fc67fc890c65c3a7c9 13-Mar-2013 Wei Yongjun <yongjun_wei@trendmicro.com.cn> sfc: remove duplicated include from efx.c

Remove duplicated include.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
1648a23fa159e5c433aac06dc5e0d9db36146016 13-Feb-2013 Daniel Pieczko <dpieczko@solarflare.com> sfc: allocate more RX buffers per page

Allocating 2 buffers per page is insanely inefficient when MTU is 1500
and PAGE_SIZE is 64K (as it usually is on POWER). Allocate as many as
we can fit, and choose the refill batch size at run-time so that we
still always use a whole page at once.

[bwh: Fix loop condition to allow for compound pages; rebase]
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2768935a46603bb9bdd121864b1f2b2e8a71cccc 13-Feb-2013 Daniel Pieczko <dpieczko@solarflare.com> sfc: reuse pages to avoid DMA mapping/unmapping costs

On POWER systems, DMA mapping/unmapping operations are very expensive.
These changes reduce these costs by trying to reuse DMA mapped pages.

After all the buffers associated with a page have been processed and
passed up, the page is placed into a ring (if there is room). For
each page that is required for a refill operation, a page in the ring
is examined to determine if its page count has fallen to 1, ie. the
kernel has released its reference to these packets. If this is the
case, the page can be immediately added back into the RX descriptor
ring, without having to re-map it for DMA.

If the kernel is still holding a reference to this page, it is removed
from the ring and unmapped for DMA. Then a new page, which can
immediately be used by RX buffers in the descriptor ring, is allocated
and DMA mapped.

The time a page needs to spend in the recycle ring before the kernel
has released its page references is based on the number of buffers
that use this page. As large pages can hold more RX buffers, the RX
recycle ring can be shorter. This reduces memory usage on POWER
systems, while maintaining the performance gain achieved by recycling
pages, following the driver change to pack more than two RX buffers
into large pages.

When an IOMMU is not present, the recycle ring can be small to reduce
memory usage, since DMA mapping operations are inexpensive.

With a small recycle ring, attempting to refill the descriptor queue
with more buffers than the equivalent size of the recycle ring could
ultimately lead to memory leaks if page entries in the recycle ring
were overwritten. To prevent this, the check to see if the recycle
ring is full is changed to check if the next entry to be written is
NULL.

[bwh: Combine and rebase several commits so this is complete
before the following buffer-packing changes. Remove module
parameter.]
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
85740cdf0b84224a9fce62dc9150008ef8d6ab4e 30-Jan-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Enable RX DMA scattering where possible

Enable RX DMA scattering iff an RX buffer large enough for the current
MTU will not fit into a single page and the NIC supports DMA
scattering for kernel-mode RX queues.

On Falcon and Siena, the RX_USR_BUF_SIZE field is used as the DMA
limit for both all RX queues with scatter enabled. Set it to 1824,
matching what Onload uses now.

Maintain a statistic for frames truncated due to lack of descriptors
(rx_nodesc_trunc). This is distinct from rx_frm_trunc which may be
incremented when scattering is disabled and implies an over-length
frame.

Whenever an MTU change causes scattering to be turned on or off,
update filters that point to the PF queues, but leave others
unchanged, as VF drivers assume scattering is off.

Add n_frags parameters to various functions, and make them iterate:
- efx_rx_packet()
- efx_recycle_rx_buffers()
- efx_rx_mk_skb()
- efx_rx_deliver()

Make efx_handle_rx_event() responsible for updating
efx_rx_queue::removed_count.

Change the RX pipeline state to a starting ring index and number of
fragments, and make __efx_rx_packet() responsible for clearing it.

Based on earlier versions by David Riddoch and Jon Cooper.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
ff734ef4bca05fd5cd51b83d2e2a9f008b64f9a3 30-Jan-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Wrap __efx_rx_packet() with efx_rx_flush_packet()

The pipeline mechanism will need to change a bit for scattered
packets. Add a wrapper to insulate efx_process_channel() from this.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
272baeeb6a98f5f746c2eeab4973c2df89e9d7ea 30-Jan-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Properly distinguish RX buffer and DMA lengths

Replace efx_nic::rx_buffer_len with efx_nic::rx_dma_len, the maximum
RX DMA length.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
626950db84c065925ee10c2e833da265cbda8800 14-Jan-2013 Alexandre Rames <arames@solarflare.com> sfc: Add AER and EEH support for Siena

The Linux side of EEH is triggered by MMIO reads, but this
driver's data path does not issue any MMIO reads (except in
legacy interrupt mode). Therefore add a monitor function
to poll EEH periodically.

When preparing to reset the device based on our own error
detection, also poll EEH and defer to its recovery mechanism
if appropriate.

[bwh: Use a separate condition for the initial link poll; fix some
style errors]
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
97d48a10c670f87bba9e5b2241e32f2eccd3fef0 11-Jan-2013 Alexandre Rames <arames@solarflare.com> sfc: Remove rx_alloc_method SKB

[bwh: Remove more dead code, and make efx_ptp_rx() pull the data it
needs into the header area.]
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
29c69a4882641285a854d6d03ca5adbba68c0034 28-Jan-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Detach net device when stopping queues for reconfiguration

We must only ever stop TX queues when they are full or the net device
is not 'ready' so far as the net core, and specifically the watchdog,
is concerned. Otherwise, the watchdog may fire *immediately* if no
packets have been added to the queue in the last 5 seconds.

The device is ready if all the following are true:

(a) It has a qdisc
(b) It is marked present
(c) It is running
(d) The link is reported up

(a) and (c) are normally true, and must not be changed by a driver.
(d) is under our control, but fake link changes may disturb userland.
This leaves (b). We already mark the device absent during reset
and self-test, but we need to do the same during MTU changes and ring
reallocation. We don't need to do this when the device is brought
down because then (c) is already false.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
1dd06ae8db716e17ec7e06244b858606edf378c0 06-Dec-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org> drivers/net: fix up function prototypes after __dev* removals

The __dev* removal patches for the network drivers ended up messing up
the function prototypes for a bunch of drivers. This patch fixes all of
them back up to be properly aligned.

Bonus is that this almost removes 100 lines of code, always a nice
surprise.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
87d1fc11303473a2bd74eedb8377ff80d853972b 03-Dec-2012 Bill Pemberton <wfp5p@virginia.edu> sfc: remove __dev* attributes

CONFIG_HOTPLUG is going away as an option. As result the __dev*
markings will be going away.

Remove use of __devinit, __devexit_p, __devinitdata, __devinitconst,
and __devexit.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Solarflare linux maintainers <linux-net-drivers@solarflare.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
b9cc977d9d4d1866ee83df38815f4b3b34d99dd9 28-Nov-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Make module parameters really boolean

Most of the module parameters treated as boolean are currently exposed
as type int or uint. Defining them with the proper type is useful
documentation for both users and developers.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
c2f3b8e3a44b6fe9e36704e30157ebe1a88c08b1 17-Oct-2012 Daniel Pieczko <dpieczko@solarflare.com> sfc: lock TX queues when calling netif_device_detach()

The assertion of netif_device_present() at the top of
efx_hard_start_xmit() may fail if we don't do this.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
32766ec8195f801935cce8954cf45389885afc38 05-Oct-2012 Ben Hutchings <bhutchings@solarflare.com> drivers/net/ethernet/sfc: use standard __{clear,set}_bit_le() functions

There are now standard functions for dealing with little-endian bit
arrays, so use them instead of our own implementations.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
7c236c43b838221e17220bcb39e8e8d8c7123713 03-Sep-2012 Stuart Hodgson <smhodgson@solarflare.com> sfc: Add support for IEEE-1588 PTP

Add PTP IEEE-1588 support and make accesible via the PHC subsystem.

This work is based on prior code by Andrew Jackson

Signed-off-by: Stuart Hodgson <smhodgson@solarflare.com>
[bwh:
- Add byte order conversion in efx_ptp_send_times()
- Simplify conversion of PPS event times
- Add the built-in vs module check to CONFIG_SFC_PTP dependencies]
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
c31e5f9f97fba32103c8bdd286eee8e3aefbee31 18-Jul-2012 Stuart Hodgson <smhodgson@solarflare.com> sfc: Add channel specific receive_skb handler and post_remove callback

Allows an extra channel to override the standard receive_skb handler
and also for extra non generic operations to be performed on remove.

Also set default rx strategy so only skbs can be delivered to the
PTP receive function.

Signed-off-by: Stuart Hodgson <smhodgson@solarflare.com>
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
79d68b370074044d7a9dd789ee103ffe5ef00bda 16-Jul-2012 Stuart Hodgson <smhodgson@solarflare.com> sfc: Add explicit RX queue flag to channel

The PTP channel will have its own RX queue even though it's not
a regular traffic channel.

Original work by Ben Hutchings <bhutchings@solarflare.com>

Signed-off-by: Stuart Hodgson <smhodgson@solarflare.com>
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
8f8b3d518999fd1c342310910aa1e49112c86d05 24-Aug-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Fix the initial device operstate

Following commit 8f4cccb ('net: Set device operstate at registration
time') it is now correct and preferable to set the carrier off before
registering a device.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
adeb15aa1ce3413d461ec0958a979e9d64cd764c 02-Aug-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Assign efx and efx->type as early as possible in efx_pci_probe()

We also stop clearing *efx in efx_init_struct(). This is safe because
alloc_etherdev_mq() already clears it for us.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
3f65ea5b2aa0f76a463c85ed39955c26faf4f5a7 27-Jul-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Remove bogus comment about MTU change and RX buffer overrun

RX DMA is limited by the length specified in each descriptor and not
by the MAC. Over-length frames may get into the RX FIFO regardless of
the MAC settings, due to a hardware bug, but they will be truncated by
the packet DMA engine and reported as such in the completion event.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
7bde852afc88909d78e617b70d3e7a3dc6bc04ff 27-Jul-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Remove overly paranoid locking assertions from netdev operations

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
7153f623ea47f3feb54209d75b80ed09a497cd4a 27-Jul-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Fix reset vs probe/remove/PM races involving efx_nic::state

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: Ben Hutchings <bhutchings@solarflare.com>
b812f8b7a9b657367eaacab8c34e6711a657a48b 27-Jul-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Improve log messages in case we abort probe due to a pending reset

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: Ben Hutchings <bhutchings@solarflare.com>
8b7325b4e29256881117aff8a162e829c79b47e9 27-Jul-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Never try to stop and start a NIC that is disabled

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: Ben Hutchings <bhutchings@solarflare.com>
5642ceef466365ebc94eb1332d9e6228efa09518 27-Jul-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Hold RTNL lock (only) when calling efx_stop_interrupts()

Interrupt state should be consistently guarded by the RTNL lock once
the net device is registered.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
6032fb56c546c0a14856dc57a92d84560816b217 27-Jul-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Keep disabled NICs quiescent during suspend/resume

Currently we ignore and clear the disabled state.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
61da026d86517def727eb67d7cb8ee5657a12dd9 27-Jul-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Hold the RTNL lock for more of the suspend/resume cycle

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: Ben Hutchings <bhutchings@solarflare.com>
f16aeea0e679d5fd43fc02e99569c52d77d5e5d3 27-Jul-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Change state names to be clearer, and comment them

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: Ben Hutchings <bhutchings@solarflare.com>
14bf718fb97efe9ff649c317e7d87a3617b13e7c 22-May-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Stop TX queues before they fill up

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: Ben Hutchings <bhutchings@solarflare.com>
7e6d06f0de3f74ca929441add094518ae332257c 30-Jul-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Fix maximum number of TSO segments and minimum TX queue size

Currently an skb requiring TSO may not fit within a minimum-size TX
queue. The TX queue selected for the skb may stall and trigger the TX
watchdog repeatedly (since the problem skb will be retried after the
TX reset). This issue is designated as CVE-2012-3412.

Set the maximum number of TSO segments for our devices to 100. This
should make no difference to behaviour unless the actual MSS is less
than about 700. Increase the minimum TX queue size accordingly to
allow for 2 worst-case skbs, so that there will definitely be space
to add an skb after we wake a queue.

To avoid invalidating existing configurations, change
efx_ethtool_set_ringparam() to fix up values that are too small rather
than returning -EINVAL.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
0e33d87033d84768ae700217e7c52dfb0c3399ca 17-May-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Use generic DMA API, not PCI-DMA API

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
3de4e30196f09ff2c096f2f8e17ebc9adda9db8d 05-Apr-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Fix missing cleanup in failure path of efx_pci_probe()

We need to clear the private data pointer in the PCI device.
Also reorder cleanup in efx_pci_remove() for symmetry.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
3dca9d2dc285faf1910d405b65df845cab061356 30-Mar-2012 Stuart Hodgson <smhodgson@solarflare.com> sfc: Do not attempt to flush queues if DMA is disabled

efx_nic_fatal_interrupt() disables DMA before scheduling a reset.
After this, we need not and *cannot* flush queues.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
3132d2827d92c2ee47fdf4dbec75bba0a2f291cb 05-May-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Fix division by zero when using one RX channel and no SR-IOV

If RSS is disabled on the PF (efx->n_rx_channels == 1) we try to set
up the indirection table so that VFs can use it, setting
efx->rss_spread = efx_vf_size(efx). But if SR-IOV was disabled at
compile time, this evaluates to 0 and we end up dividing by zero when
initialising the table.

I considered changing the fallback definition of efx_vf_size() to
return 1, but its value is really meaningless if we are not going to
enable VFs. Therefore add a condition of efx_sriov_wanted(efx) in
efx_probe_interrupts().

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
460eeaa03c5c0af32a388337a6e1f0f1acd043ce 05-Mar-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Log the part number on probe

During probe of each port, read and log the part number from VPD.
Remove the Falcon-specific board name lookup.

Initial version by Stuart Hodgson <smhodgson@solarflare.com>.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
dd40781e3a4e9d3177a548c389232ee9496dae8e 29-Feb-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Run event/IRQ self-test asynchronously when interface is brought up

Generate a test event on each event queue whenever the interface is
brought up, then after 1 second check that we have either handled a
test event or handled another IRQ for each event queue.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
e7bed9c8838c09518c02ea1a2ee74569836065ea 28-Feb-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Remove TX completions from adaptive IRQ scoring

RX and TX completions on the same event queue are generally not associated
with the same flows. The inclusion of TX completions in the adaptive IRQ
score is more of a source of noise rather than useful feedback. Therefore,
do not include them in the score, and adjust the default threshold scores
down.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
504f9b5a6bb5336ad434438d0cdd61a16db80129 21-Feb-2012 Danny Kukawka <danny.kukawka@bisect.de> ethernet: unify return value of .ndo_set_mac_address if address is invalid

Unify return value of .ndo_set_mac_address if the given address
isn't valid. Return -EADDRNOTAVAIL as eth_mac_addr() already does
if is_valid_ether_addr() fails.

Signed-off-by: Danny Kukawka <danny.kukawka@bisect.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
c92aaff18e0a48f693678105343160e0bd032dfa 22-Feb-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Reverse initial buffer table allocation to allow for later resizing

We have a very simple way of allocating buffer table entries to
queues, which is just to take the next one available. The extra
channels are the highest numbered channels but they need to be
allocated the lowest entries so that the traffic channels can be
allocated new entries without any collisions.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
cd2d5b529cdb9bd274f3e4bc68d37d4d63b7f383 14-Feb-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Add SR-IOV back-end support for SFC9000 family

On the SFC9000 family, each port has 1024 Virtual Interfaces (VIs),
each with an RX queue, a TX queue, an event queue and a mailbox
register. These may be assigned to up to 127 SR-IOV virtual functions
per port, with up to 64 VIs per VF.

We allocate an extra channel (IRQ and event queue only) to receive
requests from VF drivers.

There is a per-port limit of 4 concurrent RX queue flushes, and queue
flushes may be initiated by the MC in response to a Function Level
Reset (FLR) of a VF. Therefore, when SR-IOV is in use, we submit all
flush requests via the MC.

The RSS indirection table is shared with VFs, so the number of RX
queues used in the PF is limited to the number of VIs per VF.

This is almost entirely the work of Steve Hodgson, formerly
shodgson@solarflare.com.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
28e47c498a931200125e299e9d60d22e27b4ab0d 15-Feb-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Allocate SRAM between buffer table and descriptor caches at init time

Each port has a block of 64-bit SRAM that is divided between buffer
table and descriptor cache regions at initialisation time. Currently
we use a fixed allocation, but it needs to be changed to support
larger numbers of queues.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
a9a52506277275b73955504bf4df745502a28b8b 14-Feb-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Pass NIC structure into efx_wanted_parallelism()

This lets us identify the NIC affected in case of failure, and
will be necessary to adjust for SR-IOV constraints.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
7f967c011ae9c59fc7e7a017070ef7b22a5a4fbf 14-Feb-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Add support for 'extra' channel types

Abstract some of the channel operations to allow for 'extra'
channels that do not have RX or TX queues.

- Try to assign a channel to each extra channel type that is enabled
for the NIC, but gracefully degrade if we can't allocate sufficient
MSI-X vectors
- Allow each extra channel type to generate its own channel name
- Allow channel types to disable reallocation and reinitialisation
of their channels

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
a16e5b246c5b1aff3141ca6ae443307f3241a133 14-Feb-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Make all CPU/IRQ/channel/queue counts unsigned

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
9d9a6973a890c5b2258e717e4aae716720e60fcb 11-Feb-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Use proper function to test for RX channel in efx_poll()

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
9f2cb71c2b0ce33c472856c0feec2883fa0d9cd1 08-Feb-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Leave interrupts and event queues enabled whenever we can

When SR-IOV is enabled we may receive FLR (Function-Level Reset)
events, associated queue flush events and requests from VF drivers at
any time. Therefore we need to keep event queues and interrupts
enabled whenever possible.

Currently we stop interrupt-driven event processing before flushing RX
and TX queues; efx_nic_flush_queues() then polls event queues for
flush events and discards any others it finds. Change it to work with
the regular event handling functions.

Currently efx_start_channel() fills RX queues synchronously when a
device is brought up. This could now race with NAPI, so change it to
send fill events.

This was almost entirely written by Steve Hodgson, formerly
shodgson@solarflare.com.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
7c43161c11d7f40e38db9a1adb61347f06127796 27-Jan-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Warn if unable to create MTDs

Log an explicit warning if we are unable to create MTDs for a net
device. Also correct the comment about why mtd_device_register() may
fail; there is no longer an MTD table to fill up.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
fadac6aae1b8d9344beaa18aa9035869d773fd98 19-Nov-2011 Ben Hutchings <bhutchings@solarflare.com> sfc: Do not retry hardware probe if it schedules a reset

If efx_pci_probe_main() schedules an INVISIBLE or ALL reset (but
nothing more drastic), we retry it up to 5 times. So far as I'm
aware, this was a workaround for bugs in Falcon A0 which were fixed
in production silicon. Remove the retry.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
d9ab70079a9730f2d748714cbe4242bc707b9eef 14-Feb-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Skip RX end-of-batch work on channels without an RX queue

The code in efx_process_channel() to update the RX queue after each
batch of RX completions works out as a no-op on a TX-only channel
where the RX queue structure is set to all-zeroes, but
(1) efx_channel_get_rx_queue() will BUG() if DEBUG is defined, and
(2) it's a waste of time.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
db3395697cad6e9dff8d21249e0b59dc9bb83b48 26-Aug-2011 Ben Hutchings <bhutchings@solarflare.com> sfc: Replace efx_rx_buffer::is_page and other booleans with a flags field

Replace checksummed and discard booleans from efx_handle_rx_event()
with a bitmask, added to the flags field.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
0fca8c97612f90a68ff6e1873e674b4d69a435db 09-Jan-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Rename implementation of ndo_set_rx_mode

Rename efx_set_multicast_list() to efx_set_rx_mode(), in line
with the operation name net_device_ops::ndo_set_rx_mode.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
6c8eef4ac8dfd888be5b46e363f8e42b9f0d5b6a 09-Jan-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Remove redundant 'rc' variable, always set to 0

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2aa9ef11e70c47ed26f831798f02ad3794e5ad41 09-Jan-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Minor formatting fixes

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
86ee53020abe4eb9c85e612129e3848ee98302fd 09-Jan-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Use existing local variables instead of repeated indirect lookups

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
73ba7b68e952d98b0885e35402b204a7a675f4a9 09-Jan-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Remove remnants of on-load self-test

The out-of-tree version of the sfc driver used to run a self-test on
each device before registering it. Although this was never included
in-tree, some functions have checks for this special case which is not
really possible.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
cc180b69c009ec52f67a56d96b9073b9f774b323 08-Dec-2011 Ben Hutchings <bhutchings@solarflare.com> sfc: Correct interrupt timer quantum for Siena (normal and turbo mode)

We currently assume that the timer quantum for Siena is 5 us, the same
as for Falcon. This is not correct; timer ticks are generated on a
rota which takes a minimum of 768 cycles (each event delivery or other
timer change will delay it by 3 cycles). The timer quantum should be
6.144 or 3.072 us depending on whether turbo mode is active.

Replace EFX_IRQ_MOD_RESOLUTION with a timer_quantum_ns field in struct
efx_nic, initialised by the efx_nic_type::probe function.

While we're at it, replace EFX_IRQ_MOD_MAX with a timer_period_max
field in struct efx_nic_type.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
30b81cda9516878906b44fed16aac9df1dbb89c7 13-Sep-2011 Ben Hutchings <bhutchings@solarflare.com> sfc: Remove efx_nic_type::push_multicast_hash operation

Both implementations of efx_nic_type::reconfigure_mac operation
push the multicast hash filter to the hardware. It is therefore
redundant to call efx_nic_type::push_multicast_hash as well.

efx_mcdi_mac_reconfigure() also uses this operation, but the
implementation for Siena just uses MCDI anyway. Merge that into
efx_mcdi_mac_reconfigure().

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
710b208dc2687fdb3370110d54a67fb2288835eb 03-Sep-2011 Ben Hutchings <bhutchings@solarflare.com> sfc: Merge efx_mac_operations into efx_nic_type

No NICs need to switch efx_mac_operations at run-time, and the MAC
operations are fairly closely bound to NIC types.

Move efx_mac_operations::reconfigure to efx_nic_type::reconfigure_mac
and efx_mac_operations::check_fault fo efx_nic_type::check_mac_fault.
Change callers to call through efx->type or directly if the NIC type
is known.

Remove efx_mac_operations::update_stats. The implementations for
Falcon used to fetch MAC statistics synchronously and this was used by
efx_register_netdev() to clear statistics after running self-tests.
However, it now only converts statistics that have already been
fetched (and that only for Falcon), and the call from
efx_register_netdev() has no effect.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
1cb345220f135dcca24f01cc04cbb97a8242d419 03-Sep-2011 Ben Hutchings <bhutchings@solarflare.com> sfc: Hold efx_nic::stats_lock while reading efx_nic::mac_stats

efx_nic::stats_lock is used to serialise stats updates, but each
reader was dropping it before it finished reading efx_nic::mac_stats.

If there were concurrent stats reads using procfs, or one using procfs
and one using ethtool, an update could race with a read. On a 32-bit
system, the reader could see word-tearing of 64-bit stats (32 bits of
the old value and 32 bits of the new).

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
e332bcb3d149644c344ee5fdf1f6e4ac39e9d9a3 20-Dec-2011 Ben Hutchings <bhutchings@solarflare.com> sfc: Remove fallback for invalid permanent MAC address

By the time we look at the MAC address in efx_probe_port(), either the
driver or the firmware has already validated the board configuration.
The possibility of having an invalid MAC address just isn't worth
considering. It certainly isn't worth having a compile-time option
for this.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
cdb08f8fd8642a6d661c920f565e85cf87a0c9be 20-Dec-2011 Ben Hutchings <bhutchings@solarflare.com> sfc: Set default parallelism to per-core by default

The previous default of per-package can be more CPU-efficient, but
users generally seem to prefer per-core. It should also allow
accelerated RFS to direct packets more precisely, if IRQ affinity
is properly spread out.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
fa142b9da3393fd92b398b6bdecf3f21914e309b 20-Dec-2011 Ben Hutchings <bhutchings@solarflare.com> sfc: Rename efx_wanted_channels() to efx_wanted_parallelism()

This function returns the degree of parallelism wanted, which is not
necessarily the total number of channels we want to create.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
18e83e4cd144e30fb38bf1f714914182c6c8bced 05-Jan-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Const-qualify static data as appropriate, partly prompted by checkpatch

Fix the following warnings:

WARNING: struct dev_pm_ops should normally be const
WARNING: static const char * array should probably be static const char * const

Similarly const-qualify struct i2c_board_info, struct i2c_algo_bit_data,
struct efx_ethtool_stat, struct efx_mtd_ops and struct siena_nvram_type_info.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
e9e01846c7e18a3b5682b54e50f1005949737bd9 05-Jan-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Avoid assignment in an if-statement, reported by checkpatch

Fix the following error:

ERROR: do not use assignment in if condition

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
9c636baf8518d0f986004b40669b75506459beac 05-Jan-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Fix some formatting errors reported by checkpatch

Fix the following errors and warnings:

ERROR: trailing whitespace
ERROR: spaces required around that '=' (ctx:VxV)
WARNING: please, no space before tabs

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
278bc4296bd64ffd1d3913b487dc8a520e423a7a 15-Dec-2011 Ben Hutchings <bhutchings@solarflare.com> ethtool: Define and apply a default policy for RX flow hash indirection

All drivers that support modification of the RX flow hash indirection
table initialise it in the same way: RX rings are assigned to table
entries in rotation. Make that default policy explicit by having them
call a ethtool_rxfh_indir_default() function.

In the ethtool core, add support for a zero size value for
ETHTOOL_SRXFHINDIR, which resets the table to this default.

Partly-suggested-by: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Acked-by: Shreyas N Bhatewara <sbhatewara@vmware.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
547c474fa7dffeff312a8568d243f5f1fe84938c 02-Dec-2011 Ben Hutchings <bhutchings@solarflare.com> sfc: Remove device ID macros only used once

The SFC9020/SFL9021 device IDs are only used in the device ID table,
where we can just as well use comments.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
c8f44affb7244f2ac3e703cab13d55ede27621bb 15-Nov-2011 Michał Mirosław <mirq-linux@rere.qmqm.pl> net: introduce and use netdev_features_t for device features sets

v2: add couple missing conversions in drivers
split unexporting netdev_fix_features()
implemented %pNF
convert sock::sk_route_(no?)caps

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
9e393b3060ec4ed7e7c7c5de154e08e48c98f623 05-Sep-2011 Ben Hutchings <bhutchings@solarflare.com> sfc: Validate IRQ moderation parameters in efx_init_irq_moderation()

Add a range check, and move the check that RX and TX are consistent
from efx_ethtool_set_coalesce().

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
a0c4faf5484b1fe38952d5b975f19e9f4b8f0f2b 05-Sep-2011 Ben Hutchings <bhutchings@solarflare.com> sfc: Correct reporting and validation of TX interrupt coalescing

The reported TX IRQ moderation is generated in a completely crazy way.
Make it simple and correct.

When channels are shared between RX and TX, TX IRQ moderation must be
the same as RX IRQ moderation, but must be specified as 0! Allow it
to be either specified as the same, or left at its previous value
in which case it will be quietly overridden.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
b548f97684412b0969dc148e1706eb047151e356 05-Sep-2011 Ben Hutchings <bhutchings@solarflare.com> sfc: Use consistent types for interrupt coalescing parameters

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
afc4b13df143122f99a0eb10bfefb216c2806de0 16-Aug-2011 Jiri Pirko <jpirko@redhat.com> net: remove use of ndo_set_multicast_list in drivers

replace it by ndo_set_rx_mode

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
874aeea5d01cac55c160a4e503e3ddb4db030de7 13-May-2011 Jeff Kirsher <jeffrey.t.kirsher@intel.com> sfc: Move the Solarflare drivers

Moves the Solarflare drivers into drivers/net/ethernet/sfc/ and
make the necessary Kconfig and Makefile changes.

CC: Steve Hodgson <shodgson@solarflare.com>
CC: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>