dma/idxd: add generic option for queue config

Message ID 20220330150700.435875-1-kevin.laatz@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series dma/idxd: add generic option for queue config |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Kevin Laatz March 30, 2022, 3:07 p.m. UTC
  The device config script currently uses some defaults to configure
devices in a generic way.

With the addition of this option, users have more control over how
queues are configured.

Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
---
 drivers/dma/idxd/dpdk_idxd_cfg.py | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)
  

Comments

Bruce Richardson March 31, 2022, 2:57 p.m. UTC | #1
On Wed, Mar 30, 2022 at 04:07:00PM +0100, Kevin Laatz wrote:
> The device config script currently uses some defaults to configure
> devices in a generic way.
> 
> With the addition of this option, users have more control over how
> queues are configured.
> 
> Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
> ---
>  drivers/dma/idxd/dpdk_idxd_cfg.py | 29 ++++++++++++++++++++++++++---
>  1 file changed, 26 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/dma/idxd/dpdk_idxd_cfg.py b/drivers/dma/idxd/dpdk_idxd_cfg.py
> index 3f5d5ee752..9ac724e7a8 100755
> --- a/drivers/dma/idxd/dpdk_idxd_cfg.py
> +++ b/drivers/dma/idxd/dpdk_idxd_cfg.py
> @@ -62,9 +62,25 @@ def get_dsa_id(pci):
>                  return int(dir[3:])
>      sys.exit(f"Could not get device ID for device {pci}")
>  
> -
> -def configure_dsa(dsa_id, queues, prefix):
> +def parse_wq_opts(dsa_id, q, wq_opts):
> +    "Parse the additional user-specified queue configuration"
> +    wq_dir = SysfsDir(f'/sys/bus/dsa/devices/dsa{dsa_id}/wq{dsa_id}.{q}')
> +    for wq_opt in wq_opts:
> +        try:
> +            opt, val = wq_opt.split("=")
> +        except ValueError:
> +            sys.exit("Invalid format, use format 'option=value'")
> +        if not os.path.exists(os.path.join(wq_dir.path, f'{opt}')):
> +            sys.exit(f"Invalid sysfs node '{opt}', path does not exist")
> +        wq_dir.write_values({opt: val})
> +
> +
> +def configure_dsa(dsa_id, args):
>      "Configure the DSA instance with appropriate number of queues"
> +    queues = args.q
> +    prefix = args.prefix
> +    wq_opts = args.wq_option
> +
>      dsa_dir = SysfsDir(f"/sys/bus/dsa/devices/dsa{dsa_id}")
>  
>      max_groups = dsa_dir.read_int("max_groups")
> @@ -92,6 +108,11 @@ def configure_dsa(dsa_id, queues, prefix):
>                               "max_batch_size": 1024,
>                               "size": int(max_work_queues_size / nb_queues)})
>  
> +    # parse additional user-spcified queue configuration
> +    if wq_opts:
> +        for q in range(nb_queues):
> +            parse_wq_opts(dsa_id, q, wq_opts)
> +

I think this may be better to have the parse function only parse the
options and split them. If that is done before the actual queue
configuration function is called, then the additional options could be
passed in there, and merged with the existing config settings. This avoids
duplicating things and doing two sets of configs.

/Bruce
  
Kevin Laatz March 31, 2022, 3:47 p.m. UTC | #2
On 31/03/2022 15:57, Bruce Richardson wrote:
> On Wed, Mar 30, 2022 at 04:07:00PM +0100, Kevin Laatz wrote:
>> The device config script currently uses some defaults to configure
>> devices in a generic way.
>>
>> With the addition of this option, users have more control over how
>> queues are configured.
>>
>> Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
>> ---
>>   drivers/dma/idxd/dpdk_idxd_cfg.py | 29 ++++++++++++++++++++++++++---
>>   1 file changed, 26 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/dma/idxd/dpdk_idxd_cfg.py b/drivers/dma/idxd/dpdk_idxd_cfg.py
>> index 3f5d5ee752..9ac724e7a8 100755
>> --- a/drivers/dma/idxd/dpdk_idxd_cfg.py
>> +++ b/drivers/dma/idxd/dpdk_idxd_cfg.py
>> @@ -62,9 +62,25 @@ def get_dsa_id(pci):
>>                   return int(dir[3:])
>>       sys.exit(f"Could not get device ID for device {pci}")
>>   
>> -
>> -def configure_dsa(dsa_id, queues, prefix):
>> +def parse_wq_opts(dsa_id, q, wq_opts):
>> +    "Parse the additional user-specified queue configuration"
>> +    wq_dir = SysfsDir(f'/sys/bus/dsa/devices/dsa{dsa_id}/wq{dsa_id}.{q}')
>> +    for wq_opt in wq_opts:
>> +        try:
>> +            opt, val = wq_opt.split("=")
>> +        except ValueError:
>> +            sys.exit("Invalid format, use format 'option=value'")
>> +        if not os.path.exists(os.path.join(wq_dir.path, f'{opt}')):
>> +            sys.exit(f"Invalid sysfs node '{opt}', path does not exist")
>> +        wq_dir.write_values({opt: val})
>> +
>> +
>> +def configure_dsa(dsa_id, args):
>>       "Configure the DSA instance with appropriate number of queues"
>> +    queues = args.q
>> +    prefix = args.prefix
>> +    wq_opts = args.wq_option
>> +
>>       dsa_dir = SysfsDir(f"/sys/bus/dsa/devices/dsa{dsa_id}")
>>   
>>       max_groups = dsa_dir.read_int("max_groups")
>> @@ -92,6 +108,11 @@ def configure_dsa(dsa_id, queues, prefix):
>>                                "max_batch_size": 1024,
>>                                "size": int(max_work_queues_size / nb_queues)})
>>   
>> +    # parse additional user-spcified queue configuration
>> +    if wq_opts:
>> +        for q in range(nb_queues):
>> +            parse_wq_opts(dsa_id, q, wq_opts)
>> +
> I think this may be better to have the parse function only parse the
> options and split them. If that is done before the actual queue
> configuration function is called, then the additional options could be
> passed in there, and merged with the existing config settings. This avoids
> duplicating things and doing two sets of configs.

Thanks for the suggestion, Bruce. I'll look into it and send a v2.

/Kevin
  

Patch

diff --git a/drivers/dma/idxd/dpdk_idxd_cfg.py b/drivers/dma/idxd/dpdk_idxd_cfg.py
index 3f5d5ee752..9ac724e7a8 100755
--- a/drivers/dma/idxd/dpdk_idxd_cfg.py
+++ b/drivers/dma/idxd/dpdk_idxd_cfg.py
@@ -62,9 +62,25 @@  def get_dsa_id(pci):
                 return int(dir[3:])
     sys.exit(f"Could not get device ID for device {pci}")
 
-
-def configure_dsa(dsa_id, queues, prefix):
+def parse_wq_opts(dsa_id, q, wq_opts):
+    "Parse the additional user-specified queue configuration"
+    wq_dir = SysfsDir(f'/sys/bus/dsa/devices/dsa{dsa_id}/wq{dsa_id}.{q}')
+    for wq_opt in wq_opts:
+        try:
+            opt, val = wq_opt.split("=")
+        except ValueError:
+            sys.exit("Invalid format, use format 'option=value'")
+        if not os.path.exists(os.path.join(wq_dir.path, f'{opt}')):
+            sys.exit(f"Invalid sysfs node '{opt}', path does not exist")
+        wq_dir.write_values({opt: val})
+
+
+def configure_dsa(dsa_id, args):
     "Configure the DSA instance with appropriate number of queues"
+    queues = args.q
+    prefix = args.prefix
+    wq_opts = args.wq_option
+
     dsa_dir = SysfsDir(f"/sys/bus/dsa/devices/dsa{dsa_id}")
 
     max_groups = dsa_dir.read_int("max_groups")
@@ -92,6 +108,11 @@  def configure_dsa(dsa_id, queues, prefix):
                              "max_batch_size": 1024,
                              "size": int(max_work_queues_size / nb_queues)})
 
+    # parse additional user-spcified queue configuration
+    if wq_opts:
+        for q in range(nb_queues):
+            parse_wq_opts(dsa_id, q, wq_opts)
+
     # enable device and then queues
     idxd_dir = SysfsDir(get_drv_dir("idxd"))
     idxd_dir.write_values({"bind": f"dsa{dsa_id}"})
@@ -112,6 +133,8 @@  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('--wq-option', action='append',
+                       help="Provide additional config option for queues (format 'x=y')")
     arg_p.add_argument('--reset', action='store_true',
                        help="Reset DSA device and its queues")
     parsed_args = arg_p.parse_args(args[1:])
@@ -121,7 +144,7 @@  def main(args):
     if parsed_args.reset:
         reset_device(dsa_id)
     else:
-        configure_dsa(dsa_id, parsed_args.q, parsed_args.prefix)
+        configure_dsa(dsa_id, parsed_args)
 
 
 if __name__ == "__main__":