Path: blob/master/tools/virtio/virtio-trace/trace-agent.h
26282 views
/* SPDX-License-Identifier: GPL-2.0 */1#ifndef __TRACE_AGENT_H__2#define __TRACE_AGENT_H__3#include <pthread.h>4#include <stdbool.h>56#define MAX_CPUS 2567#define PIPE_INIT (1024*1024)89/*10* agent_info - structure managing total information of guest agent11* @pipe_size: size of pipe (default 1MB)12* @use_stdout: set to true when o option is added (default false)13* @cpus: total number of CPUs14* @ctl_fd: fd of control path, /dev/virtio-ports/agent-ctl-path15* @rw_ti: structure managing information of read/write threads16*/17struct agent_info {18unsigned long pipe_size;19bool use_stdout;20int cpus;21int ctl_fd;22struct rw_thread_info *rw_ti[MAX_CPUS];23};2425/*26* rw_thread_info - structure managing a read/write thread a cpu27* @cpu_num: cpu number operating this read/write thread28* @in_fd: fd of reading trace data path in cpu_num29* @out_fd: fd of writing trace data path in cpu_num30* @read_pipe: fd of read pipe31* @write_pipe: fd of write pipe32* @pipe_size: size of pipe (default 1MB)33*/34struct rw_thread_info {35int cpu_num;36int in_fd;37int out_fd;38int read_pipe;39int write_pipe;40unsigned long pipe_size;41};4243/* use for stopping rw threads */44extern bool global_sig_receive;4546/* use for notification */47extern bool global_run_operation;48extern pthread_mutex_t mutex_notify;49extern pthread_cond_t cond_wakeup;5051/* for controller of read/write threads */52extern int rw_ctl_init(const char *ctl_path);53extern void *rw_ctl_loop(int ctl_fd);5455/* for trace read/write thread */56extern void *rw_thread_info_new(void);57extern void *rw_thread_init(int cpu, const char *in_path, const char *out_path,58bool stdout_flag, unsigned long pipe_size,59struct rw_thread_info *rw_ti);60extern pthread_t rw_thread_run(struct rw_thread_info *rw_ti);6162static inline void *zalloc(size_t size)63{64return calloc(1, size);65}6667#define pr_err(format, ...) fprintf(stderr, format, ## __VA_ARGS__)68#define pr_info(format, ...) fprintf(stdout, format, ## __VA_ARGS__)69#ifdef DEBUG70#define pr_debug(format, ...) fprintf(stderr, format, ## __VA_ARGS__)71#else72#define pr_debug(format, ...) do {} while (0)73#endif7475#endif /*__TRACE_AGENT_H__*/767778