[PATCH v8 5/7] test/eth_tx: add testcase for instance get API

Naga Harish K, S V s.v.naga.harish.k at intel.com
Wed Jun 22 19:30:11 CEST 2022


Reviewed-by: Naga Harish K S V <s.v.naga.harish.k at intel.com>

> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura at intel.com>
> Sent: Wednesday, June 22, 2022 10:24 PM
> To: dev at dpdk.org; jerinj at marvell.com; Jayatheerthan, Jay
> <jay.jayatheerthan at intel.com>; Naga Harish K, S V
> <s.v.naga.harish.k at intel.com>
> Subject: [PATCH v8 5/7] test/eth_tx: add testcase for instance get API
> 
> Added testcase for rte_event_eth_tx_adapter_instance_get()
> 
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura at intel.com>
> ---
>  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 */
>  	}
> --
> 2.6.4



More information about the dev mailing list