net/mlx5: add C++ include guard to public header
[dpdk.git] / drivers / net / dpaa2 / dpaa2_ethdev.c
index efb2feb..379daec 100644 (file)
@@ -18,6 +18,7 @@
 #include <rte_dev.h>
 #include <rte_fslmc.h>
 #include <rte_flow_driver.h>
+#include "rte_dpaa2_mempool.h"
 
 #include "dpaa2_pmd_logs.h"
 #include <fslmc_vfio.h>
@@ -398,6 +399,8 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)
        if (dpaa2_enable_err_queue) {
                priv->rx_err_vq = rte_zmalloc("dpni_rx_err",
                        sizeof(struct dpaa2_queue), 0);
+               if (!priv->rx_err_vq)
+                       goto fail;
 
                dpaa2_q = (struct dpaa2_queue *)priv->rx_err_vq;
                dpaa2_q->q_storage = rte_malloc("err_dq_storage",
@@ -667,6 +670,30 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
        if (rx_offloads & RTE_ETH_RX_OFFLOAD_VLAN_FILTER)
                dpaa2_vlan_offload_set(dev, RTE_ETH_VLAN_FILTER_MASK);
 
+       if (eth_conf->lpbk_mode) {
+               ret = dpaa2_dev_recycle_config(dev);
+               if (ret) {
+                       DPAA2_PMD_ERR("Error to configure %s to recycle port.",
+                               dev->data->name);
+
+                       return ret;
+               }
+       } else {
+               /** User may disable loopback mode by calling
+                * "dev_configure" with lpbk_mode cleared.
+                * No matter the port was configured recycle or not,
+                * recycle de-configure is called here.
+                * If port is not recycled, the de-configure will return directly.
+                */
+               ret = dpaa2_dev_recycle_deconfig(dev);
+               if (ret) {
+                       DPAA2_PMD_ERR("Error to de-configure recycle port %s.",
+                               dev->data->name);
+
+                       return ret;
+               }
+       }
+
        dpaa2_tm_init(dev);
 
        return 0;
@@ -712,9 +739,14 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,
        }
 
        if (!priv->bp_list || priv->bp_list->mp != mb_pool) {
+               if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+                       ret = rte_dpaa2_bpid_info_init(mb_pool);
+                       if (ret)
+                               return ret;
+               }
                bpid = mempool_to_bpid(mb_pool);
-               ret = dpaa2_attach_bp_list(priv,
-                                          rte_dpaa2_bpid_info[bpid].bp_list);
+               ret = dpaa2_attach_bp_list(priv, dpni,
+                               rte_dpaa2_bpid_info[bpid].bp_list);
                if (ret)
                        return ret;
        }
@@ -2595,6 +2627,9 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
                return -1;
        }
 
+       if (eth_dev->data->dev_conf.lpbk_mode)
+               dpaa2_dev_recycle_deconfig(eth_dev);
+
        /* Clean the device first */
        ret = dpni_reset(dpni_dev, CMD_PRI_LOW, priv->token);
        if (ret) {
@@ -2618,6 +2653,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
        priv->dist_queues = attr.num_queues;
        priv->num_channels = attr.num_channels;
        priv->channel_inuse = 0;
+       rte_spinlock_init(&priv->lpbk_qp_lock);
 
        /* only if the custom CG is enabled */
        if (attr.options & DPNI_OPT_CUSTOM_CG)
@@ -2802,7 +2838,9 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
                        return ret;
                }
        }
-       RTE_LOG(INFO, PMD, "%s: netdev created\n", eth_dev->data->name);
+       RTE_LOG(INFO, PMD, "%s: netdev created, connected to %s\n",
+               eth_dev->data->name, dpaa2_dev->ep_name);
+
        return 0;
 init_err:
        dpaa2_dev_close(eth_dev);