From patchwork Sat May 25 14:07:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 798941 Delivered-To: patch@linaro.org Received: by 2002:a5d:6a47:0:b0:354:fb4b:99cd with SMTP id t7csp1156837wrw; Sat, 25 May 2024 07:08:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXQaxel5lxkAJ9aX9cWjy+Cy22jmyZyZoVnYgpK0WD/zgCjWotxcT8+f+/nsFG4kkaD42XnOgV+vgtEy8SDI+Yx X-Google-Smtp-Source: AGHT+IF2HCKTuzLSDwiX91cgMRVIwsgSE46MhdJ3HHZUCNyujO5zIbeSnxXoqmU7kPJql3C3DWjo X-Received: by 2002:a05:651c:201d:b0:2e5:6958:b5de with SMTP id 38308e7fff4ca-2e95b09af62mr29394421fa.21.1716646092329; Sat, 25 May 2024 07:08:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716646092; cv=none; d=google.com; s=arc-20160816; b=aPANq269cR/xJ+wEWm3hr5U5g9hBRa1SMGfRWY6TjFTENEdXSGtwEgp8vcNUgOwt8S krIsnjX7oK8IrYIVP+BQyv3F+T/Vmux3YEIIkMuI+l5GeOQ9gT33kMz4DehmXinXhuOx cqUgdvb32ymAkv/PbwMfVHrGnLeEfwxzYF5rE+NrI1CsSK4LDRUsv7JMZ3QGQybznGst 9uzuepdHFygPwR8//NzaWXQi8iwTj0o4hkgBE2k485w4BJj4Z6NlKRB3g8Gl6hGarBsT EcMd+JrpUQDLI+RdGgK3hITjePWPPWjk8YT2HXO+kkP2RHFv+yWh46kg8rk8BL7e06Wi iUTg== 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=YlZHVDe/tWnEf116HCDrHBnadF124iyZQQJCDFljrlQ=; fh=N6ystvY2g7QTpz2QKkAMt/Nu9xETjtRlVAZxgmiIO6M=; b=YpFj2X5m37UDoPf89LsM2F2VtKN2MPEeqQJ5eHYVkJmMd0+BOXJLZ9IivBvaVZQcY2 TgD1DbbeoeC7D7N1/P4dPy6bGGJ7awXmbQ0Id3DF1cq/09sucTdlds7tYTadJYDWSR8/ X5K26BovIES7zyB/2H9fkmB5Bky5SMmyVb6ivGxK5LYUpXNAc3XrkBu2qaaVjHXI6WDL uxdc0+Q2fIPoabjPtNG4fygghN1C+4teYyQT+kwLhsEcLINSDzLfZs6fWSV901iat0wy qKU+KJjN9WTMGlx5VpRtLKs8L7UjTv5raL53Yrq/S//YILIkG2vzgj6dyaouef3Ttve3 FDZw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tzHPcPqg; 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 38308e7fff4ca-2e95bccaf53si11124941fa.32.2024.05.25.07.08.12; Sat, 25 May 2024 07:08:12 -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=tzHPcPqg; 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 73882402CC; Sat, 25 May 2024 16:08:08 +0200 (CEST) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by mails.dpdk.org (Postfix) with ESMTP id 879B1402C7 for ; Sat, 25 May 2024 16:08:07 +0200 (CEST) Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2e73441edf7so66776321fa.1 for ; Sat, 25 May 2024 07:08:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716646087; x=1717250887; 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=YlZHVDe/tWnEf116HCDrHBnadF124iyZQQJCDFljrlQ=; b=tzHPcPqgXXyG/RYbASUNkTlEPF3u+CPwyRjdxO1taU5KUY1f6EZj91HODFVT77z4hV WXGu+LmmCH1Z+Zcd6avkENzAGbblFVPWN/6wg+uOtgKMu+TZQTXnXCR8462EDvObSHRw LdPnNujl2AGeelh3VSSRAa5llcMElPpQSOrebJWuFLqJ8tG2jXEYB/XwSRiMbAkKe0c3 4nSW3csHpQQM6PjII4WqRSD3HrhnWcxKA1exCG14hLXa/bmfc10Qk/hPrkAbuzeGysQm 4p/mT6y9h40OSi2T4ZNQYblZZZcPes8F7sHlAgxaqvCgWLTUUmUHMn4TYpMXCf8B4RiM mFIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716646087; x=1717250887; 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=YlZHVDe/tWnEf116HCDrHBnadF124iyZQQJCDFljrlQ=; b=NqwB4N3IWu07bxn2aPTxmSL/ehaMP25YHfvu0doaEWglplLCxR0izu1+SstcneqTgO 5nNvDs7Diqu7laGDxDiT5H2jhFBuwETaMlnUYA1ESciQPzrHcoyfWBdicfR44Rm3KA1G 2vkLNu5Smp/3OsV9SP4gH+EpISeaVOIcLA3mQur0eh2/XW8X3Y+Jdmha2Ff7DcVIT2iG PEI9xY2QDJFyI1SQGX2tVmXy8gMJkzOD081zk5y6/jsOdO3k1eXYMgAS/S6lt/02SV21 lbVGev5KaFYbyIIb7nmDpZ1TprIgORfsR2lTrLQGXYk7TPxOyCcrAmqh7IVinajW8ehu PA9A== X-Gm-Message-State: AOJu0YzLbW0X7HLLa9HjmkcHwKpyEcsUjq973hNon5LCm/p/xUB6RMDi Yzn+JaR5GfjDZM/xN/Qu1CHLnhX5rLdwt/LOiOY3ghJpWzeKu3qm+9BxMCyQqyTjIZTQOYSm0fQ 8WBLCODdU X-Received: by 2002:a2e:7d11:0:b0:2e4:14a0:4d15 with SMTP id 38308e7fff4ca-2e95b27ee38mr30249291fa.51.1716646087110; Sat, 25 May 2024 07:08:07 -0700 (PDT) Received: from localhost.localdomain (ec2-54-151-66-232.us-west-1.compute.amazonaws.com. [54.151.66.232]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42100f134cesm81969625e9.18.2024.05.25.07.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 May 2024 07:08:06 -0700 (PDT) From: Zhangfei Gao To: Akhil Goyal , Fan Zhang , Ashish Gupta Cc: dev@dpdk.org, Zhangfei Gao Subject: [PATCH v2 1/3] compress/uadk: Introduce UADK compression driver Date: Sat, 25 May 2024 14:07:51 +0000 Message-Id: <20240525140753.122-2-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240525140753.122-1-zhangfei.gao@linaro.org> References: <20240525140753.122-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 --- 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 +++++ 4 files changed, 126 insertions(+) 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/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_ */