DPDK patches and discussions
 help / color / mirror / Atom feed
From: Kevin Laatz <kevin.laatz@intel.com>
To: dev@dpdk.org
Cc: bruce.richardson@intel.com, Kevin Laatz <kevin.laatz@intel.com>
Subject: [PATCH v2] dma/idxd: add generic option for queue config
Date: Thu, 31 Mar 2022 18:21:12 +0100	[thread overview]
Message-ID: <20220331172112.575972-1-kevin.laatz@intel.com> (raw)
In-Reply-To: <20220330150700.435875-1-kevin.laatz@intel.com>

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 | 39 ++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/drivers/dma/idxd/dpdk_idxd_cfg.py b/drivers/dma/idxd/dpdk_idxd_cfg.py
index 3f5d5ee752..704cf775ed 100755
--- a/drivers/dma/idxd/dpdk_idxd_cfg.py
+++ b/drivers/dma/idxd/dpdk_idxd_cfg.py
@@ -63,8 +63,24 @@ def get_dsa_id(pci):
     sys.exit(f"Could not get device ID for device {pci}")
 
 
-def configure_dsa(dsa_id, queues, prefix):
+def parse_wq_opts(wq_opts):
+    "Parse user-specified queue configuration, creating a dict of options"
+    opt_dict = {}
+    for wq_opt in wq_opts:
+        try:
+            opt, val = wq_opt.split("=")
+        except ValueError:
+            sys.exit("Invalid --wq-option format, use format 'option=value'")
+        opt_dict[opt] = val
+    return opt_dict
+
+
+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")
@@ -83,14 +99,17 @@ def configure_dsa(dsa_id, queues, prefix):
 
     # configure each queue
     for q in range(nb_queues):
+        default_dict = {"group_id": q % nb_groups,
+                        "type": "user",
+                        "mode": "dedicated",
+                        "name": f"{prefix}_wq{dsa_id}.{q}",
+                        "priority": 1,
+                        "max_batch_size": 1024,
+                        "size": int(max_work_queues_size / nb_queues)}
+        config_dict = parse_wq_opts(wq_opts)
+        write_dict = {**default_dict, **config_dict}
         wq_dir = SysfsDir(os.path.join(dsa_dir.path, f"wq{dsa_id}.{q}"))
-        wq_dir.write_values({"group_id": q % nb_groups,
-                             "type": "user",
-                             "mode": "dedicated",
-                             "name": f"{prefix}_wq{dsa_id}.{q}",
-                             "priority": 1,
-                             "max_batch_size": 1024,
-                             "size": int(max_work_queues_size / nb_queues)})
+        wq_dir.write_values(write_dict)
 
     # enable device and then queues
     idxd_dir = SysfsDir(get_drv_dir("idxd"))
@@ -112,6 +131,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 +142,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__":
-- 
2.31.1


  parent reply	other threads:[~2022-03-31 17:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-30 15:07 [PATCH] " Kevin Laatz
2022-03-31 14:57 ` Bruce Richardson
2022-03-31 15:47   ` Kevin Laatz
2022-03-31 17:21 ` Kevin Laatz [this message]
2022-04-01  9:08   ` [PATCH v2] " Bruce Richardson
2022-04-01 10:35   ` [PATCH v3] " Kevin Laatz
2022-04-01 10:51     ` Bruce Richardson
2022-06-07 10:47       ` Thomas Monjalon
2022-04-04  9:58     ` Pai G, Sunil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220331172112.575972-1-kevin.laatz@intel.com \
    --to=kevin.laatz@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).