@@ -8016,14 +8016,20 @@ static int __bnxt_reserve_rings(struct bnxt *bp)
80168016 }
80178017 rx_rings = min_t (int , rx_rings , hwr .grp );
80188018 hwr .cp = min_t (int , hwr .cp , bp -> cp_nr_rings );
8019- if (hwr .stat > bnxt_get_ulp_stat_ctxs (bp ))
8019+ if (bnxt_ulp_registered (bp -> edev ) &&
8020+ hwr .stat > bnxt_get_ulp_stat_ctxs (bp ))
80208021 hwr .stat -= bnxt_get_ulp_stat_ctxs (bp );
80218022 hwr .cp = min_t (int , hwr .cp , hwr .stat );
80228023 rc = bnxt_trim_rings (bp , & rx_rings , & hwr .tx , hwr .cp , sh );
80238024 if (bp -> flags & BNXT_FLAG_AGG_RINGS )
80248025 hwr .rx = rx_rings << 1 ;
80258026 tx_cp = bnxt_num_tx_to_cp (bp , hwr .tx );
80268027 hwr .cp = sh ? max_t (int , tx_cp , rx_rings ) : tx_cp + rx_rings ;
8028+ if (hwr .tx != bp -> tx_nr_rings ) {
8029+ netdev_warn (bp -> dev ,
8030+ "Able to reserve only %d out of %d requested TX rings\n" ,
8031+ hwr .tx , bp -> tx_nr_rings );
8032+ }
80278033 bp -> tx_nr_rings = hwr .tx ;
80288034
80298035 /* If we cannot reserve all the RX rings, reset the RSS map only
@@ -12851,6 +12857,17 @@ static int bnxt_set_xps_mapping(struct bnxt *bp)
1285112857 return rc ;
1285212858}
1285312859
12860+ static int bnxt_tx_nr_rings (struct bnxt * bp )
12861+ {
12862+ return bp -> num_tc ? bp -> tx_nr_rings_per_tc * bp -> num_tc :
12863+ bp -> tx_nr_rings_per_tc ;
12864+ }
12865+
12866+ static int bnxt_tx_nr_rings_per_tc (struct bnxt * bp )
12867+ {
12868+ return bp -> num_tc ? bp -> tx_nr_rings / bp -> num_tc : bp -> tx_nr_rings ;
12869+ }
12870+
1285412871static int __bnxt_open_nic (struct bnxt * bp , bool irq_re_init , bool link_re_init )
1285512872{
1285612873 int rc = 0 ;
@@ -12868,6 +12885,13 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
1286812885 if (rc )
1286912886 return rc ;
1287012887
12888+ /* Make adjustments if reserved TX rings are less than requested */
12889+ bp -> tx_nr_rings -= bp -> tx_nr_rings_xdp ;
12890+ bp -> tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc (bp );
12891+ if (bp -> tx_nr_rings_xdp ) {
12892+ bp -> tx_nr_rings_xdp = bp -> tx_nr_rings_per_tc ;
12893+ bp -> tx_nr_rings += bp -> tx_nr_rings_xdp ;
12894+ }
1287112895 rc = bnxt_alloc_mem (bp , irq_re_init );
1287212896 if (rc ) {
1287312897 netdev_err (bp -> dev , "bnxt_alloc_mem err: %x\n" , rc );
@@ -16325,7 +16349,7 @@ static void bnxt_trim_dflt_sh_rings(struct bnxt *bp)
1632516349 bp -> cp_nr_rings = min_t (int , bp -> tx_nr_rings_per_tc , bp -> rx_nr_rings );
1632616350 bp -> rx_nr_rings = bp -> cp_nr_rings ;
1632716351 bp -> tx_nr_rings_per_tc = bp -> cp_nr_rings ;
16328- bp -> tx_nr_rings = bp -> tx_nr_rings_per_tc ;
16352+ bp -> tx_nr_rings = bnxt_tx_nr_rings ( bp ) ;
1632916353}
1633016354
1633116355static int bnxt_set_dflt_rings (struct bnxt * bp , bool sh )
@@ -16357,7 +16381,7 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)
1635716381 bnxt_trim_dflt_sh_rings (bp );
1635816382 else
1635916383 bp -> cp_nr_rings = bp -> tx_nr_rings_per_tc + bp -> rx_nr_rings ;
16360- bp -> tx_nr_rings = bp -> tx_nr_rings_per_tc ;
16384+ bp -> tx_nr_rings = bnxt_tx_nr_rings ( bp ) ;
1636116385
1636216386 avail_msix = bnxt_get_max_func_irqs (bp ) - bp -> cp_nr_rings ;
1636316387 if (avail_msix >= BNXT_MIN_ROCE_CP_RINGS ) {
@@ -16370,7 +16394,7 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)
1637016394 rc = __bnxt_reserve_rings (bp );
1637116395 if (rc && rc != - ENODEV )
1637216396 netdev_warn (bp -> dev , "Unable to reserve tx rings\n" );
16373- bp -> tx_nr_rings_per_tc = bp -> tx_nr_rings ;
16397+ bp -> tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc ( bp ) ;
1637416398 if (sh )
1637516399 bnxt_trim_dflt_sh_rings (bp );
1637616400
@@ -16379,7 +16403,7 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)
1637916403 rc = __bnxt_reserve_rings (bp );
1638016404 if (rc && rc != - ENODEV )
1638116405 netdev_warn (bp -> dev , "2nd rings reservation failed.\n" );
16382- bp -> tx_nr_rings_per_tc = bp -> tx_nr_rings ;
16406+ bp -> tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc ( bp ) ;
1638316407 }
1638416408 if (BNXT_CHIP_TYPE_NITRO_A0 (bp )) {
1638516409 bp -> rx_nr_rings ++ ;
@@ -16413,7 +16437,7 @@ static int bnxt_init_dflt_ring_mode(struct bnxt *bp)
1641316437 if (rc )
1641416438 goto init_dflt_ring_err ;
1641516439
16416- bp -> tx_nr_rings_per_tc = bp -> tx_nr_rings ;
16440+ bp -> tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc ( bp ) ;
1641716441
1641816442 bnxt_set_dflt_rfs (bp );
1641916443
0 commit comments