Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * eth1394.h -- Ethernet driver for Linux IEEE-1394 Subsystem | |
3 | * | |
4 | * Copyright (C) 2000 Bonin Franck <boninf@free.fr> | |
5 | * (C) 2001 Ben Collins <bcollins@debian.org> | |
6 | * | |
7 | * Mainly based on work by Emanuel Pirker and Andreas E. Bombe | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software Foundation, | |
21 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
22 | */ | |
23 | ||
24 | #ifndef __ETH1394_H | |
25 | #define __ETH1394_H | |
26 | ||
27 | #include <linux/netdevice.h> | |
28 | ||
29 | #include "ieee1394.h" | |
e167c88e | 30 | #include "ieee1394_types.h" |
1da177e4 LT |
31 | |
32 | /* Register for incoming packets. This is 4096 bytes, which supports up to | |
33 | * S3200 (per Table 16-3 of IEEE 1394b-2002). */ | |
34 | #define ETHER1394_REGION_ADDR_LEN 4096 | |
35 | ||
1da177e4 LT |
36 | /* GASP identifier numbers for IPv4 over IEEE 1394 */ |
37 | #define ETHER1394_GASP_SPECIFIER_ID 0x00005E | |
38 | #define ETHER1394_GASP_SPECIFIER_ID_HI ((ETHER1394_GASP_SPECIFIER_ID >> 8) & 0xffff) | |
39 | #define ETHER1394_GASP_SPECIFIER_ID_LO (ETHER1394_GASP_SPECIFIER_ID & 0xff) | |
40 | #define ETHER1394_GASP_VERSION 1 | |
41 | ||
42 | #define ETHER1394_GASP_OVERHEAD (2 * sizeof(quadlet_t)) /* GASP header overhead */ | |
43 | ||
44 | #define ETHER1394_GASP_BUFFERS 16 | |
45 | ||
3ae3d0d4 JM |
46 | /* rawiso buffer size - due to a limitation in rawiso, we must limit each |
47 | * GASP buffer to be less than PAGE_SIZE. */ | |
48 | #define ETHER1394_ISO_BUF_SIZE ETHER1394_GASP_BUFFERS * \ | |
49 | min((unsigned int)PAGE_SIZE, \ | |
50 | 2 * (1U << (priv->host->csr.max_rec + 1))) | |
51 | ||
1da177e4 LT |
52 | /* Node set == 64 */ |
53 | #define NODE_SET (ALL_NODES + 1) | |
54 | ||
55 | enum eth1394_bc_states { ETHER1394_BC_ERROR, | |
56 | ETHER1394_BC_RUNNING, | |
57 | ETHER1394_BC_STOPPED }; | |
58 | ||
59 | ||
60 | /* Private structure for our ethernet driver */ | |
61 | struct eth1394_priv { | |
62 | struct net_device_stats stats; /* Device stats */ | |
63 | struct hpsb_host *host; /* The card for this dev */ | |
64 | u16 bc_maxpayload; /* Max broadcast payload */ | |
65 | u8 bc_sspd; /* Max broadcast speed */ | |
66 | u64 local_fifo; /* Local FIFO Address */ | |
67 | spinlock_t lock; /* Private lock */ | |
68 | int broadcast_channel; /* Async stream Broadcast Channel */ | |
69 | enum eth1394_bc_states bc_state; /* broadcast channel state */ | |
70 | struct hpsb_iso *iso; /* Async stream recv handle */ | |
71 | int bc_dgl; /* Outgoing broadcast datagram label */ | |
72 | struct list_head ip_node_list; /* List of IP capable nodes */ | |
73 | struct unit_directory *ud_list[ALL_NODES]; /* Cached unit dir list */ | |
74 | }; | |
75 | ||
76 | ||
77 | /* Define a fake hardware header format for the networking core. Note that | |
78 | * header size cannot exceed 16 bytes as that is the size of the header cache. | |
79 | * Also, we do not need the source address in the header so we omit it and | |
80 | * keep the header to under 16 bytes */ | |
81 | #define ETH1394_ALEN (8) | |
82 | #define ETH1394_HLEN (10) | |
83 | ||
84 | struct eth1394hdr { | |
85 | unsigned char h_dest[ETH1394_ALEN]; /* destination eth1394 addr */ | |
86 | unsigned short h_proto; /* packet type ID field */ | |
87 | } __attribute__((packed)); | |
88 | ||
89 | #ifdef __KERNEL__ | |
90 | #include <linux/skbuff.h> | |
91 | ||
92 | static inline struct eth1394hdr *eth1394_hdr(const struct sk_buff *skb) | |
93 | { | |
98e399f8 | 94 | return (struct eth1394hdr *)skb_mac_header(skb); |
1da177e4 LT |
95 | } |
96 | #endif | |
97 | ||
98 | typedef enum {ETH1394_GASP, ETH1394_WRREQ} eth1394_tx_type; | |
99 | ||
100 | /* IP1394 headers */ | |
101 | #include <asm/byteorder.h> | |
102 | ||
103 | /* Unfragmented */ | |
104 | #if defined __BIG_ENDIAN_BITFIELD | |
105 | struct eth1394_uf_hdr { | |
106 | u16 lf:2; | |
107 | u16 res:14; | |
108 | u16 ether_type; /* Ethernet packet type */ | |
109 | } __attribute__((packed)); | |
110 | #elif defined __LITTLE_ENDIAN_BITFIELD | |
111 | struct eth1394_uf_hdr { | |
112 | u16 res:14; | |
113 | u16 lf:2; | |
114 | u16 ether_type; | |
115 | } __attribute__((packed)); | |
116 | #else | |
117 | #error Unknown bit field type | |
118 | #endif | |
119 | ||
120 | /* First fragment */ | |
121 | #if defined __BIG_ENDIAN_BITFIELD | |
122 | struct eth1394_ff_hdr { | |
123 | u16 lf:2; | |
124 | u16 res1:2; | |
125 | u16 dg_size:12; /* Datagram size */ | |
126 | u16 ether_type; /* Ethernet packet type */ | |
127 | u16 dgl; /* Datagram label */ | |
128 | u16 res2; | |
129 | } __attribute__((packed)); | |
130 | #elif defined __LITTLE_ENDIAN_BITFIELD | |
131 | struct eth1394_ff_hdr { | |
132 | u16 dg_size:12; | |
133 | u16 res1:2; | |
134 | u16 lf:2; | |
135 | u16 ether_type; | |
136 | u16 dgl; | |
137 | u16 res2; | |
138 | } __attribute__((packed)); | |
139 | #else | |
140 | #error Unknown bit field type | |
141 | #endif | |
142 | ||
143 | /* XXX: Subsequent fragments, including last */ | |
144 | #if defined __BIG_ENDIAN_BITFIELD | |
145 | struct eth1394_sf_hdr { | |
146 | u16 lf:2; | |
147 | u16 res1:2; | |
148 | u16 dg_size:12; /* Datagram size */ | |
149 | u16 res2:4; | |
150 | u16 fg_off:12; /* Fragment offset */ | |
151 | u16 dgl; /* Datagram label */ | |
152 | u16 res3; | |
153 | } __attribute__((packed)); | |
154 | #elif defined __LITTLE_ENDIAN_BITFIELD | |
155 | struct eth1394_sf_hdr { | |
156 | u16 dg_size:12; | |
157 | u16 res1:2; | |
158 | u16 lf:2; | |
159 | u16 fg_off:12; | |
160 | u16 res2:4; | |
161 | u16 dgl; | |
162 | u16 res3; | |
163 | } __attribute__((packed)); | |
164 | #else | |
165 | #error Unknown bit field type | |
166 | #endif | |
167 | ||
168 | #if defined __BIG_ENDIAN_BITFIELD | |
169 | struct eth1394_common_hdr { | |
170 | u16 lf:2; | |
171 | u16 pad1:14; | |
172 | } __attribute__((packed)); | |
173 | #elif defined __LITTLE_ENDIAN_BITFIELD | |
174 | struct eth1394_common_hdr { | |
175 | u16 pad1:14; | |
176 | u16 lf:2; | |
177 | } __attribute__((packed)); | |
178 | #else | |
179 | #error Unknown bit field type | |
180 | #endif | |
181 | ||
182 | struct eth1394_hdr_words { | |
183 | u16 word1; | |
184 | u16 word2; | |
185 | u16 word3; | |
186 | u16 word4; | |
187 | }; | |
188 | ||
189 | union eth1394_hdr { | |
190 | struct eth1394_common_hdr common; | |
191 | struct eth1394_uf_hdr uf; | |
192 | struct eth1394_ff_hdr ff; | |
193 | struct eth1394_sf_hdr sf; | |
194 | struct eth1394_hdr_words words; | |
195 | }; | |
196 | ||
197 | /* End of IP1394 headers */ | |
198 | ||
199 | /* Fragment types */ | |
200 | #define ETH1394_HDR_LF_UF 0 /* unfragmented */ | |
201 | #define ETH1394_HDR_LF_FF 1 /* first fragment */ | |
202 | #define ETH1394_HDR_LF_LF 2 /* last fragment */ | |
203 | #define ETH1394_HDR_LF_IF 3 /* interior fragment */ | |
204 | ||
205 | #define IP1394_HW_ADDR_LEN 16 /* As per RFC */ | |
206 | ||
207 | /* Our arp packet (ARPHRD_IEEE1394) */ | |
208 | struct eth1394_arp { | |
209 | u16 hw_type; /* 0x0018 */ | |
210 | u16 proto_type; /* 0x0806 */ | |
211 | u8 hw_addr_len; /* 16 */ | |
212 | u8 ip_addr_len; /* 4 */ | |
213 | u16 opcode; /* ARP Opcode */ | |
214 | /* Above is exactly the same format as struct arphdr */ | |
215 | ||
216 | u64 s_uniq_id; /* Sender's 64bit EUI */ | |
217 | u8 max_rec; /* Sender's max packet size */ | |
218 | u8 sspd; /* Sender's max speed */ | |
219 | u16 fifo_hi; /* hi 16bits of sender's FIFO addr */ | |
220 | u32 fifo_lo; /* lo 32bits of sender's FIFO addr */ | |
221 | u32 sip; /* Sender's IP Address */ | |
222 | u32 tip; /* IP Address of requested hw addr */ | |
223 | }; | |
224 | ||
225 | /* Network timeout */ | |
226 | #define ETHER1394_TIMEOUT 100000 | |
227 | ||
228 | /* This is our task struct. It's used for the packet complete callback. */ | |
229 | struct packet_task { | |
230 | struct sk_buff *skb; | |
231 | int outstanding_pkts; | |
232 | eth1394_tx_type tx_type; | |
233 | int max_payload; | |
234 | struct hpsb_packet *packet; | |
235 | struct eth1394_priv *priv; | |
236 | union eth1394_hdr hdr; | |
237 | u64 addr; | |
238 | u16 dest_node; | |
239 | }; | |
240 | ||
241 | #endif /* __ETH1394_H */ |