PCI/MSI: Introduce pcim_enable_msi*() family helpers

Currently many device drivers need contiguously call functions
pci_enable_msix() for MSI-X or pci_enable_msi_block() for MSI
in a loop until success or failure. This update generalizes
this usage pattern and introduces pcim_enable_msi*() family
helpers.

As result, device drivers do not have to deal with tri-state
return values from pci_enable_msix() and pci_enable_msi_block()
functions directly and expected to have more clearer and straight
code.

So i.e. the request loop described in the documentation...

	int foo_driver_enable_msix(struct foo_adapter *adapter,
				   int nvec)
	{
		while (nvec >= FOO_DRIVER_MINIMUM_NVEC) {
			rc = pci_enable_msix(adapter->pdev,
					     adapter->msix_entries,
					     nvec);
			if (rc > 0)
				nvec = rc;
			else
				return rc;
		}

		return -ENOSPC;
	}

...would turn into a single helper call....

	rc = pcim_enable_msix_range(adapter->pdev,
				    adapter->msix_entries,
				    nvec,
				    FOO_DRIVER_MINIMUM_NVEC);

Device drivers with more specific requirements (i.e. a number of
MSI-Xs which is a multiple of a certain number within a specified
range) would still need to implement the loop using the two old
functions.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Suggested-by: Ben Hutchings <bhutchings@solarflare.com>
ipr: Do not call pci_disable_msi/msix() if pci_enable_msi/msix() failed

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
ipr: Make use of pcim_enable_msi/msix() interfaces

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
ixgbe: Make use of pcim_enable_msix_range() interface

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
ixgbevf: Make use of pcim_enable_msix_range() interface

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
megaraid: Make use of pcim_enable_msix() interface

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
ntb: Fix missed call to pci_enable_msix()

Current MSI-X enablement code assumes MSI-Xs were successfully
allocated in case less than requested vectors were available.
That assumption is wrong, since MSI-Xs should be enabled with
a repeated call to pci_enable_msix(). This update fixes this.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Acked-by: Jon Mason <jon.mason@intel.com>
ntb: Make use of pcim_enable_msix/msix_exact() interfaces

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
qib: Make use of pcim_enable_msix() and pci_msix_table_size() interfaces

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
qla2xxx: Make use of pcim_enable_msix_range() interface

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
qlge: Get rid of an redundant assignment

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
qlge: Make use of pcim_enable_msix() interface

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
tg3: Make use of pcim_enable_msix() interface

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
vmxnet3: Return -EINVAL if number of requested MSI-Xs is not enough

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
vmxnet3: Fixup a weird loop exit

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
vmxnet3: Return -ENOSPC when not enough MSI-X vectors available

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
vmxnet3: Limit number of rx queues to 1 if per-queue MSI-Xs failed

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
vmxnet3: Make use of pcim_enable_msix_range() interface

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>