diff --git a/CMakeLists.txt b/CMakeLists.txt index dbd274b6..2e351e39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -684,6 +684,15 @@ if(DEVOURER_KESTREL) target_include_directories(kestrelprobe PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/common) endif() +# cellcaps — print the AdapterCaps that gate a cell node (USB or, with +# DEVOURER_PCIE, vfio PCIe). examples/common/radio_open.h selects the radio; +# a POSIX bench tool (libusb + _exit), like the other radio_open probes. +if(NOT WIN32) + add_executable(cellcaps examples/cellcaps/main.cpp examples/common/env_config.cpp) + target_link_libraries(cellcaps PUBLIC devourer PRIVATE PkgConfig::libusb) + target_include_directories(cellcaps PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/common) +endif() + # rtl8733bprobe — staged USB bring-up prober for the RTL8733B (HALMAC 87xx), # the pcieprobe/kestrelprobe sibling: identity -> power-on + EFUSE -> firmware # -> MAC/PHY -> TSSI audit stages, used alongside normal factory dispatch. It diff --git a/examples/cell/main.cpp b/examples/cell/main.cpp index 7a7ceb7e..bc3d53bb 100644 --- a/examples/cell/main.cpp +++ b/examples/cell/main.cpp @@ -273,6 +273,7 @@ #include "cell/LinkAdapt.h" #include "cell/SlotGrid.h" #include "logger.h" +#include "cell_caps.h" #include "radio_open.h" #include "cell/CellScheduler.h" #include "cell/ChannelSwitch.h" @@ -564,7 +565,7 @@ int64_t sleep_until_tsf(IRadio *dev, int64_t target) { bool caps_ok(IRadio *dev) { const auto c = dev->GetAdapterCaps(); - if (!c.tsf_write_ok || !c.tbtt_follows_tsf || !c.beacon_backoff_ctl || !c.hw_beacon_txtsf) { + if (!devourer::cell_node_caps_ok(c)) { fprintf(stderr, "this radio cannot run a cell node (tsf_write_ok=%d tbtt_follows_tsf=%d " "beacon_backoff_ctl=%d hw_beacon_txtsf=%d)\n", c.tsf_write_ok, c.tbtt_follows_tsf, c.beacon_backoff_ctl, c.hw_beacon_txtsf); diff --git a/examples/cellcaps/main.cpp b/examples/cellcaps/main.cpp new file mode 100644 index 00000000..37c8e3b7 --- /dev/null +++ b/examples/cellcaps/main.cpp @@ -0,0 +1,28 @@ +/* cellcaps — open the radio named in the environment (USB via DEVOURER_VID/ + * PID, or PCIe via DEVOURER_PCIE_BDF) and print the AdapterCaps that decide + * whether it can run a cell node (examples/cell caps_ok), as JSON. Read-only + * beyond the normal bring-up the open path does; no beacon, no TX. */ +#include +#include + +#include "cell_caps.h" +#include "radio_open.h" + +int main() { + auto logger = std::make_shared(); + OpenedRadio radio = open_radio_from_env(logger, 0x0bda, 0); + if (!radio.dev) { + fprintf(stderr, "cellcaps: open failed\n"); + return 1; + } + const auto c = radio.dev->GetAdapterCaps(); + const bool cell_ok = devourer::cell_node_caps_ok(c); + printf("{\"ev\":\"cellcaps\",\"radio\":\"%s\",\"chip\":\"%s\",\"variant\":\"%s\",\"transport\":\"%s\"," + "\"tsf_write_ok\":%d,\"tbtt_follows_tsf\":%d,\"beacon_backoff_ctl\":%d,\"hw_beacon_txtsf\":%d," + "\"ack_responder_ok\":%d,\"hw_rx_timestamp\":%d,\"hw_injected_mgmt_txtsf\":%d," + "\"cell_node_ok\":%d}\n", + radio.label.c_str(), c.chip_name, c.variant, c.transport, c.tsf_write_ok, c.tbtt_follows_tsf, + c.beacon_backoff_ctl, c.hw_beacon_txtsf, c.ack_responder_ok, c.hw_rx_timestamp, + c.hw_injected_mgmt_txtsf, cell_ok ? 1 : 0); + return 0; +} diff --git a/examples/common/cell_caps.h b/examples/common/cell_caps.h new file mode 100644 index 00000000..e85514ed --- /dev/null +++ b/examples/common/cell_caps.h @@ -0,0 +1,20 @@ +// cell_caps.h — the single source of truth for which AdapterCaps a radio +// needs to run an examples/cell node (a DU or a UE): write its TSF, have the +// beacon TBTT follow that TSF, control the beacon-queue backoff, and stamp the +// live TSF into the beacon at TX. Both examples/cell (caps_ok) and the +// examples/cellcaps probe use this, so the probe's verdict cannot drift from +// the gate the cell node actually applies. +#ifndef DEVOURER_EXAMPLES_CELL_CAPS_H +#define DEVOURER_EXAMPLES_CELL_CAPS_H + +#include "AdapterCaps.h" + +namespace devourer { + +inline bool cell_node_caps_ok(const AdapterCaps &c) { + return c.tsf_write_ok && c.tbtt_follows_tsf && c.beacon_backoff_ctl && c.hw_beacon_txtsf; +} + +} // namespace devourer + +#endif // DEVOURER_EXAMPLES_CELL_CAPS_H