From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id A7C59A0547;
	Fri, 28 May 2021 15:56:16 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 96DAC41105;
	Fri, 28 May 2021 15:56:08 +0200 (CEST)
Received: from mga17.intel.com (mga17.intel.com [192.55.52.151])
 by mails.dpdk.org (Postfix) with ESMTP id ECC5340698
 for <dev@dpdk.org>; Fri, 28 May 2021 15:56:04 +0200 (CEST)
IronPort-SDR: Ty7HqhwewygFv6Q6jkhaZZ7vbLT6Ws5NlG9yXh1wgN14UXYx2lJbvPMLSvyXgNmgpF0aGusJg8
 EKcDwcEmXCAQ==
X-IronPort-AV: E=McAfee;i="6200,9189,9998"; a="183301279"
X-IronPort-AV: E=Sophos;i="5.83,229,1616482800"; d="scan'208";a="183301279"
Received: from orsmga001.jf.intel.com ([10.7.209.18])
 by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 28 May 2021 06:56:04 -0700
IronPort-SDR: 9TsXuX1nuC7uYd1QZYg3Fukik8/qTTBYqzRtGmf4T3UF1eOQybKG1Da7dX576P3y4dII2TU1d5
 cBtMGSsAjL0g==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.83,229,1616482800"; d="scan'208";a="477934781"
Received: from silpixa00401026.ir.intel.com ([10.243.23.108])
 by orsmga001.jf.intel.com with ESMTP; 28 May 2021 06:56:03 -0700
From: Kevin Laatz <kevin.laatz@intel.com>
To: dev@dpdk.org
Cc: bruce.richardson@intel.com,
	Kevin Laatz <kevin.laatz@intel.com>
Date: Fri, 28 May 2021 14:55:59 +0100
Message-Id: <20210528135559.344815-3-kevin.laatz@intel.com>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20210528135559.344815-1-kevin.laatz@intel.com>
References: <20210528131902.344423-1-kevin.laatz@intel.com>
 <20210528135559.344815-1-kevin.laatz@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v3 2/2] raw/ioat: add device reset to python
 script
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Currently once a device is configured, the user does not have the ability
to reset the device via the script.

This patch adds a device reset option to the script. For example
"$dpdk_idxd_cfg.py 0 --reset" would reset device 0.

Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

---
v3: remove printing if the script running config or reset
---
 drivers/raw/ioat/dpdk_idxd_cfg.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/raw/ioat/dpdk_idxd_cfg.py b/drivers/raw/ioat/dpdk_idxd_cfg.py
index ad8393a645..83ef4817db 100755
--- a/drivers/raw/ioat/dpdk_idxd_cfg.py
+++ b/drivers/raw/ioat/dpdk_idxd_cfg.py
@@ -29,6 +29,12 @@ def write_values(self, values):
                 f.write(str(contents))
 
 
+def reset_device(dsa_id):
+    "Reset the DSA device and all its queues"
+    drv_dir = SysfsDir("/sys/bus/dsa/drivers/dsa")
+    drv_dir.write_values({"unbind": f"dsa{dsa_id}"})
+
+
 def get_pci_dir(pci):
     "Search for the sysfs directory of the PCI device"
     base_dir = '/sys/bus/pci/devices/'
@@ -95,11 +101,16 @@ def main(args):
     arg_p.add_argument('--name-prefix', metavar='prefix', dest='prefix',
                        default="dpdk",
                        help="Prefix for workqueue name to mark for DPDK use [default: 'dpdk']")
+    arg_p.add_argument('--reset', action='store_true',
+                       help="Reset DSA device and its queues")
     parsed_args = arg_p.parse_args(args[1:])
 
     dsa_id = parsed_args.dsa_id
     dsa_id = get_dsa_id(dsa_id) if ':' in dsa_id else dsa_id
-    configure_dsa(dsa_id, parsed_args.q, parsed_args.prefix)
+    if parsed_args.reset:
+        reset_device(dsa_id)
+    else:
+        configure_dsa(dsa_id, parsed_args.q, parsed_args.prefix)
 
 
 if __name__ == "__main__":
-- 
2.30.2