improve stats reporting

now again use three messages to transmit stats (much more efficient than
sending single values, also more acurate).
This commit is contained in:
Martin Preuss
2025-08-25 10:22:05 +02:00
parent 7efaf720cc
commit 6e062d3f60
13 changed files with 234 additions and 186 deletions

View File

@@ -14,8 +14,8 @@
.equ NETMSG_CMD_PING = 10
.equ NETMSG_CMD_PONG = 11
.equ NETMSG_CMD_SENDSTATS = 20
.equ NETMSG_CMD_RECVSTATS = 21
.equ NETMSG_CMD_SENDSTATS = 22
.equ NETMSG_CMD_RECVSTATS = 23
.equ NETMSG_CMD_TWIBUSMEMBER = 30
.equ NETMSG_CMD_DEBUG = 40

View File

@@ -51,14 +51,10 @@ NETMSG_MemStats_Write:
st X+, r21
.endif
; current buffers used
push xl
push xh
bigcall NET_Buffer_CountUsed ; (r16, r17, r18, X)
pop xh
pop xl
lds r16, netBuffersUsed
st X+, r16
; max buffers used
clr r16
lds r16, netBuffersMaxUsed
st X+, r16
; no buffer errors
ldd r16, Y+NET_IFACE_OFFS_ERR_NOBUF_LOW

View File

@@ -19,21 +19,52 @@
NETMSG_RecvStats_Write:
ldi r16, 0xff
st X+, r16 ; dest address
ldi r16, 18 ; msg code+src address+10 payload bytes
ldi r16, 19 ; msg code+src address+10 payload bytes
st X+, r16 ; msg len
ldi r16, NETMSG_CMD_RECVSTATS
st X+, r16 ; msg code
ldd r16, Y+NET_IFACE_OFFS_ADDRESS
st X+, r16 ; src address
bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21)
adiw yh:yl, NET_IFACE_OFFS_PACKETSIN_LOW
ldi r18, 12
bigcall Utils_Copy_SDRAM ; (R17, R18, X, Y)
sbiw yh:yl, NET_IFACE_OFFS_PACKETSIN_LOW+12
sbiw xh:xl, 20 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload)
; UID
bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21)
; interface number
ldd r16, Y+NET_IFACE_OFFS_IFACENUM
st X+, r16
; packets in
ldd r16, Y+NET_IFACE_OFFS_PACKETSIN_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_PACKETSIN_HIGH
st X+, r16
; content error
ldd r16, Y+NET_IFACE_OFFS_ERR_CONTENT_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_ERR_CONTENT_HIGH
st X+, r16
; io error
ldd r16, Y+NET_IFACE_OFFS_ERR_IO_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_ERR_IO_HIGH
st X+, r16
; nobuf error
ldd r16, Y+NET_IFACE_OFFS_ERR_NOBUF_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_ERR_NOBUF_HIGH
st X+, r16
; msgsize error
ldd r16, Y+NET_IFACE_OFFS_ERR_MSGSIZE_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_ERR_MSGSIZE_HIGH
st X+, r16
; missed error
ldd r16, Y+NET_IFACE_OFFS_ERR_MISSED_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_ERR_MISSED_HIGH
st X+, r16
sbiw xh:xl, 21 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload)
bigcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X)
sbiw xh:xl, 21 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload, 1 byte crc)
sbiw xh:xl, 22 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload, 1 byte crc)
ret
; @end

View File

@@ -12,28 +12,44 @@
; ---------------------------------------------------------------------------
; @routine NETMSG_SendStats_Write @global
;
; @param Y pointer to device to write msg for and to
; @param Y pointer to device to write msg for
; @param X pointer to buffer to write to
; @clobbers R16, R18 (R17, R19, R20, R21, Z)
NETMSG_SendStats_Write:
ldi r16, 0xff
st X+, r16 ; dest address
ldi r16, 12 ; msg code+src address+10 payload bytes
ldi r16, 13 ; msg code+src address+11 payload bytes
st X+, r16 ; msg len
ldi r16, NETMSG_CMD_SENDSTATS
st X+, r16 ; msg code
ldd r16, Y+NET_IFACE_OFFS_ADDRESS
st X+, r16 ; src address
bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21)
adiw yh:yl, NET_IFACE_OFFS_PACKETSOUT_LOW
ldi r18, 6
bigcall Utils_Copy_SDRAM ; (R17, R18, X, Y)
sbiw yh:yl, NET_IFACE_OFFS_PACKETSOUT_LOW+6
sbiw xh:xl, 14 ; go back to beginning of message (1 byte dst addr, 1 byte length, 12 bytes payload)
; UID
bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21)
; interface number
ldd r16, Y+NET_IFACE_OFFS_IFACENUM
st X+, r16
; packets out
ldd r16, Y+NET_IFACE_OFFS_PACKETSOUT_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_PACKETSOUT_HIGH
st X+, r16
; collisions
ldd r16, Y+NET_IFACE_OFFS_ERR_COLLISIONS_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_ERR_COLLISIONS_HIGH
st X+, r16
; busy
ldd r16, Y+NET_IFACE_OFFS_ERR_BUSY_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_ERR_BUSY_HIGH
st X+, r16
sbiw xh:xl, 15 ; go back to beginning of message (1 byte dst addr, 1 byte length, 13 bytes payload)
bigcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X)
sbiw xh:xl, 15 ; go back to beginning of message (1 byte dst addr, 1 byte length, 12 bytes payload, 1 byte crc)
sbiw xh:xl, 16 ; go back to beginning of message (1 byte dst addr, 1 byte length, 12 bytes payload, 1 byte crc)
ret
; @end