From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 59EFEA0547; Thu, 16 Jun 2022 04:42:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3992C42BD2; Thu, 16 Jun 2022 04:41:30 +0200 (CEST) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2091.outbound.protection.outlook.com [40.107.100.91]) by mails.dpdk.org (Postfix) with ESMTP id 7D64A4114F for ; Thu, 16 Jun 2022 04:41:29 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W03xNjItvZKNVW7adFsSp9WmqAB3NwCTJK/LHQ1RArORZKTT8sz+Bd7N2CPp5441k3zdlpObcGHzG2EvU53T0OYup+URSQFMi5SXGv3x1aMftgVDmz0WfUffCFYkx7tPIFs3mAD+bPw6j/QqTWLlhFIzqyJns+fEREbJX2ICzh4NesN8LNxdrLUGzA/lnomFd1MBGgFkImUUe8qUcH4kGYtnI4gWI3XTIvCpj5BLJfdbLPfopORW8PzUuP5M5GYdbDZCGqmfJP+0Hf8SL4IW+evIPoFpq3lN/5xoyHagOiSVVVrGB0mDPNAGU7pI52twdzaz4RfNtw1dCHuTZFoipA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9f67gHHj42EtVtwfIFunG6VH+mxbS/D3wnoGOIcuklY=; b=i0f90hZVKpGpiA0nUXHIESnmtHXEsotJjH3d9sgZrLTJ/CAhgkIj8znKyVKdDYzDKs49vlqJH3bEvd2WqfrZwBgpwi5yzKs4R8iuVag395KarVIN5S0QbpBVSWsgROEql8pa4Cz8pTJ4tTtO2s1L5FU2hzZCxIn4XaqisQq7dFvwUH/v5nsqZHlazDgjumseVHVw8C9rzKpK/o6607Lbyp4Rq3VEGOVQnj8HX9Ml3caifJoeoyTt/58gpvHJGao3xolFKc+uL9nuOq64wtYeYeXB3f3XI+mHjrXMt0LEt0DSLhE8U3nROzrfgnPZpzAbzZKC7EiDGZUW/OwdY5Q1zQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9f67gHHj42EtVtwfIFunG6VH+mxbS/D3wnoGOIcuklY=; b=iBe8cE/YkJJaeiCZzEWc6D041V2ipklIrM8BZ3rjsUqD3pyO+VkRQWqd1j+uUEEv7efjoRDOP6ZwBzyCijeRZoxIjcCU2PlNj8UkaIwiRDLB2eR2ugVVHFO+ht7vV5Xoj9N7kRoZ2Cf67xs3waY3/v9cj302tLnWMJEyoeBv9Sw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM6PR13MB3004.namprd13.prod.outlook.com (2603:10b6:5:191::21) by CY4PR1301MB1912.namprd13.prod.outlook.com (2603:10b6:910:46::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.11; Thu, 16 Jun 2022 02:41:26 +0000 Received: from DM6PR13MB3004.namprd13.prod.outlook.com ([fe80::ac31:a36a:cc15:cd35]) by DM6PR13MB3004.namprd13.prod.outlook.com ([fe80::ac31:a36a:cc15:cd35%7]) with mapi id 15.20.5353.011; Thu, 16 Jun 2022 02:41:26 +0000 From: Jin Liu To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Jin Liu , Diana Wang , Peng Zhang , Chaoyong He Subject: [PATCH v2 14/15] net/nfp: nfdk packet xmit function Date: Thu, 16 Jun 2022 04:39:38 +0200 Message-Id: <20220616023939.1798769-15-jin.liu@corigine.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220616023939.1798769-1-jin.liu@corigine.com> References: <20220602015304.710197-1-jin.liu@corigine.com> <20220616023939.1798769-1-jin.liu@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P123CA0087.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:190::20) To DM6PR13MB3004.namprd13.prod.outlook.com (2603:10b6:5:191::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2d556ea3-3d0c-4c4a-8a26-08da4f41b56c X-MS-TrafficTypeDiagnostic: CY4PR1301MB1912:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xJOiPxNxXCl2W10vPATYBpN5UE9V8+T7Gv9zzvDhawz7WgvgFED0bLgjAUpSpXPm7qnq/qBJoTIm4mO3ZEDSXAhipHvEWkdr3sqZZAvdTYzmeL9uD7SJ1cBEiWaX8B5ggA8GhKrBvxn+vbXH2IyYlKbrMfTyEQ5OjFd3NdMFxI43xkZIaSQTy23+6VbWbIB8yK0TQrzMLqBUS18hIUS5cjN+5rtcnIo4lbJpxaTipbGNJ7E6Exb678GeXM6ZJfe1uU989pXGx+zsi/ImVP9KpqbpYvtL+f/g1d8i2xkYcOiol4i9ioqD21csZcXg1LjSXAPh0MCs4MHF4N+pPGr4QhG3s0o94lyhCr/Q/l+Zba4oZsExGLxPYj/23P7D+R7tRcMgZJVG4Z2SVsllI/mX0bJVXrQWSMWqsdgWxH4QlJa4JSCooKzXvxOY2Wgd5uyJ7mrc1Kh1EEPm85rJ8c7BYqheUoOg7UCLwzSF1aN2GYVgxdyTDGB5DTTENUxqLLP2coj/1OeX71lSmzRBfaDz22KZuMK9a6iPrpUU+Mbll5M8HbHf8EcCvGof4JJxDi3CsktbX5Ed2lOkSXYeiCreMTB2kfSMDMb8r8Vq816Q0podfib+YA1Pn4UGvd0UuRfZOx2/MRLmchGSkQ0WjR/8R8p1m9bdDLfKy+7486SufgfsX//hFSutqk5TDSk2GPl9KQz1tc1NKXCgkC/ISYXWaA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR13MB3004.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(346002)(39830400003)(396003)(366004)(41300700001)(1076003)(107886003)(2616005)(5660300002)(8936002)(30864003)(6666004)(86362001)(6486002)(508600001)(26005)(6512007)(44832011)(52116002)(6506007)(66574015)(38100700002)(2906002)(38350700002)(4326008)(36756003)(6916009)(83380400001)(316002)(66946007)(8676002)(66476007)(66556008)(54906003)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dC9qSGxRWDMrL2pMdmJiVXBMOWRIWXk5Wjg4aEp4MUw3TWpTYWhTSGRNUkU4?= =?utf-8?B?dEc4cGZ3cjdYUXkraTVHWFJjWS9LRDRlSk9QeXRiRTRPODdwVFFxak56NjdO?= =?utf-8?B?dFY5OGhrM3dPVlBOU2F3d3lRWjVjR0w5NWhLV0dXRGhBdmlEVnUvVmtMVkEr?= =?utf-8?B?N3hwVFpmNlZ2OWJyMnZ6WjlJZnlGWHNtakxHSThpMDZyUk5lUzNFNDRjQ1lR?= =?utf-8?B?VG5qWkFyRmZTeE93cnlKdklsdVk3dUNWd3pPRkJaMmx0ajR5YjhNL1Z0RGd6?= =?utf-8?B?ZlMxeUFtUzlYY1JHRUl0TTdo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b1hqUmNu?= =?utf-8?B?RW1OQS9nZ1o4aUtCTm95TkZlTExXR2FhcWZzSDFCV2JsM21iWnhuREc0Vzh3?= =?utf-8?B?SEJuN0dwUGJxUU1Jc1ExWXIreUhnZGdUUFBWQ3c3NXFZOWphY3gvL1oxdWEv?= =?utf-8?B?Q2twNEx6RFlTb3ZiWURrODJub1lLR0xiOU0yL0pjUEdBQnQ5dDRMQTd5akRx?= =?utf-8?B?NmladVZBZmxKM3Q0STN6SWxHTVh6bkhjYllhcllza1hMRm1QakdLUT09?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d556ea3-3d0c-4c4a-8a26-08da4f41b56c X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB3004.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2022 02:41:26.5197 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wCXxLzocXgD1WWYhU6mOfsSJYEGQsDfj8eQGupPXkIVVmmrBQuSDglJR7gN2mGdjDQ7pXOUpR2hzO4+/FI0CCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1301MB1912 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Implement NFP3800 card packet transmit function for firmware with NFDk. Signed-off-by: Jin Liu Signed-off-by: Diana Wang Signed-off-by: Peng Zhang Signed-off-by: Chaoyong He Signed-off-by: Niklas Söderlund --- drivers/net/nfp/nfp_ethdev.c | 3 +- drivers/net/nfp/nfp_ethdev_vf.c | 3 +- drivers/net/nfp/nfp_rxtx.c | 281 ++++++++++++++++++++++++++++++++ drivers/net/nfp/nfp_rxtx.h | 3 + 4 files changed, 288 insertions(+), 2 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index e8a8368d0f..b6817c10da 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -374,6 +374,7 @@ nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev) switch (NFD_CFG_CLASS_VER_of(hw->ver)) { case NFP_NET_CFG_VERSION_DP_NFD3: eth_dev->dev_ops = &nfp_net_nfd3_eth_dev_ops; + eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts; break; case NFP_NET_CFG_VERSION_DP_NFDK: if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 5) { @@ -382,6 +383,7 @@ nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev) return -EINVAL; } eth_dev->dev_ops = &nfp_net_nfdk_eth_dev_ops; + eth_dev->tx_pkt_burst = &nfp_net_nfdk_xmit_pkts; break; default: PMD_DRV_LOG(ERR, "The version of firmware is not correct."); @@ -390,7 +392,6 @@ nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev) eth_dev->rx_queue_count = nfp_net_rx_queue_count; eth_dev->rx_pkt_burst = &nfp_net_recv_pkts; - eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts; return 0; } diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index 56428814b7..66a1c0a36b 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -279,6 +279,7 @@ nfp_netvf_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev) switch (NFD_CFG_CLASS_VER_of(hw->ver)) { case NFP_NET_CFG_VERSION_DP_NFD3: eth_dev->dev_ops = &nfp_netvf_nfd3_eth_dev_ops; + eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts; break; case NFP_NET_CFG_VERSION_DP_NFDK: if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 5) { @@ -287,6 +288,7 @@ nfp_netvf_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev) return -EINVAL; } eth_dev->dev_ops = &nfp_netvf_nfdk_eth_dev_ops; + eth_dev->tx_pkt_burst = &nfp_net_nfdk_xmit_pkts; break; default: PMD_DRV_LOG(ERR, "The version of firmware is not correct."); @@ -295,7 +297,6 @@ nfp_netvf_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev) eth_dev->rx_queue_count = nfp_net_rx_queue_count; eth_dev->rx_pkt_burst = &nfp_net_recv_pkts; - eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts; return 0; } diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index 4f422c5090..1b00f96ed3 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -20,6 +20,9 @@ #include "nfp_rxtx.h" #include "nfp_logs.h" #include "nfp_ctrl.h" +#include "nfpcore/nfp_mip.h" +#include "nfpcore/nfp_rtsym.h" +#include "nfpcore/nfp-common/nfp_platform.h" static int nfp_net_rx_fill_freelist(struct nfp_net_rxq *rxq) @@ -1104,3 +1107,281 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev, return 0; } + +static inline uint32_t +nfp_net_nfdk_free_tx_desc(struct nfp_net_txq *txq) +{ + uint32_t free_desc; + + if (txq->wr_p >= txq->rd_p) + free_desc = txq->tx_count - (txq->wr_p - txq->rd_p); + else + free_desc = txq->rd_p - txq->wr_p; + + return (free_desc > NFDK_TX_DESC_STOP_CNT) ? + (free_desc - NFDK_TX_DESC_STOP_CNT) : 0; +} + +static inline uint32_t +nfp_net_nfdk_txq_full(struct nfp_net_txq *txq) +{ + return (nfp_net_nfdk_free_tx_desc(txq) < txq->tx_free_thresh); +} + +static inline int +nfp_net_nfdk_headlen_to_segs(unsigned int headlen) +{ + return DIV_ROUND_UP(headlen + + NFDK_TX_MAX_DATA_PER_DESC - + NFDK_TX_MAX_DATA_PER_HEAD, + NFDK_TX_MAX_DATA_PER_DESC); +} + +static int +nfp_net_nfdk_tx_maybe_close_block(struct nfp_net_txq *txq, struct rte_mbuf *pkt) +{ + unsigned int n_descs, wr_p, i, nop_slots; + struct rte_mbuf *pkt_temp; + + pkt_temp = pkt; + n_descs = nfp_net_nfdk_headlen_to_segs(pkt_temp->data_len); + while (pkt_temp->next) { + pkt_temp = pkt_temp->next; + n_descs += DIV_ROUND_UP(pkt_temp->data_len, NFDK_TX_MAX_DATA_PER_DESC); + } + + if (unlikely(n_descs > NFDK_TX_DESC_GATHER_MAX)) + return -EINVAL; + + n_descs += !!(pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG); + + if (round_down(txq->wr_p, NFDK_TX_DESC_BLOCK_CNT) != + round_down(txq->wr_p + n_descs, NFDK_TX_DESC_BLOCK_CNT)) + goto close_block; + + if ((uint32_t)txq->data_pending + pkt->pkt_len > NFDK_TX_MAX_DATA_PER_BLOCK) + goto close_block; + + return 0; + +close_block: + wr_p = txq->wr_p; + nop_slots = D_BLOCK_CPL(wr_p); + + memset(&txq->ktxds[wr_p], 0, nop_slots * sizeof(struct nfp_net_nfdk_tx_desc)); + for (i = wr_p; i < nop_slots + wr_p; i++) { + if (txq->txbufs[i].mbuf) { + rte_pktmbuf_free_seg(txq->txbufs[i].mbuf); + txq->txbufs[i].mbuf = NULL; + } + } + txq->data_pending = 0; + txq->wr_p = D_IDX(txq, txq->wr_p + nop_slots); + + return nop_slots; +} + +static inline uint64_t +nfp_net_nfdk_tx_cksum(struct nfp_net_txq *txq, struct rte_mbuf *mb, + uint64_t flags) +{ + uint64_t ol_flags; + struct nfp_net_hw *hw = txq->hw; + + if (!(hw->cap & NFP_NET_CFG_CTRL_TXCSUM)) + return flags; + + ol_flags = mb->ol_flags; + + /* IPv6 does not need checksum */ + if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM) + flags |= NFDK_DESC_TX_L3_CSUM; + + if (ol_flags & RTE_MBUF_F_TX_L4_MASK) + flags |= NFDK_DESC_TX_L4_CSUM; + + return flags; +} + +static inline uint64_t +nfp_net_nfdk_tx_tso(struct nfp_net_txq *txq, struct rte_mbuf *mb) +{ + uint64_t ol_flags; + struct nfp_net_nfdk_tx_desc txd; + struct nfp_net_hw *hw = txq->hw; + + if (!(hw->cap & NFP_NET_CFG_CTRL_LSO_ANY)) + goto clean_txd; + + ol_flags = mb->ol_flags; + + if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG)) + goto clean_txd; + + txd.l3_offset = mb->l2_len; + txd.l4_offset = mb->l2_len + mb->l3_len; + txd.lso_meta_res = 0; + txd.mss = rte_cpu_to_le_16(mb->tso_segsz); + txd.lso_hdrlen = mb->l2_len + mb->l3_len + mb->l4_len; + txd.lso_totsegs = (mb->pkt_len + mb->tso_segsz) / mb->tso_segsz; + +clean_txd: + txd.l3_offset = 0; + txd.l4_offset = 0; + txd.lso_hdrlen = 0; + txd.mss = 0; + txd.lso_totsegs = 0; + txd.lso_meta_res = 0; + + return txd.raw; +} + +uint16_t +nfp_net_nfdk_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) +{ + uint32_t buf_idx; + uint64_t dma_addr; + uint16_t free_descs; + uint32_t npkts = 0; + uint64_t metadata = 0; + uint16_t issued_descs = 0; + struct nfp_net_txq *txq; + struct nfp_net_hw *hw; + struct nfp_net_nfdk_tx_desc *ktxds; + struct rte_mbuf *pkt, *temp_pkt; + struct rte_mbuf **lmbuf; + + txq = tx_queue; + hw = txq->hw; + + PMD_TX_LOG(DEBUG, "working for queue %u at pos %d and %u packets", + txq->qidx, txq->wr_p, nb_pkts); + + if ((nfp_net_nfdk_free_tx_desc(txq) < NFDK_TX_DESC_PER_SIMPLE_PKT * + nb_pkts) || (nfp_net_nfdk_txq_full(txq))) + nfp_net_tx_free_bufs(txq); + + free_descs = (uint16_t)nfp_net_nfdk_free_tx_desc(txq); + if (unlikely(free_descs == 0)) + return 0; + + PMD_TX_LOG(DEBUG, "queue: %u. Sending %u packets", txq->qidx, nb_pkts); + /* Sending packets */ + while ((npkts < nb_pkts) && free_descs) { + uint32_t type, dma_len, dlen_type, tmp_dlen; + int nop_descs, used_descs; + + pkt = *(tx_pkts + npkts); + nop_descs = nfp_net_nfdk_tx_maybe_close_block(txq, pkt); + if (nop_descs < 0) + goto xmit_end; + + issued_descs += nop_descs; + ktxds = &txq->ktxds[txq->wr_p]; + /* Grabbing the mbuf linked to the current descriptor */ + buf_idx = txq->wr_p; + lmbuf = &txq->txbufs[buf_idx++].mbuf; + /* Warming the cache for releasing the mbuf later on */ + RTE_MBUF_PREFETCH_TO_FREE(*lmbuf); + + temp_pkt = pkt; + + if (unlikely(pkt->nb_segs > 1 && + !(hw->cap & NFP_NET_CFG_CTRL_GATHER))) { + PMD_INIT_LOG(INFO, "NFP_NET_CFG_CTRL_GATHER not set"); + rte_panic("Multisegment packet unsupported\n"); + } + + /* + * Checksum and VLAN flags just in the first descriptor for a + * multisegment packet, but TSO info needs to be in all of them. + */ + + dma_len = pkt->data_len; + if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) && + (pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG)) { + type = NFDK_DESC_TX_TYPE_TSO; + } else if (!pkt->next && dma_len < NFDK_TX_MAX_DATA_PER_HEAD) { + type = NFDK_DESC_TX_TYPE_SIMPLE; + } else { + type = NFDK_DESC_TX_TYPE_GATHER; + } + dma_len -= 1; + dlen_type = (NFDK_DESC_TX_DMA_LEN_HEAD & dma_len) | + (NFDK_DESC_TX_TYPE_HEAD & (type << 12)); + ktxds->dma_len_type = rte_cpu_to_le_16(dlen_type); + dma_addr = rte_mbuf_data_iova(pkt); + PMD_TX_LOG(DEBUG, "Working with mbuf at dma address:" + "%" PRIx64 "", dma_addr); + ktxds->dma_addr_hi = rte_cpu_to_le_16(dma_addr >> 32); + ktxds->dma_addr_lo = rte_cpu_to_le_32(dma_addr & 0xffffffff); + ktxds++; + + tmp_dlen = dlen_type & NFDK_DESC_TX_DMA_LEN_HEAD; + dma_len -= tmp_dlen; + dma_addr += tmp_dlen + 1; + + while (pkt) { + if (*lmbuf) + rte_pktmbuf_free_seg(*lmbuf); + *lmbuf = pkt; + while (dma_len > 0) { + dma_len -= 1; + dlen_type = NFDK_DESC_TX_DMA_LEN & dma_len; + + ktxds->dma_len_type = rte_cpu_to_le_16(dlen_type); + ktxds->dma_addr_hi = rte_cpu_to_le_16(dma_addr >> 32); + ktxds->dma_addr_lo = rte_cpu_to_le_32(dma_addr & 0xffffffff); + ktxds++; + + dma_len -= dlen_type; + dma_addr += dlen_type + 1; + } + + if (!pkt->next) + break; + + pkt = pkt->next; + dma_len = pkt->data_len; + dma_addr = rte_mbuf_data_iova(pkt); + PMD_TX_LOG(DEBUG, "Working with mbuf at dma address:" + "%" PRIx64 "", dma_addr); + + lmbuf = &txq->txbufs[buf_idx++].mbuf; + } + + (ktxds - 1)->dma_len_type = rte_cpu_to_le_16(dlen_type | NFDK_DESC_TX_EOP); + + ktxds->raw = rte_cpu_to_le_64(nfp_net_nfdk_tx_cksum(txq, temp_pkt, metadata)); + ktxds++; + + if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) && + (temp_pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG)) { + ktxds->raw = rte_cpu_to_le_64(nfp_net_nfdk_tx_tso(txq, temp_pkt)); + ktxds++; + } + + used_descs = ktxds - txq->ktxds - txq->wr_p; + if (round_down(txq->wr_p, NFDK_TX_DESC_BLOCK_CNT) != + round_down(txq->wr_p + used_descs - 1, NFDK_TX_DESC_BLOCK_CNT)) { + rte_panic("Used descs cross block boundary\n"); + } + + txq->wr_p = D_IDX(txq, txq->wr_p + used_descs); + if (txq->wr_p % NFDK_TX_DESC_BLOCK_CNT) + txq->data_pending += temp_pkt->pkt_len; + else + txq->data_pending = 0; + + issued_descs += used_descs; + npkts++; + free_descs = (uint16_t)nfp_net_nfdk_free_tx_desc(txq); + } + +xmit_end: + /* Increment write pointers. Force memory write before we let HW know */ + rte_wmb(); + nfp_qcp_ptr_add(txq->qcp_q, NFP_QCP_WRITE_PTR, issued_descs); + + return npkts; +} diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h index ba8ffbd1ff..5c005d74e7 100644 --- a/drivers/net/nfp/nfp_rxtx.h +++ b/drivers/net/nfp/nfp_rxtx.h @@ -352,6 +352,9 @@ int nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev, uint16_t nb_desc, unsigned int socket_id, const struct rte_eth_txconf *tx_conf); +uint16_t nfp_net_nfdk_xmit_pkts(void *tx_queue, + struct rte_mbuf **tx_pkts, + uint16_t nb_pkts); #endif /* _NFP_RXTX_H_ */ /* -- 2.27.0