From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by dpdk.org (Postfix) with ESMTP id C6553AFD5 for ; Wed, 30 Apr 2014 16:14:46 +0200 (CEST) Received: by mail-we0-f182.google.com with SMTP id u57so1715080wes.41 for ; Wed, 30 Apr 2014 07:14:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=GEuJkBZDHu/ygypC7wdp412xNPcxpTLgGt9mmhmPnzI=; b=GMDcF8BYT8EOY0iB/Gnk5s1QMxIMFZclBMXlyxupgAjE/lIorB9lc/twfZDAxex1iq y9wxwVg8IFrdktmA34qxGpCfww/0LuoaTBcEZCgR2FyTkfJO/s7Op6hUmGSeXWPFMk+j wgV1Un/ig5AaCVs7iMnvjRFZLWdMUfHRID5Q47pJ8V9A4/mKaFyTgvnKDozyCOXurCyz VhwU87edyXtFQeMSr957MIQ/LHvWe2KssDOnsZ6CnAL4WRSsGdlij9H5sXruGOBvAR1a 0xAcuogFv+UunRYcbSiZ7sQeobrHJi68uWQTP7PFQe5ahlV3mAPsCyrKMAWuLRJrFHaj SWwQ== X-Gm-Message-State: ALoCoQlKlwHMYvu5kutPupN5mIdzXKzCUR2gwSddCzmCa4qS3N1nBVjk2FeG49pPESrlImDays1t X-Received: by 10.180.7.133 with SMTP id j5mr3860344wia.55.1398867290715; Wed, 30 Apr 2014 07:14:50 -0700 (PDT) Received: from alcyon.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id gp15sm36382431wjc.10.2014.04.30.07.14.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Apr 2014 07:14:49 -0700 (PDT) From: David Marchand To: dev@dpdk.org Date: Wed, 30 Apr 2014 16:14:42 +0200 Message-Id: <1398867282-15076-1-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.7.10.4 Subject: [dpdk-dev] [PATCH RFC] eal: change core mask input format X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Apr 2014 14:14:47 -0000 From: Didier Pallard In current version, coremask can only be specified using a bitmask. It will now be possible to specify core masks in 2 different ways: - Using a bitmask (-c 0xnnn): bitmask must be in hex format and start with 0x - Using a core set description in following format: -c [c1[-c2]][,c3[-c4]]... -c 0-7,16-23,31 being equivalent to -c 0x80FF00FF Signed-off-by: Didier Pallard --- lib/librte_eal/bsdapp/eal/eal.c | 103 ++++++++++++++++++++++++---------- lib/librte_eal/linuxapp/eal/eal.c | 111 ++++++++++++++++++++++++++----------- 2 files changed, 152 insertions(+), 62 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index f8a6fc1..5c181b3 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -302,10 +302,13 @@ rte_config_init(void) static void eal_usage(const char *prgname) { - printf("\nUsage: %s -c COREMASK -n NUM [-m NB] [-r NUM] [-b ]" + printf("\nUsage: %s -c CORESET -n NUM [-m NB] [-r NUM] [-b ]" "[--proc-type primary|secondary|auto] \n\n" "EAL options:\n" - " -c COREMASK : A hexadecimal bitmask of cores to run on\n" + " -c CORESET : Set of cores to run on, supports two different formats:\n" + " - A hexadecimal bitmask of cores starting with 0x\n" + " - A list of cores in following format c1[-c2][,c3[-c4]]...\n" + " where c1,c2,c3,... are core indexes between 0 and %d\n" " -n NUM : Number of memory channels\n" " -v : Display version information on startup\n" " (multiple -b options are allowed)\n" @@ -330,7 +333,7 @@ eal_usage(const char *prgname) " --"OPT_NO_PCI" : disable pci\n" " --"OPT_NO_SHCONF": no shared config (mmap'd files)\n" "\n", - prgname); + prgname, RTE_MAX_LCORE-1); /* Allow the application to print its usage message too if hook is set */ if ( rte_application_usage_hook ) { printf("===== Application Usage =====\n\n"); @@ -384,37 +387,79 @@ eal_parse_coremask(const char *coremask) while (isblank(*coremask)) coremask++; if (coremask[0] == '0' && ((coremask[1] == 'x') - || (coremask[1] == 'X')) ) + || (coremask[1] == 'X')) ) { coremask += 2; - i = strnlen(coremask, sysconf(_SC_ARG_MAX)); - while ((i > 0) && isblank(coremask[i - 1])) - i--; - if (i == 0) - return -1; + i = strnlen(coremask, sysconf(_SC_ARG_MAX)); + while ((i > 0) && isblank(coremask[i - 1])) + i--; + if (i == 0) + return -1; - for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) { - c = coremask[i]; - if (isxdigit(c) == 0) { - /* invalid characters */ - return (-1); - } - val = xdigit2val(c); - for(j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE; j++, idx++) { - if((1 << j) & val) { - cfg->lcore_role[idx] = ROLE_RTE; - if(count == 0) - cfg->master_lcore = idx; - count++; - } else { - cfg->lcore_role[idx] = ROLE_OFF; + for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) { + c = coremask[i]; + if (isxdigit(c) == 0) { + /* invalid characters */ + return (-1); + } + val = xdigit2val(c); + for(j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE; j++, idx++) { + if((1 << j) & val) { + cfg->lcore_role[idx] = ROLE_RTE; + if(count == 0) + cfg->master_lcore = idx; + count++; + } else { + cfg->lcore_role[idx] = ROLE_OFF; + } } } - } - for(; i >= 0; i--) - if(coremask[i] != '0') + + for(; i >= 0; i--) + if(coremask[i] != '0') + return -1; + for(; idx < RTE_MAX_LCORE; idx++) + cfg->lcore_role[idx] = ROLE_OFF; + } else { + char *end = NULL; + int min, max; + + /* Reset core roles */ + for(idx = 0; idx < RTE_MAX_LCORE; idx++) + cfg->lcore_role[idx] = ROLE_OFF; + + /* else this is a list of cores */ + min = RTE_MAX_LCORE; + do { + while (isblank(*coremask)) + coremask++; + idx = strtoul(coremask, &end, 10); + if (end != NULL) { + while (isblank(*end)) + end++; + if (*end == '-') { + min = idx; + coremask = end + 1; + } else if ((*end == ',') || (*end == '\0')) { + max = idx; + if (min == RTE_MAX_LCORE) + min = idx; + for (idx=min; idx<=max; idx++) { + cfg->lcore_role[idx] = ROLE_RTE; + if(count == 0) + cfg->master_lcore = idx; + count++; + } + min = RTE_MAX_LCORE; + if (*end != '\0') + coremask = end + 1; + } else { + break; + } + } + } while ((*coremask != '\0') && (end != NULL) && (*end != '\0')); + if ((*coremask == '\0') || (end == NULL) || (*end != '\0')) return -1; - for(; idx < RTE_MAX_LCORE; idx++) - cfg->lcore_role[idx] = ROLE_OFF; + } if(count == 0) return -1; return 0; diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index d7a59de..de082ab 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -330,10 +330,13 @@ eal_hugedirs_unlock(void) static void eal_usage(const char *prgname) { - printf("\nUsage: %s -c COREMASK -n NUM [-m NB] [-r NUM] [-b ]" + printf("\nUsage: %s -c CORESET -n NUM [-m NB] [-r NUM] [-b ]" "[--proc-type primary|secondary|auto] \n\n" "EAL options:\n" - " -c COREMASK : A hexadecimal bitmask of cores to run on\n" + " -c CORESET : Set of cores to run on, supports two different formats:\n" + " - A hexadecimal bitmask of cores starting with 0x\n" + " - A list of cores in following format c1[-c2][,c3[-c4]]...\n" + " where c1,c2,c3,... are core indexes between 0 and %d\n" " -n NUM : Number of memory channels\n" " -v : Display version information on startup\n" " -d LIB.so : add driver (can be used multiple times)\n" @@ -368,7 +371,7 @@ eal_usage(const char *prgname) " --"OPT_NO_HPET" : disable hpet\n" " --"OPT_NO_SHCONF": no shared config (mmap'd files)\n" "\n", - prgname); + prgname, RTE_MAX_LCORE-1); /* Allow the application to print its usage message too if hook is set */ if ( rte_application_usage_hook ) { printf("===== Application Usage =====\n\n"); @@ -422,42 +425,84 @@ eal_parse_coremask(const char *coremask) while (isblank(*coremask)) coremask++; if (coremask[0] == '0' && ((coremask[1] == 'x') - || (coremask[1] == 'X')) ) + || (coremask[1] == 'X')) ) { coremask += 2; - i = strnlen(coremask, PATH_MAX); - while ((i > 0) && isblank(coremask[i - 1])) - i--; - if (i == 0) - return -1; + i = strnlen(coremask, PATH_MAX); + while ((i > 0) && isblank(coremask[i - 1])) + i--; + if (i == 0) + return -1; - for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) { - c = coremask[i]; - if (isxdigit(c) == 0) { - /* invalid characters */ - return (-1); - } - val = xdigit2val(c); - for(j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE; j++, idx++) { - if((1 << j) & val) { - if (!lcore_config[idx].detected) { - RTE_LOG(ERR, EAL, "lcore %u " - "unavailable\n", idx); - return -1; + for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) { + c = coremask[i]; + if (isxdigit(c) == 0) { + /* invalid characters */ + return (-1); + } + val = xdigit2val(c); + for(j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE; j++, idx++) { + if((1 << j) & val) { + if (!lcore_config[idx].detected) { + RTE_LOG(ERR, EAL, "lcore %u " + "unavailable\n", idx); + return -1; + } + cfg->lcore_role[idx] = ROLE_RTE; + if(count == 0) + cfg->master_lcore = idx; + count++; + } else { + cfg->lcore_role[idx] = ROLE_OFF; } - cfg->lcore_role[idx] = ROLE_RTE; - if(count == 0) - cfg->master_lcore = idx; - count++; - } else { - cfg->lcore_role[idx] = ROLE_OFF; } } - } - for(; i >= 0; i--) - if(coremask[i] != '0') + + for(; i >= 0; i--) + if(coremask[i] != '0') + return -1; + for(; idx < RTE_MAX_LCORE; idx++) + cfg->lcore_role[idx] = ROLE_OFF; + } else { + char *end = NULL; + int min, max; + + /* Reset core roles */ + for(idx = 0; idx < RTE_MAX_LCORE; idx++) + cfg->lcore_role[idx] = ROLE_OFF; + + /* else this is a list of cores */ + min = RTE_MAX_LCORE; + do { + while (isblank(*coremask)) + coremask++; + idx = strtoul(coremask, &end, 10); + if (end != NULL) { + while (isblank(*end)) + end++; + if (*end == '-') { + min = idx; + coremask = end + 1; + } else if ((*end == ',') || (*end == '\0')) { + max = idx; + if (min == RTE_MAX_LCORE) + min = idx; + for (idx=min; idx<=max; idx++) { + cfg->lcore_role[idx] = ROLE_RTE; + if(count == 0) + cfg->master_lcore = idx; + count++; + } + min = RTE_MAX_LCORE; + if (*end != '\0') + coremask = end + 1; + } else { + break; + } + } + } while ((*coremask != '\0') && (end != NULL) && (*end != '\0')); + if ((*coremask == '\0') || (end == NULL) || (*end != '\0')) return -1; - for(; idx < RTE_MAX_LCORE; idx++) - cfg->lcore_role[idx] = ROLE_OFF; + } if(count == 0) return -1; /* Update the count of enabled logical cores of the EAL configuration */ -- 1.7.10.4