blob: ab67e14926b04bee006269e6531bd3916c16ec05 [file]
project(
'libnsm',
['c', 'cpp'],
version: '0.1',
meson_version: '>=1.1.1',
default_options: ['warning_level=3', 'werror=true', 'cpp_std=c++23'],
)
# Enable support for the C++ coroutines extension
add_project_arguments('-fcoroutines', language: ['cpp'])
nlohmann_json = dependency('nlohmann_json')
sdbusplus = dependency('sdbusplus')
sdeventplus = dependency('sdeventplus')
phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
phosphor_logging = dependency('phosphor-logging')
tests_cpp_args = []
if get_option('tests').enabled()
gtest = dependency(
'gtest',
main: true,
disabler: true,
required: false,
version: '>=1.14.0',
)
gmock = dependency('gmock', disabler: true, required: false)
if not gtest.found() or not gmock.found()
googletest = import('cmake').subproject('googletest', required: true)
gtest = declare_dependency(
dependencies: [
googletest.get_variable('gtest_dep'),
googletest.get_variable('gtest_main_dep'),
],
)
gmock = googletest.get_variable('gmock_dep')
endif
gtest = gtest.as_system('system')
gmock = gmock.as_system('system')
# Mocking coroutines for building coverage reports
if get_option('b_coverage')
tests_cpp_args = [
'-DCOVERAGE_DISABLE_COROUTINES',
'-Dco_return=return',
'-Dco_await=',
]
endif
endif
if get_option('system-guid').enabled()
add_project_arguments('-DENABLE_SYSTEM_GUID', language: ['cpp', 'c'])
endif
if get_option('grace-spi-operations').enabled()
add_project_arguments(
'-DENABLE_GRACE_SPI_OPERATIONS',
language: ['cpp', 'c'],
)
endif
if get_option('grace-spi-operations-raw-debug-dump').enabled()
add_project_arguments(
'-DENABLE_GRACE_SPI_OPERATION_RAW_DEBUG_DUMP',
language: ['cpp', 'c'],
)
endif
cpp = meson.get_compiler('cpp')
if cpp.has_header('CLI/CLI.hpp')
CLI11_dep = declare_dependency()
else
CLI11_dep = dependency('CLI11')
endif
conf_data = configuration_data()
conf_data.set('SENSOR_POLLING_TIME', get_option('sensor-polling-time'))
conf_data.set('SENSOR_POLLING_TIME_GPM', get_option('sensor-polling-time-gpm'))
conf_data.set(
'DEVICE_UPDATE_POST_PATCH_SLEEP_MS',
get_option('device-update-post-patch-sleep'),
)
conf_data.set(
'DEVICE_UPDATE_POST_PATCH_SLEEP_MAX_ITER',
get_option('device-update-post-patch-sleep-iteration'),
)
conf_data.set('GPU_PWR_GD_GPIO', '"' + get_option('gpio-name') + '"')
conf_data.set(
'SENSOR_POLLING_TIME_LONG_RUNNING',
get_option('sensor-polling-time-long-running'),
)
conf_data.set('NUM_GPU_PER_MODULE', get_option('num-gpu-per-module'))
conf_data.set(
'INSTANCE_ID_EXPIRATION_INTERVAL',
get_option('instance-id-expiration-interval'),
)
conf_data.set(
'NUMBER_OF_REQUEST_RETRIES',
get_option('number-of-request-retries'),
)
conf_data.set(
'SENSOR_PROGRESS_COUNTERS_DUMP_COUNT_THRESHOLD',
get_option('sensor-progress-counters-dump-count-threshold'),
)
conf_data.set(
'SENSOR_PROGRESS_COUNTERS_DUMP_TIME_THRESHOLD',
get_option('sensor-progress-counters-dump-time-threshold'),
)
conf_data.set(
'SENSOR_PROGRESS_COUNTERS_MEMFD_SIZE',
get_option('sensor-progress-counters-memfd-size'),
)
conf_data.set(
'DISCOVERY_PROGRESS_COUNTERS_MEMFD_SIZE',
get_option('discovery-progress-counters-memfd-size'),
)
conf_data.set('RESPONSE_TIME_OUT', get_option('response-time-out'))
conf_data.set('MCTP_SEND_TIMEOUT_MS', get_option('mctp-send-timeout'))
conf_data.set(
'RESPONSE_TIME_OUT_LONG_RUNNING',
get_option('response-time-out-long-running'),
)
conf_data.set('DEFAULT_RR_REFRESH_LIMIT_IN_MS', get_option('rr-refresh-limit'))
conf_data.set(
'ALLOWED_BUFFER_IN_MS',
get_option('allowed-buffer-in-ms-for-polling'),
)
conf_data.set(
'INACTIVE_SLEEP_TIME_IN_MS',
get_option('inactive-sleep-time-in-ms'),
)
if get_option('progressCounter').enabled()
conf_data.set('NVIDIA_PROGRESS_COUNTER', 0)
endif
if get_option('stanbyToDC').enabled()
conf_data.set('NVIDIA_STANDBYTODC', 0)
endif
if get_option('reset-metrics').enabled()
conf_data.set('NVIDIA_RESET_METRICS', 0)
endif
cx8_features = get_option('cx8-features')
if get_option('shmem').enabled() and not cx8_features
conf_data.set('NVIDIA_SHMEM', 0)
endif
if get_option('enable-histogram').enabled()
# FEC histogram is supported on CX devices (CX9+, and CX8 per-platform), so it
# must be available even on cx8-features builds. The heavier histograms stay
# gated behind NVIDIA_HISTOGRAM (disabled under cx8-features to keep the image slim).
conf_data.set('NVIDIA_FEC_HISTOGRAM', 1)
if not cx8_features
conf_data.set('NVIDIA_HISTOGRAM', 1)
endif
endif
if get_option('enable-debug-token').enabled() and not cx8_features
add_project_arguments('-DENABLE_DEBUG_TOKEN', language: ['cpp', 'c'])
endif
if get_option('nvidia-manager-ready-csm').enabled()
add_project_arguments(
'-DNVIDIA_MANAGER_READY_CSM',
language: ['cpp'],
)
endif
if get_option('enable-debug-info').enabled() and not cx8_features
add_project_arguments('-DENABLE_DEBUG_INFO', language: ['cpp', 'c'])
endif
conf_data.set10(
'NETIR_DUMP_ENABLED',
get_option('enable-netir-dump').enabled(),
)
conf_data.set10(
'DIAGNOSTIC_DUMP_ENABLED',
get_option('enable-diagnostic-dump').enabled(),
)
if get_option('enable-network-adapter-reset').enabled() and not cx8_features
add_project_arguments(
'-DENABLE_NETWORK_ADAPTER_RESET',
language: ['cpp', 'c'],
)
endif
if get_option('enable-network-adapter-protection-option').enabled() or cx8_features
add_project_arguments(
'-DENABLE_NETWORK_ADAPTER_PROTECTION_OPTION',
language: ['cpp', 'c'],
)
endif
if get_option('enable-association-discovery').enabled()
add_project_arguments(
'-DENABLE_ASSOCIATION_DISCOVERY',
language: ['cpp', 'c'],
)
endif
if get_option('enable-event-gpu-uuid-label').enabled()
add_project_arguments('-DENABLE_EVENT_GPU_UUID_LABEL', language: ['cpp'])
endif
if get_option('enable-pcie-aer-error').enabled() and not cx8_features
add_project_arguments('-DENABLE_PCIE_AER_ERROR', language: ['cpp', 'c'])
endif
if get_option('enable-clock-output-state').enabled() and not cx8_features
add_project_arguments('-DENABLE_CLOCK_OUTPUT_STATE', language: ['cpp', 'c'])
endif
if get_option('enable-pcie-ltssm-state').enabled() and not cx8_features
add_project_arguments('-DENABLE_PCIE_LTSSM_STATE', language: ['cpp', 'c'])
endif
effective_sensors_all = get_option('nsm-sensors-all')
if cx8_features
effective_sensors_all = false
endif
if (get_option('enable-error-injection').enabled() and not cx8_features) or get_option(
'nsm-sensors-include',
).contains(
'error-injection',
) or effective_sensors_all
add_project_arguments('-DENABLE_ERROR_INJECTION', language: ['cpp', 'c'])
endif
if get_option('aer-error-status-priority')
conf_data.set('AER_ERR_SENSOR_PRIORITY', 1)
else
conf_data.set('AER_ERR_SENSOR_PRIORITY', 0)
endif
if get_option('per-lan-error-count-priority')
conf_data.set('PER_LANE_ERROR_COUNT_PRIORITY', 1)
else
conf_data.set('PER_LANE_ERROR_COUNT_PRIORITY', 0)
endif
if get_option('error-injection-priority')
conf_data.set('ERROR_INJECTION_PRIORITY', 1)
else
conf_data.set('ERROR_INJECTION_PRIORITY', 0)
endif
if get_option('confidential-compute-mode')
conf_data.set('CONFIDENTIAL_COMPUTE_MODE_PRIORITY', 1)
endif
if get_option('confidential-compute-devtool-mode')
conf_data.set('CONFIDENTIAL_COMPUTE_DEVTOOL_MODE_PRIORITY', 1)
endif
if get_option('accelerator-dbus').allowed()
conf_data.set('ACCELERATOR_DBUS', 0)
endif
if get_option('tracing').enabled() and get_option('tests').enabled()
error(
'Cannot enable both features "tracing" and "tests" at a time. Please disable one of them.',
)
endif
if get_option('tracing').enabled()
summary('tracing', '-DLTTNG_TRACING', section: 'Enabled Tracing')
conf_data.set('LTTNG_TRACING', 1)
liblttng = dependency('lttng-ust', required: true)
ldl = dependency('dl', required: true)
endif
conf_data.set('LOCAL_EID', get_option('local-eid'))
if get_option('enable-in-kernel-mctp').enabled()
conf_data.set('MCTP_IN_KERNEL', 0)
endif
conf_data.set(
'DELAY_BETWEEN_CONCURRENT_REQUESTS',
get_option('delay-between-concurrent-requests'),
)
if get_option('fixup-missing-event-notification').enabled()
conf_data.set('FIXUP_MISSING_EVENT_NOTIFICATION', 1)
endif
if get_option('nvidia-fpga-pcie-reference-clock-count').enabled()
add_project_arguments(
'-DNVIDIA_FPGA_PCIE_REFERENCE_CLOCK_COUNT',
language: ['cpp', 'c'],
)
endif
if get_option('mctp-eid-filtering')
add_project_arguments('-DFILTER_MCTP_EID=true', language: ['cpp', 'c'])
else
add_project_arguments('-DFILTER_MCTP_EID=false', language: ['cpp', 'c'])
endif
nsm_port_all = get_option('nsm-port-all')
nsm_port_include = get_option('nsm-port-include')
if cx8_features
nsm_port_all = false
endif
if nsm_port_all or nsm_port_include.contains('lldp')
add_project_arguments('-DENABLE_LLDP', language: ['cpp'])
endif
conf_data.set('MCTP_EID_TO_FILTER', get_option('mctp-eid-to-filter'))
configure_file(output: 'config.h', configuration: conf_data)
add_project_arguments(
'-include',
join_paths(meson.current_build_dir(), 'config.h'),
language: ['c', 'cpp'],
)
#
# Retry backoff configuration (single, unambiguous array option: [maxRetries, delayMs])
#
retry_backoff = get_option('retry-backoff')
if retry_backoff.length() != 2
error('retry-backoff must have exactly two items: [maxRetries, delayMs]')
endif
max_retries = retry_backoff[0].to_int()
delay_ms = retry_backoff[1].to_int()
if max_retries < 0 or max_retries > 255
error('retry-backoff: maxRetries must be 0..255')
endif
if delay_ms < 1 or delay_ms > 4294967295
error('retry-backoff: delayMs must be 1..4294967295')
endif
retry_conf = configuration_data()
retry_conf.set('RETRY_BACKOFF_MAX_RETRIES', max_retries)
retry_conf.set('RETRY_BACKOFF_DELAY_MS', delay_ms)
configure_file(output: 'retry_backoff_config.h', configuration: retry_conf)
add_project_arguments(
'-include',
join_paths(meson.current_build_dir(), 'retry_backoff_config.h'),
language: ['c', 'cpp'],
)
openssl_dep = dependency('openssl', required: true)
dynamic_linker = []
deps = [
CLI11_dep,
nlohmann_json,
sdbusplus,
sdeventplus,
phosphor_dbus_interfaces,
phosphor_logging,
openssl_dep,
]
if get_option('shmem').enabled() and not cx8_features
nvidia_shmem = dependency('nvidia-tal', required: true)
deps += nvidia_shmem
endif
systemd = dependency('systemd')
systemd_system_unit_dir = systemd.get_variable(pkgconfig: 'systemdsystemunitdir')
# Build libnsm static library first (used by nsmtool, mockupResponder)
subdir('libnsm')
subdir('services')
subdir('nsmtool')
subdir('nsmd')
if get_option('mockup-responder').enabled()
subdir('mockupResponder')
endif
if get_option('tests').enabled()
subdir('common/test')
subdir('debug-token/test')
subdir('libnsm/test')
subdir('mockupResponder/test')
subdir('nsmtool/test')
subdir('dot/test')
endif