DPDK patches and discussions
 help / color / mirror / Atom feed
From: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
To: <david.hunt@intel.com>, <anatoly.burakov@intel.com>,
	<jerinj@marvell.com>,  <radu.nicolau@intel.com>,
	<gakhil@marvell.com>, <cristian.dumitrescu@intel.com>,
	<ferruh.yigit@amd.com>, <konstantin.ananyev@huawei.com>
Cc: <dev@dpdk.org>
Subject: [PATCH v3 3/5] test/power: removed function pointer validations
Date: Tue, 8 Oct 2024 17:27:16 +0000	[thread overview]
Message-ID: <20241008172719.902619-4-sivaprasad.tummala@amd.com> (raw)
In-Reply-To: <20241008172719.902619-1-sivaprasad.tummala@amd.com>

After refactoring the power library, power management operations are now
consistently supported regardless of the operating environment, making
function pointer checks unnecessary and thus removed from applications.

v2:
 - removed function pointer validation in l3fwd-power app.

Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
---
 app/test/test_power.c         | 95 -----------------------------------
 app/test/test_power_cpufreq.c | 52 -------------------
 app/test/test_power_kvm_vm.c  | 36 -------------
 examples/l3fwd-power/main.c   | 12 ++---
 4 files changed, 4 insertions(+), 191 deletions(-)

diff --git a/app/test/test_power.c b/app/test/test_power.c
index 403adc22d6..5df5848c70 100644
--- a/app/test/test_power.c
+++ b/app/test/test_power.c
@@ -24,86 +24,6 @@ test_power(void)
 
 #include <rte_power.h>
 
-static int
-check_function_ptrs(void)
-{
-	enum power_management_env env = rte_power_get_env();
-
-	const bool not_null_expected = !(env == PM_ENV_NOT_SET);
-
-	const char *inject_not_string1 = not_null_expected ? " not" : "";
-	const char *inject_not_string2 = not_null_expected ? "" : " not";
-
-	if ((rte_power_freqs == NULL) == not_null_expected) {
-		printf("rte_power_freqs should%s be NULL, environment has%s been "
-				"initialised\n", inject_not_string1,
-					inject_not_string2);
-		return -1;
-	}
-	if ((rte_power_get_freq == NULL) == not_null_expected) {
-		printf("rte_power_get_freq should%s be NULL, environment has%s been "
-				"initialised\n", inject_not_string1,
-					inject_not_string2);
-		return -1;
-	}
-	if ((rte_power_set_freq == NULL) == not_null_expected) {
-		printf("rte_power_set_freq should%s be NULL, environment has%s been "
-				"initialised\n", inject_not_string1,
-				inject_not_string2);
-		return -1;
-	}
-	if ((rte_power_freq_up == NULL) == not_null_expected) {
-		printf("rte_power_freq_up should%s be NULL, environment has%s been "
-				"initialised\n", inject_not_string1,
-				inject_not_string2);
-		return -1;
-	}
-	if ((rte_power_freq_down == NULL) == not_null_expected) {
-		printf("rte_power_freq_down should%s be NULL, environment has%s been "
-				"initialised\n", inject_not_string1,
-				inject_not_string2);
-		return -1;
-	}
-	if ((rte_power_freq_max == NULL) == not_null_expected) {
-		printf("rte_power_freq_max should%s be NULL, environment has%s been "
-				"initialised\n", inject_not_string1,
-				inject_not_string2);
-		return -1;
-	}
-	if ((rte_power_freq_min == NULL) == not_null_expected) {
-		printf("rte_power_freq_min should%s be NULL, environment has%s been "
-				"initialised\n", inject_not_string1,
-				inject_not_string2);
-		return -1;
-	}
-	if ((rte_power_turbo_status == NULL) == not_null_expected) {
-		printf("rte_power_turbo_status should%s be NULL, environment has%s been "
-				"initialised\n", inject_not_string1,
-				inject_not_string2);
-		return -1;
-	}
-	if ((rte_power_freq_enable_turbo == NULL) == not_null_expected) {
-		printf("rte_power_freq_enable_turbo should%s be NULL, environment has%s been "
-				"initialised\n", inject_not_string1,
-				inject_not_string2);
-		return -1;
-	}
-	if ((rte_power_freq_disable_turbo == NULL) == not_null_expected) {
-		printf("rte_power_freq_disable_turbo should%s be NULL, environment has%s been "
-				"initialised\n", inject_not_string1,
-				inject_not_string2);
-		return -1;
-	}
-	if ((rte_power_get_capabilities == NULL) == not_null_expected) {
-		printf("rte_power_get_capabilities should%s be NULL, environment has%s been "
-				"initialised\n", inject_not_string1,
-				inject_not_string2);
-		return -1;
-	}
-
-	return 0;
-}
-
 static int
 test_power(void)
 {
@@ -124,10 +44,6 @@ test_power(void)
 		return -1;
 	}
 
-	/* Verify that function pointers are NULL */
-	if (check_function_ptrs() < 0)
-		goto fail_all;
-
 	rte_power_unset_env();
 
 	/* Perform tests for valid environments.*/
@@ -154,22 +70,11 @@ test_power(void)
 			return -1;
 		}
 
-		/* Verify that function pointers are NOT NULL */
-		if (check_function_ptrs() < 0)
-			goto fail_all;
-
 		rte_power_unset_env();
 
-		/* Verify that function pointers are NULL */
-		if (check_function_ptrs() < 0)
-			goto fail_all;
-
 	}
 
 	return 0;
-fail_all:
-	rte_power_unset_env();
-	return -1;
 }
 #endif
 
diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c
index 619b2811c6..8cb67e662c 100644
--- a/app/test/test_power_cpufreq.c
+++ b/app/test/test_power_cpufreq.c
@@ -519,58 +519,6 @@ test_power_cpufreq(void)
 		goto fail_all;
 	}
 
-	/* verify that function pointers are not NULL */
-	if (rte_power_freqs == NULL) {
-		printf("rte_power_freqs should not be NULL, environment has not been "
-				"initialised\n");
-		goto fail_all;
-	}
-	if (rte_power_get_freq == NULL) {
-		printf("rte_power_get_freq should not be NULL, environment has not "
-				"been initialised\n");
-		goto fail_all;
-	}
-	if (rte_power_set_freq == NULL) {
-		printf("rte_power_set_freq should not be NULL, environment has not "
-				"been initialised\n");
-		goto fail_all;
-	}
-	if (rte_power_freq_up == NULL) {
-		printf("rte_power_freq_up should not be NULL, environment has not "
-				"been initialised\n");
-		goto fail_all;
-	}
-	if (rte_power_freq_down == NULL) {
-		printf("rte_power_freq_down should not be NULL, environment has not "
-				"been initialised\n");
-		goto fail_all;
-	}
-	if (rte_power_freq_max == NULL) {
-		printf("rte_power_freq_max should not be NULL, environment has not "
-				"been initialised\n");
-		goto fail_all;
-	}
-	if (rte_power_freq_min == NULL) {
-		printf("rte_power_freq_min should not be NULL, environment has not "
-				"been initialised\n");
-		goto fail_all;
-	}
-	if (rte_power_turbo_status == NULL) {
-		printf("rte_power_turbo_status should not be NULL, environment has not "
-				"been initialised\n");
-		goto fail_all;
-	}
-	if (rte_power_freq_enable_turbo == NULL) {
-		printf("rte_power_freq_enable_turbo should not be NULL, environment has not "
-				"been initialised\n");
-		goto fail_all;
-	}
-	if (rte_power_freq_disable_turbo == NULL) {
-		printf("rte_power_freq_disable_turbo should not be NULL, environment has not "
-				"been initialised\n");
-		goto fail_all;
-	}
-
 	ret = rte_power_exit(TEST_POWER_LCORE_ID);
 	if (ret < 0) {
 		printf("Cannot exit power management for lcore %u\n",
diff --git a/app/test/test_power_kvm_vm.c b/app/test/test_power_kvm_vm.c
index 464e06002e..a7d104e973 100644
--- a/app/test/test_power_kvm_vm.c
+++ b/app/test/test_power_kvm_vm.c
@@ -47,42 +47,6 @@ test_power_kvm_vm(void)
 		return -1;
 	}
 
-	/* verify that function pointers are not NULL */
-	if (rte_power_freqs == NULL) {
-		printf("rte_power_freqs should not be NULL, environment has not been "
-				"initialised\n");
-		return -1;
-	}
-	if (rte_power_get_freq == NULL) {
-		printf("rte_power_get_freq should not be NULL, environment has not "
-				"been initialised\n");
-		return -1;
-	}
-	if (rte_power_set_freq == NULL) {
-		printf("rte_power_set_freq should not be NULL, environment has not "
-				"been initialised\n");
-		return -1;
-	}
-	if (rte_power_freq_up == NULL) {
-		printf("rte_power_freq_up should not be NULL, environment has not "
-				"been initialised\n");
-		return -1;
-	}
-	if (rte_power_freq_down == NULL) {
-		printf("rte_power_freq_down should not be NULL, environment has not "
-				"been initialised\n");
-		return -1;
-	}
-	if (rte_power_freq_max == NULL) {
-		printf("rte_power_freq_max should not be NULL, environment has not "
-				"been initialised\n");
-		return -1;
-	}
-	if (rte_power_freq_min == NULL) {
-		printf("rte_power_freq_min should not be NULL, environment has not "
-				"been initialised\n");
-		return -1;
-	}
 	/* Test initialisation of an out of bounds lcore */
 	ret = rte_power_init(TEST_POWER_VM_LCORE_OUT_OF_BOUNDS);
 	if (ret != -1) {
diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index 2bb6b092c3..6bd76515e6 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -440,8 +440,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,
 	 * check whether need to scale down frequency a step if it sleep a lot.
 	 */
 	if (sleep_time_ratio >= SCALING_DOWN_TIME_RATIO_THRESHOLD) {
-		if (rte_power_freq_down)
-			rte_power_freq_down(lcore_id);
+		rte_power_freq_down(lcore_id);
 	}
 	else if ( (unsigned)(stats[lcore_id].nb_rx_processed /
 		stats[lcore_id].nb_iteration_looped) < MAX_PKT_BURST) {
@@ -449,8 +448,7 @@ power_timer_cb(__rte_unused struct rte_timer *tim,
 		 * scale down a step if average packet per iteration less
 		 * than expectation.
 		 */
-		if (rte_power_freq_down)
-			rte_power_freq_down(lcore_id);
+		rte_power_freq_down(lcore_id);
 	}
 
 	/**
@@ -1344,11 +1342,9 @@ main_legacy_loop(__rte_unused void *dummy)
 			}
 
 			if (lcore_scaleup_hint == FREQ_HIGHEST) {
-				if (rte_power_freq_max)
-					rte_power_freq_max(lcore_id);
+				rte_power_freq_max(lcore_id);
 			} else if (lcore_scaleup_hint == FREQ_HIGHER) {
-				if (rte_power_freq_up)
-					rte_power_freq_up(lcore_id);
+				rte_power_freq_up(lcore_id);
 			}
 		} else {
 			/**
-- 
2.34.1


  parent reply	other threads:[~2024-10-08 17:28 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-20 15:33 [RFC PATCH 0/2] power: refactor power management library Sivaprasad Tummala
2024-02-20 15:33 ` Sivaprasad Tummala
2024-02-20 15:33 ` [RFC PATCH 1/2] power: refactor core " Sivaprasad Tummala
2024-02-27 16:18   ` Ferruh Yigit
2024-02-29  7:10     ` Tummala, Sivaprasad
2024-02-28 12:51   ` Ferruh Yigit
2024-03-01  2:56   ` lihuisong (C)
2024-03-01 10:39     ` Hunt, David
2024-03-05  4:35     ` Tummala, Sivaprasad
2024-02-20 15:33 ` [RFC PATCH 2/2] power: refactor uncore " Sivaprasad Tummala
2024-03-01  3:33   ` lihuisong (C)
2024-03-01  6:06     ` Tummala, Sivaprasad
2024-07-20 16:50 ` [PATCH v1 0/4] power: refactor " Sivaprasad Tummala
2024-07-20 16:50   ` [PATCH v1 1/4] power: refactor core " Sivaprasad Tummala
2024-07-23 10:03     ` Hunt, David
2024-07-27 18:44       ` Tummala, Sivaprasad
2024-07-20 16:50   ` [PATCH v1 2/4] power: refactor uncore " Sivaprasad Tummala
2024-07-23 10:26     ` Hunt, David
2024-07-20 16:50   ` [PATCH v1 3/4] test/power: removed function pointer validations Sivaprasad Tummala
2024-07-22 10:49     ` Hunt, David
2024-07-27 18:45       ` Tummala, Sivaprasad
2024-07-20 16:50   ` [PATCH v1 4/4] power/amd_uncore: uncore power management support for AMD EPYC processors Sivaprasad Tummala
2024-07-23 10:33     ` Hunt, David
2024-07-27 18:46       ` Tummala, Sivaprasad
2024-07-20 16:50   ` [PATCH v1 0/4] power: refactor power management library Sivaprasad Tummala
2024-08-26 13:06   ` [PATCH v2 " Sivaprasad Tummala
2024-08-26 13:06     ` [PATCH v2 1/4] power: refactor core " Sivaprasad Tummala
2024-08-26 15:26       ` Stephen Hemminger
2024-10-07 19:25         ` Tummala, Sivaprasad
2024-08-27  8:21       ` lihuisong (C)
2024-09-12 11:17         ` Tummala, Sivaprasad
2024-09-13  7:34           ` lihuisong (C)
2024-09-18  8:37             ` Tummala, Sivaprasad
2024-09-19  3:37               ` lihuisong (C)
2024-08-26 13:06     ` [PATCH v2 2/4] power: refactor uncore " Sivaprasad Tummala
2024-08-27 13:02       ` lihuisong (C)
2024-10-08  6:19         ` Tummala, Sivaprasad
2024-08-26 13:06     ` [PATCH v2 3/4] test/power: removed function pointer validations Sivaprasad Tummala
2024-08-26 13:06     ` [PATCH v2 4/4] power/amd_uncore: uncore power management support for AMD EPYC processors Sivaprasad Tummala
2024-08-26 13:06     ` [PATCH v2 0/4] power: refactor power management library Sivaprasad Tummala
2024-10-07 18:01     ` Stephen Hemminger
2024-10-08 17:27     ` [PATCH v3 0/5] " Sivaprasad Tummala
2024-10-08 17:27       ` [PATCH v3 1/5] power: refactor core " Sivaprasad Tummala
2024-10-08 17:27       ` [PATCH v3 2/5] power: refactor uncore " Sivaprasad Tummala
2024-10-08 17:27       ` Sivaprasad Tummala [this message]
2024-10-08 17:27       ` [PATCH v3 4/5] power/amd_uncore: uncore support for AMD EPYC processors Sivaprasad Tummala
2024-10-08 17:27       ` [PATCH v3 5/5] maintainers: update for drivers/power Sivaprasad Tummala
2024-10-08 17:27       ` [PATCH v3 0/5] power: refactor power management library Sivaprasad Tummala
2024-10-08 17:43       ` Sivaprasad Tummala
2024-10-08 17:43         ` [PATCH v3 1/5] power: refactor core " Sivaprasad Tummala
2024-10-08 17:43         ` [PATCH v3 2/5] power: refactor uncore " Sivaprasad Tummala
2024-10-08 17:43         ` [PATCH v3 3/5] test/power: removed function pointer validations Sivaprasad Tummala
2024-10-08 17:43         ` [PATCH v3 4/5] power/amd_uncore: uncore support for AMD EPYC processors Sivaprasad Tummala
2024-10-08 17:43         ` [PATCH v3 5/5] maintainers: update for drivers/power Sivaprasad Tummala
2024-10-08 17:43         ` [PATCH v3 0/5] power: refactor power management library Sivaprasad Tummala
2024-10-12 17:44         ` Stephen Hemminger
2024-10-15  2:49       ` [PATCH v4 " Sivaprasad Tummala
2024-10-15  2:49         ` [PATCH v4 1/5] power: refactor core " Sivaprasad Tummala
2024-10-15  2:49         ` [PATCH v4 2/5] power: refactor uncore " Sivaprasad Tummala
2024-10-15  2:49         ` [PATCH v4 3/5] test/power: removed function pointer validations Sivaprasad Tummala
2024-10-15  2:49         ` [PATCH v4 4/5] power/amd_uncore: uncore support for AMD EPYC processors Sivaprasad Tummala
2024-10-15  2:49         ` [PATCH v4 5/5] maintainers: update for drivers/power Sivaprasad Tummala
2024-10-15  2:49         ` [PATCH v4 0/5] power: refactor power management library Sivaprasad Tummala
2024-10-15  3:15         ` Stephen Hemminger
2024-10-17 10:26         ` [PATCH v5 " Sivaprasad Tummala
2024-10-17 10:26           ` [PATCH v5 1/5] power: refactor core " Sivaprasad Tummala
2024-10-17 10:26           ` [PATCH v5 2/5] power: refactor uncore " Sivaprasad Tummala
2024-10-17 10:26           ` [PATCH v5 3/5] test/power: removed function pointer validations Sivaprasad Tummala
2024-10-17 10:26           ` [PATCH v5 4/5] drivers/power: uncore support for AMD EPYC processors Sivaprasad Tummala
2024-10-17 10:26           ` [PATCH v5 5/5] maintainers: update for drivers/power Sivaprasad Tummala
2024-10-17 10:26           ` [PATCH v5 0/5] power: refactor power management library Sivaprasad Tummala
2024-10-17 16:17           ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241008172719.902619-4-sivaprasad.tummala@amd.com \
    --to=sivaprasad.tummala@amd.com \
    --cc=anatoly.burakov@intel.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=david.hunt@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=gakhil@marvell.com \
    --cc=jerinj@marvell.com \
    --cc=konstantin.ananyev@huawei.com \
    --cc=radu.nicolau@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).