[PATCH] defxx: Big-endian hosts support
[safe/jmp/linux-2.6] / drivers / net / iseries_veth.c
index 3d56cf5..2284e2c 100644 (file)
@@ -56,9 +56,7 @@
  * number of packets outstanding to a remote partition at a time.
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
-#include <linux/version.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
 #include <linux/mm.h>
 #include <linux/ethtool.h>
-#include <asm/iSeries/mf.h>
-#include <asm/iSeries/iSeries_pci.h>
+#include <linux/if_ether.h>
+
+#include <asm/abs_addr.h>
+#include <asm/iseries/mf.h>
 #include <asm/uaccess.h>
 
-#include <asm/iSeries/HvLpConfig.h>
-#include <asm/iSeries/HvTypes.h>
-#include <asm/iSeries/HvLpEvent.h>
+#include <asm/iseries/hv_lp_config.h>
+#include <asm/iseries/hv_types.h>
+#include <asm/iseries/hv_lp_event.h>
 #include <asm/iommu.h>
 #include <asm/vio.h>
 
@@ -586,13 +586,13 @@ static void veth_handle_int(struct veth_lpevent *event)
        };
 }
 
-static void veth_handle_event(struct HvLpEvent *event, struct pt_regs *regs)
+static void veth_handle_event(struct HvLpEvent *event)
 {
        struct veth_lpevent *veth_event = (struct veth_lpevent *)event;
 
-       if (event->xFlags.xFunction == HvLpEvent_Function_Ack)
+       if (hvlpevent_is_ack(event))
                veth_handle_ack(veth_event);
-       else if (event->xFlags.xFunction == HvLpEvent_Function_Int)
+       else
                veth_handle_int(veth_event);
 }
 
@@ -1029,17 +1029,28 @@ static u32 veth_get_link(struct net_device *dev)
        return 1;
 }
 
-static struct ethtool_ops ops = {
+static const struct ethtool_ops ops = {
        .get_drvinfo = veth_get_drvinfo,
        .get_settings = veth_get_settings,
        .get_link = veth_get_link,
 };
 
-static struct net_device * __init veth_probe_one(int vlan, struct device *vdev)
+static struct net_device * __init veth_probe_one(int vlan,
+               struct vio_dev *vio_dev)
 {
        struct net_device *dev;
        struct veth_port *port;
+       struct device *vdev = &vio_dev->dev;
        int i, rc;
+       const unsigned char *mac_addr;
+
+       mac_addr = vio_get_attribute(vio_dev, "local-mac-address", NULL);
+       if (mac_addr == NULL)
+               mac_addr = vio_get_attribute(vio_dev, "mac-address", NULL);
+       if (mac_addr == NULL) {
+               veth_error("Unable to fetch MAC address from device tree.\n");
+               return NULL;
+       }
 
        dev = alloc_etherdev(sizeof (struct veth_port));
        if (! dev) {
@@ -1064,16 +1075,11 @@ static struct net_device * __init veth_probe_one(int vlan, struct device *vdev)
        }
        port->dev = vdev;
 
-       dev->dev_addr[0] = 0x02;
-       dev->dev_addr[1] = 0x01;
-       dev->dev_addr[2] = 0xff;
-       dev->dev_addr[3] = vlan;
-       dev->dev_addr[4] = 0xff;
-       dev->dev_addr[5] = this_lp;
+       memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
 
        dev->mtu = VETH_MAX_MTU;
 
-       memcpy(&port->mac_addr, dev->dev_addr, 6);
+       memcpy(&port->mac_addr, mac_addr, ETH_ALEN);
 
        dev->open = veth_open;
        dev->hard_start_xmit = veth_start_xmit;
@@ -1397,13 +1403,13 @@ static inline void veth_build_dma_list(struct dma_chunk *list,
         * it just at the granularity of iSeries real->absolute
         * mapping?  Indeed, given the way the allocator works, can we
         * count on them being absolutely contiguous? */
-       list[0].addr = ISERIES_HV_ADDR(p);
+       list[0].addr = iseries_hv_addr(p);
        list[0].size = min(length,
                           PAGE_SIZE - ((unsigned long)p & ~PAGE_MASK));
 
        done = list[0].size;
        while (done < length) {
-               list[i].addr = ISERIES_HV_ADDR(p + done);
+               list[i].addr = iseries_hv_addr(p + done);
                list[i].size = min(length-done, PAGE_SIZE);
                done += list[i].size;
                i++;
@@ -1496,8 +1502,8 @@ static void veth_receive(struct veth_lpar_connection *cnx,
                                            cnx->dst_inst,
                                            HvLpDma_AddressType_RealAddress,
                                            HvLpDma_AddressType_TceIndex,
-                                           ISERIES_HV_ADDR(&local_list),
-                                           ISERIES_HV_ADDR(&remote_list),
+                                           iseries_hv_addr(&local_list),
+                                           iseries_hv_addr(&remote_list),
                                            length);
                if (rc != HvLpDma_Rc_Good) {
                        dev_kfree_skb_irq(skb);
@@ -1608,7 +1614,7 @@ static int veth_probe(struct vio_dev *vdev, const struct vio_device_id *id)
        struct net_device *dev;
        struct veth_port *port;
 
-       dev = veth_probe_one(i, &vdev->dev);
+       dev = veth_probe_one(i, vdev);
        if (dev == NULL) {
                veth_remove(vdev);
                return 1;
@@ -1641,16 +1647,19 @@ static int veth_probe(struct vio_dev *vdev, const struct vio_device_id *id)
  * support.
  */
 static struct vio_device_id veth_device_table[] __devinitdata = {
-       { "vlan", "" },
+       { "network", "IBM,iSeries-l-lan" },
        { "", "" }
 };
 MODULE_DEVICE_TABLE(vio, veth_device_table);
 
 static struct vio_driver veth_driver = {
-       .name = DRV_NAME,
        .id_table = veth_device_table,
        .probe = veth_probe,
-       .remove = veth_remove
+       .remove = veth_remove,
+       .driver = {
+               .name = DRV_NAME,
+               .owner = THIS_MODULE,
+       }
 };
 
 /*