Lines Matching defs:efx
42 static int efx_ef10_set_udp_tnl_ports(struct efx_nic *efx, bool unloading);
45 static int efx_ef10_get_warm_boot_count(struct efx_nic *efx)
49 efx_readd(efx, ®, ER_DZ_BIU_MC_SFT_STATUS);
58 static unsigned int efx_ef10_pf_mem_bar(struct efx_nic *efx)
60 switch (efx->pci_dev->device) {
69 static unsigned int efx_ef10_vf_mem_bar(struct efx_nic *efx)
74 static unsigned int efx_ef10_mem_map_size(struct efx_nic *efx)
78 bar = efx->type->mem_bar(efx);
79 return resource_size(&efx->pci_dev->resource[bar]);
82 static bool efx_ef10_is_vf(struct efx_nic *efx)
84 return efx->type->is_vf;
88 static int efx_ef10_get_vf_index(struct efx_nic *efx)
91 struct efx_ef10_nic_data *nic_data = efx->nic_data;
95 rc = efx_mcdi_rpc(efx, MC_CMD_GET_FUNCTION_INFO, NULL, 0, outbuf,
107 static int efx_ef10_init_datapath_caps(struct efx_nic *efx)
110 struct efx_ef10_nic_data *nic_data = efx->nic_data;
116 rc = efx_mcdi_rpc(efx, MC_CMD_GET_CAPABILITIES, NULL, 0,
121 netif_err(efx, drv, efx->net_dev,
148 netif_err(efx, probe, efx->net_dev,
157 rc = efx_mcdi_window_mode_to_stride(efx, vi_window_mode);
162 netif_dbg(efx, probe, efx->net_dev,
164 efx->vi_stride);
168 efx->num_mac_stats = MCDI_WORD(outbuf,
170 netif_dbg(efx, probe, efx->net_dev,
172 efx->num_mac_stats);
175 netif_dbg(efx, probe, efx->net_dev,
177 efx->num_mac_stats);
183 static void efx_ef10_read_licensed_features(struct efx_nic *efx)
187 struct efx_ef10_nic_data *nic_data = efx->nic_data;
193 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_LICENSING_V3, inbuf, sizeof(inbuf),
202 static int efx_ef10_get_sysclk_freq(struct efx_nic *efx)
207 rc = efx_mcdi_rpc(efx, MC_CMD_GET_CLOCK, NULL, 0,
215 static int efx_ef10_get_timer_workarounds(struct efx_nic *efx)
217 struct efx_ef10_nic_data *nic_data = efx->nic_data;
225 rc = efx_mcdi_get_workarounds(efx, &implemented, &enabled);
241 rc = efx_mcdi_set_workaround(efx,
251 netif_dbg(efx, probe, efx->net_dev,
254 netif_dbg(efx, probe, efx->net_dev,
261 static void efx_ef10_process_timer_config(struct efx_nic *efx,
266 if (EFX_EF10_WORKAROUND_61265(efx)) {
267 efx->timer_quantum_ns = MCDI_DWORD(data,
269 efx->timer_max_ns = MCDI_DWORD(data,
271 } else if (EFX_EF10_WORKAROUND_35388(efx)) {
272 efx->timer_quantum_ns = MCDI_DWORD(data,
276 efx->timer_max_ns = max_count * efx->timer_quantum_ns;
278 efx->timer_quantum_ns = MCDI_DWORD(data,
282 efx->timer_max_ns = max_count * efx->timer_quantum_ns;
285 netif_dbg(efx, probe, efx->net_dev,
287 efx->timer_quantum_ns, efx->timer_max_ns);
290 static int efx_ef10_get_timer_config(struct efx_nic *efx)
295 rc = efx_ef10_get_timer_workarounds(efx);
299 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_GET_EVQ_TMR_PROPERTIES, NULL, 0,
303 efx_ef10_process_timer_config(efx, outbuf);
308 rc = efx_ef10_get_sysclk_freq(efx);
313 efx->timer_quantum_ns = quantum;
314 efx->timer_max_ns = efx->type->timer_period_max * quantum;
317 efx_mcdi_display_error(efx, MC_CMD_GET_EVQ_TMR_PROPERTIES,
325 static int efx_ef10_get_mac_address_pf(struct efx_nic *efx, u8 *mac_address)
333 rc = efx_mcdi_rpc(efx, MC_CMD_GET_MAC_ADDRESSES, NULL, 0,
345 static int efx_ef10_get_mac_address_vf(struct efx_nic *efx, u8 *mac_address)
354 rc = efx_mcdi_rpc(efx, MC_CMD_VPORT_GET_MAC_ADDRESSES, inbuf,
377 struct efx_nic *efx = dev_get_drvdata(dev);
380 ((efx->mcdi->fn_flags) &
389 struct efx_nic *efx = dev_get_drvdata(dev);
392 ((efx->mcdi->fn_flags) &
397 static struct efx_ef10_vlan *efx_ef10_find_vlan(struct efx_nic *efx, u16 vid)
399 struct efx_ef10_nic_data *nic_data = efx->nic_data;
412 static int efx_ef10_add_vlan(struct efx_nic *efx, u16 vid)
414 struct efx_ef10_nic_data *nic_data = efx->nic_data;
420 vlan = efx_ef10_find_vlan(efx, vid);
427 netif_warn(efx, drv, efx->net_dev,
442 if (efx->filter_state) {
443 mutex_lock(&efx->mac_lock);
444 down_write(&efx->filter_sem);
445 rc = efx_mcdi_filter_add_vlan(efx, vlan->vid);
446 up_write(&efx->filter_sem);
447 mutex_unlock(&efx->mac_lock);
465 static void efx_ef10_del_vlan_internal(struct efx_nic *efx,
468 struct efx_ef10_nic_data *nic_data = efx->nic_data;
472 if (efx->filter_state) {
473 down_write(&efx->filter_sem);
474 efx_mcdi_filter_del_vlan(efx, vlan->vid);
475 up_write(&efx->filter_sem);
482 static int efx_ef10_del_vlan(struct efx_nic *efx, u16 vid)
484 struct efx_ef10_nic_data *nic_data = efx->nic_data;
497 vlan = efx_ef10_find_vlan(efx, vid);
499 netif_err(efx, drv, efx->net_dev,
503 efx_ef10_del_vlan_internal(efx, vlan);
511 static void efx_ef10_cleanup_vlans(struct efx_nic *efx)
513 struct efx_ef10_nic_data *nic_data = efx->nic_data;
518 efx_ef10_del_vlan_internal(efx, vlan);
526 static int efx_ef10_probe(struct efx_nic *efx)
534 efx->nic_data = nic_data;
539 rc = efx_nic_alloc_buffer(efx, &nic_data->mcdi_buf,
549 rc = efx_ef10_get_warm_boot_count(efx);
563 _efx_writed(efx, cpu_to_le32(1), ER_DZ_MC_DB_HWRD);
565 rc = efx_mcdi_init(efx);
575 rc = efx_mcdi_reset(efx, RESET_TYPE_ALL);
580 rc = efx_mcdi_log_ctrl(efx, true, false, 0);
584 rc = device_create_file(&efx->pci_dev->dev,
589 rc = device_create_file(&efx->pci_dev->dev, &dev_attr_primary_flag);
593 rc = efx_get_pf_index(efx, &nic_data->pf_index);
597 rc = efx_ef10_init_datapath_caps(efx);
601 efx_ef10_read_licensed_features(efx);
609 efx->tx_queues_per_channel = 4;
611 efx->tx_queues_per_channel = 2;
612 efx->max_vis = efx_ef10_mem_map_size(efx) / efx->vi_stride;
613 if (!efx->max_vis) {
614 netif_err(efx, drv, efx->net_dev, "error determining max VIs\n");
618 efx->max_channels = min_t(unsigned int, EFX_MAX_CHANNELS,
619 efx->max_vis / efx->tx_queues_per_channel);
620 efx->max_tx_channels = efx->max_channels;
621 if (WARN_ON(efx->max_channels == 0)) {
626 efx->rx_packet_len_offset =
631 efx->net_dev->hw_features |= NETIF_F_RXFCS;
633 rc = efx_mcdi_port_get_number(efx);
636 efx->port_num = rc;
638 rc = efx->type->get_mac_address(efx, efx->net_dev->perm_addr);
642 rc = efx_ef10_get_timer_config(efx);
646 rc = efx_mcdi_mon_probe(efx);
650 efx_ptp_defer_probe_with_channel(efx);
653 if ((efx->pci_dev->physfn) && (!efx->pci_dev->is_physfn)) {
654 struct pci_dev *pci_dev_pf = efx->pci_dev->physfn;
660 ether_addr_copy(nic_data->port_id, efx->net_dev->perm_addr);
666 rc = efx_ef10_add_vlan(efx, EFX_FILTER_VID_UNSPEC);
674 rc = efx_ef10_add_vlan(efx, 0);
680 efx->mcdi->fn_flags &
682 efx->net_dev->udp_tunnel_nic_info = &efx_ef10_udp_tunnels;
687 efx_ef10_cleanup_vlans(efx);
690 efx_ptp_remove(efx);
691 efx_mcdi_mon_remove(efx);
693 device_remove_file(&efx->pci_dev->dev, &dev_attr_primary_flag);
695 device_remove_file(&efx->pci_dev->dev, &dev_attr_link_control_flag);
697 efx_mcdi_detach(efx);
701 (void)efx_ef10_set_udp_tnl_ports(efx, true);
705 efx_mcdi_fini(efx);
707 efx_nic_free_buffer(efx, &nic_data->mcdi_buf);
710 efx->nic_data = NULL;
716 static void efx_ef10_free_piobufs(struct efx_nic *efx)
718 struct efx_ef10_nic_data *nic_data = efx->nic_data;
728 rc = efx_mcdi_rpc(efx, MC_CMD_FREE_PIOBUF, inbuf, sizeof(inbuf),
736 static int efx_ef10_alloc_piobufs(struct efx_nic *efx, unsigned int n)
738 struct efx_ef10_nic_data *nic_data = efx->nic_data;
747 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_ALLOC_PIOBUF, NULL, 0,
753 if (!(efx_ef10_is_vf(efx) && rc == -ENOSPC))
754 efx_mcdi_display_error(efx, MC_CMD_ALLOC_PIOBUF,
764 netif_dbg(efx, probe, efx->net_dev,
771 efx_ef10_free_piobufs(efx);
775 static int efx_ef10_link_piobufs(struct efx_nic *efx)
777 struct efx_ef10_nic_data *nic_data = efx->nic_data;
793 rc = efx_mcdi_rpc(efx, MC_CMD_LINK_PIOBUF,
797 netif_err(efx, drv, efx->net_dev,
803 netif_dbg(efx, probe, efx->net_dev,
809 efx_for_each_channel(channel, efx) {
814 channel->channel >= efx->xdp_channel_offset)
822 offset = ((efx->tx_channel_offset + efx->n_tx_channels -
843 rc = efx_mcdi_rpc(efx, MC_CMD_LINK_PIOBUF,
852 netif_err(efx, drv, efx->net_dev,
859 index * efx->vi_stride + offset;
861 netif_dbg(efx, probe, efx->net_dev,
880 efx_mcdi_rpc(efx, MC_CMD_UNLINK_PIOBUF,
887 static void efx_ef10_forget_old_piobufs(struct efx_nic *efx)
893 efx_for_each_channel(channel, efx)
900 static int efx_ef10_alloc_piobufs(struct efx_nic *efx, unsigned int n)
905 static int efx_ef10_link_piobufs(struct efx_nic *efx)
910 static void efx_ef10_free_piobufs(struct efx_nic *efx)
914 static void efx_ef10_forget_old_piobufs(struct efx_nic *efx)
920 static void efx_ef10_remove(struct efx_nic *efx)
922 struct efx_ef10_nic_data *nic_data = efx->nic_data;
931 if (efx->pci_dev->is_virtfn) {
932 pci_dev_pf = efx->pci_dev->physfn;
937 vf->efx = NULL;
939 netif_info(efx, drv, efx->net_dev,
944 efx_ef10_cleanup_vlans(efx);
947 efx_ptp_remove(efx);
949 efx_mcdi_mon_remove(efx);
951 efx_mcdi_rx_free_indir_table(efx);
956 rc = efx_mcdi_free_vis(efx);
960 efx_ef10_free_piobufs(efx);
962 device_remove_file(&efx->pci_dev->dev, &dev_attr_primary_flag);
963 device_remove_file(&efx->pci_dev->dev, &dev_attr_link_control_flag);
965 efx_mcdi_detach(efx);
969 (void)efx_ef10_set_udp_tnl_ports(efx, true);
974 efx_mcdi_fini(efx);
975 efx_nic_free_buffer(efx, &nic_data->mcdi_buf);
979 static int efx_ef10_probe_pf(struct efx_nic *efx)
981 return efx_ef10_probe(efx);
984 int efx_ef10_vadaptor_query(struct efx_nic *efx, unsigned int port_id,
988 struct efx_ef10_nic_data *nic_data = efx->nic_data;
999 rc = efx_mcdi_rpc(efx, MC_CMD_VADAPTOR_QUERY, inbuf, sizeof(inbuf),
1023 int efx_ef10_vadaptor_alloc(struct efx_nic *efx, unsigned int port_id)
1028 return efx_mcdi_rpc(efx, MC_CMD_VADAPTOR_ALLOC, inbuf, sizeof(inbuf),
1032 int efx_ef10_vadaptor_free(struct efx_nic *efx, unsigned int port_id)
1037 return efx_mcdi_rpc(efx, MC_CMD_VADAPTOR_FREE, inbuf, sizeof(inbuf),
1041 int efx_ef10_vport_add_mac(struct efx_nic *efx,
1049 return efx_mcdi_rpc(efx, MC_CMD_VPORT_ADD_MAC_ADDRESS, inbuf,
1053 int efx_ef10_vport_del_mac(struct efx_nic *efx,
1061 return efx_mcdi_rpc(efx, MC_CMD_VPORT_DEL_MAC_ADDRESS, inbuf,
1066 static int efx_ef10_probe_vf(struct efx_nic *efx)
1075 pci_dev_pf = efx->pci_dev->physfn;
1081 netif_info(efx, drv, efx->net_dev,
1088 rc = efx_ef10_probe(efx);
1092 rc = efx_ef10_get_vf_index(efx);
1096 if (efx->pci_dev->is_virtfn) {
1097 if (efx->pci_dev->physfn) {
1099 pci_get_drvdata(efx->pci_dev->physfn);
1101 struct efx_ef10_nic_data *nic_data = efx->nic_data;
1103 nic_data_p->vf[nic_data->vf_index].efx = efx;
1105 efx->pci_dev;
1107 netif_info(efx, drv, efx->net_dev,
1114 efx_ef10_remove(efx);
1118 static int efx_ef10_probe_vf(struct efx_nic *efx __attribute__ ((unused)))
1124 static int efx_ef10_alloc_vis(struct efx_nic *efx,
1127 struct efx_ef10_nic_data *nic_data = efx->nic_data;
1129 return efx_mcdi_alloc_vis(efx, min_vis, max_vis, &nic_data->vi_base,
1136 static int efx_ef10_dimension_resources(struct efx_nic *efx)
1138 unsigned int min_vis = max_t(unsigned int, efx->tx_queues_per_channel,
1141 struct efx_ef10_nic_data *nic_data = efx->nic_data;
1146 channel_vis = max(efx->n_channels,
1147 ((efx->n_tx_channels + efx->n_extra_tx_channels) *
1148 efx->tx_queues_per_channel) +
1149 efx->n_xdp_channels * efx->xdp_tx_per_channel);
1150 if (efx->max_vis && efx->max_vis < channel_vis) {
1151 netif_dbg(efx, drv, efx->net_dev,
1153 channel_vis, efx->max_vis);
1154 channel_vis = efx->max_vis;
1166 efx->n_tx_channels) {
1168 DIV_ROUND_UP(efx->n_tx_channels,
1171 rc = efx_ef10_alloc_piobufs(efx, n_piobufs);
1173 netif_dbg(efx, probe, efx->net_dev,
1176 netif_dbg(efx, probe, efx->net_dev,
1179 netif_err(efx, probe, efx->net_dev,
1182 netif_dbg(efx, probe, efx->net_dev,
1199 uc_mem_map_size = PAGE_ALIGN((channel_vis - 1) * efx->vi_stride +
1205 pio_write_vi_base = uc_mem_map_size / efx->vi_stride;
1208 efx->vi_stride) -
1218 rc = efx_mcdi_free_vis(efx);
1222 rc = efx_ef10_alloc_vis(efx, min_vis, max_vis);
1227 netif_info(efx, drv, efx->net_dev,
1235 efx->max_channels = nic_data->n_allocated_vis;
1236 efx->max_tx_channels =
1237 nic_data->n_allocated_vis / efx->tx_queues_per_channel;
1239 efx_mcdi_free_vis(efx);
1249 netif_dbg(efx, probe, efx->net_dev,
1252 efx_ef10_free_piobufs(efx);
1256 membase = ioremap(efx->membase_phys, uc_mem_map_size);
1258 netif_err(efx, probe, efx->net_dev,
1263 iounmap(efx->membase);
1264 efx->membase = membase;
1268 nic_data->wc_membase = ioremap_wc(efx->membase_phys +
1272 netif_err(efx, probe, efx->net_dev,
1280 (pio_write_vi_base * efx->vi_stride + ER_DZ_TX_PIOBUF -
1283 rc = efx_ef10_link_piobufs(efx);
1285 efx_ef10_free_piobufs(efx);
1288 netif_dbg(efx, probe, efx->net_dev,
1290 &efx->membase_phys, efx->membase, uc_mem_map_size,
1296 static void efx_ef10_fini_nic(struct efx_nic *efx)
1298 struct efx_ef10_nic_data *nic_data = efx->nic_data;
1300 spin_lock_bh(&efx->stats_lock);
1303 spin_unlock_bh(&efx->stats_lock);
1306 static int efx_ef10_init_nic(struct efx_nic *efx)
1308 struct efx_ef10_nic_data *nic_data = efx->nic_data;
1309 struct net_device *net_dev = efx->net_dev;
1314 rc = efx_ef10_init_datapath_caps(efx);
1320 if (efx->must_realloc_vis) {
1322 rc = efx_ef10_alloc_vis(efx, nic_data->n_allocated_vis,
1326 efx->must_realloc_vis = false;
1329 nic_data->mc_stats = kmalloc(efx->num_mac_stats * sizeof(__le64),
1335 rc = efx_ef10_alloc_piobufs(efx, nic_data->n_piobufs);
1337 rc = efx_ef10_link_piobufs(efx);
1339 efx_ef10_free_piobufs(efx);
1347 netif_dbg(efx, drv, efx->net_dev,
1350 netif_err(efx, drv, efx->net_dev,
1356 if (efx_has_cap(efx, VXLAN_NVGRE) && !efx_ef10_is_vf(efx))
1365 if (efx_has_cap(efx, TX_TSO_V2_ENCAP)) {
1381 rc = efx->type->rx_push_rss_config(efx, false,
1382 efx->rss_context.rx_indir_table, NULL);
1387 static void efx_ef10_table_reset_mc_allocations(struct efx_nic *efx)
1389 struct efx_ef10_nic_data *nic_data = efx->nic_data;
1395 efx->must_realloc_vis = true;
1396 efx_mcdi_filter_table_reset_mc_allocations(efx);
1398 efx_ef10_forget_old_piobufs(efx);
1399 efx->rss_context.context_id = EFX_MCDI_RSS_CONTEXT_INVALID;
1403 efx->vport_id = EVB_PORT_ID_ASSIGNED;
1406 for (i = 0; i < efx->vf_count; i++)
1449 static int efx_ef10_reset(struct efx_nic *efx, enum reset_type reset_type)
1451 int rc = efx_mcdi_reset(efx, reset_type);
1467 efx_ef10_table_reset_mc_allocations(efx);
1687 static u64 efx_ef10_raw_stat_mask(struct efx_nic *efx)
1690 u32 port_caps = efx_mcdi_phy_get_caps(efx);
1691 struct efx_ef10_nic_data *nic_data = efx->nic_data;
1693 if (!(efx->mcdi->fn_flags &
1714 static void efx_ef10_get_stat_mask(struct efx_nic *efx, unsigned long *mask)
1716 struct efx_ef10_nic_data *nic_data = efx->nic_data;
1719 raw_mask[0] = efx_ef10_raw_stat_mask(efx);
1730 if (efx->num_mac_stats >= MC_CMD_MAC_NSTATS_V2)
1737 if (efx->num_mac_stats >= MC_CMD_MAC_NSTATS_V3 &&
1754 static size_t efx_ef10_describe_stats(struct efx_nic *efx, u8 *names)
1758 efx_ef10_get_stat_mask(efx, mask);
1763 static size_t efx_ef10_update_stats_common(struct efx_nic *efx, u64 *full_stats,
1767 struct efx_ef10_nic_data *nic_data = efx->nic_data;
1771 efx_ef10_get_stat_mask(efx, mask);
1832 static size_t efx_ef10_update_stats_pf(struct efx_nic *efx, u64 *full_stats,
1835 struct efx_ef10_nic_data *nic_data = efx->nic_data;
1839 efx_ef10_get_stat_mask(efx, mask);
1845 efx_nic_copy_stats(efx, nic_data->mc_stats);
1851 efx_nic_fix_nodesc_drop_stat(efx,
1872 efx_update_sw_stats(efx, stats);
1874 return efx_ef10_update_stats_common(efx, full_stats, core_stats);
1877 static int efx_ef10_try_update_nic_stats_vf(struct efx_nic *efx)
1878 __must_hold(&efx->stats_lock)
1881 struct efx_ef10_nic_data *nic_data = efx->nic_data;
1885 u32 dma_len = efx->num_mac_stats * sizeof(u64);
1890 spin_unlock_bh(&efx->stats_lock);
1892 efx_ef10_get_stat_mask(efx, mask);
1894 rc = efx_nic_alloc_buffer(efx, &stats_buf, dma_len, GFP_KERNEL);
1896 spin_lock_bh(&efx->stats_lock);
1901 dma_stats[efx->num_mac_stats - 1] = EFX_MC_STATS_GENERATION_INVALID;
1909 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf),
1911 spin_lock_bh(&efx->stats_lock);
1914 if (rc != -ENOENT || atomic_read(&efx->active_queues))
1915 efx_mcdi_display_error(efx, MC_CMD_MAC_STATS,
1920 generation_end = dma_stats[efx->num_mac_stats - 1];
1935 efx_update_sw_stats(efx, stats);
1938 spin_unlock_bh(&efx->stats_lock);
1939 efx_nic_free_buffer(efx, &stats_buf);
1940 spin_lock_bh(&efx->stats_lock);
1944 static size_t efx_ef10_update_stats_vf(struct efx_nic *efx, u64 *full_stats,
1947 if (efx_ef10_try_update_nic_stats_vf(efx))
1950 return efx_ef10_update_stats_common(efx, full_stats, core_stats);
1953 static size_t efx_ef10_update_stats_atomic_vf(struct efx_nic *efx, u64 *full_stats,
1956 struct efx_ef10_nic_data *nic_data = efx->nic_data;
1961 efx_update_sw_stats(efx, nic_data->stats);
1962 return efx_ef10_update_stats_common(efx, full_stats, core_stats);
1967 struct efx_nic *efx = channel->efx;
1979 if (EFX_EF10_WORKAROUND_61265(efx)) {
1989 efx_mcdi_rpc_async(efx, MC_CMD_SET_EVQ_TMR,
1991 } else if (EFX_EF10_WORKAROUND_35388(efx)) {
1992 unsigned int ticks = efx_usecs_to_ticks(efx, usecs);
1998 efx_writed_page(efx, &timer_cmd, ER_DD_EVQ_INDIRECT,
2001 unsigned int ticks = efx_usecs_to_ticks(efx, usecs);
2006 efx_writed_page(efx, &timer_cmd, ER_DZ_EVQ_TMR,
2011 static void efx_ef10_get_wol_vf(struct efx_nic *efx,
2014 static int efx_ef10_set_wol_vf(struct efx_nic *efx, u32 type)
2019 static void efx_ef10_get_wol(struct efx_nic *efx, struct ethtool_wolinfo *wol)
2026 static int efx_ef10_set_wol(struct efx_nic *efx, u32 type)
2033 static void efx_ef10_mcdi_request(struct efx_nic *efx,
2037 struct efx_ef10_nic_data *nic_data = efx->nic_data;
2050 _efx_writed(efx, cpu_to_le32((u64)nic_data->mcdi_buf.dma_addr >> 32),
2052 _efx_writed(efx, cpu_to_le32((u32)nic_data->mcdi_buf.dma_addr),
2056 static bool efx_ef10_mcdi_poll_response(struct efx_nic *efx)
2058 struct efx_ef10_nic_data *nic_data = efx->nic_data;
2066 efx_ef10_mcdi_read_response(struct efx_nic *efx, efx_dword_t *outbuf,
2069 struct efx_ef10_nic_data *nic_data = efx->nic_data;
2075 static void efx_ef10_mcdi_reboot_detected(struct efx_nic *efx)
2077 struct efx_ef10_nic_data *nic_data = efx->nic_data;
2080 efx_ef10_table_reset_mc_allocations(efx);
2091 static int efx_ef10_mcdi_poll_reboot(struct efx_nic *efx)
2093 struct efx_ef10_nic_data *nic_data = efx->nic_data;
2096 rc = efx_ef10_get_warm_boot_count(efx);
2110 efx_ef10_mcdi_reboot_detected(efx);
2125 struct efx_nic *efx = context->efx;
2127 netif_vdbg(efx, intr, efx->net_dev,
2130 if (likely(READ_ONCE(efx->irq_soft_enabled))) {
2132 if (context->index == efx->irq_level)
2133 efx->last_irq_cpu = raw_smp_processor_id();
2136 efx_schedule_channel_irq(efx->channel[context->index]);
2144 struct efx_nic *efx = dev_id;
2145 bool soft_enabled = READ_ONCE(efx->irq_soft_enabled);
2151 efx_readd(efx, ®, ER_DZ_BIU_INT_ISR);
2159 if (queues & (1U << efx->irq_level))
2160 efx->last_irq_cpu = raw_smp_processor_id();
2162 efx_for_each_channel(channel, efx) {
2169 netif_vdbg(efx, intr, efx->net_dev,
2176 static int efx_ef10_irq_test_generate(struct efx_nic *efx)
2180 if (efx_mcdi_set_workaround(efx, MC_CMD_WORKAROUND_BUG41750, true,
2186 MCDI_SET_DWORD(inbuf, TRIGGER_INTERRUPT_IN_INTR_LEVEL, efx->irq_level);
2187 return efx_mcdi_rpc(efx, MC_CMD_TRIGGER_INTERRUPT,
2196 return efx_nic_alloc_buffer(tx_queue->efx, &tx_queue->txd.buf,
2212 efx_writeo_page(tx_queue->efx, ®,
2311 static u32 efx_ef10_tso_versions(struct efx_nic *efx)
2313 struct efx_ef10_nic_data *nic_data = efx->nic_data;
2330 struct efx_nic *efx = tx_queue->efx;
2335 nic_data = efx->nic_data;
2344 if (efx->type->ptp_set_ts_sync_events)
2345 efx->type->ptp_set_ts_sync_events(efx, false, false);
2354 if (efx_has_cap(efx, TX_TSO_V2)) {
2358 netif_dbg(efx, hw, efx->net_dev, "Using TSOv2 for channel %u\n",
2361 } else if (efx_has_cap(efx, TX_TSO)) {
2389 if (tx_queue->tso_version == 2 && efx_has_cap(efx, TX_TSO_V2_ENCAP))
2398 netdev_WARN(efx->net_dev, "failed to initialise TXQ %d\n",
2410 efx_writed_page(tx_queue->efx, ®,
2480 static int efx_ef10_probe_multicast_chaining(struct efx_nic *efx)
2482 struct efx_ef10_nic_data *nic_data = efx->nic_data;
2487 rc = efx_mcdi_get_workarounds(efx, &implemented, &enabled);
2505 rc = efx_mcdi_set_workaround(efx,
2511 netif_info(efx, drv, efx->net_dev,
2521 rc = efx_ef10_get_warm_boot_count(efx);
2535 static int efx_ef10_filter_table_probe(struct efx_nic *efx)
2537 struct efx_ef10_nic_data *nic_data = efx->nic_data;
2538 int rc = efx_ef10_probe_multicast_chaining(efx);
2543 rc = efx_mcdi_filter_table_probe(efx, nic_data->workaround_26807);
2549 rc = efx_mcdi_filter_add_vlan(efx, vlan->vid);
2556 efx_mcdi_filter_table_remove(efx);
2576 struct efx_nic *efx = rx_queue->efx;
2594 efx_writed_page(efx, ®, ER_DZ_RX_DESC_UPD,
2618 efx_mcdi_rpc_async(channel->efx, MC_CMD_DRIVER_EVENT,
2624 efx_ef10_rx_defer_refill_complete(struct efx_nic *efx, unsigned long cookie,
2633 struct efx_nic *efx = channel->efx;
2637 nic_data = efx->nic_data;
2648 struct efx_nic *efx = rx_queue->efx;
2650 netif_info(efx, hw, efx->net_dev,
2654 efx_schedule_reset(efx, RESET_TYPE_DISABLE);
2662 struct efx_nic *efx = rx_queue->efx;
2664 netif_info(efx, hw, efx->net_dev,
2668 efx_schedule_reset(efx, RESET_TYPE_DISABLE);
2676 netif_dbg(rx_queue->efx, hw, rx_queue->efx->net_dev,
2698 struct efx_nic *efx = channel->efx;
2702 if (!(efx->net_dev->features & NETIF_F_RXALL)) {
2703 if (!efx->loopback_selftest)
2715 netdev_WARN(efx->net_dev,
2719 if (!efx->loopback_selftest)
2731 netdev_WARN(efx->net_dev,
2735 if (!efx->loopback_selftest)
2743 netdev_WARN(efx->net_dev,
2751 netdev_WARN(efx->net_dev,
2755 if (!efx->loopback_selftest)
2761 netdev_WARN(efx->net_dev,
2769 netdev_WARN(efx->net_dev,
2773 if (!efx->loopback_selftest)
2788 struct efx_nic *efx = channel->efx;
2789 struct efx_ef10_nic_data *nic_data = efx->nic_data;
2795 if (unlikely(READ_ONCE(efx->reset_pending)))
2812 netdev_WARN(efx->net_dev, "saw RX_DROP_EVENT: event="
2825 struct efx_ef10_nic_data *nic_data = efx->nic_data;
2830 netdev_WARN(efx->net_dev,
2896 netdev_WARN(efx->net_dev,
2937 struct efx_nic *efx = channel->efx;
2944 if (unlikely(READ_ONCE(efx->reset_pending)))
3003 netif_err(efx, hw, efx->net_dev,
3015 struct efx_nic *efx = channel->efx;
3028 netif_err(efx, hw, efx->net_dev,
3040 struct efx_nic *efx = channel->efx;
3057 netif_err(efx, hw, efx->net_dev,
3067 struct efx_nic *efx = channel->efx;
3091 netif_vdbg(efx, drv, efx->net_dev,
3121 netif_err(efx, hw, efx->net_dev,
3136 struct efx_nic *efx = channel->efx;
3139 if (EFX_EF10_WORKAROUND_35388(efx)) {
3151 efx_writed_page(efx, &rptr, ER_DD_EVQ_INDIRECT,
3158 efx_writed_page(efx, &rptr, ER_DD_EVQ_INDIRECT,
3164 efx_writed_page(efx, &rptr, ER_DZ_EVQ_RPTR, channel->channel);
3171 struct efx_nic *efx = channel->efx;
3187 rc = efx_mcdi_rpc(efx, MC_CMD_DRIVER_EVENT, inbuf, sizeof(inbuf),
3196 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
3199 static void efx_ef10_prepare_flr(struct efx_nic *efx)
3201 atomic_set(&efx->active_queues, 0);
3204 static int efx_ef10_vport_set_mac_address(struct efx_nic *efx)
3206 struct efx_ef10_nic_data *nic_data = efx->nic_data;
3214 efx_device_detach_sync(efx);
3215 efx_net_stop(efx->net_dev);
3216 down_write(&efx->filter_sem);
3217 efx_mcdi_filter_table_remove(efx);
3218 up_write(&efx->filter_sem);
3220 rc = efx_ef10_vadaptor_free(efx, efx->vport_id);
3225 rc = efx_ef10_vport_del_mac(efx, efx->vport_id,
3230 rc = efx_ef10_vport_add_mac(efx, efx->vport_id,
3231 efx->net_dev->dev_addr);
3233 ether_addr_copy(nic_data->vport_mac, efx->net_dev->dev_addr);
3235 rc2 = efx_ef10_vport_add_mac(efx, efx->vport_id, mac_old);
3244 rc2 = efx_ef10_vadaptor_alloc(efx, efx->vport_id);
3248 down_write(&efx->filter_sem);
3249 rc2 = efx_ef10_filter_table_probe(efx);
3250 up_write(&efx->filter_sem);
3254 rc2 = efx_net_open(efx->net_dev);
3258 efx_device_attach_if_not_resetting(efx);
3263 netif_err(efx, drv, efx->net_dev,
3265 efx_schedule_reset(efx, RESET_TYPE_DATAPATH);
3270 static int efx_ef10_set_mac_address(struct efx_nic *efx)
3273 bool was_enabled = efx->port_enabled;
3280 if (efx->pci_dev->is_virtfn && efx->pci_dev->physfn) {
3281 struct efx_nic *efx_pf = pci_get_drvdata(efx->pci_dev->physfn);
3282 struct efx_ef10_nic_data *nic_data = efx->nic_data;
3288 ether_addr_copy(mac, efx->net_dev->dev_addr);
3294 netif_dbg(efx, drv, efx->net_dev,
3300 efx_device_detach_sync(efx);
3301 efx_net_stop(efx->net_dev);
3303 mutex_lock(&efx->mac_lock);
3304 down_write(&efx->filter_sem);
3305 efx_mcdi_filter_table_remove(efx);
3308 efx->net_dev->dev_addr);
3310 efx->vport_id);
3311 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_VADAPTOR_SET_MAC, inbuf,
3314 efx_ef10_filter_table_probe(efx);
3315 up_write(&efx->filter_sem);
3316 mutex_unlock(&efx->mac_lock);
3319 efx_net_open(efx->net_dev);
3320 efx_device_attach_if_not_resetting(efx);
3323 netif_err(efx, drv, efx->net_dev,
3326 } else if (rc == -ENOSYS && !efx_ef10_is_vf(efx)) {
3332 rc = efx_ef10_vport_set_mac_address(efx);
3334 efx_mcdi_display_error(efx, MC_CMD_VADAPTOR_SET_MAC,
3341 static int efx_ef10_mac_reconfigure(struct efx_nic *efx, bool mtu_only)
3343 WARN_ON(!mutex_is_locked(&efx->mac_lock));
3345 efx_mcdi_filter_sync_rx_mode(efx);
3347 if (mtu_only && efx_has_cap(efx, SET_MAC_ENHANCED))
3348 return efx_mcdi_set_mtu(efx);
3349 return efx_mcdi_set_mac(efx);
3352 static int efx_ef10_start_bist(struct efx_nic *efx, u32 bist_type)
3357 return efx_mcdi_rpc(efx, MC_CMD_START_BIST, inbuf, sizeof(inbuf),
3365 static int efx_ef10_poll_bist(struct efx_nic *efx)
3372 rc = efx_mcdi_rpc(efx, MC_CMD_POLL_BIST, NULL, 0,
3383 netif_dbg(efx, hw, efx->net_dev, "BIST passed.\n");
3386 netif_err(efx, hw, efx->net_dev, "BIST timed out\n");
3389 netif_err(efx, hw, efx->net_dev, "BIST failed.\n");
3392 netif_err(efx, hw, efx->net_dev,
3398 static int efx_ef10_run_bist(struct efx_nic *efx, u32 bist_type)
3402 netif_dbg(efx, drv, efx->net_dev, "starting BIST type %u\n", bist_type);
3404 rc = efx_ef10_start_bist(efx, bist_type);
3408 return efx_ef10_poll_bist(efx);
3412 efx_ef10_test_chip(struct efx_nic *efx, struct efx_self_tests *tests)
3416 efx_reset_down(efx, RESET_TYPE_WORLD);
3418 rc = efx_mcdi_rpc(efx, MC_CMD_ENABLE_OFFLINE_BIST,
3423 tests->memory = efx_ef10_run_bist(efx, MC_CMD_MC_MEM_BIST) ? -1 : 1;
3424 tests->registers = efx_ef10_run_bist(efx, MC_CMD_REG_BIST) ? -1 : 1;
3426 rc = efx_mcdi_reset(efx, RESET_TYPE_WORLD);
3431 rc2 = efx_reset_up(efx, RESET_TYPE_WORLD, rc == 0);
3465 static int efx_ef10_mtd_probe_partition(struct efx_nic *efx,
3485 if (info->port != efx_port_num(efx))
3488 rc = efx_mcdi_nvram_info(efx, type, &size, &erase_size, &protected);
3511 rc = efx_mcdi_rpc(efx, MC_CMD_NVRAM_METADATA, inbuf, sizeof(inbuf),
3536 static int efx_ef10_mtd_probe(struct efx_nic *efx)
3548 rc = efx_mcdi_rpc(efx, MC_CMD_NVRAM_PARTITIONS, NULL, 0,
3568 rc = efx_ef10_mtd_probe_partition(efx, &parts[n_parts], type,
3582 rc = efx_mtd_add(efx, &parts[0].common, n_parts, sizeof(*parts));
3591 static void efx_ef10_ptp_write_host_time(struct efx_nic *efx, u32 host_time)
3593 _efx_writed(efx, cpu_to_le32(host_time), ER_DZ_MC_DB_LWRD);
3596 static void efx_ef10_ptp_write_host_time_vf(struct efx_nic *efx,
3616 rc = efx_mcdi_rpc(channel->efx, MC_CMD_PTP,
3649 rc = efx_mcdi_rpc(channel->efx, MC_CMD_PTP,
3655 static int efx_ef10_ptp_set_ts_sync_events(struct efx_nic *efx, bool en,
3665 channel = efx_ptp_channel(efx);
3669 efx_ef10_ptp_set_ts_sync_events(efx, false, temp);
3677 static int efx_ef10_ptp_set_ts_config_vf(struct efx_nic *efx,
3683 static int efx_ef10_ptp_set_ts_config(struct efx_nic *efx,
3690 efx_ef10_ptp_set_ts_sync_events(efx, false, false);
3692 return efx_ptp_change_mode(efx,
3709 rc = efx_ptp_change_mode(efx, true, 0);
3711 rc = efx_ef10_ptp_set_ts_sync_events(efx, true, false);
3713 efx_ptp_change_mode(efx, false, 0);
3720 static int efx_ef10_get_phys_port_id(struct efx_nic *efx,
3723 struct efx_ef10_nic_data *nic_data = efx->nic_data;
3734 static int efx_ef10_vlan_rx_add_vid(struct efx_nic *efx, __be16 proto, u16 vid)
3739 return efx_ef10_add_vlan(efx, vid);
3742 static int efx_ef10_vlan_rx_kill_vid(struct efx_nic *efx, __be16 proto, u16 vid)
3747 return efx_ef10_del_vlan(efx, vid);
3755 static int efx_ef10_set_udp_tnl_ports(struct efx_nic *efx, bool unloading)
3757 struct efx_ef10_nic_data *nic_data = efx->nic_data;
3773 efx_device_attach_if_not_resetting(efx);
3810 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_SET_TUNNEL_ENCAP_UDP_PORTS,
3824 netif_warn(efx, drv, efx->net_dev,
3828 netif_info(efx, drv, efx->net_dev,
3845 efx_device_attach_if_not_resetting(efx);
3851 static int efx_ef10_udp_tnl_push_ports(struct efx_nic *efx)
3853 struct efx_ef10_nic_data *nic_data = efx->nic_data;
3861 efx_device_detach_sync(efx);
3862 rc = efx_ef10_set_udp_tnl_ports(efx, false);
3872 struct efx_nic *efx = netdev_priv(dev);
3881 nic_data = efx->nic_data;
3890 efx_device_detach_sync(efx);
3893 rc = efx_ef10_set_udp_tnl_ports(efx, false);
3904 static bool efx_ef10_udp_tnl_has_port(struct efx_nic *efx, __be16 port)
3906 struct efx_ef10_nic_data *nic_data = efx->nic_data;
3932 struct efx_nic *efx = netdev_priv(dev);
3936 nic_data = efx->nic_data;
3942 efx_device_detach_sync(efx);
3945 rc = efx_ef10_set_udp_tnl_ports(efx, false);
3967 static size_t efx_ef10_print_additional_fwver(struct efx_nic *efx, char *buf,
3970 struct efx_ef10_nic_data *nic_data = efx->nic_data;
3977 static unsigned int ef10_check_caps(const struct efx_nic *efx,
3981 const struct efx_ef10_nic_data *nic_data = efx->nic_data;