DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jiawen Wu <jiawenwu@trustnetic.com>
To: dev@dpdk.org
Cc: Jiawen Wu <jiawenwu@trustnetic.com>
Subject: [PATCH 9/9] net/ngbe: support to set link down/up
Date: Fri,  2 Sep 2022 11:00:11 +0800	[thread overview]
Message-ID: <20220902030011.377523-10-jiawenwu@trustnetic.com> (raw)
In-Reply-To: <20220902030011.377523-1-jiawenwu@trustnetic.com>

Add support to set device link down/up.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 doc/guides/rel_notes/release_22_11.rst |  4 ++++
 drivers/net/ngbe/base/ngbe_phy.c       |  1 +
 drivers/net/ngbe/base/ngbe_phy_rtl.c   | 13 ++++++++++++
 drivers/net/ngbe/base/ngbe_phy_rtl.h   |  2 ++
 drivers/net/ngbe/ngbe_ethdev.c         | 28 ++++++++++++++++++++++++++
 5 files changed, 48 insertions(+)

diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 8c021cf050..843501c7c2 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -84,6 +84,10 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =======================================================
 
+* **Updated Wangxun ngbe driver.**
+
+  * Added support to set device link down/up.
+
 
 ABI Changes
 -----------
diff --git a/drivers/net/ngbe/base/ngbe_phy.c b/drivers/net/ngbe/base/ngbe_phy.c
index 06562b594f..acff7bfebf 100644
--- a/drivers/net/ngbe/base/ngbe_phy.c
+++ b/drivers/net/ngbe/base/ngbe_phy.c
@@ -400,6 +400,7 @@ s32 ngbe_init_phy(struct ngbe_hw *hw)
 		hw->phy.init_hw = ngbe_init_phy_rtl;
 		hw->phy.check_link = ngbe_check_phy_link_rtl;
 		hw->phy.setup_link = ngbe_setup_phy_link_rtl;
+		hw->phy.set_phy_power = ngbe_set_phy_power_rtl;
 		hw->phy.get_adv_pause = ngbe_get_phy_advertised_pause_rtl;
 		hw->phy.get_lp_adv_pause = ngbe_get_phy_lp_advertised_pause_rtl;
 		hw->phy.set_pause_adv = ngbe_set_phy_pause_adv_rtl;
diff --git a/drivers/net/ngbe/base/ngbe_phy_rtl.c b/drivers/net/ngbe/base/ngbe_phy_rtl.c
index 33c5e79e87..9b323624ec 100644
--- a/drivers/net/ngbe/base/ngbe_phy_rtl.c
+++ b/drivers/net/ngbe/base/ngbe_phy_rtl.c
@@ -393,3 +393,16 @@ s32 ngbe_check_phy_link_rtl(struct ngbe_hw *hw, u32 *speed, bool *link_up)
 	return status;
 }
 
+s32 ngbe_set_phy_power_rtl(struct ngbe_hw *hw, bool on)
+{
+	u16 value = 0;
+
+	hw->phy.read_reg(hw, RTL_BMCR, 0, &value);
+	if (on)
+		value &= ~RTL_BMCR_PWDN;
+	else
+		value |= RTL_BMCR_PWDN;
+	hw->phy.write_reg(hw, RTL_BMCR, 0, value);
+
+	return 0;
+}
diff --git a/drivers/net/ngbe/base/ngbe_phy_rtl.h b/drivers/net/ngbe/base/ngbe_phy_rtl.h
index d717a1915c..b2fbc4f74d 100644
--- a/drivers/net/ngbe/base/ngbe_phy_rtl.h
+++ b/drivers/net/ngbe/base/ngbe_phy_rtl.h
@@ -15,6 +15,7 @@
 #define   RTL_BMCR_RESET		MS16(15, 0x1)
 #define	  RTL_BMCR_SPEED_SELECT0	MS16(13, 0x1)
 #define   RTL_BMCR_ANE			MS16(12, 0x1)
+#define   RTL_BMCR_PWDN			MS16(11, 0x1)
 #define   RTL_BMCR_RESTART_AN		MS16(9, 0x1)
 #define   RTL_BMCR_DUPLEX		MS16(8, 0x1)
 #define   RTL_BMCR_SPEED_SELECT1	MS16(6, 0x1)
@@ -88,5 +89,6 @@ s32 ngbe_get_phy_lp_advertised_pause_rtl(struct ngbe_hw *hw, u8 *pause_bit);
 s32 ngbe_set_phy_pause_adv_rtl(struct ngbe_hw *hw, u16 pause_bit);
 s32 ngbe_check_phy_link_rtl(struct ngbe_hw *hw,
 			u32 *speed, bool *link_up);
+s32 ngbe_set_phy_power_rtl(struct ngbe_hw *hw, bool on);
 
 #endif /* _NGBE_PHY_RTL_H_ */
diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c
index 1090ba9a11..afdb3ad41f 100644
--- a/drivers/net/ngbe/ngbe_ethdev.c
+++ b/drivers/net/ngbe/ngbe_ethdev.c
@@ -1219,6 +1219,32 @@ ngbe_dev_stop(struct rte_eth_dev *dev)
 	return 0;
 }
 
+/*
+ * Set device link up: power on.
+ */
+static int
+ngbe_dev_set_link_up(struct rte_eth_dev *dev)
+{
+	struct ngbe_hw *hw = ngbe_dev_hw(dev);
+
+	hw->phy.set_phy_power(hw, true);
+
+	return 0;
+}
+
+/*
+ * Set device link down: power off.
+ */
+static int
+ngbe_dev_set_link_down(struct rte_eth_dev *dev)
+{
+	struct ngbe_hw *hw = ngbe_dev_hw(dev);
+
+	hw->phy.set_phy_power(hw, false);
+
+	return 0;
+}
+
 /*
  * Reset and stop device.
  */
@@ -3030,6 +3056,8 @@ static const struct eth_dev_ops ngbe_eth_dev_ops = {
 	.dev_infos_get              = ngbe_dev_info_get,
 	.dev_start                  = ngbe_dev_start,
 	.dev_stop                   = ngbe_dev_stop,
+	.dev_set_link_up            = ngbe_dev_set_link_up,
+	.dev_set_link_down          = ngbe_dev_set_link_down,
 	.dev_close                  = ngbe_dev_close,
 	.dev_reset                  = ngbe_dev_reset,
 	.promiscuous_enable         = ngbe_dev_promiscuous_enable,
-- 
2.27.0



  parent reply	other threads:[~2022-09-02  3:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-02  3:00 [PATCH 0/9] Wangxun fixes and supports Jiawen Wu
2022-09-02  3:00 ` [PATCH 1/9] net/txgbe: fix IPv6 rule in flow director Jiawen Wu
2022-09-02  3:00 ` [PATCH 2/9] net/txgbe: fix OEM customized LED Jiawen Wu
2022-09-02  3:00 ` [PATCH 3/9] net/txgbe: remove semaphore between SW/FW Jiawen Wu
2022-09-02  3:00 ` [PATCH 4/9] net/txgbe: rename some extended statistic Jiawen Wu
2022-09-02  3:00 ` [PATCH 5/9] net/ngbe: " Jiawen Wu
2022-09-02  3:00 ` [PATCH 6/9] net/ngbe: remove semaphore between SW/FW Jiawen Wu
2022-09-02  3:00 ` [PATCH 7/9] net/ngbe: fix max frame size Jiawen Wu
2022-09-02  3:00 ` [PATCH 8/9] net/ngbe: fix YT PHY mixed mode occasionally failing link Jiawen Wu
2022-09-02  3:00 ` Jiawen Wu [this message]
2022-09-21 11:46   ` [PATCH 9/9] net/ngbe: support to set link down/up Ferruh Yigit
2022-09-13  1:55 ` [PATCH 0/9] Wangxun fixes and supports Jiawen Wu
2022-09-21 11:48 ` Ferruh Yigit

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=20220902030011.377523-10-jiawenwu@trustnetic.com \
    --to=jiawenwu@trustnetic.com \
    --cc=dev@dpdk.org \
    /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).