Add a packet sequence number
[lttng-modules.git] / lib / ringbuffer / backend_types.h
index 1d301de2e178f8bc992ceb842ff8a4522f359618..8c53d0754eee633e4bf958c11a82f77fbb95322e 100644 (file)
@@ -1,14 +1,26 @@
-#ifndef _LINUX_RING_BUFFER_BACKEND_TYPES_H
-#define _LINUX_RING_BUFFER_BACKEND_TYPES_H
+#ifndef _LIB_RING_BUFFER_BACKEND_TYPES_H
+#define _LIB_RING_BUFFER_BACKEND_TYPES_H
 
 /*
- * linux/ringbuffer/backend_types.h
- *
- * Copyright (C) 2008-2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * lib/ringbuffer/backend_types.h
  *
  * Ring buffer backend (types).
  *
- * Dual LGPL v2.1/GPL v2 license.
+ * Copyright (C) 2008-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <linux/cpumask.h>
@@ -32,6 +44,16 @@ struct lib_ring_buffer_backend_subbuffer {
        unsigned long id;               /* backend subbuffer identifier */
 };
 
+struct lib_ring_buffer_backend_counts {
+       /*
+        * Counter specific to the sub-buffer location within the ring buffer.
+        * The actual sequence number of the packet within the entire ring
+        * buffer can be derived from the formula nr_subbuffers * seq_cnt +
+        * subbuf_idx.
+        */
+       uint64_t seq_cnt;               /* packet sequence number */
+};
+
 /*
  * Forward declaration of frontend-specific channel and ring_buffer.
  */
@@ -43,6 +65,8 @@ struct lib_ring_buffer_backend {
        struct lib_ring_buffer_backend_subbuffer *buf_wsb;
        /* ring_buffer_backend_subbuffer for reader */
        struct lib_ring_buffer_backend_subbuffer buf_rsb;
+       /* Array of lib_ring_buffer_backend_counts for the packet counter */
+       struct lib_ring_buffer_backend_counts *buf_cnt;
        /*
         * Pointer array of backend pages, for whole buffer.
         * Indexed by ring_buffer_backend_subbuffer identifier (id) index.
@@ -53,7 +77,7 @@ struct lib_ring_buffer_backend {
        struct channel *chan;           /* Associated channel */
        int cpu;                        /* This buffer's cpu. -1 if global. */
        union v_atomic records_read;    /* Number of records read */
-       unsigned int allocated:1;       /* Bool: is buffer allocated ? */
+       unsigned int allocated:1;       /* is buffer allocated ? */
 };
 
 struct channel_backend {
@@ -65,16 +89,23 @@ struct channel_backend {
                                         * for writer.
                                         */
        unsigned int buf_size_order;    /* Order of buffer size */
-       int extra_reader_sb:1;          /* Bool: has extra reader subbuffer */
+       unsigned int extra_reader_sb:1; /* has extra reader subbuffer ? */
        struct lib_ring_buffer *buf;    /* Channel per-cpu buffers */
 
        unsigned long num_subbuf;       /* Number of sub-buffers for writer */
        u64 start_tsc;                  /* Channel creation TSC value */
        void *priv;                     /* Client-specific information */
+       void *priv_ops;                 /* Client-specific ops pointer */
+       void (*release_priv_ops)(void *priv_ops);
        struct notifier_block cpu_hp_notifier;   /* CPU hotplug notifier */
-       const struct lib_ring_buffer_config *config; /* Ring buffer configuration */
+       /*
+        * We need to copy config because the module containing the
+        * source config can vanish before the last reference to this
+        * channel's streams is released.
+        */
+       struct lib_ring_buffer_config config; /* Ring buffer configuration */
        cpumask_var_t cpumask;          /* Allocated per-cpu buffers cpumask */
        char name[NAME_MAX];            /* Channel name */
 };
 
-#endif /* _LINUX_RING_BUFFER_BACKEND_TYPES_H */
+#endif /* _LIB_RING_BUFFER_BACKEND_TYPES_H */
This page took 0.023584 seconds and 4 git commands to generate.