summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsongyanchao <[email protected]>2024-03-01 09:50:00 +0000
committersongyanchao <[email protected]>2024-03-01 10:32:06 +0000
commit0ded7e8b40817cbe32e0b77ee9fcd72b1f781635 (patch)
tree40f1125b834778304e5d5b8040b8c827fc9d0ed3
parent8bd3643c8432d59e8907d309acbc406460386e40 (diff)
✨ feat(TSG-19602): Add the trace information for 'shm_dev_rx/tx' node.v4.6.75-20240301
Add the trace information for 'shm_dev_rx/tx' node.
-rw-r--r--service/src/node_shmdev.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/service/src/node_shmdev.c b/service/src/node_shmdev.c
index 4aa6506..4eff1ae 100644
--- a/service/src/node_shmdev.c
+++ b/service/src/node_shmdev.c
@@ -1,4 +1,3 @@
-#include "rte_branch_prediction.h"
#include <rte_debug.h>
#include <rte_ethdev.h>
#include <rte_ether.h>
@@ -39,6 +38,31 @@ struct shmdev_stat_per_lcore
struct shmdev_stat_per_lcore shmdev_graph_stat[RTE_MAX_LCORE];
+enum packet_direction
+{
+ PACKET_DIRECTION_TX,
+ PACKET_DIRECTION_RX
+};
+
+/* Generate and store the trace information */
+static __rte_always_inline void gen_store_trace_info(struct rte_node * node, struct rte_mbuf * mbuf,
+ struct vdev * shm_dev_desc, enum packet_direction direction)
+{
+ struct dp_record_meta meta = {0};
+ rte_strscpy(meta.module, node->name, sizeof(meta.module));
+
+ char str_record[MR_STRING_MAX] = {0};
+ int len = snprintf(str_record, sizeof(str_record), "prot:%u,%s", shm_dev_desc->port_id, shm_dev_desc->symbol);
+
+ if (direction == PACKET_DIRECTION_RX)
+ {
+ len += snprintf(str_record + len, sizeof(str_record) - len, ",next:%s", node->nodes[0]->name);
+ }
+
+ /* Emit the trace record */
+ dp_trace_record_emit_str(sc_main_get()->trace, mbuf, &meta, str_record);
+}
+
uint16_t shmdev_rx_node_process(struct rte_graph * graph, struct rte_node * node, void ** objs, uint16_t cnt)
{
struct dev_node_ctx * ctx = (struct dev_node_ctx *)node->ctx;
@@ -105,6 +129,12 @@ uint16_t shmdev_rx_node_process(struct rte_graph * graph, struct rte_node * node
/* Fill port ingress */
mrb_meta->port_ingress = dev_desc->port_id;
+
+ /* Check if tracing is enabled for the current Mbuf */
+ if (unlikely(dp_trace_record_can_emit(mbuf0)))
+ {
+ gen_store_trace_info(node, mbuf0, shm_dev_desc, PACKET_DIRECTION_RX);
+ }
}
/* Update total rx pkts */
@@ -129,6 +159,15 @@ uint16_t shmdev_tx_node_process(struct rte_graph * graph, struct rte_node * node
MR_SHMDEV_STAT_ADD(shmdev_graph_stat, graph->id, total_tx_pkts, cnt);
+ for (unsigned int i = 0; i < nr_pkts; i++)
+ {
+ /* Check if tracing is enabled for the current Mbuf */
+ if (unlikely(dp_trace_record_can_emit(mbufs[i])))
+ {
+ gen_store_trace_info(node, mbufs[i], shm_dev_desc, PACKET_DIRECTION_TX);
+ }
+ }
+
while (nr_pkts)
{
if (nr_pkts > RTE_GRAPH_BURST_SIZE)