ieee1394: struct device - replace bus_id with dev_name(), dev_set_name()
[safe/jmp/linux-2.6] / drivers / ieee1394 / eth1394.h
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 #include <linux/skbuff.h>
29 #include <asm/byteorder.h>
30
31 #include "ieee1394.h"
32 #include "ieee1394_types.h"
33
34 /* Register for incoming packets. This is 4096 bytes, which supports up to
35  * S3200 (per Table 16-3 of IEEE 1394b-2002). */
36 #define ETHER1394_REGION_ADDR_LEN       4096
37
38 /* GASP identifier numbers for IPv4 over IEEE 1394 */
39 #define ETHER1394_GASP_SPECIFIER_ID     0x00005E
40 #define ETHER1394_GASP_SPECIFIER_ID_HI  ((0x00005E >> 8) & 0xffff)
41 #define ETHER1394_GASP_SPECIFIER_ID_LO  (0x00005E & 0xff)
42 #define ETHER1394_GASP_VERSION          1
43
44 #define ETHER1394_GASP_OVERHEAD (2 * sizeof(quadlet_t)) /* for GASP header */
45
46 #define ETHER1394_GASP_BUFFERS  16
47
48 #define NODE_SET                (ALL_NODES + 1)         /* Node set == 64 */
49
50 enum eth1394_bc_states { ETHER1394_BC_ERROR,
51                          ETHER1394_BC_RUNNING,
52                          ETHER1394_BC_STOPPED };
53
54
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 */
69
70         struct work_struct wake;        /* Wake up after xmit failure    */
71         struct net_device *wake_dev;    /* Stupid backlink for .wake     */
72         nodeid_t wake_node;             /* Destination of failed xmit    */
73 };
74
75
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)
82
83 struct eth1394hdr {
84         unsigned char   h_dest[ETH1394_ALEN];   /* destination eth1394 addr     */
85         unsigned short  h_proto;                /* packet type ID field */
86 }  __attribute__((packed));
87
88 static inline struct eth1394hdr *eth1394_hdr(const struct sk_buff *skb)
89 {
90         return (struct eth1394hdr *)skb_mac_header(skb);
91 }
92
93 typedef enum {ETH1394_GASP, ETH1394_WRREQ} eth1394_tx_type;
94
95 /* IP1394 headers */
96
97 /* Unfragmented */
98 #if defined __BIG_ENDIAN_BITFIELD
99 struct eth1394_uf_hdr {
100         u16 lf:2;
101         u16 res:14;
102         u16 ether_type;         /* Ethernet packet type */
103 } __attribute__((packed));
104 #elif defined __LITTLE_ENDIAN_BITFIELD
105 struct eth1394_uf_hdr {
106         u16 res:14;
107         u16 lf:2;
108         u16 ether_type;
109 } __attribute__((packed));
110 #else
111 #error Unknown bit field type
112 #endif
113
114 /* First fragment */
115 #if defined __BIG_ENDIAN_BITFIELD
116 struct eth1394_ff_hdr {
117         u16 lf:2;
118         u16 res1:2;
119         u16 dg_size:12;         /* Datagram size */
120         u16 ether_type;         /* Ethernet packet type */
121         u16 dgl;                /* Datagram label */
122         u16 res2;
123 } __attribute__((packed));
124 #elif defined __LITTLE_ENDIAN_BITFIELD
125 struct eth1394_ff_hdr {
126         u16 dg_size:12;
127         u16 res1:2;
128         u16 lf:2;
129         u16 ether_type;
130         u16 dgl;
131         u16 res2;
132 } __attribute__((packed));
133 #else
134 #error Unknown bit field type
135 #endif
136
137 /* XXX: Subsequent fragments, including last */
138 #if defined __BIG_ENDIAN_BITFIELD
139 struct eth1394_sf_hdr {
140         u16 lf:2;
141         u16 res1:2;
142         u16 dg_size:12;         /* Datagram size */
143         u16 res2:4;
144         u16 fg_off:12;          /* Fragment offset */
145         u16 dgl;                /* Datagram label */
146         u16 res3;
147 } __attribute__((packed));
148 #elif defined __LITTLE_ENDIAN_BITFIELD
149 struct eth1394_sf_hdr {
150         u16 dg_size:12;
151         u16 res1:2;
152         u16 lf:2;
153         u16 fg_off:12;
154         u16 res2:4;
155         u16 dgl;
156         u16 res3;
157 } __attribute__((packed));
158 #else
159 #error Unknown bit field type
160 #endif
161
162 #if defined __BIG_ENDIAN_BITFIELD
163 struct eth1394_common_hdr {
164         u16 lf:2;
165         u16 pad1:14;
166 } __attribute__((packed));
167 #elif defined __LITTLE_ENDIAN_BITFIELD
168 struct eth1394_common_hdr {
169         u16 pad1:14;
170         u16 lf:2;
171 } __attribute__((packed));
172 #else
173 #error Unknown bit field type
174 #endif
175
176 struct eth1394_hdr_words {
177         u16 word1;
178         u16 word2;
179         u16 word3;
180         u16 word4;
181 };
182
183 union eth1394_hdr {
184         struct eth1394_common_hdr common;
185         struct eth1394_uf_hdr uf;
186         struct eth1394_ff_hdr ff;
187         struct eth1394_sf_hdr sf;
188         struct eth1394_hdr_words words;
189 };
190
191 /* End of IP1394 headers */
192
193 /* Fragment types */
194 #define ETH1394_HDR_LF_UF       0       /* unfragmented         */
195 #define ETH1394_HDR_LF_FF       1       /* first fragment       */
196 #define ETH1394_HDR_LF_LF       2       /* last fragment        */
197 #define ETH1394_HDR_LF_IF       3       /* interior fragment    */
198
199 #define IP1394_HW_ADDR_LEN      16      /* As per RFC           */
200
201 /* Our arp packet (ARPHRD_IEEE1394) */
202 struct eth1394_arp {
203         u16 hw_type;            /* 0x0018       */
204         u16 proto_type;         /* 0x0806       */
205         u8 hw_addr_len;         /* 16           */
206         u8 ip_addr_len;         /* 4            */
207         u16 opcode;             /* ARP Opcode   */
208         /* Above is exactly the same format as struct arphdr */
209
210         u64 s_uniq_id;          /* Sender's 64bit EUI                   */
211         u8 max_rec;             /* Sender's max packet size             */
212         u8 sspd;                /* Sender's max speed                   */
213         u16 fifo_hi;            /* hi 16bits of sender's FIFO addr      */
214         u32 fifo_lo;            /* lo 32bits of sender's FIFO addr      */
215         u32 sip;                /* Sender's IP Address                  */
216         u32 tip;                /* IP Address of requested hw addr      */
217 };
218
219 /* Network timeout */
220 #define ETHER1394_TIMEOUT       100000
221
222 /* This is our task struct. It's used for the packet complete callback.  */
223 struct packet_task {
224         struct sk_buff *skb;
225         int outstanding_pkts;
226         eth1394_tx_type tx_type;
227         int max_payload;
228         struct hpsb_packet *packet;
229         struct eth1394_priv *priv;
230         union eth1394_hdr hdr;
231         u64 addr;
232         u16 dest_node;
233 };
234
235 #endif /* __ETH1394_H */