On Fri, Apr 21, 2023 at 11:33 AM Vamsi Attunuru <[email protected]> wrote: > > Patch adds a node to receive packets from kernel > over a raw socket.
Subjection suggestion: node/kernel_rx: support receving packet from kernel > > Signed-off-by: Vamsi Attunuru <[email protected]> > --- > doc/guides/prog_guide/graph_lib.rst | 7 + > lib/node/kernel_recv.c | 277 ++++++++++++++++++++++++++++ > lib/node/kernel_recv_priv.h | 74 ++++++++ > lib/node/meson.build | 1 + > 4 files changed, 359 insertions(+) > > diff --git a/doc/guides/prog_guide/graph_lib.rst > b/doc/guides/prog_guide/graph_lib.rst > index b3b5b14827..1057f16de8 100644 > --- a/doc/guides/prog_guide/graph_lib.rst > +++ b/doc/guides/prog_guide/graph_lib.rst > @@ -402,3 +402,10 @@ on the raw socket. > > Aftering sending the burst of packets to kernel, this node redirects the same > objects to pkt_drop node to free up the packet buffers. > + > +kernel_recv Better to change node name to kernel_rx > +~~~~~~~~~~~ > +This node receives packets from kernel over a raw socket interface. 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. You can tell typical use case for punt and kernel_tx node. i.e expection path handling. Also, may consider chnage to kernel_tx for punt node. > diff --git a/lib/node/kernel_recv.c b/lib/node/kernel_recv.c > new file mode 100644 > index 0000000000..361dcc3b5f > --- /dev/null > +++ b/lib/node/kernel_recv.c > @@ -0,0 +1,277 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(C) 2023 Marvell International Ltd. > + */ > + > +#include <fcntl.h> > +#include <poll.h> > +#include <stdlib.h> > +#include <sys/ioctl.h> > +#include <sys/socket.h> > +#include <unistd.h> > + > +#include <rte_debug.h> > +#include <rte_ethdev.h> > +#include <rte_graph.h> > +#include <rte_graph_worker.h> > +#include <rte_ip.h> > +#include <rte_malloc.h> > +#include <rte_mbuf.h> > +#include <rte_mempool.h> > +#include <rte_net.h> > + > +#include "ethdev_rx_priv.h" > +#include "kernel_recv_priv.h" > +#include "node_private.h" > + > +static struct kernel_recv_node_main kernel_recv_main; Try to remove global varible. > +#ifndef __INCLUDE_KERNEL_RECV_PRIV_H__ No need to add INCLUDE > +#define __INCLUDE_KERNEL_RECV_PRIV_H__ > + > +#define KERN_RECV_CACHE_COUNT 64 > + > +typedef struct kernel_recv_info { > + struct rte_mbuf *rx_bufs[KERN_RECV_CACHE_COUNT]; > + uint16_t cls_next; > + uint16_t idx; > + uint16_t cnt; > + int sock; > +} kernel_recv_info_t; > + > +/** > + * @internal > + * > + * Kernel Recv node context structure. Across the patch series, no need for Doxgen comments for internal functions.

