From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F88AC2BA2B for ; Sat, 11 Apr 2020 14:17:59 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id E77F6206F7 for ; Sat, 11 Apr 2020 14:17:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=marvell.com header.i=@marvell.com header.b="CLuLTQ7A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E77F6206F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=marvell.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 10C071C2ED; Sat, 11 Apr 2020 16:15:43 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id D6FA21C2DB for ; Sat, 11 Apr 2020 16:15:39 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03BEFbm5021902; Sat, 11 Apr 2020 07:15:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=cm78KWBDCnx41qdKD7pNmZvQmFS4Tjah0evugwZm40k=; b=CLuLTQ7A6amsE5sNwdosEf9pmrHyIzEBz5dylsJEaGpAhZDemeYIXCpt8xwXXes0wSSV 8OeAkzIj8W5eLc3ytZAPqq+FDq5VUAORqvO8Am9R1gmLCiFEZuIW4mJTd32/DzM3EWMV 9SMHUnJ4gZ56w01D1MOJYhZVwdpXzRPzjyDaQCGlFcX+y45/Lm1Yt0DkjaPXmkgaNvL8 ogQ7fytR1FAotecJmC7XqBBg2fjFS6Hij2FnEDYWfTS8Eup4UujWUlpghv3/qPK1zgbb SAl6Dyt4KD9gzsqr5VZTFpC5AEEMSN8HBjHiO2opHtp677CpBeG4LerZXhOnheYb63UB Jw== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0a-0016f401.pphosted.com with ESMTP id 30bb8q8n67-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 11 Apr 2020 07:15:38 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 11 Apr 2020 07:15:35 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 11 Apr 2020 07:15:35 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 8ED6F3F7040; Sat, 11 Apr 2020 07:15:32 -0700 (PDT) From: To: Nithin Dabilpuram , Pavan Nikhilesh CC: , , , , , , , Date: Sat, 11 Apr 2020 19:44:16 +0530 Message-ID: <20200411141428.1987768-18-jerinj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200411141428.1987768-1-jerinj@marvell.com> References: <20200405085613.1336841-1-jerinj@marvell.com> <20200411141428.1987768-1-jerinj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-11_04:2020-04-09, 2020-04-11 signatures=0 Subject: [dpdk-dev] [PATCH v5 17/29] node: add ethdev Tx node X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" From: Nithin Dabilpuram Add rte_node ethdev_tx process function and register it to graph infra. This node has a specific (port, tx-queue) as context and it enqueue's all the packets received to that specific queue pair. When rte_eth_tx_burst() i.e enqueue to queue pair fails, packets are forwarded to pkt_drop node to be free'd. Signed-off-by: Nithin Dabilpuram Signed-off-by: Pavan Nikhilesh Signed-off-by: Kiran Kumar K --- lib/librte_node/Makefile | 3 +- lib/librte_node/ethdev_tx.c | 86 ++++++++++++++++++++++++++++++++ lib/librte_node/ethdev_tx_priv.h | 62 +++++++++++++++++++++++ lib/librte_node/meson.build | 4 +- 4 files changed, 152 insertions(+), 3 deletions(-) create mode 100644 lib/librte_node/ethdev_tx.c create mode 100644 lib/librte_node/ethdev_tx_priv.h diff --git a/lib/librte_node/Makefile b/lib/librte_node/Makefile index 314149385..7428f6c43 100644 --- a/lib/librte_node/Makefile +++ b/lib/librte_node/Makefile @@ -11,7 +11,7 @@ CFLAGS += -O3 -DALLOW_EXPERIMENTAL_API CFLAGS += $(WERROR_FLAGS) # Strict-aliasing rules are violated by uint8_t[] to context size casts. CFLAGS += -fno-strict-aliasing -LDLIBS += -lrte_eal -lrte_graph -lrte_ethdev +LDLIBS += -lrte_eal -lrte_graph -lrte_mbuf -lrte_ethdev EXPORT_MAP := rte_node_version.map @@ -19,5 +19,6 @@ EXPORT_MAP := rte_node_version.map SRCS-$(CONFIG_RTE_LIBRTE_NODE) += null.c SRCS-$(CONFIG_RTE_LIBRTE_NODE) += log.c SRCS-$(CONFIG_RTE_LIBRTE_NODE) += ethdev_rx.c +SRCS-$(CONFIG_RTE_LIBRTE_NODE) += ethdev_tx.c include $(RTE_SDK)/mk/rte.lib.mk diff --git a/lib/librte_node/ethdev_tx.c b/lib/librte_node/ethdev_tx.c new file mode 100644 index 000000000..075149089 --- /dev/null +++ b/lib/librte_node/ethdev_tx.c @@ -0,0 +1,86 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2020 Marvell International Ltd. + */ + +#include +#include +#include +#include +#include + +#include "ethdev_tx_priv.h" + +static struct ethdev_tx_node_main ethdev_tx_main; + +static uint16_t +ethdev_tx_node_process(struct rte_graph *graph, struct rte_node *node, + void **objs, uint16_t nb_objs) +{ + ethdev_tx_node_ctx_t *ctx = (ethdev_tx_node_ctx_t *)node->ctx; + uint16_t port, queue; + uint16_t count; + + /* Get Tx port id */ + port = ctx->port; + queue = ctx->queue; + + count = rte_eth_tx_burst(port, queue, (struct rte_mbuf **)objs, + nb_objs); + + /* Redirect unsent pkts to drop node */ + if (count != nb_objs) { + rte_node_enqueue(graph, node, ETHDEV_TX_NEXT_PKT_DROP, + &objs[count], nb_objs - count); + } + + return count; +} + +static int +ethdev_tx_node_init(const struct rte_graph *graph, struct rte_node *node) +{ + ethdev_tx_node_ctx_t *ctx = (ethdev_tx_node_ctx_t *)node->ctx; + uint64_t port_id = RTE_MAX_ETHPORTS; + int i; + + /* Find our port id */ + for (i = 0; i < RTE_MAX_ETHPORTS; i++) { + if (ethdev_tx_main.nodes[i] == node->id) { + port_id = i; + break; + } + } + RTE_VERIFY(port_id < RTE_MAX_ETHPORTS); + + /* Update port and queue */ + ctx->port = port_id; + ctx->queue = graph->id; + + return 0; +} + +struct ethdev_tx_node_main * +ethdev_tx_node_data_get(void) +{ + return ðdev_tx_main; +} + +static struct rte_node_register ethdev_tx_node_base = { + .process = ethdev_tx_node_process, + .name = "ethdev_tx", + + .init = ethdev_tx_node_init, + + .nb_edges = ETHDEV_TX_NEXT_MAX, + .next_nodes = { + [ETHDEV_TX_NEXT_PKT_DROP] = "pkt_drop", + }, +}; + +struct rte_node_register * +ethdev_tx_node_get(void) +{ + return ðdev_tx_node_base; +} + +RTE_NODE_REGISTER(ethdev_tx_node_base); diff --git a/lib/librte_node/ethdev_tx_priv.h b/lib/librte_node/ethdev_tx_priv.h new file mode 100644 index 000000000..586bff44a --- /dev/null +++ b/lib/librte_node/ethdev_tx_priv.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2020 Marvell International Ltd. + */ +#ifndef __INCLUDE_ETHDEV_TX_PRIV_H__ +#define __INCLUDE_ETHDEV_TX_PRIV_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +struct ethdev_tx_node_ctx; +typedef struct ethdev_tx_node_ctx ethdev_tx_node_ctx_t; + +enum ethdev_tx_next_nodes { + ETHDEV_TX_NEXT_PKT_DROP, + ETHDEV_TX_NEXT_MAX, +}; + +/** + * @internal + * + * Ethernet Tx node context structure. + */ +struct ethdev_tx_node_ctx { + uint16_t port; /**< Port identifier of the Ethernet Tx node. */ + uint16_t queue; /**< Queue identifier of the Ethernet Tx node. */ +}; + +/** + * @internal + * + * Ethernet Tx node main structure. + */ +struct ethdev_tx_node_main { + uint32_t nodes[RTE_MAX_ETHPORTS]; /**< Tx nodes for each ethdev port. */ +}; + +/** + * @internal + * + * Get the Ethernet Tx node data. + * + * @return + * Pointer to Ethernet Tx node data. + */ +struct ethdev_tx_node_main *ethdev_tx_node_data_get(void); + +/** + * @internal + * + * Get the Ethernet Tx node. + * + * @retrun + * Pointer to the Ethernet Tx node. + */ +struct rte_node_register *ethdev_tx_node_get(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __INCLUDE_ETHDEV_TX_PRIV_H__ */ diff --git a/lib/librte_node/meson.build b/lib/librte_node/meson.build index 94caa6c23..505c76abd 100644 --- a/lib/librte_node/meson.build +++ b/lib/librte_node/meson.build @@ -1,8 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(C) 2020 Marvell International Ltd. -sources = files('null.c', 'log.c', 'ethdev_rx.c') +sources = files('null.c', 'log.c', 'ethdev_rx.c', 'ethdev_tx.c') allow_experimental_apis = true # Strict-aliasing rules are violated by uint8_t[] to context size casts. cflags += '-fno-strict-aliasing' -deps += ['graph', 'ethdev'] +deps += ['graph', 'mbuf', 'ethdev'] -- 2.25.1