5d6a8616893f7effd8d527b71859cb1cbd50919f
[dpdk.git] / drivers / common / mlx5 / linux / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright 2020 Mellanox Technologies, Ltd
3
4 includes += include_directories('.')
5
6 static_ibverbs = (get_option('ibverbs_link') == 'static')
7 dlopen_ibverbs = (get_option('ibverbs_link') == 'dlopen')
8 LIB_GLUE_BASE = 'librte_common_mlx5_glue.so'
9 LIB_GLUE_VERSION = abi_version
10 LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION
11 if dlopen_ibverbs
12         dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1)
13         cflags += [
14                 '-DMLX5_GLUE="@0@"'.format(LIB_GLUE),
15                 '-DMLX5_GLUE_VERSION="@0@"'.format(LIB_GLUE_VERSION),
16         ]
17 endif
18
19 libnames = [ 'mlx5', 'ibverbs' ]
20 libs = []
21 foreach libname:libnames
22         lib = dependency('lib' + libname, static:static_ibverbs,
23                         required:false, method: 'pkg-config')
24         if not lib.found() and not static_ibverbs
25                 lib = cc.find_library(libname, required:false)
26         endif
27         if lib.found()
28                 libs += lib
29                 if not static_ibverbs and not dlopen_ibverbs
30                         ext_deps += lib
31                 endif
32         else
33                 build = false
34                 reason = 'missing dependency, "' + libname + '"'
35                 subdir_done()
36         endif
37 endforeach
38 if static_ibverbs or dlopen_ibverbs
39         # Build without adding shared libs to Requires.private
40         ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
41         ext_deps += declare_dependency(compile_args: ibv_cflags.split())
42 endif
43 if static_ibverbs
44         # Add static deps ldflags to internal apps and Libs.private
45         ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
46         ext_deps += declare_dependency(link_args:ibv_ldflags.split())
47 endif
48
49 sources += files('mlx5_nl.c')
50 sources += files('mlx5_common_os.c')
51 sources += files('mlx5_common_verbs.c')
52 if not dlopen_ibverbs
53         sources += files('mlx5_glue.c')
54 endif
55
56 # To maintain the compatibility with the make build system
57 # mlx5_autoconf.h file is still generated.
58 # input array for meson member search:
59 # [ "MACRO to define if found", "header for the search",
60 #   "symbol to search", "struct member to search" ]
61 has_member_args = [
62         [ 'HAVE_IBV_MLX5_MOD_SWP', 'infiniband/mlx5dv.h',
63         'struct mlx5dv_sw_parsing_caps', 'sw_parsing_offloads' ],
64         [ 'HAVE_IBV_DEVICE_COUNTERS_SET_V42', 'infiniband/verbs.h',
65         'struct ibv_counter_set_init_attr', 'counter_set_id' ],
66         [ 'HAVE_IBV_DEVICE_COUNTERS_SET_V45', 'infiniband/verbs.h',
67         'struct ibv_counters_init_attr', 'comp_mask' ],
68         [ 'HAVE_MLX5DV_DEVX_UAR_OFFSET', 'infiniband/mlx5dv.h',
69         'struct mlx5dv_devx_uar', 'mmap_off' ],
70 ]
71 # input array for meson symbol search:
72 # [ "MACRO to define if found", "header for the search",
73 #   "symbol to search" ]
74 has_sym_args = [
75         [ 'HAVE_IBV_RELAXED_ORDERING', 'infiniband/verbs.h',
76         'IBV_ACCESS_RELAXED_ORDERING ' ],
77         [ 'HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT', 'infiniband/mlx5dv.h',
78         'MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX' ],
79         [ 'HAVE_IBV_DEVICE_TUNNEL_SUPPORT', 'infiniband/mlx5dv.h',
80         'MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS' ],
81         [ 'HAVE_IBV_MLX5_MOD_MPW', 'infiniband/mlx5dv.h',
82         'MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED' ],
83         [ 'HAVE_IBV_MLX5_MOD_CQE_128B_COMP', 'infiniband/mlx5dv.h',
84         'MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP' ],
85         [ 'HAVE_IBV_MLX5_MOD_CQE_128B_PAD', 'infiniband/mlx5dv.h',
86         'MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD' ],
87         [ 'HAVE_IBV_FLOW_DV_SUPPORT', 'infiniband/mlx5dv.h',
88         'mlx5dv_create_flow_action_packet_reformat' ],
89         [ 'HAVE_IBV_DEVICE_MPLS_SUPPORT', 'infiniband/verbs.h',
90         'IBV_FLOW_SPEC_MPLS' ],
91         [ 'HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING', 'infiniband/verbs.h',
92         'IBV_WQ_FLAGS_PCI_WRITE_END_PADDING' ],
93         [ 'HAVE_IBV_WQ_FLAG_RX_END_PADDING', 'infiniband/verbs.h',
94         'IBV_WQ_FLAG_RX_END_PADDING' ],
95         [ 'HAVE_MLX5DV_DR_DEVX_PORT', 'infiniband/mlx5dv.h',
96         'mlx5dv_query_devx_port' ],
97         [ 'HAVE_IBV_DEVX_OBJ', 'infiniband/mlx5dv.h',
98         'mlx5dv_devx_obj_create' ],
99         [ 'HAVE_IBV_FLOW_DEVX_COUNTERS', 'infiniband/mlx5dv.h',
100         'MLX5DV_FLOW_ACTION_COUNTERS_DEVX' ],
101         [ 'HAVE_MLX5_DR_CREATE_ACTION_DEFAULT_MISS', 'infiniband/mlx5dv.h',
102         'MLX5DV_FLOW_ACTION_DEFAULT_MISS' ],
103         [ 'HAVE_IBV_DEVX_ASYNC', 'infiniband/mlx5dv.h',
104         'mlx5dv_devx_obj_query_async' ],
105         [ 'HAVE_IBV_DEVX_QP', 'infiniband/mlx5dv.h',
106         'mlx5dv_devx_qp_query' ],
107         [ 'HAVE_MLX5DV_PP_ALLOC', 'infiniband/mlx5dv.h',
108         'mlx5dv_pp_alloc' ],
109         [ 'HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR', 'infiniband/mlx5dv.h',
110         'mlx5dv_dr_action_create_dest_devx_tir' ],
111         [ 'HAVE_IBV_DEVX_EVENT', 'infiniband/mlx5dv.h',
112         'mlx5dv_devx_get_event' ],
113         [ 'HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER', 'infiniband/mlx5dv.h',
114         'mlx5dv_dr_action_create_flow_meter' ],
115         [ 'HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD', 'infiniband/mlx5dv.h',
116         'MLX5_MMAP_GET_NC_PAGES_CMD' ],
117         [ 'HAVE_MLX5DV_DR', 'infiniband/mlx5dv.h',
118         'MLX5DV_DR_DOMAIN_TYPE_NIC_RX' ],
119         [ 'HAVE_MLX5DV_DR_ESWITCH', 'infiniband/mlx5dv.h',
120         'MLX5DV_DR_DOMAIN_TYPE_FDB' ],
121         [ 'HAVE_MLX5DV_DR_VLAN', 'infiniband/mlx5dv.h',
122         'mlx5dv_dr_action_create_push_vlan' ],
123         [ 'HAVE_IBV_VAR', 'infiniband/mlx5dv.h', 'mlx5dv_alloc_var' ],
124         [ 'HAVE_MLX5_OPCODE_ENHANCED_MPSW', 'infiniband/mlx5dv.h',
125         'MLX5_OPCODE_ENHANCED_MPSW' ],
126         [ 'HAVE_MLX5_OPCODE_SEND_EN', 'infiniband/mlx5dv.h',
127         'MLX5_OPCODE_SEND_EN' ],
128         [ 'HAVE_MLX5_OPCODE_WAIT', 'infiniband/mlx5dv.h',
129         'MLX5_OPCODE_WAIT' ],
130         [ 'HAVE_MLX5_OPCODE_ACCESS_ASO', 'infiniband/mlx5dv.h',
131         'MLX5_OPCODE_ACCESS_ASO' ],
132         [ 'HAVE_SUPPORTED_40000baseKR4_Full', 'linux/ethtool.h',
133         'SUPPORTED_40000baseKR4_Full' ],
134         [ 'HAVE_SUPPORTED_40000baseCR4_Full', 'linux/ethtool.h',
135         'SUPPORTED_40000baseCR4_Full' ],
136         [ 'HAVE_SUPPORTED_40000baseSR4_Full', 'linux/ethtool.h',
137         'SUPPORTED_40000baseSR4_Full' ],
138         [ 'HAVE_SUPPORTED_40000baseLR4_Full', 'linux/ethtool.h',
139         'SUPPORTED_40000baseLR4_Full' ],
140         [ 'HAVE_SUPPORTED_56000baseKR4_Full', 'linux/ethtool.h',
141         'SUPPORTED_56000baseKR4_Full' ],
142         [ 'HAVE_SUPPORTED_56000baseCR4_Full', 'linux/ethtool.h',
143         'SUPPORTED_56000baseCR4_Full' ],
144         [ 'HAVE_SUPPORTED_56000baseSR4_Full', 'linux/ethtool.h',
145         'SUPPORTED_56000baseSR4_Full' ],
146         [ 'HAVE_SUPPORTED_56000baseLR4_Full', 'linux/ethtool.h',
147         'SUPPORTED_56000baseLR4_Full' ],
148         [ 'HAVE_ETHTOOL_LINK_MODE_25G', 'linux/ethtool.h',
149         'ETHTOOL_LINK_MODE_25000baseCR_Full_BIT' ],
150         [ 'HAVE_ETHTOOL_LINK_MODE_50G', 'linux/ethtool.h',
151         'ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT' ],
152         [ 'HAVE_ETHTOOL_LINK_MODE_100G', 'linux/ethtool.h',
153         'ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT' ],
154         [ 'HAVE_IFLA_NUM_VF', 'linux/if_link.h',
155         'IFLA_NUM_VF' ],
156         [ 'HAVE_IFLA_EXT_MASK', 'linux/if_link.h',
157         'IFLA_EXT_MASK' ],
158         [ 'HAVE_IFLA_PHYS_SWITCH_ID', 'linux/if_link.h',
159         'IFLA_PHYS_SWITCH_ID' ],
160         [ 'HAVE_IFLA_PHYS_PORT_NAME', 'linux/if_link.h',
161         'IFLA_PHYS_PORT_NAME' ],
162         [ 'HAVE_RDMA_NL_NLDEV', 'rdma/rdma_netlink.h',
163         'RDMA_NL_NLDEV' ],
164         [ 'HAVE_RDMA_NLDEV_CMD_GET', 'rdma/rdma_netlink.h',
165         'RDMA_NLDEV_CMD_GET' ],
166         [ 'HAVE_RDMA_NLDEV_CMD_PORT_GET', 'rdma/rdma_netlink.h',
167         'RDMA_NLDEV_CMD_PORT_GET' ],
168         [ 'HAVE_RDMA_NLDEV_ATTR_DEV_INDEX', 'rdma/rdma_netlink.h',
169         'RDMA_NLDEV_ATTR_DEV_INDEX' ],
170         [ 'HAVE_RDMA_NLDEV_ATTR_DEV_NAME', 'rdma/rdma_netlink.h',
171         'RDMA_NLDEV_ATTR_DEV_NAME' ],
172         [ 'HAVE_RDMA_NLDEV_ATTR_PORT_INDEX', 'rdma/rdma_netlink.h',
173         'RDMA_NLDEV_ATTR_PORT_INDEX' ],
174         [ 'HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX', 'rdma/rdma_netlink.h',
175         'RDMA_NLDEV_ATTR_NDEV_INDEX' ],
176         [ 'HAVE_MLX5_DR_FLOW_DUMP', 'infiniband/mlx5dv.h',
177         'mlx5dv_dump_dr_domain'],
178         [ 'HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE', 'infiniband/mlx5dv.h',
179         'mlx5dv_dr_action_create_flow_sampler'],
180         [ 'HAVE_MLX5DV_DR_MEM_RECLAIM', 'infiniband/mlx5dv.h',
181         'mlx5dv_dr_domain_set_reclaim_device_memory'],
182         [ 'HAVE_MLX5_DR_CREATE_ACTION_DEST_ARRAY', 'infiniband/mlx5dv.h',
183         'mlx5dv_dr_action_create_dest_array'],
184         [ 'HAVE_DEVLINK', 'linux/devlink.h', 'DEVLINK_GENL_NAME' ],
185         [ 'HAVE_MLX5_DR_CREATE_ACTION_ASO', 'infiniband/mlx5dv.h',
186         'mlx5dv_dr_action_create_aso' ],
187         [ 'HAVE_INFINIBAND_VERBS_H', 'infiniband/verbs.h',
188         'INFINIBAND_VERBS_H' ],
189         [ 'HAVE_MLX5_UMR_IMKEY', 'infiniband/mlx5dv.h',
190         'MLX5_WQE_UMR_CTRL_FLAG_INLINE' ],
191 ]
192 config = configuration_data()
193 foreach arg:has_sym_args
194         config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
195                 dependencies: libs))
196 endforeach
197 foreach arg:has_member_args
198         file_prefix = '#include <' + arg[1] + '>'
199         config.set(arg[0], cc.has_member(arg[2], arg[3],
200                 prefix : file_prefix, dependencies: libs))
201 endforeach
202 configure_file(output : 'mlx5_autoconf.h', configuration : config)
203
204 # Build Glue Library
205 if dlopen_ibverbs
206         dlopen_name = 'mlx5_glue'
207         dlopen_lib_name = 'rte_common_' + dlopen_name
208         dlopen_so_version = LIB_GLUE_VERSION
209         dlopen_sources = files('mlx5_glue.c')
210         dlopen_install_dir = [ eal_pmd_path + '-glue' ]
211         dlopen_includes = [global_inc]
212         dlopen_includes += include_directories(
213                 '../../../../lib/librte_eal/include/generic',
214         )
215         shared_lib = shared_library(
216                 dlopen_lib_name,
217                 dlopen_sources,
218                 include_directories: dlopen_includes,
219                 c_args: cflags,
220                 dependencies: libs,
221                 link_args: [
222                 '-Wl,-export-dynamic',
223                 '-Wl,-h,@0@'.format(LIB_GLUE),
224                 ],
225                 soversion: dlopen_so_version,
226                 install: true,
227                 install_dir: dlopen_install_dir,
228         )
229 endif