Lines Matching +full:enable +full:- +full:lpa

1 // SPDX-License-Identifier: GPL-2.0-only
22 BUILD_BUG_ON(MC_CMD_GET_PHY_CFG_OUT_NAME_LEN != sizeof(cfg->name)); in efx_mcdi_get_phy_cfg()
30 rc = -EIO; in efx_mcdi_get_phy_cfg()
34 cfg->flags = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_FLAGS); in efx_mcdi_get_phy_cfg()
35 cfg->type = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_TYPE); in efx_mcdi_get_phy_cfg()
36 cfg->supported_cap = in efx_mcdi_get_phy_cfg()
38 cfg->channel = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_CHANNEL); in efx_mcdi_get_phy_cfg()
39 cfg->port = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_PRT); in efx_mcdi_get_phy_cfg()
40 cfg->stats_mask = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_STATS_MASK); in efx_mcdi_get_phy_cfg()
41 memcpy(cfg->name, MCDI_PTR(outbuf, GET_PHY_CFG_OUT_NAME), in efx_mcdi_get_phy_cfg()
42 sizeof(cfg->name)); in efx_mcdi_get_phy_cfg()
43 cfg->media = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_MEDIA_TYPE); in efx_mcdi_get_phy_cfg()
44 cfg->mmd_mask = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_MMD_MASK); in efx_mcdi_get_phy_cfg()
45 memcpy(cfg->revision, MCDI_PTR(outbuf, GET_PHY_CFG_OUT_REVISION), in efx_mcdi_get_phy_cfg()
46 sizeof(cfg->revision)); in efx_mcdi_get_phy_cfg()
51 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_mcdi_get_phy_cfg()
58 memcpy(efx->link_advertising, advertising, in efx_link_set_advertising()
61 efx->link_advertising[0] |= ADVERTISED_Autoneg; in efx_link_set_advertising()
63 efx->wanted_fc |= (EFX_FC_TX | EFX_FC_RX); in efx_link_set_advertising()
65 efx->wanted_fc &= ~(EFX_FC_TX | EFX_FC_RX); in efx_link_set_advertising()
67 efx->wanted_fc ^= EFX_FC_TX; in efx_link_set_advertising()
99 rc = -EIO; in efx_mcdi_loopback_modes()
108 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_mcdi_loopback_modes()
234 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_get_mcdi_phy_flags()
240 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_TXDIS_LBN)) in efx_get_mcdi_phy_flags()
242 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_LOWPOWER_LBN)) in efx_get_mcdi_phy_flags()
244 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_POWEROFF_LBN)) in efx_get_mcdi_phy_flags()
247 mode = efx->phy_mode & supported; in efx_get_mcdi_phy_flags()
288 link_state->fc = EFX_FC_AUTO | EFX_FC_TX | EFX_FC_RX; in efx_mcdi_phy_decode_link()
291 link_state->fc = EFX_FC_TX | EFX_FC_RX; in efx_mcdi_phy_decode_link()
294 link_state->fc = EFX_FC_RX; in efx_mcdi_phy_decode_link()
300 link_state->fc = 0; in efx_mcdi_phy_decode_link()
304 link_state->up = !!(flags & (1 << MC_CMD_GET_LINK_OUT_LINK_UP_LBN)); in efx_mcdi_phy_decode_link()
305 link_state->fd = !!(flags & (1 << MC_CMD_GET_LINK_OUT_FULL_DUPLEX_LBN)); in efx_mcdi_phy_decode_link()
306 link_state->speed = speed; in efx_mcdi_phy_decode_link()
316 * fw-default preferences for the cable type.
318 * link partner support it, otherwise autoneg/fw-default.
374 void efx_mcdi_phy_check_fcntl(struct efx_nic *efx, u32 lpa) in efx_mcdi_phy_check_fcntl() argument
376 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_check_fcntl()
382 if (~phy_cfg->supported_cap & (1 << MC_CMD_PHY_CAP_AN_LBN)) in efx_mcdi_phy_check_fcntl()
386 if (efx->wanted_fc & EFX_FC_AUTO) in efx_mcdi_phy_check_fcntl()
390 if (lpa & (1 << MC_CMD_PHY_CAP_PAUSE_LBN)) in efx_mcdi_phy_check_fcntl()
392 if (lpa & (1 << MC_CMD_PHY_CAP_ASYM_LBN)) in efx_mcdi_phy_check_fcntl()
395 if ((efx->wanted_fc & EFX_FC_TX) && rmtadv == ADVERTISED_Asym_Pause) in efx_mcdi_phy_check_fcntl()
396 netif_err(efx, link, efx->net_dev, in efx_mcdi_phy_check_fcntl()
402 struct efx_link_state old_state = efx->link_state; in efx_mcdi_phy_poll()
406 WARN_ON(!mutex_is_locked(&efx->mac_lock)); in efx_mcdi_phy_poll()
413 efx->link_state.up = false; in efx_mcdi_phy_poll()
416 efx, &efx->link_state, in efx_mcdi_phy_poll()
421 return !efx_link_state_equal(&efx->link_state, &old_state); in efx_mcdi_phy_poll()
434 return -ENOMEM; in efx_mcdi_phy_probe()
448 efx->phy_data = phy_data; in efx_mcdi_phy_probe()
449 efx->phy_type = phy_data->type; in efx_mcdi_phy_probe()
451 efx->mdio_bus = phy_data->channel; in efx_mcdi_phy_probe()
452 efx->mdio.prtad = phy_data->port; in efx_mcdi_phy_probe()
453 efx->mdio.mmds = phy_data->mmd_mask & ~(1 << MC_CMD_MMD_CLAUSE22); in efx_mcdi_phy_probe()
454 efx->mdio.mode_support = 0; in efx_mcdi_phy_probe()
455 if (phy_data->mmd_mask & (1 << MC_CMD_MMD_CLAUSE22)) in efx_mcdi_phy_probe()
456 efx->mdio.mode_support |= MDIO_SUPPORTS_C22; in efx_mcdi_phy_probe()
457 if (phy_data->mmd_mask & ~(1 << MC_CMD_MMD_CLAUSE22)) in efx_mcdi_phy_probe()
458 efx->mdio.mode_support |= MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22; in efx_mcdi_phy_probe()
462 mcdi_to_ethtool_linkset(phy_data->media, caps, in efx_mcdi_phy_probe()
463 efx->link_advertising); in efx_mcdi_phy_probe()
465 phy_data->forced_cap = caps; in efx_mcdi_phy_probe()
467 /* Assert that we can map efx -> mcdi loopback modes */ in efx_mcdi_phy_probe()
496 rc = efx_mcdi_loopback_modes(efx, &efx->loopback_modes); in efx_mcdi_phy_probe()
502 efx->loopback_modes &= ~(1 << LOOPBACK_NONE); in efx_mcdi_phy_probe()
505 efx_mcdi_phy_decode_link(efx, &efx->link_state, in efx_mcdi_phy_probe()
513 efx->fec_config = mcdi_fec_caps_to_ethtool(caps, in efx_mcdi_phy_probe()
514 efx->link_state.speed == 25000 || in efx_mcdi_phy_probe()
515 efx->link_state.speed == 50000); in efx_mcdi_phy_probe()
518 efx->wanted_fc = EFX_FC_RX | EFX_FC_TX; in efx_mcdi_phy_probe()
519 if (phy_data->supported_cap & (1 << MC_CMD_PHY_CAP_AN_LBN)) in efx_mcdi_phy_probe()
520 efx->wanted_fc |= EFX_FC_AUTO; in efx_mcdi_phy_probe()
521 efx_link_set_wanted_fc(efx, efx->wanted_fc); in efx_mcdi_phy_probe()
532 struct efx_mcdi_phy_data *phy_data = efx->phy_data; in efx_mcdi_phy_remove()
534 efx->phy_data = NULL; in efx_mcdi_phy_remove()
540 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_get_link_ksettings()
544 cmd->base.speed = efx->link_state.speed; in efx_mcdi_phy_get_link_ksettings()
545 cmd->base.duplex = efx->link_state.fd; in efx_mcdi_phy_get_link_ksettings()
546 cmd->base.port = mcdi_to_ethtool_media(phy_cfg->media); in efx_mcdi_phy_get_link_ksettings()
547 cmd->base.phy_address = phy_cfg->port; in efx_mcdi_phy_get_link_ksettings()
548 cmd->base.autoneg = !!(efx->link_advertising[0] & ADVERTISED_Autoneg); in efx_mcdi_phy_get_link_ksettings()
549 cmd->base.mdio_support = (efx->mdio.mode_support & in efx_mcdi_phy_get_link_ksettings()
552 mcdi_to_ethtool_linkset(phy_cfg->media, phy_cfg->supported_cap, in efx_mcdi_phy_get_link_ksettings()
553 cmd->link_modes.supported); in efx_mcdi_phy_get_link_ksettings()
554 memcpy(cmd->link_modes.advertising, efx->link_advertising, in efx_mcdi_phy_get_link_ksettings()
562 mcdi_to_ethtool_linkset(phy_cfg->media, in efx_mcdi_phy_get_link_ksettings()
564 cmd->link_modes.lp_advertising); in efx_mcdi_phy_get_link_ksettings()
569 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_set_link_ksettings()
573 if (cmd->base.autoneg) { in efx_mcdi_phy_set_link_ksettings()
574 caps = (ethtool_linkset_to_mcdi_cap(cmd->link_modes.advertising) | in efx_mcdi_phy_set_link_ksettings()
576 } else if (cmd->base.duplex) { in efx_mcdi_phy_set_link_ksettings()
577 switch (cmd->base.speed) { in efx_mcdi_phy_set_link_ksettings()
586 default: return -EINVAL; in efx_mcdi_phy_set_link_ksettings()
589 switch (cmd->base.speed) { in efx_mcdi_phy_set_link_ksettings()
593 default: return -EINVAL; in efx_mcdi_phy_set_link_ksettings()
597 caps |= ethtool_fec_caps_to_mcdi(phy_cfg->supported_cap, efx->fec_config); in efx_mcdi_phy_set_link_ksettings()
600 efx->loopback_mode, 0); in efx_mcdi_phy_set_link_ksettings()
604 if (cmd->base.autoneg) { in efx_mcdi_phy_set_link_ksettings()
605 efx_link_set_advertising(efx, cmd->link_modes.advertising); in efx_mcdi_phy_set_link_ksettings()
606 phy_cfg->forced_cap = 0; in efx_mcdi_phy_set_link_ksettings()
609 phy_cfg->forced_cap = caps; in efx_mcdi_phy_set_link_ksettings()
628 return -EOPNOTSUPP; in efx_mcdi_phy_get_fecparam()
635 fec->fec = mcdi_fec_caps_to_ethtool(caps, is_25g); in efx_mcdi_phy_get_fecparam()
638 fec->fec &= ~ETHTOOL_FEC_BASER; in efx_mcdi_phy_get_fecparam()
643 fec->active_fec = ETHTOOL_FEC_OFF; in efx_mcdi_phy_get_fecparam()
646 fec->active_fec = ETHTOOL_FEC_BASER; in efx_mcdi_phy_get_fecparam()
649 fec->active_fec = ETHTOOL_FEC_RS; in efx_mcdi_phy_get_fecparam()
652 netif_warn(efx, hw, efx->net_dev, in efx_mcdi_phy_get_fecparam()
658 fec->active_fec = ETHTOOL_FEC_AUTO; in efx_mcdi_phy_get_fecparam()
675 return -EINVAL; in ethtool_fec_supported()
681 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_set_fecparam()
685 rc = ethtool_fec_supported(phy_cfg->supported_cap, fec->fec); in efx_mcdi_phy_set_fecparam()
692 if (test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, efx->link_advertising)) in efx_mcdi_phy_set_fecparam()
693 caps = (ethtool_linkset_to_mcdi_cap(efx->link_advertising) | in efx_mcdi_phy_set_fecparam()
696 caps = phy_cfg->forced_cap; in efx_mcdi_phy_set_fecparam()
698 caps |= ethtool_fec_caps_to_mcdi(phy_cfg->supported_cap, fec->fec); in efx_mcdi_phy_set_fecparam()
700 efx->loopback_mode, 0); in efx_mcdi_phy_set_fecparam()
705 efx->fec_config = fec->fec; in efx_mcdi_phy_set_fecparam()
723 return -EIO; in efx_mcdi_phy_test_alive()
725 return -EINVAL; in efx_mcdi_phy_test_alive()
732 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_port_reconfigure()
733 u32 caps = (efx->link_advertising[0] ? in efx_mcdi_port_reconfigure()
734 ethtool_linkset_to_mcdi_cap(efx->link_advertising) : in efx_mcdi_port_reconfigure()
735 phy_cfg->forced_cap); in efx_mcdi_port_reconfigure()
737 caps |= ethtool_fec_caps_to_mcdi(phy_cfg->supported_cap, efx->fec_config); in efx_mcdi_port_reconfigure()
740 efx->loopback_mode, 0); in efx_mcdi_port_reconfigure()
787 rc = -ETIMEDOUT; in efx_mcdi_bist()
791 results[count++] = (status == MC_CMD_POLL_BIST_PASSED) ? 1 : -1; in efx_mcdi_bist()
794 if (efx->phy_type == PHY_TYPE_SFT9001B && in efx_mcdi_bist()
816 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_run_tests()
820 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_LBN)) { in efx_mcdi_phy_run_tests()
832 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_SHORT_LBN)) { in efx_mcdi_phy_run_tests()
834 (phy_cfg->flags & in efx_mcdi_phy_run_tests()
839 } else if (phy_cfg->flags & in efx_mcdi_phy_run_tests()
855 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; in efx_mcdi_phy_test_name()
857 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_LBN)) { in efx_mcdi_phy_test_name()
860 --index; in efx_mcdi_phy_test_name()
863 if (phy_cfg->flags & ((1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_SHORT_LBN) | in efx_mcdi_phy_test_name()
867 --index; in efx_mcdi_phy_test_name()
869 if (efx->phy_type == PHY_TYPE_SFT9001B) { in efx_mcdi_phy_test_name()
872 index -= ARRAY_SIZE(mcdi_sft9001_cable_diag_names); in efx_mcdi_phy_test_name()
887 /** efx_mcdi_phy_get_module_eeprom_page() - Get a single page of module eeprom
895 * >=0 - amount of data copied
896 * <0 - error
911 return -EINVAL; in efx_mcdi_phy_get_module_eeprom_page()
913 to_copy = min(space, SFP_PAGE_SIZE - offset); in efx_mcdi_phy_get_module_eeprom_page()
926 return -EIO; in efx_mcdi_phy_get_module_eeprom_page()
930 return -EIO; in efx_mcdi_phy_get_module_eeprom_page()
968 struct efx_mcdi_phy_data *phy_data = efx->phy_data; in efx_mcdi_phy_module_type()
970 if (phy_data->media != MC_CMD_MEDIA_QSFP_PLUS) in efx_mcdi_phy_module_type()
971 return phy_data->media; in efx_mcdi_phy_module_type()
993 ssize_t space_remaining = ee->len; in efx_mcdi_phy_get_module_eeprom()
1008 page = -1; /* We obtain the lower page by asking for -1. */ in efx_mcdi_phy_get_module_eeprom()
1012 return -EOPNOTSUPP; in efx_mcdi_phy_get_module_eeprom()
1015 page_off = ee->offset % SFP_PAGE_SIZE; in efx_mcdi_phy_get_module_eeprom()
1016 page += ee->offset / SFP_PAGE_SIZE; in efx_mcdi_phy_get_module_eeprom()
1024 space_remaining -= rc; in efx_mcdi_phy_get_module_eeprom()
1031 int intended_size = SFP_PAGE_SIZE - page_off; in efx_mcdi_phy_get_module_eeprom()
1033 space_remaining -= intended_size; in efx_mcdi_phy_get_module_eeprom()
1062 return -EOPNOTSUPP; in efx_mcdi_phy_get_module_info()
1071 modinfo->type = ETH_MODULE_SFF_8079; in efx_mcdi_phy_get_module_info()
1072 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; in efx_mcdi_phy_get_module_info()
1074 modinfo->type = ETH_MODULE_SFF_8472; in efx_mcdi_phy_get_module_info()
1075 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; in efx_mcdi_phy_get_module_info()
1080 modinfo->type = ETH_MODULE_SFF_8436; in efx_mcdi_phy_get_module_info()
1081 modinfo->eeprom_len = ETH_MODULE_SFF_8436_MAX_LEN; in efx_mcdi_phy_get_module_info()
1085 return -EOPNOTSUPP; in efx_mcdi_phy_get_module_info()
1093 return EFX_MAX_FRAME_LEN(efx->net_dev->mtu); in efx_calc_mac_mtu()
1105 efx->net_dev->dev_addr); in efx_mcdi_set_mac()
1111 !!(efx->net_dev->features & NETIF_F_RXFCS)); in efx_mcdi_set_mac()
1113 switch (efx->wanted_fc) { in efx_mcdi_set_mac()
1124 if (efx->wanted_fc & EFX_FC_AUTO) in efx_mcdi_set_mac()
1126 if (efx->fc_disable) in efx_mcdi_set_mac()
1162 int enable = action == EFX_STATS_ENABLE ? 1 : 0; in efx_mcdi_mac_stats() local
1164 dma_addr_t dma_addr = efx->stats_buffer.dma_addr; in efx_mcdi_mac_stats()
1166 efx->num_mac_stats * sizeof(u64) : 0; in efx_mcdi_mac_stats()
1172 MAC_STATS_IN_DMA, !!enable, in efx_mcdi_mac_stats()
1175 MAC_STATS_IN_PERIODIC_ENABLE, enable, in efx_mcdi_mac_stats()
1182 MCDI_SET_DWORD(inbuf, MAC_STATS_IN_PORT_ID, efx->vport_id); in efx_mcdi_mac_stats()
1187 if (rc && (rc != -ENOENT || atomic_read(&efx->active_queues))) in efx_mcdi_mac_stats()
1195 __le64 *dma_stats = efx->stats_buffer.addr; in efx_mcdi_mac_start_stats()
1197 dma_stats[efx->num_mac_stats - 1] = EFX_MC_STATS_GENERATION_INVALID; in efx_mcdi_mac_start_stats()
1212 __le64 *dma_stats = efx->stats_buffer.addr; in efx_mcdi_mac_pull_stats()
1215 dma_stats[efx->num_mac_stats - 1] = EFX_MC_STATS_GENERATION_INVALID; in efx_mcdi_mac_pull_stats()
1218 while (dma_stats[efx->num_mac_stats - 1] == in efx_mcdi_mac_pull_stats()
1220 attempts-- != 0) in efx_mcdi_mac_pull_stats()
1228 if (!efx->num_mac_stats) in efx_mcdi_mac_init_stats()
1232 rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer, in efx_mcdi_mac_init_stats()
1233 efx->num_mac_stats * sizeof(u64), GFP_KERNEL); in efx_mcdi_mac_init_stats()
1235 netif_warn(efx, probe, efx->net_dev, in efx_mcdi_mac_init_stats()
1240 netif_dbg(efx, probe, efx->net_dev, in efx_mcdi_mac_init_stats()
1242 (u64) efx->stats_buffer.dma_addr, in efx_mcdi_mac_init_stats()
1243 efx->stats_buffer.addr, in efx_mcdi_mac_init_stats()
1244 (u64) virt_to_phys(efx->stats_buffer.addr)); in efx_mcdi_mac_init_stats()
1251 efx_nic_free_buffer(efx, &efx->stats_buffer); in efx_mcdi_mac_fini_stats()
1280 u32 flags, fcntl, speed, lpa; in efx_mcdi_process_link_change() local
1288 lpa = EFX_QWORD_FIELD(*ev, MCDI_EVENT_LINKCHANGE_LP_CAP); in efx_mcdi_process_link_change()
1290 /* efx->link_state is only modified by efx_mcdi_phy_get_link(), in efx_mcdi_process_link_change()
1294 efx_mcdi_phy_decode_link(efx, &efx->link_state, speed, flags, fcntl); in efx_mcdi_process_link_change()
1296 efx_mcdi_phy_check_fcntl(efx, lpa); in efx_mcdi_process_link_change()