From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 77524A00C3; Thu, 23 Jun 2022 08:24:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 971C64280E; Thu, 23 Jun 2022 08:24:30 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id C1A3F4069D for ; Thu, 23 Jun 2022 08:24:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655965463; x=1687501463; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=Eq/HCc1H2oBQEyRORUbiN0o0f/CcolqfoqV+MOYu4XE=; b=PMcbQJhMJHPckUK4ed5bhsERVJx+o7GMgDetxganDA1NMBUcrtzXB9YX r8iw/xXdbLmhu37JIS7WaRTmR75KyG4yXtnBChxyziM/7ynVKUGrNkWDX h7o1x5OUFzE4CLocxE0vV4xkTWbMWgYVfDx+9Vto8ihe4zZO4EHxGbDcN MJgh7Y/V2lLlveFQ3dusBHXtugX4K8AWETa2YqLeObCJM/0h+DLHGPjEX yu9xQgORoznynfs8Eqi8Rwxrre4ZYfnUeZjzk7+sKSHhhjMnUL24rc582 vjs+T+MZ/mWPKIT4ZfH6fCV0Q4wYU/3YdYu4AyL/j5TAmQgt257yZZGWC w==; X-IronPort-AV: E=McAfee;i="6400,9594,10386"; a="260455673" X-IronPort-AV: E=Sophos;i="5.92,215,1650956400"; d="scan'208";a="260455673" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2022 23:24:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,215,1650956400"; d="scan'208";a="677922894" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by FMSMGA003.fm.intel.com with ESMTP; 22 Jun 2022 23:24:21 -0700 From: Ganapati Kundapura To: dev@dpdk.org, jerinj@marvell.com, jay.jayatheerthan@intel.com, s.v.naga.harish.k@intel.com Subject: [PATCH v9 3/7] test/eth_rx: add test case for instance get API Date: Thu, 23 Jun 2022 01:24:14 -0500 Message-Id: <20220623062418.694734-3-ganapati.kundapura@intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220623062418.694734-1-ganapati.kundapura@intel.com> References: <20220622165405.533042-1-ganapati.kundapura@intel.com> <20220623062418.694734-1-ganapati.kundapura@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Added test case for rte_event_eth_rx_adapter_instance_get() Signed-off-by: Ganapati Kundapura --- app/test/test_event_eth_rx_adapter.c | 203 ++++++++++++++++++++++++++++++++++- 1 file changed, 202 insertions(+), 1 deletion(-) diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c index e358a70..1da7782 100644 --- a/app/test/test_event_eth_rx_adapter.c +++ b/app/test/test_event_eth_rx_adapter.c @@ -39,6 +39,7 @@ test_event_eth_rx_intr_adapter_common(void) #define TEST_INST_ID 0 #define TEST_DEV_ID 0 #define TEST_ETHDEV_ID 0 +#define TEST_ETH_QUEUE_ID 0 struct event_eth_rx_adapter_test_params { struct rte_mempool *mp; @@ -1001,6 +1002,202 @@ adapter_queue_conf(void) return TEST_SUCCESS; } +static int +adapter_pollq_instance_get(void) +{ + int err; + uint8_t inst_id; + uint16_t eth_dev_id; + struct rte_eth_dev_info dev_info; + struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0}; + + /* Case 1: Test without configuring eth */ + err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID, + &inst_id); + TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err); + + /* Case 2: Test with wrong eth port */ + eth_dev_id = rte_eth_dev_count_total() + 1; + err = rte_event_eth_rx_adapter_instance_get(eth_dev_id, + TEST_ETH_QUEUE_ID, + &inst_id); + TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err); + + /* Case 3: Test with wrong rx queue */ + err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID, + dev_info.max_rx_queues + 1, + &inst_id); + TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err); + + /* Case 4: Test with right instance, port & rxq */ + /* Add queue 1 to Rx adapter */ + queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID; + queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC; + queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL; + queue_conf.servicing_weight = 1; /* poll queue */ + + err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID, + TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID, + &queue_conf); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID, + &inst_id); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d", + TEST_INST_ID, err); + + /* Add queue 2 to Rx adapter */ + queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1; + err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID, + TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID + 1, + &queue_conf); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID + 1, + &inst_id); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d", + TEST_INST_ID, err); + + /* Add queue 3 to Rx adapter */ + queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2; + err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID, + TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID + 2, + &queue_conf); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID + 2, + &inst_id); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d", + TEST_INST_ID, err); + + /* Case 5: Test with right instance, port & wrong rxq */ + err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID + 3, + &inst_id); + TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err); + + /* Delete all queues from the Rx adapter */ + err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID, + TEST_ETHDEV_ID, + -1); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + return TEST_SUCCESS; +} + +static int +adapter_intrq_instance_get(void) +{ + int err; + uint8_t inst_id; + uint16_t eth_dev_id; + struct rte_eth_dev_info dev_info; + struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0}; + + /* Case 1: Test without configuring eth */ + err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID, + &inst_id); + TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err); + + /* Case 2: Test with wrong eth port */ + eth_dev_id = rte_eth_dev_count_total() + 1; + err = rte_event_eth_rx_adapter_instance_get(eth_dev_id, + TEST_ETH_QUEUE_ID, + &inst_id); + TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err); + + /* Case 3: Test with wrong rx queue */ + err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID, + dev_info.max_rx_queues + 1, + &inst_id); + TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err); + + /* Case 4: Test with right instance, port & rxq */ + /* Intr enabled eth device can have both polled and intr queues. + * Add polled queue 1 to Rx adapter + */ + queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID; + queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC; + queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL; + queue_conf.servicing_weight = 1; /* poll queue */ + + err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID, + TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID, + &queue_conf); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID, + &inst_id); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d", + TEST_INST_ID, err); + + /* Add intr queue 2 to Rx adapter */ + queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1; + queue_conf.servicing_weight = 0; /* intr queue */ + err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID, + TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID + 1, + &queue_conf); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID + 1, + &inst_id); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d", + TEST_INST_ID, err); + + /* Add intr queue 3 to Rx adapter */ + queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2; + queue_conf.servicing_weight = 0; /* intr queue */ + err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID, + TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID + 2, + &queue_conf); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID + 2, + &inst_id); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d", + TEST_INST_ID, err); + + /* Case 5: Test with right instance, port & wrong rxq */ + err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID + 3, + &inst_id); + TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err); + + /* Delete all queues from the Rx adapter */ + err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID, + TEST_ETHDEV_ID, + -1); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + return TEST_SUCCESS; +} + static struct unit_test_suite event_eth_rx_tests = { .suite_name = "rx event eth adapter test suite", .setup = testsuite_setup, @@ -1019,6 +1216,8 @@ static struct unit_test_suite event_eth_rx_tests = { adapter_queue_event_buf_test), TEST_CASE_ST(adapter_create_with_params, adapter_free, adapter_queue_stats_test), + TEST_CASE_ST(adapter_create, adapter_free, + adapter_pollq_instance_get), TEST_CASES_END() /**< NULL terminate unit test array */ } }; @@ -1029,7 +1228,9 @@ static struct unit_test_suite event_eth_rx_intr_tests = { .teardown = testsuite_teardown_rx_intr, .unit_test_cases = { TEST_CASE_ST(adapter_create, adapter_free, - adapter_intr_queue_add_del), + adapter_intr_queue_add_del), + TEST_CASE_ST(adapter_create, adapter_free, + adapter_intrq_instance_get), TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 2.6.4