Skip to content

Commit

Permalink
Extend host_exerciser to allow 16 line requests
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-adler committed Apr 12, 2023
1 parent 2065ed5 commit 62a16ef
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 9 deletions.
20 changes: 17 additions & 3 deletions samples/host_exerciser/host_exerciser.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ typedef enum {
HOSTEXE_CLS_2 = 0x1,
HOSTEXE_CLS_4 = 0x2,
HOSTEXE_CLS_8 = 0x3,
HOSTEXE_CLS_16 = 0x4,
} hostexe_req_len;

//configures atomic transactions
Expand Down Expand Up @@ -202,7 +203,8 @@ union he_cfg {
uint64_t TestCfg : 5;
uint64_t IntrOnErr : 1;
uint64_t IntrTestMode : 1;
uint64_t Rsvd_63_30 : 34;
uint64_t ReqLen_High : 2;
uint64_t Rsvd_63_32 : 32;
};
};

Expand Down Expand Up @@ -315,11 +317,23 @@ const std::map<std::string, uint32_t> he_modes = {
{ "trput", HOST_EXEMODE_TRPUT},
};

const std::map<std::string, uint32_t> he_req_cls_len= {
struct MapKeyComparator
{
bool operator()( const std::string& a, const std::string& b ) const
{
if (a.length() != b.length())
return (a.length() < b.length());
else
return (a < b);
}
};

const std::map<std::string, uint32_t, MapKeyComparator> he_req_cls_len = {
{ "cl_1", HOSTEXE_CLS_1},
{ "cl_2", HOSTEXE_CLS_2},
{ "cl_4", HOSTEXE_CLS_4},
{ "cl_8", HOSTEXE_CLS_8},
{ "cl_16", HOSTEXE_CLS_16},
};

const std::map<std::string, uint32_t> he_req_atomic_func = {
Expand Down Expand Up @@ -369,7 +383,7 @@ class host_exerciser : public test_afu {
->transform(CLI::CheckedTransformer(he_modes))->default_val("lpbk");

// Cache line
app_.add_option("--cls", he_req_cls_len_, "number of CLs per request{cl_1, cl_2, cl_4, cl_8}")
app_.add_option("--cls", he_req_cls_len_, "number of CLs per request{cl_1, cl_2, cl_4, cl_8, cl_16}")
->transform(CLI::CheckedTransformer(he_req_cls_len))->default_val("cl_1");

// Configures test rollover or test termination
Expand Down
46 changes: 40 additions & 6 deletions samples/host_exerciser/host_exerciser_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class host_exerciser_cmd : public test_command
:host_exe_(NULL) {
he_lpbk_cfg_.value = 0;
he_lpbk_ctl_.value = 0;
he_lpbk_max_reqlen_ = HOSTEXE_CLS_8;
he_lpbk_api_ver_ = 0;
he_lpbk_atomics_supported_ = false;
is_ase_sim_ = false;
Expand Down Expand Up @@ -377,6 +378,25 @@ class host_exerciser_cmd : public test_command
return true;
}

inline void set_cfg_reqlen(hostexe_req_len req_len)
{
// Legal request lengths have grown over time, leading to the field being
// split in the configuration register.
he_lpbk_cfg_.ReqLen_High = req_len >> 2;
he_lpbk_cfg_.ReqLen = req_len & 3;
}

inline void set_cfg_reqlen(uint32_t req_len)
{
set_cfg_reqlen(static_cast<hostexe_req_len>(req_len));
}

inline hostexe_req_len get_cfg_reqlen()
{
return static_cast<hostexe_req_len>((he_lpbk_cfg_.ReqLen_High << 2) |
he_lpbk_cfg_.ReqLen);
}

int parse_input_options()
{

Expand All @@ -396,7 +416,12 @@ class host_exerciser_cmd : public test_command
he_lpbk_cfg_.TestMode = host_exe_->he_modes_;

// Host Exerciser Read
he_lpbk_cfg_.ReqLen = host_exe_->he_req_cls_len_;
if (host_exe_->he_req_cls_len_ > he_lpbk_max_reqlen_) {
std::cerr << "Request length " << host_exe_->he_req_cls_len_
<< " is not supported by this platform." << std::endl;
return -1;
}
set_cfg_reqlen(host_exe_->he_req_cls_len_);

// Host Exerciser lpbk delay
if (host_exe_->he_delay_)
Expand Down Expand Up @@ -429,7 +454,7 @@ class host_exerciser_cmd : public test_command
std::cerr << "The platform does not support atomic functions" << std::endl;
return -1;
}
if ((he_lpbk_cfg_.ReqLen != HOSTEXE_CLS_1) && (he_lpbk_cfg_.TestMode == HOST_EXEMODE_LPBK1)) {
if ((get_cfg_reqlen() != HOSTEXE_CLS_1) && (he_lpbk_cfg_.TestMode == HOST_EXEMODE_LPBK1)) {
std::cerr << "Atomic function in lpbk mode requires cl_1" << std::endl;
return -1;
}
Expand Down Expand Up @@ -571,7 +596,8 @@ class host_exerciser_cmd : public test_command
std::cout << std::endl << "Testing loopback, varying payload size:" << std::endl;
for (std::map<std::string, uint32_t>::const_iterator cls=he_req_cls_len.begin(); cls!=he_req_cls_len.end(); ++cls) {
// Set request length
he_lpbk_cfg_.ReqLen = cls->second;
if (cls->second > he_lpbk_max_reqlen_) break;
set_cfg_reqlen(cls->second);

// Initialize buffer values
he_init_src_buffer(source_);
Expand All @@ -583,7 +609,7 @@ class host_exerciser_cmd : public test_command
std::cout << " " << cls->first << ": "
<< (test_status ? "FAIL" : "PASS") << std::endl;
}
he_lpbk_cfg_.ReqLen = HOSTEXE_CLS_1;
set_cfg_reqlen(HOSTEXE_CLS_1);

// Test atomic functions if the API supports it
if (he_lpbk_atomics_supported_) {
Expand All @@ -609,7 +635,10 @@ class host_exerciser_cmd : public test_command
uint32_t trip = 0;
for (std::map<std::string, uint32_t>::const_reverse_iterator cls=he_req_cls_len.rbegin(); cls!=he_req_cls_len.rend(); ++cls) {
he_lpbk_cfg_.TestMode = HOST_EXEMODE_TRPUT;
he_lpbk_cfg_.ReqLen = cls->second;

if (cls->second > he_lpbk_max_reqlen_) break;
set_cfg_reqlen(cls->second);

he_lpbk_cfg_.AtomicFunc = (trip & 1 ? HOSTEXE_ATOMIC_FADD_4 : HOSTEXE_ATOMIC_CAS_8);
host_exe_->he_continuousmode_ = true;
he_lpbk_cfg_.Continuous = 1;
Expand Down Expand Up @@ -640,7 +669,8 @@ class host_exerciser_cmd : public test_command
host_exe_->he_continuousmode_ = true;
he_lpbk_cfg_.Continuous = 1;
for (std::map<std::string, uint32_t>::const_iterator cls=he_req_cls_len.begin(); cls!=he_req_cls_len.end(); ++cls) {
he_lpbk_cfg_.ReqLen = cls->second;
if (cls->second > he_lpbk_max_reqlen_) break;
set_cfg_reqlen(cls->second);

he_lpbk_cfg_.TestMode = HOST_EXEMODE_READ;
int test_status = run_single_test();
Expand Down Expand Up @@ -700,6 +730,9 @@ class host_exerciser_cmd : public test_command
he_lpbk_atomics_supported_ = (he_lpbk_api_ver_ != 0) &&
(0 == ((he_info >> 24) & 1));

// The maximum request length before API version 2 was 8.
he_lpbk_max_reqlen_ = (he_lpbk_api_ver_ < 2) ? HOSTEXE_CLS_8 : HOSTEXE_CLS_16;

if (0 == host_exe_->he_clock_mhz_) {
uint16_t freq = he_info;
if (freq) {
Expand Down Expand Up @@ -783,6 +816,7 @@ class host_exerciser_cmd : public test_command
shared_buffer::ptr_t dsm_;
he_interrupt0 he_interrupt_;
token::ptr_t token_;
hostexe_req_len he_lpbk_max_reqlen_;
uint8_t he_lpbk_api_ver_;
bool he_lpbk_atomics_supported_;
bool is_ase_sim_;
Expand Down

0 comments on commit 62a16ef

Please sign in to comment.