Skip to content

Commit

Permalink
add QSFP cable status to fpgainfo phy (#2916)
Browse files Browse the repository at this point in the history
* add QSFP cable status to fpgainfo phy

fpgainfo phy reads QSFP cable  status and prints connected or not
connected

QSFP0                            : Not Connected
QSFP1                            : Not Connected

Signed-off-by: anandaravuri <ananda.ravuri@intel.com>

* fix qsfp not supported case

Signed-off-by: anandaravuri <ananda.ravuri@intel.com>

---------

Signed-off-by: anandaravuri <ananda.ravuri@intel.com>
Co-authored-by: Tim Whisonant <tim.whisonant@intel.com>
  • Loading branch information
anandaravuri and tswhison committed Apr 12, 2023
1 parent 619fdf1 commit 5f590f0
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 4 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

0 comments on commit 5f590f0

Please sign in to comment.