diff options
author | Mithlesh Thukral <mithlesh@linsyssoft.com> | 2009-01-19 20:22:34 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-04-03 14:53:10 -0700 |
commit | 371d7a9e6f0486fb814582c46785fdb147d7215e (patch) | |
tree | fe19ba9cf929af7e05869140777529f5b9308343 /drivers/staging | |
parent | d0128aa9dc8a19a403cb35b5d3a6ded7210eb921 (diff) |
Staging: sxg: Ethtool framework and Receive code path changes
* Add Ethtool framework to driver
* Makefile changes to fix build redundancy.
* Fix ups to error code paths in receieve buffer allocation as well as receive code path.
* Read MAC address from FLASH/EEPROM
Signed-off-by: LinSysSoft Sahara Team <saharaproj@linsyssoft.com>
Signed-off-by: Christopher Harrer <charrer@alacritech.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/sxg/Makefile | 4 | ||||
-rw-r--r-- | drivers/staging/sxg/sxg.c | 12 | ||||
-rw-r--r-- | drivers/staging/sxg/sxg.h | 8 | ||||
-rw-r--r-- | drivers/staging/sxg/sxg_ethtool.c | 338 | ||||
-rw-r--r-- | drivers/staging/sxg/sxghif.h | 2 |
5 files changed, 355 insertions, 9 deletions
diff --git a/drivers/staging/sxg/Makefile b/drivers/staging/sxg/Makefile index ec48faa7b3e..8e053222c2a 100644 --- a/drivers/staging/sxg/Makefile +++ b/drivers/staging/sxg/Makefile @@ -1 +1,3 @@ -obj-$(CONFIG_SXG) += sxg.o +obj-$(CONFIG_SXG) += sxg_nic.o + +sxg_nic-y := sxg.o sxg_ethtool.o diff --git a/drivers/staging/sxg/sxg.c b/drivers/staging/sxg/sxg.c index b23cbc67834..80e84768da1 100644 --- a/drivers/staging/sxg/sxg.c +++ b/drivers/staging/sxg/sxg.c @@ -62,13 +62,11 @@ #include <linux/dma-mapping.h> #include <linux/mii.h> -#define SLIC_DUMP_ENABLED 0 #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 DBG 1 #define ATK_DEBUG 1 #include "sxg_os.h" @@ -156,8 +154,7 @@ static struct sxgbase_driver sxg_global = { static int intagg_delay = 100; static u32 dynamic_intagg = 0; -#define DRV_NAME "sxg" -#define DRV_VERSION "1.0.1" +char sxg_driver_name[] = "sxg"; #define DRV_AUTHOR "Alacritech, Inc. Engineering" #define DRV_DESCRIPTION \ "Alacritech SLIC Techonology(tm) Non-Accelerated 10Gbe Driver" @@ -753,7 +750,7 @@ static int sxg_entry_probe(struct pci_dev *pcidev, if (sxg_debug > 0 && did_version++ == 0) { printk(KERN_INFO "%s\n", sxg_banner); - printk(KERN_INFO "%s\n", DRV_VERSION); + printk(KERN_INFO "%s\n", SXG_DRV_VERSION); } if (!(err = pci_set_dma_mask(pcidev, DMA_64BIT_MASK))) { @@ -770,7 +767,7 @@ static int sxg_entry_probe(struct pci_dev *pcidev, DBG_ERROR("Call pci_request_regions\n"); - err = pci_request_regions(pcidev, DRV_NAME); + err = pci_request_regions(pcidev, sxg_driver_name); if (err) { DBG_ERROR("pci_request_regions FAILED err[%x]\n", err); return err; @@ -919,6 +916,7 @@ static int sxg_entry_probe(struct pci_dev *pcidev, #endif #endif netdev->set_multicast_list = sxg_mcast_set_list; + SET_ETHTOOL_OPS(netdev, &sxg_nic_ethtool_ops); strcpy(netdev->name, "eth%d"); /* strcpy(netdev->name, pci_name(pcidev)); */ @@ -3857,7 +3855,7 @@ static void sxg_complete_descriptor_blocks(struct adapter_t *adapter, } static struct pci_driver sxg_driver = { - .name = DRV_NAME, + .name = sxg_driver_name, .id_table = sxg_pci_tbl, .probe = sxg_entry_probe, .remove = sxg_entry_remove, diff --git a/drivers/staging/sxg/sxg.h b/drivers/staging/sxg/sxg.h index 28e7cd7337c..a00c2dc97a1 100644 --- a/drivers/staging/sxg/sxg.h +++ b/drivers/staging/sxg/sxg.h @@ -42,7 +42,12 @@ #ifndef __SXG_DRIVER_H__ #define __SXG_DRIVER_H__ -#define p_net_device struct net_device * +#define SLIC_DUMP_ENABLED 0 + +#define SXG_DRV_NAME "sxg" /* TBD: This might be removed eventually */ +#define SXG_DRV_VERSION "1.0.1" + +extern char sxg_driver_name[]; /* * struct sxg_stats - Probably move these to someplace where * the slicstat (sxgstat?) program can get them. @@ -759,4 +764,5 @@ struct slic_crash_info { #define SIOCSLICSETINTAGG (SIOCDEVPRIVATE+10) #define SIOCSLICTRACEDUMP (SIOCDEVPRIVATE+11) +extern struct ethtool_ops sxg_nic_ethtool_ops; #endif /* __SXG_DRIVER_H__ */ diff --git a/drivers/staging/sxg/sxg_ethtool.c b/drivers/staging/sxg/sxg_ethtool.c new file mode 100644 index 00000000000..c15c250e9ec --- /dev/null +++ b/drivers/staging/sxg/sxg_ethtool.c @@ -0,0 +1,338 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +/* + * FILENAME: sxg_ethtool.c + * + * The ethtool support for 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/errno.h> +#include <linux/module.h> +#include <linux/netdevice.h> +#include <linux/etherdevice.h> +#include <linux/ethtool.h> +#include <linux/skbuff.h> +#include <linux/pci.h> + +#include "sxg_os.h" +#include "sxghw.h" +#include "sxghif.h" +#include "sxg.h" +//#include "sxg.c" +#include "saharadbgdownload.h" + +struct sxg_nic_stats { + char stat_string[ETH_GSTRING_LEN]; + int sizeof_stat; + int stat_offset; +}; + +#define SXG_NIC_STATS(m) sizeof(((struct adapter_t *)0)->m), \ + offsetof(struct adapter_t, m) + +#define USER_VIEWABLE_EEPROM_SIZE 28 + +static struct sxg_nic_stats sxg_nic_gstrings_stats[] = { + {"xmit_ring_0_full", SXG_NIC_STATS(Stats.XmtZeroFull)}, + + /* May be will need in future */ +/* {"dumb_xmit_broadcast_packets", SXG_NIC_STATS(Stats.DumbXmtBcastPkts)}, + {"dumb_xmit_broadcast_bytes", SXG_NIC_STATS(Stats.DumbXmtBcastBytes)}, + {"dumb_xmit_unicast_packets", SXG_NIC_STATS(Stats.DumbXmtUcastPkts)}, + {"dumb_xmit_unicast_bytes", SXG_NIC_STATS(Stats.DumbXmtUcastBytes)}, +*/ + {"xmit_queue_length", SXG_NIC_STATS(Stats.XmtQLen)}, + {"memory_allocation_failure", SXG_NIC_STATS(Stats.NoMem)}, + {"Interrupts", SXG_NIC_STATS(Stats.NumInts)}, + {"false_interrupts", SXG_NIC_STATS(Stats.FalseInts)}, + {"processed_data_queue_full", SXG_NIC_STATS(Stats.PdqFull)}, + {"event_ring_full", SXG_NIC_STATS(Stats.EventRingFull)}, + {"transport_checksum_error", SXG_NIC_STATS(Stats.TransportCsum)}, + {"transport_underflow_error", SXG_NIC_STATS(Stats.TransportUflow)}, + {"transport_header_length_error", SXG_NIC_STATS(Stats.TransportHdrLen)}, + {"network_checksum_error", SXG_NIC_STATS(Stats.NetworkCsum)}, + {"network_underflow_error", SXG_NIC_STATS(Stats.NetworkUflow)}, + {"network_header_length_error", SXG_NIC_STATS(Stats.NetworkHdrLen)}, + {"receive_parity_error", SXG_NIC_STATS(Stats.Parity)}, + {"link_parity_error", SXG_NIC_STATS(Stats.LinkParity)}, + {"link/data early_error", SXG_NIC_STATS(Stats.LinkEarly)}, + {"buffer_overflow_error", SXG_NIC_STATS(Stats.LinkBufOflow)}, + {"link_code_error", SXG_NIC_STATS(Stats.LinkCode)}, + {"dribble nibble", SXG_NIC_STATS(Stats.LinkDribble)}, + {"CRC_error", SXG_NIC_STATS(Stats.LinkCrc)}, + {"link_overflow_error", SXG_NIC_STATS(Stats.LinkOflow)}, + {"link_underflow_error", SXG_NIC_STATS(Stats.LinkUflow)}, + + /* May be need in future */ +/* {"dumb_rcv_broadcast_packets", SXG_NIC_STATS(Stats.DumbRcvBcastPkts)}, + {"dumb_rcv_broadcast_bytes", SXG_NIC_STATS(Stats.DumbRcvBcastBytes)}, + {"dumb_rcv_multicast_packets", SXG_NIC_STATS(Stats.DumbRcvMcastPkts)}, + {"dumb_rcv_multicast_bytes", SXG_NIC_STATS(Stats.DumbRcvMcastBytes)}, + {"dumb_rcv_unicast_packets", SXG_NIC_STATS(Stats.DumbRcvUcastPkts)}, + {"dumb_rcv_unicast_bytes", SXG_NIC_STATS(Stats.DumbRcvUcastBytes)}, +*/ + {"no_sgl_buffer", SXG_NIC_STATS(Stats.NoSglBuf)}, +}; + +#define SXG_NIC_STATS_LEN ARRAY_SIZE(sxg_nic_gstrings_stats) + +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_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) +{ + struct adapter_t *adapter = netdev_priv(dev); + strncpy(drvinfo->driver, sxg_driver_name, 32); + strncpy(drvinfo->version, SXG_DRV_VERSION, 32); + strncpy(drvinfo->fw_version, SAHARA_UCODE_VERS_STRING, 32); + strncpy(drvinfo->bus_info, pci_name(adapter->pcidev), 32); + /* TODO : Read the major and minor number of firmware. Is this + * from the FLASH/EEPROM or download file ? + */ + /* LINSYS : Check if this is correct or if not find the right value + * Also check what is the right EEPROM length : EEPROM_SIZE_XFMR or EEPROM_SIZE_NO_XFMR + */ +} + +static int sxg_nic_set_settings(struct net_device *netdev, + struct ethtool_cmd *ecmd) +{ + /* No settings are applicable as we support only 10Gb/FIBRE_media */ + return -EOPNOTSUPP; +} + +static int +sxg_nic_get_strings(struct net_device *netdev, u32 stringset, u8 * data) +{ + int index; + + switch(stringset) { + case ETH_SS_TEST: + return -EOPNOTSUPP; + break; + case ETH_SS_STATS: + for (index = 0; index < SXG_NIC_STATS_LEN; index++) { + memcpy(data + index * ETH_GSTRING_LEN, + sxg_nic_gstrings_stats[index].stat_string, + ETH_GSTRING_LEN); + } + break; + } +} + +static void +sxg_nic_get_ethtool_stats(struct net_device *netdev, + struct ethtool_stats *stats, u64 * data) +{ + struct adapter_t *adapter = netdev_priv(netdev); + int index; + for (index = 0; index < SXG_NIC_STATS_LEN; index++) { + char *p = (char *)adapter + + sxg_nic_gstrings_stats[index].stat_offset; + data[index] = (sxg_nic_gstrings_stats[index].sizeof_stat == + sizeof(u64)) ? *(u64 *) p : *(u32 *) p; + } +} + +static int sxg_nic_get_sset_count(struct net_device *netdev, int sset) +{ + switch (sset) { + case ETH_SS_STATS: + return SXG_NIC_STATS_LEN; + default: + return -EOPNOTSUPP; + } +} + +static int sxg_nic_get_settings(struct net_device *netdev, + struct ethtool_cmd *ecmd) +{ + struct adapter_t *adapter = netdev_priv(netdev); + + ecmd->supported = SUPPORTED_10000baseT_Full; + ecmd->autoneg = AUTONEG_ENABLE; //VSS check This + ecmd->transceiver = XCVR_EXTERNAL; //VSS check This + + /* For Fibre Channel */ + ecmd->supported |= SUPPORTED_FIBRE; + ecmd->advertising = (ADVERTISED_10000baseT_Full | + ADVERTISED_FIBRE); + ecmd->port = PORT_FIBRE; + + + /* Link Speed */ + if(adapter->LinkState & SXG_LINK_UP) { + ecmd->speed = SPEED_10000; //adapter->LinkSpeed; + ecmd->duplex = DUPLEX_FULL; + } + return 0; +} + +static int sxg_nic_get_rx_csum(struct net_device *netdev) +{ + struct adapter_t *adapter = netdev_priv(netdev); + return ((adapter->flags & SXG_RCV_IP_CSUM_ENABLED) || + (adapter->flags & SXG_RCV_TCP_CSUM_ENABLED)); +} + +static int sxg_nic_set_rx_csum(struct net_device *netdev, u32 data) +{ + struct adapter_t *adapter = netdev_priv(netdev); + if (data) + adapter->flags |= SXG_RCV_IP_CSUM_ENABLED; + else + adapter->flags &= ~SXG_RCV_IP_CSUM_ENABLED; + + /* Reset the card here (call the reset functions .. currently unavailable)*/ + + return 0; +} + +static int sxg_nic_get_regs_len(struct net_device *dev) +{ + return (SXG_HWREG_MEMSIZE + SXG_UCODEREG_MEMSIZE); +} + +static void sxg_nic_get_regs(struct net_device *netdev, + struct ethtool_regs *regs, void *p) +{ + struct adapter_t *adapter = netdev_priv(netdev); + struct sxg_hw_regs *HwRegs = adapter->HwRegs; + struct sxg_ucode_regs *UcodeRegs = adapter->UcodeRegs; + u32 *buff = p; + + memset(p, 0, (sizeof(struct sxg_hw_regs)+sizeof(struct sxg_ucode_regs))); + memcpy(buff, HwRegs, sizeof(struct sxg_hw_regs)); + memcpy((buff+sizeof(struct sxg_hw_regs)), UcodeRegs, sizeof(struct sxg_ucode_regs)); +} + +static int sxg_nic_get_wol(struct net_device *netdev, + struct ethtool_wolinfo *wol) +{ + /* We dont support wake-on-lan */ + return -EOPNOTSUPP; +} + +static int sxg_nic_get_eeprom_len(struct net_device *netdev) +{ + return (USER_VIEWABLE_EEPROM_SIZE); +} + +static int sxg_nic_get_eeprom(struct net_device *netdev, + struct ethtool_eeprom *eeprom, u8 *bytes) +{ + struct adapter_t *adapter = netdev_priv(netdev); + struct sw_cfg_data *data; + unsigned long i, status; + dma_addr_t p_addr; + + data = pci_alloc_consistent(adapter->pcidev, sizeof(struct sw_cfg_data), + &p_addr); + if(!data) { + /* + * 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", __FUNCTION__); + return -ENOMEM; + } + + WRITE_REG(adapter->UcodeRegs[0].ConfigStat, SXG_CFG_TIMEOUT, TRUE); + 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 */ + } + + memset(bytes, 0, eeprom->len); + memcpy(bytes, data->MacAddr[0].MacAddr, sizeof(struct sxg_config_mac)); + memcpy(bytes+6, data->AtkFru.PartNum, 6); + memcpy(bytes+12, data->AtkFru.Revision, 2); + memcpy(bytes+14, data->AtkFru.Serial, 14); + + return 0; +} + +struct ethtool_ops sxg_nic_ethtool_ops = { + .get_settings = sxg_nic_get_settings, + .set_settings = sxg_nic_set_settings, + .get_drvinfo = sxg_nic_get_drvinfo, + .get_regs_len = sxg_nic_get_regs_len, + .get_regs = sxg_nic_get_regs, + .get_link = ethtool_op_get_link, + .get_wol = sxg_nic_get_wol, + .get_eeprom_len = sxg_nic_get_eeprom_len, + .get_eeprom = sxg_nic_get_eeprom, +// .get_ringparam = sxg_nic_get_ringparam, +// .get_pauseparam = sxg_nic_get_pauseparam, +// .set_pauseparam = sxg_nic_set_pauseparam, + .set_tx_csum = ethtool_op_set_tx_csum, + .get_sg = ethtool_op_get_sg, + .set_sg = ethtool_op_set_sg, +// .get_tso = sxg_nic_get_tso, +// .set_tso = sxg_nic_set_tso, +// .self_test = sxg_nic_diag_test, + .get_strings = sxg_nic_get_strings, + .get_ethtool_stats = sxg_nic_get_ethtool_stats, + .get_sset_count = sxg_nic_get_sset_count, + .get_rx_csum = sxg_nic_get_rx_csum, + .set_rx_csum = sxg_nic_set_rx_csum, +// .get_coalesce = sxg_nic_get_intr_coalesce, +// .set_coalesce = sxg_nic_set_intr_coalesce, +}; diff --git a/drivers/staging/sxg/sxghif.h b/drivers/staging/sxg/sxghif.h index b9e6da9b8ba..5a9e2712c89 100644 --- a/drivers/staging/sxg/sxghif.h +++ b/drivers/staging/sxg/sxghif.h @@ -9,6 +9,8 @@ * Alacritech Sahara host interface ******************************************************************/ +#define DBG 1 + /* UCODE Registers */ struct sxg_ucode_regs { /* Address 0 - 0x3F = Command codes 0-15 for TCB 0. Excode 0 */ |