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 C0DE81E34 for ; Sat, 21 Jul 2018 20:22:17 +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=RKsLevrboDLd5sYVSOdPUsALT2tKgxAYJHlGh3nLq50=; b=EFroRVfJ0V5LvngnGEDXkSXj1PqRHXD21Y070ghZO8qAeBM/nbHNYS/yt2OxZ/ObQjvO28QmdH7dtMdJSnUGmSPR3sTulBj61yYf8KmlZLiBp0D6MrPDsCExg1gGlklUnSvjyQZef7HlVcUa47ZHeJxSqlO9QMIAI6OE9ob8Rbg= 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:26 +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:47 +0530 Message-Id: <1532197069-24224-4-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: fcaf5561-a721-45f1-3ab8-08d5ef365bce 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:Qq/MyUDfJVq0pfJSX5xoLmLfBb/qCDpvgddEEhtUYeSWnEJYeoiDwNHGfJkIQS2hDg5FCyfNOXm3OmBLjeCUHiB6nZb7Q1ulEfmagmKzYnu6/Bb3n0kNb+kcW5nr64InATmY+e3vAbJ3FBFL6XsQK/uv1DNT+H1iqWP2QyePT7nt1KCNaqSvthcCk4TbTIOmQp61iEHS7M2fhePxja5DCnsFuplC3RztcjQ2m5SipcWUzVYHl4+VJ2tOlb++FWkK; 25:p99jYpP3h+GoGKM17RVTW7c1ZT3FBnndHI5rYqrz2JIw1/0BKczWCwgieRKvLQLALMlZJOMF005bKu2Kmf5W26muKHuD24pb76EZ7cKm9AuwDP0EXS10RbV0+V06jtlONJvQfH0qNbovvzCpMCCLEWclzP/VXjzKITUFFbX6RpaKpYpdUSRDQQ4XgtCTXdRDk2Dwy+RI3OxHVVesR6UQlXyM9P7yz1RNI+EvsxGiV/UJWlM515vA5CC6wrDATPTOmNdVBQsLc0BVOHygvGNLmamCwZGfjv4mHAgKVJps0MAmVSQ4XZrzdlhkKfobuqacMoYrcV//V7G0hGXbV8oVRA==; 31:OzvEqNthFl2wmZ08ORfIXVENbCrPzUSgNfDEMP/26M9rpF3ZVU9p1oUAhNII9hN1ailmVrL5WdrZjO71z8EmiUM1EB2qaJX+23iqmBuzdwiZ9Hv6fAHEjsozhYK82QAJB0NwDY8QtxxiEhE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-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)(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)(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:nylzXecQFuacR6UYrsRkWMbPPujIlvXoJvbTQTt?= =?us-ascii?Q?eiR+daEVmcpkmxa7c0IKUJZ1WHc54h7kdlY/YTcQXtK0sf1sDp9Qv6p8nn2j?= =?us-ascii?Q?PZAHKr5tedkM8eSzEeY9Utdl0YUdpp93NxOlyEYaVzNKmq394v5tkuNzRQDe?= =?us-ascii?Q?6RbmFWkcEol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KN1BdQqD?= =?us-ascii?Q?TgkSi2K5lELa/a7H49POmwKwM2dCq4d/1CwFyKSFd21M23FojqNz5+IF6fZK?= =?us-ascii?Q?wSJel5+jxicPm+2bE98mKkTyOOxZCise8fgrmedcrxwDihLU/cfKqIZ1tdqZ?= =?us-ascii?Q?hjJhNCEZrScQWqTfy3PJrsjh1X1YBEPSyCkGAQ+9pBTGVH7OLGFpmtvERXbM?= =?us-ascii?Q?yuaktffEqwQ3euCX3qGgUuOSuBOQxz522xZa6QDHWVA0tUp8fBvB/PVPU6fF?= =?us-ascii?Q?GTzSe7l+3Vep/c+Vdnj6O5lMr2YmKMIsMcuDtIbJnfLzK?= X-Microsoft-Antispam-Message-Info: 6BLHqphGIQsG0ZYXahsfGvvIntAD6IrdPbBv+hIAcTeThCMCCuhdxBN/wJAOawvFHJgp44qXvjq5TXrq7kSr1jbLa6edpU/eZqY+H6ujXwyu5MnOKykKp5YvgY7CR+6QGDg8iIZejFWXN5F54xLJf7mPdDTCgzjfwEkbrvGbvCmaLjjdtXravYlLrxggne8JqeNpfYlhXaVYhvmUhUkCVgzlR0NL2n6s+DKCpfzM6hkAf9Q8OQHelO1tCTp3oL0622gs4Ismdd292u31+s83yqIPJCDQOYf6p4dPq2RFNDtVB8IGCiFNfU1x3utkYkFtB2jI6M+/8bvM9+zsoHrneM0iu4CnqPYlU3pPNM/yKbk= X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3634; 6:tr6h6TJxKS+zvRBllfqNEZoVJ0AdTilR8OykOXkliHI8CAsmFJzCC5f7On4GfkchZx5H3xr9RYN1aZT4kROeWjAmGOlutLT2EzzclBOXoPtgO04TAe8d5fULkgwszRBJILdy4bCy93tVvSeP9TV4qkxztJS/BpsyPCjxZyUNRbeBY27teWwr/slzO+ZaIF1BQMthvIOTEwdhUD8lYtZoygPyG0VNtoG5tNZq7xfMMzlvA/NgKRsu2su5Z3dDGsafjpZmnJzhShp1aVDFg2timOXULP0inTH6P1rLE9VZC6svQ9Ua9jWPQ0JMffZRlES4GSUQ2hUxJrBGMo20rOsNZb+B+3aXi/QZdKaU2ex3j6Q9wLS/nuYenw5rHAy8YVEWf5X4cXHYZ+3hSwfEhZkXnX8jtLfG5QfAv/31FjXHsFa4vIlUDFEhWH2mf2JP+0MiEzcPkuF5n4url6+evIYzfw==; 5:l2o2dbxGq15EOt3qBKqmEoJqgklsmfzAuXsLUTcn+ORs/NBFzWSINEYPy0q1Vv5wHRgDx8xEhuA9IPB3fwrAckY9FXRGb5HyZjh+3cgpP0NVLE57bOaHKwTXYjtGSqFLjEYWyubhTm7Ke/KL3M1/BaaKotwL/cTFvrg6xRWMs1c=; 7:XK37eW6YuLyOGCrbMWcde5QQS8LKWEsMEYzhXKbBNBJ07Ou2v35qo91ImLl2o5CfStPZvKb4J8B0xedIMwBb9bb4IlPCc/sMlz4FNEWAC8z1Qt4B10p3LM5KtAqkocOwrIkyJENjU6vOy2GZz7kvXj0j2SIOYTZXzeyma3nQuu6i7GklMoKeDnoaVaUPknV0KJ5/8BxzdMFu81r/lbvnsf2kS6+gjAVrGhhCckQq+jaip2KmfskcXyKmeTfI86UN SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2018 18:18:26.7591 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fcaf5561-a721-45f1-3ab8-08d5ef365bce 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 3/5] compress/zlib: create private xform 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 Create non-shareable private xform for stateless operation processing Signed-off-by: Sunila Sahu Signed-off-by: Shally Verma Signed-off-by: Ashish Gupta --- drivers/compress/zlib/zlib_pmd.c | 93 ++++++++++++++++++++++++++++++++ drivers/compress/zlib/zlib_pmd_ops.c | 74 ++++++++++++++++++++++++- drivers/compress/zlib/zlib_pmd_private.h | 4 ++ 3 files changed, 169 insertions(+), 2 deletions(-) diff --git a/drivers/compress/zlib/zlib_pmd.c b/drivers/compress/zlib/zlib_pmd.c index 9363808..9a464ee 100644 --- a/drivers/compress/zlib/zlib_pmd.c +++ b/drivers/compress/zlib/zlib_pmd.c @@ -7,6 +7,99 @@ #include "zlib_pmd_private.h" +/** Parse comp xform and set private xform/stream parameters */ +int +zlib_set_stream_parameters(const struct rte_comp_xform *xform, + struct zlib_stream *stream) +{ + int strategy, level, wbits; + z_stream *strm = &stream->strm; + + /* allocate deflate state */ + strm->zalloc = Z_NULL; + strm->zfree = Z_NULL; + strm->opaque = Z_NULL; + + switch (xform->type) { + case RTE_COMP_COMPRESS: + /** Compression window bits */ + switch (xform->compress.algo) { + case RTE_COMP_ALGO_DEFLATE: + wbits = -(xform->compress.window_size); + break; + default: + ZLIB_PMD_ERR("Compression algorithm not supported\n"); + return -1; + } + /** Compression Level */ + switch (xform->compress.level) { + case RTE_COMP_LEVEL_PMD_DEFAULT: + level = Z_DEFAULT_COMPRESSION; + break; + case RTE_COMP_LEVEL_NONE: + level = Z_NO_COMPRESSION; + break; + case RTE_COMP_LEVEL_MIN: + level = Z_BEST_SPEED; + break; + case RTE_COMP_LEVEL_MAX: + level = Z_BEST_COMPRESSION; + break; + default: + level = xform->compress.level; + if (level < RTE_COMP_LEVEL_MIN || + level > RTE_COMP_LEVEL_MAX) { + ZLIB_PMD_ERR("Compression level %d " + "not supported\n", + level); + return -1; + } + } + /** Compression strategy */ + switch (xform->compress.deflate.huffman) { + case RTE_COMP_HUFFMAN_DEFAULT: + strategy = Z_DEFAULT_STRATEGY; + break; + case RTE_COMP_HUFFMAN_FIXED: + strategy = Z_FIXED; + break; + case RTE_COMP_HUFFMAN_DYNAMIC: + strategy = Z_DEFAULT_STRATEGY; + break; + default: + ZLIB_PMD_ERR("Compression strategy not supported\n"); + return -1; + } + if (deflateInit2(strm, level, + Z_DEFLATED, wbits, + DEF_MEM_LEVEL, strategy) != Z_OK) { + ZLIB_PMD_ERR("Deflate init failed\n"); + return -1; + } + break; + + case RTE_COMP_DECOMPRESS: + /** window bits */ + switch (xform->decompress.algo) { + case RTE_COMP_ALGO_DEFLATE: + wbits = -(xform->decompress.window_size); + break; + default: + ZLIB_PMD_ERR("Compression algorithm not supported\n"); + return -1; + } + + if (inflateInit2(strm, wbits) != Z_OK) { + ZLIB_PMD_ERR("Inflate init failed\n"); + return -1; + } + break; + default: + return -1; + } + return 0; +} + static int zlib_create(const char *name, struct rte_vdev_device *vdev, diff --git a/drivers/compress/zlib/zlib_pmd_ops.c b/drivers/compress/zlib/zlib_pmd_ops.c index 645c5b1..2fb6a85 100644 --- a/drivers/compress/zlib/zlib_pmd_ops.c +++ b/drivers/compress/zlib/zlib_pmd_ops.c @@ -214,6 +214,76 @@ zlib_pmd_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, return -1; } +/** Configure stream */ +static int +zlib_pmd_stream_create(struct rte_compressdev *dev, + const struct rte_comp_xform *xform, + void **zstream) +{ + int ret = 0; + struct zlib_stream *stream; + struct zlib_private *internals = dev->data->dev_private; + + if (xform == NULL) { + ZLIB_PMD_ERR("invalid xform struct"); + return -EINVAL; + } + + if (rte_mempool_get(internals->mp, zstream)) { + ZLIB_PMD_ERR("Couldn't get object from session mempool"); + return -ENOMEM; + } + stream = *((struct zlib_stream **)zstream); + + ret = zlib_set_stream_parameters(xform, stream); + + if (ret < 0) { + ZLIB_PMD_ERR("failed configure session parameters"); + + memset(stream, 0, sizeof(struct zlib_stream)); + /* Return session to mempool */ + rte_mempool_put(internals->mp, stream); + return ret; + } + + return 0; +} + +/** Configure private xform */ +static int +zlib_pmd_private_xform_create(struct rte_compressdev *dev, + const struct rte_comp_xform *xform, + void **private_xform) +{ + return zlib_pmd_stream_create(dev, xform, private_xform); +} + +/** Clear the memory of stream so it doesn't leave key material behind */ +static int +zlib_pmd_stream_free(__rte_unused struct rte_compressdev *dev, + void *zstream) +{ + struct zlib_stream *stream = (struct zlib_stream *)zstream; + if (!stream) + return -EINVAL; + + stream->free(&stream->strm); + /* Zero out the whole structure */ + memset(stream, 0, sizeof(struct zlib_stream)); + struct rte_mempool *mp = rte_mempool_from_obj(stream); + rte_mempool_put(mp, stream); + + return 0; +} + +/** Clear the memory of stream so it doesn't leave key material behind */ +static int +zlib_pmd_private_xform_free(struct rte_compressdev *dev, + void *private_xform) +{ + return zlib_pmd_stream_free(dev, private_xform); +} + struct rte_compressdev_ops zlib_pmd_ops = { .dev_configure = zlib_pmd_config, .dev_start = zlib_pmd_start, @@ -228,8 +298,8 @@ struct rte_compressdev_ops zlib_pmd_ops = { .queue_pair_setup = zlib_pmd_qp_setup, .queue_pair_release = zlib_pmd_qp_release, - .private_xform_create = NULL, - .private_xform_free = NULL, + .private_xform_create = zlib_pmd_private_xform_create, + .private_xform_free = zlib_pmd_private_xform_free, .stream_create = NULL, .stream_free = NULL diff --git a/drivers/compress/zlib/zlib_pmd_private.h b/drivers/compress/zlib/zlib_pmd_private.h index 0e391a4..2c6e83d 100644 --- a/drivers/compress/zlib/zlib_pmd_private.h +++ b/drivers/compress/zlib/zlib_pmd_private.h @@ -61,6 +61,10 @@ struct zlib_priv_xform { struct zlib_stream stream; } __rte_cache_aligned; +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; -- 2.9.5