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()
510 netif_dbg(channel->efx, probe, channel->efx->net_dev, in efx_probe_channel()
543 struct efx_nic *efx = channel->efx; in efx_get_channel_name() local
548 if (efx->tx_channel_offset == 0) { in efx_get_channel_name()
550 } else if (channel->channel < efx->tx_channel_offset) { in efx_get_channel_name()
554 number -= efx->tx_channel_offset; in efx_get_channel_name()
556 snprintf(buf, len, "%s%s-%d", efx->name, type, number); in efx_get_channel_name()
559 static void efx_set_channel_names(struct efx_nic *efx) in efx_set_channel_names() argument
563 efx_for_each_channel(channel, efx) in efx_set_channel_names()
565 efx->msi_context[channel->channel].name, in efx_set_channel_names()
566 sizeof(efx->msi_context[0].name)); in efx_set_channel_names()
569 static int efx_probe_channels(struct efx_nic *efx) in efx_probe_channels() argument
575 efx->next_buffer_table = 0; in efx_probe_channels()
582 efx_for_each_channel_rev(channel, efx) { in efx_probe_channels()
585 netif_err(efx, probe, efx->net_dev, in efx_probe_channels()
591 efx_set_channel_names(efx); in efx_probe_channels()
596 efx_remove_channels(efx); in efx_probe_channels()
604 static void efx_start_datapath(struct efx_nic *efx) in efx_start_datapath() argument
606 bool old_rx_scatter = efx->rx_scatter; in efx_start_datapath()
616 efx->rx_dma_len = (efx->rx_prefix_size + in efx_start_datapath()
617 EFX_MAX_FRAME_LEN(efx->net_dev->mtu) + in efx_start_datapath()
618 efx->type->rx_buffer_padding); in efx_start_datapath()
620 efx->rx_ip_align + efx->rx_dma_len); in efx_start_datapath()
622 efx->rx_scatter = efx->type->always_rx_scatter; in efx_start_datapath()
623 efx->rx_buffer_order = 0; in efx_start_datapath()
624 } else if (efx->type->can_rx_scatter) { in efx_start_datapath()
630 efx->rx_scatter = true; in efx_start_datapath()
631 efx->rx_dma_len = EFX_RX_USR_BUF_SIZE; in efx_start_datapath()
632 efx->rx_buffer_order = 0; in efx_start_datapath()
634 efx->rx_scatter = false; in efx_start_datapath()
635 efx->rx_buffer_order = get_order(rx_buf_len); in efx_start_datapath()
638 efx_rx_config_page_split(efx); in efx_start_datapath()
639 if (efx->rx_buffer_order) in efx_start_datapath()
640 netif_dbg(efx, drv, efx->net_dev, in efx_start_datapath()
642 efx->rx_dma_len, efx->rx_buffer_order, in efx_start_datapath()
643 efx->rx_pages_per_batch); in efx_start_datapath()
645 netif_dbg(efx, drv, efx->net_dev, in efx_start_datapath()
647 efx->rx_dma_len, efx->rx_page_buf_step, in efx_start_datapath()
648 efx->rx_bufs_per_page, efx->rx_pages_per_batch); in efx_start_datapath()
651 if (efx->rx_scatter != old_rx_scatter) in efx_start_datapath()
652 efx->type->filter_update_rx_scatter(efx); in efx_start_datapath()
661 efx->txq_stop_thresh = efx->txq_entries - efx_tx_max_skb_descs(efx); in efx_start_datapath()
662 efx->txq_wake_thresh = efx->txq_stop_thresh / 2; in efx_start_datapath()
665 efx_for_each_channel(channel, efx) { in efx_start_datapath()
668 atomic_inc(&efx->active_queues); in efx_start_datapath()
673 atomic_inc(&efx->active_queues); in efx_start_datapath()
682 efx_ptp_start_datapath(efx); in efx_start_datapath()
684 if (netif_device_present(efx->net_dev)) in efx_start_datapath()
685 netif_tx_wake_all_queues(efx->net_dev); in efx_start_datapath()
688 static void efx_stop_datapath(struct efx_nic *efx) in efx_stop_datapath() argument
695 EFX_ASSERT_RESET_SERIALISED(efx); in efx_stop_datapath()
696 BUG_ON(efx->port_enabled); in efx_stop_datapath()
698 efx_ptp_stop_datapath(efx); in efx_stop_datapath()
701 efx_for_each_channel(channel, efx) { in efx_stop_datapath()
706 efx_for_each_channel(channel, efx) { in efx_stop_datapath()
719 rc = efx->type->fini_dmaq(efx); in efx_stop_datapath()
720 if (rc && EFX_WORKAROUND_7803(efx)) { in efx_stop_datapath()
726 netif_err(efx, drv, efx->net_dev, in efx_stop_datapath()
728 efx_schedule_reset(efx, RESET_TYPE_ALL); in efx_stop_datapath()
730 netif_err(efx, drv, efx->net_dev, "failed to flush queues\n"); in efx_stop_datapath()
732 netif_dbg(efx, drv, efx->net_dev, in efx_stop_datapath()
736 efx_for_each_channel(channel, efx) { in efx_stop_datapath()
749 netif_dbg(channel->efx, drv, channel->efx->net_dev, in efx_remove_channel()
760 static void efx_remove_channels(struct efx_nic *efx) in efx_remove_channels() argument
764 efx_for_each_channel(channel, efx) in efx_remove_channels()
769 efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries) in efx_realloc_channels() argument
776 rc = efx_check_disabled(efx); in efx_realloc_channels()
783 efx_for_each_channel(channel, efx) { in efx_realloc_channels()
802 efx_device_detach_sync(efx); in efx_realloc_channels()
803 efx_stop_all(efx); in efx_realloc_channels()
804 efx_soft_disable_interrupts(efx); in efx_realloc_channels()
808 for (i = 0; i < efx->n_channels; i++) { in efx_realloc_channels()
809 channel = efx->channel[i]; in efx_realloc_channels()
820 old_rxq_entries = efx->rxq_entries; in efx_realloc_channels()
821 old_txq_entries = efx->txq_entries; in efx_realloc_channels()
822 efx->rxq_entries = rxq_entries; in efx_realloc_channels()
823 efx->txq_entries = txq_entries; in efx_realloc_channels()
824 for (i = 0; i < efx->n_channels; i++) { in efx_realloc_channels()
825 channel = efx->channel[i]; in efx_realloc_channels()
826 efx->channel[i] = other_channel[i]; in efx_realloc_channels()
831 efx->next_buffer_table = next_buffer_table; in efx_realloc_channels()
833 for (i = 0; i < efx->n_channels; i++) { in efx_realloc_channels()
834 channel = efx->channel[i]; in efx_realloc_channels()
840 efx_init_napi_channel(efx->channel[i]); in efx_realloc_channels()
845 for (i = 0; i < efx->n_channels; i++) { in efx_realloc_channels()
854 rc2 = efx_soft_enable_interrupts(efx); in efx_realloc_channels()
857 netif_err(efx, drv, efx->net_dev, in efx_realloc_channels()
859 efx_schedule_reset(efx, RESET_TYPE_DISABLE); in efx_realloc_channels()
861 efx_start_all(efx); in efx_realloc_channels()
862 netif_device_attach(efx->net_dev); in efx_realloc_channels()
868 efx->rxq_entries = old_rxq_entries; in efx_realloc_channels()
869 efx->txq_entries = old_txq_entries; in efx_realloc_channels()
870 for (i = 0; i < efx->n_channels; i++) { in efx_realloc_channels()
871 channel = efx->channel[i]; in efx_realloc_channels()
872 efx->channel[i] = other_channel[i]; in efx_realloc_channels()
910 void efx_link_status_changed(struct efx_nic *efx) in efx_link_status_changed() argument
912 struct efx_link_state *link_state = &efx->link_state; in efx_link_status_changed()
918 if (!netif_running(efx->net_dev)) in efx_link_status_changed()
921 if (link_state->up != netif_carrier_ok(efx->net_dev)) { in efx_link_status_changed()
922 efx->n_link_state_changes++; in efx_link_status_changed()
925 netif_carrier_on(efx->net_dev); in efx_link_status_changed()
927 netif_carrier_off(efx->net_dev); in efx_link_status_changed()
932 netif_info(efx, link, efx->net_dev, in efx_link_status_changed()
935 efx->net_dev->mtu); in efx_link_status_changed()
937 netif_info(efx, link, efx->net_dev, "link down\n"); in efx_link_status_changed()
940 void efx_link_set_advertising(struct efx_nic *efx, u32 advertising) in efx_link_set_advertising() argument
942 efx->link_advertising = advertising; in efx_link_set_advertising()
945 efx->wanted_fc |= (EFX_FC_TX | EFX_FC_RX); in efx_link_set_advertising()
947 efx->wanted_fc &= ~(EFX_FC_TX | EFX_FC_RX); in efx_link_set_advertising()
949 efx->wanted_fc ^= EFX_FC_TX; in efx_link_set_advertising()
953 void efx_link_set_wanted_fc(struct efx_nic *efx, u8 wanted_fc) in efx_link_set_wanted_fc() argument
955 efx->wanted_fc = wanted_fc; in efx_link_set_wanted_fc()
956 if (efx->link_advertising) { in efx_link_set_wanted_fc()
958 efx->link_advertising |= (ADVERTISED_Pause | in efx_link_set_wanted_fc()
961 efx->link_advertising &= ~(ADVERTISED_Pause | in efx_link_set_wanted_fc()
964 efx->link_advertising ^= ADVERTISED_Asym_Pause; in efx_link_set_wanted_fc()
968 static void efx_fini_port(struct efx_nic *efx);
973 void efx_mac_reconfigure(struct efx_nic *efx) in efx_mac_reconfigure() argument
975 down_read(&efx->filter_sem); in efx_mac_reconfigure()
976 efx->type->reconfigure_mac(efx); in efx_mac_reconfigure()
977 up_read(&efx->filter_sem); in efx_mac_reconfigure()
987 int __efx_reconfigure_port(struct efx_nic *efx) in __efx_reconfigure_port() argument
992 WARN_ON(!mutex_is_locked(&efx->mac_lock)); in __efx_reconfigure_port()
995 phy_mode = efx->phy_mode; in __efx_reconfigure_port()
996 if (LOOPBACK_INTERNAL(efx)) in __efx_reconfigure_port()
997 efx->phy_mode |= PHY_MODE_TX_DISABLED; in __efx_reconfigure_port()
999 efx->phy_mode &= ~PHY_MODE_TX_DISABLED; in __efx_reconfigure_port()
1001 rc = efx->type->reconfigure_port(efx); in __efx_reconfigure_port()
1004 efx->phy_mode = phy_mode; in __efx_reconfigure_port()
1011 int efx_reconfigure_port(struct efx_nic *efx) in efx_reconfigure_port() argument
1015 EFX_ASSERT_RESET_SERIALISED(efx); in efx_reconfigure_port()
1017 mutex_lock(&efx->mac_lock); in efx_reconfigure_port()
1018 rc = __efx_reconfigure_port(efx); in efx_reconfigure_port()
1019 mutex_unlock(&efx->mac_lock); in efx_reconfigure_port()
1029 struct efx_nic *efx = container_of(data, struct efx_nic, mac_work); in efx_mac_work() local
1031 mutex_lock(&efx->mac_lock); in efx_mac_work()
1032 if (efx->port_enabled) in efx_mac_work()
1033 efx_mac_reconfigure(efx); in efx_mac_work()
1034 mutex_unlock(&efx->mac_lock); in efx_mac_work()
1037 static int efx_probe_port(struct efx_nic *efx) in efx_probe_port() argument
1041 netif_dbg(efx, probe, efx->net_dev, "create port\n"); in efx_probe_port()
1044 efx->phy_mode = PHY_MODE_SPECIAL; in efx_probe_port()
1047 rc = efx->type->probe_port(efx); in efx_probe_port()
1052 ether_addr_copy(efx->net_dev->dev_addr, efx->net_dev->perm_addr); in efx_probe_port()
1057 static int efx_init_port(struct efx_nic *efx) in efx_init_port() argument
1061 netif_dbg(efx, drv, efx->net_dev, "init port\n"); in efx_init_port()
1063 mutex_lock(&efx->mac_lock); in efx_init_port()
1065 rc = efx->phy_op->init(efx); in efx_init_port()
1069 efx->port_initialized = true; in efx_init_port()
1073 efx_mac_reconfigure(efx); in efx_init_port()
1076 rc = efx->phy_op->reconfigure(efx); in efx_init_port()
1080 mutex_unlock(&efx->mac_lock); in efx_init_port()
1084 efx->phy_op->fini(efx); in efx_init_port()
1086 mutex_unlock(&efx->mac_lock); in efx_init_port()
1090 static void efx_start_port(struct efx_nic *efx) in efx_start_port() argument
1092 netif_dbg(efx, ifup, efx->net_dev, "start port\n"); in efx_start_port()
1093 BUG_ON(efx->port_enabled); in efx_start_port()
1095 mutex_lock(&efx->mac_lock); in efx_start_port()
1096 efx->port_enabled = true; in efx_start_port()
1099 efx_mac_reconfigure(efx); in efx_start_port()
1101 mutex_unlock(&efx->mac_lock); in efx_start_port()
1109 static void efx_stop_port(struct efx_nic *efx) in efx_stop_port() argument
1111 netif_dbg(efx, ifdown, efx->net_dev, "stop port\n"); in efx_stop_port()
1113 EFX_ASSERT_RESET_SERIALISED(efx); in efx_stop_port()
1115 mutex_lock(&efx->mac_lock); in efx_stop_port()
1116 efx->port_enabled = false; in efx_stop_port()
1117 mutex_unlock(&efx->mac_lock); in efx_stop_port()
1120 netif_addr_lock_bh(efx->net_dev); in efx_stop_port()
1121 netif_addr_unlock_bh(efx->net_dev); in efx_stop_port()
1123 cancel_delayed_work_sync(&efx->monitor_work); in efx_stop_port()
1124 efx_selftest_async_cancel(efx); in efx_stop_port()
1125 cancel_work_sync(&efx->mac_work); in efx_stop_port()
1128 static void efx_fini_port(struct efx_nic *efx) in efx_fini_port() argument
1130 netif_dbg(efx, drv, efx->net_dev, "shut down port\n"); in efx_fini_port()
1132 if (!efx->port_initialized) in efx_fini_port()
1135 efx->phy_op->fini(efx); in efx_fini_port()
1136 efx->port_initialized = false; in efx_fini_port()
1138 efx->link_state.up = false; in efx_fini_port()
1139 efx_link_status_changed(efx); in efx_fini_port()
1142 static void efx_remove_port(struct efx_nic *efx) in efx_remove_port() argument
1144 netif_dbg(efx, drv, efx->net_dev, "destroying port\n"); in efx_remove_port()
1146 efx->type->remove_port(efx); in efx_remove_port()
1165 static void efx_associate(struct efx_nic *efx) in efx_associate() argument
1169 if (efx->primary == efx) { in efx_associate()
1172 netif_dbg(efx, probe, efx->net_dev, "adding to primary list\n"); in efx_associate()
1173 list_add_tail(&efx->node, &efx_primary_list); in efx_associate()
1177 if (efx_same_controller(efx, other)) { in efx_associate()
1181 pci_name(efx->pci_dev), in efx_associate()
1182 efx->net_dev->name); in efx_associate()
1184 &efx->secondary_list); in efx_associate()
1185 other->primary = efx; in efx_associate()
1192 if (efx_same_controller(efx, other)) { in efx_associate()
1193 netif_dbg(efx, probe, efx->net_dev, in efx_associate()
1197 list_add_tail(&efx->node, in efx_associate()
1199 efx->primary = other; in efx_associate()
1204 netif_dbg(efx, probe, efx->net_dev, in efx_associate()
1206 list_add_tail(&efx->node, &efx_unassociated_list); in efx_associate()
1210 static void efx_dissociate(struct efx_nic *efx) in efx_dissociate() argument
1214 list_del(&efx->node); in efx_dissociate()
1215 efx->primary = NULL; in efx_dissociate()
1217 list_for_each_entry_safe(other, next, &efx->secondary_list, node) { in efx_dissociate()
1227 static int efx_init_io(struct efx_nic *efx) in efx_init_io() argument
1229 struct pci_dev *pci_dev = efx->pci_dev; in efx_init_io()
1230 dma_addr_t dma_mask = efx->type->max_dma_mask; in efx_init_io()
1231 unsigned int mem_map_size = efx->type->mem_map_size(efx); in efx_init_io()
1234 netif_dbg(efx, probe, efx->net_dev, "initialising I/O\n"); in efx_init_io()
1236 bar = efx->type->mem_bar; in efx_init_io()
1240 netif_err(efx, probe, efx->net_dev, in efx_init_io()
1259 netif_err(efx, probe, efx->net_dev, in efx_init_io()
1263 netif_dbg(efx, probe, efx->net_dev, in efx_init_io()
1266 efx->membase_phys = pci_resource_start(efx->pci_dev, bar); in efx_init_io()
1269 netif_err(efx, probe, efx->net_dev, in efx_init_io()
1274 efx->membase = ioremap_nocache(efx->membase_phys, mem_map_size); in efx_init_io()
1275 if (!efx->membase) { in efx_init_io()
1276 netif_err(efx, probe, efx->net_dev, in efx_init_io()
1278 (unsigned long long)efx->membase_phys, mem_map_size); in efx_init_io()
1282 netif_dbg(efx, probe, efx->net_dev, in efx_init_io()
1284 (unsigned long long)efx->membase_phys, mem_map_size, in efx_init_io()
1285 efx->membase); in efx_init_io()
1290 pci_release_region(efx->pci_dev, bar); in efx_init_io()
1292 efx->membase_phys = 0; in efx_init_io()
1294 pci_disable_device(efx->pci_dev); in efx_init_io()
1299 static void efx_fini_io(struct efx_nic *efx) in efx_fini_io() argument
1303 netif_dbg(efx, drv, efx->net_dev, "shutting down I/O\n"); in efx_fini_io()
1305 if (efx->membase) { in efx_fini_io()
1306 iounmap(efx->membase); in efx_fini_io()
1307 efx->membase = NULL; in efx_fini_io()
1310 if (efx->membase_phys) { in efx_fini_io()
1311 bar = efx->type->mem_bar; in efx_fini_io()
1312 pci_release_region(efx->pci_dev, bar); in efx_fini_io()
1313 efx->membase_phys = 0; in efx_fini_io()
1317 if (!pci_vfs_assigned(efx->pci_dev)) in efx_fini_io()
1318 pci_disable_device(efx->pci_dev); in efx_fini_io()
1321 void efx_set_default_rx_indir_table(struct efx_nic *efx) in efx_set_default_rx_indir_table() argument
1325 for (i = 0; i < ARRAY_SIZE(efx->rx_indir_table); i++) in efx_set_default_rx_indir_table()
1326 efx->rx_indir_table[i] = in efx_set_default_rx_indir_table()
1327 ethtool_rxfh_indir_default(i, efx->rss_spread); in efx_set_default_rx_indir_table()
1330 static unsigned int efx_wanted_parallelism(struct efx_nic *efx) in efx_wanted_parallelism() argument
1340 netif_warn(efx, probe, efx->net_dev, in efx_wanted_parallelism()
1361 if (efx->type->sriov_wanted) { in efx_wanted_parallelism()
1362 if (efx->type->sriov_wanted(efx) && efx_vf_size(efx) > 1 && in efx_wanted_parallelism()
1363 count > efx_vf_size(efx)) { in efx_wanted_parallelism()
1364 netif_warn(efx, probe, efx->net_dev, in efx_wanted_parallelism()
1368 count, efx_vf_size(efx)); in efx_wanted_parallelism()
1369 count = efx_vf_size(efx); in efx_wanted_parallelism()
1380 static int efx_probe_interrupts(struct efx_nic *efx) in efx_probe_interrupts() argument
1387 if (efx->extra_channel_type[i]) in efx_probe_interrupts()
1390 if (efx->interrupt_mode == EFX_INT_MODE_MSIX) { in efx_probe_interrupts()
1394 n_channels = efx_wanted_parallelism(efx); in efx_probe_interrupts()
1398 n_channels = min(n_channels, efx->max_channels); in efx_probe_interrupts()
1402 rc = pci_enable_msix_range(efx->pci_dev, in efx_probe_interrupts()
1406 efx->interrupt_mode = EFX_INT_MODE_MSI; 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()
1413 netif_err(efx, drv, efx->net_dev, in efx_probe_interrupts()
1419 efx->n_channels = n_channels; in efx_probe_interrupts()
1423 efx->n_tx_channels = min(max(n_channels / 2, in efx_probe_interrupts()
1425 efx->max_tx_channels); in efx_probe_interrupts()
1426 efx->n_rx_channels = max(n_channels - in efx_probe_interrupts()
1427 efx->n_tx_channels, in efx_probe_interrupts()
1430 efx->n_tx_channels = min(n_channels, in efx_probe_interrupts()
1431 efx->max_tx_channels); in efx_probe_interrupts()
1432 efx->n_rx_channels = n_channels; in efx_probe_interrupts()
1434 for (i = 0; i < efx->n_channels; i++) in efx_probe_interrupts()
1435 efx_get_channel(efx, i)->irq = in efx_probe_interrupts()
1441 if (efx->interrupt_mode == EFX_INT_MODE_MSI) { in efx_probe_interrupts()
1442 efx->n_channels = 1; in efx_probe_interrupts()
1443 efx->n_rx_channels = 1; in efx_probe_interrupts()
1444 efx->n_tx_channels = 1; in efx_probe_interrupts()
1445 rc = pci_enable_msi(efx->pci_dev); in efx_probe_interrupts()
1447 efx_get_channel(efx, 0)->irq = efx->pci_dev->irq; in efx_probe_interrupts()
1449 netif_err(efx, drv, efx->net_dev, in efx_probe_interrupts()
1451 efx->interrupt_mode = EFX_INT_MODE_LEGACY; in efx_probe_interrupts()
1456 if (efx->interrupt_mode == EFX_INT_MODE_LEGACY) { in efx_probe_interrupts()
1457 efx->n_channels = 1 + (efx_separate_tx_channels ? 1 : 0); in efx_probe_interrupts()
1458 efx->n_rx_channels = 1; in efx_probe_interrupts()
1459 efx->n_tx_channels = 1; in efx_probe_interrupts()
1460 efx->legacy_irq = efx->pci_dev->irq; in efx_probe_interrupts()
1464 j = efx->n_channels; in efx_probe_interrupts()
1466 if (!efx->extra_channel_type[i]) in efx_probe_interrupts()
1468 if (efx->interrupt_mode != EFX_INT_MODE_MSIX || in efx_probe_interrupts()
1469 efx->n_channels <= extra_channels) { in efx_probe_interrupts()
1470 efx->extra_channel_type[i]->handle_no_channel(efx); in efx_probe_interrupts()
1473 efx_get_channel(efx, j)->type = in efx_probe_interrupts()
1474 efx->extra_channel_type[i]; in efx_probe_interrupts()
1480 if (efx->type->sriov_wanted) { in efx_probe_interrupts()
1481 efx->rss_spread = ((efx->n_rx_channels > 1 || in efx_probe_interrupts()
1482 !efx->type->sriov_wanted(efx)) ? in efx_probe_interrupts()
1483 efx->n_rx_channels : efx_vf_size(efx)); in efx_probe_interrupts()
1487 efx->rss_spread = efx->n_rx_channels; in efx_probe_interrupts()
1492 static int efx_soft_enable_interrupts(struct efx_nic *efx) in efx_soft_enable_interrupts() argument
1497 BUG_ON(efx->state == STATE_DISABLED); in efx_soft_enable_interrupts()
1499 efx->irq_soft_enabled = true; in efx_soft_enable_interrupts()
1502 efx_for_each_channel(channel, efx) { in efx_soft_enable_interrupts()
1511 efx_mcdi_mode_event(efx); in efx_soft_enable_interrupts()
1516 efx_for_each_channel(channel, efx) { in efx_soft_enable_interrupts()
1527 static void efx_soft_disable_interrupts(struct efx_nic *efx) in efx_soft_disable_interrupts() argument
1531 if (efx->state == STATE_DISABLED) in efx_soft_disable_interrupts()
1534 efx_mcdi_mode_poll(efx); in efx_soft_disable_interrupts()
1536 efx->irq_soft_enabled = false; in efx_soft_disable_interrupts()
1539 if (efx->legacy_irq) in efx_soft_disable_interrupts()
1540 synchronize_irq(efx->legacy_irq); in efx_soft_disable_interrupts()
1542 efx_for_each_channel(channel, efx) { in efx_soft_disable_interrupts()
1552 efx_mcdi_flush_async(efx); in efx_soft_disable_interrupts()
1555 static int efx_enable_interrupts(struct efx_nic *efx) in efx_enable_interrupts() argument
1560 BUG_ON(efx->state == STATE_DISABLED); in efx_enable_interrupts()
1562 if (efx->eeh_disabled_legacy_irq) { in efx_enable_interrupts()
1563 enable_irq(efx->legacy_irq); in efx_enable_interrupts()
1564 efx->eeh_disabled_legacy_irq = false; in efx_enable_interrupts()
1567 efx->type->irq_enable_master(efx); in efx_enable_interrupts()
1569 efx_for_each_channel(channel, efx) { in efx_enable_interrupts()
1577 rc = efx_soft_enable_interrupts(efx); in efx_enable_interrupts()
1585 efx_for_each_channel(channel, efx) { in efx_enable_interrupts()
1592 efx->type->irq_disable_non_ev(efx); in efx_enable_interrupts()
1597 static void efx_disable_interrupts(struct efx_nic *efx) in efx_disable_interrupts() argument
1601 efx_soft_disable_interrupts(efx); in efx_disable_interrupts()
1603 efx_for_each_channel(channel, efx) { in efx_disable_interrupts()
1608 efx->type->irq_disable_non_ev(efx); in efx_disable_interrupts()
1611 static void efx_remove_interrupts(struct efx_nic *efx) in efx_remove_interrupts() argument
1616 efx_for_each_channel(channel, efx) in efx_remove_interrupts()
1618 pci_disable_msi(efx->pci_dev); in efx_remove_interrupts()
1619 pci_disable_msix(efx->pci_dev); in efx_remove_interrupts()
1622 efx->legacy_irq = 0; in efx_remove_interrupts()
1625 static void efx_set_channels(struct efx_nic *efx) in efx_set_channels() argument
1630 efx->tx_channel_offset = in efx_set_channels()
1632 efx->n_channels - efx->n_tx_channels : 0; in efx_set_channels()
1638 efx_for_each_channel(channel, efx) { in efx_set_channels()
1639 if (channel->channel < efx->n_rx_channels) in efx_set_channels()
1645 tx_queue->queue -= (efx->tx_channel_offset * in efx_set_channels()
1650 static int efx_probe_nic(struct efx_nic *efx) in efx_probe_nic() argument
1654 netif_dbg(efx, probe, efx->net_dev, "creating NIC\n"); in efx_probe_nic()
1657 rc = efx->type->probe(efx); in efx_probe_nic()
1662 if (!efx->max_channels || !efx->max_tx_channels) { in efx_probe_nic()
1663 netif_err(efx, drv, efx->net_dev, in efx_probe_nic()
1673 rc = efx_probe_interrupts(efx); in efx_probe_nic()
1677 efx_set_channels(efx); in efx_probe_nic()
1680 rc = efx->type->dimension_resources(efx); in efx_probe_nic()
1686 efx_remove_interrupts(efx); in efx_probe_nic()
1690 if (efx->n_channels > 1) in efx_probe_nic()
1691 netdev_rss_key_fill(&efx->rx_hash_key, in efx_probe_nic()
1692 sizeof(efx->rx_hash_key)); in efx_probe_nic()
1693 efx_set_default_rx_indir_table(efx); in efx_probe_nic()
1695 netif_set_real_num_tx_queues(efx->net_dev, efx->n_tx_channels); in efx_probe_nic()
1696 netif_set_real_num_rx_queues(efx->net_dev, efx->n_rx_channels); in efx_probe_nic()
1699 efx_init_irq_moderation(efx, tx_irq_mod_usec, rx_irq_mod_usec, true, in efx_probe_nic()
1705 efx_remove_interrupts(efx); in efx_probe_nic()
1707 efx->type->remove(efx); in efx_probe_nic()
1711 static void efx_remove_nic(struct efx_nic *efx) in efx_remove_nic() argument
1713 netif_dbg(efx, drv, efx->net_dev, "destroying NIC\n"); in efx_remove_nic()
1715 efx_remove_interrupts(efx); in efx_remove_nic()
1716 efx->type->remove(efx); in efx_remove_nic()
1719 static int efx_probe_filters(struct efx_nic *efx) in efx_probe_filters() argument
1723 spin_lock_init(&efx->filter_lock); in efx_probe_filters()
1724 init_rwsem(&efx->filter_sem); in efx_probe_filters()
1725 down_write(&efx->filter_sem); in efx_probe_filters()
1726 rc = efx->type->filter_table_probe(efx); in efx_probe_filters()
1731 if (efx->type->offload_features & NETIF_F_NTUPLE) { in efx_probe_filters()
1732 efx->rps_flow_id = kcalloc(efx->type->max_rx_ip_filters, in efx_probe_filters()
1733 sizeof(*efx->rps_flow_id), in efx_probe_filters()
1735 if (!efx->rps_flow_id) { in efx_probe_filters()
1736 efx->type->filter_table_remove(efx); in efx_probe_filters()
1743 up_write(&efx->filter_sem); in efx_probe_filters()
1747 static void efx_remove_filters(struct efx_nic *efx) in efx_remove_filters() argument
1750 kfree(efx->rps_flow_id); in efx_remove_filters()
1752 down_write(&efx->filter_sem); in efx_remove_filters()
1753 efx->type->filter_table_remove(efx); in efx_remove_filters()
1754 up_write(&efx->filter_sem); in efx_remove_filters()
1757 static void efx_restore_filters(struct efx_nic *efx) in efx_restore_filters() argument
1759 down_read(&efx->filter_sem); in efx_restore_filters()
1760 efx->type->filter_table_restore(efx); in efx_restore_filters()
1761 up_read(&efx->filter_sem); in efx_restore_filters()
1770 static int efx_probe_all(struct efx_nic *efx) in efx_probe_all() argument
1774 rc = efx_probe_nic(efx); in efx_probe_all()
1776 netif_err(efx, probe, efx->net_dev, "failed to create NIC\n"); in efx_probe_all()
1780 rc = efx_probe_port(efx); in efx_probe_all()
1782 netif_err(efx, probe, efx->net_dev, "failed to create port\n"); in efx_probe_all()
1787 if (WARN_ON(EFX_DEFAULT_DMAQ_SIZE < EFX_TXQ_MIN_ENT(efx))) { in efx_probe_all()
1791 efx->rxq_entries = efx->txq_entries = EFX_DEFAULT_DMAQ_SIZE; in efx_probe_all()
1794 rc = efx->type->vswitching_probe(efx); in efx_probe_all()
1796 netif_warn(efx, probe, efx->net_dev, in efx_probe_all()
1801 rc = efx_probe_filters(efx); in efx_probe_all()
1803 netif_err(efx, probe, efx->net_dev, in efx_probe_all()
1808 rc = efx_probe_channels(efx); in efx_probe_all()
1815 efx_remove_filters(efx); in efx_probe_all()
1818 efx->type->vswitching_remove(efx); in efx_probe_all()
1821 efx_remove_port(efx); in efx_probe_all()
1823 efx_remove_nic(efx); in efx_probe_all()
1835 static void efx_start_all(struct efx_nic *efx) in efx_start_all() argument
1837 EFX_ASSERT_RESET_SERIALISED(efx); in efx_start_all()
1838 BUG_ON(efx->state == STATE_DISABLED); in efx_start_all()
1842 if (efx->port_enabled || !netif_running(efx->net_dev) || in efx_start_all()
1843 efx->reset_pending) in efx_start_all()
1846 efx_start_port(efx); in efx_start_all()
1847 efx_start_datapath(efx); in efx_start_all()
1850 if (efx->type->monitor != NULL) in efx_start_all()
1851 queue_delayed_work(efx->workqueue, &efx->monitor_work, in efx_start_all()
1857 if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0) { in efx_start_all()
1858 mutex_lock(&efx->mac_lock); in efx_start_all()
1859 if (efx->phy_op->poll(efx)) in efx_start_all()
1860 efx_link_status_changed(efx); in efx_start_all()
1861 mutex_unlock(&efx->mac_lock); in efx_start_all()
1864 efx->type->start_stats(efx); in efx_start_all()
1865 efx->type->pull_stats(efx); in efx_start_all()
1866 spin_lock_bh(&efx->stats_lock); in efx_start_all()
1867 efx->type->update_stats(efx, NULL, NULL); in efx_start_all()
1868 spin_unlock_bh(&efx->stats_lock); in efx_start_all()
1876 static void efx_stop_all(struct efx_nic *efx) in efx_stop_all() argument
1878 EFX_ASSERT_RESET_SERIALISED(efx); in efx_stop_all()
1881 if (!efx->port_enabled) in efx_stop_all()
1887 efx->type->pull_stats(efx); in efx_stop_all()
1888 spin_lock_bh(&efx->stats_lock); in efx_stop_all()
1889 efx->type->update_stats(efx, NULL, NULL); in efx_stop_all()
1890 spin_unlock_bh(&efx->stats_lock); in efx_stop_all()
1891 efx->type->stop_stats(efx); in efx_stop_all()
1892 efx_stop_port(efx); in efx_stop_all()
1898 WARN_ON(netif_running(efx->net_dev) && in efx_stop_all()
1899 netif_device_present(efx->net_dev)); in efx_stop_all()
1900 netif_tx_disable(efx->net_dev); in efx_stop_all()
1902 efx_stop_datapath(efx); in efx_stop_all()
1905 static void efx_remove_all(struct efx_nic *efx) in efx_remove_all() argument
1907 efx_remove_channels(efx); in efx_remove_all()
1908 efx_remove_filters(efx); in efx_remove_all()
1910 efx->type->vswitching_remove(efx); in efx_remove_all()
1912 efx_remove_port(efx); in efx_remove_all()
1913 efx_remove_nic(efx); in efx_remove_all()
1932 int efx_init_irq_moderation(struct efx_nic *efx, unsigned int tx_usecs, in efx_init_irq_moderation() argument
1937 unsigned int irq_mod_max = DIV_ROUND_UP(efx->type->timer_period_max * in efx_init_irq_moderation()
1938 efx->timer_quantum_ns, in efx_init_irq_moderation()
1943 EFX_ASSERT_RESET_SERIALISED(efx); in efx_init_irq_moderation()
1948 tx_ticks = irq_mod_ticks(tx_usecs, efx->timer_quantum_ns); in efx_init_irq_moderation()
1949 rx_ticks = irq_mod_ticks(rx_usecs, efx->timer_quantum_ns); in efx_init_irq_moderation()
1951 if (tx_ticks != rx_ticks && efx->tx_channel_offset == 0 && in efx_init_irq_moderation()
1953 netif_err(efx, drv, efx->net_dev, "Channels are shared. " in efx_init_irq_moderation()
1958 efx->irq_rx_adaptive = rx_adaptive; in efx_init_irq_moderation()
1959 efx->irq_rx_moderation = rx_ticks; in efx_init_irq_moderation()
1960 efx_for_each_channel(channel, efx) { in efx_init_irq_moderation()
1970 void efx_get_irq_moderation(struct efx_nic *efx, unsigned int *tx_usecs, in efx_get_irq_moderation() argument
1977 *rx_adaptive = efx->irq_rx_adaptive; in efx_get_irq_moderation()
1978 *rx_usecs = DIV_ROUND_UP(efx->irq_rx_moderation * in efx_get_irq_moderation()
1979 efx->timer_quantum_ns, in efx_get_irq_moderation()
1986 if (efx->tx_channel_offset == 0) in efx_get_irq_moderation()
1990 efx->channel[efx->tx_channel_offset]->irq_moderation * in efx_get_irq_moderation()
1991 efx->timer_quantum_ns, in efx_get_irq_moderation()
2004 struct efx_nic *efx = container_of(data, struct efx_nic, in efx_monitor() local
2007 netif_vdbg(efx, timer, efx->net_dev, in efx_monitor()
2010 BUG_ON(efx->type->monitor == NULL); in efx_monitor()
2015 if (mutex_trylock(&efx->mac_lock)) { in efx_monitor()
2016 if (efx->port_enabled) in efx_monitor()
2017 efx->type->monitor(efx); in efx_monitor()
2018 mutex_unlock(&efx->mac_lock); in efx_monitor()
2021 queue_delayed_work(efx->workqueue, &efx->monitor_work, in efx_monitor()
2036 struct efx_nic *efx = netdev_priv(net_dev); in efx_ioctl() local
2040 return efx_ptp_set_ts_config(efx, ifr); in efx_ioctl()
2042 return efx_ptp_get_ts_config(efx, ifr); in efx_ioctl()
2049 return mdio_mii_ioctl(&efx->mdio, data, cmd); in efx_ioctl()
2060 struct efx_nic *efx = channel->efx; in efx_init_napi_channel() local
2062 channel->napi_dev = efx->net_dev; in efx_init_napi_channel()
2069 static void efx_init_napi(struct efx_nic *efx) in efx_init_napi() argument
2073 efx_for_each_channel(channel, efx) in efx_init_napi()
2086 static void efx_fini_napi(struct efx_nic *efx) in efx_fini_napi() argument
2090 efx_for_each_channel(channel, efx) in efx_fini_napi()
2108 struct efx_nic *efx = netdev_priv(net_dev); in efx_netpoll() local
2111 efx_for_each_channel(channel, efx) in efx_netpoll()
2122 struct efx_nic *efx = channel->efx; in efx_busy_poll() local
2126 if (!netif_running(efx->net_dev)) in efx_busy_poll()
2157 struct efx_nic *efx = netdev_priv(net_dev); in efx_net_open() local
2160 netif_dbg(efx, ifup, efx->net_dev, "opening device on CPU %d\n", in efx_net_open()
2163 rc = efx_check_disabled(efx); in efx_net_open()
2166 if (efx->phy_mode & PHY_MODE_SPECIAL) in efx_net_open()
2168 if (efx_mcdi_poll_reboot(efx) && efx_reset(efx, RESET_TYPE_ALL)) in efx_net_open()
2173 efx_link_status_changed(efx); in efx_net_open()
2175 efx_start_all(efx); in efx_net_open()
2176 efx_selftest_async_start(efx); in efx_net_open()
2186 struct efx_nic *efx = netdev_priv(net_dev); in efx_net_stop() local
2188 netif_dbg(efx, ifdown, efx->net_dev, "closing on CPU %d\n", in efx_net_stop()
2192 efx_stop_all(efx); in efx_net_stop()
2201 struct efx_nic *efx = netdev_priv(net_dev); in efx_net_stats() local
2203 spin_lock_bh(&efx->stats_lock); in efx_net_stats()
2204 efx->type->update_stats(efx, NULL, stats); in efx_net_stats()
2205 spin_unlock_bh(&efx->stats_lock); in efx_net_stats()
2213 struct efx_nic *efx = netdev_priv(net_dev); in efx_watchdog() local
2215 netif_err(efx, tx_err, efx->net_dev, in efx_watchdog()
2217 efx->port_enabled); in efx_watchdog()
2219 efx_schedule_reset(efx, RESET_TYPE_TX_WATCHDOG); in efx_watchdog()
2226 struct efx_nic *efx = netdev_priv(net_dev); in efx_change_mtu() local
2229 rc = efx_check_disabled(efx); in efx_change_mtu()
2235 netif_dbg(efx, drv, efx->net_dev, "changing MTU to %d\n", new_mtu); in efx_change_mtu()
2237 efx_device_detach_sync(efx); in efx_change_mtu()
2238 efx_stop_all(efx); in efx_change_mtu()
2240 mutex_lock(&efx->mac_lock); in efx_change_mtu()
2242 efx_mac_reconfigure(efx); in efx_change_mtu()
2243 mutex_unlock(&efx->mac_lock); in efx_change_mtu()
2245 efx_start_all(efx); in efx_change_mtu()
2246 netif_device_attach(efx->net_dev); in efx_change_mtu()
2252 struct efx_nic *efx = netdev_priv(net_dev); in efx_set_mac_address() local
2259 netif_err(efx, drv, efx->net_dev, in efx_set_mac_address()
2268 if (efx->type->set_mac_address) { in efx_set_mac_address()
2269 rc = efx->type->set_mac_address(efx); in efx_set_mac_address()
2277 mutex_lock(&efx->mac_lock); in efx_set_mac_address()
2278 efx_mac_reconfigure(efx); in efx_set_mac_address()
2279 mutex_unlock(&efx->mac_lock); in efx_set_mac_address()
2287 struct efx_nic *efx = netdev_priv(net_dev); in efx_set_rx_mode() local
2289 if (efx->port_enabled) in efx_set_rx_mode()
2290 queue_work(efx->workqueue, &efx->mac_work); in efx_set_rx_mode()
2296 struct efx_nic *efx = netdev_priv(net_dev); in efx_set_features() local
2300 return efx->type->filter_clear_rx(efx, EFX_FILTER_PRI_MANUAL); in efx_set_features()
2337 static void efx_update_name(struct efx_nic *efx) in efx_update_name() argument
2339 strcpy(efx->name, efx->net_dev->name); in efx_update_name()
2340 efx_mtd_rename(efx); in efx_update_name()
2341 efx_set_channel_names(efx); in efx_update_name()
2363 struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); in show_phy_type() local
2364 return sprintf(buf, "%d\n", efx->phy_type); in show_phy_type()
2372 struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); in show_mcdi_log() local
2373 struct efx_mcdi_iface *mcdi = efx_mcdi(efx); in show_mcdi_log()
2380 struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); in set_mcdi_log() local
2381 struct efx_mcdi_iface *mcdi = efx_mcdi(efx); in set_mcdi_log()
2390 static int efx_register_netdev(struct efx_nic *efx) in efx_register_netdev() argument
2392 struct net_device *net_dev = efx->net_dev; in efx_register_netdev()
2397 net_dev->irq = efx->pci_dev->irq; in efx_register_netdev()
2399 if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0) in efx_register_netdev()
2410 efx->state = STATE_READY; in efx_register_netdev()
2412 if (efx->reset_pending) { in efx_register_netdev()
2413 netif_err(efx, probe, efx->net_dev, in efx_register_netdev()
2422 efx_update_name(efx); in efx_register_netdev()
2431 efx_for_each_channel(channel, efx) { in efx_register_netdev()
2437 efx_associate(efx); in efx_register_netdev()
2441 rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_type); in efx_register_netdev()
2443 netif_err(efx, drv, efx->net_dev, in efx_register_netdev()
2448 rc = device_create_file(&efx->pci_dev->dev, &dev_attr_mcdi_logging); in efx_register_netdev()
2450 netif_err(efx, drv, efx->net_dev, in efx_register_netdev()
2460 device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type); in efx_register_netdev()
2464 efx_dissociate(efx); in efx_register_netdev()
2467 efx->state = STATE_UNINIT; in efx_register_netdev()
2469 netif_err(efx, drv, efx->net_dev, "could not register net dev\n"); in efx_register_netdev()
2473 static void efx_unregister_netdev(struct efx_nic *efx) in efx_unregister_netdev() argument
2475 if (!efx->net_dev) in efx_unregister_netdev()
2478 BUG_ON(netdev_priv(efx->net_dev) != efx); in efx_unregister_netdev()
2480 if (efx_dev_registered(efx)) { in efx_unregister_netdev()
2481 strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name)); in efx_unregister_netdev()
2483 device_remove_file(&efx->pci_dev->dev, &dev_attr_mcdi_logging); in efx_unregister_netdev()
2485 device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type); in efx_unregister_netdev()
2486 unregister_netdev(efx->net_dev); in efx_unregister_netdev()
2498 void efx_reset_down(struct efx_nic *efx, enum reset_type method) in efx_reset_down() argument
2500 EFX_ASSERT_RESET_SERIALISED(efx); in efx_reset_down()
2503 efx->type->prepare_flr(efx); in efx_reset_down()
2505 efx_stop_all(efx); in efx_reset_down()
2506 efx_disable_interrupts(efx); in efx_reset_down()
2508 mutex_lock(&efx->mac_lock); in efx_reset_down()
2509 if (efx->port_initialized && method != RESET_TYPE_INVISIBLE && in efx_reset_down()
2511 efx->phy_op->fini(efx); in efx_reset_down()
2512 efx->type->fini(efx); in efx_reset_down()
2520 int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok) in efx_reset_up() argument
2524 EFX_ASSERT_RESET_SERIALISED(efx); in efx_reset_up()
2527 efx->type->finish_flr(efx); in efx_reset_up()
2530 rc = efx->type->init(efx); in efx_reset_up()
2532 netif_err(efx, drv, efx->net_dev, "failed to initialise NIC\n"); in efx_reset_up()
2539 if (efx->port_initialized && method != RESET_TYPE_INVISIBLE && in efx_reset_up()
2541 rc = efx->phy_op->init(efx); in efx_reset_up()
2544 rc = efx->phy_op->reconfigure(efx); in efx_reset_up()
2546 netif_err(efx, drv, efx->net_dev, in efx_reset_up()
2550 rc = efx_enable_interrupts(efx); in efx_reset_up()
2555 rc = efx->type->vswitching_restore(efx); in efx_reset_up()
2557 netif_warn(efx, probe, efx->net_dev, in efx_reset_up()
2562 down_read(&efx->filter_sem); in efx_reset_up()
2563 efx_restore_filters(efx); in efx_reset_up()
2564 up_read(&efx->filter_sem); in efx_reset_up()
2565 if (efx->type->sriov_reset) in efx_reset_up()
2566 efx->type->sriov_reset(efx); in efx_reset_up()
2568 mutex_unlock(&efx->mac_lock); in efx_reset_up()
2570 efx_start_all(efx); in efx_reset_up()
2575 efx->port_initialized = false; in efx_reset_up()
2577 mutex_unlock(&efx->mac_lock); in efx_reset_up()
2587 int efx_reset(struct efx_nic *efx, enum reset_type method) in efx_reset() argument
2592 netif_info(efx, drv, efx->net_dev, "resetting (%s)\n", in efx_reset()
2595 efx_device_detach_sync(efx); in efx_reset()
2596 efx_reset_down(efx, method); in efx_reset()
2598 rc = efx->type->reset(efx, method); in efx_reset()
2600 netif_err(efx, drv, efx->net_dev, "failed to reset hardware\n"); in efx_reset()
2608 efx->reset_pending &= -(1 << (method + 1)); in efx_reset()
2610 __clear_bit(method, &efx->reset_pending); in efx_reset()
2616 pci_set_master(efx->pci_dev); in efx_reset()
2623 rc2 = efx_reset_up(efx, method, !disabled); in efx_reset()
2631 dev_close(efx->net_dev); in efx_reset()
2632 netif_err(efx, drv, efx->net_dev, "has been disabled\n"); in efx_reset()
2633 efx->state = STATE_DISABLED; in efx_reset()
2635 netif_dbg(efx, drv, efx->net_dev, "reset complete\n"); in efx_reset()
2636 netif_device_attach(efx->net_dev); in efx_reset()
2646 int efx_try_recovery(struct efx_nic *efx) in efx_try_recovery() argument
2654 struct eeh_dev *eehdev = pci_dev_to_eeh_dev(efx->pci_dev); in efx_try_recovery()
2665 static void efx_wait_for_bist_end(struct efx_nic *efx) in efx_wait_for_bist_end() argument
2670 if (efx_mcdi_poll_reboot(efx)) in efx_wait_for_bist_end()
2675 netif_err(efx, drv, efx->net_dev, "Warning: No MC reboot after BIST mode\n"); in efx_wait_for_bist_end()
2680 efx->mc_bist_for_other_fn = false; in efx_wait_for_bist_end()
2688 struct efx_nic *efx = container_of(data, struct efx_nic, reset_work); in efx_reset_work() local
2692 pending = ACCESS_ONCE(efx->reset_pending); in efx_reset_work()
2696 efx_wait_for_bist_end(efx); in efx_reset_work()
2700 efx_try_recovery(efx)) in efx_reset_work()
2712 if (efx->state == STATE_READY) in efx_reset_work()
2713 (void)efx_reset(efx, method); in efx_reset_work()
2718 void efx_schedule_reset(struct efx_nic *efx, enum reset_type type) in efx_schedule_reset() argument
2722 if (efx->state == STATE_RECOVERY) { in efx_schedule_reset()
2723 netif_dbg(efx, drv, efx->net_dev, in efx_schedule_reset()
2740 netif_dbg(efx, drv, efx->net_dev, "scheduling %s reset\n", in efx_schedule_reset()
2744 method = efx->type->map_reset_reason(type); in efx_schedule_reset()
2745 netif_dbg(efx, drv, efx->net_dev, in efx_schedule_reset()
2751 set_bit(method, &efx->reset_pending); in efx_schedule_reset()
2757 if (ACCESS_ONCE(efx->state) != STATE_READY) in efx_schedule_reset()
2762 efx_mcdi_mode_poll(efx); in efx_schedule_reset()
2764 queue_work(reset_workqueue, &efx->reset_work); in efx_schedule_reset()
2803 int efx_port_dummy_op_int(struct efx_nic *efx) in efx_port_dummy_op_int() argument
2807 void efx_port_dummy_op_void(struct efx_nic *efx) {} in efx_port_dummy_op_void() argument
2809 static bool efx_port_dummy_op_poll(struct efx_nic *efx) in efx_port_dummy_op_poll() argument
2830 static int efx_init_struct(struct efx_nic *efx, in efx_init_struct() argument
2836 INIT_LIST_HEAD(&efx->node); in efx_init_struct()
2837 INIT_LIST_HEAD(&efx->secondary_list); in efx_init_struct()
2838 spin_lock_init(&efx->biu_lock); in efx_init_struct()
2840 INIT_LIST_HEAD(&efx->mtd_list); in efx_init_struct()
2842 INIT_WORK(&efx->reset_work, efx_reset_work); in efx_init_struct()
2843 INIT_DELAYED_WORK(&efx->monitor_work, efx_monitor); in efx_init_struct()
2844 INIT_DELAYED_WORK(&efx->selftest_work, efx_selftest_async_work); in efx_init_struct()
2845 efx->pci_dev = pci_dev; in efx_init_struct()
2846 efx->msg_enable = debug; in efx_init_struct()
2847 efx->state = STATE_UNINIT; in efx_init_struct()
2848 strlcpy(efx->name, pci_name(pci_dev), sizeof(efx->name)); in efx_init_struct()
2850 efx->net_dev = net_dev; in efx_init_struct()
2851 efx->rx_prefix_size = efx->type->rx_prefix_size; in efx_init_struct()
2852 efx->rx_ip_align = in efx_init_struct()
2853 NET_IP_ALIGN ? (efx->rx_prefix_size + NET_IP_ALIGN) % 4 : 0; in efx_init_struct()
2854 efx->rx_packet_hash_offset = in efx_init_struct()
2855 efx->type->rx_hash_offset - efx->type->rx_prefix_size; in efx_init_struct()
2856 efx->rx_packet_ts_offset = in efx_init_struct()
2857 efx->type->rx_ts_offset - efx->type->rx_prefix_size; in efx_init_struct()
2858 spin_lock_init(&efx->stats_lock); in efx_init_struct()
2859 mutex_init(&efx->mac_lock); in efx_init_struct()
2860 efx->phy_op = &efx_dummy_phy_operations; in efx_init_struct()
2861 efx->mdio.dev = net_dev; in efx_init_struct()
2862 INIT_WORK(&efx->mac_work, efx_mac_work); in efx_init_struct()
2863 init_waitqueue_head(&efx->flush_wq); in efx_init_struct()
2866 efx->channel[i] = efx_alloc_channel(efx, i, NULL); in efx_init_struct()
2867 if (!efx->channel[i]) in efx_init_struct()
2869 efx->msi_context[i].efx = efx; in efx_init_struct()
2870 efx->msi_context[i].index = i; in efx_init_struct()
2874 efx->interrupt_mode = max(efx->type->max_interrupt_mode, in efx_init_struct()
2878 snprintf(efx->workqueue_name, sizeof(efx->workqueue_name), "sfc%s", in efx_init_struct()
2880 efx->workqueue = create_singlethread_workqueue(efx->workqueue_name); in efx_init_struct()
2881 if (!efx->workqueue) in efx_init_struct()
2887 efx_fini_struct(efx); in efx_init_struct()
2891 static void efx_fini_struct(struct efx_nic *efx) in efx_fini_struct() argument
2896 kfree(efx->channel[i]); in efx_fini_struct()
2898 kfree(efx->vpd_sn); in efx_fini_struct()
2900 if (efx->workqueue) { in efx_fini_struct()
2901 destroy_workqueue(efx->workqueue); in efx_fini_struct()
2902 efx->workqueue = NULL; in efx_fini_struct()
2906 void efx_update_sw_stats(struct efx_nic *efx, u64 *stats) in efx_update_sw_stats() argument
2911 efx_for_each_channel(channel, efx) in efx_update_sw_stats()
2914 stats[GENERIC_STAT_rx_noskb_drops] = atomic_read(&efx->n_rx_noskb_drops); in efx_update_sw_stats()
2926 static void efx_pci_remove_main(struct efx_nic *efx) in efx_pci_remove_main() argument
2931 BUG_ON(efx->state == STATE_READY); in efx_pci_remove_main()
2932 cancel_work_sync(&efx->reset_work); in efx_pci_remove_main()
2934 efx_disable_interrupts(efx); in efx_pci_remove_main()
2935 efx_nic_fini_interrupt(efx); in efx_pci_remove_main()
2936 efx_fini_port(efx); in efx_pci_remove_main()
2937 efx->type->fini(efx); in efx_pci_remove_main()
2938 efx_fini_napi(efx); in efx_pci_remove_main()
2939 efx_remove_all(efx); in efx_pci_remove_main()
2948 struct efx_nic *efx; in efx_pci_remove() local
2950 efx = pci_get_drvdata(pci_dev); in efx_pci_remove()
2951 if (!efx) in efx_pci_remove()
2956 efx_dissociate(efx); in efx_pci_remove()
2957 dev_close(efx->net_dev); in efx_pci_remove()
2958 efx_disable_interrupts(efx); in efx_pci_remove()
2959 efx->state = STATE_UNINIT; in efx_pci_remove()
2962 if (efx->type->sriov_fini) in efx_pci_remove()
2963 efx->type->sriov_fini(efx); in efx_pci_remove()
2965 efx_unregister_netdev(efx); in efx_pci_remove()
2967 efx_mtd_remove(efx); in efx_pci_remove()
2969 efx_pci_remove_main(efx); in efx_pci_remove()
2971 efx_fini_io(efx); in efx_pci_remove()
2972 netif_dbg(efx, drv, efx->net_dev, "shutdown successful\n"); in efx_pci_remove()
2974 efx_fini_struct(efx); in efx_pci_remove()
2975 free_netdev(efx->net_dev); in efx_pci_remove()
2986 static void efx_probe_vpd_strings(struct efx_nic *efx) in efx_probe_vpd_strings() argument
2988 struct pci_dev *dev = efx->pci_dev; in efx_probe_vpd_strings()
2996 netif_err(efx, drv, efx->net_dev, "Unable to read VPD\n"); in efx_probe_vpd_strings()
3003 netif_err(efx, drv, efx->net_dev, "VPD Read-only not found\n"); in efx_probe_vpd_strings()
3016 netif_err(efx, drv, efx->net_dev, "Part number not found\n"); in efx_probe_vpd_strings()
3023 netif_err(efx, drv, efx->net_dev, "Incomplete part number\n"); in efx_probe_vpd_strings()
3027 netif_info(efx, drv, efx->net_dev, in efx_probe_vpd_strings()
3034 netif_err(efx, drv, efx->net_dev, "Serial number not found\n"); in efx_probe_vpd_strings()
3041 netif_err(efx, drv, efx->net_dev, "Incomplete serial number\n"); in efx_probe_vpd_strings()
3045 efx->vpd_sn = kmalloc(j + 1, GFP_KERNEL); in efx_probe_vpd_strings()
3046 if (!efx->vpd_sn) in efx_probe_vpd_strings()
3049 snprintf(efx->vpd_sn, j + 1, "%s", &vpd_data[i]); in efx_probe_vpd_strings()
3056 static int efx_pci_probe_main(struct efx_nic *efx) in efx_pci_probe_main() argument
3061 rc = efx_probe_all(efx); in efx_pci_probe_main()
3065 efx_init_napi(efx); in efx_pci_probe_main()
3067 rc = efx->type->init(efx); in efx_pci_probe_main()
3069 netif_err(efx, probe, efx->net_dev, in efx_pci_probe_main()
3074 rc = efx_init_port(efx); in efx_pci_probe_main()
3076 netif_err(efx, probe, efx->net_dev, in efx_pci_probe_main()
3081 rc = efx_nic_init_interrupt(efx); in efx_pci_probe_main()
3084 rc = efx_enable_interrupts(efx); in efx_pci_probe_main()
3091 efx_nic_fini_interrupt(efx); in efx_pci_probe_main()
3093 efx_fini_port(efx); in efx_pci_probe_main()
3095 efx->type->fini(efx); in efx_pci_probe_main()
3097 efx_fini_napi(efx); in efx_pci_probe_main()
3098 efx_remove_all(efx); in efx_pci_probe_main()
3116 struct efx_nic *efx; in efx_pci_probe() local
3120 net_dev = alloc_etherdev_mqs(sizeof(*efx), EFX_MAX_CORE_TX_QUEUES, in efx_pci_probe()
3124 efx = netdev_priv(net_dev); in efx_pci_probe()
3125 efx->type = (const struct efx_nic_type *) entry->driver_data; in efx_pci_probe()
3126 net_dev->features |= (efx->type->offload_features | NETIF_F_SG | in efx_pci_probe()
3129 if (efx->type->offload_features & NETIF_F_V6_CSUM) in efx_pci_probe()
3137 pci_set_drvdata(pci_dev, efx); in efx_pci_probe()
3139 rc = efx_init_struct(efx, pci_dev, net_dev); in efx_pci_probe()
3143 netif_info(efx, probe, efx->net_dev, in efx_pci_probe()
3146 if (!efx->type->is_vf) in efx_pci_probe()
3147 efx_probe_vpd_strings(efx); in efx_pci_probe()
3150 rc = efx_init_io(efx); in efx_pci_probe()
3154 rc = efx_pci_probe_main(efx); in efx_pci_probe()
3158 rc = efx_register_netdev(efx); in efx_pci_probe()
3162 if (efx->type->sriov_init) { in efx_pci_probe()
3163 rc = efx->type->sriov_init(efx); in efx_pci_probe()
3165 netif_err(efx, probe, efx->net_dev, in efx_pci_probe()
3169 netif_dbg(efx, probe, efx->net_dev, "initialisation successful\n"); in efx_pci_probe()
3173 rc = efx_mtd_probe(efx); in efx_pci_probe()
3176 netif_warn(efx, probe, efx->net_dev, in efx_pci_probe()
3181 netif_warn(efx, probe, efx->net_dev, in efx_pci_probe()
3187 efx_pci_remove_main(efx); in efx_pci_probe()
3189 efx_fini_io(efx); in efx_pci_probe()
3191 efx_fini_struct(efx); in efx_pci_probe()
3194 netif_dbg(efx, drv, efx->net_dev, "initialisation failed. rc=%d\n", rc); in efx_pci_probe()
3206 struct efx_nic *efx = pci_get_drvdata(dev); in efx_pci_sriov_configure() local
3208 if (efx->type->sriov_configure) { in efx_pci_sriov_configure()
3209 rc = efx->type->sriov_configure(efx, num_vfs); in efx_pci_sriov_configure()
3221 struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); in efx_pm_freeze() local
3225 if (efx->state != STATE_DISABLED) { in efx_pm_freeze()
3226 efx->state = STATE_UNINIT; in efx_pm_freeze()
3228 efx_device_detach_sync(efx); in efx_pm_freeze()
3230 efx_stop_all(efx); in efx_pm_freeze()
3231 efx_disable_interrupts(efx); in efx_pm_freeze()
3242 struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); in efx_pm_thaw() local
3246 if (efx->state != STATE_DISABLED) { in efx_pm_thaw()
3247 rc = efx_enable_interrupts(efx); in efx_pm_thaw()
3251 mutex_lock(&efx->mac_lock); in efx_pm_thaw()
3252 efx->phy_op->reconfigure(efx); in efx_pm_thaw()
3253 mutex_unlock(&efx->mac_lock); in efx_pm_thaw()
3255 efx_start_all(efx); in efx_pm_thaw()
3257 netif_device_attach(efx->net_dev); in efx_pm_thaw()
3259 efx->state = STATE_READY; in efx_pm_thaw()
3261 efx->type->resume_wol(efx); in efx_pm_thaw()
3267 queue_work(reset_workqueue, &efx->reset_work); in efx_pm_thaw()
3280 struct efx_nic *efx = pci_get_drvdata(pci_dev); in efx_pm_poweroff() local
3282 efx->type->fini(efx); in efx_pm_poweroff()
3284 efx->reset_pending = 0; in efx_pm_poweroff()
3294 struct efx_nic *efx = pci_get_drvdata(pci_dev); in efx_pm_resume() local
3304 pci_set_master(efx->pci_dev); in efx_pm_resume()
3305 rc = efx->type->reset(efx, RESET_TYPE_ALL); in efx_pm_resume()
3308 rc = efx->type->init(efx); in efx_pm_resume()
3343 struct efx_nic *efx = pci_get_drvdata(pdev); in efx_io_error_detected() local
3350 if (efx->state != STATE_DISABLED) { in efx_io_error_detected()
3351 efx->state = STATE_RECOVERY; in efx_io_error_detected()
3352 efx->reset_pending = 0; in efx_io_error_detected()
3354 efx_device_detach_sync(efx); in efx_io_error_detected()
3356 efx_stop_all(efx); in efx_io_error_detected()
3357 efx_disable_interrupts(efx); in efx_io_error_detected()
3377 struct efx_nic *efx = pci_get_drvdata(pdev); in efx_io_slot_reset() local
3382 netif_err(efx, hw, efx->net_dev, in efx_io_slot_reset()
3389 netif_err(efx, hw, efx->net_dev, in efx_io_slot_reset()
3400 struct efx_nic *efx = pci_get_drvdata(pdev); in efx_io_resume() local
3405 if (efx->state == STATE_DISABLED) in efx_io_resume()
3408 rc = efx_reset(efx, RESET_TYPE_ALL); in efx_io_resume()
3410 netif_err(efx, hw, efx->net_dev, in efx_io_resume()
3413 efx->state = STATE_READY; in efx_io_resume()
3414 netif_dbg(efx, hw, efx->net_dev, in efx_io_resume()