From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0084.outbound.protection.outlook.com [104.47.42.84]) by dpdk.org (Postfix) with ESMTP id 9187BF978 for ; Thu, 2 Mar 2017 12:38:47 +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=c8AXbeD0Vv9swR20MMkEHwv9lg7FqBJ3ZEugmOOQ4C39lvuVPDKPB69AZUPdVhfuQ1zp0g6Qc6TczS45memGeehV1id/ntAPNCSu5LhXuNs7im5KF93sZab4ZUgi9IsNHW0vqYNrPhDV68T+YcbuHbRzmkR78ux1jIJnkSB+jHE= 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 CY1PR07MB2277.namprd07.prod.outlook.com (10.164.112.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Thu, 2 Mar 2017 11:38:42 +0000 From: Shijith Thotton To: ferruh.yigit@intel.com Cc: dev@dpdk.org, Jerin Jacob , Derek Chickles , Venkat Koppula , Srisivasubramanian S , Mallesham Jatharakonda Date: Thu, 2 Mar 2017 17:02:21 +0530 Message-Id: <1488454371-3342-17-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1487669225-30091-1-git-send-email-shijith.thotton@caviumnetworks.com> <1488454371-3342-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: BM1PR01CA0021.INDPRD01.PROD.OUTLOOK.COM (10.163.198.156) To CY1PR07MB2277.namprd07.prod.outlook.com (10.164.112.155) X-MS-Office365-Filtering-Correlation-Id: ed456678-0a16-409b-cf49-08d46160af5a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2277; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 3:prbIdaHTg7Q/cE8d5sCzGM3LbEAI0Ki/4Pvbza1+yfnrcdJq9sMhHykIRYlo/AKtLTTL8g6FCnIobtWaOF56mxP8YpRkip5f5pTuRp0sl54w14pWArBWWoBWkmhIs+C8UZQ6HWq6uRK5BUjujrOV95qZDze+T9eRN1PLKlxQSwO4P3NAs3FFG9DxhjKLpUNhpkC5CBnK5nnUno3f3v4q1FnWZw3Omb/U6Z0Zt0bdM7qjb6d4SNUsp2MW8QuC6+9gQFHFMQnO1ARL7ZWgJGC7DA==; 25:yARWpGQZX5BQapa3jol6W/xWpbw12MQWkCqBAWQ0FB09IZoXUpMO1ipYkmwQe3klcAaAjmTm5gw/MOnprI6KZeZXaXkmcr3ci1eAL5qIn5wlOgWI/BPtoteqfs00pPugM11uGucXNBmxn+l1IFKjSLGyao524fmavK2ZhPAwgYszXuDWKsgizUgKSBkpur716NbKeA2/e8AmXxmoBw/0ahJ5d6MVzhSZn8UERqMbGKvWgn7ecm7XvO5tgspfLMqZWT9zrOspjYoIwSbPX8/XfZ9DihHZudfdxix306scdyb5/lHNASPXsihEgtqH2bdEHrZcseW40dYCyeDB2j5fFpActQ5nWykcIIyU3mfHJnhjC8fOYvrqOzidU3B3tWMj9xueEa5PJfdXKV6ZN/eyZWLbLs4qn2RGc2oak86+VNyJoHe3Q7JDndGVW8eBSC/ijGlFOnORLjsOlb0XPbHO/g== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 31:WUNCQwrhRM00X4rerNcV0gU1CEmYEoSxn7TC75HfHcuKynKLRaWKOdeEy9yG+B2rRpO1iG6GhtSESC+NOIFZnRDOJS60Vv0h8KvozPXlHl0k1FDc7jm3Dw7VXwKbl/VxMV35pjo0YnpTNZVC0h9IlC2GYQXm+qo6TH3C+K3pIStih+MBb7ppLLT+s8lkwikp03OKlyAxwJxwA0IuCe8k8j0dd49RPFW4q+Ed2Al4HPM=; 20:2Yjtl6tob/HJMW/npnLYmdf3MWZ6CtRTln9SPdEwrBEbWHLTMwIpq2DM4DRT0BIdqaJhSQP9n+R1QYUv87Ad9gk01rWdvugSOiO7GAVQqUeosJUObN1lINA7poDSrcxZDsXPp8nwt69YwJxWSirpxjoG6OJltHxQtgA22biulP8lS/ZM+3x+FsJyaXhSQYAddvYpgCmS4Det3oLuk7t76FB0fPF7vj3xX7VW/OOLIKOFj5Ji/UJ/MNGXOPbHRO9/qgjCo7rgFPyKld7Iy3RF5Qkw1TAMWC4FGvy0/Ut14c/AmYH12CJEcNCFI/8qO1TYnw/o4KLqvVKssKh5FG4XY/pYECwsVOMCt2R1db/mvsRxGLLaJYkIvcGjLnbEnNOT5Hrs+5fzD/k+4wRSufD7R9nz93+4IJGdaAAVAY+yLtJull9y8oDAbpJsT+HYhJrK38hhXs1NtOj6sz9gYXPaG3Ti4cr1zALPLwp5U0NjbCPG6ohyuGKDRIuFqntwI8kwHFdWK4JmfJy0bKfMXHeGFltKLXyEGypfu8LuGOI35ASQVLiFzRISHsR2emMmw4+3JTHKkUe5juODJgZ7EVYail74lc/qxfjr30RXeOq9t7Y= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041248)(20161123558025)(20161123555025)(20161123560025)(20161123564025)(20161123562025)(6072148); SRVR:CY1PR07MB2277; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2277; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 4:yCtyt217A98ZFj+wYVTYb5HLjU3Lg0eKH12bgazPxNMbjZlVWUp5cawAhchXJFtTXJ1pyVzzcUHydnklxA3CbEDXdD5RIwMtgGCBkRn5FqefOSE4yJWj7ehMdJ2casPd+9bkFTPeOStu0D000xeI3+/2hIXmbSNCNmmdfzcctkiJ9T9ugSZEtBeSbJ8wQ6z2iBTMsivoJvsvqBu/aT4w1oA7nQ00R+1FUpYlvpkqLXpPVZALQ2gg/3VTxyMb+vI73BEd0ZmRELrCbS5jGbr8wm2oyDzADTlQArYXrYzC+ty4WSwn5/qm+PmF926AtBf2gINfjqvZuRRSZ6m7m7q0fL2MCVugv+9xkGR9qcz9e1iBZ8PA+JTKvAirbZXLXCz62wvEJmcQXycKclFwNREyxDEFXqNLGF5Agjx3fnsX1rZhZ1t5N+36zxISrPI/L4C5jh72tPWVefE02efboLpSQHhedZwF9rc/u/YgWwfcsSOXsP4eicpAxxopBcAi+gT7zDh5cyRcEvABRiNi7R65wnF7uO8Q0h9YyruN79pdGQZraLSQJWbSX1GZE4zZO1wKbzl7jgZCD18vuO8RcYqfMwyov4XtAjRUfI27MvqbY6U= X-Forefront-PRVS: 023495660C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(2950100002)(6916009)(42882006)(5660300001)(92566002)(4720700003)(33646002)(48376002)(50226002)(6666003)(2906002)(5003940100001)(36756003)(8676002)(50466002)(81166006)(110136004)(38730400002)(4326008)(305945005)(2361001)(53936002)(2351001)(25786008)(6512007)(189998001)(54906002)(47776003)(6506006)(6486002)(66066001)(6116002)(3846002)(50986999)(76176999)(5009440100003)(42186005)(7736002)(7099028)(110426004)(358055004); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2277; H:lio357.in.caveonetworks.com; FPR:; SPF:None; MLV:nov; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2277; 23:dKQFZ7uS9IrezvV+2CV2gT+2B8Zes5fWcls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nxTGskuED/P76LlQCjjGVFV1KPJTref0rjZkm?= =?us-ascii?Q?z4T38DYJQY6rAAYKJf9TiYF/ptAf5ADk5onlJNHYubirVUCTX4COfvbOyrXp?= =?us-ascii?Q?xw6PVemrFTRaXBZIlfZ+afbIGRULqej2Vo2NmvnOV2qDBsNCLPfPXPtRIvy/?= =?us-ascii?Q?jzzAzqPTAjz4wTX0UpNa74v5ANkWfnMVixKDMTSgbcLefZBXxzXQAR6gTfUW?= =?us-ascii?Q?Sb6EmocppM=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 6:LMt2+EKeOOCvQ/+nqWqtlmgdDMJcOUc8bHibeExXfD7XCeP7fc4y0Nlce6VhoY0+mftyMiCdqlNXTwNpSi8fFxvqJAazablYrjyyKp/WX7y8FbEsd23+F1wbrRFwaSlIDk/Nalxfst9bHXU59TrK9kzPYchlWNhNbL6UOibMfTBe04R3vfDQQLRB1tenjiVpudyzYM6dN3inoVMR8SK/wHLGikrkvJtUlodXtT2RwdXGiXRdwTM2UH/V2XKRfTULaJIl9we9e7WSINpDTTD+ZswcWIvqRS/op1DlQioGQ2E9PhxKFf2RuWSyQuyhWgWjQZdZZ9UbJTpzfcsBNbIUhl59vF5Rr5uqRu9Qy92LbOGsgfuEFuZ6tNQkdKl+ykzvSuMxErQejTUeBOZtSjSUoA==; 5:ZOtOZS/xAYT35QjiCAmw3jGi0dxGjWNQZ8yXlnlLPXoU6/IzmI4QFP732LFt4ab05KzMBywURfNTSHkMxo6gsxsMqclHoRFpMhEjS7C82OH2UMvMlf++P9zADxH5BURvcGMpL2XKx95f1bhaKi6YCA==; 24:OHaEWYaeH/O7E8px0XZdN079ydQ4psCVMS8WmiwWEh3G1e3hsMPPtDyS9pkFIMLWOFa1HFmYJ/kUSX8YV6XtepZ9+I3cJ7ggk4wPnR6bzPY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 7:G+eL5Ohj3zW0vqIENqkKvyNIDwbGXolq/y5KvQ8AYdjj+3L4TQWAxFGdB3p5j0mFxLv+TcsA6+uouq11Nde0E7n6WJ5nLUNPJAzzfhLFKi0M6ah/w+pj9DOQ9TscVz8jN7ii4lyRkfBwegALOnWw2ppjjnaKSBqEoA9BTGrr4tZPmz5soCntBmxD3LUv+oZF9IY2IrAaldztNiigtvWr2B16AGS0Pv0fg9Eshb3pRM5f+KNn+59kPNLFa5H0bg95WYaoQnXolM0PmmwMAAthgCLOkEZDW7psKdApSgro0fWhIQev7YWIg9GwFWTjMYjZpSUyBIzi0K0mNCN8A7erzw== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2017 11:38:42.2019 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2277 Subject: [dpdk-dev] [PATCH v2 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: Thu, 02 Mar 2017 11:38:48 -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