From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1EC6FA0577; Sun, 5 Apr 2020 11:00:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 33C411C0CE; Sun, 5 Apr 2020 10:57:25 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id B83671BEE3 for ; Sun, 5 Apr 2020 10:57:23 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0358goxk019798; Sun, 5 Apr 2020 01:57:22 -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=WvgZ0Y/P4rxi0ULjl61HEgsJgl5ePRX3iFa3Dhqs3gs=; b=EZ/fbPzWkp0TYBWHlOJIrFWIQhwL5yolNEvd6m7sc2z2uU0PPiupmtjBk+e4SQQxPDdE 1tOTCmkMYq6nST0otyNiJVNKPqBW1dxoSzRsV3rS8ix6tgpG0N+1u72IA1RuaiygXhbn qr/KAlYrscHwkgNH+o+buQa6fc4uy15GnT3n7sUm/pnMgpWRG7jBXyduo2qWsZpnHiai ekVJhmEW2Xe49daoMDvizl6N68SW7Z4vLo/AoGpHU5fo7EcILTDrXPZVNsuYjYdi9jJL lm1ixdXM9VQ51TKwqvcoBPp40b6GMKnjvzC/tNegL6qRvrxM1ELNZdLPpmQnVH4dPRTu og== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 306srm29vu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 05 Apr 2020 01:57:22 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 5 Apr 2020 01:57:19 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sun, 5 Apr 2020 01:57:20 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id A73193F7040; Sun, 5 Apr 2020 01:57:16 -0700 (PDT) From: To: John McNamara , Marko Kovacevic , Nithin Dabilpuram , Pavan Nikhilesh CC: , , , , , , Date: Sun, 5 Apr 2020 14:26:02 +0530 Message-ID: <20200405085613.1336841-19-jerinj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200405085613.1336841-1-jerinj@marvell.com> References: <20200331192945.2466880-1-jerinj@marvell.com> <20200405085613.1336841-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-04_19:2020-04-03, 2020-04-04 signatures=0 Subject: [dpdk-dev] [PATCH v4 18/29] node: add ethdev Rx and Tx node ctrl API 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 ctrl api to setup ethdev_rx and ethdev_tx node. This ctrl api clones 'N' number of ethdev_rx and ethdev_tx nodes with specific (port, queue) pairs updated in their context. All the ethdev ports and queues are setup before this api is called. Signed-off-by: Nithin Dabilpuram Signed-off-by: Pavan Nikhilesh Signed-off-by: Kiran Kumar K --- doc/api/doxy-api-index.md | 2 + lib/librte_node/Makefile | 6 +- lib/librte_node/ethdev_ctrl.c | 100 +++++++++++++++++++++++++++ lib/librte_node/meson.build | 5 +- lib/librte_node/node_private.h | 74 ++++++++++++++++++++ lib/librte_node/rte_node_eth_api.h | 70 +++++++++++++++++++ lib/librte_node/rte_node_version.map | 1 + 7 files changed, 255 insertions(+), 3 deletions(-) create mode 100644 lib/librte_node/ethdev_ctrl.c create mode 100644 lib/librte_node/rte_node_eth_api.h diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md index fd2ff64d7..1784674df 100644 --- a/doc/api/doxy-api-index.md +++ b/doc/api/doxy-api-index.md @@ -161,6 +161,8 @@ The public API headers are grouped by topics: [table_action] (@ref rte_table_action.h) * [graph] (@ref rte_graph.h): [graph_worker] (@ref rte_graph_worker.h) + * graph_nodes: + [eth_node] (@ref rte_node_eth_api.h), - **basic**: [approx fraction] (@ref rte_approx.h), diff --git a/lib/librte_node/Makefile b/lib/librte_node/Makefile index 7428f6c43..ea5fa77f7 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_mbuf -lrte_ethdev +LDLIBS += -lrte_eal -lrte_graph -lrte_mbuf -lrte_ethdev -lrte_mempool EXPORT_MAP := rte_node_version.map @@ -20,5 +20,9 @@ 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 +SRCS-$(CONFIG_RTE_LIBRTE_NODE) += ethdev_ctrl.c + +# install header files +SYMLINK-$(CONFIG_RTE_LIBRTE_NODE)-include += rte_node_eth_api.h include $(RTE_SDK)/mk/rte.lib.mk diff --git a/lib/librte_node/ethdev_ctrl.c b/lib/librte_node/ethdev_ctrl.c new file mode 100644 index 000000000..b2ac5e2c4 --- /dev/null +++ b/lib/librte_node/ethdev_ctrl.c @@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2020 Marvell International Ltd. + */ + +#include +#include +#include +#include + +#include "rte_node_eth_api.h" + +#include "ethdev_rx_priv.h" +#include "ethdev_tx_priv.h" +#include "node_private.h" + +static struct ethdev_ctrl { + uint16_t nb_graphs; +} ctrl; + +int +rte_node_eth_config(struct rte_node_ethdev_config *conf, uint16_t nb_confs, + uint16_t nb_graphs) +{ + struct ethdev_tx_node_main *tx_node_data; + uint16_t tx_q_used, rx_q_used, port_id; + struct rte_node_register *tx_node; + char name[RTE_NODE_NAMESIZE]; + struct rte_mempool *mp; + uint32_t id; + int i, j; + + tx_node_data = ethdev_tx_node_data_get(); + tx_node = ethdev_tx_node_get(); + for (i = 0; i < nb_confs; i++) { + port_id = conf[i].port_id; + + if (!rte_eth_dev_is_valid_port(port_id)) + return -EINVAL; + + /* Check for mbuf minimum private size requirement */ + for (j = 0; j < conf[i].mp_count; j++) { + mp = conf[i].mp[j]; + if (!mp) + continue; + /* Check for minimum private space */ + if (rte_pktmbuf_priv_size(mp) < + RTE_NODE_MBUF_PRIV2_SIZE) { + node_err("ethdev", + "Minimum mbuf priv size requirement not met by mp %s", + mp->name); + return -EINVAL; + } + } + + rx_q_used = conf[i].num_rx_queues; + tx_q_used = conf[i].num_tx_queues; + /* Check if we have a txq for each worker */ + if (tx_q_used < nb_graphs) + return -EINVAL; + + /* Create node for each rx port queue pair */ + for (j = 0; j < rx_q_used; j++) { + struct ethdev_rx_node_main *rx_node_data; + struct rte_node_register *rx_node; + ethdev_rx_node_elem_t *elem; + + rx_node_data = ethdev_rx_get_node_data_get(); + rx_node = ethdev_rx_node_get(); + snprintf(name, sizeof(name), "%u-%u", port_id, j); + /* Clone a new rx node with same edges as parent */ + id = rte_node_clone(rx_node->id, name); + if (id == RTE_NODE_ID_INVALID) + return -EIO; + + /* Add it to list of ethdev rx nodes for lookup */ + elem = malloc(sizeof(ethdev_rx_node_elem_t)); + memset(elem, 0, sizeof(ethdev_rx_node_elem_t)); + elem->ctx.port_id = port_id; + elem->ctx.queue_id = j; + elem->nid = id; + elem->next = rx_node_data->head; + rx_node_data->head = elem; + + node_dbg("ethdev", "Rx node %s-%s: is at %u", + rx_node->name, name, id); + } + + /* Create a per port tx node from base node */ + snprintf(name, sizeof(name), "%u", port_id); + /* Clone a new node with same edges as parent */ + id = rte_node_clone(tx_node->id, name); + tx_node_data->nodes[port_id] = id; + + node_dbg("ethdev", "Tx node %s-%s: is at %u", tx_node->name, + name, id); + } + + ctrl.nb_graphs = nb_graphs; + return 0; +} diff --git a/lib/librte_node/meson.build b/lib/librte_node/meson.build index 505c76abd..af2eb2d91 100644 --- a/lib/librte_node/meson.build +++ b/lib/librte_node/meson.build @@ -1,8 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(C) 2020 Marvell International Ltd. -sources = files('null.c', 'log.c', 'ethdev_rx.c', 'ethdev_tx.c') +sources = files('null.c', 'log.c', 'ethdev_rx.c', 'ethdev_tx.c', 'ethdev_ctrl.c') +headers = files('rte_node_eth_api.h') allow_experimental_apis = true # Strict-aliasing rules are violated by uint8_t[] to context size casts. cflags += '-fno-strict-aliasing' -deps += ['graph', 'mbuf', 'ethdev'] +deps += ['graph', 'mbuf', 'lpm', 'ethdev', 'mempool', 'cryptodev'] diff --git a/lib/librte_node/node_private.h b/lib/librte_node/node_private.h index f30902a94..141448546 100644 --- a/lib/librte_node/node_private.h +++ b/lib/librte_node/node_private.h @@ -6,7 +6,9 @@ #define __NODE_PRIVATE_H__ #include +#include #include +#include extern int rte_node_logtype; #define NODE_LOG(level, node_name, ...) \ @@ -19,4 +21,76 @@ extern int rte_node_logtype; #define node_info(node_name, ...) NODE_LOG(INFO, node_name, __VA_ARGS__) #define node_dbg(node_name, ...) NODE_LOG(DEBUG, node_name, __VA_ARGS__) +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Node mbuf private data to store next hop, ttl and checksum. + */ +struct rte_node_mbuf_priv1 { + union { + /* IP4 rewrite */ + struct { + uint16_t nh; + uint16_t ttl; + uint32_t cksum; + }; + + uint64_t u; + }; +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Node mbuf private data to store crypto operation. + */ +struct rte_node_mbuf_priv2 { + union { + /* Sym crypto */ + struct { + struct rte_crypto_op op; + }; + }; +} __rte_cache_aligned; + +#define RTE_NODE_MBUF_PRIV2_SIZE sizeof(struct rte_node_mbuf_priv2) + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Get mbuf_priv1 pointer from rte_mbuf. + * + * @param + * Pointer to the rte_mbuf. + * + * @return + * Pointer to the mbuf_priv1. + */ +static __rte_always_inline struct rte_node_mbuf_priv1 * +rte_node_mbuf_priv1(struct rte_mbuf *m) +{ + return (struct rte_node_mbuf_priv1 *)&m->udata64; +} + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Get mbuf_priv2 pointer from rte_mbuf. + * + * @param + * Pointer to the rte_mbuf. + * + * @return + * Pointer to the mbuf_priv2. + */ +static __rte_always_inline struct rte_node_mbuf_priv2 * +rte_node_mbuf_priv2(struct rte_mbuf *m) +{ + return (struct rte_node_mbuf_priv2 *)rte_mbuf_to_priv(m); +} + #endif /* __NODE_PRIVATE_H__ */ diff --git a/lib/librte_node/rte_node_eth_api.h b/lib/librte_node/rte_node_eth_api.h new file mode 100644 index 000000000..39b31b45b --- /dev/null +++ b/lib/librte_node/rte_node_eth_api.h @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2020 Marvell International Ltd. + */ + +#ifndef __INCLUDE_RTE_NODE_ETH_API_H__ +#define __INCLUDE_RTE_NODE_ETH_API_H__ + +/** + * @file rte_node_eth_api.h + * + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * This API allows to setup ethdev_rx and ethdev_tx nodes + * and its queue associations. + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Port config for ethdev_rx and ethdev_tx node. + */ +struct rte_node_ethdev_config { + uint16_t port_id; + /**< Port identifier */ + uint16_t num_rx_queues; + /**< Number of Rx queues. */ + uint16_t num_tx_queues; + /**< Number of Tx queues. */ + struct rte_mempool **mp; + /**< Array of mempools associated to Rx queue. */ + uint16_t mp_count; + /**< Size of mp array. */ +}; + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Initializes ethdev nodes. + * + * @param cfg + * Array of ethdev config that identifies which port's + * ethdev_rx and ethdev_tx nodes need to be created + * and queue association. + * @param cnt + * Size of cfg array. + * @param nb_graphs + * Number of graphs that will be used. + * + * @return + * 0 on successful initialization, negative otherwise. + */ +__rte_experimental +int rte_node_eth_config(struct rte_node_ethdev_config *cfg, + uint16_t cnt, uint16_t nb_graphs); +#ifdef __cplusplus +} +#endif + +#endif /* __INCLUDE_RTE_NODE_ETH_API_H__ */ diff --git a/lib/librte_node/rte_node_version.map b/lib/librte_node/rte_node_version.map index f87163bb9..c6c71bd02 100644 --- a/lib/librte_node/rte_node_version.map +++ b/lib/librte_node/rte_node_version.map @@ -1,6 +1,7 @@ EXPERIMENTAL { global: + rte_node_eth_config; rte_node_logtype; local: *; }; -- 2.25.1