-/*
- * Parse the coremask given as argument (hexadecimal string) and fill
- * the global configuration (core role and core count) with the parsed
- * value.
- */
-static int xdigit2val(unsigned char c)
-{
- int val;
- if(isdigit(c))
- val = c - '0';
- else if(isupper(c))
- val = c - 'A' + 10;
- else
- val = c - 'a' + 10;
- return val;
-}
-static int
-eal_parse_coremask(const char *coremask)
-{
- struct rte_config *cfg = rte_eal_get_configuration();
- int i, j, idx = 0 ;
- unsigned count = 0;
- char c;
- int val;
-
- if (coremask == NULL)
- return -1;
- /* Remove all blank characters ahead and after .
- * Remove 0x/0X if exists.
- */
- while (isblank(*coremask))
- coremask++;
- if (coremask[0] == '0' && ((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;
-
- 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;
- }
- }
- }
- for(; i >= 0; i--)
- if(coremask[i] != '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 */
- cfg->lcore_count = count;
- return 0;
-}
-
-static int
-eal_parse_syslog(const char *facility)
-{
- int i;
- static struct {
- const char *name;
- int value;
- } map[] = {
- { "auth", LOG_AUTH },
- { "cron", LOG_CRON },
- { "daemon", LOG_DAEMON },
- { "ftp", LOG_FTP },
- { "kern", LOG_KERN },
- { "lpr", LOG_LPR },
- { "mail", LOG_MAIL },
- { "news", LOG_NEWS },
- { "syslog", LOG_SYSLOG },
- { "user", LOG_USER },
- { "uucp", LOG_UUCP },
- { "local0", LOG_LOCAL0 },
- { "local1", LOG_LOCAL1 },
- { "local2", LOG_LOCAL2 },
- { "local3", LOG_LOCAL3 },
- { "local4", LOG_LOCAL4 },
- { "local5", LOG_LOCAL5 },
- { "local6", LOG_LOCAL6 },
- { "local7", LOG_LOCAL7 },
- { NULL, 0 }
- };
-
- for (i = 0; map[i].name; i++) {
- if (!strcmp(facility, map[i].name)) {
- internal_config.syslog_facility = map[i].value;
- return 0;
- }
- }
- return -1;
-}
-