From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 56731A0542; Fri, 2 Sep 2022 05:01:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BD5E542B6F; Fri, 2 Sep 2022 05:01:10 +0200 (CEST) Received: from smtpbg.qq.com (smtpbgjp3.qq.com [54.92.39.34]) by mails.dpdk.org (Postfix) with ESMTP id A658542B79 for ; Fri, 2 Sep 2022 05:01:08 +0200 (CEST) X-QQ-mid: bizesmtp70t1662087665tle42ch8 Received: from wxdbg.localdomain.com ( [183.129.236.74]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 02 Sep 2022 11:01:04 +0800 (CST) X-QQ-SSF: 01400000000000G0T000000A0000000 X-QQ-FEAT: t7ADaf3T+WRR9ZxkIHN5xBDu91ekpXhGs3Rp2JzYj6+jlN8v4/3ug5who/HCJ cGi1pUNC670Vns+f3Br4Wl9+vbeXQfBnooqE+kAOkV5WQXgsesITOF2QgYTYqfDAL4cYSys 7GN1dS3a+m+4WWg2i2jFpG2epmwd7vkvqHNv8qB1ZuEpFG4GzgKLZpIvtjkg88+s/nBKP+c HrGNKuvuiRKVx5Hrp3x6MdSfAVFKoR47KkWq8bex2rKD+pAuU0lZqCeMnVW3uN38MsrD1sA HD+ddqNIjHMAGYoyJPbDKKLTfdcGr5XVLg2iV1ZDAhRxSEBWInqvYECjsgK2sUidJoKy4Kj ZD1Y/F3zkBLKlgHqZ1BF/ykoa9QtAMWSqS7oQFGHPGZdF5S7K14GdnnNzFxT+0IUTzF8SUR X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Subject: [PATCH 9/9] net/ngbe: support to set link down/up Date: Fri, 2 Sep 2022 11:00:11 +0800 Message-Id: <20220902030011.377523-10-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220902030011.377523-1-jiawenwu@trustnetic.com> References: <20220902030011.377523-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybglogicsvr:qybglogicsvr5 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add support to set device link down/up. Signed-off-by: Jiawen Wu --- 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