From patchwork Mon Apr 22 14:31:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 790963 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp2390835wrm; Mon, 22 Apr 2024 07:31:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXeunIJwpuXAfsoflrXZPv4OFLrnn12Rzugjs8mVk3lA7ohErz0I9GAPxgW6U1Mb9sEvhwu/jV/w5ZTLeonA57V X-Google-Smtp-Source: AGHT+IGBotRSueJgYgcf0Ds4nlrQpe2CZ7uNsnm3+7sGoAbj+NmfQWa2i3hvLrrfz8a0BMi5r6BS X-Received: by 2002:a05:6000:10c:b0:343:b61c:e13a with SMTP id o12-20020a056000010c00b00343b61ce13amr6733086wrx.9.1713796285323; Mon, 22 Apr 2024 07:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713796285; cv=none; d=google.com; s=arc-20160816; b=ki4SVJ8qwKgl7E8yrhayuVEOV+bvLYHDIIeUaOjBQLyVZ4sRTvpmCORvMI1EtY76U2 VH7eEPn+Yv7EA67hRf8yb9hQYWGeIS6u9/2me4ELMbGWb9XirLnQkTpTKfpToXYMnjzt Y1ZLw8zyFpuJEbGR8gmFO94TyIU+iXMuj02S9isxp3Am4460blzvUoO2YEAF3RaKO0LN 28K2KJTeAUqAosaTNqyIoFzpbqDV5r/SRNvHDnarw7LZCjRV1CZ++MW3MyuP/oMzgGjZ CMBA/kCFq3nWQk/FNtlumAqgiEX/XswhpA5pHMdByeoUs8Vi4LUQ+AkLFV4jjVkeqUa1 PS8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=j4xMt+AWey8VWm3KvQnvr2bJH8ndbonWITOXul8268w=; fh=N6ystvY2g7QTpz2QKkAMt/Nu9xETjtRlVAZxgmiIO6M=; b=iDPKaPuM5yv0qOBOIbyLKxxb75RN0BcwLlqsgaYawrGxeEdmaus9a38br/11C5joP/ YGgFJQ2D1rUPWs7bZ4bkvfDPPPpOOUmR+WG6EyLtJoEhsaZ/BfvdpGgrf2YoEx1Xzc3M hMYm+BwqHj7j5wmi7bYIizYuJYCJDerYKDW759hBWqQfBx531vva2MLyJCUSXYSOOEqS 43ufbaiRmlAJdmiF1aEu9ZNkiJBdHp4eIpuMlsaTi631iKGPKiK1Ozgepb/hA9tflbjO GRkQMmGwrLJGz85Nze3TrLvAGV0hjU7JUP6VSq183StJSmx3r5+ATwO4JL0m+KhgjG3t 3uBg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZdLH9zTI; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mails.dpdk.org (mails.dpdk.org. [217.70.189.124]) by mx.google.com with ESMTP id y16-20020adfe6d0000000b0034a2ac33bacsi4272332wrm.791.2024.04.22.07.31.25; Mon, 22 Apr 2024 07:31:25 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) client-ip=217.70.189.124; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZdLH9zTI; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EDF09402EA; Mon, 22 Apr 2024 16:31:20 +0200 (CEST) Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by mails.dpdk.org (Postfix) with ESMTP id 67C25402DE for ; Mon, 22 Apr 2024 16:31:19 +0200 (CEST) Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-5d42e7ab8a9so2693438a12.3 for ; Mon, 22 Apr 2024 07:31:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713796278; x=1714401078; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j4xMt+AWey8VWm3KvQnvr2bJH8ndbonWITOXul8268w=; b=ZdLH9zTIBQ1bshupjwU5DL6N4zp7TZj0dWIBDSKTDfUlaW1ElSCJq5UA+XAVxG6Tzl UU6PwH5FweajOmcoArHvC4QBDeG/38fjeqgyLjqn/rMlpoTnrMSFSQ0rEYb2r4Lx4nQ1 kP8HwYGAiwChCBIdsusYhYufwJcUrvPZVDnfPfY5EFr84ZzhJe3PTpzjb/VDogkznS7a tvQO308M1Ubyc6TR/cMbsPgrhhaqsGtCchWGY48wUt0hWpsTK1LCGMMyq8xy4pYAYgNZ cdV2toeKvS4Q8Uui3SrK/BhEnzMUhAgpP0NuTS5OVNUVKMK8hjxYUoMYd9Jg8psgaE5M cTQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713796278; x=1714401078; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j4xMt+AWey8VWm3KvQnvr2bJH8ndbonWITOXul8268w=; b=PUalrDO4QfD3D1wwH0Hqqlp0dUsJqkyZI9wdZi6xq9BXeNeBqcdbeFeIIRjneUXeYe Vd7YRqBLw29w2L19g94oD1ZSmJWjoSz0Z9yB1p868XLL1ZSdFyehq4wPm7TnANi32Aue KC3stKxDZu0kbSZwFtO/KYWakOfDXYaC0mDSpzhkZXXAcdZ0w3N7AV5bFiM8VDIbfpAZ fEy8b9EoS8O1Tva1nx+LYQlwcdk8n4bZLtV4nWqcPcJzOA8bhJIWFcNAX5ozPQcb2FME yF3mY2S7GSMo9Rq/K/XToRq09sp8ElKpONh7zQuyBUyh43RkRyiFZx1U8k/1gFiWM1fZ amuw== X-Gm-Message-State: AOJu0Ywyuqigjj25CgE4mRndJURMAnY+NnlJY918H4SgvzdEzFyDwS3D 3IxfS8OLmCUknx0YBkCbOL2CNafgLCfbPYgirPC4iMyrHT3LJMgeXu6RCi+Ycyw6xxETNpDHe+7 glp5jq2wr X-Received: by 2002:a17:90a:2f62:b0:2ab:a991:6eb8 with SMTP id s89-20020a17090a2f6200b002aba9916eb8mr8470782pjd.42.1713796278369; Mon, 22 Apr 2024 07:31:18 -0700 (PDT) Received: from localhost.localdomain ([121.37.54.139]) by smtp.gmail.com with ESMTPSA id v17-20020a17090ad59100b0029c19285192sm9481284pju.44.2024.04.22.07.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 07:31:17 -0700 (PDT) From: Zhangfei Gao To: Akhil Goyal , Fan Zhang , Ashish Gupta Cc: dev@dpdk.org, Zhangfei Gao Subject: [PATCH 1/3] compress/uadk: Introduce UADK compression driver Date: Mon, 22 Apr 2024 14:31:00 +0000 Message-Id: <20240422143102.251-2-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240422143102.251-1-zhangfei.gao@linaro.org> References: <20240422143102.251-1-zhangfei.gao@linaro.org> 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 Introduce a new compression & decompression PMD for hardware accelerators based on UADK [1]. UADK is a framework for user applications to access hardware accelerators. UADK relies on IOMMU SVA (Shared Virtual Address) feature, which shares the same page table between IOMMU and MMU. Thereby user application can directly use the virtual address for the device DMA, which enhances the performance as well as easy usability. This patch adds the basic framework. Test: sudo dpdk-test --vdev=compress_uadk RTE>>compressdev_autotest RTE>>quit [1] https://github.com/Linaro/uadk Signed-off-by: Zhangfei Gao --- MAINTAINERS | 6 ++ doc/guides/compressdevs/features/uadk.ini | 11 +++ doc/guides/compressdevs/index.rst | 1 + doc/guides/compressdevs/uadk.rst | 98 +++++++++++++++++++ doc/guides/rel_notes/release_24_07.rst | 5 + drivers/compress/meson.build | 1 + drivers/compress/uadk/meson.build | 30 ++++++ drivers/compress/uadk/uadk_compress_pmd.c | 89 +++++++++++++++++ .../compress/uadk/uadk_compress_pmd_private.h | 20 ++++ 9 files changed, 261 insertions(+) create mode 100644 doc/guides/compressdevs/features/uadk.ini create mode 100644 doc/guides/compressdevs/uadk.rst create mode 100644 drivers/compress/uadk/meson.build create mode 100644 drivers/compress/uadk/uadk_compress_pmd.c create mode 100644 drivers/compress/uadk/uadk_compress_pmd_private.h diff --git a/MAINTAINERS b/MAINTAINERS index 7abb3aee49..4f1f640004 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1212,6 +1212,12 @@ F: drivers/compress/octeontx/ F: doc/guides/compressdevs/octeontx.rst F: doc/guides/compressdevs/features/octeontx.ini +HiSilicon UADK compress +M: Zhangfei Gao +F: drivers/compress/uadk/ +F: doc/guides/compressdevs/uadk.rst +F: doc/guides/compressdevs/features/uadk.ini + Intel QuickAssist M: Kai Ji F: drivers/compress/qat/ diff --git a/doc/guides/compressdevs/features/uadk.ini b/doc/guides/compressdevs/features/uadk.ini new file mode 100644 index 0000000000..0bbdb6c5cf --- /dev/null +++ b/doc/guides/compressdevs/features/uadk.ini @@ -0,0 +1,11 @@ +; +; Refer to default.ini for the full list of available PMD features. +; +; Supported features of 'uadk' compression driver. +; +[Features] +HW Accelerated = Y +Deflate = Y +Crc32 = N +Fixed = Y +Dynamic = Y diff --git a/doc/guides/compressdevs/index.rst b/doc/guides/compressdevs/index.rst index 849f211688..87ed4f72a4 100644 --- a/doc/guides/compressdevs/index.rst +++ b/doc/guides/compressdevs/index.rst @@ -15,4 +15,5 @@ Compression Device Drivers nitrox octeontx qat_comp + uadk zlib diff --git a/doc/guides/compressdevs/uadk.rst b/doc/guides/compressdevs/uadk.rst new file mode 100644 index 0000000000..7e7f9f2548 --- /dev/null +++ b/doc/guides/compressdevs/uadk.rst @@ -0,0 +1,98 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright 2024-2025 Huawei Technologies Co.,Ltd. All rights reserved. + Copyright 2024-2025 Linaro ltd. + +UADK Compression Poll Mode Driver +================================= + +UADK compression PMD provides poll mode compression & decompression driver +All compression operations are using UADK library compression API, which is +algorithm-level API, abstracting accelerators' low-level implementations. + +UADK compression PMD relies on `UADK library `_. + +UADK is a framework for user applications to access hardware accelerators. +UADK relies on IOMMU SVA (Shared Virtual Address) feature, +which shares the same page table between IOMMU and MMU. +As a result, the user application can directly use the virtual address for +device DMA, which enhances performance as well as easy usability. + + +Features +-------- + +UADK compression PMD has support for: + +Compression/Decompression algorithm: + + * DEFLATE - using Fixed and Dynamic Huffman encoding + +Window size support: + + * 32K + + +Test steps +---------- + +#. Build UADK + + .. code-block:: console + + git clone https://github.com/Linaro/uadk.git + cd uadk + mkdir build + ./autogen.sh + ./configure --prefix=$PWD/build + make + make install + + .. note:: + + Without ``--prefix``, UADK will be installed to ``/usr/local/lib`` by default. + + .. note:: + + If get error: "cannot find -lnuma", please install the libnuma-dev. + +#. Run pkg-config libwd to ensure env is setup correctly + + .. code-block:: console + + export PKG_CONFIG_PATH=$PWD/build/lib/pkgconfig + pkg-config libwd --cflags --libs -I/usr/local/include -L/usr/local/lib -lwd + + .. note:: + + export ``PKG_CONFIG_PATH`` is required on demand, + not needed if UADK is installed to ``/usr/local/lib``. + +#. Build DPDK + + .. code-block:: console + + cd dpdk + mkdir build + meson setup build (--reconfigure) + cd build + ninja + sudo ninja install + +#. Prepare hugepages for DPDK (see also :doc:`../tools/hugepages`) + + .. code-block:: console + + echo 1024 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages + echo 1024 > /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages + echo 1024 > /sys/devices/system/node/node2/hugepages/hugepages-2048kB/nr_hugepages + echo 1024 > /sys/devices/system/node/node3/hugepages/hugepages-2048kB/nr_hugepages + mkdir -p /mnt/huge_2mb + mount -t hugetlbfs none /mnt/huge_2mb -o pagesize=2MB + +#. Run test app + + .. code-block:: console + + sudo dpdk-test --vdev=compress_uadk + RTE>>compressdev_autotest + RTE>>quit diff --git a/doc/guides/rel_notes/release_24_07.rst b/doc/guides/rel_notes/release_24_07.rst index a69f24cf99..a7574045f0 100644 --- a/doc/guides/rel_notes/release_24_07.rst +++ b/doc/guides/rel_notes/release_24_07.rst @@ -24,6 +24,11 @@ DPDK Release 24.07 New Features ------------ +* **Added UADK compress driver.** + + Added a new compress driver for the UADK library. See the + :doc:`../compressdevs/uadk` guide for more details on this new driver. + .. This section should contain new features added in this release. Sample format: diff --git a/drivers/compress/meson.build b/drivers/compress/meson.build index b91195b27d..91d7800a4a 100644 --- a/drivers/compress/meson.build +++ b/drivers/compress/meson.build @@ -10,6 +10,7 @@ drivers = [ 'mlx5', 'nitrox', 'octeontx', + 'uadk', 'zlib', ] diff --git a/drivers/compress/uadk/meson.build b/drivers/compress/uadk/meson.build new file mode 100644 index 0000000000..704833bbcf --- /dev/null +++ b/drivers/compress/uadk/meson.build @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2024-2025 Huawei Technologies Co.,Ltd. All rights reserved. +# Copyright 2024-2025 Linaro ltd. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +sources = files( + 'uadk_compress_pmd.c', +) + +deps += 'bus_vdev' +dep = dependency('libwd_comp', required: false, method: 'pkg-config') +if not dep.found() + build = false + reason = 'missing dependency, "libwd_comp"' +else + ext_deps += dep +endif + +dep = dependency('libwd', required: false, method: 'pkg-config') +if not dep.found() + build = false + reason = 'missing dependency, "libwd"' +else + ext_deps += dep +endif diff --git a/drivers/compress/uadk/uadk_compress_pmd.c b/drivers/compress/uadk/uadk_compress_pmd.c new file mode 100644 index 0000000000..d73524ce84 --- /dev/null +++ b/drivers/compress/uadk/uadk_compress_pmd.c @@ -0,0 +1,89 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2024-2025 Huawei Technologies Co.,Ltd. All rights reserved. + * Copyright 2024-2025 Linaro ltd. + */ + +#include +#include +#include + +#include +#include + +#include "uadk_compress_pmd_private.h" + +static struct rte_compressdev_ops uadk_compress_pmd_ops = { + .dev_configure = NULL, + .dev_start = NULL, + .dev_stop = NULL, + .dev_close = NULL, + .stats_get = NULL, + .stats_reset = NULL, + .dev_infos_get = NULL, + .queue_pair_setup = NULL, + .queue_pair_release = NULL, + .private_xform_create = NULL, + .private_xform_free = NULL, + .stream_create = NULL, + .stream_free = NULL, +}; + +static int +uadk_compress_probe(struct rte_vdev_device *vdev) +{ + struct rte_compressdev_pmd_init_params init_params = { + "", + rte_socket_id(), + }; + struct rte_compressdev *compressdev; + struct uacce_dev *udev; + const char *name; + + udev = wd_get_accel_dev("deflate"); + if (!udev) + return -ENODEV; + + name = rte_vdev_device_name(vdev); + if (name == NULL) + return -EINVAL; + + compressdev = rte_compressdev_pmd_create(name, &vdev->device, + sizeof(struct uadk_compress_priv), &init_params); + if (compressdev == NULL) { + UADK_LOG(ERR, "driver %s: create failed", init_params.name); + return -ENODEV; + } + + compressdev->dev_ops = &uadk_compress_pmd_ops; + compressdev->dequeue_burst = NULL; + compressdev->enqueue_burst = NULL; + compressdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED; + + return 0; +} + +static int +uadk_compress_remove(struct rte_vdev_device *vdev) +{ + struct rte_compressdev *compressdev; + const char *name; + + name = rte_vdev_device_name(vdev); + if (name == NULL) + return -EINVAL; + + compressdev = rte_compressdev_pmd_get_named_dev(name); + if (compressdev == NULL) + return -ENODEV; + + return rte_compressdev_pmd_destroy(compressdev); +} + +static struct rte_vdev_driver uadk_compress_pmd = { + .probe = uadk_compress_probe, + .remove = uadk_compress_remove, +}; + +#define UADK_COMPRESS_DRIVER_NAME compress_uadk +RTE_PMD_REGISTER_VDEV(UADK_COMPRESS_DRIVER_NAME, uadk_compress_pmd); +RTE_LOG_REGISTER_DEFAULT(uadk_compress_logtype, INFO); diff --git a/drivers/compress/uadk/uadk_compress_pmd_private.h b/drivers/compress/uadk/uadk_compress_pmd_private.h new file mode 100644 index 0000000000..a96aea7c73 --- /dev/null +++ b/drivers/compress/uadk/uadk_compress_pmd_private.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2024-2025 Huawei Technologies Co.,Ltd. All rights reserved. + * Copyright 2024-2025 Linaro ltd. + */ + +#ifndef _UADK_COMPRESS_PMD_PRIVATE_H_ +#define _UADK_COMPRESS_PMD_PRIVATE_H_ + +struct uadk_compress_priv { + struct rte_mempool *mp; +}; + +extern int uadk_compress_logtype; + +#define UADK_LOG(level, fmt, ...) \ + rte_log(RTE_LOG_ ## level, uadk_compress_logtype, \ + "%s() line %u: " fmt "\n", __func__, __LINE__, \ + ## __VA_ARGS__) + +#endif /* _UADK_COMPRESS_PMD_PRIVATE_H_ */ From patchwork Mon Apr 22 14:31:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 790964 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp2390912wrm; Mon, 22 Apr 2024 07:31:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUwg8R9JfDtTtRzSE5/Sj+3l+t8ZHb4/qOL9pqwuMXatR/VzoUAijFHcO7teA28pmDtl4F23FQolGOq4pzJjWtd X-Google-Smtp-Source: AGHT+IGCtYWpv99OFBxXxCl9NHfutp/bPlyxRn+ckjFD6KclS4VyoVccIam7HPbAudlgVxExqsB4 X-Received: by 2002:a05:651c:223:b0:2d6:f7d4:a393 with SMTP id z3-20020a05651c022300b002d6f7d4a393mr5711514ljn.9.1713796292601; Mon, 22 Apr 2024 07:31:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713796292; cv=none; d=google.com; s=arc-20160816; b=wg7JZSEMsI4kVBdDEmYYqtALaf27mQ+6la5TAvdU3PZKPrSvAST4LINGxFXPJ9m3YT Vy02hNg4POyXbhxM2XoaHYrXgRO+45lC9hdYXRirVFrdSDm7El2gtEZPcEh2Qlwcbtk+ QTQWHda2QQBPldUFcxDz7Jx5rQSEyYC9b7aBOg6o/PBxoZ8itW7h8D4usry2KmWb3j/p LB4ZC+HO0LpmT2FS32Zo7zljj8sLAtzrUKdXfPJMlMw+N3vM91uaF8MsjkxSpgvRbph2 vCeo6Ok33NrWZFpVgZlMpt1ieH7Eudx4DWZ6sYYu9ifLtg6b0eITOwHiPLLowtKo6Cxg jXbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wSOE5wNtNhcmzGDyBKj5myVPivsEg4c2BjxALL+8p8M=; fh=N6ystvY2g7QTpz2QKkAMt/Nu9xETjtRlVAZxgmiIO6M=; b=Nb6IT9NNCnlXHfzJEc59OnxiBuANR6PO2/Z9IOJUKtvD07puMDXanFTHlC2X8XYb8u 1lI5Fn0bwLliIomHHtpTAGn2bymBdMyvS4YfjbuUadQ/5+se5X5GvjkhCvx12mIC2nzB bjQ5JM2mrLrYbxP7DW5v0dObhH1kdaVW71xFAcoYdvK3+lJMDd0MdGLtvBdbyqB4K+LX /8jg/ZtWjRKu77V8DOW2jS7o8F4UZStGv6KHU+vRgrvfebwiA3tdyXpX872qQSyGJoHO Iy9Ge0Ajd3JG4y+puLzI9RMHVPoCcJmw0f9DQJ+efBlOd/ePDz1xFLyLk/FDMV1wu75/ tTsA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XMyRwOJH; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mails.dpdk.org (mails.dpdk.org. [217.70.189.124]) by mx.google.com with ESMTP id b7-20020a05600c4e0700b0041a77b2ce19si730872wmq.5.2024.04.22.07.31.32; Mon, 22 Apr 2024 07:31:32 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) client-ip=217.70.189.124; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XMyRwOJH; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 36C9B40633; Mon, 22 Apr 2024 16:31:23 +0200 (CEST) Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by mails.dpdk.org (Postfix) with ESMTP id 2B888402F0 for ; Mon, 22 Apr 2024 16:31:21 +0200 (CEST) Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-5c66b093b86so3810492a12.0 for ; Mon, 22 Apr 2024 07:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713796280; x=1714401080; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wSOE5wNtNhcmzGDyBKj5myVPivsEg4c2BjxALL+8p8M=; b=XMyRwOJHnxS68dR2TszNbuxTjT1nn6eFtHQKOC3l08YjQ1LNgBappnhbXxIiDqPv4r Qzs7s+VUyBVknoLvXxsBkvd2iUIbLsN6rpaHPOV8FoMxXWfQCO+QLj/pVrXgnpOIYJEz 9EMf12biXsApKbOJXSTDalhj6P1HcwKFTmYwL3unI1pzlvttVSf7Wyr3jwGdZEUoXEDQ sF1zzWnNhAwmqupROHRky/pan1LPOv58AY8wmRPUJQVYRTpGBfmlxn/N1AUzgbjX3o/D cDJLDrVoiksXaxeBSVDhu9QWNzZWwmNbRZit4qL5b9Ah8LozQwiRJB47JU8OEWZuq+qU pWDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713796280; x=1714401080; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wSOE5wNtNhcmzGDyBKj5myVPivsEg4c2BjxALL+8p8M=; b=cwIaUQFoqTgylN1hJTIbN+HYkDxqoTzrRiganmFWG7fx2vWAOa7sSLXlHQPeZWs5d2 fBKdqmKQK2CuVjtlJyPdBMsc/aYnchj5CoFUcTJgXVG/YG6opi/CxBP40T9Dkds2xKm9 stdF00c5gcVTmcmVInctI9A4xiVFnGQIzoAogLjN3N9dHlfLHOd/VmMIP+Ve2mdELmjs FSlPEu/owcb0fYt7APOfSKp6L6ig9oJQhmnTWq9Z+P+Pevt2iCSIWmAKuw8XtFuarQBi YSaHhpn8ZkVLeqvmfxqjvKwZ2Ot99AiTyBwWZBC+8tfwGfKq4WK3larptXFJqCPLg7LM 5r/w== X-Gm-Message-State: AOJu0Yw9+DpfGbW6p1X882cDmHpjeudoSN5XvltSA8fLgElNaXW1n/gk revWCiByaDbn3Bm6AJMhUUlq5BK3p91t833mVBIs8JZtm7KFczFti/qO7OnHisM= X-Received: by 2002:a17:90a:2ca5:b0:2a2:6244:32b5 with SMTP id n34-20020a17090a2ca500b002a2624432b5mr13952678pjd.11.1713796280319; Mon, 22 Apr 2024 07:31:20 -0700 (PDT) Received: from localhost.localdomain ([121.37.54.139]) by smtp.gmail.com with ESMTPSA id v17-20020a17090ad59100b0029c19285192sm9481284pju.44.2024.04.22.07.31.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 07:31:19 -0700 (PDT) From: Zhangfei Gao To: Akhil Goyal , Fan Zhang , Ashish Gupta Cc: dev@dpdk.org, Zhangfei Gao Subject: [PATCH 2/3] compress/uadk: support basic operations Date: Mon, 22 Apr 2024 14:31:01 +0000 Message-Id: <20240422143102.251-3-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240422143102.251-1-zhangfei.gao@linaro.org> References: <20240422143102.251-1-zhangfei.gao@linaro.org> 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 Support the basic dev control operations: configure, close, start, stop, infos_get, and queue pairs operations, etc. Signed-off-by: Zhangfei Gao --- drivers/compress/uadk/uadk_compress_pmd.c | 325 +++++++++++++++++- .../compress/uadk/uadk_compress_pmd_private.h | 16 + 2 files changed, 330 insertions(+), 11 deletions(-) diff --git a/drivers/compress/uadk/uadk_compress_pmd.c b/drivers/compress/uadk/uadk_compress_pmd.c index d73524ce84..25858855e6 100644 --- a/drivers/compress/uadk/uadk_compress_pmd.c +++ b/drivers/compress/uadk/uadk_compress_pmd.c @@ -12,18 +12,321 @@ #include "uadk_compress_pmd_private.h" +static const struct +rte_compressdev_capabilities uadk_compress_pmd_capabilities[] = { + { /* Deflate */ + .algo = RTE_COMP_ALGO_DEFLATE, + .comp_feature_flags = RTE_COMP_FF_SHAREABLE_PRIV_XFORM | + RTE_COMP_FF_HUFFMAN_FIXED | + RTE_COMP_FF_HUFFMAN_DYNAMIC, + }, + + RTE_COMP_END_OF_CAPABILITIES_LIST() +}; + +static int +uadk_compress_pmd_config(struct rte_compressdev *dev, + struct rte_compressdev_config *config) +{ + char mp_name[RTE_MEMPOOL_NAMESIZE]; + struct uadk_compress_priv *priv; + struct rte_mempool *mp; + int ret; + + if (dev == NULL || config == NULL) + return -EINVAL; + + snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, + "stream_mp_%u", dev->data->dev_id); + priv = dev->data->dev_private; + + /* alloc resources */ + ret = wd_comp_env_init(NULL); + if (ret < 0) + return -EINVAL; + + mp = priv->mp; + if (mp == NULL) { + mp = rte_mempool_create(mp_name, + config->max_nb_priv_xforms + + config->max_nb_streams, + sizeof(struct uadk_stream), + 0, 0, NULL, NULL, NULL, + NULL, config->socket_id, 0); + if (mp == NULL) { + UADK_LOG(ERR, "Cannot create private xform pool on socket %d\n", + config->socket_id); + ret = -ENOMEM; + goto err_mempool; + } + priv->mp = mp; + } + + return 0; + +err_mempool: + wd_comp_env_uninit(); + return ret; +} + +static int +uadk_compress_pmd_start(struct rte_compressdev *dev __rte_unused) +{ + return 0; +} + +static void +uadk_compress_pmd_stop(struct rte_compressdev *dev __rte_unused) +{ +} + +static int +uadk_compress_pmd_close(struct rte_compressdev *dev) +{ + struct uadk_compress_priv *priv = + (struct uadk_compress_priv *)dev->data->dev_private; + + /* free resources */ + rte_mempool_free(priv->mp); + priv->mp = NULL; + wd_comp_env_uninit(); + + return 0; +} + +static void +uadk_compress_pmd_stats_get(struct rte_compressdev *dev, + struct rte_compressdev_stats *stats) +{ + int qp_id; + + for (qp_id = 0; qp_id < dev->data->nb_queue_pairs; qp_id++) { + struct uadk_qp *qp = dev->data->queue_pairs[qp_id]; + + stats->enqueued_count += qp->qp_stats.enqueued_count; + stats->dequeued_count += qp->qp_stats.dequeued_count; + stats->enqueue_err_count += qp->qp_stats.enqueue_err_count; + stats->dequeue_err_count += qp->qp_stats.dequeue_err_count; + } +} + +static void +uadk_compress_pmd_stats_reset(struct rte_compressdev *dev) +{ + int qp_id; + + for (qp_id = 0; qp_id < dev->data->nb_queue_pairs; qp_id++) { + struct uadk_qp *qp = dev->data->queue_pairs[qp_id]; + + memset(&qp->qp_stats, 0, sizeof(qp->qp_stats)); + } +} + +static void +uadk_compress_pmd_info_get(struct rte_compressdev *dev, + struct rte_compressdev_info *dev_info) +{ + if (dev_info != NULL) { + dev_info->driver_name = dev->device->driver->name; + dev_info->feature_flags = dev->feature_flags; + dev_info->capabilities = uadk_compress_pmd_capabilities; + } +} + +static int +uadk_compress_pmd_qp_release(struct rte_compressdev *dev, uint16_t qp_id) +{ + struct uadk_qp *qp = dev->data->queue_pairs[qp_id]; + + if (qp != NULL) { + rte_ring_free(qp->processed_pkts); + rte_free(qp); + dev->data->queue_pairs[qp_id] = NULL; + } + + return 0; +} + +static int +uadk_pmd_qp_set_unique_name(struct rte_compressdev *dev, + struct uadk_qp *qp) +{ + unsigned int n = snprintf(qp->name, sizeof(qp->name), + "uadk_pmd_%u_qp_%u", + dev->data->dev_id, qp->id); + + if (n >= sizeof(qp->name)) + return -EINVAL; + + return 0; +} + +static struct rte_ring * +uadk_pmd_qp_create_processed_pkts_ring(struct uadk_qp *qp, + unsigned int ring_size, int socket_id) +{ + struct rte_ring *r = qp->processed_pkts; + + if (r) { + if (rte_ring_get_size(r) >= ring_size) { + UADK_LOG(INFO, "Reusing existing ring %s for processed packets", + qp->name); + return r; + } + + UADK_LOG(ERR, "Unable to reuse existing ring %s for processed packets", + qp->name); + return NULL; + } + + return rte_ring_create(qp->name, ring_size, socket_id, + RING_F_EXACT_SZ); +} + +static int +uadk_compress_pmd_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, + uint32_t max_inflight_ops, int socket_id) +{ + struct uadk_qp *qp = NULL; + + /* Free memory prior to re-allocation if needed. */ + if (dev->data->queue_pairs[qp_id] != NULL) + uadk_compress_pmd_qp_release(dev, qp_id); + + /* Allocate the queue pair data structure. */ + qp = rte_zmalloc_socket("uadk PMD Queue Pair", sizeof(*qp), + RTE_CACHE_LINE_SIZE, socket_id); + if (qp == NULL) + return (-ENOMEM); + + qp->id = qp_id; + dev->data->queue_pairs[qp_id] = qp; + + if (uadk_pmd_qp_set_unique_name(dev, qp)) + goto qp_setup_cleanup; + + qp->processed_pkts = uadk_pmd_qp_create_processed_pkts_ring(qp, + max_inflight_ops, socket_id); + if (qp->processed_pkts == NULL) + goto qp_setup_cleanup; + + memset(&qp->qp_stats, 0, sizeof(qp->qp_stats)); + + return 0; + +qp_setup_cleanup: + if (qp) { + rte_free(qp); + qp = NULL; + } + return -EINVAL; +} + +static int +uadk_compress_pmd_xform_create(struct rte_compressdev *dev, + const struct rte_comp_xform *xform, + void **private_xform) +{ + struct uadk_compress_priv *priv = dev->data->dev_private; + struct wd_comp_sess_setup setup = {0}; + struct sched_params param = {0}; + struct uadk_stream *stream; + handle_t handle; + + if (xform == NULL) { + UADK_LOG(ERR, "invalid xform struct"); + return -EINVAL; + } + + if (rte_mempool_get(priv->mp, private_xform)) { + UADK_LOG(ERR, "Couldn't get object from session mempool"); + return -ENOMEM; + } + + stream = *((struct uadk_stream **)private_xform); + + switch (xform->type) { + case RTE_COMP_COMPRESS: + switch (xform->compress.algo) { + case RTE_COMP_ALGO_NULL: + break; + case RTE_COMP_ALGO_DEFLATE: + setup.alg_type = WD_DEFLATE; + setup.win_sz = WD_COMP_WS_8K; + setup.comp_lv = WD_COMP_L8; + setup.op_type = WD_DIR_COMPRESS; + param.type = setup.op_type; + param.numa_id = -1; /* choose nearby numa node */ + setup.sched_param = ¶m; + break; + default: + goto err; + } + break; + case RTE_COMP_DECOMPRESS: + switch (xform->decompress.algo) { + case RTE_COMP_ALGO_NULL: + break; + case RTE_COMP_ALGO_DEFLATE: + setup.alg_type = WD_DEFLATE; + setup.comp_lv = WD_COMP_L8; + setup.op_type = WD_DIR_DECOMPRESS; + param.type = setup.op_type; + param.numa_id = -1; /* choose nearby numa node */ + setup.sched_param = ¶m; + break; + default: + goto err; + } + break; + default: + UADK_LOG(ERR, "Algorithm %u is not supported.", xform->type); + goto err; + } + + handle = wd_comp_alloc_sess(&setup); + if (!handle) + goto err; + + stream->handle = handle; + stream->type = xform->type; + + return 0; + +err: + rte_mempool_put(priv->mp, private_xform); + return -EINVAL; +} + +static int +uadk_compress_pmd_xform_free(struct rte_compressdev *dev __rte_unused, void *private_xform) +{ + struct uadk_stream *stream = (struct uadk_stream *)private_xform; + struct rte_mempool *mp; + + if (!stream) + return -EINVAL; + + wd_comp_free_sess(stream->handle); + memset(stream, 0, sizeof(struct uadk_stream)); + mp = rte_mempool_from_obj(stream); + rte_mempool_put(mp, stream); + + return 0; +} + static struct rte_compressdev_ops uadk_compress_pmd_ops = { - .dev_configure = NULL, - .dev_start = NULL, - .dev_stop = NULL, - .dev_close = NULL, - .stats_get = NULL, - .stats_reset = NULL, - .dev_infos_get = NULL, - .queue_pair_setup = NULL, - .queue_pair_release = NULL, - .private_xform_create = NULL, - .private_xform_free = NULL, + .dev_configure = uadk_compress_pmd_config, + .dev_start = uadk_compress_pmd_start, + .dev_stop = uadk_compress_pmd_stop, + .dev_close = uadk_compress_pmd_close, + .stats_get = uadk_compress_pmd_stats_get, + .stats_reset = uadk_compress_pmd_stats_reset, + .dev_infos_get = uadk_compress_pmd_info_get, + .queue_pair_setup = uadk_compress_pmd_qp_setup, + .queue_pair_release = uadk_compress_pmd_qp_release, + .private_xform_create = uadk_compress_pmd_xform_create, + .private_xform_free = uadk_compress_pmd_xform_free, .stream_create = NULL, .stream_free = NULL, }; diff --git a/drivers/compress/uadk/uadk_compress_pmd_private.h b/drivers/compress/uadk/uadk_compress_pmd_private.h index a96aea7c73..97a921316e 100644 --- a/drivers/compress/uadk/uadk_compress_pmd_private.h +++ b/drivers/compress/uadk/uadk_compress_pmd_private.h @@ -10,6 +10,22 @@ struct uadk_compress_priv { struct rte_mempool *mp; }; +struct __rte_cache_aligned uadk_qp { + /* Ring for placing process packets */ + struct rte_ring *processed_pkts; + /* Queue pair statistics */ + struct rte_compressdev_stats qp_stats; + /* Queue Pair Identifier */ + uint16_t id; + /* Unique Queue Pair Name */ + char name[RTE_COMPRESSDEV_NAME_MAX_LEN]; +}; + +struct __rte_cache_aligned uadk_stream { + handle_t handle; + enum rte_comp_xform_type type; +}; + extern int uadk_compress_logtype; #define UADK_LOG(level, fmt, ...) \ From patchwork Mon Apr 22 14:31:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 790965 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp2390974wrm; Mon, 22 Apr 2024 07:31:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXhsxVZNHaKXoEOOgeZGT91NFkD9RFiIyhcedesElnVhIioN19U1vfsLYAQETKVNmGRTCd5zSAMpfovsSo/9rxO X-Google-Smtp-Source: AGHT+IEgpksunvMKSml5/jfOJ6L9rCdCVL/bCpjOgXVLoCx7Qd5T3tfOiSh0/SDGLezi3/XJr+UN X-Received: by 2002:a5d:4d4b:0:b0:34a:9b75:cb95 with SMTP id a11-20020a5d4d4b000000b0034a9b75cb95mr4266433wru.37.1713796301898; Mon, 22 Apr 2024 07:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713796301; cv=none; d=google.com; s=arc-20160816; b=lfRC5xz+uIe/uoI8k9ajy8habk4USTkRU3/uxoghGFBH36A+QrtKW79A7JRwaOc4qy 3aPnWvvTfqlki05m2O7OkuCrkPZS0dniUAqtiX/0m1lyhi0OK7GqpZg2BUcTi+m+39o9 yVvZYJdgbL0ayUPLE07TM5JAzqdDO0vLgensf3stOwvQ6IO0ZFFrxosJf4YGWsGTx+D8 8xG6a0ZMEY4wcPwSpNqrWCsilo5p3NNZHMArwSPWpyORAlwDFgDCp9rW3279cmg0Cs2R CRUndfJx3xEGJLWYYXbctjCxb/rNKMt3wZmnFOlFfvRXOz8qi8e008+/l+X5Ji/mGQgK ORUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Bke7GsIMNdY53LfN2ieTrVMGxeO10Vi7ref4oetuTNQ=; fh=N6ystvY2g7QTpz2QKkAMt/Nu9xETjtRlVAZxgmiIO6M=; b=bfNPnTHwucjq0mtTGkpscK5XhOfSstUl993j0Pu37zSLmAi7EFqzYFzapGLY8Ahkwl hJn3m/A+g4pEz09BHCN7Z2imRJOnBABzN1pk7SnB2yisI9dSLBbUOvbAbP8melbDS8eV wMS4LLwUzGK+Pu5jmwm2qBvL3opUL19+gknsbGjxWBh2DgO1T88URW5agapGp644xKbe eL2HBajkDx3difnMYjK5pk19+Mj4lGaGQW8OCh7U7030WT3CtN4h632tm60dBm1ZtBKg sIwb/phdFS61qgd6hB+ogZ8zSwAmeRbUN2tTokvN7Id/9mZILm4Qmb17rX7gsQ3+bLxd UcBw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q1eBOl4d; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mails.dpdk.org (mails.dpdk.org. [217.70.189.124]) by mx.google.com with ESMTP id j9-20020adfe509000000b0033cdf3e881csi4789760wrm.1039.2024.04.22.07.31.41; Mon, 22 Apr 2024 07:31:41 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) client-ip=217.70.189.124; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q1eBOl4d; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3E3A040696; Mon, 22 Apr 2024 16:31:25 +0200 (CEST) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by mails.dpdk.org (Postfix) with ESMTP id 79F8F40648 for ; Mon, 22 Apr 2024 16:31:23 +0200 (CEST) Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-2a53b331400so2865740a91.1 for ; Mon, 22 Apr 2024 07:31:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713796283; x=1714401083; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Bke7GsIMNdY53LfN2ieTrVMGxeO10Vi7ref4oetuTNQ=; b=q1eBOl4dyq9bw/o6Vcxypf/aROBdlUZONFSe2uMZC8AhxpiA2faowg+df259LsBDOl d0+/M/ETWMP1K/9umFkKzWnoN/BlJx/4LYi+8JtNXqQd5VYDRi1QiIVDuyawuzhHslds 6+CW+Gi/KEdt3MlttRyLGh5VJb+Qw0Op/SBoN8167qtBBxoJk0gyu11t/Ve4KyYtXmJM xCXoov60fZNrLbGRgU3qxR4oSRN+Ky0/0oEdl7fbE7PBZJoViUwmdszu31uiDDsHw4P7 KE6lRHav+zk44PGqtDtp3mi7aE54NSImqPhcW3qVtexmfi40YJP/gds2dRy2T5hjfXPV 4fVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713796283; x=1714401083; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bke7GsIMNdY53LfN2ieTrVMGxeO10Vi7ref4oetuTNQ=; b=SH5Vds8/IlN9IOcGsxAHmu93HAID4wWAf6bt6sM9FoSoybymaUYgVYXyiH8/FebIjc Rq14ZWQLsbNb1W6eqONAUVJSusLGBBcNIKkr3oPc/5N08JwnUGHYQDspTNS+WChYZ5Hh kzh6fMw+tQf3U2CF6aeCGNaARwrKe9cophr6oAwLjFkWcCgS/19jSLQsVnN0FGi8wISu JEu6Ez2+gpj6lXxnsB9eJXlG4PzGuq5y1IltNC4brnQkbposzoaSuN4C3RrkZwFu0Pzl 9cj5DT3S4M1Izq14DHeWFrm0RQ0FOzvXMBazECaQTDGpzPavZ9wGFDTHfRxF44hrcUau zhSQ== X-Gm-Message-State: AOJu0YzoJp3PR+wn73rtsABLftSwzSxcL5ct827b7F1GJVWgcKSY3Oie zPKkaNcHqPq5bUsaY6cgmQ9xZWyvWFa2xrrWdmSgFSH1xI7tRTiCLlzKmIGq/TY= X-Received: by 2002:a17:90a:5d04:b0:2a0:4c3b:2c39 with SMTP id s4-20020a17090a5d0400b002a04c3b2c39mr9829014pji.23.1713796282666; Mon, 22 Apr 2024 07:31:22 -0700 (PDT) Received: from localhost.localdomain ([121.37.54.139]) by smtp.gmail.com with ESMTPSA id v17-20020a17090ad59100b0029c19285192sm9481284pju.44.2024.04.22.07.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 07:31:22 -0700 (PDT) From: Zhangfei Gao To: Akhil Goyal , Fan Zhang , Ashish Gupta Cc: dev@dpdk.org, Zhangfei Gao Subject: [PATCH 3/3] compress/uadk: support burst enqueue/dequeue Date: Mon, 22 Apr 2024 14:31:02 +0000 Message-Id: <20240422143102.251-4-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240422143102.251-1-zhangfei.gao@linaro.org> References: <20240422143102.251-1-zhangfei.gao@linaro.org> 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 This commit adds the burst enqueue and dequeue operations. Signed-off-by: Zhangfei Gao --- drivers/compress/uadk/uadk_compress_pmd.c | 88 ++++++++++++++++++++++- 1 file changed, 86 insertions(+), 2 deletions(-) diff --git a/drivers/compress/uadk/uadk_compress_pmd.c b/drivers/compress/uadk/uadk_compress_pmd.c index 25858855e6..312aa5c744 100644 --- a/drivers/compress/uadk/uadk_compress_pmd.c +++ b/drivers/compress/uadk/uadk_compress_pmd.c @@ -331,6 +331,90 @@ static struct rte_compressdev_ops uadk_compress_pmd_ops = { .stream_free = NULL, }; +static uint16_t +uadk_compress_pmd_enqueue_burst_sync(void *queue_pair, + struct rte_comp_op **ops, uint16_t nb_ops) +{ + struct uadk_qp *qp = queue_pair; + struct uadk_stream *stream; + struct rte_comp_op *op; + uint16_t enqd = 0; + int i, ret = 0; + + for (i = 0; i < nb_ops; i++) { + op = ops[i]; + + if (op->op_type == RTE_COMP_OP_STATEFUL) { + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + } else { + /* process stateless ops */ + stream = (struct uadk_stream *)op->private_xform; + if (stream) { + struct wd_comp_req req = {0}; + uint16_t dst_len = rte_pktmbuf_data_len(op->m_dst); + + req.src = rte_pktmbuf_mtod(op->m_src, uint8_t *); + req.src_len = op->src.length; + req.dst = rte_pktmbuf_mtod(op->m_dst, uint8_t *); + req.dst_len = dst_len; + req.op_type = (enum wd_comp_op_type)stream->type; + req.cb = NULL; + req.data_fmt = WD_FLAT_BUF; + do { + ret = wd_do_comp_sync(stream->handle, &req); + } while (ret == -WD_EBUSY); + + op->consumed += req.src_len; + + if (req.dst_len <= dst_len) { + op->produced += req.dst_len; + op->status = RTE_COMP_OP_STATUS_SUCCESS; + } else { + op->status = RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED; + } + + if (ret) { + op->status = RTE_COMP_OP_STATUS_ERROR; + break; + } + } else { + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + } + } + + /* Whatever is out of op, put it into completion queue with + * its status + */ + if (!ret) + ret = rte_ring_enqueue(qp->processed_pkts, (void *)op); + + if (unlikely(ret)) { + /* increment count if failed to enqueue op */ + qp->qp_stats.enqueue_err_count++; + } else { + qp->qp_stats.enqueued_count++; + enqd++; + } + } + + return enqd; +} + +static uint16_t +uadk_compress_pmd_dequeue_burst_sync(void *queue_pair, + struct rte_comp_op **ops, + uint16_t nb_ops) +{ + struct uadk_qp *qp = queue_pair; + unsigned int nb_dequeued = 0; + + nb_dequeued = rte_ring_dequeue_burst(qp->processed_pkts, + (void **)ops, nb_ops, NULL); + qp->qp_stats.dequeued_count += nb_dequeued; + + return nb_dequeued; +} + static int uadk_compress_probe(struct rte_vdev_device *vdev) { @@ -358,8 +442,8 @@ uadk_compress_probe(struct rte_vdev_device *vdev) } compressdev->dev_ops = &uadk_compress_pmd_ops; - compressdev->dequeue_burst = NULL; - compressdev->enqueue_burst = NULL; + compressdev->dequeue_burst = uadk_compress_pmd_dequeue_burst_sync; + compressdev->enqueue_burst = uadk_compress_pmd_enqueue_burst_sync; compressdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED; return 0;