/** * ice_get_irq_res - get an interrupt resource * @pf: board private structure * @dyn_allowed: allow entry to be dynamically allocated * * Allocate new irq entry in the free slot of the tracker. Since xarray * is used, always allocate new entry at the lowest possible index. Set * proper allocation limit for maximum tracker entries. * * Returns allocated irq entry or NULL on failure.
*/ staticstruct ice_irq_entry *ice_get_irq_res(struct ice_pf *pf, bool dyn_allowed)
{ struct xa_limit limit = { .max = pf->irq_tracker.num_entries - 1,
.min = 0 }; unsignedint num_static = pf->irq_tracker.num_static - 1; struct ice_irq_entry *entry; unsignedint index; int ret;
entry = kzalloc(sizeof(*entry), GFP_KERNEL); if (!entry) return NULL;
/* only already allocated if the caller says so */ if (!dyn_allowed)
limit.max = num_static;
ret = xa_alloc(&pf->irq_tracker.entries, &index, entry, limit,
GFP_KERNEL);
if (ret) {
kfree(entry);
entry = NULL;
} else {
entry->index = index;
entry->dynamic = index > num_static;
}
/** * ice_alloc_irq - Allocate new interrupt vector * @pf: board private structure * @dyn_allowed: allow dynamic allocation of the interrupt * * Allocate new interrupt vector for a given owner id. * return struct msi_map with interrupt details and track * allocated interrupt appropriately. * * This function reserves new irq entry from the irq_tracker. * if according to the tracker information all interrupts that * were allocated with ice_pci_alloc_irq_vectors are already used * and dynamically allocated interrupts are supported then new * interrupt will be allocated with pci_msix_alloc_irq_at. * * Some callers may only support dynamically allocated interrupts. * This is indicated with dyn_allowed flag. * * On failure, return map with negative .index. The caller * is expected to check returned map index. *
*/ struct msi_map ice_alloc_irq(struct ice_pf *pf, bool dyn_allowed)
{ struct msi_map map = { .index = -ENOENT }; struct device *dev = ice_pf_to_dev(pf); struct ice_irq_entry *entry;
entry = ice_get_irq_res(pf, dyn_allowed); if (!entry) return map;
if (pci_msix_can_alloc_dyn(pf->pdev) && entry->dynamic) {
map = pci_msix_alloc_irq_at(pf->pdev, entry->index, NULL); if (map.index < 0) goto exit_free_res;
dev_dbg(dev, "allocated new irq at index %d\n", map.index);
} else {
map.index = entry->index;
map.virq = pci_irq_vector(pf->pdev, map.index);
}
return map;
exit_free_res:
dev_err(dev, "Could not allocate irq at idx %d\n", entry->index);
ice_free_irq_res(pf, entry->index); return map;
}
/** * ice_free_irq - Free interrupt vector * @pf: board private structure * @map: map with interrupt details * * Remove allocated interrupt from the interrupt tracker. If interrupt was * allocated dynamically, free respective interrupt vector.
*/ void ice_free_irq(struct ice_pf *pf, struct msi_map map)
{ struct ice_irq_entry *entry;
if (!entry) {
dev_err(ice_pf_to_dev(pf), "Failed to get MSIX interrupt entry at index %d",
map.index); return;
}
dev_dbg(ice_pf_to_dev(pf), "Free irq at index %d\n", map.index);
if (entry->dynamic)
pci_msix_free_irq(pf->pdev, map);
ice_free_irq_res(pf, map.index);
}
/** * ice_virt_get_irqs - get irqs for SR-IOV usacase * @pf: pointer to PF structure * @needed: number of irqs to get * * This returns the first MSI-X vector index in PF space that is used by this * VF. This index is used when accessing PF relative registers such as * GLINT_VECT2FUNC and GLINT_DYN_CTL. * This will always be the OICR index in the AVF driver so any functionality * using vf->first_vector_idx for queue configuration_id: id of VF which will * use this irqs
*/ int ice_virt_get_irqs(struct ice_pf *pf, u32 needed)
{ int res = bitmap_find_next_zero_area(pf->virt_irq_tracker.bm,
pf->virt_irq_tracker.num_entries,
0, needed, 0);
if (res >= pf->virt_irq_tracker.num_entries) return -ENOENT;
bitmap_set(pf->virt_irq_tracker.bm, res, needed);
/* conversion from number in bitmap to global irq index */ return res + pf->virt_irq_tracker.base;
}
/** * ice_virt_free_irqs - free irqs used by the VF * @pf: pointer to PF structure * @index: first index to be free * @irqs: number of irqs to free
*/ void ice_virt_free_irqs(struct ice_pf *pf, u32 index, u32 irqs)
{
bitmap_clear(pf->virt_irq_tracker.bm, index - pf->virt_irq_tracker.base,
irqs);
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.