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 87FBCA0C46; Tue, 28 Sep 2021 03:22:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5642D410DF; Tue, 28 Sep 2021 03:22:56 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id 77F9B40E3C for ; Tue, 28 Sep 2021 03:22:54 +0200 (CEST) Received: from dggeme756-chm.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4HJMDT3nNbz8tV7; Tue, 28 Sep 2021 09:22:01 +0800 (CST) Received: from [10.67.103.128] (10.67.103.128) by dggeme756-chm.china.huawei.com (10.3.19.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Tue, 28 Sep 2021 09:22:51 +0800 From: "Min Hu (Connor)" To: CC: , References: <1617876888-63458-1-git-send-email-humin29@huawei.com> <1620272768-42421-1-git-send-email-humin29@huawei.com> <1620272768-42421-3-git-send-email-humin29@huawei.com> Message-ID: Date: Tue, 28 Sep 2021 09:22:51 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <1620272768-42421-3-git-send-email-humin29@huawei.com> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.103.128] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggeme756-chm.china.huawei.com (10.3.19.102) X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH v2 2/2] examples/ethtool: add closing port operation 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 Sender: "dev" Hi, Ferruh, any comments? ÔÚ 2021/5/6 11:46, Min Hu (Connor) дµÀ: > From: Huisong Li > > Currently, ethtool directly ends the process after 'quit' cmd. In this > case, software resources are not released and hardware resources of the > device are not uninstalled. > > This patch adds closing port operation to release resources. > > Fixes: bda68ab9d1e7 ("examples/ethtool: add user-space ethtool sample application") > Cc: stable@dpdk.org > > Signed-off-by: Huisong Li > Signed-off-by: Min Hu (Connor) > --- > examples/ethtool/ethtool-app/main.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/examples/ethtool/ethtool-app/main.c b/examples/ethtool/ethtool-app/main.c > index 21ed85c..9ac0a44 100644 > --- a/examples/ethtool/ethtool-app/main.c > +++ b/examples/ethtool/ethtool-app/main.c > @@ -256,6 +256,22 @@ static int worker_main(__rte_unused void *ptr_data) > return 0; > } > > +static void close_ports(void) > +{ > + uint16_t portid; > + int ret; > + > + for (portid = 0; portid < app_cfg.cnt_ports; portid++) { > + printf("Closing port %d...", portid); > + ret = rte_eth_dev_stop(portid); > + if (ret != 0) > + rte_exit(EXIT_FAILURE, "rte_eth_dev_stop: err=%s, port=%u\n", > + strerror(-ret), portid); > + rte_eth_dev_close(portid); > + printf(" Done\n"); > + } > +} > + > int main(int argc, char **argv) > { > int cnt_args_parsed; > @@ -299,6 +315,8 @@ int main(int argc, char **argv) > return -1; > } > > + close_ports(); > + > /* clean up the EAL */ > rte_eal_cleanup(); > >