Linux v2.6.15-rc7
[pohmelfs.git] / drivers / ieee1394 / eth1394.h
bloba77213cfc4837b8dd302e1b502ac36073c664d9b
1 /*
2 * eth1394.h -- Ethernet driver for Linux IEEE-1394 Subsystem
4 * Copyright (C) 2000 Bonin Franck <boninf@free.fr>
5 * (C) 2001 Ben Collins <bcollins@debian.org>
7 * Mainly based on work by Emanuel Pirker and Andreas E. Bombe
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.
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.
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.
24 #ifndef __ETH1394_H
25 #define __ETH1394_H
27 #include <linux/netdevice.h>
29 #include "ieee1394.h"
31 /* Register for incoming packets. This is 4096 bytes, which supports up to
32 * S3200 (per Table 16-3 of IEEE 1394b-2002). */
33 #define ETHER1394_REGION_ADDR_LEN 4096
35 #define ETHER1394_INVALID_ADDR ~0ULL
37 /* GASP identifier numbers for IPv4 over IEEE 1394 */
38 #define ETHER1394_GASP_SPECIFIER_ID 0x00005E
39 #define ETHER1394_GASP_SPECIFIER_ID_HI ((ETHER1394_GASP_SPECIFIER_ID >> 8) & 0xffff)
40 #define ETHER1394_GASP_SPECIFIER_ID_LO (ETHER1394_GASP_SPECIFIER_ID & 0xff)
41 #define ETHER1394_GASP_VERSION 1
43 #define ETHER1394_GASP_OVERHEAD (2 * sizeof(quadlet_t)) /* GASP header overhead */
45 #define ETHER1394_GASP_BUFFERS 16
47 /* rawiso buffer size - due to a limitation in rawiso, we must limit each
48 * GASP buffer to be less than PAGE_SIZE. */
49 #define ETHER1394_ISO_BUF_SIZE ETHER1394_GASP_BUFFERS * \
50 min((unsigned int)PAGE_SIZE, \
51 2 * (1U << (priv->host->csr.max_rec + 1)))
53 /* Node set == 64 */
54 #define NODE_SET (ALL_NODES + 1)
56 enum eth1394_bc_states { ETHER1394_BC_ERROR,
57 ETHER1394_BC_RUNNING,
58 ETHER1394_BC_STOPPED };
61 /* Private structure for our ethernet driver */
62 struct eth1394_priv {
63 struct net_device_stats stats; /* Device stats */
64 struct hpsb_host *host; /* The card for this dev */
65 u16 bc_maxpayload; /* Max broadcast payload */
66 u8 bc_sspd; /* Max broadcast speed */
67 u64 local_fifo; /* Local FIFO Address */
68 spinlock_t lock; /* Private lock */
69 int broadcast_channel; /* Async stream Broadcast Channel */
70 enum eth1394_bc_states bc_state; /* broadcast channel state */
71 struct hpsb_iso *iso; /* Async stream recv handle */
72 int bc_dgl; /* Outgoing broadcast datagram label */
73 struct list_head ip_node_list; /* List of IP capable nodes */
74 struct unit_directory *ud_list[ALL_NODES]; /* Cached unit dir list */
78 /* Define a fake hardware header format for the networking core. Note that
79 * header size cannot exceed 16 bytes as that is the size of the header cache.
80 * Also, we do not need the source address in the header so we omit it and
81 * keep the header to under 16 bytes */
82 #define ETH1394_ALEN (8)
83 #define ETH1394_HLEN (10)
85 struct eth1394hdr {
86 unsigned char h_dest[ETH1394_ALEN]; /* destination eth1394 addr */
87 unsigned short h_proto; /* packet type ID field */
88 } __attribute__((packed));
90 #ifdef __KERNEL__
91 #include <linux/skbuff.h>
93 static inline struct eth1394hdr *eth1394_hdr(const struct sk_buff *skb)
95 return (struct eth1394hdr *)skb->mac.raw;
97 #endif
99 typedef enum {ETH1394_GASP, ETH1394_WRREQ} eth1394_tx_type;
101 /* IP1394 headers */
102 #include <asm/byteorder.h>
104 /* Unfragmented */
105 #if defined __BIG_ENDIAN_BITFIELD
106 struct eth1394_uf_hdr {
107 u16 lf:2;
108 u16 res:14;
109 u16 ether_type; /* Ethernet packet type */
110 } __attribute__((packed));
111 #elif defined __LITTLE_ENDIAN_BITFIELD
112 struct eth1394_uf_hdr {
113 u16 res:14;
114 u16 lf:2;
115 u16 ether_type;
116 } __attribute__((packed));
117 #else
118 #error Unknown bit field type
119 #endif
121 /* First fragment */
122 #if defined __BIG_ENDIAN_BITFIELD
123 struct eth1394_ff_hdr {
124 u16 lf:2;
125 u16 res1:2;
126 u16 dg_size:12; /* Datagram size */
127 u16 ether_type; /* Ethernet packet type */
128 u16 dgl; /* Datagram label */
129 u16 res2;
130 } __attribute__((packed));
131 #elif defined __LITTLE_ENDIAN_BITFIELD
132 struct eth1394_ff_hdr {
133 u16 dg_size:12;
134 u16 res1:2;
135 u16 lf:2;
136 u16 ether_type;
137 u16 dgl;
138 u16 res2;
139 } __attribute__((packed));
140 #else
141 #error Unknown bit field type
142 #endif
144 /* XXX: Subsequent fragments, including last */
145 #if defined __BIG_ENDIAN_BITFIELD
146 struct eth1394_sf_hdr {
147 u16 lf:2;
148 u16 res1:2;
149 u16 dg_size:12; /* Datagram size */
150 u16 res2:4;
151 u16 fg_off:12; /* Fragment offset */
152 u16 dgl; /* Datagram label */
153 u16 res3;
154 } __attribute__((packed));
155 #elif defined __LITTLE_ENDIAN_BITFIELD
156 struct eth1394_sf_hdr {
157 u16 dg_size:12;
158 u16 res1:2;
159 u16 lf:2;
160 u16 fg_off:12;
161 u16 res2:4;
162 u16 dgl;
163 u16 res3;
164 } __attribute__((packed));
165 #else
166 #error Unknown bit field type
167 #endif
169 #if defined __BIG_ENDIAN_BITFIELD
170 struct eth1394_common_hdr {
171 u16 lf:2;
172 u16 pad1:14;
173 } __attribute__((packed));
174 #elif defined __LITTLE_ENDIAN_BITFIELD
175 struct eth1394_common_hdr {
176 u16 pad1:14;
177 u16 lf:2;
178 } __attribute__((packed));
179 #else
180 #error Unknown bit field type
181 #endif
183 struct eth1394_hdr_words {
184 u16 word1;
185 u16 word2;
186 u16 word3;
187 u16 word4;
190 union eth1394_hdr {
191 struct eth1394_common_hdr common;
192 struct eth1394_uf_hdr uf;
193 struct eth1394_ff_hdr ff;
194 struct eth1394_sf_hdr sf;
195 struct eth1394_hdr_words words;
198 /* End of IP1394 headers */
200 /* Fragment types */
201 #define ETH1394_HDR_LF_UF 0 /* unfragmented */
202 #define ETH1394_HDR_LF_FF 1 /* first fragment */
203 #define ETH1394_HDR_LF_LF 2 /* last fragment */
204 #define ETH1394_HDR_LF_IF 3 /* interior fragment */
206 #define IP1394_HW_ADDR_LEN 16 /* As per RFC */
208 /* Our arp packet (ARPHRD_IEEE1394) */
209 struct eth1394_arp {
210 u16 hw_type; /* 0x0018 */
211 u16 proto_type; /* 0x0806 */
212 u8 hw_addr_len; /* 16 */
213 u8 ip_addr_len; /* 4 */
214 u16 opcode; /* ARP Opcode */
215 /* Above is exactly the same format as struct arphdr */
217 u64 s_uniq_id; /* Sender's 64bit EUI */
218 u8 max_rec; /* Sender's max packet size */
219 u8 sspd; /* Sender's max speed */
220 u16 fifo_hi; /* hi 16bits of sender's FIFO addr */
221 u32 fifo_lo; /* lo 32bits of sender's FIFO addr */
222 u32 sip; /* Sender's IP Address */
223 u32 tip; /* IP Address of requested hw addr */
226 /* Network timeout */
227 #define ETHER1394_TIMEOUT 100000
229 /* This is our task struct. It's used for the packet complete callback. */
230 struct packet_task {
231 struct sk_buff *skb;
232 int outstanding_pkts;
233 eth1394_tx_type tx_type;
234 int max_payload;
235 struct hpsb_packet *packet;
236 struct eth1394_priv *priv;
237 union eth1394_hdr hdr;
238 u64 addr;
239 u16 dest_node;
242 #endif /* __ETH1394_H */