Skip to content
Merged
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
4 changes: 3 additions & 1 deletion cli/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,7 @@ static int log_dump(int argc, char **argv)
const struct argconfig_choice types[] = {
{"RAM", SWITCHTEC_LOG_RAM, "dump the app log from RAM"},
{"FLASH", SWITCHTEC_LOG_FLASH, "dump the app log from flash"},
{"FTDC", SWITCHTEC_LOG_FTDC, "dump the FTDC firmware log"},
{"MEMLOG", SWITCHTEC_LOG_MEMLOG,
"dump the Memlog info from flash in the last fatal error handling dump"},
{"REGS", SWITCHTEC_LOG_REGS,
Expand Down Expand Up @@ -1149,6 +1150,7 @@ static int log_parse(int argc, char **argv)
const struct argconfig_choice log_types[] = {
{"APP", SWITCHTEC_LOG_PARSE_TYPE_APP, "app log"},
{"MAILBOX", SWITCHTEC_LOG_PARSE_TYPE_MAILBOX, "mailbox log"},
{"FTDC", SWITCHTEC_LOG_PARSE_TYPE_FTDC, "ftdc"},
{}
};
const struct argconfig_choice device_gen[] = {
Expand Down Expand Up @@ -1227,7 +1229,7 @@ static int log_parse(int argc, char **argv)
fprintf(stderr, "\nParsed log saved to %s.\n",
cfg.parsed_log_filename);

if (info.version_mismatch) {
if (info.version_mismatch && cfg.log_type != SWITCHTEC_LOG_PARSE_TYPE_FTDC) {
fprintf(stderr, "\nWARNING: The two input files have different version numbers.\n");
fprintf(stderr, "\t\tFW Version\tSDK Version\n");
fprintf(stderr, "Log file:\t0x%08x\t0x%08x\n",
Expand Down
10 changes: 10 additions & 0 deletions inc/switchtec/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,14 @@ struct log_b_retr_result {
uint8_t data[MRPC_MAX_DATA_LEN - sizeof(struct log_b_retr_hdr)];
};

struct log_ftdc_retr {
uint8_t sub_cmd_id;
uint8_t reserved;
uint16_t req_seq;
};

struct log_ftdc_retr_result {
uint8_t data[MRPC_MAX_DATA_LEN];
};

#endif
4 changes: 3 additions & 1 deletion inc/switchtec/mrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ enum mrpc_cmd {
MRPC_SJTAG_UNLOCK = 0x10F,
MRPC_SECURITY_CONFIG_GET_GEN5 = 0x110,
MRPC_SECURITY_CONFIG_SET_GEN5 = 0x111,
MRPC_MAX_ID = 0x112,

MRPC_FTDC_LOG_DUMP = 0x147,
MRPC_MAX_ID = 0x148,
};

enum mrpc_bg_status {
Expand Down
4 changes: 3 additions & 1 deletion inc/switchtec/switchtec.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ enum switchtec_bw_type {
enum switchtec_log_type {
SWITCHTEC_LOG_RAM,
SWITCHTEC_LOG_FLASH,
SWITCHTEC_LOG_FTDC,
SWITCHTEC_LOG_MEMLOG,
SWITCHTEC_LOG_REGS,
SWITCHTEC_LOG_SYS_STACK,
Expand All @@ -242,7 +243,8 @@ enum switchtec_log_type {
*/
enum switchtec_log_parse_type {
SWITCHTEC_LOG_PARSE_TYPE_APP,
SWITCHTEC_LOG_PARSE_TYPE_MAILBOX
SWITCHTEC_LOG_PARSE_TYPE_MAILBOX,
SWITCHTEC_LOG_PARSE_TYPE_FTDC,
};

/**
Expand Down
1 change: 1 addition & 0 deletions lib/platform/gasops.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ static const struct no_retry_struct gasop_noretry_cmds[] = {
[MRPC_DBG_UNLOCK] = {1, 0, NULL},
[MRPC_SECURITY_CONFIG_SET_GEN5] = {1, 0, NULL},
[MRPC_FW_TX] = {1, 1, fw_toggle_noretry_subcmds},
[MRPC_FTDC_LOG_DUMP] = {0, 0, NULL},
};
static const int gasop_noretry_cmds_count = sizeof(gasop_noretry_cmds) /
sizeof(char);
Expand Down
87 changes: 77 additions & 10 deletions lib/switchtec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,8 +1112,8 @@ static int write_parsed_log(struct log_a_data log_data[],
bool is_bl1;
struct module_log_defs *mod_defs;

if (entry_idx == 0) {
if (log_type == SWITCHTEC_LOG_PARSE_TYPE_APP)
if (entry_idx == 0){
if (log_type == SWITCHTEC_LOG_PARSE_TYPE_APP || log_type == SWITCHTEC_LOG_PARSE_TYPE_FTDC)
fputs(" #|Timestamp |Module |Severity |Event ID |Event\n",
log_file);
else
Expand All @@ -1138,7 +1138,7 @@ static int write_parsed_log(struct log_a_data log_data[],
hours = time % 24;
days = time / 24;

if (log_type == SWITCHTEC_LOG_PARSE_TYPE_APP) {
if (log_type == SWITCHTEC_LOG_PARSE_TYPE_APP || log_type == SWITCHTEC_LOG_PARSE_TYPE_FTDC) {
/*
* app log: module ID and log severity are in the 3rd
* DWord
Expand Down Expand Up @@ -1199,7 +1199,7 @@ static int write_parsed_log(struct log_a_data log_data[],
if (ret < 0)
goto ret_print_error;

if (log_type == SWITCHTEC_LOG_PARSE_TYPE_APP) {
if (log_type == SWITCHTEC_LOG_PARSE_TYPE_APP || log_type == SWITCHTEC_LOG_PARSE_TYPE_FTDC) {
/* print the module name and log severity */
if (fprintf(log_file, "%-12s |%-8s |0x%04x |",
mod_defs->mod_name, log_sev_strs[log_sev],
Expand Down Expand Up @@ -1232,14 +1232,31 @@ static int write_parsed_log(struct log_a_data log_data[],
return -1;
}

static int append_ftdc_log_header(int fd, uint32_t sdk_def_version,
uint32_t fw_def_version)
{
int ret;
char hdr_str_fmt[] = "##########################################\n"
"## Parsed with FTDC log file from definition:\n"
"## FW def version %08x\n"
"## SDK def version %08x\n"
"##########################################\n\n";
char hdr_str[512];

snprintf(hdr_str, 512, hdr_str_fmt, fw_def_version, sdk_def_version);
ret = write(fd, hdr_str, strlen(hdr_str));

return ret;
}

static int parse_def_header(FILE *log_def_file, uint32_t *fw_version,
uint32_t *sdk_version)
{
char line[512];
int i;

*fw_version = 0;
*sdk_version = 0;

while (fgets(line, sizeof(line), log_def_file)) {
if (line[0] != '#')
continue;
Expand Down Expand Up @@ -1464,6 +1481,40 @@ static int log_c_to_file(struct switchtec_dev *dev, int sub_cmd_id, int fd)
return 0;
}

static int log_d_to_file(struct switchtec_dev *dev, int sub_cmd_id, int fd)
{
int ret;
int read = 0;

struct log_ftdc_retr_result res;
struct log_ftdc_retr cmd = {
.sub_cmd_id = sub_cmd_id,
.reserved = 0,
.req_seq = 0,
};
uint32_t length = sizeof(res.data);

cmd.req_seq = 0;
res.data[1] = 0;

while ( !(res.data[1]) ) {
ret = switchtec_cmd(dev, MRPC_FTDC_LOG_DUMP, &cmd, sizeof(cmd),
&res, sizeof(res));
if (ret)
return -1;

ret = write(fd, res.data, (res.data[0]+1)*4);
if (ret < 0)
return ret;

read += length;
cmd.req_seq++;

}

return 0;
}

static int log_ram_flash_to_file(struct switchtec_dev *dev,
int gen5_cmd, int gen4_cmd, int gen4_cmd_lgcy,
int fd, FILE *log_def_file,
Expand Down Expand Up @@ -1522,6 +1573,8 @@ int switchtec_log_to_file(struct switchtec_dev *dev,
MRPC_FWLOGRD_FLASH_WITH_FLAG,
MRPC_FWLOGRD_FLASH,
fd, log_def_file, info);
case SWITCHTEC_LOG_FTDC:
return log_d_to_file(dev, MRPC_FWLOGRD_RAM, fd);
case SWITCHTEC_LOG_MEMLOG:
return log_b_to_file(dev, MRPC_FWLOGRD_MEMLOG, fd);
case SWITCHTEC_LOG_REGS:
Expand Down Expand Up @@ -1605,15 +1658,25 @@ int switchtec_parse_log(FILE *bin_log_file, FILE *log_def_file,
memset(info, 0, sizeof(*info));

if ((log_type != SWITCHTEC_LOG_PARSE_TYPE_APP) &&
(log_type != SWITCHTEC_LOG_PARSE_TYPE_MAILBOX)) {
errno = EINVAL;
(log_type != SWITCHTEC_LOG_PARSE_TYPE_MAILBOX) &&
(log_type != SWITCHTEC_LOG_PARSE_TYPE_FTDC)) {
errno = EINVAL;
return -errno;
}

ret = parse_log_header(bin_log_file, &fw_version_log,
&sdk_version_log);
if (ret)
return ret;

if (log_type != SWITCHTEC_LOG_PARSE_TYPE_FTDC)
{
ret = parse_log_header(bin_log_file, &fw_version_log,
&sdk_version_log);
if (ret)
return ret;
}

ret = parse_def_header(log_def_file, &fw_version_def,
&sdk_version_def);
if (ret)
Expand All @@ -1632,13 +1695,17 @@ int switchtec_parse_log(FILE *bin_log_file, FILE *log_def_file,
info->log_sdk_version = sdk_version_log;
}
/* read the log definition file into defs */
if (log_type == SWITCHTEC_LOG_PARSE_TYPE_APP)
if (log_type == SWITCHTEC_LOG_PARSE_TYPE_APP || log_type == SWITCHTEC_LOG_PARSE_TYPE_FTDC)
ret = read_app_log_defs(log_def_file, &defs);
else
ret = read_mailbox_log_defs(log_def_file, &defs);

ret = append_log_header(fileno(parsed_log_file), sdk_version_log,
fw_version_log, 0);
if (log_type != SWITCHTEC_LOG_PARSE_TYPE_FTDC)
ret = append_log_header(fileno(parsed_log_file), sdk_version_log,
fw_version_log, 0);
else
ret = append_ftdc_log_header(fileno(parsed_log_file), sdk_version_def,
fw_version_def);
if (ret < 0)
return ret;

Expand Down