From: Alexander Duyck With this change we are effectively adding a stub PHY driver for the fbnic driver to enable it to report link state of the PMA/PMD separately from the PCS. This is needed as the firmware will be performing link training when the link is first detected and this will in turn cause the PCS to link flap if we don't add a delay to the PMD link up process to allow for this. With this change we are able to identify the device based on the PMA/PMD and PCS pair being used. The logic is mostly in place to just handle the link detection and report the correct speed for the link. This patch is using the gen10g_config_aneg stub to skip doing any configuration for now. Eventually this will likely be replaced as we actually start adding configuration bits to the driver. Signed-off-by: Alexander Duyck --- MAINTAINERS | 1 + drivers/net/phy/Kconfig | 6 +++++ drivers/net/phy/Makefile | 1 + drivers/net/phy/fbnic_phy.c | 52 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 drivers/net/phy/fbnic_phy.c diff --git a/MAINTAINERS b/MAINTAINERS index 1ab7e8746299..ce18b92f3157 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16712,6 +16712,7 @@ R: kernel-team@meta.com S: Maintained F: Documentation/networking/device_drivers/ethernet/meta/ F: drivers/net/ethernet/meta/ +F: drivers/net/phy/fbnic_phy.c METHODE UDPU SUPPORT M: Robert Marko diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 98700d069191..16d943bbb883 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -230,6 +230,12 @@ config DAVICOM_PHY help Currently supports dm9161e and dm9131 +config FBNIC_PHY + tristate "FBNIC PHY" + help + Supports the Meta Platforms 25G/50G/100G Ethernet PHY included in + fbnic network driver. + config ICPLUS_PHY tristate "ICPlus PHYs" help diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index 76e0db40f879..29b47d9d0425 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -59,6 +59,7 @@ obj-$(CONFIG_DP83869_PHY) += dp83869.o obj-$(CONFIG_DP83TC811_PHY) += dp83tc811.o obj-$(CONFIG_DP83TD510_PHY) += dp83td510.o obj-$(CONFIG_DP83TG720_PHY) += dp83tg720.o +obj-$(CONFIG_FBNIC_PHY) += fbnic_phy.o obj-$(CONFIG_FIXED_PHY) += fixed_phy.o obj-$(CONFIG_ICPLUS_PHY) += icplus.o obj-$(CONFIG_INTEL_XWAY_PHY) += intel-xway.o diff --git a/drivers/net/phy/fbnic_phy.c b/drivers/net/phy/fbnic_phy.c new file mode 100644 index 000000000000..5b9be27aec32 --- /dev/null +++ b/drivers/net/phy/fbnic_phy.c @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) Meta Platforms, Inc. and affiliates. */ + +#include +#include +#include +#include +#include +#include + +MODULE_DESCRIPTION("Meta Platforms FBNIC PHY driver"); +MODULE_LICENSE("GPL"); + +static int fbnic_phy_match_phy_device(struct phy_device *phydev, + const struct phy_driver *phydrv) +{ + u32 *device_ids = phydev->c45_ids.device_ids; + + return device_ids[MDIO_MMD_PMAPMD] == MP_FBNIC_XPCS_PMA_100G_ID && + device_ids[MDIO_MMD_PCS] == DW_XPCS_ID; +} + +static int fbnic_phy_get_features(struct phy_device *phydev) +{ + phylink_set(phydev->supported, 100000baseCR2_Full); + phylink_set(phydev->supported, 50000baseCR_Full); + phylink_set(phydev->supported, 50000baseCR2_Full); + phylink_set(phydev->supported, 25000baseCR_Full); + + return 0; +} + +static struct phy_driver fbnic_phy_driver[] = { +{ + .phy_id = MP_FBNIC_XPCS_PMA_100G_ID, + .phy_id_mask = 0xffffffff, + .name = "Meta Platforms FBNIC PHY Driver", + .match_phy_device = fbnic_phy_match_phy_device, + .get_features = fbnic_phy_get_features, + .read_status = genphy_c45_read_status, + .config_aneg = gen10g_config_aneg, +}, +}; + +module_phy_driver(fbnic_phy_driver); + +static const struct mdio_device_id __maybe_unused fbnic_phy_tbl[] = { + { MP_FBNIC_XPCS_PMA_100G_ID, 0xffffffff }, + { } +}; + +MODULE_DEVICE_TABLE(mdio, fbnic_phy_tbl);