drivers/net/ethernet/intel/ice/ice_vf_lib.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/ice/ice_vf_lib.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/ice/ice_vf_lib.c- Extension
.c- Size
- 36705 bytes
- Lines
- 1425
- 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
ice_vf_lib_private.hice.hice_lib.hice_fltr.hvirt/allowlist.h
Detected Declarations
function ice_put_vffunction ice_release_vffunction ice_get_vf_by_idfunction ice_has_vfsfunction ice_get_num_vfsfunction ice_is_vf_disabledfunction ice_wait_on_vf_resetfunction ice_check_vf_ready_for_cfgfunction ice_trigger_vf_resetfunction ice_vf_clear_countersfunction VFfunction resetfunction VFfunction ice_vf_rebuild_host_vlan_cfgfunction ice_vf_rebuild_host_tx_rate_cfgfunction ice_vf_set_host_trust_cfgfunction ice_vf_rebuild_host_mac_cfgfunction ice_vf_rebuild_aggregator_node_cfgfunction ice_vf_rebuild_host_cfgfunction ice_set_vf_state_qs_disfunction ice_vf_set_initializedfunction ice_vf_post_vsi_rebuildfunction VFfunction ice_vf_get_promisc_masksfunction ice_vf_clear_all_promisc_modesfunction ice_vf_set_vsi_promiscfunction ice_vf_clear_vsi_promiscfunction ice_reset_vf_mbx_cntfunction ice_reset_all_vfsfunction ice_notify_vf_resetfunction ice_reset_vffunction ice_set_vf_state_disfunction ice_initialize_vf_entryfunction ice_deinitialize_vf_entryfunction ice_dis_vf_qsfunction ice_err_to_virt_errfunction ice_check_vf_initfunction enablefunction ice_vsi_ena_spoofchkfunction ice_vsi_dis_spoofchkfunction ice_vsi_apply_spoofchkfunction ice_is_vf_trustedfunction ice_vf_has_no_qs_enafunction ice_is_vf_link_upfunction ice_vf_ctrl_invalidate_vsifunction ice_vf_ctrl_vsi_releasefunction ice_vf_init_host_cfgfunction ice_vf_invalidate_vsi
Annotated Snippet
if (vf->vf_id == vf_id) {
struct ice_vf *found;
if (kref_get_unless_zero(&vf->refcnt))
found = vf;
else
found = NULL;
rcu_read_unlock();
return found;
}
}
rcu_read_unlock();
return NULL;
}
/**
* ice_release_vf - Release VF associated with a refcount
* @ref: the kref decremented to zero
*
* Callback function for kref_put to release a VF once its reference count has
* hit zero.
*/
static void ice_release_vf(struct kref *ref)
{
struct ice_vf *vf = container_of(ref, struct ice_vf, refcnt);
pci_dev_put(vf->vfdev);
vf->vf_ops->free(vf);
}
/**
* ice_put_vf - Release a reference to a VF
* @vf: the VF structure to decrease reference count on
*
* Decrease the reference count for a VF, and free the entry if it is no
* longer in use.
*
* This must be called after ice_get_vf_by_id() once the reference to the VF
* structure is no longer used. Otherwise, the VF structure will never be
* freed.
*/
void ice_put_vf(struct ice_vf *vf)
{
kref_put(&vf->refcnt, ice_release_vf);
}
/**
* ice_has_vfs - Return true if the PF has any associated VFs
* @pf: the PF private structure
*
* Return whether or not the PF has any allocated VFs.
*
* Note that this function only guarantees that there are no VFs at the point
* of calling it. It does not guarantee that no more VFs will be added.
*/
bool ice_has_vfs(struct ice_pf *pf)
{
/* A simple check that the hash table is not empty does not require
* the mutex or rcu_read_lock.
*/
return !hash_empty(pf->vfs.table);
}
/**
* ice_get_num_vfs - Get number of allocated VFs
* @pf: the PF private structure
*
* Return the total number of allocated VFs. NOTE: VF IDs are not guaranteed
* to be contiguous. Do not assume that a VF ID is guaranteed to be less than
* the output of this function.
*/
u16 ice_get_num_vfs(struct ice_pf *pf)
{
struct ice_vf *vf;
unsigned int bkt;
u16 num_vfs = 0;
rcu_read_lock();
ice_for_each_vf_rcu(pf, bkt, vf)
num_vfs++;
rcu_read_unlock();
return num_vfs;
}
/**
* ice_get_vf_vsi - get VF's VSI based on the stored index
Annotation
- Immediate include surface: `ice_vf_lib_private.h`, `ice.h`, `ice_lib.h`, `ice_fltr.h`, `virt/allowlist.h`.
- Detected declarations: `function ice_put_vf`, `function ice_release_vf`, `function ice_get_vf_by_id`, `function ice_has_vfs`, `function ice_get_num_vfs`, `function ice_is_vf_disabled`, `function ice_wait_on_vf_reset`, `function ice_check_vf_ready_for_cfg`, `function ice_trigger_vf_reset`, `function ice_vf_clear_counters`.
- 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.