From: Florian Fainelli <f.fainelli@gmail.com>
To: Salil Mehta <salil.mehta@huawei.com>, davem@davemloft.net
Cc: yisen.zhuang@huawei.com, huangdaode@hisilicon.com,
lipeng321@huawei.com, mehta.salil.lnk@gmail.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linuxarm@huawei.com
Subject: Re: [PATCH V2 net-next 6/8] net: hns3: Add MDIO support to HNS3 Ethernet driver for hip08 SoC
Date: Tue, 13 Jun 2017 16:46:16 -0700 [thread overview]
Message-ID: <cc35a067-3395-7653-e2c7-46c60644f0ad@gmail.com> (raw)
In-Reply-To: <20170613231035.494020-7-salil.mehta@huawei.com>
On 06/13/2017 04:10 PM, Salil Mehta wrote:
> This patch adds the support of MDIO bus interface for HNS3 driver.
> Code provides various interfaces to start and stop the PHY layer
> and to read and write the MDIO bus or PHY.
>
> Signed-off-by: Daode Huang <huangdaode@hisilicon.com>
> Signed-off-by: lipeng <lipeng321@huawei.com>
> Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
> Signed-off-by: Yisen Zhuang <yisen.zhuang@huawei.com>
> ---
> + phy = get_phy_device(mdio_bus, mac->phy_addr, mac->is_c45);
> + if (!phy || IS_ERR(phy)) {
> + dev_err(mdio_bus->parent, "Failed to get phy device\n");
> + ret = -EIO;
> + goto err_mdio_register;
> + }
> +
> + phy->irq = mdio_bus->irq[mac->phy_addr];
> +
> + /* All data is now stored in the phy struct;
> + * register it
> + */
> + ret = phy_device_register(phy);
> + if (ret) {
> + ret = -ENODEV;
> + goto err_phy_register;
> + }
Until this gets fixed in the core PHY library, it's okay to do that, but
please fix the
> +
> + mac->phy_dev = phy;
> +
> + return 0;
> +
> +err_phy_register:
> + phy_device_free(phy);
> +
> +err_mdio_register:
> + mdiobus_unregister(mdio_bus);
> + mdiobus_free(mdio_bus);
> +err_miibus_alloc:
> + return ret;
> +}
> +
> +static void hclge_mac_adjust_link(struct net_device *net_dev)
> +{
> + int duplex;
> + int speed;
> + struct hclge_mac *hw_mac;
> + struct hclge_hw *hw;
> + struct hclge_dev *hdev;
> +
> + if (!net_dev)
> + return;
> +
> + hw_mac = container_of(net_dev, struct hclge_mac, ndev);
> + hw = container_of(hw_mac, struct hclge_hw, mac);
> + hdev = hw->back;
> +
> + speed = hw_mac->phy_dev->speed;
> + duplex = hw_mac->phy_dev->duplex;
> +
> + /* update antoneg. */
> + hw_mac->autoneg = hw_mac->phy_dev->autoneg;
> +
> + if ((hw_mac->speed != speed) || (hw_mac->duplex != duplex))
> + (void)hclge_cfg_mac_speed_dup(hdev, speed, !!duplex);
> +}
> +
> +int hclge_mac_start_phy(struct hclge_dev *hdev)
> +{
> + struct hclge_mac *mac = &hdev->hw.mac;
> + struct phy_device *phy_dev = mac->phy_dev;
> + int ret;
> +
> + if (!phy_dev)
> + return 0;
> +
> + if (mac->phy_if != PHY_INTERFACE_MODE_XGMII) {
> + phy_dev->dev_flags = 0;
> +
> + ret = phy_connect_direct(&mac->ndev, phy_dev,
> + hclge_mac_adjust_link,
> + mac->phy_if);
> + phy_dev->supported = SUPPORTED_10baseT_Half |
> + SUPPORTED_10baseT_Full |
> + SUPPORTED_100baseT_Half |
> + SUPPORTED_100baseT_Full |
> + SUPPORTED_Autoneg |
> + SUPPORTED_1000baseT_Full;
> +
> + phy_dev->autoneg = false;
> + } else {
> + ret = phy_attach_direct(&mac->ndev, phy_dev, 0, mac->phy_if);
> + phy_dev->supported = SUPPORTED_10000baseR_FEC |
> + SUPPORTED_10000baseKR_Full;
> + }
I really don't see why you don't take the exact same path whether it's
XGMII or not, just like you are not masking with that the PHY driver
already supports, this needs fixing.
> + if (unlikely(ret))
> + return -ENODEV;
> +
> + phy_start(phy_dev);
> +
> + return 0;
> +}
> +
> +void hclge_mac_stop_phy(struct hclge_dev *hdev)
> +{
> + struct hclge_mac *mac = &hdev->hw.mac;
> + struct phy_device *phy_dev = mac->phy_dev;
> +
> + if (!phy_dev)
> + return;
> +
> + phy_stop(phy_dev);
> +
> + if (mac->phy_if != PHY_INTERFACE_MODE_XGMII)
> + phy_disconnect(phy_dev);
> + else
> + phy_detach(phy_dev);
Same here.
--
Florian
next prev parent reply other threads:[~2017-06-13 23:46 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-13 23:10 [PATCH V2 net-next 0/8] Hisilicon Network Subsystem 3 Ethernet Driver Salil Mehta
2017-06-13 23:10 ` [PATCH V2 net-next 1/8] net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC Salil Mehta
2017-06-13 23:53 ` Stephen Hemminger
2017-06-17 10:47 ` Salil Mehta
2017-06-19 15:48 ` Stephen Hemminger
2017-07-22 23:57 ` Salil Mehta
2017-06-13 23:10 ` [PATCH V2 net-next 2/8] net: hns3: Add support of the HNAE3 framework Salil Mehta
2017-06-14 1:32 ` Andrew Lunn
2017-06-17 11:12 ` Salil Mehta
2017-06-14 1:37 ` Andrew Lunn
2017-06-17 11:18 ` Salil Mehta
2017-06-17 12:11 ` Andrew Lunn
2017-06-18 14:53 ` Andrew Lunn
2017-07-22 23:31 ` Salil Mehta
2017-06-13 23:10 ` [PATCH V2 net-next 3/8] net: hns3: Add HNS3 IMP(Integrated Mgmt Proc) Cmd Interface Support Salil Mehta
2017-06-13 23:10 ` [PATCH V2 net-next 4/8] net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support Salil Mehta
2017-06-13 23:10 ` [PATCH V2 net-next 5/8] net: hns3: Add support of TX Scheduler & Shaper to HNS3 driver Salil Mehta
2017-06-13 23:10 ` [PATCH V2 net-next 6/8] net: hns3: Add MDIO support to HNS3 Ethernet driver for hip08 SoC Salil Mehta
2017-06-13 23:46 ` Florian Fainelli [this message]
2017-06-17 10:40 ` Salil Mehta
2017-06-14 2:42 ` Andrew Lunn
2017-06-17 11:56 ` Salil Mehta
2017-06-14 2:55 ` Andrew Lunn
2017-06-17 11:56 ` Salil Mehta
2017-06-13 23:10 ` [PATCH V2 net-next 7/8] net: hns3: Add Ethtool support to HNS3 driver Salil Mehta
2017-06-13 23:55 ` Stephen Hemminger
2017-06-17 11:05 ` Salil Mehta
2017-06-14 2:19 ` Andrew Lunn
2017-06-17 11:20 ` Salil Mehta
2017-06-14 2:32 ` Andrew Lunn
2017-06-17 11:54 ` Salil Mehta
2017-06-13 23:10 ` [PATCH V2 net-next 8/8] net: hns3: Add HNS3 driver to kernel build framework & MAINTAINERS Salil Mehta
2017-06-14 10:52 ` kbuild test robot
2017-06-14 15:37 ` kbuild test robot
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=cc35a067-3395-7653-e2c7-46c60644f0ad@gmail.com \
--to=f.fainelli@gmail.com \
--cc=davem@davemloft.net \
--cc=huangdaode@hisilicon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=lipeng321@huawei.com \
--cc=mehta.salil.lnk@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=salil.mehta@huawei.com \
--cc=yisen.zhuang@huawei.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