From patchwork Tue Jun 11 07:07:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 803237 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:e87:b0:35b:5a80:51b4 with SMTP id dz7csp169032wrb; Tue, 11 Jun 2024 00:08:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVVfouYK9LLzeB7nMp/xsqAtuMdrE5VlB6sSC6FNkZKbm8gyin4zx8F9E8ainscqQX1++6bwpEtgDejLDW8E5nW X-Google-Smtp-Source: AGHT+IHFj6QZk1wqQgGI33Gdi2Uv5+ZOO1X37T2A2t4otX5+13nN0LDZKB6zKlIyyQFijm/afrKM X-Received: by 2002:a19:ee12:0:b0:52c:8508:464d with SMTP id 2adb3069b0e04-52c850846cfmr3084735e87.55.1718089733449; Tue, 11 Jun 2024 00:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718089733; cv=none; d=google.com; s=arc-20160816; b=wshEj6JaYYfxj5iPrzT0GdckRfaTtLKqlFKSyPvmXeMJnnVRxqOLITeF2y3Bduz8aN O5lINGdSluA4BgQztZyOOzVS3NxQBoVaAgzcCY1uVXpqS0I+cWghf5PBuhdDWdcciQYu Qb7+a4n32d/8no9QG9PJuVRsLNqkbqYmKnB/XXhbWou2KyO+JGlM6UDmUiSkMbkI3bJK Z+TZHOHheWRDvcdDBfRsWJBznkYgE9L2Wg+LeDT7xEbRcJFxTnwXR+gLrKmNVQ3QuTbm xLbci5jfi0AgTBjMFiY5Bq2oAiVXv5a/4SQRP9fnPiu+HrpJEVbLab4B5LmZIyz+3QXJ mTww== 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=WnDkHryYS7OZAWuONVs5cjf1tJG4Y4FcB+r1DfivWCU=; fh=N6ystvY2g7QTpz2QKkAMt/Nu9xETjtRlVAZxgmiIO6M=; b=zvGKzfEIpVulhnado9H+sv8nNlOwx0UlHEO/k/hZqsfj4vXLOw8M2ftIhcsm65HWGG W5ACqLSR4QYuV+Ag8jVFbJd2POlSduFw1ZWaFgn1drYF1unO6P+dCopQiw+dz/80BqBk EtaQ6bdG2U4G3B9EcvOpaImsvu0mmKrKXB41oFi7LlCaPWS4JOmCwvjM5EybJlILjePF 9OZ99VCZ9IJofWOX6Vg5I+uS9QHAQUM8YO2o6K4a0P1Gi91RGx2BvCIBHnUXkPTFC3in 89LcfSH5EtVofoqfOuvJuSU28/9oI36uclE8bbJl6I5PisyjeGC9wjGMv93SR5ooiS91 sOpw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rgeXh1Pt; 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 ffacd0b85a97d-35f1b0bbb3csi3639247f8f.1004.2024.06.11.00.08.53; Tue, 11 Jun 2024 00:08:53 -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=rgeXh1Pt; 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 4D3BC4067C; Tue, 11 Jun 2024 09:08:51 +0200 (CEST) Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by mails.dpdk.org (Postfix) with ESMTP id 25119400D6 for ; Tue, 11 Jun 2024 09:08:50 +0200 (CEST) Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-656d8b346d2so3708198a12.2 for ; Tue, 11 Jun 2024 00:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718089729; x=1718694529; 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=WnDkHryYS7OZAWuONVs5cjf1tJG4Y4FcB+r1DfivWCU=; b=rgeXh1PtYNMgTbFZ+kgE/O9WNUcsKy2LVfh4oP6lxdNrAQpqFGZ3wOH07zJvL8oEjo 65cSByX78Il56ofimcaV0Axd39FUYOyyjtQ6yapXZZVlGU8HIDT+2xB2N91Vw0ExMEkN MuRK52fTe8qURodeqkzPcmulN6jOdrQ0SBs++wvDiZsnbUez/2hTi81HZdYWU90ohB+c H6cAgvlY0NE8UMKppSoZHlVfasQ/oowibk+T3i33Pq+a0v76a2ypgGmhOPFv98I/HIwZ 8XvhNsrG82N1Lro+ufVZGg/qMl6m0lVbPUzUdO3mAV5lRP2MsbCRCAG6ybZ3PSCNbgot 55bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718089729; x=1718694529; 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=WnDkHryYS7OZAWuONVs5cjf1tJG4Y4FcB+r1DfivWCU=; b=hvQjv5IxWNIIsmgIesURoF1UcdTQky1NSQksk9pZUJIySEzl0451XqtN1BZOxjaVZC CNVXiXjtfARwyfmDyJD4egLASUbWq+hH7Tnp+18c3caQQIGOmavZPxb7iW4FWjvcJdFR SaIdPA3nysjhxjeWVl1UVv6sAXXY5BjkvxRi6ovz5/hORxcXBLdTycClnGSKMUj1FFJX JlbzTqEVp8Gofqpzef4ffxWIrE0R33/S4My2NN4d7xDXUHqyC0gQJ3A7kXAiXr5MMSBB PbXs+mkNYmdQzlYG8SCrcRY6X0Imkp1oBUEPiKNOv7A4PTmdV388o7LyFZnSjjn3VTrK tBSQ== X-Gm-Message-State: AOJu0Yx09aRKODjuczQYL1zg3cBoekRR3UeCaNvseZDoeY77fk0Dczs7 QySZSsqDC2kIFYIQBuo5vnB3EnRI6hxrIoLPTyB0T2dlpQcXntitqozlvo6nHec= X-Received: by 2002:a05:6a20:3c8f:b0:1b5:e80d:2fd2 with SMTP id adf61e73a8af0-1b5e80d34a8mr5350220637.46.1718089729003; Tue, 11 Jun 2024 00:08:49 -0700 (PDT) Received: from localhost.localdomain (ec2-52-53-61-205.us-west-1.compute.amazonaws.com. [52.53.61.205]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ad947cdasm550945b3a.42.2024.06.11.00.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 00:08:48 -0700 (PDT) From: Zhangfei Gao To: Akhil Goyal , Fan Zhang , Ashish Gupta Cc: dev@dpdk.org, Zhangfei Gao Subject: [PATCH v3 1/3] compress/uadk: Introduce UADK compression driver Date: Tue, 11 Jun 2024 07:07:24 +0000 Message-Id: <20240611070726.468-2-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240611070726.468-1-zhangfei.gao@linaro.org> References: <20240611070726.468-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. [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 | 79 +++++++++++++++++++ drivers/compress/meson.build | 1 + drivers/compress/uadk/meson.build | 30 +++++++ drivers/compress/uadk/uadk_compress_pmd.c | 75 ++++++++++++++++++ .../compress/uadk/uadk_compress_pmd_private.h | 20 +++++ 8 files changed, 223 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 c9adff9846..8e541d23e5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1213,6 +1213,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..02fa3c7667 --- /dev/null +++ b/doc/guides/compressdevs/uadk.rst @@ -0,0 +1,79 @@ +.. 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 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..6ffc22a0d2 --- /dev/null +++ b/drivers/compress/uadk/uadk_compress_pmd.c @@ -0,0 +1,75 @@ +/* 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; + +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..88e9075619 --- /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 { + bool env_init; +}; + +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_ */