New upstream version 17.11.5
[deb_dpdk.git] / drivers / net / mlx5 / mlx5_trigger.c
index 214543f..e6a29cb 100644 (file)
@@ -73,19 +73,11 @@ mlx5_txq_start(struct rte_eth_dev *dev)
        unsigned int i;
        int ret;
 
-       /* Add memory regions to Tx queues. */
        for (i = 0; i != priv->txqs_n; ++i) {
-               unsigned int idx = 0;
-               struct mlx5_mr *mr;
                struct mlx5_txq_ctrl *txq_ctrl = mlx5_txq_get(dev, i);
 
                if (!txq_ctrl)
                        continue;
-               LIST_FOREACH(mr, &priv->mr, next) {
-                       mlx5_txq_mp2mr_reg(&txq_ctrl->txq, mr->mp, idx++);
-                       if (idx == MLX5_PMD_TX_MP_CACHE)
-                               break;
-               }
                txq_alloc_elts(txq_ctrl);
                txq_ctrl->ibv = mlx5_txq_ibv_new(dev, i);
                if (!txq_ctrl->ibv) {
@@ -94,12 +86,17 @@ mlx5_txq_start(struct rte_eth_dev *dev)
                }
        }
        ret = mlx5_tx_uar_remap(dev, priv->ctx->cmd_fd);
-       if (ret)
+       if (ret) {
+               /* Adjust index for rollback. */
+               i = priv->txqs_n - 1;
                goto error;
+       }
        return 0;
 error:
        ret = rte_errno; /* Save rte_errno before cleanup. */
-       mlx5_txq_stop(dev);
+       do {
+               mlx5_txq_release(dev, i);
+       } while (i-- != 0);
        rte_errno = ret; /* Restore rte_errno. */
        return -rte_errno;
 }
@@ -151,7 +148,9 @@ mlx5_rxq_start(struct rte_eth_dev *dev)
        return 0;
 error:
        ret = rte_errno; /* Save rte_errno before cleanup. */
-       mlx5_rxq_stop(dev);
+       do {
+               mlx5_rxq_release(dev, i);
+       } while (i-- != 0);
        rte_errno = ret; /* Restore rte_errno. */
        return -rte_errno;
 }
@@ -171,31 +170,29 @@ int
 mlx5_dev_start(struct rte_eth_dev *dev)
 {
        struct priv *priv = dev->data->dev_private;
-       struct mlx5_mr *mr = NULL;
        int ret;
 
-       dev->data->dev_started = 1;
+       DRV_LOG(DEBUG, "port %u starting device", dev->data->port_id);
        ret = mlx5_flow_create_drop_queue(dev);
        if (ret) {
                DRV_LOG(ERR, "port %u drop queue allocation failed: %s",
                        dev->data->port_id, strerror(rte_errno));
                goto error;
        }
-       DRV_LOG(DEBUG, "port %u allocating and configuring hash Rx queues",
-               dev->data->port_id);
-       rte_mempool_walk(mlx5_mp2mr_iter, priv);
        ret = mlx5_txq_start(dev);
        if (ret) {
                DRV_LOG(ERR, "port %u Tx queue allocation failed: %s",
                        dev->data->port_id, strerror(rte_errno));
-               goto error;
+               return -rte_errno;
        }
        ret = mlx5_rxq_start(dev);
        if (ret) {
                DRV_LOG(ERR, "port %u Rx queue allocation failed: %s",
                        dev->data->port_id, strerror(rte_errno));
-               goto error;
+               mlx5_txq_stop(dev);
+               return -rte_errno;
        }
+       dev->data->dev_started = 1;
        ret = mlx5_rx_intr_vec_enable(dev);
        if (ret) {
                DRV_LOG(ERR, "port %u Rx interrupt vector creation failed",
@@ -223,8 +220,6 @@ error:
        ret = rte_errno; /* Save rte_errno before cleanup. */
        /* Rollback. */
        dev->data->dev_started = 0;
-       for (mr = LIST_FIRST(&priv->mr); mr; mr = LIST_FIRST(&priv->mr))
-               mlx5_mr_release(mr);
        mlx5_flow_stop(dev, &priv->flows);
        mlx5_traffic_disable(dev);
        mlx5_txq_stop(dev);
@@ -246,7 +241,6 @@ void
 mlx5_dev_stop(struct rte_eth_dev *dev)
 {
        struct priv *priv = dev->data->dev_private;
-       struct mlx5_mr *mr;
 
        dev->data->dev_started = 0;
        /* Prevent crashes when queues are still in use. */
@@ -254,16 +248,13 @@ mlx5_dev_stop(struct rte_eth_dev *dev)
        dev->tx_pkt_burst = removed_tx_burst;
        rte_wmb();
        usleep(1000 * priv->rxqs_n);
-       DRV_LOG(DEBUG, "port %u cleaning up and destroying hash Rx queues",
-               dev->data->port_id);
+       DRV_LOG(DEBUG, "port %u stopping device", dev->data->port_id);
        mlx5_flow_stop(dev, &priv->flows);
        mlx5_traffic_disable(dev);
        mlx5_rx_intr_vec_disable(dev);
        mlx5_dev_interrupt_handler_uninstall(dev);
        mlx5_txq_stop(dev);
        mlx5_rxq_stop(dev);
-       for (mr = LIST_FIRST(&priv->mr); mr; mr = LIST_FIRST(&priv->mr))
-               mlx5_mr_release(mr);
        mlx5_flow_delete_drop_queue(dev);
 }
 
@@ -336,9 +327,8 @@ mlx5_traffic_enable(struct rte_eth_dev *dev)
                        struct rte_flow_item_vlan vlan_spec = {
                                .tci = rte_cpu_to_be_16(vlan),
                        };
-                       struct rte_flow_item_vlan vlan_mask = {
-                               .tci = 0xffff,
-                       };
+                       struct rte_flow_item_vlan vlan_mask =
+                               rte_flow_item_vlan_mask;
 
                        ret = mlx5_ctrl_flow_vlan(dev, &bcast, &bcast,
                                                  &vlan_spec, &vlan_mask);
@@ -375,9 +365,8 @@ mlx5_traffic_enable(struct rte_eth_dev *dev)
                        struct rte_flow_item_vlan vlan_spec = {
                                .tci = rte_cpu_to_be_16(vlan),
                        };
-                       struct rte_flow_item_vlan vlan_mask = {
-                               .tci = 0xffff,
-                       };
+                       struct rte_flow_item_vlan vlan_mask =
+                               rte_flow_item_vlan_mask;
 
                        ret = mlx5_ctrl_flow_vlan(dev, &unicast,
                                                  &unicast_mask,