From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0061.outbound.protection.outlook.com [104.47.34.61]) by dpdk.org (Postfix) with ESMTP id DE0441B571 for ; Mon, 2 Jul 2018 18:57:58 +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=cwN25bk71rt6VBwLIwbyNZsLDh0LgvK98prqFuTIhAc=; b=D9EgJBjyZJxgBKgesDTRrK5YTfWq3bWuNLvVFzO4hfGUUXGuOfFQlRPup012zLlMbz2Gq/4it2ERRs+li+t6mKfyLj1KJCrz5qkJBZlyG7/y51V0UFMTMKh9rKL8NifPyql8HPBbU4D43TZKmorW2b2y5P0s0MgjK7oMN+SdWKQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Shally.Verma@cavium.com; Received: from hyd1sverma-dt.caveonetworks.com (115.113.156.2) by CY4PR0701MB3635.namprd07.prod.outlook.com (2603:10b6:910:93::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.23; Mon, 2 Jul 2018 16:57:55 +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, 2 Jul 2018 22:27:08 +0530 Message-Id: <1530550631-22841-3-git-send-email-shally.verma@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530550631-22841-1-git-send-email-shally.verma@caviumnetworks.com> References: <1530550631-22841-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: MA1PR01CA0081.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00::21) To CY4PR0701MB3635.namprd07.prod.outlook.com (2603:10b6:910:93::10) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6c954a62-cfd8-4d65-3ada-08d5e03cf636 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:CY4PR0701MB3635; X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3635; 3:awmU6Fopcb/8mTgp2wrhXjuW6bI/1aswAISPKo6Hag0ikqCTIyhjomnc8vdXGaNWAoDzOUu90KCYc1DrTDAAvpRzjIjcphz0kG/oeKRf6mWmWSJYrVJCBiAemWb+e+2oECyB3oGbaHITGavR0ogo5+5Yb6xdxKw79Cb7Te1G2M2oI+9aD9nNR1b/9KPAYQn6apa/JxI9Ik2ZGNcvbpTMh3Y2oGjx8eCcc/M1DUZ6yL2RD9laDPKkKsL4UpAhbwmT; 25:0iH0RCMcd8LUzzonJKpSdn2MB8WgXxll5w/sZIw1tGLaqK6Y/7rDN9K+WcOU0ZjynBfP5rrvlaJkR4dZdpuEOfm+If+jrsQ9t75NTg76FHVqXci6nEfSfWlOw4LmTeTstTGUwLRl3r7wdnIeZfRv9d6s4yClrYp9WUl0uGcCa3BDydww9+bM4KcrVVTnKNHgHI7qVririzJH/nrmKTxLS3FE2XN1r3ti69NMLgS/9wP+nRzeGv8VMBsVegiiak7jpp0RvfoU/RCoRJejJ2KAgEQIOAUg95c5uVMS2qEFWJNnIZblACz0ov1Y+GmeQeU/VxGC6vuH/zqlFjCoukSdYw==; 31:2XSy/uPpE8SXcEaK8VO9iZ7dWK6X//J59YMlunZAEyKzeQ4PTMm10zresjDwhnRiZRB//9ytCA6YeNsyFOKWLQwuEBz2y8+pjxazmg6desl1PBjf8gdano6sQpUnMGn46CZ9osEop2yBd2AVw59U0tXfQPvrG3F9eqAQSUx275S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ange-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)(93006095)(3231254)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:CY4PR0701MB3635; BCL:0; PCL:0; RULEID:; SRVR:CY4PR0701MB3635; X-Forefront-PRVS: 07215D0470 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(396003)(39860400002)(376002)(366004)(136003)(199004)(189003)(478600001)(72206003)(106356001)(6486002)(42882007)(4326008)(53936002)(107886003)(25786009)(476003)(26005)(8936002)(16526019)(6666003)(8676002)(55236004)(2616005)(11346002)(6512007)(51416003)(76176011)(186003)(6506007)(446003)(956004)(52116002)(6916009)(81166006)(7736002)(81156014)(44832011)(486006)(305945005)(386003)(66066001)(16586007)(47776003)(316002)(50226002)(54906003)(5660300001)(3846002)(6116002)(14444005)(50466002)(48376002)(68736007)(2906002)(2351001)(2361001)(97736004)(105586002)(53416004)(36756003)(69596002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR0701MB3635; 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; CY4PR0701MB3635; 23:mei1+NXNuF1YXS27kkxR4Fx2nU8V1UAi0Z3drbK?= =?us-ascii?Q?2Lap8sJYcDBccofqAE1wFtZOGMhxvt2qK87d7XrCfe7fuN97Shpdn/aTkudn?= =?us-ascii?Q?RLpQZK8+QOoTYC/kw4YYYMJafqnNNu0AqFd4O07+WmBwbNFohYMsDD0W4SJf?= =?us-ascii?Q?WHf3Ao6Rcv84JmT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XdEumf?= =?us-ascii?Q?QdfoWqWEhcCInV85hU78e/Stda7h8xMPLhDcc8u0PgFthokLrK/Mmo22Ocbn?= =?us-ascii?Q?siCe0z9xEG2ejx6BMWDDBX+GqmRz65ltzSub5I0XrMPjI3G22p9P4E+F6lao?= =?us-ascii?Q?zUtYQBpFSLbp9QQ2GAXQMVVrcKUcdK9Wh1oiS1bQCROjo+kaSLAAlFbAovea?= =?us-ascii?Q?edaBZZuBOx97UaeTuOgqS2RKflxMeZMfy6+12yOzorSfA37IwPtI2KA2sCNH?= =?us-ascii?Q?hkCWITRh3SR/XaWLKVCoIQeXo4QzX2mfqhvByU54mlDCgzeIe9gWpogBRy7H?= =?us-ascii?Q?Cz3NS/D3V/u3nRUYxuEj2lDG6+kc=3D?= X-Microsoft-Antispam-Message-Info: 192M7Cj/IW9NTapTvHl7xMOZs1PWUfkr45Ab3xG/9Zo2NJsyWovzL0AObdOIsVVobUWlaYZb7v4+9nC8nMLpp83PK+5d+fIXyNUmKRTq9aKMHmAIB2bQm/ljIq1Zn3HOBlvZrZZl5Yy7kF6joc/xWe7fjM4aFy6emW2UH9C5EA2gFGM0RH9vuyJcLJm0H96JcuN2wlzM50HXJGYn7pN8P0R/qLMzV0qBaS6TIxl1HmCa6t4pkbl88RcxX8vrhNwyM+3sJCe4PalU+RzXJB+nSpAVeawogpY4F14PY41AxfDherucyu4XZhMfoa8kABpC9Pyq/ffLMs2cbakC/Mp7kxj27yePY6FIF6A7XCzxlV4= X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3635; 6:rIpzzbUzaD5N/NWsIxu3WvjV2yXbwVf5dqjv1fG2TJmQA6JCyj82AkhI/zaNfpv49TQuceYS/0MD/cdWSRgJSzftrIYubdvSj9Zvvdz1AXcJEsW3tzysoCClYYWHtUmF4sLh5lMOWdp+MLe78Au+h4aESPLNhiy+5cuaEyjBmE+Np8mldXa5luunTMCrh3CO3fUPcxns2FyiUg8AeGSm/8+PCWYQuOGgunEdQErS+STPikWZkD6mLEVG5q9Hp6zK8dV6qmMgjYgA3xMDbeahi2Z1kpr/hX2sMqNVrhSMXV8HJRzv3eVkkXRXj2fyzyP329Z+9RXpxQB/jg9WTAgaw5HbWqm61rBc465VsnQ8k3Nahbhg+tugpUH+DXoUyxQw9gAr54qpMONF2e9uFvOGkF/J9+GuRXuOBfxnr32EEde/37M2arbd5s01oDSHiOEm2KNEiGDdHNeisMa4OPEykQ==; 5:IAy85GGvGu/lFz6n2W6E+z3d79177JIz+Y4soi3hzrkn3G3rO56AzmmKcAZ5h399bxLixL+UyuTuLWrWV8LDOsdK6sr21Xp+Njkxvtfdc/+o31ajlhdv/uyeVa8qygkeuPYr5Q3qEZxZgASqEZL9vgeUFPOYaO3fT0ZwKm6qIO4=; 24:/Ieo7LncQwxPfcUU0MNsA1iMoyguvDD0hSezQodaRz5F60y8a+H2HUmIikZz/lk+ONbjTBdhU8RaBY5+PGe7B7WUHEER9jiAJkpI+N6VbRo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3635; 7:EldKBlofhWm6Or8EPBJ5p60rMB1RDAOnzQzuobtEg3x7kjt0Zca62DE7agOzf0uwTrwQcdBf+RIOA9sBZQNxwjNHnmzCYZlYt/GAywSogA4SG/gTsbqYvi/UkOb+JRHLWLS4Hh8PFspG8p8BSppJsn4cGo2leFtp9WKy4fvHxZWj9TJUetCI8bPgcqOd1BKPntxNvg6pQntQRm4maOLzZiKqhoT4vFVBRfM/z+/g7qimZhy6gXW47GQGeDDZagDs X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2018 16:57:55.6128 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6c954a62-cfd8-4d65-3ada-08d5e03cf636 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR0701MB3635 Subject: [dpdk-dev] [PATCH v2 2/5] compress/zlib: add device setup 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, 02 Jul 2018 16:57:59 -0000 From: Ashish Gupta Implement device configure and 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/zlib_pmd.c | 2 + drivers/compress/zlib/zlib_pmd_ops.c | 236 +++++++++++++++++++++++++++++++ drivers/compress/zlib/zlib_pmd_private.h | 34 +++++ 4 files changed, 273 insertions(+) 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/zlib_pmd.c b/drivers/compress/zlib/zlib_pmd.c index f667ccc..c4f67bb 100644 --- a/drivers/compress/zlib/zlib_pmd.c +++ b/drivers/compress/zlib/zlib_pmd.c @@ -20,6 +20,8 @@ zlib_create(const char *name, return -ENODEV; } + dev->dev_ops = rte_zlib_pmd_ops; + dev->feature_flags = RTE_COMP_FF_NONCOMPRESSED_BLOCKS; 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..03b6da5 --- /dev/null +++ b/drivers/compress/zlib/zlib_pmd_ops.c @@ -0,0 +1,236 @@ +/* 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, + .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; + + struct zlib_private *internals = dev->data->dev_private; + snprintf(internals->mp_name, RTE_MEMPOOL_NAMESIZE, + "stream_mp_%u", dev->data->dev_id); + mp = rte_mempool_lookup(internals->mp_name); + if (mp == NULL) { + mp = rte_mempool_create(internals->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; + } + } + 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; + struct rte_mempool *mp = rte_mempool_lookup(internals->mp_name); + rte_mempool_free(mp); + 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]; + struct rte_ring *r = NULL; + + if (qp != NULL) { + r = rte_ring_lookup(qp->name); + if (r) + rte_ring_free(r); + rte_free(qp); + dev->data->queue_pairs[qp_id] = NULL; + } + return 0; +} + +/** set a unique name for the queue pair based on it's 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; + + r = rte_ring_lookup(qp->name); + 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 d4c80b1..dc83464 100644 --- a/drivers/compress/zlib/zlib_pmd_private.h +++ b/drivers/compress/zlib/zlib_pmd_private.h @@ -30,4 +30,38 @@ struct zlib_private { char mp_name[RTE_MEMPOOL_NAMESIZE]; }; +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