- /*
- * browse lines of /proc/cpuinfo and fill memseg entries in
- * global configuration
- */
- while (fgets(buf, sizeof(buf), f) != NULL) {
-
- if (parse_processor_id(buf, &lcore_id) == 0)
- continue;
-
- if (parse_socket_id(buf, &socket_id) == 0)
- continue;
-
- if (buf[0] == '\n') {
- RTE_LOG(DEBUG, EAL, "Detected lcore %u on socket %u\n",
- lcore_id, socket_id);
- if (lcore_id >= RTE_MAX_LCORE) {
- RTE_LOG(DEBUG, EAL,
- "Skip lcore %u >= RTE_MAX_LCORE\n",
- lcore_id);
- continue;
- }
-
- /*
- * In a virtualization environment, the socket ID
- * reported by the system may not be linked to a real
- * physical socket ID, and may be incoherent. So in this
- * case, a default socket ID of 0 is assigned.
- */
- if (socket_id >= RTE_MAX_NUMA_NODES) {
-#ifdef CONFIG_RTE_EAL_ALLOW_INV_SOCKET_ID
- socket_id = 0;
-#else
- rte_panic("Socket ID (%u) is greater than "
- "RTE_MAX_NUMA_NODES (%d)\n",
- socket_id, RTE_MAX_NUMA_NODES);
-#endif
- }
-
- lcore_config[lcore_id].detected = 1;
- lcore_config[lcore_id].socket_id = socket_id;
-
- }
- }
-
- fclose(f);
-
- /* disable lcores that were not detected */
- RTE_LCORE_FOREACH(lcore_id) {
-
- if (lcore_config[lcore_id].detected == 0) {
- RTE_LOG(DEBUG, EAL, "Skip lcore %u (not detected)\n",
- lcore_id);
- config->lcore_role[lcore_id] = ROLE_OFF;
- }
- else
- count ++;
- }
-
- config->lcore_count = count;
-
+/* Get the cpu core id value from the /sys/.../cpuX core_id value */
+unsigned
+eal_cpu_core_id(unsigned lcore_id)
+{
+ char path[PATH_MAX];
+ unsigned long id;
+
+ int len = snprintf(path, sizeof(path), SYS_CPU_DIR "/%s", lcore_id, CORE_ID_FILE);
+ if (len <= 0 || (unsigned)len >= sizeof(path))
+ goto err;
+ if (eal_parse_sysfs_value(path, &id) != 0)
+ goto err;
+ return (unsigned)id;
+
+err:
+ RTE_LOG(ERR, EAL, "Error reading core id value from %s "
+ "for lcore %u - assuming core 0\n", SYS_CPU_DIR, lcore_id);