Skip to content

Commit ed83cf4

Browse files
committed
libnvme: make fabrics optional
The fabrics part is rather large and usually is not necessary for embedded use cases. Also it is very Linux specific and makes any porting attempts really hard. Thus make the fabrics part optional. Signed-off-by: Daniel Wagner <[email protected]>
1 parent ef2df88 commit ed83cf4

9 files changed

Lines changed: 100 additions & 119 deletions

File tree

libnvme/examples/meson.build

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,17 @@ executable(
3535
],
3636
)
3737

38-
executable(
39-
'discover-loop',
40-
['discover-loop.c'],
41-
dependencies: [
42-
config_dep,
43-
ccan_dep,
44-
libnvme_dep,
45-
],
46-
)
38+
if want_fabrics
39+
executable(
40+
'discover-loop',
41+
['discover-loop.c'],
42+
dependencies: [
43+
config_dep,
44+
ccan_dep,
45+
libnvme_dep,
46+
],
47+
)
48+
endif
4749

4850
executable(
4951
'mi-mctp',
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extern "C" {
1515
#endif
1616

1717
#include <nvme/cmds.h>
18-
#include <nvme/fabrics.h>
18+
@FABRICS_INCLUDE@
1919
#include <nvme/filters.h>
2020
#include <nvme/ioctl.h>
2121
#include <nvme/lib-types.h>

libnvme/src/libnvme.ld

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -270,70 +270,6 @@ LIBNVME_3 {
270270
nvme_uuid_from_string;
271271
nvme_uuid_random;
272272
nvme_uuid_to_string;
273-
nvmf_add_ctrl;
274-
nvmf_adrfam_str;
275-
nvmf_cms_str;
276-
nvmf_config_modify;
277-
nvmf_connect;
278-
nvmf_connect_config_json;
279-
nvmf_connect_ctrl;
280-
nvmf_context_create;
281-
nvmf_context_set_connection;
282-
nvmf_context_set_crypto;
283-
nvmf_context_set_device;
284-
nvmf_context_set_discovery_cbs;
285-
nvmf_context_set_discovery_defaults;
286-
nvmf_context_set_fabrics_config;
287-
nvmf_context_set_hostnqn;
288-
nvmf_context_set_persistent;
289-
nvmf_default_config;
290-
nvmf_discovery;
291-
nvmf_discovery_config_file;
292-
nvmf_discovery_config_json;
293-
nvmf_discovery_ctx_already_connected_set;
294-
nvmf_discovery_ctx_connected_set;
295-
nvmf_discovery_ctx_create;
296-
nvmf_discovery_ctx_ctrlkey_set;
297-
nvmf_discovery_ctx_decide_retry_set;
298-
nvmf_discovery_ctx_default_fabrics_config_set;
299-
nvmf_discovery_ctx_device_set;
300-
nvmf_discovery_ctx_discovery_log_set;
301-
nvmf_discovery_ctx_host_iface_set;
302-
nvmf_discovery_ctx_host_traddr_set;
303-
nvmf_discovery_ctx_hostid_set;
304-
nvmf_discovery_ctx_hostkey_set;
305-
nvmf_discovery_ctx_hostnqn_set;
306-
nvmf_discovery_ctx_keep_alive_timeout;
307-
nvmf_discovery_ctx_keyring_set;
308-
nvmf_discovery_ctx_max_retries;
309-
nvmf_discovery_ctx_parser_cleanup_set;
310-
nvmf_discovery_ctx_parser_init_set;
311-
nvmf_discovery_ctx_parser_next_line_set;
312-
nvmf_discovery_ctx_persistent_set;
313-
nvmf_discovery_ctx_subsysnqn_set;
314-
nvmf_discovery_ctx_tls_key_identity_set;
315-
nvmf_discovery_ctx_tls_key_set;
316-
nvmf_discovery_ctx_traddr_set;
317-
nvmf_discovery_ctx_transport_set;
318-
nvmf_discovery_ctx_trsvcid_set;
319-
nvmf_discovery_nbft;
320-
nvmf_eflags_str;
321-
nvmf_exat_ptr_next;
322-
nvmf_free_uri;
323-
nvmf_get_default_trsvcid;
324-
nvmf_get_discovery_log;
325-
nvmf_get_discovery_wargs;
326-
nvmf_is_registration_supported;
327-
nvmf_nbft_free;
328-
nvmf_nbft_read_files;
329-
nvmf_prtype_str;
330-
nvmf_qptype_str;
331-
nvmf_register_ctrl;
332-
nvmf_sectype_str;
333-
nvmf_subtype_str;
334-
nvmf_treq_str;
335-
nvmf_trtype_str;
336-
nvmf_update_config;
337273
local:
338274
*;
339275
};

libnvme/src/meson.build

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ sources = [
99
'nvme/base64.c',
1010
'nvme/cmds.c',
1111
'nvme/crc32.c',
12-
'nvme/fabrics.c',
1312
'nvme/filters.c',
1413
'nvme/ioctl.c',
1514
'nvme/lib.c',
@@ -22,6 +21,28 @@ sources = [
2221
'nvme/tree.c',
2322
'nvme/util.c',
2423
]
24+
headers = [
25+
'nvme/cmds.h',
26+
'nvme/filters.h',
27+
'nvme/ioctl.h',
28+
'nvme/lib-types.h',
29+
'nvme/lib.h',
30+
'nvme/linux.h',
31+
'nvme/mi.h',
32+
'nvme/nbft.h',
33+
'nvme/tree.h',
34+
'nvme/types.h',
35+
'nvme/util.h',
36+
]
37+
38+
if want_fabrics
39+
sources += [
40+
'nvme/fabrics.c',
41+
]
42+
headers += [
43+
'nvme/fabrics.h',
44+
]
45+
endif
2546

2647
if json_c_dep.found()
2748
sources += 'nvme/json.c'
@@ -43,16 +64,35 @@ deps = [
4364
accessors_dep,
4465
]
4566

46-
ldfile = 'libnvme.ld'
67+
nvme_ld = meson.current_source_dir() / 'libnvme.ld'
68+
nvmf_ld = meson.current_source_dir() / 'libnvmf.ld'
69+
70+
link_args = [
71+
'-Wl,--version-script=@0@'.format(nvme_ld),
72+
'-Wl,--version-script=@0@'.format(accessors_ld_full_path),
73+
]
74+
75+
libconf = configuration_data()
76+
if want_fabrics
77+
link_args += '-Wl,--version-script=@0@'.format(nvmf_ld)
78+
libconf.set('FABRICS_INCLUDE', '#include <nvme/fabrics.h>')
79+
else
80+
libconf.set('FABRICS_INCLUDE', '')
81+
endif
82+
83+
libnvme_header = configure_file(
84+
input: 'libnvme.h.in',
85+
output: 'libnvme.h',
86+
configuration: libconf,
87+
install: true,
88+
install_dir: prefixdir / get_option('includedir') / 'nvme'
89+
)
4790

4891
libnvme = library(
4992
'nvme', # produces libnvme.so
5093
sources,
5194
version: libnvme_so_version,
52-
link_args: [
53-
'-Wl,--version-script=@0@'.format(meson.current_source_dir() / ldfile),
54-
'-Wl,--version-script=@0@'.format(accessors_ld_full_path),
55-
],
95+
link_args: link_args,
5696
dependencies: deps,
5797
install: true,
5898
)
@@ -91,26 +131,12 @@ libnvme_test_dep = declare_dependency(
91131
mode = 'rw-r--r--'
92132
install_headers(
93133
[
94-
'libnvme.h',
95134
'libnvme-mi.h',
96135
],
97136
install_mode: mode,
98137
)
99138
install_headers(
100-
[
101-
'nvme/cmds.h',
102-
'nvme/fabrics.h',
103-
'nvme/filters.h',
104-
'nvme/ioctl.h',
105-
'nvme/lib-types.h',
106-
'nvme/lib.h',
107-
'nvme/linux.h',
108-
'nvme/mi.h',
109-
'nvme/nbft.h',
110-
'nvme/tree.h',
111-
'nvme/types.h',
112-
'nvme/util.h',
113-
],
139+
headers,
114140
subdir: 'nvme',
115141
install_mode: mode,
116142
)

libnvme/src/nvme/tree.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,10 @@ int nvme_create_ctrl(struct nvme_global_ctx *ctx,
13891389

13901390
c->ctx = ctx;
13911391
c->hdl = NULL;
1392+
#ifdef CONFIG_FABRICS
1393+
// XXX it's necessary to initialize the defaults...
13921394
nvmf_default_config(&c->cfg);
1395+
#endif // !CONFIG_FABRICS
13931396
list_head_init(&c->namespaces);
13941397
list_head_init(&c->paths);
13951398
list_node_init(&c->entry);

libnvme/test/ioctl/meson.build

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,19 @@ ana = executable(
5252
)
5353
test('libnvme - ana', ana, env: mock_ioctl_env)
5454

55-
discovery = executable(
56-
'test-discovery',
57-
'discovery.c',
58-
dependencies: [
59-
config_dep,
60-
ccan_dep,
61-
libnvme_dep,
62-
],
63-
link_with: mock_ioctl,
64-
)
65-
test('libnvme - discovery', discovery, env: mock_ioctl_env)
55+
if want_fabrics
56+
discovery = executable(
57+
'test-discovery',
58+
'discovery.c',
59+
dependencies: [
60+
config_dep,
61+
ccan_dep,
62+
libnvme_dep,
63+
],
64+
link_with: mock_ioctl,
65+
)
66+
test('libnvme - discovery', discovery, env: mock_ioctl_env)
67+
endif
6668

6769
features = executable(
6870
'test-features',

libnvme/test/meson.build

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,19 @@ uuid = executable(
101101

102102
test('libnvme - uuid', uuid)
103103

104-
uriparser = executable(
105-
'test-uriparser',
106-
['uriparser.c'],
107-
dependencies: [
108-
config_dep,
109-
ccan_dep,
110-
libnvme_dep,
111-
],
112-
)
104+
if want_fabrics
105+
uriparser = executable(
106+
'test-uriparser',
107+
['uriparser.c'],
108+
dependencies: [
109+
config_dep,
110+
ccan_dep,
111+
libnvme_dep,
112+
],
113+
)
113114

114115
test('libnvme - uriparser', uriparser)
116+
endif
115117

116118
if conf.get('HAVE_NETDB')
117119
mock_ifaddrs = library(

meson.build

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ cxx_available = add_languages('cpp', required: false, native: false)
5151
# dependencies are present. Also, -Dpython=enabled forces -Dlibnvme=enabled.
5252
want_nvme = get_option('nvme').disabled() == false
5353
want_libnvme = get_option('libnvme').disabled() == false
54+
want_fabrics = get_option('fabrics').disabled() == false
5455
want_docs = get_option('docs')
5556
want_docs_build = get_option('docs-build')
5657

@@ -128,6 +129,8 @@ endif
128129
conf.set('SYSCONFDIR', '"@0@"'.format(sysconfdir))
129130
conf.set('RUNDIR', '"@0@"'.format(rundir))
130131

132+
conf.set('CONFIG_FABRICS', want_fabrics, description: 'Is fabrics enabled')
133+
131134
# Check for libjson-c availability
132135
if get_option('json-c').disabled()
133136
json_c_dep = dependency('', required: false)
@@ -277,14 +280,14 @@ else
277280
endif
278281

279282

280-
if get_option('liburing').disabled()
283+
if not want_fabrics or get_option('liburing').disabled()
281284
liburing_dep = dependency('', required: false)
282285
else
283286
liburing_dep = dependency('liburing', version: '>=2.2', required: get_option('liburing'))
284287
endif
285288
conf.set('CONFIG_LIBURING', liburing_dep.found(), description: 'Is liburing available?')
286289

287-
if get_option('openssl').disabled()
290+
if not want_fabrics or get_option('openssl').disabled()
288291
openssl_dep = dependency('', required: false)
289292
else
290293
openssl_dep = dependency(
@@ -313,14 +316,14 @@ if openssl_dep.found()
313316
endif
314317
conf.set('CONFIG_OPENSSL', openssl_dep.found(), description: 'Is OpenSSL/LibreSSL available?')
315318

316-
if get_option('keyutils').disabled()
319+
if not want_fabrics or get_option('keyutils').disabled()
317320
keyutils_dep = dependency('', required: false)
318321
else
319322
keyutils_dep = dependency('libkeyutils', required : get_option('keyutils'))
320323
endif
321324
conf.set('CONFIG_KEYUTILS', keyutils_dep.found(), description: 'Is libkeyutils available?')
322325

323-
if get_option('libdbus').disabled()
326+
if not want_fabrics or get_option('libdbus').disabled()
324327
libdbus_dep = dependency('', required: false)
325328
else
326329
# Check for libdbus availability. Optional, only required for MCTP dbus scan
@@ -630,6 +633,7 @@ summary(dep_dict, section: 'Dependencies', bool_yn: true)
630633
wanted_dict = {
631634
'nvme': want_nvme,
632635
'libnvme': want_libnvme,
636+
'fabrics': want_fabrics,
633637
'python bindings ': want_python,
634638
'build docs': want_docs_build,
635639
}

meson_options.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ option(
1111
value: 'enabled',
1212
description: 'Build libnvme library'
1313
)
14+
option(
15+
'fabrics',
16+
type : 'feature',
17+
value: 'enabled',
18+
description : 'NVMeoF support'
19+
)
1420
option(
1521
'python',
1622
type : 'feature',

0 commit comments

Comments
 (0)