On 2023/3/16 17:19, Dmitry Kozlyuk wrote:
> On Thu, Mar 16, 2023 at 4:11 AM fengchengwen <fengcheng...@huawei.com> wrote:
>> 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".
>> 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.
>>
>> Hope for more feedback.
> 
> What if rte_eth_dev_priv_dump() was a documented no-op when "f == NULL"?
> This can be implemented in ethdev layer:
> 1) if not implemented, return ENOTSUP
> 2) if f == NULL, return 0
> 3) else call PMD
> Technically, even now a null device handle can be used, but this is
> cumbersome and wastes resources for running the API twice.

Thanks your advise.
V2 has sent which adopt Thomas's comment:
        printf("Device private info:\n");
        ret = rte_eth_dev_priv_dump(port_id, stdout);
        if (ret == -ENOTSUP)
                printf("  none\n");
        else if (ret < 0)
                fprintf(stderr, "  Failed to dump private info with error (%d): 
%s\n",
                        ret, strerror(-ret));
which seem simpler.

> .
> 

Reply via email to