11 #include <linux/bitops.h>
13 #include <linux/pci.h>
14 #include <linux/module.h>
15 #include <linux/slab.h>
16 #include <linux/random.h>
32 static void siena_init_wol(
struct efx_nic *efx);
50 FRF_CZ_TC_TIMER_VAL, 0);
55 static int siena_mdio_write(
struct net_device *net_dev,
58 struct efx_nic *efx = netdev_priv(net_dev);
63 addr, value, &status);
72 static int siena_mdio_read(
struct net_device *net_dev,
73 int prtad,
int devad,
u16 addr)
75 struct efx_nic *efx = netdev_priv(net_dev);
81 addr, &value, &status);
91 static int siena_probe_port(
struct efx_nic *efx)
100 efx->
mdio.mdio_read = siena_mdio_read;
101 efx->
mdio.mdio_write = siena_mdio_write;
104 rc = efx->
phy_op->probe(efx);
114 "stats buffer at %llx (virt %p phys %llx)\n",
124 static void siena_remove_port(
struct efx_nic *efx)
132 EFX_OWORD32(0x0003FFFF, 0x0003FFFF, 0x0003FFFF, 0x0003FFFF) },
134 EFX_OWORD32(0x000103FF, 0x00000000, 0x00000000, 0x00000000) },
136 EFX_OWORD32(0xFFFFFFFE, 0xFFFFFFFF, 0x0003FFFF, 0x00000000) },
138 EFX_OWORD32(0x7FFF0037, 0xFFFF8000, 0xFFFFFFFF, 0x03FFFFFF) },
140 EFX_OWORD32(0xFFFEFE80, 0x1FFFFFFF, 0x020000FE, 0x007FFFFF) },
142 EFX_OWORD32(0x001FFFFF, 0x00000000, 0x00000000, 0x00000000) },
144 EFX_OWORD32(0x00000003, 0x00000000, 0x00000000, 0x00000000) },
146 EFX_OWORD32(0x000003FF, 0x00000000, 0x00000000, 0x00000000) },
148 EFX_OWORD32(0x00000FFF, 0x00000000, 0x00000000, 0x00000000) },
150 EFX_OWORD32(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF) },
152 EFX_OWORD32(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF) },
154 EFX_OWORD32(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF) },
156 EFX_OWORD32(0xFFFFFFFF, 0xFFFFFFFF, 0x00000007, 0x00000000) },
169 rc = siena_reset_hw(efx, reset_method);
178 rc = siena_reset_hw(efx, reset_method);
181 return rc ? rc : rc2;
196 static int siena_map_reset_flags(
u32 *
flags)
202 SIENA_RESET_MC = (SIENA_RESET_PORT |
206 if ((*flags & SIENA_RESET_MC) == SIENA_RESET_MC) {
207 *flags &= ~SIENA_RESET_MC;
211 if ((*flags & SIENA_RESET_PORT) == SIENA_RESET_PORT) {
212 *flags &= ~SIENA_RESET_PORT;
236 static int siena_probe_nvconfig(
struct efx_nic *efx)
249 static void siena_dimension_resources(
struct efx_nic *efx)
258 static int siena_probe_nic(
struct efx_nic *efx)
261 bool already_attached =
false;
273 "Siena FPGA not supported\n");
293 "Unable to register driver with MCPU\n");
296 if (already_attached)
299 "Host already registered with MCPU\n");
317 "INT_KER at %llx (virt %p phys %llx)\n",
323 rc = siena_probe_nvconfig(efx);
326 "NVRAM is invalid therefore using defaults\n");
333 rc = efx_mcdi_mon_probe(efx);
357 static int siena_init_nic(
struct efx_nic *efx)
404 FRF_CZ_RX_RSS_IPV6_IP_THASH_ENABLE, 1);
425 static void siena_remove_nic(
struct efx_nic *efx)
427 efx_mcdi_mon_remove(efx);
441 #define STATS_GENERATION_INVALID ((__force __le64)(-1))
443 static int siena_try_update_nic_stats(
struct efx_nic *efx)
447 __le64 generation_start, generation_end;
457 #define MAC_STAT(M, D) \
458 mac_stats->M = le64_to_cpu(dma_stats[MC_CMD_MAC_ ## D])
535 if (generation_end != generation_start)
541 static void siena_update_nic_stats(
struct efx_nic *efx)
547 for (retry = 0; retry < 100; ++
retry) {
548 if (siena_try_update_nic_stats(efx) == 0)
556 static void siena_start_nic_stats(
struct efx_nic *efx)
566 static void siena_stop_nic_stats(
struct efx_nic *efx)
625 static void siena_init_wol(
struct efx_nic *efx)
651 .probe = siena_probe_nic,
652 .remove = siena_remove_nic,
653 .init = siena_init_nic,
654 .dimension_resources = siena_dimension_resources,
657 .map_reset_reason = siena_map_reset_reason,
658 .map_reset_flags = siena_map_reset_flags,
659 .reset = siena_reset_hw,
660 .probe_port = siena_probe_port,
661 .remove_port = siena_remove_port,
663 .update_stats = siena_update_nic_stats,
664 .start_stats = siena_start_nic_stats,
665 .stop_stats = siena_stop_nic_stats,
667 .push_irq_moderation = siena_push_irq_moderation,
671 .get_wol = siena_get_wol,
672 .set_wol = siena_set_wol,
673 .resume_wol = siena_init_wol,
674 .test_chip = siena_test_chip,
686 .rx_buffer_hash_size = 0x10,
687 .rx_buffer_padding = 0,
689 .phys_addr_channels = 32,