xref: /freebsd/sys/net/firewire.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1b8b33234SDoug Rabson /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3fe267a55SPedro F. Giffuni  *
4b8b33234SDoug Rabson  * Copyright (c) 2004 Doug Rabson
5b8b33234SDoug Rabson  * All rights reserved.
6b8b33234SDoug Rabson  *
7b8b33234SDoug Rabson  * Redistribution and use in source and binary forms, with or without
8b8b33234SDoug Rabson  * modification, are permitted provided that the following conditions
9b8b33234SDoug Rabson  * are met:
10b8b33234SDoug Rabson  * 1. Redistributions of source code must retain the above copyright
11b8b33234SDoug Rabson  *    notice, this list of conditions and the following disclaimer.
12b8b33234SDoug Rabson  * 2. Redistributions in binary form must reproduce the above copyright
13b8b33234SDoug Rabson  *    notice, this list of conditions and the following disclaimer in the
14b8b33234SDoug Rabson  *    documentation and/or other materials provided with the distribution.
15b8b33234SDoug Rabson  *
16b8b33234SDoug Rabson  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17b8b33234SDoug Rabson  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18b8b33234SDoug Rabson  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19b8b33234SDoug Rabson  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20b8b33234SDoug Rabson  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21b8b33234SDoug Rabson  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22b8b33234SDoug Rabson  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23b8b33234SDoug Rabson  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24b8b33234SDoug Rabson  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25b8b33234SDoug Rabson  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26b8b33234SDoug Rabson  * SUCH DAMAGE.
27b8b33234SDoug Rabson  */
28b8b33234SDoug Rabson 
29b8b33234SDoug Rabson #ifndef _NET_FIREWIRE_H_
30b8b33234SDoug Rabson #define _NET_FIREWIRE_H_
31b8b33234SDoug Rabson 
32b8b33234SDoug Rabson #define FW_ENCAP_UNFRAG		0
33b8b33234SDoug Rabson #define FW_ENCAP_FIRST		1
34b8b33234SDoug Rabson #define FW_ENCAP_LAST		2
35b8b33234SDoug Rabson #define FW_ENCAP_NEXT		3
36b8b33234SDoug Rabson 
37b8b33234SDoug Rabson union fw_encap {
38b8b33234SDoug Rabson 		uint32_t ul[2];
39b8b33234SDoug Rabson 		struct {
40b8b33234SDoug Rabson #if BYTE_ORDER == BIG_ENDIAN
41b8b33234SDoug Rabson 			uint32_t lf		:2;
42b8b33234SDoug Rabson 			uint32_t reserved	:14;
43b8b33234SDoug Rabson 			uint32_t ether_type	:16;
44b8b33234SDoug Rabson #else
45b8b33234SDoug Rabson 			uint32_t ether_type	:16;
46b8b33234SDoug Rabson 			uint32_t reserved	:14;
47b8b33234SDoug Rabson 			uint32_t lf		:2;
48b8b33234SDoug Rabson #endif
49b8b33234SDoug Rabson 		} unfrag;
50b8b33234SDoug Rabson 		struct {
51b8b33234SDoug Rabson #if BYTE_ORDER == BIG_ENDIAN
52b8b33234SDoug Rabson 			uint32_t lf		:2;
53b8b33234SDoug Rabson 			uint32_t reserved1	:2;
54941d3718SDoug Rabson 			uint32_t datagram_size	:12;
55b8b33234SDoug Rabson 			uint32_t ether_type	:16;
56b8b33234SDoug Rabson 			uint32_t dgl		:16;
57b8b33234SDoug Rabson 			uint32_t reserved2	:16;
58b8b33234SDoug Rabson #else
59b8b33234SDoug Rabson 			uint32_t ether_type	:16;
60b8b33234SDoug Rabson 			uint32_t datagram_size	:12;
61b8b33234SDoug Rabson 			uint32_t reserved1	:2;
62b8b33234SDoug Rabson 			uint32_t lf		:2;
63b8b33234SDoug Rabson 			uint32_t reserved2	:16;
64b8b33234SDoug Rabson 			uint32_t dgl		:16;
65b8b33234SDoug Rabson #endif
66b8b33234SDoug Rabson 		} firstfrag;
67b8b33234SDoug Rabson 		struct {
68b8b33234SDoug Rabson #if BYTE_ORDER == BIG_ENDIAN
69b8b33234SDoug Rabson 			uint32_t lf		:2;
70b8b33234SDoug Rabson 			uint32_t reserved1	:2;
71941d3718SDoug Rabson 			uint32_t datagram_size	:12;
72b8b33234SDoug Rabson 			uint32_t reserved2	:4;
73b8b33234SDoug Rabson 			uint32_t fragment_offset :12;
74b8b33234SDoug Rabson 			uint32_t dgl		:16;
75b8b33234SDoug Rabson 			uint32_t reserved3	:16;
76b8b33234SDoug Rabson #else
77b8b33234SDoug Rabson 			uint32_t fragment_offset :12;
78b8b33234SDoug Rabson 			uint32_t reserved2	:4;
79b8b33234SDoug Rabson 			uint32_t datagram_size	:12;
80b8b33234SDoug Rabson 			uint32_t reserved1	:2;
81b8b33234SDoug Rabson 			uint32_t lf		:2;
82b8b33234SDoug Rabson 			uint32_t reserved3	:16;
83b8b33234SDoug Rabson 			uint32_t dgl		:16;
84b8b33234SDoug Rabson #endif
85b8b33234SDoug Rabson 		} nextfrag;
86b8b33234SDoug Rabson };
87b8b33234SDoug Rabson 
88b8b33234SDoug Rabson #define MTAG_FIREWIRE			1394
89b8b33234SDoug Rabson #define MTAG_FIREWIRE_HWADDR		0
90b8b33234SDoug Rabson #define MTAG_FIREWIRE_SENDER_EUID	1
91b8b33234SDoug Rabson 
92b8b33234SDoug Rabson struct fw_hwaddr {
93b8b33234SDoug Rabson 	uint32_t		sender_unique_ID_hi;
94b8b33234SDoug Rabson 	uint32_t		sender_unique_ID_lo;
95b8b33234SDoug Rabson 	uint8_t			sender_max_rec;
96b8b33234SDoug Rabson 	uint8_t			sspd;
97b8b33234SDoug Rabson 	uint16_t		sender_unicast_FIFO_hi;
98b8b33234SDoug Rabson 	uint32_t		sender_unicast_FIFO_lo;
99b8b33234SDoug Rabson };
100b8b33234SDoug Rabson 
101b8b33234SDoug Rabson /*
102b8b33234SDoug Rabson  * BPF wants to see one of these.
103b8b33234SDoug Rabson  */
104b8b33234SDoug Rabson struct fw_bpfhdr {
105b8b33234SDoug Rabson 	uint8_t			firewire_dhost[8];
106b8b33234SDoug Rabson 	uint8_t			firewire_shost[8];
107b8b33234SDoug Rabson 	uint16_t		firewire_type;
108b8b33234SDoug Rabson };
109b8b33234SDoug Rabson 
110b8b33234SDoug Rabson #ifdef _KERNEL
111b8b33234SDoug Rabson 
112b8b33234SDoug Rabson /*
113b8b33234SDoug Rabson  * A structure to track the reassembly of a link-level fragmented
114b8b33234SDoug Rabson  * datagram.
115b8b33234SDoug Rabson  */
116b8b33234SDoug Rabson struct fw_reass {
117b8b33234SDoug Rabson 	STAILQ_ENTRY(fw_reass)	fr_link;
118b8b33234SDoug Rabson 	uint32_t		fr_id;		/* host+dgl */
119b8b33234SDoug Rabson 	struct mbuf		*fr_frags;	/* chain of frags */
120b8b33234SDoug Rabson };
121b8b33234SDoug Rabson STAILQ_HEAD(fw_reass_list, fw_reass);
122b8b33234SDoug Rabson 
123b8b33234SDoug Rabson struct fw_com {
124fc74a9f9SBrooks Davis 	struct ifnet		*fc_ifp;
125b8b33234SDoug Rabson 	struct fw_hwaddr	fc_hwaddr;
126b8b33234SDoug Rabson 	struct firewire_comm	*fc_fc;
127b8b33234SDoug Rabson 	uint8_t			fc_broadcast_channel;
128b8b33234SDoug Rabson 	uint8_t			fc_speed;	/* our speed */
129b8b33234SDoug Rabson 	uint16_t		fc_node;	/* our nodeid */
130b8b33234SDoug Rabson 	struct fw_reass_list	fc_frags;	/* partial datagrams */
131b8b33234SDoug Rabson };
13231cfaf19SJustin Hibbits #define	IFP2FWC(ifp)	((struct fw_com *)if_getl2com(ifp))
133b8b33234SDoug Rabson 
134b8b33234SDoug Rabson extern	void	firewire_input(struct ifnet *ifp, struct mbuf *m, uint16_t src);
135b8b33234SDoug Rabson extern	void	firewire_ifattach(struct ifnet *, struct fw_hwaddr *);
136b8b33234SDoug Rabson extern	void	firewire_ifdetach(struct ifnet *);
137b8b33234SDoug Rabson extern	void	firewire_busreset(struct ifnet *);
138e40bae9aSRoman Divacky extern	int	firewire_ioctl(struct ifnet *, u_long, caddr_t);
139b8b33234SDoug Rabson 
140b8b33234SDoug Rabson #endif /* !_KERNEL */
141b8b33234SDoug Rabson 
142b8b33234SDoug Rabson #endif /* !_NET_FIREWIRE_H_ */
143