Lines Matching +full:sfc +full:- +full:no +full:- +full:dma

1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright 2005-2006 Fen Systems Ltd.
5 * Copyright 2006-2013 Solarflare Communications Inc.
134 (*(u32 *)((efx)->stats_buffer.addr + XgDmaDone_offset))
139 /* 48-bit stats are zero-padded to 64 on DMA */ \
199 [0 ... BITS_TO_LONGS(FALCON_STAT_COUNT) - 1] = ~0UL,
216 #define SPI_STATUS_WPEN 0x80 /* Write-protect pin enabled */
225 * Non-volatile memory layout
231 * 0-0x400 chip and board config (see struct falcon_nvconfig)
232 * 0x400-0x8000 unused (or may contain VPD if EEPROM not present)
233 * 0x8000-end boot code (mapped to PCI expansion ROM)
236 * 0-0x400 chip and board config
238 * 0x800-0x1800 boot config
306 * 8 KB, 16-bit address, 32 B write block */
311 * 128 KB, 24-bit address, 32 KB erase block, 256 B write block */
320 * I2C bus - this is a bit-bashing interface using GPIO pins
377 struct ef4_nic *efx = channel->efx; in falcon_push_irq_moderation()
380 if (channel->irq_moderation_us) { in falcon_push_irq_moderation()
383 ticks = ef4_usecs_to_ticks(efx, channel->irq_moderation_us); in falcon_push_irq_moderation()
388 ticks - 1); in falcon_push_irq_moderation()
397 channel->channel); in falcon_push_irq_moderation()
407 * (~1ms without back-pressure), then to drain the remainder of the in falcon_prepare_flush()
416 * Due to SFC bug 3706 (silicon revision <=A1) reads can be duplicated in the
434 ef4_oword_t *int_ker = efx->irq_status.addr; in falcon_legacy_interrupt_a1()
442 netif_vdbg(efx, intr, efx->net_dev, in falcon_legacy_interrupt_a1()
447 efx->last_irq_cpu = raw_smp_processor_id(); in falcon_legacy_interrupt_a1()
448 netif_vdbg(efx, intr, efx->net_dev, in falcon_legacy_interrupt_a1()
452 if (!likely(READ_ONCE(efx->irq_soft_enabled))) in falcon_legacy_interrupt_a1()
488 return -ENOSYS; in dummy_rx_push_rss_config()
498 memcpy(&temp, efx->rx_hash_key, sizeof(temp)); in falcon_b0_rx_push_rss_config()
501 memcpy(efx->rx_indir_table, rx_indir_table, in falcon_b0_rx_push_rss_config()
502 sizeof(efx->rx_indir_table)); in falcon_b0_rx_push_rss_config()
520 return EF4_OWORD_FIELD(reg, FRF_AB_EE_SPI_HCMD_CMD_EN) ? -EBUSY : 0; in falcon_spi_poll()
543 netif_err(efx, hw, efx->net_dev, in falcon_spi_wait()
545 return -ETIMEDOUT; in falcon_spi_wait()
563 return -EINVAL; in falcon_spi_cmd()
585 FRF_AB_EE_SPI_HCMD_SF_SEL, spi->device_id, in falcon_spi_cmd()
590 (addressed ? spi->addr_len : 0), in falcon_spi_cmd()
612 return command | (((address >> 8) & spi->munge_address) << 3); in falcon_spi_munge_command()
624 block_len = min(len - pos, FALCON_SPI_MAX_LEN); in falcon_spi_read()
636 rc = -EINTR; in falcon_spi_read()
661 (spi->block_size - (start & (spi->block_size - 1)))); in falcon_spi_write_limit()
673 rc = falcon_spi_cmd(efx, spi, SPI_RDSR, -1, NULL, in falcon_spi_wait_write()
680 netif_err(efx, hw, efx->net_dev, in falcon_spi_wait_write()
683 spi->device_id, status); in falcon_spi_wait_write()
684 return -ETIMEDOUT; in falcon_spi_wait_write()
700 rc = falcon_spi_cmd(efx, spi, SPI_WREN, -1, NULL, NULL, 0); in falcon_spi_write()
704 block_len = min(len - pos, in falcon_spi_write()
720 rc = -EIO; in falcon_spi_write()
729 rc = -EINTR; in falcon_spi_write()
742 const struct falcon_spi_device *spi = part->spi; in falcon_spi_slow_wait()
743 struct ef4_nic *efx = part->common.mtd.priv; in falcon_spi_slow_wait()
752 rc = falcon_spi_cmd(efx, spi, SPI_RDSR, -1, NULL, in falcon_spi_slow_wait()
759 return -EINTR; in falcon_spi_slow_wait()
762 part->common.name, part->common.dev_type_name); in falcon_spi_slow_wait()
763 return -ETIMEDOUT; in falcon_spi_slow_wait()
774 rc = falcon_spi_cmd(efx, spi, SPI_RDSR, -1, NULL, in falcon_spi_unlock()
782 rc = falcon_spi_cmd(efx, spi, SPI_WREN, -1, NULL, NULL, 0); in falcon_spi_unlock()
785 rc = falcon_spi_cmd(efx, spi, SPI_SST_EWSR, -1, NULL, NULL, 0); in falcon_spi_unlock()
790 rc = falcon_spi_cmd(efx, spi, SPI_WRSR, -1, &status, in falcon_spi_unlock()
806 const struct falcon_spi_device *spi = part->spi; in falcon_spi_erase()
807 struct ef4_nic *efx = part->common.mtd.priv; in falcon_spi_erase()
813 if (len != spi->erase_size) in falcon_spi_erase()
814 return -EINVAL; in falcon_spi_erase()
816 if (spi->erase_command == 0) in falcon_spi_erase()
817 return -EOPNOTSUPP; in falcon_spi_erase()
822 rc = falcon_spi_cmd(efx, spi, SPI_WREN, -1, NULL, NULL, 0); in falcon_spi_erase()
825 rc = falcon_spi_cmd(efx, spi, spi->erase_command, start, NULL, in falcon_spi_erase()
834 block_len = min(len - pos, sizeof(buffer)); in falcon_spi_erase()
840 return -EIO; in falcon_spi_erase()
845 return -EINTR; in falcon_spi_erase()
853 struct ef4_nic *efx = part->mtd.priv; in falcon_mtd_rename()
855 snprintf(part->name, sizeof(part->name), "%s %s", in falcon_mtd_rename()
856 efx->name, part->type_name); in falcon_mtd_rename()
863 struct ef4_nic *efx = mtd->priv; in falcon_mtd_read()
864 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_mtd_read()
867 rc = mutex_lock_interruptible(&nic_data->spi_lock); in falcon_mtd_read()
870 rc = falcon_spi_read(efx, part->spi, part->offset + start, in falcon_mtd_read()
872 mutex_unlock(&nic_data->spi_lock); in falcon_mtd_read()
879 struct ef4_nic *efx = mtd->priv; in falcon_mtd_erase()
880 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_mtd_erase()
883 rc = mutex_lock_interruptible(&nic_data->spi_lock); in falcon_mtd_erase()
886 rc = falcon_spi_erase(part, part->offset + start, len); in falcon_mtd_erase()
887 mutex_unlock(&nic_data->spi_lock); in falcon_mtd_erase()
895 struct ef4_nic *efx = mtd->priv; in falcon_mtd_write()
896 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_mtd_write()
899 rc = mutex_lock_interruptible(&nic_data->spi_lock); in falcon_mtd_write()
902 rc = falcon_spi_write(efx, part->spi, part->offset + start, in falcon_mtd_write()
904 mutex_unlock(&nic_data->spi_lock); in falcon_mtd_write()
911 struct ef4_nic *efx = mtd->priv; in falcon_mtd_sync()
912 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_mtd_sync()
915 mutex_lock(&nic_data->spi_lock); in falcon_mtd_sync()
917 mutex_unlock(&nic_data->spi_lock); in falcon_mtd_sync()
923 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_mtd_probe()
927 int rc = -ENODEV; in falcon_mtd_probe()
934 return -ENOMEM; in falcon_mtd_probe()
937 spi = &nic_data->spi_flash; in falcon_mtd_probe()
938 if (falcon_spi_present(spi) && spi->size > FALCON_FLASH_BOOTCODE_START) { in falcon_mtd_probe()
945 parts[n_parts].common.mtd.size = spi->size - FALCON_FLASH_BOOTCODE_START; in falcon_mtd_probe()
946 parts[n_parts].common.mtd.erasesize = spi->erase_size; in falcon_mtd_probe()
950 spi = &nic_data->spi_eeprom; in falcon_mtd_probe()
951 if (falcon_spi_present(spi) && spi->size > FALCON_EEPROM_BOOTCONFIG_START) { in falcon_mtd_probe()
959 min(spi->size, FALCON_EEPROM_BOOTCONFIG_END) - in falcon_mtd_probe()
961 parts[n_parts].common.mtd.erasesize = spi->erase_size; in falcon_mtd_probe()
985 /* Move the XAUI into low power, unless there is no PHY, in in falcon_setup_xaui()
987 if (efx->phy_type == PHY_TYPE_NONE) in falcon_setup_xaui()
1015 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_reset_xaui()
1020 WARN_ON(nic_data->stats_disable_count == 0); in falcon_reset_xaui()
1036 netif_err(efx, hw, efx->net_dev, in falcon_reset_xaui()
1038 return -ETIMEDOUT; in falcon_reset_xaui()
1043 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_ack_status_intr()
1050 if (!efx->link_state.up) in falcon_ack_status_intr()
1055 if (nic_data->xmac_poll_required) in falcon_ack_status_intr()
1092 return (efx->loopback_mode == LOOPBACK_XGMII || in falcon_xmac_link_ok()
1094 (!(efx->mdio.mmds & (1 << MDIO_MMD_PHYXS)) || in falcon_xmac_link_ok()
1103 bool rx_fc = !!(efx->link_state.fc & EF4_FC_RX); in falcon_reconfigure_xmac_core()
1104 bool tx_fc = !!(efx->link_state.fc & EF4_FC_TX); in falcon_reconfigure_xmac_core()
1106 /* Configure MAC - cut-thru mode is hard wired on */ in falcon_reconfigure_xmac_core()
1128 FRF_AB_XM_ACPT_ALL_UCAST, !efx->unicast_filter, in falcon_reconfigure_xmac_core()
1133 max_frame_len = EF4_MAX_FRAME_LEN(efx->net_dev->mtu); in falcon_reconfigure_xmac_core()
1147 memcpy(&reg, &efx->net_dev->dev_addr[0], 4); in falcon_reconfigure_xmac_core()
1149 memcpy(&reg, &efx->net_dev->dev_addr[4], 2); in falcon_reconfigure_xmac_core()
1156 bool xgxs_loopback = (efx->loopback_mode == LOOPBACK_XGXS); in falcon_reconfigure_xgxs_core()
1157 bool xaui_loopback = (efx->loopback_mode == LOOPBACK_XAUI); in falcon_reconfigure_xgxs_core()
1158 bool xgmii_loopback = (efx->loopback_mode == LOOPBACK_XGMII); in falcon_reconfigure_xgxs_core()
1193 /* Try to bring up the Falcon side of the Falcon-Phy XAUI link */
1199 ef4_phy_mode_disabled(efx->phy_mode)) in falcon_xmac_link_ok_retry()
1206 netif_dbg(efx, hw, efx->net_dev, "bashing xaui\n"); in falcon_xmac_link_ok_retry()
1211 --tries; in falcon_xmac_link_ok_retry()
1226 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_reconfigure_xmac()
1235 nic_data->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 5); in falcon_reconfigure_xmac()
1243 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_poll_xmac()
1246 if (!efx->link_state.up || !nic_data->xmac_poll_required) in falcon_poll_xmac()
1249 nic_data->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 1); in falcon_poll_xmac()
1262 union ef4_multicast_hash *mc_hash = &efx->multicast_hash; in falcon_push_multicast_hash()
1264 WARN_ON(!mutex_is_locked(&efx->mac_lock)); in falcon_push_multicast_hash()
1266 ef4_writeo(efx, &mc_hash->oword[0], FR_AB_MAC_MC_HASH_REG0); in falcon_push_multicast_hash()
1267 ef4_writeo(efx, &mc_hash->oword[1], FR_AB_MAC_MC_HASH_REG1); in falcon_push_multicast_hash()
1272 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_reset_macs()
1291 netif_err(efx, hw, efx->net_dev, in falcon_reset_macs()
1296 WARN_ON(nic_data->stats_disable_count == 0); in falcon_reset_macs()
1314 netif_dbg(efx, hw, efx->net_dev, in falcon_reset_macs()
1320 netif_err(efx, hw, efx->net_dev, "MAC reset failed\n"); in falcon_reset_macs()
1328 * are re-enabled by the caller */ in falcon_reset_macs()
1339 (efx->loopback_mode != LOOPBACK_NONE)) in falcon_drain_tx_fifo()
1343 /* There is no point in draining more than once */ in falcon_drain_tx_fifo()
1357 /* Isolate the MAC -> RX */ in falcon_deconfigure_mac_wrapper()
1362 /* Isolate TX -> MAC */ in falcon_deconfigure_mac_wrapper()
1368 struct ef4_link_state *link_state = &efx->link_state; in falcon_reconfigure_mac_wrapper()
1372 isolate = !!READ_ONCE(efx->reset_pending); in falcon_reconfigure_mac_wrapper()
1374 switch (link_state->speed) { in falcon_reconfigure_mac_wrapper()
1388 FRF_AB_MAC_UC_PROM, !efx->unicast_filter, in falcon_reconfigure_mac_wrapper()
1395 !link_state->up || isolate); in falcon_reconfigure_mac_wrapper()
1407 /* Unisolate the MAC -> RX */ in falcon_reconfigure_mac_wrapper()
1415 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_stats_request()
1418 WARN_ON(nic_data->stats_pending); in falcon_stats_request()
1419 WARN_ON(nic_data->stats_disable_count); in falcon_stats_request()
1422 nic_data->stats_pending = true; in falcon_stats_request()
1425 /* Initiate DMA transfer of stats */ in falcon_stats_request()
1429 efx->stats_buffer.dma_addr); in falcon_stats_request()
1432 mod_timer(&nic_data->stats_timer, round_jiffies_up(jiffies + HZ / 2)); in falcon_stats_request()
1437 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_stats_complete()
1439 if (!nic_data->stats_pending) in falcon_stats_complete()
1442 nic_data->stats_pending = false; in falcon_stats_complete()
1446 falcon_stat_mask, nic_data->stats, in falcon_stats_complete()
1447 efx->stats_buffer.addr, true); in falcon_stats_complete()
1449 netif_err(efx, hw, efx->net_dev, in falcon_stats_complete()
1458 struct ef4_nic *efx = nic_data->efx; in falcon_stats_timer_func()
1460 spin_lock(&efx->stats_lock); in falcon_stats_timer_func()
1463 if (nic_data->stats_disable_count == 0) in falcon_stats_timer_func()
1466 spin_unlock(&efx->stats_lock); in falcon_stats_timer_func()
1471 struct ef4_link_state old_state = efx->link_state; in falcon_loopback_link_poll()
1473 WARN_ON(!mutex_is_locked(&efx->mac_lock)); in falcon_loopback_link_poll()
1476 efx->link_state.fd = true; in falcon_loopback_link_poll()
1477 efx->link_state.fc = efx->wanted_fc; in falcon_loopback_link_poll()
1478 efx->link_state.up = true; in falcon_loopback_link_poll()
1479 efx->link_state.speed = 10000; in falcon_loopback_link_poll()
1481 return !ef4_link_state_equal(&efx->link_state, &old_state); in falcon_loopback_link_poll()
1497 efx->phy_op->poll(efx); in falcon_reconfigure_port()
1504 efx->phy_op->reconfigure(efx); in falcon_reconfigure_port()
1510 /* Synchronise efx->link_state with the kernel */ in falcon_reconfigure_port()
1551 /* wait up to 50ms - taken max from datasheet */ in falcon_gmii_wait()
1557 netif_err(efx, hw, efx->net_dev, in falcon_gmii_wait()
1561 return -EIO; in falcon_gmii_wait()
1567 netif_err(efx, hw, efx->net_dev, "timed out waiting for GMII\n"); in falcon_gmii_wait()
1568 return -ETIMEDOUT; in falcon_gmii_wait()
1576 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_mdio_write()
1580 netif_vdbg(efx, hw, efx->net_dev, in falcon_mdio_write()
1584 mutex_lock(&nic_data->mdio_lock); in falcon_mdio_write()
1620 mutex_unlock(&nic_data->mdio_lock); in falcon_mdio_write()
1629 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_mdio_read()
1633 mutex_lock(&nic_data->mdio_lock); in falcon_mdio_read()
1656 netif_vdbg(efx, hw, efx->net_dev, in falcon_mdio_read()
1666 netif_dbg(efx, hw, efx->net_dev, in falcon_mdio_read()
1672 mutex_unlock(&nic_data->mdio_lock); in falcon_mdio_read()
1679 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_probe_port()
1682 switch (efx->phy_type) { in falcon_probe_port()
1684 efx->phy_op = &falcon_sfx7101_phy_ops; in falcon_probe_port()
1688 efx->phy_op = &falcon_qt202x_phy_ops; in falcon_probe_port()
1691 efx->phy_op = &falcon_txc_phy_ops; in falcon_probe_port()
1694 netif_err(efx, probe, efx->net_dev, "Unknown PHY type %d\n", in falcon_probe_port()
1695 efx->phy_type); in falcon_probe_port()
1696 return -ENODEV; in falcon_probe_port()
1700 mutex_init(&nic_data->mdio_lock); in falcon_probe_port()
1701 efx->mdio.mdio_read = falcon_mdio_read; in falcon_probe_port()
1702 efx->mdio.mdio_write = falcon_mdio_write; in falcon_probe_port()
1703 rc = efx->phy_op->probe(efx); in falcon_probe_port()
1708 efx->link_state.speed = 10000; in falcon_probe_port()
1709 efx->link_state.fd = true; in falcon_probe_port()
1713 efx->wanted_fc = EF4_FC_RX | EF4_FC_TX; in falcon_probe_port()
1715 efx->wanted_fc = EF4_FC_RX; in falcon_probe_port()
1716 if (efx->mdio.mmds & MDIO_DEVS_AN) in falcon_probe_port()
1717 efx->wanted_fc |= EF4_FC_AUTO; in falcon_probe_port()
1720 rc = ef4_nic_alloc_buffer(efx, &efx->stats_buffer, in falcon_probe_port()
1724 netif_dbg(efx, probe, efx->net_dev, in falcon_probe_port()
1726 (u64)efx->stats_buffer.dma_addr, in falcon_probe_port()
1727 efx->stats_buffer.addr, in falcon_probe_port()
1728 (u64)virt_to_phys(efx->stats_buffer.addr)); in falcon_probe_port()
1735 efx->phy_op->remove(efx); in falcon_remove_port()
1736 ef4_nic_free_buffer(efx, &efx->stats_buffer); in falcon_remove_port()
1743 struct ef4_nic *efx = channel->efx; in falcon_handle_global_event()
1744 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_handle_global_event()
1754 nic_data->xmac_poll_required = true; in falcon_handle_global_event()
1761 netif_err(efx, rx_err, efx->net_dev, in falcon_handle_global_event()
1763 channel->channel); in falcon_handle_global_event()
1765 atomic_inc(&efx->rx_reset); in falcon_handle_global_event()
1783 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_read_nvram()
1791 if (falcon_spi_present(&nic_data->spi_flash)) in falcon_read_nvram()
1792 spi = &nic_data->spi_flash; in falcon_read_nvram()
1793 else if (falcon_spi_present(&nic_data->spi_eeprom)) in falcon_read_nvram()
1794 spi = &nic_data->spi_eeprom; in falcon_read_nvram()
1796 return -EINVAL; in falcon_read_nvram()
1800 return -ENOMEM; in falcon_read_nvram()
1803 mutex_lock(&nic_data->spi_lock); in falcon_read_nvram()
1805 mutex_unlock(&nic_data->spi_lock); in falcon_read_nvram()
1807 netif_err(efx, hw, efx->net_dev, "Failed to read %s\n", in falcon_read_nvram()
1808 falcon_spi_present(&nic_data->spi_flash) ? in falcon_read_nvram()
1810 rc = -EIO; in falcon_read_nvram()
1814 magic_num = le16_to_cpu(nvconfig->board_magic_num); in falcon_read_nvram()
1815 struct_ver = le16_to_cpu(nvconfig->board_struct_ver); in falcon_read_nvram()
1817 rc = -EINVAL; in falcon_read_nvram()
1819 netif_err(efx, hw, efx->net_dev, in falcon_read_nvram()
1824 netif_err(efx, hw, efx->net_dev, in falcon_read_nvram()
1828 word = &nvconfig->board_magic_num; in falcon_read_nvram()
1838 netif_err(efx, hw, efx->net_dev, in falcon_read_nvram()
1902 mutex_lock(&efx->mac_lock); in falcon_b0_test_chip()
1903 if (efx->loopback_modes) { in falcon_b0_test_chip()
1906 if (efx->loopback_modes & (1 << LOOPBACK_XGMII)) in falcon_b0_test_chip()
1907 efx->loopback_mode = LOOPBACK_XGMII; in falcon_b0_test_chip()
1909 efx->loopback_mode = __ffs(efx->loopback_modes); in falcon_b0_test_chip()
1912 mutex_unlock(&efx->mac_lock); in falcon_b0_test_chip()
1916 tests->registers = in falcon_b0_test_chip()
1919 ? -1 : 1; in falcon_b0_test_chip()
1972 return -EINVAL; in falcon_map_reset_flags()
1979 struct falcon_nic_data *nic_data = efx->nic_data; in __falcon_reset_hw()
1983 netif_dbg(efx, hw, efx->net_dev, "performing %s hardware reset\n", in __falcon_reset_hw()
1988 rc = pci_save_state(efx->pci_dev); in __falcon_reset_hw()
1990 netif_err(efx, drv, efx->net_dev, in __falcon_reset_hw()
1996 rc = pci_save_state(nic_data->pci_dev2); in __falcon_reset_hw()
1998 netif_err(efx, drv, efx->net_dev, in __falcon_reset_hw()
2026 netif_dbg(efx, hw, efx->net_dev, "waiting for hardware reset\n"); in __falcon_reset_hw()
2032 pci_restore_state(nic_data->pci_dev2); in __falcon_reset_hw()
2033 pci_restore_state(efx->pci_dev); in __falcon_reset_hw()
2034 netif_dbg(efx, drv, efx->net_dev, in __falcon_reset_hw()
2041 rc = -ETIMEDOUT; in __falcon_reset_hw()
2042 netif_err(efx, hw, efx->net_dev, in __falcon_reset_hw()
2046 netif_dbg(efx, hw, efx->net_dev, "hardware reset complete\n"); in __falcon_reset_hw()
2052 pci_restore_state(efx->pci_dev); in __falcon_reset_hw()
2060 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_reset_hw()
2063 mutex_lock(&nic_data->spi_lock); in falcon_reset_hw()
2065 mutex_unlock(&nic_data->spi_lock); in falcon_reset_hw()
2075 BUG_ON(!mutex_is_locked(&efx->mac_lock)); in falcon_monitor()
2077 rc = falcon_board(efx)->type->monitor(efx); in falcon_monitor()
2079 netif_err(efx, hw, efx->net_dev, in falcon_monitor()
2081 (rc == -ERANGE) ? "reported fault" : "failed"); in falcon_monitor()
2082 efx->phy_mode |= PHY_MODE_LOW_POWER; in falcon_monitor()
2090 link_changed = efx->phy_op->poll(efx); in falcon_monitor()
2131 netif_dbg(efx, hw, efx->net_dev, in falcon_reset_sram()
2140 netif_dbg(efx, hw, efx->net_dev, in falcon_reset_sram()
2147 netif_err(efx, hw, efx->net_dev, "timed out waiting for SRAM reset\n"); in falcon_reset_sram()
2148 return -ETIMEDOUT; in falcon_reset_sram()
2156 spi_device->device_id = device_id; in falcon_spi_device_init()
2157 spi_device->size = in falcon_spi_device_init()
2159 spi_device->addr_len = in falcon_spi_device_init()
2161 spi_device->munge_address = (spi_device->size == 1 << 9 && in falcon_spi_device_init()
2162 spi_device->addr_len == 1); in falcon_spi_device_init()
2163 spi_device->erase_command = in falcon_spi_device_init()
2165 spi_device->erase_size = in falcon_spi_device_init()
2168 spi_device->block_size = in falcon_spi_device_init()
2172 spi_device->size = 0; in falcon_spi_device_init()
2176 /* Extract non-volatile configuration */
2179 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_probe_nvconfig()
2185 return -ENOMEM; in falcon_probe_nvconfig()
2191 efx->phy_type = nvconfig->board_v2.port0_phy_type; in falcon_probe_nvconfig()
2192 efx->mdio.prtad = nvconfig->board_v2.port0_phy_addr; in falcon_probe_nvconfig()
2194 if (le16_to_cpu(nvconfig->board_struct_ver) >= 3) { in falcon_probe_nvconfig()
2196 efx, &nic_data->spi_flash, FFE_AB_SPI_DEVICE_FLASH, in falcon_probe_nvconfig()
2197 le32_to_cpu(nvconfig->board_v3 in falcon_probe_nvconfig()
2200 efx, &nic_data->spi_eeprom, FFE_AB_SPI_DEVICE_EEPROM, in falcon_probe_nvconfig()
2201 le32_to_cpu(nvconfig->board_v3 in falcon_probe_nvconfig()
2206 ether_addr_copy(efx->net_dev->perm_addr, nvconfig->mac_address[0]); in falcon_probe_nvconfig()
2208 netif_dbg(efx, probe, efx->net_dev, "PHY is %d phy_id %d\n", in falcon_probe_nvconfig()
2209 efx->phy_type, efx->mdio.prtad); in falcon_probe_nvconfig()
2212 le16_to_cpu(nvconfig->board_v2.board_revision)); in falcon_probe_nvconfig()
2220 efx->rx_dc_base = 0x20000; in falcon_dimension_resources()
2221 efx->tx_dc_base = 0x26000; in falcon_dimension_resources()
2228 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_probe_spi_devices()
2239 netif_dbg(efx, probe, efx->net_dev, "Booted from %s\n", in falcon_probe_spi_devices()
2245 boot_dev = -1; in falcon_probe_spi_devices()
2246 netif_dbg(efx, probe, efx->net_dev, in falcon_probe_spi_devices()
2257 mutex_init(&nic_data->spi_lock); in falcon_probe_spi_devices()
2260 falcon_spi_device_init(efx, &nic_data->spi_flash, in falcon_probe_spi_devices()
2264 falcon_spi_device_init(efx, &nic_data->spi_eeprom, in falcon_probe_spi_devices()
2277 * The PCI core takes care of mapping the MSI-X tables. in falcon_b0_mem_map_size()
2289 efx->primary = efx; /* only one usable function per controller */ in falcon_probe_nic()
2294 return -ENOMEM; in falcon_probe_nic()
2295 efx->nic_data = nic_data; in falcon_probe_nic()
2296 nic_data->efx = efx; in falcon_probe_nic()
2298 rc = -ENODEV; in falcon_probe_nic()
2301 netif_err(efx, probe, efx->net_dev, in falcon_probe_nic()
2309 u8 pci_rev = efx->pci_dev->revision; in falcon_probe_nic()
2312 netif_err(efx, probe, efx->net_dev, in falcon_probe_nic()
2318 netif_err(efx, probe, efx->net_dev, in falcon_probe_nic()
2323 netif_err(efx, probe, efx->net_dev, in falcon_probe_nic()
2324 "Falcon rev A1 PCI-X not supported\n"); in falcon_probe_nic()
2328 dev = pci_dev_get(efx->pci_dev); in falcon_probe_nic()
2332 if (dev->bus == efx->pci_dev->bus && in falcon_probe_nic()
2333 dev->devfn == efx->pci_dev->devfn + 1) { in falcon_probe_nic()
2334 nic_data->pci_dev2 = dev; in falcon_probe_nic()
2338 if (!nic_data->pci_dev2) { in falcon_probe_nic()
2339 netif_err(efx, probe, efx->net_dev, in falcon_probe_nic()
2341 rc = -ENODEV; in falcon_probe_nic()
2349 netif_err(efx, probe, efx->net_dev, "failed to reset NIC\n"); in falcon_probe_nic()
2354 rc = ef4_nic_alloc_buffer(efx, &efx->irq_status, sizeof(ef4_oword_t), in falcon_probe_nic()
2358 BUG_ON(efx->irq_status.dma_addr & 0x0f); in falcon_probe_nic()
2360 netif_dbg(efx, probe, efx->net_dev, in falcon_probe_nic()
2362 (u64)efx->irq_status.dma_addr, in falcon_probe_nic()
2363 efx->irq_status.addr, in falcon_probe_nic()
2364 (u64)virt_to_phys(efx->irq_status.addr)); in falcon_probe_nic()
2368 /* Read in the non-volatile configuration */ in falcon_probe_nic()
2371 if (rc == -EINVAL) in falcon_probe_nic()
2372 netif_err(efx, probe, efx->net_dev, "NVRAM is invalid\n"); in falcon_probe_nic()
2376 efx->max_channels = (ef4_nic_rev(efx) <= EF4_REV_FALCON_A1 ? 4 : in falcon_probe_nic()
2378 efx->max_tx_channels = efx->max_channels; in falcon_probe_nic()
2379 efx->timer_quantum_ns = 4968; /* 621 cycles */ in falcon_probe_nic()
2380 efx->timer_max_ns = efx->type->timer_period_max * in falcon_probe_nic()
2381 efx->timer_quantum_ns; in falcon_probe_nic()
2385 board->i2c_adap.owner = THIS_MODULE; in falcon_probe_nic()
2386 board->i2c_data = falcon_i2c_bit_operations; in falcon_probe_nic()
2387 board->i2c_data.data = efx; in falcon_probe_nic()
2388 board->i2c_adap.algo_data = &board->i2c_data; in falcon_probe_nic()
2389 board->i2c_adap.dev.parent = &efx->pci_dev->dev; in falcon_probe_nic()
2390 strscpy(board->i2c_adap.name, "SFC4000 GPIO", in falcon_probe_nic()
2391 sizeof(board->i2c_adap.name)); in falcon_probe_nic()
2392 rc = i2c_bit_add_bus(&board->i2c_adap); in falcon_probe_nic()
2396 rc = falcon_board(efx)->type->init(efx); in falcon_probe_nic()
2398 netif_err(efx, probe, efx->net_dev, in falcon_probe_nic()
2403 nic_data->stats_disable_count = 1; in falcon_probe_nic()
2404 timer_setup(&nic_data->stats_timer, falcon_stats_timer_func, 0); in falcon_probe_nic()
2409 i2c_del_adapter(&board->i2c_adap); in falcon_probe_nic()
2410 memset(&board->i2c_adap, 0, sizeof(board->i2c_adap)); in falcon_probe_nic()
2412 ef4_nic_free_buffer(efx, &efx->irq_status); in falcon_probe_nic()
2415 if (nic_data->pci_dev2) { in falcon_probe_nic()
2416 pci_dev_put(nic_data->pci_dev2); in falcon_probe_nic()
2417 nic_data->pci_dev2 = NULL; in falcon_probe_nic()
2421 kfree(efx->nic_data); in falcon_probe_nic()
2434 /* Data FIFO size is 5.5K. The RX DMA engine only in falcon_init_rx_cfg()
2435 * supports scattering for user-mode queues, but will in falcon_init_rx_cfg()
2436 * split DMA writes at intervals of RX_USR_BUF_SIZE in falcon_init_rx_cfg()
2437 * (32-byte units) even for kernel-mode queues. We in falcon_init_rx_cfg()
2472 /* This call performs hardware-specific global initialisation, such as
2481 /* Use on-chip SRAM */ in falcon_init_nic()
2529 falcon_b0_rx_push_rss_config(efx, false, efx->rx_indir_table); in falcon_init_nic()
2543 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_remove_nic()
2546 board->type->fini(efx); in falcon_remove_nic()
2549 i2c_del_adapter(&board->i2c_adap); in falcon_remove_nic()
2550 memset(&board->i2c_adap, 0, sizeof(board->i2c_adap)); in falcon_remove_nic()
2552 ef4_nic_free_buffer(efx, &efx->irq_status); in falcon_remove_nic()
2557 if (nic_data->pci_dev2) { in falcon_remove_nic()
2558 pci_dev_put(nic_data->pci_dev2); in falcon_remove_nic()
2559 nic_data->pci_dev2 = NULL; in falcon_remove_nic()
2563 kfree(efx->nic_data); in falcon_remove_nic()
2564 efx->nic_data = NULL; in falcon_remove_nic()
2576 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_update_nic_stats()
2577 u64 *stats = nic_data->stats; in falcon_update_nic_stats()
2580 if (!nic_data->stats_disable_count) { in falcon_update_nic_stats()
2585 if (nic_data->stats_pending && in falcon_update_nic_stats()
2587 nic_data->stats_pending = false; in falcon_update_nic_stats()
2592 stats, efx->stats_buffer.addr, true); in falcon_update_nic_stats()
2597 stats[FALCON_STAT_rx_bytes] - in falcon_update_nic_stats()
2598 stats[FALCON_STAT_rx_good_bytes] - in falcon_update_nic_stats()
2607 core_stats->rx_packets = stats[FALCON_STAT_rx_packets]; in falcon_update_nic_stats()
2608 core_stats->tx_packets = stats[FALCON_STAT_tx_packets]; in falcon_update_nic_stats()
2609 core_stats->rx_bytes = stats[FALCON_STAT_rx_bytes]; in falcon_update_nic_stats()
2610 core_stats->tx_bytes = stats[FALCON_STAT_tx_bytes]; in falcon_update_nic_stats()
2611 core_stats->rx_dropped = stats[FALCON_STAT_rx_nodesc_drop_cnt] + in falcon_update_nic_stats()
2614 core_stats->multicast = stats[FALCON_STAT_rx_multicast]; in falcon_update_nic_stats()
2615 core_stats->rx_length_errors = in falcon_update_nic_stats()
2618 core_stats->rx_crc_errors = stats[FALCON_STAT_rx_bad]; in falcon_update_nic_stats()
2619 core_stats->rx_frame_errors = stats[FALCON_STAT_rx_align_error]; in falcon_update_nic_stats()
2620 core_stats->rx_fifo_errors = stats[FALCON_STAT_rx_overflow]; in falcon_update_nic_stats()
2622 core_stats->rx_errors = (core_stats->rx_length_errors + in falcon_update_nic_stats()
2623 core_stats->rx_crc_errors + in falcon_update_nic_stats()
2624 core_stats->rx_frame_errors + in falcon_update_nic_stats()
2633 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_start_nic_stats()
2635 spin_lock_bh(&efx->stats_lock); in falcon_start_nic_stats()
2636 if (--nic_data->stats_disable_count == 0) in falcon_start_nic_stats()
2638 spin_unlock_bh(&efx->stats_lock); in falcon_start_nic_stats()
2651 struct falcon_nic_data *nic_data = efx->nic_data; in falcon_stop_nic_stats()
2656 spin_lock_bh(&efx->stats_lock); in falcon_stop_nic_stats()
2657 ++nic_data->stats_disable_count; in falcon_stop_nic_stats()
2658 spin_unlock_bh(&efx->stats_lock); in falcon_stop_nic_stats()
2660 del_timer_sync(&nic_data->stats_timer); in falcon_stop_nic_stats()
2664 for (i = 0; i < 4 && nic_data->stats_pending; i++) { in falcon_stop_nic_stats()
2670 spin_lock_bh(&efx->stats_lock); in falcon_stop_nic_stats()
2672 spin_unlock_bh(&efx->stats_lock); in falcon_stop_nic_stats()
2677 falcon_board(efx)->type->set_id_led(efx, mode); in falcon_set_id_led()
2689 wol->supported = 0; in falcon_get_wol()
2690 wol->wolopts = 0; in falcon_get_wol()
2691 memset(&wol->sopass, 0, sizeof(wol->sopass)); in falcon_get_wol()
2697 return -EINVAL; in falcon_set_wol()
2703 * Revision-dependent attributes used by efx.c and nic.c