From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F0BE943063; Mon, 14 Aug 2023 17:17:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0F945432BD; Mon, 14 Aug 2023 17:16:32 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 9F44F432B1; Mon, 14 Aug 2023 17:16:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692026188; x=1723562188; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R+z8eYrRdENqmmjRhGzkkRXLbyn3DJyDVhhaqVnGzGg=; b=nI9TisDSfBxHLnpDasWFvvqTVlqCW1lRXvLnHtmBUkO8orKmoTR6wwqR WH9X8xVTcHhIaANGaHmQ7JWPtA5iMU8/gx1XF4g50ebC0NIQNEyDJULyS sagzBQsFLbrJzpDF+46zR6NAMpNL8/M9aM30W81SaCFzfiDMOhVTx6+8b IleQBJdRfxPXP+iDKcpxWLDx7jZ+hFa8OREF95dP9K4miWqozjhw5pJsM +88rS1acZesTmhLLLoyDf1HW63fQJkFSw34bVbzJQdRFEcOm5Y4hScrz4 sIjKBPx8BXBAul0sTDBr5PoWSjUmbCqeajDOhVCKyqI+bnkmlcnZw635R Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10802"; a="362211297" X-IronPort-AV: E=Sophos;i="6.01,172,1684825200"; d="scan'208";a="362211297" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2023 08:16:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10802"; a="803499973" X-IronPort-AV: E=Sophos;i="6.01,172,1684825200"; d="scan'208";a="803499973" Received: from silpixa00401385.ir.intel.com ([10.237.214.14]) by fmsmga004.fm.intel.com with ESMTP; 14 Aug 2023 08:16:25 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: ci@dpdk.org, Bruce Richardson Subject: [PATCH v2 6/8] examples/l3fwd: make eventdev an optional dependency Date: Mon, 14 Aug 2023 16:16:07 +0100 Message-Id: <20230814151609.3077077-7-bruce.richardson@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230814151609.3077077-1-bruce.richardson@intel.com> References: <20230721115125.55137-1-bruce.richardson@intel.com> <20230814151609.3077077-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org With l3fwd being a very commonly used example app, and built as part of our CI tests, we need to ensure it's buildable with just about all supported DPDK configurations. To enable l3fwd application to be built when the eventdev library is disabled, we need to compile in the eventdev support conditionally. Thankfully, the eventdev support is pretty self-contained, with only the main.c file having more than a couple of ifdefs. Signed-off-by: Bruce Richardson --- examples/l3fwd/l3fwd_em.c | 2 + examples/l3fwd/l3fwd_em_hlm.h | 2 + examples/l3fwd/l3fwd_event.c | 2 + examples/l3fwd/l3fwd_event.h | 7 ++- examples/l3fwd/l3fwd_event_generic.c | 2 + examples/l3fwd/l3fwd_event_internal_port.c | 2 + examples/l3fwd/l3fwd_fib.c | 2 + examples/l3fwd/l3fwd_lpm.c | 2 + examples/l3fwd/main.c | 65 +++++++++++++++++----- examples/l3fwd/meson.build | 5 +- 10 files changed, 74 insertions(+), 17 deletions(-) diff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c index 476ac0c54f..40e102b38a 100644 --- a/examples/l3fwd/l3fwd_em.c +++ b/examples/l3fwd/l3fwd_em.c @@ -663,6 +663,7 @@ em_main_loop(__rte_unused void *dummy) return 0; } +#ifdef RTE_LIB_EVENTDEV static __rte_always_inline void em_event_loop_single(struct l3fwd_event_resources *evt_rsrc, const uint8_t flags) @@ -959,6 +960,7 @@ em_event_main_loop_tx_q_burst_vector(__rte_unused void *dummy) em_event_loop_vector(evt_rsrc, L3FWD_EVENT_TX_ENQ); return 0; } +#endif /* Initialize exact match (hash) parameters. 8< */ void diff --git a/examples/l3fwd/l3fwd_em_hlm.h b/examples/l3fwd/l3fwd_em_hlm.h index 2e11eefad7..31cda9ddc1 100644 --- a/examples/l3fwd/l3fwd_em_hlm.h +++ b/examples/l3fwd/l3fwd_em_hlm.h @@ -255,6 +255,7 @@ l3fwd_em_send_packets(int nb_rx, struct rte_mbuf **pkts_burst, uint16_t portid, send_packets_multi(qconf, pkts_burst, dst_port, nb_rx); } +#ifdef RTE_LIB_EVENTDEV /* * Buffer optimized handling of events, invoked * from main_loop. @@ -347,5 +348,6 @@ l3fwd_em_process_event_vector(struct rte_event_vector *vec, process_event_vector(vec, dst_port); } +#endif /* RTE_LIB_EVENTDEV */ #endif /* __L3FWD_EM_HLM_H__ */ diff --git a/examples/l3fwd/l3fwd_event.c b/examples/l3fwd/l3fwd_event.c index 32906ab08d..d72a4138cc 100644 --- a/examples/l3fwd/l3fwd_event.c +++ b/examples/l3fwd/l3fwd_event.c @@ -2,6 +2,7 @@ * Copyright(C) 2019 Marvell International Ltd. */ +#ifdef RTE_LIB_EVENTDEV #include #include @@ -341,3 +342,4 @@ l3fwd_event_worker_cleanup(uint8_t event_d_id, uint8_t event_p_id, rte_event_port_quiesce(event_d_id, event_p_id, l3fwd_event_port_flush, NULL); } +#endif /* #ifdef RTE_LIB_EVENTDEV */ diff --git a/examples/l3fwd/l3fwd_event.h b/examples/l3fwd/l3fwd_event.h index e21817c36b..1fd6fe4a78 100644 --- a/examples/l3fwd/l3fwd_event.h +++ b/examples/l3fwd/l3fwd_event.h @@ -6,11 +6,13 @@ #define __L3FWD_EVENTDEV_H__ #include +#include +#include + +#ifdef RTE_LIB_EVENTDEV #include #include #include -#include -#include #include "l3fwd.h" @@ -164,4 +166,5 @@ void l3fwd_event_worker_cleanup(uint8_t event_d_id, uint8_t event_p_id, struct rte_event events[], uint16_t nb_enq, uint16_t nb_deq, uint8_t is_vector); +#endif /* ifdef RTE_LIB_EVENTDEV */ #endif /* __L3FWD_EVENTDEV_H__ */ diff --git a/examples/l3fwd/l3fwd_event_generic.c b/examples/l3fwd/l3fwd_event_generic.c index c80573fc58..ddb6e5c38d 100644 --- a/examples/l3fwd/l3fwd_event_generic.c +++ b/examples/l3fwd/l3fwd_event_generic.c @@ -2,6 +2,7 @@ * Copyright(C) 2019 Marvell International Ltd. */ +#ifdef RTE_LIB_EVENTDEV #include #include "l3fwd.h" @@ -309,3 +310,4 @@ l3fwd_event_set_generic_ops(struct l3fwd_event_setup_ops *ops) ops->event_port_setup = l3fwd_event_port_setup_generic; ops->adapter_setup = l3fwd_rx_tx_adapter_setup_generic; } +#endif /* RTE_LIB_EVENTDEV */ diff --git a/examples/l3fwd/l3fwd_event_internal_port.c b/examples/l3fwd/l3fwd_event_internal_port.c index 32cf657148..cb49a8b9fa 100644 --- a/examples/l3fwd/l3fwd_event_internal_port.c +++ b/examples/l3fwd/l3fwd_event_internal_port.c @@ -2,6 +2,7 @@ * Copyright(C) 2019 Marvell International Ltd. */ +#ifdef RTE_LIB_EVENTDEV #include #include "l3fwd.h" @@ -311,3 +312,4 @@ l3fwd_event_set_internal_port_ops(struct l3fwd_event_setup_ops *ops) ops->event_port_setup = l3fwd_event_port_setup_internal_port; ops->adapter_setup = l3fwd_rx_tx_adapter_setup_internal_port; } +#endif /* RTE_LIB_EVENTDEV */ diff --git a/examples/l3fwd/l3fwd_fib.c b/examples/l3fwd/l3fwd_fib.c index 18398492ae..6a21984415 100644 --- a/examples/l3fwd/l3fwd_fib.c +++ b/examples/l3fwd/l3fwd_fib.c @@ -253,6 +253,7 @@ fib_main_loop(__rte_unused void *dummy) return 0; } +#ifdef RTE_LIB_EVENTDEV /* One eventdev loop for single and burst using fib. */ static __rte_always_inline void fib_event_loop(struct l3fwd_event_resources *evt_rsrc, @@ -635,6 +636,7 @@ fib_event_main_loop_tx_q_burst_vector(__rte_unused void *dummy) fib_event_loop_vector(evt_rsrc, L3FWD_EVENT_TX_ENQ); return 0; } +#endif /* Function to setup fib. 8< */ void diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c index 4ac1925c84..a484a33089 100644 --- a/examples/l3fwd/l3fwd_lpm.c +++ b/examples/l3fwd/l3fwd_lpm.c @@ -226,6 +226,7 @@ lpm_main_loop(__rte_unused void *dummy) return 0; } +#ifdef RTE_LIB_EVENTDEV static __rte_always_inline uint16_t lpm_process_event_pkt(const struct lcore_conf *lconf, struct rte_mbuf *mbuf) { @@ -554,6 +555,7 @@ lpm_event_main_loop_tx_q_burst_vector(__rte_unused void *dummy) lpm_event_loop_vector(evt_rsrc, L3FWD_EVENT_TX_ENQ); return 0; } +#endif void setup_lpm(const int socketid) diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index a4f061537e..6063eb1399 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -135,8 +135,10 @@ static struct rte_eth_conf port_conf = { uint32_t max_pkt_len; -static struct rte_mempool *pktmbuf_pool[RTE_MAX_ETHPORTS][NB_SOCKETS]; +#ifdef RTE_LIB_EVENTDEV static struct rte_mempool *vector_pool[RTE_MAX_ETHPORTS]; +#endif +static struct rte_mempool *pktmbuf_pool[RTE_MAX_ETHPORTS][NB_SOCKETS]; static uint8_t lkp_per_socket[NB_SOCKETS]; struct l3fwd_lkp_mode { @@ -398,8 +400,10 @@ print_usage(const char *prgname) " [--parse-ptype]" " [--per-port-pool]" " [--mode]" +#ifdef RTE_LIB_EVENTDEV " [--eventq-sched]" " [--event-vector [--event-vector-size SIZE] [--event-vector-tmo NS]]" +#endif " [-E]" " [-L]\n\n" @@ -422,6 +426,7 @@ print_usage(const char *prgname) " --per-port-pool: Use separate buffer pool per port\n" " --mode: Packet transfer mode for I/O, poll or eventdev\n" " Default mode = poll\n" +#ifdef RTE_LIB_EVENTDEV " --eventq-sched: Event queue synchronization method\n" " ordered, atomic or parallel.\n" " Default: atomic\n" @@ -432,6 +437,7 @@ print_usage(const char *prgname) " --event-vector: Enable event vectorization.\n" " --event-vector-size: Max vector size if event vectorization is enabled.\n" " --event-vector-tmo: Max timeout to form vector in nanoseconds if event vectorization is enabled\n" +#endif " -E : Enable exact match, legacy flag please use --lookup=em instead\n" " -L : Enable longest prefix match, legacy flag please use --lookup=lpm instead\n" " --rule_ipv4=FILE: Specify the ipv4 rules entries file.\n" @@ -559,14 +565,16 @@ parse_eth_dest(const char *optarg) } static void -parse_mode(const char *optarg) +parse_mode(const char *optarg __rte_unused) { +#ifdef RTE_LIB_EVENTDEV struct l3fwd_event_resources *evt_rsrc = l3fwd_get_eventdev_rsrc(); if (!strcmp(optarg, "poll")) evt_rsrc->enabled = false; else if (!strcmp(optarg, "eventdev")) evt_rsrc->enabled = true; +#endif } static void @@ -601,6 +609,7 @@ parse_queue_size(const char *queue_size_arg, uint16_t *queue_size, int rx) *queue_size = value; } +#ifdef RTE_LIB_EVENTDEV static void parse_eventq_sched(const char *optarg) { @@ -631,6 +640,7 @@ parse_event_eth_rx_queues(const char *eth_rx_queues) evt_rsrc->eth_rx_queues = num_eth_rx_queues; } +#endif static int parse_lookup(const char *optarg) @@ -756,9 +766,11 @@ parse_args(int argc, char **argv) int option_index; char *prgname = argv[0]; uint8_t lcore_params = 0; +#ifdef RTE_LIB_EVENTDEV uint8_t eventq_sched = 0; uint8_t eth_rx_q = 0; struct l3fwd_event_resources *evt_rsrc = l3fwd_get_eventdev_rsrc(); +#endif argvopt = argv; @@ -850,6 +862,7 @@ parse_args(int argc, char **argv) parse_mode(optarg); break; +#ifdef RTE_LIB_EVENTDEV case CMD_LINE_OPT_EVENTQ_SYNC_NUM: parse_eventq_sched(optarg); eventq_sched = 1; @@ -860,6 +873,20 @@ parse_args(int argc, char **argv) eth_rx_q = 1; break; + case CMD_LINE_OPT_ENABLE_VECTOR_NUM: + printf("event vectorization is enabled\n"); + evt_rsrc->vector_enabled = 1; + break; + + case CMD_LINE_OPT_VECTOR_SIZE_NUM: + evt_rsrc->vector_size = strtol(optarg, NULL, 10); + break; + + case CMD_LINE_OPT_VECTOR_TMO_NS_NUM: + evt_rsrc->vector_tmo_ns = strtoull(optarg, NULL, 10); + break; +#endif + case CMD_LINE_OPT_LOOKUP_NUM: if (lookup_mode != L3FWD_LOOKUP_DEFAULT) { fprintf(stderr, "Only one lookup mode is allowed at a time!\n"); @@ -875,16 +902,6 @@ parse_args(int argc, char **argv) return -1; break; - case CMD_LINE_OPT_ENABLE_VECTOR_NUM: - printf("event vectorization is enabled\n"); - evt_rsrc->vector_enabled = 1; - break; - case CMD_LINE_OPT_VECTOR_SIZE_NUM: - evt_rsrc->vector_size = strtol(optarg, NULL, 10); - break; - case CMD_LINE_OPT_VECTOR_TMO_NS_NUM: - evt_rsrc->vector_tmo_ns = strtoull(optarg, NULL, 10); - break; case CMD_LINE_OPT_RULE_IPV4_NUM: l3fwd_set_rule_ipv4_name(optarg); break; @@ -900,6 +917,8 @@ parse_args(int argc, char **argv) } } + RTE_SET_USED(lcore_params); /* needed if no eventdev block */ +#ifdef RTE_LIB_EVENTDEV if (evt_rsrc->enabled && lcore_params) { fprintf(stderr, "lcore config is not valid when event mode is selected\n"); return -1; @@ -927,6 +946,7 @@ parse_args(int argc, char **argv) "vector timeout set to default (%" PRIu64 " ns)\n", evt_rsrc->vector_tmo_ns); } +#endif /* * Nothing is selected, pick longest-prefix match @@ -962,7 +982,9 @@ print_ethaddr(const char *name, const struct rte_ether_addr *eth_addr) int init_mem(uint16_t portid, unsigned int nb_mbuf) { +#ifdef RTE_LIB_EVENTDEV struct l3fwd_event_resources *evt_rsrc = l3fwd_get_eventdev_rsrc(); +#endif struct lcore_conf *qconf; int socketid; unsigned lcore_id; @@ -1007,6 +1029,7 @@ init_mem(uint16_t portid, unsigned int nb_mbuf) } } +#ifdef RTE_LIB_EVENTDEV if (evt_rsrc->vector_enabled && vector_pool[portid] == NULL) { unsigned int nb_vec; @@ -1025,6 +1048,7 @@ init_mem(uint16_t portid, unsigned int nb_mbuf) printf("Allocated vector pool for port %d\n", portid); } +#endif qconf = &lcore_conf[lcore_id]; qconf->ipv4_lookup_struct = @@ -1406,6 +1430,7 @@ l3fwd_service_enable(uint32_t service_id) return 0; } +#ifdef RTE_LIB_EVENTDEV static void l3fwd_event_service_setup(void) { @@ -1458,16 +1483,20 @@ l3fwd_event_service_setup(void) l3fwd_service_enable(service_id); } } +#endif int main(int argc, char **argv) { +#ifdef RTE_LIB_EVENTDEV struct l3fwd_event_resources *evt_rsrc; + int i; +#endif struct lcore_conf *qconf; uint16_t queueid, portid; unsigned int lcore_id; uint8_t queue; - int i, ret; + int ret; /* init EAL */ ret = rte_eal_init(argc, argv); @@ -1487,7 +1516,9 @@ main(int argc, char **argv) *(uint64_t *)(val_eth + portid) = dest_eth_addr[portid]; } +#ifdef RTE_LIB_EVENTDEV evt_rsrc = l3fwd_get_eventdev_rsrc(); +#endif /* parse application arguments (after the EAL ones) */ ret = parse_args(argc, argv); if (ret < 0) @@ -1499,6 +1530,7 @@ main(int argc, char **argv) /* Add the config file rules */ l3fwd_lkp.read_config_files(); +#ifdef RTE_LIB_EVENTDEV evt_rsrc->per_port_pool = per_port_pool; evt_rsrc->pkt_pool = pktmbuf_pool; evt_rsrc->vec_pool = vector_pool; @@ -1514,6 +1546,7 @@ main(int argc, char **argv) l3fwd_lkp.main_loop = evt_rsrc->ops.lpm_event_loop; l3fwd_event_service_setup(); } else +#endif l3fwd_poll_resource_setup(); /* start ports */ @@ -1562,6 +1595,8 @@ main(int argc, char **argv) ret = 0; /* launch per-lcore init on every lcore */ rte_eal_mp_remote_launch(l3fwd_lkp.main_loop, NULL, CALL_MAIN); + +#ifdef RTE_LIB_EVENTDEV if (evt_rsrc->enabled) { for (i = 0; i < evt_rsrc->rx_adptr.nb_rx_adptr; i++) rte_event_eth_rx_adapter_stop( @@ -1589,7 +1624,9 @@ main(int argc, char **argv) rte_event_dev_stop(evt_rsrc->event_d_id); rte_event_dev_close(evt_rsrc->event_d_id); - } else { + } else +#endif + { rte_eal_mp_wait_lcore(); RTE_ETH_FOREACH_DEV(portid) { diff --git a/examples/l3fwd/meson.build b/examples/l3fwd/meson.build index b40244a941..c25de77bba 100644 --- a/examples/l3fwd/meson.build +++ b/examples/l3fwd/meson.build @@ -7,7 +7,7 @@ # DPDK instance, use 'make' allow_experimental_apis = true -deps += ['acl', 'hash', 'lpm', 'fib', 'eventdev'] +deps += ['acl', 'hash', 'lpm', 'fib'] sources = files( 'l3fwd_acl.c', 'l3fwd_em.c', @@ -18,3 +18,6 @@ sources = files( 'l3fwd_lpm.c', 'main.c', ) +if dpdk_conf.has('RTE_LIB_EVENTDEV') + deps += 'eventdev' +endif -- 2.39.2