@@ -6284,7 +6284,8 @@ static int bnxt_hwrm_get_rings(struct bnxt *bp)
6284
6284
if (bp -> flags & BNXT_FLAG_AGG_RINGS )
6285
6285
rx >>= 1 ;
6286
6286
if (cp < (rx + tx )) {
6287
- bnxt_trim_rings (bp , & rx , & tx , cp , false);
6287
+ rx = cp / 2 ;
6288
+ tx = rx ;
6288
6289
if (bp -> flags & BNXT_FLAG_AGG_RINGS )
6289
6290
rx <<= 1 ;
6290
6291
hw_resc -> resv_rx_rings = rx ;
@@ -6585,6 +6586,7 @@ static int __bnxt_reserve_rings(struct bnxt *bp)
6585
6586
int grp , rx_rings , rc ;
6586
6587
int vnic = 1 , stat ;
6587
6588
bool sh = false;
6589
+ int tx_cp ;
6588
6590
6589
6591
if (!bnxt_need_reserve_rings (bp ))
6590
6592
return 0 ;
@@ -6634,7 +6636,8 @@ static int __bnxt_reserve_rings(struct bnxt *bp)
6634
6636
rc = bnxt_trim_rings (bp , & rx_rings , & tx , cp , sh );
6635
6637
if (bp -> flags & BNXT_FLAG_AGG_RINGS )
6636
6638
rx = rx_rings << 1 ;
6637
- cp = sh ? max_t (int , tx , rx_rings ) : tx + rx_rings ;
6639
+ tx_cp = bnxt_num_tx_to_cp (bp , tx );
6640
+ cp = sh ? max_t (int , tx_cp , rx_rings ) : tx_cp + rx_rings ;
6638
6641
bp -> tx_nr_rings = tx ;
6639
6642
6640
6643
/* If we cannot reserve all the RX rings, reset the RSS map only
@@ -9061,8 +9064,8 @@ static int bnxt_set_real_num_queues(struct bnxt *bp)
9061
9064
return rc ;
9062
9065
}
9063
9066
9064
- static int bnxt_trim_rings (struct bnxt * bp , int * rx , int * tx , int max ,
9065
- bool shared )
9067
+ static int __bnxt_trim_rings (struct bnxt * bp , int * rx , int * tx , int max ,
9068
+ bool shared )
9066
9069
{
9067
9070
int _rx = * rx , _tx = * tx ;
9068
9071
@@ -9085,6 +9088,46 @@ static int bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max,
9085
9088
return 0 ;
9086
9089
}
9087
9090
9091
+ static int __bnxt_num_tx_to_cp (struct bnxt * bp , int tx , int tx_sets , int tx_xdp )
9092
+ {
9093
+ return tx ;
9094
+ }
9095
+
9096
+ int bnxt_num_tx_to_cp (struct bnxt * bp , int tx )
9097
+ {
9098
+ int tcs = netdev_get_num_tc (bp -> dev );
9099
+
9100
+ if (!tcs )
9101
+ tcs = 1 ;
9102
+ return __bnxt_num_tx_to_cp (bp , tx , tcs , bp -> tx_nr_rings_xdp );
9103
+ }
9104
+
9105
+ static int bnxt_num_cp_to_tx (struct bnxt * bp , int tx_cp )
9106
+ {
9107
+ int tcs = netdev_get_num_tc (bp -> dev );
9108
+
9109
+ return (tx_cp - bp -> tx_nr_rings_xdp ) * tcs +
9110
+ bp -> tx_nr_rings_xdp ;
9111
+ }
9112
+
9113
+ static int bnxt_trim_rings (struct bnxt * bp , int * rx , int * tx , int max ,
9114
+ bool sh )
9115
+ {
9116
+ int tx_cp = bnxt_num_tx_to_cp (bp , * tx );
9117
+
9118
+ if (tx_cp != * tx ) {
9119
+ int tx_saved = tx_cp , rc ;
9120
+
9121
+ rc = __bnxt_trim_rings (bp , rx , & tx_cp , max , sh );
9122
+ if (rc )
9123
+ return rc ;
9124
+ if (tx_cp != tx_saved )
9125
+ * tx = bnxt_num_cp_to_tx (bp , tx_cp );
9126
+ return 0 ;
9127
+ }
9128
+ return __bnxt_trim_rings (bp , rx , tx , max , sh );
9129
+ }
9130
+
9088
9131
static void bnxt_setup_msix (struct bnxt * bp )
9089
9132
{
9090
9133
const int len = sizeof (bp -> irq_tbl [0 ].name );
@@ -9247,7 +9290,7 @@ static int bnxt_get_num_msix(struct bnxt *bp)
9247
9290
9248
9291
static int bnxt_init_msix (struct bnxt * bp )
9249
9292
{
9250
- int i , total_vecs , max , rc = 0 , min = 1 , ulp_msix ;
9293
+ int i , total_vecs , max , rc = 0 , min = 1 , ulp_msix , tx_cp ;
9251
9294
struct msix_entry * msix_ent ;
9252
9295
9253
9296
total_vecs = bnxt_get_num_msix (bp );
@@ -9289,9 +9332,10 @@ static int bnxt_init_msix(struct bnxt *bp)
9289
9332
if (rc )
9290
9333
goto msix_setup_exit ;
9291
9334
9335
+ tx_cp = bnxt_num_tx_to_cp (bp , bp -> tx_nr_rings );
9292
9336
bp -> cp_nr_rings = (min == 1 ) ?
9293
- max_t (int , bp -> tx_nr_rings , bp -> rx_nr_rings ) :
9294
- bp -> tx_nr_rings + bp -> rx_nr_rings ;
9337
+ max_t (int , tx_cp , bp -> rx_nr_rings ) :
9338
+ tx_cp + bp -> rx_nr_rings ;
9295
9339
9296
9340
} else {
9297
9341
rc = - ENOMEM ;
@@ -12186,23 +12230,27 @@ static void bnxt_sp_task(struct work_struct *work)
12186
12230
clear_bit (BNXT_STATE_IN_SP_TASK , & bp -> state );
12187
12231
}
12188
12232
12233
+ static void _bnxt_get_max_rings (struct bnxt * bp , int * max_rx , int * max_tx ,
12234
+ int * max_cp );
12235
+
12189
12236
/* Under rtnl_lock */
12190
12237
int bnxt_check_rings (struct bnxt * bp , int tx , int rx , bool sh , int tcs ,
12191
12238
int tx_xdp )
12192
12239
{
12193
- int max_rx , max_tx , tx_sets = 1 ;
12240
+ int max_rx , max_tx , max_cp , tx_sets = 1 , tx_cp ;
12194
12241
int tx_rings_needed , stats ;
12195
12242
int rx_rings = rx ;
12196
- int cp , vnics , rc ;
12243
+ int cp , vnics ;
12197
12244
12198
12245
if (tcs )
12199
12246
tx_sets = tcs ;
12200
12247
12201
- rc = bnxt_get_max_rings (bp , & max_rx , & max_tx , sh );
12202
- if (rc )
12203
- return rc ;
12248
+ if (bp -> flags & BNXT_FLAG_AGG_RINGS )
12249
+ rx_rings <<= 1 ;
12204
12250
12205
- if (max_rx < rx )
12251
+ _bnxt_get_max_rings (bp , & max_rx , & max_tx , & max_cp );
12252
+
12253
+ if (max_rx < rx_rings )
12206
12254
return - ENOMEM ;
12207
12255
12208
12256
tx_rings_needed = tx * tx_sets + tx_xdp ;
@@ -12211,11 +12259,12 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
12211
12259
12212
12260
vnics = 1 ;
12213
12261
if ((bp -> flags & (BNXT_FLAG_RFS | BNXT_FLAG_CHIP_P5 )) == BNXT_FLAG_RFS )
12214
- vnics += rx_rings ;
12262
+ vnics += rx ;
12215
12263
12216
- if (bp -> flags & BNXT_FLAG_AGG_RINGS )
12217
- rx_rings <<= 1 ;
12218
- cp = sh ? max_t (int , tx_rings_needed , rx ) : tx_rings_needed + rx ;
12264
+ tx_cp = __bnxt_num_tx_to_cp (bp , tx_rings_needed , tx_sets , tx_xdp );
12265
+ cp = sh ? max_t (int , tx_cp , rx ) : tx_cp + rx ;
12266
+ if (max_cp < cp )
12267
+ return - ENOMEM ;
12219
12268
stats = cp ;
12220
12269
if (BNXT_NEW_RM (bp )) {
12221
12270
cp += bnxt_get_ulp_msix_num (bp );
@@ -12849,7 +12898,7 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)
12849
12898
{
12850
12899
struct bnxt * bp = netdev_priv (dev );
12851
12900
bool sh = false;
12852
- int rc ;
12901
+ int rc , tx_cp ;
12853
12902
12854
12903
if (tc > bp -> max_tc ) {
12855
12904
netdev_err (dev , "Too many traffic classes requested: %d. Max supported is %d.\n" ,
@@ -12880,8 +12929,9 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)
12880
12929
netdev_reset_tc (dev );
12881
12930
}
12882
12931
bp -> tx_nr_rings += bp -> tx_nr_rings_xdp ;
12883
- bp -> cp_nr_rings = sh ? max_t (int , bp -> tx_nr_rings , bp -> rx_nr_rings ) :
12884
- bp -> tx_nr_rings + bp -> rx_nr_rings ;
12932
+ tx_cp = bnxt_num_tx_to_cp (bp , bp -> tx_nr_rings );
12933
+ bp -> cp_nr_rings = sh ? max_t (int , tx_cp , bp -> rx_nr_rings ) :
12934
+ tx_cp + bp -> rx_nr_rings ;
12885
12935
12886
12936
if (netif_running (bp -> dev ))
12887
12937
return bnxt_open_nic (bp , true, false);
@@ -13360,7 +13410,10 @@ static void _bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx,
13360
13410
if (bp -> flags & BNXT_FLAG_AGG_RINGS )
13361
13411
* max_rx >>= 1 ;
13362
13412
if (bp -> flags & BNXT_FLAG_CHIP_P5 ) {
13363
- bnxt_trim_rings (bp , max_rx , max_tx , * max_cp , false);
13413
+ if (* max_cp < (* max_rx + * max_tx )) {
13414
+ * max_rx = * max_cp / 2 ;
13415
+ * max_tx = * max_rx ;
13416
+ }
13364
13417
/* On P5 chips, max_cp output param should be available NQs */
13365
13418
* max_cp = max_irq ;
13366
13419
}
0 commit comments