* [dpdk-dev] [PATCH] event/opdl: rework loops to comply with dpdk style
@ 2018-01-22 10:04 Harry van Haaren
2018-01-22 10:30 ` Liang, Ma
0 siblings, 1 reply; 3+ messages in thread
From: Harry van Haaren @ 2018-01-22 10:04 UTC (permalink / raw)
To: dev; +Cc: Harry van Haaren, liang.j.ma, peter.mccarthy
This commit reworks the loop counter variable declarations
to be in line with the DPDK source code.
Fixes: 3c7f3dcfb099 ("event/opdl: add PMD main body and helper function")
Fixes: 8ca8e3b48eff ("event/opdl: add event queue config get/set")
Fixes: d548ef513cd7 ("event/opdl: add unit tests")
Cc: liang.j.ma@intel.com
Cc: peter.mccarthy@intel.com
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
Compile tested for loop declarations by adding "-std=gnu90" to the
OPDL Makefile CFLAGS variable, which now passes here. Note that DPDK
as a whole does not compile with gnu90, so don't pass it as EXTRA_CFLAGS
---
drivers/event/opdl/Makefile | 2 --
drivers/event/opdl/opdl_evdev.c | 9 +++++----
drivers/event/opdl/opdl_evdev_init.c | 23 ++++++++++++++---------
drivers/event/opdl/opdl_evdev_xstats.c | 9 ++++++---
drivers/event/opdl/opdl_test.c | 6 ++++--
5 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/drivers/event/opdl/Makefile b/drivers/event/opdl/Makefile
index a8aff2c..747ae5b 100644
--- a/drivers/event/opdl/Makefile
+++ b/drivers/event/opdl/Makefile
@@ -7,8 +7,6 @@ include $(RTE_SDK)/mk/rte.vars.mk
LIB = librte_pmd_opdl_event.a
# build flags
-CFLAGS += -std=c99
-CFLAGS += -D_XOPEN_SOURCE=600
CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)
# for older GCC versions, allow us to initialize an event using
diff --git a/drivers/event/opdl/opdl_evdev.c b/drivers/event/opdl/opdl_evdev.c
index dcbf404..d5e2b60 100644
--- a/drivers/event/opdl/opdl_evdev.c
+++ b/drivers/event/opdl/opdl_evdev.c
@@ -288,7 +288,8 @@ opdl_queue_setup(struct rte_eventdev *dev,
}
}
/* Check if queue id has been setup already */
- for (uint32_t i = 0; i < device->nb_q_md; i++) {
+ uint32_t i;
+ for (i = 0; i < device->nb_q_md; i++) {
if (device->q_md[i].ext_id == queue_id) {
PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
"queue id %u already setup\n",
@@ -390,8 +391,8 @@ opdl_dump(struct rte_eventdev *dev, FILE *f)
fprintf(f,
"\n\n -- RING STATISTICS --\n");
-
- for (uint32_t i = 0; i < device->nb_opdls; i++)
+ uint32_t i;
+ for (i = 0; i < device->nb_opdls; i++)
opdl_ring_dump(device->opdl[i], f);
fprintf(f,
@@ -400,7 +401,7 @@ opdl_dump(struct rte_eventdev *dev, FILE *f)
"Av. Grant Size Av. Cycles PP"
" Empty DEQs Non Empty DEQs Pkts Processed\n");
- for (uint32_t i = 0; i < device->max_port_nb; i++) {
+ for (i = 0; i < device->max_port_nb; i++) {
char queue_id[64];
char total_cyc[64];
const char *p_type;
diff --git a/drivers/event/opdl/opdl_evdev_init.c b/drivers/event/opdl/opdl_evdev_init.c
index c37d8bc..84ab258 100644
--- a/drivers/event/opdl/opdl_evdev_init.c
+++ b/drivers/event/opdl/opdl_evdev_init.c
@@ -314,8 +314,8 @@ static int opdl_add_deps(struct opdl_evdev *device,
"Stages and dependents"
" are not for same opdl ring",
opdl_pmd_dev_id(device));
- for (uint32_t k = 0;
- k < device->nb_opdls; k++) {
+ uint32_t k;
+ for (k = 0; k < device->nb_opdls; k++) {
opdl_ring_dump(device->opdl[k],
stdout);
}
@@ -505,8 +505,9 @@ void
destroy_queues_and_rings(struct rte_eventdev *dev)
{
struct opdl_evdev *device = opdl_pmd_priv(dev);
+ uint32_t i;
- for (uint32_t i = 0; i < device->nb_opdls; i++) {
+ for (i = 0; i < device->nb_opdls; i++) {
if (device->opdl[i])
opdl_ring_free(device->opdl[i]);
}
@@ -639,7 +640,8 @@ create_queues_and_rings(struct rte_eventdev *dev)
OPDL_Q_POS_START,
-1);
- for (uint32_t i = 0; i < device->nb_q_md; i++) {
+ uint32_t i;
+ for (i = 0; i < device->nb_q_md; i++) {
/* Check */
if (!device->q_md[i].setup) {
@@ -702,7 +704,8 @@ initialise_all_other_ports(struct rte_eventdev *dev)
struct opdl_evdev *device = opdl_pmd_priv(dev);
- for (uint32_t i = 0; i < device->nb_ports; i++) {
+ uint32_t i;
+ for (i = 0; i < device->nb_ports; i++) {
struct opdl_port *port = &device->ports[i];
struct opdl_queue *queue = &device->queue[port->queue_id];
@@ -827,7 +830,7 @@ initialise_all_other_ports(struct rte_eventdev *dev)
* setup the last bit of stage md
*/
if (!err) {
- for (uint32_t i = 0; i < device->nb_ports; i++) {
+ for (i = 0; i < device->nb_ports; i++) {
struct opdl_port *port = &device->ports[i];
struct opdl_queue *queue =
&device->queue[port->queue_id];
@@ -872,7 +875,8 @@ initialise_queue_zero_ports(struct rte_eventdev *dev)
struct opdl_evdev *device = opdl_pmd_priv(dev);
/* Assign queue zero and figure out how many Q0 ports we have */
- for (uint32_t i = 0; i < device->nb_ports; i++) {
+ uint32_t i;
+ for (i = 0; i < device->nb_ports; i++) {
struct opdl_port *port = &device->ports[i];
if (port->queue_id == OPDL_INVALID_QID) {
port->queue_id = 0;
@@ -889,7 +893,7 @@ initialise_queue_zero_ports(struct rte_eventdev *dev)
if (stage_inst) {
/* Assign the new created input stage to all relevant ports */
- for (uint32_t i = 0; i < device->nb_ports; i++) {
+ for (i = 0; i < device->nb_ports; i++) {
struct opdl_port *port = &device->ports[i];
if (port->queue_id == 0) {
queue = &device->queue[port->queue_id];
@@ -914,8 +918,9 @@ assign_internal_queue_ids(struct rte_eventdev *dev)
{
int err = 0;
struct opdl_evdev *device = opdl_pmd_priv(dev);
+ uint32_t i;
- for (uint32_t i = 0; i < device->nb_ports; i++) {
+ for (i = 0; i < device->nb_ports; i++) {
struct opdl_port *port = &device->ports[i];
if (port->external_qid != OPDL_INVALID_QID) {
port->queue_id =
diff --git a/drivers/event/opdl/opdl_evdev_xstats.c b/drivers/event/opdl/opdl_evdev_xstats.c
index 94dfeee..70b84d9 100644
--- a/drivers/event/opdl/opdl_evdev_xstats.c
+++ b/drivers/event/opdl/opdl_evdev_xstats.c
@@ -86,7 +86,8 @@ opdl_xstats_get_names(const struct rte_eventdev *dev,
uint32_t port_idx = queue_port_id * max_num_port_xstat;
- for (uint32_t j = 0; j < max_num_port_xstat; j++) {
+ uint32_t j;
+ for (j = 0; j < max_num_port_xstat; j++) {
strcpy(xstats_names[j].name,
device->port_xstat[j + port_idx].stat.name);
@@ -121,7 +122,8 @@ opdl_xstats_get(const struct rte_eventdev *dev,
uint32_t p_start = queue_port_id * max_num_port_xstat;
uint32_t p_finish = p_start + max_num_port_xstat;
- for (uint32_t i = 0; i < n; i++) {
+ uint32_t i;
+ for (i = 0; i < n; i++) {
if (ids[i] < p_start || ids[i] >= p_finish)
return -EINVAL;
@@ -142,7 +144,8 @@ opdl_xstats_get_by_name(const struct rte_eventdev *dev,
uint32_t max_index = device->max_port_nb * max_num_port_xstat;
- for (uint32_t i = 0; i < max_index; i++) {
+ uint32_t i;
+ for (i = 0; i < max_index; i++) {
if (strncmp(name,
device->port_xstat[i].stat.name,
diff --git a/drivers/event/opdl/opdl_test.c b/drivers/event/opdl/opdl_test.c
index 44a5cc5..13d4f6b 100644
--- a/drivers/event/opdl/opdl_test.c
+++ b/drivers/event/opdl/opdl_test.c
@@ -433,7 +433,8 @@ atomic_basic(struct test *t)
return -1;
}
- for (int j = 0; j < 3; j++) {
+ int j;
+ for (j = 0; j < 3; j++) {
deq_ev[j].op = RTE_EVENT_OP_FORWARD;
deq_ev[j].queue_id = t->qid[1];
}
@@ -495,8 +496,9 @@ static int
check_statistics(void)
{
int num_ports = 3; /* Hard-coded for this app */
+ int i;
- for (int i = 0; i < num_ports; i++) {
+ for (i = 0; i < num_ports; i++) {
int num_stats, num_stats_returned;
num_stats = rte_event_dev_xstats_names_get(0,
--
2.7.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] event/opdl: rework loops to comply with dpdk style
2018-01-22 10:04 [dpdk-dev] [PATCH] event/opdl: rework loops to comply with dpdk style Harry van Haaren
@ 2018-01-22 10:30 ` Liang, Ma
2018-01-24 17:56 ` Thomas Monjalon
0 siblings, 1 reply; 3+ messages in thread
From: Liang, Ma @ 2018-01-22 10:30 UTC (permalink / raw)
To: Harry van Haaren; +Cc: dev, peter.mccarthy
On 22 Jan 10:04, Harry van Haaren wrote:
> This commit reworks the loop counter variable declarations
> to be in line with the DPDK source code.
>
> Fixes: 3c7f3dcfb099 ("event/opdl: add PMD main body and helper function")
> Fixes: 8ca8e3b48eff ("event/opdl: add event queue config get/set")
> Fixes: d548ef513cd7 ("event/opdl: add unit tests")
>
> Cc: liang.j.ma@intel.com
> Cc: peter.mccarthy@intel.com
>
> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
>
> ---
>
> Compile tested for loop declarations by adding "-std=gnu90" to the
> OPDL Makefile CFLAGS variable, which now passes here. Note that DPDK
> as a whole does not compile with gnu90, so don't pass it as EXTRA_CFLAGS
> ---
> drivers/event/opdl/Makefile | 2 --
> drivers/event/opdl/opdl_evdev.c | 9 +++++----
> drivers/event/opdl/opdl_evdev_init.c | 23 ++++++++++++++---------
> drivers/event/opdl/opdl_evdev_xstats.c | 9 ++++++---
> drivers/event/opdl/opdl_test.c | 6 ++++--
> 5 files changed, 29 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/event/opdl/Makefile b/drivers/event/opdl/Makefile
> index a8aff2c..747ae5b 100644
> --- a/drivers/event/opdl/Makefile
> +++ b/drivers/event/opdl/Makefile
> @@ -7,8 +7,6 @@ include $(RTE_SDK)/mk/rte.vars.mk
> LIB = librte_pmd_opdl_event.a
>
> # build flags
> -CFLAGS += -std=c99
> -CFLAGS += -D_XOPEN_SOURCE=600
> CFLAGS += -O3
> CFLAGS += $(WERROR_FLAGS)
> # for older GCC versions, allow us to initialize an event using
> diff --git a/drivers/event/opdl/opdl_evdev.c b/drivers/event/opdl/opdl_evdev.c
> index dcbf404..d5e2b60 100644
> --- a/drivers/event/opdl/opdl_evdev.c
> +++ b/drivers/event/opdl/opdl_evdev.c
> @@ -288,7 +288,8 @@ opdl_queue_setup(struct rte_eventdev *dev,
> }
> }
> /* Check if queue id has been setup already */
> - for (uint32_t i = 0; i < device->nb_q_md; i++) {
> + uint32_t i;
> + for (i = 0; i < device->nb_q_md; i++) {
> if (device->q_md[i].ext_id == queue_id) {
> PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
> "queue id %u already setup\n",
> @@ -390,8 +391,8 @@ opdl_dump(struct rte_eventdev *dev, FILE *f)
>
> fprintf(f,
> "\n\n -- RING STATISTICS --\n");
> -
> - for (uint32_t i = 0; i < device->nb_opdls; i++)
> + uint32_t i;
> + for (i = 0; i < device->nb_opdls; i++)
> opdl_ring_dump(device->opdl[i], f);
>
> fprintf(f,
> @@ -400,7 +401,7 @@ opdl_dump(struct rte_eventdev *dev, FILE *f)
> "Av. Grant Size Av. Cycles PP"
> " Empty DEQs Non Empty DEQs Pkts Processed\n");
>
> - for (uint32_t i = 0; i < device->max_port_nb; i++) {
> + for (i = 0; i < device->max_port_nb; i++) {
> char queue_id[64];
> char total_cyc[64];
> const char *p_type;
> diff --git a/drivers/event/opdl/opdl_evdev_init.c b/drivers/event/opdl/opdl_evdev_init.c
> index c37d8bc..84ab258 100644
> --- a/drivers/event/opdl/opdl_evdev_init.c
> +++ b/drivers/event/opdl/opdl_evdev_init.c
> @@ -314,8 +314,8 @@ static int opdl_add_deps(struct opdl_evdev *device,
> "Stages and dependents"
> " are not for same opdl ring",
> opdl_pmd_dev_id(device));
> - for (uint32_t k = 0;
> - k < device->nb_opdls; k++) {
> + uint32_t k;
> + for (k = 0; k < device->nb_opdls; k++) {
> opdl_ring_dump(device->opdl[k],
> stdout);
> }
> @@ -505,8 +505,9 @@ void
> destroy_queues_and_rings(struct rte_eventdev *dev)
> {
> struct opdl_evdev *device = opdl_pmd_priv(dev);
> + uint32_t i;
>
> - for (uint32_t i = 0; i < device->nb_opdls; i++) {
> + for (i = 0; i < device->nb_opdls; i++) {
> if (device->opdl[i])
> opdl_ring_free(device->opdl[i]);
> }
> @@ -639,7 +640,8 @@ create_queues_and_rings(struct rte_eventdev *dev)
> OPDL_Q_POS_START,
> -1);
>
> - for (uint32_t i = 0; i < device->nb_q_md; i++) {
> + uint32_t i;
> + for (i = 0; i < device->nb_q_md; i++) {
>
> /* Check */
> if (!device->q_md[i].setup) {
> @@ -702,7 +704,8 @@ initialise_all_other_ports(struct rte_eventdev *dev)
>
> struct opdl_evdev *device = opdl_pmd_priv(dev);
>
> - for (uint32_t i = 0; i < device->nb_ports; i++) {
> + uint32_t i;
> + for (i = 0; i < device->nb_ports; i++) {
> struct opdl_port *port = &device->ports[i];
> struct opdl_queue *queue = &device->queue[port->queue_id];
>
> @@ -827,7 +830,7 @@ initialise_all_other_ports(struct rte_eventdev *dev)
> * setup the last bit of stage md
> */
> if (!err) {
> - for (uint32_t i = 0; i < device->nb_ports; i++) {
> + for (i = 0; i < device->nb_ports; i++) {
> struct opdl_port *port = &device->ports[i];
> struct opdl_queue *queue =
> &device->queue[port->queue_id];
> @@ -872,7 +875,8 @@ initialise_queue_zero_ports(struct rte_eventdev *dev)
> struct opdl_evdev *device = opdl_pmd_priv(dev);
>
> /* Assign queue zero and figure out how many Q0 ports we have */
> - for (uint32_t i = 0; i < device->nb_ports; i++) {
> + uint32_t i;
> + for (i = 0; i < device->nb_ports; i++) {
> struct opdl_port *port = &device->ports[i];
> if (port->queue_id == OPDL_INVALID_QID) {
> port->queue_id = 0;
> @@ -889,7 +893,7 @@ initialise_queue_zero_ports(struct rte_eventdev *dev)
> if (stage_inst) {
>
> /* Assign the new created input stage to all relevant ports */
> - for (uint32_t i = 0; i < device->nb_ports; i++) {
> + for (i = 0; i < device->nb_ports; i++) {
> struct opdl_port *port = &device->ports[i];
> if (port->queue_id == 0) {
> queue = &device->queue[port->queue_id];
> @@ -914,8 +918,9 @@ assign_internal_queue_ids(struct rte_eventdev *dev)
> {
> int err = 0;
> struct opdl_evdev *device = opdl_pmd_priv(dev);
> + uint32_t i;
>
> - for (uint32_t i = 0; i < device->nb_ports; i++) {
> + for (i = 0; i < device->nb_ports; i++) {
> struct opdl_port *port = &device->ports[i];
> if (port->external_qid != OPDL_INVALID_QID) {
> port->queue_id =
> diff --git a/drivers/event/opdl/opdl_evdev_xstats.c b/drivers/event/opdl/opdl_evdev_xstats.c
> index 94dfeee..70b84d9 100644
> --- a/drivers/event/opdl/opdl_evdev_xstats.c
> +++ b/drivers/event/opdl/opdl_evdev_xstats.c
> @@ -86,7 +86,8 @@ opdl_xstats_get_names(const struct rte_eventdev *dev,
>
> uint32_t port_idx = queue_port_id * max_num_port_xstat;
>
> - for (uint32_t j = 0; j < max_num_port_xstat; j++) {
> + uint32_t j;
> + for (j = 0; j < max_num_port_xstat; j++) {
>
> strcpy(xstats_names[j].name,
> device->port_xstat[j + port_idx].stat.name);
> @@ -121,7 +122,8 @@ opdl_xstats_get(const struct rte_eventdev *dev,
> uint32_t p_start = queue_port_id * max_num_port_xstat;
> uint32_t p_finish = p_start + max_num_port_xstat;
>
> - for (uint32_t i = 0; i < n; i++) {
> + uint32_t i;
> + for (i = 0; i < n; i++) {
> if (ids[i] < p_start || ids[i] >= p_finish)
> return -EINVAL;
>
> @@ -142,7 +144,8 @@ opdl_xstats_get_by_name(const struct rte_eventdev *dev,
>
> uint32_t max_index = device->max_port_nb * max_num_port_xstat;
>
> - for (uint32_t i = 0; i < max_index; i++) {
> + uint32_t i;
> + for (i = 0; i < max_index; i++) {
>
> if (strncmp(name,
> device->port_xstat[i].stat.name,
> diff --git a/drivers/event/opdl/opdl_test.c b/drivers/event/opdl/opdl_test.c
> index 44a5cc5..13d4f6b 100644
> --- a/drivers/event/opdl/opdl_test.c
> +++ b/drivers/event/opdl/opdl_test.c
> @@ -433,7 +433,8 @@ atomic_basic(struct test *t)
> return -1;
> }
>
> - for (int j = 0; j < 3; j++) {
> + int j;
> + for (j = 0; j < 3; j++) {
> deq_ev[j].op = RTE_EVENT_OP_FORWARD;
> deq_ev[j].queue_id = t->qid[1];
> }
> @@ -495,8 +496,9 @@ static int
> check_statistics(void)
> {
> int num_ports = 3; /* Hard-coded for this app */
> + int i;
>
> - for (int i = 0; i < num_ports; i++) {
> + for (i = 0; i < num_ports; i++) {
> int num_stats, num_stats_returned;
>
> num_stats = rte_event_dev_xstats_names_get(0,
> --
> 2.7.4
>
Many thanks Harry.
Acked-by: Liang Ma <liang.j.ma@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] event/opdl: rework loops to comply with dpdk style
2018-01-22 10:30 ` Liang, Ma
@ 2018-01-24 17:56 ` Thomas Monjalon
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2018-01-24 17:56 UTC (permalink / raw)
To: Harry van Haaren; +Cc: dev, Liang, Ma, peter.mccarthy
22/01/2018 11:30, Liang, Ma:
> On 22 Jan 10:04, Harry van Haaren wrote:
> > This commit reworks the loop counter variable declarations
> > to be in line with the DPDK source code.
> >
> > Fixes: 3c7f3dcfb099 ("event/opdl: add PMD main body and helper function")
> > Fixes: 8ca8e3b48eff ("event/opdl: add event queue config get/set")
> > Fixes: d548ef513cd7 ("event/opdl: add unit tests")
> >
> > Cc: liang.j.ma@intel.com
> > Cc: peter.mccarthy@intel.com
> >
> > Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
> >
> > ---
> Many thanks Harry.
>
> Acked-by: Liang Ma <liang.j.ma@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-24 17:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-22 10:04 [dpdk-dev] [PATCH] event/opdl: rework loops to comply with dpdk style Harry van Haaren
2018-01-22 10:30 ` Liang, Ma
2018-01-24 17:56 ` Thomas Monjalon
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).