Skip to content

Commit ffb6ebc

Browse files
committed
bfdump support
This commit adds bfdump support to dump the dmesg of DPU ARM linux with command 'rshim -c -i <N> --bfdump'. It also improves the help information for command mode with 'rshim -c --help'. Signed-off-by: Liming Sun <[email protected]>
1 parent ba56861 commit ffb6ebc

File tree

6 files changed

+321
-48
lines changed

6 files changed

+321
-48
lines changed

man/rshim.8

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,25 @@ Specify the backend to attach, which can be one of usb, pcie or pcie_lf. If not
9595

9696
-c, --cmdmode
9797
.in +4n
98-
Run rshim as command line rather than as driver. The following sub-commands are supported (only for USB backend).
99-
98+
Run rshim as command line rather than as driver. Run "-c --help" to see the sub-commands.
99+
.br
100+
Syntax: rshim -c --help
101+
.br
102+
OPTIONS:
100103
-g, --get-debug
101-
Get the current debug setting.
104+
Get the debug code.
105+
106+
-m, --bfdump
107+
Start debug dump which is sent to the standard output.
102108

103109
-r, --reg <addr.[32|64] [value]>
104110
Read/write registers.
105111

106-
-s, set-debug <0 | 1>
107-
Set the debug setting.
112+
-s, --set-debug <0 | 1> set debug code
113+
Set the debug code.
114+
115+
If rshim driver is already running on the current host, use "-i <index>" to specify /dev/rshim<index> to use.
116+
If "-i <index>" is not specified, it'll try to connect to the first USB backend.
108117
.in
109118

110119
-d, --device

src/rshim.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,7 @@ ssize_t rshim_fifo_write(rshim_backend_t *bd, const char *buffer,
17541754

17551755
static void rshim_work_handler(rshim_backend_t *bd)
17561756
{
1757+
rsh_scratchpad3_t sp3 = { .word = 0 };
17571758
int rc;
17581759

17591760
pthread_mutex_lock(&bd->mutex);
@@ -1762,8 +1763,12 @@ static void rshim_work_handler(rshim_backend_t *bd)
17621763

17631764
if (bd->keepalive && bd->has_rshim && !bd->debug_code && !bd->drop_mode &&
17641765
!bd->in_access_check) {
1765-
bd->write_rshim(bd, RSHIM_CHANNEL, bd->regs->scratchpad1,
1766-
RSHIM_KEEPALIVE_MAGIC_NUM, RSHIM_REG_SIZE_8B);
1766+
bd->read_rshim(bd, RSHIM_CHANNEL, bd->regs->scratchpad3,
1767+
&sp3.word, RSHIM_REG_SIZE_8B);
1768+
if (sp3.dbg_cmd == RSH_DBG_CMD_NONE) {
1769+
bd->write_rshim(bd, RSHIM_CHANNEL, bd->regs->scratchpad1,
1770+
RSHIM_KEEPALIVE_MAGIC_NUM, RSHIM_REG_SIZE_8B);
1771+
}
17671772
bd->keepalive = 0;
17681773
}
17691774

@@ -3316,13 +3321,12 @@ static void print_help(void)
33163321
printf("\n");
33173322
printf("OPTIONS:\n");
33183323
printf(" -b, --backend backend name (usb, pcie or pcie-lf)\n");
3319-
printf(" -c, --cmdmode run in command line mode\n");
3320-
printf(" -g, --get-debug get debug code\n");
3321-
printf(" -r, --reg <addr.[32|64] [value]> read/write register\n");
3322-
printf(" -s, --set-debug <0 | 1> set debug code\n");
3324+
printf(" -c, --cmdmode command line mode");
3325+
printf(" ('-c --help' for sub-commands)\n");
33233326
printf(" -d, --device device to attach\n");
33243327
printf(" -f, --foreground run in foreground\n");
33253328
printf(" -F, --force run in force mode\n");
3329+
printf(" -h, --help show help info\n");
33263330
printf(" -i, --index use device path /dev/rshim<i>/\n");
33273331
printf(" -l, --log-level log level");
33283332
printf("(0:none, 1:error, 2:warning, 3:notice, 4:debug)\n");
@@ -3332,27 +3336,25 @@ static void print_help(void)
33323336

33333337
int main(int argc, char *argv[])
33343338
{
3335-
static const char short_options[] = "b:cd:fgFhi:l:nr:sv";
3339+
static const char short_options[] = "b:cd:fFhi:l:nv";
33363340
static struct option long_options[] = {
33373341
{ "backend", required_argument, NULL, 'b' },
33383342
{ "cmdmode", no_argument, NULL, 'c' },
33393343
{ "device", required_argument, NULL, 'd' },
33403344
{ "foreground", no_argument, NULL, 'f' },
33413345
{ "force", no_argument, NULL, 'F' },
3342-
{ "get-debug", no_argument, NULL, 'g' },
33433346
{ "help", no_argument, NULL, 'h' },
33443347
{ "index", required_argument, NULL, 'i' },
33453348
{ "log-level", required_argument, NULL, 'l' },
33463349
{ "nonet", no_argument, NULL, 'n' },
3347-
{ "reg", required_argument, NULL, 'r' },
3348-
{ "set-debug", required_argument, NULL, 's' },
33493350
{ "version", no_argument, NULL, 'v' },
33503351
{ NULL, 0, NULL, 0 }
33513352
};
33523353
int c, rc, pid_fd = -1;
33533354
pthread_t thread;
33543355

33553356
/* Parse arguments. */
3357+
opterr = 0;
33563358
while ((c = getopt_long(argc, argv, short_options, long_options, NULL))
33573359
!= -1) {
33583360
switch (c) {
@@ -3402,6 +3404,16 @@ int main(int argc, char *argv[])
34023404
printf("Rshim Driver for BlueField SoC 2.0\n");
34033405
#endif
34043406
return 0;
3407+
case '?':
3408+
if (!rshim_cmdmode) {
3409+
if (optopt) {
3410+
fprintf(stderr, "Invalid option: -%c\n", optopt);
3411+
} else {
3412+
fprintf(stderr, "Invalid option\n");
3413+
}
3414+
return -EINVAL;
3415+
}
3416+
break;
34053417
case 'h':
34063418
default:
34073419
if (!rshim_cmdmode) {

src/rshim.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ struct rshim_regs {
482482
uint32_t reset_control;
483483
uint32_t scratchpad1;
484484
uint32_t scratchpad2;
485+
uint32_t scratchpad3;
485486
uint32_t scratchpad6;
486487
uint32_t tm_htt_sts;
487488
uint32_t tm_tth_sts;

0 commit comments

Comments
 (0)