eventdev/eth_rx: support Rx queue config get

Added rte_event_eth_rx_adapter_queue_conf_get() API to get rx queue
information - event queue identifier, flags for handling received packets,
scheduler type, event priority, polling frequency of the receive queue
and flow identifier in rte_event_eth_rx_adapter_queue_conf structure

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
This commit is contained in:
Ganapati Kundapura 2021-09-16 07:51:06 -05:00 committed by Jerin Jacob
parent 83ab470d12
commit da781e6488
6 changed files with 205 additions and 1 deletions

View File

@ -747,6 +747,55 @@ adapter_stats(void)
return TEST_SUCCESS;
}
static int
adapter_queue_conf(void)
{
int err;
struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
/* Case 1: queue conf get without any queues in Rx adapter */
err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
TEST_ETHDEV_ID,
0, &queue_conf);
TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
/* Add queue to Rx adapter */
queue_conf.ev.queue_id = 0;
queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
TEST_ETHDEV_ID,
0, &queue_conf);
TEST_ASSERT(err == 0, "Expected 0 got %d", err);
/* Case 2: queue conf get with queue added to Rx adapter */
err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
TEST_ETHDEV_ID,
0, &queue_conf);
TEST_ASSERT(err == 0, "Expected 0 got %d", err);
/* Case 3: queue conf get with invalid rx queue id */
err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
TEST_ETHDEV_ID,
-1, &queue_conf);
TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
/* Case 4: queue conf get with NULL queue conf struct */
err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
TEST_ETHDEV_ID,
0, NULL);
TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
/* Delete queue from the Rx adapter */
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,
@ -759,6 +808,7 @@ static struct unit_test_suite event_eth_rx_tests = {
adapter_multi_eth_add_del),
TEST_CASE_ST(adapter_create, adapter_free, adapter_start_stop),
TEST_CASE_ST(adapter_create, adapter_free, adapter_stats),
TEST_CASE_ST(adapter_create, adapter_free, adapter_queue_conf),
TEST_CASES_END() /**< NULL terminate unit test array */
}
};

View File

@ -146,6 +146,14 @@ if the callback is supported, and the counts maintained by the service function,
if one exists. The service function also maintains a count of cycles for which
it was not able to enqueue to the event device.
Getting Adapter queue config
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The ``rte_event_eth_rx_adapter_queue_conf_get()`` function reports
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``.
Interrupt Based Rx Queues
~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -557,6 +557,32 @@ typedef int (*eventdev_eth_rx_adapter_queue_del_t)
const struct rte_eth_dev *eth_dev,
int32_t rx_queue_id);
/**
* Retrieve Rx adapter queue config information for the specified
* rx queue ID.
*
* @param dev
* Event device pointer
*
* @param eth_dev
* Ethernet device pointer
*
* @param rx_queue_id
* Ethernet device receive queue index.
*
* @param[out] queue_conf
* Pointer to rte_event_eth_rx_adapter_queue_conf structure
*
* @return
* - 0: Success
* - <0: Error code on failure.
*/
typedef int (*eventdev_eth_rx_adapter_queue_conf_get_t)
(const struct rte_eventdev *dev,
const struct rte_eth_dev *eth_dev,
uint16_t rx_queue_id,
struct rte_event_eth_rx_adapter_queue_conf *queue_conf);
/**
* Start ethernet Rx adapter. This callback is invoked if
* the caps returned from eventdev_eth_rx_adapter_caps_get(.., eth_port_id)
@ -1077,6 +1103,8 @@ struct rte_eventdev_ops {
/**< Add Rx queues to ethernet Rx adapter */
eventdev_eth_rx_adapter_queue_del_t eth_rx_adapter_queue_del;
/**< Delete Rx queues from ethernet Rx adapter */
eventdev_eth_rx_adapter_queue_conf_get_t eth_rx_adapter_queue_conf_get;
/**< Get Rx adapter queue info */
eventdev_eth_rx_adapter_start_t eth_rx_adapter_start;
/**< Start ethernet Rx adapter */
eventdev_eth_rx_adapter_stop_t eth_rx_adapter_stop;

View File

@ -41,6 +41,8 @@
/* Sentinel value to detect initialized file handle */
#define INIT_FD -1
#define RXA_ADAPTER_ARRAY "rte_event_eth_rx_adapter_array"
/*
* Used to store port and queue ID of interrupting Rx queue
*/
@ -1372,7 +1374,7 @@ rxa_service_func(void *args)
static int
rte_event_eth_rx_adapter_init(void)
{
const char *name = "rte_event_eth_rx_adapter_array";
const char *name = RXA_ADAPTER_ARRAY;
const struct rte_memzone *mz;
unsigned int sz;
@ -1395,6 +1397,21 @@ rte_event_eth_rx_adapter_init(void)
return 0;
}
static int
rxa_memzone_lookup(void)
{
const struct rte_memzone *mz;
if (event_eth_rx_adapter == NULL) {
mz = rte_memzone_lookup(RXA_ADAPTER_ARRAY);
if (mz == NULL)
return -ENOMEM;
event_eth_rx_adapter = mz->addr;
}
return 0;
}
static inline struct rte_event_eth_rx_adapter *
rxa_id_to_adapter(uint8_t id)
{
@ -2664,6 +2681,9 @@ rte_event_eth_rx_adapter_stats_get(uint8_t id,
uint32_t i;
int ret;
if (rxa_memzone_lookup())
return -ENOMEM;
RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
rx_adapter = rxa_id_to_adapter(id);
@ -2702,6 +2722,9 @@ rte_event_eth_rx_adapter_stats_reset(uint8_t id)
struct eth_device_info *dev_info;
uint32_t i;
if (rxa_memzone_lookup())
return -ENOMEM;
RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
rx_adapter = rxa_id_to_adapter(id);
@ -2727,6 +2750,9 @@ rte_event_eth_rx_adapter_service_id_get(uint8_t id, uint32_t *service_id)
{
struct rte_event_eth_rx_adapter *rx_adapter;
if (rxa_memzone_lookup())
return -ENOMEM;
RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
rx_adapter = rxa_id_to_adapter(id);
@ -2783,3 +2809,67 @@ rte_event_eth_rx_adapter_cb_register(uint8_t id,
return 0;
}
int
rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
uint16_t eth_dev_id,
uint16_t rx_queue_id,
struct rte_event_eth_rx_adapter_queue_conf *queue_conf)
{
struct rte_eventdev *dev;
struct rte_event_eth_rx_adapter *rx_adapter;
struct eth_device_info *dev_info;
struct eth_rx_queue_info *queue_info;
struct rte_event *qi_ev;
int ret;
if (rxa_memzone_lookup())
return -ENOMEM;
RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);
if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
return -EINVAL;
}
if (queue_conf == NULL) {
RTE_EDEV_LOG_ERR("Rx queue conf struct cannot be NULL");
return -EINVAL;
}
rx_adapter = rxa_id_to_adapter(id);
if (rx_adapter == NULL)
return -EINVAL;
dev_info = &rx_adapter->eth_devices[eth_dev_id];
if (dev_info->rx_queue == NULL ||
!dev_info->rx_queue[rx_queue_id].queue_enabled) {
RTE_EDEV_LOG_ERR("Rx queue %u not added", rx_queue_id);
return -EINVAL;
}
queue_info = &dev_info->rx_queue[rx_queue_id];
qi_ev = (struct rte_event *)&queue_info->event;
memset(queue_conf, 0, sizeof(*queue_conf));
queue_conf->rx_queue_flags = 0;
if (queue_info->flow_id_mask != 0)
queue_conf->rx_queue_flags |=
RTE_EVENT_ETH_RX_ADAPTER_QUEUE_FLOW_ID_VALID;
queue_conf->servicing_weight = queue_info->wt;
memcpy(&queue_conf->ev, qi_ev, sizeof(*qi_ev));
dev = &rte_eventdevs[rx_adapter->eventdev_id];
if (dev->dev_ops->eth_rx_adapter_queue_conf_get != NULL) {
ret = (*dev->dev_ops->eth_rx_adapter_queue_conf_get)(dev,
&rte_eth_devices[eth_dev_id],
rx_queue_id,
queue_conf);
return ret;
}
return 0;
}

View File

@ -33,6 +33,7 @@
* - rte_event_eth_rx_adapter_stop()
* - rte_event_eth_rx_adapter_stats_get()
* - rte_event_eth_rx_adapter_stats_reset()
* - rte_event_eth_rx_adapter_queue_conf_get()
*
* The application creates an ethernet to event adapter using
* rte_event_eth_rx_adapter_create_ext() or rte_event_eth_rx_adapter_create()
@ -545,6 +546,32 @@ int rte_event_eth_rx_adapter_vector_limits_get(
uint8_t dev_id, uint16_t eth_port_id,
struct rte_event_eth_rx_adapter_vector_limits *limits);
/**
* Retrieve Rx queue config information.
*
* @param id
* Adapter identifier.
* @param eth_dev_id
* Port identifier of Ethernet device.
* @param rx_queue_id
* Ethernet device receive queue index.
* @param[out] queue_conf
* Pointer to struct rte_event_eth_rx_adapter_queue_conf
* @return
* - 0: Success, Receive queue added correctly.
* - <0: Error code on failure.
*/
__rte_experimental
int rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
uint16_t eth_dev_id,
uint16_t rx_queue_id,
struct rte_event_eth_rx_adapter_queue_conf *queue_conf);
#ifdef __cplusplus
}
#endif

View File

@ -143,6 +143,7 @@ EXPERIMENTAL {
rte_event_vector_pool_create;
rte_event_eth_rx_adapter_vector_limits_get;
__rte_eventdev_trace_crypto_adapter_enqueue;
rte_event_eth_rx_adapter_queue_conf_get;
};
INTERNAL {