AcquisitionDevice: IPv4 address and UDP destination port is property of the device and not of a particular run
This commit is contained in:
@@ -912,7 +912,7 @@ DiffractionExperiment::operator JFJochProtoBuf::DetectorInput() const {
|
||||
|
||||
JFJochProtoBuf::DetectorConfig DiffractionExperiment::DetectorConfig(const JFJochProtoBuf::ReceiverNetworkConfig &net_config) const {
|
||||
JFJochProtoBuf::DetectorConfig ret;
|
||||
if (net_config.fpga_mac_addr_size() < GetDataStreamsNum())
|
||||
if (net_config.device_size() < GetDataStreamsNum())
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds,
|
||||
"Number of FPGA boards in the receiver is less then necessary");
|
||||
|
||||
@@ -924,16 +924,17 @@ JFJochProtoBuf::DetectorConfig DiffractionExperiment::DetectorConfig(const JFJoc
|
||||
*ret.mutable_module_hostname() = internal.detector().module_hostname();
|
||||
|
||||
for (int d = 0; d < GetDataStreamsNum(); d++) {
|
||||
for (int module = 0; module < GetModulesNum(d); module++) {
|
||||
for (int m = 0; m < GetModulesNum(d); m++) {
|
||||
auto mod_cfg = ret.add_modules();
|
||||
mod_cfg->set_udp_dest_port_1(GetDestUDPPort(d, 2 * module));
|
||||
mod_cfg->set_udp_dest_port_2(GetDestUDPPort(d, 2 * module + 1));
|
||||
mod_cfg->set_ipv4_src_addr_1(IPv4AddressToStr(GetSrcIPv4Address(d, 2 * module)));
|
||||
mod_cfg->set_ipv4_src_addr_2(IPv4AddressToStr(GetSrcIPv4Address(d, 2 * module + 1)));
|
||||
mod_cfg->set_ipv4_dest_addr_1(IPv4AddressToStr(GetDestIPv4Address(d)));
|
||||
mod_cfg->set_ipv4_dest_addr_2(IPv4AddressToStr(GetDestIPv4Address(d)));
|
||||
mod_cfg->set_mac_addr_dest_1(net_config.fpga_mac_addr(d));
|
||||
mod_cfg->set_mac_addr_dest_2(net_config.fpga_mac_addr(d));
|
||||
mod_cfg->set_udp_dest_port_1(net_config.device(d).udp_port());
|
||||
mod_cfg->set_udp_dest_port_2(net_config.device(d).udp_port());
|
||||
mod_cfg->set_ipv4_src_addr_1(IPv4AddressToStr(GetSrcIPv4Address(d, 2 * m)));
|
||||
mod_cfg->set_ipv4_src_addr_2(IPv4AddressToStr(GetSrcIPv4Address(d, 2 * m + 1)));
|
||||
mod_cfg->set_ipv4_dest_addr_1(net_config.device(d).ipv4_addr());
|
||||
mod_cfg->set_ipv4_dest_addr_2(net_config.device(d).ipv4_addr());
|
||||
mod_cfg->set_mac_addr_dest_1(net_config.device(d).mac_addr());
|
||||
mod_cfg->set_mac_addr_dest_2(net_config.device(d).mac_addr());
|
||||
mod_cfg->set_module_id_in_data_stream(m);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
+8
-4
@@ -3,19 +3,23 @@
|
||||
"device": [
|
||||
{
|
||||
"id" : 1,
|
||||
"type": "pcie"
|
||||
"type": "pcie",
|
||||
"ipv4_addr": "10.10.85.1"
|
||||
},
|
||||
{
|
||||
"id" : 3,
|
||||
"type": "pcie"
|
||||
"type": "pcie",
|
||||
"ipv4_addr": "10.10.85.2"
|
||||
},
|
||||
{
|
||||
"id" : 0,
|
||||
"type": "pcie"
|
||||
"type": "pcie",
|
||||
"ipv4_addr": "10.10.85.3"
|
||||
},
|
||||
{
|
||||
"id" : 2,
|
||||
"type": "pcie"
|
||||
"type": "pcie",
|
||||
"ipv4_addr": "10.10.85.4"
|
||||
}
|
||||
],
|
||||
"tcp_send_buffer_size": 256000000,
|
||||
|
||||
@@ -118,8 +118,15 @@ JFJochProtoBuf::ReceiverNetworkConfig JFJochReceiverClient::GetNetworkConfig() {
|
||||
"JFJochReceiver: " + status.error_message());
|
||||
} else {
|
||||
// For tests to work, dummy receiver needs to replay with nonsense MAC addresses
|
||||
ret.add_fpga_mac_addr("00:00:00:00:00:00");
|
||||
ret.add_fpga_mac_addr("00:00:00:00:00:01");
|
||||
auto d1 = ret.add_device();
|
||||
d1->set_mac_addr("00:00:00:00:00:00");
|
||||
d1->set_ipv4_addr("10.10.50.1");
|
||||
d1->set_udp_port(1234);
|
||||
|
||||
auto d2 = ret.add_device();
|
||||
d2->set_mac_addr("00:00:00:00:00:01");
|
||||
d2->set_ipv4_addr("10.10.50.2");
|
||||
d2->set_udp_port(1234);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
+7
-1
@@ -252,8 +252,14 @@ message ReceiverOutput {
|
||||
optional float indexing_rate = 13;
|
||||
}
|
||||
|
||||
message ReceiverNetworkConfigDevice {
|
||||
string mac_addr = 1;
|
||||
string ipv4_addr = 2;
|
||||
uint64 udp_port = 3;
|
||||
}
|
||||
|
||||
message ReceiverNetworkConfig {
|
||||
repeated string fpga_mac_addr = 1;
|
||||
repeated ReceiverNetworkConfigDevice device = 1;
|
||||
}
|
||||
|
||||
message ReceiverStatus {
|
||||
|
||||
+69
-67
File diff suppressed because one or more lines are too long
@@ -164,7 +164,11 @@ grpc::Status JFJochReceiverService::GetPreviewFrame(grpc::ServerContext *context
|
||||
|
||||
grpc::Status JFJochReceiverService::GetNetworkConfig(grpc::ServerContext *context, const JFJochProtoBuf::Empty *request,
|
||||
JFJochProtoBuf::ReceiverNetworkConfig *response) {
|
||||
for (const auto &aq: aq_devices)
|
||||
response->add_fpga_mac_addr(aq->GetMACAddress());
|
||||
for (const auto &aq: aq_devices) {
|
||||
auto dev_net_cfg = response->add_device();
|
||||
dev_net_cfg->set_mac_addr(aq->GetMACAddress());
|
||||
dev_net_cfg->set_ipv4_addr(aq->GetIPv4Address());
|
||||
dev_net_cfg->set_udp_port(aq->GetUDPPort());
|
||||
}
|
||||
return grpc::Status::OK;
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "../../common/JFJochException.h"
|
||||
#include "AcquisitionDevice.h"
|
||||
|
||||
#include "../../common/NetworkAddressConvert.h"
|
||||
|
||||
void *mmap_acquisition_buffer(size_t size, int16_t numa_node) {
|
||||
void *ret = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
@@ -54,12 +54,11 @@ uint64_t AcquisitionDevice::GetBufferHandle(size_t frame, uint8_t module_number)
|
||||
|
||||
void AcquisitionDevice::FillActionRegister(const DiffractionExperiment& x, ActionConfig &job) {
|
||||
|
||||
job.fpga_ipv4_addr = x.GetDestIPv4Address(data_stream);
|
||||
job.nmodules = x.GetModulesNum(data_stream);
|
||||
job.frames_internal_packet_gen = x.GetFrameNum();
|
||||
job.one_over_energy = std::lround((1<<20)/ x.GetPhotonEnergy_keV());
|
||||
job.nstorage_cells = x.GetStorageCellNumber() - 1;
|
||||
job.mode = 0;
|
||||
job.nmodules = x.GetModulesNum(data_stream);
|
||||
job.nframes = x.GetFrameNum();
|
||||
job.one_over_energy = std::lround((1<<20)/ x.GetPhotonEnergy_keV());
|
||||
job.nstorage_cells = x.GetStorageCellNumber() - 1;
|
||||
job.mode = 0;
|
||||
|
||||
if ((x.GetDetectorMode() == DetectorMode::Conversion) && x.GetConversionOnFPGA())
|
||||
job.mode |= MODE_CONV;
|
||||
@@ -112,10 +111,7 @@ void AcquisitionDevice::StartAction(const DiffractionExperiment &experiment) {
|
||||
if (cfg_out.mode != cfg_in.mode)
|
||||
throw JFJochException(JFJochExceptionCategory::AcquisitionDeviceError,
|
||||
"Mismatch between expected and actual values of configuration registers (mode)");
|
||||
if (cfg_out.fpga_ipv4_addr != cfg_in.fpga_ipv4_addr)
|
||||
throw JFJochException(JFJochExceptionCategory::AcquisitionDeviceError,
|
||||
"Mismatch between expected and actual values of configuration registers (FPGA IPv4 Addr)");
|
||||
if (cfg_out.frames_internal_packet_gen != cfg_in.frames_internal_packet_gen)
|
||||
if (cfg_out.nframes != cfg_in.nframes)
|
||||
throw JFJochException(JFJochExceptionCategory::AcquisitionDeviceError,
|
||||
"Mismatch between expected and actual values of configuration registers (Frames per trigger)");
|
||||
if (cfg_out.nmodules != cfg_in.nmodules)
|
||||
@@ -433,13 +429,11 @@ JFJochProtoBuf::FPGAStatus AcquisitionDevice::GetStatus() const {
|
||||
}
|
||||
|
||||
std::string AcquisitionDevice::GetMACAddress() const {
|
||||
uint64_t mac_address_network_order = HW_GetMACAddress();
|
||||
std::ostringstream ss;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
ss << std::setfill('0') << std::setw(2) << std::hex << ((mac_address_network_order >> (i * 8)) & 0xFF);
|
||||
if (i != 5) ss << ":";
|
||||
}
|
||||
return ss.str();
|
||||
return MacAddressToStr(HW_GetMACAddress());
|
||||
}
|
||||
|
||||
std::string AcquisitionDevice::GetIPv4Address() const {
|
||||
return IPv4AddressToStr(HW_GetIPv4Address());
|
||||
}
|
||||
|
||||
ActionConfig AcquisitionDevice::ReadActionRegister() {
|
||||
@@ -452,6 +446,10 @@ int32_t AcquisitionDevice::GetNUMANode() const {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint16_t AcquisitionDevice::GetUDPPort() const {
|
||||
return 1234;
|
||||
}
|
||||
|
||||
uint64_t AcquisitionDevice::GetBunchID(size_t curr_frame, uint16_t module_number) const {
|
||||
return counters.GetBunchID(curr_frame, module_number);
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ class AcquisitionDevice {
|
||||
virtual void HW_GetEnvParams(ActionEnvParams *status) const {
|
||||
memset(status, 0, sizeof(ActionEnvParams));
|
||||
}
|
||||
virtual uint32_t HW_GetIPv4Address() const = 0;
|
||||
virtual uint64_t HW_GetMACAddress() const = 0;
|
||||
virtual void HW_EndAction() {}; // do clean-up after action is done
|
||||
virtual void CopyInternalPacketGenFrameToDeviceBuffer();
|
||||
@@ -126,8 +127,9 @@ public:
|
||||
ActionConfig ReadActionRegister();
|
||||
bool IsDone() const;
|
||||
|
||||
std::string GetIPv4Address() const;
|
||||
std::string GetMACAddress() const;
|
||||
|
||||
virtual uint16_t GetUDPPort() const;
|
||||
virtual int32_t GetNUMANode() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -15,11 +15,10 @@ typedef __u64 uint64_t;
|
||||
#pragma pack(4)
|
||||
|
||||
struct ActionConfig {
|
||||
uint32_t fpga_ipv4_addr;
|
||||
uint32_t nmodules;
|
||||
uint32_t mode;
|
||||
uint32_t one_over_energy;
|
||||
uint32_t frames_internal_packet_gen;
|
||||
uint32_t nframes;
|
||||
uint32_t nstorage_cells;
|
||||
};
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ void HLSSimulatedDevice::CreatePacketJF(const DiffractionExperiment& experiment,
|
||||
|
||||
packet->ipv4_header_h = htons(0x4500); // Big endian in IP header!
|
||||
packet->ipv4_header_total_length = htons(8268); // Big endian in IP header!
|
||||
packet->ipv4_header_dest_ip = experiment.GetDestIPv4Address(data_stream);
|
||||
packet->ipv4_header_dest_ip = fpga_ipv4_addr;
|
||||
packet->ipv4_header_sour_ip = experiment.GetSrcIPv4Address(data_stream, half_module);
|
||||
|
||||
packet->ipv4_header_ttl_protocol = htons(0x0011);
|
||||
@@ -158,7 +158,7 @@ void HLSSimulatedDevice::HW_StartAction() {
|
||||
(hbm256_t *) (hbm_memory[9].data()),
|
||||
(hbm256_t *) (hbm_memory[10].data()),
|
||||
(hbm256_t *) (hbm_memory[11].data()),
|
||||
din_eth, dout_eth, fpga_mac_addr, cfg,
|
||||
din_eth, dout_eth, fpga_mac_addr, fpga_ipv4_addr, cfg,
|
||||
work_request_stream,
|
||||
completion_stream,
|
||||
run_data_collection,
|
||||
@@ -219,6 +219,7 @@ void hls_action(hls::stream<axis_datamover_ctrl> &in_datamover_cmd_stream,
|
||||
hbm256_t *d_hbm_p10, hbm256_t *d_hbm_p11,
|
||||
AXI_STREAM &din_eth, AXI_STREAM &dout_eth,
|
||||
uint64_t fpga_mac_addr,
|
||||
uint32_t fpga_ipv4_addr,
|
||||
const ActionConfig &act_reg,
|
||||
hls::stream<ap_uint<32> > &s_axis_work_request,
|
||||
hls::stream<ap_uint<32> > &m_axis_completion,
|
||||
@@ -271,19 +272,19 @@ void hls_action(hls::stream<axis_datamover_ctrl> &in_datamover_cmd_stream,
|
||||
ethernet(din_eth, ip1, arp1, fpga_mac_addr, eth_packets, clear_counters);
|
||||
|
||||
while(!ip1.empty())
|
||||
ipv4(ip1, udp1, icmp1, act_reg.fpga_ipv4_addr);
|
||||
ipv4(ip1, udp1, icmp1, fpga_ipv4_addr);
|
||||
|
||||
arp(arp1,
|
||||
dout_eth,
|
||||
fpga_mac_addr,
|
||||
act_reg.fpga_ipv4_addr,
|
||||
fpga_ipv4_addr,
|
||||
1, run_data_collection);
|
||||
|
||||
while (!arp1.empty()) {
|
||||
arp(arp1,
|
||||
dout_eth,
|
||||
fpga_mac_addr,
|
||||
act_reg.fpga_ipv4_addr,
|
||||
fpga_ipv4_addr,
|
||||
1, run_data_collection);
|
||||
}
|
||||
|
||||
@@ -291,7 +292,7 @@ void hls_action(hls::stream<axis_datamover_ctrl> &in_datamover_cmd_stream,
|
||||
arp(arp1,
|
||||
dout_eth,
|
||||
fpga_mac_addr,
|
||||
act_reg.fpga_ipv4_addr,
|
||||
fpga_ipv4_addr,
|
||||
0, run_data_collection);
|
||||
|
||||
while(!icmp1.empty())
|
||||
@@ -314,7 +315,7 @@ void hls_action(hls::stream<axis_datamover_ctrl> &in_datamover_cmd_stream,
|
||||
idle_data_collection,
|
||||
act_reg.mode,
|
||||
act_reg.one_over_energy,
|
||||
act_reg.frames_internal_packet_gen,
|
||||
act_reg.nframes,
|
||||
act_reg.nmodules,
|
||||
act_reg.nstorage_cells);
|
||||
run_data_collection = 0;
|
||||
@@ -398,6 +399,10 @@ void hls_action(hls::stream<axis_datamover_ctrl> &in_datamover_cmd_stream,
|
||||
|
||||
}
|
||||
|
||||
uint32_t HLSSimulatedDevice::HW_GetIPv4Address() const {
|
||||
return fpga_ipv4_addr;
|
||||
}
|
||||
|
||||
uint64_t HLSSimulatedDevice::HW_GetMACAddress() const {
|
||||
return fpga_mac_addr;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ void hls_action(hls::stream<axis_datamover_ctrl> &in_datamover_cmd_stream,
|
||||
hbm256_t *d_hbm_p10, hbm256_t *d_hbm_p11,
|
||||
AXI_STREAM &din_eth, AXI_STREAM &dout_eth,
|
||||
uint64_t fpga_mac_addr,
|
||||
uint32_t fpga_ipv4_addr,
|
||||
const ActionConfig &act_reg,
|
||||
hls::stream<ap_uint<32> > &s_axis_work_request,
|
||||
hls::stream<ap_uint<32> > &m_axis_completion,
|
||||
@@ -51,6 +52,7 @@ class HLSSimulatedDevice : public AcquisitionDevice {
|
||||
ap_uint<1> cancel_data_collection;
|
||||
uint64_t in_mem_location[LOAD_CALIBRATION_BRAM_SIZE];
|
||||
static const uint64_t fpga_mac_addr = 0xCCAA11223344;
|
||||
static const uint32_t fpga_ipv4_addr = 0x0132010A;
|
||||
|
||||
void HW_ReadActionRegister(ActionConfig *job) override;
|
||||
void HW_WriteActionRegister(const ActionConfig *job) override;
|
||||
@@ -62,17 +64,18 @@ class HLSSimulatedDevice : public AcquisitionDevice {
|
||||
void HW_SetCancelDataCollectionBit() override;
|
||||
bool HW_SendWorkRequest(uint32_t handle) override;
|
||||
uint64_t HW_GetMACAddress() const override;
|
||||
uint32_t HW_GetIPv4Address() const override;
|
||||
void HW_GetStatus(ActionStatus *status) const override;
|
||||
public:
|
||||
HLSSimulatedDevice(uint16_t data_stream, size_t in_frame_buffer_size_modules, int16_t numa_node = -1);
|
||||
~HLSSimulatedDevice();
|
||||
void SendPacket(char *buffer, int len, uint8_t user = 0);
|
||||
void CreatePacketJF(const DiffractionExperiment& experiment, uint64_t frame_number, uint32_t eth_packet,
|
||||
uint32_t module, const uint16_t *data, bool trigger, int8_t adjust_axis = 0, uint8_t user = 0);
|
||||
uint32_t module_number, const uint16_t *data, bool trigger, int8_t adjust_axis = 0, uint8_t user = 0);
|
||||
void CreatePacketEIGER(const DiffractionExperiment& experiment, uint64_t frame_number, uint32_t eth_packet,
|
||||
uint32_t module, const uint16_t *data, bool trigger, int8_t adjust_axis = 0, uint8_t user = 0);
|
||||
uint32_t module_number, const uint16_t *data, bool trigger, int8_t adjust_axis = 0, uint8_t user = 0);
|
||||
void CreatePackets(const DiffractionExperiment& experiment, uint64_t frame_number_0, uint64_t frames,
|
||||
uint32_t module, const uint16_t *data, bool trigger, int8_t adjust_axis = 0,
|
||||
uint32_t module_number, const uint16_t *data, bool trigger, int8_t adjust_axis = 0,
|
||||
uint8_t user = 0);
|
||||
void CreateFinalPacket(const DiffractionExperiment& experiment);
|
||||
AXI_STREAM &OutputStream();
|
||||
|
||||
@@ -53,7 +53,7 @@ void MlxRawEthDevice::MeasureThread() {
|
||||
qp.ReadyToReceive();
|
||||
qp.ReadyToSend();
|
||||
|
||||
qp.FlowSteeringIPv4(cfg.fpga_ipv4_addr);
|
||||
qp.FlowSteeringIPv4(ipv4_addr);
|
||||
|
||||
for (int i = 0; i < BUFFER_COUNT-1; i++)
|
||||
qp.PostReceiveWR(*buffer.GetMemoryRegion(), i, buffer.GetLocation(i), BUFFER_SIZE);
|
||||
@@ -140,11 +140,18 @@ void MlxRawEthDevice::SetMACAddress(uint64_t mac_addr_network_order) {
|
||||
mac_addr = mac_addr_network_order;
|
||||
}
|
||||
|
||||
void MlxRawEthDevice::SetIPv4Address(uint32_t ipv4_addr_network_order) {
|
||||
ipv4_addr = ipv4_addr_network_order;
|
||||
}
|
||||
|
||||
uint64_t MlxRawEthDevice::HW_GetMACAddress() const {
|
||||
return mac_addr;
|
||||
}
|
||||
|
||||
uint32_t MlxRawEthDevice::HW_GetIPv4Address() const {
|
||||
return ipv4_addr;
|
||||
}
|
||||
|
||||
uint64_t MlxRawEthDevice::PollCQ(IBRegBuffer &buffer, IBQueuePair &qp, IBCompletionQueue &cq, ProcessJFPacket &process) {
|
||||
#ifdef JFJOCH_USE_NUMA
|
||||
if (numa_available() != -1)
|
||||
@@ -208,9 +215,9 @@ void MlxRawEthDevice::SendARP(IBRegBuffer &buffer, IBQueuePair &qp) {
|
||||
.ar_pln = 0x4, // 4 bytes
|
||||
.ar_op = htons(1), // ARP request
|
||||
.ar_sha = {src_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5]},
|
||||
.ar_sip = cfg.fpga_ipv4_addr,
|
||||
.ar_sip = ipv4_addr,
|
||||
.ar_tha = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
|
||||
.ar_tip = cfg.fpga_ipv4_addr
|
||||
.ar_tip = ipv4_addr
|
||||
};
|
||||
|
||||
memcpy(buffer.GetLocation(BUFFER_COUNT-1), &arp_packet, sizeof(RAW_ARP_Packet));
|
||||
|
||||
@@ -22,6 +22,7 @@ class MlxRawEthDevice : public AcquisitionDevice {
|
||||
ThreadSafeFIFO<Completion> completion_queue;
|
||||
ThreadSafeFIFO<ProcessWorkRequest> wr_queue;
|
||||
uint64_t mac_addr;
|
||||
uint32_t ipv4_addr;
|
||||
ActionConfig cfg;
|
||||
const int16_t numa_node;
|
||||
|
||||
@@ -47,6 +48,7 @@ class MlxRawEthDevice : public AcquisitionDevice {
|
||||
bool HW_SendWorkRequest(uint32_t handle) override;
|
||||
void HW_GetStatus(ActionStatus *status) const override;
|
||||
uint64_t HW_GetMACAddress() const override;
|
||||
uint32_t HW_GetIPv4Address() const override;
|
||||
void HW_EndAction() override;
|
||||
void CopyInternalPacketGenFrameToDeviceBuffer() override;
|
||||
public:
|
||||
@@ -56,6 +58,7 @@ public:
|
||||
void InitializeCalibration(const DiffractionExperiment &experiment, const JFCalibration &calib) override;
|
||||
int32_t GetNUMANode() const override;
|
||||
void SetMACAddress(uint64_t mac_addr_network_order);
|
||||
void SetIPv4Address(uint32_t ipv4_addr_network_order);
|
||||
};
|
||||
|
||||
#endif //JUNGFRAUJOCH_RAWETHDEVICE_H
|
||||
|
||||
@@ -84,6 +84,10 @@ uint64_t MockAcquisitionDevice::HW_GetMACAddress() const {
|
||||
return 0; // Doesn't matter
|
||||
}
|
||||
|
||||
uint32_t MockAcquisitionDevice::HW_GetIPv4Address() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MockAcquisitionDevice::HW_GetStatus(ActionStatus *status) const {
|
||||
memset(status, 0, sizeof(ActionStatus));
|
||||
status->max_modules = max_modules;
|
||||
|
||||
@@ -25,6 +25,7 @@ class MockAcquisitionDevice : public AcquisitionDevice {
|
||||
bool HW_SendWorkRequest(uint32_t handle) override;
|
||||
bool HW_IsIdle() const override;
|
||||
uint64_t HW_GetMACAddress() const override;
|
||||
uint32_t HW_GetIPv4Address() const override;
|
||||
void HW_GetStatus(ActionStatus *status) const override;
|
||||
void CopyInternalPacketGenFrameToDeviceBuffer() override;
|
||||
public:
|
||||
|
||||
@@ -146,7 +146,6 @@ void PCIExpressDevice::SetMACAddress(uint64_t mac_addr_network_order) {
|
||||
if (ioctl(fd, IOCTL_JFJOCH_SET_MAC, &mac_addr_network_order) != 0)
|
||||
throw JFJochException(JFJochExceptionCategory::PCIeError,
|
||||
"Failed setting MAC address", errno);
|
||||
|
||||
}
|
||||
|
||||
void PCIExpressDevice::HW_GetStatus(ActionStatus *status) const {
|
||||
@@ -199,14 +198,16 @@ void PCIExpressDevice::SetDefaultMAC() const {
|
||||
"Failed setting default MAC", errno);
|
||||
}
|
||||
|
||||
void PCIExpressDevice::SetIPv4Address(const std::string &ipv4_addr) {
|
||||
ActionConfig config {
|
||||
.fpga_ipv4_addr = IPv4AddressFromStr(ipv4_addr),
|
||||
.nmodules = 1,
|
||||
.one_over_energy = 1,
|
||||
.frames_internal_packet_gen = 1,
|
||||
.nstorage_cells = 1
|
||||
};
|
||||
|
||||
HW_WriteActionRegister(&config);
|
||||
void PCIExpressDevice::SetIPv4Address(uint32_t ipv4_addr_network_order) {
|
||||
if (ioctl(fd, IOCTL_JFJOCH_SET_IPV4, &ipv4_addr_network_order) != 0)
|
||||
throw JFJochException(JFJochExceptionCategory::PCIeError,
|
||||
"Failed setting IPv4 address", errno);
|
||||
}
|
||||
|
||||
uint32_t PCIExpressDevice::HW_GetIPv4Address() const {
|
||||
uint32_t tmp;
|
||||
if (ioctl(fd, IOCTL_JFJOCH_GET_IPV4, &tmp) != 0)
|
||||
throw JFJochException(JFJochExceptionCategory::PCIeError,
|
||||
"Failed getting MAC address", errno);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ class PCIExpressDevice : public AcquisitionDevice {
|
||||
void HW_WriteActionRegister(const ActionConfig *job) override;
|
||||
void HW_ReadActionRegister(ActionConfig *job) override;
|
||||
uint64_t HW_GetMACAddress() const override;
|
||||
uint32_t HW_GetIPv4Address() const override;
|
||||
void HW_EndAction() override;
|
||||
|
||||
void Reset();
|
||||
@@ -30,15 +31,16 @@ public:
|
||||
PCIExpressDevice(const std::string &device_name, uint16_t data_stream);
|
||||
~PCIExpressDevice() override;
|
||||
|
||||
void SetMACAddress(uint64_t mac_addr_network_order);
|
||||
void HW_GetStatus(ActionStatus *status) const override;
|
||||
void HW_GetEnvParams(ActionEnvParams *status) const override;
|
||||
uint32_t GetNumKernelBuffers() const;
|
||||
|
||||
int32_t GetNUMANode() const override;
|
||||
void ClearNetworkCounters();
|
||||
|
||||
void SetMACAddress(uint64_t mac_addr_network_order);
|
||||
void SetDefaultMAC() const;
|
||||
void SetIPv4Address(const std::string &ipv4_addr);
|
||||
void SetIPv4Address(uint32_t ipv4_addr_network_order);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Copyright (2019-2022) Paul Scherrer Institute
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "../common/Logger.h"
|
||||
#include "../common/JFJochException.h"
|
||||
#include "../../common/Logger.h"
|
||||
#include "../../common/JFJochException.h"
|
||||
#include "PCIExpressDevice.h"
|
||||
#include "../../common/NetworkAddressConvert.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
Logger logger("jfjoch_pcie_set_network");
|
||||
@@ -18,7 +19,7 @@ int main(int argc, char **argv) {
|
||||
try {
|
||||
PCIExpressDevice test(argv[1], 0);
|
||||
test.SetDefaultMAC();
|
||||
test.SetIPv4Address(argv[2]);
|
||||
test.SetIPv4Address(IPv4AddressFromStr(std::string(argv[2])));
|
||||
logger.Info("Done");
|
||||
} catch (const JFJochException &e) {
|
||||
logger.ErrorException(e);
|
||||
|
||||
@@ -41,11 +41,11 @@ int main(int argc, char **argv) {
|
||||
std::cout << "Stalls host mem " << status.stalls_host() << std::endl;
|
||||
|
||||
ActionConfig cfg = test.ReadActionRegister();
|
||||
std::cout << "IPv4 address " << IPv4AddressToStr(cfg.fpga_ipv4_addr) << std::endl;
|
||||
std::cout << "MAC address " << test.GetMACAddress() << std::endl;
|
||||
std::cout << "IPv4 address " << test.GetIPv4Address() << std::endl;
|
||||
std::cout << "Mode " << std::hex << cfg.mode << std::dec << std::endl;
|
||||
std::cout << "Modules " << std::dec << cfg.nmodules << std::endl;
|
||||
std::cout << "Frames int. pkt. gen. " << std::dec << cfg.frames_internal_packet_gen << std::endl;
|
||||
std::cout << "Frames int. pkt. gen. " << std::dec << cfg.nframes << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "FPGA FIFO status: " << std::endl;
|
||||
for (const auto &[x,y]: status.fifo_status()) {
|
||||
|
||||
@@ -32,16 +32,18 @@ AcquisitionDevice *SetupAcquisitionDevice(const nlohmann::json &input, uint16_t
|
||||
ret = new HLSSimulatedDevice(data_stream, frame_buffer_size, numa_node);
|
||||
else if (input.contains("type") && (input["type"] == "pcie")) {
|
||||
auto pci_dev = new PCIExpressDevice(data_stream, pci_slot);
|
||||
if (input.contains("fpga_mac_addr"))
|
||||
pci_dev->SetMACAddress(MacAddressFromStr(input["fpga_mac_addr"].get<std::string>()));
|
||||
pci_dev->SetIPv4Address(IPv4AddressFromStr(input["ipv4_addr"].get<std::string>()));
|
||||
|
||||
if (input.contains("mac_addr"))
|
||||
pci_dev->SetMACAddress(MacAddressFromStr(input["mac_addr"].get<std::string>()));
|
||||
else
|
||||
pci_dev->SetDefaultMAC();
|
||||
ret = pci_dev;
|
||||
#ifdef JFJOCH_USE_IBVERBS
|
||||
} else if (input.contains("type") && (input["type"] == "mlx_raw_eth")) {
|
||||
auto mlx_dev = new MlxRawEthDevice(pci_slot, data_stream, frame_buffer_size, numa_node);
|
||||
if (input.contains("mac_addr"))
|
||||
mlx_dev->SetMACAddress(MacAddressFromStr(input["mac_addr"].get<std::string>()));
|
||||
mlx_dev->SetIPv4Address(IPv4AddressFromStr(input["ipv4_addr"].get<std::string>()));
|
||||
mlx_dev->SetMACAddress(MacAddressFromStr(input["mac_addr"].get<std::string>()));
|
||||
ret = mlx_dev;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -109,12 +109,12 @@ int jfjoch_read_wc(struct jfjoch_drvdata *drvdata, u32 *output) {
|
||||
|
||||
void jfjoch_set_config(struct jfjoch_drvdata *drvdata, const struct ActionConfig *config) {
|
||||
mutex_lock(&set_config_mutex);
|
||||
memcpy_toio((drvdata->bar0) + ACTION_CONFIG_OFFSET + ADDR_IPV4_ADDR, config, sizeof(struct ActionConfig));
|
||||
memcpy_toio((drvdata->bar0) + ACTION_CONFIG_OFFSET + ADDR_NMODULES, config, sizeof(struct ActionConfig));
|
||||
mutex_unlock(&set_config_mutex);
|
||||
}
|
||||
|
||||
void jfjoch_get_config(struct jfjoch_drvdata *drvdata, struct ActionConfig *config) {
|
||||
memcpy_fromio(config, (drvdata->bar0) + ACTION_CONFIG_OFFSET + ADDR_IPV4_ADDR, sizeof(struct ActionConfig));
|
||||
memcpy_fromio(config, (drvdata->bar0) + ACTION_CONFIG_OFFSET + ADDR_NMODULES, sizeof(struct ActionConfig));
|
||||
}
|
||||
|
||||
void jfjoch_get_status(struct jfjoch_drvdata *drvdata, struct ActionStatus *status) {
|
||||
|
||||
@@ -48,28 +48,22 @@ TEST_CASE("ActionStatus") {
|
||||
|
||||
|
||||
TEST_CASE("ActionConfigSize") {
|
||||
REQUIRE(sizeof(ActionConfig) == 6 * sizeof(uint32_t));
|
||||
REQUIRE(sizeof(ActionConfig) == 5 * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
TEST_CASE("ActionConfig") {
|
||||
ActionConfig config{};
|
||||
auto config32 = (uint32_t *) &config;
|
||||
|
||||
config.fpga_ipv4_addr = 32;
|
||||
CHECK(config32[(ADDR_IPV4_ADDR - ADDR_IPV4_ADDR)/4] == 32);
|
||||
|
||||
config.nmodules = 456;
|
||||
CHECK(config32[(ADDR_NMODULES - ADDR_IPV4_ADDR)/4] == 456);
|
||||
|
||||
config.one_over_energy = 1<<17;
|
||||
CHECK(config32[(ADDR_ONE_OVER_ENERGY - ADDR_IPV4_ADDR)/4] == 1<<17);
|
||||
|
||||
config.mode = 1<<5;
|
||||
CHECK(config32[(ADDR_DATA_COL_MODE - ADDR_IPV4_ADDR)/4] == 1<<5);
|
||||
|
||||
config.frames_internal_packet_gen = 1<<18;
|
||||
CHECK(config32[(ADDR_NFRAMES - ADDR_IPV4_ADDR)/4] == 1 << 18 );
|
||||
|
||||
config.nframes = 1<<18;
|
||||
config.nstorage_cells = 16;
|
||||
CHECK(config32[(ADDR_NSTORAGE_CELLS - ADDR_IPV4_ADDR)/4] == 16);
|
||||
|
||||
CHECK(config32[(ADDR_NMODULES - ADDR_NMODULES)/4] == 456);
|
||||
CHECK(config32[(ADDR_ONE_OVER_ENERGY - ADDR_NMODULES)/4] == 1<<17);
|
||||
CHECK(config32[(ADDR_DATA_COL_MODE - ADDR_NMODULES)/4] == 1<<5);
|
||||
CHECK(config32[(ADDR_NFRAMES - ADDR_NMODULES)/4] == 1 << 18 );
|
||||
CHECK(config32[(ADDR_NSTORAGE_CELLS - ADDR_NMODULES)/4] == 16);
|
||||
}
|
||||
@@ -1006,8 +1006,16 @@ TEST_CASE("DiffractionExperiment_DetectorModuleHostname","[DiffractionExperiment
|
||||
JFJochProtoBuf::DetectorConfig det_cfg;
|
||||
|
||||
JFJochProtoBuf::ReceiverNetworkConfig net_cfg;
|
||||
net_cfg.add_fpga_mac_addr("AA:BB:CC:DD:EE:FF");
|
||||
net_cfg.add_fpga_mac_addr("AA:BB:CC:DD:EE:FE");
|
||||
|
||||
auto d1 = net_cfg.add_device();
|
||||
d1->set_mac_addr("00:00:00:00:00:00");
|
||||
d1->set_ipv4_addr("10.10.50.1");
|
||||
d1->set_udp_port(1234);
|
||||
|
||||
auto d2 = net_cfg.add_device();
|
||||
d2->set_mac_addr("00:00:00:00:00:01");
|
||||
d2->set_ipv4_addr("10.10.50.2");
|
||||
d2->set_udp_port(1234);
|
||||
|
||||
std::vector<std::string> h_out;
|
||||
REQUIRE_NOTHROW(x.GetDetectorModuleHostname(h_out));
|
||||
|
||||
@@ -707,7 +707,7 @@ TEST_CASE("HLS_DataCollectionFSM","[OpenCAPI]") {
|
||||
idle_data_collection,
|
||||
act_reg.mode,
|
||||
act_reg.one_over_energy,
|
||||
act_reg.frames_internal_packet_gen,
|
||||
act_reg.nframes,
|
||||
act_reg.nmodules,
|
||||
act_reg.nstorage_cells);
|
||||
REQUIRE(idle_data_collection == 1);
|
||||
@@ -724,7 +724,7 @@ TEST_CASE("HLS_DataCollectionFSM","[OpenCAPI]") {
|
||||
idle_data_collection,
|
||||
act_reg.mode,
|
||||
act_reg.one_over_energy,
|
||||
act_reg.frames_internal_packet_gen,
|
||||
act_reg.nframes,
|
||||
act_reg.nmodules,
|
||||
act_reg.nstorage_cells);
|
||||
REQUIRE(idle_data_collection == 0);
|
||||
@@ -739,7 +739,7 @@ TEST_CASE("HLS_DataCollectionFSM","[OpenCAPI]") {
|
||||
idle_data_collection,
|
||||
act_reg.mode,
|
||||
act_reg.one_over_energy,
|
||||
act_reg.frames_internal_packet_gen,
|
||||
act_reg.nframes,
|
||||
act_reg.nmodules,
|
||||
act_reg.nstorage_cells);
|
||||
REQUIRE(idle_data_collection == 0);
|
||||
@@ -757,7 +757,7 @@ TEST_CASE("HLS_DataCollectionFSM","[OpenCAPI]") {
|
||||
idle_data_collection,
|
||||
act_reg.mode,
|
||||
act_reg.one_over_energy,
|
||||
act_reg.frames_internal_packet_gen,
|
||||
act_reg.nframes,
|
||||
act_reg.nmodules,
|
||||
act_reg.nstorage_cells);
|
||||
REQUIRE(idle_data_collection == 0);
|
||||
@@ -772,7 +772,7 @@ TEST_CASE("HLS_DataCollectionFSM","[OpenCAPI]") {
|
||||
idle_data_collection,
|
||||
act_reg.mode,
|
||||
act_reg.one_over_energy,
|
||||
act_reg.frames_internal_packet_gen,
|
||||
act_reg.nframes,
|
||||
act_reg.nmodules,
|
||||
act_reg.nstorage_cells);
|
||||
|
||||
@@ -789,7 +789,7 @@ TEST_CASE("HLS_DataCollectionFSM","[OpenCAPI]") {
|
||||
idle_data_collection,
|
||||
act_reg.mode,
|
||||
act_reg.one_over_energy,
|
||||
act_reg.frames_internal_packet_gen,
|
||||
act_reg.nframes,
|
||||
act_reg.nmodules,
|
||||
act_reg.nstorage_cells);
|
||||
|
||||
@@ -808,7 +808,7 @@ TEST_CASE("HLS_DataCollectionFSM","[OpenCAPI]") {
|
||||
idle_data_collection,
|
||||
act_reg.mode,
|
||||
act_reg.one_over_energy,
|
||||
act_reg.frames_internal_packet_gen,
|
||||
act_reg.nframes,
|
||||
act_reg.nmodules,
|
||||
act_reg.nstorage_cells);
|
||||
|
||||
@@ -825,7 +825,7 @@ TEST_CASE("HLS_DataCollectionFSM","[OpenCAPI]") {
|
||||
idle_data_collection,
|
||||
act_reg.mode,
|
||||
act_reg.one_over_energy,
|
||||
act_reg.frames_internal_packet_gen,
|
||||
act_reg.nframes,
|
||||
act_reg.nmodules,
|
||||
act_reg.nstorage_cells);
|
||||
|
||||
@@ -842,7 +842,7 @@ TEST_CASE("HLS_DataCollectionFSM","[OpenCAPI]") {
|
||||
idle_data_collection,
|
||||
act_reg.mode,
|
||||
act_reg.one_over_energy,
|
||||
act_reg.frames_internal_packet_gen,
|
||||
act_reg.nframes,
|
||||
act_reg.nmodules,
|
||||
act_reg.nstorage_cells);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user