Lines Matching refs:efx
37 efx_mcdi_get_phy_cfg(struct efx_nic *efx, struct efx_mcdi_phy_data *cfg) in efx_mcdi_get_phy_cfg() argument
46 rc = efx_mcdi_rpc(efx, MC_CMD_GET_PHY_CFG, NULL, 0, in efx_mcdi_get_phy_cfg()
73 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_mcdi_get_phy_cfg()
77 static int efx_mcdi_set_link(struct efx_nic *efx, u32 capabilities, in efx_mcdi_set_link() argument
91 rc = efx_mcdi_rpc(efx, MC_CMD_SET_LINK, inbuf, sizeof(inbuf), in efx_mcdi_set_link()
96 static int efx_mcdi_loopback_modes(struct efx_nic *efx, u64 *loopback_modes) in efx_mcdi_loopback_modes() argument
102 rc = efx_mcdi_rpc(efx, MC_CMD_GET_LOOPBACK_MODES, NULL, 0, in efx_mcdi_loopback_modes()
118 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_mcdi_loopback_modes()
125 struct efx_nic *efx = netdev_priv(net_dev); in efx_mcdi_mdio_read() local
131 MCDI_SET_DWORD(inbuf, MDIO_READ_IN_BUS, efx->mdio_bus); in efx_mcdi_mdio_read()
136 rc = efx_mcdi_rpc(efx, MC_CMD_MDIO_READ, inbuf, sizeof(inbuf), in efx_mcdi_mdio_read()
151 struct efx_nic *efx = netdev_priv(net_dev); in efx_mcdi_mdio_write() local
157 MCDI_SET_DWORD(inbuf, MDIO_WRITE_IN_BUS, efx->mdio_bus); in efx_mcdi_mdio_write()
163 rc = efx_mcdi_rpc(efx, MC_CMD_MDIO_WRITE, inbuf, sizeof(inbuf), in efx_mcdi_mdio_write()
260 static u32 efx_get_mcdi_phy_flags(struct efx_nic *efx) in efx_get_mcdi_phy_flags() argument
262 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_get_mcdi_phy_flags()
275 mode = efx->phy_mode & supported; in efx_get_mcdi_phy_flags()
309 static void efx_mcdi_phy_decode_link(struct efx_nic *efx, in efx_mcdi_phy_decode_link() argument
336 static int efx_mcdi_phy_probe(struct efx_nic *efx) in efx_mcdi_phy_probe() argument
348 rc = efx_mcdi_get_phy_cfg(efx, phy_data); in efx_mcdi_phy_probe()
354 rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0, in efx_mcdi_phy_probe()
360 efx->phy_data = phy_data; in efx_mcdi_phy_probe()
361 efx->phy_type = phy_data->type; in efx_mcdi_phy_probe()
363 efx->mdio_bus = phy_data->channel; in efx_mcdi_phy_probe()
364 efx->mdio.prtad = phy_data->port; in efx_mcdi_phy_probe()
365 efx->mdio.mmds = phy_data->mmd_mask & ~(1 << MC_CMD_MMD_CLAUSE22); in efx_mcdi_phy_probe()
366 efx->mdio.mode_support = 0; in efx_mcdi_phy_probe()
368 efx->mdio.mode_support |= MDIO_SUPPORTS_C22; in efx_mcdi_phy_probe()
370 efx->mdio.mode_support |= MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22; in efx_mcdi_phy_probe()
374 efx->link_advertising = in efx_mcdi_phy_probe()
408 rc = efx_mcdi_loopback_modes(efx, &efx->loopback_modes); in efx_mcdi_phy_probe()
413 efx->loopback_modes &= ~(1 << LOOPBACK_NONE); in efx_mcdi_phy_probe()
417 efx, &efx->link_state, in efx_mcdi_phy_probe()
423 efx->wanted_fc = EFX_FC_RX | EFX_FC_TX; in efx_mcdi_phy_probe()
425 efx->wanted_fc |= EFX_FC_AUTO; in efx_mcdi_phy_probe()
426 efx_link_set_wanted_fc(efx, efx->wanted_fc); in efx_mcdi_phy_probe()
435 int efx_mcdi_port_reconfigure(struct efx_nic *efx) in efx_mcdi_port_reconfigure() argument
437 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_port_reconfigure()
438 u32 caps = (efx->link_advertising ? in efx_mcdi_port_reconfigure()
439 ethtool_to_mcdi_cap(efx->link_advertising) : in efx_mcdi_port_reconfigure()
442 return efx_mcdi_set_link(efx, caps, efx_get_mcdi_phy_flags(efx), in efx_mcdi_port_reconfigure()
443 efx->loopback_mode, 0); in efx_mcdi_port_reconfigure()
449 static void efx_mcdi_phy_check_fcntl(struct efx_nic *efx, u32 lpa) in efx_mcdi_phy_check_fcntl() argument
451 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_check_fcntl()
460 if (efx->wanted_fc & EFX_FC_AUTO) in efx_mcdi_phy_check_fcntl()
469 if ((efx->wanted_fc & EFX_FC_TX) && rmtadv == ADVERTISED_Asym_Pause) in efx_mcdi_phy_check_fcntl()
470 netif_err(efx, link, efx->net_dev, in efx_mcdi_phy_check_fcntl()
474 static bool efx_mcdi_phy_poll(struct efx_nic *efx) in efx_mcdi_phy_poll() argument
476 struct efx_link_state old_state = efx->link_state; in efx_mcdi_phy_poll()
480 WARN_ON(!mutex_is_locked(&efx->mac_lock)); in efx_mcdi_phy_poll()
484 rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0, in efx_mcdi_phy_poll()
487 efx->link_state.up = false; in efx_mcdi_phy_poll()
490 efx, &efx->link_state, in efx_mcdi_phy_poll()
495 return !efx_link_state_equal(&efx->link_state, &old_state); in efx_mcdi_phy_poll()
498 static void efx_mcdi_phy_remove(struct efx_nic *efx) in efx_mcdi_phy_remove() argument
500 struct efx_mcdi_phy_data *phy_data = efx->phy_data; in efx_mcdi_phy_remove()
502 efx->phy_data = NULL; in efx_mcdi_phy_remove()
506 static void efx_mcdi_phy_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd) in efx_mcdi_phy_get_settings() argument
508 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_get_settings()
514 ecmd->advertising = efx->link_advertising; in efx_mcdi_phy_get_settings()
515 ethtool_cmd_speed_set(ecmd, efx->link_state.speed); in efx_mcdi_phy_get_settings()
516 ecmd->duplex = efx->link_state.fd; in efx_mcdi_phy_get_settings()
520 ecmd->autoneg = !!(efx->link_advertising & ADVERTISED_Autoneg); in efx_mcdi_phy_get_settings()
521 ecmd->mdio_support = (efx->mdio.mode_support & in efx_mcdi_phy_get_settings()
525 rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0, in efx_mcdi_phy_get_settings()
534 static int efx_mcdi_phy_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd) in efx_mcdi_phy_set_settings() argument
536 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_set_settings()
561 rc = efx_mcdi_set_link(efx, caps, efx_get_mcdi_phy_flags(efx), in efx_mcdi_phy_set_settings()
562 efx->loopback_mode, 0); in efx_mcdi_phy_set_settings()
568 efx, ecmd->advertising | ADVERTISED_Autoneg); in efx_mcdi_phy_set_settings()
571 efx_link_set_advertising(efx, 0); in efx_mcdi_phy_set_settings()
577 static int efx_mcdi_phy_test_alive(struct efx_nic *efx) in efx_mcdi_phy_test_alive() argument
585 rc = efx_mcdi_rpc(efx, MC_CMD_GET_PHY_STATE, NULL, 0, in efx_mcdi_phy_test_alive()
609 static int efx_mcdi_bist(struct efx_nic *efx, unsigned int bist_mode, in efx_mcdi_bist() argument
622 rc = efx_mcdi_rpc(efx, MC_CMD_START_BIST, in efx_mcdi_bist()
630 rc = efx_mcdi_rpc(efx, MC_CMD_POLL_BIST, NULL, 0, in efx_mcdi_bist()
649 if (efx->phy_type == PHY_TYPE_SFT9001B && in efx_mcdi_bist()
669 static int efx_mcdi_phy_run_tests(struct efx_nic *efx, int *results, in efx_mcdi_phy_run_tests() argument
672 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_run_tests()
677 rc = efx_mcdi_bist(efx, MC_CMD_PHY_BIST, results); in efx_mcdi_phy_run_tests()
699 rc = efx_mcdi_bist(efx, mode, results); in efx_mcdi_phy_run_tests()
708 static const char *efx_mcdi_phy_test_name(struct efx_nic *efx, in efx_mcdi_phy_test_name() argument
711 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_test_name()
725 if (efx->phy_type == PHY_TYPE_SFT9001B) { in efx_mcdi_phy_test_name()
737 static int efx_mcdi_phy_get_module_eeprom(struct efx_nic *efx, in efx_mcdi_phy_get_module_eeprom() argument
759 rc = efx_mcdi_rpc(efx, MC_CMD_GET_PHY_MEDIA_INFO, in efx_mcdi_phy_get_module_eeprom()
793 static int efx_mcdi_phy_get_module_info(struct efx_nic *efx, in efx_mcdi_phy_get_module_info() argument
796 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_get_module_info()
824 u32 efx_mcdi_phy_get_caps(struct efx_nic *efx) in efx_mcdi_phy_get_caps() argument
826 struct efx_mcdi_phy_data *phy_data = efx->phy_data; in efx_mcdi_phy_get_caps()
838 void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev) in efx_mcdi_process_link_change() argument
854 efx_mcdi_phy_decode_link(efx, &efx->link_state, speed, flags, fcntl); in efx_mcdi_process_link_change()
856 efx_mcdi_phy_check_fcntl(efx, lpa); in efx_mcdi_process_link_change()
858 efx_link_status_changed(efx); in efx_mcdi_process_link_change()
861 int efx_mcdi_set_mac(struct efx_nic *efx) in efx_mcdi_set_mac() argument
870 efx->net_dev->dev_addr); in efx_mcdi_set_mac()
873 EFX_MAX_FRAME_LEN(efx->net_dev->mtu)); in efx_mcdi_set_mac()
878 SET_MAC_IN_REJECT_UNCST, efx->unicast_filter); in efx_mcdi_set_mac()
880 switch (efx->wanted_fc) { in efx_mcdi_set_mac()
891 if (efx->wanted_fc & EFX_FC_AUTO) in efx_mcdi_set_mac()
893 if (efx->fc_disable) in efx_mcdi_set_mac()
898 return efx_mcdi_rpc(efx, MC_CMD_SET_MAC, cmdbytes, sizeof(cmdbytes), in efx_mcdi_set_mac()
902 bool efx_mcdi_mac_check_fault(struct efx_nic *efx) in efx_mcdi_mac_check_fault() argument
910 rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0, in efx_mcdi_mac_check_fault()
924 static int efx_mcdi_mac_stats(struct efx_nic *efx, in efx_mcdi_mac_stats() argument
927 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_mcdi_mac_stats()
933 dma_addr_t dma_addr = efx->stats_buffer.dma_addr; in efx_mcdi_mac_stats()
951 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf), in efx_mcdi_mac_stats()
954 if (rc && (rc != -ENOENT || atomic_read(&efx->active_queues))) in efx_mcdi_mac_stats()
955 efx_mcdi_display_error(efx, MC_CMD_MAC_STATS, sizeof(inbuf), in efx_mcdi_mac_stats()
960 void efx_mcdi_mac_start_stats(struct efx_nic *efx) in efx_mcdi_mac_start_stats() argument
962 __le64 *dma_stats = efx->stats_buffer.addr; in efx_mcdi_mac_start_stats()
966 efx_mcdi_mac_stats(efx, EFX_STATS_ENABLE, 0); in efx_mcdi_mac_start_stats()
969 void efx_mcdi_mac_stop_stats(struct efx_nic *efx) in efx_mcdi_mac_stop_stats() argument
971 efx_mcdi_mac_stats(efx, EFX_STATS_DISABLE, 0); in efx_mcdi_mac_stop_stats()
977 void efx_mcdi_mac_pull_stats(struct efx_nic *efx) in efx_mcdi_mac_pull_stats() argument
979 __le64 *dma_stats = efx->stats_buffer.addr; in efx_mcdi_mac_pull_stats()
983 efx_mcdi_mac_stats(efx, EFX_STATS_PULL, 0); in efx_mcdi_mac_pull_stats()
991 int efx_mcdi_port_probe(struct efx_nic *efx) in efx_mcdi_port_probe() argument
996 efx->phy_op = &efx_mcdi_phy_ops; in efx_mcdi_port_probe()
999 efx->mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22; in efx_mcdi_port_probe()
1000 efx->mdio.mdio_read = efx_mcdi_mdio_read; in efx_mcdi_port_probe()
1001 efx->mdio.mdio_write = efx_mcdi_mdio_write; in efx_mcdi_port_probe()
1004 rc = efx->phy_op->probe(efx); in efx_mcdi_port_probe()
1009 rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer, in efx_mcdi_port_probe()
1013 netif_dbg(efx, probe, efx->net_dev, in efx_mcdi_port_probe()
1015 (u64)efx->stats_buffer.dma_addr, in efx_mcdi_port_probe()
1016 efx->stats_buffer.addr, in efx_mcdi_port_probe()
1017 (u64)virt_to_phys(efx->stats_buffer.addr)); in efx_mcdi_port_probe()
1019 efx_mcdi_mac_stats(efx, EFX_STATS_DISABLE, 1); in efx_mcdi_port_probe()
1024 void efx_mcdi_port_remove(struct efx_nic *efx) in efx_mcdi_port_remove() argument
1026 efx->phy_op->remove(efx); in efx_mcdi_port_remove()
1027 efx_nic_free_buffer(efx, &efx->stats_buffer); in efx_mcdi_port_remove()
1031 int efx_mcdi_port_get_number(struct efx_nic *efx) in efx_mcdi_port_get_number() argument
1036 rc = efx_mcdi_rpc(efx, MC_CMD_GET_PORT_ASSIGNMENT, NULL, 0, in efx_mcdi_port_get_number()