2 * IPv4 over IEEE 1394, per RFC 2734
4 * Copyright (C) 2009 Jay Fenlason <fenlason@redhat.com>
6 * based on eth1394 by Ben Collins et al
9 #include <linux/device.h>
10 #include <linux/ethtool.h>
11 #include <linux/firewire.h>
12 #include <linux/firewire-constants.h>
13 #include <linux/highmem.h>
16 #include <linux/mod_devicetable.h>
17 #include <linux/module.h>
18 #include <linux/moduleparam.h>
19 #include <linux/netdevice.h>
20 #include <linux/skbuff.h>
22 #include <asm/unaligned.h>
25 /* Things to potentially make runtime cofigurable */
26 /* must be at least as large as our maximum receive size */
27 #define FIFO_SIZE 4096
28 /* Network timeout in glibbles */
29 #define IPV4_TIMEOUT 100000
31 /* Runitme configurable paramaters */
32 static int ipv4_mpd
= 25;
33 static int ipv4_max_xmt
= 0;
34 /* 16k for receiving arp and broadcast packets. Enough? */
35 static int ipv4_iso_page_count
= 4;
37 MODULE_AUTHOR("Jay Fenlason (fenlason@redhat.com)");
38 MODULE_DESCRIPTION("Firewire IPv4 Driver (IPv4-over-IEEE1394 as per RFC 2734)");
39 MODULE_LICENSE("GPL");
40 MODULE_DEVICE_TABLE(ieee1394
, ipv4_id_table
);
41 module_param_named(max_partial_datagrams
, ipv4_mpd
, int, S_IRUGO
| S_IWUSR
);
42 MODULE_PARM_DESC(max_partial_datagrams
, "Maximum number of received"
43 " incomplete fragmented datagrams (default = 25).");
45 /* Max xmt is useful for forcing fragmentation, which makes testing easier. */
46 module_param_named(max_transmit
, ipv4_max_xmt
, int, S_IRUGO
| S_IWUSR
);
47 MODULE_PARM_DESC(max_transmit
, "Maximum datagram size to transmit"
48 " (larger datagrams will be fragmented) (default = 0 (use hardware defaults).");
50 /* iso page count controls how many pages will be used for receiving broadcast packets. */
51 module_param_named(iso_pages
, ipv4_iso_page_count
, int, S_IRUGO
| S_IWUSR
);
52 MODULE_PARM_DESC(iso_pages
, "Number of pages to use for receiving broadcast packets"
55 /* uncomment this line to do debugging */
56 #define fw_debug(s, args...) printk(KERN_DEBUG KBUILD_MODNAME ": " s, ## args)
58 /* comment out these lines to do debugging. */
60 /* #define fw_debug(s...) */
61 /* #define print_hex_dump(l...) */
63 /* Define a fake hardware header format for the networking core. Note that
64 * header size cannot exceed 16 bytes as that is the size of the header cache.
65 * Also, we do not need the source address in the header so we omit it and
66 * keep the header to under 16 bytes */
68 /* This must equal sizeof(struct ipv4_ether_hdr) */
69 #define IPV4_HLEN (10)
71 /* FIXME: what's a good size for this? */
72 #define INVALID_FIFO_ADDR (u64)~0ULL
74 /* Things specified by standards */
75 #define BROADCAST_CHANNEL 31
77 #define S100_BUFFER_SIZE 512
78 #define MAX_BUFFER_SIZE 4096
80 #define IPV4_GASP_SPECIFIER_ID 0x00005EU
81 #define IPV4_GASP_VERSION 0x00000001U
83 #define IPV4_GASP_OVERHEAD (2 * sizeof(u32)) /* for GASP header */
85 #define IPV4_UNFRAG_HDR_SIZE sizeof(u32)
86 #define IPV4_FRAG_HDR_SIZE (2 * sizeof(u32))
87 #define IPV4_FRAG_OVERHEAD sizeof(u32)
89 #define ALL_NODES (0xffc0 | 0x003f)
91 #define IPV4_HDR_UNFRAG 0 /* unfragmented */
92 #define IPV4_HDR_FIRSTFRAG 1 /* first fragment */
93 #define IPV4_HDR_LASTFRAG 2 /* last fragment */
94 #define IPV4_HDR_INTFRAG 3 /* interior fragment */
96 /* Our arp packet (ARPHRD_IEEE1394) */
97 /* FIXME: note that this is probably bogus on weird-endian machines */
99 u16 hw_type
; /* 0x0018 */
100 u16 proto_type
; /* 0x0806 */
101 u8 hw_addr_len
; /* 16 */
102 u8 ip_addr_len
; /* 4 */
103 u16 opcode
; /* ARP Opcode */
104 /* Above is exactly the same format as struct arphdr */
106 u64 s_uniq_id
; /* Sender's 64bit EUI */
107 u8 max_rec
; /* Sender's max packet size */
108 u8 sspd
; /* Sender's max speed */
109 u16 fifo_hi
; /* hi 16bits of sender's FIFO addr */
110 u32 fifo_lo
; /* lo 32bits of sender's FIFO addr */
111 u32 sip
; /* Sender's IP Address */
112 u32 tip
; /* IP Address of requested hw addr */
113 } __attribute__((packed
));
115 struct ipv4_ether_hdr
{
116 unsigned char h_dest
[IPV4_ALEN
]; /* destination address */
117 unsigned short h_proto
; /* packet type ID field */
118 } __attribute__((packed
));
120 static inline struct ipv4_ether_hdr
*ipv4_ether_hdr(const struct sk_buff
*skb
)
122 return (struct ipv4_ether_hdr
*)skb_mac_header(skb
);
131 enum ipv4_broadcast_state
{
132 IPV4_BROADCAST_ERROR
,
133 IPV4_BROADCAST_RUNNING
,
134 IPV4_BROADCAST_STOPPED
,
137 #define ipv4_get_hdr_lf(h) (((h)->w0&0xC0000000)>>30)
138 #define ipv4_get_hdr_ether_type(h) (((h)->w0&0x0000FFFF) )
139 #define ipv4_get_hdr_dg_size(h) (((h)->w0&0x0FFF0000)>>16)
140 #define ipv4_get_hdr_fg_off(h) (((h)->w0&0x00000FFF) )
141 #define ipv4_get_hdr_dgl(h) (((h)->w1&0xFFFF0000)>>16)
143 #define ipv4_set_hdr_lf(lf) (( lf)<<30)
144 #define ipv4_set_hdr_ether_type(et) (( et) )
145 #define ipv4_set_hdr_dg_size(dgs) ((dgs)<<16)
146 #define ipv4_set_hdr_fg_off(fgo) ((fgo) )
148 #define ipv4_set_hdr_dgl(dgl) ((dgl)<<16)
155 static inline void ipv4_make_uf_hdr( struct ipv4_hdr
*hdr
, unsigned ether_type
) {
156 hdr
->w0
= ipv4_set_hdr_lf(IPV4_HDR_UNFRAG
)
157 |ipv4_set_hdr_ether_type(ether_type
);
158 fw_debug ( "Setting unfragmented header %p to %x\n", hdr
, hdr
->w0
);
161 static inline void ipv4_make_ff_hdr ( struct ipv4_hdr
*hdr
, unsigned ether_type
, unsigned dg_size
, unsigned dgl
) {
162 hdr
->w0
= ipv4_set_hdr_lf(IPV4_HDR_FIRSTFRAG
)
163 |ipv4_set_hdr_dg_size(dg_size
)
164 |ipv4_set_hdr_ether_type(ether_type
);
165 hdr
->w1
= ipv4_set_hdr_dgl(dgl
);
166 fw_debug ( "Setting fragmented header %p to first_frag %x,%x (et %x, dgs %x, dgl %x)\n", hdr
, hdr
->w0
, hdr
->w1
,
167 ether_type
, dg_size
, dgl
);
170 static inline void ipv4_make_sf_hdr ( struct ipv4_hdr
*hdr
, unsigned lf
, unsigned dg_size
, unsigned fg_off
, unsigned dgl
) {
171 hdr
->w0
= ipv4_set_hdr_lf(lf
)
172 |ipv4_set_hdr_dg_size(dg_size
)
173 |ipv4_set_hdr_fg_off(fg_off
);
174 hdr
->w1
= ipv4_set_hdr_dgl(dgl
);
175 fw_debug ( "Setting fragmented header %p to %x,%x (lf %x, dgs %x, fo %x dgl %x)\n",
176 hdr
, hdr
->w0
, hdr
->w1
,
177 lf
, dg_size
, fg_off
, dgl
);
180 /* End of IP1394 headers */
183 #define ETH1394_HDR_LF_UF 0 /* unfragmented */
184 #define ETH1394_HDR_LF_FF 1 /* first fragment */
185 #define ETH1394_HDR_LF_LF 2 /* last fragment */
186 #define ETH1394_HDR_LF_IF 3 /* interior fragment */
188 #define IP1394_HW_ADDR_LEN 16 /* As per RFC */
190 /* This list keeps track of what parts of the datagram have been filled in */
191 struct ipv4_fragment_info
{
192 struct list_head fragment_info
;
197 struct ipv4_partial_datagram
{
198 struct list_head pdg_list
;
199 struct list_head fragment_info
;
201 /* FIXME Why not use skb->data? */
209 * We keep one of these for each IPv4 capable device attached to a fw_card.
210 * The list of them is stored in the fw_card structure rather than in the
211 * ipv4_priv because the remote IPv4 nodes may be probed before the card is,
212 * so we need a place to store them before the ipv4_priv structure is
216 struct list_head ipv4_nodes
;
217 /* guid of the remote node */
219 /* FIFO address to transmit datagrams to, or INVALID_FIFO_ADDR */
222 spinlock_t pdg_lock
; /* partial datagram lock */
223 /* List of partial datagrams received from this node */
224 struct list_head pdg_list
;
225 /* Number of entries in pdg_list at the moment */
228 /* max payload to transmit to this remote node */
229 /* This already includes the IPV4_FRAG_HDR_SIZE overhead */
231 /* outgoing datagram label */
233 /* Current node_id of the remote node */
235 /* current generation of the remote node */
237 /* max speed that this node can receive at */
244 enum ipv4_broadcast_state broadcast_state
;
245 struct fw_iso_context
*broadcast_rcv_context
;
246 struct fw_iso_buffer broadcast_rcv_buffer
;
247 void **broadcast_rcv_buffer_ptrs
;
248 unsigned broadcast_rcv_next_ptr
;
249 unsigned num_broadcast_rcv_ptrs
;
250 unsigned rcv_buffer_size
;
252 * This value is the maximum unfragmented datagram size that can be
253 * sent by the hardware. It already has the GASP overhead and the
254 * unfragmented datagram header overhead calculated into it.
256 unsigned broadcast_xmt_max_payload
;
257 u16 broadcast_xmt_datagramlabel
;
260 * The csr address that remote nodes must send datagrams to for us to
263 struct fw_address_handler handler
;
267 /* struct work_struct wake;*/
268 /* List of packets to be sent */
269 struct list_head packet_list
;
271 * List of packets that were broadcasted. When we get an ISO interrupt
272 * one of them has been sent
274 struct list_head broadcasted_list
;
275 /* List of packets that have been sent but not yet acked */
276 struct list_head sent_list
;
278 struct fw_card
*card
;
281 /* This is our task struct. It's used for the packet complete callback. */
282 struct ipv4_packet_task
{
284 * ptask can actually be on priv->packet_list, priv->broadcasted_list,
285 * or priv->sent_list depending on its current state.
287 struct list_head packet_list
;
288 struct fw_transaction transaction
;
291 struct ipv4_priv
*priv
;
292 enum ipv4_tx_type tx_type
;
293 int outstanding_pkts
;
294 unsigned max_payload
;
301 static struct kmem_cache
*ipv4_packet_task_cache
;
303 static const char ipv4_driver_name
[] = "firewire-ipv4";
305 static const struct ieee1394_device_id ipv4_id_table
[] = {
307 .match_flags
= IEEE1394_MATCH_SPECIFIER_ID
|
308 IEEE1394_MATCH_VERSION
,
309 .specifier_id
= IPV4_GASP_SPECIFIER_ID
,
310 .version
= IPV4_GASP_VERSION
,
315 static u32 ipv4_unit_directory_data
[] = {
316 0x00040000, /* unit directory */
317 0x12000000 | IPV4_GASP_SPECIFIER_ID
, /* specifier ID */
318 0x81000003, /* text descriptor */
319 0x13000000 | IPV4_GASP_VERSION
, /* version */
320 0x81000005, /* text descriptor */
322 0x00030000, /* Three quadlets */
323 0x00000000, /* Text */
324 0x00000000, /* Language 0 */
325 0x49414e41, /* I A N A */
326 0x00030000, /* Three quadlets */
327 0x00000000, /* Text */
328 0x00000000, /* Language 0 */
329 0x49507634, /* I P v 4 */
332 static struct fw_descriptor ipv4_unit_directory
= {
333 .length
= ARRAY_SIZE(ipv4_unit_directory_data
),
335 .data
= ipv4_unit_directory_data
338 static int ipv4_send_packet(struct ipv4_packet_task
*ptask
);
340 /* ------------------------------------------------------------------ */
341 /******************************************
342 * HW Header net device functions
343 ******************************************/
344 /* These functions have been adapted from net/ethernet/eth.c */
346 /* Create a fake MAC header for an arbitrary protocol layer.
347 * saddr=NULL means use device source address
348 * daddr=NULL means leave destination address (eg unresolved arp). */
350 static int ipv4_header ( struct sk_buff
*skb
, struct net_device
*dev
,
351 unsigned short type
, const void *daddr
,
352 const void *saddr
, unsigned len
) {
353 struct ipv4_ether_hdr
*eth
;
355 eth
= (struct ipv4_ether_hdr
*)skb_push(skb
, sizeof(*eth
));
356 eth
->h_proto
= htons(type
);
358 if (dev
->flags
& (IFF_LOOPBACK
| IFF_NOARP
)) {
359 memset(eth
->h_dest
, 0, dev
->addr_len
);
360 return dev
->hard_header_len
;
364 memcpy(eth
->h_dest
, daddr
, dev
->addr_len
);
365 return dev
->hard_header_len
;
368 return -dev
->hard_header_len
;
371 /* Rebuild the faked MAC header. This is called after an ARP
372 * (or in future other address resolution) has completed on this
373 * sk_buff. We now let ARP fill in the other fields.
375 * This routine CANNOT use cached dst->neigh!
376 * Really, it is used only when dst->neigh is wrong.
379 static int ipv4_rebuild_header(struct sk_buff
*skb
)
381 struct ipv4_ether_hdr
*eth
;
383 eth
= (struct ipv4_ether_hdr
*)skb
->data
;
384 if (eth
->h_proto
== htons(ETH_P_IP
))
385 return arp_find((unsigned char *)ð
->h_dest
, skb
);
387 fw_notify ( "%s: unable to resolve type %04x addresses\n",
388 skb
->dev
->name
,ntohs(eth
->h_proto
) );
392 static int ipv4_header_cache(const struct neighbour
*neigh
, struct hh_cache
*hh
) {
393 unsigned short type
= hh
->hh_type
;
394 struct net_device
*dev
;
395 struct ipv4_ether_hdr
*eth
;
397 if (type
== htons(ETH_P_802_3
))
400 eth
= (struct ipv4_ether_hdr
*)((u8
*)hh
->hh_data
+ 16 - sizeof(*eth
));
402 memcpy(eth
->h_dest
, neigh
->ha
, dev
->addr_len
);
404 hh
->hh_len
= IPV4_HLEN
;
408 /* Called by Address Resolution module to notify changes in address. */
409 static void ipv4_header_cache_update(struct hh_cache
*hh
, const struct net_device
*dev
, const unsigned char * haddr
) {
410 memcpy((u8
*)hh
->hh_data
+ 16 - IPV4_HLEN
, haddr
, dev
->addr_len
);
413 static int ipv4_header_parse(const struct sk_buff
*skb
, unsigned char *haddr
) {
414 memcpy(haddr
, skb
->dev
->dev_addr
, IPV4_ALEN
);
418 static const struct header_ops ipv4_header_ops
= {
419 .create
= ipv4_header
,
420 .rebuild
= ipv4_rebuild_header
,
421 .cache
= ipv4_header_cache
,
422 .cache_update
= ipv4_header_cache_update
,
423 .parse
= ipv4_header_parse
,
426 /* ------------------------------------------------------------------ */
428 /* FIXME: is this correct for all cases? */
429 static bool ipv4_frag_overlap(struct ipv4_partial_datagram
*pd
, unsigned offset
, unsigned len
)
431 struct ipv4_fragment_info
*fi
;
432 unsigned end
= offset
+ len
;
434 list_for_each_entry(fi
, &pd
->fragment_info
, fragment_info
) {
435 if (offset
< fi
->offset
+ fi
->len
&& end
> fi
->offset
) {
436 fw_debug ( "frag_overlap pd %p fi %p (%x@%x) with %x@%x\n", pd
, fi
, fi
->len
, fi
->offset
, len
, offset
);
440 fw_debug ( "frag_overlap %p does not overlap with %x@%x\n", pd
, len
, offset
);
444 /* Assumes that new fragment does not overlap any existing fragments */
445 static struct ipv4_fragment_info
*ipv4_frag_new ( struct ipv4_partial_datagram
*pd
, unsigned offset
, unsigned len
) {
446 struct ipv4_fragment_info
*fi
, *fi2
, *new;
447 struct list_head
*list
;
449 fw_debug ( "frag_new pd %p %x@%x\n", pd
, len
, offset
);
450 list
= &pd
->fragment_info
;
451 list_for_each_entry(fi
, &pd
->fragment_info
, fragment_info
) {
452 if (fi
->offset
+ fi
->len
== offset
) {
453 /* The new fragment can be tacked on to the end */
454 /* Did the new fragment plug a hole? */
455 fi2
= list_entry(fi
->fragment_info
.next
, struct ipv4_fragment_info
, fragment_info
);
456 if (fi
->offset
+ fi
->len
== fi2
->offset
) {
457 fw_debug ( "pd %p: hole filling %p (%x@%x) and %p(%x@%x): now %x@%x\n", pd
, fi
, fi
->len
, fi
->offset
,
458 fi2
, fi2
->len
, fi2
->offset
, fi
->len
+ len
+ fi2
->len
, fi
->offset
);
459 /* glue fragments together */
460 fi
->len
+= len
+ fi2
->len
;
461 list_del(&fi2
->fragment_info
);
464 fw_debug ( "pd %p: extending %p from %x@%x to %x@%x\n", pd
, fi
, fi
->len
, fi
->offset
, fi
->len
+len
, fi
->offset
);
469 if (offset
+ len
== fi
->offset
) {
470 /* The new fragment can be tacked on to the beginning */
471 /* Did the new fragment plug a hole? */
472 fi2
= list_entry(fi
->fragment_info
.prev
, struct ipv4_fragment_info
, fragment_info
);
473 if (fi2
->offset
+ fi2
->len
== fi
->offset
) {
474 /* glue fragments together */
475 fw_debug ( "pd %p: extending %p and merging with %p from %x@%x to %x@%x\n",
476 pd
, fi2
, fi
, fi2
->len
, fi2
->offset
, fi2
->len
+ fi
->len
+ len
, fi2
->offset
);
477 fi2
->len
+= fi
->len
+ len
;
478 list_del(&fi
->fragment_info
);
482 fw_debug ( "pd %p: extending %p from %x@%x to %x@%x\n", pd
, fi
, fi
->len
, fi
->offset
, offset
, fi
->len
+ len
);
487 if (offset
> fi
->offset
+ fi
->len
) {
488 list
= &fi
->fragment_info
;
491 if (offset
+ len
< fi
->offset
) {
492 list
= fi
->fragment_info
.prev
;
497 new = kmalloc(sizeof(*new), GFP_ATOMIC
);
499 fw_error ( "out of memory in fragment handling!\n" );
503 new->offset
= offset
;
505 list_add(&new->fragment_info
, list
);
506 fw_debug ( "pd %p: new frag %p %x@%x\n", pd
, new, new->len
, new->offset
);
507 list_for_each_entry( fi
, &pd
->fragment_info
, fragment_info
)
508 fw_debug ( "fi %p %x@%x\n", fi
, fi
->len
, fi
->offset
);
512 /* ------------------------------------------------------------------ */
514 static struct ipv4_partial_datagram
*ipv4_pd_new(struct net_device
*netdev
,
515 struct ipv4_node
*node
, u16 datagram_label
, unsigned dg_size
, u32
*frag_buf
,
516 unsigned frag_off
, unsigned frag_len
) {
517 struct ipv4_partial_datagram
*new;
518 struct ipv4_fragment_info
*fi
;
520 new = kmalloc(sizeof(*new), GFP_ATOMIC
);
523 INIT_LIST_HEAD(&new->fragment_info
);
524 fi
= ipv4_frag_new ( new, frag_off
, frag_len
);
527 new->datagram_label
= datagram_label
;
528 new->datagram_size
= dg_size
;
529 new->skb
= dev_alloc_skb(dg_size
+ netdev
->hard_header_len
+ 15);
530 if ( new->skb
== NULL
)
532 skb_reserve(new->skb
, (netdev
->hard_header_len
+ 15) & ~15);
533 new->pbuf
= skb_put(new->skb
, dg_size
);
534 memcpy(new->pbuf
+ frag_off
, frag_buf
, frag_len
);
535 list_add_tail(&new->pdg_list
, &node
->pdg_list
);
536 fw_debug ( "pd_new: new pd %p { dgl %u, dg_size %u, skb %p, pbuf %p } on node %p\n",
537 new, new->datagram_label
, new->datagram_size
, new->skb
, new->pbuf
, node
);
545 fw_error("ipv4_pd_new: no memory\n");
549 static struct ipv4_partial_datagram
*ipv4_pd_find(struct ipv4_node
*node
, u16 datagram_label
) {
550 struct ipv4_partial_datagram
*pd
;
552 list_for_each_entry(pd
, &node
->pdg_list
, pdg_list
) {
553 if ( pd
->datagram_label
== datagram_label
) {
554 fw_debug ( "pd_find(node %p, label %u): pd %p\n", node
, datagram_label
, pd
);
558 fw_debug ( "pd_find(node %p, label %u) no entry\n", node
, datagram_label
);
563 static void ipv4_pd_delete ( struct ipv4_partial_datagram
*old
) {
564 struct ipv4_fragment_info
*fi
, *n
;
566 fw_debug ( "pd_delete %p\n", old
);
567 list_for_each_entry_safe(fi
, n
, &old
->fragment_info
, fragment_info
) {
568 fw_debug ( "Freeing fi %p\n", fi
);
571 list_del(&old
->pdg_list
);
572 dev_kfree_skb_any(old
->skb
);
576 static bool ipv4_pd_update ( struct ipv4_node
*node
, struct ipv4_partial_datagram
*pd
,
577 u32
*frag_buf
, unsigned frag_off
, unsigned frag_len
) {
578 fw_debug ( "pd_update node %p, pd %p, frag_buf %p, %x@%x\n", node
, pd
, frag_buf
, frag_len
, frag_off
);
579 if ( ipv4_frag_new ( pd
, frag_off
, frag_len
) == NULL
)
581 memcpy(pd
->pbuf
+ frag_off
, frag_buf
, frag_len
);
584 * Move list entry to beginnig of list so that oldest partial
585 * datagrams percolate to the end of the list
587 list_move_tail(&pd
->pdg_list
, &node
->pdg_list
);
588 fw_debug ( "New pd list:\n" );
589 list_for_each_entry ( pd
, &node
->pdg_list
, pdg_list
) {
590 fw_debug ( "pd %p\n", pd
);
595 static bool ipv4_pd_is_complete ( struct ipv4_partial_datagram
*pd
) {
596 struct ipv4_fragment_info
*fi
;
599 fi
= list_entry(pd
->fragment_info
.next
, struct ipv4_fragment_info
, fragment_info
);
601 ret
= (fi
->len
== pd
->datagram_size
);
602 fw_debug ( "pd_is_complete (pd %p, dgs %x): fi %p (%x@%x) %s\n", pd
, pd
->datagram_size
, fi
, fi
->len
, fi
->offset
, ret
? "yes" : "no" );
606 /* ------------------------------------------------------------------ */
608 static int ipv4_node_new ( struct fw_card
*card
, struct fw_device
*device
) {
609 struct ipv4_node
*node
;
611 node
= kmalloc ( sizeof(*node
), GFP_KERNEL
);
613 fw_error ( "allocate new node failed\n" );
616 node
->guid
= (u64
)device
->config_rom
[3] << 32 | device
->config_rom
[4];
617 node
->fifo
= INVALID_FIFO_ADDR
;
618 INIT_LIST_HEAD(&node
->pdg_list
);
619 spin_lock_init(&node
->pdg_lock
);
621 node
->generation
= device
->generation
;
623 node
->nodeid
= device
->node_id
;
624 /* FIXME what should it really be? */
625 node
->max_payload
= S100_BUFFER_SIZE
- IPV4_UNFRAG_HDR_SIZE
;
626 node
->datagram_label
= 0U;
627 node
->xmt_speed
= device
->max_speed
;
628 list_add_tail ( &node
->ipv4_nodes
, &card
->ipv4_nodes
);
629 fw_debug ( "node_new: %p { guid %016llx, generation %u, nodeid %x, max_payload %x, xmt_speed %x } added\n",
630 node
, (unsigned long long)node
->guid
, node
->generation
, node
->nodeid
, node
->max_payload
, node
->xmt_speed
);
634 static struct ipv4_node
*ipv4_node_find_by_guid(struct ipv4_priv
*priv
, u64 guid
) {
635 struct ipv4_node
*node
;
638 spin_lock_irqsave(&priv
->lock
, flags
);
639 list_for_each_entry(node
, &priv
->card
->ipv4_nodes
, ipv4_nodes
)
640 if (node
->guid
== guid
) {
641 /* FIXME: lock the node first? */
642 spin_unlock_irqrestore ( &priv
->lock
, flags
);
643 fw_debug ( "node_find_by_guid (%016llx) found %p\n", (unsigned long long)guid
, node
);
647 spin_unlock_irqrestore ( &priv
->lock
, flags
);
648 fw_debug ( "node_find_by_guid (%016llx) not found\n", (unsigned long long)guid
);
652 static struct ipv4_node
*ipv4_node_find_by_nodeid(struct ipv4_priv
*priv
, u16 nodeid
) {
653 struct ipv4_node
*node
;
656 spin_lock_irqsave(&priv
->lock
, flags
);
657 list_for_each_entry(node
, &priv
->card
->ipv4_nodes
, ipv4_nodes
)
658 if (node
->nodeid
== nodeid
) {
659 /* FIXME: lock the node first? */
660 spin_unlock_irqrestore ( &priv
->lock
, flags
);
661 fw_debug ( "node_find_by_nodeid (%x) found %p\n", nodeid
, node
);
664 fw_debug ( "node_find_by_nodeid (%x) not found\n", nodeid
);
665 spin_unlock_irqrestore ( &priv
->lock
, flags
);
669 /* This is only complicated because we can't assume priv exists */
670 static void ipv4_node_delete ( struct fw_card
*card
, struct fw_device
*device
) {
671 struct net_device
*netdev
;
672 struct ipv4_priv
*priv
;
673 struct ipv4_node
*node
;
676 struct ipv4_partial_datagram
*pd
, *pd_next
;
678 guid
= (u64
)device
->config_rom
[3] << 32 | device
->config_rom
[4];
679 netdev
= card
->netdev
;
681 priv
= netdev_priv ( netdev
);
685 spin_lock_irqsave ( &priv
->lock
, flags
);
686 list_for_each_entry( node
, &card
->ipv4_nodes
, ipv4_nodes
) {
687 if ( node
->guid
== guid
) {
688 list_del ( &node
->ipv4_nodes
);
689 list_for_each_entry_safe( pd
, pd_next
, &node
->pdg_list
, pdg_list
)
690 ipv4_pd_delete ( pd
);
695 spin_unlock_irqrestore ( &priv
->lock
, flags
);
698 /* ------------------------------------------------------------------ */
701 static int ipv4_finish_incoming_packet ( struct net_device
*netdev
,
702 struct sk_buff
*skb
, u16 source_node_id
, bool is_broadcast
, u16 ether_type
) {
703 struct ipv4_priv
*priv
;
704 static u64 broadcast_hw
= ~0ULL;
708 fw_debug ( "ipv4_finish_incoming_packet(%p, %p, %x, %s, %x\n",
709 netdev
, skb
, source_node_id
, is_broadcast
? "true" : "false", ether_type
);
710 priv
= netdev_priv(netdev
);
711 /* Write metadata, and then pass to the receive level */
713 skb
->ip_summed
= CHECKSUM_UNNECESSARY
; /* don't check it */
716 * Parse the encapsulation header. This actually does the job of
717 * converting to an ethernet frame header, as well as arp
718 * conversion if needed. ARP conversion is easier in this
719 * direction, since we are using ethernet as our backend.
722 * If this is an ARP packet, convert it. First, we want to make
723 * use of some of the fields, since they tell us a little bit
724 * about the sending machine.
726 if (ether_type
== ETH_P_ARP
) {
727 struct ipv4_arp
*arp1394
;
729 unsigned char *arp_ptr
;
734 struct ipv4_node
*node
;
735 static const u16 ipv4_speed_to_max_payload
[] = {
736 /* S100, S200, S400, S800, S1600, S3200 */
737 512, 1024, 2048, 4096, 4096, 4096
740 /* fw_debug ( "ARP packet\n" ); */
741 arp1394
= (struct ipv4_arp
*)skb
->data
;
742 arp
= (struct arphdr
*)skb
->data
;
743 arp_ptr
= (unsigned char *)(arp
+ 1);
744 fifo_addr
= (u64
)ntohs(arp1394
->fifo_hi
) << 32 |
745 ntohl(arp1394
->fifo_lo
);
746 max_rec
= priv
->card
->max_receive
;
747 if ( arp1394
->max_rec
< max_rec
)
748 max_rec
= arp1394
->max_rec
;
749 sspd
= arp1394
->sspd
;
751 * Sanity check. MacOSX seems to be sending us 131 in this
752 * field (atleast on my Panther G5). Not sure why.
755 fw_notify ( "sspd %x out of range\n", sspd
);
759 max_payload
= min(ipv4_speed_to_max_payload
[sspd
],
760 (u16
)(1 << (max_rec
+ 1))) - IPV4_UNFRAG_HDR_SIZE
;
762 guid
= be64_to_cpu(get_unaligned(&arp1394
->s_uniq_id
));
763 node
= ipv4_node_find_by_guid(priv
, guid
);
765 fw_notify ( "No node for ARP packet from %llx\n", guid
);
768 if ( node
->nodeid
!= source_node_id
|| node
->generation
!= priv
->card
->generation
) {
769 fw_notify ( "Internal error: node->nodeid (%x) != soucre_node_id (%x) or node->generation (%x) != priv->card->generation(%x)\n",
770 node
->nodeid
, source_node_id
, node
->generation
, priv
->card
->generation
);
771 node
->nodeid
= source_node_id
;
772 node
->generation
= priv
->card
->generation
;
775 /* FIXME: for debugging */
776 if ( sspd
> SCODE_400
)
778 /* Update our speed/payload/fifo_offset table */
780 * FIXME: this does not handle cases where two high-speed endpoints must use a slower speed because of
781 * a lower speed hub between them. We need to look at the actual topology map here.
783 fw_debug ( "Setting node %p fifo %llx (was %llx), max_payload %x (was %x), speed %x (was %x)\n",
784 node
, fifo_addr
, node
->fifo
, max_payload
, node
->max_payload
, sspd
, node
->xmt_speed
);
785 node
->fifo
= fifo_addr
;
786 node
->max_payload
= max_payload
;
788 * Only allow speeds to go down from their initial value.
789 * Otherwise a local node that can only do S400 or slower may
790 * be told to transmit at S800 to a faster remote node.
792 if ( node
->xmt_speed
> sspd
)
793 node
->xmt_speed
= sspd
;
796 * Now that we're done with the 1394 specific stuff, we'll
797 * need to alter some of the data. Believe it or not, all
798 * that needs to be done is sender_IP_address needs to be
799 * moved, the destination hardware address get stuffed
800 * in and the hardware address length set to 8.
802 * IMPORTANT: The code below overwrites 1394 specific data
803 * needed above so keep the munging of the data for the
804 * higher level IP stack last.
808 arp_ptr
+= arp
->ar_hln
; /* skip over sender unique id */
809 *(u32
*)arp_ptr
= arp1394
->sip
; /* move sender IP addr */
810 arp_ptr
+= arp
->ar_pln
; /* skip over sender IP addr */
812 if (arp
->ar_op
== htons(ARPOP_REQUEST
))
813 memset(arp_ptr
, 0, sizeof(u64
));
815 memcpy(arp_ptr
, netdev
->dev_addr
, sizeof(u64
));
818 /* Now add the ethernet header. */
819 guid
= cpu_to_be64(priv
->card
->guid
);
820 if (dev_hard_header(skb
, netdev
, ether_type
, is_broadcast
? &broadcast_hw
: &guid
, NULL
,
822 struct ipv4_ether_hdr
*eth
;
826 skb_reset_mac_header(skb
);
827 skb_pull(skb
, sizeof(*eth
));
828 eth
= ipv4_ether_hdr(skb
);
829 if (*eth
->h_dest
& 1) {
830 if (memcmp(eth
->h_dest
, netdev
->broadcast
, netdev
->addr_len
) == 0) {
831 fw_debug ( "Broadcast\n" );
832 skb
->pkt_type
= PACKET_BROADCAST
;
836 skb
->pkt_type
= PACKET_MULTICAST
;
839 if (memcmp(eth
->h_dest
, netdev
->dev_addr
, netdev
->addr_len
)) {
842 memcpy ( &a1
, eth
->h_dest
, sizeof(u64
));
843 memcpy ( &a2
, netdev
->dev_addr
, sizeof(u64
));
844 fw_debug ( "Otherhost %llx %llx %x\n", a1
, a2
, netdev
->addr_len
);
845 skb
->pkt_type
= PACKET_OTHERHOST
;
848 if (ntohs(eth
->h_proto
) >= 1536) {
849 fw_debug ( " proto %x %x\n", eth
->h_proto
, ntohs(eth
->h_proto
) );
850 protocol
= eth
->h_proto
;
852 rawp
= (u16
*)skb
->data
;
853 if (*rawp
== 0xFFFF) {
854 fw_debug ( "proto 802_3\n" );
855 protocol
= htons(ETH_P_802_3
);
857 fw_debug ( "proto 802_2\n" );
858 protocol
= htons(ETH_P_802_2
);
861 skb
->protocol
= protocol
;
863 status
= netif_rx(skb
);
864 if ( status
== NET_RX_DROP
) {
865 netdev
->stats
.rx_errors
++;
866 netdev
->stats
.rx_dropped
++;
868 netdev
->stats
.rx_packets
++;
869 netdev
->stats
.rx_bytes
+= skb
->len
;
871 if (netif_queue_stopped(netdev
))
872 netif_wake_queue(netdev
);
876 netdev
->stats
.rx_errors
++;
877 netdev
->stats
.rx_dropped
++;
878 dev_kfree_skb_any(skb
);
879 if (netif_queue_stopped(netdev
))
880 netif_wake_queue(netdev
);
881 netdev
->last_rx
= jiffies
;
885 /* ------------------------------------------------------------------ */
887 static int ipv4_incoming_packet ( struct ipv4_priv
*priv
, u32
*buf
, int len
, u16 source_node_id
, bool is_broadcast
) {
889 struct net_device
*netdev
;
893 struct ipv4_node
*node
;
894 struct ipv4_partial_datagram
*pd
;
901 fw_debug ( "ipv4_incoming_packet(%p, %p, %d, %x, %s)\n", priv
, buf
, len
, source_node_id
, is_broadcast
? "true" : "false" );
902 netdev
= priv
->card
->netdev
;
904 hdr
.w0
= ntohl(buf
[0]);
905 lf
= ipv4_get_hdr_lf(&hdr
);
906 if ( lf
== IPV4_HDR_UNFRAG
) {
908 * An unfragmented datagram has been received by the ieee1394
909 * bus. Build an skbuff around it so we can pass it to the
910 * high level network layer.
912 ether_type
= ipv4_get_hdr_ether_type(&hdr
);
913 fw_debug ( "header w0 = %x, lf = %x, ether_type = %x\n", hdr
.w0
, lf
, ether_type
);
915 len
-= IPV4_UNFRAG_HDR_SIZE
;
917 skb
= dev_alloc_skb(len
+ netdev
->hard_header_len
+ 15);
918 if (unlikely(!skb
)) {
919 fw_error ( "Out of memory for incoming packet\n");
920 netdev
->stats
.rx_dropped
++;
923 skb_reserve(skb
, (netdev
->hard_header_len
+ 15) & ~15);
924 memcpy(skb_put(skb
, len
), buf
, len
);
925 return ipv4_finish_incoming_packet(netdev
, skb
, source_node_id
, is_broadcast
, ether_type
);
927 /* A datagram fragment has been received, now the fun begins. */
928 hdr
.w1
= ntohl(buf
[1]);
930 len
-= IPV4_FRAG_HDR_SIZE
;
931 if ( lf
==IPV4_HDR_FIRSTFRAG
) {
932 ether_type
= ipv4_get_hdr_ether_type(&hdr
);
935 fg_off
= ipv4_get_hdr_fg_off(&hdr
);
936 ether_type
= 0; /* Shut up compiler! */
938 datagram_label
= ipv4_get_hdr_dgl(&hdr
);
939 dg_size
= ipv4_get_hdr_dg_size(&hdr
); /* ??? + 1 */
940 fw_debug ( "fragmented: %x.%x = lf %x, ether_type %x, fg_off %x, dgl %x, dg_size %x\n", hdr
.w0
, hdr
.w1
, lf
, ether_type
, fg_off
, datagram_label
, dg_size
);
941 node
= ipv4_node_find_by_nodeid ( priv
, source_node_id
);
942 spin_lock_irqsave(&node
->pdg_lock
, flags
);
943 pd
= ipv4_pd_find( node
, datagram_label
);
945 while ( node
->pdg_size
>= ipv4_mpd
) {
946 /* remove the oldest */
947 ipv4_pd_delete ( list_first_entry(&node
->pdg_list
, struct ipv4_partial_datagram
, pdg_list
) );
950 pd
= ipv4_pd_new ( netdev
, node
, datagram_label
, dg_size
,
958 if (ipv4_frag_overlap(pd
, fg_off
, len
) || pd
->datagram_size
!= dg_size
) {
960 * Differing datagram sizes or overlapping fragments,
961 * Either way the remote machine is playing silly buggers
962 * with us: obliterate the old datagram and start a new one.
964 ipv4_pd_delete ( pd
);
965 pd
= ipv4_pd_new ( netdev
, node
, datagram_label
,
966 dg_size
, buf
, fg_off
, len
);
975 worked
= ipv4_pd_update ( node
, pd
,
979 * Couldn't save off fragment anyway
980 * so might as well obliterate the
983 ipv4_pd_delete ( pd
);
988 } /* new datagram or add to existing one */
990 if ( lf
== IPV4_HDR_FIRSTFRAG
)
991 pd
->ether_type
= ether_type
;
992 if ( ipv4_pd_is_complete ( pd
) ) {
993 ether_type
= pd
->ether_type
;
995 skb
= skb_get(pd
->skb
);
996 ipv4_pd_delete ( pd
);
997 spin_unlock_irqrestore(&node
->pdg_lock
, flags
);
998 return ipv4_finish_incoming_packet ( netdev
, skb
, source_node_id
, false, ether_type
);
1001 * Datagram is not complete, we're done for the
1004 spin_unlock_irqrestore(&node
->pdg_lock
, flags
);
1008 spin_unlock_irqrestore(&node
->pdg_lock
, flags
);
1009 if (netif_queue_stopped(netdev
))
1010 netif_wake_queue(netdev
);
1014 static void ipv4_receive_packet ( struct fw_card
*card
, struct fw_request
*r
,
1015 int tcode
, int destination
, int source
, int generation
, int speed
,
1016 unsigned long long offset
, void *payload
, size_t length
, void *callback_data
) {
1017 struct ipv4_priv
*priv
;
1020 fw_debug ( "ipv4_receive_packet(%p,%p,%x,%x,%x,%x,%x,%llx,%p,%lx,%p)\n",
1021 card
, r
, tcode
, destination
, source
, generation
, speed
, offset
, payload
,
1022 (unsigned long)length
, callback_data
);
1023 print_hex_dump ( KERN_DEBUG
, "header: ", DUMP_PREFIX_OFFSET
, 32, 1, payload
, length
, false );
1024 priv
= callback_data
;
1025 if ( tcode
!= TCODE_WRITE_BLOCK_REQUEST
1026 || destination
!= card
->node_id
1027 || generation
!= card
->generation
1028 || offset
!= priv
->handler
.offset
) {
1029 fw_send_response(card
, r
, RCODE_CONFLICT_ERROR
);
1030 fw_debug("Conflict error card node_id=%x, card generation=%x, local offset %llx\n",
1031 card
->node_id
, card
->generation
, (unsigned long long)priv
->handler
.offset
);
1034 status
= ipv4_incoming_packet ( priv
, payload
, length
, source
, false );
1035 if ( status
!= 0 ) {
1036 fw_error ( "Incoming packet failure\n" );
1037 fw_send_response ( card
, r
, RCODE_CONFLICT_ERROR
);
1040 fw_send_response ( card
, r
, RCODE_COMPLETE
);
1043 static void ipv4_receive_broadcast(struct fw_iso_context
*context
, u32 cycle
,
1044 size_t header_length
, void *header
, void *data
) {
1045 struct ipv4_priv
*priv
;
1046 struct fw_iso_packet packet
;
1047 struct fw_card
*card
;
1055 unsigned long offset
;
1056 unsigned long flags
;
1058 fw_debug ( "ipv4_receive_broadcast ( context=%p, cycle=%x, header_length=%lx, header=%p, data=%p )\n", context
, cycle
, (unsigned long)header_length
, header
, data
);
1059 print_hex_dump ( KERN_DEBUG
, "header: ", DUMP_PREFIX_OFFSET
, 32, 1, header
, header_length
, false );
1063 length
= ntohs(hdr_ptr
[0]);
1064 spin_lock_irqsave(&priv
->lock
,flags
);
1065 offset
= priv
->rcv_buffer_size
* priv
->broadcast_rcv_next_ptr
;
1066 buf_ptr
= priv
->broadcast_rcv_buffer_ptrs
[priv
->broadcast_rcv_next_ptr
++];
1067 if ( priv
->broadcast_rcv_next_ptr
== priv
->num_broadcast_rcv_ptrs
)
1068 priv
->broadcast_rcv_next_ptr
= 0;
1069 spin_unlock_irqrestore(&priv
->lock
,flags
);
1070 fw_debug ( "length %u at %p\n", length
, buf_ptr
);
1071 print_hex_dump ( KERN_DEBUG
, "buffer: ", DUMP_PREFIX_OFFSET
, 32, 1, buf_ptr
, length
, false );
1073 specifier_id
= (be32_to_cpu(buf_ptr
[0]) & 0xffff) << 8
1074 | (be32_to_cpu(buf_ptr
[1]) & 0xff000000) >> 24;
1075 ver
= be32_to_cpu(buf_ptr
[1]) & 0xFFFFFF;
1076 source_node_id
= be32_to_cpu(buf_ptr
[0]) >> 16;
1077 /* fw_debug ( "source %x SpecID %x ver %x\n", source_node_id, specifier_id, ver ); */
1078 if ( specifier_id
== IPV4_GASP_SPECIFIER_ID
&& ver
== IPV4_GASP_VERSION
) {
1080 length
-= IPV4_GASP_OVERHEAD
;
1081 ipv4_incoming_packet(priv
, buf_ptr
, length
, source_node_id
, true);
1083 fw_debug ( "Ignoring packet: not GASP\n" );
1084 packet
.payload_length
= priv
->rcv_buffer_size
;
1085 packet
.interrupt
= 1;
1089 packet
.header_length
= IPV4_GASP_OVERHEAD
;
1090 spin_lock_irqsave(&priv
->lock
,flags
);
1091 retval
= fw_iso_context_queue ( priv
->broadcast_rcv_context
, &packet
,
1092 &priv
->broadcast_rcv_buffer
, offset
);
1093 spin_unlock_irqrestore(&priv
->lock
,flags
);
1095 fw_error ( "requeue failed\n" );
1098 static void debug_ptask ( struct ipv4_packet_task
*ptask
) {
1099 static const char *tx_types
[] = { "Unknown", "GASP", "Write" };
1101 fw_debug ( "packet %p { hdr { w0 %x w1 %x }, skb %p, priv %p,"
1102 " tx_type %s, outstanding_pkts %d, max_payload %x, fifo %llx,"
1103 " speed %x, dest_node %x, generation %x }\n",
1104 ptask
, ptask
->hdr
.w0
, ptask
->hdr
.w1
, ptask
->skb
, ptask
->priv
,
1105 ptask
->tx_type
> IPV4_WRREQ
? "Invalid" : tx_types
[ptask
->tx_type
],
1106 ptask
->outstanding_pkts
, ptask
->max_payload
,
1107 ptask
->fifo_addr
, ptask
->speed
, ptask
->dest_node
, ptask
->generation
);
1108 print_hex_dump ( KERN_DEBUG
, "packet :", DUMP_PREFIX_OFFSET
, 32, 1,
1109 ptask
->skb
->data
, ptask
->skb
->len
, false );
1112 static void ipv4_transmit_packet_done ( struct ipv4_packet_task
*ptask
) {
1113 struct ipv4_priv
*priv
;
1114 unsigned long flags
;
1117 spin_lock_irqsave ( &priv
->lock
, flags
);
1118 list_del ( &ptask
->packet_list
);
1119 spin_unlock_irqrestore ( &priv
->lock
, flags
);
1120 ptask
->outstanding_pkts
--;
1121 if ( ptask
->outstanding_pkts
> 0 ) {
1126 struct sk_buff
*skb
;
1128 /* Update the ptask to point to the next fragment and send it */
1129 lf
= ipv4_get_hdr_lf(&ptask
->hdr
);
1131 case IPV4_HDR_LASTFRAG
:
1132 case IPV4_HDR_UNFRAG
:
1134 fw_error ( "Outstanding packet %x lf %x, header %x,%x\n", ptask
->outstanding_pkts
, lf
, ptask
->hdr
.w0
, ptask
->hdr
.w1
);
1137 case IPV4_HDR_FIRSTFRAG
:
1138 /* Set frag type here for future interior fragments */
1139 dg_size
= ipv4_get_hdr_dg_size(&ptask
->hdr
);
1140 fg_off
= ptask
->max_payload
- IPV4_FRAG_HDR_SIZE
;
1141 datagram_label
= ipv4_get_hdr_dgl(&ptask
->hdr
);
1144 case IPV4_HDR_INTFRAG
:
1145 dg_size
= ipv4_get_hdr_dg_size(&ptask
->hdr
);
1146 fg_off
= ipv4_get_hdr_fg_off(&ptask
->hdr
) + ptask
->max_payload
- IPV4_FRAG_HDR_SIZE
;
1147 datagram_label
= ipv4_get_hdr_dgl(&ptask
->hdr
);
1151 skb_pull ( skb
, ptask
->max_payload
);
1152 if ( ptask
->outstanding_pkts
> 1 ) {
1153 ipv4_make_sf_hdr ( &ptask
->hdr
,
1154 IPV4_HDR_INTFRAG
, dg_size
, fg_off
, datagram_label
);
1156 ipv4_make_sf_hdr ( &ptask
->hdr
,
1157 IPV4_HDR_LASTFRAG
, dg_size
, fg_off
, datagram_label
);
1158 ptask
->max_payload
= skb
->len
+ IPV4_FRAG_HDR_SIZE
;
1161 ipv4_send_packet ( ptask
);
1163 dev_kfree_skb_any ( ptask
->skb
);
1164 kmem_cache_free( ipv4_packet_task_cache
, ptask
);
1168 static void ipv4_write_complete ( struct fw_card
*card
, int rcode
,
1169 void *payload
, size_t length
, void *data
) {
1170 struct ipv4_packet_task
*ptask
;
1173 fw_debug ( "ipv4_write_complete ( %p, %x, %p, %lx, %p )\n",
1174 card
, rcode
, payload
, (unsigned long)length
, data
);
1175 debug_ptask ( ptask
);
1177 if ( rcode
== RCODE_COMPLETE
) {
1178 ipv4_transmit_packet_done ( ptask
);
1180 fw_error ( "ipv4_write_complete: failed: %x\n", rcode
);
1181 /* ??? error recovery */
1185 static int ipv4_send_packet ( struct ipv4_packet_task
*ptask
) {
1186 struct ipv4_priv
*priv
;
1188 struct ipv4_hdr
*bufhdr
;
1189 unsigned long flags
;
1190 struct net_device
*netdev
;
1195 fw_debug ( "ipv4_send_packet\n" );
1196 debug_ptask ( ptask
);
1198 tx_len
= ptask
->max_payload
;
1199 switch (ipv4_get_hdr_lf(&ptask
->hdr
)) {
1200 case IPV4_HDR_UNFRAG
:
1201 bufhdr
= (struct ipv4_hdr
*)skb_push(ptask
->skb
, IPV4_UNFRAG_HDR_SIZE
);
1202 bufhdr
->w0
= htonl(ptask
->hdr
.w0
);
1205 case IPV4_HDR_FIRSTFRAG
:
1206 case IPV4_HDR_INTFRAG
:
1207 case IPV4_HDR_LASTFRAG
:
1208 bufhdr
= (struct ipv4_hdr
*)skb_push(ptask
->skb
, IPV4_FRAG_HDR_SIZE
);
1209 bufhdr
->w0
= htonl(ptask
->hdr
.w0
);
1210 bufhdr
->w1
= htonl(ptask
->hdr
.w1
);
1216 if ( ptask
->tx_type
== IPV4_GASP
) {
1221 /* ptask->generation may not have been set yet */
1222 generation
= priv
->card
->generation
;
1224 nodeid
= priv
->card
->node_id
;
1225 packets
= (u32
*)skb_push(ptask
->skb
, sizeof(u32
)*2);
1226 packets
[0] = htonl(nodeid
<< 16 | (IPV4_GASP_SPECIFIER_ID
>>8));
1227 packets
[1] = htonl((IPV4_GASP_SPECIFIER_ID
& 0xFF) << 24 | IPV4_GASP_VERSION
);
1228 fw_send_request ( priv
->card
, &ptask
->transaction
, TCODE_STREAM_DATA
,
1229 fw_stream_packet_destination_id(3, BROADCAST_CHANNEL
, 0),
1230 generation
, SCODE_100
, 0ULL, ptask
->skb
->data
, tx_len
+ 8, ipv4_write_complete
, ptask
);
1231 spin_lock_irqsave(&priv
->lock
,flags
);
1232 list_add_tail ( &ptask
->packet_list
, &priv
->broadcasted_list
);
1233 spin_unlock_irqrestore(&priv
->lock
,flags
);
1240 fw_debug("send_request (%p, %p, WRITE_BLOCK, %x, %x, %x, %llx, %p, %d, %p, %p\n",
1241 priv
->card
, &ptask
->transaction
, ptask
->dest_node
, ptask
->generation
,
1242 ptask
->speed
, (unsigned long long)ptask
->fifo_addr
, ptask
->skb
->data
, tx_len
,
1243 ipv4_write_complete
, ptask
);
1244 fw_send_request ( priv
->card
, &ptask
->transaction
,
1245 TCODE_WRITE_BLOCK_REQUEST
, ptask
->dest_node
, ptask
->generation
, ptask
->speed
,
1246 ptask
->fifo_addr
, ptask
->skb
->data
, tx_len
, ipv4_write_complete
, ptask
);
1247 spin_lock_irqsave(&priv
->lock
,flags
);
1248 list_add_tail ( &ptask
->packet_list
, &priv
->sent_list
);
1249 spin_unlock_irqrestore(&priv
->lock
,flags
);
1250 netdev
= priv
->card
->netdev
;
1251 netdev
->trans_start
= jiffies
;
1255 static int ipv4_broadcast_start ( struct ipv4_priv
*priv
) {
1256 struct fw_iso_context
*context
;
1258 unsigned num_packets
;
1259 unsigned max_receive
;
1260 struct fw_iso_packet packet
;
1261 unsigned long offset
;
1263 /* unsigned transmit_speed; */
1266 if ( priv
->card
->broadcast_channel
!= (BROADCAST_CHANNEL_VALID
|BROADCAST_CHANNEL_INITIAL
)) {
1267 fw_notify ( "Invalid broadcast channel %x\n", priv
->card
->broadcast_channel
);
1268 /* FIXME: try again later? */
1269 /* return -EINVAL; */
1272 if ( priv
->local_fifo
== INVALID_FIFO_ADDR
) {
1273 struct fw_address_region region
;
1275 priv
->handler
.length
= FIFO_SIZE
;
1276 priv
->handler
.address_callback
= ipv4_receive_packet
;
1277 priv
->handler
.callback_data
= priv
;
1278 /* FIXME: this is OHCI, but what about others? */
1279 region
.start
= 0xffff00000000ULL
;
1280 region
.end
= 0xfffffffffffcULL
;
1282 retval
= fw_core_add_address_handler ( &priv
->handler
, ®ion
);
1284 goto failed_initial
;
1285 priv
->local_fifo
= priv
->handler
.offset
;
1289 * FIXME: rawiso limits us to PAGE_SIZE. This only matters if we ever have
1290 * a machine with PAGE_SIZE < 4096
1292 max_receive
= 1U << (priv
->card
->max_receive
+ 1);
1293 num_packets
= ( ipv4_iso_page_count
* PAGE_SIZE
) / max_receive
;
1294 if ( ! priv
->broadcast_rcv_context
) {
1297 context
= fw_iso_context_create ( priv
->card
,
1298 FW_ISO_CONTEXT_RECEIVE
, BROADCAST_CHANNEL
,
1299 priv
->card
->link_speed
, 8, ipv4_receive_broadcast
, priv
);
1300 if (IS_ERR(context
)) {
1301 retval
= PTR_ERR(context
);
1302 goto failed_context_create
;
1304 retval
= fw_iso_buffer_init ( &priv
->broadcast_rcv_buffer
,
1305 priv
->card
, ipv4_iso_page_count
, DMA_FROM_DEVICE
);
1307 goto failed_buffer_init
;
1308 ptrptr
= kmalloc ( sizeof(void*)*num_packets
, GFP_KERNEL
);
1311 goto failed_ptrs_alloc
;
1313 priv
->broadcast_rcv_buffer_ptrs
= ptrptr
;
1314 for ( u
= 0; u
< ipv4_iso_page_count
; u
++ ) {
1318 ptr
= kmap ( priv
->broadcast_rcv_buffer
.pages
[u
] );
1319 for ( v
= 0; v
< num_packets
/ ipv4_iso_page_count
; v
++ )
1320 *ptrptr
++ = (void *)((char *)ptr
+ v
* max_receive
);
1322 priv
->broadcast_rcv_context
= context
;
1324 context
= priv
->broadcast_rcv_context
;
1326 packet
.payload_length
= max_receive
;
1327 packet
.interrupt
= 1;
1331 packet
.header_length
= IPV4_GASP_OVERHEAD
;
1333 for ( u
= 0; u
< num_packets
; u
++ ) {
1334 retval
= fw_iso_context_queue ( context
, &packet
,
1335 &priv
->broadcast_rcv_buffer
, offset
);
1337 goto failed_rcv_queue
;
1338 offset
+= max_receive
;
1340 priv
->num_broadcast_rcv_ptrs
= num_packets
;
1341 priv
->rcv_buffer_size
= max_receive
;
1342 priv
->broadcast_rcv_next_ptr
= 0U;
1343 retval
= fw_iso_context_start ( context
, -1, 0, FW_ISO_CONTEXT_MATCH_ALL_TAGS
); /* ??? sync */
1345 goto failed_rcv_queue
;
1346 /* FIXME: adjust this when we know the max receive speeds of all other IP nodes on the bus. */
1347 /* since we only xmt at S100 ??? */
1348 priv
->broadcast_xmt_max_payload
= S100_BUFFER_SIZE
- IPV4_GASP_OVERHEAD
- IPV4_UNFRAG_HDR_SIZE
;
1349 priv
->broadcast_state
= IPV4_BROADCAST_RUNNING
;
1353 kfree ( priv
->broadcast_rcv_buffer_ptrs
);
1354 priv
->broadcast_rcv_buffer_ptrs
= NULL
;
1356 fw_iso_buffer_destroy ( &priv
->broadcast_rcv_buffer
, priv
->card
);
1358 fw_iso_context_destroy ( context
);
1359 priv
->broadcast_rcv_context
= NULL
;
1360 failed_context_create
:
1361 fw_core_remove_address_handler ( &priv
->handler
);
1363 priv
->local_fifo
= INVALID_FIFO_ADDR
;
1367 /* This is called after an "ifup" */
1368 static int ipv4_open(struct net_device
*dev
) {
1369 struct ipv4_priv
*priv
;
1372 priv
= netdev_priv(dev
);
1373 if (priv
->broadcast_state
== IPV4_BROADCAST_ERROR
) {
1374 ret
= ipv4_broadcast_start ( priv
);
1378 netif_start_queue(dev
);
1382 /* This is called after an "ifdown" */
1383 static int ipv4_stop(struct net_device
*netdev
)
1385 /* flush priv->wake */
1386 /* flush_scheduled_work(); */
1388 netif_stop_queue(netdev
);
1392 /* Transmit a packet (called by kernel) */
1393 static int ipv4_tx(struct sk_buff
*skb
, struct net_device
*netdev
)
1395 struct ipv4_ether_hdr hdr_buf
;
1396 struct ipv4_priv
*priv
= netdev_priv(netdev
);
1399 enum ipv4_tx_type tx_type
;
1400 unsigned max_payload
;
1402 u16
*datagram_label_ptr
;
1403 struct ipv4_packet_task
*ptask
;
1404 struct ipv4_node
*node
= NULL
;
1406 ptask
= kmem_cache_alloc(ipv4_packet_task_cache
, GFP_ATOMIC
);
1410 skb
= skb_share_check(skb
, GFP_ATOMIC
);
1415 * Get rid of the fake ipv4 header, but first make a copy.
1416 * We might need to rebuild the header on tx failure.
1418 memcpy(&hdr_buf
, skb
->data
, sizeof(hdr_buf
));
1419 skb_pull(skb
, sizeof(hdr_buf
));
1421 proto
= hdr_buf
.h_proto
;
1425 * Set the transmission type for the packet. ARP packets and IP
1426 * broadcast packets are sent via GASP.
1428 if ( memcmp(hdr_buf
.h_dest
, netdev
->broadcast
, IPV4_ALEN
) == 0
1429 || proto
== htons(ETH_P_ARP
)
1430 || ( proto
== htons(ETH_P_IP
)
1431 && IN_MULTICAST(ntohl(ip_hdr(skb
)->daddr
)) ) ) {
1432 /* fw_debug ( "transmitting arp or multicast packet\n" );*/
1433 tx_type
= IPV4_GASP
;
1434 dest_node
= ALL_NODES
;
1435 max_payload
= priv
->broadcast_xmt_max_payload
;
1436 /* BUG_ON(max_payload < S100_BUFFER_SIZE - IPV4_GASP_OVERHEAD); */
1437 datagram_label_ptr
= &priv
->broadcast_xmt_datagramlabel
;
1438 ptask
->fifo_addr
= INVALID_FIFO_ADDR
;
1439 ptask
->generation
= 0U;
1440 ptask
->dest_node
= 0U;
1443 __be64 guid
= get_unaligned((u64
*)hdr_buf
.h_dest
);
1446 node
= ipv4_node_find_by_guid(priv
, be64_to_cpu(guid
));
1448 fw_debug ( "Normal packet but no node\n" );
1452 if (node
->fifo
== INVALID_FIFO_ADDR
) {
1453 fw_debug ( "Normal packet but no fifo addr\n" );
1457 /* fw_debug ( "Transmitting normal packet to %x at %llxx\n", node->nodeid, node->fifo ); */
1458 generation
= node
->generation
;
1459 dest_node
= node
->nodeid
;
1460 max_payload
= node
->max_payload
;
1461 /* BUG_ON(max_payload < S100_BUFFER_SIZE - IPV4_FRAG_HDR_SIZE); */
1463 datagram_label_ptr
= &node
->datagram_label
;
1464 tx_type
= IPV4_WRREQ
;
1465 ptask
->fifo_addr
= node
->fifo
;
1466 ptask
->generation
= generation
;
1467 ptask
->dest_node
= dest_node
;
1468 ptask
->speed
= node
->xmt_speed
;
1471 /* If this is an ARP packet, convert it */
1472 if (proto
== htons(ETH_P_ARP
)) {
1473 /* Convert a standard ARP packet to 1394 ARP. The first 8 bytes (the entire
1474 * arphdr) is the same format as the ip1394 header, so they overlap. The rest
1475 * needs to be munged a bit. The remainder of the arphdr is formatted based
1476 * on hwaddr len and ipaddr len. We know what they'll be, so it's easy to
1479 * Now that the EUI is used for the hardware address all we need to do to make
1480 * this work for 1394 is to insert 2 quadlets that contain max_rec size,
1481 * speed, and unicast FIFO address information between the sender_unique_id
1482 * and the IP addresses.
1484 struct arphdr
*arp
= (struct arphdr
*)skb
->data
;
1485 unsigned char *arp_ptr
= (unsigned char *)(arp
+ 1);
1486 struct ipv4_arp
*arp1394
= (struct ipv4_arp
*)skb
->data
;
1489 ipaddr
= *(u32
*)(arp_ptr
+ IPV4_ALEN
);
1490 arp1394
->hw_addr_len
= 16;
1491 arp1394
->max_rec
= priv
->card
->max_receive
;
1492 arp1394
->sspd
= priv
->card
->link_speed
;
1493 arp1394
->fifo_hi
= htons(priv
->local_fifo
>> 32);
1494 arp1394
->fifo_lo
= htonl(priv
->local_fifo
& 0xFFFFFFFF);
1495 arp1394
->sip
= ipaddr
;
1497 if ( ipv4_max_xmt
&& max_payload
> ipv4_max_xmt
)
1498 max_payload
= ipv4_max_xmt
;
1504 ptask
->tx_type
= tx_type
;
1505 /* Does it all fit in one packet? */
1506 if ( dg_size
<= max_payload
) {
1507 ipv4_make_uf_hdr(&ptask
->hdr
, be16_to_cpu(proto
));
1508 ptask
->outstanding_pkts
= 1;
1509 max_payload
= dg_size
+ IPV4_UNFRAG_HDR_SIZE
;
1513 max_payload
-= IPV4_FRAG_OVERHEAD
;
1514 datagram_label
= (*datagram_label_ptr
)++;
1515 ipv4_make_ff_hdr(&ptask
->hdr
, be16_to_cpu(proto
), dg_size
, datagram_label
);
1516 ptask
->outstanding_pkts
= DIV_ROUND_UP(dg_size
, max_payload
);
1517 max_payload
+= IPV4_FRAG_HDR_SIZE
;
1519 ptask
->max_payload
= max_payload
;
1520 ipv4_send_packet ( ptask
);
1521 return NETDEV_TX_OK
;
1525 kmem_cache_free(ipv4_packet_task_cache
, ptask
);
1530 netdev
->stats
.tx_dropped
++;
1531 netdev
->stats
.tx_errors
++;
1534 * FIXME: According to a patch from 2003-02-26, "returning non-zero
1535 * causes serious problems" here, allegedly. Before that patch,
1536 * -ERRNO was returned which is not appropriate under Linux 2.6.
1537 * Perhaps more needs to be done? Stop the queue in serious
1538 * conditions and restart it elsewhere?
1540 return NETDEV_TX_OK
;
1544 * FIXME: What to do if we timeout? I think a host reset is probably in order,
1545 * so that's what we do. Should we increment the stat counters too?
1547 static void ipv4_tx_timeout(struct net_device
*dev
) {
1548 struct ipv4_priv
*priv
;
1550 priv
= netdev_priv(dev
);
1551 fw_error ( "%s: Timeout, resetting host\n", dev
->name
);
1553 fw_core_initiate_bus_reset ( priv
->card
, 1 );
1557 static int ipv4_change_mtu ( struct net_device
*dev
, int new_mtu
) {
1560 struct ipv4_priv
*priv
;
1567 priv
= netdev_priv(dev
);
1568 /* This is not actually true because we can fragment packets at the firewire layer */
1569 max_mtu
= (1 << (priv
->card
->max_receive
+ 1))
1570 - sizeof(struct ipv4_hdr
) - IPV4_GASP_OVERHEAD
;
1571 if (new_mtu
> max_mtu
) {
1572 fw_notify ( "%s: Local node constrains MTU to %d\n", dev
->name
, max_mtu
);
1580 static void ipv4_get_drvinfo(struct net_device
*dev
,
1581 struct ethtool_drvinfo
*info
) {
1582 strcpy(info
->driver
, ipv4_driver_name
);
1583 strcpy(info
->bus_info
, "ieee1394"); /* FIXME provide more detail? */
1586 static struct ethtool_ops ipv4_ethtool_ops
= {
1587 .get_drvinfo
= ipv4_get_drvinfo
,
1590 static const struct net_device_ops ipv4_netdev_ops
= {
1591 .ndo_open
= ipv4_open
,
1592 .ndo_stop
= ipv4_stop
,
1593 .ndo_start_xmit
= ipv4_tx
,
1594 .ndo_tx_timeout
= ipv4_tx_timeout
,
1595 .ndo_change_mtu
= ipv4_change_mtu
,
1598 static void ipv4_init_dev ( struct net_device
*dev
) {
1599 dev
->header_ops
= &ipv4_header_ops
;
1600 dev
->netdev_ops
= &ipv4_netdev_ops
;
1601 SET_ETHTOOL_OPS(dev
, &ipv4_ethtool_ops
);
1603 dev
->watchdog_timeo
= IPV4_TIMEOUT
;
1604 dev
->flags
= IFF_BROADCAST
| IFF_MULTICAST
;
1605 dev
->features
= NETIF_F_HIGHDMA
;
1606 dev
->addr_len
= IPV4_ALEN
;
1607 dev
->hard_header_len
= IPV4_HLEN
;
1608 dev
->type
= ARPHRD_IEEE1394
;
1610 /* FIXME: This value was copied from ether_setup(). Is it too much? */
1611 dev
->tx_queue_len
= 1000;
1614 static int ipv4_probe ( struct device
*dev
) {
1615 struct fw_unit
* unit
;
1616 struct fw_device
*device
;
1617 struct fw_card
*card
;
1618 struct net_device
*netdev
;
1619 struct ipv4_priv
*priv
;
1623 fw_debug("ipv4 Probing\n" );
1624 unit
= fw_unit ( dev
);
1625 device
= fw_device ( unit
->device
.parent
);
1626 card
= device
->card
;
1628 if ( ! device
->is_local
) {
1631 fw_debug ( "Non-local, adding remote node entry\n" );
1632 added
= ipv4_node_new ( card
, device
);
1635 fw_debug("ipv4 Local: adding netdev\n" );
1636 netdev
= alloc_netdev ( sizeof(*priv
), "firewire%d", ipv4_init_dev
);
1637 if ( netdev
== NULL
) {
1638 fw_error( "Out of memory\n");
1642 SET_NETDEV_DEV(netdev
, card
->device
);
1643 priv
= netdev_priv(netdev
);
1645 spin_lock_init(&priv
->lock
);
1646 priv
->broadcast_state
= IPV4_BROADCAST_ERROR
;
1647 priv
->broadcast_rcv_context
= NULL
;
1648 priv
->broadcast_xmt_max_payload
= 0;
1649 priv
->broadcast_xmt_datagramlabel
= 0;
1651 priv
->local_fifo
= INVALID_FIFO_ADDR
;
1653 /* INIT_WORK(&priv->wake, ipv4_handle_queue);*/
1654 INIT_LIST_HEAD(&priv
->packet_list
);
1655 INIT_LIST_HEAD(&priv
->broadcasted_list
);
1656 INIT_LIST_HEAD(&priv
->sent_list
);
1661 * Use the RFC 2734 default 1500 octets or the maximum payload
1664 max_mtu
= (1 << (card
->max_receive
+ 1))
1665 - sizeof(struct ipv4_hdr
) - IPV4_GASP_OVERHEAD
;
1666 netdev
->mtu
= min(1500U, max_mtu
);
1668 /* Set our hardware address while we're at it */
1669 guid
= cpu_to_be64(card
->guid
);
1670 memcpy(netdev
->dev_addr
, &guid
, sizeof(u64
));
1671 memset(netdev
->broadcast
, 0xff, sizeof(u64
));
1672 if ( register_netdev ( netdev
) ) {
1673 fw_error ( "Cannot register the driver\n");
1677 fw_notify ( "%s: IPv4 over Firewire on device %016llx\n",
1678 netdev
->name
, card
->guid
);
1679 card
->netdev
= netdev
;
1681 return 0 /* ipv4_new_node ( ud ) */;
1684 free_netdev ( netdev
);
1689 static int ipv4_remove ( struct device
*dev
) {
1690 struct fw_unit
* unit
;
1691 struct fw_device
*device
;
1692 struct fw_card
*card
;
1693 struct net_device
*netdev
;
1694 struct ipv4_priv
*priv
;
1695 struct ipv4_node
*node
;
1696 struct ipv4_partial_datagram
*pd
, *pd_next
;
1697 struct ipv4_packet_task
*ptask
, *pt_next
;
1699 fw_debug("ipv4 Removing\n" );
1700 unit
= fw_unit ( dev
);
1701 device
= fw_device ( unit
->device
.parent
);
1702 card
= device
->card
;
1704 if ( ! device
->is_local
) {
1705 fw_debug ( "Node %x is non-local, removing remote node entry\n", device
->node_id
);
1706 ipv4_node_delete ( card
, device
);
1709 netdev
= card
->netdev
;
1711 fw_debug ( "Node %x is local: deleting netdev\n", device
->node_id
);
1712 priv
= netdev_priv ( netdev
);
1713 unregister_netdev ( netdev
);
1714 fw_debug ( "unregistered\n" );
1715 if ( priv
->local_fifo
!= INVALID_FIFO_ADDR
)
1716 fw_core_remove_address_handler ( &priv
->handler
);
1717 fw_debug ( "address handler gone\n" );
1718 if ( priv
->broadcast_rcv_context
) {
1719 fw_iso_context_stop ( priv
->broadcast_rcv_context
);
1720 fw_iso_buffer_destroy ( &priv
->broadcast_rcv_buffer
, priv
->card
);
1721 fw_iso_context_destroy ( priv
->broadcast_rcv_context
);
1722 fw_debug ( "rcv stopped\n" );
1724 list_for_each_entry_safe( ptask
, pt_next
, &priv
->packet_list
, packet_list
) {
1725 dev_kfree_skb_any ( ptask
->skb
);
1726 kmem_cache_free( ipv4_packet_task_cache
, ptask
);
1728 list_for_each_entry_safe( ptask
, pt_next
, &priv
->broadcasted_list
, packet_list
) {
1729 dev_kfree_skb_any ( ptask
->skb
);
1730 kmem_cache_free( ipv4_packet_task_cache
, ptask
);
1732 list_for_each_entry_safe( ptask
, pt_next
, &priv
->sent_list
, packet_list
) {
1733 dev_kfree_skb_any ( ptask
->skb
);
1734 kmem_cache_free( ipv4_packet_task_cache
, ptask
);
1736 fw_debug ( "lists emptied\n" );
1737 list_for_each_entry( node
, &card
->ipv4_nodes
, ipv4_nodes
) {
1738 if ( node
->pdg_size
) {
1739 list_for_each_entry_safe( pd
, pd_next
, &node
->pdg_list
, pdg_list
)
1740 ipv4_pd_delete ( pd
);
1743 node
->fifo
= INVALID_FIFO_ADDR
;
1745 fw_debug ( "nodes cleaned up\n" );
1746 free_netdev ( netdev
);
1747 card
->netdev
= NULL
;
1748 fw_debug ( "done\n" );
1753 static void ipv4_update ( struct fw_unit
*unit
) {
1754 struct fw_device
*device
;
1755 struct fw_card
*card
;
1757 fw_debug ( "ipv4_update unit %p\n", unit
);
1758 device
= fw_device ( unit
->device
.parent
);
1759 card
= device
->card
;
1760 if ( ! device
->is_local
) {
1761 struct ipv4_node
*node
;
1763 struct net_device
*netdev
;
1764 struct ipv4_priv
*priv
;
1766 netdev
= card
->netdev
;
1768 priv
= netdev_priv ( netdev
);
1769 guid
= (u64
)device
->config_rom
[3] << 32 | device
->config_rom
[4];
1770 node
= ipv4_node_find_by_guid ( priv
, guid
);
1772 fw_error ( "ipv4_update: no node for device %llx\n", guid
);
1775 fw_debug ( "Non-local, updating remote node entry for guid %llx old generation %x, old nodeid %x\n", guid
, node
->generation
, node
->nodeid
);
1776 node
->generation
= device
->generation
;
1778 node
->nodeid
= device
->node_id
;
1779 fw_debug ( "New generation %x, new nodeid %x\n", node
->generation
, node
->nodeid
);
1781 fw_error ( "nonlocal, but no netdev? How can that be?\n" );
1783 /* FIXME: What do we need to do on bus reset? */
1784 fw_debug ( "Local, doing nothing\n" );
1788 static struct fw_driver ipv4_driver
= {
1790 .owner
= THIS_MODULE
,
1791 .name
= ipv4_driver_name
,
1792 .bus
= &fw_bus_type
,
1793 .probe
= ipv4_probe
,
1794 .remove
= ipv4_remove
,
1796 .update
= ipv4_update
,
1797 .id_table
= ipv4_id_table
,
1800 static int __init
ipv4_init ( void ) {
1803 added
= fw_core_add_descriptor ( &ipv4_unit_directory
);
1805 fw_error ( "Failed to add descriptor" );
1806 ipv4_packet_task_cache
= kmem_cache_create("packet_task",
1807 sizeof(struct ipv4_packet_task
), 0, 0, NULL
);
1808 fw_debug("Adding ipv4 module\n" );
1809 return driver_register ( &ipv4_driver
.driver
);
1812 static void __exit
ipv4_cleanup ( void ) {
1813 fw_core_remove_descriptor ( &ipv4_unit_directory
);
1814 fw_debug("Removing ipv4 module\n" );
1815 driver_unregister ( &ipv4_driver
.driver
);
1818 module_init(ipv4_init
);
1819 module_exit(ipv4_cleanup
);