From 3d47db7e6003f3e4e313fbed2c4e7931badd589b Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 22 Jul 2021 13:47:18 +0200 Subject: [PATCH] bug fix for virtual datastream and client --- .../slsDetectorFunctionList.c | 47 ++++++++++--------- .../src/slsDetectorServer_funcs.c | 42 ----------------- slsDetectorSoftware/src/Detector.cpp | 5 +- 3 files changed, 27 insertions(+), 67 deletions(-) diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index e09a53146..c7a9814fe 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -1707,30 +1707,34 @@ int configureMAC() { getIpAddressinString(src_ip2, srcip2); getIpAddressinString(dst_ip2, dstip2); - int numInterfaces = getNumberofUDPInterfaces(); - int vetoEnabled = getVeto(); - - LOG(logINFO, ("\t#Veto : %d\n", vetoEnabled)); - LOG(logINFO, ("\t#10Gb Interfaces : %d\n", numInterfaces)); - 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", + "\tDest Port : %d\n\n", src_ip, src_mac, srcport, dst_ip, dst_mac, dstport)); - LOG(logINFO, - ("\tVeto Interface (%s)\n", - (vetoEnabled && numInterfaces == 2 ? "enabled" : "disabled"))); + int i3gbe = getVetoStream(); + int i10gbe = (getNumberofUDPInterfaces() == 2 ? 1 : 0); + + if (i3gbe) { + LOG(logINFOGREEN, ("\tVeto (3GbE) : enabled\n\n")); + } else { + LOG(logINFORED, ("\tVeto (3GbE) : 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", + "\tDest Port2 : %d\n\n", src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2)); #ifdef VIRTUAL @@ -1738,8 +1742,7 @@ int configureMAC() { LOG(logERROR, ("could not set udp destination IP and port\n")); return FAIL; } - if (vetoEnabled && numInterfaces == 2 && - setUDPDestinationDetails(1, dst_ip2, dstport2) == FAIL) { + if (i10gbe && setUDPDestinationDetails(1, dst_ip2, dstport2) == FAIL) { LOG(logERROR, ("could not set udp destination IP and port for " "interface 2\n")); return FAIL; @@ -1753,7 +1756,7 @@ int configureMAC() { setupHeader(iRxEntry, 0, dstip, dstmac, dstport, srcmac, srcip, srcport); // veto - if (vetoEnabled && numInterfaces == 2) { + if (i10gbe) { setupHeader(iRxEntry, 1, dstip2, dstmac2, dstport2, srcmac2, srcip2, srcport2); } @@ -2699,8 +2702,7 @@ int startStateMachine() { if (createUDPSocket(0) != OK) { return FAIL; } - if (getVeto() && getNumberofUDPInterfaces() == 2 && - createUDPSocket(1) != OK) { + if (getNumberofUDPInterfaces() == 2 && createUDPSocket(1) != OK) { return FAIL; } LOG(logINFOBLUE, ("Starting State Machine\n")); @@ -2735,8 +2737,7 @@ void *start_timer(void *arg) { return NULL; } - int numInterfaces = getNumberofUDPInterfaces(); - int vetoEnabled = getVeto(); + int i10gbe = (getNumberofUDPInterfaces() == 2 ? 1 : 0); int numRepeats = getNumTriggers(); if (getTiming() == AUTO_TIMING) { @@ -2818,7 +2819,7 @@ void *start_timer(void *arg) { // second interface (veto) char packetData2[vetopacketsize]; memset(packetData2, 0, vetopacketsize); - if (vetoEnabled && numInterfaces == 2) { + if (i10gbe) { // set header veto_header *header = (veto_header *)(packetData2); header->frameNumber = virtual_currentFrameNumber; @@ -2829,9 +2830,9 @@ void *start_timer(void *arg) { // send 1 packet = 1 frame sendUDPPacket(1, packetData2, vetopacketsize); } - LOG(logINFO, - ("Sent frame: %d (bursts/ triggers: %d) [%lld]\n", frameNr, - repeatNr, (long long unsigned int)virtual_currentFrameNumber)); + LOG(logINFO, ("Sent frame %s: %d (bursts/ triggers: %d) [%lld]\n", + (i10gbe ? "(+veto)" : ""), frameNr, repeatNr, + (long long unsigned int)virtual_currentFrameNumber)); clock_gettime(CLOCK_REALTIME, &end); int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec)); @@ -2857,7 +2858,7 @@ void *start_timer(void *arg) { } closeUDPSocket(0); - if (vetoEnabled && numInterfaces == 2) { + if (i10gbe) { closeUDPSocket(1); } diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 083bee508..3ce2cacb7 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -7529,49 +7529,7 @@ int get_veto(int file_des) { #endif return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } -/* -int set_veto(int file_des) { - ret = OK; - memset(mess, 0, sizeof(mess)); - int arg = 0; - if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) - return printSocketReadError(); - LOG(logINFO, ("Setting veto mode: %u\n", arg)); - -#ifndef GOTTHARD2D - functionNotImplemented(); -#else - // only set - if (Server_VerifyLock() == OK) { - setVeto(arg); - // if numinterfaces is 2 and veto is 1 now, then configuremac - if (arg > 0 && getNumberofUDPInterfaces() == 2 && - is_udp_configured() == OK) { - ret = configureMAC(); - if (ret != OK) { - sprintf(mess, "Configure Mac failed after enabling veto\n"); - strcpy(configureMessage, mess); - LOG(logERROR, (mess)); - configured = FAIL; - LOG(logWARNING, ("Configure FAIL, not all parameters " - "configured yet\n")); - - } else { - LOG(logINFOGREEN, ("\tConfigure MAC successful\n")); - configured = OK; - } - } - if (ret == OK) { - int retval = getVeto(); - LOG(logDEBUG1, ("veto mode retval: %u\n", retval)); - validate(arg, retval, "set veto mode", DEC); - } - } -#endif - return Server_SendResult(file_des, INT32, NULL, 0); -} -*/ int set_veto(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 1a6bd84fc..866af9362 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1592,7 +1592,7 @@ void Detector::setVetoStream(defs::ethernetInterface interface, Positions pos) { int old_numinterfaces = getNumberofUDPInterfaces_(pos).tsquash( "retrieved inconsistent number of udp interfaces"); int numinterfaces = ((interface & defs::ethernetInterface::I10GBE) == - defs::ethernetInterface::I3GBE) + defs::ethernetInterface::I10GBE) ? 2 : 1; if (numinterfaces != old_numinterfaces) { @@ -2142,7 +2142,8 @@ std::vector Detector::getPortNumbers(int start_port) { num_sockets_per_detector *= 2; break; case defs::JUNGFRAU: - if (getNumberofUDPInterfaces().squash() == 2) { + case defs::GOTTHARD2: + if (getNumberofUDPInterfaces_({}).squash() == 2) { num_sockets_per_detector *= 2; } break;