linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Biju Das <biju.das.jz@bp.renesas.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Sergei Shtylyov <sergei.shtylyov@gmail.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Sergey Shtylyov <s.shtylyov@omprussia.ru>,
	Adam Ford <aford173@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
	Andrew Gabbasov <andrew_gabbasov@mentor.com>,
	Yuusuke Ashizuka <ashiduka@fujitsu.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-renesas-soc@vger.kernel.org" 
	<linux-renesas-soc@vger.kernel.org>,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Biju Das <biju.das@bp.renesas.com>,
	Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: RE: [PATCH/RFC 2/2] ravb: Add GbEthernet driver support
Date: Wed, 14 Jul 2021 17:01:34 +0000	[thread overview]
Message-ID: <OS0PR01MB59225983D7FB35F82213911686139@OS0PR01MB5922.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <YO8KeCg8bQPjI/a5@lunn.ch>

Hi Andrew Lunn,

Thanks for the feedback.

> Subject: Re: [PATCH/RFC 2/2] ravb: Add GbEthernet driver support
> 
> > +	if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) {
> > +		ravb_write(ndev, ravb_read(ndev, CXR31)
> > +			 | CXR31_SEL_LINK0, CXR31);
> > +	} else {
> > +		ravb_write(ndev, ravb_read(ndev, CXR31)
> > +			 & ~CXR31_SEL_LINK0, CXR31);
> > +	}
> 
> You need to be very careful here. What value is passed to the PHY?

PHY_INTERFACE_MODE_RGMII is the value passed to PHY.

The below code is used only by R-Car3, where MAC supports internal delay.

> 
> There is some funky code:
> 
>        /* Fall back to legacy rgmii-*id behavior */
>         if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
>             priv->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) {
>                 priv->rxcidm = 1;
>                 priv->rgmii_override = 1;
>         }
> 
>         if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
>             priv->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) {
>                 if (!WARN(soc_device_match(ravb_delay_mode_quirk_match),
>                           "phy-mode %s requires TX clock internal delay
> mode which is not supported by this hardware revision. Please update
> device tree",
>                           phy_modes(priv->phy_interface))) {
>                         priv->txcidm = 1;
>                         priv->rgmii_override = 1;
>                 }
>         }
> ...
> 
>         iface = priv->rgmii_override ? PHY_INTERFACE_MODE_RGMII
>                                      : priv->phy_interface;
>         phydev = of_phy_connect(ndev, pn, ravb_adjust_link, 0, iface);
> 
> So it looks like, with PHY_INTERFACE_MODE_RGMII_ID,
> PHY_INTERFACE_MODE_RGMII_TXID, PHY_INTERFACE_MODE_RGMII_RXID the PHY is
> passed PHY_INTERFACE_MODE_RGMII, with the assumption the MAC is adding the
> delay. But it looks like you are only adding a delay for
> PHY_INTERFACE_MODE_RGMII_ID. So this appears wrong.

This SoC family doesn't use that code and doesn't support MAC internal delay. 
It is applicable only for R-Car Gen3 whet it sets "priv->rgmii_override"
For other SoC's it is just priv->phy_interface.

> 
> > @@ -1082,15 +1440,23 @@ static int ravb_phy_init(struct net_device
> *ndev)
> >  		netdev_info(ndev, "limited PHY to 100Mbit/s\n");
> >  	}
> >
> > -	/* 10BASE, Pause and Asym Pause is not supported */
> > -	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT);
> > -	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Full_BIT);
> > -	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_Pause_BIT);
> > -	phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_Asym_Pause_BIT);
> > +	if (priv->chip_id == RZ_G2L) {
> > +		if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID)
> > +			ravb_write(ndev, ravb_read(ndev, CXR35) |
> CXR35_SEL_MODIN, CXR35);
> > +		else if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII)
> > +			ravb_write(ndev, 0x3E80000, CXR35);
> 
> This is not obviously correct. What about the other two RGMII modes?
> 
> > @@ -1348,6 +1741,21 @@ static const struct ethtool_ops ravb_ethtool_ops
> = {
> >  	.set_wol		= ravb_set_wol,
> >  };
> >
> > +static const struct ethtool_ops rgeth_ethtool_ops = {
> > +	.nway_reset		= phy_ethtool_nway_reset,
> > +	.get_msglevel		= ravb_get_msglevel,
> > +	.set_msglevel		= ravb_set_msglevel,
> > +	.get_link		= ethtool_op_get_link,
> > +	.get_strings		= ravb_get_strings,
> > +	.get_ethtool_stats	= ravb_get_ethtool_stats,
> > +	.get_sset_count		= ravb_get_sset_count,
> > +	.get_ringparam		= ravb_get_ringparam,
> > +	.set_ringparam		= ravb_set_ringparam,
> > +	.get_ts_info		= ravb_get_ts_info,
> > +	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
> > +	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
> > +};
> 
> It is not obvious why you need a seperate ethtool_ops structure? Does it
> not support WOL?

Yes,WOL is supported by WAKE_PHY. As per HW manual MAGIC packet detection is not supported.
OK I will add wol. Also it supports eee which we are planning to add later stage.


> 

> > +static const struct net_device_ops rgeth_netdev_ops = {
> > +	.ndo_open               = ravb_open,
> > +	.ndo_stop               = ravb_close,
> > +	.ndo_start_xmit         = ravb_start_xmit,
> > +	.ndo_select_queue       = ravb_select_queue,
> > +	.ndo_get_stats          = ravb_get_stats,
> > +	.ndo_set_rx_mode        = ravb_set_rx_mode,
> > +	.ndo_tx_timeout         = ravb_tx_timeout,
> > +	.ndo_do_ioctl           = ravb_do_ioctl,
> > +	.ndo_validate_addr      = eth_validate_addr,
> > +	.ndo_set_mac_address    = eth_mac_addr,
> > +	.ndo_set_features       = rgeth_set_features,
> 
> It seems like .ndo_set_features is the only difference. Maybe handle that
> in actual function?

OK will do.

> 
> > @@ -1965,6 +2446,7 @@ static const struct of_device_id
> ravb_match_table[] = {
> >  	{ .compatible = "renesas,etheravb-rcar-gen2", .data = (void
> *)RCAR_GEN2 },
> >  	{ .compatible = "renesas,etheravb-r8a7795", .data = (void
> *)RCAR_GEN3 },
> >  	{ .compatible = "renesas,etheravb-rcar-gen3", .data = (void
> > *)RCAR_GEN3 },
> > +	{ .compatible = "renesas,rzg2l-gether", .data = (void *)RZ_G2L },
> >  	{ }
> >  };
> 
> Please document the new compatible string in the DT binding.

OK. Will do

Thanks,
Biju
> 
>        Andrew

  reply	other threads:[~2021-07-14 17:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-14 14:54 [PATCH/RFC 0/2] Add Gigabit Ethernet " Biju Das
2021-07-14 14:54 ` [PATCH/RFC 1/2] ravb: Preparation for supporting Gigabit Ethernet driver Biju Das
2021-07-14 15:39   ` Andrew Lunn
2021-07-14 16:24     ` Biju Das
2021-07-14 18:20   ` Sergei Shtylyov
2021-07-15  6:49     ` Biju Das
2021-07-14 14:54 ` [PATCH/RFC 2/2] ravb: Add GbEthernet driver support Biju Das
2021-07-14 16:02   ` Andrew Lunn
2021-07-14 17:01     ` Biju Das [this message]
2021-07-14 17:25       ` Andrew Lunn
2021-07-14 17:56         ` Biju Das
2021-07-15 10:13   ` Geert Uytterhoeven
2021-07-15 10:31     ` Biju Das
2021-07-19 20:41   ` Sergei Shtylyov
2021-07-20  6:32     ` Biju Das
2021-07-14 19:26 ` [PATCH/RFC 0/2] Add Gigabit Ethernet " Sergei Shtylyov

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=OS0PR01MB59225983D7FB35F82213911686139@OS0PR01MB5922.jpnprd01.prod.outlook.com \
    --to=biju.das.jz@bp.renesas.com \
    --cc=Chris.Paterson2@renesas.com \
    --cc=aford173@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=andrew_gabbasov@mentor.com \
    --cc=ashiduka@fujitsu.com \
    --cc=biju.das@bp.renesas.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=kuba@kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=s.shtylyov@omprussia.ru \
    --cc=sergei.shtylyov@gmail.com \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    --subject='RE: [PATCH/RFC 2/2] ravb: Add GbEthernet driver support' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).