1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2020 Marvell International Ltd.
6 #include <rte_ethdev.h>
8 #include <rte_graph_worker.h>
10 #include "ethdev_tx_priv.h"
12 static struct ethdev_tx_node_main ethdev_tx_main;
15 ethdev_tx_node_process(struct rte_graph *graph, struct rte_node *node,
16 void **objs, uint16_t nb_objs)
18 ethdev_tx_node_ctx_t *ctx = (ethdev_tx_node_ctx_t *)node->ctx;
26 count = rte_eth_tx_burst(port, queue, (struct rte_mbuf **)objs,
29 /* Redirect unsent pkts to drop node */
30 if (count != nb_objs) {
31 rte_node_enqueue(graph, node, ETHDEV_TX_NEXT_PKT_DROP,
32 &objs[count], nb_objs - count);
39 ethdev_tx_node_init(const struct rte_graph *graph, struct rte_node *node)
41 ethdev_tx_node_ctx_t *ctx = (ethdev_tx_node_ctx_t *)node->ctx;
42 uint64_t port_id = RTE_MAX_ETHPORTS;
45 /* Find our port id */
46 for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
47 if (ethdev_tx_main.nodes[i] == node->id) {
52 RTE_VERIFY(port_id < RTE_MAX_ETHPORTS);
54 /* Update port and queue */
56 ctx->queue = graph->id;
61 struct ethdev_tx_node_main *
62 ethdev_tx_node_data_get(void)
64 return ðdev_tx_main;
67 static struct rte_node_register ethdev_tx_node_base = {
68 .process = ethdev_tx_node_process,
71 .init = ethdev_tx_node_init,
73 .nb_edges = ETHDEV_TX_NEXT_MAX,
75 [ETHDEV_TX_NEXT_PKT_DROP] = "pkt_drop",
79 struct rte_node_register *
80 ethdev_tx_node_get(void)
82 return ðdev_tx_node_base;
85 RTE_NODE_REGISTER(ethdev_tx_node_base);