M3badchannels (#526)

* badchannels for m3 and modify for g2 (file from single and multi)

* m3: invert polarity of bit 7 and 11 signals from setmodule, allow commas in bad channel file

* badchannel file can take commas, colons and comments (also taking care of spaces at the end of channel numbers)

* tests 'badchannels' and 'Channel file reading' added, removing duplicates in badchannel list, defining macro for num counters in client side

* fix segfault when list from file is empty, 

* fix tests assertion for ctbconfig (adding message) for c++11

* fixed badchannels in m3server (clocking in trimming) 

* badchannel tests can be run from any folder (finds the file)
This commit is contained in:
Dhanya Thattil
2022-09-01 15:30:04 +02:00
committed by GitHub
parent 02322bb3c2
commit 7de6f157b5
36 changed files with 499 additions and 221 deletions

View File

@ -3024,8 +3024,8 @@ void setVetoAlgorithm(enum vetoAlgorithm alg,
bus_w(addr, value);
}
void setBadChannels(int nch, int *channels) {
LOG(logINFO, ("Setting %d bad channels\n", nch));
int setBadChannels(int numChannels, int *channelList) {
LOG(logINFO, ("Setting %d bad channels\n", numChannels));
int numAddr = MASK_STRIP_NUM_REGS;
int startAddr = MASK_STRIP_START_REG;
@ -3037,42 +3037,44 @@ void setBadChannels(int nch, int *channels) {
}
// setting badchannels, loop through list
for (int i = 0; i < nch; ++i) {
LOG(logINFO, ("\t[%d]: %d\n", i, channels[i]));
int iaddr = channels[i] / 32;
int iBit = channels[i] % 32;
for (int i = 0; i != numChannels; ++i) {
LOG(logINFO, ("\t[%d]: %d\n", i, channelList[i]));
int iaddr = channelList[i] / 32;
int iBit = channelList[i] % 32;
uint32_t addr = startAddr + iaddr * REG_OFFSET;
LOG(logDEBUG1,
("val:%d iaddr:%d iBit:%d, addr:0x%x old:0x%x val:0x%x\n",
channels[i], iaddr, iBit, addr, bus_r(addr), (1 << iBit)));
channelList[i], iaddr, iBit, addr, bus_r(addr), (1 << iBit)));
bus_w(addr, bus_r(addr) | (1 << iBit));
}
return OK;
}
int *getBadChannels(int *nch) {
int *getBadChannels(int *numChannels) {
int *retvals = NULL;
// count number of bad channels
*nch = 0;
for (int i = 0; i < MASK_STRIP_NUM_REGS; ++i) {
*numChannels = 0;
for (int i = 0; i != MASK_STRIP_NUM_REGS; ++i) {
uint32_t addr = MASK_STRIP_START_REG + i * REG_OFFSET;
*nch += __builtin_popcount(bus_r(addr));
*numChannels += __builtin_popcount(bus_r(addr));
}
if (*nch > 0) {
if (*numChannels > 0) {
// get list of bad channels
retvals = malloc(*nch * sizeof(int));
retvals = malloc(*numChannels * sizeof(int));
memset(retvals, 0, *numChannels * sizeof(int));
if (retvals == NULL) {
*nch = -1;
*numChannels = -1;
return NULL;
}
int chIndex = 0;
int numAddr = MASK_STRIP_NUM_REGS;
// loop through registers
for (int iaddr = 0; iaddr < numAddr; ++iaddr) {
for (int iaddr = 0; iaddr != numAddr; ++iaddr) {
// calculate address and get value
uint32_t addr = MASK_STRIP_START_REG + iaddr * REG_OFFSET;
uint32_t val = bus_r(addr);
// loop through 32 bits
for (int iBit = 0; iBit < 32; ++iBit) {
for (int iBit = 0; iBit != 32; ++iBit) {
// masked, add to list
if ((val >> iBit) & 0x1) {
LOG(logDEBUG1, ("iaddr:%d iBit:%d val:0x%x, ch:%d\n", iaddr,
@ -3084,7 +3086,7 @@ int *getBadChannels(int *nch) {
}
// debugging
LOG(logDEBUG1, ("Reading Bad channel list\n"));
for (int i = 0; i < (*nch); ++i) {
for (int i = 0; i != (*numChannels); ++i) {
LOG(logDEBUG1, ("[%d]: %d\n", i, retvals[i]));
}
return retvals;