From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0080.outbound.protection.outlook.com [104.47.36.80]) by dpdk.org (Postfix) with ESMTP id 023F4D45A for ; Sat, 25 Mar 2017 07:27:44 +0100 (CET) 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; bh=GsyyDWW+GH/dsshNpkNUvrbtweMV4UnCxf4nlVpI0GI=; b=Q5b4l7k4OPnJzFLBx9dnPrWTrbpa+jDhAUgIg6NJxGNOwSVNb5hGFYBIQ7tSbegSEdq2n0k8qkKD+anRjGHI6TNgDqwX5mxjb8uVNzc0NzG2fU6yMAOdCPtt6p+Ka4OnAB7cxEJLmmR51ImcEf0IOBUb3bA9vDCfhslsgq3d13Q= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=caviumnetworks.com; Received: from lio357.in.caveonetworks.com (14.140.2.178) by CY1PR07MB2280.namprd07.prod.outlook.com (10.164.112.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.977.11; Sat, 25 Mar 2017 06:27:41 +0000 From: Shijith Thotton To: Ferruh Yigit Cc: dev@dpdk.org, Jerin Jacob , Derek Chickles , Venkat Koppula , Srisivasubramanian S , Mallesham Jatharakonda Date: Sat, 25 Mar 2017 11:54:27 +0530 Message-Id: <1490423097-6797-17-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1490423097-6797-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> <1490423097-6797-1-git-send-email-shijith.thotton@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: BM1PR01CA0117.INDPRD01.PROD.OUTLOOK.COM (10.174.208.33) To CY1PR07MB2280.namprd07.prod.outlook.com (10.164.112.158) X-MS-Office365-Filtering-Correlation-Id: 56da75c1-d18e-4729-967e-08d473480b98 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2280; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 3:baKguRHJ8ASZbVHAJ6b6rGBHauxuaPDb/5Y0e57HZldbBq5gusp+/vGQINZnvIrhHfGBbNpiLB97f99ch57cgRLP+ZI6k73wym8hUPr1AAH7KN+rVJ3NBxI+5GMUsXLHsV/dJCEF4YS+t10ar3hf/B7rsNmrXSi3Z/1hdB74EBbpIopMvEnErkHaLbafiWn4rsJNY1rUK/VBn+wftg0GCwIuQiOWGqBCgQ36KHLCZ4+ClWUwgisQFKGO0B+Mf74OHWhp/itX2luTeK1mF6zdzw==; 25:OjbxCChH4Wp4IabgvGNkgGcQID0iwMQAWYoA+NgO5aGf+zrUZjxHpuR76jrJHFlrfCkfrIXmOWsPf88MolwoQpp6whyoMB4MGRePRHljfCkioj0+qcxPYNQ1HEHrYFP255oxN+DZN5wl2Riuj5xAN8Ng781ezy/GBzByI9ZOshtEu5SxVX0bn//Sp2EBZdM+6xvvfv4JuS79r6goeiUVIQEaejtxNG5OAf9FQJRpUty/Cq8VaL7QF/UPijtIqNKCzxPbTwFBRFuPRf2z8J5WnCfqw6ZhsA5W6ZjGpp1uNELRwagAGU/q9W02Cg/8o1+BcLBvh+C+0NKXWx2dja+GCC4xAGUuzEpuIpBipy9CH0/IfsTh2HXtAlUiXYMo9cBFijduUD4/W4hx94q9ubhdgN3bFYlFu9kXVmnSOTGx1yMa9u3cFMD+65lDeCZmrmQDrLcOnvXNqo305s61B6N5Zw== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 31:tVyoD/KKYXQDWUgsM2h0oeyF4xpF0Ckaflj+nUCShqAIuZU2EW2kzZeaBewV4WbyZbQOoG1q5PrTrZtV/KzQNqhUKjjaDaYboKX6hjpak+6omaA5DJseJdF+fkyOO42qhMQ4Y0/NzGzjparOcau7MSbHSApqw4ejX1zsMZATpGTSbm1N98O/gWNfDN7WduUCEbiFMZpY+VFgt4d4pMp7N4+HbW+HcUjSOOzo7PPrCmumzFtVZj+3yCJbCC8ECq/l; 20:5cP0ls/wA2bFRri/ZKy6C/Cxyoy0SvMeTURiSsXnS4/nD8bYacCAMb8CvTm+a3RYBtO98Qup7aGOZKYvt/aG/Lh7IRWUhcf/gQgucX8+lpbyX8Ohugb8trCWp2jkNtGUeWqNrHNcZ971Fq2LTFjS0F1dauq1ysbq99kku/pXTGYUyeL6+LbOMMZ0i3tLOoEbRUawh4sjKs6lSo7/Iie+NGevXCIDJcpW20yzhzrgAesca8dw5u7M6Kmwt2aLANr5if1h+TD0va4Ni8LKQ5bVc8BOJ9bj0UpFetL6K1wv2JwM/30OPvl8vaKj1+gxVG4j6Dk+NX50H/wi1wksJjiui8FnbOdZz76HlAL5VTXKi38H3fHOuy9BEs3VqQASGop5Tuzax5VrS0dkUocrkSvRhxbyQRlBdUL2frvOaNEqq8mQnDEQO2ToX8vngjyrocY3/TMJlgN2eRiu6TcF3AITgj+AtZ4ExvW85TRJ5/s11ZnKwRilZxVEq/NAqeUFAXjRnhNeH1FXLygooFSNS1BR7c0HuguW4E5xUb+fEKfg8j+ItXmPAOe1p5pktpiHVyXiun6mXoqsS31yBuiQVNIbXNSewwU5AUdnm5r6X9hlukY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123564025)(20161123560025)(20161123562025)(20161123558025)(20161123555025)(6072148); SRVR:CY1PR07MB2280; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2280; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 4:HEONJrBLH9x3sJvg4TJ04kSJI8E+MfyjGL6kZ4btYMO5QgNyJDDQ1/6EEKLZTUUbxywV3dStaq5ypQyyED0VeajAUbGZi/HvWVKhtOj4zJW4fEIUJ0MuHcvEYjiBd5vbosdx9nh+hAAhhySgr2ETC2cKx2BkgG+cNkVQ2OZWVGGDwQ5A5p+oMYUKBbCPWpXXO2sm+75NQR9qYqo22XNtiQD0eIBcvorrc6rlV5NgYVw1F9jctAFsxwfEdfa0GZ1icoTDNK87IwczYZl2/Mqjg8QRlgfN2y+Augaf7LLe4A66+zBIo3StFTbDGirzle8YhwwZXwzCUE5J1xiYgSOBZnGoEMajif3KNUAJ0g0SMKoNUxOw3C/EFvS5BJPX5ws75IuiXWRRwp20tZSsa51Z2IxM2a+UEXOhpfE2oAy40zya65IZWQAbOOayOT+CxVAefk3BRfGrq9HHOWSO4Az3CbFIS3ZiKhhPlUF+/uCM/f8bBzBwKW+RbGi2ZAGyhRmAV4bl0qJ/YJ8zCz734lNMcrcT4R6y7YHIaOrztRrfszsxMHsvYHdFfiTo0A7DizYVVod6+2OL9f1FIna3SGNOqYJ3WExE8rXODRRphvPftZs= X-Forefront-PRVS: 025796F161 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39450400003)(39410400002)(39830400002)(2906002)(2950100002)(5003940100001)(66066001)(42882006)(6916009)(50466002)(48376002)(47776003)(42186005)(53936002)(6512007)(68736007)(5009440100003)(54906002)(50226002)(38730400002)(6486002)(6666003)(25786009)(305945005)(81166006)(7736002)(6116002)(3846002)(4326008)(8676002)(6506006)(189998001)(36756003)(50986999)(76176999)(33646002)(4720700003)(5660300001)(110136004)(110426004)(358055004); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2280; H:lio357.in.caveonetworks.com; FPR:; SPF:None; MLV:nov; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2280; 23:SdPXA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a?= =?us-ascii?Q?vKO0Jl8zbcui710r7hboWc0KU3rraqIP4wy0WOF4tSqHxKLPpDsNZ6fg2t+h?= =?us-ascii?Q?b+J0uwJ9Q/mD7JAwHDc7UA/NEX3CiRNKHMYIrCUyrbspaSajhsgbgpFZtl5O?= =?us-ascii?Q?kcNhLvCVRurB7wQkcp7Vq1ngDQCCSNMcQucFMGojhj2x5YkIhggIRMc8I/OU?= =?us-ascii?Q?TvrbnN8EjW56XslDILWcRZK/umdYzIehaeST0GM4Qz4szl2cQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 6:Ad+KZbUt2kIAaqcz64lLk/kS1OraHsUyyrtK/o15MennONANjSVM+gTvlnoMB41IxulqP2DLyZIo6hjTFuBqMeRo9/F7L9xIZ75obp98ksVXVskjdcMuwnHNBI7tSGgh9HeL+etAjlPk4ZmTp0lc4xip3rfE1NjPbYceEjLiOafF+K8wtVsSxye1JNbPoBNihhFs6LgFl2YtgSlQHko4O/US7RiqSAQ9Y7axmeIVc6OmEb+uAZCbdRw9jxqGRCczzOnYL+5GczTaaTa7XIlGQ6RPS8X2VW0XLy1X3JwvnzDNe0ndLyDYkgFxOB8aiLfHtwnARBBLX4DyhTt53hIf5/S9oPBPSwqT9Jov9kO7JxD22J2fNddVpTPk462R1VJEZFxDOtbwmtHPzM0DEH9vVw==; 5:jmVT9NFUG2HOruupG5expJshfPZcybV7XtOV4Jj7YPHZPsT08j/p74JR3bE6/pK3wjVPp2A1vTg3ey/gLcfZmE+/x8ZeXeO5C6v+Xw/ktyYDlkEXmBnbYuX6ay9KXPH/MtzGngodQH88e5thmJzDUA==; 24:Y0PRrGcFV5bhixzbYKfgEivw3QMMuEpyUpe5g2yanH3DVkaO0bSfiv9sDid7ahkn11M3NYMpbZxCHfO7D9PUnu2EI0L2mjFy3OrC7E04vus= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 7:TZOxSeyT0yAHmE1O6HhRbtO9/9yQLrAkZBRkGOfX0CHQltbcG6X9Nicz5U8O0l95YJ17Svgbjjt4u5ZdkHBdNb+yOvMSqBppP3ycMU5J0HMHIBUhlkdkkT2KfZ7B79fUdqkfgUwubK/oCWHUwZjslO9lowSxxUjoO6lVSTxXqfpU07jM8xIw9X5YGDGOoAb313AumSvbAdV4f3gZ7K8Hw2HnHGQfHYzZPYQusBmGQ9bhzHIB1Wb5UhbRTJwk+rN7awXjBMLzrmQo5mHqQM7453IHwD9VdQeixo13lYsBvr6wTEjkYe8PKHVTxWhjNeK4fvdpDmWPGz8OZntvzOTARw== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2017 06:27:41.1712 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2280 Subject: [dpdk-dev] [PATCH v3 16/46] net/liquidio: add APIs to allocate and free soft command 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: Sat, 25 Mar 2017 06:27:45 -0000 Get buffers from SC buffer pool and create soft command. Buffers are freed to the pool once the command reaches device. Signed-off-by: Shijith Thotton Signed-off-by: Jerin Jacob Signed-off-by: Derek Chickles Signed-off-by: Venkat Koppula Signed-off-by: Srisivasubramanian S Signed-off-by: Mallesham Jatharakonda --- drivers/net/liquidio/lio_rxtx.c | 66 +++++++++++++++++++++++++++++++++++++++ drivers/net/liquidio/lio_rxtx.h | 38 ++++++++++++++++++++++ drivers/net/liquidio/lio_struct.h | 6 ++++ 3 files changed, 110 insertions(+) diff --git a/drivers/net/liquidio/lio_rxtx.c b/drivers/net/liquidio/lio_rxtx.c index 1c6ce59..cfec96d 100644 --- a/drivers/net/liquidio/lio_rxtx.c +++ b/drivers/net/liquidio/lio_rxtx.c @@ -227,3 +227,69 @@ { rte_mempool_free(lio_dev->sc_buf_pool); } + +struct lio_soft_command * +lio_alloc_soft_command(struct lio_device *lio_dev, uint32_t datasize, + uint32_t rdatasize, uint32_t ctxsize) +{ + uint32_t offset = sizeof(struct lio_soft_command); + struct lio_soft_command *sc; + struct rte_mbuf *m; + uint64_t dma_addr; + + RTE_ASSERT((offset + datasize + rdatasize + ctxsize) <= + LIO_SOFT_COMMAND_BUFFER_SIZE); + + m = rte_pktmbuf_alloc(lio_dev->sc_buf_pool); + if (m == NULL) { + lio_dev_err(lio_dev, "Cannot allocate mbuf for sc\n"); + return NULL; + } + + /* set rte_mbuf data size and there is only 1 segment */ + m->pkt_len = LIO_SOFT_COMMAND_BUFFER_SIZE; + m->data_len = LIO_SOFT_COMMAND_BUFFER_SIZE; + + /* use rte_mbuf buffer for soft command */ + sc = rte_pktmbuf_mtod(m, struct lio_soft_command *); + memset(sc, 0, LIO_SOFT_COMMAND_BUFFER_SIZE); + sc->size = LIO_SOFT_COMMAND_BUFFER_SIZE; + sc->dma_addr = rte_mbuf_data_dma_addr(m); + sc->mbuf = m; + + dma_addr = sc->dma_addr; + + if (ctxsize) { + sc->ctxptr = (uint8_t *)sc + offset; + sc->ctxsize = ctxsize; + } + + /* Start data at 128 byte boundary */ + offset = (offset + ctxsize + 127) & 0xffffff80; + + if (datasize) { + sc->virtdptr = (uint8_t *)sc + offset; + sc->dmadptr = dma_addr + offset; + sc->datasize = datasize; + } + + /* Start rdata at 128 byte boundary */ + offset = (offset + datasize + 127) & 0xffffff80; + + if (rdatasize) { + RTE_ASSERT(rdatasize >= 16); + sc->virtrptr = (uint8_t *)sc + offset; + sc->dmarptr = dma_addr + offset; + sc->rdatasize = rdatasize; + sc->status_word = (uint64_t *)((uint8_t *)(sc->virtrptr) + + rdatasize - 8); + } + + return sc; +} + +void +lio_free_soft_command(struct lio_soft_command *sc) +{ + rte_pktmbuf_free(sc->mbuf); +} diff --git a/drivers/net/liquidio/lio_rxtx.h b/drivers/net/liquidio/lio_rxtx.h index b308211..284cb18 100644 --- a/drivers/net/liquidio/lio_rxtx.h +++ b/drivers/net/liquidio/lio_rxtx.h @@ -53,9 +53,47 @@ struct lio_request_list { /** Maximum number of buffers to allocate into soft command buffer pool */ #define LIO_MAX_SOFT_COMMAND_BUFFERS 255 +struct lio_soft_command { + /** Soft command buffer info. */ + struct lio_stailq_node node; + uint64_t dma_addr; + uint32_t size; + +#define LIO_COMPLETION_WORD_INIT 0xffffffffffffffffULL + uint64_t *status_word; + + /** Data buffer info */ + void *virtdptr; + uint64_t dmadptr; + uint32_t datasize; + + /** Return buffer info */ + void *virtrptr; + uint64_t dmarptr; + uint32_t rdatasize; + + /** Context buffer info */ + void *ctxptr; + uint32_t ctxsize; + + /** Time out and callback */ + size_t wait_time; + size_t timeout; + uint32_t iq_no; + void (*callback)(uint32_t, void *); + void *callback_arg; + struct rte_mbuf *mbuf; +}; + int lio_setup_sc_buffer_pool(struct lio_device *lio_dev); void lio_free_sc_buffer_pool(struct lio_device *lio_dev); +struct lio_soft_command * +lio_alloc_soft_command(struct lio_device *lio_dev, + uint32_t datasize, uint32_t rdatasize, + uint32_t ctxsize); +void lio_free_soft_command(struct lio_soft_command *sc); + /** Setup instruction queue zero for the device * @param lio_dev which lio device to setup * diff --git a/drivers/net/liquidio/lio_struct.h b/drivers/net/liquidio/lio_struct.h index 992ad39..45f9ac9 100644 --- a/drivers/net/liquidio/lio_struct.h +++ b/drivers/net/liquidio/lio_struct.h @@ -43,6 +43,12 @@ #include "lio_hw_defs.h" +struct lio_stailq_node { + STAILQ_ENTRY(lio_stailq_node) entries; +}; + +STAILQ_HEAD(lio_stailq_head, lio_stailq_node); + struct lio_version { uint16_t major; uint16_t minor; -- 1.8.3.1