Move LTTng-UST buffer ownership from application to consumer
[lttng-tools.git] / src / common / sessiond-comm / sessiond-comm.h
index e69c32bb2dfc80392a17532592057008535e3a44..c390a9f5284a573a49f0c524750f5d7c66eaf25f 100644 (file)
@@ -31,6 +31,7 @@
 #include <common/compat/socket.h>
 #include <common/uri.h>
 #include <common/defaults.h>
+#include <common/compat/uuid.h>
 
 #include <arpa/inet.h>
 #include <netinet/in.h>
 
 enum lttcomm_sessiond_command {
        /* Tracer command */
-       LTTNG_ADD_CONTEXT,
-       LTTNG_CALIBRATE,
-       LTTNG_DISABLE_CHANNEL,
-       LTTNG_DISABLE_EVENT,
-       LTTNG_DISABLE_ALL_EVENT,
-       LTTNG_ENABLE_CHANNEL,
-       LTTNG_ENABLE_EVENT,
-       LTTNG_ENABLE_ALL_EVENT,
+       LTTNG_ADD_CONTEXT                   = 0,
+       LTTNG_CALIBRATE                     = 1,
+       LTTNG_DISABLE_CHANNEL               = 2,
+       LTTNG_DISABLE_EVENT                 = 3,
+       LTTNG_DISABLE_ALL_EVENT             = 4,
+       LTTNG_ENABLE_CHANNEL                = 5,
+       LTTNG_ENABLE_EVENT                  = 6,
+       LTTNG_ENABLE_ALL_EVENT              = 7,
        /* Session daemon command */
-       LTTNG_CREATE_SESSION,
-       LTTNG_DESTROY_SESSION,
-       LTTNG_LIST_CHANNELS,
-       LTTNG_LIST_DOMAINS,
-       LTTNG_LIST_EVENTS,
-       LTTNG_LIST_SESSIONS,
-       LTTNG_LIST_TRACEPOINTS,
-       LTTNG_REGISTER_CONSUMER,
-       LTTNG_START_TRACE,
-       LTTNG_STOP_TRACE,
-       LTTNG_LIST_TRACEPOINT_FIELDS,
+       LTTNG_CREATE_SESSION                = 8,
+       LTTNG_DESTROY_SESSION               = 9,
+       LTTNG_LIST_CHANNELS                 = 10,
+       LTTNG_LIST_DOMAINS                  = 11,
+       LTTNG_LIST_EVENTS                   = 12,
+       LTTNG_LIST_SESSIONS                 = 13,
+       LTTNG_LIST_TRACEPOINTS              = 14,
+       LTTNG_REGISTER_CONSUMER             = 15,
+       LTTNG_START_TRACE                   = 16,
+       LTTNG_STOP_TRACE                    = 17,
+       LTTNG_LIST_TRACEPOINT_FIELDS        = 18,
 
        /* Consumer */
-       LTTNG_DISABLE_CONSUMER,
-       LTTNG_ENABLE_CONSUMER,
-       LTTNG_SET_CONSUMER_URI,
-       /* Relay daemon */
-       RELAYD_ADD_STREAM,
-       RELAYD_CREATE_SESSION,
-       RELAYD_START_DATA,
-       RELAYD_UPDATE_SYNC_INFO,
-       RELAYD_VERSION,
-       RELAYD_SEND_METADATA,
-       RELAYD_CLOSE_STREAM,
-       RELAYD_DATA_PENDING,
-       RELAYD_QUIESCENT_CONTROL,
-       LTTNG_SET_FILTER,
-       LTTNG_HEALTH_CHECK,
-       LTTNG_DATA_PENDING,
+       LTTNG_DISABLE_CONSUMER              = 19,
+       LTTNG_ENABLE_CONSUMER               = 20,
+       LTTNG_SET_CONSUMER_URI              = 21,
+       LTTNG_ENABLE_EVENT_WITH_FILTER      = 22,
+       LTTNG_HEALTH_CHECK                  = 23,
+       LTTNG_DATA_PENDING                  = 24,
+};
+
+enum lttcomm_relayd_command {
+       RELAYD_ADD_STREAM                   = 1,
+       RELAYD_CREATE_SESSION               = 2,
+       RELAYD_START_DATA                   = 3,
+       RELAYD_UPDATE_SYNC_INFO             = 4,
+       RELAYD_VERSION                      = 5,
+       RELAYD_SEND_METADATA                = 6,
+       RELAYD_CLOSE_STREAM                 = 7,
+       RELAYD_DATA_PENDING                 = 8,
+       RELAYD_QUIESCENT_CONTROL            = 9,
+       RELAYD_BEGIN_DATA_PENDING           = 10,
+       RELAYD_END_DATA_PENDING             = 11,
 };
 
 /*
@@ -111,6 +116,7 @@ enum lttcomm_return_code {
        LTTCOMM_CONSUMERD_SPLICE_EINVAL,            /* EINVAL from splice(2) */
        LTTCOMM_CONSUMERD_SPLICE_ENOMEM,            /* ENOMEM from splice(2) */
        LTTCOMM_CONSUMERD_SPLICE_ESPIPE,            /* ESPIPE from splice(2) */
+       LTTCOMM_CONSUMERD_ENOMEM,                   /* Consumer is out of memory */
 
        /* MUST be last element */
        LTTCOMM_NR,                                             /* Last element */
@@ -136,14 +142,14 @@ struct lttcomm_sockaddr {
                struct sockaddr_in sin;
                struct sockaddr_in6 sin6;
        } addr;
-};
+} LTTNG_PACKED;
 
 struct lttcomm_sock {
        int fd;
        enum lttcomm_sock_proto proto;
        struct lttcomm_sockaddr sockaddr;
        const struct lttcomm_proto_ops *ops;
-};
+} LTTNG_PACKED;
 
 struct lttcomm_net_family {
        int family;
@@ -173,44 +179,39 @@ struct lttcomm_session_msg {
                struct {
                        char channel_name[LTTNG_SYMBOL_NAME_LEN];
                        char name[NAME_MAX];
-               } disable;
+               } LTTNG_PACKED disable;
                /* Event data */
                struct {
                        char channel_name[LTTNG_SYMBOL_NAME_LEN];
                        struct lttng_event event;
-               } enable;
+                       /* Length of following bytecode for filter. */
+                       uint32_t bytecode_len;
+               } LTTNG_PACKED enable;
                /* Create channel */
                struct {
                        struct lttng_channel chan;
-               } channel;
+               } LTTNG_PACKED channel;
                /* Context */
                struct {
                        char channel_name[LTTNG_SYMBOL_NAME_LEN];
-                       char event_name[LTTNG_SYMBOL_NAME_LEN];
                        struct lttng_event_context ctx;
-               } context;
+               } LTTNG_PACKED context;
                /* Use by register_consumer */
                struct {
                        char path[PATH_MAX];
-               } reg;
+               } LTTNG_PACKED reg;
                /* List */
                struct {
                        char channel_name[LTTNG_SYMBOL_NAME_LEN];
-               } list;
+               } LTTNG_PACKED list;
                struct lttng_calibrate calibrate;
                /* Used by the set_consumer_url and used by create_session also call */
                struct {
                        /* Number of lttng_uri following */
                        uint32_t size;
-               } uri;
-               struct {
-                       char channel_name[LTTNG_SYMBOL_NAME_LEN];
-                       char event_name[LTTNG_SYMBOL_NAME_LEN];
-                       /* Length of following bytecode */
-                       uint32_t bytecode_len;
-               } filter;
+               } LTTNG_PACKED uri;
        } u;
-};
+} LTTNG_PACKED;
 
 #define LTTNG_FILTER_MAX_LEN   65536
 
@@ -219,11 +220,14 @@ struct lttcomm_session_msg {
  * bytecode. It is made of tuples: (uint16_t, var. len. string). It
  * starts at reloc_table_offset.
  */
+#define LTTNG_FILTER_PADDING   32
 struct lttng_filter_bytecode {
        uint32_t len;   /* len of data */
        uint32_t reloc_table_offset;
+       uint64_t seqnum;
+       char padding[LTTNG_FILTER_PADDING];
        char data[0];
-};
+} LTTNG_PACKED;
 
 /*
  * Data structure for the response from sessiond to the lttng client.
@@ -235,16 +239,16 @@ struct lttcomm_lttng_msg {
        uint32_t data_size;
        /* Contains: trace_name + data */
        char payload[];
-};
+} LTTNG_PACKED;
 
 struct lttcomm_health_msg {
        uint32_t component;
        uint32_t cmd;
-};
+} LTTNG_PACKED;
 
 struct lttcomm_health_data {
        uint32_t ret_code;
-};
+} LTTNG_PACKED;
 
 /*
  * lttcomm_consumer_msg is the message sent from sessiond to consumerd
@@ -256,42 +260,75 @@ struct lttcomm_consumer_msg {
        union {
                struct {
                        int channel_key;
-                       uint64_t max_sb_size; /* the subbuffer size for this channel */
-                       /* shm_fd and wait_fd are sent as ancillary data */
-                       uint64_t mmap_len;
+                       uint64_t session_id;
+                       char pathname[PATH_MAX];
+                       uid_t uid;
+                       gid_t gid;
+                       int relayd_id;
                        /* nb_init_streams is the number of streams open initially. */
                        unsigned int nb_init_streams;
                        char name[LTTNG_SYMBOL_NAME_LEN];
-               } channel;
+                       /* Use splice or mmap to consume this fd */
+                       enum lttng_event_output output;
+                       int type; /* Per cpu or metadata. */
+               } LTTNG_PACKED channel; /* Only used by Kernel. */
                struct {
-                       int channel_key;
                        int stream_key;
-                       /* shm_fd and wait_fd are sent as ancillary data */
-                       uint32_t state;    /* enum lttcomm_consumer_fd_state */
-                       enum lttng_event_output output; /* use splice or mmap to consume this fd */
-                       uint64_t mmap_len;
-                       uid_t uid;         /* User ID owning the session */
-                       gid_t gid;         /* Group ID owning the session */
-                       char path_name[PATH_MAX];
-                       int net_index;
-                       unsigned int metadata_flag;
-                       char name[DEFAULT_STREAM_NAME_LEN];  /* Name string of the stream */
-                       uint64_t session_id;   /* Tracing session id of the stream */
-               } stream;
+                       int channel_key;
+                       int cpu;        /* On which CPU this stream is assigned. */
+               } LTTNG_PACKED stream;  /* Only used by Kernel. */
                struct {
                        int net_index;
                        enum lttng_stream_type type;
                        /* Open socket to the relayd */
                        struct lttcomm_sock sock;
-               } relayd_sock;
+                       /* Tracing session id associated to the relayd. */
+                       uint64_t session_id;
+               } LTTNG_PACKED relayd_sock;
                struct {
                        uint64_t net_seq_idx;
-               } destroy_relayd;
+               } LTTNG_PACKED destroy_relayd;
                struct {
                        uint64_t session_id;
-               } data_pending;
+               } LTTNG_PACKED data_pending;
+               struct {
+                       uint64_t subbuf_size;                           /* bytes */
+                       uint64_t num_subbuf;                            /* power of 2 */
+                       int overwrite;                                          /* 1: overwrite, 0: discard */
+                       unsigned int switch_timer_interval;     /* usec */
+                       unsigned int read_timer_interval;       /* usec */
+                       int output;                                                     /* splice, mmap */
+                       int type;                                                       /* metadata or per_cpu */
+                       uint64_t session_id;                            /* Tracing session id */
+                       char pathname[PATH_MAX];                        /* Channel file path. */
+                       char name[LTTNG_SYMBOL_NAME_LEN];       /* Channel name. */
+                       uid_t uid;                                                      /* User ID of the session */
+                       gid_t gid;                                                      /* Group ID ot the session */
+                       int relayd_id;                                          /* Relayd id if apply. */
+                       unsigned long key;                                      /* Unique channel key. */
+                       unsigned char uuid[UUID_STR_LEN];       /* uuid for ust tracer. */
+               } LTTNG_PACKED ask_channel;
+               struct {
+                       unsigned long key;
+               } LTTNG_PACKED get_channel;
+               struct {
+                       unsigned long key;
+               } LTTNG_PACKED destroy_channel;
        } u;
-};
+} LTTNG_PACKED;
+
+/*
+ * Status message returned to the sessiond after a received command.
+ */
+struct lttcomm_consumer_status_msg {
+       enum lttng_error_code ret_code;
+} LTTNG_PACKED;
+
+struct lttcomm_consumer_status_channel {
+       enum lttng_error_code ret_code;
+       unsigned long key;
+       unsigned int stream_count;
+} LTTNG_PACKED;
 
 #ifdef HAVE_LIBLTTNG_UST_CTL
 
@@ -310,7 +347,7 @@ struct lttcomm_ust_msg {
                struct lttng_ust_context context;
                struct lttng_ust_tracer_version version;
        } u;
-};
+} LTTNG_PACKED;
 
 /*
  * Data structure for the response from UST to the session daemon.
@@ -324,13 +361,13 @@ struct lttcomm_ust_reply {
        union {
                struct {
                        uint64_t memory_map_size;
-               } channel;
+               } LTTNG_PACKED channel;
                struct {
                        uint64_t memory_map_size;
-               } stream;
+               } LTTNG_PACKED stream;
                struct lttng_ust_tracer_version version;
        } u;
-};
+} LTTNG_PACKED;
 
 #endif /* HAVE_LIBLTTNG_UST_CTL */
 
This page took 0.029093 seconds and 4 git commands to generate.