@@ -4756,7 +4756,7 @@ static int bnxt_cp_rings_in_use(struct bnxt *bp)
4756
4756
static bool bnxt_need_reserve_rings (struct bnxt * bp )
4757
4757
{
4758
4758
struct bnxt_hw_resc * hw_resc = & bp -> hw_resc ;
4759
- int cp = bp -> cp_nr_rings ;
4759
+ int cp = bnxt_cp_rings_in_use ( bp ) ;
4760
4760
int rx = bp -> rx_nr_rings ;
4761
4761
int vnic = 1 , grp = rx ;
4762
4762
@@ -4783,9 +4783,9 @@ static int bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max,
4783
4783
static int __bnxt_reserve_rings (struct bnxt * bp )
4784
4784
{
4785
4785
struct bnxt_hw_resc * hw_resc = & bp -> hw_resc ;
4786
+ int cp = bnxt_cp_rings_in_use (bp );
4786
4787
int tx = bp -> tx_nr_rings ;
4787
4788
int rx = bp -> rx_nr_rings ;
4788
- int cp = bp -> cp_nr_rings ;
4789
4789
int grp , rx_rings , rc ;
4790
4790
bool sh = false;
4791
4791
int vnic = 1 ;
@@ -5908,7 +5908,7 @@ void bnxt_set_max_func_cp_rings(struct bnxt *bp, unsigned int max)
5908
5908
bp -> hw_resc .max_cp_rings = max ;
5909
5909
}
5910
5910
5911
- static unsigned int bnxt_get_max_func_irqs (struct bnxt * bp )
5911
+ unsigned int bnxt_get_max_func_irqs (struct bnxt * bp )
5912
5912
{
5913
5913
struct bnxt_hw_resc * hw_resc = & bp -> hw_resc ;
5914
5914
@@ -5920,6 +5920,26 @@ void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max_irqs)
5920
5920
bp -> hw_resc .max_irqs = max_irqs ;
5921
5921
}
5922
5922
5923
+ int bnxt_get_avail_msix (struct bnxt * bp , int num )
5924
+ {
5925
+ int max_cp = bnxt_get_max_func_cp_rings (bp );
5926
+ int max_irq = bnxt_get_max_func_irqs (bp );
5927
+ int total_req = bp -> cp_nr_rings + num ;
5928
+ int max_idx , avail_msix ;
5929
+
5930
+ max_idx = min_t (int , bp -> total_irqs , max_cp );
5931
+ avail_msix = max_idx - bp -> cp_nr_rings ;
5932
+ if (!(bp -> flags & BNXT_FLAG_NEW_RM ) || avail_msix >= num )
5933
+ return avail_msix ;
5934
+
5935
+ if (max_irq < total_req ) {
5936
+ num = max_irq - bp -> cp_nr_rings ;
5937
+ if (num <= 0 )
5938
+ return 0 ;
5939
+ }
5940
+ return num ;
5941
+ }
5942
+
5923
5943
static int bnxt_get_num_msix (struct bnxt * bp )
5924
5944
{
5925
5945
if (!(bp -> flags & BNXT_FLAG_NEW_RM ))
@@ -5930,7 +5950,7 @@ static int bnxt_get_num_msix(struct bnxt *bp)
5930
5950
5931
5951
static int bnxt_init_msix (struct bnxt * bp )
5932
5952
{
5933
- int i , total_vecs , max , rc = 0 , min = 1 ;
5953
+ int i , total_vecs , max , rc = 0 , min = 1 , ulp_msix ;
5934
5954
struct msix_entry * msix_ent ;
5935
5955
5936
5956
total_vecs = bnxt_get_num_msix (bp );
@@ -5951,7 +5971,8 @@ static int bnxt_init_msix(struct bnxt *bp)
5951
5971
min = 2 ;
5952
5972
5953
5973
total_vecs = pci_enable_msix_range (bp -> pdev , msix_ent , min , total_vecs );
5954
- if (total_vecs < 0 ) {
5974
+ ulp_msix = bnxt_get_ulp_msix_num (bp );
5975
+ if (total_vecs < 0 || total_vecs < ulp_msix ) {
5955
5976
rc = - ENODEV ;
5956
5977
goto msix_setup_exit ;
5957
5978
}
@@ -5964,7 +5985,7 @@ static int bnxt_init_msix(struct bnxt *bp)
5964
5985
bp -> total_irqs = total_vecs ;
5965
5986
/* Trim rings based upon num of vectors allocated */
5966
5987
rc = bnxt_trim_rings (bp , & bp -> rx_nr_rings , & bp -> tx_nr_rings ,
5967
- total_vecs , min == 1 );
5988
+ total_vecs - ulp_msix , min == 1 );
5968
5989
if (rc )
5969
5990
goto msix_setup_exit ;
5970
5991
@@ -6028,9 +6049,8 @@ static void bnxt_clear_int_mode(struct bnxt *bp)
6028
6049
bp -> flags &= ~BNXT_FLAG_USING_MSIX ;
6029
6050
}
6030
6051
6031
- static int bnxt_reserve_rings (struct bnxt * bp )
6052
+ int bnxt_reserve_rings (struct bnxt * bp )
6032
6053
{
6033
- int orig_cp = bp -> hw_resc .resv_cp_rings ;
6034
6054
int tcs = netdev_get_num_tc (bp -> dev );
6035
6055
int rc ;
6036
6056
@@ -6042,7 +6062,8 @@ static int bnxt_reserve_rings(struct bnxt *bp)
6042
6062
netdev_err (bp -> dev , "ring reservation failure rc: %d\n" , rc );
6043
6063
return rc ;
6044
6064
}
6045
- if ((bp -> flags & BNXT_FLAG_NEW_RM ) && bp -> cp_nr_rings > orig_cp ) {
6065
+ if ((bp -> flags & BNXT_FLAG_NEW_RM ) &&
6066
+ (bnxt_get_num_msix (bp ) != bp -> total_irqs )) {
6046
6067
bnxt_clear_int_mode (bp );
6047
6068
rc = bnxt_init_int_mode (bp );
6048
6069
if (rc )
0 commit comments