1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2004 Doug Rabson 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 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. 15 * 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 26 * SUCH DAMAGE. 27 */ 28 29 #ifndef _NET_FIREWIRE_H_ 30 #define _NET_FIREWIRE_H_ 31 32 #define FW_ENCAP_UNFRAG 0 33 #define FW_ENCAP_FIRST 1 34 #define FW_ENCAP_LAST 2 35 #define FW_ENCAP_NEXT 3 36 37 union fw_encap { 38 uint32_t ul[2]; 39 struct { 40 #if BYTE_ORDER == BIG_ENDIAN 41 uint32_t lf :2; 42 uint32_t reserved :14; 43 uint32_t ether_type :16; 44 #else 45 uint32_t ether_type :16; 46 uint32_t reserved :14; 47 uint32_t lf :2; 48 #endif 49 } unfrag; 50 struct { 51 #if BYTE_ORDER == BIG_ENDIAN 52 uint32_t lf :2; 53 uint32_t reserved1 :2; 54 uint32_t datagram_size :12; 55 uint32_t ether_type :16; 56 uint32_t dgl :16; 57 uint32_t reserved2 :16; 58 #else 59 uint32_t ether_type :16; 60 uint32_t datagram_size :12; 61 uint32_t reserved1 :2; 62 uint32_t lf :2; 63 uint32_t reserved2 :16; 64 uint32_t dgl :16; 65 #endif 66 } firstfrag; 67 struct { 68 #if BYTE_ORDER == BIG_ENDIAN 69 uint32_t lf :2; 70 uint32_t reserved1 :2; 71 uint32_t datagram_size :12; 72 uint32_t reserved2 :4; 73 uint32_t fragment_offset :12; 74 uint32_t dgl :16; 75 uint32_t reserved3 :16; 76 #else 77 uint32_t fragment_offset :12; 78 uint32_t reserved2 :4; 79 uint32_t datagram_size :12; 80 uint32_t reserved1 :2; 81 uint32_t lf :2; 82 uint32_t reserved3 :16; 83 uint32_t dgl :16; 84 #endif 85 } nextfrag; 86 }; 87 88 #define MTAG_FIREWIRE 1394 89 #define MTAG_FIREWIRE_HWADDR 0 90 #define MTAG_FIREWIRE_SENDER_EUID 1 91 92 struct fw_hwaddr { 93 uint32_t sender_unique_ID_hi; 94 uint32_t sender_unique_ID_lo; 95 uint8_t sender_max_rec; 96 uint8_t sspd; 97 uint16_t sender_unicast_FIFO_hi; 98 uint32_t sender_unicast_FIFO_lo; 99 }; 100 101 /* 102 * BPF wants to see one of these. 103 */ 104 struct fw_bpfhdr { 105 uint8_t firewire_dhost[8]; 106 uint8_t firewire_shost[8]; 107 uint16_t firewire_type; 108 }; 109 110 #ifdef _KERNEL 111 112 /* 113 * A structure to track the reassembly of a link-level fragmented 114 * datagram. 115 */ 116 struct fw_reass { 117 STAILQ_ENTRY(fw_reass) fr_link; 118 uint32_t fr_id; /* host+dgl */ 119 struct mbuf *fr_frags; /* chain of frags */ 120 }; 121 STAILQ_HEAD(fw_reass_list, fw_reass); 122 123 struct fw_com { 124 struct ifnet *fc_ifp; 125 struct fw_hwaddr fc_hwaddr; 126 struct firewire_comm *fc_fc; 127 uint8_t fc_broadcast_channel; 128 uint8_t fc_speed; /* our speed */ 129 uint16_t fc_node; /* our nodeid */ 130 struct fw_reass_list fc_frags; /* partial datagrams */ 131 }; 132 #define IFP2FWC(ifp) ((struct fw_com *)if_getl2com(ifp)) 133 134 extern void firewire_input(struct ifnet *ifp, struct mbuf *m, uint16_t src); 135 extern void firewire_ifattach(struct ifnet *, struct fw_hwaddr *); 136 extern void firewire_ifdetach(struct ifnet *); 137 extern void firewire_busreset(struct ifnet *); 138 extern int firewire_ioctl(struct ifnet *, u_long, caddr_t); 139 140 #endif /* !_KERNEL */ 141 142 #endif /* !_NET_FIREWIRE_H_ */ 143