Skip to content

Commit

Permalink
adding more IOCTL for RX buffer diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
ruck314 committed Apr 24, 2024
1 parent 1139038 commit fe7c298
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 17 deletions.
16 changes: 15 additions & 1 deletion include/rogue/hardware/axi/AxiStreamDma.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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
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
110 changes: 94 additions & 16 deletions python/pyrogue/hardware/axi/_AxiStreamDmaMon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -92,11 +139,42 @@ def __init__(self, axiStreamDma, pollInterval=1, **kwargs):
))

self.add(pr.LocalVariable(
name = 'getTxBuffMissCount',
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,
))
30 changes: 30 additions & 0 deletions src/rogue/hardware/axi/AxiStreamDma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fe7c298

Please sign in to comment.