Skip to content

Commit

Permalink
Merge branch 'master' into feature/pip_install
Browse files Browse the repository at this point in the history
  • Loading branch information
tswhison committed Apr 17, 2023
2 parents 5843f8e + 5f590f0 commit 025f4c2
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 13 deletions.
7 changes: 6 additions & 1 deletion libraries/libboard/board_c6100/board_c6100.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright(c) 2022, Intel Corporation
// Copyright(c) 2022-2023, Intel Corporation
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -423,6 +423,11 @@ fpga_result print_phy_info(fpga_token token)
char feature_dev[SYSFS_PATH_MAX] = { 0 };
uint8_t *mmap_ptr = NULL;

res = qsfp_cable_status(token);
if (res != FPGA_OK) {
OPAE_MSG("Failed to find QSFP cable info");
}

res = find_dev_feature(token, HSSI_FEATURE_ID, feature_dev);
if (res != FPGA_OK) {
OPAE_ERR("Failed to find feature ");
Expand Down
66 changes: 65 additions & 1 deletion libraries/libboard/board_common/board_common.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright(c) 2019-2022, Intel Corporation
// Copyright(c) 2019-2023, Intel Corporation
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -66,6 +66,10 @@

#define FACTORY_BIT (1ULL << 36)

// QSFP cable status
#define DFL_SYSFS_QSFP "*dfl*dev.%ld/qsfp_connected"
#define MAX_DEV_FEATURE_COUNT 256

// Read sysfs
fpga_result read_sysfs(fpga_token token, char *sysfs_path,
char *sysfs_name, size_t len)
Expand Down Expand Up @@ -740,3 +744,63 @@ fpga_result reformat_bom_info(

return res;
}

// QSFP cable status
fpga_result qsfp_cable_status(const fpga_token token)
{
fpga_object fpga_object;
fpga_result res = FPGA_OK;
uint64_t value = 0;
size_t i = 0;
char qsfp_path[PATH_MAX] = { 0 };
int retval = 0;
size_t qsfp_count = 0;

for (i = 0; i < MAX_DEV_FEATURE_COUNT; i++) {

memset(qsfp_path, 0, sizeof(qsfp_path));

retval = snprintf(qsfp_path, sizeof(qsfp_path),
DFL_SYSFS_QSFP, i);
if (retval < 0) {
OPAE_MSG("error in formatting qsfp cable status");
return FPGA_EXCEPTION;
}

res = fpgaTokenGetObject(token, qsfp_path,
&fpga_object, FPGA_OBJECT_GLOB);
if (res != FPGA_OK) {
OPAE_MSG("Failed to get token Object");
continue;
}

res = fpgaObjectRead64(fpga_object, &value, 0);
if (res == FPGA_OK) {
OPAE_MSG("Failed to Read object ");

switch (value) {
case 0:
printf("QSFP%-28ld : %s \n", qsfp_count, "Not Connected");
break;
case 1:
printf("QSFP%-28ld : %s \n", qsfp_count, "Connected");
break;
default:
printf("QSFP%-28ld : %s \n", qsfp_count, "N/A");
}

qsfp_count++;

} else {
OPAE_MSG("Failed to Read object ");
}

res = fpgaDestroyObject(&fpga_object);
if (res != FPGA_OK) {
OPAE_MSG("Failed to Destroy Object");
}

}

return res;
}
12 changes: 11 additions & 1 deletion libraries/libboard/board_common/board_common.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright(c) 2019-2022, Intel Corporation
// Copyright(c) 2019-2023, Intel Corporation
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -187,6 +187,16 @@ fpga_result reformat_bom_info(
const size_t len,
const size_t max_result_len);

/**
* prints QSFP cable status.
*
* @param[in] token fpga_token object for device (FPGA_DEVICE type)
* @returns FPGA_OK on success.
* FPGA_EXCEPTION if invalid sysfs path
*/
fpga_result qsfp_cable_status(const fpga_token token);


#ifdef __cplusplus
}
#endif /* __cplusplus */
Expand Down
7 changes: 6 additions & 1 deletion libraries/libboard/board_n6000/board_n6000.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright(c) 2021-2022, Intel Corporation
// Copyright(c) 2021-2023, Intel Corporation
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -510,6 +510,11 @@ fpga_result print_phy_info(fpga_token token)
char feature_dev[SYSFS_PATH_MAX] = { 0 };
uint8_t *mmap_ptr = NULL;

res = qsfp_cable_status(token);
if (res != FPGA_OK) {
OPAE_MSG("Failed to find QSFP cable info");
}

res = find_dev_feature(token, HSSI_FEATURE_ID, feature_dev);
if (res != FPGA_OK) {
OPAE_MSG("Failed to find feature HSSI");
Expand Down
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 025f4c2

Please sign in to comment.