From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0087.outbound.protection.outlook.com [104.47.40.87]) by dpdk.org (Postfix) with ESMTP id 3F6FF1B55A for ; Mon, 2 Jul 2018 18:56:08 +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=m6gsSnzz9B1cnabXVSf7BxPeVES7eA3aWSaj+r3UCJU=; b=fhmbR5x80VbKkGzeNMTviAN8Jg5Ca0R7i5q6vly/E2GbucvZVG4Pq2NglwyXqBja+O8SIW0KxVVwAnG4bQ9vB1JdMRcdjJFX5J1U6TRwqzqW9RYcBLw4+coSUnWVFofrRlV80hfZ/c3m1euu/UPWXIltqVLQYxadnNeawrjZqGI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Shally.Verma@cavium.com; Received: from hyd1sverma-dt.caveonetworks.com (115.113.156.2) by MWHPR0701MB3644.namprd07.prod.outlook.com (2603:10b6:301:7d::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.20; Mon, 2 Jul 2018 16:55:59 +0000 From: Shally Verma To: pablo.de.lara.guarch@intel.com Cc: dev@dpdk.org, pathreya@caviumnetworks.com, mchalla@caviumnetworks.com, Ashish Gupta , Ashish Gupta , Sunila Sahu Date: Mon, 2 Jul 2018 22:24:35 +0530 Message-Id: <1530550477-22444-5-git-send-email-shally.verma@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530550477-22444-1-git-send-email-shally.verma@caviumnetworks.com> References: <1530550477-22444-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: MAXPR0101CA0007.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:c::17) To MWHPR0701MB3644.namprd07.prod.outlook.com (2603:10b6:301:7d::37) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8745f7aa-11f2-49df-97fb-08d5e03cb3d9 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:MWHPR0701MB3644; X-Microsoft-Exchange-Diagnostics: 1; MWHPR0701MB3644; 3:weE3rhS7l8EVpHCAsoIDOhoTJYd3+rq483vwgTBFRX+0J/xN56d9MQvtlrP9WiCCKPviJo5NvP7gCag3l+YYRy4b8GjGEkY20QjNV7oau2aHizrv7p/5hv7bRFo32eUerZuDRp9FKo3dMWv7EZMvEOchJNDWynNIUs/2tQ1bXkU2zWYAVAbw/VF7F6ebJNsmtHJS2LKU29UTe6PGh5XgF+aIT8JN3LG/OSWTdZ2PtcQaiySOl17TArVb/ty8sNEf; 25:P8Ae/0TKFV1FZA5KYzNdaD1UcbOFvsflpFKzZMGpTDF2GizRbsYb/gGzK74SdFpMx4bdCpxb9FSIIjEzXmBvGWgxEU+0qBiCrJD+TPnrOuRPoXd3EC7CMHss6mnu64modBTUkHCDAX7khCV3x+141ZZNDevI2Y+vu+uO7mXDXS0ghH/0+ArYJcwgD7QZw3pOdfpyuoHnJASsgZgIjuobCCj+FcWq4nMQFmJcAM7hK2CRY8Xoksv+xgLXJ732bqLoHoKPg/HSh+k7JyoAORE5y1o2KQNxurN6o/LZRQzCtDyOZe/I6gSMK5cL9YG7BQwkJrSE0c4uEs/fKSJ2FO4CGQ==; 31:mVr7uImO9uCx2XlMjtHW9wMuTO8wrtlMhZNrfgcSSycjUSTYuD4j8bytEij4gejaK+q0VbW3KOGK0pL6kUNylVrevLnfPm/pQiIGefXZFJfjEKFkK8UPN61GUHW+5V8PpRnI9t6UHDR3FGsovCd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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)(10201501046)(3002001)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:MWHPR0701MB3644; BCL:0; PCL:0; RULEID:; SRVR:MWHPR0701MB3644; X-Forefront-PRVS: 07215D0470 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(396003)(136003)(39860400002)(346002)(376002)(189003)(199004)(6506007)(25786009)(55236004)(107886003)(3846002)(6116002)(16586007)(2906002)(14444005)(186003)(51416003)(52116002)(16526019)(76176011)(4326008)(6486002)(105586002)(386003)(36756003)(6512007)(2351001)(42882007)(54906003)(69596002)(72206003)(2361001)(53936002)(26005)(48376002)(50466002)(316002)(68736007)(478600001)(6916009)(476003)(81166006)(66066001)(81156014)(8936002)(575784001)(97736004)(8676002)(47776003)(446003)(11346002)(106356001)(50226002)(2616005)(956004)(6666003)(44832011)(53416004)(486006)(7736002)(305945005)(5660300001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR0701MB3644; 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; MWHPR0701MB3644; 23:D2L4gPe7Vi9diHwfteL+KjQmrr3ZT6Myn1AmntM?= =?us-ascii?Q?RkKrYa9uIrgweCTFc1tLERpF9Ht15YIaJdn7XeXkmp7IWd2fi8TC8RQU0x0O?= =?us-ascii?Q?Y7gqwGmq+Zqd+lgdBNrkoA5Zcua3jtO4I4vG+IrDbHL7pI8koaiWHdnduXl8?= =?us-ascii?Q?EY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3/gmU1ccHjxOQBRBwTIXI+3eQZ01q3PpHp68vVxW4OoTUW+5xmuUh8FNynSPD4NJgrJua1oS9RER9MIM4uTn/Vpx7OF/qtVE0vfjYg93ARPQAhNiIHZIxUE2twxbOtCvgaHk08C5n3pdh5VEHsuyHKOuakSpN4q1uA2QJqFqOekndFtlGmPd1H5/EGmMCt4wsZ1XbME+fsGhxxyxqLyehn/FLKm4e1XoQv2R/A+INUlQUNs9Dsazb0ZLFw==; 5:PLOiIh2LptCWTlG86BQOeSDkHcHrwAkaXwlwM+Fh9x5XwVOX9ZDK45I/FrPS2cisZH/odSyX6gKpyc58ioYiQuOOO5I3LeMTqrsVu6p3XVVbPj2Ozs9QDPfoFdVt1rFIrmio3iGqhP98oGQXrpcwlEJ8fo7gceDlGMgudyQwrd0=; 24:Q9OmSnxxEpS4u0RHlrzN+ZJBIoWWow8LnrbTH4AqxnYdZoSMmHPWfgEWrrb1miOrZUBiCveTpdPr2Ck/Yf3KCVuhE8GXE9DD7JbnX8/Txcg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR0701MB3644; 7:zJFncf7mRushsqXFuMDOMvySUUPvkHVmWw/Rw6OQVsxNsBs9a+houBfxET7sXkGJVKZmUcnkTjhdf8eXefpd387Vk9HmOB6TJDprhURdZFkCqtPEpYWEYoGNDDsKWvajxPSamvyQDtSxHcVbz75BNkfbbIOlC/Pcq0LwuG+hBWvghsnHpjHMvDz9EwdiKNxfe31TMQsXL+veev/T/MkbOaj86nsseF9KSecW0rVzxPiA6ZGsg9ORuJ5y1EWRxI1D X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2018 16:55:59.2520 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8745f7aa-11f2-49df-97fb-08d5e03cb3d9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR0701MB3644 Subject: [dpdk-dev] [PATCH v2 4/6] 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: Mon, 02 Jul 2018 16:56:08 -0000 From: Ashish Gupta 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 | 114 ++++++++++++++++++++++++ drivers/compress/octeontx/zipvf.c | 49 +++++++++++ drivers/compress/octeontx/zipvf.h | 169 ++++++++++++++++++++++++++++++++++++ 3 files changed, 332 insertions(+) diff --git a/drivers/compress/octeontx/zip_pmd.c b/drivers/compress/octeontx/zip_pmd.c index c8feb96bc..4a0eea41a 100644 --- a/drivers/compress/octeontx/zip_pmd.c +++ b/drivers/compress/octeontx/zip_pmd.c @@ -25,6 +25,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; + + 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, @@ -111,6 +172,7 @@ zip_set_stream_parameters(struct rte_compressdev *dev, inst->s.res_ptr_ctl.s.length = 0; z_stream->inst = inst; + z_stream->func = zip_process_op; return 0; @@ -385,6 +447,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, @@ -446,6 +558,8 @@ zip_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, compressdev->dev_ops = &octtx_zip_pmd_ops; /* register rx/tx burst functions for data path */ + compressdev->dequeue_burst = zip_pmd_dequeue_burst_sync; + compressdev->enqueue_burst = zip_pmd_enqueue_burst_sync; compressdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED; return ret; } diff --git a/drivers/compress/octeontx/zipvf.c b/drivers/compress/octeontx/zipvf.c index 2a74e8bbb..996ae69ab 100644 --- a/drivers/compress/octeontx/zipvf.c +++ b/drivers/compress/octeontx/zipvf.c @@ -91,6 +91,55 @@ zipvf_q_term(struct zipvf_qp *qp) } +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) { diff --git a/drivers/compress/octeontx/zipvf.h b/drivers/compress/octeontx/zipvf.h index 038877e4e..ee39b8eb3 100644 --- a/drivers/compress/octeontx/zipvf.h +++ b/drivers/compress/octeontx/zipvf.h @@ -156,6 +156,170 @@ 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_INFO("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 *)(zstrm->bufs[IN_DATA_BUF]); + + 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_INFO("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 *)(zstrm->bufs[OUT_DATA_BUF]); + + 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); @@ -176,6 +340,11 @@ zip_set_stream_parameters(struct rte_compressdev *dev, const struct rte_comp_xform *xform, struct zip_stream *z_stream); +int +zip_process_op(struct rte_comp_op *op, + struct zipvf_qp *qp, + struct zip_stream *zstrm); + uint64_t zip_reg_read64(uint8_t *hw_addr, uint64_t offset); -- 2.14.3