From patchwork Fri Sep 16 07:13:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Elo, Matias \(Nokia - FI/Espoo\)" X-Patchwork-Id: 76358 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp347568qgf; Fri, 16 Sep 2016 00:16:21 -0700 (PDT) X-Received: by 10.200.40.36 with SMTP id 33mr14131502qtq.53.1474010181465; Fri, 16 Sep 2016 00:16:21 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id r12si3779520qke.16.2016.09.16.00.16.20; Fri, 16 Sep 2016 00:16:21 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE dis=NONE) header.from=nokia.com Received: by lists.linaro.org (Postfix, from userid 109) id D8D9D60C9B; Fri, 16 Sep 2016 07:16:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 997AE60D33; Fri, 16 Sep 2016 07:14:40 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id E079960C75; Fri, 16 Sep 2016 07:14:30 +0000 (UTC) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0092.outbound.protection.outlook.com [104.47.1.92]) by lists.linaro.org (Postfix) with ESMTPS id E693D60CFD for ; Fri, 16 Sep 2016 07:13:56 +0000 (UTC) Received: from VI1PR07CA0078.eurprd07.prod.outlook.com (10.164.94.174) by HE1PR0701MB1993.eurprd07.prod.outlook.com (10.167.189.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.8; Fri, 16 Sep 2016 07:13:54 +0000 Received: from AM1FFO11FD053.protection.gbl (2a01:111:f400:7e00::159) by VI1PR07CA0078.outlook.office365.com (2a01:111:e400:5967::46) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.629.8 via Frontend Transport; Fri, 16 Sep 2016 07:13:55 +0000 Received-SPF: Pass (protection.outlook.com: domain of nokia.com designates 131.228.2.240 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.2.240; helo=fihe3nok0734.emea.nsn-net.net; Received: from fihe3nok0734.emea.nsn-net.net (131.228.2.240) by AM1FFO11FD053.mail.protection.outlook.com (10.174.65.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.619.6 via Frontend Transport; Fri, 16 Sep 2016 07:13:54 +0000 Received: from fihe3nok0734.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0734.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u8G7DXEU017488 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 16 Sep 2016 10:13:33 +0300 Received: from 10.144.19.15 ([10.144.104.92]) by fihe3nok0734.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u8G7DXpq017473 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Fri, 16 Sep 2016 10:13:33 +0300 X-HPESVCS-Source-Ip: 10.144.104.92 From: Matias Elo To: Date: Fri, 16 Sep 2016 10:13:29 +0300 Message-ID: <1474010009-7435-5-git-send-email-matias.elo@nokia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474010009-7435-1-git-send-email-matias.elo@nokia.com> References: <1474010009-7435-1-git-send-email-matias.elo@nokia.com> X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:131.228.2.240; IPV:NLI; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(7916002)(2980300002)(438002)(189002)(199003)(229853001)(2950100001)(450100001)(36756003)(586003)(87936001)(7846002)(305945005)(106466001)(50226002)(356003)(47776003)(5003940100001)(5660300001)(19580405001)(2906002)(16796002)(68736007)(97736004)(33646002)(76176999)(50986999)(2351001)(19580395003)(626004)(8936002)(11100500001)(81166006)(8676002)(110136003)(189998001)(107886002)(48376002)(50466002)(77096005)(81156014)(92566002)(32563001)(42882005); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0701MB1993; H:fihe3nok0734.emea.nsn-net.net; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11FD053; 1:TY1lt4q2expU8UMftTltHcCIPX9HmGG71YoAG6nOzx1IecNQolZW3FOl2bM6oad9wvyWsOxUrZD6gGaM+cwZQ2ZxAyeh7cdjejCUOQJ6OZtvzfg7VLwkqo86I2PTc2a6Mjv3BHuSyhd2qYfslXPAUYNSxvQPRnpghNBRaIHAXgG0Lvxck4FZT8mWA0GIf+RFkcP79KrB6yNDcNTn3uOmgq3j7dYOiH7DxeTNV6WJnDImH5aCXafV1ODam4CPhZaCQZ5jjsCOmhf09k4wMb0FKGDm+Zjr6pnukpFu+sDfhVSYGB1MBcF2i0LvNiVx0FsvI0yKMXSzL6RF8dknSZUdDjFzw2pWydTf+xLMvQRURwcK2mTQHb4XXtnQMzZT5sMmMn6oUZlni+l4cVrdGq4haUTRjuRhugfrBONCKZk5aztIyDjiUXMl3mUtk8W/f+6F2fFwqPvxk5CcO6XreNncaptJAEytF1ef9Jg/YF5AE+s= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: edc9dd4c-0d85-4119-2a77-08d3de0104e2 X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB1993; 2:yJiLnRzaSQFlEl/+C3AGsGQtDNnPen+6iUW/mHixlgahwijQD8G/f/WpGzecuvbHWBrk5FIaOAmBSWWyqFYeoc1ya0Zdebt0T0Ycs7Hw1e1kmQ6MsYdJ8ZoayA4z3N9x2XGEy27a6omGYhvxOW+iznPH0GDH0ZRkVtLP9Mfjcfm3ifbyuv3KZ4wubDBq6nSD; 3:U8zkjZPh6TMDCjmFU1nrQsQ1/HwjjcZOV1ZUCD4yz82gAMSWaj2hOUfxOcYgKPwkz9S9wjBLIAdmN7fjdb9OrhkPABszK2YhxohC+3/kpsN1X1wmcK2TfuZZrq+o6fT37HzC8QmdSSyNv7nMF3Brj6CJ88vFr9yo46B1QE18cedp6WWfxJmxi1Bui9zVpgwaAIw2zJUQwOjn+GQ1wJtcTX2219pVhmsFPqBaLsWb/52Fq0xSt8cu12594gL5/FXRebdWf2KnEriZRVRpeDm9eQ== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:HE1PR0701MB1993; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB1993; 25:YX3eVA/SGu5qy1ung+Dbw5IJjcMeM6QTlZkSOEoncOz7G0SnB9QL54UJdJ8W6/2mXIamy/Iry0dnbEAZkOa6F2/ulINMrv/nAZi11zdIu42eMj2Krc+GZhRRTRvGhOKNCkIs63fdggalb3OT/bOvbTI/1hvw+PZJZJwciPwKdUE54fvH+bJ965zJOH93wK2XT+Hi45yOvMuNa2WCXwzRiQ9ya+XlNKnvGVDGDoQCvuuySXuO4i6MttmXZuWG4jagmbufOr++0+74Lbhec4bLOnzZ6N7lTmBnNtig/i0fCXAoN0Q4MyC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qzqW1Bzk3cvpvbHpZhG8pY2th/2Y7ulXt0yRms+bZuazIt67T/WSkCGA8OfMbns3H2NtnVQu3ZWExadwTL01o6EEkusTGwNueq9XNRFLw1a8TyTfAZJWs1uiUXI4ItNztyrZBPW6fNU77EyJOLXVIEFkONBWj1OkjYgYLWlK95atmwAm/nx6QPkZOeOXx29tikC/oG1Tzh/0msrU8F/CnYE7UK1F7po7kvV3kZ82r0oQ8bgHZEn7JxLPiCDqgPurrp6isJKKy2tn7YG117fp3JvI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(82608151540597); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(13016025)(13018025)(3002001)(10201501046)(6055026); SRVR:HE1PR0701MB1993; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0701MB1993; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB1993; 4:jGuiasf8HQABFZD4aOOptXg0mIcsQVy+esGKqktoo/imlAxzQB+OH3rczJ5NAKtCylmRDDuxZGISI7jBXI/Yu4MQNOfKuI6P8srHrOLnt8fqVKLAaS/Kw4defDfVNK4FRdBduQxbwjUKEB+8hGoqCkeHGMQ2Cdecvn6BQraPY/qBmsJ7+TwajvASMbYtQG+Sp0H1m/4zDww1NE3eym4Y3HzDxN/4qMlh7j+qyoFCtklta+FlhkRoQ5TiMUu3Z128joKW9Wj+WWmTeH/cMM41aDzYRioVRdkhgLF1UqTevMuUuomGMqVC1jOBgGwdEEw3M6EafaS0sk3gcDFPWNExGKemmE7Vmh2WYDD4YT0zOlGO1hszQOGyDRW/W8G1Db0u9OXFuitDzs1e+zQgeiIzT2VIoPi8+UIAZVwPZ64cHHl/Vl0qxo7HRuBm5GxW19HZy3lZQ6tTIl9KAxyeiWhxhvEViI26PSHM6kTWLA4wcNE= X-Forefront-PRVS: 0067A8BA2A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0701MB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3kXtuUrK41fToQsGUnZJvwsb50qTb36LLMgPCeLrOw0QbBbthdT1FfEJdv9ue1yC63oQKqZiDldjMM31lT9OmhMYknLl2uiiY9BkhH48yP/m46d8pRWANp2uSNp/5mVhxGQ9qMTOgu9QfvW4IIOUVi0o0XODLnJpye+wpRA9siEtTI9k3 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2016 07:13:54.6232 (UTC) X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.240]; Helo=[fihe3nok0734.emea.nsn-net.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0701MB1993 X-Topics: patch Subject: [lng-odp] [PATCH v2 5/5] example: l3fwd: simplify worker main loop X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Reduce extra code in the fast path. Signed-off-by: Matias Elo --- example/l3fwd/odp_l3fwd.c | 154 +++++++++++++++++++++++++++------------------- 1 file changed, 89 insertions(+), 65 deletions(-) -- 2.7.4 diff --git a/example/l3fwd/odp_l3fwd.c b/example/l3fwd/odp_l3fwd.c index 9e29e1b..5539711 100644 --- a/example/l3fwd/odp_l3fwd.c +++ b/example/l3fwd/odp_l3fwd.c @@ -62,6 +62,7 @@ struct thread_arg_s { uint64_t rx_drops; uint64_t tx_drops; struct { + int if_idx; /* interface index */ int nb_rxq; /* number of rxq this thread will access */ int rxq[MAX_NB_QUEUE]; /* rxq[i] is index in pktio.ifin[] */ int txq_idx; /* index in pktio.ifout[] */ @@ -175,7 +176,7 @@ static inline void ipv4_dec_ttl_csum_update(odph_ipv4hdr_t *ip) ip->chksum += odp_cpu_to_be_16(1 << 8); } -static int l3fwd_pkt_hash(odp_packet_t pkt, int sif) +static inline int l3fwd_pkt_hash(odp_packet_t pkt, int sif) { fwd_db_entry_t *entry; ipv4_tuple5_t key; @@ -217,7 +218,7 @@ static int l3fwd_pkt_hash(odp_packet_t pkt, int sif) return dif; } -static int l3fwd_pkt_lpm(odp_packet_t pkt, int sif) +static inline int l3fwd_pkt_lpm(odp_packet_t pkt, int sif) { odph_ipv4hdr_t *ip; odph_ethhdr_t *eth; @@ -275,75 +276,83 @@ static inline int drop_err_pkts(odp_packet_t pkt_tbl[], unsigned num) return dropped; } -static void l3fwd_one_queue(uint32_t sif, int rxq_idx, void *thr_arg) +static int run_worker(void *arg) { - odp_packet_t *tbl; - odp_pktout_queue_t outq; + int if_idx; + struct thread_arg_s *thr_arg = arg; odp_pktin_queue_t inq; + int input_ifs[thr_arg->nb_pktio]; + odp_pktin_queue_t input_queues[thr_arg->nb_pktio]; + odp_pktout_queue_t output_queues[global.cmd_args.if_count]; odp_packet_t pkt_tbl[MAX_PKT_BURST]; - struct thread_arg_s *arg; + odp_packet_t *tbl; int pkts, drop, sent; int dst_port, dif; - int i; + int i, j; + int pktio = 0; + int num_pktio = 0; - arg = thr_arg; - inq = global.l3fwd_pktios[sif].ifin[rxq_idx]; - pkts = odp_pktin_recv(inq, pkt_tbl, MAX_PKT_BURST); - if (pkts <= 0) - return; + /* Copy all required handles to local memory */ + for (i = 0; i < global.cmd_args.if_count; i++) { + int txq_idx = thr_arg->pktio[i].txq_idx; - arg->packets += pkts; - drop = drop_err_pkts(pkt_tbl, pkts); - pkts -= drop; - arg->rx_drops += drop; + output_queues[i] = global.l3fwd_pktios[i].ifout[txq_idx]; - dif = global.fwd_func(pkt_tbl[0], sif); - tbl = &pkt_tbl[0]; - while (pkts) { - int txq_idx; + if_idx = thr_arg->pktio[i].if_idx; + for (j = 0; j < thr_arg->pktio[i].nb_rxq; j++) { + int rxq_idx = thr_arg->pktio[i].rxq[j]; - dst_port = dif; - for (i = 1; i < pkts; i++) { - dif = global.fwd_func(tbl[i], sif); - if (dif != dst_port) - break; + inq = global.l3fwd_pktios[if_idx].ifin[rxq_idx]; + input_ifs[num_pktio] = if_idx; + input_queues[num_pktio] = inq; + num_pktio++; } - - txq_idx = arg->pktio[dst_port].txq_idx; - outq = global.l3fwd_pktios[dst_port].ifout[txq_idx]; - sent = odp_pktout_send(outq, tbl, i); - if (odp_unlikely(sent < i)) { - sent = sent < 0 ? 0 : sent; - odp_packet_free_multi(&tbl[sent], i - sent); - arg->tx_drops += i - sent; - } - - if (i < pkts) - tbl += i; - - pkts -= i; } -} -static int run_worker(void *arg) -{ - int if_idx, rxq, nb_rxq; - struct thread_arg_s *thr_arg = arg; + num_pktio = thr_arg->nb_pktio; + if_idx = input_ifs[pktio]; + inq = input_queues[pktio]; odp_barrier_wait(&barrier); while (!exit_threads) { - for (if_idx = 0; if_idx < thr_arg->nb_pktio; if_idx++) { - nb_rxq = thr_arg->pktio[if_idx].nb_rxq; - if (!nb_rxq || thr_arg->thr_idx == INVALID_ID) - continue; + if (num_pktio > 1) { + if_idx = input_ifs[pktio]; + inq = input_queues[pktio]; + pktio++; + if (pktio == num_pktio) + pktio = 0; + } - for (rxq = 0; rxq < nb_rxq; rxq++) { - int rxq_idx; + pkts = odp_pktin_recv(inq, pkt_tbl, MAX_PKT_BURST); + if (pkts <= 0) + continue; - rxq_idx = thr_arg->pktio[if_idx].rxq[rxq]; - l3fwd_one_queue(if_idx, rxq_idx, arg); + thr_arg->packets += pkts; + drop = drop_err_pkts(pkt_tbl, pkts); + pkts -= drop; + thr_arg->rx_drops += drop; + + dif = global.fwd_func(pkt_tbl[0], if_idx); + tbl = &pkt_tbl[0]; + while (pkts) { + dst_port = dif; + for (i = 1; i < pkts; i++) { + dif = global.fwd_func(tbl[i], if_idx); + if (dif != dst_port) + break; + } + sent = odp_pktout_send(output_queues[dst_port], tbl, i); + if (odp_unlikely(sent < i)) { + sent = sent < 0 ? 0 : sent; + odp_packet_free_multi(&tbl[sent], i - sent); + thr_arg->tx_drops += i - sent; } + + if (i < pkts) + tbl += i; + + pkts -= i; } } @@ -675,7 +684,7 @@ static void print_info(char *progname, app_args_t *args) */ static void setup_worker_qconf(app_args_t *args) { - int nb_worker, if_count; + int nb_worker, if_count, pktio; int i, j, rxq_idx; struct thread_arg_s *arg; struct l3fwd_pktio_s *port; @@ -692,10 +701,11 @@ static void setup_worker_qconf(app_args_t *args) arg->thr_idx = i; j = i % if_count; port = &global.l3fwd_pktios[j]; - rxq_idx = arg->pktio[j].nb_rxq; - arg->pktio[j].rxq[rxq_idx] = + arg->pktio[0].rxq[0] = port->rxq_idx % port->nb_rxq; - arg->pktio[j].nb_rxq++; + arg->pktio[0].nb_rxq = 1; + arg->pktio[0].if_idx = j; + arg->nb_pktio = 1; port->rxq_idx++; } } else { @@ -705,9 +715,12 @@ static void setup_worker_qconf(app_args_t *args) arg->thr_idx = j; port = &global.l3fwd_pktios[i]; rxq_idx = arg->pktio[i].nb_rxq; - arg->pktio[i].rxq[rxq_idx] = + pktio = arg->nb_pktio; + arg->pktio[pktio].rxq[rxq_idx] = port->rxq_idx % port->nb_rxq; - arg->pktio[i].nb_rxq++; + arg->pktio[pktio].nb_rxq++; + arg->pktio[pktio].if_idx = i; + arg->nb_pktio++; port->rxq_idx++; } } @@ -747,12 +760,21 @@ static void setup_worker_qconf(app_args_t *args) /* put the queue into worker_args */ arg = &global.worker_args[q->core_idx]; - rxq_idx = arg->pktio[q->if_idx].nb_rxq; - arg->pktio[q->if_idx].rxq[rxq_idx] = q->rxq_idx; - arg->pktio[q->if_idx].nb_rxq++; + + /* Check if interface already has queues configured */ + for (j = 0; j < args->if_count; j++) { + if (arg->pktio[j].if_idx == q->if_idx) + break; + } + if (j == args->if_count) + j = arg->nb_pktio++; + + rxq_idx = arg->pktio[j].nb_rxq; + arg->pktio[j].rxq[rxq_idx] = q->rxq_idx; + arg->pktio[j].nb_rxq++; + arg->pktio[j].if_idx = q->if_idx; arg->thr_idx = q->core_idx; } - /* distribute tx queues among threads */ for (i = 0; i < args->worker_count; i++) { arg = &global.worker_args[i]; @@ -821,7 +843,7 @@ static void setup_worker_qconf(app_args_t *args) static void print_qconf_table(app_args_t *args) { - int i, j, k, qid; + int i, j, k, qid, if_idx; char buf[32]; struct thread_arg_s *thr_arg; @@ -836,7 +858,9 @@ static void print_qconf_table(app_args_t *args) if (!thr_arg->pktio[j].nb_rxq) continue; - snprintf(buf, 32, "%s/%d", args->if_names[j], j); + if_idx = thr_arg->pktio[j].if_idx; + snprintf(buf, 32, "%s/%d", args->if_names[if_idx], + if_idx); for (k = 0; k < MAX_NB_QUEUE; k++) { qid = thr_arg->pktio[j].rxq[k]; if (qid != INVALID_ID) @@ -948,6 +972,7 @@ int main(int argc, char **argv) for (j = 0; j < MAX_NB_PKTIO; j++) { thr_arg->thr_idx = INVALID_ID; thr_arg->pktio[j].txq_idx = INVALID_ID; + thr_arg->pktio[j].if_idx = INVALID_ID; memset(thr_arg->pktio[j].rxq, INVALID_ID, sizeof(thr_arg->pktio[j].rxq)); } @@ -1069,7 +1094,6 @@ int main(int argc, char **argv) odp_cpumask_t thr_mask; arg = &global.worker_args[i]; - arg->nb_pktio = args->if_count; odp_cpumask_zero(&thr_mask); odp_cpumask_set(&thr_mask, cpu); thr_params.arg = arg;