common/mlx5: split common file under Linux directory
[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_pmd_mlx5_glue.so'
9 LIB_GLUE_VERSION = '20.02.0'
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, required:false)
23         if not lib.found() and not static_ibverbs
24                 lib = cc.find_library(libname, required:false)
25         endif
26         if lib.found()
27                 libs += lib
28                 if not static_ibverbs and not dlopen_ibverbs
29                         ext_deps += lib
30                 endif
31         else
32                 build = false
33                 reason = 'missing dependency, "' + libname + '"'
34                 subdir_done()
35         endif
36 endforeach
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())
41 endif
42 if static_ibverbs
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())
46 endif
47
48 sources += files('mlx5_nl.c')
49 sources += files('mlx5_common_os.c')
50 if not dlopen_ibverbs
51         sources += files('mlx5_glue.c')
52 endif
53
54 # To maintain the compatibility with the make build system
55 # mlx5_autoconf.h file is still generated.
56 # input array for meson member search:
57 # [ "MACRO to define if found", "header for the search",
58 #   "symbol to search", "struct member to search" ]
59 has_member_args = [
60         [ 'HAVE_IBV_MLX5_MOD_SWP', 'infiniband/mlx5dv.h',
61         'struct mlx5dv_sw_parsing_caps', 'sw_parsing_offloads' ],
62         [ 'HAVE_IBV_DEVICE_COUNTERS_SET_V42', 'infiniband/verbs.h',
63         'struct ibv_counter_set_init_attr', 'counter_set_id' ],
64         [ 'HAVE_IBV_DEVICE_COUNTERS_SET_V45', 'infiniband/verbs.h',
65         'struct ibv_counters_init_attr', 'comp_mask' ],
66 ]
67 # input array for meson symbol search:
68 # [ "MACRO to define if found", "header for the search",
69 #   "symbol to search" ]
70 has_sym_args = [
71         [ 'HAVE_IBV_RELAXED_ORDERING', 'infiniband/verbs.h',
72         'IBV_ACCESS_RELAXED_ORDERING ' ],
73         [ 'HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT', 'infiniband/mlx5dv.h',
74         'MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX' ],
75         [ 'HAVE_IBV_DEVICE_TUNNEL_SUPPORT', 'infiniband/mlx5dv.h',
76         'MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS' ],
77         [ 'HAVE_IBV_MLX5_MOD_MPW', 'infiniband/mlx5dv.h',
78         'MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED' ],
79         [ 'HAVE_IBV_MLX5_MOD_CQE_128B_COMP', 'infiniband/mlx5dv.h',
80         'MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP' ],
81         [ 'HAVE_IBV_MLX5_MOD_CQE_128B_PAD', 'infiniband/mlx5dv.h',
82         'MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD' ],
83         [ 'HAVE_IBV_FLOW_DV_SUPPORT', 'infiniband/mlx5dv.h',
84         'mlx5dv_create_flow_action_packet_reformat' ],
85         [ 'HAVE_IBV_DEVICE_MPLS_SUPPORT', 'infiniband/verbs.h',
86         'IBV_FLOW_SPEC_MPLS' ],
87         [ 'HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING', 'infiniband/verbs.h',
88         'IBV_WQ_FLAGS_PCI_WRITE_END_PADDING' ],
89         [ 'HAVE_IBV_WQ_FLAG_RX_END_PADDING', 'infiniband/verbs.h',
90         'IBV_WQ_FLAG_RX_END_PADDING' ],
91         [ 'HAVE_MLX5DV_DR_DEVX_PORT', 'infiniband/mlx5dv.h',
92         'mlx5dv_query_devx_port' ],
93         [ 'HAVE_IBV_DEVX_OBJ', 'infiniband/mlx5dv.h',
94         'mlx5dv_devx_obj_create' ],
95         [ 'HAVE_IBV_FLOW_DEVX_COUNTERS', 'infiniband/mlx5dv.h',
96         'MLX5DV_FLOW_ACTION_COUNTERS_DEVX' ],
97         [ 'HAVE_IBV_DEVX_ASYNC', 'infiniband/mlx5dv.h',
98         'mlx5dv_devx_obj_query_async' ],
99         [ 'HAVE_IBV_DEVX_QP', 'infiniband/mlx5dv.h',
100         'mlx5dv_devx_qp_query' ],
101         [ 'HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR', 'infiniband/mlx5dv.h',
102         'mlx5dv_dr_action_create_dest_devx_tir' ],
103         [ 'HAVE_IBV_DEVX_EVENT', 'infiniband/mlx5dv.h',
104         'mlx5dv_devx_get_event' ],
105         [ 'HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER', 'infiniband/mlx5dv.h',
106         'mlx5dv_dr_action_create_flow_meter' ],
107         [ 'HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD', 'infiniband/mlx5dv.h',
108         'MLX5_MMAP_GET_NC_PAGES_CMD' ],
109         [ 'HAVE_MLX5DV_DR', 'infiniband/mlx5dv.h',
110         'MLX5DV_DR_DOMAIN_TYPE_NIC_RX' ],
111         [ 'HAVE_MLX5DV_DR_ESWITCH', 'infiniband/mlx5dv.h',
112         'MLX5DV_DR_DOMAIN_TYPE_FDB' ],
113         [ 'HAVE_MLX5DV_DR_VLAN', 'infiniband/mlx5dv.h',
114         'mlx5dv_dr_action_create_push_vlan' ],
115         [ 'HAVE_IBV_VAR', 'infiniband/mlx5dv.h', 'mlx5dv_alloc_var' ],
116         [ 'HAVE_SUPPORTED_40000baseKR4_Full', 'linux/ethtool.h',
117         'SUPPORTED_40000baseKR4_Full' ],
118         [ 'HAVE_SUPPORTED_40000baseCR4_Full', 'linux/ethtool.h',
119         'SUPPORTED_40000baseCR4_Full' ],
120         [ 'HAVE_SUPPORTED_40000baseSR4_Full', 'linux/ethtool.h',
121         'SUPPORTED_40000baseSR4_Full' ],
122         [ 'HAVE_SUPPORTED_40000baseLR4_Full', 'linux/ethtool.h',
123         'SUPPORTED_40000baseLR4_Full' ],
124         [ 'HAVE_SUPPORTED_56000baseKR4_Full', 'linux/ethtool.h',
125         'SUPPORTED_56000baseKR4_Full' ],
126         [ 'HAVE_SUPPORTED_56000baseCR4_Full', 'linux/ethtool.h',
127         'SUPPORTED_56000baseCR4_Full' ],
128         [ 'HAVE_SUPPORTED_56000baseSR4_Full', 'linux/ethtool.h',
129         'SUPPORTED_56000baseSR4_Full' ],
130         [ 'HAVE_SUPPORTED_56000baseLR4_Full', 'linux/ethtool.h',
131         'SUPPORTED_56000baseLR4_Full' ],
132         [ 'HAVE_ETHTOOL_LINK_MODE_25G', 'linux/ethtool.h',
133         'ETHTOOL_LINK_MODE_25000baseCR_Full_BIT' ],
134         [ 'HAVE_ETHTOOL_LINK_MODE_50G', 'linux/ethtool.h',
135         'ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT' ],
136         [ 'HAVE_ETHTOOL_LINK_MODE_100G', 'linux/ethtool.h',
137         'ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT' ],
138         [ 'HAVE_IFLA_NUM_VF', 'linux/if_link.h',
139         'IFLA_NUM_VF' ],
140         [ 'HAVE_IFLA_EXT_MASK', 'linux/if_link.h',
141         'IFLA_EXT_MASK' ],
142         [ 'HAVE_IFLA_PHYS_SWITCH_ID', 'linux/if_link.h',
143         'IFLA_PHYS_SWITCH_ID' ],
144         [ 'HAVE_IFLA_PHYS_PORT_NAME', 'linux/if_link.h',
145         'IFLA_PHYS_PORT_NAME' ],
146         [ 'HAVE_RDMA_NL_NLDEV', 'rdma/rdma_netlink.h',
147         'RDMA_NL_NLDEV' ],
148         [ 'HAVE_RDMA_NLDEV_CMD_GET', 'rdma/rdma_netlink.h',
149         'RDMA_NLDEV_CMD_GET' ],
150         [ 'HAVE_RDMA_NLDEV_CMD_PORT_GET', 'rdma/rdma_netlink.h',
151         'RDMA_NLDEV_CMD_PORT_GET' ],
152         [ 'HAVE_RDMA_NLDEV_ATTR_DEV_INDEX', 'rdma/rdma_netlink.h',
153         'RDMA_NLDEV_ATTR_DEV_INDEX' ],
154         [ 'HAVE_RDMA_NLDEV_ATTR_DEV_NAME', 'rdma/rdma_netlink.h',
155         'RDMA_NLDEV_ATTR_DEV_NAME' ],
156         [ 'HAVE_RDMA_NLDEV_ATTR_PORT_INDEX', 'rdma/rdma_netlink.h',
157         'RDMA_NLDEV_ATTR_PORT_INDEX' ],
158         [ 'HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX', 'rdma/rdma_netlink.h',
159         'RDMA_NLDEV_ATTR_NDEV_INDEX' ],
160         [ 'HAVE_MLX5_DR_FLOW_DUMP', 'infiniband/mlx5dv.h',
161         'mlx5dv_dump_dr_domain'],
162         [ 'HAVE_DEVLINK', 'linux/devlink.h', 'DEVLINK_GENL_NAME' ],
163 ]
164 config = configuration_data()
165 foreach arg:has_sym_args
166         config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
167                 dependencies: libs))
168 endforeach
169 foreach arg:has_member_args
170         file_prefix = '#include <' + arg[1] + '>'
171         config.set(arg[0], cc.has_member(arg[2], arg[3],
172                 prefix : file_prefix, dependencies: libs))
173 endforeach
174 configure_file(output : 'mlx5_autoconf.h', configuration : config)
175
176 # Build Glue Library
177 if dlopen_ibverbs
178         dlopen_name = 'mlx5_glue'
179         dlopen_lib_name = 'rte_pmd_@0@'.format(dlopen_name)
180         dlopen_so_version = LIB_GLUE_VERSION
181         dlopen_sources = files('mlx5_glue.c')
182         dlopen_install_dir = [ eal_pmd_path + '-glue' ]
183         dlopen_includes = [global_inc]
184         dlopen_includes += include_directories(
185                 '../../../../lib/librte_eal/include/generic',
186         )
187         shared_lib = shared_library(
188                 dlopen_lib_name,
189                 dlopen_sources,
190                 include_directories: dlopen_includes,
191                 c_args: cflags,
192                 dependencies: libs,
193                 link_args: [
194                 '-Wl,-export-dynamic',
195                 '-Wl,-h,@0@'.format(LIB_GLUE),
196                 ],
197                 soversion: dlopen_so_version,
198                 install: true,
199                 install_dir: dlopen_install_dir,
200         )
201 endif