96 lines
2.6 KiB
C++
96 lines
2.6 KiB
C++
// Copyright (2019-2022) Paul Scherrer Institute
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#ifdef JFJOCH_USE_IBVERBS
|
|
#include "RawEthDevice.h"
|
|
|
|
RawEthDevice::RawEthDevice(const std::string &device_name,
|
|
uint16_t data_stream,
|
|
size_t in_frame_buffer_size_modules,
|
|
int16_t in_numa_node)
|
|
: AcquisitionDevice(data_stream),
|
|
context(device_name),
|
|
numa_node(in_numa_node) {
|
|
max_modules = 16;
|
|
MapBuffersStandard(in_frame_buffer_size_modules, 1, numa_node);
|
|
}
|
|
|
|
void RawEthDevice::InitializeCalibration(const DiffractionExperiment &experiment, const JFCalibration &calib) {
|
|
// Do nothing
|
|
}
|
|
|
|
int32_t RawEthDevice::GetNUMANode() const {
|
|
return numa_node;
|
|
}
|
|
|
|
Completion RawEthDevice::ReadCompletion() {
|
|
return completion_queue.GetBlocking();
|
|
}
|
|
|
|
void RawEthDevice::HW_WriteActionRegister(const ActionConfig *job) {
|
|
memcpy(&cfg, job, sizeof(ActionConfig));
|
|
}
|
|
|
|
void RawEthDevice::HW_ReadActionRegister(ActionConfig *job) {
|
|
memcpy(job, &cfg, sizeof(ActionConfig));
|
|
}
|
|
|
|
void RawEthDevice::HW_StartAction() {
|
|
cancel = false;
|
|
receiver = std::make_unique<IBReceiver>(context,
|
|
completion_queue,
|
|
wr_queue,
|
|
cfg.nmodules,
|
|
mac_addr,
|
|
cfg.fpga_ipv4_addr,
|
|
cancel,
|
|
1,
|
|
numa_node);
|
|
}
|
|
|
|
bool RawEthDevice::HW_IsIdle() const {
|
|
return (receiver == nullptr);
|
|
}
|
|
|
|
void RawEthDevice::HW_SetCancelDataCollectionBit() {
|
|
cancel = true;
|
|
}
|
|
|
|
bool RawEthDevice::HW_SendWorkRequest(uint32_t handle) {
|
|
if (handle == UINT32_MAX)
|
|
HW_SetCancelDataCollectionBit();
|
|
else
|
|
wr_queue.Put(ProcessWorkRequest{
|
|
.ptr = buffer_device.at(handle),
|
|
.handle = handle
|
|
});
|
|
|
|
return true;
|
|
}
|
|
|
|
void RawEthDevice::HW_GetStatus(ActionStatus *status) const {
|
|
// do nothing for the moment
|
|
}
|
|
|
|
void RawEthDevice::HW_GetEnvParams(ActionEnvParams *status) const {
|
|
// do nothing
|
|
}
|
|
|
|
void RawEthDevice::HW_EndAction() {
|
|
receiver.reset();
|
|
}
|
|
|
|
void RawEthDevice::CopyInternalPacketGenFrameToDeviceBuffer() {
|
|
// Do nothing
|
|
}
|
|
|
|
void RawEthDevice::SetMACAddress(uint64_t mac_addr_network_order) {
|
|
mac_addr = mac_addr_network_order;
|
|
}
|
|
|
|
|
|
uint64_t RawEthDevice::HW_GetMACAddress() const {
|
|
return mac_addr;
|
|
}
|
|
|
|
#endif //JFJOCH_USE_IBVERBS
|