From patchwork Tue Jan 16 18:23:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sivaprasad Tummala X-Patchwork-Id: 135892 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5345D438E3; Tue, 16 Jan 2024 19:24:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 314BE40DDC; Tue, 16 Jan 2024 19:23:56 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2065.outbound.protection.outlook.com [40.107.220.65]) by mails.dpdk.org (Postfix) with ESMTP id 135DC40A73; Tue, 16 Jan 2024 19:23:53 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KBUvi/OUFxJJWwL2ZVD0gKFf/YK4ecndHAp4j9TnTl0r4a6QJQqfTs9aZeVZXcqk9ydq7ySC6BfoheEWDJP9cvw6Gw6+SRi2xlXCbJJfJUZw/UNus/gPK7yG06Q1kuYjlactjeCIDhL0wJQZxCxNEg7py3DppKIvfJVBt9WM2rLME3XukDsN4s/LR+4JCrp74lGDe2qYKFEFzPakCUSVmVAACbqmGNo0YwUZ+I1pmOBWxvEWf3Xo09muPgyEYnzQJfJs2m0e6yAA8HaJobJr36LowqyTtr6Loi55ZvIJ2Z81sI06Eg9gs0K60WtQwdvbg6kb0T2rUDBLWjRfs0SkOw== 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=tEdzuwMABIKRnPgsOqMhOTy2ypEHQJJZ7eDm8pbf1Jc=; b=Wi8Cr1FPdFAVABF1B2zUjtEM3kC2SaxJLF8sO81ta0AR7CZSixxk0rsvFTfppwvxkH/BLkRdZWipl49L3c1eaXQoNYfhkDF/aFZK7E/a0HVfST8tfuAhCunUW3uKygN+HRjzw03pqc+50qqf/vv1WZPECnQk6aRBmqBx8Jj9xx0XEQRRS4ftSrMhdxi1Hy0dTCYZ350Ttl2kRUbbR4tDQA+S0wFaKtJ3GK6k9wV/jqLXQAj0AbmgvoFvO3OnenxQ69BquoXyCMtZ96xdrGIIZXQFdsniBhFFqK71OyvogiEX5ijeWujkqzgTtxGGgGn9PKIKDWAEtOq0e3pkTIunMQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tEdzuwMABIKRnPgsOqMhOTy2ypEHQJJZ7eDm8pbf1Jc=; b=1LpUhtMifueiso4n1ICiLJ75E9XM+rZ9tlV12Yp1vV4FS5MLn4yOi/Lk4rVKRZHrxxK+3959Tb+C7JVMAykdt8PSo+mx+NPAxgDefOunRHsH6aFkam8hWKEIa3hEvnzoNvnI/gES+/EaYKNv5qMthe97TKTdfIZunTYMNyDG2l8= Received: from BYAPR07CA0019.namprd07.prod.outlook.com (2603:10b6:a02:bc::32) by IA1PR12MB6187.namprd12.prod.outlook.com (2603:10b6:208:3e5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.29; Tue, 16 Jan 2024 18:23:49 +0000 Received: from SJ1PEPF00001CDC.namprd05.prod.outlook.com (2603:10b6:a02:bc:cafe::b) by BYAPR07CA0019.outlook.office365.com (2603:10b6:a02:bc::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.26 via Frontend Transport; Tue, 16 Jan 2024 18:23:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CDC.mail.protection.outlook.com (10.167.242.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7202.16 via Frontend Transport; Tue, 16 Jan 2024 18:23:48 +0000 Received: from 7dbylenovo.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 16 Jan 2024 12:23:46 -0600 From: Sivaprasad Tummala To: , , , , , , , , CC: , Subject: [PATCH v4 2/6] examples/l3fwd-power: fix lcore ID restriction Date: Tue, 16 Jan 2024 18:23:27 +0000 Message-ID: <20240116182332.95537-3-sivaprasad.tummala@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240116182332.95537-1-sivaprasad.tummala@amd.com> References: <20231220064502.2830-1-sivaprasad.tummala@amd.com> <20240116182332.95537-1-sivaprasad.tummala@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDC:EE_|IA1PR12MB6187:EE_ X-MS-Office365-Filtering-Correlation-Id: 2473ac8d-04f0-4cbb-d2c3-08dc16c048ad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bdpiTX9ZVqGQW0gS1V2W+dnvc0WcZ3Qtnoc3XehDJok11XsAzBBOXFfNkqiyDyb/ntubd8yDxyA/jATIoYvTxkb6gGLedevoL3UL3mBsFXlrmsBoVOs0e+bfABFSzmO0afHmOhDR/qlT4V9+EsIQ7U2CDN+oL9WMTioGpTd5gBq+js4lSDMWQWnl/M7xcVRgZXQnVb1Q9ykYNiUcHdYKsoQuD940OzMDjvx2DuBAjjKs0e14eXrQvim8gnWPuK/hedKoVPagazl0p4luhkzeMwqRvE3Lj4mTfsvehtBp2RnjYX97G+WD3ZAxcQB7lyGLZgEp2/8dozOaNXlZRpPzPFHQGkuDiPasQ+k9PvoCW945IZYfdK7bW+ZGRZpfPzcndMwfejgjQ864d+LjNhosgzxDY9HWQAnFIx4P30W3qBtehPRYwcobAebyZ8RONU1wSxDgDawcy99QMPxR+0K1Ln9kU//n8MQxVqTuyHhUijVyQHFZuuY6jDMjQOO3YfhISBEReSjoCRAlgRDfiLS+AHLCSYw1Lf8P2tGzCMh4V727jfSkoAnEfjNreUbP/MbheJ4YfZaw4n9MKhKAk+YhYL+RRVyVFc8iJUPqZiqzOv6KQVaZja/iPYDzDcLxt01x+eylG0VlEib+FxFunF2vQmfdP03CWoKaXjOL7Pt6VMeyC8cxdvb3rYtyNzBgtulhfdsYtY6C4+360yTrbCLpd8irlGIiY8rSPwt8RZaab+FCDv5Rtxi6FiIjtsUpfbCer5Uxh/LZYC+5f7N98hveVpLSjvOXy5oX2yob1z2WfBQqaiDv15DPpx56fMpvqmyV X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(346002)(376002)(396003)(136003)(230273577357003)(230173577357003)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(82310400011)(40470700004)(36840700001)(46966006)(83380400001)(5660300002)(356005)(81166007)(8676002)(8936002)(4326008)(82740400003)(7416002)(2906002)(336012)(16526019)(86362001)(2616005)(47076005)(40460700003)(40480700001)(1076003)(36860700001)(426003)(26005)(478600001)(44832011)(7696005)(6666004)(36756003)(110136005)(316002)(70586007)(70206006)(54906003)(41300700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2024 18:23:48.6775 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2473ac8d-04f0-4cbb-d2c3-08dc16c048ad X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CDC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6187 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 Currently the config option allows lcore IDs up to 255, irrespective of RTE_MAX_LCORES and needs to be fixed. The patch allows config options based on DPDK config. Fixes: f88e7c175a68 ("examples/l3fwd-power: add high/regular perf cores options") Cc: radu.nicolau@intel.com Cc: stable@dpdk.org Signed-off-by: Sivaprasad Tummala --- examples/l3fwd-power/main.c | 57 ++++++++++++++++---------------- examples/l3fwd-power/main.h | 4 +-- examples/l3fwd-power/perf_core.c | 10 +++--- 3 files changed, 35 insertions(+), 36 deletions(-) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index f4adcf41b5..d0f3c332ee 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -214,7 +214,7 @@ enum freq_scale_hint_t struct lcore_rx_queue { uint16_t port_id; - uint8_t queue_id; + uint16_t queue_id; enum freq_scale_hint_t freq_up_hint; uint32_t zero_rx_packet_count; uint32_t idle_hint; @@ -838,7 +838,7 @@ sleep_until_rx_interrupt(int num, int lcore) struct rte_epoll_event event[num]; int n, i; uint16_t port_id; - uint8_t queue_id; + uint16_t queue_id; void *data; if (status[lcore].wakeup) { @@ -850,9 +850,9 @@ sleep_until_rx_interrupt(int num, int lcore) n = rte_epoll_wait(RTE_EPOLL_PER_THREAD, event, num, 10); for (i = 0; i < n; i++) { data = event[i].epdata.data; - port_id = ((uintptr_t)data) >> CHAR_BIT; + port_id = ((uintptr_t)data) >> (sizeof(uint16_t) * CHAR_BIT); queue_id = ((uintptr_t)data) & - RTE_LEN2MASK(CHAR_BIT, uint8_t); + RTE_LEN2MASK((sizeof(uint16_t) * CHAR_BIT), uint16_t); RTE_LOG(INFO, L3FWD_POWER, "lcore %u is waked up from rx interrupt on" " port %d queue %d\n", @@ -867,7 +867,7 @@ static void turn_on_off_intr(struct lcore_conf *qconf, bool on) { int i; struct lcore_rx_queue *rx_queue; - uint8_t queue_id; + uint16_t queue_id; uint16_t port_id; for (i = 0; i < qconf->n_rx_queue; ++i) { @@ -887,7 +887,7 @@ static void turn_on_off_intr(struct lcore_conf *qconf, bool on) static int event_register(struct lcore_conf *qconf) { struct lcore_rx_queue *rx_queue; - uint8_t queueid; + uint16_t queueid; uint16_t portid; uint32_t data; int ret; @@ -897,7 +897,7 @@ static int event_register(struct lcore_conf *qconf) rx_queue = &(qconf->rx_queue_list[i]); portid = rx_queue->port_id; queueid = rx_queue->queue_id; - data = portid << CHAR_BIT | queueid; + data = portid << (sizeof(uint16_t) * CHAR_BIT) | queueid; ret = rte_eth_dev_rx_intr_ctl_q(portid, queueid, RTE_EPOLL_PER_THREAD, @@ -917,8 +917,7 @@ static int main_intr_loop(__rte_unused void *dummy) unsigned int lcore_id; uint64_t prev_tsc, diff_tsc, cur_tsc; int i, j, nb_rx; - uint8_t queueid; - uint16_t portid; + uint16_t portid, queueid; struct lcore_conf *qconf; struct lcore_rx_queue *rx_queue; uint32_t lcore_rx_idle_count = 0; @@ -946,7 +945,7 @@ static int main_intr_loop(__rte_unused void *dummy) portid = qconf->rx_queue_list[i].port_id; queueid = qconf->rx_queue_list[i].queue_id; RTE_LOG(INFO, L3FWD_POWER, - " -- lcoreid=%u portid=%u rxqueueid=%hhu\n", + " -- lcoreid=%u portid=%u rxqueueid=%hu\n", lcore_id, portid, queueid); } @@ -1083,8 +1082,7 @@ main_telemetry_loop(__rte_unused void *dummy) unsigned int lcore_id; uint64_t prev_tsc, diff_tsc, cur_tsc, prev_tel_tsc; int i, j, nb_rx; - uint8_t queueid; - uint16_t portid; + uint16_t portid, queueid; struct lcore_conf *qconf; struct lcore_rx_queue *rx_queue; uint64_t ep_nep[2] = {0}, fp_nfp[2] = {0}; @@ -1114,7 +1112,7 @@ main_telemetry_loop(__rte_unused void *dummy) portid = qconf->rx_queue_list[i].port_id; queueid = qconf->rx_queue_list[i].queue_id; RTE_LOG(INFO, L3FWD_POWER, " -- lcoreid=%u portid=%u " - "rxqueueid=%hhu\n", lcore_id, portid, queueid); + "rxqueueid=%hu\n", lcore_id, portid, queueid); } while (!is_done()) { @@ -1205,8 +1203,7 @@ main_legacy_loop(__rte_unused void *dummy) uint64_t prev_tsc, diff_tsc, cur_tsc, tim_res_tsc, hz; uint64_t prev_tsc_power = 0, cur_tsc_power, diff_tsc_power; int i, j, nb_rx; - uint8_t queueid; - uint16_t portid; + uint16_t portid, queueid; struct lcore_conf *qconf; struct lcore_rx_queue *rx_queue; enum freq_scale_hint_t lcore_scaleup_hint; @@ -1234,7 +1231,7 @@ main_legacy_loop(__rte_unused void *dummy) portid = qconf->rx_queue_list[i].port_id; queueid = qconf->rx_queue_list[i].queue_id; RTE_LOG(INFO, L3FWD_POWER, " -- lcoreid=%u portid=%u " - "rxqueueid=%hhu\n", lcore_id, portid, queueid); + "rxqueueid=%hu\n", lcore_id, portid, queueid); } /* add into event wait list */ @@ -1399,25 +1396,25 @@ main_legacy_loop(__rte_unused void *dummy) static int check_lcore_params(void) { - uint8_t queue, lcore; + uint16_t queue, lcore; uint16_t i; int socketid; for (i = 0; i < nb_lcore_params; ++i) { queue = lcore_params[i].queue_id; if (queue >= MAX_RX_QUEUE_PER_PORT) { - printf("invalid queue number: %hhu\n", queue); + printf("invalid queue number: %hu\n", queue); return -1; } lcore = lcore_params[i].lcore_id; if (!rte_lcore_is_enabled(lcore)) { - printf("error: lcore %hhu is not enabled in lcore " + printf("error: lcore %hu is not enabled in lcore " "mask\n", lcore); return -1; } if ((socketid = rte_lcore_to_socket_id(lcore) != 0) && (numa_on == 0)) { - printf("warning: lcore %hhu is on socket %d with numa " + printf("warning: lcore %hu is on socket %d with numa " "off\n", lcore, socketid); } if (app_mode == APP_MODE_TELEMETRY && lcore == rte_lcore_id()) { @@ -1451,7 +1448,7 @@ check_port_config(void) return 0; } -static uint8_t +static uint16_t get_port_n_rx_queues(const uint16_t port) { int queue = -1; @@ -1462,14 +1459,14 @@ get_port_n_rx_queues(const uint16_t port) lcore_params[i].queue_id > queue) queue = lcore_params[i].queue_id; } - return (uint8_t)(++queue); + return (uint16_t)(++queue); } static int init_lcore_rx_queues(void) { uint16_t i, nb_rx_queue; - uint8_t lcore; + uint16_t lcore; for (i = 0; i < nb_lcore_params; ++i) { lcore = lcore_params[i].lcore_id; @@ -1661,6 +1658,8 @@ parse_config(const char *q_arg) char *str_fld[_NUM_FLD]; int i; unsigned size; + unsigned int max_fld[_NUM_FLD] = {RTE_MAX_ETHPORTS, + USHRT_MAX, RTE_MAX_LCORE}; nb_lcore_params = 0; @@ -1681,7 +1680,7 @@ parse_config(const char *q_arg) errno = 0; int_fld[i] = strtoul(str_fld[i], &end, 0); if (errno != 0 || end == str_fld[i] || int_fld[i] > - 255) + max_fld[i]) return -1; } if (nb_lcore_params >= MAX_LCORE_PARAMS) { @@ -1690,11 +1689,11 @@ parse_config(const char *q_arg) return -1; } lcore_params_array[nb_lcore_params].port_id = - (uint8_t)int_fld[FLD_PORT]; + (uint16_t)int_fld[FLD_PORT]; lcore_params_array[nb_lcore_params].queue_id = - (uint8_t)int_fld[FLD_QUEUE]; + (uint16_t)int_fld[FLD_QUEUE]; lcore_params_array[nb_lcore_params].lcore_id = - (uint8_t)int_fld[FLD_LCORE]; + (uint16_t)int_fld[FLD_LCORE]; ++nb_lcore_params; } lcore_params = lcore_params_array; @@ -2501,8 +2500,8 @@ main(int argc, char **argv) uint64_t hz; uint32_t n_tx_queue, nb_lcores; uint32_t dev_rxq_num, dev_txq_num; - uint8_t nb_rx_queue, queue, socketid; - uint16_t portid; + uint8_t socketid; + uint16_t portid, nb_rx_queue, queue; const char *ptr_strings[NUM_TELSTATS]; /* init EAL */ diff --git a/examples/l3fwd-power/main.h b/examples/l3fwd-power/main.h index 258de98f5b..dcb5744ee6 100644 --- a/examples/l3fwd-power/main.h +++ b/examples/l3fwd-power/main.h @@ -9,8 +9,8 @@ #define MAX_LCORE_PARAMS 1024 struct lcore_params { uint16_t port_id; - uint8_t queue_id; - uint8_t lcore_id; + uint16_t queue_id; + uint16_t lcore_id; } __rte_cache_aligned; extern struct lcore_params *lcore_params; diff --git a/examples/l3fwd-power/perf_core.c b/examples/l3fwd-power/perf_core.c index 41ef6d0c9a..1fb9ceb584 100644 --- a/examples/l3fwd-power/perf_core.c +++ b/examples/l3fwd-power/perf_core.c @@ -22,9 +22,9 @@ static uint16_t nb_hp_lcores; struct perf_lcore_params { uint16_t port_id; - uint8_t queue_id; + uint16_t queue_id; uint8_t high_perf; - uint8_t lcore_idx; + uint16_t lcore_idx; } __rte_cache_aligned; static struct perf_lcore_params prf_lc_prms[MAX_LCORE_PARAMS]; @@ -161,13 +161,13 @@ parse_perf_config(const char *q_arg) return -1; } prf_lc_prms[nb_prf_lc_prms].port_id = - (uint8_t)int_fld[FLD_PORT]; + (uint16_t)int_fld[FLD_PORT]; prf_lc_prms[nb_prf_lc_prms].queue_id = - (uint8_t)int_fld[FLD_QUEUE]; + (uint16_t)int_fld[FLD_QUEUE]; prf_lc_prms[nb_prf_lc_prms].high_perf = !!(uint8_t)int_fld[FLD_LCORE_HP]; prf_lc_prms[nb_prf_lc_prms].lcore_idx = - (uint8_t)int_fld[FLD_LCORE_IDX]; + (uint16_t)int_fld[FLD_LCORE_IDX]; ++nb_prf_lc_prms; }