Xenomai 3.3.2
Loading...
Searching...
No Matches
rt_eth1394.h
1/*
2 * eth1394.h -- Driver for Ethernet emulation over FireWire, (adapted from Linux1394)
3 * working under RTnet.
4 *
5 * Copyright (C) 2005 Zhang Yuchen <yuchen623@gmail.com>
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 <ieee1394.h>
28#include <rtskb.h>
29#include <linux/netdevice.h>
30#include <rtnet_port.h>
31
32
33/* Register for incoming packets. This is 4096 bytes, which supports up to
34 * S3200 (per Table 16-3 of IEEE 1394b-2002). */
35#define ETHER1394_REGION_ADDR_LEN 4096
36#define ETHER1394_REGION_ADDR 0xfffff0200000ULL
37#define ETHER1394_REGION_ADDR_END (ETHER1394_REGION_ADDR + ETHER1394_REGION_ADDR_LEN)
38
39/* GASP identifier numbers for IPv4 over IEEE 1394 */
40#define ETHER1394_GASP_SPECIFIER_ID 0x00005E
41#define ETHER1394_GASP_SPECIFIER_ID_HI ((ETHER1394_GASP_SPECIFIER_ID >> 8) & 0xffff)
42#define ETHER1394_GASP_SPECIFIER_ID_LO (ETHER1394_GASP_SPECIFIER_ID & 0xff)
43#define ETHER1394_GASP_VERSION 1
44
45#define ETHER1394_GASP_OVERHEAD (2 * sizeof(quadlet_t)) /* GASP header overhead */
46
47#define ETHER1394_GASP_BUFFERS 16
48
49#define ETH1394_BC_CHANNEL 31
50
51#define ALL_NODES 0x003f //stolen from ieee1394_types.h
52/* Node set == 64 */
53#define NODE_SET (ALL_NODES + 1)
54
55enum eth1394_bc_states { ETHER1394_BC_CLOSED, ETHER1394_BC_OPENED,
56 ETHER1394_BC_CHECK, ETHER1394_BC_ERROR,
57 ETHER1394_BC_RUNNING,
58 ETHER1394_BC_STOPPED };
59
60#define TX_RING_SIZE 32
61#define RX_RING_SIZE 8 /* RX_RING_SIZE*2 rtskbs will be preallocated */
62
63struct pdg_list {
64 struct list_head list; /* partial datagram list per node */
65 unsigned int sz; /* partial datagram list size per node */
66 rtdm_lock_t lock; /* partial datagram lock */
67};
68
69/* IP1394 headers */
70#include <asm/byteorder.h>
71
72/* Unfragmented */
73#if defined __BIG_ENDIAN_BITFIELD
74struct eth1394_uf_hdr {
75 u16 lf:2;
76 u16 res:14;
77 u16 ether_type; /* Ethernet packet type */
78} __attribute__((packed));
79#elif defined __LITTLE_ENDIAN_BITFIELD
80struct eth1394_uf_hdr {
81 u16 res:14;
82 u16 lf:2;
83 u16 ether_type;
84} __attribute__((packed));
85#else
86#error Unknown bit field type
87#endif
88
89/* End of IP1394 headers */
90
91/* Fragment types */
92#define ETH1394_HDR_LF_UF 0 /* unfragmented */
93#define ETH1394_HDR_LF_FF 1 /* first fragment */
94#define ETH1394_HDR_LF_LF 2 /* last fragment */
95#define ETH1394_HDR_LF_IF 3 /* interior fragment */
96
97#define IP1394_HW_ADDR_LEN 2 /* In RFC, the value is 16; here use the value for modified spec */
98
99/* Our arp packet (ARPHRD_IEEE1394) */
100struct eth1394_arp {
101 u16 hw_type; /* 0x0018 */
102 u16 proto_type; /* 0x0080 */
103 u8 hw_addr_len; /* 2 */
104 u8 ip_addr_len; /* 4 */
105 u16 opcode; /* ARP Opcode: 1 for req, 2 for resp */
106 /* Above is exactly the same format as struct arphdr */
107
108 unsigned char s_uniq_id[ETH_ALEN]; /* Sender's node id padded with zeros */
109 u8 max_rec; /* Sender's max packet size */
110 u8 sspd; /* Sender's max speed */
111 u32 sip; /* Sender's IP Address */
112 u32 tip; /* IP Address of requested hw addr */
113};
114
115
116/* Network timeout */
117#define ETHER1394_TIMEOUT 100000
118
119/* First fragment */
120#if defined __BIG_ENDIAN_BITFIELD
121struct eth1394_ff_hdr {
122 u16 lf:2;
123 u16 res1:2;
124 u16 dg_size:12; /* Datagram size */
125 u16 ether_type; /* Ethernet packet type */
126 u16 dgl; /* Datagram label */
127 u16 res2;
128} __attribute__((packed));
129#elif defined __LITTLE_ENDIAN_BITFIELD
130struct eth1394_ff_hdr {
131 u16 dg_size:12;
132 u16 res1:2;
133 u16 lf:2;
134 u16 ether_type;
135 u16 dgl;
136 u16 res2;
137} __attribute__((packed));
138#else
139#error Unknown bit field type
140#endif
141
142/* XXX: Subsequent fragments, including last */
143#if defined __BIG_ENDIAN_BITFIELD
144struct eth1394_sf_hdr {
145 u16 lf:2;
146 u16 res1:2;
147 u16 dg_size:12; /* Datagram size */
148 u16 res2:4;
149 u16 fg_off:12; /* Fragment offset */
150 u16 dgl; /* Datagram label */
151 u16 res3;
152} __attribute__((packed));
153#elif defined __LITTLE_ENDIAN_BITFIELD
154struct eth1394_sf_hdr {
155 u16 dg_size:12;
156 u16 res1:2;
157 u16 lf:2;
158 u16 fg_off:12;
159 u16 res2:4;
160 u16 dgl;
161 u16 res3;
162} __attribute__((packed));
163#else
164#error Unknown bit field type
165#endif
166
167#if defined __BIG_ENDIAN_BITFIELD
168struct eth1394_common_hdr {
169 u16 lf:2;
170 u16 pad1:14;
171} __attribute__((packed));
172#elif defined __LITTLE_ENDIAN_BITFIELD
173struct eth1394_common_hdr {
174 u16 pad1:14;
175 u16 lf:2;
176} __attribute__((packed));
177#else
178#error Unknown bit field type
179#endif
180
181struct eth1394_hdr_words {
182 u16 word1;
183 u16 word2;
184 u16 word3;
185 u16 word4;
186};
187
188union eth1394_hdr {
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;
194};
195
196typedef enum {ETH1394_GASP, ETH1394_WRREQ} eth1394_tx_type;
197
198/* This is our task struct. It's used for the packet complete callback. */
199struct packet_task {
200 struct list_head lh;
201 struct rtskb *skb;
202 int outstanding_pkts;
203 eth1394_tx_type tx_type;
204 int max_payload;
205 struct hpsb_packet *packet;
206 struct eth1394_priv *priv;
207 union eth1394_hdr hdr;
208 u64 addr;
209 u16 dest_node;
210 unsigned int priority; //the priority mapped to priority on 1394 transaction
211};
212
213/* Private structure for our ethernet driver */
214struct eth1394_priv {
215 struct net_device_stats stats; /* Device stats */
216 struct hpsb_host *host; /* The card for this dev */
217 u16 maxpayload[NODE_SET]; /* Max payload per node */
218 unsigned char sspd[NODE_SET]; /* Max speed per node */
219 rtdm_lock_t lock; /* Private lock */
220 int broadcast_channel; /* Async stream Broadcast Channel */
221 enum eth1394_bc_states bc_state; /* broadcast channel state */
222 struct hpsb_iso *iso;
223 struct pdg_list pdg[ALL_NODES]; /* partial RX datagram lists */
224 int dgl[NODE_SET]; /* Outgoing datagram label per node */
225
226 /* The addresses of a Tx/Rx-in-place packets/buffers. */
227 struct rtskb *tx_skbuff[TX_RING_SIZE];
228 struct rtskb *rx_skbuff[RX_RING_SIZE];
229 struct packet_task ptask_list[20]; //the list of pre-allocated ptask structure
230};
231
232
233
234struct host_info {
235 struct hpsb_host *host;
236 struct rtnet_device *dev;
237};
238
239
240#endif /* __ETH1394_H */
pipeline_spinlock_t rtdm_lock_t
Lock variable.
Definition driver.h:552