[PATCH 2.6.17 2/9] NetXen: Hardware access routines

2006-08-31 Thread Amit S. Kale

diff -Narup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/drivers/net/netxen/netxen_nic_hw.c 
linux-2.6.17/drivers/net/netxen/netxen_nic_hw.c
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_hw.c1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_hw.c 2006-08-31 
06:17:22.0 -0700
@@ -0,0 +1,1102 @@
+/*
+ * Copyright (C) 2003 - 2006 NetXen, Inc.
+ * All rights reserved.
+ * 
+ * This program is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but

+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License

+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * The full GNU General Public License is included in this distribution

+ * in the file called LICENSE.
+ * 
+ * Contact Information:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * Source file for NIC routines to access the Phantom hardware
+ *
+ */
+
+#include netxen_nic.h
+#include netxen_nic_hw.h
+#include netxen_nic_phan_reg.h
+
+/*  PCI Windowing for DDR regions.  */
+
+#define ADDR_IN_RANGE(addr, low, high) \
+   (((addr) = (high))  ((addr) = (low)))
+
+#define NETXEN_FLASH_BASE  (BOOTLD_START)
+#define NETXEN_PHANTOM_MEM_BASE(NETXEN_FLASH_BASE)
+#define NETXEN_MAX_MTU 8000
+#define NETXEN_MTU_MASK0x
+#define NETXEN_WINDOW_ONE 0x200/* CRB Window: bit 25 of CRB address */
+
+unsigned long netxen_nic_pci_set_window(void __iomem * pci_base,
+   unsigned long long addr);
+void netxen_free_hw_resources(struct netxen_adapter *adapter);
+
+int netxen_nic_set_mac(struct net_device *netdev, void *p)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+   struct sockaddr *addr = p;
+
+   if (netif_running(netdev))
+   return -EBUSY;
+
+   if (!is_valid_ether_addr(addr-sa_data))
+   return -EADDRNOTAVAIL;
+
+   DPRINTK(INFO, valid ether addr\n);
+   memcpy(netdev-dev_addr, addr-sa_data, netdev-addr_len);
+
+   netxen_nic_macaddr_set(port, addr-sa_data);
+
+   return 0;
+}
+
+/**
+ * netxen_nic_set_multi - Multicast
+ **/
+void netxen_nic_set_multi(struct net_device *netdev)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+   struct dev_mc_list *mc_ptr;
+
+   mc_ptr = netdev-mc_list;
+   if (netdev-flags  IFF_PROMISC)
+   netxen_nic_set_promisc_mode(port);
+   else
+   netxen_nic_unset_promisc_mode(port);
+}
+
+/*
+ * netxen_nic_change_mtu - Change the Maximum Transfer Unit
+ * @returns 0 on success, negative on failure
+ */
+int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+
+   if (new_mtu  NETXEN_MTU_MASK)
+   return -EINVAL;
+
+   if (new_mtu  NETXEN_MAX_MTU) {
+   printk(KERN_ERR
+  %s: %s MTU  NETXEN_MAX_MTU is not supported\n,
+  netxen_nic_driver_name, netdev-name);
+   return -EINVAL;
+   }
+
+   netxen_nic_set_mtu(port, new_mtu);
+   netdev-mtu = new_mtu;
+
+   return 0;
+}
+
+/*
+ * check if the firmware has been downloaded and ready to run  and
+ * setup the address for the descriptors in the adapter
+ */
+int netxen_nic_hw_resources(struct netxen_adapter *adapter)
+{
+   struct netxen_hardware_context *hw = adapter-ahw;
+   int i;
+   u32 state = 0;
+   void *addr;
+   int loops = 0, err = 0;
+   int ctx, ring;
+   u32 card_cmdring = 0;
+   struct netxen_rcv_desc_crb *rcv_desc_crb = NULL;
+   struct netxen_recv_context *recv_ctx;
+   struct netxen_rcv_desc_ctx *rcv_desc;
+   struct cmd_desc_type0_t *pcmd;
+
+   DPRINTK(INFO, pci_base: %lx\n, adapter-ahw.pci_base);
+   DPRINTK(INFO, crb_base: %lx %lx, NETXEN_PCI_CRBSPACE,
+   adapter-ahw.pci_base + NETXEN_PCI_CRBSPACE);
+   DPRINTK(INFO, cam base: %lx %lx, NETXEN_CRB_CAM,
+   adapter-ahw.pci_base + NETXEN_CRB_CAM);
+   DPRINTK(INFO, cam RAM: %lx %lx, NETXEN_CAM_RAM_BASE,
+   adapter-ahw.pci_base + NETXEN_CAM_RAM_BASE);
+   DPRINTK(INFO, NIC base:%lx %lx\n, NIC_CRB_BASE_PORT1,
+   adapter-ahw.pci_base + NIC_CRB_BASE_PORT1);
+
+   /* Window 1 call */
+   card_cmdring = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_CMDRING));

Re: [PATCH 2.6.17 2/9] NetXen: Hardware access routines

2006-08-28 Thread Amit S. Kale
On Monday 21 August 2006 19:33, Stephen Hemminger wrote:
 On Mon, 21 Aug 2006 13:57:23 +0530

 Amit S. Kale [EMAIL PROTECTED] wrote:
  We can certainly create a table for all error messages. It'll hurt
  readability of code in many of the other places where printks are used to
  indicate some hardware error.
  -Amit

 My suggestion was intended as an way to handle multiple driver versions
 all using the same firmware or vice versa. By locking the firmware and
 driver version together you might make maintenance more difficult.

Ah, I had missed that completely in your first email. Thanks for your 
suggestion.

The NetXen firmware will most probably keep changing. It's hardware is 
flexible enough, so the firmware changes will possibly be varied in nature. 
Thinking about this further, it seems we should coalesce firmware dependent 
code into a few isolated functions. While this may be difficult, we should do 
it anyway. Hopefully future changes will not cause these efforts to go waste.
-Amit

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.17 2/9] NetXen: Hardware access routines

2006-08-25 Thread Sanjeev Jorapur

On Mon, 2006-08-21 at 07:03 -0700, Stephen Hemminger wrote:
 On Mon, 21 Aug 2006 13:57:23 +0530
 Amit S. Kale [EMAIL PROTECTED] wrote:
 
  We can certainly create a table for all error messages. It'll hurt 
  readability 
  of code in many of the other places where printks are used to indicate some 
  hardware error.
  -Amit
 
 My suggestion was intended as an way to handle multiple driver versions
 all using the same firmware or vice versa. By locking the firmware and
 driver version together you might make maintenance more difficult.

We misunderstood your earlier comment. The compatible driver  firmware
images have the same major  minor version numbers. Only the sub-version
numbers may be different. This gives us more flexibility in releasing
driver  firmware fixes.

Sanjeev.


-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.17 2/9] NetXen: Hardware access routines

2006-08-21 Thread Amit S. Kale
We can certainly create a table for all error messages. It'll hurt readability 
of code in many of the other places where printks are used to indicate some 
hardware error.
-Amit

On Friday 18 August 2006 20:46, Stephen Hemminger wrote:
  +   if (fw_major != _NETXEN_NIC_LINUX_MAJOR) {
  +   printk(KERN_ERR The mismatch in driver version and firmware 
  +   version major number\n
  +   Driver version major number = %d \t
  +   Firmware version major number = %d \n,
  +   _NETXEN_NIC_LINUX_MAJOR, fw_major);
  +   adapter-driver_mismatch = 1;
  +   }
  +   if (fw_minor != _NETXEN_NIC_LINUX_MINOR) {
  +   printk(KERN_ERR The mismatch in driver version and firmware 
  +   version minor number\n
  +   Driver version minor number = %d \t
  +   Firmware version minor number = %d \n,
  +   _NETXEN_NIC_LINUX_MINOR, fw_minor);
  +   adapter-driver_mismatch = 1;
  +   }

 You might want a table for this?
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.17 2/9] NetXen: Hardware access routines (name prefixed)

2006-08-21 Thread Pradeep Dalvi


diff -u linux-2.6.17/drivers/net/netxen/netxen_nic_hw.c 
linux-2.6.17/drivers/net/netxen/netxen_nic_hw.c
--- linux-2.6.17/drivers/net/netxen/netxen_nic_hw.c 2006-08-17 
07:12:34.0 -0700
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_hw.c 2006-08-21 
02:20:00.0 -0700
@@ -317,9 +317,9 @@
adapter-stats.xmitcsummed++;
 }

-int is_flash_supported(struct netxen_adapter *adapter)
+int netxen_is_flash_supported(struct netxen_adapter *adapter)
 {
-   int locs[] = { 0, 0x4, 0x100, 0x4000, 0x4128 };
+   const int locs[] = { 0, 0x4, 0x100, 0x4000, 0x4128 };
int addr, val01, val02, i, j;

/* if the flash size less than 4Mb, make huge war cry and die */
@@ -364,7 +364,7 @@
return 0;
 }

-int get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[])
+int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[])
 {
u32 *pmac = (u32 *)  mac[0];

@@ -430,7 +430,7 @@
adapter-curr_window = wndw;
 }

-void load_firmware(struct netxen_adapter *adapter)
+void netxen_load_firmware(struct netxen_adapter *adapter)
 {
int i;
long data, size = 0;



On Fri, 18 Aug 2006, Stephen Hemminger wrote:



Way to many DPRINTK()'s


+
+int is_flash_supported(struct netxen_adapter *adapter)


needs to be static or prefixed.


+{
+   int locs[] = { 0, 0x4, 0x100, 0x4000, 0x4128 };


use const


+   int addr, val01, val02, i, j;
+
+   /* if the flash size less than 4Mb, make huge war cry and die */
+   for (j = 1; j  4; j++) {
+   addr = j * 0x10;
+   for (i = 0; i  (sizeof(locs) / sizeof(locs[0])); i++) {
+   if (netxen_rom_fast_read(adapter, locs[i], val01) == 0
+netxen_rom_fast_read(adapter, (addr + locs[i]),
+   val02) == 0) {
+   if (val01 == val02)
+   return -1;
+   } else
+   return -1;
+   }
+   }
+
+   return 0;
+}
+
+static int netxen_get_flash_block(struct netxen_adapter *adapter, int base,
+ int size, u32 * buf)
+{
+   int i, addr;
+   u32 *ptr32;
+
+   addr = base;
+   ptr32 = buf;
+   for (i = 0; i  size / sizeof(u32); i++) {
+   if (netxen_rom_fast_read(adapter, addr, ptr32) == -1)
+   return -1;
+   ptr32++;
+   addr += sizeof(u32);
+   }
+   if ((char *)buf + size  (char *)ptr32) {
+   u32 local;
+
+   if (netxen_rom_fast_read(adapter, addr, local) == -1)
+   return -1;
+   memcpy(ptr32, local, (char *)buf + size - (char *)ptr32);
+   }
+
+   return 0;
+}
+
+int get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[])


static int get_flash_mac_addr()..
+

+void load_firmware(struct netxen_adapter *adapter)


also must be static


+{
+   int i;
+   long data, size = 0;
+   long flashaddr = NETXEN_FLASH_BASE, memaddr = NETXEN_PHANTOM_MEM_BASE;
+   u64 off;
+   ptrdiff_t addr;
+
+   size = (16 * 1024) / 4;
+   writel(1, NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_CAS_RST));
+
+   for (i = 0; i  size; i++) {
+   if (netxen_rom_fast_read(adapter, flashaddr, (int *)data) != 
0) {
+   DPRINTK(ERR,
+   Error in netxen_rom_fast_read(). Will skip
+   loading flash image\n);
+   return;
+   }
+   off = netxen_nic_pci_set_window(adapter-ahw.pci_base, memaddr);
+   addr = (ptrdiff_t) (adapter-ahw.pci_base + off);
+   writel(data, (void __iomem *)addr);
+   flashaddr += 4;
+   memaddr += 4;
+   }
+   udelay(100);
+   /* make sure Casper is powered on */
+   writel(0x3fff,
+  NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_CHIP_CLK_CTRL));
+   writel(0, NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_CAS_RST));
+
+   udelay(1);
+}
+
+int
+netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data,
+  int len)
+{
+   void __iomem * addr;
+
+   if (ADDR_IN_WINDOW1(off)) {
+   addr = NETXEN_CRB_NORMALIZE(adapter, off);
+   } else {/* Window 0 */
+   addr = (void *)(ptrdiff_t) (adapter-ahw.pci_base + off);
+   netxen_nic_pci_change_crbwindow(adapter, 0);
+   }
+
+   DPRINTK(INFO, writing to base %lx offset %llx addr %p
+data %llx len %d\n,
+   adapter-ahw.pci_base, off, addr,
+   *(unsigned long long *)data, len);
+   switch (len) {
+   case 1:
+   writeb(*(u8 *) data, addr);
+   break;
+   case 2:
+   writew(*(u16 *) data, addr);
+

Re: [PATCH 2.6.17 2/9] NetXen: Hardware access routines

2006-08-21 Thread Stephen Hemminger
On Mon, 21 Aug 2006 13:57:23 +0530
Amit S. Kale [EMAIL PROTECTED] wrote:

 We can certainly create a table for all error messages. It'll hurt 
 readability 
 of code in many of the other places where printks are used to indicate some 
 hardware error.
 -Amit

My suggestion was intended as an way to handle multiple driver versions
all using the same firmware or vice versa. By locking the firmware and
driver version together you might make maintenance more difficult.
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2.6.17 2/9] NetXen: Hardware access routines

2006-08-18 Thread Amit S. Kale

diff -Nrup -X linux-2.6.17.orig/Documentation/dontdiff 
linux-2.6.17.orig/drivers/net/netxen/netxen_nic_hw.c 
linux-2.6.17/drivers/net/netxen/netxen_nic_hw.c
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_hw.c1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_hw.c 2006-08-17 
07:12:34.0 -0700
@@ -0,0 +1,1097 @@
+/*
+ * Copyright (C) 2003 - 2006 NetXen, Inc.
+ * All rights reserved.
+ * 
+ * This program is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but

+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License

+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * The full GNU General Public License is included in this distribution

+ * in the file called LICENSE.
+ * 
+ * Contact Information:

+ *[EMAIL PROTECTED]
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * Source file for NIC routines to access the Phantom hardware
+ *
+ */
+
+#include netxen_nic.h
+#include netxen_nic_hw.h
+#include netxen_nic_phan_reg.h
+
+/*  PCI Windowing for DDR regions.  */
+
+#define ADDR_IN_RANGE(addr, low, high) \
+   (((addr) = (high))  ((addr) = (low)))
+
+#define NETXEN_FLASH_BASE  (BOOTLD_START)
+#define NETXEN_PHANTOM_MEM_BASE(NETXEN_FLASH_BASE)
+#define NETXEN_MAX_MTU 8000
+#define NETXEN_MTU_MASK0x
+#define NETXEN_WINDOW_ONE 0x200/* CRB Window: bit 25 of CRB address */
+
+unsigned long netxen_nic_pci_set_window(void __iomem * pci_base,
+  unsigned long long addr);
+void netxen_free_hw_resources(struct netxen_adapter *adapter);
+
+int netxen_nic_set_mac(struct net_device *netdev, void *p)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+   struct sockaddr *addr = p;
+
+   if (netif_running(netdev))
+   return -EBUSY;
+
+   if (!is_valid_ether_addr(addr-sa_data))
+   return -EADDRNOTAVAIL;
+
+   DPRINTK(INFO, valid ether addr\n);
+   memcpy(netdev-dev_addr, addr-sa_data, netdev-addr_len);
+
+   netxen_nic_macaddr_set(port, addr-sa_data);
+
+   return 0;
+}
+
+/**
+ * netxen_nic_set_multi - Multicast
+ **/
+void netxen_nic_set_multi(struct net_device *netdev)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+   struct dev_mc_list *mc_ptr;
+
+   mc_ptr = netdev-mc_list;
+   if (netdev-flags  IFF_PROMISC)
+   netxen_nic_set_promisc_mode(port);
+   else
+   netxen_nic_unset_promisc_mode(port);
+}
+
+/*
+ * netxen_nic_change_mtu - Change the Maximum Transfer Unit
+ * @returns 0 on success, negative on failure
+ */
+int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu)
+{
+   struct netxen_port *port = netdev_priv(netdev);
+
+   if (new_mtu  NETXEN_MTU_MASK)
+   return -EINVAL;
+
+   if (new_mtu  NETXEN_MAX_MTU) {
+   printk(KERN_ERR %s: %s MTU  NETXEN_MAX_MTU is not 
supported\n,
+  netxen_nic_driver_name, netdev-name);
+   return -EINVAL;
+   }
+
+   netxen_nic_set_mtu(port, new_mtu);
+   netdev-mtu = new_mtu;
+
+   return 0;
+}
+/*
+ * check if the firmware has been downloaded and ready to run  and
+ * setup the address for the descriptors in the adapter
+ */
+int netxen_nic_hw_resources(struct netxen_adapter *adapter)
+{
+   struct netxen_hardware_context *hw = adapter-ahw;
+   int i;
+   u32 state = 0;
+   void *addr;
+   int loops = 0, err = 0;
+   int ctx, ring;
+   u32 card_cmdring = 0;
+   struct netxen_rcv_desc_crb *rcv_desc_crb = NULL;
+   struct netxen_recv_context *recv_ctx;
+   struct netxen_rcv_desc_ctx *rcv_desc;
+   struct cmd_desc_type0_t *pcmd;
+
+   DPRINTK(INFO, pci_base: %lx\n, adapter-ahw.pci_base);
+   DPRINTK(INFO, crb_base: %lx %lx, NETXEN_PCI_CRBSPACE,
+   adapter-ahw.pci_base + NETXEN_PCI_CRBSPACE);
+   DPRINTK(INFO, cam base: %lx %lx, NETXEN_CRB_CAM,
+   adapter-ahw.pci_base + NETXEN_CRB_CAM);
+   DPRINTK(INFO, cam RAM: %lx %lx, NETXEN_CAM_RAM_BASE,
+   adapter-ahw.pci_base + NETXEN_CAM_RAM_BASE);
+   DPRINTK(INFO, NIC base:%lx %lx\n, NIC_CRB_BASE_PORT1,
+   adapter-ahw.pci_base + NIC_CRB_BASE_PORT1);
+
+   /* Window 1 call */
+   card_cmdring = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_CMDRING));
+
+   

Re: [PATCH 2.6.17 2/9] NetXen: Hardware access routines

2006-08-18 Thread Stephen Hemminger

Way to many DPRINTK()'s 

 +
 +int is_flash_supported(struct netxen_adapter *adapter)

needs to be static or prefixed.

 +{
 + int locs[] = { 0, 0x4, 0x100, 0x4000, 0x4128 };

use const

 + int addr, val01, val02, i, j;
 +
 + /* if the flash size less than 4Mb, make huge war cry and die */
 + for (j = 1; j  4; j++) {
 + addr = j * 0x10;
 + for (i = 0; i  (sizeof(locs) / sizeof(locs[0])); i++) {
 + if (netxen_rom_fast_read(adapter, locs[i], val01) == 0
 +  netxen_rom_fast_read(adapter, (addr + locs[i]),
 + val02) == 0) {
 + if (val01 == val02)
 + return -1;
 + } else
 + return -1;
 + }
 + }
 +
 + return 0;
 +}
 +
 +static int netxen_get_flash_block(struct netxen_adapter *adapter, int base,
 +   int size, u32 * buf)
 +{
 + int i, addr;
 + u32 *ptr32;
 +
 + addr = base;
 + ptr32 = buf;
 + for (i = 0; i  size / sizeof(u32); i++) {
 + if (netxen_rom_fast_read(adapter, addr, ptr32) == -1)
 + return -1;
 + ptr32++;
 + addr += sizeof(u32);
 + }
 + if ((char *)buf + size  (char *)ptr32) {
 + u32 local;
 +
 + if (netxen_rom_fast_read(adapter, addr, local) == -1)
 + return -1;
 + memcpy(ptr32, local, (char *)buf + size - (char *)ptr32);
 + }
 +
 + return 0;
 +}
 +
 +int get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[])

static int get_flash_mac_addr()..
+
 +void load_firmware(struct netxen_adapter *adapter)

also must be static

 +{
 + int i;
 + long data, size = 0;
 + long flashaddr = NETXEN_FLASH_BASE, memaddr = NETXEN_PHANTOM_MEM_BASE;
 + u64 off;
 + ptrdiff_t addr;
 +
 + size = (16 * 1024) / 4;
 + writel(1, NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_CAS_RST));
 +
 + for (i = 0; i  size; i++) {
 + if (netxen_rom_fast_read(adapter, flashaddr, (int *)data) != 
 0) {
 + DPRINTK(ERR,
 + Error in netxen_rom_fast_read(). Will skip
 + loading flash image\n);
 + return;
 + }
 + off = netxen_nic_pci_set_window(adapter-ahw.pci_base, memaddr);
 + addr = (ptrdiff_t) (adapter-ahw.pci_base + off);
 + writel(data, (void __iomem *)addr);
 + flashaddr += 4;
 + memaddr += 4;
 + }
 + udelay(100);
 + /* make sure Casper is powered on */
 + writel(0x3fff,
 +NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_CHIP_CLK_CTRL));
 + writel(0, NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_CAS_RST));
 +
 + udelay(1);
 +}
 +
 +int
 +netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data,
 +int len)
 +{
 + void __iomem * addr;
 +
 + if (ADDR_IN_WINDOW1(off)) {
 + addr = NETXEN_CRB_NORMALIZE(adapter, off);
 + } else {/* Window 0 */
 + addr = (void *)(ptrdiff_t) (adapter-ahw.pci_base + off);
 + netxen_nic_pci_change_crbwindow(adapter, 0);
 + }
 +
 + DPRINTK(INFO, writing to base %lx offset %llx addr %p
 +  data %llx len %d\n,
 + adapter-ahw.pci_base, off, addr,
 + *(unsigned long long *)data, len);
 + switch (len) {
 + case 1:
 + writeb(*(u8 *) data, addr);
 + break;
 + case 2:
 + writew(*(u16 *) data, addr);
 + break;
 + case 4:
 + writel(*(u32 *) data, addr);
 + break;
 + case 8:
 + writeq(*(u64 *) data, addr);
 + break;
 + default:
 + DPRINTK(INFO,
 + writing data %lx to offset %llx, num words=%d\n,
 + *(unsigned long *)data, off, (len  3));
 +
 + NETXEN_NIC_HW_BLOCK_WRITE_64(data, addr, (len  3));
 + break;
 + }
 + if (!ADDR_IN_WINDOW1(off))
 + netxen_nic_pci_change_crbwindow(adapter, 1);
 +
 + return 0;
 +}
 +
 +int
 +netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off, void *data,
 +   int len)

If you can make this inline then the switch can be optimized.

 +{
 + void __iomem * addr;
 +
 + if (ADDR_IN_WINDOW1(off)) { /* Window 1 */
 + addr = NETXEN_CRB_NORMALIZE(adapter, off);
 + } else {/* Window 0 */
 + addr = (void *)(ptrdiff_t) (adapter-ahw.pci_base + off);
 + netxen_nic_pci_change_crbwindow(adapter, 0);
 + }
 +
 + DPRINTK(INFO, reading from base %lx offset %llx addr %p\n,
 + adapter-ahw.pci_base, off, addr);
 + switch (len) {
 + case 1:
 +