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 8D51741C5A; Fri, 10 Feb 2023 05:58:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5E032427F2; Fri, 10 Feb 2023 05:58:25 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 54F20410D0 for ; Fri, 10 Feb 2023 05:58:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676005103; x=1707541103; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tQTGHyUooVh6Q41L6wdDm1xnMKZ/XqSeoKvZIO2KPt8=; b=eyu2XO8yEJohiMDV61KYiRHI7x9aEgu5CRl8jZNkty6zuSmyxfTC+2ub SSY7rvVh6rI1M6qJbAkZ9IF8F2g38Pa6hC73wfgu7on8Xrvt1tsBbarDZ bzkJZmfOoLkGY+CaWK0Kj6ist+LRELDPbld58sQPtMk7AL9IxZ3ZEYUbc IE++ipF4Nkc1Xxkl/ZctELvnb0FFRD/+/9o4E2/OI5OPWdKSU0WidCIWH WXeKkvij9XwAGgNJCki7AJBBIlfih+yI7Cb3YidIr+NthKZAtEL/yO8VI kscEwBd0wju8gBod1NMpMwM0wblDi6BSaHJKY6Jl1QgVIU8+3Y9KtGvnf A==; X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="318354278" X-IronPort-AV: E=Sophos;i="5.97,285,1669104000"; d="scan'208";a="318354278" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2023 20:58:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="841912878" X-IronPort-AV: E=Sophos;i="5.97,285,1669104000"; d="scan'208";a="841912878" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by orsmga005.jf.intel.com with ESMTP; 09 Feb 2023 20:58:22 -0800 From: Naga Harish K S V To: jerinj@marvell.com, erik.g.carrillo@intel.com, abhinandan.gujjar@intel.com Cc: dev@dpdk.org, jay.jayatheerthan@intel.com Subject: [PATCH v4 2/3] eventdev/eth_tx: add params set/get APIs Date: Thu, 9 Feb 2023 22:58:15 -0600 Message-Id: <20230210045816.3039312-2-s.v.naga.harish.k@intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20230210045816.3039312-1-s.v.naga.harish.k@intel.com> References: <20230123180458.486189-1-s.v.naga.harish.k@intel.com> <20230210045816.3039312-1-s.v.naga.harish.k@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 The adapter configuration parameters defined in the ``struct rte_event_eth_tx_adapter_runtime_params`` can be configured and retrieved using ``rte_event_eth_tx_adapter_runtime_params_set`` and ``rte_event_eth_tx_adapter_runtime_params_get`` respectively. Signed-off-by: Naga Harish K S V --- app/test/test_event_eth_tx_adapter.c | 130 ++++++++++++++++++ .../prog_guide/event_ethernet_tx_adapter.rst | 15 ++ lib/eventdev/rte_event_eth_tx_adapter.c | 103 +++++++++++++- lib/eventdev/rte_event_eth_tx_adapter.h | 103 ++++++++++++++ lib/eventdev/version.map | 2 + 5 files changed, 350 insertions(+), 3 deletions(-) diff --git a/app/test/test_event_eth_tx_adapter.c b/app/test/test_event_eth_tx_adapter.c index c19a87a86a..a093ee0efc 100644 --- a/app/test/test_event_eth_tx_adapter.c +++ b/app/test/test_event_eth_tx_adapter.c @@ -795,6 +795,134 @@ tx_adapter_queue_start_stop(void) return TEST_SUCCESS; } +static int +tx_adapter_set_get_params(void) +{ + int err; + struct rte_event_eth_tx_adapter_runtime_params in_params; + struct rte_event_eth_tx_adapter_runtime_params out_params; + + err = rte_event_eth_tx_adapter_queue_add(TEST_INST_ID, + TEST_ETHDEV_ID, + 0); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_tx_adapter_runtime_params_init(&in_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + err = rte_event_eth_tx_adapter_runtime_params_init(&out_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + /* Case 1: Get the default values of adapter */ + err = rte_event_eth_tx_adapter_runtime_params_get(TEST_INST_ID, + &out_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + TEST_ASSERT(out_params.flush_threshold == TXA_FLUSH_THRESHOLD, + "Expected %u got %u", + TXA_FLUSH_THRESHOLD, out_params.flush_threshold); + TEST_ASSERT(out_params.max_nb_tx == TXA_MAX_NB_TX, + "Expected %u got %u", + TXA_MAX_NB_TX, out_params.max_nb_tx); + + /* Case 2: Set max_nb_tx = 32 (=TXA_BATCH_SEIZE) */ + in_params.max_nb_tx = 32; + in_params.flush_threshold = TXA_FLUSH_THRESHOLD; + + err = rte_event_eth_tx_adapter_runtime_params_set(TEST_INST_ID, + &in_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_tx_adapter_runtime_params_get(TEST_INST_ID, + &out_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + TEST_ASSERT(in_params.max_nb_tx == out_params.max_nb_tx, + "Expected %u got %u", + in_params.max_nb_tx, out_params.max_nb_tx); + TEST_ASSERT(in_params.flush_threshold == out_params.flush_threshold, + "Expected %u got %u", + in_params.flush_threshold, out_params.flush_threshold); + + /* Case 3: Set max_nb_tx = 192 */ + in_params.max_nb_tx = 192; + + err = rte_event_eth_tx_adapter_runtime_params_set(TEST_INST_ID, + &in_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_tx_adapter_runtime_params_get(TEST_INST_ID, + &out_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + TEST_ASSERT(in_params.max_nb_tx == out_params.max_nb_tx, + "Expected %u got %u", + in_params.max_nb_tx, out_params.max_nb_tx); + + /* Case 4: Set max_nb_tx = 256 */ + in_params.max_nb_tx = 256; + + err = rte_event_eth_tx_adapter_runtime_params_set(TEST_INST_ID, + &in_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_tx_adapter_runtime_params_get(TEST_INST_ID, + &out_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + TEST_ASSERT(in_params.max_nb_tx == out_params.max_nb_tx, + "Expected %u got %u", + in_params.max_nb_tx, out_params.max_nb_tx); + + /* Case 5: Set max_nb_tx = 30(loop_cnt++ & (TXA_FLUSH_THRESHOLD - 1)) == 0) { + if (txa->loop_cnt++ == txa->flush_threshold) { struct txa_service_ethdev *tdi; struct txa_service_queue_info *tqi; struct rte_eth_dev *dev; uint16_t i; + txa->loop_cnt = 0; tdi = txa->txa_ethdev; nb_tx = 0; @@ -769,6 +770,7 @@ txa_service_adapter_create_ext(uint8_t id, struct rte_eventdev *dev, txa->service_id = TXA_INVALID_SERVICE_ID; rte_spinlock_init(&txa->tx_lock); txa_service_data_array[id] = txa; + txa->flush_threshold = TXA_FLUSH_THRESHOLD; return 0; } @@ -1291,6 +1293,101 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id) return ret; } +static int +txa_caps_check(uint8_t id, struct txa_service_data *txa) +{ + uint32_t caps = 0; + struct rte_eth_dev *eth_dev = NULL; + struct txa_service_ethdev *tdi; + int i; + + if (!txa->dev_count) + return -EINVAL; + + /* The eth_dev used is always the same type. + * Hence first valid eth_dev is taken. + */ + for (i = 0; i < txa->dev_count; i++) { + tdi = &txa->txa_ethdev[i]; + if (tdi->nb_queues) { + eth_dev = tdi->dev; + break; + } + } + if (eth_dev == NULL) + return -EINVAL; + + if (txa_dev_caps_get(id)) + txa_dev_caps_get(id)(txa_evdev(id), eth_dev, &caps); + + if (caps & RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT) + return -ENOTSUP; + + return 0; +} + +int +rte_event_eth_tx_adapter_runtime_params_set(uint8_t id, + struct rte_event_eth_tx_adapter_runtime_params *txa_params) +{ + struct txa_service_data *txa; + int ret; + + if (txa_lookup()) + return -ENOMEM; + + TXA_CHECK_OR_ERR_RET(id); + + if (txa_params == NULL) + return -EINVAL; + + txa = txa_service_id_to_data(id); + if (txa == NULL) + return -EINVAL; + + ret = txa_caps_check(id, txa); + if (ret) + return ret; + + rte_spinlock_lock(&txa->tx_lock); + txa->flush_threshold = txa_params->flush_threshold; + txa->max_nb_tx = txa_params->max_nb_tx; + rte_spinlock_unlock(&txa->tx_lock); + + return 0; +} + +int +rte_event_eth_tx_adapter_runtime_params_get(uint8_t id, + struct rte_event_eth_tx_adapter_runtime_params *txa_params) +{ + struct txa_service_data *txa; + int ret; + + if (txa_lookup()) + return -ENOMEM; + + TXA_CHECK_OR_ERR_RET(id); + + if (txa_params == NULL) + return -EINVAL; + + txa = txa_service_id_to_data(id); + if (txa == NULL) + return -EINVAL; + + ret = txa_caps_check(id, txa); + if (ret) + return ret; + + rte_spinlock_lock(&txa->tx_lock); + txa_params->flush_threshold = txa->flush_threshold; + txa_params->max_nb_tx = txa->max_nb_tx; + rte_spinlock_unlock(&txa->tx_lock); + + return 0; +} + int rte_event_eth_tx_adapter_stop(uint8_t id) { diff --git a/lib/eventdev/rte_event_eth_tx_adapter.h b/lib/eventdev/rte_event_eth_tx_adapter.h index cd539af7ef..e0332910eb 100644 --- a/lib/eventdev/rte_event_eth_tx_adapter.h +++ b/lib/eventdev/rte_event_eth_tx_adapter.h @@ -37,6 +37,8 @@ * - rte_event_eth_tx_adapter_instance_get() * - rte_event_eth_tx_adapter_queue_start() * - rte_event_eth_tx_adapter_queue_stop() + * - rte_event_eth_tx_adapter_runtime_params_get() + * - rte_event_eth_tx_adapter_runtime_params_set() * * The application creates the adapter using * rte_event_eth_tx_adapter_create() or rte_event_eth_tx_adapter_create_ext(). @@ -103,6 +105,33 @@ struct rte_event_eth_tx_adapter_conf { */ }; +#define TXA_FLUSH_THRESHOLD 1024 +/**< The default value of flush threshold for service + * based adapter. + */ + +#define TXA_MAX_NB_TX 128 +/**< The default value for maximum number of packets processed by service + * based adapter per each call. + */ + +/** + * Adapter runtime configuration parameters + */ +struct rte_event_eth_tx_adapter_runtime_params { + uint32_t max_nb_tx; + /**< The adapter can return early if it has processed at least + * max_nb_tx mbufs. This isn't treated as a requirement; batching may + * cause the adapter to process more than max_nb_tx mbufs. + */ + uint16_t flush_threshold; + /**< the number of service function iteration count to + * flush buffered packets. + */ + uint16_t rsvd[29]; + /**< Reserved fields for future expansion */ +}; + /** * Function type used for adapter configuration callback. The callback is * used to fill in members of the struct rte_event_eth_tx_adapter_conf, this @@ -516,6 +545,80 @@ __rte_experimental int rte_event_eth_tx_adapter_queue_stop(uint16_t eth_dev_id, uint16_t tx_queue_id); +/** + * Initialize the adapter runtime configuration parameters with default values + * + * @param txa_params + * A pointer to structure of type struct rte_event_eth_tx_adapter_runtime_params + * + * @return + * - 0: Success + * - <0: Error code on failure + */ +__rte_experimental +static inline int +rte_event_eth_tx_adapter_runtime_params_init( + struct rte_event_eth_tx_adapter_runtime_params *txa_params) +{ + if (txa_params == NULL) + return -EINVAL; + + memset(txa_params, 0, sizeof(*txa_params)); + txa_params->max_nb_tx = TXA_MAX_NB_TX; + txa_params->flush_threshold = TXA_FLUSH_THRESHOLD; + + return 0; +} + +/** + * Set the runtime configuration parameters for adapter. + * + * In case not all fields are to be updated, the suggested way to use this + * api is read the current values using rte_event_eth_tx_adapter_get_params(), + * modify the required parameters and then call + * rte_event_eth_tx_adapter_runtime_params_set(). + * + * This API is to be used after adding at least one queue to the adapter + * and is supported only for service based adapter. + * + * @param id + * Adapter identifier + * @param params + * A pointer to structure of type struct rte_event_eth_tx_adapter_runtime_params + * with configuration parameter values. This structure can be initialized using + * rte_event_eth_tx_adapter_runtime_params_init() API to default values or + * application may reset this structure and update required fields. + * + * @return + * - 0: Success + * - <0: Error code on failure + */ +__rte_experimental +int +rte_event_eth_tx_adapter_runtime_params_set(uint8_t id, + struct rte_event_eth_tx_adapter_runtime_params *params); + +/** + * Get the runtime configuration parameters of adapter. + * + * This API is to be used after adding at least one queue to the adapter + * and is supported only for service based adapter. + * + * @param id + * Adapter identifier + * @param[out] params + * A pointer to structure of type struct rte_event_eth_tx_adapter_runtime_params + * containing valid Tx adapter parameters when return value is 0. + * + * @return + * - 0: Success + * - <0: Error code on failure + */ +__rte_experimental +int +rte_event_eth_tx_adapter_runtime_params_get(uint8_t id, + struct rte_event_eth_tx_adapter_runtime_params *params); + #ifdef __cplusplus } #endif diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map index da97db794f..38dfbb1f41 100644 --- a/lib/eventdev/version.map +++ b/lib/eventdev/version.map @@ -123,6 +123,8 @@ EXPERIMENTAL { # added in 23.03 rte_event_eth_rx_adapter_runtime_params_get; rte_event_eth_rx_adapter_runtime_params_set; + rte_event_eth_tx_adapter_runtime_params_get; + rte_event_eth_tx_adapter_runtime_params_set; rte_event_timer_remaining_ticks_get; }; -- 2.25.1