diff options
Diffstat (limited to 'drivers/net/netxen')
-rw-r--r-- | drivers/net/netxen/netxen_nic.h | 153 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_ethtool.c | 118 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_hw.c | 43 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_hw.h | 74 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_init.c | 294 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_isr.c | 4 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_main.c | 8 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_niu.c | 106 |
8 files changed, 566 insertions, 234 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index 59324b1..3f3896e 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h @@ -63,11 +63,14 @@ #include "netxen_nic_hw.h" -#define NETXEN_NIC_BUILD_NO "2" #define _NETXEN_NIC_LINUX_MAJOR 3 #define _NETXEN_NIC_LINUX_MINOR 3 #define _NETXEN_NIC_LINUX_SUBVERSION 3 -#define NETXEN_NIC_LINUX_VERSIONID "3.3.3" "-" NETXEN_NIC_BUILD_NO +#define NETXEN_NIC_LINUX_VERSIONID "3.3.3" + +#define NUM_FLASH_SECTORS (64) +#define FLASH_SECTOR_SIZE (64 * 1024) +#define FLASH_TOTAL_SIZE (NUM_FLASH_SECTORS * FLASH_SECTOR_SIZE) #define RCV_DESC_RINGSIZE \ (sizeof(struct rcv_desc) * adapter->max_rx_desc_count) @@ -85,6 +88,7 @@ #define NETXEN_RCV_PRODUCER_OFFSET 0 #define NETXEN_RCV_PEG_DB_ID 2 #define NETXEN_HOST_DUMMY_DMA_SIZE 1024 +#define FLASH_SUCCESS 0 #define ADDR_IN_WINDOW1(off) \ ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0 @@ -239,49 +243,39 @@ extern unsigned long long netxen_dma_mask; typedef u32 netxen_ctx_msg; -#define _netxen_set_bits(config_word, start, bits, val) {\ - unsigned long long mask = (((1ULL << (bits)) - 1) << (start)); \ - unsigned long long value = (val); \ - (config_word) &= ~mask; \ - (config_word) |= (((value) << (start)) & mask); \ -} - #define netxen_set_msg_peg_id(config_word, val) \ - _netxen_set_bits(config_word, 0, 2, val) + ((config_word) &= ~3, (config_word) |= val & 3) #define netxen_set_msg_privid(config_word) \ - set_bit(2, (unsigned long*)&config_word) + ((config_word) |= 1 << 2) #define netxen_set_msg_count(config_word, val) \ - _netxen_set_bits(config_word, 3, 15, val) + ((config_word) &= ~(0x7fff<<3), (config_word) |= (val & 0x7fff) << 3) #define netxen_set_msg_ctxid(config_word, val) \ - _netxen_set_bits(config_word, 18, 10, val) + ((config_word) &= ~(0x3ff<<18), (config_word) |= (val & 0x3ff) << 18) #define netxen_set_msg_opcode(config_word, val) \ - _netxen_set_bits(config_word, 28, 4, val) + ((config_word) &= ~(0xf<<24), (config_word) |= (val & 0xf) << 24) struct netxen_rcv_context { - u32 rcv_ring_addr_lo; - u32 rcv_ring_addr_hi; - u32 rcv_ring_size; - u32 rsrvd; + __le64 rcv_ring_addr; + __le32 rcv_ring_size; + __le32 rsrvd; }; struct netxen_ring_ctx { /* one command ring */ - u64 cmd_consumer_offset; - u32 cmd_ring_addr_lo; - u32 cmd_ring_addr_hi; - u32 cmd_ring_size; - u32 rsrvd; + __le64 cmd_consumer_offset; + __le64 cmd_ring_addr; + __le32 cmd_ring_size; + __le32 rsrvd; /* three receive rings */ struct netxen_rcv_context rcv_ctx[3]; /* one status ring */ - u32 sts_ring_addr_lo; - u32 sts_ring_addr_hi; - u32 sts_ring_size; + __le64 sts_ring_addr; + __le32 sts_ring_size; - u32 ctx_id; + __le32 ctx_id; } __attribute__ ((aligned(64))); /* @@ -305,81 +299,85 @@ struct netxen_ring_ctx { ((cmd_desc)->port_ctxid |= ((var) & 0x0F)) #define netxen_set_cmd_desc_flags(cmd_desc, val) \ - _netxen_set_bits((cmd_desc)->flags_opcode, 0, 7, val) + ((cmd_desc)->flags_opcode &= ~cpu_to_le16(0x7f), \ + (cmd_desc)->flags_opcode |= cpu_to_le16((val) & 0x7f)) #define netxen_set_cmd_desc_opcode(cmd_desc, val) \ - _netxen_set_bits((cmd_desc)->flags_opcode, 7, 6, val) + ((cmd_desc)->flags_opcode &= ~cpu_to_le16(0x3f<<7), \ + (cmd_desc)->flags_opcode |= cpu_to_le16((val) & (0x3f<<7))) #define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \ - _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 0, 8, val); + ((cmd_desc)->num_of_buffers_total_length &= ~cpu_to_le32(0xff), \ + (cmd_desc)->num_of_buffers_total_length |= cpu_to_le32((val) & 0xff)) #define netxen_set_cmd_desc_totallength(cmd_desc, val) \ - _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 8, 24, val); + ((cmd_desc)->num_of_buffers_total_length &= cpu_to_le32(0xff), \ + (cmd_desc)->num_of_buffers_total_length |= cpu_to_le32(val << 24)) #define netxen_get_cmd_desc_opcode(cmd_desc) \ - (((cmd_desc)->flags_opcode >> 7) & 0x003F) + ((le16_to_cpu((cmd_desc)->flags_opcode) >> 7) & 0x003F) #define netxen_get_cmd_desc_totallength(cmd_desc) \ - (((cmd_desc)->num_of_buffers_total_length >> 8) & 0x0FFFFFF) + (le32_to_cpu((cmd_desc)->num_of_buffers_total_length) >> 8) struct cmd_desc_type0 { u8 tcp_hdr_offset; /* For LSO only */ u8 ip_hdr_offset; /* For LSO only */ /* Bit pattern: 0-6 flags, 7-12 opcode, 13-15 unused */ - u16 flags_opcode; + __le16 flags_opcode; /* Bit pattern: 0-7 total number of segments, 8-31 Total size of the packet */ - u32 num_of_buffers_total_length; + __le32 num_of_buffers_total_length; union { struct { - u32 addr_low_part2; - u32 addr_high_part2; + __le32 addr_low_part2; + __le32 addr_high_part2; }; - u64 addr_buffer2; + __le64 addr_buffer2; }; - u16 reference_handle; /* changed to u16 to add mss */ - u16 mss; /* passed by NDIS_PACKET for LSO */ + __le16 reference_handle; /* changed to u16 to add mss */ + __le16 mss; /* passed by NDIS_PACKET for LSO */ /* Bit pattern 0-3 port, 0-3 ctx id */ u8 port_ctxid; u8 total_hdr_length; /* LSO only : MAC+IP+TCP Hdr size */ - u16 conn_id; /* IPSec offoad only */ + __le16 conn_id; /* IPSec offoad only */ union { struct { - u32 addr_low_part3; - u32 addr_high_part3; + __le32 addr_low_part3; + __le32 addr_high_part3; }; - u64 addr_buffer3; + __le64 addr_buffer3; }; union { struct { - u32 addr_low_part1; - u32 addr_high_part1; + __le32 addr_low_part1; + __le32 addr_high_part1; }; - u64 addr_buffer1; + __le64 addr_buffer1; }; - u16 buffer1_length; - u16 buffer2_length; - u16 buffer3_length; - u16 buffer4_length; + __le16 buffer1_length; + __le16 buffer2_length; + __le16 buffer3_length; + __le16 buffer4_length; union { struct { - u32 addr_low_part4; - u32 addr_high_part4; + __le32 addr_low_part4; + __le32 addr_high_part4; }; - u64 addr_buffer4; + __le64 addr_buffer4; }; - u64 unused; + __le64 unused; } __attribute__ ((aligned(64))); /* Note: sizeof(rcv_desc) should always be a mutliple of 2 */ struct rcv_desc { - u16 reference_handle; - u16 reserved; - u32 buffer_length; /* allocated buffer length (usually 2K) */ - u64 addr_buffer; + __le16 reference_handle; + __le16 reserved; + __le32 buffer_length; /* allocated buffer length (usually 2K) */ + __le64 addr_buffer; }; /* opcode field in status_desc */ @@ -405,36 +403,36 @@ struct rcv_desc { (((status_desc)->lro & 0x80) >> 7) #define netxen_get_sts_port(status_desc) \ - ((status_desc)->status_desc_data & 0x0F) + (le64_to_cpu((status_desc)->status_desc_data) & 0x0F) #define netxen_get_sts_status(status_desc) \ - (((status_desc)->status_desc_data >> 4) & 0x0F) + ((le64_to_cpu((status_desc)->status_desc_data) >> 4) & 0x0F) #define netxen_get_sts_type(status_desc) \ - (((status_desc)->status_desc_data >> 8) & 0x0F) + ((le64_to_cpu((status_desc)->status_desc_data) >> 8) & 0x0F) #define netxen_get_sts_totallength(status_desc) \ - (((status_desc)->status_desc_data >> 12) & 0xFFFF) + ((le64_to_cpu((status_desc)->status_desc_data) >> 12) & 0xFFFF) #define netxen_get_sts_refhandle(status_desc) \ - (((status_desc)->status_desc_data >> 28) & 0xFFFF) + ((le64_to_cpu((status_desc)->status_desc_data) >> 28) & 0xFFFF) #define netxen_get_sts_prot(status_desc) \ - (((status_desc)->status_desc_data >> 44) & 0x0F) + ((le64_to_cpu((status_desc)->status_desc_data) >> 44) & 0x0F) #define netxen_get_sts_owner(status_desc) \ - (((status_desc)->status_desc_data >> 56) & 0x03) + ((le64_to_cpu((status_desc)->status_desc_data) >> 56) & 0x03) #define netxen_get_sts_opcode(status_desc) \ - (((status_desc)->status_desc_data >> 58) & 0x03F) + ((le64_to_cpu((status_desc)->status_desc_data) >> 58) & 0x03F) #define netxen_clear_sts_owner(status_desc) \ ((status_desc)->status_desc_data &= \ - ~(((unsigned long long)3) << 56 )) + ~cpu_to_le64(((unsigned long long)3) << 56 )) #define netxen_set_sts_owner(status_desc, val) \ ((status_desc)->status_desc_data |= \ - (((unsigned long long)((val) & 0x3)) << 56 )) + cpu_to_le64(((unsigned long long)((val) & 0x3)) << 56 )) struct status_desc { /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length 28-43 reference_handle, 44-47 protocol, 48-52 unused 53-55 desc_cnt, 56-57 owner, 58-63 opcode */ - u64 status_desc_data; - u32 hash_value; + __le64 status_desc_data; + __le32 hash_value; u8 hash_type; u8 msg_type; u8 unused; @@ -1005,9 +1003,9 @@ void netxen_niu_gbe_set_mii_mode(struct netxen_adapter *adapter, int port, void netxen_niu_gbe_set_gmii_mode(struct netxen_adapter *adapter, int port, long enable); int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy, long reg, - __le32 * readval); + __u32 * readval); int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long phy, - long reg, __le32 val); + long reg, __u32 val); /* Functions available from netxen_nic_hw.c */ int netxen_nic_set_mtu_xgb(struct netxen_port *port, int new_mtu); @@ -1034,6 +1032,15 @@ void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val); void netxen_load_firmware(struct netxen_adapter *adapter); int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose); int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp); +int netxen_rom_fast_read_words(struct netxen_adapter *adapter, int addr, + u8 *bytes, size_t size); +int netxen_rom_fast_write_words(struct netxen_adapter *adapter, int addr, + u8 *bytes, size_t size); +int netxen_flash_unlock(struct netxen_adapter *adapter); +int netxen_backup_crbinit(struct netxen_adapter *adapter); +int netxen_flash_erase_secondary(struct netxen_adapter *adapter); +int netxen_flash_erase_primary(struct netxen_adapter *adapter); + int netxen_rom_fast_write(struct netxen_adapter *adapter, int addr, int data); int netxen_rom_se(struct netxen_adapter *adapter, int addr); int netxen_do_rom_se(struct netxen_adapter *adapter, int addr); diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c index 3404461..cc0efe2 100644 --- a/drivers/net/netxen/netxen_nic_ethtool.c +++ b/drivers/net/netxen/netxen_nic_ethtool.c @@ -32,6 +32,7 @@ */ #include <linux/types.h> +#include <linux/delay.h> #include <asm/uaccess.h> #include <linux/pci.h> #include <asm/io.h> @@ -94,17 +95,7 @@ static const char netxen_nic_gstrings_test[][ETH_GSTRING_LEN] = { static int netxen_nic_get_eeprom_len(struct net_device *dev) { - struct netxen_port *port = netdev_priv(dev); - struct netxen_adapter *adapter = port->adapter; - int n; - - if ((netxen_rom_fast_read(adapter, 0, &n) == 0) - && (n & NETXEN_ROM_ROUNDUP)) { - n &= ~NETXEN_ROM_ROUNDUP; - if (n < NETXEN_MAX_EEPROM_LEN) - return n; - } - return 0; + return FLASH_TOTAL_SIZE; } static void @@ -218,7 +209,7 @@ netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) { struct netxen_port *port = netdev_priv(dev); struct netxen_adapter *adapter = port->adapter; - __le32 status; + __u32 status; /* read which mode */ if (adapter->ahw.board_type == NETXEN_NIC_GBE) { @@ -226,7 +217,7 @@ netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) if (adapter->phy_write && adapter->phy_write(adapter, port->portnum, NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, - (__le32) ecmd->autoneg) != 0) + ecmd->autoneg) != 0) return -EIO; else port->link_autoneg = ecmd->autoneg; @@ -279,7 +270,7 @@ static int netxen_nic_get_regs_len(struct net_device *dev) } struct netxen_niu_regs { - __le32 reg[NETXEN_NIC_REGS_COUNT]; + __u32 reg[NETXEN_NIC_REGS_COUNT]; }; static struct netxen_niu_regs niu_registers[] = { @@ -372,7 +363,7 @@ netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) { struct netxen_port *port = netdev_priv(dev); struct netxen_adapter *adapter = port->adapter; - __le32 mode, *regs_buff = p; + __u32 mode, *regs_buff = p; void __iomem *addr; int i, window; @@ -415,7 +406,7 @@ static u32 netxen_nic_get_link(struct net_device *dev) { struct netxen_port *port = netdev_priv(dev); struct netxen_adapter *adapter = port->adapter; - __le32 status; + __u32 status; /* read which mode */ if (adapter->ahw.board_type == NETXEN_NIC_GBE) { @@ -440,18 +431,92 @@ netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, struct netxen_port *port = netdev_priv(dev); struct netxen_adapter *adapter = port->adapter; int offset; + int ret; if (eeprom->len == 0) return -EINVAL; eeprom->magic = (port->pdev)->vendor | ((port->pdev)->device << 16); - for (offset = 0; offset < eeprom->len; offset++) - if (netxen_rom_fast_read - (adapter, (8 * offset) + 8, (int *)eeprom->data) == -1) - return -EIO; + offset = eeprom->offset; + + ret = netxen_rom_fast_read_words(adapter, offset, bytes, + eeprom->len); + if (ret < 0) + return ret; + return 0; } +static int +netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, + u8 * bytes) +{ + struct netxen_port *port = netdev_priv(dev); + struct netxen_adapter *adapter = port->adapter; + int offset = eeprom->offset; + static int flash_start; + static int ready_to_flash; + int ret; + + if (flash_start == 0) { + ret = netxen_flash_unlock(adapter); + if (ret < 0) { + printk(KERN_ERR "%s: Flash unlock failed.\n", + netxen_nic_driver_name); + return ret; + } + printk(KERN_INFO "%s: flash unlocked. \n", + netxen_nic_driver_name); + ret = netxen_flash_erase_secondary(adapter); + if (ret != FLASH_SUCCESS) { + printk(KERN_ERR "%s: Flash erase failed.\n", + netxen_nic_driver_name); + return ret; + } + printk(KERN_INFO "%s: secondary flash erased successfully.\n", + netxen_nic_driver_name); + flash_start = 1; + return 0; + } + + if (offset == BOOTLD_START) { + ret = netxen_flash_erase_primary(adapter); + if (ret != FLASH_SUCCESS) { + printk(KERN_ERR "%s: Flash erase failed.\n", + netxen_nic_driver_name); + return ret; + } + + ret = netxen_rom_se(adapter, USER_START); + if (ret != FLASH_SUCCESS) + return ret; + ret = netxen_rom_se(adapter, FIXED_START); + if (ret != FLASH_SUCCESS) + return ret; + + printk(KERN_INFO "%s: primary flash erased successfully\n", + netxen_nic_driver_name); + + ret = netxen_backup_crbinit(adapter); + if (ret != FLASH_SUCCESS) { + printk(KERN_ERR "%s: CRBinit backup failed.\n", + netxen_nic_driver_name); + return ret; + } + printk(KERN_INFO "%s: CRBinit backup done.\n", + netxen_nic_driver_name); + ready_to_flash = 1; + } + + if (!ready_to_flash) { + printk(KERN_ERR "%s: Invalid write sequence, returning...\n", + netxen_nic_driver_name); + return -EINVAL; + } + + return netxen_rom_fast_write_words(adapter, offset, bytes, eeprom->len); +} + static void netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) { @@ -482,13 +547,13 @@ netxen_nic_get_pauseparam(struct net_device *dev, { struct netxen_port *port = netdev_priv(dev); struct netxen_adapter *adapter = port->adapter; - __le32 val; + __u32 val; if (adapter->ahw.board_type == NETXEN_NIC_GBE) { /* get flow control settings */ netxen_nic_read_w0(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum), - (u32 *) & val); + &val); pause->rx_pause = netxen_gb_get_rx_flowctl(val); pause->tx_pause = netxen_gb_get_tx_flowctl(val); /* get autoneg settings */ @@ -502,7 +567,7 @@ netxen_nic_set_pauseparam(struct net_device *dev, { struct netxen_port *port = netdev_priv(dev); struct netxen_adapter *adapter = port->adapter; - __le32 val; + __u32 val; unsigned int autoneg; /* read mode */ @@ -522,13 +587,13 @@ netxen_nic_set_pauseparam(struct net_device *dev, netxen_nic_write_w0(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum), - *(u32 *) (&val)); + *&val); /* set autoneg */ autoneg = pause->autoneg; if (adapter->phy_write && adapter->phy_write(adapter, port->portnum, NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, - (__le32) autoneg) != 0) + autoneg) != 0) return -EIO; else { port->link_autoneg = pause->autoneg; @@ -543,7 +608,7 @@ static int netxen_nic_reg_test(struct net_device *dev) struct netxen_port *port = netdev_priv(dev); struct netxen_adapter *adapter = port->adapter; u32 data_read, data_written, save; - __le32 mode; + __u32 mode; /* * first test the "Read Only" registers by writing which mode @@ -721,6 +786,7 @@ struct ethtool_ops netxen_nic_ethtool_ops = { .get_link = netxen_nic_get_link, .get_eeprom_len = netxen_nic_get_eeprom_len, .get_eeprom = netxen_nic_get_eeprom, + .set_eeprom = netxen_nic_set_eeprom, .get_ringparam = netxen_nic_get_ringparam, .get_pauseparam = netxen_nic_get_pauseparam, .set_pauseparam = netxen_nic_set_pauseparam, diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index 191e233..f263232 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c @@ -95,7 +95,7 @@ void netxen_nic_set_multi(struct net_device *netdev) struct netxen_port *port = netdev_priv(netdev); struct netxen_adapter *adapter = port->adapter; struct dev_mc_list *mc_ptr; - __le32 netxen_mac_addr_cntl_data = 0; + __u32 netxen_mac_addr_cntl_data = 0; mc_ptr = netdev->mc_list; if (netdev->flags & IFF_PROMISC) { @@ -236,8 +236,9 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) } memset(addr, 0, sizeof(struct netxen_ring_ctx)); adapter->ctx_desc = (struct netxen_ring_ctx *)addr; - adapter->ctx_desc->cmd_consumer_offset = adapter->ctx_desc_phys_addr - + sizeof(struct netxen_ring_ctx); + adapter->ctx_desc->cmd_consumer_offset = + cpu_to_le64(adapter->ctx_desc_phys_addr + + sizeof(struct netxen_ring_ctx)); adapter->cmd_consumer = (uint32_t *) (((char *)addr) + sizeof(struct netxen_ring_ctx)); @@ -253,11 +254,10 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) return -ENOMEM; } - adapter->ctx_desc->cmd_ring_addr_lo = - hw->cmd_desc_phys_addr & 0xffffffffUL; - adapter->ctx_desc->cmd_ring_addr_hi = - ((u64) hw->cmd_desc_phys_addr >> 32); - adapter->ctx_desc->cmd_ring_size = adapter->max_tx_desc_count; + adapter->ctx_desc->cmd_ring_addr = + cpu_to_le64(hw->cmd_desc_phys_addr); + adapter->ctx_desc->cmd_ring_size = + cpu_to_le32(adapter->max_tx_desc_count); hw->cmd_desc_head = (struct cmd_desc_type0 *)addr; @@ -278,12 +278,10 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) return err; } rcv_desc->desc_head = (struct rcv_desc *)addr; - adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr_lo = - rcv_desc->phys_addr & 0xffffffffUL; - adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr_hi = - ((u64) rcv_desc->phys_addr >> 32); + adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr = + cpu_to_le64(rcv_desc->phys_addr); adapter->ctx_desc->rcv_ctx[ring].rcv_ring_size = - rcv_desc->max_rx_desc_count; + cpu_to_le32(rcv_desc->max_rx_desc_count); } addr = netxen_alloc(adapter->ahw.pdev, STATUS_DESC_RINGSIZE, @@ -297,11 +295,10 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) return err; } recv_ctx->rcv_status_desc_head = (struct status_desc *)addr; - adapter->ctx_desc->sts_ring_addr_lo = - recv_ctx->rcv_status_desc_phys_addr & 0xffffffffUL; - adapter->ctx_desc->sts_ring_addr_hi = - ((u64) recv_ctx->rcv_status_desc_phys_addr >> 32); - adapter->ctx_desc->sts_ring_size = adapter->max_rx_desc_count; + adapter->ctx_desc->sts_ring_addr = + cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr); + adapter->ctx_desc->sts_ring_size = + cpu_to_le32(adapter->max_rx_desc_count); } /* Window = 1 */ @@ -387,10 +384,6 @@ void netxen_tso_check(struct netxen_adapter *adapter, } adapter->stats.xmitcsummed++; desc->tcp_hdr_offset = skb->h.raw - skb->data; - netxen_set_cmd_desc_totallength(desc, - cpu_to_le32 - (netxen_get_cmd_desc_totallength - (desc))); desc->ip_hdr_offset = skb->nh.raw - skb->data; } @@ -867,9 +860,9 @@ netxen_crb_writelit_adapter(struct netxen_adapter *adapter, unsigned long off, void netxen_nic_set_link_parameters(struct netxen_port *port) { struct netxen_adapter *adapter = port->adapter; - __le32 status; - __le32 autoneg; - __le32 mode; + __u32 status; + __u32 autoneg; + __u32 mode; netxen_nic_read_w0(adapter, NETXEN_NIU_MODE, &mode); if (netxen_get_niu_enable_ge(mode)) { /* Gb 10/100/1000 Mbps mode */ diff --git a/drivers/net/netxen/netxen_nic_hw.h b/drivers/net/netxen/netxen_nic_hw.h index 0685633..ab1112eb 100644 --- a/drivers/net/netxen/netxen_nic_hw.h +++ b/drivers/net/netxen/netxen_nic_hw.h @@ -124,28 +124,28 @@ typedef enum { */ #define netxen_gb_enable_tx(config_word) \ - set_bit(0, (unsigned long*)(&config_word)) + ((config_word) |= 1 << 0) #define netxen_gb_enable_rx(config_word) \ - set_bit(2, (unsigned long*)(&config_word)) + ((config_word) |= 1 << 2) #define netxen_gb_tx_flowctl(config_word) \ - set_bit(4, (unsigned long*)(&config_word)) + ((config_word) |= 1 << 4) #define netxen_gb_rx_flowctl(config_word) \ - set_bit(5, (unsigned long*)(&config_word)) + ((config_word) |= 1 << 5) #define netxen_gb_tx_reset_pb(config_word) \ - set_bit(16, (unsigned long*)(&config_word)) + ((config_word) |= 1 << 16) #define netxen_gb_rx_reset_pb(config_word) \ - set_bit(17, (unsigned long*)(&config_word)) + ((config_word) |= 1 << 17) #define netxen_gb_tx_reset_mac(config_word) \ - set_bit(18, (unsigned long*)(&config_word)) + ((config_word) |= 1 << 18) #define netxen_gb_rx_reset_mac(config_word) \ - set_bit(19, (unsigned long*)(&config_word)) + ((config_word) |= 1 << 19) #define netxen_gb_soft_reset(config_word) \ - set_bit(31, (unsigned long*)(&config_word)) + ((config_word) |= 1 << 31) #define netxen_gb_unset_tx_flowctl(config_word) \ - clear_bit(4, (unsigned long *)(&config_word)) + ((config_word) &= ~(1 << 4)) #define netxen_gb_unset_rx_flowctl(config_word) \ - clear_bit(5, (unsigned long*)(&config_word)) + ((config_word) &= ~(1 << 5)) #define netxen_gb_get_tx_synced(config_word) \ _netxen_crb_get_bit((config_word), 1) @@ -171,15 +171,15 @@ typedef enum { */ #define netxen_gb_set_duplex(config_word) \ - set_bit(0, (unsigned long*)&config_word) + ((config_word) |= 1 << 0) #define netxen_gb_set_crc_enable(config_word) \ - set_bit(1, (unsigned long*)&config_word) + ((config_word) |= 1 << 1) #define netxen_gb_set_padshort(config_word) \ - set_bit(2, (unsigned long*)&config_word) + ((config_word) |= 1 << 2) #define netxen_gb_set_checklength(config_word) \ - set_bit(4, (unsigned long*)&config_word) + ((config_word) |= 1 << 4) #define netxen_gb_set_hugeframes(config_word) \ - set_bit(5, (unsigned long*)&config_word) + ((config_word) |= 1 << 5) #define netxen_gb_set_preamblelen(config_word, val) \ ((config_word) |= ((val) << 12) & 0xF000) #define netxen_gb_set_intfmode(config_word, val) \ @@ -190,9 +190,9 @@ typedef enum { #define netxen_gb_set_mii_mgmt_clockselect(config_word, val) \ ((config_word) |= ((val) & 0x07)) #define netxen_gb_mii_mgmt_reset(config_word) \ - set_bit(31, (unsigned long*)&config_word) + ((config_word) |= 1 << 31) #define netxen_gb_mii_mgmt_unset(config_word) \ - clear_bit(31, (unsigned long*)&config_word) + ((config_word) &= ~(1 << 31)) /* * NIU GB MII Mgmt Command Register (applies to GB0, GB1, GB2, GB3) @@ -201,7 +201,7 @@ typedef enum { */ #define netxen_gb_mii_mgmt_set_read_cycle(config_word) \ - set_bit(0, (unsigned long*)&config_word) + ((config_word) |= 1 << 0) #define netxen_gb_mii_mgmt_reg_addr(config_word, val) \ ((config_word) |= ((val) & 0x1F)) #define netxen_gb_mii_mgmt_phy_addr(config_word, val) \ @@ -274,9 +274,9 @@ typedef enum { #define netxen_set_phy_speed(config_word, val) \ ((config_word) |= ((val & 0x03) << 14)) #define netxen_set_phy_duplex(config_word) \ - set_bit(13, (unsigned long*)&config_word) + ((config_word) |= 1 << 13) #define netxen_clear_phy_duplex(config_word) \ - clear_bit(13, (unsigned long*)&config_word) + ((config_word) &= ~(1 << 13)) #define netxen_get_phy_jabber(config_word) \ _netxen_crb_get_bit(config_word, 0) @@ -350,11 +350,11 @@ typedef enum { _netxen_crb_get_bit(config_word, 15) #define netxen_set_phy_int_link_status_changed(config_word) \ - set_bit(10, (unsigned long*)&config_word) + ((config_word) |= 1 << 10) #define netxen_set_phy_int_autoneg_completed(config_word) \ - set_bit(11, (unsigned long*)&config_word) + ((config_word) |= 1 << 11) #define netxen_set_phy_int_speed_changed(config_word) \ - set_bit(14, (unsigned long*)&config_word) + ((config_word) |= 1 << 14) /* * NIU Mode Register. @@ -382,22 +382,22 @@ typedef enum { */ #define netxen_set_gb_drop_gb0(config_word) \ - set_bit(0, (unsigned long*)&config_word) + ((config_word) |= 1 << 0) #define netxen_set_gb_drop_gb1(config_word) \ - set_bit(1, (unsigned long*)&config_word) + ((config_word) |= 1 << 1) #define netxen_set_gb_drop_gb2(config_word) \ - set_bit(2, (unsigned long*)&config_word) + ((config_word) |= 1 << 2) #define netxen_set_gb_drop_gb3(config_word) \ - set_bit(3, (unsigned long*)&config_word) + ((config_word) |= 1 << 3) #define netxen_clear_gb_drop_gb0(config_word) \ - clear_bit(0, (unsigned long*)&config_word) + ((config_word) &= ~(1 << 0)) #define netxen_clear_gb_drop_gb1(config_word) \ - clear_bit(1, (unsigned long*)&config_word) + ((config_word) &= ~(1 << 1)) #define netxen_clear_gb_drop_gb2(config_word) \ - clear_bit(2, (unsigned long*)&config_word) + ((config_word) &= ~(1 << 2)) #define netxen_clear_gb_drop_gb3(config_word) \ - clear_bit(3, (unsigned long*)&config_word) + ((config_word) &= ~(1 << 3)) /* * NIU XG MAC Config Register @@ -413,7 +413,7 @@ typedef enum { */ #define netxen_xg_soft_reset(config_word) \ - set_bit(4, (unsigned long*)&config_word) + ((config_word) |= 1 << 4) /* * MAC Control Register @@ -433,19 +433,19 @@ typedef enum { #define netxen_nic_mcr_set_id_pool0(config, val) \ ((config) |= ((val) &0x03)) #define netxen_nic_mcr_set_enable_xtnd0(config) \ - (set_bit(3, (unsigned long *)&(config))) + ((config) |= 1 << 3) #define netxen_nic_mcr_set_id_pool1(config, val) \ ((config) |= (((val) & 0x03) << 4)) #define netxen_nic_mcr_set_enable_xtnd1(config) \ - (set_bit(6, (unsigned long *)&(config))) + ((config) |= 1 << 6) #define netxen_nic_mcr_set_id_pool2(config, val) \ ((config) |= (((val) & 0x03) << 8)) #define netxen_nic_mcr_set_enable_xtnd2(config) \ - (set_bit(10, (unsigned long *)&(config))) + ((config) |= 1 << 10) #define netxen_nic_mcr_set_id_pool3(config, val) \ ((config) |= (((val) & 0x03) << 12)) #define netxen_nic_mcr_set_enable_xtnd3(config) \ - (set_bit(14, (unsigned long *)&(config))) + ((config) |= 1 << 14) #define netxen_nic_mcr_set_mode_select(config, val) \ ((config) |= (((val) & 0x03) << 24)) #define netxen_nic_mcr_set_enable_pool(config, val) \ diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index c3e41f3..f7bb8c9 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c @@ -110,6 +110,7 @@ static void crb_addr_transform_setup(void) crb_addr_transform(CAM); crb_addr_transform(C2C1); crb_addr_transform(C2C0); + crb_addr_transform(SMB); } int netxen_init_firmware(struct netxen_adapter *adapter) @@ -276,6 +277,7 @@ unsigned long netxen_decode_crb_addr(unsigned long addr) static long rom_max_timeout = 10000; static long rom_lock_timeout = 1000000; +static long rom_write_timeout = 700; static inline int rom_lock(struct netxen_adapter *adapter) { @@ -404,7 +406,7 @@ do_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp) { netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr); netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3); - udelay(100); /* prevent bursting on CRB */ + udelay(70); /* prevent bursting on CRB */ netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0); netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, 0xb); if (netxen_wait_rom_done(adapter)) { @@ -413,13 +415,46 @@ do_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp) } /* reset abyte_cnt and dummy_byte_cnt */ netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0); - udelay(100); /* prevent bursting on CRB */ + udelay(70); /* prevent bursting on CRB */ netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0); *valp = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_ROM_RDATA); return 0; } +static inline int +do_rom_fast_read_words(struct netxen_adapter *adapter, int addr, + u8 *bytes, size_t size) +{ + int addridx; + int ret = 0; + + for (addridx = addr; addridx < (addr + size); addridx += 4) { + ret = do_rom_fast_read(adapter, addridx, (int *)bytes); + if (ret != 0) + break; + bytes += 4; + } + + return ret; +} + +int +netxen_rom_fast_read_words(struct netxen_adapter *adapter, int addr, + u8 *bytes, size_t size) +{ + int ret; + + ret = rom_lock(adapter); + if (ret < 0) + return ret; + + ret = do_rom_fast_read_words(adapter, addr, bytes, size); + + netxen_rom_unlock(adapter); + return ret; +} + int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp) { int ret; @@ -443,6 +478,152 @@ int netxen_rom_fast_write(struct netxen_adapter *adapter, int addr, int data) netxen_rom_unlock(adapter); return ret; } + +static inline int do_rom_fast_write_words(struct netxen_adapter *adapter, + int addr, u8 *bytes, size_t size) +{ + int addridx = addr; + int ret = 0; + + while (addridx < (addr + size)) { + int last_attempt = 0; + int timeout = 0; + int data; + + data = *(u32*)bytes; + + ret = do_rom_fast_write(adapter, addridx, data); + if (ret < 0) + return ret; + + while(1) { + int data1; + + do_rom_fast_read(adapter, addridx, &data1); + if (data1 == data) + break; + + if (timeout++ >= rom_write_timeout) { + if (last_attempt++ < 4) { + ret = do_rom_fast_write(adapter, + addridx, data); + if (ret < 0) + return ret; + } + else { + printk(KERN_INFO "Data write did not " + "succeed at address 0x%x\n", addridx); + break; + } + } + } + + bytes += 4; + addridx += 4; + } + + return ret; +} + +int netxen_rom_fast_write_words(struct netxen_adapter *adapter, int addr, + u8 *bytes, size_t size) +{ + int ret = 0; + + ret = rom_lock(adapter); + if (ret < 0) + return ret; + + ret = do_rom_fast_write_words(adapter, addr, bytes, size); + netxen_rom_unlock(adapter); + + return ret; +} + +int netxen_rom_wrsr(struct netxen_adapter *adapter, int data) +{ + int ret; + + ret = netxen_rom_wren(adapter); + if (ret < 0) + return ret; + + netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_ROM_WDATA, data); + netxen_crb_writelit_adapter(adapter, + NETXEN_ROMUSB_ROM_INSTR_OPCODE, 0x1); + + ret = netxen_wait_rom_done(adapter); + if (ret < 0) + return ret; + + return netxen_rom_wip_poll(adapter); +} + +int netxen_rom_rdsr(struct netxen_adapter *adapter) +{ + int ret; + + ret = rom_lock(adapter); + if (ret < 0) + return ret; + + ret = netxen_do_rom_rdsr(adapter); + netxen_rom_unlock(adapter); + return ret; +} + +int netxen_backup_crbinit(struct netxen_adapter *adapter) +{ + int ret = FLASH_SUCCESS; + int val; + char *buffer = kmalloc(FLASH_SECTOR_SIZE, GFP_KERNEL); + + if (!buffer) + return -ENOMEM; + /* unlock sector 63 */ + val = netxen_rom_rdsr(adapter); + val = val & 0xe3; + ret = netxen_rom_wrsr(adapter, val); + if (ret != FLASH_SUCCESS) + goto out_kfree; + + ret = netxen_rom_wip_poll(adapter); + if (ret != FLASH_SUCCESS) + goto out_kfree; + + /* copy sector 0 to sector 63 */ + ret = netxen_rom_fast_read_words(adapter, CRBINIT_START, + buffer, FLASH_SECTOR_SIZE); + if (ret != FLASH_SUCCESS) + goto out_kfree; + + ret = netxen_rom_fast_write_words(adapter, FIXED_START, + buffer, FLASH_SECTOR_SIZE); + if (ret != FLASH_SUCCESS) + goto out_kfree; + + /* lock sector 63 */ + val = netxen_rom_rdsr(adapter); + if (!(val & 0x8)) { + val |= (0x1 << 2); + /* lock sector 63 */ + if (netxen_rom_wrsr(adapter, val) == 0) { + ret = netxen_rom_wip_poll(adapter); + if (ret != FLASH_SUCCESS) + goto out_kfree; + + /* lock SR writes */ + ret = netxen_rom_wip_poll(adapter); + if (ret != FLASH_SUCCESS) + goto out_kfree; + } + } + +out_kfree: + kfree(buffer); + return ret; +} + int netxen_do_rom_se(struct netxen_adapter *adapter, int addr) { netxen_rom_wren(adapter); @@ -457,6 +638,27 @@ int netxen_do_rom_se(struct netxen_adapter *adapter, int addr) return netxen_rom_wip_poll(adapter); } +void check_erased_flash(struct netxen_adapter *adapter, int addr) +{ + int i; + int val; + int count = 0, erased_errors = 0; + int range; + + range = (addr == USER_START) ? FIXED_START : addr + FLASH_SECTOR_SIZE; + + for (i = addr; i < range; i += 4) { + netxen_rom_fast_read(adapter, i, &val); + if (val != 0xffffffff) + erased_errors++; + count++; + } + + if (erased_errors) + printk(KERN_INFO "0x%x out of 0x%x words fail to be erased " + "for sector address: %x\n", erased_errors, count, addr); +} + int netxen_rom_se(struct netxen_adapter *adapter, int addr) { int ret = 0; @@ -465,6 +667,68 @@ int netxen_rom_se(struct netxen_adapter *adapter, int addr) } ret = netxen_do_rom_se(adapter, addr); netxen_rom_unlock(adapter); + msleep(30); + check_erased_flash(adapter, addr); + + return ret; +} + +int +netxen_flash_erase_sections(struct netxen_adapter *adapter, int start, int end) +{ + int ret = FLASH_SUCCESS; + int i; + + for (i = start; i < end; i++) { + ret = netxen_rom_se(adapter, i * FLASH_SECTOR_SIZE); + if (ret) + break; + ret = netxen_rom_wip_poll(adapter); + if (ret < 0) + return ret; + } + + return ret; +} + +int +netxen_flash_erase_secondary(struct netxen_adapter *adapter) +{ + int ret = FLASH_SUCCESS; + int start, end; + + start = SECONDARY_START / FLASH_SECTOR_SIZE; + end = USER_START / FLASH_SECTOR_SIZE; + ret = netxen_flash_erase_sections(adapter, start, end); + + return ret; +} + +int +netxen_flash_erase_primary(struct netxen_adapter *adapter) +{ + int ret = FLASH_SUCCESS; + int start, end; + + start = PRIMARY_START / FLASH_SECTOR_SIZE; + end = SECONDARY_START / FLASH_SECTOR_SIZE; + ret = netxen_flash_erase_sections(adapter, start, end); + + return ret; +} + +int netxen_flash_unlock(struct netxen_adapter *adapter) +{ + int ret = 0; + + ret = netxen_rom_wrsr(adapter, 0); + if (ret < 0) + return ret; + + ret = netxen_rom_wren(adapter); + if (ret < 0) + return ret; + return ret; } @@ -543,9 +807,13 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose) } for (i = 0; i < n; i++) { - off = - netxen_decode_crb_addr((unsigned long)buf[i].addr) + - NETXEN_PCI_CRBSPACE; + off = netxen_decode_crb_addr((unsigned long)buf[i].addr); + if (off == NETXEN_ADDR_ERROR) { + printk(KERN_ERR"CRB init value out of range %lx\n", + buf[i].addr); + continue; + } + off += NETXEN_PCI_CRBSPACE; /* skipping cold reboot MAGIC */ if (off == NETXEN_CAM_RAM(0x1fc)) continue; @@ -662,6 +930,7 @@ void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val) int loops = 0; if (!pegtune_val) { + val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); while (val != PHAN_INITIALIZE_COMPLETE && loops < 200000) { udelay(100); schedule(); @@ -690,8 +959,7 @@ int netxen_nic_rx_has_work(struct netxen_adapter *adapter) desc_head = recv_ctx->rcv_status_desc_head; desc = &desc_head[consumer]; - if (((le16_to_cpu(netxen_get_sts_owner(desc))) - & STATUS_OWNER_HOST)) + if (netxen_get_sts_owner(desc) & STATUS_OWNER_HOST) return 1; } @@ -787,11 +1055,11 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, struct netxen_port *port = adapter->port[netxen_get_sts_port(desc)]; struct pci_dev *pdev = port->pdev; struct net_device *netdev = port->netdev; - int index = le16_to_cpu(netxen_get_sts_refhandle(desc)); + int index = netxen_get_sts_refhandle(desc); struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]); struct netxen_rx_buffer *buffer; struct sk_buff *skb; - u32 length = le16_to_cpu(netxen_get_sts_totallength(desc)); + u32 length = netxen_get_sts_totallength(desc); u32 desc_ctx; struct netxen_rcv_desc_ctx *rcv_desc; int ret; @@ -918,16 +1186,14 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max) */ while (count < max) { desc = &desc_head[consumer]; - if (! - (le16_to_cpu(netxen_get_sts_owner(desc)) & - STATUS_OWNER_HOST)) { + if (!(netxen_get_sts_owner(desc) & STATUS_OWNER_HOST)) { DPRINTK(ERR, "desc %p ownedby %x\n", desc, netxen_get_sts_owner(desc)); break; } netxen_process_rcv(adapter, ctxid, desc); netxen_clear_sts_owner(desc); - netxen_set_sts_owner(desc, cpu_to_le16(STATUS_OWNER_PHANTOM)); + netxen_set_sts_owner(desc, STATUS_OWNER_PHANTOM); consumer = (consumer + 1) & (adapter->max_rx_desc_count - 1); count++; } @@ -1232,7 +1498,7 @@ void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ctx, /* make a rcv descriptor */ pdesc->reference_handle = cpu_to_le16(buffer->ref_handle); - pdesc->buffer_length = cpu_to_le16(rcv_desc->dma_size); + pdesc->buffer_length = cpu_to_le32(rcv_desc->dma_size); pdesc->addr_buffer = cpu_to_le64(buffer->dma); DPRINTK(INFO, "done writing descripter\n"); producer = diff --git a/drivers/net/netxen/netxen_nic_isr.c b/drivers/net/netxen/netxen_nic_isr.c index 06847d4..be366e4 100644 --- a/drivers/net/netxen/netxen_nic_isr.c +++ b/drivers/net/netxen/netxen_nic_isr.c @@ -79,7 +79,7 @@ void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 portno, void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno, u32 enable) { - __le32 int_src; + __u32 int_src; struct netxen_port *port; /* This should clear the interrupt source */ @@ -110,7 +110,7 @@ void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno, /* write it down later.. */ if ((netxen_get_phy_int_speed_changed(int_src)) || (netxen_get_phy_int_link_status_changed(int_src))) { - __le32 status; + __u32 status; DPRINTK(INFO, "SPEED CHANGED OR LINK STATUS CHANGED \n"); diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 96e1bee..69c1b9d 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -117,7 +117,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) void __iomem *mem_ptr1 = NULL; void __iomem *mem_ptr2 = NULL; - u8 *db_ptr = NULL; + u8 __iomem *db_ptr = NULL; unsigned long mem_base, mem_len, db_base, db_len; int pci_using_dac, i, err; int ring; @@ -191,7 +191,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) db_len); db_ptr = ioremap(db_base, NETXEN_DB_MAPSIZE_BYTES); - if (db_ptr == 0UL) { + if (!db_ptr) { printk(KERN_ERR "%s: Failed to allocate doorbell map.", netxen_nic_driver_name); err = -EIO; @@ -818,7 +818,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) /* Take skb->data itself */ pbuf = &adapter->cmd_buf_arr[producer]; if ((netdev->features & NETIF_F_TSO) && skb_shinfo(skb)->gso_size > 0) { - pbuf->mss = cpu_to_le16(skb_shinfo(skb)->gso_size); + pbuf->mss = skb_shinfo(skb)->gso_size; hwdesc->mss = cpu_to_le16(skb_shinfo(skb)->gso_size); } else { pbuf->mss = 0; @@ -882,7 +882,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) hwdesc->addr_buffer3 = cpu_to_le64(temp_dma); break; case 3: - hwdesc->buffer4_length = temp_len; + hwdesc->buffer4_length = cpu_to_le16(temp_len); hwdesc->addr_buffer4 = cpu_to_le64(temp_dma); break; } diff --git a/drivers/net/netxen/netxen_nic_niu.c b/drivers/net/netxen/netxen_nic_niu.c index 4987dc7..40d7003 100644 --- a/drivers/net/netxen/netxen_nic_niu.c +++ b/drivers/net/netxen/netxen_nic_niu.c @@ -89,15 +89,15 @@ static inline int phy_unlock(struct netxen_adapter *adapter) * */ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy, - long reg, __le32 * readval) + long reg, __u32 * readval) { long timeout = 0; long result = 0; long restore = 0; - __le32 address; - __le32 command; - __le32 status; - __le32 mac_cfg0; + __u32 address; + __u32 command; + __u32 status; + __u32 mac_cfg0; if (phy_lock(adapter) != 0) { return -1; @@ -112,7 +112,7 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy, &mac_cfg0, 4)) return -EIO; if (netxen_gb_get_soft_reset(mac_cfg0)) { - __le32 temp; + __u32 temp; temp = 0; netxen_gb_tx_reset_pb(temp); netxen_gb_rx_reset_pb(temp); @@ -184,15 +184,15 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy, * */ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, - long phy, long reg, __le32 val) + long phy, long reg, __u32 val) { long timeout = 0; long result = 0; long restore = 0; - __le32 address; - __le32 command; - __le32 status; - __le32 mac_cfg0; + __u32 address; + __u32 command; + __u32 status; + __u32 mac_cfg0; /* * MII mgmt all goes through port 0 MAC interface, so it @@ -203,7 +203,7 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, &mac_cfg0, 4)) return -EIO; if (netxen_gb_get_soft_reset(mac_cfg0)) { - __le32 temp; + __u32 temp; temp = 0; netxen_gb_tx_reset_pb(temp); netxen_gb_rx_reset_pb(temp); @@ -269,7 +269,7 @@ int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter, int port) { int result = 0; - __le32 enable = 0; + __u32 enable = 0; netxen_set_phy_int_link_status_changed(enable); netxen_set_phy_int_autoneg_completed(enable); netxen_set_phy_int_speed_changed(enable); @@ -402,7 +402,7 @@ void netxen_niu_gbe_set_gmii_mode(struct netxen_adapter *adapter, int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port) { int result = 0; - __le32 status; + __u32 status; if (adapter->disable_phy_interrupts) adapter->disable_phy_interrupts(adapter, port); mdelay(2); @@ -410,7 +410,7 @@ int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port) if (0 == netxen_niu_gbe_phy_read(adapter, port, NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, - (__le32 *) & status)) { + &status)) { if (netxen_get_phy_link(status)) { if (netxen_get_phy_speed(status) == 2) { netxen_niu_gbe_set_gmii_mode(adapter, port, 1); @@ -489,7 +489,7 @@ int netxen_niu_gbe_handle_phy_interrupt(struct netxen_adapter *adapter, int port, long enable) { int result = 0; - __le32 int_src; + __u32 int_src; printk(KERN_INFO PFX "NETXEN: Handling PHY interrupt on port %d" " (device enable = %d)\n", (int)port, (int)enable); @@ -530,7 +530,7 @@ int netxen_niu_gbe_handle_phy_interrupt(struct netxen_adapter *adapter, printk(KERN_INFO PFX "autoneg_error "); if ((netxen_get_phy_int_speed_changed(int_src)) || (netxen_get_phy_int_link_status_changed(int_src))) { - __le32 status; + __u32 status; printk(KERN_INFO PFX "speed_changed or link status changed"); @@ -583,9 +583,9 @@ int netxen_niu_gbe_handle_phy_interrupt(struct netxen_adapter *adapter, int netxen_niu_macaddr_get(struct netxen_adapter *adapter, int phy, netxen_ethernet_macaddr_t * addr) { - u64 result = 0; - __le32 stationhigh; - __le32 stationlow; + u32 stationhigh; + u32 stationlow; + u8 val[8]; if (addr == NULL) return -EINVAL; @@ -598,10 +598,10 @@ int netxen_niu_macaddr_get(struct netxen_adapter *adapter, if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy), &stationlow, 4)) return -EIO; + ((__le32 *)val)[1] = cpu_to_le32(stationhigh); + ((__le32 *)val)[0] = cpu_to_le32(stationlow); - result = (u64) netxen_gb_get_stationaddress_low(stationlow); - result |= (u64) stationhigh << 16; - memcpy(*addr, &result, sizeof(netxen_ethernet_macaddr_t)); + memcpy(addr, val + 2, 6); return 0; } @@ -613,24 +613,25 @@ int netxen_niu_macaddr_get(struct netxen_adapter *adapter, int netxen_niu_macaddr_set(struct netxen_port *port, netxen_ethernet_macaddr_t addr) { - __le32 temp = 0; + u8 temp[4]; + u32 val; struct netxen_adapter *adapter = port->adapter; int phy = port->portnum; unsigned char mac_addr[6]; int i; for (i = 0; i < 10; i++) { - memcpy(&temp, addr, 2); - temp <<= 16; + temp[0] = temp[1] = 0; + memcpy(temp + 2, addr, 2); + val = le32_to_cpu(*(__le32 *)temp); if (netxen_nic_hw_write_wx - (adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy), &temp, 4)) + (adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy), &val, 4)) return -EIO; - temp = 0; - - memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32)); + memcpy(temp, ((u8 *) addr) + 2, sizeof(__le32)); + val = le32_to_cpu(*(__le32 *)temp); if (netxen_nic_hw_write_wx - (adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy), &temp, 4)) + (adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy), &val, 4)) return -2; netxen_niu_macaddr_get(adapter, phy, @@ -659,9 +660,9 @@ int netxen_niu_macaddr_set(struct netxen_port *port, int netxen_niu_enable_gbe_port(struct netxen_adapter *adapter, int port, netxen_niu_gbe_ifmode_t mode) { - __le32 mac_cfg0; - __le32 mac_cfg1; - __le32 mii_cfg; + __u32 mac_cfg0; + __u32 mac_cfg1; + __u32 mii_cfg; if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) return -EINVAL; @@ -736,7 +737,7 @@ int netxen_niu_enable_gbe_port(struct netxen_adapter *adapter, /* Disable a GbE interface */ int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter, int port) { - __le32 mac_cfg0; + __u32 mac_cfg0; if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) return -EINVAL; @@ -752,7 +753,7 @@ int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter, int port) /* Disable an XG interface */ int netxen_niu_disable_xg_port(struct netxen_adapter *adapter, int port) { - __le32 mac_cfg; + __u32 mac_cfg; if (port != 0) return -EINVAL; @@ -769,7 +770,7 @@ int netxen_niu_disable_xg_port(struct netxen_adapter *adapter, int port) int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, int port, netxen_niu_prom_mode_t mode) { - __le32 reg; + __u32 reg; if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) return -EINVAL; @@ -826,22 +827,21 @@ int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, int port, int netxen_niu_xg_macaddr_set(struct netxen_port *port, netxen_ethernet_macaddr_t addr) { - __le32 temp = 0; + u8 temp[4]; + u32 val; struct netxen_adapter *adapter = port->adapter; - memcpy(&temp, addr, 2); - temp = cpu_to_le32(temp); - temp <<= 16; + temp[0] = temp[1] = 0; + memcpy(temp + 2, addr, 2); + val = le32_to_cpu(*(__le32 *)temp); if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_1, - &temp, 4)) + &val, 4)) return -EIO; - temp = 0; - memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32)); - temp = cpu_to_le32(temp); + val = le32_to_cpu(*(__le32 *)temp); if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_HI, - &temp, 4)) + &val, 4)) return -EIO; return 0; @@ -854,9 +854,9 @@ int netxen_niu_xg_macaddr_set(struct netxen_port *port, int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, int phy, netxen_ethernet_macaddr_t * addr) { - __le32 stationhigh; - __le32 stationlow; - u64 result; + u32 stationhigh; + u32 stationlow; + u8 val[8]; if (addr == NULL) return -EINVAL; @@ -869,10 +869,10 @@ int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, int phy, if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_1, &stationlow, 4)) return -EIO; + ((__le32 *)val)[1] = cpu_to_le32(stationhigh); + ((__le32 *)val)[0] = cpu_to_le32(stationlow); - result = ((u64) stationlow) >> 16; - result |= (u64) stationhigh << 16; - memcpy(*addr, &result, sizeof(netxen_ethernet_macaddr_t)); + memcpy(addr, val + 2, 6); return 0; } @@ -880,7 +880,7 @@ int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, int phy, int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter, int port, netxen_niu_prom_mode_t mode) { - __le32 reg; + __u32 reg; if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) return -EINVAL; |