Lines Matching refs:efx
33 efx_mcdi_get_phy_cfg(struct efx_nic *efx, struct efx_mcdi_phy_data *cfg) in efx_mcdi_get_phy_cfg() argument
42 rc = efx_mcdi_rpc(efx, MC_CMD_GET_PHY_CFG, NULL, 0, in efx_mcdi_get_phy_cfg()
69 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_mcdi_get_phy_cfg()
73 static int efx_mcdi_set_link(struct efx_nic *efx, u32 capabilities, in efx_mcdi_set_link() argument
87 rc = efx_mcdi_rpc(efx, MC_CMD_SET_LINK, inbuf, sizeof(inbuf), in efx_mcdi_set_link()
92 static int efx_mcdi_loopback_modes(struct efx_nic *efx, u64 *loopback_modes) in efx_mcdi_loopback_modes() argument
98 rc = efx_mcdi_rpc(efx, MC_CMD_GET_LOOPBACK_MODES, NULL, 0, in efx_mcdi_loopback_modes()
114 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_mcdi_loopback_modes()
121 struct efx_nic *efx = netdev_priv(net_dev); in efx_mcdi_mdio_read() local
127 MCDI_SET_DWORD(inbuf, MDIO_READ_IN_BUS, efx->mdio_bus); in efx_mcdi_mdio_read()
132 rc = efx_mcdi_rpc(efx, MC_CMD_MDIO_READ, inbuf, sizeof(inbuf), in efx_mcdi_mdio_read()
147 struct efx_nic *efx = netdev_priv(net_dev); in efx_mcdi_mdio_write() local
153 MCDI_SET_DWORD(inbuf, MDIO_WRITE_IN_BUS, efx->mdio_bus); in efx_mcdi_mdio_write()
159 rc = efx_mcdi_rpc(efx, MC_CMD_MDIO_WRITE, inbuf, sizeof(inbuf), in efx_mcdi_mdio_write()
276 static u32 efx_get_mcdi_phy_flags(struct efx_nic *efx) in efx_get_mcdi_phy_flags() argument
278 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_get_mcdi_phy_flags()
291 mode = efx->phy_mode & supported; in efx_get_mcdi_phy_flags()
325 static void efx_mcdi_phy_decode_link(struct efx_nic *efx, in efx_mcdi_phy_decode_link() argument
411 static int efx_mcdi_phy_probe(struct efx_nic *efx) in efx_mcdi_phy_probe() argument
423 rc = efx_mcdi_get_phy_cfg(efx, phy_data); in efx_mcdi_phy_probe()
429 rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0, in efx_mcdi_phy_probe()
435 efx->phy_data = phy_data; in efx_mcdi_phy_probe()
436 efx->phy_type = phy_data->type; in efx_mcdi_phy_probe()
438 efx->mdio_bus = phy_data->channel; in efx_mcdi_phy_probe()
439 efx->mdio.prtad = phy_data->port; in efx_mcdi_phy_probe()
440 efx->mdio.mmds = phy_data->mmd_mask & ~(1 << MC_CMD_MMD_CLAUSE22); in efx_mcdi_phy_probe()
441 efx->mdio.mode_support = 0; in efx_mcdi_phy_probe()
443 efx->mdio.mode_support |= MDIO_SUPPORTS_C22; in efx_mcdi_phy_probe()
445 efx->mdio.mode_support |= MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22; in efx_mcdi_phy_probe()
450 efx->link_advertising); in efx_mcdi_phy_probe()
483 rc = efx_mcdi_loopback_modes(efx, &efx->loopback_modes); in efx_mcdi_phy_probe()
488 efx->loopback_modes &= ~(1 << LOOPBACK_NONE); in efx_mcdi_phy_probe()
492 efx, &efx->link_state, in efx_mcdi_phy_probe()
500 efx->fec_config = mcdi_fec_caps_to_ethtool(caps, in efx_mcdi_phy_probe()
501 efx->link_state.speed == 25000 || in efx_mcdi_phy_probe()
502 efx->link_state.speed == 50000); in efx_mcdi_phy_probe()
505 efx->wanted_fc = EFX_FC_RX | EFX_FC_TX; in efx_mcdi_phy_probe()
507 efx->wanted_fc |= EFX_FC_AUTO; in efx_mcdi_phy_probe()
508 efx_link_set_wanted_fc(efx, efx->wanted_fc); in efx_mcdi_phy_probe()
517 int efx_mcdi_port_reconfigure(struct efx_nic *efx) in efx_mcdi_port_reconfigure() argument
519 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_port_reconfigure()
520 u32 caps = (efx->link_advertising[0] ? in efx_mcdi_port_reconfigure()
521 ethtool_linkset_to_mcdi_cap(efx->link_advertising) : in efx_mcdi_port_reconfigure()
524 caps |= ethtool_fec_caps_to_mcdi(efx->fec_config); in efx_mcdi_port_reconfigure()
526 return efx_mcdi_set_link(efx, caps, efx_get_mcdi_phy_flags(efx), in efx_mcdi_port_reconfigure()
527 efx->loopback_mode, 0); in efx_mcdi_port_reconfigure()
533 static void efx_mcdi_phy_check_fcntl(struct efx_nic *efx, u32 lpa) in efx_mcdi_phy_check_fcntl() argument
535 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_check_fcntl()
544 if (efx->wanted_fc & EFX_FC_AUTO) in efx_mcdi_phy_check_fcntl()
553 if ((efx->wanted_fc & EFX_FC_TX) && rmtadv == ADVERTISED_Asym_Pause) in efx_mcdi_phy_check_fcntl()
554 netif_err(efx, link, efx->net_dev, in efx_mcdi_phy_check_fcntl()
558 static bool efx_mcdi_phy_poll(struct efx_nic *efx) in efx_mcdi_phy_poll() argument
560 struct efx_link_state old_state = efx->link_state; in efx_mcdi_phy_poll()
564 WARN_ON(!mutex_is_locked(&efx->mac_lock)); in efx_mcdi_phy_poll()
568 rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0, in efx_mcdi_phy_poll()
571 efx->link_state.up = false; in efx_mcdi_phy_poll()
574 efx, &efx->link_state, in efx_mcdi_phy_poll()
579 return !efx_link_state_equal(&efx->link_state, &old_state); in efx_mcdi_phy_poll()
582 static void efx_mcdi_phy_remove(struct efx_nic *efx) in efx_mcdi_phy_remove() argument
584 struct efx_mcdi_phy_data *phy_data = efx->phy_data; in efx_mcdi_phy_remove()
586 efx->phy_data = NULL; in efx_mcdi_phy_remove()
590 static void efx_mcdi_phy_get_link_ksettings(struct efx_nic *efx, in efx_mcdi_phy_get_link_ksettings() argument
593 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_get_link_ksettings()
597 cmd->base.speed = efx->link_state.speed; in efx_mcdi_phy_get_link_ksettings()
598 cmd->base.duplex = efx->link_state.fd; in efx_mcdi_phy_get_link_ksettings()
601 cmd->base.autoneg = !!(efx->link_advertising[0] & ADVERTISED_Autoneg); in efx_mcdi_phy_get_link_ksettings()
602 cmd->base.mdio_support = (efx->mdio.mode_support & in efx_mcdi_phy_get_link_ksettings()
607 memcpy(cmd->link_modes.advertising, efx->link_advertising, in efx_mcdi_phy_get_link_ksettings()
611 rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0, in efx_mcdi_phy_get_link_ksettings()
621 efx_mcdi_phy_set_link_ksettings(struct efx_nic *efx, in efx_mcdi_phy_set_link_ksettings() argument
624 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_set_link_ksettings()
652 caps |= ethtool_fec_caps_to_mcdi(efx->fec_config); in efx_mcdi_phy_set_link_ksettings()
654 rc = efx_mcdi_set_link(efx, caps, efx_get_mcdi_phy_flags(efx), in efx_mcdi_phy_set_link_ksettings()
655 efx->loopback_mode, 0); in efx_mcdi_phy_set_link_ksettings()
660 efx_link_set_advertising(efx, cmd->link_modes.advertising); in efx_mcdi_phy_set_link_ksettings()
663 efx_link_clear_advertising(efx); in efx_mcdi_phy_set_link_ksettings()
669 static int efx_mcdi_phy_get_fecparam(struct efx_nic *efx, in efx_mcdi_phy_get_fecparam() argument
679 rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0, in efx_mcdi_phy_get_fecparam()
708 netif_warn(efx, hw, efx->net_dev, in efx_mcdi_phy_get_fecparam()
721 static int efx_mcdi_phy_set_fecparam(struct efx_nic *efx, in efx_mcdi_phy_set_fecparam() argument
724 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_set_fecparam()
731 if (test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, efx->link_advertising)) in efx_mcdi_phy_set_fecparam()
732 caps = (ethtool_linkset_to_mcdi_cap(efx->link_advertising) | in efx_mcdi_phy_set_fecparam()
738 rc = efx_mcdi_set_link(efx, caps, efx_get_mcdi_phy_flags(efx), in efx_mcdi_phy_set_fecparam()
739 efx->loopback_mode, 0); in efx_mcdi_phy_set_fecparam()
744 efx->fec_config = fec->fec; in efx_mcdi_phy_set_fecparam()
748 static int efx_mcdi_phy_test_alive(struct efx_nic *efx) in efx_mcdi_phy_test_alive() argument
756 rc = efx_mcdi_rpc(efx, MC_CMD_GET_PHY_STATE, NULL, 0, in efx_mcdi_phy_test_alive()
780 static int efx_mcdi_bist(struct efx_nic *efx, unsigned int bist_mode, in efx_mcdi_bist() argument
793 rc = efx_mcdi_rpc(efx, MC_CMD_START_BIST, in efx_mcdi_bist()
801 rc = efx_mcdi_rpc(efx, MC_CMD_POLL_BIST, NULL, 0, in efx_mcdi_bist()
820 if (efx->phy_type == PHY_TYPE_SFT9001B && in efx_mcdi_bist()
840 static int efx_mcdi_phy_run_tests(struct efx_nic *efx, int *results, in efx_mcdi_phy_run_tests() argument
843 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_run_tests()
848 rc = efx_mcdi_bist(efx, MC_CMD_PHY_BIST, results); in efx_mcdi_phy_run_tests()
870 rc = efx_mcdi_bist(efx, mode, results); in efx_mcdi_phy_run_tests()
879 static const char *efx_mcdi_phy_test_name(struct efx_nic *efx, in efx_mcdi_phy_test_name() argument
882 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_test_name()
896 if (efx->phy_type == PHY_TYPE_SFT9001B) { in efx_mcdi_phy_test_name()
925 static int efx_mcdi_phy_get_module_eeprom_page(struct efx_nic *efx, in efx_mcdi_phy_get_module_eeprom_page() argument
943 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_GET_PHY_MEDIA_INFO, in efx_mcdi_phy_get_module_eeprom_page()
965 static int efx_mcdi_phy_get_module_eeprom_byte(struct efx_nic *efx, in efx_mcdi_phy_get_module_eeprom_byte() argument
972 rc = efx_mcdi_phy_get_module_eeprom_page(efx, page, &data, byte, 1); in efx_mcdi_phy_get_module_eeprom_byte()
979 static int efx_mcdi_phy_diag_type(struct efx_nic *efx) in efx_mcdi_phy_diag_type() argument
982 return efx_mcdi_phy_get_module_eeprom_byte(efx, 0, in efx_mcdi_phy_diag_type()
986 static int efx_mcdi_phy_sff_8472_level(struct efx_nic *efx) in efx_mcdi_phy_sff_8472_level() argument
989 return efx_mcdi_phy_get_module_eeprom_byte(efx, 0, in efx_mcdi_phy_sff_8472_level()
993 static u32 efx_mcdi_phy_module_type(struct efx_nic *efx) in efx_mcdi_phy_module_type() argument
995 struct efx_mcdi_phy_data *phy_data = efx->phy_data; in efx_mcdi_phy_module_type()
1003 switch (efx_mcdi_phy_get_module_eeprom_byte(efx, 0, 0)) { in efx_mcdi_phy_module_type()
1014 static int efx_mcdi_phy_get_module_eeprom(struct efx_nic *efx, in efx_mcdi_phy_get_module_eeprom() argument
1024 switch (efx_mcdi_phy_module_type(efx)) { in efx_mcdi_phy_get_module_eeprom()
1026 num_pages = efx_mcdi_phy_sff_8472_level(efx) > 0 ? in efx_mcdi_phy_get_module_eeprom()
1044 rc = efx_mcdi_phy_get_module_eeprom_page(efx, page, in efx_mcdi_phy_get_module_eeprom()
1076 static int efx_mcdi_phy_get_module_info(struct efx_nic *efx, in efx_mcdi_phy_get_module_info() argument
1082 switch (efx_mcdi_phy_module_type(efx)) { in efx_mcdi_phy_get_module_info()
1084 sff_8472_level = efx_mcdi_phy_sff_8472_level(efx); in efx_mcdi_phy_get_module_info()
1093 diag_type = efx_mcdi_phy_diag_type(efx); in efx_mcdi_phy_get_module_info()
1135 u32 efx_mcdi_phy_get_caps(struct efx_nic *efx) in efx_mcdi_phy_get_caps() argument
1137 struct efx_mcdi_phy_data *phy_data = efx->phy_data; in efx_mcdi_phy_get_caps()
1152 void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev) in efx_mcdi_process_link_change() argument
1168 efx_mcdi_phy_decode_link(efx, &efx->link_state, speed, flags, fcntl); in efx_mcdi_process_link_change()
1170 efx_mcdi_phy_check_fcntl(efx, lpa); in efx_mcdi_process_link_change()
1172 efx_link_status_changed(efx); in efx_mcdi_process_link_change()
1175 int efx_mcdi_set_mac(struct efx_nic *efx) in efx_mcdi_set_mac() argument
1184 efx->net_dev->dev_addr); in efx_mcdi_set_mac()
1187 EFX_MAX_FRAME_LEN(efx->net_dev->mtu)); in efx_mcdi_set_mac()
1192 SET_MAC_IN_REJECT_UNCST, efx->unicast_filter); in efx_mcdi_set_mac()
1196 !!(efx->net_dev->features & NETIF_F_RXFCS)); in efx_mcdi_set_mac()
1198 switch (efx->wanted_fc) { in efx_mcdi_set_mac()
1209 if (efx->wanted_fc & EFX_FC_AUTO) in efx_mcdi_set_mac()
1211 if (efx->fc_disable) in efx_mcdi_set_mac()
1216 return efx_mcdi_rpc(efx, MC_CMD_SET_MAC, cmdbytes, sizeof(cmdbytes), in efx_mcdi_set_mac()
1220 bool efx_mcdi_mac_check_fault(struct efx_nic *efx) in efx_mcdi_mac_check_fault() argument
1228 rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0, in efx_mcdi_mac_check_fault()
1242 static int efx_mcdi_mac_stats(struct efx_nic *efx, in efx_mcdi_mac_stats() argument
1250 dma_addr_t dma_addr = efx->stats_buffer.dma_addr; in efx_mcdi_mac_stats()
1252 efx->num_mac_stats * sizeof(u64) : 0; in efx_mcdi_mac_stats()
1267 if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0) { in efx_mcdi_mac_stats()
1268 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_mcdi_mac_stats()
1273 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf), in efx_mcdi_mac_stats()
1276 if (rc && (rc != -ENOENT || atomic_read(&efx->active_queues))) in efx_mcdi_mac_stats()
1277 efx_mcdi_display_error(efx, MC_CMD_MAC_STATS, sizeof(inbuf), in efx_mcdi_mac_stats()
1282 void efx_mcdi_mac_start_stats(struct efx_nic *efx) in efx_mcdi_mac_start_stats() argument
1284 __le64 *dma_stats = efx->stats_buffer.addr; in efx_mcdi_mac_start_stats()
1286 dma_stats[efx->num_mac_stats - 1] = EFX_MC_STATS_GENERATION_INVALID; in efx_mcdi_mac_start_stats()
1288 efx_mcdi_mac_stats(efx, EFX_STATS_ENABLE, 0); in efx_mcdi_mac_start_stats()
1291 void efx_mcdi_mac_stop_stats(struct efx_nic *efx) in efx_mcdi_mac_stop_stats() argument
1293 efx_mcdi_mac_stats(efx, EFX_STATS_DISABLE, 0); in efx_mcdi_mac_stop_stats()
1299 void efx_mcdi_mac_pull_stats(struct efx_nic *efx) in efx_mcdi_mac_pull_stats() argument
1301 __le64 *dma_stats = efx->stats_buffer.addr; in efx_mcdi_mac_pull_stats()
1304 dma_stats[efx->num_mac_stats - 1] = EFX_MC_STATS_GENERATION_INVALID; in efx_mcdi_mac_pull_stats()
1305 efx_mcdi_mac_stats(efx, EFX_STATS_PULL, 0); in efx_mcdi_mac_pull_stats()
1307 while (dma_stats[efx->num_mac_stats - 1] == in efx_mcdi_mac_pull_stats()
1313 int efx_mcdi_port_probe(struct efx_nic *efx) in efx_mcdi_port_probe() argument
1318 efx->phy_op = &efx_mcdi_phy_ops; in efx_mcdi_port_probe()
1321 efx->mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22; in efx_mcdi_port_probe()
1322 efx->mdio.mdio_read = efx_mcdi_mdio_read; in efx_mcdi_port_probe()
1323 efx->mdio.mdio_write = efx_mcdi_mdio_write; in efx_mcdi_port_probe()
1326 rc = efx->phy_op->probe(efx); in efx_mcdi_port_probe()
1331 rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer, in efx_mcdi_port_probe()
1332 efx->num_mac_stats * sizeof(u64), GFP_KERNEL); in efx_mcdi_port_probe()
1335 netif_dbg(efx, probe, efx->net_dev, in efx_mcdi_port_probe()
1337 (u64)efx->stats_buffer.dma_addr, in efx_mcdi_port_probe()
1338 efx->stats_buffer.addr, in efx_mcdi_port_probe()
1339 (u64)virt_to_phys(efx->stats_buffer.addr)); in efx_mcdi_port_probe()
1341 efx_mcdi_mac_stats(efx, EFX_STATS_DISABLE, 1); in efx_mcdi_port_probe()
1346 void efx_mcdi_port_remove(struct efx_nic *efx) in efx_mcdi_port_remove() argument
1348 efx->phy_op->remove(efx); in efx_mcdi_port_remove()
1349 efx_nic_free_buffer(efx, &efx->stats_buffer); in efx_mcdi_port_remove()
1353 int efx_mcdi_port_get_number(struct efx_nic *efx) in efx_mcdi_port_get_number() argument
1358 rc = efx_mcdi_rpc(efx, MC_CMD_GET_PORT_ASSIGNMENT, NULL, 0, in efx_mcdi_port_get_number()