From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0081.outbound.protection.outlook.com [104.47.32.81]) by dpdk.org (Postfix) with ESMTP id 95ADEFA35 for ; Tue, 21 Feb 2017 10:29:06 +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=RefxoBnDagUzEJRoZdChTp1bugJmaQLkKZq1MJDJGXU=; b=OsD9GPY/APkQW0Bw+ZaSn1Wo9eLEU4/J8w8kUbG8bRt10BhUxZJlGsbgIUm0fxLY11sIK93+hkkViqIefdEYQ5iEkSz0RE7YzhaMB/muKNmEmU02fGtmz/LueOsrEUmiOxYbv9oL25Q3ue/boK07Yhaklfgu1wBuwDWhd54mzEw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Shijith.Thotton@cavium.com; Received: from lio357.in.caveonetworks.com (14.140.2.178) by SN1PR07MB2285.namprd07.prod.outlook.com (10.164.47.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.13; Tue, 21 Feb 2017 09:29:03 +0000 From: Shijith Thotton To: dev@dpdk.org Cc: Jerin Jacob , Derek Chickles , Venkat Koppula , Mallesham Jatharakonda Date: Tue, 21 Feb 2017 14:56:34 +0530 Message-Id: <1487669225-30091-20-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487669225-30091-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1487669225-30091-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: MA1PR01CA0089.INDPRD01.PROD.OUTLOOK.COM (10.174.56.29) To SN1PR07MB2285.namprd07.prod.outlook.com (10.164.47.155) X-MS-Office365-Filtering-Correlation-Id: 65436626-838d-49a2-d952-08d45a3c145f X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:SN1PR07MB2285; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 3:R80KcLoTyqCIB7RUiBHNgb4aEgCAJq0rdaMf9FA4kWIhcOzFFJmFJMHYNAr4YsZjrt27JeUv2H0bgddXKiLoJ+SiRQ4Xkv+RdDmXtV2a141NLnXLtWbTqVxR6UjEzrTzFimhsuqacYYKva7cc1hCM4ogiv0SHyaRJCuAw3aerTbMo5DnY/ZW9LliXbB2g7e1Zb16ZoqxIpwzwV4pBxTMZxEMMhrpT0FWQklHL+lvYD2GUx+lUCjjiDsr8MUN6o/ydcr+YsORS5Ftp9uPVEJ9Og==; 25:CSNCiZ7Jx1PRJcMGJzqCqVsJi436WtwdOv0UTUqZAkHf9oz1Xu0hKHZQg2HoocRwzh49BXXhw0INs1Lc35oIjSZU73kfE/v9oNfX9+G9C94Q3SXUeUUAzeK1PQOAI53u2uiqkcvqu7vJOMo9o7i0m1nQ7dbDzA2cpcJ4NiIPYWjzp2QD2qt45/keeGwcKBCyLZ98IwL3nuCKkdMDcf76nLX6X5v5zvtYEknk2oMlQ/s4drEMyEAGtVvXoNcud8p/Ii3fZt2L4OAqZMDoq+dmWcTS2ZVo1Q5omLhYu0oMlqkyH8CPx2pEITl5MkmdojaUayQc8OXI0bZuBjCyuGLA6Z0UwFtzn+QY6lSJRq3flMJoeDUnswJ21+N+lvx5VyukOxFNAEPe1rxJawfFLUXzw3ZrtkA5l6aajMU7rbyfJKa4gXRj485KcqjOJJsElRQZhf+H9lApQ/CGKrSo/sRRMg== X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 31:BmPYUZ9qzgG9Z4vOVjoV7/flpcwlXn7TksmiiL6v5Zh+VHGplsThysphAA4zwml3GsdO6QUQ/77N1gke4J5EOqKnEE6AYOp23dV7OVZLM4PBJ10UCnvMsZMaeNuDoOPF42nKiI1EdHIxu5wd7LIWGjUtka0/NspFjvN3JZZ5S5btk2j1eVJ6c2Dm3AAjhYprhle8q9DkSFjRKBoFk2fLyiNaPG4ibxMJhtkTL8dfrzo=; 20:wvZSaVXw6fpFhzsGXOxAh9CxA6GWGqYab0IXEbtePUZvnEeg+xb0HDAyaJJkS6vp9uMvFu4bedmfsSz5B4volmJ+qjHrjkzX2dci51xdhTuwgUH3wsn15WbtXcFPvqQoAYtwPdp7qX5DvTpcNhNP2emTzaRBghCakcneGqxmT61qlXIkTiWDZOXYVwhC4LeyU6reU0wJdj0M/oZ/BaM/FR8NPm+tV5cJNqmPsFpoeksca8GBCUCBrGXdaHzH4NKC7w+d4QVa/KavxZW6NyYV4CVPAc6DoqDbIscjq65788z6ZIS+J2KcKeU8/SGhldiSg5IM4fhAugkrUec3AsM9WHTx6QNFeMZYQMZouzgtGztnXZ0ryJcqEqecUJFZyYh55dgk7NIcDUTsi1rEcCiL7iRpbuNyisCYRcx/cCWdL7yafNEHlwOMy34DC20qs5usKff9KEae+O8Qbe/4HIJas1z/Owoo2vyTplSG6adXoIIlYRWub3GrILDiDAaMchA/6SNm+J7CXfpcdalYhU4ALLsYkqdgcbdqfo5H75wu1QUl0aBlwGvPm2nsoDQqOWxfMzdfwCYfj2EU2ImCQVXPLGPivDW0VWWw9wWvVNaibN4= 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)(3002001)(10201501046)(6041248)(20161123555025)(20161123564025)(20161123562025)(20161123560025)(20161123558025)(6072148); SRVR:SN1PR07MB2285; BCL:0; PCL:0; RULEID:; SRVR:SN1PR07MB2285; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 4:Df7EaYO8OkKXsKG5G5Um5ATu6Z+k7mqC+IrFW37/puTLmnlWDDzxND8U78VJX9NGRyphKH1uQj+EgDhyAaYZEksii560aDE0v0YA6y1Pb+Z5eo5luHubilgbvUS6vNUiTE6HEkfII5e7OVEbBQA943vyQOZ4WQz+7gXX/n70P8xV5UGG4V3EuKgMf4p8qC4HXvrrHH2lwBxqGij0FKRjS73Vr3wliv6myZdMyYpaowObzqgCzJdXLqGTXzMlWIAo3FO5+kLvrx4gaz95HESm/dgTLlr418BbWpXiFrZQtAyJBFTl6v8SWQ/h7K+9ytihJVI94i5A2EhBoxvcP9oq8oe3DhZCZ3iie9qPiVxS0BsiD4fPK7Z0MH+Ok6E6PSbCNEViLjUVPkh8oNgNxoYaRjDV3btBMXAIRFJYitlgDgLmRWjA+LSF/9I57KCyMqf9BPF8GN804anmmxOk0+841iaTX7aEC0zucIpOmHnM9clHQ6Q9R7V+2YF0f2aUXrjxOEIE9+vPTZnzeTnYfxGrJv5l6CqgGTr/z7FEqGaz/49iSKmabzRkgMtHemmx7xIW8SET4LrkaERe+XTdER/Sn5rT6x2X/w8NF1wAeD38d0s= X-Forefront-PRVS: 0225B0D5BC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(39410400002)(39830400002)(189002)(199003)(50226002)(81166006)(42186005)(2361001)(101416001)(81156014)(305945005)(3846002)(6116002)(5009440100003)(8676002)(105586002)(7736002)(53936002)(36756003)(110136004)(106356001)(6506006)(25786008)(38730400002)(2351001)(92566002)(48376002)(6486002)(97736004)(50466002)(5003940100001)(189998001)(68736007)(2906002)(4326007)(33646002)(76176999)(54906002)(5660300001)(6666003)(6916009)(50986999)(2950100002)(6512007)(4720700003)(42882006)(66066001)(47776003)(7099028)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR07MB2285; H:lio357.in.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR07MB2285; 23:MK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us-ascii?Q?/AKTeAPB8a/Kh03TEHeHbS3VVCFV/NgdIlXUvfPl/4CoybrgFvfJ+SEsWMIq?= =?us-ascii?Q?bAsDXOT2zoRoS81tqSdYDMAs3bUe2p6G0FSajQRaavXdsIVbryCS/yByJy85?= =?us-ascii?Q?0/2Q2G1JyXeV4lze3ohPZeIJzafIxnihJvMN8rT6E25TNajYP5dNbCwHwbBM?= =?us-ascii?Q?2/1siEumYbGtSFk+WfS6bDmnOH692uW54qwYK1FX9dih9Kv76jqr4H/WVH/C?= =?us-ascii?Q?fAswK00OVVadlKJ7nKMJTuqFT3D9VIbQu76k0fTgLeiXQcF+1e6SrkV/V8mZ?= =?us-ascii?Q?3tVJcnpSOJHnJAtWen52zq6xjFca5p6JPaI5bAr+f8jnUG1FDa726URCcljc?= =?us-ascii?Q?CzZr7hPN8T0hd+zr2Ya5zOnunofMjHAxHYgPglVju/AcumirEVNgITlMo6N0?= =?us-ascii?Q?EZPBUCvfnKKyXoELOpQyjA=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 6:Ah83sSfK0JwfexrydiANXdb60DQCFFGhaHU+l0oKaO8cxaJYCHOefClhx5FDTjh4GggiC2sa5kUjgkfu7OKF31EDkmNFW5F1fxYT59YNgpy6kpIDt+T4DLZdEY83zkMSLTu9HCH4Z1Bng6GnA2dY6loWh/NjC9bsqaw4NWa6pC1ApYDUcL0qp/vvw6hobkW1YZ+qIbvn8hiwZ/0R6fUH2EiTVM3beP506sWldTG9LC5wtoZBhBsZSafqGk/1OxL2hwUAotU1v30qMcYaYTdVCKXcuJ38VY3BO8UcsFITNPWHJlO2HICQE38W3fxGdjhOmOOr6+bIIDl2YE9VjQOkpNhnCvdJ62pgQOJ6vngfTA6v28IlVkN0EtRQCioiuhzbLj3yQI4Q46MC6zbPDDzi9A==; 5:SCjtkzY6TGrZlYviucYmXEji6Yz62KaJRM605m0L5hDo4VvndWSwKvpdt7QddpNqzsnFhhRHuxwkciMv0hHHOWfuEjH7WV4zGhhfkvIsXw3YhiMVz5qtMq17ZE7NzcMlcaLRV/7w9rbib9y86VHQeg==; 24:6ECu+S4uxXEOCA8R93k93YD5v08UOrQwA/eY0sBYNjrxPDquGk0lxBFZZoOKesPmmyswODDbJQHXBMyMeLVD3cbNyRGUgnW+erUX0ikZr1Y= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 7:c2Ce1CsPo4S8103BbQjPR86zBYKVHvtMQXkcaF45hIt6FMFR4xqKZg3A0w0ZVFv4sTAz1Zmd1P8EmxfJVs0DIDBvURZKiKorGoTv3iPAtrtL/jzMeLTIs2fmijB9KsrzusBsHbBOmfIRqorQDIM8hsViJsr7wjR8HSni2DwRSrQWdsHAfCCLq7qP2tQPMqKG03LfdJFw3oSEog8u1q8RDXjIwRtGaBvzGMzSS5MtDqvv5622WmPIxoOpxzY0uVoGhr8DkM5aXvxmXgyRkzxwpDyavbsxU/U4B42ykmZyJJdECe9/n6SJboZ4Un6sXQi9pnDIDv3c/SKptoaoe0FutQ== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Feb 2017 09:29:03.0101 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2285 Subject: [dpdk-dev] [PATCH 19/50] net/liquidio: add API 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: Tue, 21 Feb 2017 09:29:07 -0000 Add API to create command using buffers from soft command buffer pool. 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: 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..8dab73e 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_clist_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..a06726b 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_clist_node { + CIRCLEQ_ENTRY(lio_clist_node) entries; +}; + +CIRCLEQ_HEAD(lio_clist_head, lio_clist_node); + struct lio_version { uint16_t major; uint16_t minor; -- 1.8.3.1