drivers/net/ethernet/intel/ice/ice_lib.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/ice/ice_lib.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/ice/ice_lib.c- Extension
.c- Size
- 109326 bytes
- Lines
- 4107
- 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.hice_base.hice_flow.hice_lib.hice_fltr.hice_dcb_lib.hice_type.hice_vsi_vlan_ops.h
Detected Declarations
function ice_vsi_ctrl_all_rx_ringsfunction ice_for_each_rxqfunction ice_vsi_alloc_arraysfunction ice_vsi_set_num_descfunction ice_get_rxq_countfunction ice_get_txq_countfunction ice_vsi_set_num_qsfunction ice_get_free_slotfunction ice_vsi_delete_from_hwfunction ice_vsi_free_arraysfunction ice_vsi_free_statsfunction ice_for_each_alloc_txqfunction ice_for_each_alloc_rxqfunction ice_vsi_alloc_ring_statsfunction ice_vsi_freefunction ice_vsi_deletefunction ice_msix_clean_ctrl_vsifunction ice_msix_clean_ringsfunction ice_vsi_alloc_stat_arraysfunction ice_vsi_alloc_deffunction ice_vsi_cfgfunction ice_alloc_fd_resfunction ice_vsi_get_qsfunction ice_vsi_put_qsfunction ice_for_each_alloc_txqfunction ice_for_each_alloc_rxqfunction ice_is_safe_modefunction ice_is_rdma_enafunction ice_vsi_clean_rss_flow_fldfunction ice_rss_cleanfunction ice_vsi_set_rss_paramsfunction ice_set_dflt_vsi_ctxfunction behaviorfunction ice_vsi_setup_q_mapfunction ice_set_fd_vsi_ctxfunction ice_set_rss_vsi_ctxfunction ice_chnl_vsi_setup_q_mapfunction ice_vsi_is_vlan_pruning_enafunction ice_vsi_initfunction ice_vsi_clear_ringsfunction ice_for_each_q_vectorfunction ice_for_each_alloc_rxqfunction ice_vsi_alloc_ringsfunction ice_vsi_manage_rss_lutfunction ice_vsi_cfg_crc_stripfunction ice_vsi_cfg_rss_lut_keyfunction correctfunction ice_vsi_set_vf_rss_flow_fld
Annotated Snippet
if (vsi->req_txq) {
vsi->alloc_txq = vsi->req_txq;
vsi->num_txq = vsi->req_txq;
} else {
vsi->alloc_txq = ice_get_txq_count(pf);
}
pf->num_lan_tx = vsi->alloc_txq;
/* only 1 Rx queue unless RSS is enabled */
if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) {
vsi->alloc_rxq = 1;
} else {
if (vsi->req_rxq) {
vsi->alloc_rxq = vsi->req_rxq;
vsi->num_rxq = vsi->req_rxq;
} else {
vsi->alloc_rxq = ice_get_rxq_count(pf);
}
}
pf->num_lan_rx = vsi->alloc_rxq;
vsi->num_q_vectors = max(vsi->alloc_rxq, vsi->alloc_txq);
break;
case ICE_VSI_SF:
vsi->alloc_txq = 1;
vsi->alloc_rxq = 1;
vsi->num_q_vectors = 1;
vsi->irq_dyn_alloc = true;
break;
case ICE_VSI_VF:
if (vf->num_req_qs)
vf->num_vf_qs = vf->num_req_qs;
vsi->alloc_txq = vf->num_vf_qs;
vsi->alloc_rxq = vf->num_vf_qs;
/* pf->vfs.num_msix_per includes (VF miscellaneous vector +
* data queue interrupts). Since vsi->num_q_vectors is number
* of queues vectors, subtract 1 (ICE_NONQ_VECS_VF) from the
* original vector count
*/
vsi->num_q_vectors = vf->num_msix - ICE_NONQ_VECS_VF;
break;
case ICE_VSI_CTRL:
vsi->alloc_txq = 1;
vsi->alloc_rxq = 1;
vsi->num_q_vectors = 1;
break;
case ICE_VSI_CHNL:
vsi->alloc_txq = 0;
vsi->alloc_rxq = 0;
break;
case ICE_VSI_LB:
vsi->alloc_txq = 1;
vsi->alloc_rxq = 1;
/* A dummy q_vector, no actual IRQ. */
vsi->num_q_vectors = 1;
break;
default:
dev_warn(ice_pf_to_dev(pf), "Unknown VSI type %d\n", vsi_type);
break;
}
ice_vsi_set_num_desc(vsi);
}
/**
* ice_get_free_slot - get the next non-NULL location index in array
* @array: array to search
* @size: size of the array
* @curr: last known occupied index to be used as a search hint
*
* void * is being used to keep the functionality generic. This lets us use this
* function on any array of pointers.
*/
static int ice_get_free_slot(void *array, int size, int curr)
{
int **tmp_array = (int **)array;
int next;
if (curr < (size - 1) && !tmp_array[curr + 1]) {
next = curr + 1;
} else {
int i = 0;
while ((i < size) && (tmp_array[i]))
i++;
if (i == size)
next = ICE_NO_VSI;
else
Annotation
- Immediate include surface: `ice.h`, `ice_base.h`, `ice_flow.h`, `ice_lib.h`, `ice_fltr.h`, `ice_dcb_lib.h`, `ice_type.h`, `ice_vsi_vlan_ops.h`.
- Detected declarations: `function ice_vsi_ctrl_all_rx_rings`, `function ice_for_each_rxq`, `function ice_vsi_alloc_arrays`, `function ice_vsi_set_num_desc`, `function ice_get_rxq_count`, `function ice_get_txq_count`, `function ice_vsi_set_num_qs`, `function ice_get_free_slot`, `function ice_vsi_delete_from_hw`, `function ice_vsi_free_arrays`.
- 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.