From 4913a24e7910edf5a3f52536b780d1b1d4bb73a4 Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Sat, 1 Apr 2023 17:43:20 -0700 Subject: [PATCH] cxgbetool(8): Add support for tracing loopback traffic for a port. Use lo to tap the loopback for port . MFC after: 1 week Sponsored by: Chelsio Communications --- usr.sbin/cxgbetool/cxgbetool.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/usr.sbin/cxgbetool/cxgbetool.c b/usr.sbin/cxgbetool/cxgbetool.c index 43707df0b47a..149eacb54924 100644 --- a/usr.sbin/cxgbetool/cxgbetool.c +++ b/usr.sbin/cxgbetool/cxgbetool.c @@ -124,7 +124,7 @@ usage(FILE *fp) "\tsched-queue bind NIC queues to TX Scheduling class\n" "\tstdio interactive mode\n" "\ttcb read TCB\n" - "\ttracer tx|rx set and enable a tracer\n" + "\ttracer tx|rx|lo set and enable a tracer\n" "\ttracer disable|enable disable or enable a tracer\n" "\ttracer list list all tracers\n" ); @@ -2478,17 +2478,24 @@ set_tracer(uint8_t idx, int argc, const char *argv[]) t.valid = 1; if (argc != 1) { - warnx("must specify tx or rx."); + warnx("must specify one of tx/rx/lo"); return (EINVAL); } len = strlen(argv[0]); if (len != 3) { - warnx("argument must be 3 characters (tx or rx)"); + warnx("argument must be 3 characters (tx/rx/lo). eg. tx0"); return (EINVAL); } - if (strncmp(argv[0], "tx", 2) == 0) { + if (strncmp(argv[0], "lo", 2) == 0) { + port = argv[0][2] - '0'; + if (port < 0 || port > 3) { + warnx("'%c' in %s is invalid", argv[0][2], argv[0]); + return (EINVAL); + } + port += 8; + } else if (strncmp(argv[0], "tx", 2) == 0) { port = argv[0][2] - '0'; if (port < 0 || port > 3) { warnx("'%c' in %s is invalid", argv[0][2], argv[0]);