|
72 | 72 | /* Factor to multiply with in order to get infinite latency */ |
73 | 73 | #define UCP_CONTEXT_INFINITE_LAT_FACTOR 100 |
74 | 74 |
|
75 | | -#define UCP_MLX_PREFIX "mlx" |
76 | | -#define UCP_MLX_DEFAULT_PORT "1" |
77 | | - |
78 | 75 | typedef enum ucp_transports_list_search_result { |
79 | 76 | UCP_TRANSPORTS_LIST_SEARCH_RESULT_PRIMARY = UCS_BIT(0), |
80 | 77 | UCP_TRANSPORTS_LIST_SEARCH_RESULT_AUX_IN_MAIN = UCS_BIT(1), |
@@ -1080,56 +1077,51 @@ ucp_config_is_tl_name_present(const ucs_config_names_array_t *tl_array, |
1080 | 1077 | tl_cfg_mask)); |
1081 | 1078 | } |
1082 | 1079 |
|
1083 | | -/* Return a pointer to the suffix of the device name, |
1084 | | - * or the end of the string if no suffix is found. */ |
1085 | | -static const char *ucp_get_dev_name_suffix(const char *dev_name) |
| 1080 | +static UCS_F_ALWAYS_INLINE void |
| 1081 | +ucp_get_dev_basename(const char *dev_name, char *dev_basename_p) |
1086 | 1082 | { |
1087 | 1083 | const char *colon = strchr(dev_name, ':'); |
1088 | | - if (colon == NULL) { |
1089 | | - return dev_name + strlen(dev_name); |
1090 | | - } |
1091 | | - return colon + 1; |
1092 | | -} |
| 1084 | + size_t basename_len; |
1093 | 1085 |
|
1094 | | -static inline int |
1095 | | -ucp_is_dev_mlx_default_port(const char *dev_name, const char *dev_name_suffix) |
1096 | | -{ |
1097 | | - return (!strncmp(dev_name, UCP_MLX_PREFIX, strlen(UCP_MLX_PREFIX))) && |
1098 | | - (!strcmp(dev_name_suffix, UCP_MLX_DEFAULT_PORT)); |
| 1086 | + if (colon != NULL) { |
| 1087 | + basename_len = colon - dev_name; |
| 1088 | + memcpy(dev_basename_p, dev_name, basename_len); |
| 1089 | + dev_basename_p[basename_len] = '\0'; |
| 1090 | + } else { |
| 1091 | + dev_basename_p[0] = '\0'; |
| 1092 | + } |
1099 | 1093 | } |
1100 | 1094 |
|
| 1095 | +/* go over the device list from the user and check (against the available resources) |
| 1096 | + * which can be satisfied */ |
1101 | 1097 | static int ucp_is_resource_in_device_list(const uct_tl_resource_desc_t *resource, |
1102 | 1098 | const ucs_config_names_array_t *devices, |
1103 | 1099 | uint64_t *dev_cfg_mask, |
1104 | 1100 | uct_device_type_t dev_type) |
1105 | 1101 | { |
1106 | | - char dev_name_base[UCT_DEVICE_NAME_MAX]; |
| 1102 | + char dev_basename[UCT_DEVICE_NAME_MAX]; |
1107 | 1103 | uint64_t mask, exclusive_mask; |
1108 | | - const char *dev_name_suffix; |
1109 | 1104 |
|
1110 | | - /* go over the device list from the user and check (against the available resources) |
1111 | | - * which can be satisfied */ |
1112 | 1105 | ucs_assert_always(devices[dev_type].count <= 64); /* Using uint64_t bitmap */ |
| 1106 | + |
| 1107 | + /* search for the full device name */ |
1113 | 1108 | mask = ucp_str_array_search((const char**)devices[dev_type].names, |
1114 | 1109 | devices[dev_type].count, resource->dev_name, |
1115 | 1110 | NULL); |
| 1111 | + mask |= ucp_str_array_search_in_ranges((const char**)devices[dev_type].names, |
| 1112 | + devices[dev_type].count, |
| 1113 | + resource->dev_name); |
1116 | 1114 |
|
| 1115 | + /* for network devices, also search for the base name (before the colon) */ |
1117 | 1116 | if (dev_type == UCT_DEVICE_TYPE_NET) { |
1118 | | - dev_name_suffix = ucp_get_dev_name_suffix(resource->dev_name); |
1119 | | - |
1120 | | - if (ucp_is_dev_mlx_default_port(resource->dev_name, dev_name_suffix)) { |
1121 | | - ucs_strncpy_zero(dev_name_base, resource->dev_name, |
1122 | | - (size_t)(dev_name_suffix - resource->dev_name)); |
1123 | | - |
1124 | | - /* search for the base name (ex: mlx5_0) */ |
| 1117 | + ucp_get_dev_basename(resource->dev_name, dev_basename); |
| 1118 | + if (*dev_basename != '\0') { |
1125 | 1119 | mask |= ucp_str_array_search((const char**)devices[dev_type].names, |
1126 | | - devices[dev_type].count, dev_name_base, |
| 1120 | + devices[dev_type].count, dev_basename, |
1127 | 1121 | NULL); |
1128 | | - |
1129 | | - /* search in ranges (ex: mlx5_[0-2]) */ |
1130 | 1122 | mask |= ucp_str_array_search_in_ranges( |
1131 | 1123 | (const char**)devices[dev_type].names, |
1132 | | - devices[dev_type].count, dev_name_base); |
| 1124 | + devices[dev_type].count, dev_basename); |
1133 | 1125 | } |
1134 | 1126 | } |
1135 | 1127 |
|
|
0 commit comments