diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-15 10:09:27 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-15 12:02:35 -0700 |
commit | e9d599220b97e7d52311f6011c75ba0cfcb356fe (patch) | |
tree | 1309442e3019c2d0b469e3bafdb4eed2e3cc3c73 /drivers | |
parent | 0b33559a1adb3b9953503c9b55a61c37db34ffc0 (diff) |
Staging: remove sxg driver
Unfortunatly, the upstream company has abandonded development of this
driver. So it's best to just remove the driver from the tree.
Cc: Christopher Harrer <charrer@alacritech.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/Kconfig | 2 | ||||
-rw-r--r-- | drivers/staging/Makefile | 1 | ||||
-rw-r--r-- | drivers/staging/sxg/Kconfig | 11 | ||||
-rw-r--r-- | drivers/staging/sxg/Makefile | 3 | ||||
-rw-r--r-- | drivers/staging/sxg/README | 12 | ||||
-rw-r--r-- | drivers/staging/sxg/sxg.c | 4543 | ||||
-rw-r--r-- | drivers/staging/sxg/sxg.h | 787 | ||||
-rw-r--r-- | drivers/staging/sxg/sxg_ethtool.c | 328 | ||||
-rw-r--r-- | drivers/staging/sxg/sxg_os.h | 149 | ||||
-rw-r--r-- | drivers/staging/sxg/sxgdbg.h | 184 | ||||
-rw-r--r-- | drivers/staging/sxg/sxghif.h | 1014 | ||||
-rw-r--r-- | drivers/staging/sxg/sxghw.h | 1020 | ||||
-rw-r--r-- | drivers/staging/sxg/sxgphycode-1.2.h | 130 |
13 files changed, 0 insertions, 8184 deletions
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index e86a6716156..10d3fcffe91 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -45,8 +45,6 @@ source "drivers/staging/et131x/Kconfig" source "drivers/staging/slicoss/Kconfig" -source "drivers/staging/sxg/Kconfig" - source "drivers/staging/go7007/Kconfig" source "drivers/staging/usbip/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index fa5361664ba..c30093bae62 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -5,7 +5,6 @@ obj-$(CONFIG_STAGING) += staging.o obj-$(CONFIG_ET131X) += et131x/ obj-$(CONFIG_SLICOSS) += slicoss/ -obj-$(CONFIG_SXG) += sxg/ obj-$(CONFIG_VIDEO_GO7007) += go7007/ obj-$(CONFIG_USB_IP_COMMON) += usbip/ obj-$(CONFIG_W35UND) += winbond/ diff --git a/drivers/staging/sxg/Kconfig b/drivers/staging/sxg/Kconfig deleted file mode 100644 index c5cbdafee4d..00000000000 --- a/drivers/staging/sxg/Kconfig +++ /dev/null @@ -1,11 +0,0 @@ -config SXG - tristate "Alacritech SLIC Technology Non-Accelerated 10Gbe support" - depends on PCI && NETDEV_10000 - depends on X86 - default n - help - This driver supports the Alacritech SLIC Technology Non-Accelerated - 10Gbe network cards. - - To compile this driver as a module, choose - M here: the module will be called sxg_nic. diff --git a/drivers/staging/sxg/Makefile b/drivers/staging/sxg/Makefile deleted file mode 100644 index 8e053222c2a..00000000000 --- a/drivers/staging/sxg/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -obj-$(CONFIG_SXG) += sxg_nic.o - -sxg_nic-y := sxg.o sxg_ethtool.o diff --git a/drivers/staging/sxg/README b/drivers/staging/sxg/README deleted file mode 100644 index e42f344ea5f..00000000000 --- a/drivers/staging/sxg/README +++ /dev/null @@ -1,12 +0,0 @@ -This is the rough cut at a driver for the Alacritech SLIC Technology -Non-Accelerated 10Gbe network driver. - -TODO: - - remove wrappers - - checkpatch.pl cleanups - - new functionality that the card needs - - remove reliance on x86 - -Please send patches to: - Greg Kroah-Hartman <gregkh@suse.de> -for any cleanups that you do to this driver. diff --git a/drivers/staging/sxg/sxg.c b/drivers/staging/sxg/sxg.c deleted file mode 100644 index 395e876c7dc..00000000000 --- a/drivers/staging/sxg/sxg.c +++ /dev/null @@ -1,4543 +0,0 @@ -/************************************************************************** - * - * Copyright (C) 2000-2008 Alacritech, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY ALACRITECH, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ALACRITECH, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation - * are those of the authors and should not be interpreted as representing - * official policies, either expressed or implied, of Alacritech, Inc. - * - * Parts developed by LinSysSoft Sahara team - * - **************************************************************************/ - -/* - * FILENAME: sxg.c - * - * The SXG driver for Alacritech's 10Gbe products. - * - * NOTE: This is the standard, non-accelerated version of Alacritech's - * IS-NIC driver. - */ - -#include <linux/kernel.h> -#include <linux/string.h> -#include <linux/errno.h> -#include <linux/module.h> -#include <linux/moduleparam.h> -#include <linux/firmware.h> -#include <linux/ioport.h> -#include <linux/slab.h> -#include <linux/interrupt.h> -#include <linux/timer.h> -#include <linux/pci.h> -#include <linux/spinlock.h> -#include <linux/init.h> -#include <linux/netdevice.h> -#include <linux/etherdevice.h> -#include <linux/ethtool.h> -#include <linux/skbuff.h> -#include <linux/delay.h> -#include <linux/types.h> -#include <linux/dma-mapping.h> -#include <linux/mii.h> -#include <linux/ip.h> -#include <linux/in.h> -#include <linux/tcp.h> -#include <linux/ipv6.h> - -#define SLIC_GET_STATS_ENABLED 0 -#define LINUX_FREES_ADAPTER_RESOURCES 1 -#define SXG_OFFLOAD_IP_CHECKSUM 0 -#define SXG_POWER_MANAGEMENT_ENABLED 0 -#define VPCI 0 -#define ATK_DEBUG 1 -#define SXG_UCODE_DEBUG 0 - - -#include "sxg_os.h" -#include "sxghw.h" -#include "sxghif.h" -#include "sxg.h" -#include "sxgdbg.h" -#include "sxgphycode-1.2.h" - -static int sxg_allocate_buffer_memory(struct adapter_t *adapter, u32 Size, - enum sxg_buffer_type BufferType); -static int sxg_allocate_rcvblock_complete(struct adapter_t *adapter, - void *RcvBlock, - dma_addr_t PhysicalAddress, - u32 Length); -static void sxg_allocate_sgl_buffer_complete(struct adapter_t *adapter, - struct sxg_scatter_gather *SxgSgl, - dma_addr_t PhysicalAddress, - u32 Length); - -static void sxg_mcast_init_crc32(void); -static int sxg_entry_open(struct net_device *dev); -static int sxg_second_open(struct net_device * dev); -static int sxg_entry_halt(struct net_device *dev); -static int sxg_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); -static int sxg_send_packets(struct sk_buff *skb, struct net_device *dev); -static int sxg_transmit_packet(struct adapter_t *adapter, struct sk_buff *skb); -static int sxg_dumb_sgl(struct sxg_x64_sgl *pSgl, - struct sxg_scatter_gather *SxgSgl); - -static void sxg_handle_interrupt(struct adapter_t *adapter, int *work_done, - int budget); -static void sxg_interrupt(struct adapter_t *adapter); -static int sxg_poll(struct napi_struct *napi, int budget); -static int sxg_process_isr(struct adapter_t *adapter, u32 MessageId); -static u32 sxg_process_event_queue(struct adapter_t *adapter, u32 RssId, - int *sxg_napi_continue, int *work_done, int budget); -static void sxg_complete_slow_send(struct adapter_t *adapter); -static struct sk_buff *sxg_slow_receive(struct adapter_t *adapter, - struct sxg_event *Event); -static void sxg_process_rcv_error(struct adapter_t *adapter, u32 ErrorStatus); -static bool sxg_mac_filter(struct adapter_t *adapter, - struct ether_header *EtherHdr, ushort length); -static struct net_device_stats *sxg_get_stats(struct net_device * dev); -void sxg_free_resources(struct adapter_t *adapter); -void sxg_free_rcvblocks(struct adapter_t *adapter); -void sxg_free_sgl_buffers(struct adapter_t *adapter); -void sxg_unmap_resources(struct adapter_t *adapter); -void sxg_free_mcast_addrs(struct adapter_t *adapter); -void sxg_collect_statistics(struct adapter_t *adapter); -static int sxg_register_interrupt(struct adapter_t *adapter); -static void sxg_remove_isr(struct adapter_t *adapter); -static irqreturn_t sxg_isr(int irq, void *dev_id); - -static void sxg_watchdog(unsigned long data); -static void sxg_update_link_status (struct work_struct *work); - -#define XXXTODO 0 - -#if XXXTODO -static int sxg_mac_set_address(struct net_device *dev, void *ptr); -#endif -static void sxg_mcast_set_list(struct net_device *dev); - -static int sxg_adapter_set_hwaddr(struct adapter_t *adapter); - -static int sxg_initialize_adapter(struct adapter_t *adapter); -static void sxg_stock_rcv_buffers(struct adapter_t *adapter); -static void sxg_complete_descriptor_blocks(struct adapter_t *adapter, - unsigned char Index); -int sxg_change_mtu (struct net_device *netdev, int new_mtu); -static int sxg_initialize_link(struct adapter_t *adapter); -static int sxg_phy_init(struct adapter_t *adapter); -static void sxg_link_event(struct adapter_t *adapter); -static enum SXG_LINK_STATE sxg_get_link_state(struct adapter_t *adapter); -static void sxg_link_state(struct adapter_t *adapter, - enum SXG_LINK_STATE LinkState); -static int sxg_write_mdio_reg(struct adapter_t *adapter, - u32 DevAddr, u32 RegAddr, u32 Value); -static int sxg_read_mdio_reg(struct adapter_t *adapter, - u32 DevAddr, u32 RegAddr, u32 *pValue); -static void sxg_set_mcast_addr(struct adapter_t *adapter); - -static unsigned int sxg_first_init = 1; -static char *sxg_banner = - "Alacritech SLIC Technology(tm) Server and Storage \ - 10Gbe Accelerator (Non-Accelerated)\n"; - -static int sxg_debug = 1; -static int debug = -1; -static struct net_device *head_netdevice = NULL; - -static struct sxgbase_driver sxg_global = { - .dynamic_intagg = 1, -}; -static int intagg_delay = 100; -static u32 dynamic_intagg = 0; - -char sxg_driver_name[] = "sxg_nic"; -#define DRV_AUTHOR "Alacritech, Inc. Engineering" -#define DRV_DESCRIPTION \ - "Alacritech SLIC Techonology(tm) Non-Accelerated 10Gbe Driver" -#define DRV_COPYRIGHT \ - "Copyright 2000-2008 Alacritech, Inc. All rights reserved." - -MODULE_AUTHOR(DRV_AUTHOR); -MODULE_DESCRIPTION(DRV_DESCRIPTION); -MODULE_LICENSE("GPL"); - -module_param(dynamic_intagg, int, 0); -MODULE_PARM_DESC(dynamic_intagg, "Dynamic Interrupt Aggregation Setting"); -module_param(intagg_delay, int, 0); -MODULE_PARM_DESC(intagg_delay, "uSec Interrupt Aggregation Delay"); - -static struct pci_device_id sxg_pci_tbl[] __devinitdata = { - {PCI_DEVICE(SXG_VENDOR_ID, SXG_DEVICE_ID)}, - {0,} -}; - -MODULE_DEVICE_TABLE(pci, sxg_pci_tbl); - -static inline void sxg_reg32_write(void __iomem *reg, u32 value, bool flush) -{ - writel(value, reg); - if (flush) - mb(); -} - -static inline void sxg_reg64_write(struct adapter_t *adapter, void __iomem *reg, - u64 value, u32 cpu) -{ - u32 value_high = (u32) (value >> 32); - u32 value_low = (u32) (value & 0x00000000FFFFFFFF); - unsigned long flags; - - spin_lock_irqsave(&adapter->Bit64RegLock, flags); - writel(value_high, (void __iomem *)(&adapter->UcodeRegs[cpu].Upper)); - writel(value_low, reg); - spin_unlock_irqrestore(&adapter->Bit64RegLock, flags); -} - -static void sxg_init_driver(void) -{ - if (sxg_first_init) { - DBG_ERROR("sxg: %s sxg_first_init set jiffies[%lx]\n", - __func__, jiffies); - sxg_first_init = 0; - spin_lock_init(&sxg_global.driver_lock); - } -} - -static void sxg_dbg_macaddrs(struct adapter_t *adapter) -{ - DBG_ERROR(" (%s) curr %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", - adapter->netdev->name, adapter->currmacaddr[0], - adapter->currmacaddr[1], adapter->currmacaddr[2], - adapter->currmacaddr[3], adapter->currmacaddr[4], - adapter->currmacaddr[5]); - DBG_ERROR(" (%s) mac %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", - adapter->netdev->name, adapter->macaddr[0], - adapter->macaddr[1], adapter->macaddr[2], - adapter->macaddr[3], adapter->macaddr[4], - adapter->macaddr[5]); - return; -} - -/* SXG Globals */ -static struct sxg_driver SxgDriver; - -#ifdef ATKDBG -static struct sxg_trace_buffer LSxgTraceBuffer; -#endif /* ATKDBG */ -static struct sxg_trace_buffer *SxgTraceBuffer = NULL; - -/* - * MSI Related API's - */ -int sxg_register_intr(struct adapter_t *adapter); -int sxg_enable_msi_x(struct adapter_t *adapter); -int sxg_add_msi_isr(struct adapter_t *adapter); -void sxg_remove_msix_isr(struct adapter_t *adapter); -int sxg_set_interrupt_capability(struct adapter_t *adapter); - -int sxg_set_interrupt_capability(struct adapter_t *adapter) -{ - int ret; - - ret = sxg_enable_msi_x(adapter); - if (ret != STATUS_SUCCESS) { - adapter->msi_enabled = FALSE; - DBG_ERROR("sxg_set_interrupt_capability MSI-X Disable\n"); - } else { - adapter->msi_enabled = TRUE; - DBG_ERROR("sxg_set_interrupt_capability MSI-X Enable\n"); - } - return ret; -} - -int sxg_register_intr(struct adapter_t *adapter) -{ - int ret = 0; - - if (adapter->msi_enabled) { - ret = sxg_add_msi_isr(adapter); - } - else { - DBG_ERROR("MSI-X Enable Failed. Using Pin INT\n"); - ret = sxg_register_interrupt(adapter); - if (ret != STATUS_SUCCESS) { - DBG_ERROR("sxg_register_interrupt Failed\n"); - } - } - return ret; -} - -int sxg_enable_msi_x(struct adapter_t *adapter) -{ - int ret; - - adapter->nr_msix_entries = 1; - adapter->msi_entries = kmalloc(adapter->nr_msix_entries * - sizeof(struct msix_entry),GFP_KERNEL); - if (!adapter->msi_entries) { - DBG_ERROR("%s:MSI Entries memory allocation Failed\n",__func__); - return -ENOMEM; - } - memset(adapter->msi_entries, 0, adapter->nr_msix_entries * - sizeof(struct msix_entry)); - - ret = pci_enable_msix(adapter->pcidev, adapter->msi_entries, - adapter->nr_msix_entries); - if (ret) { - DBG_ERROR("Enabling MSI-X with %d vectors failed\n", - adapter->nr_msix_entries); - /*Should try with less vector returned.*/ - kfree(adapter->msi_entries); - return STATUS_FAILURE; /*MSI-X Enable failed.*/ - } - return (STATUS_SUCCESS); -} - -int sxg_add_msi_isr(struct adapter_t *adapter) -{ - int ret,i; - - if (!adapter->intrregistered) { - spin_unlock_irqrestore(&sxg_global.driver_lock, - sxg_global.flags); - for (i=0; i<adapter->nr_msix_entries; i++) { - ret = request_irq (adapter->msi_entries[i].vector, - sxg_isr, - IRQF_SHARED, - adapter->netdev->name, - adapter->netdev); - if (ret) { - spin_lock_irqsave(&sxg_global.driver_lock, - sxg_global.flags); - DBG_ERROR("sxg: MSI-X request_irq (%s) " - "FAILED [%x]\n", adapter->netdev->name, - ret); - return (ret); - } - } - } - spin_lock_irqsave(&sxg_global.driver_lock, sxg_global.flags); - adapter->msi_enabled = TRUE; - adapter->intrregistered = 1; - adapter->IntRegistered = TRUE; - return (STATUS_SUCCESS); -} - -void sxg_remove_msix_isr(struct adapter_t *adapter) -{ - int i,vector; - struct net_device *netdev = adapter->netdev; - - for(i=0; i< adapter->nr_msix_entries;i++) - { - vector = adapter->msi_entries[i].vector; - DBG_ERROR("%s : Freeing IRQ vector#%d\n",__func__,vector); - free_irq(vector,netdev); - } -} - - -static void sxg_remove_isr(struct adapter_t *adapter) -{ - struct net_device *netdev = adapter->netdev; - if (adapter->msi_enabled) - sxg_remove_msix_isr(adapter); - else - free_irq(adapter->netdev->irq, netdev); -} - -void sxg_reset_interrupt_capability(struct adapter_t *adapter) -{ - if (adapter->msi_enabled) { - pci_disable_msix(adapter->pcidev); - kfree(adapter->msi_entries); - adapter->msi_entries = NULL; - } - return; -} - -/* - * sxg_download_microcode - * - * Download Microcode to Sahara adapter using the Linux - * Firmware module to get the ucode.sys file. - * - * Arguments - - * adapter - A pointer to our adapter structure - * UcodeSel - microcode file selection - * - * Return - * int - */ -static bool sxg_download_microcode(struct adapter_t *adapter, - enum SXG_UCODE_SEL UcodeSel) -{ - const struct firmware *fw; - const char *file = ""; - struct sxg_hw_regs *HwRegs = adapter->HwRegs; - int ret; - int ucode_start; - u32 Section; - u32 ThisSectionSize; - u32 instruction = 0; - u32 BaseAddress, AddressOffset, Address; - /* u32 Failure; */ - u32 ValueRead; - u32 i; - u32 index = 0; - u32 num_sections = 0; - u32 sectionSize[16]; - u32 sectionStart[16]; - - SXG_TRACE(TRACE_SXG, SxgTraceBuffer, TRACE_NOISY, "DnldUcod", - adapter, 0, 0, 0); - - /* - * This routine is only implemented to download the microcode - * for the Revision B Sahara chip. Rev A and Diagnostic - * microcode is not supported at this time. If Rev A or - * diagnostic ucode is required, this routine will obviously - * need to change. Also, eventually need to add support for - * Rev B checked version of ucode. That's easy enough once - * the free version of Rev B works. - */ - ASSERT(UcodeSel == SXG_UCODE_SYSTEM); - ASSERT(adapter->asictype == SAHARA_REV_B); -#if SXG_UCODE_DEBUG - file = "sxg/saharadbgdownloadB.sys"; -#else - file = "sxg/saharadownloadB.sys"; -#endif - ret = request_firmware(&fw, file, &adapter->pcidev->dev); - if (ret) { - DBG_ERROR("%s SXG_NIC: Failed to load firmware %s\n", __func__,file); - return ret; - } - - /* - * The microcode .sys file contains starts with a 4 byte word containing - * the number of sections. That is followed by "num_sections" 4 byte - * words containing each "section" size. That is followed num_sections - * 4 byte words containing each section "start" address. - * - * Following the above header, the .sys file contains num_sections, - * where each section size is specified, newline delineatetd 12 byte - * microcode instructions. - */ - num_sections = *(u32 *)(fw->data + index); - index += 4; - ASSERT(num_sections <= 3); - for (i = 0; i < num_sections; i++) { - sectionSize[i] = *(u32 *)(fw->data + index); - index += 4; - } - for (i = 0; i < num_sections; i++) { - sectionStart[i] = *(u32 *)(fw->data + index); - index += 4; - } - - /* First, reset the card */ - WRITE_REG(HwRegs->Reset, 0xDEAD, FLUSH); - udelay(50); - HwRegs = adapter->HwRegs; - - /* - * Download each section of the microcode as specified in - * sectionSize[index] to sectionStart[index] address. As - * described above, the .sys file contains 12 byte word - * microcode instructions. The *download.sys file is generated - * using the objtosys.exe utility that was built for Sahara - * microcode. - */ - /* See usage of this below when we read back for parity */ - ucode_start = index; - instruction = *(u32 *)(fw->data + index); - index += 4; - - for (Section = 0; Section < num_sections; Section++) { - BaseAddress = sectionStart[Section]; - /* Size in instructions */ - ThisSectionSize = sectionSize[Section] / 12; - for (AddressOffset = 0; AddressOffset < ThisSectionSize; - AddressOffset++) { - u32 first_instr = 0; /* See comment below */ - - Address = BaseAddress + AddressOffset; - ASSERT((Address & ~MICROCODE_ADDRESS_MASK) == 0); - /* Write instruction bits 31 - 0 (low) */ - first_instr = instruction; - WRITE_REG(HwRegs->UcodeDataLow, instruction, FLUSH); - instruction = *(u32 *)(fw->data + index); - index += 4; /* Advance to the "next" instruction */ - - /* Write instruction bits 63-32 (middle) */ - WRITE_REG(HwRegs->UcodeDataMiddle, instruction, FLUSH); - instruction = *(u32 *)(fw->data + index); - index += 4; /* Advance to the "next" instruction */ - - /* Write instruction bits 95-64 (high) */ - WRITE_REG(HwRegs->UcodeDataHigh, instruction, FLUSH); - instruction = *(u32 *)(fw->data + index); - index += 4; /* Advance to the "next" instruction */ - - /* Write instruction address with the WRITE bit set */ - WRITE_REG(HwRegs->UcodeAddr, - (Address | MICROCODE_ADDRESS_WRITE), FLUSH); - /* - * Sahara bug in the ucode download logic - the write to DataLow - * for the next instruction could get corrupted. To avoid this, - * write to DataLow again for this instruction (which may get - * corrupted, but it doesn't matter), then increment the address - * and write the data for the next instruction to DataLow. That - * write should succeed. - */ - WRITE_REG(HwRegs->UcodeDataLow, first_instr, FLUSH); - } - } - /* - * Now repeat the entire operation reading the instruction back and - * checking for parity errors - */ - index = ucode_start; - - for (Section = 0; Section < num_sections; Section++) { - BaseAddress = sectionStart[Section]; - /* Size in instructions */ - ThisSectionSize = sectionSize[Section] / 12; - for (AddressOffset = 0; AddressOffset < ThisSectionSize; - AddressOffset++) { - Address = BaseAddress + AddressOffset; - /* Write the address with the READ bit set */ - WRITE_REG(HwRegs->UcodeAddr, - (Address | MICROCODE_ADDRESS_READ), FLUSH); - /* Read it back and check parity bit. */ - READ_REG(HwRegs->UcodeAddr, ValueRead); - if (ValueRead & MICROCODE_ADDRESS_PARITY) { - DBG_ERROR("sxg: %s PARITY ERROR\n", - __func__); - - return FALSE; /* Parity error */ - } - ASSERT((ValueRead & MICROCODE_ADDRESS_MASK) == Address); - /* Read the instruction back and compare */ - /* First instruction */ - instruction = *(u32 *)(fw->data + index); - index += 4; - READ_REG(HwRegs->UcodeDataLow, ValueRead); - if (ValueRead != instruction) { - DBG_ERROR("sxg: %s MISCOMPARE LOW\n", - __func__); - return FALSE; /* Miscompare */ - } - instruction = *(u32 *)(fw->data + index); - index += 4; - READ_REG(HwRegs->UcodeDataMiddle, ValueRead); - if (ValueRead != instruction) { - DBG_ERROR("sxg: %s MISCOMPARE MIDDLE\n", - __func__); - return FALSE; /* Miscompare */ - } - instruction = *(u32 *)(fw->data + index); - index += 4; - READ_REG(HwRegs->UcodeDataHigh, ValueRead); - if (ValueRead != instruction) { - DBG_ERROR("sxg: %s MISCOMPARE HIGH\n", - __func__); - return FALSE; /* Miscompare */ - } - } - } - - /* download finished */ - release_firmware(fw); - /* Everything OK, Go. */ - WRITE_REG(HwRegs->UcodeAddr, MICROCODE_ADDRESS_GO, FLUSH); - - /* - * Poll the CardUp register to wait for microcode to initialize - * Give up after 10,000 attemps (500ms). - */ - for (i = 0; i < 10000; i++) { - udelay(50); - READ_REG(adapter->UcodeRegs[0].CardUp, ValueRead); - if (ValueRead == 0xCAFE) { - break; - } - } - if (i == 10000) { - DBG_ERROR("sxg: %s TIMEOUT bringing up card - verify MICROCODE\n", __func__); - - return FALSE; /* Timeout */ - } - /* - * Now write the LoadSync register. This is used to - * synchronize with the card so it can scribble on the memory - * that contained 0xCAFE from the "CardUp" step above - */ - if (UcodeSel == SXG_UCODE_SYSTEM) { - WRITE_REG(adapter->UcodeRegs[0].LoadSync, 0, FLUSH); - } - - SXG_TRACE(TRACE_SXG, SxgTraceBuffer, TRACE_NOISY, "XDnldUcd", - adapter, 0, 0, 0); - return (TRUE); -} - -/* - * sxg_allocate_resources - Allocate memory and locks - * - * Arguments - - * adapter - A pointer to our adapter structure - * - * Return - int - */ -static int sxg_allocate_resources(struct adapter_t *adapter) -{ - int status = STATUS_SUCCESS; - u32 RssIds, IsrCount; - /* struct sxg_xmt_ring *XmtRing; */ - /* struct sxg_rcv_ring *RcvRing; */ - - DBG_ERROR("%s ENTER\n", __func__); - - SXG_TRACE(TRACE_SXG, SxgTraceBuffer, TRACE_NOISY, "AllocRes", - adapter, 0, 0, 0); - - /* Windows tells us how many CPUs it plans to use for */ - /* RSS */ - RssIds = SXG_RSS_CPU_COUNT(adapter); - IsrCount = adapter->msi_enabled ? RssIds : 1; - - DBG_ERROR("%s Setup the spinlocks\n", __func__); - - /* Allocate spinlocks and initialize listheads first. */ - spin_lock_init(&adapter->RcvQLock); - spin_lock_init(&adapter->SglQLock); - spin_lock_init(&adapter->XmtZeroLock); - spin_lock_init(&adapter->Bit64RegLock); - spin_lock_init(&adapter->AdapterLock); - atomic_set(&adapter->pending_allocations, 0); - - DBG_ERROR("%s Setup the lists\n", __func__); - - InitializeListHead(&adapter->FreeRcvBuffers); - InitializeListHead(&adapter->FreeRcvBlocks); - InitializeListHead(&adapter->AllRcvBlocks); - InitializeListHead(&adapter->FreeSglBuffers); - InitializeListHead(&adapter->AllSglBuffers); - - /* - * Mark these basic allocations done. This flags essentially - * tells the SxgFreeResources routine that it can grab spinlocks - * and reference listheads. - */ - adapter->BasicAllocations = TRUE; - /* - * Main allocation loop. Start with the maximum supported by - * the microcode and back off if memory allocation - * fails. If we hit a minimum, fail. - */ - - for (;;) { - DBG_ERROR("%s Allocate XmtRings size[%x]\n", __func__, - (unsigned int)(sizeof(struct sxg_xmt_ring) * 1)); - - /* - * Start with big items first - receive and transmit rings. - * At the moment I'm going to keep the ring size fixed and - * adjust the TCBs if we fail. Later we might - * consider reducing the ring size as well.. - */ - adapter->XmtRings = pci_alloc_consistent(adapter->pcidev, - sizeof(struct sxg_xmt_ring) * - 1, - &adapter->PXmtRings); - DBG_ERROR("%s XmtRings[%p]\n", __func__, adapter->XmtRings); - - if (!adapter->XmtRings) { - goto per_tcb_allocation_failed; - } - memset(adapter->XmtRings, 0, sizeof(struct sxg_xmt_ring) * 1); - - DBG_ERROR("%s Allocate RcvRings size[%x]\n", __func__, - (unsigned int)(sizeof(struct sxg_rcv_ring) * 1)); - adapter->RcvRings = - pci_alloc_consistent(adapter->pcidev, - sizeof(struct sxg_rcv_ring) * 1, - &adapter->PRcvRings); - DBG_ERROR("%s RcvRings[%p]\n", __func__, adapter->RcvRings); - if (!adapter->RcvRings) { - goto per_tcb_allocation_failed; - } - memset(adapter->RcvRings, 0, sizeof(struct sxg_rcv_ring) * 1); - adapter->ucode_stats = kzalloc(sizeof(struct sxg_ucode_stats), GFP_ATOMIC); - adapter->pucode_stats = pci_map_single(adapter->pcidev, - adapter->ucode_stats, - sizeof(struct sxg_ucode_stats), - PCI_DMA_FROMDEVICE); -// memset(adapter->ucode_stats, 0, sizeof(struct sxg_ucode_stats)); - break; - - per_tcb_allocation_failed: - /* an allocation failed. Free any successful allocations. */ - if (adapter->XmtRings) { - pci_free_consistent(adapter->pcidev, - sizeof(struct sxg_xmt_ring) * 1, - adapter->XmtRings, - adapter->PXmtRings); - adapter->XmtRings = NULL; - } - if (adapter->RcvRings) { - pci_free_consistent(adapter->pcidev, - sizeof(struct sxg_rcv_ring) * 1, - adapter->RcvRings, - adapter->PRcvRings); - adapter->RcvRings = NULL; - } - /* Loop around and try again.... */ - if (adapter->ucode_stats) { - pci_unmap_single(adapter->pcidev, - sizeof(struct sxg_ucode_stats), - adapter->pucode_stats, PCI_DMA_FROMDEVICE); - adapter->ucode_stats = NULL; - } - - } - - DBG_ERROR("%s Initialize RCV ZERO and XMT ZERO rings\n", __func__); - /* Initialize rcv zero and xmt zero rings */ - SXG_INITIALIZE_RING(adapter->RcvRingZeroInfo, SXG_RCV_RING_SIZE); - SXG_INITIALIZE_RING(adapter->XmtRingZeroInfo, SXG_XMT_RING_SIZE); - - /* Sanity check receive data structure format */ - /* ASSERT((adapter->ReceiveBufferSize == SXG_RCV_DATA_BUFFER_SIZE) || - (adapter->ReceiveBufferSize == SXG_RCV_JUMBO_BUFFER_SIZE)); */ - ASSERT(sizeof(struct sxg_rcv_descriptor_block) == - SXG_RCV_DESCRIPTOR_BLOCK_SIZE); - - DBG_ERROR("%s Allocate EventRings size[%x]\n", __func__, - (unsigned int)(sizeof(struct sxg_event_ring) * RssIds)); - - /* Allocate event queues. */ - adapter->EventRings = pci_alloc_consistent(adapter->pcidev, - sizeof(struct sxg_event_ring) * - RssIds, - &adapter->PEventRings); - - if (!adapter->EventRings) { - /* Caller will call SxgFreeAdapter to clean up above - * allocations */ - SXG_TRACE(TRACE_SXG, SxgTraceBuffer, TRACE_NOISY, "XAResF8", - adapter, SXG_MAX_ENTRIES, 0, 0); - status = STATUS_RESOURCES; - goto per_tcb_allocation_failed; - } - memset(adapter->EventRings, 0, sizeof(struct sxg_event_ring) * RssIds); - - DBG_ERROR("%s Allocate ISR size[%x]\n", __func__, IsrCount); - /* Allocate ISR */ - adapter->Isr = pci_alloc_consistent(adapter->pcidev, - IsrCount, &adapter->PIsr); - if (!adapter->Isr) { - /* Caller will call SxgFreeAdapter to clean up above - * allocations */ - SXG_TRACE(TRACE_SXG, SxgTraceBuffer, TRACE_NOISY, "XAResF9", - adapter, SXG_MAX_ENTRIES, 0, 0); - status = STATUS_RESOURCES; - goto per_tcb_allocation_failed; - } - memset(adapter->Isr, 0, sizeof(u32) * IsrCount); - - DBG_ERROR("%s Allocate shared XMT ring zero index location size[%x]\n", - __func__, (unsigned int)sizeof(u32)); - - /* Allocate shared XMT ring zero index location */ - adapter->XmtRingZeroIndex = pci_alloc_consistent(adapter->pcidev, - sizeof(u32), - &adapter-> - PXmtRingZeroIndex); - if (!adapter->XmtRingZeroIndex) { - SXG_TRACE(TRACE_SXG, SxgTraceBuffer, TRACE_NOISY, "XAResF10", - adapter, SXG_MAX_ENTRIES, 0, 0); - status = STATUS_RESOURCES; - goto per_tcb_allocation_failed; - } - memset(adapter->XmtRingZeroIndex, 0, sizeof(u32)); - - SXG_TRACE(TRACE_SXG, SxgTraceBuffer, TRACE_NOISY, "XAlcResS", - adapter, SXG_MAX_ENTRIES, 0, 0); - - return status; -} - -/* - * sxg_config_pci - - * - * Set up PCI Configuration space - * - * Arguments - - * pcidev - A pointer to our adapter structure - */ -static void sxg_config_pci(struct pci_dev *pcidev) -{ - u16 pci_command; - u16 new_command; - - pci_read_config_word(pcidev, PCI_COMMAND, &pci_command); - DBG_ERROR("sxg: %s PCI command[%4.4x]\n", __func__, pci_command); - /* Set the command register */ - new_command = pci_command | ( - /* Memory Space Enable */ - PCI_COMMAND_MEMORY | - /* Bus master enable */ - PCI_COMMAND_MASTER | - /* Memory write and invalidate */ - PCI_COMMAND_INVALIDATE | - /* Parity error response */ - PCI_COMMAND_PARITY | - /* System ERR */ - PCI_COMMAND_SERR | - /* Fast back-to-back */ - PCI_COMMAND_FAST_BACK); - if (pci_command != new_command) { - DBG_ERROR("%s -- Updating PCI COMMAND register %4.4x->%4.4x.\n", - __func__, pci_command, new_command); - pci_write_config_word(pcidev, PCI_COMMAND, new_command); - } -} - -/* - * sxg_read_config - * @adapter : Pointer to the adapter structure for the card - * This function will read the configuration data from EEPROM/FLASH - */ -static inline int sxg_read_config(struct adapter_t *adapter) -{ - /* struct sxg_config data; */ - struct sxg_config *config; - struct sw_cfg_data *data; - dma_addr_t p_addr; - unsigned long status; - unsigned long i; - config = pci_alloc_consistent(adapter->pcidev, - sizeof(struct sxg_config), &p_addr); - - if(!config) { - /* - * We cant get even this much memory. Raise a hell - * Get out of here - */ - printk(KERN_ERR"%s : Could not allocate memory for reading \ - EEPROM\n", __func__); - return -ENOMEM; - } - - data = &config->SwCfg; - - /* Initialize (reflective memory) status register */ - WRITE_REG(adapter->UcodeRegs[0].ConfigStat, SXG_CFG_TIMEOUT, TRUE); - - /* Send request to fetch configuration data */ - WRITE_REG64(adapter, adapter->UcodeRegs[0].Config, p_addr, 0); - for(i=0; i<1000; i++) { - READ_REG(adapter->UcodeRegs[0].ConfigStat, status); - if (status != SXG_CFG_TIMEOUT) - break; - mdelay(1); /* Do we really need this */ - } - - switch(status) { - /* Config read from EEPROM succeeded */ - case SXG_CFG_LOAD_EEPROM: - /* Config read from Flash succeeded */ - case SXG_CFG_LOAD_FLASH: - /* - * Copy the MAC address to adapter structure - * TODO: We are not doing the remaining part : FRU, etc - */ - memcpy(adapter->macaddr, data->MacAddr[0].MacAddr, - sizeof(struct sxg_config_mac)); - break; - case SXG_CFG_TIMEOUT: - case SXG_CFG_LOAD_INVALID: - case SXG_CFG_LOAD_ERROR: - default: /* Fix default handler later */ - printk(KERN_WARNING"%s : We could not read the config \ - word. Status = %ld\n", __func__, status); - |