Skip to contentSkip to conversation

net/gve: fix meson build failure on non-Linux platforms

PATCH Superseded Junfeng Guo 4 participants 10 messages Oct 26, 2022 – Oct 27, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/gve: fix meson build failure on non-Linux platforms

Meson build may fail on FreeBSD with gcc and clang, due to missing the header file linux/pci_regs.h on non-Linux platform. Thus, in this patch, we removed the file include and added the used Macros derived from linux/pci_regs.h.

Fixes 3047a5ac8e66 ("net/gve: add support for device initialization")
---
 drivers/net/gve/gve_ethdev.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/net/gve/gve_ethdev.c +13 -1
index b0f7b98daa..e968317737 100644
@@ -1,12 +1,24 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(C) 2022 Intel Corporation
  */
-#include <linux/pci_regs.h>
 
 #include "gve_ethdev.h"
 #include "base/gve_adminq.h"
 #include "base/gve_register.h"
 
+/*
+ * Following macros are derived from linux/pci_regs.h, however,
+ * we can't simply include that header here, as there is no such
+ * file for non-Linux platform.
+ */
+#define PCI_CFG_SPACE_SIZE	256
+#define PCI_CAPABILITY_LIST	0x34	/* Offset of first capability list entry */
+#define PCI_STD_HEADER_SIZEOF	64
+#define PCI_CAP_SIZEOF		4
+#define PCI_CAP_ID_MSIX		0x11	/* MSI-X */
+#define PCI_MSIX_FLAGS		2	/* Message Control */
+#define PCI_MSIX_FLAGS_QSIZE	0x07FF	/* Table size */
+
 const char gve_version_str[] = GVE_VERSION;
 static const char gve_version_prefix[] = GVE_VERSION_PREFIX;
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 8 lines · Junfeng Guo

Meson build may fail on FreeBSD with gcc and clang, due to missing the header file linux/pci_regs.h on non-Linux platform. Thus, in this patch, we removed the file include and added the used Macros derived from linux/pci_regs.h.

Fixes 3047a5ac8e66 ("net/gve: add support for device initialization")

...
No need for Cc: stable.

Quoted 22 lines
---
 drivers/net/gve/gve_ethdev.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/net/gve/gve_ethdev.c +2 -1
index b0f7b98daa..e968317737 100644
@@ -1,12 +1,24 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(C) 2022 Intel Corporation
  */
-#include <linux/pci_regs.h>
 
 #include "gve_ethdev.h"
 #include "base/gve_adminq.h"
 #include "base/gve_register.h"
 
+/*
+ * Following macros are derived from linux/pci_regs.h, however,

drivers/net/gve/gve_ethdev.c line 20

Quoted 10 lines
drivers/net/gve/gve_ethdev.c +10 -0
+ * we can't simply include that header here, as there is no such
+ * file for non-Linux platform.
+ */
+#define PCI_CFG_SPACE_SIZE     256
+#define PCI_CAPABILITY_LIST    0x34    /* Offset of first capability list entry */
+#define PCI_STD_HEADER_SIZEOF  64
+#define PCI_CAP_SIZEOF         4
+#define PCI_CAP_ID_MSIX                0x11    /* MSI-X */
+#define PCI_MSIX_FLAGS         2       /* Message Control */
+#define PCI_MSIX_FLAGS_QSIZE   0x07FF  /* Table size */

No, don't introduce such defines in a driver. We have a PCI library, that provides some defines. So fix your driver to use them.

Signature · 1 line
David Marchand
#2 lore raw
Quoted 37 lines · David Marchand

CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.

Quoted 8 lines · Junfeng Guo

Meson build may fail on FreeBSD with gcc and clang, due to missing the header file linux/pci_regs.h on non-Linux platform. Thus, in this patch, we removed the file include and added the used Macros derived from linux/pci_regs.h.

Fixes 3047a5ac8e66 ("net/gve: add support for device initialization")

...
No need for Cc: stable.

Quoted 20 lines
---
  drivers/net/gve/gve_ethdev.c | 14 +++++++++++++-
  1 file changed, 13 insertions(+), 1 deletion(-)
drivers/net/gve/gve_ethdev.c +0 -1
index b0f7b98daa..e968317737 100644
@@ -1,12 +1,24 @@
  /* SPDX-License-Identifier: BSD-3-Clause
   * Copyright(C) 2022 Intel Corporation
   */
-#include <linux/pci_regs.h>
 
  #include "gve_ethdev.h"
  #include "base/gve_adminq.h"
  #include "base/gve_register.h"
 
Quoted 17 lines

drivers/net/gve/gve_ethdev.c line 20

Quoted 12 lines
drivers/net/gve/gve_ethdev.c +12 -0
+/*
+ * Following macros are derived from linux/pci_regs.h, however,
+ * we can't simply include that header here, as there is no such
+ * file for non-Linux platform.
+ */
+#define PCI_CFG_SPACE_SIZE     256
+#define PCI_CAPABILITY_LIST    0x34    /* Offset of first capability list entry */
+#define PCI_STD_HEADER_SIZEOF  64
+#define PCI_CAP_SIZEOF         4
+#define PCI_CAP_ID_MSIX                0x11    /* MSI-X */
+#define PCI_MSIX_FLAGS         2       /* Message Control */
+#define PCI_MSIX_FLAGS_QSIZE   0x07FF  /* Table size */

No, don't introduce such defines in a driver. We have a PCI library, that provides some defines. So fix your driver to use them.

I can see 'bnx2x' driver is using some flags from 'dev/pci/pcireg.h' header for FreeBSD, unfortunately macro names are not same so a #ifdef is required. Also I don't know it has all macros or if the header is available in all versions etc..

Other option can be to define them all for DPDK in common pci header? As far as I can see we don't have all defined right now.

#3 lore raw
Quoted 23 lines · Ferruh Yigit
Quoted 23 lines
Quoted 23 lines
drivers/net/gve/gve_ethdev.c +9 -1
index b0f7b98daa..e968317737 100644
@@ -1,12 +1,24 @@
  /* SPDX-License-Identifier: BSD-3-Clause
   * Copyright(C) 2022 Intel Corporation
   */
-#include <linux/pci_regs.h>
 
  #include "gve_ethdev.h"
  #include "base/gve_adminq.h"
  #include "base/gve_register.h"
 
+/*
+ * Following macros are derived from linux/pci_regs.h, however,
+ * we can't simply include that header here, as there is no such
+ * file for non-Linux platform.
+ */
+#define PCI_CFG_SPACE_SIZE     256
+#define PCI_CAPABILITY_LIST    0x34    /* Offset of first capability list entry */
+#define PCI_STD_HEADER_SIZEOF  64
+#define PCI_CAP_SIZEOF         4
Quoted 8 lines
Quoted 8 lines

drivers/net/gve/gve_ethdev.c line 20

Quoted 3 lines
drivers/net/gve/gve_ethdev.c +3 -0
+#define PCI_CAP_ID_MSIX                0x11    /* MSI-X */
+#define PCI_MSIX_FLAGS         2       /* Message Control */
+#define PCI_MSIX_FLAGS_QSIZE   0x07FF  /* Table size */

No, don't introduce such defines in a driver. We have a PCI library, that provides some defines. So fix your driver to use them.

After chat with Ferruh, I am ok if we take this compilation fix for now and unblock the CI..

Quoted 9 lines

I can see 'bnx2x' driver is using some flags from 'dev/pci/pcireg.h' header for FreeBSD, unfortunately macro names are not same so a #ifdef is required. Also I don't know it has all macros or if the header is available in all versions etc..

Other option can be to define them all for DPDK in common pci header? As far as I can see we don't have all defined right now.

If there are some missing definitions we can add them in the pci header indeed. Those are constants, defined in the PCIE standard.

I can post a cleanup later, but I would be happy if someone else handles it.

Thanks.

Signature · 1 line
David Marchand
#4 lore raw
Quoted 15 lines · David Marchand
Quoted 14 lines · Ferruh Yigit
Quoted 14 lines
Quoted 14 lines
drivers/net/gve/gve_ethdev.c +0 -1
index b0f7b98daa..e968317737 100644
@@ -1,12 +1,24 @@
   /* SPDX-License-Identifier: BSD-3-Clause
    * Copyright(C) 2022 Intel Corporation
    */
-#include <linux/pci_regs.h>
 
   #include "gve_ethdev.h"
   #include "base/gve_adminq.h"
   #include "base/gve_register.h"
 
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/net/gve/gve_ethdev.c +5 -0
+/*
+ * Following macros are derived from linux/pci_regs.h, however,
+ * we can't simply include that header here, as there is no such
+ * file for non-Linux platform.
+ */
Quoted 8 lines
Quoted 8 lines

drivers/net/gve/gve_ethdev.c line 20

Quoted 7 lines
drivers/net/gve/gve_ethdev.c +7 -0
+#define PCI_CFG_SPACE_SIZE     256
+#define PCI_CAPABILITY_LIST    0x34    /* Offset of first capability list entry */
+#define PCI_STD_HEADER_SIZEOF  64
+#define PCI_CAP_SIZEOF         4
+#define PCI_CAP_ID_MSIX                0x11    /* MSI-X */
+#define PCI_MSIX_FLAGS         2       /* Message Control */
+#define PCI_MSIX_FLAGS_QSIZE   0x07FF  /* Table size */

@Junfeng,

Can you please move these defines to 'gve_ethdev.h'? Beginning of 'gve_ethdev.c' seems too unrelated for PCI defines.

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

No, don't introduce such defines in a driver. We have a PCI library, that provides some defines. So fix your driver to use them.

After chat with Ferruh, I am ok if we take this compilation fix for now and unblock the CI..

ack

Quoted 7 lines
Quoted 7 lines

I can see 'bnx2x' driver is using some flags from 'dev/pci/pcireg.h' header for FreeBSD, unfortunately macro names are not same so a #ifdef is required. Also I don't know it has all macros or if the header is available in all versions etc..

Quoted 9 lines
Quoted 3 lines

Other option can be to define them all for DPDK in common pci header? As far as I can see we don't have all defined right now.

If there are some missing definitions we can add them in the pci header indeed. Those are constants, defined in the PCIE standard.

I can post a cleanup later, but I would be happy if someone else handles it.

@Junfeng,

Can you have bandwidth for this cleanup?

Task is to define PCI macros in common pci header, ('bus_pci_driver.h' I guess ?), and update drivers to use new common ones, remove local definition from drivers.

DPDK macros can use Linux macro names with RTE_ prefix and with a define guard, as done in following:
https://elixir.bootlin.com/dpdk/v22.07/source/drivers/bus/pci/linux/pci_init.h#L50

#5 lore raw
Quoted 50 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, October 26, 2022 18:01
To: David Marchand <[email protected]>; Guo, Junfeng <[email protected]>
Cc: Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; Xia, Chenbo <[email protected]>; Zhang, Helin <[email protected]>
Subject: Re: [PATCH] net/gve: fix meson build failure on non-Linux platforms

Quoted 1 line · David Marchand

On Wed, Oct 26, 2022 at 11:10 AM Ferruh Yigit <[email protected]>

Quoted 1 line · wrote:
Quoted 1 line
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/net/gve/gve_ethdev.c

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

index b0f7b98daa..e968317737 100644

drivers/net/gve/gve_ethdev.c +0 -1
@@ -1,12 +1,24 @@
   /* SPDX-License-Identifier: BSD-3-Clause
    * Copyright(C) 2022 Intel Corporation
    */
-#include <linux/pci_regs.h>
 
   #include "gve_ethdev.h"
   #include "base/gve_adminq.h"
   #include "base/gve_register.h"
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/net/gve/gve_ethdev.c

Quoted 7 lines
drivers/net/gve/gve_ethdev.c +7 -0
+/*
+ * Following macros are derived from linux/pci_regs.h, however,
+ * we can't simply include that header here, as there is no such
+ * file for non-Linux platform.
+ */
+#define PCI_CFG_SPACE_SIZE     256
+#define PCI_CAPABILITY_LIST    0x34    /* Offset of first capability

list entry */

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/net/gve/gve_ethdev.c line 20

Quoted 5 lines
drivers/net/gve/gve_ethdev.c +5 -0
+#define PCI_STD_HEADER_SIZEOF  64
+#define PCI_CAP_SIZEOF         4
+#define PCI_CAP_ID_MSIX                0x11    /* MSI-X */
+#define PCI_MSIX_FLAGS         2       /* Message Control */
+#define PCI_MSIX_FLAGS_QSIZE   0x07FF  /* Table size */
Quoted 4 lines

@Junfeng,

Can you please move these defines to 'gve_ethdev.h'? Beginning of 'gve_ethdev.c' seems too unrelated for PCI defines.

Sure, will update this in v2. Thanks!

Quoted 33 lines
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines

No, don't introduce such defines in a driver. We have a PCI library, that provides some defines. So fix your driver to use them.

After chat with Ferruh, I am ok if we take this compilation fix for now and unblock the CI..

ack

Quoted 4 lines
Quoted 4 lines

I can see 'bnx2x' driver is using some flags from 'dev/pci/pcireg.h' header for FreeBSD, unfortunately macro names are not same so a

#ifdef

Quoted 4 lines
Quoted 4 lines

is required. Also I don't know it has all macros or if the header is available in all versions etc..

Other option can be to define them all for DPDK in common pci header?

As

Quoted 4 lines
Quoted 2 lines

far as I can see we don't have all defined right now.

If there are some missing definitions we can add them in the pci header

indeed.

Quoted 3 lines

Those are constants, defined in the PCIE standard.

I can post a cleanup later, but I would be happy if someone else handles

it.

Quoted 1 line
Quoted 7 lines

@Junfeng,

Can you have bandwidth for this cleanup?

Task is to define PCI macros in common pci header, ('bus_pci_driver.h' I guess ?), and update drivers to use new common ones, remove local definition from drivers.

Yes, the task makes sense and is quite clear.
How about doing this cleanup later, maybe next week with a new patch? Quite busy this week due to RC2...
Thanks! :)

Quoted 6 lines

DPDK macros can use Linux macro names with RTE_ prefix and with a define
guard, as done in following:
https://elixir.bootlin.com/dpdk/v22.07/source/drivers/bus/pci/linux/pci_i
nit.h#L50

I'll try with this, thanks for the comments!

Tested-by on v1 1/1
#6 lore raw
In reply to Junfeng Guo
Quoted 11 lines

From: Junfeng Guo <[email protected]>
Sent: 2022年10月26日 16:43
To: Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; [email protected]; Xing, Beilei <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; Xia, Chenbo <[email protected]>; Zhang, Helin <[email protected]>; Guo, Junfeng <[email protected]>; [email protected]
Subject: [PATCH] net/gve: fix meson build failure on non-Linux platforms

Quoted 8 lines

Meson build may fail on FreeBSD with gcc and clang, due to missing the header file linux/pci_regs.h on non-Linux platform. Thus, in this patch, we removed the file include and added the used Macros derived from linux/pci_regs.h.

Fixes 3047a5ac8e66 ("net/gve: add support for device initialization")
#7 lore raw

PATCH v2 1/1 net/gve: fix meson build failure on non-Linux platforms

In reply to Junfeng Guo

Meson build may fail on FreeBSD with gcc and clang, due to missing the header file linux/pci_regs.h on non-Linux platform. Thus, in this patch, we removed the file include and added the used Macros derived from linux/pci_regs.h.

Fixes 3047a5ac8e66 ("net/gve: add support for device initialization")
---
 drivers/net/gve/gve_ethdev.c |  1 -
 drivers/net/gve/gve_ethdev.h | 13 +++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
drivers/net/gve/gve_ethdev.c +0 -1
index b0f7b98daa..18c879b8d1 100644
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(C) 2022 Intel Corporation
  */
-#include <linux/pci_regs.h>
 
 #include "gve_ethdev.h"
 #include "base/gve_adminq.h"
drivers/net/gve/gve_ethdev.h +13 -0
index 36b334c36b..f6cac3ff2b 100644
@@ -11,6 +11,19 @@
 
 #include "base/gve.h"
 
+/*
+ * Following macros are derived from linux/pci_regs.h, however,
+ * we can't simply include that header here, as there is no such
+ * file for non-Linux platform.
+ */
+#define PCI_CFG_SPACE_SIZE	256
+#define PCI_CAPABILITY_LIST	0x34	/* Offset of first capability list entry */
+#define PCI_STD_HEADER_SIZEOF	64
+#define PCI_CAP_SIZEOF		4
+#define PCI_CAP_ID_MSIX		0x11	/* MSI-X */
+#define PCI_MSIX_FLAGS		2	/* Message Control */
+#define PCI_MSIX_FLAGS_QSIZE	0x07FF	/* Table size */
+
 #define GVE_DEFAULT_RX_FREE_THRESH  512
 #define GVE_DEFAULT_TX_FREE_THRESH  256
 #define GVE_TX_MAX_FREE_SZ          512
Signature · 1 line
2.34.1
#8 lore raw
Quoted 8 lines · Junfeng Guo

Meson build may fail on FreeBSD with gcc and clang, due to missing the header file linux/pci_regs.h on non-Linux platform. Thus, in this patch, we removed the file include and added the used Macros derived from linux/pci_regs.h.

Fixes 3047a5ac8e66 ("net/gve: add support for device initialization")

Squashed into relevant commit in next-net, thanks.

Tested-by on v2 1/1
#9 lore raw
In reply to Junfeng Guo
Quoted 11 lines

From: Junfeng Guo <[email protected]>
Sent: 2022年10月26日 18:23
To: Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; [email protected]; Xing, Beilei <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; Xia, Chenbo <[email protected]>; Zhang, Helin <[email protected]>; Guo, Junfeng <[email protected]>
Subject: [PATCH v2] net/gve: fix meson build failure on non-Linux platforms

Quoted 7 lines

Meson build may fail on FreeBSD with gcc and clang, due to missing the header file linux/pci_regs.h on non-Linux platform. Thus, in this patch, we removed the file include and added the used Macros derived from linux/pci_regs.h.

Fixes 3047a5ac8e66 ("net/gve: add support for device initialization")