Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
---
drivers/net/atlantic/Makefile | 4 +++
drivers/net/atlantic/atl_ethdev.c | 55 +++++++++++++++++++++++++++++++++
drivers/net/atlantic/atl_ethdev.h | 2 ++
drivers/net/atlantic/meson.build | 3 ++
drivers/net/atlantic/rte_pmd_atlantic.c | 19 ++++++++++++
drivers/net/atlantic/rte_pmd_atlantic.h | 44 ++++++++++++++++++++++++++
6 files changed, 127 insertions(+)
create mode 100644 drivers/net/atlantic/rte_pmd_atlantic.c
create mode 100644 drivers/net/atlantic/rte_pmd_atlantic.h
@@ -32,5 +32,9 @@ VPATH += $(SRCDIR)/hw_atl
# all source are stored in SRCS-y
#
SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_ethdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += rte_pmd_atlantic.c
+
+# install this header file
+SYMLINK-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD)-include := rte_pmd_atlantic.h
include $(RTE_SDK)/mk/rte.lib.mk
@@ -66,6 +66,11 @@ static void atl_dev_info_get(struct rte_eth_dev *dev,
static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev);
+
+/* LEDs */
+static int atl_dev_led_on(struct rte_eth_dev *dev);
+static int atl_dev_led_off(struct rte_eth_dev *dev);
+
/* EEPROM */
static int atl_dev_get_eeprom_length(struct rte_eth_dev *dev);
static int atl_dev_get_eeprom(struct rte_eth_dev *dev,
@@ -188,6 +193,11 @@ static const struct eth_dev_ops atl_eth_dev_ops = {
.get_reg = atl_dev_get_regs,
+
+ /* LEDs */
+ .dev_led_on = atl_dev_led_on,
+ .dev_led_off = atl_dev_led_off,
+
/* EEPROM */
.get_eeprom_length = atl_dev_get_eeprom_length,
.get_eeprom = atl_dev_get_eeprom,
@@ -866,6 +876,51 @@ atl_dev_interrupt_handler(void *param)
atl_dev_interrupt_action(dev, dev->intr_handle);
}
+/**
+ * LED ON Enables software controllable LED blinking.
+ * LED status then is independent of link status or traffic
+ */
+static int
+atl_dev_led_on(struct rte_eth_dev *dev)
+{
+ struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+ if (hw->aq_fw_ops->led_control == NULL)
+ return -ENOTSUP;
+
+ return hw->aq_fw_ops->led_control(hw,
+ AQ_HW_LED_BLINK |
+ (AQ_HW_LED_BLINK << 2) |
+ (AQ_HW_LED_BLINK << 4));
+}
+
+/**
+ * LED OFF disables software controllable LED blinking
+ * LED is controlled by default logic and depends on link status and
+ * traffic activity
+ */
+static int
+atl_dev_led_off(struct rte_eth_dev *dev)
+{
+ struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+ if (hw->aq_fw_ops->led_control == NULL)
+ return -ENOTSUP;
+
+ return hw->aq_fw_ops->led_control(hw, AQ_HW_LED_DEFAULT);
+}
+
+int
+atl_dev_led_control(struct rte_eth_dev *dev, int control)
+{
+ struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+ if (hw->aq_fw_ops->led_control == NULL)
+ return -ENOTSUP;
+
+ return hw->aq_fw_ops->led_control(hw, control);
+}
+
#define SFP_EEPROM_SIZE 0xff
static int
@@ -46,4 +46,6 @@ struct atl_adapter {
#define ATL_DEV_PRIVATE_TO_CFG(adapter) \
(&((struct atl_adapter *)adapter)->hw_cfg)
+int
+atl_dev_led_control(struct rte_eth_dev *dev, int control);
#endif /* _ATLANTIC_ETHDEV_H_ */
@@ -5,6 +5,7 @@
sources = files(
'atl_ethdev.c',
+ 'rte_pmd_atlantic.c',
)
deps += ['hash', 'eal']
@@ -17,3 +18,5 @@ if get_option('buildtype') == 'debug'
endif
allow_experimental_apis = true
+
+install_headers('rte_pmd_atlantic.h')
new file mode 100644
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Aquantia Corporation
+ */
+
+#include <rte_ethdev_driver.h>
+
+#include "rte_pmd_atlantic.h"
+#include "atl_ethdev.h"
+
+int rte_pmd_atl_dev_led_control(int port, int control)
+{
+ struct rte_eth_dev *dev;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+ dev = &rte_eth_devices[port];
+
+ return atl_dev_led_control(dev, control);
+}
new file mode 100644
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Aquantia Corporation
+ */
+
+/**
+ * @file rte_pmd_atlantic.h
+ * atlantic PMD specific functions.
+ *
+ **/
+
+#ifndef _PMD_ATLANTIC_H_
+#define _PMD_ATLANTIC_H_
+
+#include <rte_ethdev_driver.h>
+
+#define RTE_PMD_AQ_HW_LED_OFF 0x3U
+#define RTE_PMD_AQ_HW_LED_BLINK 0x2U
+#define RTE_PMD_AQ_HW_LED_ON 0x1U
+#define RTE_PMD_AQ_HW_LED_DEFAULT 0x0U
+
+/**
+ * This is a custom API for adapter's LED controls.
+ *
+ * @param dev
+ * Ethernet device to apply control to
+ * @param control
+ * 6 bit value (3 leds each 2bit):
+ * - bits 0-1: LED0 control
+ * - bits 2-3: LED1 control
+ * - bits 4-5: LED2 control
+ * Each two bit control value is:
+ * - 0: Firmware manages this LED activity
+ * - 1: Permanent ON
+ * - 2: Blinking
+ * - 3: Permanent OFF
+ *
+ * @return
+ * - (0) if successful.
+ * - (-ENOTSUP) if hardware doesn't support.
+ */
+int rte_pmd_atl_dev_led_control(int port, int control);
+
+
+#endif /* _PMD_ATLANTIC_H_ */