Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AxiStreamDma: exposing all the TX/RX diagnostic ioctl() to python #999

Merged
merged 6 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions include/rogue/hardware/axi/AxiStreamDma.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,45 @@ class AxiStreamDma : public rogue::interfaces::stream::Master, public rogue::int

// Process Buffer Return
void retBuffer(uint8_t* data, uint32_t meta, uint32_t rawSize);

//! Get the size of buffers (RX/TX)
uint32_t getBuffSize();

//! Get the number of RX buffers
uint32_t getRxBuffCount();

//! Get RX buffer in User count
uint32_t getRxBuffinUserCount();

//! Get RX buffer in HW count
uint32_t getRxBuffinHwCount();

//! Get RX buffer in Pre-HW Queue count
uint32_t getRxBuffinPreHwQCount();

//! Get RX buffer in SW Queue count
uint32_t getRxBuffinSwQCount();

//! Get RX buffer missing count
uint32_t getRxBuffMissCount();

//! Get the number of TX buffers
uint32_t getTxBuffCount();

//! Get TX buffer in User count
uint32_t getTxBuffinUserCount();

//! Get TX buffer in HW count
uint32_t getTxBuffinHwCount();

//! Get TX buffer in Pre-HW Queue count
uint32_t getTxBuffinPreHwQCount();

//! Get TX buffer in SW Queue count
uint32_t getTxBuffinSwQCount();

//! Get TX buffer missing count
uint32_t getTxBuffMissCount();
};

//! Alias for using shared pointer as AxiStreamDmaPtr
Expand Down
5 changes: 5 additions & 0 deletions include/rogue/hardware/drivers/DmaDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
#define DMA_Get_TxBuffinPreHWQ_Count 0x1011
#define DMA_Get_TxBuffinSWQ_Count 0x1012
#define DMA_Get_TxBuffMiss_Count 0x1013
#define DMA_Get_RxBuffinUser_Count 0x1014
#define DMA_Get_RxBuffinHW_Count 0x1015
#define DMA_Get_RxBuffinPreHWQ_Count 0x1016
#define DMA_Get_RxBuffinSWQ_Count 0x1017
#define DMA_Get_RxBuffMiss_Count 0x1018

/* Mask size */
#define DMA_MASK_SIZE 512
Expand Down
180 changes: 180 additions & 0 deletions python/pyrogue/hardware/axi/_AxiStreamDmaMon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
#-----------------------------------------------------------------------------
# Company: SLAC National Accelerator Laboratory
#-----------------------------------------------------------------------------
# Description: Module for monitoring the DMA kernel driver
#-----------------------------------------------------------------------------
# This file is part of the rogue software platform. It is subject to
# the license terms in the LICENSE.txt file found in the top-level directory
# of this distribution and at:
# https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
# No part of the rogue software platform, including this file, may be
# copied, modified, propagated, or distributed except according to the terms
# contained in the LICENSE.txt file.
#-----------------------------------------------------------------------------

import pyrogue as pr

class AxiStreamDmaMonRx(pr.Device):
def __init__(self, axiStreamDma, pollInterval=1, **kwargs):
super(self.__class__, self).__init__(**kwargs)

# Create a pointer to the AXI Stream DMA object
self._dma = axiStreamDma

# Add variables
self.add(pr.LocalVariable(
name = 'BuffCount',
description = 'Get the number of RX buffers',
mode = 'RO',
value = 0,
typeStr = 'UInt32',
localGet = lambda: self._dma.getRxBuffCount(),
))

self.add(pr.LocalVariable(
name = 'BuffinUserCount',
description = 'RX buffer in User count',
mode = 'RO',
value = 0,
typeStr = 'UInt32',
localGet = lambda: self._dma.getRxBuffinUserCount(),
pollInterval= pollInterval,
))

self.add(pr.LocalVariable(
name = 'BuffinHwCount',
description = 'RX buffer in HW count',
mode = 'RO',
value = 0,
typeStr = 'UInt32',
localGet = lambda: self._dma.getRxBuffinHwCount(),
pollInterval= pollInterval,
))

self.add(pr.LocalVariable(
name = 'BuffinPreHwQCount',
description = 'RX buffer in Pre-HW Queue count',
mode = 'RO',
value = 0,
typeStr = 'UInt32',
localGet = lambda: self._dma.getRxBuffinPreHwQCount(),
pollInterval= pollInterval,
))

self.add(pr.LocalVariable(
name = 'BuffinSwQCount',
description = 'RX buffer in SW Queue count',
mode = 'RO',
value = 0,
typeStr = 'UInt32',
localGet = lambda: self._dma.getRxBuffinSwQCount(),
pollInterval= pollInterval,
))

self.add(pr.LocalVariable(
name = 'BuffMissCount',
description = 'RX buffer missing count',
mode = 'RO',
value = 0,
typeStr = 'UInt32',
localGet = lambda: self._dma.getRxBuffMissCount(),
pollInterval= pollInterval,
))

class AxiStreamDmaMonTx(pr.Device):
def __init__(self, axiStreamDma, pollInterval=1, **kwargs):
super(self.__class__, self).__init__(**kwargs)

# Create a pointer to the AXI Stream DMA object
self._dma = axiStreamDma

# Add variables
self.add(pr.LocalVariable(
name = 'BuffCount',
description = 'Get the number of TX buffers',
mode = 'RO',
value = 0,
typeStr = 'UInt32',
localGet = lambda: self._dma.getTxBuffCount(),
))

self.add(pr.LocalVariable(
name = 'BuffinUserCount',
description = 'TX buffer in User count',
mode = 'RO',
value = 0,
typeStr = 'UInt32',
localGet = lambda: self._dma.getTxBuffinUserCount(),
pollInterval= pollInterval,
))

self.add(pr.LocalVariable(
name = 'BuffinHwCount',
description = 'TX buffer in HW count',
mode = 'RO',
value = 0,
typeStr = 'UInt32',
localGet = lambda: self._dma.getTxBuffinHwCount(),
pollInterval= pollInterval,
))

self.add(pr.LocalVariable(
name = 'BuffinPreHwQCount',
description = 'TX buffer in Pre-HW Queue count',
mode = 'RO',
value = 0,
typeStr = 'UInt32',
localGet = lambda: self._dma.getTxBuffinPreHwQCount(),
pollInterval= pollInterval,
))

self.add(pr.LocalVariable(
name = 'BuffinSwQCount',
description = 'TX buffer in SW Queue count',
mode = 'RO',
value = 0,
typeStr = 'UInt32',
localGet = lambda: self._dma.getTxBuffinSwQCount(),
pollInterval= pollInterval,
))

self.add(pr.LocalVariable(
name = 'BuffMissCount',
description = 'TX buffer missing count',
mode = 'RO',
value = 0,
typeStr = 'UInt32',
localGet = lambda: self._dma.getTxBuffMissCount(),
pollInterval= pollInterval,
))

class AxiStreamDmaMon(pr.Device):
def __init__(self, axiStreamDma, pollInterval=1, **kwargs):
super(self.__class__, self).__init__(**kwargs)

# Create a pointer to the AXI Stream DMA object
self._dma = axiStreamDma

# Add variables
self.add(pr.LocalVariable(
name = 'BuffSize',
description = 'Size of buffers (RX/TX)',
mode = 'RO',
value = 0x0,
typeStr = 'UInt32',
units = 'Bytes',
disp = '{:#x}',
localGet = lambda: self._dma.getBuffSize(),
))

self.add(AxiStreamDmaMonRx(
name = 'Rx',
axiStreamDma = axiStreamDma,
pollInterval = pollInterval,
))

self.add(AxiStreamDmaMonTx(
name = 'Tx',
axiStreamDma = axiStreamDma,
pollInterval = pollInterval,
))
10 changes: 10 additions & 0 deletions python/pyrogue/hardware/axi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#-----------------------------------------------------------------------------
# This file is part of the rogue software platform. It is subject to
# the license terms in the LICENSE.txt file found in the top-level directory
# of this distribution and at:
# https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
# No part of the rogue software platform, including this file, may be
# copied, modified, propagated, or distributed except according to the terms
# contained in the LICENSE.txt file.
#-----------------------------------------------------------------------------
from pyrogue.hardware.axi._AxiStreamDmaMon import *
78 changes: 78 additions & 0 deletions src/rogue/hardware/axi/AxiStreamDma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,71 @@ void rha::AxiStreamDma::runThread(std::weak_ptr<int> lockPtr) {
}
}

//! Get the size of buffers (RX/TX)
uint32_t rha::AxiStreamDma::getBuffSize() {
return uint32_t(ioctl(fd_, DMA_Get_Buff_Size, 0));
}

//! Get the number of RX buffers
uint32_t rha::AxiStreamDma::getRxBuffCount() {
return uint32_t(ioctl(fd_, DMA_Get_RxBuff_Count, 0));
}

//! Get RX buffer in User count
uint32_t rha::AxiStreamDma::getRxBuffinUserCount() {
return ioctl(fd_, DMA_Get_RxBuffinUser_Count, 0);
}

//! Get RX buffer in HW count
uint32_t rha::AxiStreamDma::getRxBuffinHwCount() {
return ioctl(fd_, DMA_Get_RxBuffinHW_Count, 0);
}

//! Get RX buffer in Pre-HW Queue count
uint32_t rha::AxiStreamDma::getRxBuffinPreHwQCount() {
return ioctl(fd_, DMA_Get_RxBuffinPreHWQ_Count, 0);
}

//! Get RX buffer in SW Queue count
uint32_t rha::AxiStreamDma::getRxBuffinSwQCount() {
return ioctl(fd_, DMA_Get_RxBuffinSWQ_Count, 0);
}

//! Get RX buffer missing count
uint32_t rha::AxiStreamDma::getRxBuffMissCount() {
return ioctl(fd_, DMA_Get_RxBuffMiss_Count, 0);
}

//! Get the number of TX buffers
uint32_t rha::AxiStreamDma::getTxBuffCount() {
return uint32_t(ioctl(fd_, DMA_Get_TxBuff_Count, 0));
}

//! Get TX buffer in User count
uint32_t rha::AxiStreamDma::getTxBuffinUserCount() {
return ioctl(fd_, DMA_Get_TxBuffinUser_Count, 0);
}

//! Get TX buffer in HW count
uint32_t rha::AxiStreamDma::getTxBuffinHwCount() {
return ioctl(fd_, DMA_Get_TxBuffinHW_Count, 0);
}

//! Get TX buffer in Pre-HW Queue count
uint32_t rha::AxiStreamDma::getTxBuffinPreHwQCount() {
return ioctl(fd_, DMA_Get_TxBuffinPreHWQ_Count, 0);
}

//! Get TX buffer in SW Queue count
uint32_t rha::AxiStreamDma::getTxBuffinSwQCount() {
return ioctl(fd_, DMA_Get_TxBuffinSWQ_Count, 0);
}

//! Get TX buffer missing count
uint32_t rha::AxiStreamDma::getTxBuffMissCount() {
return ioctl(fd_, DMA_Get_TxBuffMiss_Count, 0);
}

void rha::AxiStreamDma::setup_python() {
#ifndef NO_PYTHON

Expand All @@ -575,6 +640,19 @@ void rha::AxiStreamDma::setup_python() {
.def("setDriverDebug", &rha::AxiStreamDma::setDriverDebug)
.def("dmaAck", &rha::AxiStreamDma::dmaAck)
.def("setTimeout", &rha::AxiStreamDma::setTimeout)
.def("getBuffSize", &rha::AxiStreamDma::getBuffSize)
.def("getRxBuffCount", &rha::AxiStreamDma::getRxBuffCount)
.def("getRxBuffinUserCount", &rha::AxiStreamDma::getRxBuffinUserCount)
.def("getRxBuffinHwCount", &rha::AxiStreamDma::getRxBuffinHwCount)
.def("getRxBuffinPreHwQCount", &rha::AxiStreamDma::getRxBuffinPreHwQCount)
.def("getRxBuffinSwQCount", &rha::AxiStreamDma::getRxBuffinSwQCount)
.def("getRxBuffMissCount", &rha::AxiStreamDma::getRxBuffMissCount)
.def("getTxBuffCount", &rha::AxiStreamDma::getTxBuffCount)
.def("getTxBuffinUserCount", &rha::AxiStreamDma::getTxBuffinUserCount)
.def("getTxBuffinHwCount", &rha::AxiStreamDma::getTxBuffinHwCount)
.def("getTxBuffinPreHwQCount", &rha::AxiStreamDma::getTxBuffinPreHwQCount)
.def("getTxBuffinSwQCount", &rha::AxiStreamDma::getTxBuffinSwQCount)
.def("getTxBuffMissCount", &rha::AxiStreamDma::getTxBuffMissCount)
.def("zeroCopyDisable", &rha::AxiStreamDma::zeroCopyDisable);

bp::implicitly_convertible<rha::AxiStreamDmaPtr, ris::MasterPtr>();
Expand Down
Loading