From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0055.outbound.protection.outlook.com [157.56.110.55]) by dpdk.org (Postfix) with ESMTP id 09F6D3990 for ; Sun, 29 May 2016 18:55:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=h1el/yHtrfDU5HIitW8kQDPbesGqQZMMDpp2fZ6PxoY=; b=hUn5dSfM53gRQy96WJ9zjYi9zPQuRmmnqm+fUv6ryaG+e/X2Vz3DvnvNH2ykiuI6hUYgoOKjhQYK9Q9HP5L3h9FZSg+LLGw/+HKikDvj/yRoSEQ7BG63wGCVYcR8/5qr/7tdnvYIWFmrtsRcHKas5tcbA3sc1DXirKZfZXmofw8= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost.localdomain.localdomain (122.167.187.184) by BY1PR0701MB1722.namprd07.prod.outlook.com (10.162.111.141) with Microsoft SMTP Server (TLS) id 15.1.501.7; Sun, 29 May 2016 16:55:02 +0000 From: Jerin Jacob To: CC: , , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Sun, 29 May 2016 22:24:19 +0530 Message-ID: <1464540867-13115-2-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1464540867-13115-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1462634198-2289-1-git-send-email-jerin.jacob@caviumnetworks.com> <1464540867-13115-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [122.167.187.184] X-ClientProxiedBy: PN1PR01CA0029.INDPRD01.PROD.OUTLOOK.COM (10.164.137.36) To BY1PR0701MB1722.namprd07.prod.outlook.com (10.162.111.141) X-MS-Office365-Filtering-Correlation-Id: 7b93eebc-8c61-4102-d713-08d387e1fc80 X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1722; 2:OL62KD6QIZLVtcXNXaAO4ZFMC/COnco3HQc35lopMBJF1ofeiA20rPXZ4h+DolautlHP1MBHpE1ktyPrvS+75DUcUnfEfnYjuiOAMkQcPO+DpBVUgrDDtZWBJ7+Nzr39gbNQhtodaAQAYgHZh3ZkQ4QIkf23hzpg6gs6BUugx4+iVUcjGvuvIC/V4Y8B87vq; 3:ZCIb2OSl4bEEnYyu6aMCgxvDj4s0HKjmAdcqaHTSbV/7IiGBimkAPl8LK1Obrb52vTSNuXob33mRdZFW1MbxSCT8XFVT7vOMBaS8dsDuV9ZCC9uIIBIDbh4J/iNvGdjn X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1722; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1722; 25:91+9MLQzQwlwaXSQZTUDqvNL/go5hYWcBQUX02YBhStACQi1jaFCG8l80uLXxBBkNkPTJFsKyvnHo/DG1uAszkBxGWEyrtl0FwuTNzmcK1y9rF3+IvwLy3KeGxj9Vu35jVcRJ7sGlEB6UWEp+9GDnG4QlinfIjDXlemBECn6KB1E8s6WEGvd8y21bl+fF2XGHGFmuOWd9yTCxeoRXRyB5ofVwsrL0jXq8613fL02jG1+2osCPxAS+jSjb59dnZkA9wRgQ6lEMts+ZVL56jLXuI/HHTb/ipEYpDJfPva0M1BLjT4a499GxHIpfm8Th9rwsDQVBFP2GcRJWyYGM94AbwGPPyxWmj96WxyLSUuZTRx7mjFzDbQsCFKp85xgZj3PL0mMlZcY1jFVQjQV7yGaxx6pR3UNO3cSAmUlNx5b8hCwgc7vJHMWbRr6lKBZ3lfL4gQiOR3uOzO3DDATfGCSrjlBmxMNuEQ624+ir2ihv7g/5MKTMi6vc/9+K7xhO2JwoQZ2d81bTAacpaZ+1aEW8Lj3etaVcq6rzIvg0JiLkry9Qd89U2BejVoJ9fLJdnyMormfLFexpNG1fbGvZg/DXg/p+ny77ufVaEgwkMXf2KzwqUfzs3JLiJg1haa4l0eMPN/6s97v7U6PtxI4sj1yNdRoBS9RiUvaHs5FHiXqN0LVlFOYHvUwrb01Hg+gj0wcpOaD+caL9kdEYQfxwwo+XlzCWuT8Gk63oHKsRWvab+N91NED8JNUydo+ILvTsGPW X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1722; 20:zJZoAuCARGfc/mux/AwuyRFiFEyda2ZIL6wHXf6e5kpox4U9YaIrlEXToT881cQE1l0psaPdjGHgrSDlrZTmyv/nP9K81gCvPfGVD1gavvrQOuWqxIrXsOHXbzmBMIAjBGQN0JpcgLHFw1JXyWClnzRrZ9tG21PToKFNOqq4GXnj1U0SgtVL5P3I5hua6r0R/5POCCW0B2DSjxEm9uAI0WFKCP1/wIloYEUUontUb6SuX4ORqBPkfMn6wCzbDZEaUkrY3pEIo78HVGr/CRDLLOuNbhjmokUnAKj9LzXlb5CUQ9UxGi/gsAESIyuT6Uhb9U7UpGryqfvHdhYA31x5OYjrHLx2TBqGJcUrCM2f+lbRnLKbgctt+S3vrMPvdiGx0QiTKgqZFxG6lMAC9jm7icAFvK437Usj9Oeb76CLxxsR11FqCGgg06e0lwOmoeJuy1qV2bqKb9OwcmydRpeFG2R0BTWKelmjFZdFtFWNOF6wwn3L/+GKVhL6atQkG+HpsaNV4K3Dd/1pt0zsRO5yGq8ztQ7pLdgEPrBiE8OL5BRjB4NG//rDZqf6e56Mrg06puDLVXoAwFYbTxZxLMtT5EeeWp0QEQCUX6fOSYr4jy0= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:BY1PR0701MB1722; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1722; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1722; 4:QIdxiOmfbzmxOon698nt9vi8t5RS1AN5o6gYkkJVVrXy/CxX0oJav+2dm3cH3VYvle5+p8pIfu2V7NqfN0+Jk19xiO5rIVWILVqO5nPTGF/F5yn9EkZpFIfZUGTCfZcgWAhKqO4FiGXAhUcdwhPG/00jIy2LvFHkKbJIDgH6EQ8/feq2GkRAyOaXhAq2q3ZTcIWooDy0KzFqWATIkA/mBulOGFN/uhwgvS/mgL/eoFiOVyaEL7ufJL8QcB4SXqo1mV/cYo/8sOzed8+bacn7cgRWo1kI/QWyYwIwzlMkmo5W1GoqY0Zc7N0zn3OPsF02ylCRDRGle3jxrIeUhY85wpGppzlFy0TbRws6YbHS2sqNx7PS3+l8EBKmKDpuRkPD X-Forefront-PRVS: 0957AD37A0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(33646002)(42186005)(50466002)(92566002)(50226002)(229853001)(2351001)(5003940100001)(189998001)(2950100001)(110136002)(77096005)(36756003)(47776003)(5004730100002)(48376002)(2906002)(586003)(8676002)(5008740100001)(19580395003)(66066001)(4326007)(76176999)(81166006)(3846002)(6116002)(50986999)(19580405001)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1722; H:localhost.localdomain.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1722; 23:w4t82s9yD6500NQuUJKqvihJuIXxn8qCvQybjBsddowTIqdJwzbhwkN1isEhd0p2KdN+spO7bpAEkIRW7H9oKHoWUQhPtsB00Am4JxNuoZMTYEVYDIAXLcZAI940wJGk4ZQgzTdjFfrs2PS6nzu9GpxJfMBEBYDImJj7KybPpxzMt03TNuYeUGcVIBDMJZ72Bv6xDq5srCKXfzDKIG0tel4dMjuyBKyKuM8AMFGulDWjBxiPo8x4wHCqmWbM0ZV2ojchvO4qBq1+hGhiK/X9EO3iHZQqjerM/6fxAFB//FLN3rKBIAX0bSJ8vVDcXSCdIfrLSstU1pczpxSp9Q3UTndPL32oW22YUrKmQ+mEuJz1GQffE6dt8pzh66O5hHLg/c5B81bTgL8ZBvMkEy73/6RbLxmsE/fr5/Z38UYWLHsVVPxU/w84vwkmwymyKuDnLI3dYZnw3XQiTLYpAgpjgQXzbvExJXvq/IqC22I3v+XZh83due7Yespan8ebcfoco9+qYQ/eyLDO8Z3ZsjZTq6frmCRK11/jwEbQXE/1iurqqUgyCUaUxJK5Hk9uN2Q33/6mh6MCDBqNesabnZNLiiPVkGoW4EopRh4C4oLFq0qPBFoSSeGXO45QOHTNBQloc7e7VDWevoBuXTdw+msnD3v7qwIUkf7tvxRtPq+st8h9hJ0ZZOL1FlljdrMLUgGse+EdcUKrGsbfOesAVeoIduEhqdzoN7++4rf0TYLM7vkyi4OCoa3LfHr6270PzmKAbWSoiCGITAuMC147ALCLkvhlGFYuVCiY88NwSehO5QvHbE+oz/GqmFq51fiZRRd6cQH1I7b0N6lARvYC+7dHTFhIzRpSujObowxIaCEtOisDp2LZeZGx5L/WQV/W1cvs X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1722; 5:Bk2fre7u4rzJ5KHiW58IPQJgcsrDvkAqHnbO7VGlwtiuoaRCPl/rHR61eV5P8AS7hwVVDgHOJ3tf+ybJOzap8DUJWKexUAjE9yrwcfxM+viBeQs4+DSkItnfisFbyD7tTMjDL6drqZrMYk5NsLPVfQ==; 24:uUvpxGlEQUKhhcwIhVbltR7OiqwwLuoEhsYNT+IK10qMbzlfxobpgjDRyBZhsVuPv1zylEMnjV4SmdERiebMVkWsg92NzAtjJv+3kAaQ5xw=; 7:wvKuYMT64i25eugNqg6sV/jGqgmw9NSViRQJuz3C4mH+NrUH/1vXpfNpFypbKJ87WuMrZYYlRU2iJG7wmp+RxiwPL+Xjl7GLp+3LjukqURKDkvAhunAQhXozWvZJvmuLrtr98uMlX9HEeYlViELQSTfIOlLJO+oqaMqfCfzyTqBh1HiuB+4aoL2bZs8QLQ6H SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2016 16:55:02.8064 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1722 Subject: [dpdk-dev] [PATCH v2 12/20] thunderx/nicvf: 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: Sun, 29 May 2016 16:55:08 -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 | 256 ++++++++++++++++++++++++++++++++++++ drivers/net/thunderx/nicvf_rxtx.h | 93 +++++++++++++ 4 files changed, 355 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 817ad37..4c53cb9 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 int nicvf_dev_configure(struct rte_eth_dev *dev); @@ -671,6 +671,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..3cf7193 --- /dev/null +++ b/drivers/net/thunderx/nicvf_rxtx.c @@ -0,0 +1,256 @@ +/* + * 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_xmittted_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_xmittted_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_xmittted_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..3c51432 --- /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