From: Salil Mehta <salil.mehta@huawei.com>
To: <davem@davemloft.net>
Cc: <salil.mehta@huawei.com>, <yisen.zhuang@huawei.com>,
<lipeng321@huawei.com>, <mehta.salil@opnsrc.net>,
<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linuxarm@huawei.com>, Jian Shen <shenjian15@huawei.com>
Subject: [PATCH net-next 11/11] net: hns3: Refine hns3_get_link_ksettings()
Date: Mon, 3 Sep 2018 11:21:56 +0100 [thread overview]
Message-ID: <20180903102156.18676-12-salil.mehta@huawei.com> (raw)
In-Reply-To: <20180903102156.18676-1-salil.mehta@huawei.com>
From: Jian Shen <shenjian15@huawei.com>
In the previous implement, the query operation for fibre port and copper
port are mixed. This patch refines it by seperating them based on the port
type.
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 68 +++++++++++++---------
1 file changed, 40 insertions(+), 28 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 41d817d..3019007 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -546,26 +546,56 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
struct ethtool_link_ksettings *cmd)
{
struct hnae3_handle *h = hns3_get_handle(netdev);
- u32 flowctrl_adv = 0;
+ const struct hnae3_ae_ops *ops;
u8 link_stat;
if (!h->ae_algo || !h->ae_algo->ops)
return -EOPNOTSUPP;
- /* 1.auto_neg & speed & duplex from cmd */
- if (netdev->phydev) {
+ ops = h->ae_algo->ops;
+ if (ops->get_port_type)
+ ops->get_port_type(h, &cmd->base.port);
+ else
+ return -EOPNOTSUPP;
+
+ switch (cmd->base.port) {
+ case PORT_FIBRE:
+ /* 1.auto_neg & speed & duplex from cmd */
+ if (ops->get_ksettings_an_result)
+ ops->get_ksettings_an_result(h,
+ &cmd->base.autoneg,
+ &cmd->base.speed,
+ &cmd->base.duplex);
+ else
+ return -EOPNOTSUPP;
+
+ /* 2.get link mode*/
+ if (ops->get_link_mode)
+ ops->get_link_mode(h,
+ cmd->link_modes.supported,
+ cmd->link_modes.advertising);
+
+ /* 3.mdix_ctrl&mdix get from phy reg */
+ if (ops->get_mdix_mode)
+ ops->get_mdix_mode(h, &cmd->base.eth_tp_mdix_ctrl,
+ &cmd->base.eth_tp_mdix);
+
+ break;
+ case PORT_TP:
+ if (!netdev->phydev)
+ return -EOPNOTSUPP;
+
phy_ethtool_ksettings_get(netdev->phydev, cmd);
+ break;
+ default:
+ netdev_warn(netdev,
+ "Unknown port type, neither Fibre/Copper detected");
return 0;
}
- if (h->ae_algo->ops->get_ksettings_an_result)
- h->ae_algo->ops->get_ksettings_an_result(h,
- &cmd->base.autoneg,
- &cmd->base.speed,
- &cmd->base.duplex);
- else
- return -EOPNOTSUPP;
+ /* mdio_support */
+ cmd->base.mdio_support = ETH_MDIO_SUPPORTS_C22;
link_stat = hns3_get_link(netdev);
if (!link_stat) {
@@ -573,24 +603,6 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
cmd->base.duplex = DUPLEX_UNKNOWN;
}
- /* 2.get link mode and port type*/
- if (h->ae_algo->ops->get_link_mode)
- h->ae_algo->ops->get_link_mode(h,
- cmd->link_modes.supported,
- cmd->link_modes.advertising);
-
- cmd->base.port = PORT_NONE;
- if (h->ae_algo->ops->get_port_type)
- h->ae_algo->ops->get_port_type(h,
- &cmd->base.port);
-
- /* 3.mdix_ctrl&mdix get from phy reg */
- if (h->ae_algo->ops->get_mdix_mode)
- h->ae_algo->ops->get_mdix_mode(h, &cmd->base.eth_tp_mdix_ctrl,
- &cmd->base.eth_tp_mdix);
- /* 4.mdio_support */
- cmd->base.mdio_support = ETH_MDIO_SUPPORTS_C22;
-
return 0;
}
--
2.7.4
next prev parent reply other threads:[~2018-09-03 10:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-03 10:21 [PATCH net-next 00/11] Misc. bug fixes & small enhancements for HNS3 Driver Salil Mehta
2018-09-03 10:21 ` [PATCH net-next 01/11] net: hns3: Fix for vf vlan delete failed problem Salil Mehta
2018-09-03 10:21 ` [PATCH net-next 02/11] net: hns3: Fix for multicast failure Salil Mehta
2018-09-03 10:21 ` [PATCH net-next 03/11] net: hns3: Fix error of checking used vlan id Salil Mehta
2018-09-03 10:21 ` [PATCH net-next 04/11] net: hns3: Implement shutdown ops in hns3 pci driver Salil Mehta
2018-09-03 10:21 ` [PATCH net-next 05/11] net: hns3: Fix for loopback selftest failed problem Salil Mehta
2018-09-03 10:21 ` [PATCH net-next 06/11] net: hns3: Fix ping exited problem when doing lp selftest Salil Mehta
2018-09-03 10:21 ` [PATCH net-next 07/11] net: hns3: Preserve vlan 0 in hardware table Salil Mehta
2018-09-03 10:21 ` [PATCH net-next 08/11] net: hns3: Only update mac configuation when necessary Salil Mehta
2018-09-03 10:21 ` [PATCH net-next 09/11] net: hns3: Change the dst mac addr of loopback packet Salil Mehta
2018-09-03 10:21 ` [PATCH net-next 10/11] net: hns3: Remove redundant codes of query advertised flow control abilitiy Salil Mehta
2018-09-03 10:21 ` Salil Mehta [this message]
2018-09-04 5:06 ` [PATCH net-next 00/11] Misc. bug fixes & small enhancements for HNS3 Driver 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=20180903102156.18676-12-salil.mehta@huawei.com \
--to=salil.mehta@huawei.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=lipeng321@huawei.com \
--cc=mehta.salil@opnsrc.net \
--cc=netdev@vger.kernel.org \
--cc=shenjian15@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;
as well as URLs for NNTP newsgroup(s).