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 2E363A050D;
	Wed, 30 Mar 2022 17:06:38 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 1ED5440685;
	Wed, 30 Mar 2022 17:06:38 +0200 (CEST)
Received: from mga06.intel.com (mga06.intel.com [134.134.136.31])
 by mails.dpdk.org (Postfix) with ESMTP id 1DFC14003C
 for <dev@dpdk.org>; Wed, 30 Mar 2022 17:06:35 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1648652796; x=1680188796;
 h=from:to:cc:subject:date:message-id:mime-version:
 content-transfer-encoding;
 bh=+yeUfBYw1Cg3Gl6cHOtBMJs5CEZhNOt+UsrzKkgXUYM=;
 b=UMuWJ2EO7dWa8nFci2GBPIeymRBs2lGTVqmdwMc1b3+MYPgZiz4HAUgR
 UnRhnKfLyPK2nCf7NWobLXCyO7hI/rHC4r6LcklX3RjVcjWVtKFX8vCi1
 w9IsS75kqdW+TnqOjLKm0hZtpSvpoEnu3YXmW934RPwgXWBJXBx5fTRX6
 MDn4FqGq1fGzyAOOALxRPlI5b2HQQ6Jf79RrnV7O3QxHOcttKDVrScdJ4
 isj0ydtFuOBpD0QZkTnJRqteh3bt/2IvF34kuMgzdex8wNgQy2RKJWzUR
 nsYHFfMVfyDUPWJB/veHX43t1SD/Wc+eG+522kB7EUTLhOsqzI34+/HKY Q==;
X-IronPort-AV: E=McAfee;i="6200,9189,10301"; a="320264379"
X-IronPort-AV: E=Sophos;i="5.90,222,1643702400"; d="scan'208";a="320264379"
Received: from orsmga002.jf.intel.com ([10.7.209.21])
 by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 30 Mar 2022 08:06:35 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.90,222,1643702400"; d="scan'208";a="519711361"
Received: from silpixa00401122.ir.intel.com ([10.55.128.10])
 by orsmga002.jf.intel.com with ESMTP; 30 Mar 2022 08:06:34 -0700
From: Kevin Laatz <kevin.laatz@intel.com>
To: dev@dpdk.org
Cc: bruce.richardson@intel.com,
	Kevin Laatz <kevin.laatz@intel.com>
Subject: [PATCH] dma/idxd: add generic option for queue config
Date: Wed, 30 Mar 2022 16:07:00 +0100
Message-Id: <20220330150700.435875-1-kevin.laatz@intel.com>
X-Mailer: git-send-email 2.31.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
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

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)
+
     # 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__":
-- 
2.31.1