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 33906A0548; Thu, 2 Jun 2022 03:55:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BF5E242B93; Thu, 2 Jun 2022 03:55:10 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2107.outbound.protection.outlook.com [40.107.223.107]) by mails.dpdk.org (Postfix) with ESMTP id 3DA4F42B96 for ; Thu, 2 Jun 2022 03:55:09 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jfKtHvUzIkYNhVcAetfB5WXB73Ivsu/qNQshxbYrTNTc/5NwpRS8Uqlh6uRSkBNA/gJyQT3RFKIWQs8UJ5fwe4arMzCpCPxw4J71yyZbNORVeQoYPlQBM0H2vOKvnuMomqeKe5ijHtYcQB2AMjDN1WeVtJH0Bg+431UFew3J+fh6cOGFGHvmME2uw2FNvjjGFdMcridI4iemHh3V3Jfi9yPZ34V2YkIa341F0GNzuyPFsKoxRpl6vK7ufmQ+IojZQCQxiCicoxAqT9qyIeX72dz5oZANNi6lFK4ccvytLD1K4nadCuqk+2E7nVPojR7dDtfH2O/+f4lvVr8ViZYRNA== 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=tNM/vXhqVcKJmzEiLs/zu9TlQd9swaxZROCdzVl9Jog=; b=VThrJh9PLtJzaYH3SUmkmXUK6N7E7W6f5HZdhBuUfXn4bE1mJDLyMVCTd3y4QWVrH4wvyWiCUdEP9M999GUQfou/+F/rAMwnndBgO8PGx4SSLxCY2PTNrQJqRvCpaVaLeU89MgZB+8I5wOZFJd42N8CoU2qPr8n8NEvPqsopczbOy0GLTNVF6u7GNc4mqZ3rdD96Z7PNpuoDMlwNCHJxCwk7HOnklUwv/Z7S6ltrNZ06W5VPvpBHG7d36V4dsdVEUroB8v3iXh1Kuz69RDzXWTa/CD10Ey0/4D43hLV9qqZh3eqZBMmehm8md/D/b1w9EHmSyZjZewsckalamF+pSQ== 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=tNM/vXhqVcKJmzEiLs/zu9TlQd9swaxZROCdzVl9Jog=; b=QPVihhDIOvLCl8q8nyfh/pyJWWmv4uG8scqui5EWLHMTp+Ng2R7A8qi3OyoGrk8yzk7tLmIZfi5KYknyNYnE8eo6mOgXTwVgPHwDbbIuHcRMmOJ8qD7ztKnFaSK5DEdnENEyOcnynCIbz4LThBIl/EXsj5uedmC6k8+BhCUCmEA= 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 DM4PR13MB5858.namprd13.prod.outlook.com (2603:10b6:8:46::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.11; Thu, 2 Jun 2022 01:55:08 +0000 Received: from DM6PR13MB3004.namprd13.prod.outlook.com ([fe80::d902:ed7d:82bb:c753]) by DM6PR13MB3004.namprd13.prod.outlook.com ([fe80::d902:ed7d:82bb:c753%4]) with mapi id 15.20.5314.013; Thu, 2 Jun 2022 01:55:08 +0000 From: Jin Liu To: dev@dpdk.org Cc: niklas.soderlund@corigine.com, Jin Liu , Diana Wang , Peng Zhang , Chaoyong He Subject: [PATCH 13/14] net/nfp: nfdk packet xmit function Date: Thu, 2 Jun 2022 03:53:03 +0200 Message-Id: <20220602015304.710197-14-jin.liu@corigine.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220602015304.710197-1-jin.liu@corigine.com> References: <20220602015304.710197-1-jin.liu@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P123CA0457.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1aa::12) 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: 53a60b0c-031d-41a8-5f91-08da443aeb89 X-MS-TrafficTypeDiagnostic: DM4PR13MB5858: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: ihK6jkIFhuL+EbkKSK64ztbBoXtyiprDQJa1/BSgsyMs57hzNZIASeDqtoRSFdIkQZm+KJtcOyD08cl949unw/nVfi9BsV4tMPhEk55ctD8YtJjfA2BMc7u0ivdGTdzHNBhD6OkXL6hlMrmzzmGLckRYgZXzjWN+38ghbHgkITkwDC9smmM8eE+xgVeSV2KjAjJ7/2pm6zz0DYvcIx7Kfpb2g/wTVs+Tsu1gXM1jUsejfM+iLr5RePoDLzFCMC0GKnq+E2B6Hfbz7xILRn70AmYjSKiDolIhFDjTm0/v0c6hm+0wQD8c2ByJkSbDUUCOzzKg5QWfOPXvLaJmUTCy39bGRxXOXE2lyqWmvGJKXqGd9SGUYzJ1VDv+pr6d/0viO/gnPL8exh4FGp3FIiaCOa1DFZ32IEeZJZa/bc/WkesOUeMFaR+qw54UtNv74Xnym1dLz896jPpTgGHLXBpVzeaORQvWQn3w2kq0BA361KBCBvyMZUPi7VrGNBvgYuC7iL9f3E0P8NbLEIsO+UwPcL04pP0QQg1Z/++nT4MoDqBXPSq9sE3ernTXbCCmiqlxVVQarNaVoHPaeKjm/3PCV1HJC83slaTTLlU63MON+dTPAARJp4tQYU53Svl497iCNyVJZ+DMPapjR0lIyqqET8aCg7wgWEJg6QezIRY+w1qTAb3oj/Hczyk7hE+TgjrNWmIKdpzAiDnuz2Yf5WXG7Q== 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:(13230001)(4636009)(346002)(366004)(396003)(136003)(376002)(39840400004)(36756003)(186003)(66574015)(83380400001)(30864003)(5660300002)(4326008)(44832011)(8936002)(2906002)(6916009)(54906003)(1076003)(107886003)(6506007)(316002)(2616005)(41300700001)(8676002)(66946007)(66476007)(6666004)(66556008)(26005)(6512007)(52116002)(38100700002)(38350700002)(86362001)(6486002)(508600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?L3hYa2xRRzNSNHFZMGZmMkd4bG55UFU3ZHdyRWVrUE9GOUZOWXV2YmF1OUxr?= =?utf-8?B?ckJ5Yi9ITTRjaW03OU9yeHR5UWxlanBqSUxNNHpESGd1MTYxVndWMldZbnF5?= =?utf-8?B?Sks0M3g3d0NHSXVkcnRISlM2VkxyY3FCamg3SitYWTdXSlZ2NmNZK3dlMWJX?= =?utf-8?B?eFBUNGlEZS9PSUxKdmxzZXlYd2xxSk14MkI3dnQxamJIUjhBcEllSGpISUlC?= =?utf-8?B?NGVuV3JtQm5XeTBRQmk0bXJZOS8veEFzTUZiVmx3eWdBbHNWdzU1bUNwQTNo?= =?utf-8?B?eHViWms1QmNFTzNvTFR6c1k5SUtkOHhoOUFyNTJad3Y2SDA1K1VvTnFXYU5l?= =?utf-8?B?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dO?= =?utf-8?B?Y0syZCsxYlByZVZiYi8ybFlqN1A1U3NKLzBLdUJkS3pRbEZLM2lzNktxV3gy?= =?utf-8?B?bFlHeFJ3YSt4ano5Z00rblRhL3RZenJPWGluU0JwSlNXUUpERG1BU1BYd2Za?= =?utf-8?B?a1JSK1B3M0ZobitDUmlwSmZkSTB5eFd5OVJKWUMvQlJHOW9Kc244Zz09?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53a60b0c-031d-41a8-5f91-08da443aeb89 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB3004.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2022 01:55:08.0224 (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: nhlXjMPkVwdfiTEPWu3lyTM6GZY6S30YJWrqBi+6bFEvFYezyPSAJ6vjnSy+lqVMHPcun3mQoLau0Cdw/4WaKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR13MB5858 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 NFDK firmware. 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 4e3a6a964d..238b2b5451 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -462,6 +462,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) { @@ -470,6 +471,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."); @@ -478,7 +480,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 a5c6aceb32..bb8206c4f6 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -365,6 +365,7 @@ nfp_netvf_init(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) { @@ -373,6 +374,7 @@ nfp_netvf_init(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."); @@ -381,7 +383,6 @@ nfp_netvf_init(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; /* For secondary processes, the primary has done all the work */ if (rte_eal_process_type() != RTE_PROC_PRIMARY) diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index bf5817db4b..fd3ee40aa5 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) @@ -1140,3 +1143,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->ktxbufs[i].mbuf) { + rte_pktmbuf_free_seg(txq->ktxbufs[i].mbuf); + txq->ktxbufs[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->ktxbufs[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->ktxbufs[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 cce3e0c0e5..e58127b66e 100644 --- a/drivers/net/nfp/nfp_rxtx.h +++ b/drivers/net/nfp/nfp_rxtx.h @@ -359,6 +359,9 @@ int nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev, const struct rte_eth_txconf *tx_conf); void nfp_net_nfdk_tx_queue_release(struct rte_eth_dev *dev, uint16_t queue_idx); void nfp_net_nfdk_reset_tx_queue(struct nfp_net_txq *txq); +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