From patchwork Thu Oct 21 09:50:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiawen Wu X-Patchwork-Id: 102564 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1555EA0547; Thu, 21 Oct 2021 11:53:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CE25E41266; Thu, 21 Oct 2021 11:51:16 +0200 (CEST) Received: from smtpbgau1.qq.com (smtpbgau1.qq.com [54.206.16.166]) by mails.dpdk.org (Postfix) with ESMTP id 845EC41250 for ; Thu, 21 Oct 2021 11:51:12 +0200 (CEST) X-QQ-mid: bizesmtp38t1634809867tdu999kg Received: from jiawenwu.trustnetic.com (unknown [183.129.236.74]) by esmtp6.qq.com (ESMTP) with id ; Thu, 21 Oct 2021 17:51:06 +0800 (CST) X-QQ-SSF: 01400000000000E0I000000A0000000 X-QQ-FEAT: YSwSv5UBo8ihXWU1VRUix6qoNuDlOXG5g99LgpZ1H0JJPxdLLRQT+/rJaGdHi lCRCu9b06A1tPJeMUimVuv2YN/l1PSU141g2LzMEi0LnkWlfeyTPoAbB1Us48FN5+fu+k6E 8y7fqTJdURrR/yJ7V0twkyLlpfCUp5jqWauCtgumk3ELb1dc9AwLDRVUjSV+GrHJ8GoP1qm r5TsMyvBpwKZEja6iaA9K4UImM1a2aE4tctCOmBxBc+VVg17EU/3v6uchO/wmQZdMa+ulbu j7yPpSP9wtKAZYexsuVAQd7G+N0PymjW9HBP/LG7Jbw95L4oHdGADx/fqvVWSNutcR7p1L7 ZuX5VGuVBIj11oX6deGdEL0vq8CIA0mWoshtP27a6BFhopet4w= X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Date: Thu, 21 Oct 2021 17:50:17 +0800 Message-Id: <20211021095023.18288-21-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20211021095023.18288-1-jiawenwu@trustnetic.com> References: <20211021095023.18288-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgforeign:qybgforeign2 X-QQ-Bgrelay: 1 Subject: [dpdk-dev] [PATCH v2 20/26] net/ngbe: support device LED on and off 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 Sender: "dev" Support device LED on and off. Signed-off-by: Jiawen Wu --- drivers/net/ngbe/base/ngbe_dummy.h | 10 +++++++ drivers/net/ngbe/base/ngbe_hw.c | 48 ++++++++++++++++++++++++++++++ drivers/net/ngbe/base/ngbe_hw.h | 3 ++ drivers/net/ngbe/base/ngbe_type.h | 4 +++ drivers/net/ngbe/ngbe_ethdev.c | 16 ++++++++++ 5 files changed, 81 insertions(+) diff --git a/drivers/net/ngbe/base/ngbe_dummy.h b/drivers/net/ngbe/base/ngbe_dummy.h index 0baabcbae7..9930a3a1d6 100644 --- a/drivers/net/ngbe/base/ngbe_dummy.h +++ b/drivers/net/ngbe/base/ngbe_dummy.h @@ -104,6 +104,14 @@ static inline s32 ngbe_mac_get_link_capabilities_dummy(struct ngbe_hw *TUP0, { return NGBE_ERR_OPS_DUMMY; } +static inline s32 ngbe_mac_led_on_dummy(struct ngbe_hw *TUP0, u32 TUP1) +{ + return NGBE_ERR_OPS_DUMMY; +} +static inline s32 ngbe_mac_led_off_dummy(struct ngbe_hw *TUP0, u32 TUP1) +{ + return NGBE_ERR_OPS_DUMMY; +} static inline s32 ngbe_mac_set_rar_dummy(struct ngbe_hw *TUP0, u32 TUP1, u8 *TUP2, u32 TUP3, u32 TUP4) { @@ -278,6 +286,8 @@ static inline void ngbe_init_ops_dummy(struct ngbe_hw *hw) hw->mac.setup_link = ngbe_mac_setup_link_dummy; hw->mac.check_link = ngbe_mac_check_link_dummy; hw->mac.get_link_capabilities = ngbe_mac_get_link_capabilities_dummy; + hw->mac.led_on = ngbe_mac_led_on_dummy; + hw->mac.led_off = ngbe_mac_led_off_dummy; hw->mac.set_rar = ngbe_mac_set_rar_dummy; hw->mac.clear_rar = ngbe_mac_clear_rar_dummy; hw->mac.set_vmdq = ngbe_mac_set_vmdq_dummy; diff --git a/drivers/net/ngbe/base/ngbe_hw.c b/drivers/net/ngbe/base/ngbe_hw.c index 8262e50a80..cd547eee6f 100644 --- a/drivers/net/ngbe/base/ngbe_hw.c +++ b/drivers/net/ngbe/base/ngbe_hw.c @@ -390,6 +390,50 @@ s32 ngbe_stop_hw(struct ngbe_hw *hw) return 0; } +/** + * ngbe_led_on - Turns on the software controllable LEDs. + * @hw: pointer to hardware structure + * @index: led number to turn on + **/ +s32 ngbe_led_on(struct ngbe_hw *hw, u32 index) +{ + u32 led_reg = rd32(hw, NGBE_LEDCTL); + + DEBUGFUNC("ngbe_led_on"); + + if (index > 3) + return NGBE_ERR_PARAM; + + /* To turn on the LED, set mode to ON. */ + led_reg |= NGBE_LEDCTL_100M; + wr32(hw, NGBE_LEDCTL, led_reg); + ngbe_flush(hw); + + return 0; +} + +/** + * ngbe_led_off - Turns off the software controllable LEDs. + * @hw: pointer to hardware structure + * @index: led number to turn off + **/ +s32 ngbe_led_off(struct ngbe_hw *hw, u32 index) +{ + u32 led_reg = rd32(hw, NGBE_LEDCTL); + + DEBUGFUNC("ngbe_led_off"); + + if (index > 3) + return NGBE_ERR_PARAM; + + /* To turn off the LED, set mode to OFF. */ + led_reg &= ~NGBE_LEDCTL_100M; + wr32(hw, NGBE_LEDCTL, led_reg); + ngbe_flush(hw); + + return 0; +} + /** * ngbe_validate_mac_addr - Validate MAC address * @mac_addr: pointer to MAC address. @@ -1836,6 +1880,10 @@ s32 ngbe_init_ops_pf(struct ngbe_hw *hw) mac->disable_sec_rx_path = ngbe_disable_sec_rx_path; mac->enable_sec_rx_path = ngbe_enable_sec_rx_path; + /* LEDs */ + mac->led_on = ngbe_led_on; + mac->led_off = ngbe_led_off; + /* RAR, VLAN, Multicast */ mac->set_rar = ngbe_set_rar; mac->clear_rar = ngbe_clear_rar; diff --git a/drivers/net/ngbe/base/ngbe_hw.h b/drivers/net/ngbe/base/ngbe_hw.h index a84ddca6ac..ad7e8fc2d9 100644 --- a/drivers/net/ngbe/base/ngbe_hw.h +++ b/drivers/net/ngbe/base/ngbe_hw.h @@ -32,6 +32,9 @@ s32 ngbe_setup_mac_link_em(struct ngbe_hw *hw, u32 speed, bool autoneg_wait_to_complete); +s32 ngbe_led_on(struct ngbe_hw *hw, u32 index); +s32 ngbe_led_off(struct ngbe_hw *hw, u32 index); + s32 ngbe_set_rar(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq, u32 enable_addr); s32 ngbe_clear_rar(struct ngbe_hw *hw, u32 index); diff --git a/drivers/net/ngbe/base/ngbe_type.h b/drivers/net/ngbe/base/ngbe_type.h index 310d32ecfa..886dffc0db 100644 --- a/drivers/net/ngbe/base/ngbe_type.h +++ b/drivers/net/ngbe/base/ngbe_type.h @@ -265,6 +265,10 @@ struct ngbe_mac_info { s32 (*get_link_capabilities)(struct ngbe_hw *hw, u32 *speed, bool *autoneg); + /* LED */ + s32 (*led_on)(struct ngbe_hw *hw, u32 index); + s32 (*led_off)(struct ngbe_hw *hw, u32 index); + /* RAR */ s32 (*set_rar)(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq, u32 enable_addr); diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c index 94d6de15f9..93072f5f34 100644 --- a/drivers/net/ngbe/ngbe_ethdev.c +++ b/drivers/net/ngbe/ngbe_ethdev.c @@ -2188,6 +2188,20 @@ ngbe_dev_interrupt_handler(void *param) ngbe_dev_interrupt_action(dev); } +static int +ngbe_dev_led_on(struct rte_eth_dev *dev) +{ + struct ngbe_hw *hw = ngbe_dev_hw(dev); + return hw->mac.led_on(hw, 0) == 0 ? 0 : -ENOTSUP; +} + +static int +ngbe_dev_led_off(struct rte_eth_dev *dev) +{ + struct ngbe_hw *hw = ngbe_dev_hw(dev); + return hw->mac.led_off(hw, 0) == 0 ? 0 : -ENOTSUP; +} + static int ngbe_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) { @@ -2692,6 +2706,8 @@ static const struct eth_dev_ops ngbe_eth_dev_ops = { .rx_queue_release = ngbe_dev_rx_queue_release, .tx_queue_setup = ngbe_dev_tx_queue_setup, .tx_queue_release = ngbe_dev_tx_queue_release, + .dev_led_on = ngbe_dev_led_on, + .dev_led_off = ngbe_dev_led_off, .flow_ctrl_get = ngbe_flow_ctrl_get, .flow_ctrl_set = ngbe_flow_ctrl_set, .mac_addr_add = ngbe_add_rar,