From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0087.outbound.protection.outlook.com [104.47.38.87]) by dpdk.org (Postfix) with ESMTP id 41DA32BF5 for ; Sat, 21 Jul 2018 20:22:18 +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=OI5DapzutNlcRdsg36D1kYvTIhG3tCfKG9yuhbWgaxg=; b=chtDWPhNdTvIzEbStMfDmEROZN1/50uHUrzMniC9E2WaCjqh5CoLD3AmQ1zcnWS8WiRbj1kyfCsk01r14ZMViFLrSz3WFZvcTtkGmJcZa4IujlHjccQb8G7p/KU5tPptppUxbIq4/PbKjAkeUUjhJytT6qS5cVhHpJrpOcS+qhI= 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:29 +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, Sunila Sahu Date: Sat, 21 Jul 2018 23:47:48 +0530 Message-Id: <1532197069-24224-5-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: 4dc49347-2ff8-49db-8ae5-08d5ef365d71 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:jQNrpoNaPZgBew8ZjERL4bxmmPr4JnGeh3hEybSWJrd6U9uZw7dxBgbYuRN9mHVXO7t3+p5SiXfJh4VHL518xM76dZjPBxNYymCK0i3g3Xp1UYysd/XZewrunVoDIakttbUZAxtlJ0/E9U11Wrr85XUvHui3/rqZdEGfsHlcySHEkNr5GoHCYzYcmqFscd+P158qF2j1AULx8QBSqCd8lyOKiMtBn85f9IubQZPH9ImB3FgBzZC4H1k5xO8g8Ngi; 25:i/FO/+tbUb1EnZsHajQhaZCCCDVyHm90e+GYwOm9jtk82Wm8/fC5G1ldRpud4lwiVxlhprPX4gYJMxX2feWL3J1QXByI+TfszSbdfpY0SvUFvBb1CmvX/QRs5QeG254xrkOkv+e174SZ9DDo5UmJwpc8y0dztlH+CwwuCzXRuDQdsegtEj3JXPFYPpsFEWDjmAaIDz09wb7f311bkBCiedkG9ce5ediMCVhkR4zwtMoHFAt5YuAtOK0B52vquHryHs1JddHVCInk8VKmHFJ7+xhNKdz+E25awlN7ev53XbUfxGSx4h96Uf/Sz5uhXXhdKsCBIMwTPQ5T1Owo6K5+VA==; 31:dTu0Lak284p1efPuOmgGq/AmYsOMC+MkLAySIjeztPwWh7BJHGwRzCQbfgoQLAHQiem8U9pN+zRPtG/1Jh43T6eyBBfHhOe3HoyujEqok+QjYNVrNUkFtIcIIGm85qm45A+9WApBhLA2FzYKMfzo54k95Rye6Nj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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)(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:hDaPhPI2wpx5cUORBBkBkx7EOr23H9KiWqdeShU?= =?us-ascii?Q?Z2IfHta0KBFb9YF2y5u3C+J7I+DhM3Gj5wND+f4g0BS0DMCDJm8YqWefWJpr?= =?us-ascii?Q?JKvWS0t5wJOkOGgZ63CwrQRtVjeEZzD76k30r89gxC5PoWTanbrP1rm/h/0b?= =?us-ascii?Q?yZCB+kIKpIIdiwEg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c4JZ3wWAZ43d3gCphmKX9+xzgioJR05CwfZIUybeUmof1mMn00M+2dULy63naokaZEtQYQkUzf03znusg6PXwG+55QDT/OO96w0mtrCadzPZ7gmNPx86KYTQ3bMghDuy4DqMIBXqVd6PPktrDOHMIHIzT4HfQeJnrVJFZ98HN9mbGZGXLd6DHpyPwFHY3ENq1XMaRNady+GJ5j7TiBo0WVf1qLmg==; 5:hpzwe2CEZp1bjeTwflnIgPrXEM0a8ij5KyLvTJixuOu+8ioOyGwYWBUnaqqmu6wcwdmKkN3gEYccWKT9uXDt2kY9ATi1RjinuOLeV/L0y6gv4Wi4bhvBOcR47/bcd1Wudc/fC2LWWfAxqgSiBLPGAUj8itJd0MJZjajVV9xfD0o=; 7:0BAtYr+8BOwhGeutddpsg8PgU5i0C2D8E797sQnquQUsI2TJq2KKYt229cMcdMbguTtSV/OTgZ4MummbHRfD0H82kwj5TEluUoy28YgBBJSf5la0Zogjw+mRQfAi1r7sKli58mAS4fnRa9+0gsInjxQBKB+6+hC8Jyu6tYR6Me1awMRnKXCTQNMpTDKPv3QLc/IA3HPaAiRL6UKQNf9VqHa70OA4ftl6IySpzlSxqY+tAaYyyMzdJwkMzOPzd6Ll SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2018 18:18:29.5401 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4dc49347-2ff8-49db-8ae5-08d5ef365d71 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 4/5] compress/zlib: support burst enqueue/dequeue 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:22:18 -0000 From: Sunila Sahu Signed-off-by: Sunila Sahu Signed-off-by: Shally Verma Signed-off-by: Ashish Gupta --- drivers/compress/zlib/zlib_pmd.c | 254 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 253 insertions(+), 1 deletion(-) diff --git a/drivers/compress/zlib/zlib_pmd.c b/drivers/compress/zlib/zlib_pmd.c index 9a464ee..44baa67 100644 --- a/drivers/compress/zlib/zlib_pmd.c +++ b/drivers/compress/zlib/zlib_pmd.c @@ -7,7 +7,213 @@ #include "zlib_pmd_private.h" -/** Parse comp xform and set private xform/stream parameters */ +/** Compute next mbuf in the list, assign data buffer and length, + * returns 0 if mbuf is NULL + */ +#define COMPUTE_BUF(mbuf, data, len) \ + ((mbuf = mbuf->next) ? \ + (data = rte_pktmbuf_mtod(mbuf, uint8_t *)), \ + (len = rte_pktmbuf_data_len(mbuf)) : 0) + +static void +process_zlib_deflate(struct rte_comp_op *op, z_stream *strm) +{ + int ret, flush, fin_flush; + struct rte_mbuf *mbuf_src = op->m_src; + struct rte_mbuf *mbuf_dst = op->m_dst; + + switch (op->flush_flag) { + case RTE_COMP_FLUSH_FULL: + case RTE_COMP_FLUSH_FINAL: + fin_flush = Z_FINISH; + break; + default: + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + ZLIB_PMD_ERR("Invalid flush value\n"); + } + + if (unlikely(!strm)) { + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + ZLIB_PMD_ERR("Invalid z_stream\n"); + return; + } + /* Update z_stream with the inputs provided by application */ + strm->next_in = rte_pktmbuf_mtod_offset(mbuf_src, uint8_t *, + op->src.offset); + + strm->avail_in = rte_pktmbuf_data_len(mbuf_src) - op->src.offset; + + strm->next_out = rte_pktmbuf_mtod_offset(mbuf_dst, uint8_t *, + op->dst.offset); + + strm->avail_out = rte_pktmbuf_data_len(mbuf_dst) - op->dst.offset; + + /* Set flush value to NO_FLUSH unless it is last mbuf */ + flush = Z_NO_FLUSH; + /* Initialize status to SUCCESS */ + op->status = RTE_COMP_OP_STATUS_SUCCESS; + + do { + /* Set flush value to Z_FINISH for last block */ + if ((op->src.length - strm->total_in) <= strm->avail_in) { + strm->avail_in = (op->src.length - strm->total_in); + flush = fin_flush; + } + do { + ret = deflate(strm, flush); + if (unlikely(ret == Z_STREAM_ERROR)) { + /* error return, do not process further */ + op->status = RTE_COMP_OP_STATUS_ERROR; + goto def_end; + } + /* Break if Z_STREAM_END is encountered */ + if (ret == Z_STREAM_END) + goto def_end; + + /* Keep looping until input mbuf is consumed. + * Exit if destination mbuf gets exhausted. + */ + } while ((strm->avail_out == 0) && + COMPUTE_BUF(mbuf_dst, strm->next_out, strm->avail_out)); + + if (!strm->avail_out) { + /* there is no space for compressed output */ + op->status = RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED; + break; + } + + /* Update source buffer to next mbuf + * Exit if input buffers are fully consumed + */ + } while (COMPUTE_BUF(mbuf_src, strm->next_in, strm->avail_in)); + +def_end: + /* Update op stats */ + switch (op->status) { + case RTE_COMP_OP_STATUS_SUCCESS: + op->consumed += strm->total_in; + case RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED: + op->produced += strm->total_out; + break; + default: + ZLIB_PMD_ERR("stats not updated for status:%d\n", + op->status); + } + + deflateReset(strm); +} + +static void +process_zlib_inflate(struct rte_comp_op *op, z_stream *strm) +{ + int ret, flush; + struct rte_mbuf *mbuf_src = op->m_src; + struct rte_mbuf *mbuf_dst = op->m_dst; + + if (unlikely(!strm)) { + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + ZLIB_PMD_ERR("Invalid z_stream\n"); + return; + } + strm->next_in = rte_pktmbuf_mtod_offset(mbuf_src, uint8_t *, + op->src.offset); + + strm->avail_in = rte_pktmbuf_data_len(mbuf_src) - op->src.offset; + + strm->next_out = rte_pktmbuf_mtod_offset(mbuf_dst, uint8_t *, + op->dst.offset); + + strm->avail_out = rte_pktmbuf_data_len(mbuf_dst) - op->dst.offset; + + /** Ignoring flush value provided from application for decompression */ + flush = Z_NO_FLUSH; + /* initialize status to SUCCESS */ + op->status = RTE_COMP_OP_STATUS_SUCCESS; + + do { + do { + ret = inflate(strm, flush); + + switch (ret) { + /* Fall-through */ + case Z_NEED_DICT: + ret = Z_DATA_ERROR; + /* Fall-through */ + case Z_DATA_ERROR: + /* Fall-through */ + case Z_MEM_ERROR: + /* Fall-through */ + case Z_STREAM_ERROR: + op->status = RTE_COMP_OP_STATUS_ERROR; + /* Fall-through */ + case Z_STREAM_END: + /* no further computation needed if + * Z_STREAM_END is encountered + */ + goto inf_end; + default: + /* success */ + break; + + } + /* Keep looping until input mbuf is consumed. + * Exit if destination mbuf gets exhausted. + */ + } while ((strm->avail_out == 0) && + COMPUTE_BUF(mbuf_dst, strm->next_out, strm->avail_out)); + + if (!strm->avail_out) { + /* there is no more space for decompressed output */ + op->status = RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED; + break; + } + /* Read next input buffer to be processed, exit if compressed + * blocks are fully read + */ + } while (COMPUTE_BUF(mbuf_src, strm->next_in, strm->avail_in)); + +inf_end: + /* Update op stats */ + switch (op->status) { + case RTE_COMP_OP_STATUS_SUCCESS: + op->consumed += strm->total_in; + /* Fall-through */ + case RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED: + op->produced += strm->total_out; + break; + default: + ZLIB_PMD_ERR("stats not produced for status:%d\n", + op->status); + } + + inflateReset(strm); +} + +/** Process comp operation for mbuf */ +static inline int +process_zlib_op(struct zlib_qp *qp, struct rte_comp_op *op) +{ + struct zlib_stream *stream; + struct zlib_priv_xform *private_xform; + + if ((op->op_type == RTE_COMP_OP_STATEFUL) || + (op->src.offset > rte_pktmbuf_data_len(op->m_src)) || + (op->dst.offset > rte_pktmbuf_data_len(op->m_dst))) { + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + ZLIB_PMD_ERR("Invalid source or destination buffers or " + "invalid Operation requested\n"); + } else { + private_xform = (struct zlib_priv_xform *)op->private_xform; + stream = &private_xform->stream; + stream->comp(op, &stream->strm); + } + /* whatever is out of op, put it into completion queue with + * its status + */ + return rte_ring_enqueue(qp->processed_pkts, (void *)op); +} + +/** Parse comp xform and set private xform/Stream parameters */ int zlib_set_stream_parameters(const struct rte_comp_xform *xform, struct zlib_stream *stream) @@ -22,6 +228,8 @@ zlib_set_stream_parameters(const struct rte_comp_xform *xform, switch (xform->type) { case RTE_COMP_COMPRESS: + stream->comp = process_zlib_deflate; + stream->free = deflateEnd; /** Compression window bits */ switch (xform->compress.algo) { case RTE_COMP_ALGO_DEFLATE: @@ -79,6 +287,8 @@ zlib_set_stream_parameters(const struct rte_comp_xform *xform, break; case RTE_COMP_DECOMPRESS: + stream->comp = process_zlib_inflate; + stream->free = inflateEnd; /** window bits */ switch (xform->decompress.algo) { case RTE_COMP_ALGO_DEFLATE: @@ -100,6 +310,44 @@ zlib_set_stream_parameters(const struct rte_comp_xform *xform, return 0; } +static uint16_t +zlib_pmd_enqueue_burst(void *queue_pair, + struct rte_comp_op **ops, uint16_t nb_ops) +{ + struct zlib_qp *qp = queue_pair; + int ret; + uint16_t i; + uint16_t enqd = 0; + for (i = 0; i < nb_ops; i++) { + ret = process_zlib_op(qp, ops[i]); + if (unlikely(ret < 0)) { + /* increment count if failed to push to completion + * queue + */ + qp->qp_stats.enqueue_err_count++; + } else { + qp->qp_stats.enqueued_count++; + enqd++; + } + } + return enqd; +} + +static uint16_t +zlib_pmd_dequeue_burst(void *queue_pair, + struct rte_comp_op **ops, uint16_t nb_ops) +{ + struct zlib_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 zlib_create(const char *name, struct rte_vdev_device *vdev, @@ -116,6 +364,10 @@ zlib_create(const char *name, dev->dev_ops = rte_zlib_pmd_ops; + /* register rx/tx burst functions for data path */ + dev->dequeue_burst = zlib_pmd_dequeue_burst; + dev->enqueue_burst = zlib_pmd_enqueue_burst; + return 0; } -- 2.9.5