From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0068.outbound.protection.outlook.com [104.47.41.68]) by dpdk.org (Postfix) with ESMTP id 4D8E91B7E1 for ; Tue, 5 Jun 2018 12:36:10 +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=FI/i7jO5yCUDdgT/6XpQvvB7ppkdQ66B1dOVovcrSMA=; b=Ph2giGRxBS/s90N6Ks2DpEAO3c6S+9t54B9AQxh2UONQma+GU3VjM8dBWCC+pK/uKIrinQ6SQS2eaUSlaxWcA2xfQH8t/0MwX0S+HdpiYRl8Za99hBlqW1cYw3AVGZmUKYqyNnsrDPPWLVndHgFrjTN1GTbqrW5avet4aflUZ6M= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Shally.Verma@cavium.com; Received: from hyd1sverma-dt.caveonetworks.com (115.113.156.2) by CY4PR0701MB3633.namprd07.prod.outlook.com (2603:10b6:910:92::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.820.11; Tue, 5 Jun 2018 10:36:06 +0000 From: Shally Verma To: pablo.de.lara.guarch@intel.com Cc: fiona.trahe@intel.com, dev@dpdk.org, pathreya@caviumnetworks.com, mchalla@caviumnetworks.com, Ashish Gupta , Sunila Sahu Date: Tue, 5 Jun 2018 16:05:10 +0530 Message-Id: <1528194913-25893-5-git-send-email-shally.verma@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1528194913-25893-1-git-send-email-shally.verma@caviumnetworks.com> References: <1528194913-25893-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: PN1PR0101CA0006.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:e::16) To CY4PR0701MB3633.namprd07.prod.outlook.com (2603:10b6:910:92::35) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:CY4PR0701MB3633; X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3633; 3:MLVsugeHG7ajjATt+2ZfS2xr37waFKOn9pzY1RZeTRBXZfUKkwqbnCVUwdGR4qF3FUZu23uhMMrgSi6fAYifLiZk+t0PaYHbdobgdTD3lhELwSr14Eocy1oQq9gKBbnfc9Oq0xcj4nZo94CXm7e9AlCH7khs0Ism6fUH1qU3Ggn9B5L3s+abwqC7YZNLpwS/TIGi+JDGS0/IwssxfYv0guC13Y9DzY8a6tQ/A2z2L+mM+5w2K8Qu3CfUa3QoY0fC; 25:b4IT2Ja6RtHuZFCAXCxaIP8RyXdi/TrAB7TdjKdbFsxj3Ir37tTc5rNf80mctXyCphu1mdHTMXyhRjE+Yn36gmt0PqeeSRyPkwGvhzv+gVlg2Ja/Uj0svI7JgQKPerLsQzkhYF4UKdW7TRAcsY2qrdm8yx6ABmADEyQwhu3h9PC63HsLfl8KkL+OpL8XRS46CLoVg7UrHRsfXYpM8b54C99rSYx+Ab+F5l+vorPA84ke4jjhqmkq+XGbM7On0cV4ZAHL6oQd0PYKhJgscz79quNIF9Xt8wLPKmOUKWc7yXZEeih54AGJZH2W/Sxn8uIKaexY7hkCSy4FpugsdA5Ifg==; 31:RlNWcC0dyxt7chwW8t5oaS0wPyhRXfyjs8NJPioIasSRLH71nwJ/uyJE41zUYOrhJK+pYtNVJsHUQP2H3Ju10Tg5g0lYzlErAWSJBJJWmMvXtgKEjbF2XELY40dDg/kBn14v0/Bvoe2WBJDzLMAn4CsSSMQfDndWLASoJpfzyPpi6OyEJ9cL3GSHZD7O6+qLVniaXHu2oTcTC28uxcTJQ5iDY7xEhRt4761L/41pFos= X-MS-TrafficTypeDiagnostic: CY4PR0701MB3633: X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3633; 20:tdpZIKccOdkOBsDis33OTAEeKR4N/4bc+6T5uE0FsjrNG+8KNIFJfTHZu7EMDYwnsYl56gDdFFTnIH7h65qyt6ZsjYBqOg/cpLK7Lt1IH23un04BfhOD9HP/8jaLnrwaaoxu2BBdyxl+aw7cZNbWEdNE4pihCgYKNu/RbW8BomFX1NGJHHqSlBOZmok9hfpx6aa8pYXN3DIxZdUDtC4iyP7NfZ+PFcLRNIrctDJ87cfGPiSB2WEnelSzdVPV21+7jeP5yZ8PJU4O0ZdtfK8ECP48gRLvnPLAd0fm/Zl/ZhgC7k9PrKumzppaB/sPtwzYykCh4kSyfK3l/z6+NLcXS2IddI3ffRh5+/5lAXAfpGdqo46iC8bbj1kmZZTdI9IMHoOuVpNfhmN265mdoLAvPIPi50lIRcek9XrpwcXQxmXgE5/DMxx4NCgxSRLyfcthhcBHfSQ2mWglECkglKysEmQV2ysTtK0XomVtQbYDccHzsfgbFskY52XwqLknQeReUaflnFquJcX4Lra5LV2XQW7bTRnP1S1Q8VWEvTBxhSMLl3Yy1bqxLaDjduXnQcOqgKTbFwJTMpeWYTquftOWgkijHhhXvHu2pkAWN90SwYI=; 4:N0sQtA0m68f1a6gBELLkMwTrzlWoFi5TjD/3MjtvKYjq8o0qzWcPwCkXxjRPDCvjp4CoMzDOmoN5XI+NZJuk2Qo0O19nBkWUZOHS70/sWcs+DqrDPuaqUKw5BmOmfEcmREyDlWpHx59tt+1kzoHCnXP7JAPE9oeWWTQT2e5n+fFksXxRRvQO/aOiSULS84Ri11Do2GtJUncAYeOA64EJeWtPmShQS23USus183rgDinyHmClDzDVme7u5URJgLDVSgemCuV/ccBXplUy8VyPvg== 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)(5005006)(8121501046)(93006095)(3231254)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:CY4PR0701MB3633; BCL:0; PCL:0; RULEID:; SRVR:CY4PR0701MB3633; X-Forefront-PRVS: 0694C54398 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(366004)(39860400002)(346002)(396003)(376002)(189003)(199004)(6486002)(956004)(476003)(36756003)(97736004)(54906003)(5660300001)(316002)(59450400001)(386003)(25786009)(50466002)(69596002)(44832011)(53416004)(2906002)(186003)(48376002)(42882007)(52116002)(16526019)(76176011)(6512007)(486006)(8936002)(6916009)(8676002)(53936002)(6506007)(6116002)(3846002)(81166006)(105586002)(81156014)(2616005)(2351001)(26005)(47776003)(51416003)(72206003)(305945005)(6666003)(107886003)(7736002)(16586007)(55236004)(106356001)(2361001)(4326008)(66066001)(478600001)(446003)(50226002)(11346002)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR0701MB3633; H:hyd1sverma-dt.caveonetworks.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR0701MB3633; 23:PUehWUyd3CKDIojBzzh8o3FGG7eydsjZ/Mtorr1?= =?us-ascii?Q?CV9pXC5RDnVFG8f71IxctNa7dDpUaSu0EjhwGsTY5cBDfp7oQ7sr1fRcmyJg?= =?us-ascii?Q?ZErHW+4z0P8Hlh4O0dB5ojjhtQVOwHG67Ofvg2EMRBPJifWprBO9AY42mMuG?= =?us-ascii?Q?mHMIfv1HhsINDJjVx0F04s6ixW6CaMkbVCY1oPIWOK0qcAUFxfPEZCswmBu/?= =?us-ascii?Q?UwCIPDT2qtgKySqCvLzPidumJkOgz59sNA2JFzw/T31Yv+5MK6bjnlfETZSc?= =?us-ascii?Q?dk3YgIQRM+IUFqaZAgjI9vi6TbB2hqiRsXf6mNp3Xwn2IrTY413uh7+3ZEdx?= =?us-ascii?Q?ek+zavm/qMJcDK1iPnE6AK1EPF068nETMbgZyQVmh0VKZ5kATqOPzUCwydll?= =?us-ascii?Q?Y4d1lB5W4I1vAzRFX6Vrx/2/2JV2HdDtug+yzGzpS+XwP3XPwxukUlBXhBtC?= =?us-ascii?Q?/R32cXnXh0GLJR0LE1DlWPoeiA6WthXqeGRcuCAMaR5icK13vQDnqLdDYJ1C?= =?us-ascii?Q?gkEJHVLDV2XvXm5YysnwLkiJ/cesIRxZZj7jzDkz7yTGIqvpxbAWH5XOhVqN?= =?us-ascii?Q?3TBGml5EOhhOfRlDNGcYC6378/DzNlN3eYkXuGJJ7gj9FrOuJF0g5suZ5Qla?= =?us-ascii?Q?JEZ9u7FJFTd9AQYlKapPP1mm6BQ0k7GNNAQtnq9rZpyEMe8njqo4VudVWiy9?= =?us-ascii?Q?tn4mwJMWtpiwj9Hd/qbRij0YMFp2GXI3EF63SSKej2PagzSOkf8CiuA/T6rK?= =?us-ascii?Q?xTejqiiavCw3iKIr8SFso8aVOWNvRmJ7RLoB6iShXI/wcgHO2C9tTbrexXzH?= =?us-ascii?Q?vO84sclVuRyjZ3dTuTBR2dVfYx4Cv26GB3rsAWPQGgh9PMONOFIQ0BYR6H2/?= =?us-ascii?Q?0b058Z/QolILs/vWrt7fLQFDgA3AubT6r0h+4phuUDbRRiAtASBP1+wS4Rm8?= =?us-ascii?Q?oe+YMcSHs6fBQdDMEfaUlBzJNfahRYhEu1KthXHwor3HpQThiJOX1/u+tCH+?= =?us-ascii?Q?vik/qMuoB4PUrdHpW817xFZsuDlkwKyUzlkb9v5bx20HzdcjWFtRs2heOz8S?= =?us-ascii?Q?d021fWfsUgwV6PRQ/reWlTYI3DmJaQlWvgNVu+x318J3H73Jq8eykdpGf481?= =?us-ascii?Q?IRZxgcQEroB3oWsryVMpMBQN5ESqdhoUFyOlVXvmHlrsmdfRXauOgfLVrs7S?= =?us-ascii?Q?bO8WKOAhYLxfUrchVVLY5UGOZih8ycgvhiouMI2sp4Acx8naaZYxyUj3JkVF?= =?us-ascii?Q?XUVKv/6Kxgqd3F299zOkx6emO14b+CG9sLKlWTtbuFeo/bFMaw9c9K/hQssr?= =?us-ascii?Q?oc5euwwDKtzX8/7TK9ynwGAbXCkuOwxZ9OvaHRCXoxtiFB6GZt5NeBW6aF91?= =?us-ascii?Q?eV0KGfLsQ7f4lesM9tgHJX5jy9aWpGpzgWBw+ZS66KHp43Wru?= X-Microsoft-Antispam-Message-Info: Mvxw3ADZ4kaQgn0cxNUnchrUyNLCWVAwLSZbZQ1PtEEBuXLgOKyl+0ymFuCTZGoks3QHn5g11dKdIsXtpTTz5svuD2ugMBuYo6ul1UBNGue2BvPnsL4tbINPSuIL76IJMqH6SlpvyH40N564OlQhZBiStr79K1DYlwFnO0i+Ce1B7jh4fc8VCcX+5CbmxNlZ X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3633; 6:TzZqKOczMV383elVSeq7ojebEPLp1jEY3RBBmXQ1mS5hxHkWaqde9CeNDNXWaLY5M2TsjgZ8eLersK38aTE4NT2RL1ZM46Tg7a88BNXRN7g2zit3bdAf+OJmNVvd59HYWYpL4fbUlD7Jw0uXlZ0Bm6HpG4DZg6VfyjbNzefKGtuiseQE586tXkxFAjagZupOOzhb3vgGPkaE4pNXZ6JtjRGuExWCw2b+vKL+2E224JE4V6sm2xdQEI/K/jA2tqibU2eP1kPSvnxpBC4IHi4m/BQc7nAVCj41onxZLOVubC1sxkn7Ml0iaK90PgTPRIVjeU3QE5pYz5S4nz1YfvXbTOI2b8Cf6vFqA8tJG/STAckQuQEtIN0kZcn79F8RDfBssrKZZ9LOmbiQfCgIfema7IePfZ7DMeaLV2/him15HG+6sru96BF0PVmsOB+IEjBck5mZ5/c1rtjGRV79AklMmw==; 5:T4fb3BDhLKd3o6KE0plsIC62lnNGkPp/t/b1M3bxC/BCe/NEYsuU78wAMkvyDP3k3vsdUmSfUM3GC6PmpnG5gVYw4JbImVEC+jzNCIhtH3WvNOwCQmr1rKgxE//YQiTbMClcUBAmV27N7JjfMM+No5pijbXquMZlG+S+LQFvcFw=; 24:gs3dzXJJh/vpqhOHIkHNVcln+2K3MpRG3t1u9OWTgMmJxliydxJrou5YfSQblcPcVuN54GHIhgUlypEi7ljbHBazBO68y4gqmuf1/KL9I3k= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3633; 7:/uFi69GA0nOZbTC7GZ4VY75EQuViHnJ1HD9Yh03MINYBQxtGXnY1eTwYxxZfBVxNuzkcJW2aFlUofFDxe4XOiFOzhq24Wc7MXJhiPpEOjC4DCYyfWKvYtK5hCRPmMsZPBtd+Ms+vV73lcfdq3rbiodzc+FslvpPJcdUbL4lHGXZIAL13A5R2FTpmzL5n9qZ4qm7ng7RpPWL30vfvJKdD3nYG31hMcogEjzffyIZeSEZkbiM2zmzhE5Aem+3N2yIU X-MS-Office365-Filtering-Correlation-Id: ce9b728b-567a-492e-7393-08d5cad02661 X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2018 10:36:06.1067 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ce9b728b-567a-492e-7393-08d5cad02661 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR0701MB3633 Subject: [dpdk-dev] [PATCH v1 4/7] compress/octeontx: add ops 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: Tue, 05 Jun 2018 10:36:11 -0000 implement enqueue and dequeue apis Signed-off-by: Ashish Gupta Signed-off-by: Shally Verma Signed-off-by: Sunila Sahu --- drivers/compress/octeontx/zip_pmd.c | 111 ++++++++++++++++++++++++ drivers/compress/octeontx/zipvf.c | 49 +++++++++++ drivers/compress/octeontx/zipvf.h | 164 ++++++++++++++++++++++++++++++++++++ 3 files changed, 324 insertions(+) diff --git a/drivers/compress/octeontx/zip_pmd.c b/drivers/compress/octeontx/zip_pmd.c index 349114626..9e629fd17 100644 --- a/drivers/compress/octeontx/zip_pmd.c +++ b/drivers/compress/octeontx/zip_pmd.c @@ -30,6 +30,67 @@ static const struct rte_compressdev_capabilities RTE_COMP_END_OF_CAPABILITIES_LIST() }; +/* + * Reset session to default state for next set of stateless operation + */ +static inline void reset_stream(struct zip_stream *z_stream) +{ + union zip_inst_s *inst = (union zip_inst_s *)(z_stream->inst); + + inst->s.bf = 1; + inst->s.ef = 0; +} + +int +zip_process_op(struct rte_comp_op *op, + struct zipvf_qp *qp, + struct zip_stream *zstrm) +{ + int ret; + union zip_inst_s *inst = zstrm->inst; + volatile union zip_zres_s *zresult = NULL; + + if (op->op_type == RTE_COMP_OP_STATELESS) + zipvf_prepare_cmd_stateless(op, zstrm); + + zresult = (union zip_zres_s *)zstrm->bufs[RES_BUF]; + zresult->s.compcode = 0; + +#ifdef ZIP_DBG + zip_dump_instruction(inst); +#endif + + /* Submit zip command */ + ret = zipvf_push_command(qp, (void *)inst); + + /* Check and Process results in sync mode */ + do { + } while (!zresult->s.compcode); + + if (zresult->s.compcode == ZIP_COMP_E_SUCCESS) { + op->status = RTE_COMP_OP_STATUS_SUCCESS; + } else { + /* FATAL error cannot do anything */ + ZIP_PMD_ERR("operation failed with error code:%d\n", + zresult->s.compcode); + if (zresult->s.compcode == ZIP_COMP_E_DSTOP) + op->status = RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED; + else + op->status = RTE_COMP_OP_STATUS_ERROR; + } + + ZIP_PMD_INFO("ret %d,written %d\n", ret, zresult->s.totalbyteswritten); + + op->produced = zresult->s.totalbyteswritten; + op->consumed = zresult->s.totalbytesread; + + if (zresult->s.ef == 1) + reset_stream(zstrm); + + zresult->s.compcode = 0; + return ret; +} + /** Parse xform parameters and setup a stream */ int zip_set_stream_parameters(struct rte_compressdev *dev, @@ -399,6 +460,56 @@ zip_pmd_stream_free(struct rte_compressdev *dev, void *stream) return 0; } +static uint16_t +zip_pmd_enqueue_burst_sync(void *queue_pair, + struct rte_comp_op **ops, uint16_t nb_ops) +{ + struct zipvf_qp *qp = queue_pair; + struct rte_comp_op *op; + struct zip_stream *zstrm; + int ret, i; + uint16_t enqd = 0; + + for (i = 0; i < nb_ops; i++) { + op = ops[i]; + if (op->op_type == RTE_COMP_OP_STATEFUL) + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + else { + /* process stateless ops */ + zstrm = (struct zip_stream *)op->private_xform; + ret = zstrm->func(op, qp, zstrm); + } + + /* Whatever is out of op, put it into completion queue with + * its status + */ + ret = rte_ring_enqueue(qp->processed_pkts, (void *)op); + if (unlikely(ret < 0)) { + /* increment count if failed to enqueue op*/ + qp->qp_stats.enqueue_err_count++; + } else { + qp->qp_stats.enqueued_count++; + enqd++; + } + } + return enqd; +} + +static uint16_t +zip_pmd_dequeue_burst_sync(void *queue_pair, + struct rte_comp_op **ops, uint16_t nb_ops) +{ + struct zipvf_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; +} + struct rte_compressdev_ops octtx_zip_pmd_ops = { .dev_configure = zip_pmd_config, .dev_start = zip_pmd_start, diff --git a/drivers/compress/octeontx/zipvf.c b/drivers/compress/octeontx/zipvf.c index 436e80b78..d50f36d64 100644 --- a/drivers/compress/octeontx/zipvf.c +++ b/drivers/compress/octeontx/zipvf.c @@ -85,6 +85,55 @@ int zipvf_q_term(struct zipvf_qp *qp) return 0; } + +int zipvf_push_command(struct zipvf_qp *qp, union zip_inst_s *cmd) +{ + zip_quex_doorbell_t dbell; + union zip_nptr_s ncp; + uint64_t *ncb_ptr; + struct zipvf_cmdq *cmdq = &qp->cmdq; + void *reg_base = qp->vf->vbar0; + + /*Held queue lock*/ + rte_spinlock_lock(&(cmdq->qlock)); + + /* Check space availability in zip cmd queue */ + if ((((cmdq->sw_head - (uint64_t *)cmdq->va) * sizeof(uint64_t *)) + + ZIP_CMD_SIZE) == (ZIP_MAX_CMDQ_SIZE - 8)) { + /*Last buffer of the command queue*/ + memcpy((uint8_t *)cmdq->sw_head, + (uint8_t *)cmd, + sizeof(union zip_inst_s)); + /* move pointer to next loc in unit of 64-bit word */ + cmdq->sw_head += ZIP_CMD_SIZE_WORDS; + + /* now, point the "Next-Chunk Buffer Ptr" to sw_head */ + ncb_ptr = cmdq->sw_head; + /* Pointing head again to cmdqueue base*/ + cmdq->sw_head = (uint64_t *)cmdq->va; + + ncp.u = 0ull; + ncp.s.addr = cmdq->iova; + *ncb_ptr = ncp.u; + } else { + /*Enough buffers available in the command queue*/ + memcpy((uint8_t *)cmdq->sw_head, + (uint8_t *)cmd, + sizeof(union zip_inst_s)); + cmdq->sw_head += ZIP_CMD_SIZE_WORDS; + } + + rte_wmb(); + + /* Ringing ZIP VF doorbell */ + dbell.u = 0ull; + dbell.s.dbell_cnt = 1; + zip_reg_write64(reg_base, ZIP_VQ_DOORBELL, dbell.u); + + rte_spinlock_unlock(&(cmdq->qlock)); + return 0; +} + int zipvf_create(struct rte_compressdev *compressdev, int vfid) { struct rte_pci_device *pdev = RTE_DEV_TO_PCI(compressdev->device); diff --git a/drivers/compress/octeontx/zipvf.h b/drivers/compress/octeontx/zipvf.h index 2388e2947..849094fc6 100644 --- a/drivers/compress/octeontx/zipvf.h +++ b/drivers/compress/octeontx/zipvf.h @@ -162,10 +162,174 @@ struct zip_vf { /* pointer to pools */ } __rte_cache_aligned; + +static inline int +zipvf_prepare_in_buf(struct zip_stream *zstrm, struct rte_comp_op *op) +{ + uint32_t offset, inlen; + union zip_zptr_s *sg_list = NULL; + struct rte_mbuf *m_src; + union zip_inst_s *inst = zstrm->inst; + rte_iova_t iova; + + inlen = op->src.length; + offset = op->src.offset; + m_src = op->m_src; + + if (m_src->nb_segs == 1) { + /* Prepare direct input data pointer */ + inst->s.dg = 0; + inst->s.inp_ptr_addr.s.addr = + rte_pktmbuf_iova_offset(m_src, offset); + inst->s.inp_ptr_ctl.s.length = inlen; + return 0; + } + + ZIP_PMD_ERR("Input packet is segmented\n"); + + /* Packet is segmented, create gather buffer */ + inst->s.dg = 1; + iova = rte_mempool_virt2iova(zstrm->bufs[IN_DATA_BUF]); + if (iova & 0xF) { + /* Align it to 16 Byte address */ + iova = ZIP_ALIGN_ROUNDUP(iova, ZIP_SGPTR_ALIGN); + } + + inst->s.inp_ptr_addr.s.addr = iova; + inst->s.inp_ptr_ctl.s.length = (m_src->nb_segs < MAX_SG_LEN) ? + (m_src->nb_segs) : MAX_SG_LEN; + + sg_list = (union zip_zptr_s *)iova; + + int i = 0; + rte_iova_t addr; + uint16_t len; + + while (i < inst->s.inp_ptr_ctl.s.length) { + addr = rte_pktmbuf_iova_offset(m_src, offset); + len = rte_pktmbuf_data_len(m_src); + if (len > inlen) + len = inlen; + sg_list[i].s.addr = addr; + sg_list[i].s.length = len; + i++; + inlen -= len; + m_src = m_src->next;//try offset += len instead + offset = 0; + } + return 0; +} + +static inline int +zipvf_prepare_out_buf(struct zip_stream *zstrm, struct rte_comp_op *op) +{ + uint32_t offset; + union zip_zptr_s *sg_list = NULL; + struct rte_mbuf *m_dst; + union zip_inst_s *inst = zstrm->inst; + rte_iova_t iova; + + offset = op->src.offset; + m_dst = op->m_dst; + + if (m_dst->nb_segs == 1) { + /* Prepare direct input data pointer */ + inst->s.ds = 0; + inst->s.out_ptr_addr.s.addr = + rte_pktmbuf_iova_offset(m_dst, offset); + inst->s.totaloutputlength = rte_pktmbuf_data_len(m_dst) - + op->dst.offset; + inst->s.out_ptr_ctl.s.length = inst->s.totaloutputlength; + return 0; + } + + ZIP_PMD_ERR("output packet is segmented\n"); + + /* Packet is segmented, create gather buffer */ + inst->s.ds = 1; + iova = rte_mempool_virt2iova(zstrm->bufs[OUT_DATA_BUF]); + if (iova & 0xF) { + /* Align it to 16 Byte address */ + iova = ZIP_ALIGN_ROUNDUP(iova, ZIP_SGPTR_ALIGN); + } + + inst->s.out_ptr_addr.s.addr = iova; + inst->s.inp_ptr_ctl.s.length = (m_dst->nb_segs < MAX_SG_LEN) ? + (m_dst->nb_segs) : MAX_SG_LEN; + + sg_list = (union zip_zptr_s *)iova; + + int i = 0; + + while (i < inst->s.inp_ptr_ctl.s.length) { + sg_list[i].s.addr = rte_pktmbuf_iova_offset(m_dst, offset); + sg_list[i].s.length = rte_pktmbuf_data_len(m_dst); + inst->s.totaloutputlength += sg_list[i].s.length; + m_dst = m_dst->next;//try offset += len instead + offset = 0; + i++; + } + + return 0; +} + +static inline int +zipvf_prepare_cmd_stateless(struct rte_comp_op *op, struct zip_stream *zstrm) +{ + union zip_inst_s *inst = zstrm->inst; + + /* set flush flag to always 1*/ + inst->s.ef = 1; + + if (inst->s.op == ZIP_OP_E_DECOMP) + inst->s.sf = 1; + else + inst->s.sf = 0; + + /* Set input checksum */ + inst->s.adlercrc32 = op->input_chksum; + + /* Prepare gather buffers if input packet is segmented */ + zipvf_prepare_in_buf(zstrm, op); + zipvf_prepare_out_buf(zstrm, op); + + return 0; +} + +#ifdef ZIP_DBG +static inline void zip_dump_instruction(void *inst) +{ + union zip_inst_s *cmd83 = (union zip_inst_s *)inst; + printf("####### START ########\n"); + printf("doneint:%d totaloutputlength:%d\n", cmd83->s.doneint, + cmd83->s.totaloutputlength); + printf("exnum:%d iv:%d exbits:%d hmif:%d halg:%d\n", cmd83->s.exn, + cmd83->s.iv, cmd83->s.exbits, cmd83->s.hmif, cmd83->s.halg); + printf("flush:%d speed:%d cc:%d\n", cmd83->s.sf, + cmd83->s.ss, cmd83->s.cc); + printf("eof:%d bof:%d op:%d dscatter:%d dgather:%d hgather:%d\n", + cmd83->s.ef, cmd83->s.bf, cmd83->s.op, cmd83->s.ds, + cmd83->s.dg, cmd83->s.hg); + printf("historylength:%d adler32:%d\n", cmd83->s.historylength, + cmd83->s.adlercrc32); + printf("ctx_ptr.addr:0x%lx\n", cmd83->s.ctx_ptr_addr.s.addr); + printf("ctx_ptr.len:%d\n", cmd83->s.ctx_ptr_ctl.s.length); + printf("history_ptr.addr:0x%lx\n", cmd83->s.his_ptr_addr.s.addr); + printf("history_ptr.len:%d\n", cmd83->s.his_ptr_ctl.s.length); + printf("inp_ptr.addr:0x%lx\n", cmd83->s.inp_ptr_addr.s.addr); + printf("inp_ptr.len:%d\n", cmd83->s.inp_ptr_ctl.s.length); + printf("out_ptr.addr:0x%lx\n", cmd83->s.out_ptr_addr.s.addr); + printf("out_ptr.len:%d\n", cmd83->s.out_ptr_ctl.s.length); + printf("result_ptr.len:%d\n", cmd83->s.res_ptr_ctl.s.length); + printf("####### END ########\n"); +} +#endif + int zipvf_create(struct rte_compressdev *compressdev, int vfid); int zipvf_destroy(struct rte_compressdev *compressdev); int 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); int zip_set_stream_parameters(struct rte_compressdev *dev, const struct rte_comp_xform *xform, struct zip_stream *z_stream); -- 2.14.3