History log of /drivers/net/ethernet/sfc/net_driver.h
Revision Date Author Comments
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>
8ccf3800dbdeaf26bcdefa471c9c8e0da7e6ec7a 17-Jul-2014 Andrew Rybchenko <Andrew.Rybchenko@oktetlabs.ru> sfc: Add per-queue statistics in ethtool

Implement per channel software TX and RX packet counters
accessed as ethtool statistics.

This allows confirmation with MAC statistics.

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>
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>
5b3b76085c68b33da6903f216ebc16903b199ac4 12-Feb-2014 Ben Hutchings <bhutchings@solarflare.com> sfc: Add/remove blank lines to taste

Remove trailing blank lines in several files.
Use only one blank line between functions.
Add a blank line as a separator in a few places.

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>
8c5270acf3f74a2bff04461ce7fbbcf0ae54b2ae 28-Nov-2013 Andrew Rybchenko <Andrew.Rybchenko@oktetlabs.ru> sfc: remove unused 'enum efx_rx_alloc_method'

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
ff2de51bfb26e8d6f2ee6d45d5a5eedf51c19d2f 23-Nov-2013 Andrew Rybchenko <Andrew.Rybchenko@oktetlabs.ru> sfc: remove unused 'refcnt' from efx_rx_page_state

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
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>
d43050c0c7d930cdeb10fb9201d9e2d005cef02a 14-Nov-2013 Andrew Rybchenko <Andrew.Rybchenko@oktetlabs.ru> sfc: Change efx_nic_type::rx_push_indir_table to push hash key as well

The EF10 implementation already does this, and it makes more logical
sense to group the RSS hash key and indirection table together.
Rename the operation to rx_push_rss_config.

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>
2ccd0b192534b1dc6af45ffb81faa44b7ae416bf 28-Nov-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Copy RX prefix into skb head area in efx_rx_mk_skb()

We can potentially pull the entire packet contents into the head area
and then free the page it was in. In order to read an inline
timestamp safely, we need to copy the prefix into the head area as
well.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
9ec0659595c8020f1efa55aa00870e8773f8ee89 21-Nov-2013 Daniel Pieczko <dpieczko@solarflare.com> sfc: split setup of hardware timestamping into NIC-type operation

I added efx_ptp_get_mode() to avoid moving the definition for
efx_ptp_data, since the current PTP mode is needed for
siena.c:siena_set_ptp_hwtstamp.

[bwh: Also move the rx_filters mask, and add kernel-doc]
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>
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>
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>
2acdb92e85412bf791a3c01f2173695b6e0a3f72 31-Oct-2013 Alexandre Rames <arames@solarflare.com> sfc: Fix DMA unmapping issue with firmware assisted TSO

When using firmware assisted TSO, we use a single DMA mapping for
the linear area of a TSO skb.

We still have to segment the super-packet and insert a descriptor
containing the original headers before each segment of payload, so we
can unmap the linear area only after the last segment is completed.
The unmapping information for the linear area is therefore associated
with the last header descriptor.

We calculate the DMA address to unmap from using the map length and
the invariant that the end of the DMA mapping matches the end of
the data referenced by the last descriptor. But this invariant is
broken when there is TCP payload in the linear area.

Fix this by adding and using an explicit dma_offset field.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
ee45fd92c739db5b7950163d91dfe5f016af6d24 02-Sep-2013 Jon Cooper <jcooper@solarflare.com> sfc: Use TX PIO for sufficiently small packets

Sufficiently small linear packets can be copied into the PIO buffer
with a single call to memcpy_toio(). Non-linear packets require an
intermediate cache-line-sized buffer.

[bwh: I wrote the first version of this, but Jon did the hard work to
handle non-linear packets.]
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
183233bec8105c06341d8cd380db1d830d0efc00 28-Jun-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Allocate and link PIO buffers; map them with write-combining

Try to allocate a segment of PIO buffer to each TX channel. If
allocation fails, log an error but continue.

PIO buffers must be mapped separately from the NIC registers, with
write-combining enabled. Where the host page size is 4K, we could
potentially map each VI's registers and PIO buffer separately.
However, this would add significant complexity, and we also need to
support architectures such as POWER which have a greater page size.
So make a single contiguous write-combining mapping after the
uncacheable mapping, aligned to the host page size, and link PIO
buffers there. Where necessary, allocate additional VIs within
the write-combining mapping purely for access to PIO buffers.

Link all TX buffers to TX queues and the additional VIs in
efx_ef10_dimension_resources() and in efx_ef10_init_nic() after
an MC reboot.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
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>
ba8977bdb20d7ae72ec6fddc1c081ca2d56852cb 09-Jan-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Extend struct efx_tx_buffer to allow pushing option descriptors

The TX path firmware for EF10 supports 'option descriptors' to control
offloads and various other features. Add a flag and field for these
in struct efx_tx_buffer, and don't treat them as DMA descriptors on
completion.

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>
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>
3dced740c243f454a9b83fbe73133911d5c6ce8d 27-Apr-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Add support for reading packet length from prefix

Define a flag for struct efx_rx_buffer and efx_rx_packet() that
indicates packet length must be read from the prefix. If this
is set, read the length in __efx_rx_packet() (when the prefix
should have arrived in cache).

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
02e121650b5e46ef3f2b3ed1ebc4b70e47799056 27-Apr-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Add TX merged completion counter

Add a counter for TX merged completion events.

This is implemented in the common TX path, because the NIC event
handlers only know how many descriptors were completed, not how many
packets.

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>
977a5d5d32f4797ace5ef65ee3f2232a1c88a274 07-Mar-2013 Laurence Evans <levans@solarflare.com> sfc: Add a function pointer to abstract write of host time into NIC shared memory

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>
45a3fd55acc8989ff93d469e57b123cd3702a948 28-Nov-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Move MTD operations into efx_nic_type

Merge the per-NIC-type MTD probe selection and struct efx_mtd_ops into
struct efx_nic_type. Move the implementations into the appropriate
source files.

Several NVRAM functions are now only called from MTD operations which
are now implemented in the same file (falcon.c or mcdi.c). There is no
need for them to be extern, or to be defined at all if CONFIG_SFC_MTD
is not enabled, so move them into the #ifdef CONFIG_SFC_MTD sections
in those files.

Most of the SPI-related definitions are also only used in falcon.c,
so move them there. Put the remainder of spi.h into nic.h (which
previously included it).

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
b766630b351c68c0383831dba9b81a905e5e84c6 28-Nov-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Eliminate struct efx_mtd

Currently we use struct efx_mtd to represent a physical NVRAM device
and struct efx_mtd_partition to represent a partition on that device.
But this only really makes sense for Falcon, as we don't know or care
whether MC-managed NVRAM partitions are on one or more physical
devices. It complicates iteration and provides little benefit.
Therefore:

- Replace the pointer to efx_mtd in mtd_info::priv with a pointer to efx_nic
- Move the falcon_spi_device pointer into the union in struct efx_mtd_partition
- Move the device name to efx_mtd_partition::dev_type_name
- Move the efx_mtd_ops pointer to efx_nic::mtd_ops
- Make efx_nic::mtd_list a list of partitions

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>
6d661cec7955e30c6f8813752ac5f95c736a6d49 27-Oct-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Split Falcon-arch-specific and common filter state

Move the common state from struct efx_filter_state into struct efx_nic.
Rename struct efx_filter_state to efx_farch_filter_state and change
the type of efx_nic::filter_state to void *.

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>
df2cd8af097850bb3440817fdb6b08922ff4b327 19-Sep-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Add support for MCDI v2

MCDI v2 adds a second header dword with wider command and length
fields. It also defines extra error codes.

Change the fallback error number for unknown MCDI error codes from EIO
to EPROTO. EIO is treated as indicating the MCDI transport has failed
and we need to reset the function, which is rather drastic.

v2 error codes and lengths don't fit into completion events, so for a
v2-capable transport, always read the response header rather then
using the event fields.

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>
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>
caa7558655d5ae1997c6d52f87b59f8ec6f2c3af 19-Sep-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Make struct efx_special_buffer less special

On EF10, the firmware is in charge of allocating buffer table entries.
Change struct efx_special_buffer to use a struct efx_buffer member,
so that it can be used with efx_nic_{alloc,free}_buffer() in that
case.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
f3ad50034425692965a0f2becdd9c45ecb45cd66 18-Sep-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Make MCDI independent of Siena

Move the lowest layer (transport) of the current MCDI code to
per-NIC-type operations.

Introduce a new structure and efx_nic member for MCDI-specific data.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
9dd3a13b885fef7dca0d2f27517a50b5fb5097c6 13-Sep-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Move details of a Falcon bug workaround out of ethtool.c

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
d07df8ec089cc72dded73dac5cf564ef9bba2fa1 16-May-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Define and set RX buffer flag for packets parsed as TCP

This will be useful for shortcutting some software packet parsing.

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>
6602041b8343fcdb6433cc72ca6cb6c2e189da6d 10-Jun-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Store port number in private data, not net_device::dev_id

We should not use net_device::dev_id to indicate the port number, as
this affects the way the local part of IPv6 addresses is normally
generated.

This field was intended for use where multiple devices may share a
single assigned MAC address and need to have different IPv6 addresses.
Siena's two ports each have their own MAC addresses.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
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>
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>
179ea7f039f68ae4247a340bfb59fd861e7def12 07-Mar-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Replace efx_rx_is_last_buffer() with a flag

This condition is brittle and we have lots of flags to spare.

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>
b74e3e8cd6f952faf8797fca81a5a2ceace6b9aa 30-Jan-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Update RX buffer address together with length

Adjust rx_buf->page_offset when we eat the RX hash prefix. Remove
efx_rx_buf_offset(), which is now redundant.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
9bc2fc9b5272cc888fb10d5839f7188fa0bfdc90 30-Jan-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Make RX queue descriptor counts unsigned for consistency

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>
80c2e716d555912168f93853f96a24d0de75897b 23-Jan-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Document current usage of efx_rx_buffer::len and efx_nic::rx_buffer_len

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>
4a74dc65e3ad825a66dfbcb256f98c550f96445b 05-Mar-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Allow efx_channel_type::receive_skb() to reject a packet

Instead of having efx_ptp_rx() call netif_receive_skb() for an invalid
PTP packet, make it return false for rejected packets and have
efx_rx_deliver() pass them up.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
b590ace09d51cd39744e0f7662c5e4a0d1b5d952 11-Jan-2013 Ben Hutchings <bhutchings@solarflare.com> sfc: Fix efx_rx_buf_offset() in the presence of swiotlb

We assume that the mapping between DMA and virtual addresses is done
on whole pages, so we can find the page offset of an RX buffer using
the lower bits of the DMA address. However, swiotlb maps in units of
2K, breaking this assumption.

Add an explicit page_offset field to struct efx_rx_buffer.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
525d9e824018cd7cc8d8d44832ddcd363abfe6e1 02-Oct-2012 Daniel Pieczko <dpieczko@solarflare.com> sfc: Work-around flush timeout when flushes have completed

We sometimes hit a "failed to flush" timeout on some TX queues, but the
flushes have completed and the flush completion events seem to go missing.
In this case, we can check the TX_DESC_PTR_TBL register and drain the
queues if the flushes had finished.

[bwh: Minor fixes to coding style]
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
d5e8cc6c946e0857826dcfbb3585068858445bfe 06-Sep-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Really disable flow control while flushing

Receiving pause frames can block TX queue flushes. Earlier changes
work around this by reconfiguring the MAC during flushes for VFs, but
during flushes for the PF we would only change the fc_disable counter.
Unless the MAC is reconfigured for some other reason during the flush
(which I would not expect to happen) this had no effect at all.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
a24006ed12616bde1bbdb26868495906a212d8dc 31-Oct-2012 Ben Hutchings <bhutchings@solarflare.com> ptp: Enable clock drivers along with associated net/PHY drivers

Where a PTP clock driver is associated with a net or PHY driver, it
should be enabled automatically whenever that driver is enabled.
Therefore:

- Make PTP clock drivers select rather than depending on PTP_1588_CLOCK
- Remove separate boolean options for PTP clock drivers that are built
as part of net driver modules. (This also fixes cases where the PTP
subsystem is wrongly forced to be built-in.)
- Set 'default y' for PTP clock drivers that depend on specific net
drivers but are built separately

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
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>
25ce200215666956d96d1a62a20c75a2f3b9d38e 17-Jul-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Bump version to 3.2

The key new feature for 3.2 is PTP support.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
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>
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>
f7251a9ce936f1006fbfdef63dbe42ae5e0fee7c 17-May-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Simplify TSO header buffer allocation

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: 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>
7668ff9c2ad7d354655e23afa836a92d54d2ea63 17-May-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Refactor struct efx_tx_buffer to use a flags field

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: Ben Hutchings <bhutchings@solarflare.com>
d4f2cecce138c34960c467d0ae38a6d4bcd6af7b 04-Jul-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Disable VF queues during register self-test

Currently VF queues and drivers may remain active during this test.
This could cause memory corruption or spurious test failures.
Therefore we reset the port/function before running these tests on
Siena.

On Falcon this doesn't work: we have to do some additional
initialisation before some blocks will work again. So refactor the
reset/register-test sequence into an efx_nic_type method so
efx_selftest() doesn't have to consider such quirks.

In the process, fix another minor bug: Siena does not have an
'invisible' reset and the self-test currently fails to push the PHY
configuration after resetting. Passing RESET_TYPE_ALL to
efx_reset_{down,up}() fixes this.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
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>
49ce9c2cda18f62b13055dc715e7b514157c2da8 10-Jul-2012 Ben Hutchings <bhutchings@solarflare.com> drivers/net/ethernet: Fix (nearly-)kernel-doc comments for various functions

Fix incorrect start markers, wrapped summary lines, missing section
breaks, incorrect separators, and some name mismatches. Delete
a few that are content-free.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Acked-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
c087bd2cfdaf334d7d0c32bd1fcc1a23d5b88973 01-May-2012 Stuart Hodgson <smhodgson@solarflare.com> sfc: Added support for new ethtool APIs for obtaining module eeprom

Currently allows for SFP+ eeprom to be returned using the ethtool API.
This can be extended in future to handle different eeprom formats
and sizes

Signed-off-by: Stuart Hodgson <smhodgson@solarflare.com>
[bwh: Drop redundant validation, comment, whitespace]
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
da9ca505829f6c270b239536b1b169644d7cf072 11-Apr-2012 David Riddoch <driddoch@solarflare.com> sfc: Fill RX rings completely full, rather than to 95% full

There was no runtime control of the fast_fill_limit in any case, so purged
that field.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
58f7e57d11b99575ddb0a3ee9baf7551f10bc3dd 29-Feb-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Remove efx_channel::last_eventq_read_ptr

This member has never been used in a production version of the driver.

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>
73e0026fb2bee4f2ca85c702040e143ec504eaa6 23-Feb-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Correct efx_for_each_possible_channel_tx_queue() to skip non-TX channels

efx_for_each_possible_channel_tx_queue() should do nothing for RX-only
or extra channels. The current definition results in allocating
additional unused hardware TX queues when using the mqprio qdisc and
either separate_tx_channels or SR-IOV.

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>
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>
5bbe2f4f64cc7f6da6390035dcfc42b14bd80484 14-Feb-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Make buffer table indices and counts consistently unsigned

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
a606f4325dca6950996abbae452d33f2af095f39 23-May-2011 Steve Hodgson <shodgson@solarflare.com> sfc: Disable flow control during flushes

The TX DMA engine issues upstream read requests when there is room in
the TX FIFO for the completion. However, the fetches for the rest of
the packet might be delayed by any back pressure. Since a flush must
wait for an EOP, the entire flush may be delayed by back pressure.

Mitigate this by disabling flow control before the flushes are
started. Since PF and VF flushes run in parallel introduce
fc_disable, a reference count of the number of flushes outstanding.

The same principle could be applied to Falcon, but that
would bring with it its own testing.

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>
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>
f9c762500ae77ab8940094be1325c8a2a1c8e5f5 12-Oct-2011 Ben Hutchings <bhutchings@solarflare.com> sfc: Make all MAC statistics consistently 64 bits wide

Currently we use type u64 for byte counts, which can very quickly
exceed 2^32, and unsigned long for packet counts, which do not. But
it can still take only 20-something minutes to send or receive 2^32
packets, and not all tools properly handle overflow even if they
sample more often than this.

The MAC statistics are all updated synchronously, so it costs very
little to make them all 64-bit regardless of native word size.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
b249513e8ba3ca8bc2c87e78eb6e302d5d8abd6f 09-Jan-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Remove obsolete function efx_dev_name()

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
1646a6f352a6f70fcca828589ed04797aa09d494 05-Jan-2012 Ben Hutchings <bhutchings@solarflare.com> sfc: Clean up test interrupt handling

Interrupts are normally generated by the event queues, moderated by
timers. However, they may also be triggered by detection of a 'fatal'
error condition (e.g. memory parity error) or by the host writing to
certain CSR fields as part of a self-test.

The IRQ level/index used for these on Falcon rev B0 and Siena is set
by the KER_INT_LEVE_SEL field and cached by the driver in
efx_nic::fatal_irq_level. Since this value is also relevant to
self-tests rename the field to just 'irq_level'.

Avoid unnecessary cache traffic by using a per-channel 'last_irq_cpu'
field and only writing to the per-controller field when the interrupt
matches efx_nic::irq_level. Remove the volatile qualifier and use
ACCESS_ONCE in the places we read these fields.

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>
5f3f9d6c441faa323444b2f6b092d630fcd7d04c 04-Nov-2011 Ben Hutchings <bhutchings@solarflare.com> sfc: Consistently test DEBUG macro, not EFX_ENABLE_DEBUG

The netif_dbg() macro is defined in <linux/netdevice.h>. If the DEBUG
macro is defined, it logs a message at 'debug' level, otherwise it
does nothing.

In net_driver.h we define DEBUG if EFX_ENABLE_DEBUG is defined, but
this is too late for those source files that already got a
definition of netif_dbg() by including <linux/netdevice.h>

Get rid of EFX_ENABLE_DEBUG, and only define and test DEBUG.

In mtd.c, we do not use DEBUG as a condition flag but are forced to
use the DEBUG macro-function from <linux/mtd/mtd.h>. Undefine DEBUG
before including it.

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>
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>
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>
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>