diff options
| author | songyanchao <[email protected]> | 2024-03-01 07:35:56 +0000 |
|---|---|---|
| committer | songyanchao <[email protected]> | 2024-03-01 10:30:30 +0000 |
| commit | 5494f5a4cbc3cfc22ac64e996c2698da8a4ef65e (patch) | |
| tree | 9b38835ee4534d656ca78241d3039a9894964e6d | |
| parent | 3d311df2748b04964fc1faa031fa062ad81a69b8 (diff) | |
✨ feat(TSG-19602): Add the trace information for 'forwarder' node.
Add the trace information for 'forwarder' node.
| -rw-r--r-- | service/src/node_etherfabric.c | 5 | ||||
| -rw-r--r-- | service/src/node_forwarder.c | 60 |
2 files changed, 62 insertions, 3 deletions
diff --git a/service/src/node_etherfabric.c b/service/src/node_etherfabric.c index 8a2cbbe..58d47a5 100644 --- a/service/src/node_etherfabric.c +++ b/service/src/node_etherfabric.c @@ -736,6 +736,11 @@ static __rte_always_inline void construct_trace_info_egress(struct rte_node * no len += snprintf(str_record + len, sizeof(str_record) - len, "nf_create:yes"); } + /* Populate the egress port info */ + struct mr_dev_desc * dev_desc = mr_dev_desc_lookup_by_port_id(sc_main_get()->devmgr_main, mrb_meta->port_egress); + len += + snprintf(str_record + len, sizeof(str_record) - len, ",tx_port:%u,%s", mrb_meta->port_egress, dev_desc->symbol); + /* Emit the trace record */ dp_trace_record_emit_str(sc_main_get()->trace, mbuf, &meta, str_record); } diff --git a/service/src/node_forwarder.c b/service/src/node_forwarder.c index 777baa2..b251b28 100644 --- a/service/src/node_forwarder.c +++ b/service/src/node_forwarder.c @@ -89,6 +89,54 @@ void forwarder_table_inserter(uint16_t sid, uint16_t type) MR_INFO("%s", str_forwarder); } +/* Construct the trace information */ +static __rte_always_inline void construct_trace_info(struct rte_node * node, struct rte_mbuf * mbuf, + uint16_t next_node_index, struct forwarder_stat * stat, + struct forwarder_stat * stat_for_trace) +{ + struct dp_record_meta meta = {0}; + rte_strscpy(meta.module, node->name, sizeof(meta.module)); + + /* Populate the next node infomation */ + char str_record[MR_STRING_MAX] = {0}; + int len = snprintf(str_record, sizeof(str_record), "next:%s", node->nodes[next_node_index]->name); + + /* Populate the drop reason */ + if (unlikely(next_node_index == FORWARDER_PKT_DROP)) + { + if (stat_for_trace->drop_for_pop_sid_err != stat->drop_for_pop_sid_err) + { + len += snprintf(str_record + len, sizeof(str_record) - len, ",drp_rsn:pop sid err"); + stat_for_trace->drop_for_pop_sid_err = stat->drop_for_pop_sid_err; + } + else if (stat_for_trace->drop_for_invalid_sid != stat->drop_for_invalid_sid) + { + len += snprintf(str_record + len, sizeof(str_record) - len, ",drp_rsn:invalid sid"); + stat_for_trace->drop_for_invalid_sid = stat->drop_for_invalid_sid; + } + } + + /* Populate the pop sid */ + struct mrb_metadata * mrb_meta = mrbuf_cz_data(mbuf, MR_NODE_CTRLZONE_ID); + len += snprintf(str_record + len, sizeof(str_record) - len, ",pop sid:%u", mrb_meta->cur_sid); + + /* Populate the Sid list */ + uint16_t sids[RTE_DIM(mrb_meta->sid_list.sids)] = {}; + int nr_sids = sid_list_get(&mrb_meta->sid_list, sids, RTE_DIM(mrb_meta->sid_list.sids)); + + len += snprintf(str_record + len, sizeof(str_record) - len, ",sids:"); + for (int i = 0; i < nr_sids; i++) + { + if (sids[i] != 0) + { + len += snprintf(str_record + len, sizeof(str_record) - len, "%u,", sids[i]); + } + } + + /* Emit the trace record */ + dp_trace_record_emit_str(sc_main_get()->trace, mbuf, &meta, str_record); +} + /* Forwarder node process function */ static __rte_always_inline uint16_t forwarder_node_process(struct rte_graph * graph, struct rte_node * node, void ** objs, uint16_t cnt) @@ -100,10 +148,10 @@ static __rte_always_inline uint16_t forwarder_node_process(struct rte_graph * gr struct forwarder_main * forwarder_main = g_forwarder_main_get(); uint16_t batch_next_node_index = FORWARDER_NEXT_LB; uint16_t n_left_from = cnt; - rte_graph_t graph_id = graph->id; struct rte_mbuf ** pkts = (struct rte_mbuf **)objs; - struct forwarder_stat stat = {}; void ** batch_pkts = objs; + struct forwarder_stat stat = {0}; + struct forwarder_stat stat_for_trace = {0}; unsigned int next_node_index_counters[FORWARDER_NEXT_MAX] = {0}; @@ -159,6 +207,12 @@ static __rte_always_inline uint16_t forwarder_node_process(struct rte_graph * gr mrb_metadata->cur_sid = sid; node_enqueue: + /* Check if tracing is enabled for the current Mbuf */ + if (unlikely(dp_trace_record_can_emit(mbuf))) + { + construct_trace_info(node, mbuf, next_node_index, &stat, &stat_for_trace); + } + /* Judge the next index whether to change */ if (unlikely(batch_next_node_index != next_node_index)) { @@ -176,7 +230,7 @@ static __rte_always_inline uint16_t forwarder_node_process(struct rte_graph * gr } /* Update graph stat */ - struct forwarder_stat * graph_stat = &stat_per_graph[graph_id]; + struct forwarder_stat * graph_stat = &stat_per_graph[graph->id]; graph_stat->deal_pkts += cnt; graph_stat->to_load_balance += next_node_index_counters[FORWARDER_NEXT_LB]; graph_stat->to_vwire_egress += next_node_index_counters[FORWARDER_VWIRE_EGRESS]; |
