net/dpaa2: add per-thread initialization API
authorNipun Gupta <nipun.gupta@nxp.com>
Mon, 19 Jul 2021 13:59:15 +0000 (19:29 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 23 Jul 2021 18:29:53 +0000 (20:29 +0200)
DPAA2 hardware require a hardware portal context.
If a thread doing DPAA2 i/o do not have portal, it will
allocate it on run-time. This may cause a delay in the
datapath at run-time. To avoid it, it is better to allocate
a hw context portal at the start of thread expected to do
i/o with DPAA2 hardware.

This patch makes necessary changes for the same and creates
a pmd API to allocate a hw context portal for a thread.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
drivers/net/dpaa2/dpaa2_ethdev.c
drivers/net/dpaa2/rte_pmd_dpaa2.h
drivers/net/dpaa2/version.map

index c224a88..1a1e437 100644 (file)
@@ -20,7 +20,8 @@
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <sys/epoll.h>
-#include<sys/eventfd.h>
+#include <sys/eventfd.h>
+#include <sys/syscall.h>
 
 #include <rte_mbuf.h>
 #include <ethdev_driver.h>
@@ -168,7 +169,7 @@ dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id, int cpu_id)
        fclose(file);
 }
 
-static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev, int cpu_id)
+static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev)
 {
        struct epoll_event epoll_ev;
        int eventfd, dpio_epoll_fd, ret;
@@ -205,8 +206,6 @@ static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev, int cpu_id)
        }
        dpio_dev->epoll_fd = dpio_epoll_fd;
 
-       dpaa2_affine_dpio_intr_to_respective_core(dpio_dev->hw_id, cpu_id);
-
        return 0;
 }
 
@@ -242,10 +241,11 @@ dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id)
        }
 
 #ifdef RTE_EVENT_DPAA2
-       if (dpaa2_dpio_intr_init(dpio_dev, cpu_id)) {
+       if (dpaa2_dpio_intr_init(dpio_dev)) {
                DPAA2_BUS_ERR("Interrupt registration failed for dpio");
                return -1;
        }
+       dpaa2_affine_dpio_intr_to_respective_core(dpio_dev->hw_id, cpu_id);
 #endif
 
        return 0;
index 8b803b8..d892819 100644 (file)
@@ -2382,6 +2382,22 @@ dpaa2_tm_ops_get(struct rte_eth_dev *dev __rte_unused, void *ops)
        return 0;
 }
 
+void
+rte_pmd_dpaa2_thread_init(void)
+{
+       int ret;
+
+       if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
+               ret = dpaa2_affine_qbman_swp();
+               if (ret) {
+                       DPAA2_PMD_ERR(
+                               "Failed to allocate IO portal, tid: %d\n",
+                               rte_gettid());
+                       return;
+               }
+       }
+}
+
 static struct eth_dev_ops dpaa2_ethdev_ops = {
        .dev_configure    = dpaa2_eth_dev_configure,
        .dev_start            = dpaa2_dev_start,
index 7204a8f..84ac9d3 100644 (file)
@@ -84,4 +84,14 @@ rte_pmd_dpaa2_set_custom_hash(uint16_t port_id,
                              uint16_t offset,
                              uint8_t size);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Do thread specific initialization
+ */
+__rte_experimental
+void
+rte_pmd_dpaa2_thread_init(void);
+
 #endif /* _RTE_PMD_DPAA2_H */
index b50da13..49f69da 100644 (file)
@@ -6,6 +6,8 @@ EXPERIMENTAL {
 
        # added in 21.05
        rte_pmd_dpaa2_mux_rx_frame_len;
+       # added in 21.08
+       rte_pmd_dpaa2_thread_init;
 };
 
 INTERNAL {