DPDK  19.02.0
rte_telemetry_internal.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Intel Corporation
3  */
4 
5 #include <rte_log.h>
6 #include <rte_tailq.h>
7 
8 #ifndef _RTE_TELEMETRY_INTERNAL_H_
9 #define _RTE_TELEMETRY_INTERNAL_H_
10 
11 /* Logging Macros */
12 extern int telemetry_log_level;
13 
14 #define TELEMETRY_LOG(level, fmt, args...) \
15  rte_log(RTE_LOG_ ##level, telemetry_log_level, "%s(): "fmt "\n", \
16  __func__, ##args)
17 
18 #define TELEMETRY_LOG_ERR(fmt, args...) \
19  TELEMETRY_LOG(ERR, fmt, ## args)
20 
21 #define TELEMETRY_LOG_WARN(fmt, args...) \
22  TELEMETRY_LOG(WARNING, fmt, ## args)
23 
24 #define TELEMETRY_LOG_INFO(fmt, args...) \
25  TELEMETRY_LOG(INFO, fmt, ## args)
26 
27 typedef struct telemetry_client {
28  char *file_path;
29  int fd;
30  TAILQ_ENTRY(telemetry_client) client_list;
31 } telemetry_client;
32 
33 typedef struct telemetry_impl {
34  int accept_fd;
35  int server_fd;
36  pthread_t thread_id;
37  int thread_status;
38  uint32_t socket_id;
39  int reg_index[RTE_MAX_ETHPORTS];
40  int metrics_register_done;
41  TAILQ_HEAD(, telemetry_client) client_list_head;
42  struct telemetry_client *request_client;
43  int register_fail_count;
44 } telemetry_impl;
45 
46 enum rte_telemetry_parser_actions {
47  ACTION_GET = 0,
48  ACTION_DELETE = 2
49 };
50 
51 int32_t
52 rte_telemetry_parse_client_message(struct telemetry_impl *telemetry, char *buf);
53 
54 int32_t
55 rte_telemetry_send_error_response(struct telemetry_impl *telemetry,
56  int error_type);
57 
58 int32_t
59 rte_telemetry_register_client(struct telemetry_impl *telemetry,
60  const char *client_path);
61 
62 int32_t
63 rte_telemetry_unregister_client(struct telemetry_impl *telemetry,
64  const char *client_path);
65 
71 int32_t
72 rte_telemetry_is_port_active(int port_id);
73 
74 int32_t
75 rte_telemetry_send_ports_stats_values(uint32_t *metric_ids, int num_metric_ids,
76  uint32_t *port_ids, int num_port_ids, struct telemetry_impl *telemetry);
77 
78 int32_t
79 rte_telemetry_socket_messaging_testing(int index, int socket);
80 
81 #endif