Lines Matching refs:efx

25 #include "efx.h"
105 static void efx_remove_port(struct efx_nic *efx);
106 static int efx_xdp_setup_prog(struct efx_nic *efx, struct bpf_prog *prog);
111 #define EFX_ASSERT_RESET_SERIALISED(efx) \
113 if ((efx->state == STATE_READY) || \
114 (efx->state == STATE_RECOVERY) || \
115 (efx->state == STATE_DISABLED)) \
125 static void efx_fini_port(struct efx_nic *efx);
127 static int efx_probe_port(struct efx_nic *efx)
131 netif_dbg(efx, probe, efx->net_dev, "create port\n");
134 efx->phy_mode = PHY_MODE_SPECIAL;
137 rc = efx->type->probe_port(efx);
142 eth_hw_addr_set(efx->net_dev, efx->net_dev->perm_addr);
147 static int efx_init_port(struct efx_nic *efx)
151 netif_dbg(efx, drv, efx->net_dev, "init port\n");
153 mutex_lock(&efx->mac_lock);
155 efx->port_initialized = true;
158 rc = efx_siena_mcdi_port_reconfigure(efx);
162 mutex_unlock(&efx->mac_lock);
166 mutex_unlock(&efx->mac_lock);
170 static void efx_fini_port(struct efx_nic *efx)
172 netif_dbg(efx, drv, efx->net_dev, "shut down port\n");
174 if (!efx->port_initialized)
177 efx->port_initialized = false;
179 efx->link_state.up = false;
180 efx_siena_link_status_changed(efx);
183 static void efx_remove_port(struct efx_nic *efx)
185 netif_dbg(efx, drv, efx->net_dev, "destroying port\n");
187 efx->type->remove_port(efx);
206 static void efx_associate(struct efx_nic *efx)
210 if (efx->primary == efx) {
213 netif_dbg(efx, probe, efx->net_dev, "adding to primary list\n");
214 list_add_tail(&efx->node, &efx_primary_list);
218 if (efx_same_controller(efx, other)) {
222 pci_name(efx->pci_dev),
223 efx->net_dev->name);
225 &efx->secondary_list);
226 other->primary = efx;
233 if (efx_same_controller(efx, other)) {
234 netif_dbg(efx, probe, efx->net_dev,
238 list_add_tail(&efx->node,
240 efx->primary = other;
245 netif_dbg(efx, probe, efx->net_dev,
247 list_add_tail(&efx->node, &efx_unassociated_list);
251 static void efx_dissociate(struct efx_nic *efx)
255 list_del(&efx->node);
256 efx->primary = NULL;
258 list_for_each_entry_safe(other, next, &efx->secondary_list, node) {
267 static int efx_probe_nic(struct efx_nic *efx)
271 netif_dbg(efx, probe, efx->net_dev, "creating NIC\n");
274 rc = efx->type->probe(efx);
279 if (!efx->max_channels || !efx->max_tx_channels) {
280 netif_err(efx, drv, efx->net_dev,
290 rc = efx_siena_probe_interrupts(efx);
294 rc = efx_siena_set_channels(efx);
299 rc = efx->type->dimension_resources(efx);
305 efx_siena_remove_interrupts(efx);
309 if (efx->n_channels > 1)
310 netdev_rss_key_fill(efx->rss_context.rx_hash_key,
311 sizeof(efx->rss_context.rx_hash_key));
312 efx_siena_set_default_rx_indir_table(efx, &efx->rss_context);
315 efx->irq_mod_step_us = DIV_ROUND_UP(efx->timer_quantum_ns, 1000);
316 efx_siena_init_irq_moderation(efx, tx_irq_mod_usec, rx_irq_mod_usec,
322 efx_siena_remove_interrupts(efx);
324 efx->type->remove(efx);
328 static void efx_remove_nic(struct efx_nic *efx)
330 netif_dbg(efx, drv, efx->net_dev, "destroying NIC\n");
332 efx_siena_remove_interrupts(efx);
333 efx->type->remove(efx);
342 static int efx_probe_all(struct efx_nic *efx)
346 rc = efx_probe_nic(efx);
348 netif_err(efx, probe, efx->net_dev, "failed to create NIC\n");
352 rc = efx_probe_port(efx);
354 netif_err(efx, probe, efx->net_dev, "failed to create port\n");
359 if (WARN_ON(EFX_DEFAULT_DMAQ_SIZE < EFX_TXQ_MIN_ENT(efx))) {
365 rc = efx->type->vswitching_probe(efx);
367 netif_warn(efx, probe, efx->net_dev,
372 rc = efx_siena_probe_filters(efx);
374 netif_err(efx, probe, efx->net_dev,
379 rc = efx_siena_probe_channels(efx);
386 efx_siena_remove_filters(efx);
389 efx->type->vswitching_remove(efx);
392 efx_remove_port(efx);
394 efx_remove_nic(efx);
399 static void efx_remove_all(struct efx_nic *efx)
402 efx_xdp_setup_prog(efx, NULL);
405 efx_siena_remove_channels(efx);
406 efx_siena_remove_filters(efx);
408 efx->type->vswitching_remove(efx);
410 efx_remove_port(efx);
411 efx_remove_nic(efx);
419 unsigned int efx_siena_usecs_to_ticks(struct efx_nic *efx, unsigned int usecs)
423 if (usecs * 1000 < efx->timer_quantum_ns)
425 return usecs * 1000 / efx->timer_quantum_ns;
429 int efx_siena_init_irq_moderation(struct efx_nic *efx, unsigned int tx_usecs,
436 EFX_ASSERT_RESET_SERIALISED(efx);
438 timer_max_us = efx->timer_max_ns / 1000;
443 if (tx_usecs != rx_usecs && efx->tx_channel_offset == 0 &&
445 netif_err(efx, drv, efx->net_dev, "Channels are shared. "
450 efx->irq_rx_adaptive = rx_adaptive;
451 efx->irq_rx_moderation_us = rx_usecs;
452 efx_for_each_channel(channel, efx) {
464 void efx_siena_get_irq_moderation(struct efx_nic *efx, unsigned int *tx_usecs,
467 *rx_adaptive = efx->irq_rx_adaptive;
468 *rx_usecs = efx->irq_rx_moderation_us;
474 if (efx->tx_channel_offset == 0) {
479 tx_channel = efx->channel[efx->tx_channel_offset];
495 struct efx_nic *efx = netdev_priv(net_dev);
499 return efx_siena_ptp_set_ts_config(efx, ifr);
501 return efx_siena_ptp_get_ts_config(efx, ifr);
508 return mdio_mii_ioctl(&efx->mdio, data, cmd);
520 struct efx_nic *efx = netdev_priv(net_dev);
523 netif_dbg(efx, ifup, efx->net_dev, "opening device on CPU %d\n",
526 rc = efx_check_disabled(efx);
529 if (efx->phy_mode & PHY_MODE_SPECIAL)
531 if (efx_siena_mcdi_poll_reboot(efx) && efx_siena_reset(efx, RESET_TYPE_ALL))
536 efx_siena_link_status_changed(efx);
538 efx_siena_start_all(efx);
539 if (efx->state == STATE_DISABLED || efx->reset_pending)
540 netif_device_detach(efx->net_dev);
541 efx_siena_selftest_async_start(efx);
551 struct efx_nic *efx = netdev_priv(net_dev);
553 netif_dbg(efx, ifdown, efx->net_dev, "closing on CPU %d\n",
557 efx_siena_stop_all(efx);
564 struct efx_nic *efx = netdev_priv(net_dev);
566 if (efx->type->vlan_rx_add_vid)
567 return efx->type->vlan_rx_add_vid(efx, proto, vid);
574 struct efx_nic *efx = netdev_priv(net_dev);
576 if (efx->type->vlan_rx_kill_vid)
577 return efx->type->vlan_rx_kill_vid(efx, proto, vid);
614 static int efx_xdp_setup_prog(struct efx_nic *efx, struct bpf_prog *prog)
618 if (efx->xdp_rxq_info_failed) {
619 netif_err(efx, drv, efx->net_dev,
624 if (prog && efx->net_dev->mtu > efx_siena_xdp_max_mtu(efx)) {
625 netif_err(efx, drv, efx->net_dev,
627 efx->net_dev->mtu, efx_siena_xdp_max_mtu(efx));
631 old_prog = rtnl_dereference(efx->xdp_prog);
632 rcu_assign_pointer(efx->xdp_prog, prog);
643 struct efx_nic *efx = netdev_priv(dev);
647 return efx_xdp_setup_prog(efx, xdp->prog);
656 struct efx_nic *efx = netdev_priv(dev);
661 return efx_siena_xdp_tx_buffers(efx, n, xdpfs, flags & XDP_XMIT_FLUSH);
664 static void efx_update_name(struct efx_nic *efx)
666 strcpy(efx->name, efx->net_dev->name);
667 efx_siena_mtd_rename(efx);
668 efx_siena_set_channel_names(efx);
690 struct efx_nic *efx = dev_get_drvdata(dev);
691 return sprintf(buf, "%d\n", efx->phy_type);
695 static int efx_register_netdev(struct efx_nic *efx)
697 struct net_device *net_dev = efx->net_dev;
702 net_dev->irq = efx->pci_dev->irq;
704 if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0)
717 efx->state = STATE_READY;
719 if (efx->reset_pending) {
720 pci_err(efx->pci_dev, "aborting probe due to scheduled reset\n");
728 efx_update_name(efx);
737 efx_for_each_channel(channel, efx) {
743 efx_associate(efx);
747 rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_type);
749 netif_err(efx, drv, efx->net_dev,
754 efx_siena_init_mcdi_logging(efx);
760 efx_dissociate(efx);
763 efx->state = STATE_UNINIT;
765 netif_err(efx, drv, efx->net_dev, "could not register net dev\n");
769 static void efx_unregister_netdev(struct efx_nic *efx)
771 if (!efx->net_dev)
774 BUG_ON(netdev_priv(efx->net_dev) != efx);
776 if (efx_dev_registered(efx)) {
777 strscpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name));
778 efx_siena_fini_mcdi_logging(efx);
779 device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type);
780 unregister_netdev(efx->net_dev);
805 void efx_siena_update_sw_stats(struct efx_nic *efx, u64 *stats)
810 efx_for_each_channel(channel, efx)
813 stats[GENERIC_STAT_rx_noskb_drops] = atomic_read(&efx->n_rx_noskb_drops);
825 static void efx_pci_remove_main(struct efx_nic *efx)
830 BUG_ON(efx->state == STATE_READY);
831 efx_siena_flush_reset_workqueue(efx);
833 efx_siena_disable_interrupts(efx);
834 efx_siena_clear_interrupt_affinity(efx);
835 efx_siena_fini_interrupt(efx);
836 efx_fini_port(efx);
837 efx->type->fini(efx);
838 efx_siena_fini_napi(efx);
839 efx_remove_all(efx);
848 struct efx_nic *efx;
850 efx = pci_get_drvdata(pci_dev);
851 if (!efx)
856 efx_dissociate(efx);
857 dev_close(efx->net_dev);
858 efx_siena_disable_interrupts(efx);
859 efx->state = STATE_UNINIT;
862 if (efx->type->sriov_fini)
863 efx->type->sriov_fini(efx);
865 efx_unregister_netdev(efx);
867 efx_siena_mtd_remove(efx);
869 efx_pci_remove_main(efx);
871 efx_siena_fini_io(efx);
872 netif_dbg(efx, drv, efx->net_dev, "shutdown successful\n");
874 efx_siena_fini_struct(efx);
875 free_netdev(efx->net_dev);
882 static void efx_probe_vpd_strings(struct efx_nic *efx)
884 struct pci_dev *dev = efx->pci_dev;
907 efx->vpd_sn = kmemdup_nul(vpd_data + start, kw_len, GFP_KERNEL);
916 static int efx_pci_probe_main(struct efx_nic *efx)
921 rc = efx_probe_all(efx);
925 efx_siena_init_napi(efx);
927 down_write(&efx->filter_sem);
928 rc = efx->type->init(efx);
929 up_write(&efx->filter_sem);
931 pci_err(efx->pci_dev, "failed to initialise NIC\n");
935 rc = efx_init_port(efx);
937 netif_err(efx, probe, efx->net_dev,
942 rc = efx_siena_init_interrupt(efx);
946 efx_siena_set_interrupt_affinity(efx);
947 rc = efx_siena_enable_interrupts(efx);
954 efx_siena_clear_interrupt_affinity(efx);
955 efx_siena_fini_interrupt(efx);
957 efx_fini_port(efx);
959 efx->type->fini(efx);
961 efx_siena_fini_napi(efx);
962 efx_remove_all(efx);
967 static int efx_pci_probe_post_io(struct efx_nic *efx)
969 struct net_device *net_dev = efx->net_dev;
970 int rc = efx_pci_probe_main(efx);
975 if (efx->type->sriov_init) {
976 rc = efx->type->sriov_init(efx);
978 pci_err(efx->pci_dev, "SR-IOV can't be enabled rc %d\n",
983 net_dev->features |= (efx->type->offload_features | NETIF_F_SG |
985 if (efx->type->offload_features & (NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM))
988 if (!efx->type->tso_versions || !efx->type->tso_versions(efx))
995 net_dev->hw_features |= net_dev->features & ~efx->fixed_features;
1005 net_dev->features |= efx->fixed_features;
1011 rc = efx_register_netdev(efx);
1015 efx_pci_remove_main(efx);
1032 struct efx_nic *efx;
1036 net_dev = alloc_etherdev_mqs(sizeof(*efx), EFX_MAX_CORE_TX_QUEUES,
1040 efx = netdev_priv(net_dev);
1041 efx->type = (const struct efx_nic_type *) entry->driver_data;
1042 efx->fixed_features |= NETIF_F_HIGHDMA;
1044 pci_set_drvdata(pci_dev, efx);
1046 rc = efx_siena_init_struct(efx, pci_dev, net_dev);
1052 if (!efx->type->is_vf)
1053 efx_probe_vpd_strings(efx);
1056 rc = efx_siena_init_io(efx, efx->type->mem_bar(efx),
1057 efx->type->max_dma_mask,
1058 efx->type->mem_map_size(efx));
1062 rc = efx_pci_probe_post_io(efx);
1067 efx->reset_pending = 0;
1068 rc = efx_pci_probe_post_io(efx);
1077 efx->reset_pending = 0;
1078 rc = efx_pci_probe_post_io(efx);
1084 netif_dbg(efx, probe, efx->net_dev, "initialisation successful\n");
1088 rc = efx_mtd_probe(efx);
1091 netif_warn(efx, probe, efx->net_dev,
1094 if (efx->type->udp_tnl_push_ports)
1095 efx->type->udp_tnl_push_ports(efx);
1100 efx_siena_fini_io(efx);
1102 efx_siena_fini_struct(efx);
1105 netif_dbg(efx, drv, efx->net_dev, "initialisation failed. rc=%d\n", rc);
1117 struct efx_nic *efx = pci_get_drvdata(dev);
1119 if (efx->type->sriov_configure) {
1120 rc = efx->type->sriov_configure(efx, num_vfs);
1132 struct efx_nic *efx = dev_get_drvdata(dev);
1136 if (efx->state != STATE_DISABLED) {
1137 efx->state = STATE_UNINIT;
1139 efx_device_detach_sync(efx);
1141 efx_siena_stop_all(efx);
1142 efx_siena_disable_interrupts(efx);
1152 struct efx_nic *efx = pci_get_drvdata(pci_dev);
1154 if (!efx)
1164 struct efx_nic *efx = dev_get_drvdata(dev);
1168 if (efx->state != STATE_DISABLED) {
1169 rc = efx_siena_enable_interrupts(efx);
1173 mutex_lock(&efx->mac_lock);
1174 efx_siena_mcdi_port_reconfigure(efx);
1175 mutex_unlock(&efx->mac_lock);
1177 efx_siena_start_all(efx);
1179 efx_device_attach_if_not_resetting(efx);
1181 efx->state = STATE_READY;
1183 efx->type->resume_wol(efx);
1189 efx_siena_queue_reset_work(efx);
1202 struct efx_nic *efx = pci_get_drvdata(pci_dev);
1204 efx->type->fini(efx);
1206 efx->reset_pending = 0;
1216 struct efx_nic *efx = pci_get_drvdata(pci_dev);
1226 pci_set_master(efx->pci_dev);
1227 rc = efx->type->reset(efx, RESET_TYPE_ALL);
1230 down_write(&efx->filter_sem);
1231 rc = efx->type->init(efx);
1232 up_write(&efx->filter_sem);