From patchwork Wed Feb 24 12:42:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 386843 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp342014jap; Wed, 24 Feb 2021 04:44:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJydQZRwEV2vDsOGSFePlpdi4tijSqHSbg1yRqSDySGpxNQdIcZ4LnRbLGiTubt4CJz46Wgx X-Received: by 2002:a05:6402:1594:: with SMTP id c20mr11574038edv.92.1614170648828; Wed, 24 Feb 2021 04:44:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614170648; cv=none; d=google.com; s=arc-20160816; b=BZPTPixwU/+DqJrrelTyOxNBcbS/TxMHbjcK3cEakE79MRko1VYiiMJaKmy+AXi31J 2ELWNIyYY08oNIV3e0cyphkkpP/nOMB0dZgWOkuWu76fF7fqy5hDcv2SlqdjOU4FbSli RrDSB/5mKnJsZRDaAIYqvunQAzHms6KZdDErw45QTfmH16g/MISk756V7Q/l8GfA3VWP WqGjGMYXGrgt0012dyfgmN06pVgnGtSoomvsEfIyUQ4sJ2I34zKdZDzsNf1Wpmjf0V1G 3Gq4S7UJA/sowkxjQDo4glH1T/xED4XU7nh3ra+2dtYlOMNil7pKwrE9yslYiViOojpp TBxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:cc:to:from; bh=e+lfUbqlx7Zkpmnxw+ryP68fOkzACYyXy1CBFMFB1eI=; b=a3cEQXujxH6KyQS5WLeZIBqYqcgGJR5fEkJaayl9VkxCXnzOCrvntZBM4pUIF9lp08 SCAv7luEmiv7q+okE41Po4C736fU/lfV5Rl5zLk5/t9l+uswqdgdq6xcfpOCS7KEoVuk Ij7Ea6MmF4kkJVcRSZOi62Z9WgEg9HuGnv0vrkImRkGkEbzf3i5KbxEvzwnm4CfL3Tvx 1amqnvokvh28Vc7HJlin2eg1pCYYn0hT3D/wygrQ5PKIpDYSi0EggAhhaEzMl6wQThGP I+YPNqko0GgVHUl1EMLHn7L+S4kJ5TFR8lhpnp6wnwg4Ibz0kjPuNYdFjeU9eQdZMPgO ctUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from mails.dpdk.org (mails.dpdk.org. [217.70.189.124]) by mx.google.com with ESMTP id g7si1165086edj.528.2021.02.24.04.44.08; Wed, 24 Feb 2021 04:44:08 -0800 (PST) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) client-ip=217.70.189.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8FA1C16085C; Wed, 24 Feb 2021 13:43:29 +0100 (CET) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by mails.dpdk.org (Postfix) with ESMTP id 9F77E160841 for ; Wed, 24 Feb 2021 13:43:23 +0100 (CET) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 766401A039E; Wed, 24 Feb 2021 13:43:23 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 2A5631A0391; Wed, 24 Feb 2021 13:43:21 +0100 (CET) Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 1F902402D6; Wed, 24 Feb 2021 13:43:18 +0100 (CET) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Hemant Agrawal Date: Wed, 24 Feb 2021 18:12:55 +0530 Message-Id: <20210224124311.29799-8-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210224124311.29799-1-hemant.agrawal@nxp.com> References: <20210211141620.12482-1-hemant.agrawal@nxp.com> <20210224124311.29799-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v3 07/23] net/dpaa: support external buffers in Tx 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 Sender: "dev" This patch support tx of external buffers Signed-off-by: Hemant Agrawal --- drivers/net/dpaa/dpaa_rxtx.c | 39 +++++++++++++++++++++++++++--------- drivers/net/dpaa/dpaa_rxtx.h | 8 +------- 2 files changed, 31 insertions(+), 16 deletions(-) -- 2.17.1 diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c index e38fba23c0..423de40e95 100644 --- a/drivers/net/dpaa/dpaa_rxtx.c +++ b/drivers/net/dpaa/dpaa_rxtx.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * * Copyright 2016 Freescale Semiconductor, Inc. All rights reserved. - * Copyright 2017,2019 NXP + * Copyright 2017,2019-2021 NXP * */ @@ -334,7 +334,7 @@ dpaa_unsegmented_checksum(struct rte_mbuf *mbuf, struct qm_fd *fd_arr) } } -struct rte_mbuf * +static struct rte_mbuf * dpaa_eth_sg_to_mbuf(const struct qm_fd *fd, uint32_t ifid) { struct dpaa_bp_info *bp_info = DPAA_BPID_TO_POOL_INFO(fd->bpid); @@ -791,13 +791,12 @@ uint16_t dpaa_eth_queue_rx(void *q, return num_rx; } -int +static int dpaa_eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf, struct qm_fd *fd, - uint32_t bpid) + struct dpaa_bp_info *bp_info) { struct rte_mbuf *cur_seg = mbuf, *prev_seg = NULL; - struct dpaa_bp_info *bp_info = DPAA_BPID_TO_POOL_INFO(bpid); struct rte_mbuf *temp, *mi; struct qm_sg_entry *sg_temp, *sgt; int i = 0; @@ -840,7 +839,7 @@ dpaa_eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf, fd->format = QM_FD_SG; fd->addr = temp->buf_iova; fd->offset = temp->data_off; - fd->bpid = bpid; + fd->bpid = bp_info ? bp_info->bpid : 0xff; fd->length20 = mbuf->pkt_len; while (i < DPAA_SGT_MAX_ENTRIES) { @@ -862,6 +861,9 @@ dpaa_eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf, DPAA_MEMPOOL_TO_BPID(cur_seg->pool); } cur_seg = cur_seg->next; + } else if (RTE_MBUF_HAS_EXTBUF(cur_seg)) { + sg_temp->bpid = 0xff; + cur_seg = cur_seg->next; } else { /* Get owner MBUF from indirect buffer */ mi = rte_mbuf_from_indirect(cur_seg); @@ -911,6 +913,9 @@ tx_on_dpaa_pool_unsegmented(struct rte_mbuf *mbuf, */ DPAA_MBUF_TO_CONTIG_FD(mbuf, fd_arr, bp_info->bpid); } + } else if (RTE_MBUF_HAS_EXTBUF(mbuf)) { + DPAA_MBUF_TO_CONTIG_FD(mbuf, fd_arr, + bp_info ? bp_info->bpid : 0xff); } else { /* This is data-containing core mbuf: 'mi' */ mi = rte_mbuf_from_indirect(mbuf); @@ -929,7 +934,8 @@ tx_on_dpaa_pool_unsegmented(struct rte_mbuf *mbuf, * been released by BMAN. */ rte_mbuf_refcnt_update(mi, 1); - DPAA_MBUF_TO_CONTIG_FD(mbuf, fd_arr, bp_info->bpid); + DPAA_MBUF_TO_CONTIG_FD(mbuf, fd_arr, + bp_info ? bp_info->bpid : 0xff); } rte_pktmbuf_free(mbuf); } @@ -951,7 +957,7 @@ tx_on_dpaa_pool(struct rte_mbuf *mbuf, tx_on_dpaa_pool_unsegmented(mbuf, bp_info, fd_arr); } else if (mbuf->nb_segs > 1 && mbuf->nb_segs <= DPAA_SGT_MAX_ENTRIES) { - if (dpaa_eth_mbuf_to_sg_fd(mbuf, fd_arr, bp_info->bpid)) { + if (dpaa_eth_mbuf_to_sg_fd(mbuf, fd_arr, bp_info)) { DPAA_PMD_DEBUG("Unable to create Scatter Gather FD"); return 1; } @@ -1055,6 +1061,7 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) uint16_t state; int ret, realloc_mbuf = 0; uint32_t seqn, index, flags[DPAA_TX_BURST_SIZE] = {0}; + struct rte_mbuf **orig_bufs = bufs; if (unlikely(!DPAA_PER_LCORE_PORTAL)) { ret = rte_dpaa_portal_init((void *)0); @@ -1112,6 +1119,11 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) mp = mi->pool; } + if (unlikely(RTE_MBUF_HAS_EXTBUF(mbuf))) { + bp_info = NULL; + goto indirect_buf; + } + bp_info = DPAA_MEMPOOL_TO_POOL_INFO(mp); if (unlikely(mp->ops_index != bp_info->dpaa_ops_index || realloc_mbuf == 1)) { @@ -1130,7 +1142,7 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) mbuf = temp_mbuf; realloc_mbuf = 0; } - +indirect_buf: state = tx_on_dpaa_pool(mbuf, bp_info, &fd_arr[loop]); if (unlikely(state)) { @@ -1157,6 +1169,15 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) DPAA_DP_LOG(DEBUG, "Transmitted %d buffers on queue: %p", sent, q); + + loop = 0; + while (loop < sent) { + if (unlikely(RTE_MBUF_HAS_EXTBUF(*orig_bufs))) + rte_pktmbuf_free(*orig_bufs); + orig_bufs++; + loop++; + } + return sent; } diff --git a/drivers/net/dpaa/dpaa_rxtx.h b/drivers/net/dpaa/dpaa_rxtx.h index d9d7e04f5c..99e09196e9 100644 --- a/drivers/net/dpaa/dpaa_rxtx.h +++ b/drivers/net/dpaa/dpaa_rxtx.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * * Copyright 2016 Freescale Semiconductor, Inc. All rights reserved. - * Copyright 2017,2020 NXP + * Copyright 2017,2020-2021 NXP * */ @@ -279,12 +279,6 @@ uint16_t dpaa_eth_tx_drop_all(void *q __rte_unused, struct rte_mbuf **bufs __rte_unused, uint16_t nb_bufs __rte_unused); -struct rte_mbuf *dpaa_eth_sg_to_mbuf(const struct qm_fd *fd, uint32_t ifid); - -int dpaa_eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf, - struct qm_fd *fd, - uint32_t bpid); - uint16_t dpaa_free_mbuf(const struct qm_fd *fd); void dpaa_rx_cb(struct qman_fq **fq, struct qm_dqrr_entry **dqrr, void **bufs, int num_bufs);