From patchwork Tue Nov 30 09:54:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Radu Nicolau X-Patchwork-Id: 104778 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 09775A0C55; Tue, 30 Nov 2021 11:13:35 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 82FB14113C; Tue, 30 Nov 2021 11:13:34 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id B0F55410F7 for ; Tue, 30 Nov 2021 11:13:32 +0100 (CET) X-IronPort-AV: E=McAfee;i="6200,9189,10183"; a="236414891" X-IronPort-AV: E=Sophos;i="5.87,275,1631602800"; d="scan'208";a="236414891" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2021 02:13:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,275,1631602800"; d="scan'208";a="458780657" Received: from silpixa00400884.ir.intel.com ([10.243.22.82]) by orsmga003.jf.intel.com with ESMTP; 30 Nov 2021 02:13:30 -0800 From: Radu Nicolau To: Bruce Richardson , Kevin Laatz Cc: dev@dpdk.org, Radu Nicolau Subject: [PATCH] dma/idxd: add allow/block list support Date: Tue, 30 Nov 2021 09:54:39 +0000 Message-Id: <20211130095439.784229-1-radu.nicolau@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add support for allow or block list for devices bound to the kernel driver. When used the allow or block list applies as an additional condition to the name prefix. Signed-off-by: Radu Nicolau Reviewed-by: Bruce Richardson Acked-by: Bruce Richardson --- doc/guides/dmadevs/idxd.rst | 10 ++++++++++ drivers/dma/idxd/idxd_bus.c | 30 ++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/doc/guides/dmadevs/idxd.rst b/doc/guides/dmadevs/idxd.rst index d4a210b854..6201d4db1d 100644 --- a/doc/guides/dmadevs/idxd.rst +++ b/doc/guides/dmadevs/idxd.rst @@ -117,6 +117,16 @@ the value used as the DPDK ``--file-prefix`` parameter may be used as a workqueu name prefix, instead of ``dpdk_``, allowing each DPDK application instance to only use a subset of configured queues. +Additionally, the -a (allowlist) or -b (blocklist) commandline parameters are +also available to further restrict the device list that will be used. +If the -a option is used then any device that passes the ``dpdk_`` or +``--file-prefix`` prefix condition must also be present in the allow list. +Similarly, when the block list is used any device that passes the prefix +condition must not be in the block list. +For example, to only use ``wq0.3``, assuming the name prefix condition is met:: + + $ dpdk-test -a wq0.3 + Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``, that is a "DMA device type" inside DPDK, and can be accessed using APIs from the ``rte_dmadev`` library. diff --git a/drivers/dma/idxd/idxd_bus.c b/drivers/dma/idxd/idxd_bus.c index 08639e9dce..13cb967f6d 100644 --- a/drivers/dma/idxd/idxd_bus.c +++ b/drivers/dma/idxd/idxd_bus.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -244,8 +245,18 @@ idxd_probe_dsa(struct rte_dsa_device *dev) return 0; } +static int search_devargs(const char *name) +{ + struct rte_devargs *devargs; + RTE_EAL_DEVARGS_FOREACH(dsa_bus.bus.name, devargs) { + if (strcmp(devargs->name, name) == 0) + return 1; + } + return 0; +} + static int -is_for_this_process_use(const char *name) +is_for_this_process_use(struct rte_dsa_device *dev, const char *name) { char *runtime_dir = strdup(rte_eal_get_runtime_dir()); char *prefix = basename(runtime_dir); @@ -257,6 +268,13 @@ is_for_this_process_use(const char *name) if (strncmp(name, prefix, prefixlen) == 0 && name[prefixlen] == '_') retval = 1; + if (retval && dsa_bus.bus.conf.scan_mode != RTE_BUS_SCAN_UNDEFINED) { + if (dsa_bus.bus.conf.scan_mode == RTE_BUS_SCAN_ALLOWLIST) + retval = search_devargs(dev->device.name); + else + retval = !search_devargs(dev->device.name); + } + free(runtime_dir); return retval; } @@ -273,7 +291,8 @@ dsa_probe(void) read_wq_string(dev, "name", name, sizeof(name)) < 0) continue; - if (strncmp(type, "user", 4) == 0 && is_for_this_process_use(name)) { + if (strncmp(type, "user", 4) == 0 && + is_for_this_process_use(dev, name)) { dev->device.driver = &dsa_bus.driver; idxd_probe_dsa(dev); continue; @@ -370,8 +389,11 @@ dsa_addr_parse(const char *name, void *addr) return -1; } - wq->device_id = device_id; - wq->wq_id = wq_id; + if (wq != NULL) { + wq->device_id = device_id; + wq->wq_id = wq_id; + } + return 0; }