[dpdk-dev] eal/bsdapp: add FreeBSD module compilation to meson build

Message ID 20170921145453.174003-1-bruce.richardson@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Bruce Richardson
Headers

Checks

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

Commit Message

Bruce Richardson Sept. 21, 2017, 2:54 p.m. UTC
  Support compiling the FreeBSD kernel modules using meson and ninja.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 config/rte_config.h                         |  5 ++++
 lib/librte_eal/bsdapp/BSDmakefile.meson     | 42 +++++++++++++++++++++++++++++
 lib/librte_eal/bsdapp/contigmem/meson.build | 32 ++++++++++++++++++++++
 lib/librte_eal/bsdapp/meson.build           | 23 ++++++++++++++++
 lib/librte_eal/bsdapp/nic_uio/meson.build   | 32 ++++++++++++++++++++++
 5 files changed, 134 insertions(+)
 create mode 100644 lib/librte_eal/bsdapp/BSDmakefile.meson
 create mode 100644 lib/librte_eal/bsdapp/contigmem/meson.build
 create mode 100644 lib/librte_eal/bsdapp/nic_uio/meson.build
  

Comments

Van Haaren, Harry Oct. 4, 2017, 3:34 p.m. UTC | #1
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richardson
> Sent: Thursday, September 21, 2017 3:55 PM
> To: dev@dpdk.org
> Cc: Richardson, Bruce <bruce.richardson@intel.com>
> Subject: [dpdk-dev] [PATCH] eal/bsdapp: add FreeBSD module compilation to
> meson build
> 
> Support compiling the FreeBSD kernel modules using meson and ninja.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>

Tested on BSD box, both existing GMake system, and Meson / Ninja working as expected here.
With inline comment below fixed;

Tested-by: Harry van Haaren <harry.van.haaren@intel.com>


> ---
>  config/rte_config.h                         |  5 ++++
>  lib/librte_eal/bsdapp/BSDmakefile.meson     | 42
> +++++++++++++++++++++++++++++
>  lib/librte_eal/bsdapp/contigmem/meson.build | 32 ++++++++++++++++++++++
>  lib/librte_eal/bsdapp/meson.build           | 23 ++++++++++++++++
>  lib/librte_eal/bsdapp/nic_uio/meson.build   | 32 ++++++++++++++++++++++
>  5 files changed, 134 insertions(+)
>  create mode 100644 lib/librte_eal/bsdapp/BSDmakefile.meson
>  create mode 100644 lib/librte_eal/bsdapp/contigmem/meson.build
>  create mode 100644 lib/librte_eal/bsdapp/nic_uio/meson.build
> 
> diff --git a/config/rte_config.h b/config/rte_config.h
> index 3e26d5118..26656137c 100644
> --- a/config/rte_config.h
> +++ b/config/rte_config.h
> @@ -58,6 +58,11 @@
>  #define RTE_BACKTRACE 1
>  #define RTE_EAL_VFIO 1
> 
> +/* bsd module defines */
> +#define RTE_CONTIGMEM_MAX_NUM_BUFS 64
> +#define RTE_CONTIGMEM_DEFAULT_NUM_BUFS 1
> +#define RTE_CONTIGMEM_DEFAULT_BUF_SIZE 512*1024*1024

ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#39: FILE: config/rte_config.h:64:
+#define RTE_CONTIGMEM_DEFAULT_BUF_SIZE 512*1024*1024
  
Bruce Richardson Oct. 4, 2017, 4:29 p.m. UTC | #2
On Wed, Oct 04, 2017 at 04:34:11PM +0100, Van Haaren, Harry wrote:
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richardson
> > Sent: Thursday, September 21, 2017 3:55 PM
> > To: dev@dpdk.org
> > Cc: Richardson, Bruce <bruce.richardson@intel.com>
> > Subject: [dpdk-dev] [PATCH] eal/bsdapp: add FreeBSD module compilation to
> > meson build
> > 
> > Support compiling the FreeBSD kernel modules using meson and ninja.
> > 
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> Tested on BSD box, both existing GMake system, and Meson / Ninja working as expected here.
> With inline comment below fixed;
> 
> Tested-by: Harry van Haaren <harry.van.haaren@intel.com>
> 
Applied to dpdk-next-build
  

Patch

diff --git a/config/rte_config.h b/config/rte_config.h
index 3e26d5118..26656137c 100644
--- a/config/rte_config.h
+++ b/config/rte_config.h
@@ -58,6 +58,11 @@ 
 #define RTE_BACKTRACE 1
 #define RTE_EAL_VFIO 1
 
+/* bsd module defines */
+#define RTE_CONTIGMEM_MAX_NUM_BUFS 64
+#define RTE_CONTIGMEM_DEFAULT_NUM_BUFS 1
+#define RTE_CONTIGMEM_DEFAULT_BUF_SIZE 512*1024*1024
+
 /* mempool defines */
 #define RTE_MEMPOOL_CACHE_MAX_SIZE 512
 
diff --git a/lib/librte_eal/bsdapp/BSDmakefile.meson b/lib/librte_eal/bsdapp/BSDmakefile.meson
new file mode 100644
index 000000000..2f16ac05b
--- /dev/null
+++ b/lib/librte_eal/bsdapp/BSDmakefile.meson
@@ -0,0 +1,42 @@ 
+#   BSD LICENSE
+#
+#   Copyright(c) 2017 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in
+#       the documentation and/or other materials provided with the
+#       distribution.
+#     * Neither the name of Intel Corporation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+# makefile for building kernel modules using meson
+# takes parameters from the environment
+
+# source file is passed via KMOD_SRC as full path, we only use final
+# component of it, as VPATH is used to find actual file, so as to
+# have the .o files placed in the build, not source directory
+SRCS = ${KMOD_SRC:T} device_if.h bus_if.h pci_if.h
+CFLAGS += $(KMOD_CFLAGS)
+
+.include <bsd.kmod.mk>
diff --git a/lib/librte_eal/bsdapp/contigmem/meson.build b/lib/librte_eal/bsdapp/contigmem/meson.build
new file mode 100644
index 000000000..0af8c2ed3
--- /dev/null
+++ b/lib/librte_eal/bsdapp/contigmem/meson.build
@@ -0,0 +1,32 @@ 
+#   BSD LICENSE
+#
+#   Copyright(c) 2017 Intel Corporation.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in
+#       the documentation and/or other materials provided with the
+#       distribution.
+#     * Neither the name of Intel Corporation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+sources = files('contigmem.c')
diff --git a/lib/librte_eal/bsdapp/meson.build b/lib/librte_eal/bsdapp/meson.build
index bda974a9a..eadfca438 100644
--- a/lib/librte_eal/bsdapp/meson.build
+++ b/lib/librte_eal/bsdapp/meson.build
@@ -30,3 +30,26 @@ 
 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 subdir('eal')
+kmods = ['contigmem', 'nic_uio']
+
+# for building kernel modules, we use kernel build system using make, as
+# with Linux. We have a skeleton BSDmakefile, which pulls many of its
+# values from the environment. Each module only has a single source file
+# right now, which allows us to simplify things. We pull in the source files
+# from the individual meson.build files, and then use a custom target to call
+# make, passing in the values as environmental parameters.
+kmod_cflags = ['-I' + meson.build_root(),
+		'-I' + join_paths(meson.source_root(), 'config'),
+		'-include rte_config.h']
+foreach k:kmods
+	subdir(k)
+	custom_target(k,
+		input: [files('BSDmakefile.meson'), sources],
+		output: k + '.ko',
+		command: ['make', '-f', '@INPUT0@',
+			'KMOD_SRC=@INPUT1@',
+			'KMOD=' + k,
+			'VPATH=' + join_paths(meson.current_source_dir(), k),
+			'KMOD_CFLAGS=' + ' '.join(kmod_cflags)],
+		build_by_default: get_option('enable_kmods'))
+endforeach
diff --git a/lib/librte_eal/bsdapp/nic_uio/meson.build b/lib/librte_eal/bsdapp/nic_uio/meson.build
new file mode 100644
index 000000000..ca8a48c7e
--- /dev/null
+++ b/lib/librte_eal/bsdapp/nic_uio/meson.build
@@ -0,0 +1,32 @@ 
+#   BSD LICENSE
+#
+#   Copyright(c) 2017 Intel Corporation.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in
+#       the documentation and/or other materials provided with the
+#       distribution.
+#     * Neither the name of Intel Corporation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+sources = files('nic_uio.c')