Lines Matching refs:efx
91 static void efx_ef10_rx_free_indir_table(struct efx_nic *efx);
92 static void efx_ef10_filter_table_remove(struct efx_nic *efx);
94 static int efx_ef10_get_warm_boot_count(struct efx_nic *efx) in efx_ef10_get_warm_boot_count() argument
98 efx_readd(efx, ®, ER_DZ_BIU_MC_SFT_STATUS); in efx_ef10_get_warm_boot_count()
103 static unsigned int efx_ef10_mem_map_size(struct efx_nic *efx) in efx_ef10_mem_map_size() argument
107 bar = efx->type->mem_bar; in efx_ef10_mem_map_size()
108 return resource_size(&efx->pci_dev->resource[bar]); in efx_ef10_mem_map_size()
111 static bool efx_ef10_is_vf(struct efx_nic *efx) in efx_ef10_is_vf() argument
113 return efx->type->is_vf; in efx_ef10_is_vf()
116 static int efx_ef10_get_pf_index(struct efx_nic *efx) in efx_ef10_get_pf_index() argument
119 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_get_pf_index()
123 rc = efx_mcdi_rpc(efx, MC_CMD_GET_FUNCTION_INFO, NULL, 0, outbuf, in efx_ef10_get_pf_index()
135 static int efx_ef10_get_vf_index(struct efx_nic *efx) in efx_ef10_get_vf_index() argument
138 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_get_vf_index()
142 rc = efx_mcdi_rpc(efx, MC_CMD_GET_FUNCTION_INFO, NULL, 0, outbuf, in efx_ef10_get_vf_index()
154 static int efx_ef10_init_datapath_caps(struct efx_nic *efx) in efx_ef10_init_datapath_caps() argument
157 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_init_datapath_caps()
163 rc = efx_mcdi_rpc(efx, MC_CMD_GET_CAPABILITIES, NULL, 0, in efx_ef10_init_datapath_caps()
168 netif_err(efx, drv, efx->net_dev, in efx_ef10_init_datapath_caps()
185 netif_err(efx, drv, efx->net_dev, in efx_ef10_init_datapath_caps()
192 netif_err(efx, probe, efx->net_dev, in efx_ef10_init_datapath_caps()
200 static int efx_ef10_get_sysclk_freq(struct efx_nic *efx) in efx_ef10_get_sysclk_freq() argument
205 rc = efx_mcdi_rpc(efx, MC_CMD_GET_CLOCK, NULL, 0, in efx_ef10_get_sysclk_freq()
213 static int efx_ef10_get_mac_address_pf(struct efx_nic *efx, u8 *mac_address) in efx_ef10_get_mac_address_pf() argument
221 rc = efx_mcdi_rpc(efx, MC_CMD_GET_MAC_ADDRESSES, NULL, 0, in efx_ef10_get_mac_address_pf()
233 static int efx_ef10_get_mac_address_vf(struct efx_nic *efx, u8 *mac_address) in efx_ef10_get_mac_address_vf() argument
242 rc = efx_mcdi_rpc(efx, MC_CMD_VPORT_GET_MAC_ADDRESSES, inbuf, in efx_ef10_get_mac_address_vf()
265 struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); in efx_ef10_show_link_control_flag() local
268 ((efx->mcdi->fn_flags) & in efx_ef10_show_link_control_flag()
277 struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); in efx_ef10_show_primary_flag() local
280 ((efx->mcdi->fn_flags) & in efx_ef10_show_primary_flag()
289 static int efx_ef10_probe(struct efx_nic *efx) in efx_ef10_probe() argument
292 struct net_device *net_dev = efx->net_dev; in efx_ef10_probe()
298 efx->max_channels = min_t(unsigned int, in efx_ef10_probe()
300 efx_ef10_mem_map_size(efx) / in efx_ef10_probe()
302 efx->max_tx_channels = efx->max_channels; in efx_ef10_probe()
303 if (WARN_ON(efx->max_channels == 0)) in efx_ef10_probe()
309 efx->nic_data = nic_data; in efx_ef10_probe()
314 rc = efx_nic_alloc_buffer(efx, &nic_data->mcdi_buf, in efx_ef10_probe()
324 rc = efx_ef10_get_warm_boot_count(efx); in efx_ef10_probe()
342 _efx_writed(efx, cpu_to_le32(1), ER_DZ_MC_DB_HWRD); in efx_ef10_probe()
344 rc = efx_mcdi_init(efx); in efx_ef10_probe()
349 rc = efx_mcdi_reset(efx, RESET_TYPE_ALL); in efx_ef10_probe()
354 rc = efx_mcdi_log_ctrl(efx, true, false, 0); in efx_ef10_probe()
358 rc = device_create_file(&efx->pci_dev->dev, in efx_ef10_probe()
363 rc = device_create_file(&efx->pci_dev->dev, &dev_attr_primary_flag); in efx_ef10_probe()
367 rc = efx_ef10_get_pf_index(efx); in efx_ef10_probe()
371 rc = efx_ef10_init_datapath_caps(efx); in efx_ef10_probe()
375 efx->rx_packet_len_offset = in efx_ef10_probe()
378 rc = efx_mcdi_port_get_number(efx); in efx_ef10_probe()
381 efx->port_num = rc; in efx_ef10_probe()
384 rc = efx->type->get_mac_address(efx, efx->net_dev->perm_addr); in efx_ef10_probe()
388 rc = efx_ef10_get_sysclk_freq(efx); in efx_ef10_probe()
391 efx->timer_quantum_ns = 1536000 / rc; /* 1536 cycles */ in efx_ef10_probe()
397 rc = efx_mcdi_set_workaround(efx, MC_CMD_WORKAROUND_BUG35388, true, NULL); in efx_ef10_probe()
403 rc = efx_mcdi_get_workarounds(efx, NULL, &enabled); in efx_ef10_probe()
411 netif_dbg(efx, probe, efx->net_dev, in efx_ef10_probe()
415 rc = efx_mcdi_mon_probe(efx); in efx_ef10_probe()
419 efx_ptp_probe(efx, NULL); in efx_ef10_probe()
422 if ((efx->pci_dev->physfn) && (!efx->pci_dev->is_physfn)) { in efx_ef10_probe()
423 struct pci_dev *pci_dev_pf = efx->pci_dev->physfn; in efx_ef10_probe()
429 ether_addr_copy(nic_data->port_id, efx->net_dev->perm_addr); in efx_ef10_probe()
434 device_remove_file(&efx->pci_dev->dev, &dev_attr_primary_flag); in efx_ef10_probe()
436 device_remove_file(&efx->pci_dev->dev, &dev_attr_link_control_flag); in efx_ef10_probe()
438 efx_mcdi_fini(efx); in efx_ef10_probe()
440 efx_nic_free_buffer(efx, &nic_data->mcdi_buf); in efx_ef10_probe()
443 efx->nic_data = NULL; in efx_ef10_probe()
447 static int efx_ef10_free_vis(struct efx_nic *efx) in efx_ef10_free_vis() argument
451 int rc = efx_mcdi_rpc_quiet(efx, MC_CMD_FREE_VIS, NULL, 0, in efx_ef10_free_vis()
458 efx_mcdi_display_error(efx, MC_CMD_FREE_VIS, 0, outbuf, outlen, in efx_ef10_free_vis()
465 static void efx_ef10_free_piobufs(struct efx_nic *efx) in efx_ef10_free_piobufs() argument
467 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_free_piobufs()
477 rc = efx_mcdi_rpc(efx, MC_CMD_FREE_PIOBUF, inbuf, sizeof(inbuf), in efx_ef10_free_piobufs()
485 static int efx_ef10_alloc_piobufs(struct efx_nic *efx, unsigned int n) in efx_ef10_alloc_piobufs() argument
487 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_alloc_piobufs()
496 rc = efx_mcdi_rpc(efx, MC_CMD_ALLOC_PIOBUF, NULL, 0, in efx_ef10_alloc_piobufs()
506 netif_dbg(efx, probe, efx->net_dev, in efx_ef10_alloc_piobufs()
513 efx_ef10_free_piobufs(efx); in efx_ef10_alloc_piobufs()
517 static int efx_ef10_link_piobufs(struct efx_nic *efx) in efx_ef10_link_piobufs() argument
519 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_link_piobufs()
539 rc = efx_mcdi_rpc(efx, MC_CMD_LINK_PIOBUF, in efx_ef10_link_piobufs()
543 netif_err(efx, drv, efx->net_dev, in efx_ef10_link_piobufs()
549 netif_dbg(efx, probe, efx->net_dev, in efx_ef10_link_piobufs()
555 efx_for_each_channel(channel, efx) { in efx_ef10_link_piobufs()
561 offset = ((efx->tx_channel_offset + efx->n_tx_channels - in efx_ef10_link_piobufs()
582 rc = efx_mcdi_rpc(efx, MC_CMD_LINK_PIOBUF, in efx_ef10_link_piobufs()
591 netif_err(efx, drv, efx->net_dev, in efx_ef10_link_piobufs()
600 netif_dbg(efx, probe, efx->net_dev, in efx_ef10_link_piobufs()
615 efx_mcdi_rpc(efx, MC_CMD_UNLINK_PIOBUF, in efx_ef10_link_piobufs()
622 static void efx_ef10_forget_old_piobufs(struct efx_nic *efx) in efx_ef10_forget_old_piobufs() argument
628 efx_for_each_channel(channel, efx) in efx_ef10_forget_old_piobufs()
635 static int efx_ef10_alloc_piobufs(struct efx_nic *efx, unsigned int n) in efx_ef10_alloc_piobufs() argument
640 static int efx_ef10_link_piobufs(struct efx_nic *efx) in efx_ef10_link_piobufs() argument
645 static void efx_ef10_free_piobufs(struct efx_nic *efx) in efx_ef10_free_piobufs() argument
649 static void efx_ef10_forget_old_piobufs(struct efx_nic *efx) in efx_ef10_forget_old_piobufs() argument
655 static void efx_ef10_remove(struct efx_nic *efx) in efx_ef10_remove() argument
657 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_remove()
666 if (efx->pci_dev->is_virtfn) { in efx_ef10_remove()
667 pci_dev_pf = efx->pci_dev->physfn; in efx_ef10_remove()
672 vf->efx = NULL; in efx_ef10_remove()
674 netif_info(efx, drv, efx->net_dev, in efx_ef10_remove()
679 efx_ptp_remove(efx); in efx_ef10_remove()
681 efx_mcdi_mon_remove(efx); in efx_ef10_remove()
683 efx_ef10_rx_free_indir_table(efx); in efx_ef10_remove()
688 rc = efx_ef10_free_vis(efx); in efx_ef10_remove()
692 efx_ef10_free_piobufs(efx); in efx_ef10_remove()
694 device_remove_file(&efx->pci_dev->dev, &dev_attr_primary_flag); in efx_ef10_remove()
695 device_remove_file(&efx->pci_dev->dev, &dev_attr_link_control_flag); in efx_ef10_remove()
697 efx_mcdi_fini(efx); in efx_ef10_remove()
698 efx_nic_free_buffer(efx, &nic_data->mcdi_buf); in efx_ef10_remove()
702 static int efx_ef10_probe_pf(struct efx_nic *efx) in efx_ef10_probe_pf() argument
704 return efx_ef10_probe(efx); in efx_ef10_probe_pf()
707 int efx_ef10_vadaptor_alloc(struct efx_nic *efx, unsigned int port_id) in efx_ef10_vadaptor_alloc() argument
712 return efx_mcdi_rpc(efx, MC_CMD_VADAPTOR_ALLOC, inbuf, sizeof(inbuf), in efx_ef10_vadaptor_alloc()
716 int efx_ef10_vadaptor_free(struct efx_nic *efx, unsigned int port_id) in efx_ef10_vadaptor_free() argument
721 return efx_mcdi_rpc(efx, MC_CMD_VADAPTOR_FREE, inbuf, sizeof(inbuf), in efx_ef10_vadaptor_free()
725 int efx_ef10_vport_add_mac(struct efx_nic *efx, in efx_ef10_vport_add_mac() argument
733 return efx_mcdi_rpc(efx, MC_CMD_VPORT_ADD_MAC_ADDRESS, inbuf, in efx_ef10_vport_add_mac()
737 int efx_ef10_vport_del_mac(struct efx_nic *efx, in efx_ef10_vport_del_mac() argument
745 return efx_mcdi_rpc(efx, MC_CMD_VPORT_DEL_MAC_ADDRESS, inbuf, in efx_ef10_vport_del_mac()
750 static int efx_ef10_probe_vf(struct efx_nic *efx) in efx_ef10_probe_vf() argument
759 pci_dev_pf = efx->pci_dev->physfn; in efx_ef10_probe_vf()
765 netif_info(efx, drv, efx->net_dev, in efx_ef10_probe_vf()
772 rc = efx_ef10_probe(efx); in efx_ef10_probe_vf()
776 rc = efx_ef10_get_vf_index(efx); in efx_ef10_probe_vf()
780 if (efx->pci_dev->is_virtfn) { in efx_ef10_probe_vf()
781 if (efx->pci_dev->physfn) { in efx_ef10_probe_vf()
783 pci_get_drvdata(efx->pci_dev->physfn); in efx_ef10_probe_vf()
785 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_probe_vf()
787 nic_data_p->vf[nic_data->vf_index].efx = efx; in efx_ef10_probe_vf()
789 efx->pci_dev; in efx_ef10_probe_vf()
791 netif_info(efx, drv, efx->net_dev, in efx_ef10_probe_vf()
798 efx_ef10_remove(efx); in efx_ef10_probe_vf()
802 static int efx_ef10_probe_vf(struct efx_nic *efx __attribute__ ((unused))) in efx_ef10_probe_vf() argument
808 static int efx_ef10_alloc_vis(struct efx_nic *efx, in efx_ef10_alloc_vis() argument
813 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_alloc_vis()
819 rc = efx_mcdi_rpc(efx, MC_CMD_ALLOC_VIS, inbuf, sizeof(inbuf), in efx_ef10_alloc_vis()
827 netif_dbg(efx, drv, efx->net_dev, "base VI is A0x%03x\n", in efx_ef10_alloc_vis()
838 static int efx_ef10_dimension_resources(struct efx_nic *efx) in efx_ef10_dimension_resources() argument
840 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_dimension_resources()
848 channel_vis = max(efx->n_channels, efx->n_tx_channels * EFX_TXQ_TYPES); in efx_ef10_dimension_resources()
859 efx->n_tx_channels) { in efx_ef10_dimension_resources()
861 DIV_ROUND_UP(efx->n_tx_channels, in efx_ef10_dimension_resources()
864 rc = efx_ef10_alloc_piobufs(efx, n_piobufs); in efx_ef10_dimension_resources()
866 netif_err(efx, probe, efx->net_dev, in efx_ef10_dimension_resources()
869 netif_dbg(efx, probe, efx->net_dev, in efx_ef10_dimension_resources()
905 rc = efx_ef10_free_vis(efx); in efx_ef10_dimension_resources()
909 rc = efx_ef10_alloc_vis(efx, min_vis, max_vis); in efx_ef10_dimension_resources()
914 netif_info(efx, drv, efx->net_dev, in efx_ef10_dimension_resources()
922 efx->max_channels = nic_data->n_allocated_vis; in efx_ef10_dimension_resources()
923 efx->max_tx_channels = in efx_ef10_dimension_resources()
926 efx_ef10_free_vis(efx); in efx_ef10_dimension_resources()
936 netif_dbg(efx, probe, efx->net_dev, in efx_ef10_dimension_resources()
939 efx_ef10_free_piobufs(efx); in efx_ef10_dimension_resources()
943 membase = ioremap_nocache(efx->membase_phys, uc_mem_map_size); in efx_ef10_dimension_resources()
945 netif_err(efx, probe, efx->net_dev, in efx_ef10_dimension_resources()
950 iounmap(efx->membase); in efx_ef10_dimension_resources()
951 efx->membase = membase; in efx_ef10_dimension_resources()
955 nic_data->wc_membase = ioremap_wc(efx->membase_phys + in efx_ef10_dimension_resources()
959 netif_err(efx, probe, efx->net_dev, in efx_ef10_dimension_resources()
970 rc = efx_ef10_link_piobufs(efx); in efx_ef10_dimension_resources()
972 efx_ef10_free_piobufs(efx); in efx_ef10_dimension_resources()
975 netif_dbg(efx, probe, efx->net_dev, in efx_ef10_dimension_resources()
977 &efx->membase_phys, efx->membase, uc_mem_map_size, in efx_ef10_dimension_resources()
983 static int efx_ef10_init_nic(struct efx_nic *efx) in efx_ef10_init_nic() argument
985 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_init_nic()
989 rc = efx_ef10_init_datapath_caps(efx); in efx_ef10_init_nic()
997 rc = efx_ef10_alloc_vis(efx, nic_data->n_allocated_vis, in efx_ef10_init_nic()
1005 rc = efx_ef10_alloc_piobufs(efx, nic_data->n_piobufs); in efx_ef10_init_nic()
1007 rc = efx_ef10_link_piobufs(efx); in efx_ef10_init_nic()
1009 efx_ef10_free_piobufs(efx); in efx_ef10_init_nic()
1014 netif_err(efx, drv, efx->net_dev, in efx_ef10_init_nic()
1020 efx->type->rx_push_rss_config(efx, false, efx->rx_indir_table); in efx_ef10_init_nic()
1025 static void efx_ef10_reset_mc_allocations(struct efx_nic *efx) in efx_ef10_reset_mc_allocations() argument
1027 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_reset_mc_allocations()
1036 efx_ef10_forget_old_piobufs(efx); in efx_ef10_reset_mc_allocations()
1044 for (i = 0; i < efx->vf_count; i++) in efx_ef10_reset_mc_allocations()
1087 static int efx_ef10_reset(struct efx_nic *efx, enum reset_type reset_type) in efx_ef10_reset() argument
1089 int rc = efx_mcdi_reset(efx, reset_type); in efx_ef10_reset()
1105 efx_ef10_reset_mc_allocations(efx); in efx_ef10_reset()
1268 static u64 efx_ef10_raw_stat_mask(struct efx_nic *efx) in efx_ef10_raw_stat_mask() argument
1271 u32 port_caps = efx_mcdi_phy_get_caps(efx); in efx_ef10_raw_stat_mask()
1272 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_raw_stat_mask()
1274 if (!(efx->mcdi->fn_flags & in efx_ef10_raw_stat_mask()
1290 static void efx_ef10_get_stat_mask(struct efx_nic *efx, unsigned long *mask) in efx_ef10_get_stat_mask() argument
1292 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_get_stat_mask()
1295 raw_mask[0] = efx_ef10_raw_stat_mask(efx); in efx_ef10_get_stat_mask()
1318 static size_t efx_ef10_describe_stats(struct efx_nic *efx, u8 *names) in efx_ef10_describe_stats() argument
1322 efx_ef10_get_stat_mask(efx, mask); in efx_ef10_describe_stats()
1327 static size_t efx_ef10_update_stats_common(struct efx_nic *efx, u64 *full_stats, in efx_ef10_update_stats_common() argument
1331 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_update_stats_common()
1335 efx_ef10_get_stat_mask(efx, mask); in efx_ef10_update_stats_common()
1396 static int efx_ef10_try_update_nic_stats_pf(struct efx_nic *efx) in efx_ef10_try_update_nic_stats_pf() argument
1398 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_try_update_nic_stats_pf()
1404 efx_ef10_get_stat_mask(efx, mask); in efx_ef10_try_update_nic_stats_pf()
1406 dma_stats = efx->stats_buffer.addr; in efx_ef10_try_update_nic_stats_pf()
1407 nic_data = efx->nic_data; in efx_ef10_try_update_nic_stats_pf()
1414 stats, efx->stats_buffer.addr, false); in efx_ef10_try_update_nic_stats_pf()
1421 efx_nic_fix_nodesc_drop_stat(efx, in efx_ef10_try_update_nic_stats_pf()
1428 efx_update_sw_stats(efx, stats); in efx_ef10_try_update_nic_stats_pf()
1433 static size_t efx_ef10_update_stats_pf(struct efx_nic *efx, u64 *full_stats, in efx_ef10_update_stats_pf() argument
1442 if (efx_ef10_try_update_nic_stats_pf(efx) == 0) in efx_ef10_update_stats_pf()
1447 return efx_ef10_update_stats_common(efx, full_stats, core_stats); in efx_ef10_update_stats_pf()
1450 static int efx_ef10_try_update_nic_stats_vf(struct efx_nic *efx) in efx_ef10_try_update_nic_stats_vf() argument
1453 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_try_update_nic_stats_vf()
1462 spin_unlock_bh(&efx->stats_lock); in efx_ef10_try_update_nic_stats_vf()
1468 spin_lock_bh(&efx->stats_lock); in efx_ef10_try_update_nic_stats_vf()
1469 efx_update_sw_stats(efx, stats); in efx_ef10_try_update_nic_stats_vf()
1473 efx_ef10_get_stat_mask(efx, mask); in efx_ef10_try_update_nic_stats_vf()
1475 rc = efx_nic_alloc_buffer(efx, &stats_buf, dma_len, GFP_ATOMIC); in efx_ef10_try_update_nic_stats_vf()
1477 spin_lock_bh(&efx->stats_lock); in efx_ef10_try_update_nic_stats_vf()
1490 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf), in efx_ef10_try_update_nic_stats_vf()
1492 spin_lock_bh(&efx->stats_lock); in efx_ef10_try_update_nic_stats_vf()
1495 if (rc != -ENOENT || atomic_read(&efx->active_queues)) in efx_ef10_try_update_nic_stats_vf()
1496 efx_mcdi_display_error(efx, MC_CMD_MAC_STATS, in efx_ef10_try_update_nic_stats_vf()
1516 efx_update_sw_stats(efx, stats); in efx_ef10_try_update_nic_stats_vf()
1518 efx_nic_free_buffer(efx, &stats_buf); in efx_ef10_try_update_nic_stats_vf()
1522 static size_t efx_ef10_update_stats_vf(struct efx_nic *efx, u64 *full_stats, in efx_ef10_update_stats_vf() argument
1525 if (efx_ef10_try_update_nic_stats_vf(efx)) in efx_ef10_update_stats_vf()
1528 return efx_ef10_update_stats_common(efx, full_stats, core_stats); in efx_ef10_update_stats_vf()
1533 struct efx_nic *efx = channel->efx; in efx_ef10_push_irq_moderation() local
1545 if (EFX_EF10_WORKAROUND_35388(efx)) { in efx_ef10_push_irq_moderation()
1550 efx_writed_page(efx, &timer_cmd, ER_DD_EVQ_INDIRECT, in efx_ef10_push_irq_moderation()
1555 efx_writed_page(efx, &timer_cmd, ER_DZ_EVQ_TMR, in efx_ef10_push_irq_moderation()
1560 static void efx_ef10_get_wol_vf(struct efx_nic *efx, in efx_ef10_get_wol_vf() argument
1563 static int efx_ef10_set_wol_vf(struct efx_nic *efx, u32 type) in efx_ef10_set_wol_vf() argument
1568 static void efx_ef10_get_wol(struct efx_nic *efx, struct ethtool_wolinfo *wol) in efx_ef10_get_wol() argument
1575 static int efx_ef10_set_wol(struct efx_nic *efx, u32 type) in efx_ef10_set_wol() argument
1582 static void efx_ef10_mcdi_request(struct efx_nic *efx, in efx_ef10_mcdi_request() argument
1586 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_mcdi_request()
1599 _efx_writed(efx, cpu_to_le32((u64)nic_data->mcdi_buf.dma_addr >> 32), in efx_ef10_mcdi_request()
1601 _efx_writed(efx, cpu_to_le32((u32)nic_data->mcdi_buf.dma_addr), in efx_ef10_mcdi_request()
1605 static bool efx_ef10_mcdi_poll_response(struct efx_nic *efx) in efx_ef10_mcdi_poll_response() argument
1607 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_mcdi_poll_response()
1615 efx_ef10_mcdi_read_response(struct efx_nic *efx, efx_dword_t *outbuf, in efx_ef10_mcdi_read_response() argument
1618 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_mcdi_read_response()
1624 static void efx_ef10_mcdi_reboot_detected(struct efx_nic *efx) in efx_ef10_mcdi_reboot_detected() argument
1626 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_mcdi_reboot_detected()
1629 efx_ef10_reset_mc_allocations(efx); in efx_ef10_mcdi_reboot_detected()
1640 static int efx_ef10_mcdi_poll_reboot(struct efx_nic *efx) in efx_ef10_mcdi_poll_reboot() argument
1642 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_mcdi_poll_reboot()
1645 rc = efx_ef10_get_warm_boot_count(efx); in efx_ef10_mcdi_poll_reboot()
1659 efx_ef10_mcdi_reboot_detected(efx); in efx_ef10_mcdi_poll_reboot()
1674 struct efx_nic *efx = context->efx; in efx_ef10_msi_interrupt() local
1676 netif_vdbg(efx, intr, efx->net_dev, in efx_ef10_msi_interrupt()
1679 if (likely(ACCESS_ONCE(efx->irq_soft_enabled))) { in efx_ef10_msi_interrupt()
1681 if (context->index == efx->irq_level) in efx_ef10_msi_interrupt()
1682 efx->last_irq_cpu = raw_smp_processor_id(); in efx_ef10_msi_interrupt()
1685 efx_schedule_channel_irq(efx->channel[context->index]); in efx_ef10_msi_interrupt()
1693 struct efx_nic *efx = dev_id; in efx_ef10_legacy_interrupt() local
1694 bool soft_enabled = ACCESS_ONCE(efx->irq_soft_enabled); in efx_ef10_legacy_interrupt()
1700 efx_readd(efx, ®, ER_DZ_BIU_INT_ISR); in efx_ef10_legacy_interrupt()
1708 if (queues & (1U << efx->irq_level)) in efx_ef10_legacy_interrupt()
1709 efx->last_irq_cpu = raw_smp_processor_id(); in efx_ef10_legacy_interrupt()
1711 efx_for_each_channel(channel, efx) { in efx_ef10_legacy_interrupt()
1718 netif_vdbg(efx, intr, efx->net_dev, in efx_ef10_legacy_interrupt()
1725 static void efx_ef10_irq_test_generate(struct efx_nic *efx) in efx_ef10_irq_test_generate() argument
1731 MCDI_SET_DWORD(inbuf, TRIGGER_INTERRUPT_IN_INTR_LEVEL, efx->irq_level); in efx_ef10_irq_test_generate()
1732 (void) efx_mcdi_rpc(efx, MC_CMD_TRIGGER_INTERRUPT, in efx_ef10_irq_test_generate()
1738 return efx_nic_alloc_buffer(tx_queue->efx, &tx_queue->txd.buf, in efx_ef10_tx_probe()
1754 efx_writeo_page(tx_queue->efx, ®, in efx_ef10_push_tx_desc()
1765 struct efx_nic *efx = tx_queue->efx; in efx_ef10_tx_init() local
1766 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_tx_init()
1786 netif_dbg(efx, hw, efx->net_dev, "pushing TXQ %d. %zu entries (%llx)\n", in efx_ef10_tx_init()
1796 rc = efx_mcdi_rpc(efx, MC_CMD_INIT_TXQ, inbuf, inlen, in efx_ef10_tx_init()
1823 netdev_WARN(efx->net_dev, "failed to initialise TXQ %d\n", in efx_ef10_tx_init()
1831 struct efx_nic *efx = tx_queue->efx; in efx_ef10_tx_fini() local
1838 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_FINI_TXQ, inbuf, sizeof(inbuf), in efx_ef10_tx_fini()
1847 efx_mcdi_display_error(efx, MC_CMD_FINI_TXQ, MC_CMD_FINI_TXQ_IN_LEN, in efx_ef10_tx_fini()
1853 efx_nic_free_buffer(tx_queue->efx, &tx_queue->txd.buf); in efx_ef10_tx_remove()
1864 efx_writed_page(tx_queue->efx, ®, in efx_ef10_notify_tx_desc()
1911 static int efx_ef10_alloc_rss_context(struct efx_nic *efx, u32 *context, in efx_ef10_alloc_rss_context() argument
1916 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_alloc_rss_context()
1923 efx->rss_spread : in efx_ef10_alloc_rss_context()
1924 min(rounddown_pow_of_two(efx->rss_spread), in efx_ef10_alloc_rss_context()
1939 rc = efx_mcdi_rpc(efx, MC_CMD_RSS_CONTEXT_ALLOC, inbuf, sizeof(inbuf), in efx_ef10_alloc_rss_context()
1955 static void efx_ef10_free_rss_context(struct efx_nic *efx, u32 context) in efx_ef10_free_rss_context() argument
1963 rc = efx_mcdi_rpc(efx, MC_CMD_RSS_CONTEXT_FREE, inbuf, sizeof(inbuf), in efx_ef10_free_rss_context()
1968 static int efx_ef10_populate_rss_table(struct efx_nic *efx, u32 context, in efx_ef10_populate_rss_table() argument
1977 BUILD_BUG_ON(ARRAY_SIZE(efx->rx_indir_table) != in efx_ef10_populate_rss_table()
1980 for (i = 0; i < ARRAY_SIZE(efx->rx_indir_table); ++i) in efx_ef10_populate_rss_table()
1985 rc = efx_mcdi_rpc(efx, MC_CMD_RSS_CONTEXT_SET_TABLE, tablebuf, in efx_ef10_populate_rss_table()
1992 BUILD_BUG_ON(ARRAY_SIZE(efx->rx_hash_key) != in efx_ef10_populate_rss_table()
1994 for (i = 0; i < ARRAY_SIZE(efx->rx_hash_key); ++i) in efx_ef10_populate_rss_table()
1996 efx->rx_hash_key[i]; in efx_ef10_populate_rss_table()
1998 return efx_mcdi_rpc(efx, MC_CMD_RSS_CONTEXT_SET_KEY, keybuf, in efx_ef10_populate_rss_table()
2002 static void efx_ef10_rx_free_indir_table(struct efx_nic *efx) in efx_ef10_rx_free_indir_table() argument
2004 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_rx_free_indir_table()
2007 efx_ef10_free_rss_context(efx, nic_data->rx_rss_context); in efx_ef10_rx_free_indir_table()
2011 static int efx_ef10_rx_push_shared_rss_config(struct efx_nic *efx, in efx_ef10_rx_push_shared_rss_config() argument
2015 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_rx_push_shared_rss_config()
2016 int rc = efx_ef10_alloc_rss_context(efx, &new_rx_rss_context, in efx_ef10_rx_push_shared_rss_config()
2024 efx_set_default_rx_indir_table(efx); in efx_ef10_rx_push_shared_rss_config()
2028 static int efx_ef10_rx_push_exclusive_rss_config(struct efx_nic *efx, in efx_ef10_rx_push_exclusive_rss_config() argument
2031 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_rx_push_exclusive_rss_config()
2037 rc = efx_ef10_alloc_rss_context(efx, &new_rx_rss_context, in efx_ef10_rx_push_exclusive_rss_config()
2047 rc = efx_ef10_populate_rss_table(efx, new_rx_rss_context, in efx_ef10_rx_push_exclusive_rss_config()
2053 efx_ef10_rx_free_indir_table(efx); in efx_ef10_rx_push_exclusive_rss_config()
2056 if (rx_indir_table != efx->rx_indir_table) in efx_ef10_rx_push_exclusive_rss_config()
2057 memcpy(efx->rx_indir_table, rx_indir_table, in efx_ef10_rx_push_exclusive_rss_config()
2058 sizeof(efx->rx_indir_table)); in efx_ef10_rx_push_exclusive_rss_config()
2063 efx_ef10_free_rss_context(efx, new_rx_rss_context); in efx_ef10_rx_push_exclusive_rss_config()
2065 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_ef10_rx_push_exclusive_rss_config()
2069 static int efx_ef10_pf_rx_push_rss_config(struct efx_nic *efx, bool user, in efx_ef10_pf_rx_push_rss_config() argument
2074 if (efx->rss_spread == 1) in efx_ef10_pf_rx_push_rss_config()
2077 rc = efx_ef10_rx_push_exclusive_rss_config(efx, rx_indir_table); in efx_ef10_pf_rx_push_rss_config()
2084 for (i = 0; i < ARRAY_SIZE(efx->rx_indir_table) && !mismatch; in efx_ef10_pf_rx_push_rss_config()
2087 ethtool_rxfh_indir_default(i, efx->rss_spread); in efx_ef10_pf_rx_push_rss_config()
2089 rc = efx_ef10_rx_push_shared_rss_config(efx, &context_size); in efx_ef10_pf_rx_push_rss_config()
2091 if (context_size != efx->rss_spread) in efx_ef10_pf_rx_push_rss_config()
2092 netif_warn(efx, probe, efx->net_dev, in efx_ef10_pf_rx_push_rss_config()
2097 efx->rss_spread, context_size); in efx_ef10_pf_rx_push_rss_config()
2099 netif_warn(efx, probe, efx->net_dev, in efx_ef10_pf_rx_push_rss_config()
2105 netif_info(efx, probe, efx->net_dev, in efx_ef10_pf_rx_push_rss_config()
2113 static int efx_ef10_vf_rx_push_rss_config(struct efx_nic *efx, bool user, in efx_ef10_vf_rx_push_rss_config() argument
2117 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vf_rx_push_rss_config()
2123 return efx_ef10_rx_push_shared_rss_config(efx, NULL); in efx_ef10_vf_rx_push_rss_config()
2128 return efx_nic_alloc_buffer(rx_queue->efx, &rx_queue->rxd.buf, in efx_ef10_rx_probe()
2141 struct efx_nic *efx = rx_queue->efx; in efx_ef10_rx_init() local
2142 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_rx_init()
2165 netif_dbg(efx, hw, efx->net_dev, "pushing RXQ %d. %zu entries (%llx)\n", in efx_ef10_rx_init()
2175 rc = efx_mcdi_rpc(efx, MC_CMD_INIT_RXQ, inbuf, inlen, in efx_ef10_rx_init()
2178 netdev_WARN(efx->net_dev, "failed to initialise RXQ %d\n", in efx_ef10_rx_init()
2186 struct efx_nic *efx = rx_queue->efx; in efx_ef10_rx_fini() local
2193 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_FINI_RXQ, inbuf, sizeof(inbuf), in efx_ef10_rx_fini()
2202 efx_mcdi_display_error(efx, MC_CMD_FINI_RXQ, MC_CMD_FINI_RXQ_IN_LEN, in efx_ef10_rx_fini()
2208 efx_nic_free_buffer(rx_queue->efx, &rx_queue->rxd.buf); in efx_ef10_rx_remove()
2227 struct efx_nic *efx = rx_queue->efx; in efx_ef10_rx_write() local
2245 efx_writed_page(efx, ®, ER_DZ_RX_DESC_UPD, in efx_ef10_rx_write()
2269 efx_mcdi_rpc_async(channel->efx, MC_CMD_DRIVER_EVENT, in efx_ef10_rx_defer_refill()
2275 efx_ef10_rx_defer_refill_complete(struct efx_nic *efx, unsigned long cookie, in efx_ef10_rx_defer_refill_complete() argument
2284 return efx_nic_alloc_buffer(channel->efx, &channel->eventq.buf, in efx_ef10_ev_probe()
2294 struct efx_nic *efx = channel->efx; in efx_ef10_ev_fini() local
2300 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_FINI_EVQ, inbuf, sizeof(inbuf), in efx_ef10_ev_fini()
2309 efx_mcdi_display_error(efx, MC_CMD_FINI_EVQ, MC_CMD_FINI_EVQ_IN_LEN, in efx_ef10_ev_fini()
2320 struct efx_nic *efx = channel->efx; in efx_ef10_ev_init() local
2329 nic_data = efx->nic_data; in efx_ef10_ev_init()
2362 rc = efx_mcdi_rpc(efx, MC_CMD_INIT_EVQ, inbuf, inlen, in efx_ef10_ev_init()
2369 rc = efx_mcdi_get_workarounds(efx, &implemented, &enabled); in efx_ef10_ev_init()
2386 rc = efx_mcdi_set_workaround(efx, in efx_ef10_ev_init()
2393 netif_info(efx, drv, efx->net_dev, in efx_ef10_ev_init()
2415 efx_nic_free_buffer(channel->efx, &channel->eventq.buf); in efx_ef10_ev_remove()
2421 struct efx_nic *efx = rx_queue->efx; in efx_ef10_handle_rx_wrong_queue() local
2423 netif_info(efx, hw, efx->net_dev, in efx_ef10_handle_rx_wrong_queue()
2427 efx_schedule_reset(efx, RESET_TYPE_DISABLE); in efx_ef10_handle_rx_wrong_queue()
2435 struct efx_nic *efx = rx_queue->efx; in efx_ef10_handle_rx_bad_lbits() local
2437 netif_info(efx, hw, efx->net_dev, in efx_ef10_handle_rx_bad_lbits()
2441 efx_schedule_reset(efx, RESET_TYPE_DISABLE); in efx_ef10_handle_rx_bad_lbits()
2449 netif_dbg(rx_queue->efx, hw, rx_queue->efx->net_dev, in efx_ef10_handle_rx_abort()
2469 struct efx_nic *efx = channel->efx; in efx_ef10_handle_rx_event() local
2474 if (unlikely(ACCESS_ONCE(efx->reset_pending))) in efx_ef10_handle_rx_event()
2485 netdev_WARN(efx->net_dev, "saw RX_DROP_EVENT: event=" in efx_ef10_handle_rx_event()
2498 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_handle_rx_event()
2503 netdev_WARN(efx->net_dev, in efx_ef10_handle_rx_event()
2578 struct efx_nic *efx = channel->efx; in efx_ef10_handle_tx_event() local
2584 if (unlikely(ACCESS_ONCE(efx->reset_pending))) in efx_ef10_handle_tx_event()
2605 struct efx_nic *efx = channel->efx; in efx_ef10_handle_driver_event() local
2618 netif_err(efx, hw, efx->net_dev, in efx_ef10_handle_driver_event()
2630 struct efx_nic *efx = channel->efx; in efx_ef10_handle_driver_generated_event() local
2647 netif_err(efx, hw, efx->net_dev, in efx_ef10_handle_driver_generated_event()
2657 struct efx_nic *efx = channel->efx; in efx_ef10_ev_process() local
2682 netif_vdbg(efx, drv, efx->net_dev, in efx_ef10_ev_process()
2702 if (tx_descs > efx->txq_entries) { in efx_ef10_ev_process()
2718 netif_err(efx, hw, efx->net_dev, in efx_ef10_ev_process()
2733 struct efx_nic *efx = channel->efx; in efx_ef10_ev_read_ack() local
2736 if (EFX_EF10_WORKAROUND_35388(efx)) { in efx_ef10_ev_read_ack()
2748 efx_writed_page(efx, &rptr, ER_DD_EVQ_INDIRECT, in efx_ef10_ev_read_ack()
2755 efx_writed_page(efx, &rptr, ER_DD_EVQ_INDIRECT, in efx_ef10_ev_read_ack()
2761 efx_writed_page(efx, &rptr, ER_DZ_EVQ_RPTR, channel->channel); in efx_ef10_ev_read_ack()
2768 struct efx_nic *efx = channel->efx; in efx_ef10_ev_test_generate() local
2784 rc = efx_mcdi_rpc(efx, MC_CMD_DRIVER_EVENT, inbuf, sizeof(inbuf), in efx_ef10_ev_test_generate()
2793 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_ef10_ev_test_generate()
2796 void efx_ef10_handle_drain_event(struct efx_nic *efx) in efx_ef10_handle_drain_event() argument
2798 if (atomic_dec_and_test(&efx->active_queues)) in efx_ef10_handle_drain_event()
2799 wake_up(&efx->flush_wq); in efx_ef10_handle_drain_event()
2801 WARN_ON(atomic_read(&efx->active_queues) < 0); in efx_ef10_handle_drain_event()
2804 static int efx_ef10_fini_dmaq(struct efx_nic *efx) in efx_ef10_fini_dmaq() argument
2806 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_fini_dmaq()
2816 atomic_set(&efx->active_queues, 0); in efx_ef10_fini_dmaq()
2821 if (efx->state != STATE_RECOVERY) { in efx_ef10_fini_dmaq()
2822 efx_for_each_channel(channel, efx) { in efx_ef10_fini_dmaq()
2829 wait_event_timeout(efx->flush_wq, in efx_ef10_fini_dmaq()
2830 atomic_read(&efx->active_queues) == 0, in efx_ef10_fini_dmaq()
2832 pending = atomic_read(&efx->active_queues); in efx_ef10_fini_dmaq()
2834 netif_err(efx, hw, efx->net_dev, "failed to flush %d queues\n", in efx_ef10_fini_dmaq()
2843 static void efx_ef10_prepare_flr(struct efx_nic *efx) in efx_ef10_prepare_flr() argument
2845 atomic_set(&efx->active_queues, 0); in efx_ef10_prepare_flr()
2920 static void efx_ef10_filter_push_prep(struct efx_nic *efx, in efx_ef10_filter_push_prep() argument
2925 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_filter_push_prep()
2998 static int efx_ef10_filter_push(struct efx_nic *efx, in efx_ef10_filter_push() argument
3006 efx_ef10_filter_push_prep(efx, spec, inbuf, *handle, replacing); in efx_ef10_filter_push()
3007 rc = efx_mcdi_rpc(efx, MC_CMD_FILTER_OP, inbuf, sizeof(inbuf), in efx_ef10_filter_push()
3030 static s32 efx_ef10_filter_insert(struct efx_nic *efx, in efx_ef10_filter_insert() argument
3034 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_insert()
3068 spin_lock_bh(&efx->filter_lock); in efx_ef10_filter_insert()
3124 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_insert()
3172 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_insert()
3174 rc = efx_ef10_filter_push(efx, spec, &table->entry[ins_index].handle, in efx_ef10_filter_insert()
3178 spin_lock_bh(&efx->filter_lock); in efx_ef10_filter_insert()
3215 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_insert()
3220 rc = efx_mcdi_rpc(efx, MC_CMD_FILTER_OP, in efx_ef10_filter_insert()
3223 spin_lock_bh(&efx->filter_lock); in efx_ef10_filter_insert()
3244 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_insert()
3249 static void efx_ef10_filter_update_rx_scatter(struct efx_nic *efx) in efx_ef10_filter_update_rx_scatter() argument
3259 static int efx_ef10_filter_remove_internal(struct efx_nic *efx, in efx_ef10_filter_remove_internal() argument
3264 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_remove_internal()
3277 spin_lock_bh(&efx->filter_lock); in efx_ef10_filter_remove_internal()
3282 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_remove_internal()
3310 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_remove_internal()
3319 (efx_rss_enabled(efx) ? in efx_ef10_filter_remove_internal()
3323 rc = efx_ef10_filter_push(efx, &new_spec, in efx_ef10_filter_remove_internal()
3327 spin_lock_bh(&efx->filter_lock); in efx_ef10_filter_remove_internal()
3339 rc = efx_mcdi_rpc(efx, MC_CMD_FILTER_OP, in efx_ef10_filter_remove_internal()
3342 spin_lock_bh(&efx->filter_lock); in efx_ef10_filter_remove_internal()
3352 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_remove_internal()
3357 static int efx_ef10_filter_remove_safe(struct efx_nic *efx, in efx_ef10_filter_remove_safe() argument
3361 return efx_ef10_filter_remove_internal(efx, 1U << priority, in efx_ef10_filter_remove_safe()
3365 static u32 efx_ef10_filter_get_unsafe_id(struct efx_nic *efx, u32 filter_id) in efx_ef10_filter_get_unsafe_id() argument
3370 static int efx_ef10_filter_remove_unsafe(struct efx_nic *efx, in efx_ef10_filter_remove_unsafe() argument
3374 return efx_ef10_filter_remove_internal(efx, 1U << priority, in efx_ef10_filter_remove_unsafe()
3378 static int efx_ef10_filter_get_safe(struct efx_nic *efx, in efx_ef10_filter_get_safe() argument
3383 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_get_safe()
3387 spin_lock_bh(&efx->filter_lock); in efx_ef10_filter_get_safe()
3397 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_get_safe()
3401 static int efx_ef10_filter_clear_rx(struct efx_nic *efx, in efx_ef10_filter_clear_rx() argument
3412 rc = efx_ef10_filter_remove_internal(efx, priority_mask, in efx_ef10_filter_clear_rx()
3421 static u32 efx_ef10_filter_count_rx_used(struct efx_nic *efx, in efx_ef10_filter_count_rx_used() argument
3424 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_count_rx_used()
3428 spin_lock_bh(&efx->filter_lock); in efx_ef10_filter_count_rx_used()
3435 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_count_rx_used()
3439 static u32 efx_ef10_filter_get_rx_id_limit(struct efx_nic *efx) in efx_ef10_filter_get_rx_id_limit() argument
3441 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_get_rx_id_limit()
3446 static s32 efx_ef10_filter_get_rx_ids(struct efx_nic *efx, in efx_ef10_filter_get_rx_ids() argument
3450 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_get_rx_ids()
3455 spin_lock_bh(&efx->filter_lock); in efx_ef10_filter_get_rx_ids()
3469 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_get_rx_ids()
3477 static s32 efx_ef10_filter_rfs_insert(struct efx_nic *efx, in efx_ef10_filter_rfs_insert() argument
3480 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_rfs_insert()
3501 spin_lock_bh(&efx->filter_lock); in efx_ef10_filter_rfs_insert()
3561 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_rfs_insert()
3566 efx_ef10_filter_push_prep(efx, spec, inbuf, in efx_ef10_filter_rfs_insert()
3568 efx_mcdi_rpc_async(efx, MC_CMD_FILTER_OP, inbuf, sizeof(inbuf), in efx_ef10_filter_rfs_insert()
3575 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_rfs_insert()
3580 efx_ef10_filter_rfs_insert_complete(struct efx_nic *efx, unsigned long cookie, in efx_ef10_filter_rfs_insert_complete() argument
3584 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_rfs_insert_complete()
3594 spin_lock_bh(&efx->filter_lock); in efx_ef10_filter_rfs_insert_complete()
3606 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_rfs_insert_complete()
3612 efx_ef10_filter_rfs_expire_complete(struct efx_nic *efx,
3617 static bool efx_ef10_filter_rfs_expire_one(struct efx_nic *efx, u32 flow_id, in efx_ef10_filter_rfs_expire_one() argument
3620 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_rfs_expire_one()
3630 !rps_may_expire_flow(efx->net_dev, spec->dmaq_id, in efx_ef10_filter_rfs_expire_one()
3638 if (efx_mcdi_rpc_async(efx, MC_CMD_FILTER_OP, inbuf, sizeof(inbuf), 0, in efx_ef10_filter_rfs_expire_one()
3647 efx_ef10_filter_rfs_expire_complete(struct efx_nic *efx, in efx_ef10_filter_rfs_expire_complete() argument
3652 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_rfs_expire_complete()
3656 spin_lock_bh(&efx->filter_lock); in efx_ef10_filter_rfs_expire_complete()
3663 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_rfs_expire_complete()
3700 static int efx_ef10_filter_table_probe(struct efx_nic *efx) in efx_ef10_filter_table_probe() argument
3716 rc = efx_mcdi_rpc(efx, MC_CMD_GET_PARSER_DISP_INFO, in efx_ef10_filter_table_probe()
3733 netif_dbg(efx, probe, efx->net_dev, in efx_ef10_filter_table_probe()
3737 netif_dbg(efx, probe, efx->net_dev, in efx_ef10_filter_table_probe()
3755 efx->filter_state = table; in efx_ef10_filter_table_probe()
3767 static void efx_ef10_filter_table_restore(struct efx_nic *efx) in efx_ef10_filter_table_restore() argument
3769 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_table_restore()
3770 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_filter_table_restore()
3776 WARN_ON(!rwsem_is_locked(&efx->filter_sem)); in efx_ef10_filter_table_restore()
3784 spin_lock_bh(&efx->filter_lock); in efx_ef10_filter_table_restore()
3792 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_table_restore()
3794 rc = efx_ef10_filter_push(efx, spec, in efx_ef10_filter_table_restore()
3800 spin_lock_bh(&efx->filter_lock); in efx_ef10_filter_table_restore()
3810 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_table_restore()
3813 netif_err(efx, hw, efx->net_dev, in efx_ef10_filter_table_restore()
3820 static void efx_ef10_filter_table_remove(struct efx_nic *efx) in efx_ef10_filter_table_remove() argument
3822 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_table_remove()
3828 efx->filter_state = NULL; in efx_ef10_filter_table_remove()
3843 rc = efx_mcdi_rpc(efx, MC_CMD_FILTER_OP, inbuf, sizeof(inbuf), in efx_ef10_filter_table_remove()
3846 netdev_WARN(efx->net_dev, in efx_ef10_filter_table_remove()
3859 filter_idx = efx_ef10_filter_get_unsafe_id(efx, id); \
3863 static void efx_ef10_filter_mark_old(struct efx_nic *efx) in efx_ef10_filter_mark_old() argument
3865 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_mark_old()
3872 spin_lock_bh(&efx->filter_lock); in efx_ef10_filter_mark_old()
3880 spin_unlock_bh(&efx->filter_lock); in efx_ef10_filter_mark_old()
3884 static void efx_ef10_filter_uc_addr_list(struct efx_nic *efx, bool *promisc) in efx_ef10_filter_uc_addr_list() argument
3886 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_uc_addr_list()
3887 struct net_device *net_dev = efx->net_dev; in efx_ef10_filter_uc_addr_list()
3910 static void efx_ef10_filter_mc_addr_list(struct efx_nic *efx, bool *promisc) in efx_ef10_filter_mc_addr_list() argument
3912 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_mc_addr_list()
3913 struct net_device *net_dev = efx->net_dev; in efx_ef10_filter_mc_addr_list()
3937 static int efx_ef10_filter_insert_addr_list(struct efx_nic *efx, in efx_ef10_filter_insert_addr_list() argument
3940 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_insert_addr_list()
3957 filter_flags = efx_rss_enabled(efx) ? EFX_FILTER_FLAG_RX_RSS : 0; in efx_ef10_filter_insert_addr_list()
3964 rc = efx_ef10_filter_insert(efx, &spec, true); in efx_ef10_filter_insert_addr_list()
3967 netif_info(efx, drv, efx->net_dev, in efx_ef10_filter_insert_addr_list()
3975 efx, EFX_FILTER_PRI_AUTO, in efx_ef10_filter_insert_addr_list()
3985 addr_list[i].id = efx_ef10_filter_get_unsafe_id(efx, rc); in efx_ef10_filter_insert_addr_list()
3993 rc = efx_ef10_filter_insert(efx, &spec, true); in efx_ef10_filter_insert_addr_list()
3995 netif_warn(efx, drv, efx->net_dev, in efx_ef10_filter_insert_addr_list()
4002 efx, EFX_FILTER_PRI_AUTO, in efx_ef10_filter_insert_addr_list()
4008 table->bcast_id = efx_ef10_filter_get_unsafe_id(efx, rc); in efx_ef10_filter_insert_addr_list()
4015 static int efx_ef10_filter_insert_def(struct efx_nic *efx, bool multicast, in efx_ef10_filter_insert_def() argument
4018 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_insert_def()
4019 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_filter_insert_def()
4025 filter_flags = efx_rss_enabled(efx) ? EFX_FILTER_FLAG_RX_RSS : 0; in efx_ef10_filter_insert_def()
4034 rc = efx_ef10_filter_insert(efx, &spec, true); in efx_ef10_filter_insert_def()
4036 netif_warn(efx, drv, efx->net_dev, in efx_ef10_filter_insert_def()
4040 table->mcdef_id = efx_ef10_filter_get_unsafe_id(efx, rc); in efx_ef10_filter_insert_def()
4048 rc = efx_ef10_filter_insert(efx, &spec, true); in efx_ef10_filter_insert_def()
4050 netif_warn(efx, drv, efx->net_dev, in efx_ef10_filter_insert_def()
4056 efx, EFX_FILTER_PRI_AUTO, in efx_ef10_filter_insert_def()
4062 table->bcast_id = efx_ef10_filter_get_unsafe_id(efx, rc); in efx_ef10_filter_insert_def()
4077 static void efx_ef10_filter_remove_old(struct efx_nic *efx) in efx_ef10_filter_remove_old() argument
4079 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_remove_old()
4087 efx, 1U << EFX_FILTER_PRI_AUTO, in efx_ef10_filter_remove_old()
4095 static int efx_ef10_vport_set_mac_address(struct efx_nic *efx) in efx_ef10_vport_set_mac_address() argument
4097 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vport_set_mac_address()
4105 efx_device_detach_sync(efx); in efx_ef10_vport_set_mac_address()
4106 efx_net_stop(efx->net_dev); in efx_ef10_vport_set_mac_address()
4107 down_write(&efx->filter_sem); in efx_ef10_vport_set_mac_address()
4108 efx_ef10_filter_table_remove(efx); in efx_ef10_vport_set_mac_address()
4109 up_write(&efx->filter_sem); in efx_ef10_vport_set_mac_address()
4111 rc = efx_ef10_vadaptor_free(efx, nic_data->vport_id); in efx_ef10_vport_set_mac_address()
4116 rc = efx_ef10_vport_del_mac(efx, nic_data->vport_id, in efx_ef10_vport_set_mac_address()
4121 rc = efx_ef10_vport_add_mac(efx, nic_data->vport_id, in efx_ef10_vport_set_mac_address()
4122 efx->net_dev->dev_addr); in efx_ef10_vport_set_mac_address()
4124 ether_addr_copy(nic_data->vport_mac, efx->net_dev->dev_addr); in efx_ef10_vport_set_mac_address()
4126 rc2 = efx_ef10_vport_add_mac(efx, nic_data->vport_id, mac_old); in efx_ef10_vport_set_mac_address()
4135 rc2 = efx_ef10_vadaptor_alloc(efx, nic_data->vport_id); in efx_ef10_vport_set_mac_address()
4139 down_write(&efx->filter_sem); in efx_ef10_vport_set_mac_address()
4140 rc2 = efx_ef10_filter_table_probe(efx); in efx_ef10_vport_set_mac_address()
4141 up_write(&efx->filter_sem); in efx_ef10_vport_set_mac_address()
4145 rc2 = efx_net_open(efx->net_dev); in efx_ef10_vport_set_mac_address()
4149 netif_device_attach(efx->net_dev); in efx_ef10_vport_set_mac_address()
4154 netif_err(efx, drv, efx->net_dev, in efx_ef10_vport_set_mac_address()
4156 efx_schedule_reset(efx, RESET_TYPE_DATAPATH); in efx_ef10_vport_set_mac_address()
4164 static void efx_ef10_filter_sync_rx_mode(struct efx_nic *efx) in efx_ef10_filter_sync_rx_mode() argument
4166 struct efx_ef10_filter_table *table = efx->filter_state; in efx_ef10_filter_sync_rx_mode()
4167 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_filter_sync_rx_mode()
4168 struct net_device *net_dev = efx->net_dev; in efx_ef10_filter_sync_rx_mode()
4171 if (!efx_dev_registered(efx)) in efx_ef10_filter_sync_rx_mode()
4177 efx_ef10_filter_mark_old(efx); in efx_ef10_filter_sync_rx_mode()
4183 efx_ef10_filter_uc_addr_list(efx, &uc_promisc); in efx_ef10_filter_sync_rx_mode()
4184 efx_ef10_filter_mc_addr_list(efx, &mc_promisc); in efx_ef10_filter_sync_rx_mode()
4189 efx_ef10_filter_insert_def(efx, false, false); in efx_ef10_filter_sync_rx_mode()
4190 efx_ef10_filter_insert_addr_list(efx, false, false); in efx_ef10_filter_sync_rx_mode()
4196 if (efx_ef10_filter_insert_addr_list(efx, false, false)) in efx_ef10_filter_sync_rx_mode()
4197 efx_ef10_filter_insert_def(efx, false, false); in efx_ef10_filter_sync_rx_mode()
4204 if (nic_data->workaround_26807 && efx->mc_promisc != mc_promisc) in efx_ef10_filter_sync_rx_mode()
4205 efx_ef10_filter_remove_old(efx); in efx_ef10_filter_sync_rx_mode()
4211 if (efx_ef10_filter_insert_def(efx, true, true)) { in efx_ef10_filter_sync_rx_mode()
4213 efx_ef10_filter_remove_old(efx); in efx_ef10_filter_sync_rx_mode()
4214 efx_ef10_filter_insert_addr_list(efx, true, false); in efx_ef10_filter_sync_rx_mode()
4220 efx_ef10_filter_insert_def(efx, true, false); in efx_ef10_filter_sync_rx_mode()
4221 efx_ef10_filter_insert_addr_list(efx, true, false); in efx_ef10_filter_sync_rx_mode()
4229 if (efx_ef10_filter_insert_addr_list(efx, true, true)) { in efx_ef10_filter_sync_rx_mode()
4232 efx_ef10_filter_remove_old(efx); in efx_ef10_filter_sync_rx_mode()
4233 if (efx_ef10_filter_insert_def(efx, true, true)) in efx_ef10_filter_sync_rx_mode()
4234 efx_ef10_filter_insert_addr_list(efx, true, false); in efx_ef10_filter_sync_rx_mode()
4238 efx_ef10_filter_remove_old(efx); in efx_ef10_filter_sync_rx_mode()
4239 efx->mc_promisc = mc_promisc; in efx_ef10_filter_sync_rx_mode()
4242 static int efx_ef10_set_mac_address(struct efx_nic *efx) in efx_ef10_set_mac_address() argument
4245 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_set_mac_address()
4246 bool was_enabled = efx->port_enabled; in efx_ef10_set_mac_address()
4249 efx_device_detach_sync(efx); in efx_ef10_set_mac_address()
4250 efx_net_stop(efx->net_dev); in efx_ef10_set_mac_address()
4251 down_write(&efx->filter_sem); in efx_ef10_set_mac_address()
4252 efx_ef10_filter_table_remove(efx); in efx_ef10_set_mac_address()
4255 efx->net_dev->dev_addr); in efx_ef10_set_mac_address()
4258 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_VADAPTOR_SET_MAC, inbuf, in efx_ef10_set_mac_address()
4261 efx_ef10_filter_table_probe(efx); in efx_ef10_set_mac_address()
4262 up_write(&efx->filter_sem); in efx_ef10_set_mac_address()
4264 efx_net_open(efx->net_dev); in efx_ef10_set_mac_address()
4265 netif_device_attach(efx->net_dev); in efx_ef10_set_mac_address()
4268 if (efx->pci_dev->is_virtfn && efx->pci_dev->physfn) { in efx_ef10_set_mac_address()
4269 struct pci_dev *pci_dev_pf = efx->pci_dev->physfn; in efx_ef10_set_mac_address()
4279 efx->net_dev->dev_addr); in efx_ef10_set_mac_address()
4291 if (vf->efx == efx) { in efx_ef10_set_mac_address()
4293 efx->net_dev->dev_addr); in efx_ef10_set_mac_address()
4301 netif_err(efx, drv, efx->net_dev, in efx_ef10_set_mac_address()
4304 } else if (rc == -ENOSYS && !efx_ef10_is_vf(efx)) { in efx_ef10_set_mac_address()
4310 rc = efx_ef10_vport_set_mac_address(efx); in efx_ef10_set_mac_address()
4312 efx_mcdi_display_error(efx, MC_CMD_VADAPTOR_SET_MAC, in efx_ef10_set_mac_address()
4319 static int efx_ef10_mac_reconfigure(struct efx_nic *efx) in efx_ef10_mac_reconfigure() argument
4321 efx_ef10_filter_sync_rx_mode(efx); in efx_ef10_mac_reconfigure()
4323 return efx_mcdi_set_mac(efx); in efx_ef10_mac_reconfigure()
4326 static int efx_ef10_mac_reconfigure_vf(struct efx_nic *efx) in efx_ef10_mac_reconfigure_vf() argument
4328 efx_ef10_filter_sync_rx_mode(efx); in efx_ef10_mac_reconfigure_vf()
4333 static int efx_ef10_start_bist(struct efx_nic *efx, u32 bist_type) in efx_ef10_start_bist() argument
4338 return efx_mcdi_rpc(efx, MC_CMD_START_BIST, inbuf, sizeof(inbuf), in efx_ef10_start_bist()
4346 static int efx_ef10_poll_bist(struct efx_nic *efx) in efx_ef10_poll_bist() argument
4353 rc = efx_mcdi_rpc(efx, MC_CMD_POLL_BIST, NULL, 0, in efx_ef10_poll_bist()
4364 netif_dbg(efx, hw, efx->net_dev, "BIST passed.\n"); in efx_ef10_poll_bist()
4367 netif_err(efx, hw, efx->net_dev, "BIST timed out\n"); in efx_ef10_poll_bist()
4370 netif_err(efx, hw, efx->net_dev, "BIST failed.\n"); in efx_ef10_poll_bist()
4373 netif_err(efx, hw, efx->net_dev, in efx_ef10_poll_bist()
4379 static int efx_ef10_run_bist(struct efx_nic *efx, u32 bist_type) in efx_ef10_run_bist() argument
4383 netif_dbg(efx, drv, efx->net_dev, "starting BIST type %u\n", bist_type); in efx_ef10_run_bist()
4385 rc = efx_ef10_start_bist(efx, bist_type); in efx_ef10_run_bist()
4389 return efx_ef10_poll_bist(efx); in efx_ef10_run_bist()
4393 efx_ef10_test_chip(struct efx_nic *efx, struct efx_self_tests *tests) in efx_ef10_test_chip() argument
4397 efx_reset_down(efx, RESET_TYPE_WORLD); in efx_ef10_test_chip()
4399 rc = efx_mcdi_rpc(efx, MC_CMD_ENABLE_OFFLINE_BIST, in efx_ef10_test_chip()
4404 tests->memory = efx_ef10_run_bist(efx, MC_CMD_MC_MEM_BIST) ? -1 : 1; in efx_ef10_test_chip()
4405 tests->registers = efx_ef10_run_bist(efx, MC_CMD_REG_BIST) ? -1 : 1; in efx_ef10_test_chip()
4407 rc = efx_mcdi_reset(efx, RESET_TYPE_WORLD); in efx_ef10_test_chip()
4412 rc2 = efx_reset_up(efx, RESET_TYPE_WORLD, rc == 0); in efx_ef10_test_chip()
4439 static int efx_ef10_mtd_probe_partition(struct efx_nic *efx, in efx_ef10_mtd_probe_partition() argument
4459 if (info->port != efx_port_num(efx)) in efx_ef10_mtd_probe_partition()
4462 rc = efx_mcdi_nvram_info(efx, type, &size, &erase_size, &protected); in efx_ef10_mtd_probe_partition()
4478 rc = efx_mcdi_rpc(efx, MC_CMD_NVRAM_METADATA, inbuf, sizeof(inbuf), in efx_ef10_mtd_probe_partition()
4500 static int efx_ef10_mtd_probe(struct efx_nic *efx) in efx_ef10_mtd_probe() argument
4512 rc = efx_mcdi_rpc(efx, MC_CMD_NVRAM_PARTITIONS, NULL, 0, in efx_ef10_mtd_probe()
4532 rc = efx_ef10_mtd_probe_partition(efx, &parts[n_parts], type, in efx_ef10_mtd_probe()
4541 rc = efx_mtd_add(efx, &parts[0].common, n_parts, sizeof(*parts)); in efx_ef10_mtd_probe()
4550 static void efx_ef10_ptp_write_host_time(struct efx_nic *efx, u32 host_time) in efx_ef10_ptp_write_host_time() argument
4552 _efx_writed(efx, cpu_to_le32(host_time), ER_DZ_MC_DB_LWRD); in efx_ef10_ptp_write_host_time()
4555 static void efx_ef10_ptp_write_host_time_vf(struct efx_nic *efx, in efx_ef10_ptp_write_host_time_vf() argument
4575 rc = efx_mcdi_rpc(channel->efx, MC_CMD_PTP, in efx_ef10_rx_enable_timestamping()
4608 rc = efx_mcdi_rpc(channel->efx, MC_CMD_PTP, in efx_ef10_rx_disable_timestamping()
4614 static int efx_ef10_ptp_set_ts_sync_events(struct efx_nic *efx, bool en, in efx_ef10_ptp_set_ts_sync_events() argument
4624 efx_for_each_channel(channel, efx) { in efx_ef10_ptp_set_ts_sync_events()
4627 efx_ef10_ptp_set_ts_sync_events(efx, false, temp); in efx_ef10_ptp_set_ts_sync_events()
4635 static int efx_ef10_ptp_set_ts_config_vf(struct efx_nic *efx, in efx_ef10_ptp_set_ts_config_vf() argument
4641 static int efx_ef10_ptp_set_ts_config(struct efx_nic *efx, in efx_ef10_ptp_set_ts_config() argument
4648 efx_ef10_ptp_set_ts_sync_events(efx, false, false); in efx_ef10_ptp_set_ts_config()
4650 return efx_ptp_change_mode(efx, in efx_ef10_ptp_set_ts_config()
4666 rc = efx_ptp_change_mode(efx, true, 0); in efx_ef10_ptp_set_ts_config()
4668 rc = efx_ef10_ptp_set_ts_sync_events(efx, true, false); in efx_ef10_ptp_set_ts_config()
4670 efx_ptp_change_mode(efx, false, 0); in efx_ef10_ptp_set_ts_config()