drivers/net/ethernet/sfc/ef10_sriov.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/sfc/ef10_sriov.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/sfc/ef10_sriov.c- Extension
.c- Size
- 20303 bytes
- Lines
- 807
- 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.
- 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/etherdevice.hlinux/pci.hlinux/module.hnet_driver.hef10_sriov.hefx.hnic.hmcdi_pcol.h
Detected Declarations
function efx_ef10_evb_port_assignfunction efx_ef10_vswitch_allocfunction efx_ef10_vswitch_freefunction efx_ef10_vport_allocfunction efx_ef10_vport_freefunction efx_ef10_sriov_free_vf_vportsfunction efx_ef10_sriov_free_vf_vswitchingfunction efx_ef10_sriov_assign_vf_vportfunction efx_ef10_sriov_alloc_vf_vswitchingfunction efx_ef10_sriov_restore_vf_vswitchingfunction efx_ef10_vadaptor_alloc_set_featuresfunction efx_ef10_vswitching_probe_pffunction efx_ef10_vswitching_probe_vffunction efx_ef10_vswitching_restore_pffunction efx_ef10_vswitching_restore_vffunction efx_ef10_vswitching_remove_pffunction efx_ef10_vswitching_remove_vffunction efx_ef10_pci_sriov_enablefunction guestfunction efx_ef10_sriov_configurefunction efx_ef10_sriov_initfunction efx_ef10_sriov_finifunction efx_ef10_vport_del_vf_macfunction efx_ef10_sriov_set_vf_macfunction efx_ef10_sriov_set_vf_vlanfunction efx_ef10_sriov_set_privilege_maskfunction efx_ef10_sriov_set_vf_spoofchkfunction efx_ef10_sriov_set_vf_link_statefunction efx_ef10_sriov_get_vf_config
Annotated Snippet
if (vf->vport_assigned) {
efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, i);
vf->vport_assigned = 0;
}
if (!is_zero_ether_addr(vf->mac)) {
efx_ef10_vport_del_mac(efx, vf->vport_id, vf->mac);
eth_zero_addr(vf->mac);
}
if (vf->vport_id) {
efx_ef10_vport_free(efx, vf->vport_id);
vf->vport_id = 0;
}
vf->efx = NULL;
}
}
static void efx_ef10_sriov_free_vf_vswitching(struct efx_nic *efx)
{
struct efx_ef10_nic_data *nic_data = efx->nic_data;
efx_ef10_sriov_free_vf_vports(efx);
kfree(nic_data->vf);
nic_data->vf = NULL;
}
static int efx_ef10_sriov_assign_vf_vport(struct efx_nic *efx,
unsigned int vf_i)
{
struct efx_ef10_nic_data *nic_data = efx->nic_data;
struct ef10_vf *vf = nic_data->vf + vf_i;
int rc;
if (WARN_ON_ONCE(!nic_data->vf))
return -EOPNOTSUPP;
rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED,
MC_CMD_VPORT_ALLOC_IN_VPORT_TYPE_NORMAL,
vf->vlan, &vf->vport_id);
if (rc)
return rc;
rc = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac);
if (rc) {
eth_zero_addr(vf->mac);
return rc;
}
rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i);
if (rc)
return rc;
vf->vport_assigned = 1;
return 0;
}
static int efx_ef10_sriov_alloc_vf_vswitching(struct efx_nic *efx)
{
struct efx_ef10_nic_data *nic_data = efx->nic_data;
unsigned int i;
int rc;
nic_data->vf = kzalloc_objs(struct ef10_vf, efx->vf_count);
if (!nic_data->vf)
return -ENOMEM;
for (i = 0; i < efx->vf_count; i++) {
eth_random_addr(nic_data->vf[i].mac);
nic_data->vf[i].efx = NULL;
nic_data->vf[i].vlan = EFX_EF10_NO_VLAN;
rc = efx_ef10_sriov_assign_vf_vport(efx, i);
if (rc)
goto fail;
}
return 0;
fail:
efx_ef10_sriov_free_vf_vswitching(efx);
return rc;
}
static int efx_ef10_sriov_restore_vf_vswitching(struct efx_nic *efx)
{
unsigned int i;
int rc;
for (i = 0; i < efx->vf_count; i++) {
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/pci.h`, `linux/module.h`, `net_driver.h`, `ef10_sriov.h`, `efx.h`, `nic.h`, `mcdi_pcol.h`.
- Detected declarations: `function efx_ef10_evb_port_assign`, `function efx_ef10_vswitch_alloc`, `function efx_ef10_vswitch_free`, `function efx_ef10_vport_alloc`, `function efx_ef10_vport_free`, `function efx_ef10_sriov_free_vf_vports`, `function efx_ef10_sriov_free_vf_vswitching`, `function efx_ef10_sriov_assign_vf_vport`, `function efx_ef10_sriov_alloc_vf_vswitching`, `function efx_ef10_sriov_restore_vf_vswitching`.
- 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.
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.