Move to kernel style SPDX license identifiers
[lttng-ust.git] / include / lttng / ringbuffer-config.h
index 3b7d348aa8b2d0e1f8b5be0ea00039ea13fa5e2d..dc0c00c80b5c14b2509d95cbef45290b5f6a5b9d 100644 (file)
@@ -1,33 +1,15 @@
-#ifndef _LTTNG_RING_BUFFER_CONFIG_H
-#define _LTTNG_RING_BUFFER_CONFIG_H
-
 /*
- * lttng/ringbuffer-config.h
+ * SPDX-License-Identifier: MIT
  *
- * Copyright (C) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Ring buffer configuration header. Note: after declaring the standard inline
  * functions, clients should also include linux/ringbuffer/api.h.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
+#ifndef _LTTNG_RING_BUFFER_CONFIG_H
+#define _LTTNG_RING_BUFFER_CONFIG_H
+
 #include <errno.h>
 #include "lttng/ust-tracer.h"
 #include <stdint.h>
@@ -57,7 +39,8 @@ struct lttng_ust_lib_ring_buffer_client_cb {
        size_t (*record_header_size) (const struct lttng_ust_lib_ring_buffer_config *config,
                                      struct channel *chan, size_t offset,
                                      size_t *pre_header_padding,
-                                     struct lttng_ust_lib_ring_buffer_ctx *ctx);
+                                     struct lttng_ust_lib_ring_buffer_ctx *ctx,
+                                     void *client_ctx);
 
        /* Slow path only, at subbuffer switch */
        size_t (*subbuffer_header_size) (void);
@@ -92,6 +75,13 @@ struct lttng_ust_lib_ring_buffer_client_cb {
                            size_t offset, size_t *header_len,
                            size_t *payload_len, uint64_t *timestamp,
                            struct lttng_ust_shm_handle *handle);
+       /*
+        * Offset and size of content size field in client.
+        */
+       void (*content_size_field) (const struct lttng_ust_lib_ring_buffer_config *config,
+                               size_t *offset, size_t *length);
+       void (*packet_size_field) (const struct lttng_ust_lib_ring_buffer_config *config,
+                               size_t *offset, size_t *length);
 };
 
 /*
@@ -133,7 +123,7 @@ struct lttng_ust_lib_ring_buffer_client_cb {
  * RING_BUFFER_WAKEUP_NONE does not perform any wakeup whatsoever. The client
  * has the responsibility to perform wakeups.
  */
-#define LTTNG_UST_RING_BUFFER_CONFIG_PADDING   32
+#define LTTNG_UST_RING_BUFFER_CONFIG_PADDING   20
 
 enum lttng_ust_lib_ring_buffer_alloc_types {
        RING_BUFFER_ALLOC_PER_CPU,
@@ -146,8 +136,8 @@ enum lttng_ust_lib_ring_buffer_sync_types {
 };
 
 enum lttng_ust_lib_ring_buffer_mode_types {
-       RING_BUFFER_OVERWRITE,          /* Overwrite when buffer full */
-       RING_BUFFER_DISCARD,            /* Discard when buffer full */
+       RING_BUFFER_OVERWRITE = 0,      /* Overwrite when buffer full */
+       RING_BUFFER_DISCARD = 1,        /* Discard when buffer full */
 };
 
 enum lttng_ust_lib_ring_buffer_output_types {
@@ -204,6 +194,8 @@ struct lttng_ust_lib_ring_buffer_config {
         * callbacks and update the cb pointers.
         */
        int client_type;
+       int _unused1;
+       const struct lttng_ust_lib_ring_buffer_client_cb *cb_ptr;
        char padding[LTTNG_UST_RING_BUFFER_CONFIG_PADDING];
 };
 
@@ -219,7 +211,7 @@ struct lttng_ust_lib_ring_buffer_config {
  * removed.
  */
 #define LTTNG_UST_RING_BUFFER_CTX_PADDING      \
-               (24 - sizeof(int) - sizeof(void *))
+               (24 - sizeof(int) - sizeof(void *) - sizeof(void *))
 struct lttng_ust_lib_ring_buffer_ctx {
        /* input received by lib_ring_buffer_reserve(), saved here. */
        struct channel *chan;           /* channel */
@@ -247,9 +239,22 @@ struct lttng_ust_lib_ring_buffer_ctx {
                                         */
        uint64_t tsc;                   /* time-stamp counter value */
        unsigned int rflags;            /* reservation flags */
-       unsigned int padding1;          /* padding to realign on pointer */
+       /*
+        * The field ctx_len is the length of struct
+        * lttng_ust_lib_ring_buffer_ctx as known by the user of
+        * lib_ring_buffer_ctx_init.
+        */
+       unsigned int ctx_len;
        void *ip;                       /* caller ip address */
+       void *priv2;                    /* 2nd priv data */
        char padding2[LTTNG_UST_RING_BUFFER_CTX_PADDING];
+       /*
+        * This is the end of the initial fields expected by the original ABI
+        * between probes and UST. Only the fields above can be used if
+        * ctx_len is 0. Use the value of ctx_len to find out which of the
+        * following fields may be used.
+        */
+       struct lttng_ust_lib_ring_buffer_backend_pages *backend_pages;
 };
 
 /**
@@ -265,12 +270,14 @@ static inline lttng_ust_notrace
 void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
                              struct channel *chan, void *priv,
                              size_t data_size, int largest_align,
-                             int cpu, struct lttng_ust_shm_handle *handle);
+                             int cpu, struct lttng_ust_shm_handle *handle,
+                             void *priv2);
 static inline
 void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
                              struct channel *chan, void *priv,
                              size_t data_size, int largest_align,
-                             int cpu, struct lttng_ust_shm_handle *handle)
+                             int cpu, struct lttng_ust_shm_handle *handle,
+                             void *priv2)
 {
        ctx->chan = chan;
        ctx->priv = priv;
@@ -279,8 +286,9 @@ void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
        ctx->cpu = cpu;
        ctx->rflags = 0;
        ctx->handle = handle;
-       ctx->padding1 = 0;
+       ctx->ctx_len = sizeof(struct lttng_ust_lib_ring_buffer_ctx);
        ctx->ip = 0;
+       ctx->priv2 = priv2;
        memset(ctx->padding2, 0, LTTNG_UST_RING_BUFFER_CTX_PADDING);
 }
 
@@ -320,7 +328,7 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type);
 static inline
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
 {
-       return offset_align(align_drift, size_of_type);
+       return lttng_ust_offset_align(align_drift, size_of_type);
 }
 
 #else
This page took 0.028224 seconds and 4 git commands to generate.