From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 66DC6A04DC; Mon, 19 Oct 2020 11:14:15 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CEDA3E2D8; Mon, 19 Oct 2020 10:54:17 +0200 (CEST) Received: from qq.com (smtpbg566.qq.com [183.3.255.187]) by dpdk.org (Postfix) with ESMTP id A5B2BCF89 for ; Mon, 19 Oct 2020 10:53:39 +0200 (CEST) X-QQ-mid: bizesmtp6t1603097614tkpzsgw7k Received: from localhost.localdomain.com (unknown [183.129.236.74]) by esmtp6.qq.com (ESMTP) with id ; Mon, 19 Oct 2020 16:53:34 +0800 (CST) X-QQ-SSF: 01400000002000C0C000B00A0000000 X-QQ-FEAT: WQsncPOZxiT9siCtNcOU6tPBJM6sejICOjWcd65VQ6E8XzDQfpj9BlcwtT4pa eSygD8ajGV4aySdaD3QFSPbMpapeRfM0kth1I3wsMG+1Vm7RLJtjl1ZZxZeqSk7JJ1nxupS BPbtFeejXXAzH9IwiQBmKbljm5kS2SxndKPgORbtFvhq1+rh3YKVeedfnclRJIn9HN7AfBy 7Nr+uO4lm2eyhlQWecsphaqSZeUnOzPFdECJ9OBV6spLPpyeQSxFQesszrahk8T4YKm4cd4 cSBvTAw+v5atGbshkts+3pvkbizW0WVSGOaXP+kknYOuSNxssyJYXTLuxLV5DLgwUM7wrgM 75G4bSGTXyJq0vUX0CWI73mn7aKww== X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Date: Mon, 19 Oct 2020 16:54:09 +0800 Message-Id: <20201019085415.82207-53-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20201019085415.82207-1-jiawenwu@trustnetic.com> References: <20201019085415.82207-1-jiawenwu@trustnetic.com> X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgweb:qybgweb13 Subject: [dpdk-dev] [PATCH v4 52/58] net/txgbe: support device LED on and off X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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/txgbe/base/txgbe_hw.c | 46 +++++++++++++++++++++++++++++++ drivers/net/txgbe/base/txgbe_hw.h | 3 ++ drivers/net/txgbe/txgbe_ethdev.c | 20 ++++++++++++++ 3 files changed, 69 insertions(+) diff --git a/drivers/net/txgbe/base/txgbe_hw.c b/drivers/net/txgbe/base/txgbe_hw.c index ab3f9b143..5ee13b0f8 100644 --- a/drivers/net/txgbe/base/txgbe_hw.c +++ b/drivers/net/txgbe/base/txgbe_hw.c @@ -560,6 +560,52 @@ s32 txgbe_stop_hw(struct txgbe_hw *hw) return 0; } +/** + * txgbe_led_on - Turns on the software controllable LEDs. + * @hw: pointer to hardware structure + * @index: led number to turn on + **/ +s32 txgbe_led_on(struct txgbe_hw *hw, u32 index) +{ + u32 led_reg = rd32(hw, TXGBE_LEDCTL); + + DEBUGFUNC("txgbe_led_on"); + + if (index > 4) + return TXGBE_ERR_PARAM; + + /* To turn on the LED, set mode to ON. */ + led_reg |= TXGBE_LEDCTL_SEL(index); + led_reg |= TXGBE_LEDCTL_ORD(index); + wr32(hw, TXGBE_LEDCTL, led_reg); + txgbe_flush(hw); + + return 0; +} + +/** + * txgbe_led_off - Turns off the software controllable LEDs. + * @hw: pointer to hardware structure + * @index: led number to turn off + **/ +s32 txgbe_led_off(struct txgbe_hw *hw, u32 index) +{ + u32 led_reg = rd32(hw, TXGBE_LEDCTL); + + DEBUGFUNC("txgbe_led_off"); + + if (index > 4) + return TXGBE_ERR_PARAM; + + /* To turn off the LED, set mode to OFF. */ + led_reg &= ~(TXGBE_LEDCTL_SEL(index)); + led_reg &= ~(TXGBE_LEDCTL_ORD(index)); + wr32(hw, TXGBE_LEDCTL, led_reg); + txgbe_flush(hw); + + return 0; +} + /** * txgbe_validate_mac_addr - Validate MAC address * @mac_addr: pointer to MAC address. diff --git a/drivers/net/txgbe/base/txgbe_hw.h b/drivers/net/txgbe/base/txgbe_hw.h index 02369d6df..09298ea0c 100644 --- a/drivers/net/txgbe/base/txgbe_hw.h +++ b/drivers/net/txgbe/base/txgbe_hw.h @@ -16,6 +16,9 @@ s32 txgbe_get_mac_addr(struct txgbe_hw *hw, u8 *mac_addr); void txgbe_set_lan_id_multi_port(struct txgbe_hw *hw); +s32 txgbe_led_on(struct txgbe_hw *hw, u32 index); +s32 txgbe_led_off(struct txgbe_hw *hw, u32 index); + s32 txgbe_set_rar(struct txgbe_hw *hw, u32 index, u8 *addr, u32 vmdq, u32 enable_addr); s32 txgbe_clear_rar(struct txgbe_hw *hw, u32 index); diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index 86d0a5ac9..de5523860 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -2842,6 +2842,24 @@ txgbe_dev_interrupt_handler(void *param) txgbe_dev_interrupt_action(dev, dev->intr_handle); } +static int +txgbe_dev_led_on(struct rte_eth_dev *dev) +{ + struct txgbe_hw *hw; + + hw = TXGBE_DEV_HW(dev); + return txgbe_led_on(hw, 4) == 0 ? 0 : -ENOTSUP; +} + +static int +txgbe_dev_led_off(struct rte_eth_dev *dev) +{ + struct txgbe_hw *hw; + + hw = TXGBE_DEV_HW(dev); + return txgbe_led_off(hw, 4) == 0 ? 0 : -ENOTSUP; +} + static int txgbe_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) { @@ -3697,6 +3715,8 @@ static const struct eth_dev_ops txgbe_eth_dev_ops = { .rx_queue_release = txgbe_dev_rx_queue_release, .tx_queue_setup = txgbe_dev_tx_queue_setup, .tx_queue_release = txgbe_dev_tx_queue_release, + .dev_led_on = txgbe_dev_led_on, + .dev_led_off = txgbe_dev_led_off, .flow_ctrl_get = txgbe_flow_ctrl_get, .flow_ctrl_set = txgbe_flow_ctrl_set, .priority_flow_ctrl_set = txgbe_priority_flow_ctrl_set, -- 2.18.4