From a0f44e34af49c8814b397e47b72f786fdc9d1317 Mon Sep 17 00:00:00 2001 From: Larry Ruckman Date: Sun, 21 Apr 2024 21:29:54 -0700 Subject: [PATCH 1/5] exposing all the TX/RX diagnostic ioctl() to python --- include/rogue/hardware/axi/AxiStreamDma.h | 25 ++++++++++++ src/rogue/hardware/axi/AxiStreamDma.cpp | 48 +++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/include/rogue/hardware/axi/AxiStreamDma.h b/include/rogue/hardware/axi/AxiStreamDma.h index bd02ee5d4..b145d9909 100644 --- a/include/rogue/hardware/axi/AxiStreamDma.h +++ b/include/rogue/hardware/axi/AxiStreamDma.h @@ -199,6 +199,31 @@ 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 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/src/rogue/hardware/axi/AxiStreamDma.cpp b/src/rogue/hardware/axi/AxiStreamDma.cpp index d7330925a..1d85f2d06 100644 --- a/src/rogue/hardware/axi/AxiStreamDma.cpp +++ b/src/rogue/hardware/axi/AxiStreamDma.cpp @@ -566,6 +566,46 @@ 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 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 +615,14 @@ 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("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(); From d536379cd85443925dad58d90e260256fab2e94d Mon Sep 17 00:00:00 2001 From: Larry Ruckman Date: Sun, 21 Apr 2024 21:30:24 -0700 Subject: [PATCH 2/5] adding the AxiStreamDmaMon python class --- .../pyrogue/hardware/axi/_AxiStreamDmaMon.py | 103 ++++++++++++++++++ python/pyrogue/hardware/axi/__init__.py | 10 ++ 2 files changed, 113 insertions(+) create mode 100644 python/pyrogue/hardware/axi/_AxiStreamDmaMon.py create mode 100644 python/pyrogue/hardware/axi/__init__.py diff --git a/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py b/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py new file mode 100644 index 000000000..19eea3275 --- /dev/null +++ b/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py @@ -0,0 +1,103 @@ +#----------------------------------------------------------------------------- +# 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 +import rogue.hardware.axi + +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(pr.LocalVariable( + name = 'RxBuffCount', + description = 'Get the number of RX buffers', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getRxBuffCount(), + )) + + self.add(pr.LocalVariable( + name = 'TxBuffCount', + description = 'Get the number of TX buffers', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getTxBuffCount(), + )) + + self.add(pr.LocalVariable( + name = 'TxBuffinUserCount', + description = 'TX buffer in User count', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getTxBuffinUserCount(), + pollInterval= pollInterval, + )) + + self.add(pr.LocalVariable( + name = 'TxBuffinHwCount', + description = 'TX buffer in HW count', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getTxBuffinHwCount(), + pollInterval= pollInterval, + )) + + self.add(pr.LocalVariable( + name = 'TxBuffinPreHwQCount', + 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 = 'TxBuffinSwQCount', + 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 = 'getTxBuffMissCount', + description = 'TX buffer missing count', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getTxBuffMissCount(), + 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 * From 1139038340b4ac2c7fc54dcae6bb569c917d3dfd Mon Sep 17 00:00:00 2001 From: Larry Ruckman Date: Sun, 21 Apr 2024 21:38:51 -0700 Subject: [PATCH 3/5] linter fix --- python/pyrogue/hardware/axi/_AxiStreamDmaMon.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py b/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py index 19eea3275..72183e588 100644 --- a/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py +++ b/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py @@ -13,7 +13,6 @@ #----------------------------------------------------------------------------- import pyrogue as pr -import rogue.hardware.axi class AxiStreamDmaMon(pr.Device): def __init__(self, axiStreamDma, pollInterval=1, **kwargs): From fe7c298eaed0220480ded9f9ff77a37adb73b076 Mon Sep 17 00:00:00 2001 From: Larry Ruckman Date: Tue, 23 Apr 2024 19:03:08 -0700 Subject: [PATCH 4/5] adding more IOCTL for RX buffer diagnostics --- include/rogue/hardware/axi/AxiStreamDma.h | 16 ++- include/rogue/hardware/drivers/DmaDriver.h | 5 + .../pyrogue/hardware/axi/_AxiStreamDmaMon.py | 110 +++++++++++++++--- src/rogue/hardware/axi/AxiStreamDma.cpp | 30 +++++ 4 files changed, 144 insertions(+), 17 deletions(-) diff --git a/include/rogue/hardware/axi/AxiStreamDma.h b/include/rogue/hardware/axi/AxiStreamDma.h index b145d9909..af50b7e82 100644 --- a/include/rogue/hardware/axi/AxiStreamDma.h +++ b/include/rogue/hardware/axi/AxiStreamDma.h @@ -206,6 +206,21 @@ class AxiStreamDma : public rogue::interfaces::stream::Master, public rogue::int //! 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(); @@ -223,7 +238,6 @@ class AxiStreamDma : public rogue::interfaces::stream::Master, public rogue::int //! 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 index 72183e588..6d6a82866 100644 --- a/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py +++ b/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py @@ -14,7 +14,7 @@ import pyrogue as pr -class AxiStreamDmaMon(pr.Device): +class AxiStreamDmaMonRx(pr.Device): def __init__(self, axiStreamDma, pollInterval=1, **kwargs): super(self.__class__, self).__init__(**kwargs) @@ -23,27 +23,74 @@ def __init__(self, axiStreamDma, pollInterval=1, **kwargs): # Add variables self.add(pr.LocalVariable( - name = 'BuffSize', - description = 'size of buffers (RX/TX)', + name = 'BuffCount', + description = 'Get the number of RX buffers', mode = 'RO', - value = 0x0, + value = 0, typeStr = 'UInt32', - units = 'Bytes', - disp = '{:#x}', - localGet = lambda: self._dma.getBuffSize(), + localGet = lambda: self._dma.getRxBuffCount(), )) self.add(pr.LocalVariable( - name = 'RxBuffCount', - description = 'Get the number of RX buffers', + name = 'BuffinUserCount', + description = 'RX buffer in User count', mode = 'RO', value = 0, typeStr = 'UInt32', - localGet = lambda: self._dma.getRxBuffCount(), + 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 = 'TxBuffCount', + 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, @@ -52,7 +99,7 @@ def __init__(self, axiStreamDma, pollInterval=1, **kwargs): )) self.add(pr.LocalVariable( - name = 'TxBuffinUserCount', + name = 'BuffinUserCount', description = 'TX buffer in User count', mode = 'RO', value = 0, @@ -62,7 +109,7 @@ def __init__(self, axiStreamDma, pollInterval=1, **kwargs): )) self.add(pr.LocalVariable( - name = 'TxBuffinHwCount', + name = 'BuffinHwCount', description = 'TX buffer in HW count', mode = 'RO', value = 0, @@ -72,7 +119,7 @@ def __init__(self, axiStreamDma, pollInterval=1, **kwargs): )) self.add(pr.LocalVariable( - name = 'TxBuffinPreHwQCount', + name = 'BuffinPreHwQCount', description = 'TX buffer in Pre-HW Queue count', mode = 'RO', value = 0, @@ -82,7 +129,7 @@ def __init__(self, axiStreamDma, pollInterval=1, **kwargs): )) self.add(pr.LocalVariable( - name = 'TxBuffinSwQCount', + name = 'BuffinSwQCount', description = 'TX buffer in SW Queue count', mode = 'RO', value = 0, @@ -92,7 +139,7 @@ def __init__(self, axiStreamDma, pollInterval=1, **kwargs): )) self.add(pr.LocalVariable( - name = 'getTxBuffMissCount', + name = 'BuffMissCount', description = 'TX buffer missing count', mode = 'RO', value = 0, @@ -100,3 +147,34 @@ def __init__(self, axiStreamDma, pollInterval=1, **kwargs): 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/src/rogue/hardware/axi/AxiStreamDma.cpp b/src/rogue/hardware/axi/AxiStreamDma.cpp index 1d85f2d06..9f043264b 100644 --- a/src/rogue/hardware/axi/AxiStreamDma.cpp +++ b/src/rogue/hardware/axi/AxiStreamDma.cpp @@ -576,6 +576,31 @@ 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)); @@ -617,6 +642,11 @@ void rha::AxiStreamDma::setup_python() { .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) From 35207ceeef8128a11dd25bb1315e3f3525cac45c Mon Sep 17 00:00:00 2001 From: Larry Ruckman Date: Tue, 23 Apr 2024 19:16:20 -0700 Subject: [PATCH 5/5] linter fix --- python/pyrogue/hardware/axi/_AxiStreamDmaMon.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py b/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py index 6d6a82866..2e79aacd6 100644 --- a/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py +++ b/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py @@ -172,9 +172,9 @@ def __init__(self, axiStreamDma, pollInterval=1, **kwargs): axiStreamDma = axiStreamDma, pollInterval = pollInterval, )) - + self.add(AxiStreamDmaMonTx( name = 'Tx', axiStreamDma = axiStreamDma, pollInterval = pollInterval, - )) + ))