setup enviroment for compilation
[linux-2.4.21-pre4.git] / 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 /* Register for incoming packets. This is 8192 bytes, which supports up to
28  * 1600mbs. We'll need to change this if that ever becomes "small" :)  */
29 #define ETHER1394_REGION_ADDR_LEN       8192
30 #define ETHER1394_REGION_ADDR           0xfffff0200000ULL
31 #define ETHER1394_REGION_ADDR_END       (ETHER1394_REGION_ADDR + ETHER1394_REGION_ADDR_LEN)
32
33 /* Node set == 64 */
34 #define NODE_SET                        (ALL_NODES + 1)
35
36 /* Private structure for our ethernet driver */
37 struct eth1394_priv {
38         struct net_device_stats stats;  /* Device stats                  */
39         struct hpsb_host *host;         /* The card for this dev         */
40         unsigned char max_rec[NODE_SET];/* Max payload per node          */
41         unsigned char sspd[NODE_SET];   /* Max speed per node            */
42         u16 fifo_hi[ALL_NODES];         /* 16bit hi fifo offset per node */
43         u32 fifo_lo[ALL_NODES];         /* 32bit lo fifo offset per node */
44         u64 eui[ALL_NODES];             /* EUI-64 per node               */
45         spinlock_t lock;                /* Private lock                  */
46 };
47
48 struct host_info {
49         struct list_head list;
50         struct hpsb_host *host;
51         struct net_device *dev;
52 };
53
54 /* This is our task struct. It's used for the packet complete callback.  */
55 struct packet_task {
56         struct sk_buff *skb;    /* Socket buffer we are sending */
57         nodeid_t dest_node;     /* Destination of the packet */
58         u64 addr;               /* Address */
59         struct hpsb_queue_struct tq;    /* The task */
60 };
61
62 /* IP1394 headers */
63 #include <asm/byteorder.h>
64
65 /* Unfragmented */
66 #if defined __BIG_ENDIAN_BITFIELD
67 struct eth1394_uf_hdr {
68         u8 lf:2;
69         u16 res:14;
70         u16 ether_type;         /* Ethernet packet type */
71 } __attribute__((packed));
72 #elif defined __LITTLE_ENDIAN_BITFIELD
73 struct eth1394_uf_hdr {
74         u16 res:14;
75         u8 lf:2;
76         u16 ether_type;
77 } __attribute__((packed));
78 #else
79 #error Unknown bit field type
80 #endif
81
82 /* First fragment */
83 #if defined __BIG_ENDIAN_BITFIELD
84 struct eth1394_ff_hdr {
85         u8 lf:2;
86         u8 res1:2;
87         u16 dg_size:12;         /* Datagram size */
88         u16 ether_type;         /* Ethernet packet type */
89         u16 dgl;                /* Datagram label */
90         u16 res2;
91 } __attribute__((packed));
92 #elif defined __LITTLE_ENDIAN_BITFIELD
93 struct eth1394_ff_hdr {
94         u16 dg_size:12;
95         u8 res1:2;
96         u8 lf:2;
97         u16 ether_type;
98         u16 dgl;
99         u16 res2;
100 } __attribute__((packed));
101 #else
102 #error Unknown bit field type
103 #endif
104
105 /* XXX: Subsequent fragments, including last */
106 #if defined __BIG_ENDIAN_BITFIELD
107 struct eth1394_sf_hdr {
108         u8 lf:2;
109         u8 res1:2;
110         u16 dg_size:12;         /* Datagram size */
111         u8 res2:6;
112         u16 fg_off:10;          /* Fragment offset */
113         u16 dgl;                /* Datagram label */
114         u16 res3;
115 } __attribute__((packed));
116 #elif defined __LITTLE_ENDIAN_BITFIELD
117 struct eth1394_sf_hdr {
118         u16 dg_size:12;
119         u8 res1:2;
120         u8 lf:2;
121         u16 fg_off:10;
122         u8 res2:6;
123         u16 dgl;
124         u16 res3;
125 } __attribute__((packed));
126 #else
127 #error Unknown bit field type
128 #endif
129
130 #if defined __BIG_ENDIAN_BITFIELD
131 struct eth1394_common_hdr {
132         u8 lf:2;
133         u16 pad1:14;
134 } __attribute__((packed));
135 #elif defined __LITTLE_ENDIAN_BITFIELD
136 struct eth1394_common_hdr {
137         u16 pad1:14;
138         u8 lf:2;
139 } __attribute__((packed));
140 #else
141 #error Unknown bit field type
142 #endif
143
144 struct eth1394_hdr_words {
145         u16 word1;
146         u16 word2;
147         u16 word3;
148         u16 word4;
149 };
150
151 union eth1394_hdr {
152         struct eth1394_common_hdr common;
153         struct eth1394_uf_hdr uf;
154         struct eth1394_ff_hdr ff;
155         struct eth1394_sf_hdr sf;
156         struct eth1394_hdr_words words;
157 };
158
159 /* End of IP1394 headers */
160
161 /* Fragment types */
162 #define ETH1394_HDR_LF_UF       0       /* unfragmented         */
163 #define ETH1394_HDR_LF_FF       1       /* first fragment       */
164 #define ETH1394_HDR_LF_LF       2       /* last fragment        */
165 #define ETH1394_HDR_LF_IF       3       /* interior fragment    */
166
167 #define IP1394_HW_ADDR_LEN      16      /* As per RFC           */
168
169 /* Our arp packet (ARPHRD_IEEE1394) */
170 struct eth1394_arp {
171         u16 hw_type;            /* 0x0018       */
172         u16 proto_type;         /* 0x0806       */
173         u8 hw_addr_len;         /* 16           */
174         u8 ip_addr_len;         /* 4            */
175         u16 opcode;             /* ARP Opcode   */
176         /* Above is exactly the same format as struct arphdr */
177
178         u64 s_uniq_id;          /* Sender's 64bit EUI                   */
179         u8 max_rec;             /* Sender's max packet size             */
180         u8 sspd;                /* Sender's max speed                   */
181         u16 fifo_hi;            /* hi 16bits of sender's FIFO addr      */
182         u32 fifo_lo;            /* lo 32bits of sender's FIFO addr      */
183         u32 sip;                /* Sender's IP Address                  */
184         u32 tip;                /* IP Address of requested hw addr      */
185 };
186
187 /* Network timeout */
188 #define ETHER1394_TIMEOUT       100000
189
190 #endif /* __ETH1394_H */