From 92104e94806f47e090e3bb40f6ae45f695351a5e Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 15 Dec 2006 07:57:08 -0800 Subject: netxen: remove private ioctl The netxen driver includes a private ioctl that provides access to functionality that is already available in other ways. The PCI layer has application access hooks (see setpci), and the statistics are available in ethtool/netstats. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/netxen/netxen_nic_hw.c | 294 ------------------------------------- 1 file changed, 294 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_hw.c') diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index 9147b6048df..5dac50c8707 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c @@ -997,297 +997,3 @@ void netxen_nic_flash_print(struct netxen_adapter *adapter) fw_major, fw_minor); } -int netxen_crb_read_val(struct netxen_adapter *adapter, unsigned long off) -{ - int data; - netxen_nic_hw_read_wx(adapter, off, &data, 4); - return data; -} - -int netxen_nic_hw_write_ioctl(struct netxen_adapter *adapter, u64 off, - void *data, int len) -{ - void *addr; - u64 offset = off; - u8 *mem_ptr = NULL; - unsigned long mem_base; - unsigned long mem_page; - - if (ADDR_IN_WINDOW1(off)) { - addr = NETXEN_CRB_NORMALIZE(adapter, off); - if (!addr) { - mem_base = pci_resource_start(adapter->ahw.pdev, 0); - offset = NETXEN_CRB_NORMAL(off); - mem_page = offset & PAGE_MASK; - if (mem_page != ((offset + len - 1) & PAGE_MASK)) - mem_ptr = - ioremap(mem_base + mem_page, PAGE_SIZE * 2); - else - mem_ptr = - ioremap(mem_base + mem_page, PAGE_SIZE); - if (mem_ptr == 0UL) { - return 1; - } - addr = mem_ptr; - addr += offset & (PAGE_SIZE - 1); - } - } else { - addr = pci_base_offset(adapter, off); - if (!addr) { - mem_base = pci_resource_start(adapter->ahw.pdev, 0); - mem_page = off & PAGE_MASK; - if (mem_page != ((off + len - 1) & PAGE_MASK)) - mem_ptr = - ioremap(mem_base + mem_page, PAGE_SIZE * 2); - else - mem_ptr = - ioremap(mem_base + mem_page, PAGE_SIZE); - if (mem_ptr == 0UL) { - return 1; - } - addr = mem_ptr; - addr += off & (PAGE_SIZE - 1); - } - netxen_nic_pci_change_crbwindow(adapter, 0); - } - 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_write64((u64 __iomem *) data, addr, - (len >> 3)); - break; - } - - if (!ADDR_IN_WINDOW1(off)) - netxen_nic_pci_change_crbwindow(adapter, 1); - if (mem_ptr) - iounmap(mem_ptr); - return 0; -} - -int netxen_nic_hw_read_ioctl(struct netxen_adapter *adapter, u64 off, - void *data, int len) -{ - void *addr; - u64 offset; - u8 *mem_ptr = NULL; - unsigned long mem_base; - unsigned long mem_page; - - if (ADDR_IN_WINDOW1(off)) { - addr = NETXEN_CRB_NORMALIZE(adapter, off); - if (!addr) { - mem_base = pci_resource_start(adapter->ahw.pdev, 0); - offset = NETXEN_CRB_NORMAL(off); - mem_page = offset & PAGE_MASK; - if (mem_page != ((offset + len - 1) & PAGE_MASK)) - mem_ptr = - ioremap(mem_base + mem_page, PAGE_SIZE * 2); - else - mem_ptr = - ioremap(mem_base + mem_page, PAGE_SIZE); - if (mem_ptr == 0UL) { - *(u8 *) data = 0; - return 1; - } - addr = mem_ptr; - addr += offset & (PAGE_SIZE - 1); - } - } else { - addr = pci_base_offset(adapter, off); - if (!addr) { - mem_base = pci_resource_start(adapter->ahw.pdev, 0); - mem_page = off & PAGE_MASK; - if (mem_page != ((off + len - 1) & PAGE_MASK)) - mem_ptr = - ioremap(mem_base + mem_page, PAGE_SIZE * 2); - else - mem_ptr = - ioremap(mem_base + mem_page, PAGE_SIZE); - if (mem_ptr == 0UL) - return 1; - addr = mem_ptr; - addr += off & (PAGE_SIZE - 1); - } - netxen_nic_pci_change_crbwindow(adapter, 0); - } - switch (len) { - case 1: - *(u8 *) data = readb(addr); - break; - case 2: - *(u16 *) data = readw(addr); - break; - case 4: - *(u32 *) data = readl(addr); - break; - case 8: - *(u64 *) data = readq(addr); - break; - default: - netxen_nic_hw_block_read64((u64 __iomem *) data, addr, - (len >> 3)); - break; - } - if (!ADDR_IN_WINDOW1(off)) - netxen_nic_pci_change_crbwindow(adapter, 1); - if (mem_ptr) - iounmap(mem_ptr); - return 0; -} - -int netxen_nic_pci_mem_write_ioctl(struct netxen_adapter *adapter, u64 off, - void *data, int size) -{ - void *addr; - int ret = 0; - u8 *mem_ptr = NULL; - unsigned long mem_base; - unsigned long mem_page; - - if (data == NULL || off > (128 * 1024 * 1024)) { - printk(KERN_ERR "%s: data: %p off:%llx\n", - netxen_nic_driver_name, data, off); - return 1; - } - off = netxen_nic_pci_set_window(adapter, off); - /* Corner case : Malicious user tried to break the driver by reading - last few bytes in ranges and tries to read further addresses. - */ - if (!pci_base(adapter, off + size - 1) && pci_base(adapter, off)) { - printk(KERN_ERR "%s: Invalid access to memory address range" - " 0x%llx - 0x%llx\n", netxen_nic_driver_name, off, - off + size); - return 1; - } - addr = pci_base_offset(adapter, off); - DPRINTK(INFO, "writing data %llx to offset %llx\n", - *(unsigned long long *)data, off); - if (!addr) { - mem_base = pci_resource_start(adapter->ahw.pdev, 0); - mem_page = off & PAGE_MASK; - /* Map two pages whenever user tries to access addresses in two - consecutive pages. - */ - if (mem_page != ((off + size - 1) & PAGE_MASK)) - mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE * 2); - else - mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE); - if (mem_ptr == 0UL) { - return 1; - } - addr = mem_ptr; - addr += off & (PAGE_SIZE - 1); - } - switch (size) { - 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, (size >> 3)); - - netxen_nic_hw_block_write64((u64 __iomem *) data, addr, - (size >> 3)); - break; - } - - if (mem_ptr) - iounmap(mem_ptr); - DPRINTK(INFO, "wrote %llx\n", *(unsigned long long *)data); - - return ret; -} - -int netxen_nic_pci_mem_read_ioctl(struct netxen_adapter *adapter, - u64 off, void *data, int size) -{ - void *addr; - int ret = 0; - u8 *mem_ptr = NULL; - unsigned long mem_base; - unsigned long mem_page; - - if (data == NULL || off > (128 * 1024 * 1024)) { - printk(KERN_ERR "%s: data: %p off:%llx\n", - netxen_nic_driver_name, data, off); - return 1; - } - off = netxen_nic_pci_set_window(adapter, off); - /* Corner case : Malicious user tried to break the driver by reading - last few bytes in ranges and tries to read further addresses. - */ - if (!pci_base(adapter, off + size - 1) && pci_base(adapter, off)) { - printk(KERN_ERR "%s: Invalid access to memory address range" - " 0x%llx - 0x%llx\n", netxen_nic_driver_name, off, - off + size); - return 1; - } - addr = pci_base_offset(adapter, off); - if (!addr) { - mem_base = pci_resource_start(adapter->ahw.pdev, 0); - mem_page = off & PAGE_MASK; - /* Map two pages whenever user tries to access addresses in two - consecutive pages. - */ - if (mem_page != ((off + size - 1) & PAGE_MASK)) - mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE * 2); - else - mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE); - if (mem_ptr == 0UL) { - *(u8 *) data = 0; - return 1; - } - addr = mem_ptr; - addr += off & (PAGE_SIZE - 1); - } - switch (size) { - case 1: - *(u8 *) data = readb(addr); - break; - case 2: - *(u16 *) data = readw(addr); - break; - case 4: - *(u32 *) data = readl(addr); - break; - case 8: - *(u64 *) data = readq(addr); - break; - default: - netxen_nic_hw_block_read64((u64 __iomem *) data, addr, - (size >> 3)); - break; - } - - if (mem_ptr) - iounmap(mem_ptr); - DPRINTK(INFO, "read %llx\n", *(unsigned long long *)data); - - return ret; -} -- cgit v1.2.3-70-g09d2