From patchwork Fri May 20 11:31:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 575396 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp1188926mab; Mon, 23 May 2022 01:23:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnhitOkrxbLlZ0RVEVWm/kef4nyR0LD/K8Ij1EKNMdeWPFlRCFby0XwzUDng3iVM048rwv X-Received: by 2002:a05:600c:4ecb:b0:397:549b:21d9 with SMTP id g11-20020a05600c4ecb00b00397549b21d9mr931882wmq.100.1653294180212; Mon, 23 May 2022 01:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653294180; cv=none; d=google.com; s=arc-20160816; b=YYJzQbnht8tLu7rs6azo658eMK65001BDKJ0Wm6/6G7DdDf3XbppLOdj4W39Gzev20 ObR2wV4mEs8k5Mx+wDRlzX7Ns3awUzbMzPe8aOFEvk8q8oQ6s+24S8NQ7lp+Z/fFC54A XF2TCY4l2LXe2rs2duaBhnMLOxFG3T11oDUkAx1Li16letN/hS1KWVVsM4MT/cCElZ8C +3ONl23GJ6RkJTsCWpdU+baVTp+EseeU0ey4XJaBD6hVdx77754NLXCZAe1R6uSuYHZ1 neMfzONwhg0Oacl6/wChoD6+I2K2Mqk/9zOTWP9OvPHIO8oG/UKH9iMhQISRtJ/IXp4B hnlg== 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=sqQlqdwFK+SovsZ2ePl7/t44O72oqdsJKYUwfvMUgvc=; b=KKHA6pSwdqhXHdkIgECtdksL+A801SPMD6mUiGkxr07q6oYcShBMeI528Xql3Ablwi gaPN5q1MytAsTzthiUBcJI+LTALI+z0ZekjDCjS1/6CwMp/Mo/V5DvNRMEFgARAvihIT DELEWioNk+vgV9KCd1b9VRW3ttUiiRKBIIlCxj+nmBZSTYW8hM43X1V9IsL8etTxfQD4 fEpYXWPKT79Ct9zbe6PvDf5LazR0BzBJ0BsqzuzNX9xQHpS5Ce/DnYFZyDf5DSn/Ok3p v73Fi+BOkA2ITdjxoPinKOiXKcYLYR/FgDCNDeUSrUavupt5IxXCRhvtaQ5xMkM1pH5y UKKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ClX1wrbL; 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 u18-20020adfeb52000000b0020f0a01f8a6si7656777wrn.568.2022.05.23.01.23.00; Mon, 23 May 2022 01:23:00 -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=ClX1wrbL; 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 [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE4274161A; Mon, 23 May 2022 10:22:55 +0200 (CEST) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by mails.dpdk.org (Postfix) with ESMTP id 82D1C40222 for ; Fri, 20 May 2022 13:32:07 +0200 (CEST) Received: by mail-wr1-f45.google.com with SMTP id f2so11147849wrc.0 for ; Fri, 20 May 2022 04:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sqQlqdwFK+SovsZ2ePl7/t44O72oqdsJKYUwfvMUgvc=; b=ClX1wrbLKToNgpyE43NkwUVdF5rIVv7VfoSPE/9XFmPXZhU1m6zPYvT+Dr0IJXpW93 O0ELinFSKP2kzY9FUkZj2ZP0YaZxdHHa1CzktugBSDj0aub/hHanpcYwVsGd+2YJqIDq eG+nwcPhLzmFlhy2OgPz8xd67LqSwG2xHKOI8CorrsLE0RwGhMQAXPc2JybLxPAvnjHd cB7cobVHRBrjfA5JssjqzliXM7TrcbemzggZyXqbnlWCoKVc5LPukNUl28rOkRyi3J8W 6hWx/dLAqOCJ/Ti0sx4dInlBjsg+BzFOAlKFGg4goL/Bhhw8TS4HTYB7hezdKY1GOZZS 7hDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sqQlqdwFK+SovsZ2ePl7/t44O72oqdsJKYUwfvMUgvc=; b=fiMz17AgFrmOOfkKfxTVJq17fLLLCYweA5fWnFKZgJT2j5SOu/jlwXC12tWBax54Nx 5TsL+SNuO/6XsALmWeN2I2eCeBrpw6Y3KG3Rc36ZrJog5n8J8074LK6pVJ4agarHUBCa nkAkiivVO+mdRVg4lUNIXin86d79NmCmsU3f6Z1PFLI15cfY+i0ldlGLcWUuV6VOQg57 dODg/gTfDphZ+7jILnSky5aYk4omkVS38P4MDBBlzehkUN2s+0eLYCHvhqx9eauXSxW9 149DXMyq7KFh5C7tmV/Ktw3HWCCfNiyw2W1RWGP9LBW9vduWp0iKM12lf/hME7mdclgY 86QQ== X-Gm-Message-State: AOAM532aHGpebwy4bp4h1DON0EhgsArWY+RA+i5jZdpumV9eTpvNbZpO jVQwb3eK0K+TZLQYtsuMSK31yw== X-Received: by 2002:a05:6000:11cc:b0:20c:fecc:3a44 with SMTP id i12-20020a05600011cc00b0020cfecc3a44mr7488463wrx.366.1653046327119; Fri, 20 May 2022 04:32:07 -0700 (PDT) Received: from localhost.localdomain ([213.146.143.36]) by smtp.gmail.com with ESMTPSA id m10-20020a7bca4a000000b003972e136b8asm1828080wml.15.2022.05.20.04.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 04:32:06 -0700 (PDT) From: Zhangfei Gao To: Akhil Goyal , Declan Doherty , Fan Zhang , Ashish Gupta , Ray Kinsella Cc: dev@dpdk.org, Zhangfei Gao Subject: [PATCH RFC 1/3] compress: add UADK compression PMD Date: Fri, 20 May 2022 19:31:52 +0800 Message-Id: <20220520113154.7164-2-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220520113154.7164-1-zhangfei.gao@linaro.org> References: <20220520113154.7164-1-zhangfei.gao@linaro.org> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 23 May 2022 10:22:54 +0200 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 compression & decompression PMD for HiSilicon Hunpeng930 The UADK compression PMD rely on uadk api. Test: sudo dpdk-test --vdev=0000:75:00.0 RTE>>compressdev_autotest RTE>>quit Signed-off-by: Zhangfei Gao --- doc/guides/compressdevs/index.rst | 1 + doc/guides/compressdevs/uadk.rst | 73 ++++ drivers/compress/meson.build | 1 + drivers/compress/uadk/meson.build | 28 ++ drivers/compress/uadk/uadk_compress_pmd.c | 500 ++++++++++++++++++++++ drivers/compress/uadk/version.map | 3 + 6 files changed, 606 insertions(+) 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/version.map diff --git a/doc/guides/compressdevs/index.rst b/doc/guides/compressdevs/index.rst index 54a3ef4273..e47a9ab9cf 100644 --- a/doc/guides/compressdevs/index.rst +++ b/doc/guides/compressdevs/index.rst @@ -14,4 +14,5 @@ Compression Device Drivers mlx5 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..08eb636da2 --- /dev/null +++ b/doc/guides/compressdevs/uadk.rst @@ -0,0 +1,73 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright 2022-2023 Huawei Technologies Co.,Ltd. All rights reserved. + Copyright 2022-2023 Linaro ltd. + +UADK Compression Poll Mode Driver +======================================================= + +UADK compression PMD provides poll mode compression & decompression driver +support for the following hardware accelerator devices: + +* ``HiSilicon Kunpeng930`` + +Features +-------- + +UADK compression PMD has support for: + +Compression/Decompression algorithm: + + * DEFLATE - using Fixed and Dynamic Huffman encoding + +Window size support: + + * 32K + +Checksum generation: + + * CRC32, Adler and combined checksum + +Stateful operation: + + * Decompression only + +Test steps +----------- + + .. code-block:: console + + 1. Build + cd dpdk + mkdir build + meson build (--reconfigure) + cd build + ninja + sudo ninja install + + 2. Prepare + 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 + + 2 Test with zip pf + sudo dpdk-test --vdev=0000:75:00.0 + RTE>>compressdev_autotest + RTE>>quit + + 3. Test with zip vf + su root + echo 1 > /sys/devices/pci0000:74/0000:74:00.0/0000:75:00.0/sriov_numvfs + exit + sudo dpdk-test --vdev=0000:75:00.1 + RTE>>compressdev_autotest + RTE>>quit + +Dependency +------------ + +UADK compression PMD relies on HiSilicon UADK library [1] + +[1] https://github.com/Linaro/uadk diff --git a/drivers/compress/meson.build b/drivers/compress/meson.build index abe043ab94..041a45ba41 100644 --- a/drivers/compress/meson.build +++ b/drivers/compress/meson.build @@ -10,6 +10,7 @@ drivers = [ 'mlx5', 'octeontx', 'zlib', + 'uadk', ] std_deps = ['compressdev'] # compressdev pulls in all other needed deps diff --git a/drivers/compress/uadk/meson.build b/drivers/compress/uadk/meson.build new file mode 100644 index 0000000000..347ef9757d --- /dev/null +++ b/drivers/compress/uadk/meson.build @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2022-2023 Huawei Technologies Co.,Ltd. All rights reserved. +# Copyright 2022-2023 Linaro ltd. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +if arch_subdir != 'arm' or not dpdk_conf.get('RTE_ARCH_64') + build = false + reason = 'only supported on aarch64' + subdir_done() +endif + +sources = files( + 'uadk_compress_pmd.c', +) + +deps += ['bus_pci'] +dep = cc.find_library('libwd_comp', dirs: ['/usr/local/lib'], required: false) +if not dep.found() + build = false + reason = 'missing dependency, "libwd_comp"' +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..16a0593f84 --- /dev/null +++ b/drivers/compress/uadk/uadk_compress_pmd.c @@ -0,0 +1,500 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2022-2023 Huawei Technologies Co.,Ltd. All rights reserved. + * Copyright 2022-2023 Linaro ltd. + */ + +#include +#include +#include +#include +#include + +struct uadk_compress_priv { + struct rte_mempool *mp; +} __rte_cache_aligned; + +struct uadk_qp { + struct rte_ring *processed_pkts; + /**< Ring for placing process packets */ + struct rte_compressdev_stats qp_stats; + /**< Queue pair statistics */ + uint16_t id; + /**< Queue Pair Identifier */ + char name[RTE_COMPRESSDEV_NAME_MAX_LEN]; + /**< Unique Queue Pair Name */ +} __rte_cache_aligned; + +struct uadk_stream { + handle_t handle; + enum rte_comp_xform_type type; +} __rte_cache_aligned; + +RTE_LOG_REGISTER_DEFAULT(uadk_compress_logtype, INFO); + +#define UADK_LOG(level, fmt, ...) \ + rte_log(RTE_LOG_ ## level, uadk_compress_logtype, \ + "%s() line %u: " fmt "\n", __func__, __LINE__, \ + ## __VA_ARGS__) + +#define UADK_COMPRESS_DRIVER_NAME compress_uadk + +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 __rte_unused) +{ +} + +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 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 -1; + + 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 -1; +} + +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_ZLIB; + 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 = 0; + 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_ZLIB; + setup.comp_lv = WD_COMP_L8; + setup.op_type = WD_DIR_DECOMPRESS; + param.type = setup.op_type; + param.numa_id = 0; + 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 = 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 +}; + +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 = 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_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, + struct rte_pci_device *pci_dev) +{ + char name[RTE_COMPRESSDEV_NAME_MAX_LEN]; + struct rte_compressdev *compressdev; + struct rte_compressdev_pmd_init_params init_params = { + "", + rte_socket_id(), + }; + + rte_pci_device_name(&pci_dev->addr, name, sizeof(name)); + compressdev = rte_compressdev_pmd_create(name, &pci_dev->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 = 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; +} + +static int +uadk_compress_pci_remove(struct rte_pci_device *pci_dev) +{ + struct rte_compressdev *compressdev; + char name[RTE_COMPRESSDEV_NAME_MAX_LEN]; + + if (pci_dev == NULL) + return -EINVAL; + + rte_pci_device_name(&pci_dev->addr, name, sizeof(name)); + compressdev = rte_compressdev_pmd_get_named_dev(name); + if (compressdev == NULL) + return -ENODEV; + + return rte_compressdev_pmd_destroy(compressdev); +} + +#define PCI_VENDOR_ID_HUAWEI 0x19e5 +#define PCI_DEVICE_ID_ZIP_PF 0xa250 +#define PCI_DEVICE_ID_ZIP_VF 0xa251 + +static struct rte_pci_id pci_id_uadk_compress_table[] = { + { + RTE_PCI_DEVICE(PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_ZIP_PF), + }, + { + RTE_PCI_DEVICE(PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_ZIP_VF), + }, + { + .device_id = 0 + }, +}; + +/** + * Structure that represents a PCI driver + */ +static struct rte_pci_driver uadk_compress_pmd = { + .id_table = pci_id_uadk_compress_table, + .probe = uadk_compress_pci_probe, + .remove = uadk_compress_pci_remove, +}; + +RTE_PMD_REGISTER_PCI(UADK_COMPRESS_DRIVER_NAME, uadk_compress_pmd); +RTE_PMD_REGISTER_PCI_TABLE(UADK_COMPRESS_DRIVER_NAME, pci_id_uadk_compress_table); diff --git a/drivers/compress/uadk/version.map b/drivers/compress/uadk/version.map new file mode 100644 index 0000000000..c2e0723b4c --- /dev/null +++ b/drivers/compress/uadk/version.map @@ -0,0 +1,3 @@ +DPDK_22 { + local: *; +}; From patchwork Fri May 20 11:31:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 575397 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:c603:0:0:0:0 with SMTP id jv3csp1188952mab; Mon, 23 May 2022 01:23:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc/STnTG3y+2I8rLVLNXr6rg8sYCFG2ewY1Eb6xP6G19fQTCnu0v4WcyTY0V9JVMiPYoBm X-Received: by 2002:a7b:c4ca:0:b0:397:3bac:9b2a with SMTP id g10-20020a7bc4ca000000b003973bac9b2amr12479651wmk.154.1653294185868; Mon, 23 May 2022 01:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653294185; cv=none; d=google.com; s=arc-20160816; b=dx/JCsSuFsieBa5bQORGFN5MSzbp6RL95N2oYi//U5JCZYSNKAJkkMN11aV8qFhICB 2Vcfg9CbOw/wrjV0R9VqETGmPNJesZZ3VtpLTBkES5Wx9AFo9X6rDvGcaKYQaIWSPvan F2KhSGBGeF/7hi4H/VpkqXiSkBXsYirkxVYVctAniFopf32uAeHH6FyThiIymYVSZ4yF TzH7iSCjJZJyh9x0EZ92j/tL+0yqx0v5xVM23B5RCSLBl2qDwzmMBCrfnkQcc4U38KTR u4u3Tw7JvYmR0QOHISQqLJjJpwbLmOTgNosQ2ZaFO428y1s4DcuJ1jaxGStewaht0/pS h+xg== 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=Py/i2YMGI+FkIjuIMjkwfCz+4Oqv7RM/xBZl+Yf2/n4=; b=hFzi8Ges2vigrwHXgLrGw5mPSkyJTBBGLa7iSMD/zrDqVLwSm1uHT+0D4zp6d9aWBx rlGwCJDWiCEyEFaLVInLuR/3efnxQ5EKJTlGzBFMYimUzDBUI0VWODsQV0uKnKjAWiTZ 0nBkiaQfIlbJqo6qk2lX5ahLouFd6uVlge3Qd9O2udo7lF5KzCglWeMn9NlDlRxqvmu9 KJxO3ZYbBha11PNomOTQr/g7Ut79+esaRKajV5V0gSoX/NXjai5nSwaQtc4ZlFY/pbWX LkZxzaYwf2tpojDVLtJfEPwJ2h+ZcpEurtyUKJ/TINaZQraUeiGb2z38dAw7YJhY8sRY G68w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="HraNN7i/"; 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 s3-20020adfdb03000000b0020d0bfcc22dsi8992664wri.87.2022.05.23.01.23.05; Mon, 23 May 2022 01:23:05 -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="HraNN7i/"; 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 [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B7CB7427F0; Mon, 23 May 2022 10:22:56 +0200 (CEST) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mails.dpdk.org (Postfix) with ESMTP id 2CD1740222 for ; Fri, 20 May 2022 13:32:08 +0200 (CEST) Received: by mail-wr1-f46.google.com with SMTP id k30so11105307wrd.5 for ; Fri, 20 May 2022 04:32:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Py/i2YMGI+FkIjuIMjkwfCz+4Oqv7RM/xBZl+Yf2/n4=; b=HraNN7i/lSYVob6GLomD+9JugzdNHlqwxfPqYkVYaVqyHEVYrhCsOTGbxqOKS4kWiy O1oJPEJpCRAjiseC68j9g+No0M5XLYlH6HABMqxDBK7YQtKsSi12jjKa9txcDTvH2V3W CsCo4Z3DRnryhxXekWFDm4kJrKcH7YtbvuUYK+a21Ujvc8YFqstbPMQYU1DTzaBzunaI sf8nm5hSs7gNLsCXHgiDBfgC0L4LMZTzwdActezP39HkqRRbSL1fPF9XEudKEmBnd+k2 wU8Kwv6pGQzPiZKETPGdHOo73/Nl3wuSwVbfnTN17KQqD0fqWFuiEvHypHRIv+b/xLx5 70pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Py/i2YMGI+FkIjuIMjkwfCz+4Oqv7RM/xBZl+Yf2/n4=; b=to0iTExUBHu5DwMYTI2SEBw55x0kVP2i3uDtWNbodoQo9x+dltFLkf5ObuG7I/YXhe 7jamBpFYX0L1Vg1rpaZqzHCbLg+J+WO60JQNzXuQDKTVHcJw8/4H7ksCE6TFdLTASh2v Uevrl0yAx5gv6bttyqkrYhB77IuBzkcRgP29zG24iEfaYahoPUBOf6/pCOk46MOQf2Zk nEBBSp/m+hr6ftVjCTw7WBby+CyQKJvaBvl3kR64v77As1l4VyHV23j+vOIEtIf+burS uUMacQqtmje4liQMg/Isvm9wz7xcxdKeDVzB4AMdRSg7qQtX3x3ZIn24wvT2Evz0G9H3 ffXA== X-Gm-Message-State: AOAM533rtQ8zXNwDr8+eujQ38+Pk+sUsQijtVGdeBh9qRAUG6o0QP88H KFS0vqOnCjCv50F0XCn+pyy/Lw== X-Received: by 2002:adf:f1ce:0:b0:20c:d569:d2eb with SMTP id z14-20020adff1ce000000b0020cd569d2ebmr7960643wro.440.1653046327950; Fri, 20 May 2022 04:32:07 -0700 (PDT) Received: from localhost.localdomain ([213.146.143.36]) by smtp.gmail.com with ESMTPSA id m10-20020a7bca4a000000b003972e136b8asm1828080wml.15.2022.05.20.04.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 04:32:07 -0700 (PDT) From: Zhangfei Gao To: Akhil Goyal , Declan Doherty , Fan Zhang , Ashish Gupta , Ray Kinsella Cc: dev@dpdk.org, Zhangfei Gao Subject: [PATCH RFC 2/3] test/crypto: add cryptodev_uadk_autotest Date: Fri, 20 May 2022 19:31:53 +0800 Message-Id: <20220520113154.7164-3-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220520113154.7164-1-zhangfei.gao@linaro.org> References: <20220520113154.7164-1-zhangfei.gao@linaro.org> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 23 May 2022 10:22:54 +0200 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 Example: sudo dpdk-test --vdev=0000:76:00.0 --log-level=6 RTE>>cryptodev_uadk_autotest RTE>>quit Signed-off-by: Zhangfei Gao --- app/test/test_cryptodev.c | 7 +++++++ app/test/test_cryptodev.h | 1 + 2 files changed, 8 insertions(+) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 10b48cdadb..b413807d2b 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -15445,6 +15445,12 @@ test_cryptodev_mlx5(void) return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD)); } +static int +test_cryptodev_uadk(void) +{ + return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD)); +} + static int test_cryptodev_null(void) { @@ -15722,6 +15728,7 @@ REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm); REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest, test_cryptodev_cpu_aesni_gcm); REGISTER_TEST_COMMAND(cryptodev_mlx5_autotest, test_cryptodev_mlx5); +REGISTER_TEST_COMMAND(cryptodev_uadk_autotest, test_cryptodev_uadk); REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null); REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g); REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi); diff --git a/app/test/test_cryptodev.h b/app/test/test_cryptodev.h index 90c8287365..1f2a20e84e 100644 --- a/app/test/test_cryptodev.h +++ b/app/test/test_cryptodev.h @@ -75,6 +75,7 @@ #define CRYPTODEV_NAME_CN9K_PMD crypto_cn9k #define CRYPTODEV_NAME_CN10K_PMD crypto_cn10k #define CRYPTODEV_NAME_MLX5_PMD crypto_mlx5 +#define CRYPTODEV_NAME_UADK_PMD crypto_uadk enum cryptodev_api_test_type {