From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-eopbgr730041.outbound.protection.outlook.com [40.107.73.41]) by dpdk.org (Postfix) with ESMTP id AFC4D44BE for ; Mon, 23 Jul 2018 16:51:52 +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=SqzztgmEMyMMCgnwFzvIUfJOOLDcg3Wwo9sXLK4Dxvs=; b=Dfs0k1JKI3mG66Mii+wjkicq7wbfj8PJf4tWLq0OOtZlArl8PT7haOnu9em89vJiOXUbGcQz2bbA+LPPd/dSl1cTvhfZ9KHmKWBUNpbPiQH8UJ1O1h8cmSwtnLQsoQclqs0mhA4aQKP8givH8/SIrsVBYgBR9rfARUjpHoFX3JY= 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:49 +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:12 +0530 Message-Id: <1532357474-9544-4-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: f20f5541-c4e8-4435-280f-08d5f0abd316 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:VDQqge3IzLvCFG9zoFMOrSaXdhASkFzvyiQX8hdHdvMIJntPK1wzFRP8O7OeWyD/NU4w9EJk+9aFqyf8WwsWgtQzfv7w5ToCCltuQ2maCI4++Q38++ww12f/BBJw/5lO7JSzfJd3rplPI3PQNe4vlDtsLzCKvx6RNQknwhF1r1bKdEa+D07EM/oy1OX0IIP7jec/fIUSwIHefVYRntBseO3Xkc5FjCnO4wx4D8IIh4TUplhVrIIQq/M5oA6tSrAZ; 25:iV7pBzAxiAiLZpeAVrc6FI1oJFdCBZvR87ppeVdwoc40ZZgUnM/ys178IrBoi/CgHXbwZHUKuVd84IOHEQjHq20RSjGrWMG0FoC4Hem9128aBuYmAqWZIzecU2af7MJcQvuPrAQtLArPIs59eAy0KWRuZHcW7jKvdSNVbsDv/Dh0KvnxUOjXvDz/lfsZ7X0mV5xB9i0vLQDJzBrYoSUMlb9IlbA8xMI6RRZHCSirKgUk8LQ2MZF2gZM9dl/+S+czhUUpJRtir8qSI0smyWJZhDi46VBvpp9RAE3r8IPGbwYT+TIgkLLSoOYQYxQyeWsKF2H/5nwoSvAf1aNeC/c9xA==; 31:M4lkoE4AxilN7TnSPv3NLhM4vjAASCdhvADHRvZfdsWtLUaeduCxXK4PzNHDDYZ+LGTvLi94GawOJnMFN6YYBnuhD2h/RttqWZe7XmaeelrHPiXkVXEqXhJC3Wo/hx5L/UHYnGLLzQri1yp6bwizCrzAJX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oft-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)(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)(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:FFNHPOq4oE+GK1hlKNNggiTn4WjPUSVd5UPyAKm?= =?us-ascii?Q?e8VOONYa/lwluGTgBO33DkFkfFTZAxbQ7uhZ69JtIcY8naURvew2emOefRkI?= =?us-ascii?Q?Xd+DHKFxV4iktV8mJfWRqKgCUPrgwbsjswNmvAGBFaKK1/jR/8P69ETvdFTT?= =?us-ascii?Q?eiPsm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EI18u4eOSQIE9d70CcNWbT?= =?us-ascii?Q?L4FVwJdonsnORMn9eGtKdDzB4cJ4CiTm9FAZOO/0GqjQPa8NCh/mHvrbUbJW?= =?us-ascii?Q?fSEdRzy131q5gjZqtRjsUB9MWPbCRQrvta1li32fGR2apbe8068Rbjh6amH6?= =?us-ascii?Q?gnPPjtatudxYvK0MTquSaNW4qwGlh7FcrPMyXSKGMzedr79Rdeqw0DErUnZo?= =?us-ascii?Q?jh/d/u/7kb76qvb8BE6i1PBZHokBm39ptt5hoJq+9jAU6shqKoa0nMiaSKzp?= =?us-ascii?Q?CynFc/ELww0+mwo3T56Lgji9Rnxg39CPcBtuRK8uTDQIbsaL8fDm74cB+H05?= =?us-ascii?Q?o5SZ9Xg=3D=3D?= X-Microsoft-Antispam-Message-Info: z9ToYLGuu2mBqK89YVJ9dvFoOsOQigquBnoXRnUpzGxHp4Oyj8dwdk2UyFkNCvG/KHdqzDddzcQrAi4U0l7Nl95BxH9mhLah6R+g0RK8vmRtOCsfLxPfwtBSmtbZ3S6M5RmX5JDutQxrgVvH6dzvGhQellD+tbhRv/uDsMElQ4NzfWJKCXdne2DNWj6edP0x1kCGU6k5kUcmbFDgXi5R8Cb8yOSUZoxNuDyC1wAXULewNG4AkCPGV5v/I71KUQWgBBAqznFX9ztD/TKcxsSo7vf4CXAi3HVQ0Ejdz4D6IYL+YQFyn7oV//93KTKwbcSEeTVmngMlS9f1TdgVVo2vdoaI+GwA/0ZIj2LnTDMIfc8= X-Microsoft-Exchange-Diagnostics: 1; MWHPR0701MB3641; 6:Wt1wog+ioE2KP4q1IgSvd5r6Tlb9oJY0YYz+MW7ZgQGdOXZTpPA1zXRYXrxMNq0rqfI54MkK2YhltVFTH6VGHWXj0DVRHU6jROLgRKS/q8bhqffjokY1b8X2CL32F58PBd4ItknTn9/ejfPul1RcaRRyycBXolJOx8dust8iL+7klIETQPJSykoDiTQ33Vz7RYoT99XpltlUGPYfZN5sK6TnSbfni3c0nPXy9349GmZCalPt4Gf9MLgzkAQt8c5+Tm0eP894NwDgYmqaXHIQSnsOuBkUS57ljg8HIzz7lKG9BQ0rWUAEUGAWpbIMH7GYwc/kmZKFeWDslcFtXNgFcMzwbK1v01SZ96eVDrvL0TkFxWjOa3JbiGKcGmt4GgdKUUfKajVa6z3xlMRzxcYCNEf3w6pOWcAEVjVPz7xRug/OCdi3RVQsV7Zp/T+msLfPfH6Mi8u1obSqNgKLhRgM6Q==; 5:hYG4lXGCkXNn3oNRA6boSkvxundf9cMTZgU75u3QP6X8cm4sWo2mJOeJzZc9grODebfQfYppi9trtmNJhihcnWWiD0k8qdLLvDxoGikC0PEsSPzX+imVEKZXvV9NoWUnUmmxV3QihvKIIbN1/B2NRJTpcl4E7Tkia6E5jPQzBjw=; 7:kocfP9mkqR6HtlnOccaAls69E8CscTNrIQg4eg3VpspKpJlcnXGmyDArGtcv5LMb2OjvZx2FJnAlkA5sCPQy/4MRx3/J9lrzEFi0VWYdW4GR5YBkWMhFk3wKDjFQJN5WHZbWB13v/0bIaQ6DxyRtv0AhYD8XxaSrWi+BBrmTw55gV4zhvhjNd1cCc7FoK8E4wr/LIBbzWLhZ58qQmOizh3+obL6E/hVocLO3XuZTsiEF5WOVatgKJ4dZEn6arReC SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2018 14:51:49.1811 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f20f5541-c4e8-4435-280f-08d5f0abd316 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 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: Mon, 23 Jul 2018 14:51:53 -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 | 94 ++++++++++++++++++++++++++++++++ drivers/compress/zlib/zlib_pmd_ops.c | 74 ++++++++++++++++++++++++- drivers/compress/zlib/zlib_pmd_private.h | 4 ++ 3 files changed, 170 insertions(+), 2 deletions(-) diff --git a/drivers/compress/zlib/zlib_pmd.c b/drivers/compress/zlib/zlib_pmd.c index 9363808..47bc73d 100644 --- a/drivers/compress/zlib/zlib_pmd.c +++ b/drivers/compress/zlib/zlib_pmd.c @@ -7,6 +7,100 @@ #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; + } + break; + } + /** 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