gotthard2: vetostream (detector: only 3gbe, 10gbe via numudpinterfaces)

This commit is contained in:
maliakal_d 2021-07-15 16:21:17 +02:00
parent 4d7fb4e4e0
commit 780d4bfe0a
10 changed files with 120 additions and 13 deletions

View File

@ -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 */

View File

@ -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));

View File

@ -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

View File

@ -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);
int get_master(int);
int get_veto_stream(int);
int set_veto_stream(int);

View File

@ -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);
}

View File

@ -1739,7 +1739,6 @@ class Detector {
private:
std::vector<int> getPortNumbers(int start_port);
void updateRxRateCorrections();
defs::EthernetInterface in_{defs::EthernetInterface::NONE};
};
} // namespace sls

View File

@ -1548,16 +1548,35 @@ void Detector::setVeto(bool enable, Positions pos) {
}
Result<defs::EthernetInterface> Detector::getVetoStream(Positions pos) const {
// return pimpl->Parallel(&Module::getVetoStream, pos);
Result<defs::EthernetInterface> 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<defs::EthernetInterface> 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<int> Detector::getADCConfiguration(const int chipIndex,
const int adcIndex,

View File

@ -1870,6 +1870,14 @@ void Module::setVeto(bool enable) {
sendToDetector(F_SET_VETO, static_cast<int>(enable), nullptr);
}
bool Module::getVetoStream() const {
return (sendToDetector<int>(F_GET_VETO_STREAM));
}
void Module::setVetoStream(const bool value) {
sendToDetector(F_SET_VETO_STREAM, static_cast<int>(value), nullptr);
}
int Module::getADCConfiguration(const int chipIndex, const int adcIndex) const {
int args[]{chipIndex, adcIndex};
return sendToDetector<int>(F_GET_ADC_CONFIGURATION, args);

View File

@ -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);

View File

@ -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";