Re: [PATCH 6/9] Resending NetXen 1G/10G NIC driver patch
diff -u linux-2.6.16.18/drivers/net/netxen/netxen_nic_init.c linux-2.6.16.18/drivers/net/netxen/netxen_nic_init.c --- linux-2.6.16.18/drivers/net/netxen/netxen_nic_init.c 2006-05-25 02:43:22.0 -0700 +++ linux-2.6.16.18/drivers/net/netxen/netxen_nic_init.c 2006-05-26 04:05:34.0 -0700 @@ -200,8 +200,8 @@ } /* - * netxen_decode_crb_addr(0 - utility to translate from internal Phantom - * CRB address to external PCI CRB address. + * netxen_decode_crb_addr(0 - utility to translate from internal Phantom CRB address + * to external PCI CRB address. */ unsigned long netxen_decode_crb_addr(unsigned long addr) { @@ -869,7 +869,6 @@ for (p = 0; p < adapter->ahw.max_ports; p++) { nport = adapter->port[p]; if (netif_queue_stopped(nport->netdev) - && (nport->state == NETXEN_PORT_UP) && (nport->flags & NETXEN_NETDEV_STATUS)) { netif_wake_queue(nport->netdev); nport->flags &= ~NETXEN_NETDEV_STATUS; @@ -920,7 +919,7 @@ } count++;/* now there should be no failure */ pdesc = &rcv_desc->desc_head[producer]; - skb_reserve(skb, IP_ALIGNMENT_BYTES); + skb_reserve(skb, NET_IP_ALIGN); /* * This will be setup when we receive the * buffer after it has been filled On Thu, 2006-05-25 at 09:47 -0700, Stephen Hemminger wrote: > Why is this necessary. Additional private API seems like leftover > debug code. > > > +int > > +netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data, > > + struct netxen_port *port) > > +{ > > + struct netxen_nic_ioctl_data data; > > + struct netxen_nic_ioctl_data *up_data; > > + int retval = 0; > > + struct netxen_statistics netxen_stats; > > + > > + up_data = (void *)u_data; > > + > > + DPRINTK(INFO, "doing ioctl for %p\n", adapter); > > + if (copy_from_user(&data, up_data, sizeof(data))) { > > + /* evil user tried to crash the kernel */ > > + DPRINTK(ERR, "bad copy from userland: %d\n", (int)sizeof(data)); > > + retval = -EFAULT; > > + goto error_out; > > + } > > + > > + /* Shouldn't access beyond legal limits of "char u[64];" member */ > > + if (!data.ptr && (data.size > sizeof(data.u))) { > > + /* evil user tried to crash the kernel */ > > + DPRINTK(ERR, "bad size: %d\n", data.size); > > + retval = -EFAULT; > > + goto error_out; > > + } > > + > > + switch (data.cmd) { > > + case netxen_nic_cmd_pci_read: > > + if ((retval = netxen_nic_hw_read_wx(adapter, data.off, > > + &(data.u), data.size))) > > + goto error_out; > > + if (copy_to_user((void *)&(up_data->u), &(data.u), data.size)) { > > + DPRINTK(ERR, "bad copy to userland: %d\n", > > + (int)sizeof(data)); > > + retval = -EFAULT; > > + goto error_out; > > + } > > + data.rv = 0; > > + break; > > + > > Can't you access the same registers area with ethtool. > > > > + case netxen_nic_cmd_pci_write: > > + data.rv = netxen_nic_hw_write_wx(adapter, data.off, &(data.u), > > +data.size); > > + break; > > + > > + case netxen_nic_cmd_pci_mem_read: > > + DPRINTK(INFO, "doing %s for %p\n", > > + "netxen_nic_cmd_pci_mm_rd", adapter); > > + netxen_nic_pci_mem_read(adapter, data.off, &(data.u), > > + data.size); > > + if (copy_to_user((void *)&(up_data->u), &(data.u), data.size)) { > > + DPRINTK(ERR, "bad copy to userland: %d\n", > > + (int)sizeof(data)); > > + retval = -EFAULT; > > + goto error_out; > > + } > > + data.rv = 0; > > + DPRINTK(INFO, "read %lx\n", (unsigned long)data.u); > > + break; > > PCI memory is accessible directly through sysfs for diagnostic tools. > > > > + case netxen_nic_cmd_pci_mem_write: > > + netxen_nic_pci_mem_write(adapter, data.off, &(data.u), > > +data.size); > > + data.rv = 0;/* write always succeeds */ > > + break; > > + > > + case netxen_nic_cmd_pci_config_read: > > + switch (data.size) { > > + case 1: > > + data.rv = pci_read_config_byte(adapter->ahw.pdev, > > + data.off, > > + (char *)&(data.u)); > > + break; > > + case 2: > > + data.rv = pci_read_config_word(ad
Re: [PATCH 6/9] Resending NetXen 1G/10G NIC driver patch
Why is this necessary. Additional private API seems like leftover debug code. > +int > +netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data, > + struct netxen_port *port) > +{ > + struct netxen_nic_ioctl_data data; > + struct netxen_nic_ioctl_data *up_data; > + int retval = 0; > + struct netxen_statistics netxen_stats; > + > + up_data = (void *)u_data; > + > + DPRINTK(INFO, "doing ioctl for %p\n", adapter); > + if (copy_from_user(&data, up_data, sizeof(data))) { > + /* evil user tried to crash the kernel */ > + DPRINTK(ERR, "bad copy from userland: %d\n", (int)sizeof(data)); > + retval = -EFAULT; > + goto error_out; > + } > + > + /* Shouldn't access beyond legal limits of "char u[64];" member */ > + if (!data.ptr && (data.size > sizeof(data.u))) { > + /* evil user tried to crash the kernel */ > + DPRINTK(ERR, "bad size: %d\n", data.size); > + retval = -EFAULT; > + goto error_out; > + } > + > + switch (data.cmd) { > + case netxen_nic_cmd_pci_read: > + if ((retval = netxen_nic_hw_read_wx(adapter, data.off, > + &(data.u), data.size))) > + goto error_out; > + if (copy_to_user((void *)&(up_data->u), &(data.u), data.size)) { > + DPRINTK(ERR, "bad copy to userland: %d\n", > + (int)sizeof(data)); > + retval = -EFAULT; > + goto error_out; > + } > + data.rv = 0; > + break; > + Can't you access the same registers area with ethtool. > + case netxen_nic_cmd_pci_write: > + data.rv = netxen_nic_hw_write_wx(adapter, data.off, &(data.u), > + data.size); > + break; > + > + case netxen_nic_cmd_pci_mem_read: > + DPRINTK(INFO, "doing %s for %p\n", > + "netxen_nic_cmd_pci_mm_rd", adapter); > + netxen_nic_pci_mem_read(adapter, data.off, &(data.u), > + data.size); > + if (copy_to_user((void *)&(up_data->u), &(data.u), data.size)) { > + DPRINTK(ERR, "bad copy to userland: %d\n", > + (int)sizeof(data)); > + retval = -EFAULT; > + goto error_out; > + } > + data.rv = 0; > + DPRINTK(INFO, "read %lx\n", (unsigned long)data.u); > + break; PCI memory is accessible directly through sysfs for diagnostic tools. > + case netxen_nic_cmd_pci_mem_write: > + netxen_nic_pci_mem_write(adapter, data.off, &(data.u), > + data.size); > + data.rv = 0;/* write always succeeds */ > + break; > + > + case netxen_nic_cmd_pci_config_read: > + switch (data.size) { > + case 1: > + data.rv = pci_read_config_byte(adapter->ahw.pdev, > +data.off, > +(char *)&(data.u)); > + break; > + case 2: > + data.rv = pci_read_config_word(adapter->ahw.pdev, > +data.off, > +(short *)&(data.u)); > + break; > + case 4: > + data.rv = pci_read_config_dword(adapter->ahw.pdev, > + data.off, > + (u32 *) & (data.u)); > + break; > + } > + if (copy_to_user((void *)&(up_data->u), &(data.u), data.size)) { > + DPRINTK(ERR, "bad copy to userland: %d\n", > + (int)sizeof(data)); > + retval = -EFAULT; > + goto error_out; > + } > + break; > + > + case netxen_nic_cmd_pci_config_write: > + switch (data.size) { > + case 1: > + data.rv = pci_write_config_byte(adapter->ahw.pdev, > + data.off, > + *(char *)&(data.u)); > + break; > + case 2: > + data.rv = pci_write_config_word(adapter->ahw.pdev, > + data.off, > + *(short *)&(data.u)); > + break; > + case 4: > + data.rv = pci_write_config_dword(adapter->ahw.pdev, > + d
[PATCH 6/9] Resending NetXen 1G/10G NIC driver patch
diff -Naru linux-2.6.16.18.orig/drivers/net/netxen/netxen_nic_init.c linux-2.6.16.18/drivers/net/netxen/netxen_nic_init.c --- linux-2.6.16.18.orig/drivers/net/netxen/netxen_nic_init.c 1969-12-31 16:00:00.0 -0800 +++ linux-2.6.16.18/drivers/net/netxen/netxen_nic_init.c2006-05-25 02:43:22.0 -0700 @@ -0,0 +1,1219 @@ +/* + * 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 initialize the Phantom Hardware + * + */ + +#include +#include +#include "netxen_nic.h" +#include "netxen_nic_hw.h" +#include "netxen_nic_ioctl.h" +#include "netxen_nic_phan_reg.h" + +struct crb_addr_pair { + long addr; + long data; +}; + +#define NETXEN_MAX_CRB_XFORM 60 +static unsigned int crb_addr_xform[NETXEN_MAX_CRB_XFORM]; +#define NETXEN_ADDR_ERROR ((unsigned long ) 0x ) + +#define crb_addr_transform(name) \ +crb_addr_xform[NETXEN_HW_PX_MAP_CRB_##name] = \ +NETXEN_HW_CRB_HUB_AGT_ADR_##name << 20 + +#define NETXEN_FLASH_BASE (BOOTLD_START) +#define NETXEN_PHANTOM_MEM_BASE(NETXEN_FLASH_BASE) + +static void crb_addr_transform_setup(void) +{ + crb_addr_transform(XDMA); + crb_addr_transform(TIMR); + crb_addr_transform(SRE); + crb_addr_transform(SQN3); + crb_addr_transform(SQN2); + crb_addr_transform(SQN1); + crb_addr_transform(SQN0); + crb_addr_transform(SQS3); + crb_addr_transform(SQS2); + crb_addr_transform(SQS1); + crb_addr_transform(SQS0); + crb_addr_transform(RPMX7); + crb_addr_transform(RPMX6); + crb_addr_transform(RPMX5); + crb_addr_transform(RPMX4); + crb_addr_transform(RPMX3); + crb_addr_transform(RPMX2); + crb_addr_transform(RPMX1); + crb_addr_transform(RPMX0); + crb_addr_transform(ROMUSB); + crb_addr_transform(SN); + crb_addr_transform(QMN); + crb_addr_transform(QMS); + crb_addr_transform(PGNI); + crb_addr_transform(PGND); + crb_addr_transform(PGN3); + crb_addr_transform(PGN2); + crb_addr_transform(PGN1); + crb_addr_transform(PGN0); + crb_addr_transform(PGSI); + crb_addr_transform(PGSD); + crb_addr_transform(PGS3); + crb_addr_transform(PGS2); + crb_addr_transform(PGS1); + crb_addr_transform(PGS0); + crb_addr_transform(PS); + crb_addr_transform(PH); + crb_addr_transform(NIU); + crb_addr_transform(I2Q); + crb_addr_transform(EG); + crb_addr_transform(MN); + crb_addr_transform(MS); + crb_addr_transform(CAS2); + crb_addr_transform(CAS1); + crb_addr_transform(CAS0); + crb_addr_transform(CAM); + crb_addr_transform(C2C1); + crb_addr_transform(C2C0); +} + +int init_firmware(struct netxen_adapter *adapter) +{ + u32 state = 0, loops = 0, err = 0; + + /* Window 1 call */ + read_lock(&adapter->adapter_lock); + state = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); + read_unlock(&adapter->adapter_lock); + + while (state != PHAN_INITIALIZE_COMPLETE && loops < 20) { + udelay(100); + /* Window 1 call */ + read_lock(&adapter->adapter_lock); + state = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); + read_unlock(&adapter->adapter_lock); + + loops++; + } + if (loops >= 20) { + printk(KERN_ERR "Cmd Peg initialization not complete:%x.\n", + state); + err = -EIO; + return err; + } + /* Window 1 call */ + read_lock(&adapter->adapter_lock); + writel(PHAN_INITIALIZE_ACK, + NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); + read_unlock(&adapter->adapter_lock); + + return err; +} + +void initialize_adapter_sw(struct netxen_adapter *adapter) +{ +