MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / ieee1394 / eth1394.h
blobed8f1c4b7fd80ee38ca331d0a2df32e12bea101d
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 /* Node set == 64 */
48 #define NODE_SET (ALL_NODES + 1)
50 enum eth1394_bc_states { ETHER1394_BC_ERROR,
51 ETHER1394_BC_RUNNING,
52 ETHER1394_BC_STOPPED };
55 /* Private structure for our ethernet driver */
56 struct eth1394_priv {
57 struct net_device_stats stats; /* Device stats */
58 struct hpsb_host *host; /* The card for this dev */
59 u16 bc_maxpayload; /* Max broadcast payload */
60 u8 bc_sspd; /* Max broadcast speed */
61 u64 local_fifo; /* Local FIFO Address */
62 spinlock_t lock; /* Private lock */
63 int broadcast_channel; /* Async stream Broadcast Channel */
64 enum eth1394_bc_states bc_state; /* broadcast channel state */
65 struct hpsb_iso *iso; /* Async stream recv handle */
66 int bc_dgl; /* Outgoing broadcast datagram label */
67 struct list_head ip_node_list; /* List of IP capable nodes */
68 struct unit_directory *ud_list[ALL_NODES]; /* Cached unit dir list */
72 /* Define a fake hardware header format for the networking core. Note that
73 * header size cannot exceed 16 bytes as that is the size of the header cache.
74 * Also, we do not need the source address in the header so we omit it and
75 * keep the header to under 16 bytes */
76 #define ETH1394_ALEN (8)
77 #define ETH1394_HLEN (10)
79 struct eth1394hdr {
80 unsigned char h_dest[ETH1394_ALEN]; /* destination eth1394 addr */
81 unsigned short h_proto; /* packet type ID field */
82 } __attribute__((packed));
84 #ifdef __KERNEL__
85 #include <linux/skbuff.h>
87 static inline struct eth1394hdr *eth1394_hdr(const struct sk_buff *skb)
89 return (struct eth1394hdr *)skb->mac.raw;
91 #endif
93 typedef enum {ETH1394_GASP, ETH1394_WRREQ} eth1394_tx_type;
95 /* IP1394 headers */
96 #include <asm/byteorder.h>
98 /* Unfragmented */
99 #if defined __BIG_ENDIAN_BITFIELD
100 struct eth1394_uf_hdr {
101 u16 lf:2;
102 u16 res:14;
103 u16 ether_type; /* Ethernet packet type */
104 } __attribute__((packed));
105 #elif defined __LITTLE_ENDIAN_BITFIELD
106 struct eth1394_uf_hdr {
107 u16 res:14;
108 u16 lf:2;
109 u16 ether_type;
110 } __attribute__((packed));
111 #else
112 #error Unknown bit field type
113 #endif
115 /* First fragment */
116 #if defined __BIG_ENDIAN_BITFIELD
117 struct eth1394_ff_hdr {
118 u16 lf:2;
119 u16 res1:2;
120 u16 dg_size:12; /* Datagram size */
121 u16 ether_type; /* Ethernet packet type */
122 u16 dgl; /* Datagram label */
123 u16 res2;
124 } __attribute__((packed));
125 #elif defined __LITTLE_ENDIAN_BITFIELD
126 struct eth1394_ff_hdr {
127 u16 dg_size:12;
128 u16 res1:2;
129 u16 lf:2;
130 u16 ether_type;
131 u16 dgl;
132 u16 res2;
133 } __attribute__((packed));
134 #else
135 #error Unknown bit field type
136 #endif
138 /* XXX: Subsequent fragments, including last */
139 #if defined __BIG_ENDIAN_BITFIELD
140 struct eth1394_sf_hdr {
141 u16 lf:2;
142 u16 res1:2;
143 u16 dg_size:12; /* Datagram size */
144 u16 res2:4;
145 u16 fg_off:12; /* Fragment offset */
146 u16 dgl; /* Datagram label */
147 u16 res3;
148 } __attribute__((packed));
149 #elif defined __LITTLE_ENDIAN_BITFIELD
150 struct eth1394_sf_hdr {
151 u16 dg_size:12;
152 u16 res1:2;
153 u16 lf:2;
154 u16 fg_off:12;
155 u16 res2:4;
156 u16 dgl;
157 u16 res3;
158 } __attribute__((packed));
159 #else
160 #error Unknown bit field type
161 #endif
163 #if defined __BIG_ENDIAN_BITFIELD
164 struct eth1394_common_hdr {
165 u16 lf:2;
166 u16 pad1:14;
167 } __attribute__((packed));
168 #elif defined __LITTLE_ENDIAN_BITFIELD
169 struct eth1394_common_hdr {
170 u16 pad1:14;
171 u16 lf:2;
172 } __attribute__((packed));
173 #else
174 #error Unknown bit field type
175 #endif
177 struct eth1394_hdr_words {
178 u16 word1;
179 u16 word2;
180 u16 word3;
181 u16 word4;
184 union eth1394_hdr {
185 struct eth1394_common_hdr common;
186 struct eth1394_uf_hdr uf;
187 struct eth1394_ff_hdr ff;
188 struct eth1394_sf_hdr sf;
189 struct eth1394_hdr_words words;
192 /* End of IP1394 headers */
194 /* Fragment types */
195 #define ETH1394_HDR_LF_UF 0 /* unfragmented */
196 #define ETH1394_HDR_LF_FF 1 /* first fragment */
197 #define ETH1394_HDR_LF_LF 2 /* last fragment */
198 #define ETH1394_HDR_LF_IF 3 /* interior fragment */
200 #define IP1394_HW_ADDR_LEN 16 /* As per RFC */
202 /* Our arp packet (ARPHRD_IEEE1394) */
203 struct eth1394_arp {
204 u16 hw_type; /* 0x0018 */
205 u16 proto_type; /* 0x0806 */
206 u8 hw_addr_len; /* 16 */
207 u8 ip_addr_len; /* 4 */
208 u16 opcode; /* ARP Opcode */
209 /* Above is exactly the same format as struct arphdr */
211 u64 s_uniq_id; /* Sender's 64bit EUI */
212 u8 max_rec; /* Sender's max packet size */
213 u8 sspd; /* Sender's max speed */
214 u16 fifo_hi; /* hi 16bits of sender's FIFO addr */
215 u32 fifo_lo; /* lo 32bits of sender's FIFO addr */
216 u32 sip; /* Sender's IP Address */
217 u32 tip; /* IP Address of requested hw addr */
220 /* Network timeout */
221 #define ETHER1394_TIMEOUT 100000
223 /* This is our task struct. It's used for the packet complete callback. */
224 struct packet_task {
225 struct sk_buff *skb;
226 int outstanding_pkts;
227 eth1394_tx_type tx_type;
228 int max_payload;
229 struct hpsb_packet *packet;
230 struct eth1394_priv *priv;
231 union eth1394_hdr hdr;
232 u64 addr;
233 u16 dest_node;
236 #endif /* __ETH1394_H */