Skip to content

Commit

Permalink
feat: add UioAxiDmaIf::dump_status()
Browse files Browse the repository at this point in the history
  • Loading branch information
patrislav1 committed Sep 16, 2024
1 parent 0790a2a commit 6ae7b89
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions example/demo_cpp/src/axi_dma_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ int main(int argc, char* argv[]) {
if (g_stop_loop) {
data_handler.stop();
fut.wait();
axi_dma->dump_status();
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions example/demo_python/axi_dma_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def main():
print(f'{words_total} words OK')
traffic_gen.stop()
data_handler.stop()
axi_dma.dump_status()


if __name__ == '__main__':
Expand Down
3 changes: 3 additions & 0 deletions inc/udmaio/UioAxiDmaIf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class UioAxiDmaIf : public UioIf, AxiDmaBlock {
/// @brief Check status register and log any errors
/// @return true if any error occurred
bool check_for_errors();

/// @brief Dump all status register flags in the log
void dump_status();
};

} // namespace udmaio
3 changes: 2 additions & 1 deletion pyudmaio/src/PythonBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ PYBIND11_MODULE(binding, m) {
py::class_<udmaio::UioAxiDmaIf, udmaio::UioIf, std::shared_ptr<udmaio::UioAxiDmaIf>>(
m,
"UioAxiDmaIf")
.def(py::init<udmaio::UioDeviceLocation>());
.def(py::init<udmaio::UioDeviceLocation>())
.def("dump_status", &udmaio::UioAxiDmaIf::dump_status);

py::class_<udmaio::UioMemSgdma, udmaio::UioIf, std::shared_ptr<udmaio::UioMemSgdma>>(
m,
Expand Down
1 change: 1 addition & 0 deletions src/DataHandlerAbstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void DataHandlerAbstract::_handle_input(const boost::system::error_code& ec) {
if (dma_stat.err_irq && _dma.check_for_errors()) {
BOOST_LOG_SEV(_lg, bls::fatal)
<< "DMA error, curr.desc 0x" << std::hex << _dma.get_curr_desc();
_dma.dump_status();
_desc.print_descs();
throw std::runtime_error("DMA engine error raised");
}
Expand Down
26 changes: 26 additions & 0 deletions src/UioAxiDmaIf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@
#include <ios>
#include <stdexcept>

#include "udmaio/FrameFormat.hpp"

namespace axi_dma {

std::ostream& operator<<(std::ostream& os, const s2mm_dmasr_t& stat) {
auto fmt = [](std::string name, bool val) { return (val ? "+" : "-") + name; };
os << fmt("halted", stat.halted) << " ";
os << fmt("idle", stat.idle) << " ";
os << fmt("sg_incld", stat.sg_incld) << " ";
os << fmt("dma_int_err", stat.dma_int_err) << " ";
os << fmt("dma_slv_err", stat.dma_slv_err) << " ";
os << fmt("dma_dec_err", stat.dma_dec_err) << " ";
os << fmt("sg_int_err", stat.sg_int_err) << " ";
os << fmt("sg_slv_err", stat.sg_slv_err) << " ";
os << fmt("sg_dec_err", stat.sg_dec_err) << " ";
os << fmt("ioc_irq", stat.ioc_irq) << " ";
os << fmt("dly_irq", stat.dly_irq) << " ";
os << fmt("err_irq", stat.err_irq);
return os;
}

} // namespace axi_dma

namespace udmaio {

void UioAxiDmaIf::start(uintptr_t start_desc) {
Expand Down Expand Up @@ -123,4 +146,7 @@ bool UioAxiDmaIf::check_for_errors() {
return has_errors;
}

void UioAxiDmaIf::dump_status() {
BOOST_LOG_SEV(_lg, bls::info) << s2mm_dmasr.rd();
}
} // namespace udmaio

0 comments on commit 6ae7b89

Please sign in to comment.