mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Frank Sae <Frank.Sae@motor-comm.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, xiaogang.fan@motor-comm.com,
	fei.zhang@motor-comm.com, hua.sun@motor-comm.com
Subject: Re: [PATCH net-next v2 05/21] motorcomm:yt6801: Implement the fxgmac_start function
Date: Sat, 23 Nov 2024 00:16:58 +0100	[thread overview]
Message-ID: <95675880-1b93-4916-beee-e5feb6531009@lunn.ch> (raw)
In-Reply-To: <20241120105625.22508-6-Frank.Sae@motor-comm.com>

> +static  void fxgmac_phylink_handler(struct net_device *ndev)
> +{
> +	struct fxgmac_pdata *pdata = netdev_priv(ndev);
> +	struct fxgmac_hw_ops *hw_ops = &pdata->hw_ops;
> +
> +	pdata->phy_link = pdata->phydev->link;
> +	pdata->phy_speed = pdata->phydev->speed;
> +	pdata->phy_duplex = pdata->phydev->duplex;
> +
> +	yt_dbg(pdata, "EPHY_CTRL:%x, link:%d, speed:%d,  duplex:%x.\n",
> +	       rd32_mem(pdata, EPHY_CTRL), pdata->phy_link, pdata->phy_speed,
> +	       pdata->phy_duplex);
> +
> +	if (pdata->phy_link) {
> +		hw_ops->config_mac_speed(pdata);
> +		hw_ops->enable_rx(pdata);
> +		hw_ops->enable_tx(pdata);
> +		netif_carrier_on(pdata->netdev);

phylib controls the carrier, not the MAC driver.

> +static int fxgmac_phy_connect(struct fxgmac_pdata *pdata)
> +{
> +	struct phy_device *phydev = pdata->phydev;
> +	int ret;
> +
> +	ret = phy_connect_direct(pdata->netdev, phydev, fxgmac_phylink_handler,
> +				 PHY_INTERFACE_MODE_RGMII);

RGMII is unusual, you normally want RGMII_ID. Where are the 2ns delays
added?

> +int fxgmac_phy_irq_enable(struct fxgmac_pdata *pdata, bool clear_phy_interrupt)
> +{
> +	struct phy_device *phydev = pdata->phydev;
> +
> +	if (clear_phy_interrupt &&
> +	    phy_read(phydev, PHY_INT_STATUS) < 0)
> +		return -ETIMEDOUT;
> +
> +	return phy_modify(phydev, PHY_INT_MASK,
> +				     PHY_INT_MASK_LINK_UP |
> +					     PHY_INT_MASK_LINK_DOWN,
> +				     PHY_INT_MASK_LINK_UP |
> +					     PHY_INT_MASK_LINK_DOWN);

The PHY driver is in charge of PHY interrupts.

> +int fxgmac_start(struct fxgmac_pdata *pdata)
> +{
> +	struct fxgmac_hw_ops *hw_ops = &pdata->hw_ops;
> +	u32 val;
> +	int ret;
> +
> +	if (pdata->dev_state != FXGMAC_DEV_OPEN &&
> +	    pdata->dev_state != FXGMAC_DEV_STOP &&
> +	    pdata->dev_state != FXGMAC_DEV_RESUME) {
> +		yt_dbg(pdata, " dev_state err:%x\n", pdata->dev_state);
> +		return 0;
> +	}
> +
> +	if (pdata->dev_state != FXGMAC_DEV_STOP) {
> +		hw_ops->reset_phy(pdata);
> +		hw_ops->release_phy(pdata);
> +		yt_dbg(pdata, "reset phy.\n");
> +	}
> +
> +	if (pdata->dev_state == FXGMAC_DEV_OPEN) {
> +		ret = fxgmac_phy_connect(pdata);
> +		if (ret < 0)
> +			return ret;
> +
> +		yt_dbg(pdata, "fxgmac_phy_connect.\n");
> +	}
> +
> +	phy_init_hw(pdata->phydev);
> +	phy_resume(pdata->phydev);

The MAC should not be doing this.

> +
> +	hw_ops->pcie_init(pdata);
> +	if (test_bit(FXGMAC_POWER_STATE_DOWN, &pdata->powerstate)) {
> +		yt_err(pdata,
> +		       "fxgmac powerstate is %lu when config power up.\n",
> +		       pdata->powerstate);
> +	}
> +
> +	hw_ops->config_power_up(pdata);
> +	hw_ops->dismiss_all_int(pdata);
> +	ret = hw_ops->init(pdata);
> +	if (ret < 0) {
> +		yt_err(pdata, "fxgmac hw init error.\n");
> +		return ret;
> +	}
> +
> +	fxgmac_napi_enable(pdata);
> +	ret = fxgmac_request_irqs(pdata);
> +	if (ret < 0)
> +		return ret;
> +
> +	/* Config interrupt to level signal */
> +	val = rd32_mac(pdata, DMA_MR);
> +	fxgmac_set_bits(&val, DMA_MR_INTM_POS, DMA_MR_INTM_LEN, 2);
> +	fxgmac_set_bits(&val, DMA_MR_QUREAD_POS, DMA_MR_QUREAD_LEN, 1);
> +	wr32_mac(pdata, val, DMA_MR);
> +
> +	hw_ops->enable_mgm_irq(pdata);
> +	hw_ops->set_interrupt_moderation(pdata);
> +
> +	if (pdata->per_channel_irq) {
> +		fxgmac_enable_msix_irqs(pdata);
> +		ret = fxgmac_phy_irq_enable(pdata, true);
> +		if (ret < 0)
> +			goto dis_napi;
> +	}
> +
> +	fxgmac_enable_rx_tx_ints(pdata);
> +	phy_speed_up(pdata->phydev);
> +	genphy_soft_reset(pdata->phydev);

More things the MAC driver should not be doing.

	Andrew

  reply	other threads:[~2024-11-22 23:17 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-20 10:56 [PATCH net-next v2 00/21] net:yt6801: Add Motorcomm yt6801 PCIe driver Frank Sae
2024-11-20 10:56 ` [PATCH net-next v2 03/21] motorcomm:yt6801: Implement the fxgmac_drv_probe function Frank Sae
2024-11-22 17:30   ` Vadim Fedorenko
2024-11-20 10:56 ` [PATCH net-next v2 04/21] motorcomm:yt6801: Implement the .ndo_open function Frank Sae
2024-11-20 10:56 ` [PATCH net-next v2 05/21] motorcomm:yt6801: Implement the fxgmac_start function Frank Sae
2024-11-22 23:16   ` Andrew Lunn [this message]
2024-11-25  9:31     ` Frank Sae
2024-11-25 14:18       ` Andrew Lunn
2024-11-26  3:15         ` Frank Sae
2024-11-26  9:28           ` Frank Sae
2024-11-26 13:48             ` Andrew Lunn
2024-11-20 10:56 ` [PATCH net-next v2 08/21] motorcomm:yt6801: Implement the fxgmac_read_mac_addr function Frank Sae
2024-11-20 10:56 ` [PATCH net-next v2 12/21] motorcomm:yt6801: Implement .ndo_tx_timeout and .ndo_change_mtu functions Frank Sae
2024-11-22 23:19   ` Andrew Lunn
2024-11-20 10:56 ` [PATCH net-next v2 13/21] motorcomm:yt6801: Implement some ethtool_ops function Frank Sae
2024-11-22 22:34   ` Andrew Lunn
2024-11-20 10:56 ` [PATCH net-next v2 14/21] motorcomm:yt6801: Implement the WOL function of ethtool_ops Frank Sae
2024-11-22 23:04   ` Andrew Lunn
2024-11-20 10:56 ` [PATCH net-next v2 15/21] motorcomm:yt6801: Implement pci_driver suspend and resume Frank Sae
2024-11-22 23:10   ` Andrew Lunn
2024-11-20 10:56 ` [PATCH net-next v2 16/21] motorcomm:yt6801: Add a Makefile in the motorcomm folder Frank Sae
2024-11-20 10:56 ` [PATCH net-next v2 17/21] motorcomm:yt6801: Update the Makefile and Kconfig in the motorcomm Frank Sae
2024-11-20 10:56 ` [PATCH net-next v2 18/21] motorcomm:yt6801: Update the Makefile and Kconfig in the ethernet Frank Sae
2024-11-20 10:56 ` [PATCH net-next v2 19/21] ethernet: Update the index.rst in the ethernet documentation folder Frank Sae
2024-11-20 10:56 ` [PATCH net-next v2 20/21] motorcomm:yt6801: Add a yt6801.rst " Frank Sae
2024-11-20 10:56 ` [PATCH net-next v2 21/21] MAINTAINERS:Add the motorcomm ethernet driver entry Frank Sae
2024-11-20 11:14 ` [PATCH net-next v2 11/21] motorcomm:yt6801: Implement some net_device_ops function Frank Sae
2024-11-20 11:14 ` [PATCH net-next v2 09/21] motorcomm:yt6801: Implement some hw_ops function Frank Sae
2024-11-23  1:03   ` Andrew Lunn
2024-11-25  9:49     ` Frank Sae
2024-11-25 14:39       ` Andrew Lunn
2024-11-26  3:04         ` Frank Sae
2024-11-21  1:52 ` [PATCH net-next v2 07/21] motorcomm:yt6801: Implement the fxgmac_init function Frank Sae
2024-11-21  1:53 ` [PATCH net-next v2 02/21] motorcomm:yt6801: Implement pci_driver shutdown Frank Sae
2024-11-21  1:53 ` [PATCH net-next v2 01/21] motorcomm:yt6801: Add support for a pci table in this module Frank Sae
2024-11-21  1:53 ` [PATCH net-next v2 06/21] motorcomm:yt6801: Implement the poll functions Frank Sae
2024-11-21  6:18 ` [PATCH net-next v2 10/21] motorcomm:yt6801: Implement .ndo_start_xmit function Frank Sae
2024-11-21  9:00 ` [PATCH net-next v2 00/21] net:yt6801: Add Motorcomm yt6801 PCIe driver Paolo Abeni
2024-11-22 22:14 ` Andrew Lunn
2024-11-23  0:45 ` Andrew Lunn

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=95675880-1b93-4916-beee-e5feb6531009@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=Frank.Sae@motor-comm.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fei.zhang@motor-comm.com \
    --cc=hua.sun@motor-comm.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=xiaogang.fan@motor-comm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®