Skip to content

Commit 0979b79

Browse files
committed
Ethernet10GBaseRDecoder: initial refactoring and error reporting
1 parent d236c77 commit 0979b79

2 files changed

Lines changed: 29 additions & 14 deletions

File tree

scopeprotocols/Ethernet10GBaseRDecoder.cpp

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* libscopeprotocols *
44
* *
5-
* Copyright (c) 2012-2023 Andrew D. Zonenberg and contributors *
5+
* Copyright (c) 2012-2026 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -59,37 +59,51 @@ string Ethernet10GBaseRDecoder::GetProtocolName()
5959

6060
bool Ethernet10GBaseRDecoder::ValidateChannel(size_t i, StreamDescriptor stream)
6161
{
62-
if(stream.m_channel == NULL)
62+
if(stream.m_channel == nullptr)
6363
return false;
6464

65-
if( (i == 0) && (dynamic_cast<Ethernet64b66bWaveform*>(stream.m_channel->GetData(0)) != NULL) )
65+
if( (i == 0) && (dynamic_cast<Ethernet64b66bWaveform*>(stream.m_channel->GetData(0)) != nullptr) )
6666
return true;
6767

6868
return false;
6969
}
7070

71+
Filter::DataLocation Ethernet10GBaseRDecoder::GetInputLocation()
72+
{
73+
//We explicitly manage our input memory and don't care where it is when Refresh() is called
74+
return LOC_DONTCARE;
75+
}
76+
7177
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7278
// Actual decoder logic
7379

74-
void Ethernet10GBaseRDecoder::Refresh()
80+
void Ethernet10GBaseRDecoder::Refresh(
81+
[[maybe_unused]] vk::raii::CommandBuffer& cmdBuf,
82+
[[maybe_unused]] shared_ptr<QueueHandle> queue)
7583
{
76-
ClearPackets();
84+
#ifdef HAVE_NVTX
85+
nvtx3::scoped_range nrange("Ethernet10GBaseRDecoder::Refresh");
86+
#endif
7787

78-
//Get the input data
88+
//Make sure we've got valid inputs
89+
ClearErrors();
90+
ClearPackets();
7991
if(!VerifyAllInputsOK())
8092
{
81-
SetData(NULL, 0);
93+
if(!GetInput(0))
94+
AddErrorMessage("Missing inputs", "No signal input connected");
95+
else if(!GetInputWaveform(0))
96+
AddErrorMessage("Missing inputs", "No waveform available at input");
97+
98+
SetData(nullptr, 0);
8299
return;
83100
}
84101

85102
auto data = dynamic_cast<Ethernet64b66bWaveform*>(GetInputWaveform(0));
86103
data->PrepareForCpuAccess();
87104

88105
//Create the output capture
89-
auto cap = new EthernetWaveform;
90-
cap->m_timescale = data->m_timescale;
91-
cap->m_startTimestamp = data->m_startTimestamp;
92-
cap->m_startFemtoseconds = data->m_startFemtoseconds;
106+
auto cap = SetupEmptyWaveform<EthernetWaveform>(data, 0);
93107
cap->PrepareForCpuAccess();
94108

95109
size_t len = data->m_samples.size();
@@ -370,6 +384,5 @@ void Ethernet10GBaseRDecoder::Refresh()
370384
BytesToFrames(bytes, starts, ends, cap);
371385
}
372386

373-
SetData(cap, 0);
374387
cap->MarkModifiedFromCpu();
375388
}

scopeprotocols/Ethernet10GBaseRDecoder.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* libscopeprotocols *
44
* *
5-
* Copyright (c) 2012-2022 Andrew D. Zonenberg and contributors *
5+
* Copyright (c) 2012-2026 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -40,7 +40,9 @@ class Ethernet10GBaseRDecoder : public EthernetProtocolDecoder
4040
public:
4141
Ethernet10GBaseRDecoder(const std::string& color);
4242

43-
virtual void Refresh() override;
43+
virtual void Refresh(vk::raii::CommandBuffer& cmdBuf, std::shared_ptr<QueueHandle> queue) override;
44+
virtual DataLocation GetInputLocation() override;
45+
4446
static std::string GetProtocolName();
4547

4648
virtual bool ValidateChannel(size_t i, StreamDescriptor stream) override;

0 commit comments

Comments
 (0)