/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
*
* Copyright 2011-2016 Freescale Semiconductor Inc.
- * Copyright 2017 NXP
+ * Copyright 2017,2020 NXP
*
*/
#include <assert.h>
return process_portal_free(&input);
}
+
+#define DPAA_IOCTL_ENABLE_LINK_STATUS_INTERRUPT \
+ _IOW(DPAA_IOCTL_MAGIC, 0x0E, struct usdpaa_ioctl_link_status)
+
+#define DPAA_IOCTL_DISABLE_LINK_STATUS_INTERRUPT \
+ _IOW(DPAA_IOCTL_MAGIC, 0x0F, char*)
+
+int dpaa_intr_enable(char *if_name, int efd)
+{
+ struct usdpaa_ioctl_link_status args;
+
+ int ret = check_fd();
+
+ if (ret)
+ return ret;
+
+ args.efd = (uint32_t)efd;
+ strcpy(args.if_name, if_name);
+
+ ret = ioctl(fd, DPAA_IOCTL_ENABLE_LINK_STATUS_INTERRUPT, &args);
+ if (ret)
+ return errno;
+
+ return 0;
+}
+
+int dpaa_intr_disable(char *if_name)
+{
+ int ret = check_fd();
+
+ if (ret)
+ return ret;
+
+ ret = ioctl(fd, DPAA_IOCTL_DISABLE_LINK_STATUS_INTERRUPT, &if_name);
+ if (ret) {
+ if (errno == EINVAL)
+ printf("Failed to disable interrupt: Not Supported\n");
+ else
+ printf("Failed to disable interrupt\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+#define DPAA_IOCTL_GET_LINK_STATUS \
+ _IOWR(DPAA_IOCTL_MAGIC, 0x10, struct usdpaa_ioctl_link_status_args)
+
+int dpaa_get_link_status(char *if_name)
+{
+ int ret = check_fd();
+ struct usdpaa_ioctl_link_status_args args;
+
+ if (ret)
+ return ret;
+
+ strcpy(args.if_name, if_name);
+ args.link_status = 0;
+
+ ret = ioctl(fd, DPAA_IOCTL_GET_LINK_STATUS, &args);
+ if (ret) {
+ if (errno == EINVAL)
+ printf("Failed to get link status: Not Supported\n");
+ else
+ printf("Failed to get link status\n");
+ return ret;
+ }
+
+ return args.link_status;
+}
#include <fsl_qman.h>
#include <fsl_bman.h>
#include <fsl_fman.h>
+#include <process.h>
/* Supported Rx offloads */
static uint64_t dev_rx_offloads_sup =
static int
dpaa_eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info);
+static int dpaa_eth_link_update(struct rte_eth_dev *dev,
+ int wait_to_complete __rte_unused);
+
+static void dpaa_interrupt_handler(void *param);
+
static inline void
dpaa_poll_queue_default_config(struct qm_mcc_initfq *opts)
{
struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
uint64_t rx_offloads = eth_conf->rxmode.offloads;
uint64_t tx_offloads = eth_conf->txmode.offloads;
+ struct rte_device *rdev = dev->device;
+ struct rte_dpaa_device *dpaa_dev;
+ struct fman_if *fif = dev->process_private;
+ struct __fman_if *__fif;
+ struct rte_intr_handle *intr_handle;
+ int ret;
PMD_INIT_FUNC_TRACE();
+ dpaa_dev = container_of(rdev, struct rte_dpaa_device, device);
+ intr_handle = &dpaa_dev->intr_handle;
+ __fif = container_of(fif, struct __fman_if, __if);
+
/* Rx offloads which are enabled by default */
if (dev_rx_offloads_nodis & ~rx_offloads) {
DPAA_PMD_INFO(
dev->data->scattered_rx = 1;
}
+ /* if the interrupts were configured on this devices*/
+ if (intr_handle && intr_handle->fd) {
+ if (dev->data->dev_conf.intr_conf.lsc != 0)
+ rte_intr_callback_register(intr_handle,
+ dpaa_interrupt_handler,
+ (void *)dev);
+
+ ret = dpaa_intr_enable(__fif->node_name, intr_handle->fd);
+ if (ret) {
+ if (dev->data->dev_conf.intr_conf.lsc != 0) {
+ rte_intr_callback_unregister(intr_handle,
+ dpaa_interrupt_handler,
+ (void *)dev);
+ if (ret == EINVAL)
+ printf("Failed to enable interrupt: Not Supported\n");
+ else
+ printf("Failed to enable interrupt\n");
+ }
+ dev->data->dev_conf.intr_conf.lsc = 0;
+ dev->data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC;
+ }
+ }
return 0;
}
return NULL;
}
+static void dpaa_interrupt_handler(void *param)
+{
+ struct rte_eth_dev *dev = param;
+ struct rte_device *rdev = dev->device;
+ struct rte_dpaa_device *dpaa_dev;
+ struct rte_intr_handle *intr_handle;
+ uint64_t buf;
+ int bytes_read;
+
+ dpaa_dev = container_of(rdev, struct rte_dpaa_device, device);
+ intr_handle = &dpaa_dev->intr_handle;
+
+ bytes_read = read(intr_handle->fd, &buf, sizeof(uint64_t));
+ if (bytes_read < 0)
+ DPAA_PMD_ERR("Error reading eventfd\n");
+ dpaa_eth_link_update(dev, 0);
+ _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
+}
+
static int dpaa_eth_dev_start(struct rte_eth_dev *dev)
{
struct dpaa_if *dpaa_intf = dev->data->dev_private;
static void dpaa_eth_dev_close(struct rte_eth_dev *dev)
{
+ struct fman_if *fif = dev->process_private;
+ struct __fman_if *__fif;
+ struct rte_device *rdev = dev->device;
+ struct rte_dpaa_device *dpaa_dev;
+ struct rte_intr_handle *intr_handle;
+
PMD_INIT_FUNC_TRACE();
+ dpaa_dev = container_of(rdev, struct rte_dpaa_device, device);
+ intr_handle = &dpaa_dev->intr_handle;
+ __fif = container_of(fif, struct __fman_if, __if);
+
dpaa_eth_dev_stop(dev);
+
+ if (intr_handle && intr_handle->fd &&
+ dev->data->dev_conf.intr_conf.lsc != 0) {
+ dpaa_intr_disable(__fif->node_name);
+ rte_intr_callback_unregister(intr_handle,
+ dpaa_interrupt_handler,
+ (void *)dev);
+ }
}
static int
struct dpaa_if *dpaa_intf = dev->data->dev_private;
struct rte_eth_link *link = &dev->data->dev_link;
struct fman_if *fif = dev->process_private;
+ struct __fman_if *__fif = container_of(fif, struct __fman_if, __if);
+ int ret;
PMD_INIT_FUNC_TRACE();
DPAA_PMD_ERR("invalid link_speed: %s, %d",
dpaa_intf->name, fif->mac_type);
- link->link_status = dpaa_intf->valid;
+ ret = dpaa_get_link_status(__fif->node_name);
+ if (ret < 0) {
+ if (ret == -EINVAL) {
+ DPAA_PMD_DEBUG("Using default link status-No Support");
+ ret = 1;
+ } else {
+ DPAA_PMD_ERR("rte_dpaa_get_link_status %d", ret);
+ return ret;
+ }
+ }
+
+ link->link_status = ret;
link->link_duplex = ETH_LINK_FULL_DUPLEX;
link->link_autoneg = ETH_LINK_AUTONEG;
+
+ DPAA_PMD_INFO("Port %d Link is %s\n", dev->data->port_id,
+ link->link_status ? "Up" : "Down");
return 0;
}
qman_ern_register_cb(dpaa_free_mbuf);
+ if (dpaa_drv->drv_flags & RTE_DPAA_DRV_INTR_LSC)
+ eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
+
/* Invoke PMD device initialization function */
diag = dpaa_dev_init(eth_dev);
if (diag == 0) {
}
static struct rte_dpaa_driver rte_dpaa_pmd = {
+ .drv_flags = RTE_DPAA_DRV_INTR_LSC,
.drv_type = FSL_DPAA_ETH,
.probe = rte_dpaa_probe,
.remove = rte_dpaa_remove,