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