From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0062.outbound.protection.outlook.com [157.56.111.62]) by dpdk.org (Postfix) with ESMTP id CF8C6D0B5 for ; Fri, 17 Jun 2016 15:32:22 +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; bh=6sDcA5aoLwBbXNKVLlvmt71GYmBZrX3QWRFjux7vVD4=; b=EUP/GvYNKdR/2Bmvjy5f6/s2CG25kVaWLUWdmZ1jJymHHfPPcp0QQ+jG29+9/KgGazbTpWTGMgsG2yf/JPRBDGNdqDuZ0NqkZxslrezq+58XjiG9d1Yoen0ptO4mGH7JETerlGmYwGHk4OeBth4OaEdYaO2Mo8nimcVIrCXLbaE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@cavium.com; Received: from localhost.localdomain.localdomain (171.48.17.70) by BN3PR0701MB1718.namprd07.prod.outlook.com (10.163.39.17) with Microsoft SMTP Server (TLS) id 15.1.517.8; Fri, 17 Jun 2016 13:32:16 +0000 From: Jerin Jacob To: CC: , , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Fri, 17 Jun 2016 18:59:46 +0530 Message-ID: <1466170194-28393-20-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1466170194-28393-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1465931200-23912-1-git-send-email-jerin.jacob@caviumnetworks.com> <1466170194-28393-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [171.48.17.70] X-ClientProxiedBy: BM1PR01CA0028.INDPRD01.PROD.OUTLOOK.COM (10.163.198.163) To BN3PR0701MB1718.namprd07.prod.outlook.com (10.163.39.17) X-MS-Office365-Filtering-Correlation-Id: 94a9444e-dc07-4d6e-24cd-08d396b3cf07 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 2:r4yci4gQJ2na1whWU2/Bvs78Tu+mq9aWnj7yFuJ/m7koj18pb2c2odTfuUDwQroD3lWL0K0gabbLKc7uOSoOaKlwIHC0MeoshF6/iW24USwIp4Q0njdrwdnZ4GxZqoLji0Bfty2F4F1KaCcXUfLQIdLU9XzdENTdqIfgPcprVNYf/RLWURvJoh0CkUVefO0w; 3:Rg7PlqQfl7vhZ7yuya2mWx9JdtyLGdPQEoWRkIf5o7TioVL4YjeZPhxfxKWi4zQ5+NMpR85X8KA9xabmYva37/PuFZVJi9vMVyfdy2tq+wP7NnYHRQWXkiVJpdjN/t6o X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 25:VD0Hz9VtuMYPkPhHEqwBHMDMpd42hD53Grn0YcOewDy5t1rI4ZFDFnqJFCoApTdCbLyY4uum59TgwGv0BoNvtTMs/dPRd+AeRNdAdaAYvvqiL6nr/qFCgQ4J2pS2RPqirwxEwrHhYtNxwFcZ4i2VG8KqXglOKmRvWsYJxL4ku8lnI8Qjkk86OSgH8efa0RoIgjbvar2VaNk0b6w5VM6DpQeXJbk5bkAdV4VnoDeyMB6GLI5Cg6MtOVhkF7rDtxk2dYjHpSwvo7GwcFJj9mVoSNIxKtgoVjo1FgBO6U8tK07t09EGmUHJe7Np3xfP451QqshRwu0qoJ3SQqH7XaZgkQYhTtrIR2JTMhCXbUO53/qI3/2pOgjmWK5ngkaIp3Y7ywqU1niNj44MqR5adlh8332hGz3PEyP/Jol4NEMKagk4PVGLAkPfyVi6q0JzUD4neOFSnLn4CHjTUJbKoNxaDbGZ8MQhyt+6tRFsxvrga2P+d0ph2iZOXBQ5Ze6QoPbKSknINPkjb7Voe3hhm2Fc52R7QIlNSU53Ut0xJfSvtQmncovjgj2+kJNdeZDumf3HGZ0O0Zn4gEM7wd8uZgb/G9PS7uWK/Lk/fL7Jg5kX0770DWDny7WU1DmuDNB9UqgxU4U+etIcLjwsuzA4mQfnsndAuVzgjJkk/oQiriRrIVDtTUuckWj90RyVtkLD2aUaZ5BQgby98ZNXQ2AILHFVP9SGvB4+EW0fD9U1BNAavLYKiNj3QKJbNctmdmsd3ux8 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 20:DhW/ZB7UlVSj4X32puve3x2hr42CLCYhXxSwG/yGk4xFutX6G0wAd6lRrT3zVkC52NtlKkuLvBZlaKzQe5ysSy/Mq4qWVpbjsMTq3iafBzPgRbZoHNaCv3lF+jRyjWTB3ULlgwuCQDyUVPD4sXQrFpwC98XTf1HxK6y99kSKHGvOqD5DAYW23XChU4ENAoI8toJZThCyPYK0K5TN+AbyQyJcRkwF/hePkMwRmdx29Hw/svfj3JbGWs5IlB2HfLxsWfnzJZPWozVjZsKwIOWo15aRcuC2biPUzHKlD1mKrtNK4zYpo/ZI+w5RdjW7hYln6UpD/apYj1oiup7oN4vrUEX3v+hG9LZqFOTMmu0DM+XwcQ865BP+xzeQKMH9gPckBBLenchualZJa5+G5xWqbXOf3PZ0coOLC8dUVxzpJV9YjRHvlb5SJIXSNm+dOABKioYVeys7M/HKc/e6O/QYI1LKh6W7aeoPsqisE6TyWdEGasVarBFP+qGxbzq6Ctsktiln2Fp49kMYwkpb7pyJKV8A/x6Uvva5r9tbI/qrHfQlSzHvuRz8jbzYVxiYzOu2jmiWeFTHIUyUAhPN/4fuVL/z4sPtKH1v9L8DwsB/8EA= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BN3PR0701MB1718; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 4:XOeE36ZCKgWHE4PPuVJHOU29xRZM3p1qcOHXqsjeCtwrcGHYfBMCNwOrX66RNYUE5f1ZO8ONw0u7dMx2ZuEGfw7yUgomLBEN4VK7SmhbXhpdW4JGaW+B5wNTJeICStYID60SHYxDFsxwgGwF8g4L0mZRvGFlHoQQ0N8h5yWKUUxwBLVQEZfcPsMl5+rZmDA1sEM6rubTnYyh2UCk7Aob0fV8dx226vzHnmjEAjia8TakbW8pXyp7pgBHZKAVvLZK5/wSy2hVCj8CTowVtGkSO/ObHGrnLL4a2dLPQO+74/M2RdettW9jvCVUeyePh9JGKjLPP0zbKN2Ana+bxmktV2W5ISHbULG8NxeZxCUP/1IGl2vouk12dQBRo0qNVDrA X-Forefront-PRVS: 09760A0505 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(199003)(189002)(48376002)(19580395003)(68736007)(2351001)(47776003)(229853001)(97736004)(19580405001)(586003)(50986999)(110136002)(36756003)(3846002)(66066001)(92566002)(105586002)(189998001)(76176999)(33646002)(42186005)(81156014)(575784001)(5004730100002)(101416001)(50466002)(2950100001)(5003940100001)(4326007)(5008740100001)(50226002)(2906002)(6116002)(77096005)(81166006)(8676002)(106356001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1718; H:localhost.localdomain.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; CAT:NONE; LANG:en; CAT:NONE; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR0701MB1718; 23:pDdT8ZOm+heZ5oW1IoeiEKmZ1O89mIEB966dt1S?= =?us-ascii?Q?gI4ZCF2RASgRyT40Y7Yh/A1e9XBNztD2YLqVD2abp5r1Ca//zBPZO+MbPZLi?= =?us-ascii?Q?z2rOvj/AZgwBIweJ97WcbX6q1D7cgyvjzzp+9MWus44IhF2hl37lnrYrN6NP?= =?us-ascii?Q?BsynGL5P+uXNFAfKP4/2Q6OveAMYVjpQaDr6F5iSWYgbQhBcCdN4UXP4TAPX?= =?us-ascii?Q?JET8Y6uJBrjue1IrNQ9nNvPUgQ/2ND00H7NUx3+t+iSSz5vL5Mb/7C4QHnU9?= =?us-ascii?Q?79hbJGed4FCbiOEEmQj5s4hGtDXtWAnFj6sWwmJTtGUSeJ8rZO6F7IMvgEF5?= =?us-ascii?Q?hLFL6oiolnNxqBu8oB332z0+6MWfzsNKIQe5djvbNuyubIDDZU1eK3erE7fc?= =?us-ascii?Q?yvu085ux5w19bZ7QJ1G4ebi/Tc5rkIJl22XYcnLPuZcnJDra5PYK2yACYVWX?= =?us-ascii?Q?AhfOIFHs5R/BOW632jRqEoXHYKt4OeFqG/Y9AcsTB+rYIBnFLbxbSGldAXGq?= =?us-ascii?Q?gKOYMF1tEojZUTwO2TKuFqqTE+wpoW6WtQIVyBWoLyyf0n9mYD7WW2rPnEbL?= =?us-ascii?Q?+35aDHblH0TMInpKjqajHUOiUS/MnNBAcZEKsISmDK50nHdStgxe+SXwCjkr?= =?us-ascii?Q?OvhLqkqJ0WDazGYkI1cwz8NNpUjajDpgRc3e76qhFfQHJs7Zak7iN282dU2T?= =?us-ascii?Q?yha1X/+CS8V7a6Qz1W9QE/w4tuh+KdoW4YQVu2X1zEf0ehpkVcVgt7tGnjLK?= =?us-ascii?Q?9F+IXOu2678Okj/5gHJcMA9nZ2H4+JgBA+7MO5V+PiMy/gUOmTqxZnOZ2FFi?= =?us-ascii?Q?ISYOcrXuwY2TATylwNzTYZjpHQmNKXmKZOUeZo/dniVfboGO0c6tuSqO266e?= =?us-ascii?Q?FNtBEADZ/DGNbfheIp5Td/Sm0XOOC5DVgHy94cefMsBKPH7YdD4+MAPtOpDI?= =?us-ascii?Q?fqjCdg0NJSYH02aGyY4OOfvFtihYrxtQ/T0CEOKMzvrDAUjRz9jFgOpZtwCL?= =?us-ascii?Q?Lng/Ph5q6l0ik7u8EHyyI7tKa9S4Y4Ju4Q3RZRP86GVA3bcqd+ZOH/HU2L3g?= =?us-ascii?Q?ZI7JFBeUcLzYKBInKbWoEtCWwgwPbW8y5P6fpZRH83Tw+9/+LUA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 6:ZyQH4MQTGg5lHwtts/hai0KTYj3HRG2ldf75agOwtWWYnS4OW3fcsGJNMqkFzeJWJ1co/o8h6w0AQ+Ss1QVQNVAL+5d56NOtdCrPmyvquu4uekNHYD2wxOeSOALx1/QPIOXaSRLgV6f09yAFysccLNgVBljfJtkaJnLn4HMKOfngjcELcQLr8OR2lr3YT6XM0bSCtNbTmbAVqgiC63COe267doJ7gh8UtBgjMI0vEDQ+IL4Qr6zkIOL0PLoi0rU6Zai7YMrQ/lT9LbmU2JObHOmvHcwzRfziX3j9WWKIoRs=; 5:sQ09LQc5eEqs5zm/yDSA9fCbJ79MiKtb+y+eHcvtqKJf9CsxiYhV/l5uK+dfq5QP8bnBlFFI2NpdiZoPAzUKVEJCu/eJfNfGF77qxHc4D9leNN6VPN9H9EubfqyrZr71V8oxmVYsv26d9c7WBzDIDw==; 24:CVcecUIX++az1sZ5SUq9/oFtp99e94ChV84tEt5HaXqS55u5PwRq0k+O+9VWuUcgcpZK/LDyerbPy/6DwCLUfA5g0bFopyKD9l7rONxz/+A=; 7:BgW2e7DL11MfGhnOc9blUDe44EWtsVqst4S93NDRUO16sitVzy/ryheiNhqrV/I5AlX/7K+K04v6EQkKVusIZ/ECpzxCguNktYJVehXqc/zSCPpUXVuN+WihP+G4t3GO+n7nFn2q8/ANZa2eFE0NOUmmI4+X4nNtTIuZqD/aq2OU4oAxDkDWRZhmtNrhPVFGULZYCOIUyzbvpnq0BUdxXg== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2016 13:32:16.7128 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1718 Subject: [dpdk-dev] [PATCH v6 19/27] net/thunderx: add single and multi segment Tx functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 13:32:23 -0000 Signed-off-by: Jerin Jacob Signed-off-by: Maciej Czekaj Signed-off-by: Kamil Rytarowski Signed-off-by: Zyta Szpak Signed-off-by: Slawomir Rosek Signed-off-by: Radoslaw Biernacki --- drivers/net/thunderx/Makefile | 2 + drivers/net/thunderx/nicvf_ethdev.c | 5 +- drivers/net/thunderx/nicvf_rxtx.c | 255 ++++++++++++++++++++++++++++++++++++ drivers/net/thunderx/nicvf_rxtx.h | 93 +++++++++++++ 4 files changed, 354 insertions(+), 1 deletion(-) create mode 100644 drivers/net/thunderx/nicvf_rxtx.c create mode 100644 drivers/net/thunderx/nicvf_rxtx.h diff --git a/drivers/net/thunderx/Makefile b/drivers/net/thunderx/Makefile index eb9f100..9079b5b 100644 --- a/drivers/net/thunderx/Makefile +++ b/drivers/net/thunderx/Makefile @@ -51,10 +51,12 @@ VPATH += $(SRCDIR)/base # # all source are stored in SRCS-y # +SRCS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += nicvf_rxtx.c SRCS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += nicvf_hw.c SRCS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += nicvf_mbox.c SRCS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += nicvf_ethdev.c +CFLAGS_nicvf_rxtx.o += -fno-prefetch-loop-arrays -Ofast # this lib depends upon: DEPDIRS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += lib/librte_eal lib/librte_ether diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index e20f0d9..c727ce0 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -66,7 +66,7 @@ #include "base/nicvf_plat.h" #include "nicvf_ethdev.h" - +#include "nicvf_rxtx.h" #include "nicvf_logs.h" static inline int @@ -617,6 +617,9 @@ nicvf_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx, (tx_conf->tx_free_thresh == NICVF_DEFAULT_TX_FREE_THRESH ? NICVF_TX_FREE_MPOOL_THRESH : tx_conf->tx_free_thresh); + txq->pool_free = nicvf_multi_pool_free_xmited_buffers; + } else { + txq->pool_free = nicvf_single_pool_free_xmited_buffers; } /* Allocate software ring */ diff --git a/drivers/net/thunderx/nicvf_rxtx.c b/drivers/net/thunderx/nicvf_rxtx.c new file mode 100644 index 0000000..88a5152 --- /dev/null +++ b/drivers/net/thunderx/nicvf_rxtx.c @@ -0,0 +1,255 @@ +/* + * BSD LICENSE + * + * Copyright (C) Cavium networks Ltd. 2016. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Cavium networks nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "base/nicvf_plat.h" + +#include "nicvf_ethdev.h" +#include "nicvf_rxtx.h" +#include "nicvf_logs.h" + +static inline void __hot +fill_sq_desc_header(union sq_entry_t *entry, struct rte_mbuf *pkt) +{ + /* Local variable sqe to avoid read from sq desc memory*/ + union sq_entry_t sqe; + uint64_t ol_flags; + + /* Fill SQ header descriptor */ + sqe.buff[0] = 0; + sqe.hdr.subdesc_type = SQ_DESC_TYPE_HEADER; + /* Number of sub-descriptors following this one */ + sqe.hdr.subdesc_cnt = pkt->nb_segs; + sqe.hdr.tot_len = pkt->pkt_len; + + ol_flags = pkt->ol_flags & NICVF_TX_OFFLOAD_MASK; + if (unlikely(ol_flags)) { + /* L4 cksum */ + if (ol_flags & PKT_TX_TCP_CKSUM) + sqe.hdr.csum_l4 = SEND_L4_CSUM_TCP; + else if (ol_flags & PKT_TX_UDP_CKSUM) + sqe.hdr.csum_l4 = SEND_L4_CSUM_UDP; + else + sqe.hdr.csum_l4 = SEND_L4_CSUM_DISABLE; + sqe.hdr.l4_offset = pkt->l3_len + pkt->l2_len; + + /* L3 cksum */ + if (ol_flags & PKT_TX_IP_CKSUM) { + sqe.hdr.csum_l3 = 1; + sqe.hdr.l3_offset = pkt->l2_len; + } + } + + entry->buff[0] = sqe.buff[0]; +} + +void __hot +nicvf_single_pool_free_xmited_buffers(struct nicvf_txq *sq) +{ + int j = 0; + uint32_t curr_head; + uint32_t head = sq->head; + struct rte_mbuf **txbuffs = sq->txbuffs; + void *obj_p[NICVF_MAX_TX_FREE_THRESH] __rte_cache_aligned; + + curr_head = nicvf_addr_read(sq->sq_head) >> 4; + while (head != curr_head) { + if (txbuffs[head]) + obj_p[j++] = txbuffs[head]; + + head = (head + 1) & sq->qlen_mask; + } + + rte_mempool_put_bulk(sq->pool, obj_p, j); + sq->head = curr_head; + sq->xmit_bufs -= j; + NICVF_TX_ASSERT(sq->xmit_bufs >= 0); +} + +void __hot +nicvf_multi_pool_free_xmited_buffers(struct nicvf_txq *sq) +{ + uint32_t n = 0; + uint32_t curr_head; + uint32_t head = sq->head; + struct rte_mbuf **txbuffs = sq->txbuffs; + + curr_head = nicvf_addr_read(sq->sq_head) >> 4; + while (head != curr_head) { + if (txbuffs[head]) { + rte_pktmbuf_free_seg(txbuffs[head]); + n++; + } + + head = (head + 1) & sq->qlen_mask; + } + + sq->head = curr_head; + sq->xmit_bufs -= n; + NICVF_TX_ASSERT(sq->xmit_bufs >= 0); +} + +static inline uint32_t __hot +nicvf_free_tx_desc(struct nicvf_txq *sq) +{ + return ((sq->head - sq->tail - 1) & sq->qlen_mask); +} + +/* Send Header + Packet */ +#define TX_DESC_PER_PKT 2 + +static inline uint32_t __hot +nicvf_free_xmitted_buffers(struct nicvf_txq *sq, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) +{ + uint32_t free_desc = nicvf_free_tx_desc(sq); + + if (free_desc < nb_pkts * TX_DESC_PER_PKT || + sq->xmit_bufs > sq->tx_free_thresh) { + if (unlikely(sq->pool == NULL)) + sq->pool = tx_pkts[0]->pool; + + sq->pool_free(sq); + /* Freed now, let see the number of free descs again */ + free_desc = nicvf_free_tx_desc(sq); + } + return free_desc; +} + +uint16_t __hot +nicvf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) +{ + int i; + uint32_t free_desc; + uint32_t tail; + struct nicvf_txq *sq = tx_queue; + union sq_entry_t *desc_ptr = sq->desc; + struct rte_mbuf **txbuffs = sq->txbuffs; + struct rte_mbuf *pkt; + uint32_t qlen_mask = sq->qlen_mask; + + tail = sq->tail; + free_desc = nicvf_free_xmitted_buffers(sq, tx_pkts, nb_pkts); + + for (i = 0; i < nb_pkts && (int)free_desc >= TX_DESC_PER_PKT; i++) { + pkt = tx_pkts[i]; + + txbuffs[tail] = NULL; + fill_sq_desc_header(desc_ptr + tail, pkt); + tail = (tail + 1) & qlen_mask; + + txbuffs[tail] = pkt; + fill_sq_desc_gather(desc_ptr + tail, pkt); + tail = (tail + 1) & qlen_mask; + free_desc -= TX_DESC_PER_PKT; + } + + sq->tail = tail; + sq->xmit_bufs += i; + rte_wmb(); + + /* Inform HW to xmit the packets */ + nicvf_addr_write(sq->sq_door, i * TX_DESC_PER_PKT); + return i; +} + +uint16_t __hot +nicvf_xmit_pkts_multiseg(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) +{ + int i, k; + uint32_t used_desc, next_used_desc, used_bufs, free_desc, tail; + struct nicvf_txq *sq = tx_queue; + union sq_entry_t *desc_ptr = sq->desc; + struct rte_mbuf **txbuffs = sq->txbuffs; + struct rte_mbuf *pkt, *seg; + uint32_t qlen_mask = sq->qlen_mask; + uint16_t nb_segs; + + tail = sq->tail; + used_desc = 0; + used_bufs = 0; + + free_desc = nicvf_free_xmitted_buffers(sq, tx_pkts, nb_pkts); + + for (i = 0; i < nb_pkts; i++) { + pkt = tx_pkts[i]; + + nb_segs = pkt->nb_segs; + + next_used_desc = used_desc + nb_segs + 1; + if (next_used_desc > free_desc) + break; + used_desc = next_used_desc; + used_bufs += nb_segs; + + txbuffs[tail] = NULL; + fill_sq_desc_header(desc_ptr + tail, pkt); + tail = (tail + 1) & qlen_mask; + + txbuffs[tail] = pkt; + fill_sq_desc_gather(desc_ptr + tail, pkt); + tail = (tail + 1) & qlen_mask; + + seg = pkt->next; + for (k = 1; k < nb_segs; k++) { + txbuffs[tail] = seg; + fill_sq_desc_gather(desc_ptr + tail, seg); + tail = (tail + 1) & qlen_mask; + seg = seg->next; + } + } + + sq->tail = tail; + sq->xmit_bufs += used_bufs; + rte_wmb(); + + /* Inform HW to xmit the packets */ + nicvf_addr_write(sq->sq_door, used_desc); + return nb_pkts; +} diff --git a/drivers/net/thunderx/nicvf_rxtx.h b/drivers/net/thunderx/nicvf_rxtx.h new file mode 100644 index 0000000..b1fdc69 --- /dev/null +++ b/drivers/net/thunderx/nicvf_rxtx.h @@ -0,0 +1,93 @@ +/* + * BSD LICENSE + * + * Copyright (C) Cavium networks Ltd. 2016. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Cavium networks nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __THUNDERX_NICVF_RXTX_H__ +#define __THUNDERX_NICVF_RXTX_H__ + +#include + +#define NICVF_TX_OFFLOAD_MASK (PKT_TX_IP_CKSUM | PKT_TX_L4_MASK) + +#ifndef __hot +#define __hot __attribute__((hot)) +#endif + +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN +static inline uint16_t __attribute__((const)) +nicvf_frag_num(uint16_t i) +{ + return (i & ~3) + 3 - (i & 3); +} + +static inline void __hot +fill_sq_desc_gather(union sq_entry_t *entry, struct rte_mbuf *pkt) +{ + /* Local variable sqe to avoid read from sq desc memory*/ + union sq_entry_t sqe; + + /* Fill the SQ gather entry */ + sqe.buff[0] = 0; sqe.buff[1] = 0; + sqe.gather.subdesc_type = SQ_DESC_TYPE_GATHER; + sqe.gather.ld_type = NIC_SEND_LD_TYPE_E_LDT; + sqe.gather.size = pkt->data_len; + sqe.gather.addr = rte_mbuf_data_dma_addr(pkt); + + entry->buff[0] = sqe.buff[0]; + entry->buff[1] = sqe.buff[1]; +} + +#else + +static inline uint16_t __attribute__((const)) +nicvf_frag_num(uint16_t i) +{ + return i; +} + +static inline void __hot +fill_sq_desc_gather(union sq_entry_t *entry, struct rte_mbuf *pkt) +{ + entry->buff[0] = (uint64_t)SQ_DESC_TYPE_GATHER << 60 | + (uint64_t)NIC_SEND_LD_TYPE_E_LDT << 58 | + pkt->data_len; + entry->buff[1] = rte_mbuf_data_dma_addr(pkt); +} +#endif + +uint16_t nicvf_xmit_pkts(void *txq, struct rte_mbuf **tx_pkts, uint16_t pkts); +uint16_t nicvf_xmit_pkts_multiseg(void *txq, struct rte_mbuf **tx_pkts, + uint16_t pkts); + +void nicvf_single_pool_free_xmited_buffers(struct nicvf_txq *sq); +void nicvf_multi_pool_free_xmited_buffers(struct nicvf_txq *sq); + +#endif /* __THUNDERX_NICVF_RXTX_H__ */ -- 2.5.5