Lines Matching refs:efx
102 static void efx_remove_port(struct efx_nic *efx);
103 static int efx_xdp_setup_prog(struct efx_nic *efx, struct bpf_prog *prog);
108 #define EFX_ASSERT_RESET_SERIALISED(efx) \ argument
110 if ((efx->state == STATE_READY) || \
111 (efx->state == STATE_RECOVERY) || \
112 (efx->state == STATE_DISABLED)) \
122 static void efx_fini_port(struct efx_nic *efx);
124 static int efx_probe_port(struct efx_nic *efx) in efx_probe_port() argument
128 netif_dbg(efx, probe, efx->net_dev, "create port\n"); in efx_probe_port()
131 efx->phy_mode = PHY_MODE_SPECIAL; in efx_probe_port()
134 rc = efx->type->probe_port(efx); in efx_probe_port()
139 ether_addr_copy(efx->net_dev->dev_addr, efx->net_dev->perm_addr); in efx_probe_port()
144 static int efx_init_port(struct efx_nic *efx) in efx_init_port() argument
148 netif_dbg(efx, drv, efx->net_dev, "init port\n"); in efx_init_port()
150 mutex_lock(&efx->mac_lock); in efx_init_port()
152 efx->port_initialized = true; in efx_init_port()
155 rc = efx_mcdi_port_reconfigure(efx); in efx_init_port()
159 mutex_unlock(&efx->mac_lock); in efx_init_port()
163 mutex_unlock(&efx->mac_lock); in efx_init_port()
167 static void efx_fini_port(struct efx_nic *efx) in efx_fini_port() argument
169 netif_dbg(efx, drv, efx->net_dev, "shut down port\n"); in efx_fini_port()
171 if (!efx->port_initialized) in efx_fini_port()
174 efx->port_initialized = false; in efx_fini_port()
176 efx->link_state.up = false; in efx_fini_port()
177 efx_link_status_changed(efx); in efx_fini_port()
180 static void efx_remove_port(struct efx_nic *efx) in efx_remove_port() argument
182 netif_dbg(efx, drv, efx->net_dev, "destroying port\n"); in efx_remove_port()
184 efx->type->remove_port(efx); in efx_remove_port()
203 static void efx_associate(struct efx_nic *efx) in efx_associate() argument
207 if (efx->primary == efx) { in efx_associate()
210 netif_dbg(efx, probe, efx->net_dev, "adding to primary list\n"); in efx_associate()
211 list_add_tail(&efx->node, &efx_primary_list); in efx_associate()
215 if (efx_same_controller(efx, other)) { in efx_associate()
219 pci_name(efx->pci_dev), in efx_associate()
220 efx->net_dev->name); in efx_associate()
222 &efx->secondary_list); in efx_associate()
223 other->primary = efx; in efx_associate()
230 if (efx_same_controller(efx, other)) { in efx_associate()
231 netif_dbg(efx, probe, efx->net_dev, in efx_associate()
235 list_add_tail(&efx->node, in efx_associate()
237 efx->primary = other; in efx_associate()
242 netif_dbg(efx, probe, efx->net_dev, in efx_associate()
244 list_add_tail(&efx->node, &efx_unassociated_list); in efx_associate()
248 static void efx_dissociate(struct efx_nic *efx) in efx_dissociate() argument
252 list_del(&efx->node); in efx_dissociate()
253 efx->primary = NULL; in efx_dissociate()
255 list_for_each_entry_safe(other, next, &efx->secondary_list, node) { in efx_dissociate()
264 static int efx_probe_nic(struct efx_nic *efx) in efx_probe_nic() argument
268 netif_dbg(efx, probe, efx->net_dev, "creating NIC\n"); in efx_probe_nic()
271 rc = efx->type->probe(efx); in efx_probe_nic()
276 if (!efx->max_channels || !efx->max_tx_channels) { in efx_probe_nic()
277 netif_err(efx, drv, efx->net_dev, in efx_probe_nic()
287 rc = efx_probe_interrupts(efx); in efx_probe_nic()
291 rc = efx_set_channels(efx); in efx_probe_nic()
296 rc = efx->type->dimension_resources(efx); in efx_probe_nic()
302 efx_remove_interrupts(efx); in efx_probe_nic()
306 if (efx->n_channels > 1) in efx_probe_nic()
307 netdev_rss_key_fill(efx->rss_context.rx_hash_key, in efx_probe_nic()
308 sizeof(efx->rss_context.rx_hash_key)); in efx_probe_nic()
309 efx_set_default_rx_indir_table(efx, &efx->rss_context); in efx_probe_nic()
312 efx->irq_mod_step_us = DIV_ROUND_UP(efx->timer_quantum_ns, 1000); in efx_probe_nic()
313 efx_init_irq_moderation(efx, tx_irq_mod_usec, rx_irq_mod_usec, true, in efx_probe_nic()
319 efx_remove_interrupts(efx); in efx_probe_nic()
321 efx->type->remove(efx); in efx_probe_nic()
325 static void efx_remove_nic(struct efx_nic *efx) in efx_remove_nic() argument
327 netif_dbg(efx, drv, efx->net_dev, "destroying NIC\n"); in efx_remove_nic()
329 efx_remove_interrupts(efx); in efx_remove_nic()
330 efx->type->remove(efx); in efx_remove_nic()
339 static int efx_probe_all(struct efx_nic *efx) in efx_probe_all() argument
343 rc = efx_probe_nic(efx); in efx_probe_all()
345 netif_err(efx, probe, efx->net_dev, "failed to create NIC\n"); in efx_probe_all()
349 rc = efx_probe_port(efx); in efx_probe_all()
351 netif_err(efx, probe, efx->net_dev, "failed to create port\n"); in efx_probe_all()
356 if (WARN_ON(EFX_DEFAULT_DMAQ_SIZE < EFX_TXQ_MIN_ENT(efx))) { in efx_probe_all()
362 rc = efx->type->vswitching_probe(efx); in efx_probe_all()
364 netif_warn(efx, probe, efx->net_dev, in efx_probe_all()
369 rc = efx_probe_filters(efx); in efx_probe_all()
371 netif_err(efx, probe, efx->net_dev, in efx_probe_all()
376 rc = efx_probe_channels(efx); in efx_probe_all()
383 efx_remove_filters(efx); in efx_probe_all()
386 efx->type->vswitching_remove(efx); in efx_probe_all()
389 efx_remove_port(efx); in efx_probe_all()
391 efx_remove_nic(efx); in efx_probe_all()
396 static void efx_remove_all(struct efx_nic *efx) in efx_remove_all() argument
399 efx_xdp_setup_prog(efx, NULL); in efx_remove_all()
402 efx_remove_channels(efx); in efx_remove_all()
403 efx_remove_filters(efx); in efx_remove_all()
405 efx->type->vswitching_remove(efx); in efx_remove_all()
407 efx_remove_port(efx); in efx_remove_all()
408 efx_remove_nic(efx); in efx_remove_all()
416 unsigned int efx_usecs_to_ticks(struct efx_nic *efx, unsigned int usecs) in efx_usecs_to_ticks() argument
420 if (usecs * 1000 < efx->timer_quantum_ns) in efx_usecs_to_ticks()
422 return usecs * 1000 / efx->timer_quantum_ns; in efx_usecs_to_ticks()
425 unsigned int efx_ticks_to_usecs(struct efx_nic *efx, unsigned int ticks) in efx_ticks_to_usecs() argument
430 return DIV_ROUND_UP(ticks * efx->timer_quantum_ns, 1000); in efx_ticks_to_usecs()
434 int efx_init_irq_moderation(struct efx_nic *efx, unsigned int tx_usecs, in efx_init_irq_moderation() argument
441 EFX_ASSERT_RESET_SERIALISED(efx); in efx_init_irq_moderation()
443 timer_max_us = efx->timer_max_ns / 1000; in efx_init_irq_moderation()
448 if (tx_usecs != rx_usecs && efx->tx_channel_offset == 0 && in efx_init_irq_moderation()
450 netif_err(efx, drv, efx->net_dev, "Channels are shared. " in efx_init_irq_moderation()
455 efx->irq_rx_adaptive = rx_adaptive; in efx_init_irq_moderation()
456 efx->irq_rx_moderation_us = rx_usecs; in efx_init_irq_moderation()
457 efx_for_each_channel(channel, efx) { in efx_init_irq_moderation()
469 void efx_get_irq_moderation(struct efx_nic *efx, unsigned int *tx_usecs, in efx_get_irq_moderation() argument
472 *rx_adaptive = efx->irq_rx_adaptive; in efx_get_irq_moderation()
473 *rx_usecs = efx->irq_rx_moderation_us; in efx_get_irq_moderation()
479 if (efx->tx_channel_offset == 0) { in efx_get_irq_moderation()
484 tx_channel = efx->channel[efx->tx_channel_offset]; in efx_get_irq_moderation()
500 struct efx_nic *efx = netdev_priv(net_dev); in efx_ioctl() local
504 return efx_ptp_set_ts_config(efx, ifr); in efx_ioctl()
506 return efx_ptp_get_ts_config(efx, ifr); in efx_ioctl()
513 return mdio_mii_ioctl(&efx->mdio, data, cmd); in efx_ioctl()
525 struct efx_nic *efx = netdev_priv(net_dev); in efx_net_open() local
528 netif_dbg(efx, ifup, efx->net_dev, "opening device on CPU %d\n", in efx_net_open()
531 rc = efx_check_disabled(efx); in efx_net_open()
534 if (efx->phy_mode & PHY_MODE_SPECIAL) in efx_net_open()
536 if (efx_mcdi_poll_reboot(efx) && efx_reset(efx, RESET_TYPE_ALL)) in efx_net_open()
541 efx_link_status_changed(efx); in efx_net_open()
543 efx_start_all(efx); in efx_net_open()
544 if (efx->state == STATE_DISABLED || efx->reset_pending) in efx_net_open()
545 netif_device_detach(efx->net_dev); in efx_net_open()
546 efx_selftest_async_start(efx); in efx_net_open()
556 struct efx_nic *efx = netdev_priv(net_dev); in efx_net_stop() local
558 netif_dbg(efx, ifdown, efx->net_dev, "closing on CPU %d\n", in efx_net_stop()
562 efx_stop_all(efx); in efx_net_stop()
569 struct efx_nic *efx = netdev_priv(net_dev); in efx_vlan_rx_add_vid() local
571 if (efx->type->vlan_rx_add_vid) in efx_vlan_rx_add_vid()
572 return efx->type->vlan_rx_add_vid(efx, proto, vid); in efx_vlan_rx_add_vid()
579 struct efx_nic *efx = netdev_priv(net_dev); in efx_vlan_rx_kill_vid() local
581 if (efx->type->vlan_rx_kill_vid) in efx_vlan_rx_kill_vid()
582 return efx->type->vlan_rx_kill_vid(efx, proto, vid); in efx_vlan_rx_kill_vid()
619 static int efx_xdp_setup_prog(struct efx_nic *efx, struct bpf_prog *prog) in efx_xdp_setup_prog() argument
623 if (efx->xdp_rxq_info_failed) { in efx_xdp_setup_prog()
624 netif_err(efx, drv, efx->net_dev, in efx_xdp_setup_prog()
629 if (prog && efx->net_dev->mtu > efx_xdp_max_mtu(efx)) { in efx_xdp_setup_prog()
630 netif_err(efx, drv, efx->net_dev, in efx_xdp_setup_prog()
632 efx->net_dev->mtu, efx_xdp_max_mtu(efx)); in efx_xdp_setup_prog()
636 old_prog = rtnl_dereference(efx->xdp_prog); in efx_xdp_setup_prog()
637 rcu_assign_pointer(efx->xdp_prog, prog); in efx_xdp_setup_prog()
648 struct efx_nic *efx = netdev_priv(dev); in efx_xdp() local
652 return efx_xdp_setup_prog(efx, xdp->prog); in efx_xdp()
661 struct efx_nic *efx = netdev_priv(dev); in efx_xdp_xmit() local
666 return efx_xdp_tx_buffers(efx, n, xdpfs, flags & XDP_XMIT_FLUSH); in efx_xdp_xmit()
669 static void efx_update_name(struct efx_nic *efx) in efx_update_name() argument
671 strcpy(efx->name, efx->net_dev->name); in efx_update_name()
672 efx_mtd_rename(efx); in efx_update_name()
673 efx_set_channel_names(efx); in efx_update_name()
695 struct efx_nic *efx = dev_get_drvdata(dev); in phy_type_show() local
696 return sprintf(buf, "%d\n", efx->phy_type); in phy_type_show()
700 static int efx_register_netdev(struct efx_nic *efx) in efx_register_netdev() argument
702 struct net_device *net_dev = efx->net_dev; in efx_register_netdev()
707 net_dev->irq = efx->pci_dev->irq; in efx_register_netdev()
709 if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0) in efx_register_netdev()
722 efx->state = STATE_READY; in efx_register_netdev()
724 if (efx->reset_pending) { in efx_register_netdev()
725 pci_err(efx->pci_dev, "aborting probe due to scheduled reset\n"); in efx_register_netdev()
733 efx_update_name(efx); in efx_register_netdev()
742 efx_for_each_channel(channel, efx) { in efx_register_netdev()
748 efx_associate(efx); in efx_register_netdev()
752 rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_type); in efx_register_netdev()
754 netif_err(efx, drv, efx->net_dev, in efx_register_netdev()
759 efx_init_mcdi_logging(efx); in efx_register_netdev()
765 efx_dissociate(efx); in efx_register_netdev()
768 efx->state = STATE_UNINIT; in efx_register_netdev()
770 netif_err(efx, drv, efx->net_dev, "could not register net dev\n"); in efx_register_netdev()
774 static void efx_unregister_netdev(struct efx_nic *efx) in efx_unregister_netdev() argument
776 if (!efx->net_dev) in efx_unregister_netdev()
779 BUG_ON(netdev_priv(efx->net_dev) != efx); in efx_unregister_netdev()
781 if (efx_dev_registered(efx)) { in efx_unregister_netdev()
782 strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name)); in efx_unregister_netdev()
783 efx_fini_mcdi_logging(efx); in efx_unregister_netdev()
784 device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type); in efx_unregister_netdev()
785 unregister_netdev(efx->net_dev); in efx_unregister_netdev()
826 void efx_update_sw_stats(struct efx_nic *efx, u64 *stats) in efx_update_sw_stats() argument
831 efx_for_each_channel(channel, efx) in efx_update_sw_stats()
834 stats[GENERIC_STAT_rx_noskb_drops] = atomic_read(&efx->n_rx_noskb_drops); in efx_update_sw_stats()
846 static void efx_pci_remove_main(struct efx_nic *efx) in efx_pci_remove_main() argument
851 BUG_ON(efx->state == STATE_READY); in efx_pci_remove_main()
852 efx_flush_reset_workqueue(efx); in efx_pci_remove_main()
854 efx_disable_interrupts(efx); in efx_pci_remove_main()
855 efx_clear_interrupt_affinity(efx); in efx_pci_remove_main()
856 efx_nic_fini_interrupt(efx); in efx_pci_remove_main()
857 efx_fini_port(efx); in efx_pci_remove_main()
858 efx->type->fini(efx); in efx_pci_remove_main()
859 efx_fini_napi(efx); in efx_pci_remove_main()
860 efx_remove_all(efx); in efx_pci_remove_main()
869 struct efx_nic *efx; in efx_pci_remove() local
871 efx = pci_get_drvdata(pci_dev); in efx_pci_remove()
872 if (!efx) in efx_pci_remove()
877 efx_dissociate(efx); in efx_pci_remove()
878 dev_close(efx->net_dev); in efx_pci_remove()
879 efx_disable_interrupts(efx); in efx_pci_remove()
880 efx->state = STATE_UNINIT; in efx_pci_remove()
883 if (efx->type->sriov_fini) in efx_pci_remove()
884 efx->type->sriov_fini(efx); in efx_pci_remove()
886 efx_unregister_netdev(efx); in efx_pci_remove()
888 efx_mtd_remove(efx); in efx_pci_remove()
890 efx_pci_remove_main(efx); in efx_pci_remove()
892 efx_fini_io(efx); in efx_pci_remove()
893 netif_dbg(efx, drv, efx->net_dev, "shutdown successful\n"); in efx_pci_remove()
895 efx_fini_struct(efx); in efx_pci_remove()
896 free_netdev(efx->net_dev); in efx_pci_remove()
905 static void efx_probe_vpd_strings(struct efx_nic *efx) in efx_probe_vpd_strings() argument
907 struct pci_dev *dev = efx->pci_dev; in efx_probe_vpd_strings()
930 efx->vpd_sn = kmemdup_nul(vpd_data + start, kw_len, GFP_KERNEL); in efx_probe_vpd_strings()
939 static int efx_pci_probe_main(struct efx_nic *efx) in efx_pci_probe_main() argument
944 rc = efx_probe_all(efx); in efx_pci_probe_main()
948 efx_init_napi(efx); in efx_pci_probe_main()
950 down_write(&efx->filter_sem); in efx_pci_probe_main()
951 rc = efx->type->init(efx); in efx_pci_probe_main()
952 up_write(&efx->filter_sem); in efx_pci_probe_main()
954 pci_err(efx->pci_dev, "failed to initialise NIC\n"); in efx_pci_probe_main()
958 rc = efx_init_port(efx); in efx_pci_probe_main()
960 netif_err(efx, probe, efx->net_dev, in efx_pci_probe_main()
965 rc = efx_nic_init_interrupt(efx); in efx_pci_probe_main()
969 efx_set_interrupt_affinity(efx); in efx_pci_probe_main()
970 rc = efx_enable_interrupts(efx); in efx_pci_probe_main()
977 efx_clear_interrupt_affinity(efx); in efx_pci_probe_main()
978 efx_nic_fini_interrupt(efx); in efx_pci_probe_main()
980 efx_fini_port(efx); in efx_pci_probe_main()
982 efx->type->fini(efx); in efx_pci_probe_main()
984 efx_fini_napi(efx); in efx_pci_probe_main()
985 efx_remove_all(efx); in efx_pci_probe_main()
990 static int efx_pci_probe_post_io(struct efx_nic *efx) in efx_pci_probe_post_io() argument
992 struct net_device *net_dev = efx->net_dev; in efx_pci_probe_post_io()
993 int rc = efx_pci_probe_main(efx); in efx_pci_probe_post_io()
998 if (efx->type->sriov_init) { in efx_pci_probe_post_io()
999 rc = efx->type->sriov_init(efx); in efx_pci_probe_post_io()
1001 pci_err(efx->pci_dev, "SR-IOV can't be enabled rc %d\n", in efx_pci_probe_post_io()
1006 net_dev->features |= (efx->type->offload_features | NETIF_F_SG | in efx_pci_probe_post_io()
1008 if (efx->type->offload_features & (NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM)) in efx_pci_probe_post_io()
1011 if (!efx->type->tso_versions || !efx->type->tso_versions(efx)) in efx_pci_probe_post_io()
1018 net_dev->hw_features |= net_dev->features & ~efx->fixed_features; in efx_pci_probe_post_io()
1028 net_dev->features |= efx->fixed_features; in efx_pci_probe_post_io()
1030 rc = efx_register_netdev(efx); in efx_pci_probe_post_io()
1034 efx_pci_remove_main(efx); in efx_pci_probe_post_io()
1051 struct efx_nic *efx; in efx_pci_probe() local
1055 net_dev = alloc_etherdev_mqs(sizeof(*efx), EFX_MAX_CORE_TX_QUEUES, in efx_pci_probe()
1059 efx = netdev_priv(net_dev); in efx_pci_probe()
1060 efx->type = (const struct efx_nic_type *) entry->driver_data; in efx_pci_probe()
1061 efx->fixed_features |= NETIF_F_HIGHDMA; in efx_pci_probe()
1063 pci_set_drvdata(pci_dev, efx); in efx_pci_probe()
1065 rc = efx_init_struct(efx, pci_dev, net_dev); in efx_pci_probe()
1071 if (!efx->type->is_vf) in efx_pci_probe()
1072 efx_probe_vpd_strings(efx); in efx_pci_probe()
1075 rc = efx_init_io(efx, efx->type->mem_bar(efx), efx->type->max_dma_mask, in efx_pci_probe()
1076 efx->type->mem_map_size(efx)); in efx_pci_probe()
1080 rc = efx_pci_probe_post_io(efx); in efx_pci_probe()
1085 efx->reset_pending = 0; in efx_pci_probe()
1086 rc = efx_pci_probe_post_io(efx); in efx_pci_probe()
1095 efx->reset_pending = 0; in efx_pci_probe()
1096 rc = efx_pci_probe_post_io(efx); in efx_pci_probe()
1102 netif_dbg(efx, probe, efx->net_dev, "initialisation successful\n"); in efx_pci_probe()
1106 rc = efx_mtd_probe(efx); in efx_pci_probe()
1109 netif_warn(efx, probe, efx->net_dev, in efx_pci_probe()
1114 if (efx->type->udp_tnl_push_ports) in efx_pci_probe()
1115 efx->type->udp_tnl_push_ports(efx); in efx_pci_probe()
1120 efx_fini_io(efx); in efx_pci_probe()
1122 efx_fini_struct(efx); in efx_pci_probe()
1125 netif_dbg(efx, drv, efx->net_dev, "initialisation failed. rc=%d\n", rc); in efx_pci_probe()
1137 struct efx_nic *efx = pci_get_drvdata(dev); in efx_pci_sriov_configure() local
1139 if (efx->type->sriov_configure) { in efx_pci_sriov_configure()
1140 rc = efx->type->sriov_configure(efx, num_vfs); in efx_pci_sriov_configure()
1152 struct efx_nic *efx = dev_get_drvdata(dev); in efx_pm_freeze() local
1156 if (efx->state != STATE_DISABLED) { in efx_pm_freeze()
1157 efx->state = STATE_UNINIT; in efx_pm_freeze()
1159 efx_device_detach_sync(efx); in efx_pm_freeze()
1161 efx_stop_all(efx); in efx_pm_freeze()
1162 efx_disable_interrupts(efx); in efx_pm_freeze()
1173 struct efx_nic *efx = dev_get_drvdata(dev); in efx_pm_thaw() local
1177 if (efx->state != STATE_DISABLED) { in efx_pm_thaw()
1178 rc = efx_enable_interrupts(efx); in efx_pm_thaw()
1182 mutex_lock(&efx->mac_lock); in efx_pm_thaw()
1183 efx_mcdi_port_reconfigure(efx); in efx_pm_thaw()
1184 mutex_unlock(&efx->mac_lock); in efx_pm_thaw()
1186 efx_start_all(efx); in efx_pm_thaw()
1188 efx_device_attach_if_not_resetting(efx); in efx_pm_thaw()
1190 efx->state = STATE_READY; in efx_pm_thaw()
1192 efx->type->resume_wol(efx); in efx_pm_thaw()
1198 efx_queue_reset_work(efx); in efx_pm_thaw()
1211 struct efx_nic *efx = pci_get_drvdata(pci_dev); in efx_pm_poweroff() local
1213 efx->type->fini(efx); in efx_pm_poweroff()
1215 efx->reset_pending = 0; in efx_pm_poweroff()
1225 struct efx_nic *efx = pci_get_drvdata(pci_dev); in efx_pm_resume() local
1235 pci_set_master(efx->pci_dev); in efx_pm_resume()
1236 rc = efx->type->reset(efx, RESET_TYPE_ALL); in efx_pm_resume()
1239 down_write(&efx->filter_sem); in efx_pm_resume()
1240 rc = efx->type->init(efx); in efx_pm_resume()
1241 up_write(&efx->filter_sem); in efx_pm_resume()