Lines Matching +full:self +full:- +full:advertising
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright 2005-2006 Fen Systems Ltd.
5 * Copyright 2005-2013 Solarflare Communications Inc.
85 * queued onto this work queue. This is not a per-nic work queue, because
108 * This is only used in MSI-X interrupt mode
115 /* This is the weight assigned to each of the (per-channel) virtual
122 * On Falcon-based NICs, this will:
123 * - Check the on-board hardware monitor;
124 * - Poll the link state and reconfigure the hardware as necessary.
125 * On Siena-based NICs for power systems with EEH support, this will give EEH a
134 * round-trip latency and reducing overhead.
150 * 0 => MSI-X
156 /* This is the requested number of CPUs to use for Receive-Side Scaling (RSS),
160 * Cards without MSI-X will only target one CPU via legacy or MSI interrupt.
165 MODULE_PARM_DESC(rss_cpus, "Number of CPUs to use for Receive-Side Scaling");
209 if ((efx->state == STATE_READY) || \
210 (efx->state == STATE_RECOVERY) || \
211 (efx->state == STATE_DISABLED)) \
217 if (efx->state == STATE_DISABLED || efx->state == STATE_RECOVERY) { in ef4_check_disabled()
218 netif_err(efx, drv, efx->net_dev, in ef4_check_disabled()
220 return -EIO; in ef4_check_disabled()
243 if (unlikely(!channel->enabled)) in ef4_process_channel()
247 tx_queue->pkts_compl = 0; in ef4_process_channel()
248 tx_queue->bytes_compl = 0; in ef4_process_channel()
262 if (tx_queue->bytes_compl) { in ef4_process_channel()
263 netdev_tx_completed_queue(tx_queue->core_txq, in ef4_process_channel()
264 tx_queue->pkts_compl, tx_queue->bytes_compl); in ef4_process_channel()
278 int step = efx->irq_mod_step_us; in ef4_update_irq_mod()
280 if (channel->irq_mod_score < irq_adapt_low_thresh) { in ef4_update_irq_mod()
281 if (channel->irq_moderation_us > step) { in ef4_update_irq_mod()
282 channel->irq_moderation_us -= step; in ef4_update_irq_mod()
283 efx->type->push_irq_moderation(channel); in ef4_update_irq_mod()
285 } else if (channel->irq_mod_score > irq_adapt_high_thresh) { in ef4_update_irq_mod()
286 if (channel->irq_moderation_us < in ef4_update_irq_mod()
287 efx->irq_rx_moderation_us) { in ef4_update_irq_mod()
288 channel->irq_moderation_us += step; in ef4_update_irq_mod()
289 efx->type->push_irq_moderation(channel); in ef4_update_irq_mod()
293 channel->irq_count = 0; in ef4_update_irq_mod()
294 channel->irq_mod_score = 0; in ef4_update_irq_mod()
301 struct ef4_nic *efx = channel->efx; in ef4_poll()
304 netif_vdbg(efx, intr, efx->net_dev, in ef4_poll()
306 channel->channel, raw_smp_processor_id()); in ef4_poll()
312 efx->irq_rx_adaptive && in ef4_poll()
313 unlikely(++channel->irq_count == 1000)) { in ef4_poll()
338 struct ef4_nic *efx = channel->efx; in ef4_probe_eventq()
341 netif_dbg(efx, probe, efx->net_dev, in ef4_probe_eventq()
342 "chan %d create event queue\n", channel->channel); in ef4_probe_eventq()
346 entries = roundup_pow_of_two(efx->rxq_entries + efx->txq_entries + 128); in ef4_probe_eventq()
348 channel->eventq_mask = max(entries, EF4_MIN_EVQ_SIZE) - 1; in ef4_probe_eventq()
356 struct ef4_nic *efx = channel->efx; in ef4_init_eventq()
359 EF4_WARN_ON_PARANOID(channel->eventq_init); in ef4_init_eventq()
361 netif_dbg(efx, drv, efx->net_dev, in ef4_init_eventq()
362 "chan %d init event queue\n", channel->channel); in ef4_init_eventq()
366 efx->type->push_irq_moderation(channel); in ef4_init_eventq()
367 channel->eventq_read_ptr = 0; in ef4_init_eventq()
368 channel->eventq_init = true; in ef4_init_eventq()
376 netif_dbg(channel->efx, ifup, channel->efx->net_dev, in ef4_start_eventq()
377 "chan %d start event queue\n", channel->channel); in ef4_start_eventq()
380 channel->enabled = true; in ef4_start_eventq()
383 napi_enable(&channel->napi_str); in ef4_start_eventq()
390 if (!channel->enabled) in ef4_stop_eventq()
393 napi_disable(&channel->napi_str); in ef4_stop_eventq()
394 channel->enabled = false; in ef4_stop_eventq()
399 if (!channel->eventq_init) in ef4_fini_eventq()
402 netif_dbg(channel->efx, drv, channel->efx->net_dev, in ef4_fini_eventq()
403 "chan %d fini event queue\n", channel->channel); in ef4_fini_eventq()
406 channel->eventq_init = false; in ef4_fini_eventq()
411 netif_dbg(channel->efx, drv, channel->efx->net_dev, in ef4_remove_eventq()
412 "chan %d remove event queue\n", channel->channel); in ef4_remove_eventq()
436 channel->efx = efx; in ef4_alloc_channel()
437 channel->channel = i; in ef4_alloc_channel()
438 channel->type = &ef4_default_channel_type; in ef4_alloc_channel()
441 tx_queue = &channel->tx_queue[j]; in ef4_alloc_channel()
442 tx_queue->efx = efx; in ef4_alloc_channel()
443 tx_queue->queue = i * EF4_TXQ_TYPES + j; in ef4_alloc_channel()
444 tx_queue->channel = channel; in ef4_alloc_channel()
447 rx_queue = &channel->rx_queue; in ef4_alloc_channel()
448 rx_queue->efx = efx; in ef4_alloc_channel()
449 timer_setup(&rx_queue->slow_fill, ef4_rx_slow_fill, 0); in ef4_alloc_channel()
471 channel->napi_dev = NULL; in ef4_copy_channel()
472 INIT_HLIST_NODE(&channel->napi_str.napi_hash_node); in ef4_copy_channel()
473 channel->napi_str.napi_id = 0; in ef4_copy_channel()
474 channel->napi_str.state = 0; in ef4_copy_channel()
475 memset(&channel->eventq, 0, sizeof(channel->eventq)); in ef4_copy_channel()
478 tx_queue = &channel->tx_queue[j]; in ef4_copy_channel()
479 if (tx_queue->channel) in ef4_copy_channel()
480 tx_queue->channel = channel; in ef4_copy_channel()
481 tx_queue->buffer = NULL; in ef4_copy_channel()
482 memset(&tx_queue->txd, 0, sizeof(tx_queue->txd)); in ef4_copy_channel()
485 rx_queue = &channel->rx_queue; in ef4_copy_channel()
486 rx_queue->buffer = NULL; in ef4_copy_channel()
487 memset(&rx_queue->rxd, 0, sizeof(rx_queue->rxd)); in ef4_copy_channel()
488 timer_setup(&rx_queue->slow_fill, ef4_rx_slow_fill, 0); in ef4_copy_channel()
499 netif_dbg(channel->efx, probe, channel->efx->net_dev, in ef4_probe_channel()
500 "creating channel %d\n", channel->channel); in ef4_probe_channel()
502 rc = channel->type->pre_probe(channel); in ef4_probe_channel()
532 struct ef4_nic *efx = channel->efx; in ef4_get_channel_name()
536 number = channel->channel; in ef4_get_channel_name()
537 if (efx->tx_channel_offset == 0) { in ef4_get_channel_name()
539 } else if (channel->channel < efx->tx_channel_offset) { in ef4_get_channel_name()
540 type = "-rx"; in ef4_get_channel_name()
542 type = "-tx"; in ef4_get_channel_name()
543 number -= efx->tx_channel_offset; in ef4_get_channel_name()
545 snprintf(buf, len, "%s%s-%d", efx->name, type, number); in ef4_get_channel_name()
553 channel->type->get_name(channel, in ef4_set_channel_names()
554 efx->msi_context[channel->channel].name, in ef4_set_channel_names()
555 sizeof(efx->msi_context[0].name)); in ef4_set_channel_names()
564 efx->next_buffer_table = 0; in ef4_probe_channels()
574 netif_err(efx, probe, efx->net_dev, in ef4_probe_channels()
576 channel->channel); in ef4_probe_channels()
595 netdev_features_t old_features = efx->net_dev->features; in ef4_start_datapath()
596 bool old_rx_scatter = efx->rx_scatter; in ef4_start_datapath()
606 efx->rx_dma_len = (efx->rx_prefix_size + in ef4_start_datapath()
607 EF4_MAX_FRAME_LEN(efx->net_dev->mtu) + in ef4_start_datapath()
608 efx->type->rx_buffer_padding); in ef4_start_datapath()
610 efx->rx_ip_align + efx->rx_dma_len); in ef4_start_datapath()
612 efx->rx_scatter = efx->type->always_rx_scatter; in ef4_start_datapath()
613 efx->rx_buffer_order = 0; in ef4_start_datapath()
614 } else if (efx->type->can_rx_scatter) { in ef4_start_datapath()
620 efx->rx_scatter = true; in ef4_start_datapath()
621 efx->rx_dma_len = EF4_RX_USR_BUF_SIZE; in ef4_start_datapath()
622 efx->rx_buffer_order = 0; in ef4_start_datapath()
624 efx->rx_scatter = false; in ef4_start_datapath()
625 efx->rx_buffer_order = get_order(rx_buf_len); in ef4_start_datapath()
629 if (efx->rx_buffer_order) in ef4_start_datapath()
630 netif_dbg(efx, drv, efx->net_dev, in ef4_start_datapath()
632 efx->rx_dma_len, efx->rx_buffer_order, in ef4_start_datapath()
633 efx->rx_pages_per_batch); in ef4_start_datapath()
635 netif_dbg(efx, drv, efx->net_dev, in ef4_start_datapath()
637 efx->rx_dma_len, efx->rx_page_buf_step, in ef4_start_datapath()
638 efx->rx_bufs_per_page, efx->rx_pages_per_batch); in ef4_start_datapath()
643 efx->net_dev->hw_features |= efx->net_dev->features; in ef4_start_datapath()
644 efx->net_dev->hw_features &= ~efx->fixed_features; in ef4_start_datapath()
645 efx->net_dev->features |= efx->fixed_features; in ef4_start_datapath()
646 if (efx->net_dev->features != old_features) in ef4_start_datapath()
647 netdev_features_change(efx->net_dev); in ef4_start_datapath()
649 /* RX filters may also have scatter-enabled flags */ in ef4_start_datapath()
650 if (efx->rx_scatter != old_rx_scatter) in ef4_start_datapath()
651 efx->type->filter_update_rx_scatter(efx); in ef4_start_datapath()
660 efx->txq_stop_thresh = efx->txq_entries - ef4_tx_max_skb_descs(efx); in ef4_start_datapath()
661 efx->txq_wake_thresh = efx->txq_stop_thresh / 2; in ef4_start_datapath()
667 atomic_inc(&efx->active_queues); in ef4_start_datapath()
672 atomic_inc(&efx->active_queues); in ef4_start_datapath()
678 WARN_ON(channel->rx_pkt_n_frags); in ef4_start_datapath()
681 if (netif_device_present(efx->net_dev)) in ef4_start_datapath()
682 netif_tx_wake_all_queues(efx->net_dev); in ef4_start_datapath()
693 BUG_ON(efx->port_enabled); in ef4_stop_datapath()
698 rx_queue->refill_enabled = false; in ef4_stop_datapath()
704 * might be kept active by non-data events, so don't in ef4_stop_datapath()
714 rc = efx->type->fini_dmaq(efx); in ef4_stop_datapath()
721 netif_err(efx, drv, efx->net_dev, in ef4_stop_datapath()
725 netif_err(efx, drv, efx->net_dev, "failed to flush queues\n"); in ef4_stop_datapath()
727 netif_dbg(efx, drv, efx->net_dev, in ef4_stop_datapath()
744 netif_dbg(channel->efx, drv, channel->efx->net_dev, in ef4_remove_channel()
745 "destroy chan %d\n", channel->channel); in ef4_remove_channel()
752 channel->type->post_remove(channel); in ef4_remove_channel()
782 if (channel->type->copy) in ef4_realloc_channels()
785 channel->eventq.index + in ef4_realloc_channels()
786 channel->eventq.entries); in ef4_realloc_channels()
789 rx_queue->rxd.index + in ef4_realloc_channels()
790 rx_queue->rxd.entries); in ef4_realloc_channels()
793 tx_queue->txd.index + in ef4_realloc_channels()
794 tx_queue->txd.entries); in ef4_realloc_channels()
803 for (i = 0; i < efx->n_channels; i++) { in ef4_realloc_channels()
804 channel = efx->channel[i]; in ef4_realloc_channels()
805 if (channel->type->copy) in ef4_realloc_channels()
806 channel = channel->type->copy(channel); in ef4_realloc_channels()
808 rc = -ENOMEM; in ef4_realloc_channels()
815 old_rxq_entries = efx->rxq_entries; in ef4_realloc_channels()
816 old_txq_entries = efx->txq_entries; in ef4_realloc_channels()
817 efx->rxq_entries = rxq_entries; in ef4_realloc_channels()
818 efx->txq_entries = txq_entries; in ef4_realloc_channels()
819 for (i = 0; i < efx->n_channels; i++) { in ef4_realloc_channels()
820 channel = efx->channel[i]; in ef4_realloc_channels()
821 efx->channel[i] = other_channel[i]; in ef4_realloc_channels()
826 efx->next_buffer_table = next_buffer_table; in ef4_realloc_channels()
828 for (i = 0; i < efx->n_channels; i++) { in ef4_realloc_channels()
829 channel = efx->channel[i]; in ef4_realloc_channels()
830 if (!channel->type->copy) in ef4_realloc_channels()
835 ef4_init_napi_channel(efx->channel[i]); in ef4_realloc_channels()
840 for (i = 0; i < efx->n_channels; i++) { in ef4_realloc_channels()
842 if (channel && channel->type->copy) { in ef4_realloc_channels()
852 netif_err(efx, drv, efx->net_dev, in ef4_realloc_channels()
857 netif_device_attach(efx->net_dev); in ef4_realloc_channels()
863 efx->rxq_entries = old_rxq_entries; in ef4_realloc_channels()
864 efx->txq_entries = old_txq_entries; in ef4_realloc_channels()
865 for (i = 0; i < efx->n_channels; i++) { in ef4_realloc_channels()
866 channel = efx->channel[i]; in ef4_realloc_channels()
867 efx->channel[i] = other_channel[i]; in ef4_realloc_channels()
875 mod_timer(&rx_queue->slow_fill, jiffies + msecs_to_jiffies(100)); in ef4_schedule_slow_fill()
907 struct ef4_link_state *link_state = &efx->link_state; in ef4_link_status_changed()
913 if (!netif_running(efx->net_dev)) in ef4_link_status_changed()
916 if (link_state->up != netif_carrier_ok(efx->net_dev)) { in ef4_link_status_changed()
917 efx->n_link_state_changes++; in ef4_link_status_changed()
919 if (link_state->up) in ef4_link_status_changed()
920 netif_carrier_on(efx->net_dev); in ef4_link_status_changed()
922 netif_carrier_off(efx->net_dev); in ef4_link_status_changed()
926 if (link_state->up) in ef4_link_status_changed()
927 netif_info(efx, link, efx->net_dev, in ef4_link_status_changed()
928 "link up at %uMbps %s-duplex (MTU %d)\n", in ef4_link_status_changed()
929 link_state->speed, link_state->fd ? "full" : "half", in ef4_link_status_changed()
930 efx->net_dev->mtu); in ef4_link_status_changed()
932 netif_info(efx, link, efx->net_dev, "link down\n"); in ef4_link_status_changed()
935 void ef4_link_set_advertising(struct ef4_nic *efx, u32 advertising) in ef4_link_set_advertising() argument
937 efx->link_advertising = advertising; in ef4_link_set_advertising()
938 if (advertising) { in ef4_link_set_advertising()
939 if (advertising & ADVERTISED_Pause) in ef4_link_set_advertising()
940 efx->wanted_fc |= (EF4_FC_TX | EF4_FC_RX); in ef4_link_set_advertising()
942 efx->wanted_fc &= ~(EF4_FC_TX | EF4_FC_RX); in ef4_link_set_advertising()
943 if (advertising & ADVERTISED_Asym_Pause) in ef4_link_set_advertising()
944 efx->wanted_fc ^= EF4_FC_TX; in ef4_link_set_advertising()
950 efx->wanted_fc = wanted_fc; in ef4_link_set_wanted_fc()
951 if (efx->link_advertising) { in ef4_link_set_wanted_fc()
953 efx->link_advertising |= (ADVERTISED_Pause | in ef4_link_set_wanted_fc()
956 efx->link_advertising &= ~(ADVERTISED_Pause | in ef4_link_set_wanted_fc()
959 efx->link_advertising ^= ADVERTISED_Asym_Pause; in ef4_link_set_wanted_fc()
965 /* We assume that efx->type->reconfigure_mac will always try to sync RX
966 * filters and therefore needs to read-lock the filter table against freeing
970 down_read(&efx->filter_sem); in ef4_mac_reconfigure()
971 efx->type->reconfigure_mac(efx); in ef4_mac_reconfigure()
972 up_read(&efx->filter_sem); in ef4_mac_reconfigure()
977 * through phy_op->set_link_ksettings(), and pushed asynchronously to the MAC
987 WARN_ON(!mutex_is_locked(&efx->mac_lock)); in __ef4_reconfigure_port()
990 phy_mode = efx->phy_mode; in __ef4_reconfigure_port()
992 efx->phy_mode |= PHY_MODE_TX_DISABLED; in __ef4_reconfigure_port()
994 efx->phy_mode &= ~PHY_MODE_TX_DISABLED; in __ef4_reconfigure_port()
996 rc = efx->type->reconfigure_port(efx); in __ef4_reconfigure_port()
999 efx->phy_mode = phy_mode; in __ef4_reconfigure_port()
1012 mutex_lock(&efx->mac_lock); in ef4_reconfigure_port()
1014 mutex_unlock(&efx->mac_lock); in ef4_reconfigure_port()
1026 mutex_lock(&efx->mac_lock); in ef4_mac_work()
1027 if (efx->port_enabled) in ef4_mac_work()
1029 mutex_unlock(&efx->mac_lock); in ef4_mac_work()
1036 netif_dbg(efx, probe, efx->net_dev, "create port\n"); in ef4_probe_port()
1039 efx->phy_mode = PHY_MODE_SPECIAL; in ef4_probe_port()
1042 rc = efx->type->probe_port(efx); in ef4_probe_port()
1047 ether_addr_copy(efx->net_dev->dev_addr, efx->net_dev->perm_addr); in ef4_probe_port()
1056 netif_dbg(efx, drv, efx->net_dev, "init port\n"); in ef4_init_port()
1058 mutex_lock(&efx->mac_lock); in ef4_init_port()
1060 rc = efx->phy_op->init(efx); in ef4_init_port()
1064 efx->port_initialized = true; in ef4_init_port()
1071 rc = efx->phy_op->reconfigure(efx); in ef4_init_port()
1072 if (rc && rc != -EPERM) in ef4_init_port()
1075 mutex_unlock(&efx->mac_lock); in ef4_init_port()
1079 efx->phy_op->fini(efx); in ef4_init_port()
1081 mutex_unlock(&efx->mac_lock); in ef4_init_port()
1087 netif_dbg(efx, ifup, efx->net_dev, "start port\n"); in ef4_start_port()
1088 BUG_ON(efx->port_enabled); in ef4_start_port()
1090 mutex_lock(&efx->mac_lock); in ef4_start_port()
1091 efx->port_enabled = true; in ef4_start_port()
1096 mutex_unlock(&efx->mac_lock); in ef4_start_port()
1100 * and the async self-test, wait for them to finish and prevent them
1106 netif_dbg(efx, ifdown, efx->net_dev, "stop port\n"); in ef4_stop_port()
1110 mutex_lock(&efx->mac_lock); in ef4_stop_port()
1111 efx->port_enabled = false; in ef4_stop_port()
1112 mutex_unlock(&efx->mac_lock); in ef4_stop_port()
1115 netif_addr_lock_bh(efx->net_dev); in ef4_stop_port()
1116 netif_addr_unlock_bh(efx->net_dev); in ef4_stop_port()
1118 cancel_delayed_work_sync(&efx->monitor_work); in ef4_stop_port()
1120 cancel_work_sync(&efx->mac_work); in ef4_stop_port()
1125 netif_dbg(efx, drv, efx->net_dev, "shut down port\n"); in ef4_fini_port()
1127 if (!efx->port_initialized) in ef4_fini_port()
1130 efx->phy_op->fini(efx); in ef4_fini_port()
1131 efx->port_initialized = false; in ef4_fini_port()
1133 efx->link_state.up = false; in ef4_fini_port()
1139 netif_dbg(efx, drv, efx->net_dev, "destroying port\n"); in ef4_remove_port()
1141 efx->type->remove_port(efx); in ef4_remove_port()
1155 return left->type == right->type && in ef4_same_controller()
1156 left->vpd_sn && right->vpd_sn && in ef4_same_controller()
1157 !strcmp(left->vpd_sn, right->vpd_sn); in ef4_same_controller()
1164 if (efx->primary == efx) { in ef4_associate()
1167 netif_dbg(efx, probe, efx->net_dev, "adding to primary list\n"); in ef4_associate()
1168 list_add_tail(&efx->node, &ef4_primary_list); in ef4_associate()
1173 list_del(&other->node); in ef4_associate()
1174 netif_dbg(other, probe, other->net_dev, in ef4_associate()
1176 pci_name(efx->pci_dev), in ef4_associate()
1177 efx->net_dev->name); in ef4_associate()
1178 list_add_tail(&other->node, in ef4_associate()
1179 &efx->secondary_list); in ef4_associate()
1180 other->primary = efx; in ef4_associate()
1188 netif_dbg(efx, probe, efx->net_dev, in ef4_associate()
1190 pci_name(other->pci_dev), in ef4_associate()
1191 other->net_dev->name); in ef4_associate()
1192 list_add_tail(&efx->node, in ef4_associate()
1193 &other->secondary_list); in ef4_associate()
1194 efx->primary = other; in ef4_associate()
1199 netif_dbg(efx, probe, efx->net_dev, in ef4_associate()
1201 list_add_tail(&efx->node, &ef4_unassociated_list); in ef4_associate()
1209 list_del(&efx->node); in ef4_dissociate()
1210 efx->primary = NULL; in ef4_dissociate()
1212 list_for_each_entry_safe(other, next, &efx->secondary_list, node) { in ef4_dissociate()
1213 list_del(&other->node); in ef4_dissociate()
1214 netif_dbg(other, probe, other->net_dev, in ef4_dissociate()
1216 list_add_tail(&other->node, &ef4_unassociated_list); in ef4_dissociate()
1217 other->primary = NULL; in ef4_dissociate()
1224 struct pci_dev *pci_dev = efx->pci_dev; in ef4_init_io()
1225 dma_addr_t dma_mask = efx->type->max_dma_mask; in ef4_init_io()
1226 unsigned int mem_map_size = efx->type->mem_map_size(efx); in ef4_init_io()
1229 netif_dbg(efx, probe, efx->net_dev, "initialising I/O\n"); in ef4_init_io()
1231 bar = efx->type->mem_bar; in ef4_init_io()
1235 netif_err(efx, probe, efx->net_dev, in ef4_init_io()
1247 rc = dma_set_mask_and_coherent(&pci_dev->dev, dma_mask); in ef4_init_io()
1253 netif_err(efx, probe, efx->net_dev, in ef4_init_io()
1257 netif_dbg(efx, probe, efx->net_dev, in ef4_init_io()
1260 efx->membase_phys = pci_resource_start(efx->pci_dev, bar); in ef4_init_io()
1263 netif_err(efx, probe, efx->net_dev, in ef4_init_io()
1265 rc = -EIO; in ef4_init_io()
1268 efx->membase = ioremap(efx->membase_phys, mem_map_size); in ef4_init_io()
1269 if (!efx->membase) { in ef4_init_io()
1270 netif_err(efx, probe, efx->net_dev, in ef4_init_io()
1272 (unsigned long long)efx->membase_phys, mem_map_size); in ef4_init_io()
1273 rc = -ENOMEM; in ef4_init_io()
1276 netif_dbg(efx, probe, efx->net_dev, in ef4_init_io()
1278 (unsigned long long)efx->membase_phys, mem_map_size, in ef4_init_io()
1279 efx->membase); in ef4_init_io()
1284 pci_release_region(efx->pci_dev, bar); in ef4_init_io()
1286 efx->membase_phys = 0; in ef4_init_io()
1288 pci_disable_device(efx->pci_dev); in ef4_init_io()
1297 netif_dbg(efx, drv, efx->net_dev, "shutting down I/O\n"); in ef4_fini_io()
1299 if (efx->membase) { in ef4_fini_io()
1300 iounmap(efx->membase); in ef4_fini_io()
1301 efx->membase = NULL; in ef4_fini_io()
1304 if (efx->membase_phys) { in ef4_fini_io()
1305 bar = efx->type->mem_bar; in ef4_fini_io()
1306 pci_release_region(efx->pci_dev, bar); in ef4_fini_io()
1307 efx->membase_phys = 0; in ef4_fini_io()
1310 /* Don't disable bus-mastering if VFs are assigned */ in ef4_fini_io()
1311 if (!pci_vfs_assigned(efx->pci_dev)) in ef4_fini_io()
1312 pci_disable_device(efx->pci_dev); in ef4_fini_io()
1319 for (i = 0; i < ARRAY_SIZE(efx->rx_indir_table); i++) in ef4_set_default_rx_indir_table()
1320 efx->rx_indir_table[i] = in ef4_set_default_rx_indir_table()
1321 ethtool_rxfh_indir_default(i, efx->rss_spread); in ef4_set_default_rx_indir_table()
1334 netif_warn(efx, probe, efx->net_dev, in ef4_wanted_parallelism()
1352 netif_cond_dbg(efx, probe, efx->net_dev, !rss_cpus, warn, in ef4_wanted_parallelism()
1371 if (efx->extra_channel_type[i]) in ef4_probe_interrupts()
1374 if (efx->interrupt_mode == EF4_INT_MODE_MSIX) { in ef4_probe_interrupts()
1382 n_channels = min(n_channels, efx->max_channels); in ef4_probe_interrupts()
1386 rc = pci_enable_msix_range(efx->pci_dev, in ef4_probe_interrupts()
1390 efx->interrupt_mode = EF4_INT_MODE_MSI; in ef4_probe_interrupts()
1391 netif_err(efx, drv, efx->net_dev, in ef4_probe_interrupts()
1392 "could not enable MSI-X\n"); in ef4_probe_interrupts()
1394 netif_err(efx, drv, efx->net_dev, in ef4_probe_interrupts()
1395 "WARNING: Insufficient MSI-X vectors" in ef4_probe_interrupts()
1397 netif_err(efx, drv, efx->net_dev, in ef4_probe_interrupts()
1403 efx->n_channels = n_channels; in ef4_probe_interrupts()
1405 n_channels -= extra_channels; in ef4_probe_interrupts()
1407 efx->n_tx_channels = min(max(n_channels / 2, in ef4_probe_interrupts()
1409 efx->max_tx_channels); in ef4_probe_interrupts()
1410 efx->n_rx_channels = max(n_channels - in ef4_probe_interrupts()
1411 efx->n_tx_channels, in ef4_probe_interrupts()
1414 efx->n_tx_channels = min(n_channels, in ef4_probe_interrupts()
1415 efx->max_tx_channels); in ef4_probe_interrupts()
1416 efx->n_rx_channels = n_channels; in ef4_probe_interrupts()
1418 for (i = 0; i < efx->n_channels; i++) in ef4_probe_interrupts()
1419 ef4_get_channel(efx, i)->irq = in ef4_probe_interrupts()
1425 if (efx->interrupt_mode == EF4_INT_MODE_MSI) { in ef4_probe_interrupts()
1426 efx->n_channels = 1; in ef4_probe_interrupts()
1427 efx->n_rx_channels = 1; in ef4_probe_interrupts()
1428 efx->n_tx_channels = 1; in ef4_probe_interrupts()
1429 rc = pci_enable_msi(efx->pci_dev); in ef4_probe_interrupts()
1431 ef4_get_channel(efx, 0)->irq = efx->pci_dev->irq; in ef4_probe_interrupts()
1433 netif_err(efx, drv, efx->net_dev, in ef4_probe_interrupts()
1435 efx->interrupt_mode = EF4_INT_MODE_LEGACY; in ef4_probe_interrupts()
1440 if (efx->interrupt_mode == EF4_INT_MODE_LEGACY) { in ef4_probe_interrupts()
1441 efx->n_channels = 1 + (ef4_separate_tx_channels ? 1 : 0); in ef4_probe_interrupts()
1442 efx->n_rx_channels = 1; in ef4_probe_interrupts()
1443 efx->n_tx_channels = 1; in ef4_probe_interrupts()
1444 efx->legacy_irq = efx->pci_dev->irq; in ef4_probe_interrupts()
1448 j = efx->n_channels; in ef4_probe_interrupts()
1450 if (!efx->extra_channel_type[i]) in ef4_probe_interrupts()
1452 if (efx->interrupt_mode != EF4_INT_MODE_MSIX || in ef4_probe_interrupts()
1453 efx->n_channels <= extra_channels) { in ef4_probe_interrupts()
1454 efx->extra_channel_type[i]->handle_no_channel(efx); in ef4_probe_interrupts()
1456 --j; in ef4_probe_interrupts()
1457 ef4_get_channel(efx, j)->type = in ef4_probe_interrupts()
1458 efx->extra_channel_type[i]; in ef4_probe_interrupts()
1462 efx->rss_spread = efx->n_rx_channels; in ef4_probe_interrupts()
1472 BUG_ON(efx->state == STATE_DISABLED); in ef4_soft_enable_interrupts()
1474 efx->irq_soft_enabled = true; in ef4_soft_enable_interrupts()
1478 if (!channel->type->keep_eventq) { in ef4_soft_enable_interrupts()
1493 if (!channel->type->keep_eventq) in ef4_soft_enable_interrupts()
1504 if (efx->state == STATE_DISABLED) in ef4_soft_disable_interrupts()
1507 efx->irq_soft_enabled = false; in ef4_soft_disable_interrupts()
1510 if (efx->legacy_irq) in ef4_soft_disable_interrupts()
1511 synchronize_irq(efx->legacy_irq); in ef4_soft_disable_interrupts()
1514 if (channel->irq) in ef4_soft_disable_interrupts()
1515 synchronize_irq(channel->irq); in ef4_soft_disable_interrupts()
1518 if (!channel->type->keep_eventq) in ef4_soft_disable_interrupts()
1528 BUG_ON(efx->state == STATE_DISABLED); in ef4_enable_interrupts()
1530 if (efx->eeh_disabled_legacy_irq) { in ef4_enable_interrupts()
1531 enable_irq(efx->legacy_irq); in ef4_enable_interrupts()
1532 efx->eeh_disabled_legacy_irq = false; in ef4_enable_interrupts()
1535 efx->type->irq_enable_master(efx); in ef4_enable_interrupts()
1538 if (channel->type->keep_eventq) { in ef4_enable_interrupts()
1556 if (channel->type->keep_eventq) in ef4_enable_interrupts()
1560 efx->type->irq_disable_non_ev(efx); in ef4_enable_interrupts()
1572 if (channel->type->keep_eventq) in ef4_disable_interrupts()
1576 efx->type->irq_disable_non_ev(efx); in ef4_disable_interrupts()
1583 /* Remove MSI/MSI-X interrupts */ in ef4_remove_interrupts()
1585 channel->irq = 0; in ef4_remove_interrupts()
1586 pci_disable_msi(efx->pci_dev); in ef4_remove_interrupts()
1587 pci_disable_msix(efx->pci_dev); in ef4_remove_interrupts()
1590 efx->legacy_irq = 0; in ef4_remove_interrupts()
1598 efx->tx_channel_offset = in ef4_set_channels()
1600 efx->n_channels - efx->n_tx_channels : 0; in ef4_set_channels()
1604 * RX-only and TX-only channels. in ef4_set_channels()
1607 if (channel->channel < efx->n_rx_channels) in ef4_set_channels()
1608 channel->rx_queue.core_index = channel->channel; in ef4_set_channels()
1610 channel->rx_queue.core_index = -1; in ef4_set_channels()
1613 tx_queue->queue -= (efx->tx_channel_offset * in ef4_set_channels()
1622 netif_dbg(efx, probe, efx->net_dev, "creating NIC\n"); in ef4_probe_nic()
1624 /* Carry out hardware-type specific initialisation */ in ef4_probe_nic()
1625 rc = efx->type->probe(efx); in ef4_probe_nic()
1630 if (!efx->max_channels || !efx->max_tx_channels) { in ef4_probe_nic()
1631 netif_err(efx, drv, efx->net_dev, in ef4_probe_nic()
1634 rc = -ENOSPC; in ef4_probe_nic()
1639 * to hook in MSI-X interrupts. in ef4_probe_nic()
1648 rc = efx->type->dimension_resources(efx); in ef4_probe_nic()
1649 if (rc != 0 && rc != -EAGAIN) in ef4_probe_nic()
1652 if (rc == -EAGAIN) in ef4_probe_nic()
1656 } while (rc == -EAGAIN); in ef4_probe_nic()
1658 if (efx->n_channels > 1) in ef4_probe_nic()
1659 netdev_rss_key_fill(&efx->rx_hash_key, in ef4_probe_nic()
1660 sizeof(efx->rx_hash_key)); in ef4_probe_nic()
1663 netif_set_real_num_tx_queues(efx->net_dev, efx->n_tx_channels); in ef4_probe_nic()
1664 netif_set_real_num_rx_queues(efx->net_dev, efx->n_rx_channels); in ef4_probe_nic()
1667 efx->irq_mod_step_us = DIV_ROUND_UP(efx->timer_quantum_ns, 1000); in ef4_probe_nic()
1676 efx->type->remove(efx); in ef4_probe_nic()
1682 netif_dbg(efx, drv, efx->net_dev, "destroying NIC\n"); in ef4_remove_nic()
1685 efx->type->remove(efx); in ef4_remove_nic()
1692 spin_lock_init(&efx->filter_lock); in ef4_probe_filters()
1693 init_rwsem(&efx->filter_sem); in ef4_probe_filters()
1694 mutex_lock(&efx->mac_lock); in ef4_probe_filters()
1695 down_write(&efx->filter_sem); in ef4_probe_filters()
1696 rc = efx->type->filter_table_probe(efx); in ef4_probe_filters()
1701 if (efx->type->offload_features & NETIF_F_NTUPLE) { in ef4_probe_filters()
1706 channel->rps_flow_id = in ef4_probe_filters()
1707 kcalloc(efx->type->max_rx_ip_filters, in ef4_probe_filters()
1708 sizeof(*channel->rps_flow_id), in ef4_probe_filters()
1710 if (!channel->rps_flow_id) in ef4_probe_filters()
1714 i < efx->type->max_rx_ip_filters; in ef4_probe_filters()
1716 channel->rps_flow_id[i] = in ef4_probe_filters()
1722 kfree(channel->rps_flow_id); in ef4_probe_filters()
1723 efx->type->filter_table_remove(efx); in ef4_probe_filters()
1724 rc = -ENOMEM; in ef4_probe_filters()
1728 efx->rps_expire_index = efx->rps_expire_channel = 0; in ef4_probe_filters()
1732 up_write(&efx->filter_sem); in ef4_probe_filters()
1733 mutex_unlock(&efx->mac_lock); in ef4_probe_filters()
1743 kfree(channel->rps_flow_id); in ef4_remove_filters()
1745 down_write(&efx->filter_sem); in ef4_remove_filters()
1746 efx->type->filter_table_remove(efx); in ef4_remove_filters()
1747 up_write(&efx->filter_sem); in ef4_remove_filters()
1752 down_read(&efx->filter_sem); in ef4_restore_filters()
1753 efx->type->filter_table_restore(efx); in ef4_restore_filters()
1754 up_read(&efx->filter_sem); in ef4_restore_filters()
1769 netif_err(efx, probe, efx->net_dev, "failed to create NIC\n"); in ef4_probe_all()
1775 netif_err(efx, probe, efx->net_dev, "failed to create port\n"); in ef4_probe_all()
1781 rc = -EINVAL; in ef4_probe_all()
1784 efx->rxq_entries = efx->txq_entries = EF4_DEFAULT_DMAQ_SIZE; in ef4_probe_all()
1788 netif_err(efx, probe, efx->net_dev, in ef4_probe_all()
1820 BUG_ON(efx->state == STATE_DISABLED); in ef4_start_all()
1824 if (efx->port_enabled || !netif_running(efx->net_dev) || in ef4_start_all()
1825 efx->reset_pending) in ef4_start_all()
1832 if (efx->type->monitor != NULL) in ef4_start_all()
1833 queue_delayed_work(efx->workqueue, &efx->monitor_work, in ef4_start_all()
1836 efx->type->start_stats(efx); in ef4_start_all()
1837 efx->type->pull_stats(efx); in ef4_start_all()
1838 spin_lock_bh(&efx->stats_lock); in ef4_start_all()
1839 efx->type->update_stats(efx, NULL, NULL); in ef4_start_all()
1840 spin_unlock_bh(&efx->stats_lock); in ef4_start_all()
1853 if (!efx->port_enabled) in ef4_stop_all()
1859 efx->type->pull_stats(efx); in ef4_stop_all()
1860 spin_lock_bh(&efx->stats_lock); in ef4_stop_all()
1861 efx->type->update_stats(efx, NULL, NULL); in ef4_stop_all()
1862 spin_unlock_bh(&efx->stats_lock); in ef4_stop_all()
1863 efx->type->stop_stats(efx); in ef4_stop_all()
1870 WARN_ON(netif_running(efx->net_dev) && in ef4_stop_all()
1871 netif_device_present(efx->net_dev)); in ef4_stop_all()
1872 netif_tx_disable(efx->net_dev); in ef4_stop_all()
1894 if (usecs * 1000 < efx->timer_quantum_ns) in ef4_usecs_to_ticks()
1896 return usecs * 1000 / efx->timer_quantum_ns; in ef4_usecs_to_ticks()
1904 return DIV_ROUND_UP(ticks * efx->timer_quantum_ns, 1000); in ef4_ticks_to_usecs()
1917 timer_max_us = efx->timer_max_ns / 1000; in ef4_init_irq_moderation()
1920 return -EINVAL; in ef4_init_irq_moderation()
1922 if (tx_usecs != rx_usecs && efx->tx_channel_offset == 0 && in ef4_init_irq_moderation()
1924 netif_err(efx, drv, efx->net_dev, "Channels are shared. " in ef4_init_irq_moderation()
1926 return -EINVAL; in ef4_init_irq_moderation()
1929 efx->irq_rx_adaptive = rx_adaptive; in ef4_init_irq_moderation()
1930 efx->irq_rx_moderation_us = rx_usecs; in ef4_init_irq_moderation()
1933 channel->irq_moderation_us = rx_usecs; in ef4_init_irq_moderation()
1935 channel->irq_moderation_us = tx_usecs; in ef4_init_irq_moderation()
1944 *rx_adaptive = efx->irq_rx_adaptive; in ef4_get_irq_moderation()
1945 *rx_usecs = efx->irq_rx_moderation_us; in ef4_get_irq_moderation()
1951 if (efx->tx_channel_offset == 0) { in ef4_get_irq_moderation()
1956 tx_channel = efx->channel[efx->tx_channel_offset]; in ef4_get_irq_moderation()
1957 *tx_usecs = tx_channel->irq_moderation_us; in ef4_get_irq_moderation()
1973 netif_vdbg(efx, timer, efx->net_dev, in ef4_monitor()
1976 BUG_ON(efx->type->monitor == NULL); in ef4_monitor()
1981 if (mutex_trylock(&efx->mac_lock)) { in ef4_monitor()
1982 if (efx->port_enabled) in ef4_monitor()
1983 efx->type->monitor(efx); in ef4_monitor()
1984 mutex_unlock(&efx->mac_lock); in ef4_monitor()
1987 queue_delayed_work(efx->workqueue, &efx->monitor_work, in ef4_monitor()
2007 (data->phy_id & 0xfc00) == 0x0400) in ef4_ioctl()
2008 data->phy_id ^= MDIO_PHY_ID_C45 | 0x0400; in ef4_ioctl()
2010 return mdio_mii_ioctl(&efx->mdio, data, cmd); in ef4_ioctl()
2021 struct ef4_nic *efx = channel->efx; in ef4_init_napi_channel()
2023 channel->napi_dev = efx->net_dev; in ef4_init_napi_channel()
2024 netif_napi_add(channel->napi_dev, &channel->napi_str, in ef4_init_napi_channel()
2038 if (channel->napi_dev) in ef4_fini_napi_channel()
2039 netif_napi_del(&channel->napi_str); in ef4_fini_napi_channel()
2041 channel->napi_dev = NULL; in ef4_fini_napi_channel()
2064 netif_dbg(efx, ifup, efx->net_dev, "opening device on CPU %d\n", in ef4_net_open()
2070 if (efx->phy_mode & PHY_MODE_SPECIAL) in ef4_net_open()
2071 return -EBUSY; in ef4_net_open()
2090 netif_dbg(efx, ifdown, efx->net_dev, "closing on CPU %d\n", in ef4_net_stop()
2099 /* Context: process, dev_base_lock or RTNL held, non-blocking. */
2105 spin_lock_bh(&efx->stats_lock); in ef4_net_stats()
2106 efx->type->update_stats(efx, NULL, stats); in ef4_net_stats()
2107 spin_unlock_bh(&efx->stats_lock); in ef4_net_stats()
2115 netif_err(efx, tx_err, efx->net_dev, in ef4_watchdog()
2117 efx->port_enabled); in ef4_watchdog()
2133 netif_dbg(efx, drv, efx->net_dev, "changing MTU to %d\n", new_mtu); in ef4_change_mtu()
2138 mutex_lock(&efx->mac_lock); in ef4_change_mtu()
2139 net_dev->mtu = new_mtu; in ef4_change_mtu()
2141 mutex_unlock(&efx->mac_lock); in ef4_change_mtu()
2144 netif_device_attach(efx->net_dev); in ef4_change_mtu()
2152 u8 *new_addr = addr->sa_data; in ef4_set_mac_address()
2157 netif_err(efx, drv, efx->net_dev, in ef4_set_mac_address()
2160 return -EADDRNOTAVAIL; in ef4_set_mac_address()
2164 ether_addr_copy(old_addr, net_dev->dev_addr); in ef4_set_mac_address()
2165 ether_addr_copy(net_dev->dev_addr, new_addr); in ef4_set_mac_address()
2166 if (efx->type->set_mac_address) { in ef4_set_mac_address()
2167 rc = efx->type->set_mac_address(efx); in ef4_set_mac_address()
2169 ether_addr_copy(net_dev->dev_addr, old_addr); in ef4_set_mac_address()
2175 mutex_lock(&efx->mac_lock); in ef4_set_mac_address()
2177 mutex_unlock(&efx->mac_lock); in ef4_set_mac_address()
2187 if (efx->port_enabled) in ef4_set_rx_mode()
2188 queue_work(efx->workqueue, &efx->mac_work); in ef4_set_rx_mode()
2197 /* If disabling RX n-tuple filtering, clear existing filters */ in ef4_set_features()
2198 if (net_dev->features & ~data & NETIF_F_NTUPLE) { in ef4_set_features()
2199 rc = efx->type->filter_clear_rx(efx, EF4_FILTER_PRI_MANUAL); in ef4_set_features()
2205 if ((net_dev->features ^ data) & NETIF_F_HW_VLAN_CTAG_FILTER) { in ef4_set_features()
2235 strcpy(efx->name, efx->net_dev->name); in ef4_update_name()
2245 if ((net_dev->netdev_ops == &ef4_netdev_ops) && in ef4_netdev_event()
2260 return sprintf(buf, "%d\n", efx->phy_type); in phy_type_show()
2266 struct net_device *net_dev = efx->net_dev; in ef4_register_netdev()
2270 net_dev->watchdog_timeo = 5 * HZ; in ef4_register_netdev()
2271 net_dev->irq = efx->pci_dev->irq; in ef4_register_netdev()
2272 net_dev->netdev_ops = &ef4_netdev_ops; in ef4_register_netdev()
2273 net_dev->ethtool_ops = &ef4_ethtool_ops; in ef4_register_netdev()
2274 net_dev->gso_max_segs = EF4_TSO_MAX_SEGS; in ef4_register_netdev()
2275 net_dev->min_mtu = EF4_MIN_MTU; in ef4_register_netdev()
2276 net_dev->max_mtu = EF4_MAX_MTU; in ef4_register_netdev()
2284 efx->state = STATE_READY; in ef4_register_netdev()
2286 if (efx->reset_pending) { in ef4_register_netdev()
2287 netif_err(efx, probe, efx->net_dev, in ef4_register_netdev()
2289 rc = -EIO; in ef4_register_netdev()
2293 rc = dev_alloc_name(net_dev, net_dev->name); in ef4_register_netdev()
2315 rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_type); in ef4_register_netdev()
2317 netif_err(efx, drv, efx->net_dev, in ef4_register_netdev()
2328 efx->state = STATE_UNINIT; in ef4_register_netdev()
2330 netif_err(efx, drv, efx->net_dev, "could not register net dev\n"); in ef4_register_netdev()
2336 if (!efx->net_dev) in ef4_unregister_netdev()
2339 BUG_ON(netdev_priv(efx->net_dev) != efx); in ef4_unregister_netdev()
2342 strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name)); in ef4_unregister_netdev()
2343 device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type); in ef4_unregister_netdev()
2344 unregister_netdev(efx->net_dev); in ef4_unregister_netdev()
2363 mutex_lock(&efx->mac_lock); in ef4_reset_down()
2364 if (efx->port_initialized && method != RESET_TYPE_INVISIBLE && in ef4_reset_down()
2366 efx->phy_op->fini(efx); in ef4_reset_down()
2367 efx->type->fini(efx); in ef4_reset_down()
2382 rc = efx->type->init(efx); in ef4_reset_up()
2384 netif_err(efx, drv, efx->net_dev, "failed to initialise NIC\n"); in ef4_reset_up()
2391 if (efx->port_initialized && method != RESET_TYPE_INVISIBLE && in ef4_reset_up()
2393 rc = efx->phy_op->init(efx); in ef4_reset_up()
2396 rc = efx->phy_op->reconfigure(efx); in ef4_reset_up()
2397 if (rc && rc != -EPERM) in ef4_reset_up()
2398 netif_err(efx, drv, efx->net_dev, in ef4_reset_up()
2406 down_read(&efx->filter_sem); in ef4_reset_up()
2408 up_read(&efx->filter_sem); in ef4_reset_up()
2410 mutex_unlock(&efx->mac_lock); in ef4_reset_up()
2417 efx->port_initialized = false; in ef4_reset_up()
2419 mutex_unlock(&efx->mac_lock); in ef4_reset_up()
2434 netif_info(efx, drv, efx->net_dev, "resetting (%s)\n", in ef4_reset()
2440 rc = efx->type->reset(efx, method); in ef4_reset()
2442 netif_err(efx, drv, efx->net_dev, "failed to reset hardware\n"); in ef4_reset()
2450 efx->reset_pending &= -(1 << (method + 1)); in ef4_reset()
2451 else /* it doesn't fit into the well-ordered scope hierarchy */ in ef4_reset()
2452 __clear_bit(method, &efx->reset_pending); in ef4_reset()
2454 /* Reinitialise bus-mastering, which may have been turned off before in ef4_reset()
2458 pci_set_master(efx->pci_dev); in ef4_reset()
2473 dev_close(efx->net_dev); in ef4_reset()
2474 netif_err(efx, drv, efx->net_dev, "has been disabled\n"); in ef4_reset()
2475 efx->state = STATE_DISABLED; in ef4_reset()
2477 netif_dbg(efx, drv, efx->net_dev, "reset complete\n"); in ef4_reset()
2478 netif_device_attach(efx->net_dev); in ef4_reset()
2486 * Returns a non-zero value otherwise.
2496 struct eeh_dev *eehdev = pci_dev_to_eeh_dev(efx->pci_dev); in ef4_try_recovery()
2516 pending = READ_ONCE(efx->reset_pending); in ef4_reset_work()
2517 method = fls(pending) - 1; in ef4_reset_work()
2533 if (efx->state == STATE_READY) in ef4_reset_work()
2543 if (efx->state == STATE_RECOVERY) { in ef4_schedule_reset()
2544 netif_dbg(efx, drv, efx->net_dev, in ef4_schedule_reset()
2559 netif_dbg(efx, drv, efx->net_dev, "scheduling %s reset\n", in ef4_schedule_reset()
2563 method = efx->type->map_reset_reason(type); in ef4_schedule_reset()
2564 netif_dbg(efx, drv, efx->net_dev, in ef4_schedule_reset()
2570 set_bit(method, &efx->reset_pending); in ef4_schedule_reset()
2576 if (READ_ONCE(efx->state) != STATE_READY) in ef4_schedule_reset()
2579 queue_work(reset_workqueue, &efx->reset_work); in ef4_schedule_reset()
2633 * ef4_nic (including all sub-structures).
2641 INIT_LIST_HEAD(&efx->node); in ef4_init_struct()
2642 INIT_LIST_HEAD(&efx->secondary_list); in ef4_init_struct()
2643 spin_lock_init(&efx->biu_lock); in ef4_init_struct()
2645 INIT_LIST_HEAD(&efx->mtd_list); in ef4_init_struct()
2647 INIT_WORK(&efx->reset_work, ef4_reset_work); in ef4_init_struct()
2648 INIT_DELAYED_WORK(&efx->monitor_work, ef4_monitor); in ef4_init_struct()
2649 INIT_DELAYED_WORK(&efx->selftest_work, ef4_selftest_async_work); in ef4_init_struct()
2650 efx->pci_dev = pci_dev; in ef4_init_struct()
2651 efx->msg_enable = debug; in ef4_init_struct()
2652 efx->state = STATE_UNINIT; in ef4_init_struct()
2653 strlcpy(efx->name, pci_name(pci_dev), sizeof(efx->name)); in ef4_init_struct()
2655 efx->net_dev = net_dev; in ef4_init_struct()
2656 efx->rx_prefix_size = efx->type->rx_prefix_size; in ef4_init_struct()
2657 efx->rx_ip_align = in ef4_init_struct()
2658 NET_IP_ALIGN ? (efx->rx_prefix_size + NET_IP_ALIGN) % 4 : 0; in ef4_init_struct()
2659 efx->rx_packet_hash_offset = in ef4_init_struct()
2660 efx->type->rx_hash_offset - efx->type->rx_prefix_size; in ef4_init_struct()
2661 efx->rx_packet_ts_offset = in ef4_init_struct()
2662 efx->type->rx_ts_offset - efx->type->rx_prefix_size; in ef4_init_struct()
2663 spin_lock_init(&efx->stats_lock); in ef4_init_struct()
2664 mutex_init(&efx->mac_lock); in ef4_init_struct()
2665 efx->phy_op = &ef4_dummy_phy_operations; in ef4_init_struct()
2666 efx->mdio.dev = net_dev; in ef4_init_struct()
2667 INIT_WORK(&efx->mac_work, ef4_mac_work); in ef4_init_struct()
2668 init_waitqueue_head(&efx->flush_wq); in ef4_init_struct()
2671 efx->channel[i] = ef4_alloc_channel(efx, i, NULL); in ef4_init_struct()
2672 if (!efx->channel[i]) in ef4_init_struct()
2674 efx->msi_context[i].efx = efx; in ef4_init_struct()
2675 efx->msi_context[i].index = i; in ef4_init_struct()
2679 efx->interrupt_mode = max(efx->type->max_interrupt_mode, in ef4_init_struct()
2683 snprintf(efx->workqueue_name, sizeof(efx->workqueue_name), "sfc%s", in ef4_init_struct()
2685 efx->workqueue = create_singlethread_workqueue(efx->workqueue_name); in ef4_init_struct()
2686 if (!efx->workqueue) in ef4_init_struct()
2693 return -ENOMEM; in ef4_init_struct()
2701 kfree(efx->channel[i]); in ef4_fini_struct()
2703 kfree(efx->vpd_sn); in ef4_fini_struct()
2705 if (efx->workqueue) { in ef4_fini_struct()
2706 destroy_workqueue(efx->workqueue); in ef4_fini_struct()
2707 efx->workqueue = NULL; in ef4_fini_struct()
2717 n_rx_nodesc_trunc += channel->n_rx_nodesc_trunc; in ef4_update_sw_stats()
2719 stats[GENERIC_STAT_rx_noskb_drops] = atomic_read(&efx->n_rx_noskb_drops); in ef4_update_sw_stats()
2736 BUG_ON(efx->state == STATE_READY); in ef4_pci_remove_main()
2737 cancel_work_sync(&efx->reset_work); in ef4_pci_remove_main()
2742 efx->type->fini(efx); in ef4_pci_remove_main()
2762 dev_close(efx->net_dev); in ef4_pci_remove()
2764 efx->state = STATE_UNINIT; in ef4_pci_remove()
2774 netif_dbg(efx, drv, efx->net_dev, "shutdown successful\n"); in ef4_pci_remove()
2777 free_netdev(efx->net_dev); in ef4_pci_remove()
2787 struct pci_dev *dev = efx->pci_dev; in ef4_probe_vpd_strings()
2810 efx->vpd_sn = kmemdup_nul(vpd_data + start, kw_len, GFP_KERNEL); in ef4_probe_vpd_strings()
2823 /* Do start-of-day initialisation */ in ef4_pci_probe_main()
2830 rc = efx->type->init(efx); in ef4_pci_probe_main()
2832 netif_err(efx, probe, efx->net_dev, in ef4_pci_probe_main()
2839 netif_err(efx, probe, efx->net_dev, in ef4_pci_probe_main()
2858 efx->type->fini(efx); in ef4_pci_probe_main()
2886 return -ENOMEM; in ef4_pci_probe()
2888 efx->type = (const struct ef4_nic_type *) entry->driver_data; in ef4_pci_probe()
2889 efx->fixed_features |= NETIF_F_HIGHDMA; in ef4_pci_probe()
2892 SET_NETDEV_DEV(net_dev, &pci_dev->dev); in ef4_pci_probe()
2897 netif_info(efx, probe, efx->net_dev, in ef4_pci_probe()
2911 net_dev->features |= (efx->type->offload_features | NETIF_F_SG | in ef4_pci_probe()
2914 net_dev->vlan_features |= (NETIF_F_HW_CSUM | NETIF_F_SG | in ef4_pci_probe()
2917 net_dev->hw_features = net_dev->features & ~efx->fixed_features; in ef4_pci_probe()
2923 net_dev->features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; in ef4_pci_probe()
2924 net_dev->features |= efx->fixed_features; in ef4_pci_probe()
2930 netif_dbg(efx, probe, efx->net_dev, "initialisation successful\n"); in ef4_pci_probe()
2936 if (rc && rc != -EPERM) in ef4_pci_probe()
2937 netif_warn(efx, probe, efx->net_dev, in ef4_pci_probe()
2941 if (rc && rc != -EINVAL) in ef4_pci_probe()
2942 netif_notice(efx, probe, efx->net_dev, in ef4_pci_probe()
2956 netif_dbg(efx, drv, efx->net_dev, "initialisation failed. rc=%d\n", rc); in ef4_pci_probe()
2967 if (efx->state != STATE_DISABLED) { in ef4_pm_freeze()
2968 efx->state = STATE_UNINIT; in ef4_pm_freeze()
2988 if (efx->state != STATE_DISABLED) { in ef4_pm_thaw()
2993 mutex_lock(&efx->mac_lock); in ef4_pm_thaw()
2994 efx->phy_op->reconfigure(efx); in ef4_pm_thaw()
2995 mutex_unlock(&efx->mac_lock); in ef4_pm_thaw()
2999 netif_device_attach(efx->net_dev); in ef4_pm_thaw()
3001 efx->state = STATE_READY; in ef4_pm_thaw()
3003 efx->type->resume_wol(efx); in ef4_pm_thaw()
3009 queue_work(reset_workqueue, &efx->reset_work); in ef4_pm_thaw()
3024 efx->type->fini(efx); in ef4_pm_poweroff()
3026 efx->reset_pending = 0; in ef4_pm_poweroff()
3046 pci_set_master(efx->pci_dev); in ef4_pm_resume()
3047 rc = efx->type->reset(efx, RESET_TYPE_ALL); in ef4_pm_resume()
3050 rc = efx->type->init(efx); in ef4_pm_resume()
3092 if (efx->state != STATE_DISABLED) { in ef4_io_error_detected()
3093 efx->state = STATE_RECOVERY; in ef4_io_error_detected()
3094 efx->reset_pending = 0; in ef4_io_error_detected()
3123 netif_err(efx, hw, efx->net_dev, in ef4_io_slot_reset()
3124 "Cannot re-enable PCI device after reset.\n"); in ef4_io_slot_reset()
3139 if (efx->state == STATE_DISABLED) in ef4_io_resume()
3144 netif_err(efx, hw, efx->net_dev, in ef4_io_resume()
3147 efx->state = STATE_READY; in ef4_io_resume()
3148 netif_dbg(efx, hw, efx->net_dev, in ef4_io_resume()
3199 rc = -ENOMEM; in ef4_init_module()