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