2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5 * Netflix Inc. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #ifndef __tcp_log_dev_h__
32 #define __tcp_log_dev_h__
35 * This is the common header for data streamed from the log device. All
36 * blocks of data need to start with this header.
38 struct tcp_log_common_header {
39 uint32_t tlch_version; /* Version is specific to type. */
40 uint32_t tlch_type; /* Type of entry(ies) that follow. */
41 uint64_t tlch_length; /* Total length, including header. */
44 #define TCP_LOG_DEV_TYPE_BBR 1 /* black box recorder */
48 * This is a queue entry. All queue entries need to start with this structure
49 * so the common code can cast them to this structure; however, other modules
50 * are free to include additional data after this structure.
52 * The elements are explained here:
53 * tldq_queue: used by the common code to maintain this entry's position in the
55 * tldq_buf: should be NULL, or a pointer to a chunk of data. The data must be
56 * as long as the common header indicates.
57 * tldq_xform: If tldq_buf is NULL, the code will call this to create the
58 * the tldq_buf object. The function should *not* directly modify tldq_buf,
59 * but should return the buffer (which must meet the restrictions
60 * indicated for tldq_buf).
61 * tldq_dtor: This function is called to free the queue entry. If tldq_buf is
62 * not NULL, the dtor function must free that, too.
63 * tldq_refcnt: used by the common code to indicate how many readers still need
66 struct tcp_log_dev_queue {
67 STAILQ_ENTRY(tcp_log_dev_queue) tldq_queue;
68 struct tcp_log_common_header *tldq_buf;
69 struct tcp_log_common_header *(*tldq_xform)(struct tcp_log_dev_queue *entry);
70 void (*tldq_dtor)(struct tcp_log_dev_queue *entry);
71 volatile u_int tldq_refcnt;
74 STAILQ_HEAD(log_queueh, tcp_log_dev_queue);
76 struct tcp_log_dev_info {
77 STAILQ_ENTRY(tcp_log_dev_info) tldi_list;
78 struct tcp_log_dev_queue *tldi_head;
79 struct tcp_log_common_header *tldi_cur;
82 STAILQ_HEAD(log_infoh, tcp_log_dev_info);
85 MALLOC_DECLARE(M_TCPLOGDEV);
86 int tcp_log_dev_add_log(struct tcp_log_dev_queue *entry);
87 #endif /* TCP_BLACKBOX */
89 #endif /* !__tcp_log_dev_h__ */