net/dpaa2: support optional Tx confirmation
authorHemant Agrawal <hemant.agrawal@nxp.com>
Wed, 24 Feb 2021 12:43:01 +0000 (18:13 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 24 Feb 2021 17:03:30 +0000 (18:03 +0100)
Add support for dev arg ``fslmc:dpni.1,drv_tx_conf=1``

It is optional for dpaa2 to use TX confirmation. DPAA2
can free the transmitted packets. However some use-case
requires the TX confirmation to be explicit.

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
doc/guides/nics/dpaa2.rst
drivers/net/dpaa2/dpaa2_ethdev.c
drivers/net/dpaa2/dpaa2_ethdev.h

index 893e87e..4eec8fc 100644 (file)
@@ -484,6 +484,10 @@ for details.
   of the packet pull command which is issued  in the previous cycle.
   e.g. ``fslmc:dpni.1,drv_no_prefetch=1``
 
+* Use dev arg option  ``drv_tx_conf=1`` to enable TX confirmation mode.
+  In this mode tx conf queues need to be polled to free the buffers.
+  e.g. ``fslmc:dpni.1,drv_tx_conf=1``
+
 Enabling logs
 -------------
 
index 490eb4b..4b3eb7f 100644 (file)
@@ -31,6 +31,7 @@
 
 #define DRIVER_LOOPBACK_MODE "drv_loopback"
 #define DRIVER_NO_PREFETCH_MODE "drv_no_prefetch"
+#define DRIVER_TX_CONF "drv_tx_conf"
 #define CHECK_INTERVAL         100  /* 100ms */
 #define MAX_REPEAT_TIME        90   /* 9s (90 * 100ms) in total */
 
@@ -363,7 +364,7 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)
        PMD_INIT_FUNC_TRACE();
 
        num_rxqueue_per_tc = (priv->nb_rx_queues / priv->num_rx_tc);
-       if (priv->tx_conf_en)
+       if (priv->flags & DPAA2_TX_CONF_ENABLE)
                tot_queues = priv->nb_rx_queues + 2 * priv->nb_tx_queues;
        else
                tot_queues = priv->nb_rx_queues + priv->nb_tx_queues;
@@ -401,7 +402,7 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)
                        goto fail_tx;
        }
 
-       if (priv->tx_conf_en) {
+       if (priv->flags & DPAA2_TX_CONF_ENABLE) {
                /*Setup tx confirmation queues*/
                for (i = 0; i < priv->nb_tx_queues; i++) {
                        mc_q->eth_data = dev->data;
@@ -483,7 +484,7 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev)
                        dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i];
                        rte_free(dpaa2_q->cscn);
                }
-               if (priv->tx_conf_en) {
+               if (priv->flags & DPAA2_TX_CONF_ENABLE) {
                        /* cleanup tx conf queue storage */
                        for (i = 0; i < priv->nb_tx_queues; i++) {
                                dpaa2_q = (struct dpaa2_queue *)
@@ -857,7 +858,7 @@ dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,
 
        if (tx_queue_id == 0) {
                /*Set tx-conf and error configuration*/
-               if (priv->tx_conf_en)
+               if (priv->flags & DPAA2_TX_CONF_ENABLE)
                        ret = dpni_set_tx_confirmation_mode(dpni, CMD_PRI_LOW,
                                                            priv->token,
                                                            DPNI_CONF_AFFINE);
@@ -918,7 +919,7 @@ dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,
        dpaa2_q->cb_eqresp_free = dpaa2_dev_free_eqresp_buf;
        dev->data->tx_queues[tx_queue_id] = dpaa2_q;
 
-       if (priv->tx_conf_en) {
+       if (priv->flags & DPAA2_TX_CONF_ENABLE) {
                dpaa2_q->tx_conf_queue = dpaa2_tx_conf_q;
                options = options | DPNI_QUEUE_OPT_USER_CTX;
                tx_conf_cfg.user_context = (size_t)(dpaa2_q);
@@ -2614,10 +2615,14 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
        priv->max_vlan_filters = attr.vlan_filter_entries;
        priv->flags = 0;
 #if defined(RTE_LIBRTE_IEEE1588)
-       priv->tx_conf_en = 1;
-#else
-       priv->tx_conf_en = 0;
+       printf("DPDK IEEE1588 is enabled\n");
+       priv->flags |= DPAA2_TX_CONF_ENABLE;
 #endif
+       /* Used with ``fslmc:dpni.1,drv_tx_conf=1`` */
+       if (dpaa2_get_devargs(dev->devargs, DRIVER_TX_CONF)) {
+               priv->flags |= DPAA2_TX_CONF_ENABLE;
+               DPAA2_PMD_INFO("TX_CONF Enabled");
+       }
 
        /* Allocate memory for hardware structure for queues */
        ret = dpaa2_alloc_rx_tx_queues(eth_dev);
@@ -2650,7 +2655,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 
        /* ... tx buffer layout ... */
        memset(&layout, 0, sizeof(struct dpni_buffer_layout));
-       if (priv->tx_conf_en) {
+       if (priv->flags & DPAA2_TX_CONF_ENABLE) {
                layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
                                 DPNI_BUF_LAYOUT_OPT_TIMESTAMP;
                layout.pass_timestamp = true;
@@ -2667,13 +2672,11 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 
        /* ... tx-conf and error buffer layout ... */
        memset(&layout, 0, sizeof(struct dpni_buffer_layout));
-       if (priv->tx_conf_en) {
-               layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
-                                DPNI_BUF_LAYOUT_OPT_TIMESTAMP;
+       if (priv->flags & DPAA2_TX_CONF_ENABLE) {
+               layout.options = DPNI_BUF_LAYOUT_OPT_TIMESTAMP;
                layout.pass_timestamp = true;
-       } else {
-               layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS;
        }
+       layout.options |= DPNI_BUF_LAYOUT_OPT_FRAME_STATUS;
        layout.pass_frame_status = 1;
        ret = dpni_set_buffer_layout(dpni_dev, CMD_PRI_LOW, priv->token,
                                     DPNI_QUEUE_TX_CONFIRM, &layout);
@@ -2807,7 +2810,6 @@ rte_dpaa2_probe(struct rte_dpaa2_driver *dpaa2_drv,
                eth_dev->data->dev_private = (void *)dev_priv;
                /* Store a pointer to eth_dev in dev_private */
                dev_priv->eth_dev = eth_dev;
-               dev_priv->tx_conf_en = 0;
        } else {
                eth_dev = rte_eth_dev_attach_secondary(dpaa2_dev->device.name);
                if (!eth_dev) {
@@ -2860,5 +2862,6 @@ static struct rte_dpaa2_driver rte_dpaa2_pmd = {
 RTE_PMD_REGISTER_DPAA2(net_dpaa2, rte_dpaa2_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(net_dpaa2,
                DRIVER_LOOPBACK_MODE "=<int> "
-               DRIVER_NO_PREFETCH_MODE "=<int>");
+               DRIVER_NO_PREFETCH_MODE "=<int>"
+               DRIVER_TX_CONF "=<int>");
 RTE_LOG_REGISTER(dpaa2_logtype_pmd, pmd.net.dpaa2, NOTICE);
index 9837eb6..becdb50 100644 (file)
@@ -60,6 +60,8 @@
 
 /* Disable RX tail drop, default is enable */
 #define DPAA2_RX_TAILDROP_OFF  0x04
+/* Tx confirmation enabled */
+#define DPAA2_TX_CONF_ENABLE   0x08
 
 #define DPAA2_RSS_OFFLOAD_ALL ( \
        ETH_RSS_L2_PAYLOAD | \
@@ -152,14 +154,13 @@ struct dpaa2_dev_priv {
        void *tx_vq[MAX_TX_QUEUES];
        struct dpaa2_bp_list *bp_list; /**<Attached buffer pool list */
        void *tx_conf_vq[MAX_TX_QUEUES];
-       uint8_t tx_conf_en;
+       uint8_t flags; /*dpaa2 config flags */
        uint8_t max_mac_filters;
        uint8_t max_vlan_filters;
        uint8_t num_rx_tc;
        uint16_t qos_entries;
        uint16_t fs_entries;
        uint8_t dist_queues;
-       uint8_t flags; /*dpaa2 config flags */
        uint8_t en_ordered;
        uint8_t en_loose_ordered;
        uint8_t max_cgs;