Add irq allocation functions. This will help
to allocate IRQs to both netdev and RoCE aux devices.
Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
Reviewed-by: Bhargava Chenna Marreddy <bhargava.marreddy@broadcom.com>
Reviewed-by: Rajashekar Hudumula <rajashekar.hudumula@broadcom.com>
---
drivers/net/ethernet/broadcom/bnge/bnge.h | 3 +
.../net/ethernet/broadcom/bnge/bnge_resc.c | 69 +++++++++++++++++++
.../net/ethernet/broadcom/bnge/bnge_resc.h | 13 ++++
3 files changed, 85 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/bnge/bnge.h b/drivers/net/ethernet/broadcom/bnge/bnge.h
index b58d8fc6f258..3c161b1a9b62 100644
--- a/drivers/net/ethernet/broadcom/bnge/bnge.h
+++ b/drivers/net/ethernet/broadcom/bnge/bnge.h
@@ -172,6 +172,9 @@ struct bnge_dev {
#define BNGE_SUPPORTS_TPA(bd) ((bd)->max_tpa_v2)
u8 num_tc;
+
+ struct bnge_irq *irq_tbl;
+ u16 irqs_acquired;
};
static inline bool bnge_is_roce_en(struct bnge_dev *bd)
diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_resc.c b/drivers/net/ethernet/broadcom/bnge/bnge_resc.c
index 68e094474822..84f91e05a2b0 100644
--- a/drivers/net/ethernet/broadcom/bnge/bnge_resc.c
+++ b/drivers/net/ethernet/broadcom/bnge/bnge_resc.c
@@ -326,3 +326,72 @@ int bnge_reserve_rings(struct bnge_dev *bd)
return rc;
}
+
+int bnge_alloc_irqs(struct bnge_dev *bd)
+{
+ u16 aux_msix, tx_cp, num_entries;
+ u16 irqs_demand, max, min = 1;
+ int i, rc = 0;
+
+ irqs_demand = bnge_nqs_demand(bd);
+ max = bnge_get_max_func_irqs(bd);
+ if (irqs_demand > max)
+ irqs_demand = max;
+
+ if (!(bd->flags & BNGE_EN_SHARED_CHNL))
+ min = 2;
+
+ irqs_demand = pci_alloc_irq_vectors(bd->pdev, min, irqs_demand,
+ PCI_IRQ_MSIX);
+ aux_msix = bnge_aux_get_msix(bd);
+ if (irqs_demand < 0 || irqs_demand < aux_msix) {
+ rc = -ENODEV;
+ goto err_free_irqs;
+ }
+
+ num_entries = irqs_demand;
+ if (pci_msix_can_alloc_dyn(bd->pdev))
+ num_entries = max;
+ bd->irq_tbl = kcalloc(num_entries, sizeof(*bd->irq_tbl), GFP_KERNEL);
+ if (!bd->irq_tbl) {
+ rc = -ENOMEM;
+ goto err_free_irqs;
+ }
+
+ for (i = 0; i < irqs_demand; i++)
+ bd->irq_tbl[i].vector = pci_irq_vector(bd->pdev, i);
+
+ bd->irqs_acquired = irqs_demand;
+ /* Reduce rings based upon num of vectors allocated.
+ * We dont need to consider NQs as they have been calculated
+ * and must be more than irqs_demand.
+ */
+ rc = bnge_adjust_rings(bd, &bd->rx_nr_rings,
+ &bd->tx_nr_rings,
+ irqs_demand - aux_msix, min == 1);
+ if (rc)
+ goto err_free_irqs;
+
+ tx_cp = bnge_num_tx_to_cp(bd, bd->tx_nr_rings);
+ bd->nq_nr_rings = (min == 1) ?
+ max_t(u16, tx_cp, bd->rx_nr_rings) :
+ tx_cp + bd->rx_nr_rings;
+
+ /* Readjust tx_nr_rings_per_tc */
+ if (!bd->num_tc)
+ bd->tx_nr_rings_per_tc = bd->tx_nr_rings;
+
+ return 0;
+
+err_free_irqs:
+ dev_err(bd->dev, "Failed to allocate IRQs err = %d\n", rc);
+ bnge_free_irqs(bd);
+ return rc;
+}
+
+void bnge_free_irqs(struct bnge_dev *bd)
+{
+ pci_free_irq_vectors(bd->pdev);
+ kfree(bd->irq_tbl);
+ bd->irq_tbl = NULL;
+}
diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_resc.h b/drivers/net/ethernet/broadcom/bnge/bnge_resc.h
index c6cef514588f..23db93e03787 100644
--- a/drivers/net/ethernet/broadcom/bnge/bnge_resc.h
+++ b/drivers/net/ethernet/broadcom/bnge/bnge_resc.h
@@ -51,8 +51,21 @@ struct bnge_hw_rings {
u16 rss_ctx;
};
+/* "TXRX", 2 hypens, plus maximum integer */
+#define BNGE_IRQ_NAME_EXTRA 17
+struct bnge_irq {
+ irq_handler_t handler;
+ unsigned int vector;
+ u8 requested:1;
+ u8 have_cpumask:1;
+ char name[IFNAMSIZ + BNGE_IRQ_NAME_EXTRA];
+ cpumask_var_t cpu_mask;
+};
+
int bnge_reserve_rings(struct bnge_dev *bd);
int bnge_fix_rings_count(u16 *rx, u16 *tx, u16 max, bool shared);
+int bnge_alloc_irqs(struct bnge_dev *bd);
+void bnge_free_irqs(struct bnge_dev *bd);
static inline u32
bnge_adjust_pow_two(u32 total_ent, u16 ent_per_blk)
--
2.47.1
Hi Vikas, kernel test robot noticed the following build warnings: [auto build test WARNING on linus/master] [also build test WARNING on v6.16-rc3 next-20250624] [cannot apply to horms-ipvs/master] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Vikas-Gupta/bng_en-Add-PCI-interface/20250618-173130 base: linus/master patch link: https://lore.kernel.org/r/20250618144743.843815-9-vikas.gupta%40broadcom.com patch subject: [net-next, 08/10] bng_en: Add irq allocation support config: parisc-randconfig-r073-20250619 (https://download.01.org/0day-ci/archive/20250625/202506251636.aTzmB45K-lkp@intel.com/config) compiler: hppa-linux-gcc (GCC) 8.5.0 If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202506251636.aTzmB45K-lkp@intel.com/ smatch warnings: drivers/net/ethernet/broadcom/bnge/bnge_resc.c:347 bnge_alloc_irqs() warn: unsigned 'irqs_demand' is never less than zero. vim +/irqs_demand +347 drivers/net/ethernet/broadcom/bnge/bnge_resc.c 329 330 int bnge_alloc_irqs(struct bnge_dev *bd) 331 { 332 u16 aux_msix, tx_cp, num_entries; 333 u16 irqs_demand, max, min = 1; 334 int i, rc = 0; 335 336 irqs_demand = bnge_nqs_demand(bd); 337 max = bnge_get_max_func_irqs(bd); 338 if (irqs_demand > max) 339 irqs_demand = max; 340 341 if (!(bd->flags & BNGE_EN_SHARED_CHNL)) 342 min = 2; 343 344 irqs_demand = pci_alloc_irq_vectors(bd->pdev, min, irqs_demand, 345 PCI_IRQ_MSIX); 346 aux_msix = bnge_aux_get_msix(bd); > 347 if (irqs_demand < 0 || irqs_demand < aux_msix) { 348 rc = -ENODEV; 349 goto err_free_irqs; 350 } 351 352 num_entries = irqs_demand; 353 if (pci_msix_can_alloc_dyn(bd->pdev)) 354 num_entries = max; 355 bd->irq_tbl = kcalloc(num_entries, sizeof(*bd->irq_tbl), GFP_KERNEL); 356 if (!bd->irq_tbl) { 357 rc = -ENOMEM; 358 goto err_free_irqs; 359 } 360 361 for (i = 0; i < irqs_demand; i++) 362 bd->irq_tbl[i].vector = pci_irq_vector(bd->pdev, i); 363 364 bd->irqs_acquired = irqs_demand; 365 /* Reduce rings based upon num of vectors allocated. 366 * We dont need to consider NQs as they have been calculated 367 * and must be more than irqs_demand. 368 */ 369 rc = bnge_adjust_rings(bd, &bd->rx_nr_rings, 370 &bd->tx_nr_rings, 371 irqs_demand - aux_msix, min == 1); 372 if (rc) 373 goto err_free_irqs; 374 375 tx_cp = bnge_num_tx_to_cp(bd, bd->tx_nr_rings); 376 bd->nq_nr_rings = (min == 1) ? 377 max_t(u16, tx_cp, bd->rx_nr_rings) : 378 tx_cp + bd->rx_nr_rings; 379 380 /* Readjust tx_nr_rings_per_tc */ 381 if (!bd->num_tc) 382 bd->tx_nr_rings_per_tc = bd->tx_nr_rings; 383 384 return 0; 385 386 err_free_irqs: 387 dev_err(bd->dev, "Failed to allocate IRQs err = %d\n", rc); 388 bnge_free_irqs(bd); 389 return rc; 390 } 391 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Hi Vikas, kernel test robot noticed the following build warnings: [auto build test WARNING on linus/master] [also build test WARNING on v6.16-rc3 next-20250620] [cannot apply to horms-ipvs/master] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Vikas-Gupta/bng_en-Add-PCI-interface/20250618-173130 base: linus/master patch link: https://lore.kernel.org/r/20250618144743.843815-9-vikas.gupta%40broadcom.com patch subject: [net-next, 08/10] bng_en: Add irq allocation support config: parisc-randconfig-r073-20250619 (https://download.01.org/0day-ci/archive/20250623/202506231320.YMpashmK-lkp@intel.com/config) compiler: hppa-linux-gcc (GCC) 8.5.0 If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202506231320.YMpashmK-lkp@intel.com/ smatch warnings: drivers/net/ethernet/broadcom/bnge/bnge_resc.c:347 bnge_alloc_irqs() warn: unsigned 'irqs_demand' is never less than zero. vim +/irqs_demand +347 drivers/net/ethernet/broadcom/bnge/bnge_resc.c 329 330 int bnge_alloc_irqs(struct bnge_dev *bd) 331 { 332 u16 aux_msix, tx_cp, num_entries; 333 u16 irqs_demand, max, min = 1; 334 int i, rc = 0; 335 336 irqs_demand = bnge_nqs_demand(bd); 337 max = bnge_get_max_func_irqs(bd); 338 if (irqs_demand > max) 339 irqs_demand = max; 340 341 if (!(bd->flags & BNGE_EN_SHARED_CHNL)) 342 min = 2; 343 344 irqs_demand = pci_alloc_irq_vectors(bd->pdev, min, irqs_demand, 345 PCI_IRQ_MSIX); 346 aux_msix = bnge_aux_get_msix(bd); > 347 if (irqs_demand < 0 || irqs_demand < aux_msix) { 348 rc = -ENODEV; 349 goto err_free_irqs; 350 } 351 352 num_entries = irqs_demand; 353 if (pci_msix_can_alloc_dyn(bd->pdev)) 354 num_entries = max; 355 bd->irq_tbl = kcalloc(num_entries, sizeof(*bd->irq_tbl), GFP_KERNEL); 356 if (!bd->irq_tbl) { 357 rc = -ENOMEM; 358 goto err_free_irqs; 359 } 360 361 for (i = 0; i < irqs_demand; i++) 362 bd->irq_tbl[i].vector = pci_irq_vector(bd->pdev, i); 363 364 bd->irqs_acquired = irqs_demand; 365 /* Reduce rings based upon num of vectors allocated. 366 * We dont need to consider NQs as they have been calculated 367 * and must be more than irqs_demand. 368 */ 369 rc = bnge_adjust_rings(bd, &bd->rx_nr_rings, 370 &bd->tx_nr_rings, 371 irqs_demand - aux_msix, min == 1); 372 if (rc) 373 goto err_free_irqs; 374 375 tx_cp = bnge_num_tx_to_cp(bd, bd->tx_nr_rings); 376 bd->nq_nr_rings = (min == 1) ? 377 max_t(u16, tx_cp, bd->rx_nr_rings) : 378 tx_cp + bd->rx_nr_rings; 379 380 /* Readjust tx_nr_rings_per_tc */ 381 if (!bd->num_tc) 382 bd->tx_nr_rings_per_tc = bd->tx_nr_rings; 383 384 return 0; 385 386 err_free_irqs: 387 dev_err(bd->dev, "Failed to allocate IRQs err = %d\n", rc); 388 bnge_free_irqs(bd); 389 return rc; 390 } 391 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Hi Vikas, kernel test robot noticed the following build warnings: [auto build test WARNING on linus/master] [also build test WARNING on v6.16-rc2 next-20250620] [cannot apply to horms-ipvs/master] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Vikas-Gupta/bng_en-Add-PCI-interface/20250618-173130 base: linus/master patch link: https://lore.kernel.org/r/20250618144743.843815-9-vikas.gupta%40broadcom.com patch subject: [net-next, 08/10] bng_en: Add irq allocation support config: parisc-randconfig-r073-20250619 (https://download.01.org/0day-ci/archive/20250622/202506221311.dmMiJyFp-lkp@intel.com/config) compiler: hppa-linux-gcc (GCC) 8.5.0 If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202506221311.dmMiJyFp-lkp@intel.com/ smatch warnings: drivers/net/ethernet/broadcom/bnge/bnge_resc.c:347 bnge_alloc_irqs() warn: unsigned 'irqs_demand' is never less than zero. vim +/irqs_demand +347 drivers/net/ethernet/broadcom/bnge/bnge_resc.c 329 330 int bnge_alloc_irqs(struct bnge_dev *bd) 331 { 332 u16 aux_msix, tx_cp, num_entries; 333 u16 irqs_demand, max, min = 1; 334 int i, rc = 0; 335 336 irqs_demand = bnge_nqs_demand(bd); 337 max = bnge_get_max_func_irqs(bd); 338 if (irqs_demand > max) 339 irqs_demand = max; 340 341 if (!(bd->flags & BNGE_EN_SHARED_CHNL)) 342 min = 2; 343 344 irqs_demand = pci_alloc_irq_vectors(bd->pdev, min, irqs_demand, 345 PCI_IRQ_MSIX); 346 aux_msix = bnge_aux_get_msix(bd); > 347 if (irqs_demand < 0 || irqs_demand < aux_msix) { 348 rc = -ENODEV; 349 goto err_free_irqs; 350 } 351 352 num_entries = irqs_demand; 353 if (pci_msix_can_alloc_dyn(bd->pdev)) 354 num_entries = max; 355 bd->irq_tbl = kcalloc(num_entries, sizeof(*bd->irq_tbl), GFP_KERNEL); 356 if (!bd->irq_tbl) { 357 rc = -ENOMEM; 358 goto err_free_irqs; 359 } 360 361 for (i = 0; i < irqs_demand; i++) 362 bd->irq_tbl[i].vector = pci_irq_vector(bd->pdev, i); 363 364 bd->irqs_acquired = irqs_demand; 365 /* Reduce rings based upon num of vectors allocated. 366 * We dont need to consider NQs as they have been calculated 367 * and must be more than irqs_demand. 368 */ 369 rc = bnge_adjust_rings(bd, &bd->rx_nr_rings, 370 &bd->tx_nr_rings, 371 irqs_demand - aux_msix, min == 1); 372 if (rc) 373 goto err_free_irqs; 374 375 tx_cp = bnge_num_tx_to_cp(bd, bd->tx_nr_rings); 376 bd->nq_nr_rings = (min == 1) ? 377 max_t(u16, tx_cp, bd->rx_nr_rings) : 378 tx_cp + bd->rx_nr_rings; 379 380 /* Readjust tx_nr_rings_per_tc */ 381 if (!bd->num_tc) 382 bd->tx_nr_rings_per_tc = bd->tx_nr_rings; 383 384 return 0; 385 386 err_free_irqs: 387 dev_err(bd->dev, "Failed to allocate IRQs err = %d\n", rc); 388 bnge_free_irqs(bd); 389 return rc; 390 } 391 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Hi Vikas, kernel test robot noticed the following build warnings: [auto build test WARNING on linus/master] [also build test WARNING on v6.16-rc2 next-20250619] [cannot apply to horms-ipvs/master] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Vikas-Gupta/bng_en-Add-PCI-interface/20250618-173130 base: linus/master patch link: https://lore.kernel.org/r/20250618144743.843815-9-vikas.gupta%40broadcom.com patch subject: [net-next, 08/10] bng_en: Add irq allocation support config: parisc-randconfig-r073-20250619 (https://download.01.org/0day-ci/archive/20250620/202506200530.jiD9Txum-lkp@intel.com/config) compiler: hppa-linux-gcc (GCC) 8.5.0 If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202506200530.jiD9Txum-lkp@intel.com/ smatch warnings: drivers/net/ethernet/broadcom/bnge/bnge_resc.c:347 bnge_alloc_irqs() warn: unsigned 'irqs_demand' is never less than zero. vim +/irqs_demand +347 drivers/net/ethernet/broadcom/bnge/bnge_resc.c 329 330 int bnge_alloc_irqs(struct bnge_dev *bd) 331 { 332 u16 aux_msix, tx_cp, num_entries; 333 u16 irqs_demand, max, min = 1; 334 int i, rc = 0; 335 336 irqs_demand = bnge_nqs_demand(bd); 337 max = bnge_get_max_func_irqs(bd); 338 if (irqs_demand > max) 339 irqs_demand = max; 340 341 if (!(bd->flags & BNGE_EN_SHARED_CHNL)) 342 min = 2; 343 344 irqs_demand = pci_alloc_irq_vectors(bd->pdev, min, irqs_demand, 345 PCI_IRQ_MSIX); 346 aux_msix = bnge_aux_get_msix(bd); > 347 if (irqs_demand < 0 || irqs_demand < aux_msix) { 348 rc = -ENODEV; 349 goto err_free_irqs; 350 } 351 352 num_entries = irqs_demand; 353 if (pci_msix_can_alloc_dyn(bd->pdev)) 354 num_entries = max; 355 bd->irq_tbl = kcalloc(num_entries, sizeof(*bd->irq_tbl), GFP_KERNEL); 356 if (!bd->irq_tbl) { 357 rc = -ENOMEM; 358 goto err_free_irqs; 359 } 360 361 for (i = 0; i < irqs_demand; i++) 362 bd->irq_tbl[i].vector = pci_irq_vector(bd->pdev, i); 363 364 bd->irqs_acquired = irqs_demand; 365 /* Reduce rings based upon num of vectors allocated. 366 * We dont need to consider NQs as they have been calculated 367 * and must be more than irqs_demand. 368 */ 369 rc = bnge_adjust_rings(bd, &bd->rx_nr_rings, 370 &bd->tx_nr_rings, 371 irqs_demand - aux_msix, min == 1); 372 if (rc) 373 goto err_free_irqs; 374 375 tx_cp = bnge_num_tx_to_cp(bd, bd->tx_nr_rings); 376 bd->nq_nr_rings = (min == 1) ? 377 max_t(u16, tx_cp, bd->rx_nr_rings) : 378 tx_cp + bd->rx_nr_rings; 379 380 /* Readjust tx_nr_rings_per_tc */ 381 if (!bd->num_tc) 382 bd->tx_nr_rings_per_tc = bd->tx_nr_rings; 383 384 return 0; 385 386 err_free_irqs: 387 dev_err(bd->dev, "Failed to allocate IRQs err = %d\n", rc); 388 bnge_free_irqs(bd); 389 return rc; 390 } 391 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
On 18/06/2025 15:47, Vikas Gupta wrote: > Add irq allocation functions. This will help > to allocate IRQs to both netdev and RoCE aux devices. > > Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com> > Reviewed-by: Bhargava Chenna Marreddy <bhargava.marreddy@broadcom.com> > Reviewed-by: Rajashekar Hudumula <rajashekar.hudumula@broadcom.com> > --- > drivers/net/ethernet/broadcom/bnge/bnge.h | 3 + > .../net/ethernet/broadcom/bnge/bnge_resc.c | 69 +++++++++++++++++++ > .../net/ethernet/broadcom/bnge/bnge_resc.h | 13 ++++ > 3 files changed, 85 insertions(+) > > diff --git a/drivers/net/ethernet/broadcom/bnge/bnge.h b/drivers/net/ethernet/broadcom/bnge/bnge.h > index b58d8fc6f258..3c161b1a9b62 100644 > --- a/drivers/net/ethernet/broadcom/bnge/bnge.h > +++ b/drivers/net/ethernet/broadcom/bnge/bnge.h > @@ -172,6 +172,9 @@ struct bnge_dev { > #define BNGE_SUPPORTS_TPA(bd) ((bd)->max_tpa_v2) > > u8 num_tc; > + > + struct bnge_irq *irq_tbl; > + u16 irqs_acquired; > }; > > static inline bool bnge_is_roce_en(struct bnge_dev *bd) > diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_resc.c b/drivers/net/ethernet/broadcom/bnge/bnge_resc.c > index 68e094474822..84f91e05a2b0 100644 > --- a/drivers/net/ethernet/broadcom/bnge/bnge_resc.c > +++ b/drivers/net/ethernet/broadcom/bnge/bnge_resc.c > @@ -326,3 +326,72 @@ int bnge_reserve_rings(struct bnge_dev *bd) > > return rc; > } > + > +int bnge_alloc_irqs(struct bnge_dev *bd) > +{ > + u16 aux_msix, tx_cp, num_entries; > + u16 irqs_demand, max, min = 1; > + int i, rc = 0; This assignment is not needed. Error paths re-assign proper error code while normal flow re-assigns rc to the return value of bnge_adjust_rings() > + > + irqs_demand = bnge_nqs_demand(bd); > + max = bnge_get_max_func_irqs(bd); > + if (irqs_demand > max) > + irqs_demand = max; > + > + if (!(bd->flags & BNGE_EN_SHARED_CHNL)) > + min = 2; > + > + irqs_demand = pci_alloc_irq_vectors(bd->pdev, min, irqs_demand, > + PCI_IRQ_MSIX); > + aux_msix = bnge_aux_get_msix(bd); > + if (irqs_demand < 0 || irqs_demand < aux_msix) { > + rc = -ENODEV; > + goto err_free_irqs; > + } > + > + num_entries = irqs_demand; > + if (pci_msix_can_alloc_dyn(bd->pdev)) > + num_entries = max; > + bd->irq_tbl = kcalloc(num_entries, sizeof(*bd->irq_tbl), GFP_KERNEL); > + if (!bd->irq_tbl) { > + rc = -ENOMEM; > + goto err_free_irqs; > + } > + > + for (i = 0; i < irqs_demand; i++) > + bd->irq_tbl[i].vector = pci_irq_vector(bd->pdev, i); > + > + bd->irqs_acquired = irqs_demand; > + /* Reduce rings based upon num of vectors allocated. > + * We dont need to consider NQs as they have been calculated > + * and must be more than irqs_demand. > + */ > + rc = bnge_adjust_rings(bd, &bd->rx_nr_rings, > + &bd->tx_nr_rings, > + irqs_demand - aux_msix, min == 1); > + if (rc) > + goto err_free_irqs; > + > + tx_cp = bnge_num_tx_to_cp(bd, bd->tx_nr_rings); > + bd->nq_nr_rings = (min == 1) ? > + max_t(u16, tx_cp, bd->rx_nr_rings) : > + tx_cp + bd->rx_nr_rings; > + > + /* Readjust tx_nr_rings_per_tc */ > + if (!bd->num_tc) > + bd->tx_nr_rings_per_tc = bd->tx_nr_rings; > + > + return 0; > + > +err_free_irqs: > + dev_err(bd->dev, "Failed to allocate IRQs err = %d\n", rc); > + bnge_free_irqs(bd); > + return rc; > +} [...]
© 2016 - 2025 Red Hat, Inc.