return NULL;
}
+static void
+trace_point_dump(FILE *f, struct trace_point *tp)
+{
+ rte_trace_point_t *handle = tp->handle;
+
+ fprintf(f, "\tid %d, %s, size is %d, %s\n",
+ trace_id_get(handle), tp->name,
+ (uint16_t)(*handle & __RTE_TRACE_FIELD_SIZE_MASK),
+ rte_trace_point_is_enabled(handle) ? "enabled" : "disabled");
+}
+
+static void
+trace_lcore_mem_dump(FILE *f)
+{
+ struct trace *trace = trace_obj_get();
+ struct __rte_trace_header *header;
+ uint32_t count;
+
+ if (trace->nb_trace_mem_list == 0)
+ return;
+
+ rte_spinlock_lock(&trace->lock);
+ fprintf(f, "nb_trace_mem_list = %d\n", trace->nb_trace_mem_list);
+ fprintf(f, "\nTrace mem info\n--------------\n");
+ for (count = 0; count < trace->nb_trace_mem_list; count++) {
+ header = trace->lcore_meta[count].mem;
+ fprintf(f, "\tid %d, mem=%p, area=%s, lcore_id=%d, name=%s\n",
+ count, header,
+ trace_area_to_string(trace->lcore_meta[count].area),
+ header->stream_header.lcore_id,
+ header->stream_header.thread_name);
+ }
+ rte_spinlock_unlock(&trace->lock);
+}
+
+void
+rte_trace_dump(FILE *f)
+{
+ struct trace_point_head *tp_list = trace_list_head_get();
+ struct trace *trace = trace_obj_get();
+ struct trace_point *tp;
+
+ fprintf(f, "\nGlobal info\n-----------\n");
+ fprintf(f, "status = %s\n",
+ rte_trace_is_enabled() ? "enabled" : "disabled");
+ fprintf(f, "mode = %s\n",
+ trace_mode_to_string(rte_trace_mode_get()));
+ fprintf(f, "dir = %s\n", trace->dir);
+ fprintf(f, "buffer len = %d\n", trace->buff_len);
+ fprintf(f, "number of trace points = %d\n", trace->nb_trace_points);
+
+ trace_lcore_mem_dump(f);
+ fprintf(f, "\nTrace point info\n----------------\n");
+ STAILQ_FOREACH(tp, tp_list, next)
+ trace_point_dump(f, tp);
+}
+
void
__rte_trace_mem_per_thread_alloc(void)
{
}
}
+static void
+meta_fix_freq(struct trace *trace, char *meta)
+{
+ char *str;
+ int rc;
+
+ str = RTE_PTR_ADD(meta, trace->ctf_meta_offset_freq);
+ rc = sprintf(str, "%20"PRIu64"", rte_get_timer_hz());
+ str[rc] = ';';
+}
+
+static void
+meta_fix_freq_offset(struct trace *trace, char *meta)
+{
+ uint64_t uptime_tickes_floor, uptime_ticks, freq, uptime_sec;
+ uint64_t offset, offset_s;
+ char *str;
+ int rc;
+
+ uptime_ticks = trace->uptime_ticks &
+ ((1ULL << __RTE_TRACE_EVENT_HEADER_ID_SHIFT) - 1);
+ freq = rte_get_tsc_hz();
+ uptime_tickes_floor = RTE_ALIGN_MUL_FLOOR(uptime_ticks, freq);
+
+ uptime_sec = uptime_tickes_floor / freq;
+ offset_s = trace->epoch_sec - uptime_sec;
+
+ offset = uptime_ticks - uptime_tickes_floor;
+ offset += trace->epoch_nsec * (freq / NSEC_PER_SEC);
+
+ str = RTE_PTR_ADD(meta, trace->ctf_meta_offset_freq_off_s);
+ rc = sprintf(str, "%20"PRIu64"", offset_s);
+ str[rc] = ';';
+ str = RTE_PTR_ADD(meta, trace->ctf_meta_offset_freq_off);
+ rc = sprintf(str, "%20"PRIu64"", offset);
+ str[rc] = ';';
+}
+
+static void
+meta_fixup(struct trace *trace, char *meta)
+{
+ meta_fix_freq(trace, meta);
+ meta_fix_freq_offset(trace, meta);
+}
+
+int
+rte_trace_metadata_dump(FILE *f)
+{
+ struct trace *trace = trace_obj_get();
+ char *ctf_meta = trace->ctf_meta;
+ int rc;
+
+ if (!rte_trace_is_enabled())
+ return 0;
+
+ if (ctf_meta == NULL)
+ return -EINVAL;
+
+ if (!__atomic_load_n(&trace->ctf_fixup_done, __ATOMIC_SEQ_CST) &&
+ rte_get_timer_hz()) {
+ meta_fixup(trace, ctf_meta);
+ __atomic_store_n(&trace->ctf_fixup_done, 1, __ATOMIC_SEQ_CST);
+ }
+
+ rc = fprintf(f, "%s", ctf_meta);
+ return rc < 0 ? rc : 0;
+}