power: add get/set pause duration API
authorKevin Laatz <kevin.laatz@intel.com>
Thu, 2 Jun 2022 15:13:37 +0000 (16:13 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Sat, 4 Jun 2022 20:39:35 +0000 (22:39 +0200)
Add new get/set API for configuring 'pause_duration' which used to adjust
the pause mode callback duration.

Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
Acked-by: Ray Kinsella <mdr@ashroe.eu>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Tested-by: David Hunt <david.hunt@intel.com>
doc/guides/prog_guide/power_man.rst
lib/power/rte_power_pmd_mgmt.c
lib/power/rte_power_pmd_mgmt.h
lib/power/version.map

index 5d345f6..266c754 100644 (file)
@@ -258,6 +258,12 @@ API Overview for Ethernet PMD Power Management
 * **Set Emptypoll Max**: Set the number of empty polls to wait before entering
   sleep state.
 
+* **Get Pause Duration**: Get the configured duration (microseconds) to be used
+  in the Pause callback.
+
+* **Set Pause Duration**: Set the duration of the pause (microseconds) used in
+  the Pause mode callback.
+
 References
 ----------
 
index dfb7ca9..1374cc2 100644 (file)
@@ -12,6 +12,7 @@
 #include "rte_power_pmd_mgmt.h"
 
 unsigned int emptypoll_max;
+unsigned int pause_duration;
 
 /* store some internal state */
 static struct pmd_conf_data {
@@ -315,6 +316,7 @@ clb_pause(uint16_t port_id __rte_unused, uint16_t qidx __rte_unused,
        struct queue_list_entry *queue_conf = arg;
        struct pmd_core_cfg *lcore_conf;
        const bool empty = nb_rx == 0;
+       uint32_t pause_duration = rte_power_pmd_mgmt_get_pause_duration();
 
        lcore_conf = &lcore_cfgs[lcore];
 
@@ -334,11 +336,11 @@ clb_pause(uint16_t port_id __rte_unused, uint16_t qidx __rte_unused,
                if (global_data.intrinsics_support.power_pause) {
                        const uint64_t cur = rte_rdtsc();
                        const uint64_t wait_tsc =
-                                       cur + global_data.tsc_per_us;
+                                       cur + global_data.tsc_per_us * pause_duration;
                        rte_power_pause(wait_tsc);
                } else {
                        uint64_t i;
-                       for (i = 0; i < global_data.pause_per_us; i++)
+                       for (i = 0; i < global_data.pause_per_us * pause_duration; i++)
                                rte_pause();
                }
        }
@@ -673,6 +675,24 @@ rte_power_pmd_mgmt_get_emptypoll_max(void)
        return emptypoll_max;
 }
 
+int
+rte_power_pmd_mgmt_set_pause_duration(unsigned int duration)
+{
+       if (duration == 0) {
+               RTE_LOG(ERR, POWER, "Pause duration must be greater than 0, value unchanged");
+               return -EINVAL;
+       }
+       pause_duration = duration;
+
+       return 0;
+}
+
+unsigned int
+rte_power_pmd_mgmt_get_pause_duration(void)
+{
+       return pause_duration;
+}
+
 RTE_INIT(rte_power_ethdev_pmgmt_init) {
        size_t i;
 
@@ -684,4 +704,5 @@ RTE_INIT(rte_power_ethdev_pmgmt_init) {
 
        /* initialize config defaults */
        emptypoll_max = 512;
+       pause_duration = 1;
 }
index d5a94f8..18a9c3a 100644 (file)
@@ -117,6 +117,37 @@ __rte_experimental
 unsigned int
 rte_power_pmd_mgmt_get_emptypoll_max(void);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
+ *
+ * Set the pause_duration. Used to adjust the pause mode callback duration.
+ *
+ * @note Duration must be greater than zero.
+ *
+ * @param duration
+ *   The value to set pause_duration to.
+ * @return
+ *   0 on success
+ *   <0 on error
+ */
+__rte_experimental
+int
+rte_power_pmd_mgmt_set_pause_duration(unsigned int duration);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
+ *
+ * Get the current value of pause_duration.
+ *
+ * @return
+ *   The current pause_duration value.
+ */
+__rte_experimental
+unsigned int
+rte_power_pmd_mgmt_get_pause_duration(void);
+
 #ifdef __cplusplus
 }
 #endif
index 812843c..4673b71 100644 (file)
@@ -41,5 +41,7 @@ EXPERIMENTAL {
 
        # added in 22.07
        rte_power_pmd_mgmt_get_emptypoll_max;
+       rte_power_pmd_mgmt_get_pause_duration;
        rte_power_pmd_mgmt_set_emptypoll_max;
+       rte_power_pmd_mgmt_set_pause_duration;
 };