From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0074.outbound.protection.outlook.com [104.47.34.74]) by dpdk.org (Postfix) with ESMTP id 18C681B59B for ; Mon, 2 Jul 2018 18:58:05 +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=1/sWABGiYtF7oOQntejsw7sAJYxutnTddlhPDAhLg7A=; b=HXbd8udGrRmtNXlseRidZPGnWwh555cwkgZem8wuXMpVmj7ynu0PtVFtHvbj5B7yrDH5GgUWrEpBZ33tAXsO1fnEoMTYJRtvpcBnzNWBXco8ygs7Lv1sImO3cVP4l/anQGQGU5k1sD8j3XFFshsGwx19wAUUm60o5owLFKwKtlg= 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:58:01 +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, 2 Jul 2018 22:27:10 +0530 Message-Id: <1530550631-22841-5-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: 1e0dbbad-0d59-4620-72cf-08d5e03cf9ae 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:1D31K5+woISv4VO+u2xoC6MKEZSEVJg056FkYoInRvp3cVk7X//MWy+hL05JY9ZMu5idbUpMEy9pXWCKKnq829i7w1SKgxaEHI5AuDDhEp2fJAOgoRSNLhV70ebQJn4BR1KDMbrFqfpe/+XbARffb76wZs2VTK5EEOoh1hXN24/xF2e3ioYGsmRypIKo8bg/fbzw3vBLGOkroErxBlEMhdLMgBX3qhCuMevMp1yk0zI46AsVW54oL3HceU5LYhmX; 25:saR/Srrameksz9dJfV0he+ASFKG3DG/K4lqTcT6slgECQMNlqvBX0O3E7A07N5nzzHFLxvSwsrvknb30iLEYBf+JXirzV7Jfu7fXUcFXuR264olx8R3dqocUlCsTsNNDgrLiC88mYJVgEl/D/7IZwf+5PEY2FTDXQMO6Y99t8Ba6MiABXaywAeJ3Wvt9Nfcy5Gh1TUQtGb4HOqQA+vIMkfA4DnfTrvFVZ9m91vcUcunvSRO/UQJcjvlpVQ54riiNziRJLGOladc6uUajSmcCfwG/apZFPM+nxlt/UrXv8xFYVit6bTxAxKtoDH3yL97LHrk0qQqzUkeDW3B4tCozZg==; 31:KRy2qTQrZehFred3gtQxQDelWjpVx14UzXsjZUa+iN1r8DYded8loeLkpfG3eMea68Np92xC6XlKnDgrEv0C8DkHvds+KH5C6abFtypyTmXy+DBOFB+M3TyL8LJ0DTm5wRO/dAWxLdi/dqygpgTSVprUUDxvpqX3YR6NXBYPnOa1ErjbjXR8OnRaXerh3fuMwMVfsXTUHvzUY+AnwRbRRRIVk+q+JzGT3SHddbnpsYM= X-MS-TrafficTypeDiagnostic: CY4PR0701MB3635: X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3635; 20:4siyPdthwwcyb1Mfp2u1tpH++lkX60BYOfxe14fpuQsNF+Q9dWxSZQPU6im9yBUGdGOph9uzCDZKYBwRhhVeoGnx/Fg+cydozuetS5zr69yfdxwlcN5qWCFO/DAmL4mzv9nlO8Bk0Zxk0UtxE9KXUkp3zAg9CJNoL18vha6vF2vfBdV8ClkGIKRu+QvWYuvb/qJN03GUt9CTZme1Zvkv3KKwOIJ64CmrttTyS1i92Zwv5MEpRQ502bUpLcQYd4EydmCT8cLCxoDpv8SDugPfZ0eGpOGMXLijSJpKvKKLGbVAuplMuOQB4UBYq+ZYpQQ0iGVQY7PAtO+CcGz/jfDNjAsiYPvzyXS7QkQn+JzVPIqBqUzuZCYqToVNZcUK2czgIHjNVCGEScXYnRm6s3RaPDn00fwtKouL3oPPE2Ln4IUJHJR89dvnQcvAODgweIc6eZK7JHQHUrG6/zRpi1q4MnlT9O+YaC7OL50U6P2hpBZfTw6Gn2XqKQUfazcdkYCxgqXOzMrENZswxfbq0cYchPN5J9o6wbh9TWMWzPU6+rIc6WZqZsWycll/slJCBvq/PX8nlyisioPdr0b5OPr/Uxv7jLyXl28eyVHz2KKgC08=; 4:MatSQJ3H6Rmt2E3Oa1qAN5OmLicLa/+pWSggXGCSuC/0wWHRiXypw1YlJtP1zgACoSbBR8YVqh2/NIQmoENdcHDxdPk0rDVy7cHhhehNn7Gvrt2JWfMUzP+51WE6r+J+EXgtTsH8SNPHQELD0f0QzDY6saDsckQSGhkwCBQj8jS7SQ9SiexQ7jxwcEPOnza1FZpF8G1jeXEGuMZLbVmInS19/DwWbkGU5LXXJ/LaWk651yRQ8Ca37MpquWZDj8lTwHL2VG5Elm2ePGYI0b3hmg== 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)(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:WAHi6hLn0LPlfZSmfkMpTn5ESoZgNFhEyPXjLOo?= =?us-ascii?Q?nRSboEGNj+EK8ewRYqexsoWRKrjiQW2oCZUG4mTzlKfmT/VnVM0WA2RD0xS2?= =?us-ascii?Q?/4mlyLyu5XSBpxcs01yWhrzSyeKbrLk/fE4h8w2modE5ta5CFC1xMM8x6jaU?= =?us-ascii?Q?FFvzKgzTgSUUgaHE7wNmPUbZ5fRcffBBM1crkK1M1SXuvfkxeZREabMsZufm?= =?us-ascii?Q?z78ypNx9qlikYr4IUwwpbOo8f5kv+qcjKz2DrS8ZqbIrEr0gH5lPa7f5RzqG?= =?us-ascii?Q?Lo8up87XOGG6KWf+WZSdZgaeNY37bdrEjN5N8pqvcNxUZu+2EgqImQRxzCch?= =?us-ascii?Q?YBL9QNAQBIQqmzwBbmUoq5HdvYjZ18yvxjkzRbnYtN8pGF/LLMjYTLeXTCYA?= =?us-ascii?Q?SWXKyLTBLaDhcRGvylVrS/2AEgmyrO63nrEnSusksXxf0Ym9o5SSnKhfK+94?= =?us-ascii?Q?PxVcvHePk+U2V6Cdkfq+XB/naFayCuTFwCvoz4a0K7qSm0obFzUIFI3IM02h?= =?us-ascii?Q?hKPSCW5+BkoX/2lrGuLhQNtYaUvrIyYq8R5GSSjolxBreket27VMDV/P930O?= =?us-ascii?Q?KeN7Z+eDun00uiDd4+rWyIlOk01lChfNxGzA05Z6f3RqwobL4ysGd5ShfPrW?= =?us-ascii?Q?RTME7FkhLYAanT4dTNlLZBb86IbosstTYG9mTXZ9cZogyuJZ87Zi/YEa4R7h?= =?us-ascii?Q?jZ7aX6d5yGw9kUf+fFazwXQwFtUiQDQMYBaJ7FxVtkv8v9+MpbdtcOZIl7j2?= =?us-ascii?Q?1EZvV5wp02pxsbQIrjIKe3JorEfS//yLuZ9kQ8JAHmrypYBX2oW2+XFK0NkE?= =?us-ascii?Q?fKQfb5rnt9Uu0pY+9biBIBHS9AKo0SkrqeHRKSe80QisEaqlXx46rtwI3v43?= =?us-ascii?Q?5vPOu/4k1QO9QiQrf9BI8YQqviXDrstiMn6ofGplu8EZWDzAG+9TIYliRGUL?= =?us-ascii?Q?+YDT3blGrpddnim3XJ/yElF9OU7SF84vQWO6b26ob67N86VuDcfotgc0p/nV?= =?us-ascii?Q?UGpD7PiNJfD0Dz141lvLxZEUgPQNmC0BmaUH1e1PMFa/ix7Sw4ZMpKshhhdv?= =?us-ascii?Q?uuhbpasUuLWxhhMv/mZmCpP2EtEsdO+dQknBY8S2e3Ff/0BuNV0HjyyWBP4Y?= =?us-ascii?Q?94A8Gd6xVDGyb3qMKiqmpc1kxaSgtf5vxztGlIPAG2aNFVgVelkDFhyrWVj6?= =?us-ascii?Q?Icb8zt5eLyC9PjjNZw3qYR5hnUEi29S+/beEV1enaywf5etlpCb2zYauuNtB?= =?us-ascii?Q?IJpILVJ6ERoOITVgN/zVQZ+xS7jo2gDtDUXKQbo/La+z0hGJ5t2lqUxPmipU?= =?us-ascii?Q?zczdyVH0u/kvyz6vu7Sw31PBj3nH5lUjwbk4ocKuKSfQ+Pir6J4bUub3M/6E?= =?us-ascii?Q?g1/QSeN/eGcm8a7tNvURlYUMD7js=3D?= X-Microsoft-Antispam-Message-Info: sN5BElWqaDGfAertHUTZNMSNAFqqj0gjBYnx0L2EQxv7sADXG5moVkQSfPffq/eA2S6SXY9qgcqI9GBknzPsOBbdyJL6mJQ4BO30nyHi4AsLYA5z0sEkiU48h65PjudUNro43m/hGGZkdKwsFfH4Mi9bitbgVcDzuXf94Mjxr/nQdQRvrzyHpv6YCEnmO1N8QIsfV7RADf5XUY4j2fapC5tf/ei5SAmN7dY0d4WqcdGyqmdd/EchvtusPuEdmeMiAAiwUQs49Is8XkGnRColiPvPHIStezlwAXosT/QF4UGxAjZt/HTag1WK9eE7zFfUaLfzbCyf5beIwZFfoSB1GezmAN526N2wXxuyjzxOjYY= X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3635; 6:Jim5CaR8qw9TzMNd4lL3+J55dlq1nWAEq/Z+pPyuEIO2FLM1XSEFhy0ovIzQIuawEVwaI1g1abp3VfVznGZNh7jpgo5JHxRsOmXEDIc8LQAPeYxgCYfav2jfONUuu6MHIgRYkFcZeJMbp0yqV+FelXNn7M9+SGd78wDDWSssG8xFL88Ecm2iV+eowaHU872SAXNK/V0RgGsOoMXGo9B/bqgS4OyYR6JO9CpeiwohJsd61vCb9jn/g48FQ786X8PUM7rnp4h9/IFq4D/zUsRuAHxcf46DiLE3dkIZFw1WjnGNxCLyeE5lZ++B4ewOXHUxusz213ZMTPJBrP9iGdOzJlyvNnio3aMw1UJTvDiHfox+9tWQNcAWi2hPfSt5Dy8kDSEg48JPGhdHtzI+kIBwKC5V0Ig1E4X9p5s0XPrvm3YJFyPaxF+ERWYFAuTklGrAxZNe9hYxeAV+/Xf7PvSeiQ==; 5:ja990/bciaO6Koc+IqYjSf+V0nM9htmFcIHOifDA2TkrwRMhPls6RhTvwUrz/v9BSBzqiO8XlnwZPfeeazHbEpVJy77ZUIAqEVgi7jNTbmm1Tz7aBV7N8eeI0pDF4b/g28WqbU0aj17ewlCEOgSa34krSSoKjWC/7lcvRkJ5TnI=; 24:yG4xtjhy1prTbczVMo4Ke02uibY/QHLmFIBLZFmTd/RTZzhmpyiyLG04F7ArdwhBaHyqpDEW3mwl6rjlc99QqWRGjuzeVkyWpcj6cJlqnas= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3635; 7:BEIvYCM15UyzS+9GeA6yC832JZg6LtoSFmVFXxD6fol0veXrfm9u1TB6IrHlNF8LfT2paTpDRUt1mD8ZKMhQRZF2IgNN8mW+4XOrHMRZr+4RlA7GB3l/3clKqTeTz3MQaRDX62K/+RM37vo4gawdYQOWS9UspELjy6WqESL29EQW2Rld4rRkzAjvhsFv3l9gEZln1SeX23eHGxyJM87iAsQYrw9r++5PEVn/DAPX1nqz5XwcKhkuFj/lFaDvxTQ2 X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2018 16:58:01.1846 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1e0dbbad-0d59-4620-72cf-08d5e03cf9ae 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 4/5] compress/zlib: add enq deq apis 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:58:05 -0000 From: Sunila Sahu implement enqueue and dequeue apis Signed-off-by: Sunila Sahu Signed-off-by: Shally Verma Signed-off-by: Ashish Gupta --- drivers/compress/zlib/zlib_pmd.c | 238 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 237 insertions(+), 1 deletion(-) diff --git a/drivers/compress/zlib/zlib_pmd.c b/drivers/compress/zlib/zlib_pmd.c index 7c2614e..aef23de 100644 --- a/drivers/compress/zlib/zlib_pmd.c +++ b/drivers/compress/zlib/zlib_pmd.c @@ -6,7 +6,198 @@ #include #include "zlib_pmd_private.h" -/** Parse comp xform and set private xform/stream parameters */ +/** Compute next mbuf in the list, assign data buffer and len */ +#define COMPUTE_BUF(mbuf, data, len) \ + ((mbuf = mbuf->next) ? \ + (data = rte_pktmbuf_mtod(mbuf, uint8_t *)), \ + (len = rte_pktmbuf_data_len(mbuf)) : 0) + +/** Set op->status to appropriate flag if we run out of mbuf */ +#define COMPUTE_DST_BUF(mbuf, dst, dlen) \ + ((COMPUTE_BUF(mbuf, dst, dlen)) ? 1 : \ + (!(op->status = \ + RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED))) + +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("\nInvalid flush value"); + + } + + if (unlikely(!strm)) { + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + ZLIB_PMD_ERR("\nInvalid z_stream"); + 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; + break; + } + /* Break if Z_STREAM_END is encountered */ + if (ret == Z_STREAM_END) + goto def_end; + + /* Break if current input buffer is consumed or + * there is no more space for compressed output + */ + } while ((strm->avail_out == 0) && + COMPUTE_DST_BUF(mbuf_dst, strm->next_out, + strm->avail_out)); + + /* Update source buffer to next mbuf + * Exit if op->status is not SUCCESS or input buffers are fully consumed + */ + } while ((op->status == RTE_COMP_OP_STATUS_SUCCESS) && + (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("\nInvalid z_stream"); + 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) { + case Z_NEED_DICT: + ret = Z_DATA_ERROR; /* and fall through */ + case Z_DATA_ERROR: + case Z_MEM_ERROR: + case Z_STREAM_ERROR: + op->status = RTE_COMP_OP_STATUS_ERROR; + break; + default: + /* Break if Z_STREAM_END is encountered */ + if (ret == Z_STREAM_END) + goto inf_end; + } + /* Break if Z_STREAM_END is encountered or dst mbuf gets over */ + } while ((strm->avail_out == 0) && + COMPUTE_DST_BUF(mbuf_dst, strm->next_out, + strm->avail_out)); + + /* Exit if op->status is not SUCCESS. + * Read next input buffer to be processed, exit if compressed + * blocks are fully read + */ + } while ((op->status == RTE_COMP_OP_STATUS_SUCCESS) && + (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; + 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; + + 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("\nInvalid source or destination buffers or " + "invalid Operation requested"); + } else { + stream = &((struct zlib_priv_xform *)op->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) @@ -21,6 +212,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: @@ -78,6 +271,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: @@ -99,6 +294,43 @@ 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, i; + int 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, @@ -115,6 +347,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; + dev->feature_flags = RTE_COMP_FF_NONCOMPRESSED_BLOCKS; return 0; -- 2.9.5