Remove event id parameter from event_reserve callback
[lttng-modules.git] / src / lttng-ring-buffer-event-notifier-client.h
index ea0ab66ed1fa868dd3d6701014bb9e081b18c8a3..a1c8cb323187b75ba2c3c8def9457786630d9f6e 100644 (file)
@@ -7,11 +7,14 @@
  * Copyright (C) 2010-2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  */
 
+#include <linux/limits.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <wrapper/vmalloc.h>   /* for wrapper_vmalloc_sync_mappings() */
+#include <lttng/abi.h>
 #include <lttng/events.h>
 #include <lttng/tracer.h>
+#include <wrapper/limits.h>
 
 static struct lttng_transport lttng_relay_transport;
 
@@ -20,6 +23,7 @@ struct event_notifier_packet_header {
 };
 
 struct event_notifier_record_header {
+       uint32_t payload_len;           /* in bytes */
        uint8_t header_end[0];          /* End of header */
 };
 
@@ -38,7 +42,17 @@ size_t record_header_size(const struct lib_ring_buffer_config *config,
                                 struct lib_ring_buffer_ctx *ctx,
                                 void *client_ctx)
 {
-       return 0;
+       size_t orig_offset = offset;
+       size_t padding;
+
+       padding = lib_ring_buffer_align(offset, lttng_alignof(uint32_t));
+       offset += padding;
+
+       offset += sizeof(uint32_t);
+
+       *pre_header_padding = padding;
+
+       return offset - orig_offset;
 }
 
 #include <ringbuffer/api.h>
@@ -55,7 +69,8 @@ size_t client_record_header_size(const struct lib_ring_buffer_config *config,
                                 struct lib_ring_buffer_ctx *ctx,
                                 void *client_ctx)
 {
-       return 0;
+       return record_header_size(config, chan, offset,
+                                 pre_header_padding, ctx, client_ctx);
 }
 
 /**
@@ -169,10 +184,7 @@ static void client_record_get(const struct lib_ring_buffer_config *config,
                        offsetof(struct event_notifier_record_header, header_end));
        CHAN_WARN_ON(chan, ret != offsetof(struct event_notifier_record_header, header_end));
        *header_len = offsetof(struct event_notifier_record_header, header_end);
-       /*
-        * Currently, only 64-bit event notifier ID.
-        */
-       *payload_len = sizeof(uint64_t);
+       *payload_len = header.payload_len;
        *timestamp = 0;
 }
 
@@ -274,15 +286,36 @@ void lttng_buffer_read_close(struct lib_ring_buffer *buf)
 }
 
 static
-int lttng_event_reserve(struct lib_ring_buffer_ctx *ctx, uint32_t event_id)
+void lttng_write_event_notifier_header(const struct lib_ring_buffer_config *config,
+                           struct lib_ring_buffer_ctx *ctx)
+{
+       uint32_t data_size;
+
+       WARN_ON_ONCE(ctx->data_size > U32_MAX);
+
+       data_size = (uint32_t) ctx->data_size;
+
+       lib_ring_buffer_write(config, ctx, &data_size, sizeof(data_size));
+
+       lib_ring_buffer_align_ctx(ctx, ctx->largest_align);
+}
+
+static
+int lttng_event_reserve(struct lib_ring_buffer_ctx *ctx)
 {
+       struct channel *chan = ctx->client_priv;
        int ret;
 
+       memset(&ctx->priv, 0, sizeof(ctx->priv));
+       ctx->priv.chan = chan;
+
        ret = lib_ring_buffer_reserve(&client_config, ctx, NULL);
        if (ret)
                return ret;
        lib_ring_buffer_backend_get_pages(&client_config, ctx,
-                       &ctx->backend_pages);
+                       &ctx->priv.backend_pages);
+
+       lttng_write_event_notifier_header(&client_config, ctx);
        return 0;
 }
 
This page took 0.024052 seconds and 4 git commands to generate.