DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel
@ 2014-07-25 17:36 Stephen Hemminger
  2014-07-25 17:37 ` [dpdk-dev] [PATCH 2/2] igb_uio: handle no IRQ fallback Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Stephen Hemminger @ 2014-07-25 17:36 UTC (permalink / raw)
  To: Thomas Monjalon, Yerden Zhumabekov; +Cc: dev

Add more compatibility wrappers, and split out all the wrapper
code to a separate file. Builds on Debian Squeeze (2.6.32) which
is oldest version of kernel current DPDK supports.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

---
 lib/librte_eal/linuxapp/igb_uio/compat.h  |  103 ++++++++++++++++++++++++++++++
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c |   81 -----------------------
 2 files changed, 104 insertions(+), 80 deletions(-)

--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ b/lib/librte_eal/linuxapp/igb_uio/compat.h	2014-07-25 10:29:58.664127988 -0700
@@ -0,0 +1,103 @@
+/*
+ * Minimal wrappers to allow compiling igb_uio on older kernels.
+ */
+
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
+#define pci_cfg_access_lock   pci_block_user_cfg_access
+#define pci_cfg_access_unlock pci_unblock_user_cfg_access
+#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
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)
+static int pci_num_vf(struct pci_dev *dev)
+{
+	struct iov {
+		int pos;
+		int nres;
+		u32 cap;
+		u16 ctrl;
+		u16 total;
+		u16 initial;
+		u16 nr_virtfn;
+	} *iov = (struct iov *)dev->sriov;
+
+	if (!dev->is_physfn)
+		return 0;
+
+	return iov->nr_virtfn;
+}
+#endif
+
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
+
+/* Check if INTX works to control irq's.
+ * Set's INTX_DISABLE flag and reads it back
+ */
+static bool pci_intx_mask_supported(struct pci_dev *pdev)
+{
+	bool mask_supported = false;
+	uint16_t orig, new;
+
+	pci_block_user_cfg_access(pdev);
+	pci_read_config_word(pdev, PCI_COMMAND, &orig);
+	pci_write_config_word(pdev, PCI_COMMAND,
+			      orig ^ PCI_COMMAND_INTX_DISABLE);
+	pci_read_config_word(pdev, PCI_COMMAND, &new);
+
+	if ((new ^ orig) & ~PCI_COMMAND_INTX_DISABLE) {
+		dev_err(&pdev->dev, "Command register changed from "
+			"0x%x to 0x%x: driver or hardware bug?\n", orig, new);
+	} else if ((new ^ orig) & PCI_COMMAND_INTX_DISABLE) {
+		mask_supported = true;
+		pci_write_config_word(pdev, PCI_COMMAND, orig);
+	}
+	pci_unblock_user_cfg_access(pdev);
+
+	return mask_supported;
+}
+
+static bool pci_check_and_mask_intx(struct pci_dev *pdev)
+{
+	bool pending;
+	uint32_t status;
+
+	pci_block_user_cfg_access(pdev);
+	pci_read_config_dword(pdev, PCI_COMMAND, &status);
+
+	/* interrupt is not ours, goes to out */
+	pending = (((status >> 16) & PCI_STATUS_INTERRUPT) != 0);
+	if (pending) {
+		uint16_t old, new;
+
+		old = status;
+		if (status != 0)
+			new = old & (~PCI_COMMAND_INTX_DISABLE);
+		else
+			new = old | PCI_COMMAND_INTX_DISABLE;
+
+		if (old != new)
+			pci_write_config_word(pdev, PCI_COMMAND, new);
+	}
+	pci_unblock_user_cfg_access(pdev);
+
+	return pending;
+}
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
+/* Compatability wrapper for new kernel API for IRQ */
+#define irq_data	irq_desc
+#define irq_get_irq_data(irq)	irq_to_desc(irq)
+#define irq_data_get_msi(data)	get_irq_desc_msi(data)
+#endif
+
--- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c	2014-07-25 10:29:58.668128002 -0700
+++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c	2014-07-25 10:29:58.664127988 -0700
@@ -37,10 +37,7 @@
 #endif
 #include <rte_pci_dev_features.h>
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
-#define pci_cfg_access_lock   pci_block_user_cfg_access
-#define pci_cfg_access_unlock pci_unblock_user_cfg_access
-#endif
+#include "compat.h"
 
 #ifdef RTE_PCI_CONFIG
 #define PCI_SYS_FILE_BUF_SIZE      10
@@ -70,26 +67,6 @@ igbuio_get_uio_pci_dev(struct uio_info *
 }
 
 /* sriov sysfs */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)
-static int pci_num_vf(struct pci_dev *dev)
-{
-	struct iov {
-		int pos;
-		int nres;
-		u32 cap;
-		u16 ctrl;
-		u16 total;
-		u16 initial;
-		u16 nr_virtfn;
-	} *iov = (struct iov *)dev->sriov;
-
-	if (!dev->is_physfn)
-		return 0;
-
-	return iov->nr_virtfn;
-}
-#endif
-
 static ssize_t
 show_max_vfs(struct device *dev, struct device_attribute *attr,
 	     char *buf)
@@ -228,62 +205,6 @@ static struct attribute *dev_attrs[] = {
 static const struct attribute_group dev_attr_grp = {
 	.attrs = dev_attrs,
 };
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
-/* Check if INTX works to control irq's.
- * Set's INTX_DISABLE flag and reads it back
- */
-static bool pci_intx_mask_supported(struct pci_dev *pdev)
-{
-	bool mask_supported = false;
-	uint16_t orig, new;
-
-	pci_block_user_cfg_access(pdev);
-	pci_read_config_word(pdev, PCI_COMMAND, &orig);
-	pci_write_config_word(pdev, PCI_COMMAND,
-			      orig ^ PCI_COMMAND_INTX_DISABLE);
-	pci_read_config_word(pdev, PCI_COMMAND, &new);
-
-	if ((new ^ orig) & ~PCI_COMMAND_INTX_DISABLE) {
-		dev_err(&pdev->dev, "Command register changed from "
-			"0x%x to 0x%x: driver or hardware bug?\n", orig, new);
-	} else if ((new ^ orig) & PCI_COMMAND_INTX_DISABLE) {
-		mask_supported = true;
-		pci_write_config_word(pdev, PCI_COMMAND, orig);
-	}
-	pci_unblock_user_cfg_access(pdev);
-
-	return mask_supported;
-}
-
-static bool pci_check_and_mask_intx(struct pci_dev *pdev)
-{
-	bool pending;
-	uint32_t status;
-
-	pci_block_user_cfg_access(pdev);
-	pci_read_config_dword(pdev, PCI_COMMAND, &status);
-
-	/* interrupt is not ours, goes to out */
-	pending = (((status >> 16) & PCI_STATUS_INTERRUPT) != 0);
-	if (pending) {
-		uint16_t old, new;
-
-		old = status;
-		if (status != 0)
-			new = old & (~PCI_COMMAND_INTX_DISABLE);
-		else
-			new = old | PCI_COMMAND_INTX_DISABLE;
-
-		if (old != new)
-			pci_write_config_word(pdev, PCI_COMMAND, new);
-	}
-	pci_unblock_user_cfg_access(pdev);
-
-	return pending;
-}
-#endif
-
 /*
  * It masks the msix on/off of generating MSI-X messages.
  */

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 2/2] igb_uio: handle no IRQ fallback
  2014-07-25 17:36 [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel Stephen Hemminger
@ 2014-07-25 17:37 ` Stephen Hemminger
  2014-08-01 13:11   ` Thomas Monjalon
  2014-08-01 13:10 ` [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel Thomas Monjalon
  2014-09-01 14:55 ` Guillaume Gaudonville
  2 siblings, 1 reply; 12+ messages in thread
From: Stephen Hemminger @ 2014-07-25 17:37 UTC (permalink / raw)
  To: Thomas Monjalon, Yerden Zhumabekov; +Cc: dev

Fix a couple of issues with my earlier igb_uio stuff:
1. With MSI (like MSI-X) actual IRQ number is not known until
   after the pci_enable_msi() is done.
2. If INTX fails, fall back to running without IRQ.
   This allows usermode PCI to recover and run without out IRQ
   for cases where PCI INTX support is broken (aka VMWare).

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>


--- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c	2014-07-25 10:30:07.740159856 -0700
+++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c	2014-07-25 10:30:07.736159842 -0700
@@ -506,7 +506,6 @@ igbuio_pci_probe(struct pci_dev *dev, co
 	udev->info.version = "0.1";
 	udev->info.handler = igbuio_pci_irqhandler;
 	udev->info.irqcontrol = igbuio_pci_irqcontrol;
-	udev->info.irq = dev->irq;
 #ifdef CONFIG_XEN_DOM0
 	/* check if the driver run on Xen Dom0 */
 	if (xen_initial_domain())
@@ -516,9 +515,6 @@ igbuio_pci_probe(struct pci_dev *dev, co
 	udev->pdev = dev;
 
 	switch (igbuio_intr_mode_preferred) {
-	case RTE_INTR_MODE_NONE:
-		udev->info.irq = 0;
-		break;
 	case RTE_INTR_MODE_MSIX:
 		/* Only 1 msi-x vector needed */
 		msix_entry.entry = 0;
@@ -532,6 +528,7 @@ igbuio_pci_probe(struct pci_dev *dev, co
 	case RTE_INTR_MODE_MSI:
 		if (pci_enable_msi(dev) == 0) {
 			dev_dbg(&dev->dev, "using MSI");
+			udev->info.irq = dev->irq;
 			udev->mode = RTE_INTR_MODE_MSI;
 			break;
 		}
@@ -540,13 +537,17 @@ igbuio_pci_probe(struct pci_dev *dev, co
 		if (pci_intx_mask_supported(dev)) {
 			dev_dbg(&dev->dev, "using INTX");
 			udev->info.irq_flags = IRQF_SHARED;
+			udev->info.irq = dev->irq;
 			udev->mode = RTE_INTR_MODE_LEGACY;
-		} else {
-			dev_err(&dev->dev, "PCI INTX mask not supported\n");
-			err = -EIO;
-			goto fail_release_iomem;
+			break;
 		}
+		dev_notice(&dev->dev, "PCI INTX mask not supported\n");
+		/* fall back to no IRQ */
+	case RTE_INTR_MODE_NONE:
+		udev->mode = RTE_INTR_MODE_NONE;
+		udev->info.irq = 0;
 		break;
+
 	default:
 		dev_err(&dev->dev, "invalid IRQ mode %u",
 			igbuio_intr_mode_preferred);

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel
  2014-07-25 17:36 [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel Stephen Hemminger
  2014-07-25 17:37 ` [dpdk-dev] [PATCH 2/2] igb_uio: handle no IRQ fallback Stephen Hemminger
@ 2014-08-01 13:10 ` Thomas Monjalon
  2014-08-22 17:29   ` Sanford, Robert
  2014-09-01 14:55 ` Guillaume Gaudonville
  2 siblings, 1 reply; 12+ messages in thread
From: Thomas Monjalon @ 2014-08-01 13:10 UTC (permalink / raw)
  To: Stephen Hemminger, dev

2014-07-25 10:36, Stephen Hemminger:
> Add more compatibility wrappers, and split out all the wrapper
> code to a separate file. Builds on Debian Squeeze (2.6.32) which
> is oldest version of kernel current DPDK supports.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>

Applied for version 1.7.1.

There are still some compilation issues with RHEL:
include/linux/pci.h:1572: note: previous declaration of ‘pci_num_vf’ was here
include/linux/pci.h:868: note: previous declaration of ‘pci_intx_mask_supported’ was here
include/linux/pci.h:869: note: previous declaration of ‘pci_check_and_mask_intx’ was here

Some ifdefs are missing but I don't want to dig into RHEL kernel headers to
find what is the first RHEL release to support these functions.
By the way, if someone knows an easy method to get all RHEL kernel headers
or to know the release where a symbol appeared, it would be very useful.

-- 
Thomas

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] igb_uio: handle no IRQ fallback
  2014-07-25 17:37 ` [dpdk-dev] [PATCH 2/2] igb_uio: handle no IRQ fallback Stephen Hemminger
@ 2014-08-01 13:11   ` Thomas Monjalon
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Monjalon @ 2014-08-01 13:11 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

2014-07-25 10:37, Stephen Hemminger:
> Fix a couple of issues with my earlier igb_uio stuff:
> 1. With MSI (like MSI-X) actual IRQ number is not known until
>    after the pci_enable_msi() is done.
> 2. If INTX fails, fall back to running without IRQ.
>    This allows usermode PCI to recover and run without out IRQ
>    for cases where PCI INTX support is broken (aka VMWare).
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>

Applied for version 1.7.1.

Thanks
-- 
Thomas

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel
  2014-08-01 13:10 ` [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel Thomas Monjalon
@ 2014-08-22 17:29   ` Sanford, Robert
  2014-08-22 18:09     ` Robert Sanford
  0 siblings, 1 reply; 12+ messages in thread
From: Sanford, Robert @ 2014-08-22 17:29 UTC (permalink / raw)
  To: Thomas Monjalon, Stephen Hemminger, dev

Hi Thomas,

Not that I would *like* to fix this, but I *need* to fix it. We are using
CentOS 6.5, which I believe is based on RHEL. We have kernel
2.6.32-431.3.1.el6.x86_64.

I realize that we need to add/change ifdefs around pci_num_vf,
pci_intx_mask_supported, and pci_check_and_mask_intx in igb_uio/compat.h.
Any more specific suggestions on how to (elegantly) fix it for us, but not
break it for anyone else?

--
Regards,
Robert


>2014-07-25 10:36, Stephen Hemminger:
>> Add more compatibility wrappers, and split out all the wrapper
>> code to a separate file. Builds on Debian Squeeze (2.6.32) which
>> is oldest version of kernel current DPDK supports.
>> 
>> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>
>Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
>
>Applied for version 1.7.1.
>
>There are still some compilation issues with RHEL:
>include/linux/pci.h:1572: note: previous declaration of Œpci_num_vf¹ was
>here
>include/linux/pci.h:868: note: previous declaration of
>Œpci_intx_mask_supported¹ was here
>include/linux/pci.h:869: note: previous declaration of
>Œpci_check_and_mask_intx¹ was here
>
>Some ifdefs are missing but I don't want to dig into RHEL kernel headers
>to
>find what is the first RHEL release to support these functions.
>By the way, if someone knows an easy method to get all RHEL kernel headers
>or to know the release where a symbol appeared, it would be very useful.
>
>-- 
>Thomas

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel
  2014-08-22 17:29   ` Sanford, Robert
@ 2014-08-22 18:09     ` Robert Sanford
  2014-08-23 15:14       ` Stephen Hemminger
  2014-09-01 15:07       ` Guillaume Gaudonville
  0 siblings, 2 replies; 12+ messages in thread
From: Robert Sanford @ 2014-08-22 18:09 UTC (permalink / raw)
  To: Thomas Monjalon, dev

This is what we came up with. It works for us. In our kernel headers'
linux/pci.h, pci_num_vf is enclosed within "#ifdef CONFIG_PCI_IOV/#endif";
pci_intx_mask_supported and pci_check_and_mask_intx are enclosed within
"#ifdef HAVE_PCI_SET_MWI/#endif".

What do you think?

--
Thanks,
Robert


---
 lib/librte_eal/linuxapp/igb_uio/compat.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/linuxapp/igb_uio/compat.h
b/lib/librte_eal/linuxapp/igb_uio/compat.h
index 2a16540..f7404d8 100644
--- a/lib/librte_eal/linuxapp/igb_uio/compat.h
+++ b/lib/librte_eal/linuxapp/igb_uio/compat.h
@@ -17,7 +17,7 @@
 #define   PCI_MSIX_ENTRY_CTRL_MASKBIT   1
 #endif

-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34) &&
!defined(CONFIG_PCI_IOV)
 static int pci_num_vf(struct pci_dev *dev)
 {
    struct iov {
@@ -38,7 +38,7 @@ static int pci_num_vf(struct pci_dev *dev)
 #endif


-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) &&
!defined(HAVE_PCI_SET_MWI)

 /* Check if INTX works to control irq's.
  * Set's INTX_DISABLE flag and reads it back
-- 
1.7.1



On Fri, Aug 22, 2014 at 1:29 PM, Sanford, Robert <rsanford@akamai.com>
wrote:
>
> Hi Thomas,
>
> Not that I would *like* to fix this, but I *need* to fix it. We are using
> CentOS 6.5, which I believe is based on RHEL. We have kernel
> 2.6.32-431.3.1.el6.x86_64.
>
> I realize that we need to add/change ifdefs around pci_num_vf,
> pci_intx_mask_supported, and pci_check_and_mask_intx in igb_uio/compat.h.
> Any more specific suggestions on how to (elegantly) fix it for us, but not
> break it for anyone else?
>
> --
> Regards,
> Robert
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel
  2014-08-22 18:09     ` Robert Sanford
@ 2014-08-23 15:14       ` Stephen Hemminger
  2014-08-26 16:08         ` Sanford, Robert
  2014-09-01 15:07       ` Guillaume Gaudonville
  1 sibling, 1 reply; 12+ messages in thread
From: Stephen Hemminger @ 2014-08-23 15:14 UTC (permalink / raw)
  To: Robert Sanford; +Cc: dev

On Fri, 22 Aug 2014 14:09:35 -0400
Robert Sanford <rsanford2@gmail.com> wrote:

> This is what we came up with. It works for us. In our kernel headers'
> linux/pci.h, pci_num_vf is enclosed within "#ifdef CONFIG_PCI_IOV/#endif";
> pci_intx_mask_supported and pci_check_and_mask_intx are enclosed within
> "#ifdef HAVE_PCI_SET_MWI/#endif".
> 
> What do you think?

Maybe we can just get rid of kernel version checks all together and
just use the HAVE_ checks.

I will test on stock 2.6.32.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel
  2014-08-23 15:14       ` Stephen Hemminger
@ 2014-08-26 16:08         ` Sanford, Robert
  2014-09-01 11:15           ` Thomas Monjalon
  0 siblings, 1 reply; 12+ messages in thread
From: Sanford, Robert @ 2014-08-26 16:08 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev


>
>> This is what we came up with. It works for us. In our kernel headers'
>> linux/pci.h, pci_num_vf is enclosed within "#ifdef
>>CONFIG_PCI_IOV/#endif";
>> pci_intx_mask_supported and pci_check_and_mask_intx are enclosed within
>> "#ifdef HAVE_PCI_SET_MWI/#endif".
>> 
>> What do you think?
>
>Maybe we can just get rid of kernel version checks all together and
>just use the HAVE_ checks.
>
>I will test on stock 2.6.32.

Sorry, I spoke too soon. Although it builds with the ifdefs, I just found
that it does not load.
"kernel: igb_uio: Unknown symbol irq_to_desc"

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel
  2014-08-26 16:08         ` Sanford, Robert
@ 2014-09-01 11:15           ` Thomas Monjalon
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Monjalon @ 2014-09-01 11:15 UTC (permalink / raw)
  To: Sanford, Robert; +Cc: dev

Hi Robert,

2014-08-26 11:08, Sanford, Robert:
> >> This is what we came up with. It works for us. In our kernel headers'
> >> linux/pci.h, pci_num_vf is enclosed within "#ifdef
> >>CONFIG_PCI_IOV/#endif";
> >> pci_intx_mask_supported and pci_check_and_mask_intx are enclosed within
> >> "#ifdef HAVE_PCI_SET_MWI/#endif".
> >> 
> >> What do you think?
> >
> >Maybe we can just get rid of kernel version checks all together and
> >just use the HAVE_ checks.
> >
> >I will test on stock 2.6.32.
> 
> Sorry, I spoke too soon. Although it builds with the ifdefs, I just found
> that it does not load.
> "kernel: igb_uio: Unknown symbol irq_to_desc"

Do you have some progress on this side?
Release 1.7.1 should be closed tomorrow and your help would be greatly
appreciated.

Thanks
-- 
Thomas

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel
  2014-07-25 17:36 [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel Stephen Hemminger
  2014-07-25 17:37 ` [dpdk-dev] [PATCH 2/2] igb_uio: handle no IRQ fallback Stephen Hemminger
  2014-08-01 13:10 ` [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel Thomas Monjalon
@ 2014-09-01 14:55 ` Guillaume Gaudonville
  2014-09-03  2:28   ` Thomas Monjalon
  2 siblings, 1 reply; 12+ messages in thread
From: Guillaume Gaudonville @ 2014-09-01 14:55 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

On 07/25/2014 07:36 PM, Stephen Hemminger wrote:
> Add more compatibility wrappers, and split out all the wrapper
> code to a separate file. Builds on Debian Squeeze (2.6.32) which
> is oldest version of kernel current DPDK supports.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>
> ---
>   lib/librte_eal/linuxapp/igb_uio/compat.h  |  103 ++++++++++++++++++++++++++++++
>   lib/librte_eal/linuxapp/igb_uio/igb_uio.c |   81 -----------------------
>   2 files changed, 104 insertions(+), 80 deletions(-)
>
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ b/lib/librte_eal/linuxapp/igb_uio/compat.h	2014-07-25 10:29:58.664127988 -0700
> @@ -0,0 +1,103 @@
> +/*
> + * Minimal wrappers to allow compiling igb_uio on older kernels.
> + */
> +
> +
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
> +#define pci_cfg_access_lock   pci_block_user_cfg_access
> +#define pci_cfg_access_unlock pci_unblock_user_cfg_access
> +#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
> +
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)
> +static int pci_num_vf(struct pci_dev *dev)
> +{
> +	struct iov {
> +		int pos;
> +		int nres;
> +		u32 cap;
> +		u16 ctrl;
> +		u16 total;
> +		u16 initial;
> +		u16 nr_virtfn;
> +	} *iov = (struct iov *)dev->sriov;
> +
> +	if (!dev->is_physfn)
> +		return 0;
> +
> +	return iov->nr_virtfn;
> +}
> +#endif
> +
> +
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
> +
> +/* Check if INTX works to control irq's.
> + * Set's INTX_DISABLE flag and reads it back
> + */
> +static bool pci_intx_mask_supported(struct pci_dev *pdev)
> +{
> +	bool mask_supported = false;
> +	uint16_t orig, new;
> +
> +	pci_block_user_cfg_access(pdev);
> +	pci_read_config_word(pdev, PCI_COMMAND, &orig);
> +	pci_write_config_word(pdev, PCI_COMMAND,
> +			      orig ^ PCI_COMMAND_INTX_DISABLE);
> +	pci_read_config_word(pdev, PCI_COMMAND, &new);
> +
> +	if ((new ^ orig) & ~PCI_COMMAND_INTX_DISABLE) {
> +		dev_err(&pdev->dev, "Command register changed from "
> +			"0x%x to 0x%x: driver or hardware bug?\n", orig, new);
> +	} else if ((new ^ orig) & PCI_COMMAND_INTX_DISABLE) {
> +		mask_supported = true;
> +		pci_write_config_word(pdev, PCI_COMMAND, orig);
> +	}
> +	pci_unblock_user_cfg_access(pdev);
> +
> +	return mask_supported;
> +}
> +
> +static bool pci_check_and_mask_intx(struct pci_dev *pdev)
> +{
> +	bool pending;
> +	uint32_t status;
> +
> +	pci_block_user_cfg_access(pdev);
> +	pci_read_config_dword(pdev, PCI_COMMAND, &status);
> +
> +	/* interrupt is not ours, goes to out */
> +	pending = (((status >> 16) & PCI_STATUS_INTERRUPT) != 0);
> +	if (pending) {
> +		uint16_t old, new;
> +
> +		old = status;
> +		if (status != 0)
> +			new = old & (~PCI_COMMAND_INTX_DISABLE);
> +		else
> +			new = old | PCI_COMMAND_INTX_DISABLE;
> +
> +		if (old != new)
> +			pci_write_config_word(pdev, PCI_COMMAND, new);
> +	}
> +	pci_unblock_user_cfg_access(pdev);
> +
> +	return pending;
> +}
> +#endif
> +
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
> +/* Compatability wrapper for new kernel API for IRQ */
> +#define irq_data	irq_desc
> +#define irq_get_irq_data(irq)	irq_to_desc(irq)
> +#define irq_data_get_msi(data)	get_irq_desc_msi(data)
> +#endif
> +
irq_to_desc is not exported to modules before kernel 3.4 and commit 
3911ff30.
On Red Hat 6.5 the module fails to load due to an unknow symbol error. 
I've seen
another post saying that it also fails to insert on kernel 2.6.34. I 
guess it should not work
either on debian squeeze (kernel 2.6.32), did you compile it in built-in?

For now, I don't see how we could fix it, since it is not exported we 
are not allowed to use it in a kernel
module. Do you have a way to fix this issue?

Thanks,
Guillaume
> --- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c	2014-07-25 10:29:58.668128002 -0700
> +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c	2014-07-25 10:29:58.664127988 -0700
> @@ -37,10 +37,7 @@
>   #endif
>   #include <rte_pci_dev_features.h>
>   
> -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
> -#define pci_cfg_access_lock   pci_block_user_cfg_access
> -#define pci_cfg_access_unlock pci_unblock_user_cfg_access
> -#endif
> +#include "compat.h"
>   
>   #ifdef RTE_PCI_CONFIG
>   #define PCI_SYS_FILE_BUF_SIZE      10
> @@ -70,26 +67,6 @@ igbuio_get_uio_pci_dev(struct uio_info *
>   }
>   
>   /* sriov sysfs */
> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)
> -static int pci_num_vf(struct pci_dev *dev)
> -{
> -	struct iov {
> -		int pos;
> -		int nres;
> -		u32 cap;
> -		u16 ctrl;
> -		u16 total;
> -		u16 initial;
> -		u16 nr_virtfn;
> -	} *iov = (struct iov *)dev->sriov;
> -
> -	if (!dev->is_physfn)
> -		return 0;
> -
> -	return iov->nr_virtfn;
> -}
> -#endif
> -
>   static ssize_t
>   show_max_vfs(struct device *dev, struct device_attribute *attr,
>   	     char *buf)
> @@ -228,62 +205,6 @@ static struct attribute *dev_attrs[] = {
>   static const struct attribute_group dev_attr_grp = {
>   	.attrs = dev_attrs,
>   };
> -
> -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
> -/* Check if INTX works to control irq's.
> - * Set's INTX_DISABLE flag and reads it back
> - */
> -static bool pci_intx_mask_supported(struct pci_dev *pdev)
> -{
> -	bool mask_supported = false;
> -	uint16_t orig, new;
> -
> -	pci_block_user_cfg_access(pdev);
> -	pci_read_config_word(pdev, PCI_COMMAND, &orig);
> -	pci_write_config_word(pdev, PCI_COMMAND,
> -			      orig ^ PCI_COMMAND_INTX_DISABLE);
> -	pci_read_config_word(pdev, PCI_COMMAND, &new);
> -
> -	if ((new ^ orig) & ~PCI_COMMAND_INTX_DISABLE) {
> -		dev_err(&pdev->dev, "Command register changed from "
> -			"0x%x to 0x%x: driver or hardware bug?\n", orig, new);
> -	} else if ((new ^ orig) & PCI_COMMAND_INTX_DISABLE) {
> -		mask_supported = true;
> -		pci_write_config_word(pdev, PCI_COMMAND, orig);
> -	}
> -	pci_unblock_user_cfg_access(pdev);
> -
> -	return mask_supported;
> -}
> -
> -static bool pci_check_and_mask_intx(struct pci_dev *pdev)
> -{
> -	bool pending;
> -	uint32_t status;
> -
> -	pci_block_user_cfg_access(pdev);
> -	pci_read_config_dword(pdev, PCI_COMMAND, &status);
> -
> -	/* interrupt is not ours, goes to out */
> -	pending = (((status >> 16) & PCI_STATUS_INTERRUPT) != 0);
> -	if (pending) {
> -		uint16_t old, new;
> -
> -		old = status;
> -		if (status != 0)
> -			new = old & (~PCI_COMMAND_INTX_DISABLE);
> -		else
> -			new = old | PCI_COMMAND_INTX_DISABLE;
> -
> -		if (old != new)
> -			pci_write_config_word(pdev, PCI_COMMAND, new);
> -	}
> -	pci_unblock_user_cfg_access(pdev);
> -
> -	return pending;
> -}
> -#endif
> -
>   /*
>    * It masks the msix on/off of generating MSI-X messages.
>    */

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel
  2014-08-22 18:09     ` Robert Sanford
  2014-08-23 15:14       ` Stephen Hemminger
@ 2014-09-01 15:07       ` Guillaume Gaudonville
  1 sibling, 0 replies; 12+ messages in thread
From: Guillaume Gaudonville @ 2014-09-01 15:07 UTC (permalink / raw)
  To: Robert Sanford, Thomas Monjalon, dev

On 08/22/2014 08:09 PM, Robert Sanford wrote:
> This is what we came up with. It works for us. In our kernel headers'
> linux/pci.h, pci_num_vf is enclosed within "#ifdef CONFIG_PCI_IOV/#endif";
> pci_intx_mask_supported and pci_check_and_mask_intx are enclosed within
> "#ifdef HAVE_PCI_SET_MWI/#endif".
Testing on HAVE_PCI_SET_MWI seems not correct. It is defined since linux 
2.6.12.
There is no define associated with the commit that adds 
pci_intx_mask_supported and
pci_check_and_mask_intx.

So I think we'll have to check the distribution, something like:

-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) && \
+       (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE == 
RHEL_RELEASE_VERSION(6,5)))

What do you think?

--
Best regards,
Guillaume
>
> What do you think?
>
> --
> Thanks,
> Robert
>
>
> ---
>   lib/librte_eal/linuxapp/igb_uio/compat.h |    4 ++--
>   1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/librte_eal/linuxapp/igb_uio/compat.h
> b/lib/librte_eal/linuxapp/igb_uio/compat.h
> index 2a16540..f7404d8 100644
> --- a/lib/librte_eal/linuxapp/igb_uio/compat.h
> +++ b/lib/librte_eal/linuxapp/igb_uio/compat.h
> @@ -17,7 +17,7 @@
>   #define   PCI_MSIX_ENTRY_CTRL_MASKBIT   1
>   #endif
>
> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34) &&
> !defined(CONFIG_PCI_IOV)
>   static int pci_num_vf(struct pci_dev *dev)
>   {
>      struct iov {
> @@ -38,7 +38,7 @@ static int pci_num_vf(struct pci_dev *dev)
>   #endif
>
>
> -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) &&
> !defined(HAVE_PCI_SET_MWI)
>
>   /* Check if INTX works to control irq's.
>    * Set's INTX_DISABLE flag and reads it back

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel
  2014-09-01 14:55 ` Guillaume Gaudonville
@ 2014-09-03  2:28   ` Thomas Monjalon
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Monjalon @ 2014-09-03  2:28 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

Hi Stephen,

There are some reports about build errors with igb_uio.
This is critical for the release.
As your patches have introduced this problem, we'd like
to have your opinion.

For release 1.7.1, I've reverted MSI support.
We should try to fix it for next release.

2014-09-01 16:55, Guillaume Gaudonville:
> On 07/25/2014 07:36 PM, Stephen Hemminger wrote:
> > +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
> > +/* Compatability wrapper for new kernel API for IRQ */
> > +#define irq_data	irq_desc
> > +#define irq_get_irq_data(irq)	irq_to_desc(irq)
> > +#define irq_data_get_msi(data)	get_irq_desc_msi(data)
> > +#endif
> 
> irq_to_desc is not exported to modules before kernel 3.4 and commit 
> 3911ff30.
> On Red Hat 6.5 the module fails to load due to an unknow symbol error.
> I've seen another post saying that it also fails to insert on kernel 2.6.34.
> I guess it should not work either on debian squeeze (kernel 2.6.32),
> did you compile it in built-in?

Generally speaking, I think your patches would need more tests.
If you cannot properly test your patches, you could explain how you test it,
when submitting patch, so someone else could continue the test campaign.

> For now, I don't see how we could fix it, since it is not exported we 
> are not allowed to use it in a kernel module.
> Do you have a way to fix this issue?

Waiting for the fix, MSI support is reverted.

Thanks for your understanding
-- 
Thomas

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-09-03  2:24 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-25 17:36 [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel Stephen Hemminger
2014-07-25 17:37 ` [dpdk-dev] [PATCH 2/2] igb_uio: handle no IRQ fallback Stephen Hemminger
2014-08-01 13:11   ` Thomas Monjalon
2014-08-01 13:10 ` [dpdk-dev] [PATCH 1/2] igb_uio: fix compability on old kernel Thomas Monjalon
2014-08-22 17:29   ` Sanford, Robert
2014-08-22 18:09     ` Robert Sanford
2014-08-23 15:14       ` Stephen Hemminger
2014-08-26 16:08         ` Sanford, Robert
2014-09-01 11:15           ` Thomas Monjalon
2014-09-01 15:07       ` Guillaume Gaudonville
2014-09-01 14:55 ` Guillaume Gaudonville
2014-09-03  2:28   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).