95 lines
2.7 KiB
C++
95 lines
2.7 KiB
C++
// Copyright (2019-2022) Paul Scherrer Institute
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#ifdef JFJOCH_USE_IBVERBS
|
|
#include "MlxRawEthDevice.h"
|
|
|
|
MlxRawEthDevice::MlxRawEthDevice(uint16_t dev_id, uint16_t data_stream, size_t in_frame_buffer_size_modules,
|
|
int16_t in_numa_node)
|
|
: AcquisitionDevice(data_stream),
|
|
context("mlx5_" + std::to_string(dev_id)),
|
|
numa_node(in_numa_node)
|
|
{
|
|
max_modules = 16;
|
|
MapBuffersStandard(in_frame_buffer_size_modules, 1, numa_node);
|
|
mac_addr = (static_cast<uint64_t>(dev_id) << 8*5) | 0x00DDCCBBAA06;
|
|
}
|
|
|
|
void MlxRawEthDevice::InitializeCalibration(const DiffractionExperiment &experiment, const JFCalibration &calib) {
|
|
// Do nothing
|
|
}
|
|
|
|
int32_t MlxRawEthDevice::GetNUMANode() const {
|
|
return numa_node;
|
|
}
|
|
|
|
Completion MlxRawEthDevice::ReadCompletion() {
|
|
return completion_queue.GetBlocking();
|
|
}
|
|
|
|
void MlxRawEthDevice::HW_WriteActionRegister(const ActionConfig *job) {
|
|
memcpy(&cfg, job, sizeof(ActionConfig));
|
|
}
|
|
|
|
void MlxRawEthDevice::HW_ReadActionRegister(ActionConfig *job) {
|
|
memcpy(job, &cfg, sizeof(ActionConfig));
|
|
}
|
|
|
|
void MlxRawEthDevice::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 MlxRawEthDevice::HW_IsIdle() const {
|
|
return (receiver == nullptr);
|
|
}
|
|
|
|
void MlxRawEthDevice::HW_SetCancelDataCollectionBit() {
|
|
cancel = true;
|
|
}
|
|
|
|
bool MlxRawEthDevice::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 MlxRawEthDevice::HW_GetStatus(ActionStatus *status) const {
|
|
memset(status, 0, sizeof(ActionStatus));
|
|
|
|
status->modules_internal_packet_generator = 1;
|
|
status->max_modules = max_modules;
|
|
}
|
|
|
|
void MlxRawEthDevice::HW_EndAction() {
|
|
receiver.reset();
|
|
}
|
|
|
|
void MlxRawEthDevice::CopyInternalPacketGenFrameToDeviceBuffer() {
|
|
// Do nothing
|
|
}
|
|
|
|
void MlxRawEthDevice::SetMACAddress(uint64_t mac_addr_network_order) {
|
|
mac_addr = mac_addr_network_order;
|
|
}
|
|
|
|
|
|
uint64_t MlxRawEthDevice::HW_GetMACAddress() const {
|
|
return mac_addr;
|
|
}
|
|
|
|
#endif //JFJOCH_USE_IBVERBS
|