g2 and m3 round robin (#559)

* g2 and m3: round robin
This commit is contained in:
Dhanya Thattil 2022-10-18 15:51:23 +02:00 committed by GitHub
parent 46bb9bc2d7
commit e7879ee365
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 290 additions and 193 deletions

View File

@ -100,6 +100,7 @@ This document describes the differences between v7.0.0 and v6.x.x
- jungfrau reset core and usleep removed (fix for 6.1.1 is now fixed in firmware)
- g2 change clkdivs 2 3 4 to defaults for burst and cw mode.
- ctb and moench: allowing 1g non blocking acquire to send data
- m3 and g2 rr
- m3 and g2 temp
- gain plot zooming fixed (disabled, acc. to main plot)
- ctb, moench, jungfrau (pll reset at start fixed, before no defines)

View File

@ -204,9 +204,9 @@
#define PKT_CONFIG_REG (0x00 * REG_OFFSET + BASE_PKT)
#define PKT_CONFIG_NRXR_MAX_OFST (0)
#define PKT_CONFIG_NRXR_MAX_MSK (0x0000003F << PKT_CONFIG_NRXR_MAX_OFST)
#define PKT_CONFIG_NRXR_MAX_MSK (0x0000001F << PKT_CONFIG_NRXR_MAX_OFST)
#define PKT_CONFIG_RXR_START_ID_OFST (8)
#define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST)
#define PKT_CONFIG_RXR_START_ID_MSK (0x0000001F << PKT_CONFIG_RXR_START_ID_OFST)
/* Module Coordinates Register */
#define COORD_0_REG (0x02 * REG_OFFSET + BASE_PKT)

View File

@ -27,6 +27,7 @@ extern int debugflag;
extern int updateFlag;
extern int checkModuleFlag;
extern udpStruct udpDetails[MAX_UDP_DESTINATION];
extern int numUdpDestinations;
extern const enum detectorType myDetectorType;
extern int ignoreConfigFileFlag;
@ -1851,6 +1852,36 @@ int getNumberofUDPInterfaces() {
return ((bus_r(CONFIG_REG) & CONFIG_VETO_CH_10GBE_ENBL_MSK) ? 2 : 1);
}
int getNumberofDestinations(int *retval) {
*retval = (((bus_r(PKT_CONFIG_REG) & PKT_CONFIG_NRXR_MAX_MSK) >>
PKT_CONFIG_NRXR_MAX_OFST) +
1);
return OK;
}
int setNumberofDestinations(int value) {
LOG(logINFO, ("Setting number of entries to %d\n", value));
--value;
bus_w(PKT_CONFIG_REG, bus_r(PKT_CONFIG_REG) & ~PKT_CONFIG_NRXR_MAX_MSK);
bus_w(PKT_CONFIG_REG,
bus_r(PKT_CONFIG_REG) |
((value << PKT_CONFIG_NRXR_MAX_OFST) & PKT_CONFIG_NRXR_MAX_MSK));
return OK;
}
int getFirstUDPDestination() {
return ((bus_r(PKT_CONFIG_REG) & PKT_CONFIG_RXR_START_ID_MSK) >>
PKT_CONFIG_RXR_START_ID_OFST);
}
void setFirstUDPDestination(int value) {
LOG(logINFO, ("Setting first entry to %d\n", value));
bus_w(PKT_CONFIG_REG, bus_r(PKT_CONFIG_REG) & ~PKT_CONFIG_RXR_START_ID_MSK);
bus_w(PKT_CONFIG_REG,
bus_r(PKT_CONFIG_REG) | ((value << PKT_CONFIG_RXR_START_ID_OFST) &
PKT_CONFIG_RXR_START_ID_MSK));
}
void setupHeader(int iRxEntry, int vetoInterface, uint32_t destip,
uint64_t destmac, uint32_t destport, uint64_t sourcemac,
uint32_t sourceip, uint32_t sourceport) {
@ -1895,6 +1926,9 @@ void setupHeader(int iRxEntry, int vetoInterface, uint32_t destip,
// total length is redefined in firmware
calcChecksum(udp);
if (iRxEntry < numUdpDestinations) {
LOG(logINFO, ("\tIP checksum : 0x%lx\n\n", udp->ip_checksum));
}
}
void calcChecksum(udp_header *udp) {
@ -1925,93 +1959,98 @@ void calcChecksum(udp_header *udp) {
sum = (sum & 0xffff) + (sum >> 16); // Fold 32-bit sum to 16 bits
long int checksum = sum & 0xffff;
checksum += UDP_IP_HEADER_LENGTH_BYTES;
LOG(logINFO, ("\tIP checksum is 0x%lx\n", checksum));
udp->ip_checksum = checksum;
}
int configureMAC() {
uint32_t srcip = udpDetails[0].srcip;
uint32_t srcip2 = udpDetails[0].srcip2;
uint32_t dstip = udpDetails[0].dstip;
uint32_t dstip2 = udpDetails[0].dstip2;
uint64_t srcmac = udpDetails[0].srcmac;
uint64_t srcmac2 = udpDetails[0].srcmac2;
uint64_t dstmac = udpDetails[0].dstmac;
uint64_t dstmac2 = udpDetails[0].dstmac2;
int srcport = udpDetails[0].srcport;
int srcport2 = udpDetails[0].srcport2;
int dstport = udpDetails[0].dstport;
int dstport2 = udpDetails[0].dstport2;
LOG(logINFOBLUE, ("Configuring MAC\n"));
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip);
char src_mac2[MAC_ADDRESS_SIZE], src_ip2[INET_ADDRSTRLEN],
dst_mac2[MAC_ADDRESS_SIZE], dst_ip2[INET_ADDRSTRLEN];
getMacAddressinString(src_mac2, MAC_ADDRESS_SIZE, srcmac2);
getMacAddressinString(dst_mac2, MAC_ADDRESS_SIZE, dstmac2);
getIpAddressinString(src_ip2, srcip2);
getIpAddressinString(dst_ip2, dstip2);
LOG(logINFO, ("\tData Interface \n"));
LOG(logINFO, ("\tSource IP : %s\n"
"\tSource MAC : %s\n"
"\tSource Port : %d\n"
"\tDest IP : %s\n"
"\tDest MAC : %s\n"
"\tDest Port : %d\n\n",
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
LOG(logINFO, ("Number of entries: %d\n\n", numUdpDestinations));
for (int iRxEntry = 0; iRxEntry != MAX_UDP_DESTINATION; ++iRxEntry) {
uint32_t srcip = udpDetails[iRxEntry].srcip;
uint32_t srcip2 = udpDetails[iRxEntry].srcip2;
uint32_t dstip = udpDetails[iRxEntry].dstip;
uint32_t dstip2 = udpDetails[iRxEntry].dstip2;
uint64_t srcmac = udpDetails[iRxEntry].srcmac;
uint64_t srcmac2 = udpDetails[iRxEntry].srcmac2;
uint64_t dstmac = udpDetails[iRxEntry].dstmac;
uint64_t dstmac2 = udpDetails[iRxEntry].dstmac2;
int srcport = udpDetails[iRxEntry].srcport;
int srcport2 = udpDetails[iRxEntry].srcport2;
int dstport = udpDetails[iRxEntry].dstport;
int dstport2 = udpDetails[iRxEntry].dstport2;
int lll = getVetoStream();
int i10gbe = (getNumberofUDPInterfaces() == 2 ? 1 : 0);
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip);
char src_mac2[MAC_ADDRESS_SIZE], src_ip2[INET_ADDRSTRLEN],
dst_mac2[MAC_ADDRESS_SIZE], dst_ip2[INET_ADDRSTRLEN];
getMacAddressinString(src_mac2, MAC_ADDRESS_SIZE, srcmac2);
getMacAddressinString(dst_mac2, MAC_ADDRESS_SIZE, dstmac2);
getIpAddressinString(src_ip2, srcip2);
getIpAddressinString(dst_ip2, dstip2);
if (lll) {
LOG(logINFOGREEN, ("\tVeto (lll) : enabled\n\n"));
} else {
LOG(logINFORED, ("\tVeto (lll) : disabled\n\n"));
}
if (i10gbe) {
LOG(logINFOGREEN, ("\tVeto (10GbE): enabled\n"));
} else {
LOG(logINFORED, ("\tVeto (10GbE): disabled\n"));
}
LOG(logINFO, ("\tSource IP2 : %s\n"
"\tSource MAC2 : %s\n"
"\tSource Port2: %d\n"
"\tDest IP2 : %s\n"
"\tDest MAC2 : %s\n"
"\tDest Port2 : %d\n\n",
src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2));
int i10gbe = (getNumberofUDPInterfaces() == 2 ? 1 : 0);
if (iRxEntry < numUdpDestinations) {
LOG(logINFOBLUE, ("\tEntry %d\n", iRxEntry));
LOG(logINFO, ("\tData Interface \n"));
LOG(logINFO, ("\tSource IP : %s\n"
"\tSource MAC : %s\n"
"\tSource Port : %d\n"
"\tDest IP : %s\n"
"\tDest MAC : %s\n"
"\tDest Port : %d\n\n",
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
if (getVetoStream()) {
LOG(logINFOGREEN, ("\tVeto (lll) : enabled\n\n"));
} else {
LOG(logINFORED, ("\tVeto (lll) : disabled\n\n"));
}
if (i10gbe) {
LOG(logINFOGREEN, ("\tVeto (10GbE): enabled\n"));
} else {
LOG(logINFORED, ("\tVeto (10GbE): disabled\n"));
}
LOG(logINFO,
("\tSource IP2 : %s\n"
"\tSource MAC2 : %s\n"
"\tSource Port2: %d\n"
"\tDest IP2 : %s\n"
"\tDest MAC2 : %s\n"
"\tDest Port2 : %d\n\n",
src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2));
}
#ifdef VIRTUAL
if (setUDPDestinationDetails(0, 0, dst_ip, dstport) == FAIL) {
LOG(logERROR, ("could not set udp destination IP and port\n"));
return FAIL;
}
if (i10gbe && setUDPDestinationDetails(0, 1, dst_ip2, dstport2) == FAIL) {
LOG(logERROR, ("could not set udp destination IP and port for "
"interface 2\n"));
return FAIL;
}
return OK;
if (setUDPDestinationDetails(iRxEntry, 0, dst_ip, dstport) == FAIL) {
LOG(logERROR, ("could not set udp destination IP and port for "
"data interface [entry:%d] \n",
iRxEntry));
return FAIL;
}
if (i10gbe &&
setUDPDestinationDetails(iRxEntry, 1, dst_ip2, dstport2) == FAIL) {
LOG(logERROR, ("could not set udp destination IP and port for "
"veto interface [entry:%d] \n",
iRxEntry));
return FAIL;
}
#endif
// default one rxr entry (others not yet implemented in client yet)
int iRxEntry = 0;
// data
setupHeader(iRxEntry, 0, dstip, dstmac, dstport, srcmac, srcip,
srcport);
// data
setupHeader(iRxEntry, 0, dstip, dstmac, dstport, srcmac, srcip, srcport);
// veto
if (i10gbe) {
setupHeader(iRxEntry, 1, dstip2, dstmac2, dstport2, srcmac2, srcip2,
srcport2);
// veto
if (i10gbe) {
setupHeader(iRxEntry, 1, dstip2, dstmac2, dstport2, srcmac2, srcip2,
srcport2);
}
}
cleanFifos();
resetCore();
// alignDeserializer();
@ -3193,6 +3232,7 @@ void *start_timer(void *arg) {
return NULL;
}
int firstDest = getFirstUDPDestination();
int i10gbe = (getNumberofUDPInterfaces() == 2 ? 1 : 0);
int numRepeats = getNumTriggers();
@ -3249,6 +3289,7 @@ void *start_timer(void *arg) {
*((uint16_t *)(vetoData + i)) = i;
}
int iRxEntry = firstDest;
// loop over number of repeats
for (int repeatNr = 0; repeatNr != numRepeats; ++repeatNr) {
@ -3284,7 +3325,7 @@ void *start_timer(void *arg) {
memcpy(packetData + sizeof(sls_detector_header), imageData,
datasize);
// send 1 packet = 1 frame
sendUDPPacket(0, 0, packetData, packetsize);
sendUDPPacket(iRxEntry, 0, packetData, packetsize);
// second interface (veto)
char packetData2[vetopacketsize];
@ -3298,11 +3339,12 @@ void *start_timer(void *arg) {
memcpy(packetData2 + sizeof(veto_header), vetoData,
vetodatasize);
// send 1 packet = 1 frame
sendUDPPacket(0, 1, packetData2, vetopacketsize);
sendUDPPacket(iRxEntry, 1, packetData2, vetopacketsize);
}
LOG(logINFO, ("Sent frame %s: %d (bursts/ triggers: %d) [%lld]\n",
(i10gbe ? "(+veto)" : ""), frameNr, repeatNr,
(long long unsigned int)virtual_currentFrameNumber));
LOG(logINFO,
("Sent frame %s: %d (bursts/ triggers: %d) [%lld] to E%d\n",
(i10gbe ? "(+veto)" : ""), frameNr, repeatNr,
(long long unsigned int)virtual_currentFrameNumber, iRxEntry));
clock_gettime(CLOCK_REALTIME, &end);
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
(end.tv_nsec - begin.tv_nsec));
@ -3314,6 +3356,10 @@ void *start_timer(void *arg) {
}
}
++virtual_currentFrameNumber;
++iRxEntry;
if (iRxEntry == numUdpDestinations) {
iRxEntry = 0;
}
}
clock_gettime(CLOCK_REALTIME, &rend);
int64_t timeNs = ((rend.tv_sec - rbegin.tv_sec) * 1E9 +

View File

@ -1676,7 +1676,9 @@ void *start_timer(void *arg) {
char imageData[imageSize];
memset(imageData, 0, imageSize);
if (adcConfigured == -1) {
*((uint32_t *)(imageData)) = 0xCACACACA;
// split dereferencing for rhel7 warnings
uint32_t *start = (uint32_t *)imageData;
*start = 0xCACACACA;
}
for (int i = sizeof(uint32_t); i < imageSize; i += sizeof(uint16_t)) {
*((uint16_t *)(imageData + i)) = (uint16_t)i;
@ -1703,7 +1705,9 @@ void *start_timer(void *arg) {
char packetData[packetSize];
memset(packetData, 0, packetSize);
// set header
*((uint16_t *)(packetData)) = virtual_currentFrameNumber;
// split dereferencing for rhel7 warnings
uint16_t *fnum = (uint16_t *)packetData;
*fnum = virtual_currentFrameNumber;
++virtual_currentFrameNumber;
// fill data

View File

@ -523,4 +523,7 @@
#define DEADTIME_EARLY_EXP_FIN_ERR_OFST (4)
#define DEADTIME_EARLY_EXP_FIN_ERR_MSK (0x00000001 << DEADTIME_EARLY_EXP_FIN_ERR_OFST)
/* UDP datagram registers --------------------------------------------------*/
#define RXR_ENDPOINT_OFST (16 * REG_OFFSET)
// clang-format on

View File

@ -28,6 +28,7 @@ extern int debugflag;
extern int updateFlag;
extern int checkModuleFlag;
extern udpStruct udpDetails[MAX_UDP_DESTINATION];
extern int numUdpDestinations;
extern const enum detectorType myDetectorType;
// Global variable from communication_funcs.c
@ -1904,76 +1905,115 @@ int getExtSignal(int signalIndex) {
int getNumberofUDPInterfaces() { return 1; }
int getNumberofDestinations(int *retval) {
*retval = (((bus_r(PKT_CONFIG_REG) & PKT_CONFIG_NRXR_MAX_MSK) >>
PKT_CONFIG_NRXR_MAX_OFST) +
1);
return OK;
}
int setNumberofDestinations(int value) {
LOG(logINFO, ("Setting number of entries to %d\n", value));
--value;
bus_w(PKT_CONFIG_REG, bus_r(PKT_CONFIG_REG) & ~PKT_CONFIG_NRXR_MAX_MSK);
bus_w(PKT_CONFIG_REG,
bus_r(PKT_CONFIG_REG) |
((value << PKT_CONFIG_NRXR_MAX_OFST) & PKT_CONFIG_NRXR_MAX_MSK));
return OK;
}
int getFirstUDPDestination() {
return ((bus_r(PKT_CONFIG_REG) & PKT_CONFIG_RXR_START_ID_MSK) >>
PKT_CONFIG_RXR_START_ID_OFST);
}
void setFirstUDPDestination(int value) {
LOG(logINFO, ("Setting first entry to %d\n", value));
bus_w(PKT_CONFIG_REG, bus_r(PKT_CONFIG_REG) & ~PKT_CONFIG_RXR_START_ID_MSK);
bus_w(PKT_CONFIG_REG,
bus_r(PKT_CONFIG_REG) | ((value << PKT_CONFIG_RXR_START_ID_OFST) &
PKT_CONFIG_RXR_START_ID_MSK));
}
int configureMAC() {
uint32_t srcip = udpDetails[0].srcip;
uint32_t dstip = udpDetails[0].dstip;
uint64_t srcmac = udpDetails[0].srcmac;
uint64_t dstmac = udpDetails[0].dstmac;
int srcport = udpDetails[0].srcport;
int dstport = udpDetails[0].dstport;
LOG(logINFOBLUE, ("Configuring MAC\n"));
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip);
LOG(logINFO, ("Number of entries: %d\n\n", numUdpDestinations));
for (int iRxEntry = 0; iRxEntry != MAX_UDP_DESTINATION; ++iRxEntry) {
LOG(logINFO, ("\tSource IP : %s\n"
"\tSource MAC : %s\n"
"\tSource Port : %d\n"
"\tDest IP : %s\n"
"\tDest MAC : %s\n"
"\tDest Port : %d\n",
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
uint32_t srcip = udpDetails[iRxEntry].srcip;
uint32_t dstip = udpDetails[iRxEntry].dstip;
uint64_t srcmac = udpDetails[iRxEntry].srcmac;
uint64_t dstmac = udpDetails[iRxEntry].dstmac;
int srcport = udpDetails[iRxEntry].srcport;
int dstport = udpDetails[iRxEntry].dstport;
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip);
if (iRxEntry < numUdpDestinations) {
LOG(logINFOBLUE, ("\tEntry %d\n", iRxEntry));
LOG(logINFO, ("\tSource IP : %s\n"
"\tSource MAC : %s\n"
"\tSource Port : %d\n"
"\tDest IP : %s\n"
"\tDest MAC : %s\n"
"\tDest Port : %d\n",
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
}
#ifdef VIRTUAL
if (setUDPDestinationDetails(0, 0, dst_ip, dstport) == FAIL) {
LOG(logERROR, ("could not set udp destination IP and port\n"));
return FAIL;
}
if (setUDPDestinationDetails(iRxEntry, 0, dst_ip, dstport) == FAIL) {
LOG(logERROR, ("could not set udp destination IP and port for "
"data interface [entry:%d] \n",
iRxEntry));
return FAIL;
}
#endif
// start addr
uint32_t addr = BASE_UDP_RAM;
// calculate rxr endpoint offset
// addr += (iRxEntry * RXR_ENDPOINT_OFST);//TODO: is there round robin
// already implemented?
// get struct memory
udp_header *udp =
(udp_header *)(Nios_getBaseAddress() + addr / (sizeof(u_int32_t)));
memset(udp, 0, sizeof(udp_header));
// start addr
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)));
memset(udp, 0, sizeof(udp_header));
// mac addresses
// msb (32) + lsb (16)
udp->udp_destmac_msb = ((dstmac >> 16) & BIT32_MASK);
udp->udp_destmac_lsb = ((dstmac >> 0) & BIT16_MASK);
// msb (16) + lsb (32)
udp->udp_srcmac_msb = ((srcmac >> 32) & BIT16_MASK);
udp->udp_srcmac_lsb = ((srcmac >> 0) & BIT32_MASK);
// mac addresses
// msb (32) + lsb (16)
udp->udp_destmac_msb = ((dstmac >> 16) & BIT32_MASK);
udp->udp_destmac_lsb = ((dstmac >> 0) & BIT16_MASK);
// msb (16) + lsb (32)
udp->udp_srcmac_msb = ((srcmac >> 32) & BIT16_MASK);
udp->udp_srcmac_lsb = ((srcmac >> 0) & BIT32_MASK);
// ip addresses
udp->ip_srcip_msb = ((srcip >> 16) & BIT16_MASK);
udp->ip_srcip_lsb = ((srcip >> 0) & BIT16_MASK);
udp->ip_destip_msb = ((dstip >> 16) & BIT16_MASK);
udp->ip_destip_lsb = ((dstip >> 0) & BIT16_MASK);
// ip addresses
udp->ip_srcip_msb = ((srcip >> 16) & BIT16_MASK);
udp->ip_srcip_lsb = ((srcip >> 0) & BIT16_MASK);
udp->ip_destip_msb = ((dstip >> 16) & BIT16_MASK);
udp->ip_destip_lsb = ((dstip >> 0) & BIT16_MASK);
// source port
udp->udp_srcport = srcport;
udp->udp_destport = dstport;
// source port
udp->udp_srcport = srcport;
udp->udp_destport = dstport;
// other defines
udp->udp_ethertype = 0x800;
udp->ip_ver = 0x4;
udp->ip_ihl = 0x5;
udp->ip_flags = 0x2; // FIXME
udp->ip_ttl = 0x40;
udp->ip_protocol = 0x11;
// total length is redefined in firmware
// other defines
udp->udp_ethertype = 0x800;
udp->ip_ver = 0x4;
udp->ip_ihl = 0x5;
udp->ip_flags = 0x2; // FIXME
udp->ip_ttl = 0x40;
udp->ip_protocol = 0x11;
// total length is redefined in firmware
calcChecksum(udp);
calcChecksum(udp);
if (iRxEntry < numUdpDestinations) {
LOG(logINFO, ("\tIP checksum : 0x%lx\n\n", udp->ip_checksum));
}
}
// TODO?
cleanFifos();
@ -2010,7 +2050,6 @@ void calcChecksum(udp_header *udp) {
sum = (sum & 0xffff) + (sum >> 16); // Fold 32-bit sum to 16 bits
long int checksum = sum & 0xffff;
checksum += UDP_IP_HEADER_LENGTH_BYTES;
LOG(logINFO, ("\tIP checksum is 0x%lx\n", checksum));
udp->ip_checksum = checksum;
}
@ -2460,6 +2499,8 @@ void *start_timer(void *arg) {
return NULL;
}
int firstDest = getFirstUDPDestination();
const int64_t periodNs = getPeriod();
const int numFrames = (getNumFrames() * getNumTriggers());
const int64_t expUs = getGatePeriod() / 1000;
@ -2520,6 +2561,7 @@ void *start_timer(void *arg) {
}
// Send data
int iRxEntry = firstDest;
// loop over number of frames
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
@ -2553,10 +2595,11 @@ void *start_timer(void *arg) {
memcpy(packetData + sizeof(sls_detector_header),
imageData + srcOffset, dataSize);
srcOffset += dataSize;
sendUDPPacket(0, 0, packetData, packetSize);
sendUDPPacket(iRxEntry, 0, packetData, packetSize);
}
LOG(logINFO, ("Sent frame: %d [%lld]\n", frameNr,
(long long unsigned int)virtual_currentFrameNumber));
LOG(logINFO,
("Sent frame: %d [%lld] to E%d\n", frameNr,
(long long unsigned int)virtual_currentFrameNumber, iRxEntry));
clock_gettime(CLOCK_REALTIME, &end);
int64_t timeNs =
((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec));
@ -2568,6 +2611,10 @@ void *start_timer(void *arg) {
}
}
++virtual_currentFrameNumber;
++iRxEntry;
if (iRxEntry == numUdpDestinations) {
iRxEntry = 0;
}
}
closeUDPSocket(0);

View File

@ -435,13 +435,16 @@ void setNumberofUDPInterfaces(int val);
#endif
int getNumberofUDPInterfaces();
#if defined(JUNGFRAUD) || defined(EIGERD)
#if defined(JUNGFRAUD) || defined(EIGERD) || defined(MYTHEN3D) || \
defined(GOTTHARD2D)
int getNumberofDestinations(int *retval);
int setNumberofDestinations(int value);
#endif
#ifdef JUNGFRAUD
#if defined(JUNGFRAUD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
int getFirstUDPDestination();
void setFirstUDPDestination(int value);
#endif
#ifdef JUNGFRAUD
void selectPrimaryInterface(int val);
int getPrimaryInterface();
void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip,

View File

@ -58,7 +58,6 @@ int ignoreConfigFileFlag = 0;
udpStruct udpDetails[MAX_UDP_DESTINATION];
int numUdpDestinations = 1;
int firstUDPDestination = 0;
int configured = FAIL;
char configureMessage[MAX_STR_LENGTH] = "udp parameters not configured yet";
@ -9047,7 +9046,8 @@ int get_dest_udp_list(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Getting udp destination list for entry %d\n", arg));
#if !defined(EIGERD) && !defined(JUNGFRAUD)
#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MYTHEN3D) && \
!defined(GOTTHARD2D)
functionNotImplemented();
#else
if (arg >= MAX_UDP_DESTINATION) {
@ -9114,7 +9114,8 @@ int set_dest_udp_list(int file_des) {
getMacAddressinString(mac, MAC_ADDRESS_SIZE, args64[0]);
getMacAddressinString(mac2, MAC_ADDRESS_SIZE, args64[1]);
#if !defined(EIGERD) && !defined(JUNGFRAUD)
#if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MYTHEN3D) && \
!defined(GOTTHARD2D)
functionNotImplemented();
#else
// only set
@ -9133,7 +9134,7 @@ int set_dest_udp_list(int file_des) {
MAX_UDP_DESTINATION - 1);
LOG(logERROR, (mess));
}
#ifdef EIGERD
#if defined(EIGERD) || defined(MYTHEN3D)
else if (args[4] != 0 || args64[1] != 0) {
ret = FAIL;
strcpy(mess, "Could not set udp destination. ip2 and mac2 not "
@ -9213,14 +9214,11 @@ int set_dest_udp_list(int file_des) {
numdest = 1;
}
// set number of destinations
#if defined(JUNGFRAUD) || defined(EIGERD)
if (setNumberofDestinations(numdest) == FAIL) {
ret = FAIL;
strcpy(mess, "Could not set number of udp destinations.\n");
LOG(logERROR, (mess));
} else
#endif
{
} else {
numUdpDestinations = numdest;
LOG(logINFOBLUE, ("Number of UDP Destinations: %d\n",
numUdpDestinations));
@ -9238,12 +9236,12 @@ int get_num_dest_list(int file_des) {
memset(mess, 0, sizeof(mess));
int retval = -1;
#if !defined(JUNGFRAUD) && !defined(EIGERD)
#if !defined(JUNGFRAUD) && !defined(EIGERD) && !defined(MYTHEN3D) && \
!defined(GOTTHARD2D)
functionNotImplemented();
#else
retval = numUdpDestinations;
LOG(logDEBUG1, ("numUdpDestinations retval: 0x%x\n", retval));
int retval1 = 0;
if (getNumberofDestinations(&retval1) == FAIL || retval1 != retval) {
ret = FAIL;
@ -9253,8 +9251,8 @@ int get_num_dest_list(int file_des) {
retval1, retval);
LOG(logERROR, (mess));
}
#endif
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
@ -9269,7 +9267,8 @@ int clear_all_udp_dst(int file_des) {
// minimum 1 destination in fpga
int numdest = 1;
// set number of destinations
#if defined(JUNGFRAUD) || defined(EIGERD)
#if defined(JUNGFRAUD) || defined(EIGERD) || defined(MYTHEN3D) || \
defined(GOTTHARD2D)
if (setNumberofDestinations(numdest) == FAIL) {
ret = FAIL;
strcpy(mess, "Could not clear udp destinations to 1 entry.\n");
@ -9296,20 +9295,12 @@ int get_udp_first_dest(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
#ifndef JUNGFRAUD
#if !defined(JUNGFRAUD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
retval = firstUDPDestination;
if (getFirstUDPDestination() != retval) {
ret = FAIL;
sprintf(mess,
"Could not get first desintation. (server reads %d, fpga reads "
"%d).\n",
getFirstUDPDestination(), retval);
LOG(logERROR, (mess));
}
#endif
retval = getFirstUDPDestination();
LOG(logDEBUG1, ("first udp destination retval: 0x%x\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
@ -9322,7 +9313,7 @@ int set_udp_first_dest(int file_des) {
return printSocketReadError();
LOG(logDEBUG1, ("Setting first udp destination to %d\n", arg));
#ifndef JUNGFRAUD
#if !defined(JUNGFRAUD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)
functionNotImplemented();
#else
// only set
@ -9338,10 +9329,6 @@ int set_udp_first_dest(int file_des) {
int retval = getFirstUDPDestination();
validate(&ret, mess, arg, retval, "set udp first destination",
DEC);
if (ret == OK) {
firstUDPDestination = arg;
// configure_mac();
}
}
}
}

View File

@ -718,15 +718,17 @@ class Detector {
void setDestinationUDPList(const UdpDestination, const int module_id);
/** [Jungfrau][Eiger] */
/** [Jungfrau][Eiger][Mythen3][Gotthard2] */
Result<int> getNumberofUDPDestinations(Positions pos = {}) const;
void clearUDPDestinations(Positions pos = {});
/** [Jungfrau] */
/** [Jungfrau][Mythen3][Gotthard2] */
Result<int> getFirstUDPDestination(Positions pos = {}) const;
/**[Jungfrau] Options 0-31 (or number of udp destinations) */
/**[Jungfrau][Gotthard2] Options 0-31 (or number of udp destinations)\n
* [Mythen3] Options 0-63 (or number of udp destinations)
*/
void setFirstUDPDestination(const int value, Positions pos = {});
Result<IpAddr> getDestinationUDPIP(Positions pos = {}) const;

View File

@ -1519,9 +1519,10 @@ std::string CmdProxy::UDPDestinationList(int action) {
"\n\t[mac=xx:xx:xx:xx:xx:xx] "
"[(optional)mac2=xx:xx:xx:xx:xx:xx]\n\t[port=value] "
"[(optional)port2=value\n\tThe order of ip, mac and port does "
"not matter. entry_value can be >0 only for Eiger and Jungfrau "
"where round robin is implemented. If 'auto' used, then ip is "
"set to ip of rx_hostname."
"not matter. entry_value can be >0 only for "
"[Eiger][Jungfrau][Mythen3][Gotthard2] where round robin is "
"implemented. If 'auto' used, then ip is set to ip of "
"rx_hostname."
<< '\n';
} else if (action == defs::GET_ACTION) {
if (!args.empty()) {

View File

@ -1600,9 +1600,9 @@ class CmdProxy {
GET_COMMAND(
udp_numdst, getNumberofUDPDestinations,
"\n\t[Jungfrau][Eiger] One can enter upto 32 "
"destinations that the detector will stream images "
"out in a round robin fashion. This is get only command. Default: 1");
"\n\t[Jungfrau][Eiger][Mythen3][Gotthard2] One can enter upto 32 (64 "
"for Mythen3) destinations that the detector will stream images out in "
"a round robin fashion. This is get only command. Default: 1");
EXECUTE_SET_COMMAND(udp_cleardst, clearUDPDestinations,
"\n\tClears udp destination details on the detector.");
@ -1610,11 +1610,11 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID(
udp_firstdst, getFirstUDPDestination, setFirstUDPDestination,
StringTo<int>,
"[0 - 31 (or number of udp destinations)]\n\t[Jungfrau] One can set "
"which is the first "
"destination that the detector will stream images "
"out from in a round robin fashion. The entry must not have been "
"empty. Default: 0");
"\n[0 - 31 (or number of udp "
"destinations)]\n\t[Jungfrau][Gotthard2]\n[0-63]\n\t[Mythen3]\n\n\t "
"One can set which is the first destination that the detector will "
"stream images out from in a round robin fashion. The entry must not "
"have been empty. Default: 0");
INTEGER_COMMAND_VEC_ID(
udp_srcmac, getSourceUDPMAC, setSourceUDPMAC, MacAddr,

View File

@ -2394,7 +2394,8 @@ TEST_CASE("udp_dstlist", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::EIGER) {
if (det_type == defs::JUNGFRAU || det_type == defs::EIGER ||
det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) {
REQUIRE_NOTHROW(proxy.Call("udp_dstlist", {}, 0, GET, std::cout, 0));
REQUIRE_THROWS(proxy.Call(
"udp_dstlist", {"ip=0.0.0.0", "mac=00:00:00:00:00:00", "port=1233"},
@ -2408,7 +2409,8 @@ TEST_CASE("udp_numdst", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU || det_type == defs::EIGER) {
if (det_type == defs::JUNGFRAU || det_type == defs::EIGER ||
det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) {
REQUIRE_NOTHROW(proxy.Call("udp_numdst", {}, -1, GET));
} else {
REQUIRE_THROWS(proxy.Call("udp_numdst", {}, -1, GET));
@ -2427,7 +2429,8 @@ TEST_CASE("udp_firstdst", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU) {
if (det_type == defs::JUNGFRAU || det_type == defs::MYTHEN3 ||
det_type == defs::GOTTHARD2) {
auto prev_val = det.getFirstUDPDestination();
{
std::ostringstream oss;

View File

@ -448,9 +448,9 @@ void Listener::CopyPacket(char *dst, char *src, uint32_t dataSize,
// copy packet data
switch (generalData->detType) {
// for gotthard, 1st packet: 4 bytes fnum, CACA
// + CACA, 639*2 bytes data 2nd packet: 4
// bytes fnum, previous 1*2 bytes data + 640*2 bytes data !!
// for gotthard,
// 1st packet: 4 bytes fnum, CACA + CACA, 639*2 bytes data
// 2nd packet: 4 bytes fnum, previous 1*2 bytes data + 640*2 bytes data
case GOTTHARD:
if (!pnum)
memcpy(dst, &src[detHeaderSize + 4], dataSize - 2);