From 780d4bfe0ade9ada1772c785d504d6874bf64b40 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 15 Jul 2021 16:21:17 +0200 Subject: [PATCH] gotthard2: vetostream (detector: only 3gbe, 10gbe via numudpinterfaces) --- .../gotthard2DetectorServer/RegisterDefs.h | 4 +- .../slsDetectorFunctionList.c | 25 +++++++-- .../include/slsDetectorFunctionList.h | 2 + .../include/slsDetectorServer_funcs.h | 4 +- .../src/slsDetectorServer_funcs.c | 51 +++++++++++++++++++ slsDetectorSoftware/include/sls/Detector.h | 1 - slsDetectorSoftware/src/Detector.cpp | 31 ++++++++--- slsDetectorSoftware/src/Module.cpp | 8 +++ slsDetectorSoftware/src/Module.h | 2 + .../include/sls/sls_detector_funcs.h | 5 ++ 10 files changed, 120 insertions(+), 13 deletions(-) diff --git a/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h b/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h index d9d7c7315..8f9204c3b 100644 --- a/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h +++ b/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h @@ -90,7 +90,9 @@ #define CONFIG_VETO_ENBL_OFST (0) #define CONFIG_VETO_ENBL_MSK (0x00000001 << CONFIG_VETO_ENBL_OFST) -#define CONFIG_VETO_CH_10GB_ENBL_OFST (1) +#define CONFIG_VETO_CH_3GB_ENBL_OFST (11) +#define CONFIG_VETO_CH_3GB_ENBL_MSK (0x00000001 << CONFIG_VETO_CH_3GB_ENBL_OFST) +#define CONFIG_VETO_CH_10GB_ENBL_OFST (15) #define CONFIG_VETO_CH_10GB_ENBL_MSK (0x00000001 << CONFIG_VETO_CH_10GB_ENBL_OFST) /* Control RW register */ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index 21f7baca1..975049e11 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -1581,14 +1581,14 @@ enum timingMode getTiming() { void setNumberofUDPInterfaces(int val) { uint32_t addr = CONFIG_REG; - // 2 interfaces (enable veto) + // 2 rxr interfaces (enable debugging interface) if (val > 1) { - LOG(logINFOBLUE, ("Setting #Interfaces: 2 (10gbps veto streaming)\n")); + LOG(logINFOBLUE, ("Enabling 10GbE (debugging) veto streaming\n")); bus_w(addr, bus_r(addr) | CONFIG_VETO_CH_10GB_ENBL_MSK); } - // 1 interface (disable veto) + // 1 rxr interface (disable debugging interface) else { - LOG(logINFOBLUE, ("Setting #Interfaces: 1 (2.5gbps veto streaming)\n")); + LOG(logINFOBLUE, ("Disabling 10GbE (debugging) veto streaming\n")); bus_w(addr, bus_r(addr) & ~CONFIG_VETO_CH_10GB_ENBL_MSK); } LOG(logDEBUG, ("config reg:0x%x\n", bus_r(addr))); @@ -2578,6 +2578,23 @@ int getVeto() { CONFIG_VETO_ENBL_OFST); } +void setVetoStream(int value) { + uint32_t addr = CONFIG_REG; + + if (value) { + LOG(logINFOBLUE, ("Enabling 3GbE veto streaming\n")); + bus_w(addr, bus_r(addr) | CONFIG_VETO_CH_3GB_ENBL_MSK); + } else { + LOG(logINFOBLUE, ("Disabling 3GbE veto streaming\n")); + bus_w(addr, bus_r(addr) & ~CONFIG_VETO_CH_3GB_ENBL_MSK); + } + LOG(logDEBUG, ("config reg:0x%x\n", bus_r(addr))); +} + +int getVetoStream() { + return ((bus_r(CONFIG_REG) & CONFIG_VETO_CH_3GB_ENBL_MSK) ? 1 : 0); +} + void setBadChannels(int nch, int *channels) { LOG(logINFO, ("Setting %d bad channels\n", nch)); diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 84103f61f..72401feed 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -540,6 +540,8 @@ void setTimingSource(enum timingSourceType value); enum timingSourceType getTimingSource(); void setVeto(int enable); int getVeto(); +void setVetoStream(int value); +int getVetoStream(); void setBadChannels(int nch, int *channels); int *getBadChannels(int *nch); #endif diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index 62a947254..36a8c96b7 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -246,4 +246,6 @@ int is_virtual(int); int get_pattern(int); int load_default_pattern(int); int get_all_threshold_energy(int); -int get_master(int); \ No newline at end of file +int get_master(int); +int get_veto_stream(int); +int set_veto_stream(int); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index e3f8d4126..07abf900b 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -369,6 +369,8 @@ void function_table() { flist[F_LOAD_DEFAULT_PATTERN] = &load_default_pattern; flist[F_GET_ALL_THRESHOLD_ENERGY] = &get_all_threshold_energy; flist[F_GET_MASTER] = &get_master; + flist[F_GET_VETO_STREAM] = &get_veto_stream; + flist[F_SET_VETO_STREAM] = &set_veto_stream; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { @@ -8406,3 +8408,52 @@ int get_master(int file_des){ #endif return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } + +int get_veto_stream(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + enum EthernetInterface retval = NONE; + + LOG(logDEBUG1, ("Getting veto stream\n")); + +#ifndef GOTTHARD2D + functionNotImplemented(); +#else + // get only + retval = getVetoStream(); + LOG(logDEBUG1, ("vetostream retval: %u\n", retval)); +#endif + return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); +} + +int set_veto_stream(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + enum EthernetInterface arg = 0; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + LOG(logINFO, ("Setting vetostream: %u\n", (int)arg)); + +#ifndef GOTTHARD2D + functionNotImplemented(); +#else + // only set + if (Server_VerifyLock() == OK) { + + if (arg != 0 && arg != 1) { + ret = FAIL; + sprintf(mess, + "Could not set vetostream 3GbE. Invalid argument %d.\n", + arg); + LOG(logERROR, (mess)); + } else { + setVetoStream(arg); + int retval = getVetoStream(); + LOG(logDEBUG1, ("vetostream retval: %u\n", retval)); + validate(arg, retval, "set veto stream", DEC); + } + } +#endif + return Server_SendResult(file_des, INT32, NULL, 0); +} \ No newline at end of file diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index 0e6fe9aee..06993bc85 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -1739,7 +1739,6 @@ class Detector { private: std::vector getPortNumbers(int start_port); void updateRxRateCorrections(); - defs::EthernetInterface in_{defs::EthernetInterface::NONE}; }; } // namespace sls \ No newline at end of file diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 8acddfe15..3d6c2f410 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1548,16 +1548,35 @@ void Detector::setVeto(bool enable, Positions pos) { } Result Detector::getVetoStream(Positions pos) const { - // return pimpl->Parallel(&Module::getVetoStream, pos); - Result res(1); - res[0] = in_; + // 3gbe + auto r3 = pimpl->Parallel(&Module::getVetoStream, pos); + // 10gbe (debugging interface) opens 2nd udp interface in receiver + auto r10 = getNumberofUDPInterfaces(); + + Result res(r3.size()); + for (unsigned int i = 0; i < res.size(); ++i) { + res[i] = (r3[i] ? defs::EthernetInterface::I3GBE + : defs::EthernetInterface::NONE); + if (r10[i] == 2) { + res[i] = res[i] | defs::EthernetInterface::I10GBE; + } + } return res; } void Detector::setVetoStream(defs::EthernetInterface interface, Positions pos) { - // pimpl->Parallel(&Module::setVetoStream, pos, enable); - in_ = interface; -} + // 3gbe + bool i3gbe = (interface & defs::EthernetInterface::I3GBE); + pimpl->Parallel(&Module::setVetoStream, pos, i3gbe); + + // 10gbe (debugging interface) opens 2nd udp interface in receiver + int old_numinterfaces = getNumberofUDPInterfaces(pos).tsquash( + "retrieved inconsistent number of udp interfaces"); + int numinterfaces = (interface & defs::EthernetInterface::I10GBE) ? 2 : 1; + if (numinterfaces != old_numinterfaces) { + setNumberofUDPInterfaces(numinterfaces, pos); + } + } Result Detector::getADCConfiguration(const int chipIndex, const int adcIndex, diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index c5a570ea7..c93fca57b 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -1870,6 +1870,14 @@ void Module::setVeto(bool enable) { sendToDetector(F_SET_VETO, static_cast(enable), nullptr); } +bool Module::getVetoStream() const { + return (sendToDetector(F_GET_VETO_STREAM)); +} + +void Module::setVetoStream(const bool value) { + sendToDetector(F_SET_VETO_STREAM, static_cast(value), nullptr); +} + int Module::getADCConfiguration(const int chipIndex, const int adcIndex) const { int args[]{chipIndex, adcIndex}; return sendToDetector(F_GET_ADC_CONFIGURATION, args); diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index a1c52d0f7..81f6bfee1 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -406,6 +406,8 @@ class Module : public virtual slsDetectorDefs { void setTimingSource(slsDetectorDefs::timingSourceType value); bool getVeto() const; void setVeto(bool enable); + bool getVetoStream() const; + void setVetoStream(const bool value); int getADCConfiguration(const int chipIndex, const int adcIndex) const; void setADCConfiguration(const int chipIndex, const int adcIndex, int value); diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index 9abb18d7f..34a772671 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -221,6 +221,8 @@ enum detFuncs { F_LOAD_DEFAULT_PATTERN, F_GET_ALL_THRESHOLD_ENERGY, F_GET_MASTER, + F_GET_VETO_STREAM, + F_SET_VETO_STREAM, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 256, /**< detector function should not exceed this @@ -548,6 +550,9 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_LOAD_DEFAULT_PATTERN: return "F_LOAD_DEFAULT_PATTERN"; case F_GET_ALL_THRESHOLD_ENERGY: return "F_GET_ALL_THRESHOLD_ENERGY"; case F_GET_MASTER: return "F_GET_MASTER"; + case F_GET_VETO_STREAM: return "F_GET_VETO_STREAM"; + case F_SET_VETO_STREAM: return "F_SET_VETO_STREAM"; + case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";