examples/l2fwd-event: add infra to split eventdev framework
authorSunil Kumar Kori <skori@marvell.com>
Wed, 30 Oct 2019 16:26:44 +0000 (21:56 +0530)
committerJerin Jacob <jerinj@marvell.com>
Mon, 4 Nov 2019 17:09:10 +0000 (18:09 +0100)
Add infra to split eventdev framework based on event Tx adapter
capability.
If event Tx adapter has internal port capability then we use
`rte_event_eth_tx_adapter_enqueue` to transmitting packets else
we use a SINGLE_LINK event queue to enqueue packets to a service
core which is responsible for transmitting packets.

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Acked-by: Nipun Gupta <nipun.gupta@nxp.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
examples/l2fwd-event/Makefile
examples/l2fwd-event/l2fwd_event.c
examples/l2fwd-event/l2fwd_event.h
examples/l2fwd-event/l2fwd_event_generic.c [new file with mode: 0644]
examples/l2fwd-event/l2fwd_event_internal_port.c [new file with mode: 0644]
examples/l2fwd-event/meson.build

index 08ba183..6f41768 100644 (file)
@@ -10,6 +10,8 @@ SRCS-y := main.c
 SRCS-y += l2fwd_poll.c
 SRCS-y += l2fwd_event.c
 SRCS-y += l2fwd_common.c
+SRCS-y += l2fwd_event_generic.c
+SRCS-y += l2fwd_event_internal_port.c
 
 # Build using pkg-config variables if possible
 ifeq ($(shell pkg-config --exists libdpdk && echo 0),0)
index 48d32d7..7f90e63 100644 (file)
 
 #include "l2fwd_event.h"
 
+static void
+l2fwd_event_capability_setup(struct l2fwd_event_resources *evt_rsrc)
+{
+       uint32_t caps = 0;
+       uint16_t i;
+       int ret;
+
+       RTE_ETH_FOREACH_DEV(i) {
+               ret = rte_event_eth_tx_adapter_caps_get(0, i, &caps);
+               if (ret)
+                       rte_panic("Invalid capability for Tx adptr port %d\n",
+                                 i);
+
+               evt_rsrc->tx_mode_q |= !(caps &
+                                  RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT);
+       }
+
+       if (evt_rsrc->tx_mode_q)
+               l2fwd_event_set_generic_ops(&evt_rsrc->ops);
+       else
+               l2fwd_event_set_internal_port_ops(&evt_rsrc->ops);
+}
+
 void
 l2fwd_event_resource_setup(struct l2fwd_resources *rsrc)
 {
@@ -31,4 +54,7 @@ l2fwd_event_resource_setup(struct l2fwd_resources *rsrc)
                rte_panic("Failed to allocate memory\n");
 
        rsrc->evt_rsrc = evt_rsrc;
+
+       /* Setup eventdev capability callbacks */
+       l2fwd_event_capability_setup(evt_rsrc);
 }
index 9a1bb16..b7aaa39 100644 (file)
 
 #include "l2fwd_common.h"
 
+struct event_setup_ops {
+};
+
 struct l2fwd_event_resources {
+       uint8_t tx_mode_q;
+       struct event_setup_ops ops;
 };
 
 void l2fwd_event_resource_setup(struct l2fwd_resources *rsrc);
+void l2fwd_event_set_generic_ops(struct event_setup_ops *ops);
+void l2fwd_event_set_internal_port_ops(struct event_setup_ops *ops);
 
 #endif /* __L2FWD_EVENT_H__ */
diff --git a/examples/l2fwd-event/l2fwd_event_generic.c b/examples/l2fwd-event/l2fwd_event_generic.c
new file mode 100644 (file)
index 0000000..9afade7
--- /dev/null
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2019 Marvell International Ltd.
+ */
+
+#include <stdbool.h>
+#include <getopt.h>
+
+#include <rte_cycles.h>
+#include <rte_ethdev.h>
+#include <rte_eventdev.h>
+#include <rte_event_eth_rx_adapter.h>
+#include <rte_event_eth_tx_adapter.h>
+#include <rte_lcore.h>
+#include <rte_spinlock.h>
+
+#include "l2fwd_common.h"
+#include "l2fwd_event.h"
+
+void
+l2fwd_event_set_generic_ops(struct event_setup_ops *ops)
+{
+       RTE_SET_USED(ops);
+}
diff --git a/examples/l2fwd-event/l2fwd_event_internal_port.c b/examples/l2fwd-event/l2fwd_event_internal_port.c
new file mode 100644 (file)
index 0000000..ce95b8e
--- /dev/null
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2019 Marvell International Ltd.
+ */
+
+#include <stdbool.h>
+#include <getopt.h>
+
+#include <rte_cycles.h>
+#include <rte_ethdev.h>
+#include <rte_eventdev.h>
+#include <rte_event_eth_rx_adapter.h>
+#include <rte_event_eth_tx_adapter.h>
+#include <rte_lcore.h>
+#include <rte_spinlock.h>
+
+#include "l2fwd_common.h"
+#include "l2fwd_event.h"
+
+void
+l2fwd_event_set_internal_port_ops(struct event_setup_ops *ops)
+{
+       RTE_SET_USED(ops);
+}
index c1ae203..4e9a069 100644 (file)
@@ -13,4 +13,6 @@ sources = files(
        'l2fwd_poll.c',
        'l2fwd_common.c',
        'l2fwd_event.c',
+       'l2fwd_event_internal_port.c',
+       'l2fwd_event_generic.c'
 )