vetoalg added hits and raw

This commit is contained in:
maliakal_d 2021-08-11 16:08:32 +02:00
parent 0dbb6ff512
commit 7a76064223
13 changed files with 120 additions and 77 deletions

View File

@ -2448,10 +2448,15 @@ class Detector(CppDetectorApi):
@property
def vetoalg(self):
"""[Gotthard2] Algorithm used for veto
"""[Gotthard2] Algorithm used for veto. Enum: vetoAlgorithm, streamingInterface
Note
----
Options:
(vetoAlgorithm): ALG_HITS, ALG_RAW
(streamingInterface): ETHERNET_10GB, LOW_LATENCY_LINK
Example
----------
>>> d.vetoalg = defs.DEFAULT_ALGORITHM, defs.ETHERNET_10GB
>>> d.vetoalg = defs.ALG_HITS, defs.ETHERNET_10GB
"""
result = {}
interface = [streamingInterface.LOW_LATENCY_LINK, streamingInterface.ETHERNET_10GB]

View File

@ -303,8 +303,8 @@ void init_enums(py::module &m) {
&operator&));
py::enum_<slsDetectorDefs::vetoAlgorithm>(Defs, "vetoAlgorithm")
.value("DEFAULT_ALGORITHM",
slsDetectorDefs::vetoAlgorithm::DEFAULT_ALGORITHM)
.value("ALG_HITS", slsDetectorDefs::vetoAlgorithm::ALG_HITS)
.value("ALG_RAW", slsDetectorDefs::vetoAlgorithm::ALG_RAW)
.export_values();
py::enum_<slsDetectorDefs::gainMode>(Defs, "gainMode")

View File

@ -90,16 +90,16 @@
#define CONFIG_VETO_ENBL_OFST (0)
#define CONFIG_VETO_ENBL_MSK (0x00000001 << CONFIG_VETO_ENBL_OFST)
#define CONFIG_VETO_CH_3GB_ALG_OFST (8)
#define CONFIG_VETO_CH_3GB_ALG_MSK (0x00000007 << CONFIG_VETO_CH_3GB_ALG_OFST)
#define CONFIG_VETO_CH_3GB_ALG_DEFAULT_VAL ((0x0 << CONFIG_VETO_CH_3GB_ALG_OFST) & CONFIG_VETO_CH_3GB_ALG_MSK)
#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_ALG_OFST (12)
#define CONFIG_VETO_CH_10GB_ALG_MSK (0x00000007 << CONFIG_VETO_CH_10GB_ALG_OFST)
#define CONFIG_VETO_CH_10GB_ALG_DEFAULT_VAL ((0x0 << CONFIG_VETO_CH_10GB_ALG_OFST) & CONFIG_VETO_CH_10GB_ALG_MSK)
#define CONFIG_VETO_CH_10GB_ENBL_OFST (15)
#define CONFIG_VETO_CH_10GB_ENBL_MSK (0x00000001 << CONFIG_VETO_CH_10GB_ENBL_OFST)
#define CONFIG_VETO_CH_LLL_ALG_OFST (8)
#define CONFIG_VETO_CH_LLL_ALG_MSK (0x00000007 << CONFIG_VETO_CH_LLL_ALG_OFST)
#define CONFIG_VETO_CH_LLL_ENBL_OFST (11)
#define CONFIG_VETO_CH_LLL_ENBL_MSK (0x00000001 << CONFIG_VETO_CH_LLL_ENBL_OFST)
#define CONFIG_VETO_CH_10GBE_ALG_OFST (12)
#define CONFIG_VETO_CH_10GBE_ALG_MSK (0x00000007 << CONFIG_VETO_CH_10GBE_ALG_OFST)
#define CONFIG_VETO_CH_10GBE_ENBL_OFST (15)
#define CONFIG_VETO_CH_10GBE_ENBL_MSK (0x00000001 << CONFIG_VETO_CH_10GBE_ENBL_OFST)
#define ALGORITHM_HITS_VAL (0x0)
#define ALGORITHM_RAW_VAL (0x7)
/* Control RW register */
#define CONTROL_REG (0x09 * REG_OFFSET + BASE_CONTROL)

View File

@ -481,6 +481,8 @@ void setupDetector() {
setBurstPeriod(DEFAULT_BURST_PERIOD);
setTiming(DEFAULT_TIMING_MODE);
setCurrentSource(DEFAULT_CURRENT_SOURCE);
setVetoAlgorithm(DEFAULT_ALGORITHM, LOW_LATENCY_LINK);
setVetoAlgorithm(DEFAULT_ALGORITHM, ETHERNET_10GB);
}
int resetToDefaultDacs(int hardReset) {
@ -1620,12 +1622,12 @@ void setNumberofUDPInterfaces(int val) {
// 2 rxr interfaces (enable debugging interface)
if (val > 1) {
LOG(logINFOBLUE, ("Enabling 10GbE (debugging) veto streaming\n"));
bus_w(addr, bus_r(addr) | CONFIG_VETO_CH_10GB_ENBL_MSK);
bus_w(addr, bus_r(addr) | CONFIG_VETO_CH_10GBE_ENBL_MSK);
}
// 1 rxr interface (disable debugging interface)
else {
LOG(logINFOBLUE, ("Disabling 10GbE (debugging) veto streaming\n"));
bus_w(addr, bus_r(addr) & ~CONFIG_VETO_CH_10GB_ENBL_MSK);
bus_w(addr, bus_r(addr) & ~CONFIG_VETO_CH_10GBE_ENBL_MSK);
}
LOG(logDEBUG, ("config reg:0x%x\n", bus_r(addr)));
}
@ -1633,7 +1635,7 @@ void setNumberofUDPInterfaces(int val) {
int getNumberofUDPInterfaces() {
LOG(logDEBUG, ("config reg:0x%x\n", bus_r(CONFIG_REG)));
// return 2 if 10gbps veto streaming enabled, else 1
return ((bus_r(CONFIG_REG) & CONFIG_VETO_CH_10GB_ENBL_MSK) ? 2 : 1);
return ((bus_r(CONFIG_REG) & CONFIG_VETO_CH_10GBE_ENBL_MSK) ? 2 : 1);
}
void setupHeader(int iRxEntry, int vetoInterface, uint32_t destip,
@ -1756,9 +1758,9 @@ int configureMAC() {
int i10gbe = (getNumberofUDPInterfaces() == 2 ? 1 : 0);
if (lll) {
LOG(logINFOGREEN, ("\tVeto (3GbE) : enabled\n\n"));
LOG(logINFOGREEN, ("\tVeto (lll) : enabled\n\n"));
} else {
LOG(logINFORED, ("\tVeto (3GbE) : disabled\n\n"));
LOG(logINFORED, ("\tVeto (lll) : disabled\n\n"));
}
if (i10gbe) {
LOG(logINFOGREEN, ("\tVeto (10GbE): enabled\n"));
@ -2629,65 +2631,73 @@ 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);
LOG(logINFOBLUE, ("Enabling lll veto streaming\n"));
bus_w(addr, bus_r(addr) | CONFIG_VETO_CH_LLL_ENBL_MSK);
} else {
LOG(logINFOBLUE, ("Disabling 3GbE veto streaming\n"));
bus_w(addr, bus_r(addr) & ~CONFIG_VETO_CH_3GB_ENBL_MSK);
LOG(logINFOBLUE, ("Disabling lll veto streaming\n"));
bus_w(addr, bus_r(addr) & ~CONFIG_VETO_CH_LLL_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);
return ((bus_r(CONFIG_REG) & CONFIG_VETO_CH_LLL_ENBL_MSK) ? 1 : 0);
}
enum vetoAlgorithm getVetoAlgorithm(enum streamingInterface interface) {
// 3gbe
int retval = 0;
if (interface == LOW_LATENCY_LINK) {
int retval = ((bus_r(CONFIG_REG) & CONFIG_VETO_CH_3GB_ALG_MSK) >>
CONFIG_VETO_CH_3GB_ALG_OFST);
switch (retval) {
// more to follow
case CONFIG_VETO_CH_3GB_ALG_DEFAULT_VAL:
return DEFAULT_ALGORITHM;
default:
LOG(logERROR, ("unknown algorithm %d for 3gbe\n", retval));
return -1;
retval = ((bus_r(CONFIG_REG) & CONFIG_VETO_CH_LLL_ALG_MSK) >>
CONFIG_VETO_CH_LLL_ALG_OFST);
} else {
retval = ((bus_r(CONFIG_REG) & CONFIG_VETO_CH_10GBE_ALG_MSK) >>
CONFIG_VETO_CH_10GBE_ALG_OFST);
}
}
// 10gbe
int retval = ((bus_r(CONFIG_REG) & CONFIG_VETO_CH_10GB_ALG_MSK) >>
CONFIG_VETO_CH_10GB_ALG_OFST);
switch (retval) {
// more to follow
case CONFIG_VETO_CH_10GB_ALG_DEFAULT_VAL:
return DEFAULT_ALGORITHM;
case ALGORITHM_HITS_VAL:
return ALG_HITS;
case ALGORITHM_RAW_VAL:
return ALG_RAW;
default:
LOG(logERROR, ("unknown algorithm %d for 3gbe\n", retval));
LOG(logERROR, ("unknown algorithm %d\n", retval));
return -1;
}
}
void setVetoAlgorithm(enum streamingInterface interface,
enum vetoAlgorithm alg) {
void setVetoAlgorithm(enum vetoAlgorithm alg,
enum streamingInterface interface) {
uint32_t addr = CONFIG_REG;
uint32_t value = bus_r(addr);
switch (alg) {
// more to follow
case DEFAULT_ALGORITHM:
case ALG_HITS:
if (interface == LOW_LATENCY_LINK) {
LOG(logINFO, ("Setting default veto algorithm for 3Gbe\n"));
value &= (~CONFIG_VETO_CH_3GB_ALG_MSK);
value |= CONFIG_VETO_CH_3GB_ALG_DEFAULT_VAL;
LOG(logINFO, ("Setting veto algorithm [lll]: hits\n"));
value &= (~CONFIG_VETO_CH_LLL_ALG_MSK);
value |= ((ALGORITHM_HITS_VAL << CONFIG_VETO_CH_LLL_ALG_OFST) &
CONFIG_VETO_CH_LLL_ALG_MSK);
} else {
LOG(logINFO, ("Setting default veto algorithm for 10Gbe\n"));
value &= (~CONFIG_VETO_CH_10GB_ALG_MSK);
value |= CONFIG_VETO_CH_10GB_ALG_DEFAULT_VAL;
LOG(logINFO, ("Setting veto algorithm [10Gbe]: hits\n"));
value &= (~CONFIG_VETO_CH_10GBE_ALG_MSK);
value |= ((ALGORITHM_HITS_VAL << CONFIG_VETO_CH_10GBE_ALG_OFST) &
CONFIG_VETO_CH_10GBE_ALG_MSK);
}
break;
case ALG_RAW:
if (interface == LOW_LATENCY_LINK) {
LOG(logINFO, ("Setting veto algorithm [lll]: raw\n"));
value &= (~CONFIG_VETO_CH_LLL_ALG_MSK);
value |= ((ALGORITHM_RAW_VAL << CONFIG_VETO_CH_LLL_ALG_OFST) &
CONFIG_VETO_CH_LLL_ALG_MSK);
} else {
LOG(logINFO, ("Setting veto algorithm [10Gbe]: raw\n"));
value &= (~CONFIG_VETO_CH_10GBE_ALG_MSK);
value |= ((ALGORITHM_RAW_VAL << CONFIG_VETO_CH_10GBE_ALG_OFST) &
CONFIG_VETO_CH_10GBE_ALG_MSK);
}
break;
default:
LOG(logERROR, ("unknown algorithm %d for 3gbe\n", alg));
LOG(logERROR, ("unknown algorithm %d for lll\n", alg));
return;
}
bus_w(addr, value);

View File

@ -49,6 +49,7 @@
#define DEFAULT_SETTINGS (DYNAMICGAIN)
#define DEFAULT_CURRENT_SOURCE (0)
#define DEFAULT_TIMING_SOURCE (TIMING_INTERNAL)
#define DEFAULT_ALGORITHM (ALG_HITS)
#define DEFAULT_READOUT_C0 (6) //(144444448) // rdo_clk, 144 MHz
#define DEFAULT_READOUT_C1 (6) //(144444448) // rdo_x2_clk, 144 MHz
@ -62,6 +63,10 @@
#define INT_SYSTEM_C0_FREQUENCY (144000000) // 144 MHz
#define READOUT_PLL_VCO_FREQ_HZ (866666688) // 866 MHz
#define SYSTEM_PLL_VCO_FREQ_HZ (722222224) // 722 MHz
#define ALGORITHM_HITS_VAL (0x0)
#define ALGORITHM_RAW_VAL (0x7)
#define VETO_DATA_SIZE (160)
typedef struct {
uint64_t frameNumber;

View File

@ -554,7 +554,8 @@ int getVeto();
void setVetoStream(int value);
int getVetoStream();
enum vetoAlgorithm getVetoAlgorithm(enum streamingInterface interface);
void setVetoAlgorithm(enum streamingInterface interface, enum vetoAlgorithm alg);
void setVetoAlgorithm(enum vetoAlgorithm alg,
enum streamingInterface interface);
void setBadChannels(int nch, int *channels);
int *getBadChannels(int *nch);
#endif

View File

@ -8519,7 +8519,7 @@ int get_veto_algorithm(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
enum streamingInterface arg = NONE;
enum vetoAlgorithm retval = DEFAULT_ALGORITHM;
enum vetoAlgorithm retval = ALG_HITS;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
@ -8551,7 +8551,7 @@ int set_veto_algorithm(int file_des) {
enum vetoAlgorithm alg = args[0];
enum streamingInterface interface = args[1];
LOG(logDEBUG1, ("Setting vetoalgorithm (interface: %d): %u\n", (int)interface,
LOG(logINFOBLUE, ("Setting vetoalgorithm (interface: %d): %u\n", (int)interface,
(int)alg));
#ifndef GOTTHARD2D
@ -8565,13 +8565,17 @@ int set_veto_algorithm(int file_des) {
"Could not set vetoalgorithm. Invalid interface %d.\n",
interface);
LOG(logERROR, (mess));
} else if (alg != DEFAULT_ALGORITHM) {
ret = FAIL;
sprintf(mess,
"Could not set vetoalgorithm. Invalid algorithm %d.\n",
alg);
LOG(logERROR, (mess));
} else {
switch (alg) {
case ALG_HITS:
case ALG_RAW:
break;
default:
modeNotImplemented("Veto Algorithm index", (int)alg);
break;
}
}
if (ret == OK) {
setVetoAlgorithm(alg, interface);
int retval = getVetoAlgorithm(interface);
LOG(logDEBUG1, ("vetoalgorithm retval: %u\n", retval));

View File

@ -1337,7 +1337,7 @@ class Detector {
getVetoAlgorithm(const defs::streamingInterface value,
Positions pos = {}) const;
/** [Gotthard2] Options(vetoAlgorithm): DEFAULT_ALGORITHM.
/** [Gotthard2] Options(vetoAlgorithm): ALG_HITS, ALG_RAW.
* Options(streamingInterface): LOW_LATENCY_LINK, ETHERNET_10GB */
void setVetoAlgorithm(const defs::vetoAlgorithm alg,
const defs::streamingInterface value,

View File

@ -2051,7 +2051,7 @@ std::string CmdProxy::VetoAlgorithm(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[default] [lll|10gbe]\n\t[Gotthard2] Set the veto "
os << "[hits|raw] [lll|10gbe]\n\t[Gotthard2] Set the veto "
"algorithm."
<< '\n';
} else if (action == defs::GET_ACTION) {

View File

@ -1688,6 +1688,8 @@ Detector::getVetoAlgorithm(const defs::streamingInterface interface,
void Detector::setVetoAlgorithm(const defs::vetoAlgorithm alg,
defs::streamingInterface interface,
Positions pos) {
LOG(logINFOBLUE) << "alg:" << ToString(alg)
<< " interface:" << ToString(interface);
pimpl->Parallel(&Module::setVetoAlgorithm, pos, alg, interface);
}

View File

@ -631,34 +631,46 @@ TEST_CASE("vetoalg", "[.cmd]") {
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD2) {
auto prev_val_3g = det.getVetoAlgorithm(defs::streamingInterface::LOW_LATENCY_LINK);
auto prev_val_lll =
det.getVetoAlgorithm(defs::streamingInterface::LOW_LATENCY_LINK);
auto prev_val_10g =
det.getVetoAlgorithm(defs::streamingInterface::ETHERNET_10GB);
{
std::ostringstream oss;
proxy.Call("vetoalg", {"default", "lll"}, -1, PUT, oss);
REQUIRE(oss.str() == "vetoalg default lll\n");
proxy.Call("vetoalg", {"hits", "lll"}, -1, PUT, oss);
REQUIRE(oss.str() == "vetoalg hits lll\n");
}
{
std::ostringstream oss;
proxy.Call("vetoalg", {"lll"}, -1, GET, oss);
REQUIRE(oss.str() == "vetoalg default lll\n");
REQUIRE(oss.str() == "vetoalg hits lll\n");
}
{
std::ostringstream oss;
proxy.Call("vetoalg", {"default", "10gbe"}, -1, PUT, oss);
REQUIRE(oss.str() == "vetoalg default 10gbe\n");
proxy.Call("vetoalg", {"hits", "10gbe"}, -1, PUT, oss);
REQUIRE(oss.str() == "vetoalg hits 10gbe\n");
}
{
std::ostringstream oss;
proxy.Call("vetoalg", {"10gbe"}, -1, GET, oss);
REQUIRE(oss.str() == "vetoalg default 10gbe\n");
REQUIRE(oss.str() == "vetoalg hits 10gbe\n");
}
{
std::ostringstream oss;
proxy.Call("vetoalg", {"raw", "lll"}, -1, PUT, oss);
REQUIRE(oss.str() == "vetoalg raw lll\n");
}
{
std::ostringstream oss;
proxy.Call("vetoalg", {"raw", "10gbe"}, -1, PUT, oss);
REQUIRE(oss.str() == "vetoalg raw 10gbe\n");
}
REQUIRE_THROWS(
proxy.Call("vetoalg", {"default", "lll", "10gbe"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("vetoalg", {"default", "none"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("vetoalg", {"hits", "none"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
det.setVetoAlgorithm(prev_val_3g[i], defs::streamingInterface::LOW_LATENCY_LINK,
det.setVetoAlgorithm(prev_val_lll[i],
defs::streamingInterface::LOW_LATENCY_LINK,
{i});
det.setVetoAlgorithm(prev_val_10g[i],
defs::streamingInterface::ETHERNET_10GB, {i});

View File

@ -413,7 +413,7 @@ typedef struct {
ALL = LOW_LATENCY_LINK | ETHERNET_10GB
};
enum vetoAlgorithm { DEFAULT_ALGORITHM };
enum vetoAlgorithm { ALG_HITS, ALG_RAW };
enum gainMode {
DYNAMIC,

View File

@ -608,8 +608,10 @@ std::string ToString(const defs::streamingInterface s) {
std::string ToString(const defs::vetoAlgorithm s) {
switch (s) {
case defs::DEFAULT_ALGORITHM:
return std::string("default");
case defs::ALG_HITS:
return std::string("hits");
case defs::ALG_RAW:
return std::string("raw");
default:
return std::string("Unknown");
}
@ -1014,8 +1016,10 @@ template <> defs::streamingInterface StringTo(const std::string &s) {
}
template <> defs::vetoAlgorithm StringTo(const std::string &s) {
if (s == "default")
return defs::DEFAULT_ALGORITHM;
if (s == "hits")
return defs::ALG_HITS;
if (s == "raw")
return defs::ALG_RAW;
throw sls::RuntimeError("Unknown veto algorithm " + s);
}