mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-16 08:09:21 +01:00
Removeudpcache (#65)
* WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * solved eiger 1-10g issue * some fixes for remove udp cache to work * bug fix virtual * removed special handling of rx_udpip
This commit is contained in:
Binary file not shown.
@@ -25,6 +25,7 @@
|
||||
|
||||
// Global variable from slsDetectorServer_funcs
|
||||
extern int debugflag;
|
||||
extern udpStruct udpDetails;
|
||||
|
||||
// Global variable from UDPPacketHeaderGenerator
|
||||
extern uint64_t udpFrameNumber;
|
||||
@@ -63,7 +64,7 @@ int analogEnable = 1;
|
||||
int digitalEnable = 0;
|
||||
int naSamples = 1;
|
||||
int ndSamples = 1;
|
||||
|
||||
int detPos[2] = {0, 0};
|
||||
|
||||
int isFirmwareCheckDone() {
|
||||
return firmware_check_done;
|
||||
@@ -1503,7 +1504,13 @@ long int calcChecksum(int sourceip, int destip) {
|
||||
|
||||
|
||||
|
||||
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport){
|
||||
int configureMAC(){
|
||||
uint32_t sourceip = udpDetails.srcip;
|
||||
uint32_t destip = udpDetails.dstip;
|
||||
uint64_t sourcemac = udpDetails.srcmac;
|
||||
uint64_t destmac = udpDetails.dstmac;
|
||||
int sourceport = udpDetails.srcport;
|
||||
int destport = udpDetails.dstport;
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
@@ -1517,8 +1524,8 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
||||
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, udpport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, udpport) == FAIL) {
|
||||
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, destport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, destport) == FAIL) {
|
||||
FILE_LOG(logERROR, ("could not set udp 1G destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
@@ -1527,7 +1534,6 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
|
||||
// 10 G
|
||||
FILE_LOG(logINFOBLUE, ("Configuring 10G MAC\n"));
|
||||
uint32_t sourceport = DEFAULT_TX_UDP_PORT;
|
||||
|
||||
FILE_LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(sourceip>>24)&0xff,(sourceip>>16)&0xff,(sourceip>>8)&0xff,(sourceip)&0xff, sourceip));
|
||||
@@ -1551,7 +1557,7 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
(unsigned int)((destmac>>8)&0xFF),
|
||||
(unsigned int)((destmac>>0)&0xFF),
|
||||
(long long unsigned int)destmac));
|
||||
FILE_LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n",udpport, udpport));
|
||||
FILE_LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n",destport, destport));
|
||||
|
||||
long int checksum=calcChecksum(sourceip, destip);
|
||||
bus_w(TX_IP_REG, sourceip);
|
||||
@@ -1576,7 +1582,7 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
FILE_LOG(logDEBUG1, ("Read from RX_MAC_MSB_REG: 0x%08x\n", bus_r(RX_MAC_MSB_REG)));
|
||||
|
||||
val = (((sourceport << UDP_PORT_TX_OFST) & UDP_PORT_TX_MSK) |
|
||||
((udpport << UDP_PORT_RX_OFST) & UDP_PORT_RX_MSK));
|
||||
((destport << UDP_PORT_RX_OFST) & UDP_PORT_RX_MSK));
|
||||
bus_w(UDP_PORT_REG, val);
|
||||
FILE_LOG(logDEBUG1, ("Read from UDP_PORT_REG: 0x%08x\n", bus_r(UDP_PORT_REG)));
|
||||
|
||||
@@ -1591,6 +1597,15 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setDetectorPosition(int pos[]) {
|
||||
memcpy(detPos, pos, sizeof(detPos));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int* getDetectorPosition() {
|
||||
return detPos;
|
||||
}
|
||||
|
||||
int enableTenGigabitEthernet(int val) {
|
||||
uint32_t addr = CONFIG_REG;
|
||||
|
||||
|
||||
@@ -1176,6 +1176,9 @@ int Beb_GetQuad() {
|
||||
return Beb_quadEnable;
|
||||
}
|
||||
|
||||
int* Beb_GetDetectorPosition() {
|
||||
return Beb_positions;
|
||||
}
|
||||
|
||||
int Beb_SetDetectorPosition(int pos[]) {
|
||||
if (!Beb_activated)
|
||||
|
||||
@@ -76,6 +76,7 @@ int Beb_GetBebFPGATemp();
|
||||
void Beb_SetDetectorNumber(uint32_t detid);
|
||||
int Beb_SetQuad(int value);
|
||||
int Beb_GetQuad();
|
||||
int* Beb_GetDetectorPosition();
|
||||
int Beb_SetDetectorPosition(int pos[]);
|
||||
int Beb_SetStartingFrameNumber(uint64_t value);
|
||||
int Beb_GetStartingFrameNumber(uint64_t* retval, int tengigaEnable);
|
||||
|
||||
Binary file not shown.
@@ -18,7 +18,7 @@
|
||||
|
||||
// Global variable from slsDetectorServer_funcs
|
||||
extern int debugflag;
|
||||
|
||||
extern udpStruct udpDetails;
|
||||
|
||||
// Global variable from communication_funcs.c
|
||||
extern int isControlServer;
|
||||
@@ -86,6 +86,7 @@ int eiger_virtual_activate=1;
|
||||
pthread_t eiger_virtual_tid;
|
||||
int eiger_virtual_stop = 0;
|
||||
uint64_t eiger_virtual_startingframenumber = 0;
|
||||
int eiger_virtual_detPos[2] = {0, 0};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -134,6 +135,10 @@ void basictests() {
|
||||
(long long int)sw_fw_apiversion,
|
||||
REQUIRED_FIRMWARE_VERSION,
|
||||
(long long int)client_sw_apiversion));
|
||||
|
||||
// update default udpdstip and udpdstmac (1g is hardware ip and hardware mac)
|
||||
udpDetails.srcip = ipadd;
|
||||
udpDetails.srcmac = macadd;
|
||||
|
||||
// return if debugflag is not zero, debug mode
|
||||
if (debugflag) {
|
||||
@@ -929,7 +934,7 @@ enum detectorSettings getSettings() {
|
||||
/* parameters - threshold */
|
||||
|
||||
int getThresholdEnergy() {
|
||||
FILE_LOG(logINFO, ("Getting Threshold energy\n"));
|
||||
FILE_LOG(logDEBUG1, ("Getting Threshold energy\n"));
|
||||
return eiger_photonenergy;
|
||||
}
|
||||
|
||||
@@ -1157,17 +1162,25 @@ enum timingMode getTiming() {
|
||||
|
||||
/* configure mac */
|
||||
|
||||
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2) {
|
||||
int configureMAC() {
|
||||
uint32_t sourceip = udpDetails.srcip;
|
||||
uint32_t destip = udpDetails.dstip;
|
||||
uint64_t sourcemac = udpDetails.srcmac;
|
||||
uint64_t destmac = udpDetails.dstmac;
|
||||
int src_port = udpDetails.srcport;
|
||||
int destport = udpDetails.dstport;
|
||||
int destport2 = udpDetails.dstport2;
|
||||
|
||||
#ifdef VIRTUAL
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
||||
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d, port2:%d)\n", cDestIp, udpport, udpport2));
|
||||
if (setUDPDestinationDetails(0, cDestIp, udpport) == FAIL) {
|
||||
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d, port2:%d)\n", cDestIp, destport, destport2));
|
||||
if (setUDPDestinationDetails(0, cDestIp, destport) == FAIL) {
|
||||
FILE_LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if (setUDPDestinationDetails(1, cDestIp, udpport2) == FAIL) {
|
||||
if (setUDPDestinationDetails(1, cDestIp, destport2) == FAIL) {
|
||||
FILE_LOG(logERROR, ("could not set udp destination IP and port2\n"));
|
||||
return FAIL;
|
||||
}
|
||||
@@ -1175,8 +1188,6 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
#else
|
||||
FILE_LOG(logINFO, ("Configuring MAC\n"));
|
||||
|
||||
int src_port = DEFAULT_UDP_SOURCE_PORT;
|
||||
|
||||
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||
getMacAddressinString(src_mac, 50, sourcemac);
|
||||
getMacAddressinString(dst_mac, 50, destmac);
|
||||
@@ -1195,9 +1206,9 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
|
||||
int beb_num = detid;
|
||||
int header_number = 0;
|
||||
int dst_port = udpport;
|
||||
int dst_port = destport;
|
||||
if (!top)
|
||||
dst_port = udpport2;
|
||||
dst_port = destport2;
|
||||
|
||||
FILE_LOG(logINFO, ("\tDest Port : %d\n", dst_port));
|
||||
|
||||
@@ -1212,9 +1223,9 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
/*}*/
|
||||
|
||||
header_number = 32;
|
||||
dst_port = udpport2;
|
||||
dst_port = destport2;
|
||||
if (!top)
|
||||
dst_port = udpport;
|
||||
dst_port = destport;
|
||||
FILE_LOG(logINFO, ("\tDest Port : %d\n",dst_port));
|
||||
|
||||
/*for(i=0;i<32;i++) {*//** modified for Aldo*/
|
||||
@@ -1235,15 +1246,23 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
}
|
||||
|
||||
|
||||
|
||||
int setDetectorPosition(int pos[]) {
|
||||
#ifdef VIRTUAL
|
||||
memcpy(eiger_virtual_detPos, pos, sizeof(eiger_virtual_detPos));
|
||||
return OK;
|
||||
#else
|
||||
return Beb_SetDetectorPosition(pos);
|
||||
#endif
|
||||
}
|
||||
|
||||
int* getDetectorPosition() {
|
||||
#ifdef VIRTUAL
|
||||
return eiger_virtual_detPos;
|
||||
#else
|
||||
return Beb_GetDetectorPosition();
|
||||
#endif
|
||||
}
|
||||
|
||||
int setQuad(int value) {
|
||||
if (value < 0) {
|
||||
return OK;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
// Global variable from slsDetectorServer_funcs
|
||||
extern int debugflag;
|
||||
extern udpStruct udpDetails;
|
||||
|
||||
int firmware_compatibility = OK;
|
||||
int firmware_check_done = 0;
|
||||
@@ -35,7 +36,7 @@ int virtual_stop = 0;
|
||||
|
||||
uint32_t clkDivider[NUM_CLOCKS] = {125, 20, 80};
|
||||
int highvoltage = 0;
|
||||
|
||||
int detPos[2] = {0, 0};
|
||||
|
||||
int isFirmwareCheckDone() {
|
||||
return firmware_check_done;
|
||||
@@ -471,13 +472,21 @@ int setHighVoltage(int val){
|
||||
}
|
||||
|
||||
|
||||
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport) {
|
||||
int configureMAC() {
|
||||
|
||||
uint32_t srcip = udpDetails.srcip;
|
||||
uint32_t dstip = udpDetails.dstip;
|
||||
uint64_t srcmac = udpDetails.srcmac;
|
||||
uint64_t dstmac = udpDetails.dstmac;
|
||||
int srcport = udpDetails.srcport;
|
||||
int dstport = udpDetails.dstport;
|
||||
|
||||
#ifdef VIRTUAL
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
||||
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, udpport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, udpport) == FAIL) {
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff);
|
||||
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, dstport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, dstport) == FAIL) {
|
||||
FILE_LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
@@ -485,30 +494,29 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
#endif
|
||||
FILE_LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
|
||||
uint32_t sourceport = DEFAULT_TX_UDP_PORT;
|
||||
FILE_LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(sourceip>>24)&0xff,(sourceip>>16)&0xff,(sourceip>>8)&0xff,(sourceip)&0xff, sourceip));
|
||||
(srcip>>24)&0xff,(srcip>>16)&0xff,(srcip>>8)&0xff,(srcip)&0xff, srcip));
|
||||
FILE_LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((sourcemac>>40)&0xFF),
|
||||
(unsigned int)((sourcemac>>32)&0xFF),
|
||||
(unsigned int)((sourcemac>>24)&0xFF),
|
||||
(unsigned int)((sourcemac>>16)&0xFF),
|
||||
(unsigned int)((sourcemac>>8)&0xFF),
|
||||
(unsigned int)((sourcemac>>0)&0xFF),
|
||||
(long long unsigned int)sourcemac));
|
||||
FILE_LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n",sourceport, sourceport));
|
||||
(unsigned int)((srcmac>>40)&0xFF),
|
||||
(unsigned int)((srcmac>>32)&0xFF),
|
||||
(unsigned int)((srcmac>>24)&0xFF),
|
||||
(unsigned int)((srcmac>>16)&0xFF),
|
||||
(unsigned int)((srcmac>>8)&0xFF),
|
||||
(unsigned int)((srcmac>>0)&0xFF),
|
||||
(long long unsigned int)srcmac));
|
||||
FILE_LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n", srcport, srcport));
|
||||
|
||||
FILE_LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t\t(0x%08x)\n",
|
||||
(destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff, destip));
|
||||
FILE_LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff, dstip));
|
||||
FILE_LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((destmac>>40)&0xFF),
|
||||
(unsigned int)((destmac>>32)&0xFF),
|
||||
(unsigned int)((destmac>>24)&0xFF),
|
||||
(unsigned int)((destmac>>16)&0xFF),
|
||||
(unsigned int)((destmac>>8)&0xFF),
|
||||
(unsigned int)((destmac>>0)&0xFF),
|
||||
(long long unsigned int)destmac));
|
||||
FILE_LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n\n",udpport, udpport));
|
||||
(unsigned int)((dstmac>>40)&0xFF),
|
||||
(unsigned int)((dstmac>>32)&0xFF),
|
||||
(unsigned int)((dstmac>>24)&0xFF),
|
||||
(unsigned int)((dstmac>>16)&0xFF),
|
||||
(unsigned int)((dstmac>>8)&0xFF),
|
||||
(unsigned int)((dstmac>>0)&0xFF),
|
||||
(long long unsigned int)dstmac));
|
||||
FILE_LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n\n",dstport, dstport));
|
||||
|
||||
// start addr
|
||||
uint32_t addr = BASE_PATTERN_RAM;
|
||||
@@ -520,21 +528,21 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
|
||||
// mac addresses
|
||||
// msb (32) + lsb (16)
|
||||
udp->udp_destmac_msb = ((destmac >> 16) & BIT32_MASK);
|
||||
udp->udp_destmac_lsb = ((destmac >> 0) & BIT16_MASK);
|
||||
udp->udp_destmac_msb = ((dstmac >> 16) & BIT32_MASK);
|
||||
udp->udp_destmac_lsb = ((dstmac >> 0) & BIT16_MASK);
|
||||
// msb (16) + lsb (32)
|
||||
udp->udp_srcmac_msb = ((sourcemac >> 32) & BIT16_MASK);
|
||||
udp->udp_srcmac_lsb = ((sourcemac >> 0) & BIT32_MASK);
|
||||
udp->udp_srcmac_msb = ((srcmac >> 32) & BIT16_MASK);
|
||||
udp->udp_srcmac_lsb = ((srcmac >> 0) & BIT32_MASK);
|
||||
|
||||
// ip addresses
|
||||
udp->ip_srcip_msb = ((sourceip >> 16) & BIT16_MASK);
|
||||
udp->ip_srcip_lsb = ((sourceip >> 0) & BIT16_MASK);
|
||||
udp->ip_destip_msb = ((destip >> 16) & BIT16_MASK);
|
||||
udp->ip_destip_lsb = ((destip >> 0) & BIT16_MASK);
|
||||
udp->ip_srcip_msb = ((srcip >> 16) & BIT16_MASK);
|
||||
udp->ip_srcip_lsb = ((srcip >> 0) & BIT16_MASK);
|
||||
udp->ip_destip_msb = ((dstip >> 16) & BIT16_MASK);
|
||||
udp->ip_destip_lsb = ((dstip >> 0) & BIT16_MASK);
|
||||
|
||||
// source port
|
||||
udp->udp_srcport = sourceport;
|
||||
udp->udp_destport = udpport;
|
||||
udp->udp_srcport = srcport;
|
||||
udp->udp_destport = dstport;
|
||||
|
||||
// other defines
|
||||
udp->udp_ethertype = 0x800;
|
||||
@@ -590,6 +598,15 @@ void calcChecksum(udp_header* udp) {
|
||||
|
||||
/* aquisition */
|
||||
|
||||
int setDetectorPosition(int pos[]) {
|
||||
memcpy(detPos, pos, sizeof(detPos));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int* getDetectorPosition() {
|
||||
return detPos;
|
||||
}
|
||||
|
||||
int startStateMachine(){
|
||||
#ifdef VIRTUAL
|
||||
// create udp socket
|
||||
|
||||
Binary file not shown.
@@ -15,7 +15,7 @@
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
|
||||
extern udpStruct udpDetails;
|
||||
|
||||
// Variables that will be exported
|
||||
int phaseShift = DEFAULT_PHASE_SHIFT;
|
||||
@@ -30,6 +30,7 @@ int virtual_status = 0;
|
||||
int virtual_stop = 0;
|
||||
int highvoltage = 0;
|
||||
#endif
|
||||
int detPos[2] = {0, 0};
|
||||
|
||||
int detectorFirstServer = 1;
|
||||
int dacValues[NDAC] = {0};
|
||||
@@ -1327,7 +1328,13 @@ void calcChecksum(mac_conf* mac, int sourceip, int destip) {
|
||||
mac->ip.ip_chksum = checksum;
|
||||
}
|
||||
|
||||
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport) {
|
||||
int configureMAC() {
|
||||
uint32_t sourceip = udpDetails.srcip;
|
||||
uint32_t destip = udpDetails.dstip;
|
||||
uint64_t sourcemac = udpDetails.srcmac;
|
||||
uint64_t destmac = udpDetails.dstmac;
|
||||
int sourceport = udpDetails.srcport;
|
||||
int destport = udpDetails.dstport;
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
@@ -1337,7 +1344,6 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
FILE_LOG(logDEBUG1, ("\tRoi: %d, Ip Packet size: %d UDP Packet size: %d\n",
|
||||
adcConfigured, ipPacketSize, udpPacketSize));
|
||||
|
||||
uint32_t sourceport = DEFAULT_TX_UDP_PORT;
|
||||
FILE_LOG(logINFO, ("\tSource IP : %d.%d.%d.%d (0x%08x)\n",
|
||||
(sourceip>>24)&0xff,(sourceip>>16)&0xff,(sourceip>>8)&0xff,(sourceip)&0xff, sourceip));
|
||||
FILE_LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x (0x%010llx)\n",
|
||||
@@ -1359,7 +1365,7 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
(unsigned int)((destmac>>8)&0xFF),
|
||||
(unsigned int)((destmac>>0)&0xFF),
|
||||
(long long unsigned int)destmac));
|
||||
FILE_LOG(logINFO, ("\tDest. Port : %d (0x%08x)\n",udpport, udpport));
|
||||
FILE_LOG(logINFO, ("\tDest. Port : %d (0x%08x)\n",destport, destport));
|
||||
|
||||
//reset mac
|
||||
bus_w (addr, bus_r(addr) | RST_MSK);
|
||||
@@ -1413,7 +1419,7 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
|
||||
calcChecksum(mac_conf_regs, sourceip, destip);
|
||||
mac_conf_regs->udp.udp_srcport = sourceport;
|
||||
mac_conf_regs->udp.udp_destport = udpport;
|
||||
mac_conf_regs->udp.udp_destport = destport;
|
||||
mac_conf_regs->udp.udp_len = udpPacketSize;
|
||||
mac_conf_regs->udp.udp_chksum = 0x0000;
|
||||
|
||||
@@ -1516,10 +1522,20 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int getAdcConfigured(){
|
||||
return adcConfigured;
|
||||
}
|
||||
|
||||
int setDetectorPosition(int pos[]) {
|
||||
memcpy(detPos, pos, sizeof(detPos));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int* getDetectorPosition() {
|
||||
return detPos;
|
||||
}
|
||||
|
||||
|
||||
/* aquisition */
|
||||
|
||||
|
||||
Binary file not shown.
@@ -23,6 +23,7 @@
|
||||
|
||||
// Global variable from slsDetectorServer_funcs
|
||||
extern int debugflag;
|
||||
extern udpStruct udpDetails;
|
||||
|
||||
int firmware_compatibility = OK;
|
||||
int firmware_check_done = 0;
|
||||
@@ -38,6 +39,9 @@ enum detectorSettings thisSettings = UNINITIALIZED;
|
||||
int highvoltage = 0;
|
||||
int dacValues[NDAC] = {0};
|
||||
int adcPhase = 0;
|
||||
int detPos[4] = {0, 0, 0, 0};
|
||||
int numUDPInterfaces = 1;
|
||||
|
||||
|
||||
int isFirmwareCheckDone() {
|
||||
return firmware_check_done;
|
||||
@@ -1022,16 +1026,12 @@ void setNumberofUDPInterfaces(int val) {
|
||||
FILE_LOG(logINFOBLUE, ("Setting #Interfaces: 1\n"));
|
||||
bus_w(addr, bus_r(addr) &~ CONFIG_OPRTN_MDE_2_X_10GbE_MSK);
|
||||
}
|
||||
FILE_LOG(logINFO, ("config reg:0x%x\n", bus_r(addr)));
|
||||
FILE_LOG(logDEBUG, ("config reg:0x%x\n", bus_r(addr)));
|
||||
}
|
||||
|
||||
int getNumberofUDPInterfaces() {
|
||||
FILE_LOG(logINFO, ("config reg:0x%x\n", bus_r(CONFIG_REG)));
|
||||
FILE_LOG(logINFO, ("config reg 2x10 :0x%x %d\n",
|
||||
CONFIG_OPRTN_MDE_2_X_10GbE_MSK,
|
||||
bus_r(CONFIG_REG)|CONFIG_OPRTN_MDE_2_X_10GbE_MSK));
|
||||
FILE_LOG(logDEBUG, ("config reg:0x%x\n", bus_r(CONFIG_REG)));
|
||||
// return 2 if enabled, else 1
|
||||
|
||||
return ((bus_r(CONFIG_REG) & CONFIG_OPRTN_MDE_2_X_10GbE_MSK) ? 2 : 1);
|
||||
}
|
||||
|
||||
@@ -1128,94 +1128,104 @@ void calcChecksum(udp_header* udp) {
|
||||
|
||||
|
||||
|
||||
int configureMAC(int numInterfaces, int selInterface,
|
||||
uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport,
|
||||
uint32_t destip2, uint64_t destmac2, uint64_t sourcemac2, uint32_t sourceip2, uint32_t udpport2) {
|
||||
int configureMAC() {
|
||||
|
||||
uint32_t srcip = udpDetails.srcip;
|
||||
uint32_t srcip2 = udpDetails.srcip2;
|
||||
uint32_t dstip = udpDetails.dstip;
|
||||
uint32_t dstip2 = udpDetails.dstip2;
|
||||
uint64_t srcmac = udpDetails.srcmac;
|
||||
uint64_t srcmac2 = udpDetails.srcmac2;
|
||||
uint64_t dstmac = udpDetails.dstmac;
|
||||
uint64_t dstmac2 = udpDetails.dstmac2;
|
||||
int srcport = udpDetails.srcport;
|
||||
int srcport2 = udpDetails.srcport2;
|
||||
int dstport = udpDetails.dstport;
|
||||
int dstport2 = udpDetails.dstport2;
|
||||
|
||||
#ifdef VIRTUAL
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
||||
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, udpport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, udpport) == FAIL) {
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff);
|
||||
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, dstport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, dstport) == FAIL) {
|
||||
FILE_LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
FILE_LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
|
||||
uint32_t sourceport = DEFAULT_TX_UDP_PORT;
|
||||
|
||||
int numInterfaces = getNumberofUDPInterfaces();
|
||||
int selInterface = getPrimaryInterface();
|
||||
FILE_LOG(logINFO, ("\t#Interfaces : %d\n", numInterfaces));
|
||||
FILE_LOG(logINFO, ("\tInterface : %d %s\n\n", selInterface, (selInterface ? "Inner" : "Outer")));
|
||||
|
||||
FILE_LOG(logINFO, ("\tOuter %s\n", (numInterfaces == 2) ? "(Bottom)": (selInterface ? "Not Used" : "Used")));
|
||||
FILE_LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(sourceip>>24)&0xff,(sourceip>>16)&0xff,(sourceip>>8)&0xff,(sourceip)&0xff, sourceip));
|
||||
(srcip>>24)&0xff,(srcip>>16)&0xff,(srcip>>8)&0xff,(srcip)&0xff, srcip));
|
||||
FILE_LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((sourcemac>>40)&0xFF),
|
||||
(unsigned int)((sourcemac>>32)&0xFF),
|
||||
(unsigned int)((sourcemac>>24)&0xFF),
|
||||
(unsigned int)((sourcemac>>16)&0xFF),
|
||||
(unsigned int)((sourcemac>>8)&0xFF),
|
||||
(unsigned int)((sourcemac>>0)&0xFF),
|
||||
(long long unsigned int)sourcemac));
|
||||
FILE_LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n",sourceport, sourceport));
|
||||
(unsigned int)((srcmac>>40)&0xFF),
|
||||
(unsigned int)((srcmac>>32)&0xFF),
|
||||
(unsigned int)((srcmac>>24)&0xFF),
|
||||
(unsigned int)((srcmac>>16)&0xFF),
|
||||
(unsigned int)((srcmac>>8)&0xFF),
|
||||
(unsigned int)((srcmac>>0)&0xFF),
|
||||
(long long unsigned int)srcmac));
|
||||
FILE_LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n", srcport, srcport));
|
||||
|
||||
FILE_LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t\t(0x%08x)\n",
|
||||
(destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff, destip));
|
||||
FILE_LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff, dstip));
|
||||
FILE_LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((destmac>>40)&0xFF),
|
||||
(unsigned int)((destmac>>32)&0xFF),
|
||||
(unsigned int)((destmac>>24)&0xFF),
|
||||
(unsigned int)((destmac>>16)&0xFF),
|
||||
(unsigned int)((destmac>>8)&0xFF),
|
||||
(unsigned int)((destmac>>0)&0xFF),
|
||||
(long long unsigned int)destmac));
|
||||
FILE_LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n\n",udpport, udpport));
|
||||
(unsigned int)((dstmac>>40)&0xFF),
|
||||
(unsigned int)((dstmac>>32)&0xFF),
|
||||
(unsigned int)((dstmac>>24)&0xFF),
|
||||
(unsigned int)((dstmac>>16)&0xFF),
|
||||
(unsigned int)((dstmac>>8)&0xFF),
|
||||
(unsigned int)((dstmac>>0)&0xFF),
|
||||
(long long unsigned int)dstmac));
|
||||
FILE_LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n\n",dstport, dstport));
|
||||
|
||||
uint32_t sourceport2 = DEFAULT_TX_UDP_PORT + 1;
|
||||
FILE_LOG(logINFO, ("\tInner %s\n", (numInterfaces == 2) ? "(Top)": (selInterface ? "Used" : "Not Used")));
|
||||
FILE_LOG(logINFO, ("\tSource IP2 : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(sourceip2>>24)&0xff,(sourceip2>>16)&0xff,(sourceip2>>8)&0xff,(sourceip2)&0xff, sourceip2));
|
||||
(srcip2>>24)&0xff,(srcip2>>16)&0xff,(srcip2>>8)&0xff,(srcip2)&0xff, srcip2));
|
||||
FILE_LOG(logINFO, ("\tSource MAC2 : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((sourcemac2>>40)&0xFF),
|
||||
(unsigned int)((sourcemac2>>32)&0xFF),
|
||||
(unsigned int)((sourcemac2>>24)&0xFF),
|
||||
(unsigned int)((sourcemac2>>16)&0xFF),
|
||||
(unsigned int)((sourcemac2>>8)&0xFF),
|
||||
(unsigned int)((sourcemac2>>0)&0xFF),
|
||||
(long long unsigned int)sourcemac2));
|
||||
FILE_LOG(logINFO, ("\tSource Port2: %d \t\t\t(0x%08x)\n",sourceport2, sourceport2));
|
||||
(unsigned int)((srcmac2>>40)&0xFF),
|
||||
(unsigned int)((srcmac2>>32)&0xFF),
|
||||
(unsigned int)((srcmac2>>24)&0xFF),
|
||||
(unsigned int)((srcmac2>>16)&0xFF),
|
||||
(unsigned int)((srcmac2>>8)&0xFF),
|
||||
(unsigned int)((srcmac2>>0)&0xFF),
|
||||
(long long unsigned int)srcmac2));
|
||||
FILE_LOG(logINFO, ("\tSource Port2: %d \t\t\t(0x%08x)\n", srcport2, srcport2));
|
||||
|
||||
FILE_LOG(logINFO, ("\tDest. IP2 : %d.%d.%d.%d \t\t\t(0x%08x)\n",
|
||||
(destip2>>24)&0xff,(destip2>>16)&0xff,(destip2>>8)&0xff,(destip2)&0xff, destip2));
|
||||
FILE_LOG(logINFO, ("\tDest. IP2 : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(dstip2>>24)&0xff,(dstip2>>16)&0xff,(dstip2>>8)&0xff,(dstip2)&0xff, dstip2));
|
||||
FILE_LOG(logINFO, ("\tDest. MAC2 : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((destmac2>>40)&0xFF),
|
||||
(unsigned int)((destmac2>>32)&0xFF),
|
||||
(unsigned int)((destmac2>>24)&0xFF),
|
||||
(unsigned int)((destmac2>>16)&0xFF),
|
||||
(unsigned int)((destmac2>>8)&0xFF),
|
||||
(unsigned int)((destmac2>>0)&0xFF),
|
||||
(long long unsigned int)destmac2));
|
||||
FILE_LOG(logINFO, ("\tDest. Port2 : %d \t\t\t(0x%08x)\n",udpport2, udpport2));
|
||||
(unsigned int)((dstmac2>>40)&0xFF),
|
||||
(unsigned int)((dstmac2>>32)&0xFF),
|
||||
(unsigned int)((dstmac2>>24)&0xFF),
|
||||
(unsigned int)((dstmac2>>16)&0xFF),
|
||||
(unsigned int)((dstmac2>>8)&0xFF),
|
||||
(unsigned int)((dstmac2>>0)&0xFF),
|
||||
(long long unsigned int)dstmac2));
|
||||
FILE_LOG(logINFO, ("\tDest. Port2 : %d \t\t\t(0x%08x)\n", dstport2, dstport2));
|
||||
|
||||
// default one rxr entry (others not yet implemented in client yet)
|
||||
int iRxEntry = 0;
|
||||
|
||||
if (numInterfaces == 2) {
|
||||
// bottom
|
||||
setupHeader(iRxEntry, OUTER, destip, destmac, udpport, sourcemac, sourceip, sourceport);
|
||||
setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, srcip, srcport);
|
||||
// top
|
||||
setupHeader(iRxEntry, INNER, destip2, destmac2, udpport2, sourcemac2, sourceip2, sourceport2);
|
||||
setupHeader(iRxEntry, INNER, dstip2, dstmac2, dstport2, srcmac2, srcip2, srcport2);
|
||||
}
|
||||
// single interface
|
||||
else {
|
||||
// default
|
||||
if (selInterface == 0) {
|
||||
setupHeader(iRxEntry, OUTER, destip, destmac, udpport, sourcemac, sourceip, sourceport);
|
||||
setupHeader(iRxEntry, OUTER, dstip, dstmac, dstport, srcmac, srcip, srcport);
|
||||
} else {
|
||||
setupHeader(iRxEntry, INNER, destip, destmac, udpport, sourcemac, sourceip, sourceport);
|
||||
setupHeader(iRxEntry, INNER, dstip, dstmac, dstport, srcmac, srcip, srcport2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1228,15 +1238,13 @@ int configureMAC(int numInterfaces, int selInterface,
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int setDetectorPosition(int pos[]) {
|
||||
int ret = OK;
|
||||
int innerPos[2] = {pos[X], pos[Y]};
|
||||
int outerPos[2] = {pos[X], pos[Y]};
|
||||
int selInterface = getPrimaryInterface();
|
||||
int numInterfaces = getNumberofUDPInterfaces();
|
||||
|
||||
if (numInterfaces == 1) {
|
||||
if (getNumberofUDPInterfaces() == 1) {
|
||||
FILE_LOG(logDEBUG, ("Setting detector position: 1 Interface %s \n(%d, %d)\n",
|
||||
(selInterface ? "Inner" : "Outer"), innerPos[X], innerPos[Y]));
|
||||
}
|
||||
@@ -1246,6 +1254,10 @@ int setDetectorPosition(int pos[]) {
|
||||
" inner top(%d, %d), outer bottom(%d, %d)\n"
|
||||
, innerPos[X], innerPos[Y], outerPos[X], outerPos[Y]));
|
||||
}
|
||||
detPos[0] = innerPos[0];
|
||||
detPos[1] = innerPos[1];
|
||||
detPos[2] = outerPos[0];
|
||||
detPos[3] = outerPos[1];
|
||||
|
||||
// row
|
||||
//outer
|
||||
@@ -1270,7 +1282,7 @@ int setDetectorPosition(int pos[]) {
|
||||
ret = FAIL;
|
||||
|
||||
if (ret == OK) {
|
||||
if (numInterfaces == 1) {
|
||||
if (getNumberofUDPInterfaces() == 1) {
|
||||
FILE_LOG(logINFOBLUE, ("Position set to [%d, %d]\n", innerPos[X], innerPos[Y]));
|
||||
}
|
||||
else {
|
||||
@@ -1282,6 +1294,10 @@ int setDetectorPosition(int pos[]) {
|
||||
}
|
||||
|
||||
|
||||
int* getDetectorPosition() {
|
||||
return detPos;
|
||||
}
|
||||
|
||||
|
||||
/* jungfrau specific - powerchip, autocompdisable, asictimer, clockdiv, pll, flashing fpga */
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
extern udpStruct udpDetails;
|
||||
|
||||
// Global variable from slsDetectorServer_funcs
|
||||
extern int debugflag;
|
||||
@@ -35,6 +36,7 @@ int32_t clkPhase[NUM_CLOCKS] = {0, 0, 0};
|
||||
uint32_t clkDivider[NUM_CLOCKS] = {125, 20, 80};
|
||||
|
||||
int highvoltage = 0;
|
||||
int detPos[2] = {0, 0};
|
||||
|
||||
int isFirmwareCheckDone() {
|
||||
return firmware_check_done;
|
||||
@@ -400,17 +402,19 @@ int setHighVoltage(int val){
|
||||
}
|
||||
|
||||
|
||||
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport) {
|
||||
int configureMAC() {
|
||||
#ifdef VIRTUAL
|
||||
uint32_t dstip = udpDetails.dstip;
|
||||
int dstport = udpDetails.dstport;
|
||||
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
||||
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, udpport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, udpport) == FAIL) {
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff);
|
||||
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, dstport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, dstport) == FAIL) {
|
||||
FILE_LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
@@ -636,6 +640,15 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
|
||||
/* aquisition */
|
||||
|
||||
int setDetectorPosition(int pos[]) {
|
||||
memcpy(detPos, pos, sizeof(detPos));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int* getDetectorPosition() {
|
||||
return detPos;
|
||||
}
|
||||
|
||||
int startStateMachine(){
|
||||
#ifdef VIRTUAL
|
||||
// create udp socket
|
||||
@@ -658,6 +671,8 @@ int startStateMachine(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
int64_t periodns = setTimer(FRAME_PERIOD, -1);
|
||||
|
||||
@@ -14,6 +14,21 @@ Here are the definitions, but the actual implementation should be done for each
|
||||
****************************************************/
|
||||
|
||||
enum interfaceType {OUTER, INNER};
|
||||
typedef struct udpStruct_s {
|
||||
int srcport;
|
||||
int srcport2;
|
||||
int dstport;
|
||||
int dstport2;
|
||||
uint64_t srcmac;
|
||||
uint64_t srcmac2;
|
||||
uint64_t dstmac;
|
||||
uint64_t dstmac2;
|
||||
uint32_t srcip;
|
||||
uint32_t srcip2;
|
||||
uint32_t dstip;
|
||||
uint32_t dstip2;
|
||||
}udpStruct;
|
||||
|
||||
|
||||
// basic tests
|
||||
int isFirmwareCheckDone();
|
||||
@@ -263,19 +278,14 @@ long int calcChecksum(int sourceip, int destip);
|
||||
int getAdcConfigured();
|
||||
#endif
|
||||
|
||||
#ifdef EIGERD
|
||||
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2);
|
||||
#elif JUNGFRAUD
|
||||
int configureMAC(int numInterfaces, int selInterface,
|
||||
uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport,
|
||||
uint32_t destip2, uint64_t destmac2, uint64_t sourcemac2, uint32_t sourceip2, uint32_t udpport2);
|
||||
#else
|
||||
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport);
|
||||
#endif
|
||||
|
||||
#if defined(JUNGFRAUD) || defined(EIGERD)
|
||||
|
||||
int configureMAC();
|
||||
int setDetectorPosition(int pos[]);
|
||||
#endif
|
||||
int* getDetectorPosition();
|
||||
int isConfigurable();
|
||||
|
||||
|
||||
#ifdef EIGERD
|
||||
int setQuad(int value);
|
||||
int getQuad();
|
||||
|
||||
@@ -56,7 +56,6 @@ int get_last_client_ip(int);
|
||||
int set_port(int);
|
||||
int update_client(int);
|
||||
int send_update(int);
|
||||
int configure_mac(int);
|
||||
int calibrate_pedestal(int);
|
||||
int enable_ten_giga(int);
|
||||
int set_all_trimbits(int);
|
||||
@@ -108,6 +107,35 @@ int set_interrupt_subframe(int);
|
||||
int get_interrupt_subframe(int);
|
||||
int set_read_n_lines(int);
|
||||
int get_read_n_lines(int);
|
||||
void calculate_and_set_position();
|
||||
int set_detector_position(int);
|
||||
int check_detector_idle();
|
||||
int is_configurable();
|
||||
void configure_mac();
|
||||
int set_source_udp_ip(int);
|
||||
int get_source_udp_ip(int);
|
||||
int set_source_udp_ip2(int);
|
||||
int get_source_udp_ip2(int);
|
||||
int set_dest_udp_ip(int);
|
||||
int get_dest_udp_ip(int);
|
||||
int set_dest_udp_ip2(int);
|
||||
int get_dest_udp_ip2(int);
|
||||
int set_source_udp_mac(int);
|
||||
int get_source_udp_mac(int);
|
||||
int set_source_udp_mac2(int);
|
||||
int get_source_udp_mac2(int);
|
||||
int set_dest_udp_mac(int);
|
||||
int get_dest_udp_mac(int);
|
||||
int set_dest_udp_mac2(int);
|
||||
int get_dest_udp_mac2(int);
|
||||
int set_dest_udp_port(int);
|
||||
int get_dest_udp_port(int);
|
||||
int set_dest_udp_port2(int);
|
||||
int get_dest_udp_port2(int);
|
||||
int set_num_interfaces(int);
|
||||
int get_num_interfaces(int);
|
||||
int set_interface_sel(int);
|
||||
int get_interface_sel(int);
|
||||
int set_parallel_mode(int);
|
||||
int get_parallel_mode(int);
|
||||
int set_overflow_mode(int);
|
||||
|
||||
@@ -39,12 +39,17 @@ extern char mess[MAX_STR_LENGTH];
|
||||
// Variables that will be exported
|
||||
int sockfd = 0;
|
||||
int debugflag = 0;
|
||||
udpStruct udpDetails = {32410, 32411, 50001, 50002, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
int configured = FAIL;
|
||||
char configureMessage[MAX_STR_LENGTH]="";
|
||||
int maxydet = -1;
|
||||
int detectorId = -1;
|
||||
|
||||
|
||||
|
||||
// Local variables
|
||||
int (*flist[NUM_DET_FUNCTIONS])(int);
|
||||
#ifdef EIGERD
|
||||
uint32_t dhcpipad = 0;
|
||||
#endif
|
||||
|
||||
|
||||
enum updateRet {NO_UPDATE, UPDATE};
|
||||
|
||||
@@ -63,9 +68,6 @@ void init_detector() {
|
||||
if (isControlServer) {
|
||||
basictests();
|
||||
initControlServer();
|
||||
#ifdef EIGERD
|
||||
dhcpipad = getDetectorIP();
|
||||
#endif
|
||||
}
|
||||
else initStopServer();
|
||||
strcpy(mess,"dummy message");
|
||||
@@ -199,7 +201,6 @@ const char* getFunctionName(enum detFuncs func) {
|
||||
case F_GET_LAST_CLIENT_IP: return "F_GET_LAST_CLIENT_IP";
|
||||
case F_SET_PORT: return "F_SET_PORT";
|
||||
case F_UPDATE_CLIENT: return "F_UPDATE_CLIENT";
|
||||
case F_CONFIGURE_MAC: return "F_CONFIGURE_MAC";
|
||||
case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA";
|
||||
case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS";
|
||||
case F_SET_PATTERN_IO_CONTROL: return "F_SET_PATTERN_IO_CONTROL";
|
||||
@@ -250,6 +251,31 @@ const char* getFunctionName(enum detFuncs func) {
|
||||
case F_GET_INTERRUPT_SUBFRAME: return "F_GET_INTERRUPT_SUBFRAME";
|
||||
case F_SET_READ_N_LINES: return "F_SET_READ_N_LINES";
|
||||
case F_GET_READ_N_LINES: return "F_GET_READ_N_LINES";
|
||||
case F_SET_POSITION: return "F_SET_POSITION";
|
||||
case F_SET_SOURCE_UDP_MAC: return "F_SET_SOURCE_UDP_MAC";
|
||||
case F_GET_SOURCE_UDP_MAC: return "F_GET_SOURCE_UDP_MAC";
|
||||
case F_SET_SOURCE_UDP_MAC2: return "F_SET_SOURCE_UDP_MAC2";
|
||||
case F_GET_SOURCE_UDP_MAC2: return "F_GET_SOURCE_UDP_MAC2";
|
||||
case F_SET_SOURCE_UDP_IP: return "F_SET_SOURCE_UDP_IP";
|
||||
case F_GET_SOURCE_UDP_IP: return "F_GET_SOURCE_UDP_IP";
|
||||
case F_SET_SOURCE_UDP_IP2: return "F_SET_SOURCE_UDP_IP2";
|
||||
case F_GET_SOURCE_UDP_IP2: return "F_GET_SOURCE_UDP_IP2";
|
||||
case F_SET_DEST_UDP_MAC: return "F_SET_DEST_UDP_MAC";
|
||||
case F_GET_DEST_UDP_MAC: return "F_GET_DEST_UDP_MAC";
|
||||
case F_SET_DEST_UDP_MAC2: return "F_SET_DEST_UDP_MAC2";
|
||||
case F_GET_DEST_UDP_MAC2: return "F_GET_DEST_UDP_MAC2";
|
||||
case F_SET_DEST_UDP_IP: return "F_SET_DEST_UDP_IP";
|
||||
case F_GET_DEST_UDP_IP: return "F_GET_DEST_UDP_IP";
|
||||
case F_SET_DEST_UDP_IP2: return "F_SET_DEST_UDP_IP2";
|
||||
case F_GET_DEST_UDP_IP2: return "F_GET_DEST_UDP_IP2";
|
||||
case F_SET_DEST_UDP_PORT: return "F_SET_DEST_UDP_PORT";
|
||||
case F_GET_DEST_UDP_PORT: return "F_GET_DEST_UDP_PORT";
|
||||
case F_SET_DEST_UDP_PORT2: return "F_SET_DEST_UDP_PORT2";
|
||||
case F_GET_DEST_UDP_PORT2: return "F_GET_DEST_UDP_PORT2";
|
||||
case F_SET_NUM_INTERFACES: return "F_SET_NUM_INTERFACES";
|
||||
case F_GET_NUM_INTERFACES: return "F_GET_NUM_INTERFACES";
|
||||
case F_SET_INTERFACE_SEL: return "F_SET_INTERFACE_SEL";
|
||||
case F_GET_INTERFACE_SEL: return "F_GET_INTERFACE_SEL";
|
||||
case F_SET_PARALLEL_MODE: return "F_SET_PARALLEL_MODE";
|
||||
case F_GET_PARALLEL_MODE: return "F_GET_PARALLEL_MODE";
|
||||
case F_SET_OVERFLOW_MODE: return "F_SET_OVERFLOW_MODE";
|
||||
@@ -294,7 +320,6 @@ void function_table() {
|
||||
flist[F_GET_LAST_CLIENT_IP] = &get_last_client_ip;
|
||||
flist[F_SET_PORT] = &set_port;
|
||||
flist[F_UPDATE_CLIENT] = &update_client;
|
||||
flist[F_CONFIGURE_MAC] = &configure_mac;
|
||||
flist[F_ENABLE_TEN_GIGA] = &enable_ten_giga;
|
||||
flist[F_SET_ALL_TRIMBITS] = &set_all_trimbits;
|
||||
flist[F_SET_PATTERN_IO_CONTROL] = &set_pattern_io_control;
|
||||
@@ -345,6 +370,31 @@ void function_table() {
|
||||
flist[F_GET_INTERRUPT_SUBFRAME] = &get_interrupt_subframe;
|
||||
flist[F_SET_READ_N_LINES] = &set_read_n_lines;
|
||||
flist[F_GET_READ_N_LINES] = &get_read_n_lines;
|
||||
flist[F_SET_POSITION] = &set_detector_position;
|
||||
flist[F_SET_SOURCE_UDP_MAC] = &set_source_udp_mac;
|
||||
flist[F_GET_SOURCE_UDP_MAC] = &get_source_udp_mac;
|
||||
flist[F_SET_SOURCE_UDP_MAC2] = &set_source_udp_mac2;
|
||||
flist[F_GET_SOURCE_UDP_MAC2] = &get_source_udp_mac2;
|
||||
flist[F_SET_SOURCE_UDP_IP] = &set_source_udp_ip;
|
||||
flist[F_GET_SOURCE_UDP_IP] = &get_source_udp_ip;
|
||||
flist[F_SET_SOURCE_UDP_IP2] = &set_source_udp_ip2;
|
||||
flist[F_GET_SOURCE_UDP_IP2] = &get_source_udp_ip2;
|
||||
flist[F_SET_DEST_UDP_MAC] = &set_dest_udp_mac;
|
||||
flist[F_GET_DEST_UDP_MAC] = &get_dest_udp_mac;
|
||||
flist[F_SET_DEST_UDP_MAC2] = &set_dest_udp_mac2;
|
||||
flist[F_GET_DEST_UDP_MAC2] = &get_dest_udp_mac2;
|
||||
flist[F_SET_DEST_UDP_IP] = &set_dest_udp_ip;
|
||||
flist[F_GET_DEST_UDP_IP] = &get_dest_udp_ip;
|
||||
flist[F_SET_DEST_UDP_IP2] = &set_dest_udp_ip2;
|
||||
flist[F_GET_DEST_UDP_IP2] = &get_dest_udp_ip2;
|
||||
flist[F_SET_DEST_UDP_PORT] = &set_dest_udp_port;
|
||||
flist[F_GET_DEST_UDP_PORT] = &get_dest_udp_port;
|
||||
flist[F_SET_DEST_UDP_PORT2] = &set_dest_udp_port2;
|
||||
flist[F_GET_DEST_UDP_PORT2] = &get_dest_udp_port2;
|
||||
flist[F_SET_NUM_INTERFACES] = &set_num_interfaces;
|
||||
flist[F_GET_NUM_INTERFACES] = &get_num_interfaces;
|
||||
flist[F_SET_INTERFACE_SEL] = &set_interface_sel;
|
||||
flist[F_GET_INTERFACE_SEL] = &get_interface_sel;
|
||||
flist[F_SET_PARALLEL_MODE] = &set_parallel_mode;
|
||||
flist[F_GET_PARALLEL_MODE] = &get_parallel_mode;
|
||||
flist[F_SET_OVERFLOW_MODE] = &set_overflow_mode;
|
||||
@@ -1501,15 +1551,35 @@ int start_acquisition(int file_des) {
|
||||
FILE_LOG(logDEBUG1, ("Starting Acquisition\n"));
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
ret = startStateMachine();
|
||||
if (ret == FAIL) {
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
sprintf(mess, "Could not start acquisition. Could not create udp socket in server. Check rx_udpip & rx_udpport.\n");
|
||||
#else
|
||||
sprintf(mess, "Could not start acquisition\n");
|
||||
#endif
|
||||
#ifdef EIGERD
|
||||
// check for hardware mac and hardware ip
|
||||
if (udpDetails.srcmac != getDetectorMAC()) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Invalid udp source mac address for this detector. Must be same as hardware detector mac address \n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
else if (!enableTenGigabitEthernet(-1) && (udpDetails.srcip != getDetectorIP())) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Invalid udp source ip address for this detector. Must be same as hardware detector ip address in 1G readout mode \n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (configured == FAIL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not start acquisition because %s\n", configureMessage);
|
||||
FILE_LOG(logERROR,(mess));
|
||||
} else {
|
||||
ret = startStateMachine();
|
||||
if (ret == FAIL) {
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
sprintf(mess, "Could not start acquisition. Could not create udp socket in server. Check rx_udpip & rx_udpport.\n");
|
||||
#else
|
||||
sprintf(mess, "Could not start acquisition\n");
|
||||
#endif
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
}
|
||||
FILE_LOG(logDEBUG2, ("Starting Acquisition ret: %d\n", ret));
|
||||
}
|
||||
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
|
||||
@@ -1589,17 +1659,36 @@ int start_and_read_all(int file_des) {
|
||||
FILE_LOG(logDEBUG1, ("Starting Acquisition\n"));
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
ret = startStateMachine();
|
||||
if (ret == FAIL) {
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
sprintf(mess, "Could not start acquisition. Could not create udp socket in server. Check rx_udpip & rx_udpport.\n");
|
||||
#else
|
||||
sprintf(mess, "Could not start acquisition\n");
|
||||
#endif
|
||||
#ifdef EIGERD
|
||||
// check for hardware mac and hardware ip
|
||||
if (udpDetails.srcmac != getDetectorMAC()) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Invalid udp source mac address for this detector. Must be same as hardware detector mac address \n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
else if (!enableTenGigabitEthernet(-1) && (udpDetails.srcip != getDetectorIP())) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Invalid udp source ip address for this detector. Must be same as hardware detector ip address in 1G readout mode \n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (configured == FAIL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not start acquisition because %s\n", configureMessage);
|
||||
FILE_LOG(logERROR,(mess));
|
||||
} else {
|
||||
ret = startStateMachine();
|
||||
if (ret == FAIL) {
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
sprintf(mess, "Could not start acquisition. Could not create udp socket in server. Check rx_udpip & rx_udpport.\n");
|
||||
#else
|
||||
sprintf(mess, "Could not start acquisition\n");
|
||||
#endif
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
}
|
||||
FILE_LOG(logDEBUG2, ("Starting Acquisition ret: %d\n", ret));
|
||||
|
||||
}
|
||||
|
||||
// lock or acquisition start error
|
||||
@@ -1904,6 +1993,10 @@ int set_roi(int file_des) {
|
||||
sprintf(mess, "Could not set ROI. Invalid xmin or xmax\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
// old firmware requires a redo configure mac
|
||||
else {
|
||||
configure_mac();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2276,7 +2369,7 @@ int send_update(int file_des) {
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
int configure_mac(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
@@ -2435,7 +2528,7 @@ int configure_mac(int file_des) {
|
||||
|
||||
// always remember the ip sent from the client (could be for 10g(if not dhcp))
|
||||
if (srcIp != getDetectorIP())
|
||||
dhcpipad = srcIp;
|
||||
custom10gIp = srcIp;
|
||||
|
||||
//only for 1Gbe, change ip to hardware ip
|
||||
if (!enableTenGigabitEthernet(-1)) {
|
||||
@@ -2444,7 +2537,7 @@ int configure_mac(int file_des) {
|
||||
}
|
||||
// 10 gbe (use ip given from client)
|
||||
else
|
||||
srcIp = dhcpipad;
|
||||
srcIp = custom10gIp;
|
||||
ret = configureMAC(dstIp, dstMac, srcMac, srcIp, dstPort, dstPort2);
|
||||
#elif JUNGFRAUD
|
||||
ret = configureMAC(numInterfaces, selInterface, dstIp, dstMac, srcMac, srcIp, dstPort, dstIp2, dstMac2, srcMac2, srcIp2, dstPort2);
|
||||
@@ -2486,7 +2579,7 @@ int configure_mac(int file_des) {
|
||||
}
|
||||
return Server_SendResult(file_des, OTHER, UPDATE, retvals, sizeof(retvals));
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
int enable_ten_giga(int file_des) {
|
||||
@@ -2497,14 +2590,28 @@ int enable_ten_giga(int file_des) {
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
FILE_LOG(logDEBUG1, ("Enable/ Disable 10GbE : %d\n", arg));
|
||||
FILE_LOG(logINFOBLUE, ("Setting 10GbE: %d\n", arg));
|
||||
|
||||
#if defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// set & get
|
||||
if ((arg == -1) || (Server_VerifyLock() == OK)) {
|
||||
retval = enableTenGigabitEthernet(arg);
|
||||
if (arg >= 0 && enableTenGigabitEthernet(-1) != arg) {
|
||||
enableTenGigabitEthernet(arg);
|
||||
uint64_t hardwaremac = getDetectorMAC();
|
||||
if (udpDetails.srcmac != hardwaremac) {
|
||||
FILE_LOG(logINFOBLUE, ("Updating udp source mac\n"));
|
||||
udpDetails.srcmac = hardwaremac;
|
||||
}
|
||||
uint32_t hardwareip = getDetectorIP();
|
||||
if (arg == 0 && udpDetails.srcip != hardwareip) {
|
||||
FILE_LOG(logINFOBLUE, ("Updating udp source ip\n"));
|
||||
udpDetails.srcip = hardwareip;
|
||||
}
|
||||
configure_mac();
|
||||
}
|
||||
retval = enableTenGigabitEthernet(-1);
|
||||
FILE_LOG(logDEBUG1, ("10GbE: %d\n", retval));
|
||||
validate(arg, retval, "enable/disable 10GbE", DEC);
|
||||
}
|
||||
@@ -4116,6 +4223,678 @@ int get_read_n_lines(int file_des) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void calculate_and_set_position() {
|
||||
if (maxydet == -1 || detectorId == -1) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set detector position (did not get multi size).\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
return;
|
||||
}
|
||||
int maxy = maxydet;
|
||||
#ifdef JUNGFRAUD
|
||||
maxy *= getNumberofUDPInterfaces();
|
||||
#endif
|
||||
int pos[2] = {0, 0};
|
||||
// row
|
||||
pos[0] = (detectorId % maxy);
|
||||
// col for horiz. udp ports
|
||||
pos[1] = (detectorId / maxy);
|
||||
#ifdef EIGERD
|
||||
pos[1] *= 2;
|
||||
#endif
|
||||
FILE_LOG(logDEBUG, ("Setting Positions (%d,%d)\n", pos[0], pos[1]));
|
||||
if(setDetectorPosition(pos) == FAIL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set detector position.\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
// to redo the detector mac (depends on positions)
|
||||
else {
|
||||
// create detector mac from x and y
|
||||
if (udpDetails.srcmac == 0) {
|
||||
char dmac[50];
|
||||
memset(dmac, 0, 50);
|
||||
sprintf(dmac, "aa:bb:cc:dd:%02x:%02x", pos[0]&0xFF, pos[1]&0xFF);
|
||||
FILE_LOG(logINFO, ("Udp source mac address created: %s\n", dmac));
|
||||
unsigned char a[6];
|
||||
sscanf(dmac, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]);
|
||||
udpDetails.srcmac = 0;
|
||||
int i;
|
||||
for (i = 0; i < 6; ++i) {
|
||||
udpDetails.srcmac = (udpDetails.srcmac << 8) + a[i];
|
||||
}
|
||||
}
|
||||
#ifdef JUNGFRAUD
|
||||
if (getNumberofUDPInterfaces() > 1) {
|
||||
if (udpDetails.srcmac2 == 0) {
|
||||
char dmac2[50];
|
||||
memset(dmac2, 0, 50);
|
||||
sprintf(dmac2, "aa:bb:cc:dd:%02x:%02x", (pos[0] + 1 )&0xFF, pos[1]&0xFF);
|
||||
FILE_LOG(logINFO, ("Udp source mac address2 created: %s\n", dmac2));
|
||||
unsigned char a[6];
|
||||
sscanf(dmac2, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]);
|
||||
udpDetails.srcmac2 = 0;
|
||||
int i;
|
||||
for (i = 0; i < 6; ++i) {
|
||||
udpDetails.srcmac2 = (udpDetails.srcmac2 << 8) + a[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
configure_mac();
|
||||
}
|
||||
// no need to do a get (also jungfrau gives bigger set for second)
|
||||
}
|
||||
|
||||
|
||||
int set_detector_position(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int args[2] = { 0, 0};
|
||||
|
||||
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
FILE_LOG(logINFO, ("Setting detector positions: [%u, %u]\n", args[0], args[1]));
|
||||
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle() == OK) {
|
||||
maxydet = args[0];
|
||||
detectorId = args[1];
|
||||
calculate_and_set_position();
|
||||
}
|
||||
}
|
||||
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
int check_detector_idle() {
|
||||
enum runStatus status = getRunStatus();
|
||||
if (status != IDLE && status != RUN_FINISHED && status != STOPPED) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Cannot configure mac when detector is not idle. Detector at %s state\n", getRunStateName(status));
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int is_configurable() {
|
||||
if (udpDetails.srcip == 0) {
|
||||
strcpy(configureMessage, "udp source ip not configured\n");
|
||||
FILE_LOG(logWARNING, ("%s", configureMessage));
|
||||
return FAIL;
|
||||
}
|
||||
if (udpDetails.dstip == 0) {
|
||||
strcpy(configureMessage, "udp destination ip not configured\n");
|
||||
FILE_LOG(logWARNING, ("%s", configureMessage));
|
||||
return FAIL;
|
||||
}
|
||||
if (udpDetails.srcmac == 0) {
|
||||
strcpy(configureMessage, "udp source mac not configured\n");
|
||||
FILE_LOG(logWARNING, ("%s", configureMessage));
|
||||
return FAIL;
|
||||
}
|
||||
if (udpDetails.dstmac == 0) {
|
||||
strcpy(configureMessage, "udp destination mac not configured\n");
|
||||
FILE_LOG(logWARNING, ("%s", configureMessage));
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef JUNGFRAUD
|
||||
if (getNumberofUDPInterfaces() == 2) {
|
||||
if (udpDetails.srcip2 == 0) {
|
||||
strcpy(configureMessage, "udp source ip2 not configured\n");
|
||||
FILE_LOG(logWARNING, ("%s", configureMessage));
|
||||
return FAIL;
|
||||
}
|
||||
if (udpDetails.dstip2 == 0) {
|
||||
strcpy(configureMessage, "udp destination ip2 not configured\n");
|
||||
FILE_LOG(logWARNING, ("%s", configureMessage));
|
||||
return FAIL;
|
||||
}
|
||||
if (udpDetails.srcmac2 == 0) {
|
||||
strcpy(configureMessage, "udp source mac2 not configured\n");
|
||||
FILE_LOG(logWARNING, ("%s", configureMessage));
|
||||
return FAIL;
|
||||
}
|
||||
if (udpDetails.dstmac2 == 0) {
|
||||
strcpy(configureMessage, "udp destination mac2 not configured\n");
|
||||
FILE_LOG(logWARNING, ("%s", configureMessage));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
void configure_mac() {
|
||||
if (is_configurable() == OK) {
|
||||
ret = configureMAC();
|
||||
if (ret != OK) {
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
if (ret == -1) {
|
||||
sprintf(mess, "Could not allocate RAM\n");
|
||||
} else {
|
||||
sprintf(mess,"Could not configure mac because of incorrect udp 1G destination IP and port\n");
|
||||
}
|
||||
#else
|
||||
sprintf(mess,"Configure Mac failed\n");
|
||||
#endif
|
||||
strcpy(configureMessage, mess);
|
||||
FILE_LOG(logERROR,(mess));
|
||||
} else {
|
||||
FILE_LOG(logINFOGREEN, ("\tConfigure MAC successful\n"));
|
||||
configured = OK;
|
||||
return;
|
||||
}
|
||||
}
|
||||
configured = FAIL;
|
||||
FILE_LOG(logWARNING, ("Configure FAIL, not all parameters configured yet\n"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int set_source_udp_ip(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint32_t arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
arg = __builtin_bswap32(arg);
|
||||
FILE_LOG(logINFO, ("Setting udp source ip: 0x%x\n", arg));
|
||||
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle() == OK) {
|
||||
if (udpDetails.srcip != arg) {
|
||||
udpDetails.srcip = arg;
|
||||
configure_mac();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
int get_source_udp_ip(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint32_t retval = -1;
|
||||
FILE_LOG(logDEBUG1, ("Getting udp source ip\n"));
|
||||
|
||||
// get only
|
||||
retval = udpDetails.srcip;
|
||||
retval = __builtin_bswap32(retval);
|
||||
FILE_LOG(logDEBUG1, ("udp soure ip retval: 0x%x\n", retval));
|
||||
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int set_source_udp_ip2(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint32_t arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
arg = __builtin_bswap32(arg);
|
||||
FILE_LOG(logINFO, ("Setting udp source ip2: 0x%x\n", arg));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle() == OK) {
|
||||
if (udpDetails.srcip2 != arg) {
|
||||
udpDetails.srcip2 = arg;
|
||||
configure_mac();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
int get_source_udp_ip2(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint32_t retval = -1;
|
||||
FILE_LOG(logDEBUG1, ("Getting udp source ip2\n"));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = udpDetails.srcip2;
|
||||
retval = __builtin_bswap32(retval);
|
||||
FILE_LOG(logDEBUG1, ("udp soure ip2 retval: 0x%x\n", retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
int set_dest_udp_ip(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint32_t arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
arg = __builtin_bswap32(arg);
|
||||
FILE_LOG(logINFO, ("Setting udp destination ip: 0x%x\n", arg));
|
||||
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle() == OK) {
|
||||
if (udpDetails.dstip != arg) {
|
||||
udpDetails.dstip = arg;
|
||||
configure_mac();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
int get_dest_udp_ip(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint32_t retval = -1;
|
||||
FILE_LOG(logDEBUG1, ("Getting destination ip\n"));
|
||||
|
||||
// get only
|
||||
retval = udpDetails.dstip;
|
||||
retval = __builtin_bswap32(retval);
|
||||
FILE_LOG(logDEBUG1, ("udp destination ip retval: 0x%x\n", retval));
|
||||
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int set_dest_udp_ip2(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint32_t arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
arg = __builtin_bswap32(arg);
|
||||
FILE_LOG(logINFO, ("Setting udp destination ip2: 0x%x\n", arg));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle() == OK) {
|
||||
if (udpDetails.dstip2 != arg) {
|
||||
udpDetails.dstip2 = arg;
|
||||
configure_mac();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
int get_dest_udp_ip2(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint32_t retval = -1;
|
||||
FILE_LOG(logDEBUG1, ("Getting udp destination ip2\n"));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = udpDetails.dstip2;
|
||||
retval = __builtin_bswap32(retval);
|
||||
FILE_LOG(logDEBUG1, ("udp destination ip2 retval: 0x%x\n", retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int set_source_udp_mac(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint64_t arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT64) < 0)
|
||||
return printSocketReadError();
|
||||
FILE_LOG(logINFO, ("Setting udp source mac: 0x%lx\n", arg));
|
||||
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle() == OK) {
|
||||
if (udpDetails.srcmac != arg) {
|
||||
udpDetails.srcmac = arg;
|
||||
configure_mac();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Server_SendResult(file_des, INT64, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
int get_source_udp_mac(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint64_t retval = -1;
|
||||
FILE_LOG(logDEBUG1, ("Getting udp source mac\n"));
|
||||
|
||||
// get only
|
||||
retval = udpDetails.srcmac;
|
||||
FILE_LOG(logDEBUG1, ("udp soure mac retval: 0x%lx\n", retval));
|
||||
|
||||
return Server_SendResult(file_des, INT64, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
|
||||
int set_source_udp_mac2(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint64_t arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT64) < 0)
|
||||
return printSocketReadError();
|
||||
FILE_LOG(logINFO, ("Setting udp source mac2: 0x%lx\n", arg));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle() == OK) {
|
||||
if (udpDetails.srcmac2 != arg) {
|
||||
udpDetails.srcmac2 = arg;
|
||||
configure_mac();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
int get_source_udp_mac2(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint64_t retval = -1;
|
||||
FILE_LOG(logDEBUG1, ("Getting udp source mac2\n"));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = udpDetails.srcmac2;
|
||||
FILE_LOG(logDEBUG1, ("udp soure mac2 retval: 0x%lx\n", retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
|
||||
int set_dest_udp_mac(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint64_t arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT64) < 0)
|
||||
return printSocketReadError();
|
||||
FILE_LOG(logINFO, ("Setting udp destination mac: 0x%lx\n", arg));
|
||||
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle() == OK) {
|
||||
if (udpDetails.dstmac != arg) {
|
||||
udpDetails.dstmac = arg;
|
||||
configure_mac();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Server_SendResult(file_des, INT64, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
int get_dest_udp_mac(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint64_t retval = -1;
|
||||
FILE_LOG(logDEBUG1, ("Getting udp destination mac\n"));
|
||||
|
||||
// get only
|
||||
retval = udpDetails.dstmac;
|
||||
FILE_LOG(logDEBUG1, ("udp destination mac retval: 0x%lx\n", retval));
|
||||
|
||||
return Server_SendResult(file_des, INT64, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int set_dest_udp_mac2(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint64_t arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT64) < 0)
|
||||
return printSocketReadError();
|
||||
FILE_LOG(logINFO, ("Setting udp destination mac2: 0x%lx\n", arg));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle() == OK) {
|
||||
if (udpDetails.dstmac2 != arg) {
|
||||
udpDetails.dstmac2 = arg;
|
||||
configure_mac();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
int get_dest_udp_mac2(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint64_t retval = -1;
|
||||
FILE_LOG(logDEBUG1, ("Getting udp destination mac2\n"));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = udpDetails.dstmac2;
|
||||
FILE_LOG(logDEBUG1, ("udp destination mac2 retval: 0x%lx\n", retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int set_dest_udp_port(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
FILE_LOG(logINFO, ("Setting udp destination port: %u\n", arg));
|
||||
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle() == OK) {
|
||||
if (udpDetails.dstport != arg) {
|
||||
udpDetails.dstport = arg;
|
||||
configure_mac();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
int get_dest_udp_port(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retval = -1;
|
||||
FILE_LOG(logDEBUG1, ("Getting destination port\n"));
|
||||
|
||||
// get only
|
||||
retval = udpDetails.dstport;
|
||||
FILE_LOG(logDEBUG, ("udp destination port retval: %u\n", retval));
|
||||
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int set_dest_udp_port2(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
FILE_LOG(logINFO, ("Setting udp destination port2: %u\n", arg));
|
||||
|
||||
#if !defined(JUNGFRAUD) && !defined(EIGERD)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle() == OK) {
|
||||
if (udpDetails.dstport2 != arg) {
|
||||
udpDetails.dstport2 = arg;
|
||||
configure_mac();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
int get_dest_udp_port2(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retval = -1;
|
||||
FILE_LOG(logDEBUG1, ("Getting destination port2\n"));
|
||||
|
||||
#if !defined(JUNGFRAUD) && !defined(EIGERD)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = udpDetails.dstport2;
|
||||
FILE_LOG(logDEBUG1, ("udp destination port2 retval: %u\n", retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int set_num_interfaces(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
FILE_LOG(logINFO, ("Setting number of interfaces: %d\n", arg));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle() == OK) {
|
||||
if (getNumberofUDPInterfaces() != arg) {
|
||||
setNumberofUDPInterfaces(arg);
|
||||
calculate_and_set_position(); // aleady configures mac
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
int get_num_interfaces(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retval = -1;
|
||||
FILE_LOG(logDEBUG1, ("Getting number of udp interfaces\n"));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
retval = 1;
|
||||
#else
|
||||
// get only
|
||||
retval = getNumberofUDPInterfaces();
|
||||
#endif
|
||||
FILE_LOG(logDEBUG1, ("Number of udp interfaces retval: %u\n", retval));
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int set_interface_sel(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
FILE_LOG(logINFO, ("Setting selected interface: %d\n", arg));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (check_detector_idle() == OK) {
|
||||
if (getPrimaryInterface() != arg) {
|
||||
selectPrimaryInterface(arg);
|
||||
configure_mac();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
int get_interface_sel(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retval = -1;
|
||||
FILE_LOG(logDEBUG1, ("Getting selected interface\n"));
|
||||
|
||||
#ifndef JUNGFRAUD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
retval = getPrimaryInterface();
|
||||
FILE_LOG(logDEBUG1, ("Selected interface retval: %u\n", retval));
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
|
||||
int set_parallel_mode(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
@@ -4323,3 +5102,4 @@ int get_readout_mode(int file_des) {
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user