From patchwork Fri Jun 2 16:22:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vamsi Krishna Attunuru X-Patchwork-Id: 127975 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0E70742C11; Fri, 2 Jun 2023 18:22:37 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DBD0242D35; Fri, 2 Jun 2023 18:22:33 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 81B1B42D31 for ; Fri, 2 Jun 2023 18:22:32 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 352A1oka026966; Fri, 2 Jun 2023 09:22:31 -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=pfpt0220; bh=JRW8tzjkBHECVW600jU0pTw+Sj6UocKuwurx/kJvo3k=; b=KqwozQG4wFMVdxOMEUGhaLPc9KWAgX+6NDBTcaZuiGZlXmF24Yswsd2iFRyF3+jGtflQ NdaV2drle+OYWsyn0UqJ2o0mgdP4LAB4XHegvtGFhzwWZFJIS7Z7nD2wwHt0jOPB+iMS 3bzKehvMuDL3zisIawjQr5jNRNrhD//pOoA7d0GmMCZR/LHgFr8eRKOenaJNycwd19B9 EuU9Ume/kc6MsCIWu8RQj9gVBh+0ult41861nCxCQDIIAnofGiBbTt+dvwoa1gE+lcwZ bCwx43l1xdaVV9gyTVonaMwndRfB/N+cYy9IhBvznHA17RQyiQ0CWXevPiXl9wLmIbzA uw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3qy3uykfvu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 02 Jun 2023 09:22:31 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Fri, 2 Jun 2023 09:22:29 -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.48 via Frontend Transport; Fri, 2 Jun 2023 09:22:29 -0700 Received: from localhost.localdomain (unknown [10.28.36.156]) by maili.marvell.com (Postfix) with ESMTP id CA0733F7061; Fri, 2 Jun 2023 09:22:27 -0700 (PDT) From: Vamsi Attunuru To: , , CC: , , Subject: [PATCH v3 1/3] node/kernel_tx: support packet transmit to kernel Date: Fri, 2 Jun 2023 09:22:14 -0700 Message-ID: <20230602162216.1868870-2-vattunuru@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230602162216.1868870-1-vattunuru@marvell.com> References: <20230425131516.3308612-1-vattunuru@marvell.com> <20230602162216.1868870-1-vattunuru@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: jWrL6i4EQ3hual9TkKekqVQjLk7TV2da X-Proofpoint-ORIG-GUID: jWrL6i4EQ3hual9TkKekqVQjLk7TV2da X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-02_12,2023-06-02_02,2023-05-22_02 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 Patch adds a node to transmit the packets to kernel over a raw socket. Signed-off-by: Vamsi Attunuru Acked-by: Nithin Dabilpuram --- doc/guides/prog_guide/graph_lib.rst | 9 ++ lib/node/kernel_tx.c | 122 ++++++++++++++++++++++++++++ lib/node/kernel_tx_priv.h | 16 ++++ lib/node/meson.build | 1 + 4 files changed, 148 insertions(+) diff --git a/doc/guides/prog_guide/graph_lib.rst b/doc/guides/prog_guide/graph_lib.rst index 1cfdc86433..fa22b014f3 100644 --- a/doc/guides/prog_guide/graph_lib.rst +++ b/doc/guides/prog_guide/graph_lib.rst @@ -392,3 +392,12 @@ null ~~~~ This node ignores the set of objects passed to it and reports that all are processed. + +kernel_tx +~~~~~~~~~ +This node is an exit node that forwards the packets to kernel. It will be used +to forward any control plane traffic to kernel stack from DPDK. It uses a raw +socket interface to transmit the packets, it uses the packet's destination +IP address in sockaddr_in address structure and ``sendto`` function to send +data on the raw socket. Aftering sending the burst of packets to kernel, +this node free up the packet buffers. diff --git a/lib/node/kernel_tx.c b/lib/node/kernel_tx.c new file mode 100644 index 0000000000..27d1808c71 --- /dev/null +++ b/lib/node/kernel_tx.c @@ -0,0 +1,122 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2023 Marvell International Ltd. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "kernel_tx_priv.h" +#include "node_private.h" + +static __rte_always_inline void +kernel_tx_process_mbuf(struct rte_node *node, struct rte_mbuf **mbufs, uint16_t cnt) +{ + kernel_tx_node_ctx_t *ctx = (kernel_tx_node_ctx_t *)node->ctx; + struct sockaddr_in sin = {0}; + struct rte_ipv4_hdr *ip4; + size_t len; + char *buf; + int i; + + for (i = 0; i < cnt; i++) { + ip4 = rte_pktmbuf_mtod(mbufs[i], struct rte_ipv4_hdr *); + len = rte_pktmbuf_data_len(mbufs[i]); + buf = (char *)ip4; + + sin.sin_family = AF_INET; + sin.sin_port = 0; + sin.sin_addr.s_addr = ip4->dst_addr; + + if (sendto(ctx->sock, buf, len, 0, (struct sockaddr *)&sin, sizeof(sin)) < 0) + node_err("kernel_tx", "Unable to send packets: %s\n", strerror(errno)); + } +} + +static uint16_t +kernel_tx_node_process(struct rte_graph *graph __rte_unused, struct rte_node *node, void **objs, + uint16_t nb_objs) +{ + struct rte_mbuf **pkts = (struct rte_mbuf **)objs; + uint16_t obj_left = nb_objs; + +#define PREFETCH_CNT 4 + + while (obj_left >= 12) { + /* Prefetch next-next mbufs */ + rte_prefetch0(pkts[8]); + rte_prefetch0(pkts[9]); + rte_prefetch0(pkts[10]); + rte_prefetch0(pkts[11]); + + /* Prefetch next mbuf data */ + rte_prefetch0(rte_pktmbuf_mtod_offset(pkts[4], void *, pkts[4]->l2_len)); + rte_prefetch0(rte_pktmbuf_mtod_offset(pkts[5], void *, pkts[5]->l2_len)); + rte_prefetch0(rte_pktmbuf_mtod_offset(pkts[6], void *, pkts[6]->l2_len)); + rte_prefetch0(rte_pktmbuf_mtod_offset(pkts[7], void *, pkts[7]->l2_len)); + + kernel_tx_process_mbuf(node, pkts, PREFETCH_CNT); + + obj_left -= PREFETCH_CNT; + pkts += PREFETCH_CNT; + } + + while (obj_left > 0) { + kernel_tx_process_mbuf(node, pkts, 1); + + obj_left--; + pkts++; + } + + rte_pktmbuf_free_bulk((struct rte_mbuf **)objs, nb_objs); + + return nb_objs; +} + +static int +kernel_tx_node_init(const struct rte_graph *graph __rte_unused, struct rte_node *node) +{ + kernel_tx_node_ctx_t *ctx = (kernel_tx_node_ctx_t *)node->ctx; + + ctx->sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); + if (ctx->sock < 0) + node_err("kernel_tx", "Unable to open RAW socket\n"); + + return 0; +} + +static void +kernel_tx_node_fini(const struct rte_graph *graph __rte_unused, struct rte_node *node) +{ + kernel_tx_node_ctx_t *ctx = (kernel_tx_node_ctx_t *)node->ctx; + + if (ctx->sock >= 0) { + close(ctx->sock); + ctx->sock = -1; + } +} + +static struct rte_node_register kernel_tx_node_base = { + .process = kernel_tx_node_process, + .name = "kernel_tx", + + .init = kernel_tx_node_init, + .fini = kernel_tx_node_fini, + + .nb_edges = 0, +}; + +struct rte_node_register * +kernel_tx_node_get(void) +{ + return &kernel_tx_node_base; +} + +RTE_NODE_REGISTER(kernel_tx_node_base); diff --git a/lib/node/kernel_tx_priv.h b/lib/node/kernel_tx_priv.h new file mode 100644 index 0000000000..6fd8a4f2af --- /dev/null +++ b/lib/node/kernel_tx_priv.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2023 Marvell International Ltd. + */ + +#ifndef __KERNEL_TX_PRIV_H__ +#define __KERNEL_TX_PRIV_H__ + +/* kernel_tx node context structure. */ +typedef struct kernel_tx_node_ctx { + int sock; +} kernel_tx_node_ctx_t; + +/* Get the pointer to kernel_tx node register structure */ +struct rte_node_register *kernel_tx_node_get(void); + +#endif /* __KERNEL_TX_PRIV_H__ */ diff --git a/lib/node/meson.build b/lib/node/meson.build index dbdf673c86..0520be23ff 100644 --- a/lib/node/meson.build +++ b/lib/node/meson.build @@ -13,6 +13,7 @@ sources = files( 'ethdev_tx.c', 'ip4_lookup.c', 'ip4_rewrite.c', + 'kernel_tx.c', 'log.c', 'null.c', 'pkt_cls.c', From patchwork Fri Jun 2 16:22:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vamsi Krishna Attunuru X-Patchwork-Id: 127976 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5CAD842C11; Fri, 2 Jun 2023 18:22:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E3CFC42C4D; Fri, 2 Jun 2023 18:22:35 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id C6D5D42D39 for ; Fri, 2 Jun 2023 18:22:34 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3529oZ2A027573; Fri, 2 Jun 2023 09:22:34 -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=pfpt0220; bh=6SpPoK0WIasulCuQL/6oJdFCKzKS3dSCPcb8j8db72o=; b=FmsjQXDYH1Jyjs8X7qZiZVzQTeCIcfR8sfcdh76EsspY3b+nuvzAcXSWVvz8URdfGITJ UmBZA6ZbpT1/h5Bcvu6k5hiumQ/s7qKUYm/Hu4zR82gXaqFsfr5bJYgar4WEc+7WseM0 PrS45T+Z5Q9RVz+WI7ZOsV4GeBWP3u2Y9o5m7MMdXUxoIaPDPPaAmHD5nKHY7oKx9KEt pkh6KYYtLCIN6eCswNgXi7bPpmG64U8+gH3EIvYteAVrKj49eMfMTRNC7oJpca5Cz9/l RlpmxN94cr4hJLbzMQOcY5lUKFvZZRdRxyI8JOSPAgAFkbbYFS9LBhM9c4VSa9YxeRwv vQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3qy3uykfw0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 02 Jun 2023 09:22:33 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Fri, 2 Jun 2023 09:22:32 -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.48 via Frontend Transport; Fri, 2 Jun 2023 09:22:32 -0700 Received: from localhost.localdomain (unknown [10.28.36.156]) by maili.marvell.com (Postfix) with ESMTP id 41E203F7048; Fri, 2 Jun 2023 09:22:30 -0700 (PDT) From: Vamsi Attunuru To: , , CC: , , Subject: [PATCH v3 2/3] node/kernel_rx: support receiving packets from kernel Date: Fri, 2 Jun 2023 09:22:15 -0700 Message-ID: <20230602162216.1868870-3-vattunuru@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230602162216.1868870-1-vattunuru@marvell.com> References: <20230425131516.3308612-1-vattunuru@marvell.com> <20230602162216.1868870-1-vattunuru@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: Qc7TvdEre63eaiYBU88HnwsAtL4JFRe2 X-Proofpoint-ORIG-GUID: Qc7TvdEre63eaiYBU88HnwsAtL4JFRe2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-02_12,2023-06-02_02,2023-05-22_02 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 Adds a node to receive packets from kernel over a raw socket. Signed-off-by: Vamsi Attunuru Acked-by: Nithin Dabilpuram --- doc/guides/prog_guide/graph_lib.rst | 8 + lib/node/kernel_rx.c | 276 ++++++++++++++++++++++++++++ lib/node/kernel_rx_priv.h | 48 +++++ lib/node/meson.build | 1 + 4 files changed, 333 insertions(+) diff --git a/doc/guides/prog_guide/graph_lib.rst b/doc/guides/prog_guide/graph_lib.rst index fa22b014f3..4b05bcee3c 100644 --- a/doc/guides/prog_guide/graph_lib.rst +++ b/doc/guides/prog_guide/graph_lib.rst @@ -401,3 +401,11 @@ socket interface to transmit the packets, it uses the packet's destination IP address in sockaddr_in address structure and ``sendto`` function to send data on the raw socket. Aftering sending the burst of packets to kernel, this node free up the packet buffers. + +kernel_rx +~~~~~~~~~ +This node is a source node which receives packets from kernel and forwards to +any of the intermediate nodes. It uses the raw socket interface to receive +packets from kernel. Uses ``poll`` function to poll on the socket fd for +``POLLIN`` events to read the packets from raw socket to stream buffer and does +``rte_node_next_stream_move()`` when there are received packets. diff --git a/lib/node/kernel_rx.c b/lib/node/kernel_rx.c new file mode 100644 index 0000000000..2dba7c8cc7 --- /dev/null +++ b/lib/node/kernel_rx.c @@ -0,0 +1,276 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2023 Marvell International Ltd. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ethdev_rx_priv.h" +#include "kernel_rx_priv.h" +#include "node_private.h" + +static inline struct rte_mbuf * +alloc_rx_mbuf(kernel_rx_node_ctx_t *ctx) +{ + kernel_rx_info_t *rx = ctx->recv_info; + + if (rx->idx >= rx->cnt) { + uint16_t cnt; + + rx->idx = 0; + rx->cnt = 0; + + cnt = rte_pktmbuf_alloc_bulk(ctx->pktmbuf_pool, rx->rx_bufs, KERN_RX_CACHE_COUNT); + if (cnt <= 0) + return NULL; + + rx->cnt = cnt; + } + + return rx->rx_bufs[rx->idx++]; +} + +static inline void +mbuf_update(struct rte_mbuf **mbufs, uint16_t nb_pkts) +{ + struct rte_net_hdr_lens hdr_lens; + struct rte_mbuf *m; + int i; + + for (i = 0; i < nb_pkts; i++) { + m = mbufs[i]; + + m->packet_type = rte_net_get_ptype(m, &hdr_lens, RTE_PTYPE_ALL_MASK); + + m->ol_flags = 0; + m->tx_offload = 0; + + m->l2_len = hdr_lens.l2_len; + m->l3_len = hdr_lens.l3_len; + m->l4_len = hdr_lens.l4_len; + } +} + +static uint16_t +recv_pkt_parse(void **objs, uint16_t nb_pkts) +{ + uint16_t pkts_left = nb_pkts; + struct rte_mbuf **pkts; + int i; + + pkts = (struct rte_mbuf **)objs; + + if (pkts_left >= 4) { + for (i = 0; i < 4; i++) + rte_prefetch0(rte_pktmbuf_mtod(pkts[i], void *)); + } + + while (pkts_left >= 12) { + /* Prefetch next-next mbufs */ + rte_prefetch0(pkts[8]); + rte_prefetch0(pkts[9]); + rte_prefetch0(pkts[10]); + rte_prefetch0(pkts[11]); + + /* Prefetch next mbuf data */ + rte_prefetch0(rte_pktmbuf_mtod(pkts[4], void *)); + rte_prefetch0(rte_pktmbuf_mtod(pkts[5], void *)); + rte_prefetch0(rte_pktmbuf_mtod(pkts[6], void *)); + rte_prefetch0(rte_pktmbuf_mtod(pkts[7], void *)); + + /* Extract ptype of mbufs */ + mbuf_update(pkts, 4); + + pkts += 4; + pkts_left -= 4; + } + + if (pkts_left > 0) + mbuf_update(pkts, pkts_left); + + return nb_pkts; +} + +static uint16_t +kernel_rx_node_do(struct rte_graph *graph, struct rte_node *node, kernel_rx_node_ctx_t *ctx) +{ + kernel_rx_info_t *rx; + uint16_t next_index; + int fd; + + rx = ctx->recv_info; + next_index = rx->node_next; + + fd = rx->sock; + if (fd > 0) { + struct rte_mbuf **mbufs; + uint16_t len = 0, count = 0; + int nb_cnt, i; + + nb_cnt = (node->size >= RTE_GRAPH_BURST_SIZE) ? RTE_GRAPH_BURST_SIZE : node->size; + + mbufs = (struct rte_mbuf **)node->objs; + for (i = 0; i < nb_cnt; i++) { + struct rte_mbuf *m = alloc_rx_mbuf(ctx); + + if (!m) + break; + + len = read(fd, rte_pktmbuf_mtod(m, char *), rte_pktmbuf_tailroom(m)); + if (len == 0 || len == 0xFFFF) { + rte_pktmbuf_free(m); + if (rx->idx <= 0) + node_dbg("kernel_rx", "rx_mbuf array is empty\n"); + rx->idx--; + break; + } + *mbufs++ = m; + + m->port = node->id; + rte_pktmbuf_data_len(m) = len; + + count++; + } + + if (count) { + recv_pkt_parse(node->objs, count); + node->idx = count; + + /* Enqueue to next node */ + rte_node_next_stream_move(graph, node, next_index); + } + + return count; + } + + return 0; +} + +static uint16_t +kernel_rx_node_process(struct rte_graph *graph, struct rte_node *node, void **objs, + uint16_t nb_objs) +{ + kernel_rx_node_ctx_t *ctx = (kernel_rx_node_ctx_t *)node->ctx; + int fd; + + RTE_SET_USED(objs); + RTE_SET_USED(nb_objs); + + if (!ctx) + return 0; + + fd = ctx->recv_info->sock; + if (fd > 0) { + struct pollfd fds = {.fd = fd, .events = POLLIN}; + + if (poll(&fds, 1, 0) > 0) { + if (fds.revents & POLLIN) + return kernel_rx_node_do(graph, node, ctx); + } + } + + return 0; +} + +static int +kernel_rx_node_init(const struct rte_graph *graph, struct rte_node *node) +{ + struct kernel_rx_node_main *rx_node_main = kernel_rx_node_data_get(); + kernel_rx_node_ctx_t *ctx = (kernel_rx_node_ctx_t *)node->ctx; + kernel_rx_node_elem_t *elem = rx_node_main->head; + kernel_rx_info_t *recv_info; + int sock; + + while (elem) { + if (elem->nid == node->id) { + /* Update node specific context */ + memcpy(ctx, &elem->ctx, sizeof(kernel_rx_node_ctx_t)); + break; + } + elem = elem->next; + } + + RTE_VERIFY(elem != NULL); + + if (ctx->pktmbuf_pool == NULL) { + node_err("kernel_rx", "Invalid mbuf pool on graph %s\n", graph->name); + return -EINVAL; + } + + recv_info = rte_zmalloc_socket("kernel_rx_info", sizeof(kernel_rx_info_t), + RTE_CACHE_LINE_SIZE, graph->socket); + if (!recv_info) { + node_err("kernel_rx", "Kernel recv_info is NULL\n"); + return -ENOMEM; + } + + sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); + if (sock < 0) { + node_err("kernel_rx", "Unable to open RAW socket\n"); + return sock; + } + + recv_info->sock = sock; + ctx->recv_info = recv_info; + + return 0; +} + +static void +kernel_rx_node_fini(const struct rte_graph *graph __rte_unused, struct rte_node *node) +{ + kernel_rx_node_ctx_t *ctx = (kernel_rx_node_ctx_t *)node->ctx; + + if (ctx->recv_info) { + close(ctx->recv_info->sock); + ctx->recv_info->sock = -1; + rte_free(ctx->recv_info); + } + + ctx->recv_info = NULL; +} + +struct kernel_rx_node_main * +kernel_rx_node_data_get(void) +{ + static struct kernel_rx_node_main kernel_rx_main; + + return &kernel_rx_main; +} + +static struct rte_node_register kernel_rx_node_base = { + .process = kernel_rx_node_process, + .flags = RTE_NODE_SOURCE_F, + .name = "kernel_rx", + + .init = kernel_rx_node_init, + .fini = kernel_rx_node_fini, + + .nb_edges = KERNEL_RX_NEXT_MAX, + .next_nodes = { + [KERNEL_RX_NEXT_PKT_CLS] = "pkt_cls", + [KERNEL_RX_NEXT_IP4_LOOKUP] = "ip4_lookup", + }, +}; + +struct rte_node_register * +kernel_rx_node_get(void) +{ + return &kernel_rx_node_base; +} + +RTE_NODE_REGISTER(kernel_rx_node_base); diff --git a/lib/node/kernel_rx_priv.h b/lib/node/kernel_rx_priv.h new file mode 100644 index 0000000000..f1aa2344d7 --- /dev/null +++ b/lib/node/kernel_rx_priv.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2023 Marvell International Ltd. + */ + +#ifndef __KERNEL_RX_PRIV_H__ +#define __KERNEL_RX_PRIV_H__ + +#define KERN_RX_CACHE_COUNT 64 + +typedef struct kernel_rx_info { + struct rte_mbuf *rx_bufs[KERN_RX_CACHE_COUNT]; + uint16_t node_next; + uint16_t idx; + uint16_t cnt; + int sock; +} kernel_rx_info_t; + +/* kernel_rx node context structure */ +typedef struct kernel_rx_node_ctx { + struct rte_mempool *pktmbuf_pool; + kernel_rx_info_t *recv_info; +} kernel_rx_node_ctx_t; + +/* kernel_rx node list element structure */ +typedef struct kernel_rx_node_elem { + struct kernel_rx_node_elem *next; /* Pointer to the next node element. */ + struct kernel_rx_node_ctx ctx; /* kernel_rx node context. */ + rte_node_t nid; /* Node identifier of the kernel_rx node. */ +} kernel_rx_node_elem_t; + +enum kernel_rx_next_nodes { + KERNEL_RX_NEXT_PKT_CLS, + KERNEL_RX_NEXT_IP4_LOOKUP, + KERNEL_RX_NEXT_MAX, +}; + +/* kernel_rx node main structure */ +struct kernel_rx_node_main { + kernel_rx_node_elem_t *head; /* Pointer to the head node element. */ +}; + +/* Get the pointer of kernel_rx node data */ +struct kernel_rx_node_main *kernel_rx_node_data_get(void); + +/* Get the pointer of kernel_rx node register structure */ +struct rte_node_register *kernel_rx_node_get(void); + +#endif /* __KERNEL_RX_PRIV_H__ */ diff --git a/lib/node/meson.build b/lib/node/meson.build index 0520be23ff..1f04fd1d7e 100644 --- a/lib/node/meson.build +++ b/lib/node/meson.build @@ -13,6 +13,7 @@ sources = files( 'ethdev_tx.c', 'ip4_lookup.c', 'ip4_rewrite.c', + 'kernel_rx.c', 'kernel_tx.c', 'log.c', 'null.c', From patchwork Fri Jun 2 16:22:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vamsi Krishna Attunuru X-Patchwork-Id: 127977 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 127EE42C11; Fri, 2 Jun 2023 18:22:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 02AB342D3E; Fri, 2 Jun 2023 18:22:39 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 6852F42D31 for ; Fri, 2 Jun 2023 18:22:37 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 352AewZj027246; Fri, 2 Jun 2023 09:22:36 -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=pfpt0220; bh=5ma31mPcewjVN0ZxemQ9boFUHl6HNRRg27mXK4C4loY=; b=Kq8oa90BXWmzgeDxKqq7zJ9vfcySZJLTC2FEfc5Fqs2jQtQERwTPbaZXrCuovxdKsNaW P8LVctUjKSGNjKhIhZpMZAxMVH6WCRur3FV4LW/ptr7ZRQ69BkjUQq+/vayx1R622KXb aZSvBbnH+HoBMr4XFr4RZMgII6sf0jVscT1TSXeLAeKLKVqtIuYpAxJdwR/srGm12eV4 GNThRLs6+xzzrZl6gfGgkxnug9iZ1RxnwxmyuXTd/h7B9cmqfoHvK/VScnSXU5Ofg0tY vytW9T2cbJZ5yJUE6NMaJWkVuy1w8zlozNBmKuRbAL5htlXolVWYznmSPsKoOV82sSjn MA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3qy3uykfw3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 02 Jun 2023 09:22:36 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Fri, 2 Jun 2023 09:22:34 -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.48 via Frontend Transport; Fri, 2 Jun 2023 09:22:34 -0700 Received: from localhost.localdomain (unknown [10.28.36.156]) by maili.marvell.com (Postfix) with ESMTP id ADC023F7060; Fri, 2 Jun 2023 09:22:32 -0700 (PDT) From: Vamsi Attunuru To: , , CC: , , Subject: [PATCH v3 3/3] node/ethdev_rx: remove hardcoded node next details Date: Fri, 2 Jun 2023 09:22:16 -0700 Message-ID: <20230602162216.1868870-4-vattunuru@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230602162216.1868870-1-vattunuru@marvell.com> References: <20230425131516.3308612-1-vattunuru@marvell.com> <20230602162216.1868870-1-vattunuru@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: -MUuVTJCnfHWBrrzhAKYz8Nqv92GE3Wg X-Proofpoint-ORIG-GUID: -MUuVTJCnfHWBrrzhAKYz8Nqv92GE3Wg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-02_12,2023-06-02_02,2023-05-22_02 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 For ethdev_rx node, node_next details can be populated during node cloning time and same gets assigned to node context structure during node initialization. Patch removes overriding node_next details in node init(). Signed-off-by: Vamsi Attunuru Acked-by: Nithin Dabilpuram --- lib/node/ethdev_ctrl.c | 1 + lib/node/ethdev_rx.c | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/node/ethdev_ctrl.c b/lib/node/ethdev_ctrl.c index 37df0431b8..496f791cee 100644 --- a/lib/node/ethdev_ctrl.c +++ b/lib/node/ethdev_ctrl.c @@ -82,6 +82,7 @@ rte_node_eth_config(struct rte_node_ethdev_config *conf, uint16_t nb_confs, memset(elem, 0, sizeof(ethdev_rx_node_elem_t)); elem->ctx.port_id = port_id; elem->ctx.queue_id = j; + elem->ctx.cls_next = ETHDEV_RX_NEXT_PKT_CLS; elem->nid = id; elem->next = rx_node_data->head; rx_node_data->head = elem; diff --git a/lib/node/ethdev_rx.c b/lib/node/ethdev_rx.c index a19237b42f..d131034991 100644 --- a/lib/node/ethdev_rx.c +++ b/lib/node/ethdev_rx.c @@ -194,8 +194,6 @@ ethdev_rx_node_init(const struct rte_graph *graph, struct rte_node *node) RTE_VERIFY(elem != NULL); - ctx->cls_next = ETHDEV_RX_NEXT_PKT_CLS; - /* Check and setup ptype */ return ethdev_ptype_setup(ctx->port_id, ctx->queue_id); } @@ -215,7 +213,6 @@ static struct rte_node_register ethdev_rx_node_base = { .nb_edges = ETHDEV_RX_NEXT_MAX, .next_nodes = { - /* Default pkt classification node */ [ETHDEV_RX_NEXT_PKT_CLS] = "pkt_cls", [ETHDEV_RX_NEXT_IP4_LOOKUP] = "ip4_lookup", },