Skip to content

Commit 0365f85

Browse files
authored
Merge pull request #340 from BenReed161/support-ftdc-log-dump-cmd
Add support for FTDC MRPC command log collection
2 parents 1c0ced0 + 5c696f1 commit 0365f85

File tree

5 files changed

+50
-1
lines changed

5 files changed

+50
-1
lines changed

cli/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,7 @@ static int log_dump(int argc, char **argv)
10001000
const struct argconfig_choice types[] = {
10011001
{"RAM", SWITCHTEC_LOG_RAM, "dump the app log from RAM"},
10021002
{"FLASH", SWITCHTEC_LOG_FLASH, "dump the app log from flash"},
1003+
{"FTDC", SWITCHTEC_LOG_FTDC, "dump the FTDC firmware log"},
10031004
{"MEMLOG", SWITCHTEC_LOG_MEMLOG,
10041005
"dump the Memlog info from flash in the last fatal error handling dump"},
10051006
{"REGS", SWITCHTEC_LOG_REGS,

inc/switchtec/log.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,14 @@ struct log_b_retr_result {
8181
uint8_t data[MRPC_MAX_DATA_LEN - sizeof(struct log_b_retr_hdr)];
8282
};
8383

84+
struct log_ftdc_retr {
85+
uint8_t sub_cmd_id;
86+
uint8_t reserved;
87+
uint16_t req_seq;
88+
};
89+
90+
struct log_ftdc_retr_result {
91+
uint8_t data[MRPC_MAX_DATA_LEN];
92+
};
93+
8494
#endif

inc/switchtec/mrpc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ enum mrpc_cmd {
124124
MRPC_SN_VER_GET_GEN5 = 0x119,
125125
MRPC_DBG_UNLOCK_GEN5 = 0x11A,
126126
MRPC_BOOTUP_RESUME_GEN5 = 0x11B,
127+
MRPC_FTDC_LOG_DUMP = 0x147,
127128

128-
MRPC_MAX_ID = 0x11C,
129+
MRPC_MAX_ID = 0x148,
129130
};
130131

131132
enum mrpc_bg_status {

inc/switchtec/switchtec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ enum switchtec_bw_type {
195195
enum switchtec_log_type {
196196
SWITCHTEC_LOG_RAM,
197197
SWITCHTEC_LOG_FLASH,
198+
SWITCHTEC_LOG_FTDC,
198199
SWITCHTEC_LOG_MEMLOG,
199200
SWITCHTEC_LOG_REGS,
200201
SWITCHTEC_LOG_SYS_STACK,

lib/switchtec.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,40 @@ static int log_c_to_file(struct switchtec_dev *dev, int sub_cmd_id, int fd)
14211421
return 0;
14221422
}
14231423

1424+
static int log_d_to_file(struct switchtec_dev *dev, int sub_cmd_id, int fd)
1425+
{
1426+
int ret;
1427+
int read = 0;
1428+
1429+
struct log_ftdc_retr_result res;
1430+
struct log_ftdc_retr cmd = {
1431+
.sub_cmd_id = sub_cmd_id,
1432+
.reserved = 0,
1433+
.req_seq = 0,
1434+
};
1435+
uint32_t length = sizeof(res.data);
1436+
1437+
cmd.req_seq = 0;
1438+
res.data[1] = 0;
1439+
1440+
while ( !(res.data[1]) ) {
1441+
ret = switchtec_cmd(dev, MRPC_FTDC_LOG_DUMP, &cmd, sizeof(cmd),
1442+
&res, sizeof(res));
1443+
if (ret)
1444+
return -1;
1445+
1446+
ret = write(fd, res.data, (res.data[0]+1)*4);
1447+
if (ret < 0)
1448+
return ret;
1449+
1450+
read += length;
1451+
cmd.req_seq++;
1452+
1453+
}
1454+
1455+
return 0;
1456+
}
1457+
14241458
static int log_ram_flash_to_file(struct switchtec_dev *dev,
14251459
int gen5_cmd, int gen4_cmd, int gen4_cmd_lgcy,
14261460
int fd, FILE *log_def_file,
@@ -1479,6 +1513,8 @@ int switchtec_log_to_file(struct switchtec_dev *dev,
14791513
MRPC_FWLOGRD_FLASH_WITH_FLAG,
14801514
MRPC_FWLOGRD_FLASH,
14811515
fd, log_def_file, info);
1516+
case SWITCHTEC_LOG_FTDC:
1517+
return log_d_to_file(dev, MRPC_FWLOGRD_RAM, fd);
14821518
case SWITCHTEC_LOG_MEMLOG:
14831519
return log_b_to_file(dev, MRPC_FWLOGRD_MEMLOG, fd);
14841520
case SWITCHTEC_LOG_REGS:

0 commit comments

Comments
 (0)