From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 6D787A0096 for ; Mon, 3 Jun 2019 19:34:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 167491B9BE; Mon, 3 Jun 2019 19:33:47 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id A0CE31B9BD for ; Mon, 3 Jun 2019 19:33:44 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x53HKPJK027530; Mon, 3 Jun 2019 10:33:44 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=wwTb6fguiNnMXthKP4P2ohLTwiDu3A9UweX40DJkVZQ=; b=lgiGXatKLEWWUNTUo/bgs5Fs1WN9xv3smXocsB65aPjkgReIai34Ss2XgxMPbOm5tBq+ ipuTqiZs//6BBG5H2FiIQjLFRgyyXYsj2EVMTtHtugQKXgPosNJi8N/kEM8UBLX76A11 Vfj+1SOHbz/MQkmvN91YOGdTxlhvjhhNxFRYeA1Sy2xZnr1OvydJNueAasr1EEzGjYvh s70R/khh+Qwc9t5rp7Scp5pxlFt1NQq604d+E359VouSQ1WUtgH55LYjFPHUhmlnfcko is0uDxweVyVeUV6vNpmrjyxv+XOktZ8VDbvM431V+i7a7kZ0mbYTreQTihgyQ/M433x6 Kg== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2sw79pr6pf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 03 Jun 2019 10:33:44 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 3 Jun 2019 10:33:42 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 3 Jun 2019 10:33:42 -0700 Received: from ajoseph83.caveonetworks.com.com (unknown [10.29.45.56]) by maili.marvell.com (Postfix) with ESMTP id EDAEA3F703F; Mon, 3 Jun 2019 10:33:37 -0700 (PDT) From: Anoob Joseph To: Jerin Jacob , Nikhil Rao , "Erik Gabriel Carrillo" , Abhinandan Gujjar , Bruce Richardson , Pablo de Lara CC: Anoob Joseph , Narayana Prasad , , Lukasz Bartosik , Pavan Nikhilesh , Hemant Agrawal , "Nipun Gupta" , Harry van Haaren , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , Liang Ma Date: Mon, 3 Jun 2019 23:02:04 +0530 Message-ID: <1559583160-13944-5-git-send-email-anoobj@marvell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1559583160-13944-1-git-send-email-anoobj@marvell.com> References: <1559583160-13944-1-git-send-email-anoobj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-06-03_13:, , signatures=0 Subject: [dpdk-dev] [PATCH 04/39] examples/l2fwd-event: move global vars to common header X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Moving global variables to common header for access from control plane and data plane code. Signed-off-by: Anoob Joseph Signed-off-by: Lukasz Bartosik --- examples/l2fwd-event/l2fwd_common.h | 26 +++++++++++++++++++++++ examples/l2fwd-event/main.c | 41 +++++++++++++++---------------------- 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/examples/l2fwd-event/l2fwd_common.h b/examples/l2fwd-event/l2fwd_common.h index a7bb5af..55226f7 100644 --- a/examples/l2fwd-event/l2fwd_common.h +++ b/examples/l2fwd-event/l2fwd_common.h @@ -5,6 +5,10 @@ #ifndef _L2FWD_COMMON_H_ #define _L2FWD_COMMON_H_ +#include + +#include + #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 #define MAX_PKT_BURST 32 @@ -34,4 +38,26 @@ struct l2fwd_port_statistics { uint64_t dropped; } __rte_cache_aligned; +volatile bool force_quit; + +int mac_updating; + +/* ethernet addresses of ports */ +static struct rte_ether_addr l2fwd_ports_eth_addr[RTE_MAX_ETHPORTS]; + +/* mask of enabled ports */ +static uint32_t l2fwd_enabled_port_mask; + +/* list of enabled ports */ +static uint32_t l2fwd_dst_ports[RTE_MAX_ETHPORTS]; + +struct lcore_queue_conf lcore_queue_conf[RTE_MAX_LCORE]; + +struct rte_eth_dev_tx_buffer *tx_buffer[RTE_MAX_ETHPORTS]; + +struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS]; + +/* A tsc-based timer responsible for triggering statistics printout */ +uint64_t timer_period; + #endif /* _L2FWD_COMMON_H_ */ diff --git a/examples/l2fwd-event/main.c b/examples/l2fwd-event/main.c index 1551c7f..67f2bb0 100644 --- a/examples/l2fwd-event/main.c +++ b/examples/l2fwd-event/main.c @@ -42,29 +42,11 @@ #include "l2fwd_common.h" -static volatile bool force_quit; - -/* MAC updating enabled by default */ -static int mac_updating = 1; - static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT; static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT; -/* ethernet addresses of ports */ -static struct rte_ether_addr l2fwd_ports_eth_addr[RTE_MAX_ETHPORTS]; - -/* mask of enabled ports */ -static uint32_t l2fwd_enabled_port_mask; - -/* list of enabled ports */ -static uint32_t l2fwd_dst_ports[RTE_MAX_ETHPORTS]; - static unsigned int l2fwd_rx_queue_per_lcore = 1; -struct lcore_queue_conf lcore_queue_conf[RTE_MAX_LCORE]; - -static struct rte_eth_dev_tx_buffer *tx_buffer[RTE_MAX_ETHPORTS]; - static struct rte_eth_conf port_conf = { .rxmode = { .split_hdr_size = 0, @@ -76,11 +58,6 @@ static struct rte_eth_conf port_conf = { struct rte_mempool *l2fwd_pktmbuf_pool; -struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS]; - -/* A tsc-based timer responsible for triggering statistics printout */ -static uint64_t timer_period = 10; /* default period is 10 seconds */ - /* Print out statistics on packets dropped */ static void print_stats(void) @@ -492,6 +469,20 @@ signal_handler(int signum) } } +static void +l2fwd_init_global_vars(void) +{ + force_quit = false; + + /* MAC updating enabled by default */ + mac_updating = 1; + + /* Default period is 10 seconds */ + timer_period = 10; + + l2fwd_enabled_port_mask = 0; +} + int main(int argc, char **argv) { @@ -505,6 +496,9 @@ main(int argc, char **argv) unsigned int nb_lcores = 0; unsigned int nb_mbufs; + /* Set default values for global vars */ + l2fwd_init_global_vars(); + /* init EAL */ ret = rte_eal_init(argc, argv); if (ret < 0) @@ -512,7 +506,6 @@ main(int argc, char **argv) argc -= ret; argv += ret; - force_quit = false; signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); -- 2.7.4