From patchwork Mon Jan 23 18:04:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Naga Harish K, S V" X-Patchwork-Id: 122446 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 DFAE44246D; Mon, 23 Jan 2023 19:05:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 78EF940223; Mon, 23 Jan 2023 19:05:05 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id C540E400EF for ; Mon, 23 Jan 2023 19:05:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674497104; x=1706033104; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gpZDuWBjYadRV10GVCoPR/D8RZ7dJj/VFl/aUD9s86s=; b=kDwBf/G29b/sWbnMquPy7T0VAeZBlw7jpHaus37/TxrK66i7CzRHtq0r jrXasE6d1xklmPdWpRiXkb2aoHEY/gJ4UNk7XsPoKQ0UMCN4ybbPBzq0X Y0Bw7o+nXvLrE7V4OfDY/SGgQ3KRc/wVtYFEDPqgALByIbhLPNgjwDuVw gush/Zvs+0/ZWzma/i+MfvCDxC8r4c9RTtqem9Ux1CFH0VBx4Vzc/tAyK 0MIyDP0QHCIHgZTSNgy3TmAz2DQf9ehOqnv9bGsHYLr2DEKBn+gl11g95 KO5pHpg/AhBMP2i/rn1xhqAd195NpyP5GwrEf0LYzUIBWCQw0OZGEas0/ A==; X-IronPort-AV: E=McAfee;i="6500,9779,10599"; a="390608229" X-IronPort-AV: E=Sophos;i="5.97,240,1669104000"; d="scan'208";a="390608229" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2023 10:05:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10599"; a="611713864" X-IronPort-AV: E=Sophos;i="5.97,240,1669104000"; d="scan'208";a="611713864" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by orsmga003.jf.intel.com with ESMTP; 23 Jan 2023 10:05:01 -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 v2 1/3] eventdev/eth_rx: add params set/get APIs Date: Mon, 23 Jan 2023 12:04:56 -0600 Message-Id: <20230123180458.486189-1-s.v.naga.harish.k@intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20230107161852.3708690-1-s.v.naga.harish.k@intel.com> References: <20230107161852.3708690-1-s.v.naga.harish.k@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 The adapter configuration parameters defined in the ``struct rte_event_eth_rx_adapter_runtime_params`` can be configured and retrieved using ``rte_event_eth_rx_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_rx_adapter.c | 92 +++++++++++++++++++ .../prog_guide/event_ethernet_rx_adapter.rst | 20 ++++ lib/eventdev/rte_event_eth_rx_adapter.c | 88 +++++++++++++++++- lib/eventdev/rte_event_eth_rx_adapter.h | 70 +++++++++++++- lib/eventdev/version.map | 2 + 5 files changed, 270 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..eeece4918d 100644 --- a/app/test/test_event_eth_rx_adapter.c +++ b/app/test/test_event_eth_rx_adapter.c @@ -1198,6 +1198,96 @@ 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; + struct rte_event_eth_rx_adapter_queue_conf queue_config = {0}; + struct rte_event ev; + + ev.queue_id = 0; + ev.sched_type = RTE_SCHED_TYPE_ATOMIC; + ev.priority = 0; + ev.flow_id = 1; + + queue_config.rx_queue_flags = + RTE_EVENT_ETH_RX_ADAPTER_QUEUE_FLOW_ID_VALID; + queue_config.ev = ev; + queue_config.servicing_weight = 1; + + err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID, + TEST_ETHDEV_ID, 0, + &queue_config); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + /* Case 1: Get the default value of mbufs processed by Rx adapter */ + err = rte_event_eth_rx_adapter_runtime_params_get(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_runtime_params_set(TEST_INST_ID, &in_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_rx_adapter_runtime_params_get(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_runtime_params_set(TEST_INST_ID, &in_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_rx_adapter_runtime_params_get(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_runtime_params_set(TEST_INST_ID, &in_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_eth_rx_adapter_runtime_params_get(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; @@ -3436,6 +3438,90 @@ rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id, return -EINVAL; } +static int +rxa_caps_check(struct event_eth_rx_adapter *rxa) +{ + uint16_t eth_dev_id; + uint32_t caps = 0; + int ret; + + if (!rxa->nb_queues) + return -EINVAL; + + /* The eth_dev used is always of same type. + * Hence eth_dev_id is taken from first entry of poll array. + */ + eth_dev_id = rxa->eth_rx_poll[0].eth_dev_id; + ret = rte_event_eth_rx_adapter_caps_get(rxa->eventdev_id, + eth_dev_id, + &caps); + if (ret) { + RTE_EDEV_LOG_ERR("Failed to get adapter caps edev %" PRIu8 + "eth port %" PRIu16, rxa->eventdev_id, eth_dev_id); + return ret; + } + + if (caps & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT) + return -ENOTSUP; + + return 0; +} + +int +rte_event_eth_rx_adapter_runtime_params_set(uint8_t id, + struct rte_event_eth_rx_adapter_runtime_params *params) +{ + struct event_eth_rx_adapter *rxa; + int ret; + + if (params == NULL) + return -EINVAL; + + if (rxa_memzone_lookup()) + return -ENOMEM; + + rxa = rxa_id_to_adapter(id); + if (rxa == NULL) + return -EINVAL; + + ret = rxa_caps_check(rxa); + if (ret) + return ret; + + rte_spinlock_lock(&rxa->rx_lock); + rxa->max_nb_rx = params->max_nb_rx; + rte_spinlock_unlock(&rxa->rx_lock); + + return 0; +} + +int +rte_event_eth_rx_adapter_runtime_params_get(uint8_t id, + struct rte_event_eth_rx_adapter_runtime_params *params) +{ + struct event_eth_rx_adapter *rxa; + int ret; + + if (params == NULL) + return -EINVAL; + + if (rxa_memzone_lookup()) + return -ENOMEM; + + rxa = rxa_id_to_adapter(id); + if (rxa == NULL) + return -EINVAL; + + ret = rxa_caps_check(rxa); + if (ret) + return ret; + + params->max_nb_rx = rxa->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 f4652f40e8..214ffd018c 100644 --- a/lib/eventdev/rte_event_eth_rx_adapter.h +++ b/lib/eventdev/rte_event_eth_rx_adapter.h @@ -39,10 +39,21 @@ * - 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_runtime_params_get() + * - rte_event_eth_rx_adapter_runtime_params_set() * * 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_runtime_params_set() 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 +310,19 @@ 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. + */ + uint32_t rsvd[15]; + /**< Reserved fields for future use */ +}; + /** * * Callback function invoked by the SW adapter before it continues @@ -377,7 +401,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. @@ -743,6 +767,50 @@ 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 runtime configuration parameters + * + * 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_rx_adapter_runtime_params + * with configuration parameter values. + * + * @return + * - 0: Success + * - <0: Error code on failure + */ +__rte_experimental +int +rte_event_eth_rx_adapter_runtime_params_set(uint8_t id, + struct rte_event_eth_rx_adapter_runtime_params *params); + +/** + * Get the adapter runtime configuration parameters + * + * 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_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_runtime_params_get(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 3add5e3088..da97db794f 100644 --- a/lib/eventdev/version.map +++ b/lib/eventdev/version.map @@ -121,6 +121,8 @@ EXPERIMENTAL { rte_event_eth_tx_adapter_queue_stop; # added in 23.03 + rte_event_eth_rx_adapter_runtime_params_get; + rte_event_eth_rx_adapter_runtime_params_set; rte_event_timer_remaining_ticks_get; }; From patchwork Mon Jan 23 18:04:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Naga Harish K, S V" X-Patchwork-Id: 122447 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 83E064246D; Mon, 23 Jan 2023 19:05:10 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6D35B40E5A; Mon, 23 Jan 2023 19:05:09 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 7863240150 for ; Mon, 23 Jan 2023 19:05:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674497105; x=1706033105; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gFHa5u+Esu/HXxSwbD4LposPpIi57ESYDB7uFtBGmEg=; b=A8ijVfuZ7k9KkozlAEqQ1/PFX6S7HlFI5nWd91YB8Nf7u841rkmAp1sV rZP4jXplzngFCsoCvtd2Tol24cHTpq8JEFk1h+Flf8JCDvcKhAeCN/luD SRosTNW5S6EM5wqzCH4AGgIz2lwioM+N30H28j57EJoeq+Qy6jp5lNJVK hQQAj+FlPH06jyN51/qN3J3szV/RM74D2Ucdl7mbKWyVLE4VPi8qxoIZy 55YtwN9l9AFBXr2gvSOajtVzCa7NAMylcQygrJWo0SLR9pZzEaCBHYbKS /siRPnbiIHtXSfTYmgSrJ+HFn6HWvcHbE4DP8P762oT1TfaDre7XhnI8P w==; X-IronPort-AV: E=McAfee;i="6500,9779,10599"; a="390608248" X-IronPort-AV: E=Sophos;i="5.97,240,1669104000"; d="scan'208";a="390608248" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2023 10:05:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10599"; a="611713880" X-IronPort-AV: E=Sophos;i="5.97,240,1669104000"; d="scan'208";a="611713880" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by orsmga003.jf.intel.com with ESMTP; 23 Jan 2023 10:05:03 -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 v2 2/3] eventdev/eth_tx: add params set/get APIs Date: Mon, 23 Jan 2023 12:04:57 -0600 Message-Id: <20230123180458.486189-2-s.v.naga.harish.k@intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20230123180458.486189-1-s.v.naga.harish.k@intel.com> References: <20230107161852.3708690-1-s.v.naga.harish.k@intel.com> <20230123180458.486189-1-s.v.naga.harish.k@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 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 | 110 ++++++++++++++++++ .../prog_guide/event_ethernet_tx_adapter.rst | 23 ++++ lib/eventdev/rte_event_eth_tx_adapter.c | 90 +++++++++++++- lib/eventdev/rte_event_eth_tx_adapter.h | 66 +++++++++++ lib/eventdev/version.map | 2 + 5 files changed, 290 insertions(+), 1 deletion(-) diff --git a/app/test/test_event_eth_tx_adapter.c b/app/test/test_event_eth_tx_adapter.c index c19a87a86a..437f09bef7 100644 --- a/app/test/test_event_eth_tx_adapter.c +++ b/app/test/test_event_eth_tx_adapter.c @@ -40,6 +40,8 @@ test_event_eth_tx_adapter_common(void) #define PORT(p) default_params.port[(p)] #define TEST_ETHDEV_ID PORT(0) #define TEST_ETHDEV_PAIR_ID PORT(PAIR_PORT_INDEX(0)) +#define DEFAULT_FLUSH_THRESHOLD 1024 +#define TXA_NB_TX_WORK_DEFAULT 128 #define EDEV_RETRY 0xffff @@ -795,6 +797,112 @@ 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); + + /* 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 == DEFAULT_FLUSH_THRESHOLD, + "Expected %u got %u", + DEFAULT_FLUSH_THRESHOLD, out_params.flush_threshold); + TEST_ASSERT(out_params.max_nb_tx == TXA_NB_TX_WORK_DEFAULT, + "Expected %u got %u", + TXA_NB_TX_WORK_DEFAULT, 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 = DEFAULT_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 +772,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; } @@ -1281,6 +1285,90 @@ 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; + + if (!txa->dev_count) + return -EINVAL; + + /* The eth_dev used is always the same type. + * Hence first valid eth_dev is taken. + */ + eth_dev = txa->txa_ethdev[0].dev; + 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..cb5db6781c 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,23 @@ struct rte_event_eth_tx_adapter_conf { */ }; +/** + * Adapter 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 +535,53 @@ __rte_experimental int rte_event_eth_tx_adapter_queue_stop(uint16_t eth_dev_id, uint16_t tx_queue_id); +/** + * 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() + * and modify the required parameters and then call + * rte_event_eth_tx_adapter_set_params(). + * + * 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. + * + * @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; }; From patchwork Mon Jan 23 18:04:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Naga Harish K, S V" X-Patchwork-Id: 122448 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 605934246D; Mon, 23 Jan 2023 19:05:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E160042D2B; Mon, 23 Jan 2023 19:05:10 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 4E2F940150 for ; Mon, 23 Jan 2023 19:05:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674497107; x=1706033107; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JZjWH2YuDbJuWaax3Fsg4QPG56k1mKjZiZBNneGeAvI=; b=GmRmrb32W9u5nFSGqky59EUtaNr0OYrAz5WvYPi9HPs2pckeUgg8R7My PSlSakdcjIoKpm1xycfZvAwjtaghkPXKserrtke8NAieYW1B34IWKCpdL cF5Otm+wFOx4Rzc3fhB+3IX6EobZy4ixx174ohRiNhX8oUfcdpNkNlLvz yeYcuLPUCWhEW6UkJdR4+NCPd4Hz+hDDyrEP6MTCH/A9ntb/vgoPpmTTD dtdVFLTeoK88vUk1pEUr0TKSI/Uk4D9Qo1PGvzMexUbQvQ6B51JCFi8iL g243HU1vrGG+KRcxiBWQpeAVoQ8JTR/TO5miwmn6FMkKXWjcCtDPG9oc2 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10599"; a="390608267" X-IronPort-AV: E=Sophos;i="5.97,240,1669104000"; d="scan'208";a="390608267" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2023 10:05:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10599"; a="611713890" X-IronPort-AV: E=Sophos;i="5.97,240,1669104000"; d="scan'208";a="611713890" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by orsmga003.jf.intel.com with ESMTP; 23 Jan 2023 10:05:06 -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 v2 3/3] eventdev/crypto: add params set/get APIs Date: Mon, 23 Jan 2023 12:04:58 -0600 Message-Id: <20230123180458.486189-3-s.v.naga.harish.k@intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20230123180458.486189-1-s.v.naga.harish.k@intel.com> References: <20230107161852.3708690-1-s.v.naga.harish.k@intel.com> <20230123180458.486189-1-s.v.naga.harish.k@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 The adapter runtime configuration parameters defined in the ``struct rte_event_crypto_adapter_runtime_params`` can be configured and retrieved using ``rte_event_crypto_adapter_runtime_params_set`` and ``rte_event_eth_rx_adapter_runtime_params_get`` respectively. Signed-off-by: Naga Harish K S V --- app/test/test_event_crypto_adapter.c | 93 +++++++++++++++++++ .../prog_guide/event_crypto_adapter.rst | 19 ++++ lib/eventdev/rte_event_crypto_adapter.c | 88 ++++++++++++++++++ lib/eventdev/rte_event_crypto_adapter.h | 59 ++++++++++++ lib/eventdev/version.map | 2 + 5 files changed, 261 insertions(+) diff --git a/app/test/test_event_crypto_adapter.c b/app/test/test_event_crypto_adapter.c index a38e389abd..9bcbf79e57 100644 --- a/app/test/test_event_crypto_adapter.c +++ b/app/test/test_event_crypto_adapter.c @@ -272,6 +272,95 @@ test_crypto_adapter_stats(void) return TEST_SUCCESS; } +static int +test_crypto_adapter_params(void) +{ + int err; + struct rte_event_crypto_adapter_runtime_params in_params; + struct rte_event_crypto_adapter_runtime_params out_params; + uint32_t cap; + struct rte_event_crypto_adapter_queue_conf queue_conf = { + .ev = response_info, + }; + + err = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap); + TEST_ASSERT_SUCCESS(err, "Failed to get adapter capabilities\n"); + + if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) { + err = rte_event_crypto_adapter_queue_pair_add(TEST_ADAPTER_ID, + TEST_CDEV_ID, TEST_CDEV_QP_ID, &queue_conf); + } else + err = rte_event_crypto_adapter_queue_pair_add(TEST_ADAPTER_ID, + TEST_CDEV_ID, TEST_CDEV_QP_ID, NULL); + + TEST_ASSERT_SUCCESS(err, "Failed to create add queue pair\n"); + + /* Case 1: Get the default value of mbufs processed by adapter */ + err = rte_event_crypto_adapter_runtime_params_get(TEST_ADAPTER_ID, &out_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + /* Case 2: Set max_nb = 32 (=BATCH_SEIZE) */ + in_params.max_nb = 32; + + err = rte_event_crypto_adapter_runtime_params_set(TEST_ADAPTER_ID, &in_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_crypto_adapter_runtime_params_get(TEST_ADAPTER_ID, &out_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + TEST_ASSERT(in_params.max_nb == out_params.max_nb, "Expected %u got %u", + in_params.max_nb, out_params.max_nb); + + /* Case 3: Set max_nb = 192 */ + in_params.max_nb = 192; + + err = rte_event_crypto_adapter_runtime_params_set(TEST_ADAPTER_ID, &in_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_crypto_adapter_runtime_params_get(TEST_ADAPTER_ID, &out_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + TEST_ASSERT(in_params.max_nb == out_params.max_nb, "Expected %u got %u", + in_params.max_nb, out_params.max_nb); + + /* Case 4: Set max_nb = 256 */ + in_params.max_nb = 256; + + err = rte_event_crypto_adapter_runtime_params_set(TEST_ADAPTER_ID, &in_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + + err = rte_event_crypto_adapter_runtime_params_get(TEST_ADAPTER_ID, &out_params); + TEST_ASSERT(err == 0, "Expected 0 got %d", err); + TEST_ASSERT(in_params.max_nb == out_params.max_nb, "Expected %u got %u", + in_params.max_nb, out_params.max_nb); + + /* Case 5: Set max_nb = 30(nb_qps) + return -EINVAL; + ret = rte_event_crypto_adapter_caps_get(adapter->eventdev_id, + adapter->next_cdev_id, + &caps); + if (ret) { + RTE_EDEV_LOG_ERR("Failed to get adapter caps dev %" PRIu8 + " cdev %" PRIu8, adapter->eventdev_id, + adapter->next_cdev_id); + return ret; + } + + if ((caps & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) || + (caps & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) + return -ENOTSUP; + + return 0; +} + +int +rte_event_crypto_adapter_runtime_params_set(uint8_t id, + struct rte_event_crypto_adapter_runtime_params *params) +{ + struct event_crypto_adapter *adapter; + int ret; + + if (eca_memzone_lookup()) + return -ENOMEM; + + EVENT_CRYPTO_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL); + + if (params == NULL) { + RTE_EDEV_LOG_ERR("params pointer is NULL\n"); + return -EINVAL; + } + + adapter = eca_id_to_adapter(id); + if (adapter == NULL) + return -EINVAL; + + ret = crypto_adapter_cap_check(adapter); + if (ret) + return ret; + + rte_spinlock_lock(&adapter->lock); + adapter->max_nb = params->max_nb; + rte_spinlock_unlock(&adapter->lock); + + return 0; +} + +int +rte_event_crypto_adapter_runtime_params_get(uint8_t id, + struct rte_event_crypto_adapter_runtime_params *params) +{ + struct event_crypto_adapter *adapter; + int ret; + + if (eca_memzone_lookup()) + return -ENOMEM; + + + EVENT_CRYPTO_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL); + + if (params == NULL) { + RTE_EDEV_LOG_ERR("params pointer is NULL\n"); + return -EINVAL; + } + + adapter = eca_id_to_adapter(id); + if (adapter == NULL) + return -EINVAL; + + ret = crypto_adapter_cap_check(adapter); + if (ret) + return ret; + + params->max_nb = adapter->max_nb; + + return 0; +} + int rte_event_crypto_adapter_service_id_get(uint8_t id, uint32_t *service_id) { diff --git a/lib/eventdev/rte_event_crypto_adapter.h b/lib/eventdev/rte_event_crypto_adapter.h index fad4543506..9de267443b 100644 --- a/lib/eventdev/rte_event_crypto_adapter.h +++ b/lib/eventdev/rte_event_crypto_adapter.h @@ -138,6 +138,8 @@ * - rte_event_crypto_adapter_stop() * - rte_event_crypto_adapter_stats_get() * - rte_event_crypto_adapter_stats_reset() + * - rte_event_crypto_adapter_runtime_params_get() + * - rte_event_crypto_adapter_runtime_params_set() * The application creates an instance using rte_event_crypto_adapter_create() * or rte_event_crypto_adapter_create_ext(). @@ -253,6 +255,19 @@ struct rte_event_crypto_adapter_conf { */ }; +/** + * Adapter runtime configuration parameters + */ +struct rte_event_crypto_adapter_runtime_params { + uint32_t max_nb; + /**< The adapter can return early if it has processed at least + * max_nb crypto ops. This isn't treated as a requirement; batching + * may cause the adapter to process more than max_nb crypto ops. + */ + uint32_t rsvd[15]; + /**< Reserved fields for future expansion */ +}; + #define RTE_EVENT_CRYPTO_ADAPTER_EVENT_VECTOR 0x1 /**< This flag indicates that crypto operations processed on the crypto * adapter need to be vectorized @@ -608,6 +623,50 @@ rte_event_crypto_adapter_service_id_get(uint8_t id, uint32_t *service_id); int rte_event_crypto_adapter_event_port_get(uint8_t id, uint8_t *event_port_id); +/** + * Set the adapter runtime configuration parameters + * + * This API needs to be called after adding at least one qp to the adapter + * and is supported only for the service-based adapter. + * + * @param id + * Adapter identifier + * + * @param params + * A pointer to structure of type struct rte_event_crypto_adapter_runtime_params + * with configuration parameter values. + * + * @return + * - 0: Success + * - <0: Error code on failure + */ +__rte_experimental +int +rte_event_crypto_adapter_runtime_params_set(uint8_t id, + struct rte_event_crypto_adapter_runtime_params *params); + +/** + * Get the adapter runtime configuration parameters + * + * This API needs to be called after adding at least one qp to the adapter + * and is supported only for the service-based adapter. + * + * @param id + * Adapter identifier + * + * @param[out] params + * A pointer to structure of type struct rte_event_crypto_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_crypto_adapter_runtime_params_get(uint8_t id, + struct rte_event_crypto_adapter_runtime_params *params); + /** * @warning * @b EXPERIMENTAL: this API may change without prior notice diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map index 38dfbb1f41..60e5e3a593 100644 --- a/lib/eventdev/version.map +++ b/lib/eventdev/version.map @@ -121,6 +121,8 @@ EXPERIMENTAL { rte_event_eth_tx_adapter_queue_stop; # added in 23.03 + rte_event_crypto_adapter_runtime_params_get; + rte_event_crypto_adapter_runtime_params_set; rte_event_eth_rx_adapter_runtime_params_get; rte_event_eth_rx_adapter_runtime_params_set; rte_event_eth_tx_adapter_runtime_params_get;