Lines Matching refs:efx
103 static void efx_remove_port(struct efx_nic *efx);
104 static int efx_xdp_setup_prog(struct efx_nic *efx, struct bpf_prog *prog);
115 static void efx_fini_port(struct efx_nic *efx);
117 static int efx_probe_port(struct efx_nic *efx) in efx_probe_port() argument
121 netif_dbg(efx, probe, efx->net_dev, "create port\n"); in efx_probe_port()
124 efx->phy_mode = PHY_MODE_SPECIAL; in efx_probe_port()
127 rc = efx->type->probe_port(efx); in efx_probe_port()
132 eth_hw_addr_set(efx->net_dev, efx->net_dev->perm_addr); in efx_probe_port()
137 static int efx_init_port(struct efx_nic *efx) in efx_init_port() argument
141 netif_dbg(efx, drv, efx->net_dev, "init port\n"); in efx_init_port()
143 mutex_lock(&efx->mac_lock); in efx_init_port()
145 efx->port_initialized = true; in efx_init_port()
148 rc = efx_mcdi_port_reconfigure(efx); in efx_init_port()
152 mutex_unlock(&efx->mac_lock); in efx_init_port()
156 mutex_unlock(&efx->mac_lock); in efx_init_port()
160 static void efx_fini_port(struct efx_nic *efx) in efx_fini_port() argument
162 netif_dbg(efx, drv, efx->net_dev, "shut down port\n"); in efx_fini_port()
164 if (!efx->port_initialized) in efx_fini_port()
167 efx->port_initialized = false; in efx_fini_port()
169 efx->link_state.up = false; in efx_fini_port()
170 efx_link_status_changed(efx); in efx_fini_port()
173 static void efx_remove_port(struct efx_nic *efx) in efx_remove_port() argument
175 netif_dbg(efx, drv, efx->net_dev, "destroying port\n"); in efx_remove_port()
177 efx->type->remove_port(efx); in efx_remove_port()
196 static void efx_associate(struct efx_nic *efx) in efx_associate() argument
200 if (efx->primary == efx) { in efx_associate()
203 netif_dbg(efx, probe, efx->net_dev, "adding to primary list\n"); in efx_associate()
204 list_add_tail(&efx->node, &efx_primary_list); in efx_associate()
208 if (efx_same_controller(efx, other)) { in efx_associate()
212 pci_name(efx->pci_dev), in efx_associate()
213 efx->net_dev->name); in efx_associate()
215 &efx->secondary_list); in efx_associate()
216 other->primary = efx; in efx_associate()
223 if (efx_same_controller(efx, other)) { in efx_associate()
224 netif_dbg(efx, probe, efx->net_dev, in efx_associate()
228 list_add_tail(&efx->node, in efx_associate()
230 efx->primary = other; in efx_associate()
235 netif_dbg(efx, probe, efx->net_dev, in efx_associate()
237 list_add_tail(&efx->node, &efx_unassociated_list); in efx_associate()
241 static void efx_dissociate(struct efx_nic *efx) in efx_dissociate() argument
245 list_del(&efx->node); in efx_dissociate()
246 efx->primary = NULL; in efx_dissociate()
248 list_for_each_entry_safe(other, next, &efx->secondary_list, node) { in efx_dissociate()
257 static int efx_probe_nic(struct efx_nic *efx) in efx_probe_nic() argument
261 netif_dbg(efx, probe, efx->net_dev, "creating NIC\n"); in efx_probe_nic()
264 rc = efx->type->probe(efx); in efx_probe_nic()
269 if (!efx->max_channels || !efx->max_tx_channels) { in efx_probe_nic()
270 netif_err(efx, drv, efx->net_dev, in efx_probe_nic()
280 rc = efx_probe_interrupts(efx); in efx_probe_nic()
284 rc = efx_set_channels(efx); in efx_probe_nic()
289 rc = efx->type->dimension_resources(efx); in efx_probe_nic()
295 efx_remove_interrupts(efx); in efx_probe_nic()
299 if (efx->n_channels > 1) in efx_probe_nic()
300 netdev_rss_key_fill(efx->rss_context.rx_hash_key, in efx_probe_nic()
301 sizeof(efx->rss_context.rx_hash_key)); in efx_probe_nic()
302 efx_set_default_rx_indir_table(efx, &efx->rss_context); in efx_probe_nic()
305 efx->irq_mod_step_us = DIV_ROUND_UP(efx->timer_quantum_ns, 1000); in efx_probe_nic()
306 efx_init_irq_moderation(efx, tx_irq_mod_usec, rx_irq_mod_usec, true, in efx_probe_nic()
312 efx_remove_interrupts(efx); in efx_probe_nic()
314 efx->type->remove(efx); in efx_probe_nic()
318 static void efx_remove_nic(struct efx_nic *efx) in efx_remove_nic() argument
320 netif_dbg(efx, drv, efx->net_dev, "destroying NIC\n"); in efx_remove_nic()
322 efx_remove_interrupts(efx); in efx_remove_nic()
323 efx->type->remove(efx); in efx_remove_nic()
332 static int efx_probe_all(struct efx_nic *efx) in efx_probe_all() argument
336 rc = efx_probe_nic(efx); in efx_probe_all()
338 netif_err(efx, probe, efx->net_dev, "failed to create NIC\n"); in efx_probe_all()
342 rc = efx_probe_port(efx); in efx_probe_all()
344 netif_err(efx, probe, efx->net_dev, "failed to create port\n"); in efx_probe_all()
349 if (WARN_ON(EFX_DEFAULT_DMAQ_SIZE < EFX_TXQ_MIN_ENT(efx))) { in efx_probe_all()
355 rc = efx->type->vswitching_probe(efx); in efx_probe_all()
357 netif_warn(efx, probe, efx->net_dev, in efx_probe_all()
362 rc = efx_probe_filters(efx); in efx_probe_all()
364 netif_err(efx, probe, efx->net_dev, in efx_probe_all()
369 rc = efx_probe_channels(efx); in efx_probe_all()
373 efx->state = STATE_NET_DOWN; in efx_probe_all()
378 efx_remove_filters(efx); in efx_probe_all()
381 efx->type->vswitching_remove(efx); in efx_probe_all()
384 efx_remove_port(efx); in efx_probe_all()
386 efx_remove_nic(efx); in efx_probe_all()
391 static void efx_remove_all(struct efx_nic *efx) in efx_remove_all() argument
394 efx_xdp_setup_prog(efx, NULL); in efx_remove_all()
397 efx_remove_channels(efx); in efx_remove_all()
398 efx_remove_filters(efx); in efx_remove_all()
400 efx->type->vswitching_remove(efx); in efx_remove_all()
402 efx_remove_port(efx); in efx_remove_all()
403 efx_remove_nic(efx); in efx_remove_all()
411 unsigned int efx_usecs_to_ticks(struct efx_nic *efx, unsigned int usecs) in efx_usecs_to_ticks() argument
415 if (usecs * 1000 < efx->timer_quantum_ns) in efx_usecs_to_ticks()
417 return usecs * 1000 / efx->timer_quantum_ns; in efx_usecs_to_ticks()
420 unsigned int efx_ticks_to_usecs(struct efx_nic *efx, unsigned int ticks) in efx_ticks_to_usecs() argument
425 return DIV_ROUND_UP(ticks * efx->timer_quantum_ns, 1000); in efx_ticks_to_usecs()
429 int efx_init_irq_moderation(struct efx_nic *efx, unsigned int tx_usecs, in efx_init_irq_moderation() argument
436 EFX_ASSERT_RESET_SERIALISED(efx); in efx_init_irq_moderation()
438 timer_max_us = efx->timer_max_ns / 1000; in efx_init_irq_moderation()
443 if (tx_usecs != rx_usecs && efx->tx_channel_offset == 0 && in efx_init_irq_moderation()
445 netif_err(efx, drv, efx->net_dev, "Channels are shared. " in efx_init_irq_moderation()
450 efx->irq_rx_adaptive = rx_adaptive; in efx_init_irq_moderation()
451 efx->irq_rx_moderation_us = rx_usecs; in efx_init_irq_moderation()
452 efx_for_each_channel(channel, efx) { in efx_init_irq_moderation()
464 void efx_get_irq_moderation(struct efx_nic *efx, unsigned int *tx_usecs, in efx_get_irq_moderation() argument
467 *rx_adaptive = efx->irq_rx_adaptive; in efx_get_irq_moderation()
468 *rx_usecs = efx->irq_rx_moderation_us; in efx_get_irq_moderation()
474 if (efx->tx_channel_offset == 0) { in efx_get_irq_moderation()
479 tx_channel = efx->channel[efx->tx_channel_offset]; in efx_get_irq_moderation()
495 struct efx_nic *efx = efx_netdev_priv(net_dev); in efx_ioctl() local
499 return efx_ptp_set_ts_config(efx, ifr); in efx_ioctl()
501 return efx_ptp_get_ts_config(efx, ifr); in efx_ioctl()
508 return mdio_mii_ioctl(&efx->mdio, data, cmd); in efx_ioctl()
520 struct efx_nic *efx = efx_netdev_priv(net_dev); in efx_net_open() local
523 netif_dbg(efx, ifup, efx->net_dev, "opening device on CPU %d\n", in efx_net_open()
526 rc = efx_check_disabled(efx); in efx_net_open()
529 if (efx->phy_mode & PHY_MODE_SPECIAL) in efx_net_open()
531 if (efx_mcdi_poll_reboot(efx) && efx_reset(efx, RESET_TYPE_ALL)) in efx_net_open()
536 efx_link_status_changed(efx); in efx_net_open()
538 efx_start_all(efx); in efx_net_open()
539 if (efx->state == STATE_DISABLED || efx->reset_pending) in efx_net_open()
540 netif_device_detach(efx->net_dev); in efx_net_open()
542 efx->state = STATE_NET_UP; in efx_net_open()
544 efx_selftest_async_start(efx); in efx_net_open()
554 struct efx_nic *efx = efx_netdev_priv(net_dev); in efx_net_stop() local
556 netif_dbg(efx, ifdown, efx->net_dev, "closing on CPU %d\n", in efx_net_stop()
560 efx_stop_all(efx); in efx_net_stop()
567 struct efx_nic *efx = efx_netdev_priv(net_dev); in efx_vlan_rx_add_vid() local
569 if (efx->type->vlan_rx_add_vid) in efx_vlan_rx_add_vid()
570 return efx->type->vlan_rx_add_vid(efx, proto, vid); in efx_vlan_rx_add_vid()
577 struct efx_nic *efx = efx_netdev_priv(net_dev); in efx_vlan_rx_kill_vid() local
579 if (efx->type->vlan_rx_kill_vid) in efx_vlan_rx_kill_vid()
580 return efx->type->vlan_rx_kill_vid(efx, proto, vid); in efx_vlan_rx_kill_vid()
617 static int efx_xdp_setup_prog(struct efx_nic *efx, struct bpf_prog *prog) in efx_xdp_setup_prog() argument
621 if (efx->xdp_rxq_info_failed) { in efx_xdp_setup_prog()
622 netif_err(efx, drv, efx->net_dev, in efx_xdp_setup_prog()
627 if (prog && efx->net_dev->mtu > efx_xdp_max_mtu(efx)) { in efx_xdp_setup_prog()
628 netif_err(efx, drv, efx->net_dev, in efx_xdp_setup_prog()
630 efx->net_dev->mtu, efx_xdp_max_mtu(efx)); in efx_xdp_setup_prog()
634 old_prog = rtnl_dereference(efx->xdp_prog); in efx_xdp_setup_prog()
635 rcu_assign_pointer(efx->xdp_prog, prog); in efx_xdp_setup_prog()
646 struct efx_nic *efx = efx_netdev_priv(dev); in efx_xdp() local
650 return efx_xdp_setup_prog(efx, xdp->prog); in efx_xdp()
659 struct efx_nic *efx = efx_netdev_priv(dev); in efx_xdp_xmit() local
664 return efx_xdp_tx_buffers(efx, n, xdpfs, flags & XDP_XMIT_FLUSH); in efx_xdp_xmit()
667 static void efx_update_name(struct efx_nic *efx) in efx_update_name() argument
669 strcpy(efx->name, efx->net_dev->name); in efx_update_name()
670 efx_mtd_rename(efx); in efx_update_name()
671 efx_set_channel_names(efx); in efx_update_name()
693 struct efx_nic *efx = dev_get_drvdata(dev); in phy_type_show() local
694 return sprintf(buf, "%d\n", efx->phy_type); in phy_type_show()
698 static int efx_register_netdev(struct efx_nic *efx) in efx_register_netdev() argument
700 struct net_device *net_dev = efx->net_dev; in efx_register_netdev()
705 net_dev->irq = efx->pci_dev->irq; in efx_register_netdev()
707 if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0) in efx_register_netdev()
720 if (efx->reset_pending) { in efx_register_netdev()
721 pci_err(efx->pci_dev, "aborting probe due to scheduled reset\n"); in efx_register_netdev()
729 efx_update_name(efx); in efx_register_netdev()
738 efx_for_each_channel(channel, efx) { in efx_register_netdev()
744 efx_associate(efx); in efx_register_netdev()
746 efx->state = STATE_NET_DOWN; in efx_register_netdev()
750 rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_type); in efx_register_netdev()
752 netif_err(efx, drv, efx->net_dev, in efx_register_netdev()
757 efx_init_mcdi_logging(efx); in efx_register_netdev()
763 efx_dissociate(efx); in efx_register_netdev()
766 efx->state = STATE_UNINIT; in efx_register_netdev()
768 netif_err(efx, drv, efx->net_dev, "could not register net dev\n"); in efx_register_netdev()
772 static void efx_unregister_netdev(struct efx_nic *efx) in efx_unregister_netdev() argument
774 if (!efx->net_dev) in efx_unregister_netdev()
777 if (WARN_ON(efx_netdev_priv(efx->net_dev) != efx)) in efx_unregister_netdev()
780 if (efx_dev_registered(efx)) { in efx_unregister_netdev()
781 strscpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name)); in efx_unregister_netdev()
782 efx_fini_mcdi_logging(efx); in efx_unregister_netdev()
783 device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type); in efx_unregister_netdev()
784 unregister_netdev(efx->net_dev); in efx_unregister_netdev()
821 void efx_update_sw_stats(struct efx_nic *efx, u64 *stats) in efx_update_sw_stats() argument
826 efx_for_each_channel(channel, efx) in efx_update_sw_stats()
829 stats[GENERIC_STAT_rx_noskb_drops] = atomic_read(&efx->n_rx_noskb_drops); in efx_update_sw_stats()
841 static void efx_pci_remove_main(struct efx_nic *efx) in efx_pci_remove_main() argument
846 WARN_ON(efx_net_active(efx->state)); in efx_pci_remove_main()
847 efx_flush_reset_workqueue(efx); in efx_pci_remove_main()
849 efx_disable_interrupts(efx); in efx_pci_remove_main()
850 efx_clear_interrupt_affinity(efx); in efx_pci_remove_main()
851 efx_nic_fini_interrupt(efx); in efx_pci_remove_main()
852 efx_fini_port(efx); in efx_pci_remove_main()
853 efx->type->fini(efx); in efx_pci_remove_main()
854 efx_fini_napi(efx); in efx_pci_remove_main()
855 efx_remove_all(efx); in efx_pci_remove_main()
865 struct efx_nic *efx; in efx_pci_remove() local
867 efx = pci_get_drvdata(pci_dev); in efx_pci_remove()
868 if (!efx) in efx_pci_remove()
873 efx_dissociate(efx); in efx_pci_remove()
874 dev_close(efx->net_dev); in efx_pci_remove()
875 efx_disable_interrupts(efx); in efx_pci_remove()
876 efx->state = STATE_UNINIT; in efx_pci_remove()
879 if (efx->type->sriov_fini) in efx_pci_remove()
880 efx->type->sriov_fini(efx); in efx_pci_remove()
882 efx_unregister_netdev(efx); in efx_pci_remove()
884 efx_mtd_remove(efx); in efx_pci_remove()
886 efx_pci_remove_main(efx); in efx_pci_remove()
888 efx_fini_io(efx); in efx_pci_remove()
889 pci_dbg(efx->pci_dev, "shutdown successful\n"); in efx_pci_remove()
891 efx_fini_struct(efx); in efx_pci_remove()
892 free_netdev(efx->net_dev); in efx_pci_remove()
893 probe_data = container_of(efx, struct efx_probe_data, efx); in efx_pci_remove()
903 static void efx_probe_vpd_strings(struct efx_nic *efx) in efx_probe_vpd_strings() argument
905 struct pci_dev *dev = efx->pci_dev; in efx_probe_vpd_strings()
928 efx->vpd_sn = kmemdup_nul(vpd_data + start, kw_len, GFP_KERNEL); in efx_probe_vpd_strings()
937 static int efx_pci_probe_main(struct efx_nic *efx) in efx_pci_probe_main() argument
942 rc = efx_probe_all(efx); in efx_pci_probe_main()
946 efx_init_napi(efx); in efx_pci_probe_main()
948 down_write(&efx->filter_sem); in efx_pci_probe_main()
949 rc = efx->type->init(efx); in efx_pci_probe_main()
950 up_write(&efx->filter_sem); in efx_pci_probe_main()
952 pci_err(efx->pci_dev, "failed to initialise NIC\n"); in efx_pci_probe_main()
956 rc = efx_init_port(efx); in efx_pci_probe_main()
958 netif_err(efx, probe, efx->net_dev, in efx_pci_probe_main()
963 rc = efx_nic_init_interrupt(efx); in efx_pci_probe_main()
967 efx_set_interrupt_affinity(efx); in efx_pci_probe_main()
968 rc = efx_enable_interrupts(efx); in efx_pci_probe_main()
975 efx_clear_interrupt_affinity(efx); in efx_pci_probe_main()
976 efx_nic_fini_interrupt(efx); in efx_pci_probe_main()
978 efx_fini_port(efx); in efx_pci_probe_main()
980 efx->type->fini(efx); in efx_pci_probe_main()
982 efx_fini_napi(efx); in efx_pci_probe_main()
983 efx_remove_all(efx); in efx_pci_probe_main()
988 static int efx_pci_probe_post_io(struct efx_nic *efx) in efx_pci_probe_post_io() argument
990 struct net_device *net_dev = efx->net_dev; in efx_pci_probe_post_io()
991 int rc = efx_pci_probe_main(efx); in efx_pci_probe_post_io()
996 if (efx->type->sriov_init) { in efx_pci_probe_post_io()
997 rc = efx->type->sriov_init(efx); in efx_pci_probe_post_io()
999 pci_err(efx->pci_dev, "SR-IOV can't be enabled rc %d\n", in efx_pci_probe_post_io()
1004 net_dev->features |= (efx->type->offload_features | NETIF_F_SG | in efx_pci_probe_post_io()
1006 if (efx->type->offload_features & (NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM)) { in efx_pci_probe_post_io()
1008 if (efx_has_cap(efx, TX_TSO_V2_ENCAP)) in efx_pci_probe_post_io()
1012 if (!efx->type->tso_versions || !efx->type->tso_versions(efx)) in efx_pci_probe_post_io()
1019 net_dev->hw_features |= net_dev->features & ~efx->fixed_features; in efx_pci_probe_post_io()
1029 net_dev->features |= efx->fixed_features; in efx_pci_probe_post_io()
1035 rc = efx_register_netdev(efx); in efx_pci_probe_post_io()
1039 efx_pci_remove_main(efx); in efx_pci_probe_post_io()
1057 struct efx_nic *efx; in efx_pci_probe() local
1065 efx = &probe_data->efx; in efx_pci_probe()
1075 efx->net_dev = net_dev; in efx_pci_probe()
1076 efx->type = (const struct efx_nic_type *) entry->driver_data; in efx_pci_probe()
1077 efx->fixed_features |= NETIF_F_HIGHDMA; in efx_pci_probe()
1079 pci_set_drvdata(pci_dev, efx); in efx_pci_probe()
1081 rc = efx_init_struct(efx, pci_dev); in efx_pci_probe()
1084 efx->mdio.dev = net_dev; in efx_pci_probe()
1088 if (!efx->type->is_vf) in efx_pci_probe()
1089 efx_probe_vpd_strings(efx); in efx_pci_probe()
1092 rc = efx_init_io(efx, efx->type->mem_bar(efx), efx->type->max_dma_mask, in efx_pci_probe()
1093 efx->type->mem_map_size(efx)); in efx_pci_probe()
1097 rc = efx_pci_probe_post_io(efx); in efx_pci_probe()
1102 efx->reset_pending = 0; in efx_pci_probe()
1103 rc = efx_pci_probe_post_io(efx); in efx_pci_probe()
1112 efx->reset_pending = 0; in efx_pci_probe()
1113 rc = efx_pci_probe_post_io(efx); in efx_pci_probe()
1119 netif_dbg(efx, probe, efx->net_dev, "initialisation successful\n"); in efx_pci_probe()
1123 rc = efx_mtd_probe(efx); in efx_pci_probe()
1126 netif_warn(efx, probe, efx->net_dev, in efx_pci_probe()
1131 if (efx->type->udp_tnl_push_ports) in efx_pci_probe()
1132 efx->type->udp_tnl_push_ports(efx); in efx_pci_probe()
1137 efx_fini_io(efx); in efx_pci_probe()
1139 efx_fini_struct(efx); in efx_pci_probe()
1142 netif_dbg(efx, drv, efx->net_dev, "initialisation failed. rc=%d\n", rc); in efx_pci_probe()
1156 struct efx_nic *efx = pci_get_drvdata(dev); in efx_pci_sriov_configure() local
1158 if (efx->type->sriov_configure) { in efx_pci_sriov_configure()
1159 rc = efx->type->sriov_configure(efx, num_vfs); in efx_pci_sriov_configure()
1171 struct efx_nic *efx = dev_get_drvdata(dev); in efx_pm_freeze() local
1175 if (efx_net_active(efx->state)) { in efx_pm_freeze()
1176 efx_device_detach_sync(efx); in efx_pm_freeze()
1178 efx_stop_all(efx); in efx_pm_freeze()
1179 efx_disable_interrupts(efx); in efx_pm_freeze()
1181 efx->state = efx_freeze(efx->state); in efx_pm_freeze()
1191 struct efx_nic *efx = pci_get_drvdata(pci_dev); in efx_pci_shutdown() local
1193 if (!efx) in efx_pci_shutdown()
1203 struct efx_nic *efx = dev_get_drvdata(dev); in efx_pm_thaw() local
1207 if (efx_frozen(efx->state)) { in efx_pm_thaw()
1208 rc = efx_enable_interrupts(efx); in efx_pm_thaw()
1212 mutex_lock(&efx->mac_lock); in efx_pm_thaw()
1213 efx_mcdi_port_reconfigure(efx); in efx_pm_thaw()
1214 mutex_unlock(&efx->mac_lock); in efx_pm_thaw()
1216 efx_start_all(efx); in efx_pm_thaw()
1218 efx_device_attach_if_not_resetting(efx); in efx_pm_thaw()
1220 efx->state = efx_thaw(efx->state); in efx_pm_thaw()
1222 efx->type->resume_wol(efx); in efx_pm_thaw()
1228 efx_queue_reset_work(efx); in efx_pm_thaw()
1241 struct efx_nic *efx = pci_get_drvdata(pci_dev); in efx_pm_poweroff() local
1243 efx->type->fini(efx); in efx_pm_poweroff()
1245 efx->reset_pending = 0; in efx_pm_poweroff()
1255 struct efx_nic *efx = pci_get_drvdata(pci_dev); in efx_pm_resume() local
1265 pci_set_master(efx->pci_dev); in efx_pm_resume()
1266 rc = efx->type->reset(efx, RESET_TYPE_ALL); in efx_pm_resume()
1269 down_write(&efx->filter_sem); in efx_pm_resume()
1270 rc = efx->type->init(efx); in efx_pm_resume()
1271 up_write(&efx->filter_sem); in efx_pm_resume()