drivers/net/ethernet/fungible/funeth/funeth_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/fungible/funeth/funeth_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/fungible/funeth/funeth_main.c- Extension
.c- Size
- 52322 bytes
- Lines
- 2070
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/bpf.hlinux/crash_dump.hlinux/etherdevice.hlinux/ethtool.hlinux/filter.hlinux/idr.hlinux/if_vlan.hlinux/module.hlinux/netdevice.hlinux/pci.hlinux/rtnetlink.hlinux/inetdevice.hfuneth.hfuneth_devlink.hfuneth_ktls.hfun_port.hfun_queue.hfuneth_txrx.h
Detected Declarations
function fun_port_write_cmdsfunction fun_port_write_cmdfunction fun_port_read_cmdsfunction fun_port_read_cmdfunction fun_report_linkfunction fun_adi_writefunction fun_config_rssfunction fun_destroy_rssfunction fun_irq_aff_notifyfunction fun_irq_aff_releasefunction fun_free_qirqfunction fun_prune_queue_irqsfunction xa_for_eachfunction fun_alloc_queue_irqsfunction free_txqsfunction alloc_txqsfunction free_rxqsfunction alloc_rxqsfunction free_xdpqsfunction fun_free_ringsfunction fun_alloc_ringsfunction fun_advance_ring_statefunction fun_port_createfunction fun_port_destroyfunction fun_eth_createfunction fun_vi_createfunction idfunction fun_queue_irq_handlerfunction fun_enable_irqsfunction xa_for_eachfunction xa_for_eachfunction fun_disable_one_irqfunction fun_disable_irqsfunction fun_downfunction fun_upfunction funeth_openfunction funeth_closefunction fun_get_stats64function fun_change_mtufunction fun_set_macaddrfunction fun_get_port_attributesfunction fun_hwtstamp_getfunction fun_hwtstamp_setfunction fun_enter_xdpfunction fun_end_xdpfunction fun_xdp_setupfunction fun_xdpfunction fun_init_vports
Annotated Snippet
static const struct net_device_ops fun_netdev_ops = {
.ndo_open = funeth_open,
.ndo_stop = funeth_close,
.ndo_start_xmit = fun_start_xmit,
.ndo_get_stats64 = fun_get_stats64,
.ndo_change_mtu = fun_change_mtu,
.ndo_set_mac_address = fun_set_macaddr,
.ndo_validate_addr = eth_validate_addr,
.ndo_uninit = fun_uninit,
.ndo_bpf = fun_xdp,
.ndo_xdp_xmit = fun_xdp_xmit_frames,
.ndo_set_vf_mac = fun_set_vf_mac,
.ndo_set_vf_vlan = fun_set_vf_vlan,
.ndo_set_vf_rate = fun_set_vf_rate,
.ndo_get_vf_config = fun_get_vf_config,
.ndo_hwtstamp_get = fun_hwtstamp_get,
.ndo_hwtstamp_set = fun_hwtstamp_set,
};
#define GSO_ENCAP_FLAGS (NETIF_F_GSO_GRE | NETIF_F_GSO_IPXIP4 | \
NETIF_F_GSO_IPXIP6 | NETIF_F_GSO_UDP_TUNNEL | \
NETIF_F_GSO_UDP_TUNNEL_CSUM)
#define TSO_FLAGS (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN | \
NETIF_F_GSO_UDP_L4)
#define VLAN_FEAT (NETIF_F_SG | NETIF_F_HW_CSUM | TSO_FLAGS | \
GSO_ENCAP_FLAGS | NETIF_F_HIGHDMA)
static void fun_dflt_rss_indir(struct funeth_priv *fp, unsigned int nrx)
{
unsigned int i;
for (i = 0; i < fp->indir_table_nentries; i++)
fp->indir_table[i] = ethtool_rxfh_indir_default(i, nrx);
}
/* Reset the RSS indirection table to equal distribution across the current
* number of Rx queues. Called at init time and whenever the number of Rx
* queues changes subsequently. Note that this may also resize the indirection
* table.
*/
static void fun_reset_rss_indir(struct net_device *dev, unsigned int nrx)
{
struct funeth_priv *fp = netdev_priv(dev);
if (!fp->rss_cfg)
return;
/* Set the table size to the max possible that allows an equal number
* of occurrences of each CQ.
*/
fp->indir_table_nentries = rounddown(FUN_ETH_RSS_MAX_INDIR_ENT, nrx);
fun_dflt_rss_indir(fp, nrx);
}
/* Update the RSS LUT to contain only queues in [0, nrx). Normally this will
* update the LUT to an equal distribution among nrx queues, If @only_if_needed
* is set the LUT is left unchanged if it already does not reference any queues
* >= nrx.
*/
static int fun_rss_set_qnum(struct net_device *dev, unsigned int nrx,
bool only_if_needed)
{
struct funeth_priv *fp = netdev_priv(dev);
u32 old_lut[FUN_ETH_RSS_MAX_INDIR_ENT];
unsigned int i, oldsz;
int err;
if (!fp->rss_cfg)
return 0;
if (only_if_needed) {
for (i = 0; i < fp->indir_table_nentries; i++)
if (fp->indir_table[i] >= nrx)
break;
if (i >= fp->indir_table_nentries)
return 0;
}
memcpy(old_lut, fp->indir_table, sizeof(old_lut));
oldsz = fp->indir_table_nentries;
fun_reset_rss_indir(dev, nrx);
err = fun_config_rss(dev, fp->hash_algo, fp->rss_key,
fp->indir_table, FUN_ADMIN_SUBOP_MODIFY);
if (!err)
return 0;
memcpy(fp->indir_table, old_lut, sizeof(old_lut));
fp->indir_table_nentries = oldsz;
Annotation
- Immediate include surface: `linux/bpf.h`, `linux/crash_dump.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/filter.h`, `linux/idr.h`, `linux/if_vlan.h`, `linux/module.h`.
- Detected declarations: `function fun_port_write_cmds`, `function fun_port_write_cmd`, `function fun_port_read_cmds`, `function fun_port_read_cmd`, `function fun_report_link`, `function fun_adi_write`, `function fun_config_rss`, `function fun_destroy_rss`, `function fun_irq_aff_notify`, `function fun_irq_aff_release`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern 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.