| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> | 
| Stefan Richter | efbeccf | 2007-04-02 02:12:32 +0200 | [diff] [blame] | 28 | #include <linux/skbuff.h> | 
 | 29 | #include <asm/byteorder.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 |  | 
 | 31 | #include "ieee1394.h" | 
| Stefan Richter | e167c88 | 2007-03-05 03:07:38 +0100 | [diff] [blame] | 32 | #include "ieee1394_types.h" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | /* GASP identifier numbers for IPv4 over IEEE 1394 */ | 
 | 39 | #define ETHER1394_GASP_SPECIFIER_ID	0x00005E | 
| Stefan Richter | efbeccf | 2007-04-02 02:12:32 +0200 | [diff] [blame] | 40 | #define ETHER1394_GASP_SPECIFIER_ID_HI	((0x00005E >> 8) & 0xffff) | 
 | 41 | #define ETHER1394_GASP_SPECIFIER_ID_LO	(0x00005E & 0xff) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #define ETHER1394_GASP_VERSION		1 | 
 | 43 |  | 
| Stefan Richter | efbeccf | 2007-04-02 02:12:32 +0200 | [diff] [blame] | 44 | #define ETHER1394_GASP_OVERHEAD	(2 * sizeof(quadlet_t))	/* for GASP header */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 |  | 
| Stefan Richter | efbeccf | 2007-04-02 02:12:32 +0200 | [diff] [blame] | 46 | #define ETHER1394_GASP_BUFFERS	16 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 |  | 
| Stefan Richter | efbeccf | 2007-04-02 02:12:32 +0200 | [diff] [blame] | 48 | #define NODE_SET		(ALL_NODES + 1)		/* Node set == 64 */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | 	struct hpsb_host *host;		/* The card for this dev	 */ | 
 | 58 | 	u16 bc_maxpayload;		/* Max broadcast payload	 */ | 
 | 59 | 	u8 bc_sspd;			/* Max broadcast speed		 */ | 
 | 60 | 	u64 local_fifo;			/* Local FIFO Address		 */ | 
 | 61 | 	spinlock_t lock;		/* Private lock			 */ | 
 | 62 | 	int broadcast_channel;		/* Async stream Broadcast Channel */ | 
 | 63 | 	enum eth1394_bc_states bc_state; /* broadcast channel state	 */ | 
 | 64 | 	struct hpsb_iso *iso;		/* Async stream recv handle	 */ | 
 | 65 | 	int bc_dgl;			/* Outgoing broadcast datagram label */ | 
 | 66 | 	struct list_head ip_node_list;	/* List of IP capable nodes	 */ | 
 | 67 | 	struct unit_directory *ud_list[ALL_NODES]; /* Cached unit dir list */ | 
| Stefan Richter | 7a97bc0 | 2007-05-05 17:25:51 +0200 | [diff] [blame] | 68 |  | 
 | 69 | 	struct work_struct wake;	/* Wake up after xmit failure	 */ | 
 | 70 | 	struct net_device *wake_dev;	/* Stupid backlink for .wake	 */ | 
 | 71 | 	nodeid_t wake_node;		/* Destination of failed xmit	 */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | }; | 
 | 73 |  | 
 | 74 |  | 
 | 75 | /* Define a fake hardware header format for the networking core.  Note that | 
 | 76 |  * header size cannot exceed 16 bytes as that is the size of the header cache. | 
 | 77 |  * Also, we do not need the source address in the header so we omit it and | 
 | 78 |  * keep the header to under 16 bytes */ | 
 | 79 | #define ETH1394_ALEN (8) | 
 | 80 | #define ETH1394_HLEN (10) | 
 | 81 |  | 
 | 82 | struct eth1394hdr { | 
 | 83 | 	unsigned char	h_dest[ETH1394_ALEN];	/* destination eth1394 addr	*/ | 
| Harvey Harrison | faf26bc | 2008-12-13 15:03:06 -0800 | [diff] [blame] | 84 | 	__be16		h_proto;		/* packet type ID field	*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | }  __attribute__((packed)); | 
 | 86 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | static inline struct eth1394hdr *eth1394_hdr(const struct sk_buff *skb) | 
 | 88 | { | 
| Arnaldo Carvalho de Melo | 98e399f | 2007-03-19 15:33:04 -0700 | [diff] [blame] | 89 | 	return (struct eth1394hdr *)skb_mac_header(skb); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 |  | 
 | 92 | typedef enum {ETH1394_GASP, ETH1394_WRREQ} eth1394_tx_type; | 
 | 93 |  | 
 | 94 | /* IP1394 headers */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 |  | 
 | 96 | /* Unfragmented */ | 
 | 97 | #if defined __BIG_ENDIAN_BITFIELD | 
 | 98 | struct eth1394_uf_hdr { | 
 | 99 | 	u16 lf:2; | 
 | 100 | 	u16 res:14; | 
| Harvey Harrison | faf26bc | 2008-12-13 15:03:06 -0800 | [diff] [blame] | 101 | 	__be16 ether_type;		/* Ethernet packet type */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | } __attribute__((packed)); | 
 | 103 | #elif defined __LITTLE_ENDIAN_BITFIELD | 
 | 104 | struct eth1394_uf_hdr { | 
 | 105 | 	u16 res:14; | 
 | 106 | 	u16 lf:2; | 
| Harvey Harrison | faf26bc | 2008-12-13 15:03:06 -0800 | [diff] [blame] | 107 | 	__be16 ether_type; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | } __attribute__((packed)); | 
 | 109 | #else | 
 | 110 | #error Unknown bit field type | 
 | 111 | #endif | 
 | 112 |  | 
 | 113 | /* First fragment */ | 
 | 114 | #if defined __BIG_ENDIAN_BITFIELD | 
 | 115 | struct eth1394_ff_hdr { | 
 | 116 | 	u16 lf:2; | 
 | 117 | 	u16 res1:2; | 
 | 118 | 	u16 dg_size:12;		/* Datagram size */ | 
| Harvey Harrison | faf26bc | 2008-12-13 15:03:06 -0800 | [diff] [blame] | 119 | 	__be16 ether_type;		/* Ethernet packet type */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | 	u16 dgl;		/* Datagram label */ | 
 | 121 | 	u16 res2; | 
 | 122 | } __attribute__((packed)); | 
 | 123 | #elif defined __LITTLE_ENDIAN_BITFIELD | 
 | 124 | struct eth1394_ff_hdr { | 
 | 125 | 	u16 dg_size:12; | 
 | 126 | 	u16 res1:2; | 
 | 127 | 	u16 lf:2; | 
| Harvey Harrison | faf26bc | 2008-12-13 15:03:06 -0800 | [diff] [blame] | 128 | 	__be16 ether_type; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | 	u16 dgl; | 
 | 130 | 	u16 res2; | 
 | 131 | } __attribute__((packed)); | 
 | 132 | #else | 
 | 133 | #error Unknown bit field type | 
 | 134 | #endif | 
 | 135 |  | 
 | 136 | /* XXX: Subsequent fragments, including last */ | 
 | 137 | #if defined __BIG_ENDIAN_BITFIELD | 
 | 138 | struct eth1394_sf_hdr { | 
 | 139 | 	u16 lf:2; | 
 | 140 | 	u16 res1:2; | 
 | 141 | 	u16 dg_size:12;		/* Datagram size */ | 
 | 142 | 	u16 res2:4; | 
 | 143 | 	u16 fg_off:12;		/* Fragment offset */ | 
 | 144 | 	u16 dgl;		/* Datagram label */ | 
 | 145 | 	u16 res3; | 
 | 146 | } __attribute__((packed)); | 
 | 147 | #elif defined __LITTLE_ENDIAN_BITFIELD | 
 | 148 | struct eth1394_sf_hdr { | 
 | 149 | 	u16 dg_size:12; | 
 | 150 | 	u16 res1:2; | 
 | 151 | 	u16 lf:2; | 
 | 152 | 	u16 fg_off:12; | 
 | 153 | 	u16 res2:4; | 
 | 154 | 	u16 dgl; | 
 | 155 | 	u16 res3; | 
 | 156 | } __attribute__((packed)); | 
 | 157 | #else | 
 | 158 | #error Unknown bit field type | 
 | 159 | #endif | 
 | 160 |  | 
 | 161 | #if defined __BIG_ENDIAN_BITFIELD | 
 | 162 | struct eth1394_common_hdr { | 
 | 163 | 	u16 lf:2; | 
 | 164 | 	u16 pad1:14; | 
 | 165 | } __attribute__((packed)); | 
 | 166 | #elif defined __LITTLE_ENDIAN_BITFIELD | 
 | 167 | struct eth1394_common_hdr { | 
 | 168 | 	u16 pad1:14; | 
 | 169 | 	u16 lf:2; | 
 | 170 | } __attribute__((packed)); | 
 | 171 | #else | 
 | 172 | #error Unknown bit field type | 
 | 173 | #endif | 
 | 174 |  | 
 | 175 | struct eth1394_hdr_words { | 
 | 176 | 	u16 word1; | 
 | 177 | 	u16 word2; | 
 | 178 | 	u16 word3; | 
 | 179 | 	u16 word4; | 
 | 180 | }; | 
 | 181 |  | 
 | 182 | union eth1394_hdr { | 
 | 183 | 	struct eth1394_common_hdr common; | 
 | 184 | 	struct eth1394_uf_hdr uf; | 
 | 185 | 	struct eth1394_ff_hdr ff; | 
 | 186 | 	struct eth1394_sf_hdr sf; | 
 | 187 | 	struct eth1394_hdr_words words; | 
 | 188 | }; | 
 | 189 |  | 
 | 190 | /* End of IP1394 headers */ | 
 | 191 |  | 
 | 192 | /* Fragment types */ | 
 | 193 | #define ETH1394_HDR_LF_UF	0	/* unfragmented		*/ | 
 | 194 | #define ETH1394_HDR_LF_FF	1	/* first fragment	*/ | 
 | 195 | #define ETH1394_HDR_LF_LF	2	/* last fragment	*/ | 
 | 196 | #define ETH1394_HDR_LF_IF	3	/* interior fragment	*/ | 
 | 197 |  | 
 | 198 | #define IP1394_HW_ADDR_LEN	16	/* As per RFC		*/ | 
 | 199 |  | 
 | 200 | /* Our arp packet (ARPHRD_IEEE1394) */ | 
 | 201 | struct eth1394_arp { | 
 | 202 | 	u16 hw_type;		/* 0x0018	*/ | 
 | 203 | 	u16 proto_type;		/* 0x0806	*/ | 
 | 204 | 	u8 hw_addr_len;		/* 16 		*/ | 
 | 205 | 	u8 ip_addr_len;		/* 4		*/ | 
 | 206 | 	u16 opcode;		/* ARP Opcode	*/ | 
 | 207 | 	/* Above is exactly the same format as struct arphdr */ | 
 | 208 |  | 
| Harvey Harrison | faf26bc | 2008-12-13 15:03:06 -0800 | [diff] [blame] | 209 | 	__be64 s_uniq_id;	/* Sender's 64bit EUI		*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | 	u8 max_rec;		/* Sender's max packet size		*/ | 
 | 211 | 	u8 sspd;		/* Sender's max speed			*/ | 
| Harvey Harrison | faf26bc | 2008-12-13 15:03:06 -0800 | [diff] [blame] | 212 | 	__be16 fifo_hi;		/* hi 16bits of sender's FIFO addr	*/ | 
 | 213 | 	__be32 fifo_lo;		/* lo 32bits of sender's FIFO addr	*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | 	u32 sip;		/* Sender's IP Address			*/ | 
 | 215 | 	u32 tip;		/* IP Address of requested hw addr	*/ | 
 | 216 | }; | 
 | 217 |  | 
 | 218 | /* Network timeout */ | 
 | 219 | #define ETHER1394_TIMEOUT	100000 | 
 | 220 |  | 
 | 221 | /* This is our task struct. It's used for the packet complete callback.  */ | 
 | 222 | struct packet_task { | 
 | 223 | 	struct sk_buff *skb; | 
 | 224 | 	int outstanding_pkts; | 
 | 225 | 	eth1394_tx_type tx_type; | 
 | 226 | 	int max_payload; | 
 | 227 | 	struct hpsb_packet *packet; | 
 | 228 | 	struct eth1394_priv *priv; | 
 | 229 | 	union eth1394_hdr hdr; | 
 | 230 | 	u64 addr; | 
 | 231 | 	u16 dest_node; | 
 | 232 | }; | 
 | 233 |  | 
 | 234 | #endif /* __ETH1394_H */ |