net/hns3: fix return value for unsupported tuple
[dpdk.git] / drivers / net / dpaa2 / dpaa2_ethdev.c
index 37a6db4..52eb6df 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",
@@ -507,8 +510,7 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev)
                /* cleaning up queue storage */
                for (i = 0; i < priv->nb_rx_queues; i++) {
                        dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
-                       if (dpaa2_q->q_storage)
-                               rte_free(dpaa2_q->q_storage);
+                       rte_free(dpaa2_q->q_storage);
                }
                /* cleanup tx queue cscn */
                for (i = 0; i < priv->nb_tx_queues; i++) {
@@ -667,6 +669,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 +738,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;
        }
@@ -852,6 +883,7 @@ dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,
        struct dpni_queue tx_conf_cfg;
        struct dpni_queue tx_flow_cfg;
        uint8_t options = 0, flow_id;
+       uint16_t channel_id;
        struct dpni_queue_id qid;
        uint32_t tc_id;
        int ret;
@@ -877,20 +909,6 @@ dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,
        memset(&tx_conf_cfg, 0, sizeof(struct dpni_queue));
        memset(&tx_flow_cfg, 0, sizeof(struct dpni_queue));
 
-       tc_id = tx_queue_id;
-       flow_id = 0;
-
-       ret = dpni_set_queue(dpni, CMD_PRI_LOW, priv->token, DPNI_QUEUE_TX,
-                       tc_id, flow_id, options, &tx_flow_cfg);
-       if (ret) {
-               DPAA2_PMD_ERR("Error in setting the tx flow: "
-                       "tc_id=%d, flow=%d err=%d",
-                       tc_id, flow_id, ret);
-                       return -1;
-       }
-
-       dpaa2_q->flow_id = flow_id;
-
        if (tx_queue_id == 0) {
                /*Set tx-conf and error configuration*/
                if (priv->flags & DPAA2_TX_CONF_ENABLE)
@@ -907,10 +925,26 @@ dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,
                        return -1;
                }
        }
+
+       tc_id = tx_queue_id % priv->num_tx_tc;
+       channel_id = (uint8_t)(tx_queue_id / priv->num_tx_tc) % priv->num_channels;
+       flow_id = 0;
+
+       ret = dpni_set_queue(dpni, CMD_PRI_LOW, priv->token, DPNI_QUEUE_TX,
+                       ((channel_id << 8) | tc_id), flow_id, options, &tx_flow_cfg);
+       if (ret) {
+               DPAA2_PMD_ERR("Error in setting the tx flow: "
+                       "tc_id=%d, flow=%d err=%d",
+                       tc_id, flow_id, ret);
+                       return -1;
+       }
+
+       dpaa2_q->flow_id = flow_id;
+
        dpaa2_q->tc_index = tc_id;
 
        ret = dpni_get_queue(dpni, CMD_PRI_LOW, priv->token,
-                            DPNI_QUEUE_TX, dpaa2_q->tc_index,
+                            DPNI_QUEUE_TX, ((channel_id << 8) | dpaa2_q->tc_index),
                             dpaa2_q->flow_id, &tx_flow_cfg, &qid);
        if (ret) {
                DPAA2_PMD_ERR("Error in getting LFQID err=%d", ret);
@@ -942,7 +976,7 @@ dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,
                ret = dpni_set_congestion_notification(dpni, CMD_PRI_LOW,
                                                       priv->token,
                                                       DPNI_QUEUE_TX,
-                                                      tc_id,
+                                                      ((channel_id << 8) | tc_id),
                                                       &cong_notif_cfg);
                if (ret) {
                        DPAA2_PMD_ERR(
@@ -959,7 +993,7 @@ dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,
                options = options | DPNI_QUEUE_OPT_USER_CTX;
                tx_conf_cfg.user_context = (size_t)(dpaa2_q);
                ret = dpni_set_queue(dpni, CMD_PRI_LOW, priv->token,
-                            DPNI_QUEUE_TX_CONFIRM, dpaa2_tx_conf_q->tc_index,
+                            DPNI_QUEUE_TX_CONFIRM, ((channel_id << 8) | dpaa2_tx_conf_q->tc_index),
                             dpaa2_tx_conf_q->flow_id, options, &tx_conf_cfg);
                if (ret) {
                        DPAA2_PMD_ERR("Error in setting the tx conf flow: "
@@ -970,7 +1004,7 @@ dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,
                }
 
                ret = dpni_get_queue(dpni, CMD_PRI_LOW, priv->token,
-                            DPNI_QUEUE_TX_CONFIRM, dpaa2_tx_conf_q->tc_index,
+                            DPNI_QUEUE_TX_CONFIRM, ((channel_id << 8) | dpaa2_tx_conf_q->tc_index),
                             dpaa2_tx_conf_q->flow_id, &tx_conf_cfg, &qid);
                if (ret) {
                        DPAA2_PMD_ERR("Error in getting LFQID err=%d", ret);
@@ -1152,7 +1186,6 @@ dpaa2_dev_start(struct rte_eth_dev *dev)
        struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
        struct dpni_queue cfg;
        struct dpni_error_cfg   err_cfg;
-       uint16_t qdid;
        struct dpni_queue_id qid;
        struct dpaa2_queue *dpaa2_q;
        int ret, i;
@@ -1162,7 +1195,6 @@ dpaa2_dev_start(struct rte_eth_dev *dev)
        intr_handle = dpaa2_dev->intr_handle;
 
        PMD_INIT_FUNC_TRACE();
-
        ret = dpni_enable(dpni, CMD_PRI_LOW, priv->token);
        if (ret) {
                DPAA2_PMD_ERR("Failure in enabling dpni %d device: err=%d",
@@ -1173,14 +1205,6 @@ dpaa2_dev_start(struct rte_eth_dev *dev)
        /* Power up the phy. Needed to make the link go UP */
        dpaa2_dev_set_link_up(dev);
 
-       ret = dpni_get_qdid(dpni, CMD_PRI_LOW, priv->token,
-                           DPNI_QUEUE_TX, &qdid);
-       if (ret) {
-               DPAA2_PMD_ERR("Error in getting qdid: err=%d", ret);
-               return ret;
-       }
-       priv->qdid = qdid;
-
        for (i = 0; i < data->nb_rx_queues; i++) {
                dpaa2_q = (struct dpaa2_queue *)data->rx_queues[i];
                ret = dpni_get_queue(dpni, CMD_PRI_LOW, priv->token,
@@ -1980,7 +2004,7 @@ dpaa2_dev_set_link_down(struct rte_eth_dev *dev)
        }
 
        /*changing  tx burst function to avoid any more enqueues */
-       dev->tx_pkt_burst = dummy_dev_tx;
+       dev->tx_pkt_burst = rte_eth_pkt_burst_dummy;
 
        /* Loop while dpni_disable() attempts to drain the egress FQs
         * and confirm them back to us.
@@ -2602,6 +2626,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) {
@@ -2619,9 +2646,13 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
        }
 
        priv->num_rx_tc = attr.num_rx_tcs;
+       priv->num_tx_tc = attr.num_tx_tcs;
        priv->qos_entries = attr.qos_entries;
        priv->fs_entries = attr.fs_entries;
        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)
@@ -2635,8 +2666,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
        for (i = 0; i < attr.num_rx_tcs; i++)
                priv->nb_rx_queues += attr.num_queues;
 
-       /* Using number of TX queues as number of TX TCs */
-       priv->nb_tx_queues = attr.num_tx_tcs;
+       priv->nb_tx_queues = attr.num_tx_tcs * attr.num_channels;
 
        DPAA2_PMD_DEBUG("RX-TC= %d, rx_queues= %d, tx_queues=%d, max_cgs=%d",
                        priv->num_rx_tc, priv->nb_rx_queues,
@@ -2807,7 +2837,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);