2 * NET3: Fibre Channel device handling subroutines
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Vineet Abraham <vma@iol.unh.edu>
13 #include <asm/uaccess.h>
14 #include <asm/system.h>
15 #include <linux/types.h>
16 #include <linux/kernel.h>
17 #include <linux/string.h>
19 #include <linux/socket.h>
21 #include <linux/inet.h>
22 #include <linux/netdevice.h>
23 #include <linux/fcdevice.h>
24 #include <linux/skbuff.h>
25 #include <linux/errno.h>
26 #include <linux/timer.h>
27 #include <linux/net.h>
28 #include <linux/proc_fs.h>
29 #include <linux/init.h>
33 * Put the headers on a Fibre Channel packet.
36 static int fc_header(struct sk_buff
*skb
, struct net_device
*dev
,
38 const void *daddr
, const void *saddr
, unsigned len
)
44 * Add the 802.2 SNAP header if IP as the IPv4 code calls
45 * dev->hard_header directly.
47 if (type
== ETH_P_IP
|| type
== ETH_P_ARP
)
51 hdr_len
= sizeof(struct fch_hdr
) + sizeof(struct fcllc
);
52 fch
= (struct fch_hdr
*)skb_push(skb
, hdr_len
);
53 fcllc
= (struct fcllc
*)(fch
+1);
54 fcllc
->dsap
= fcllc
->ssap
= EXTENDED_SAP
;
56 fcllc
->protid
[0] = fcllc
->protid
[1] = fcllc
->protid
[2] = 0x00;
57 fcllc
->ethertype
= htons(type
);
61 hdr_len
= sizeof(struct fch_hdr
);
62 fch
= (struct fch_hdr
*)skb_push(skb
, hdr_len
);
66 memcpy(fch
->saddr
,saddr
,dev
->addr_len
);
68 memcpy(fch
->saddr
,dev
->dev_addr
,dev
->addr_len
);
72 memcpy(fch
->daddr
,daddr
,dev
->addr_len
);
79 * A neighbour discovery of some species (eg arp) has completed. We
80 * can now send the packet.
83 static int fc_rebuild_header(struct sk_buff
*skb
)
85 struct fch_hdr
*fch
=(struct fch_hdr
*)skb
->data
;
86 struct fcllc
*fcllc
=(struct fcllc
*)(skb
->data
+sizeof(struct fch_hdr
));
87 if(fcllc
->ethertype
!= htons(ETH_P_IP
)) {
88 printk("fc_rebuild_header: Don't know how to resolve type %04X addresses ?\n", ntohs(fcllc
->ethertype
));
92 return arp_find(fch
->daddr
, skb
);
98 static const struct header_ops fc_header_ops
= {
100 .rebuild
= fc_rebuild_header
,
103 static void fc_setup(struct net_device
*dev
)
105 dev
->header_ops
= &fc_header_ops
;
106 dev
->type
= ARPHRD_IEEE802
;
107 dev
->hard_header_len
= FC_HLEN
;
109 dev
->addr_len
= FC_ALEN
;
110 dev
->tx_queue_len
= 100; /* Long queues on fc */
111 dev
->flags
= IFF_BROADCAST
;
113 memset(dev
->broadcast
, 0xFF, FC_ALEN
);
117 * alloc_fcdev - Register fibre channel device
118 * @sizeof_priv: Size of additional driver-private structure to be allocated
119 * for this fibre channel device
121 * Fill in the fields of the device structure with fibre channel-generic values.
123 * Constructs a new net device, complete with a private data area of
124 * size @sizeof_priv. A 32-byte (not bit) alignment is enforced for
125 * this private data area.
127 struct net_device
*alloc_fcdev(int sizeof_priv
)
129 return alloc_netdev(sizeof_priv
, "fc%d", fc_setup
);
131 EXPORT_SYMBOL(alloc_fcdev
);