From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-eopbgr730052.outbound.protection.outlook.com [40.107.73.52]) by dpdk.org (Postfix) with ESMTP id E139C32A5 for ; Mon, 23 Jul 2018 16:51:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZApVFzksUhUlbS3rT9WCLYs17mKXNJrjA2t6/MC4R+c=; b=dsoTbEw5QKeIsGp9qOl9je0uKPu/JFjWcTr4OtU3AECwoDvhHvgbeLGp+cnMlAwPvytILCQPZryM/+W+N5u/Uj29otLuidzF8cw1RzMfZuFL+M71HjCljL0zgRJLhCUGDd0WkwJVvsriQTAhIqeBNDG94DgEHdxCsFuSszlkPH0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Shally.Verma@cavium.com; Received: from hyd1sverma-dt.caveonetworks.com (115.113.156.2) by MWHPR0701MB3641.namprd07.prod.outlook.com (2603:10b6:301:7d::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.16; Mon, 23 Jul 2018 14:51:46 +0000 From: Shally Verma To: pablo.de.lara.guarch@intel.com Cc: dev@dpdk.org, pathreya@caviumnetworks.com, mchalla@caviumnetworks.com, Ashish Gupta , Sunila Sahu Date: Mon, 23 Jul 2018 20:21:11 +0530 Message-Id: <1532357474-9544-3-git-send-email-shally.verma@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532357474-9544-1-git-send-email-shally.verma@caviumnetworks.com> References: <1532357474-9544-1-git-send-email-shally.verma@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: PN1PR0101CA0041.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:c::27) To MWHPR0701MB3641.namprd07.prod.outlook.com (2603:10b6:301:7d::34) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5a200d01-bd57-49e3-6178-08d5f0abd16b X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:MWHPR0701MB3641; X-Microsoft-Exchange-Diagnostics: 1; MWHPR0701MB3641; 3:WhZaAsM1sBMrfgWeXWSDYE4KitkZ8hgRFX1WassfSHDGp+iLVqEFxIaGCfwAdfH5Z+kMDA4TRbBHOcTUtVgEF3t7+WjmTVk316sjQDbVsWMoi9PsdN2cCIOkftG6sMnZgu3552ZM3WlidzZ9M6om3bIicAXRsthFs/gI10PBboDExBI1wpzT/2km1FC1PO5W2ffibskVQ3DyH2uqsHgk2fpXhZOKlh9rB2jb3r8fkpNME9Sd4TIPQUJe/TOWiFUc; 25:ZfLQcOihZRPI0Bbd+zmNsLGoN3ALthaa76XftxvNH2+AxR3fkBmrGDamoMQyyO7FX7fiJbbrRj+yJXdcpK7Us7H6mwqGTDz0NV1m6zJ7qbWziGE6diP0W+AGR8YFaPLIoh7T6DiEQPKzYCO/uLnnlLe9de/o0HDz7rJJ4a2gWmqGJTJxRGnIEk3FSGT/SrovPcs6GPQrAngaOOoh3Ja0tsCHyr6CRpQEh01AWCqB/98LhZgYkc+DNuH9fF/uJi0GBj6TCiRgfDDuuREzM7rc7H7kTOpGdxY16P/b4tAXoEtv48/oj/TdqjvkD4Cuuzko9EZwukJH3XVyr8lk8QI6jg==; 31:6PIASkXPE2Mcvt74BFOz9yrv8soGFPULcFzppzoru+l7qOoP5R0532X/nuRSgUpQCWWGC7OBlM1J86j+7riswyKZYV4A27kK0orv10NzzTRxw7Yc6zHd4C8WolgcihYKha4WV+NFqydOG1Xc/CfZJEpPdvGzqEd9uG83efH5N/nPYBIt9+xhA81HIk5DflY54mBOkT7W761SlMjw+n9r5Vtm1hQb4pq6mLzDefkyYfw= X-MS-TrafficTypeDiagnostic: MWHPR0701MB3641: X-Microsoft-Exchange-Diagnostics: 1; MWHPR0701MB3641; 20:ygrzKGrIssiXS/vliZb580Yw2jtrt4/C6lYi+V6NLwLPQqhw6Q2XrHyqtgLPjGHVXEV9BKowXMJcg/jpvVUEA/gtQnBk+S0SJ8ZF0K6BocZaTuiUH5/g0TpViGxnxLSni34dQy1Acu8kjcJhCkdaQRKhb0um8/V2AcrFReNz5465futm/MLvFuTXjCcjNO6AMvjaaug2tifPwYF1cn5b7gYzMy39jQwDxFGrpxF4z/n0Mv0KXkzTbLfXzSSVbvPgY5+PEtdZjYtZNjBvic/30LhrhJxhJyC1XNF8KswcSoR8AR7o8xnOR0QPZs103y0ZIXfRwTZXuBt7sTuZoufO0JWUgFcL70KMGOM+VQliJGM+0ZkkIJUnGtQWccTeHCc9k+J78cmLg8f+31XPkELQEQsGg8WNUKg6h+q99EAtNkFeHwGuvmcJNCjMVC7V6sTlN40/TLNx4n4Lkt4+4dd8jm3N+VR0LD5y5rzyrbAeysweQ61/y4YSXxTVoJF4a/n/m5azRuE2wlVXawVoYjBfMoIXmzROSjbZDwxB3UCV0rikntKmU/q/fQPKXuZgpS2MkbxK1kvnEFEynujOndXubw52kTNq6Cb0yYauRWiI88E=; 4:caQsEKIphqen6tBEcsT29cz9TgplND9nLFNDlzjVM0l2lkBcHHhUEkJUZjyM6DtkdAU2QhNjYTy+9GQlJ7wSX3ClqSuWNz/xI29OFylyuzjMt4ihiURGKnD2hq0PX+GQJzDJSsOxWerCR1QX/JC2PGnh5879ICIkD3vkUqNWZUzw4MR3Kvbl3rePcHelt79zWY1gZCidV99l862a9kFJluvJsNYKCnbypaJ1i0udVmuwnMETRRNY7e54yEpfXK9+NWJZSGpkRHahrVQcnaHN1A== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231311)(944501410)(52105095)(3002001)(10201501046)(93006095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:MWHPR0701MB3641; BCL:0; PCL:0; RULEID:; SRVR:MWHPR0701MB3641; X-Forefront-PRVS: 0742443479 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(366004)(39860400002)(136003)(346002)(376002)(199004)(189003)(6512007)(25786009)(53936002)(48376002)(107886003)(47776003)(66066001)(50466002)(14444005)(50226002)(2351001)(69596002)(55236004)(4326008)(36756003)(446003)(42882007)(7736002)(575784001)(305945005)(5660300001)(3846002)(478600001)(6116002)(72206003)(11346002)(316002)(8676002)(97736004)(44832011)(76176011)(16586007)(81156014)(68736007)(81166006)(52116002)(476003)(956004)(2616005)(486006)(51416003)(26005)(2906002)(386003)(6506007)(2361001)(6486002)(105586002)(6916009)(53416004)(186003)(6666003)(54906003)(16526019)(106356001)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR0701MB3641; H:hyd1sverma-dt.caveonetworks.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR0701MB3641; 23:tvkPO28IlmaOKDUiiHDtSG8UPZCmqswq+D/OkMy?= =?us-ascii?Q?SkkH10UkPHDRO5n+3VUuk70ACVk2puogNtMIhh3J8FAQKMgKso8FARRfBM2u?= =?us-ascii?Q?xFmP9qsN/FEzWq/tBLfUoxa1wjbo4steAHdYPT8qiNH4u9NEe0fbDve6EzJG?= =?us-ascii?Q?pvjxPB2yFZbf8UPxGJs6myMrNJtTJl+//d2EQaFmlT38/rd+GA8b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gjc0H53QXBHk/E3Qq7HUM9Ok/Ph9ln6B6e2/hGnhxZ9lOe2mnK/FrJcKmt2rCekXgo85xkNr6QBiPRvDW8QyKmocBci/N+2kxlzVsbiwddsVVcDmoJ/JkwZNjcZMi60Ps0YTOxULwwFLUza0YgR0QzViY1rWOHkL5AJl2qkwR2JekjLvRG2HSdwMo43nonszAP7YDBoWLRDsPU7UUN8g==; 5:7XaG2FpFbgyo6GlfWPJfP2xoi1P9qldeS65+x0+X5UUmxkPj5FQXKzdNUZLSk4Qqn4PkIWbWgVWcogWcOC/HoxI7iBCmvk26zKmTlrfLZDOaJZcG1wlb6cGENGnidozXAg61CGVCPjqy78fMgrUKNKZEX3+whz4O9xPREFF2tuk=; 7:i973YorrKkQYy6QOqUG80rlqt48NJjrcBu9S25Uu1sNLzBuQGgAS2YMZoo5NWxVZMWvDhbCw/3/9VHMxIogmomynT2O0Mz3DuaMFdy/RSqQlrWOebAYd9PPfDVUu/aqnNJh8eHzhZV01b8l53SAhBm9y/j1p3bTtIajpmjtFs69Yo20VTKbhoRorqmS2Y7Eeqdnwe/JNSrDMIVt4mnS/JYcX3zqhqrqz5qotwXyfmEn0wiHDS6R+YHaEuEHKt2D1 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2018 14:51:46.6342 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5a200d01-bd57-49e3-6178-08d5f0abd16b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR0701MB3641 Subject: [dpdk-dev] [PATCH v4 2/5] compress/zlib: add device PMD ops X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jul 2018 14:51:50 -0000 From: Ashish Gupta Implement device configure and queue pair setup PMD ops Signed-off-by: Sunila Sahu Signed-off-by: Shally Verma Signed-off-by: Ashish Gupta --- drivers/compress/zlib/Makefile | 1 + drivers/compress/zlib/meson.build | 2 +- drivers/compress/zlib/zlib_pmd.c | 2 + drivers/compress/zlib/zlib_pmd_ops.c | 238 +++++++++++++++++++++++++++++++ drivers/compress/zlib/zlib_pmd_private.h | 35 +++++ 5 files changed, 277 insertions(+), 1 deletion(-) diff --git a/drivers/compress/zlib/Makefile b/drivers/compress/zlib/Makefile index bd322c9..5cf8de6 100644 --- a/drivers/compress/zlib/Makefile +++ b/drivers/compress/zlib/Makefile @@ -24,5 +24,6 @@ LDLIBS += -lrte_bus_vdev # library source files SRCS-$(CONFIG_RTE_LIBRTE_PMD_ZLIB) += zlib_pmd.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_ZLIB) += zlib_pmd_ops.c include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/compress/zlib/meson.build b/drivers/compress/zlib/meson.build index 3f0a77b..7748de2 100644 --- a/drivers/compress/zlib/meson.build +++ b/drivers/compress/zlib/meson.build @@ -7,7 +7,7 @@ if not dep.found() endif deps += 'bus_vdev' -sources = files('zlib_pmd.c') +sources = files('zlib_pmd.c', 'zlib_pmd_ops.c') ext_deps += dep pkgconfig_extra_libs += '-lz' diff --git a/drivers/compress/zlib/zlib_pmd.c b/drivers/compress/zlib/zlib_pmd.c index 39d3628..9363808 100644 --- a/drivers/compress/zlib/zlib_pmd.c +++ b/drivers/compress/zlib/zlib_pmd.c @@ -21,6 +21,8 @@ zlib_create(const char *name, return -ENODEV; } + dev->dev_ops = rte_zlib_pmd_ops; + return 0; } diff --git a/drivers/compress/zlib/zlib_pmd_ops.c b/drivers/compress/zlib/zlib_pmd_ops.c new file mode 100644 index 0000000..645c5b1 --- /dev/null +++ b/drivers/compress/zlib/zlib_pmd_ops.c @@ -0,0 +1,238 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Cavium Networks + */ + +#include + +#include +#include + +#include "zlib_pmd_private.h" + +static const struct rte_compressdev_capabilities zlib_pmd_capabilities[] = { + { /* Deflate */ + .algo = RTE_COMP_ALGO_DEFLATE, + .comp_feature_flags = (RTE_COMP_FF_NONCOMPRESSED_BLOCKS | + RTE_COMP_FF_HUFFMAN_FIXED | + RTE_COMP_FF_HUFFMAN_DYNAMIC | + RTE_COMP_FF_OOP_SGL_IN_SGL_OUT), + .window_size = { + .min = 8, + .max = 15, + .increment = 1 + }, + }, + + RTE_COMP_END_OF_CAPABILITIES_LIST() + +}; + +/** Configure device */ +static int +zlib_pmd_config(struct rte_compressdev *dev, + struct rte_compressdev_config *config) +{ + struct rte_mempool *mp; + char mp_name[RTE_MEMPOOL_NAMESIZE]; + struct zlib_private *internals = dev->data->dev_private; + + snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, + "stream_mp_%u", dev->data->dev_id); + mp = internals->mp; + if (mp == NULL) { + mp = rte_mempool_create(mp_name, + config->max_nb_priv_xforms + + config->max_nb_streams, + sizeof(struct zlib_priv_xform), + 0, 0, NULL, NULL, NULL, + NULL, config->socket_id, + 0); + if (mp == NULL) { + ZLIB_PMD_ERR("Cannot create private xform pool on " + "socket %d\n", config->socket_id); + return -ENOMEM; + } + internals->mp = mp; + } + return 0; +} + +/** Start device */ +static int +zlib_pmd_start(__rte_unused struct rte_compressdev *dev) +{ + return 0; +} + +/** Stop device */ +static void +zlib_pmd_stop(__rte_unused struct rte_compressdev *dev) +{ +} + +/** Close device */ +static int +zlib_pmd_close(struct rte_compressdev *dev) +{ + struct zlib_private *internals = dev->data->dev_private; + rte_mempool_free(internals->mp); + internals->mp = NULL; + return 0; +} + +/** Get device statistics */ +static void +zlib_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 zlib_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; + } +} + +/** Reset device statistics */ +static void +zlib_pmd_stats_reset(struct rte_compressdev *dev) +{ + int qp_id; + + for (qp_id = 0; qp_id < dev->data->nb_queue_pairs; qp_id++) { + struct zlib_qp *qp = dev->data->queue_pairs[qp_id]; + + memset(&qp->qp_stats, 0, sizeof(qp->qp_stats)); + } +} + +/** Get device info */ +static void +zlib_pmd_info_get(struct rte_compressdev *dev, + struct rte_compressdev_info *dev_info) +{ + if (dev_info != NULL) { + dev_info->driver_name = dev->device->name; + dev_info->feature_flags = dev->feature_flags; + dev_info->capabilities = zlib_pmd_capabilities; + } +} + +/** Release queue pair */ +static int +zlib_pmd_qp_release(struct rte_compressdev *dev, uint16_t qp_id) +{ + struct zlib_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; +} + +/** set a unique name for the queue pair based on its name, dev_id and qp_id */ +static int +zlib_pmd_qp_set_unique_name(struct rte_compressdev *dev, + struct zlib_qp *qp) +{ + unsigned int n = snprintf(qp->name, sizeof(qp->name), + "zlib_pmd_%u_qp_%u", + dev->data->dev_id, qp->id); + + if (n >= sizeof(qp->name)) + return -1; + + return 0; +} + +/** Create a ring to place process packets on */ +static struct rte_ring * +zlib_pmd_qp_create_processed_pkts_ring(struct zlib_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) { + ZLIB_PMD_INFO("Reusing existing ring %s for processed" + " packets", qp->name); + return r; + } + + ZLIB_PMD_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); +} + +/** Setup a queue pair */ +static int +zlib_pmd_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, + uint32_t max_inflight_ops, int socket_id) +{ + struct zlib_qp *qp = NULL; + + /* Free memory prior to re-allocation if needed. */ + if (dev->data->queue_pairs[qp_id] != NULL) + zlib_pmd_qp_release(dev, qp_id); + + /* Allocate the queue pair data structure. */ + qp = rte_zmalloc_socket("ZLIB 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 (zlib_pmd_qp_set_unique_name(dev, qp)) + goto qp_setup_cleanup; + + qp->processed_pkts = zlib_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; +} + +struct rte_compressdev_ops zlib_pmd_ops = { + .dev_configure = zlib_pmd_config, + .dev_start = zlib_pmd_start, + .dev_stop = zlib_pmd_stop, + .dev_close = zlib_pmd_close, + + .stats_get = zlib_pmd_stats_get, + .stats_reset = zlib_pmd_stats_reset, + + .dev_infos_get = zlib_pmd_info_get, + + .queue_pair_setup = zlib_pmd_qp_setup, + .queue_pair_release = zlib_pmd_qp_release, + + .private_xform_create = NULL, + .private_xform_free = NULL, + + .stream_create = NULL, + .stream_free = NULL +}; + +struct rte_compressdev_ops *rte_zlib_pmd_ops = &zlib_pmd_ops; diff --git a/drivers/compress/zlib/zlib_pmd_private.h b/drivers/compress/zlib/zlib_pmd_private.h index d26a740..0e391a4 100644 --- a/drivers/compress/zlib/zlib_pmd_private.h +++ b/drivers/compress/zlib/zlib_pmd_private.h @@ -27,6 +27,41 @@ int zlib_logtype_driver; ZLIB_PMD_LOG(WARNING, fmt, ## args) struct zlib_private { + struct rte_mempool *mp; }; +struct zlib_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; + +/* Algorithm handler function prototype */ +typedef void (*comp_func_t)(struct rte_comp_op *op, z_stream *strm); + +typedef int (*comp_free_t)(z_stream *strm); + +/** ZLIB Stream structure */ +struct zlib_stream { + z_stream strm; + /**< zlib stream structure */ + comp_func_t comp; + /**< Operation (compression/decompression) */ + comp_free_t free; + /**< Free Operation (compression/decompression) */ +} __rte_cache_aligned; + +/** ZLIB private xform structure */ +struct zlib_priv_xform { + struct zlib_stream stream; +} __rte_cache_aligned; + +/** Device specific operations function pointer structure */ +extern struct rte_compressdev_ops *rte_zlib_pmd_ops; + #endif /* _RTE_ZLIB_PMD_PRIVATE_H_ */ -- 2.9.5