From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-eopbgr730077.outbound.protection.outlook.com [40.107.73.77]) by dpdk.org (Postfix) with ESMTP id 707074C8C for ; Mon, 23 Jul 2018 16:51:56 +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=jVA7qaTC5BFNmGR6JQVnGFhXALaf3FAQCSA0sndsOok=; b=VU7b56O0uGlI/oWzvD9/e6T9QPimiRHrr1n7a1+pCXdYLmwtg7FUhoYlkRbqr6mNheBvMghf8b+Fu/WQMGrvaZH0oebB+2SaLakpsuSiJFJL26uannrPCFOIwiDJAktze++wF8v+fmaQMEzuJIRHdAtTwHZ7EH3pvpS4msMPjg0= 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:51 +0000 From: Shally Verma To: pablo.de.lara.guarch@intel.com Cc: dev@dpdk.org, pathreya@caviumnetworks.com, mchalla@caviumnetworks.com, Sunila Sahu , Sunila Sahu , Ashish Gupta Date: Mon, 23 Jul 2018 20:21:13 +0530 Message-Id: <1532357474-9544-5-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: 97715fb2-8aa4-40e7-b348-08d5f0abd4c5 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:MG+MXwAtC24bytT0MZ5GHBP+uIqoaHymagKonp1SUK1uZ4Q1aAI66sYMfjgzbkz4m1M2hEYL0OOTI5Lx3TDHsN2CvPgBDoENNalZbT4WL5n8VwUbEQEWGefJN6hjnvfM1ZnbIvEpiBU22jlUrHYk+c0qMBV4emDl62J5/Rn7CyTExXmom2oHK5z5F6PyLOwVfZqtfxzy0u0Zk7MUOqUuHhw0qk9LR4ZmTVH8hikTM7zXAnrLYsyuNpw2yp8XHbde; 25:Za+Qe7+kykWgJ9FpJnnecbijFACHbx+7LiO6THTSHgErctA+evggkEwb302EJ0sund5MTPhu/FbL7mzE2K2BJMZWR2gnEHaw3ARDhqyTxADInf/q/BG9UOA94yfjQxUSCCnsx0aiMZ2L6IsRJch0OCwh11AIlpKUdWRxrVSbIIFPkJwlbwZCC9+ZAFesEILG+NNj1B6BQYAMtI6JPQqzQ0P2mY45hp7odT+b7GOmp3hoUc5En7wNY+8jVn+BKb7HZ/n3AVH4+dQWUGGxYVBKCDC7+g+FOINcT/RpTqI1lwGvy30NRLQxz54W/7KJs7eEvbDCs3R48cT0wbpyerpFlg==; 31:B3XzlWNOUCV5yImj86OhP7CZzJNnzb4TC50KFGPITqRscdtup+ho3AZOxvaYP0xM+CwfFZ50lP7+PRMU5FzqYadcdeYVwtg9VE24OP1V+8teurLGr8xOaMPKWBzPoka6kO1FlEwYxnwGSnyPavUU/vxcHCxgXqDJly99NIpVm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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)(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)(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:I8hVEdCXpg7QNEwUBEOlnvG0v7EjnuSwIgy3XvH?= =?us-ascii?Q?p1A0dwi5bC6nNqfr6QxWLZhgWqUq4XLUv8aLY6JikTPiAOMFCzJ3tSq4leHK?= =?us-ascii?Q?r1gzCP1XuqMk6jUscS84GJHyjIndYvTFmJS5PLXuheD4GihOu9/FIU8PQiWG?= =?us-ascii?Q?x0UL2h32a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ADLwDzlh4D+9lTvEepbfUwKSAl3N5LJgipLSclnpjKn5WwkHzj+a16tlvWz3rnfPfrhNjXiXOfr169j6Un5oHbVBsKlyepr6NUYluaqFliBK2RIrjvKWDrnWPVpwe30hCKV/PIal0KD2QBWvZLI/1x68xSHlQVMSPWQZ/F6zdJ0ib0s+kZFm4A9j03bjIOpszk8G+ULAw/ugv1xeNV+/uhQfq/SyBNVcgjIU0annvC0zLtsXj2SJgX5WDKAF/w==; 5:uLt79azKbptZBqHeMdoXHFzUIq0+RH27/2rgTPwXvSWRTIIb2YhjoOBs3y5uFh/vBsPCMHZ1W3r9FhNaXBI/AkiL1wm1+W2HpKpwi6VmsTgESwzkI7GG9zsMDzM5uMrm9ZesNpZR0oJWWY5NuQep6KH7JvPhOQHt+KxpUaHy0Jk=; 7:H1bgwo6zm5sXACQUSb0ExkNwZO7q6kzxhtKt1bfNrw1vjxUL7p5v53XDwhzOHdTd7zACWUgPhqAGe+RXWbKM07spzw8Hz8g9+zGnCdrxdhwfCH1RSDTB9rYGXYn0Jya0Z7+1TusOlb9Q9BBwKC34nEughylGrjibUSFnwwqbeLVHW1Zr8e0ROc6duGnxIEt4FaFTGmCvrR39dPoqjXw3aYUMNSRiTzN6ON9+mBUqmykFfjAPVtiyS1HRHmSpJP1M SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2018 14:51:51.9936 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97715fb2-8aa4-40e7-b348-08d5f0abd4c5 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 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: Mon, 23 Jul 2018 14:51:57 -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 | 255 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 254 insertions(+), 1 deletion(-) diff --git a/drivers/compress/zlib/zlib_pmd.c b/drivers/compress/zlib/zlib_pmd.c index 47bc73d..dc1e230 100644 --- a/drivers/compress/zlib/zlib_pmd.c +++ b/drivers/compress/zlib/zlib_pmd.c @@ -7,7 +7,214 @@ #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; + /* Fall-through */ + 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 +229,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: @@ -80,6 +289,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: @@ -101,6 +312,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, @@ -117,6 +366,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