|
|
|||
File indexing completed on 2026-09-16 09:14:02
0001 /* 0002 * SPDX-License-Identifier: BSD-3-Clause 0003 * Copyright © 2013-2024 Inria. All rights reserved. 0004 * Copyright © 2016 Cisco Systems, Inc. All rights reserved. 0005 * Copyright © 2025 Siemens Corporation and/or its affiliates. All rights reserved. 0006 * See COPYING in top-level directory. 0007 */ 0008 0009 #ifndef HWLOC_PLUGINS_H 0010 #define HWLOC_PLUGINS_H 0011 0012 /** \file 0013 * \brief Public interface for building hwloc plugins. 0014 */ 0015 0016 struct hwloc_backend; 0017 0018 #include "hwloc.h" 0019 0020 #ifdef HWLOC_INSIDE_PLUGIN 0021 /* needed for hwloc_plugin_check_namespace() */ 0022 #ifdef HWLOC_HAVE_LTDL 0023 #include <ltdl.h> 0024 #elif !defined(HWLOC_WIN_SYS) 0025 #include <dlfcn.h> 0026 #endif 0027 #endif 0028 0029 0030 0031 /** \defgroup hwlocality_disc_components Components and Plugins: Discovery components and backends 0032 * 0033 * \note These structures and functions may change when ::HWLOC_COMPONENT_ABI is modified. 0034 * 0035 * @{ 0036 */ 0037 0038 /** \brief Discovery component structure 0039 * 0040 * This is the major kind of components, taking care of the discovery. 0041 * They are registered by generic components, either statically-built or as plugins. 0042 */ 0043 struct hwloc_disc_component { 0044 /** \brief Name. 0045 * If this component is built as a plugin, this name does not have to match the plugin filename. 0046 */ 0047 const char *name; 0048 0049 /** \brief Discovery phases performed by this component. 0050 * OR'ed set of ::hwloc_disc_phase_t 0051 */ 0052 unsigned phases; 0053 0054 /** \brief Component phases to exclude, as an OR'ed set of ::hwloc_disc_phase_t. 0055 * 0056 * For a GLOBAL component, this usually includes all other phases (\c ~UL). 0057 * 0058 * Other components only exclude types that may bring conflicting 0059 * topology information. MISC components should likely not be excluded 0060 * since they usually bring non-primary additional information. 0061 */ 0062 unsigned excluded_phases; 0063 0064 /** \brief Instantiate callback to create a backend from the component. 0065 * Parameters data1, data2, data3 are NULL except for components 0066 * that have special enabling routines such as hwloc_topology_set_xml(). */ 0067 struct hwloc_backend * (*instantiate)(struct hwloc_topology *topology, struct hwloc_disc_component *component, unsigned excluded_phases, const void *data1, const void *data2, const void *data3); 0068 0069 /** \brief Component priority. 0070 * Used to sort topology->components, higher priority first. 0071 * Also used to decide between two components with the same name. 0072 * 0073 * Usual values are 0074 * 50 for native OS (or platform) components, 0075 * 45 for x86, 0076 * 40 for no-OS fallback, 0077 * 30 for global components (xml, synthetic), 0078 * 20 for pci, 0079 * 10 for other misc components (opencl etc.). 0080 */ 0081 unsigned priority; 0082 0083 /** \brief Enabled by default. 0084 * If unset, if will be disabled unless explicitly requested. 0085 */ 0086 unsigned enabled_by_default; 0087 0088 /** \private Used internally to list components by priority on topology->components 0089 * (the component structure is usually read-only, 0090 * the core copies it before using this field for queueing) 0091 */ 0092 struct hwloc_disc_component * next; 0093 }; 0094 0095 /** \brief Discovery phase */ 0096 typedef enum hwloc_disc_phase_e { 0097 /** \brief xml or synthetic, platform-specific components such as bgq. 0098 * Discovers everything including CPU, memory, I/O and everything else. 0099 * A component with a Global phase usually excludes all other phases. 0100 * \hideinitializer */ 0101 HWLOC_DISC_PHASE_GLOBAL = (1U<<0), 0102 0103 /** \brief CPU discovery. 0104 * \hideinitializer */ 0105 HWLOC_DISC_PHASE_CPU = (1U<<1), 0106 0107 /** \brief Attach memory to existing CPU objects. 0108 * \hideinitializer */ 0109 HWLOC_DISC_PHASE_MEMORY = (1U<<2), 0110 0111 /** \brief Attach PCI devices and bridges to existing CPU objects. 0112 * \hideinitializer */ 0113 HWLOC_DISC_PHASE_PCI = (1U<<3), 0114 0115 /** \brief I/O discovery that requires PCI devices (OS devices such as OpenCL, CUDA, etc.). 0116 * \hideinitializer */ 0117 HWLOC_DISC_PHASE_IO = (1U<<4), 0118 0119 /** \brief Misc objects that gets added below anything else. 0120 * \hideinitializer */ 0121 HWLOC_DISC_PHASE_MISC = (1U<<5), 0122 0123 /** \brief Annotating existing objects, adding distances, etc. 0124 * \hideinitializer */ 0125 HWLOC_DISC_PHASE_ANNOTATE = (1U<<6), 0126 0127 /** \brief Final tweaks to a ready-to-use topology. 0128 * This phase runs once the topology is loaded, before it is returned to the topology. 0129 * Hence it may only use the main hwloc API for modifying the topology, 0130 * for instance by restricting it, adding info attributes, etc. 0131 * \hideinitializer */ 0132 HWLOC_DISC_PHASE_TWEAK = (1U<<7) 0133 } hwloc_disc_phase_t; 0134 0135 /** \brief Discovery status flags */ 0136 enum hwloc_disc_status_flag_e { 0137 /** \brief The sets of allowed resources were already retrieved \hideinitializer */ 0138 HWLOC_DISC_STATUS_FLAG_GOT_ALLOWED_RESOURCES = (1UL<<1) 0139 }; 0140 0141 /** \brief Discovery status structure 0142 * 0143 * Used by the core and backends to inform about what has been/is being done 0144 * during the discovery process. 0145 */ 0146 struct hwloc_disc_status { 0147 /** \brief The current discovery phase that is performed. 0148 * Must match one of the phases in the component phases field. 0149 */ 0150 hwloc_disc_phase_t phase; 0151 0152 /** \brief Dynamically excluded phases. 0153 * If a component decides during discovery that some phases are no longer needed. 0154 */ 0155 unsigned excluded_phases; 0156 0157 /** \brief OR'ed set of ::hwloc_disc_status_flag_e */ 0158 unsigned long flags; 0159 }; 0160 0161 /** \brief Discovery backend structure 0162 * 0163 * A backend is the instantiation of a discovery component. 0164 * When a component gets enabled for a topology, 0165 * its instantiate() callback creates a backend. 0166 * 0167 * hwloc_backend_alloc() initializes all fields to default values 0168 * that the component may change (except "component" and "next") 0169 * before enabling the backend with hwloc_backend_enable(). 0170 * 0171 * Most backends assume that the topology is_thissystem flag is 0172 * set because they talk to the underlying operating system. 0173 * However they may still be used in topologies without the 0174 * is_thissystem flag for debugging reasons. 0175 * In practice, they are usually auto-disabled in such cases 0176 * (excluded by xml or synthetic backends, or by environment 0177 * variables when changing the Linux fsroot or the x86 cpuid path). 0178 */ 0179 struct hwloc_backend { 0180 /** \private Reserved for the core, set by hwloc_backend_alloc() */ 0181 struct hwloc_disc_component * component; 0182 /** \private Reserved for the core, set by hwloc_backend_enable() */ 0183 struct hwloc_topology * topology; 0184 /** \private Reserved for the core. Set to 1 if forced through envvar, 0 otherwise. */ 0185 int envvar_forced; 0186 /** \private Reserved for the core. Used internally to list backends topology->backends. */ 0187 struct hwloc_backend * next; 0188 0189 /** \brief Discovery phases performed by this component, possibly without some of them if excluded by other components. 0190 * OR'ed set of ::hwloc_disc_phase_t 0191 */ 0192 unsigned phases; 0193 0194 /** \brief Backend flags, currently always 0. */ 0195 unsigned long flags; 0196 0197 /** \brief Backend-specific 'is_thissystem' property. 0198 * Set to 0 if the backend disables the thissystem flag for this topology 0199 * (e.g. loading from xml or synthetic string, 0200 * or using a different fsroot on Linux, or a x86 CPUID dump). 0201 * Set to -1 if the backend doesn't care (default). 0202 */ 0203 int is_thissystem; 0204 0205 /** \brief Backend private data, or NULL if none. */ 0206 void * private_data; 0207 /** \brief Callback for freeing the private_data. 0208 * May be NULL. 0209 */ 0210 void (*disable)(struct hwloc_backend *backend); 0211 0212 /** \brief Main discovery callback. 0213 * returns -1 on error, either because it couldn't add its objects ot the existing topology, 0214 * or because of an actual discovery/gathering failure. 0215 * May be NULL. 0216 */ 0217 int (*discover)(struct hwloc_backend *backend, struct hwloc_disc_status *status); 0218 0219 /** \brief Callback to retrieve the locality of a PCI object. 0220 * Called by the PCI core when attaching PCI hierarchy to CPU objects. 0221 * May be NULL. 0222 */ 0223 int (*get_pci_busid_cpuset)(struct hwloc_backend *backend, struct hwloc_pcidev_attr_s *busid, hwloc_bitmap_t cpuset); 0224 }; 0225 0226 /** \brief Allocate a backend structure, set good default values, initialize backend->component and topology, etc. 0227 * The caller will then modify whatever needed, and call hwloc_backend_enable(). 0228 */ 0229 HWLOC_DECLSPEC struct hwloc_backend * hwloc_backend_alloc(struct hwloc_topology *topology, struct hwloc_disc_component *component); 0230 0231 /** \brief Enable a previously allocated and setup backend. */ 0232 HWLOC_DECLSPEC int hwloc_backend_enable(struct hwloc_backend *backend); 0233 0234 /** @} */ 0235 0236 0237 0238 0239 /** \defgroup hwlocality_generic_components Components and Plugins: Generic components 0240 * 0241 * \note These structures and functions may change when ::HWLOC_COMPONENT_ABI is modified. 0242 * 0243 * @{ 0244 */ 0245 0246 /** \brief Generic component type */ 0247 typedef enum hwloc_component_type_e { 0248 /** \brief The data field must point to a struct hwloc_disc_component. */ 0249 HWLOC_COMPONENT_TYPE_DISC, 0250 0251 /** \brief The data field must point to a struct hwloc_xml_component. */ 0252 HWLOC_COMPONENT_TYPE_XML 0253 } hwloc_component_type_t; 0254 0255 /** \brief Generic component structure 0256 * 0257 * Generic components structure, either statically listed by configure in static-components.h 0258 * or dynamically loaded as a plugin. 0259 */ 0260 struct hwloc_component { 0261 /** \brief Component ABI version, set to ::HWLOC_COMPONENT_ABI */ 0262 unsigned abi; 0263 0264 /** \brief Process-wide component initialization callback. 0265 * 0266 * This optional callback is called when the component is registered 0267 * to the hwloc core (after loading the plugin). 0268 * 0269 * When the component is built as a plugin, this callback 0270 * should call hwloc_check_plugin_namespace() 0271 * and return an negative error code on error. 0272 * 0273 * \p flags is always 0 for now. 0274 * 0275 * \return 0 on success, or a negative code on error. 0276 * 0277 * \note If the component uses ltdl for loading its own plugins, 0278 * it should load/unload them only in init() and finalize(), 0279 * to avoid race conditions with hwloc's use of ltdl. 0280 */ 0281 int (*init)(unsigned long flags); 0282 0283 /** \brief Process-wide component termination callback. 0284 * 0285 * This optional callback is called after unregistering the component 0286 * from the hwloc core (before unloading the plugin). 0287 * 0288 * \p flags is always 0 for now. 0289 * 0290 * \note If the component uses ltdl for loading its own plugins, 0291 * it should load/unload them only in init() and finalize(), 0292 * to avoid race conditions with hwloc's use of ltdl. 0293 */ 0294 void (*finalize)(unsigned long flags); 0295 0296 /** \brief Component type */ 0297 hwloc_component_type_t type; 0298 0299 /** \brief Component flags, unused for now */ 0300 unsigned long flags; 0301 0302 /** \brief Component data, pointing to a struct hwloc_disc_component or struct hwloc_xml_component. */ 0303 void * data; 0304 }; 0305 0306 /** \brief Make sure that plugins can lookup core symbols. 0307 * 0308 * This is a sanity check to avoid lazy-lookup failures when libhwloc 0309 * is loaded within a plugin, and later tries to load its own plugins. 0310 * This may fail (and abort the program) if libhwloc symbols are in a 0311 * private namespace. 0312 * 0313 * \return 0 on success. 0314 * \return -1 if the plugin cannot be successfully loaded. The caller 0315 * plugin init() callback should return a negative error code as well. 0316 * 0317 * Plugins should call this function in their init() callback to avoid 0318 * later crashes if lazy symbol resolution is used by the upper layer that 0319 * loaded hwloc (e.g. OpenCL implementations using dlopen with RTLD_LAZY). 0320 * 0321 * \note The build system must define HWLOC_INSIDE_PLUGIN if and only if 0322 * building the caller as a plugin. 0323 * 0324 * \note This function should remain inline so plugins can call it even 0325 * when they cannot find libhwloc symbols. 0326 */ 0327 static __hwloc_inline int 0328 hwloc_plugin_check_namespace(const char *pluginname __hwloc_attribute_unused, const char *symbol __hwloc_attribute_unused) 0329 { 0330 #ifdef HWLOC_INSIDE_PLUGIN 0331 void *sym; 0332 #ifdef HWLOC_HAVE_LTDL 0333 lt_dlhandle handle = lt_dlopen(NULL); 0334 #elif defined(HWLOC_WIN_SYS) 0335 HMODULE handle = GetModuleHandleA(NULL); 0336 #else 0337 void *handle = dlopen(NULL, RTLD_NOW|RTLD_LOCAL); 0338 #endif 0339 if (!handle) 0340 /* cannot check, assume things will work */ 0341 return 0; 0342 #ifdef HWLOC_HAVE_LTDL 0343 sym = lt_dlsym(handle, symbol); 0344 lt_dlclose(handle); 0345 #elif defined(HWLOC_WIN_SYS) 0346 sym = GetModuleHandleA("hwloc.dll"); 0347 FreeLibrary(handle); 0348 #else 0349 sym = dlsym(handle, symbol); 0350 dlclose(handle); 0351 #endif 0352 if (!sym) { 0353 static int verboseenv_checked = 0; 0354 static int verboseenv_value = 0; 0355 if (!verboseenv_checked) { 0356 const char *verboseenv = getenv("HWLOC_PLUGINS_VERBOSE"); 0357 verboseenv_value = verboseenv ? atoi(verboseenv) : 0; 0358 verboseenv_checked = 1; 0359 } 0360 if (verboseenv_value) 0361 fprintf(stderr, "Plugin `%s' disabling itself because it cannot find the `%s' core symbol.\n", 0362 pluginname, symbol); 0363 return -1; 0364 } 0365 #endif /* HWLOC_INSIDE_PLUGIN */ 0366 return 0; 0367 } 0368 0369 /** @} */ 0370 0371 0372 0373 0374 /** \defgroup hwlocality_components_core_funcs Components and Plugins: Core functions to be used by components 0375 * 0376 * \note These structures and functions may change when ::HWLOC_COMPONENT_ABI is modified. 0377 * 0378 * @{ 0379 */ 0380 0381 /** \brief Check whether error messages are hidden. 0382 * 0383 * Callers should print critical error messages 0384 * (e.g. invalid hw topo info, invalid config) 0385 * only if this function returns strictly less than 2. 0386 * 0387 * Callers should print non-critical error messages 0388 * (e.g. failure to initialize CUDA) 0389 * if this function returns 0. 0390 * 0391 * This function return 1 by default (show critical only), 0392 * 0 in lstopo (show all), 0393 * or anything set in HWLOC_HIDE_ERRORS in the environment. 0394 * 0395 * Use macros HWLOC_SHOW_CRITICAL_ERRORS() and HWLOC_SHOW_ALL_ERRORS() 0396 * for clarity. 0397 */ 0398 HWLOC_DECLSPEC int hwloc_hide_errors(void); 0399 0400 #define HWLOC_SHOW_CRITICAL_ERRORS() (hwloc_hide_errors() < 2) 0401 #define HWLOC_SHOW_ALL_ERRORS() (hwloc_hide_errors() == 0) 0402 0403 /** \brief Add an object to the topology. 0404 * 0405 * Insert new object \p obj in the topology starting under existing object \p root 0406 * (if \c NULL, the topology root object is used). 0407 * 0408 * It is sorted along the tree of other objects according to the inclusion of 0409 * cpusets, to eventually be added as a child of the smallest object including 0410 * this object. 0411 * 0412 * If the cpuset is empty, the type of the object (and maybe some attributes) 0413 * must be enough to find where to insert the object. This is especially true 0414 * for NUMA nodes with memory and no CPUs. 0415 * 0416 * The given object should not have children. 0417 * 0418 * This shall only be called before levels are built. 0419 * 0420 * The caller should check whether the object type is filtered-out before calling this function. 0421 * 0422 * The topology cpuset/nodesets will be enlarged to include the object sets. 0423 * 0424 * \p reason is a unique string identifying where and why this insertion call was performed 0425 * (it will be displayed in case of internal insertion error). 0426 * 0427 * Returns the object on success. 0428 * Returns NULL and frees obj on error. 0429 * Returns another object and frees obj if it was merged with an identical pre-existing object. 0430 */ 0431 HWLOC_DECLSPEC hwloc_obj_t 0432 hwloc__insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t root, 0433 hwloc_obj_t obj, const char *reason); 0434 0435 /** \brief Insert an object somewhere in the topology. 0436 * 0437 * It is added as the last child of the given parent. 0438 * The cpuset is completely ignored, so strange objects such as I/O devices should 0439 * preferably be inserted with this. 0440 * 0441 * When used for "normal" children with cpusets (when importing from XML 0442 * when duplicating a topology), the caller should make sure that: 0443 * - children are inserted in order, 0444 * - children cpusets do not intersect. 0445 * 0446 * The given object may have normal, I/O or Misc children, as long as they are in order as well. 0447 * These children must have valid parent and next_sibling pointers. 0448 * 0449 * The caller should check whether the object type is filtered-out before calling this function. 0450 */ 0451 HWLOC_DECLSPEC void hwloc_insert_object_by_parent(struct hwloc_topology *topology, hwloc_obj_t parent, hwloc_obj_t obj); 0452 0453 /** \brief Allocate and initialize an object of the given type and physical index. 0454 * 0455 * If \p os_index is unknown or irrelevant, use \c HWLOC_UNKNOWN_INDEX. 0456 */ 0457 HWLOC_DECLSPEC hwloc_obj_t hwloc_alloc_setup_object(hwloc_topology_t topology, hwloc_obj_type_t type, unsigned os_index); 0458 0459 /** \brief Setup object cpusets/nodesets by OR'ing its children. 0460 * 0461 * Used when adding an object late in the topology. 0462 * Will update the new object by OR'ing all its new children sets. 0463 * 0464 * Used when PCI backend adds a hostbridge parent, when distances 0465 * add a new Group, etc. 0466 */ 0467 HWLOC_DECLSPEC int hwloc_obj_add_children_sets(hwloc_obj_t obj); 0468 0469 /** \brief Request a reconnection of children and levels in the topology. 0470 * 0471 * May be used by backends during discovery if they need arrays or lists 0472 * of object within levels or children to be fully connected. 0473 * 0474 * \p flags is currently unused, must 0. 0475 */ 0476 HWLOC_DECLSPEC int hwloc_topology_reconnect(hwloc_topology_t topology, unsigned long flags __hwloc_attribute_unused); 0477 0478 /** @} */ 0479 0480 0481 0482 0483 /** \defgroup hwlocality_components_filtering Components and Plugins: Filtering objects 0484 * 0485 * \note These structures and functions may change when ::HWLOC_COMPONENT_ABI is modified. 0486 * 0487 * @{ 0488 */ 0489 0490 /** \brief Check whether the given PCI device classid is important. 0491 * 0492 * \return 1 if important, 0 otherwise. 0493 */ 0494 static __hwloc_inline int 0495 hwloc_filter_check_pcidev_subtype_important(unsigned classid) 0496 { 0497 unsigned baseclass = classid >> 8; 0498 return (baseclass == 0x03 /* PCI_BASE_CLASS_DISPLAY */ 0499 || baseclass == 0x02 /* PCI_BASE_CLASS_NETWORK */ 0500 || baseclass == 0x01 /* PCI_BASE_CLASS_STORAGE */ 0501 || baseclass == 0x00 /* Unclassified, for Atos/Bull BXI */ 0502 || baseclass == 0x0b /* PCI_BASE_CLASS_PROCESSOR */ 0503 || classid == 0x0c04 /* PCI_CLASS_SERIAL_FIBER */ 0504 || classid == 0x0c06 /* PCI_CLASS_SERIAL_INFINIBAND */ 0505 || classid == 0x0502 /* PCI_CLASS_MEMORY_CXL */ 0506 || baseclass == 0x06 /* PCI_BASE_CLASS_BRIDGE with non-PCI downstream. the core will drop the useless ones later */ 0507 || baseclass == 0x12 /* Processing Accelerators */); 0508 } 0509 0510 /** \brief Check whether the given OS device subtype is important. 0511 * 0512 * \return 1 if important, 0 otherwise. 0513 */ 0514 static __hwloc_inline int 0515 hwloc_filter_check_osdev_subtype_important(hwloc_obj_osdev_type_t subtype) 0516 { 0517 return (subtype != HWLOC_OBJ_OSDEV_DMA); 0518 } 0519 0520 /** \brief Check whether a non-I/O object type should be filtered-out. 0521 * 0522 * Cannot be used for I/O objects. 0523 * 0524 * \return 1 if the object type should be kept, 0 otherwise. 0525 */ 0526 static __hwloc_inline int 0527 hwloc_filter_check_keep_object_type(hwloc_topology_t topology, hwloc_obj_type_t type) 0528 { 0529 enum hwloc_type_filter_e filter = HWLOC_TYPE_FILTER_KEEP_NONE; 0530 hwloc_topology_get_type_filter(topology, type, &filter); 0531 assert(filter != HWLOC_TYPE_FILTER_KEEP_IMPORTANT); /* IMPORTANT only used for I/O */ 0532 return filter == HWLOC_TYPE_FILTER_KEEP_NONE ? 0 : 1; 0533 } 0534 0535 /** \brief Check whether the given object should be filtered-out. 0536 * 0537 * \return 1 if the object type should be kept, 0 otherwise. 0538 */ 0539 static __hwloc_inline int 0540 hwloc_filter_check_keep_object(hwloc_topology_t topology, hwloc_obj_t obj) 0541 { 0542 hwloc_obj_type_t type = obj->type; 0543 enum hwloc_type_filter_e filter = HWLOC_TYPE_FILTER_KEEP_NONE; 0544 hwloc_topology_get_type_filter(topology, type, &filter); 0545 if (filter == HWLOC_TYPE_FILTER_KEEP_NONE) 0546 return 0; 0547 if (filter == HWLOC_TYPE_FILTER_KEEP_IMPORTANT) { 0548 if (type == HWLOC_OBJ_PCI_DEVICE) 0549 return hwloc_filter_check_pcidev_subtype_important(obj->attr->pcidev.class_id); 0550 if (type == HWLOC_OBJ_OS_DEVICE) 0551 return hwloc_filter_check_osdev_subtype_important(obj->attr->osdev.type); 0552 } 0553 return 1; 0554 } 0555 0556 /** @} */ 0557 0558 0559 0560 0561 /** \defgroup hwlocality_components_pcidisc Components and Plugins: helpers for PCI discovery 0562 * 0563 * \note These structures and functions may change when ::HWLOC_COMPONENT_ABI is modified. 0564 * 0565 * @{ 0566 */ 0567 0568 /** \brief Return the offset of the given capability in the PCI config space buffer 0569 * 0570 * This function requires a 256-bytes config space. Unknown/unavailable bytes should be set to 0xff. 0571 */ 0572 HWLOC_DECLSPEC unsigned hwloc_pcidisc_find_cap(const unsigned char *config, unsigned cap); 0573 0574 /** \brief Fill linkspeed by reading the PCI config space where PCI_CAP_ID_EXP is at position offset. 0575 * 0576 * Needs 20 bytes of EXP capability block starting at offset in the config space 0577 * for registers up to link status. 0578 */ 0579 HWLOC_DECLSPEC int hwloc_pcidisc_find_linkspeed(const unsigned char *config, unsigned offset, float *linkspeed); 0580 0581 /** \brief Return the hwloc object type (PCI device or Bridge) for the given class and configuration space. 0582 * 0583 * This function requires 16 bytes of common configuration header at the beginning of config. 0584 */ 0585 HWLOC_DECLSPEC hwloc_obj_type_t hwloc_pcidisc_check_bridge_type(unsigned device_class, const unsigned char *config); 0586 0587 /** \brief Fills the attributes of the given PCI bridge using the given PCI config space. 0588 * 0589 * This function requires 32 bytes of common configuration header at the beginning of config. 0590 * 0591 * Returns -1 and destroys /p obj if bridge fields are invalid. 0592 */ 0593 HWLOC_DECLSPEC int hwloc_pcidisc_find_bridge_buses(unsigned domain, unsigned bus, unsigned dev, unsigned func, 0594 unsigned *secondary_busp, unsigned *subordinate_busp, 0595 const unsigned char *config); 0596 0597 /** \brief Insert a PCI object in the given PCI tree by looking at PCI bus IDs. 0598 * 0599 * If \p treep points to \c NULL, the new object is inserted there. 0600 */ 0601 HWLOC_DECLSPEC void hwloc_pcidisc_tree_insert_by_busid(struct hwloc_obj **treep, struct hwloc_obj *obj); 0602 0603 /** \brief Add some hostbridges on top of the given tree of PCI objects and attach them to the topology. 0604 * 0605 * Other backends may lookup PCI objects or localities (for instance to attach OS devices) 0606 * by using hwloc_pcidisc_find_by_busid() or hwloc_pcidisc_find_busid_parent(). 0607 */ 0608 HWLOC_DECLSPEC int hwloc_pcidisc_tree_attach(struct hwloc_topology *topology, struct hwloc_obj *tree); 0609 0610 /** @} */ 0611 0612 0613 0614 0615 /** \defgroup hwlocality_components_pcifind Components and Plugins: finding PCI objects during other discoveries 0616 * 0617 * \note These structures and functions may change when ::HWLOC_COMPONENT_ABI is modified. 0618 * 0619 * @{ 0620 */ 0621 0622 /** \brief Find the object or a parent of a PCI bus ID. 0623 * 0624 * When attaching a new object (typically an OS device) whose locality 0625 * is specified by PCI bus ID, this function returns the PCI object 0626 * to use as a parent for attaching. 0627 * 0628 * If the exact PCI device with this bus ID exists, it is returned. 0629 * Otherwise (for instance if it was filtered out), the function returns 0630 * another object with similar locality (for instance a parent bridge, 0631 * or the local CPU Package). 0632 */ 0633 HWLOC_DECLSPEC struct hwloc_obj * hwloc_pci_find_parent_by_busid(struct hwloc_topology *topology, unsigned domain, unsigned bus, unsigned dev, unsigned func); 0634 0635 /** \brief Find the PCI device or bridge matching a PCI bus ID exactly. 0636 * 0637 * This is useful for adding specific information about some objects 0638 * based on their PCI id. When it comes to attaching objects based on 0639 * PCI locality, hwloc_pci_find_parent_by_busid() should be preferred. 0640 */ 0641 HWLOC_DECLSPEC struct hwloc_obj * hwloc_pci_find_by_busid(struct hwloc_topology *topology, unsigned domain, unsigned bus, unsigned dev, unsigned func); 0642 0643 0644 /** @} */ 0645 0646 0647 0648 0649 /** \defgroup hwlocality_components_distances Components and Plugins: distances 0650 * 0651 * \note These structures and functions may change when ::HWLOC_COMPONENT_ABI is modified. 0652 * 0653 * @{ 0654 */ 0655 0656 /** \brief Handle to a new distances structure during its addition to the topology. */ 0657 typedef void * hwloc_backend_distances_add_handle_t; 0658 0659 /** \brief Create a new empty distances structure. 0660 * 0661 * This is identical to hwloc_distances_add_create() 0662 * but this variant is designed for backend inserting 0663 * distances during topology discovery. 0664 */ 0665 HWLOC_DECLSPEC hwloc_backend_distances_add_handle_t 0666 hwloc_backend_distances_add_create(hwloc_topology_t topology, 0667 const char *name, unsigned long kind, 0668 unsigned long flags); 0669 0670 /** \brief Specify the objects and values in a new empty distances structure. 0671 * 0672 * This is similar to hwloc_distances_add_values() 0673 * but this variant is designed for backend inserting 0674 * distances during topology discovery. 0675 * 0676 * The only semantical difference is that \p objs and \p values 0677 * are not duplicated, but directly attached to the topology. 0678 * On success, these arrays are given to the core and should not 0679 * ever be freed by the caller anymore. 0680 */ 0681 HWLOC_DECLSPEC int 0682 hwloc_backend_distances_add_values(hwloc_topology_t topology, 0683 hwloc_backend_distances_add_handle_t handle, 0684 unsigned nbobjs, hwloc_obj_t *objs, 0685 hwloc_uint64_t *values, 0686 unsigned long flags); 0687 0688 /** \brief Commit a new distances structure. 0689 * 0690 * This is similar to hwloc_distances_add_commit() 0691 * but this variant is designed for backend inserting 0692 * distances during topology discovery. 0693 */ 0694 HWLOC_DECLSPEC int 0695 hwloc_backend_distances_add_commit(hwloc_topology_t topology, 0696 hwloc_backend_distances_add_handle_t handle, 0697 unsigned long flags); 0698 0699 /** @} */ 0700 0701 0702 0703 0704 #endif /* HWLOC_PLUGINS_H */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|