Skip to content

Commit

Permalink
[alf] Add service to reset CRORC channels
Browse files Browse the repository at this point in the history
  • Loading branch information
kostorr committed May 5, 2022
1 parent a8ebf15 commit 743762b
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 1 deletion.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,17 @@ It extends the `SCA_SEQUENCE` to add the following functionality:
* DIM input `0xf00d\n0x0000f00d, 0x0000beef\n0x0000f00d`
* DIM output `0xcafe\n0\n0xbeef\n`

##### RESET_CARD
* Parameters:
* empty

* Returns:
* empty

* Example:
* DIM input ` `
* DIM output ` `

## Slow Control library
ALF can also be used as a C++ library to access the Slow Control interface of the CRU. The three available interfaces (IC, SCA & SWT) can be accessed through single operations, or sequences of operations.

Expand Down
5 changes: 4 additions & 1 deletion apps/AlfClient.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class AlfClient : public AliceO2::Common::Program
"Hostname of node running the ALF server(required)");
options.add_options()("crorc",
po::bool_switch(&mOptions.crorc)->default_value(false),
"Flag enabling the test of the crorc (exclusive)");
"Flag enabling the test of the crorc (exclusive - includes card reset!)");
options.add_options()("ic",
po::bool_switch(&mOptions.ic)->default_value(false),
"Flag enabling the ic tests");
Expand Down Expand Up @@ -139,12 +139,15 @@ class AlfClient : public AliceO2::Common::Program
if (mOptions.crorc) {
link.cardType = roc::CardType::Crorc;
RegisterSequenceRpc registerSequence(names.registerSequence());
ResetCardRpc resetCard(names.resetCard());
auto regOut = registerSequence.write({ std::make_pair("0x19c", ""),
std::make_pair("0xa0", ""),
std::make_pair("0x1f0", ""),
std::make_pair("0x1f0", "0x00080000"),
std::make_pair("0x1f0", "") });
std::cout << "[REGISTER SEQUENCE] output: " << regOut << std::endl;
auto resetCardOut = resetCard.write("alf_client_test");
std::cout << "[RESET CARD] output: " << resetCardOut << std::endl;

return;
}
Expand Down
24 changes: 24 additions & 0 deletions src/AlfClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,30 @@ class LlaSessionStopRpc : DimRpcInfoWrapper
}
};

class ResetCardRpc : DimRpcInfoWrapper
{
public:
ResetCardRpc(const std::string& serviceName)
: DimRpcInfoWrapper(serviceName)
{
}

std::string write(const std::string& buffer)
{
setString(buffer);
std::string ret;
try {
ret = getString();
} catch (const AlfException& e) {
if (kDebugLogging) {
Logger::get() << "ResetCard: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
}
return errString;
}
return ret;
}
};

} // namespace alf
} // namespace o2

Expand Down
23 changes: 23 additions & 0 deletions src/AlfServer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include "Logger.h"
#include "Util.h"

#include "ReadoutCard/ChannelFactory.h"
#include "ReadoutCard/Exception.h"

namespace o2
{
namespace alf
Expand Down Expand Up @@ -190,6 +193,24 @@ std::string AlfServer::llaSessionStop(const std::string& /*parameter*/, roc::Ser
return "";
}

std::string AlfServer::resetCard(const std::string& /*parameter*/, AlfLink link)
{
// Reset the CRORC DMA channel
auto params = roc::Parameters::makeParameters(link.serialId, link.linkId);
params.setBufferParameters(o2::roc::buffer_parameters::Null());
params.setFirmwareCheckEnabled(false);
std::shared_ptr<roc::DmaChannelInterface> dmaChannel;
try {
dmaChannel = roc::ChannelFactory().getDmaChannel(params);
} catch (const roc::LockException& e) {
BOOST_THROW_EXCEPTION(
AlfException() << ErrorInfo::Message("Another process is holding the channel lock (cannot reset)"));
}
dmaChannel->resetChannel(roc::ResetLevel::InternalSiu);

return "";
}

roc::PatternPlayer::Info AlfServer::parseStringToPatternPlayerInfo(const std::vector<std::string> parameters)
{
roc::PatternPlayer::Info ppInfo;
Expand Down Expand Up @@ -610,6 +631,8 @@ void AlfServer::makeRpcServers(std::vector<AlfLink> links, bool sequentialRpcs)
// Register Sequence
servers.push_back(makeServer(names.registerSequenceLink(),
[bar](auto parameter) { return registerBlobWrite(parameter, bar); }));
servers.push_back(makeServer(names.resetCard(),
[link, this](auto parameter) { return resetCard(parameter, link); }));
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/AlfServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class AlfServer
static std::string registerBlobWrite(const std::string& parameter, std::shared_ptr<roc::BarInterface>, bool isCru = false);
std::string llaSessionStart(const std::string& parameter, roc::SerialId serialId);
std::string llaSessionStop(const std::string& parameter, roc::SerialId serialId);
std::string resetCard(const std::string& parameter, AlfLink link);

static std::vector<uint32_t> stringToRegisterPair(const std::string stringPair);
static std::pair<Sca::Operation, Sca::Data> stringToScaPair(const std::string stringPair);
Expand Down
1 change: 1 addition & 0 deletions src/DimServices/ServiceNames.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ DEFLINKSERVICENAME(scaMftPsuSequence, "SCA_MFT_PSU_SEQUENCE")
DEFLINKSERVICENAME(swtSequence, "SWT_SEQUENCE")
DEFLINKSERVICENAME(icSequence, "IC_SEQUENCE")
DEFLINKSERVICENAME(icGbtI2cWrite, "IC_GBT_I2C_WRITE")
DEFLINKSERVICENAME(resetCard, "RESET_CARD")

std::string ServiceNames::formatLink(std::string name) const
{
Expand Down
1 change: 1 addition & 0 deletions src/DimServices/ServiceNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ServiceNames
std::string registerSequenceLink() const;
std::string llaSessionStart() const;
std::string llaSessionStop() const;
std::string resetCard() const;

private:
std::string formatLink(std::string name) const;
Expand Down

0 comments on commit 743762b

Please sign in to comment.