Skip to content

Commit 06069bd

Browse files
committed
feat: shorten desc. fmt, add curr.desc.ptr
1 parent 030f949 commit 06069bd

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

inc/udmaio/UioAxiDmaIf.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111

1212
#pragma once
1313

14+
#include <cstdint>
1415
#include <tuple>
1516

17+
#include <sys/types.h>
18+
1619
#include "RegAccessor.hpp"
1720
#include "UioIf.hpp"
1821
#include "udmaio/rdl/AxiDma.hpp"
@@ -28,6 +31,7 @@ class UioAxiDmaIf : public UioIf, AxiDmaBlock {
2831
/// @brief Configure and start the AXI DMA controller
2932
/// @param start_desc Address of first SGDMA descriptor
3033
void start(uintptr_t start_desc);
34+
uintptr_t get_curr_desc();
3135

3236
using UioIf::arm_interrupt;
3337

src/DataHandlerAbstract.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ void DataHandlerAbstract::_handle_input(const boost::system::error_code& ec) {
6262
auto [irq_count, dma_stat] = _dma.clear_interrupt();
6363
BOOST_LOG_SEV(_lg, bls::trace) << "irq count = " << irq_count;
6464
if (dma_stat.err_irq && _dma.check_for_errors()) {
65+
BOOST_LOG_SEV(_lg, bls::fatal)
66+
<< "DMA error, curr.desc 0x" << std::hex << _dma.get_curr_desc();
6567
_desc.print_descs();
6668
throw std::runtime_error("DMA engine error raised");
6769
}

src/UioAxiDmaIf.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "udmaio/UioAxiDmaIf.hpp"
1313

14+
#include <cstdint>
1415
#include <ios>
1516
#include <stdexcept>
1617

@@ -51,6 +52,17 @@ void UioAxiDmaIf::start(uintptr_t start_desc) {
5152
<< "DMA ctrl = 0x" << std::hex << reg_to_raw(s2mm_dmacr.rd()) << std::dec;
5253
}
5354

55+
uintptr_t UioAxiDmaIf::get_curr_desc() {
56+
uintptr_t result = s2mm_curdesc.rd().current_descriptor_pointer;
57+
result <<= 6;
58+
if (sizeof(result) > sizeof(uint32_t)) {
59+
uintptr_t msb = s2mm_curdesc_msb.rd();
60+
msb <<= 32;
61+
result |= msb;
62+
}
63+
return result;
64+
}
65+
5466
std::tuple<uint32_t, axi_dma::s2mm_dmasr_t> UioAxiDmaIf::clear_interrupt() {
5567
uint32_t irq_count = wait_for_interrupt();
5668

src/UioMemSgdma.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,17 @@ void UioMemSgdma::init_buffers(std::shared_ptr<DmaBufferAbstract> mem,
8989
}
9090

9191
void UioMemSgdma::print_desc(const S2mmDesc& desc) const {
92+
auto fmt_flag = [](std::string name, bool val) { return (val ? "+" : "-") + name; };
9293
#define BLI BOOST_LOG_SEV(_lg, bls::info) << ""
93-
BLI << "S2mmDesc {";
94-
BLI << " next desc = 0x" << std::hex << desc.nxtdesc;
95-
BLI << " buffer addr = 0x" << std::hex << desc.buffer_addr;
96-
BLI << " control";
97-
BLI << " buffer_len = " << std::dec << desc.control.buffer_len;
98-
BLI << " sof = " << std::dec << desc.control.rxsof;
99-
BLI << " eof = " << std::dec << desc.control.rxeof;
100-
BLI << " status";
101-
BLI << " buffer_len = " << std::dec << desc.status.num_stored_bytes;
102-
BLI << " sof = " << std::dec << desc.status.rxsof;
103-
BLI << " eof = " << std::dec << desc.status.rxeof;
104-
BLI << " dmainterr = " << std::dec << desc.status.dmainterr;
105-
BLI << " dmaslverr = " << std::dec << desc.status.dmaslverr;
106-
BLI << " dmadecerr = " << std::dec << desc.status.dmadecerr;
107-
BLI << " cmplt = " << std::dec << desc.status.cmplt;
108-
BLI << "}" << std::dec;
94+
BLI << "next_desc: 0x" << std::hex << desc.nxtdesc << ", " << "buff_addr: 0x" << std::hex
95+
<< desc.buffer_addr;
96+
BLI << "ctrl: buf_len " << std::dec << desc.control.buffer_len << ", "
97+
<< fmt_flag("sof", desc.control.rxsof) << " " << fmt_flag("eof", desc.control.rxeof) << " ";
98+
BLI << "status: num_bytes " << std::dec << desc.status.num_stored_bytes << ", "
99+
<< fmt_flag("sof", desc.status.rxsof) << " " << fmt_flag("eof", desc.status.rxeof) << " "
100+
<< fmt_flag("interr", desc.status.dmainterr) << " "
101+
<< fmt_flag("slverr", desc.status.dmaslverr) << " "
102+
<< fmt_flag("decerr", desc.status.dmadecerr) << " " << fmt_flag("cmplt", desc.status.cmplt);
109103
}
110104

111105
void UioMemSgdma::print_descs() const {

0 commit comments

Comments
 (0)