#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
/* Verbs headers do not support -pedantic. */
#ifdef PEDANTIC
/**
* DPDK callback for Ethernet device configuration.
*
- * Prepare the driver for a given number of TX and RX queues.
- *
* @param dev
* Pointer to Ethernet device structure.
*
mlx4_dev_configure(struct rte_eth_dev *dev)
{
struct priv *priv = dev->data->dev_private;
- unsigned int rxqs_n = dev->data->nb_rx_queues;
- unsigned int txqs_n = dev->data->nb_tx_queues;
-
- priv->rxqs = (void *)dev->data->rx_queues;
- priv->txqs = (void *)dev->data->tx_queues;
- if (txqs_n != priv->txqs_n) {
- INFO("%p: TX queues number update: %u -> %u",
- (void *)dev, priv->txqs_n, txqs_n);
- priv->txqs_n = txqs_n;
- }
- if (rxqs_n != priv->rxqs_n) {
- INFO("%p: Rx queues number update: %u -> %u",
- (void *)dev, priv->rxqs_n, rxqs_n);
- priv->rxqs_n = rxqs_n;
- }
- return 0;
+ int ret;
+
+ /* Prepare internal flow rules. */
+ ret = mlx4_flow_sync(priv);
+ if (ret)
+ ERROR("cannot set up internal flow rules: %s",
+ strerror(-ret));
+ return ret;
}
/**
return 0;
DEBUG("%p: attaching configured flows to all RX queues", (void *)dev);
priv->started = 1;
- ret = mlx4_mac_addr_add(priv);
- if (ret)
- goto err;
ret = mlx4_intr_install(priv);
if (ret) {
ERROR("%p: interrupt handler installation failed",
return 0;
err:
/* Rollback. */
- mlx4_mac_addr_del(priv);
priv->started = 0;
return ret;
}
priv->started = 0;
mlx4_flow_stop(priv);
mlx4_intr_uninstall(priv);
- mlx4_mac_addr_del(priv);
}
/**
mlx4_dev_close(struct rte_eth_dev *dev)
{
struct priv *priv = dev->data->dev_private;
- void *tmp;
unsigned int i;
if (priv == NULL)
DEBUG("%p: closing device \"%s\"",
(void *)dev,
((priv->ctx != NULL) ? priv->ctx->device->name : ""));
- mlx4_mac_addr_del(priv);
- /*
- * Prevent crashes when queues are still in use. This is unfortunately
- * still required for DPDK 1.3 because some programs (such as testpmd)
- * never release them before closing the device.
- */
+ mlx4_flow_clean(priv);
dev->rx_pkt_burst = mlx4_rx_burst_removed;
dev->tx_pkt_burst = mlx4_tx_burst_removed;
- if (priv->rxqs != NULL) {
- /* XXX race condition if mlx4_rx_burst() is still running. */
- usleep(1000);
- for (i = 0; (i != priv->rxqs_n); ++i) {
- tmp = (*priv->rxqs)[i];
- if (tmp == NULL)
- continue;
- (*priv->rxqs)[i] = NULL;
- mlx4_rxq_cleanup(tmp);
- rte_free(tmp);
- }
- priv->rxqs_n = 0;
- priv->rxqs = NULL;
- }
- if (priv->txqs != NULL) {
- /* XXX race condition if mlx4_tx_burst() is still running. */
- usleep(1000);
- for (i = 0; (i != priv->txqs_n); ++i) {
- tmp = (*priv->txqs)[i];
- if (tmp == NULL)
- continue;
- (*priv->txqs)[i] = NULL;
- mlx4_txq_cleanup(tmp);
- rte_free(tmp);
- }
- priv->txqs_n = 0;
- priv->txqs = NULL;
- }
+ for (i = 0; i != dev->data->nb_rx_queues; ++i)
+ mlx4_rx_queue_release(dev->data->rx_queues[i]);
+ for (i = 0; i != dev->data->nb_tx_queues; ++i)
+ mlx4_tx_queue_release(dev->data->tx_queues[i]);
if (priv->pd != NULL) {
assert(priv->ctx != NULL);
claim_zero(ibv_dealloc_pd(priv->pd));
mac.addr_bytes[4], mac.addr_bytes[5]);
/* Register MAC address. */
priv->mac = mac;
- if (mlx4_mac_addr_add(priv))
- goto port_error;
#ifndef NDEBUG
{
char ifname[IF_NAMESIZE];