[PATCH] app/testpmd: dump private info in 'show port info'
Thomas Monjalon
thomas at monjalon.net
Thu Mar 16 08:55:58 CET 2023
16/03/2023 02:10, fengchengwen:
> On 2023/3/15 18:12, Ferruh Yigit wrote:
> > On 3/15/2023 2:33 AM, Chengwen Feng wrote:
> >> This patch adds dump private info in 'show port info [port_id]' cmd.
> >>
> >> Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
> >> ---
> >> app/test-pmd/config.c | 5 +++++
> >> 1 file changed, 5 insertions(+)
> >>
> >> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> >> index 018536f177..ab5199f223 100644
> >> --- a/app/test-pmd/config.c
> >> +++ b/app/test-pmd/config.c
> >> @@ -938,6 +938,11 @@ port_infos_display(portid_t port_id)
> >> printf("unknown\n");
> >> break;
> >> }
> >> + printf("Device private info:\n");
> >
> > Not all drivers support device private info, above should print only
> > when it is supported.
> >
> >> + ret = rte_eth_dev_priv_dump(port_id, stdout);
> >> + if (ret < 0)
> >> + fprintf(stderr, " Failed to dump private info with error (%d): %s\n",
> >> + ret, strerror(-ret));
> >
> > Similarly, if driver doesn't support '.eth_dev_priv_dump' it shouldn't
> > print the above error log.
> >
>
> Because we have no API to know the PMD whether impl specific ops, we could only knowed by invoking.
> Except above impl, I also consider the other two:
> 1. just invoke rte_eth_dev_priv_dump without previous printf("Device private info") and later error printf.
> and I think people may curious about the extra output without a prompt just like "Device private info".
You can print the error only if the return is not ENOTSUP.
You can keep the first print and then print "none" if ENOTSUP.
> 2. use fmemopen (the below code), this way will perfect process the PMD which not imp ops.
> FILE *f = fmemopen(buf, max-size(e.g. 128KB));
> ret = rte_eth_dev_priv_dump(port_id, f);
> if (ret == 0) {
> printf("Device private info:\n");
> printf("%s", buf);
> }
> But the windows platform don't support fmemopen.
That's also a good solution but we need to support Windows.
More information about the dev
mailing list