@@ -8045,6 +8045,8 @@ static int __bnxt_reserve_rings(struct bnxt *bp)
80458045 ulp_msix = bnxt_get_avail_msix (bp , bp -> ulp_num_msix_want );
80468046 if (!ulp_msix )
80478047 bnxt_set_ulp_stat_ctxs (bp , 0 );
8048+ else
8049+ bnxt_set_dflt_ulp_stat_ctxs (bp );
80488050
80498051 if (ulp_msix > bp -> ulp_num_msix_want )
80508052 ulp_msix = bp -> ulp_num_msix_want ;
@@ -12992,6 +12994,21 @@ static int bnxt_tx_nr_rings_per_tc(struct bnxt *bp)
1299212994 return bp -> num_tc ? bp -> tx_nr_rings / bp -> num_tc : bp -> tx_nr_rings ;
1299312995}
1299412996
12997+ static void bnxt_set_xdp_tx_rings (struct bnxt * bp )
12998+ {
12999+ bp -> tx_nr_rings_xdp = bp -> tx_nr_rings_per_tc ;
13000+ bp -> tx_nr_rings += bp -> tx_nr_rings_xdp ;
13001+ }
13002+
13003+ static void bnxt_adj_tx_rings (struct bnxt * bp )
13004+ {
13005+ /* Make adjustments if reserved TX rings are less than requested */
13006+ bp -> tx_nr_rings -= bp -> tx_nr_rings_xdp ;
13007+ bp -> tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc (bp );
13008+ if (bp -> tx_nr_rings_xdp )
13009+ bnxt_set_xdp_tx_rings (bp );
13010+ }
13011+
1299513012static int __bnxt_open_nic (struct bnxt * bp , bool irq_re_init , bool link_re_init )
1299613013{
1299713014 int rc = 0 ;
@@ -13009,13 +13026,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
1300913026 if (rc )
1301013027 return rc ;
1301113028
13012- /* Make adjustments if reserved TX rings are less than requested */
13013- bp -> tx_nr_rings -= bp -> tx_nr_rings_xdp ;
13014- bp -> tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc (bp );
13015- if (bp -> tx_nr_rings_xdp ) {
13016- bp -> tx_nr_rings_xdp = bp -> tx_nr_rings_per_tc ;
13017- bp -> tx_nr_rings += bp -> tx_nr_rings_xdp ;
13018- }
13029+ bnxt_adj_tx_rings (bp );
1301913030 rc = bnxt_alloc_mem (bp , irq_re_init );
1302013031 if (rc ) {
1302113032 netdev_err (bp -> dev , "bnxt_alloc_mem err: %x\n" , rc );
@@ -15436,11 +15447,19 @@ static int bnxt_change_mtu(struct net_device *dev, int new_mtu)
1543615447 return 0 ;
1543715448}
1543815449
15450+ void bnxt_set_cp_rings (struct bnxt * bp , bool sh )
15451+ {
15452+ int tx_cp = bnxt_num_tx_to_cp (bp , bp -> tx_nr_rings );
15453+
15454+ bp -> cp_nr_rings = sh ? max_t (int , tx_cp , bp -> rx_nr_rings ) :
15455+ tx_cp + bp -> rx_nr_rings ;
15456+ }
15457+
1543915458int bnxt_setup_mq_tc (struct net_device * dev , u8 tc )
1544015459{
1544115460 struct bnxt * bp = netdev_priv (dev );
1544215461 bool sh = false;
15443- int rc , tx_cp ;
15462+ int rc ;
1544415463
1544515464 if (tc > bp -> max_tc ) {
1544615465 netdev_err (dev , "Too many traffic classes requested: %d. Max supported is %d.\n" ,
@@ -15473,9 +15492,7 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)
1547315492 bp -> num_tc = 0 ;
1547415493 }
1547515494 bp -> tx_nr_rings += bp -> tx_nr_rings_xdp ;
15476- tx_cp = bnxt_num_tx_to_cp (bp , bp -> tx_nr_rings );
15477- bp -> cp_nr_rings = sh ? max_t (int , tx_cp , bp -> rx_nr_rings ) :
15478- tx_cp + bp -> rx_nr_rings ;
15495+ bnxt_set_cp_rings (bp , sh );
1547915496
1548015497 if (netif_running (bp -> dev ))
1548115498 return bnxt_open_nic (bp , true, false);
@@ -16525,6 +16542,19 @@ static void bnxt_trim_dflt_sh_rings(struct bnxt *bp)
1652516542 bp -> tx_nr_rings = bnxt_tx_nr_rings (bp );
1652616543}
1652716544
16545+ static void bnxt_adj_dflt_rings (struct bnxt * bp , bool sh )
16546+ {
16547+ if (sh )
16548+ bnxt_trim_dflt_sh_rings (bp );
16549+ else
16550+ bp -> cp_nr_rings = bp -> tx_nr_rings_per_tc + bp -> rx_nr_rings ;
16551+ bp -> tx_nr_rings = bnxt_tx_nr_rings (bp );
16552+ if (sh && READ_ONCE (bp -> xdp_prog )) {
16553+ bnxt_set_xdp_tx_rings (bp );
16554+ bnxt_set_cp_rings (bp , true);
16555+ }
16556+ }
16557+
1652816558static int bnxt_set_dflt_rings (struct bnxt * bp , bool sh )
1652916559{
1653016560 int dflt_rings , max_rx_rings , max_tx_rings , rc ;
@@ -16550,11 +16580,8 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)
1655016580 return rc ;
1655116581 bp -> rx_nr_rings = min_t (int , dflt_rings , max_rx_rings );
1655216582 bp -> tx_nr_rings_per_tc = min_t (int , dflt_rings , max_tx_rings );
16553- if (sh )
16554- bnxt_trim_dflt_sh_rings (bp );
16555- else
16556- bp -> cp_nr_rings = bp -> tx_nr_rings_per_tc + bp -> rx_nr_rings ;
16557- bp -> tx_nr_rings = bnxt_tx_nr_rings (bp );
16583+
16584+ bnxt_adj_dflt_rings (bp , sh );
1655816585
1655916586 avail_msix = bnxt_get_max_func_irqs (bp ) - bp -> cp_nr_rings ;
1656016587 if (avail_msix >= BNXT_MIN_ROCE_CP_RINGS ) {
@@ -16567,16 +16594,17 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)
1656716594 rc = __bnxt_reserve_rings (bp );
1656816595 if (rc && rc != - ENODEV )
1656916596 netdev_warn (bp -> dev , "Unable to reserve tx rings\n" );
16570- bp -> tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc (bp );
16597+
16598+ bnxt_adj_tx_rings (bp );
1657116599 if (sh )
16572- bnxt_trim_dflt_sh_rings (bp );
16600+ bnxt_adj_dflt_rings (bp , true );
1657316601
1657416602 /* Rings may have been trimmed, re-reserve the trimmed rings. */
1657516603 if (bnxt_need_reserve_rings (bp )) {
1657616604 rc = __bnxt_reserve_rings (bp );
1657716605 if (rc && rc != - ENODEV )
1657816606 netdev_warn (bp -> dev , "2nd rings reservation failed.\n" );
16579- bp -> tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc (bp );
16607+ bnxt_adj_tx_rings (bp );
1658016608 }
1658116609 if (BNXT_CHIP_TYPE_NITRO_A0 (bp )) {
1658216610 bp -> rx_nr_rings ++ ;
@@ -16610,7 +16638,7 @@ static int bnxt_init_dflt_ring_mode(struct bnxt *bp)
1661016638 if (rc )
1661116639 goto init_dflt_ring_err ;
1661216640
16613- bp -> tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc (bp );
16641+ bnxt_adj_tx_rings (bp );
1661416642
1661516643 bnxt_set_dflt_rfs (bp );
1661616644
0 commit comments