From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8876DA0547; Mon, 27 Jun 2022 17:51:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2AA4640691; Mon, 27 Jun 2022 17:51:51 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 83DEE40685; Mon, 27 Jun 2022 17:51:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656345108; x=1687881108; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=sN/WLu3zxhBF2mGvPWm+cPhjU6roYErT4BpksM4BhLA=; b=nQ/LoPxosEM6mwJA70kX4/zNRSkUVFwQiCPyrLTn7wWMUWPndA1hUu1u Nk+P6nvqygRXdaXpapIVArQQw5Ly7PscdaoB9QYWPrfuflvXw4SdNiBpS UiCr5xk/61lVZGzeJZ1jcNqh7qsb31DJbrhcA75keurGvFYxyl2biaAuO axFiW1Hv388lhWClAoL+hpMudl1wehcHe3+FfmAZGnG8iA3o5bKu7pFah l60P17FLPi7LfekdFU1lWUpdUaDsh93U2q4qQehcsiWCZt42U+zDR/LJ5 Yi+bwEsz3ZdujZ4qpKgXQWlLeN9S0S/8yPgtax4MsI56T04N8ws7Z4AgL w==; X-IronPort-AV: E=McAfee;i="6400,9594,10391"; a="261281463" X-IronPort-AV: E=Sophos;i="5.92,226,1650956400"; d="scan'208";a="261281463" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2022 08:51:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,226,1650956400"; d="scan'208";a="587486614" Received: from orsmsx604.amr.corp.intel.com ([10.22.229.17]) by orsmga007.jf.intel.com with ESMTP; 27 Jun 2022 08:51:46 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Mon, 27 Jun 2022 08:51:46 -0700 Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Mon, 27 Jun 2022 08:51:46 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Mon, 27 Jun 2022 08:51:46 -0700 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.43) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Mon, 27 Jun 2022 08:51:45 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=batHOQJQhhyPukKmFLpaiNOY1tYBAabvRQ+ZHyKknKRKeZgRB9tVWMdcRLtjfjQpzLrp8DxBG+i8NOsJFhQqTAKFWnw3KefdhQgpYLiFyyRHoNsSfs8vLPDUqOuFBL+zxKNaa5fYjVQx8yl1627o0ckDUd92M66ar7a2dumZQfJQ7UPxw0uQtykKfbZHfShFWGdmgmy97KWglGj+cwCQgGQ4sWxWCFzf/EgXeLTkN54uf1RyThWsqYhLZKBdwzOUWIVk1aTtCnFEUB1N3BAYzx/1twZVwy5vwpioX2NzKy7ThZlr+afFoDV+bR0qM3Nskk6cD+vUYELXYp4dd+PCig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=A/Kgiuievj54bMeYl/2roAy8ee5WpnjBDKL6+BrabHI=; b=DR3+XIYQYzSi7WsWjGb7EfSmDH5nqQ7QnQOrdqLBCtNBMeA4+ZEWClPOBuZmsqyRhzES/vZOOw3uEP4UjyYVL1uHrxrR8zK2Zf6amwKI8bM+3SCz+zGt0k7RmAIlOlCRc9og2/pazTe3lNayN2zOsNqHEMDlMR6b7HEJ+1Unew7NbaUGohTfR+UxSqu6jhPqadFzhUHpX/LK9CUDFLuR2JsywDxGZpBrFu9HxwcTP8Y6UnyfaMYZo+vARhUB2h28ttoVNiofdqLrA8x6TZ4ubXReiXeJPszJ5wyE1vQ+UdvVTFlFDxtvq6evhlVjVQY/cHrrxk9rjJkbQmJVOPe1kQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BYAPR11MB3799.namprd11.prod.outlook.com (2603:10b6:a03:fb::19) by DM5PR11MB1802.namprd11.prod.outlook.com (2603:10b6:3:10a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.18; Mon, 27 Jun 2022 15:51:43 +0000 Received: from BYAPR11MB3799.namprd11.prod.outlook.com ([fe80::e424:dc7d:97d3:66a9]) by BYAPR11MB3799.namprd11.prod.outlook.com ([fe80::e424:dc7d:97d3:66a9%3]) with mapi id 15.20.5373.015; Mon, 27 Jun 2022 15:51:43 +0000 Message-ID: Date: Mon, 27 Jun 2022 16:51:38 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH] examples/distributor: update dynamic configuration Content-Language: en-US To: =?UTF-8?B?QWJkdWxsYWggw5ZtZXIgWWFtYcOn?= CC: , References: <20220621201517.76991-1-omer.yamac@ceng.metu.edu.tr> From: "Hunt, David" In-Reply-To: <20220621201517.76991-1-omer.yamac@ceng.metu.edu.tr> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P265CA0115.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c3::19) To BYAPR11MB3799.namprd11.prod.outlook.com (2603:10b6:a03:fb::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ab049899-1ab1-47b6-e7ad-08da5854eed2 X-MS-TrafficTypeDiagnostic: DM5PR11MB1802:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DmC8ixfJXNO0PV3dk4MreGdrKuQ47uSMn23u22STfXZIKmiOLNp7rwRNtZveTitWyEMBvmuB9m872he4zP5Oyd8AvzDMFcM1N12eT/TAmnoeVZO2L6DG92cgdHkB9nu7Exi9VApaLQPmpI6yZD6FcoKE2W1rUA1fvrA21a8KBWpkgnT9aUTqZQPb3gtnYs08t8IcQ6fNsnzFHpL+HBVfi3zHO/9SomjwH7IfRE61YFf0+ZZSV75qyOOy7x3xJtM46wNav9oOkepWgVUPBVRcFeARA5KarvpuPgcgzGvw5wKyrABJiSn2+paotnzUDuL+Loj5z+Y9WEWkLnPuEyoKWrF85UIvNyfRf9kXkEB9vnKq0pOCdQgYg1gSCU3JvTvrEagKiUMjxLL8njbuL1jIJiOSTTzTEr5FbdHYXxD7p8wu3iw6C/Vm/SCbqhWqLoK6JeVsL4ZSXG9KoBa7r7LiX6qQH0McoVe2E+EatBEyHCLjznHZvcd28SIXZxl6bzNyPezN/D8JINXdzPKrQPbyRjXXPAr0twc5mfTdji05esp/+ZjlbIoQr/4WbbnLjhufEvsHH6yKtcIRkLjUQxIfRIJiGadoWkv8npdrEG5m5oJVF7wdyFGY4pY6RkKppgaX4ORlIa/VfFrUubdvnGwxsEUdwmzxHkGU7GlgO6r3PXhXaZmbN4m/0Rz+e0V1b1WFyTTnxXRUmbNqkz8OxMjVH+rm6+mP6FHcQodm9j2TZv43bNJ7zP0wD5Gcn/m7RTOXEzsnEPCa6Fg7TvYp3bFqg3JCrGArr36L0SrDHoL/r0RIpabb75ZPnubzv4ZiaCfLvW9rJiQei9f2K7SqRPQ8fg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB3799.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(136003)(366004)(376002)(346002)(39860400002)(396003)(36756003)(30864003)(31686004)(4326008)(38100700002)(66476007)(8936002)(316002)(66946007)(5660300002)(2906002)(6486002)(66556008)(86362001)(478600001)(6666004)(26005)(2616005)(6506007)(41300700001)(53546011)(83380400001)(186003)(8676002)(6916009)(66574015)(6512007)(82960400001)(31696002)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?U042OXdJOG5XZlZZdmovV084QmV6WHZVRzkxM0ZCMVNvTWFPV2xTbHlZeWxp?= =?utf-8?B?NE0vKzJLVWpBaDNiUTJvNDcyNTBvWHJGdWsveTY2cURTTGlMV2RqcS9aUytH?= =?utf-8?B?c1dTMGkybFhTT2NIRHFJYVNGb243cWtpaGFYV2RTMEZ3dDg0OWJ4STlTdlZR?= =?utf-8?B?MDNWW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JXNzhMN1JDMXI2K3VKcmZH?= =?utf-8?B?UDh6cExWdHJPRmlhdGIrLy9Odm1rak05MkpCNWdNaG5Fdlo1cEJUS1BGaVhh?= =?utf-8?B?OXBiU2M1Y0NnSy9KbkRQSWtSblBJY05NR1NmTVJ1RUxVQTJYWlNIU2ZMa2Z4?= =?utf-8?Q?I++I4XLEIM4NMZY7XobLCIPyo?= X-MS-Exchange-CrossTenant-Network-Message-Id: ab049899-1ab1-47b6-e7ad-08da5854eed2 X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3799.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2022 15:51:43.6142 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wWxNTTSb3a/yM7cc+FOTEHjcqNX3VZarPXRkezrJ93e2annkCIpXt3JhZfBYnBqQYYnEFRc56cdIg8A6ROykqA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1802 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi Ömer, I've a few comments: On 21/06/2022 21:15, Abdullah Ömer Yamaç wrote: > In this patch, > * It is possible to switch the running mode of the distributor > using the command line argument. > * With "-c" parameter, you can run RX and Distributor > on the same core. > * Without "-c" parameter, you can run RX and Distributor > on the different core. > * Syntax error of the single RX and distributor core is fixed. > * When "-c" parameter is active, the wasted distributor core is > also deactivated in the main function. > > Fixes: 4a7f40c0ff9a ("examples/distributor: add dedicated core") > Cc: stable@dpdk.org > > Signed-off-by: Abdullah Ömer Yamaç > > --- > Cc: david.hunt@intel.com > --- > doc/guides/sample_app_ug/dist_app.rst | 3 +- > examples/distributor/main.c | 205 +++++++++++++++++++------- > 2 files changed, 152 insertions(+), 56 deletions(-) > > diff --git a/doc/guides/sample_app_ug/dist_app.rst b/doc/guides/sample_app_ug/dist_app.rst > index 3bd03905c3..5c80561187 100644 > --- a/doc/guides/sample_app_ug/dist_app.rst > +++ b/doc/guides/sample_app_ug/dist_app.rst > @@ -42,11 +42,12 @@ Running the Application > > .. code-block:: console > > - .//examples/dpdk-distributor [EAL options] -- -p PORTMASK > + .//examples/dpdk-distributor [EAL options] -- -p PORTMASK [-c] > > where, > > * -p PORTMASK: Hexadecimal bitmask of ports to configure > + * -c: Combines the RX core with distribution core > > #. To run the application in linux environment with 10 lcores, 4 ports, > issue the command: > diff --git a/examples/distributor/main.c b/examples/distributor/main.c > index 02bf91f555..6e98f78054 100644 > --- a/examples/distributor/main.c > +++ b/examples/distributor/main.c > @@ -39,6 +39,7 @@ volatile uint8_t quit_signal_rx; > volatile uint8_t quit_signal_dist; > volatile uint8_t quit_signal_work; > unsigned int power_lib_initialised; > +bool enable_lcore_rx_distributor; > > static volatile struct app_stats { > struct { > @@ -256,14 +257,82 @@ lcore_rx(struct lcore_params *p) > } > app_stats.rx.rx_pkts += nb_rx; > > -/* > - * You can run the distributor on the rx core with this code. Returned > - * packets are then send straight to the tx core. > - */ > -#if 0 > - rte_distributor_process(d, bufs, nb_rx); > - const uint16_t nb_ret = rte_distributor_returned_pktsd, > - bufs, BURST_SIZE*2); > + /* > + * Swap the following two lines if you want the rx traffic > + * to go directly to tx, no distribution. > + */ > + struct rte_ring *out_ring = p->rx_dist_ring; > + /* struct rte_ring *out_ring = p->dist_tx_ring; */ > + > + uint16_t sent = rte_ring_enqueue_burst(out_ring, > + (void *)bufs, nb_rx, NULL); > + > + app_stats.rx.enqueued_pkts += sent; > + if (unlikely(sent < nb_rx)) { > + app_stats.rx.enqdrop_pkts += nb_rx - sent; > + RTE_LOG_DP(DEBUG, DISTRAPP, > + "%s:Packet loss due to full ring\n", __func__); > + while (sent < nb_rx) > + rte_pktmbuf_free(bufs[sent++]); > + } > + if (++port == nb_ports) > + port = 0; > + } > + if (power_lib_initialised) > + rte_power_exit(rte_lcore_id()); > + /* set worker & tx threads quit flag */ > + printf("\nCore %u exiting rx task.\n", rte_lcore_id()); > + quit_signal = 1; > + return 0; > +} > + > +static int > +lcore_rx_and_distributor(struct lcore_params *p) > +{ > + struct rte_distributor *d = p->d; > + const uint16_t nb_ports = rte_eth_dev_count_avail(); > + const int socket_id = rte_socket_id(); > + uint16_t port; > + struct rte_mbuf *bufs[BURST_SIZE*2]; > + > + RTE_ETH_FOREACH_DEV(port) { > + /* skip ports that are not enabled */ > + if ((enabled_port_mask & (1 << port)) == 0) > + continue; > + > + if (rte_eth_dev_socket_id(port) > 0 && > + rte_eth_dev_socket_id(port) != socket_id) > + printf("WARNING, port %u is on remote NUMA node to " > + "RX thread.\n\tPerformance will not " > + "be optimal.\n", port); > + } > + > + printf("\nCore %u doing packet RX and Distributor.\n", rte_lcore_id()); > + port = 0; > + while (!quit_signal_rx) { > + > + /* skip ports that are not enabled */ > + if ((enabled_port_mask & (1 << port)) == 0) { > + if (++port == nb_ports) > + port = 0; > + continue; > + } > + const uint16_t nb_rx = rte_eth_rx_burst(port, 0, bufs, > + BURST_SIZE); > + if (unlikely(nb_rx == 0)) { > + if (++port == nb_ports) > + port = 0; > + continue; > + } > + app_stats.rx.rx_pkts += nb_rx; > + > + /* > + * Run the distributor on the rx core. Returned > + * packets are then send straight to the tx core. > + */ > + rte_distributor_process(d, bufs, nb_rx); > + const uint16_t nb_ret = rte_distributor_returned_pkts(d, > + bufs, BURST_SIZE*2); > > app_stats.rx.returned_pkts += nb_ret; > if (unlikely(nb_ret == 0)) { > @@ -275,18 +344,6 @@ lcore_rx(struct lcore_params *p) > struct rte_ring *tx_ring = p->dist_tx_ring; > uint16_t sent = rte_ring_enqueue_burst(tx_ring, > (void *)bufs, nb_ret, NULL); > -#else > - uint16_t nb_ret = nb_rx; > - /* > - * Swap the following two lines if you want the rx traffic > - * to go directly to tx, no distribution. > - */ > - struct rte_ring *out_ring = p->rx_dist_ring; > - /* struct rte_ring *out_ring = p->dist_tx_ring; */ > - > - uint16_t sent = rte_ring_enqueue_burst(out_ring, > - (void *)bufs, nb_ret, NULL); > -#endif > > app_stats.rx.enqueued_pkts += sent; > if (unlikely(sent < nb_ret)) { > @@ -475,7 +532,11 @@ print_stats(void) > { > struct rte_eth_stats eth_stats; > unsigned int i, j; > - const unsigned int num_workers = rte_lcore_count() - 4; > + unsigned int num_workers; > + if (enable_lcore_rx_distributor) > + num_workers = rte_lcore_count() - 3; > + else > + num_workers = rte_lcore_count() - 4; This could be "num_workers = rte_lcore_count() - (3 + enable_lcore_rx_distributor)" Also, if you don't like the magic number, you could add a #define FIXED_FUNCTION_CORES 3 at the top of the file and use here. > > RTE_ETH_FOREACH_DEV(i) { > rte_eth_stats_get(i, ð_stats); > @@ -504,20 +565,22 @@ print_stats(void) > prev_app_stats.rx.enqdrop_pkts)/1000000.0, > ANSI_COLOR_RESET); > > - printf("Distributor thread:\n"); > - printf(" - In: %5.2f\n", > - (app_stats.dist.in_pkts - > - prev_app_stats.dist.in_pkts)/1000000.0); > - printf(" - Returned: %5.2f\n", > - (app_stats.dist.ret_pkts - > - prev_app_stats.dist.ret_pkts)/1000000.0); > - printf(" - Sent: %5.2f\n", > - (app_stats.dist.sent_pkts - > - prev_app_stats.dist.sent_pkts)/1000000.0); > - printf(" - Dropped %s%5.2f%s\n", ANSI_COLOR_RED, > - (app_stats.dist.enqdrop_pkts - > - prev_app_stats.dist.enqdrop_pkts)/1000000.0, > - ANSI_COLOR_RESET); > + if (!enable_lcore_rx_distributor) { > + printf("Distributor thread:\n"); > + printf(" - In: %5.2f\n", > + (app_stats.dist.in_pkts - > + prev_app_stats.dist.in_pkts)/1000000.0); > + printf(" - Returned: %5.2f\n", > + (app_stats.dist.ret_pkts - > + prev_app_stats.dist.ret_pkts)/1000000.0); > + printf(" - Sent: %5.2f\n", > + (app_stats.dist.sent_pkts - > + prev_app_stats.dist.sent_pkts)/1000000.0); > + printf(" - Dropped %s%5.2f%s\n", ANSI_COLOR_RED, > + (app_stats.dist.enqdrop_pkts - > + prev_app_stats.dist.enqdrop_pkts)/1000000.0, > + ANSI_COLOR_RESET); > + } > > printf("TX thread:\n"); > printf(" - Dequeued: %5.2f\n", > @@ -629,8 +692,9 @@ init_power_library(void) > static void > print_usage(const char *prgname) > { > - printf("%s [EAL options] -- -p PORTMASK\n" > - " -p PORTMASK: hexadecimal bitmask of ports to configure\n", > + printf("%s [EAL options] -- -p PORTMASK [-c]\n" > + " -p PORTMASK: hexadecimal bitmask of ports to configure\n" > + " -c: Combines the RX core with the distribution core\n", > prgname); > } > > @@ -662,7 +726,7 @@ parse_args(int argc, char **argv) > > argvopt = argv; > > - while ((opt = getopt_long(argc, argvopt, "p:", > + while ((opt = getopt_long(argc, argvopt, "cp:", > lgopts, &option_index)) != EOF) { > > switch (opt) { > @@ -676,6 +740,10 @@ parse_args(int argc, char **argv) > } > break; > > + case 'c': > + enable_lcore_rx_distributor = true; > + break; > + > default: > print_usage(prgname); > return -1; > @@ -705,9 +773,11 @@ main(int argc, char *argv[]) > unsigned int lcore_id, worker_id = 0; > int distr_core_id = -1, rx_core_id = -1, tx_core_id = -1; > unsigned nb_ports; > + unsigned int num_workers; > uint16_t portid; > uint16_t nb_ports_available; > uint64_t t, freq; > + enable_lcore_rx_distributor = false; I'd suggest removing this line and setting the initial value in the declaration above. I would also suggest defaulting it to true. > > /* catch ctrl-c so we can print on exit */ > signal(SIGINT, int_handler); > @@ -724,7 +794,12 @@ main(int argc, char *argv[]) > if (ret < 0) > rte_exit(EXIT_FAILURE, "Invalid distributor parameters\n"); > > - if (rte_lcore_count() < 5) > + if (enable_lcore_rx_distributor) > + num_workers = rte_lcore_count() - 3; > + else > + num_workers = rte_lcore_count() - 4; > + This could be "num_workers = rte_lcore_count() - (4 - enable_lcore_rx_distributor)". > + if (rte_lcore_count() < 5 && !enable_lcore_rx_distributor) > rte_exit(EXIT_FAILURE, "Error, This application needs at " > "least 5 logical cores to run:\n" > "1 lcore for stats (can be core 0)\n" > @@ -733,6 +808,15 @@ main(int argc, char *argv[]) > "1 lcore for packet TX\n" > "and at least 1 lcore for worker threads\n"); > > + if (rte_lcore_count() < 4 && enable_lcore_rx_distributor) > + rte_exit(EXIT_FAILURE, "Error, This application needs at " > + "least 4 logical cores to run:\n" > + "1 lcore for stats (can be core 0)\n" > + "1 lcore for packet RX and distribution\n" > + "1 lcore for packet TX\n" > + "and at least 1 lcore for worker threads\n"); > + the two checks above could be replaced with something like: min_cores = 4 + enable_lcore_rx_distributor; if (rte_lcore_count() < min_cores)                 rte_exit(EXIT_FAILURE, "Error, This application needs at "                                 "least %d logical cores to run:\n"                                 "1 lcore for stats (can be core 0)\n"                                 "1 lcore for packet RX\n"                                 "1 lcore for distribution\n"                                 "1 lcore for packet TX\n"                                 "and at least 1 lcore for worker threads\n",                                 min_cores); > + > if (init_power_library() == 0) > power_lib_initialised = 1; > > @@ -772,7 +856,7 @@ main(int argc, char *argv[]) > } > > d = rte_distributor_create("PKT_DIST", rte_socket_id(), > - rte_lcore_count() - 4, > + num_workers, > RTE_DIST_ALG_BURST); > if (d == NULL) > rte_exit(EXIT_FAILURE, "Cannot create distributor\n"); > @@ -808,7 +892,7 @@ main(int argc, char *argv[]) > if (lcore_cap.priority != 1) > continue; > > - if (distr_core_id < 0) { > + if (distr_core_id < 0 && !enable_lcore_rx_distributor) { > distr_core_id = lcore_id; > printf("Distributor on priority core %d\n", > lcore_id); > @@ -839,7 +923,7 @@ main(int argc, char *argv[]) > lcore_id == (unsigned int)rx_core_id || > lcore_id == (unsigned int)tx_core_id) > continue; > - if (distr_core_id < 0) { > + if (distr_core_id < 0 && !enable_lcore_rx_distributor) { > distr_core_id = lcore_id; > printf("Distributor on core %d\n", lcore_id); > continue; > @@ -856,7 +940,12 @@ main(int argc, char *argv[]) > } > } > > - printf(" tx id %d, dist id %d, rx id %d\n", > + if (enable_lcore_rx_distributor) > + printf(" tx id %d, rx id %d\n", > + tx_core_id, > + rx_core_id); > + else > + printf(" tx id %d, dist id %d, rx id %d\n", > tx_core_id, > distr_core_id, > rx_core_id); > @@ -888,15 +977,16 @@ main(int argc, char *argv[]) > dist_tx_ring, tx_core_id); > > /* Start distributor core */ > - struct lcore_params *pd = > - rte_malloc(NULL, sizeof(*pd), 0); > - if (!pd) > - rte_panic("malloc failure\n"); > - *pd = (struct lcore_params){worker_id++, d, > - rx_dist_ring, dist_tx_ring, mbuf_pool}; > - rte_eal_remote_launch( > - (lcore_function_t *)lcore_distributor, > - pd, distr_core_id); > + struct lcore_params *pd; > + if (!enable_lcore_rx_distributor) { > + pd = rte_malloc(NULL, sizeof(*pd), 0); > + if (!pd) > + rte_panic("malloc failure\n"); > + *pd = (struct lcore_params){worker_id++, d, > + rx_dist_ring, dist_tx_ring, mbuf_pool}; > + rte_eal_remote_launch((lcore_function_t *)lcore_distributor, > + pd, distr_core_id); > + } > > /* Start rx core */ > struct lcore_params *pr = > @@ -905,8 +995,12 @@ main(int argc, char *argv[]) > rte_panic("malloc failure\n"); > *pr = (struct lcore_params){worker_id++, d, rx_dist_ring, > dist_tx_ring, mbuf_pool}; > - rte_eal_remote_launch((lcore_function_t *)lcore_rx, > - pr, rx_core_id); > + if (enable_lcore_rx_distributor) > + rte_eal_remote_launch((lcore_function_t *)lcore_rx_and_distributor, > + pr, rx_core_id); > + else > + rte_eal_remote_launch((lcore_function_t *)lcore_rx, > + pr, rx_core_id); > > freq = rte_get_timer_hz(); > t = rte_rdtsc() + freq; > @@ -925,7 +1019,8 @@ main(int argc, char *argv[]) > > print_stats(); > > - rte_free(pd); > + if (!enable_lcore_rx_distributor) > + rte_free(pd); > rte_free(pr); > > /* clean up the EAL */ Thanks, Dave.