force writing of udp header aligned and in order for all detectors

This commit is contained in:
muelle_m1 committed 2026-11-03 17:05:05 +01:00
1 parent dd50a21b59
commit 67bf693b69
5 files changed
+65 -12

No files matched your search

@@ -2158,8 +2158,9 @@ int configureMAC() {
// start addr
uint32_t addr = RXR_ENDPOINT_START_REG;
// get struct memory
udp_header *udp = (udp_header *)(Blackfin_getBaseAddress() + addr / 2);
// build udp header
udp_header header;
udp_header *udp = &header;
memset(udp, 0, sizeof(udp_header));
// mac addresses
@@ -2191,6 +2192,15 @@ int configureMAC() {
calcChecksum(udp);
// force FPGA writes to be aligned and in order
volatile uint32_t *dst =
(volatile uint32_t *)(Blackfin_getBaseAddress() + addr / 2);
uint32_t words[sizeof(udp_header) / sizeof(uint32_t)];
memcpy(words, udp, sizeof(udp_header));
for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) {
dst[i] = words[i];
}
cleanFifos(); // FIXME: resetPerpheral() for ctb?
resetPeripheral();
LOG(logINFO, ("Waiting for %d s for mac to be up\n",
@@ -2052,9 +2052,9 @@ void setupHeader(int iRxEntry, int vetoInterface, uint32_t destip,
iRxEntry += RXR_ENDPOINTS_MAX;
}
addr += (iRxEntry * RXR_ENDPOINT_OFST);
// get struct memory
udp_header *udp =
(udp_header *)(Nios_getBaseAddress() + addr / (sizeof(u_int32_t)));
// build udp header
udp_header header;
udp_header *udp = &header;
memset(udp, 0, sizeof(udp_header));
// mac addresses
@@ -2085,6 +2085,16 @@ void setupHeader(int iRxEntry, int vetoInterface, uint32_t destip,
// total length is redefined in firmware
calcChecksum(udp);
// force FPGA writes to be aligned and in order
volatile uint32_t *dst = (volatile uint32_t *)(Nios_getBaseAddress() +
addr / (sizeof(u_int32_t)));
uint32_t words[sizeof(udp_header) / sizeof(uint32_t)];
memcpy(words, udp, sizeof(udp_header));
for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) {
dst[i] = words[i];
}
if (iRxEntry < numUdpDestinations) {
LOG(logINFO, ("\tIP checksum : 0x%lx\n\n", udp->ip_checksum));
}
@@ -1870,8 +1870,9 @@ void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip,
: RXR_ENDPOINT_OUTER_START_REG);
// calculate rxr endpoint offset
addr += (iRxEntry * RXR_ENDPOINT_OFST);
// get struct memory
udp_header *udp = (udp_header *)(Blackfin_getBaseAddress() + addr / 2);
// build udp header
udp_header header;
udp_header *udp = &header;
memset(udp, 0, sizeof(udp_header));
// mac addresses
@@ -1902,6 +1903,16 @@ void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip,
// total length is redefined in firmware
calcChecksum(udp);
// force FPGA writes to be aligned and in order
volatile uint32_t *dst =
(volatile uint32_t *)(Blackfin_getBaseAddress() + addr / 2);
uint32_t words[sizeof(udp_header) / sizeof(uint32_t)];
memcpy(words, udp, sizeof(udp_header));
for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) {
dst[i] = words[i];
}
if (iRxEntry < numUdpDestinations) {
LOG(logINFO, ("\tIP checksum : 0x%lx\n\n", udp->ip_checksum));
}
@@ -1203,8 +1203,9 @@ void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip,
: RXR_ENDPOINT_OUTER_START_REG);
// calculate rxr endpoint offset
addr += (iRxEntry * RXR_ENDPOINT_OFST);
// get struct memory
udp_header *udp = (udp_header *)(Blackfin_getBaseAddress() + addr / 2);
// build udp header
udp_header header;
udp_header *udp = &header;
memset(udp, 0, sizeof(udp_header));
// mac addresses
@@ -1235,6 +1236,16 @@ void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip,
// total length is redefined in firmware
calcChecksum(udp);
// force FPGA writes to be aligned and in order
volatile uint32_t *dst =
(volatile uint32_t *)(Blackfin_getBaseAddress() + addr / 2);
uint32_t words[sizeof(udp_header) / sizeof(uint32_t)];
memcpy(words, udp, sizeof(udp_header));
for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) {
dst[i] = words[i];
}
if (iRxEntry < numUdpDestinations) {
LOG(logINFO, ("\tIP checksum : 0x%lx\n\n", udp->ip_checksum));
}
@@ -2225,9 +2225,9 @@ int configureMAC() {
uint32_t addr = BASE_UDP_RAM;
// calculate rxr endpoint offset
addr += (iRxEntry * RXR_ENDPOINT_OFST); // TODO: is there round robin
// get struct memory
udp_header *udp =
(udp_header *)(Nios_getBaseAddress() + addr / (sizeof(u_int32_t)));
// build udp header
udp_header header;
udp_header *udp = &header;
memset(udp, 0, sizeof(udp_header));
// mac addresses
@@ -2258,6 +2258,17 @@ int configureMAC() {
// total length is redefined in firmware
calcChecksum(udp);
// force FPGA writes to be aligned and in order
volatile uint32_t *dst = (volatile uint32_t *)(Nios_getBaseAddress() +
addr /
(sizeof(u_int32_t)));
uint32_t words[sizeof(udp_header) / sizeof(uint32_t)];
memcpy(words, udp, sizeof(udp_header));
for (size_t i = 0; i != sizeof(words) / sizeof(words[0]); ++i) {
dst[i] = words[i];
}
if (iRxEntry < numUdpDestinations) {
LOG(logINFO, ("\tIP checksum : 0x%lx\n\n", udp->ip_checksum));
}