net/mlx4: support secondary process
[dpdk.git] / drivers / net / mlx4 / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright 2018 6WIND S.A.
3 # Copyright 2018 Mellanox Technologies, Ltd
4
5 pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
6 LIB_GLUE_BASE = 'librte_pmd_mlx4_glue.so'
7 LIB_GLUE_VERSION = '18.02.0'
8 LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION
9 if pmd_dlopen
10         dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1)
11         cflags += [
12                 '-DMLX4_GLUE="@0@"'.format(LIB_GLUE),
13                 '-DMLX4_GLUE_VERSION="@0@"'.format(LIB_GLUE_VERSION),
14         ]
15 endif
16 libs = [
17         dependency('libmnl', required:false),
18         dependency('libmlx4', required:false),
19         dependency('libibverbs', required:false),
20 ]
21 build = true
22 foreach lib:libs
23         if not lib.found()
24                 build = false
25         endif
26 endforeach
27 # Compile PMD
28 if build
29         allow_experimental_apis = true
30         ext_deps += libs
31         sources = files(
32                 'mlx4.c',
33                 'mlx4_ethdev.c',
34                 'mlx4_flow.c',
35                 'mlx4_intr.c',
36                 'mlx4_mp.c',
37                 'mlx4_mr.c',
38                 'mlx4_rxq.c',
39                 'mlx4_rxtx.c',
40                 'mlx4_txq.c',
41                 'mlx4_utils.c',
42         )
43         if not pmd_dlopen
44                 sources += files('mlx4_glue.c')
45         endif
46         cflags_options = [
47                 '-Wextra',
48                 '-std=c11',
49                 '-Wno-strict-prototypes',
50                 '-D_BSD_SOURCE',
51                 '-D_DEFAULT_SOURCE',
52                 '-D_XOPEN_SOURCE=600'
53         ]
54         foreach option:cflags_options
55                 if cc.has_argument(option)
56                         cflags += option
57                 endif
58         endforeach
59         if get_option('buildtype').contains('debug')
60                 cflags += [ '-pedantic', '-UNDEBUG', '-DPEDANTIC' ]
61         else
62                 cflags += [ '-DNDEBUG', '-UPEDANTIC' ]
63         endif
64         # To maintain the compatibility with the make build system
65         # mlx4_autoconf.h file is still generated.
66         # input array for meson member search:
67         # [ "MACRO to define if found", "header for the search",
68         #   "symbol to search","struct member to search" ]
69         #
70         has_member_args = [
71                 [ 'HAVE_IBV_MLX4_WQE_LSO_SEG', 'infiniband/mlx4dv.h',
72                 'struct mlx4_wqe_lso_seg', 'mss_hdr_size' ],
73         ]
74         # input array for meson symbol search:
75         # [ "MACRO to define if found", "header for the search",
76         #   "symbol to search" ]
77         has_sym_args = [
78                 [ 'HAVE_IBV_MLX4_BUF_ALLOCATORS', 'infiniband/mlx4dv.h',
79                 'MLX4DV_SET_CTX_ATTR_BUF_ALLOCATORS' ],
80                 [ 'HAVE_IBV_MLX4_UAR_MMAP_OFFSET', 'infiniband/mlx4dv.h',
81                 'MLX4DV_QP_MASK_UAR_MMAP_OFFSET' ],
82         ]
83         config = configuration_data()
84         foreach arg:has_sym_args
85                 config.set(arg[0], cc.has_header_symbol(arg[1], arg[2]))
86         endforeach
87         foreach arg:has_member_args
88                 file_prefix = '#include<' + arg[1] + '>'
89                 config.set(arg[0], cc.has_member(arg[2], arg[3],
90                         prefix : file_prefix))
91         endforeach
92         configure_file(output : 'mlx4_autoconf.h', configuration : config)
93 endif
94 # Build Glue Library
95 if pmd_dlopen and build
96         dlopen_name = 'mlx4_glue'
97         dlopen_lib_name = driver_name_fmt.format(dlopen_name)
98         dlopen_so_version = LIB_GLUE_VERSION
99         dlopen_sources = files('mlx4_glue.c')
100         dlopen_install_dir = [ eal_pmd_path + '-glue' ]
101         shared_lib = shared_library(
102                 dlopen_lib_name,
103                 dlopen_sources,
104                 include_directories: global_inc,
105                 c_args: cflags,
106                 dependencies: libs,
107                 link_args: [
108                 '-Wl,-export-dynamic',
109                 '-Wl,-h,@0@'.format(LIB_GLUE),
110                 ],
111                 soversion: dlopen_so_version,
112                 install: true,
113                 install_dir: dlopen_install_dir,
114         )
115 endif