Beispiel #1
0
int
rte_cfgfile_has_entry(struct rte_cfgfile *cfg, const char *sectionname,
		const char *entryname)
{
	return rte_cfgfile_get_entry(cfg, sectionname, entryname) != NULL;
}
Beispiel #2
0
static int
app_install_cfgfile(const char *file_name)
{
	struct rte_cfgfile *file;
	uint32_t n_cores, i;

	memset(app.cores, 0, sizeof(app.cores));

	if (file_name[0] == '\0')
		return -1;

	file = rte_cfgfile_load(file_name, 0);
	if (file == NULL) {
		rte_panic("Config file %s not found\n", file_name);
		return -1;
	}

	n_cores = (uint32_t) rte_cfgfile_num_sections(file, "core",
		strnlen("core", 5));
	if (n_cores < app.n_cores) {
		rte_panic("Config file parse error: not enough cores specified "
			"(%u cores missing)\n", app.n_cores - n_cores);
		return -1;
	}
	if (n_cores > app.n_cores) {
		rte_panic("Config file parse error: too many cores specified "
			"(%u cores too many)\n", n_cores - app.n_cores);
		return -1;
	}

	for (i = 0; i < n_cores; i++) {
		struct app_core_params *p = &app.cores[i];
		char section_name[16];
		const char *entry;
		uint32_t j;

		/* [core X] */
		snprintf(section_name, sizeof(section_name), "core %u", i);
		if (!rte_cfgfile_has_section(file, section_name)) {
			rte_panic("Config file parse error: core IDs are not "
				"sequential (core %u missing)\n", i);
			return -1;
		}

		/* type */
		entry = rte_cfgfile_get_entry(file, section_name, "type");
		if (!entry) {
			rte_panic("Config file parse error: core %u type not "
				"defined\n", i);
			return -1;
		}
		if ((app_core_type_string_to_id(entry, &p->core_type) != 0) ||
		    (p->core_type == APP_CORE_NONE)) {
			rte_panic("Config file parse error: core %u type "
				"error\n", i);
			return -1;
		}

		/* queues in */
		entry = rte_cfgfile_get_entry(file, section_name, "queues in");
		if (!entry) {
			rte_panic("Config file parse error: core %u queues in "
				"not defined\n", i);
			return -1;
		}

		for (j = 0; (j < APP_MAX_SWQ_PER_CORE) && (entry != NULL);
			j++) {
			char *next;

			p->swq_in[j] =  (uint32_t) strtol(entry, &next, 10);
			if (next == entry)
				break;
			entry = next;
		}

		if ((j != APP_MAX_SWQ_PER_CORE) || (*entry != '\0')) {
			rte_panic("Config file parse error: core %u queues in "
				"error\n", i);
			return -1;
		}

		/* queues out */
		entry = rte_cfgfile_get_entry(file, section_name, "queues out");
		if (!entry) {
			rte_panic("Config file parse error: core %u queues out "
				"not defined\n", i);
			return -1;
		}

		for (j = 0; (j < APP_MAX_SWQ_PER_CORE) && (entry != NULL);
			j++) {
			char *next;

			p->swq_out[j] =  (uint32_t) strtol(entry, &next, 10);
			if (next == entry)
				break;
			entry = next;
		}
		if ((j != APP_MAX_SWQ_PER_CORE) || (*entry != '\0')) {
			rte_panic("Config file parse error: core %u queues out "
				"error\n", i);
			return -1;
		}
	}

	rte_cfgfile_close(file);

	return 0;
}