pcie-bifurcation: Pass configuration file path Summary: On systems with detachable HPMs, there are different system setups where not all HPMs may be present. We shouldn't be checking the bifurcation on missing HPMs as this will generate unused mappings, and this process may potentially fail to store the generated files for a missing HPM if the related directory doesn't exist. Provide an option to pass the configuration file path. Google-Bug-Id: 409831464 Change-Id: Ibac867f0ed82c9db4da119d5bf9c5e39f94ba367 Signed-off-by: Kyle Nieman <kyle.nieman@fii-na.corp-partner.google.com>
diff --git a/fru/main.cpp b/fru/main.cpp index 82e46ff..02c3af2 100644 --- a/fru/main.cpp +++ b/fru/main.cpp
@@ -1,22 +1,34 @@ #include "pcie_bifurcation.hpp" #include "pcie_bifurcation_server_3.hpp" +#ifdef BASE_PCIE_BIFURCATION +#include <CLI/CLI.hpp> +#endif + #include <iostream> #include <string_view> // Placeholder path -constexpr std::string_view pcieConfigFilePath = +constexpr std::string_view DEFAULT_CONFIG_FILE = "/usr/share/pcie-bifurcation/configFile.json"; -int main() +int main(int argc, char* argv[]) { #ifdef BASE_PCIE_BIFURCATION + CLI::App app("PCIe Bifurcation Daemon"); + std::string pcieConfigFilePath{DEFAULT_CONFIG_FILE}; + app.add_option("-f,--file", pcieConfigFilePath, + "Configuration file defining the I2C EEPROMs containing the " + "bifurcation information.\n" + "By default, /usr/share/pcie-bifurcation/configFile.json"); + CLI11_PARSE(app, argc, argv); + google::pcie_bifurcation::PCIeBifurcation pcieBifurcation( pcieConfigFilePath); std::cout << "Using base PCIeBifurcation implementation\n"; #else google::pcie_bifurcation::Server3PcieBifurcation pcieBifurcation( - pcieConfigFilePath); + DEFAULT_CONFIG_FILE); std::cout << "Using Server3PcieBifurcation implementation\n"; #endif
diff --git a/meson.build b/meson.build index 3138663..dc1a1c3 100644 --- a/meson.build +++ b/meson.build
@@ -21,6 +21,7 @@ sdbusplus_dep, meson.get_compiler('cpp').find_library('i2c'), nlohmann_json, + dependency('CLI11'), ] if get_option('fru').allowed()