Lines Matching refs:efx
202 static int efx_soft_enable_interrupts(struct efx_nic *efx);
203 static void efx_soft_disable_interrupts(struct efx_nic *efx);
205 static void efx_remove_channels(struct efx_nic *efx);
207 static void efx_remove_port(struct efx_nic *efx);
209 static void efx_fini_napi(struct efx_nic *efx);
211 static void efx_fini_struct(struct efx_nic *efx);
212 static void efx_start_all(struct efx_nic *efx);
213 static void efx_stop_all(struct efx_nic *efx);
215 #define EFX_ASSERT_RESET_SERIALISED(efx) \ argument
217 if ((efx->state == STATE_READY) || \
218 (efx->state == STATE_RECOVERY) || \
219 (efx->state == STATE_DISABLED)) \
223 static int efx_check_disabled(struct efx_nic *efx) in efx_check_disabled() argument
225 if (efx->state == STATE_DISABLED || efx->state == STATE_RECOVERY) { in efx_check_disabled()
226 netif_err(efx, drv, efx->net_dev, in efx_check_disabled()
288 struct efx_nic *efx = channel->efx; in efx_poll() local
294 netif_vdbg(efx, intr, efx->net_dev, in efx_poll()
302 efx->irq_rx_adaptive && in efx_poll()
308 efx->type->push_irq_moderation(channel); in efx_poll()
313 efx->irq_rx_moderation) { in efx_poll()
315 efx->type->push_irq_moderation(channel); in efx_poll()
344 struct efx_nic *efx = channel->efx; in efx_probe_eventq() local
347 netif_dbg(efx, probe, efx->net_dev, in efx_probe_eventq()
352 entries = roundup_pow_of_two(efx->rxq_entries + efx->txq_entries + 128); in efx_probe_eventq()
362 struct efx_nic *efx = channel->efx; in efx_init_eventq() local
367 netif_dbg(efx, drv, efx->net_dev, in efx_init_eventq()
372 efx->type->push_irq_moderation(channel); in efx_init_eventq()
382 netif_dbg(channel->efx, ifup, channel->efx->net_dev, in efx_start_eventq()
411 netif_dbg(channel->efx, drv, channel->efx->net_dev, in efx_fini_eventq()
420 netif_dbg(channel->efx, drv, channel->efx->net_dev, in efx_remove_eventq()
434 efx_alloc_channel(struct efx_nic *efx, int i, struct efx_channel *old_channel) in efx_alloc_channel() argument
445 channel->efx = efx; in efx_alloc_channel()
451 tx_queue->efx = efx; in efx_alloc_channel()
457 rx_queue->efx = efx; in efx_alloc_channel()
507 netif_dbg(channel->efx, probe, channel->efx->net_dev, in efx_probe_channel()
540 struct efx_nic *efx = channel->efx; in efx_get_channel_name() local
545 if (efx->tx_channel_offset == 0) { in efx_get_channel_name()
547 } else if (channel->channel < efx->tx_channel_offset) { in efx_get_channel_name()
551 number -= efx->tx_channel_offset; in efx_get_channel_name()
553 snprintf(buf, len, "%s%s-%d", efx->name, type, number); in efx_get_channel_name()
556 static void efx_set_channel_names(struct efx_nic *efx) in efx_set_channel_names() argument
560 efx_for_each_channel(channel, efx) in efx_set_channel_names()
562 efx->msi_context[channel->channel].name, in efx_set_channel_names()
563 sizeof(efx->msi_context[0].name)); in efx_set_channel_names()
566 static int efx_probe_channels(struct efx_nic *efx) in efx_probe_channels() argument
572 efx->next_buffer_table = 0; in efx_probe_channels()
579 efx_for_each_channel_rev(channel, efx) { in efx_probe_channels()
582 netif_err(efx, probe, efx->net_dev, in efx_probe_channels()
588 efx_set_channel_names(efx); in efx_probe_channels()
593 efx_remove_channels(efx); in efx_probe_channels()
601 static void efx_start_datapath(struct efx_nic *efx) in efx_start_datapath() argument
603 bool old_rx_scatter = efx->rx_scatter; in efx_start_datapath()
613 efx->rx_dma_len = (efx->rx_prefix_size + in efx_start_datapath()
614 EFX_MAX_FRAME_LEN(efx->net_dev->mtu) + in efx_start_datapath()
615 efx->type->rx_buffer_padding); in efx_start_datapath()
617 efx->rx_ip_align + efx->rx_dma_len); in efx_start_datapath()
619 efx->rx_scatter = efx->type->always_rx_scatter; in efx_start_datapath()
620 efx->rx_buffer_order = 0; in efx_start_datapath()
621 } else if (efx->type->can_rx_scatter) { in efx_start_datapath()
627 efx->rx_scatter = true; in efx_start_datapath()
628 efx->rx_dma_len = EFX_RX_USR_BUF_SIZE; in efx_start_datapath()
629 efx->rx_buffer_order = 0; in efx_start_datapath()
631 efx->rx_scatter = false; in efx_start_datapath()
632 efx->rx_buffer_order = get_order(rx_buf_len); in efx_start_datapath()
635 efx_rx_config_page_split(efx); in efx_start_datapath()
636 if (efx->rx_buffer_order) in efx_start_datapath()
637 netif_dbg(efx, drv, efx->net_dev, in efx_start_datapath()
639 efx->rx_dma_len, efx->rx_buffer_order, in efx_start_datapath()
640 efx->rx_pages_per_batch); in efx_start_datapath()
642 netif_dbg(efx, drv, efx->net_dev, in efx_start_datapath()
644 efx->rx_dma_len, efx->rx_page_buf_step, in efx_start_datapath()
645 efx->rx_bufs_per_page, efx->rx_pages_per_batch); in efx_start_datapath()
648 if (efx->rx_scatter != old_rx_scatter) in efx_start_datapath()
649 efx->type->filter_update_rx_scatter(efx); in efx_start_datapath()
658 efx->txq_stop_thresh = efx->txq_entries - efx_tx_max_skb_descs(efx); in efx_start_datapath()
659 efx->txq_wake_thresh = efx->txq_stop_thresh / 2; in efx_start_datapath()
662 efx_for_each_channel(channel, efx) { in efx_start_datapath()
665 atomic_inc(&efx->active_queues); in efx_start_datapath()
670 atomic_inc(&efx->active_queues); in efx_start_datapath()
679 efx_ptp_start_datapath(efx); in efx_start_datapath()
681 if (netif_device_present(efx->net_dev)) in efx_start_datapath()
682 netif_tx_wake_all_queues(efx->net_dev); in efx_start_datapath()
685 static void efx_stop_datapath(struct efx_nic *efx) in efx_stop_datapath() argument
692 EFX_ASSERT_RESET_SERIALISED(efx); in efx_stop_datapath()
693 BUG_ON(efx->port_enabled); in efx_stop_datapath()
695 efx_ptp_stop_datapath(efx); in efx_stop_datapath()
698 efx_for_each_channel(channel, efx) { in efx_stop_datapath()
703 efx_for_each_channel(channel, efx) { in efx_stop_datapath()
716 rc = efx->type->fini_dmaq(efx); in efx_stop_datapath()
717 if (rc && EFX_WORKAROUND_7803(efx)) { in efx_stop_datapath()
723 netif_err(efx, drv, efx->net_dev, in efx_stop_datapath()
725 efx_schedule_reset(efx, RESET_TYPE_ALL); in efx_stop_datapath()
727 netif_err(efx, drv, efx->net_dev, "failed to flush queues\n"); in efx_stop_datapath()
729 netif_dbg(efx, drv, efx->net_dev, in efx_stop_datapath()
733 efx_for_each_channel(channel, efx) { in efx_stop_datapath()
746 netif_dbg(channel->efx, drv, channel->efx->net_dev, in efx_remove_channel()
757 static void efx_remove_channels(struct efx_nic *efx) in efx_remove_channels() argument
761 efx_for_each_channel(channel, efx) in efx_remove_channels()
766 efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries) in efx_realloc_channels() argument
773 rc = efx_check_disabled(efx); in efx_realloc_channels()
780 efx_for_each_channel(channel, efx) { in efx_realloc_channels()
799 efx_device_detach_sync(efx); in efx_realloc_channels()
800 efx_stop_all(efx); in efx_realloc_channels()
801 efx_soft_disable_interrupts(efx); in efx_realloc_channels()
805 for (i = 0; i < efx->n_channels; i++) { in efx_realloc_channels()
806 channel = efx->channel[i]; in efx_realloc_channels()
817 old_rxq_entries = efx->rxq_entries; in efx_realloc_channels()
818 old_txq_entries = efx->txq_entries; in efx_realloc_channels()
819 efx->rxq_entries = rxq_entries; in efx_realloc_channels()
820 efx->txq_entries = txq_entries; in efx_realloc_channels()
821 for (i = 0; i < efx->n_channels; i++) { in efx_realloc_channels()
822 channel = efx->channel[i]; in efx_realloc_channels()
823 efx->channel[i] = other_channel[i]; in efx_realloc_channels()
828 efx->next_buffer_table = next_buffer_table; in efx_realloc_channels()
830 for (i = 0; i < efx->n_channels; i++) { in efx_realloc_channels()
831 channel = efx->channel[i]; in efx_realloc_channels()
837 efx_init_napi_channel(efx->channel[i]); in efx_realloc_channels()
842 for (i = 0; i < efx->n_channels; i++) { in efx_realloc_channels()
851 rc2 = efx_soft_enable_interrupts(efx); in efx_realloc_channels()
854 netif_err(efx, drv, efx->net_dev, in efx_realloc_channels()
856 efx_schedule_reset(efx, RESET_TYPE_DISABLE); in efx_realloc_channels()
858 efx_start_all(efx); in efx_realloc_channels()
859 netif_device_attach(efx->net_dev); in efx_realloc_channels()
865 efx->rxq_entries = old_rxq_entries; in efx_realloc_channels()
866 efx->txq_entries = old_txq_entries; in efx_realloc_channels()
867 for (i = 0; i < efx->n_channels; i++) { in efx_realloc_channels()
868 channel = efx->channel[i]; in efx_realloc_channels()
869 efx->channel[i] = other_channel[i]; in efx_realloc_channels()
907 void efx_link_status_changed(struct efx_nic *efx) in efx_link_status_changed() argument
909 struct efx_link_state *link_state = &efx->link_state; in efx_link_status_changed()
915 if (!netif_running(efx->net_dev)) in efx_link_status_changed()
918 if (link_state->up != netif_carrier_ok(efx->net_dev)) { in efx_link_status_changed()
919 efx->n_link_state_changes++; in efx_link_status_changed()
922 netif_carrier_on(efx->net_dev); in efx_link_status_changed()
924 netif_carrier_off(efx->net_dev); in efx_link_status_changed()
929 netif_info(efx, link, efx->net_dev, in efx_link_status_changed()
932 efx->net_dev->mtu); in efx_link_status_changed()
934 netif_info(efx, link, efx->net_dev, "link down\n"); in efx_link_status_changed()
937 void efx_link_set_advertising(struct efx_nic *efx, u32 advertising) in efx_link_set_advertising() argument
939 efx->link_advertising = advertising; in efx_link_set_advertising()
942 efx->wanted_fc |= (EFX_FC_TX | EFX_FC_RX); in efx_link_set_advertising()
944 efx->wanted_fc &= ~(EFX_FC_TX | EFX_FC_RX); in efx_link_set_advertising()
946 efx->wanted_fc ^= EFX_FC_TX; in efx_link_set_advertising()
950 void efx_link_set_wanted_fc(struct efx_nic *efx, u8 wanted_fc) in efx_link_set_wanted_fc() argument
952 efx->wanted_fc = wanted_fc; in efx_link_set_wanted_fc()
953 if (efx->link_advertising) { in efx_link_set_wanted_fc()
955 efx->link_advertising |= (ADVERTISED_Pause | in efx_link_set_wanted_fc()
958 efx->link_advertising &= ~(ADVERTISED_Pause | in efx_link_set_wanted_fc()
961 efx->link_advertising ^= ADVERTISED_Asym_Pause; in efx_link_set_wanted_fc()
965 static void efx_fini_port(struct efx_nic *efx);
970 void efx_mac_reconfigure(struct efx_nic *efx) in efx_mac_reconfigure() argument
972 down_read(&efx->filter_sem); in efx_mac_reconfigure()
973 efx->type->reconfigure_mac(efx); in efx_mac_reconfigure()
974 up_read(&efx->filter_sem); in efx_mac_reconfigure()
984 int __efx_reconfigure_port(struct efx_nic *efx) in __efx_reconfigure_port() argument
989 WARN_ON(!mutex_is_locked(&efx->mac_lock)); in __efx_reconfigure_port()
992 phy_mode = efx->phy_mode; in __efx_reconfigure_port()
993 if (LOOPBACK_INTERNAL(efx)) in __efx_reconfigure_port()
994 efx->phy_mode |= PHY_MODE_TX_DISABLED; in __efx_reconfigure_port()
996 efx->phy_mode &= ~PHY_MODE_TX_DISABLED; in __efx_reconfigure_port()
998 rc = efx->type->reconfigure_port(efx); in __efx_reconfigure_port()
1001 efx->phy_mode = phy_mode; in __efx_reconfigure_port()
1008 int efx_reconfigure_port(struct efx_nic *efx) in efx_reconfigure_port() argument
1012 EFX_ASSERT_RESET_SERIALISED(efx); in efx_reconfigure_port()
1014 mutex_lock(&efx->mac_lock); in efx_reconfigure_port()
1015 rc = __efx_reconfigure_port(efx); in efx_reconfigure_port()
1016 mutex_unlock(&efx->mac_lock); in efx_reconfigure_port()
1026 struct efx_nic *efx = container_of(data, struct efx_nic, mac_work); in efx_mac_work() local
1028 mutex_lock(&efx->mac_lock); in efx_mac_work()
1029 if (efx->port_enabled) in efx_mac_work()
1030 efx_mac_reconfigure(efx); in efx_mac_work()
1031 mutex_unlock(&efx->mac_lock); in efx_mac_work()
1034 static int efx_probe_port(struct efx_nic *efx) in efx_probe_port() argument
1038 netif_dbg(efx, probe, efx->net_dev, "create port\n"); in efx_probe_port()
1041 efx->phy_mode = PHY_MODE_SPECIAL; in efx_probe_port()
1044 rc = efx->type->probe_port(efx); in efx_probe_port()
1049 ether_addr_copy(efx->net_dev->dev_addr, efx->net_dev->perm_addr); in efx_probe_port()
1054 static int efx_init_port(struct efx_nic *efx) in efx_init_port() argument
1058 netif_dbg(efx, drv, efx->net_dev, "init port\n"); in efx_init_port()
1060 mutex_lock(&efx->mac_lock); in efx_init_port()
1062 rc = efx->phy_op->init(efx); in efx_init_port()
1066 efx->port_initialized = true; in efx_init_port()
1070 efx_mac_reconfigure(efx); in efx_init_port()
1073 rc = efx->phy_op->reconfigure(efx); in efx_init_port()
1077 mutex_unlock(&efx->mac_lock); in efx_init_port()
1081 efx->phy_op->fini(efx); in efx_init_port()
1083 mutex_unlock(&efx->mac_lock); in efx_init_port()
1087 static void efx_start_port(struct efx_nic *efx) in efx_start_port() argument
1089 netif_dbg(efx, ifup, efx->net_dev, "start port\n"); in efx_start_port()
1090 BUG_ON(efx->port_enabled); in efx_start_port()
1092 mutex_lock(&efx->mac_lock); in efx_start_port()
1093 efx->port_enabled = true; in efx_start_port()
1096 efx_mac_reconfigure(efx); in efx_start_port()
1098 mutex_unlock(&efx->mac_lock); in efx_start_port()
1106 static void efx_stop_port(struct efx_nic *efx) in efx_stop_port() argument
1108 netif_dbg(efx, ifdown, efx->net_dev, "stop port\n"); in efx_stop_port()
1110 EFX_ASSERT_RESET_SERIALISED(efx); in efx_stop_port()
1112 mutex_lock(&efx->mac_lock); in efx_stop_port()
1113 efx->port_enabled = false; in efx_stop_port()
1114 mutex_unlock(&efx->mac_lock); in efx_stop_port()
1117 netif_addr_lock_bh(efx->net_dev); in efx_stop_port()
1118 netif_addr_unlock_bh(efx->net_dev); in efx_stop_port()
1120 cancel_delayed_work_sync(&efx->monitor_work); in efx_stop_port()
1121 efx_selftest_async_cancel(efx); in efx_stop_port()
1122 cancel_work_sync(&efx->mac_work); in efx_stop_port()
1125 static void efx_fini_port(struct efx_nic *efx) in efx_fini_port() argument
1127 netif_dbg(efx, drv, efx->net_dev, "shut down port\n"); in efx_fini_port()
1129 if (!efx->port_initialized) in efx_fini_port()
1132 efx->phy_op->fini(efx); in efx_fini_port()
1133 efx->port_initialized = false; in efx_fini_port()
1135 efx->link_state.up = false; in efx_fini_port()
1136 efx_link_status_changed(efx); in efx_fini_port()
1139 static void efx_remove_port(struct efx_nic *efx) in efx_remove_port() argument
1141 netif_dbg(efx, drv, efx->net_dev, "destroying port\n"); in efx_remove_port()
1143 efx->type->remove_port(efx); in efx_remove_port()
1162 static void efx_associate(struct efx_nic *efx) in efx_associate() argument
1166 if (efx->primary == efx) { in efx_associate()
1169 netif_dbg(efx, probe, efx->net_dev, "adding to primary list\n"); in efx_associate()
1170 list_add_tail(&efx->node, &efx_primary_list); in efx_associate()
1174 if (efx_same_controller(efx, other)) { in efx_associate()
1178 pci_name(efx->pci_dev), in efx_associate()
1179 efx->net_dev->name); in efx_associate()
1181 &efx->secondary_list); in efx_associate()
1182 other->primary = efx; in efx_associate()
1189 if (efx_same_controller(efx, other)) { in efx_associate()
1190 netif_dbg(efx, probe, efx->net_dev, in efx_associate()
1194 list_add_tail(&efx->node, in efx_associate()
1196 efx->primary = other; in efx_associate()
1201 netif_dbg(efx, probe, efx->net_dev, in efx_associate()
1203 list_add_tail(&efx->node, &efx_unassociated_list); in efx_associate()
1207 static void efx_dissociate(struct efx_nic *efx) in efx_dissociate() argument
1211 list_del(&efx->node); in efx_dissociate()
1212 efx->primary = NULL; in efx_dissociate()
1214 list_for_each_entry_safe(other, next, &efx->secondary_list, node) { in efx_dissociate()
1224 static int efx_init_io(struct efx_nic *efx) in efx_init_io() argument
1226 struct pci_dev *pci_dev = efx->pci_dev; in efx_init_io()
1227 dma_addr_t dma_mask = efx->type->max_dma_mask; in efx_init_io()
1228 unsigned int mem_map_size = efx->type->mem_map_size(efx); in efx_init_io()
1231 netif_dbg(efx, probe, efx->net_dev, "initialising I/O\n"); in efx_init_io()
1233 bar = efx->type->mem_bar; in efx_init_io()
1237 netif_err(efx, probe, efx->net_dev, in efx_init_io()
1256 netif_err(efx, probe, efx->net_dev, in efx_init_io()
1260 netif_dbg(efx, probe, efx->net_dev, in efx_init_io()
1263 efx->membase_phys = pci_resource_start(efx->pci_dev, bar); in efx_init_io()
1266 netif_err(efx, probe, efx->net_dev, in efx_init_io()
1271 efx->membase = ioremap_nocache(efx->membase_phys, mem_map_size); in efx_init_io()
1272 if (!efx->membase) { in efx_init_io()
1273 netif_err(efx, probe, efx->net_dev, in efx_init_io()
1275 (unsigned long long)efx->membase_phys, mem_map_size); in efx_init_io()
1279 netif_dbg(efx, probe, efx->net_dev, in efx_init_io()
1281 (unsigned long long)efx->membase_phys, mem_map_size, in efx_init_io()
1282 efx->membase); in efx_init_io()
1287 pci_release_region(efx->pci_dev, bar); in efx_init_io()
1289 efx->membase_phys = 0; in efx_init_io()
1291 pci_disable_device(efx->pci_dev); in efx_init_io()
1296 static void efx_fini_io(struct efx_nic *efx) in efx_fini_io() argument
1300 netif_dbg(efx, drv, efx->net_dev, "shutting down I/O\n"); in efx_fini_io()
1302 if (efx->membase) { in efx_fini_io()
1303 iounmap(efx->membase); in efx_fini_io()
1304 efx->membase = NULL; in efx_fini_io()
1307 if (efx->membase_phys) { in efx_fini_io()
1308 bar = efx->type->mem_bar; in efx_fini_io()
1309 pci_release_region(efx->pci_dev, bar); in efx_fini_io()
1310 efx->membase_phys = 0; in efx_fini_io()
1314 if (!pci_vfs_assigned(efx->pci_dev)) in efx_fini_io()
1315 pci_disable_device(efx->pci_dev); in efx_fini_io()
1318 void efx_set_default_rx_indir_table(struct efx_nic *efx) in efx_set_default_rx_indir_table() argument
1322 for (i = 0; i < ARRAY_SIZE(efx->rx_indir_table); i++) in efx_set_default_rx_indir_table()
1323 efx->rx_indir_table[i] = in efx_set_default_rx_indir_table()
1324 ethtool_rxfh_indir_default(i, efx->rss_spread); in efx_set_default_rx_indir_table()
1327 static unsigned int efx_wanted_parallelism(struct efx_nic *efx) in efx_wanted_parallelism() argument
1337 netif_warn(efx, probe, efx->net_dev, in efx_wanted_parallelism()
1358 if (efx->type->sriov_wanted) { in efx_wanted_parallelism()
1359 if (efx->type->sriov_wanted(efx) && efx_vf_size(efx) > 1 && in efx_wanted_parallelism()
1360 count > efx_vf_size(efx)) { in efx_wanted_parallelism()
1361 netif_warn(efx, probe, efx->net_dev, in efx_wanted_parallelism()
1365 count, efx_vf_size(efx)); in efx_wanted_parallelism()
1366 count = efx_vf_size(efx); in efx_wanted_parallelism()
1377 static int efx_probe_interrupts(struct efx_nic *efx) in efx_probe_interrupts() argument
1384 if (efx->extra_channel_type[i]) in efx_probe_interrupts()
1387 if (efx->interrupt_mode == EFX_INT_MODE_MSIX) { in efx_probe_interrupts()
1391 n_channels = efx_wanted_parallelism(efx); in efx_probe_interrupts()
1395 n_channels = min(n_channels, efx->max_channels); in efx_probe_interrupts()
1399 rc = pci_enable_msix_range(efx->pci_dev, in efx_probe_interrupts()
1403 efx->interrupt_mode = EFX_INT_MODE_MSI; in efx_probe_interrupts()
1404 netif_err(efx, drv, efx->net_dev, in efx_probe_interrupts()
1407 netif_err(efx, drv, efx->net_dev, in efx_probe_interrupts()
1410 netif_err(efx, drv, efx->net_dev, in efx_probe_interrupts()
1416 efx->n_channels = n_channels; in efx_probe_interrupts()
1420 efx->n_tx_channels = min(max(n_channels / 2, in efx_probe_interrupts()
1422 efx->max_tx_channels); in efx_probe_interrupts()
1423 efx->n_rx_channels = max(n_channels - in efx_probe_interrupts()
1424 efx->n_tx_channels, in efx_probe_interrupts()
1427 efx->n_tx_channels = min(n_channels, in efx_probe_interrupts()
1428 efx->max_tx_channels); in efx_probe_interrupts()
1429 efx->n_rx_channels = n_channels; in efx_probe_interrupts()
1431 for (i = 0; i < efx->n_channels; i++) in efx_probe_interrupts()
1432 efx_get_channel(efx, i)->irq = in efx_probe_interrupts()
1438 if (efx->interrupt_mode == EFX_INT_MODE_MSI) { in efx_probe_interrupts()
1439 efx->n_channels = 1; in efx_probe_interrupts()
1440 efx->n_rx_channels = 1; in efx_probe_interrupts()
1441 efx->n_tx_channels = 1; in efx_probe_interrupts()
1442 rc = pci_enable_msi(efx->pci_dev); in efx_probe_interrupts()
1444 efx_get_channel(efx, 0)->irq = efx->pci_dev->irq; in efx_probe_interrupts()
1446 netif_err(efx, drv, efx->net_dev, in efx_probe_interrupts()
1448 efx->interrupt_mode = EFX_INT_MODE_LEGACY; in efx_probe_interrupts()
1453 if (efx->interrupt_mode == EFX_INT_MODE_LEGACY) { in efx_probe_interrupts()
1454 efx->n_channels = 1 + (efx_separate_tx_channels ? 1 : 0); in efx_probe_interrupts()
1455 efx->n_rx_channels = 1; in efx_probe_interrupts()
1456 efx->n_tx_channels = 1; in efx_probe_interrupts()
1457 efx->legacy_irq = efx->pci_dev->irq; in efx_probe_interrupts()
1461 j = efx->n_channels; in efx_probe_interrupts()
1463 if (!efx->extra_channel_type[i]) in efx_probe_interrupts()
1465 if (efx->interrupt_mode != EFX_INT_MODE_MSIX || in efx_probe_interrupts()
1466 efx->n_channels <= extra_channels) { in efx_probe_interrupts()
1467 efx->extra_channel_type[i]->handle_no_channel(efx); in efx_probe_interrupts()
1470 efx_get_channel(efx, j)->type = in efx_probe_interrupts()
1471 efx->extra_channel_type[i]; in efx_probe_interrupts()
1477 if (efx->type->sriov_wanted) { in efx_probe_interrupts()
1478 efx->rss_spread = ((efx->n_rx_channels > 1 || in efx_probe_interrupts()
1479 !efx->type->sriov_wanted(efx)) ? in efx_probe_interrupts()
1480 efx->n_rx_channels : efx_vf_size(efx)); in efx_probe_interrupts()
1484 efx->rss_spread = efx->n_rx_channels; in efx_probe_interrupts()
1489 static int efx_soft_enable_interrupts(struct efx_nic *efx) in efx_soft_enable_interrupts() argument
1494 BUG_ON(efx->state == STATE_DISABLED); in efx_soft_enable_interrupts()
1496 efx->irq_soft_enabled = true; in efx_soft_enable_interrupts()
1499 efx_for_each_channel(channel, efx) { in efx_soft_enable_interrupts()
1508 efx_mcdi_mode_event(efx); in efx_soft_enable_interrupts()
1513 efx_for_each_channel(channel, efx) { in efx_soft_enable_interrupts()
1524 static void efx_soft_disable_interrupts(struct efx_nic *efx) in efx_soft_disable_interrupts() argument
1528 if (efx->state == STATE_DISABLED) in efx_soft_disable_interrupts()
1531 efx_mcdi_mode_poll(efx); in efx_soft_disable_interrupts()
1533 efx->irq_soft_enabled = false; in efx_soft_disable_interrupts()
1536 if (efx->legacy_irq) in efx_soft_disable_interrupts()
1537 synchronize_irq(efx->legacy_irq); in efx_soft_disable_interrupts()
1539 efx_for_each_channel(channel, efx) { in efx_soft_disable_interrupts()
1549 efx_mcdi_flush_async(efx); in efx_soft_disable_interrupts()
1552 static int efx_enable_interrupts(struct efx_nic *efx) in efx_enable_interrupts() argument
1557 BUG_ON(efx->state == STATE_DISABLED); in efx_enable_interrupts()
1559 if (efx->eeh_disabled_legacy_irq) { in efx_enable_interrupts()
1560 enable_irq(efx->legacy_irq); in efx_enable_interrupts()
1561 efx->eeh_disabled_legacy_irq = false; in efx_enable_interrupts()
1564 efx->type->irq_enable_master(efx); in efx_enable_interrupts()
1566 efx_for_each_channel(channel, efx) { in efx_enable_interrupts()
1574 rc = efx_soft_enable_interrupts(efx); in efx_enable_interrupts()
1582 efx_for_each_channel(channel, efx) { in efx_enable_interrupts()
1589 efx->type->irq_disable_non_ev(efx); in efx_enable_interrupts()
1594 static void efx_disable_interrupts(struct efx_nic *efx) in efx_disable_interrupts() argument
1598 efx_soft_disable_interrupts(efx); in efx_disable_interrupts()
1600 efx_for_each_channel(channel, efx) { in efx_disable_interrupts()
1605 efx->type->irq_disable_non_ev(efx); in efx_disable_interrupts()
1608 static void efx_remove_interrupts(struct efx_nic *efx) in efx_remove_interrupts() argument
1613 efx_for_each_channel(channel, efx) in efx_remove_interrupts()
1615 pci_disable_msi(efx->pci_dev); in efx_remove_interrupts()
1616 pci_disable_msix(efx->pci_dev); in efx_remove_interrupts()
1619 efx->legacy_irq = 0; in efx_remove_interrupts()
1622 static void efx_set_channels(struct efx_nic *efx) in efx_set_channels() argument
1627 efx->tx_channel_offset = in efx_set_channels()
1629 efx->n_channels - efx->n_tx_channels : 0; in efx_set_channels()
1635 efx_for_each_channel(channel, efx) { in efx_set_channels()
1636 if (channel->channel < efx->n_rx_channels) in efx_set_channels()
1642 tx_queue->queue -= (efx->tx_channel_offset * in efx_set_channels()
1647 static int efx_probe_nic(struct efx_nic *efx) in efx_probe_nic() argument
1651 netif_dbg(efx, probe, efx->net_dev, "creating NIC\n"); in efx_probe_nic()
1654 rc = efx->type->probe(efx); in efx_probe_nic()
1659 if (!efx->max_channels || !efx->max_tx_channels) { in efx_probe_nic()
1660 netif_err(efx, drv, efx->net_dev, in efx_probe_nic()
1670 rc = efx_probe_interrupts(efx); in efx_probe_nic()
1674 efx_set_channels(efx); in efx_probe_nic()
1677 rc = efx->type->dimension_resources(efx); in efx_probe_nic()
1683 efx_remove_interrupts(efx); in efx_probe_nic()
1687 if (efx->n_channels > 1) in efx_probe_nic()
1688 netdev_rss_key_fill(&efx->rx_hash_key, in efx_probe_nic()
1689 sizeof(efx->rx_hash_key)); in efx_probe_nic()
1690 efx_set_default_rx_indir_table(efx); in efx_probe_nic()
1692 netif_set_real_num_tx_queues(efx->net_dev, efx->n_tx_channels); in efx_probe_nic()
1693 netif_set_real_num_rx_queues(efx->net_dev, efx->n_rx_channels); in efx_probe_nic()
1696 efx_init_irq_moderation(efx, tx_irq_mod_usec, rx_irq_mod_usec, true, in efx_probe_nic()
1702 efx_remove_interrupts(efx); in efx_probe_nic()
1704 efx->type->remove(efx); in efx_probe_nic()
1708 static void efx_remove_nic(struct efx_nic *efx) in efx_remove_nic() argument
1710 netif_dbg(efx, drv, efx->net_dev, "destroying NIC\n"); in efx_remove_nic()
1712 efx_remove_interrupts(efx); in efx_remove_nic()
1713 efx->type->remove(efx); in efx_remove_nic()
1716 static int efx_probe_filters(struct efx_nic *efx) in efx_probe_filters() argument
1720 spin_lock_init(&efx->filter_lock); in efx_probe_filters()
1721 init_rwsem(&efx->filter_sem); in efx_probe_filters()
1722 down_write(&efx->filter_sem); in efx_probe_filters()
1723 rc = efx->type->filter_table_probe(efx); in efx_probe_filters()
1728 if (efx->type->offload_features & NETIF_F_NTUPLE) { in efx_probe_filters()
1729 efx->rps_flow_id = kcalloc(efx->type->max_rx_ip_filters, in efx_probe_filters()
1730 sizeof(*efx->rps_flow_id), in efx_probe_filters()
1732 if (!efx->rps_flow_id) { in efx_probe_filters()
1733 efx->type->filter_table_remove(efx); in efx_probe_filters()
1740 up_write(&efx->filter_sem); in efx_probe_filters()
1744 static void efx_remove_filters(struct efx_nic *efx) in efx_remove_filters() argument
1747 kfree(efx->rps_flow_id); in efx_remove_filters()
1749 down_write(&efx->filter_sem); in efx_remove_filters()
1750 efx->type->filter_table_remove(efx); in efx_remove_filters()
1751 up_write(&efx->filter_sem); in efx_remove_filters()
1754 static void efx_restore_filters(struct efx_nic *efx) in efx_restore_filters() argument
1756 down_read(&efx->filter_sem); in efx_restore_filters()
1757 efx->type->filter_table_restore(efx); in efx_restore_filters()
1758 up_read(&efx->filter_sem); in efx_restore_filters()
1767 static int efx_probe_all(struct efx_nic *efx) in efx_probe_all() argument
1771 rc = efx_probe_nic(efx); in efx_probe_all()
1773 netif_err(efx, probe, efx->net_dev, "failed to create NIC\n"); in efx_probe_all()
1777 rc = efx_probe_port(efx); in efx_probe_all()
1779 netif_err(efx, probe, efx->net_dev, "failed to create port\n"); in efx_probe_all()
1784 if (WARN_ON(EFX_DEFAULT_DMAQ_SIZE < EFX_TXQ_MIN_ENT(efx))) { in efx_probe_all()
1788 efx->rxq_entries = efx->txq_entries = EFX_DEFAULT_DMAQ_SIZE; in efx_probe_all()
1791 rc = efx->type->vswitching_probe(efx); in efx_probe_all()
1793 netif_warn(efx, probe, efx->net_dev, in efx_probe_all()
1798 rc = efx_probe_filters(efx); in efx_probe_all()
1800 netif_err(efx, probe, efx->net_dev, in efx_probe_all()
1805 rc = efx_probe_channels(efx); in efx_probe_all()
1812 efx_remove_filters(efx); in efx_probe_all()
1815 efx->type->vswitching_remove(efx); in efx_probe_all()
1818 efx_remove_port(efx); in efx_probe_all()
1820 efx_remove_nic(efx); in efx_probe_all()
1832 static void efx_start_all(struct efx_nic *efx) in efx_start_all() argument
1834 EFX_ASSERT_RESET_SERIALISED(efx); in efx_start_all()
1835 BUG_ON(efx->state == STATE_DISABLED); in efx_start_all()
1839 if (efx->port_enabled || !netif_running(efx->net_dev) || in efx_start_all()
1840 efx->reset_pending) in efx_start_all()
1843 efx_start_port(efx); in efx_start_all()
1844 efx_start_datapath(efx); in efx_start_all()
1847 if (efx->type->monitor != NULL) in efx_start_all()
1848 queue_delayed_work(efx->workqueue, &efx->monitor_work, in efx_start_all()
1854 if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0) { in efx_start_all()
1855 mutex_lock(&efx->mac_lock); in efx_start_all()
1856 if (efx->phy_op->poll(efx)) in efx_start_all()
1857 efx_link_status_changed(efx); in efx_start_all()
1858 mutex_unlock(&efx->mac_lock); in efx_start_all()
1861 efx->type->start_stats(efx); in efx_start_all()
1862 efx->type->pull_stats(efx); in efx_start_all()
1863 spin_lock_bh(&efx->stats_lock); in efx_start_all()
1864 efx->type->update_stats(efx, NULL, NULL); in efx_start_all()
1865 spin_unlock_bh(&efx->stats_lock); in efx_start_all()
1873 static void efx_stop_all(struct efx_nic *efx) in efx_stop_all() argument
1875 EFX_ASSERT_RESET_SERIALISED(efx); in efx_stop_all()
1878 if (!efx->port_enabled) in efx_stop_all()
1884 efx->type->pull_stats(efx); in efx_stop_all()
1885 spin_lock_bh(&efx->stats_lock); in efx_stop_all()
1886 efx->type->update_stats(efx, NULL, NULL); in efx_stop_all()
1887 spin_unlock_bh(&efx->stats_lock); in efx_stop_all()
1888 efx->type->stop_stats(efx); in efx_stop_all()
1889 efx_stop_port(efx); in efx_stop_all()
1895 WARN_ON(netif_running(efx->net_dev) && in efx_stop_all()
1896 netif_device_present(efx->net_dev)); in efx_stop_all()
1897 netif_tx_disable(efx->net_dev); in efx_stop_all()
1899 efx_stop_datapath(efx); in efx_stop_all()
1902 static void efx_remove_all(struct efx_nic *efx) in efx_remove_all() argument
1904 efx_remove_channels(efx); in efx_remove_all()
1905 efx_remove_filters(efx); in efx_remove_all()
1907 efx->type->vswitching_remove(efx); in efx_remove_all()
1909 efx_remove_port(efx); in efx_remove_all()
1910 efx_remove_nic(efx); in efx_remove_all()
1929 int efx_init_irq_moderation(struct efx_nic *efx, unsigned int tx_usecs, in efx_init_irq_moderation() argument
1934 unsigned int irq_mod_max = DIV_ROUND_UP(efx->type->timer_period_max * in efx_init_irq_moderation()
1935 efx->timer_quantum_ns, in efx_init_irq_moderation()
1940 EFX_ASSERT_RESET_SERIALISED(efx); in efx_init_irq_moderation()
1945 tx_ticks = irq_mod_ticks(tx_usecs, efx->timer_quantum_ns); in efx_init_irq_moderation()
1946 rx_ticks = irq_mod_ticks(rx_usecs, efx->timer_quantum_ns); in efx_init_irq_moderation()
1948 if (tx_ticks != rx_ticks && efx->tx_channel_offset == 0 && in efx_init_irq_moderation()
1950 netif_err(efx, drv, efx->net_dev, "Channels are shared. " in efx_init_irq_moderation()
1955 efx->irq_rx_adaptive = rx_adaptive; in efx_init_irq_moderation()
1956 efx->irq_rx_moderation = rx_ticks; in efx_init_irq_moderation()
1957 efx_for_each_channel(channel, efx) { in efx_init_irq_moderation()
1967 void efx_get_irq_moderation(struct efx_nic *efx, unsigned int *tx_usecs, in efx_get_irq_moderation() argument
1974 *rx_adaptive = efx->irq_rx_adaptive; in efx_get_irq_moderation()
1975 *rx_usecs = DIV_ROUND_UP(efx->irq_rx_moderation * in efx_get_irq_moderation()
1976 efx->timer_quantum_ns, in efx_get_irq_moderation()
1983 if (efx->tx_channel_offset == 0) in efx_get_irq_moderation()
1987 efx->channel[efx->tx_channel_offset]->irq_moderation * in efx_get_irq_moderation()
1988 efx->timer_quantum_ns, in efx_get_irq_moderation()
2001 struct efx_nic *efx = container_of(data, struct efx_nic, in efx_monitor() local
2004 netif_vdbg(efx, timer, efx->net_dev, in efx_monitor()
2007 BUG_ON(efx->type->monitor == NULL); in efx_monitor()
2012 if (mutex_trylock(&efx->mac_lock)) { in efx_monitor()
2013 if (efx->port_enabled) in efx_monitor()
2014 efx->type->monitor(efx); in efx_monitor()
2015 mutex_unlock(&efx->mac_lock); in efx_monitor()
2018 queue_delayed_work(efx->workqueue, &efx->monitor_work, in efx_monitor()
2033 struct efx_nic *efx = netdev_priv(net_dev); in efx_ioctl() local
2037 return efx_ptp_set_ts_config(efx, ifr); in efx_ioctl()
2039 return efx_ptp_get_ts_config(efx, ifr); in efx_ioctl()
2046 return mdio_mii_ioctl(&efx->mdio, data, cmd); in efx_ioctl()
2057 struct efx_nic *efx = channel->efx; in efx_init_napi_channel() local
2059 channel->napi_dev = efx->net_dev; in efx_init_napi_channel()
2066 static void efx_init_napi(struct efx_nic *efx) in efx_init_napi() argument
2070 efx_for_each_channel(channel, efx) in efx_init_napi()
2083 static void efx_fini_napi(struct efx_nic *efx) in efx_fini_napi() argument
2087 efx_for_each_channel(channel, efx) in efx_fini_napi()
2105 struct efx_nic *efx = netdev_priv(net_dev); in efx_netpoll() local
2108 efx_for_each_channel(channel, efx) in efx_netpoll()
2119 struct efx_nic *efx = channel->efx; in efx_busy_poll() local
2123 if (!netif_running(efx->net_dev)) in efx_busy_poll()
2154 struct efx_nic *efx = netdev_priv(net_dev); in efx_net_open() local
2157 netif_dbg(efx, ifup, efx->net_dev, "opening device on CPU %d\n", in efx_net_open()
2160 rc = efx_check_disabled(efx); in efx_net_open()
2163 if (efx->phy_mode & PHY_MODE_SPECIAL) in efx_net_open()
2165 if (efx_mcdi_poll_reboot(efx) && efx_reset(efx, RESET_TYPE_ALL)) in efx_net_open()
2170 efx_link_status_changed(efx); in efx_net_open()
2172 efx_start_all(efx); in efx_net_open()
2173 efx_selftest_async_start(efx); in efx_net_open()
2183 struct efx_nic *efx = netdev_priv(net_dev); in efx_net_stop() local
2185 netif_dbg(efx, ifdown, efx->net_dev, "closing on CPU %d\n", in efx_net_stop()
2189 efx_stop_all(efx); in efx_net_stop()
2198 struct efx_nic *efx = netdev_priv(net_dev); in efx_net_stats() local
2200 spin_lock_bh(&efx->stats_lock); in efx_net_stats()
2201 efx->type->update_stats(efx, NULL, stats); in efx_net_stats()
2202 spin_unlock_bh(&efx->stats_lock); in efx_net_stats()
2210 struct efx_nic *efx = netdev_priv(net_dev); in efx_watchdog() local
2212 netif_err(efx, tx_err, efx->net_dev, in efx_watchdog()
2214 efx->port_enabled); in efx_watchdog()
2216 efx_schedule_reset(efx, RESET_TYPE_TX_WATCHDOG); in efx_watchdog()
2223 struct efx_nic *efx = netdev_priv(net_dev); in efx_change_mtu() local
2226 rc = efx_check_disabled(efx); in efx_change_mtu()
2232 netif_dbg(efx, drv, efx->net_dev, "changing MTU to %d\n", new_mtu); in efx_change_mtu()
2234 efx_device_detach_sync(efx); in efx_change_mtu()
2235 efx_stop_all(efx); in efx_change_mtu()
2237 mutex_lock(&efx->mac_lock); in efx_change_mtu()
2239 efx_mac_reconfigure(efx); in efx_change_mtu()
2240 mutex_unlock(&efx->mac_lock); in efx_change_mtu()
2242 efx_start_all(efx); in efx_change_mtu()
2243 netif_device_attach(efx->net_dev); in efx_change_mtu()
2249 struct efx_nic *efx = netdev_priv(net_dev); in efx_set_mac_address() local
2256 netif_err(efx, drv, efx->net_dev, in efx_set_mac_address()
2265 if (efx->type->set_mac_address) { in efx_set_mac_address()
2266 rc = efx->type->set_mac_address(efx); in efx_set_mac_address()
2274 mutex_lock(&efx->mac_lock); in efx_set_mac_address()
2275 efx_mac_reconfigure(efx); in efx_set_mac_address()
2276 mutex_unlock(&efx->mac_lock); in efx_set_mac_address()
2284 struct efx_nic *efx = netdev_priv(net_dev); in efx_set_rx_mode() local
2286 if (efx->port_enabled) in efx_set_rx_mode()
2287 queue_work(efx->workqueue, &efx->mac_work); in efx_set_rx_mode()
2293 struct efx_nic *efx = netdev_priv(net_dev); in efx_set_features() local
2297 return efx->type->filter_clear_rx(efx, EFX_FILTER_PRI_MANUAL); in efx_set_features()
2334 static void efx_update_name(struct efx_nic *efx) in efx_update_name() argument
2336 strcpy(efx->name, efx->net_dev->name); in efx_update_name()
2337 efx_mtd_rename(efx); in efx_update_name()
2338 efx_set_channel_names(efx); in efx_update_name()
2360 struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); in show_phy_type() local
2361 return sprintf(buf, "%d\n", efx->phy_type); in show_phy_type()
2369 struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); in show_mcdi_log() local
2370 struct efx_mcdi_iface *mcdi = efx_mcdi(efx); in show_mcdi_log()
2377 struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); in set_mcdi_log() local
2378 struct efx_mcdi_iface *mcdi = efx_mcdi(efx); in set_mcdi_log()
2387 static int efx_register_netdev(struct efx_nic *efx) in efx_register_netdev() argument
2389 struct net_device *net_dev = efx->net_dev; in efx_register_netdev()
2394 net_dev->irq = efx->pci_dev->irq; in efx_register_netdev()
2396 if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0) in efx_register_netdev()
2407 efx->state = STATE_READY; in efx_register_netdev()
2409 if (efx->reset_pending) { in efx_register_netdev()
2410 netif_err(efx, probe, efx->net_dev, in efx_register_netdev()
2419 efx_update_name(efx); in efx_register_netdev()
2428 efx_for_each_channel(channel, efx) { in efx_register_netdev()
2434 efx_associate(efx); in efx_register_netdev()
2438 rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_type); in efx_register_netdev()
2440 netif_err(efx, drv, efx->net_dev, in efx_register_netdev()
2445 rc = device_create_file(&efx->pci_dev->dev, &dev_attr_mcdi_logging); in efx_register_netdev()
2447 netif_err(efx, drv, efx->net_dev, in efx_register_netdev()
2457 device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type); in efx_register_netdev()
2461 efx_dissociate(efx); in efx_register_netdev()
2464 efx->state = STATE_UNINIT; in efx_register_netdev()
2466 netif_err(efx, drv, efx->net_dev, "could not register net dev\n"); in efx_register_netdev()
2470 static void efx_unregister_netdev(struct efx_nic *efx) in efx_unregister_netdev() argument
2472 if (!efx->net_dev) in efx_unregister_netdev()
2475 BUG_ON(netdev_priv(efx->net_dev) != efx); in efx_unregister_netdev()
2477 if (efx_dev_registered(efx)) { in efx_unregister_netdev()
2478 strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name)); in efx_unregister_netdev()
2480 device_remove_file(&efx->pci_dev->dev, &dev_attr_mcdi_logging); in efx_unregister_netdev()
2482 device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type); in efx_unregister_netdev()
2483 unregister_netdev(efx->net_dev); in efx_unregister_netdev()
2495 void efx_reset_down(struct efx_nic *efx, enum reset_type method) in efx_reset_down() argument
2497 EFX_ASSERT_RESET_SERIALISED(efx); in efx_reset_down()
2500 efx->type->prepare_flr(efx); in efx_reset_down()
2502 efx_stop_all(efx); in efx_reset_down()
2503 efx_disable_interrupts(efx); in efx_reset_down()
2505 mutex_lock(&efx->mac_lock); in efx_reset_down()
2506 if (efx->port_initialized && method != RESET_TYPE_INVISIBLE && in efx_reset_down()
2508 efx->phy_op->fini(efx); in efx_reset_down()
2509 efx->type->fini(efx); in efx_reset_down()
2517 int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok) in efx_reset_up() argument
2521 EFX_ASSERT_RESET_SERIALISED(efx); in efx_reset_up()
2524 efx->type->finish_flr(efx); in efx_reset_up()
2527 rc = efx->type->init(efx); in efx_reset_up()
2529 netif_err(efx, drv, efx->net_dev, "failed to initialise NIC\n"); in efx_reset_up()
2536 if (efx->port_initialized && method != RESET_TYPE_INVISIBLE && in efx_reset_up()
2538 rc = efx->phy_op->init(efx); in efx_reset_up()
2541 rc = efx->phy_op->reconfigure(efx); in efx_reset_up()
2543 netif_err(efx, drv, efx->net_dev, in efx_reset_up()
2547 rc = efx_enable_interrupts(efx); in efx_reset_up()
2552 rc = efx->type->vswitching_restore(efx); in efx_reset_up()
2554 netif_warn(efx, probe, efx->net_dev, in efx_reset_up()
2559 down_read(&efx->filter_sem); in efx_reset_up()
2560 efx_restore_filters(efx); in efx_reset_up()
2561 up_read(&efx->filter_sem); in efx_reset_up()
2562 if (efx->type->sriov_reset) in efx_reset_up()
2563 efx->type->sriov_reset(efx); in efx_reset_up()
2565 mutex_unlock(&efx->mac_lock); in efx_reset_up()
2567 efx_start_all(efx); in efx_reset_up()
2572 efx->port_initialized = false; in efx_reset_up()
2574 mutex_unlock(&efx->mac_lock); in efx_reset_up()
2584 int efx_reset(struct efx_nic *efx, enum reset_type method) in efx_reset() argument
2589 netif_info(efx, drv, efx->net_dev, "resetting (%s)\n", in efx_reset()
2592 efx_device_detach_sync(efx); in efx_reset()
2593 efx_reset_down(efx, method); in efx_reset()
2595 rc = efx->type->reset(efx, method); in efx_reset()
2597 netif_err(efx, drv, efx->net_dev, "failed to reset hardware\n"); in efx_reset()
2605 efx->reset_pending &= -(1 << (method + 1)); in efx_reset()
2607 __clear_bit(method, &efx->reset_pending); in efx_reset()
2613 pci_set_master(efx->pci_dev); in efx_reset()
2620 rc2 = efx_reset_up(efx, method, !disabled); in efx_reset()
2628 dev_close(efx->net_dev); in efx_reset()
2629 netif_err(efx, drv, efx->net_dev, "has been disabled\n"); in efx_reset()
2630 efx->state = STATE_DISABLED; in efx_reset()
2632 netif_dbg(efx, drv, efx->net_dev, "reset complete\n"); in efx_reset()
2633 netif_device_attach(efx->net_dev); in efx_reset()
2643 int efx_try_recovery(struct efx_nic *efx) in efx_try_recovery() argument
2651 struct eeh_dev *eehdev = pci_dev_to_eeh_dev(efx->pci_dev); in efx_try_recovery()
2662 static void efx_wait_for_bist_end(struct efx_nic *efx) in efx_wait_for_bist_end() argument
2667 if (efx_mcdi_poll_reboot(efx)) in efx_wait_for_bist_end()
2672 netif_err(efx, drv, efx->net_dev, "Warning: No MC reboot after BIST mode\n"); in efx_wait_for_bist_end()
2677 efx->mc_bist_for_other_fn = false; in efx_wait_for_bist_end()
2685 struct efx_nic *efx = container_of(data, struct efx_nic, reset_work); in efx_reset_work() local
2689 pending = ACCESS_ONCE(efx->reset_pending); in efx_reset_work()
2693 efx_wait_for_bist_end(efx); in efx_reset_work()
2697 efx_try_recovery(efx)) in efx_reset_work()
2709 if (efx->state == STATE_READY) in efx_reset_work()
2710 (void)efx_reset(efx, method); in efx_reset_work()
2715 void efx_schedule_reset(struct efx_nic *efx, enum reset_type type) in efx_schedule_reset() argument
2719 if (efx->state == STATE_RECOVERY) { in efx_schedule_reset()
2720 netif_dbg(efx, drv, efx->net_dev, in efx_schedule_reset()
2737 netif_dbg(efx, drv, efx->net_dev, "scheduling %s reset\n", in efx_schedule_reset()
2741 method = efx->type->map_reset_reason(type); in efx_schedule_reset()
2742 netif_dbg(efx, drv, efx->net_dev, in efx_schedule_reset()
2748 set_bit(method, &efx->reset_pending); in efx_schedule_reset()
2754 if (ACCESS_ONCE(efx->state) != STATE_READY) in efx_schedule_reset()
2759 efx_mcdi_mode_poll(efx); in efx_schedule_reset()
2761 queue_work(reset_workqueue, &efx->reset_work); in efx_schedule_reset()
2800 int efx_port_dummy_op_int(struct efx_nic *efx) in efx_port_dummy_op_int() argument
2804 void efx_port_dummy_op_void(struct efx_nic *efx) {} in efx_port_dummy_op_void() argument
2806 static bool efx_port_dummy_op_poll(struct efx_nic *efx) in efx_port_dummy_op_poll() argument
2827 static int efx_init_struct(struct efx_nic *efx, in efx_init_struct() argument
2833 INIT_LIST_HEAD(&efx->node); in efx_init_struct()
2834 INIT_LIST_HEAD(&efx->secondary_list); in efx_init_struct()
2835 spin_lock_init(&efx->biu_lock); in efx_init_struct()
2837 INIT_LIST_HEAD(&efx->mtd_list); in efx_init_struct()
2839 INIT_WORK(&efx->reset_work, efx_reset_work); in efx_init_struct()
2840 INIT_DELAYED_WORK(&efx->monitor_work, efx_monitor); in efx_init_struct()
2841 INIT_DELAYED_WORK(&efx->selftest_work, efx_selftest_async_work); in efx_init_struct()
2842 efx->pci_dev = pci_dev; in efx_init_struct()
2843 efx->msg_enable = debug; in efx_init_struct()
2844 efx->state = STATE_UNINIT; in efx_init_struct()
2845 strlcpy(efx->name, pci_name(pci_dev), sizeof(efx->name)); in efx_init_struct()
2847 efx->net_dev = net_dev; in efx_init_struct()
2848 efx->rx_prefix_size = efx->type->rx_prefix_size; in efx_init_struct()
2849 efx->rx_ip_align = in efx_init_struct()
2850 NET_IP_ALIGN ? (efx->rx_prefix_size + NET_IP_ALIGN) % 4 : 0; in efx_init_struct()
2851 efx->rx_packet_hash_offset = in efx_init_struct()
2852 efx->type->rx_hash_offset - efx->type->rx_prefix_size; in efx_init_struct()
2853 efx->rx_packet_ts_offset = in efx_init_struct()
2854 efx->type->rx_ts_offset - efx->type->rx_prefix_size; in efx_init_struct()
2855 spin_lock_init(&efx->stats_lock); in efx_init_struct()
2856 mutex_init(&efx->mac_lock); in efx_init_struct()
2857 efx->phy_op = &efx_dummy_phy_operations; in efx_init_struct()
2858 efx->mdio.dev = net_dev; in efx_init_struct()
2859 INIT_WORK(&efx->mac_work, efx_mac_work); in efx_init_struct()
2860 init_waitqueue_head(&efx->flush_wq); in efx_init_struct()
2863 efx->channel[i] = efx_alloc_channel(efx, i, NULL); in efx_init_struct()
2864 if (!efx->channel[i]) in efx_init_struct()
2866 efx->msi_context[i].efx = efx; in efx_init_struct()
2867 efx->msi_context[i].index = i; in efx_init_struct()
2871 efx->interrupt_mode = max(efx->type->max_interrupt_mode, in efx_init_struct()
2875 snprintf(efx->workqueue_name, sizeof(efx->workqueue_name), "sfc%s", in efx_init_struct()
2877 efx->workqueue = create_singlethread_workqueue(efx->workqueue_name); in efx_init_struct()
2878 if (!efx->workqueue) in efx_init_struct()
2884 efx_fini_struct(efx); in efx_init_struct()
2888 static void efx_fini_struct(struct efx_nic *efx) in efx_fini_struct() argument
2893 kfree(efx->channel[i]); in efx_fini_struct()
2895 kfree(efx->vpd_sn); in efx_fini_struct()
2897 if (efx->workqueue) { in efx_fini_struct()
2898 destroy_workqueue(efx->workqueue); in efx_fini_struct()
2899 efx->workqueue = NULL; in efx_fini_struct()
2903 void efx_update_sw_stats(struct efx_nic *efx, u64 *stats) in efx_update_sw_stats() argument
2908 efx_for_each_channel(channel, efx) in efx_update_sw_stats()
2911 stats[GENERIC_STAT_rx_noskb_drops] = atomic_read(&efx->n_rx_noskb_drops); in efx_update_sw_stats()
2923 static void efx_pci_remove_main(struct efx_nic *efx) in efx_pci_remove_main() argument
2928 BUG_ON(efx->state == STATE_READY); in efx_pci_remove_main()
2929 cancel_work_sync(&efx->reset_work); in efx_pci_remove_main()
2931 efx_disable_interrupts(efx); in efx_pci_remove_main()
2932 efx_nic_fini_interrupt(efx); in efx_pci_remove_main()
2933 efx_fini_port(efx); in efx_pci_remove_main()
2934 efx->type->fini(efx); in efx_pci_remove_main()
2935 efx_fini_napi(efx); in efx_pci_remove_main()
2936 efx_remove_all(efx); in efx_pci_remove_main()
2945 struct efx_nic *efx; in efx_pci_remove() local
2947 efx = pci_get_drvdata(pci_dev); in efx_pci_remove()
2948 if (!efx) in efx_pci_remove()
2953 efx_dissociate(efx); in efx_pci_remove()
2954 dev_close(efx->net_dev); in efx_pci_remove()
2955 efx_disable_interrupts(efx); in efx_pci_remove()
2956 efx->state = STATE_UNINIT; in efx_pci_remove()
2959 if (efx->type->sriov_fini) in efx_pci_remove()
2960 efx->type->sriov_fini(efx); in efx_pci_remove()
2962 efx_unregister_netdev(efx); in efx_pci_remove()
2964 efx_mtd_remove(efx); in efx_pci_remove()
2966 efx_pci_remove_main(efx); in efx_pci_remove()
2968 efx_fini_io(efx); in efx_pci_remove()
2969 netif_dbg(efx, drv, efx->net_dev, "shutdown successful\n"); in efx_pci_remove()
2971 efx_fini_struct(efx); in efx_pci_remove()
2972 free_netdev(efx->net_dev); in efx_pci_remove()
2983 static void efx_probe_vpd_strings(struct efx_nic *efx) in efx_probe_vpd_strings() argument
2985 struct pci_dev *dev = efx->pci_dev; in efx_probe_vpd_strings()
2993 netif_err(efx, drv, efx->net_dev, "Unable to read VPD\n"); in efx_probe_vpd_strings()
3000 netif_err(efx, drv, efx->net_dev, "VPD Read-only not found\n"); in efx_probe_vpd_strings()
3013 netif_err(efx, drv, efx->net_dev, "Part number not found\n"); in efx_probe_vpd_strings()
3020 netif_err(efx, drv, efx->net_dev, "Incomplete part number\n"); in efx_probe_vpd_strings()
3024 netif_info(efx, drv, efx->net_dev, in efx_probe_vpd_strings()
3031 netif_err(efx, drv, efx->net_dev, "Serial number not found\n"); in efx_probe_vpd_strings()
3038 netif_err(efx, drv, efx->net_dev, "Incomplete serial number\n"); in efx_probe_vpd_strings()
3042 efx->vpd_sn = kmalloc(j + 1, GFP_KERNEL); in efx_probe_vpd_strings()
3043 if (!efx->vpd_sn) in efx_probe_vpd_strings()
3046 snprintf(efx->vpd_sn, j + 1, "%s", &vpd_data[i]); in efx_probe_vpd_strings()
3053 static int efx_pci_probe_main(struct efx_nic *efx) in efx_pci_probe_main() argument
3058 rc = efx_probe_all(efx); in efx_pci_probe_main()
3062 efx_init_napi(efx); in efx_pci_probe_main()
3064 rc = efx->type->init(efx); in efx_pci_probe_main()
3066 netif_err(efx, probe, efx->net_dev, in efx_pci_probe_main()
3071 rc = efx_init_port(efx); in efx_pci_probe_main()
3073 netif_err(efx, probe, efx->net_dev, in efx_pci_probe_main()
3078 rc = efx_nic_init_interrupt(efx); in efx_pci_probe_main()
3081 rc = efx_enable_interrupts(efx); in efx_pci_probe_main()
3088 efx_nic_fini_interrupt(efx); in efx_pci_probe_main()
3090 efx_fini_port(efx); in efx_pci_probe_main()
3092 efx->type->fini(efx); in efx_pci_probe_main()
3094 efx_fini_napi(efx); in efx_pci_probe_main()
3095 efx_remove_all(efx); in efx_pci_probe_main()
3113 struct efx_nic *efx; in efx_pci_probe() local
3117 net_dev = alloc_etherdev_mqs(sizeof(*efx), EFX_MAX_CORE_TX_QUEUES, in efx_pci_probe()
3121 efx = netdev_priv(net_dev); in efx_pci_probe()
3122 efx->type = (const struct efx_nic_type *) entry->driver_data; in efx_pci_probe()
3123 net_dev->features |= (efx->type->offload_features | NETIF_F_SG | in efx_pci_probe()
3126 if (efx->type->offload_features & NETIF_F_V6_CSUM) in efx_pci_probe()
3134 pci_set_drvdata(pci_dev, efx); in efx_pci_probe()
3136 rc = efx_init_struct(efx, pci_dev, net_dev); in efx_pci_probe()
3140 netif_info(efx, probe, efx->net_dev, in efx_pci_probe()
3143 if (!efx->type->is_vf) in efx_pci_probe()
3144 efx_probe_vpd_strings(efx); in efx_pci_probe()
3147 rc = efx_init_io(efx); in efx_pci_probe()
3151 rc = efx_pci_probe_main(efx); in efx_pci_probe()
3155 rc = efx_register_netdev(efx); in efx_pci_probe()
3159 if (efx->type->sriov_init) { in efx_pci_probe()
3160 rc = efx->type->sriov_init(efx); in efx_pci_probe()
3162 netif_err(efx, probe, efx->net_dev, in efx_pci_probe()
3166 netif_dbg(efx, probe, efx->net_dev, "initialisation successful\n"); in efx_pci_probe()
3170 rc = efx_mtd_probe(efx); in efx_pci_probe()
3173 netif_warn(efx, probe, efx->net_dev, in efx_pci_probe()
3178 netif_warn(efx, probe, efx->net_dev, in efx_pci_probe()
3184 efx_pci_remove_main(efx); in efx_pci_probe()
3186 efx_fini_io(efx); in efx_pci_probe()
3188 efx_fini_struct(efx); in efx_pci_probe()
3191 netif_dbg(efx, drv, efx->net_dev, "initialisation failed. rc=%d\n", rc); in efx_pci_probe()
3203 struct efx_nic *efx = pci_get_drvdata(dev); in efx_pci_sriov_configure() local
3205 if (efx->type->sriov_configure) { in efx_pci_sriov_configure()
3206 rc = efx->type->sriov_configure(efx, num_vfs); in efx_pci_sriov_configure()
3218 struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); in efx_pm_freeze() local
3222 if (efx->state != STATE_DISABLED) { in efx_pm_freeze()
3223 efx->state = STATE_UNINIT; in efx_pm_freeze()
3225 efx_device_detach_sync(efx); in efx_pm_freeze()
3227 efx_stop_all(efx); in efx_pm_freeze()
3228 efx_disable_interrupts(efx); in efx_pm_freeze()
3239 struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); in efx_pm_thaw() local
3243 if (efx->state != STATE_DISABLED) { in efx_pm_thaw()
3244 rc = efx_enable_interrupts(efx); in efx_pm_thaw()
3248 mutex_lock(&efx->mac_lock); in efx_pm_thaw()
3249 efx->phy_op->reconfigure(efx); in efx_pm_thaw()
3250 mutex_unlock(&efx->mac_lock); in efx_pm_thaw()
3252 efx_start_all(efx); in efx_pm_thaw()
3254 netif_device_attach(efx->net_dev); in efx_pm_thaw()
3256 efx->state = STATE_READY; in efx_pm_thaw()
3258 efx->type->resume_wol(efx); in efx_pm_thaw()
3264 queue_work(reset_workqueue, &efx->reset_work); in efx_pm_thaw()
3277 struct efx_nic *efx = pci_get_drvdata(pci_dev); in efx_pm_poweroff() local
3279 efx->type->fini(efx); in efx_pm_poweroff()
3281 efx->reset_pending = 0; in efx_pm_poweroff()
3291 struct efx_nic *efx = pci_get_drvdata(pci_dev); in efx_pm_resume() local
3301 pci_set_master(efx->pci_dev); in efx_pm_resume()
3302 rc = efx->type->reset(efx, RESET_TYPE_ALL); in efx_pm_resume()
3305 rc = efx->type->init(efx); in efx_pm_resume()
3340 struct efx_nic *efx = pci_get_drvdata(pdev); in efx_io_error_detected() local
3347 if (efx->state != STATE_DISABLED) { in efx_io_error_detected()
3348 efx->state = STATE_RECOVERY; in efx_io_error_detected()
3349 efx->reset_pending = 0; in efx_io_error_detected()
3351 efx_device_detach_sync(efx); in efx_io_error_detected()
3353 efx_stop_all(efx); in efx_io_error_detected()
3354 efx_disable_interrupts(efx); in efx_io_error_detected()
3374 struct efx_nic *efx = pci_get_drvdata(pdev); in efx_io_slot_reset() local
3379 netif_err(efx, hw, efx->net_dev, in efx_io_slot_reset()
3386 netif_err(efx, hw, efx->net_dev, in efx_io_slot_reset()
3397 struct efx_nic *efx = pci_get_drvdata(pdev); in efx_io_resume() local
3402 if (efx->state == STATE_DISABLED) in efx_io_resume()
3405 rc = efx_reset(efx, RESET_TYPE_ALL); in efx_io_resume()
3407 netif_err(efx, hw, efx->net_dev, in efx_io_resume()
3410 efx->state = STATE_READY; in efx_io_resume()
3411 netif_dbg(efx, hw, efx->net_dev, in efx_io_resume()