* [dpdk-dev] [PATCH] raw/ioat: extend python script functionality
@ 2021-05-27 13:26 Kevin Laatz
2021-05-27 14:27 ` Bruce Richardson
2021-05-28 13:19 ` [dpdk-dev] [PATCH v2 0/2] extend idxd config " Kevin Laatz
0 siblings, 2 replies; 12+ messages in thread
From: Kevin Laatz @ 2021-05-27 13:26 UTC (permalink / raw)
To: dev; +Cc: bruce.richardson, Kevin Laatz
Currently the user needs to find the DSA instance number for any DSA
device they would like to configure using this script, which can be
cumbersome and error-prone since the instance numbering changes when
changing the binding of the devices between vfio-pci and idxd. In
addition to this, once the device is configured, there is no option to
reset the device using the script.
This patch contains two additions to the script:
1. Add the ability to specify the DSA device to configure using the
device's PCI address instead of the DSA instance number. For example,
"$dpdk_idxd_cfg.py 0" and "$dpdk_idxd_cfg.py 6a:01.0" are both valid
references to the same device (assuming the numbering).
2. An option to reset the device via the script. For example,
"$dpdk_idxd_cfg.py 6a:01.0 --reset"
Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
---
drivers/raw/ioat/dpdk_idxd_cfg.py | 38 +++++++++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/drivers/raw/ioat/dpdk_idxd_cfg.py b/drivers/raw/ioat/dpdk_idxd_cfg.py
index ff06d9e240..7bc33b6ddb 100755
--- a/drivers/raw/ioat/dpdk_idxd_cfg.py
+++ b/drivers/raw/ioat/dpdk_idxd_cfg.py
@@ -29,6 +29,29 @@ 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"
+ full_pci = pci if pci.startswith("0000:") else f"0000:{pci}"
+ if os.path.exists(f'/sys/bus/pci/devices/{full_pci}'):
+ return f'/sys/bus/pci/devices/{full_pci}'
+ return None
+
+
+def get_dsa_id(pci):
+ "Get the DSA instance ID using the PCI address of the device"
+ pci_dir = get_pci_dir(pci)
+ for path, dirs, files in os.walk(pci_dir):
+ for dir in dirs:
+ if dir.startswith('dsa') and 'wq' not in dir:
+ return int(dir[3:])
+
+
def configure_dsa(dsa_id, queues, prefix):
"Configure the DSA instance with appropriate number of queues"
dsa_dir = SysfsDir(f"/sys/bus/dsa/devices/dsa{dsa_id}")
@@ -68,14 +91,25 @@ def main(args):
"Main function, does arg parsing and calls config function"
arg_p = argparse.ArgumentParser(
description="Configure whole DSA device instance for DPDK use")
- arg_p.add_argument('dsa_id', type=int, help="DSA instance number")
+ arg_p.add_argument('dsa_id',
+ help="Specify DSA instance either via DSA instance number or PCI address")
arg_p.add_argument('-q', metavar='queues', type=int, default=255,
help="Number of queues to set up")
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:])
- configure_dsa(parsed_args.dsa_id, parsed_args.q, parsed_args.prefix)
+
+ dsa_id = parsed_args.dsa_id
+ dsa_id = get_dsa_id(dsa_id) if ':' in dsa_id else dsa_id
+ 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__":
--
2.30.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH] raw/ioat: extend python script functionality
2021-05-27 13:26 [dpdk-dev] [PATCH] raw/ioat: extend python script functionality Kevin Laatz
@ 2021-05-27 14:27 ` Bruce Richardson
2021-05-27 14:46 ` Laatz, Kevin
2021-05-28 13:19 ` [dpdk-dev] [PATCH v2 0/2] extend idxd config " Kevin Laatz
1 sibling, 1 reply; 12+ messages in thread
From: Bruce Richardson @ 2021-05-27 14:27 UTC (permalink / raw)
To: Kevin Laatz; +Cc: dev
On Thu, May 27, 2021 at 02:26:46PM +0100, Kevin Laatz wrote:
> Currently the user needs to find the DSA instance number for any DSA
> device they would like to configure using this script, which can be
> cumbersome and error-prone since the instance numbering changes when
> changing the binding of the devices between vfio-pci and idxd. In
> addition to this, once the device is configured, there is no option to
> reset the device using the script.
>
> This patch contains two additions to the script:
> 1. Add the ability to specify the DSA device to configure using the
> device's PCI address instead of the DSA instance number. For example,
> "$dpdk_idxd_cfg.py 0" and "$dpdk_idxd_cfg.py 6a:01.0" are both valid
> references to the same device (assuming the numbering).
> 2. An option to reset the device via the script. For example,
> "$dpdk_idxd_cfg.py 6a:01.0 --reset"
>
> Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
> ---
> drivers/raw/ioat/dpdk_idxd_cfg.py | 38 +++++++++++++++++++++++++++++--
> 1 file changed, 36 insertions(+), 2 deletions(-)
>
Hi Kevin,
since you list out two changes here, it's a good indication that this might
be better as two separate patches. Can you please split it, thanks.
Couple of minor comments inline below too.
Regards,
/Bruce
> diff --git a/drivers/raw/ioat/dpdk_idxd_cfg.py b/drivers/raw/ioat/dpdk_idxd_cfg.py
> index ff06d9e240..7bc33b6ddb 100755
> --- a/drivers/raw/ioat/dpdk_idxd_cfg.py
> +++ b/drivers/raw/ioat/dpdk_idxd_cfg.py
> @@ -29,6 +29,29 @@ 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"
> + full_pci = pci if pci.startswith("0000:") else f"0000:{pci}"
This will limit the script to only working on domains starting with 0000.
While I'm not aware of any specific cases where this won't work, for
generality sake, can we detect the presence/absense of the 0000: in some
other way, e.g. length, or count of ":" characters?
> + if os.path.exists(f'/sys/bus/pci/devices/{full_pci}'):
> + return f'/sys/bus/pci/devices/{full_pci}'
> + return None
> +
> +
> +def get_dsa_id(pci):
> + "Get the DSA instance ID using the PCI address of the device"
> + pci_dir = get_pci_dir(pci)
> + for path, dirs, files in os.walk(pci_dir):
What happens if pci_dir is None?
> + for dir in dirs:
> + if dir.startswith('dsa') and 'wq' not in dir:
> + return int(dir[3:])
> +
> +
> def configure_dsa(dsa_id, queues, prefix):
> "Configure the DSA instance with appropriate number of queues"
> dsa_dir = SysfsDir(f"/sys/bus/dsa/devices/dsa{dsa_id}")
> @@ -68,14 +91,25 @@ def main(args):
> "Main function, does arg parsing and calls config function"
> arg_p = argparse.ArgumentParser(
> description="Configure whole DSA device instance for DPDK use")
> - arg_p.add_argument('dsa_id', type=int, help="DSA instance number")
> + arg_p.add_argument('dsa_id',
> + help="Specify DSA instance either via DSA instance number or PCI address")
> arg_p.add_argument('-q', metavar='queues', type=int, default=255,
> help="Number of queues to set up")
> 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:])
> - configure_dsa(parsed_args.dsa_id, parsed_args.q, parsed_args.prefix)
> +
> + dsa_id = parsed_args.dsa_id
> + dsa_id = get_dsa_id(dsa_id) if ':' in dsa_id else dsa_id
> + 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__":
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH] raw/ioat: extend python script functionality
2021-05-27 14:27 ` Bruce Richardson
@ 2021-05-27 14:46 ` Laatz, Kevin
0 siblings, 0 replies; 12+ messages in thread
From: Laatz, Kevin @ 2021-05-27 14:46 UTC (permalink / raw)
To: Richardson, Bruce; +Cc: dev
<...>
> Hi Kevin,
>
> since you list out two changes here, it's a good indication that this might
> be better as two separate patches. Can you please split it, thanks.
>
> Couple of minor comments inline below too.
>
> Regards,
> /Bruce
>
Thanks for the feedback, Bruce. I'll split the changes as suggested and will
address the comments below for v2.
-Kevin
> > diff --git a/drivers/raw/ioat/dpdk_idxd_cfg.py
> b/drivers/raw/ioat/dpdk_idxd_cfg.py
> > index ff06d9e240..7bc33b6ddb 100755
> > --- a/drivers/raw/ioat/dpdk_idxd_cfg.py
> > +++ b/drivers/raw/ioat/dpdk_idxd_cfg.py
> > @@ -29,6 +29,29 @@ 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"
> > + full_pci = pci if pci.startswith("0000:") else f"0000:{pci}"
>
> This will limit the script to only working on domains starting with 0000.
> While I'm not aware of any specific cases where this won't work, for
> generality sake, can we detect the presence/absense of the 0000: in some
> other way, e.g. length, or count of ":" characters?
>
> > + if os.path.exists(f'/sys/bus/pci/devices/{full_pci}'):
> > + return f'/sys/bus/pci/devices/{full_pci}'
> > + return None
> > +
> > +
> > +def get_dsa_id(pci):
> > + "Get the DSA instance ID using the PCI address of the device"
> > + pci_dir = get_pci_dir(pci)
> > + for path, dirs, files in os.walk(pci_dir):
>
> What happens if pci_dir is None?
>
> > + for dir in dirs:
> > + if dir.startswith('dsa') and 'wq' not in dir:
> > + return int(dir[3:])
> > +
> > +
> > def configure_dsa(dsa_id, queues, prefix):
> > "Configure the DSA instance with appropriate number of queues"
> > dsa_dir = SysfsDir(f"/sys/bus/dsa/devices/dsa{dsa_id}")
> > @@ -68,14 +91,25 @@ def main(args):
> > "Main function, does arg parsing and calls config function"
> > arg_p = argparse.ArgumentParser(
> > description="Configure whole DSA device instance for DPDK use")
> > - arg_p.add_argument('dsa_id', type=int, help="DSA instance number")
> > + arg_p.add_argument('dsa_id',
> > + help="Specify DSA instance either via DSA instance number or
> PCI address")
> > arg_p.add_argument('-q', metavar='queues', type=int, default=255,
> > help="Number of queues to set up")
> > 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:])
> > - configure_dsa(parsed_args.dsa_id, parsed_args.q, parsed_args.prefix)
> > +
> > + dsa_id = parsed_args.dsa_id
> > + dsa_id = get_dsa_id(dsa_id) if ':' in dsa_id else dsa_id
> > + 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__":
> > --
> > 2.30.2
> >
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH v2 0/2] extend idxd config script functionality
2021-05-27 13:26 [dpdk-dev] [PATCH] raw/ioat: extend python script functionality Kevin Laatz
2021-05-27 14:27 ` Bruce Richardson
@ 2021-05-28 13:19 ` Kevin Laatz
2021-05-28 13:19 ` [dpdk-dev] [PATCH v2 1/2] raw/ioat: add pci address handling to python script Kevin Laatz
` (2 more replies)
1 sibling, 3 replies; 12+ messages in thread
From: Kevin Laatz @ 2021-05-28 13:19 UTC (permalink / raw)
To: dev; +Cc: bruce.richardson, Kevin Laatz
This patchset extends the functionality of the idxd config script, the
additions are described in the individual patches.
Kevin Laatz (2):
raw/ioat: add pci address handling to python script
raw/ioat: add device reset to python script
drivers/raw/ioat/dpdk_idxd_cfg.py | 41 +++++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH v2 1/2] raw/ioat: add pci address handling to python script
2021-05-28 13:19 ` [dpdk-dev] [PATCH v2 0/2] extend idxd config " Kevin Laatz
@ 2021-05-28 13:19 ` Kevin Laatz
2021-05-28 13:34 ` Bruce Richardson
2021-05-28 13:19 ` [dpdk-dev] [PATCH v2 2/2] raw/ioat: add device reset " Kevin Laatz
2021-05-28 13:55 ` [dpdk-dev] [PATCH v3 0/2] extend idxd config script functionality Kevin Laatz
2 siblings, 1 reply; 12+ messages in thread
From: Kevin Laatz @ 2021-05-28 13:19 UTC (permalink / raw)
To: dev; +Cc: bruce.richardson, Kevin Laatz
Currently the user needs to find the DSA instance number for any DSA device
they would like to configure using this script, which can be cumbersome and
error-prone since the instance numbering changes when changing the binding
of the devices between vfio-pci and idxd.
This patch improved the usability of the script by adding the ability to
specify the DSA device to configure using the device's PCI address instead
of the DSA instance number. For example, "$dpdk_idxd_cfg.py 0" and
"$dpdk_idxd_cfg.py 6a:01.0" are both valid references to the same device
(assuming the numbering).
Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
---
v2:
- split the device reset change into its own patch
- changed sysfs dir search
- improved error case handling
---
drivers/raw/ioat/dpdk_idxd_cfg.py | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/raw/ioat/dpdk_idxd_cfg.py b/drivers/raw/ioat/dpdk_idxd_cfg.py
index ff06d9e240..ad8393a645 100755
--- a/drivers/raw/ioat/dpdk_idxd_cfg.py
+++ b/drivers/raw/ioat/dpdk_idxd_cfg.py
@@ -29,6 +29,26 @@ def write_values(self, values):
f.write(str(contents))
+def get_pci_dir(pci):
+ "Search for the sysfs directory of the PCI device"
+ base_dir = '/sys/bus/pci/devices/'
+ for path, dirs, files in os.walk(base_dir):
+ for dir in dirs:
+ if pci in dir:
+ return os.path.join(base_dir, dir)
+ sys.exit(f"Could not find sysfs directory for device {pci}")
+
+
+def get_dsa_id(pci):
+ "Get the DSA instance ID using the PCI address of the device"
+ pci_dir = get_pci_dir(pci)
+ for path, dirs, files in os.walk(pci_dir):
+ for dir in dirs:
+ if dir.startswith('dsa') and 'wq' not in dir:
+ return int(dir[3:])
+ sys.exit(f"Could not get device ID for device {pci}")
+
+
def configure_dsa(dsa_id, queues, prefix):
"Configure the DSA instance with appropriate number of queues"
dsa_dir = SysfsDir(f"/sys/bus/dsa/devices/dsa{dsa_id}")
@@ -68,14 +88,18 @@ def main(args):
"Main function, does arg parsing and calls config function"
arg_p = argparse.ArgumentParser(
description="Configure whole DSA device instance for DPDK use")
- arg_p.add_argument('dsa_id', type=int, help="DSA instance number")
+ arg_p.add_argument('dsa_id',
+ help="Specify DSA instance either via DSA instance number or PCI address")
arg_p.add_argument('-q', metavar='queues', type=int, default=255,
help="Number of queues to set up")
arg_p.add_argument('--name-prefix', metavar='prefix', dest='prefix',
default="dpdk",
help="Prefix for workqueue name to mark for DPDK use [default: 'dpdk']")
parsed_args = arg_p.parse_args(args[1:])
- configure_dsa(parsed_args.dsa_id, parsed_args.q, parsed_args.prefix)
+
+ 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 __name__ == "__main__":
--
2.30.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH v2 2/2] raw/ioat: add device reset to python script
2021-05-28 13:19 ` [dpdk-dev] [PATCH v2 0/2] extend idxd config " Kevin Laatz
2021-05-28 13:19 ` [dpdk-dev] [PATCH v2 1/2] raw/ioat: add pci address handling to python script Kevin Laatz
@ 2021-05-28 13:19 ` Kevin Laatz
2021-05-28 13:37 ` Bruce Richardson
2021-05-28 13:55 ` [dpdk-dev] [PATCH v3 0/2] extend idxd config script functionality Kevin Laatz
2 siblings, 1 reply; 12+ messages in thread
From: Kevin Laatz @ 2021-05-28 13:19 UTC (permalink / raw)
To: dev; +Cc: bruce.richardson, Kevin Laatz
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(-)
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__":
--
2.30.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/2] raw/ioat: add pci address handling to python script
2021-05-28 13:19 ` [dpdk-dev] [PATCH v2 1/2] raw/ioat: add pci address handling to python script Kevin Laatz
@ 2021-05-28 13:34 ` Bruce Richardson
0 siblings, 0 replies; 12+ messages in thread
From: Bruce Richardson @ 2021-05-28 13:34 UTC (permalink / raw)
To: Kevin Laatz; +Cc: dev
On Fri, May 28, 2021 at 02:19:01PM +0100, Kevin Laatz wrote:
> Currently the user needs to find the DSA instance number for any DSA device
> they would like to configure using this script, which can be cumbersome and
> error-prone since the instance numbering changes when changing the binding
> of the devices between vfio-pci and idxd.
>
s/changes/may change/
I've found a number of times that after unbinding and rebinding a device the
number did not change.
> This patch improved the usability of the script by adding the ability to
s/improved/improves/
> specify the DSA device to configure using the device's PCI address instead
> of the DSA instance number. For example, "$dpdk_idxd_cfg.py 0" and
> "$dpdk_idxd_cfg.py 6a:01.0" are both valid references to the same device
> (assuming the numbering).
>
> Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
>
With the above minor commit-log tweaks
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> v2:
> - split the device reset change into its own patch
> - changed sysfs dir search
> - improved error case handling
> ---
> drivers/raw/ioat/dpdk_idxd_cfg.py | 28 ++++++++++++++++++++++++++--
> 1 file changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/raw/ioat/dpdk_idxd_cfg.py b/drivers/raw/ioat/dpdk_idxd_cfg.py
> index ff06d9e240..ad8393a645 100755
> --- a/drivers/raw/ioat/dpdk_idxd_cfg.py
> +++ b/drivers/raw/ioat/dpdk_idxd_cfg.py
> @@ -29,6 +29,26 @@ def write_values(self, values):
> f.write(str(contents))
>
>
> +def get_pci_dir(pci):
> + "Search for the sysfs directory of the PCI device"
> + base_dir = '/sys/bus/pci/devices/'
> + for path, dirs, files in os.walk(base_dir):
> + for dir in dirs:
> + if pci in dir:
> + return os.path.join(base_dir, dir)
> + sys.exit(f"Could not find sysfs directory for device {pci}")
> +
> +
> +def get_dsa_id(pci):
> + "Get the DSA instance ID using the PCI address of the device"
> + pci_dir = get_pci_dir(pci)
> + for path, dirs, files in os.walk(pci_dir):
> + for dir in dirs:
> + if dir.startswith('dsa') and 'wq' not in dir:
> + return int(dir[3:])
> + sys.exit(f"Could not get device ID for device {pci}")
> +
> +
> def configure_dsa(dsa_id, queues, prefix):
> "Configure the DSA instance with appropriate number of queues"
> dsa_dir = SysfsDir(f"/sys/bus/dsa/devices/dsa{dsa_id}")
> @@ -68,14 +88,18 @@ def main(args):
> "Main function, does arg parsing and calls config function"
> arg_p = argparse.ArgumentParser(
> description="Configure whole DSA device instance for DPDK use")
> - arg_p.add_argument('dsa_id', type=int, help="DSA instance number")
> + arg_p.add_argument('dsa_id',
> + help="Specify DSA instance either via DSA instance number or PCI address")
> arg_p.add_argument('-q', metavar='queues', type=int, default=255,
> help="Number of queues to set up")
> arg_p.add_argument('--name-prefix', metavar='prefix', dest='prefix',
> default="dpdk",
> help="Prefix for workqueue name to mark for DPDK use [default: 'dpdk']")
> parsed_args = arg_p.parse_args(args[1:])
> - configure_dsa(parsed_args.dsa_id, parsed_args.q, parsed_args.prefix)
> +
> + 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 __name__ == "__main__":
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v2 2/2] raw/ioat: add device reset to python script
2021-05-28 13:19 ` [dpdk-dev] [PATCH v2 2/2] raw/ioat: add device reset " Kevin Laatz
@ 2021-05-28 13:37 ` Bruce Richardson
0 siblings, 0 replies; 12+ messages in thread
From: Bruce Richardson @ 2021-05-28 13:37 UTC (permalink / raw)
To: Kevin Laatz; +Cc: dev
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>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH v3 0/2] extend idxd config script functionality
2021-05-28 13:19 ` [dpdk-dev] [PATCH v2 0/2] extend idxd config " Kevin Laatz
2021-05-28 13:19 ` [dpdk-dev] [PATCH v2 1/2] raw/ioat: add pci address handling to python script Kevin Laatz
2021-05-28 13:19 ` [dpdk-dev] [PATCH v2 2/2] raw/ioat: add device reset " Kevin Laatz
@ 2021-05-28 13:55 ` Kevin Laatz
2021-05-28 13:55 ` [dpdk-dev] [PATCH v3 1/2] raw/ioat: add pci address handling to python script Kevin Laatz
` (2 more replies)
2 siblings, 3 replies; 12+ messages in thread
From: Kevin Laatz @ 2021-05-28 13:55 UTC (permalink / raw)
To: dev; +Cc: bruce.richardson, Kevin Laatz
This patchset extends the functionality of the idxd config script, the
additions are described in the individual patches.
v3:
- minor commit log updates
- remove printing if the script is running config or reset
Kevin Laatz (2):
raw/ioat: add pci address handling to python script
raw/ioat: add device reset to python script
drivers/raw/ioat/dpdk_idxd_cfg.py | 39 +++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH v3 1/2] raw/ioat: add pci address handling to python script
2021-05-28 13:55 ` [dpdk-dev] [PATCH v3 0/2] extend idxd config script functionality Kevin Laatz
@ 2021-05-28 13:55 ` Kevin Laatz
2021-05-28 13:55 ` [dpdk-dev] [PATCH v3 2/2] raw/ioat: add device reset " Kevin Laatz
2021-06-17 7:32 ` [dpdk-dev] [PATCH v3 0/2] extend idxd config script functionality Thomas Monjalon
2 siblings, 0 replies; 12+ messages in thread
From: Kevin Laatz @ 2021-05-28 13:55 UTC (permalink / raw)
To: dev; +Cc: bruce.richardson, Kevin Laatz
Currently the user needs to find the DSA instance number for any DSA device
they would like to configure using this script, which can be cumbersome and
error-prone since the instance numbering may change when changing the
binding of the devices between vfio-pci and idxd.
This patch improves the usability of the script by adding the ability to
specify the DSA device to configure using the device's PCI address instead
of the DSA instance number. For example, "$dpdk_idxd_cfg.py 0" and
"$dpdk_idxd_cfg.py 6a:01.0" are both valid references to the same device
(assuming the numbering).
Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
v2:
- split the device reset change into its own patch
- changed sysfs dir search
- improved error case handling
v3: minor commit log updates
---
drivers/raw/ioat/dpdk_idxd_cfg.py | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/raw/ioat/dpdk_idxd_cfg.py b/drivers/raw/ioat/dpdk_idxd_cfg.py
index ff06d9e240..ad8393a645 100755
--- a/drivers/raw/ioat/dpdk_idxd_cfg.py
+++ b/drivers/raw/ioat/dpdk_idxd_cfg.py
@@ -29,6 +29,26 @@ def write_values(self, values):
f.write(str(contents))
+def get_pci_dir(pci):
+ "Search for the sysfs directory of the PCI device"
+ base_dir = '/sys/bus/pci/devices/'
+ for path, dirs, files in os.walk(base_dir):
+ for dir in dirs:
+ if pci in dir:
+ return os.path.join(base_dir, dir)
+ sys.exit(f"Could not find sysfs directory for device {pci}")
+
+
+def get_dsa_id(pci):
+ "Get the DSA instance ID using the PCI address of the device"
+ pci_dir = get_pci_dir(pci)
+ for path, dirs, files in os.walk(pci_dir):
+ for dir in dirs:
+ if dir.startswith('dsa') and 'wq' not in dir:
+ return int(dir[3:])
+ sys.exit(f"Could not get device ID for device {pci}")
+
+
def configure_dsa(dsa_id, queues, prefix):
"Configure the DSA instance with appropriate number of queues"
dsa_dir = SysfsDir(f"/sys/bus/dsa/devices/dsa{dsa_id}")
@@ -68,14 +88,18 @@ def main(args):
"Main function, does arg parsing and calls config function"
arg_p = argparse.ArgumentParser(
description="Configure whole DSA device instance for DPDK use")
- arg_p.add_argument('dsa_id', type=int, help="DSA instance number")
+ arg_p.add_argument('dsa_id',
+ help="Specify DSA instance either via DSA instance number or PCI address")
arg_p.add_argument('-q', metavar='queues', type=int, default=255,
help="Number of queues to set up")
arg_p.add_argument('--name-prefix', metavar='prefix', dest='prefix',
default="dpdk",
help="Prefix for workqueue name to mark for DPDK use [default: 'dpdk']")
parsed_args = arg_p.parse_args(args[1:])
- configure_dsa(parsed_args.dsa_id, parsed_args.q, parsed_args.prefix)
+
+ 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 __name__ == "__main__":
--
2.30.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH v3 2/2] raw/ioat: add device reset to python script
2021-05-28 13:55 ` [dpdk-dev] [PATCH v3 0/2] extend idxd config script functionality Kevin Laatz
2021-05-28 13:55 ` [dpdk-dev] [PATCH v3 1/2] raw/ioat: add pci address handling to python script Kevin Laatz
@ 2021-05-28 13:55 ` Kevin Laatz
2021-06-17 7:32 ` [dpdk-dev] [PATCH v3 0/2] extend idxd config script functionality Thomas Monjalon
2 siblings, 0 replies; 12+ messages in thread
From: Kevin Laatz @ 2021-05-28 13:55 UTC (permalink / raw)
To: dev; +Cc: bruce.richardson, Kevin Laatz
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v3 0/2] extend idxd config script functionality
2021-05-28 13:55 ` [dpdk-dev] [PATCH v3 0/2] extend idxd config script functionality Kevin Laatz
2021-05-28 13:55 ` [dpdk-dev] [PATCH v3 1/2] raw/ioat: add pci address handling to python script Kevin Laatz
2021-05-28 13:55 ` [dpdk-dev] [PATCH v3 2/2] raw/ioat: add device reset " Kevin Laatz
@ 2021-06-17 7:32 ` Thomas Monjalon
2 siblings, 0 replies; 12+ messages in thread
From: Thomas Monjalon @ 2021-06-17 7:32 UTC (permalink / raw)
To: Kevin Laatz; +Cc: dev, bruce.richardson
28/05/2021 15:55, Kevin Laatz:
> This patchset extends the functionality of the idxd config script, the
> additions are described in the individual patches.
>
> v3:
> - minor commit log updates
> - remove printing if the script is running config or reset
>
> Kevin Laatz (2):
> raw/ioat: add pci address handling to python script
> raw/ioat: add device reset to python script
Series applied, thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-06-17 7:32 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27 13:26 [dpdk-dev] [PATCH] raw/ioat: extend python script functionality Kevin Laatz
2021-05-27 14:27 ` Bruce Richardson
2021-05-27 14:46 ` Laatz, Kevin
2021-05-28 13:19 ` [dpdk-dev] [PATCH v2 0/2] extend idxd config " Kevin Laatz
2021-05-28 13:19 ` [dpdk-dev] [PATCH v2 1/2] raw/ioat: add pci address handling to python script Kevin Laatz
2021-05-28 13:34 ` Bruce Richardson
2021-05-28 13:19 ` [dpdk-dev] [PATCH v2 2/2] raw/ioat: add device reset " Kevin Laatz
2021-05-28 13:37 ` Bruce Richardson
2021-05-28 13:55 ` [dpdk-dev] [PATCH v3 0/2] extend idxd config script functionality Kevin Laatz
2021-05-28 13:55 ` [dpdk-dev] [PATCH v3 1/2] raw/ioat: add pci address handling to python script Kevin Laatz
2021-05-28 13:55 ` [dpdk-dev] [PATCH v3 2/2] raw/ioat: add device reset " Kevin Laatz
2021-06-17 7:32 ` [dpdk-dev] [PATCH v3 0/2] extend idxd config script functionality Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).