@@ -12992,6 +12992,21 @@ static int bnxt_tx_nr_rings_per_tc(struct bnxt *bp)
1299212992 return bp -> num_tc ? bp -> tx_nr_rings / bp -> num_tc : bp -> tx_nr_rings ;
1299312993}
1299412994
12995+ static void bnxt_set_xdp_tx_rings (struct bnxt * bp )
12996+ {
12997+ bp -> tx_nr_rings_xdp = bp -> tx_nr_rings_per_tc ;
12998+ bp -> tx_nr_rings += bp -> tx_nr_rings_xdp ;
12999+ }
13000+
13001+ static void bnxt_adj_tx_rings (struct bnxt * bp )
13002+ {
13003+ /* Make adjustments if reserved TX rings are less than requested */
13004+ bp -> tx_nr_rings -= bp -> tx_nr_rings_xdp ;
13005+ bp -> tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc (bp );
13006+ if (bp -> tx_nr_rings_xdp )
13007+ bnxt_set_xdp_tx_rings (bp );
13008+ }
13009+
1299513010static int __bnxt_open_nic (struct bnxt * bp , bool irq_re_init , bool link_re_init )
1299613011{
1299713012 int rc = 0 ;
@@ -13009,13 +13024,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
1300913024 if (rc )
1301013025 return rc ;
1301113026
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- }
13027+ bnxt_adj_tx_rings (bp );
1301913028 rc = bnxt_alloc_mem (bp , irq_re_init );
1302013029 if (rc ) {
1302113030 netdev_err (bp -> dev , "bnxt_alloc_mem err: %x\n" , rc );
@@ -15436,11 +15445,19 @@ static int bnxt_change_mtu(struct net_device *dev, int new_mtu)
1543615445 return 0 ;
1543715446}
1543815447
15448+ void bnxt_set_cp_rings (struct bnxt * bp , bool sh )
15449+ {
15450+ int tx_cp = bnxt_num_tx_to_cp (bp , bp -> tx_nr_rings );
15451+
15452+ bp -> cp_nr_rings = sh ? max_t (int , tx_cp , bp -> rx_nr_rings ) :
15453+ tx_cp + bp -> rx_nr_rings ;
15454+ }
15455+
1543915456int bnxt_setup_mq_tc (struct net_device * dev , u8 tc )
1544015457{
1544115458 struct bnxt * bp = netdev_priv (dev );
1544215459 bool sh = false;
15443- int rc , tx_cp ;
15460+ int rc ;
1544415461
1544515462 if (tc > bp -> max_tc ) {
1544615463 netdev_err (dev , "Too many traffic classes requested: %d. Max supported is %d.\n" ,
@@ -15473,9 +15490,7 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)
1547315490 bp -> num_tc = 0 ;
1547415491 }
1547515492 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 ;
15493+ bnxt_set_cp_rings (bp , sh );
1547915494
1548015495 if (netif_running (bp -> dev ))
1548115496 return bnxt_open_nic (bp , true, false);
@@ -16525,6 +16540,15 @@ static void bnxt_trim_dflt_sh_rings(struct bnxt *bp)
1652516540 bp -> tx_nr_rings = bnxt_tx_nr_rings (bp );
1652616541}
1652716542
16543+ static void bnxt_adj_dflt_rings (struct bnxt * bp , bool sh )
16544+ {
16545+ if (sh )
16546+ bnxt_trim_dflt_sh_rings (bp );
16547+ else
16548+ bp -> cp_nr_rings = bp -> tx_nr_rings_per_tc + bp -> rx_nr_rings ;
16549+ bp -> tx_nr_rings = bnxt_tx_nr_rings (bp );
16550+ }
16551+
1652816552static int bnxt_set_dflt_rings (struct bnxt * bp , bool sh )
1652916553{
1653016554 int dflt_rings , max_rx_rings , max_tx_rings , rc ;
@@ -16550,11 +16574,8 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)
1655016574 return rc ;
1655116575 bp -> rx_nr_rings = min_t (int , dflt_rings , max_rx_rings );
1655216576 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 );
16577+
16578+ bnxt_adj_dflt_rings (bp , sh );
1655816579
1655916580 avail_msix = bnxt_get_max_func_irqs (bp ) - bp -> cp_nr_rings ;
1656016581 if (avail_msix >= BNXT_MIN_ROCE_CP_RINGS ) {
0 commit comments