Lines Matching +full:msi +full:- +full:x

1 // SPDX-License-Identifier: GPL-2.0
9 * ice_init_irq_tracker - initialize interrupt tracker
18 pf->irq_tracker.num_entries = max_vectors; in ice_init_irq_tracker()
19 pf->irq_tracker.num_static = num_static; in ice_init_irq_tracker()
20 xa_init_flags(&pf->irq_tracker.entries, XA_FLAGS_ALLOC); in ice_init_irq_tracker()
24 * ice_deinit_irq_tracker - free xarray tracker
29 xa_destroy(&pf->irq_tracker.entries); in ice_deinit_irq_tracker()
33 * ice_free_irq_res - free a block of resources
41 entry = xa_erase(&pf->irq_tracker.entries, index); in ice_free_irq_res()
46 * ice_get_irq_res - get an interrupt resource
58 struct xa_limit limit = { .max = pf->irq_tracker.num_entries, in ice_get_irq_res()
60 unsigned int num_static = pf->irq_tracker.num_static; in ice_get_irq_res()
73 ret = xa_alloc(&pf->irq_tracker.entries, &index, entry, limit, in ice_get_irq_res()
80 entry->index = index; in ice_get_irq_res()
81 entry->dynamic = index >= num_static; in ice_get_irq_res()
88 * ice_reduce_msix_usage - Reduce usage of MSI-X vectors
90 * @v_remain: number of remaining MSI-X vectors to be distributed
92 * Reduce the usage of MSI-X vectors when entire request cannot be fulfilled.
93 * pf->num_lan_msix and pf->num_rdma_msix values are set based on number of
101 pf->num_lan_msix = v_remain; in ice_reduce_msix_usage()
109 dev_warn(ice_pf_to_dev(pf), "Not enough MSI-X vectors to support RDMA.\n"); in ice_reduce_msix_usage()
110 clear_bit(ICE_FLAG_RDMA_ENA, pf->flags); in ice_reduce_msix_usage()
112 pf->num_rdma_msix = 0; in ice_reduce_msix_usage()
113 pf->num_lan_msix = ICE_MIN_LAN_TXRX_MSIX; in ice_reduce_msix_usage()
115 (v_remain - v_rdma < v_rdma)) { in ice_reduce_msix_usage()
118 pf->num_rdma_msix = ICE_MIN_RDMA_MSIX; in ice_reduce_msix_usage()
119 pf->num_lan_msix = v_remain - ICE_MIN_RDMA_MSIX; in ice_reduce_msix_usage()
123 pf->num_rdma_msix = (v_remain - ICE_RDMA_NUM_AEQ_MSIX) / 2 + in ice_reduce_msix_usage()
125 pf->num_lan_msix = v_remain - pf->num_rdma_msix; in ice_reduce_msix_usage()
130 * ice_ena_msix_range - Request a range of MSIX vectors from the OS
143 hw_num_msix = pf->hw.func_caps.common_cap.num_msix_vectors; in ice_ena_msix_range()
150 if (test_bit(ICE_FLAG_FD_ENA, pf->flags)) in ice_ena_msix_range()
159 pf->num_lan_msix = num_cpus; in ice_ena_msix_range()
160 v_wanted += pf->num_lan_msix; in ice_ena_msix_range()
164 pf->num_rdma_msix = num_cpus + ICE_RDMA_NUM_AEQ_MSIX; in ice_ena_msix_range()
165 v_wanted += pf->num_rdma_msix; in ice_ena_msix_range()
171 dev_warn(dev, "not enough device MSI-X vectors. wanted = %d, available = %d\n", in ice_ena_msix_range()
175 err = -ERANGE; in ice_ena_msix_range()
179 v_remain = hw_num_msix - v_other; in ice_ena_msix_range()
181 v_other = ICE_MIN_MSIX - ICE_MIN_LAN_TXRX_MSIX; in ice_ena_msix_range()
186 v_wanted = pf->num_lan_msix + pf->num_rdma_msix + v_other; in ice_ena_msix_range()
188 dev_notice(dev, "Reducing request to %d MSI-X vectors for LAN traffic.\n", in ice_ena_msix_range()
189 pf->num_lan_msix); in ice_ena_msix_range()
191 dev_notice(dev, "Reducing request to %d MSI-X vectors for RDMA.\n", in ice_ena_msix_range()
192 pf->num_rdma_msix); in ice_ena_msix_range()
196 v_actual = pci_alloc_irq_vectors(pf->pdev, ICE_MIN_MSIX, v_wanted, in ice_ena_msix_range()
199 dev_err(dev, "unable to reserve MSI-X vectors\n"); in ice_ena_msix_range()
205 dev_warn(dev, "not enough OS MSI-X vectors. requested = %d, obtained = %d\n", in ice_ena_msix_range()
210 pci_free_irq_vectors(pf->pdev); in ice_ena_msix_range()
211 err = -ERANGE; in ice_ena_msix_range()
214 int v_remain = v_actual - v_other; in ice_ena_msix_range()
221 dev_notice(dev, "Enabled %d MSI-X vectors for LAN traffic.\n", in ice_ena_msix_range()
222 pf->num_lan_msix); in ice_ena_msix_range()
225 dev_notice(dev, "Enabled %d MSI-X vectors for RDMA.\n", in ice_ena_msix_range()
226 pf->num_rdma_msix); in ice_ena_msix_range()
233 pf->num_rdma_msix = 0; in ice_ena_msix_range()
234 pf->num_lan_msix = 0; in ice_ena_msix_range()
239 * ice_clear_interrupt_scheme - Undo things done by ice_init_interrupt_scheme
244 pci_free_irq_vectors(pf->pdev); in ice_clear_interrupt_scheme()
249 * ice_init_interrupt_scheme - Determine proper interrupt scheme
254 int total_vectors = pf->hw.func_caps.common_cap.num_msix_vectors; in ice_init_interrupt_scheme()
260 return -ENOMEM; in ice_init_interrupt_scheme()
262 if (pci_msix_can_alloc_dyn(pf->pdev)) in ice_init_interrupt_scheme()
273 * ice_alloc_irq - Allocate new interrupt vector
296 int sriov_base_vector = pf->sriov_base_vector; in ice_alloc_irq()
297 struct msi_map map = { .index = -ENOENT }; in ice_alloc_irq()
306 if (sriov_base_vector && entry->index >= sriov_base_vector) in ice_alloc_irq()
309 if (pci_msix_can_alloc_dyn(pf->pdev) && entry->dynamic) { in ice_alloc_irq()
310 map = pci_msix_alloc_irq_at(pf->pdev, entry->index, NULL); in ice_alloc_irq()
315 map.index = entry->index; in ice_alloc_irq()
316 map.virq = pci_irq_vector(pf->pdev, map.index); in ice_alloc_irq()
322 dev_err(dev, "Could not allocate irq at idx %d\n", entry->index); in ice_alloc_irq()
323 ice_free_irq_res(pf, entry->index); in ice_alloc_irq()
328 * ice_free_irq - Free interrupt vector
339 entry = xa_load(&pf->irq_tracker.entries, map.index); in ice_free_irq()
349 if (entry->dynamic) in ice_free_irq()
350 pci_msix_free_irq(pf->pdev, map); in ice_free_irq()
356 * ice_get_max_used_msix_vector - Get the max used interrupt vector
369 start = pf->irq_tracker.num_static; in ice_get_max_used_msix_vector()
370 max_idx = start - 1; in ice_get_max_used_msix_vector()
372 xa_for_each_start(&pf->irq_tracker.entries, index, entry, start) { in ice_get_max_used_msix_vector()