Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
303 changes: 230 additions & 73 deletions cli/diag.c

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions cli/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1856,8 +1856,10 @@ enum switchtec_fw_type check_and_print_fw_image(int img_fd,
fprintf(stderr, "%s: Invalid image file format\n",
img_filename);
return ret;
} else if (ret > 0) {
return SWITCHTEC_FW_TYPE_BL2;
}

printf("File: %s\n", get_basename(img_filename));
printf("Gen: %s\n", switchtec_fw_image_gen_str(&info));
printf("Type: %s\n", switchtec_fw_image_type(&info));
Expand Down Expand Up @@ -2242,8 +2244,8 @@ static int fw_redundant(int argc, char **argv)

argconfig_parse(argc, argv, CMD_DESC_FW_REDUNDANT, opts, &cfg, sizeof(cfg));

if (!switchtec_is_gen5(cfg.dev)) {
fprintf(stderr, "Setting the redundant flag is only supported on Gen5 switches\n");
if (!switchtec_is_gen5(cfg.dev) && !switchtec_is_gen6(cfg.dev)) {
fprintf(stderr, "Setting the redundant flag is only supported on Gen5/6 switches\n");
return 1;
}
if (!cfg.bl2 && !cfg.key && !cfg.firmware && !cfg.config && !cfg.riotcore) {
Expand All @@ -2254,6 +2256,10 @@ static int fw_redundant(int argc, char **argv)
fprintf(stderr, "Set redundant flag to either set - 1 or unset - 0\n");
return 1;
}
if (switchtec_is_gen6(cfg.dev) && cfg.riotcore) {
fprintf(stderr, "Setting riotcore partition is not supported on Gen6 switches\n");
return 1;
}

ret = switchtec_fw_set_redundant_flag(cfg.dev, cfg.key,
cfg.riotcore, cfg.bl2,
Expand All @@ -2270,7 +2276,7 @@ static int fw_redundant(int argc, char **argv)
return ret;
}

#define CMD_DESC_FW_READ "read a firmware image from flash"
#define CMD_DESC_FW_READ "read a firmware image from flash, default(no args) reads main firmware image"

static int fw_read(int argc, char **argv)
{
Expand Down Expand Up @@ -2302,8 +2308,6 @@ static int fw_read(int argc, char **argv)
"assume yes when prompted"},
{"inactive", 'i', "", CFG_NONE, &cfg.inactive, no_argument,
"read the inactive partition"},
{"data", 'd', "", CFG_NONE, &cfg.data, no_argument,
"read the data/config partiton instead of the main firmware"},
{"config", 'c', "", CFG_NONE, &cfg.data, no_argument,
"read the data/config partiton instead of the main firmware"},
{"bl2", 'b', "", CFG_NONE, &cfg.bl2, no_argument,
Expand Down
14 changes: 8 additions & 6 deletions cli/mfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,21 +475,23 @@ static int info(int argc, char **argv)

printf("----------------- UID info --------------------------------\n");
printf("Device Unique ID: \t\t\t0x");
for (int i = 0; i < SWITCHTEC_UID_DWORD_S; i++) {
printf("%08X", *sn_info.UID);
printf("%08X\n", *sn_info.UID);
sn_info.UID++;
for (int i = 1; i < SWITCHTEC_UID_DWORD_S; i++) {
printf("\t\t\t\t\t %08X\n", *sn_info.UID);
sn_info.UID++;
}
printf("\n");
printf("Status: \t\t\t\t%s\n", status[(sn_info.PSID_UID_valid_flags >> 4) & 0x3]);
printf("Mask Read Mask Enable: \t\t\t0x%0x\n", (sn_info.PSID_UID_valid_flags >> 6) & 0x1);
printf("Read Mask Request Enable: \t\t0x%0x\n", (sn_info.PSID_UID_valid_flags >> 7) & 0x1);
printf("----------------- PSID info -------------------------------\n");
printf("Device PSID: \t\t\t\t0x");
for (int i = 0; i < SWITCHTEC_PSID_DWORD_S; i++) {
printf("%08X", *sn_info.PSID0);
printf("%08X\n", *sn_info.PSID0);
sn_info.PSID0++;
for (int i = 1; i < SWITCHTEC_PSID_DWORD_S; i++) {
printf("\t\t\t\t\t %08X\n", *sn_info.PSID0);
sn_info.PSID0++;
}
printf("\n");
printf("Status: \t\t\t\t%s\n", status[(sn_info.PSID_UID_valid_flags) & 0x3]);
printf("Read Mask Enable: \t\t\t0x%0x\n", (sn_info.PSID_UID_valid_flags >> 2) & 0x1);
printf("Read Mask Request Enable: \t\t0x%0x\n", (sn_info.PSID_UID_valid_flags >> 3) & 0x1);
Expand Down
17 changes: 17 additions & 0 deletions inc/switchtec/diag.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,23 @@ struct switchtec_gen5_diag_eye_run_in {
uint32_t lane_mask[4];
};

struct switchtec_gen6_diag_eye_run_in {
uint8_t sub_cmd;
uint8_t resvd1;
uint8_t timeout_disable;
uint8_t resvd2;
uint32_t lane_mask[4];
uint8_t sar_sel;
uint8_t intleav_sel;
uint8_t vstep;
int8_t hstep;
uint8_t data_mode;
uint8_t eye_mode;
uint16_t resvd3;
uint32_t ref_timer_lwr;
uint32_t ref_timer_upp;
};

struct switchtec_diag_cross_hair_in {
uint8_t sub_cmd;
uint8_t lane_id;
Expand Down
3 changes: 3 additions & 0 deletions inc/switchtec/mrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ enum mrpc_sub_cmd {
MRPC_EYE_CAP_STATUS_GEN5 = 1,
MRPC_EYE_CAP_READ_GEN5 = 2,

MRPC_EYE_CAP_RUN_GEN6 = 3,
MRPC_EYE_CAP_READ_GEN6 = 4,

MRPC_CROSS_HAIR_ENABLE = 0,
MRPC_CROSS_HAIR_DISABLE = 1,
MRPC_CROSS_HAIR_GET = 2,
Expand Down
108 changes: 71 additions & 37 deletions inc/switchtec/switchtec.h
Original file line number Diff line number Diff line change
Expand Up @@ -932,42 +932,42 @@ static inline const char *switchtec_ltssm_str_gen5(int ltssm, int show_minor)
static inline const char *switchtec_ltssm_str_gen6(int ltssm_major)
{
switch(ltssm_major) {
case 0x00: return "DETECT_QUIET";
case 0x01: return "DETECT_ACTIVE";
case 0x02: return "POLL_ACTIVE";
case 0x03: return "POLL_COMPLIANCE";
case 0x04: return "POLL_CONFIG";
case 0x05: return "PRE_DETECT_QUIET";
case 0x06: return "DETECT_WAIT";
case 0x07: return "CFG_LINKWD_START";
case 0x08: return "CFG_LINKWD_ACEPT";
case 0x09: return "CFG_LANENUM_WAI";
case 0x0A: return "CFG_LANENUM_ACEPT";
case 0x0B: return "CFG_COMPLETE";
case 0x0C: return "CFG_IDLE";
case 0x0D: return "RCVRY_LOCK";
case 0x0E: return "RCVRY_SPEED";
case 0x0F: return "RCVRY_RCVRCFG";
case 0x10: return "RCVRY_IDLE";
case 0x11: return "L0";
case 0x12: return "L0S";
case 0x13: return "L123_SEND_EIDLE";
case 0x14: return "L1_IDLE";
case 0x15: return "L2_IDLE";
case 0x16: return "L2_WAKE";
case 0x17: return "DISABLED_ENTRY";
case 0x18: return "DISABLED_IDLE";
case 0x19: return "DISABLED";
case 0x1A: return "LPBK_ENTRY";
case 0x1B: return "LPBK_ACTIVE";
case 0x1C: return "LPBK_EXIT";
case 0x1D: return "LPBK_EXIT_TIMEOUT";
case 0x1E: return "HOT_RESET_ENTRY";
case 0x1F: return "HOT_RESET";
case 0x20: return "RCVRY_EQ0";
case 0x21: return "RCVRY_EQ1";
case 0x22: return "RCVRY_EQ2";
case 0x23: return "RCVRY_EQ3";
case 0x00: return "Detect (QUIET)";
case 0x01: return "Detect (ACTIVE)";
case 0x02: return "Polling (ACTIVE)";
case 0x03: return "Polling (COMPLIANCE)";
case 0x04: return "Polling (CONFIG)";
case 0x05: return "Detect (PRE_DETECT_QUIET)";
case 0x06: return "Detect (DETECT_WAIT)";
case 0x07: return "Configuration (LINKWD_START)";
case 0x08: return "Configuration (LINKWD_ACCEPT)";
case 0x09: return "Configuration (LANENUM_WAIT)";
case 0x0A: return "Configuration (LANENUM_ACCEPT)";
case 0x0B: return "Configuration (COMPLETE)";
case 0x0C: return "Configuration (IDLE)";
case 0x0D: return "Recovery (LOCK)";
case 0x0E: return "Recovery (SPEED)";
case 0x0F: return "Recovery (RCVRCFG)";
case 0x10: return "Recovery (IDLE)";
case 0x11: return "L0 (ACTIVE)";
case 0x12: return "L0s (IDLE)";
case 0x13: return "L1/L2/L3 (SEND_EIDLE)";
case 0x14: return "L1 (IDLE)";
case 0x15: return "L2 (IDLE)";
case 0x16: return "L2 (WAKE)";
case 0x17: return "Disabled (ENTRY)";
case 0x18: return "Disabled (IDLE)";
case 0x19: return "Disabled";
case 0x1A: return "Loopback (ENTRY)";
case 0x1B: return "Loopback (ACTIVE)";
case 0x1C: return "Loopback (EXIT)";
case 0x1D: return "Loopback (EXIT_TIMEOUT)";
case 0x1E: return "Hot Reset (ENTRY)";
case 0x1F: return "Hot Reset";
case 0x20: return "Recovery (EQ0)";
case 0x21: return "Recovery (EQ1)";
case 0x22: return "Recovery (EQ2)";
case 0x23: return "Recovery (EQ3)";
default: return "UNKNOWN";
}
}
Expand Down Expand Up @@ -1519,6 +1519,25 @@ enum switchtec_diag_eye_data_mode {
SWITCHTEC_DIAG_EYE_RATIO,
};

enum switchtec_diag_eye_data_mode_gen6 {
SWITCHTEC_DIAG_EYE_ADC,
SWITCHTEC_DIAG_EYE_FFE,
SWITCHTEC_DIAG_EYE_DFE,
};

enum switchtec_diag_eye_mode_gen6 {
SWITCHTEC_DIAG_EYE_FULL,
SWITCHTEC_DIAG_EYE_INTERLEAVE,
SWITCHTEC_DIAG_EYE_SAR,
};

enum switchtec_diag_eye_h_step {
SWITCHTEC_DIAG_EYE_ULTRA_FINE = 1,
SWITCHTEC_DIAG_EYE_FINE = 2,
SWITCHTEC_DIAG_EYE_MEDIUM = 3,
SWITCHTEC_DIAG_EYE_COARSE = 4,
};

struct switchtec_gen5_diag_eye_status_in {
uint8_t sub_cmd;
uint8_t resvd1[3];
Expand Down Expand Up @@ -1574,13 +1593,26 @@ enum switchtec_diag_pattern_gen5 {
SWITCHTEC_DIAG_GEN_5_PATTERN_PRBS_DISABLED,
};

enum switchtec_diag_pattern_gen6 {
SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_7,
SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_9,
SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_11,
SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_13,
SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_15,
SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_23,
SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_31,
SWITCHTEC_DIAG_GEN_6_PATTERN_PCIE_52_UI_JIT = 0x19,
SWITCHTEC_DIAG_GEN_6_PATTERN_PRBS_DISABLED = 0x1A,
};

enum switchtec_diag_pattern_link_rate {
SWITCHTEC_DIAG_PAT_LINK_DISABLED = 0,
SWITCHTEC_DIAG_PAT_LINK_GEN1 = 1,
SWITCHTEC_DIAG_PAT_LINK_GEN2 = 2,
SWITCHTEC_DIAG_PAT_LINK_GEN3 = 3,
SWITCHTEC_DIAG_PAT_LINK_GEN4 = 4,
SWITCHTEC_DIAG_PAT_LINK_GEN5 = 5,
SWITCHTEC_DIAG_PAT_LINK_GEN6 = 6,
};

enum switchtec_diag_ltssm_speed {
Expand Down Expand Up @@ -1632,7 +1664,9 @@ int switchtec_diag_eye_read(struct switchtec_dev *dev, int lane_id, int bin,
int* num_phases, double* ber_data);
int switchtec_diag_eye_start(struct switchtec_dev *dev, int lane_mask[4],
struct range *x_range, struct range *y_range,
int step_interval, int capture_depth);
int step_interval, int capture_depth, int sar_sel,
int intleav_sel, int hstep, int data_mode,
int eye_mode, uint64_t refclk, int vstep);
int switchtec_diag_eye_fetch(struct switchtec_dev *dev, double *pixels,
size_t pixel_cnt, int *lane_id);
int switchtec_diag_eye_cancel(struct switchtec_dev *dev);
Expand Down
91 changes: 73 additions & 18 deletions lib/diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ int switchtec_diag_eye_read(struct switchtec_dev *dev, int lane_id,
*/
int switchtec_diag_eye_start(struct switchtec_dev *dev, int lane_mask[4],
struct range *x_range, struct range *y_range,
int step_interval, int capture_depth)
int step_interval, int capture_depth, int sar_sel,
int intleav_sel, int hstep, int data_mode,
int eye_mode, uint64_t refclk, int vstep)
{
int err, ret;
if (switchtec_is_gen5(dev)) {
Expand All @@ -295,6 +297,27 @@ int switchtec_diag_eye_start(struct switchtec_dev *dev, int lane_mask[4],
.lane_mask[3] = lane_mask[3],
};

ret = switchtec_diag_eye_cmd_gen5(dev, &in, sizeof(in));
err = errno;
errno = err;
return ret;
} else if (switchtec_is_gen6(dev)) {
struct switchtec_gen6_diag_eye_run_in in = {
.sub_cmd = MRPC_EYE_CAP_RUN_GEN6,
.timeout_disable = 1,
.lane_mask[0] = lane_mask[0],
.lane_mask[1] = lane_mask[1],
.lane_mask[2] = lane_mask[2],
.lane_mask[3] = lane_mask[3],
.sar_sel = sar_sel,
.intleav_sel = intleav_sel,
.vstep = vstep,
.data_mode = data_mode,
.eye_mode = eye_mode,
.ref_timer_lwr = refclk & 0xFFFFFFFF,
.ref_timer_upp = refclk >> 32,
};

ret = switchtec_diag_eye_cmd_gen5(dev, &in, sizeof(in));
err = errno;
errno = err;
Expand Down Expand Up @@ -2481,12 +2504,23 @@ int switchtec_osa_dump_conf(struct switchtec_dev *dev, int stack_id)
printf("%s", (osa_dmp_out.os_type_trig_link_rate >> 2) & 1 ? "GEN3," : "");
printf("%s", (osa_dmp_out.os_type_trig_link_rate >> 3) & 1 ? "GEN4," : "");
printf("%s\n", (osa_dmp_out.os_type_trig_link_rate >> 4) & 1 ? "GEN5" : "");

printf("os types: \t\t%s", osa_dmp_out.os_type_trig_os_types & 1 ? "TS1," : "");
printf("%s", (osa_dmp_out.os_type_trig_os_types >> 1) & 1 ? "TS2," : "");
printf("%s", (osa_dmp_out.os_type_trig_os_types >> 2) & 1 ? "FTS," : "");
printf("%s\n", (osa_dmp_out.os_type_trig_os_types >> 3) & 1 ? "CTL_SKP" : "");

if (switchtec_is_gen6(dev))
printf("%s\n", (osa_dmp_out.os_type_trig_link_rate >> 5) & 1 ? "GEN6" : "");

printf("os types: \t\t");
if (switchtec_is_gen6(dev)) {
printf("%s", osa_dmp_out.os_type_trig_os_types & 1 ? "TS0," : "");
printf("%s", (osa_dmp_out.os_type_trig_os_types >> 1) & 1 ? "TS1," : "");
printf("%s", (osa_dmp_out.os_type_trig_os_types >> 2) & 1 ? "TS2," : "");
printf("%s\n", (osa_dmp_out.os_type_trig_os_types >> 3) & 1 ? "FTS" : "");
printf("%s\n", (osa_dmp_out.os_type_trig_os_types >> 4) & 1 ? "CTL_SKP" : "");
} else {
printf("%s", osa_dmp_out.os_type_trig_os_types & 1 ? "TS1," : "");
printf("%s", (osa_dmp_out.os_type_trig_os_types >> 1) & 1 ? "TS2," : "");
printf("%s", (osa_dmp_out.os_type_trig_os_types >> 2) & 1 ? "FTS," : "");
printf("%s\n", (osa_dmp_out.os_type_trig_os_types >> 3) & 1 ? "CTL_SKP" : "");
}

printf("------- OS Pattern ---------------------\n");
printf("lanes: \t\t\t%s", osa_dmp_out.os_pat_trig_lane_mask & 1 ? "0," : "");
for (int i = 1; i < 16; i++) {
Expand All @@ -2506,6 +2540,8 @@ int switchtec_osa_dump_conf(struct switchtec_dev *dev, int stack_id)
printf("%s", (osa_dmp_out.os_pat_trig_link_rate >> 2) & 1 ? "GEN3," : "");
printf("%s", (osa_dmp_out.os_pat_trig_link_rate >> 3) & 1 ? "GEN4," : "");
printf("%s\n", (osa_dmp_out.os_pat_trig_link_rate >> 4) & 1 ? "GEN5" : "");
if (switchtec_is_gen6(dev))
printf("%s\n", (osa_dmp_out.os_type_trig_link_rate >> 5) & 1 ? "GEN6" : "");

printf("patttern: \t\t0x%08x %08x %08x %08x\n", osa_dmp_out.os_pat_trig_val_dw0,
osa_dmp_out.os_pat_trig_val_dw1, osa_dmp_out.os_pat_trig_val_dw2,
Expand Down Expand Up @@ -2536,9 +2572,15 @@ int switchtec_osa_dump_conf(struct switchtec_dev *dev, int stack_id)
printf("direciton: \t\t%s", osa_dmp_out.capture_dir & 1 ? "RX," : "");
printf("%s\n", (osa_dmp_out.capture_dir >> 1) & 1 ? "TX" : "");

printf("drop single os: \t%d: Single TS1, TS2, FTS and CTL_SKP OS's %s in the capture\n",
osa_dmp_out.capture_drop_os,
osa_dmp_out.capture_drop_os ? " excluded" : "included");
if (switchtec_is_gen6(dev))
printf("drop single os: \t%d: Single TS0, TS1, TS2, FTS and CTL_SKP OS's %s in the capture\n",
osa_dmp_out.capture_drop_os,
osa_dmp_out.capture_drop_os ? " excluded" : "included");
else
printf("drop single os: \t%d: Single TS1, TS2, FTS and CTL_SKP OS's %s in the capture\n",
osa_dmp_out.capture_drop_os,
osa_dmp_out.capture_drop_os ? " excluded" : "included");

printf("stop mode: \t\t%d: OSA will stop capturing after %s lane has stopped writing into %s allocated RAMs\n",
osa_dmp_out.capture_stop_mode,
osa_dmp_out.capture_stop_mode ? "all" : "any",
Expand All @@ -2548,14 +2590,27 @@ int switchtec_osa_dump_conf(struct switchtec_dev *dev, int stack_id)
osa_dmp_out.capture_snap_mode ? "until the RAM is full" : "according to the Post-Trigger Entries value");
printf("post-trigger entries: \t%d\n", osa_dmp_out.capture_post_trig_entries);

printf("os types: \t\t%s", (osa_dmp_out.capture_os_types & 1) ? "TS1," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 1) & 1 ? "TS2," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 2) & 1 ? "FTS," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 3) & 1 ? "CTL_SKP," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 4) & 1 ? "SKP," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 5) & 1 ? "EIEOS," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 6) & 1 ? "EIOS," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 7) & 1 ? "ERR_OS," : "");
printf("os types: \t\t");
if (switchtec_is_gen6(dev)) {
printf("%s", (osa_dmp_out.capture_os_types & 1) ? "TS0," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 1) & 1 ? "TS2," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 2) & 1 ? "TS2," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 3) & 1 ? "FTS," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 4) & 1 ? "CTL_SKP," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 5) & 1 ? "SKP," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 6) & 1 ? "EIEOS," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 7) & 1 ? "EIOS," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 8) & 1 ? "ERR_OS," : "");
} else {
printf("%s", (osa_dmp_out.capture_os_types & 1) ? "TS1," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 1) & 1 ? "TS2," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 2) & 1 ? "FTS," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 3) & 1 ? "CTL_SKP," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 4) & 1 ? "SKP," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 5) & 1 ? "EIEOS," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 6) & 1 ? "EIOS," : "");
printf("%s", (osa_dmp_out.capture_os_types >> 7) & 1 ? "ERR_OS," : "");
}
printf("\n");
return ret;
}
Expand Down
Loading