From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B41BC28CC6 for ; Mon, 3 Jun 2019 16:57:00 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id E5E23275E9 for ; Mon, 3 Jun 2019 16:56:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="fWzgTbM+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5E23275E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=marvell.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7C30A1BACB; Mon, 3 Jun 2019 18:53:13 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 8FED01BACB for ; Mon, 3 Jun 2019 18:53:12 +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 x53GduWM031506; Mon, 3 Jun 2019 09:53:11 -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=8DFewbAkFwJZ7sKIOtFGZT8Uv+RsZNqSawxyqN/dDEY=; b=fWzgTbM+30lyGgur6/XHZvTrC7jEXEjTNDIvrG/cMO2nnsa/FXQ2gpa0klHkJDJbl0Ur r/pjpjHZ/1paoLzfJfz0F4v6IqCDxAvR3ftnyL0ZTIBxmuei8OmcXkczom9AF7Tf90x3 +avuCEyQxp5OGeZNuVxODNXlRfZZBh2mNq+jxsu18uM87fO/r+R9eVZlzZm8d0Ld7lJ0 IH4AinKtqPBQAiLK0NjLhqcxL5h5UhJ3bFqYnBCrLoZw/WJK4EqNWm1oWMKaRjpXNXD9 7igkLF0kfSX8FWEOlYG9TxkzFUDCGypQ6LPeasQXs+mwfZiiY8btyh6/UsshPofLDzrG JA== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 2sw2wmh7f5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 03 Jun 2019 09:53:11 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 3 Jun 2019 09:53:10 -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 09:53:08 -0700 Received: from ajoseph83.caveonetworks.com.com (unknown [10.29.45.56]) by maili.marvell.com (Postfix) with ESMTP id B520A3F703F; Mon, 3 Jun 2019 09:53:03 -0700 (PDT) From: Anoob Joseph To: Jerin Jacob , Nikhil Rao , "Erik Gabriel Carrillo" , Abhinandan Gujjar , Bruce Richardson , Pablo de Lara CC: Narayana Prasad , , Lukasz Bartosik , Pavan Nikhilesh , "Hemant Agrawal" , Nipun Gupta , "Harry van Haaren" , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , Liang Ma , "Anoob Joseph" Date: Mon, 3 Jun 2019 22:19:43 +0530 Message-ID: <1559580584-5728-39-git-send-email-anoobj@marvell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1559580584-5728-1-git-send-email-anoobj@marvell.com> References: <1559580584-5728-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 38/39] examples/l2fwd-event: add eventmode worker 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" Adding burst no Tx internal-port eventmode worker Signed-off-by: Anoob Joseph Signed-off-by: Lukasz Bartosik --- examples/l2fwd-event/l2fwd_worker.c | 219 +++++++++++++++++++++++++++++++++++- 1 file changed, 218 insertions(+), 1 deletion(-) diff --git a/examples/l2fwd-event/l2fwd_worker.c b/examples/l2fwd-event/l2fwd_worker.c index 0a413a4..251c546 100644 --- a/examples/l2fwd-event/l2fwd_worker.c +++ b/examples/l2fwd-event/l2fwd_worker.c @@ -315,7 +315,7 @@ l2fwd_poll_mode_worker(void) */ /* Workers registered */ -#define L2FWD_EVENTMODE_WORKERS 2 +#define L2FWD_EVENTMODE_WORKERS 3 /* * Event mode worker @@ -639,6 +639,214 @@ l2fwd_eventmode_non_burst_tx_internal_port(void *args) rte_free(links); } +/* + * Event mode worker + * Operating mode : burst no internal port (regular tx worker) + */ +static void +l2fwd_eventmode_burst_no_internal_port(void *args) +{ + struct rte_event ev[MAX_PKT_BURST]; + struct rte_mbuf *pkt; + struct rte_eventmode_helper_conf *mode_conf; + struct rte_eventmode_helper_event_link_info *links = NULL; + unsigned int lcore_nb_link = 0; + uint32_t lcore_id; + unsigned int i, j, left, nb_rx = 0; + unsigned int portid; + struct lcore_queue_conf *qconf; + int is_master_core; + struct rte_event_port_conf event_port_conf; + uint16_t deq_len = 0, enq_len = 0; + uint8_t tx_queue; + struct tsc_tracker tsc = {0}; + + /* Get core ID */ + lcore_id = rte_lcore_id(); + + RTE_LOG(INFO, L2FWD, + "Launching event mode burst worker no internal port " + "(regular tx worker) on lcore %d\n", lcore_id); + + /* Set the flag if master core */ + is_master_core = (lcore_id == rte_get_master_lcore()) ? 1 : 0; + + /* Get qconf for this core */ + 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; + + /* Mode conf will be passed as args */ + mode_conf = (struct rte_eventmode_helper_conf *)args; + + /* Get the links configured for this lcore */ + lcore_nb_link = rte_eventmode_helper_get_event_lcore_links(lcore_id, + mode_conf, &links); + + /* Check if we have links registered for this lcore */ + if (lcore_nb_link == 0) { + /* No links registered. The core could do periodic drains */ + l2fwd_drain_loop(qconf, &tsc, is_master_core); + goto clean_and_exit; + } + + /* We have valid links */ + + /* Reset stats before proceeding */ + reset_eth_stats(is_master_core); + + /* + * There is no internal port between ethdev and eventdev. So the worker + * thread needs to submit event to a designated tx queue. Internally + * eth core would receive events from multiple worker threads and send + * out packets on wire. + */ + tx_queue = rte_eventmode_helper_get_tx_queue(mode_conf, + links[0].eventdev_id); + + /* Get the burst size of the event device */ + + /* Get the default conf of the first link */ + rte_event_port_default_conf_get(links[0].eventdev_id, + links[0].event_portid, + &event_port_conf); + + /* Save the burst size */ + deq_len = event_port_conf.dequeue_depth; + enq_len = event_port_conf.enqueue_depth; + + /* Dequeue and enqueue length should not exceed MAX_PKT_BURST */ + if (deq_len > MAX_PKT_BURST) + deq_len = MAX_PKT_BURST; + if (enq_len > MAX_PKT_BURST) + enq_len = MAX_PKT_BURST; + + /* See if it's single link */ + if (lcore_nb_link == 1) + goto single_link_loop; + else + goto multi_link_loop; + +single_link_loop: + + RTE_LOG(INFO, L2FWD, " -- lcoreid=%u event_port_id=%u\n", lcore_id, + links[0].event_portid); + + while (!force_quit) { + + /* Do periodic operations (buffer drain & stats monitor) */ + l2fwd_periodic_drain_stats_monitor(qconf, &tsc, is_master_core); + + /* Read packet from event queues */ + nb_rx = rte_event_dequeue_burst(links[0].eventdev_id, + links[0].event_portid, + ev, /* events */ + deq_len, /* nb_events */ + 0 /* timeout_ticks */); + + if (nb_rx == 0) + continue; + + for (j = 0; j < nb_rx; j++) { + + portid = ev[j].queue_id; + port_statistics[portid].rx++; + pkt = ev[j].mbuf; + + rte_prefetch0(rte_pktmbuf_mtod(pkt, void *)); + + /* Process packet */ + l2fwd_event_pre_forward(&(ev[j]), portid); + + /* + * Internal port is not available, the packet needs + * to be enqueued to the designated event queue. + */ + + /* Prepare event for submission to tx event queue */ + l2fwd_event_switch_to_tx_queue(&(ev[j]), tx_queue); + } + + for (j = 0, left = nb_rx; + j < (nb_rx + enq_len - 1)/enq_len; j++) { + + /* Submit the updated events for tx stage */ + left -= rte_event_enqueue_burst(links[0].eventdev_id, + links[0].event_portid, + &(ev[j*enq_len]), /* events */ + left > enq_len ? + enq_len : left /* nb_events */); + } + } + goto clean_and_exit; + +multi_link_loop: + + for (i = 0; i < lcore_nb_link; i++) { + RTE_LOG(INFO, L2FWD, " -- lcoreid=%u event_port_id=%u\n", + lcore_id, links[i].event_portid); + } + + while (!force_quit) { + + /* Do periodic operations (buffer drain & stats monitor) */ + l2fwd_periodic_drain_stats_monitor(qconf, &tsc, is_master_core); + + for (i = 0; i < lcore_nb_link; i++) { + /* Read packet from event queues */ + nb_rx = rte_event_dequeue_burst(links[i].eventdev_id, + links[i].event_portid, + ev, /* events */ + deq_len, /* nb_events */ + 0 /* timeout_ticks */); + + if (nb_rx == 0) + continue; + + for (j = 0; j < nb_rx; j++) { + + portid = ev[j].queue_id; + port_statistics[portid].rx++; + pkt = ev[j].mbuf; + + rte_prefetch0(rte_pktmbuf_mtod(pkt, void *)); + + /* Process packet */ + l2fwd_event_pre_forward(&(ev[j]), portid); + + /* + * Internal port is not available, the packet + * needs to be enqueued to the designated event + * queue. + */ + + /* Update the scheduling type for tx stage */ + l2fwd_event_switch_to_tx_queue(&(ev[j]), + tx_queue); + } + + for (j = 0, left = nb_rx; + j < (nb_rx + enq_len - 1)/enq_len; j++) { + + /* Submit the updated events for tx stage */ + left -= rte_event_enqueue_burst( + links[i].eventdev_id, + links[i].event_portid, + &(ev[j*enq_len]), /* events */ + left > enq_len ? + enq_len : left /* nb_events */); + } + } + } + goto clean_and_exit; + +clean_and_exit: + if (links != NULL) + rte_free(links); +} + static uint8_t l2fwd_eventmode_populate_wrkr_params( struct rte_eventmode_helper_app_worker_params *wrkrs) @@ -665,6 +873,15 @@ l2fwd_eventmode_populate_wrkr_params( wrkr->worker_thread = l2fwd_eventmode_non_burst_tx_internal_port; nb_wrkr_param++; + wrkr++; + + /* Burst no internal port (regular tx worker) */ + wrkr->cap.burst = RTE_EVENTMODE_HELPER_RX_TYPE_BURST; + wrkr->cap.tx_internal_port = + RTE_EVENTMODE_HELPER_TX_TYPE_NO_INTERNAL_PORT; + wrkr->worker_thread = l2fwd_eventmode_burst_no_internal_port; + + nb_wrkr_param++; return nb_wrkr_param; } -- 2.7.4