diff options
author | Jacob Keller <jacob.e.keller@intel.com> | 2014-09-03 04:12:57 -0400 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2014-09-18 06:57:09 -0400 |
commit | 3bcf344657afefdd468dd9c2b30a009ee7ce7abc (patch) | |
tree | 45bd5d215c5bd9ad2928561d518f401db297cbe6 | |
parent | 027bb561eff4a5c2185d3cbad6a41785eb50dded (diff) |
ixgbe: determine vector count inside ixgbe_acquire_msix_vectors
Our calculated v_budget doesn't matter except if we allocate MSI-X
vectors. We shouldn't need to calculate this outside of the function, so
don't. Instead, only calculate it once we attempt to acquire MSI-X
vectors. This helps collocate all of the MSI-X vector code together.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r-- | drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c index f504fafa00bd..39df14f08aaa 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c | |||
@@ -696,23 +696,45 @@ static void ixgbe_set_num_queues(struct ixgbe_adapter *adapter) | |||
696 | ixgbe_set_rss_queues(adapter); | 696 | ixgbe_set_rss_queues(adapter); |
697 | } | 697 | } |
698 | 698 | ||
699 | static int ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter, | 699 | /** |
700 | int vectors) | 700 | * ixgbe_acquire_msix_vectors - acquire MSI-X vectors |
701 | * @adapter: board private structure | ||
702 | * | ||
703 | * Attempts to acquire a suitable range of MSI-X vector interrupts. Will | ||
704 | * return a negative error code if unable to acquire MSI-X vectors for any | ||
705 | * reason. | ||
706 | */ | ||
707 | static int ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter) | ||
701 | { | 708 | { |
702 | int i, vector_threshold; | 709 | struct ixgbe_hw *hw = &adapter->hw; |
710 | int i, vectors, vector_threshold; | ||
711 | |||
712 | /* We start by asking for one vector per queue pair */ | ||
713 | vectors = max(adapter->num_rx_queues, adapter->num_tx_queues); | ||
703 | 714 | ||
704 | /* We'll want at least 2 (vector_threshold): | 715 | /* It is easy to be greedy for MSI-X vectors. However, it really |
705 | * 1) TxQ[0] + RxQ[0] handler | 716 | * doesn't do much good if we have a lot more vectors than CPUs. We'll |
706 | * 2) Other (Link Status Change, etc.) | 717 | * be somewhat conservative and only ask for (roughly) the same number |
718 | * of vectors as there are CPUs. | ||
707 | */ | 719 | */ |
708 | vector_threshold = MIN_MSIX_COUNT; | 720 | vectors = min_t(int, vectors, num_online_cpus()); |
709 | 721 | ||
710 | /* | 722 | /* Some vectors are necessary for non-queue interrupts */ |
711 | * The more we get, the more we will assign to Tx/Rx Cleanup | 723 | vectors += NON_Q_VECTORS; |
712 | * for the separate queues...where Rx Cleanup >= Tx Cleanup. | 724 | |
713 | * Right now, we simply care about how many we'll get; we'll | 725 | /* Hardware can only support a maximum of hw.mac->max_msix_vectors. |
714 | * set them up later while requesting irq's. | 726 | * With features such as RSS and VMDq, we can easily surpass the |
727 | * number of Rx and Tx descriptor queues supported by our device. | ||
728 | * Thus, we cap the maximum in the rare cases where the CPU count also | ||
729 | * exceeds our vector limit | ||
730 | */ | ||
731 | vectors = min_t(int, vectors, hw->mac.max_msix_vectors); | ||
732 | |||
733 | /* We want a minimum of two MSI-X vectors for (1) a TxQ[0] + RxQ[0] | ||
734 | * handler, and (2) an Other (Link Status Change, etc.) handler. | ||
715 | */ | 735 | */ |
736 | vector_threshold = MIN_MSIX_COUNT; | ||
737 | |||
716 | adapter->msix_entries = kcalloc(vectors, | 738 | adapter->msix_entries = kcalloc(vectors, |
717 | sizeof(struct msix_entry), | 739 | sizeof(struct msix_entry), |
718 | GFP_KERNEL); | 740 | GFP_KERNEL); |
@@ -1069,32 +1091,10 @@ static void ixgbe_reset_interrupt_capability(struct ixgbe_adapter *adapter) | |||
1069 | **/ | 1091 | **/ |
1070 | static void ixgbe_set_interrupt_capability(struct ixgbe_adapter *adapter) | 1092 | static void ixgbe_set_interrupt_capability(struct ixgbe_adapter *adapter) |
1071 | { | 1093 | { |
1072 | struct ixgbe_hw *hw = &adapter->hw; | 1094 | int err; |
1073 | int v_budget, err; | ||
1074 | |||
1075 | /* | ||
1076 | * It's easy to be greedy for MSI-X vectors, but it really | ||
1077 | * doesn't do us much good if we have a lot more vectors | ||
1078 | * than CPU's. So let's be conservative and only ask for | ||
1079 | * (roughly) the same number of vectors as there are CPU's. | ||
1080 | * The default is to use pairs of vectors. | ||
1081 | */ | ||
1082 | v_budget = max(adapter->num_rx_queues, adapter->num_tx_queues); | ||
1083 | v_budget = min_t(int, v_budget, num_online_cpus()); | ||
1084 | v_budget += NON_Q_VECTORS; | ||
1085 | |||
1086 | /* | ||
1087 | * At the same time, hardware can only support a maximum of | ||
1088 | * hw.mac->max_msix_vectors vectors. With features | ||
1089 | * such as RSS and VMDq, we can easily surpass the number of Rx and Tx | ||
1090 | * descriptor queues supported by our device. Thus, we cap it off in | ||
1091 | * those rare cases where the cpu count also exceeds our vector limit. | ||
1092 | */ | ||
1093 | v_budget = min_t(int, v_budget, hw->mac.max_msix_vectors); | ||
1094 | 1095 | ||
1095 | /* A failure in MSI-X entry allocation isn't fatal, but it does | 1096 | /* We will try to get MSI-X interrupts first */ |
1096 | * mean we disable MSI-X capabilities of the adapter. */ | 1097 | if (!ixgbe_acquire_msix_vectors(adapter)) |
1097 | if (!ixgbe_acquire_msix_vectors(adapter, v_budget)) | ||
1098 | return; | 1098 | return; |
1099 | 1099 | ||
1100 | /* At this point, we do not have MSI-X capabilities. We need to | 1100 | /* At this point, we do not have MSI-X capabilities. We need to |