Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1 | /**************************************************************************** |
| 2 | * Driver for Solarflare Solarstorm network controllers and boards |
| 3 | * Copyright 2005-2006 Fen Systems Ltd. |
Ben Hutchings | 0a6f40c | 2011-02-25 00:01:34 +0000 | [diff] [blame] | 4 | * Copyright 2006-2010 Solarflare Communications Inc. |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License version 2 as published |
| 8 | * by the Free Software Foundation, incorporated herein by reference. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/bitops.h> |
| 12 | #include <linux/delay.h> |
| 13 | #include <linux/pci.h> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/seq_file.h> |
Ben Hutchings | 37b5a60 | 2008-05-30 22:27:04 +0100 | [diff] [blame] | 16 | #include <linux/i2c.h> |
Ben Hutchings | f31a45d | 2008-12-12 21:43:33 -0800 | [diff] [blame] | 17 | #include <linux/mii.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 18 | #include <linux/slab.h> |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 19 | #include "net_driver.h" |
| 20 | #include "bitfield.h" |
| 21 | #include "efx.h" |
Ben Hutchings | 744093c | 2009-11-29 15:12:08 +0000 | [diff] [blame] | 22 | #include "nic.h" |
Ben Hutchings | 8b8a95a | 2012-09-18 01:57:07 +0100 | [diff] [blame] | 23 | #include "farch_regs.h" |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 24 | #include "io.h" |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 25 | #include "phy.h" |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 26 | #include "workarounds.h" |
Ben Hutchings | d4f2cec | 2012-07-04 03:58:33 +0100 | [diff] [blame] | 27 | #include "selftest.h" |
Ben Hutchings | ab0115f | 2012-09-13 01:11:31 +0100 | [diff] [blame] | 28 | #include "mdio_10g.h" |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 29 | |
Ben Hutchings | 8986352 | 2009-11-25 16:09:04 +0000 | [diff] [blame] | 30 | /* Hardware control for SFC4000 (aka Falcon). */ |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 31 | |
Ben Hutchings | ab0115f | 2012-09-13 01:11:31 +0100 | [diff] [blame] | 32 | /************************************************************************** |
| 33 | * |
| 34 | * MAC stats DMA format |
| 35 | * |
| 36 | ************************************************************************** |
| 37 | */ |
| 38 | |
| 39 | #define FALCON_MAC_STATS_SIZE 0x100 |
| 40 | |
| 41 | #define XgRxOctets_offset 0x0 |
| 42 | #define XgRxOctets_WIDTH 48 |
| 43 | #define XgRxOctetsOK_offset 0x8 |
| 44 | #define XgRxOctetsOK_WIDTH 48 |
| 45 | #define XgRxPkts_offset 0x10 |
| 46 | #define XgRxPkts_WIDTH 32 |
| 47 | #define XgRxPktsOK_offset 0x14 |
| 48 | #define XgRxPktsOK_WIDTH 32 |
| 49 | #define XgRxBroadcastPkts_offset 0x18 |
| 50 | #define XgRxBroadcastPkts_WIDTH 32 |
| 51 | #define XgRxMulticastPkts_offset 0x1C |
| 52 | #define XgRxMulticastPkts_WIDTH 32 |
| 53 | #define XgRxUnicastPkts_offset 0x20 |
| 54 | #define XgRxUnicastPkts_WIDTH 32 |
| 55 | #define XgRxUndersizePkts_offset 0x24 |
| 56 | #define XgRxUndersizePkts_WIDTH 32 |
| 57 | #define XgRxOversizePkts_offset 0x28 |
| 58 | #define XgRxOversizePkts_WIDTH 32 |
| 59 | #define XgRxJabberPkts_offset 0x2C |
| 60 | #define XgRxJabberPkts_WIDTH 32 |
| 61 | #define XgRxUndersizeFCSerrorPkts_offset 0x30 |
| 62 | #define XgRxUndersizeFCSerrorPkts_WIDTH 32 |
| 63 | #define XgRxDropEvents_offset 0x34 |
| 64 | #define XgRxDropEvents_WIDTH 32 |
| 65 | #define XgRxFCSerrorPkts_offset 0x38 |
| 66 | #define XgRxFCSerrorPkts_WIDTH 32 |
| 67 | #define XgRxAlignError_offset 0x3C |
| 68 | #define XgRxAlignError_WIDTH 32 |
| 69 | #define XgRxSymbolError_offset 0x40 |
| 70 | #define XgRxSymbolError_WIDTH 32 |
| 71 | #define XgRxInternalMACError_offset 0x44 |
| 72 | #define XgRxInternalMACError_WIDTH 32 |
| 73 | #define XgRxControlPkts_offset 0x48 |
| 74 | #define XgRxControlPkts_WIDTH 32 |
| 75 | #define XgRxPausePkts_offset 0x4C |
| 76 | #define XgRxPausePkts_WIDTH 32 |
| 77 | #define XgRxPkts64Octets_offset 0x50 |
| 78 | #define XgRxPkts64Octets_WIDTH 32 |
| 79 | #define XgRxPkts65to127Octets_offset 0x54 |
| 80 | #define XgRxPkts65to127Octets_WIDTH 32 |
| 81 | #define XgRxPkts128to255Octets_offset 0x58 |
| 82 | #define XgRxPkts128to255Octets_WIDTH 32 |
| 83 | #define XgRxPkts256to511Octets_offset 0x5C |
| 84 | #define XgRxPkts256to511Octets_WIDTH 32 |
| 85 | #define XgRxPkts512to1023Octets_offset 0x60 |
| 86 | #define XgRxPkts512to1023Octets_WIDTH 32 |
| 87 | #define XgRxPkts1024to15xxOctets_offset 0x64 |
| 88 | #define XgRxPkts1024to15xxOctets_WIDTH 32 |
| 89 | #define XgRxPkts15xxtoMaxOctets_offset 0x68 |
| 90 | #define XgRxPkts15xxtoMaxOctets_WIDTH 32 |
| 91 | #define XgRxLengthError_offset 0x6C |
| 92 | #define XgRxLengthError_WIDTH 32 |
| 93 | #define XgTxPkts_offset 0x80 |
| 94 | #define XgTxPkts_WIDTH 32 |
| 95 | #define XgTxOctets_offset 0x88 |
| 96 | #define XgTxOctets_WIDTH 48 |
| 97 | #define XgTxMulticastPkts_offset 0x90 |
| 98 | #define XgTxMulticastPkts_WIDTH 32 |
| 99 | #define XgTxBroadcastPkts_offset 0x94 |
| 100 | #define XgTxBroadcastPkts_WIDTH 32 |
| 101 | #define XgTxUnicastPkts_offset 0x98 |
| 102 | #define XgTxUnicastPkts_WIDTH 32 |
| 103 | #define XgTxControlPkts_offset 0x9C |
| 104 | #define XgTxControlPkts_WIDTH 32 |
| 105 | #define XgTxPausePkts_offset 0xA0 |
| 106 | #define XgTxPausePkts_WIDTH 32 |
| 107 | #define XgTxPkts64Octets_offset 0xA4 |
| 108 | #define XgTxPkts64Octets_WIDTH 32 |
| 109 | #define XgTxPkts65to127Octets_offset 0xA8 |
| 110 | #define XgTxPkts65to127Octets_WIDTH 32 |
| 111 | #define XgTxPkts128to255Octets_offset 0xAC |
| 112 | #define XgTxPkts128to255Octets_WIDTH 32 |
| 113 | #define XgTxPkts256to511Octets_offset 0xB0 |
| 114 | #define XgTxPkts256to511Octets_WIDTH 32 |
| 115 | #define XgTxPkts512to1023Octets_offset 0xB4 |
| 116 | #define XgTxPkts512to1023Octets_WIDTH 32 |
| 117 | #define XgTxPkts1024to15xxOctets_offset 0xB8 |
| 118 | #define XgTxPkts1024to15xxOctets_WIDTH 32 |
| 119 | #define XgTxPkts1519toMaxOctets_offset 0xBC |
| 120 | #define XgTxPkts1519toMaxOctets_WIDTH 32 |
| 121 | #define XgTxUndersizePkts_offset 0xC0 |
| 122 | #define XgTxUndersizePkts_WIDTH 32 |
| 123 | #define XgTxOversizePkts_offset 0xC4 |
| 124 | #define XgTxOversizePkts_WIDTH 32 |
| 125 | #define XgTxNonTcpUdpPkt_offset 0xC8 |
| 126 | #define XgTxNonTcpUdpPkt_WIDTH 16 |
| 127 | #define XgTxMacSrcErrPkt_offset 0xCC |
| 128 | #define XgTxMacSrcErrPkt_WIDTH 16 |
| 129 | #define XgTxIpSrcErrPkt_offset 0xD0 |
| 130 | #define XgTxIpSrcErrPkt_WIDTH 16 |
| 131 | #define XgDmaDone_offset 0xD4 |
| 132 | #define XgDmaDone_WIDTH 32 |
| 133 | |
Ben Hutchings | e513612 | 2012-12-14 21:52:56 +0000 | [diff] [blame] | 134 | #define FALCON_XMAC_STATS_DMA_FLAG(efx) \ |
| 135 | (*(u32 *)((efx)->stats_buffer.addr + XgDmaDone_offset)) |
Ben Hutchings | ab0115f | 2012-09-13 01:11:31 +0100 | [diff] [blame] | 136 | |
| 137 | #define FALCON_STAT_OFFSET(falcon_stat) EFX_VAL(falcon_stat, offset) |
| 138 | #define FALCON_STAT_WIDTH(falcon_stat) EFX_VAL(falcon_stat, WIDTH) |
| 139 | |
| 140 | /* Retrieve statistic from statistics block */ |
| 141 | #define FALCON_STAT(efx, falcon_stat, efx_stat) do { \ |
| 142 | if (FALCON_STAT_WIDTH(falcon_stat) == 16) \ |
| 143 | (efx)->mac_stats.efx_stat += le16_to_cpu( \ |
| 144 | *((__force __le16 *) \ |
| 145 | (efx->stats_buffer.addr + \ |
| 146 | FALCON_STAT_OFFSET(falcon_stat)))); \ |
| 147 | else if (FALCON_STAT_WIDTH(falcon_stat) == 32) \ |
| 148 | (efx)->mac_stats.efx_stat += le32_to_cpu( \ |
| 149 | *((__force __le32 *) \ |
| 150 | (efx->stats_buffer.addr + \ |
| 151 | FALCON_STAT_OFFSET(falcon_stat)))); \ |
| 152 | else \ |
| 153 | (efx)->mac_stats.efx_stat += le64_to_cpu( \ |
| 154 | *((__force __le64 *) \ |
| 155 | (efx->stats_buffer.addr + \ |
| 156 | FALCON_STAT_OFFSET(falcon_stat)))); \ |
| 157 | } while (0) |
| 158 | |
| 159 | /************************************************************************** |
| 160 | * |
Ben Hutchings | 45a3fd5 | 2012-11-28 04:38:14 +0000 | [diff] [blame] | 161 | * Basic SPI command set and bit definitions |
| 162 | * |
| 163 | *************************************************************************/ |
| 164 | |
| 165 | #define SPI_WRSR 0x01 /* Write status register */ |
| 166 | #define SPI_WRITE 0x02 /* Write data to memory array */ |
| 167 | #define SPI_READ 0x03 /* Read data from memory array */ |
| 168 | #define SPI_WRDI 0x04 /* Reset write enable latch */ |
| 169 | #define SPI_RDSR 0x05 /* Read status register */ |
| 170 | #define SPI_WREN 0x06 /* Set write enable latch */ |
| 171 | #define SPI_SST_EWSR 0x50 /* SST: Enable write to status register */ |
| 172 | |
| 173 | #define SPI_STATUS_WPEN 0x80 /* Write-protect pin enabled */ |
| 174 | #define SPI_STATUS_BP2 0x10 /* Block protection bit 2 */ |
| 175 | #define SPI_STATUS_BP1 0x08 /* Block protection bit 1 */ |
| 176 | #define SPI_STATUS_BP0 0x04 /* Block protection bit 0 */ |
| 177 | #define SPI_STATUS_WEN 0x02 /* State of the write enable latch */ |
| 178 | #define SPI_STATUS_NRDY 0x01 /* Device busy flag */ |
| 179 | |
| 180 | /************************************************************************** |
| 181 | * |
| 182 | * Non-volatile memory layout |
Ben Hutchings | ab0115f | 2012-09-13 01:11:31 +0100 | [diff] [blame] | 183 | * |
| 184 | ************************************************************************** |
| 185 | */ |
| 186 | |
Ben Hutchings | 45a3fd5 | 2012-11-28 04:38:14 +0000 | [diff] [blame] | 187 | /* SFC4000 flash is partitioned into: |
| 188 | * 0-0x400 chip and board config (see struct falcon_nvconfig) |
| 189 | * 0x400-0x8000 unused (or may contain VPD if EEPROM not present) |
| 190 | * 0x8000-end boot code (mapped to PCI expansion ROM) |
| 191 | * SFC4000 small EEPROM (size < 0x400) is used for VPD only. |
| 192 | * SFC4000 large EEPROM (size >= 0x400) is partitioned into: |
| 193 | * 0-0x400 chip and board config |
| 194 | * configurable VPD |
| 195 | * 0x800-0x1800 boot config |
| 196 | * Aside from the chip and board config, all of these are optional and may |
| 197 | * be absent or truncated depending on the devices used. |
| 198 | */ |
| 199 | #define FALCON_NVCONFIG_END 0x400U |
| 200 | #define FALCON_FLASH_BOOTCODE_START 0x8000U |
| 201 | #define FALCON_EEPROM_BOOTCONFIG_START 0x800U |
| 202 | #define FALCON_EEPROM_BOOTCONFIG_END 0x1800U |
| 203 | |
Ben Hutchings | ab0115f | 2012-09-13 01:11:31 +0100 | [diff] [blame] | 204 | /* Board configuration v2 (v1 is obsolete; later versions are compatible) */ |
| 205 | struct falcon_nvconfig_board_v2 { |
| 206 | __le16 nports; |
| 207 | u8 port0_phy_addr; |
| 208 | u8 port0_phy_type; |
| 209 | u8 port1_phy_addr; |
| 210 | u8 port1_phy_type; |
| 211 | __le16 asic_sub_revision; |
| 212 | __le16 board_revision; |
| 213 | } __packed; |
| 214 | |
| 215 | /* Board configuration v3 extra information */ |
| 216 | struct falcon_nvconfig_board_v3 { |
| 217 | __le32 spi_device_type[2]; |
| 218 | } __packed; |
| 219 | |
| 220 | /* Bit numbers for spi_device_type */ |
| 221 | #define SPI_DEV_TYPE_SIZE_LBN 0 |
| 222 | #define SPI_DEV_TYPE_SIZE_WIDTH 5 |
| 223 | #define SPI_DEV_TYPE_ADDR_LEN_LBN 6 |
| 224 | #define SPI_DEV_TYPE_ADDR_LEN_WIDTH 2 |
| 225 | #define SPI_DEV_TYPE_ERASE_CMD_LBN 8 |
| 226 | #define SPI_DEV_TYPE_ERASE_CMD_WIDTH 8 |
| 227 | #define SPI_DEV_TYPE_ERASE_SIZE_LBN 16 |
| 228 | #define SPI_DEV_TYPE_ERASE_SIZE_WIDTH 5 |
| 229 | #define SPI_DEV_TYPE_BLOCK_SIZE_LBN 24 |
| 230 | #define SPI_DEV_TYPE_BLOCK_SIZE_WIDTH 5 |
| 231 | #define SPI_DEV_TYPE_FIELD(type, field) \ |
| 232 | (((type) >> EFX_LOW_BIT(field)) & EFX_MASK32(EFX_WIDTH(field))) |
| 233 | |
| 234 | #define FALCON_NVCONFIG_OFFSET 0x300 |
| 235 | |
| 236 | #define FALCON_NVCONFIG_BOARD_MAGIC_NUM 0xFA1C |
| 237 | struct falcon_nvconfig { |
| 238 | efx_oword_t ee_vpd_cfg_reg; /* 0x300 */ |
| 239 | u8 mac_address[2][8]; /* 0x310 */ |
| 240 | efx_oword_t pcie_sd_ctl0123_reg; /* 0x320 */ |
| 241 | efx_oword_t pcie_sd_ctl45_reg; /* 0x330 */ |
| 242 | efx_oword_t pcie_pcs_ctl_stat_reg; /* 0x340 */ |
| 243 | efx_oword_t hw_init_reg; /* 0x350 */ |
| 244 | efx_oword_t nic_stat_reg; /* 0x360 */ |
| 245 | efx_oword_t glb_ctl_reg; /* 0x370 */ |
| 246 | efx_oword_t srm_cfg_reg; /* 0x380 */ |
| 247 | efx_oword_t spare_reg; /* 0x390 */ |
| 248 | __le16 board_magic_num; /* 0x3A0 */ |
| 249 | __le16 board_struct_ver; |
| 250 | __le16 board_checksum; |
| 251 | struct falcon_nvconfig_board_v2 board_v2; |
| 252 | efx_oword_t ee_base_page_reg; /* 0x3B0 */ |
| 253 | struct falcon_nvconfig_board_v3 board_v3; /* 0x3C0 */ |
| 254 | } __packed; |
| 255 | |
| 256 | /*************************************************************************/ |
| 257 | |
Ben Hutchings | d4f2cec | 2012-07-04 03:58:33 +0100 | [diff] [blame] | 258 | static int falcon_reset_hw(struct efx_nic *efx, enum reset_type method); |
Ben Hutchings | ab0115f | 2012-09-13 01:11:31 +0100 | [diff] [blame] | 259 | static void falcon_reconfigure_mac_wrapper(struct efx_nic *efx); |
Ben Hutchings | d4f2cec | 2012-07-04 03:58:33 +0100 | [diff] [blame] | 260 | |
Ben Hutchings | 2f7f573 | 2008-12-12 21:34:25 -0800 | [diff] [blame] | 261 | static const unsigned int |
| 262 | /* "Large" EEPROM device: Atmel AT25640 or similar |
| 263 | * 8 KB, 16-bit address, 32 B write block */ |
| 264 | large_eeprom_type = ((13 << SPI_DEV_TYPE_SIZE_LBN) |
| 265 | | (2 << SPI_DEV_TYPE_ADDR_LEN_LBN) |
| 266 | | (5 << SPI_DEV_TYPE_BLOCK_SIZE_LBN)), |
| 267 | /* Default flash device: Atmel AT25F1024 |
| 268 | * 128 KB, 24-bit address, 32 KB erase block, 256 B write block */ |
| 269 | default_flash_type = ((17 << SPI_DEV_TYPE_SIZE_LBN) |
| 270 | | (3 << SPI_DEV_TYPE_ADDR_LEN_LBN) |
| 271 | | (0x52 << SPI_DEV_TYPE_ERASE_CMD_LBN) |
| 272 | | (15 << SPI_DEV_TYPE_ERASE_SIZE_LBN) |
| 273 | | (8 << SPI_DEV_TYPE_BLOCK_SIZE_LBN)); |
| 274 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 275 | /************************************************************************** |
| 276 | * |
| 277 | * I2C bus - this is a bit-bashing interface using GPIO pins |
| 278 | * Note that it uses the output enables to tristate the outputs |
| 279 | * SDA is the data pin and SCL is the clock |
| 280 | * |
| 281 | ************************************************************************** |
| 282 | */ |
Ben Hutchings | 37b5a60 | 2008-05-30 22:27:04 +0100 | [diff] [blame] | 283 | static void falcon_setsda(void *data, int state) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 284 | { |
Ben Hutchings | 37b5a60 | 2008-05-30 22:27:04 +0100 | [diff] [blame] | 285 | struct efx_nic *efx = (struct efx_nic *)data; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 286 | efx_oword_t reg; |
| 287 | |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 288 | efx_reado(efx, ®, FR_AB_GPIO_CTL); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 289 | EFX_SET_OWORD_FIELD(reg, FRF_AB_GPIO3_OEN, !state); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 290 | efx_writeo(efx, ®, FR_AB_GPIO_CTL); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 291 | } |
| 292 | |
Ben Hutchings | 37b5a60 | 2008-05-30 22:27:04 +0100 | [diff] [blame] | 293 | static void falcon_setscl(void *data, int state) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 294 | { |
Ben Hutchings | 37b5a60 | 2008-05-30 22:27:04 +0100 | [diff] [blame] | 295 | struct efx_nic *efx = (struct efx_nic *)data; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 296 | efx_oword_t reg; |
| 297 | |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 298 | efx_reado(efx, ®, FR_AB_GPIO_CTL); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 299 | EFX_SET_OWORD_FIELD(reg, FRF_AB_GPIO0_OEN, !state); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 300 | efx_writeo(efx, ®, FR_AB_GPIO_CTL); |
Ben Hutchings | 37b5a60 | 2008-05-30 22:27:04 +0100 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | static int falcon_getsda(void *data) |
| 304 | { |
| 305 | struct efx_nic *efx = (struct efx_nic *)data; |
| 306 | efx_oword_t reg; |
| 307 | |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 308 | efx_reado(efx, ®, FR_AB_GPIO_CTL); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 309 | return EFX_OWORD_FIELD(reg, FRF_AB_GPIO3_IN); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 310 | } |
| 311 | |
Ben Hutchings | 37b5a60 | 2008-05-30 22:27:04 +0100 | [diff] [blame] | 312 | static int falcon_getscl(void *data) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 313 | { |
Ben Hutchings | 37b5a60 | 2008-05-30 22:27:04 +0100 | [diff] [blame] | 314 | struct efx_nic *efx = (struct efx_nic *)data; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 315 | efx_oword_t reg; |
| 316 | |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 317 | efx_reado(efx, ®, FR_AB_GPIO_CTL); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 318 | return EFX_OWORD_FIELD(reg, FRF_AB_GPIO0_IN); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 319 | } |
| 320 | |
Ben Hutchings | 18e83e4 | 2012-01-05 19:05:20 +0000 | [diff] [blame] | 321 | static const struct i2c_algo_bit_data falcon_i2c_bit_operations = { |
Ben Hutchings | 37b5a60 | 2008-05-30 22:27:04 +0100 | [diff] [blame] | 322 | .setsda = falcon_setsda, |
| 323 | .setscl = falcon_setscl, |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 324 | .getsda = falcon_getsda, |
| 325 | .getscl = falcon_getscl, |
Ben Hutchings | 62c7832 | 2008-05-30 22:27:46 +0100 | [diff] [blame] | 326 | .udelay = 5, |
Ben Hutchings | 9dadae6 | 2008-07-18 18:59:12 +0100 | [diff] [blame] | 327 | /* Wait up to 50 ms for slave to let us pull SCL high */ |
| 328 | .timeout = DIV_ROUND_UP(HZ, 20), |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 329 | }; |
| 330 | |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 331 | static void falcon_push_irq_moderation(struct efx_channel *channel) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 332 | { |
| 333 | efx_dword_t timer_cmd; |
| 334 | struct efx_nic *efx = channel->efx; |
| 335 | |
| 336 | /* Set timer register */ |
| 337 | if (channel->irq_moderation) { |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 338 | EFX_POPULATE_DWORD_2(timer_cmd, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 339 | FRF_AB_TC_TIMER_MODE, |
| 340 | FFE_BB_TIMER_MODE_INT_HLDOFF, |
| 341 | FRF_AB_TC_TIMER_VAL, |
Ben Hutchings | 0d86ebd | 2009-10-23 08:32:13 +0000 | [diff] [blame] | 342 | channel->irq_moderation - 1); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 343 | } else { |
| 344 | EFX_POPULATE_DWORD_2(timer_cmd, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 345 | FRF_AB_TC_TIMER_MODE, |
| 346 | FFE_BB_TIMER_MODE_DIS, |
| 347 | FRF_AB_TC_TIMER_VAL, 0); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 348 | } |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 349 | BUILD_BUG_ON(FR_AA_TIMER_COMMAND_KER != FR_BZ_TIMER_COMMAND_P0); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 350 | efx_writed_page_locked(efx, &timer_cmd, FR_BZ_TIMER_COMMAND_P0, |
| 351 | channel->channel); |
Ben Hutchings | 127e6e1 | 2009-11-25 16:09:55 +0000 | [diff] [blame] | 352 | } |
| 353 | |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 354 | static void falcon_deconfigure_mac_wrapper(struct efx_nic *efx); |
| 355 | |
Ben Hutchings | 127e6e1 | 2009-11-25 16:09:55 +0000 | [diff] [blame] | 356 | static void falcon_prepare_flush(struct efx_nic *efx) |
| 357 | { |
| 358 | falcon_deconfigure_mac_wrapper(efx); |
| 359 | |
| 360 | /* Wait for the tx and rx fifo's to get to the next packet boundary |
| 361 | * (~1ms without back-pressure), then to drain the remainder of the |
| 362 | * fifo's at data path speeds (negligible), with a healthy margin. */ |
| 363 | msleep(10); |
Ben Hutchings | 6bc5d3a | 2008-09-01 12:49:37 +0100 | [diff] [blame] | 364 | } |
| 365 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 366 | /* Acknowledge a legacy interrupt from Falcon |
| 367 | * |
| 368 | * This acknowledges a legacy (not MSI) interrupt via INT_ACK_KER_REG. |
| 369 | * |
| 370 | * Due to SFC bug 3706 (silicon revision <=A1) reads can be duplicated in the |
| 371 | * BIU. Interrupt acknowledge is read sensitive so must write instead |
| 372 | * (then read to ensure the BIU collector is flushed) |
| 373 | * |
| 374 | * NB most hardware supports MSI interrupts |
| 375 | */ |
Ben Hutchings | 1840667 | 2013-01-03 23:36:57 +0000 | [diff] [blame] | 376 | static inline void falcon_irq_ack_a1(struct efx_nic *efx) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 377 | { |
| 378 | efx_dword_t reg; |
| 379 | |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 380 | EFX_POPULATE_DWORD_1(reg, FRF_AA_INT_ACK_KER_FIELD, 0xb7eb7e); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 381 | efx_writed(efx, ®, FR_AA_INT_ACK_KER); |
| 382 | efx_readd(efx, ®, FR_AA_WORK_AROUND_BROKEN_PCI_READS); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 383 | } |
| 384 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 385 | |
Ben Hutchings | 86094f7 | 2013-08-21 19:51:04 +0100 | [diff] [blame] | 386 | static irqreturn_t falcon_legacy_interrupt_a1(int irq, void *dev_id) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 387 | { |
Ben Hutchings | d3208b5 | 2008-05-16 21:20:00 +0100 | [diff] [blame] | 388 | struct efx_nic *efx = dev_id; |
| 389 | efx_oword_t *int_ker = efx->irq_status.addr; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 390 | int syserr; |
| 391 | int queues; |
| 392 | |
| 393 | /* Check to see if this is our interrupt. If it isn't, we |
| 394 | * exit without having touched the hardware. |
| 395 | */ |
| 396 | if (unlikely(EFX_OWORD_IS_ZERO(*int_ker))) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 397 | netif_vdbg(efx, intr, efx->net_dev, |
| 398 | "IRQ %d on CPU %d not for me\n", irq, |
| 399 | raw_smp_processor_id()); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 400 | return IRQ_NONE; |
| 401 | } |
| 402 | efx->last_irq_cpu = raw_smp_processor_id(); |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 403 | netif_vdbg(efx, intr, efx->net_dev, |
| 404 | "IRQ %d on CPU %d status " EFX_OWORD_FMT "\n", |
| 405 | irq, raw_smp_processor_id(), EFX_OWORD_VAL(*int_ker)); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 406 | |
Ben Hutchings | d829118 | 2012-10-05 23:35:41 +0100 | [diff] [blame] | 407 | if (!likely(ACCESS_ONCE(efx->irq_soft_enabled))) |
| 408 | return IRQ_HANDLED; |
| 409 | |
Ben Hutchings | f70d184 | 2012-01-06 01:08:24 +0000 | [diff] [blame] | 410 | /* Check to see if we have a serious error condition */ |
| 411 | syserr = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_FATAL_INT); |
| 412 | if (unlikely(syserr)) |
Ben Hutchings | 86094f7 | 2013-08-21 19:51:04 +0100 | [diff] [blame] | 413 | return efx_farch_fatal_interrupt(efx); |
Ben Hutchings | f70d184 | 2012-01-06 01:08:24 +0000 | [diff] [blame] | 414 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 415 | /* Determine interrupting queues, clear interrupt status |
| 416 | * register and acknowledge the device interrupt. |
| 417 | */ |
Ben Hutchings | 674979d | 2009-11-29 03:42:10 +0000 | [diff] [blame] | 418 | BUILD_BUG_ON(FSF_AZ_NET_IVEC_INT_Q_WIDTH > EFX_MAX_CHANNELS); |
| 419 | queues = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_INT_Q); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 420 | EFX_ZERO_OWORD(*int_ker); |
| 421 | wmb(); /* Ensure the vector is cleared before interrupt ack */ |
| 422 | falcon_irq_ack_a1(efx); |
| 423 | |
Ben Hutchings | 8313aca | 2010-09-10 06:41:57 +0000 | [diff] [blame] | 424 | if (queues & 1) |
Ben Hutchings | 1646a6f3 | 2012-01-05 20:14:10 +0000 | [diff] [blame] | 425 | efx_schedule_channel_irq(efx_get_channel(efx, 0)); |
Ben Hutchings | 8313aca | 2010-09-10 06:41:57 +0000 | [diff] [blame] | 426 | if (queues & 2) |
Ben Hutchings | 1646a6f3 | 2012-01-05 20:14:10 +0000 | [diff] [blame] | 427 | efx_schedule_channel_irq(efx_get_channel(efx, 1)); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 428 | return IRQ_HANDLED; |
| 429 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 430 | /************************************************************************** |
| 431 | * |
| 432 | * EEPROM/flash |
| 433 | * |
| 434 | ************************************************************************** |
| 435 | */ |
| 436 | |
Ben Hutchings | 23d30f0 | 2008-12-12 21:56:11 -0800 | [diff] [blame] | 437 | #define FALCON_SPI_MAX_LEN sizeof(efx_oword_t) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 438 | |
Ben Hutchings | be4ea89 | 2008-12-12 21:33:50 -0800 | [diff] [blame] | 439 | static int falcon_spi_poll(struct efx_nic *efx) |
| 440 | { |
| 441 | efx_oword_t reg; |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 442 | efx_reado(efx, ®, FR_AB_EE_SPI_HCMD); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 443 | return EFX_OWORD_FIELD(reg, FRF_AB_EE_SPI_HCMD_CMD_EN) ? -EBUSY : 0; |
Ben Hutchings | be4ea89 | 2008-12-12 21:33:50 -0800 | [diff] [blame] | 444 | } |
| 445 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 446 | /* Wait for SPI command completion */ |
| 447 | static int falcon_spi_wait(struct efx_nic *efx) |
| 448 | { |
Ben Hutchings | be4ea89 | 2008-12-12 21:33:50 -0800 | [diff] [blame] | 449 | /* Most commands will finish quickly, so we start polling at |
| 450 | * very short intervals. Sometimes the command may have to |
| 451 | * wait for VPD or expansion ROM access outside of our |
| 452 | * control, so we allow up to 100 ms. */ |
| 453 | unsigned long timeout = jiffies + 1 + DIV_ROUND_UP(HZ, 10); |
| 454 | int i; |
| 455 | |
| 456 | for (i = 0; i < 10; i++) { |
| 457 | if (!falcon_spi_poll(efx)) |
| 458 | return 0; |
| 459 | udelay(10); |
| 460 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 461 | |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 462 | for (;;) { |
Ben Hutchings | be4ea89 | 2008-12-12 21:33:50 -0800 | [diff] [blame] | 463 | if (!falcon_spi_poll(efx)) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 464 | return 0; |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 465 | if (time_after_eq(jiffies, timeout)) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 466 | netif_err(efx, hw, efx->net_dev, |
| 467 | "timed out waiting for SPI\n"); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 468 | return -ETIMEDOUT; |
| 469 | } |
Ben Hutchings | be4ea89 | 2008-12-12 21:33:50 -0800 | [diff] [blame] | 470 | schedule_timeout_uninterruptible(1); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 471 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 472 | } |
| 473 | |
Ben Hutchings | 45a3fd5 | 2012-11-28 04:38:14 +0000 | [diff] [blame] | 474 | static int |
| 475 | falcon_spi_cmd(struct efx_nic *efx, const struct falcon_spi_device *spi, |
| 476 | unsigned int command, int address, |
| 477 | const void *in, void *out, size_t len) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 478 | { |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 479 | bool addressed = (address >= 0); |
| 480 | bool reading = (out != NULL); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 481 | efx_oword_t reg; |
| 482 | int rc; |
| 483 | |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 484 | /* Input validation */ |
| 485 | if (len > FALCON_SPI_MAX_LEN) |
| 486 | return -EINVAL; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 487 | |
Ben Hutchings | be4ea89 | 2008-12-12 21:33:50 -0800 | [diff] [blame] | 488 | /* Check that previous command is not still running */ |
| 489 | rc = falcon_spi_poll(efx); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 490 | if (rc) |
| 491 | return rc; |
| 492 | |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 493 | /* Program address register, if we have an address */ |
| 494 | if (addressed) { |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 495 | EFX_POPULATE_OWORD_1(reg, FRF_AB_EE_SPI_HADR_ADR, address); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 496 | efx_writeo(efx, ®, FR_AB_EE_SPI_HADR); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 497 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 498 | |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 499 | /* Program data register, if we have data */ |
| 500 | if (in != NULL) { |
| 501 | memcpy(®, in, len); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 502 | efx_writeo(efx, ®, FR_AB_EE_SPI_HDATA); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | /* Issue read/write command */ |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 506 | EFX_POPULATE_OWORD_7(reg, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 507 | FRF_AB_EE_SPI_HCMD_CMD_EN, 1, |
| 508 | FRF_AB_EE_SPI_HCMD_SF_SEL, spi->device_id, |
| 509 | FRF_AB_EE_SPI_HCMD_DABCNT, len, |
| 510 | FRF_AB_EE_SPI_HCMD_READ, reading, |
| 511 | FRF_AB_EE_SPI_HCMD_DUBCNT, 0, |
| 512 | FRF_AB_EE_SPI_HCMD_ADBCNT, |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 513 | (addressed ? spi->addr_len : 0), |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 514 | FRF_AB_EE_SPI_HCMD_ENC, command); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 515 | efx_writeo(efx, ®, FR_AB_EE_SPI_HCMD); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 516 | |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 517 | /* Wait for read/write to complete */ |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 518 | rc = falcon_spi_wait(efx); |
| 519 | if (rc) |
| 520 | return rc; |
| 521 | |
| 522 | /* Read data */ |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 523 | if (out != NULL) { |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 524 | efx_reado(efx, ®, FR_AB_EE_SPI_HDATA); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 525 | memcpy(out, ®, len); |
| 526 | } |
| 527 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 528 | return 0; |
| 529 | } |
| 530 | |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 531 | static inline u8 |
Ben Hutchings | ecd0a6f0 | 2012-11-28 04:12:41 +0000 | [diff] [blame] | 532 | falcon_spi_munge_command(const struct falcon_spi_device *spi, |
| 533 | const u8 command, const unsigned int address) |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 534 | { |
| 535 | return command | (((address >> 8) & spi->munge_address) << 3); |
| 536 | } |
| 537 | |
Ben Hutchings | 45a3fd5 | 2012-11-28 04:38:14 +0000 | [diff] [blame] | 538 | static int |
| 539 | falcon_spi_read(struct efx_nic *efx, const struct falcon_spi_device *spi, |
| 540 | loff_t start, size_t len, size_t *retlen, u8 *buffer) |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 541 | { |
Ben Hutchings | 23d30f0 | 2008-12-12 21:56:11 -0800 | [diff] [blame] | 542 | size_t block_len, pos = 0; |
| 543 | unsigned int command; |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 544 | int rc = 0; |
| 545 | |
| 546 | while (pos < len) { |
Ben Hutchings | 23d30f0 | 2008-12-12 21:56:11 -0800 | [diff] [blame] | 547 | block_len = min(len - pos, FALCON_SPI_MAX_LEN); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 548 | |
Ben Hutchings | ecd0a6f0 | 2012-11-28 04:12:41 +0000 | [diff] [blame] | 549 | command = falcon_spi_munge_command(spi, SPI_READ, start + pos); |
Ben Hutchings | 7688483 | 2009-11-29 15:10:44 +0000 | [diff] [blame] | 550 | rc = falcon_spi_cmd(efx, spi, command, start + pos, NULL, |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 551 | buffer + pos, block_len); |
| 552 | if (rc) |
| 553 | break; |
| 554 | pos += block_len; |
| 555 | |
| 556 | /* Avoid locking up the system */ |
| 557 | cond_resched(); |
| 558 | if (signal_pending(current)) { |
| 559 | rc = -EINTR; |
| 560 | break; |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | if (retlen) |
| 565 | *retlen = pos; |
| 566 | return rc; |
| 567 | } |
| 568 | |
Ben Hutchings | 45a3fd5 | 2012-11-28 04:38:14 +0000 | [diff] [blame] | 569 | #ifdef CONFIG_SFC_MTD |
| 570 | |
| 571 | struct falcon_mtd_partition { |
| 572 | struct efx_mtd_partition common; |
| 573 | const struct falcon_spi_device *spi; |
| 574 | size_t offset; |
| 575 | }; |
| 576 | |
| 577 | #define to_falcon_mtd_partition(mtd) \ |
| 578 | container_of(mtd, struct falcon_mtd_partition, common.mtd) |
| 579 | |
| 580 | static size_t |
| 581 | falcon_spi_write_limit(const struct falcon_spi_device *spi, size_t start) |
| 582 | { |
| 583 | return min(FALCON_SPI_MAX_LEN, |
| 584 | (spi->block_size - (start & (spi->block_size - 1)))); |
| 585 | } |
| 586 | |
| 587 | /* Wait up to 10 ms for buffered write completion */ |
| 588 | static int |
| 589 | falcon_spi_wait_write(struct efx_nic *efx, const struct falcon_spi_device *spi) |
| 590 | { |
| 591 | unsigned long timeout = jiffies + 1 + DIV_ROUND_UP(HZ, 100); |
| 592 | u8 status; |
| 593 | int rc; |
| 594 | |
| 595 | for (;;) { |
| 596 | rc = falcon_spi_cmd(efx, spi, SPI_RDSR, -1, NULL, |
| 597 | &status, sizeof(status)); |
| 598 | if (rc) |
| 599 | return rc; |
| 600 | if (!(status & SPI_STATUS_NRDY)) |
| 601 | return 0; |
| 602 | if (time_after_eq(jiffies, timeout)) { |
| 603 | netif_err(efx, hw, efx->net_dev, |
| 604 | "SPI write timeout on device %d" |
| 605 | " last status=0x%02x\n", |
| 606 | spi->device_id, status); |
| 607 | return -ETIMEDOUT; |
| 608 | } |
| 609 | schedule_timeout_uninterruptible(1); |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | static int |
Ben Hutchings | ecd0a6f0 | 2012-11-28 04:12:41 +0000 | [diff] [blame] | 614 | falcon_spi_write(struct efx_nic *efx, const struct falcon_spi_device *spi, |
Ben Hutchings | 7688483 | 2009-11-29 15:10:44 +0000 | [diff] [blame] | 615 | loff_t start, size_t len, size_t *retlen, const u8 *buffer) |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 616 | { |
| 617 | u8 verify_buffer[FALCON_SPI_MAX_LEN]; |
Ben Hutchings | 23d30f0 | 2008-12-12 21:56:11 -0800 | [diff] [blame] | 618 | size_t block_len, pos = 0; |
| 619 | unsigned int command; |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 620 | int rc = 0; |
| 621 | |
| 622 | while (pos < len) { |
Ben Hutchings | 7688483 | 2009-11-29 15:10:44 +0000 | [diff] [blame] | 623 | rc = falcon_spi_cmd(efx, spi, SPI_WREN, -1, NULL, NULL, 0); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 624 | if (rc) |
| 625 | break; |
| 626 | |
Ben Hutchings | 23d30f0 | 2008-12-12 21:56:11 -0800 | [diff] [blame] | 627 | block_len = min(len - pos, |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 628 | falcon_spi_write_limit(spi, start + pos)); |
Ben Hutchings | ecd0a6f0 | 2012-11-28 04:12:41 +0000 | [diff] [blame] | 629 | command = falcon_spi_munge_command(spi, SPI_WRITE, start + pos); |
Ben Hutchings | 7688483 | 2009-11-29 15:10:44 +0000 | [diff] [blame] | 630 | rc = falcon_spi_cmd(efx, spi, command, start + pos, |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 631 | buffer + pos, NULL, block_len); |
| 632 | if (rc) |
| 633 | break; |
| 634 | |
Ben Hutchings | 7688483 | 2009-11-29 15:10:44 +0000 | [diff] [blame] | 635 | rc = falcon_spi_wait_write(efx, spi); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 636 | if (rc) |
| 637 | break; |
| 638 | |
Ben Hutchings | ecd0a6f0 | 2012-11-28 04:12:41 +0000 | [diff] [blame] | 639 | command = falcon_spi_munge_command(spi, SPI_READ, start + pos); |
Ben Hutchings | 7688483 | 2009-11-29 15:10:44 +0000 | [diff] [blame] | 640 | rc = falcon_spi_cmd(efx, spi, command, start + pos, |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 641 | NULL, verify_buffer, block_len); |
| 642 | if (memcmp(verify_buffer, buffer + pos, block_len)) { |
| 643 | rc = -EIO; |
| 644 | break; |
| 645 | } |
| 646 | |
| 647 | pos += block_len; |
| 648 | |
| 649 | /* Avoid locking up the system */ |
| 650 | cond_resched(); |
| 651 | if (signal_pending(current)) { |
| 652 | rc = -EINTR; |
| 653 | break; |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | if (retlen) |
| 658 | *retlen = pos; |
| 659 | return rc; |
| 660 | } |
| 661 | |
Ben Hutchings | 45a3fd5 | 2012-11-28 04:38:14 +0000 | [diff] [blame] | 662 | static int |
| 663 | falcon_spi_slow_wait(struct falcon_mtd_partition *part, bool uninterruptible) |
| 664 | { |
| 665 | const struct falcon_spi_device *spi = part->spi; |
| 666 | struct efx_nic *efx = part->common.mtd.priv; |
| 667 | u8 status; |
| 668 | int rc, i; |
| 669 | |
| 670 | /* Wait up to 4s for flash/EEPROM to finish a slow operation. */ |
| 671 | for (i = 0; i < 40; i++) { |
| 672 | __set_current_state(uninterruptible ? |
| 673 | TASK_UNINTERRUPTIBLE : TASK_INTERRUPTIBLE); |
| 674 | schedule_timeout(HZ / 10); |
| 675 | rc = falcon_spi_cmd(efx, spi, SPI_RDSR, -1, NULL, |
| 676 | &status, sizeof(status)); |
| 677 | if (rc) |
| 678 | return rc; |
| 679 | if (!(status & SPI_STATUS_NRDY)) |
| 680 | return 0; |
| 681 | if (signal_pending(current)) |
| 682 | return -EINTR; |
| 683 | } |
| 684 | pr_err("%s: timed out waiting for %s\n", |
| 685 | part->common.name, part->common.dev_type_name); |
| 686 | return -ETIMEDOUT; |
| 687 | } |
| 688 | |
| 689 | static int |
| 690 | falcon_spi_unlock(struct efx_nic *efx, const struct falcon_spi_device *spi) |
| 691 | { |
| 692 | const u8 unlock_mask = (SPI_STATUS_BP2 | SPI_STATUS_BP1 | |
| 693 | SPI_STATUS_BP0); |
| 694 | u8 status; |
| 695 | int rc; |
| 696 | |
| 697 | rc = falcon_spi_cmd(efx, spi, SPI_RDSR, -1, NULL, |
| 698 | &status, sizeof(status)); |
| 699 | if (rc) |
| 700 | return rc; |
| 701 | |
| 702 | if (!(status & unlock_mask)) |
| 703 | return 0; /* already unlocked */ |
| 704 | |
| 705 | rc = falcon_spi_cmd(efx, spi, SPI_WREN, -1, NULL, NULL, 0); |
| 706 | if (rc) |
| 707 | return rc; |
| 708 | rc = falcon_spi_cmd(efx, spi, SPI_SST_EWSR, -1, NULL, NULL, 0); |
| 709 | if (rc) |
| 710 | return rc; |
| 711 | |
| 712 | status &= ~unlock_mask; |
| 713 | rc = falcon_spi_cmd(efx, spi, SPI_WRSR, -1, &status, |
| 714 | NULL, sizeof(status)); |
| 715 | if (rc) |
| 716 | return rc; |
| 717 | rc = falcon_spi_wait_write(efx, spi); |
| 718 | if (rc) |
| 719 | return rc; |
| 720 | |
| 721 | return 0; |
| 722 | } |
| 723 | |
| 724 | #define FALCON_SPI_VERIFY_BUF_LEN 16 |
| 725 | |
| 726 | static int |
| 727 | falcon_spi_erase(struct falcon_mtd_partition *part, loff_t start, size_t len) |
| 728 | { |
| 729 | const struct falcon_spi_device *spi = part->spi; |
| 730 | struct efx_nic *efx = part->common.mtd.priv; |
| 731 | unsigned pos, block_len; |
| 732 | u8 empty[FALCON_SPI_VERIFY_BUF_LEN]; |
| 733 | u8 buffer[FALCON_SPI_VERIFY_BUF_LEN]; |
| 734 | int rc; |
| 735 | |
| 736 | if (len != spi->erase_size) |
| 737 | return -EINVAL; |
| 738 | |
| 739 | if (spi->erase_command == 0) |
| 740 | return -EOPNOTSUPP; |
| 741 | |
| 742 | rc = falcon_spi_unlock(efx, spi); |
| 743 | if (rc) |
| 744 | return rc; |
| 745 | rc = falcon_spi_cmd(efx, spi, SPI_WREN, -1, NULL, NULL, 0); |
| 746 | if (rc) |
| 747 | return rc; |
| 748 | rc = falcon_spi_cmd(efx, spi, spi->erase_command, start, NULL, |
| 749 | NULL, 0); |
| 750 | if (rc) |
| 751 | return rc; |
| 752 | rc = falcon_spi_slow_wait(part, false); |
| 753 | |
| 754 | /* Verify the entire region has been wiped */ |
| 755 | memset(empty, 0xff, sizeof(empty)); |
| 756 | for (pos = 0; pos < len; pos += block_len) { |
| 757 | block_len = min(len - pos, sizeof(buffer)); |
| 758 | rc = falcon_spi_read(efx, spi, start + pos, block_len, |
| 759 | NULL, buffer); |
| 760 | if (rc) |
| 761 | return rc; |
| 762 | if (memcmp(empty, buffer, block_len)) |
| 763 | return -EIO; |
| 764 | |
| 765 | /* Avoid locking up the system */ |
| 766 | cond_resched(); |
| 767 | if (signal_pending(current)) |
| 768 | return -EINTR; |
| 769 | } |
| 770 | |
| 771 | return rc; |
| 772 | } |
| 773 | |
| 774 | static void falcon_mtd_rename(struct efx_mtd_partition *part) |
| 775 | { |
| 776 | struct efx_nic *efx = part->mtd.priv; |
| 777 | |
| 778 | snprintf(part->name, sizeof(part->name), "%s %s", |
| 779 | efx->name, part->type_name); |
| 780 | } |
| 781 | |
| 782 | static int falcon_mtd_read(struct mtd_info *mtd, loff_t start, |
| 783 | size_t len, size_t *retlen, u8 *buffer) |
| 784 | { |
| 785 | struct falcon_mtd_partition *part = to_falcon_mtd_partition(mtd); |
| 786 | struct efx_nic *efx = mtd->priv; |
| 787 | struct falcon_nic_data *nic_data = efx->nic_data; |
| 788 | int rc; |
| 789 | |
| 790 | rc = mutex_lock_interruptible(&nic_data->spi_lock); |
| 791 | if (rc) |
| 792 | return rc; |
| 793 | rc = falcon_spi_read(efx, part->spi, part->offset + start, |
| 794 | len, retlen, buffer); |
| 795 | mutex_unlock(&nic_data->spi_lock); |
| 796 | return rc; |
| 797 | } |
| 798 | |
| 799 | static int falcon_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len) |
| 800 | { |
| 801 | struct falcon_mtd_partition *part = to_falcon_mtd_partition(mtd); |
| 802 | struct efx_nic *efx = mtd->priv; |
| 803 | struct falcon_nic_data *nic_data = efx->nic_data; |
| 804 | int rc; |
| 805 | |
| 806 | rc = mutex_lock_interruptible(&nic_data->spi_lock); |
| 807 | if (rc) |
| 808 | return rc; |
| 809 | rc = falcon_spi_erase(part, part->offset + start, len); |
| 810 | mutex_unlock(&nic_data->spi_lock); |
| 811 | return rc; |
| 812 | } |
| 813 | |
| 814 | static int falcon_mtd_write(struct mtd_info *mtd, loff_t start, |
| 815 | size_t len, size_t *retlen, const u8 *buffer) |
| 816 | { |
| 817 | struct falcon_mtd_partition *part = to_falcon_mtd_partition(mtd); |
| 818 | struct efx_nic *efx = mtd->priv; |
| 819 | struct falcon_nic_data *nic_data = efx->nic_data; |
| 820 | int rc; |
| 821 | |
| 822 | rc = mutex_lock_interruptible(&nic_data->spi_lock); |
| 823 | if (rc) |
| 824 | return rc; |
| 825 | rc = falcon_spi_write(efx, part->spi, part->offset + start, |
| 826 | len, retlen, buffer); |
| 827 | mutex_unlock(&nic_data->spi_lock); |
| 828 | return rc; |
| 829 | } |
| 830 | |
| 831 | static int falcon_mtd_sync(struct mtd_info *mtd) |
| 832 | { |
| 833 | struct falcon_mtd_partition *part = to_falcon_mtd_partition(mtd); |
| 834 | struct efx_nic *efx = mtd->priv; |
| 835 | struct falcon_nic_data *nic_data = efx->nic_data; |
| 836 | int rc; |
| 837 | |
| 838 | mutex_lock(&nic_data->spi_lock); |
| 839 | rc = falcon_spi_slow_wait(part, true); |
| 840 | mutex_unlock(&nic_data->spi_lock); |
| 841 | return rc; |
| 842 | } |
| 843 | |
| 844 | static int falcon_mtd_probe(struct efx_nic *efx) |
| 845 | { |
| 846 | struct falcon_nic_data *nic_data = efx->nic_data; |
| 847 | struct falcon_mtd_partition *parts; |
| 848 | struct falcon_spi_device *spi; |
| 849 | size_t n_parts; |
| 850 | int rc = -ENODEV; |
| 851 | |
| 852 | ASSERT_RTNL(); |
| 853 | |
| 854 | /* Allocate space for maximum number of partitions */ |
| 855 | parts = kcalloc(2, sizeof(*parts), GFP_KERNEL); |
| 856 | n_parts = 0; |
| 857 | |
| 858 | spi = &nic_data->spi_flash; |
| 859 | if (falcon_spi_present(spi) && spi->size > FALCON_FLASH_BOOTCODE_START) { |
| 860 | parts[n_parts].spi = spi; |
| 861 | parts[n_parts].offset = FALCON_FLASH_BOOTCODE_START; |
| 862 | parts[n_parts].common.dev_type_name = "flash"; |
| 863 | parts[n_parts].common.type_name = "sfc_flash_bootrom"; |
| 864 | parts[n_parts].common.mtd.type = MTD_NORFLASH; |
| 865 | parts[n_parts].common.mtd.flags = MTD_CAP_NORFLASH; |
| 866 | parts[n_parts].common.mtd.size = spi->size - FALCON_FLASH_BOOTCODE_START; |
| 867 | parts[n_parts].common.mtd.erasesize = spi->erase_size; |
| 868 | n_parts++; |
| 869 | } |
| 870 | |
| 871 | spi = &nic_data->spi_eeprom; |
| 872 | if (falcon_spi_present(spi) && spi->size > FALCON_EEPROM_BOOTCONFIG_START) { |
| 873 | parts[n_parts].spi = spi; |
| 874 | parts[n_parts].offset = FALCON_EEPROM_BOOTCONFIG_START; |
| 875 | parts[n_parts].common.dev_type_name = "EEPROM"; |
| 876 | parts[n_parts].common.type_name = "sfc_bootconfig"; |
| 877 | parts[n_parts].common.mtd.type = MTD_RAM; |
| 878 | parts[n_parts].common.mtd.flags = MTD_CAP_RAM; |
| 879 | parts[n_parts].common.mtd.size = |
| 880 | min(spi->size, FALCON_EEPROM_BOOTCONFIG_END) - |
| 881 | FALCON_EEPROM_BOOTCONFIG_START; |
| 882 | parts[n_parts].common.mtd.erasesize = spi->erase_size; |
| 883 | n_parts++; |
| 884 | } |
| 885 | |
| 886 | rc = efx_mtd_add(efx, &parts[0].common, n_parts, sizeof(*parts)); |
| 887 | if (rc) |
| 888 | kfree(parts); |
| 889 | return rc; |
| 890 | } |
| 891 | |
| 892 | #endif /* CONFIG_SFC_MTD */ |
| 893 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 894 | /************************************************************************** |
| 895 | * |
Ben Hutchings | ab0115f | 2012-09-13 01:11:31 +0100 | [diff] [blame] | 896 | * XMAC operations |
| 897 | * |
| 898 | ************************************************************************** |
| 899 | */ |
| 900 | |
| 901 | /* Configure the XAUI driver that is an output from Falcon */ |
| 902 | static void falcon_setup_xaui(struct efx_nic *efx) |
| 903 | { |
| 904 | efx_oword_t sdctl, txdrv; |
| 905 | |
| 906 | /* Move the XAUI into low power, unless there is no PHY, in |
| 907 | * which case the XAUI will have to drive a cable. */ |
| 908 | if (efx->phy_type == PHY_TYPE_NONE) |
| 909 | return; |
| 910 | |
| 911 | efx_reado(efx, &sdctl, FR_AB_XX_SD_CTL); |
| 912 | EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_HIDRVD, FFE_AB_XX_SD_CTL_DRV_DEF); |
| 913 | EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_LODRVD, FFE_AB_XX_SD_CTL_DRV_DEF); |
| 914 | EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_HIDRVC, FFE_AB_XX_SD_CTL_DRV_DEF); |
| 915 | EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_LODRVC, FFE_AB_XX_SD_CTL_DRV_DEF); |
| 916 | EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_HIDRVB, FFE_AB_XX_SD_CTL_DRV_DEF); |
| 917 | EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_LODRVB, FFE_AB_XX_SD_CTL_DRV_DEF); |
| 918 | EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_HIDRVA, FFE_AB_XX_SD_CTL_DRV_DEF); |
| 919 | EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_LODRVA, FFE_AB_XX_SD_CTL_DRV_DEF); |
| 920 | efx_writeo(efx, &sdctl, FR_AB_XX_SD_CTL); |
| 921 | |
| 922 | EFX_POPULATE_OWORD_8(txdrv, |
| 923 | FRF_AB_XX_DEQD, FFE_AB_XX_TXDRV_DEQ_DEF, |
| 924 | FRF_AB_XX_DEQC, FFE_AB_XX_TXDRV_DEQ_DEF, |
| 925 | FRF_AB_XX_DEQB, FFE_AB_XX_TXDRV_DEQ_DEF, |
| 926 | FRF_AB_XX_DEQA, FFE_AB_XX_TXDRV_DEQ_DEF, |
| 927 | FRF_AB_XX_DTXD, FFE_AB_XX_TXDRV_DTX_DEF, |
| 928 | FRF_AB_XX_DTXC, FFE_AB_XX_TXDRV_DTX_DEF, |
| 929 | FRF_AB_XX_DTXB, FFE_AB_XX_TXDRV_DTX_DEF, |
| 930 | FRF_AB_XX_DTXA, FFE_AB_XX_TXDRV_DTX_DEF); |
| 931 | efx_writeo(efx, &txdrv, FR_AB_XX_TXDRV_CTL); |
| 932 | } |
| 933 | |
| 934 | int falcon_reset_xaui(struct efx_nic *efx) |
| 935 | { |
| 936 | struct falcon_nic_data *nic_data = efx->nic_data; |
| 937 | efx_oword_t reg; |
| 938 | int count; |
| 939 | |
| 940 | /* Don't fetch MAC statistics over an XMAC reset */ |
| 941 | WARN_ON(nic_data->stats_disable_count == 0); |
| 942 | |
| 943 | /* Start reset sequence */ |
| 944 | EFX_POPULATE_OWORD_1(reg, FRF_AB_XX_RST_XX_EN, 1); |
| 945 | efx_writeo(efx, ®, FR_AB_XX_PWR_RST); |
| 946 | |
| 947 | /* Wait up to 10 ms for completion, then reinitialise */ |
| 948 | for (count = 0; count < 1000; count++) { |
| 949 | efx_reado(efx, ®, FR_AB_XX_PWR_RST); |
| 950 | if (EFX_OWORD_FIELD(reg, FRF_AB_XX_RST_XX_EN) == 0 && |
| 951 | EFX_OWORD_FIELD(reg, FRF_AB_XX_SD_RST_ACT) == 0) { |
| 952 | falcon_setup_xaui(efx); |
| 953 | return 0; |
| 954 | } |
| 955 | udelay(10); |
| 956 | } |
| 957 | netif_err(efx, hw, efx->net_dev, |
| 958 | "timed out waiting for XAUI/XGXS reset\n"); |
| 959 | return -ETIMEDOUT; |
| 960 | } |
| 961 | |
| 962 | static void falcon_ack_status_intr(struct efx_nic *efx) |
| 963 | { |
| 964 | struct falcon_nic_data *nic_data = efx->nic_data; |
| 965 | efx_oword_t reg; |
| 966 | |
| 967 | if ((efx_nic_rev(efx) != EFX_REV_FALCON_B0) || LOOPBACK_INTERNAL(efx)) |
| 968 | return; |
| 969 | |
| 970 | /* We expect xgmii faults if the wireside link is down */ |
Ben Hutchings | ab3b825 | 2012-10-05 19:31:02 +0100 | [diff] [blame] | 971 | if (!efx->link_state.up) |
Ben Hutchings | ab0115f | 2012-09-13 01:11:31 +0100 | [diff] [blame] | 972 | return; |
| 973 | |
| 974 | /* We can only use this interrupt to signal the negative edge of |
| 975 | * xaui_align [we have to poll the positive edge]. */ |
| 976 | if (nic_data->xmac_poll_required) |
| 977 | return; |
| 978 | |
| 979 | efx_reado(efx, ®, FR_AB_XM_MGT_INT_MSK); |
| 980 | } |
| 981 | |
| 982 | static bool falcon_xgxs_link_ok(struct efx_nic *efx) |
| 983 | { |
| 984 | efx_oword_t reg; |
| 985 | bool align_done, link_ok = false; |
| 986 | int sync_status; |
| 987 | |
| 988 | /* Read link status */ |
| 989 | efx_reado(efx, ®, FR_AB_XX_CORE_STAT); |
| 990 | |
| 991 | align_done = EFX_OWORD_FIELD(reg, FRF_AB_XX_ALIGN_DONE); |
| 992 | sync_status = EFX_OWORD_FIELD(reg, FRF_AB_XX_SYNC_STAT); |
| 993 | if (align_done && (sync_status == FFE_AB_XX_STAT_ALL_LANES)) |
| 994 | link_ok = true; |
| 995 | |
| 996 | /* Clear link status ready for next read */ |
| 997 | EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_COMMA_DET, FFE_AB_XX_STAT_ALL_LANES); |
| 998 | EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_CHAR_ERR, FFE_AB_XX_STAT_ALL_LANES); |
| 999 | EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_DISPERR, FFE_AB_XX_STAT_ALL_LANES); |
| 1000 | efx_writeo(efx, ®, FR_AB_XX_CORE_STAT); |
| 1001 | |
| 1002 | return link_ok; |
| 1003 | } |
| 1004 | |
| 1005 | static bool falcon_xmac_link_ok(struct efx_nic *efx) |
| 1006 | { |
| 1007 | /* |
| 1008 | * Check MAC's XGXS link status except when using XGMII loopback |
| 1009 | * which bypasses the XGXS block. |
| 1010 | * If possible, check PHY's XGXS link status except when using |
| 1011 | * MAC loopback. |
| 1012 | */ |
| 1013 | return (efx->loopback_mode == LOOPBACK_XGMII || |
| 1014 | falcon_xgxs_link_ok(efx)) && |
| 1015 | (!(efx->mdio.mmds & (1 << MDIO_MMD_PHYXS)) || |
| 1016 | LOOPBACK_INTERNAL(efx) || |
| 1017 | efx_mdio_phyxgxs_lane_sync(efx)); |
| 1018 | } |
| 1019 | |
| 1020 | static void falcon_reconfigure_xmac_core(struct efx_nic *efx) |
| 1021 | { |
| 1022 | unsigned int max_frame_len; |
| 1023 | efx_oword_t reg; |
| 1024 | bool rx_fc = !!(efx->link_state.fc & EFX_FC_RX); |
| 1025 | bool tx_fc = !!(efx->link_state.fc & EFX_FC_TX); |
| 1026 | |
| 1027 | /* Configure MAC - cut-thru mode is hard wired on */ |
| 1028 | EFX_POPULATE_OWORD_3(reg, |
| 1029 | FRF_AB_XM_RX_JUMBO_MODE, 1, |
| 1030 | FRF_AB_XM_TX_STAT_EN, 1, |
| 1031 | FRF_AB_XM_RX_STAT_EN, 1); |
| 1032 | efx_writeo(efx, ®, FR_AB_XM_GLB_CFG); |
| 1033 | |
| 1034 | /* Configure TX */ |
| 1035 | EFX_POPULATE_OWORD_6(reg, |
| 1036 | FRF_AB_XM_TXEN, 1, |
| 1037 | FRF_AB_XM_TX_PRMBL, 1, |
| 1038 | FRF_AB_XM_AUTO_PAD, 1, |
| 1039 | FRF_AB_XM_TXCRC, 1, |
| 1040 | FRF_AB_XM_FCNTL, tx_fc, |
| 1041 | FRF_AB_XM_IPG, 0x3); |
| 1042 | efx_writeo(efx, ®, FR_AB_XM_TX_CFG); |
| 1043 | |
| 1044 | /* Configure RX */ |
| 1045 | EFX_POPULATE_OWORD_5(reg, |
| 1046 | FRF_AB_XM_RXEN, 1, |
| 1047 | FRF_AB_XM_AUTO_DEPAD, 0, |
| 1048 | FRF_AB_XM_ACPT_ALL_MCAST, 1, |
Ben Hutchings | 964e613 | 2012-11-19 23:08:22 +0000 | [diff] [blame] | 1049 | FRF_AB_XM_ACPT_ALL_UCAST, !efx->unicast_filter, |
Ben Hutchings | ab0115f | 2012-09-13 01:11:31 +0100 | [diff] [blame] | 1050 | FRF_AB_XM_PASS_CRC_ERR, 1); |
| 1051 | efx_writeo(efx, ®, FR_AB_XM_RX_CFG); |
| 1052 | |
| 1053 | /* Set frame length */ |
| 1054 | max_frame_len = EFX_MAX_FRAME_LEN(efx->net_dev->mtu); |
| 1055 | EFX_POPULATE_OWORD_1(reg, FRF_AB_XM_MAX_RX_FRM_SIZE, max_frame_len); |
| 1056 | efx_writeo(efx, ®, FR_AB_XM_RX_PARAM); |
| 1057 | EFX_POPULATE_OWORD_2(reg, |
| 1058 | FRF_AB_XM_MAX_TX_FRM_SIZE, max_frame_len, |
| 1059 | FRF_AB_XM_TX_JUMBO_MODE, 1); |
| 1060 | efx_writeo(efx, ®, FR_AB_XM_TX_PARAM); |
| 1061 | |
| 1062 | EFX_POPULATE_OWORD_2(reg, |
| 1063 | FRF_AB_XM_PAUSE_TIME, 0xfffe, /* MAX PAUSE TIME */ |
| 1064 | FRF_AB_XM_DIS_FCNTL, !rx_fc); |
| 1065 | efx_writeo(efx, ®, FR_AB_XM_FC); |
| 1066 | |
| 1067 | /* Set MAC address */ |
| 1068 | memcpy(®, &efx->net_dev->dev_addr[0], 4); |
| 1069 | efx_writeo(efx, ®, FR_AB_XM_ADR_LO); |
| 1070 | memcpy(®, &efx->net_dev->dev_addr[4], 2); |
| 1071 | efx_writeo(efx, ®, FR_AB_XM_ADR_HI); |
| 1072 | } |
| 1073 | |
| 1074 | static void falcon_reconfigure_xgxs_core(struct efx_nic *efx) |
| 1075 | { |
| 1076 | efx_oword_t reg; |
| 1077 | bool xgxs_loopback = (efx->loopback_mode == LOOPBACK_XGXS); |
| 1078 | bool xaui_loopback = (efx->loopback_mode == LOOPBACK_XAUI); |
| 1079 | bool xgmii_loopback = (efx->loopback_mode == LOOPBACK_XGMII); |
Ben Hutchings | ab3b825 | 2012-10-05 19:31:02 +0100 | [diff] [blame] | 1080 | bool old_xgmii_loopback, old_xgxs_loopback, old_xaui_loopback; |
Ben Hutchings | ab0115f | 2012-09-13 01:11:31 +0100 | [diff] [blame] | 1081 | |
| 1082 | /* XGXS block is flaky and will need to be reset if moving |
| 1083 | * into our out of XGMII, XGXS or XAUI loopbacks. */ |
Ben Hutchings | ab3b825 | 2012-10-05 19:31:02 +0100 | [diff] [blame] | 1084 | efx_reado(efx, ®, FR_AB_XX_CORE_STAT); |
| 1085 | old_xgxs_loopback = EFX_OWORD_FIELD(reg, FRF_AB_XX_XGXS_LB_EN); |
| 1086 | old_xgmii_loopback = EFX_OWORD_FIELD(reg, FRF_AB_XX_XGMII_LB_EN); |
Ben Hutchings | ab0115f | 2012-09-13 01:11:31 +0100 | [diff] [blame] | 1087 | |
Ben Hutchings | ab3b825 | 2012-10-05 19:31:02 +0100 | [diff] [blame] | 1088 | efx_reado(efx, ®, FR_AB_XX_SD_CTL); |
| 1089 | old_xaui_loopback = EFX_OWORD_FIELD(reg, FRF_AB_XX_LPBKA); |
Ben Hutchings | ab0115f | 2012-09-13 01:11:31 +0100 | [diff] [blame] | 1090 | |
Ben Hutchings | ab3b825 | 2012-10-05 19:31:02 +0100 | [diff] [blame] | 1091 | /* The PHY driver may have turned XAUI off */ |
| 1092 | if ((xgxs_loopback != old_xgxs_loopback) || |
| 1093 | (xaui_loopback != old_xaui_loopback) || |
| 1094 | (xgmii_loopback != old_xgmii_loopback)) |
| 1095 | falcon_reset_xaui(efx); |
Ben Hutchings | ab0115f | 2012-09-13 01:11:31 +0100 | [diff] [blame] | 1096 | |
| 1097 | efx_reado(efx, ®, FR_AB_XX_CORE_STAT); |
| 1098 | EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_FORCE_SIG, |
| 1099 | (xgxs_loopback || xaui_loopback) ? |
| 1100 | FFE_AB_XX_FORCE_SIG_ALL_LANES : 0); |
| 1101 | EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_XGXS_LB_EN, xgxs_loopback); |
| 1102 | EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_XGMII_LB_EN, xgmii_loopback); |
| 1103 | efx_writeo(efx, ®, FR_AB_XX_CORE_STAT); |
| 1104 | |
| 1105 | efx_reado(efx, ®, FR_AB_XX_SD_CTL); |
| 1106 | EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_LPBKD, xaui_loopback); |
| 1107 | EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_LPBKC, xaui_loopback); |
| 1108 | EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_LPBKB, xaui_loopback); |
| 1109 | EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_LPBKA, xaui_loopback); |
| 1110 | efx_writeo(efx, ®, FR_AB_XX_SD_CTL); |
| 1111 | } |
| 1112 | |
| 1113 | |
| 1114 | /* Try to bring up the Falcon side of the Falcon-Phy XAUI link */ |
| 1115 | static bool falcon_xmac_link_ok_retry(struct efx_nic *efx, int tries) |
| 1116 | { |
| 1117 | bool mac_up = falcon_xmac_link_ok(efx); |
| 1118 | |
| 1119 | if (LOOPBACK_MASK(efx) & LOOPBACKS_EXTERNAL(efx) & LOOPBACKS_WS || |
| 1120 | efx_phy_mode_disabled(efx->phy_mode)) |
| 1121 | /* XAUI link is expected to be down */ |
| 1122 | return mac_up; |
| 1123 | |
| 1124 | falcon_stop_nic_stats(efx); |
| 1125 | |
| 1126 | while (!mac_up && tries) { |
| 1127 | netif_dbg(efx, hw, efx->net_dev, "bashing xaui\n"); |
| 1128 | falcon_reset_xaui(efx); |
| 1129 | udelay(200); |
| 1130 | |
| 1131 | mac_up = falcon_xmac_link_ok(efx); |
| 1132 | --tries; |
| 1133 | } |
| 1134 | |
| 1135 | falcon_start_nic_stats(efx); |
| 1136 | |
| 1137 | return mac_up; |
| 1138 | } |
| 1139 | |
| 1140 | static bool falcon_xmac_check_fault(struct efx_nic *efx) |
| 1141 | { |
| 1142 | return !falcon_xmac_link_ok_retry(efx, 5); |
| 1143 | } |
| 1144 | |
| 1145 | static int falcon_reconfigure_xmac(struct efx_nic *efx) |
| 1146 | { |
| 1147 | struct falcon_nic_data *nic_data = efx->nic_data; |
| 1148 | |
Ben Hutchings | 964e613 | 2012-11-19 23:08:22 +0000 | [diff] [blame] | 1149 | efx_farch_filter_sync_rx_mode(efx); |
| 1150 | |
Ben Hutchings | ab0115f | 2012-09-13 01:11:31 +0100 | [diff] [blame] | 1151 | falcon_reconfigure_xgxs_core(efx); |
| 1152 | falcon_reconfigure_xmac_core(efx); |
| 1153 | |
| 1154 | falcon_reconfigure_mac_wrapper(efx); |
| 1155 | |
| 1156 | nic_data->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 5); |
| 1157 | falcon_ack_status_intr(efx); |
| 1158 | |
| 1159 | return 0; |
| 1160 | } |
| 1161 | |
| 1162 | static void falcon_update_stats_xmac(struct efx_nic *efx) |
| 1163 | { |
| 1164 | struct efx_mac_stats *mac_stats = &efx->mac_stats; |
| 1165 | |
| 1166 | /* Update MAC stats from DMAed values */ |
| 1167 | FALCON_STAT(efx, XgRxOctets, rx_bytes); |
| 1168 | FALCON_STAT(efx, XgRxOctetsOK, rx_good_bytes); |
| 1169 | FALCON_STAT(efx, XgRxPkts, rx_packets); |
| 1170 | FALCON_STAT(efx, XgRxPktsOK, rx_good); |
| 1171 | FALCON_STAT(efx, XgRxBroadcastPkts, rx_broadcast); |
| 1172 | FALCON_STAT(efx, XgRxMulticastPkts, rx_multicast); |
| 1173 | FALCON_STAT(efx, XgRxUnicastPkts, rx_unicast); |
| 1174 | FALCON_STAT(efx, XgRxUndersizePkts, rx_lt64); |
| 1175 | FALCON_STAT(efx, XgRxOversizePkts, rx_gtjumbo); |
| 1176 | FALCON_STAT(efx, XgRxJabberPkts, rx_bad_gtjumbo); |
| 1177 | FALCON_STAT(efx, XgRxUndersizeFCSerrorPkts, rx_bad_lt64); |
| 1178 | FALCON_STAT(efx, XgRxDropEvents, rx_overflow); |
| 1179 | FALCON_STAT(efx, XgRxFCSerrorPkts, rx_bad); |
| 1180 | FALCON_STAT(efx, XgRxAlignError, rx_align_error); |
| 1181 | FALCON_STAT(efx, XgRxSymbolError, rx_symbol_error); |
| 1182 | FALCON_STAT(efx, XgRxInternalMACError, rx_internal_error); |
| 1183 | FALCON_STAT(efx, XgRxControlPkts, rx_control); |
| 1184 | FALCON_STAT(efx, XgRxPausePkts, rx_pause); |
| 1185 | FALCON_STAT(efx, XgRxPkts64Octets, rx_64); |
| 1186 | FALCON_STAT(efx, XgRxPkts65to127Octets, rx_65_to_127); |
| 1187 | FALCON_STAT(efx, XgRxPkts128to255Octets, rx_128_to_255); |
| 1188 | FALCON_STAT(efx, XgRxPkts256to511Octets, rx_256_to_511); |
| 1189 | FALCON_STAT(efx, XgRxPkts512to1023Octets, rx_512_to_1023); |
| 1190 | FALCON_STAT(efx, XgRxPkts1024to15xxOctets, rx_1024_to_15xx); |
| 1191 | FALCON_STAT(efx, XgRxPkts15xxtoMaxOctets, rx_15xx_to_jumbo); |
| 1192 | FALCON_STAT(efx, XgRxLengthError, rx_length_error); |
| 1193 | FALCON_STAT(efx, XgTxPkts, tx_packets); |
| 1194 | FALCON_STAT(efx, XgTxOctets, tx_bytes); |
| 1195 | FALCON_STAT(efx, XgTxMulticastPkts, tx_multicast); |
| 1196 | FALCON_STAT(efx, XgTxBroadcastPkts, tx_broadcast); |
| 1197 | FALCON_STAT(efx, XgTxUnicastPkts, tx_unicast); |
| 1198 | FALCON_STAT(efx, XgTxControlPkts, tx_control); |
| 1199 | FALCON_STAT(efx, XgTxPausePkts, tx_pause); |
| 1200 | FALCON_STAT(efx, XgTxPkts64Octets, tx_64); |
| 1201 | FALCON_STAT(efx, XgTxPkts65to127Octets, tx_65_to_127); |
| 1202 | FALCON_STAT(efx, XgTxPkts128to255Octets, tx_128_to_255); |
| 1203 | FALCON_STAT(efx, XgTxPkts256to511Octets, tx_256_to_511); |
| 1204 | FALCON_STAT(efx, XgTxPkts512to1023Octets, tx_512_to_1023); |
| 1205 | FALCON_STAT(efx, XgTxPkts1024to15xxOctets, tx_1024_to_15xx); |
| 1206 | FALCON_STAT(efx, XgTxPkts1519toMaxOctets, tx_15xx_to_jumbo); |
| 1207 | FALCON_STAT(efx, XgTxUndersizePkts, tx_lt64); |
| 1208 | FALCON_STAT(efx, XgTxOversizePkts, tx_gtjumbo); |
| 1209 | FALCON_STAT(efx, XgTxNonTcpUdpPkt, tx_non_tcpudp); |
| 1210 | FALCON_STAT(efx, XgTxMacSrcErrPkt, tx_mac_src_error); |
| 1211 | FALCON_STAT(efx, XgTxIpSrcErrPkt, tx_ip_src_error); |
| 1212 | |
| 1213 | /* Update derived statistics */ |
| 1214 | efx_update_diff_stat(&mac_stats->tx_good_bytes, |
| 1215 | mac_stats->tx_bytes - mac_stats->tx_bad_bytes - |
| 1216 | mac_stats->tx_control * 64); |
| 1217 | efx_update_diff_stat(&mac_stats->rx_bad_bytes, |
| 1218 | mac_stats->rx_bytes - mac_stats->rx_good_bytes - |
| 1219 | mac_stats->rx_control * 64); |
| 1220 | } |
| 1221 | |
| 1222 | static void falcon_poll_xmac(struct efx_nic *efx) |
| 1223 | { |
| 1224 | struct falcon_nic_data *nic_data = efx->nic_data; |
| 1225 | |
Ben Hutchings | ab3b825 | 2012-10-05 19:31:02 +0100 | [diff] [blame] | 1226 | /* We expect xgmii faults if the wireside link is down */ |
| 1227 | if (!efx->link_state.up || !nic_data->xmac_poll_required) |
Ben Hutchings | ab0115f | 2012-09-13 01:11:31 +0100 | [diff] [blame] | 1228 | return; |
| 1229 | |
| 1230 | nic_data->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 1); |
| 1231 | falcon_ack_status_intr(efx); |
| 1232 | } |
| 1233 | |
| 1234 | /************************************************************************** |
| 1235 | * |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1236 | * MAC wrapper |
| 1237 | * |
| 1238 | ************************************************************************** |
| 1239 | */ |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 1240 | |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 1241 | static void falcon_push_multicast_hash(struct efx_nic *efx) |
| 1242 | { |
| 1243 | union efx_multicast_hash *mc_hash = &efx->multicast_hash; |
| 1244 | |
| 1245 | WARN_ON(!mutex_is_locked(&efx->mac_lock)); |
| 1246 | |
| 1247 | efx_writeo(efx, &mc_hash->oword[0], FR_AB_MAC_MC_HASH_REG0); |
| 1248 | efx_writeo(efx, &mc_hash->oword[1], FR_AB_MAC_MC_HASH_REG1); |
| 1249 | } |
| 1250 | |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 1251 | static void falcon_reset_macs(struct efx_nic *efx) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1252 | { |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 1253 | struct falcon_nic_data *nic_data = efx->nic_data; |
| 1254 | efx_oword_t reg, mac_ctrl; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1255 | int count; |
| 1256 | |
Ben Hutchings | daeda63 | 2009-11-28 05:36:04 +0000 | [diff] [blame] | 1257 | if (efx_nic_rev(efx) < EFX_REV_FALCON_B0) { |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 1258 | /* It's not safe to use GLB_CTL_REG to reset the |
| 1259 | * macs, so instead use the internal MAC resets |
| 1260 | */ |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 1261 | EFX_POPULATE_OWORD_1(reg, FRF_AB_XM_CORE_RST, 1); |
| 1262 | efx_writeo(efx, ®, FR_AB_XM_GLB_CFG); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1263 | |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 1264 | for (count = 0; count < 10000; count++) { |
| 1265 | efx_reado(efx, ®, FR_AB_XM_GLB_CFG); |
| 1266 | if (EFX_OWORD_FIELD(reg, FRF_AB_XM_CORE_RST) == |
| 1267 | 0) |
| 1268 | return; |
| 1269 | udelay(10); |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 1270 | } |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 1271 | |
| 1272 | netif_err(efx, hw, efx->net_dev, |
| 1273 | "timed out waiting for XMAC core reset\n"); |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 1274 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1275 | |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 1276 | /* Mac stats will fail whist the TX fifo is draining */ |
| 1277 | WARN_ON(nic_data->stats_disable_count == 0); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1278 | |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 1279 | efx_reado(efx, &mac_ctrl, FR_AB_MAC_CTRL); |
| 1280 | EFX_SET_OWORD_FIELD(mac_ctrl, FRF_BB_TXFIFO_DRAIN_EN, 1); |
| 1281 | efx_writeo(efx, &mac_ctrl, FR_AB_MAC_CTRL); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1282 | |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1283 | efx_reado(efx, ®, FR_AB_GLB_CTL); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1284 | EFX_SET_OWORD_FIELD(reg, FRF_AB_RST_XGTX, 1); |
| 1285 | EFX_SET_OWORD_FIELD(reg, FRF_AB_RST_XGRX, 1); |
| 1286 | EFX_SET_OWORD_FIELD(reg, FRF_AB_RST_EM, 1); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1287 | efx_writeo(efx, ®, FR_AB_GLB_CTL); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1288 | |
| 1289 | count = 0; |
| 1290 | while (1) { |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1291 | efx_reado(efx, ®, FR_AB_GLB_CTL); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1292 | if (!EFX_OWORD_FIELD(reg, FRF_AB_RST_XGTX) && |
| 1293 | !EFX_OWORD_FIELD(reg, FRF_AB_RST_XGRX) && |
| 1294 | !EFX_OWORD_FIELD(reg, FRF_AB_RST_EM)) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1295 | netif_dbg(efx, hw, efx->net_dev, |
| 1296 | "Completed MAC reset after %d loops\n", |
| 1297 | count); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1298 | break; |
| 1299 | } |
| 1300 | if (count > 20) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1301 | netif_err(efx, hw, efx->net_dev, "MAC reset failed\n"); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1302 | break; |
| 1303 | } |
| 1304 | count++; |
| 1305 | udelay(10); |
| 1306 | } |
| 1307 | |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 1308 | /* Ensure the correct MAC is selected before statistics |
| 1309 | * are re-enabled by the caller */ |
| 1310 | efx_writeo(efx, &mac_ctrl, FR_AB_MAC_CTRL); |
Steve Hodgson | b7b40ee | 2010-04-28 09:28:10 +0000 | [diff] [blame] | 1311 | |
Steve Hodgson | b7b40ee | 2010-04-28 09:28:10 +0000 | [diff] [blame] | 1312 | falcon_setup_xaui(efx); |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 1313 | } |
| 1314 | |
Ben Hutchings | 9dd3a13 | 2012-09-13 01:11:25 +0100 | [diff] [blame] | 1315 | static void falcon_drain_tx_fifo(struct efx_nic *efx) |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 1316 | { |
| 1317 | efx_oword_t reg; |
| 1318 | |
Ben Hutchings | daeda63 | 2009-11-28 05:36:04 +0000 | [diff] [blame] | 1319 | if ((efx_nic_rev(efx) < EFX_REV_FALCON_B0) || |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 1320 | (efx->loopback_mode != LOOPBACK_NONE)) |
| 1321 | return; |
| 1322 | |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1323 | efx_reado(efx, ®, FR_AB_MAC_CTRL); |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 1324 | /* There is no point in draining more than once */ |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1325 | if (EFX_OWORD_FIELD(reg, FRF_BB_TXFIFO_DRAIN_EN)) |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 1326 | return; |
| 1327 | |
| 1328 | falcon_reset_macs(efx); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1329 | } |
| 1330 | |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 1331 | static void falcon_deconfigure_mac_wrapper(struct efx_nic *efx) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1332 | { |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 1333 | efx_oword_t reg; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1334 | |
Ben Hutchings | daeda63 | 2009-11-28 05:36:04 +0000 | [diff] [blame] | 1335 | if (efx_nic_rev(efx) < EFX_REV_FALCON_B0) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1336 | return; |
| 1337 | |
| 1338 | /* Isolate the MAC -> RX */ |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1339 | efx_reado(efx, ®, FR_AZ_RX_CFG); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1340 | EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_INGR_EN, 0); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1341 | efx_writeo(efx, ®, FR_AZ_RX_CFG); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1342 | |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 1343 | /* Isolate TX -> MAC */ |
| 1344 | falcon_drain_tx_fifo(efx); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1345 | } |
| 1346 | |
Ben Hutchings | ab0115f | 2012-09-13 01:11:31 +0100 | [diff] [blame] | 1347 | static void falcon_reconfigure_mac_wrapper(struct efx_nic *efx) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1348 | { |
Ben Hutchings | eb50c0d | 2009-11-23 16:06:30 +0000 | [diff] [blame] | 1349 | struct efx_link_state *link_state = &efx->link_state; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1350 | efx_oword_t reg; |
Steve Hodgson | fd371e3 | 2010-06-01 11:17:51 +0000 | [diff] [blame] | 1351 | int link_speed, isolate; |
| 1352 | |
Ben Hutchings | a7d529a | 2011-06-24 20:46:31 +0100 | [diff] [blame] | 1353 | isolate = !!ACCESS_ONCE(efx->reset_pending); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1354 | |
Ben Hutchings | eb50c0d | 2009-11-23 16:06:30 +0000 | [diff] [blame] | 1355 | switch (link_state->speed) { |
Ben Hutchings | f31a45d | 2008-12-12 21:43:33 -0800 | [diff] [blame] | 1356 | case 10000: link_speed = 3; break; |
| 1357 | case 1000: link_speed = 2; break; |
| 1358 | case 100: link_speed = 1; break; |
| 1359 | default: link_speed = 0; break; |
| 1360 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1361 | /* MAC_LINK_STATUS controls MAC backpressure but doesn't work |
| 1362 | * as advertised. Disable to ensure packets are not |
| 1363 | * indefinitely held and TX queue can be flushed at any point |
| 1364 | * while the link is down. */ |
| 1365 | EFX_POPULATE_OWORD_5(reg, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1366 | FRF_AB_MAC_XOFF_VAL, 0xffff /* max pause time */, |
| 1367 | FRF_AB_MAC_BCAD_ACPT, 1, |
Ben Hutchings | 964e613 | 2012-11-19 23:08:22 +0000 | [diff] [blame] | 1368 | FRF_AB_MAC_UC_PROM, !efx->unicast_filter, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1369 | FRF_AB_MAC_LINK_STATUS, 1, /* always set */ |
| 1370 | FRF_AB_MAC_SPEED, link_speed); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1371 | /* On B0, MAC backpressure can be disabled and packets get |
| 1372 | * discarded. */ |
Ben Hutchings | daeda63 | 2009-11-28 05:36:04 +0000 | [diff] [blame] | 1373 | if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0) { |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1374 | EFX_SET_OWORD_FIELD(reg, FRF_BB_TXFIFO_DRAIN_EN, |
Steve Hodgson | fd371e3 | 2010-06-01 11:17:51 +0000 | [diff] [blame] | 1375 | !link_state->up || isolate); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1376 | } |
| 1377 | |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1378 | efx_writeo(efx, ®, FR_AB_MAC_CTRL); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1379 | |
| 1380 | /* Restore the multicast hash registers. */ |
Ben Hutchings | 8be4f3e | 2009-11-25 16:12:16 +0000 | [diff] [blame] | 1381 | falcon_push_multicast_hash(efx); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1382 | |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1383 | efx_reado(efx, ®, FR_AZ_RX_CFG); |
Ben Hutchings | 4b0d29d | 2009-11-29 03:42:18 +0000 | [diff] [blame] | 1384 | /* Enable XOFF signal from RX FIFO (we enabled it during NIC |
| 1385 | * initialisation but it may read back as 0) */ |
| 1386 | EFX_SET_OWORD_FIELD(reg, FRF_AZ_RX_XOFF_MAC_EN, 1); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1387 | /* Unisolate the MAC -> RX */ |
Ben Hutchings | daeda63 | 2009-11-28 05:36:04 +0000 | [diff] [blame] | 1388 | if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0) |
Steve Hodgson | fd371e3 | 2010-06-01 11:17:51 +0000 | [diff] [blame] | 1389 | EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_INGR_EN, !isolate); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1390 | efx_writeo(efx, ®, FR_AZ_RX_CFG); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1391 | } |
| 1392 | |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 1393 | static void falcon_stats_request(struct efx_nic *efx) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1394 | { |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 1395 | struct falcon_nic_data *nic_data = efx->nic_data; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1396 | efx_oword_t reg; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1397 | |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 1398 | WARN_ON(nic_data->stats_pending); |
| 1399 | WARN_ON(nic_data->stats_disable_count); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1400 | |
Ben Hutchings | e513612 | 2012-12-14 21:52:56 +0000 | [diff] [blame] | 1401 | FALCON_XMAC_STATS_DMA_FLAG(efx) = 0; |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 1402 | nic_data->stats_pending = true; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1403 | wmb(); /* ensure done flag is clear */ |
| 1404 | |
| 1405 | /* Initiate DMA transfer of stats */ |
| 1406 | EFX_POPULATE_OWORD_2(reg, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1407 | FRF_AB_MAC_STAT_DMA_CMD, 1, |
| 1408 | FRF_AB_MAC_STAT_DMA_ADR, |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1409 | efx->stats_buffer.dma_addr); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1410 | efx_writeo(efx, ®, FR_AB_MAC_STAT_DMA); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1411 | |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 1412 | mod_timer(&nic_data->stats_timer, round_jiffies_up(jiffies + HZ / 2)); |
| 1413 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1414 | |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 1415 | static void falcon_stats_complete(struct efx_nic *efx) |
| 1416 | { |
| 1417 | struct falcon_nic_data *nic_data = efx->nic_data; |
| 1418 | |
| 1419 | if (!nic_data->stats_pending) |
| 1420 | return; |
| 1421 | |
Rusty Russell | 3db1cd5 | 2011-12-19 13:56:45 +0000 | [diff] [blame] | 1422 | nic_data->stats_pending = false; |
Ben Hutchings | e513612 | 2012-12-14 21:52:56 +0000 | [diff] [blame] | 1423 | if (FALCON_XMAC_STATS_DMA_FLAG(efx)) { |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 1424 | rmb(); /* read the done flag before the stats */ |
Ben Hutchings | 710b208 | 2011-09-03 00:15:00 +0100 | [diff] [blame] | 1425 | falcon_update_stats_xmac(efx); |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 1426 | } else { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1427 | netif_err(efx, hw, efx->net_dev, |
| 1428 | "timed out waiting for statistics\n"); |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 1429 | } |
| 1430 | } |
| 1431 | |
| 1432 | static void falcon_stats_timer_func(unsigned long context) |
| 1433 | { |
| 1434 | struct efx_nic *efx = (struct efx_nic *)context; |
| 1435 | struct falcon_nic_data *nic_data = efx->nic_data; |
| 1436 | |
| 1437 | spin_lock(&efx->stats_lock); |
| 1438 | |
| 1439 | falcon_stats_complete(efx); |
| 1440 | if (nic_data->stats_disable_count == 0) |
| 1441 | falcon_stats_request(efx); |
| 1442 | |
| 1443 | spin_unlock(&efx->stats_lock); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1444 | } |
| 1445 | |
Steve Hodgson | fdaa9ae | 2009-11-28 05:34:05 +0000 | [diff] [blame] | 1446 | static bool falcon_loopback_link_poll(struct efx_nic *efx) |
| 1447 | { |
| 1448 | struct efx_link_state old_state = efx->link_state; |
| 1449 | |
| 1450 | WARN_ON(!mutex_is_locked(&efx->mac_lock)); |
| 1451 | WARN_ON(!LOOPBACK_INTERNAL(efx)); |
| 1452 | |
| 1453 | efx->link_state.fd = true; |
| 1454 | efx->link_state.fc = efx->wanted_fc; |
| 1455 | efx->link_state.up = true; |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 1456 | efx->link_state.speed = 10000; |
Steve Hodgson | fdaa9ae | 2009-11-28 05:34:05 +0000 | [diff] [blame] | 1457 | |
| 1458 | return !efx_link_state_equal(&efx->link_state, &old_state); |
| 1459 | } |
| 1460 | |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 1461 | static int falcon_reconfigure_port(struct efx_nic *efx) |
| 1462 | { |
| 1463 | int rc; |
| 1464 | |
| 1465 | WARN_ON(efx_nic_rev(efx) > EFX_REV_FALCON_B0); |
| 1466 | |
| 1467 | /* Poll the PHY link state *before* reconfiguring it. This means we |
| 1468 | * will pick up the correct speed (in loopback) to select the correct |
| 1469 | * MAC. |
| 1470 | */ |
| 1471 | if (LOOPBACK_INTERNAL(efx)) |
| 1472 | falcon_loopback_link_poll(efx); |
| 1473 | else |
| 1474 | efx->phy_op->poll(efx); |
| 1475 | |
| 1476 | falcon_stop_nic_stats(efx); |
| 1477 | falcon_deconfigure_mac_wrapper(efx); |
| 1478 | |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 1479 | falcon_reset_macs(efx); |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 1480 | |
| 1481 | efx->phy_op->reconfigure(efx); |
Ben Hutchings | 710b208 | 2011-09-03 00:15:00 +0100 | [diff] [blame] | 1482 | rc = falcon_reconfigure_xmac(efx); |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 1483 | BUG_ON(rc); |
| 1484 | |
| 1485 | falcon_start_nic_stats(efx); |
| 1486 | |
| 1487 | /* Synchronise efx->link_state with the kernel */ |
| 1488 | efx_link_status_changed(efx); |
| 1489 | |
| 1490 | return 0; |
| 1491 | } |
| 1492 | |
Ben Hutchings | 9dd3a13 | 2012-09-13 01:11:25 +0100 | [diff] [blame] | 1493 | /* TX flow control may automatically turn itself off if the link |
| 1494 | * partner (intermittently) stops responding to pause frames. There |
| 1495 | * isn't any indication that this has happened, so the best we do is |
| 1496 | * leave it up to the user to spot this and fix it by cycling transmit |
| 1497 | * flow control on this end. |
| 1498 | */ |
| 1499 | |
| 1500 | static void falcon_a1_prepare_enable_fc_tx(struct efx_nic *efx) |
| 1501 | { |
| 1502 | /* Schedule a reset to recover */ |
| 1503 | efx_schedule_reset(efx, RESET_TYPE_INVISIBLE); |
| 1504 | } |
| 1505 | |
| 1506 | static void falcon_b0_prepare_enable_fc_tx(struct efx_nic *efx) |
| 1507 | { |
| 1508 | /* Recover by resetting the EM block */ |
| 1509 | falcon_stop_nic_stats(efx); |
| 1510 | falcon_drain_tx_fifo(efx); |
| 1511 | falcon_reconfigure_xmac(efx); |
| 1512 | falcon_start_nic_stats(efx); |
| 1513 | } |
| 1514 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1515 | /************************************************************************** |
| 1516 | * |
| 1517 | * PHY access via GMII |
| 1518 | * |
| 1519 | ************************************************************************** |
| 1520 | */ |
| 1521 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1522 | /* Wait for GMII access to complete */ |
| 1523 | static int falcon_gmii_wait(struct efx_nic *efx) |
| 1524 | { |
Ben Hutchings | 80cb9a0 | 2009-11-25 16:08:41 +0000 | [diff] [blame] | 1525 | efx_oword_t md_stat; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1526 | int count; |
| 1527 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 1528 | /* wait up to 50ms - taken max from datasheet */ |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 1529 | for (count = 0; count < 5000; count++) { |
Ben Hutchings | 80cb9a0 | 2009-11-25 16:08:41 +0000 | [diff] [blame] | 1530 | efx_reado(efx, &md_stat, FR_AB_MD_STAT); |
| 1531 | if (EFX_OWORD_FIELD(md_stat, FRF_AB_MD_BSY) == 0) { |
| 1532 | if (EFX_OWORD_FIELD(md_stat, FRF_AB_MD_LNFL) != 0 || |
| 1533 | EFX_OWORD_FIELD(md_stat, FRF_AB_MD_BSERR) != 0) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1534 | netif_err(efx, hw, efx->net_dev, |
| 1535 | "error from GMII access " |
| 1536 | EFX_OWORD_FMT"\n", |
| 1537 | EFX_OWORD_VAL(md_stat)); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1538 | return -EIO; |
| 1539 | } |
| 1540 | return 0; |
| 1541 | } |
| 1542 | udelay(10); |
| 1543 | } |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1544 | netif_err(efx, hw, efx->net_dev, "timed out waiting for GMII\n"); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1545 | return -ETIMEDOUT; |
| 1546 | } |
| 1547 | |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 1548 | /* Write an MDIO register of a PHY connected to Falcon. */ |
| 1549 | static int falcon_mdio_write(struct net_device *net_dev, |
| 1550 | int prtad, int devad, u16 addr, u16 value) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1551 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 1552 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 4833f02 | 2010-12-02 13:47:35 +0000 | [diff] [blame] | 1553 | struct falcon_nic_data *nic_data = efx->nic_data; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1554 | efx_oword_t reg; |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 1555 | int rc; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1556 | |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1557 | netif_vdbg(efx, hw, efx->net_dev, |
| 1558 | "writing MDIO %d register %d.%d with 0x%04x\n", |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 1559 | prtad, devad, addr, value); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1560 | |
Ben Hutchings | 4833f02 | 2010-12-02 13:47:35 +0000 | [diff] [blame] | 1561 | mutex_lock(&nic_data->mdio_lock); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1562 | |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 1563 | /* Check MDIO not currently being accessed */ |
| 1564 | rc = falcon_gmii_wait(efx); |
| 1565 | if (rc) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1566 | goto out; |
| 1567 | |
| 1568 | /* Write the address/ID register */ |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1569 | EFX_POPULATE_OWORD_1(reg, FRF_AB_MD_PHY_ADR, addr); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1570 | efx_writeo(efx, ®, FR_AB_MD_PHY_ADR); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1571 | |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1572 | EFX_POPULATE_OWORD_2(reg, FRF_AB_MD_PRT_ADR, prtad, |
| 1573 | FRF_AB_MD_DEV_ADR, devad); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1574 | efx_writeo(efx, ®, FR_AB_MD_ID); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1575 | |
| 1576 | /* Write data */ |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1577 | EFX_POPULATE_OWORD_1(reg, FRF_AB_MD_TXD, value); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1578 | efx_writeo(efx, ®, FR_AB_MD_TXD); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1579 | |
| 1580 | EFX_POPULATE_OWORD_2(reg, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1581 | FRF_AB_MD_WRC, 1, |
| 1582 | FRF_AB_MD_GC, 0); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1583 | efx_writeo(efx, ®, FR_AB_MD_CS); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1584 | |
| 1585 | /* Wait for data to be written */ |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 1586 | rc = falcon_gmii_wait(efx); |
| 1587 | if (rc) { |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1588 | /* Abort the write operation */ |
| 1589 | EFX_POPULATE_OWORD_2(reg, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1590 | FRF_AB_MD_WRC, 0, |
| 1591 | FRF_AB_MD_GC, 1); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1592 | efx_writeo(efx, ®, FR_AB_MD_CS); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1593 | udelay(10); |
| 1594 | } |
| 1595 | |
Steve Hodgson | ab86746 | 2009-11-28 05:34:44 +0000 | [diff] [blame] | 1596 | out: |
Ben Hutchings | 4833f02 | 2010-12-02 13:47:35 +0000 | [diff] [blame] | 1597 | mutex_unlock(&nic_data->mdio_lock); |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 1598 | return rc; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1599 | } |
| 1600 | |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 1601 | /* Read an MDIO register of a PHY connected to Falcon. */ |
| 1602 | static int falcon_mdio_read(struct net_device *net_dev, |
| 1603 | int prtad, int devad, u16 addr) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1604 | { |
Ben Hutchings | 767e468 | 2008-09-01 12:43:14 +0100 | [diff] [blame] | 1605 | struct efx_nic *efx = netdev_priv(net_dev); |
Ben Hutchings | 4833f02 | 2010-12-02 13:47:35 +0000 | [diff] [blame] | 1606 | struct falcon_nic_data *nic_data = efx->nic_data; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1607 | efx_oword_t reg; |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 1608 | int rc; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1609 | |
Ben Hutchings | 4833f02 | 2010-12-02 13:47:35 +0000 | [diff] [blame] | 1610 | mutex_lock(&nic_data->mdio_lock); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1611 | |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 1612 | /* Check MDIO not currently being accessed */ |
| 1613 | rc = falcon_gmii_wait(efx); |
| 1614 | if (rc) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1615 | goto out; |
| 1616 | |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1617 | EFX_POPULATE_OWORD_1(reg, FRF_AB_MD_PHY_ADR, addr); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1618 | efx_writeo(efx, ®, FR_AB_MD_PHY_ADR); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1619 | |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1620 | EFX_POPULATE_OWORD_2(reg, FRF_AB_MD_PRT_ADR, prtad, |
| 1621 | FRF_AB_MD_DEV_ADR, devad); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1622 | efx_writeo(efx, ®, FR_AB_MD_ID); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1623 | |
| 1624 | /* Request data to be read */ |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1625 | EFX_POPULATE_OWORD_2(reg, FRF_AB_MD_RDC, 1, FRF_AB_MD_GC, 0); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1626 | efx_writeo(efx, ®, FR_AB_MD_CS); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1627 | |
| 1628 | /* Wait for data to become available */ |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 1629 | rc = falcon_gmii_wait(efx); |
| 1630 | if (rc == 0) { |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1631 | efx_reado(efx, ®, FR_AB_MD_RXD); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1632 | rc = EFX_OWORD_FIELD(reg, FRF_AB_MD_RXD); |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1633 | netif_vdbg(efx, hw, efx->net_dev, |
| 1634 | "read from MDIO %d register %d.%d, got %04x\n", |
| 1635 | prtad, devad, addr, rc); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1636 | } else { |
| 1637 | /* Abort the read operation */ |
| 1638 | EFX_POPULATE_OWORD_2(reg, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1639 | FRF_AB_MD_RIC, 0, |
| 1640 | FRF_AB_MD_GC, 1); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 1641 | efx_writeo(efx, ®, FR_AB_MD_CS); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1642 | |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1643 | netif_dbg(efx, hw, efx->net_dev, |
| 1644 | "read from MDIO %d register %d.%d, got error %d\n", |
| 1645 | prtad, devad, addr, rc); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1646 | } |
| 1647 | |
Steve Hodgson | ab86746 | 2009-11-28 05:34:44 +0000 | [diff] [blame] | 1648 | out: |
Ben Hutchings | 4833f02 | 2010-12-02 13:47:35 +0000 | [diff] [blame] | 1649 | mutex_unlock(&nic_data->mdio_lock); |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 1650 | return rc; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1651 | } |
| 1652 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1653 | /* This call is responsible for hooking in the MAC and PHY operations */ |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 1654 | static int falcon_probe_port(struct efx_nic *efx) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1655 | { |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 1656 | struct falcon_nic_data *nic_data = efx->nic_data; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1657 | int rc; |
| 1658 | |
Ben Hutchings | 96c45726 | 2009-10-23 08:32:42 +0000 | [diff] [blame] | 1659 | switch (efx->phy_type) { |
| 1660 | case PHY_TYPE_SFX7101: |
| 1661 | efx->phy_op = &falcon_sfx7101_phy_ops; |
| 1662 | break; |
Ben Hutchings | 96c45726 | 2009-10-23 08:32:42 +0000 | [diff] [blame] | 1663 | case PHY_TYPE_QT2022C2: |
| 1664 | case PHY_TYPE_QT2025C: |
Ben Hutchings | b37b62f | 2009-10-23 08:33:42 +0000 | [diff] [blame] | 1665 | efx->phy_op = &falcon_qt202x_phy_ops; |
Ben Hutchings | 96c45726 | 2009-10-23 08:32:42 +0000 | [diff] [blame] | 1666 | break; |
Ben Hutchings | 7e51b43 | 2010-09-22 10:00:47 +0000 | [diff] [blame] | 1667 | case PHY_TYPE_TXC43128: |
| 1668 | efx->phy_op = &falcon_txc_phy_ops; |
| 1669 | break; |
Ben Hutchings | 96c45726 | 2009-10-23 08:32:42 +0000 | [diff] [blame] | 1670 | default: |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1671 | netif_err(efx, probe, efx->net_dev, "Unknown PHY type %d\n", |
| 1672 | efx->phy_type); |
Ben Hutchings | 96c45726 | 2009-10-23 08:32:42 +0000 | [diff] [blame] | 1673 | return -ENODEV; |
| 1674 | } |
| 1675 | |
Ben Hutchings | c1c4f45 | 2009-11-29 15:08:55 +0000 | [diff] [blame] | 1676 | /* Fill out MDIO structure and loopback modes */ |
Ben Hutchings | 4833f02 | 2010-12-02 13:47:35 +0000 | [diff] [blame] | 1677 | mutex_init(&nic_data->mdio_lock); |
Ben Hutchings | 68e7f45 | 2009-04-29 08:05:08 +0000 | [diff] [blame] | 1678 | efx->mdio.mdio_read = falcon_mdio_read; |
| 1679 | efx->mdio.mdio_write = falcon_mdio_write; |
Ben Hutchings | c1c4f45 | 2009-11-29 15:08:55 +0000 | [diff] [blame] | 1680 | rc = efx->phy_op->probe(efx); |
| 1681 | if (rc != 0) |
| 1682 | return rc; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1683 | |
Steve Hodgson | b895d73 | 2009-11-28 05:35:00 +0000 | [diff] [blame] | 1684 | /* Initial assumption */ |
| 1685 | efx->link_state.speed = 10000; |
| 1686 | efx->link_state.fd = true; |
| 1687 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1688 | /* Hardware flow ctrl. FalconA RX FIFO too small for pause generation */ |
Ben Hutchings | daeda63 | 2009-11-28 05:36:04 +0000 | [diff] [blame] | 1689 | if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0) |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 1690 | efx->wanted_fc = EFX_FC_RX | EFX_FC_TX; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1691 | else |
Ben Hutchings | 04cc8ca | 2008-12-12 21:50:46 -0800 | [diff] [blame] | 1692 | efx->wanted_fc = EFX_FC_RX; |
Steve Hodgson | 7a6b8f6 | 2010-02-03 09:30:38 +0000 | [diff] [blame] | 1693 | if (efx->mdio.mmds & MDIO_DEVS_AN) |
| 1694 | efx->wanted_fc |= EFX_FC_AUTO; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1695 | |
| 1696 | /* Allocate buffer for stats */ |
Ben Hutchings | 152b6a6 | 2009-11-29 03:43:56 +0000 | [diff] [blame] | 1697 | rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer, |
Ben Hutchings | 0d19a54 | 2012-09-18 21:59:52 +0100 | [diff] [blame] | 1698 | FALCON_MAC_STATS_SIZE, GFP_KERNEL); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1699 | if (rc) |
| 1700 | return rc; |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1701 | netif_dbg(efx, probe, efx->net_dev, |
| 1702 | "stats buffer at %llx (virt %p phys %llx)\n", |
| 1703 | (u64)efx->stats_buffer.dma_addr, |
| 1704 | efx->stats_buffer.addr, |
| 1705 | (u64)virt_to_phys(efx->stats_buffer.addr)); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1706 | |
| 1707 | return 0; |
| 1708 | } |
| 1709 | |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 1710 | static void falcon_remove_port(struct efx_nic *efx) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1711 | { |
Steve Hodgson | ff3b00a | 2009-12-23 13:46:36 +0000 | [diff] [blame] | 1712 | efx->phy_op->remove(efx); |
Ben Hutchings | 152b6a6 | 2009-11-29 03:43:56 +0000 | [diff] [blame] | 1713 | efx_nic_free_buffer(efx, &efx->stats_buffer); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1714 | } |
| 1715 | |
Ben Hutchings | 40641ed | 2010-12-02 13:47:45 +0000 | [diff] [blame] | 1716 | /* Global events are basically PHY events */ |
| 1717 | static bool |
| 1718 | falcon_handle_global_event(struct efx_channel *channel, efx_qword_t *event) |
| 1719 | { |
| 1720 | struct efx_nic *efx = channel->efx; |
Ben Hutchings | cef68bd | 2010-12-02 13:47:51 +0000 | [diff] [blame] | 1721 | struct falcon_nic_data *nic_data = efx->nic_data; |
Ben Hutchings | 40641ed | 2010-12-02 13:47:45 +0000 | [diff] [blame] | 1722 | |
| 1723 | if (EFX_QWORD_FIELD(*event, FSF_AB_GLB_EV_G_PHY0_INTR) || |
| 1724 | EFX_QWORD_FIELD(*event, FSF_AB_GLB_EV_XG_PHY0_INTR) || |
| 1725 | EFX_QWORD_FIELD(*event, FSF_AB_GLB_EV_XFP_PHY0_INTR)) |
| 1726 | /* Ignored */ |
| 1727 | return true; |
| 1728 | |
| 1729 | if ((efx_nic_rev(efx) == EFX_REV_FALCON_B0) && |
| 1730 | EFX_QWORD_FIELD(*event, FSF_BB_GLB_EV_XG_MGT_INTR)) { |
Ben Hutchings | cef68bd | 2010-12-02 13:47:51 +0000 | [diff] [blame] | 1731 | nic_data->xmac_poll_required = true; |
Ben Hutchings | 40641ed | 2010-12-02 13:47:45 +0000 | [diff] [blame] | 1732 | return true; |
| 1733 | } |
| 1734 | |
| 1735 | if (efx_nic_rev(efx) <= EFX_REV_FALCON_A1 ? |
| 1736 | EFX_QWORD_FIELD(*event, FSF_AA_GLB_EV_RX_RECOVERY) : |
| 1737 | EFX_QWORD_FIELD(*event, FSF_BB_GLB_EV_RX_RECOVERY)) { |
| 1738 | netif_err(efx, rx_err, efx->net_dev, |
| 1739 | "channel %d seen global RX_RESET event. Resetting.\n", |
| 1740 | channel->channel); |
| 1741 | |
| 1742 | atomic_inc(&efx->rx_reset); |
| 1743 | efx_schedule_reset(efx, EFX_WORKAROUND_6555(efx) ? |
| 1744 | RESET_TYPE_RX_RECOVERY : RESET_TYPE_DISABLE); |
| 1745 | return true; |
| 1746 | } |
| 1747 | |
| 1748 | return false; |
| 1749 | } |
| 1750 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1751 | /************************************************************************** |
| 1752 | * |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1753 | * Falcon test code |
| 1754 | * |
| 1755 | **************************************************************************/ |
| 1756 | |
Ben Hutchings | 0aa3fba | 2009-11-29 03:43:33 +0000 | [diff] [blame] | 1757 | static int |
| 1758 | falcon_read_nvram(struct efx_nic *efx, struct falcon_nvconfig *nvconfig_out) |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1759 | { |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 1760 | struct falcon_nic_data *nic_data = efx->nic_data; |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1761 | struct falcon_nvconfig *nvconfig; |
Ben Hutchings | ecd0a6f0 | 2012-11-28 04:12:41 +0000 | [diff] [blame] | 1762 | struct falcon_spi_device *spi; |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1763 | void *region; |
| 1764 | int rc, magic_num, struct_ver; |
| 1765 | __le16 *word, *limit; |
| 1766 | u32 csum; |
| 1767 | |
Ben Hutchings | ecd0a6f0 | 2012-11-28 04:12:41 +0000 | [diff] [blame] | 1768 | if (falcon_spi_present(&nic_data->spi_flash)) |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 1769 | spi = &nic_data->spi_flash; |
Ben Hutchings | ecd0a6f0 | 2012-11-28 04:12:41 +0000 | [diff] [blame] | 1770 | else if (falcon_spi_present(&nic_data->spi_eeprom)) |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 1771 | spi = &nic_data->spi_eeprom; |
| 1772 | else |
Ben Hutchings | 2f7f573 | 2008-12-12 21:34:25 -0800 | [diff] [blame] | 1773 | return -EINVAL; |
| 1774 | |
Ben Hutchings | 0a95f56 | 2008-11-04 20:33:11 +0000 | [diff] [blame] | 1775 | region = kmalloc(FALCON_NVCONFIG_END, GFP_KERNEL); |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1776 | if (!region) |
| 1777 | return -ENOMEM; |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1778 | nvconfig = region + FALCON_NVCONFIG_OFFSET; |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1779 | |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 1780 | mutex_lock(&nic_data->spi_lock); |
Ben Hutchings | 7688483 | 2009-11-29 15:10:44 +0000 | [diff] [blame] | 1781 | rc = falcon_spi_read(efx, spi, 0, FALCON_NVCONFIG_END, NULL, region); |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 1782 | mutex_unlock(&nic_data->spi_lock); |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1783 | if (rc) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1784 | netif_err(efx, hw, efx->net_dev, "Failed to read %s\n", |
Ben Hutchings | ecd0a6f0 | 2012-11-28 04:12:41 +0000 | [diff] [blame] | 1785 | falcon_spi_present(&nic_data->spi_flash) ? |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 1786 | "flash" : "EEPROM"); |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1787 | rc = -EIO; |
| 1788 | goto out; |
| 1789 | } |
| 1790 | |
| 1791 | magic_num = le16_to_cpu(nvconfig->board_magic_num); |
| 1792 | struct_ver = le16_to_cpu(nvconfig->board_struct_ver); |
| 1793 | |
| 1794 | rc = -EINVAL; |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1795 | if (magic_num != FALCON_NVCONFIG_BOARD_MAGIC_NUM) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1796 | netif_err(efx, hw, efx->net_dev, |
| 1797 | "NVRAM bad magic 0x%x\n", magic_num); |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1798 | goto out; |
| 1799 | } |
| 1800 | if (struct_ver < 2) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1801 | netif_err(efx, hw, efx->net_dev, |
| 1802 | "NVRAM has ancient version 0x%x\n", struct_ver); |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1803 | goto out; |
| 1804 | } else if (struct_ver < 4) { |
| 1805 | word = &nvconfig->board_magic_num; |
| 1806 | limit = (__le16 *) (nvconfig + 1); |
| 1807 | } else { |
| 1808 | word = region; |
Ben Hutchings | 0a95f56 | 2008-11-04 20:33:11 +0000 | [diff] [blame] | 1809 | limit = region + FALCON_NVCONFIG_END; |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1810 | } |
| 1811 | for (csum = 0; word < limit; ++word) |
| 1812 | csum += le16_to_cpu(*word); |
| 1813 | |
| 1814 | if (~csum & 0xffff) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1815 | netif_err(efx, hw, efx->net_dev, |
| 1816 | "NVRAM has incorrect checksum\n"); |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1817 | goto out; |
| 1818 | } |
| 1819 | |
| 1820 | rc = 0; |
| 1821 | if (nvconfig_out) |
| 1822 | memcpy(nvconfig_out, nvconfig, sizeof(*nvconfig)); |
| 1823 | |
| 1824 | out: |
| 1825 | kfree(region); |
| 1826 | return rc; |
| 1827 | } |
| 1828 | |
Ben Hutchings | 0aa3fba | 2009-11-29 03:43:33 +0000 | [diff] [blame] | 1829 | static int falcon_test_nvram(struct efx_nic *efx) |
| 1830 | { |
| 1831 | return falcon_read_nvram(efx, NULL); |
| 1832 | } |
| 1833 | |
Ben Hutchings | 86094f7 | 2013-08-21 19:51:04 +0100 | [diff] [blame] | 1834 | static const struct efx_farch_register_test falcon_b0_register_tests[] = { |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1835 | { FR_AZ_ADR_REGION, |
Steve Hodgson | 4cddca5 | 2010-02-03 09:31:40 +0000 | [diff] [blame] | 1836 | EFX_OWORD32(0x0003FFFF, 0x0003FFFF, 0x0003FFFF, 0x0003FFFF) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1837 | { FR_AZ_RX_CFG, |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1838 | EFX_OWORD32(0xFFFFFFFE, 0x00017FFF, 0x00000000, 0x00000000) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1839 | { FR_AZ_TX_CFG, |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1840 | EFX_OWORD32(0x7FFF0037, 0x00000000, 0x00000000, 0x00000000) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1841 | { FR_AZ_TX_RESERVED, |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1842 | EFX_OWORD32(0xFFFEFE80, 0x1FFFFFFF, 0x020000FE, 0x007FFFFF) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1843 | { FR_AB_MAC_CTRL, |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1844 | EFX_OWORD32(0xFFFF0000, 0x00000000, 0x00000000, 0x00000000) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1845 | { FR_AZ_SRM_TX_DC_CFG, |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1846 | EFX_OWORD32(0x001FFFFF, 0x00000000, 0x00000000, 0x00000000) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1847 | { FR_AZ_RX_DC_CFG, |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1848 | EFX_OWORD32(0x0000000F, 0x00000000, 0x00000000, 0x00000000) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1849 | { FR_AZ_RX_DC_PF_WM, |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1850 | EFX_OWORD32(0x000003FF, 0x00000000, 0x00000000, 0x00000000) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1851 | { FR_BZ_DP_CTRL, |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1852 | EFX_OWORD32(0x00000FFF, 0x00000000, 0x00000000, 0x00000000) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1853 | { FR_AB_GM_CFG2, |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 1854 | EFX_OWORD32(0x00007337, 0x00000000, 0x00000000, 0x00000000) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1855 | { FR_AB_GMF_CFG0, |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 1856 | EFX_OWORD32(0x00001F1F, 0x00000000, 0x00000000, 0x00000000) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1857 | { FR_AB_XM_GLB_CFG, |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1858 | EFX_OWORD32(0x00000C68, 0x00000000, 0x00000000, 0x00000000) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1859 | { FR_AB_XM_TX_CFG, |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1860 | EFX_OWORD32(0x00080164, 0x00000000, 0x00000000, 0x00000000) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1861 | { FR_AB_XM_RX_CFG, |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1862 | EFX_OWORD32(0x07100A0C, 0x00000000, 0x00000000, 0x00000000) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1863 | { FR_AB_XM_RX_PARAM, |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1864 | EFX_OWORD32(0x00001FF8, 0x00000000, 0x00000000, 0x00000000) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1865 | { FR_AB_XM_FC, |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1866 | EFX_OWORD32(0xFFFF0001, 0x00000000, 0x00000000, 0x00000000) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1867 | { FR_AB_XM_ADR_LO, |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1868 | EFX_OWORD32(0xFFFFFFFF, 0x00000000, 0x00000000, 0x00000000) }, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1869 | { FR_AB_XX_SD_CTL, |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 1870 | EFX_OWORD32(0x0003FF0F, 0x00000000, 0x00000000, 0x00000000) }, |
| 1871 | }; |
| 1872 | |
Ben Hutchings | d4f2cec | 2012-07-04 03:58:33 +0100 | [diff] [blame] | 1873 | static int |
| 1874 | falcon_b0_test_chip(struct efx_nic *efx, struct efx_self_tests *tests) |
Ben Hutchings | 152b6a6 | 2009-11-29 03:43:56 +0000 | [diff] [blame] | 1875 | { |
Ben Hutchings | d4f2cec | 2012-07-04 03:58:33 +0100 | [diff] [blame] | 1876 | enum reset_type reset_method = RESET_TYPE_INVISIBLE; |
| 1877 | int rc, rc2; |
| 1878 | |
| 1879 | mutex_lock(&efx->mac_lock); |
| 1880 | if (efx->loopback_modes) { |
| 1881 | /* We need the 312 clock from the PHY to test the XMAC |
| 1882 | * registers, so move into XGMII loopback if available */ |
| 1883 | if (efx->loopback_modes & (1 << LOOPBACK_XGMII)) |
| 1884 | efx->loopback_mode = LOOPBACK_XGMII; |
| 1885 | else |
| 1886 | efx->loopback_mode = __ffs(efx->loopback_modes); |
| 1887 | } |
| 1888 | __efx_reconfigure_port(efx); |
| 1889 | mutex_unlock(&efx->mac_lock); |
| 1890 | |
| 1891 | efx_reset_down(efx, reset_method); |
| 1892 | |
| 1893 | tests->registers = |
Ben Hutchings | 86094f7 | 2013-08-21 19:51:04 +0100 | [diff] [blame] | 1894 | efx_farch_test_registers(efx, falcon_b0_register_tests, |
| 1895 | ARRAY_SIZE(falcon_b0_register_tests)) |
Ben Hutchings | d4f2cec | 2012-07-04 03:58:33 +0100 | [diff] [blame] | 1896 | ? -1 : 1; |
| 1897 | |
| 1898 | rc = falcon_reset_hw(efx, reset_method); |
| 1899 | rc2 = efx_reset_up(efx, reset_method, rc == 0); |
| 1900 | return rc ? rc : rc2; |
Ben Hutchings | 152b6a6 | 2009-11-29 03:43:56 +0000 | [diff] [blame] | 1901 | } |
| 1902 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1903 | /************************************************************************** |
| 1904 | * |
| 1905 | * Device reset |
| 1906 | * |
| 1907 | ************************************************************************** |
| 1908 | */ |
| 1909 | |
Ben Hutchings | 0e2a9c7 | 2011-06-24 20:50:07 +0100 | [diff] [blame] | 1910 | static enum reset_type falcon_map_reset_reason(enum reset_type reason) |
| 1911 | { |
| 1912 | switch (reason) { |
| 1913 | case RESET_TYPE_RX_RECOVERY: |
| 1914 | case RESET_TYPE_RX_DESC_FETCH: |
| 1915 | case RESET_TYPE_TX_DESC_FETCH: |
| 1916 | case RESET_TYPE_TX_SKIP: |
| 1917 | /* These can occasionally occur due to hardware bugs. |
| 1918 | * We try to reset without disrupting the link. |
| 1919 | */ |
| 1920 | return RESET_TYPE_INVISIBLE; |
| 1921 | default: |
| 1922 | return RESET_TYPE_ALL; |
| 1923 | } |
| 1924 | } |
| 1925 | |
| 1926 | static int falcon_map_reset_flags(u32 *flags) |
| 1927 | { |
| 1928 | enum { |
| 1929 | FALCON_RESET_INVISIBLE = (ETH_RESET_DMA | ETH_RESET_FILTER | |
| 1930 | ETH_RESET_OFFLOAD | ETH_RESET_MAC), |
| 1931 | FALCON_RESET_ALL = FALCON_RESET_INVISIBLE | ETH_RESET_PHY, |
| 1932 | FALCON_RESET_WORLD = FALCON_RESET_ALL | ETH_RESET_IRQ, |
| 1933 | }; |
| 1934 | |
| 1935 | if ((*flags & FALCON_RESET_WORLD) == FALCON_RESET_WORLD) { |
| 1936 | *flags &= ~FALCON_RESET_WORLD; |
| 1937 | return RESET_TYPE_WORLD; |
| 1938 | } |
| 1939 | |
| 1940 | if ((*flags & FALCON_RESET_ALL) == FALCON_RESET_ALL) { |
| 1941 | *flags &= ~FALCON_RESET_ALL; |
| 1942 | return RESET_TYPE_ALL; |
| 1943 | } |
| 1944 | |
| 1945 | if ((*flags & FALCON_RESET_INVISIBLE) == FALCON_RESET_INVISIBLE) { |
| 1946 | *flags &= ~FALCON_RESET_INVISIBLE; |
| 1947 | return RESET_TYPE_INVISIBLE; |
| 1948 | } |
| 1949 | |
| 1950 | return -EINVAL; |
| 1951 | } |
| 1952 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1953 | /* Resets NIC to known state. This routine must be called in process |
| 1954 | * context and is allowed to sleep. */ |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 1955 | static int __falcon_reset_hw(struct efx_nic *efx, enum reset_type method) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1956 | { |
| 1957 | struct falcon_nic_data *nic_data = efx->nic_data; |
| 1958 | efx_oword_t glb_ctl_reg_ker; |
| 1959 | int rc; |
| 1960 | |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1961 | netif_dbg(efx, hw, efx->net_dev, "performing %s hardware reset\n", |
| 1962 | RESET_TYPE(method)); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1963 | |
| 1964 | /* Initiate device reset */ |
| 1965 | if (method == RESET_TYPE_WORLD) { |
| 1966 | rc = pci_save_state(efx->pci_dev); |
| 1967 | if (rc) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1968 | netif_err(efx, drv, efx->net_dev, |
| 1969 | "failed to backup PCI state of primary " |
| 1970 | "function prior to hardware reset\n"); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1971 | goto fail1; |
| 1972 | } |
Ben Hutchings | 152b6a6 | 2009-11-29 03:43:56 +0000 | [diff] [blame] | 1973 | if (efx_nic_is_dual_func(efx)) { |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1974 | rc = pci_save_state(nic_data->pci_dev2); |
| 1975 | if (rc) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 1976 | netif_err(efx, drv, efx->net_dev, |
| 1977 | "failed to backup PCI state of " |
| 1978 | "secondary function prior to " |
| 1979 | "hardware reset\n"); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1980 | goto fail2; |
| 1981 | } |
| 1982 | } |
| 1983 | |
| 1984 | EFX_POPULATE_OWORD_2(glb_ctl_reg_ker, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1985 | FRF_AB_EXT_PHY_RST_DUR, |
| 1986 | FFE_AB_EXT_PHY_RST_DUR_10240US, |
| 1987 | FRF_AB_SWRST, 1); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1988 | } else { |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1989 | EFX_POPULATE_OWORD_7(glb_ctl_reg_ker, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 1990 | /* exclude PHY from "invisible" reset */ |
| 1991 | FRF_AB_EXT_PHY_RST_CTL, |
| 1992 | method == RESET_TYPE_INVISIBLE, |
| 1993 | /* exclude EEPROM/flash and PCIe */ |
| 1994 | FRF_AB_PCIE_CORE_RST_CTL, 1, |
| 1995 | FRF_AB_PCIE_NSTKY_RST_CTL, 1, |
| 1996 | FRF_AB_PCIE_SD_RST_CTL, 1, |
| 1997 | FRF_AB_EE_RST_CTL, 1, |
| 1998 | FRF_AB_EXT_PHY_RST_DUR, |
| 1999 | FFE_AB_EXT_PHY_RST_DUR_10240US, |
| 2000 | FRF_AB_SWRST, 1); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2001 | } |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 2002 | efx_writeo(efx, &glb_ctl_reg_ker, FR_AB_GLB_CTL); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2003 | |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2004 | netif_dbg(efx, hw, efx->net_dev, "waiting for hardware reset\n"); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2005 | schedule_timeout_uninterruptible(HZ / 20); |
| 2006 | |
| 2007 | /* Restore PCI configuration if needed */ |
| 2008 | if (method == RESET_TYPE_WORLD) { |
Jon Mason | 1d3c16a | 2010-11-30 17:43:26 -0600 | [diff] [blame] | 2009 | if (efx_nic_is_dual_func(efx)) |
| 2010 | pci_restore_state(nic_data->pci_dev2); |
| 2011 | pci_restore_state(efx->pci_dev); |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2012 | netif_dbg(efx, drv, efx->net_dev, |
| 2013 | "successfully restored PCI config\n"); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2014 | } |
| 2015 | |
| 2016 | /* Assert that reset complete */ |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 2017 | efx_reado(efx, &glb_ctl_reg_ker, FR_AB_GLB_CTL); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2018 | if (EFX_OWORD_FIELD(glb_ctl_reg_ker, FRF_AB_SWRST) != 0) { |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2019 | rc = -ETIMEDOUT; |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2020 | netif_err(efx, hw, efx->net_dev, |
| 2021 | "timed out waiting for hardware reset\n"); |
Jon Mason | 1d3c16a | 2010-11-30 17:43:26 -0600 | [diff] [blame] | 2022 | goto fail3; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2023 | } |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2024 | netif_dbg(efx, hw, efx->net_dev, "hardware reset complete\n"); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2025 | |
| 2026 | return 0; |
| 2027 | |
| 2028 | /* pci_save_state() and pci_restore_state() MUST be called in pairs */ |
| 2029 | fail2: |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2030 | pci_restore_state(efx->pci_dev); |
| 2031 | fail1: |
Jon Mason | 1d3c16a | 2010-11-30 17:43:26 -0600 | [diff] [blame] | 2032 | fail3: |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2033 | return rc; |
| 2034 | } |
| 2035 | |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 2036 | static int falcon_reset_hw(struct efx_nic *efx, enum reset_type method) |
| 2037 | { |
| 2038 | struct falcon_nic_data *nic_data = efx->nic_data; |
| 2039 | int rc; |
| 2040 | |
| 2041 | mutex_lock(&nic_data->spi_lock); |
| 2042 | rc = __falcon_reset_hw(efx, method); |
| 2043 | mutex_unlock(&nic_data->spi_lock); |
| 2044 | |
| 2045 | return rc; |
| 2046 | } |
| 2047 | |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 2048 | static void falcon_monitor(struct efx_nic *efx) |
Ben Hutchings | fe75820 | 2009-11-25 16:11:45 +0000 | [diff] [blame] | 2049 | { |
Steve Hodgson | fdaa9ae | 2009-11-28 05:34:05 +0000 | [diff] [blame] | 2050 | bool link_changed; |
Ben Hutchings | fe75820 | 2009-11-25 16:11:45 +0000 | [diff] [blame] | 2051 | int rc; |
| 2052 | |
Steve Hodgson | fdaa9ae | 2009-11-28 05:34:05 +0000 | [diff] [blame] | 2053 | BUG_ON(!mutex_is_locked(&efx->mac_lock)); |
| 2054 | |
Ben Hutchings | fe75820 | 2009-11-25 16:11:45 +0000 | [diff] [blame] | 2055 | rc = falcon_board(efx)->type->monitor(efx); |
| 2056 | if (rc) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2057 | netif_err(efx, hw, efx->net_dev, |
| 2058 | "Board sensor %s; shutting down PHY\n", |
| 2059 | (rc == -ERANGE) ? "reported fault" : "failed"); |
Ben Hutchings | fe75820 | 2009-11-25 16:11:45 +0000 | [diff] [blame] | 2060 | efx->phy_mode |= PHY_MODE_LOW_POWER; |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 2061 | rc = __efx_reconfigure_port(efx); |
| 2062 | WARN_ON(rc); |
Ben Hutchings | fe75820 | 2009-11-25 16:11:45 +0000 | [diff] [blame] | 2063 | } |
Steve Hodgson | fdaa9ae | 2009-11-28 05:34:05 +0000 | [diff] [blame] | 2064 | |
| 2065 | if (LOOPBACK_INTERNAL(efx)) |
| 2066 | link_changed = falcon_loopback_link_poll(efx); |
| 2067 | else |
| 2068 | link_changed = efx->phy_op->poll(efx); |
| 2069 | |
| 2070 | if (link_changed) { |
| 2071 | falcon_stop_nic_stats(efx); |
| 2072 | falcon_deconfigure_mac_wrapper(efx); |
| 2073 | |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 2074 | falcon_reset_macs(efx); |
Ben Hutchings | 710b208 | 2011-09-03 00:15:00 +0100 | [diff] [blame] | 2075 | rc = falcon_reconfigure_xmac(efx); |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 2076 | BUG_ON(rc); |
Steve Hodgson | fdaa9ae | 2009-11-28 05:34:05 +0000 | [diff] [blame] | 2077 | |
| 2078 | falcon_start_nic_stats(efx); |
| 2079 | |
| 2080 | efx_link_status_changed(efx); |
| 2081 | } |
| 2082 | |
Ben Hutchings | 8fbca79 | 2010-09-22 10:00:11 +0000 | [diff] [blame] | 2083 | falcon_poll_xmac(efx); |
Ben Hutchings | fe75820 | 2009-11-25 16:11:45 +0000 | [diff] [blame] | 2084 | } |
| 2085 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2086 | /* Zeroes out the SRAM contents. This routine must be called in |
| 2087 | * process context and is allowed to sleep. |
| 2088 | */ |
| 2089 | static int falcon_reset_sram(struct efx_nic *efx) |
| 2090 | { |
| 2091 | efx_oword_t srm_cfg_reg_ker, gpio_cfg_reg_ker; |
| 2092 | int count; |
| 2093 | |
| 2094 | /* Set the SRAM wake/sleep GPIO appropriately. */ |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 2095 | efx_reado(efx, &gpio_cfg_reg_ker, FR_AB_GPIO_CTL); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2096 | EFX_SET_OWORD_FIELD(gpio_cfg_reg_ker, FRF_AB_GPIO1_OEN, 1); |
| 2097 | EFX_SET_OWORD_FIELD(gpio_cfg_reg_ker, FRF_AB_GPIO1_OUT, 1); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 2098 | efx_writeo(efx, &gpio_cfg_reg_ker, FR_AB_GPIO_CTL); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2099 | |
| 2100 | /* Initiate SRAM reset */ |
| 2101 | EFX_POPULATE_OWORD_2(srm_cfg_reg_ker, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2102 | FRF_AZ_SRM_INIT_EN, 1, |
| 2103 | FRF_AZ_SRM_NB_SZ, 0); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 2104 | efx_writeo(efx, &srm_cfg_reg_ker, FR_AZ_SRM_CFG); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2105 | |
| 2106 | /* Wait for SRAM reset to complete */ |
| 2107 | count = 0; |
| 2108 | do { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2109 | netif_dbg(efx, hw, efx->net_dev, |
| 2110 | "waiting for SRAM reset (attempt %d)...\n", count); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2111 | |
| 2112 | /* SRAM reset is slow; expect around 16ms */ |
| 2113 | schedule_timeout_uninterruptible(HZ / 50); |
| 2114 | |
| 2115 | /* Check for reset complete */ |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 2116 | efx_reado(efx, &srm_cfg_reg_ker, FR_AZ_SRM_CFG); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2117 | if (!EFX_OWORD_FIELD(srm_cfg_reg_ker, FRF_AZ_SRM_INIT_EN)) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2118 | netif_dbg(efx, hw, efx->net_dev, |
| 2119 | "SRAM reset complete\n"); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2120 | |
| 2121 | return 0; |
| 2122 | } |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 2123 | } while (++count < 20); /* wait up to 0.4 sec */ |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2124 | |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2125 | netif_err(efx, hw, efx->net_dev, "timed out waiting for SRAM reset\n"); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2126 | return -ETIMEDOUT; |
| 2127 | } |
| 2128 | |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 2129 | static void falcon_spi_device_init(struct efx_nic *efx, |
Ben Hutchings | ecd0a6f0 | 2012-11-28 04:12:41 +0000 | [diff] [blame] | 2130 | struct falcon_spi_device *spi_device, |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 2131 | unsigned int device_id, u32 device_type) |
| 2132 | { |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 2133 | if (device_type != 0) { |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 2134 | spi_device->device_id = device_id; |
| 2135 | spi_device->size = |
| 2136 | 1 << SPI_DEV_TYPE_FIELD(device_type, SPI_DEV_TYPE_SIZE); |
| 2137 | spi_device->addr_len = |
| 2138 | SPI_DEV_TYPE_FIELD(device_type, SPI_DEV_TYPE_ADDR_LEN); |
| 2139 | spi_device->munge_address = (spi_device->size == 1 << 9 && |
| 2140 | spi_device->addr_len == 1); |
Ben Hutchings | f415072 | 2008-11-04 20:34:28 +0000 | [diff] [blame] | 2141 | spi_device->erase_command = |
| 2142 | SPI_DEV_TYPE_FIELD(device_type, SPI_DEV_TYPE_ERASE_CMD); |
| 2143 | spi_device->erase_size = |
| 2144 | 1 << SPI_DEV_TYPE_FIELD(device_type, |
| 2145 | SPI_DEV_TYPE_ERASE_SIZE); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 2146 | spi_device->block_size = |
| 2147 | 1 << SPI_DEV_TYPE_FIELD(device_type, |
| 2148 | SPI_DEV_TYPE_BLOCK_SIZE); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 2149 | } else { |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 2150 | spi_device->size = 0; |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 2151 | } |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 2152 | } |
| 2153 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2154 | /* Extract non-volatile configuration */ |
| 2155 | static int falcon_probe_nvconfig(struct efx_nic *efx) |
| 2156 | { |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 2157 | struct falcon_nic_data *nic_data = efx->nic_data; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2158 | struct falcon_nvconfig *nvconfig; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2159 | int rc; |
| 2160 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2161 | nvconfig = kmalloc(sizeof(*nvconfig), GFP_KERNEL); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 2162 | if (!nvconfig) |
| 2163 | return -ENOMEM; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2164 | |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 2165 | rc = falcon_read_nvram(efx, nvconfig); |
Ben Hutchings | 6c88b0b | 2010-12-02 13:47:01 +0000 | [diff] [blame] | 2166 | if (rc) |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 2167 | goto out; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2168 | |
Ben Hutchings | 6c88b0b | 2010-12-02 13:47:01 +0000 | [diff] [blame] | 2169 | efx->phy_type = nvconfig->board_v2.port0_phy_type; |
| 2170 | efx->mdio.prtad = nvconfig->board_v2.port0_phy_addr; |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 2171 | |
Ben Hutchings | 6c88b0b | 2010-12-02 13:47:01 +0000 | [diff] [blame] | 2172 | if (le16_to_cpu(nvconfig->board_struct_ver) >= 3) { |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 2173 | falcon_spi_device_init( |
| 2174 | efx, &nic_data->spi_flash, FFE_AB_SPI_DEVICE_FLASH, |
Ben Hutchings | 6c88b0b | 2010-12-02 13:47:01 +0000 | [diff] [blame] | 2175 | le32_to_cpu(nvconfig->board_v3 |
| 2176 | .spi_device_type[FFE_AB_SPI_DEVICE_FLASH])); |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 2177 | falcon_spi_device_init( |
| 2178 | efx, &nic_data->spi_eeprom, FFE_AB_SPI_DEVICE_EEPROM, |
Ben Hutchings | 6c88b0b | 2010-12-02 13:47:01 +0000 | [diff] [blame] | 2179 | le32_to_cpu(nvconfig->board_v3 |
| 2180 | .spi_device_type[FFE_AB_SPI_DEVICE_EEPROM])); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2181 | } |
| 2182 | |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 2183 | /* Read the MAC addresses */ |
Ben Hutchings | 7e300bc | 2010-12-02 13:48:28 +0000 | [diff] [blame] | 2184 | memcpy(efx->net_dev->perm_addr, nvconfig->mac_address[0], ETH_ALEN); |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 2185 | |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2186 | netif_dbg(efx, probe, efx->net_dev, "PHY is %d phy_id %d\n", |
| 2187 | efx->phy_type, efx->mdio.prtad); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2188 | |
Ben Hutchings | 6c88b0b | 2010-12-02 13:47:01 +0000 | [diff] [blame] | 2189 | rc = falcon_probe_board(efx, |
| 2190 | le16_to_cpu(nvconfig->board_v2.board_revision)); |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 2191 | out: |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2192 | kfree(nvconfig); |
| 2193 | return rc; |
| 2194 | } |
| 2195 | |
Ben Hutchings | 28e47c4 | 2012-02-15 01:58:49 +0000 | [diff] [blame] | 2196 | static void falcon_dimension_resources(struct efx_nic *efx) |
| 2197 | { |
| 2198 | efx->rx_dc_base = 0x20000; |
| 2199 | efx->tx_dc_base = 0x26000; |
| 2200 | } |
| 2201 | |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 2202 | /* Probe all SPI devices on the NIC */ |
| 2203 | static void falcon_probe_spi_devices(struct efx_nic *efx) |
| 2204 | { |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 2205 | struct falcon_nic_data *nic_data = efx->nic_data; |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 2206 | efx_oword_t nic_stat, gpio_ctl, ee_vpd_cfg; |
Ben Hutchings | 2f7f573 | 2008-12-12 21:34:25 -0800 | [diff] [blame] | 2207 | int boot_dev; |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 2208 | |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 2209 | efx_reado(efx, &gpio_ctl, FR_AB_GPIO_CTL); |
| 2210 | efx_reado(efx, &nic_stat, FR_AB_NIC_STAT); |
| 2211 | efx_reado(efx, &ee_vpd_cfg, FR_AB_EE_VPD_CFG0); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 2212 | |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2213 | if (EFX_OWORD_FIELD(gpio_ctl, FRF_AB_GPIO3_PWRUP_VALUE)) { |
| 2214 | boot_dev = (EFX_OWORD_FIELD(nic_stat, FRF_AB_SF_PRST) ? |
| 2215 | FFE_AB_SPI_DEVICE_FLASH : FFE_AB_SPI_DEVICE_EEPROM); |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2216 | netif_dbg(efx, probe, efx->net_dev, "Booted from %s\n", |
| 2217 | boot_dev == FFE_AB_SPI_DEVICE_FLASH ? |
| 2218 | "flash" : "EEPROM"); |
Ben Hutchings | 2f7f573 | 2008-12-12 21:34:25 -0800 | [diff] [blame] | 2219 | } else { |
| 2220 | /* Disable VPD and set clock dividers to safe |
| 2221 | * values for initial programming. */ |
| 2222 | boot_dev = -1; |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2223 | netif_dbg(efx, probe, efx->net_dev, |
| 2224 | "Booted from internal ASIC settings;" |
| 2225 | " setting SPI config\n"); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2226 | EFX_POPULATE_OWORD_3(ee_vpd_cfg, FRF_AB_EE_VPD_EN, 0, |
Ben Hutchings | 2f7f573 | 2008-12-12 21:34:25 -0800 | [diff] [blame] | 2227 | /* 125 MHz / 7 ~= 20 MHz */ |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2228 | FRF_AB_EE_SF_CLOCK_DIV, 7, |
Ben Hutchings | 2f7f573 | 2008-12-12 21:34:25 -0800 | [diff] [blame] | 2229 | /* 125 MHz / 63 ~= 2 MHz */ |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2230 | FRF_AB_EE_EE_CLOCK_DIV, 63); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 2231 | efx_writeo(efx, &ee_vpd_cfg, FR_AB_EE_VPD_CFG0); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 2232 | } |
| 2233 | |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 2234 | mutex_init(&nic_data->spi_lock); |
| 2235 | |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2236 | if (boot_dev == FFE_AB_SPI_DEVICE_FLASH) |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 2237 | falcon_spi_device_init(efx, &nic_data->spi_flash, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2238 | FFE_AB_SPI_DEVICE_FLASH, |
Ben Hutchings | 2f7f573 | 2008-12-12 21:34:25 -0800 | [diff] [blame] | 2239 | default_flash_type); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2240 | if (boot_dev == FFE_AB_SPI_DEVICE_EEPROM) |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 2241 | falcon_spi_device_init(efx, &nic_data->spi_eeprom, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2242 | FFE_AB_SPI_DEVICE_EEPROM, |
Ben Hutchings | 2f7f573 | 2008-12-12 21:34:25 -0800 | [diff] [blame] | 2243 | large_eeprom_type); |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 2244 | } |
| 2245 | |
Ben Hutchings | b105798 | 2012-09-19 00:56:47 +0100 | [diff] [blame] | 2246 | static unsigned int falcon_a1_mem_map_size(struct efx_nic *efx) |
| 2247 | { |
| 2248 | return 0x20000; |
| 2249 | } |
| 2250 | |
| 2251 | static unsigned int falcon_b0_mem_map_size(struct efx_nic *efx) |
| 2252 | { |
| 2253 | /* Map everything up to and including the RSS indirection table. |
| 2254 | * The PCI core takes care of mapping the MSI-X tables. |
| 2255 | */ |
| 2256 | return FR_BZ_RX_INDIRECTION_TBL + |
| 2257 | FR_BZ_RX_INDIRECTION_TBL_STEP * FR_BZ_RX_INDIRECTION_TBL_ROWS; |
| 2258 | } |
| 2259 | |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 2260 | static int falcon_probe_nic(struct efx_nic *efx) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2261 | { |
| 2262 | struct falcon_nic_data *nic_data; |
Ben Hutchings | e775fb9 | 2009-11-23 16:06:02 +0000 | [diff] [blame] | 2263 | struct falcon_board *board; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2264 | int rc; |
| 2265 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2266 | /* Allocate storage for hardware specific data */ |
| 2267 | nic_data = kzalloc(sizeof(*nic_data), GFP_KERNEL); |
Ben Hutchings | 88c5942 | 2008-09-03 15:07:50 +0100 | [diff] [blame] | 2268 | if (!nic_data) |
| 2269 | return -ENOMEM; |
Ben Hutchings | 5daab96 | 2008-05-16 21:19:43 +0100 | [diff] [blame] | 2270 | efx->nic_data = nic_data; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2271 | |
Ben Hutchings | 5784946 | 2009-11-29 15:08:21 +0000 | [diff] [blame] | 2272 | rc = -ENODEV; |
| 2273 | |
Ben Hutchings | 86094f7 | 2013-08-21 19:51:04 +0100 | [diff] [blame] | 2274 | if (efx_farch_fpga_ver(efx) != 0) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2275 | netif_err(efx, probe, efx->net_dev, |
| 2276 | "Falcon FPGA not supported\n"); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2277 | goto fail1; |
Ben Hutchings | 5784946 | 2009-11-29 15:08:21 +0000 | [diff] [blame] | 2278 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2279 | |
Ben Hutchings | 5784946 | 2009-11-29 15:08:21 +0000 | [diff] [blame] | 2280 | if (efx_nic_rev(efx) <= EFX_REV_FALCON_A1) { |
| 2281 | efx_oword_t nic_stat; |
| 2282 | struct pci_dev *dev; |
| 2283 | u8 pci_rev = efx->pci_dev->revision; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2284 | |
Ben Hutchings | 5784946 | 2009-11-29 15:08:21 +0000 | [diff] [blame] | 2285 | if ((pci_rev == 0xff) || (pci_rev == 0)) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2286 | netif_err(efx, probe, efx->net_dev, |
| 2287 | "Falcon rev A0 not supported\n"); |
Ben Hutchings | 5784946 | 2009-11-29 15:08:21 +0000 | [diff] [blame] | 2288 | goto fail1; |
| 2289 | } |
| 2290 | efx_reado(efx, &nic_stat, FR_AB_NIC_STAT); |
| 2291 | if (EFX_OWORD_FIELD(nic_stat, FRF_AB_STRAP_10G) == 0) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2292 | netif_err(efx, probe, efx->net_dev, |
| 2293 | "Falcon rev A1 1G not supported\n"); |
Ben Hutchings | 5784946 | 2009-11-29 15:08:21 +0000 | [diff] [blame] | 2294 | goto fail1; |
| 2295 | } |
| 2296 | if (EFX_OWORD_FIELD(nic_stat, FRF_AA_STRAP_PCIE) == 0) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2297 | netif_err(efx, probe, efx->net_dev, |
| 2298 | "Falcon rev A1 PCI-X not supported\n"); |
Ben Hutchings | 5784946 | 2009-11-29 15:08:21 +0000 | [diff] [blame] | 2299 | goto fail1; |
| 2300 | } |
| 2301 | |
| 2302 | dev = pci_dev_get(efx->pci_dev); |
Linus Torvalds | 0e59e7e7 | 2011-10-28 14:20:44 -0700 | [diff] [blame] | 2303 | while ((dev = pci_get_device(PCI_VENDOR_ID_SOLARFLARE, |
| 2304 | PCI_DEVICE_ID_SOLARFLARE_SFC4000A_1, |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2305 | dev))) { |
| 2306 | if (dev->bus == efx->pci_dev->bus && |
| 2307 | dev->devfn == efx->pci_dev->devfn + 1) { |
| 2308 | nic_data->pci_dev2 = dev; |
| 2309 | break; |
| 2310 | } |
| 2311 | } |
| 2312 | if (!nic_data->pci_dev2) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2313 | netif_err(efx, probe, efx->net_dev, |
| 2314 | "failed to find secondary function\n"); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2315 | rc = -ENODEV; |
| 2316 | goto fail2; |
| 2317 | } |
| 2318 | } |
| 2319 | |
| 2320 | /* Now we can reset the NIC */ |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 2321 | rc = __falcon_reset_hw(efx, RESET_TYPE_ALL); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2322 | if (rc) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2323 | netif_err(efx, probe, efx->net_dev, "failed to reset NIC\n"); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2324 | goto fail3; |
| 2325 | } |
| 2326 | |
| 2327 | /* Allocate memory for INT_KER */ |
Ben Hutchings | 0d19a54 | 2012-09-18 21:59:52 +0100 | [diff] [blame] | 2328 | rc = efx_nic_alloc_buffer(efx, &efx->irq_status, sizeof(efx_oword_t), |
| 2329 | GFP_KERNEL); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2330 | if (rc) |
| 2331 | goto fail4; |
| 2332 | BUG_ON(efx->irq_status.dma_addr & 0x0f); |
| 2333 | |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2334 | netif_dbg(efx, probe, efx->net_dev, |
| 2335 | "INT_KER at %llx (virt %p phys %llx)\n", |
| 2336 | (u64)efx->irq_status.dma_addr, |
| 2337 | efx->irq_status.addr, |
| 2338 | (u64)virt_to_phys(efx->irq_status.addr)); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2339 | |
Ben Hutchings | 4a5b504 | 2008-09-01 12:47:16 +0100 | [diff] [blame] | 2340 | falcon_probe_spi_devices(efx); |
| 2341 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2342 | /* Read in the non-volatile configuration */ |
| 2343 | rc = falcon_probe_nvconfig(efx); |
Ben Hutchings | 6c88b0b | 2010-12-02 13:47:01 +0000 | [diff] [blame] | 2344 | if (rc) { |
| 2345 | if (rc == -EINVAL) |
| 2346 | netif_err(efx, probe, efx->net_dev, "NVRAM is invalid\n"); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2347 | goto fail5; |
Ben Hutchings | 6c88b0b | 2010-12-02 13:47:01 +0000 | [diff] [blame] | 2348 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2349 | |
Ben Hutchings | b105798 | 2012-09-19 00:56:47 +0100 | [diff] [blame] | 2350 | efx->max_channels = (efx_nic_rev(efx) <= EFX_REV_FALCON_A1 ? 4 : |
| 2351 | EFX_MAX_CHANNELS); |
Ben Hutchings | cc180b6 | 2011-12-08 19:51:47 +0000 | [diff] [blame] | 2352 | efx->timer_quantum_ns = 4968; /* 621 cycles */ |
| 2353 | |
Ben Hutchings | 37b5a60 | 2008-05-30 22:27:04 +0100 | [diff] [blame] | 2354 | /* Initialise I2C adapter */ |
Ben Hutchings | e775fb9 | 2009-11-23 16:06:02 +0000 | [diff] [blame] | 2355 | board = falcon_board(efx); |
| 2356 | board->i2c_adap.owner = THIS_MODULE; |
| 2357 | board->i2c_data = falcon_i2c_bit_operations; |
| 2358 | board->i2c_data.data = efx; |
| 2359 | board->i2c_adap.algo_data = &board->i2c_data; |
| 2360 | board->i2c_adap.dev.parent = &efx->pci_dev->dev; |
| 2361 | strlcpy(board->i2c_adap.name, "SFC4000 GPIO", |
| 2362 | sizeof(board->i2c_adap.name)); |
| 2363 | rc = i2c_bit_add_bus(&board->i2c_adap); |
Ben Hutchings | 37b5a60 | 2008-05-30 22:27:04 +0100 | [diff] [blame] | 2364 | if (rc) |
| 2365 | goto fail5; |
| 2366 | |
Ben Hutchings | 44838a4 | 2009-11-25 16:09:41 +0000 | [diff] [blame] | 2367 | rc = falcon_board(efx)->type->init(efx); |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame] | 2368 | if (rc) { |
Ben Hutchings | 62776d0 | 2010-06-23 11:30:07 +0000 | [diff] [blame] | 2369 | netif_err(efx, probe, efx->net_dev, |
| 2370 | "failed to initialise board\n"); |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame] | 2371 | goto fail6; |
| 2372 | } |
| 2373 | |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 2374 | nic_data->stats_disable_count = 1; |
| 2375 | setup_timer(&nic_data->stats_timer, &falcon_stats_timer_func, |
| 2376 | (unsigned long)efx); |
| 2377 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2378 | return 0; |
| 2379 | |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame] | 2380 | fail6: |
Lars-Peter Clausen | bf51a8c | 2013-03-09 08:16:46 +0000 | [diff] [blame] | 2381 | i2c_del_adapter(&board->i2c_adap); |
Ben Hutchings | e775fb9 | 2009-11-23 16:06:02 +0000 | [diff] [blame] | 2382 | memset(&board->i2c_adap, 0, sizeof(board->i2c_adap)); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2383 | fail5: |
Ben Hutchings | 152b6a6 | 2009-11-29 03:43:56 +0000 | [diff] [blame] | 2384 | efx_nic_free_buffer(efx, &efx->irq_status); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2385 | fail4: |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2386 | fail3: |
| 2387 | if (nic_data->pci_dev2) { |
| 2388 | pci_dev_put(nic_data->pci_dev2); |
| 2389 | nic_data->pci_dev2 = NULL; |
| 2390 | } |
| 2391 | fail2: |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2392 | fail1: |
| 2393 | kfree(efx->nic_data); |
| 2394 | return rc; |
| 2395 | } |
| 2396 | |
Ben Hutchings | 56241ce | 2009-10-23 08:30:06 +0000 | [diff] [blame] | 2397 | static void falcon_init_rx_cfg(struct efx_nic *efx) |
| 2398 | { |
Ben Hutchings | 56241ce | 2009-10-23 08:30:06 +0000 | [diff] [blame] | 2399 | /* RX control FIFO thresholds (32 entries) */ |
| 2400 | const unsigned ctrl_xon_thr = 20; |
| 2401 | const unsigned ctrl_xoff_thr = 25; |
Ben Hutchings | 56241ce | 2009-10-23 08:30:06 +0000 | [diff] [blame] | 2402 | efx_oword_t reg; |
| 2403 | |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 2404 | efx_reado(efx, ®, FR_AZ_RX_CFG); |
Ben Hutchings | daeda63 | 2009-11-28 05:36:04 +0000 | [diff] [blame] | 2405 | if (efx_nic_rev(efx) <= EFX_REV_FALCON_A1) { |
Ben Hutchings | 85740cdf | 2013-01-29 23:33:15 +0000 | [diff] [blame] | 2406 | /* Data FIFO size is 5.5K. The RX DMA engine only |
| 2407 | * supports scattering for user-mode queues, but will |
| 2408 | * split DMA writes at intervals of RX_USR_BUF_SIZE |
| 2409 | * (32-byte units) even for kernel-mode queues. We |
| 2410 | * set it to be so large that that never happens. |
| 2411 | */ |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2412 | EFX_SET_OWORD_FIELD(reg, FRF_AA_RX_DESC_PUSH_EN, 0); |
| 2413 | EFX_SET_OWORD_FIELD(reg, FRF_AA_RX_USR_BUF_SIZE, |
Ben Hutchings | 85740cdf | 2013-01-29 23:33:15 +0000 | [diff] [blame] | 2414 | (3 * 4096) >> 5); |
Ben Hutchings | 5fb6b06 | 2011-02-24 19:30:41 +0000 | [diff] [blame] | 2415 | EFX_SET_OWORD_FIELD(reg, FRF_AA_RX_XON_MAC_TH, 512 >> 8); |
| 2416 | EFX_SET_OWORD_FIELD(reg, FRF_AA_RX_XOFF_MAC_TH, 2048 >> 8); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2417 | EFX_SET_OWORD_FIELD(reg, FRF_AA_RX_XON_TX_TH, ctrl_xon_thr); |
| 2418 | EFX_SET_OWORD_FIELD(reg, FRF_AA_RX_XOFF_TX_TH, ctrl_xoff_thr); |
Ben Hutchings | 56241ce | 2009-10-23 08:30:06 +0000 | [diff] [blame] | 2419 | } else { |
Ben Hutchings | 625b451 | 2009-10-23 08:30:17 +0000 | [diff] [blame] | 2420 | /* Data FIFO size is 80K; register fields moved */ |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2421 | EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_DESC_PUSH_EN, 0); |
| 2422 | EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_USR_BUF_SIZE, |
Ben Hutchings | 85740cdf | 2013-01-29 23:33:15 +0000 | [diff] [blame] | 2423 | EFX_RX_USR_BUF_SIZE >> 5); |
Ben Hutchings | 5fb6b06 | 2011-02-24 19:30:41 +0000 | [diff] [blame] | 2424 | /* Send XON and XOFF at ~3 * max MTU away from empty/full */ |
| 2425 | EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_XON_MAC_TH, 27648 >> 8); |
| 2426 | EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_XOFF_MAC_TH, 54272 >> 8); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2427 | EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_XON_TX_TH, ctrl_xon_thr); |
| 2428 | EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_XOFF_TX_TH, ctrl_xoff_thr); |
| 2429 | EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_INGR_EN, 1); |
Ben Hutchings | 477e54e | 2010-06-25 07:05:56 +0000 | [diff] [blame] | 2430 | |
| 2431 | /* Enable hash insertion. This is broken for the |
| 2432 | * 'Falcon' hash so also select Toeplitz TCP/IPv4 and |
| 2433 | * IPv4 hashes. */ |
| 2434 | EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_HASH_INSRT_HDR, 1); |
| 2435 | EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_HASH_ALG, 1); |
| 2436 | EFX_SET_OWORD_FIELD(reg, FRF_BZ_RX_IP_HASH, 1); |
Ben Hutchings | 56241ce | 2009-10-23 08:30:06 +0000 | [diff] [blame] | 2437 | } |
Ben Hutchings | 4b0d29d | 2009-11-29 03:42:18 +0000 | [diff] [blame] | 2438 | /* Always enable XOFF signal from RX FIFO. We enable |
| 2439 | * or disable transmission of pause frames at the MAC. */ |
| 2440 | EFX_SET_OWORD_FIELD(reg, FRF_AZ_RX_XOFF_MAC_EN, 1); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 2441 | efx_writeo(efx, ®, FR_AZ_RX_CFG); |
Ben Hutchings | 56241ce | 2009-10-23 08:30:06 +0000 | [diff] [blame] | 2442 | } |
| 2443 | |
Ben Hutchings | 152b6a6 | 2009-11-29 03:43:56 +0000 | [diff] [blame] | 2444 | /* This call performs hardware-specific global initialisation, such as |
| 2445 | * defining the descriptor cache sizes and number of RSS channels. |
| 2446 | * It does not set up any buffers, descriptor rings or event queues. |
| 2447 | */ |
| 2448 | static int falcon_init_nic(struct efx_nic *efx) |
| 2449 | { |
| 2450 | efx_oword_t temp; |
| 2451 | int rc; |
| 2452 | |
| 2453 | /* Use on-chip SRAM */ |
| 2454 | efx_reado(efx, &temp, FR_AB_NIC_STAT); |
| 2455 | EFX_SET_OWORD_FIELD(temp, FRF_AB_ONCHIP_SRAM, 1); |
| 2456 | efx_writeo(efx, &temp, FR_AB_NIC_STAT); |
| 2457 | |
Ben Hutchings | 152b6a6 | 2009-11-29 03:43:56 +0000 | [diff] [blame] | 2458 | rc = falcon_reset_sram(efx); |
| 2459 | if (rc) |
| 2460 | return rc; |
| 2461 | |
| 2462 | /* Clear the parity enables on the TX data fifos as |
| 2463 | * they produce false parity errors because of timing issues |
| 2464 | */ |
| 2465 | if (EFX_WORKAROUND_5129(efx)) { |
| 2466 | efx_reado(efx, &temp, FR_AZ_CSR_SPARE); |
| 2467 | EFX_SET_OWORD_FIELD(temp, FRF_AB_MEM_PERR_EN_TX_DATA, 0); |
| 2468 | efx_writeo(efx, &temp, FR_AZ_CSR_SPARE); |
| 2469 | } |
| 2470 | |
| 2471 | if (EFX_WORKAROUND_7244(efx)) { |
| 2472 | efx_reado(efx, &temp, FR_BZ_RX_FILTER_CTL); |
| 2473 | EFX_SET_OWORD_FIELD(temp, FRF_BZ_UDP_FULL_SRCH_LIMIT, 8); |
| 2474 | EFX_SET_OWORD_FIELD(temp, FRF_BZ_UDP_WILD_SRCH_LIMIT, 8); |
| 2475 | EFX_SET_OWORD_FIELD(temp, FRF_BZ_TCP_FULL_SRCH_LIMIT, 8); |
| 2476 | EFX_SET_OWORD_FIELD(temp, FRF_BZ_TCP_WILD_SRCH_LIMIT, 8); |
| 2477 | efx_writeo(efx, &temp, FR_BZ_RX_FILTER_CTL); |
| 2478 | } |
| 2479 | |
| 2480 | /* XXX This is documented only for Falcon A0/A1 */ |
| 2481 | /* Setup RX. Wait for descriptor is broken and must |
| 2482 | * be disabled. RXDP recovery shouldn't be needed, but is. |
| 2483 | */ |
| 2484 | efx_reado(efx, &temp, FR_AA_RX_SELF_RST); |
| 2485 | EFX_SET_OWORD_FIELD(temp, FRF_AA_RX_NODESC_WAIT_DIS, 1); |
| 2486 | EFX_SET_OWORD_FIELD(temp, FRF_AA_RX_SELF_RST_EN, 1); |
| 2487 | if (EFX_WORKAROUND_5583(efx)) |
| 2488 | EFX_SET_OWORD_FIELD(temp, FRF_AA_RX_ISCSI_DIS, 1); |
| 2489 | efx_writeo(efx, &temp, FR_AA_RX_SELF_RST); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2490 | |
| 2491 | /* Do not enable TX_NO_EOP_DISC_EN, since it limits packets to 16 |
| 2492 | * descriptors (which is bad). |
| 2493 | */ |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 2494 | efx_reado(efx, &temp, FR_AZ_TX_CFG); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2495 | EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_NO_EOP_DISC_EN, 0); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 2496 | efx_writeo(efx, &temp, FR_AZ_TX_CFG); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2497 | |
Ben Hutchings | 56241ce | 2009-10-23 08:30:06 +0000 | [diff] [blame] | 2498 | falcon_init_rx_cfg(efx); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2499 | |
Ben Hutchings | daeda63 | 2009-11-28 05:36:04 +0000 | [diff] [blame] | 2500 | if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0) { |
Ben Hutchings | 477e54e | 2010-06-25 07:05:56 +0000 | [diff] [blame] | 2501 | /* Set hash key for IPv4 */ |
| 2502 | memcpy(&temp, efx->rx_hash_key, sizeof(temp)); |
| 2503 | efx_writeo(efx, &temp, FR_BZ_RX_RSS_TKEY); |
| 2504 | |
| 2505 | /* Set destination of both TX and RX Flush events */ |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2506 | EFX_POPULATE_OWORD_1(temp, FRF_BZ_FLS_EVQ_ID, 0); |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 2507 | efx_writeo(efx, &temp, FR_BZ_DP_CTRL); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2508 | } |
| 2509 | |
Ben Hutchings | 86094f7 | 2013-08-21 19:51:04 +0100 | [diff] [blame] | 2510 | efx_farch_init_common(efx); |
Ben Hutchings | 152b6a6 | 2009-11-29 03:43:56 +0000 | [diff] [blame] | 2511 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2512 | return 0; |
| 2513 | } |
| 2514 | |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 2515 | static void falcon_remove_nic(struct efx_nic *efx) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2516 | { |
| 2517 | struct falcon_nic_data *nic_data = efx->nic_data; |
Ben Hutchings | e775fb9 | 2009-11-23 16:06:02 +0000 | [diff] [blame] | 2518 | struct falcon_board *board = falcon_board(efx); |
Ben Hutchings | 37b5a60 | 2008-05-30 22:27:04 +0100 | [diff] [blame] | 2519 | |
Ben Hutchings | 44838a4 | 2009-11-25 16:09:41 +0000 | [diff] [blame] | 2520 | board->type->fini(efx); |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame] | 2521 | |
Ben Hutchings | 8c87037 | 2009-03-04 09:53:02 +0000 | [diff] [blame] | 2522 | /* Remove I2C adapter and clear it in preparation for a retry */ |
Lars-Peter Clausen | bf51a8c | 2013-03-09 08:16:46 +0000 | [diff] [blame] | 2523 | i2c_del_adapter(&board->i2c_adap); |
Ben Hutchings | e775fb9 | 2009-11-23 16:06:02 +0000 | [diff] [blame] | 2524 | memset(&board->i2c_adap, 0, sizeof(board->i2c_adap)); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2525 | |
Ben Hutchings | 152b6a6 | 2009-11-29 03:43:56 +0000 | [diff] [blame] | 2526 | efx_nic_free_buffer(efx, &efx->irq_status); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2527 | |
Ben Hutchings | 4de9218 | 2010-12-02 13:47:29 +0000 | [diff] [blame] | 2528 | __falcon_reset_hw(efx, RESET_TYPE_ALL); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2529 | |
| 2530 | /* Release the second function after the reset */ |
| 2531 | if (nic_data->pci_dev2) { |
| 2532 | pci_dev_put(nic_data->pci_dev2); |
| 2533 | nic_data->pci_dev2 = NULL; |
| 2534 | } |
| 2535 | |
| 2536 | /* Tear down the private nic state */ |
| 2537 | kfree(efx->nic_data); |
| 2538 | efx->nic_data = NULL; |
| 2539 | } |
| 2540 | |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 2541 | static void falcon_update_nic_stats(struct efx_nic *efx) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2542 | { |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 2543 | struct falcon_nic_data *nic_data = efx->nic_data; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2544 | efx_oword_t cnt; |
| 2545 | |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 2546 | if (nic_data->stats_disable_count) |
| 2547 | return; |
| 2548 | |
Ben Hutchings | 12d00ca | 2009-10-23 08:30:46 +0000 | [diff] [blame] | 2549 | efx_reado(efx, &cnt, FR_AZ_RX_NODESC_DROP); |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2550 | efx->n_rx_nodesc_drop_cnt += |
| 2551 | EFX_OWORD_FIELD(cnt, FRF_AB_RX_NODESC_DROP_CNT); |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 2552 | |
Ben Hutchings | e513612 | 2012-12-14 21:52:56 +0000 | [diff] [blame] | 2553 | if (nic_data->stats_pending && FALCON_XMAC_STATS_DMA_FLAG(efx)) { |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 2554 | nic_data->stats_pending = false; |
| 2555 | rmb(); /* read the done flag before the stats */ |
Ben Hutchings | 710b208 | 2011-09-03 00:15:00 +0100 | [diff] [blame] | 2556 | falcon_update_stats_xmac(efx); |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 2557 | } |
| 2558 | } |
| 2559 | |
| 2560 | void falcon_start_nic_stats(struct efx_nic *efx) |
| 2561 | { |
| 2562 | struct falcon_nic_data *nic_data = efx->nic_data; |
| 2563 | |
| 2564 | spin_lock_bh(&efx->stats_lock); |
| 2565 | if (--nic_data->stats_disable_count == 0) |
| 2566 | falcon_stats_request(efx); |
| 2567 | spin_unlock_bh(&efx->stats_lock); |
| 2568 | } |
| 2569 | |
| 2570 | void falcon_stop_nic_stats(struct efx_nic *efx) |
| 2571 | { |
| 2572 | struct falcon_nic_data *nic_data = efx->nic_data; |
| 2573 | int i; |
| 2574 | |
| 2575 | might_sleep(); |
| 2576 | |
| 2577 | spin_lock_bh(&efx->stats_lock); |
| 2578 | ++nic_data->stats_disable_count; |
| 2579 | spin_unlock_bh(&efx->stats_lock); |
| 2580 | |
| 2581 | del_timer_sync(&nic_data->stats_timer); |
| 2582 | |
| 2583 | /* Wait enough time for the most recent transfer to |
| 2584 | * complete. */ |
| 2585 | for (i = 0; i < 4 && nic_data->stats_pending; i++) { |
Ben Hutchings | e513612 | 2012-12-14 21:52:56 +0000 | [diff] [blame] | 2586 | if (FALCON_XMAC_STATS_DMA_FLAG(efx)) |
Ben Hutchings | 55edc6e | 2009-11-25 16:11:35 +0000 | [diff] [blame] | 2587 | break; |
| 2588 | msleep(1); |
| 2589 | } |
| 2590 | |
| 2591 | spin_lock_bh(&efx->stats_lock); |
| 2592 | falcon_stats_complete(efx); |
| 2593 | spin_unlock_bh(&efx->stats_lock); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2594 | } |
| 2595 | |
Ben Hutchings | 06629f0 | 2009-11-29 03:43:43 +0000 | [diff] [blame] | 2596 | static void falcon_set_id_led(struct efx_nic *efx, enum efx_led_mode mode) |
| 2597 | { |
| 2598 | falcon_board(efx)->type->set_id_led(efx, mode); |
| 2599 | } |
| 2600 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2601 | /************************************************************************** |
| 2602 | * |
Ben Hutchings | 89c758f | 2009-11-29 03:43:07 +0000 | [diff] [blame] | 2603 | * Wake on LAN |
| 2604 | * |
| 2605 | ************************************************************************** |
| 2606 | */ |
| 2607 | |
| 2608 | static void falcon_get_wol(struct efx_nic *efx, struct ethtool_wolinfo *wol) |
| 2609 | { |
| 2610 | wol->supported = 0; |
| 2611 | wol->wolopts = 0; |
| 2612 | memset(&wol->sopass, 0, sizeof(wol->sopass)); |
| 2613 | } |
| 2614 | |
| 2615 | static int falcon_set_wol(struct efx_nic *efx, u32 type) |
| 2616 | { |
| 2617 | if (type != 0) |
| 2618 | return -EINVAL; |
| 2619 | return 0; |
| 2620 | } |
| 2621 | |
| 2622 | /************************************************************************** |
| 2623 | * |
Ben Hutchings | 754c653 | 2010-02-03 09:31:57 +0000 | [diff] [blame] | 2624 | * Revision-dependent attributes used by efx.c and nic.c |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2625 | * |
| 2626 | ************************************************************************** |
| 2627 | */ |
| 2628 | |
stephen hemminger | 6c8c251 | 2011-04-14 05:50:12 +0000 | [diff] [blame] | 2629 | const struct efx_nic_type falcon_a1_nic_type = { |
Ben Hutchings | b105798 | 2012-09-19 00:56:47 +0100 | [diff] [blame] | 2630 | .mem_map_size = falcon_a1_mem_map_size, |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 2631 | .probe = falcon_probe_nic, |
| 2632 | .remove = falcon_remove_nic, |
| 2633 | .init = falcon_init_nic, |
Ben Hutchings | 28e47c4 | 2012-02-15 01:58:49 +0000 | [diff] [blame] | 2634 | .dimension_resources = falcon_dimension_resources, |
Ben Hutchings | 1840667 | 2013-01-03 23:36:57 +0000 | [diff] [blame] | 2635 | .fini = falcon_irq_ack_a1, |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 2636 | .monitor = falcon_monitor, |
Ben Hutchings | 0e2a9c7 | 2011-06-24 20:50:07 +0100 | [diff] [blame] | 2637 | .map_reset_reason = falcon_map_reset_reason, |
| 2638 | .map_reset_flags = falcon_map_reset_flags, |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 2639 | .reset = falcon_reset_hw, |
| 2640 | .probe_port = falcon_probe_port, |
| 2641 | .remove_port = falcon_remove_port, |
Ben Hutchings | 40641ed | 2010-12-02 13:47:45 +0000 | [diff] [blame] | 2642 | .handle_global_event = falcon_handle_global_event, |
Ben Hutchings | e42c3d8 | 2013-05-27 16:52:54 +0100 | [diff] [blame] | 2643 | .fini_dmaq = efx_farch_fini_dmaq, |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 2644 | .prepare_flush = falcon_prepare_flush, |
Ben Hutchings | d5e8cc6 | 2012-09-06 16:52:31 +0100 | [diff] [blame] | 2645 | .finish_flush = efx_port_dummy_op_void, |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 2646 | .update_stats = falcon_update_nic_stats, |
| 2647 | .start_stats = falcon_start_nic_stats, |
| 2648 | .stop_stats = falcon_stop_nic_stats, |
Ben Hutchings | 06629f0 | 2009-11-29 03:43:43 +0000 | [diff] [blame] | 2649 | .set_id_led = falcon_set_id_led, |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 2650 | .push_irq_moderation = falcon_push_irq_moderation, |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 2651 | .reconfigure_port = falcon_reconfigure_port, |
Ben Hutchings | 9dd3a13 | 2012-09-13 01:11:25 +0100 | [diff] [blame] | 2652 | .prepare_enable_fc_tx = falcon_a1_prepare_enable_fc_tx, |
Ben Hutchings | 710b208 | 2011-09-03 00:15:00 +0100 | [diff] [blame] | 2653 | .reconfigure_mac = falcon_reconfigure_xmac, |
| 2654 | .check_mac_fault = falcon_xmac_check_fault, |
Ben Hutchings | 89c758f | 2009-11-29 03:43:07 +0000 | [diff] [blame] | 2655 | .get_wol = falcon_get_wol, |
| 2656 | .set_wol = falcon_set_wol, |
| 2657 | .resume_wol = efx_port_dummy_op_void, |
Ben Hutchings | 0aa3fba | 2009-11-29 03:43:33 +0000 | [diff] [blame] | 2658 | .test_nvram = falcon_test_nvram, |
Ben Hutchings | 86094f7 | 2013-08-21 19:51:04 +0100 | [diff] [blame] | 2659 | .irq_enable_master = efx_farch_irq_enable_master, |
| 2660 | .irq_test_generate = efx_farch_irq_test_generate, |
| 2661 | .irq_disable_non_ev = efx_farch_irq_disable_master, |
| 2662 | .irq_handle_msi = efx_farch_msi_interrupt, |
| 2663 | .irq_handle_legacy = falcon_legacy_interrupt_a1, |
| 2664 | .tx_probe = efx_farch_tx_probe, |
| 2665 | .tx_init = efx_farch_tx_init, |
| 2666 | .tx_remove = efx_farch_tx_remove, |
| 2667 | .tx_write = efx_farch_tx_write, |
| 2668 | .rx_push_indir_table = efx_farch_rx_push_indir_table, |
| 2669 | .rx_probe = efx_farch_rx_probe, |
| 2670 | .rx_init = efx_farch_rx_init, |
| 2671 | .rx_remove = efx_farch_rx_remove, |
| 2672 | .rx_write = efx_farch_rx_write, |
| 2673 | .rx_defer_refill = efx_farch_rx_defer_refill, |
| 2674 | .ev_probe = efx_farch_ev_probe, |
| 2675 | .ev_init = efx_farch_ev_init, |
| 2676 | .ev_fini = efx_farch_ev_fini, |
| 2677 | .ev_remove = efx_farch_ev_remove, |
| 2678 | .ev_process = efx_farch_ev_process, |
| 2679 | .ev_read_ack = efx_farch_ev_read_ack, |
| 2680 | .ev_test_generate = efx_farch_ev_test_generate, |
Steve Hodgson | b895d73 | 2009-11-28 05:35:00 +0000 | [diff] [blame] | 2681 | |
Ben Hutchings | add7247 | 2012-11-08 01:46:53 +0000 | [diff] [blame] | 2682 | /* We don't expose the filter table on Falcon A1 as it is not |
| 2683 | * mapped into function 0, but these implementations still |
| 2684 | * work with a degenerate case of all tables set to size 0. |
| 2685 | */ |
| 2686 | .filter_table_probe = efx_farch_filter_table_probe, |
| 2687 | .filter_table_restore = efx_farch_filter_table_restore, |
| 2688 | .filter_table_remove = efx_farch_filter_table_remove, |
| 2689 | .filter_insert = efx_farch_filter_insert, |
| 2690 | .filter_remove_safe = efx_farch_filter_remove_safe, |
| 2691 | .filter_get_safe = efx_farch_filter_get_safe, |
| 2692 | .filter_clear_rx = efx_farch_filter_clear_rx, |
| 2693 | .filter_count_rx_used = efx_farch_filter_count_rx_used, |
| 2694 | .filter_get_rx_id_limit = efx_farch_filter_get_rx_id_limit, |
| 2695 | .filter_get_rx_ids = efx_farch_filter_get_rx_ids, |
| 2696 | |
Ben Hutchings | 45a3fd5 | 2012-11-28 04:38:14 +0000 | [diff] [blame] | 2697 | #ifdef CONFIG_SFC_MTD |
| 2698 | .mtd_probe = falcon_mtd_probe, |
| 2699 | .mtd_rename = falcon_mtd_rename, |
| 2700 | .mtd_read = falcon_mtd_read, |
| 2701 | .mtd_erase = falcon_mtd_erase, |
| 2702 | .mtd_write = falcon_mtd_write, |
| 2703 | .mtd_sync = falcon_mtd_sync, |
| 2704 | #endif |
| 2705 | |
Ben Hutchings | daeda63 | 2009-11-28 05:36:04 +0000 | [diff] [blame] | 2706 | .revision = EFX_REV_FALCON_A1, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2707 | .txd_ptr_tbl_base = FR_AA_TX_DESC_PTR_TBL_KER, |
| 2708 | .rxd_ptr_tbl_base = FR_AA_RX_DESC_PTR_TBL_KER, |
| 2709 | .buf_tbl_base = FR_AA_BUF_FULL_TBL_KER, |
| 2710 | .evq_ptr_tbl_base = FR_AA_EVQ_PTR_TBL_KER, |
| 2711 | .evq_rptr_tbl_base = FR_AA_EVQ_RPTR_KER, |
Ben Hutchings | 6d51d30 | 2009-10-23 08:31:07 +0000 | [diff] [blame] | 2712 | .max_dma_mask = DMA_BIT_MASK(FSF_AZ_TX_KER_BUF_ADDR_WIDTH), |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2713 | .rx_buffer_padding = 0x24, |
Ben Hutchings | 85740cdf | 2013-01-29 23:33:15 +0000 | [diff] [blame] | 2714 | .can_rx_scatter = false, |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2715 | .max_interrupt_mode = EFX_INT_MODE_MSI, |
Ben Hutchings | cc180b6 | 2011-12-08 19:51:47 +0000 | [diff] [blame] | 2716 | .timer_period_max = 1 << FRF_AB_TC_TIMER_VAL_WIDTH, |
Ben Hutchings | c383b53 | 2009-11-29 15:11:02 +0000 | [diff] [blame] | 2717 | .offload_features = NETIF_F_IP_CSUM, |
Ben Hutchings | df2cd8a | 2012-09-19 00:56:18 +0100 | [diff] [blame] | 2718 | .mcdi_max_ver = -1, |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2719 | }; |
| 2720 | |
stephen hemminger | 6c8c251 | 2011-04-14 05:50:12 +0000 | [diff] [blame] | 2721 | const struct efx_nic_type falcon_b0_nic_type = { |
Ben Hutchings | b105798 | 2012-09-19 00:56:47 +0100 | [diff] [blame] | 2722 | .mem_map_size = falcon_b0_mem_map_size, |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 2723 | .probe = falcon_probe_nic, |
| 2724 | .remove = falcon_remove_nic, |
| 2725 | .init = falcon_init_nic, |
Ben Hutchings | 28e47c4 | 2012-02-15 01:58:49 +0000 | [diff] [blame] | 2726 | .dimension_resources = falcon_dimension_resources, |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 2727 | .fini = efx_port_dummy_op_void, |
| 2728 | .monitor = falcon_monitor, |
Ben Hutchings | 0e2a9c7 | 2011-06-24 20:50:07 +0100 | [diff] [blame] | 2729 | .map_reset_reason = falcon_map_reset_reason, |
| 2730 | .map_reset_flags = falcon_map_reset_flags, |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 2731 | .reset = falcon_reset_hw, |
| 2732 | .probe_port = falcon_probe_port, |
| 2733 | .remove_port = falcon_remove_port, |
Ben Hutchings | 40641ed | 2010-12-02 13:47:45 +0000 | [diff] [blame] | 2734 | .handle_global_event = falcon_handle_global_event, |
Ben Hutchings | e42c3d8 | 2013-05-27 16:52:54 +0100 | [diff] [blame] | 2735 | .fini_dmaq = efx_farch_fini_dmaq, |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 2736 | .prepare_flush = falcon_prepare_flush, |
Ben Hutchings | d5e8cc6 | 2012-09-06 16:52:31 +0100 | [diff] [blame] | 2737 | .finish_flush = efx_port_dummy_op_void, |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 2738 | .update_stats = falcon_update_nic_stats, |
| 2739 | .start_stats = falcon_start_nic_stats, |
| 2740 | .stop_stats = falcon_stop_nic_stats, |
Ben Hutchings | 06629f0 | 2009-11-29 03:43:43 +0000 | [diff] [blame] | 2741 | .set_id_led = falcon_set_id_led, |
Ben Hutchings | ef2b90e | 2009-11-29 03:42:31 +0000 | [diff] [blame] | 2742 | .push_irq_moderation = falcon_push_irq_moderation, |
Ben Hutchings | d3245b2 | 2009-11-29 03:42:41 +0000 | [diff] [blame] | 2743 | .reconfigure_port = falcon_reconfigure_port, |
Ben Hutchings | 9dd3a13 | 2012-09-13 01:11:25 +0100 | [diff] [blame] | 2744 | .prepare_enable_fc_tx = falcon_b0_prepare_enable_fc_tx, |
Ben Hutchings | 710b208 | 2011-09-03 00:15:00 +0100 | [diff] [blame] | 2745 | .reconfigure_mac = falcon_reconfigure_xmac, |
| 2746 | .check_mac_fault = falcon_xmac_check_fault, |
Ben Hutchings | 89c758f | 2009-11-29 03:43:07 +0000 | [diff] [blame] | 2747 | .get_wol = falcon_get_wol, |
| 2748 | .set_wol = falcon_set_wol, |
| 2749 | .resume_wol = efx_port_dummy_op_void, |
Ben Hutchings | d4f2cec | 2012-07-04 03:58:33 +0100 | [diff] [blame] | 2750 | .test_chip = falcon_b0_test_chip, |
Ben Hutchings | 0aa3fba | 2009-11-29 03:43:33 +0000 | [diff] [blame] | 2751 | .test_nvram = falcon_test_nvram, |
Ben Hutchings | 86094f7 | 2013-08-21 19:51:04 +0100 | [diff] [blame] | 2752 | .irq_enable_master = efx_farch_irq_enable_master, |
| 2753 | .irq_test_generate = efx_farch_irq_test_generate, |
| 2754 | .irq_disable_non_ev = efx_farch_irq_disable_master, |
| 2755 | .irq_handle_msi = efx_farch_msi_interrupt, |
| 2756 | .irq_handle_legacy = efx_farch_legacy_interrupt, |
| 2757 | .tx_probe = efx_farch_tx_probe, |
| 2758 | .tx_init = efx_farch_tx_init, |
| 2759 | .tx_remove = efx_farch_tx_remove, |
| 2760 | .tx_write = efx_farch_tx_write, |
| 2761 | .rx_push_indir_table = efx_farch_rx_push_indir_table, |
| 2762 | .rx_probe = efx_farch_rx_probe, |
| 2763 | .rx_init = efx_farch_rx_init, |
| 2764 | .rx_remove = efx_farch_rx_remove, |
| 2765 | .rx_write = efx_farch_rx_write, |
| 2766 | .rx_defer_refill = efx_farch_rx_defer_refill, |
| 2767 | .ev_probe = efx_farch_ev_probe, |
| 2768 | .ev_init = efx_farch_ev_init, |
| 2769 | .ev_fini = efx_farch_ev_fini, |
| 2770 | .ev_remove = efx_farch_ev_remove, |
| 2771 | .ev_process = efx_farch_ev_process, |
| 2772 | .ev_read_ack = efx_farch_ev_read_ack, |
| 2773 | .ev_test_generate = efx_farch_ev_test_generate, |
Ben Hutchings | add7247 | 2012-11-08 01:46:53 +0000 | [diff] [blame] | 2774 | .filter_table_probe = efx_farch_filter_table_probe, |
| 2775 | .filter_table_restore = efx_farch_filter_table_restore, |
| 2776 | .filter_table_remove = efx_farch_filter_table_remove, |
| 2777 | .filter_update_rx_scatter = efx_farch_filter_update_rx_scatter, |
| 2778 | .filter_insert = efx_farch_filter_insert, |
| 2779 | .filter_remove_safe = efx_farch_filter_remove_safe, |
| 2780 | .filter_get_safe = efx_farch_filter_get_safe, |
| 2781 | .filter_clear_rx = efx_farch_filter_clear_rx, |
| 2782 | .filter_count_rx_used = efx_farch_filter_count_rx_used, |
| 2783 | .filter_get_rx_id_limit = efx_farch_filter_get_rx_id_limit, |
| 2784 | .filter_get_rx_ids = efx_farch_filter_get_rx_ids, |
| 2785 | #ifdef CONFIG_RFS_ACCEL |
| 2786 | .filter_rfs_insert = efx_farch_filter_rfs_insert, |
| 2787 | .filter_rfs_expire_one = efx_farch_filter_rfs_expire_one, |
| 2788 | #endif |
Ben Hutchings | 45a3fd5 | 2012-11-28 04:38:14 +0000 | [diff] [blame] | 2789 | #ifdef CONFIG_SFC_MTD |
| 2790 | .mtd_probe = falcon_mtd_probe, |
| 2791 | .mtd_rename = falcon_mtd_rename, |
| 2792 | .mtd_read = falcon_mtd_read, |
| 2793 | .mtd_erase = falcon_mtd_erase, |
| 2794 | .mtd_write = falcon_mtd_write, |
| 2795 | .mtd_sync = falcon_mtd_sync, |
| 2796 | #endif |
Steve Hodgson | b895d73 | 2009-11-28 05:35:00 +0000 | [diff] [blame] | 2797 | |
Ben Hutchings | daeda63 | 2009-11-28 05:36:04 +0000 | [diff] [blame] | 2798 | .revision = EFX_REV_FALCON_B0, |
Ben Hutchings | 3e6c453 | 2009-10-23 08:30:36 +0000 | [diff] [blame] | 2799 | .txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL, |
| 2800 | .rxd_ptr_tbl_base = FR_BZ_RX_DESC_PTR_TBL, |
| 2801 | .buf_tbl_base = FR_BZ_BUF_FULL_TBL, |
| 2802 | .evq_ptr_tbl_base = FR_BZ_EVQ_PTR_TBL, |
| 2803 | .evq_rptr_tbl_base = FR_BZ_EVQ_RPTR, |
Ben Hutchings | 6d51d30 | 2009-10-23 08:31:07 +0000 | [diff] [blame] | 2804 | .max_dma_mask = DMA_BIT_MASK(FSF_AZ_TX_KER_BUF_ADDR_WIDTH), |
Ben Hutchings | 39c9cf0 | 2010-06-23 11:31:28 +0000 | [diff] [blame] | 2805 | .rx_buffer_hash_size = 0x10, |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2806 | .rx_buffer_padding = 0, |
Ben Hutchings | 85740cdf | 2013-01-29 23:33:15 +0000 | [diff] [blame] | 2807 | .can_rx_scatter = true, |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2808 | .max_interrupt_mode = EFX_INT_MODE_MSIX, |
Ben Hutchings | cc180b6 | 2011-12-08 19:51:47 +0000 | [diff] [blame] | 2809 | .timer_period_max = 1 << FRF_AB_TC_TIMER_VAL_WIDTH, |
Ben Hutchings | b4187e4 | 2010-09-20 08:43:42 +0000 | [diff] [blame] | 2810 | .offload_features = NETIF_F_IP_CSUM | NETIF_F_RXHASH | NETIF_F_NTUPLE, |
Ben Hutchings | df2cd8a | 2012-09-19 00:56:18 +0100 | [diff] [blame] | 2811 | .mcdi_max_ver = -1, |
Ben Hutchings | add7247 | 2012-11-08 01:46:53 +0000 | [diff] [blame] | 2812 | .max_rx_ip_filters = FR_BZ_RX_FILTER_TBL0_ROWS, |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 2813 | }; |
| 2814 | |