- /* get pointer to global configuration */
- config = rte_eal_get_configuration();
-
- /* open /proc/cpuinfo */
- f = fopen(PROC_CPUINFO, "r");
- if (f == NULL) {
- RTE_LOG(ERR, EAL, "%s(): Cannot find "PROC_CPUINFO"\n", __func__);
- return -1;
- }
-
- /*
- * 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);
-