eth1394.h 6.13 KB
Newer Older
Ben Collins's avatar
Ben Collins committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*
 * eth1394.h -- Ethernet driver for Linux IEEE-1394 Subsystem
 *
 * Copyright (C) 2000 Bonin Franck <boninf@free.fr>
 *           (C) 2001 Ben Collins <bcollins@debian.org>
 *
 * Mainly based on work by Emanuel Pirker and Andreas E. Bombe
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef __ETH1394_H
#define __ETH1394_H

Ben Collins's avatar
Ben Collins committed
27 28
#include "ieee1394.h"

29 30 31
/* Register for incoming packets. This is 4096 bytes, which supports up to
 * S3200 (per Table 16-3 of IEEE 1394b-2002). */
#define ETHER1394_REGION_ADDR_LEN	4096
32 33

#define ETHER1394_INVALID_ADDR		~0ULL
Ben Collins's avatar
Ben Collins committed
34

Ben Collins's avatar
Ben Collins committed
35 36
/* GASP identifier numbers for IPv4 over IEEE 1394 */
#define ETHER1394_GASP_SPECIFIER_ID	0x00005E
Ben Collins's avatar
Ben Collins committed
37 38
#define ETHER1394_GASP_SPECIFIER_ID_HI	((ETHER1394_GASP_SPECIFIER_ID >> 8) & 0xffff)
#define ETHER1394_GASP_SPECIFIER_ID_LO	(ETHER1394_GASP_SPECIFIER_ID & 0xff)
Ben Collins's avatar
Ben Collins committed
39 40
#define ETHER1394_GASP_VERSION		1

Ben Collins's avatar
Ben Collins committed
41
#define ETHER1394_GASP_OVERHEAD (2 * sizeof(quadlet_t))  /* GASP header overhead */
Ben Collins's avatar
Ben Collins committed
42

43 44
#define ETHER1394_GASP_BUFFERS 16

Ben Collins's avatar
Ben Collins committed
45 46 47
/* Node set == 64 */
#define NODE_SET			(ALL_NODES + 1)

48 49 50
enum eth1394_bc_states { ETHER1394_BC_ERROR,
			 ETHER1394_BC_RUNNING,
			 ETHER1394_BC_STOPPED };
Ben Collins's avatar
Ben Collins committed
51

Ben Collins's avatar
Ben Collins committed
52

Ben Collins's avatar
Ben Collins committed
53 54 55 56
/* Private structure for our ethernet driver */
struct eth1394_priv {
	struct net_device_stats stats;	/* Device stats			 */
	struct hpsb_host *host;		/* The card for this dev	 */
57 58 59
	u16 bc_maxpayload;		/* Max broadcast payload	 */
	u8 bc_sspd;			/* Max broadcast speed		 */
	u64 local_fifo;			/* Local FIFO Address		 */
Ben Collins's avatar
Ben Collins committed
60
	spinlock_t lock;		/* Private lock			 */
Ben Collins's avatar
Ben Collins committed
61 62 63
	int broadcast_channel;		/* Async stream Broadcast Channel */
	enum eth1394_bc_states bc_state; /* broadcast channel state	 */
	struct hpsb_iso *iso;		/* Async stream recv handle	 */
64 65 66
	int bc_dgl;			/* Outgoing broadcast datagram label */
	struct list_head ip_node_list;	/* List of IP capable nodes	 */
	struct unit_directory *ud_list[ALL_NODES]; /* Cached unit dir list */
Ben Collins's avatar
Ben Collins committed
67 68
};

Ben Collins's avatar
Ben Collins committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83

/* Define a fake hardware header format for the networking core.  Note that
 * header size cannot exceed 16 bytes as that is the size of the header cache.
 * Also, we do not need the source address in the header so we omit it and
 * keep the header to under 16 bytes */
#define ETH1394_ALEN (8)
#define ETH1394_HLEN (10)

struct eth1394hdr {
	unsigned char	h_dest[ETH1394_ALEN];	/* destination eth1394 addr	*/
	unsigned short	h_proto;		/* packet type ID field	*/
}  __attribute__((packed));



Ben Collins's avatar
Ben Collins committed
84 85
typedef enum {ETH1394_GASP, ETH1394_WRREQ} eth1394_tx_type;

Ben Collins's avatar
Ben Collins committed
86 87 88 89 90 91
/* IP1394 headers */
#include <asm/byteorder.h>

/* Unfragmented */
#if defined __BIG_ENDIAN_BITFIELD
struct eth1394_uf_hdr {
Ben Collins's avatar
Ben Collins committed
92
	u16 lf:2;
Ben Collins's avatar
Ben Collins committed
93 94 95 96 97 98
	u16 res:14;
	u16 ether_type;		/* Ethernet packet type */
} __attribute__((packed));
#elif defined __LITTLE_ENDIAN_BITFIELD
struct eth1394_uf_hdr {
	u16 res:14;
Ben Collins's avatar
Ben Collins committed
99
	u16 lf:2;
Ben Collins's avatar
Ben Collins committed
100 101 102 103 104 105 106 107 108
	u16 ether_type;
} __attribute__((packed));
#else
#error Unknown bit field type
#endif

/* First fragment */
#if defined __BIG_ENDIAN_BITFIELD
struct eth1394_ff_hdr {
Ben Collins's avatar
Ben Collins committed
109 110
	u16 lf:2;
	u16 res1:2;
Ben Collins's avatar
Ben Collins committed
111 112 113 114 115 116 117 118
	u16 dg_size:12;		/* Datagram size */
	u16 ether_type;		/* Ethernet packet type */
	u16 dgl;		/* Datagram label */
	u16 res2;
} __attribute__((packed));
#elif defined __LITTLE_ENDIAN_BITFIELD
struct eth1394_ff_hdr {
	u16 dg_size:12;
Ben Collins's avatar
Ben Collins committed
119 120
	u16 res1:2;
	u16 lf:2;
Ben Collins's avatar
Ben Collins committed
121 122 123 124 125 126 127 128 129 130 131
	u16 ether_type;
	u16 dgl;
	u16 res2;
} __attribute__((packed));
#else
#error Unknown bit field type
#endif

/* XXX: Subsequent fragments, including last */
#if defined __BIG_ENDIAN_BITFIELD
struct eth1394_sf_hdr {
Ben Collins's avatar
Ben Collins committed
132 133
	u16 lf:2;
	u16 res1:2;
Ben Collins's avatar
Ben Collins committed
134
	u16 dg_size:12;		/* Datagram size */
Ben Collins's avatar
Ben Collins committed
135 136
	u16 res2:4;
	u16 fg_off:12;		/* Fragment offset */
Ben Collins's avatar
Ben Collins committed
137 138 139 140 141 142
	u16 dgl;		/* Datagram label */
	u16 res3;
} __attribute__((packed));
#elif defined __LITTLE_ENDIAN_BITFIELD
struct eth1394_sf_hdr {
	u16 dg_size:12;
Ben Collins's avatar
Ben Collins committed
143 144 145 146
	u16 res1:2;
	u16 lf:2;
	u16 fg_off:12;
	u16 res2:4;
Ben Collins's avatar
Ben Collins committed
147 148 149 150 151 152 153 154 155
	u16 dgl;
	u16 res3;
} __attribute__((packed));
#else
#error Unknown bit field type
#endif

#if defined __BIG_ENDIAN_BITFIELD
struct eth1394_common_hdr {
Ben Collins's avatar
Ben Collins committed
156
	u16 lf:2;
Ben Collins's avatar
Ben Collins committed
157 158 159 160 161
	u16 pad1:14;
} __attribute__((packed));
#elif defined __LITTLE_ENDIAN_BITFIELD
struct eth1394_common_hdr {
	u16 pad1:14;
Ben Collins's avatar
Ben Collins committed
162
	u16 lf:2;
Ben Collins's avatar
Ben Collins committed
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
} __attribute__((packed));
#else
#error Unknown bit field type
#endif

struct eth1394_hdr_words {
	u16 word1;
	u16 word2;
	u16 word3;
	u16 word4;
};

union eth1394_hdr {
	struct eth1394_common_hdr common;
	struct eth1394_uf_hdr uf;
	struct eth1394_ff_hdr ff;
	struct eth1394_sf_hdr sf;
	struct eth1394_hdr_words words;
};

/* End of IP1394 headers */

/* Fragment types */
#define ETH1394_HDR_LF_UF	0	/* unfragmented		*/
#define ETH1394_HDR_LF_FF	1	/* first fragment	*/
#define ETH1394_HDR_LF_LF	2	/* last fragment	*/
#define ETH1394_HDR_LF_IF	3	/* interior fragment	*/

#define IP1394_HW_ADDR_LEN	16	/* As per RFC		*/

/* Our arp packet (ARPHRD_IEEE1394) */
struct eth1394_arp {
	u16 hw_type;		/* 0x0018	*/
	u16 proto_type;		/* 0x0806	*/
	u8 hw_addr_len;		/* 16 		*/
	u8 ip_addr_len;		/* 4		*/
	u16 opcode;		/* ARP Opcode	*/
	/* Above is exactly the same format as struct arphdr */

	u64 s_uniq_id;		/* Sender's 64bit EUI			*/
	u8 max_rec;		/* Sender's max packet size		*/
	u8 sspd;		/* Sender's max speed			*/
	u16 fifo_hi;		/* hi 16bits of sender's FIFO addr	*/
	u32 fifo_lo;		/* lo 32bits of sender's FIFO addr	*/
	u32 sip;		/* Sender's IP Address			*/
	u32 tip;		/* IP Address of requested hw addr	*/
};

/* Network timeout */
#define ETHER1394_TIMEOUT	100000

Ben Collins's avatar
Ben Collins committed
214 215 216 217 218 219 220 221 222 223 224 225 226
/* This is our task struct. It's used for the packet complete callback.  */
struct packet_task {
	struct sk_buff *skb;
	int outstanding_pkts;
	eth1394_tx_type tx_type;
	int max_payload;
	struct hpsb_packet *packet;
	struct eth1394_priv *priv;
	union eth1394_hdr hdr;
	u64 addr;
	u16 dest_node;
};

Ben Collins's avatar
Ben Collins committed
227
#endif /* __ETH1394_H */