From: Steven Luong Date: Mon, 15 May 2023 04:47:21 +0000 (-0700) Subject: dpdk: Be wary of the return value from rte_eth_dev_socket_id X-Git-Tag: v23.10-rc0~36 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=e77af765e2c4eb2e1eb858c48441b1f236ed41f9;p=vpp.git dpdk: Be wary of the return value from rte_eth_dev_socket_id Prior to dpdk-22.11, VPP can count on rte_eth_dev_socket_id to return numa node 0 if the device didn't set it. Ever since below patch is committed in dpdk https://patchwork.dpdk.org/project/dpdk/patch/20220929120512.480-1-olivier.matz@6wind.com/#152498 the aforementioned assumption is no longer true. If the device didn't set the numa node, VPP gets -1 from the aforementioned API call. This causes VPP to crash. This fix is to set the numa node to 0 if the API returns -1, or SOCKET_ID_ANY Type: fix Change-Id: I2fde2870e5a3eb98473fe8d119fef594bfba9a8d Signed-off-by: Steven Luong --- diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c index 3eb1da55919..ad38694dc31 100644 --- a/src/plugins/dpdk/device/init.c +++ b/src/plugins/dpdk/device/init.c @@ -268,6 +268,7 @@ dpdk_lib_init (dpdk_main_t * dm) dpdk_device_config_t *devconf = 0; vnet_eth_interface_registration_t eir = {}; dpdk_driver_t *dr; + i8 numa_node; if (!rte_eth_dev_is_valid_port (port_id)) continue; @@ -448,7 +449,12 @@ dpdk_lib_init (dpdk_main_t * dm) eir.cb.set_max_frame_size = dpdk_set_max_frame_size; xd->hw_if_index = vnet_eth_register_interface (vnm, &eir); hi = vnet_get_hw_interface (vnm, xd->hw_if_index); - hi->numa_node = xd->cpu_socket = (i8) rte_eth_dev_socket_id (port_id); + numa_node = (i8) rte_eth_dev_socket_id (port_id); + if (numa_node == SOCKET_ID_ANY) + /* numa_node is not set, default to 0 */ + hi->numa_node = xd->cpu_socket = 0; + else + hi->numa_node = xd->cpu_socket = numa_node; sw = vnet_get_hw_sw_interface (vnm, xd->hw_if_index); xd->sw_if_index = sw->sw_if_index; dpdk_log_debug ("[%u] interface %s created", port_id, hi->name);