DPDK  19.08.2
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 #define MAX_METRICS 256
28 
29 typedef struct telemetry_client {
30  char *file_path;
31  int fd;
32  TAILQ_ENTRY(telemetry_client) client_list;
33 } telemetry_client;
34 
35 typedef struct telemetry_impl {
36  int accept_fd;
37  int server_fd;
38  pthread_t thread_id;
39  int thread_status;
40  uint32_t socket_id;
41  int reg_index[RTE_MAX_ETHPORTS];
42  int metrics_register_done;
43  TAILQ_HEAD(, telemetry_client) client_list_head;
44  struct telemetry_client *request_client;
45  int register_fail_count;
46 } telemetry_impl;
47 
48 enum rte_telemetry_parser_actions {
49  ACTION_GET = 0,
50  ACTION_DELETE = 2
51 };
52 
53 enum rte_telemetry_stats_type {
54  PORT_STATS = 0,
55  GLOBAL_STATS = 1
56 };
57 
58 /* @internal */
59 struct telemetry_encode_param {
60  enum rte_telemetry_stats_type type;
61  union {
62  struct port_param {
63  int num_metric_ids;
64  uint32_t metric_ids[MAX_METRICS];
65  int num_port_ids;
66  uint32_t port_ids[RTE_MAX_ETHPORTS];
67  } pp;
68  struct global_param {
69  int num_metric_ids;
70  uint32_t metric_ids[MAX_METRICS];
71  } gp;
72  };
73 };
74 
75 int32_t
76 rte_telemetry_parse_client_message(struct telemetry_impl *telemetry, char *buf);
77 
78 int32_t
79 rte_telemetry_send_error_response(struct telemetry_impl *telemetry,
80  int error_type);
81 
82 int32_t
83 rte_telemetry_register_client(struct telemetry_impl *telemetry,
84  const char *client_path);
85 
86 int32_t
87 rte_telemetry_unregister_client(struct telemetry_impl *telemetry,
88  const char *client_path);
89 
95 int32_t
96 rte_telemetry_is_port_active(int port_id);
97 
98 int32_t
99 rte_telemetry_send_ports_stats_values(struct telemetry_encode_param *ep,
100  struct telemetry_impl *telemetry);
101 
102 int32_t
103 rte_telemetry_socket_messaging_testing(int index, int socket);
104 
105 int32_t
106 rte_telemetry_send_global_stats_values(struct telemetry_encode_param *ep,
107  struct telemetry_impl *telemetry);
108 
109 int32_t
110 rte_telemetry_parser_test(struct telemetry_impl *telemetry);
111 
112 #endif
TAILQ_HEAD(vdev_driver_list, rte_vdev_driver)