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 16C10A00C2; Sat, 7 Jan 2023 17:19:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A518B4021D; Sat, 7 Jan 2023 17:19:00 +0100 (CET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 4008140141 for ; Sat, 7 Jan 2023 17:18:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673108338; x=1704644338; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=7Hdj2ooWLpSO2tMHt8F7iZjqbUh0rkuzsiPkJ8UWlLk=; b=P4YeUaPSvGHruFHlkpQOU9AILDfOgonMQguggqrW9s2sv4iZJI/ZfHtk 4IkHtk1Wij+HFb1OUl9ZWKQfUmzf6NxC8zFAXmOtHT/LNBdJnQS3CA+99 G3t9XBE4E64upuPTIT1BLaML83g5dPZzpyXLEuHa8Xv1adrnb/e59bEHs XGrmeaTVGVMcWXSxvFO4sRaHIRPt7aL+iQoAqBDMeJbk0UJkrLEHKp0zv TC7iHUHAdiYDJyhpqgWrTt7XikEh2cWd5cA+ev1wpn79mdXvD/rBX8E7q z05ISZmmPSyujDFe4JpwuHoBqnQGXQbWstpyoLGLO2rsT8vd9myWD1UM6 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10583"; a="384952337" X-IronPort-AV: E=Sophos;i="5.96,308,1665471600"; d="scan'208";a="384952337" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jan 2023 08:18:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10583"; a="686770142" X-IronPort-AV: E=Sophos;i="5.96,308,1665471600"; d="scan'208";a="686770142" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by orsmga008.jf.intel.com with ESMTP; 07 Jan 2023 08:18:56 -0800 From: Naga Harish K S V To: jerinj@marvell.com, abhinandan.gujjar@intel.com Cc: dev@dpdk.org, jay.jayatheerthan@intel.com Subject: [PATCH 1/3] eventdev/eth_rx: add params set/get APIs Date: Sat, 7 Jan 2023 10:18:50 -0600 Message-Id: <20230107161852.3708690-1-s.v.naga.harish.k@intel.com> X-Mailer: git-send-email 2.23.0 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 The adapter configuration parameters defined in the ``struct rte_event_eth_rx_adapter_config_params`` can be configured and retrieved using ``rte_event_eth_rx_adapter_set_params`` and ``rte_event_eth_tx_adapter_get_params`` respectively. Signed-off-by: Naga Harish K S V --- app/test/test_event_eth_rx_adapter.c | 62 ++++++++++++++++++ .../prog_guide/event_ethernet_rx_adapter.rst | 20 ++++++ lib/eventdev/rte_event_eth_rx_adapter.c | 49 ++++++++++++++- lib/eventdev/rte_event_eth_rx_adapter.h | 63 ++++++++++++++++++- lib/eventdev/version.map | 4 ++ 5 files changed, 196 insertions(+), 2 deletions(-) diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c index 1da7782560..f548e3c059 100644 --- a/app/test/test_event_eth_rx_adapter.c +++ b/app/test/test_event_eth_rx_adapter.c @@ -1198,6 +1198,66 @@ adapter_intrq_instance_get(void) return TEST_SUCCESS; } +static int +adapter_get_set_params(void) +{ + int err; + struct rte_event_eth_rx_adapter_runtime_params in_params; + struct rte_event_eth_rx_adapter_runtime_params out_params; + + /* Case 1: Get the default value of mbufs processed by Rx adapter */ + err = rte_event_eth_rx_adapter_get_params(TEST_INST_ID, &out_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + /* Case 2: Set max_nb_rx = 32 (=BATCH_SEIZE) */ + in_params.max_nb_rx = 32; + + err = rte_event_eth_rx_adapter_set_params(TEST_INST_ID, &in_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_rx_adapter_get_params(TEST_INST_ID, &out_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + TEST_ASSERT(in_params.max_nb_rx == out_params.max_nb_rx, "Expected %u got %u", + in_params.max_nb_rx, out_params.max_nb_rx); + + /* Case 3: Set max_nb_rx = 192 */ + in_params.max_nb_rx = 192; + + err = rte_event_eth_rx_adapter_set_params(TEST_INST_ID, &in_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_rx_adapter_get_params(TEST_INST_ID, &out_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + TEST_ASSERT(in_params.max_nb_rx == out_params.max_nb_rx, "Expected %u got %u", + in_params.max_nb_rx, out_params.max_nb_rx); + + /* Case 4: Set max_nb_rx = 256 */ + in_params.max_nb_rx = 256; + + err = rte_event_eth_rx_adapter_set_params(TEST_INST_ID, &in_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_rx_adapter_get_params(TEST_INST_ID, &out_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + TEST_ASSERT(in_params.max_nb_rx == out_params.max_nb_rx, "Expected %u got %u", + in_params.max_nb_rx, out_params.max_nb_rx); + + /* Case 5: Set max_nb_rx = 30(event_port_id = port_id; - conf->max_nb_rx = 128; + conf->max_nb_rx = RXA_NB_RX_WORK_DEFAULT; if (started) ret = rte_event_dev_start(dev_id); rx_adapter->default_cb_arg = 1; @@ -3433,6 +3435,51 @@ rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id, return -EINVAL; } +int +rte_event_eth_rx_adapter_set_params(uint8_t id, + struct rte_event_eth_rx_adapter_runtime_params *params) +{ + struct event_eth_rx_adapter *rx_adapter; + + if (rxa_memzone_lookup()) + return -ENOMEM; + + if (params == NULL) + return -EINVAL; + + rx_adapter = rxa_id_to_adapter(id); + if (rx_adapter == NULL) + return -EINVAL; + + rte_spinlock_lock(&rx_adapter->rx_lock); + rx_adapter->max_nb_rx = params->max_nb_rx; + rte_spinlock_unlock(&rx_adapter->rx_lock); + + return 0; +} + +int +rte_event_eth_rx_adapter_get_params(uint8_t id, + struct rte_event_eth_rx_adapter_runtime_params *params) +{ + struct event_eth_rx_adapter *rx_adapter; + + if (rxa_memzone_lookup()) + return -ENOMEM; + + if (params == NULL) + return -EINVAL; + + rx_adapter = rxa_id_to_adapter(id); + if (rx_adapter == NULL) + return -EINVAL; + + params->max_nb_rx = rx_adapter->max_nb_rx; + + return 0; +} + +/* RX-adapter telemetry callbacks */ #define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s) static int diff --git a/lib/eventdev/rte_event_eth_rx_adapter.h b/lib/eventdev/rte_event_eth_rx_adapter.h index d0e7d0092c..d05525d3e2 100644 --- a/lib/eventdev/rte_event_eth_rx_adapter.h +++ b/lib/eventdev/rte_event_eth_rx_adapter.h @@ -39,10 +39,20 @@ * - rte_event_eth_rx_adapter_queue_stats_reset() * - rte_event_eth_rx_adapter_event_port_get() * - rte_event_eth_rx_adapter_instance_get() + * - rte_event_eth_rx_adapter_set_params() + * - rte_event_eth_rx_adapter_get_params() * * The application creates an ethernet to event adapter using * rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create() * or rte_event_eth_rx_adapter_create_with_params() functions. + * + * rte_event_eth_rx_adapter_create() or rte_event_eth_adapter_create_with_params() + * configures the adapter with default value of maximum packets processed per + * iteration to RXA_NB_RX_WORK_DEFAULT(128). rte_event_eth_rx_adapter_set_params() + * allows to re-configure maximum packets processed per iteration. This is + * alternative to using rte_event_eth_rx_adapter_create_ext() with parameter + * rte_event_eth_rx_adapter_conf::max_nb_rx + * * The adapter needs to know which ethernet rx queues to poll for mbufs as well * as event device parameters such as the event queue identifier, event * priority and scheduling type that the adapter should use when constructing @@ -299,6 +309,17 @@ struct rte_event_eth_rx_adapter_params { /**< flag to indicate that event buffer is separate for each queue */ }; +/** + * Adapter configuration parameters + */ +struct rte_event_eth_rx_adapter_runtime_params { + uint32_t max_nb_rx; + /**< The adapter can return early if it has processed at least + * max_nb_rx mbufs. This isn't treated as a requirement; batching may + * cause the adapter to process more than max_nb_rx mbufs. + */ +}; + /** * * Callback function invoked by the SW adapter before it continues @@ -377,7 +398,7 @@ int rte_event_eth_rx_adapter_create_ext(uint8_t id, uint8_t dev_id, * Create a new ethernet Rx event adapter with the specified identifier. * This function uses an internal configuration function that creates an event * port. This default function reconfigures the event device with an - * additional event port and setups up the event port using the port_config + * additional event port and setup the event port using the port_config * parameter passed into this function. In case the application needs more * control in configuration of the service, it should use the * rte_event_eth_rx_adapter_create_ext() version. @@ -729,6 +750,46 @@ rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id, uint16_t rx_queue_id, uint8_t *rxa_inst_id); +/** + * Set the adapter configuration parameters + * + * This API is to be used after adding at least one queue to the adapter. + * + * @param id + * Adapter identifier + * + * @param params + * A pointer to structure of type struct rte_event_eth_rx_adapter_runtime_params + * with configuration parameter values. + * + * @return + * - 0: Success + * - <0: Error code on failure + */ +__rte_experimental +int +rte_event_eth_rx_adapter_set_params(uint8_t id, + struct rte_event_eth_rx_adapter_runtime_params *params); + +/** + * Get the adapter configuration parameters + * + * @param id + * Adapter identifier + * + * @param[out] params + * A pointer to structure of type struct rte_event_eth_rx_adapter_runtime_params + * containing valid adapter parameters when return value is 0 + * + * @return + * - 0: Success + * - <0: Error code on failure + */ +__rte_experimental +int +rte_event_eth_rx_adapter_get_params(uint8_t id, + struct rte_event_eth_rx_adapter_runtime_params *params); + #ifdef __cplusplus } #endif diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map index dd63ec6f68..01ae975a26 100644 --- a/lib/eventdev/version.map +++ b/lib/eventdev/version.map @@ -118,6 +118,10 @@ EXPERIMENTAL { rte_event_eth_tx_adapter_instance_get; rte_event_eth_tx_adapter_queue_start; rte_event_eth_tx_adapter_queue_stop; + + # added in 23.03 + rte_event_eth_rx_adapter_get_params; + rte_event_eth_rx_adapter_set_params; }; INTERNAL { -- 2.25.1