From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0061.outbound.protection.outlook.com [104.47.36.61]) by dpdk.org (Postfix) with ESMTP id C88377D08 for ; Tue, 15 May 2018 12:33:02 +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; bh=d8cE6D4fp0fGNm+AGC0mikFsCg+urXzYZofajM8Ml68=; b=LgYNn0PyyBTsze1NACh4C2dP0l+QN+t+c2qVU0Buwz70ompHC23cFq2byI2ROyv7zue9YEiO/QtXVVFKrJYW61THWSC3HWQ7WeQC5gSTMbRIXqlGCigZp+bL4YKYDiljg7sH6PpEQGCsAh19C0lwMPeIcwRdiqH4X9KfU5FHEKs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Shally.Verma@cavium.com; Received: from hyd1sverma-dt.caveonetworks.com (115.113.156.2) by SN4PR0701MB3646.namprd07.prod.outlook.com (2603:10b6:803:4d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.755.16; Tue, 15 May 2018 10:32:59 +0000 From: Shally Verma To: pablo.de.lara.guarch@intel.com Cc: fiona.trahe@intel.com, dev@dpdk.org, pathreay@caviumnetworks.com, Sunila Sahu , Ashish Gupta Date: Tue, 15 May 2018 16:02:22 +0530 Message-Id: <1526380346-7386-3-git-send-email-shally.verma@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1526380346-7386-1-git-send-email-shally.verma@caviumnetworks.com> References: <1526380346-7386-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: BMXPR01CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:c::19) To SN4PR0701MB3646.namprd07.prod.outlook.com (2603:10b6:803:4d::12) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(5600026)(2017052603328)(7153060)(7193020); SRVR:SN4PR0701MB3646; X-Microsoft-Exchange-Diagnostics: 1; SN4PR0701MB3646; 3:8/fARUQQpCHcLqG5Tk6bJjicz7Q8ChlhPMbZQB30AaiLe0CPyt+ZL6ynKNwrs3xWTOxinjkI7qEQ43mfWf5KxkA+D4Dnt4M5WgX36DOZ1CQzcbmr5pSQZnhx/EgdGV2apSogcNvmnPeGVQOrLO5O10E7NdgbUMQTul2pKjkI28X7suJnfdSUqrYbcAyZpV9s6Ck7dG2eTFGTZqsxQr5SMEqzmZvgZoCZudOnMXRenh+6Elr+K7oNV7XzTMCeDcGH; 25:0LxJUaXIWfE3Sq5HEuvDCFgeqVQEShuFUCyyf6px0ZGhvHG/mKCr0reX4xCV1dcGQ95cduwsSfnm2e6p/3wgcT3t4T8SEqwEgg7WOYQQEYUJ9Y/Nupt050kdwhMGlzHb1Lzl3jWiRQ3PVbKT8gCxs1c/Nx7Ar/EZZHy0j4zjk4ZhbwnXOwaUQq5j8gvGEkisQxB8adEcWrxFDCo/nxYpFuatn3p9leB7NWZO/PFPSDPoCDCK/Xvvgzs67N2gn7i42rpFtF+HNliCiPBzYUUGfnfHECTelp4ULf+Fhbf5VKTKt2PQ5v8PWrSLZVrzq2qPR0Zox+rf9nZGoKfFTELfpA==; 31:9aOKep6+3TuoRuMzKrYYs8pFcMXHJX9ypP6FPDXZI8UzHiaoMDwcueeuf0FUlQn5+dkc4z/qTdH5OfH6OYqU1+3hxksImwiLeLP9JPoz+H4ReHHlTBH+xECteB9i15W6r/Qxt9aOYnUKa3zuQnLmepQUZyNRIlpD5HzDF83cqRwHf0CPTfTjixZX1woP4wspSesKq9qBX5xQ1fvgjXPMUKDgkZcARHEwKsH9paoe8e0= X-MS-TrafficTypeDiagnostic: SN4PR0701MB3646: X-Microsoft-Exchange-Diagnostics: 1; SN4PR0701MB3646; 20:vGbRKj2kaGukeWNXJ8A1X/qzNFAUnHMOxMH63ShA4UbS6oDwKxhLE0hw81YjfnomObMcNMlk+l2EJqtXfjFckxA/BqZzmQ9AUXZqN3ECc+Xh8d9kiA9kbANX+2ahnLynqNrK+SzIPN9bXyhyjsOX5OOB0OFvdh9ToYuSwGQGfr1sxq5ZG8+BRQ6M9Qd/Qll4oVm9u2VCMSfNqPEEi8gTgc8InBXwhvlFMN/q4Ngahyn+oo4XWJqWq4E7qwF0Xz1h1dWTAl/NAvzNKnd7rEPa7BzJQ9BiyZn5hUPsVpyEpqgFjFsXXP1bmpGZWhmnRmkrZ0EAkCHnAmzvN+IQ8cMeerUawRaldRX4ao3Yss8idFjaZOq7d+CKMgdihPhftmOYo5H8ohzNDvhAR+J7wDI/YIFLCOrgTenHzlyAcO61iP6wqKseLIGN2238DJqDBW8Fccs+GWfM8HKh3a0UUrKO0zhNeloYUugcYRiVYHAyLCUtA0Pes7PmlRnCaN+ki/4+kxGGP4K+pYqrYP6iENeVc/xl4/38iiEhWMBL3zQ1kmostfWd6F5oWBHyPI48YOkTo/oxAO4ym/4qqG4vAqokEwUWcKXg9KxBoeHcOXAk5+Q=; 4:8SCG3G8wGvctdY/orLIaqfnu90a/lDRVoLHBnNIsCAj59YHgqhB/TU4E++eoyMljly7I9uSn5sgBeiSmJpgKVw7n0miKOjaJmgezRmLL80FjW/TmBh5T7ZidZipSbFu4i36mWRFqL/vl8CYxSefcStBio1L9zF48U5MdZPOWshXx06IymJrJfXgoE6ZOEbytq9f/hMHIz52OxJ7GfEnD41z+r8w8BZLit9Cd9Xr9N2SIRK3bUfz2p84vo5AEW17g0kkgYiTrz5xPt5BAJ4/t+Q== 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)(3231254)(944501410)(52105095)(93006095)(3002001)(10201501046)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011); SRVR:SN4PR0701MB3646; BCL:0; PCL:0; RULEID:; SRVR:SN4PR0701MB3646; X-Forefront-PRVS: 0673F5BE31 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(39860400002)(376002)(366004)(396003)(346002)(189003)(199004)(478600001)(486006)(55236004)(44832011)(16586007)(54906003)(316002)(47776003)(2906002)(59450400001)(6506007)(386003)(8936002)(66066001)(6486002)(72206003)(6116002)(3846002)(25786009)(97736004)(5660300001)(42882007)(50226002)(36756003)(8676002)(48376002)(53416004)(52116002)(107886003)(26005)(50466002)(2616005)(81156014)(105586002)(81166006)(2361001)(53936002)(6666003)(6916009)(4326008)(16526019)(68736007)(476003)(446003)(956004)(106356001)(76176011)(186003)(7736002)(2351001)(69596002)(6512007)(305945005)(51416003)(11346002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN4PR0701MB3646; H:hyd1sverma-dt.caveonetworks.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN4PR0701MB3646; 23:D97ilp24s3ymMKsWJXmoDlrtOQEiDr9QzAxxlft?= =?us-ascii?Q?ROzdXWjCVEnXxyhR0ltlfW3bSln9eQ9KjDuqymHI8zo5eoC69avfU911BlGH?= =?us-ascii?Q?H3vL6eOZWEWPZjhoFeuAdcNUvRlsLWXJffylAaRNhC6ZtHsXnNcxjut9MBd/?= =?us-ascii?Q?6p2RsH6rjxiHCwNxJnZO4sKXk11fRVXrBgSC0SmuKObOfEOd+GN65EQhbTzS?= =?us-ascii?Q?uESc85nW7ftKbQ22UTV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zw==; 5:2gPIEJ6Lse0lzUgUzQL4meqgInxJ5HJwVI7KMQknPy/ern13wJ6RSDI+VjNlwEXzEFakE0vZGhKGDH1J73LK6s0WEoba89jt7ro7ey1N7aoKBFm/sYRLdUUpGQ7R5neAeuV0g/6MOyaEau69Me2CWXqZ+J1IlY8S57H2JmMDbo8=; 24:smb8DN+RVXVgitwIU+RPlpMeS+3R9HapAbEW3H194hpbZr6+ZdUw7ltqtLxPdvpy0OhT1I/2c0Gn+QNn2mItvROAgdBl73xwEqfrJcJI2d0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN4PR0701MB3646; 7:vGXMVyKdBsOcbS+4fywhxK+exDxZ7MFDtLH+RYSS+7j8C3QVFd8vlSQxhGJG6u+oU+8J5OBFyVcIEDWIRudqo6re0Yd7VyJ9bpGSnvjIT+gQiRo2t/pya/CIubdk0mF+ciKrvON2N6EfA72sJ1AqIDTpDIb5MU6GMyWPTQ7lwXIQvhK3xiuMcK3CqS4YPaMVKj/qjk3TZ3UASuESabJizdZ2qDBuv0+seRAaES9d6EZeU1o3DBRpK9tnWA5ODMAe X-MS-Office365-Filtering-Correlation-Id: c8e4fc17-087b-4f23-a211-08d5ba4f3bff X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2018 10:32:59.2397 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8e4fc17-087b-4f23-a211-08d5ba4f3bff X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR0701MB3646 Subject: [dpdk-dev] [PATCH v1 2/6] 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: Tue, 15 May 2018 10:33:03 -0000 Implement device configure and PMD ops Signed-off-by: Sunila Sahu Signed-off-by: Shally Verma Signed-off-by: Ashish Gupta --- drivers/compress/zlib/zlib_pmd_ops.c | 238 +++++++++++++++++++++++++++++++ drivers/compress/zlib/zlib_pmd_private.h | 77 ++++++++++ 2 files changed, 315 insertions(+) diff --git a/drivers/compress/zlib/zlib_pmd_ops.c b/drivers/compress/zlib/zlib_pmd_ops.c new file mode 100644 index 0000000..0bd42f3 --- /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 + +#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_SHAREABLE_PRIV_XFORM, + .window_size = { + .min = 8, + .max = 15, + .increment = 2 + }, + }, + + 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_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_LOG_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(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); +} + +/** Close device */ +static int +zlib_pmd_close(__rte_unused struct rte_compressdev *dev) +{ + 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) +{ + struct zlib_private *internals = dev->data->dev_private; + + if (dev_info != NULL) { + dev_info->driver_name = dev->device->name; + dev_info->feature_flags = dev->feature_flags; + dev_info->capabilities = zlib_pmd_capabilities; + dev_info->max_nb_queue_pairs = internals->max_nb_queue_pairs; + } +} + +/** 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_LOG_INFO("Reusing existing ring %s for processed" + " packets", qp->name); + return r; + } + + ZLIB_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); +} + +/** 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, + + /* TODO:Check if no q-pair count needed*/ + .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 new file mode 100644 index 0000000..d29dc59 --- /dev/null +++ b/drivers/compress/zlib/zlib_pmd_private.h @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017-2018 Cavium Networks + */ + +#ifndef _RTE_ZLIB_PMD_PRIVATE_H_ +#define _RTE_ZLIB_PMD_PRIVATE_H_ + +#include +#include +#include +#include + +#define COMPRESSDEV_NAME_ZLIB_PMD compress_zlib +/**< ZLIB PMD device name */ + +#define ZLIB_PMD_MAX_NB_QUEUE_PAIRS 1 +/**< ZLIB PMD specified queue pairs */ + +#define DEF_MEM_LEVEL 8 + +int zlib_logtype_driver; +#define ZLIB_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, zlib_logtype_driver, "%s(): "fmt "\n", \ + __func__, ##args) + +#define ZLIB_LOG_INFO(fmt, args...) \ + ZLIB_LOG(INFO, fmt, ## args) +#define ZLIB_LOG_ERR(fmt, args...) \ + ZLIB_LOG(ERR, fmt, ## args) +#define ZLIB_LOG_WARN(fmt, args...) \ + ZLIB_LOG(WARNING, fmt, ## args) + +struct zlib_private { + uint32_t max_nb_queue_pairs; + 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; + +/** Set ZLIB compression private-xform/Stream parameters */ +extern int +zlib_set_stream_parameters(const struct rte_comp_xform *xform, + struct zlib_stream *stream); + +/** Device specific operations function pointer structure */ +extern struct rte_compressdev_ops *rte_zlib_pmd_ops; + +#endif /* _RTE_ZLIB_PMD_PRIVATE_H_ */ -- 2.9.5