* [dpdk-dev] [PATCH v1] eventdev/rx-adapter: segfault in queue conf get
@ 2021-09-30 12:47 Ganapati Kundapura
2021-09-30 13:00 ` [dpdk-dev] [PATCH v2] " Ganapati Kundapura
0 siblings, 1 reply; 10+ messages in thread
From: Ganapati Kundapura @ 2021-09-30 12:47 UTC (permalink / raw)
To: jerinjacobk, dev; +Cc: jay.jayatheerthan
rte_event_eth_rx_adapter_queue_conf_get() segfaults if called
without queue added to the Rx adapter.
Added check to no queues in Rx adapter and error out on being
called with no queue in Rx adapter.
Added test case to call queue conf get without queues in
Rx adapter.
Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index 13664a3..76ce57b 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -751,20 +751,48 @@ static int
adapter_queue_conf(void)
{
int err;
- struct rte_event_eth_rx_adapter_queue_conf queue_conf;
+ struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
- err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
+ /* 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);
- err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
+ /* Case 3: queue conf get with invalue 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);
- err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
+ /* 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;
}
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index 10491ca..2a84490 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -2844,12 +2844,13 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
return -EINVAL;
dev_info = &rx_adapter->eth_devices[eth_dev_id];
- queue_info = &dev_info->rx_queue[rx_queue_id];
- if (!queue_info->queue_enabled) {
+ 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));
--
2.6.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v2] eventdev/rx-adapter: segfault in queue conf get
2021-09-30 12:47 [dpdk-dev] [PATCH v1] eventdev/rx-adapter: segfault in queue conf get Ganapati Kundapura
@ 2021-09-30 13:00 ` Ganapati Kundapura
2021-10-01 4:42 ` Naga Harish K, S V
2021-10-01 5:19 ` [dpdk-dev] [PATCH v3] eventdev/rx-adapter: fix segfault in que " Ganapati Kundapura
0 siblings, 2 replies; 10+ messages in thread
From: Ganapati Kundapura @ 2021-09-30 13:00 UTC (permalink / raw)
To: jerinjacobk, dev; +Cc: jay.jayatheerthan
rte_event_eth_rx_adapter_queue_conf_get() segfaults if called
without queue added to the Rx adapter.
Added check to no queues in Rx adapter and error out on being
called with no queue in Rx adapter.
Added test case to call queue conf get without queues in
Rx adapter.
Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
v2:
* Corrected typo in the comment
---
diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index 13664a3..d0dc552 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -751,20 +751,48 @@ static int
adapter_queue_conf(void)
{
int err;
- struct rte_event_eth_rx_adapter_queue_conf queue_conf;
+ struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
- err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
+ /* 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);
- err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
+ /* 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);
- err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
+ /* 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;
}
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index 10491ca..2a84490 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -2844,12 +2844,13 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
return -EINVAL;
dev_info = &rx_adapter->eth_devices[eth_dev_id];
- queue_info = &dev_info->rx_queue[rx_queue_id];
- if (!queue_info->queue_enabled) {
+ 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));
--
2.6.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v2] eventdev/rx-adapter: segfault in queue conf get
2021-09-30 13:00 ` [dpdk-dev] [PATCH v2] " Ganapati Kundapura
@ 2021-10-01 4:42 ` Naga Harish K, S V
2021-10-01 5:21 ` Kundapura, Ganapati
2021-10-01 5:19 ` [dpdk-dev] [PATCH v3] eventdev/rx-adapter: fix segfault in que " Ganapati Kundapura
1 sibling, 1 reply; 10+ messages in thread
From: Naga Harish K, S V @ 2021-10-01 4:42 UTC (permalink / raw)
To: Kundapura, Ganapati, jerinjacobk, dev; +Cc: Jayatheerthan, Jay
Hi Ganapati,
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Ganapati Kundapura
> Sent: Thursday, September 30, 2021 6:30 PM
> To: jerinjacobk@gmail.com; dev@dpdk.org
> Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>
> Subject: [dpdk-dev] [PATCH v2] eventdev/rx-adapter: segfault in queue conf
> get
The commit message can be "fix segfault in queue conf get API"
>
> rte_event_eth_rx_adapter_queue_conf_get() segfaults if called without
> queue added to the Rx adapter.
>
> Added check to no queues in Rx adapter and error out on being called with
> no queue in Rx adapter.
>
> Added test case to call queue conf get without queues in Rx adapter.
>
You may need to mention the commit details which is getting fixed.
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
>
> ---
> v2:
> * Corrected typo in the comment
> ---
>
> diff --git a/app/test/test_event_eth_rx_adapter.c
> b/app/test/test_event_eth_rx_adapter.c
> index 13664a3..d0dc552 100644
> --- a/app/test/test_event_eth_rx_adapter.c
> +++ b/app/test/test_event_eth_rx_adapter.c
> @@ -751,20 +751,48 @@ static int
> adapter_queue_conf(void)
> {
> int err;
> - struct rte_event_eth_rx_adapter_queue_conf queue_conf;
> + struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
>
> - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> TEST_DEV_ID,
> + /* 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);
>
> - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> TEST_DEV_ID,
> + /* 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);
>
> - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> TEST_DEV_ID,
> + /* 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;
> }
>
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c
> b/lib/eventdev/rte_event_eth_rx_adapter.c
> index 10491ca..2a84490 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> @@ -2844,12 +2844,13 @@
> rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
> return -EINVAL;
>
> dev_info = &rx_adapter->eth_devices[eth_dev_id];
> - queue_info = &dev_info->rx_queue[rx_queue_id];
> - if (!queue_info->queue_enabled) {
> + 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));
> --
> 2.6.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v3] eventdev/rx-adapter: fix segfault in que conf get
2021-09-30 13:00 ` [dpdk-dev] [PATCH v2] " Ganapati Kundapura
2021-10-01 4:42 ` Naga Harish K, S V
@ 2021-10-01 5:19 ` Ganapati Kundapura
2021-10-01 5:30 ` [dpdk-dev] [PATCH v4] eventdev/rx-adapter: fix segfault in queue " Ganapati Kundapura
1 sibling, 1 reply; 10+ messages in thread
From: Ganapati Kundapura @ 2021-10-01 5:19 UTC (permalink / raw)
To: jerinjacobk, dev; +Cc: jay.jayatheerthan
rte_event_eth_rx_adapter_queue_conf_get() segfaults if called
without queue added to the Rx adapter.
Added check to no queues in Rx adapter and error out on being
called with no queue in Rx adapter.
Added test case to call queue conf get without queues in
Rx adapter.
Fixes: b36879759b7f3ce ("eventdev/rx_adapter: support Rx queue config get")
Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
v3:
* Added fixes line
v2:
* Corrected typo in the comment
---
diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index 13664a3..d0dc552 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -751,20 +751,48 @@ static int
adapter_queue_conf(void)
{
int err;
- struct rte_event_eth_rx_adapter_queue_conf queue_conf;
+ struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
- err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
+ /* 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);
- err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
+ /* 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);
- err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
+ /* 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;
}
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index 10491ca..2a84490 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -2844,12 +2844,13 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
return -EINVAL;
dev_info = &rx_adapter->eth_devices[eth_dev_id];
- queue_info = &dev_info->rx_queue[rx_queue_id];
- if (!queue_info->queue_enabled) {
+ 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));
--
2.6.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v2] eventdev/rx-adapter: segfault in queue conf get
2021-10-01 4:42 ` Naga Harish K, S V
@ 2021-10-01 5:21 ` Kundapura, Ganapati
0 siblings, 0 replies; 10+ messages in thread
From: Kundapura, Ganapati @ 2021-10-01 5:21 UTC (permalink / raw)
To: Naga Harish K, S V, jerinjacobk, dev; +Cc: Jayatheerthan, Jay
Hi Harish,
> -----Original Message-----
> From: Naga Harish K, S V <s.v.naga.harish.k@intel.com>
> Sent: 01 October 2021 10:12
> To: Kundapura, Ganapati <ganapati.kundapura@intel.com>;
> jerinjacobk@gmail.com; dev@dpdk.org
> Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>
> Subject: RE: [dpdk-dev] [PATCH v2] eventdev/rx-adapter: segfault in queue
> conf get
>
> Hi Ganapati,
>
> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of Ganapati Kundapura
> > Sent: Thursday, September 30, 2021 6:30 PM
> > To: jerinjacobk@gmail.com; dev@dpdk.org
> > Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>
> > Subject: [dpdk-dev] [PATCH v2] eventdev/rx-adapter: segfault in queue
> > conf get
>
> The commit message can be "fix segfault in queue conf get API"
>
> >
> > rte_event_eth_rx_adapter_queue_conf_get() segfaults if called without
> > queue added to the Rx adapter.
> >
> > Added check to no queues in Rx adapter and error out on being called
> > with no queue in Rx adapter.
> >
> > Added test case to call queue conf get without queues in Rx adapter.
> >
>
> You may need to mention the commit details which is getting fixed.
>
Done
> > Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> >
> > ---
> > v2:
> > * Corrected typo in the comment
> > ---
> >
> > diff --git a/app/test/test_event_eth_rx_adapter.c
> > b/app/test/test_event_eth_rx_adapter.c
> > index 13664a3..d0dc552 100644
> > --- a/app/test/test_event_eth_rx_adapter.c
> > +++ b/app/test/test_event_eth_rx_adapter.c
> > @@ -751,20 +751,48 @@ static int
> > adapter_queue_conf(void)
> > {
> > int err;
> > - struct rte_event_eth_rx_adapter_queue_conf queue_conf;
> > + struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
> >
> > - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> > TEST_DEV_ID,
> > + /* 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);
> >
> > - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> > TEST_DEV_ID,
> > + /* 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);
> >
> > - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> > TEST_DEV_ID,
> > + /* 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;
> > }
> >
> > diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c
> > b/lib/eventdev/rte_event_eth_rx_adapter.c
> > index 10491ca..2a84490 100644
> > --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> > +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> > @@ -2844,12 +2844,13 @@
> > rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
> > return -EINVAL;
> >
> > dev_info = &rx_adapter->eth_devices[eth_dev_id];
> > - queue_info = &dev_info->rx_queue[rx_queue_id];
> > - if (!queue_info->queue_enabled) {
> > + 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));
> > --
> > 2.6.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v4] eventdev/rx-adapter: fix segfault in queue conf get
2021-10-01 5:19 ` [dpdk-dev] [PATCH v3] eventdev/rx-adapter: fix segfault in que " Ganapati Kundapura
@ 2021-10-01 5:30 ` Ganapati Kundapura
2021-10-04 17:19 ` Jayatheerthan, Jay
2021-10-06 17:32 ` Jerin Jacob
0 siblings, 2 replies; 10+ messages in thread
From: Ganapati Kundapura @ 2021-10-01 5:30 UTC (permalink / raw)
To: jerinjacobk, dev; +Cc: jay.jayatheerthan
rte_event_eth_rx_adapter_queue_conf_get() segfaults if called
without queue added to the Rx adapter.
Added check to no queues in Rx adapter and error out on being
called with no queue in Rx adapter.
Added test case to call queue conf get without queues in
Rx adapter.
Fixes: b36879759b7f3ce ("eventdev/rx_adapter: support Rx queue config get")
Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
---
v4:
* Fixed checkpatch warning
v3:
* Added fixes line
v2:
* Corrected typo in the comment
---
diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index 13664a3..d0dc552 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -751,20 +751,48 @@ static int
adapter_queue_conf(void)
{
int err;
- struct rte_event_eth_rx_adapter_queue_conf queue_conf;
+ struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
- err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
+ /* 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);
- err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
+ /* 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);
- err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
+ /* 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;
}
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index 10491ca..2a84490 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -2844,12 +2844,13 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
return -EINVAL;
dev_info = &rx_adapter->eth_devices[eth_dev_id];
- queue_info = &dev_info->rx_queue[rx_queue_id];
- if (!queue_info->queue_enabled) {
+ 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));
--
2.6.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v4] eventdev/rx-adapter: fix segfault in queue conf get
2021-10-01 5:30 ` [dpdk-dev] [PATCH v4] eventdev/rx-adapter: fix segfault in queue " Ganapati Kundapura
@ 2021-10-04 17:19 ` Jayatheerthan, Jay
2021-10-04 18:25 ` Kundapura, Ganapati
2021-10-06 17:32 ` Jerin Jacob
1 sibling, 1 reply; 10+ messages in thread
From: Jayatheerthan, Jay @ 2021-10-04 17:19 UTC (permalink / raw)
To: Kundapura, Ganapati, jerinjacobk, dev
> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Friday, October 1, 2021 11:00 AM
> To: jerinjacobk@gmail.com; dev@dpdk.org
> Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>
> Subject: [PATCH v4] eventdev/rx-adapter: fix segfault in queue conf get
>
> rte_event_eth_rx_adapter_queue_conf_get() segfaults if called
> without queue added to the Rx adapter.
>
> Added check to no queues in Rx adapter and error out on being
> called with no queue in Rx adapter.
>
> Added test case to call queue conf get without queues in
> Rx adapter.
>
> Fixes: b36879759b7f3ce ("eventdev/rx_adapter: support Rx queue config get")
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
>
> ---
> v4:
> * Fixed checkpatch warning
>
> v3:
> * Added fixes line
>
> v2:
> * Corrected typo in the comment
> ---
>
> diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
> index 13664a3..d0dc552 100644
> --- a/app/test/test_event_eth_rx_adapter.c
> +++ b/app/test/test_event_eth_rx_adapter.c
> @@ -751,20 +751,48 @@ static int
> adapter_queue_conf(void)
> {
> int err;
> - struct rte_event_eth_rx_adapter_queue_conf queue_conf;
> + struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
>
> - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
> + /* 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);
>
> - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
> + /* 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);
rx_queue_id param is uint16_t. Would using non-configured queue id (for e.g. rx_queue_id = 2) suffice instead of using -1 ?
> TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
>
> - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
> + /* 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;
> }
>
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
> index 10491ca..2a84490 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> @@ -2844,12 +2844,13 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
> return -EINVAL;
>
> dev_info = &rx_adapter->eth_devices[eth_dev_id];
> - queue_info = &dev_info->rx_queue[rx_queue_id];
> - if (!queue_info->queue_enabled) {
> + 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));
> --
> 2.6.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v4] eventdev/rx-adapter: fix segfault in queue conf get
2021-10-04 17:19 ` Jayatheerthan, Jay
@ 2021-10-04 18:25 ` Kundapura, Ganapati
2021-10-05 8:19 ` Jayatheerthan, Jay
0 siblings, 1 reply; 10+ messages in thread
From: Kundapura, Ganapati @ 2021-10-04 18:25 UTC (permalink / raw)
To: Jayatheerthan, Jay, jerinjacobk, dev
Hi Jay,
> -----Original Message-----
> From: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>
> Sent: 04 October 2021 22:49
> To: Kundapura, Ganapati <ganapati.kundapura@intel.com>;
> jerinjacobk@gmail.com; dev@dpdk.org
> Subject: RE: [PATCH v4] eventdev/rx-adapter: fix segfault in queue conf get
>
> > -----Original Message-----
> > From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> > Sent: Friday, October 1, 2021 11:00 AM
> > To: jerinjacobk@gmail.com; dev@dpdk.org
> > Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>
> > Subject: [PATCH v4] eventdev/rx-adapter: fix segfault in queue conf
> > get
> >
> > rte_event_eth_rx_adapter_queue_conf_get() segfaults if called without
> > queue added to the Rx adapter.
> >
> > Added check to no queues in Rx adapter and error out on being called
> > with no queue in Rx adapter.
> >
> > Added test case to call queue conf get without queues in Rx adapter.
> >
> > Fixes: b36879759b7f3ce ("eventdev/rx_adapter: support Rx queue config
> > get")
> > Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> >
> > ---
> > v4:
> > * Fixed checkpatch warning
> >
> > v3:
> > * Added fixes line
> >
> > v2:
> > * Corrected typo in the comment
> > ---
> >
> > diff --git a/app/test/test_event_eth_rx_adapter.c
> > b/app/test/test_event_eth_rx_adapter.c
> > index 13664a3..d0dc552 100644
> > --- a/app/test/test_event_eth_rx_adapter.c
> > +++ b/app/test/test_event_eth_rx_adapter.c
> > @@ -751,20 +751,48 @@ static int
> > adapter_queue_conf(void)
> > {
> > int err;
> > - struct rte_event_eth_rx_adapter_queue_conf queue_conf;
> > + struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
> >
> > - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> TEST_DEV_ID,
> > + /* 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);
> >
> > - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> TEST_DEV_ID,
> > + /* 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);
>
> rx_queue_id param is uint16_t. Would using non-configured queue id (for
> e.g. rx_queue_id = 2) suffice instead of using -1 ?
>
When -1 is promoted/demoted to uint16_t, it'll be converted to large value i.e UINT_MAX and guaranteed
to be invalid rx queue id and it's future proof.
In case, some queues are added in that test case in future, this invalid rx_queue_id also needs to be updated.
Yes, for this case rx_queue_id=2 can be used, but it's not future proof.
> > TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> >
> > - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> TEST_DEV_ID,
> > + /* 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;
> > }
> >
> > diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c
> > b/lib/eventdev/rte_event_eth_rx_adapter.c
> > index 10491ca..2a84490 100644
> > --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> > +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> > @@ -2844,12 +2844,13 @@
> rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
> > return -EINVAL;
> >
> > dev_info = &rx_adapter->eth_devices[eth_dev_id];
> > - queue_info = &dev_info->rx_queue[rx_queue_id];
> > - if (!queue_info->queue_enabled) {
> > + 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));
> > --
> > 2.6.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v4] eventdev/rx-adapter: fix segfault in queue conf get
2021-10-04 18:25 ` Kundapura, Ganapati
@ 2021-10-05 8:19 ` Jayatheerthan, Jay
0 siblings, 0 replies; 10+ messages in thread
From: Jayatheerthan, Jay @ 2021-10-05 8:19 UTC (permalink / raw)
To: Kundapura, Ganapati, jerinjacobk, dev
> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Monday, October 4, 2021 11:55 PM
> To: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; jerinjacobk@gmail.com; dev@dpdk.org
> Subject: RE: [PATCH v4] eventdev/rx-adapter: fix segfault in queue conf get
>
> Hi Jay,
>
> > -----Original Message-----
> > From: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>
> > Sent: 04 October 2021 22:49
> > To: Kundapura, Ganapati <ganapati.kundapura@intel.com>;
> > jerinjacobk@gmail.com; dev@dpdk.org
> > Subject: RE: [PATCH v4] eventdev/rx-adapter: fix segfault in queue conf get
> >
> > > -----Original Message-----
> > > From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> > > Sent: Friday, October 1, 2021 11:00 AM
> > > To: jerinjacobk@gmail.com; dev@dpdk.org
> > > Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>
> > > Subject: [PATCH v4] eventdev/rx-adapter: fix segfault in queue conf
> > > get
> > >
> > > rte_event_eth_rx_adapter_queue_conf_get() segfaults if called without
> > > queue added to the Rx adapter.
> > >
> > > Added check to no queues in Rx adapter and error out on being called
> > > with no queue in Rx adapter.
> > >
> > > Added test case to call queue conf get without queues in Rx adapter.
> > >
> > > Fixes: b36879759b7f3ce ("eventdev/rx_adapter: support Rx queue config
> > > get")
> > > Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> > >
> > > ---
> > > v4:
> > > * Fixed checkpatch warning
> > >
> > > v3:
> > > * Added fixes line
> > >
> > > v2:
> > > * Corrected typo in the comment
> > > ---
> > >
> > > diff --git a/app/test/test_event_eth_rx_adapter.c
> > > b/app/test/test_event_eth_rx_adapter.c
> > > index 13664a3..d0dc552 100644
> > > --- a/app/test/test_event_eth_rx_adapter.c
> > > +++ b/app/test/test_event_eth_rx_adapter.c
> > > @@ -751,20 +751,48 @@ static int
> > > adapter_queue_conf(void)
> > > {
> > > int err;
> > > - struct rte_event_eth_rx_adapter_queue_conf queue_conf;
> > > + struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
> > >
> > > - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> > TEST_DEV_ID,
> > > + /* 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);
> > >
> > > - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> > TEST_DEV_ID,
> > > + /* 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);
> >
> > rx_queue_id param is uint16_t. Would using non-configured queue id (for
> > e.g. rx_queue_id = 2) suffice instead of using -1 ?
> >
> When -1 is promoted/demoted to uint16_t, it'll be converted to large value i.e UINT_MAX and guaranteed
> to be invalid rx queue id and it's future proof.
> In case, some queues are added in that test case in future, this invalid rx_queue_id also needs to be updated.
>
> Yes, for this case rx_queue_id=2 can be used, but it's not future proof.
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
>
> > > TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
> > >
> > > - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
> > TEST_DEV_ID,
> > > + /* 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;
> > > }
> > >
> > > diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c
> > > b/lib/eventdev/rte_event_eth_rx_adapter.c
> > > index 10491ca..2a84490 100644
> > > --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> > > +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> > > @@ -2844,12 +2844,13 @@
> > rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
> > > return -EINVAL;
> > >
> > > dev_info = &rx_adapter->eth_devices[eth_dev_id];
> > > - queue_info = &dev_info->rx_queue[rx_queue_id];
> > > - if (!queue_info->queue_enabled) {
> > > + 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));
> > > --
> > > 2.6.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v4] eventdev/rx-adapter: fix segfault in queue conf get
2021-10-01 5:30 ` [dpdk-dev] [PATCH v4] eventdev/rx-adapter: fix segfault in queue " Ganapati Kundapura
2021-10-04 17:19 ` Jayatheerthan, Jay
@ 2021-10-06 17:32 ` Jerin Jacob
1 sibling, 0 replies; 10+ messages in thread
From: Jerin Jacob @ 2021-10-06 17:32 UTC (permalink / raw)
To: Ganapati Kundapura; +Cc: dpdk-dev, Jayatheerthan, Jay
On Fri, Oct 1, 2021 at 11:00 AM Ganapati Kundapura
<ganapati.kundapura@intel.com> wrote:
>
> rte_event_eth_rx_adapter_queue_conf_get() segfaults if called
> without queue added to the Rx adapter.
>
> Added check to no queues in Rx adapter and error out on being
> called with no queue in Rx adapter.
>
> Added test case to call queue conf get without queues in
> Rx adapter.
>
> Fixes: b36879759b7f3ce ("eventdev/rx_adapter: support Rx queue config get")
Squashed to relevant patches to dpdk-next-net-eventdev/for-main. Thanks
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
>
> ---
> v4:
> * Fixed checkpatch warning
>
> v3:
> * Added fixes line
>
> v2:
> * Corrected typo in the comment
> ---
>
> diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
> index 13664a3..d0dc552 100644
> --- a/app/test/test_event_eth_rx_adapter.c
> +++ b/app/test/test_event_eth_rx_adapter.c
> @@ -751,20 +751,48 @@ static int
> adapter_queue_conf(void)
> {
> int err;
> - struct rte_event_eth_rx_adapter_queue_conf queue_conf;
> + struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
>
> - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
> + /* 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);
>
> - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
> + /* 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);
>
> - err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID, TEST_DEV_ID,
> + /* 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;
> }
>
> diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
> index 10491ca..2a84490 100644
> --- a/lib/eventdev/rte_event_eth_rx_adapter.c
> +++ b/lib/eventdev/rte_event_eth_rx_adapter.c
> @@ -2844,12 +2844,13 @@ rte_event_eth_rx_adapter_queue_conf_get(uint8_t id,
> return -EINVAL;
>
> dev_info = &rx_adapter->eth_devices[eth_dev_id];
> - queue_info = &dev_info->rx_queue[rx_queue_id];
> - if (!queue_info->queue_enabled) {
> + 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));
> --
> 2.6.4
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-10-06 17:32 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 12:47 [dpdk-dev] [PATCH v1] eventdev/rx-adapter: segfault in queue conf get Ganapati Kundapura
2021-09-30 13:00 ` [dpdk-dev] [PATCH v2] " Ganapati Kundapura
2021-10-01 4:42 ` Naga Harish K, S V
2021-10-01 5:21 ` Kundapura, Ganapati
2021-10-01 5:19 ` [dpdk-dev] [PATCH v3] eventdev/rx-adapter: fix segfault in que " Ganapati Kundapura
2021-10-01 5:30 ` [dpdk-dev] [PATCH v4] eventdev/rx-adapter: fix segfault in queue " Ganapati Kundapura
2021-10-04 17:19 ` Jayatheerthan, Jay
2021-10-04 18:25 ` Kundapura, Ganapati
2021-10-05 8:19 ` Jayatheerthan, Jay
2021-10-06 17:32 ` Jerin Jacob
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).