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 AAEFFA0096 for ; Mon, 3 Jun 2019 19:41:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D9EA51BBD7; Mon, 3 Jun 2019 19:40:41 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 6AFC11BBD7 for ; Mon, 3 Jun 2019 19:40:40 +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 x53HeSZg018053; Mon, 3 Jun 2019 10:40:39 -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=FTKhJ8LpZafttqn4f+QdWdtb9QElhc8MKv3Zh5BDGo8=; b=bPKxglK9cF/82niNDQsffZfhj/5p48o4SZmPtDmSHIcGH05eO+kcEvV9mjnDIhSwlXVz hUZugpYWYxxTS0QMh5uZFHfg/ekWzAqsG4h2Uop1e/KpuCfO09Wj9Aud7r5wcGw6QRON taNQEjrjpLOXbknCLQfc1Fbsx4FHStMD3xHrqqyzx8loBx+QpHEa2GVJ4GbBHXMEgk+A INhh6lJeTSzRYh94M0Q/ofvHxbKX9alFzeoH6g+32cmV6kJPCPUsnneoAHbtTZmNhIyr 47gA7RXgu+vQDxH//poQ52P4LFd2tE8iRvfdWWFjjR+1Semfv0fRVsN23+HFNXiWVp2J XQ== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 2sw2wmheuv-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 03 Jun 2019 10:40:39 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 3 Jun 2019 10:37:19 -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:37:19 -0700 Received: from ajoseph83.caveonetworks.com.com (unknown [10.29.45.56]) by maili.marvell.com (Postfix) with ESMTP id 56EC03F7043; Mon, 3 Jun 2019 10:37:14 -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:39 +0530 Message-ID: <1559583160-13944-40-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_14:, , signatures=0 Subject: [dpdk-dev] [PATCH 39/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 Tx internal port eventmode worker. Signed-off-by: Anoob Joseph Signed-off-by: Lukasz Bartosik --- examples/l2fwd-event/l2fwd_worker.c | 200 +++++++++++++++++++++++++++++++++++- 1 file changed, 199 insertions(+), 1 deletion(-) diff --git a/examples/l2fwd-event/l2fwd_worker.c b/examples/l2fwd-event/l2fwd_worker.c index 251c546..1e38210 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 3 +#define L2FWD_EVENTMODE_WORKERS 4 /* * Event mode worker @@ -847,6 +847,195 @@ l2fwd_eventmode_burst_no_internal_port(void *args) rte_free(links); } +/* + * Event mode worker + * Operating mode : burst tx internal port + */ +static void +l2fwd_eventmode_burst_tx_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; + struct tsc_tracker tsc = {0}; + + /* Get core ID */ + lcore_id = rte_lcore_id(); + + RTE_LOG(INFO, L2FWD, + "Launching event mode burst worker internal port " + "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); + + /* 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); + } + + /* + * Since tx internal port is available, events can be + * directly enqueued to the adapter and it would be + * internally submitted to the eth device. + */ + for (j = 0, left = nb_rx; + j < (nb_rx + enq_len - 1)/enq_len; j++) { + + left -= rte_event_eth_tx_adapter_enqueue( + 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); + } + + /* + * Since tx internal port is available, events can be + * directly enqueued to the adapter and it would be + * internally submitted to the eth device. + */ + for (j = 0, left = nb_rx; + j < (nb_rx + enq_len - 1)/enq_len; j++) { + + left -= rte_event_eth_tx_adapter_enqueue( + 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) @@ -882,6 +1071,15 @@ l2fwd_eventmode_populate_wrkr_params( wrkr->worker_thread = l2fwd_eventmode_burst_no_internal_port; nb_wrkr_param++; + wrkr++; + + /* Burst tx internal port */ + wrkr->cap.burst = RTE_EVENTMODE_HELPER_RX_TYPE_BURST; + wrkr->cap.tx_internal_port = + RTE_EVENTMODE_HELPER_TX_TYPE_INTERNAL_PORT; + wrkr->worker_thread = l2fwd_eventmode_burst_tx_internal_port; + + nb_wrkr_param++; return nb_wrkr_param; } -- 2.7.4