12529f56eSJonathan T. Looney /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 32529f56eSJonathan T. Looney * 452467047SWarner Losh * Copyright (c) 2016 Netflix, Inc. 52529f56eSJonathan T. Looney * 62529f56eSJonathan T. Looney * Redistribution and use in source and binary forms, with or without 72529f56eSJonathan T. Looney * modification, are permitted provided that the following conditions 82529f56eSJonathan T. Looney * are met: 92529f56eSJonathan T. Looney * 1. Redistributions of source code must retain the above copyright 102529f56eSJonathan T. Looney * notice, this list of conditions and the following disclaimer. 112529f56eSJonathan T. Looney * 2. Redistributions in binary form must reproduce the above copyright 122529f56eSJonathan T. Looney * notice, this list of conditions and the following disclaimer in the 132529f56eSJonathan T. Looney * documentation and/or other materials provided with the distribution. 142529f56eSJonathan T. Looney * 152529f56eSJonathan T. Looney * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 162529f56eSJonathan T. Looney * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 172529f56eSJonathan T. Looney * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 182529f56eSJonathan T. Looney * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 192529f56eSJonathan T. Looney * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 202529f56eSJonathan T. Looney * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 212529f56eSJonathan T. Looney * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 222529f56eSJonathan T. Looney * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 232529f56eSJonathan T. Looney * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 242529f56eSJonathan T. Looney * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 252529f56eSJonathan T. Looney * SUCH DAMAGE. 262529f56eSJonathan T. Looney * 272529f56eSJonathan T. Looney * $FreeBSD$ 282529f56eSJonathan T. Looney */ 292529f56eSJonathan T. Looney 302529f56eSJonathan T. Looney #ifndef __tcp_log_dev_h__ 312529f56eSJonathan T. Looney #define __tcp_log_dev_h__ 322529f56eSJonathan T. Looney 332529f56eSJonathan T. Looney /* 342529f56eSJonathan T. Looney * This is the common header for data streamed from the log device. All 352529f56eSJonathan T. Looney * blocks of data need to start with this header. 362529f56eSJonathan T. Looney */ 372529f56eSJonathan T. Looney struct tcp_log_common_header { 382529f56eSJonathan T. Looney uint32_t tlch_version; /* Version is specific to type. */ 392529f56eSJonathan T. Looney uint32_t tlch_type; /* Type of entry(ies) that follow. */ 402529f56eSJonathan T. Looney uint64_t tlch_length; /* Total length, including header. */ 412529f56eSJonathan T. Looney } __packed; 422529f56eSJonathan T. Looney 432529f56eSJonathan T. Looney #define TCP_LOG_DEV_TYPE_BBR 1 /* black box recorder */ 442529f56eSJonathan T. Looney 452529f56eSJonathan T. Looney #ifdef _KERNEL 462529f56eSJonathan T. Looney /* 472529f56eSJonathan T. Looney * This is a queue entry. All queue entries need to start with this structure 482529f56eSJonathan T. Looney * so the common code can cast them to this structure; however, other modules 492529f56eSJonathan T. Looney * are free to include additional data after this structure. 502529f56eSJonathan T. Looney * 512529f56eSJonathan T. Looney * The elements are explained here: 522529f56eSJonathan T. Looney * tldq_queue: used by the common code to maintain this entry's position in the 532529f56eSJonathan T. Looney * queue. 542529f56eSJonathan T. Looney * tldq_buf: should be NULL, or a pointer to a chunk of data. The data must be 552529f56eSJonathan T. Looney * as long as the common header indicates. 562529f56eSJonathan T. Looney * tldq_xform: If tldq_buf is NULL, the code will call this to create the 572529f56eSJonathan T. Looney * the tldq_buf object. The function should *not* directly modify tldq_buf, 582529f56eSJonathan T. Looney * but should return the buffer (which must meet the restrictions 592529f56eSJonathan T. Looney * indicated for tldq_buf). 602529f56eSJonathan T. Looney * tldq_dtor: This function is called to free the queue entry. If tldq_buf is 612529f56eSJonathan T. Looney * not NULL, the dtor function must free that, too. 622529f56eSJonathan T. Looney * tldq_refcnt: used by the common code to indicate how many readers still need 632529f56eSJonathan T. Looney * this data. 642529f56eSJonathan T. Looney */ 652529f56eSJonathan T. Looney struct tcp_log_dev_queue { 662529f56eSJonathan T. Looney STAILQ_ENTRY(tcp_log_dev_queue) tldq_queue; 672529f56eSJonathan T. Looney struct tcp_log_common_header *tldq_buf; 682529f56eSJonathan T. Looney struct tcp_log_common_header *(*tldq_xform)(struct tcp_log_dev_queue *entry); 692529f56eSJonathan T. Looney void (*tldq_dtor)(struct tcp_log_dev_queue *entry); 702529f56eSJonathan T. Looney volatile u_int tldq_refcnt; 712529f56eSJonathan T. Looney }; 722529f56eSJonathan T. Looney 732529f56eSJonathan T. Looney STAILQ_HEAD(log_queueh, tcp_log_dev_queue); 742529f56eSJonathan T. Looney 752529f56eSJonathan T. Looney struct tcp_log_dev_info { 762529f56eSJonathan T. Looney STAILQ_ENTRY(tcp_log_dev_info) tldi_list; 772529f56eSJonathan T. Looney struct tcp_log_dev_queue *tldi_head; 782529f56eSJonathan T. Looney struct tcp_log_common_header *tldi_cur; 792529f56eSJonathan T. Looney off_t tldi_off; 802529f56eSJonathan T. Looney }; 812529f56eSJonathan T. Looney STAILQ_HEAD(log_infoh, tcp_log_dev_info); 822529f56eSJonathan T. Looney 83e24e5683SJonathan T. Looney #ifdef TCP_BLACKBOX 842529f56eSJonathan T. Looney MALLOC_DECLARE(M_TCPLOGDEV); 852529f56eSJonathan T. Looney int tcp_log_dev_add_log(struct tcp_log_dev_queue *entry); 86e24e5683SJonathan T. Looney #endif /* TCP_BLACKBOX */ 872529f56eSJonathan T. Looney #endif /* _KERNEL */ 882529f56eSJonathan T. Looney #endif /* !__tcp_log_dev_h__ */ 89