DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jerin Jacob <jerinjacobk@gmail.com>
To: Pavan Nikhilesh <pbhagavatula@marvell.com>
Cc: Jerin Jacob <jerinj@marvell.com>,
	"Richardson, Bruce" <bruce.richardson@intel.com>,
	 Akhil Goyal <akhil.goyal@nxp.com>,
	Marko Kovacevic <marko.kovacevic@intel.com>,
	Ori Kam <orika@mellanox.com>,
	Radu Nicolau <radu.nicolau@intel.com>,
	 Tomasz Kantecki <tomasz.kantecki@intel.com>,
	Sunil Kumar Kori <skori@marvell.com>, dpdk-dev <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v5 08/10] examples/l2fwd-event: add eventdev main loop
Date: Fri, 11 Oct 2019 20:22:22 +0530	[thread overview]
Message-ID: <CALBAE1Mm42f6U929N+THopTeg+_71egNj=5BRgbkOFrr6Ugpgw@mail.gmail.com> (raw)
In-Reply-To: <20191002205754.11746-9-pbhagavatula@marvell.com>

On Thu, Oct 3, 2019 at 2:29 AM <pbhagavatula@marvell.com> wrote:
>
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> Add event dev main loop based on enabled l2fwd options and eventdev
> capabilities.
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
>  examples/l2fwd-event/l2fwd_common.c |   6 +
>  examples/l2fwd-event/l2fwd_common.h |   2 +
>  examples/l2fwd-event/l2fwd_event.c  | 294 ++++++++++++++++++++++++++++
>  examples/l2fwd-event/l2fwd_event.h  |   2 +
>  examples/l2fwd-event/main.c         |   6 +-
>  5 files changed, 309 insertions(+), 1 deletion(-)
>
> diff --git a/examples/l2fwd-event/l2fwd_common.c b/examples/l2fwd-event/l2fwd_common.c
> index 213652d72..40e933c91 100644
> --- a/examples/l2fwd-event/l2fwd_common.c
> +++ b/examples/l2fwd-event/l2fwd_common.c
> @@ -65,6 +65,12 @@ l2fwd_event_init_ports(struct l2fwd_resources *l2fwd_rsrc)
>         uint16_t port_id;
>         int ret;
>
> +       if (l2fwd_rsrc->event_mode) {
> +               port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
> +               port_conf.rx_adv_conf.rss_conf.rss_key = NULL;
> +               port_conf.rx_adv_conf.rss_conf.rss_hf = ETH_RSS_IP;
> +       }
> +
>         /* Initialise each port */
>         RTE_ETH_FOREACH_DEV(port_id) {
>                 struct rte_eth_conf local_port_conf = port_conf;
> diff --git a/examples/l2fwd-event/l2fwd_common.h b/examples/l2fwd-event/l2fwd_common.h
> index cdafa52c7..852c6d321 100644
> --- a/examples/l2fwd-event/l2fwd_common.h
> +++ b/examples/l2fwd-event/l2fwd_common.h
> @@ -114,7 +114,9 @@ l2fwd_get_rsrc(void)
>
>                 memset(l2fwd_rsrc, 0, sizeof(struct l2fwd_resources));
>                 l2fwd_rsrc->mac_updating = true;
> +               l2fwd_rsrc->event_mode = true;
>                 l2fwd_rsrc->rx_queue_per_lcore = 1;
> +               l2fwd_rsrc->sched_type = RTE_SCHED_TYPE_ATOMIC;
>                 l2fwd_rsrc->timer_period = 10 * rte_get_timer_hz();
>
>                 return mz->addr;
> diff --git a/examples/l2fwd-event/l2fwd_event.c b/examples/l2fwd-event/l2fwd_event.c
> index adba40069..df0b56773 100644
> --- a/examples/l2fwd-event/l2fwd_event.c
> +++ b/examples/l2fwd-event/l2fwd_event.c
> @@ -17,6 +17,12 @@
>
>  #include "l2fwd_event.h"
>
> +#define L2FWD_EVENT_SINGLE     0x1
> +#define L2FWD_EVENT_BURST      0x2
> +#define L2FWD_EVENT_TX_DIRECT  0x4
> +#define L2FWD_EVENT_TX_ENQ     0x8
> +#define L2FWD_EVENT_UPDT_MAC   0x10
> +
>  static inline int
>  l2fwd_event_service_enable(uint32_t service_id)
>  {
> @@ -128,11 +134,289 @@ l2fwd_event_capability_setup(struct l2fwd_event_resources *event_rsrc)
>                 l2fwd_event_set_internal_port_ops(&event_rsrc->ops);
>  }
>
> +static __rte_noinline int
> +l2fwd_get_free_event_port(struct l2fwd_event_resources *event_rsrc)
> +{
> +       static int index;
> +       int port_id;
> +
> +       rte_spinlock_lock(&event_rsrc->evp.lock);
> +       if (index >= event_rsrc->evp.nb_ports) {
> +               printf("No free event port is available\n");
> +               return -1;
> +       }
> +
> +       port_id = event_rsrc->evp.event_p_id[index];
> +       index++;
> +       rte_spinlock_unlock(&event_rsrc->evp.lock);
> +
> +       return port_id;
> +}
> +
> +static __rte_always_inline void
> +l2fwd_event_loop_single(struct l2fwd_resources *l2fwd_rsrc,
> +                       const uint32_t flags)
> +{
> +       const uint8_t is_master = rte_get_master_lcore() == rte_lcore_id();
> +       struct l2fwd_event_resources *event_rsrc = l2fwd_rsrc->event_rsrc;
> +       const int port_id = l2fwd_get_free_event_port(event_rsrc);
> +       uint64_t prev_tsc = 0, diff_tsc, cur_tsc, timer_tsc = 0;
> +       const uint64_t timer_period = l2fwd_rsrc->timer_period;
> +       const uint8_t tx_q_id = event_rsrc->evq.event_q_id[
> +                                       event_rsrc->evq.nb_queues - 1];

See below

> +       const uint8_t event_d_id = event_rsrc->event_d_id;
> +       struct rte_mbuf *mbuf;
> +       uint16_t dst_port;
> +       struct rte_event ev;
> +
> +       if (port_id < 0)
> +               return;
> +
> +       printf("%s(): entering eventdev main loop on lcore %u\n", __func__,
> +               rte_lcore_id());
> +
> +       while (!l2fwd_rsrc->force_quit) {
> +               /* if timer is enabled */
> +               if (is_master && timer_period > 0) {
> +                       cur_tsc = rte_rdtsc();
> +                       diff_tsc = cur_tsc - prev_tsc;
> +
> +                       /* advance the timer */
> +                       timer_tsc += diff_tsc;
> +
> +                       /* if timer has reached its timeout */
> +                       if (unlikely(timer_tsc >= timer_period)) {
> +                               print_stats(l2fwd_rsrc);
> +                               /* reset the timer */
> +                               timer_tsc = 0;
> +                       }
> +                       prev_tsc = cur_tsc;
> +               }
> +
> +               /* Read packet from eventdev */
> +               if (!rte_event_dequeue_burst(event_d_id, port_id, &ev, 1, 0))
> +                       continue;
> +
> +
> +               mbuf = ev.mbuf;
> +               dst_port = l2fwd_rsrc->dst_ports[mbuf->port];
> +               rte_prefetch0(rte_pktmbuf_mtod(mbuf, void *));
> +
> +               if (timer_period > 0)
> +                       __atomic_fetch_add(
> +                                       &l2fwd_rsrc->port_stats[mbuf->port].rx,
> +                                       1, __ATOMIC_RELAXED);
> +
> +               mbuf->port = dst_port;
> +               if (flags & L2FWD_EVENT_UPDT_MAC)
> +                       l2fwd_mac_updating(mbuf, dst_port,
> +                                          &l2fwd_rsrc->eth_addr[dst_port]);

See below

> +
> +               if (flags & L2FWD_EVENT_TX_ENQ) {
> +                       ev.queue_id = tx_q_id;
> +                       ev.op = RTE_EVENT_OP_FORWARD;
> +                       while (rte_event_enqueue_burst(event_d_id, port_id,
> +                                                      &ev, 1) &&
> +                                       !l2fwd_rsrc->force_quit)
> +                               ;
> +               }
> +
> +               if (flags & L2FWD_EVENT_TX_DIRECT) {
> +                       rte_event_eth_tx_adapter_txq_set(mbuf, 0);
> +                       while (!rte_event_eth_tx_adapter_enqueue(event_d_id,
> +                                                               port_id,
> +                                                               &ev, 1) &&

See below

> +                                       !l2fwd_rsrc->force_quit)
> +                               ;
> +               }
> +
> +               if (timer_period > 0)
> +                       __atomic_fetch_add(
> +                                       &l2fwd_rsrc->port_stats[mbuf->port].tx,
> +                                       1, __ATOMIC_RELAXED);

As style comment:

# There is a lot of multiline statements in the code, which reduce the
readability of the code. Please find below some options to reduce it.
Could you please check options to reduce it

1) shorten the structure name like
 s/event_rsrc/evt_rsrc
 s/l2fwd_rsrc/ rsrc

2) I think, rte_exit(EXIT_FAILURE can be replaced to rte_panic in the
application case

3) Adjusting the newline code starts
diff --git a/examples/l2fwd-event/l2fwd_event.c
b/examples/l2fwd-event/l2fwd_event.c
index df0b56773..49665a102 100644
--- a/examples/l2fwd-event/l2fwd_event.c
+++ b/examples/l2fwd-event/l2fwd_event.c
@@ -87,8 +87,8 @@ l2fwd_event_service_setup(struct l2fwd_resources *l2fwd_rsrc)
                                &service_id);
                if (ret != -ESRCH && ret != 0)
                        rte_exit(EXIT_FAILURE,
-                                       "Error in starting Rx
adapter[%d] service\n",
-                                       event_rsrc->rx_adptr.rx_adptr[i]);
+                                "Error in starting Rx adapter[%d] service\n",
+                                event_rsrc->rx_adptr.rx_adptr[i]);
                l2fwd_event_service_enable(service_id);
        }

4) Replace code in the nested loop with static inline function so that code gets
enough space in new function.

  reply	other threads:[~2019-10-11 14:52 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19  9:25 [dpdk-dev] [PATCH v2 00/10] example/l2fwd-event: introduce l2fwd-event example pbhagavatula
2019-09-19  9:25 ` [dpdk-dev] [PATCH v2 01/10] examples/l2fwd-event: add default poll mode routines pbhagavatula
2019-09-19  9:43   ` Sunil Kumar Kori
2019-09-19 10:13   ` [dpdk-dev] [PATCH v3 00/10] example/l2fwd-event: introduce l2fwd-event example pbhagavatula
2019-09-19 10:13     ` [dpdk-dev] [PATCH v3 01/10] examples/l2fwd-event: add default poll mode routines pbhagavatula
2019-09-19 10:13     ` [dpdk-dev] [PATCH v3 02/10] examples/l2fwd-event: add infra for eventdev pbhagavatula
2019-09-19 10:13     ` [dpdk-dev] [PATCH v3 03/10] examples/l2fwd-event: add infra to split eventdev framework pbhagavatula
2019-09-19 10:13     ` [dpdk-dev] [PATCH v3 04/10] examples/l2fwd-event: add eth port setup for eventdev pbhagavatula
2019-09-19 10:13     ` [dpdk-dev] [PATCH v3 05/10] examples/l2fwd-event: add eventdev queue and port setup pbhagavatula
2019-09-19 10:35       ` Sunil Kumar Kori
2019-09-19 10:13     ` [dpdk-dev] [PATCH v3 06/10] examples/l2fwd-event: add event Rx/Tx adapter setup pbhagavatula
2019-09-19 10:13     ` [dpdk-dev] [PATCH v3 07/10] examples/l2fwd-event: add service core setup pbhagavatula
2019-09-19 10:13     ` [dpdk-dev] [PATCH v3 08/10] examples/l2fwd-event: add eventdev main loop pbhagavatula
2019-09-19 10:13     ` [dpdk-dev] [PATCH v3 09/10] examples/l2fwd-event: add graceful teardown pbhagavatula
2019-09-19 10:13     ` [dpdk-dev] [PATCH v3 10/10] doc: add application usage guide for l2fwd-event pbhagavatula
2019-09-24  9:41     ` [dpdk-dev] [PATCH v4 00/10] example/l2fwd-event: introduce l2fwd-event example pbhagavatula
2019-09-24  9:42       ` [dpdk-dev] [PATCH v4 01/10] examples/l2fwd-event: add default poll mode routines pbhagavatula
2019-09-26 17:28         ` Jerin Jacob
2019-09-24  9:42       ` [dpdk-dev] [PATCH v4 02/10] examples/l2fwd-event: add infra for eventdev pbhagavatula
2019-09-26 17:33         ` Jerin Jacob
2019-09-27 13:08         ` Nipun Gupta
2019-09-24  9:42       ` [dpdk-dev] [PATCH v4 03/10] examples/l2fwd-event: add infra to split eventdev framework pbhagavatula
2019-09-24  9:42       ` [dpdk-dev] [PATCH v4 04/10] examples/l2fwd-event: add eth port setup for eventdev pbhagavatula
2019-09-27 13:15         ` Nipun Gupta
2019-09-27 14:45           ` Pavan Nikhilesh Bhagavatula
2019-09-24  9:42       ` [dpdk-dev] [PATCH v4 05/10] examples/l2fwd-event: add eventdev queue and port setup pbhagavatula
2019-09-27 13:22         ` Nipun Gupta
2019-09-27 14:43           ` Pavan Nikhilesh Bhagavatula
2019-09-24  9:42       ` [dpdk-dev] [PATCH v4 06/10] examples/l2fwd-event: add event Rx/Tx adapter setup pbhagavatula
2019-09-24  9:42       ` [dpdk-dev] [PATCH v4 07/10] examples/l2fwd-event: add service core setup pbhagavatula
2019-09-24  9:42       ` [dpdk-dev] [PATCH v4 08/10] examples/l2fwd-event: add eventdev main loop pbhagavatula
2019-09-27 13:28         ` Nipun Gupta
2019-09-27 14:35           ` Pavan Nikhilesh Bhagavatula
2019-09-30  5:38             ` Nipun Gupta
2019-09-30  6:38               ` Jerin Jacob
2019-09-30  7:46                 ` Nipun Gupta
2019-09-30  8:09                   ` Pavan Nikhilesh Bhagavatula
2019-09-30 17:50                     ` Nipun Gupta
2019-10-01  5:59                       ` Pavan Nikhilesh Bhagavatula
2019-09-24  9:42       ` [dpdk-dev] [PATCH v4 09/10] examples/l2fwd-event: add graceful teardown pbhagavatula
2019-09-24  9:42       ` [dpdk-dev] [PATCH v4 10/10] doc: add application usage guide for l2fwd-event pbhagavatula
2019-09-26 17:42         ` Jerin Jacob
2019-10-02 20:57       ` [dpdk-dev] [PATCH v5 00/10] example/l2fwd-event: introduce l2fwd-event example pbhagavatula
2019-10-02 20:57         ` [dpdk-dev] [PATCH v5 01/10] examples/l2fwd-event: add default poll mode routines pbhagavatula
2019-10-11 14:41           ` Jerin Jacob
2019-10-02 20:57         ` [dpdk-dev] [PATCH v5 02/10] examples/l2fwd-event: add infra for eventdev pbhagavatula
2019-10-04 12:30           ` Nipun Gupta
2019-10-02 20:57         ` [dpdk-dev] [PATCH v5 03/10] examples/l2fwd-event: add infra to split eventdev framework pbhagavatula
2019-10-02 20:57         ` [dpdk-dev] [PATCH v5 04/10] examples/l2fwd-event: add event device setup pbhagavatula
2019-10-02 20:57         ` [dpdk-dev] [PATCH v5 05/10] examples/l2fwd-event: add eventdev queue and port setup pbhagavatula
2019-10-02 20:57         ` [dpdk-dev] [PATCH v5 06/10] examples/l2fwd-event: add event Rx/Tx adapter setup pbhagavatula
2019-10-02 20:57         ` [dpdk-dev] [PATCH v5 07/10] examples/l2fwd-event: add service core setup pbhagavatula
2019-10-02 20:57         ` [dpdk-dev] [PATCH v5 08/10] examples/l2fwd-event: add eventdev main loop pbhagavatula
2019-10-11 14:52           ` Jerin Jacob [this message]
2019-10-02 20:57         ` [dpdk-dev] [PATCH v5 09/10] examples/l2fwd-event: add graceful teardown pbhagavatula
2019-10-02 20:57         ` [dpdk-dev] [PATCH v5 10/10] doc: add application usage guide for l2fwd-event pbhagavatula
2019-10-11 14:11           ` Jerin Jacob
2019-10-03 10:33         ` [dpdk-dev] [PATCH v5 00/10] example/l2fwd-event: introduce l2fwd-event example Jerin Jacob
2019-10-03 12:40           ` Hemant Agrawal
2019-10-03 12:47             ` Jerin Jacob
2019-10-09  7:50         ` Nipun Gupta
2019-10-14 18:22         ` [dpdk-dev] [PATCH v6 " pbhagavatula
2019-10-14 18:22           ` [dpdk-dev] [PATCH v6 01/10] examples/l2fwd-event: add default poll mode routines pbhagavatula
2019-10-16 19:07             ` Stephen Hemminger
2019-10-21  3:29             ` Varghese, Vipin
2019-10-14 18:22           ` [dpdk-dev] [PATCH v6 02/10] examples/l2fwd-event: add infra for eventdev pbhagavatula
2019-10-14 18:22           ` [dpdk-dev] [PATCH v6 03/10] examples/l2fwd-event: add infra to split eventdev framework pbhagavatula
2019-10-14 18:22           ` [dpdk-dev] [PATCH v6 04/10] examples/l2fwd-event: add event device setup pbhagavatula
2019-10-14 18:22           ` [dpdk-dev] [PATCH v6 05/10] examples/l2fwd-event: add eventdev queue and port setup pbhagavatula
2019-10-14 18:22           ` [dpdk-dev] [PATCH v6 06/10] examples/l2fwd-event: add event Rx/Tx adapter setup pbhagavatula
2019-10-14 18:22           ` [dpdk-dev] [PATCH v6 07/10] examples/l2fwd-event: add service core setup pbhagavatula
2019-10-14 18:22           ` [dpdk-dev] [PATCH v6 08/10] examples/l2fwd-event: add eventdev main loop pbhagavatula
2019-10-21  3:19             ` Varghese, Vipin
2019-10-21 16:53               ` Pavan Nikhilesh Bhagavatula
2019-10-22  3:13                 ` Varghese, Vipin
2019-10-22 17:02                   ` Pavan Nikhilesh Bhagavatula
2019-10-14 18:22           ` [dpdk-dev] [PATCH v6 09/10] examples/l2fwd-event: add graceful teardown pbhagavatula
2019-10-21  3:12             ` Varghese, Vipin
2019-10-21 16:56               ` Pavan Nikhilesh Bhagavatula
2019-10-22  2:48                 ` Varghese, Vipin
2019-10-14 18:22           ` [dpdk-dev] [PATCH v6 10/10] doc: add application usage guide for l2fwd-event pbhagavatula
2019-10-16 12:38           ` [dpdk-dev] [PATCH v6 00/10] example/l2fwd-event: introduce l2fwd-event example Jerin Jacob
2019-10-21  3:25           ` Varghese, Vipin
2019-10-21 17:02             ` Pavan Nikhilesh Bhagavatula
2019-10-22  2:57               ` Varghese, Vipin
2019-10-22 15:55                 ` Pavan Nikhilesh Bhagavatula
2019-10-26 11:10           ` [dpdk-dev] [PATCH v7 " pbhagavatula
2019-10-26 11:10             ` [dpdk-dev] [PATCH v7 01/10] examples/l2fwd-event: add default poll mode routines pbhagavatula
2019-10-26 11:10             ` [dpdk-dev] [PATCH v7 02/10] examples/l2fwd-event: add infra for eventdev pbhagavatula
2019-10-26 11:10             ` [dpdk-dev] [PATCH v7 03/10] examples/l2fwd-event: add infra to split eventdev framework pbhagavatula
2019-10-26 11:10             ` [dpdk-dev] [PATCH v7 04/10] examples/l2fwd-event: add event device setup pbhagavatula
2019-10-26 11:10             ` [dpdk-dev] [PATCH v7 05/10] examples/l2fwd-event: add eventdev queue and port setup pbhagavatula
2019-10-26 11:10             ` [dpdk-dev] [PATCH v7 06/10] examples/l2fwd-event: add event Rx/Tx adapter setup pbhagavatula
2019-10-26 11:10             ` [dpdk-dev] [PATCH v7 07/10] examples/l2fwd-event: add service core setup pbhagavatula
2019-10-26 11:10             ` [dpdk-dev] [PATCH v7 08/10] examples/l2fwd-event: add eventdev main loop pbhagavatula
2019-10-26 11:10             ` [dpdk-dev] [PATCH v7 09/10] examples/l2fwd-event: add graceful teardown pbhagavatula
2019-10-26 11:10             ` [dpdk-dev] [PATCH v7 10/10] doc: add application usage guide for l2fwd-event pbhagavatula
2019-10-30 13:19               ` Jerin Jacob
2019-10-30 12:58             ` [dpdk-dev] [PATCH v7 00/10] example/l2fwd-event: introduce l2fwd-event example Jerin Jacob
2019-09-19  9:25 ` [dpdk-dev] [PATCH v2 02/10] examples/l2fwd-event: add infra for eventdev pbhagavatula
2019-09-19  9:25 ` [dpdk-dev] [PATCH v2 03/10] examples/l2fwd-event: add infra to split eventdev framework pbhagavatula
2019-09-19  9:25 ` [dpdk-dev] [PATCH v2 04/10] examples/l2fwd-event: add eth port setup for eventdev pbhagavatula
2019-09-19  9:25 ` [dpdk-dev] [PATCH v2 05/10] examples/l2fwd-event: add eventdev queue and port setup pbhagavatula
2019-09-19  9:26 ` [dpdk-dev] [PATCH v2 06/10] examples/l2fwd-event: add event Rx/Tx adapter setup pbhagavatula
2019-09-19  9:26 ` [dpdk-dev] [PATCH v2 07/10] examples/l2fwd-event: add service core setup pbhagavatula
2019-09-19  9:26 ` [dpdk-dev] [PATCH v2 08/10] examples/l2fwd-event: add eventdev main loop pbhagavatula
2019-09-19  9:26 ` [dpdk-dev] [PATCH v2 09/10] examples/l2fwd-event: add graceful teardown pbhagavatula

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='CALBAE1Mm42f6U929N+THopTeg+_71egNj=5BRgbkOFrr6Ugpgw@mail.gmail.com' \
    --to=jerinjacobk@gmail.com \
    --cc=akhil.goyal@nxp.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=marko.kovacevic@intel.com \
    --cc=orika@mellanox.com \
    --cc=pbhagavatula@marvell.com \
    --cc=radu.nicolau@intel.com \
    --cc=skori@marvell.com \
    --cc=tomasz.kantecki@intel.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).