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 <s.v.naga.haris...@intel.com>
---
 app/test/test_event_eth_rx_adapter.c          | 113 ++++++++++++++++++
 .../prog_guide/event_ethernet_rx_adapter.rst  |   8 ++
 lib/eventdev/rte_event_eth_rx_adapter.c       | 101 +++++++++++++++-
 lib/eventdev/rte_event_eth_rx_adapter.h       |  93 +++++++++++++-
 lib/eventdev/version.map                      |   3 +
 5 files changed, 316 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..cfe6052d7e 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -1198,6 +1198,117 @@ 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);
+
+       err = rte_event_eth_rx_adapter_runtime_params_init(&in_params);
+       TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+       err = rte_event_eth_rx_adapter_runtime_params_init(&out_params);
+       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(<BATCH_SIZE) */
+       in_params.max_nb_rx = 30;
+
+       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 6: Set max_nb_rx = 512 */
+       in_params.max_nb_rx = 512;
+
+       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);
+
+       err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+                                               TEST_ETHDEV_ID, 0);
+       TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+       return TEST_SUCCESS;
+}
+
 static struct unit_test_suite event_eth_rx_tests = {
        .suite_name = "rx event eth adapter test suite",
        .setup = testsuite_setup,
@@ -1218,6 +1329,8 @@ static struct unit_test_suite event_eth_rx_tests = {
                             adapter_queue_stats_test),
                TEST_CASE_ST(adapter_create, adapter_free,
                             adapter_pollq_instance_get),
+               TEST_CASE_ST(adapter_create, adapter_free,
+                            adapter_get_set_params),
                TEST_CASES_END() /**< NULL terminate unit test array */
        }
 };
diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst 
b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
index 461eca566f..72614ce714 100644
--- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
+++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst
@@ -185,6 +185,14 @@ flags for handling received packets, event queue 
identifier, scheduler type,
 event priority, polling frequency of the receive queue and flow identifier
 in struct ``rte_event_eth_rx_adapter_queue_conf``.
 
+Set/Get adapter runtime configuration parameters
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The runtime configuration parameters of adapter can be set/get using
+``rte_event_eth_rx_adapter_runtime_params_set()`` and
+``rte_event_eth_rx_adapter_runtime_params_get()`` respectively. The parameters 
that
+can be set/get are defined in ``struct 
rte_event_eth_rx_adapter_runtime_params``.
+
 Getting and resetting Adapter queue stats
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c 
b/lib/eventdev/rte_event_eth_rx_adapter.c
index b5b4ffebd3..c1cd124002 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -35,6 +35,8 @@
 #define MAX_VECTOR_NS          1E9
 #define MIN_VECTOR_NS          1E5
 
+#define RXA_NB_RX_WORK_DEFAULT 128
+
 #define ETH_RX_ADAPTER_SERVICE_NAME_LEN        32
 #define ETH_RX_ADAPTER_MEM_NAME_LEN    32
 
@@ -1554,7 +1556,7 @@ rxa_default_conf_cb(uint8_t id, uint8_t dev_id,
        }
 
        conf->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;
@@ -3461,6 +3463,103 @@ 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_init(
+               struct rte_event_eth_rx_adapter_runtime_params *params)
+{
+       if (params == NULL)
+               return -EINVAL;
+
+       memset(params, 0, sizeof(struct 
rte_event_eth_rx_adapter_runtime_params));
+       params->max_nb_rx = RXA_NB_RX_WORK_DEFAULT;
+
+       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_uint(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..ff08df25e8 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.h
+++ b/lib/eventdev/rte_event_eth_rx_adapter.h
@@ -39,10 +39,14 @@
  *  - 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_init()
+ *  - 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.
+ *
  * 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 +303,30 @@ struct rte_event_eth_rx_adapter_params {
        /**< flag to indicate that event buffer is separate for each queue */
 };
 
+/**
+ * Adapter runtime 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.
+        *
+        * 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 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
+        *
+        * This is valid for service based SW adapter only
+        */
+       uint32_t rsvd[15];
+       /**< Reserved fields for future use */
+};
+
 /**
  *
  * Callback function invoked by the SW adapter before it continues
@@ -377,7 +405,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 +771,69 @@ rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
                                      uint16_t rx_queue_id,
                                      uint8_t *rxa_inst_id);
 
+/**
+ * Initialize the adapter runtime configuration parameters with default values
+ *
+ * @param params
+ *  A pointer to structure of type struct 
rte_event_eth_rx_adapter_runtime_params
+ *
+ * @return
+ *  -  0: Success
+ *  - <0: Error code on failure
+ */
+__rte_experimental
+int
+rte_event_eth_rx_adapter_runtime_params_init(
+               struct rte_event_eth_rx_adapter_runtime_params *params);
+
+/**
+ * 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. The reserved fields of the structure
+ *  must be initialized to zero and the valid fields need to be set 
appropriately.
+ *  This structure can be initialized using
+ *  rte_event_eth_rx_adapter_runtime_params_init() to default values or
+ *  application may reset this structure and update the required fields.
+ *
+ * @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..ef9c3b86b2 100644
--- a/lib/eventdev/version.map
+++ b/lib/eventdev/version.map
@@ -121,6 +121,9 @@ 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_init;
+       rte_event_eth_rx_adapter_runtime_params_set;
        rte_event_timer_remaining_ticks_get;
 };
 
-- 
2.25.1

Reply via email to