From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0079.outbound.protection.outlook.com [104.47.36.79]) by dpdk.org (Postfix) with ESMTP id C41DC326D for ; Fri, 20 Jul 2018 20:42:51 +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=+LqiDkjJnsBCPSsTTC5yTOso7ZpcHzSsUJEkenUsXcQ=; b=dfHtLLE06P8Cs4EKiYWTGS63oVu8F+A49bjk7wRbrFs4Loap5ZU/sfzgtYDOKxbdvbNmCyJN34R4tzbfvdlGroU8LKcneD6c1G3NgO4hc2k0wOp0TpDiQGH7p/kg9yzKobUTYh4nD/bgZYqGqvP9eNa84KFrCf9bDEcigsB0awg= 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:48 +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:45 +0530 Message-Id: <20180720190447.7979-5-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: f6722196-f9f0-47d2-4b88-08d5ee709899 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:Tlq1tG88SWHRqJankELc+c3H1OuuuPsL8dge/yJDAI6RQP7lLthkXJ/VwVt9JBEfjksUS9XB01wjpMYnlx1uNn0LVXtCJUa3QIxHgrS+d2TPurq72h7wMo0CnOabN+ms3XIKSr2mplaFfhfahrsTKyLFoV3WYVHkle2MdQiMTEZ/7dCSK0Zuqljw3lvrtbzsHBlJfI4qlp3Rei3+HFN5YdNNDmdKjlQvnArIGDSudP7pQOCu46LEq2cwlmy2Ifra; 25:sI8/+17jiIIzvhObMrr9PTkKMNpQGjYGekk9beahk6acimF5gvZ1ObvBBo4szJnzE5V/dNyPgpHYwqznogxu206KwNLgOb7Els/GcRHfgsAC+PYnzNQPUdW9uoorJnJ8UPnPn652YAiaw4s+4pmbikUD64jNM2lXvVIWaNLm5IwtzBP1h91pCKLNAzAH+mC9QVYqmzNWsdm21i03ln8V5Wy6q9+5VrZiEQVui/iWjLbh3RvyelQJTxs3Uuk2CZ8q3uBrh9R4Q58kzGB1kalu7llSXSAk9RAtNu7NkhZljPAAbAMwXl8FQC1lQ3WCT9bRo+xkdWxobIW/vpAQLUKSpQ==; 31:msU/aDQffWeRNPRw/8LxXHb52+o0z7bhFhGUKksgdcO0uDAGzVWekWjDiOk60/rBRaEDdWbaRoeXZAW6tf9wII3e9g7DD8dIgESBr7M/wNKdbD294Ytx3YKPKp1ZKX/m0fQUB8hu1ByUJWsbS2CK7jpaQOiK3oZSl9EGmsLr21JJkgmY8GqTGbdkMACYFZZiPStr6EL64plibOrbqH3hZ3bnI2ge36l8yMbJMvWfjow= X-MS-TrafficTypeDiagnostic: BN6PR07MB3057: X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3057; 20:3dByk2jzO4jYmMkSI8vnX/HSEVr1OFbv/XQUWGVZNnzEYnEwWb8GhGTHF+7cbSRxflro9hqQnPFgMWRu5ENSj0OWbFgmL/2EoLseeRmUjhj/QP4JSD1psjg7UFQfHSZufgfiSo8w18p7D4KBoQo0zBx0Msm3XHSqh9uLyHsL6nveUM8NRq8cy1xLQZr8dDqOi0E35muYBBhmZ/CL3IAcio+7XqIBHuFFkBHNw+xB1xQEy8RbfRONekQ0FBFkU1vwl04ismWjay+dCKMPOBJ1kbJmSu5+9sO5QEsWl2DJihUkKQ1GBASnnD6QOaHK9ZytoMToyGKE3XTP/s8axxiEOrfiE32YqsqUJwAxgVpTCFFr5BNTRhjxDTHAYZyCHtlXIW1xTfT5kqlcSsp+Untp/2fclOS3mgki0d7BO/bFGOQ9TeuUaCvJiVb4L6Mia0x5D6mbAf4fCjDPL2i60vCcKREmxanmfjJv+rHUFk5TeqFp1HTexI+SrlTiOJQG64eJRLtl6m/egCbxhcVimQknU2eCT0en3LiSUOyrD78LsQRlMJ0GIeR8K+jrqVwXEFcr2RXgV71ZvEyXjEj2G5W8Le3uKh58JADWa3pBAW3b7Hg=; 4:1dozBZ4y+oTQN2lNgOV5zYnt+xvykvRP0RUDCjfHEZ/o0bMMwgQX/TIkuKcyLsSYDzpWtuPtR6Ve00crgLeQE3vu4uhI5vDDRw2zi9T94R24gGJmRdLU6/p0vhm4h0N53iGxwuQxVqnRq6Mlxjoy644P56eecwJfs8mpKtanziNSJ9IDELExZLqXIBbizSzK1IfTP7IbPB6SUDmha4WSIptwclJpT0cTNuTkqA4Jl06ITo4Feordsh8XHkxJK65E6AaUb9KkcoDdl3zyo4hJOQ== 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)(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)(6666003)(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:o/lNFdAuLInKui7VtcnNnPDzwsO86BnLZCBZHFEwf?= =?us-ascii?Q?L/xDZ5cxGCANNw0DeMi3kAcsxj53n5Cxo6HjqcdfWrZpBf8PaHNQNGxrGkze?= =?us-ascii?Q?quGk8MRPRqI9yetWXvKUqbxXsKWM/cv0IyTRBeRd47HB0swMpLpQ6P5vDfKC?= =?us-ascii?Q?7dP4LkrY00pfdSGmXG1+O0RFbasH1f56lnpwVXYB7G5KG+fmYbVRXl1eWjye?= =?us-ascii?Q?R8YuumOpitFtoGPRST4MYKqRyd+QHtfwKW1U/ZG4afrEfgq/w2eajBTY8ZfL?= =?us-ascii?Q?KEuxy72CSJ6wionGGbviz7AxylZ88iUagpwSeStesdXpF0/iQPvTgeF7p6XY?= =?us-ascii?Q?DBN/jS09dhhk30YihLMyqDSZNzmxsUo5rZzXnZE6qexRzyO2JdOGAr4O8aIa?= =?us-ascii?Q?v2mr9gJQn+vG1Vg1Mzn9hCSI2wZT7WRc+wPpoxtdxKF2F2FmRKnmhtIG3kUo?= =?us-ascii?Q?d1mQvyFQkR7WwRivT/1zh1MMz9gORKLEy1znGNKgd/KdVYvbA3jXaTCevjpq?= =?us-ascii?Q?BlDxlnn4anwtZOEqlM5Do6PKG8hPS2g718AXfsXK/zL4Sc3+WDTtBNMwnFc1?= =?us-ascii?Q?bWMuDAlxGKCopfhhRpyS2tL1ff5nvxMT5Xj7OzJ86um2OEapSmSf0z9OedV6?= =?us-ascii?Q?0dx0SJAHmZ8AxVxsLUUrAmqpfS5Lg8fEZ3O7sVrxkHJmbBFxB4wphlr0hKbE?= =?us-ascii?Q?ISv40xGA2MnYW37QoizPEqZixrS1BA65ia37z+HSkgec/fkZsiJ586HS9UF+?= =?us-ascii?Q?uKp1N7tOP8kHMh29pGm3NfXrLyRseFbqcAdTuEhBkzL116Te89QFI93ZsNXA?= =?us-ascii?Q?sZtChDf08HL1nhFTutDwxlf5AStY5xtoelniKVUY8muhN/3Dxri9YmYEjaJ9?= =?us-ascii?Q?z2XANVeIv34+nxlU/pgVLSk282HDIIOeH+cezRnBoNa1zO/FjHeW7emk7nWF?= =?us-ascii?Q?txFUQ+dWF0dAeOt1Kj1tKUj0vLIoKo4WxSvW3gY5xEYayMLTLEwr33K2D9I4?= =?us-ascii?Q?aD/BM3dxWVBb0gNCtI6Ul/drGCaUIo6i9Y69VSiJO52NA3apTdjicJjdiZVt?= =?us-ascii?Q?0XOfRCSDXXiBGpi6lw3kb69ZBb//idDd2m+ekYxhoy68jcA78FUkobHeovqv?= =?us-ascii?Q?XRrfSEg9vrlQOL/JgOGYRoxZ1A0kRH7XFFl8Lwea7/PpBseqbC8RpL/6WHne?= =?us-ascii?Q?q4pQzFW9iAu5IJIv22VYdnNd12dor+chMtI1q7qnzbXdSvj26OmME77EY+Ag?= =?us-ascii?Q?awcTr/S9CbqUtyWldeucU/r7Jkny2VWXnshJyFSyKev7ixHXxba6W4DP/ZxM?= =?us-ascii?Q?0V/hCBQrLYkt7kRnA73WhBONBQgfcsg/nDfZA0KuCk7v151EkXHYJdcCNWTg?= =?us-ascii?Q?58U1toXcwuRaBugy2mZR3I3FqI=3D?= X-Microsoft-Antispam-Message-Info: BC5P1vCIv8fiWEK48zYM748uLTTi5Cu9X49NTOuTeK4zVEjkWbztjg4oOaAv3/RzfYiN2b0r42iflaBo2ZyC95KjAgvW1AVugfLg40uLc6DJkperCJwi6XjGJ7YlRdHHocpyERP3sKfFHFfTA95pCW9PtfL0FXwohaO3GIoeW5Qw/YmX+PIXbwoR6Rn9PX9oEvWRendsrckFCAup/3Va3V+RNz3yw1FzW5j3NloP6PLb8mjIDhxlje0FJz2OXf2iwcDrVTCPbuXKVkL6S5PN0JQttaAqgfN03C2pfUDahUMmcYe/MelTPhbOcoIPPb8V2M8OQjbhDAmXOai6Do6vUSWS/pYtYrMVqsXb2FDosNg= X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3057; 6:p0j4pHMuF9qbGQ7iRz3bFDJHGLTXTx+/I30DLmFQYqqY7iWmfAHsnW09YHoxXFNe+Mrkxs55YTMZBBSE5BCMNVbc6/eHNKNe1wvrgSJ/uh+EY1wqUw6D1UuOMZhhmA34rJpCM9KViO8GyMXN89uWt4JoCpvpakTheNMBfeQYEZFjzvi9j4uCrmMIVUImEn7e/CbVyADJuSjvUBU5pzIf8bF94SiWzYJ/7u2rSlgk9qm0KzElqxjcNi183/fPP+xX40x/P3rA97SGgrKUDlhIFV9xL/ooq28KAhlJIns4042uznbXC/ArtgMhmoFqHyzxCbwgQzt14UHsE/oJngt79/QqSxVDioK4ehgGkr9wHqOFd0JmWw+N0G0n/DjVEoGjic6rafbaQ0304IT2Ik76nX1Ebjeht9oCAGfSn3gFlWJ0gREV0H6XJaqy56A55domnGmIW2keDL2XqN0J0vbh5Q==; 5:wZbD7DSswF8Zn/dzTbDsA9xmUw7JwcOlo71dVOIcLe8AsKLe5aZyWUkKclzuZBjMjSXnMYAzeTntP0VS0msvOpejjqKAmLqrV+xTQ7WLP5JRhXoqVnaKw920ub4QMuHqFi9RadBsulFyAhJKo0Btr+08D+yfyx1ARAmCNEpdWVA=; 7:onSD6+J75RirVaz/fD+DD85UBLIC2Q6/QiWHnRnACB4XqhdnMj+Vj5cp5f2gaIRgo0KwKosAToxmcdYsf5WXqAkXUeyEoaYCW27CDM2qm7OzsctANnvGXSz/xV0S411D9rMIDQVWFu2P+see7TDP04wFoArGaeRpwHxiERpxoSkJyyFhn2o/RXFx7GNzf8x7sLxR/MFSxljQKMZIj4qN5lsbdk4IIKJxoBgpH1P21jmF3F7zZQFptspBtv28GqF6 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2018 18:42:48.8129 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f6722196-f9f0-47d2-4b88-08d5ee709899 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 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: Fri, 20 Jul 2018 18:42:53 -0000 Add enqueue/dequeue APIs to perform compression/decompression operations Signed-off-by: Ashish Gupta Signed-off-by: Shally Verma Signed-off-by: Sunila Sahu --- drivers/compress/octeontx/otx_zip.c | 49 +++++++++ drivers/compress/octeontx/otx_zip.h | 169 ++++++++++++++++++++++++++++++++ drivers/compress/octeontx/otx_zip_pmd.c | 119 ++++++++++++++++++++++ 3 files changed, 337 insertions(+) diff --git a/drivers/compress/octeontx/otx_zip.c b/drivers/compress/octeontx/otx_zip.c index 255b095de..6499ddb86 100644 --- a/drivers/compress/octeontx/otx_zip.c +++ b/drivers/compress/octeontx/otx_zip.c @@ -89,6 +89,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 - ZIP_MAX_NCBP_SIZE)) { + /*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/otx_zip.h b/drivers/compress/octeontx/otx_zip.h index 3fcd86a86..73a99e624 100644 --- a/drivers/compress/octeontx/otx_zip.h +++ b/drivers/compress/octeontx/otx_zip.h @@ -159,6 +159,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); @@ -174,6 +338,11 @@ zipvf_q_term(struct zipvf_qp *qp); int zipvf_push_command(struct zipvf_qp *qp, union zip_inst_s *zcmd); +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); diff --git a/drivers/compress/octeontx/otx_zip_pmd.c b/drivers/compress/octeontx/otx_zip_pmd.c index fac547920..a76c95117 100644 --- a/drivers/compress/octeontx/otx_zip_pmd.c +++ b/drivers/compress/octeontx/otx_zip_pmd.c @@ -28,6 +28,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 */ static int zip_set_stream_parameters(struct rte_compressdev *dev, @@ -114,6 +175,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; @@ -397,6 +459,61 @@ zip_pmd_stream_free(struct rte_compressdev *dev, void *stream) } +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 i, ret = -1; + uint16_t enqd = 0; + + for (i = 0; i < nb_ops; i++) { + + op = ops[i]; + + if (op->op_type == RTE_COMP_OP_STATEFUL) { + ret = -1; + 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 + */ + if (!ret) + 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, @@ -458,6 +575,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; } -- 2.14.3