From patchwork Thu Jun 23 09:30:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kundapura, Ganapati" X-Patchwork-Id: 113329 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 61005A0093; Thu, 23 Jun 2022 11:31:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 35D744282C; Thu, 23 Jun 2022 11:30:48 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 41DC8427EE for ; Thu, 23 Jun 2022 11:30:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655976642; x=1687512642; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=+frSh5ketlYyq9g8DIvcCE4e4LnZw9ifRa7rNh1behU=; b=gn/7k609EOTIWlmthS90/fdCYWENo5vAwniPXGM6zddi86h5/WesfF41 iuDSjPspYEc9XT2GuMX31QxV9uFOo8ZiwQfbex6LnSLM4pz6oz13o+l2M CqtFrbVgOQ7qnL3Hyx/mqj56TQRVLniQcx71jbpo74BBZoZ3Ri1O3TQiU gjTYohX4+GtWzIR130MxkJ6yIIldFEGsqcN+AkdwE8k0puPx872vN5YUu lD60kys/CX4KarWamT0lOhyhaGnzsrI1RN78hQKYoWnEV9W6z88oGFQO3 P0OzyvX8d6Rcj8tUblwUW+xEEMUx90tczO093r/PWMIZ57LnL+59Z489p g==; X-IronPort-AV: E=McAfee;i="6400,9594,10386"; a="344662873" X-IronPort-AV: E=Sophos;i="5.92,215,1650956400"; d="scan'208";a="344662873" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 02:30:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,215,1650956400"; d="scan'208";a="677984009" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by FMSMGA003.fm.intel.com with ESMTP; 23 Jun 2022 02:30:40 -0700 From: Ganapati Kundapura To: dev@dpdk.org, jerinj@marvell.com, jay.jayatheerthan@intel.com, s.v.naga.harish.k@intel.com Subject: [PATCH v10 5/7] test/eth_tx: add testcase for instance get API Date: Thu, 23 Jun 2022 04:30:34 -0500 Message-Id: <20220623093036.708448-5-ganapati.kundapura@intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220623093036.708448-1-ganapati.kundapura@intel.com> References: <20220623062418.694734-1-ganapati.kundapura@intel.com> <20220623093036.708448-1-ganapati.kundapura@intel.com> MIME-Version: 1.0 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 testcase for rte_event_eth_tx_adapter_instance_get() Signed-off-by: Ganapati Kundapura Reviewed-by: Naga Harish K S V Acked-by: Jay Jayatheerthan --- app/test/test_event_eth_tx_adapter.c | 75 ++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/app/test/test_event_eth_tx_adapter.c b/app/test/test_event_eth_tx_adapter.c index 2900532..98debfd 100644 --- a/app/test/test_event_eth_tx_adapter.c +++ b/app/test/test_event_eth_tx_adapter.c @@ -29,6 +29,7 @@ test_event_eth_tx_adapter_common(void) #define MAX_NUM_QUEUE RTE_PMD_RING_MAX_RX_RINGS #define TEST_INST_ID 0 #define TEST_DEV_ID 0 +#define TEST_ETH_QUEUE_ID 0 #define SOCKET0 0 #define RING_SIZE 256 #define ETH_NAME_LEN 32 @@ -639,6 +640,78 @@ tx_adapter_service(void) } static int +tx_adapter_instance_get(void) +{ + int err; + uint8_t inst_id; + uint16_t eth_dev_id; + struct rte_eth_dev_info dev_info; + + /* Case 1: Test without configuring eth */ + err = rte_event_eth_tx_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_tx_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 tx 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_tx_adapter_instance_get(TEST_ETHDEV_ID, + dev_info.max_tx_queues + 1, + &inst_id); + TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err); + + /* Case 4: Test with right instance, port & rxq */ + /* Add queue to tx adapter */ + err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID, + TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_tx_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 another queue to tx adapter */ + err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID, + TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID + 1); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_tx_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); + + /* Case 5: Test with right instance, port & wrong rxq */ + err = rte_event_eth_tx_adapter_instance_get(TEST_ETHDEV_ID, + TEST_ETH_QUEUE_ID + 2, + &inst_id); + TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err); + + /* Delete all queues from the Tx adapter */ + err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID, + TEST_ETHDEV_ID, + -1); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + return TEST_SUCCESS; +} + +static int tx_adapter_dynamic_device(void) { uint16_t port_id = rte_eth_dev_count_avail(); @@ -695,6 +768,8 @@ static struct unit_test_suite event_eth_tx_tests = { tx_adapter_start_stop), TEST_CASE_ST(tx_adapter_create, tx_adapter_free, tx_adapter_service), + TEST_CASE_ST(tx_adapter_create, tx_adapter_free, + tx_adapter_instance_get), TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device), TEST_CASES_END() /**< NULL terminate unit test array */ }