@@ -1057,7 +1057,8 @@ freeout: t4_free_sge_resources(adap);
1057
1057
1058
1058
ALLOC_OFLD_RXQS (s -> ofldrxq , s -> ofldqsets , j , s -> ofld_rxq );
1059
1059
ALLOC_OFLD_RXQS (s -> rdmarxq , s -> rdmaqs , 1 , s -> rdma_rxq );
1060
- ALLOC_OFLD_RXQS (s -> rdmaciq , s -> rdmaciqs , 1 , s -> rdma_ciq );
1060
+ j = s -> rdmaciqs / adap -> params .nports ; /* rdmaq queues per channel */
1061
+ ALLOC_OFLD_RXQS (s -> rdmaciq , s -> rdmaciqs , j , s -> rdma_ciq );
1061
1062
1062
1063
#undef ALLOC_OFLD_RXQS
1063
1064
@@ -5702,7 +5703,16 @@ static void cfg_queues(struct adapter *adap)
5702
5703
s -> ofldqsets = adap -> params .nports ;
5703
5704
/* For RDMA one Rx queue per channel suffices */
5704
5705
s -> rdmaqs = adap -> params .nports ;
5705
- s -> rdmaciqs = adap -> params .nports ;
5706
+ /* Try and allow at least 1 CIQ per cpu rounding down
5707
+ * to the number of ports, with a minimum of 1 per port.
5708
+ * A 2 port card in a 6 cpu system: 6 CIQs, 3 / port.
5709
+ * A 4 port card in a 6 cpu system: 4 CIQs, 1 / port.
5710
+ * A 4 port card in a 2 cpu system: 4 CIQs, 1 / port.
5711
+ */
5712
+ s -> rdmaciqs = min_t (int , MAX_RDMA_CIQS , num_online_cpus ());
5713
+ s -> rdmaciqs = (s -> rdmaciqs / adap -> params .nports ) *
5714
+ adap -> params .nports ;
5715
+ s -> rdmaciqs = max_t (int , s -> rdmaciqs , adap -> params .nports );
5706
5716
}
5707
5717
5708
5718
for (i = 0 ; i < ARRAY_SIZE (s -> ethrxq ); i ++ ) {
@@ -5788,12 +5798,17 @@ static void reduce_ethqs(struct adapter *adap, int n)
5788
5798
static int enable_msix (struct adapter * adap )
5789
5799
{
5790
5800
int ofld_need = 0 ;
5791
- int i , want , need ;
5801
+ int i , want , need , allocated ;
5792
5802
struct sge * s = & adap -> sge ;
5793
5803
unsigned int nchan = adap -> params .nports ;
5794
- struct msix_entry entries [MAX_INGQ + 1 ];
5804
+ struct msix_entry * entries ;
5805
+
5806
+ entries = kmalloc (sizeof (* entries ) * (MAX_INGQ + 1 ),
5807
+ GFP_KERNEL );
5808
+ if (!entries )
5809
+ return - ENOMEM ;
5795
5810
5796
- for (i = 0 ; i < ARRAY_SIZE ( entries ) ; ++ i )
5811
+ for (i = 0 ; i < MAX_INGQ + 1 ; ++ i )
5797
5812
entries [i ].entry = i ;
5798
5813
5799
5814
want = s -> max_ethqsets + EXTRA_VECS ;
@@ -5810,29 +5825,39 @@ static int enable_msix(struct adapter *adap)
5810
5825
#else
5811
5826
need = adap -> params .nports + EXTRA_VECS + ofld_need ;
5812
5827
#endif
5813
- want = pci_enable_msix_range (adap -> pdev , entries , need , want );
5814
- if (want < 0 )
5815
- return want ;
5828
+ allocated = pci_enable_msix_range (adap -> pdev , entries , need , want );
5829
+ if (allocated < 0 ) {
5830
+ dev_info (adap -> pdev_dev , "not enough MSI-X vectors left,"
5831
+ " not using MSI-X\n" );
5832
+ kfree (entries );
5833
+ return allocated ;
5834
+ }
5816
5835
5817
- /*
5818
- * Distribute available vectors to the various queue groups.
5836
+ /* Distribute available vectors to the various queue groups.
5819
5837
* Every group gets its minimum requirement and NIC gets top
5820
5838
* priority for leftovers.
5821
5839
*/
5822
- i = want - EXTRA_VECS - ofld_need ;
5840
+ i = allocated - EXTRA_VECS - ofld_need ;
5823
5841
if (i < s -> max_ethqsets ) {
5824
5842
s -> max_ethqsets = i ;
5825
5843
if (i < s -> ethqsets )
5826
5844
reduce_ethqs (adap , i );
5827
5845
}
5828
5846
if (is_offload (adap )) {
5829
- i = want - EXTRA_VECS - s -> max_ethqsets ;
5830
- i -= ofld_need - nchan ;
5847
+ if (allocated < want ) {
5848
+ s -> rdmaqs = nchan ;
5849
+ s -> rdmaciqs = nchan ;
5850
+ }
5851
+
5852
+ /* leftovers go to OFLD */
5853
+ i = allocated - EXTRA_VECS - s -> max_ethqsets -
5854
+ s -> rdmaqs - s -> rdmaciqs ;
5831
5855
s -> ofldqsets = (i / nchan ) * nchan ; /* round down */
5832
5856
}
5833
- for (i = 0 ; i < want ; ++ i )
5857
+ for (i = 0 ; i < allocated ; ++ i )
5834
5858
adap -> msix_info [i ].vec = entries [i ].vector ;
5835
5859
5860
+ kfree (entries );
5836
5861
return 0 ;
5837
5862
}
5838
5863
0 commit comments