From: Gaetan Rivet Date: Tue, 18 Jul 2017 12:48:21 +0000 (+0200) Subject: net/failsafe: support link status change event X-Git-Tag: spdx-start~2426 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=ad7d6a35ca49f48eec7236c82c4e707cf92c388c;p=dpdk.git net/failsafe: support link status change event Signed-off-by: Gaetan Rivet --- diff --git a/doc/guides/nics/features/failsafe.ini b/doc/guides/nics/features/failsafe.ini index 2e802aa891..a42e344a70 100644 --- a/doc/guides/nics/features/failsafe.ini +++ b/doc/guides/nics/features/failsafe.ini @@ -5,6 +5,7 @@ ; [Features] Link status = Y +Link status event = Y MTU update = Y Jumbo frame = Y Promiscuous mode = Y diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c index 7628c21659..6006bef8de 100644 --- a/drivers/net/failsafe/failsafe.c +++ b/drivers/net/failsafe/failsafe.c @@ -238,6 +238,7 @@ fs_eth_dev_create(struct rte_vdev_device *vdev) mac->addr_bytes[0], mac->addr_bytes[1], mac->addr_bytes[2], mac->addr_bytes[3], mac->addr_bytes[4], mac->addr_bytes[5]); + dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; return 0; free_args: failsafe_args_free(dev); diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c index 359b8c969e..d205f61b8e 100644 --- a/drivers/net/failsafe/failsafe_ether.c +++ b/drivers/net/failsafe/failsafe_ether.c @@ -387,3 +387,21 @@ failsafe_eth_rmv_event_callback(uint8_t port_id __rte_unused, sdev->remove = 1; return 0; } + +int +failsafe_eth_lsc_event_callback(uint8_t port_id __rte_unused, + enum rte_eth_event_type event __rte_unused, + void *cb_arg, void *out __rte_unused) +{ + struct rte_eth_dev *dev = cb_arg; + int ret; + + ret = dev->dev_ops->link_update(dev, 0); + /* We must pass on the LSC event */ + if (ret) + return _rte_eth_dev_callback_process(dev, + RTE_ETH_EVENT_INTR_LSC, + NULL, NULL); + else + return 0; +} diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index e8edf15f43..ff9ad155cf 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -206,6 +206,8 @@ fs_dev_configure(struct rte_eth_dev *dev) } FOREACH_SUBDEV(sdev, i, dev) { int rmv_interrupt = 0; + int lsc_interrupt = 0; + int lsc_enabled; if (sdev->state != DEV_PROBED) continue; @@ -218,6 +220,17 @@ fs_dev_configure(struct rte_eth_dev *dev) } else { DEBUG("sub_device %d does not support RMV event", i); } + lsc_enabled = dev->data->dev_conf.intr_conf.lsc; + lsc_interrupt = lsc_enabled && + (ETH(sdev)->data->dev_flags & + RTE_ETH_DEV_INTR_LSC); + if (lsc_interrupt) { + DEBUG("Enabling LSC interrupts for sub_device %d", i); + dev->data->dev_conf.intr_conf.lsc = 1; + } else if (lsc_enabled && !lsc_interrupt) { + DEBUG("Disabling LSC interrupts for sub_device %d", i); + dev->data->dev_conf.intr_conf.lsc = 0; + } DEBUG("Configuring sub-device %d", i); sdev->remove = 0; ret = rte_eth_dev_configure(PORT_ID(sdev), @@ -238,6 +251,16 @@ fs_dev_configure(struct rte_eth_dev *dev) SUB_ID(sdev)); } dev->data->dev_conf.intr_conf.rmv = 0; + if (lsc_interrupt) { + ret = rte_eth_dev_callback_register(PORT_ID(sdev), + RTE_ETH_EVENT_INTR_LSC, + failsafe_eth_lsc_event_callback, + dev); + if (ret) + WARN("Failed to register LSC callback for sub_device %d", + SUB_ID(sdev)); + } + dev->data->dev_conf.intr_conf.lsc = lsc_enabled; sdev->state = DEV_ACTIVE; } if (PRIV(dev)->state < DEV_ACTIVE) diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h index 80bbc613d6..2c52d2ba4b 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -179,6 +179,9 @@ void failsafe_dev_remove(struct rte_eth_dev *dev); int failsafe_eth_rmv_event_callback(uint8_t port_id, enum rte_eth_event_type type, void *arg, void *out); +int failsafe_eth_lsc_event_callback(uint8_t port_id, + enum rte_eth_event_type event, + void *cb_arg, void *out); /* GLOBALS */