drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c- Extension
.c- Size
- 52592 bytes
- Lines
- 1982
- 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/types.hlinux/module.hlinux/pci.hlinux/netdevice.hlinux/vmalloc.hlinux/string.hlinux/in.hlinux/ip.hlinux/tcp.hlinux/ipv6.hlinux/if_bridge.hlinux/if_vlan.hixgbe.hixgbe_type.hixgbe_mbx.hixgbe_sriov.h
Detected Declarations
function ixgbe_alloc_vf_macvlansfunction __ixgbe_enable_sriovfunction ixgbe_get_vfsfunction ixgbe_enable_sriovfunction ixgbe_disable_sriovfunction ixgbe_pci_sriov_enablefunction ixgbe_pci_sriov_disablefunction ixgbe_pci_sriov_configurefunction ixgbe_set_vf_multicastsfunction ixgbe_restore_vf_multicastsfunction ixgbe_set_vf_vlanfunction ixgbe_set_vf_lpefunction ixgbe_set_vmolrfunction ixgbe_clear_vmvirfunction ixgbe_clear_vf_vlansfunction ixgbe_set_vf_macvlanfunction list_for_each_entryfunction ixgbe_vf_reset_eventfunction ixgbe_vf_clear_mbxfunction ixgbe_set_vf_macfunction ixgbe_vf_configurationfunction ixgbe_write_qdefunction ixgbe_set_vf_rx_txfunction ixgbe_vf_reset_msgfunction ixgbe_set_vf_mac_addrfunction ixgbe_set_vf_vlan_msgfunction ixgbe_set_vf_macvlan_msgfunction ixgbe_negotiate_vf_apifunction ixgbe_get_vf_queuesfunction ixgbe_get_vf_retafunction ixgbe_get_vf_rss_keyfunction ixgbe_update_vf_xcast_modefunction ixgbe_get_vf_link_statefunction ixgbe_send_vf_link_statusfunction ixgbe_negotiate_vf_featuresfunction ixgbe_rcv_msg_from_vffunction ixgbe_rcv_ack_from_vffunction ixgbe_check_mdd_eventfunction ixgbe_msg_taskfunction ixgbe_ping_vffunction ixgbe_ping_all_vfsfunction ixgbe_set_all_vfsfunction ixgbe_ndo_set_vf_macfunction ixgbe_enable_port_vlanfunction ixgbe_disable_port_vlanfunction ixgbe_ndo_set_vf_vlanfunction ixgbe_link_mbpsfunction ixgbe_set_vf_rate_limit
Annotated Snippet
if (err) {
e_err(probe, "Failed to enable PCI sriov: %d\n", err);
return;
}
}
if (!__ixgbe_enable_sriov(adapter, num_vfs)) {
ixgbe_get_vfs(adapter);
return;
}
/* If we have gotten to this point then there is no memory available
* to manage the VF devices - print message and bail.
*/
e_err(probe, "Unable to allocate memory for VF Data Storage - "
"SRIOV disabled\n");
ixgbe_disable_sriov(adapter);
}
#endif /* #ifdef CONFIG_PCI_IOV */
int ixgbe_disable_sriov(struct ixgbe_adapter *adapter)
{
unsigned int num_vfs = adapter->num_vfs, vf;
struct ixgbe_hw *hw = &adapter->hw;
unsigned long flags;
int rss;
spin_lock_irqsave(&adapter->vfs_lock, flags);
/* set num VFs to 0 to prevent access to vfinfo */
adapter->num_vfs = 0;
spin_unlock_irqrestore(&adapter->vfs_lock, flags);
/* put the reference to all of the vf devices */
for (vf = 0; vf < num_vfs; ++vf) {
struct pci_dev *vfdev = adapter->vfinfo[vf].vfdev;
if (!vfdev)
continue;
adapter->vfinfo[vf].vfdev = NULL;
pci_dev_put(vfdev);
}
/* free VF control structures */
kfree(adapter->vfinfo);
adapter->vfinfo = NULL;
/* free macvlan list */
kfree(adapter->mv_list);
adapter->mv_list = NULL;
/* if SR-IOV is already disabled then there is nothing to do */
if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
return 0;
if (hw->mac.ops.disable_mdd)
hw->mac.ops.disable_mdd(hw);
#ifdef CONFIG_PCI_IOV
/*
* If our VFs are assigned we cannot shut down SR-IOV
* without causing issues, so just leave the hardware
* available but disabled
*/
if (pci_vfs_assigned(adapter->pdev)) {
e_dev_warn("Unloading driver while VFs are assigned - VFs will not be deallocated\n");
return -EPERM;
}
/* disable iov and allow time for transactions to clear */
pci_disable_sriov(adapter->pdev);
#endif
/* Disable VMDq flag so device will be set in VM mode */
if (bitmap_weight(adapter->fwd_bitmask, adapter->num_rx_pools) == 1) {
adapter->flags &= ~IXGBE_FLAG_VMDQ_ENABLED;
adapter->flags &= ~IXGBE_FLAG_SRIOV_ENABLED;
rss = min_t(int, ixgbe_max_rss_indices(adapter),
num_online_cpus());
} else {
rss = min_t(int, IXGBE_MAX_L2A_QUEUES, num_online_cpus());
}
adapter->ring_feature[RING_F_VMDQ].offset = 0;
adapter->ring_feature[RING_F_RSS].limit = rss;
/* take a breather then clean up driver data */
msleep(100);
return 0;
}
static int ixgbe_pci_sriov_enable(struct pci_dev *dev, int num_vfs)
Annotation
- Immediate include surface: `linux/types.h`, `linux/module.h`, `linux/pci.h`, `linux/netdevice.h`, `linux/vmalloc.h`, `linux/string.h`, `linux/in.h`, `linux/ip.h`.
- Detected declarations: `function ixgbe_alloc_vf_macvlans`, `function __ixgbe_enable_sriov`, `function ixgbe_get_vfs`, `function ixgbe_enable_sriov`, `function ixgbe_disable_sriov`, `function ixgbe_pci_sriov_enable`, `function ixgbe_pci_sriov_disable`, `function ixgbe_pci_sriov_configure`, `function ixgbe_set_vf_multicasts`, `function ixgbe_restore_vf_multicasts`.
- 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.