Move LTTng-UST buffer ownership from application to consumer
[lttng-tools.git] / src / common / sessiond-comm / sessiond-comm.h
index 3511f04ead3716a9c0638398f211013c8bacc476..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                                       = 1,
-       LTTNG_CALIBRATE                                         = 2,
-       LTTNG_DISABLE_CHANNEL                           = 3,
-       LTTNG_DISABLE_EVENT                                     = 4,
-       LTTNG_DISABLE_ALL_EVENT                         = 5,
-       LTTNG_ENABLE_CHANNEL                            = 6,
-       LTTNG_ENABLE_EVENT                                      = 7,
-       LTTNG_ENABLE_ALL_EVENT                          = 8,
+       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                            = 9,
-       LTTNG_DESTROY_SESSION                           = 10,
-       LTTNG_LIST_CHANNELS                 = 11,
-       LTTNG_LIST_DOMAINS                  = 12,
-       LTTNG_LIST_EVENTS                   = 13,
-       LTTNG_LIST_SESSIONS                 = 14,
-       LTTNG_LIST_TRACEPOINTS              = 15,
-       LTTNG_REGISTER_CONSUMER             = 16,
-       LTTNG_START_TRACE                   = 17,
-       LTTNG_STOP_TRACE                    = 18,
-       LTTNG_LIST_TRACEPOINT_FIELDS        = 19,
+       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              = 20,
-       LTTNG_ENABLE_CONSUMER               = 21,
-       LTTNG_SET_CONSUMER_URI              = 22,
-       /* Relay daemon */
-       RELAYD_ADD_STREAM                   = 23,
-       RELAYD_CREATE_SESSION               = 24,
-       RELAYD_START_DATA                   = 25,
-       RELAYD_UPDATE_SYNC_INFO             = 26,
-       RELAYD_VERSION                      = 27,
-       RELAYD_SEND_METADATA                = 28,
-       RELAYD_CLOSE_STREAM                 = 29,
-       RELAYD_DATA_PENDING                 = 30,
-       RELAYD_QUIESCENT_CONTROL            = 31,
-       LTTNG_ENABLE_EVENT_WITH_FILTER      = 32,
-       LTTNG_HEALTH_CHECK                  = 33,
-       LTTNG_DATA_PENDING                  = 34,
-       RELAYD_BEGIN_DATA_PENDING           = 35,
-       RELAYD_END_DATA_PENDING             = 36,
+       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,
 };
 
 /*
@@ -113,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 */
@@ -256,28 +260,23 @@ 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];
-               } LTTNG_PACKED 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 */
-               } LTTNG_PACKED 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;
@@ -292,6 +291,29 @@ struct lttcomm_consumer_msg {
                struct {
                        uint64_t session_id;
                } 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;
 
@@ -302,6 +324,12 @@ 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
 
 #include <lttng/ust-abi.h>
This page took 0.025804 seconds and 4 git commands to generate.