g2 and m3 round robin (#559)

* g2 and m3: round robin
This commit is contained in:
Dhanya Thattil
2022-10-18 15:51:23 +02:00
committed by GitHub
parent 46bb9bc2d7
commit e7879ee365
20 changed files with 290 additions and 193 deletions

View File

@ -204,9 +204,9 @@
#define PKT_CONFIG_REG (0x00 * REG_OFFSET + BASE_PKT)
#define PKT_CONFIG_NRXR_MAX_OFST (0)
#define PKT_CONFIG_NRXR_MAX_MSK (0x0000003F << PKT_CONFIG_NRXR_MAX_OFST)
#define PKT_CONFIG_NRXR_MAX_MSK (0x0000001F << PKT_CONFIG_NRXR_MAX_OFST)
#define PKT_CONFIG_RXR_START_ID_OFST (8)
#define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST)
#define PKT_CONFIG_RXR_START_ID_MSK (0x0000001F << PKT_CONFIG_RXR_START_ID_OFST)
/* Module Coordinates Register */
#define COORD_0_REG (0x02 * REG_OFFSET + BASE_PKT)

View File

@ -27,6 +27,7 @@ extern int debugflag;
extern int updateFlag;
extern int checkModuleFlag;
extern udpStruct udpDetails[MAX_UDP_DESTINATION];
extern int numUdpDestinations;
extern const enum detectorType myDetectorType;
extern int ignoreConfigFileFlag;
@ -1851,6 +1852,36 @@ int getNumberofUDPInterfaces() {
return ((bus_r(CONFIG_REG) & CONFIG_VETO_CH_10GBE_ENBL_MSK) ? 2 : 1);
}
int getNumberofDestinations(int *retval) {
*retval = (((bus_r(PKT_CONFIG_REG) & PKT_CONFIG_NRXR_MAX_MSK) >>
PKT_CONFIG_NRXR_MAX_OFST) +
1);
return OK;
}
int setNumberofDestinations(int value) {
LOG(logINFO, ("Setting number of entries to %d\n", value));
--value;
bus_w(PKT_CONFIG_REG, bus_r(PKT_CONFIG_REG) & ~PKT_CONFIG_NRXR_MAX_MSK);
bus_w(PKT_CONFIG_REG,
bus_r(PKT_CONFIG_REG) |
((value << PKT_CONFIG_NRXR_MAX_OFST) & PKT_CONFIG_NRXR_MAX_MSK));
return OK;
}
int getFirstUDPDestination() {
return ((bus_r(PKT_CONFIG_REG) & PKT_CONFIG_RXR_START_ID_MSK) >>
PKT_CONFIG_RXR_START_ID_OFST);
}
void setFirstUDPDestination(int value) {
LOG(logINFO, ("Setting first entry to %d\n", value));
bus_w(PKT_CONFIG_REG, bus_r(PKT_CONFIG_REG) & ~PKT_CONFIG_RXR_START_ID_MSK);
bus_w(PKT_CONFIG_REG,
bus_r(PKT_CONFIG_REG) | ((value << PKT_CONFIG_RXR_START_ID_OFST) &
PKT_CONFIG_RXR_START_ID_MSK));
}
void setupHeader(int iRxEntry, int vetoInterface, uint32_t destip,
uint64_t destmac, uint32_t destport, uint64_t sourcemac,
uint32_t sourceip, uint32_t sourceport) {
@ -1895,6 +1926,9 @@ void setupHeader(int iRxEntry, int vetoInterface, uint32_t destip,
// total length is redefined in firmware
calcChecksum(udp);
if (iRxEntry < numUdpDestinations) {
LOG(logINFO, ("\tIP checksum : 0x%lx\n\n", udp->ip_checksum));
}
}
void calcChecksum(udp_header *udp) {
@ -1925,93 +1959,98 @@ void calcChecksum(udp_header *udp) {
sum = (sum & 0xffff) + (sum >> 16); // Fold 32-bit sum to 16 bits
long int checksum = sum & 0xffff;
checksum += UDP_IP_HEADER_LENGTH_BYTES;
LOG(logINFO, ("\tIP checksum is 0x%lx\n", checksum));
udp->ip_checksum = checksum;
}
int configureMAC() {
uint32_t srcip = udpDetails[0].srcip;
uint32_t srcip2 = udpDetails[0].srcip2;
uint32_t dstip = udpDetails[0].dstip;
uint32_t dstip2 = udpDetails[0].dstip2;
uint64_t srcmac = udpDetails[0].srcmac;
uint64_t srcmac2 = udpDetails[0].srcmac2;
uint64_t dstmac = udpDetails[0].dstmac;
uint64_t dstmac2 = udpDetails[0].dstmac2;
int srcport = udpDetails[0].srcport;
int srcport2 = udpDetails[0].srcport2;
int dstport = udpDetails[0].dstport;
int dstport2 = udpDetails[0].dstport2;
LOG(logINFOBLUE, ("Configuring MAC\n"));
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip);
char src_mac2[MAC_ADDRESS_SIZE], src_ip2[INET_ADDRSTRLEN],
dst_mac2[MAC_ADDRESS_SIZE], dst_ip2[INET_ADDRSTRLEN];
getMacAddressinString(src_mac2, MAC_ADDRESS_SIZE, srcmac2);
getMacAddressinString(dst_mac2, MAC_ADDRESS_SIZE, dstmac2);
getIpAddressinString(src_ip2, srcip2);
getIpAddressinString(dst_ip2, dstip2);
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\n",
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
LOG(logINFO, ("Number of entries: %d\n\n", numUdpDestinations));
for (int iRxEntry = 0; iRxEntry != MAX_UDP_DESTINATION; ++iRxEntry) {
uint32_t srcip = udpDetails[iRxEntry].srcip;
uint32_t srcip2 = udpDetails[iRxEntry].srcip2;
uint32_t dstip = udpDetails[iRxEntry].dstip;
uint32_t dstip2 = udpDetails[iRxEntry].dstip2;
uint64_t srcmac = udpDetails[iRxEntry].srcmac;
uint64_t srcmac2 = udpDetails[iRxEntry].srcmac2;
uint64_t dstmac = udpDetails[iRxEntry].dstmac;
uint64_t dstmac2 = udpDetails[iRxEntry].dstmac2;
int srcport = udpDetails[iRxEntry].srcport;
int srcport2 = udpDetails[iRxEntry].srcport2;
int dstport = udpDetails[iRxEntry].dstport;
int dstport2 = udpDetails[iRxEntry].dstport2;
int lll = getVetoStream();
int i10gbe = (getNumberofUDPInterfaces() == 2 ? 1 : 0);
char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN],
dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac);
getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac);
getIpAddressinString(src_ip, srcip);
getIpAddressinString(dst_ip, dstip);
char src_mac2[MAC_ADDRESS_SIZE], src_ip2[INET_ADDRSTRLEN],
dst_mac2[MAC_ADDRESS_SIZE], dst_ip2[INET_ADDRSTRLEN];
getMacAddressinString(src_mac2, MAC_ADDRESS_SIZE, srcmac2);
getMacAddressinString(dst_mac2, MAC_ADDRESS_SIZE, dstmac2);
getIpAddressinString(src_ip2, srcip2);
getIpAddressinString(dst_ip2, dstip2);
if (lll) {
LOG(logINFOGREEN, ("\tVeto (lll) : enabled\n\n"));
} else {
LOG(logINFORED, ("\tVeto (lll) : 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\n",
src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2));
int i10gbe = (getNumberofUDPInterfaces() == 2 ? 1 : 0);
if (iRxEntry < numUdpDestinations) {
LOG(logINFOBLUE, ("\tEntry %d\n", iRxEntry));
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\n",
src_ip, src_mac, srcport, dst_ip, dst_mac, dstport));
if (getVetoStream()) {
LOG(logINFOGREEN, ("\tVeto (lll) : enabled\n\n"));
} else {
LOG(logINFORED, ("\tVeto (lll) : 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\n",
src_ip2, src_mac2, srcport2, dst_ip2, dst_mac2, dstport2));
}
#ifdef VIRTUAL
if (setUDPDestinationDetails(0, 0, dst_ip, dstport) == FAIL) {
LOG(logERROR, ("could not set udp destination IP and port\n"));
return FAIL;
}
if (i10gbe && setUDPDestinationDetails(0, 1, dst_ip2, dstport2) == FAIL) {
LOG(logERROR, ("could not set udp destination IP and port for "
"interface 2\n"));
return FAIL;
}
return OK;
if (setUDPDestinationDetails(iRxEntry, 0, dst_ip, dstport) == FAIL) {
LOG(logERROR, ("could not set udp destination IP and port for "
"data interface [entry:%d] \n",
iRxEntry));
return FAIL;
}
if (i10gbe &&
setUDPDestinationDetails(iRxEntry, 1, dst_ip2, dstport2) == FAIL) {
LOG(logERROR, ("could not set udp destination IP and port for "
"veto interface [entry:%d] \n",
iRxEntry));
return FAIL;
}
#endif
// default one rxr entry (others not yet implemented in client yet)
int iRxEntry = 0;
// data
setupHeader(iRxEntry, 0, dstip, dstmac, dstport, srcmac, srcip,
srcport);
// data
setupHeader(iRxEntry, 0, dstip, dstmac, dstport, srcmac, srcip, srcport);
// veto
if (i10gbe) {
setupHeader(iRxEntry, 1, dstip2, dstmac2, dstport2, srcmac2, srcip2,
srcport2);
// veto
if (i10gbe) {
setupHeader(iRxEntry, 1, dstip2, dstmac2, dstport2, srcmac2, srcip2,
srcport2);
}
}
cleanFifos();
resetCore();
// alignDeserializer();
@ -3193,6 +3232,7 @@ void *start_timer(void *arg) {
return NULL;
}
int firstDest = getFirstUDPDestination();
int i10gbe = (getNumberofUDPInterfaces() == 2 ? 1 : 0);
int numRepeats = getNumTriggers();
@ -3249,6 +3289,7 @@ void *start_timer(void *arg) {
*((uint16_t *)(vetoData + i)) = i;
}
int iRxEntry = firstDest;
// loop over number of repeats
for (int repeatNr = 0; repeatNr != numRepeats; ++repeatNr) {
@ -3284,7 +3325,7 @@ void *start_timer(void *arg) {
memcpy(packetData + sizeof(sls_detector_header), imageData,
datasize);
// send 1 packet = 1 frame
sendUDPPacket(0, 0, packetData, packetsize);
sendUDPPacket(iRxEntry, 0, packetData, packetsize);
// second interface (veto)
char packetData2[vetopacketsize];
@ -3298,11 +3339,12 @@ void *start_timer(void *arg) {
memcpy(packetData2 + sizeof(veto_header), vetoData,
vetodatasize);
// send 1 packet = 1 frame
sendUDPPacket(0, 1, packetData2, vetopacketsize);
sendUDPPacket(iRxEntry, 1, packetData2, vetopacketsize);
}
LOG(logINFO, ("Sent frame %s: %d (bursts/ triggers: %d) [%lld]\n",
(i10gbe ? "(+veto)" : ""), frameNr, repeatNr,
(long long unsigned int)virtual_currentFrameNumber));
LOG(logINFO,
("Sent frame %s: %d (bursts/ triggers: %d) [%lld] to E%d\n",
(i10gbe ? "(+veto)" : ""), frameNr, repeatNr,
(long long unsigned int)virtual_currentFrameNumber, iRxEntry));
clock_gettime(CLOCK_REALTIME, &end);
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
(end.tv_nsec - begin.tv_nsec));
@ -3314,6 +3356,10 @@ void *start_timer(void *arg) {
}
}
++virtual_currentFrameNumber;
++iRxEntry;
if (iRxEntry == numUdpDestinations) {
iRxEntry = 0;
}
}
clock_gettime(CLOCK_REALTIME, &rend);
int64_t timeNs = ((rend.tv_sec - rbegin.tv_sec) * 1E9 +