From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0075.outbound.protection.outlook.com [104.47.41.75]) by dpdk.org (Postfix) with ESMTP id 9D3782C28 for ; Sat, 21 Jul 2018 20:18:27 +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=cwu/rnI2AZa0nMmVTycnBfVt0fMG95Vzqvnr6MRbUBC8IzQNR3bgccSP0b2mEPy0LTypjIR4YHMQfllz8Gj7SPZH6t/lPUwBAUvuk/M7kWF6/M2D85rdOQNVGl3+5Renpg8wBOzxdR9CouZd9YfuteypzR7t9CqOLN0L03ybhNQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Shally.Verma@cavium.com; Received: from hyd1sverma-dt.caveonetworks.com (115.113.156.2) by CY4PR0701MB3634.namprd07.prod.outlook.com (2603:10b6:910:92::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Sat, 21 Jul 2018 18:18:24 +0000 From: Shally Verma To: pablo.de.lara.guarch@intel.com Cc: dev@dpdk.org, pathreya@caviumnetworks.com, mchalla@caviumnetworks.com, ashish.gupta@caviumnetworks.com, sunila.sahu@caviumnetworks.com Date: Sat, 21 Jul 2018 23:47:46 +0530 Message-Id: <1532197069-24224-3-git-send-email-shally.verma@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532197069-24224-1-git-send-email-shally.verma@caviumnetworks.com> References: <1532197069-24224-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: MA1PR01CA0103.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::19) To CY4PR0701MB3634.namprd07.prod.outlook.com (2603:10b6:910:92::36) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5219223d-fa3c-4d67-9258-08d5ef365a25 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:CY4PR0701MB3634; X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3634; 3:JyZzukh9p4Hk8u5qkYuFw38ywtC2OOb3rwp/XBrf1NegzjUmoUjMxV7N+LkyOb9ugT1BuYB6Fgc71w96VZ7pgW98uEKmwJOyhg5Kh5gv9nzzCczeFgQ6e2y/MARtL1gh5YSg8CWSFimM2uWiJeKyMGv6shC9mR/jyFosI9Ds1YnfSyY747yZxqEW1qBqwffG64+vG7XB6qzemMz2LTOz8waZFCR9GbAT3pk4BMMoSvEbGWuUFdtzIKrvLHMkF8WD; 25:ps/495+B+RH/Q+Kp4Y2hCQZZBNafU4dHxiWIwtsKJgG6F/DX8T9ADmBwpt6i+r+0UXHICS6DzVUr9FmpbKHhTekRHxlkqAdRoy7e8S2R9NEOHPsKMpNn+OotfkMchDclL5df8Khsa74vFxOC0Sc5LKUWKdprV/H9LJ8CDtulEQRORYaFAbDi377WdmxfTYBXWtDXykNSdBbZu7FAqWqUfOsuJzLP2a61KrbQuzTPROJW9UVhm1ynDcZmgz6jQBk7+TFIt8YrIXHpEulwvpxf1CoG9uHH8tWFxn7rU7Y72qqQcXhQcQpIe9N/C/HuKTyy+dWqeRVaj2NIBd6LnCn6aQ==; 31:hTkVn13WYQ2sIDRZKDLNuPXRzRl77Y8Ha+MspWSuDDoy2V9s2Y6jEPtDdT0liGuf9DxjegKESe8K2wW45ixmxdTiXPnYGR7MgV/ZDARFEKX6vuVQtGo78PHeC5gMzWZgdJKGa9IRwhj4umf8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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)(8121501046)(5005006)(10201501046)(3002001)(93006095)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:CY4PR0701MB3634; BCL:0; PCL:0; RULEID:; SRVR:CY4PR0701MB3634; X-Forefront-PRVS: 074040B844 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(136003)(346002)(396003)(39850400004)(376002)(199004)(189003)(69596002)(25786009)(6512007)(316002)(6116002)(3846002)(55236004)(7736002)(305945005)(26005)(4326008)(107886003)(53936002)(16526019)(186003)(16586007)(97736004)(575784001)(478600001)(6486002)(72206003)(2351001)(48376002)(8676002)(47776003)(2361001)(66066001)(50466002)(36756003)(106356001)(81156014)(81166006)(53416004)(105586002)(11346002)(486006)(68736007)(5660300001)(446003)(476003)(2616005)(956004)(14444005)(44832011)(42882007)(76176011)(6506007)(6666003)(6916009)(8936002)(386003)(51416003)(50226002)(2906002)(52116002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR0701MB3634; 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; CY4PR0701MB3634; 23:3QUNBh6oKNBbqQQsBZeoAAmpY2ObmwFeeOP/V/n?= =?us-ascii?Q?EBKmZWnN/5V6rUyIaSKpfESrctb4dbPyal5ASD8Y/6IhUg+0n/+BigR9yYHT?= =?us-ascii?Q?9QbRz1eJzI4c7CcGJrVJyZ5g2WqlBka2wn4hmQqdDeEcpY0XRALa22pLeZz6?= =?us-ascii?Q?prdl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RtfPK/KxBxYY3Ku7fMrPfKARDBxmxv9OJikfswS8XV4NMJM3pZzNgDVG9QykKZhSiuAqj44892fWeqLSzetAjMRul07FHpt1Hj319fAoeBHkkVT6QzkrtvPy+ILtj+YPkEm1P/7oNMekpYoQ5PQ64SsnB02DSwvJjW9mvYYPXBJP1s8DVh+x9NseoMFy5I8P3N9N8pLZIUao8sDRSK2r8Spg1vhuZ+Y4LTZtzs+oB3sLCcYA6/KZ5m3I2h5Rww==; 5:hNPEAJds+1zSdv6rRIKZC8PylP0YVuwMmpgRIN1K8dYFTF12FBBwWcjLH5MiReBdGZ3H0HRkzRrvaK6sQZqifGYh+i0GfQUZWpXdDLqpEeus6hzv/nbUhu6Z8cUebrFHyOsyALRJgAbiesJCRYBSyvoF2w9GbqtSf2uVR5bvdmg=; 7:vF/HLE416CnAk+y/MjcnIVYPLLXLqqQf06zvwU7BeQ7QcZ6hmde68nKa25hxazmFGKMF/6b29VmLZQajftspoqJ3jn5IcB4vdFb89dkfpodWNTd/0Plxevb0ML45utY9UmQUTDfW7h9qnC4o4zeH8iTQO+z2t/6qZBVuSgk6Asrkpf9mezbf0Zdlj8U3oW4wertRXcMkUGDe/i2PMP4xcXXwH8+FkQ5n/lU8p5szDO8mvTACcdH/yTvYlhqrcFf+ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2018 18:18:24.2592 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5219223d-fa3c-4d67-9258-08d5ef365a25 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR0701MB3634 Subject: [dpdk-dev] [PATCH v3 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: Sat, 21 Jul 2018 18:18:28 -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