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.
27 #include <linux/netdevice.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 /* GASP identifier numbers for IPv4 over IEEE 1394 */
36 #define ETHER1394_GASP_SPECIFIER_ID 0x00005E
37 #define ETHER1394_GASP_SPECIFIER_ID_HI ((ETHER1394_GASP_SPECIFIER_ID >> 8) & 0xffff)
38 #define ETHER1394_GASP_SPECIFIER_ID_LO (ETHER1394_GASP_SPECIFIER_ID & 0xff)
39 #define ETHER1394_GASP_VERSION 1
41 #define ETHER1394_GASP_OVERHEAD (2 * sizeof(quadlet_t)) /* GASP header overhead */
43 #define ETHER1394_GASP_BUFFERS 16
45 /* rawiso buffer size - due to a limitation in rawiso, we must limit each
46 * GASP buffer to be less than PAGE_SIZE. */
47 #define ETHER1394_ISO_BUF_SIZE ETHER1394_GASP_BUFFERS * \
48 min((unsigned int)PAGE_SIZE, \
49 2 * (1U << (priv->host->csr.max_rec + 1)))
52 #define NODE_SET (ALL_NODES + 1)
54 enum eth1394_bc_states { ETHER1394_BC_ERROR,
56 ETHER1394_BC_STOPPED };
59 /* Private structure for our ethernet driver */
61 struct net_device_stats stats; /* Device stats */
62 struct hpsb_host *host; /* The card for this dev */
63 u16 bc_maxpayload; /* Max broadcast payload */
64 u8 bc_sspd; /* Max broadcast speed */
65 u64 local_fifo; /* Local FIFO Address */
66 spinlock_t lock; /* Private lock */
67 int broadcast_channel; /* Async stream Broadcast Channel */
68 enum eth1394_bc_states bc_state; /* broadcast channel state */
69 struct hpsb_iso *iso; /* Async stream recv handle */
70 int bc_dgl; /* Outgoing broadcast datagram label */
71 struct list_head ip_node_list; /* List of IP capable nodes */
72 struct unit_directory *ud_list[ALL_NODES]; /* Cached unit dir list */
76 /* Define a fake hardware header format for the networking core. Note that
77 * header size cannot exceed 16 bytes as that is the size of the header cache.
78 * Also, we do not need the source address in the header so we omit it and
79 * keep the header to under 16 bytes */
80 #define ETH1394_ALEN (8)
81 #define ETH1394_HLEN (10)
84 unsigned char h_dest[ETH1394_ALEN]; /* destination eth1394 addr */
85 unsigned short h_proto; /* packet type ID field */
86 } __attribute__((packed));
89 #include <linux/skbuff.h>
91 static inline struct eth1394hdr *eth1394_hdr(const struct sk_buff *skb)
93 return (struct eth1394hdr *)skb->mac.raw;
97 typedef enum {ETH1394_GASP, ETH1394_WRREQ} eth1394_tx_type;
100 #include <asm/byteorder.h>
103 #if defined __BIG_ENDIAN_BITFIELD
104 struct eth1394_uf_hdr {
107 u16 ether_type; /* Ethernet packet type */
108 } __attribute__((packed));
109 #elif defined __LITTLE_ENDIAN_BITFIELD
110 struct eth1394_uf_hdr {
114 } __attribute__((packed));
116 #error Unknown bit field type
120 #if defined __BIG_ENDIAN_BITFIELD
121 struct eth1394_ff_hdr {
124 u16 dg_size:12; /* Datagram size */
125 u16 ether_type; /* Ethernet packet type */
126 u16 dgl; /* Datagram label */
128 } __attribute__((packed));
129 #elif defined __LITTLE_ENDIAN_BITFIELD
130 struct eth1394_ff_hdr {
137 } __attribute__((packed));
139 #error Unknown bit field type
142 /* XXX: Subsequent fragments, including last */
143 #if defined __BIG_ENDIAN_BITFIELD
144 struct eth1394_sf_hdr {
147 u16 dg_size:12; /* Datagram size */
149 u16 fg_off:12; /* Fragment offset */
150 u16 dgl; /* Datagram label */
152 } __attribute__((packed));
153 #elif defined __LITTLE_ENDIAN_BITFIELD
154 struct eth1394_sf_hdr {
162 } __attribute__((packed));
164 #error Unknown bit field type
167 #if defined __BIG_ENDIAN_BITFIELD
168 struct eth1394_common_hdr {
171 } __attribute__((packed));
172 #elif defined __LITTLE_ENDIAN_BITFIELD
173 struct eth1394_common_hdr {
176 } __attribute__((packed));
178 #error Unknown bit field type
181 struct eth1394_hdr_words {
189 struct eth1394_common_hdr common;
190 struct eth1394_uf_hdr uf;
191 struct eth1394_ff_hdr ff;
192 struct eth1394_sf_hdr sf;
193 struct eth1394_hdr_words words;
196 /* End of IP1394 headers */
199 #define ETH1394_HDR_LF_UF 0 /* unfragmented */
200 #define ETH1394_HDR_LF_FF 1 /* first fragment */
201 #define ETH1394_HDR_LF_LF 2 /* last fragment */
202 #define ETH1394_HDR_LF_IF 3 /* interior fragment */
204 #define IP1394_HW_ADDR_LEN 16 /* As per RFC */
206 /* Our arp packet (ARPHRD_IEEE1394) */
208 u16 hw_type; /* 0x0018 */
209 u16 proto_type; /* 0x0806 */
210 u8 hw_addr_len; /* 16 */
211 u8 ip_addr_len; /* 4 */
212 u16 opcode; /* ARP Opcode */
213 /* Above is exactly the same format as struct arphdr */
215 u64 s_uniq_id; /* Sender's 64bit EUI */
216 u8 max_rec; /* Sender's max packet size */
217 u8 sspd; /* Sender's max speed */
218 u16 fifo_hi; /* hi 16bits of sender's FIFO addr */
219 u32 fifo_lo; /* lo 32bits of sender's FIFO addr */
220 u32 sip; /* Sender's IP Address */
221 u32 tip; /* IP Address of requested hw addr */
224 /* Network timeout */
225 #define ETHER1394_TIMEOUT 100000
227 /* This is our task struct. It's used for the packet complete callback. */
230 int outstanding_pkts;
231 eth1394_tx_type tx_type;
233 struct hpsb_packet *packet;
234 struct eth1394_priv *priv;
235 union eth1394_hdr hdr;
240 #endif /* __ETH1394_H */