[SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph
[powerpc.git] / drivers / ieee1394 / eth1394.c
index 8a7b8fa..a364003 100644 (file)
@@ -43,7 +43,6 @@
 
 #include <linux/module.h>
 
-#include <linux/sched.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/errno.h>
@@ -64,6 +63,7 @@
 #include <linux/ethtool.h>
 #include <asm/uaccess.h>
 #include <asm/delay.h>
+#include <asm/unaligned.h>
 #include <net/arp.h>
 
 #include "config_roms.h"
@@ -132,7 +132,7 @@ struct eth1394_node_info {
 #define ETH1394_DRIVER_NAME "eth1394"
 static const char driver_name[] = ETH1394_DRIVER_NAME;
 
-static kmem_cache_t *packet_task_cache;
+static struct kmem_cache *packet_task_cache;
 
 static struct hpsb_highlevel eth1394_highlevel;
 
@@ -473,12 +473,10 @@ static struct ieee1394_device_id eth1394_id_table[] = {
 MODULE_DEVICE_TABLE(ieee1394, eth1394_id_table);
 
 static struct hpsb_protocol_driver eth1394_proto_driver = {
-       .name           = "IPv4 over 1394 Driver",
+       .name           = ETH1394_DRIVER_NAME,
        .id_table       = eth1394_id_table,
        .update         = eth1394_update,
        .driver         = {
-               .name           = ETH1394_DRIVER_NAME,
-               .bus            = &ieee1394_bus_type,
                .probe          = eth1394_probe,
                .remove         = eth1394_remove,
        },
@@ -491,7 +489,7 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
        int i;
        struct eth1394_priv *priv = netdev_priv(dev);
        struct hpsb_host *host = priv->host;
-       u64 guid = *((u64*)&(host->csr.rom->bus_info_data[3]));
+       u64 guid = get_unaligned((u64*)&(host->csr.rom->bus_info_data[3]));
        u16 maxpayload = 1 << (host->csr.max_rec + 1);
        int max_speed = IEEE1394_SPEED_MAX;
 
@@ -514,8 +512,8 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
                                      ETHER1394_GASP_OVERHEAD)));
 
                /* Set our hardware address while we're at it */
-               *(u64*)dev->dev_addr = guid;
-               *(u64*)dev->broadcast = ~0x0ULL;
+               memcpy(dev->dev_addr, &guid, sizeof(u64));
+               memset(dev->broadcast, 0xff, sizeof(u64));
        }
 
        spin_unlock_irqrestore (&priv->lock, flags);
@@ -586,7 +584,10 @@ static void ether1394_add_host (struct hpsb_host *host)
         }
 
        SET_MODULE_OWNER(dev);
+#if 0
+       /* FIXME - Is this the correct parent device anyway? */
        SET_NETDEV_DEV(dev, &host->device);
+#endif
 
        priv = netdev_priv(dev);
 
@@ -833,7 +834,7 @@ static inline u16 ether1394_type_trans(struct sk_buff *skb,
        struct eth1394hdr *eth;
        unsigned char *rawp;
 
-       skb->mac.raw = skb->data;
+       skb_reset_mac_header(skb);
        skb_pull (skb, ETH1394_HLEN);
        eth = eth1394_hdr(skb);
 
@@ -894,6 +895,7 @@ static inline u16 ether1394_parse_encap(struct sk_buff *skb,
                u16 maxpayload;
                struct eth1394_node_ref *node;
                struct eth1394_node_info *node_info;
+               __be64 guid;
 
                /* Sanity check. MacOSX seems to be sending us 131 in this
                 * field (atleast on my Panther G5). Not sure why. */
@@ -902,8 +904,9 @@ static inline u16 ether1394_parse_encap(struct sk_buff *skb,
 
                maxpayload = min(eth1394_speedto_maxpayload[sspd], (u16)(1 << (max_rec + 1)));
 
+               guid = get_unaligned(&arp1394->s_uniq_id);
                node = eth1394_find_node_guid(&priv->ip_node_list,
-                                             be64_to_cpu(arp1394->s_uniq_id));
+                                             be64_to_cpu(guid));
                if (!node) {
                        return 0;
                }
@@ -931,10 +934,9 @@ static inline u16 ether1394_parse_encap(struct sk_buff *skb,
                arp_ptr += arp->ar_pln;         /* skip over sender IP addr */
 
                if (arp->ar_op == htons(ARPOP_REQUEST))
-                       /* just set ARP req target unique ID to 0 */
-                       *((u64*)arp_ptr) = 0;
+                       memset(arp_ptr, 0, sizeof(u64));
                else
-                       *((u64*)arp_ptr) = *((u64*)dev->dev_addr);
+                       memcpy(arp_ptr, dev->dev_addr, sizeof(u64));
        }
 
        /* Now add the ethernet header. */
@@ -1666,7 +1668,7 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
        if (memcmp(eth->h_dest, dev->broadcast, ETH1394_ALEN) == 0 ||
            proto == htons(ETH_P_ARP) ||
            (proto == htons(ETH_P_IP) &&
-            IN_MULTICAST(ntohl(skb->nh.iph->daddr)))) {
+            IN_MULTICAST(ntohl(ip_hdr(skb)->daddr)))) {
                tx_type = ETH1394_GASP;
                dest_node = LOCAL_BUS | ALL_NODES;
                max_payload = priv->bc_maxpayload - ETHER1394_GASP_OVERHEAD;
@@ -1675,8 +1677,10 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
                if (max_payload < dg_size + hdr_type_len[ETH1394_HDR_LF_UF])
                        priv->bc_dgl++;
        } else {
+               __be64 guid = get_unaligned((u64 *)eth->h_dest);
+
                node = eth1394_find_node_guid(&priv->ip_node_list,
-                                             be64_to_cpu(*(u64*)eth->h_dest));
+                                             be64_to_cpu(guid));
                if (!node) {
                        ret = -EAGAIN;
                        goto fail;