diff --git a/include/rogue/hardware/axi/AxiStreamDma.h b/include/rogue/hardware/axi/AxiStreamDma.h index bd02ee5d4..af50b7e82 100644 --- a/include/rogue/hardware/axi/AxiStreamDma.h +++ b/include/rogue/hardware/axi/AxiStreamDma.h @@ -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 diff --git a/include/rogue/hardware/drivers/DmaDriver.h b/include/rogue/hardware/drivers/DmaDriver.h index eddd022c6..d07214c92 100644 --- a/include/rogue/hardware/drivers/DmaDriver.h +++ b/include/rogue/hardware/drivers/DmaDriver.h @@ -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 diff --git a/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py b/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py new file mode 100644 index 000000000..2e79aacd6 --- /dev/null +++ b/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py @@ -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, + )) diff --git a/python/pyrogue/hardware/axi/__init__.py b/python/pyrogue/hardware/axi/__init__.py new file mode 100644 index 000000000..82b1470de --- /dev/null +++ b/python/pyrogue/hardware/axi/__init__.py @@ -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 * diff --git a/src/rogue/hardware/axi/AxiStreamDma.cpp b/src/rogue/hardware/axi/AxiStreamDma.cpp index d7330925a..9f043264b 100644 --- a/src/rogue/hardware/axi/AxiStreamDma.cpp +++ b/src/rogue/hardware/axi/AxiStreamDma.cpp @@ -566,6 +566,71 @@ void rha::AxiStreamDma::runThread(std::weak_ptr 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 @@ -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();