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