DPDK patches and discussions
 help / color / mirror / Atom feed
From: Naga Harish K S V <s.v.naga.harish.k@intel.com>
To: jerinj@marvell.com, abhinandan.gujjar@intel.com
Cc: dev@dpdk.org, jay.jayatheerthan@intel.com
Subject: [PATCH 2/3] eventdev/eth_tx: add params set/get APIs
Date: Sat,  7 Jan 2023 10:18:51 -0600	[thread overview]
Message-ID: <20230107161852.3708690-2-s.v.naga.harish.k@intel.com> (raw)
In-Reply-To: <20230107161852.3708690-1-s.v.naga.harish.k@intel.com>

The adapter configuration parameters defined in the
``struct rte_event_eth_tx_adapter_params`` can be configured
and retrieved using ``rte_event_eth_tx_adapter_set_params``
and ``rte_event_eth_tx_adapter_get_params`` respectively.

Signed-off-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
---
 app/test/test_event_eth_tx_adapter.c          | 100 ++++++++++++++++++
 .../prog_guide/event_ethernet_tx_adapter.rst  |  22 ++++
 lib/eventdev/rte_event_eth_tx_adapter.c       |  50 ++++++++-
 lib/eventdev/rte_event_eth_tx_adapter.h       |  58 ++++++++++
 lib/eventdev/version.map                      |   2 +
 5 files changed, 231 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..8e08379b33 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,102 @@ 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_params in_params;
+	struct rte_event_eth_tx_adapter_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_get_params(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_set_params(TEST_INST_ID, &in_params);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_get_params(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_set_params(TEST_INST_ID, &in_params);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_get_params(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_set_params(TEST_INST_ID, &in_params);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_get_params(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(<TXA_BATCH_SIZE) */
+	in_params.max_nb_tx = 30;
+
+	err = rte_event_eth_tx_adapter_set_params(TEST_INST_ID, &in_params);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	/* Case 6: Set max_nb_tx = 512 */
+	in_params.max_nb_tx = 512;
+
+	err = rte_event_eth_tx_adapter_set_params(TEST_INST_ID, &in_params);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	 /* Case 7: Set flush_threshold = 10 */
+	in_params.max_nb_tx = 128;
+	in_params.flush_threshold = 10;
+
+	err = rte_event_eth_tx_adapter_set_params(TEST_INST_ID, &in_params);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_tx_adapter_get_params(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);
+
+	err = rte_event_eth_tx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 0);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
 static int
 tx_adapter_dynamic_device(void)
 {
@@ -856,6 +954,8 @@ static struct unit_test_suite event_eth_tx_tests = {
 					tx_adapter_instance_get),
 		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
 					tx_adapter_queue_start_stop),
+		TEST_CASE_ST(tx_adapter_create, tx_adapter_free,
+					tx_adapter_set_get_params),
 		TEST_CASE_ST(NULL, NULL, tx_adapter_dynamic_device),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
diff --git a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
index 905cb445e0..aa4b5a3501 100644
--- a/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_tx_adapter.rst
@@ -207,3 +207,25 @@ Stop function stops the adapter runtime function from enqueueing any
 packets to the associated Tx queue. This API also frees any packets that
 may have been buffered for this queue. All inflight packets destined to the
 queue are freed by the adapter runtime until the queue is started again.
+
+Set/Get adapter configuration parameters
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The configuration parameters of adapter can be set/read using
+``rte_event_eth_tx_adapter_set_params()`` and
+``rte_event_eth_tx_adapter_get_params()`` respectively. The parameters that
+can be set/read are defined in ``struct rte_event_eth_tx_adapter_params``.
+
+``rte_event_eth_tx_adapter_create()`` configures the adapter with
+default value of maximum packets processed per request to 128.
+``rte_event_eth_tx_adapter_set_params()`` function allows to reconfigure maximum
+number of packets processed by adapter per service request.
+This is alternative to configuring the maximum packets processed per request by
+adapter by using ``rte_event_eth_tx_adapter_create_ext()`` with parameter
+rte_event_eth_tx_adapter_conf::max_nb_tx
+
+The adapter flush threshold also can be configured using
+``rte_event_eth_tx_adapter_set_params()``.
+
+``rte_event_eth_tx_adapter_get_params()`` function retrieves the adapter params
+that are defined in ``struct rte_event_eth_tx_adapter_params``.
diff --git a/lib/eventdev/rte_event_eth_tx_adapter.c b/lib/eventdev/rte_event_eth_tx_adapter.c
index 88309d2aaa..592d9d6ced 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.c
+++ b/lib/eventdev/rte_event_eth_tx_adapter.c
@@ -124,6 +124,8 @@ struct txa_service_data {
 	uint16_t dev_count;
 	/* Loop count to flush Tx buffers */
 	int loop_cnt;
+	/* Loop count threshold to flush Tx buffers */
+	uint16_t flush_threshold;
 	/* Per ethernet device structure */
 	struct txa_service_ethdev *txa_ethdev;
 	/* Statistics */
@@ -663,13 +665,14 @@ txa_service_func(void *args)
 		ret = 0;
 	}
 
-	if ((txa->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;
 
@@ -767,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;
 }
@@ -1279,6 +1283,50 @@ rte_event_eth_tx_adapter_stats_reset(uint8_t id)
 	return ret;
 }
 
+int
+rte_event_eth_tx_adapter_set_params(uint8_t id,
+			struct rte_event_eth_tx_adapter_params *txa_params)
+{
+	struct txa_service_data *txa;
+	if (txa_lookup())
+		return -ENOMEM;
+
+	TXA_CHECK_OR_ERR_RET(id);
+
+	if (txa_params == NULL)
+		return -EINVAL;
+
+	txa = txa_service_id_to_data(id);
+	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_get_params(uint8_t id,
+			struct rte_event_eth_tx_adapter_params *txa_params)
+{
+	struct txa_service_data *txa;
+	if (txa_lookup())
+		return -ENOMEM;
+
+	TXA_CHECK_OR_ERR_RET(id);
+
+	if (txa_params == NULL)
+		return -EINVAL;
+
+	txa = txa_service_id_to_data(id);
+	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 645b87b78a..ca72fc7b2f 100644
--- a/lib/eventdev/rte_event_eth_tx_adapter.h
+++ b/lib/eventdev/rte_event_eth_tx_adapter.h
@@ -103,6 +103,21 @@ struct rte_event_eth_tx_adapter_conf {
 	 */
 };
 
+/**
+ * Adapter configuration parameters
+ */
+struct rte_event_eth_tx_adapter_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.
+	 */
+};
+
 /**
  * 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
@@ -502,6 +517,49 @@ __rte_experimental
 int
 rte_event_eth_tx_adapter_queue_stop(uint16_t eth_dev_id, uint16_t tx_queue_id);
 
+/**
+ * Set the 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.
+ *
+ * @param id
+ *  Adapter identifier
+ * @param params
+ *  A pointer to structure of type struct rte_event_eth_tx_adapter_params
+ *  with configuration parameter values.
+ *
+ * @return
+ * -  0: Success
+ * - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_tx_adapter_set_params(uint8_t id,
+			struct rte_event_eth_tx_adapter_params *params);
+
+/**
+ * Get the configuration parameters of adapter.
+ *
+ * @param id
+ *  Adapter identifier
+ * @param[out] params
+ *  A pointer to structure of type struct rte_event_eth_tx_adapter_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_get_params(uint8_t id,
+			struct rte_event_eth_tx_adapter_params *params);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
index 01ae975a26..55e8cb514c 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -122,6 +122,8 @@ EXPERIMENTAL {
 	# added in 23.03
 	rte_event_eth_rx_adapter_get_params;
 	rte_event_eth_rx_adapter_set_params;
+	rte_event_eth_tx_adapter_get_params;
+	rte_event_eth_tx_adapter_set_params;
 };
 
 INTERNAL {
-- 
2.25.1


  reply	other threads:[~2023-01-07 16:19 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-07 16:18 [PATCH 1/3] eventdev/eth_rx: " Naga Harish K S V
2023-01-07 16:18 ` Naga Harish K S V [this message]
2023-01-07 16:18 ` [PATCH 3/3] eventdev/crypto: " Naga Harish K S V
2023-01-18 10:22 ` [PATCH 1/3] eventdev/eth_rx: " Jerin Jacob
2023-01-20  8:58   ` Naga Harish K, S V
2023-01-20  9:32     ` Jerin Jacob
2023-01-20 10:33       ` Naga Harish K, S V
2023-01-23  9:31         ` Jerin Jacob
2023-01-23 18:07           ` Naga Harish K, S V
2023-01-23 18:04 ` [PATCH v2 " Naga Harish K S V
2023-01-23 18:04   ` [PATCH v2 2/3] eventdev/eth_tx: " Naga Harish K S V
2023-01-23 18:04   ` [PATCH v2 3/3] eventdev/crypto: " Naga Harish K S V
2023-01-24  4:29   ` [PATCH v2 1/3] eventdev/eth_rx: " Jerin Jacob
2023-01-24 13:07     ` Naga Harish K, S V
2023-01-25  4:12       ` Jerin Jacob
2023-01-25  9:52         ` Naga Harish K, S V
2023-01-25 10:38           ` Jerin Jacob
2023-01-25 16:32             ` Naga Harish K, S V
2023-01-28 10:53               ` Jerin Jacob
2023-01-28 17:21                 ` Stephen Hemminger
2023-01-30  9:56                 ` Naga Harish K, S V
2023-01-30 14:43                   ` Jerin Jacob
2023-02-02 16:12                     ` Naga Harish K, S V
2023-02-03  9:44                       ` Jerin Jacob
2023-02-06  6:21                         ` Naga Harish K, S V
2023-02-06 16:38                           ` Jerin Jacob
2023-02-09 17:00                             ` Naga Harish K, S V
2023-02-09 16:57   ` [PATCH v3 " Naga Harish K S V
2023-02-09 16:57     ` [PATCH v3 2/3] eventdev/eth_tx: " Naga Harish K S V
2023-02-09 16:57     ` [PATCH v3 3/3] eventdev/crypto: " Naga Harish K S V
2023-02-10  1:55   ` [PATCH v3 1/3] eventdev/eth_rx: " Naga Harish K S V
2023-02-10  1:55     ` [PATCH v3 2/3] eventdev/eth_tx: " Naga Harish K S V
2023-02-10  1:55     ` [PATCH v3 3/3] eventdev/crypto: " Naga Harish K S V
2023-02-10  4:58   ` [PATCH v4 1/3] eventdev/eth_rx: " Naga Harish K S V
2023-02-10  4:58     ` [PATCH v4 2/3] eventdev/eth_tx: " Naga Harish K S V
2023-02-10  4:58     ` [PATCH v4 3/3] eventdev/crypto: " Naga Harish K S V
2023-02-10  6:30     ` [PATCH v4 1/3] eventdev/eth_rx: " Jerin Jacob
2023-02-10 13:33     ` [PATCH v5 " Naga Harish K S V
2023-02-10 13:33       ` [PATCH v5 2/3] eventdev/eth_tx: " Naga Harish K S V
2023-02-10 13:33       ` [PATCH v5 3/3] eventdev/crypto: " Naga Harish K S V
2023-02-10 13:58       ` [PATCH v5 1/3] eventdev/eth_rx: " Jerin Jacob
2023-02-10 17:42         ` Naga Harish K, S V
2023-02-10 13:46     ` Naga Harish K S V
2023-02-10 13:46       ` [PATCH v5 2/3] eventdev/eth_tx: " Naga Harish K S V
2023-02-10 14:05         ` Jerin Jacob
2023-02-10 15:01           ` Naga Harish K, S V
2023-02-10 15:24             ` Jerin Jacob
2023-02-10 17:41               ` Naga Harish K, S V
2023-02-10 13:46       ` [PATCH v5 3/3] eventdev/crypto: " Naga Harish K S V
2023-02-10 17:37       ` [PATCH v6 1/3] eventdev/eth_rx: " Naga Harish K S V
2023-02-10 17:37         ` [PATCH v6 2/3] eventdev/eth_tx: " Naga Harish K S V
2023-02-10 17:37         ` [PATCH v6 3/3] eventdev/crypto: " Naga Harish K S V
2023-02-13  5:08           ` Jerin Jacob

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230107161852.3708690-2-s.v.naga.harish.k@intel.com \
    --to=s.v.naga.harish.k@intel.com \
    --cc=abhinandan.gujjar@intel.com \
    --cc=dev@dpdk.org \
    --cc=jay.jayatheerthan@intel.com \
    --cc=jerinj@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).