From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A8BA9A0487 for ; Tue, 2 Jul 2019 11:56:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2A72C1B99A; Tue, 2 Jul 2019 11:56:25 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id ABDAB1B994 for ; Tue, 2 Jul 2019 11:56:22 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jul 2019 02:56:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,442,1557212400"; d="scan'208";a="184471057" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.223.2]) by fmsmga001.fm.intel.com with ESMTP; 02 Jul 2019 02:56:21 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , Hemant Agrawal Date: Tue, 2 Jul 2019 10:56:07 +0100 Message-Id: <20190702095608.20722-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190702095608.20722-1-bruce.richardson@intel.com> References: <20190619170802.7691-1-bruce.richardson@intel.com> <20190702095608.20722-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 2/3] raw/skeleton: remove compile-time constant for device id X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Use a variable value rather than compile-time constant zero as the device id for the skeleton rawdev tests. This ensures we can make the tests work even if other rawdevs are present. Signed-off-by: Bruce Richardson Acked-by: Hemant Agrawal --- .../skeleton_rawdev/skeleton_rawdev_test.c | 55 ++++++++++--------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c b/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c index 3250c2296..a6be99aee 100644 --- a/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c +++ b/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c @@ -14,7 +14,6 @@ /* Using relative path as skeleton_rawdev is not part of exported headers */ #include "skeleton_rawdev.h" -#define TEST_DEV_ID 0 #define TEST_DEV_NAME "rawdev_skeleton" #define SKELDEV_LOGS(level, fmt, args...) \ @@ -37,6 +36,8 @@ static int passed; static int failed; static int unsupported; +static uint16_t test_dev_id; + static int testsuite_setup(void) { @@ -88,7 +89,7 @@ static int test_rawdev_socket_id(void) { int socket_id; - socket_id = rte_rawdev_socket_id(TEST_DEV_ID); + socket_id = rte_rawdev_socket_id(test_dev_id); RTE_TEST_ASSERT(socket_id != -EINVAL, "Failed to get socket_id %d", socket_id); socket_id = rte_rawdev_socket_id(RTE_RAWDEV_MAX_DEVS); @@ -105,12 +106,12 @@ test_rawdev_info_get(void) struct rte_rawdev_info rdev_info = {0}; struct skeleton_rawdev_conf skel_conf = {0}; - ret = rte_rawdev_info_get(TEST_DEV_ID, NULL); + ret = rte_rawdev_info_get(test_dev_id, NULL); RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); rdev_info.dev_private = &skel_conf; - ret = rte_rawdev_info_get(TEST_DEV_ID, &rdev_info); + ret = rte_rawdev_info_get(test_dev_id, &rdev_info); RTE_TEST_ASSERT_SUCCESS(ret, "Failed to get raw dev info"); return TEST_SUCCESS; @@ -125,7 +126,7 @@ test_rawdev_configure(void) struct skeleton_rawdev_conf rdev_conf_get = {0}; /* Check invalid configuration */ - ret = rte_rawdev_configure(TEST_DEV_ID, NULL); + ret = rte_rawdev_configure(test_dev_id, NULL); RTE_TEST_ASSERT(ret == -EINVAL, "Null configure; Expected -EINVAL, got %d", ret); @@ -135,12 +136,12 @@ test_rawdev_configure(void) SKELETON_CAPA_FW_RESET; rdev_info.dev_private = &rdev_conf_set; - ret = rte_rawdev_configure(TEST_DEV_ID, + ret = rte_rawdev_configure(test_dev_id, (rte_rawdev_obj_t)&rdev_info); RTE_TEST_ASSERT_SUCCESS(ret, "Failed to configure rawdev (%d)", ret); rdev_info.dev_private = &rdev_conf_get; - ret = rte_rawdev_info_get(TEST_DEV_ID, + ret = rte_rawdev_info_get(test_dev_id, (rte_rawdev_obj_t)&rdev_info); RTE_TEST_ASSERT_SUCCESS(ret, "Failed to obtain rawdev configuration (%d)", @@ -168,7 +169,7 @@ test_rawdev_queue_default_conf_get(void) /* Get the current configuration */ rdev_info.dev_private = &rdev_conf_get; - ret = rte_rawdev_info_get(TEST_DEV_ID, + ret = rte_rawdev_info_get(test_dev_id, (rte_rawdev_obj_t)&rdev_info); RTE_TEST_ASSERT_SUCCESS(ret, "Failed to obtain rawdev configuration (%d)", ret); @@ -181,7 +182,7 @@ test_rawdev_queue_default_conf_get(void) * depth = DEF_DEPTH */ for (i = 0; i < rdev_conf_get.num_queues; i++) { - rte_rawdev_queue_conf_get(TEST_DEV_ID, i, &q); + rte_rawdev_queue_conf_get(test_dev_id, i, &q); RTE_TEST_ASSERT_EQUAL(q.depth, SKELETON_QUEUE_DEF_DEPTH, "Invalid default depth of queue (%d)", q.depth); @@ -199,7 +200,7 @@ test_rawdev_queue_count(void) unsigned int q_count; /* Get the current configuration */ - q_count = rte_rawdev_queue_count(TEST_DEV_ID); + q_count = rte_rawdev_queue_count(test_dev_id); RTE_TEST_ASSERT_EQUAL(q_count, 1, "Invalid queue count (%d)", q_count); return TEST_SUCCESS; @@ -216,7 +217,7 @@ test_rawdev_queue_setup(void) /* Get the current configuration */ rdev_info.dev_private = &rdev_conf_get; - ret = rte_rawdev_info_get(TEST_DEV_ID, + ret = rte_rawdev_info_get(test_dev_id, (rte_rawdev_obj_t)&rdev_info); RTE_TEST_ASSERT_SUCCESS(ret, "Failed to obtain rawdev configuration (%d)", @@ -230,11 +231,11 @@ test_rawdev_queue_setup(void) /* Modify the queue depth for Queue 0 and attach it */ qset.depth = 15; qset.state = SKELETON_QUEUE_ATTACH; - ret = rte_rawdev_queue_setup(TEST_DEV_ID, 0, &qset); + ret = rte_rawdev_queue_setup(test_dev_id, 0, &qset); RTE_TEST_ASSERT_SUCCESS(ret, "Failed to setup queue (%d)", ret); /* Now, fetching the queue 0 should show depth as 15 */ - ret = rte_rawdev_queue_conf_get(TEST_DEV_ID, 0, &qget); + ret = rte_rawdev_queue_conf_get(test_dev_id, 0, &qget); RTE_TEST_ASSERT_SUCCESS(ret, "Failed to get queue config (%d)", ret); RTE_TEST_ASSERT_EQUAL(qset.depth, qget.depth, @@ -254,11 +255,11 @@ test_rawdev_queue_release(void) struct skeleton_rawdev_queue qget = {0}; /* Now, fetching the queue 0 should show depth as 100 */ - ret = rte_rawdev_queue_release(TEST_DEV_ID, 0); + ret = rte_rawdev_queue_release(test_dev_id, 0); RTE_TEST_ASSERT_SUCCESS(ret, "Failed to release queue 0; (%d)", ret); /* Now, fetching the queue 0 should show depth as default */ - ret = rte_rawdev_queue_conf_get(TEST_DEV_ID, 0, &qget); + ret = rte_rawdev_queue_conf_get(test_dev_id, 0, &qget); RTE_TEST_ASSERT_SUCCESS(ret, "Failed to get queue config (%d)", ret); RTE_TEST_ASSERT_EQUAL(qget.depth, SKELETON_QUEUE_DEF_DEPTH, @@ -278,21 +279,21 @@ test_rawdev_attr_set_get(void) uint64_t ret_value; /* Set an attribute and fetch it */ - ret = rte_rawdev_set_attr(TEST_DEV_ID, "Test1", 100); + ret = rte_rawdev_set_attr(test_dev_id, "Test1", 100); RTE_TEST_ASSERT(!ret, "Unable to set an attribute (Test1)"); dummy_value = &set_value; *dummy_value = 200; - ret = rte_rawdev_set_attr(TEST_DEV_ID, "Test2", (uintptr_t)dummy_value); + ret = rte_rawdev_set_attr(test_dev_id, "Test2", (uintptr_t)dummy_value); /* Check if attributes have been set */ - ret = rte_rawdev_get_attr(TEST_DEV_ID, "Test1", &ret_value); + ret = rte_rawdev_get_attr(test_dev_id, "Test1", &ret_value); RTE_TEST_ASSERT_EQUAL(ret_value, 100, "Attribute (Test1) not set correctly (%" PRIu64 ")", ret_value); ret_value = 0; - ret = rte_rawdev_get_attr(TEST_DEV_ID, "Test2", &ret_value); + ret = rte_rawdev_get_attr(test_dev_id, "Test2", &ret_value); RTE_TEST_ASSERT_EQUAL(*((int *)(uintptr_t)ret_value), set_value, "Attribute (Test2) not set correctly (%" PRIu64 ")", ret_value); @@ -316,7 +317,7 @@ test_rawdev_start_stop(void) RTE_TEST_ASSERT(dummy_firmware != NULL, "Failed to create firmware memory backing"); - ret = rte_rawdev_firmware_load(TEST_DEV_ID, dummy_firmware); + ret = rte_rawdev_firmware_load(test_dev_id, dummy_firmware); RTE_TEST_ASSERT_SUCCESS(ret, "Firmware loading failed (%d)", ret); /* Skeleton doesn't do anything with the firmware area - that is dummy @@ -325,8 +326,8 @@ test_rawdev_start_stop(void) rte_free(dummy_firmware); dummy_firmware = NULL; - rte_rawdev_start(TEST_DEV_ID); - ret = rte_rawdev_info_get(TEST_DEV_ID, (rte_rawdev_obj_t)&rdev_info); + rte_rawdev_start(test_dev_id); + ret = rte_rawdev_info_get(test_dev_id, (rte_rawdev_obj_t)&rdev_info); RTE_TEST_ASSERT_SUCCESS(ret, "Failed to obtain rawdev configuration (%d)", ret); @@ -334,8 +335,8 @@ test_rawdev_start_stop(void) "Device start failed. State is (%d)", rdev_conf_get.device_state); - rte_rawdev_stop(TEST_DEV_ID); - ret = rte_rawdev_info_get(TEST_DEV_ID, (rte_rawdev_obj_t)&rdev_info); + rte_rawdev_stop(test_dev_id); + ret = rte_rawdev_info_get(test_dev_id, (rte_rawdev_obj_t)&rdev_info); RTE_TEST_ASSERT_SUCCESS(ret, "Failed to obtain rawdev configuration (%d)", ret); @@ -344,7 +345,7 @@ test_rawdev_start_stop(void) rdev_conf_get.device_state); /* Unloading the firmware once device is stopped */ - ret = rte_rawdev_firmware_unload(TEST_DEV_ID); + ret = rte_rawdev_firmware_unload(test_dev_id); RTE_TEST_ASSERT_SUCCESS(ret, "Failed to unload firmware (%d)", ret); return TEST_SUCCESS; @@ -365,7 +366,7 @@ test_rawdev_enqdeq(void) snprintf(buffers[0].buf_addr, strlen(TEST_DEV_NAME) + 2, "%s%d", TEST_DEV_NAME, 0); - ret = rte_rawdev_enqueue_buffers(TEST_DEV_ID, + ret = rte_rawdev_enqueue_buffers(test_dev_id, (struct rte_rawdev_buf **)&buffers, count, &queue_id); RTE_TEST_ASSERT_EQUAL((unsigned int)ret, count, @@ -375,7 +376,7 @@ test_rawdev_enqdeq(void) if (!deq_buffers) goto cleanup; - ret = rte_rawdev_dequeue_buffers(TEST_DEV_ID, + ret = rte_rawdev_dequeue_buffers(test_dev_id, (struct rte_rawdev_buf **)&deq_buffers, count, &queue_id); RTE_TEST_ASSERT_EQUAL((unsigned int)ret, count, -- 2.21.0