aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/sfc (follow)
AgeCommit message (Collapse)AuthorFilesLines
2013-08-22sfc: Eliminate struct efx_mtdBen Hutchings2-160/+120
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>
2013-08-22sfc: Rename SPI stuff to show that it is Falcon-specificBen Hutchings4-47/+47
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-22sfc: Cleanup Falcon-arch simple MAC filter stateBen Hutchings7-44/+52
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>
2013-08-22sfc: Define and use MCDI_POPULATE_DWORD_{1,2,3,4,5,6,7}Ben Hutchings2-10/+62
There is only one user now, but we're about to add many more. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-22sfc: Add flag for stack-owned RX MAC filtersBen Hutchings2-17/+37
MAC filters inserted on request from the stack (ndo_set_rx_mode) should allow manual steering but not removal. Currently we have a special case for Siena's all-multicast and all-unicast MAC filters, but on EF10 we need to allow for steering of precise MAC filters as well. The EFX_FILTER_FLAG_RX_STACK flag changes the behaviour of replacement and removal requests: - Replacement *of* a filter with this flag never clears the flag but does change steering and saved priority - Replacement *by* a filter with this flag only sets the flag but does not change steering - Removal with priority < EFX_FILTER_PRI_REQUIRED really resets RX steering and saved priority This could support precise MAC filtering on Siena in future. As a side-benefit, the default MAC filters are hidden from ethtool until they are steered. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-22sfc: Refactor Falcon-arch filter removalBen Hutchings1-34/+40
Move the special case for removal of default filters from efx_farch_filter_table_clear_entry() into a wrapper function, efx_farch_filter_table_remove(). Move the existence and priority checks into the latter and use it where appropriate. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-22sfc: Make most filter operations NIC-type-specificBen Hutchings10-1267/+1448
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>
2013-08-22sfc: Refactor Falcon-arch search limit resetBen Hutchings1-29/+30
Currently every call to efx_farch_filter_table_clear_entry() is shortly followed by a conditional reset of the table limits. The new limits (0) are not pushed to hardware until the next filter insertion. Move both the reset and the hardware reconfiguration into efx_farch_filter_table_clear_entry(), and add an explanatory comment. Also, make consistent use of the term 'search limit' for the maximum number of probes the NIC must make when searching for a filter of a particular type. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-22sfc: Split Falcon-arch-specific and common filter stateBen Hutchings2-55/+58
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>
2013-08-22sfc: Extend and abstract efx_filter_spec to cover Huntington/EF10Ben Hutchings3-392/+494
Replace type field with match_flags. Add rss_context and match values covering of most of what is now in the MCDI protocol. Change some fields into bitfields so that the structure size doesn't grow beyond 64 bytes. Ditch the filter decoding functions as it is now easier to pick apart the abstract structure. Rewrite ethtool NFC rule functions to set/get filter match flags and values directly. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-22sfc: Name the RX drop queue IDBen Hutchings2-3/+8
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-22sfc: Rename Falcon-arch filter implementation types and functionsBen Hutchings1-209/+243
The filter table(s) on EF10 are managed by firmware and will need almost entirely separate code. Rename the types and functions used within the existing implementation. The current definition of struct efx_filter_spec is really implementation-specific, so we need to keep it. For now, define a separate structure for the internal representation but leave them identical. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-22sfc: Remove unused filter_flags variables and efx_farch_filter_id_flags()Ben Hutchings1-16/+0
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Do not assume efx_nic_type::ev_fini is idempotentBen Hutchings2-0/+7
efx_fini_eventq() needs to be idempotent but EF10 firmware is picky about queue states. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: EFX_WORKAROUND_ALWAYS is really specific to Falcon-architectureBen Hutchings3-36/+19
The workarounds that currently use EFX_WORKAROUND_ALWAYS are in Falcon-specific or Falcon-arch-specific code, so get rid of the conditions altogether. Add/move comments as appropriate. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Get rid of per-NIC-type phys_addr_channels and mem_map_sizeBen Hutchings4-32/+37
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>
2013-08-21sfc: Update and improve kernel-doc for efx_mcdi_state & efx_mcdi_ifaceBen Hutchings1-11/+9
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Fix race in completion handlingBen Hutchings1-15/+10
When we poll for MCDI request completion, we don't hold the interface lock while setting the response fields in struct efx_mcdi_iface. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Add support for MCDI v2Ben Hutchings6-55/+127
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>
2013-08-21sfc: Update MCDI protocol definitions for EF10Ben Hutchings3-342/+5196
EF10 controllers do not have shared memory for communication with the MC; instead it reads requests and writes responses in host memory, which allows for longer messages. It is also responsible for all datapath control operations and hardware resource allocation, which requires a large number of new commands and adds more possible error cases. MCDI v2 extends the message header to support this. Update the MCDI protocol definition header to include v2 lengths, errors and messages, and a few definitions specific to the SFC9100 family (codenames Farmingdale and Huntington) which is the first generation of EF10. Some messages have been extended, so adjust the code accordingly: - The request for MC_CMD_DRV_ATTACH now includes a datapath firmware ID. This is ignored by Siena but we should fill it in anyway, initially always specifying low-latency datapath. - The response for MC_CMD_GET_LOOPBACK_MODES now includes a 40G field. Accept shorter responses that don't include it. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Translate MCDI error numbers received in eventsBen Hutchings2-29/+37
Currently we only translate error codes in efx_mcdi_poll(), but we also need to do so in efx_mcdi_ev_cpl(). The reason we didn't notice before is that the MC firmware error codes are mostly taken from Unix/Linux and no translation is necessary on most architectures. Make sure we notice any future failure by changing the sign of resprc (matching the kernel convention) and BUG if it's ever positive at command completion. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Move and rename Falcon/Siena common NIC operationsBen Hutchings9-1858/+2088
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>
2013-08-21sfc: Refactor queue teardown sequence to allow for EF10 flush behaviourBen Hutchings9-48/+59
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>
2013-08-21sfc: Remove bogus call to efx_release_tx_buffers()Ben Hutchings1-11/+0
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>
2013-08-21sfc: Stop RX refill before flushing RX queuesBen Hutchings4-9/+13
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>
2013-08-21sfc: Limit scope of a Falcon A1 IRQ workaroundBen Hutchings3-10/+2
We unconditionally acknowledge legacy interrupts just before disabling them. This workaround is needed on Falcon A1 but probably not on later chips where the legacy interrupt mechanism is different. It was also originally done after the IRQ handler was removed, not before. Restore the original behaviour for Falcon A1 only by doing this acknowledgement in the efx_nic_type::fini operation. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Rework IRQ enable/disableBen Hutchings4-59/+112
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>
2013-08-21sfc: Remove efx_process_channel_now()Ben Hutchings4-81/+3
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>
2013-08-21sfc: Rename Falcon-architecture register definitionsBen Hutchings8-10/+10
The EF10 architecture has a very different register layout from previous controllers, so we'll use separate files for the two sets of register definitions. Use 'farch' as an abbreviation for Falcon-architecture. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Make struct efx_special_buffer less specialBen Hutchings2-43/+37
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>
2013-08-21sfc: Add GFP flags to efx_nic_alloc_buffer() and make most callers allow blockingBen Hutchings9-14/+19
Most call sites for efx_nic_alloc_buffer() are part of the probe or reconfiguration paths and can allocate with GFP_KERNEL. A few others should use GFP_NOIO (I think). Only one is in atomic context and must use the current GFP_ATOMIC. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Make MCDI independent of SienaBen Hutchings5-77/+157
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>
2013-08-21sfc: Make efx_mcdi_init() call efx_mcdi_handle_assertion()Ben Hutchings3-9/+6
This should probably be done during MCDI initialisation for any NIC. Change efx_mcdi_init() to return an error code. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Collect all MCDI port functions into mcdi_port.cBen Hutchings7-306/+242
Collect together MCDI port functions from mcdi.c, mcdi_mac.c, mcdi_phy.c and siena.c. Rename the 'siena' functions accordingly. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Move efx_mcdi_mac_reconfigure() to siena.c and renameBen Hutchings3-23/+22
EF10 does not include a multicast hash filter, so this function is specific to Siena. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Move siena_reset_hw() and siena_map_reset_reason() into MCDI moduleBen Hutchings3-31/+30
These implementations should work for EF10 too. Rename them accordingly. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Add and use MCDI_SET_QWORD() and MCDI_SET_ARRAY_QWORD()Ben Hutchings4-29/+34
No need to keep open-coding the assignment of high and low dwords. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Ensure MCDI buffers, but not lengths, are dword alignedBen Hutchings3-31/+46
We currently require that MCDI request and response lengths are multiples of 4 bytes, because we will copy dwords in and out of shared memory and we want to be sure we won't read or write out of bounds. But all we really need to know is that there is sufficient padding for that. Also, we should ensure that buffers are dword-aligned, as on some architectures misaligned access will result in data corruption or a crash. Change the buffer type to array-of-efx_dword_t and remove the requirement that the lengths are multiples of 4. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Use proper macros to declare and access MCDI arraysBen Hutchings6-94/+85
A few functions are using heap buffers; change them to use stack buffers as we really don't need to resort to the heap for a 252 byte buffer in process context. MC_CMD_MEMCPY is quite weird in that it can use inline data placed in the request buffer after the array of records. Thus there are two variable-length arrays and we can't use the normal accessors for the second. So we have to use _MCDI_PTR() in efx_sriov_memcpy(). Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Introduce and use MCDI_CTL_SDU_LEN_MAX_V1 macro for Siena-specific codeBen Hutchings2-4/+7
The MCDI version 2 protocol supports larger payloads, but will not be implemented on Siena. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Fill out the set of MCDI accessorsBen Hutchings1-10/+32
We need to access arrays of 16-bit words and 32-bit dwords in MCDI buffers based on the MCDI protocol definitions. We should also be able to read and write fields within structures, without specifying an array index each time. So add MCDI_FIELD() and make MCDI_ARRAY_FIELD() use it. Also add MCDI_SET_FIELD(). Split MCDI_ARRAY_PTR() into MCDI_ARRAY_STRUCT_PTR() and _MCDI_ARRAY_PTR(), which are currently identical but will diverge in later changes. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Rationalise MCDI buffer accessorsBen Hutchings1-26/+20
Add _MCDI_DWORD() which yields an lvalue for the given dword field and change MCDI_DWORD(), MCDI_SET_DWORD() and MCDI_QWORD() to use it. Fold the rather trivial MCDI_PTR2() into MCDI_PTR() and _MCDI_DWORD(). Remove MCDI_SET_DWORD2() and MCDI_QWORD2(). MCDI_DWORD2() should also go, but it still has one user which we'll get rid of later. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Introduce and use MCDI_DECLARE_BUF macroBen Hutchings7-56/+66
MCDI_DECLARE_BUF declares a variable as an MCDI buffer of the requested length, adding any necessary padding. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Move more Falcon-specific code and definitions into falcon.cBen Hutchings5-666/+538
In particular, fold in the whole of falcon_xmac.c. Drop some entirely unused definitions. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Move details of a Falcon bug workaround out of ethtool.cBen Hutchings5-23/+31
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Use efx_mcdi_mon() to find efx_mcdi_mon structure from efx_nicBen Hutchings1-2/+1
This needs to be done before we separate MCDI from siena_nic_data. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: const-qualify source pointers for MMIO write functionsBen Hutchings1-8/+10
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-08-21sfc: Fix lookup of default RX MAC filters when steered using ethtoolBen Hutchings1-1/+1
commit 385904f819e3 ('sfc: Don't use efx_filter_{build,hash,increment}() for default MAC filters') used the wrong name to find the index of default RX MAC filters at insertion/ update time. This could result in memory corruption and would in any case silently fail to update the filter. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2013-07-22sfc: Enable RX scatter for flows steered by RFSBen Hutchings1-1/+3
Received packets are only scattered if this is enabled in both the matching filter and the receiving queue. This was not being done for filters inserted for RFS, so any packet requiring more than a single descriptor was dropped. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2013-07-05sfc: Fix memory leak when discarding scattered packetsBen Hutchings1-7/+20
Commit 2768935a4660 ('sfc: reuse pages to avoid DMA mapping/unmapping costs') did not fully take account of DMA scattering which was introduced immediately before. If a received packet is invalid and must be discarded, we only drop a reference to the first buffer's page, but we need to drop a reference for each buffer the packet used. I think this bug was missed partly because efx_recycle_rx_buffers() was not renamed and so no longer does what its name says. It does not change the state of buffers, but only prepares the underlying pages for recycling. Rename it accordingly. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>