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