[v2,2/2] raw/ioat: add device reset to python script

Message ID 20210528131902.344423-3-kevin.laatz@intel.com (mailing list archive)
State Superseded, archived
Headers
Series extend idxd config script functionality |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Kevin Laatz May 28, 2021, 1:19 p.m. UTC
  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>
---
 drivers/raw/ioat/dpdk_idxd_cfg.py | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
  

Comments

Bruce Richardson May 28, 2021, 1:37 p.m. UTC | #1
On Fri, May 28, 2021 at 02:19:02PM +0100, Kevin Laatz wrote:
> 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>
> ---

I'd tend toward not having the prints for what the script is doing, and
have the script silent by default. However, with or without that tweak:

Acked-by: Bruce Richardson <bruce.richardson@intel.com>
  

Patch

diff --git a/drivers/raw/ioat/dpdk_idxd_cfg.py b/drivers/raw/ioat/dpdk_idxd_cfg.py
index ad8393a645..138b555040 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,18 @@  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:
+        print(f"Resetting DSA instance {dsa_id}")
+        reset_device(dsa_id)
+    else:
+        print(f"Configuring DSA instance {dsa_id}")
+        configure_dsa(dsa_id, parsed_args.q, parsed_args.prefix)
 
 
 if __name__ == "__main__":