diff options
author | Amit S. Kale <amitkale@netxen.com> | 2006-11-29 09:00:10 -0800 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-12-02 00:16:36 -0500 |
commit | cb8011ad53e0855ef088e0e5a4bcb98fa90c70b6 (patch) | |
tree | 2ea32fc89dab2257b359a0577ae06c6565cc99d1 /drivers | |
parent | edf901638144525a140c68be01be1b22e6041a6d (diff) |
[PATCH] NetXen: temp monitoring, newer firmware support, mm footprint reduction
NetXen: 1G/10G Ethernet Driver updates
- Temparature monitoring and device control
- Memory footprint reduction
- Driver changes to support newer version of firmware
Signed-off-by: Amit S. Kale <amitkale@netxen.com>
netxen_nic.h | 165 ++++++++++++++++++++++++++++++++--
netxen_nic_ethtool.c | 89 ++++++++++++------
netxen_nic_hdr.h | 71 +++++++++++++-
netxen_nic_hw.c | 206 +++++++++++++++++++++++++++++--------------
netxen_nic_hw.h | 8 +
netxen_nic_init.c | 239 +++++++++++++++++++++++++++++++++++++++++---------
netxen_nic_ioctl.h | 12 +-
netxen_nic_isr.c | 54 +++++------
netxen_nic_main.c | 121 +++++++++++++++++--------
netxen_nic_niu.c | 172 +++++++++++++++++++++++++++--------
netxen_nic_phan_reg.h | 24 ++++-
11 files changed, 891 insertions(+), 270 deletions(-)
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/netxen/netxen_nic.h | 165 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_ethtool.c | 89 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_hdr.h | 71 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_hw.c | 206 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_hw.h | 8 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_init.c | 239 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_ioctl.h | 12 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_isr.c | 54 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_main.c | 121 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_niu.c | 172 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_phan_reg.h | 24 |
11 files changed, 891 insertions, 270 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index 0458db45e70..1bee560d7d0 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h @@ -63,12 +63,12 @@ #include "netxen_nic_hw.h" -#define NETXEN_NIC_BUILD_NO "232" +#define NETXEN_NIC_BUILD_NO "5" #define _NETXEN_NIC_LINUX_MAJOR 2 #define _NETXEN_NIC_LINUX_MINOR 3 -#define _NETXEN_NIC_LINUX_SUBVERSION 57 -#define NETXEN_NIC_LINUX_VERSIONID "2.3.57" -#define NETXEN_NIC_FW_VERSIONID "2.3.57" +#define _NETXEN_NIC_LINUX_SUBVERSION 59 +#define NETXEN_NIC_LINUX_VERSIONID "2.3.59" "-" NETXEN_NIC_BUILD_NO +#define NETXEN_NIC_FW_VERSIONID "2.3.59" #define RCV_DESC_RINGSIZE \ (sizeof(struct rcv_desc) * adapter->max_rx_desc_count) @@ -89,9 +89,24 @@ * normalize a 64MB crb address to 32MB PCI window * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1 */ +#define NETXEN_CRB_NORMAL(reg) \ + (reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST + #define NETXEN_CRB_NORMALIZE(adapter, reg) \ - ((adapter)->ahw.pci_base + (reg) \ - - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST) + pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg)) + +#define FIRST_PAGE_GROUP_START 0 +#define FIRST_PAGE_GROUP_END 0x400000 + +#define SECOND_PAGE_GROUP_START 0x4000000 +#define SECOND_PAGE_GROUP_END 0x66BC000 + +#define THIRD_PAGE_GROUP_START 0x70E4000 +#define THIRD_PAGE_GROUP_END 0x8000000 + +#define FIRST_PAGE_GROUP_SIZE FIRST_PAGE_GROUP_END - FIRST_PAGE_GROUP_START +#define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START +#define THIRD_PAGE_GROUP_SIZE THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START #define MAX_RX_BUFFER_LENGTH 2000 #define MAX_RX_JUMBO_BUFFER_LENGTH 9046 @@ -328,6 +343,7 @@ typedef enum { NETXEN_BRDTYPE_P2_SB31_10G_HMEZ = 0x000e, NETXEN_BRDTYPE_P2_SB31_10G_CX4 = 0x000f } netxen_brdtype_t; +#define NUM_SUPPORTED_BOARDS (sizeof(netxen_boards)/sizeof(netxen_brdinfo_t)) typedef enum { NETXEN_BRDMFG_INVENTEC = 1 @@ -615,15 +631,23 @@ struct netxen_rx_buffer { */ struct netxen_hardware_context { struct pci_dev *pdev; - void __iomem *pci_base; /* base of mapped phantom memory */ + void __iomem *pci_base0; + void __iomem *pci_base1; + void __iomem *pci_base2; + u8 revision_id; u16 board_type; u16 max_ports; struct netxen_board_info boardcfg; u32 xg_linkup; + u32 qg_linksup; /* Address of cmd ring in Phantom */ struct cmd_desc_type0 *cmd_desc_head; + char *pauseaddr; + struct pci_dev *cmd_desc_pdev; dma_addr_t cmd_desc_phys_addr; + dma_addr_t pause_physaddr; + struct pci_dev *pause_pdev; struct netxen_adapter *adapter; }; @@ -654,6 +678,7 @@ struct netxen_rcv_desc_ctx { u32 rcv_pending; /* Num of bufs posted in phantom */ u32 rcv_free; /* Num of bufs in free list */ dma_addr_t phys_addr; + struct pci_dev *phys_pdev; struct rcv_desc *desc_head; /* address of rx ring in Phantom */ u32 max_rx_desc_count; u32 dma_size; @@ -673,6 +698,7 @@ struct netxen_recv_context { u32 status_rx_producer; u32 status_rx_consumer; dma_addr_t rcv_status_desc_phys_addr; + struct pci_dev *rcv_status_desc_pdev; struct status_desc *rcv_status_desc_head; }; @@ -708,6 +734,7 @@ struct netxen_adapter { u32 flags; u32 irq; int driver_mismatch; + u32 temp; struct netxen_adapter_stats stats; @@ -766,6 +793,43 @@ struct netxen_port { struct netxen_port_stats stats; }; +#define PCI_OFFSET_FIRST_RANGE(adapter, off) \ + ((adapter)->ahw.pci_base0 + (off)) +#define PCI_OFFSET_SECOND_RANGE(adapter, off) \ + ((adapter)->ahw.pci_base1 + (off) - SECOND_PAGE_GROUP_START) +#define PCI_OFFSET_THIRD_RANGE(adapter, off) \ + ((adapter)->ahw.pci_base2 + (off) - THIRD_PAGE_GROUP_START) + +static inline void __iomem *pci_base_offset(struct netxen_adapter *adapter, + unsigned long off) +{ + if ((off < FIRST_PAGE_GROUP_END) && (off >= FIRST_PAGE_GROUP_START)) { + return (adapter->ahw.pci_base0 + off); + } else if ((off < SECOND_PAGE_GROUP_END) && + (off >= SECOND_PAGE_GROUP_START)) { + return (adapter->ahw.pci_base1 + off - SECOND_PAGE_GROUP_START); + } else if ((off < THIRD_PAGE_GROUP_END) && + (off >= THIRD_PAGE_GROUP_START)) { + return (adapter->ahw.pci_base2 + off - THIRD_PAGE_GROUP_START); + } + return NULL; +} + +static inline void __iomem *pci_base(struct netxen_adapter *adapter, + unsigned long off) +{ + if ((off < FIRST_PAGE_GROUP_END) && (off >= FIRST_PAGE_GROUP_START)) { + return adapter->ahw.pci_base0; + } else if ((off < SECOND_PAGE_GROUP_END) && + (off >= SECOND_PAGE_GROUP_START)) { + return adapter->ahw.pci_base1; + } else if ((off < THIRD_PAGE_GROUP_END) && + (off >= THIRD_PAGE_GROUP_START)) { + return adapter->ahw.pci_base2; + } + return NULL; +} + struct netxen_drvops { int (*enable_phy_interrupts) (struct netxen_adapter *, int); int (*disable_phy_interrupts) (struct netxen_adapter *, int); @@ -809,7 +873,6 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long phy, long reg, __le32 val); /* Functions available from netxen_nic_hw.c */ -int netxen_niu_xginit(struct netxen_adapter *); int netxen_nic_set_mtu_xgb(struct netxen_port *port, int new_mtu); int netxen_nic_set_mtu_gb(struct netxen_port *port, int new_mtu); void netxen_nic_init_niu_gb(struct netxen_adapter *adapter); @@ -828,10 +891,13 @@ void netxen_crb_writelit_adapter(struct netxen_adapter *adapter, unsigned long off, int data); /* Functions from netxen_nic_init.c */ -void netxen_phantom_init(struct netxen_adapter *adapter); +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_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); /* Functions from netxen_nic_isr.c */ void netxen_nic_isr_other(struct netxen_adapter *adapter); @@ -842,6 +908,8 @@ void netxen_handle_port_int(struct netxen_adapter *adapter, u32 port, void netxen_nic_stop_all_ports(struct netxen_adapter *adapter); void netxen_initialize_adapter_sw(struct netxen_adapter *adapter); void netxen_initialize_adapter_hw(struct netxen_adapter *adapter); +void *netxen_alloc(struct pci_dev *pdev, size_t sz, dma_addr_t * ptr, + struct pci_dev **used_dev); void netxen_initialize_adapter_ops(struct netxen_adapter *adapter); int netxen_init_firmware(struct netxen_adapter *adapter); void netxen_free_hw_resources(struct netxen_adapter *adapter); @@ -869,7 +937,10 @@ static inline void netxen_nic_disable_int(struct netxen_adapter *adapter) /* * ISR_INT_MASK: Can be read from window 0 or 1. */ - writel(0x7ff, (void __iomem *)(adapter->ahw.pci_base + ISR_INT_MASK)); + writel(0x7ff, + (void __iomem + *)(PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK))); + } static inline void netxen_nic_enable_int(struct netxen_adapter *adapter) @@ -888,13 +959,83 @@ static inline void netxen_nic_enable_int(struct netxen_adapter *adapter) break; } - writel(mask, (void __iomem *)(adapter->ahw.pci_base + ISR_INT_MASK)); + writel(mask, + (void __iomem + *)(PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK))); if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { mask = 0xbff; writel(mask, (void __iomem *) - (adapter->ahw.pci_base + ISR_INT_TARGET_MASK)); + (PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_TARGET_MASK))); + } +} + +/* + * NetXen Board information + */ + +#define NETXEN_MAX_SHORT_NAME 16 +typedef struct { + netxen_brdtype_t brdtype; /* type of board */ + long ports; /* max no of physical ports */ + char short_name[NETXEN_MAX_SHORT_NAME]; +} netxen_brdinfo_t; + +static const netxen_brdinfo_t netxen_boards[] = { + {NETXEN_BRDTYPE_P2_SB31_10G_CX4, 1, "XGb CX4"}, + {NETXEN_BRDTYPE_P2_SB31_10G_HMEZ, 1, "XGb HMEZ"}, + {NETXEN_BRDTYPE_P2_SB31_10G_IMEZ, 2, "XGb IMEZ"}, + {NETXEN_BRDTYPE_P2_SB31_10G, 1, "XGb XFP"}, + {NETXEN_BRDTYPE_P2_SB35_4G, 4, "Quad Gb"}, + {NETXEN_BRDTYPE_P2_SB31_2G, 2, "Dual Gb"}, +}; + +#define NUM_SUPPORTED_BOARDS (sizeof(netxen_boards)/sizeof(netxen_brdinfo_t)) + +static inline void get_brd_ports_name_by_type(u32 type, int *ports, char *name) +{ + int i, found = 0; + for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) { + if (netxen_boards[i].brdtype == type) { + *ports = netxen_boards[i].ports; + strcpy(name, netxen_boards[i].short_name); + found = 1; + break; + } + } + if (!found) { + *ports = 0; + name = "Unknown"; + } +} + +static inline void get_brd_port_by_type(u32 type, int *ports) +{ + int i, found = 0; + for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) { + if (netxen_boards[i].brdtype == type) { + *ports = netxen_boards[i].ports; + found = 1; + break; + } + } + if (!found) + *ports = 0; +} + +static inline void get_brd_name_by_type(u32 type, char *name) +{ + int i, found = 0; + for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) { + if (netxen_boards[i].brdtype == type) { + strcpy(name, netxen_boards[i].short_name); + found = 1; + break; + } + } + if (!found) + name = "Unknown"; } int netxen_is_flash_supported(struct netxen_adapter *adapter); diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c index caf6cc15b24..f3fc35cf8af 100644 --- a/drivers/net/netxen/netxen_nic_ethtool.c +++ b/drivers/net/netxen/netxen_nic_ethtool.c @@ -53,6 +53,9 @@ struct netxen_nic_stats { #define NETXEN_NIC_STAT(m) sizeof(((struct netxen_port *)0)->m), \ offsetof(struct netxen_port, m) +#define NETXEN_NIC_PORT_WINDOW 0x10000 +#define NETXEN_NIC_INVALID_DATA 0xDEADBEEF + static const struct netxen_nic_stats netxen_nic_gstrings_stats[] = { {"rcvd_bad_skb", NETXEN_NIC_STAT(stats.rcvdbadskb)}, {"xmit_called", NETXEN_NIC_STAT(stats.xmitcalled)}, @@ -111,9 +114,9 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) { struct netxen_port *port = netdev_priv(dev); struct netxen_adapter *adapter = port->adapter; - uint32_t fw_major = 0; - uint32_t fw_minor = 0; - uint32_t fw_build = 0; + u32 fw_major = 0; + u32 fw_minor = 0; + u32 fw_build = 0; strncpy(drvinfo->driver, "netxen_nic", 32); strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32); @@ -136,6 +139,8 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) { struct netxen_port *port = netdev_priv(dev); struct netxen_adapter *adapter = port->adapter; + struct netxen_board_info *boardinfo; + boardinfo = &adapter->ahw.boardcfg; /* read which mode */ if (adapter->ahw.board_type == NETXEN_NIC_GBE) { @@ -144,16 +149,12 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Half | - SUPPORTED_1000baseT_Full | - SUPPORTED_TP | - SUPPORTED_MII | SUPPORTED_Autoneg); + SUPPORTED_1000baseT_Full); ecmd->advertising = (ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full | ADVERTISED_1000baseT_Half | - ADVERTISED_1000baseT_Full | - ADVERTISED_TP | - ADVERTISED_MII | ADVERTISED_Autoneg); + ADVERTISED_1000baseT_Full); ecmd->port = PORT_TP; @@ -162,16 +163,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) ecmd->duplex = port->link_duplex; } else return -EIO; /* link absent */ - - ecmd->phy_address = port->portnum; - ecmd->transceiver = XCVR_EXTERNAL; - - /* get autoneg settings */ - ecmd->autoneg = port->link_autoneg; - return 0; - } - - if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { + } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { ecmd->supported = (SUPPORTED_TP | SUPPORTED_1000baseT_Full | SUPPORTED_10000baseT_Full); @@ -182,13 +174,47 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) ecmd->speed = SPEED_10000; ecmd->duplex = DUPLEX_FULL; - ecmd->phy_address = port->portnum; - ecmd->transceiver = XCVR_EXTERNAL; ecmd->autoneg = AUTONEG_DISABLE; - return 0; + } else + return -EIO; + + ecmd->phy_address = port->portnum; + ecmd->transceiver = XCVR_EXTERNAL; + + switch ((netxen_brdtype_t) boardinfo->board_type) { + case NETXEN_BRDTYPE_P2_SB35_4G: + case NETXEN_BRDTYPE_P2_SB31_2G: + ecmd->supported |= SUPPORTED_Autoneg; + ecmd->advertising |= ADVERTISED_Autoneg; + case NETXEN_BRDTYPE_P2_SB31_10G_CX4: + ecmd->supported |= SUPPORTED_TP; + ecmd->advertising |= ADVERTISED_TP; + ecmd->port = PORT_TP; + ecmd->autoneg = (boardinfo->board_type == + NETXEN_BRDTYPE_P2_SB31_10G_CX4) ? + (AUTONEG_DISABLE) : (port->link_autoneg); + break; + case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ: + case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: + ecmd->supported |= SUPPORTED_MII; + ecmd->advertising |= ADVERTISED_MII; + ecmd->port = PORT_FIBRE; + ecmd->autoneg = AUTONEG_DISABLE; + break; + case NETXEN_BRDTYPE_P2_SB31_10G: + ecmd->supported |= SUPPORTED_FIBRE; + ecmd->advertising |= ADVERTISED_FIBRE; + ecmd->port = PORT_FIBRE; + ecmd->autoneg = AUTONEG_DISABLE; + break; + default: + printk("ERROR: Unsupported board model %d\n", + (netxen_brdtype_t) boardinfo->board_type); + return -EIO; + } - return -EIO; + return 0; } static int @@ -371,7 +397,7 @@ netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) for (i = 3; niu_registers[mode].reg[i - 3] != -1; i++) { /* GB: port specific registers */ if (mode == 0 && i >= 19) - window = port->portnum * 0x10000; + window = port->portnum * NETXEN_NIC_PORT_WINDOW; NETXEN_NIC_LOCKED_READ_REG(niu_registers[mode]. reg[i - 3] + window, @@ -385,7 +411,8 @@ static void netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) { wol->supported = WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | WAKE_MAGIC; - wol->wolopts = 0; /* options can be added depending upon the mode */ + /* options can be added depending upon the mode */ + wol->wolopts = 0; } static u32 netxen_nic_get_link(struct net_device *dev) @@ -531,9 +558,9 @@ static int netxen_nic_reg_test(struct net_device *dev) save = data_read; if (data_read) - data_written = data_read & 0xDEADBEEF; + data_written = data_read & NETXEN_NIC_INVALID_DATA; else - data_written = 0xDEADBEEF; + data_written = NETXEN_NIC_INVALID_DATA; netxen_nic_write_w0(adapter, NETXEN_NIU_GB_MII_MGMT_STATUS(port-> portnum), @@ -559,9 +586,9 @@ static int netxen_nic_reg_test(struct net_device *dev) save = data_read; if (data_read) - data_written = data_read & 0xDEADBEEF; + data_written = data_read & NETXEN_NIC_INVALID_DATA; else - data_written = 0xDEADBEEF; + data_written = NETXEN_NIC_INVALID_DATA; netxen_nic_write_w0(adapter, NETXEN_NIU_GB_MII_MGMT_INDICATE(port-> portnum), @@ -587,9 +614,9 @@ static int netxen_nic_reg_test(struct net_device *dev) save = data_read; if (data_read) - data_written = data_read & 0xDEADBEEF; + data_written = data_read & NETXEN_NIC_INVALID_DATA; else - data_written = 0xDEADBEEF; + data_written = NETXEN_NIC_INVALID_DATA; netxen_nic_write_w0(adapter, NETXEN_NIU_GB_INTERFACE_STATUS(port-> portnum), diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h index 83bf28b372a..72c6ec4ee2a 100644 --- a/drivers/net/netxen/netxen_nic_hdr.h +++ b/drivers/net/netxen/netxen_nic_hdr.h @@ -6,12 +6,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, @@ -397,6 +397,7 @@ enum { #define NETXEN_ROMUSB_ROM_INSTR_OPCODE (ROMUSB_ROM + 0x0004) #define NETXEN_ROMUSB_ROM_ADDRESS (ROMUSB_ROM + 0x0008) +#define NETXEN_ROMUSB_ROM_WDATA (ROMUSB_ROM + 0x000c) #define NETXEN_ROMUSB_ROM_ABYTE_CNT (ROMUSB_ROM + 0x0010) #define NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT (ROMUSB_ROM + 0x0014) #define NETXEN_ROMUSB_ROM_RDATA (ROMUSB_ROM + 0x0018) @@ -404,7 +405,29 @@ enum { /* Lock IDs for ROM lock */ #define ROM_LOCK_DRIVER 0x0d417340 -#define NETXEN_PCI_CRB_WINDOWSIZE 0x00100000 /* all are 1MB windows */ +/****************************************************************************** +* +* Definitions specific to M25P flash +* +******************************************************************************* +* Instructions +*/ +#define M25P_INSTR_WREN 0x06 +#define M25P_INSTR_WRDI 0x04 +#define M25P_INSTR_RDID 0x9f +#define M25P_INSTR_RDSR 0x05 +#define M25P_INSTR_WRSR 0x01 +#define M25P_INSTR_READ 0x03 +#define M25P_INSTR_FAST_READ 0x0b +#define M25P_INSTR_PP 0x02 +#define M25P_INSTR_SE 0xd8 +#define M25P_INSTR_BE 0xc7 +#define M25P_INSTR_DP 0xb9 +#define M25P_INSTR_RES 0xab + +/* all are 1MB windows */ + +#define NETXEN_PCI_CRB_WINDOWSIZE 0x00100000 #define NETXEN_PCI_CRB_WINDOW(A) \ (NETXEN_PCI_CRBSPACE + (A)*NETXEN_PCI_CRB_WINDOWSIZE) @@ -505,6 +528,12 @@ enum { #define NETXEN_NIU_XG_PAUSE_LEVEL (NETXEN_CRB_NIU + 0x000dc) #define NETXEN_NIU_XG_SEL (NETXEN_CRB_NIU + 0x00128) +#define NETXEN_NIU_FULL_LEVEL_XG (NETXEN_CRB_NIU + 0x00450) + +#define NETXEN_NIU_XG1_RESET (NETXEN_CRB_NIU + 0x0011c) +#define NETXEN_NIU_XG1_POWER_DOWN (NETXEN_CRB_NIU + 0x00120) +#define NETXEN_NIU_XG1_RESET_PLL (NETXEN_CRB_NIU + 0x00124) + #define NETXEN_MAC_ADDR_CNTL_REG (NETXEN_CRB_NIU + 0x1000) #define NETXEN_MULTICAST_ADDR_HI_0 (NETXEN_CRB_NIU + 0x1010) @@ -568,6 +597,29 @@ enum { #define NETXEN_NIU_XGE_REMOTE_ERROR_CNT (NETXEN_CRB_NIU + 0x70050) #define NETXEN_NIU_XGE_CONTROL_CHAR_CNT (NETXEN_CRB_NIU + 0x70054) #define NETXEN_NIU_XGE_PAUSE_FRAME_CNT (NETXEN_CRB_NIU + 0x70058) +#define NETXEN_NIU_XG1_CONFIG_0 (NETXEN_CRB_NIU + 0x80000) +#define NETXEN_NIU_XG1_CONFIG_1 (NETXEN_CRB_NIU + 0x80004) +#define NETXEN_NIU_XG1_IPG (NETXEN_CRB_NIU + 0x80008) +#define NETXEN_NIU_XG1_STATION_ADDR_0_HI (NETXEN_CRB_NIU + 0x8000c) +#define NETXEN_NIU_XG1_STATION_ADDR_0_1 (NETXEN_CRB_NIU + 0x80010) +#define NETXEN_NIU_XG1_STATION_ADDR_1_LO (NETXEN_CRB_NIU + 0x80014) +#define NETXEN_NIU_XG1_STATUS (NETXEN_CRB_NIU + 0x80018) +#define NETXEN_NIU_XG1_MAX_FRAME_SIZE (NETXEN_CRB_NIU + 0x8001c) +#define NETXEN_NIU_XG1_PAUSE_FRAME_VALUE (NETXEN_CRB_NIU + 0x80020) +#define NETXEN_NIU_XG1_TX_BYTE_CNT (NETXEN_CRB_NIU + 0x80024) +#define NETXEN_NIU_XG1_TX_FRAME_CNT (NETXEN_CRB_NIU + 0x80028) +#define NETXEN_NIU_XG1_RX_BYTE_CNT (NETXEN_CRB_NIU + 0x8002c) +#define NETXEN_NIU_XG1_RX_FRAME_CNT (NETXEN_CRB_NIU + 0x80030) +#define NETXEN_NIU_XG1_AGGR_ERROR_CNT (NETXEN_CRB_NIU + 0x80034) +#define NETXEN_NIU_XG1_MULTICAST_FRAME_CNT (NETXEN_CRB_NIU + 0x80038) +#define NETXEN_NIU_XG1_UNICAST_FRAME_CNT (NETXEN_CRB_NIU + 0x8003c) +#define NETXEN_NIU_XG1_CRC_ERROR_CNT (NETXEN_CRB_NIU + 0x80040) +#define NETXEN_NIU_XG1_OVERSIZE_FRAME_ERR (NETXEN_CRB_NIU + 0x80044) +#define NETXEN_NIU_XG1_UNDERSIZE_FRAME_ERR (NETXEN_CRB_NIU + 0x80048) +#define NETXEN_NIU_XG1_LOCAL_ERROR_CNT (NETXEN_CRB_NIU + 0x8004c) +#define NETXEN_NIU_XG1_REMOTE_ERROR_CNT (NETXEN_CRB_NIU + 0x80050) +#define NETXEN_NIU_XG1_CONTROL_CHAR_CNT (NETXEN_CRB_NIU + 0x80054) +#define NETXEN_NIU_XG1_PAUSE_FRAME_CNT (NETXEN_CRB_NIU + 0x80058) /* XG Link status */ #define XG_LINK_UP 0x10 @@ -580,8 +632,15 @@ enum { #define NETXEN_FW_VERSION_SUB (NETXEN_CAM_RAM(0x158)) #define NETXEN_ROM_LOCK_ID (NETXEN_CAM_RAM(0x100)) -#define PCIX_PS_OP_ADDR_LO (0x10000) /* Used for PS PCI Memory access */ -#define PCIX_PS_OP_ADDR_HI (0x10004) /* via CRB (PS side only) */ +#define NETXEN_PHY_LOCK_ID (NETXEN_CAM_RAM(0x120)) + +/* Lock IDs for PHY lock */ +#define PHY_LOCK_DRIVER 0x44524956 + +/* Used for PS PCI Memory access */ +#define PCIX_PS_OP_ADDR_LO (0x10000) +/* via CRB (PS side only) */ +#define PCIX_PS_OP_ADDR_HI (0x10004) #define PCIX_INT_VECTOR (0x10100) #define PCIX_INT_MASK (0x10104) @@ -609,6 +668,8 @@ enum { #define PCIE_SEM2_LOCK (0x1c010) /* Flash lock */ #define PCIE_SEM2_UNLOCK (0x1c014) /* Flash unlock */ +#define PCIE_SEM3_LOCK (0x1c018) /* Phy lock */ +#define PCIE_SEM3_UNLOCK (0x1c01c) /* Phy unlock */ #define PCIE_TGT_SPLIT_CHICKEN (0x12080) diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index 9603c635b05..99e647a5ae7 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c @@ -6,12 +6,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, @@ -43,15 +43,26 @@ #define NETXEN_FLASH_BASE (BOOTLD_START) #define NETXEN_PHANTOM_MEM_BASE (NETXEN_FLASH_BASE) #define NETXEN_MAX_MTU 8000 -#define NETXEN_MIN_MTU 64 +#define NETXEN_MIN_MTU 64 #define NETXEN_ETH_FCS_SIZE 4 #define NETXEN_ENET_HEADER_SIZE 14 -#define NETXEN_WINDOW_ONE 0x2000000 /* CRB Window: bit 25 of CRB address */ +#define NETXEN_WINDOW_ONE 0x2000000 /*CRB Window: bit 25 of CRB address */ #define NETXEN_FIRMWARE_LEN ((16 * 1024) / 4) #define NETXEN_NIU_HDRSIZE (0x1 << 6) #define NETXEN_NIU_TLRSIZE (0x1 << 5) -unsigned long netxen_nic_pci_set_window(void __iomem * pci_base, +#define lower32(x) ((u32)((x) & 0xffffffff)) +#define upper32(x) \ + ((u32)(((unsigned long long)(x) >> 32) & 0xffffffff)) + +#define NETXEN_NIC_ZERO_PAUSE_ADDR 0ULL +#define NETXEN_NIC_UNIT_PAUSE_ADDR 0x200ULL +#define NETXEN_NIC_EPG_PAUSE_ADDR1 0x2200010000c28001ULL +#define NETXEN_NIC_EPG_PAUSE_ADDR2 0x0100088866554433ULL + +#define NETXEN_NIC_WINDOW_MARGIN 0x100000 + +unsigned long netxen_nic_pci_set_window(struct netxen_adapter *adapter, unsigned long long addr); void netxen_free_hw_resources(struct netxen_adapter *adapter); @@ -93,7 +104,9 @@ void netxen_nic_set_multi(struct net_device *netdev) port->portnum, NETXEN_NIU_PROMISC_MODE); } else { - if (adapter->ops->unset_promisc) + if (adapter->ops->unset_promisc && + adapter->ahw.boardcfg.board_type + != NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) adapter->ops->unset_promisc(adapter, port->portnum, NETXEN_NIU_NON_PROMISC_MODE); @@ -161,26 +174,24 @@ int netxen_nic_change_mtu(struct net_device *netdev, int mtu) int netxen_nic_hw_resources(struct netxen_adapter *adapter) { struct netxen_hardware_context *hw = &adapter->ahw; - int i; u32 state = 0; void *addr; + void *pause_addr; int loops = 0, err = 0; int ctx, ring; u32 card_cmdring = 0; struct netxen_rcv_desc_crb *rcv_desc_crb = NULL; struct netxen_recv_context *recv_ctx; struct netxen_rcv_desc_ctx *rcv_desc; - struct cmd_desc_type0 *pcmd; - DPRINTK(INFO, "pci_base: %lx\n", adapter->ahw.pci_base); DPRINTK(INFO, "crb_base: %lx %lx", NETXEN_PCI_CRBSPACE, - adapter->ahw.pci_base + NETXEN_PCI_CRBSPACE); + PCI_OFFSET_SECOND_RANGE(adapter, NETXEN_PCI_CRBSPACE)); DPRINTK(INFO, "cam base: %lx %lx", NETXEN_CRB_CAM, - adapter->ahw.pci_base + NETXEN_CRB_CAM); + pci_base_offset(adapter, NETXEN_CRB_CAM)); DPRINTK(INFO, "cam RAM: %lx %lx", NETXEN_CAM_RAM_BASE, - adapter->ahw.pci_base + NETXEN_CAM_RAM_BASE); + pci_base_offset(adapter, NETXEN_CAM_RAM_BASE)); DPRINTK(INFO, "NIC base:%lx %lx\n", NIC_CRB_BASE_PORT1, - adapter->ahw.pci_base + NIC_CRB_BASE_PORT1); + pci_base_offset(adapter, NIC_CRB_BASE_PORT1)); /* Window 1 call */ card_cmdring = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_CMDRING)); @@ -214,25 +225,34 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) } DPRINTK(INFO, "Recieve Peg ready too. starting stuff\n"); - addr = pci_alloc_consistent(adapter->ahw.pdev, - sizeof(struct cmd_desc_type0) * - adapter->max_tx_desc_count, - &hw->cmd_desc_phys_addr); + addr = netxen_alloc(adapter->ahw.pdev, + sizeof(struct cmd_desc_type0) * + adapter->max_tx_desc_count, + &hw->cmd_desc_phys_addr, &hw->cmd_desc_pdev); + if (addr == NULL) { DPRINTK(ERR, "bad return from pci_alloc_consistent\n"); - err = -ENOMEM; - return err; + return -ENOMEM; + } + + pause_addr = netxen_alloc(adapter->ahw.pdev, 512, + (dma_addr_t *) & hw->pause_physaddr, + &hw->pause_pdev); + if (pause_addr == NULL) { + DPRINTK(1, ERR, "bad return from pci_alloc_consistent\n"); + return -ENOMEM; } - /* we need to prelink all of the cmd descriptors */ - pcmd = (struct cmd_desc_type0 *)addr; - for (i = 1; i < adapter->max_tx_desc_count; i++) { - pcmd->netxen_next = - (card_cmdring + i * sizeof(struct cmd_desc_type0)); - pcmd++; + hw->pauseaddr = (char *)pause_addr; + { + u64 *ptr = (u64 *) pause_addr; + *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR; + *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR; + *ptr++ = NETXEN_NIC_UNIT_PAUSE_ADDR; + *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR; + *ptr++ = NETXEN_NIC_EPG_PAUSE_ADDR1; + *ptr++ = NETXEN_NIC_EPG_PAUSE_ADDR2; } - /* fill in last link (point to first) */ - pcmd->netxen_next = card_cmdring; hw->cmd_desc_head = (struct cmd_desc_type0 *)addr; @@ -241,9 +261,10 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { rcv_desc = &recv_ctx->rcv_desc[ring]; - addr = pci_alloc_consistent(adapter->ahw.pdev, - RCV_DESC_RINGSIZE, - &rcv_desc->phys_addr); + addr = netxen_alloc(adapter->ahw.pdev, + RCV_DESC_RINGSIZE, + &rcv_desc->phys_addr, + &rcv_desc->phys_pdev); if (addr == NULL) { DPRINTK(ERR, "bad return from " "pci_alloc_consistent\n"); @@ -254,10 +275,11 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) rcv_desc->desc_head = (struct rcv_desc *)addr; } - addr = pci_alloc_consistent(adapter->ahw.pdev, - STATUS_DESC_RINGSIZE, - &recv_ctx-> - rcv_status_desc_phys_addr); + addr = netxen_alloc(adapter->ahw.pdev, + STATUS_DESC_RINGSIZE, + &recv_ctx-> + rcv_status_desc_phys_addr, + &recv_ctx->rcv_status_desc_pdev); if (addr == NULL) { DPRINTK(ERR, "bad return from" " pci_alloc_consistent\n"); @@ -273,19 +295,20 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) DPRINTK(INFO, "ring #%d crb global ring reg 0x%x\n", ring, rcv_desc_crb->crb_globalrcv_ring); /* Window = 1 */ - writel(rcv_desc->phys_addr, + writel(lower32(rcv_desc->phys_addr), NETXEN_CRB_NORMALIZE(adapter, rcv_desc_crb-> crb_globalrcv_ring)); DPRINTK(INFO, "GLOBAL_RCV_RING ctx %d, addr 0x%x" - " val 0x%x," + " val 0x%llx," " virt %p\n", ctx, rcv_desc_crb->crb_globalrcv_ring, - rcv_desc->phys_addr, rcv_desc->desc_head); + (unsigned long long)rcv_desc->phys_addr, + +rcv_desc->desc_head); } /* Window = 1 */ - writel(recv_ctx->rcv_status_desc_phys_addr, + writel(lower32(recv_ctx->rcv_status_desc_phys_addr), NETXEN_CRB_NORMALIZE(adapter, recv_crb_registers[ctx]. crb_rcvstatus_ring)); @@ -293,13 +316,19 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) " val 0x%x,virt%p\n", ctx, recv_crb_registers[ctx].crb_rcvstatus_ring, - recv_ctx->rcv_status_desc_phys_addr, + (unsigned long long)recv_ctx->rcv_status_desc_phys_addr, recv_ctx->rcv_status_desc_head); } /* Window = 1 */ - writel(hw->cmd_desc_phys_addr, - NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO)); + writel(lower32(hw->pause_physaddr), + NETXEN_CRB_NORMALIZE(adapter, CRB_PAUSE_ADDR_LO)); + writel(upper32(hw->pause_physaddr), + NETXEN_CRB_NORMALIZE(adapter, CRB_PAUSE_ADDR_HI)); + writel(lower32(hw->cmd_desc_phys_addr), + NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO)); + writel(upper32(hw->cmd_desc_phys_addr), + NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_HI)); return err; } @@ -310,13 +339,19 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter) int ctx, ring; if (adapter->ahw.cmd_desc_head != NULL) { - pci_free_consistent(adapter->ahw.pdev, + pci_free_consistent(adapter->ahw.cmd_desc_pdev, sizeof(struct cmd_desc_type0) * adapter->max_tx_desc_count, adapter->ahw.cmd_desc_head, adapter->ahw.cmd_desc_phys_addr); adapter->ahw.cmd_desc_head = NULL; } + if (adapter->ahw.pauseaddr != NULL) { + pci_free_consistent(adapter->ahw.pause_pdev, 512, + adapter->ahw.pauseaddr, + adapter->ahw.pause_physaddr); + adapter->ahw.pauseaddr = NULL; + } for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { recv_ctx = &adapter->recv_ctx[ctx]; @@ -324,7 +359,7 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter) rcv_desc = &recv_ctx->rcv_desc[ring]; if (rcv_desc->desc_head != NULL) { - pci_free_consistent(adapter->ahw.pdev, + pci_free_consistent(rcv_desc->phys_pdev, RCV_DESC_RINGSIZE, rcv_desc->desc_head, rcv_desc->phys_addr); @@ -333,7 +368,7 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter) } if (recv_ctx->rcv_status_desc_head != NULL) { - pci_free_consistent(adapter->ahw.pdev, + pci_free_consistent(recv_ctx->rcv_status_desc_pdev, STATUS_DESC_RINGSIZE, recv_ctx->rcv_status_desc_head, recv_ctx-> @@ -360,10 +395,10 @@ void netxen_tso_check(struct netxen_adapter *adapter, return; } } + adapter->stats.xmitcsummed++; CMD_DESC_TCP_HDR_OFFSET_WRT(desc, skb->h.raw - skb->data); desc->length_tcp_hdr = cpu_to_le32(desc->length_tcp_hdr); desc->ip_hdr_offset = skb->nh.raw - skb->data; - adapter->stats.xmitcsummed++; } int netxen_is_flash_supported(struct netxen_adapter *adapter) @@ -373,7 +408,7 @@ int netxen_is_flash_supported(struct netxen_adapter *adapter) /* if the flash size less than 4Mb, make huge war cry and die */ for (j = 1; j < 4; j++) { - addr = j * 0x100000; + addr = j * NETXEN_NIC_WINDOW_MARGIN; for (i = 0; i < (sizeof(locs) / sizeof(locs[0])); i++) { if (netxen_rom_fast_read(adapter, locs[i], &val01) == 0 && netxen_rom_fast_read(adapter, (addr + locs[i]), @@ -458,7 +493,9 @@ void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw) * register address is received by PCI. The direct region bypasses * the CRB bus. */ - offset = adapter->ahw.pci_base + NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW); + offset = + PCI_OFFSET_SECOND_RANGE(adapter, + NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW)); if (wndw & 0x1) wndw = NETXEN_WINDOW_ONE; @@ -497,8 +534,8 @@ void netxen_load_firmware(struct netxen_adapter *adapter) "loading flash image\n"); return; } - off = netxen_nic_pci_set_window(adapter->ahw.pci_base, memaddr); - addr = (adapter->ahw.pci_base + off); + off = netxen_nic_pci_set_window(adapter, memaddr); + addr = pci_base_offset(adapter, off); writel(data, addr); flashaddr += 4; memaddr += 4; @@ -521,14 +558,19 @@ netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data, if (ADDR_IN_WINDOW1(off)) { addr = NETXEN_CRB_NORMALIZE(adapter, off); } else { /* Window 0 */ - addr = adapter->ahw.pci_base + off; + addr = pci_base_offset(adapter, off); netxen_nic_pci_change_crbwindow(adapter, 0); |