From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 07A7E41EAF; Thu, 16 Mar 2023 10:40:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E858742C54; Thu, 16 Mar 2023 10:40:07 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 0F23842C54 for ; Thu, 16 Mar 2023 10:40:06 +0100 (CET) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Pchwt39P3zSlDT; Thu, 16 Mar 2023 17:36:46 +0800 (CST) Received: from [10.67.100.224] (10.67.100.224) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 16 Mar 2023 17:39:48 +0800 Subject: Re: [PATCH] app/testpmd: dump private info in 'show port info' To: Thomas Monjalon , Ferruh Yigit , Aman Singh , Yuying Zhang CC: References: <20230314115035.33356-1-fengchengwen@huawei.com> <33a601b7-8e44-6dc7-923a-27d9a74c6993@amd.com> <12167900.O9o76ZdvQC@thomas> From: fengchengwen Message-ID: <2d1cb68c-0f14-0e45-dbe3-cb2febd9b189@huawei.com> Date: Thu, 16 Mar 2023 17:39:47 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <12167900.O9o76ZdvQC@thomas> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.100.224] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 2023/3/16 15:55, Thomas Monjalon wrote: > 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 >>>> --- >>>> 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. Good idea, fix in v2, thanks. > >> 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. > > > > . >