net/mlx5: support device removal event

Extend the LSC event handling to support the device removal as well.

The mlx5 event handling has been made capable of receiving and
signaling several event types at once.

This support includes next:
1. Removal event detection according to the user configuration.
2. Calling to all registered mlx5 removal callbacks.
3. Capabilities extension to include removal interrupt handling.

Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
This commit is contained in:
Matan Azrad 2017-09-08 13:47:45 +03:00 committed by Ferruh Yigit
parent c26ae06937
commit 7d7d7ad1e6
3 changed files with 13 additions and 3 deletions

View File

@ -7,6 +7,7 @@
Speed capabilities = Y Speed capabilities = Y
Link status = Y Link status = Y
Link status event = Y Link status event = Y
Removal event = Y
Rx interrupt = Y Rx interrupt = Y
Queue start/stop = Y Queue start/stop = Y
MTU update = Y MTU update = Y

View File

@ -871,7 +871,7 @@ static struct rte_pci_driver mlx5_driver = {
}, },
.id_table = mlx5_pci_id_map, .id_table = mlx5_pci_id_map,
.probe = mlx5_pci_probe, .probe = mlx5_pci_probe,
.drv_flags = RTE_PCI_DRV_INTR_LSC, .drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_INTR_RMV,
}; };
/** /**

View File

@ -1173,6 +1173,9 @@ priv_dev_status_handler(struct priv *priv)
event.event_type == IBV_EVENT_PORT_ERR) && event.event_type == IBV_EVENT_PORT_ERR) &&
(priv->dev->data->dev_conf.intr_conf.lsc == 1)) (priv->dev->data->dev_conf.intr_conf.lsc == 1))
ret |= (1 << RTE_ETH_EVENT_INTR_LSC); ret |= (1 << RTE_ETH_EVENT_INTR_LSC);
else if (event.event_type == IBV_EVENT_DEVICE_FATAL &&
priv->dev->data->dev_conf.intr_conf.rmv == 1)
ret |= (1 << RTE_ETH_EVENT_INTR_RMV);
else else
DEBUG("event type %d on port %d not handled", DEBUG("event type %d on port %d not handled",
event.event_type, event.element.port_num); event.event_type, event.element.port_num);
@ -1228,6 +1231,9 @@ mlx5_dev_interrupt_handler(void *cb_arg)
if (events & (1 << RTE_ETH_EVENT_INTR_LSC)) if (events & (1 << RTE_ETH_EVENT_INTR_LSC))
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL, _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL,
NULL); NULL);
if (events & (1 << RTE_ETH_EVENT_INTR_RMV))
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RMV, NULL,
NULL);
} }
/** /**
@ -1241,7 +1247,8 @@ mlx5_dev_interrupt_handler(void *cb_arg)
void void
priv_dev_interrupt_handler_uninstall(struct priv *priv, struct rte_eth_dev *dev) priv_dev_interrupt_handler_uninstall(struct priv *priv, struct rte_eth_dev *dev)
{ {
if (!dev->data->dev_conf.intr_conf.lsc) if (!dev->data->dev_conf.intr_conf.lsc &&
!dev->data->dev_conf.intr_conf.rmv)
return; return;
rte_intr_callback_unregister(&priv->intr_handle, rte_intr_callback_unregister(&priv->intr_handle,
mlx5_dev_interrupt_handler, mlx5_dev_interrupt_handler,
@ -1266,7 +1273,8 @@ priv_dev_interrupt_handler_install(struct priv *priv, struct rte_eth_dev *dev)
{ {
int rc, flags; int rc, flags;
if (!dev->data->dev_conf.intr_conf.lsc) if (!dev->data->dev_conf.intr_conf.lsc &&
!dev->data->dev_conf.intr_conf.rmv)
return; return;
assert(priv->ctx->async_fd > 0); assert(priv->ctx->async_fd > 0);
flags = fcntl(priv->ctx->async_fd, F_GETFL); flags = fcntl(priv->ctx->async_fd, F_GETFL);
@ -1274,6 +1282,7 @@ priv_dev_interrupt_handler_install(struct priv *priv, struct rte_eth_dev *dev)
if (rc < 0) { if (rc < 0) {
INFO("failed to change file descriptor async event queue"); INFO("failed to change file descriptor async event queue");
dev->data->dev_conf.intr_conf.lsc = 0; dev->data->dev_conf.intr_conf.lsc = 0;
dev->data->dev_conf.intr_conf.rmv = 0;
} else { } else {
priv->intr_handle.fd = priv->ctx->async_fd; priv->intr_handle.fd = priv->ctx->async_fd;
priv->intr_handle.type = RTE_INTR_HANDLE_EXT; priv->intr_handle.type = RTE_INTR_HANDLE_EXT;