aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2007-04-01 20:12:32 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2007-04-29 18:00:30 -0400
commitefbeccf174bac803421a5f35076a17af47c9ce00 (patch)
treefb1d033560db36ad444cdf933284157395fb4963 /drivers/ieee1394
parent09d7a96f5ad1019386594e2795c1f0229dd43305 (diff)
ieee1394: eth1394: coding style
Adjust white space and line wraps. Remove unnecessary parentheses and braces, unused macros, and some of the more redundant comments. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/ieee1394')
-rw-r--r--drivers/ieee1394/eth1394.c426
-rw-r--r--drivers/ieee1394/eth1394.h24
2 files changed, 206 insertions, 244 deletions
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
index f7b47b981fd1..ce146b32f5c5 100644
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * eth1394.c -- Ethernet driver for Linux IEEE-1394 Subsystem 2 * eth1394.c -- IPv4 driver for Linux IEEE-1394 Subsystem
3 * 3 *
4 * Copyright (C) 2001-2003 Ben Collins <bcollins@debian.org> 4 * Copyright (C) 2001-2003 Ben Collins <bcollins@debian.org>
5 * 2000 Bonin Franck <boninf@free.fr> 5 * 2000 Bonin Franck <boninf@free.fr>
@@ -22,10 +22,9 @@
22 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 */ 23 */
24 24
25/* This driver intends to support RFC 2734, which describes a method for 25/*
26 * transporting IPv4 datagrams over IEEE-1394 serial busses. This driver 26 * This driver intends to support RFC 2734, which describes a method for
27 * will ultimately support that method, but currently falls short in 27 * transporting IPv4 datagrams over IEEE-1394 serial busses.
28 * several areas.
29 * 28 *
30 * TODO: 29 * TODO:
31 * RFC 2734 related: 30 * RFC 2734 related:
@@ -40,7 +39,6 @@
40 * - Consider garbage collecting old partial datagrams after X amount of time 39 * - Consider garbage collecting old partial datagrams after X amount of time
41 */ 40 */
42 41
43
44#include <linux/module.h> 42#include <linux/module.h>
45 43
46#include <linux/kernel.h> 44#include <linux/kernel.h>
@@ -84,10 +82,6 @@
84#define ETH1394_PRINT(level, dev_name, fmt, args...) \ 82#define ETH1394_PRINT(level, dev_name, fmt, args...) \
85 printk(level "%s: %s: " fmt, driver_name, dev_name, ## args) 83 printk(level "%s: %s: " fmt, driver_name, dev_name, ## args)
86 84
87#define DEBUG(fmt, args...) \
88 printk(KERN_ERR "%s:%s[%d]: " fmt "\n", driver_name, __FUNCTION__, __LINE__, ## args)
89#define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__)
90
91struct fragment_info { 85struct fragment_info {
92 struct list_head list; 86 struct list_head list;
93 int offset; 87 int offset;
@@ -105,9 +99,9 @@ struct partial_datagram {
105}; 99};
106 100
107struct pdg_list { 101struct pdg_list {
108 struct list_head list; /* partial datagram list per node */ 102 struct list_head list; /* partial datagram list per node */
109 unsigned int sz; /* partial datagram list size per node */ 103 unsigned int sz; /* partial datagram list size per node */
110 spinlock_t lock; /* partial datagram lock */ 104 spinlock_t lock; /* partial datagram lock */
111}; 105};
112 106
113struct eth1394_host_info { 107struct eth1394_host_info {
@@ -121,16 +115,14 @@ struct eth1394_node_ref {
121}; 115};
122 116
123struct eth1394_node_info { 117struct eth1394_node_info {
124 u16 maxpayload; /* Max payload */ 118 u16 maxpayload; /* max payload */
125 u8 sspd; /* Max speed */ 119 u8 sspd; /* max speed */
126 u64 fifo; /* FIFO address */ 120 u64 fifo; /* FIFO address */
127 struct pdg_list pdg; /* partial RX datagram lists */ 121 struct pdg_list pdg; /* partial RX datagram lists */
128 int dgl; /* Outgoing datagram label */ 122 int dgl; /* outgoing datagram label */
129}; 123};
130 124
131/* Our ieee1394 highlevel driver */ 125static const char driver_name[] = "eth1394";
132#define ETH1394_DRIVER_NAME "eth1394"
133static const char driver_name[] = ETH1394_DRIVER_NAME;
134 126
135static struct kmem_cache *packet_task_cache; 127static struct kmem_cache *packet_task_cache;
136 128
@@ -138,15 +130,12 @@ static struct hpsb_highlevel eth1394_highlevel;
138 130
139/* Use common.lf to determine header len */ 131/* Use common.lf to determine header len */
140static const int hdr_type_len[] = { 132static const int hdr_type_len[] = {
141 sizeof (struct eth1394_uf_hdr), 133 sizeof(struct eth1394_uf_hdr),
142 sizeof (struct eth1394_ff_hdr), 134 sizeof(struct eth1394_ff_hdr),
143 sizeof (struct eth1394_sf_hdr), 135 sizeof(struct eth1394_sf_hdr),
144 sizeof (struct eth1394_sf_hdr) 136 sizeof(struct eth1394_sf_hdr)
145}; 137};
146 138
147/* Change this to IEEE1394_SPEED_S100 to make testing easier */
148#define ETH1394_SPEED_DEF IEEE1394_SPEED_MAX
149
150/* For now, this needs to be 1500, so that XP works with us */ 139/* For now, this needs to be 1500, so that XP works with us */
151#define ETH1394_DATA_LEN ETH_DATA_LEN 140#define ETH1394_DATA_LEN ETH_DATA_LEN
152 141
@@ -159,7 +148,8 @@ MODULE_AUTHOR("Ben Collins (bcollins@debian.org)");
159MODULE_DESCRIPTION("IEEE 1394 IPv4 Driver (IPv4-over-1394 as per RFC 2734)"); 148MODULE_DESCRIPTION("IEEE 1394 IPv4 Driver (IPv4-over-1394 as per RFC 2734)");
160MODULE_LICENSE("GPL"); 149MODULE_LICENSE("GPL");
161 150
162/* The max_partial_datagrams parameter is the maximum number of fragmented 151/*
152 * The max_partial_datagrams parameter is the maximum number of fragmented
163 * datagrams per node that eth1394 will keep in memory. Providing an upper 153 * datagrams per node that eth1394 will keep in memory. Providing an upper
164 * bound allows us to limit the amount of memory that partial datagrams 154 * bound allows us to limit the amount of memory that partial datagrams
165 * consume in the event that some partial datagrams are never completed. 155 * consume in the event that some partial datagrams are never completed.
@@ -179,10 +169,9 @@ static int ether1394_header_parse(struct sk_buff *skb, unsigned char *haddr);
179static int ether1394_header_cache(struct neighbour *neigh, struct hh_cache *hh); 169static int ether1394_header_cache(struct neighbour *neigh, struct hh_cache *hh);
180static void ether1394_header_cache_update(struct hh_cache *hh, 170static void ether1394_header_cache_update(struct hh_cache *hh,
181 struct net_device *dev, 171 struct net_device *dev,
182 unsigned char * haddr); 172 unsigned char *haddr);
183static int ether1394_mac_addr(struct net_device *dev, void *p); 173static int ether1394_mac_addr(struct net_device *dev, void *p);
184 174
185static void purge_partial_datagram(struct list_head *old);
186static int ether1394_tx(struct sk_buff *skb, struct net_device *dev); 175static int ether1394_tx(struct sk_buff *skb, struct net_device *dev);
187static void ether1394_iso(struct hpsb_iso *iso); 176static void ether1394_iso(struct hpsb_iso *iso);
188 177
@@ -190,9 +179,9 @@ static struct ethtool_ops ethtool_ops;
190 179
191static int ether1394_write(struct hpsb_host *host, int srcid, int destid, 180static int ether1394_write(struct hpsb_host *host, int srcid, int destid,
192 quadlet_t *data, u64 addr, size_t len, u16 flags); 181 quadlet_t *data, u64 addr, size_t len, u16 flags);
193static void ether1394_add_host (struct hpsb_host *host); 182static void ether1394_add_host(struct hpsb_host *host);
194static void ether1394_remove_host (struct hpsb_host *host); 183static void ether1394_remove_host(struct hpsb_host *host);
195static void ether1394_host_reset (struct hpsb_host *host); 184static void ether1394_host_reset(struct hpsb_host *host);
196 185
197/* Function for incoming 1394 packets */ 186/* Function for incoming 1394 packets */
198static struct hpsb_address_ops addr_ops = { 187static struct hpsb_address_ops addr_ops = {
@@ -207,13 +196,17 @@ static struct hpsb_highlevel eth1394_highlevel = {
207 .host_reset = ether1394_host_reset, 196 .host_reset = ether1394_host_reset,
208}; 197};
209 198
210
211static int ether1394_recv_init(struct net_device *dev) 199static int ether1394_recv_init(struct net_device *dev)
212{ 200{
213 struct eth1394_priv *priv = netdev_priv(dev); 201 struct eth1394_priv *priv = netdev_priv(dev);
202 unsigned int iso_buf_size;
203
204 /* FIXME: rawiso limits us to PAGE_SIZE */
205 iso_buf_size = min((unsigned int)PAGE_SIZE,
206 2 * (1U << (priv->host->csr.max_rec + 1)));
214 207
215 priv->iso = hpsb_iso_recv_init(priv->host, 208 priv->iso = hpsb_iso_recv_init(priv->host,
216 ETHER1394_ISO_BUF_SIZE, 209 ETHER1394_GASP_BUFFERS * iso_buf_size,
217 ETHER1394_GASP_BUFFERS, 210 ETHER1394_GASP_BUFFERS,
218 priv->broadcast_channel, 211 priv->broadcast_channel,
219 HPSB_ISO_DMA_PACKET_PER_BUFFER, 212 HPSB_ISO_DMA_PACKET_PER_BUFFER,
@@ -239,64 +232,66 @@ static int ether1394_open(struct net_device *dev)
239 struct eth1394_priv *priv = netdev_priv(dev); 232 struct eth1394_priv *priv = netdev_priv(dev);
240 int ret; 233 int ret;
241 234
242 /* Something bad happened, don't even try */
243 if (priv->bc_state == ETHER1394_BC_ERROR) { 235 if (priv->bc_state == ETHER1394_BC_ERROR) {
244 /* we'll try again */
245 ret = ether1394_recv_init(dev); 236 ret = ether1394_recv_init(dev);
246 if (ret) 237 if (ret)
247 return ret; 238 return ret;
248 } 239 }
249 240 netif_start_queue(dev);
250 netif_start_queue (dev);
251 return 0; 241 return 0;
252} 242}
253 243
254/* This is called after an "ifdown" */ 244/* This is called after an "ifdown" */
255static int ether1394_stop (struct net_device *dev) 245static int ether1394_stop(struct net_device *dev)
256{ 246{
257 netif_stop_queue (dev); 247 netif_stop_queue(dev);
258 return 0; 248 return 0;
259} 249}
260 250
261/* Return statistics to the caller */ 251/* Return statistics to the caller */
262static struct net_device_stats *ether1394_stats (struct net_device *dev) 252static struct net_device_stats *ether1394_stats(struct net_device *dev)
263{ 253{
264 return &(((struct eth1394_priv *)netdev_priv(dev))->stats); 254 return &(((struct eth1394_priv *)netdev_priv(dev))->stats);
265} 255}
266 256
267/* What to do if we timeout. I think a host reset is probably in order, so 257/* FIXME: What to do if we timeout? I think a host reset is probably in order,
268 * that's what we do. Should we increment the stat counters too? */ 258 * so that's what we do. Should we increment the stat counters too? */
269static void ether1394_tx_timeout (struct net_device *dev) 259static void ether1394_tx_timeout(struct net_device *dev)
270{ 260{
271 ETH1394_PRINT (KERN_ERR, dev->name, "Timeout, resetting host %s\n", 261 struct hpsb_host *host =
272 ((struct eth1394_priv *)netdev_priv(dev))->host->driver->name); 262 ((struct eth1394_priv *)netdev_priv(dev))->host;
273
274 highlevel_host_reset (((struct eth1394_priv *)netdev_priv(dev))->host);
275 263
276 netif_wake_queue (dev); 264 ETH1394_PRINT(KERN_ERR, dev->name, "Timeout, resetting host %s\n",
265 host->driver->name);
266 highlevel_host_reset(host);
267 netif_wake_queue(dev);
277} 268}
278 269
279static int ether1394_change_mtu(struct net_device *dev, int new_mtu) 270static int ether1394_change_mtu(struct net_device *dev, int new_mtu)
280{ 271{
281 struct eth1394_priv *priv = netdev_priv(dev); 272 int max_rec =
273 ((struct eth1394_priv *)netdev_priv(dev))->host->csr.max_rec;
282 274
283 if ((new_mtu < 68) || 275 if (new_mtu < 68 ||
284 (new_mtu > min(ETH1394_DATA_LEN, 276 new_mtu > ETH1394_DATA_LEN ||
285 (int)((1 << (priv->host->csr.max_rec + 1)) - 277 new_mtu > (1 << (max_rec + 1)) - sizeof(union eth1394_hdr) -
286 (sizeof(union eth1394_hdr) + 278 ETHER1394_GASP_OVERHEAD)
287 ETHER1394_GASP_OVERHEAD)))))
288 return -EINVAL; 279 return -EINVAL;
280
289 dev->mtu = new_mtu; 281 dev->mtu = new_mtu;
290 return 0; 282 return 0;
291} 283}
292 284
293static void purge_partial_datagram(struct list_head *old) 285static void purge_partial_datagram(struct list_head *old)
294{ 286{
295 struct partial_datagram *pd = list_entry(old, struct partial_datagram, list); 287 struct partial_datagram *pd;
296 struct list_head *lh, *n; 288 struct list_head *lh, *n;
289 struct fragment_info *fi;
290
291 pd = list_entry(old, struct partial_datagram, list);
297 292
298 list_for_each_safe(lh, n, &pd->frag_info) { 293 list_for_each_safe(lh, n, &pd->frag_info) {
299 struct fragment_info *fi = list_entry(lh, struct fragment_info, list); 294 fi = list_entry(lh, struct fragment_info, list);
300 list_del(lh); 295 list_del(lh);
301 kfree(fi); 296 kfree(fi);
302 } 297 }
@@ -337,10 +332,10 @@ static struct eth1394_node_ref *eth1394_find_node_nodeid(struct list_head *inl,
337 nodeid_t nodeid) 332 nodeid_t nodeid)
338{ 333{
339 struct eth1394_node_ref *node; 334 struct eth1394_node_ref *node;
340 list_for_each_entry(node, inl, list) { 335
336 list_for_each_entry(node, inl, list)
341 if (node->ud->ne->nodeid == nodeid) 337 if (node->ud->ne->nodeid == nodeid)
342 return node; 338 return node;
343 }
344 339
345 return NULL; 340 return NULL;
346} 341}
@@ -403,24 +398,23 @@ static int eth1394_remove(struct device *dev)
403 priv = netdev_priv(hi->dev); 398 priv = netdev_priv(hi->dev);
404 399
405 old_node = eth1394_find_node(&priv->ip_node_list, ud); 400 old_node = eth1394_find_node(&priv->ip_node_list, ud);
401 if (!old_node)
402 return 0;
406 403
407 if (old_node) { 404 list_del(&old_node->list);
408 list_del(&old_node->list); 405 kfree(old_node);
409 kfree(old_node);
410 406
411 node_info = (struct eth1394_node_info*)ud->device.driver_data; 407 node_info = (struct eth1394_node_info*)ud->device.driver_data;
412 408
413 spin_lock_irqsave(&node_info->pdg.lock, flags); 409 spin_lock_irqsave(&node_info->pdg.lock, flags);
414 /* The partial datagram list should be empty, but we'll just 410 /* The partial datagram list should be empty, but we'll just
415 * make sure anyway... */ 411 * make sure anyway... */
416 list_for_each_safe(lh, n, &node_info->pdg.list) { 412 list_for_each_safe(lh, n, &node_info->pdg.list)
417 purge_partial_datagram(lh); 413 purge_partial_datagram(lh);
418 } 414 spin_unlock_irqrestore(&node_info->pdg.lock, flags);
419 spin_unlock_irqrestore(&node_info->pdg.lock, flags);
420 415
421 kfree(node_info); 416 kfree(node_info);
422 ud->device.driver_data = NULL; 417 ud->device.driver_data = NULL;
423 }
424 return 0; 418 return 0;
425} 419}
426 420
@@ -438,35 +432,33 @@ static int eth1394_update(struct unit_directory *ud)
438 priv = netdev_priv(hi->dev); 432 priv = netdev_priv(hi->dev);
439 433
440 node = eth1394_find_node(&priv->ip_node_list, ud); 434 node = eth1394_find_node(&priv->ip_node_list, ud);
435 if (node)
436 return 0;
441 437
442 if (!node) { 438 node = kmalloc(sizeof(*node),
443 node = kmalloc(sizeof(*node), 439 in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
444 in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); 440 if (!node)
445 if (!node) 441 return -ENOMEM;
446 return -ENOMEM;
447
448 node_info = kmalloc(sizeof(*node_info),
449 in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
450 if (!node_info) {
451 kfree(node);
452 return -ENOMEM;
453 }
454 442
455 spin_lock_init(&node_info->pdg.lock); 443 node_info = kmalloc(sizeof(*node_info),
456 INIT_LIST_HEAD(&node_info->pdg.list); 444 in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
457 node_info->pdg.sz = 0; 445 if (!node_info) {
446 kfree(node);
447 return -ENOMEM;
448 }
458 449
459 ud->device.driver_data = node_info; 450 spin_lock_init(&node_info->pdg.lock);
460 node->ud = ud; 451 INIT_LIST_HEAD(&node_info->pdg.list);
452 node_info->pdg.sz = 0;
461 453
462 priv = netdev_priv(hi->dev); 454 ud->device.driver_data = node_info;
463 list_add_tail(&node->list, &priv->ip_node_list); 455 node->ud = ud;
464 }
465 456
457 priv = netdev_priv(hi->dev);
458 list_add_tail(&node->list, &priv->ip_node_list);
466 return 0; 459 return 0;
467} 460}
468 461
469
470static struct ieee1394_device_id eth1394_id_table[] = { 462static struct ieee1394_device_id eth1394_id_table[] = {
471 { 463 {
472 .match_flags = (IEEE1394_MATCH_SPECIFIER_ID | 464 .match_flags = (IEEE1394_MATCH_SPECIFIER_ID |
@@ -480,7 +472,7 @@ static struct ieee1394_device_id eth1394_id_table[] = {
480MODULE_DEVICE_TABLE(ieee1394, eth1394_id_table); 472MODULE_DEVICE_TABLE(ieee1394, eth1394_id_table);
481 473
482static struct hpsb_protocol_driver eth1394_proto_driver = { 474static struct hpsb_protocol_driver eth1394_proto_driver = {
483 .name = ETH1394_DRIVER_NAME, 475 .name = driver_name,
484 .id_table = eth1394_id_table, 476 .id_table = eth1394_id_table,
485 .update = eth1394_update, 477 .update = eth1394_update,
486 .driver = { 478 .driver = {
@@ -489,18 +481,16 @@ static struct hpsb_protocol_driver eth1394_proto_driver = {
489 }, 481 },
490}; 482};
491 483
492 484static void ether1394_reset_priv(struct net_device *dev, int set_mtu)
493static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
494{ 485{
495 unsigned long flags; 486 unsigned long flags;
496 int i; 487 int i;
497 struct eth1394_priv *priv = netdev_priv(dev); 488 struct eth1394_priv *priv = netdev_priv(dev);
498 struct hpsb_host *host = priv->host; 489 struct hpsb_host *host = priv->host;
499 u64 guid = get_unaligned((u64*)&(host->csr.rom->bus_info_data[3])); 490 u64 guid = get_unaligned((u64 *)&(host->csr.rom->bus_info_data[3]));
500 u16 maxpayload = 1 << (host->csr.max_rec + 1);
501 int max_speed = IEEE1394_SPEED_MAX; 491 int max_speed = IEEE1394_SPEED_MAX;
502 492
503 spin_lock_irqsave (&priv->lock, flags); 493 spin_lock_irqsave(&priv->lock, flags);
504 494
505 memset(priv->ud_list, 0, sizeof(struct node_entry*) * ALL_NODES); 495 memset(priv->ud_list, 0, sizeof(struct node_entry*) * ALL_NODES);
506 priv->bc_maxpayload = 512; 496 priv->bc_maxpayload = 512;
@@ -511,23 +501,24 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
511 max_speed = host->speed[i]; 501 max_speed = host->speed[i];
512 priv->bc_sspd = max_speed; 502 priv->bc_sspd = max_speed;
513 503
514 /* We'll use our maxpayload as the default mtu */ 504 /* We'll use our maximum payload as the default MTU */
515 if (set_mtu) { 505 if (set_mtu) {
506 int max_payload = 1 << (host->csr.max_rec + 1);
507
516 dev->mtu = min(ETH1394_DATA_LEN, 508 dev->mtu = min(ETH1394_DATA_LEN,
517 (int)(maxpayload - 509 (int)(max_payload - sizeof(union eth1394_hdr) -
518 (sizeof(union eth1394_hdr) + 510 ETHER1394_GASP_OVERHEAD));
519 ETHER1394_GASP_OVERHEAD)));
520 511
521 /* Set our hardware address while we're at it */ 512 /* Set our hardware address while we're at it */
522 memcpy(dev->dev_addr, &guid, sizeof(u64)); 513 memcpy(dev->dev_addr, &guid, sizeof(u64));
523 memset(dev->broadcast, 0xff, sizeof(u64)); 514 memset(dev->broadcast, 0xff, sizeof(u64));
524 } 515 }
525 516
526 spin_unlock_irqrestore (&priv->lock, flags); 517 spin_unlock_irqrestore(&priv->lock, flags);
527} 518}
528 519
529/* This function is called right before register_netdev */ 520/* This function is called right before register_netdev */
530static void ether1394_init_dev (struct net_device *dev) 521static void ether1394_init_dev(struct net_device *dev)
531{ 522{
532 /* Our functions */ 523 /* Our functions */
533 dev->open = ether1394_open; 524 dev->open = ether1394_open;
@@ -553,7 +544,7 @@ static void ether1394_init_dev (struct net_device *dev)
553 dev->hard_header_len = ETH1394_HLEN; 544 dev->hard_header_len = ETH1394_HLEN;
554 dev->type = ARPHRD_IEEE1394; 545 dev->type = ARPHRD_IEEE1394;
555 546
556 ether1394_reset_priv (dev, 1); 547 ether1394_reset_priv(dev, 1);
557} 548}
558 549
559/* 550/*
@@ -561,7 +552,7 @@ static void ether1394_init_dev (struct net_device *dev)
561 * when the module is installed. This is where we add all of our ethernet 552 * when the module is installed. This is where we add all of our ethernet
562 * devices. One for each host. 553 * devices. One for each host.
563 */ 554 */
564static void ether1394_add_host (struct hpsb_host *host) 555static void ether1394_add_host(struct hpsb_host *host)
565{ 556{
566 struct eth1394_host_info *hi = NULL; 557 struct eth1394_host_info *hi = NULL;
567 struct net_device *dev = NULL; 558 struct net_device *dev = NULL;
@@ -593,7 +584,7 @@ static void ether1394_add_host (struct hpsb_host *host)
593 "etherdevice for IEEE 1394 device %s-%d\n", 584 "etherdevice for IEEE 1394 device %s-%d\n",
594 host->driver->name, host->id); 585 host->driver->name, host->id);
595 goto out; 586 goto out;
596 } 587 }
597 588
598 SET_MODULE_OWNER(dev); 589 SET_MODULE_OWNER(dev);
599#if 0 590#if 0
@@ -616,7 +607,7 @@ static void ether1394_add_host (struct hpsb_host *host)
616 "hostinfo for IEEE 1394 device %s-%d\n", 607 "hostinfo for IEEE 1394 device %s-%d\n",
617 host->driver->name, host->id); 608 host->driver->name, host->id);
618 goto out; 609 goto out;
619 } 610 }
620 611
621 ether1394_init_dev(dev); 612 ether1394_init_dev(dev);
622 613
@@ -647,7 +638,7 @@ out:
647} 638}
648 639
649/* Remove a card from our list */ 640/* Remove a card from our list */
650static void ether1394_remove_host (struct hpsb_host *host) 641static void ether1394_remove_host(struct hpsb_host *host)
651{ 642{
652 struct eth1394_host_info *hi; 643 struct eth1394_host_info *hi;
653 struct eth1394_priv *priv; 644 struct eth1394_priv *priv;
@@ -664,8 +655,8 @@ static void ether1394_remove_host (struct hpsb_host *host)
664 free_netdev(hi->dev); 655 free_netdev(hi->dev);
665} 656}
666 657
667/* A reset has just arisen */ 658/* A bus reset happened */
668static void ether1394_host_reset (struct hpsb_host *host) 659static void ether1394_host_reset(struct hpsb_host *host)
669{ 660{
670 struct eth1394_host_info *hi; 661 struct eth1394_host_info *hi;
671 struct eth1394_priv *priv; 662 struct eth1394_priv *priv;
@@ -682,20 +673,19 @@ static void ether1394_host_reset (struct hpsb_host *host)
682 return; 673 return;
683 674
684 dev = hi->dev; 675 dev = hi->dev;
685 priv = (struct eth1394_priv *)netdev_priv(dev); 676 priv = netdev_priv(dev);
686 677
687 /* Reset our private host data, but not our mtu */ 678 /* Reset our private host data, but not our MTU */
688 netif_stop_queue (dev); 679 netif_stop_queue(dev);
689 ether1394_reset_priv (dev, 0); 680 ether1394_reset_priv(dev, 0);
690 681
691 list_for_each_entry(node, &priv->ip_node_list, list) { 682 list_for_each_entry(node, &priv->ip_node_list, list) {
692 node_info = (struct eth1394_node_info*)node->ud->device.driver_data; 683 node_info = node->ud->device.driver_data;
693 684
694 spin_lock_irqsave(&node_info->pdg.lock, flags); 685 spin_lock_irqsave(&node_info->pdg.lock, flags);
695 686
696 list_for_each_safe(lh, n, &node_info->pdg.list) { 687 list_for_each_safe(lh, n, &node_info->pdg.list)
697 purge_partial_datagram(lh); 688 purge_partial_datagram(lh);
698 }
699 689
700 INIT_LIST_HEAD(&(node_info->pdg.list)); 690 INIT_LIST_HEAD(&(node_info->pdg.list));
701 node_info->pdg.sz = 0; 691 node_info->pdg.sz = 0;
@@ -703,7 +693,7 @@ static void ether1394_host_reset (struct hpsb_host *host)
703 spin_unlock_irqrestore(&node_info->pdg.lock, flags); 693 spin_unlock_irqrestore(&node_info->pdg.lock, flags);
704 } 694 }
705 695
706 netif_wake_queue (dev); 696 netif_wake_queue(dev);
707} 697}
708 698
709/****************************************** 699/******************************************
@@ -711,7 +701,6 @@ static void ether1394_host_reset (struct hpsb_host *host)
711 ******************************************/ 701 ******************************************/
712/* These functions have been adapted from net/ethernet/eth.c */ 702/* These functions have been adapted from net/ethernet/eth.c */
713 703
714
715/* Create a fake MAC header for an arbitrary protocol layer. 704/* Create a fake MAC header for an arbitrary protocol layer.
716 * saddr=NULL means use device source address 705 * saddr=NULL means use device source address
717 * daddr=NULL means leave destination address (eg unresolved arp). */ 706 * daddr=NULL means leave destination address (eg unresolved arp). */
@@ -719,25 +708,24 @@ static int ether1394_header(struct sk_buff *skb, struct net_device *dev,
719 unsigned short type, void *daddr, void *saddr, 708 unsigned short type, void *daddr, void *saddr,
720 unsigned len) 709 unsigned len)
721{ 710{
722 struct eth1394hdr *eth = (struct eth1394hdr *)skb_push(skb, ETH1394_HLEN); 711 struct eth1394hdr *eth =
712 (struct eth1394hdr *)skb_push(skb, ETH1394_HLEN);
723 713
724 eth->h_proto = htons(type); 714 eth->h_proto = htons(type);
725 715
726 if (dev->flags & (IFF_LOOPBACK|IFF_NOARP)) { 716 if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) {
727 memset(eth->h_dest, 0, dev->addr_len); 717 memset(eth->h_dest, 0, dev->addr_len);
728 return(dev->hard_header_len); 718 return dev->hard_header_len;
729 } 719 }
730 720
731 if (daddr) { 721 if (daddr) {
732 memcpy(eth->h_dest,daddr,dev->addr_len); 722 memcpy(eth->h_dest, daddr, dev->addr_len);
733 return dev->hard_header_len; 723 return dev->hard_header_len;
734 } 724 }
735 725
736 return -dev->hard_header_len; 726 return -dev->hard_header_len;
737
738} 727}
739 728
740
741/* Rebuild the faked MAC header. This is called after an ARP 729/* Rebuild the faked MAC header. This is called after an ARP
742 * (or in future other address resolution) has completed on this 730 * (or in future other address resolution) has completed on this
743 * sk_buff. We now let ARP fill in the other fields. 731 * sk_buff. We now let ARP fill in the other fields.
@@ -754,7 +742,7 @@ static int ether1394_rebuild_header(struct sk_buff *skb)
754 742
755#ifdef CONFIG_INET 743#ifdef CONFIG_INET
756 case __constant_htons(ETH_P_IP): 744 case __constant_htons(ETH_P_IP):
757 return arp_find((unsigned char*)&eth->h_dest, skb); 745 return arp_find((unsigned char *)&eth->h_dest, skb);
758#endif 746#endif
759 default: 747 default:
760 ETH1394_PRINT(KERN_DEBUG, dev->name, 748 ETH1394_PRINT(KERN_DEBUG, dev->name,
@@ -769,17 +757,17 @@ static int ether1394_rebuild_header(struct sk_buff *skb)
769static int ether1394_header_parse(struct sk_buff *skb, unsigned char *haddr) 757static int ether1394_header_parse(struct sk_buff *skb, unsigned char *haddr)
770{ 758{
771 struct net_device *dev = skb->dev; 759 struct net_device *dev = skb->dev;
760
772 memcpy(haddr, dev->dev_addr, ETH1394_ALEN); 761 memcpy(haddr, dev->dev_addr, ETH1394_ALEN);
773 return ETH1394_ALEN; 762 return ETH1394_ALEN;
774} 763}
775 764
776
777static int ether1394_header_cache(struct neighbour *neigh, struct hh_cache *hh) 765static int ether1394_header_cache(struct neighbour *neigh, struct hh_cache *hh)
778{ 766{
779 unsigned short type = hh->hh_type; 767 unsigned short type = hh->hh_type;
780 struct eth1394hdr *eth = (struct eth1394hdr*)(((u8*)hh->hh_data) +
781 (16 - ETH1394_HLEN));
782 struct net_device *dev = neigh->dev; 768 struct net_device *dev = neigh->dev;
769 struct eth1394hdr *eth =
770 (struct eth1394hdr *)((u8 *)hh->hh_data + 16 - ETH1394_HLEN);
783 771
784 if (type == htons(ETH_P_802_3)) 772 if (type == htons(ETH_P_802_3))
785 return -1; 773 return -1;
@@ -796,7 +784,7 @@ static void ether1394_header_cache_update(struct hh_cache *hh,
796 struct net_device *dev, 784 struct net_device *dev,
797 unsigned char * haddr) 785 unsigned char * haddr)
798{ 786{
799 memcpy(((u8*)hh->hh_data) + (16 - ETH1394_HLEN), haddr, dev->addr_len); 787 memcpy((u8 *)hh->hh_data + 16 - ETH1394_HLEN, haddr, dev->addr_len);
800} 788}
801 789
802static int ether1394_mac_addr(struct net_device *dev, void *p) 790static int ether1394_mac_addr(struct net_device *dev, void *p)
@@ -807,9 +795,7 @@ static int ether1394_mac_addr(struct net_device *dev, void *p)
807 /* Not going to allow setting the MAC address, we really need to use 795 /* Not going to allow setting the MAC address, we really need to use
808 * the real one supplied by the hardware */ 796 * the real one supplied by the hardware */
809 return -EINVAL; 797 return -EINVAL;
810 } 798}
811
812
813 799
814/****************************************** 800/******************************************
815 * Datagram reception code 801 * Datagram reception code
@@ -822,11 +808,11 @@ static u16 ether1394_type_trans(struct sk_buff *skb, struct net_device *dev)
822 unsigned char *rawp; 808 unsigned char *rawp;
823 809
824 skb_reset_mac_header(skb); 810 skb_reset_mac_header(skb);
825 skb_pull (skb, ETH1394_HLEN); 811 skb_pull(skb, ETH1394_HLEN);
826 eth = eth1394_hdr(skb); 812 eth = eth1394_hdr(skb);
827 813
828 if (*eth->h_dest & 1) { 814 if (*eth->h_dest & 1) {
829 if (memcmp(eth->h_dest, dev->broadcast, dev->addr_len)==0) 815 if (memcmp(eth->h_dest, dev->broadcast, dev->addr_len) == 0)
830 skb->pkt_type = PACKET_BROADCAST; 816 skb->pkt_type = PACKET_BROADCAST;
831#if 0 817#if 0
832 else 818 else
@@ -835,17 +821,17 @@ static u16 ether1394_type_trans(struct sk_buff *skb, struct net_device *dev)
835 } else { 821 } else {
836 if (memcmp(eth->h_dest, dev->dev_addr, dev->addr_len)) 822 if (memcmp(eth->h_dest, dev->dev_addr, dev->addr_len))
837 skb->pkt_type = PACKET_OTHERHOST; 823 skb->pkt_type = PACKET_OTHERHOST;
838 } 824 }
839 825
840 if (ntohs (eth->h_proto) >= 1536) 826 if (ntohs(eth->h_proto) >= 1536)
841 return eth->h_proto; 827 return eth->h_proto;
842 828
843 rawp = skb->data; 829 rawp = skb->data;
844 830
845 if (*(unsigned short *)rawp == 0xFFFF) 831 if (*(unsigned short *)rawp == 0xFFFF)
846 return htons (ETH_P_802_3); 832 return htons(ETH_P_802_3);
847 833
848 return htons (ETH_P_802_2); 834 return htons(ETH_P_802_2);
849} 835}
850 836
851/* Parse an encapsulated IP1394 header into an ethernet frame packet. 837/* Parse an encapsulated IP1394 header into an ethernet frame packet.
@@ -858,23 +844,22 @@ static u16 ether1394_parse_encap(struct sk_buff *skb, struct net_device *dev,
858 u64 dest_hw; 844 u64 dest_hw;
859 unsigned short ret = 0; 845 unsigned short ret = 0;
860 846
861 /* Setup our hw addresses. We use these to build the 847 /* Setup our hw addresses. We use these to build the ethernet header. */
862 * ethernet header. */
863 if (destid == (LOCAL_BUS | ALL_NODES)) 848 if (destid == (LOCAL_BUS | ALL_NODES))
864 dest_hw = ~0ULL; /* broadcast */ 849 dest_hw = ~0ULL; /* broadcast */
865 else 850 else
866 dest_hw = cpu_to_be64((((u64)priv->host->csr.guid_hi) << 32) | 851 dest_hw = cpu_to_be64((u64)priv->host->csr.guid_hi << 32 |
867 priv->host->csr.guid_lo); 852 priv->host->csr.guid_lo);
868 853
869 /* If this is an ARP packet, convert it. First, we want to make 854 /* If this is an ARP packet, convert it. First, we want to make
870 * use of some of the fields, since they tell us a little bit 855 * use of some of the fields, since they tell us a little bit
871 * about the sending machine. */ 856 * about the sending machine. */
872 if (ether_type == htons(ETH_P_ARP)) { 857 if (ether_type == htons(ETH_P_ARP)) {
873 struct eth1394_arp *arp1394 = (struct eth1394_arp*)skb->data; 858 struct eth1394_arp *arp1394 = (struct eth1394_arp *)skb->data;
874 struct arphdr *arp = (struct arphdr *)skb->data; 859 struct arphdr *arp = (struct arphdr *)skb->data;
875 unsigned char *arp_ptr = (unsigned char *)(arp + 1); 860 unsigned char *arp_ptr = (unsigned char *)(arp + 1);
876 u64 fifo_addr = (u64)ntohs(arp1394->fifo_hi) << 32 | 861 u64 fifo_addr = (u64)ntohs(arp1394->fifo_hi) << 32 |
877 ntohl(arp1394->fifo_lo); 862 ntohl(arp1394->fifo_lo);
878 u8 max_rec = min(priv->host->csr.max_rec, 863 u8 max_rec = min(priv->host->csr.max_rec,
879 (u8)(arp1394->max_rec)); 864 (u8)(arp1394->max_rec));
880 int sspd = arp1394->sspd; 865 int sspd = arp1394->sspd;
@@ -888,16 +873,17 @@ static u16 ether1394_parse_encap(struct sk_buff *skb, struct net_device *dev,
888 if (sspd > 5 || sspd < 0) 873 if (sspd > 5 || sspd < 0)
889 sspd = 0; 874 sspd = 0;
890 875
891 maxpayload = min(eth1394_speedto_maxpayload[sspd], (u16)(1 << (max_rec + 1))); 876 maxpayload = min(eth1394_speedto_maxpayload[sspd],
877 (u16)(1 << (max_rec + 1)));
892 878
893 guid = get_unaligned(&arp1394->s_uniq_id); 879 guid = get_unaligned(&arp1394->s_uniq_id);
894 node = eth1394_find_node_guid(&priv->ip_node_list, 880 node = eth1394_find_node_guid(&priv->ip_node_list,
895 be64_to_cpu(guid)); 881 be64_to_cpu(guid));
896 if (!node) { 882 if (!node)
897 return 0; 883 return 0;
898 }
899 884
900 node_info = (struct eth1394_node_info*)node->ud->device.driver_data; 885 node_info =
886 (struct eth1394_node_info *)node->ud->device.driver_data;
901 887
902 /* Update our speed/payload/fifo_offset table */ 888 /* Update our speed/payload/fifo_offset table */
903 node_info->maxpayload = maxpayload; 889 node_info->maxpayload = maxpayload;
@@ -916,7 +902,7 @@ static u16 ether1394_parse_encap(struct sk_buff *skb, struct net_device *dev,
916 902
917 arp->ar_hln = 8; 903 arp->ar_hln = 8;
918 arp_ptr += arp->ar_hln; /* skip over sender unique id */ 904 arp_ptr += arp->ar_hln; /* skip over sender unique id */
919 *(u32*)arp_ptr = arp1394->sip; /* move sender IP addr */ 905 *(u32 *)arp_ptr = arp1394->sip; /* move sender IP addr */
920 arp_ptr += arp->ar_pln; /* skip over sender IP addr */ 906 arp_ptr += arp->ar_pln; /* skip over sender IP addr */
921 907
922 if (arp->ar_op == htons(ARPOP_REQUEST)) 908 if (arp->ar_op == htons(ARPOP_REQUEST))
@@ -949,10 +935,10 @@ static struct list_head *find_partial_datagram(struct list_head *pdgl, int dgl)
949{ 935{
950 struct partial_datagram *pd; 936 struct partial_datagram *pd;
951 937
952 list_for_each_entry(pd, pdgl, list) { 938 list_for_each_entry(pd, pdgl, list)
953 if (pd->dgl == dgl) 939 if (pd->dgl == dgl)
954 return &pd->list; 940 return &pd->list;
955 } 941
956 return NULL; 942 return NULL;
957} 943}
958 944
@@ -964,34 +950,34 @@ static int new_fragment(struct list_head *frag_info, int offset, int len)
964 950
965 list_for_each(lh, frag_info) { 951 list_for_each(lh, frag_info) {
966 fi = list_entry(lh, struct fragment_info, list); 952 fi = list_entry(lh, struct fragment_info, list);
967 if ((fi->offset + fi->len) == offset) { 953 if (fi->offset + fi->len == offset) {
968 /* The new fragment can be tacked on to the end */ 954 /* The new fragment can be tacked on to the end */
969 fi->len += len; 955 fi->len += len;
970 /* Did the new fragment plug a hole? */ 956 /* Did the new fragment plug a hole? */
971 fi2 = list_entry(lh->next, struct fragment_info, list); 957 fi2 = list_entry(lh->next, struct fragment_info, list);
972 if ((fi->offset + fi->len) == fi2->offset) { 958 if (fi->offset + fi->len == fi2->offset) {
973 /* glue fragments together */ 959 /* glue fragments together */
974 fi->len += fi2->len; 960 fi->len += fi2->len;
975 list_del(lh->next); 961 list_del(lh->next);
976 kfree(fi2); 962 kfree(fi2);
977 } 963 }
978 return 0; 964 return 0;
979 } else if ((offset + len) == fi->offset) { 965 } else if (offset + len == fi->offset) {
980 /* The new fragment can be tacked on to the beginning */ 966 /* The new fragment can be tacked on to the beginning */
981 fi->offset = offset; 967 fi->offset = offset;
982 fi->len += len; 968 fi->len += len;
983 /* Did the new fragment plug a hole? */ 969 /* Did the new fragment plug a hole? */
984 fi2 = list_entry(lh->prev, struct fragment_info, list); 970 fi2 = list_entry(lh->prev, struct fragment_info, list);
985 if ((fi2->offset + fi2->len) == fi->offset) { 971 if (fi2->offset + fi2->len == fi->offset) {
986 /* glue fragments together */ 972 /* glue fragments together */
987 fi2->len += fi->len; 973 fi2->len += fi->len;
988 list_del(lh); 974 list_del(lh);
989 kfree(fi); 975 kfree(fi);
990 } 976 }
991 return 0; 977 return 0;
992 } else if (offset > (fi->offset + fi->len)) { 978 } else if (offset > fi->offset + fi->len) {
993 break; 979 break;
994 } else if ((offset + len) < fi->offset) { 980 } else if (offset + len < fi->offset) {
995 lh = lh->prev; 981 lh = lh->prev;
996 break; 982 break;
997 } 983 }
@@ -1005,7 +991,6 @@ static int new_fragment(struct list_head *frag_info, int offset, int len)
1005 new->len = len; 991 new->len = len;
1006 992
1007 list_add(&new->list, lh); 993 list_add(&new->list, lh);
1008
1009 return 0; 994 return 0;
1010} 995}
1011 996
@@ -1044,25 +1029,23 @@ static int new_partial_datagram(struct net_device *dev, struct list_head *pdgl,
1044 memcpy(new->pbuf + frag_off, frag_buf, frag_len); 1029 memcpy(new->pbuf + frag_off, frag_buf, frag_len);
1045 1030
1046 list_add(&new->list, pdgl); 1031 list_add(&new->list, pdgl);
1047
1048 return 0; 1032 return 0;
1049} 1033}
1050 1034
1051static int update_partial_datagram(struct list_head *pdgl, struct list_head *lh, 1035static int update_partial_datagram(struct list_head *pdgl, struct list_head *lh,
1052 char *frag_buf, int frag_off, int frag_len) 1036 char *frag_buf, int frag_off, int frag_len)
1053{ 1037{
1054 struct partial_datagram *pd = list_entry(lh, struct partial_datagram, list); 1038 struct partial_datagram *pd =
1039 list_entry(lh, struct partial_datagram, list);
1055 1040
1056 if (new_fragment(&pd->frag_info, frag_off, frag_len) < 0) { 1041 if (new_fragment(&pd->frag_info, frag_off, frag_len) < 0)
1057 return -ENOMEM; 1042 return -ENOMEM;
1058 }
1059 1043
1060 memcpy(pd->pbuf + frag_off, frag_buf, frag_len); 1044 memcpy(pd->pbuf + frag_off, frag_buf, frag_len);
1061 1045
1062 /* Move list entry to beginnig of list so that oldest partial 1046 /* Move list entry to beginnig of list so that oldest partial
1063 * datagrams percolate to the end of the list */ 1047 * datagrams percolate to the end of the list */
1064 list_move(lh, pdgl); 1048 list_move(lh, pdgl);
1065
1066 return 0; 1049 return 0;
1067} 1050}
1068 1051
@@ -1107,7 +1090,7 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
1107 priv->ud_list[NODEID_TO_NODE(srcid)] = ud; 1090 priv->ud_list[NODEID_TO_NODE(srcid)] = ud;
1108 } 1091 }
1109 1092
1110 node_info = (struct eth1394_node_info*)ud->device.driver_data; 1093 node_info = (struct eth1394_node_info *)ud->device.driver_data;
1111 1094
1112 /* First, did we receive a fragmented or unfragmented datagram? */ 1095 /* First, did we receive a fragmented or unfragmented datagram? */
1113 hdr->words.word1 = ntohs(hdr->words.word1); 1096 hdr->words.word1 = ntohs(hdr->words.word1);
@@ -1126,7 +1109,8 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
1126 return -1; 1109 return -1;
1127 } 1110 }
1128 skb_reserve(skb, (dev->hard_header_len + 15) & ~15); 1111 skb_reserve(skb, (dev->hard_header_len + 15) & ~15);
1129 memcpy(skb_put(skb, len - hdr_len), buf + hdr_len, len - hdr_len); 1112 memcpy(skb_put(skb, len - hdr_len), buf + hdr_len,
1113 len - hdr_len);
1130 ether_type = hdr->uf.ether_type; 1114 ether_type = hdr->uf.ether_type;
1131 } else { 1115 } else {
1132 /* A datagram fragment has been received, now the fun begins. */ 1116 /* A datagram fragment has been received, now the fun begins. */
@@ -1211,9 +1195,8 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
1211 1195
1212 pd = list_entry(lh, struct partial_datagram, list); 1196 pd = list_entry(lh, struct partial_datagram, list);
1213 1197
1214 if (hdr->common.lf == ETH1394_HDR_LF_FF) { 1198 if (hdr->common.lf == ETH1394_HDR_LF_FF)
1215 pd->ether_type = ether_type; 1199 pd->ether_type = ether_type;
1216 }
1217 1200
1218 if (is_datagram_complete(lh, dg_size)) { 1201 if (is_datagram_complete(lh, dg_size)) {
1219 ether_type = pd->ether_type; 1202 ether_type = pd->ether_type;
@@ -1240,8 +1223,8 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
1240 skb->protocol = ether1394_parse_encap(skb, dev, srcid, destid, 1223 skb->protocol = ether1394_parse_encap(skb, dev, srcid, destid,
1241 ether_type); 1224 ether_type);
1242 1225
1243
1244 spin_lock_irqsave(&priv->lock, flags); 1226 spin_lock_irqsave(&priv->lock, flags);
1227
1245 if (!skb->protocol) { 1228 if (!skb->protocol) {
1246 priv->stats.rx_errors++; 1229 priv->stats.rx_errors++;
1247 priv->stats.rx_dropped++; 1230 priv->stats.rx_dropped++;
@@ -1313,20 +1296,20 @@ static void ether1394_iso(struct hpsb_iso *iso)
1313 for (i = 0; i < nready; i++) { 1296 for (i = 0; i < nready; i++) {
1314 struct hpsb_iso_packet_info *info = 1297 struct hpsb_iso_packet_info *info =
1315 &iso->infos[(iso->first_packet + i) % iso->buf_packets]; 1298 &iso->infos[(iso->first_packet + i) % iso->buf_packets];
1316 data = (quadlet_t*) (iso->data_buf.kvirt + info->offset); 1299 data = (quadlet_t *)(iso->data_buf.kvirt + info->offset);
1317 1300
1318 /* skip over GASP header */ 1301 /* skip over GASP header */
1319 buf = (char *)data + 8; 1302 buf = (char *)data + 8;
1320 len = info->len - 8; 1303 len = info->len - 8;
1321 1304
1322 specifier_id = (((be32_to_cpu(data[0]) & 0xffff) << 8) | 1305 specifier_id = (be32_to_cpu(data[0]) & 0xffff) << 8 |
1323 ((be32_to_cpu(data[1]) & 0xff000000) >> 24)); 1306 (be32_to_cpu(data[1]) & 0xff000000) >> 24;
1324 source_id = be32_to_cpu(data[0]) >> 16; 1307 source_id = be32_to_cpu(data[0]) >> 16;
1325 1308
1326 priv = netdev_priv(dev); 1309 priv = netdev_priv(dev);
1327 1310
1328 if (info->channel != (iso->host->csr.broadcast_channel & 0x3f) || 1311 if (info->channel != (iso->host->csr.broadcast_channel & 0x3f)
1329 specifier_id != ETHER1394_GASP_SPECIFIER_ID) { 1312 || specifier_id != ETHER1394_GASP_SPECIFIER_ID) {
1330 /* This packet is not for us */ 1313 /* This packet is not for us */
1331 continue; 1314 continue;
1332 } 1315 }
@@ -1358,21 +1341,16 @@ static void ether1394_arp_to_1394arp(struct sk_buff *skb,
1358 struct net_device *dev) 1341 struct net_device *dev)
1359{ 1342{
1360 struct eth1394_priv *priv = netdev_priv(dev); 1343 struct eth1394_priv *priv = netdev_priv(dev);
1361
1362 struct arphdr *arp = (struct arphdr *)skb->data; 1344 struct arphdr *arp = (struct arphdr *)skb->data;
1363 unsigned char *arp_ptr = (unsigned char *)(arp + 1); 1345 unsigned char *arp_ptr = (unsigned char *)(arp + 1);
1364 struct eth1394_arp *arp1394 = (struct eth1394_arp *)skb->data; 1346 struct eth1394_arp *arp1394 = (struct eth1394_arp *)skb->data;
1365 1347
1366 /* Believe it or not, all that need to happen is sender IP get moved
1367 * and set hw_addr_len, max_rec, sspd, fifo_hi and fifo_lo. */
1368 arp1394->hw_addr_len = 16; 1348 arp1394->hw_addr_len = 16;
1369 arp1394->sip = *(u32*)(arp_ptr + ETH1394_ALEN); 1349 arp1394->sip = *(u32*)(arp_ptr + ETH1394_ALEN);
1370 arp1394->max_rec = priv->host->csr.max_rec; 1350 arp1394->max_rec = priv->host->csr.max_rec;
1371 arp1394->sspd = priv->host->csr.lnk_spd; 1351 arp1394->sspd = priv->host->csr.lnk_spd;
1372 arp1394->fifo_hi = htons (priv->local_fifo >> 32); 1352 arp1394->fifo_hi = htons(priv->local_fifo >> 32);
1373 arp1394->fifo_lo = htonl (priv->local_fifo & ~0x0); 1353 arp1394->fifo_lo = htonl(priv->local_fifo & ~0x0);
1374
1375 return;
1376} 1354}
1377 1355
1378/* We need to encapsulate the standard header with our own. We use the 1356/* We need to encapsulate the standard header with our own. We use the
@@ -1382,7 +1360,8 @@ static unsigned int ether1394_encapsulate_prep(unsigned int max_payload,
1382 union eth1394_hdr *hdr, 1360 union eth1394_hdr *hdr,
1383 u16 dg_size, u16 dgl) 1361 u16 dg_size, u16 dgl)
1384{ 1362{
1385 unsigned int adj_max_payload = max_payload - hdr_type_len[ETH1394_HDR_LF_UF]; 1363 unsigned int adj_max_payload =
1364 max_payload - hdr_type_len[ETH1394_HDR_LF_UF];
1386 1365
1387 /* Does it all fit in one packet? */ 1366 /* Does it all fit in one packet? */
1388 if (dg_size <= adj_max_payload) { 1367 if (dg_size <= adj_max_payload) {
@@ -1395,7 +1374,7 @@ static unsigned int ether1394_encapsulate_prep(unsigned int max_payload,
1395 hdr->ff.dgl = dgl; 1374 hdr->ff.dgl = dgl;
1396 adj_max_payload = max_payload - hdr_type_len[ETH1394_HDR_LF_FF]; 1375 adj_max_payload = max_payload - hdr_type_len[ETH1394_HDR_LF_FF];
1397 } 1376 }
1398 return((dg_size + (adj_max_payload - 1)) / adj_max_payload); 1377 return (dg_size + adj_max_payload - 1) / adj_max_payload;
1399} 1378}
1400 1379
1401static unsigned int ether1394_encapsulate(struct sk_buff *skb, 1380static unsigned int ether1394_encapsulate(struct sk_buff *skb,
@@ -1407,7 +1386,7 @@ static unsigned int ether1394_encapsulate(struct sk_buff *skb,
1407 int hdrsz = hdr_type_len[ftype]; 1386 int hdrsz = hdr_type_len[ftype];
1408 unsigned int adj_max_payload = max_payload - hdrsz; 1387 unsigned int adj_max_payload = max_payload - hdrsz;
1409 1388
1410 switch(ftype) { 1389 switch (ftype) {
1411 case ETH1394_HDR_LF_UF: 1390 case ETH1394_HDR_LF_UF:
1412 bufhdr = (union eth1394_hdr *)skb_push(skb, hdrsz); 1391 bufhdr = (union eth1394_hdr *)skb_push(skb, hdrsz);
1413 bufhdr->words.word1 = htons(hdr->words.word1); 1392 bufhdr->words.word1 = htons(hdr->words.word1);
@@ -1436,7 +1415,6 @@ static unsigned int ether1394_encapsulate(struct sk_buff *skb,
1436 bufhdr->words.word3 = htons(hdr->words.word3); 1415 bufhdr->words.word3 = htons(hdr->words.word3);
1437 bufhdr->words.word4 = 0; 1416 bufhdr->words.word4 = 0;
1438 } 1417 }
1439
1440 return min(max_payload, skb->len); 1418 return min(max_payload, skb->len);
1441} 1419}
1442 1420
@@ -1455,13 +1433,13 @@ static struct hpsb_packet *ether1394_alloc_common_packet(struct hpsb_host *host)
1455 1433
1456static int ether1394_prep_write_packet(struct hpsb_packet *p, 1434static int ether1394_prep_write_packet(struct hpsb_packet *p,
1457 struct hpsb_host *host, nodeid_t node, 1435 struct hpsb_host *host, nodeid_t node,
1458 u64 addr, void * data, int tx_len) 1436 u64 addr, void *data, int tx_len)
1459{ 1437{
1460 p->node_id = node; 1438 p->node_id = node;
1461 p->data = NULL; 1439 p->data = NULL;
1462 1440
1463 p->tcode = TCODE_WRITEB; 1441 p->tcode = TCODE_WRITEB;
1464 p->header[1] = (host->node_id << 16) | (addr >> 32); 1442 p->header[1] = host->node_id << 16 | addr >> 32;
1465 p->header[2] = addr & 0xffffffff; 1443 p->header[2] = addr & 0xffffffff;
1466 1444
1467 p->header_size = 16; 1445 p->header_size = 16;
@@ -1472,12 +1450,12 @@ static int ether1394_prep_write_packet(struct hpsb_packet *p,
1472 "to node " NODE_BUS_FMT "\n", NODE_BUS_ARGS(host, node)); 1450 "to node " NODE_BUS_FMT "\n", NODE_BUS_ARGS(host, node));
1473 return -1; 1451 return -1;
1474 } 1452 }
1475 p->header[0] = (p->node_id << 16) | (p->tlabel << 10) 1453 p->header[0] =
1476 | (1 << 8) | (TCODE_WRITEB << 4); 1454 p->node_id << 16 | p->tlabel << 10 | 1 << 8 | TCODE_WRITEB << 4;
1477 1455
1478 p->header[3] = tx_len << 16; 1456 p->header[3] = tx_len << 16;
1479 p->data_size = (tx_len + 3) & ~3; 1457 p->data_size = (tx_len + 3) & ~3;
1480 p->data = (quadlet_t*)data; 1458 p->data = data;
1481 1459
1482 return 0; 1460 return 0;
1483} 1461}
@@ -1489,14 +1467,13 @@ static void ether1394_prep_gasp_packet(struct hpsb_packet *p,
1489 p->header_size = 4; 1467 p->header_size = 4;
1490 p->tcode = TCODE_STREAM_DATA; 1468 p->tcode = TCODE_STREAM_DATA;
1491 1469
1492 p->header[0] = (length << 16) | (3 << 14) 1470 p->header[0] = length << 16 | 3 << 14 | priv->broadcast_channel << 8 |
1493 | ((priv->broadcast_channel) << 8) 1471 TCODE_STREAM_DATA << 4;
1494 | (TCODE_STREAM_DATA << 4);
1495 p->data_size = length; 1472 p->data_size = length;
1496 p->data = ((quadlet_t*)skb->data) - 2; 1473 p->data = (quadlet_t *)skb->data - 2;
1497 p->data[0] = cpu_to_be32((priv->host->node_id << 16) | 1474 p->data[0] = cpu_to_be32(priv->host->node_id << 16 |
1498 ETHER1394_GASP_SPECIFIER_ID_HI); 1475 ETHER1394_GASP_SPECIFIER_ID_HI);
1499 p->data[1] = cpu_to_be32((ETHER1394_GASP_SPECIFIER_ID_LO << 24) | 1476 p->data[1] = cpu_to_be32(ETHER1394_GASP_SPECIFIER_ID_LO << 24 |
1500 ETHER1394_GASP_VERSION); 1477 ETHER1394_GASP_VERSION);
1501 1478
1502 /* Setting the node id to ALL_NODES (not LOCAL_BUS | ALL_NODES) 1479 /* Setting the node id to ALL_NODES (not LOCAL_BUS | ALL_NODES)
@@ -1525,7 +1502,7 @@ static int ether1394_send_packet(struct packet_task *ptask, unsigned int tx_len)
1525 return -1; 1502 return -1;
1526 1503
1527 if (ptask->tx_type == ETH1394_GASP) { 1504 if (ptask->tx_type == ETH1394_GASP) {
1528 int length = tx_len + (2 * sizeof(quadlet_t)); 1505 int length = tx_len + 2 * sizeof(quadlet_t);
1529 1506
1530 ether1394_prep_gasp_packet(packet, priv, ptask->skb, length); 1507 ether1394_prep_gasp_packet(packet, priv, ptask->skb, length);
1531 } else if (ether1394_prep_write_packet(packet, priv->host, 1508 } else if (ether1394_prep_write_packet(packet, priv->host,
@@ -1548,13 +1525,11 @@ static int ether1394_send_packet(struct packet_task *ptask, unsigned int tx_len)
1548 return 0; 1525 return 0;
1549} 1526}
1550 1527
1551
1552/* Task function to be run when a datagram transmission is completed */ 1528/* Task function to be run when a datagram transmission is completed */
1553static void ether1394_dg_complete(struct packet_task *ptask, int fail) 1529static void ether1394_dg_complete(struct packet_task *ptask, int fail)
1554{ 1530{
1555 struct sk_buff *skb = ptask->skb; 1531 struct sk_buff *skb = ptask->skb;
1556 struct net_device *dev = skb->dev; 1532 struct eth1394_priv *priv = netdev_priv(skb->dev);
1557 struct eth1394_priv *priv = netdev_priv(dev);
1558 unsigned long flags; 1533 unsigned long flags;
1559 1534
1560 /* Statistics */ 1535 /* Statistics */
@@ -1572,7 +1547,6 @@ static void ether1394_dg_complete(struct packet_task *ptask, int fail)
1572 kmem_cache_free(packet_task_cache, ptask); 1547 kmem_cache_free(packet_task_cache, ptask);
1573} 1548}
1574 1549
1575
1576/* Callback for when a packet has been sent and the status of that packet is 1550/* Callback for when a packet has been sent and the status of that packet is
1577 * known */ 1551 * known */
1578static void ether1394_complete_cb(void *__ptask) 1552static void ether1394_complete_cb(void *__ptask)
@@ -1600,10 +1574,8 @@ static void ether1394_complete_cb(void *__ptask)
1600 } 1574 }
1601} 1575}
1602 1576
1603
1604
1605/* Transmit a packet (called by kernel) */ 1577/* Transmit a packet (called by kernel) */
1606static int ether1394_tx (struct sk_buff *skb, struct net_device *dev) 1578static int ether1394_tx(struct sk_buff *skb, struct net_device *dev)
1607{ 1579{
1608 gfp_t kmflags = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; 1580 gfp_t kmflags = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
1609 struct eth1394hdr *eth; 1581 struct eth1394hdr *eth;
@@ -1637,13 +1609,14 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
1637 } 1609 }
1638#endif 1610#endif
1639 1611
1640 if ((skb = skb_share_check (skb, kmflags)) == NULL) { 1612 skb = skb_share_check(skb, kmflags);
1613 if (!skb) {
1641 ret = -ENOMEM; 1614 ret = -ENOMEM;
1642 goto fail; 1615 goto fail;
1643 } 1616 }
1644 1617
1645 /* Get rid of the fake eth1394 header, but save a pointer */ 1618 /* Get rid of the fake eth1394 header, but save a pointer */
1646 eth = (struct eth1394hdr*)skb->data; 1619 eth = (struct eth1394hdr *)skb->data;
1647 skb_pull(skb, ETH1394_HLEN); 1620 skb_pull(skb, ETH1394_HLEN);
1648 1621
1649 proto = eth->h_proto; 1622 proto = eth->h_proto;
@@ -1658,7 +1631,7 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
1658 tx_type = ETH1394_GASP; 1631 tx_type = ETH1394_GASP;
1659 dest_node = LOCAL_BUS | ALL_NODES; 1632 dest_node = LOCAL_BUS | ALL_NODES;
1660 max_payload = priv->bc_maxpayload - ETHER1394_GASP_OVERHEAD; 1633 max_payload = priv->bc_maxpayload - ETHER1394_GASP_OVERHEAD;
1661 BUG_ON(max_payload < (512 - ETHER1394_GASP_OVERHEAD)); 1634 BUG_ON(max_payload < 512 - ETHER1394_GASP_OVERHEAD);
1662 dgl = priv->bc_dgl; 1635 dgl = priv->bc_dgl;
1663 if (max_payload < dg_size + hdr_type_len[ETH1394_HDR_LF_UF]) 1636 if (max_payload < dg_size + hdr_type_len[ETH1394_HDR_LF_UF])
1664 priv->bc_dgl++; 1637 priv->bc_dgl++;
@@ -1671,7 +1644,8 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
1671 ret = -EAGAIN; 1644 ret = -EAGAIN;
1672 goto fail; 1645 goto fail;
1673 } 1646 }
1674 node_info = (struct eth1394_node_info*)node->ud->device.driver_data; 1647 node_info =
1648 (struct eth1394_node_info *)node->ud->device.driver_data;
1675 if (node_info->fifo == CSR1212_INVALID_ADDR_SPACE) { 1649 if (node_info->fifo == CSR1212_INVALID_ADDR_SPACE) {
1676 ret = -EAGAIN; 1650 ret = -EAGAIN;
1677 goto fail; 1651 goto fail;
@@ -1679,7 +1653,7 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
1679 1653
1680 dest_node = node->ud->ne->nodeid; 1654 dest_node = node->ud->ne->nodeid;
1681 max_payload = node_info->maxpayload; 1655 max_payload = node_info->maxpayload;
1682 BUG_ON(max_payload < (512 - ETHER1394_GASP_OVERHEAD)); 1656 BUG_ON(max_payload < 512 - ETHER1394_GASP_OVERHEAD);
1683 1657
1684 dgl = node_info->dgl; 1658 dgl = node_info->dgl;
1685 if (max_payload < dg_size + hdr_type_len[ETH1394_HDR_LF_UF]) 1659 if (max_payload < dg_size + hdr_type_len[ETH1394_HDR_LF_UF])
@@ -1689,7 +1663,7 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
1689 1663
1690 /* If this is an ARP packet, convert it */ 1664 /* If this is an ARP packet, convert it */
1691 if (proto == htons(ETH_P_ARP)) 1665 if (proto == htons(ETH_P_ARP))
1692 ether1394_arp_to_1394arp (skb, dev); 1666 ether1394_arp_to_1394arp(skb, dev);
1693 1667
1694 ptask->hdr.words.word1 = 0; 1668 ptask->hdr.words.word1 = 0;
1695 ptask->hdr.words.word2 = 0; 1669 ptask->hdr.words.word2 = 0;
@@ -1712,9 +1686,8 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
1712 1686
1713 ptask->tx_type = tx_type; 1687 ptask->tx_type = tx_type;
1714 ptask->max_payload = max_payload; 1688 ptask->max_payload = max_payload;
1715 ptask->outstanding_pkts = ether1394_encapsulate_prep(max_payload, proto, 1689 ptask->outstanding_pkts = ether1394_encapsulate_prep(max_payload,
1716 &ptask->hdr, dg_size, 1690 proto, &ptask->hdr, dg_size, dgl);
1717 dgl);
1718 1691
1719 /* Add the encapsulation header to the fragment */ 1692 /* Add the encapsulation header to the fragment */
1720 tx_len = ether1394_encapsulate(skb, max_payload, &ptask->hdr); 1693 tx_len = ether1394_encapsulate(skb, max_payload, &ptask->hdr);
@@ -1731,10 +1704,10 @@ fail:
1731 if (skb != NULL) 1704 if (skb != NULL)
1732 dev_kfree_skb(skb); 1705 dev_kfree_skb(skb);
1733 1706
1734 spin_lock_irqsave (&priv->lock, flags); 1707 spin_lock_irqsave(&priv->lock, flags);
1735 priv->stats.tx_dropped++; 1708 priv->stats.tx_dropped++;
1736 priv->stats.tx_errors++; 1709 priv->stats.tx_errors++;
1737 spin_unlock_irqrestore (&priv->lock, flags); 1710 spin_unlock_irqrestore(&priv->lock, flags);
1738 1711
1739 if (netif_queue_stopped(dev)) 1712 if (netif_queue_stopped(dev))
1740 netif_wake_queue(dev); 1713 netif_wake_queue(dev);
@@ -1742,11 +1715,11 @@ fail:
1742 return 0; /* returning non-zero causes serious problems */ 1715 return 0; /* returning non-zero causes serious problems */
1743} 1716}
1744 1717
1745static void ether1394_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 1718static void ether1394_get_drvinfo(struct net_device *dev,
1719 struct ethtool_drvinfo *info)
1746{ 1720{
1747 strcpy (info->driver, driver_name); 1721 strcpy(info->driver, driver_name);
1748 /* FIXME XXX provide sane businfo */ 1722 strcpy(info->bus_info, "ieee1394"); /* FIXME provide more detail? */
1749 strcpy (info->bus_info, "ieee1394");
1750} 1723}
1751 1724
1752static struct ethtool_ops ethtool_ops = { 1725static struct ethtool_ops ethtool_ops = {
@@ -1755,12 +1728,11 @@ static struct ethtool_ops ethtool_ops = {
1755 1728
1756static int __init ether1394_init_module (void) 1729static int __init ether1394_init_module (void)
1757{ 1730{
1758 packet_task_cache = kmem_cache_create("packet_task", sizeof(struct packet_task), 1731 packet_task_cache = kmem_cache_create("packet_task",
1732 sizeof(struct packet_task),
1759 0, 0, NULL, NULL); 1733 0, 0, NULL, NULL);
1760 1734
1761 /* Register ourselves as a highlevel driver */
1762 hpsb_register_highlevel(&eth1394_highlevel); 1735 hpsb_register_highlevel(&eth1394_highlevel);
1763
1764 return hpsb_register_protocol(&eth1394_proto_driver); 1736 return hpsb_register_protocol(&eth1394_proto_driver);
1765} 1737}
1766 1738
diff --git a/drivers/ieee1394/eth1394.h b/drivers/ieee1394/eth1394.h
index 2a88ee466354..a3439ee7cb4e 100644
--- a/drivers/ieee1394/eth1394.h
+++ b/drivers/ieee1394/eth1394.h
@@ -25,6 +25,8 @@
25#define __ETH1394_H 25#define __ETH1394_H
26 26
27#include <linux/netdevice.h> 27#include <linux/netdevice.h>
28#include <linux/skbuff.h>
29#include <asm/byteorder.h>
28 30
29#include "ieee1394.h" 31#include "ieee1394.h"
30#include "ieee1394_types.h" 32#include "ieee1394_types.h"
@@ -35,22 +37,15 @@
35 37
36/* GASP identifier numbers for IPv4 over IEEE 1394 */ 38/* GASP identifier numbers for IPv4 over IEEE 1394 */
37#define ETHER1394_GASP_SPECIFIER_ID 0x00005E 39#define ETHER1394_GASP_SPECIFIER_ID 0x00005E
38#define ETHER1394_GASP_SPECIFIER_ID_HI ((ETHER1394_GASP_SPECIFIER_ID >> 8) & 0xffff) 40#define ETHER1394_GASP_SPECIFIER_ID_HI ((0x00005E >> 8) & 0xffff)
39#define ETHER1394_GASP_SPECIFIER_ID_LO (ETHER1394_GASP_SPECIFIER_ID & 0xff) 41#define ETHER1394_GASP_SPECIFIER_ID_LO (0x00005E & 0xff)
40#define ETHER1394_GASP_VERSION 1 42#define ETHER1394_GASP_VERSION 1
41 43
42#define ETHER1394_GASP_OVERHEAD (2 * sizeof(quadlet_t)) /* GASP header overhead */ 44#define ETHER1394_GASP_OVERHEAD (2 * sizeof(quadlet_t)) /* for GASP header */
43 45
44#define ETHER1394_GASP_BUFFERS 16 46#define ETHER1394_GASP_BUFFERS 16
45 47
46/* rawiso buffer size - due to a limitation in rawiso, we must limit each 48#define NODE_SET (ALL_NODES + 1) /* Node set == 64 */
47 * GASP buffer to be less than PAGE_SIZE. */
48#define ETHER1394_ISO_BUF_SIZE ETHER1394_GASP_BUFFERS * \
49 min((unsigned int)PAGE_SIZE, \
50 2 * (1U << (priv->host->csr.max_rec + 1)))
51
52/* Node set == 64 */
53#define NODE_SET (ALL_NODES + 1)
54 49
55enum eth1394_bc_states { ETHER1394_BC_ERROR, 50enum eth1394_bc_states { ETHER1394_BC_ERROR,
56 ETHER1394_BC_RUNNING, 51 ETHER1394_BC_RUNNING,
@@ -86,19 +81,14 @@ struct eth1394hdr {
86 unsigned short h_proto; /* packet type ID field */ 81 unsigned short h_proto; /* packet type ID field */
87} __attribute__((packed)); 82} __attribute__((packed));
88 83
89#ifdef __KERNEL__
90#include <linux/skbuff.h>
91
92static inline struct eth1394hdr *eth1394_hdr(const struct sk_buff *skb) 84static inline struct eth1394hdr *eth1394_hdr(const struct sk_buff *skb)
93{ 85{
94 return (struct eth1394hdr *)skb_mac_header(skb); 86 return (struct eth1394hdr *)skb_mac_header(skb);
95} 87}
96#endif
97 88
98typedef enum {ETH1394_GASP, ETH1394_WRREQ} eth1394_tx_type; 89typedef enum {ETH1394_GASP, ETH1394_WRREQ} eth1394_tx_type;
99 90
100/* IP1394 headers */ 91/* IP1394 headers */
101#include <asm/byteorder.h>
102 92
103/* Unfragmented */ 93/* Unfragmented */
104#if defined __BIG_ENDIAN_BITFIELD 94#if defined __BIG_ENDIAN_BITFIELD