From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <jianfeng.tan@intel.com>
Received: from mga06.intel.com (mga06.intel.com [134.134.136.31])
 by dpdk.org (Postfix) with ESMTP id A4BB12B83
 for <dev@dpdk.org>; Tue, 17 Jan 2017 08:10:03 +0100 (CET)
Received: from fmsmga002.fm.intel.com ([10.253.24.26])
 by orsmga104.jf.intel.com with ESMTP; 16 Jan 2017 23:10:03 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.33,243,1477983600"; d="scan'208";a="1113750232"
Received: from dpdk06.sh.intel.com ([10.239.129.195])
 by fmsmga002.fm.intel.com with ESMTP; 16 Jan 2017 23:10:01 -0800
From: Jianfeng Tan <jianfeng.tan@intel.com>
To: dev@dpdk.org
Cc: yuanhan.liu@linux.intel.com, stephen@networkplumber.org,
 lei.a.yao@intel.com, Jianfeng Tan <jianfeng.tan@intel.com>
Date: Tue, 17 Jan 2017 07:10:30 +0000
Message-Id: <1484637030-106261-11-git-send-email-jianfeng.tan@intel.com>
X-Mailer: git-send-email 2.7.4
In-Reply-To: <1484637030-106261-1-git-send-email-jianfeng.tan@intel.com>
References: <1480810702-114815-1-git-send-email-jianfeng.tan@intel.com>
 <1484637030-106261-1-git-send-email-jianfeng.tan@intel.com>
Subject: [dpdk-dev] [PATCH v4 10/10] examples/l3fwd-power: fix not stop and
	close device
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Tue, 17 Jan 2017 07:10:04 -0000

As it gets killed, in SIGINT signal handler, device is not stopped
and closed. In virtio's case, vector assignment in the KVM is not
deassigned.

This patch will invoke dev_stop() and dev_close() in signal handler.

Fixes: d7937e2e3d12 ("power: initial import")

Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
Tested-by: Lei Yao <lei.a.yao@intel.com>
---
 examples/l3fwd-power/main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index e741434..15b47c7 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -379,6 +379,7 @@ static void
 signal_exit_now(int sigtype)
 {
 	unsigned lcore_id;
+	unsigned int portid, nb_ports;
 	int ret;
 
 	if (sigtype == SIGINT) {
@@ -393,6 +394,15 @@ signal_exit_now(int sigtype)
 					"library de-initialization failed on "
 							"core%u\n", lcore_id);
 		}
+
+		nb_ports = rte_eth_dev_count();
+		for (portid = 0; portid < nb_ports; portid++) {
+			if ((enabled_port_mask & (1 << portid)) == 0)
+				continue;
+
+			rte_eth_dev_stop(portid);
+			rte_eth_dev_close(portid);
+		}
 	}
 
 	rte_exit(EXIT_SUCCESS, "User forced exit\n");
-- 
2.7.4