DEPDIRS-librte_cfgfile := librte_eal
DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline
DEPDIRS-librte_cmdline := librte_eal librte_net
+DIRS-$(CONFIG_RTE_LIBRTE_TELEMETRY) += librte_telemetry
+DEPDIRS-librte_telemetry := librte_eal
DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ethdev
DEPDIRS-librte_ethdev := librte_net librte_eal librte_mempool librte_ring
DEPDIRS-librte_ethdev += librte_mbuf
DEPDIRS-librte_jobstats := librte_eal
DIRS-$(CONFIG_RTE_LIBRTE_METRICS) += librte_metrics
DEPDIRS-librte_metrics := librte_eal librte_ethdev
+ifeq ($(CONFIG_RTE_LIBRTE_TELEMETRY),y)
+DEPDIRS-librte_metrics += librte_telemetry
+endif
DIRS-$(CONFIG_RTE_LIBRTE_BITRATE) += librte_bitratestats
DEPDIRS-librte_bitratestats := librte_eal librte_metrics librte_ethdev
DIRS-$(CONFIG_RTE_LIBRTE_LATENCY_STATS) += librte_latencystats
DIRS-$(CONFIG_RTE_LIBRTE_IPSEC) += librte_ipsec
DEPDIRS-librte_ipsec := librte_eal librte_mbuf librte_cryptodev librte_security \
librte_net librte_hash
-DIRS-$(CONFIG_RTE_LIBRTE_TELEMETRY) += librte_telemetry
-DEPDIRS-librte_telemetry := librte_eal librte_metrics librte_ethdev
DIRS-$(CONFIG_RTE_LIBRTE_RCU) += librte_rcu
DEPDIRS-librte_rcu := librte_eal librte_ring
SRCS-y += rte_metrics_telemetry.c
SYMLINK-$(CONFIG_RTE_LIBRTE_METRICS)-include += rte_metrics_telemetry.h
-LDLIBS += -lrte_ethdev
+LDLIBS += -lrte_ethdev -lrte_telemetry
LDLIBS += -ljansson
+CFLAGS += -I$(RTE_SDK)/lib/librte_telemetry/
endif
# Install header file
ext_deps += jansson
sources += files('rte_metrics_telemetry.c')
headers = files('rte_metrics_telemetry.h')
- deps += ['ethdev']
+ deps += ['ethdev', 'telemetry']
+ includes += include_directories('../librte_telemetry')
endif
#include <rte_memzone.h>
#include <rte_spinlock.h>
+int metrics_initialized;
+
#define RTE_METRICS_MEMZONE_NAME "RTE_METRICS"
/**
struct rte_metrics_data_s *stats;
const struct rte_memzone *memzone;
+ if (metrics_initialized)
+ return;
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return;
stats = memzone->addr;
memset(stats, 0, sizeof(struct rte_metrics_data_s));
rte_spinlock_init(&stats->lock);
+ metrics_initialized = 1;
}
int
extern "C" {
#endif
+extern int metrics_initialized;
+
/** Maximum length of metric name (including null-terminator) */
#define RTE_METRICS_MAX_NAME_LEN 64
#define RTE_METRICS_MAX_METRICS 256
#include <rte_ethdev.h>
#include <rte_string_fns.h>
+#ifdef RTE_LIBRTE_TELEMETRY
+#include <rte_telemetry_internal.h>
+#endif
#include "rte_metrics.h"
#include "rte_metrics_telemetry.h"
int ret, nb_drv_idx = 0;
uint16_t d;
+ rte_metrics_init(rte_socket_id());
RTE_ETH_FOREACH_DEV(d) {
int i;
/* Different device types have different numbers of stats, so
RTE_INIT(metrics_ctor)
{
+#ifdef RTE_LIBRTE_TELEMETRY
+ static const struct metrics_functions fns = {
+ .reg_all_ethdev = rte_metrics_tel_reg_all_ethdev,
+ .encode_json_format = rte_metrics_tel_encode_json_format,
+ .get_port_stats_ids = rte_metrics_tel_get_port_stats_ids,
+ .get_ports_stats_json = rte_metrics_tel_get_ports_stats_json,
+ .extract_data = rte_metrics_tel_extract_data
+ };
+ rte_telemetry_set_metrics_fns(&fns); /* assign them to telemetry lib */
+#endif
metrics_log_level = rte_log_register("lib.metrics");
if (metrics_log_level >= 0)
rte_log_set_level(metrics_log_level, RTE_LOG_ERR);
CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)
+CFLAGS += -I$(RTE_SDK)/lib/librte_metrics/
-LDLIBS += -lrte_eal -lrte_ethdev
-LDLIBS += -lrte_metrics
+LDLIBS += -lrte_eal
LDLIBS += -lpthread
LDLIBS += -ljansson
sources = files('rte_telemetry.c', 'rte_telemetry_parser.c', 'rte_telemetry_parser_test.c')
headers = files('rte_telemetry.h', 'rte_telemetry_internal.h', 'rte_telemetry_parser.h')
-deps += ['metrics', 'ethdev']
+includes += include_directories('../librte_metrics')
jansson = dependency('jansson', required: false)
if jansson.found()
#include <jansson.h>
#include <rte_eal.h>
-#include <rte_ethdev.h>
#include <rte_metrics.h>
#include <rte_option.h>
#include <rte_string_fns.h>
+#include <rte_lcore.h>
#include "rte_telemetry.h"
#include "rte_telemetry_internal.h"
int stat_value;
};
+/* global array of functions pointers to metrics library */
+const struct metrics_functions *metrics_fns;
+
+void
+rte_telemetry_set_metrics_fns(const struct metrics_functions *fns)
+{
+ metrics_fns = fns;
+}
+
static void
rte_telemetry_get_runtime_dir(char *socket_path, size_t size)
{
return -1;
}
- ret = rte_metrics_tel_encode_json_format(ep, &json_buffer);
+ ret = metrics_fns->encode_json_format(ep, &json_buffer);
if (ret < 0) {
TELEMETRY_LOG_ERR("JSON encode function failed");
ret = rte_telemetry_send_error_response(telemetry, ret);
goto einval_fail;
}
- ret = rte_metrics_tel_get_ports_stats_json(ep, telemetry->reg_index,
+ ret = metrics_fns->get_ports_stats_json(ep, telemetry->reg_index,
&json_buffer);
if (ret < 0) {
TELEMETRY_LOG_ERR("Function for get_ports_stats_json"
int ret;
int selftest = 0;
- ret = rte_metrics_tel_reg_all_ethdev(
- &telemetry->metrics_register_done,
+ ret = metrics_fns->reg_all_ethdev(&telemetry->metrics_register_done,
telemetry->reg_index);
if (ret < 0) {
TELEMETRY_LOG_ERR("Failed to register ethdev metrics");
}
static_telemetry->socket_id = rte_socket_id();
- rte_metrics_init(static_telemetry->socket_id);
ret = pthread_attr_init(&attr);
if (ret != 0) {
#ifndef _RTE_TELEMETRY_INTERNAL_H_
#define _RTE_TELEMETRY_INTERNAL_H_
+/* function types for the functions coming from metrics library */
+typedef int32_t (*metrics_tel_reg_all_ethdev_t)(int *metrics_register_done,
+ int *reg_index_list);
+
+typedef int32_t (*metrics_tel_encode_json_format_t)(
+ struct telemetry_encode_param *ep, char **json_buffer);
+
+typedef int32_t (*metrics_tel_get_port_stats_ids_t)(
+ struct telemetry_encode_param *ep);
+
+typedef int32_t (*metrics_tel_get_ports_stats_json_t)(
+ struct telemetry_encode_param *ep,
+ int *reg_index, char **json_buffer);
+
+typedef int32_t (*metrics_tel_extract_data_t)(struct telemetry_encode_param *ep,
+ json_t *data);
+
+struct metrics_functions {
+ metrics_tel_reg_all_ethdev_t reg_all_ethdev;
+ metrics_tel_encode_json_format_t encode_json_format;
+ metrics_tel_get_port_stats_ids_t get_port_stats_ids;
+ metrics_tel_get_ports_stats_json_t get_ports_stats_json;
+ metrics_tel_extract_data_t extract_data;
+};
+extern const struct metrics_functions *metrics_fns;
+
+/* API for use by metrics libraries to provide the functions to use */
+__rte_experimental
+void rte_telemetry_set_metrics_fns(const struct metrics_functions *fns);
+
/* Logging Macros */
extern int telemetry_log_level;
#include <rte_metrics.h>
#include <rte_common.h>
-#include <rte_ethdev.h>
#include <rte_metrics_telemetry.h>
#include "rte_telemetry_internal.h"
return -1;
}
- ret = rte_metrics_tel_get_port_stats_ids(&ep);
+ ret = metrics_fns->get_port_stats_ids(&ep);
if (ret < 0) {
TELEMETRY_LOG_ERR("Could not get ports stat values");
ret = rte_telemetry_send_error_response(telemetry, ret);
return -1;
}
- ret = rte_metrics_tel_extract_data(&ep, data);
+ ret = metrics_fns->extract_data(&ep, data);
if (ret < 0) {
TELEMETRY_LOG_ERR("Extracting JSON data failed");
ret = rte_telemetry_send_error_response(telemetry, ret);
rte_telemetry_init;
rte_telemetry_parse;
rte_telemetry_selftest;
+ rte_telemetry_set_metrics_fns;
local: *;
};
libraries = [
'kvargs', # eal depends on kvargs
'eal', # everything depends on eal
+ 'telemetry',
'ring',
'rcu', # rcu depends on ring
'mempool', 'mbuf', 'net', 'meter', 'ethdev', 'pci', # core
# add pkt framework libs which use other libs from above
'port', 'table', 'pipeline',
# flow_classify lib depends on pkt framework table lib
- 'flow_classify', 'bpf', 'graph', 'node', 'telemetry']
+ 'flow_classify', 'bpf', 'graph', 'node']
if is_windows
libraries = ['kvargs','eal'] # only supported libraries for windows
_LDLIBS-$(CONFIG_RTE_LIBRTE_RIB) += -lrte_rib
_LDLIBS-$(CONFIG_RTE_LIBRTE_LPM) += -lrte_lpm
_LDLIBS-$(CONFIG_RTE_LIBRTE_ACL) += -lrte_acl
-_LDLIBS-$(CONFIG_RTE_LIBRTE_TELEMETRY) += --no-as-needed
-_LDLIBS-$(CONFIG_RTE_LIBRTE_TELEMETRY) += --whole-archive
-_LDLIBS-$(CONFIG_RTE_LIBRTE_TELEMETRY) += -lrte_telemetry -ljansson
-_LDLIBS-$(CONFIG_RTE_LIBRTE_TELEMETRY) += --no-whole-archive
-_LDLIBS-$(CONFIG_RTE_LIBRTE_TELEMETRY) += --as-needed
_LDLIBS-$(CONFIG_RTE_LIBRTE_JOBSTATS) += -lrte_jobstats
_LDLIBS-$(CONFIG_RTE_LIBRTE_METRICS) += --whole-archive
_LDLIBS-$(CONFIG_RTE_LIBRTE_METRICS) += -lrte_metrics
_LDLIBS-$(CONFIG_RTE_LIBRTE_OCTEONTX2_MEMPOOL) += -lrte_mempool_octeontx2
_LDLIBS-$(CONFIG_RTE_LIBRTE_RING) += -lrte_ring
_LDLIBS-$(CONFIG_RTE_LIBRTE_PCI) += -lrte_pci
+_LDLIBS-$(CONFIG_RTE_LIBRTE_TELEMETRY) += -lrte_telemetry -ljansson
_LDLIBS-$(CONFIG_RTE_LIBRTE_EAL) += -lrte_eal
_LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE) += -lrte_cmdline
_LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER) += -lrte_reorder