[dpdk-dev,v7,5/6] igb_uio: use kernel functions for masking MSI-X
Checks
Commit Message
This patch removes the custom MSI-X mask/unmask code and
uses already existing kernel functions.
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
---
lib/librte_eal/linuxapp/igb_uio/compat.h | 26 +++++-----------
lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 51 ++++++++++++-------------------
2 files changed, 28 insertions(+), 49 deletions(-)
Comments
Hi, Markus,
This commit appears to cause a regression on CentOS 7.4 with the in-box
Linux 3.10.0-639-2.2.el7.x86_64 kernel. Although the kernel module
appears to build correctly, when I attempt to load the module with
insmod, it fails and I see the following errors in dmesg:
> [620323.805125] igb_uio: Unknown symbol unmask_msi_irq (err 0)
> [620323.805163] igb_uio: Unknown symbol mask_msi_irq (err 0)
It also fails with the same dmesg errors if I copy it into
/lib/modules/$(uname -r)/extra, run depmod, and try to modprobe it.
Running git bisect points to this commit as the root cause.
This issue was identified as part of setting up the DPDK performance
test lab CI environment at the University of New Hampshire
InterOperability Laboratory.
Thanks,
Patrick
On 09/05/2017 08:04 AM, Markus Theil wrote:
> This patch removes the custom MSI-X mask/unmask code and
> uses already existing kernel functions.
>
> Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
> ---
> lib/librte_eal/linuxapp/igb_uio/compat.h | 26 +++++-----------
> lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 51 ++++++++++++-------------------
> 2 files changed, 28 insertions(+), 49 deletions(-)
>
> diff --git a/lib/librte_eal/linuxapp/igb_uio/compat.h b/lib/librte_eal/linuxapp/igb_uio/compat.h
> index 3825933..67a7ab3 100644
> --- a/lib/librte_eal/linuxapp/igb_uio/compat.h
> +++ b/lib/librte_eal/linuxapp/igb_uio/compat.h
> @@ -15,24 +15,6 @@
> #define HAVE_PTE_MASK_PAGE_IOMAP
> #endif
>
> -#ifndef PCI_MSIX_ENTRY_SIZE
> -#define PCI_MSIX_ENTRY_SIZE 16
> -#define PCI_MSIX_ENTRY_LOWER_ADDR 0
> -#define PCI_MSIX_ENTRY_UPPER_ADDR 4
> -#define PCI_MSIX_ENTRY_DATA 8
> -#define PCI_MSIX_ENTRY_VECTOR_CTRL 12
> -#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1
> -#endif
> -
> -/*
> - * for kernels < 2.6.38 and backported patch that moves MSI-X entry definition
> - * to pci_regs.h Those kernels has PCI_MSIX_ENTRY_SIZE defined but not
> - * PCI_MSIX_ENTRY_CTRL_MASKBIT
> - */
> -#ifndef PCI_MSIX_ENTRY_CTRL_MASKBIT
> -#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1
> -#endif
> -
> #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34) && \
> (!(defined(RHEL_RELEASE_CODE) && \
> RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(5, 9)))
> @@ -127,3 +109,11 @@ static bool pci_check_and_mask_intx(struct pci_dev *pdev)
> #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
> #define HAVE_ALLOC_IRQ_VECTORS 1
> #endif
> +
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
> +#define HAVE_PCI_MSI_MASK_IRQ 1
> +#endif
> +
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
> +#define HAVE_IRQ_DATA 1
> +#endif
> diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
> index c570eed..e4ef817 100644
> --- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
> +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
> @@ -91,27 +91,6 @@ static struct attribute *dev_attrs[] = {
> static const struct attribute_group dev_attr_grp = {
> .attrs = dev_attrs,
> };
> -/*
> - * It masks the msix on/off of generating MSI-X messages.
> - */
> -static void
> -igbuio_msix_mask_irq(struct msi_desc *desc, int32_t state)
> -{
> - u32 mask_bits = desc->masked;
> - unsigned offset = desc->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE +
> - PCI_MSIX_ENTRY_VECTOR_CTRL;
> -
> - if (state != 0)
> - mask_bits &= ~PCI_MSIX_ENTRY_CTRL_MASKBIT;
> - else
> - mask_bits |= PCI_MSIX_ENTRY_CTRL_MASKBIT;
> -
> - if (mask_bits != desc->masked) {
> - writel(mask_bits, desc->mask_base + offset);
> - readl(desc->mask_base);
> - desc->masked = mask_bits;
> - }
> -}
>
> /**
> * This is the irqcontrol callback to be registered to uio_info.
> @@ -132,21 +111,31 @@ igbuio_pci_irqcontrol(struct uio_info *info, s32 irq_state)
> struct rte_uio_pci_dev *udev = info->priv;
> struct pci_dev *pdev = udev->pdev;
>
> - pci_cfg_access_lock(pdev);
> - if (udev->mode == RTE_INTR_MODE_LEGACY)
> - pci_intx(pdev, !!irq_state);
> +#ifdef HAVE_IRQ_DATA
> + struct irq_data *irq = irq_get_irq_data(udev->info.irq);
> +#else
> + unsigned int irq = udev->info.irq;
> +#endif
>
> - else if (udev->mode == RTE_INTR_MODE_MSIX) {
> - struct msi_desc *desc;
> + pci_cfg_access_lock(pdev);
>
> -#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0))
> - list_for_each_entry(desc, &pdev->msi_list, list)
> - igbuio_msix_mask_irq(desc, irq_state);
> + if (udev->mode == RTE_INTR_MODE_MSIX) {
> +#ifdef HAVE_PCI_MSI_MASK_IRQ
> + if (irq_state == 1)
> + pci_msi_unmask_irq(irq);
> + else
> + pci_msi_mask_irq(irq);
> #else
> - list_for_each_entry(desc, &pdev->dev.msi_list, list)
> - igbuio_msix_mask_irq(desc, irq_state);
> + if (irq_state == 1)
> + unmask_msi_irq(irq);
> + else
> + mask_msi_irq(irq);
> #endif
> }
> +
> + if (udev->mode == RTE_INTR_MODE_LEGACY)
> + pci_intx(pdev, !!irq_state);
> +
> pci_cfg_access_unlock(pdev);
>
> return 0;
>
Hi,
This commit renders igb_uio unusable on Fedora 20, kernel version 3.19.8-100.fc20.x86_64.
During the build (make -j 20), a warning is issued for igb_uio regarding a missing symbol (pci_msi_unmask):
WARNING: "pci_msi_unmask_irq" [/home/<redacted>/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.ko] undefined!
WARNING: "pci_msi_mask_irq" [/home/<redacted>/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.ko] undefined!
Subsequently, the module is may not be loaded on account of same.
(from dmesg):
[673425.712110] igb_uio: Unknown symbol pci_msi_unmask_irq (err 0)
[673425.712124] igb_uio: Unknown symbol pci_msi_mask_irq (err 0)
Thanks,
Mark
>-----Original Message-----
>From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Markus Theil
>Sent: Tuesday, September 5, 2017 1:04 PM
>To: dev@dpdk.org
>Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; stephen@networkplumber.org; Markus
>Theil <markus.theil@tu-ilmenau.de>
>Subject: [dpdk-dev] [PATCH v7 5/6] igb_uio: use kernel functions for masking
>MSI-X
>
>This patch removes the custom MSI-X mask/unmask code and
>uses already existing kernel functions.
>
>Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
>---
> lib/librte_eal/linuxapp/igb_uio/compat.h | 26 +++++-----------
> lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 51 ++++++++++++------------------
>-
> 2 files changed, 28 insertions(+), 49 deletions(-)
>
>diff --git a/lib/librte_eal/linuxapp/igb_uio/compat.h
>b/lib/librte_eal/linuxapp/igb_uio/compat.h
>index 3825933..67a7ab3 100644
>--- a/lib/librte_eal/linuxapp/igb_uio/compat.h
>+++ b/lib/librte_eal/linuxapp/igb_uio/compat.h
>@@ -15,24 +15,6 @@
> #define HAVE_PTE_MASK_PAGE_IOMAP
> #endif
>
>-#ifndef PCI_MSIX_ENTRY_SIZE
>-#define PCI_MSIX_ENTRY_SIZE 16
>-#define PCI_MSIX_ENTRY_LOWER_ADDR 0
>-#define PCI_MSIX_ENTRY_UPPER_ADDR 4
>-#define PCI_MSIX_ENTRY_DATA 8
>-#define PCI_MSIX_ENTRY_VECTOR_CTRL 12
>-#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1
>-#endif
>-
>-/*
>- * for kernels < 2.6.38 and backported patch that moves MSI-X entry
>definition
>- * to pci_regs.h Those kernels has PCI_MSIX_ENTRY_SIZE defined but not
>- * PCI_MSIX_ENTRY_CTRL_MASKBIT
>- */
>-#ifndef PCI_MSIX_ENTRY_CTRL_MASKBIT
>-#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1
>-#endif
>-
> #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34) && \
> (!(defined(RHEL_RELEASE_CODE) && \
> RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(5, 9)))
>@@ -127,3 +109,11 @@ static bool pci_check_and_mask_intx(struct pci_dev *pdev)
> #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
> #define HAVE_ALLOC_IRQ_VECTORS 1
> #endif
>+
>+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
>+#define HAVE_PCI_MSI_MASK_IRQ 1
>+#endif
>+
>+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
>+#define HAVE_IRQ_DATA 1
>+#endif
>diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
>b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
>index c570eed..e4ef817 100644
>--- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
>+++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
>@@ -91,27 +91,6 @@ static struct attribute *dev_attrs[] = {
> static const struct attribute_group dev_attr_grp = {
> .attrs = dev_attrs,
> };
>-/*
>- * It masks the msix on/off of generating MSI-X messages.
>- */
>-static void
>-igbuio_msix_mask_irq(struct msi_desc *desc, int32_t state)
>-{
>- u32 mask_bits = desc->masked;
>- unsigned offset = desc->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE +
>- PCI_MSIX_ENTRY_VECTOR_CTRL;
>-
>- if (state != 0)
>- mask_bits &= ~PCI_MSIX_ENTRY_CTRL_MASKBIT;
>- else
>- mask_bits |= PCI_MSIX_ENTRY_CTRL_MASKBIT;
>-
>- if (mask_bits != desc->masked) {
>- writel(mask_bits, desc->mask_base + offset);
>- readl(desc->mask_base);
>- desc->masked = mask_bits;
>- }
>-}
>
> /**
> * This is the irqcontrol callback to be registered to uio_info.
>@@ -132,21 +111,31 @@ igbuio_pci_irqcontrol(struct uio_info *info, s32
>irq_state)
> struct rte_uio_pci_dev *udev = info->priv;
> struct pci_dev *pdev = udev->pdev;
>
>- pci_cfg_access_lock(pdev);
>- if (udev->mode == RTE_INTR_MODE_LEGACY)
>- pci_intx(pdev, !!irq_state);
>+#ifdef HAVE_IRQ_DATA
>+ struct irq_data *irq = irq_get_irq_data(udev->info.irq);
>+#else
>+ unsigned int irq = udev->info.irq;
>+#endif
>
>- else if (udev->mode == RTE_INTR_MODE_MSIX) {
>- struct msi_desc *desc;
>+ pci_cfg_access_lock(pdev);
>
>-#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0))
>- list_for_each_entry(desc, &pdev->msi_list, list)
>- igbuio_msix_mask_irq(desc, irq_state);
>+ if (udev->mode == RTE_INTR_MODE_MSIX) {
>+#ifdef HAVE_PCI_MSI_MASK_IRQ
>+ if (irq_state == 1)
>+ pci_msi_unmask_irq(irq);
>+ else
>+ pci_msi_mask_irq(irq);
> #else
>- list_for_each_entry(desc, &pdev->dev.msi_list, list)
>- igbuio_msix_mask_irq(desc, irq_state);
>+ if (irq_state == 1)
>+ unmask_msi_irq(irq);
>+ else
>+ mask_msi_irq(irq);
> #endif
> }
>+
>+ if (udev->mode == RTE_INTR_MODE_LEGACY)
>+ pci_intx(pdev, !!irq_state);
>+
> pci_cfg_access_unlock(pdev);
>
> return 0;
>--
>2.7.4
On 10/9/2017 10:56 PM, Patrick MacArthur wrote:
> Hi, Markus,
>
> This commit appears to cause a regression on CentOS 7.4 with the in-box
> Linux 3.10.0-639-2.2.el7.x86_64 kernel. Although the kernel module
> appears to build correctly, when I attempt to load the module with
> insmod, it fails and I see the following errors in dmesg:
>
>> [620323.805125] igb_uio: Unknown symbol unmask_msi_irq (err 0)
>> [620323.805163] igb_uio: Unknown symbol mask_msi_irq (err 0)
>
Hi Patrick, Mark,
Thanks for reporting, I will check it.
> It also fails with the same dmesg errors if I copy it into
> /lib/modules/$(uname -r)/extra, run depmod, and try to modprobe it.
>
> Running git bisect points to this commit as the root cause.
>
> This issue was identified as part of setting up the DPDK performance
> test lab CI environment at the University of New Hampshire
> InterOperability Laboratory.
>
> Thanks,
> Patrick
>
<...>
On 10/12/2017 11:50 AM, Kavanagh, Mark B wrote:
> Hi,
>
> This commit renders igb_uio unusable on Fedora 20, kernel version 3.19.8-100.fc20.x86_64.
>
> During the build (make -j 20), a warning is issued for igb_uio regarding a missing symbol (pci_msi_unmask):
> WARNING: "pci_msi_unmask_irq" [/home/<redacted>/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.ko] undefined!
> WARNING: "pci_msi_mask_irq" [/home/<redacted>/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.ko] undefined!
>
Hi Mark,
I can see vanilla 3.19.8 has pci_msi_unmask_irq and pci_msi_mask_irq.
Also I checked Fedora 3.19.8-100.fc20.x86_64 source code, they are still
there.
Not sure why getting this error.
> Subsequently, the module is may not be loaded on account of same.
> (from dmesg):
> [673425.712110] igb_uio: Unknown symbol pci_msi_unmask_irq (err 0)
> [673425.712124] igb_uio: Unknown symbol pci_msi_mask_irq (err 0)
>
> Thanks,
> Mark
Are the symbols exported?
On Oct 12, 2017 13:58, "Ferruh Yigit" <ferruh.yigit@intel.com> wrote:
> On 10/12/2017 11:50 AM, Kavanagh, Mark B wrote:
> > Hi,
> >
> > This commit renders igb_uio unusable on Fedora 20, kernel version
> 3.19.8-100.fc20.x86_64.
> >
> > During the build (make -j 20), a warning is issued for igb_uio regarding
> a missing symbol (pci_msi_unmask):
> > WARNING: "pci_msi_unmask_irq" [/home/<redacted>/x86_64-
> native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.ko]
> undefined!
> > WARNING: "pci_msi_mask_irq" [/home/<redacted>/x86_64-
> native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.ko]
> undefined!
> >
>
> Hi Mark,
>
> I can see vanilla 3.19.8 has pci_msi_unmask_irq and pci_msi_mask_irq.
>
> Also I checked Fedora 3.19.8-100.fc20.x86_64 source code, they are still
> there.
>
> Not sure why getting this error.
>
> > Subsequently, the module is may not be loaded on account of same.
> > (from dmesg):
> > [673425.712110] igb_uio: Unknown symbol pci_msi_unmask_irq (err 0)
> > [673425.712124] igb_uio: Unknown symbol pci_msi_mask_irq (err 0)
> >
> > Thanks,
> > Mark
>
>
>
On 10/12/2017 10:15 PM, Stephen Hemminger wrote:
> Are the symbols exported?
No!
They started to be exported in v4.5. I will update accordingly.
Thanks,
ferruh
>
> On Oct 12, 2017 13:58, "Ferruh Yigit" <ferruh.yigit@intel.com
> <mailto:ferruh.yigit@intel.com>> wrote:
>
> On 10/12/2017 11:50 AM, Kavanagh, Mark B wrote:
> > Hi,
> >
> > This commit renders igb_uio unusable on Fedora 20, kernel version
> 3.19.8-100.fc20.x86_64.
> >
> > During the build (make -j 20), a warning is issued for igb_uio
> regarding a missing symbol (pci_msi_unmask):
> > WARNING: "pci_msi_unmask_irq"
> [/home/<redacted>/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.ko]
> undefined!
> > WARNING: "pci_msi_mask_irq"
> [/home/<redacted>/x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/igb_uio/igb_uio.ko]
> undefined!
> >
>
> Hi Mark,
>
> I can see vanilla 3.19.8 has pci_msi_unmask_irq and pci_msi_mask_irq.
>
> Also I checked Fedora 3.19.8-100.fc20.x86_64 source code, they are still
> there.
>
> Not sure why getting this error.
>
> > Subsequently, the module is may not be loaded on account of same.
> > (from dmesg):
> > [673425.712110] igb_uio: Unknown symbol pci_msi_unmask_irq
> (err 0)
> > [673425.712124] igb_uio: Unknown symbol pci_msi_mask_irq (err 0)
> >
> > Thanks,
> > Mark
>
>
On 10/12/2017 6:04 PM, Ferruh Yigit wrote:
> On 10/9/2017 10:56 PM, Patrick MacArthur wrote:
>> Hi, Markus,
>>
>> This commit appears to cause a regression on CentOS 7.4 with the in-box
>> Linux 3.10.0-639-2.2.el7.x86_64 kernel. Although the kernel module
>> appears to build correctly, when I attempt to load the module with
>> insmod, it fails and I see the following errors in dmesg:
>>
>>> [620323.805125] igb_uio: Unknown symbol unmask_msi_irq (err 0)
>>> [620323.805163] igb_uio: Unknown symbol mask_msi_irq (err 0)
>>
>
> Hi Patrick, Mark,
>
> Thanks for reporting, I will check it.
Can you please test http://dpdk.org/dev/patchwork/patch/30325/
>
>
>> It also fails with the same dmesg errors if I copy it into
>> /lib/modules/$(uname -r)/extra, run depmod, and try to modprobe it.
>>
>> Running git bisect points to this commit as the root cause.
>>
>> This issue was identified as part of setting up the DPDK performance
>> test lab CI environment at the University of New Hampshire
>> InterOperability Laboratory.
>>
>> Thanks,
>> Patrick
>>
> <...>
>
>From: Yigit, Ferruh
>Sent: Friday, October 13, 2017 3:50 AM
>To: Patrick MacArthur <patrick@patrickmacarthur.net>; Markus Theil
><markus.theil@tu-ilmenau.de>; dev@dpdk.org; Kavanagh, Mark B
><mark.b.kavanagh@intel.com>
>Cc: stephen@networkplumber.org; Bob Noseworthy <ren@iol.unh.edu>; Patrick
>MacArthur <pmacarth@iol.unh.edu>; O'Driscoll, Tim <tim.odriscoll@intel.com>
>Subject: Re: [dpdk-dev] [PATCH v7 5/6] igb_uio: use kernel functions for
>masking MSI-X
>
>On 10/12/2017 6:04 PM, Ferruh Yigit wrote:
>> On 10/9/2017 10:56 PM, Patrick MacArthur wrote:
>>> Hi, Markus,
>>>
>>> This commit appears to cause a regression on CentOS 7.4 with the in-box
>>> Linux 3.10.0-639-2.2.el7.x86_64 kernel. Although the kernel module
>>> appears to build correctly, when I attempt to load the module with
>>> insmod, it fails and I see the following errors in dmesg:
>>>
>>>> [620323.805125] igb_uio: Unknown symbol unmask_msi_irq (err 0)
>>>> [620323.805163] igb_uio: Unknown symbol mask_msi_irq (err 0)
>>>
>>
>> Hi Patrick, Mark,
>>
>> Thanks for reporting, I will check it.
>
>Can you please test http://dpdk.org/dev/patchwork/patch/30325/
Hey Ferruh,
I can confirm that this patch resolves the build issues on Fedora 20, kernel 3.19.8-100.fc20.x86_64 - thanks!
Incidentally, there is a minor warning reported when applying the patch:
Applying: igb_uio: fix unknown symbols
/home/<redacted>/.git/rebase-apply/patch:47: new blank line at EOF.
+
Thanks again,
Mark
>
>>
>>
>>> It also fails with the same dmesg errors if I copy it into
>>> /lib/modules/$(uname -r)/extra, run depmod, and try to modprobe it.
>>>
>>> Running git bisect points to this commit as the root cause.
>>>
>>> This issue was identified as part of setting up the DPDK performance
>>> test lab CI environment at the University of New Hampshire
>>> InterOperability Laboratory.
>>>
>>> Thanks,
>>> Patrick
>>>
>> <...>
>>
@@ -15,24 +15,6 @@
#define HAVE_PTE_MASK_PAGE_IOMAP
#endif
-#ifndef PCI_MSIX_ENTRY_SIZE
-#define PCI_MSIX_ENTRY_SIZE 16
-#define PCI_MSIX_ENTRY_LOWER_ADDR 0
-#define PCI_MSIX_ENTRY_UPPER_ADDR 4
-#define PCI_MSIX_ENTRY_DATA 8
-#define PCI_MSIX_ENTRY_VECTOR_CTRL 12
-#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1
-#endif
-
-/*
- * for kernels < 2.6.38 and backported patch that moves MSI-X entry definition
- * to pci_regs.h Those kernels has PCI_MSIX_ENTRY_SIZE defined but not
- * PCI_MSIX_ENTRY_CTRL_MASKBIT
- */
-#ifndef PCI_MSIX_ENTRY_CTRL_MASKBIT
-#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1
-#endif
-
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34) && \
(!(defined(RHEL_RELEASE_CODE) && \
RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(5, 9)))
@@ -127,3 +109,11 @@ static bool pci_check_and_mask_intx(struct pci_dev *pdev)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
#define HAVE_ALLOC_IRQ_VECTORS 1
#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
+#define HAVE_PCI_MSI_MASK_IRQ 1
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
+#define HAVE_IRQ_DATA 1
+#endif
@@ -91,27 +91,6 @@ static struct attribute *dev_attrs[] = {
static const struct attribute_group dev_attr_grp = {
.attrs = dev_attrs,
};
-/*
- * It masks the msix on/off of generating MSI-X messages.
- */
-static void
-igbuio_msix_mask_irq(struct msi_desc *desc, int32_t state)
-{
- u32 mask_bits = desc->masked;
- unsigned offset = desc->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE +
- PCI_MSIX_ENTRY_VECTOR_CTRL;
-
- if (state != 0)
- mask_bits &= ~PCI_MSIX_ENTRY_CTRL_MASKBIT;
- else
- mask_bits |= PCI_MSIX_ENTRY_CTRL_MASKBIT;
-
- if (mask_bits != desc->masked) {
- writel(mask_bits, desc->mask_base + offset);
- readl(desc->mask_base);
- desc->masked = mask_bits;
- }
-}
/**
* This is the irqcontrol callback to be registered to uio_info.
@@ -132,21 +111,31 @@ igbuio_pci_irqcontrol(struct uio_info *info, s32 irq_state)
struct rte_uio_pci_dev *udev = info->priv;
struct pci_dev *pdev = udev->pdev;
- pci_cfg_access_lock(pdev);
- if (udev->mode == RTE_INTR_MODE_LEGACY)
- pci_intx(pdev, !!irq_state);
+#ifdef HAVE_IRQ_DATA
+ struct irq_data *irq = irq_get_irq_data(udev->info.irq);
+#else
+ unsigned int irq = udev->info.irq;
+#endif
- else if (udev->mode == RTE_INTR_MODE_MSIX) {
- struct msi_desc *desc;
+ pci_cfg_access_lock(pdev);
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0))
- list_for_each_entry(desc, &pdev->msi_list, list)
- igbuio_msix_mask_irq(desc, irq_state);
+ if (udev->mode == RTE_INTR_MODE_MSIX) {
+#ifdef HAVE_PCI_MSI_MASK_IRQ
+ if (irq_state == 1)
+ pci_msi_unmask_irq(irq);
+ else
+ pci_msi_mask_irq(irq);
#else
- list_for_each_entry(desc, &pdev->dev.msi_list, list)
- igbuio_msix_mask_irq(desc, irq_state);
+ if (irq_state == 1)
+ unmask_msi_irq(irq);
+ else
+ mask_msi_irq(irq);
#endif
}
+
+ if (udev->mode == RTE_INTR_MODE_LEGACY)
+ pci_intx(pdev, !!irq_state);
+
pci_cfg_access_unlock(pdev);
return 0;