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 E5076A0096 for ; Mon, 3 Jun 2019 19:34:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2FCFF1B9EC; Mon, 3 Jun 2019 19:34:18 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 394B81B9EC for ; Mon, 3 Jun 2019 19:34:17 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x53HKlmv000910; Mon, 3 Jun 2019 10:34:16 -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=pLMv4sw5YaDUqJ83VNU1HniFLIVKVZxpUPFP8V2jVYU=; b=hycwYvJCmJZfajAzj7YXCrB2PSSm5iM8wa5V6o9DzaX86S/9XAn8F9K0D/AbnFAcJuz+ mDmiz8QMzyKio2eXnMF5FU3zg2kXRH5X478nxrMaz5FQ7JBaoLxIGpe3UGqYdHooARmg 98Du//W1oNdcEgULdHaxV4eDnRTTpmtLdou27B7LIb3taoFdJLszNShWE7D5jGweDuOr NBqpO+mpfulYdjY1UAf8R7vOun2xhXej6t946p5ETFuv8pmyK6E5UAlbeRNJNHgpymXp pqG8f9X3Ww50qjCP+qaxU/zJspT5vr0Y0reQz0wbpTdjZZpPZdsZ7W9w7wXinnHIbCuP 8g== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 2sw2wmhdch-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 03 Jun 2019 10:34:16 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 3 Jun 2019 10:34:15 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 3 Jun 2019 10:34:13 -0700 Received: from ajoseph83.caveonetworks.com.com (unknown [10.29.45.56]) by maili.marvell.com (Postfix) with ESMTP id 97E0F3F703F; Mon, 3 Jun 2019 10:34:08 -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:09 +0530 Message-ID: <1559583160-13944-10-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 09/39] examples/l2fwd-event: move periodic tasks to new func 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" Move the periodic operations (stats flush and drain buffers) to a new function. Signed-off-by: Anoob Joseph Signed-off-by: Lukasz Bartosik --- examples/l2fwd-event/l2fwd_worker.c | 83 ++++++++++++++++++++----------------- examples/l2fwd-event/l2fwd_worker.h | 6 +++ 2 files changed, 52 insertions(+), 37 deletions(-) diff --git a/examples/l2fwd-event/l2fwd_worker.c b/examples/l2fwd-event/l2fwd_worker.c index 86bdd40..49bbdb6 100644 --- a/examples/l2fwd-event/l2fwd_worker.c +++ b/examples/l2fwd-event/l2fwd_worker.c @@ -94,6 +94,45 @@ l2fwd_drain_buffers(struct lcore_queue_conf *qconf) } } +static inline void +l2fwd_periodic_drain_stats_monitor(struct lcore_queue_conf *qconf, + struct tsc_tracker *t, int is_master_core) +{ + uint64_t diff_tsc, cur_tsc; + + cur_tsc = rte_rdtsc(); + + /* + * TX burst queue drain + */ + diff_tsc = cur_tsc - t->prev_tsc; + if (unlikely(diff_tsc > t->drain_tsc)) { + + /* Drain buffers */ + l2fwd_drain_buffers(qconf); + + /* if timer is enabled */ + if (timer_period > 0) { + + /* advance the timer */ + t->timer_tsc += diff_tsc; + + /* if timer has reached its timeout */ + if (unlikely(t->timer_tsc >= timer_period)) { + + /* do this only on master core */ + if (is_master_core) { + print_stats(); + /* reset the timer */ + t->timer_tsc = 0; + } + } + } + + t->prev_tsc = cur_tsc; + } +} + static void l2fwd_mac_updating(struct rte_mbuf *m, unsigned int dest_portid) { @@ -135,19 +174,18 @@ l2fwd_main_loop(void) struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; struct rte_mbuf *m; unsigned int lcore_id; - uint64_t prev_tsc, diff_tsc, cur_tsc, timer_tsc; unsigned int i, j, portid, nb_rx; struct lcore_queue_conf *qconf; - const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) - / US_PER_S * BURST_TX_DRAIN_US; int is_master_core; - - prev_tsc = 0; - timer_tsc = 0; + struct tsc_tracker tsc = {0}; lcore_id = rte_lcore_id(); qconf = &lcore_queue_conf[lcore_id]; + /* Set drain tsc */ + tsc.drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) / + US_PER_S * BURST_TX_DRAIN_US; + if (qconf->n_rx_port == 0) { RTE_LOG(INFO, L2FWD, "lcore %u has nothing to do\n", lcore_id); return; @@ -168,37 +206,8 @@ l2fwd_main_loop(void) while (!force_quit) { - cur_tsc = rte_rdtsc(); - - /* - * TX burst queue drain - */ - diff_tsc = cur_tsc - prev_tsc; - if (unlikely(diff_tsc > drain_tsc)) { - - /* Drain buffers */ - l2fwd_drain_buffers(qconf); - - /* if timer is enabled */ - if (timer_period > 0) { - - /* advance the timer */ - timer_tsc += diff_tsc; - - /* if timer has reached its timeout */ - if (unlikely(timer_tsc >= timer_period)) { - - /* do this only on master core */ - if (is_master_core) { - print_stats(); - /* reset the timer */ - timer_tsc = 0; - } - } - } - - prev_tsc = cur_tsc; - } + /* Do periodic operations (buffer drain & stats monitor) */ + l2fwd_periodic_drain_stats_monitor(qconf, &tsc, is_master_core); /* * Read packet from RX queues diff --git a/examples/l2fwd-event/l2fwd_worker.h b/examples/l2fwd-event/l2fwd_worker.h index dc4da5b..22d7c5c 100644 --- a/examples/l2fwd-event/l2fwd_worker.h +++ b/examples/l2fwd-event/l2fwd_worker.h @@ -4,6 +4,12 @@ #ifndef _L2FWD_WORKER_H_ #define _L2FWD_WORKER_H_ +struct tsc_tracker { + uint64_t prev_tsc; + uint64_t timer_tsc; + uint64_t drain_tsc; +}; + int l2fwd_launch_one_lcore(__attribute__((unused)) void *dummy); -- 2.7.4