[dpdk-dev] kni: fix pci_enable_msix_range error handling

Message ID 1513577790-6608-1-git-send-email-aroulin@cumulusnetworks.com (mailing list archive)
State Rejected, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Andy Roulin Dec. 18, 2017, 6:16 a.m. UTC
  pci_enable_msix_range's return value has a different meaning than what
was previously returned by pci_enable_msix.

"It returns a negative errno if an error occurs. If it succeeds, it
returns the actual number of interrupts allocated and indicates the
successful configuration of MSI-X capability structure with new
allocated MSI-X interrupts."

The following commit introduced pci_enable_msix_range:
dpdk: 9fb3cd2c ("kni: fix ethtool build with kernel 4.11")
http://dpdk.org/dev/patchwork/patch/24076/

Signed-off-by: Andy Roulin <aroulin@cumulusnetworks.com>
---
 lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Comments

Ferruh Yigit Feb. 5, 2018, 7:05 p.m. UTC | #1
On 12/18/2017 6:16 AM, Andy Roulin wrote:
> pci_enable_msix_range's return value has a different meaning than what
> was previously returned by pci_enable_msix.
> 
> "It returns a negative errno if an error occurs. If it succeeds, it
> returns the actual number of interrupts allocated and indicates the
> successful configuration of MSI-X capability structure with new
> allocated MSI-X interrupts."
> 
> The following commit introduced pci_enable_msix_range:
> dpdk: 9fb3cd2c ("kni: fix ethtool build with kernel 4.11")
> http://dpdk.org/dev/patchwork/patch/24076/

Hi Andy,

This is updating driver within KNI, and these drivers are used for ethtool
support and most of the driver is already not used at all.

I doubt the updated code is functional at all.

Did you encounter any problem?

These drivers are already outdated, and I am definitely not for actively
maintaining them which is not required for ethtool support.

> 
> Signed-off-by: Andy Roulin <aroulin@cumulusnetworks.com>
> ---
>  lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
> index e0f427a..32ef3b9 100644
> --- a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
> +++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
> @@ -1043,14 +1043,16 @@ static void igb_set_interrupt_capability(struct igb_adapter *adapter, bool msix)
>  #ifdef HAVE_PCI_ENABLE_MSIX
>  			err = pci_enable_msix(pdev,
>  			                      adapter->msix_entries, numvecs);
> +			if (err == 0)
> +				break;
>  #else
>  			err = pci_enable_msix_range(pdev,
>  					adapter->msix_entries,
>  					numvecs,
>  					numvecs);
> -#endif
> -			if (err == 0)
> +			if (err < 0)
>  				break;
> +#endif
>  		}
>  		/* MSI-X failed, so fall through and try MSI */
>  		dev_warn(pci_dev_to_dev(pdev), "Failed to initialize MSI-X interrupts. "
>
  
Andy Roulin Feb. 5, 2018, 7:46 p.m. UTC | #2
Hi Ferruh,

You can drop it then. I  encountered the same porting bug in another
project and came across dpdk's code and patchwork comments which helped me
debugging. I just thought I would contribute the fix back. If it's not
functional then just drop it :)

Andy

On Mon, Feb 5, 2018 at 11:05 AM Ferruh Yigit <ferruh.yigit@intel.com> wrote:

> On 12/18/2017 6:16 AM, Andy Roulin wrote:
> > pci_enable_msix_range's return value has a different meaning than what
> > was previously returned by pci_enable_msix.
> >
> > "It returns a negative errno if an error occurs. If it succeeds, it
> > returns the actual number of interrupts allocated and indicates the
> > successful configuration of MSI-X capability structure with new
> > allocated MSI-X interrupts."
> >
> > The following commit introduced pci_enable_msix_range:
> > dpdk: 9fb3cd2c ("kni: fix ethtool build with kernel 4.11")
> > http://dpdk.org/dev/patchwork/patch/24076/
>
> Hi Andy,
>
> This is updating driver within KNI, and these drivers are used for ethtool
> support and most of the driver is already not used at all.
>
> I doubt the updated code is functional at all.
>
> Did you encounter any problem?
>
> These drivers are already outdated, and I am definitely not for actively
> maintaining them which is not required for ethtool support.
>
> >
> > Signed-off-by: Andy Roulin <aroulin@cumulusnetworks.com>
> > ---
> >  lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
> b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
> > index e0f427a..32ef3b9 100644
> > --- a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
> > +++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
> > @@ -1043,14 +1043,16 @@ static void igb_set_interrupt_capability(struct
> igb_adapter *adapter, bool msix)
> >  #ifdef HAVE_PCI_ENABLE_MSIX
> >                       err = pci_enable_msix(pdev,
> >                                             adapter->msix_entries,
> numvecs);
> > +                     if (err == 0)
> > +                             break;
> >  #else
> >                       err = pci_enable_msix_range(pdev,
> >                                       adapter->msix_entries,
> >                                       numvecs,
> >                                       numvecs);
> > -#endif
> > -                     if (err == 0)
> > +                     if (err < 0)
> >                               break;
> > +#endif
> >               }
> >               /* MSI-X failed, so fall through and try MSI */
> >               dev_warn(pci_dev_to_dev(pdev), "Failed to initialize MSI-X
> interrupts. "
> >
>
>
  

Patch

diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
index e0f427a..32ef3b9 100644
--- a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
+++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
@@ -1043,14 +1043,16 @@  static void igb_set_interrupt_capability(struct igb_adapter *adapter, bool msix)
 #ifdef HAVE_PCI_ENABLE_MSIX
 			err = pci_enable_msix(pdev,
 			                      adapter->msix_entries, numvecs);
+			if (err == 0)
+				break;
 #else
 			err = pci_enable_msix_range(pdev,
 					adapter->msix_entries,
 					numvecs,
 					numvecs);
-#endif
-			if (err == 0)
+			if (err < 0)
 				break;
+#endif
 		}
 		/* MSI-X failed, so fall through and try MSI */
 		dev_warn(pci_dev_to_dev(pdev), "Failed to initialize MSI-X interrupts. "