From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0048.outbound.protection.outlook.com [104.47.36.48]) by dpdk.org (Postfix) with ESMTP id 9125C2E8F for ; Fri, 20 Jul 2018 20:42:49 +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=MltprBlNvLQeMJNXZ73/TWhC0W8cMHpBLi4HdmxKVdc=; b=Gt4vA01iAq8kKWJH71rFWGVXXDiYoFtK3zo+iMdor7ypn6tiUlabzsVhYWM4LzX8Dv1MvF+4vm3V04UR3wp5YpdiDvFb09FLMsBhQFq3iCbhyI7SQAYm5ZjM3pjTAJFh2k/1VUoVkNy63KiikI1mD3BQh1PKfHur0TOMo2A6nT0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ashish.Gupta@cavium.com; Received: from hyd1agupta-dt.caveonetworks.com (115.113.156.2) by BN6PR07MB3057.namprd07.prod.outlook.com (2603:10b6:404:a8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.16; Fri, 20 Jul 2018 18:42:46 +0000 From: Ashish Gupta To: pablo.de.lara.guarch@intel.com Cc: dev@dpdk.org, narayanaprasad.athreya@cavium.com, mahipal.challa@cavium.com, Ashish Gupta , Shally Verma , Sunila Sahu Date: Sat, 21 Jul 2018 00:34:44 +0530 Message-Id: <20180720190447.7979-4-Ashish.Gupta@caviumnetworks.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180720190447.7979-1-Ashish.Gupta@caviumnetworks.com> References: <20180720190447.7979-1-Ashish.Gupta@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: BM1PR01CA0083.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1::23) To BN6PR07MB3057.namprd07.prod.outlook.com (2603:10b6:404:a8::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e5e8d01a-4a36-4281-4607-08d5ee709731 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(5600053)(711020)(2017052603328)(7153060)(7193020); SRVR:BN6PR07MB3057; X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3057; 3:NF7mlEULvludUZuEJLNWtjrzyVpCp0c+oTIYSkQQNCNhh3yTG33TyGaqKEGnbwOdpEkw4t1A25jJ3AEhc0GNQ5uqA6d/ysxGEHE9XDwDi9y15/cs69SIU72j13eiJDO0vKWjxa0+za48PVpDqq1diwBeWctsxsHjlHVdnWjR7ln6ZM0JkzO9lgmJBMk1jhnuMjU/ULPhprW+jHAVwGlGF+n+E9OvnNH4tK/lWE7ALP2k0Ob78RqS51XZymiVZ3Av; 25:cSjTpiIrAuZdoxOAmYPrkJjrkvQdDPnxIRriR7KPjWO/tb6s2OHHVhci/9ZdTpEcgbbj4gQ+jB8kgZxDrzT9eT8boL1XpTrWuNe7n6Yt78uryS63jzPSoqoaHDh50xpOfAkHcFgHgfN3NEmbPD4lnL9nU7tLc3Uu61TLIboJzxJaeKcCes0j1ufeUWA+jk6QhIbg18Dk8OV3kY1Vtx39OTyk/ytFPqZRRAQ2p0W14xPpJ2dh9wMlPhL9zk6N298Hhu1sC/LRP5NCqmZIg/FiO43LKELMVeNlzAcvFNce3YT+bIbbqpJ0eDyOPhPPRNrejMfYeQLn1d7L4KEYa1gnNg==; 31:/365o9lu51Q//A1RrAPnBSteQy8c4y9pNwHm4nbBZHqmEAG0AzQdC3IFbypvUHNAhszgtFu3ENwuyQ/+M9fCp9dH5wpTzrjlr0aJ5pCn9fyJQePi+jGhyrH+aA8ctAlUVhmSQvlaOY7UpWOou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IazhvWg+0JnEEWnNWQhpEq5xBb2wjro2bqw X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(278428928389397); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231311)(944501410)(52105095)(3002001)(93006095)(10201501046)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:BN6PR07MB3057; BCL:0; PCL:0; RULEID:; SRVR:BN6PR07MB3057; X-Forefront-PRVS: 073966E86B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(366004)(346002)(396003)(39860400002)(376002)(199004)(189003)(186003)(486006)(107886003)(956004)(476003)(2616005)(26005)(6512007)(446003)(16526019)(8936002)(81156014)(97736004)(81166006)(55236004)(7736002)(11346002)(8676002)(72206003)(48376002)(4326008)(2351001)(2361001)(25786009)(6486002)(16586007)(54906003)(53416004)(50466002)(316002)(105586002)(36756003)(106356001)(42882007)(478600001)(68736007)(69596002)(14444005)(5660300001)(6916009)(66066001)(50226002)(47776003)(305945005)(76176011)(1076002)(6506007)(2906002)(6116002)(386003)(53936002)(52116002)(3846002)(51416003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR07MB3057; H:hyd1agupta-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; BN6PR07MB3057; 23:pnFT2LpcOvPvtF4mL+IzDRHJDTJZgtSjWHz4HTEHK?= =?us-ascii?Q?frQy4RjkaQZtR4LX2AAwWRN3PiU4/OpiYdz6vQCNFrgfPKojf5rjCi1riSUr?= =?us-ascii?Q?F5hf6zli6W+lqygAGsegeA+etIRCkMduyoh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BMvs4+tNc628onhomzaOkCDc8CLL071TO/5TVIEivTYDSvk9aGa1recfVmBt3TjM0+iZ07maf3tINiNOge0PAyiwqKQE+O5PUZdDPU69vmz3NTj501GaNaF5N/v7BDV6PGcZsGR17M3cdgQByWexQodH72IrMSn3H5At9jvwxc2GCJ0wZxiPDYATR+Gu1erBIQsmCEYb1aG0vOsbsZj9z7rF+hWGeUjsbWCR0cl3yGuviP1IfxHx4s93eSke1ph9D2MxXhRsFSIhzGffsLEaA==; 5:CTcr+84zvXmSruBZq3s4PYMPc4vzCS0kOtg92ZD9kJ6WiFmpd9q0McK4Hi6e40bi5YbmKY8jyIZwLPoONBglbrigRei/39iTiHuMCDPgweG1bLZNPKXEuyIhqfdY/kLLc3MVKaae3aR+8Zf9FMhLp/0EeZCYL7iQbiFx2bPBjwA=; 7:85KApPbgeZVemHNLl61jEjXQQgnDL6MZ7xa1ZrmAHEbpl2ADsNq8mV2RQu/6IPplxrwPLYmp+toSAWf5JRKkpgpTcyr7OW6us3BhUl/Gjn4wdc1YyQ+KoTZT2AgpvnuAjr7yggcKHRrbe8xolEsn5A9zY8xubaEMhBlonB4xz/JNHyOrrZb5nc/J2jnBqZ69NNt1X0W+3dnbEtmxqYTRW/7ITtSXebikX4qkQaVxIoaW5rElIJnlHjRBZqFbbKQe SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2018 18:42:46.4379 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e5e8d01a-4a36-4281-4607-08d5ee709731 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB3057 Subject: [dpdk-dev] [PATCH v3 3/6] compress/octeontx: add xform and stream create support 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: Fri, 20 Jul 2018 18:42:50 -0000 implement non-shareable private xform for applications to initiate stateless Compression/decompression. Signed-off-by: Ashish Gupta Signed-off-by: Shally Verma Signed-off-by: Sunila Sahu --- drivers/compress/octeontx/otx_zip.h | 19 +++- drivers/compress/octeontx/otx_zip_pmd.c | 149 ++++++++++++++++++++++++++++++++ 2 files changed, 167 insertions(+), 1 deletion(-) diff --git a/drivers/compress/octeontx/otx_zip.h b/drivers/compress/octeontx/otx_zip.h index 1289919cb..3fcd86a86 100644 --- a/drivers/compress/octeontx/otx_zip.h +++ b/drivers/compress/octeontx/otx_zip.h @@ -90,9 +90,24 @@ enum { MAX_BUFS_PER_STREAM } NUM_BUFS_PER_STREAM; - +struct zip_stream; struct zipvf_qp; +/* Algorithm handler function prototype */ +typedef int (*comp_func_t)(struct rte_comp_op *op, + struct zipvf_qp *qp, struct zip_stream *zstrm); + +/** + * ZIP private stream structure + */ +struct zip_stream { + union zip_inst_s *inst; + /* zip instruction pointer */ + comp_func_t func; + /* function to process comp operation */ + void *bufs[MAX_BUFS_PER_STREAM]; +} _rte_cache_aligned; + /** * ZIP instruction Queue @@ -156,6 +171,8 @@ zipvf_q_init(struct zipvf_qp *qp); int zipvf_q_term(struct zipvf_qp *qp); +int +zipvf_push_command(struct zipvf_qp *qp, union zip_inst_s *zcmd); uint64_t zip_reg_read64(uint8_t *hw_addr, uint64_t offset); diff --git a/drivers/compress/octeontx/otx_zip_pmd.c b/drivers/compress/octeontx/otx_zip_pmd.c index f6285508a..fac547920 100644 --- a/drivers/compress/octeontx/otx_zip_pmd.c +++ b/drivers/compress/octeontx/otx_zip_pmd.c @@ -28,6 +28,103 @@ static const struct rte_compressdev_capabilities RTE_COMP_END_OF_CAPABILITIES_LIST() }; +/** Parse xform parameters and setup a stream */ +static int +zip_set_stream_parameters(struct rte_compressdev *dev, + const struct rte_comp_xform *xform, + struct zip_stream *z_stream) +{ + int ret; + union zip_inst_s *inst; + struct zip_vf *vf = (struct zip_vf *)dev->data->dev_private; + void *res; + + /* Allocate resources required by a stream */ + ret = rte_mempool_get_bulk(vf->zip_mp, + z_stream->bufs, MAX_BUFS_PER_STREAM); + if (ret < 0) + return -1; + + /* get one command buffer from pool and set up */ + inst = (union zip_inst_s *)z_stream->bufs[CMD_BUF]; + res = z_stream->bufs[RES_BUF]; + + memset(inst->u, 0, sizeof(inst->u)); + + /* set bf for only first ops of stream */ + inst->s.bf = 1; + + if (xform->type == RTE_COMP_COMPRESS) { + inst->s.op = ZIP_OP_E_COMP; + + switch (xform->compress.deflate.huffman) { + case RTE_COMP_HUFFMAN_DEFAULT: + inst->s.cc = ZIP_CC_DEFAULT; + break; + case RTE_COMP_HUFFMAN_FIXED: + inst->s.cc = ZIP_CC_FIXED_HUFF; + break; + case RTE_COMP_HUFFMAN_DYNAMIC: + inst->s.cc = ZIP_CC_DYN_HUFF; + break; + default: + ret = -1; + goto err; + } + + switch (xform->compress.level) { + case RTE_COMP_LEVEL_MIN: + inst->s.ss = ZIP_COMP_E_LEVEL_MIN; + break; + case RTE_COMP_LEVEL_MAX: + inst->s.ss = ZIP_COMP_E_LEVEL_MAX; + break; + case RTE_COMP_LEVEL_NONE: + ZIP_PMD_ERR("Compression level not supported"); + ret = -1; + goto err; + default: + /* for any value between min and max , choose + * PMD default. + */ + inst->s.ss = ZIP_COMP_E_LEVEL_MED; /** PMD default **/ + break; + } + } else if (xform->type == RTE_COMP_DECOMPRESS) { + inst->s.op = ZIP_OP_E_DECOMP; + /* from HRM, + * For DEFLATE decompression, [CC] must be 0x0. + * For decompression, [SS] must be 0x0 + */ + inst->s.cc = 0; + /* Speed bit should not be set for decompression */ + inst->s.ss = 0; + /* decompression context is supported only for STATEFUL + * operations. Currently we support STATELESS ONLY so + * skip setting of ctx pointer + */ + + } else { + ZIP_PMD_ERR("\nxform type not supported"); + ret = -1; + goto err; + } + + inst->s.res_ptr_addr.s.addr = rte_mempool_virt2iova(res); + inst->s.res_ptr_ctl.s.length = 0; + + z_stream->inst = inst; + + return 0; + +err: + rte_mempool_put_bulk(vf->zip_mp, + (void *)&(z_stream->bufs[0]), + MAX_BUFS_PER_STREAM); + + return ret; +} + /** Configure device */ static int zip_pmd_config(struct rte_compressdev *dev, @@ -253,6 +350,53 @@ zip_pmd_qp_setup(struct rte_compressdev *dev, uint16_t qp_id, return -1; } +static int +zip_pmd_stream_create(struct rte_compressdev *dev, + const struct rte_comp_xform *xform, void **stream) +{ + int ret; + struct zip_stream *strm = NULL; + + strm = rte_malloc(NULL, + sizeof(struct zip_stream), 0); + + if (strm == NULL) + return (-ENOMEM); + + ret = zip_set_stream_parameters(dev, xform, strm); + if (ret < 0) { + ZIP_PMD_ERR("failed configure xform parameters"); + rte_free(strm); + return ret; + } + *stream = strm; + return 0; +} + +static int +zip_pmd_stream_free(struct rte_compressdev *dev, void *stream) +{ + struct zip_vf *vf = (struct zip_vf *) (dev->data->dev_private); + struct zip_stream *z_stream; + + if (stream == NULL) + return 0; + + z_stream = (struct zip_stream *)stream; + + /* Free resources back to pool */ + rte_mempool_put_bulk(vf->zip_mp, + (void *)&(z_stream->bufs[0]), + MAX_BUFS_PER_STREAM); + + /* Zero out the whole structure */ + memset(stream, 0, sizeof(struct zip_stream)); + rte_free(stream); + + return 0; +} + + struct rte_compressdev_ops octtx_zip_pmd_ops = { .dev_configure = zip_pmd_config, .dev_start = zip_pmd_start, @@ -266,6 +410,11 @@ struct rte_compressdev_ops octtx_zip_pmd_ops = { .queue_pair_setup = zip_pmd_qp_setup, .queue_pair_release = zip_pmd_qp_release, + + .private_xform_create = zip_pmd_stream_create, + .private_xform_free = zip_pmd_stream_free, + .stream_create = NULL, + .stream_free = NULL }; static int -- 2.14.3