drivers/net/ethernet/sfc/falcon/farch.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/sfc/falcon/farch.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/sfc/falcon/farch.c- Extension
.c- Size
- 85430 bytes
- Lines
- 2860
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/delay.hlinux/interrupt.hlinux/pci.hlinux/module.hlinux/seq_file.hlinux/crc32.hnet_driver.hbitfield.hefx.hnic.hfarch_regs.hio.hworkarounds.h
Detected Declarations
struct ef4_farch_filter_specstruct ef4_farch_filter_tablestruct ef4_farch_filter_stateenum ef4_farch_filter_typeenum ef4_farch_filter_table_idenum ef4_farch_filter_indexfunction ef4_write_buf_tblfunction ef4_masked_compare_owordfunction ef4_farch_test_registersfunction bufferfunction ef4_fini_special_bufferfunction ef4_alloc_special_bufferfunction ef4_free_special_bufferfunction ef4_farch_notify_tx_descfunction ef4_farch_push_tx_descfunction ringfunction ef4_farch_tx_limit_lenfunction ef4_farch_tx_probefunction ef4_farch_tx_initfunction ef4_farch_flush_tx_queuefunction ef4_farch_tx_finifunction ef4_farch_tx_removefunction ef4_farch_build_rx_descfunction ef4_farch_rx_writefunction ef4_farch_rx_probefunction ef4_farch_rx_initfunction ef4_farch_flush_rx_queuefunction ef4_farch_rx_finifunction ef4_farch_rx_removefunction ef4_farch_flush_wakefunction ef4_check_tx_flush_completefunction ef4_for_each_channelfunction ef4_farch_do_flushfunction ef4_for_each_channelfunction ef4_for_each_channel_rx_queuefunction ef4_farch_fini_dmaqfunction ef4_for_each_channelfunction ef4_farch_finish_flrfunction ef4_farch_ev_read_ackfunction ef4_farch_generate_eventfunction ef4_farch_magic_eventfunction ef4_farch_handle_tx_eventfunction ef4_farch_handle_rx_not_okfunction ef4_farch_handle_rx_bad_indexfunction ef4_farch_handle_rx_eventfunction unlikelyfunction ef4_farch_handle_tx_flush_donefunction ef4_farch_handle_rx_flush_done
Annotated Snippet
struct ef4_farch_filter_spec {
u8 type:4;
u8 priority:4;
u8 flags;
u16 dmaq_id;
u32 data[3];
};
struct ef4_farch_filter_table {
enum ef4_farch_filter_table_id id;
u32 offset; /* address of table relative to BAR */
unsigned size; /* number of entries */
unsigned step; /* step between entries */
unsigned used; /* number currently used */
unsigned long *used_bitmap;
struct ef4_farch_filter_spec *spec;
unsigned search_limit[EF4_FARCH_FILTER_TYPE_COUNT];
};
struct ef4_farch_filter_state {
struct ef4_farch_filter_table table[EF4_FARCH_FILTER_TABLE_COUNT];
};
static void
ef4_farch_filter_table_clear_entry(struct ef4_nic *efx,
struct ef4_farch_filter_table *table,
unsigned int filter_idx);
/* The filter hash function is LFSR polynomial x^16 + x^3 + 1 of a 32-bit
* key derived from the n-tuple. The initial LFSR state is 0xffff. */
static u16 ef4_farch_filter_hash(u32 key)
{
u16 tmp;
/* First 16 rounds */
tmp = 0x1fff ^ key >> 16;
tmp = tmp ^ tmp >> 3 ^ tmp >> 6;
tmp = tmp ^ tmp >> 9;
/* Last 16 rounds */
tmp = tmp ^ tmp << 13 ^ key;
tmp = tmp ^ tmp >> 3 ^ tmp >> 6;
return tmp ^ tmp >> 9;
}
/* To allow for hash collisions, filter search continues at these
* increments from the first possible entry selected by the hash. */
static u16 ef4_farch_filter_increment(u32 key)
{
return key * 2 - 1;
}
static enum ef4_farch_filter_table_id
ef4_farch_filter_spec_table_id(const struct ef4_farch_filter_spec *spec)
{
BUILD_BUG_ON(EF4_FARCH_FILTER_TABLE_RX_IP !=
(EF4_FARCH_FILTER_TCP_FULL >> 2));
BUILD_BUG_ON(EF4_FARCH_FILTER_TABLE_RX_IP !=
(EF4_FARCH_FILTER_TCP_WILD >> 2));
BUILD_BUG_ON(EF4_FARCH_FILTER_TABLE_RX_IP !=
(EF4_FARCH_FILTER_UDP_FULL >> 2));
BUILD_BUG_ON(EF4_FARCH_FILTER_TABLE_RX_IP !=
(EF4_FARCH_FILTER_UDP_WILD >> 2));
BUILD_BUG_ON(EF4_FARCH_FILTER_TABLE_RX_MAC !=
(EF4_FARCH_FILTER_MAC_FULL >> 2));
BUILD_BUG_ON(EF4_FARCH_FILTER_TABLE_RX_MAC !=
(EF4_FARCH_FILTER_MAC_WILD >> 2));
BUILD_BUG_ON(EF4_FARCH_FILTER_TABLE_TX_MAC !=
EF4_FARCH_FILTER_TABLE_RX_MAC + 2);
return (spec->type >> 2) + ((spec->flags & EF4_FILTER_FLAG_TX) ? 2 : 0);
}
static void ef4_farch_filter_push_rx_config(struct ef4_nic *efx)
{
struct ef4_farch_filter_state *state = efx->filter_state;
struct ef4_farch_filter_table *table;
ef4_oword_t filter_ctl;
ef4_reado(efx, &filter_ctl, FR_BZ_RX_FILTER_CTL);
table = &state->table[EF4_FARCH_FILTER_TABLE_RX_IP];
EF4_SET_OWORD_FIELD(filter_ctl, FRF_BZ_TCP_FULL_SRCH_LIMIT,
table->search_limit[EF4_FARCH_FILTER_TCP_FULL] +
EF4_FARCH_FILTER_CTL_SRCH_FUDGE_FULL);
EF4_SET_OWORD_FIELD(filter_ctl, FRF_BZ_TCP_WILD_SRCH_LIMIT,
table->search_limit[EF4_FARCH_FILTER_TCP_WILD] +
EF4_FARCH_FILTER_CTL_SRCH_FUDGE_WILD);
EF4_SET_OWORD_FIELD(filter_ctl, FRF_BZ_UDP_FULL_SRCH_LIMIT,
table->search_limit[EF4_FARCH_FILTER_UDP_FULL] +
EF4_FARCH_FILTER_CTL_SRCH_FUDGE_FULL);
EF4_SET_OWORD_FIELD(filter_ctl, FRF_BZ_UDP_WILD_SRCH_LIMIT,
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/pci.h`, `linux/module.h`, `linux/seq_file.h`, `linux/crc32.h`, `net_driver.h`.
- Detected declarations: `struct ef4_farch_filter_spec`, `struct ef4_farch_filter_table`, `struct ef4_farch_filter_state`, `enum ef4_farch_filter_type`, `enum ef4_farch_filter_table_id`, `enum ef4_farch_filter_index`, `function ef4_write_buf_tbl`, `function ef4_masked_compare_oword`, `function ef4_farch_test_registers`, `function buffer`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.