Commit 02ccdd9d authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'xilinx-phylink'



Russell King says:

====================
net: xilinx: phylink validate implementation updates

This series converts axienet to fill in the supported_interfaces member
of phylink_config, cleans up the validate() implementation, and then
converts to phylink_generic_validate().
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 01dd7424 72a47e1a
Loading
Loading
Loading
Loading
+11 −60
Original line number Diff line number Diff line
@@ -1503,65 +1503,6 @@ static const struct ethtool_ops axienet_ethtool_ops = {
	.nway_reset	= axienet_ethtools_nway_reset,
};

static void axienet_validate(struct phylink_config *config,
			     unsigned long *supported,
			     struct phylink_link_state *state)
{
	struct net_device *ndev = to_net_dev(config->dev);
	struct axienet_local *lp = netdev_priv(ndev);
	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };

	/* Only support the mode we are configured for */
	switch (state->interface) {
	case PHY_INTERFACE_MODE_NA:
		break;
	case PHY_INTERFACE_MODE_1000BASEX:
	case PHY_INTERFACE_MODE_SGMII:
		if (lp->switch_x_sgmii)
			break;
		fallthrough;
	default:
		if (state->interface != lp->phy_mode) {
			netdev_warn(ndev, "Cannot use PHY mode %s, supported: %s\n",
				    phy_modes(state->interface),
				    phy_modes(lp->phy_mode));
			linkmode_zero(supported);
			return;
		}
	}

	phylink_set(mask, Autoneg);
	phylink_set_port_modes(mask);

	phylink_set(mask, Asym_Pause);
	phylink_set(mask, Pause);

	switch (state->interface) {
	case PHY_INTERFACE_MODE_NA:
	case PHY_INTERFACE_MODE_1000BASEX:
	case PHY_INTERFACE_MODE_SGMII:
	case PHY_INTERFACE_MODE_GMII:
	case PHY_INTERFACE_MODE_RGMII:
	case PHY_INTERFACE_MODE_RGMII_ID:
	case PHY_INTERFACE_MODE_RGMII_RXID:
	case PHY_INTERFACE_MODE_RGMII_TXID:
		phylink_set(mask, 1000baseX_Full);
		phylink_set(mask, 1000baseT_Full);
		if (state->interface == PHY_INTERFACE_MODE_1000BASEX)
			break;
		fallthrough;
	case PHY_INTERFACE_MODE_MII:
		phylink_set(mask, 100baseT_Full);
		phylink_set(mask, 10baseT_Full);
		fallthrough;
	default:
		break;
	}

	linkmode_and(supported, supported, mask);
	linkmode_and(state->advertising, state->advertising, mask);
}

static void axienet_mac_pcs_get_state(struct phylink_config *config,
				      struct phylink_link_state *state)
{
@@ -1687,7 +1628,7 @@ static void axienet_mac_link_up(struct phylink_config *config,
}

static const struct phylink_mac_ops axienet_phylink_ops = {
	.validate = axienet_validate,
	.validate = phylink_generic_validate,
	.mac_pcs_get_state = axienet_mac_pcs_get_state,
	.mac_an_restart = axienet_mac_an_restart,
	.mac_prepare = axienet_mac_prepare,
@@ -2104,6 +2045,16 @@ static int axienet_probe(struct platform_device *pdev)

	lp->phylink_config.dev = &ndev->dev;
	lp->phylink_config.type = PHYLINK_NETDEV;
	lp->phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE |
		MAC_10FD | MAC_100FD | MAC_1000FD;

	__set_bit(lp->phy_mode, lp->phylink_config.supported_interfaces);
	if (lp->switch_x_sgmii) {
		__set_bit(PHY_INTERFACE_MODE_1000BASEX,
			  lp->phylink_config.supported_interfaces);
		__set_bit(PHY_INTERFACE_MODE_SGMII,
			  lp->phylink_config.supported_interfaces);
	}

	lp->phylink = phylink_create(&lp->phylink_config, pdev->dev.fwnode,
				     lp->phy_mode,