All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Russell King <rmk+kernel@armlinux.org.uk>, Andrew Lunn <andrew@lunn.ch>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH 5/5] net: phy: add Marvell Alaska X 88X3310 10Gigabit PHY support
Date: Thu, 1 Jun 2017 10:28:04 -0700	[thread overview]
Message-ID: <ddf5b409-43fb-5045-ebfc-9a20d1ca1aec@gmail.com> (raw)
In-Reply-To: <E1dGNJc-000442-8H@rmk-PC.armlinux.org.uk>

On 06/01/2017 03:26 AM, Russell King wrote:
> Add phylib support for the Marvell Alaska X 10 Gigabit PHY (MV88X3310).
> This phy is able to operate at 10G, 1G, 100M and 10M speeds, and only
> supports Clause 45 accesses.
> 
> The PHY appears (based on the vendor IDs) to be two different vendors
> IP, with each devad containing several instances.
> 
> This PHY driver has only been tested with the RJ45 copper port, fiber
> port and a Marvell Armada 8040-based ethernet interface.
> 
> It should be noted that to use the full range of speeds, MAC drivers
> need to also reconfigure the link mode as per phydev->interface, since
> the PHY automatically changes its interface mode depending on the
> negotiated speed.
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---

>  MARVELL MVNETA ETHERNET DRIVER
>  M:	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
>  L:	netdev@vger.kernel.org
> diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
> index 19eddf758c88..905990fece28 100644
> --- a/drivers/net/phy/Makefile
> +++ b/drivers/net/phy/Makefile
> @@ -55,7 +55,7 @@ obj-$(CONFIG_ICPLUS_PHY)	+= icplus.o
>  obj-$(CONFIG_INTEL_XWAY_PHY)	+= intel-xway.o
>  obj-$(CONFIG_LSI_ET1011C_PHY)	+= et1011c.o
>  obj-$(CONFIG_LXT_PHY)		+= lxt.o
> -obj-$(CONFIG_MARVELL_PHY)	+= marvell.o
> +obj-$(CONFIG_MARVELL_PHY)	+= marvell.o marvell10g.o

Could we introduce a CONFIG_MARVELL_10G_PHY symbol?


> +enum {
> +	MV_PCS_BASE_T		= 0x0000,
> +	MV_PCS_BASE_R		= 0x1000,
> +	MV_PCS_1000BASEX	= 0x2000,
> +
> +	/* These registers appear at 0x800X and 0xa00X - the 0xa00X control
> +	 * registers appear to set themselves to the 0x800X when AN is
> +	 * restarted, but status registers appear readable from either.
> +	 */
> +	MV_AN_CTRL1000		= 0x8000, /* 1000base-T control register */
> +	MV_AN_STAT1000		= 0x8001, /* 1000base-T status register */
> +
> +	/* This register appears to reflect the copper status */
> +	MV_AN_RESULT		= 0xa016,
> +	MV_AN_RESULT_SPD_10	= BIT(12),
> +	MV_AN_RESULT_SPD_100	= BIT(13),
> +	MV_AN_RESULT_SPD_1000	= BIT(14),
> +	MV_AN_RESULT_SPD_10000	= BIT(15),
> +};

Personal preference is not to use enums but jut plain #define, but
whatever works, really.


> +
> +static int mv3310_soft_reset(struct phy_device *phydev)
> +{
> +	return 0;
> +}

You could use genphy_no_soft_reset(), although genphy sort of implies
C22 now, or we could export genphy10g_soft_reset() which also does nothing.


> +	/* Ethtool does not support the WAN mode bits */
> +	if (val & (MDIO_PMA_STAT2_10GBSR | MDIO_PMA_STAT2_10GBLR |
> +		   MDIO_PMA_STAT2_10GBER | MDIO_PMA_STAT2_10GBLX4 |
> +		   MDIO_PMA_STAT2_10GBSW | MDIO_PMA_STAT2_10GBLW |
> +		   MDIO_PMA_STAT2_10GBEW))
> +		__set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, supported);
> +	if (val & MDIO_PMA_STAT2_10GBSR)
> +		__set_bit(ETHTOOL_LINK_MODE_10000baseSR_Full_BIT, supported);
> +	if (val & MDIO_PMA_STAT2_10GBLR)
> +		__set_bit(ETHTOOL_LINK_MODE_10000baseLR_Full_BIT, supported);
> +	if (val & MDIO_PMA_STAT2_10GBER)
> +		__set_bit(ETHTOOL_LINK_MODE_10000baseER_Full_BIT, supported);
> +
> +	if (val & MDIO_PMA_STAT2_EXTABLE) {
> +		val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_EXTABLE);
> +		if (val < 0)
> +			return val;
> +
> +		if (val & (MDIO_PMA_EXTABLE_10GBT | MDIO_PMA_EXTABLE_1000BT |
> +			   MDIO_PMA_EXTABLE_100BTX | MDIO_PMA_EXTABLE_10BT))
> +			__set_bit(ETHTOOL_LINK_MODE_TP_BIT, supported);
> +		if (val & MDIO_PMA_EXTABLE_10GBLRM)
> +			__set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, supported);
> +		if (val & (MDIO_PMA_EXTABLE_10GBKX4 | MDIO_PMA_EXTABLE_10GBKR |
> +			   MDIO_PMA_EXTABLE_1000BKX))
> +			__set_bit(ETHTOOL_LINK_MODE_Backplane_BIT, supported);
> +		if (val & MDIO_PMA_EXTABLE_10GBLRM)
> +			__set_bit(ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT,
> +				  supported);
> +		if (val & MDIO_PMA_EXTABLE_10GBT)
> +			__set_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT,
> +				  supported);
> +		if (val & MDIO_PMA_EXTABLE_10GBKX4)
> +			__set_bit(ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT,
> +				  supported);
> +		if (val & MDIO_PMA_EXTABLE_10GBKR)
> +			__set_bit(ETHTOOL_LINK_MODE_10000baseKR_Full_BIT,
> +				  supported);
> +		if (val & MDIO_PMA_EXTABLE_1000BT)
> +			__set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
> +				  supported);
> +		if (val & MDIO_PMA_EXTABLE_1000BKX)
> +			__set_bit(ETHTOOL_LINK_MODE_1000baseKX_Full_BIT,
> +				  supported);
> +		if (val & MDIO_PMA_EXTABLE_100BTX)
> +			__set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
> +				  supported);
> +		if (val & MDIO_PMA_EXTABLE_10BT)
> +			__set_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT,
> +				  supported);
> +	}
> +
> +	if (!ethtool_convert_link_mode_to_legacy_u32(&mask, supported))
> +		dev_warn(&phydev->mdio.dev,
> +			 "PHY supports (%*pb) more modes than phylib supports, some modes not supported.\n",
> +			 __ETHTOOL_LINK_MODE_MASK_NBITS, supported);
> +
> +	phydev->supported &= mask;
> +	phydev->advertising &= phydev->supported;

Is not this a candidate for being moved into drivers/net/phy/phy-10g.c?
Past the phy interface mode check, the rest does not appear to be
particularly Marvell specific here.

Other than that, and making it a separate Kconfig option, this looks great!
-- 
Florian

  parent reply	other threads:[~2017-06-01 17:28 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-01 10:23 [PATCH 0/5] Add phylib support for MV88X3310 10G phy Russell King - ARM Linux
2017-06-01 10:26 ` [PATCH 1/5] net: phy: add 802.3 clause 45 support to phylib Russell King
2017-06-01 12:28   ` Andrew Lunn
2017-06-01 17:15   ` Florian Fainelli
2017-06-02 12:39     ` Russell King - ARM Linux
2017-06-01 10:26 ` [PATCH 2/5] net: phy: hook up clause 45 autonegotiation restart Russell King
2017-06-01 12:23   ` Andrew Lunn
2017-06-01 12:51     ` Russell King - ARM Linux
2017-06-01 13:05       ` Andrew Lunn
2017-06-01 13:09         ` Russell King - ARM Linux
2017-06-01 13:19           ` Andrew Lunn
2017-06-01 15:47             ` Russell King - ARM Linux
2017-06-01 16:24               ` Russell King - ARM Linux
2017-06-01 17:16                 ` Florian Fainelli
2017-06-02 12:43                   ` Russell King - ARM Linux
2017-06-02 13:46                     ` Andrew Lunn
2017-06-02 14:04                       ` Russell King - ARM Linux
2017-06-01 10:26 ` [PATCH 3/5] net: phy: split out 10G genphy support Russell King
2017-06-01 12:29   ` Andrew Lunn
2017-06-01 17:17   ` Florian Fainelli
2017-06-01 10:26 ` [PATCH 4/5] net: phy: add XAUI and 10GBASE-KR PHY connection types Russell King
     [not found]   ` <E1dGNJX-00043v-3M-eh5Bv4kxaXIk46pC+1QYvQNdhmdF6hFW@public.gmane.org>
2017-06-01 12:30     ` Andrew Lunn
2017-06-01 16:56   ` Florian Fainelli
     [not found]     ` <fb1a81e0-b5b9-80e4-7852-cc65a574b9e9-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-06-01 17:32       ` Russell King - ARM Linux
2017-06-01 10:26 ` [PATCH 5/5] net: phy: add Marvell Alaska X 88X3310 10Gigabit PHY support Russell King
2017-06-01 12:51   ` Andrew Lunn
2017-06-01 13:06     ` Russell King - ARM Linux
2017-06-01 17:28   ` Florian Fainelli [this message]
2017-06-01 17:57     ` Russell King - ARM Linux
2017-06-01 16:07 ` [PATCH 0/5] Add phylib support for MV88X3310 10G phy David Miller
     [not found]   ` <20170601.120736.670167741447008364.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2017-06-01 16:54     ` Russell King - ARM Linux
     [not found] ` <20170601102327.GF27796-l+eeeJia6m9URfEZ8mYm6t73F7V6hmMc@public.gmane.org>
2017-06-05 11:22   ` [PATCH v2 0/6] " Russell King - ARM Linux
2017-06-05 11:22     ` [PATCH 1/6] net: phy: add 802.3 clause 45 support to phylib Russell King
2017-06-05 16:25       ` Florian Fainelli
2017-06-05 11:22     ` [PATCH 2/6] net: phy: avoid genphy_aneg_done() for PHYs without clause 22 support Russell King
2017-06-05 11:58       ` Andrew Lunn
2017-06-05 16:29       ` Florian Fainelli
2017-06-05 11:23     ` [PATCH 3/6] net: phy: hook up clause 45 autonegotiation restart Russell King
2017-06-05 11:59       ` Andrew Lunn
2017-06-05 16:30       ` Florian Fainelli
2017-06-05 11:23     ` [PATCH 4/6] net: phy: split out 10G genphy support Russell King
2017-06-05 11:23     ` [PATCH 5/6] net: phy: add XAUI and 10GBASE-KR PHY connection types Russell King
     [not found]       ` <E1dHq6I-0005XE-VR-eh5Bv4kxaXIk46pC+1QYvQNdhmdF6hFW@public.gmane.org>
2017-06-05 12:00         ` Andrew Lunn
2017-06-05 16:24       ` Florian Fainelli
2017-06-05 11:23     ` [PATCH 6/6] net: phy: add Marvell Alaska X 88X3310 10Gigabit PHY support Russell King
2017-06-05 18:20       ` Andrew Lunn
2017-06-05 18:21       ` Florian Fainelli
2017-06-05 18:21       ` Andrew Lunn
2017-06-05 22:10         ` Russell King - ARM Linux
     [not found]     ` <20170605112203.GA10680-l+eeeJia6m9URfEZ8mYm6t73F7V6hmMc@public.gmane.org>
2017-06-05 21:53       ` [PATCH v2 0/6] Add phylib support for MV88X3310 10G phy David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ddf5b409-43fb-5045-ebfc-9a20d1ca1aec@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=netdev@vger.kernel.org \
    --cc=rmk+kernel@armlinux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.